@factoidal/core 0.7.1 → 0.11.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 +616 -1
- package/NOTICE +2 -21
- package/README.md +123 -993
- package/api.d.ts +53 -0
- package/api.js +5 -0
- package/api.mjs +56 -0
- package/bin/engine.mjs +38 -19
- package/bin/ext.mjs +16 -20
- package/bin/factoidal.mjs +667 -118
- package/bin/pack.mjs +37 -0
- package/bin/serve-worker.mjs +32 -0
- package/bin/serve.mjs +423 -0
- package/bin/store-worker-host.mjs +1 -1
- package/bin/store.mjs +1 -1
- package/browser.d.ts +114 -507
- package/browser.js +155 -2257
- package/docs/fuseki-replacement.md +108 -0
- package/fn.d.ts +25 -96
- package/fn.js +131 -240
- package/index.d.ts +620 -260
- package/index.js +4 -234
- package/index.mjs +180 -84
- package/l4-assets/l4factoidal.js +47 -7
- package/l4-assets/l4factoidal.mjs +1 -1
- package/l4-assets/l4factoidal.wasm +0 -0
- package/l4-assets/version.json +11 -7
- package/lib/api.mjs +2337 -0
- package/lib/browser-engine.mjs +69 -0
- package/lib/dataset.mjs +471 -0
- package/lib/delta-log-hosts.mjs +191 -0
- package/lib/lean-entry.mjs +213 -0
- package/lib/pure.mjs +98 -0
- package/lib/store.mjs +115 -0
- package/lib/version.mjs +5 -0
- package/lws/README.md +137 -0
- package/lws/persist.mjs +78 -0
- package/lws/server.mjs +416 -0
- package/package.json +59 -61
- package/rdfjs.js +5 -536
- package/rdfjs.mjs +517 -0
- package/sample-store.d.ts +8 -16
- package/sample-store.mjs +39 -29
- package/solid/client/README.md +100 -0
- package/solid/client/index.mjs +293 -0
- package/solid/server/README.md +96 -0
- package/solid/server/index.mjs +395 -0
- package/store-host/deno.mjs +8 -0
- package/store-host/index.mjs +12 -0
- package/store-host/node.mjs +8 -0
- package/xmpp/README.md +107 -0
- package/xmpp/index.mjs +229 -0
- package/browser-wasm.js +0 -872
- package/factoidal-npm-entry.js +0 -15477
- package/factoidal-npm-entry.wasm.assets/code-5a7fc68f2ab1323718b8.wasm +0 -0
- package/factoidal-npm-entry.wasm.js +0 -455
- package/factoidal.js +0 -13118
- package/factoidal.wasm.assets/code-bbe6099bfb5b10c4c3ab.wasm +0 -0
- package/factoidal.wasm.js +0 -457
- package/hacl-init.js +0 -92
- 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 +0 -775
- package/hacl-wasm/api.json +0 -3787
- package/hacl-wasm/layouts.json +0 -1
- package/hacl-wasm/loader.js +0 -568
- package/hacl-wasm/shell.js +0 -12
- package/l4-core.d.ts +0 -159
- package/l4-core.js +0 -188
- package/l4.d.ts +0 -50
- package/l4.js +0 -104
- package/lib/api.js +0 -2300
- package/lib/engine-js.js +0 -165
- package/lib/engine-wasm.js +0 -300
- package/sample-store/CURRENT +0 -1
- package/sample-store/gen-1/manifest.sbm2 +0 -0
- package/sample-store/gen-1/manifest.tsv +0 -14
- package/sample-store/gen-1/predicate-0.ibk3 +0 -0
- package/sample-store/gen-1/predicate-0.ibk3.merkle +0 -1
- package/sample-store/gen-1/predicate-0.ibk3.oli2 +0 -0
- package/sample-store/gen-1/predicate-0.ibk3.oli2.merkle +0 -1
- package/sample-store/gen-1/predicate-0.ibk3.sri2 +0 -0
- package/sample-store/gen-1/predicate-0.ibk3.sri2.merkle +0 -1
- package/sample-store/gen-1/predicate-0.ibk3.tli1 +0 -0
- package/sample-store/gen-1/predicate-0.ibk3.tli1.merkle +0 -0
- package/sample-store/gen-1/predicate-1.ibk3 +0 -0
- package/sample-store/gen-1/predicate-1.ibk3.merkle +0 -0
- package/sample-store/gen-1/predicate-1.ibk3.oli2 +0 -0
- package/sample-store/gen-1/predicate-1.ibk3.oli2.merkle +0 -0
- package/sample-store/gen-1/predicate-1.ibk3.sri2 +0 -0
- package/sample-store/gen-1/predicate-1.ibk3.sri2.merkle +0 -1
- package/sample-store/gen-1/predicate-1.ibk3.tli1 +0 -0
- package/sample-store/gen-1/predicate-1.ibk3.tli1.merkle +0 -1
- package/sample-store/gen-1/predicate-10.ibk3 +0 -0
- package/sample-store/gen-1/predicate-10.ibk3.merkle +0 -1
- package/sample-store/gen-1/predicate-10.ibk3.oli2 +0 -0
- package/sample-store/gen-1/predicate-10.ibk3.oli2.merkle +0 -0
- package/sample-store/gen-1/predicate-10.ibk3.sri2 +0 -0
- package/sample-store/gen-1/predicate-10.ibk3.sri2.merkle +0 -1
- package/sample-store/gen-1/predicate-10.ibk3.tli1 +0 -0
- package/sample-store/gen-1/predicate-10.ibk3.tli1.merkle +0 -1
- package/sample-store/gen-1/predicate-11.ibk3 +0 -0
- package/sample-store/gen-1/predicate-11.ibk3.merkle +0 -0
- package/sample-store/gen-1/predicate-11.ibk3.oli2 +0 -0
- package/sample-store/gen-1/predicate-11.ibk3.oli2.merkle +0 -1
- package/sample-store/gen-1/predicate-11.ibk3.sri2 +0 -0
- package/sample-store/gen-1/predicate-11.ibk3.sri2.merkle +0 -1
- package/sample-store/gen-1/predicate-11.ibk3.tli1 +0 -0
- package/sample-store/gen-1/predicate-11.ibk3.tli1.merkle +0 -1
- package/sample-store/gen-1/predicate-12.ibk3 +0 -0
- package/sample-store/gen-1/predicate-12.ibk3.merkle +0 -1
- package/sample-store/gen-1/predicate-12.ibk3.oli2 +0 -0
- package/sample-store/gen-1/predicate-12.ibk3.oli2.merkle +0 -1
- package/sample-store/gen-1/predicate-12.ibk3.sri2 +0 -0
- package/sample-store/gen-1/predicate-12.ibk3.sri2.merkle +0 -1
- package/sample-store/gen-1/predicate-12.ibk3.tli1 +0 -0
- package/sample-store/gen-1/predicate-12.ibk3.tli1.merkle +0 -1
- package/sample-store/gen-1/predicate-2.ibk3 +0 -0
- package/sample-store/gen-1/predicate-2.ibk3.merkle +0 -1
- package/sample-store/gen-1/predicate-2.ibk3.oli2 +0 -0
- package/sample-store/gen-1/predicate-2.ibk3.oli2.merkle +0 -1
- package/sample-store/gen-1/predicate-2.ibk3.sri2 +0 -0
- package/sample-store/gen-1/predicate-2.ibk3.sri2.merkle +0 -0
- package/sample-store/gen-1/predicate-2.ibk3.tli1 +0 -0
- package/sample-store/gen-1/predicate-2.ibk3.tli1.merkle +0 -0
- package/sample-store/gen-1/predicate-3.ibk3 +0 -0
- package/sample-store/gen-1/predicate-3.ibk3.merkle +0 -1
- package/sample-store/gen-1/predicate-3.ibk3.oli2 +0 -0
- package/sample-store/gen-1/predicate-3.ibk3.oli2.merkle +0 -1
- package/sample-store/gen-1/predicate-3.ibk3.sri2 +0 -0
- package/sample-store/gen-1/predicate-3.ibk3.sri2.merkle +0 -1
- package/sample-store/gen-1/predicate-3.ibk3.tli1 +0 -0
- package/sample-store/gen-1/predicate-3.ibk3.tli1.merkle +0 -1
- package/sample-store/gen-1/predicate-4.ibk3 +0 -0
- package/sample-store/gen-1/predicate-4.ibk3.merkle +0 -0
- package/sample-store/gen-1/predicate-4.ibk3.oli2 +0 -0
- package/sample-store/gen-1/predicate-4.ibk3.oli2.merkle +0 -1
- package/sample-store/gen-1/predicate-4.ibk3.sri2 +0 -0
- package/sample-store/gen-1/predicate-4.ibk3.sri2.merkle +0 -1
- package/sample-store/gen-1/predicate-4.ibk3.tli1 +0 -0
- package/sample-store/gen-1/predicate-4.ibk3.tli1.merkle +0 -2
- package/sample-store/gen-1/predicate-5.ibk3 +0 -0
- package/sample-store/gen-1/predicate-5.ibk3.merkle +0 -1
- package/sample-store/gen-1/predicate-5.ibk3.oli2 +0 -0
- package/sample-store/gen-1/predicate-5.ibk3.oli2.merkle +0 -1
- package/sample-store/gen-1/predicate-5.ibk3.sri2 +0 -0
- package/sample-store/gen-1/predicate-5.ibk3.sri2.merkle +0 -1
- package/sample-store/gen-1/predicate-5.ibk3.tli1 +0 -0
- package/sample-store/gen-1/predicate-5.ibk3.tli1.merkle +0 -1
- package/sample-store/gen-1/predicate-6.ibk3 +0 -0
- package/sample-store/gen-1/predicate-6.ibk3.merkle +0 -1
- package/sample-store/gen-1/predicate-6.ibk3.oli2 +0 -0
- package/sample-store/gen-1/predicate-6.ibk3.oli2.merkle +0 -1
- package/sample-store/gen-1/predicate-6.ibk3.sri2 +0 -0
- package/sample-store/gen-1/predicate-6.ibk3.sri2.merkle +0 -1
- package/sample-store/gen-1/predicate-6.ibk3.tli1 +0 -0
- package/sample-store/gen-1/predicate-6.ibk3.tli1.merkle +0 -0
- package/sample-store/gen-1/predicate-7.ibk3 +0 -0
- package/sample-store/gen-1/predicate-7.ibk3.merkle +0 -0
- package/sample-store/gen-1/predicate-7.ibk3.oli2 +0 -0
- package/sample-store/gen-1/predicate-7.ibk3.oli2.merkle +0 -2
- package/sample-store/gen-1/predicate-7.ibk3.sri2 +0 -0
- package/sample-store/gen-1/predicate-7.ibk3.sri2.merkle +0 -1
- package/sample-store/gen-1/predicate-7.ibk3.tli1 +0 -0
- package/sample-store/gen-1/predicate-7.ibk3.tli1.merkle +0 -1
- package/sample-store/gen-1/predicate-8.ibk3 +0 -0
- package/sample-store/gen-1/predicate-8.ibk3.merkle +0 -1
- package/sample-store/gen-1/predicate-8.ibk3.oli2 +0 -0
- package/sample-store/gen-1/predicate-8.ibk3.oli2.merkle +0 -1
- package/sample-store/gen-1/predicate-8.ibk3.sri2 +0 -0
- package/sample-store/gen-1/predicate-8.ibk3.sri2.merkle +0 -1
- package/sample-store/gen-1/predicate-8.ibk3.tli1 +0 -0
- package/sample-store/gen-1/predicate-8.ibk3.tli1.merkle +0 -1
- package/sample-store/gen-1/predicate-9.ibk3 +0 -0
- package/sample-store/gen-1/predicate-9.ibk3.merkle +0 -1
- package/sample-store/gen-1/predicate-9.ibk3.oli2 +0 -0
- package/sample-store/gen-1/predicate-9.ibk3.oli2.merkle +0 -1
- package/sample-store/gen-1/predicate-9.ibk3.sri2 +0 -0
- package/sample-store/gen-1/predicate-9.ibk3.sri2.merkle +0 -3
- package/sample-store/gen-1/predicate-9.ibk3.tli1 +0 -0
- package/sample-store/gen-1/predicate-9.ibk3.tli1.merkle +0 -2
- package/select.d.ts +0 -116
- package/select.js +0 -492
- package/version.json +0 -102
- package/wasm.d.ts +0 -130
- package/wasm.js +0 -158
package/index.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
// TypeScript declarations for factoidal.
|
|
1
|
+
// TypeScript declarations for @factoidal/core 0.9: one engine, the Lean 4
|
|
2
|
+
// library L4Factoidal compiled to WebAssembly (formal/lean4). Every
|
|
3
|
+
// function below is a dispatch op of that module (Wasm/Dispatch.lean)
|
|
4
|
+
// behind a typed wrapper (lib/api.mjs). The same declarations describe
|
|
5
|
+
// browser.js (browser.d.ts re-exports them).
|
|
2
6
|
//
|
|
3
7
|
// Self-contained: the RDF/JS interfaces below are structurally
|
|
4
8
|
// compatible with @rdfjs/types (same names and shapes) but declared
|
|
@@ -80,31 +84,156 @@ export interface DataFactory {
|
|
|
80
84
|
export const dataFactory: DataFactory;
|
|
81
85
|
|
|
82
86
|
/**
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
87
|
+
* A parse failure that carries a position (issue #344): `line`/
|
|
88
|
+
* `column`/`offset` are set when the failing engine call reported one
|
|
89
|
+
* (Turtle, TriG, N-Triples, N-Quads); `undefined` for an RDF/XML or
|
|
90
|
+
* JSON-LD failure, or any non-parse engine error, which stay a plain
|
|
91
|
+
* `Error`. `name` is `'ParseError'`.
|
|
92
|
+
*/
|
|
93
|
+
export class ParseError extends Error {
|
|
94
|
+
readonly name: 'ParseError';
|
|
95
|
+
/** 1-based line of the error. */
|
|
96
|
+
readonly line?: number;
|
|
97
|
+
/** 1-based column of the error, counted in Unicode scalar values. */
|
|
98
|
+
readonly column?: number;
|
|
99
|
+
/**
|
|
100
|
+
* The position of the error as a UTF-16 code-unit index into the input
|
|
101
|
+
* JavaScript string: `text.slice(err.offset)` starts at the error. A
|
|
102
|
+
* character outside the Basic Multilingual Plane (U+10000 and above)
|
|
103
|
+
* counts 2, as in every JavaScript string index. (The engine reports a
|
|
104
|
+
* count of Unicode scalar values; the wrapper converts.)
|
|
105
|
+
*/
|
|
106
|
+
readonly offset?: number;
|
|
107
|
+
readonly format?: string;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** One recoverable-parse diagnostic from a `{lenient:true}` parse() call. */
|
|
111
|
+
export interface ParseDiagnostic {
|
|
112
|
+
message: string;
|
|
113
|
+
/**
|
|
114
|
+
* The position of the error as a UTF-16 code-unit index into the input
|
|
115
|
+
* JavaScript string, as ParseError.offset: `text.slice(d.offset)` starts
|
|
116
|
+
* at the error.
|
|
117
|
+
*/
|
|
118
|
+
offset: number;
|
|
119
|
+
/** 1-based; a line ends at each LINE FEED (CR LF is one line end). */
|
|
120
|
+
line: number;
|
|
121
|
+
/** 1-based, counted in Unicode scalar values from the start of the line. */
|
|
122
|
+
column: number;
|
|
123
|
+
/**
|
|
124
|
+
* The stable error class (https://github.com/danbri/factoidal/issues/716):
|
|
125
|
+
* 'undefined-prefix', 'relative-iri', 'bad-iri', 'bad-escape',
|
|
126
|
+
* 'unterminated-string', 'bad-literal', 'bad-blank-node',
|
|
127
|
+
* 'bad-prefixed-name', 'bad-directive', 'bad-graph-name', 'rdf12-syntax',
|
|
128
|
+
* 'unclosed-group', 'nesting-limit', 'unexpected-token', 'internal' or
|
|
129
|
+
* 'too-many-errors'.
|
|
130
|
+
*/
|
|
131
|
+
class: string;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/** Every options key of Dataset.serialize(), serialize() and toString(). */
|
|
135
|
+
export interface WriteOptions {
|
|
136
|
+
/**
|
|
137
|
+
* 'nquads' (default; sorted line order), 'ntriples' (refused when the
|
|
138
|
+
* dataset has a named graph), 'turtle', 'trig', 'rdfxml', 'jsonld'
|
|
139
|
+
* (expanded JSON-LD 1.1), 'rdfc' (RDFC-1.0 canonical N-Quads). Turtle and
|
|
140
|
+
* RDF/XML write the named graphs as one graph. `formats()` lists what
|
|
141
|
+
* each writer supports.
|
|
142
|
+
*/
|
|
143
|
+
format?: WriteFormat;
|
|
144
|
+
/** '1.1' refuses a dataset with an RDF 1.2 term; '1.2' (default) writes it. */
|
|
145
|
+
version?: '1.1' | '1.2';
|
|
146
|
+
/** 'turtle' only: prefix label -> namespace IRI, merged over `dataset.prefixes`. */
|
|
147
|
+
prefixes?: Record<string, string>;
|
|
148
|
+
/** 'turtle' only. Default true: integers, decimals, doubles and booleans print bare. */
|
|
149
|
+
literalShorthand?: boolean;
|
|
150
|
+
/** 'jsonld' only (JSON-LD 1.1 API section 8). */
|
|
151
|
+
useNativeTypes?: boolean;
|
|
152
|
+
/** 'jsonld' only. */
|
|
153
|
+
useRdfType?: boolean;
|
|
154
|
+
/** 'jsonld' only. */
|
|
155
|
+
rdfDirection?: string;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export type WriteFormat =
|
|
159
|
+
| 'nquads' | 'nq' | 'ntriples' | 'nt' | 'turtle' | 'ttl' | 'trig'
|
|
160
|
+
| 'rdfxml' | 'rdf-xml' | 'rdf' | 'jsonld' | 'json-ld' | 'rdfc' | 'canonical';
|
|
161
|
+
|
|
162
|
+
/** Results formats of query() with `output`. */
|
|
163
|
+
export type ResultsFormat = 'json' | 'xml' | 'csv' | 'tsv' | 'table' | 'ntriples';
|
|
164
|
+
|
|
165
|
+
/** One row of formats(). */
|
|
166
|
+
export interface FormatCapability {
|
|
167
|
+
name: string;
|
|
168
|
+
read11: boolean;
|
|
169
|
+
read12: boolean;
|
|
170
|
+
write11: boolean;
|
|
171
|
+
write12: boolean;
|
|
172
|
+
/** 'core' when both engines serve it; 'full' when only the full engine does. */
|
|
173
|
+
engine: 'core' | 'full';
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* An RDF dataset held inside the engine (https://github.com/danbri/factoidal/issues/882).
|
|
178
|
+
* Every producer (parse, csvwToRdf, rmlMap, jsonldToRdf, the closures,
|
|
179
|
+
* rifEval, CONSTRUCT) answers one; every consumer accepts one. The data
|
|
180
|
+
* stays in the wasm memory: a method sends the handle id, not the data.
|
|
181
|
+
* Release it with dispose() or `using`; a Dataset collected without
|
|
182
|
+
* dispose() is released by a FinalizationRegistry. A method of a disposed
|
|
183
|
+
* Dataset throws a TypeError.
|
|
86
184
|
*/
|
|
87
185
|
export class Dataset implements Iterable<Quad> {
|
|
88
|
-
constructor(
|
|
186
|
+
private constructor();
|
|
187
|
+
/** The engine's handle id (opaque). */
|
|
188
|
+
readonly handle: string;
|
|
189
|
+
/** Number of quads. */
|
|
89
190
|
readonly size: number;
|
|
191
|
+
/** Prefixes the source document declared (label -> namespace IRI). */
|
|
192
|
+
readonly prefixes: Record<string, string>;
|
|
193
|
+
/** Diagnostics of a `{lenient:true}` parse; else empty. */
|
|
194
|
+
readonly diagnostics: ParseDiagnostic[];
|
|
195
|
+
/** The parse format tag, when the data was read from text. */
|
|
196
|
+
readonly format: string | undefined;
|
|
197
|
+
/** True when `format` was inferred because the caller gave none. */
|
|
198
|
+
readonly formatInferred: boolean;
|
|
199
|
+
/** True after dispose(). */
|
|
200
|
+
readonly disposed: boolean;
|
|
201
|
+
/** Members the producing op reported: `rounds` (rho-df, RDFS-Plus closures); `inputCount`, `derivedCount`, `fuel` (rifEval). */
|
|
202
|
+
readonly info: Record<string, unknown>;
|
|
203
|
+
query(sparql: string, options?: DatasetQueryOptions): Promise<Bindings[] | boolean | Dataset | string | object>;
|
|
204
|
+
/** SPARQL 1.1 Update in place; answers this Dataset. */
|
|
205
|
+
update(updateText: string, options?: Record<string, never>): Promise<this>;
|
|
206
|
+
validateShacl(shapes: DataInput, options?: { format?: DataFormat; baseIRI?: string }): Promise<ShaclValidateResult>;
|
|
207
|
+
validateShex(schema: string, options: { focus: string | NamedNode | BlankNode; shape?: string | NamedNode | BlankNode | null }): Promise<boolean>;
|
|
208
|
+
closure(regime: ClosureRegime): Promise<Dataset>;
|
|
209
|
+
canonicalize(): Promise<string>;
|
|
210
|
+
serialize(options?: WriteOptions): Promise<string>;
|
|
211
|
+
toString(formatOrOptions?: WriteFormat | WriteOptions): string;
|
|
212
|
+
toNQuads(): string;
|
|
213
|
+
clone(): Dataset;
|
|
214
|
+
/** RDF/JS DatasetCore (https://rdf.js.org/dataset-spec/); match and has use the engine indexes. */
|
|
215
|
+
has(quad: Quad): boolean;
|
|
90
216
|
add(quad: Quad): this;
|
|
91
217
|
delete(quad: Quad): this;
|
|
92
|
-
|
|
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>;
|
|
218
|
+
match(subject?: Term | null, predicate?: Term | null, object?: Term | null, graph?: Term | null): Dataset;
|
|
100
219
|
toArray(): Quad[];
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
220
|
+
[Symbol.iterator](): Iterator<Quad>;
|
|
221
|
+
dispose(): void;
|
|
222
|
+
[Symbol.dispose](): void;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** @deprecated The name of Dataset before 0.10.0; removed in 0.11.0. */
|
|
226
|
+
export const DatasetHandle: typeof Dataset;
|
|
227
|
+
|
|
228
|
+
export type ClosureRegime = 'rdfs' | 'owl-rl' | 'rho-df' | 'rdfs-plus';
|
|
229
|
+
|
|
230
|
+
export interface DatasetQueryOptions {
|
|
231
|
+
sparql12?: boolean;
|
|
232
|
+
version?: '1.1' | '1.2';
|
|
233
|
+
/** Close the default graph under a regime before the query. */
|
|
234
|
+
entail?: EntailRegime;
|
|
235
|
+
/** Answer the results document in this format (text; 'json' parsed). */
|
|
236
|
+
output?: ResultsFormat;
|
|
108
237
|
}
|
|
109
238
|
|
|
110
239
|
// ---------------------------------------------------------------------
|
|
@@ -118,7 +247,14 @@ export type DataFormat =
|
|
|
118
247
|
| 'nquads' | 'nq'
|
|
119
248
|
| 'trig'
|
|
120
249
|
| 'rdfxml' | 'rdf-xml' | 'rdf'
|
|
121
|
-
| 'jsonld' | 'json-ld'
|
|
250
|
+
| 'jsonld' | 'json-ld'
|
|
251
|
+
// RDF 1.2 parsers (triple terms, reifiers, annotations, VERSION,
|
|
252
|
+
// directional language tags). The names above parse RDF 1.1 and reject
|
|
253
|
+
// RDF 1.2 syntax with "requires RDF 1.2 mode".
|
|
254
|
+
| 'turtle12' | 'ttl12'
|
|
255
|
+
| 'ntriples12' | 'nt12'
|
|
256
|
+
| 'nquads12' | 'nq12'
|
|
257
|
+
| 'trig12';
|
|
122
258
|
|
|
123
259
|
/** Entailment regime applied to the data before evaluation. */
|
|
124
260
|
/**
|
|
@@ -133,52 +269,89 @@ export type EntailRegime = 'none' | 'RDFS' | 'OWL-RL' | 'x-rdfscore' | 'x-rdfspl
|
|
|
133
269
|
|
|
134
270
|
/**
|
|
135
271
|
* One SELECT solution: a Map from variable name (no leading '?') to
|
|
136
|
-
* the bound RDF/JS term. Unbound variables are absent from the Map.
|
|
272
|
+
* the bound RDF/JS term. Unbound variables are absent from the Map. The
|
|
273
|
+
* Map iterates in the order of the SELECT clause (the `head.vars` of the
|
|
274
|
+
* SPARQL 1.1 Query Results JSON Format, section 3.1).
|
|
137
275
|
*/
|
|
138
276
|
export type Bindings = Map<string, Term>;
|
|
139
277
|
|
|
140
|
-
/**
|
|
278
|
+
/**
|
|
279
|
+
* Input data: a Dataset, a document string, or several of either. Text
|
|
280
|
+
* is read in `options.format`; with no format the engine infers one and
|
|
281
|
+
* the error (or `dataset.format`) reports it.
|
|
282
|
+
*/
|
|
141
283
|
export type DataInput =
|
|
142
284
|
| Dataset
|
|
143
285
|
| string
|
|
144
|
-
| { text: string; format?: DataFormat }
|
|
145
|
-
| Array<Dataset | string | { text: string; format?: DataFormat }>;
|
|
286
|
+
| { text: string; format?: DataFormat; baseIRI?: string }
|
|
287
|
+
| Array<Dataset | string | { text: string; format?: DataFormat; baseIRI?: string }>;
|
|
288
|
+
|
|
289
|
+
/** Same as DataInput (kept for 0.9 type imports). */
|
|
290
|
+
export type QueryInput = DataInput;
|
|
146
291
|
|
|
147
292
|
export interface ParseOptions {
|
|
148
|
-
/**
|
|
293
|
+
/** Omitted: inferred by the engine (op detectFormat), reported in `dataset.format`. */
|
|
149
294
|
format?: DataFormat;
|
|
150
295
|
/** Base IRI for resolving relative IRIs (Turtle/TriG/RDF-XML). */
|
|
151
296
|
baseIRI?: string;
|
|
297
|
+
/**
|
|
298
|
+
* Recover instead of rejecting on the first syntax error
|
|
299
|
+
* (https://github.com/danbri/factoidal/issues/716, engine op
|
|
300
|
+
* `parseDocument`): Turtle, TriG, N-Triples and N-Quads skip each bad
|
|
301
|
+
* statement and keep every good one; `dataset.diagnostics` has one
|
|
302
|
+
* entry per skipped statement. RDF/XML and JSON-LD parse strictly. A
|
|
303
|
+
* document with no error gives the strict result and no diagnostics.
|
|
304
|
+
* Default: false (strict; a syntax error, an undeclared prefix, or an
|
|
305
|
+
* unresolvable relative IRI rejects the whole parse with a ParseError).
|
|
306
|
+
*/
|
|
307
|
+
lenient?: boolean;
|
|
308
|
+
/**
|
|
309
|
+
* With `lenient`: stop after this many diagnostics; the parse then ends
|
|
310
|
+
* with one diagnostic of class 'too-many-errors'. Default: no limit.
|
|
311
|
+
*/
|
|
312
|
+
maxErrors?: number;
|
|
152
313
|
}
|
|
153
314
|
|
|
154
|
-
export interface QueryOptions {
|
|
155
|
-
/** Format tag for string data inputs
|
|
315
|
+
export interface QueryOptions extends DatasetQueryOptions {
|
|
316
|
+
/** Format tag for string data inputs; omitted: inferred. */
|
|
156
317
|
format?: DataFormat;
|
|
157
|
-
|
|
158
|
-
entail?: EntailRegime;
|
|
318
|
+
baseIRI?: string;
|
|
159
319
|
}
|
|
160
320
|
|
|
161
|
-
/**
|
|
162
|
-
|
|
321
|
+
/**
|
|
322
|
+
* Parse one RDF document into a Dataset. The returned Dataset's quad
|
|
323
|
+
* order is sorted (canonical N-Quads order), not document order;
|
|
324
|
+
* anonymous blank-node labels (`_anonN`) DO reflect document order.
|
|
325
|
+
* See README.md's "Blank nodes, labels and statement order". Strict
|
|
326
|
+
* by default (issue #344): a syntax error rejects with a ParseError
|
|
327
|
+
* (`line`/`column`/`offset` for Turtle/TriG/N-Triples/N-Quads; a
|
|
328
|
+
* message only for RDF/XML and JSON-LD). `options.lenient` recovers
|
|
329
|
+
* instead; see ParseOptions.
|
|
330
|
+
*/
|
|
331
|
+
export function parse(text: string, options?: ParseOptions | DataFormat): Promise<Dataset>;
|
|
163
332
|
|
|
164
333
|
/**
|
|
165
|
-
* Run a SPARQL 1.1 query.
|
|
334
|
+
* Run a SPARQL 1.1 query (or 1.2, with `sparql12`).
|
|
166
335
|
* SELECT resolves to Bindings[]; ASK resolves to a boolean;
|
|
167
|
-
* CONSTRUCT
|
|
168
|
-
*
|
|
169
|
-
*
|
|
336
|
+
* CONSTRUCT and DESCRIBE resolve to a Dataset (DESCRIBE answers the
|
|
337
|
+
* Concise Bounded Description of each resource named). A `SERVICE <iri>`
|
|
338
|
+
* whose IRI no registerServiceEndpoint() call named answers no
|
|
339
|
+
* solutions even without SILENT
|
|
340
|
+
* (https://github.com/danbri/factoidal/issues/717). `data` may be a DatasetHandle
|
|
341
|
+
* from openDataset(), in which case this routes to `data.query()` and
|
|
342
|
+
* `options.entail` must be 'none' or omitted (a handle carries no
|
|
343
|
+
* entailment-closure step).
|
|
170
344
|
*/
|
|
171
345
|
export function query(
|
|
172
|
-
data:
|
|
346
|
+
data: QueryInput,
|
|
173
347
|
sparql: string,
|
|
174
|
-
options?: QueryOptions
|
|
175
|
-
): Promise<Bindings[] | boolean | Dataset>;
|
|
348
|
+
options?: QueryOptions | DataFormat
|
|
349
|
+
): Promise<Bindings[] | boolean | Dataset | string | object>;
|
|
176
350
|
|
|
177
351
|
/**
|
|
178
352
|
* Run a SPARQL 1.1 query against a read-only HDT (Header-Dictionary-
|
|
179
|
-
* Triples)
|
|
180
|
-
*
|
|
181
|
-
* graph only, SELECT/ASK only (no CONSTRUCT, no named graphs).
|
|
353
|
+
* Triples) file's raw bytes (op queryHdt; the bytes cross into the
|
|
354
|
+
* engine with no encoding). Default graph only, SELECT/ASK only.
|
|
182
355
|
* @param hdtBytes whole .hdt file contents
|
|
183
356
|
*/
|
|
184
357
|
export function queryHdt(
|
|
@@ -230,48 +403,56 @@ export function clearExtensionFunctions(): Promise<void>;
|
|
|
230
403
|
export function registerServiceEndpoint(
|
|
231
404
|
iri: string,
|
|
232
405
|
data: DataInput,
|
|
233
|
-
options?: { format?: DataFormat }
|
|
406
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
234
407
|
): Promise<{ ok: true; count: number }>;
|
|
235
408
|
|
|
236
409
|
/** Remove every registered SERVICE endpoint snapshot. */
|
|
237
410
|
export function clearServiceEndpoints(): Promise<void>;
|
|
238
411
|
|
|
239
|
-
/**
|
|
240
|
-
* Apply a SPARQL 1.1 Update, returning the updated Dataset.
|
|
241
|
-
* Needs the npm-entry engine bundle.
|
|
242
|
-
*/
|
|
412
|
+
/** Apply a SPARQL 1.1 Update and answer a NEW Dataset; a Dataset argument is unchanged. */
|
|
243
413
|
export function update(
|
|
244
414
|
data: DataInput,
|
|
245
415
|
updateText: string,
|
|
246
|
-
options?: { format?: DataFormat }
|
|
416
|
+
options?: { format?: DataFormat; baseIRI?: string } | DataFormat
|
|
247
417
|
): Promise<Dataset>;
|
|
248
418
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
419
|
+
/** Open `data` as a Dataset (a Dataset argument is cloned). */
|
|
420
|
+
export function openDataset(
|
|
421
|
+
data: DataInput,
|
|
422
|
+
options?: { format?: DataFormat; baseIRI?: string } | DataFormat
|
|
423
|
+
): Promise<Dataset>;
|
|
424
|
+
|
|
425
|
+
/** Closure of the default graph under `regime`, as a new Dataset. */
|
|
426
|
+
export function closure(
|
|
427
|
+
data: DataInput,
|
|
428
|
+
regime: ClosureRegime,
|
|
429
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
430
|
+
): Promise<Dataset>;
|
|
431
|
+
|
|
432
|
+
/** The syntaxes the engine reads and writes, from the engine (op datasetFormats). */
|
|
433
|
+
export function formats(): Promise<FormatCapability[]>;
|
|
434
|
+
|
|
435
|
+
export interface SerializeOptions extends WriteOptions {
|
|
436
|
+
/** Format of string `data`; omitted: inferred. */
|
|
258
437
|
inputFormat?: DataFormat;
|
|
438
|
+
baseIRI?: string;
|
|
259
439
|
}
|
|
260
440
|
|
|
261
|
-
/**
|
|
441
|
+
/** Write a dataset in a concrete syntax (see WriteOptions). */
|
|
262
442
|
export function serialize(
|
|
263
443
|
data: DataInput,
|
|
264
|
-
options?: SerializeOptions
|
|
444
|
+
options?: SerializeOptions | WriteFormat
|
|
265
445
|
): Promise<string>;
|
|
266
446
|
|
|
267
447
|
/**
|
|
268
448
|
* RDFC-1.0 dataset canonicalization: canonical blank-node labels plus
|
|
269
449
|
* sorted canonical N-Quads. Two isomorphic inputs canonicalize to the
|
|
270
|
-
* same string.
|
|
450
|
+
* same string. `data` may be a DatasetHandle, in which case this
|
|
451
|
+
* routes to `data.canonicalize()` (options are ignored for a handle).
|
|
271
452
|
*/
|
|
272
453
|
export function canonicalize(
|
|
273
454
|
data: DataInput,
|
|
274
|
-
options?: { format?: DataFormat }
|
|
455
|
+
options?: { format?: DataFormat; baseIRI?: string } | DataFormat
|
|
275
456
|
): Promise<string>;
|
|
276
457
|
|
|
277
458
|
/**
|
|
@@ -281,42 +462,67 @@ export function canonicalize(
|
|
|
281
462
|
* `graph` is the same Dataset filtered to that one graph name (what
|
|
282
463
|
* `dataset.match(null, null, null, graphTerm)` would return).
|
|
283
464
|
*/
|
|
284
|
-
export function graphs(dataset: Dataset): Array<[
|
|
465
|
+
export function graphs(dataset: Dataset): Array<[name: NamedNode | BlankNode, graph: Dataset]>;
|
|
285
466
|
|
|
286
467
|
/**
|
|
287
|
-
* RDFC-1.0 canonical
|
|
288
|
-
* sibling of canonicalize().
|
|
468
|
+
* RDFC-1.0 canonical form of a single graph -- the graph-scoped
|
|
469
|
+
* sibling of canonicalize(). It returns the canonical N-Quads TEXT, not
|
|
470
|
+
* a digest: hash the string yourself (for example `vcSha256Hex`) when a
|
|
471
|
+
* fixed-length value is needed. Every quad's graph component is dropped
|
|
289
472
|
* before canonicalizing, so isomorphic graphs (including under
|
|
290
|
-
* blank-node relabeling)
|
|
473
|
+
* blank-node relabeling) give the same string regardless of what
|
|
291
474
|
* graph name they were extracted from. Typically called with one
|
|
292
475
|
* entry of graphs()'s output.
|
|
293
476
|
*/
|
|
294
477
|
export function canonicalHash(datasetOrGraph: Dataset): Promise<string>;
|
|
295
478
|
|
|
479
|
+
/**
|
|
480
|
+
* Whether two datasets are isomorphic (RDF 1.1 Concepts 3.6 and 4; blank
|
|
481
|
+
* nodes inside RDF 1.2 triple terms included). The engine decides
|
|
482
|
+
* (op datasetIsomorphic); rejects when its blank-node search budget is
|
|
483
|
+
* exceeded.
|
|
484
|
+
*/
|
|
485
|
+
export function isomorphic(a: DataInput, b: DataInput, options?: { format?: string; baseIRI?: string }): Promise<boolean>;
|
|
486
|
+
|
|
487
|
+
/** A Dataset holding RDF/JS quads; each term is sent to the engine as its components. */
|
|
488
|
+
export function fromQuads(quads: Iterable<Quad>): Promise<Dataset>;
|
|
489
|
+
|
|
490
|
+
/** Load the engine. Afterwards the N-Quads text functions of `@factoidal/core/rdfjs` work. */
|
|
491
|
+
export function ready(): Promise<void>;
|
|
492
|
+
|
|
493
|
+
/** The engine's name tables: format names, entailment regimes, query outputs, pack syntaxes. */
|
|
494
|
+
export function engineTables(): Promise<Record<string, unknown>>;
|
|
495
|
+
|
|
296
496
|
/** A SHACL validation-report term (see shaclValidate). */
|
|
297
497
|
export interface ShaclValidateResult {
|
|
298
498
|
conforms: boolean;
|
|
299
|
-
/**
|
|
499
|
+
/** The validation report graph: one sh:ValidationReport with
|
|
500
|
+
* sh:conforms, and one sh:result per validation result. */
|
|
300
501
|
report: Dataset;
|
|
301
502
|
}
|
|
302
503
|
|
|
303
504
|
/**
|
|
304
|
-
* SHACL
|
|
505
|
+
* SHACL validation (SHACL Core, SHACL-SPARQL constraints, SHACL 1.2 node
|
|
506
|
+
* expressions) of the data graph's default graph. A shapes graph that
|
|
507
|
+
* uses the SPARQL-based target of SHACL-AF, and a validation failure in
|
|
508
|
+
* the sense of SHACL 5.3.2, reject.
|
|
305
509
|
* @param data the data graph
|
|
306
510
|
* @param shapes the shapes graph
|
|
307
511
|
*/
|
|
308
512
|
export function shaclValidate(
|
|
309
513
|
data: DataInput,
|
|
310
514
|
shapes: DataInput,
|
|
311
|
-
options?: { format?: DataFormat }
|
|
515
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
312
516
|
): Promise<ShaclValidateResult>;
|
|
313
517
|
|
|
314
518
|
/**
|
|
315
519
|
* ShEx (Shape Expressions) validation of one focus node against one
|
|
316
|
-
* shape
|
|
317
|
-
*
|
|
318
|
-
* answer.
|
|
319
|
-
*
|
|
520
|
+
* shape, over the default graph of `data`. The Lean validator decides
|
|
521
|
+
* every schema it reads, so the answer is a boolean (the type keeps
|
|
522
|
+
* `null`, which an engine that defers a schema would answer). An
|
|
523
|
+
* `IMPORT` in the schema is not followed.
|
|
524
|
+
* @param schemaJson the schema as text: ShExJ when its first
|
|
525
|
+
* non-whitespace character is '{', ShExC otherwise
|
|
320
526
|
* @param focus an IRI, "_:label", or an RDF/JS NamedNode/BlankNode term
|
|
321
527
|
* @param shape a shape label (same shapes as focus); omit/null for the
|
|
322
528
|
* schema's own `start`
|
|
@@ -326,18 +532,17 @@ export function shexValidate(
|
|
|
326
532
|
schemaJson: string,
|
|
327
533
|
focus: string | NamedNode | BlankNode,
|
|
328
534
|
shape?: string | NamedNode | BlankNode | null,
|
|
329
|
-
options?: { format?: DataFormat }
|
|
535
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
330
536
|
): Promise<boolean | null>;
|
|
331
537
|
|
|
332
538
|
/**
|
|
333
539
|
* RDFS or OWL-RL entailment closure, materialized as a new Dataset
|
|
334
|
-
* (input triples + derived triples).
|
|
335
|
-
* bundle. Default graph only.
|
|
540
|
+
* (input triples + derived triples). Default graph only.
|
|
336
541
|
*/
|
|
337
542
|
export function owlClosure(
|
|
338
543
|
data: DataInput,
|
|
339
544
|
mode: 'RDFS' | 'OWL-RL',
|
|
340
|
-
options?: { format?: DataFormat }
|
|
545
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
341
546
|
): Promise<Dataset>;
|
|
342
547
|
|
|
343
548
|
/**
|
|
@@ -346,7 +551,7 @@ export function owlClosure(
|
|
|
346
551
|
* `rho_df_closure`): rdfs2/3/5/7/9/11 only, with the machine-checked
|
|
347
552
|
* decides-iff — on fragment inputs the result's simple query answers
|
|
348
553
|
* are exactly the entailed consequences (see
|
|
349
|
-
* docs/theorem-registry.md). Returns
|
|
554
|
+
* docs/theorem-registry.md). Returns the closure as a new Dataset.
|
|
350
555
|
* "corerdfs" is this project's API name for the fragment the
|
|
351
556
|
* literature calls ρdf (subPropertyOf/subClassOf/type/domain/range —
|
|
352
557
|
* Muñoz, Pérez & Gutierrez, "Simple and Efficient Minimal RDFS",
|
|
@@ -354,29 +559,28 @@ export function owlClosure(
|
|
|
354
559
|
*/
|
|
355
560
|
export function coreRdfsClosure(
|
|
356
561
|
data: DataInput,
|
|
357
|
-
options?: { format?: DataFormat }
|
|
358
|
-
): Promise<
|
|
562
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
563
|
+
): Promise<Dataset>;
|
|
359
564
|
|
|
360
565
|
/**
|
|
361
|
-
* Decidable core-RDFS fragment check (`
|
|
362
|
-
*
|
|
363
|
-
* the certified path's guarantee apply to this data?
|
|
566
|
+
* Decidable core-RDFS fragment check (L4Factoidal/RDFS, `isRhoDfFrag`):
|
|
567
|
+
* is the data in the core-RDFS fragment coreRdfsClosure is defined for?
|
|
364
568
|
*/
|
|
365
569
|
export function coreRdfsCheck(
|
|
366
570
|
data: DataInput,
|
|
367
|
-
options?: { format?: DataFormat }
|
|
571
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
368
572
|
): Promise<{ ok: boolean; fragment: boolean }>;
|
|
369
573
|
|
|
370
574
|
/** Literature-name alias for coreRdfsClosure (ρdf). */
|
|
371
575
|
export function rhoDfClosure(
|
|
372
576
|
data: DataInput,
|
|
373
|
-
options?: { format?: DataFormat }
|
|
374
|
-
): Promise<
|
|
577
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
578
|
+
): Promise<Dataset>;
|
|
375
579
|
|
|
376
580
|
/** Literature-name alias for coreRdfsCheck (ρdf). */
|
|
377
581
|
export function rhoDfFragmentCheck(
|
|
378
582
|
data: DataInput,
|
|
379
|
-
options?: { format?: DataFormat }
|
|
583
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
380
584
|
): Promise<{ ok: boolean; fragment: boolean }>;
|
|
381
585
|
|
|
382
586
|
/**
|
|
@@ -389,41 +593,39 @@ export function rhoDfFragmentCheck(
|
|
|
389
593
|
*/
|
|
390
594
|
export function rdfsPlusClosure(
|
|
391
595
|
data: DataInput,
|
|
392
|
-
options?: { format?: DataFormat }
|
|
393
|
-
): Promise<
|
|
596
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
597
|
+
): Promise<Dataset>;
|
|
394
598
|
|
|
395
599
|
/**
|
|
396
|
-
* OWL tableau materialisation (
|
|
397
|
-
* `
|
|
600
|
+
* OWL tableau materialisation (L4Factoidal/OWL/Materialise.lean,
|
|
601
|
+
* `materialiseWithBudget`): add `i rdf:type <ClassExpression>` for every
|
|
398
602
|
* individual the model-construction reasoner proves is a member of an
|
|
399
603
|
* OWL class expression (someValuesFrom / hasValue / unionOf /
|
|
400
604
|
* intersectionOf, and the named class an equivalentClass restriction
|
|
401
|
-
* defines).
|
|
605
|
+
* defines). Default graph only.
|
|
402
606
|
* `dataset` is input + tableau-derived triples; `addedCount` is how
|
|
403
|
-
* many triples the tableau added
|
|
607
|
+
* many triples the tableau added; `budgetHit` is true when the work
|
|
608
|
+
* budget ran out, so an absent membership is then a cap, not a proof.
|
|
404
609
|
*/
|
|
405
610
|
export function tableauMaterialise(
|
|
406
611
|
data: DataInput,
|
|
407
|
-
options?: { format?: DataFormat }
|
|
408
|
-
): Promise<{ dataset: Dataset; addedCount: number }>;
|
|
612
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
613
|
+
): Promise<{ dataset: Dataset; addedCount: number; budgetHit?: boolean }>;
|
|
409
614
|
|
|
410
615
|
/**
|
|
411
|
-
* OWL DL inconsistency verdict
|
|
412
|
-
*
|
|
616
|
+
* OWL DL inconsistency verdict: OWL RL closure, one class-expression
|
|
617
|
+
* materialisation pass, OWL RL closure again, then the clash decision.
|
|
413
618
|
* `rlAlone` is the plain OWL-RL verdict on the same input, so a caller
|
|
414
|
-
* can see the cases the tableau adds.
|
|
415
|
-
* bundle. Default graph only.
|
|
619
|
+
* can see the cases the tableau adds. Default graph only.
|
|
416
620
|
*/
|
|
417
621
|
export function tableauDlInconsistent(
|
|
418
622
|
data: DataInput,
|
|
419
|
-
options?: { format?: DataFormat }
|
|
623
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
420
624
|
): Promise<{ inconsistent: boolean; rlAlone: boolean }>;
|
|
421
625
|
|
|
422
626
|
/**
|
|
423
|
-
* OWL DL consistency verdict via the
|
|
424
|
-
* (
|
|
425
|
-
* pure verified chain bin/owl-runner runs under `--regime dl`, minus
|
|
426
|
-
* its native-only z3 oracle). Needs the npm-entry engine bundle.
|
|
627
|
+
* OWL DL consistency verdict via the clash-detecting tableau
|
|
628
|
+
* (L4Factoidal/OWL/Refute.lean) over the OWL RL closure.
|
|
427
629
|
* Default graph only. `consistent` is three-valued: `false` (a clash on
|
|
428
630
|
* every branch), `true` (a model built), or `null` -- a budget-out, with
|
|
429
631
|
* `reason` naming the fuel cap (never a silent false).
|
|
@@ -434,11 +636,9 @@ export function owlIsConsistent(
|
|
|
434
636
|
): Promise<{ consistent: boolean | null; reason?: string }>;
|
|
435
637
|
|
|
436
638
|
/**
|
|
437
|
-
* OWL entailment check: does `premise` entail `conclusion`?
|
|
438
|
-
* two-path dispatch: `via: "closure"` (the conclusion is in the OWL-RL
|
|
639
|
+
* OWL entailment check: does `premise` entail `conclusion`? Two paths: `via: "closure"` (the conclusion is in the OWL-RL
|
|
439
640
|
* closure of the premise) or `via: "refutation"` (the negated
|
|
440
|
-
* conclusion is refuted on every goal).
|
|
441
|
-
* bundle. Default graph only. `entailed` is `true`, `false`, or `null`
|
|
641
|
+
* conclusion is refuted on every goal). Default graph only. `entailed` is `true`, `false`, or `null`
|
|
442
642
|
* (a refutation budget-out, with `reason` naming the cap).
|
|
443
643
|
*/
|
|
444
644
|
export function owlEntails(
|
|
@@ -449,8 +649,7 @@ export function owlEntails(
|
|
|
449
649
|
|
|
450
650
|
/**
|
|
451
651
|
* Evaluate an RML mapping graph against one logical source's raw data,
|
|
452
|
-
* returning the generated triples as a Dataset.
|
|
453
|
-
* engine bundle. Every triples map in `mapping` reads the SAME
|
|
652
|
+
* returning the generated triples as a Dataset. Every triples map in `mapping` reads the SAME
|
|
454
653
|
* `sourceData` -- joins across two different logical sources are out
|
|
455
654
|
* of scope for this entry point.
|
|
456
655
|
* @param mapping the RML mapping graph (Turtle by default)
|
|
@@ -460,7 +659,7 @@ export function rmlMap(
|
|
|
460
659
|
mapping: DataInput,
|
|
461
660
|
sourceData: string,
|
|
462
661
|
sourceKind: 'json' | 'csv',
|
|
463
|
-
options?: { format?: DataFormat }
|
|
662
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
464
663
|
): Promise<Dataset>;
|
|
465
664
|
|
|
466
665
|
export interface CsvwOptions {
|
|
@@ -480,7 +679,7 @@ export interface CsvwOptions {
|
|
|
480
679
|
* CSVW csv2rdf conversion (w3.org/TR/csv2rdf): convert raw tabular
|
|
481
680
|
* data plus an optional CSVW metadata document (JSON text -- '' or
|
|
482
681
|
* omitted infers the schema from the CSV's own header row) into a
|
|
483
|
-
* Dataset.
|
|
682
|
+
* Dataset. Every table in a
|
|
484
683
|
* multi-table `tables` group reads the SAME `csvText`.
|
|
485
684
|
*/
|
|
486
685
|
export function csvwToRdf(
|
|
@@ -498,9 +697,9 @@ export interface JsonLdOptions {
|
|
|
498
697
|
|
|
499
698
|
/**
|
|
500
699
|
* Parse a JSON-LD document into a Dataset, with JSON-LD-specific
|
|
501
|
-
* options `parse()` has no room for
|
|
502
|
-
*
|
|
503
|
-
*
|
|
700
|
+
* options `parse()` has no room for (plain `parse(text,
|
|
701
|
+
* {format:'jsonld'})` also works for the common case). A remote
|
|
702
|
+
* `@context` is not fetched.
|
|
504
703
|
*/
|
|
505
704
|
export function jsonldToRdf(
|
|
506
705
|
jsonldText: string,
|
|
@@ -516,8 +715,7 @@ export interface JsonLdFromRdfOptions {
|
|
|
516
715
|
/**
|
|
517
716
|
* Serialize an RDF dataset as an expanded-form JSON-LD document -- the
|
|
518
717
|
* reverse of jsonldToRdf (the verified JSONLD.FromRdf.from_rdf).
|
|
519
|
-
* Returns the parsed JSON-LD value (an array of node objects).
|
|
520
|
-
* the npm-entry engine bundle.
|
|
718
|
+
* Returns the parsed JSON-LD value (an array of node objects).
|
|
521
719
|
*/
|
|
522
720
|
export function jsonldFromRdf(
|
|
523
721
|
data: DataInput,
|
|
@@ -527,14 +725,14 @@ export function jsonldFromRdf(
|
|
|
527
725
|
/**
|
|
528
726
|
* did:key resolution: resolve a `did:key:z6Mk...` (Ed25519) to its DID
|
|
529
727
|
* Document, returned as a Dataset (the verified DID_Key.did_key_document).
|
|
530
|
-
*
|
|
728
|
+
*
|
|
531
729
|
*/
|
|
532
730
|
export function didKeyResolve(didString: string): Promise<Dataset>;
|
|
533
731
|
|
|
534
732
|
/**
|
|
535
|
-
* Test whether an XML document is well-formed (
|
|
536
|
-
*
|
|
537
|
-
*
|
|
733
|
+
* Test whether an XML document is well-formed (XML 1.0). A DOCTYPE with
|
|
734
|
+
* an internal subset is read (XML 1.0 section 2.8); an external DTD is
|
|
735
|
+
* not fetched.
|
|
538
736
|
*/
|
|
539
737
|
export function xmlWellformed(xmlText: string): Promise<boolean>;
|
|
540
738
|
|
|
@@ -543,13 +741,16 @@ export interface XPathResult {
|
|
|
543
741
|
resultType: 'nodeset' | 'string' | 'number' | 'boolean';
|
|
544
742
|
count?: number;
|
|
545
743
|
stringValue?: string;
|
|
744
|
+
/** `kind` includes 'root' and 'namespace' as well as 'element',
|
|
745
|
+
* 'attribute', 'text', 'comment' and 'processing-instruction'. */
|
|
546
746
|
nodes?: Array<{ kind: string; name: string; value: string }>;
|
|
547
747
|
value?: string | number | boolean;
|
|
548
748
|
}
|
|
549
749
|
|
|
550
750
|
/**
|
|
551
|
-
* Evaluate an XPath 1.0 expression over an XML document
|
|
552
|
-
*
|
|
751
|
+
* Evaluate an XPath 1.0 expression over an XML document (the full
|
|
752
|
+
* XPath 1.0 function library). A number result is its XPath string form
|
|
753
|
+
* when it is not finite ('Infinity', 'NaN').
|
|
553
754
|
*/
|
|
554
755
|
export function xpathEval(
|
|
555
756
|
xmlText: string,
|
|
@@ -558,53 +759,228 @@ export function xpathEval(
|
|
|
558
759
|
|
|
559
760
|
/**
|
|
560
761
|
* RIF Core forward-chaining saturation, materialized as a new Dataset
|
|
561
|
-
* (input triples + derived triples, default graph only).
|
|
562
|
-
* npm-entry engine bundle.
|
|
762
|
+
* (input triples + derived triples, default graph only).
|
|
563
763
|
* @param data the premise graph
|
|
564
764
|
* @param rifRulesXml a RIF Core XML rule document
|
|
565
765
|
*/
|
|
566
766
|
export function rifEval(
|
|
567
767
|
data: DataInput,
|
|
568
768
|
rifRulesXml: string,
|
|
569
|
-
options?: { format?: DataFormat }
|
|
769
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
570
770
|
): Promise<Dataset>;
|
|
571
771
|
|
|
572
772
|
// ---------------------------------------------------------------------
|
|
573
|
-
//
|
|
574
|
-
//
|
|
575
|
-
//
|
|
576
|
-
//
|
|
773
|
+
// The persisted store: Shardborough generations (IBK3, IBK4 and IBK5
|
|
774
|
+
// blocks with their index sidecars) that `factoidal pack` or the native
|
|
775
|
+
// l4block-shard-pack wrote. skills/shardborough-storage describes the
|
|
776
|
+
// format. A Store is a store handle inside the engine: every artifact it
|
|
777
|
+
// read was checked against the SHA-256 its manifest commits, once, and
|
|
778
|
+
// every query answers from the decoded, indexed blocks it retains.
|
|
577
779
|
// ---------------------------------------------------------------------
|
|
578
780
|
|
|
579
|
-
/**
|
|
580
|
-
|
|
781
|
+
/**
|
|
782
|
+
* Reads one file of a store: `path` is relative to the collection root
|
|
783
|
+
* ('CURRENT', 'gen-1/manifest.sbm2', 'gen-1/predicate-0.ibk3', ...). In a
|
|
784
|
+
* browser, a reader over fetch():
|
|
785
|
+
* `(p) => fetch(base + p).then((r) => r.arrayBuffer())`.
|
|
786
|
+
*/
|
|
787
|
+
export type StoreReader =
|
|
788
|
+
(path: string) => Uint8Array | ArrayBuffer | Promise<Uint8Array | ArrayBuffer>;
|
|
789
|
+
|
|
790
|
+
export interface OpenStoreOptions {
|
|
791
|
+
/** Open this generation directory instead of the one CURRENT names. */
|
|
792
|
+
generation?: string;
|
|
793
|
+
/** Read only the artifacts this query's plan names. */
|
|
794
|
+
sparql?: string;
|
|
795
|
+
/** Read exactly these artifact keys. */
|
|
796
|
+
keys?: string[];
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/** An open store handle (op storeOpen). */
|
|
800
|
+
export class Store {
|
|
801
|
+
readonly handle: string;
|
|
802
|
+
readonly generation: string;
|
|
803
|
+
/** True when the generation was opened through CURRENT. */
|
|
804
|
+
readonly activated: boolean;
|
|
805
|
+
readonly identity: string;
|
|
806
|
+
/** The manifest layout label, e.g. 'predicate-ibk3-ptd1-sri2-tli1-oli2-merkle-v0'. */
|
|
807
|
+
readonly layout: string;
|
|
808
|
+
readonly wireVersion: number;
|
|
809
|
+
/** Artifacts read and verified. */
|
|
810
|
+
readonly artifacts: number;
|
|
811
|
+
/** Artifact bytes read. */
|
|
812
|
+
readonly bytes: number;
|
|
813
|
+
/** Rows the handle retains. */
|
|
814
|
+
readonly rows: number;
|
|
815
|
+
readonly closed: boolean;
|
|
816
|
+
/** One SPARQL 1.1 query against the retained blocks. The engine refuses
|
|
817
|
+
* a query whose plan needs a block the handle did not read. */
|
|
818
|
+
query(sparql: string): Promise<Bindings[] | boolean | Dataset>;
|
|
819
|
+
/** The manifest, decoded by the engine (op storeManifestInspect). */
|
|
820
|
+
inspect(): Promise<Record<string, unknown>>;
|
|
821
|
+
/** Release the handle. Idempotent. */
|
|
822
|
+
close(): Promise<void>;
|
|
823
|
+
}
|
|
581
824
|
|
|
582
825
|
/**
|
|
583
|
-
*
|
|
584
|
-
*
|
|
585
|
-
*
|
|
586
|
-
*
|
|
587
|
-
*
|
|
826
|
+
* Open a store. `source` is a collection root path (Node; the directory
|
|
827
|
+
* holding CURRENT) or a StoreReader (any runtime). With no options every
|
|
828
|
+
* artifact the manifest declares is read. Large collections need a
|
|
829
|
+
* deeper call stack than Node's default: see
|
|
830
|
+
* `@factoidal/core/store-worker` (README "The persisted store").
|
|
588
831
|
*/
|
|
589
|
-
export function
|
|
590
|
-
|
|
591
|
-
|
|
832
|
+
export function openStore(source: string | StoreReader, options?: OpenStoreOptions): Promise<Store>;
|
|
833
|
+
|
|
834
|
+
/** One query against a store: open with the query's plan, query, close. */
|
|
835
|
+
export function queryStore(
|
|
836
|
+
source: string | StoreReader,
|
|
837
|
+
sparql: string,
|
|
838
|
+
options?: { generation?: string }
|
|
592
839
|
): Promise<Bindings[] | boolean | Dataset>;
|
|
593
840
|
|
|
594
|
-
/**
|
|
595
|
-
export function
|
|
841
|
+
/** The store handles this engine instance holds open, with the residency caps (op storeHandleList). */
|
|
842
|
+
export function listStores(): Promise<Record<string, unknown>>;
|
|
596
843
|
|
|
597
844
|
/**
|
|
598
|
-
*
|
|
599
|
-
*
|
|
600
|
-
*
|
|
845
|
+
* A durable update log (hub post 18): the object deltaLogOpen() returns.
|
|
846
|
+
* In the browser the log is an IndexedDB database named `dbName`; under
|
|
847
|
+
* Node it lives in the memory of the process.
|
|
601
848
|
*/
|
|
602
|
-
export
|
|
849
|
+
export interface DeltaLogHandle {
|
|
850
|
+
dbName: string;
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/** What deltaLogInspect() reports (op deltaLogDecode). */
|
|
854
|
+
export interface DeltaLogInspection {
|
|
855
|
+
/** Batches (records) that verify, from the start of the log. */
|
|
856
|
+
batches: number;
|
|
857
|
+
/** Entries in those batches. */
|
|
858
|
+
entries: number;
|
|
859
|
+
/** The log ends with a torn final record: an append that did not complete. */
|
|
860
|
+
torn: boolean;
|
|
861
|
+
/** Bytes of that torn record (0 when the log is not torn). */
|
|
862
|
+
tornBytes: number;
|
|
863
|
+
/** Bytes of the whole log. */
|
|
864
|
+
logBytes: number;
|
|
865
|
+
records: Array<{ seq: number; epoch: number; entries: number }>;
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
/** Open (create when absent) a durable update log. Default name 'factoidal-delta-log'. */
|
|
869
|
+
export function deltaLogOpen(dbName?: string): Promise<DeltaLogHandle>;
|
|
870
|
+
|
|
871
|
+
/**
|
|
872
|
+
* Append one SPARQL Update request as one record (op deltaLogEncode).
|
|
873
|
+
* INSERT DATA, DELETE DATA, CLEAR DEFAULT, CLEAR GRAPH, DROP GRAPH and
|
|
874
|
+
* CREATE GRAPH are admitted; any other form rejects and nothing is written.
|
|
875
|
+
*/
|
|
876
|
+
export function deltaLogAppend(
|
|
877
|
+
handle: DeltaLogHandle,
|
|
878
|
+
sparqlUpdate: string,
|
|
879
|
+
options?: { epoch?: number }
|
|
880
|
+
): Promise<{ seq: number; opCount: number }>;
|
|
881
|
+
|
|
882
|
+
/** The records of the log, in commit order, as hexadecimal text joined by "\n". */
|
|
883
|
+
export function deltaLogReadAllHex(handle: DeltaLogHandle): Promise<string>;
|
|
884
|
+
|
|
885
|
+
/**
|
|
886
|
+
* Merge on read (op deltaLogMerge): `baseNQuads` with the batches of the log
|
|
887
|
+
* applied in commit order, as N-Quads. A torn final record (an append that
|
|
888
|
+
* did not complete) is not applied. A damaged record, or a record whose
|
|
889
|
+
* entries the engine cannot decode, makes the merge reject: the records after
|
|
890
|
+
* it would otherwise be lost (https://github.com/danbri/factoidal/issues/843).
|
|
891
|
+
*/
|
|
892
|
+
export function deltaLogMerge(handle: DeltaLogHandle, baseNQuads: string): Promise<string>;
|
|
893
|
+
|
|
894
|
+
/**
|
|
895
|
+
* What the log holds, record by record (op deltaLogDecode). Rejects for a
|
|
896
|
+
* damaged record or a record whose entries the engine cannot decode.
|
|
897
|
+
*/
|
|
898
|
+
export function deltaLogInspect(handle: DeltaLogHandle): Promise<DeltaLogInspection>;
|
|
899
|
+
|
|
900
|
+
/** Remove the log and its records. */
|
|
901
|
+
export function deltaLogDestroy(handle: DeltaLogHandle): Promise<void>;
|
|
902
|
+
|
|
903
|
+
/** TEST ONLY: cut the last 4 bytes of the last record, as a torn write would. False when the log is empty. */
|
|
904
|
+
export function _deltaLogCorruptLastForTest(handle: DeltaLogHandle): Promise<boolean>;
|
|
905
|
+
|
|
906
|
+
|
|
907
|
+
|
|
908
|
+
// ---------------------------------------------------------------------
|
|
909
|
+
// Common Logic (ISO/IEC 24707:2018) and IKL
|
|
910
|
+
// ---------------------------------------------------------------------
|
|
911
|
+
|
|
912
|
+
// Reads Common Logic Interchange Format
|
|
913
|
+
// text (ISO/IEC 24707:2018), with the IKL `that`-operator extension,
|
|
914
|
+
// and reports its shape -- it never produces RDF. `pureCL` is a
|
|
915
|
+
// DIALECT flag, not a validity or quality signal: true while the text
|
|
916
|
+
// stays inside ISO/IEC 24707 Common Logic, false once it uses IKL's
|
|
917
|
+
// `that` operator. A CLIF text that fails to parse rejects instead of
|
|
918
|
+
// returning either value.
|
|
919
|
+
export function clParse(clifText: string): Promise<{
|
|
920
|
+
ok: boolean;
|
|
921
|
+
sentences: number;
|
|
922
|
+
pureCL: boolean;
|
|
923
|
+
normalized: string;
|
|
924
|
+
}>;
|
|
925
|
+
|
|
926
|
+
// Reads CLIF text and writes it
|
|
927
|
+
// back out in canonical spacing. `roundTripProved` is ALWAYS `false`:
|
|
928
|
+
// `clif_roundTrip` (CL/ClifAdequacy.lean) is an OPEN lemma -- the
|
|
929
|
+
// fragment boundary `marksLexable` is MEASURED, not proved. The field
|
|
930
|
+
// is surfaced, not dropped or defaulted away, so a caller does not
|
|
931
|
+
// have to go find that out.
|
|
932
|
+
export function clSerialize(clifText: string): Promise<{
|
|
933
|
+
ok: boolean;
|
|
934
|
+
clif: string;
|
|
935
|
+
sentences: number;
|
|
936
|
+
roundTripProved: false;
|
|
937
|
+
}>;
|
|
938
|
+
|
|
939
|
+
// Alpha-normalises CLIF text: the
|
|
940
|
+
// canonical representative of each sentence's bound-variable-renaming
|
|
941
|
+
// equivalence class -- IKL GUIDE Appendix B condition (1), renaming a
|
|
942
|
+
// bound variable does not change the proposition expressed. Two
|
|
943
|
+
// sentences that differ only in bound-variable names produce
|
|
944
|
+
// byte-identical `clif` output.
|
|
945
|
+
export function clAlphaNorm(clifText: string): Promise<{
|
|
946
|
+
ok: boolean;
|
|
947
|
+
clif: string;
|
|
948
|
+
sentences: number;
|
|
949
|
+
}>;
|
|
950
|
+
|
|
951
|
+
// Hayes's reduction of IKL to
|
|
952
|
+
// Common Logic (danbri/factoidal#625), over a whole text.
|
|
953
|
+
//
|
|
954
|
+
// `preserves: "satisfiability"` -- the reduction preserves
|
|
955
|
+
// satisfiability, NOT equivalence. It suits entailment and consistency
|
|
956
|
+
// testing; it is not a transformation to apply to data you intend to
|
|
957
|
+
// keep.
|
|
958
|
+
//
|
|
959
|
+
// `noIntrusion` IS the proof hypothesis `CL.noIntrSs [] []` decides,
|
|
960
|
+
// not a paraphrase of it. The transformation runs and returns output
|
|
961
|
+
// either way; when `noIntrusion` is `false`, `tails_satisfiable` /
|
|
962
|
+
// `normalize_preserves` do not cover that output.
|
|
963
|
+
export function clNormalize(clifText: string): Promise<{
|
|
964
|
+
ok: boolean;
|
|
965
|
+
head: string[];
|
|
966
|
+
tail: string[];
|
|
967
|
+
clif: string;
|
|
968
|
+
sentences: number;
|
|
969
|
+
thatCount: number;
|
|
970
|
+
noIntrusion: boolean;
|
|
971
|
+
preserves: 'satisfiability';
|
|
972
|
+
provedUnder: string;
|
|
973
|
+
}>;
|
|
974
|
+
|
|
975
|
+
// clFiniteSat is DEFERRED from this typed surface (owner decision,
|
|
976
|
+
// 2026-08-26), not excluded: it takes a caller-supplied finite-
|
|
977
|
+
// interpretation JSON encoding that has no user yet. Reachable only
|
|
978
|
+
// through the raw dispatch ABI (`(await loadEngine()).call('clFiniteSat',
|
|
979
|
+
// [interpJson, clifText])`), which needs no typed shape commitment here.
|
|
603
980
|
|
|
604
981
|
// ---------------------------------------------------------------------
|
|
605
982
|
// Typed engine functions (#74 npm FP surface). Each is a pure,
|
|
606
|
-
// value-in / value-out wrapper over one
|
|
607
|
-
// the npm-entry bundle.
|
|
983
|
+
// value-in / value-out wrapper over one engine op.
|
|
608
984
|
// ---------------------------------------------------------------------
|
|
609
985
|
|
|
610
986
|
/**
|
|
@@ -743,100 +1119,17 @@ export function toanSubst(
|
|
|
743
1119
|
value: ToanExpr
|
|
744
1120
|
): Promise<string>;
|
|
745
1121
|
|
|
746
|
-
/** A matrix/vector cell: an integer or an exact [num, den] rational. */
|
|
747
|
-
export type MatrixCell = number | [number, number];
|
|
748
1122
|
|
|
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
1123
|
|
|
822
1124
|
// ---------------------------------------------------------------------
|
|
823
|
-
// VC Data Integrity crypto (eddsa-rdfc-2022)
|
|
824
|
-
//
|
|
825
|
-
//
|
|
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).
|
|
1125
|
+
// VC Data Integrity crypto (eddsa-rdfc-2022), the ops of
|
|
1126
|
+
// formal/lean4/Wasm/Ops/Vc.lean. Ed25519 is HACL*'s C code compiled into
|
|
1127
|
+
// the wasm module; SHA-256 is the Lean hash. No initialisation step.
|
|
835
1128
|
// ---------------------------------------------------------------------
|
|
836
1129
|
|
|
837
1130
|
/**
|
|
838
1131
|
* SHA-256 of a message string's bytes, as a lowercase hex digest
|
|
839
|
-
* (
|
|
1132
|
+
* (the Lean SHA-256).
|
|
840
1133
|
*/
|
|
841
1134
|
export function vcSha256Hex(message: string): Promise<string>;
|
|
842
1135
|
|
|
@@ -885,7 +1178,7 @@ export function vcEddsaVerifyFromCanonical(
|
|
|
885
1178
|
|
|
886
1179
|
/**
|
|
887
1180
|
* VC Data Model 2.0 structural conformance check (VC.Credential.fst's
|
|
888
|
-
* vc_check_from_string,
|
|
1181
|
+
* vc_check_from_string, ported to L4Factoidal/VC/Credential.lean — 117 pass, 0 fail on the offline
|
|
889
1182
|
* vc_stage1 fixture suite). Pure structural validation, no crypto.
|
|
890
1183
|
* `v2ctxJson` is the vendored VCDM v2 base context document's raw JSON
|
|
891
1184
|
* text (third_party/contexts/credentials-v2.jsonld); `credentialJson`
|
|
@@ -928,7 +1221,11 @@ export function vcCheckRelatedResourceDigests(
|
|
|
928
1221
|
credentialJson: string
|
|
929
1222
|
): Promise<{ valid: boolean; reason?: string }>;
|
|
930
1223
|
|
|
931
|
-
/**
|
|
1224
|
+
/**
|
|
1225
|
+
* Feature probe: which ops the loaded wasm module serves. A module older
|
|
1226
|
+
* than this package can lack some; an operation whose op is missing
|
|
1227
|
+
* rejects naming it.
|
|
1228
|
+
*/
|
|
932
1229
|
export function capabilities(): Promise<{
|
|
933
1230
|
entry: boolean;
|
|
934
1231
|
construct: boolean;
|
|
@@ -954,21 +1251,32 @@ export function capabilities(): Promise<{
|
|
|
954
1251
|
jsonSchema: boolean;
|
|
955
1252
|
schematron: boolean;
|
|
956
1253
|
toan: boolean;
|
|
957
|
-
|
|
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
|
-
*/
|
|
1254
|
+
/** The VC Data Integrity crypto ops are present. */
|
|
965
1255
|
vcCrypto: boolean;
|
|
966
|
-
/**
|
|
967
|
-
|
|
1256
|
+
/** query()'s `entail` regimes (op queryRaw) are served. */
|
|
1257
|
+
entailment: boolean;
|
|
1258
|
+
/** queryHdt() (op queryHdt) is served. */
|
|
1259
|
+
hdt: boolean;
|
|
1260
|
+
/** query()'s `sparql12` and DatasetHandle.query's (queryDataset12, datasetQuery12). */
|
|
1261
|
+
sparql12: boolean;
|
|
1262
|
+
/** openStore() and the Store methods (storeOpen, storeHandleQuery). */
|
|
1263
|
+
store: boolean;
|
|
1264
|
+
/** The deltaLog* functions (deltaLogEncode, deltaLogDecode, deltaLogMerge). */
|
|
1265
|
+
deltaLog: boolean;
|
|
1266
|
+
/** 'full': the whole library is in the wasm module. */
|
|
1267
|
+
profile: 'full' | string;
|
|
1268
|
+
/** The dispatch ABI version string of the loaded wasm module. */
|
|
1269
|
+
abiVersion: string;
|
|
1270
|
+
/** openDataset()/DatasetHandle (datasetOpen/Query/Update/Serialize/Close) are present. */
|
|
1271
|
+
datasetHandles: boolean;
|
|
1272
|
+
/** parse()'s `{lenient:true}` (parseDocument) is present. */
|
|
1273
|
+
parseDiagnostics: boolean;
|
|
1274
|
+
/** serialize()'s `{prefixes, literalShorthand}` (serializeTurtleWith) is present. */
|
|
1275
|
+
turtlePrefixes: boolean;
|
|
968
1276
|
}>;
|
|
969
1277
|
|
|
970
1278
|
// ---------------------------------------------------------------------
|
|
971
|
-
//
|
|
1279
|
+
// One call, serialised answer (op queryRaw)
|
|
972
1280
|
// ---------------------------------------------------------------------
|
|
973
1281
|
|
|
974
1282
|
/** SPARQL Results JSON term (https://www.w3.org/TR/sparql11-results-json/). */
|
|
@@ -989,8 +1297,13 @@ export type OutputFormat =
|
|
|
989
1297
|
| 'json' | 'csv' | 'tsv' | 'xml' | 'table' | 'ntriples';
|
|
990
1298
|
|
|
991
1299
|
/**
|
|
992
|
-
*
|
|
993
|
-
*
|
|
1300
|
+
* One call, serialised answer: parse `dataString`, close the default
|
|
1301
|
+
* graph under `entail`, run the query. Resolves to parsed SPARQL Results
|
|
1302
|
+
* JSON when output is 'json' (default), the text otherwise. 'csv', 'tsv'
|
|
1303
|
+
* and 'xml' are the W3C SPARQL results formats (CSV and TSV have no ASK
|
|
1304
|
+
* encoding, so an ASK with those rejects); 'table' and 'ntriples' are
|
|
1305
|
+
* display formats. A CONSTRUCT or DESCRIBE answer is a graph and takes
|
|
1306
|
+
* 'ntriples' or 'table' only.
|
|
994
1307
|
*/
|
|
995
1308
|
export function queryRaw(
|
|
996
1309
|
dataString: string,
|
|
@@ -1002,18 +1315,41 @@ export function queryRaw(
|
|
|
1002
1315
|
}
|
|
1003
1316
|
): Promise<SparqlResultsJson | string>;
|
|
1004
1317
|
|
|
1005
|
-
/** Package version string, e.g. '0.
|
|
1318
|
+
/** Package version string, e.g. '0.9.0'. */
|
|
1006
1319
|
export const version: string;
|
|
1007
1320
|
|
|
1321
|
+
/** The engine: 'lean4-wasm'. */
|
|
1322
|
+
export const engine: string;
|
|
1323
|
+
|
|
1324
|
+
/**
|
|
1325
|
+
* The loaded Lean engine handle, for the dispatch ops this package does
|
|
1326
|
+
* not wrap: `call(op, args)` answers the parsed envelope and throws on
|
|
1327
|
+
* {"ok":false}; `call('ops', [])` lists the op names. Node: index.mjs;
|
|
1328
|
+
* browser: browser.js.
|
|
1329
|
+
*/
|
|
1330
|
+
export function loadEngine(): Promise<{
|
|
1331
|
+
version(): string;
|
|
1332
|
+
call(op: string, args: string[]): any;
|
|
1333
|
+
callBlob(op: string, args: string[], bytes: Uint8Array | ArrayBuffer): any;
|
|
1334
|
+
callBlobIO(op: string, args: string[], bytes?: Uint8Array | ArrayBuffer): { envelope: any; bytes: Uint8Array };
|
|
1335
|
+
}>;
|
|
1336
|
+
|
|
1008
1337
|
declare const _default: {
|
|
1009
1338
|
parse: typeof parse;
|
|
1010
1339
|
query: typeof query;
|
|
1011
1340
|
queryHdt: typeof queryHdt;
|
|
1012
1341
|
update: typeof update;
|
|
1342
|
+
openDataset: typeof openDataset;
|
|
1343
|
+
closure: typeof closure;
|
|
1344
|
+
formats: typeof formats;
|
|
1013
1345
|
serialize: typeof serialize;
|
|
1014
1346
|
canonicalize: typeof canonicalize;
|
|
1015
1347
|
graphs: typeof graphs;
|
|
1016
1348
|
canonicalHash: typeof canonicalHash;
|
|
1349
|
+
isomorphic: typeof isomorphic;
|
|
1350
|
+
fromQuads: typeof fromQuads;
|
|
1351
|
+
ready: typeof ready;
|
|
1352
|
+
engineTables: typeof engineTables;
|
|
1017
1353
|
shaclValidate: typeof shaclValidate;
|
|
1018
1354
|
shexValidate: typeof shexValidate;
|
|
1019
1355
|
owlClosure: typeof owlClosure;
|
|
@@ -1029,10 +1365,20 @@ declare const _default: {
|
|
|
1029
1365
|
xmlWellformed: typeof xmlWellformed;
|
|
1030
1366
|
xpathEval: typeof xpathEval;
|
|
1031
1367
|
rifEval: typeof rifEval;
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1368
|
+
clParse: typeof clParse;
|
|
1369
|
+
clSerialize: typeof clSerialize;
|
|
1370
|
+
clAlphaNorm: typeof clAlphaNorm;
|
|
1371
|
+
clNormalize: typeof clNormalize;
|
|
1372
|
+
openStore: typeof openStore;
|
|
1373
|
+
queryStore: typeof queryStore;
|
|
1374
|
+
listStores: typeof listStores;
|
|
1375
|
+
deltaLogOpen: typeof deltaLogOpen;
|
|
1376
|
+
deltaLogAppend: typeof deltaLogAppend;
|
|
1377
|
+
deltaLogReadAllHex: typeof deltaLogReadAllHex;
|
|
1378
|
+
deltaLogMerge: typeof deltaLogMerge;
|
|
1379
|
+
deltaLogInspect: typeof deltaLogInspect;
|
|
1380
|
+
deltaLogDestroy: typeof deltaLogDestroy;
|
|
1381
|
+
_deltaLogCorruptLastForTest: typeof _deltaLogCorruptLastForTest;
|
|
1036
1382
|
xsltTransform: typeof xsltTransform;
|
|
1037
1383
|
mathmlEval: typeof mathmlEval;
|
|
1038
1384
|
xformsRecalc: typeof xformsRecalc;
|
|
@@ -1043,12 +1389,6 @@ declare const _default: {
|
|
|
1043
1389
|
toanSimplify: typeof toanSimplify;
|
|
1044
1390
|
toanDiff: typeof toanDiff;
|
|
1045
1391
|
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
1392
|
vcSha256Hex: typeof vcSha256Hex;
|
|
1053
1393
|
vcEd25519SecretToPublic: typeof vcEd25519SecretToPublic;
|
|
1054
1394
|
vcEd25519Sign: typeof vcEd25519Sign;
|
|
@@ -1061,8 +1401,28 @@ declare const _default: {
|
|
|
1061
1401
|
vcCheckRelatedResourceDigests: typeof vcCheckRelatedResourceDigests;
|
|
1062
1402
|
capabilities: typeof capabilities;
|
|
1063
1403
|
Dataset: typeof Dataset;
|
|
1404
|
+
DatasetHandle: typeof DatasetHandle;
|
|
1405
|
+
Store: typeof Store;
|
|
1406
|
+
ParseError: typeof ParseError;
|
|
1064
1407
|
dataFactory: DataFactory;
|
|
1065
1408
|
queryRaw: typeof queryRaw;
|
|
1066
1409
|
version: string;
|
|
1410
|
+
engine: string;
|
|
1067
1411
|
};
|
|
1068
1412
|
export default _default;
|
|
1413
|
+
|
|
1414
|
+
// Added in 0.10.0 (lib/pure.mjs).
|
|
1415
|
+
export function aeadSeal(a: { key: Uint8Array; nonce: Uint8Array; plaintext?: Uint8Array; aad?: Uint8Array }): Promise<Uint8Array>;
|
|
1416
|
+
export function aeadOpen(a: { key: Uint8Array; nonce: Uint8Array; ciphertext: Uint8Array; aad?: Uint8Array }): Promise<Uint8Array>;
|
|
1417
|
+
export function hpkeSeal(a: { skE: Uint8Array; pkR: Uint8Array; plaintext?: Uint8Array; info?: Uint8Array; aad?: Uint8Array }): Promise<{ message: Uint8Array; enc: Uint8Array; ciphertext: Uint8Array }>;
|
|
1418
|
+
export function hpkeOpen(a: { skR: Uint8Array; message: Uint8Array; info?: Uint8Array; aad?: Uint8Array }): Promise<Uint8Array>;
|
|
1419
|
+
export function proofCheck(bundleJson: string): Promise<Record<string, unknown>>;
|
|
1420
|
+
export function proofInspect(bundleJson: string): Promise<Record<string, unknown>>;
|
|
1421
|
+
export function canonicalizeNQuads(nquads: string): Promise<string>;
|
|
1422
|
+
export function normalizeNQuads(nquads: string): Promise<string>;
|
|
1423
|
+
export function serveStore(root: string, options?: { port?: number; host?: string; queryPath?: string; gspPath?: string; tdb2?: boolean }): Promise<{ url: string; port: number; close(): Promise<void> }>;
|
|
1424
|
+
|
|
1425
|
+
/** Pack a small built-in store (Node only) under dir or a temporary directory; returns the collection root. */
|
|
1426
|
+
export function sampleStorePath(dir?: string): string;
|
|
1427
|
+
/** What the sample store holds. */
|
|
1428
|
+
export const sampleStoreFacts: Readonly<{ triples: number; source: string; layout: string }>;
|