forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconnectors.ts
More file actions
35 lines (29 loc) · 1.18 KB
/
Copy pathconnectors.ts
File metadata and controls
35 lines (29 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import type { Integration } from '@/types/user';
/**
* The Connectors page groups, in tab order: the app catalogue, the apps the
* user installed, the apps they built, and the external services that used to
* live under Settings → Integrations.
*/
export const CONNECTOR_TABS = ['explore', 'installed', 'my-apps', 'services'] as const;
export type ConnectorTab = (typeof CONNECTOR_TABS)[number];
export function connectorTabFromParam(value: string | null): ConnectorTab {
return CONNECTOR_TABS.includes(value as ConnectorTab)
? (value as ConnectorTab)
: 'explore';
}
export interface ConnectorSummary {
connected: number;
available: number;
}
/**
* Counts what the Connectors page can say about external services: services
* currently connected, and services that can be connected right now. A
* `coming_soon` service is neither — it has no control the user can act on.
*/
export function summarizeIntegrations(integrations: Integration[]): ConnectorSummary {
const actionable = integrations.filter((integration) => !integration.coming_soon);
return {
connected: actionable.filter((integration) => integration.connected).length,
available: actionable.length,
};
}