@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/fn.d.ts
ADDED
|
@@ -0,0 +1,519 @@
|
|
|
1
|
+
// TypeScript declarations for factoidal/fn — the strictly functional
|
|
2
|
+
// dataset API. See fn.js for the implementation and
|
|
3
|
+
// docs/designissues/2026-07-05-functional-dataset-api.md for the
|
|
4
|
+
// design rationale (identity/cost model, dataflow pattern).
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
Dataset,
|
|
8
|
+
Quad,
|
|
9
|
+
Bindings,
|
|
10
|
+
DataFormat,
|
|
11
|
+
EntailRegime,
|
|
12
|
+
NamedNode,
|
|
13
|
+
BlankNode,
|
|
14
|
+
MathValue,
|
|
15
|
+
XFormsBind,
|
|
16
|
+
XFormsNodeValidity,
|
|
17
|
+
SchematronFinding,
|
|
18
|
+
ToanExpr,
|
|
19
|
+
MatrixCell,
|
|
20
|
+
MatrixResult,
|
|
21
|
+
ScaledValue,
|
|
22
|
+
SigmoidParams,
|
|
23
|
+
} from './index';
|
|
24
|
+
|
|
25
|
+
export type {
|
|
26
|
+
MathValue,
|
|
27
|
+
XFormsBind,
|
|
28
|
+
XFormsNodeValidity,
|
|
29
|
+
SchematronFinding,
|
|
30
|
+
ToanExpr,
|
|
31
|
+
MatrixCell,
|
|
32
|
+
MatrixResult,
|
|
33
|
+
ScaledValue,
|
|
34
|
+
SigmoidParams,
|
|
35
|
+
} from './index';
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A frozen, deduplicated snapshot of a quad set. No method mutates —
|
|
39
|
+
* every operation on an FnDataset is a free function that returns a
|
|
40
|
+
* new FnDataset (or a plain value). Iterating yields frozen RDF/JS
|
|
41
|
+
* Quad terms.
|
|
42
|
+
*
|
|
43
|
+
* Opaque and handle-based: FnDataset does not commit callers to an
|
|
44
|
+
* in-memory-array representation. Today's only implementation holds
|
|
45
|
+
* one internally, but the public surface (size, iteration, toArray(),
|
|
46
|
+
* toNQuads(), match()) is the contract a future on-disk (COTTAS)
|
|
47
|
+
* backend or a precomputed-hash-sidecar backend would satisfy without
|
|
48
|
+
* this type's shape changing — see
|
|
49
|
+
* docs/designissues/2026-07-05-functional-dataset-api.md's "future
|
|
50
|
+
* backends" section.
|
|
51
|
+
*/
|
|
52
|
+
export class FnDataset implements Iterable<Quad> {
|
|
53
|
+
private constructor(backend: unknown);
|
|
54
|
+
readonly size: number;
|
|
55
|
+
[Symbol.iterator](): Iterator<Quad>;
|
|
56
|
+
toArray(): Quad[];
|
|
57
|
+
/** Raw N-Quads text, arrival order (not canonicalized). */
|
|
58
|
+
toNQuads(): string;
|
|
59
|
+
match(
|
|
60
|
+
subject?: Quad['subject'] | null,
|
|
61
|
+
predicate?: Quad['predicate'] | null,
|
|
62
|
+
object?: Quad['object'] | null,
|
|
63
|
+
graph?: Quad['graph'] | null
|
|
64
|
+
): FnDataset;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** The empty dataset — identity element for union() / difference(). */
|
|
68
|
+
export const EMPTY: FnDataset;
|
|
69
|
+
|
|
70
|
+
/** Snapshot a (possibly mutable) RDF/JS Dataset into an FnDataset. */
|
|
71
|
+
export function fromDataset(dataset: Dataset): FnDataset;
|
|
72
|
+
|
|
73
|
+
/** Materialize an FnDataset into a fresh, independently-mutable Dataset. */
|
|
74
|
+
export function toDataset(ds: FnDataset): Dataset;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* A mutable accumulator for incrementally-arriving quads — the
|
|
78
|
+
* streaming-parser integration seam. addChunk() accepts one quad or
|
|
79
|
+
* an iterable of quads; finish() de-duplicates once and returns a
|
|
80
|
+
* frozen FnDataset. Calling either method after finish() throws.
|
|
81
|
+
*/
|
|
82
|
+
export interface Builder {
|
|
83
|
+
addChunk(chunk: Quad | Iterable<Quad>): void;
|
|
84
|
+
finish(): FnDataset;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Construct a streaming builder (see Builder). */
|
|
88
|
+
export function builder(): Builder;
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Sugar over builder(): consume a sync or async iterable of quad
|
|
92
|
+
* batches into one finished FnDataset.
|
|
93
|
+
*/
|
|
94
|
+
export function fromChunks(
|
|
95
|
+
chunks: Iterable<Quad | Iterable<Quad>> | AsyncIterable<Quad | Iterable<Quad>>
|
|
96
|
+
): Promise<FnDataset>;
|
|
97
|
+
|
|
98
|
+
/** Parse one RDF document into an FnDataset. */
|
|
99
|
+
export function parse(
|
|
100
|
+
text: string,
|
|
101
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
102
|
+
): Promise<FnDataset>;
|
|
103
|
+
|
|
104
|
+
/** Set union, first-seen order. */
|
|
105
|
+
export function union(a: FnDataset, b: FnDataset): FnDataset;
|
|
106
|
+
|
|
107
|
+
/** Quads in a that are not in b. */
|
|
108
|
+
export function difference(a: FnDataset, b: FnDataset): FnDataset;
|
|
109
|
+
|
|
110
|
+
/** Keep quads matching quadPred(quad) => boolean. */
|
|
111
|
+
export function filter(
|
|
112
|
+
ds: FnDataset,
|
|
113
|
+
quadPred: (quad: Quad) => boolean
|
|
114
|
+
): FnDataset;
|
|
115
|
+
|
|
116
|
+
/** Transform every quad with f(quad) => quad; output is re-deduplicated. */
|
|
117
|
+
export function mapQuads(ds: FnDataset, f: (quad: Quad) => Quad): FnDataset;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Run a SPARQL 1.1 query. SELECT -> Bindings[]; ASK -> boolean;
|
|
121
|
+
* CONSTRUCT -> FnDataset (needs the npm-entry engine bundle — see
|
|
122
|
+
* capabilities()).
|
|
123
|
+
*/
|
|
124
|
+
export function query(
|
|
125
|
+
ds: FnDataset,
|
|
126
|
+
sparql: string,
|
|
127
|
+
options?: { entail?: EntailRegime }
|
|
128
|
+
): Promise<Bindings[] | boolean | FnDataset>;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Materialize an entailment closure over ds's default graph as a new
|
|
132
|
+
* FnDataset (a self-CONSTRUCT under the given regime — reuses
|
|
133
|
+
* query()'s entailment support; named-graph triples are not
|
|
134
|
+
* restated). Needs the npm-entry engine bundle.
|
|
135
|
+
*/
|
|
136
|
+
export function entail(ds: FnDataset, regime: EntailRegime): Promise<FnDataset>;
|
|
137
|
+
|
|
138
|
+
/** SHACL Core validation result (see validate()). */
|
|
139
|
+
export interface ValidateResult {
|
|
140
|
+
conforms: boolean;
|
|
141
|
+
/** SHACL_Validation.validation_report_to_graph's graph as an FnDataset. */
|
|
142
|
+
report: FnDataset;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* SHACL Core validation. Needs the npm-entry engine bundle. Neither
|
|
147
|
+
* argument is mutated or consumed.
|
|
148
|
+
* @param ds the data graph
|
|
149
|
+
* @param shapes the shapes graph
|
|
150
|
+
*/
|
|
151
|
+
export function validate(ds: FnDataset, shapes: FnDataset): Promise<ValidateResult>;
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* ShEx (Shape Expressions) validation of one focus node against one
|
|
155
|
+
* shape. Needs the npm-entry engine bundle. `null` means "deferred" --
|
|
156
|
+
* outside this engine's decidable ShEx fragment, never a guessed
|
|
157
|
+
* answer.
|
|
158
|
+
* @param schema ShExJ (JSON Schema form), as text
|
|
159
|
+
* @param focus an IRI, "_:label", or an RDF/JS NamedNode/BlankNode term
|
|
160
|
+
* @param shape a shape label (same shapes as focus); omit/null for the
|
|
161
|
+
* schema's own `start`
|
|
162
|
+
*/
|
|
163
|
+
export function shex(
|
|
164
|
+
ds: FnDataset,
|
|
165
|
+
schema: string,
|
|
166
|
+
focus: string | NamedNode | BlankNode,
|
|
167
|
+
shape?: string | NamedNode | BlankNode | null
|
|
168
|
+
): Promise<boolean | null>;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Evaluate an RML mapping graph against one logical source's raw data,
|
|
172
|
+
* materializing the generated triples as a new FnDataset. Needs the
|
|
173
|
+
* npm-entry engine bundle. Every triples map in `mapping` reads the
|
|
174
|
+
* SAME `source` -- joins across two different logical sources are out
|
|
175
|
+
* of scope for this entry point.
|
|
176
|
+
* @param mapping the RML mapping graph
|
|
177
|
+
* @param source raw JSON or CSV text (not RDF)
|
|
178
|
+
*/
|
|
179
|
+
export function fromMapping(
|
|
180
|
+
mapping: FnDataset,
|
|
181
|
+
source: string,
|
|
182
|
+
kind: 'json' | 'csv'
|
|
183
|
+
): Promise<FnDataset>;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* CSVW csv2rdf conversion, materialized as a new FnDataset. Needs the
|
|
187
|
+
* npm-entry engine bundle. Both arguments are raw text (CSVW's
|
|
188
|
+
* metadata format is JSON, not RDF); '' or omitted metadata infers
|
|
189
|
+
* the schema from the CSV's own header row. Every table in a
|
|
190
|
+
* multi-table `tables` group reads the SAME `csv` text.
|
|
191
|
+
* @param csv raw RFC 4180 tabular data (not RDF)
|
|
192
|
+
* @param metadata CSVW metadata document (JSON text)
|
|
193
|
+
*/
|
|
194
|
+
export function fromCsvw(
|
|
195
|
+
csv: string,
|
|
196
|
+
metadata?: string,
|
|
197
|
+
options?: {
|
|
198
|
+
mode?: 'standard' | 'minimal';
|
|
199
|
+
base?: string;
|
|
200
|
+
url?: string;
|
|
201
|
+
}
|
|
202
|
+
): Promise<FnDataset>;
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* RIF Core forward-chaining saturation, materialized as a new
|
|
206
|
+
* FnDataset (input triples + derived triples, default graph only).
|
|
207
|
+
* Needs the npm-entry engine bundle.
|
|
208
|
+
* @param ds the premise graph
|
|
209
|
+
* @param rules a RIF Core XML rule document
|
|
210
|
+
*/
|
|
211
|
+
export function rif(ds: FnDataset, rules: string): Promise<FnDataset>;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* The CERTIFIED core-RDFS closure
|
|
215
|
+
* (RDF.Entailment.RDFS.RhoDFClosure.fst's `rho_df_closure`):
|
|
216
|
+
* rdfs2/3/5/7/9/11 only, with the machine-checked decides-iff
|
|
217
|
+
* (docs/theorem-registry.md). "corerdfs" is this project's API name
|
|
218
|
+
* for the fragment the literature calls ρdf (subPropertyOf/
|
|
219
|
+
* subClassOf/type/domain/range). Needs the npm-entry engine bundle.
|
|
220
|
+
*/
|
|
221
|
+
export function coreRdfsClosure(
|
|
222
|
+
ds: FnDataset,
|
|
223
|
+
options?: { format?: string }
|
|
224
|
+
): Promise<{ ok: boolean; dataset: FnDataset }>;
|
|
225
|
+
|
|
226
|
+
/** Literature-name alias for coreRdfsClosure (ρdf). */
|
|
227
|
+
export function rhoDfClosure(
|
|
228
|
+
ds: FnDataset,
|
|
229
|
+
options?: { format?: string }
|
|
230
|
+
): Promise<{ ok: boolean; dataset: FnDataset }>;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Decidable core-RDFS fragment check (`is_rho_df_frag`): does the
|
|
234
|
+
* certified coreRdfsClosure guarantee apply to `ds`? Needs the
|
|
235
|
+
* npm-entry engine bundle.
|
|
236
|
+
*/
|
|
237
|
+
export function coreRdfsCheck(
|
|
238
|
+
ds: FnDataset,
|
|
239
|
+
options?: { format?: string }
|
|
240
|
+
): Promise<{ ok: boolean; fragment: boolean }>;
|
|
241
|
+
|
|
242
|
+
/** Literature-name alias for coreRdfsCheck (ρdf). */
|
|
243
|
+
export function rhoDfFragmentCheck(
|
|
244
|
+
ds: FnDataset,
|
|
245
|
+
options?: { format?: string }
|
|
246
|
+
): Promise<{ ok: boolean; fragment: boolean }>;
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* RDFS-Plus closure (RDF.Entailment.RDFSPlus.fst's
|
|
250
|
+
* `rdfs_plus_closure`): RDFS plus the practical OWL subset —
|
|
251
|
+
* owl:sameAs, owl:inverseOf, Symmetric/Transitive/Functional/
|
|
252
|
+
* InverseFunctionalProperty, equivalentClass/Property. Every OWL row
|
|
253
|
+
* carries a proved licensing + truth lemma; no chain-level
|
|
254
|
+
* completeness claim (theorem registry). Needs the npm-entry engine
|
|
255
|
+
* bundle.
|
|
256
|
+
*/
|
|
257
|
+
export function rdfsPlusClosure(
|
|
258
|
+
ds: FnDataset,
|
|
259
|
+
options?: { format?: string }
|
|
260
|
+
): Promise<{ ok: boolean; dataset: FnDataset; rounds: number }>;
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* OWL tableau materialisation (formal/fstar/Tableau.fst's
|
|
264
|
+
* `tableau_materialise`): add `i rdf:type <ClassExpression>` for every
|
|
265
|
+
* individual the model-construction reasoner proves is a member of an
|
|
266
|
+
* OWL class expression. Needs the npm-entry engine bundle. Default
|
|
267
|
+
* graph only. `dataset` is input + tableau-derived triples;
|
|
268
|
+
* `addedCount` is how many triples the tableau added.
|
|
269
|
+
*/
|
|
270
|
+
export function tableauMaterialise(
|
|
271
|
+
ds: FnDataset
|
|
272
|
+
): Promise<{ dataset: FnDataset; addedCount: number }>;
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* OWL DL inconsistency verdict (bin/owl-runner's DL pipeline: OWL-RL
|
|
276
|
+
* closure -> tableau materialise -> OWL-RL closure -> is_inconsistent).
|
|
277
|
+
* `rlAlone` is the plain OWL-RL verdict on the same input. Needs the
|
|
278
|
+
* npm-entry engine bundle. Default graph only.
|
|
279
|
+
*/
|
|
280
|
+
export function tableauDlInconsistent(
|
|
281
|
+
ds: FnDataset
|
|
282
|
+
): Promise<{ inconsistent: boolean; rlAlone: boolean }>;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* OWL DL consistency verdict via the verified clash-detecting tableau
|
|
286
|
+
* (Tableau.Refute.tableau_consistent over the OWL-RL closure). Needs the
|
|
287
|
+
* npm-entry engine bundle. Default graph only. `ontology` is an
|
|
288
|
+
* FnDataset or raw RDF text (Turtle by default). `consistent` is
|
|
289
|
+
* `false`, `true`, or `null` (budget-out, `reason` names the fuel cap).
|
|
290
|
+
*/
|
|
291
|
+
export function owlIsConsistent(
|
|
292
|
+
ontology: FnDataset | string,
|
|
293
|
+
options?: { format?: string; fuel?: number | string }
|
|
294
|
+
): Promise<{ consistent: boolean | null; reason?: string }>;
|
|
295
|
+
|
|
296
|
+
/**
|
|
297
|
+
* OWL entailment check: does `premise` entail `conclusion`? Verified
|
|
298
|
+
* two-path dispatch (`via: "closure"` / `via: "refutation"`). Needs the
|
|
299
|
+
* npm-entry engine bundle. Default graph only. Each argument is an
|
|
300
|
+
* FnDataset or raw RDF text. `entailed` is `true`, `false`, or `null`
|
|
301
|
+
* (refutation budget-out, `reason` names the cap).
|
|
302
|
+
*/
|
|
303
|
+
export function owlEntails(
|
|
304
|
+
premise: FnDataset | string,
|
|
305
|
+
conclusion: FnDataset | string,
|
|
306
|
+
options?: { format?: string; fuel?: number | string }
|
|
307
|
+
): Promise<{ entailed: boolean | null; via: 'closure' | 'refutation'; reason?: string }>;
|
|
308
|
+
|
|
309
|
+
/** RDFC-1.0 canonical N-Quads text. Needs the npm-entry engine bundle. */
|
|
310
|
+
export function canonicalize(ds: FnDataset): Promise<string>;
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* sha256 hex digest of canonicalize(ds); memoized by FnDataset
|
|
314
|
+
* identity. Needs the npm-entry engine bundle (canonicalize's cost).
|
|
315
|
+
*/
|
|
316
|
+
export function hash(ds: FnDataset): Promise<string>;
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Structural equality — exact quad-set match when that is conclusive
|
|
320
|
+
* (always for blank-node-free data), RDFC-1.0 canonical-hash equality
|
|
321
|
+
* otherwise. See fn.js for the full cost-model comment.
|
|
322
|
+
*/
|
|
323
|
+
export function equals(a: FnDataset, b: FnDataset): Promise<boolean>;
|
|
324
|
+
|
|
325
|
+
/** Enumerate named graphs (default graph excluded), first-seen order. */
|
|
326
|
+
export function graphs(ds: FnDataset): Array<[iri: string, graph: FnDataset]>;
|
|
327
|
+
|
|
328
|
+
/** A minimal mutable box holding one dataflow input value. */
|
|
329
|
+
export interface Cell<T> {
|
|
330
|
+
get(): T;
|
|
331
|
+
set(value: T): void;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
export function cell<T>(initial: T): Cell<T>;
|
|
335
|
+
|
|
336
|
+
/** A read-only handle to a derived dataflow value. */
|
|
337
|
+
export interface Derived<T> {
|
|
338
|
+
/** Recomputes only when an input's content-key has changed. */
|
|
339
|
+
get(): Promise<T>;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* A derived dataflow node over one or more cells: recomputes
|
|
344
|
+
* fn(...values) only when at least one input's content-key (FnDataset
|
|
345
|
+
* content hash, or the value itself for non-dataset inputs) has
|
|
346
|
+
* changed since the last get().
|
|
347
|
+
*/
|
|
348
|
+
export function derive<Args extends unknown[], R>(
|
|
349
|
+
fn: (...args: Args) => R | Promise<R>,
|
|
350
|
+
...inputCells: { [K in keyof Args]: Cell<Args[K]> }
|
|
351
|
+
): Derived<R>;
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Left-to-right function composition for Observable-style dataflow:
|
|
355
|
+
* `pipe(f, g, h)(x)` is `h(g(f(x)))`, awaiting any async step. With no
|
|
356
|
+
* functions it is the identity.
|
|
357
|
+
*/
|
|
358
|
+
export function pipe(): (input: unknown) => Promise<unknown>;
|
|
359
|
+
export function pipe<A, B>(f: (a: A) => B | Promise<B>): (a: A) => Promise<B>;
|
|
360
|
+
export function pipe<A, B, C>(
|
|
361
|
+
f: (a: A) => B | Promise<B>,
|
|
362
|
+
g: (b: B) => C | Promise<C>
|
|
363
|
+
): (a: A) => Promise<C>;
|
|
364
|
+
export function pipe<A, B, C, D>(
|
|
365
|
+
f: (a: A) => B | Promise<B>,
|
|
366
|
+
g: (b: B) => C | Promise<C>,
|
|
367
|
+
h: (c: C) => D | Promise<D>
|
|
368
|
+
): (a: A) => Promise<D>;
|
|
369
|
+
export function pipe(
|
|
370
|
+
...fns: Array<(x: unknown) => unknown>
|
|
371
|
+
): (input: unknown) => Promise<unknown>;
|
|
372
|
+
|
|
373
|
+
// ---------------------------------------------------------------------
|
|
374
|
+
// Typed engine functions (#74 FP surface). Re-exported from the JS
|
|
375
|
+
// engine api; full doc comments live in ./index.d.ts.
|
|
376
|
+
// ---------------------------------------------------------------------
|
|
377
|
+
|
|
378
|
+
export function xsltTransform(
|
|
379
|
+
stylesheetXml: string,
|
|
380
|
+
sourceXml: string
|
|
381
|
+
): Promise<string>;
|
|
382
|
+
export function mathmlEval(
|
|
383
|
+
contentMathmlXml: string,
|
|
384
|
+
bindings?: Record<string, string>
|
|
385
|
+
): Promise<MathValue>;
|
|
386
|
+
export function xformsRecalc(
|
|
387
|
+
instanceXml: string,
|
|
388
|
+
binds: XFormsBind[]
|
|
389
|
+
): Promise<{ instance: string; validity: XFormsNodeValidity[] }>;
|
|
390
|
+
export function jsonSchemaValidate(
|
|
391
|
+
schemaJson: string,
|
|
392
|
+
instanceJson: string
|
|
393
|
+
): Promise<{
|
|
394
|
+
valid: boolean;
|
|
395
|
+
result: 'pass' | 'fail' | 'unsupported';
|
|
396
|
+
errors: string[];
|
|
397
|
+
}>;
|
|
398
|
+
export function schematronValidate(
|
|
399
|
+
schematronXml: string,
|
|
400
|
+
instanceXml: string
|
|
401
|
+
): Promise<{ findings: SchematronFinding[] }>;
|
|
402
|
+
export function toanSummation(
|
|
403
|
+
bodyExpr: ToanExpr,
|
|
404
|
+
idx: string,
|
|
405
|
+
lo: number,
|
|
406
|
+
hi: number
|
|
407
|
+
): Promise<string>;
|
|
408
|
+
export function toanProduct(
|
|
409
|
+
bodyExpr: ToanExpr,
|
|
410
|
+
idx: string,
|
|
411
|
+
lo: number,
|
|
412
|
+
hi: number
|
|
413
|
+
): Promise<string>;
|
|
414
|
+
export function toanSimplify(expr: ToanExpr): Promise<string>;
|
|
415
|
+
export function toanDiff(expr: ToanExpr, variable: string): Promise<string>;
|
|
416
|
+
export function toanSubst(
|
|
417
|
+
expr: ToanExpr,
|
|
418
|
+
variable: string,
|
|
419
|
+
value: ToanExpr
|
|
420
|
+
): Promise<string>;
|
|
421
|
+
export function matrixDeterminant(
|
|
422
|
+
matrix: MatrixCell[][]
|
|
423
|
+
): Promise<MatrixResult>;
|
|
424
|
+
export function matrixScalarProduct(
|
|
425
|
+
a: MatrixCell[],
|
|
426
|
+
b: MatrixCell[]
|
|
427
|
+
): Promise<MatrixResult>;
|
|
428
|
+
export function matrixVectorProduct(
|
|
429
|
+
a: MatrixCell[],
|
|
430
|
+
b: MatrixCell[]
|
|
431
|
+
): Promise<MatrixResult>;
|
|
432
|
+
export function matrixOuterProduct(
|
|
433
|
+
a: MatrixCell[],
|
|
434
|
+
b: MatrixCell[]
|
|
435
|
+
): Promise<MatrixResult>;
|
|
436
|
+
export function sigmoidPoints(
|
|
437
|
+
params: SigmoidParams
|
|
438
|
+
): Promise<Array<{ x: ScaledValue; y: ScaledValue }>>;
|
|
439
|
+
export function sigmoidFormulaMathml(): Promise<string>;
|
|
440
|
+
|
|
441
|
+
// ---------------------------------------------------------------------
|
|
442
|
+
// VC Data Integrity crypto (eddsa-rdfc-2022, HACL* wasm backend).
|
|
443
|
+
// Re-exported unchanged from the JS engine api; full doc comments +
|
|
444
|
+
// the init story live in ./index.d.ts.
|
|
445
|
+
// ---------------------------------------------------------------------
|
|
446
|
+
|
|
447
|
+
export function vcSha256Hex(message: string): Promise<string>;
|
|
448
|
+
export function vcEd25519SecretToPublic(secretKeyHex: string): Promise<string>;
|
|
449
|
+
export function vcEd25519Sign(
|
|
450
|
+
secretKeyHex: string,
|
|
451
|
+
messageHex: string
|
|
452
|
+
): Promise<string>;
|
|
453
|
+
export function vcEd25519Verify(
|
|
454
|
+
publicKeyHex: string,
|
|
455
|
+
messageHex: string,
|
|
456
|
+
signatureHex: string
|
|
457
|
+
): Promise<boolean>;
|
|
458
|
+
export function vcEddsaCreateFromCanonical(
|
|
459
|
+
secretKeyHex: string,
|
|
460
|
+
canonicalDocument: string,
|
|
461
|
+
canonicalConfig: string
|
|
462
|
+
): Promise<string>;
|
|
463
|
+
export function vcEddsaVerifyFromCanonical(
|
|
464
|
+
publicKeyHex: string,
|
|
465
|
+
canonicalDocument: string,
|
|
466
|
+
canonicalConfig: string,
|
|
467
|
+
proofValue: string
|
|
468
|
+
): Promise<boolean>;
|
|
469
|
+
|
|
470
|
+
// ---------------------------------------------------------------------
|
|
471
|
+
// In-memory COTTAS/Parquet bytes store. Unlike every other constructor
|
|
472
|
+
// here, openCottas() does NOT return an FnDataset: rows decode lazily
|
|
473
|
+
// as query() touches them (see fn.js's doc comment and
|
|
474
|
+
// docs/designissues/2026-07-06-inmemory-bytes-store.md). Needs the
|
|
475
|
+
// npm-entry engine bundle.
|
|
476
|
+
// ---------------------------------------------------------------------
|
|
477
|
+
|
|
478
|
+
/** A read-only, lazily-decoding COTTAS store handle (see openCottas). */
|
|
479
|
+
export interface CottasStore {
|
|
480
|
+
/** The opaque handle string the underlying engine registry uses. */
|
|
481
|
+
readonly handle: string;
|
|
482
|
+
/**
|
|
483
|
+
* SPARQL over the store. SELECT -> Bindings[]; ASK -> boolean;
|
|
484
|
+
* CONSTRUCT -> FnDataset (materialized once). No `entail` option, no
|
|
485
|
+
* write overlay (read-only) — see fn.js's openCottas doc comment for
|
|
486
|
+
* the full divergence list from query(). Throws after close().
|
|
487
|
+
*/
|
|
488
|
+
query(sparql: string): Promise<Bindings[] | boolean | FnDataset>;
|
|
489
|
+
/** Release the store. Idempotent. */
|
|
490
|
+
close(): Promise<void>;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
/** Open a COTTAS/Parquet artifact's raw bytes as a read-only store. */
|
|
494
|
+
export function openCottas(
|
|
495
|
+
bytes: Uint8Array | ArrayBuffer | string
|
|
496
|
+
): Promise<CottasStore>;
|
|
497
|
+
|
|
498
|
+
/**
|
|
499
|
+
* Serialize an FnDataset to COTTAS/Parquet bytes via the native writer
|
|
500
|
+
* (round-trips back into openCottas()). Needs the npm-entry bundle.
|
|
501
|
+
*/
|
|
502
|
+
export function toCottas(ds: FnDataset): Promise<Uint8Array>;
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Run a SPARQL 1.1 query against a read-only HDT artifact's raw bytes
|
|
506
|
+
* (factoidal_cli.ml's `--data-hdt` backend). No npm-entry engine
|
|
507
|
+
* bundle needed -- CLI-only. Default graph only, SELECT/ASK only.
|
|
508
|
+
*/
|
|
509
|
+
export function queryHdt(
|
|
510
|
+
hdtBytes: Uint8Array | ArrayBuffer | string,
|
|
511
|
+
sparql: string
|
|
512
|
+
): Promise<Bindings[] | boolean>;
|
|
513
|
+
|
|
514
|
+
/**
|
|
515
|
+
* Feature probe — the SAME shape index.js's capabilities() returns
|
|
516
|
+
* (fn.js re-exports it unchanged). Referenced off ./index so the two
|
|
517
|
+
* declarations can never drift.
|
|
518
|
+
*/
|
|
519
|
+
export function capabilities(): ReturnType<typeof import('./index').capabilities>;
|