@robosystems/report-components 0.1.4 → 0.2.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.
- package/dist/adapters/index.d.ts +1 -1
- package/dist/adapters/index.js +1 -1
- package/dist/chunk-DGP4KRWF.js +721 -0
- package/dist/chunk-DGP4KRWF.js.map +1 -0
- package/dist/index-WkjE6dZu.d.ts +427 -0
- package/dist/index.d.ts +108 -21
- package/dist/index.js +832 -198
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-JTTICHPF.js +0 -273
- package/dist/chunk-JTTICHPF.js.map +0 -1
- package/dist/index-DDFpPfUd.d.ts +0 -208
package/dist/chunk-JTTICHPF.js
DELETED
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
import { DataFactory, Store, Parser } from 'n3';
|
|
2
|
-
import jsonld from 'jsonld';
|
|
3
|
-
|
|
4
|
-
// src/constants.ts
|
|
5
|
-
var NS = {
|
|
6
|
-
rdf: "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
|
|
7
|
-
rs: "https://robosystems.ai/vocab/",
|
|
8
|
-
rsgaap: "https://robosystems.ai/taxonomy/rs-gaap/v1/",
|
|
9
|
-
skos: "http://www.w3.org/2004/02/skos/core#",
|
|
10
|
-
xlink: "http://www.w3.org/1999/xlink#",
|
|
11
|
-
xbrli: "http://www.xbrl.org/2003/instance#",
|
|
12
|
-
link: "http://www.xbrl.org/2003/linkbase#",
|
|
13
|
-
iso4217: "http://www.xbrl.org/2003/iso4217#"
|
|
14
|
-
};
|
|
15
|
-
var IRI = {
|
|
16
|
-
type: NS.rdf + "type",
|
|
17
|
-
// rs: classes
|
|
18
|
-
Report: NS.rs + "Report",
|
|
19
|
-
Fact: NS.rs + "Fact",
|
|
20
|
-
InformationBlock: NS.rs + "InformationBlock",
|
|
21
|
-
Structure: NS.rs + "Structure",
|
|
22
|
-
Association: NS.rs + "Association",
|
|
23
|
-
Element: NS.rs + "Element",
|
|
24
|
-
Period: NS.rs + "Period",
|
|
25
|
-
Unit: NS.rs + "Unit",
|
|
26
|
-
Entity: NS.rs + "Entity",
|
|
27
|
-
// rs: predicates
|
|
28
|
-
element: NS.rs + "element",
|
|
29
|
-
period: NS.rs + "period",
|
|
30
|
-
unit: NS.rs + "unit",
|
|
31
|
-
entity: NS.rs + "entity",
|
|
32
|
-
factSet: NS.rs + "factSet",
|
|
33
|
-
numericValue: NS.rs + "numericValue",
|
|
34
|
-
decimals: NS.rs + "decimals",
|
|
35
|
-
blockType: NS.rs + "blockType",
|
|
36
|
-
associationType: NS.rs + "associationType",
|
|
37
|
-
hasAssociation: NS.rs + "hasAssociation",
|
|
38
|
-
roleUri: NS.rs + "roleUri",
|
|
39
|
-
structureName: NS.rs + "structureName",
|
|
40
|
-
abstract: NS.rs + "abstract",
|
|
41
|
-
monetary: NS.rs + "monetary",
|
|
42
|
-
legalName: NS.rs + "legalName",
|
|
43
|
-
country: NS.rs + "country",
|
|
44
|
-
// skos:
|
|
45
|
-
prefLabel: NS.skos + "prefLabel",
|
|
46
|
-
// xlink:
|
|
47
|
-
from: NS.xlink + "from",
|
|
48
|
-
to: NS.xlink + "to",
|
|
49
|
-
role: NS.xlink + "role",
|
|
50
|
-
// xbrli:
|
|
51
|
-
instant: NS.xbrli + "instant",
|
|
52
|
-
startDate: NS.xbrli + "startDate",
|
|
53
|
-
endDate: NS.xbrli + "endDate",
|
|
54
|
-
periodType: NS.xbrli + "periodType",
|
|
55
|
-
balance: NS.xbrli + "balance",
|
|
56
|
-
measure: NS.xbrli + "measure",
|
|
57
|
-
// link:
|
|
58
|
-
order: NS.link + "order",
|
|
59
|
-
weight: NS.link + "weight"
|
|
60
|
-
};
|
|
61
|
-
var PREFIXES = [
|
|
62
|
-
["rs-gaap", NS.rsgaap],
|
|
63
|
-
["disclosures", "https://robosystems.ai/taxonomy/rs-gaap/disclosures/v1/"],
|
|
64
|
-
["us-gaap", "http://fasb.org/us-gaap/"],
|
|
65
|
-
["dei", "http://xbrl.sec.gov/dei/"],
|
|
66
|
-
["rs", NS.rs],
|
|
67
|
-
["skos", NS.skos],
|
|
68
|
-
["xbrli", NS.xbrli],
|
|
69
|
-
["xlink", NS.xlink],
|
|
70
|
-
["link", NS.link],
|
|
71
|
-
["iso4217", NS.iso4217]
|
|
72
|
-
];
|
|
73
|
-
function qname(iri) {
|
|
74
|
-
for (const [prefix, ns] of PREFIXES) {
|
|
75
|
-
if (iri.startsWith(ns)) {
|
|
76
|
-
return `${prefix}:${iri.slice(ns.length)}`;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
const slash = iri.lastIndexOf("/");
|
|
80
|
-
const hash = iri.lastIndexOf("#");
|
|
81
|
-
return iri.slice(Math.max(slash, hash) + 1);
|
|
82
|
-
}
|
|
83
|
-
function humanize(iri) {
|
|
84
|
-
const local = qname(iri).split(":").pop() ?? iri;
|
|
85
|
-
return local.replace(/(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/g, " ");
|
|
86
|
-
}
|
|
87
|
-
var BLOCK_ORDER = {
|
|
88
|
-
balance_sheet: 0,
|
|
89
|
-
income_statement: 1,
|
|
90
|
-
cash_flow_statement: 2,
|
|
91
|
-
equity_statement: 3
|
|
92
|
-
};
|
|
93
|
-
var BLOCK_TITLES = {
|
|
94
|
-
balance_sheet: "Balance Sheet",
|
|
95
|
-
income_statement: "Income Statement",
|
|
96
|
-
cash_flow_statement: "Cash Flow Statement",
|
|
97
|
-
equity_statement: "Statement of Changes in Equity"
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
// src/adapters/cypher.ts
|
|
101
|
-
function cypherAdapter(config) {
|
|
102
|
-
return {
|
|
103
|
-
source: `cypher:${config.graphId}/${config.reportId}`,
|
|
104
|
-
load: async () => {
|
|
105
|
-
throw new Error(
|
|
106
|
-
"The cypher adapter is not implemented yet (phase 2 / Mode B \u2014 live SEC graph)."
|
|
107
|
-
);
|
|
108
|
-
}
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
var { namedNode } = DataFactory;
|
|
112
|
-
function makeReaders(store) {
|
|
113
|
-
const objects = (s, p) => store.getObjects(namedNode(s), namedNode(p), null);
|
|
114
|
-
const firstValue = (s, p) => {
|
|
115
|
-
const os = objects(s, p);
|
|
116
|
-
return os.length ? os[0].value : null;
|
|
117
|
-
};
|
|
118
|
-
const subjectsOfType = (type) => store.getSubjects(namedNode(IRI.type), namedNode(type), null).map((t) => t.value);
|
|
119
|
-
return { objects, firstValue, subjectsOfType };
|
|
120
|
-
}
|
|
121
|
-
function toNumber(raw) {
|
|
122
|
-
if (raw === null || raw === "") return null;
|
|
123
|
-
const n = Number(raw);
|
|
124
|
-
return Number.isNaN(n) ? null : n;
|
|
125
|
-
}
|
|
126
|
-
function parseStore(store) {
|
|
127
|
-
const { objects, firstValue, subjectsOfType } = makeReaders(store);
|
|
128
|
-
const elements = {};
|
|
129
|
-
for (const id of subjectsOfType(IRI.Element)) {
|
|
130
|
-
const balance = firstValue(id, IRI.balance);
|
|
131
|
-
const periodType = firstValue(id, IRI.periodType);
|
|
132
|
-
elements[id] = {
|
|
133
|
-
id,
|
|
134
|
-
qname: qname(id),
|
|
135
|
-
label: firstValue(id, IRI.prefLabel) ?? humanize(id),
|
|
136
|
-
balance: balance === "debit" || balance === "credit" ? balance : null,
|
|
137
|
-
periodType: periodType === "instant" || periodType === "duration" ? periodType : null,
|
|
138
|
-
abstract: firstValue(id, IRI.abstract) === "true",
|
|
139
|
-
monetary: firstValue(id, IRI.monetary) === "true"
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
const periods = {};
|
|
143
|
-
for (const id of subjectsOfType(IRI.Period)) {
|
|
144
|
-
const declared = firstValue(id, IRI.periodType);
|
|
145
|
-
const instant = firstValue(id, IRI.instant);
|
|
146
|
-
const startDate = firstValue(id, IRI.startDate);
|
|
147
|
-
const endDate = firstValue(id, IRI.endDate);
|
|
148
|
-
const type = declared === "instant" ? "instant" : declared === "duration" ? "duration" : instant ? "instant" : "duration";
|
|
149
|
-
const end = (type === "instant" ? instant : endDate) ?? instant ?? endDate ?? "";
|
|
150
|
-
periods[id] = { id, type, instant, startDate, endDate, end };
|
|
151
|
-
}
|
|
152
|
-
const units = {};
|
|
153
|
-
for (const id of subjectsOfType(IRI.Unit)) {
|
|
154
|
-
const measureTerm = objects(id, IRI.measure)[0];
|
|
155
|
-
const measure = measureTerm ? qname(measureTerm.value) : "unknown";
|
|
156
|
-
units[id] = {
|
|
157
|
-
id,
|
|
158
|
-
measure,
|
|
159
|
-
label: measure.includes(":") ? measure.split(":").pop() : measure
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
let entity = null;
|
|
163
|
-
const entityIds = subjectsOfType(IRI.Entity);
|
|
164
|
-
if (entityIds.length) {
|
|
165
|
-
const id = entityIds[0];
|
|
166
|
-
entity = {
|
|
167
|
-
id,
|
|
168
|
-
name: firstValue(id, IRI.prefLabel) ?? firstValue(id, IRI.legalName) ?? "Entity",
|
|
169
|
-
legalName: firstValue(id, IRI.legalName),
|
|
170
|
-
country: firstValue(id, IRI.country)
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
const facts = [];
|
|
174
|
-
for (const id of subjectsOfType(IRI.Fact)) {
|
|
175
|
-
facts.push({
|
|
176
|
-
id,
|
|
177
|
-
element: firstValue(id, IRI.element) ?? "",
|
|
178
|
-
period: firstValue(id, IRI.period) ?? "",
|
|
179
|
-
unit: firstValue(id, IRI.unit),
|
|
180
|
-
entity: firstValue(id, IRI.entity),
|
|
181
|
-
factSet: firstValue(id, IRI.factSet),
|
|
182
|
-
value: toNumber(firstValue(id, IRI.numericValue)),
|
|
183
|
-
decimals: firstValue(id, IRI.decimals)
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
const informationBlocks = [];
|
|
187
|
-
for (const id of subjectsOfType(IRI.InformationBlock)) {
|
|
188
|
-
informationBlocks.push({
|
|
189
|
-
id,
|
|
190
|
-
blockType: firstValue(id, IRI.blockType) ?? "",
|
|
191
|
-
factSet: firstValue(id, IRI.factSet),
|
|
192
|
-
label: firstValue(id, IRI.prefLabel)
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
const structures = [];
|
|
196
|
-
const assocStructure = /* @__PURE__ */ new Map();
|
|
197
|
-
for (const id of subjectsOfType(IRI.Structure)) {
|
|
198
|
-
structures.push({
|
|
199
|
-
id,
|
|
200
|
-
blockType: firstValue(id, IRI.blockType) ?? "",
|
|
201
|
-
roleUri: firstValue(id, IRI.roleUri),
|
|
202
|
-
structureName: firstValue(id, IRI.structureName)
|
|
203
|
-
});
|
|
204
|
-
for (const assoc of objects(id, IRI.hasAssociation)) {
|
|
205
|
-
assocStructure.set(assoc.value, id);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
const calcAssociations = [];
|
|
209
|
-
const presAssociations = [];
|
|
210
|
-
for (const id of subjectsOfType(IRI.Association)) {
|
|
211
|
-
const parent = firstValue(id, IRI.from);
|
|
212
|
-
const child = firstValue(id, IRI.to);
|
|
213
|
-
if (!parent || !child) continue;
|
|
214
|
-
const type = firstValue(id, IRI.associationType);
|
|
215
|
-
const order = toNumber(firstValue(id, IRI.order)) ?? 0;
|
|
216
|
-
const role = firstValue(id, IRI.role);
|
|
217
|
-
const structure = assocStructure.get(id) ?? null;
|
|
218
|
-
if (type === "calculation") {
|
|
219
|
-
calcAssociations.push({
|
|
220
|
-
parent,
|
|
221
|
-
child,
|
|
222
|
-
weight: toNumber(firstValue(id, IRI.weight)) ?? 1,
|
|
223
|
-
order,
|
|
224
|
-
role,
|
|
225
|
-
structure
|
|
226
|
-
});
|
|
227
|
-
} else if (type === "presentation") {
|
|
228
|
-
presAssociations.push({ parent, child, order, role, structure });
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
let reportIri = null;
|
|
232
|
-
for (const graph of store.getGraphs(null, null, null)) {
|
|
233
|
-
const hash = graph.value.indexOf("#");
|
|
234
|
-
if (hash > 0) {
|
|
235
|
-
reportIri = graph.value.slice(0, hash);
|
|
236
|
-
break;
|
|
237
|
-
}
|
|
238
|
-
}
|
|
239
|
-
if (!reportIri) {
|
|
240
|
-
const reports = subjectsOfType(IRI.Report);
|
|
241
|
-
reportIri = reports.length ? reports[0] : null;
|
|
242
|
-
}
|
|
243
|
-
const reportId = reportIri ? reportIri.split("/").pop() ?? null : null;
|
|
244
|
-
return {
|
|
245
|
-
reportId,
|
|
246
|
-
reportIri,
|
|
247
|
-
entity,
|
|
248
|
-
informationBlocks,
|
|
249
|
-
structures,
|
|
250
|
-
facts,
|
|
251
|
-
elements,
|
|
252
|
-
periods,
|
|
253
|
-
units,
|
|
254
|
-
calcAssociations,
|
|
255
|
-
presAssociations
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
async function parseJsonld(doc) {
|
|
259
|
-
const json = typeof doc === "string" ? JSON.parse(doc) : doc;
|
|
260
|
-
const nquads = await jsonld.toRDF(json, { format: "application/n-quads" });
|
|
261
|
-
const store = new Store(new Parser({ format: "application/n-quads" }).parse(nquads));
|
|
262
|
-
return parseStore(store);
|
|
263
|
-
}
|
|
264
|
-
function jsonldFileAdapter(doc, source = "holon.jsonld") {
|
|
265
|
-
return {
|
|
266
|
-
source,
|
|
267
|
-
load: () => parseJsonld(doc)
|
|
268
|
-
};
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
export { BLOCK_ORDER, BLOCK_TITLES, NS, cypherAdapter, humanize, jsonldFileAdapter, parseJsonld, parseStore, qname };
|
|
272
|
-
//# sourceMappingURL=chunk-JTTICHPF.js.map
|
|
273
|
-
//# sourceMappingURL=chunk-JTTICHPF.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/constants.ts","../src/adapters/cypher.ts","../src/adapters/store.ts","../src/adapters/jsonld.ts"],"names":["Store"],"mappings":";;;;AAQO,IAAM,EAAA,GAAK;AAAA,EAChB,GAAA,EAAK,6CAAA;AAAA,EACL,EAAA,EA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,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;ACzLA,eAAsB,YAAY,GAAA,EAAiD;AACjF,EAAA,MAAM,OAAQ,OAAO,GAAA,KAAQ,WAAW,IAAA,CAAK,KAAA,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,IAAIA,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-JTTICHPF.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 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 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 ElementInfo,\n EntityInfo,\n Fact,\n InformationBlock,\n NormalizedReport,\n PeriodInfo,\n PeriodType,\n PresAssociation,\n StructureInfo,\n UnitInfo,\n} from '../model'\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 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 ──\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"]}
|
package/dist/index-DDFpPfUd.d.ts
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
import { Store } from 'n3';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The normalized report model — the load-bearing seam of the library.
|
|
5
|
-
*
|
|
6
|
-
* An **adapter** turns its source (a `holon.jsonld` file, a cypher endpoint, a
|
|
7
|
-
* live ledger) into a `NormalizedReport`: the raw facts, Information Blocks,
|
|
8
|
-
* elements / periods / units / entity, and the calculation + presentation
|
|
9
|
-
* association networks. Nothing more.
|
|
10
|
-
*
|
|
11
|
-
* The **projection** (`project.ts`) and **components** turn that normalized
|
|
12
|
-
* model into rendered statements — the presentation-order walk, the calculation
|
|
13
|
-
* subtotals, the table layout. That work is identical for every adapter, which
|
|
14
|
-
* is what makes the rendering source-agnostic.
|
|
15
|
-
*/
|
|
16
|
-
type PeriodType = 'instant' | 'duration';
|
|
17
|
-
type BalanceType = 'debit' | 'credit';
|
|
18
|
-
/** A reportable concept (a taxonomy element). */
|
|
19
|
-
interface ElementInfo {
|
|
20
|
-
/** Full element IRI — the join key used everywhere. */
|
|
21
|
-
id: string;
|
|
22
|
-
/** Compacted name, e.g. `rs-gaap:Assets`. */
|
|
23
|
-
qname: string;
|
|
24
|
-
/** Human label (`skos:prefLabel`, else a humanized local name). */
|
|
25
|
-
label: string;
|
|
26
|
-
balance: BalanceType | null;
|
|
27
|
-
periodType: PeriodType | null;
|
|
28
|
-
abstract: boolean;
|
|
29
|
-
monetary: boolean;
|
|
30
|
-
}
|
|
31
|
-
/** A reporting period — an instant (balance sheet) or a duration (flows). */
|
|
32
|
-
interface PeriodInfo {
|
|
33
|
-
id: string;
|
|
34
|
-
type: PeriodType;
|
|
35
|
-
instant: string | null;
|
|
36
|
-
startDate: string | null;
|
|
37
|
-
endDate: string | null;
|
|
38
|
-
/** The date a fact lands on: `instant` for instants, `endDate` for durations. */
|
|
39
|
-
end: string;
|
|
40
|
-
}
|
|
41
|
-
/** A unit of measure, e.g. USD. */
|
|
42
|
-
interface UnitInfo {
|
|
43
|
-
id: string;
|
|
44
|
-
/** Compacted measure, e.g. `iso4217:USD`. */
|
|
45
|
-
measure: string;
|
|
46
|
-
/** Short display label, e.g. `USD`. */
|
|
47
|
-
label: string;
|
|
48
|
-
}
|
|
49
|
-
/** The reporting entity. */
|
|
50
|
-
interface EntityInfo {
|
|
51
|
-
id: string;
|
|
52
|
-
name: string;
|
|
53
|
-
legalName: string | null;
|
|
54
|
-
country: string | null;
|
|
55
|
-
}
|
|
56
|
-
/** A single reported value. */
|
|
57
|
-
interface Fact {
|
|
58
|
-
id: string;
|
|
59
|
-
/** Element IRI. */
|
|
60
|
-
element: string;
|
|
61
|
-
/** Period IRI. */
|
|
62
|
-
period: string;
|
|
63
|
-
/** Unit IRI, when monetary/numeric. */
|
|
64
|
-
unit: string | null;
|
|
65
|
-
/** Entity IRI. */
|
|
66
|
-
entity: string | null;
|
|
67
|
-
/** FactSet IRI — the grouping key shared with an Information Block. */
|
|
68
|
-
factSet: string | null;
|
|
69
|
-
value: number | null;
|
|
70
|
-
decimals: string | null;
|
|
71
|
-
}
|
|
72
|
-
/** A calculation arc: `parent` (subtotal) rolls up `child * weight`. */
|
|
73
|
-
interface CalcAssociation {
|
|
74
|
-
parent: string;
|
|
75
|
-
child: string;
|
|
76
|
-
weight: number;
|
|
77
|
-
order: number;
|
|
78
|
-
role: string | null;
|
|
79
|
-
structure: string | null;
|
|
80
|
-
}
|
|
81
|
-
/** A presentation arc: `parent` shows `child` at the given order. */
|
|
82
|
-
interface PresAssociation {
|
|
83
|
-
parent: string;
|
|
84
|
-
child: string;
|
|
85
|
-
order: number;
|
|
86
|
-
role: string | null;
|
|
87
|
-
structure: string | null;
|
|
88
|
-
}
|
|
89
|
-
/** A network root — groups associations under one role / block type. */
|
|
90
|
-
interface StructureInfo {
|
|
91
|
-
id: string;
|
|
92
|
-
blockType: string;
|
|
93
|
-
roleUri: string | null;
|
|
94
|
-
structureName: string | null;
|
|
95
|
-
}
|
|
96
|
-
/** An Information Block — groups a statement's facts via a shared `factSet`. */
|
|
97
|
-
interface InformationBlock {
|
|
98
|
-
id: string;
|
|
99
|
-
blockType: string;
|
|
100
|
-
factSet: string | null;
|
|
101
|
-
label: string | null;
|
|
102
|
-
}
|
|
103
|
-
/** The full normalized report — the adapter's output and projection's input. */
|
|
104
|
-
interface NormalizedReport {
|
|
105
|
-
reportId: string | null;
|
|
106
|
-
reportIri: string | null;
|
|
107
|
-
entity: EntityInfo | null;
|
|
108
|
-
informationBlocks: InformationBlock[];
|
|
109
|
-
structures: StructureInfo[];
|
|
110
|
-
facts: Fact[];
|
|
111
|
-
elements: Record<string, ElementInfo>;
|
|
112
|
-
periods: Record<string, PeriodInfo>;
|
|
113
|
-
units: Record<string, UnitInfo>;
|
|
114
|
-
calcAssociations: CalcAssociation[];
|
|
115
|
-
presAssociations: PresAssociation[];
|
|
116
|
-
}
|
|
117
|
-
/** A statement column, keyed by the period end date facts are matched against. */
|
|
118
|
-
interface StatementColumn {
|
|
119
|
-
/** The period end date used to match facts into this column. */
|
|
120
|
-
key: string;
|
|
121
|
-
/** Human header label. */
|
|
122
|
-
label: string;
|
|
123
|
-
/** A representative period for this column (for tooltips / fact inspection). */
|
|
124
|
-
period: PeriodInfo;
|
|
125
|
-
}
|
|
126
|
-
/** One value in a row, plus the fact behind it (for inspection / footing). */
|
|
127
|
-
interface RowCell {
|
|
128
|
-
value: number | null;
|
|
129
|
-
fact: Fact | null;
|
|
130
|
-
}
|
|
131
|
-
/** A rendered statement line. */
|
|
132
|
-
interface StatementRow {
|
|
133
|
-
element: ElementInfo;
|
|
134
|
-
/** Tree depth — drives indentation. */
|
|
135
|
-
depth: number;
|
|
136
|
-
/** True when the element is a calculation parent (rendered bold). */
|
|
137
|
-
isSubtotal: boolean;
|
|
138
|
-
cells: RowCell[];
|
|
139
|
-
}
|
|
140
|
-
/** A fully reconstructed statement, ready to render. */
|
|
141
|
-
interface Statement {
|
|
142
|
-
ib: InformationBlock;
|
|
143
|
-
blockType: string;
|
|
144
|
-
/** Friendly heading, e.g. "Balance Sheet". */
|
|
145
|
-
title: string;
|
|
146
|
-
structureName: string | null;
|
|
147
|
-
columns: StatementColumn[];
|
|
148
|
-
rows: StatementRow[];
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* The adapter seam. An adapter turns one source into a `NormalizedReport`; the
|
|
153
|
-
* projection + components do the rest, identically for every source.
|
|
154
|
-
*
|
|
155
|
-
* The package ships two read-only reference adapters — `jsonld` (offline file
|
|
156
|
-
* via the jsonld processor) and `cypher` (a live graph database). A consuming
|
|
157
|
-
* app with operational needs (a live ledger it also edits) supplies its own
|
|
158
|
-
* adapter in-app.
|
|
159
|
-
*/
|
|
160
|
-
|
|
161
|
-
interface ReportAdapter {
|
|
162
|
-
/** A short, human-readable description of the source (for the UI). */
|
|
163
|
-
readonly source: string;
|
|
164
|
-
/** Produce the normalized report model. */
|
|
165
|
-
load(): Promise<NormalizedReport>;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* The cypher / GraphQL adapter — a live graph database (an entity graph **or**
|
|
170
|
-
* the SEC repository) read read-only with an API key. One adapter for both:
|
|
171
|
-
* only the endpoint / `graphId` differ.
|
|
172
|
-
*
|
|
173
|
-
* Phase 2 (Mode B). Stubbed for now so the seam and the `./adapters` export
|
|
174
|
-
* surface are in place; the holon-viewer's SEC mode will drive its build-out.
|
|
175
|
-
*/
|
|
176
|
-
|
|
177
|
-
interface CypherAdapterConfig {
|
|
178
|
-
/** GraphQL / cypher endpoint base URL. */
|
|
179
|
-
endpoint: string;
|
|
180
|
-
/** User-supplied API key (sent client-side; never app-managed). */
|
|
181
|
-
apiKey: string;
|
|
182
|
-
/** Target graph — an entity graph id or the SEC repository id. */
|
|
183
|
-
graphId: string;
|
|
184
|
-
/** The report to materialize. */
|
|
185
|
-
reportId: string;
|
|
186
|
-
}
|
|
187
|
-
declare function cypherAdapter(config: CypherAdapterConfig): ReportAdapter;
|
|
188
|
-
|
|
189
|
-
/** Parse a `holon.jsonld` document (string or parsed object) into the model. */
|
|
190
|
-
declare function parseJsonld(doc: string | object): Promise<NormalizedReport>;
|
|
191
|
-
/** A `ReportAdapter` over an in-memory `holon.jsonld` document. */
|
|
192
|
-
declare function jsonldFileAdapter(doc: string | object, source?: string): ReportAdapter;
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* The shared quad-store → `NormalizedReport` traversal.
|
|
196
|
-
*
|
|
197
|
-
* An adapter fills an N3 quad `Store` from its source, then hands it here. The
|
|
198
|
-
* store is read as a **union** across its graphs (`graph = null`) — the
|
|
199
|
-
* scene/boundary/projection partition is a publication concern, not a rendering
|
|
200
|
-
* one, so the join is identical however the quads arrived (a dataset-form
|
|
201
|
-
* JSON-LD holon, a flat graph, …). No SPARQL engine is required; only store
|
|
202
|
-
* traversal. The only per-source code is how the store gets filled.
|
|
203
|
-
*/
|
|
204
|
-
|
|
205
|
-
/** Traverse a populated quad `Store` into the normalized report model. */
|
|
206
|
-
declare function parseStore(store: Store): NormalizedReport;
|
|
207
|
-
|
|
208
|
-
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, jsonldFileAdapter as j, parseStore as k, parseJsonld as p };
|