Resolves the call-to-action contract for a single source row — determining its icon, destination URL, target platform, and Ask drill-in eligibility — for use across chat-adjacent surfaces (source chips, inline cards, search results). ## Key Components ### Interfaces - **`SourceRowInput`** — Describes the raw row data: `sourceRepo`, `documentType`, `id`, `title`, `externalUrl`, `targetPlatform`, and `path`. - **`SourceRowContext`** — Host-injected runtime context: `baseRoute`, `chipBasePlatform`, `currentPlatform`, `tableIdForDocumentType`, `composeContentUrl`, and `docPlatformTargets`. - **`SourceRowCTA`** — The resolved output contract: `icon`, `iconLabel`, `href`, `targetPlatform`, `askable`, and `chatRef`. ### Functions - **`resolveSourceRowCTA(row, ctx)`** — Core pure function. Derives the icon, resolves the destination URL through a priority chain, and determines Ask drill-in viability. - **`sourceRowCtxFromRuntime(runtime, surface)`** — Convenience builder that wires a `ChatRuntime` into a `SourceRowContext`, centralizing wiring shared by all call sites. - **`sanitizePath(path)`** — Strips unsafe characters from path strings to prevent traversal or query-string injection. ### Constants - **`DOC_TABLE_TYPES`** — `['markdown', 'data_room_doc']` — the document types that resolve via path-based navigation rather than requiring an `externalUrl`. ## Usage Example ```typescript import { resolveSourceRowCTA, sourceRowCtxFromRuntime } from './source-row-cta' const ctx = sourceRowCtxFromRuntime( { source: 'flamingo', composeContentUrl: runtime.composeContentUrl, docPlatformTargets: runtime.docPlatformTargets, }, { baseRoute: '/knowledge-base', chipBasePlatform: 'flamingo' }, ) const cta = resolveSourceRowCTA( { sourceRepo: 'blog-posts', documentType: 'blog_post', id: 'abc-123', title: 'How we built OpenFrame', externalUrl: 'https://flamingo.run/blog/abc-123', }, ctx, ) // cta.href → sanitized destination URL // cta.icon → React icon component // cta.askable → true (has id + documentType) // cta.chatRef → pre-built ChatRef for the Ask handler ``` **URL resolution priority (doc rows):** `docPlatformTargets[documentType]` → `chipBasePlatform` → `baseRoute` → `null`. All final hrefs pass through `safeHref()` to block `javascript:` / `data:` injection. **Source:** [`source-row-cta.ts`](https://github.com/flamingo-stack/openframe-oss-lib/blob/main/source-row-cta.ts)