Provides static lookup maps and helper functions for resolving RAG table IDs to icon names, display labels, and document type mappings — designed to be server-safe so both server-side chat route handlers and client-side components can import from a single source. ## Key Components ### Constants | Export | Purpose | |---|---| | `SOURCE_ICON_NAMES` | Maps `RagTableConfig.id` → icon name string (resolved to a React component client-side via `icon-registry.ts`) | | `SOURCE_LABELS_BY_TABLE` | Maps `RagTableConfig.id` → human-readable display label used in chat chip strips | | `DEFAULT_DOCUMENT_TYPE_TO_TABLE_ID` | Reverse map from LLM-emitted `documentType` strings → `RagTableConfig.id` | ### Functions | Export | Signature | Behavior | |---|---|---| | `getSourceIconName` | `(tableId: string \| null \| undefined) => string \| undefined` | Returns icon name or `undefined` (caller decides fallback) | | `getSourceLabel` | `(tableId: string) => string` | Returns display label; falls back to raw `tableId` slug if unmapped | | `defaultTableIdForDocumentType` | `(documentType: string) => string \| null` | Default resolver for `useEmbeddedChat`; returns `null` for unknown types | ## Usage Example ```typescript import { getSourceIconName, getSourceLabel, defaultTableIdForDocumentType, } from '@/utils/source-icons' // Resolve icon name for a chip strip glyph const iconName = getSourceIconName('github-commits') // → 'github' // Resolve display label for a sub-message chip const label = getSourceLabel('hubspot-tickets-self') // → 'My Tickets' getSourceLabel('unknown-table') // → 'unknown-table' (fallback) // Map an LLM-emitted documentType to its RAG table const tableId = defaultTableIdForDocumentType('slack_message') // → 'slack-messages' defaultTableIdForDocumentType('custom_type') // → null ``` ## Architecture Notes - **Server-safe by design** — no `'use client'` banner; icon *names* live here while icon *components* remain client-only in `src/components/chat/utils/icon-registry.ts`. - The client-side chat barrel re-exports these helpers for ergonomic imports. - `DEFAULT_DOCUMENT_TYPE_TO_TABLE_ID` mirrors the hub's `tableIdForDocumentType()` registry; embedders needing tenant-specific overrides pass a custom callback to `useEmbeddedChat` instead. **Source:** [`src/utils/source-icons.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/src/utils/source-icons.ts)