Skip to content
25 linesCodeBlameRaw
1import type { ProviderKind } from "@g1t/contracts";
2
3/**
4 * The workspace's integration setup pages, under `-/integrations/<section>`:
5 * one for each kind of provider connection. The directory at
6 * `-/integrations` links into them.
7 */
8export type IntegrationsSection = "models" | "alerts" | "trackers";
9
10const SECTIONS: Record<ProviderKind, IntegrationsSection> = {
11 models: "models",
12 alerts: "alerts",
13 tracker: "trackers",
14};
15
16/** The page a kind of provider is set up on. */
17export function integrationsSection(kind: ProviderKind): IntegrationsSection {
18 return SECTIONS[kind];
19}
20
21/** The kind of provider a section's page is for, or null when it is no section. */
22export function sectionKind(section: string | undefined): ProviderKind | null {
23 const found = (Object.keys(SECTIONS) as ProviderKind[]).find((kind) => SECTIONS[kind] === section);
24 return found ?? null;
25}