Skip to content

Commit 31f132b

Browse files
authored
Merge pull request #6 from RoboFinSystems/feature/sec-adapter
feat(sec): SEC adapter, sectioned rendering, and externalized text blocks
2 parents 9b6fe5f + 1f831cf commit 31f132b

19 files changed

Lines changed: 4329 additions & 33 deletions

src/adapters/cypher.ts

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,31 @@
11
/**
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.
53
*
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.
88
*/
9+
import type { SecQuery } from './sec'
10+
import { fetchSecReportShell, fetchSecSection, mergeSecSections } from './sec'
911
import type { ReportAdapter } from './types'
1012

1113
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`. */
1917
reportId: string
2018
}
2119

2220
export function cypherAdapter(config: CypherAdapterConfig): ReportAdapter {
2321
return {
24-
source: `cypher:${config.graphId}/${config.reportId}`,
22+
source: `sec:${config.reportId}`,
2523
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))
2827
)
28+
return mergeSecSections(shell, sections)
2929
},
3030
}
3131
}

src/adapters/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
export { cypherAdapter } from './cypher'
22
export type { CypherAdapterConfig } from './cypher'
33
export { jsonldFileAdapter, parseJsonld } from './jsonld'
4+
export {
5+
fetchSecReportShell,
6+
fetchSecSection,
7+
mergeSecSections,
8+
parseStructureDefinition,
9+
} from './sec'
10+
export type { SecQuery, SecReportShell, SecSection } from './sec'
411
export { parseStore } from './store'
512
export type { ReportAdapter } from './types'

0 commit comments

Comments
 (0)