Transforms raw RAG `/api/docs/search` API results into typed `SearchResult` rows for the `` dropdown, collapsing multiple financial entity-table rows into a single grouped result. ## Key Components ### Constants - **`SEARCH_GROUP_REPOS`** — `Set` of source repos whose rows should be collapsed into grouped results (financial tables only: cap table, KPIs, P&L, balance sheet, cash flow) - **`ENTITY_LABELS`** — Display label map from `sourceRepo` key to human-readable string (e.g. `'financial-cap-table'` → `'Cap Table'`) ### Exports - **`mapDocSearchResults(docs: DocSearchResult[]): SearchResult[]`** — Pure transform function; groups financial entity rows by `sourceRepo` while preserving insertion order, then maps each entry to the dropdown's `SearchResult` shape ## Usage Example ```typescript import { mapDocSearchResults } from './map-doc-search-results' const rawResults = await fetchDocSearch(query) const dropdownRows = mapDocSearchResults(rawResults) // Financial table rows are collapsed: // 12 cap-table rows → { title: "Cap Table (12 records)", metadata: { isGroup: true, items: [...] } } // Regular docs remain individual: // { id: '/docs/setup.md', title: 'Setup Guide', description: '...snippet...' } ``` ## Grouping Behavior | Source repo | Behavior | |---|---| | `financial-*` repos | Collapsed → single group row with record count | | `blog-posts`, `webinars`, etc. | Individual rows (each has a unique URL) | | All other docs | Individual rows with snippet as description | Grouped results carry a `metadata.isGroup: true` flag and a `metadata.items` array of the collapsed records. Non-markdown individual results use `doc.name` as description instead of the snippet. > **Note:** This is a pure transform with no side effects. Callers that need telemetry or navigation should wrap this function rather than importing hub-specific logic. ## Source [`map-doc-search-results.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/map-doc-search-results.ts)