mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-07-26 23:51:14 +02:00
feat(connector-constants): add grouping function for connectors by type and define ConnectorTypeRow interface
This commit is contained in:
parent
16d25a9aac
commit
45c5309dbb
1 changed files with 32 additions and 0 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { EnumConnectorName } from "@/contracts/enums/connector";
|
||||
import type { SearchSourceConnector } from "@/contracts/types/connector.types";
|
||||
|
||||
/**
|
||||
* Connectors retired during the MCP migration (no viable official MCP server).
|
||||
|
|
@ -278,6 +279,37 @@ export function getConnectorTitle(connectorType: string): string {
|
|||
);
|
||||
}
|
||||
|
||||
/** One row per connected connector type (multiple accounts collapsed into one). */
|
||||
export interface ConnectorTypeRow {
|
||||
type: string;
|
||||
title: string;
|
||||
connectors: SearchSourceConnector[];
|
||||
accountCount: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Collapse a flat connector list into one row per `connector_type`, titled for
|
||||
* display (MCP collapses to "MCP Servers") and sorted alphabetically. Shared by
|
||||
* the connectors panel's "Your connectors" rail and the composer add-menu so the
|
||||
* two lists never drift; callers layer their own extras (e.g. health) on top.
|
||||
*/
|
||||
export function groupConnectorsByType(connectors: SearchSourceConnector[]): ConnectorTypeRow[] {
|
||||
const byType = new Map<string, SearchSourceConnector[]>();
|
||||
for (const c of connectors) {
|
||||
const arr = byType.get(c.connector_type) ?? [];
|
||||
arr.push(c);
|
||||
byType.set(c.connector_type, arr);
|
||||
}
|
||||
return [...byType.entries()]
|
||||
.map(([type, list]) => ({
|
||||
type,
|
||||
title: type === EnumConnectorName.MCP_CONNECTOR ? "MCP Servers" : getConnectorTitle(type),
|
||||
connectors: list,
|
||||
accountCount: list.length,
|
||||
}))
|
||||
.sort((a, b) => a.title.localeCompare(b.title));
|
||||
}
|
||||
|
||||
// Composio Toolkits (available integrations via Composio)
|
||||
export const COMPOSIO_TOOLKITS = [
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue