|
1 | 1 | /** |
2 | | - * The cypher / GraphQL adapter — a live graph database (an entity graph **or** |
3 | | - * the SEC repository) read read-only with an API key. One adapter for both: |
4 | | - * only the endpoint / `graphId` differ. |
| 2 | + * The cypher adapter — a whole-report `ReportAdapter` over the live SEC graph. |
5 | 3 | * |
6 | | - * Phase 2 (Mode B). Stubbed for now so the seam and the `./adapters` export |
7 | | - * surface are in place; the holon-viewer's SEC mode will drive its build-out. |
| 4 | + * This is a convenience wrapper: it loads the section list, then every section, |
| 5 | + * and merges them into one `NormalizedReport`. Apps that want responsive, |
| 6 | + * lazy-per-section loading should call `fetchSecReportShell` + `fetchSecSection` |
| 7 | + * directly (see `./sec`) rather than materializing a whole filing up front. |
8 | 8 | */ |
| 9 | +import type { SecQuery } from './sec' |
| 10 | +import { fetchSecReportShell, fetchSecSection, mergeSecSections } from './sec' |
9 | 11 | import type { ReportAdapter } from './types' |
10 | 12 |
|
11 | 13 | export interface CypherAdapterConfig { |
12 | | - /** GraphQL / cypher endpoint base URL. */ |
13 | | - endpoint: string |
14 | | - /** User-supplied API key (sent client-side; never app-managed). */ |
15 | | - apiKey: string |
16 | | - /** Target graph — an entity graph id or the SEC repository id. */ |
17 | | - graphId: string |
18 | | - /** The report to materialize. */ |
| 14 | + /** Injected transport over `POST /v1/graphs/{graphId}/query` (auth lives here). */ |
| 15 | + query: SecQuery |
| 16 | + /** The report to materialize — a `Report.identifier`. */ |
19 | 17 | reportId: string |
20 | 18 | } |
21 | 19 |
|
22 | 20 | export function cypherAdapter(config: CypherAdapterConfig): ReportAdapter { |
23 | 21 | return { |
24 | | - source: `cypher:${config.graphId}/${config.reportId}`, |
| 22 | + source: `sec:${config.reportId}`, |
25 | 23 | load: async () => { |
26 | | - throw new Error( |
27 | | - 'The cypher adapter is not implemented yet (phase 2 / Mode B — live SEC graph).' |
| 24 | + const shell = await fetchSecReportShell(config.query, config.reportId) |
| 25 | + const sections = await Promise.all( |
| 26 | + shell.sections.map((section) => fetchSecSection(config.query, shell, section)) |
28 | 27 | ) |
| 28 | + return mergeSecSections(shell, sections) |
29 | 29 | }, |
30 | 30 | } |
31 | 31 | } |
0 commit comments