@factoidal/core 0.1.0
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/CHANGELOG.md +121 -0
- package/LICENSE +201 -0
- package/README.md +514 -0
- package/browser-wasm.js +872 -0
- package/browser.d.ts +514 -0
- package/browser.js +2276 -0
- package/factoidal-npm-entry.js +32609 -0
- package/factoidal-npm-entry.wasm.assets/code-7ac046580f1bbdda8dc6.wasm +0 -0
- package/factoidal-npm-entry.wasm.js +455 -0
- package/factoidal.js +27560 -0
- package/factoidal.wasm.assets/code-bbe6099bfb5b10c4c3ab.wasm +0 -0
- package/factoidal.wasm.js +457 -0
- package/fn.d.ts +519 -0
- package/fn.js +916 -0
- package/hacl-init.js +92 -0
- package/hacl-wasm/FStar.wasm +0 -0
- package/hacl-wasm/Hacl_Bignum.wasm +0 -0
- package/hacl-wasm/Hacl_Bignum25519_51.wasm +0 -0
- package/hacl-wasm/Hacl_Bignum_Base.wasm +0 -0
- package/hacl-wasm/Hacl_Curve25519_51.wasm +0 -0
- package/hacl-wasm/Hacl_Ed25519.wasm +0 -0
- package/hacl-wasm/Hacl_Ed25519_PrecompTable.wasm +0 -0
- package/hacl-wasm/Hacl_Hash_Base.wasm +0 -0
- package/hacl-wasm/Hacl_Hash_SHA2.wasm +0 -0
- package/hacl-wasm/Hacl_IntTypes_Intrinsics.wasm +0 -0
- package/hacl-wasm/LowStar_Endianness.wasm +0 -0
- package/hacl-wasm/WasmSupport.wasm +0 -0
- package/hacl-wasm/api.js +775 -0
- package/hacl-wasm/api.json +3787 -0
- package/hacl-wasm/layouts.json +1 -0
- package/hacl-wasm/loader.js +568 -0
- package/hacl-wasm/shell.js +12 -0
- package/index.d.ts +1068 -0
- package/index.js +237 -0
- package/index.mjs +85 -0
- package/lib/api.js +2140 -0
- package/lib/engine-js.js +165 -0
- package/lib/engine-wasm.js +300 -0
- package/package.json +101 -0
- package/rdfjs.js +540 -0
- package/version.json +101 -0
- package/wasm.d.ts +130 -0
- package/wasm.js +158 -0
package/index.d.ts
ADDED
|
@@ -0,0 +1,1068 @@
|
|
|
1
|
+
// TypeScript declarations for factoidal.
|
|
2
|
+
//
|
|
3
|
+
// Self-contained: the RDF/JS interfaces below are structurally
|
|
4
|
+
// compatible with @rdfjs/types (same names and shapes) but declared
|
|
5
|
+
// here so the package has zero dependencies.
|
|
6
|
+
|
|
7
|
+
// ---------------------------------------------------------------------
|
|
8
|
+
// RDF/JS data model (https://rdf.js.org/data-model-spec/)
|
|
9
|
+
// ---------------------------------------------------------------------
|
|
10
|
+
|
|
11
|
+
export interface NamedNode<Iri extends string = string> {
|
|
12
|
+
termType: 'NamedNode';
|
|
13
|
+
value: Iri;
|
|
14
|
+
equals(other: Term | null | undefined): boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface BlankNode {
|
|
18
|
+
termType: 'BlankNode';
|
|
19
|
+
value: string;
|
|
20
|
+
equals(other: Term | null | undefined): boolean;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface Literal {
|
|
24
|
+
termType: 'Literal';
|
|
25
|
+
value: string;
|
|
26
|
+
/** Language tag ('' when none). */
|
|
27
|
+
language: string;
|
|
28
|
+
/** Datatype IRI term (xsd:string for plain literals). */
|
|
29
|
+
datatype: NamedNode;
|
|
30
|
+
equals(other: Term | null | undefined): boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface Variable {
|
|
34
|
+
termType: 'Variable';
|
|
35
|
+
value: string;
|
|
36
|
+
equals(other: Term | null | undefined): boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface DefaultGraph {
|
|
40
|
+
termType: 'DefaultGraph';
|
|
41
|
+
value: '';
|
|
42
|
+
equals(other: Term | null | undefined): boolean;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface Quad {
|
|
46
|
+
termType: 'Quad';
|
|
47
|
+
value: '';
|
|
48
|
+
subject: Quad_Subject;
|
|
49
|
+
predicate: Quad_Predicate;
|
|
50
|
+
object: Quad_Object;
|
|
51
|
+
graph: Quad_Graph;
|
|
52
|
+
equals(other: Quad | null | undefined): boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type Quad_Subject = NamedNode | BlankNode | Variable;
|
|
56
|
+
export type Quad_Predicate = NamedNode | Variable;
|
|
57
|
+
export type Quad_Object = NamedNode | BlankNode | Literal | Variable;
|
|
58
|
+
export type Quad_Graph = DefaultGraph | NamedNode | BlankNode | Variable;
|
|
59
|
+
|
|
60
|
+
export type Term =
|
|
61
|
+
| NamedNode | BlankNode | Literal | Variable | DefaultGraph | Quad;
|
|
62
|
+
|
|
63
|
+
export interface DataFactory {
|
|
64
|
+
namedNode<Iri extends string = string>(value: Iri): NamedNode<Iri>;
|
|
65
|
+
blankNode(label?: string): BlankNode;
|
|
66
|
+
literal(value: string, languageOrDatatype?: string | NamedNode): Literal;
|
|
67
|
+
variable(name: string): Variable;
|
|
68
|
+
defaultGraph(): DefaultGraph;
|
|
69
|
+
quad(
|
|
70
|
+
subject: Quad_Subject,
|
|
71
|
+
predicate: Quad_Predicate,
|
|
72
|
+
object: Quad_Object,
|
|
73
|
+
graph?: Quad_Graph
|
|
74
|
+
): Quad;
|
|
75
|
+
fromTerm(original: Term): Term;
|
|
76
|
+
fromQuad(original: Quad): Quad;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** The package's RDF/JS DataFactory. */
|
|
80
|
+
export const dataFactory: DataFactory;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* An in-memory RDF/JS DatasetCore
|
|
84
|
+
* (https://rdf.js.org/dataset-spec/#datasetcore-interface) that also
|
|
85
|
+
* round-trips to the engine's N-Quads interchange text.
|
|
86
|
+
*/
|
|
87
|
+
export class Dataset implements Iterable<Quad> {
|
|
88
|
+
constructor(quads?: Iterable<Quad>);
|
|
89
|
+
readonly size: number;
|
|
90
|
+
add(quad: Quad): this;
|
|
91
|
+
delete(quad: Quad): this;
|
|
92
|
+
has(quad: Quad): boolean;
|
|
93
|
+
match(
|
|
94
|
+
subject?: Term | null,
|
|
95
|
+
predicate?: Term | null,
|
|
96
|
+
object?: Term | null,
|
|
97
|
+
graph?: Term | null
|
|
98
|
+
): Dataset;
|
|
99
|
+
[Symbol.iterator](): Iterator<Quad>;
|
|
100
|
+
toArray(): Quad[];
|
|
101
|
+
/** N-Quads serialization of the quads (the engine interchange form). */
|
|
102
|
+
toNQuads(): string;
|
|
103
|
+
toString(): string;
|
|
104
|
+
static fromNQuads(
|
|
105
|
+
text: string,
|
|
106
|
+
options?: { blankNodePrefix?: string; factory?: DataFactory }
|
|
107
|
+
): Dataset;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ---------------------------------------------------------------------
|
|
111
|
+
// Public API
|
|
112
|
+
// ---------------------------------------------------------------------
|
|
113
|
+
|
|
114
|
+
/** RDF serialization format tags accepted for input text. */
|
|
115
|
+
export type DataFormat =
|
|
116
|
+
| 'turtle' | 'ttl'
|
|
117
|
+
| 'ntriples' | 'nt'
|
|
118
|
+
| 'nquads' | 'nq'
|
|
119
|
+
| 'trig'
|
|
120
|
+
| 'rdfxml' | 'rdf-xml' | 'rdf'
|
|
121
|
+
| 'jsonld' | 'json-ld';
|
|
122
|
+
|
|
123
|
+
/** Entailment regime applied to the data before evaluation. */
|
|
124
|
+
/**
|
|
125
|
+
* Entailment regime for query(): the W3C-named regimes plus two
|
|
126
|
+
* experimental certified regimes (RDF.Entailment.RegimeDispatch.fst) —
|
|
127
|
+
* 'x-rdfscore': BGP answers over the theorem-backed corerdfs (ρdf)
|
|
128
|
+
* closure, sound and complete on fragment data;
|
|
129
|
+
* 'x-rdfsplus': RDFS plus the practical OWL subset, every rule under
|
|
130
|
+
* proved licensing + truth lemmas. See docs/theorem-registry.md.
|
|
131
|
+
*/
|
|
132
|
+
export type EntailRegime = 'none' | 'RDFS' | 'OWL-RL' | 'x-rdfscore' | 'x-rdfsplus';
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* One SELECT solution: a Map from variable name (no leading '?') to
|
|
136
|
+
* the bound RDF/JS term. Unbound variables are absent from the Map.
|
|
137
|
+
*/
|
|
138
|
+
export type Bindings = Map<string, Term>;
|
|
139
|
+
|
|
140
|
+
/** Input data: a Dataset, a document string, or several of either. */
|
|
141
|
+
export type DataInput =
|
|
142
|
+
| Dataset
|
|
143
|
+
| string
|
|
144
|
+
| { text: string; format?: DataFormat }
|
|
145
|
+
| Array<Dataset | string | { text: string; format?: DataFormat }>;
|
|
146
|
+
|
|
147
|
+
export interface ParseOptions {
|
|
148
|
+
/** Default: 'turtle'. */
|
|
149
|
+
format?: DataFormat;
|
|
150
|
+
/** Base IRI for resolving relative IRIs (Turtle/TriG/RDF-XML). */
|
|
151
|
+
baseIRI?: string;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface QueryOptions {
|
|
155
|
+
/** Format tag for string data inputs. Default: 'turtle'. */
|
|
156
|
+
format?: DataFormat;
|
|
157
|
+
/** Default: 'none'. */
|
|
158
|
+
entail?: EntailRegime;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/** Parse one RDF document into a Dataset. */
|
|
162
|
+
export function parse(text: string, options?: ParseOptions): Promise<Dataset>;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Run a SPARQL 1.1 query.
|
|
166
|
+
* SELECT resolves to Bindings[]; ASK resolves to a boolean;
|
|
167
|
+
* CONSTRUCT resolves to a Dataset (needs the npm-entry engine bundle
|
|
168
|
+
* — rejects with an Error mentioning "pending npm-entry build" when
|
|
169
|
+
* only the CLI bundle is available).
|
|
170
|
+
*/
|
|
171
|
+
export function query(
|
|
172
|
+
data: DataInput,
|
|
173
|
+
sparql: string,
|
|
174
|
+
options?: QueryOptions
|
|
175
|
+
): Promise<Bindings[] | boolean | Dataset>;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Run a SPARQL 1.1 query against a read-only HDT (Header-Dictionary-
|
|
179
|
+
* Triples) artifact's raw bytes (factoidal_cli.ml's `--data-hdt`
|
|
180
|
+
* backend). No npm-entry engine bundle needed -- CLI-only. Default
|
|
181
|
+
* graph only, SELECT/ASK only (no CONSTRUCT, no named graphs).
|
|
182
|
+
* @param hdtBytes whole .hdt file contents
|
|
183
|
+
*/
|
|
184
|
+
export function queryHdt(
|
|
185
|
+
hdtBytes: Uint8Array | ArrayBuffer | string,
|
|
186
|
+
sparql: string
|
|
187
|
+
): Promise<Bindings[] | boolean>;
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* An argument or return value of a custom extension function, in the
|
|
191
|
+
* SRJ term shape: {type:'uri'|'literal'|'bnode', value, datatype?,
|
|
192
|
+
* 'xml:lang'?}. An errored argument arrives as {type:'error'}.
|
|
193
|
+
*/
|
|
194
|
+
export interface ExtensionTerm {
|
|
195
|
+
type: 'uri' | 'literal' | 'bnode' | 'error';
|
|
196
|
+
value?: string;
|
|
197
|
+
datatype?: string;
|
|
198
|
+
'xml:lang'?: string;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Register a custom SPARQL extension function (SPARQL 1.1 §17.6,
|
|
203
|
+
* issue #463; Comunica-style). `fn` may be sync or async; it receives
|
|
204
|
+
* the evaluated arguments as ExtensionTerm[] and returns an
|
|
205
|
+
* ExtensionTerm, a JS primitive (boolean | number | string), a
|
|
206
|
+
* Promise of either, or null/undefined (= the §17.6 error). A query
|
|
207
|
+
* calling an IRI with no registered function gets the same error:
|
|
208
|
+
* unbound in SELECT/BIND position, row dropped in FILTER position.
|
|
209
|
+
*/
|
|
210
|
+
export function registerExtensionFunction(
|
|
211
|
+
iri: string,
|
|
212
|
+
fn: (args: ExtensionTerm[]) =>
|
|
213
|
+
ExtensionTerm | boolean | number | string | null | undefined |
|
|
214
|
+
Promise<ExtensionTerm | boolean | number | string | null | undefined>
|
|
215
|
+
): Promise<void>;
|
|
216
|
+
|
|
217
|
+
/** Remove one registered extension function. */
|
|
218
|
+
export function unregisterExtensionFunction(iri: string): Promise<void>;
|
|
219
|
+
|
|
220
|
+
/** Remove every registered extension function. */
|
|
221
|
+
export function clearExtensionFunctions(): Promise<void>;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Bind a SPARQL SERVICE endpoint IRI to a local graph snapshot, so
|
|
225
|
+
* SERVICE <iri> { ... } (and LATERAL { SERVICE ... }) queries resolve
|
|
226
|
+
* against it in-process — the same registry the W3C federated-query
|
|
227
|
+
* suite uses (qt:serviceData). The snapshot is the payload's default
|
|
228
|
+
* graph.
|
|
229
|
+
*/
|
|
230
|
+
export function registerServiceEndpoint(
|
|
231
|
+
iri: string,
|
|
232
|
+
data: DataInput,
|
|
233
|
+
options?: { format?: DataFormat }
|
|
234
|
+
): Promise<{ ok: true; count: number }>;
|
|
235
|
+
|
|
236
|
+
/** Remove every registered SERVICE endpoint snapshot. */
|
|
237
|
+
export function clearServiceEndpoints(): Promise<void>;
|
|
238
|
+
|
|
239
|
+
/**
|
|
240
|
+
* Apply a SPARQL 1.1 Update, returning the updated Dataset.
|
|
241
|
+
* Needs the npm-entry engine bundle.
|
|
242
|
+
*/
|
|
243
|
+
export function update(
|
|
244
|
+
data: DataInput,
|
|
245
|
+
updateText: string,
|
|
246
|
+
options?: { format?: DataFormat }
|
|
247
|
+
): Promise<Dataset>;
|
|
248
|
+
|
|
249
|
+
export interface SerializeOptions {
|
|
250
|
+
/**
|
|
251
|
+
* Output format. Default: 'nquads'. 'turtle' (prefix-compacted,
|
|
252
|
+
* subject-grouped) needs the npm-entry bundle and flattens every
|
|
253
|
+
* named graph into the default graph — use 'nquads' when graph names
|
|
254
|
+
* must survive.
|
|
255
|
+
*/
|
|
256
|
+
format?: 'nquads' | 'ntriples' | 'turtle' | 'ttl';
|
|
257
|
+
/** Format tag for string data inputs. Default: 'turtle'. */
|
|
258
|
+
inputFormat?: DataFormat;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** Serialize a dataset (engine-produced, sorted N-Quads order). */
|
|
262
|
+
export function serialize(
|
|
263
|
+
data: DataInput,
|
|
264
|
+
options?: SerializeOptions
|
|
265
|
+
): Promise<string>;
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* RDFC-1.0 dataset canonicalization: canonical blank-node labels plus
|
|
269
|
+
* sorted canonical N-Quads. Two isomorphic inputs canonicalize to the
|
|
270
|
+
* same string.
|
|
271
|
+
*/
|
|
272
|
+
export function canonicalize(
|
|
273
|
+
data: DataInput,
|
|
274
|
+
options?: { format?: DataFormat }
|
|
275
|
+
): Promise<string>;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Enumerate the named graphs of an already-parsed Dataset (default
|
|
279
|
+
* graph excluded), in first-seen order. Pure enumeration over
|
|
280
|
+
* `dataset`'s own quads -- no engine round-trip, always available.
|
|
281
|
+
* `graph` is the same Dataset filtered to that one graph name (what
|
|
282
|
+
* `dataset.match(null, null, null, graphTerm)` would return).
|
|
283
|
+
*/
|
|
284
|
+
export function graphs(dataset: Dataset): Array<[iri: string, graph: Dataset]>;
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* RDFC-1.0 canonical hash of a single graph -- the graph-scoped
|
|
288
|
+
* sibling of canonicalize(). Every quad's graph component is dropped
|
|
289
|
+
* before canonicalizing, so isomorphic graphs (including under
|
|
290
|
+
* blank-node relabeling) hash to the same string regardless of what
|
|
291
|
+
* graph name they were extracted from. Typically called with one
|
|
292
|
+
* entry of graphs()'s output.
|
|
293
|
+
*/
|
|
294
|
+
export function canonicalHash(datasetOrGraph: Dataset): Promise<string>;
|
|
295
|
+
|
|
296
|
+
/** A SHACL validation-report term (see shaclValidate). */
|
|
297
|
+
export interface ShaclValidateResult {
|
|
298
|
+
conforms: boolean;
|
|
299
|
+
/** SHACL_Validation.validation_report_to_graph's graph as a Dataset. */
|
|
300
|
+
report: Dataset;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* SHACL Core validation. Needs the npm-entry engine bundle.
|
|
305
|
+
* @param data the data graph
|
|
306
|
+
* @param shapes the shapes graph
|
|
307
|
+
*/
|
|
308
|
+
export function shaclValidate(
|
|
309
|
+
data: DataInput,
|
|
310
|
+
shapes: DataInput,
|
|
311
|
+
options?: { format?: DataFormat }
|
|
312
|
+
): Promise<ShaclValidateResult>;
|
|
313
|
+
|
|
314
|
+
/**
|
|
315
|
+
* ShEx (Shape Expressions) validation of one focus node against one
|
|
316
|
+
* shape. Needs the npm-entry engine bundle. `null` means "deferred" --
|
|
317
|
+
* outside this engine's decidable ShEx fragment, never a guessed
|
|
318
|
+
* answer.
|
|
319
|
+
* @param schemaJson ShExJ (JSON Schema form), as text
|
|
320
|
+
* @param focus an IRI, "_:label", or an RDF/JS NamedNode/BlankNode term
|
|
321
|
+
* @param shape a shape label (same shapes as focus); omit/null for the
|
|
322
|
+
* schema's own `start`
|
|
323
|
+
*/
|
|
324
|
+
export function shexValidate(
|
|
325
|
+
data: DataInput,
|
|
326
|
+
schemaJson: string,
|
|
327
|
+
focus: string | NamedNode | BlankNode,
|
|
328
|
+
shape?: string | NamedNode | BlankNode | null,
|
|
329
|
+
options?: { format?: DataFormat }
|
|
330
|
+
): Promise<boolean | null>;
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* RDFS or OWL-RL entailment closure, materialized as a new Dataset
|
|
334
|
+
* (input triples + derived triples). Needs the npm-entry engine
|
|
335
|
+
* bundle. Default graph only.
|
|
336
|
+
*/
|
|
337
|
+
export function owlClosure(
|
|
338
|
+
data: DataInput,
|
|
339
|
+
mode: 'RDFS' | 'OWL-RL',
|
|
340
|
+
options?: { format?: DataFormat }
|
|
341
|
+
): Promise<Dataset>;
|
|
342
|
+
|
|
343
|
+
/**
|
|
344
|
+
* The CERTIFIED six-rule core-RDFS closure
|
|
345
|
+
* (formal/fstar/RDF.Entailment.RDFS.RhoDFClosure.fst's
|
|
346
|
+
* `rho_df_closure`): rdfs2/3/5/7/9/11 only, with the machine-checked
|
|
347
|
+
* decides-iff — on fragment inputs the result's simple query answers
|
|
348
|
+
* are exactly the entailed consequences (see
|
|
349
|
+
* docs/theorem-registry.md). Returns N-Triples text plus status.
|
|
350
|
+
* "corerdfs" is this project's API name for the fragment the
|
|
351
|
+
* literature calls ρdf (subPropertyOf/subClassOf/type/domain/range —
|
|
352
|
+
* Muñoz, Pérez & Gutierrez, "Simple and Efficient Minimal RDFS",
|
|
353
|
+
* J. Web Semantics 7(3), 2009).
|
|
354
|
+
*/
|
|
355
|
+
export function coreRdfsClosure(
|
|
356
|
+
data: DataInput,
|
|
357
|
+
options?: { format?: DataFormat }
|
|
358
|
+
): Promise<{ ok: boolean; ntriples: string }>;
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Decidable core-RDFS fragment check (`is_rho_df_frag`, with its F*
|
|
362
|
+
* lemma tying it to the prop the regime theorems quantify over): does
|
|
363
|
+
* the certified path's guarantee apply to this data?
|
|
364
|
+
*/
|
|
365
|
+
export function coreRdfsCheck(
|
|
366
|
+
data: DataInput,
|
|
367
|
+
options?: { format?: DataFormat }
|
|
368
|
+
): Promise<{ ok: boolean; fragment: boolean }>;
|
|
369
|
+
|
|
370
|
+
/** Literature-name alias for coreRdfsClosure (ρdf). */
|
|
371
|
+
export function rhoDfClosure(
|
|
372
|
+
data: DataInput,
|
|
373
|
+
options?: { format?: DataFormat }
|
|
374
|
+
): Promise<{ ok: boolean; ntriples: string }>;
|
|
375
|
+
|
|
376
|
+
/** Literature-name alias for coreRdfsCheck (ρdf). */
|
|
377
|
+
export function rhoDfFragmentCheck(
|
|
378
|
+
data: DataInput,
|
|
379
|
+
options?: { format?: DataFormat }
|
|
380
|
+
): Promise<{ ok: boolean; fragment: boolean }>;
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* RDFS-Plus closure (RDF.Entailment.RDFSPlus.fst's `rdfs_plus_closure`):
|
|
384
|
+
* RDFS plus the practical OWL subset — owl:sameAs, owl:inverseOf,
|
|
385
|
+
* Symmetric/Transitive/Functional/InverseFunctionalProperty,
|
|
386
|
+
* equivalentClass/Property ("RDFS-Plus", Allemang & Hendler 2008;
|
|
387
|
+
* "RDFS++", AllegroGraph). Every OWL row carries proved licensing +
|
|
388
|
+
* truth lemmas; no chain-level completeness claim (theorem registry).
|
|
389
|
+
*/
|
|
390
|
+
export function rdfsPlusClosure(
|
|
391
|
+
data: DataInput,
|
|
392
|
+
options?: { format?: DataFormat }
|
|
393
|
+
): Promise<{ ok: boolean; ntriples: string; rounds: number }>;
|
|
394
|
+
|
|
395
|
+
/**
|
|
396
|
+
* OWL tableau materialisation (formal/fstar/Tableau.fst's
|
|
397
|
+
* `tableau_materialise`): add `i rdf:type <ClassExpression>` for every
|
|
398
|
+
* individual the model-construction reasoner proves is a member of an
|
|
399
|
+
* OWL class expression (someValuesFrom / hasValue / unionOf /
|
|
400
|
+
* intersectionOf, and the named class an equivalentClass restriction
|
|
401
|
+
* defines). Needs the npm-entry engine bundle. Default graph only.
|
|
402
|
+
* `dataset` is input + tableau-derived triples; `addedCount` is how
|
|
403
|
+
* many triples the tableau added.
|
|
404
|
+
*/
|
|
405
|
+
export function tableauMaterialise(
|
|
406
|
+
data: DataInput,
|
|
407
|
+
options?: { format?: DataFormat }
|
|
408
|
+
): Promise<{ dataset: Dataset; addedCount: number }>;
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* OWL DL inconsistency verdict (bin/owl-runner's DL pipeline: OWL-RL
|
|
412
|
+
* closure -> tableau materialise -> OWL-RL closure -> is_inconsistent).
|
|
413
|
+
* `rlAlone` is the plain OWL-RL verdict on the same input, so a caller
|
|
414
|
+
* can see the cases the tableau adds. Needs the npm-entry engine
|
|
415
|
+
* bundle. Default graph only.
|
|
416
|
+
*/
|
|
417
|
+
export function tableauDlInconsistent(
|
|
418
|
+
data: DataInput,
|
|
419
|
+
options?: { format?: DataFormat }
|
|
420
|
+
): Promise<{ inconsistent: boolean; rlAlone: boolean }>;
|
|
421
|
+
|
|
422
|
+
/**
|
|
423
|
+
* OWL DL consistency verdict via the verified clash-detecting tableau
|
|
424
|
+
* (Tableau.Refute.tableau_consistent over the OWL-RL closure -- the
|
|
425
|
+
* pure verified chain bin/owl-runner runs under `--regime dl`, minus
|
|
426
|
+
* its native-only z3 oracle). Needs the npm-entry engine bundle.
|
|
427
|
+
* Default graph only. `consistent` is three-valued: `false` (a clash on
|
|
428
|
+
* every branch), `true` (a model built), or `null` -- a budget-out, with
|
|
429
|
+
* `reason` naming the fuel cap (never a silent false).
|
|
430
|
+
*/
|
|
431
|
+
export function owlIsConsistent(
|
|
432
|
+
data: DataInput,
|
|
433
|
+
options?: { format?: DataFormat; fuel?: number | string }
|
|
434
|
+
): Promise<{ consistent: boolean | null; reason?: string }>;
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* OWL entailment check: does `premise` entail `conclusion`? Verified
|
|
438
|
+
* two-path dispatch: `via: "closure"` (the conclusion is in the OWL-RL
|
|
439
|
+
* closure of the premise) or `via: "refutation"` (the negated
|
|
440
|
+
* conclusion is refuted on every goal). Needs the npm-entry engine
|
|
441
|
+
* bundle. Default graph only. `entailed` is `true`, `false`, or `null`
|
|
442
|
+
* (a refutation budget-out, with `reason` naming the cap).
|
|
443
|
+
*/
|
|
444
|
+
export function owlEntails(
|
|
445
|
+
premise: DataInput,
|
|
446
|
+
conclusion: DataInput,
|
|
447
|
+
options?: { format?: DataFormat; fuel?: number | string }
|
|
448
|
+
): Promise<{ entailed: boolean | null; via: 'closure' | 'refutation'; reason?: string }>;
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* Evaluate an RML mapping graph against one logical source's raw data,
|
|
452
|
+
* returning the generated triples as a Dataset. Needs the npm-entry
|
|
453
|
+
* engine bundle. Every triples map in `mapping` reads the SAME
|
|
454
|
+
* `sourceData` -- joins across two different logical sources are out
|
|
455
|
+
* of scope for this entry point.
|
|
456
|
+
* @param mapping the RML mapping graph (Turtle by default)
|
|
457
|
+
* @param sourceData raw JSON or CSV text (not RDF)
|
|
458
|
+
*/
|
|
459
|
+
export function rmlMap(
|
|
460
|
+
mapping: DataInput,
|
|
461
|
+
sourceData: string,
|
|
462
|
+
sourceKind: 'json' | 'csv',
|
|
463
|
+
options?: { format?: DataFormat }
|
|
464
|
+
): Promise<Dataset>;
|
|
465
|
+
|
|
466
|
+
export interface CsvwOptions {
|
|
467
|
+
/** 'standard' (default): full csvw:TableGroup/Table/Row wrapper;
|
|
468
|
+
* 'minimal': bare cell triples only. */
|
|
469
|
+
mode?: 'standard' | 'minimal';
|
|
470
|
+
/** Base IRI for resolving the metadata's `url` and templates
|
|
471
|
+
* (default 'file:///'). */
|
|
472
|
+
base?: string;
|
|
473
|
+
/** The tabular file's own URL, used when the metadata carries none
|
|
474
|
+
* (default 'table.csv'); cell predicates default to
|
|
475
|
+
* `<tableUrl>#<colName>`. */
|
|
476
|
+
url?: string;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
/**
|
|
480
|
+
* CSVW csv2rdf conversion (w3.org/TR/csv2rdf): convert raw tabular
|
|
481
|
+
* data plus an optional CSVW metadata document (JSON text -- '' or
|
|
482
|
+
* omitted infers the schema from the CSV's own header row) into a
|
|
483
|
+
* Dataset. Needs the npm-entry engine bundle. Every table in a
|
|
484
|
+
* multi-table `tables` group reads the SAME `csvText`.
|
|
485
|
+
*/
|
|
486
|
+
export function csvwToRdf(
|
|
487
|
+
csvText: string,
|
|
488
|
+
metadataJson?: string,
|
|
489
|
+
options?: CsvwOptions
|
|
490
|
+
): Promise<Dataset>;
|
|
491
|
+
|
|
492
|
+
export interface JsonLdOptions {
|
|
493
|
+
base?: string;
|
|
494
|
+
rdfDirection?: string;
|
|
495
|
+
expandContext?: string;
|
|
496
|
+
processingMode?: string;
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
/**
|
|
500
|
+
* Parse a JSON-LD document into a Dataset, with JSON-LD-specific
|
|
501
|
+
* options `parse()` has no room for. Needs the npm-entry engine
|
|
502
|
+
* bundle (plain `parse(text, {format:'jsonld'})` also works for the
|
|
503
|
+
* common case).
|
|
504
|
+
*/
|
|
505
|
+
export function jsonldToRdf(
|
|
506
|
+
jsonldText: string,
|
|
507
|
+
options?: JsonLdOptions
|
|
508
|
+
): Promise<Dataset>;
|
|
509
|
+
|
|
510
|
+
export interface JsonLdFromRdfOptions {
|
|
511
|
+
useNativeTypes?: boolean;
|
|
512
|
+
useRdfType?: boolean;
|
|
513
|
+
format?: DataFormat;
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* Serialize an RDF dataset as an expanded-form JSON-LD document -- the
|
|
518
|
+
* reverse of jsonldToRdf (the verified JSONLD.FromRdf.from_rdf).
|
|
519
|
+
* Returns the parsed JSON-LD value (an array of node objects). Needs
|
|
520
|
+
* the npm-entry engine bundle.
|
|
521
|
+
*/
|
|
522
|
+
export function jsonldFromRdf(
|
|
523
|
+
data: DataInput,
|
|
524
|
+
options?: JsonLdFromRdfOptions
|
|
525
|
+
): Promise<any>;
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
* did:key resolution: resolve a `did:key:z6Mk...` (Ed25519) to its DID
|
|
529
|
+
* Document, returned as a Dataset (the verified DID_Key.did_key_document).
|
|
530
|
+
* Needs the npm-entry engine bundle.
|
|
531
|
+
*/
|
|
532
|
+
export function didKeyResolve(didString: string): Promise<Dataset>;
|
|
533
|
+
|
|
534
|
+
/**
|
|
535
|
+
* Test whether an XML document is well-formed (Parser_XML). The
|
|
536
|
+
* byte-oriented parser has no DOCTYPE/DTD production, so a document
|
|
537
|
+
* containing a DOCTYPE reports false. Needs the npm-entry engine bundle.
|
|
538
|
+
*/
|
|
539
|
+
export function xmlWellformed(xmlText: string): Promise<boolean>;
|
|
540
|
+
|
|
541
|
+
/** The value shape returned by {@link xpathEval}. */
|
|
542
|
+
export interface XPathResult {
|
|
543
|
+
resultType: 'nodeset' | 'string' | 'number' | 'boolean';
|
|
544
|
+
count?: number;
|
|
545
|
+
stringValue?: string;
|
|
546
|
+
nodes?: Array<{ kind: string; name: string; value: string }>;
|
|
547
|
+
value?: string | number | boolean;
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Evaluate an XPath 1.0 expression over an XML document
|
|
552
|
+
* (XPath_Eval.eval_xpath_from_root). Needs the npm-entry engine bundle.
|
|
553
|
+
*/
|
|
554
|
+
export function xpathEval(
|
|
555
|
+
xmlText: string,
|
|
556
|
+
xpathExpr: string
|
|
557
|
+
): Promise<XPathResult>;
|
|
558
|
+
|
|
559
|
+
/**
|
|
560
|
+
* RIF Core forward-chaining saturation, materialized as a new Dataset
|
|
561
|
+
* (input triples + derived triples, default graph only). Needs the
|
|
562
|
+
* npm-entry engine bundle.
|
|
563
|
+
* @param data the premise graph
|
|
564
|
+
* @param rifRulesXml a RIF Core XML rule document
|
|
565
|
+
*/
|
|
566
|
+
export function rifEval(
|
|
567
|
+
data: DataInput,
|
|
568
|
+
rifRulesXml: string,
|
|
569
|
+
options?: { format?: DataFormat }
|
|
570
|
+
): Promise<Dataset>;
|
|
571
|
+
|
|
572
|
+
// ---------------------------------------------------------------------
|
|
573
|
+
// In-memory COTTAS bytes store (docs/designissues/2026-07-06-inmemory-
|
|
574
|
+
// bytes-store.md). openCottas()'s handle is NOT a Dataset: rows decode
|
|
575
|
+
// lazily as queryCottas() touches them, never materializing the whole
|
|
576
|
+
// corpus onto the heap. Needs the npm-entry engine bundle.
|
|
577
|
+
// ---------------------------------------------------------------------
|
|
578
|
+
|
|
579
|
+
/** Open a COTTAS/Parquet artifact's raw bytes as a queryable, read-only store. */
|
|
580
|
+
export function openCottas(bytes: Uint8Array | ArrayBuffer | string): Promise<string>;
|
|
581
|
+
|
|
582
|
+
/**
|
|
583
|
+
* Run a SPARQL 1.1 query against a store opened by openCottas(). No
|
|
584
|
+
* `entail` option and no write overlay (read-only) -- see
|
|
585
|
+
* npm/factoidal/lib/api.js's queryCottas doc comment for the full
|
|
586
|
+
* divergence list from query().
|
|
587
|
+
* @param handle from openCottas()
|
|
588
|
+
*/
|
|
589
|
+
export function queryCottas(
|
|
590
|
+
handle: string,
|
|
591
|
+
sparql: string
|
|
592
|
+
): Promise<Bindings[] | boolean | Dataset>;
|
|
593
|
+
|
|
594
|
+
/** Release a store opened by openCottas(). */
|
|
595
|
+
export function closeCottas(handle: string): Promise<void>;
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Serialize a dataset to COTTAS/Parquet bytes via the native writer
|
|
599
|
+
* (RDF.CottasStore.BaseWriter.serialize_cottas_v2). Round-trips into
|
|
600
|
+
* openCottas().
|
|
601
|
+
*/
|
|
602
|
+
export function toCottas(data: DataInput): Promise<Uint8Array>;
|
|
603
|
+
|
|
604
|
+
// ---------------------------------------------------------------------
|
|
605
|
+
// Typed engine functions (#74 npm FP surface). Each is a pure,
|
|
606
|
+
// value-in / value-out wrapper over one F*-extracted engine; all need
|
|
607
|
+
// the npm-entry bundle.
|
|
608
|
+
// ---------------------------------------------------------------------
|
|
609
|
+
|
|
610
|
+
/**
|
|
611
|
+
* XSLT 1.0 transform (XSLT.Transform.transform): apply `stylesheetXml`
|
|
612
|
+
* to `sourceXml`, returning the serialized result tree.
|
|
613
|
+
*/
|
|
614
|
+
export function xsltTransform(
|
|
615
|
+
stylesheetXml: string,
|
|
616
|
+
sourceXml: string
|
|
617
|
+
): Promise<string>;
|
|
618
|
+
|
|
619
|
+
/** The exact value a Content MathML expression evaluates to. */
|
|
620
|
+
export type MathValue =
|
|
621
|
+
| { kind: 'rat'; num: number; den: number }
|
|
622
|
+
| { kind: 'bool'; value: boolean }
|
|
623
|
+
| { kind: 'undef'; reason: string };
|
|
624
|
+
|
|
625
|
+
/**
|
|
626
|
+
* Evaluate a Content MathML document (MathML.Content.eval_doc_env).
|
|
627
|
+
* `bindings` maps ci-variable names to value strings; pass {} (or
|
|
628
|
+
* omit) for a closed expression.
|
|
629
|
+
*/
|
|
630
|
+
export function mathmlEval(
|
|
631
|
+
contentMathmlXml: string,
|
|
632
|
+
bindings?: Record<string, string>
|
|
633
|
+
): Promise<MathValue>;
|
|
634
|
+
|
|
635
|
+
/** One XForms model bind (a subset of the §7 MIPs). */
|
|
636
|
+
export interface XFormsBind {
|
|
637
|
+
id?: string;
|
|
638
|
+
target: string;
|
|
639
|
+
calculate?: string;
|
|
640
|
+
constraint?: string;
|
|
641
|
+
relevant?: string;
|
|
642
|
+
required?: string;
|
|
643
|
+
readonly?: string;
|
|
644
|
+
type?:
|
|
645
|
+
| 'string' | 'boolean' | 'integer'
|
|
646
|
+
| 'decimal' | 'float' | 'double';
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/** Per-node validity from an XForms recalculate. */
|
|
650
|
+
export interface XFormsNodeValidity {
|
|
651
|
+
target: string;
|
|
652
|
+
value: string;
|
|
653
|
+
typeValid: boolean;
|
|
654
|
+
constraint: boolean;
|
|
655
|
+
relevant: boolean;
|
|
656
|
+
required: boolean;
|
|
657
|
+
readonly: boolean;
|
|
658
|
+
valid: boolean;
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
/**
|
|
662
|
+
* XForms recalculate (XForms.Bind.recalculate): apply the model binds
|
|
663
|
+
* to `instanceXml`, returning the recomputed instance and a validity
|
|
664
|
+
* report per bound node.
|
|
665
|
+
*/
|
|
666
|
+
export function xformsRecalc(
|
|
667
|
+
instanceXml: string,
|
|
668
|
+
binds: XFormsBind[]
|
|
669
|
+
): Promise<{ instance: string; validity: XFormsNodeValidity[] }>;
|
|
670
|
+
|
|
671
|
+
/**
|
|
672
|
+
* JSON Schema (draft-07) validation (JSONSchema.Validate.validate).
|
|
673
|
+
* The verified validator gives a definite pass/fail/unsupported verdict
|
|
674
|
+
* rather than a per-keyword error list; `errors` carries a single
|
|
675
|
+
* reason string when the result is not a definite pass.
|
|
676
|
+
*/
|
|
677
|
+
export function jsonSchemaValidate(
|
|
678
|
+
schemaJson: string,
|
|
679
|
+
instanceJson: string
|
|
680
|
+
): Promise<{
|
|
681
|
+
valid: boolean;
|
|
682
|
+
result: 'pass' | 'fail' | 'unsupported';
|
|
683
|
+
errors: string[];
|
|
684
|
+
}>;
|
|
685
|
+
|
|
686
|
+
/** One Schematron finding. */
|
|
687
|
+
export interface SchematronFinding {
|
|
688
|
+
type: 'assert-fail' | 'report-hit' | 'indeterminate';
|
|
689
|
+
context: string;
|
|
690
|
+
test: string;
|
|
691
|
+
message: string;
|
|
692
|
+
path: string;
|
|
693
|
+
reason?: string;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
/**
|
|
697
|
+
* Schematron validation (Schematron.Validate.validate): every finding
|
|
698
|
+
* (failed assert, fired report, indeterminate) in pattern-then-document
|
|
699
|
+
* order.
|
|
700
|
+
*/
|
|
701
|
+
export function schematronValidate(
|
|
702
|
+
schematronXml: string,
|
|
703
|
+
instanceXml: string
|
|
704
|
+
): Promise<{ findings: SchematronFinding[] }>;
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* An exact-arithmetic expression in the TOAN JSON codec, mirroring
|
|
708
|
+
* Math.Expr.expr (E_Int/E_Rat/E_Bool/E_Sym/E_App).
|
|
709
|
+
*/
|
|
710
|
+
export type ToanExpr =
|
|
711
|
+
| { int: number }
|
|
712
|
+
| { rat: [number, number] }
|
|
713
|
+
| { bool: boolean }
|
|
714
|
+
| { sym: string }
|
|
715
|
+
| { app: string; args: ToanExpr[] };
|
|
716
|
+
|
|
717
|
+
/** Finite summation of `bodyExpr[idx:=lo..hi]`, as Content MathML. */
|
|
718
|
+
export function toanSummation(
|
|
719
|
+
bodyExpr: ToanExpr,
|
|
720
|
+
idx: string,
|
|
721
|
+
lo: number,
|
|
722
|
+
hi: number
|
|
723
|
+
): Promise<string>;
|
|
724
|
+
|
|
725
|
+
/** Finite product of `bodyExpr[idx:=lo..hi]`, as Content MathML. */
|
|
726
|
+
export function toanProduct(
|
|
727
|
+
bodyExpr: ToanExpr,
|
|
728
|
+
idx: string,
|
|
729
|
+
lo: number,
|
|
730
|
+
hi: number
|
|
731
|
+
): Promise<string>;
|
|
732
|
+
|
|
733
|
+
/** Canonical simplification of `expr`, as Content MathML. */
|
|
734
|
+
export function toanSimplify(expr: ToanExpr): Promise<string>;
|
|
735
|
+
|
|
736
|
+
/** Derivative of `expr` w.r.t. `variable`, as Content MathML. */
|
|
737
|
+
export function toanDiff(expr: ToanExpr, variable: string): Promise<string>;
|
|
738
|
+
|
|
739
|
+
/** `expr[variable := value]` simplified, as Content MathML. */
|
|
740
|
+
export function toanSubst(
|
|
741
|
+
expr: ToanExpr,
|
|
742
|
+
variable: string,
|
|
743
|
+
value: ToanExpr
|
|
744
|
+
): Promise<string>;
|
|
745
|
+
|
|
746
|
+
/** A matrix/vector cell: an integer or an exact [num, den] rational. */
|
|
747
|
+
export type MatrixCell = number | [number, number];
|
|
748
|
+
|
|
749
|
+
/** The rendered result of a matrix/vector operation. */
|
|
750
|
+
export interface MatrixResult {
|
|
751
|
+
/** Math.Matrix.mres_to_string of the result ("undef" on failure). */
|
|
752
|
+
result: string;
|
|
753
|
+
/** The diagnostic reason when the result is undefined, else "". */
|
|
754
|
+
reason: string;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/** Exact determinant of a square matrix (Math.Matrix.dyn_determinant). */
|
|
758
|
+
export function matrixDeterminant(
|
|
759
|
+
matrix: MatrixCell[][]
|
|
760
|
+
): Promise<MatrixResult>;
|
|
761
|
+
|
|
762
|
+
/** Dot product of two vectors (Math.Matrix.dyn_scalarproduct). */
|
|
763
|
+
export function matrixScalarProduct(
|
|
764
|
+
a: MatrixCell[],
|
|
765
|
+
b: MatrixCell[]
|
|
766
|
+
): Promise<MatrixResult>;
|
|
767
|
+
|
|
768
|
+
/** Cross product of two 3-vectors (Math.Matrix.dyn_vectorproduct). */
|
|
769
|
+
export function matrixVectorProduct(
|
|
770
|
+
a: MatrixCell[],
|
|
771
|
+
b: MatrixCell[]
|
|
772
|
+
): Promise<MatrixResult>;
|
|
773
|
+
|
|
774
|
+
/** Outer product of two vectors (Math.Matrix.dyn_outerproduct). */
|
|
775
|
+
export function matrixOuterProduct(
|
|
776
|
+
a: MatrixCell[],
|
|
777
|
+
b: MatrixCell[]
|
|
778
|
+
): Promise<MatrixResult>;
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* A fixed-precision decimal (Math.Sigmoid.scaled: mantissa / 10^scale),
|
|
782
|
+
* the same (mantissa, scale) convention SPARQL11.Algebra.parse_to_scaled
|
|
783
|
+
* uses for xsd:decimal literals. `decimal` is the same pair formatted
|
|
784
|
+
* back to a string by SPARQL11_Algebra.format_scaled_value.
|
|
785
|
+
*/
|
|
786
|
+
export interface ScaledValue {
|
|
787
|
+
mantissa: string;
|
|
788
|
+
scale: string;
|
|
789
|
+
decimal: string;
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
/** Parameters for {@link sigmoidPoints}: decimal-literal strings/numbers. */
|
|
793
|
+
export interface SigmoidParams {
|
|
794
|
+
k: number | string;
|
|
795
|
+
x0: number | string;
|
|
796
|
+
l: number | string;
|
|
797
|
+
xmin: number | string;
|
|
798
|
+
xmax: number | string;
|
|
799
|
+
n: number | string;
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
/**
|
|
803
|
+
* n+1 evenly spaced samples of the logistic sigmoid
|
|
804
|
+
* L / (1 + exp(-k*(x - x0))) over [xmin, xmax] (Math.Sigmoid.
|
|
805
|
+
* sigmoid_points). All arithmetic -- argument reduction, the
|
|
806
|
+
* truncated Taylor series, repeated squaring, and the x samples
|
|
807
|
+
* themselves -- runs as exact rational arithmetic inside
|
|
808
|
+
* Math.Sigmoid.fst; see that module's header for the documented error
|
|
809
|
+
* bound on the returned (rounded) values.
|
|
810
|
+
*/
|
|
811
|
+
export function sigmoidPoints(
|
|
812
|
+
params: SigmoidParams
|
|
813
|
+
): Promise<Array<{ x: ScaledValue; y: ScaledValue }>>;
|
|
814
|
+
|
|
815
|
+
/**
|
|
816
|
+
* Presentation MathML for the sigmoid formula L / (1 + exp(-k*(x - x0))),
|
|
817
|
+
* engine-serialized (MathML.Present.to_presentation_mathml applied to a
|
|
818
|
+
* fixed Math.Expr.expr) -- never hand-written MathML.
|
|
819
|
+
*/
|
|
820
|
+
export function sigmoidFormulaMathml(): Promise<string>;
|
|
821
|
+
|
|
822
|
+
// ---------------------------------------------------------------------
|
|
823
|
+
// VC Data Integrity crypto (eddsa-rdfc-2022) — the F*-extracted
|
|
824
|
+
// VC_DataIntegrity pipeline, its four crypto assume vals realised by
|
|
825
|
+
// HACL*'s OWN official WebAssembly build (hacl-wasm). All need the
|
|
826
|
+
// npm-entry bundle AND the HACL* wasm backend.
|
|
827
|
+
//
|
|
828
|
+
// Init story: on the Node entries (index.js/index.mjs and the /wasm
|
|
829
|
+
// entry) these typed wrappers AUTO-AWAIT initHacl() on the first VC
|
|
830
|
+
// call — a caller never has to remember the init step. In the browser
|
|
831
|
+
// (browser.js) the page must initialise HACL* itself first (the
|
|
832
|
+
// hacl-wasm URL is page-specific); see browser.js's VC section. Either
|
|
833
|
+
// way, an uninitialised backend makes verify THROW, never silently
|
|
834
|
+
// return true (#286, the throw-on-uninit contract).
|
|
835
|
+
// ---------------------------------------------------------------------
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* SHA-256 of a message string's bytes, as a lowercase hex digest
|
|
839
|
+
* (VC_DataIntegrity.hash_sha256_hex, HACL* SHA-2).
|
|
840
|
+
*/
|
|
841
|
+
export function vcSha256Hex(message: string): Promise<string>;
|
|
842
|
+
|
|
843
|
+
/** Derive the Ed25519 public key (hex) from a 32-byte secret key (hex). */
|
|
844
|
+
export function vcEd25519SecretToPublic(secretKeyHex: string): Promise<string>;
|
|
845
|
+
|
|
846
|
+
/** Ed25519 signature (hex) over a hex-encoded message. */
|
|
847
|
+
export function vcEd25519Sign(
|
|
848
|
+
secretKeyHex: string,
|
|
849
|
+
messageHex: string
|
|
850
|
+
): Promise<string>;
|
|
851
|
+
|
|
852
|
+
/**
|
|
853
|
+
* Ed25519 verification. Wrong key, tampered signature, altered
|
|
854
|
+
* message, or a malformed-length input all resolve to false — never an
|
|
855
|
+
* exception-hidden true.
|
|
856
|
+
*/
|
|
857
|
+
export function vcEd25519Verify(
|
|
858
|
+
publicKeyHex: string,
|
|
859
|
+
messageHex: string,
|
|
860
|
+
signatureHex: string
|
|
861
|
+
): Promise<boolean>;
|
|
862
|
+
|
|
863
|
+
/**
|
|
864
|
+
* Create an eddsa-rdfc-2022 Data Integrity proofValue (multibase-z,
|
|
865
|
+
* base58btc) over already-canonicalized inputs — RDFC-1.0 canonical
|
|
866
|
+
* N-Quads of the document and of the proof config (see canonicalize()).
|
|
867
|
+
*/
|
|
868
|
+
export function vcEddsaCreateFromCanonical(
|
|
869
|
+
secretKeyHex: string,
|
|
870
|
+
canonicalDocument: string,
|
|
871
|
+
canonicalConfig: string
|
|
872
|
+
): Promise<string>;
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Verify an eddsa-rdfc-2022 proofValue against canonical inputs. Wrong
|
|
876
|
+
* key, tampered document/config, or tampered proofValue all resolve to
|
|
877
|
+
* false.
|
|
878
|
+
*/
|
|
879
|
+
export function vcEddsaVerifyFromCanonical(
|
|
880
|
+
publicKeyHex: string,
|
|
881
|
+
canonicalDocument: string,
|
|
882
|
+
canonicalConfig: string,
|
|
883
|
+
proofValue: string
|
|
884
|
+
): Promise<boolean>;
|
|
885
|
+
|
|
886
|
+
/**
|
|
887
|
+
* VC Data Model 2.0 structural conformance check (VC.Credential.fst's
|
|
888
|
+
* vc_check_from_string, F*-verified — 117 pass, 0 fail on the offline
|
|
889
|
+
* vc_stage1 fixture suite). Pure structural validation, no crypto.
|
|
890
|
+
* `v2ctxJson` is the vendored VCDM v2 base context document's raw JSON
|
|
891
|
+
* text (third_party/contexts/credentials-v2.jsonld); `credentialJson`
|
|
892
|
+
* is the raw JSON text of the VC/VP document under test.
|
|
893
|
+
*/
|
|
894
|
+
export function vcCheckCredential(
|
|
895
|
+
v2ctxJson: string,
|
|
896
|
+
credentialJson: string
|
|
897
|
+
): Promise<{ valid: boolean; reason?: string }>;
|
|
898
|
+
|
|
899
|
+
/**
|
|
900
|
+
* credentialSubject presence/shape check, VERSION-AGNOSTIC (Track A1,
|
|
901
|
+
* docs/designissues/2026-07-11-vc-canivc-eecc-plan.md) —
|
|
902
|
+
* VC.Credential.fst's vc_check_credential_subject_from_string. Unlike
|
|
903
|
+
* vcCheckCredential, does not require the VCDM 2.0 base @context to be
|
|
904
|
+
* present/first.
|
|
905
|
+
*/
|
|
906
|
+
export function vcCheckCredentialSubject(
|
|
907
|
+
credentialJson: string
|
|
908
|
+
): Promise<{ valid: boolean; reason?: string }>;
|
|
909
|
+
|
|
910
|
+
/**
|
|
911
|
+
* DATA_LOSS_DETECTION_ERROR check (Track A1, same plan doc) —
|
|
912
|
+
* VC.Credential.fst's vc_check_no_data_loss_from_string. `credentialJson`
|
|
913
|
+
* must already have any remote @context IRI inlined to the real context
|
|
914
|
+
* object.
|
|
915
|
+
*/
|
|
916
|
+
export function vcCheckNoDataLoss(
|
|
917
|
+
credentialJson: string
|
|
918
|
+
): Promise<{ valid: boolean; reason?: string }>;
|
|
919
|
+
|
|
920
|
+
/**
|
|
921
|
+
* relatedResource digest verification (VCDM 2.0 §5.3) —
|
|
922
|
+
* VC.Credential.fst's vc_check_related_resource_digests_from_string.
|
|
923
|
+
* `registryJson` is a JSON array of {"id", "digestsHex"} entries computed
|
|
924
|
+
* from vendored copies of each known resource's content bytes.
|
|
925
|
+
*/
|
|
926
|
+
export function vcCheckRelatedResourceDigests(
|
|
927
|
+
registryJson: string,
|
|
928
|
+
credentialJson: string
|
|
929
|
+
): Promise<{ valid: boolean; reason?: string }>;
|
|
930
|
+
|
|
931
|
+
/** Feature probe for the currently available engine bundles. */
|
|
932
|
+
export function capabilities(): Promise<{
|
|
933
|
+
entry: boolean;
|
|
934
|
+
construct: boolean;
|
|
935
|
+
update: boolean;
|
|
936
|
+
canonicalize: boolean;
|
|
937
|
+
graphs: boolean;
|
|
938
|
+
canonicalHash: boolean;
|
|
939
|
+
shacl: boolean;
|
|
940
|
+
shex: boolean;
|
|
941
|
+
owlClosure: boolean;
|
|
942
|
+
tableau: boolean;
|
|
943
|
+
rml: boolean;
|
|
944
|
+
csvw: boolean;
|
|
945
|
+
jsonld: boolean;
|
|
946
|
+
jsonldFromRdf: boolean;
|
|
947
|
+
didKey: boolean;
|
|
948
|
+
xml: boolean;
|
|
949
|
+
xpath: boolean;
|
|
950
|
+
rif: boolean;
|
|
951
|
+
xslt: boolean;
|
|
952
|
+
mathml: boolean;
|
|
953
|
+
xforms: boolean;
|
|
954
|
+
jsonSchema: boolean;
|
|
955
|
+
schematron: boolean;
|
|
956
|
+
toan: boolean;
|
|
957
|
+
matrix: boolean;
|
|
958
|
+
/** The sigmoid (Math.Sigmoid) ABI exports are present. */
|
|
959
|
+
sigmoid: boolean;
|
|
960
|
+
/**
|
|
961
|
+
* The VC Data Integrity crypto ABI exports are present. Note: the
|
|
962
|
+
* HACL* wasm backend is still initialised at call time — this flag
|
|
963
|
+
* reports export availability, not that init has run.
|
|
964
|
+
*/
|
|
965
|
+
vcCrypto: boolean;
|
|
966
|
+
/** The in-memory COTTAS bytes store exports are present. */
|
|
967
|
+
cottasBytesStore: boolean;
|
|
968
|
+
}>;
|
|
969
|
+
|
|
970
|
+
// ---------------------------------------------------------------------
|
|
971
|
+
// Legacy raw surface (single-shot CLI shapes)
|
|
972
|
+
// ---------------------------------------------------------------------
|
|
973
|
+
|
|
974
|
+
/** SPARQL Results JSON term (https://www.w3.org/TR/sparql11-results-json/). */
|
|
975
|
+
export interface SrjTerm {
|
|
976
|
+
type: 'uri' | 'bnode' | 'literal' | 'typed-literal';
|
|
977
|
+
value: string;
|
|
978
|
+
'xml:lang'?: string;
|
|
979
|
+
datatype?: string;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
export interface SparqlResultsJson {
|
|
983
|
+
head: { vars?: string[]; link?: string[] };
|
|
984
|
+
results?: { bindings: Array<Record<string, SrjTerm>> };
|
|
985
|
+
boolean?: boolean;
|
|
986
|
+
}
|
|
987
|
+
|
|
988
|
+
export type OutputFormat =
|
|
989
|
+
| 'json' | 'csv' | 'tsv' | 'xml' | 'table' | 'ntriples';
|
|
990
|
+
|
|
991
|
+
/**
|
|
992
|
+
* Legacy single-shot API: returns parsed SPARQL Results JSON when
|
|
993
|
+
* output is 'json' (default), the raw output string otherwise.
|
|
994
|
+
*/
|
|
995
|
+
export function queryRaw(
|
|
996
|
+
dataString: string,
|
|
997
|
+
queryString: string,
|
|
998
|
+
options?: {
|
|
999
|
+
dataFormat?: DataFormat;
|
|
1000
|
+
entail?: EntailRegime;
|
|
1001
|
+
output?: OutputFormat;
|
|
1002
|
+
}
|
|
1003
|
+
): Promise<SparqlResultsJson | string>;
|
|
1004
|
+
|
|
1005
|
+
/** Package version string, e.g. '0.1.0-alpha.0'. */
|
|
1006
|
+
export const version: string;
|
|
1007
|
+
|
|
1008
|
+
declare const _default: {
|
|
1009
|
+
parse: typeof parse;
|
|
1010
|
+
query: typeof query;
|
|
1011
|
+
queryHdt: typeof queryHdt;
|
|
1012
|
+
update: typeof update;
|
|
1013
|
+
serialize: typeof serialize;
|
|
1014
|
+
canonicalize: typeof canonicalize;
|
|
1015
|
+
graphs: typeof graphs;
|
|
1016
|
+
canonicalHash: typeof canonicalHash;
|
|
1017
|
+
shaclValidate: typeof shaclValidate;
|
|
1018
|
+
shexValidate: typeof shexValidate;
|
|
1019
|
+
owlClosure: typeof owlClosure;
|
|
1020
|
+
tableauMaterialise: typeof tableauMaterialise;
|
|
1021
|
+
tableauDlInconsistent: typeof tableauDlInconsistent;
|
|
1022
|
+
owlIsConsistent: typeof owlIsConsistent;
|
|
1023
|
+
owlEntails: typeof owlEntails;
|
|
1024
|
+
rmlMap: typeof rmlMap;
|
|
1025
|
+
csvwToRdf: typeof csvwToRdf;
|
|
1026
|
+
jsonldToRdf: typeof jsonldToRdf;
|
|
1027
|
+
jsonldFromRdf: typeof jsonldFromRdf;
|
|
1028
|
+
didKeyResolve: typeof didKeyResolve;
|
|
1029
|
+
xmlWellformed: typeof xmlWellformed;
|
|
1030
|
+
xpathEval: typeof xpathEval;
|
|
1031
|
+
rifEval: typeof rifEval;
|
|
1032
|
+
openCottas: typeof openCottas;
|
|
1033
|
+
queryCottas: typeof queryCottas;
|
|
1034
|
+
closeCottas: typeof closeCottas;
|
|
1035
|
+
toCottas: typeof toCottas;
|
|
1036
|
+
xsltTransform: typeof xsltTransform;
|
|
1037
|
+
mathmlEval: typeof mathmlEval;
|
|
1038
|
+
xformsRecalc: typeof xformsRecalc;
|
|
1039
|
+
jsonSchemaValidate: typeof jsonSchemaValidate;
|
|
1040
|
+
schematronValidate: typeof schematronValidate;
|
|
1041
|
+
toanSummation: typeof toanSummation;
|
|
1042
|
+
toanProduct: typeof toanProduct;
|
|
1043
|
+
toanSimplify: typeof toanSimplify;
|
|
1044
|
+
toanDiff: typeof toanDiff;
|
|
1045
|
+
toanSubst: typeof toanSubst;
|
|
1046
|
+
matrixDeterminant: typeof matrixDeterminant;
|
|
1047
|
+
matrixScalarProduct: typeof matrixScalarProduct;
|
|
1048
|
+
matrixVectorProduct: typeof matrixVectorProduct;
|
|
1049
|
+
matrixOuterProduct: typeof matrixOuterProduct;
|
|
1050
|
+
sigmoidPoints: typeof sigmoidPoints;
|
|
1051
|
+
sigmoidFormulaMathml: typeof sigmoidFormulaMathml;
|
|
1052
|
+
vcSha256Hex: typeof vcSha256Hex;
|
|
1053
|
+
vcEd25519SecretToPublic: typeof vcEd25519SecretToPublic;
|
|
1054
|
+
vcEd25519Sign: typeof vcEd25519Sign;
|
|
1055
|
+
vcEd25519Verify: typeof vcEd25519Verify;
|
|
1056
|
+
vcEddsaCreateFromCanonical: typeof vcEddsaCreateFromCanonical;
|
|
1057
|
+
vcEddsaVerifyFromCanonical: typeof vcEddsaVerifyFromCanonical;
|
|
1058
|
+
vcCheckCredential: typeof vcCheckCredential;
|
|
1059
|
+
vcCheckCredentialSubject: typeof vcCheckCredentialSubject;
|
|
1060
|
+
vcCheckNoDataLoss: typeof vcCheckNoDataLoss;
|
|
1061
|
+
vcCheckRelatedResourceDigests: typeof vcCheckRelatedResourceDigests;
|
|
1062
|
+
capabilities: typeof capabilities;
|
|
1063
|
+
Dataset: typeof Dataset;
|
|
1064
|
+
dataFactory: DataFactory;
|
|
1065
|
+
queryRaw: typeof queryRaw;
|
|
1066
|
+
version: string;
|
|
1067
|
+
};
|
|
1068
|
+
export default _default;
|