@robosystems/report-components 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- export { e as CypherAdapterConfig, R as ReportAdapter, o as SecQuery, p as SecReportShell, q as SecSection, v as cypherAdapter, w as fetchSecReportShell, x as fetchSecSection, y as jsonldFileAdapter, z as mergeSecSections, G as parseJsonld, H as parseStore, J as parseStructureDefinition } from '../index-BS6_6h3l.js';
1
+ export { e as CypherAdapterConfig, R as ReportAdapter, p as SecQuery, q as SecReportShell, r as SecSection, S as SectionKind, w as cypherAdapter, x as fetchSecReportShell, y as fetchSecSection, z as jsonldFileAdapter, G as mergeSecSections, H as parseJsonld, J as parseStore, K as parseStructureDefinition, L as parseStructureName } from '../index-fEwdoTEH.js';
2
2
  import 'n3';
@@ -1,3 +1,3 @@
1
- export { cypherAdapter, fetchSecReportShell, fetchSecSection, jsonldFileAdapter, mergeSecSections, parseJsonld, parseStore, parseStructureDefinition } from '../chunk-RQXAMFTZ.js';
1
+ export { cypherAdapter, fetchSecReportShell, fetchSecSection, jsonldFileAdapter, mergeSecSections, parseJsonld, parseStore, parseStructureDefinition, parseStructureName } from '../chunk-GJL4ILVH.js';
2
2
  //# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
@@ -33,6 +33,11 @@ var IRI = {
33
33
  numericValue: NS.rs + "numericValue",
34
34
  stringValue: NS.rs + "stringValue",
35
35
  decimals: NS.rs + "decimals",
36
+ dimension: NS.rs + "dimension",
37
+ axis: NS.rs + "axis",
38
+ member: NS.rs + "member",
39
+ isExplicit: NS.rs + "isExplicit",
40
+ typedValue: NS.rs + "typedValue",
36
41
  blockType: NS.rs + "blockType",
37
42
  associationType: NS.rs + "associationType",
38
43
  hasAssociation: NS.rs + "hasAssociation",
@@ -197,6 +202,41 @@ function formatValue(value, fmt = {}) {
197
202
  return scaled < 0 ? `${symbol}(${abs}${suffix})` : `${symbol}${abs}${suffix}`;
198
203
  }
199
204
 
205
+ // src/sections.ts
206
+ var CORE_STATEMENT_TYPES = /* @__PURE__ */ new Set([
207
+ "balance_sheet",
208
+ "income_statement",
209
+ "cash_flow_statement",
210
+ "equity_statement",
211
+ "comprehensive_income"
212
+ ]);
213
+ function parseStructureDefinition(definition, canonicalType) {
214
+ const raw = (definition ?? "").trim();
215
+ const parts = raw.split(" - ");
216
+ let type = "";
217
+ let title = raw;
218
+ if (parts.length >= 3) {
219
+ type = parts[1].trim();
220
+ title = parts.slice(2).join(" - ").trim();
221
+ } else if (parts.length === 2) {
222
+ title = parts[1].trim();
223
+ }
224
+ let kind = "Other";
225
+ if (/cover/i.test(title)) kind = "Cover";
226
+ else if (type === "Statement") kind = "Statement";
227
+ else if (type === "Disclosure") kind = "Disclosure";
228
+ else if (type === "Document") kind = "Document";
229
+ if (canonicalType && CORE_STATEMENT_TYPES.has(canonicalType)) kind = "Statement";
230
+ return { title: title || raw || canonicalType || "Section", kind };
231
+ }
232
+ var SEC_ROLE_PREFIX = /^\s*\d+\s*-\s/;
233
+ function parseStructureName(name) {
234
+ if (!name) return { definition: null, title: null, kind: null };
235
+ if (!SEC_ROLE_PREFIX.test(name)) return { definition: name, title: name, kind: null };
236
+ const { title, kind } = parseStructureDefinition(name, null);
237
+ return { definition: name, title, kind };
238
+ }
239
+
200
240
  // src/adapters/sec.ts
201
241
  var ENTITY_META_Q = `
202
242
  MATCH (ent:Entity)-[:ENTITY_HAS_REPORT]->(r:Report {identifier: $rid})
@@ -283,32 +323,6 @@ function deriveNumericKind(row) {
283
323
  const balance = str(row, "balance");
284
324
  return balance === "debit" || balance === "credit" ? "monetary" : "other";
285
325
  }
286
- var CORE_STATEMENT_TYPES = /* @__PURE__ */ new Set([
287
- "balance_sheet",
288
- "income_statement",
289
- "cash_flow_statement",
290
- "equity_statement",
291
- "comprehensive_income"
292
- ]);
293
- function parseStructureDefinition(definition, canonicalType) {
294
- const raw = (definition ?? "").trim();
295
- const parts = raw.split(" - ");
296
- let type = "";
297
- let title = raw;
298
- if (parts.length >= 3) {
299
- type = parts[1].trim();
300
- title = parts.slice(2).join(" - ").trim();
301
- } else if (parts.length === 2) {
302
- title = parts[1].trim();
303
- }
304
- let kind = "Other";
305
- if (/cover/i.test(title)) kind = "Cover";
306
- else if (type === "Statement") kind = "Statement";
307
- else if (type === "Disclosure") kind = "Disclosure";
308
- else if (type === "Document") kind = "Document";
309
- if (canonicalType && CORE_STATEMENT_TYPES.has(canonicalType)) kind = "Statement";
310
- return { title: title || raw || canonicalType || "Section", kind };
311
- }
312
326
  function mapEntity(row) {
313
327
  if (!row) return null;
314
328
  const id = str(row, "entity_id");
@@ -335,6 +349,7 @@ async function fetchSecReportShell(query, reportId) {
335
349
  id: str(row, "sid") ?? "",
336
350
  title,
337
351
  kind,
352
+ definition: str(row, "definition"),
338
353
  canonicalType: str(row, "canonical_type"),
339
354
  order,
340
355
  factsetIds: factsets
@@ -497,6 +512,8 @@ async function fetchSecSection(query, shell, section) {
497
512
  blockType: section.canonicalType ?? "",
498
513
  roleUri: null,
499
514
  structureName: section.title,
515
+ definition: section.definition,
516
+ kind: section.kind,
500
517
  order: section.order
501
518
  };
502
519
  return {
@@ -560,6 +577,24 @@ function cypherAdapter(config) {
560
577
  }
561
578
  };
562
579
  }
580
+ function numericKindFromItemType(itemType) {
581
+ switch (itemType) {
582
+ case "monetary":
583
+ return "monetary";
584
+ case "perShare":
585
+ return "perShare";
586
+ case "shares":
587
+ return "shares";
588
+ case "percent":
589
+ return "percent";
590
+ case "pure":
591
+ return "pure";
592
+ case "integer":
593
+ return "integer";
594
+ default:
595
+ return void 0;
596
+ }
597
+ }
563
598
  var { namedNode } = DataFactory;
564
599
  function makeReaders(store) {
565
600
  const objects = (s, p) => store.getObjects(namedNode(s), namedNode(p), null);
@@ -581,6 +616,7 @@ function parseStore(store) {
581
616
  for (const id of subjectsOfType(IRI.Element)) {
582
617
  const balance = firstValue(id, IRI.balance);
583
618
  const periodType2 = firstValue(id, IRI.periodType);
619
+ const itemType = firstValue(id, IRI.itemType) ?? void 0;
584
620
  elements[id] = {
585
621
  id,
586
622
  qname: qname(id),
@@ -589,7 +625,8 @@ function parseStore(store) {
589
625
  periodType: periodType2 === "instant" || periodType2 === "duration" ? periodType2 : null,
590
626
  abstract: firstValue(id, IRI.abstract) === "true",
591
627
  monetary: firstValue(id, IRI.monetary) === "true",
592
- itemType: firstValue(id, IRI.itemType) ?? void 0
628
+ itemType,
629
+ numericKind: numericKindFromItemType(itemType)
593
630
  };
594
631
  }
595
632
  const periods = {};
@@ -625,6 +662,21 @@ function parseStore(store) {
625
662
  }
626
663
  const facts = [];
627
664
  for (const id of subjectsOfType(IRI.Fact)) {
665
+ const dimensions = [];
666
+ for (const d of objects(id, IRI.dimension)) {
667
+ const axis = firstValue(d.value, IRI.axis);
668
+ if (!axis) continue;
669
+ const member = firstValue(d.value, IRI.member);
670
+ const typedValue = firstValue(d.value, IRI.typedValue);
671
+ dimensions.push({
672
+ axis,
673
+ member: member ?? null,
674
+ axisLabel: elements[axis]?.label ?? humanize(axis),
675
+ memberLabel: member ? elements[member]?.label ?? humanize(member) : typedValue ?? "",
676
+ explicit: firstValue(d.value, IRI.isExplicit) === "true",
677
+ typedValue: typedValue ?? null
678
+ });
679
+ }
628
680
  facts.push({
629
681
  id,
630
682
  element: firstValue(id, IRI.element) ?? "",
@@ -634,7 +686,8 @@ function parseStore(store) {
634
686
  factSet: firstValue(id, IRI.factSet),
635
687
  value: toNumber(firstValue(id, IRI.numericValue)),
636
688
  textValue: firstValue(id, IRI.stringValue),
637
- decimals: firstValue(id, IRI.decimals)
689
+ decimals: firstValue(id, IRI.decimals),
690
+ dimensions: dimensions.length ? dimensions : void 0
638
691
  });
639
692
  }
640
693
  const informationBlocks = [];
@@ -653,11 +706,14 @@ function parseStore(store) {
653
706
  const structures = [];
654
707
  const assocStructure = /* @__PURE__ */ new Map();
655
708
  for (const id of subjectsOfType(IRI.Structure)) {
709
+ const { definition, title, kind } = parseStructureName(firstValue(id, IRI.structureName));
656
710
  structures.push({
657
711
  id,
658
712
  blockType: firstValue(id, IRI.blockType) ?? "",
659
713
  roleUri: firstValue(id, IRI.roleUri),
660
- structureName: firstValue(id, IRI.structureName),
714
+ structureName: title,
715
+ definition,
716
+ kind,
661
717
  // Filing sequence (SEC role-definition number) so buildPivots orders all
662
718
  // sections by the filer's order rather than the fixed four-primary fallback.
663
719
  order: toNumber(firstValue(id, IRI.structureOrder)) ?? void 0
@@ -729,6 +785,6 @@ function jsonldFileAdapter(doc, source = "holon.jsonld") {
729
785
  };
730
786
  }
731
787
 
732
- export { BLOCK_ORDER, BLOCK_TITLES, NS, currencySymbolFor, cypherAdapter, fetchSecReportShell, fetchSecSection, formatDate, formatMoney, formatPeriod, formatValue, humanize, humanizeDuration, isExternalFactUrl, jsonldFileAdapter, mergeSecSections, numericKindOf, parseJsonld, parseStore, parseStructureDefinition, qname };
733
- //# sourceMappingURL=chunk-RQXAMFTZ.js.map
734
- //# sourceMappingURL=chunk-RQXAMFTZ.js.map
788
+ export { BLOCK_ORDER, BLOCK_TITLES, NS, currencySymbolFor, cypherAdapter, fetchSecReportShell, fetchSecSection, formatDate, formatMoney, formatPeriod, formatValue, humanize, humanizeDuration, isExternalFactUrl, jsonldFileAdapter, mergeSecSections, numericKindOf, parseJsonld, parseStore, parseStructureDefinition, parseStructureName, qname };
789
+ //# sourceMappingURL=chunk-GJL4ILVH.js.map
790
+ //# sourceMappingURL=chunk-GJL4ILVH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants.ts","../src/format.ts","../src/sections.ts","../src/adapters/sec.ts","../src/adapters/cypher.ts","../src/adapters/store.ts","../src/adapters/jsonld.ts"],"names":["qname","periodType","Store"],"mappings":";;;;AAQO,IAAM,EAAA,GAAK;AAAA,EAChB,GAAA,EAAK,6CAAA;AAAA,EACL,EAAA,EAAI,+BAAA;AAAA,EACJ,MAAA,EAAQ,6CAAA;AAAA,EACR,IAAA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AAA,CAAM,GAAG,CAAA,GAAI,GAAA;AAG1D,EAAA,MAAM,MAAA,GAAU,MAAM,MAAA,CAAO,KAAA,CAAM,MAAM,EAAE,MAAA,EAAQ,uBAAuB,CAAA;AAC1E,EAAA,MAAM,KAAA,GAAQ,IAAIC,KAAAA,CAAM,IAAI,MAAA,CAAO,EAAE,MAAA,EAAQ,qBAAA,EAAuB,CAAA,CAAE,KAAA,CAAM,MAAM,CAAC,CAAA;AACnF,EAAA,OAAO,WAAW,KAAK,CAAA;AACzB;AAGO,SAAS,iBAAA,CAAkB,GAAA,EAAsB,MAAA,GAAS,cAAA,EAA+B;AAC9F,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,IAAA,EAAM,MAAM,WAAA,CAAY,GAAG;AAAA,GAC7B;AACF","file":"chunk-GJL4ILVH.js","sourcesContent":["/**\n * RDF vocabulary and display helpers shared across adapters and projection.\n *\n * A report holon mixes several vocabularies: `rs:` for structure, `skos:` for\n * human labels, and the XBRL family (`xlink:` / `xbrli:` / `link:`) for the\n * networks. These constants are the single source of truth for the full IRIs.\n */\n\nexport const NS = {\n rdf: 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',\n rs: 'https://robosystems.ai/vocab/',\n rsgaap: 'https://robosystems.ai/taxonomy/rs-gaap/v1/',\n skos: 'http://www.w3.org/2004/02/skos/core#',\n xlink: 'http://www.w3.org/1999/xlink#',\n xbrli: 'http://www.xbrl.org/2003/instance#',\n link: 'http://www.xbrl.org/2003/linkbase#',\n iso4217: 'http://www.xbrl.org/2003/iso4217#',\n} as const\n\n/** Frequently-referenced full IRIs, pre-concatenated for terseness. */\nexport const IRI = {\n type: NS.rdf + 'type',\n // rs: classes\n Report: NS.rs + 'Report',\n Fact: NS.rs + 'Fact',\n InformationBlock: NS.rs + 'InformationBlock',\n Structure: NS.rs + 'Structure',\n Association: NS.rs + 'Association',\n Element: NS.rs + 'Element',\n Period: NS.rs + 'Period',\n Unit: NS.rs + 'Unit',\n Entity: NS.rs + 'Entity',\n // rs: predicates\n element: NS.rs + 'element',\n period: NS.rs + 'period',\n unit: NS.rs + 'unit',\n entity: NS.rs + 'entity',\n factSet: NS.rs + 'factSet',\n numericValue: NS.rs + 'numericValue',\n stringValue: NS.rs + 'stringValue',\n decimals: NS.rs + 'decimals',\n dimension: NS.rs + 'dimension',\n axis: NS.rs + 'axis',\n member: NS.rs + 'member',\n isExplicit: NS.rs + 'isExplicit',\n typedValue: NS.rs + 'typedValue',\n blockType: NS.rs + 'blockType',\n associationType: NS.rs + 'associationType',\n hasAssociation: NS.rs + 'hasAssociation',\n roleUri: NS.rs + 'roleUri',\n structure: NS.rs + 'structure',\n structureName: NS.rs + 'structureName',\n structureOrder: NS.rs + 'structureOrder',\n abstract: NS.rs + 'abstract',\n monetary: NS.rs + 'monetary',\n itemType: NS.rs + 'itemType',\n legalName: NS.rs + 'legalName',\n country: NS.rs + 'country',\n // skos:\n prefLabel: NS.skos + 'prefLabel',\n // xlink:\n from: NS.xlink + 'from',\n to: NS.xlink + 'to',\n role: NS.xlink + 'role',\n // xbrli:\n instant: NS.xbrli + 'instant',\n startDate: NS.xbrli + 'startDate',\n endDate: NS.xbrli + 'endDate',\n periodType: NS.xbrli + 'periodType',\n balance: NS.xbrli + 'balance',\n measure: NS.xbrli + 'measure',\n // link:\n order: NS.link + 'order',\n weight: NS.link + 'weight',\n} as const\n\n/**\n * Prefixes for compacting concept IRIs to `prefix:Local`. Order matters — the\n * most specific namespace must come first so `rs-gaap:` wins over `rs:`.\n */\nconst PREFIXES: ReadonlyArray<readonly [string, string]> = [\n ['rs-gaap', NS.rsgaap],\n ['disclosures', 'https://robosystems.ai/taxonomy/rs-gaap/disclosures/v1/'],\n ['us-gaap', 'http://fasb.org/us-gaap/'],\n ['dei', 'http://xbrl.sec.gov/dei/'],\n ['rs', NS.rs],\n ['skos', NS.skos],\n ['xbrli', NS.xbrli],\n ['xlink', NS.xlink],\n ['link', NS.link],\n ['iso4217', NS.iso4217],\n]\n\n/** Compact a concept IRI to `prefix:Local` (e.g. `rs-gaap:Assets`). */\nexport function qname(iri: string): string {\n for (const [prefix, ns] of PREFIXES) {\n if (iri.startsWith(ns)) {\n return `${prefix}:${iri.slice(ns.length)}`\n }\n }\n const slash = iri.lastIndexOf('/')\n const hash = iri.lastIndexOf('#')\n return iri.slice(Math.max(slash, hash) + 1)\n}\n\n/**\n * Readable concept name from a local name when no `skos:prefLabel` is present —\n * splits CamelCase into words (`AssetsCurrent` → `Assets Current`). A graceful\n * fallback for bundles that predate label emit.\n */\nexport function humanize(iri: string): string {\n const local = qname(iri).split(':').pop() ?? iri\n return local.replace(/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/g, ' ')\n}\n\n/**\n * A large text-block / policy fact whose HTML (or plain-text) body is too big to\n * store inline, so the platform externalizes it to the public CDN and the fact's\n * value is the URL (`…/fact_<hash>.html` or `.txt`). The renderer fetches and\n * embeds these instead of printing the raw link.\n */\nexport function isExternalFactUrl(value: string | null | undefined): boolean {\n return !!value && /^https?:\\/\\/\\S+\\/fact_[0-9a-f]+\\.(html|txt)$/i.test(value)\n}\n\n/** Stable display order for the canonical statement blocks; others fall after. */\nexport const BLOCK_ORDER: Record<string, number> = {\n balance_sheet: 0,\n income_statement: 1,\n cash_flow_statement: 2,\n equity_statement: 3,\n}\n\n/** Friendly section headings keyed by block type. */\nexport const BLOCK_TITLES: Record<string, string> = {\n balance_sheet: 'Balance Sheet',\n income_statement: 'Income Statement',\n cash_flow_statement: 'Cash Flow Statement',\n equity_statement: 'Statement of Changes in Equity',\n}\n","/**\n * Pure formatting helpers shared by the projection and the components. No React\n * here, so the projection can depend on it without pulling in a renderer.\n */\nimport type { ElementInfo, NumericKind, PeriodInfo } from './model'\n\n/**\n * Accounting-style money: negatives in parentheses, no sign, an em-dash for\n * absent values. Matches the RoboLedger statement renderer.\n */\nexport function formatMoney(\n value: number | null | undefined,\n opts: { currencySymbol?: string } = {}\n): string {\n if (value === null || value === undefined || Number.isNaN(value)) return '—'\n const symbol = opts.currencySymbol ?? '$'\n const abs = Math.abs(value).toLocaleString('en-US', {\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })\n return value < 0 ? `${symbol}(${abs})` : `${symbol}${abs}`\n}\n\nconst MONTHS = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']\n\n/** `2024-03-31` → `Mar 31, 2024`. Falls back to the raw string if unparseable. */\nexport function formatDate(iso: string | null | undefined): string {\n if (!iso) return ''\n const m = /^(\\d{4})-(\\d{2})-(\\d{2})/.exec(iso)\n if (!m) return iso\n const [, year, month, day] = m\n const idx = Number(month) - 1\n return `${MONTHS[idx] ?? month} ${Number(day)}, ${year}`\n}\n\n/**\n * Humanize an ISO-8601 duration value (`P10Y` → \"10 years\", `P1Y6M` → \"1 year 6\n * months\", `P30D` → \"30 days\"), or null when the string is not a duration — so a\n * non-numeric fact that happens to start with \"P\" (a company name) is untouched.\n * XBRL `durationItemType` facts (debt maturities, lease terms) arrive as these\n * strings in the text path.\n */\nexport function humanizeDuration(value: string | null | undefined): string | null {\n if (!value) return null\n const m =\n /^(-)?P(?:(\\d+)Y)?(?:(\\d+)M)?(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+(?:\\.\\d+)?)S)?)?$/.exec(\n value.trim()\n )\n if (!m) return null\n const [, sign, y, mo, w, d, h, min, s] = m\n const parts: string[] = []\n const push = (n: string | undefined, unit: string): void => {\n if (n) parts.push(`${n} ${unit}${Number(n) === 1 ? '' : 's'}`)\n }\n push(y, 'year')\n push(mo, 'month')\n push(w, 'week')\n push(d, 'day')\n push(h, 'hour')\n push(min, 'minute')\n push(s, 'second')\n if (!parts.length) return null\n return `${sign ?? ''}${parts.join(' ')}`\n}\n\n/** A human description of a period — \"As of …\" for instants, a span for durations. */\nexport function formatPeriod(period: PeriodInfo): string {\n if (period.type === 'instant') {\n return `As of ${formatDate(period.instant ?? period.end)}`\n }\n return `${formatDate(period.startDate)} – ${formatDate(period.endDate ?? period.end)}`\n}\n\n/** The effective numeric kind of an element (explicit, else derived from monetary). */\nexport function numericKindOf(el: ElementInfo): NumericKind {\n return el.numericKind ?? (el.monetary ? 'monetary' : 'other')\n}\n\n/** Common currency symbols by ISO-4217 code; null for a non-currency unit. */\nconst CURRENCY_SYMBOLS: Record<string, string> = {\n USD: '$',\n EUR: '€',\n GBP: '£',\n JPY: '¥',\n CNY: '¥',\n CHF: 'CHF ',\n CAD: 'CA$',\n AUD: 'A$',\n HKD: 'HK$',\n INR: '₹',\n KRW: '₩',\n}\n\n/**\n * A display prefix for a monetary unit measure (`iso4217:USD` → `$`), else null.\n * Unknown currencies fall back to their code (`CHF `, `SEK `) rather than a wrong\n * dollar sign — this is what fixes non-USD facts rendering as `$`.\n */\nexport function currencySymbolFor(measure: string | null | undefined): string | null {\n if (!measure) return null\n const code = (measure.includes(':') ? measure.split(':').pop()! : measure).toUpperCase()\n if (CURRENCY_SYMBOLS[code]) return CURRENCY_SYMBOLS[code]\n // A currency-shaped code (3 letters) we don't have a glyph for → code prefix.\n return /^[A-Z]{3}$/.test(code) ? `${code} ` : null\n}\n\nexport interface ValueFormat {\n /** Drives symbol, scaling opt-out, and decimal places. Defaults to `monetary`. */\n numericKind?: NumericKind\n /** Currency symbol for monetary/per-share values (from the fact's unit). */\n symbol?: string | null\n /** Divide monetary values by this (e.g. 1e6 to show millions); default 1. */\n scaleFactor?: number\n}\n\n/**\n * Format a fact value for display: accounting style (negatives in parentheses,\n * em-dash for absent), the fact's own currency symbol (never a hard-coded `$`),\n * and the section scale — with per-share amounts and share counts never rescaled\n * (an EPS of 4.93 stays 4.93 under \"in millions\"). A `percent` fact stores a\n * decimal fraction, so it is scaled ×100 and suffixed with `%` (0.10 → 10%); a\n * `pure` fact is a bare ratio, shown as a plain decimal (no `%`).\n */\nexport function formatValue(value: number | null | undefined, fmt: ValueFormat = {}): string {\n if (value === null || value === undefined || Number.isNaN(value)) return '—'\n const kind = fmt.numericKind ?? 'monetary'\n const scale = kind === 'monetary' ? (fmt.scaleFactor ?? 1) : 1\n const scaled = kind === 'percent' ? value * 100 : value / scale\n\n let minFrac = 0\n let maxFrac = 0\n if (kind === 'perShare') {\n minFrac = maxFrac = 2\n } else if (kind === 'monetary') {\n minFrac = maxFrac = scale > 1 ? 0 : 2\n } else if (kind === 'percent') {\n maxFrac = 2\n } else if (kind === 'pure') {\n maxFrac = 4\n }\n\n const abs = Math.abs(scaled).toLocaleString('en-US', {\n minimumFractionDigits: minFrac,\n maximumFractionDigits: maxFrac,\n })\n const symbol = kind === 'monetary' || kind === 'perShare' ? (fmt.symbol ?? '') : ''\n const suffix = kind === 'percent' ? '%' : ''\n return scaled < 0 ? `${symbol}(${abs}${suffix})` : `${symbol}${abs}${suffix}`\n}\n","/**\n * Shared parsing of an XBRL structure's role definition into a display title, its\n * full raw definition, and a coarse `kind`. Used by BOTH the SEC adapter (whose\n * definitions are always SEC-shaped) and the jsonld/file adapter (whose structure\n * names may be non-SEC), so every source lands the same `StructureInfo` shape —\n * the section header and TOC read identically regardless of where the data came\n * from.\n */\n\n/** Coarse grouping for a section — the basis for a \"Statements / Disclosures\" TOC. */\nexport type SectionKind = 'Statement' | 'Disclosure' | 'Document' | 'Cover' | 'Other'\n\n/**\n * The primary financial statements. Only these `canonical_type`s belong in the\n * TOC's \"Financial Statements\" group — other canonical types (rollforwards,\n * hierarchies, `(Details)` networks) are disclosures, classified by their\n * definition's type word instead.\n */\nconst CORE_STATEMENT_TYPES = new Set([\n 'balance_sheet',\n 'income_statement',\n 'cash_flow_statement',\n 'equity_statement',\n 'comprehensive_income',\n])\n\n/**\n * Split an XBRL `Structure.definition` into a human title + a coarse kind.\n * Definitions look like `\"9952153 - Statement - Consolidated Balance Sheets\"` or\n * `\"0000001 - Document - Cover Page\"` — a `\"NNNN - <Type> - <Title>\"` shape whose\n * middle word (Statement / Disclosure / Document) drives the kind. A core\n * canonical statement always reads as a Statement so the primaries group cleanly.\n */\nexport function parseStructureDefinition(\n definition: string | null,\n canonicalType: string | null\n): { title: string; kind: SectionKind } {\n const raw = (definition ?? '').trim()\n const parts = raw.split(' - ')\n let type = ''\n let title = raw\n if (parts.length >= 3) {\n type = parts[1].trim()\n title = parts.slice(2).join(' - ').trim()\n } else if (parts.length === 2) {\n title = parts[1].trim()\n }\n\n let kind: SectionKind = 'Other'\n if (/cover/i.test(title)) kind = 'Cover'\n else if (type === 'Statement') kind = 'Statement'\n else if (type === 'Disclosure') kind = 'Disclosure'\n else if (type === 'Document') kind = 'Document'\n // A core statement is always a Statement; a non-core canonical type (e.g.\n // GoodwillRollForward) stays whatever its definition type word made it.\n if (canonicalType && CORE_STATEMENT_TYPES.has(canonicalType)) kind = 'Statement'\n\n return { title: title || raw || canonicalType || 'Section', kind }\n}\n\n// A SEC role definition's signature: a leading numeric sort code immediately\n// followed by \" - \". Only names with that shape are parsed; anything else (a\n// non-SEC holon's plain structure name) is left untouched, so this never\n// over-strips a name that merely happens to contain \" - \".\nconst SEC_ROLE_PREFIX = /^\\s*\\d+\\s*-\\s/\n\n/**\n * Parse a structure NAME as carried on a holon's `rs:structureName`, the same way\n * as a SEC definition but only when it is SEC-shaped. Returns the full definition\n * (verbatim, for hover), a clean display title, and the kind (null for a non-SEC\n * name, whose title is just the name).\n */\nexport function parseStructureName(name: string | null): {\n definition: string | null\n title: string | null\n kind: SectionKind | null\n} {\n if (!name) return { definition: null, title: null, kind: null }\n if (!SEC_ROLE_PREFIX.test(name)) return { definition: name, title: name, kind: null }\n const { title, kind } = parseStructureDefinition(name, null)\n return { definition: name, title, kind }\n}\n","/**\n * The SEC adapter — reconstructs a report from the live SEC EDGAR graph\n * (`graph_id = \"sec\"`) via read-only Cypher, one section at a time.\n *\n * A single SEC filing is a large graph: a 10-K is ~90 `Structure`s (the 5 core\n * statements plus dozens of disclosure/document networks), thousands of facts.\n * Loading the whole thing up front is slow, so this module splits the work:\n *\n * - `fetchSecReportShell` — one fast pass that returns the entity + the ordered\n * **section list** (each `Structure` with its title, kind, and factset ids).\n * - `fetchSecSection` — on demand, the facts + presentation/calculation network\n * for **one** section, assembled into a single-section `NormalizedReport` the\n * shared projection/components render unchanged.\n *\n * The library stays transport-agnostic: the caller injects a `SecQuery` (a thin\n * wrapper over `POST /v1/graphs/sec/query`); this module owns only the Cypher and\n * the row → model mapping.\n *\n * ── Query rules (load-bearing; verified against the live graph) ────────────────\n * These are not stylistic — violating them turns a ~120 ms query into a ~14 s one:\n * 1. **Anchor on a primary key.** Lead per-section queries with a direct\n * `{identifier: $id}` match on `FactSet`/`Structure` (indexed). Never expand a\n * whole `Report`'s facts, and never use `WHERE x.identifier IN [list]` (a scan,\n * not an index probe) — issue one query per factset instead.\n * 3. **Always carry a `WHERE f.value IS NOT NULL` predicate** on the fact scan and\n * **always `LIMIT`.** Both flip the planner onto the fast path (~120 ms vs ~7 s).\n * `value` (the raw string) is present on every fact, so this keeps numeric and\n * text facts alike.\n * 4. **No `OPTIONAL MATCH`.** An optional unit join alone cost ~12 s; units come\n * from a separate required-join query, merged client-side.\n * 5. Aggregations must `ORDER BY <alias>` (not `s.number`); `end` is reserved, so\n * alias every `p.end_date AS end_date`.\n */\nimport { humanize, qname as toQname } from '../constants'\nimport { currencySymbolFor } from '../format'\nimport type {\n CalcAssociation,\n DimensionQualifier,\n ElementInfo,\n EntityInfo,\n Fact,\n InformationBlock,\n NormalizedReport,\n NumericKind,\n PeriodInfo,\n PeriodType,\n PresAssociation,\n StructureInfo,\n UnitInfo,\n} from '../model'\nimport { parseStructureDefinition, type SectionKind } from '../sections'\n\n/** Injected transport — runs a read-only Cypher query and returns its rows. */\nexport type SecQuery = (\n cypher: string,\n params?: Record<string, unknown>\n) => Promise<Array<Record<string, unknown>>>\n\n/** One navigable section of a filing (a `Structure` + its facts). */\nexport interface SecSection {\n /** `Structure.identifier` — the section id + the anchor for its associations. */\n id: string\n /** Human title, e.g. \"Consolidated Balance Sheets\" (definition prefix stripped). */\n title: string\n /** Coarse grouping for the table of contents. */\n kind: SectionKind\n /** The full role definition (e.g. \"9952153 - Statement - …\"), for hover/context. */\n definition: string | null\n /** `canonical_type` when the section is a recognized core statement, else null. */\n canonicalType: string | null\n /** Filing sequence (position in the ordered section list). */\n order: number\n /** `FactSet.identifier`s whose facts belong to this section. */\n factsetIds: string[]\n}\n\n/** The fast first read: entity + the ordered section list, no fact bodies. */\nexport interface SecReportShell {\n reportId: string\n entity: EntityInfo | null\n sections: SecSection[]\n}\n\n// ── Cypher ────────────────────────────────────────────────────────────────────\n\nconst ENTITY_META_Q = `\nMATCH (ent:Entity)-[:ENTITY_HAS_REPORT]->(r:Report {identifier: $rid})\nRETURN ent.identifier AS entity_id, ent.name AS entity_name,\n ent.legal_name AS legal_name, ent.cik AS cik, ent.ticker AS ticker,\n r.form AS form, r.report_date AS report_date`\n\n// Structures reachable from this report's facts, with their factsets. Dimensional\n// facts belong to the same factsets as their consolidated totals, so no\n// `has_dimensions` filter is needed — dropping it also surfaces sections whose\n// content is entirely dimensional (e.g. Schedule II). ORDER BY the alias (Kùzu\n// requires it once `collect` aggregates).\nconst SECTIONS_Q = `\nMATCH (r:Report {identifier: $rid})-[:REPORT_HAS_FACT]->(f:Fact)<-[:FACT_SET_CONTAINS_FACT]-(fs:FactSet)<-[:STRUCTURE_HAS_FACT_SET]-(s:Structure)\nRETURN s.identifier AS sid, s.canonical_type AS canonical_type,\n s.definition AS definition, s.number AS number,\n collect(DISTINCT fs.identifier) AS factsets\nORDER BY number`\n\n// Facts for one factset. Anchored on the factset PK; dimensional and consolidated\n// facts alike come through — the pivot engine keys cells by the full aspect\n// signature (element + period + dimensional coordinate), so segment/component\n// breakdowns no longer collide with the total. Element type signals\n// (`item_type`, `is_shares`) drive the value's numeric kind (monetary / per-share\n// / shares). `WHERE f.value IS NOT NULL` + `LIMIT` keep it on the fast path and\n// retain text facts (Cover Page etc.).\nconst FACTS_Q = `\nMATCH (fs:FactSet {identifier: $fsid})-[:FACT_SET_CONTAINS_FACT]->(f:Fact)-[:FACT_HAS_ELEMENT]->(e:Element),\n (f)-[:FACT_HAS_PERIOD]->(p:Period)\nWHERE f.value IS NOT NULL\nRETURN f.identifier AS fid, e.qname AS qname, e.name AS ename, e.balance AS balance,\n e.period_type AS e_period_type, e.is_abstract AS is_abstract, e.is_numeric AS is_numeric,\n e.item_type AS item_type, e.is_shares AS is_shares,\n f.numeric_value AS numeric_value, f.value AS raw_value, f.decimals AS decimals,\n p.identifier AS pid, p.period_type AS period_type,\n p.start_date AS start_date, p.end_date AS end_date\nLIMIT 2000`\n\n// Unit measures for the same factset, as a separate required-join query — an\n// OPTIONAL unit join on the facts query alone cost ~12 s.\nconst UNITS_Q = `\nMATCH (fs:FactSet {identifier: $fsid})-[:FACT_SET_CONTAINS_FACT]->(f:Fact)-[:FACT_HAS_UNIT]->(u:Unit)\nWHERE f.value IS NOT NULL\nRETURN f.identifier AS fid, u.measure AS unit\nLIMIT 2000`\n\n// Dimensional qualifiers for the same factset — again a separate required-join\n// query (never OPTIONAL) so a fact with no dimensions simply contributes no rows.\n// One row per (fact, axis); a multi-axis fact yields several, merged client-side.\nconst DIMS_Q = `\nMATCH (fs:FactSet {identifier: $fsid})-[:FACT_SET_CONTAINS_FACT]->(f:Fact)-[:FACT_HAS_DIMENSION]->(d:Dimension)\nWHERE f.value IS NOT NULL\nRETURN f.identifier AS fid, d.axis AS axis, d.member AS member,\n d.axis_uri AS axis_uri, d.member_uri AS member_uri,\n d.is_explicit AS is_explicit, d.is_typed AS is_typed\nLIMIT 4000`\n\n// The presentation + calculation networks for one section, anchored on the\n// Structure PK. `association_type` is `Presentation` / `Calculation`. Element\n// names + `is_abstract` come along so presentation-only nodes (abstract section\n// headers, which carry no facts) can be registered — without them the projection\n// can't tell a header from a concrete line and mis-orders it.\nconst ASSOC_Q = `\nMATCH (s:Structure {identifier: $sid})-[:STRUCTURE_HAS_ASSOCIATION]->(a:Association),\n (a)-[:ASSOCIATION_HAS_FROM_ELEMENT]->(pe:Element),\n (a)-[:ASSOCIATION_HAS_TO_ELEMENT]->(ce:Element)\nRETURN a.association_type AS association_type, a.order_value AS order_value, a.weight AS weight,\n pe.qname AS parent, pe.name AS parent_name, pe.is_abstract AS parent_abstract,\n ce.qname AS child, ce.name AS child_name, ce.is_abstract AS child_abstract`\n\n// ── Row helpers ────────────────────────────────────────────────────────────────\n\nfunction str(row: Record<string, unknown>, key: string): string | null {\n const v = row[key]\n return typeof v === 'string' && v !== '' ? v : v == null ? null : String(v)\n}\n\nfunction num(row: Record<string, unknown>, key: string): number | null {\n const v = row[key]\n if (v === null || v === undefined || v === '') return null\n const n = typeof v === 'number' ? v : Number(v)\n return Number.isNaN(n) ? null : n\n}\n\nfunction bool(row: Record<string, unknown>, key: string): boolean {\n const v = row[key]\n return v === true || v === 'true'\n}\n\nfunction periodType(raw: string | null): PeriodType | null {\n return raw === 'instant' || raw === 'duration' ? raw : null\n}\n\n/**\n * A prefixed qname for a dimension axis/member from its versioned XBRL IRI + local\n * name (`http://fasb.org/us-gaap/2025#…Member` + `…Member` → `us-gaap:…Member`).\n * The graph gives axis/member as bare local names; this keeps them consistent with\n * the `Element.qname`s used in the presentation network (so member ordering lines\n * up), and cell matching is internally consistent regardless (row + column derive\n * from the same mapping).\n */\nfunction xbrlQname(uri: string | null, local: string | null): string {\n if (local) {\n const ns = (uri ?? '').split('#')[0]\n if (/fasb\\.org\\/us-gaap/.test(ns)) return `us-gaap:${local}`\n if (/fasb\\.org\\/srt/.test(ns)) return `srt:${local}`\n if (/xbrl\\.sec\\.gov\\/dei/.test(ns)) return `dei:${local}`\n if (/robosystems\\.ai\\/taxonomy\\/rs-gaap/.test(ns)) return `rs-gaap:${local}`\n return local\n }\n return uri ? toQname(uri) : ''\n}\n\n/** Humanize an axis/member local name, dropping the XBRL `Axis`/`Member`/`Domain` suffix. */\nfunction dimLabel(local: string | null): string {\n if (!local) return ''\n return humanize(local.replace(/(Axis|Member|Domain)$/, '')) || humanize(local)\n}\n\n/**\n * Classify an element's numeric kind from its XBRL `item_type` (+ `is_shares`).\n * Per-share and share counts opt out of monetary rescaling; strings/text are not\n * numeric. Checked before monetary because share/per-share types are also numeric.\n */\nfunction deriveNumericKind(row: Record<string, unknown>): NumericKind | undefined {\n const itemType = str(row, 'item_type') ?? ''\n if (/perShareItemType/i.test(itemType)) return 'perShare'\n if (/sharesItemType/i.test(itemType) || bool(row, 'is_shares')) return 'shares'\n // A percentItemType stores a decimal fraction (0.10 → 10%); a pureItemType is a\n // bare dimensionless ratio (2.5 debt-to-equity), NOT a percentage.\n if (/percentItemType/i.test(itemType)) return 'percent'\n if (/pureItemType/i.test(itemType)) return 'pure'\n if (/monetaryItemType/i.test(itemType)) return 'monetary'\n if (/integerItemType/i.test(itemType)) return 'integer'\n if (!bool(row, 'is_numeric')) return undefined\n // No item_type (older captures): a debit/credit balance marks a monetary item.\n const balance = str(row, 'balance')\n return balance === 'debit' || balance === 'credit' ? 'monetary' : 'other'\n}\n\n// ── Shell ───────────────────────────────────────────────────────────────────\n\nfunction mapEntity(row: Record<string, unknown> | undefined): EntityInfo | null {\n if (!row) return null\n const id = str(row, 'entity_id')\n if (!id) return null\n return {\n id,\n name: str(row, 'entity_name') ?? str(row, 'legal_name') ?? 'Entity',\n legalName: str(row, 'legal_name'),\n country: null,\n }\n}\n\n/** Fetch the entity + ordered section list for a report (the fast first read). */\nexport async function fetchSecReportShell(\n query: SecQuery,\n reportId: string\n): Promise<SecReportShell> {\n const [entityRows, sectionRows] = await Promise.all([\n query(ENTITY_META_Q, { rid: reportId }),\n query(SECTIONS_Q, { rid: reportId }),\n ])\n\n const sections: SecSection[] = sectionRows\n .map((row, order): SecSection => {\n const { title, kind } = parseStructureDefinition(\n str(row, 'definition'),\n str(row, 'canonical_type')\n )\n const factsets = Array.isArray(row.factsets)\n ? (row.factsets as unknown[]).filter((v): v is string => typeof v === 'string')\n : []\n return {\n id: str(row, 'sid') ?? '',\n title,\n kind,\n definition: str(row, 'definition'),\n canonicalType: str(row, 'canonical_type'),\n order,\n factsetIds: factsets,\n }\n })\n .filter((s) => s.id && s.factsetIds.length > 0)\n\n return { reportId, entity: mapEntity(entityRows[0]), sections }\n}\n\n// ── Single section ────────────────────────────────────────────────────────────\n\nfunction accumulateElement(elements: Record<string, ElementInfo>, row: Record<string, unknown>) {\n const q = str(row, 'qname')\n if (!q || elements[q]) return\n const balance = str(row, 'balance')\n elements[q] = {\n id: q,\n qname: q,\n label: str(row, 'ename') ? humanize(str(row, 'ename') as string) : humanize(q),\n balance: balance === 'debit' || balance === 'credit' ? balance : null,\n periodType: periodType(str(row, 'e_period_type')),\n abstract: bool(row, 'is_abstract'),\n monetary: bool(row, 'is_numeric'),\n numericKind: deriveNumericKind(row),\n }\n}\n\n/**\n * Register a presentation-network element that has no facts of its own — chiefly\n * an abstract section header. Fact-bearing elements are already registered from\n * the facts query and take precedence (this no-ops on existing keys); this fills\n * in the abstract headers so the projection renders them as headers above their\n * section rather than as empty concrete rows below it. Abstract labels drop the\n * XBRL `Abstract` suffix (`OperatingExpensesAbstract` → `Operating Expenses`).\n */\nfunction registerPresentationElement(\n elements: Record<string, ElementInfo>,\n qname: string | null,\n name: string | null,\n isAbstract: boolean\n): void {\n if (!qname || elements[qname]) return\n elements[qname] = {\n id: qname,\n qname,\n label: name ? humanize(isAbstract ? name.replace(/Abstract$/, '') : name) : humanize(qname),\n balance: null,\n periodType: null,\n abstract: isAbstract,\n monetary: false,\n }\n}\n\nfunction accumulatePeriod(periods: Record<string, PeriodInfo>, row: Record<string, unknown>) {\n const id = str(row, 'pid')\n if (!id || periods[id]) return\n const type = periodType(str(row, 'period_type')) ?? 'duration'\n const startDate = str(row, 'start_date')\n const endDate = str(row, 'end_date')\n periods[id] = {\n id,\n type,\n instant: type === 'instant' ? endDate : null,\n startDate,\n endDate,\n end: endDate ?? '',\n }\n}\n\n/**\n * Load one section into a single-section `NormalizedReport`. All of the\n * section's facts are re-keyed to the structure id as their `factSet`, so the\n * projection groups them as one Information Block regardless of how many raw\n * FactSets the filing split them across.\n */\nexport async function fetchSecSection(\n query: SecQuery,\n shell: SecReportShell,\n section: SecSection\n): Promise<NormalizedReport> {\n const [factRowGroups, unitRowGroups, dimRowGroups, assocRows] = await Promise.all([\n Promise.all(section.factsetIds.map((fsid) => query(FACTS_Q, { fsid }))),\n Promise.all(section.factsetIds.map((fsid) => query(UNITS_Q, { fsid }))),\n Promise.all(section.factsetIds.map((fsid) => query(DIMS_Q, { fsid }))),\n query(ASSOC_Q, { sid: section.id }),\n ])\n\n const unitByFid = new Map<string, string>()\n for (const row of unitRowGroups.flat()) {\n const fid = str(row, 'fid')\n const measure = str(row, 'unit')\n if (fid && measure) unitByFid.set(fid, measure)\n }\n\n // One fact can carry several axes; collect its qualifiers (ordered by axis).\n const dimsByFid = new Map<string, DimensionQualifier[]>()\n for (const row of dimRowGroups.flat()) {\n const fid = str(row, 'fid')\n if (!fid) continue\n const memberLocal = str(row, 'member')\n const qual: DimensionQualifier = {\n axis: xbrlQname(str(row, 'axis_uri'), str(row, 'axis')),\n member: memberLocal ? xbrlQname(str(row, 'member_uri'), memberLocal) : null,\n axisLabel: dimLabel(str(row, 'axis')),\n memberLabel: dimLabel(memberLocal),\n explicit: bool(row, 'is_explicit'),\n typedValue: bool(row, 'is_typed') ? str(row, 'member') : null,\n }\n const list = dimsByFid.get(fid) ?? []\n list.push(qual)\n dimsByFid.set(fid, list)\n }\n for (const list of dimsByFid.values()) list.sort((a, b) => a.axis.localeCompare(b.axis))\n\n const elements: Record<string, ElementInfo> = {}\n const periods: Record<string, PeriodInfo> = {}\n const units: Record<string, UnitInfo> = {}\n const facts: Fact[] = []\n const seenFacts = new Set<string>()\n\n for (const row of factRowGroups.flat()) {\n const fid = str(row, 'fid')\n const element = str(row, 'qname')\n const period = str(row, 'pid')\n if (!fid || !element || !period || seenFacts.has(fid)) continue\n seenFacts.add(fid)\n\n accumulateElement(elements, row)\n accumulatePeriod(periods, row)\n\n const measure = unitByFid.get(fid) ?? null\n if (measure && !units[measure]) {\n const compact = toQname(measure)\n units[measure] = {\n id: measure,\n measure: compact,\n label: compact.includes(':') ? (compact.split(':').pop() as string) : compact,\n symbol: currencySymbolFor(compact),\n }\n }\n\n const value = num(row, 'numeric_value')\n facts.push({\n id: fid,\n element,\n period,\n unit: measure,\n entity: shell.entity?.id ?? null,\n factSet: section.id,\n value,\n decimals: str(row, 'decimals'),\n textValue: value === null ? str(row, 'raw_value') : null,\n dimensions: dimsByFid.get(fid),\n })\n }\n\n const calcAssociations: CalcAssociation[] = []\n const presAssociations: PresAssociation[] = []\n for (const row of assocRows) {\n const parent = str(row, 'parent')\n const child = str(row, 'child')\n if (!parent || !child) continue\n // Register presentation-only elements (abstract section headers carry no\n // facts, so the facts query never saw them). Fact-bearing elements are\n // already registered and unaffected — registration no-ops on existing keys.\n registerPresentationElement(\n elements,\n parent,\n str(row, 'parent_name'),\n bool(row, 'parent_abstract')\n )\n registerPresentationElement(\n elements,\n child,\n str(row, 'child_name'),\n bool(row, 'child_abstract')\n )\n const order = num(row, 'order_value') ?? 0\n const type = str(row, 'association_type')?.toLowerCase()\n if (type === 'calculation') {\n calcAssociations.push({\n parent,\n child,\n weight: num(row, 'weight') ?? 1,\n order,\n role: null,\n structure: section.id,\n })\n } else if (type === 'presentation') {\n presAssociations.push({ parent, child, order, role: null, structure: section.id })\n }\n }\n\n const informationBlock: InformationBlock = {\n id: section.id,\n blockType: section.canonicalType ?? '',\n factSet: section.id,\n label: section.title,\n structureId: section.id,\n }\n const structure: StructureInfo = {\n id: section.id,\n blockType: section.canonicalType ?? '',\n roleUri: null,\n structureName: section.title,\n definition: section.definition,\n kind: section.kind,\n order: section.order,\n }\n\n return {\n reportId: shell.reportId,\n reportIri: null,\n entity: shell.entity,\n informationBlocks: [informationBlock],\n structures: [structure],\n facts,\n elements,\n periods,\n units,\n calcAssociations,\n presAssociations,\n }\n}\n\n/** Merge single-section reports into one whole-report model (order preserved). */\nexport function mergeSecSections(\n shell: SecReportShell,\n sections: NormalizedReport[]\n): NormalizedReport {\n const elements: Record<string, ElementInfo> = {}\n const periods: Record<string, PeriodInfo> = {}\n const units: Record<string, UnitInfo> = {}\n const informationBlocks: InformationBlock[] = []\n const structures: StructureInfo[] = []\n const facts: Fact[] = []\n const calcAssociations: CalcAssociation[] = []\n const presAssociations: PresAssociation[] = []\n\n for (const part of sections) {\n Object.assign(elements, part.elements)\n Object.assign(periods, part.periods)\n Object.assign(units, part.units)\n informationBlocks.push(...part.informationBlocks)\n structures.push(...part.structures)\n facts.push(...part.facts)\n calcAssociations.push(...part.calcAssociations)\n presAssociations.push(...part.presAssociations)\n }\n\n return {\n reportId: shell.reportId,\n reportIri: null,\n entity: shell.entity,\n informationBlocks,\n structures,\n facts,\n elements,\n periods,\n units,\n calcAssociations,\n presAssociations,\n }\n}\n","/**\n * The cypher adapter — a whole-report `ReportAdapter` over the live SEC graph.\n *\n * This is a convenience wrapper: it loads the section list, then every section,\n * and merges them into one `NormalizedReport`. Apps that want responsive,\n * lazy-per-section loading should call `fetchSecReportShell` + `fetchSecSection`\n * directly (see `./sec`) rather than materializing a whole filing up front.\n */\nimport type { SecQuery } from './sec'\nimport { fetchSecReportShell, fetchSecSection, mergeSecSections } from './sec'\nimport type { ReportAdapter } from './types'\n\nexport interface CypherAdapterConfig {\n /** Injected transport over `POST /v1/graphs/{graphId}/query` (auth lives here). */\n query: SecQuery\n /** The report to materialize — a `Report.identifier`. */\n reportId: string\n}\n\nexport function cypherAdapter(config: CypherAdapterConfig): ReportAdapter {\n return {\n source: `sec:${config.reportId}`,\n load: async () => {\n const shell = await fetchSecReportShell(config.query, config.reportId)\n const sections = await Promise.all(\n shell.sections.map((section) => fetchSecSection(config.query, shell, section))\n )\n return mergeSecSections(shell, sections)\n },\n }\n}\n","/**\n * The shared quad-store → `NormalizedReport` traversal.\n *\n * An adapter fills an N3 quad `Store` from its source, then hands it here. The\n * store is read as a **union** across its graphs (`graph = null`) — the\n * scene/boundary/projection partition is a publication concern, not a rendering\n * one, so the join is identical however the quads arrived (a dataset-form\n * JSON-LD holon, a flat graph, …). No SPARQL engine is required; only store\n * traversal. The only per-source code is how the store gets filled.\n */\nimport { DataFactory, Store } from 'n3'\nimport { IRI, humanize, qname } from '../constants'\nimport type {\n CalcAssociation,\n DimensionQualifier,\n ElementInfo,\n EntityInfo,\n Fact,\n InformationBlock,\n NormalizedReport,\n NumericKind,\n PeriodInfo,\n PeriodType,\n PresAssociation,\n StructureInfo,\n UnitInfo,\n} from '../model'\nimport { parseStructureName } from '../sections'\n\n/**\n * The holon's value-domain `rs:itemType` maps 1:1 onto the numeric kinds that\n * drive formatting/scale. perShare and shares never rescale by the statement\n * factor (else e.g. an EPS of $0.04 in a thousands-scaled statement rounds to\n * 0); percent/pure/integer format distinctly. Text/date/boolean/decimal have no\n * numeric kind — the formatter falls back to monetary-or-other.\n */\nfunction numericKindFromItemType(itemType: string | undefined): NumericKind | undefined {\n switch (itemType) {\n case 'monetary':\n return 'monetary'\n case 'perShare':\n return 'perShare'\n case 'shares':\n return 'shares'\n case 'percent':\n return 'percent'\n case 'pure':\n return 'pure'\n case 'integer':\n return 'integer'\n default:\n return undefined\n }\n}\n\nconst { namedNode } = DataFactory\n\nfunction makeReaders(store: Store) {\n const objects = (s: string, p: string) => store.getObjects(namedNode(s), namedNode(p), null)\n const firstValue = (s: string, p: string): string | null => {\n const os = objects(s, p)\n return os.length ? os[0].value : null\n }\n const subjectsOfType = (type: string): string[] =>\n store.getSubjects(namedNode(IRI.type), namedNode(type), null).map((t) => t.value)\n return { objects, firstValue, subjectsOfType }\n}\n\nfunction toNumber(raw: string | null): number | null {\n if (raw === null || raw === '') return null\n const n = Number(raw)\n return Number.isNaN(n) ? null : n\n}\n\n/** Traverse a populated quad `Store` into the normalized report model. */\nexport function parseStore(store: Store): NormalizedReport {\n const { objects, firstValue, subjectsOfType } = makeReaders(store)\n\n // ── Elements ──\n const elements: Record<string, ElementInfo> = {}\n for (const id of subjectsOfType(IRI.Element)) {\n const balance = firstValue(id, IRI.balance)\n const periodType = firstValue(id, IRI.periodType)\n const itemType = firstValue(id, IRI.itemType) ?? undefined\n elements[id] = {\n id,\n qname: qname(id),\n label: firstValue(id, IRI.prefLabel) ?? humanize(id),\n balance: balance === 'debit' || balance === 'credit' ? balance : null,\n periodType: periodType === 'instant' || periodType === 'duration' ? periodType : null,\n abstract: firstValue(id, IRI.abstract) === 'true',\n monetary: firstValue(id, IRI.monetary) === 'true',\n itemType,\n numericKind: numericKindFromItemType(itemType),\n }\n }\n\n // ── Periods ──\n const periods: Record<string, PeriodInfo> = {}\n for (const id of subjectsOfType(IRI.Period)) {\n const declared = firstValue(id, IRI.periodType)\n const instant = firstValue(id, IRI.instant)\n const startDate = firstValue(id, IRI.startDate)\n const endDate = firstValue(id, IRI.endDate)\n const type: PeriodType =\n declared === 'instant'\n ? 'instant'\n : declared === 'duration'\n ? 'duration'\n : instant\n ? 'instant'\n : 'duration'\n const end = (type === 'instant' ? instant : endDate) ?? instant ?? endDate ?? ''\n periods[id] = { id, type, instant, startDate, endDate, end }\n }\n\n // ── Units ──\n const units: Record<string, UnitInfo> = {}\n for (const id of subjectsOfType(IRI.Unit)) {\n const measureTerm = objects(id, IRI.measure)[0]\n const measure = measureTerm ? qname(measureTerm.value) : 'unknown'\n units[id] = {\n id,\n measure,\n label: measure.includes(':') ? (measure.split(':').pop() as string) : measure,\n }\n }\n\n // ── Entity ──\n let entity: EntityInfo | null = null\n const entityIds = subjectsOfType(IRI.Entity)\n if (entityIds.length) {\n const id = entityIds[0]\n entity = {\n id,\n name: firstValue(id, IRI.prefLabel) ?? firstValue(id, IRI.legalName) ?? 'Entity',\n legalName: firstValue(id, IRI.legalName),\n country: firstValue(id, IRI.country),\n }\n }\n\n // ── Facts ──\n const facts: Fact[] = []\n for (const id of subjectsOfType(IRI.Fact)) {\n // Dimensional coordinate (rs:dimension -> rs:Dimension {axis, member, ...}).\n // Without this every fact reads as consolidated, so a segment breakdown\n // collapses onto the face-statement cell and can overwrite the real total.\n const dimensions: DimensionQualifier[] = []\n for (const d of objects(id, IRI.dimension)) {\n const axis = firstValue(d.value, IRI.axis)\n if (!axis) continue\n const member = firstValue(d.value, IRI.member)\n const typedValue = firstValue(d.value, IRI.typedValue)\n dimensions.push({\n axis,\n member: member ?? null,\n axisLabel: elements[axis]?.label ?? humanize(axis),\n memberLabel: member ? (elements[member]?.label ?? humanize(member)) : (typedValue ?? ''),\n explicit: firstValue(d.value, IRI.isExplicit) === 'true',\n typedValue: typedValue ?? null,\n })\n }\n facts.push({\n id,\n element: firstValue(id, IRI.element) ?? '',\n period: firstValue(id, IRI.period) ?? '',\n unit: firstValue(id, IRI.unit),\n entity: firstValue(id, IRI.entity),\n factSet: firstValue(id, IRI.factSet),\n value: toNumber(firstValue(id, IRI.numericValue)),\n textValue: firstValue(id, IRI.stringValue),\n decimals: firstValue(id, IRI.decimals),\n dimensions: dimensions.length ? dimensions : undefined,\n })\n }\n\n // ── Information Blocks ──\n const informationBlocks: InformationBlock[] = []\n for (const id of subjectsOfType(IRI.InformationBlock)) {\n informationBlocks.push({\n id,\n blockType: firstValue(id, IRI.blockType) ?? '',\n // Match a block to its structure by identity (the rs:structure link),\n // not by a semantic blockType — a full-fidelity holon carries no\n // block-type classification, so structureId is how row order is found.\n structureId: firstValue(id, IRI.structure) ?? undefined,\n factSet: firstValue(id, IRI.factSet),\n label: firstValue(id, IRI.prefLabel),\n })\n }\n\n // ── Structures + association → structure membership ──\n const structures: StructureInfo[] = []\n const assocStructure = new Map<string, string>()\n for (const id of subjectsOfType(IRI.Structure)) {\n // Split the holon's rs:structureName the same way the SEC adapter splits a\n // role definition — a clean title + the full definition + a kind — so File\n // and SEC modes render identical section labels. Non-SEC names pass through.\n const { definition, title, kind } = parseStructureName(firstValue(id, IRI.structureName))\n structures.push({\n id,\n blockType: firstValue(id, IRI.blockType) ?? '',\n roleUri: firstValue(id, IRI.roleUri),\n structureName: title,\n definition,\n kind,\n // Filing sequence (SEC role-definition number) so buildPivots orders all\n // sections by the filer's order rather than the fixed four-primary fallback.\n order: toNumber(firstValue(id, IRI.structureOrder)) ?? undefined,\n })\n for (const assoc of objects(id, IRI.hasAssociation)) {\n assocStructure.set(assoc.value, id)\n }\n }\n\n // ── Associations ──\n const calcAssociations: CalcAssociation[] = []\n const presAssociations: PresAssociation[] = []\n for (const id of subjectsOfType(IRI.Association)) {\n const parent = firstValue(id, IRI.from)\n const child = firstValue(id, IRI.to)\n if (!parent || !child) continue\n const type = firstValue(id, IRI.associationType)\n const order = toNumber(firstValue(id, IRI.order)) ?? 0\n const role = firstValue(id, IRI.role)\n const structure = assocStructure.get(id) ?? null\n if (type === 'calculation') {\n calcAssociations.push({\n parent,\n child,\n weight: toNumber(firstValue(id, IRI.weight)) ?? 1,\n order,\n role,\n structure,\n })\n } else if (type === 'presentation') {\n presAssociations.push({ parent, child, order, role, structure })\n }\n }\n\n // ── Report IRI / id ──\n // Prefer the named-graph name (`<report>#scene` → `<report>`) — present in a\n // dataset-form holon. Fall back to the `rs:Report` subject so a flat,\n // single-graph document still resolves its identity.\n let reportIri: string | null = null\n for (const graph of store.getGraphs(null, null, null)) {\n const hash = graph.value.indexOf('#')\n if (hash > 0) {\n reportIri = graph.value.slice(0, hash)\n break\n }\n }\n if (!reportIri) {\n const reports = subjectsOfType(IRI.Report)\n reportIri = reports.length ? reports[0] : null\n }\n const reportId = reportIri ? (reportIri.split('/').pop() ?? null) : null\n\n return {\n reportId,\n reportIri,\n entity,\n informationBlocks,\n structures,\n facts,\n elements,\n periods,\n units,\n calcAssociations,\n presAssociations,\n }\n}\n","/**\n * The `holon.jsonld` adapter — offline, no backend, no auth.\n *\n * The canonical, API-native holon: **dataset-form JSON-LD** carrying the three\n * named graphs (`#scene`, `#boundary`, `#projection`) as `@id` + nested\n * `@graph`. JSON is native to the RoboSystems JSON API, so this is the one\n * holon file format.\n *\n * N3.js doesn't parse JSON-LD, so this adapter uses the `jsonld` processor to\n * expand the document to N-Quads (which preserves the named-graph labels),\n * parses those into an N3 quad `Store`, and delegates to the shared\n * `parseStore` traversal (`store.ts`).\n */\nimport type { JsonLdDocument } from 'jsonld'\nimport jsonld from 'jsonld'\nimport { Parser, Store } from 'n3'\nimport type { NormalizedReport } from '../model'\nimport { parseStore } from './store'\nimport type { ReportAdapter } from './types'\n\n/** Parse a `holon.jsonld` document (string or parsed object) into the model. */\nexport async function parseJsonld(doc: string | object): Promise<NormalizedReport> {\n const json = (typeof doc === 'string' ? JSON.parse(doc) : doc) as JsonLdDocument\n // `toRDF` with the n-quads format returns a serialized string; each quad\n // carries its graph label, so the holon's named graphs survive the expansion.\n const nquads = (await jsonld.toRDF(json, { format: 'application/n-quads' })) as string\n const store = new Store(new Parser({ format: 'application/n-quads' }).parse(nquads))\n return parseStore(store)\n}\n\n/** A `ReportAdapter` over an in-memory `holon.jsonld` document. */\nexport function jsonldFileAdapter(doc: string | object, source = 'holon.jsonld'): ReportAdapter {\n return {\n source,\n load: () => parseJsonld(doc),\n }\n}\n"]}
@@ -1,5 +1,38 @@
1
1
  import { Store } from 'n3';
2
2
 
3
+ /**
4
+ * Shared parsing of an XBRL structure's role definition into a display title, its
5
+ * full raw definition, and a coarse `kind`. Used by BOTH the SEC adapter (whose
6
+ * definitions are always SEC-shaped) and the jsonld/file adapter (whose structure
7
+ * names may be non-SEC), so every source lands the same `StructureInfo` shape —
8
+ * the section header and TOC read identically regardless of where the data came
9
+ * from.
10
+ */
11
+ /** Coarse grouping for a section — the basis for a "Statements / Disclosures" TOC. */
12
+ type SectionKind = 'Statement' | 'Disclosure' | 'Document' | 'Cover' | 'Other';
13
+ /**
14
+ * Split an XBRL `Structure.definition` into a human title + a coarse kind.
15
+ * Definitions look like `"9952153 - Statement - Consolidated Balance Sheets"` or
16
+ * `"0000001 - Document - Cover Page"` — a `"NNNN - <Type> - <Title>"` shape whose
17
+ * middle word (Statement / Disclosure / Document) drives the kind. A core
18
+ * canonical statement always reads as a Statement so the primaries group cleanly.
19
+ */
20
+ declare function parseStructureDefinition(definition: string | null, canonicalType: string | null): {
21
+ title: string;
22
+ kind: SectionKind;
23
+ };
24
+ /**
25
+ * Parse a structure NAME as carried on a holon's `rs:structureName`, the same way
26
+ * as a SEC definition but only when it is SEC-shaped. Returns the full definition
27
+ * (verbatim, for hover), a clean display title, and the kind (null for a non-SEC
28
+ * name, whose title is just the name).
29
+ */
30
+ declare function parseStructureName(name: string | null): {
31
+ definition: string | null;
32
+ title: string | null;
33
+ kind: SectionKind | null;
34
+ };
35
+
3
36
  /**
4
37
  * The normalized report model — the load-bearing seam of the library.
5
38
  *
@@ -13,6 +46,7 @@ import { Store } from 'n3';
13
46
  * subtotals, the table layout. That work is identical for every adapter, which
14
47
  * is what makes the rendering source-agnostic.
15
48
  */
49
+
16
50
  type PeriodType = 'instant' | 'duration';
17
51
  type BalanceType = 'debit' | 'credit';
18
52
  /**
@@ -152,7 +186,12 @@ interface StructureInfo {
152
186
  id: string;
153
187
  blockType: string;
154
188
  roleUri: string | null;
189
+ /** Clean display title (any SEC `NNN - Type - ` prefix stripped). */
155
190
  structureName: string | null;
191
+ /** Full role definition, verbatim (e.g. "9952153 - Statement - …"), for hover. */
192
+ definition?: string | null;
193
+ /** Coarse grouping (Statement / Disclosure / Document / Cover); null/absent for non-SEC. */
194
+ kind?: SectionKind | null;
156
195
  /**
157
196
  * Filing sequence for ordering sections (SEC `Structure.number`). When present,
158
197
  * `buildStatements` orders by it instead of the canonical `BLOCK_ORDER` — a real
@@ -318,6 +357,10 @@ interface PivotTable {
318
357
  blockType: string;
319
358
  title: string;
320
359
  structureName: string | null;
360
+ /** Full role definition (for hover/context); null when unavailable. */
361
+ definition: string | null;
362
+ /** Coarse grouping for the TOC; null for non-SEC sections. */
363
+ kind: SectionKind | null;
321
364
  /** Aspects held fixed for the whole table, shown as header bars. */
322
365
  slicers: PivotSlicer[];
323
366
  /** Column header rows, outermost level first (period over members). */
@@ -340,7 +383,9 @@ interface SecSection {
340
383
  /** Human title, e.g. "Consolidated Balance Sheets" (definition prefix stripped). */
341
384
  title: string;
342
385
  /** Coarse grouping for the table of contents. */
343
- kind: 'Statement' | 'Disclosure' | 'Document' | 'Cover' | 'Other';
386
+ kind: SectionKind;
387
+ /** The full role definition (e.g. "9952153 - Statement - …"), for hover/context. */
388
+ definition: string | null;
344
389
  /** `canonical_type` when the section is a recognized core statement, else null. */
345
390
  canonicalType: string | null;
346
391
  /** Filing sequence (position in the ordered section list). */
@@ -354,17 +399,6 @@ interface SecReportShell {
354
399
  entity: EntityInfo | null;
355
400
  sections: SecSection[];
356
401
  }
357
- /**
358
- * Split an XBRL `Structure.definition` into a human title + a coarse kind.
359
- * Definitions look like `"9952153 - Statement - Consolidated Balance Sheets"` or
360
- * `"0000001 - Document - Cover Page"` — a `"NNNN - <Type> - <Title>"` shape whose
361
- * middle word (Statement / Disclosure / Document) drives the kind. A core
362
- * canonical statement always reads as a Statement so the primaries group cleanly.
363
- */
364
- declare function parseStructureDefinition(definition: string | null, canonicalType: string | null): {
365
- title: string;
366
- kind: SecSection['kind'];
367
- };
368
402
  /** Fetch the entity + ordered section list for a report (the fast first read). */
369
403
  declare function fetchSecReportShell(query: SecQuery, reportId: string): Promise<SecReportShell>;
370
404
  /**
@@ -430,4 +464,4 @@ declare function jsonldFileAdapter(doc: string | object, source?: string): Repor
430
464
  /** Traverse a populated quad `Store` into the normalized report model. */
431
465
  declare function parseStore(store: Store): NormalizedReport;
432
466
 
433
- export { type AspectKey as A, type BalanceType as B, type CalcAssociation as C, type DimensionQualifier as D, type ElementInfo as E, type Fact as F, parseJsonld as G, parseStore as H, type InformationBlock as I, parseStructureDefinition as J, type NumericKind as N, type PeriodInfo as P, type ReportAdapter as R, type Scale as S, type UnitInfo as U, type NormalizedReport as a, type PivotConfig as b, type PivotTable as c, type PivotRow as d, type CypherAdapterConfig as e, type EntityInfo as f, type PeriodType as g, type PivotCell as h, type PivotColumn as i, type PivotColumnHeader as j, type PivotSlicer as k, type PresAssociation as l, type ResolvedScale as m, type RowCell as n, type SecQuery as o, type SecReportShell as p, type SecSection as q, type Statement as r, type StatementColumn as s, type StatementRow as t, type StructureInfo as u, cypherAdapter as v, fetchSecReportShell as w, fetchSecSection as x, jsonldFileAdapter as y, mergeSecSections as z };
467
+ export { type AspectKey as A, type BalanceType as B, type CalcAssociation as C, type DimensionQualifier as D, type ElementInfo as E, type Fact as F, mergeSecSections as G, parseJsonld as H, type InformationBlock as I, parseStore as J, parseStructureDefinition as K, parseStructureName as L, type NumericKind as N, type PeriodInfo as P, type ReportAdapter as R, type SectionKind as S, type UnitInfo as U, type NormalizedReport as a, type PivotConfig as b, type PivotTable as c, type PivotRow as d, type CypherAdapterConfig as e, type EntityInfo as f, type PeriodType as g, type PivotCell as h, type PivotColumn as i, type PivotColumnHeader as j, type PivotSlicer as k, type PresAssociation as l, type ResolvedScale as m, type RowCell as n, type Scale as o, type SecQuery as p, type SecReportShell as q, type SecSection as r, type Statement as s, type StatementColumn as t, type StatementRow as u, type StructureInfo as v, cypherAdapter as w, fetchSecReportShell as x, fetchSecSection as y, jsonldFileAdapter as z };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { N as NumericKind, P as PeriodInfo, E as ElementInfo, a as NormalizedReport, I as InformationBlock, b as PivotConfig, c as PivotTable, d as PivotRow, U as UnitInfo } from './index-BS6_6h3l.js';
2
- export { A as AspectKey, B as BalanceType, C as CalcAssociation, e as CypherAdapterConfig, D as DimensionQualifier, f as EntityInfo, F as Fact, g as PeriodType, h as PivotCell, i as PivotColumn, j as PivotColumnHeader, k as PivotSlicer, l as PresAssociation, R as ReportAdapter, m as ResolvedScale, n as RowCell, S as Scale, o as SecQuery, p as SecReportShell, q as SecSection, r as Statement, s as StatementColumn, t as StatementRow, u as StructureInfo, v as cypherAdapter, w as fetchSecReportShell, x as fetchSecSection, y as jsonldFileAdapter, z as mergeSecSections, G as parseJsonld, H as parseStore, J as parseStructureDefinition } from './index-BS6_6h3l.js';
1
+ import { N as NumericKind, P as PeriodInfo, E as ElementInfo, a as NormalizedReport, I as InformationBlock, b as PivotConfig, c as PivotTable, S as SectionKind, d as PivotRow, U as UnitInfo } from './index-fEwdoTEH.js';
2
+ export { A as AspectKey, B as BalanceType, C as CalcAssociation, e as CypherAdapterConfig, D as DimensionQualifier, f as EntityInfo, F as Fact, g as PeriodType, h as PivotCell, i as PivotColumn, j as PivotColumnHeader, k as PivotSlicer, l as PresAssociation, R as ReportAdapter, m as ResolvedScale, n as RowCell, o as Scale, p as SecQuery, q as SecReportShell, r as SecSection, s as Statement, t as StatementColumn, u as StatementRow, v as StructureInfo, w as cypherAdapter, x as fetchSecReportShell, y as fetchSecSection, z as jsonldFileAdapter, G as mergeSecSections, H as parseJsonld, J as parseStore, K as parseStructureDefinition, L as parseStructureName } from './index-fEwdoTEH.js';
3
3
  import * as react from 'react';
4
4
  import 'n3';
5
5
 
@@ -109,10 +109,12 @@ declare function pivotDimensionsOn(config: PivotConfig, placement: 'rows' | 'col
109
109
  * arrangement (e.g. move a high-arity axis from columns to rows).
110
110
  */
111
111
  declare function buildPivot(model: NormalizedReport, ib: InformationBlock, config?: PivotConfig): PivotTable;
112
- /** Section metadata (id + display title) for a report, in canonical order. */
112
+ /** Section metadata (id + display title, full definition, kind) in canonical order. */
113
113
  declare function reportSections(model: NormalizedReport): Array<{
114
114
  id: string;
115
115
  title: string;
116
+ definition: string | null;
117
+ kind: SectionKind | null;
116
118
  }>;
117
119
  /**
118
120
  * Pivot every section of a report, in canonical block order. `configFor` may
@@ -206,4 +208,4 @@ interface StatementTableProps {
206
208
  }
207
209
  declare function StatementTable({ table, units, onCellClick, selected, dimensionPlacement, onDimensionPlacementChange, }: StatementTableProps): react.JSX.Element;
208
210
 
209
- export { BLOCK_ORDER, BLOCK_TITLES, ElementInfo, ExternalTextBlock, type ExternalTextBlockProps, FactInspector, type FactInspectorProps, type FootCheck, type FootTerm, InformationBlock, NS, NormalizedReport, NumericKind, PeriodInfo, PivotConfig, PivotRow, PivotTable, ReportView, type ReportViewProps, StatementTable, type StatementTableProps, UnitInfo, type ValueFormat, buildPivot, buildPivots, calcSubtotals, currencySymbolFor, defaultPivotConfig, footCheck, formatDate, formatMoney, formatPeriod, formatValue, humanize, humanizeDuration, isExternalFactUrl, numericKindOf, pivotDimensionsOn, presentationOrder, qname, reportSections, sliceReportSection };
211
+ export { BLOCK_ORDER, BLOCK_TITLES, ElementInfo, ExternalTextBlock, type ExternalTextBlockProps, FactInspector, type FactInspectorProps, type FootCheck, type FootTerm, InformationBlock, NS, NormalizedReport, NumericKind, PeriodInfo, PivotConfig, PivotRow, PivotTable, ReportView, type ReportViewProps, SectionKind, StatementTable, type StatementTableProps, UnitInfo, type ValueFormat, buildPivot, buildPivots, calcSubtotals, currencySymbolFor, defaultPivotConfig, footCheck, formatDate, formatMoney, formatPeriod, formatValue, humanize, humanizeDuration, isExternalFactUrl, numericKindOf, pivotDimensionsOn, presentationOrder, qname, reportSections, sliceReportSection };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { formatDate, BLOCK_TITLES, numericKindOf, humanizeDuration, formatValue, formatPeriod, isExternalFactUrl, BLOCK_ORDER, humanize, qname, currencySymbolFor } from './chunk-RQXAMFTZ.js';
2
- export { BLOCK_ORDER, BLOCK_TITLES, NS, currencySymbolFor, cypherAdapter, fetchSecReportShell, fetchSecSection, formatDate, formatMoney, formatPeriod, formatValue, humanize, humanizeDuration, isExternalFactUrl, jsonldFileAdapter, mergeSecSections, numericKindOf, parseJsonld, parseStore, parseStructureDefinition, qname } from './chunk-RQXAMFTZ.js';
1
+ import { formatDate, BLOCK_TITLES, numericKindOf, humanizeDuration, formatValue, formatPeriod, isExternalFactUrl, BLOCK_ORDER, humanize, qname, currencySymbolFor } from './chunk-GJL4ILVH.js';
2
+ export { BLOCK_ORDER, BLOCK_TITLES, NS, currencySymbolFor, cypherAdapter, fetchSecReportShell, fetchSecSection, formatDate, formatMoney, formatPeriod, formatValue, humanize, humanizeDuration, isExternalFactUrl, jsonldFileAdapter, mergeSecSections, numericKindOf, parseJsonld, parseStore, parseStructureDefinition, parseStructureName, qname } from './chunk-GJL4ILVH.js';
3
3
  import { useState, useEffect, useMemo, useRef } from 'react';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
 
@@ -424,9 +424,11 @@ function buildPivot(model, ib, config = defaultPivotConfig(model, ib)) {
424
424
  }
425
425
  }
426
426
  const columnHeaders = headerLevels(columnSegs);
427
+ const shownAxes = /* @__PURE__ */ new Set([...rowDimAxes, ...colDimAxes]);
427
428
  const factIndex = /* @__PURE__ */ new Map();
428
429
  for (const f of facts) {
429
430
  const byAxis = memberByAxis(f);
431
+ if ([...byAxis.keys()].some((axis) => !shownAxes.has(axis))) continue;
430
432
  const end = model.periods[f.period]?.end ?? "";
431
433
  const rowSig = coordinate(byAxis, rowDimAxes);
432
434
  const colSig = coordinate(byAxis, colDimAxes);
@@ -531,6 +533,8 @@ function buildPivot(model, ib, config = defaultPivotConfig(model, ib)) {
531
533
  blockType: ib.blockType,
532
534
  title,
533
535
  structureName: ib.structureId ? null : structure?.structureName ?? ib.label ?? null,
536
+ definition: structure?.definition ?? null,
537
+ kind: structure?.kind ?? null,
534
538
  slicers: buildSlicers(model, facts, config),
535
539
  columnHeaders,
536
540
  columns,
@@ -540,7 +544,12 @@ function buildPivot(model, ib, config = defaultPivotConfig(model, ib)) {
540
544
  };
541
545
  }
542
546
  function reportSections(model) {
543
- return buildPivots(model).map((p) => ({ id: p.ib.id, title: p.title }));
547
+ return buildPivots(model).map((p) => ({
548
+ id: p.ib.id,
549
+ title: p.title,
550
+ definition: p.definition,
551
+ kind: p.kind
552
+ }));
544
553
  }
545
554
  function buildPivots(model, configFor) {
546
555
  const order = (ib) => {