@factoidal/core 0.19.0 → 0.21.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 +65 -0
- package/README.md +59 -15
- package/authz/server.mjs +23 -2
- package/bin/engine.mjs +22 -1
- package/bin/factoidal.mjs +710 -38
- package/bin/pack-host.mjs +5 -0
- package/bin/serve.mjs +19 -3
- package/browser.d.ts +23 -0
- package/browser.js +26 -0
- package/index.d.ts +463 -24
- package/index.mjs +29 -0
- package/l4-assets/l4factoidal.js +1 -1
- package/l4-assets/l4factoidal.wasm +0 -0
- package/l4-assets/version.json +6 -6
- package/lib/api.mjs +480 -28
- package/lib/browser-engine.mjs +28 -1
- package/lib/cid-node.mjs +77 -0
- package/lib/cid.mjs +146 -0
- package/lib/cipher-host.mjs +126 -0
- package/lib/dataset.mjs +96 -12
- package/lib/engine-integrity.mjs +56 -0
- package/lib/lean-entry.mjs +30 -12
- package/lib/nodes.mjs +318 -17
- package/lib/sbm11-lws.mjs +4 -2
- package/lib/sbm11.mjs +29 -6
- package/lib/version.mjs +1 -1
- package/lws/README.md +9 -0
- package/lws/client.mjs +19 -2
- package/lws/persist.mjs +169 -0
- package/lws/server.mjs +82 -29
- package/package.json +2 -1
- package/solid/server/index.mjs +79 -13
- package/webdav/server.mjs +154 -25
- package/xmpp/client.mjs +332 -0
- package/xmpp/proxy.mjs +114 -0
package/index.d.ts
CHANGED
|
@@ -99,6 +99,7 @@ export type FactoidalErrorCode =
|
|
|
99
99
|
| 'term.invalid-iri'
|
|
100
100
|
| 'term.invalid-langtag'
|
|
101
101
|
| 'term.invalid'
|
|
102
|
+
| 'literal.value'
|
|
102
103
|
| 'query.syntax'
|
|
103
104
|
| 'query.failed'
|
|
104
105
|
| 'update.syntax'
|
|
@@ -236,6 +237,10 @@ export interface FormatCapability {
|
|
|
236
237
|
write12: boolean;
|
|
237
238
|
/** 'core' when both engines serve it; 'full' when only the full engine does. */
|
|
238
239
|
engine: 'core' | 'full';
|
|
240
|
+
/** The registered media types (W3C registration; empty for a row with none). syntaxFor() reads the same table. */
|
|
241
|
+
mediaTypes: string[];
|
|
242
|
+
/** The registered file extensions, with the leading dot ('.ttl'). */
|
|
243
|
+
extensions: string[];
|
|
239
244
|
}
|
|
240
245
|
|
|
241
246
|
/**
|
|
@@ -283,11 +288,31 @@ export class Dataset implements Iterable<Quad> {
|
|
|
283
288
|
toString(formatOrOptions?: WriteFormat | WriteOptions): string;
|
|
284
289
|
toNQuads(): string;
|
|
285
290
|
clone(): Dataset;
|
|
286
|
-
/**
|
|
287
|
-
|
|
291
|
+
/**
|
|
292
|
+
* RDF/JS DatasetCore (https://rdf.js.org/dataset-spec/); match and has use
|
|
293
|
+
* the engine indexes. `{match: 'value'}`: a literal object matches every
|
|
294
|
+
* object literal that is the same term or has the same value (sameValue());
|
|
295
|
+
* the other positions match by term.
|
|
296
|
+
*/
|
|
297
|
+
has(quad: Quad, options?: MatchOptions): boolean;
|
|
288
298
|
add(quad: Quad): this;
|
|
289
|
-
|
|
290
|
-
|
|
299
|
+
/** With `{match: 'value'}`: remove every quad of the same subject, predicate
|
|
300
|
+
* and graph whose object has the same value as the quad's literal object. */
|
|
301
|
+
delete(quad: Quad, options?: MatchOptions): this;
|
|
302
|
+
match(subject?: Term | null, predicate?: Term | null, object?: Term | null, graph?: Term | null,
|
|
303
|
+
options?: MatchOptions): Dataset;
|
|
304
|
+
/**
|
|
305
|
+
* The items of the RDF list (rdf:first/rdf:rest) at `head`, in order
|
|
306
|
+
* (https://github.com/danbri/factoidal/issues/1051 item 6). `rdf:nil` is
|
|
307
|
+
* the empty list. A list that is not well formed (a node with no or with two
|
|
308
|
+
* rdf:first or rdf:rest, or a cycle) is a FactoidalError, code `op.failed`.
|
|
309
|
+
* `graph`: omitted, null or the DefaultGraph for the default graph.
|
|
310
|
+
*/
|
|
311
|
+
listItems(head: Term, graph?: Term | null): Term[];
|
|
312
|
+
/** The members rdf:_1, rdf:_2, ... of `node`, sorted by n, and its kind (rdf:Bag, rdf:Seq, rdf:Alt) from its rdf:type. */
|
|
313
|
+
containerItems(node: Term, graph?: Term | null): { kind: NamedNode | null; items: Array<{ ordinal: number; term: Term }> };
|
|
314
|
+
/** Add a new RDF list of `items` on fresh blank nodes; answers its head (rdf:nil for no items). */
|
|
315
|
+
addList(items: Iterable<Term>, graph?: Term | null): Term;
|
|
291
316
|
toArray(): Quad[];
|
|
292
317
|
[Symbol.iterator](): Iterator<Quad>;
|
|
293
318
|
dispose(): void;
|
|
@@ -380,6 +405,12 @@ export interface ParseOptions {
|
|
|
380
405
|
* with one diagnostic of class 'too-many-errors'. Default: no limit.
|
|
381
406
|
*/
|
|
382
407
|
maxErrors?: number;
|
|
408
|
+
/**
|
|
409
|
+
* Read JSON-LD as JSON-LD-star (`@triple`, `@reifies`, `@annotation` as
|
|
410
|
+
* RDF 1.2 triple terms and reifiers), as `jsonldToRdf` does. Format
|
|
411
|
+
* 'jsonld' only (given or inferred); not with `lenient`. Default: false.
|
|
412
|
+
*/
|
|
413
|
+
rdfstar?: boolean;
|
|
383
414
|
}
|
|
384
415
|
|
|
385
416
|
export interface QueryOptions extends DatasetQueryOptions {
|
|
@@ -499,6 +530,18 @@ export function closure(
|
|
|
499
530
|
options?: { format?: DataFormat; baseIRI?: string }
|
|
500
531
|
): Promise<Dataset>;
|
|
501
532
|
|
|
533
|
+
/**
|
|
534
|
+
* SPARQL 1.2 RL infer (https://w3c.github.io/data-shapes/sparql12-rl/): the
|
|
535
|
+
* inference graph of the rule set `rules` (SPARQL-RL text) over the default
|
|
536
|
+
* graph of `data`, as a new Dataset. Rejects when the rule set has a syntax
|
|
537
|
+
* error, is not well-formed or not stratifiable, or has IMPORTS.
|
|
538
|
+
*/
|
|
539
|
+
export function sparqlRlInfer(
|
|
540
|
+
data: DataInput,
|
|
541
|
+
rules: string,
|
|
542
|
+
options?: { format?: DataFormat; baseIRI?: string }
|
|
543
|
+
): Promise<Dataset>;
|
|
544
|
+
|
|
502
545
|
/** The syntaxes the engine reads and writes, from the engine (op datasetFormats). */
|
|
503
546
|
export function formats(): Promise<FormatCapability[]>;
|
|
504
547
|
|
|
@@ -535,17 +578,31 @@ export function canonicalize(
|
|
|
535
578
|
export function graphs(dataset: Dataset): Array<[name: NamedNode | BlankNode, graph: Dataset]>;
|
|
536
579
|
|
|
537
580
|
/**
|
|
538
|
-
* The RDFC-1.0 canonical hash of a
|
|
539
|
-
* canonical N-Quads document
|
|
540
|
-
* Dataset Canonicalization 1.0, section 4.4 note 2)
|
|
541
|
-
* the canonical form and the digest.
|
|
542
|
-
* dropped first, so
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
*
|
|
581
|
+
* The RDFC-1.0 canonical hash of a dataset: the SHA-256, as 64 lowercase
|
|
582
|
+
* hexadecimal digits, of the canonical N-Quads document that canonicalize()
|
|
583
|
+
* answers (RDF Dataset Canonicalization 1.0, section 4.4 note 2), graph names
|
|
584
|
+
* included. The engine computes the canonical form and the digest. Since
|
|
585
|
+
* 0.20.0; 0.17.0 to 0.19.x dropped every graph name first, so datasets that
|
|
586
|
+
* differ only in their graph names got the same hash. To hash a graph
|
|
587
|
+
* whatever its name (for example one entry of graphs()), use
|
|
588
|
+
* canonicalHash(asDefaultGraph(g)). Rejects when the input holds an RDF 1.2
|
|
589
|
+
* triple term or the section 4.4 call budget is exceeded. The input is what
|
|
590
|
+
* canonicalize() takes: a Dataset, or text with `format` and `baseIRI`.
|
|
591
|
+
* Text is a JavaScript string (characters, not bytes): decode bytes first;
|
|
592
|
+
* the RDF text syntaxes are UTF-8 (`new TextDecoder('utf-8', { fatal: true })`).
|
|
593
|
+
* A Uint8Array is refused.
|
|
547
594
|
*/
|
|
548
|
-
export function canonicalHash(
|
|
595
|
+
export function canonicalHash(
|
|
596
|
+
data: Dataset | string | { text: string; format?: DataFormat; baseIRI?: string },
|
|
597
|
+
options?: { format?: DataFormat; baseIRI?: string },
|
|
598
|
+
): Promise<string>;
|
|
599
|
+
|
|
600
|
+
/**
|
|
601
|
+
* A new Dataset with the triples of every graph of `dataset`, all in the
|
|
602
|
+
* default graph (the engine's union of the graphs). With one entry of
|
|
603
|
+
* graphs(), it is that graph without its name. Dispose of it when done.
|
|
604
|
+
*/
|
|
605
|
+
export function asDefaultGraph(dataset: Dataset): Dataset;
|
|
549
606
|
|
|
550
607
|
/**
|
|
551
608
|
* Whether two datasets are isomorphic (RDF 1.1 Concepts 3.6 and 4; blank
|
|
@@ -555,15 +612,152 @@ export function canonicalHash(datasetOrGraph: Dataset): Promise<string>;
|
|
|
555
612
|
*/
|
|
556
613
|
export function isomorphic(a: DataInput, b: DataInput, options?: { format?: string; baseIRI?: string }): Promise<boolean>;
|
|
557
614
|
|
|
615
|
+
/**
|
|
616
|
+
* The RDF merge of two datasets (RDF 1.1 Semantics 5.2): the quads of both,
|
|
617
|
+
* with the blank nodes of each input kept apart (`_:b` in `a` and `_:b` in
|
|
618
|
+
* `b` are two blank nodes). The engine computes it (op datasetMerge, Lean
|
|
619
|
+
* theorem mergeDatasets_isMerge). Prefixes: those of `a`, then those of `b`
|
|
620
|
+
* whose label `a` does not declare. Since 0.21.0.
|
|
621
|
+
*/
|
|
622
|
+
export function datasetMerge(a: DataInput, b: DataInput, options?: { format?: string; baseIRI?: string }): Promise<Dataset>;
|
|
623
|
+
|
|
558
624
|
/** A Dataset holding RDF/JS quads; each term is sent to the engine as its components. */
|
|
559
625
|
export function fromQuads(quads: Iterable<Quad>): Promise<Dataset>;
|
|
560
626
|
|
|
561
627
|
/** Load the engine. Afterwards the N-Quads text functions of `@factoidal/core/rdfjs` work. */
|
|
562
628
|
export function ready(): Promise<void>;
|
|
563
629
|
|
|
630
|
+
// ---------------------------------------------------------------------
|
|
631
|
+
// Literal values (https://github.com/danbri/factoidal/issues/1051 items 1-3).
|
|
632
|
+
// Synchronous after the engine is loaded (`await ready()` or any other call);
|
|
633
|
+
// before that they throw a FactoidalError. The engine decides everything
|
|
634
|
+
// (formal/lean4/L4Factoidal/RDF/LiteralValue.lean). API.md "Literal values".
|
|
635
|
+
// ---------------------------------------------------------------------
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* The value of a literal, as JSON-safe data. A number that a JavaScript
|
|
639
|
+
* number may not hold exactly is a decimal string; `number` is present only
|
|
640
|
+
* when the value is exactly a binary64 value. Integer components are numbers
|
|
641
|
+
* when |n| <= 2^53 - 1, else decimal strings.
|
|
642
|
+
*/
|
|
643
|
+
export type LiteralValueData =
|
|
644
|
+
| { kind: 'string' | 'anyURI'; string: string }
|
|
645
|
+
| { kind: 'boolean'; boolean: boolean }
|
|
646
|
+
| { kind: 'decimal'; decimal: string; integer: boolean; number?: number }
|
|
647
|
+
| { kind: 'float' | 'double'; decimal?: string; number: number;
|
|
648
|
+
negativeZero?: true; special?: 'NaN' | 'INF' | '-INF' }
|
|
649
|
+
| { kind: 'duration'; months: number | string; seconds: string }
|
|
650
|
+
| { kind: 'dateTime' | 'time' | 'date' | 'gYearMonth' | 'gYear' | 'gMonthDay' | 'gDay' | 'gMonth';
|
|
651
|
+
year?: number | string; month?: number; day?: number; hour?: number;
|
|
652
|
+
minute?: number; second?: string; timezoneOffset?: number }
|
|
653
|
+
| { kind: 'hexBinary' | 'base64Binary'; hex: string }
|
|
654
|
+
| { kind: 'QName' | 'NOTATION'; prefix: string; localName: string }
|
|
655
|
+
| { kind: 'list'; items: LiteralValueData[] }
|
|
656
|
+
| { kind: 'langString'; string: string; language: string; direction?: 'ltr' | 'rtl' };
|
|
657
|
+
|
|
658
|
+
export interface LiteralValueResult {
|
|
659
|
+
/** The datatype IRI. */
|
|
660
|
+
datatype: string;
|
|
661
|
+
/** false: the engine has no lexical space for this datatype. */
|
|
662
|
+
recognized: boolean;
|
|
663
|
+
/** The lexical form is in the lexical space (null when not recognized). */
|
|
664
|
+
valid: boolean | null;
|
|
665
|
+
/** Present for a valid literal of a datatype with a value model. */
|
|
666
|
+
value?: LiteralValueData;
|
|
667
|
+
/** The canonical lexical form (XSD 1.1 Part 2 section 2.3.1), when known. */
|
|
668
|
+
canonical?: string;
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/** The XSD lexical-to-value mapping of a literal (RDF 1.1 Semantics section 7: no whiteSpace processing). */
|
|
672
|
+
export function literalValue(term: Literal): LiteralValueResult;
|
|
673
|
+
|
|
674
|
+
/** Whether the lexical form is in the datatype's lexical space; null when the engine has no lexical space for the datatype. */
|
|
675
|
+
export function isValidLiteral(term: Literal): boolean | null;
|
|
676
|
+
|
|
677
|
+
/** The literal with the canonical form of its value; null when it is not valid or has no canonical mapping. */
|
|
678
|
+
export function canonicalLiteral(term: Literal): Literal | null;
|
|
679
|
+
|
|
680
|
+
/**
|
|
681
|
+
* The literal of a JavaScript value. With no datatype the engine's table
|
|
682
|
+
* chooses: boolean xsd:boolean, string xsd:string, bigint xsd:integer, a safe
|
|
683
|
+
* integer Number xsd:integer, any other Number xsd:double, Date xsd:dateTime
|
|
684
|
+
* (UTC). `datatype` (an IRI, a NamedNode, or an XSD local name such as 'int')
|
|
685
|
+
* names the datatype; the value must be in its value space, else a
|
|
686
|
+
* FactoidalError with code 'literal.value'.
|
|
687
|
+
*/
|
|
688
|
+
export function literalFromValue(
|
|
689
|
+
value: boolean | number | bigint | string | Date,
|
|
690
|
+
options?: { datatype?: string | NamedNode }
|
|
691
|
+
): Literal;
|
|
692
|
+
|
|
564
693
|
/** The engine's name tables: format names, entailment regimes, query outputs, pack syntaxes. */
|
|
565
694
|
export function engineTables(): Promise<Record<string, unknown>>;
|
|
566
695
|
|
|
696
|
+
/**
|
|
697
|
+
* How Dataset.has, match and delete compare the object position
|
|
698
|
+
* (https://github.com/danbri/factoidal/issues/1052). 'term' (the default):
|
|
699
|
+
* RDF term equality. 'value': a literal object matches by value (sameValue()).
|
|
700
|
+
*/
|
|
701
|
+
export interface MatchOptions {
|
|
702
|
+
match?: 'term' | 'value';
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* SPARQL 1.1 `=` on two RDF terms (sections 17.3 and 17.4.1.7), decided by the
|
|
707
|
+
* engine: `true` the same value (`"01"^^xsd:integer` and `"1.0"^^xsd:decimal`),
|
|
708
|
+
* `false` different values, `null` incomparable (the operator's type error:
|
|
709
|
+
* two different literals of an unknown datatype, an ill-typed literal and
|
|
710
|
+
* another literal, `xsd:integer` and `xsd:boolean`). `"NaN"^^xsd:double` is
|
|
711
|
+
* not the same value as itself. A term is an RDF/JS term or an N-Triples term
|
|
712
|
+
* string. Synchronous: the engine must be loaded (`await ready()`).
|
|
713
|
+
*/
|
|
714
|
+
export function sameValue(a: Term | string, b: Term | string): boolean | null;
|
|
715
|
+
|
|
716
|
+
/**
|
|
717
|
+
* The syntax of a document by its file name (or IRI path; the query and the
|
|
718
|
+
* fragment are ignored) and its media type, from the engine's table of the
|
|
719
|
+
* W3C registrations (https://github.com/danbri/factoidal/issues/1053): Turtle
|
|
720
|
+
* `text/turtle` `.ttl`, N-Triples `application/n-triples` `.nt`, N-Quads
|
|
721
|
+
* `application/n-quads` `.nq`, TriG `application/trig` `.trig`, RDF/XML
|
|
722
|
+
* `application/rdf+xml` `.rdf`, JSON-LD `application/ld+json` `.jsonld`. The
|
|
723
|
+
* media type wins when it is given (its parameters are ignored); an unknown
|
|
724
|
+
* media type does not fall back to the name. Answers a `name` of formats(),
|
|
725
|
+
* or `null`. Synchronous: the engine must be loaded (`await ready()`).
|
|
726
|
+
*/
|
|
727
|
+
export function syntaxFor(what: string | { fileName?: string; mediaType?: string }): string | null;
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* An IRI as a namespace and a local name: the local name is the longest
|
|
731
|
+
* suffix that is an XML NCName (what an RDF/XML QName can carry), `''` when
|
|
732
|
+
* there is none; `namespace + localName` is the IRI
|
|
733
|
+
* (https://github.com/danbri/factoidal/issues/1051 item 4). Synchronous.
|
|
734
|
+
*/
|
|
735
|
+
export function splitIri(iri: string | NamedNode): { namespace: string; localName: string };
|
|
736
|
+
|
|
737
|
+
/** Is the text an XML NCName (Namespaces in XML 1.0, production [4])? A prefix label check. Synchronous. */
|
|
738
|
+
export function isNCName(text: string): boolean;
|
|
739
|
+
|
|
740
|
+
/** One row of the engine's vocabulary table. A term IRI is `namespace + term`. */
|
|
741
|
+
export interface VocabularyRow {
|
|
742
|
+
prefix: string;
|
|
743
|
+
namespace: string;
|
|
744
|
+
/** Local names; empty for a namespace whose vocabulary is not in the engine table. */
|
|
745
|
+
terms: string[];
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
/**
|
|
749
|
+
* The engine's vocabulary table (https://github.com/danbri/factoidal/issues/1051
|
|
750
|
+
* item 5): rdf, rdfs, xsd and owl with their terms; foaf, dcterms, dc and
|
|
751
|
+
* schema as namespaces only. The prefixes are those of the Turtle writer. Synchronous.
|
|
752
|
+
*/
|
|
753
|
+
export function vocabularies(): VocabularyRow[];
|
|
754
|
+
|
|
755
|
+
/** The container membership property `rdf:_n` (n >= 1). Synchronous. */
|
|
756
|
+
export function memberIri(n: number): NamedNode;
|
|
757
|
+
|
|
758
|
+
/** The `n` of `rdf:_n` (no leading zero, n >= 1), or `null` for any other IRI. Synchronous. */
|
|
759
|
+
export function memberOrdinal(iri: string | NamedNode): number | null;
|
|
760
|
+
|
|
567
761
|
/** A SHACL validation-report term (see shaclValidate). */
|
|
568
762
|
export interface ShaclValidateResult {
|
|
569
763
|
conforms: boolean;
|
|
@@ -758,23 +952,43 @@ export interface EvidenceRecord {
|
|
|
758
952
|
outside?: OutsideSetting[];
|
|
759
953
|
}
|
|
760
954
|
|
|
761
|
-
/**
|
|
955
|
+
/**
|
|
956
|
+
* The value on a wire. After a node, `graph` is a value of the node's
|
|
957
|
+
* `wireOut`: a Dataset for the graph wires, text for String (a writer), the
|
|
958
|
+
* rows for Table (SELECT), a boolean for Answer (ASK), `[canonical, sha256]`
|
|
959
|
+
* for String × String (rdfcStage), the report object for ValidationReport,
|
|
960
|
+
* the explain result for ExplainGraphResult. Since 0.20.0; before, a node
|
|
961
|
+
* whose output was not a Dataset left its input on the wire.
|
|
962
|
+
*/
|
|
762
963
|
export interface Wire<G = unknown> {
|
|
763
964
|
graph: G;
|
|
764
965
|
evidence: EvidenceRecord[];
|
|
765
966
|
}
|
|
766
967
|
|
|
968
|
+
/** An input port of a node: its name and its wire. */
|
|
969
|
+
export interface NodePort {
|
|
970
|
+
readonly name: string;
|
|
971
|
+
readonly wire: string;
|
|
972
|
+
}
|
|
973
|
+
|
|
767
974
|
/** A node: a registered stage with its parameters. */
|
|
768
975
|
export interface FactoidalNode {
|
|
769
976
|
readonly stage: string;
|
|
770
977
|
readonly kind: string | null;
|
|
771
978
|
/** The engine's status of this node with its settings (see NodeStatus). */
|
|
772
979
|
readonly status: NodeStatus;
|
|
773
|
-
/** The registry status of the stage. */
|
|
774
|
-
readonly registryStatus: StageInfo['status'];
|
|
980
|
+
/** The registry status of the stage; null for a stage with more than one port (not a registry entry). */
|
|
981
|
+
readonly registryStatus: StageInfo['status'] | null;
|
|
775
982
|
readonly contract: string | null;
|
|
776
983
|
readonly assumptions: readonly string[];
|
|
777
|
-
|
|
984
|
+
/**
|
|
985
|
+
* The input ports: one port 'in' for a registry stage; for a stage with
|
|
986
|
+
* more than one port (datasetMerge: 'left', 'right'), the engine's list
|
|
987
|
+
* (op graphCheckNodes). Such a node runs only in graph().
|
|
988
|
+
*/
|
|
989
|
+
readonly ports: readonly NodePort[];
|
|
990
|
+
/** The input wire of a one-port stage; null for a stage with more than one port. */
|
|
991
|
+
readonly wireIn: string | null;
|
|
778
992
|
/**
|
|
779
993
|
* The output wire with these settings: for shippedEvaluator, 'Table' for
|
|
780
994
|
* SELECT, 'Answer' for ASK, 'Dataset' for CONSTRUCT and DESCRIBE (Lean
|
|
@@ -783,7 +997,12 @@ export interface FactoidalNode {
|
|
|
783
997
|
readonly wireOut: string;
|
|
784
998
|
readonly runnable: boolean;
|
|
785
999
|
readonly bound: boolean;
|
|
786
|
-
/**
|
|
1000
|
+
/**
|
|
1001
|
+
* The node's own copy of the settings as given (passed to the package
|
|
1002
|
+
* function that runs the stage): frozen at every depth, a Dataset cloned,
|
|
1003
|
+
* taken when node() checked them. A later change to the caller's objects
|
|
1004
|
+
* does not reach the node; a change to a Dataset here makes run() refuse.
|
|
1005
|
+
*/
|
|
787
1006
|
readonly params: Readonly<Record<string, unknown>>;
|
|
788
1007
|
/** The settings as sent to the engine: JSON values, a Dataset as {$nquads}. */
|
|
789
1008
|
readonly settingsWire: Readonly<Record<string, unknown>>;
|
|
@@ -869,17 +1088,91 @@ export function stages(): Promise<StageInfo[]>;
|
|
|
869
1088
|
*/
|
|
870
1089
|
export function node(name: string, params?: Record<string, unknown>): Promise<FactoidalNode>;
|
|
871
1090
|
|
|
872
|
-
/** Compose nodes and pipelines left to right. */
|
|
1091
|
+
/** Compose nodes and pipelines left to right. A node with more than one input port throws a TypeError (use graph()). */
|
|
873
1092
|
export function pipe(...nodes: Array<FactoidalNode | Pipeline>): Pipeline;
|
|
874
1093
|
|
|
1094
|
+
/** Where a port's value comes from: graph input `input`, or the output of node `node` (an earlier node). */
|
|
1095
|
+
export type GraphSource = { readonly input: number } | { readonly node: number };
|
|
1096
|
+
|
|
1097
|
+
/** The request of graph(). */
|
|
1098
|
+
export interface GraphSpec {
|
|
1099
|
+
/** The wire of each graph input: a wire label of stages() (e.g. 'String', 'Dataset'). */
|
|
1100
|
+
inputs?: string[];
|
|
1101
|
+
/** The nodes in order; `from` has one source per input port of the node. */
|
|
1102
|
+
nodes: Array<{ node: FactoidalNode; from: GraphSource[] }>;
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
/** An issue of the engine's static check of a graph (op graphCheckNodes, Lean graphIssues). */
|
|
1106
|
+
export type GraphIssue =
|
|
1107
|
+
| { readonly kind: 'unknownInput'; readonly node: number; readonly port: number; readonly portName: string; readonly input: number }
|
|
1108
|
+
| { readonly kind: 'forwardRef'; readonly node: number; readonly port: number; readonly portName: string; readonly ref: number }
|
|
1109
|
+
| { readonly kind: 'portCount'; readonly node: number; readonly ports: number; readonly sources: number }
|
|
1110
|
+
| { readonly kind: 'wireMismatch'; readonly node: number; readonly port: number; readonly portName: string; readonly source: string; readonly portWire: string };
|
|
1111
|
+
|
|
1112
|
+
/** The engine's check of a graph with no issue (op graphCheckNodes). */
|
|
1113
|
+
export interface GraphCheck {
|
|
1114
|
+
readonly issues: readonly GraphIssue[];
|
|
1115
|
+
/** The output wire of the last node. */
|
|
1116
|
+
readonly wireOut: string | null;
|
|
1117
|
+
/** The union of the nodes' named assumptions: the premises of Graph.guarantee_sound. */
|
|
1118
|
+
readonly assumptions: readonly string[];
|
|
1119
|
+
readonly contract: { readonly theorem: string; readonly staticCheck: string };
|
|
1120
|
+
readonly nodes: readonly {
|
|
1121
|
+
readonly name: string; readonly kind: string | null; readonly status: NodeStatus;
|
|
1122
|
+
/** null for a stage with more than one port (not a registry entry). */
|
|
1123
|
+
readonly registryStatus: StageInfo['status'] | null;
|
|
1124
|
+
readonly checked: boolean; readonly contract: string | null;
|
|
1125
|
+
readonly theorems: readonly string[]; readonly assumptions: readonly string[];
|
|
1126
|
+
readonly ports: readonly NodePort[]; readonly wireOut: string;
|
|
1127
|
+
readonly settings: Record<string, unknown>; readonly settingsDigest: string;
|
|
1128
|
+
readonly roles: Readonly<Record<string, string>>;
|
|
1129
|
+
readonly outside: readonly OutsideSetting[];
|
|
1130
|
+
readonly derived: Readonly<Record<string, string>>;
|
|
1131
|
+
}[];
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/** A graph from graph(): checked by the engine, with no issue. */
|
|
1135
|
+
export interface FactoidalGraph {
|
|
1136
|
+
readonly inputs: readonly string[];
|
|
1137
|
+
readonly nodes: readonly { readonly node: FactoidalNode; readonly from: readonly GraphSource[] }[];
|
|
1138
|
+
readonly wireOut: string | null;
|
|
1139
|
+
readonly assumptions: readonly string[];
|
|
1140
|
+
readonly check: GraphCheck;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
/** The result of run() on a graph. */
|
|
1144
|
+
export interface GraphRunResult<G = unknown> extends RunResult<G> {
|
|
1145
|
+
/** The output of each node, in order; `graph` is the last one. */
|
|
1146
|
+
values: unknown[];
|
|
1147
|
+
issues: GraphIssue[];
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* A pipeline that is an acyclic graph of nodes with named input ports
|
|
1152
|
+
* (https://github.com/danbri/factoidal/issues/1130). The engine's op
|
|
1153
|
+
* graphCheckNodes checks it: a graph with an issue throws a FactoidalError
|
|
1154
|
+
* (code 'op.failed') whose `issues` is the engine's list; an engine without
|
|
1155
|
+
* the op throws code 'op.unknown'. Since 0.21.0.
|
|
1156
|
+
*/
|
|
1157
|
+
export function graph(spec: GraphSpec): FactoidalGraph;
|
|
1158
|
+
|
|
875
1159
|
/**
|
|
876
1160
|
* Run a node or pipeline on `input` (a Wire, or the graph: text for a
|
|
877
1161
|
* reader, else a Dataset or data input). Rejects before any node runs when
|
|
878
1162
|
* a node's stage has status 'missing' (unless `options.unchecked`) or has
|
|
879
|
-
* no package function,
|
|
880
|
-
* well typed (unless `options.unchecked`; then `proved` is false)
|
|
1163
|
+
* no package function, when the engine's check finds the pipeline not
|
|
1164
|
+
* well typed (unless `options.unchecked`; then `proved` is false), or when a
|
|
1165
|
+
* node's settings changed after node() checked them. Rejects with code
|
|
1166
|
+
* 'op.failed' when a node's runner gives a value that is not of the node's
|
|
1167
|
+
* `wireOut` (see Wire).
|
|
881
1168
|
*/
|
|
882
1169
|
export function run(pipeline: FactoidalNode | Pipeline, input: unknown, options?: RunOptions): Promise<RunResult>;
|
|
1170
|
+
/**
|
|
1171
|
+
* Run a graph on `inputs`, one value per graph input. Each node runs on the
|
|
1172
|
+
* values of its sources (a node with more than one port gets them in port
|
|
1173
|
+
* order); one evidence record per node, with `node` (its index) and `from`.
|
|
1174
|
+
*/
|
|
1175
|
+
export function run(graph: FactoidalGraph, inputs: unknown[], options?: RunOptions): Promise<GraphRunResult>;
|
|
883
1176
|
|
|
884
1177
|
/** Literature-name alias for coreRdfsClosure (ρdf). */
|
|
885
1178
|
export function rhoDfClosure(
|
|
@@ -1191,6 +1484,12 @@ export interface Sbm11Store {
|
|
|
1191
1484
|
/** the generation CURRENT names, or "" when the source is a generation */
|
|
1192
1485
|
generation: string;
|
|
1193
1486
|
terms: number;
|
|
1487
|
+
/** how the engine checks reads; undefined from a wasm module built before the Merkle check */
|
|
1488
|
+
verify: 'merkle' | 'none' | undefined;
|
|
1489
|
+
/** the SHA-256 of the bytes of manifest.sbm11, 64 lowercase hex digits, as
|
|
1490
|
+
* the engine computed it at open (pin it, then give it as
|
|
1491
|
+
* `manifestSha256`); undefined from a wasm module built before issue 1105 */
|
|
1492
|
+
manifestSha256: string | undefined;
|
|
1194
1493
|
query(sparql: string, options?: { base?: string; sparql12?: boolean; reference?: boolean }): Sbm11Answer;
|
|
1195
1494
|
/** the resources the reader read, when its reader records them (lwsSbm11Reader) */
|
|
1196
1495
|
readonly evidence: Sbm11ReadEvidence[] | undefined;
|
|
@@ -1198,8 +1497,16 @@ export interface Sbm11Store {
|
|
|
1198
1497
|
}
|
|
1199
1498
|
|
|
1200
1499
|
/** Open an SBM11 generation (https://github.com/danbri/factoidal/issues/1009).
|
|
1201
|
-
* Node: `source` is a directory unless a reader is given or registered.
|
|
1202
|
-
|
|
1500
|
+
* Node: `source` is a directory unless a reader is given or registered.
|
|
1501
|
+
* `verify` (default 'merkle'): the engine checks every byte it decodes against
|
|
1502
|
+
* the manifest's Merkle roots and refuses a changed file with its name;
|
|
1503
|
+
* 'none' checks lengths only.
|
|
1504
|
+
* `manifestSha256`: the trust anchor, the SHA-256 of the bytes of
|
|
1505
|
+
* manifest.sbm11 as 64 hex digits (https://github.com/danbri/factoidal/issues/1105);
|
|
1506
|
+
* the engine refuses the open when the manifest has another digest. */
|
|
1507
|
+
export function openSbm11(source: string, options?: {
|
|
1508
|
+
reader?: Sbm11Reader; verify?: 'merkle' | 'none'; manifestSha256?: string
|
|
1509
|
+
}): Promise<Sbm11Store>;
|
|
1203
1510
|
|
|
1204
1511
|
/** Serve `source` with `reader`; `null` removes it. */
|
|
1205
1512
|
export function registerSbm11Source(source: string, reader: Sbm11Reader | null): void;
|
|
@@ -1563,6 +1870,45 @@ export function vcEd25519Verify(
|
|
|
1563
1870
|
signatureHex: string
|
|
1564
1871
|
): Promise<boolean>;
|
|
1565
1872
|
|
|
1873
|
+
/**
|
|
1874
|
+
* Decrypt every xenc:EncryptedData of an XML document (XML Encryption 1.1).
|
|
1875
|
+
* RSA-OAEP, ECDH-ES and X25519 run in the wasm (HACL*); AES runs in the
|
|
1876
|
+
* host's WebCrypto. Every failure after the structure check is the one
|
|
1877
|
+
* error "XML decryption failed".
|
|
1878
|
+
*/
|
|
1879
|
+
export function xmlDecrypt(
|
|
1880
|
+
document: string,
|
|
1881
|
+
options: { keys: object[]; allowCbc?: boolean }
|
|
1882
|
+
): Promise<{ document: string; canonical: string }>;
|
|
1883
|
+
|
|
1884
|
+
/** Encrypt an XML document element, or its content, for one recipient. */
|
|
1885
|
+
export function xmlEncrypt(
|
|
1886
|
+
document: string,
|
|
1887
|
+
options: {
|
|
1888
|
+
recipient: object;
|
|
1889
|
+
algorithm?: 'aes128-gcm' | 'aes256-gcm';
|
|
1890
|
+
keyTransport?: 'rsa-oaep-mgf1p' | 'rsa-oaep-sha256';
|
|
1891
|
+
keyWrap?: 'kw-aes128' | 'kw-aes256';
|
|
1892
|
+
content?: boolean;
|
|
1893
|
+
saml?: boolean;
|
|
1894
|
+
}
|
|
1895
|
+
): Promise<{ document: string; canonical: string }>;
|
|
1896
|
+
|
|
1897
|
+
/**
|
|
1898
|
+
* Decrypt a compact JWE (RFC 7516). Every failure after the allowlist is
|
|
1899
|
+
* the one error "decryption failed".
|
|
1900
|
+
*/
|
|
1901
|
+
export function jweDecrypt(
|
|
1902
|
+
token: string,
|
|
1903
|
+
options: { jwk: object }
|
|
1904
|
+
): Promise<{ header: Record<string, unknown>; plaintext: Uint8Array }>;
|
|
1905
|
+
|
|
1906
|
+
/** Encrypt to a compact JWE (RFC 7516). */
|
|
1907
|
+
export function jweEncrypt(
|
|
1908
|
+
plaintext: Uint8Array | string,
|
|
1909
|
+
options: { alg: string; enc: string; jwk: object; header?: Record<string, unknown> }
|
|
1910
|
+
): Promise<string>;
|
|
1911
|
+
|
|
1566
1912
|
/**
|
|
1567
1913
|
* Create an eddsa-rdfc-2022 Data Integrity proofValue (multibase-z,
|
|
1568
1914
|
* base58btc) over already-canonicalized inputs — RDFC-1.0 canonical
|
|
@@ -1631,6 +1977,70 @@ export function vcCheckRelatedResourceDigests(
|
|
|
1631
1977
|
credentialJson: string
|
|
1632
1978
|
): Promise<{ valid: boolean; reason?: string }>;
|
|
1633
1979
|
|
|
1980
|
+
/** One failed MUST of CID 1.0 §2 (cidValidate). */
|
|
1981
|
+
export interface CidValidationError {
|
|
1982
|
+
/** The engine's name of the failed MUST, e.g. 'idNotUrl', 'jwkPrivateMember'. */
|
|
1983
|
+
code: string;
|
|
1984
|
+
message: string;
|
|
1985
|
+
/** RFC 6901 JSON Pointer to the member, e.g. '/verificationMethod/1/publicKeyJwk/d'; '' is the whole document. */
|
|
1986
|
+
path: string;
|
|
1987
|
+
}
|
|
1988
|
+
|
|
1989
|
+
/**
|
|
1990
|
+
* Controlled Identifiers v1.0 §2 (https://www.w3.org/TR/cid-1.0/): check a
|
|
1991
|
+
* controlled identifier document. `valid` is the engine's answer
|
|
1992
|
+
* (L4Factoidal.CID.parseDocument); `errors` lists every failed MUST it found,
|
|
1993
|
+
* empty when valid. Issue 1100 item 9.
|
|
1994
|
+
*/
|
|
1995
|
+
export function cidValidate(doc: string | object): Promise<{ valid: boolean; errors: CidValidationError[] }>;
|
|
1996
|
+
|
|
1997
|
+
/** An RFC 9457 problem details object. */
|
|
1998
|
+
export interface CidProblem {
|
|
1999
|
+
/** https://w3id.org/security#<NAME> for a §3.5 error; a tag: URI for the others. */
|
|
2000
|
+
type: string;
|
|
2001
|
+
title: string;
|
|
2002
|
+
detail: string;
|
|
2003
|
+
}
|
|
2004
|
+
|
|
2005
|
+
export interface CidRetrieveOptions {
|
|
2006
|
+
/**
|
|
2007
|
+
* GET the URL the engine names. Called as fetch(url, init) with
|
|
2008
|
+
* init.headers.accept, init.redirect 'manual' and, when the engine chose
|
|
2009
|
+
* one, init.address (the address to connect to). Answers a Response, or
|
|
2010
|
+
* { status, headers: { get(name) }, text() }. Default: Node and Deno
|
|
2011
|
+
* connect to init.address; a browser uses the page's fetch.
|
|
2012
|
+
*/
|
|
2013
|
+
fetch?: (url: string, init: { method: 'GET'; headers: { accept: string }; redirect: 'manual'; address?: string }) =>
|
|
2014
|
+
Promise<{ status: number; headers: { get(name: string): string | null }; text(): Promise<string> }>;
|
|
2015
|
+
/** Every address of a host name. Default: the system resolver (Node, Deno); none in a browser. null: none. */
|
|
2016
|
+
resolve?: ((host: string) => Promise<string[]>) | null;
|
|
2017
|
+
/** Refuse a method that has expired or been revoked at this time (a Date, or seconds since the epoch). */
|
|
2018
|
+
now?: Date | number;
|
|
2019
|
+
/** Allow an http document URL (default: https only). */
|
|
2020
|
+
allowHttp?: boolean;
|
|
2021
|
+
/** Allow loopback, link-local, private and localhost addresses (default: refused). */
|
|
2022
|
+
allowPrivateFetch?: boolean;
|
|
2023
|
+
}
|
|
2024
|
+
|
|
2025
|
+
/**
|
|
2026
|
+
* Controlled Identifiers v1.0 §3.3 Retrieve Verification Method. The engine
|
|
2027
|
+
* names each fetch and decides each answer (the private-address guard of the
|
|
2028
|
+
* authorization server, the status, the Content-Type: application/cid,
|
|
2029
|
+
* application/cid+json, application/ld+json or application/json, then §3.3);
|
|
2030
|
+
* this function does the fetch. Never rejects for a failed retrieval: it
|
|
2031
|
+
* answers `ok: false` with the §3.5 name (or FETCH_REFUSED, FETCH_FAILED,
|
|
2032
|
+
* UNSUPPORTED_MEDIA_TYPE, VERIFICATION_METHOD_NOT_IN_FORCE) and an RFC 9457
|
|
2033
|
+
* object. Issue 1100 items 7 and 9.
|
|
2034
|
+
*/
|
|
2035
|
+
export function cidRetrieveVerificationMethod(
|
|
2036
|
+
url: string,
|
|
2037
|
+
relationship: 'authentication' | 'assertionMethod' | 'keyAgreement' | 'capabilityInvocation' | 'capabilityDelegation',
|
|
2038
|
+
options?: CidRetrieveOptions
|
|
2039
|
+
): Promise<
|
|
2040
|
+
| { ok: true; verificationMethod: Record<string, unknown>; controllerDocument: string }
|
|
2041
|
+
| { ok: false; code: string; problem: CidProblem }
|
|
2042
|
+
>;
|
|
2043
|
+
|
|
1634
2044
|
/**
|
|
1635
2045
|
* Feature probe: which ops the loaded wasm module serves. A module older
|
|
1636
2046
|
* than this package can lack some; an operation whose op is missing
|
|
@@ -1645,6 +2055,8 @@ export function capabilities(): Promise<{
|
|
|
1645
2055
|
canonicalHash: boolean;
|
|
1646
2056
|
shacl: boolean;
|
|
1647
2057
|
shex: boolean;
|
|
2058
|
+
/** the engine has the SPARQL 1.2 RL op (datasetSparqlRlInfer) */
|
|
2059
|
+
sparqlRl: boolean;
|
|
1648
2060
|
owlClosure: boolean;
|
|
1649
2061
|
explain: boolean;
|
|
1650
2062
|
stages: boolean;
|
|
@@ -1652,6 +2064,10 @@ export function capabilities(): Promise<{
|
|
|
1652
2064
|
pipelineCheck: boolean;
|
|
1653
2065
|
/** The op pipelineCheckNodes: node settings in evidence, and the evaluator's output wire from the query form. */
|
|
1654
2066
|
pipelineCheckNodes: boolean;
|
|
2067
|
+
/** The op graphCheckNodes: graph() and run() of a graph, and node('datasetMerge'). */
|
|
2068
|
+
graphCheck: boolean;
|
|
2069
|
+
/** The op datasetMerge: datasetMerge(). */
|
|
2070
|
+
datasetMerge: boolean;
|
|
1655
2071
|
tableau: boolean;
|
|
1656
2072
|
rml: boolean;
|
|
1657
2073
|
csvw: boolean;
|
|
@@ -1679,6 +2095,10 @@ export function capabilities(): Promise<{
|
|
|
1679
2095
|
store: boolean;
|
|
1680
2096
|
/** The deltaLog* functions (deltaLogEncode, deltaLogDecode, deltaLogMerge). */
|
|
1681
2097
|
deltaLog: boolean;
|
|
2098
|
+
/** ops literalValue and literalFromValue (issue 1051). */
|
|
2099
|
+
literalValues: boolean;
|
|
2100
|
+
/** ops cidValidate and cidRetrieve (issue 1100). */
|
|
2101
|
+
cid: boolean;
|
|
1682
2102
|
/** 'full': the whole library is in the wasm module. */
|
|
1683
2103
|
profile: 'full' | string;
|
|
1684
2104
|
/** The dispatch ABI version string of the loaded wasm module. */
|
|
@@ -1757,15 +2177,24 @@ declare const _default: {
|
|
|
1757
2177
|
update: typeof update;
|
|
1758
2178
|
openDataset: typeof openDataset;
|
|
1759
2179
|
closure: typeof closure;
|
|
2180
|
+
sparqlRlInfer: typeof sparqlRlInfer;
|
|
1760
2181
|
formats: typeof formats;
|
|
1761
2182
|
serialize: typeof serialize;
|
|
1762
2183
|
canonicalize: typeof canonicalize;
|
|
1763
2184
|
graphs: typeof graphs;
|
|
1764
2185
|
canonicalHash: typeof canonicalHash;
|
|
2186
|
+
asDefaultGraph: typeof asDefaultGraph;
|
|
1765
2187
|
isomorphic: typeof isomorphic;
|
|
1766
2188
|
fromQuads: typeof fromQuads;
|
|
1767
2189
|
ready: typeof ready;
|
|
1768
2190
|
engineTables: typeof engineTables;
|
|
2191
|
+
sameValue: typeof sameValue;
|
|
2192
|
+
syntaxFor: typeof syntaxFor;
|
|
2193
|
+
splitIri: typeof splitIri;
|
|
2194
|
+
isNCName: typeof isNCName;
|
|
2195
|
+
vocabularies: typeof vocabularies;
|
|
2196
|
+
memberIri: typeof memberIri;
|
|
2197
|
+
memberOrdinal: typeof memberOrdinal;
|
|
1769
2198
|
shaclValidate: typeof shaclValidate;
|
|
1770
2199
|
shexValidate: typeof shexValidate;
|
|
1771
2200
|
owlClosure: typeof owlClosure;
|
|
@@ -1809,18 +2238,28 @@ declare const _default: {
|
|
|
1809
2238
|
vcEd25519SecretToPublic: typeof vcEd25519SecretToPublic;
|
|
1810
2239
|
vcEd25519Sign: typeof vcEd25519Sign;
|
|
1811
2240
|
vcEd25519Verify: typeof vcEd25519Verify;
|
|
2241
|
+
xmlDecrypt: typeof xmlDecrypt;
|
|
2242
|
+
xmlEncrypt: typeof xmlEncrypt;
|
|
2243
|
+
jweDecrypt: typeof jweDecrypt;
|
|
2244
|
+
jweEncrypt: typeof jweEncrypt;
|
|
1812
2245
|
vcEddsaCreateFromCanonical: typeof vcEddsaCreateFromCanonical;
|
|
1813
2246
|
vcEddsaVerifyFromCanonical: typeof vcEddsaVerifyFromCanonical;
|
|
1814
2247
|
vcCheckCredential: typeof vcCheckCredential;
|
|
1815
2248
|
vcCheckCredentialSubject: typeof vcCheckCredentialSubject;
|
|
1816
2249
|
vcCheckNoDataLoss: typeof vcCheckNoDataLoss;
|
|
1817
2250
|
vcCheckRelatedResourceDigests: typeof vcCheckRelatedResourceDigests;
|
|
2251
|
+
cidValidate: typeof cidValidate;
|
|
2252
|
+
cidRetrieveVerificationMethod: typeof cidRetrieveVerificationMethod;
|
|
1818
2253
|
capabilities: typeof capabilities;
|
|
1819
2254
|
Dataset: typeof Dataset;
|
|
1820
2255
|
Store: typeof Store;
|
|
1821
2256
|
FactoidalError: typeof FactoidalError;
|
|
1822
2257
|
dataFactory: DataFactory;
|
|
1823
2258
|
queryRaw: typeof queryRaw;
|
|
2259
|
+
literalValue: typeof literalValue;
|
|
2260
|
+
isValidLiteral: typeof isValidLiteral;
|
|
2261
|
+
canonicalLiteral: typeof canonicalLiteral;
|
|
2262
|
+
literalFromValue: typeof literalFromValue;
|
|
1824
2263
|
version: string;
|
|
1825
2264
|
engine: string;
|
|
1826
2265
|
};
|