@robosystems/report-components 0.1.0 → 0.1.1

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.
Files changed (51) hide show
  1. package/dist/adapters/index.d.ts +1 -5
  2. package/dist/adapters/index.js +2 -2
  3. package/dist/adapters/index.js.map +1 -1
  4. package/dist/chunk-K67BB5QI.js +264 -0
  5. package/dist/chunk-K67BB5QI.js.map +1 -0
  6. package/dist/{model.d.ts → index-2pOwdKOv.d.ts} +60 -17
  7. package/dist/index.d.ts +118 -23
  8. package/dist/index.js +491 -23
  9. package/dist/index.js.map +1 -1
  10. package/package.json +3 -2
  11. package/dist/adapters/cypher.d.ts +0 -21
  12. package/dist/adapters/cypher.d.ts.map +0 -1
  13. package/dist/adapters/cypher.js +0 -9
  14. package/dist/adapters/cypher.js.map +0 -1
  15. package/dist/adapters/index.d.ts.map +0 -1
  16. package/dist/adapters/trig.d.ts +0 -7
  17. package/dist/adapters/trig.d.ts.map +0 -1
  18. package/dist/adapters/trig.js +0 -183
  19. package/dist/adapters/trig.js.map +0 -1
  20. package/dist/adapters/types.d.ts +0 -16
  21. package/dist/adapters/types.d.ts.map +0 -1
  22. package/dist/adapters/types.js +0 -2
  23. package/dist/adapters/types.js.map +0 -1
  24. package/dist/components/FactInspector.d.ts +0 -11
  25. package/dist/components/FactInspector.d.ts.map +0 -1
  26. package/dist/components/FactInspector.js +0 -79
  27. package/dist/components/FactInspector.js.map +0 -1
  28. package/dist/components/ReportView.d.ts +0 -9
  29. package/dist/components/ReportView.d.ts.map +0 -1
  30. package/dist/components/ReportView.js +0 -51
  31. package/dist/components/ReportView.js.map +0 -1
  32. package/dist/components/StatementTable.d.ts +0 -15
  33. package/dist/components/StatementTable.d.ts.map +0 -1
  34. package/dist/components/StatementTable.js +0 -86
  35. package/dist/components/StatementTable.js.map +0 -1
  36. package/dist/constants.d.ts +0 -71
  37. package/dist/constants.d.ts.map +0 -1
  38. package/dist/constants.js +0 -115
  39. package/dist/constants.js.map +0 -1
  40. package/dist/format.d.ts +0 -17
  41. package/dist/format.d.ts.map +0 -1
  42. package/dist/format.js +0 -34
  43. package/dist/format.js.map +0 -1
  44. package/dist/index.d.ts.map +0 -1
  45. package/dist/model.d.ts.map +0 -1
  46. package/dist/model.js +0 -15
  47. package/dist/model.js.map +0 -1
  48. package/dist/project.d.ts +0 -39
  49. package/dist/project.d.ts.map +0 -1
  50. package/dist/project.js +0 -201
  51. package/dist/project.js.map +0 -1
@@ -1,5 +1 @@
1
- export { cypherAdapter } from './cypher';
2
- export type { CypherAdapterConfig } from './cypher';
3
- export { parseTrig, trigFileAdapter } from './trig';
4
- export type { ReportAdapter } from './types';
5
- //# sourceMappingURL=index.d.ts.map
1
+ export { b as CypherAdapterConfig, R as ReportAdapter, i as cypherAdapter, p as parseTrig, t as trigFileAdapter } from '../index-2pOwdKOv.js';
@@ -1,3 +1,3 @@
1
- export { cypherAdapter } from './cypher';
2
- export { parseTrig, trigFileAdapter } from './trig';
1
+ export { cypherAdapter, parseTrig, trigFileAdapter } from '../chunk-K67BB5QI.js';
2
+ //# sourceMappingURL=index.js.map
3
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/adapters/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAA"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
@@ -0,0 +1,264 @@
1
+ import { DataFactory, Parser, Store } from 'n3';
2
+
3
+ // src/constants.ts
4
+ var NS = {
5
+ rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
6
+ rs: "https://robosystems.ai/vocab/",
7
+ rsgaap: "https://robosystems.ai/taxonomy/rs-gaap/v1/",
8
+ skos: "http://www.w3.org/2004/02/skos/core#",
9
+ xlink: "http://www.w3.org/1999/xlink#",
10
+ xbrli: "http://www.xbrl.org/2003/instance#",
11
+ link: "http://www.xbrl.org/2003/linkbase#",
12
+ iso4217: "http://www.xbrl.org/2003/iso4217#"
13
+ };
14
+ var IRI = {
15
+ type: NS.rdf + "type",
16
+ // rs: classes
17
+ Report: NS.rs + "Report",
18
+ Fact: NS.rs + "Fact",
19
+ InformationBlock: NS.rs + "InformationBlock",
20
+ Structure: NS.rs + "Structure",
21
+ Association: NS.rs + "Association",
22
+ Element: NS.rs + "Element",
23
+ Period: NS.rs + "Period",
24
+ Unit: NS.rs + "Unit",
25
+ Entity: NS.rs + "Entity",
26
+ // rs: predicates
27
+ element: NS.rs + "element",
28
+ period: NS.rs + "period",
29
+ unit: NS.rs + "unit",
30
+ entity: NS.rs + "entity",
31
+ factSet: NS.rs + "factSet",
32
+ numericValue: NS.rs + "numericValue",
33
+ decimals: NS.rs + "decimals",
34
+ blockType: NS.rs + "blockType",
35
+ associationType: NS.rs + "associationType",
36
+ hasAssociation: NS.rs + "hasAssociation",
37
+ roleUri: NS.rs + "roleUri",
38
+ structureName: NS.rs + "structureName",
39
+ abstract: NS.rs + "abstract",
40
+ monetary: NS.rs + "monetary",
41
+ legalName: NS.rs + "legalName",
42
+ country: NS.rs + "country",
43
+ // skos:
44
+ prefLabel: NS.skos + "prefLabel",
45
+ // xlink:
46
+ from: NS.xlink + "from",
47
+ to: NS.xlink + "to",
48
+ role: NS.xlink + "role",
49
+ // xbrli:
50
+ instant: NS.xbrli + "instant",
51
+ startDate: NS.xbrli + "startDate",
52
+ endDate: NS.xbrli + "endDate",
53
+ periodType: NS.xbrli + "periodType",
54
+ balance: NS.xbrli + "balance",
55
+ measure: NS.xbrli + "measure",
56
+ // link:
57
+ order: NS.link + "order",
58
+ weight: NS.link + "weight"
59
+ };
60
+ var PREFIXES = [
61
+ ["rs-gaap", NS.rsgaap],
62
+ ["disclosures", "https://robosystems.ai/taxonomy/rs-gaap/disclosures/v1/"],
63
+ ["us-gaap", "http://fasb.org/us-gaap/"],
64
+ ["dei", "http://xbrl.sec.gov/dei/"],
65
+ ["rs", NS.rs],
66
+ ["skos", NS.skos],
67
+ ["xbrli", NS.xbrli],
68
+ ["xlink", NS.xlink],
69
+ ["link", NS.link],
70
+ ["iso4217", NS.iso4217]
71
+ ];
72
+ function qname(iri) {
73
+ for (const [prefix, ns] of PREFIXES) {
74
+ if (iri.startsWith(ns)) {
75
+ return `${prefix}:${iri.slice(ns.length)}`;
76
+ }
77
+ }
78
+ const slash = iri.lastIndexOf("/");
79
+ const hash = iri.lastIndexOf("#");
80
+ return iri.slice(Math.max(slash, hash) + 1);
81
+ }
82
+ function humanize(iri) {
83
+ const local = qname(iri).split(":").pop() ?? iri;
84
+ return local.replace(/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/g, " ");
85
+ }
86
+ var BLOCK_ORDER = {
87
+ balance_sheet: 0,
88
+ income_statement: 1,
89
+ cash_flow_statement: 2,
90
+ equity_statement: 3
91
+ };
92
+ var BLOCK_TITLES = {
93
+ balance_sheet: "Balance Sheet",
94
+ income_statement: "Income Statement",
95
+ cash_flow_statement: "Cash Flow Statement",
96
+ equity_statement: "Statement of Changes in Equity"
97
+ };
98
+
99
+ // src/adapters/cypher.ts
100
+ function cypherAdapter(config) {
101
+ return {
102
+ source: `cypher:${config.graphId}/${config.reportId}`,
103
+ load: async () => {
104
+ throw new Error(
105
+ "The cypher adapter is not implemented yet (phase 2 / Mode B \u2014 live SEC graph)."
106
+ );
107
+ }
108
+ };
109
+ }
110
+ var { namedNode } = DataFactory;
111
+ function makeReaders(store) {
112
+ const objects = (s, p) => store.getObjects(namedNode(s), namedNode(p), null);
113
+ const firstValue = (s, p) => {
114
+ const os = objects(s, p);
115
+ return os.length ? os[0].value : null;
116
+ };
117
+ const subjectsOfType = (type) => store.getSubjects(namedNode(IRI.type), namedNode(type), null).map((t) => t.value);
118
+ return { objects, firstValue, subjectsOfType };
119
+ }
120
+ function toNumber(raw) {
121
+ if (raw === null || raw === "") return null;
122
+ const n = Number(raw);
123
+ return Number.isNaN(n) ? null : n;
124
+ }
125
+ function parseTrig(trig) {
126
+ const parser = new Parser({ format: "application/trig" });
127
+ const store = new Store(parser.parse(trig));
128
+ const { objects, firstValue, subjectsOfType } = makeReaders(store);
129
+ const elements = {};
130
+ for (const id of subjectsOfType(IRI.Element)) {
131
+ const balance = firstValue(id, IRI.balance);
132
+ const periodType = firstValue(id, IRI.periodType);
133
+ elements[id] = {
134
+ id,
135
+ qname: qname(id),
136
+ label: firstValue(id, IRI.prefLabel) ?? humanize(id),
137
+ balance: balance === "debit" || balance === "credit" ? balance : null,
138
+ periodType: periodType === "instant" || periodType === "duration" ? periodType : null,
139
+ abstract: firstValue(id, IRI.abstract) === "true",
140
+ monetary: firstValue(id, IRI.monetary) === "true"
141
+ };
142
+ }
143
+ const periods = {};
144
+ for (const id of subjectsOfType(IRI.Period)) {
145
+ const declared = firstValue(id, IRI.periodType);
146
+ const instant = firstValue(id, IRI.instant);
147
+ const startDate = firstValue(id, IRI.startDate);
148
+ const endDate = firstValue(id, IRI.endDate);
149
+ const type = declared === "instant" ? "instant" : declared === "duration" ? "duration" : instant ? "instant" : "duration";
150
+ const end = (type === "instant" ? instant : endDate) ?? instant ?? endDate ?? "";
151
+ periods[id] = { id, type, instant, startDate, endDate, end };
152
+ }
153
+ const units = {};
154
+ for (const id of subjectsOfType(IRI.Unit)) {
155
+ const measureTerm = objects(id, IRI.measure)[0];
156
+ const measure = measureTerm ? qname(measureTerm.value) : "unknown";
157
+ units[id] = {
158
+ id,
159
+ measure,
160
+ label: measure.includes(":") ? measure.split(":").pop() : measure
161
+ };
162
+ }
163
+ let entity = null;
164
+ const entityIds = subjectsOfType(IRI.Entity);
165
+ if (entityIds.length) {
166
+ const id = entityIds[0];
167
+ entity = {
168
+ id,
169
+ name: firstValue(id, IRI.prefLabel) ?? firstValue(id, IRI.legalName) ?? "Entity",
170
+ legalName: firstValue(id, IRI.legalName),
171
+ country: firstValue(id, IRI.country)
172
+ };
173
+ }
174
+ const facts = [];
175
+ for (const id of subjectsOfType(IRI.Fact)) {
176
+ facts.push({
177
+ id,
178
+ element: firstValue(id, IRI.element) ?? "",
179
+ period: firstValue(id, IRI.period) ?? "",
180
+ unit: firstValue(id, IRI.unit),
181
+ entity: firstValue(id, IRI.entity),
182
+ factSet: firstValue(id, IRI.factSet),
183
+ value: toNumber(firstValue(id, IRI.numericValue)),
184
+ decimals: firstValue(id, IRI.decimals)
185
+ });
186
+ }
187
+ const informationBlocks = [];
188
+ for (const id of subjectsOfType(IRI.InformationBlock)) {
189
+ informationBlocks.push({
190
+ id,
191
+ blockType: firstValue(id, IRI.blockType) ?? "",
192
+ factSet: firstValue(id, IRI.factSet),
193
+ label: firstValue(id, IRI.prefLabel)
194
+ });
195
+ }
196
+ const structures = [];
197
+ const assocStructure = /* @__PURE__ */ new Map();
198
+ for (const id of subjectsOfType(IRI.Structure)) {
199
+ structures.push({
200
+ id,
201
+ blockType: firstValue(id, IRI.blockType) ?? "",
202
+ roleUri: firstValue(id, IRI.roleUri),
203
+ structureName: firstValue(id, IRI.structureName)
204
+ });
205
+ for (const assoc of objects(id, IRI.hasAssociation)) {
206
+ assocStructure.set(assoc.value, id);
207
+ }
208
+ }
209
+ const calcAssociations = [];
210
+ const presAssociations = [];
211
+ for (const id of subjectsOfType(IRI.Association)) {
212
+ const parent = firstValue(id, IRI.from);
213
+ const child = firstValue(id, IRI.to);
214
+ if (!parent || !child) continue;
215
+ const type = firstValue(id, IRI.associationType);
216
+ const order = toNumber(firstValue(id, IRI.order)) ?? 0;
217
+ const role = firstValue(id, IRI.role);
218
+ const structure = assocStructure.get(id) ?? null;
219
+ if (type === "calculation") {
220
+ calcAssociations.push({
221
+ parent,
222
+ child,
223
+ weight: toNumber(firstValue(id, IRI.weight)) ?? 1,
224
+ order,
225
+ role,
226
+ structure
227
+ });
228
+ } else if (type === "presentation") {
229
+ presAssociations.push({ parent, child, order, role, structure });
230
+ }
231
+ }
232
+ let reportIri = null;
233
+ for (const graph of store.getGraphs(null, null, null)) {
234
+ const hash = graph.value.indexOf("#");
235
+ if (hash > 0) {
236
+ reportIri = graph.value.slice(0, hash);
237
+ break;
238
+ }
239
+ }
240
+ const reportId = reportIri ? reportIri.split("/").pop() ?? null : null;
241
+ return {
242
+ reportId,
243
+ reportIri,
244
+ entity,
245
+ informationBlocks,
246
+ structures,
247
+ facts,
248
+ elements,
249
+ periods,
250
+ units,
251
+ calcAssociations,
252
+ presAssociations
253
+ };
254
+ }
255
+ function trigFileAdapter(trig, source = "holon.trig") {
256
+ return {
257
+ source,
258
+ load: async () => parseTrig(trig)
259
+ };
260
+ }
261
+
262
+ export { BLOCK_ORDER, BLOCK_TITLES, NS, cypherAdapter, humanize, parseTrig, qname, trigFileAdapter };
263
+ //# sourceMappingURL=chunk-K67BB5QI.js.map
264
+ //# sourceMappingURL=chunk-K67BB5QI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/constants.ts","../src/adapters/cypher.ts","../src/adapters/trig.ts"],"names":[],"mappings":";;;AAQO,IAAM,EAAA,GAAK;AAAA,EAChB,GAAA,EAAK,6CAAA;AAAA,EACL,EAAA,EAAI,+BAAA;AAAA,EACJ,MAAA,EAAQ,6CAAA;AAAA,EACR,IAAA,EAAM,sCAAA;AAAA,EACN,KAAA,EAAO,+BAAA;AAAA,EACP,KAAA,EAAO,oCAAA;AAAA,EACP,IAAA,EAAM,oCAAA;AAAA,EACN,OAAA,EAAS;AACX;AAGO,IAAM,GAAA,GAAM;AAAA,EACjB,IAAA,EAAM,GAAG,GAAA,GAAM,MAAA;AAAA;AAAA,EAEf,MAAA,EAAQ,GAAG,EAAA,GAAK,QAAA;AAAA,EAChB,IAAA,EAAM,GAAG,EAAA,GAAK,MAAA;AAAA,EACd,gBAAA,EAAkB,GAAG,EAAA,GAAK,kBAAA;AAAA,EAC1B,SAAA,EAAW,GAAG,EAAA,GAAK,WAAA;AAAA,EACnB,WAAA,EAAa,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A,QACA,QAAQ,QAAA,CAAS,UAAA,CAAW,IAAI,GAAA,CAAI,MAAM,CAAC,CAAA,IAAK,CAAA;AAAA,QAChD,KAAA;AAAA,QACA,IAAA;AAAA,QACA;AAAA,OACD,CAAA;AAAA,IACH,CAAA,MAAA,IAAW,SAAS,cAAA,EAAgB;AAClC,MAAA,gBAAA,CAAiB,KAAK,EAAE,MAAA,EAAQ,OAAO,KAAA,EAAO,IAAA,EAAM,WAAW,CAAA;AAAA,IACjE;AAAA,EACF;AAGA,EAAA,IAAI,SAAA,GAA2B,IAAA;AAC/B,EAAA,KAAA,MAAW,SAAS,KAAA,CAAM,SAAA,CAAU,IAAA,EAAM,IAAA,EAAM,IAAI,CAAA,EAAG;AACrD,IAAA,MAAM,IAAA,GAAO,KAAA,CAAM,KAAA,CAAM,OAAA,CAAQ,GAAG,CAAA;AACpC,IAAA,IAAI,OAAO,CAAA,EAAG;AACZ,MAAA,SAAA,GAAY,KAAA,CAAM,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,IAAI,CAAA;AACrC,MAAA;AAAA,IACF;AAAA,EACF;AACA,EAAA,MAAM,QAAA,GAAW,YAAa,SAAA,CAAU,KAAA,CAAM,GAAG,CAAA,CAAE,GAAA,MAAS,IAAA,GAAQ,IAAA;AAEpE,EAAA,OAAO;AAAA,IACL,QAAA;AAAA,IACA,SAAA;AAAA,IACA,MAAA;AAAA,IACA,iBAAA;AAAA,IACA,UAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,OAAA;AAAA,IACA,KAAA;AAAA,IACA,gBAAA;AAAA,IACA;AAAA,GACF;AACF;AAGO,SAAS,eAAA,CAAgB,IAAA,EAAc,MAAA,GAAS,YAAA,EAA6B;AAClF,EAAA,OAAO;AAAA,IACL,MAAA;AAAA,IACA,IAAA,EAAM,YAAY,SAAA,CAAU,IAAI;AAAA,GAClC;AACF","file":"chunk-K67BB5QI.js","sourcesContent":["/**\n * RDF vocabulary and display helpers shared across adapters and projection.\n *\n * A `holon.trig` 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 decimals: NS.rs + 'decimals',\n blockType: NS.rs + 'blockType',\n associationType: NS.rs + 'associationType',\n hasAssociation: NS.rs + 'hasAssociation',\n roleUri: NS.rs + 'roleUri',\n structureName: NS.rs + 'structureName',\n abstract: NS.rs + 'abstract',\n monetary: NS.rs + 'monetary',\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/** 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 * The cypher / GraphQL adapter — a live graph database (an entity graph **or**\n * the SEC repository) read read-only with an API key. One adapter for both:\n * only the endpoint / `graphId` differ.\n *\n * Phase 2 (Mode B). Stubbed for now so the seam and the `./adapters` export\n * surface are in place; the holon-viewer's SEC mode will drive its build-out.\n */\nimport type { ReportAdapter } from './types'\n\nexport interface CypherAdapterConfig {\n /** GraphQL / cypher endpoint base URL. */\n endpoint: string\n /** User-supplied API key (sent client-side; never app-managed). */\n apiKey: string\n /** Target graph — an entity graph id or the SEC repository id. */\n graphId: string\n /** The report to materialize. */\n reportId: string\n}\n\nexport function cypherAdapter(config: CypherAdapterConfig): ReportAdapter {\n return {\n source: `cypher:${config.graphId}/${config.reportId}`,\n load: async () => {\n throw new Error(\n 'The cypher adapter is not implemented yet (phase 2 / Mode B — live SEC graph).'\n )\n },\n }\n}\n","/**\n * The `holon.trig` file adapter — offline, no backend, no auth.\n *\n * Parses TriG (three named graphs: `#scene`, `#boundary`, `#projection`) with\n * N3.js into a quad store, then traverses the store to emit a `NormalizedReport`.\n * The three graphs are queried as a union (graph = `null`) — exactly the join\n * the DataBook converter does on the flat graph. No SPARQL engine is required;\n * only store traversal.\n */\nimport { DataFactory, Parser, Store } from 'n3'\nimport { IRI, humanize, qname } from '../constants'\nimport type {\n CalcAssociation,\n ElementInfo,\n EntityInfo,\n Fact,\n InformationBlock,\n NormalizedReport,\n PeriodInfo,\n PeriodType,\n PresAssociation,\n StructureInfo,\n UnitInfo,\n} from '../model'\nimport type { ReportAdapter } from './types'\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/** Parse a `holon.trig` document into the normalized report model. */\nexport function parseTrig(trig: string): NormalizedReport {\n const parser = new Parser({ format: 'application/trig' })\n const store = new Store(parser.parse(trig))\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 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 }\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 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 decimals: firstValue(id, IRI.decimals),\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 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 structures.push({\n id,\n blockType: firstValue(id, IRI.blockType) ?? '',\n roleUri: firstValue(id, IRI.roleUri),\n structureName: firstValue(id, IRI.structureName),\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 (from the named-graph names) ──\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 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/** A `ReportAdapter` over an in-memory `holon.trig` document. */\nexport function trigFileAdapter(trig: string, source = 'holon.trig'): ReportAdapter {\n return {\n source,\n load: async () => parseTrig(trig),\n }\n}\n"]}
@@ -11,10 +11,10 @@
11
11
  * subtotals, the table layout. That work is identical for every adapter, which
12
12
  * is what makes the rendering source-agnostic.
13
13
  */
14
- export type PeriodType = 'instant' | 'duration';
15
- export type BalanceType = 'debit' | 'credit';
14
+ type PeriodType = 'instant' | 'duration';
15
+ type BalanceType = 'debit' | 'credit';
16
16
  /** A reportable concept (a taxonomy element). */
17
- export interface ElementInfo {
17
+ interface ElementInfo {
18
18
  /** Full element IRI — the join key used everywhere. */
19
19
  id: string;
20
20
  /** Compacted name, e.g. `rs-gaap:Assets`. */
@@ -27,7 +27,7 @@ export interface ElementInfo {
27
27
  monetary: boolean;
28
28
  }
29
29
  /** A reporting period — an instant (balance sheet) or a duration (flows). */
30
- export interface PeriodInfo {
30
+ interface PeriodInfo {
31
31
  id: string;
32
32
  type: PeriodType;
33
33
  instant: string | null;
@@ -37,7 +37,7 @@ export interface PeriodInfo {
37
37
  end: string;
38
38
  }
39
39
  /** A unit of measure, e.g. USD. */
40
- export interface UnitInfo {
40
+ interface UnitInfo {
41
41
  id: string;
42
42
  /** Compacted measure, e.g. `iso4217:USD`. */
43
43
  measure: string;
@@ -45,14 +45,14 @@ export interface UnitInfo {
45
45
  label: string;
46
46
  }
47
47
  /** The reporting entity. */
48
- export interface EntityInfo {
48
+ interface EntityInfo {
49
49
  id: string;
50
50
  name: string;
51
51
  legalName: string | null;
52
52
  country: string | null;
53
53
  }
54
54
  /** A single reported value. */
55
- export interface Fact {
55
+ interface Fact {
56
56
  id: string;
57
57
  /** Element IRI. */
58
58
  element: string;
@@ -68,7 +68,7 @@ export interface Fact {
68
68
  decimals: string | null;
69
69
  }
70
70
  /** A calculation arc: `parent` (subtotal) rolls up `child * weight`. */
71
- export interface CalcAssociation {
71
+ interface CalcAssociation {
72
72
  parent: string;
73
73
  child: string;
74
74
  weight: number;
@@ -77,7 +77,7 @@ export interface CalcAssociation {
77
77
  structure: string | null;
78
78
  }
79
79
  /** A presentation arc: `parent` shows `child` at the given order. */
80
- export interface PresAssociation {
80
+ interface PresAssociation {
81
81
  parent: string;
82
82
  child: string;
83
83
  order: number;
@@ -85,21 +85,21 @@ export interface PresAssociation {
85
85
  structure: string | null;
86
86
  }
87
87
  /** A network root — groups associations under one role / block type. */
88
- export interface StructureInfo {
88
+ interface StructureInfo {
89
89
  id: string;
90
90
  blockType: string;
91
91
  roleUri: string | null;
92
92
  structureName: string | null;
93
93
  }
94
94
  /** An Information Block — groups a statement's facts via a shared `factSet`. */
95
- export interface InformationBlock {
95
+ interface InformationBlock {
96
96
  id: string;
97
97
  blockType: string;
98
98
  factSet: string | null;
99
99
  label: string | null;
100
100
  }
101
101
  /** The full normalized report — the adapter's output and projection's input. */
102
- export interface NormalizedReport {
102
+ interface NormalizedReport {
103
103
  reportId: string | null;
104
104
  reportIri: string | null;
105
105
  entity: EntityInfo | null;
@@ -113,7 +113,7 @@ export interface NormalizedReport {
113
113
  presAssociations: PresAssociation[];
114
114
  }
115
115
  /** A statement column, keyed by the period end date facts are matched against. */
116
- export interface StatementColumn {
116
+ interface StatementColumn {
117
117
  /** The period end date used to match facts into this column. */
118
118
  key: string;
119
119
  /** Human header label. */
@@ -122,12 +122,12 @@ export interface StatementColumn {
122
122
  period: PeriodInfo;
123
123
  }
124
124
  /** One value in a row, plus the fact behind it (for inspection / footing). */
125
- export interface RowCell {
125
+ interface RowCell {
126
126
  value: number | null;
127
127
  fact: Fact | null;
128
128
  }
129
129
  /** A rendered statement line. */
130
- export interface StatementRow {
130
+ interface StatementRow {
131
131
  element: ElementInfo;
132
132
  /** Tree depth — drives indentation. */
133
133
  depth: number;
@@ -136,7 +136,7 @@ export interface StatementRow {
136
136
  cells: RowCell[];
137
137
  }
138
138
  /** A fully reconstructed statement, ready to render. */
139
- export interface Statement {
139
+ interface Statement {
140
140
  ib: InformationBlock;
141
141
  blockType: string;
142
142
  /** Friendly heading, e.g. "Balance Sheet". */
@@ -145,4 +145,47 @@ export interface Statement {
145
145
  columns: StatementColumn[];
146
146
  rows: StatementRow[];
147
147
  }
148
- //# sourceMappingURL=model.d.ts.map
148
+
149
+ /**
150
+ * The adapter seam. An adapter turns one source into a `NormalizedReport`; the
151
+ * projection + components do the rest, identically for every source.
152
+ *
153
+ * The package ships two read-only reference adapters — `trig` (offline file via
154
+ * N3.js) and `cypher` (a live graph database). A consuming app with operational
155
+ * needs (a live ledger it also edits) supplies its own adapter in-app.
156
+ */
157
+
158
+ interface ReportAdapter {
159
+ /** A short, human-readable description of the source (for the UI). */
160
+ readonly source: string;
161
+ /** Produce the normalized report model. */
162
+ load(): Promise<NormalizedReport>;
163
+ }
164
+
165
+ /**
166
+ * The cypher / GraphQL adapter — a live graph database (an entity graph **or**
167
+ * the SEC repository) read read-only with an API key. One adapter for both:
168
+ * only the endpoint / `graphId` differ.
169
+ *
170
+ * Phase 2 (Mode B). Stubbed for now so the seam and the `./adapters` export
171
+ * surface are in place; the holon-viewer's SEC mode will drive its build-out.
172
+ */
173
+
174
+ interface CypherAdapterConfig {
175
+ /** GraphQL / cypher endpoint base URL. */
176
+ endpoint: string;
177
+ /** User-supplied API key (sent client-side; never app-managed). */
178
+ apiKey: string;
179
+ /** Target graph — an entity graph id or the SEC repository id. */
180
+ graphId: string;
181
+ /** The report to materialize. */
182
+ reportId: string;
183
+ }
184
+ declare function cypherAdapter(config: CypherAdapterConfig): ReportAdapter;
185
+
186
+ /** Parse a `holon.trig` document into the normalized report model. */
187
+ declare function parseTrig(trig: string): NormalizedReport;
188
+ /** A `ReportAdapter` over an in-memory `holon.trig` document. */
189
+ declare function trigFileAdapter(trig: string, source?: string): ReportAdapter;
190
+
191
+ export { type BalanceType as B, type CalcAssociation as C, type ElementInfo as E, type Fact as F, type InformationBlock as I, type NormalizedReport as N, type PeriodInfo as P, type ReportAdapter as R, type Statement as S, type UnitInfo as U, type StatementRow as a, type CypherAdapterConfig as b, type EntityInfo as c, type PeriodType as d, type PresAssociation as e, type RowCell as f, type StatementColumn as g, type StructureInfo as h, cypherAdapter as i, parseTrig as p, trigFileAdapter as t };
package/dist/index.d.ts CHANGED
@@ -1,26 +1,121 @@
1
+ import { P as PeriodInfo, E as ElementInfo, N as NormalizedReport, S as Statement, a as StatementRow } from './index-2pOwdKOv.js';
2
+ export { B as BalanceType, C as CalcAssociation, b as CypherAdapterConfig, c as EntityInfo, F as Fact, I as InformationBlock, d as PeriodType, e as PresAssociation, R as ReportAdapter, f as RowCell, g as StatementColumn, h as StructureInfo, U as UnitInfo, i as cypherAdapter, p as parseTrig, t as trigFileAdapter } from './index-2pOwdKOv.js';
3
+ import * as react from 'react';
4
+
1
5
  /**
2
- * `@robosystems/report-components` public API.
6
+ * RDF vocabulary and display helpers shared across adapters and projection.
3
7
  *
4
- * Render XBRL-grade financial statements from any source behind a thin adapter:
5
- *
6
- * import { ReportView } from '@robosystems/report-components'
7
- * import { trigFileAdapter } from '@robosystems/report-components/adapters'
8
- *
9
- * const report = await trigFileAdapter(trigText).load()
10
- * <ReportView report={report} />
8
+ * A `holon.trig` mixes several vocabularies: `rs:` for structure, `skos:` for
9
+ * human labels, and the XBRL family (`xlink:` / `xbrli:` / `link:`) for the
10
+ * networks. These constants are the single source of truth for the full IRIs.
11
+ */
12
+ declare const NS: {
13
+ readonly rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
14
+ readonly rs: "https://robosystems.ai/vocab/";
15
+ readonly rsgaap: "https://robosystems.ai/taxonomy/rs-gaap/v1/";
16
+ readonly skos: "http://www.w3.org/2004/02/skos/core#";
17
+ readonly xlink: "http://www.w3.org/1999/xlink#";
18
+ readonly xbrli: "http://www.xbrl.org/2003/instance#";
19
+ readonly link: "http://www.xbrl.org/2003/linkbase#";
20
+ readonly iso4217: "http://www.xbrl.org/2003/iso4217#";
21
+ };
22
+ /** Compact a concept IRI to `prefix:Local` (e.g. `rs-gaap:Assets`). */
23
+ declare function qname(iri: string): string;
24
+ /**
25
+ * Readable concept name from a local name when no `skos:prefLabel` is present —
26
+ * splits CamelCase into words (`AssetsCurrent` → `Assets Current`). A graceful
27
+ * fallback for bundles that predate label emit.
28
+ */
29
+ declare function humanize(iri: string): string;
30
+ /** Stable display order for the canonical statement blocks; others fall after. */
31
+ declare const BLOCK_ORDER: Record<string, number>;
32
+ /** Friendly section headings keyed by block type. */
33
+ declare const BLOCK_TITLES: Record<string, string>;
34
+
35
+ /**
36
+ * Pure formatting helpers shared by the projection and the components. No React
37
+ * here, so the projection can depend on it without pulling in a renderer.
38
+ */
39
+
40
+ /**
41
+ * Accounting-style money: negatives in parentheses, no sign, an em-dash for
42
+ * absent values. Matches the RoboLedger statement renderer.
43
+ */
44
+ declare function formatMoney(value: number | null | undefined, opts?: {
45
+ currencySymbol?: string;
46
+ }): string;
47
+ /** `2024-03-31` → `Mar 31, 2024`. Falls back to the raw string if unparseable. */
48
+ declare function formatDate(iso: string | null | undefined): string;
49
+ /** A human description of a period — "As of …" for instants, a span for durations. */
50
+ declare function formatPeriod(period: PeriodInfo): string;
51
+
52
+ interface OrderEntry {
53
+ order: number;
54
+ depth: number;
55
+ }
56
+ /**
57
+ * Post-order the presentation arcs of one structure → `{element: {order, depth}}`.
58
+ * Roots (a `from` that is never a `to`) are visited by their subtree's leading
59
+ * arc order, so a balance sheet's roots (Assets, then Liabilities and Equity)
60
+ * come out in the right sequence.
61
+ */
62
+ declare function presentationOrder(model: NormalizedReport, structureId: string): Map<string, OrderEntry>;
63
+ /** Concepts that are calculation parents — the authoritative subtotal set. */
64
+ declare function calcSubtotals(model: NormalizedReport): Set<string>;
65
+ /** Reconstruct every statement in the report, in canonical block order. */
66
+ declare function buildStatements(model: NormalizedReport): Statement[];
67
+ interface FootTerm {
68
+ element: ElementInfo;
69
+ weight: number;
70
+ value: number | null;
71
+ }
72
+ interface FootCheck {
73
+ element: ElementInfo;
74
+ columnIndex: number;
75
+ terms: FootTerm[];
76
+ /** Σ child·weight over the present terms, or null if none are present. */
77
+ expected: number | null;
78
+ /** The subtotal's own reported value in this column. */
79
+ actual: number | null;
80
+ ok: boolean;
81
+ }
82
+ /**
83
+ * Foot a subtotal live: sum its calculation children (× weight) and compare to
84
+ * its reported value, e.g. `13,550 + 900 = 14,450 ✓`. Returns `null` when the
85
+ * element is not a calculation parent (nothing to foot).
11
86
  */
12
- export { BLOCK_ORDER, BLOCK_TITLES, NS, humanize, qname } from './constants';
13
- export * from './format';
14
- export * from './model';
15
- export * from './project';
16
- export { FactInspector } from './components/FactInspector';
17
- export type { FactInspectorProps } from './components/FactInspector';
18
- export { ReportView } from './components/ReportView';
19
- export type { ReportViewProps } from './components/ReportView';
20
- export { StatementTable } from './components/StatementTable';
21
- export type { StatementTableProps } from './components/StatementTable';
22
- export { cypherAdapter } from './adapters/cypher';
23
- export type { CypherAdapterConfig } from './adapters/cypher';
24
- export { parseTrig, trigFileAdapter } from './adapters/trig';
25
- export type { ReportAdapter } from './adapters/types';
26
- //# sourceMappingURL=index.d.ts.map
87
+ declare function footCheck(model: NormalizedReport, statement: Statement, elementId: string, columnIndex: number): FootCheck | null;
88
+
89
+ interface FactInspectorProps {
90
+ report: NormalizedReport;
91
+ statement: Statement;
92
+ row: StatementRow;
93
+ columnIndex: number;
94
+ onClose?: () => void;
95
+ currencySymbol?: string;
96
+ }
97
+ declare function FactInspector({ report, statement, row, columnIndex, onClose, currencySymbol, }: FactInspectorProps): react.JSX.Element;
98
+
99
+ interface ReportViewProps {
100
+ report: NormalizedReport;
101
+ currencySymbol?: string;
102
+ /** Disable the click-to-inspect fact panel (render-only). */
103
+ inspect?: boolean;
104
+ }
105
+ declare function ReportView({ report, currencySymbol, inspect }: ReportViewProps): react.JSX.Element;
106
+
107
+ interface StatementTableProps {
108
+ statement: Statement;
109
+ /** Called when a value cell is clicked — drives fact inspection. */
110
+ onCellClick?: (row: StatementRow, columnIndex: number) => void;
111
+ /** Currency symbol for values (default `$`). */
112
+ currencySymbol?: string;
113
+ /** The currently-selected cell, highlighted. */
114
+ selected?: {
115
+ elementId: string;
116
+ columnIndex: number;
117
+ } | null;
118
+ }
119
+ declare function StatementTable({ statement, onCellClick, currencySymbol, selected, }: StatementTableProps): react.JSX.Element;
120
+
121
+ export { BLOCK_ORDER, BLOCK_TITLES, ElementInfo, FactInspector, type FactInspectorProps, type FootCheck, type FootTerm, NS, NormalizedReport, PeriodInfo, ReportView, type ReportViewProps, Statement, StatementRow, StatementTable, type StatementTableProps, buildStatements, calcSubtotals, footCheck, formatDate, formatMoney, formatPeriod, humanize, presentationOrder, qname };