rdflib 2.2.10 → 2.2.12-5f141ca2
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/.babelrc +0 -0
- package/README.md +1 -0
- package/changes.txt +0 -0
- package/dist/rdflib.min.js +62 -0
- package/dist/rdflib.min.js.map +1 -0
- package/esm/blank-node.js +137 -0
- package/esm/class-order.js +12 -0
- package/esm/collection.js +173 -0
- package/esm/convert.js +61 -0
- package/esm/default-graph.js +57 -0
- package/esm/empty.js +46 -0
- package/esm/factories/canonical-data-factory.js +204 -0
- package/esm/factories/extended-term-factory.js +55 -0
- package/esm/factories/factory-types.js +18 -0
- package/esm/factories/rdflib-data-factory.js +55 -0
- package/esm/fetcher.js +2180 -0
- package/esm/formula.js +987 -0
- package/esm/index.js +64 -0
- package/esm/jsonldparser.js +122 -0
- package/esm/jsonparser.js +60 -0
- package/esm/literal.js +236 -0
- package/esm/log.js +13 -0
- package/esm/n3parser.js +1854 -0
- package/esm/named-node.js +154 -0
- package/esm/namespace.js +17 -0
- package/esm/node-internal.js +151 -0
- package/esm/node.js +46 -0
- package/esm/parse.js +138 -0
- package/esm/patch-parser.js +110 -0
- package/esm/query-to-sparql.js +83 -0
- package/esm/query.js +620 -0
- package/esm/rdfaparser.js +1197 -0
- package/esm/rdfxmlparser.js +588 -0
- package/esm/serialize.js +95 -0
- package/esm/serializer.js +1162 -0
- package/esm/sparql-to-query.js +566 -0
- package/esm/statement.js +128 -0
- package/esm/store.js +1306 -0
- package/esm/tf-types.js +1 -0
- package/esm/types.js +25 -0
- package/esm/update-manager.js +1252 -0
- package/esm/updates-via.js +197 -0
- package/esm/uri.js +245 -0
- package/esm/utils/default-graph-uri.js +4 -0
- package/esm/utils/termValue.js +8 -0
- package/esm/utils/terms.js +72 -0
- package/esm/utils-js.js +348 -0
- package/esm/utils.js +103 -0
- package/esm/variable.js +101 -0
- package/esm/xsd-internal.js +10 -0
- package/esm/xsd.js +15 -0
- package/lib/blank-node.d.ts +44 -0
- package/lib/blank-node.js +0 -0
- package/lib/class-order.d.ts +7 -0
- package/lib/class-order.js +0 -0
- package/lib/collection.d.ts +65 -0
- package/lib/collection.js +0 -0
- package/lib/convert.d.ts +2 -0
- package/lib/convert.js +0 -0
- package/lib/default-graph.d.ts +13 -0
- package/lib/default-graph.js +0 -0
- package/lib/empty.d.ts +11 -0
- package/lib/empty.js +0 -0
- package/lib/factories/canonical-data-factory.d.ts +6 -0
- package/lib/factories/canonical-data-factory.js +0 -0
- package/lib/factories/extended-term-factory.d.ts +13 -0
- package/lib/factories/extended-term-factory.js +0 -0
- package/lib/factories/factory-types.d.ts +67 -0
- package/lib/factories/factory-types.js +0 -0
- package/lib/factories/rdflib-data-factory.d.ts +4 -0
- package/lib/factories/rdflib-data-factory.js +0 -0
- package/lib/fetcher.d.ts +443 -0
- package/lib/fetcher.js +3 -2
- package/lib/formula.d.ts +327 -0
- package/lib/formula.js +0 -0
- package/lib/index.d.ts +40 -0
- package/lib/index.js +0 -0
- package/lib/jsonldparser.d.ts +13 -0
- package/lib/jsonldparser.js +0 -0
- package/lib/jsonparser.d.ts +4 -0
- package/lib/jsonparser.js +0 -0
- package/lib/literal.d.ts +67 -0
- package/lib/literal.js +0 -0
- package/lib/log.d.ts +15 -0
- package/lib/log.js +0 -0
- package/lib/n3parser.d.ts +62 -0
- package/lib/n3parser.js +1334 -1289
- package/lib/named-node.d.ts +44 -0
- package/lib/named-node.js +0 -0
- package/lib/namespace.d.ts +7 -0
- package/lib/namespace.js +0 -0
- package/lib/node-internal.d.ts +63 -0
- package/lib/node-internal.js +0 -0
- package/lib/node.d.ts +2 -0
- package/lib/node.js +0 -0
- package/lib/parse.d.ts +16 -0
- package/lib/parse.js +0 -0
- package/lib/patch-parser.d.ts +3 -0
- package/lib/patch-parser.js +0 -0
- package/lib/query-to-sparql.d.ts +1 -0
- package/lib/query-to-sparql.js +0 -0
- package/lib/query.d.ts +27 -0
- package/lib/query.js +0 -0
- package/lib/rdfaparser.d.ts +78 -0
- package/lib/rdfaparser.js +0 -0
- package/lib/rdfxmlparser.d.ts +60 -0
- package/lib/rdfxmlparser.js +430 -413
- package/lib/serialize.d.ts +23 -0
- package/lib/serialize.js +1 -1
- package/lib/serializer.d.ts +54 -0
- package/lib/serializer.js +851 -824
- package/lib/sparql-to-query.d.ts +6 -0
- package/lib/sparql-to-query.js +0 -0
- package/lib/statement.d.ts +55 -0
- package/lib/statement.js +0 -0
- package/lib/store.d.ts +302 -0
- package/lib/store.js +0 -0
- package/lib/tf-types.d.ts +151 -0
- package/lib/tf-types.js +0 -0
- package/lib/types.d.ts +68 -0
- package/lib/types.js +0 -0
- package/lib/update-manager.d.ts +198 -0
- package/lib/update-manager.js +0 -0
- package/lib/updates-via.d.ts +26 -0
- package/lib/updates-via.js +0 -0
- package/lib/uri.d.ts +33 -0
- package/lib/uri.js +0 -0
- package/lib/utils/default-graph-uri.d.ts +3 -0
- package/lib/utils/default-graph-uri.js +0 -0
- package/lib/utils/termValue.d.ts +3 -0
- package/lib/utils/termValue.js +0 -0
- package/lib/utils/terms.d.ts +33 -0
- package/lib/utils/terms.js +0 -0
- package/lib/utils-js.d.ts +50 -0
- package/lib/utils-js.js +0 -0
- package/lib/utils.d.ts +20 -0
- package/lib/utils.js +0 -0
- package/lib/variable.d.ts +29 -0
- package/lib/variable.js +0 -0
- package/lib/xsd-internal.d.ts +11 -0
- package/lib/xsd-internal.js +0 -0
- package/lib/xsd.d.ts +19 -0
- package/lib/xsd.js +8 -14
- package/package.json +3 -3
- package/src/blank-node.ts +0 -0
- package/src/class-order.ts +0 -0
- package/src/collection.ts +0 -0
- package/src/convert.js +0 -0
- package/src/default-graph.ts +0 -0
- package/src/empty.ts +0 -0
- package/src/factories/canonical-data-factory.ts +0 -0
- package/src/factories/extended-term-factory.ts +0 -0
- package/src/factories/factory-types.ts +0 -0
- package/src/factories/rdflib-data-factory.ts +0 -0
- package/src/fetcher.ts +6 -3
- package/src/formula.ts +0 -0
- package/src/index.ts +0 -0
- package/src/jsonldparser.js +0 -0
- package/src/jsonparser.js +0 -0
- package/src/literal.ts +0 -0
- package/src/log.js +0 -0
- package/src/n3parser.js +1114 -1110
- package/src/named-node.ts +0 -0
- package/src/namespace.ts +0 -0
- package/src/node-internal.ts +0 -0
- package/src/node.ts +0 -0
- package/src/parse.ts +0 -0
- package/src/patch-parser.js +0 -0
- package/src/query-to-sparql.js +0 -0
- package/src/query.js +0 -0
- package/src/rdfaparser.js +0 -0
- package/src/rdfxmlparser.js +22 -21
- package/src/serialize.ts +3 -3
- package/src/serializer.js +74 -62
- package/src/sparql-to-query.js +0 -0
- package/src/statement.ts +0 -0
- package/src/store.ts +0 -0
- package/src/tf-types.ts +0 -0
- package/src/types.ts +0 -0
- package/src/update-manager.ts +0 -0
- package/src/updates-via.js +0 -0
- package/src/uri.ts +0 -0
- package/src/utils/default-graph-uri.ts +0 -0
- package/src/utils/termValue.ts +0 -0
- package/src/utils/terms.ts +0 -0
- package/src/utils-js.js +0 -0
- package/src/utils.ts +0 -0
- package/src/variable.ts +0 -0
- package/src/xsd-internal.js +0 -0
- package/src/xsd.js +16 -14
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @SPARQL: SPARQL text that is converted to a query object which is returned.
|
|
3
|
+
* @testMode: testing flag. Prevents loading of sources.
|
|
4
|
+
*/
|
|
5
|
+
export default function SPARQLToQuery(SPARQL: any, testMode: any, kb: any): false | Query;
|
|
6
|
+
import { Query } from "./query";
|
package/lib/sparql-to-query.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Bindings, GraphType, ObjectType, PredicateType, SubjectType } from './types';
|
|
2
|
+
import { Quad, DefaultGraph } from './tf-types';
|
|
3
|
+
/** A Statement represents an RDF Triple or Quad. */
|
|
4
|
+
export default class Statement<S extends SubjectType = SubjectType, P extends PredicateType = PredicateType, O extends ObjectType = ObjectType, G extends GraphType = GraphType> implements Quad<S, P, O, G | DefaultGraph> {
|
|
5
|
+
/** The subject of the triple. What the Statement is about. */
|
|
6
|
+
subject: S;
|
|
7
|
+
/** The relationship which is asserted between the subject and object */
|
|
8
|
+
predicate: P;
|
|
9
|
+
/** The thing or data value which is asserted to be related to the subject */
|
|
10
|
+
object: O;
|
|
11
|
+
/**
|
|
12
|
+
* The graph param is a named node of the document in which the triple when
|
|
13
|
+
* it is stored on the web.
|
|
14
|
+
*/
|
|
15
|
+
graph: G | DefaultGraph;
|
|
16
|
+
/**
|
|
17
|
+
* Construct a new statement
|
|
18
|
+
*
|
|
19
|
+
* @param subject - The subject of the triple. What the fact is about
|
|
20
|
+
* @param predicate - The relationship which is asserted between the subject and object
|
|
21
|
+
* @param object - The thing or data value which is asserted to be related to the subject
|
|
22
|
+
* @param {NamedNode} graph - The document where the triple is or was or will be stored on the web.
|
|
23
|
+
*
|
|
24
|
+
* The graph param is a named node of the document in which the triple when it is stored
|
|
25
|
+
* on the web. It exists because when you have read data from various places in the web,
|
|
26
|
+
* the “graph” tells you _why_ you have the triple. (At the moment, it is just the
|
|
27
|
+
* document, in future it could be an inference step)
|
|
28
|
+
*
|
|
29
|
+
* When you do UpdateManager.update() then the graph’s of all the statements must be the same,
|
|
30
|
+
* and give the document you are patching. In future, we may have a more
|
|
31
|
+
* powerful update() which can update more than one document.
|
|
32
|
+
*/
|
|
33
|
+
constructor(subject: S, predicate: P, object: O, graph?: G | DefaultGraph);
|
|
34
|
+
/** Alias for graph, favored by Tim */
|
|
35
|
+
get why(): DefaultGraph | G;
|
|
36
|
+
set why(g: DefaultGraph | G);
|
|
37
|
+
/**
|
|
38
|
+
* Checks whether two statements are the same
|
|
39
|
+
* @param other - The other statement
|
|
40
|
+
*/
|
|
41
|
+
equals(other: Quad): boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a statement with the bindings substituted
|
|
44
|
+
* @param bindings The bindings
|
|
45
|
+
*/
|
|
46
|
+
substitute(bindings: Bindings): Statement;
|
|
47
|
+
/** Creates a canonical string representation of this statement. */
|
|
48
|
+
toCanonical(): string;
|
|
49
|
+
/** Creates a n-triples string representation of this statement */
|
|
50
|
+
toNT(): string;
|
|
51
|
+
/** Creates a n-quads string representation of this statement */
|
|
52
|
+
toNQ(): string;
|
|
53
|
+
/** Creates a string representation of this statement */
|
|
54
|
+
toString(): string;
|
|
55
|
+
}
|
package/lib/statement.js
CHANGED
|
File without changes
|
package/lib/store.d.ts
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
import { defaultGraphURI } from './factories/canonical-data-factory';
|
|
2
|
+
import Formula, { FormulaOpts } from './formula';
|
|
3
|
+
import Node from './node';
|
|
4
|
+
import Variable from './variable';
|
|
5
|
+
import { Query } from './query';
|
|
6
|
+
import UpdateManager from './update-manager';
|
|
7
|
+
import { Bindings } from './types';
|
|
8
|
+
import Statement from './statement';
|
|
9
|
+
import NamedNode from './named-node';
|
|
10
|
+
import Fetcher from './fetcher';
|
|
11
|
+
import { Quad_Graph, NamedNode as TFNamedNode, Quad_Object, Quad_Predicate, Quad, Quad_Subject, Term } from './tf-types';
|
|
12
|
+
import BlankNode from './blank-node';
|
|
13
|
+
declare type FeaturesType = Array<('sameAs' | 'InverseFunctionalProperty' | 'FunctionalProperty')> | undefined;
|
|
14
|
+
export { defaultGraphURI };
|
|
15
|
+
/**
|
|
16
|
+
* Indexed Formula aka Store
|
|
17
|
+
*/
|
|
18
|
+
export default class IndexedFormula extends Formula {
|
|
19
|
+
/**
|
|
20
|
+
* An UpdateManager initialised to this store
|
|
21
|
+
*/
|
|
22
|
+
updater?: UpdateManager;
|
|
23
|
+
/**
|
|
24
|
+
* Dictionary of namespace prefixes
|
|
25
|
+
*/
|
|
26
|
+
namespaces: {
|
|
27
|
+
[key: string]: string;
|
|
28
|
+
};
|
|
29
|
+
/** Map of iri predicates to functions to call when adding { s type X } */
|
|
30
|
+
classActions: {
|
|
31
|
+
[k: string]: Function[];
|
|
32
|
+
};
|
|
33
|
+
/** Map of iri predicates to functions to call when getting statement with {s X o} */
|
|
34
|
+
propertyActions: {
|
|
35
|
+
[k: string]: Function[];
|
|
36
|
+
};
|
|
37
|
+
/** Redirect to lexically smaller equivalent symbol */
|
|
38
|
+
redirections: any[];
|
|
39
|
+
/** Reverse mapping to redirection: aliases for this */
|
|
40
|
+
aliases: any[];
|
|
41
|
+
/** Redirections we got from HTTP */
|
|
42
|
+
HTTPRedirects: Statement[];
|
|
43
|
+
/** Array of statements with this X as subject */
|
|
44
|
+
subjectIndex: Statement[];
|
|
45
|
+
/** Array of statements with this X as predicate */
|
|
46
|
+
predicateIndex: Statement[];
|
|
47
|
+
/** Array of statements with this X as object */
|
|
48
|
+
objectIndex: Statement[];
|
|
49
|
+
/** Array of statements with X as provenance */
|
|
50
|
+
whyIndex: Statement[];
|
|
51
|
+
index: [
|
|
52
|
+
Statement[],
|
|
53
|
+
Statement[],
|
|
54
|
+
Statement[],
|
|
55
|
+
Statement[]
|
|
56
|
+
];
|
|
57
|
+
features: FeaturesType;
|
|
58
|
+
static handleRDFType: Function;
|
|
59
|
+
_universalVariables?: NamedNode[];
|
|
60
|
+
_existentialVariables?: BlankNode[];
|
|
61
|
+
/** Function to remove quads from the store arrays with */
|
|
62
|
+
private rdfArrayRemove;
|
|
63
|
+
/** Callbacks which are triggered after a statement has been added to the store */
|
|
64
|
+
private dataCallbacks?;
|
|
65
|
+
/**
|
|
66
|
+
* Creates a new formula
|
|
67
|
+
* @param features - What sort of automatic processing to do? Array of string
|
|
68
|
+
* @param features.sameAs - Smush together A and B nodes whenever { A sameAs B }
|
|
69
|
+
* @param opts
|
|
70
|
+
* @param [opts.rdfFactory] - The data factory that should be used by the store
|
|
71
|
+
* @param [opts.rdfArrayRemove] - Function which removes statements from the store
|
|
72
|
+
* @param [opts.dataCallback] - Callback when a statement is added to the store, will not trigger when adding duplicates
|
|
73
|
+
*/
|
|
74
|
+
constructor(features?: FeaturesType, opts?: FormulaOpts);
|
|
75
|
+
/**
|
|
76
|
+
* Gets the URI of the default graph
|
|
77
|
+
*/
|
|
78
|
+
static get defaultGraphURI(): string;
|
|
79
|
+
/**
|
|
80
|
+
* Gets this graph with the bindings substituted
|
|
81
|
+
* @param bindings The bindings
|
|
82
|
+
*/
|
|
83
|
+
substitute<T extends Node = IndexedFormula>(bindings: Bindings): T;
|
|
84
|
+
/**
|
|
85
|
+
* Add a callback which will be triggered after a statement has been added to the store.
|
|
86
|
+
* @param cb
|
|
87
|
+
*/
|
|
88
|
+
addDataCallback(cb: (q: Quad) => void): void;
|
|
89
|
+
/**
|
|
90
|
+
* Apply a set of statements to be deleted and to be inserted
|
|
91
|
+
*
|
|
92
|
+
* @param patch - The set of statements to be deleted and to be inserted
|
|
93
|
+
* @param target - The name of the document to patch
|
|
94
|
+
* @param patchCallback - Callback to be called when patching is complete
|
|
95
|
+
*/
|
|
96
|
+
applyPatch(patch: {
|
|
97
|
+
delete?: ReadonlyArray<Statement>;
|
|
98
|
+
patch?: ReadonlyArray<Statement>;
|
|
99
|
+
where?: any;
|
|
100
|
+
}, target: TFNamedNode, patchCallback: (errorString?: string) => void): void;
|
|
101
|
+
/**
|
|
102
|
+
* N3 allows for declaring blank nodes, this function enables that support
|
|
103
|
+
*
|
|
104
|
+
* @param x The blank node to be declared, supported in N3
|
|
105
|
+
*/
|
|
106
|
+
declareExistential(x: BlankNode): BlankNode;
|
|
107
|
+
/**
|
|
108
|
+
* @param features
|
|
109
|
+
*/
|
|
110
|
+
initPropertyActions(features: FeaturesType): void;
|
|
111
|
+
/** @deprecated Use {add} instead */
|
|
112
|
+
addStatement(st: Quad): number;
|
|
113
|
+
/**
|
|
114
|
+
* Adds a triple (quad) to the store.
|
|
115
|
+
*
|
|
116
|
+
* @param subj - The thing about which the fact a relationship is asserted.
|
|
117
|
+
* Also accepts a statement or an array of Statements.
|
|
118
|
+
* @param pred - The relationship which is asserted
|
|
119
|
+
* @param obj - The object of the relationship, e.g. another thing or a value. If passed a string, this will become a literal.
|
|
120
|
+
* @param why - The document in which the triple (S,P,O) was or will be stored on the web
|
|
121
|
+
* @returns The statement added to the store, or the store
|
|
122
|
+
*/
|
|
123
|
+
add(subj: Quad_Subject | Quad | Quad[] | Statement | Statement[], pred?: Quad_Predicate, obj?: Term | string, why?: Quad_Graph): Statement | null | this | number;
|
|
124
|
+
/**
|
|
125
|
+
* Returns the symbol with canonical URI as smushed
|
|
126
|
+
* @param term - An RDF node
|
|
127
|
+
*/
|
|
128
|
+
canon(term?: Term): Node;
|
|
129
|
+
/**
|
|
130
|
+
* Checks this formula for consistency
|
|
131
|
+
*/
|
|
132
|
+
check(): void;
|
|
133
|
+
/**
|
|
134
|
+
* Checks a list of statements for consistency
|
|
135
|
+
* @param sts - The list of statements to check
|
|
136
|
+
* @param from - An index with the array ['subject', 'predicate', 'object', 'why']
|
|
137
|
+
*/
|
|
138
|
+
checkStatementList(sts: ReadonlyArray<Quad>, from?: number): boolean | void;
|
|
139
|
+
/**
|
|
140
|
+
* Closes this formula (and return it)
|
|
141
|
+
*/
|
|
142
|
+
close(): IndexedFormula;
|
|
143
|
+
compareTerms(u1: Term, u2: Term): number;
|
|
144
|
+
/**
|
|
145
|
+
* replaces @template with @target and add appropriate triples
|
|
146
|
+
* removes no triples by default and is a one-direction replication
|
|
147
|
+
* @param template node to copy
|
|
148
|
+
* @param target node to copy to
|
|
149
|
+
* @param flags Whether or not to do a two-directional copy and/or delete triples
|
|
150
|
+
*/
|
|
151
|
+
copyTo(template: Quad_Subject, target: Quad_Subject, flags?: Array<('two-direction' | 'delete')>): void;
|
|
152
|
+
/**
|
|
153
|
+
* Simplify graph in store when we realize two identifiers are equivalent
|
|
154
|
+
* We replace the bigger with the smaller.
|
|
155
|
+
* @param u1in The first node
|
|
156
|
+
* @param u2in The second node
|
|
157
|
+
*/
|
|
158
|
+
equate(u1in: Term, u2in: Term): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Creates a new empty indexed formula
|
|
161
|
+
* Only applicable for IndexedFormula, but TypeScript won't allow a subclass to override a property
|
|
162
|
+
* @param features The list of features
|
|
163
|
+
*/
|
|
164
|
+
formula(features: FeaturesType): IndexedFormula;
|
|
165
|
+
/**
|
|
166
|
+
* Returns the number of statements contained in this IndexedFormula.
|
|
167
|
+
* (Getter proxy to this.statements).
|
|
168
|
+
* Usage:
|
|
169
|
+
* ```
|
|
170
|
+
* var kb = rdf.graph()
|
|
171
|
+
* kb.length // -> 0
|
|
172
|
+
* ```
|
|
173
|
+
* @returns {Number}
|
|
174
|
+
*/
|
|
175
|
+
get length(): number;
|
|
176
|
+
/**
|
|
177
|
+
* Returns any quads matching the given arguments.
|
|
178
|
+
* Standard RDFJS spec method for Source objects, implemented as an
|
|
179
|
+
* alias to `statementsMatching()`
|
|
180
|
+
* @param subject The subject
|
|
181
|
+
* @param predicate The predicate
|
|
182
|
+
* @param object The object
|
|
183
|
+
* @param graph The graph that contains the statement
|
|
184
|
+
*/
|
|
185
|
+
match(subject?: Quad_Subject | null, predicate?: Quad_Predicate | null, object?: Quad_Object | null, graph?: Quad_Graph | null): Quad[];
|
|
186
|
+
/**
|
|
187
|
+
* Find out whether a given URI is used as symbol in the formula
|
|
188
|
+
* @param uri The URI to look for
|
|
189
|
+
*/
|
|
190
|
+
mentionsURI(uri: string): boolean;
|
|
191
|
+
/**
|
|
192
|
+
* Existentials are BNodes - something exists without naming
|
|
193
|
+
* @param uri An URI
|
|
194
|
+
*/
|
|
195
|
+
newExistential(uri: string): Term;
|
|
196
|
+
/**
|
|
197
|
+
* Adds a new property action
|
|
198
|
+
* @param pred the predicate that the function should be triggered on
|
|
199
|
+
* @param action the function that should trigger
|
|
200
|
+
*/
|
|
201
|
+
newPropertyAction(pred: Quad_Predicate, action: (store: IndexedFormula, subject: Quad_Subject, predicate: Quad_Predicate, object: Quad_Object) => boolean): boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Creates a new universal node
|
|
204
|
+
* Universals are Variables
|
|
205
|
+
* @param uri An URI
|
|
206
|
+
*/
|
|
207
|
+
newUniversal(uri: string): TFNamedNode;
|
|
208
|
+
variable(name: string): Variable;
|
|
209
|
+
/**
|
|
210
|
+
* Find an unused id for a file being edited: return a symbol
|
|
211
|
+
* (Note: Slow iff a lot of them -- could be O(log(k)) )
|
|
212
|
+
* @param doc A document named node
|
|
213
|
+
*/
|
|
214
|
+
nextSymbol(doc: TFNamedNode): TFNamedNode;
|
|
215
|
+
/**
|
|
216
|
+
* Query this store asynchronously, return bindings in callback
|
|
217
|
+
*
|
|
218
|
+
* @param myQuery The query to be run
|
|
219
|
+
* @param callback Function to call when bindings
|
|
220
|
+
* @param Fetcher | null If you want the query to do link following
|
|
221
|
+
* @param onDone OBSOLETE - do not use this // @@ Why not ?? Called when query complete
|
|
222
|
+
*/
|
|
223
|
+
query(myQuery: Query, callback: (bindings: Bindings) => void, fetcher?: Fetcher | null, onDone?: () => void): void;
|
|
224
|
+
/**
|
|
225
|
+
* Query this store synchronously and return bindings
|
|
226
|
+
*
|
|
227
|
+
* @param myQuery The query to be run
|
|
228
|
+
*/
|
|
229
|
+
querySync(myQuery: Query): any[];
|
|
230
|
+
/**
|
|
231
|
+
* Removes one or multiple statement(s) from this formula
|
|
232
|
+
* @param st - A Statement or array of Statements to remove
|
|
233
|
+
*/
|
|
234
|
+
remove(st: Quad | Quad[]): IndexedFormula;
|
|
235
|
+
/**
|
|
236
|
+
* Removes all statements in a doc
|
|
237
|
+
* @param doc - The document / graph
|
|
238
|
+
*/
|
|
239
|
+
removeDocument(doc: Quad_Graph): IndexedFormula;
|
|
240
|
+
/**
|
|
241
|
+
* Remove all statements matching args (within limit) *
|
|
242
|
+
* @param subj The subject
|
|
243
|
+
* @param pred The predicate
|
|
244
|
+
* @param obj The object
|
|
245
|
+
* @param why The graph that contains the statement
|
|
246
|
+
* @param limit The number of statements to remove
|
|
247
|
+
*/
|
|
248
|
+
removeMany(subj?: Quad_Subject | null, pred?: Quad_Predicate | null, obj?: Quad_Object | null, why?: Quad_Graph | null, limit?: number): void;
|
|
249
|
+
/**
|
|
250
|
+
* Remove all matching statements
|
|
251
|
+
* @param subject The subject
|
|
252
|
+
* @param predicate The predicate
|
|
253
|
+
* @param object The object
|
|
254
|
+
* @param graph The graph that contains the statement
|
|
255
|
+
*/
|
|
256
|
+
removeMatches(subject?: Quad_Subject | null, predicate?: Quad_Predicate | null, object?: Quad_Object | null, graph?: Quad_Graph | null): IndexedFormula;
|
|
257
|
+
/**
|
|
258
|
+
* Remove a particular statement object from the store
|
|
259
|
+
*
|
|
260
|
+
* @param st - a statement which is already in the store and indexed.
|
|
261
|
+
* Make sure you only use this for these.
|
|
262
|
+
* Otherwise, you should use remove() above.
|
|
263
|
+
*/
|
|
264
|
+
removeStatement(st: Quad): IndexedFormula;
|
|
265
|
+
/**
|
|
266
|
+
* Removes statements
|
|
267
|
+
* @param sts The statements to remove
|
|
268
|
+
*/
|
|
269
|
+
removeStatements(sts: ReadonlyArray<Quad>): IndexedFormula;
|
|
270
|
+
/**
|
|
271
|
+
* Replace big with small, obsoleted with obsoleting.
|
|
272
|
+
*/
|
|
273
|
+
replaceWith(big: Quad_Subject, small: Quad_Subject): boolean;
|
|
274
|
+
/**
|
|
275
|
+
* Return all equivalent URIs by which this is known
|
|
276
|
+
* @param x A named node
|
|
277
|
+
*/
|
|
278
|
+
allAliases(x: NamedNode): NamedNode[];
|
|
279
|
+
/**
|
|
280
|
+
* Compare by canonical URI as smushed
|
|
281
|
+
* @param x A named node
|
|
282
|
+
* @param y Another named node
|
|
283
|
+
*/
|
|
284
|
+
sameThings(x: NamedNode, y: NamedNode): boolean;
|
|
285
|
+
setPrefixForURI(prefix: string, nsuri: string): void;
|
|
286
|
+
/** Search the Store
|
|
287
|
+
*
|
|
288
|
+
* ALL CONVENIENCE LOOKUP FUNCTIONS RELY ON THIS!
|
|
289
|
+
* @param subj - A node to search for as subject, or if null, a wildcard
|
|
290
|
+
* @param pred - A node to search for as predicate, or if null, a wildcard
|
|
291
|
+
* @param obj - A node to search for as object, or if null, a wildcard
|
|
292
|
+
* @param why - A node to search for as graph, or if null, a wildcard
|
|
293
|
+
* @param justOne - flag - stop when found one rather than get all of them?
|
|
294
|
+
* @returns An array of nodes which match the wildcard position
|
|
295
|
+
*/
|
|
296
|
+
statementsMatching(subj?: Quad_Subject | null, pred?: Quad_Predicate | null, obj?: Quad_Object | null, why?: Quad_Graph | null, justOne?: boolean): Statement[];
|
|
297
|
+
/**
|
|
298
|
+
* A list of all the URIs by which this thing is known
|
|
299
|
+
* @param term
|
|
300
|
+
*/
|
|
301
|
+
uris(term: Quad_Subject): string[];
|
|
302
|
+
}
|
package/lib/store.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { SupportTable } from './factories/factory-types';
|
|
2
|
+
import { BlankNodeTermType, DefaultGraphTermType, LiteralTermType, NamedNodeTermType, VariableTermType } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* RDF/JS spec Term
|
|
5
|
+
* @link https://rdf.js.org/data-model-spec/#term-interface
|
|
6
|
+
*/
|
|
7
|
+
export interface Term {
|
|
8
|
+
termType: string;
|
|
9
|
+
value: string;
|
|
10
|
+
/**
|
|
11
|
+
* Compare this term with {other} for structural equality
|
|
12
|
+
*
|
|
13
|
+
* Note that the task force spec only allows comparison with other terms
|
|
14
|
+
*/
|
|
15
|
+
equals(other: Term): boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* RDF/JS spec NamedNode
|
|
19
|
+
* @link https://rdf.js.org/data-model-spec/#namednode-interface
|
|
20
|
+
*/
|
|
21
|
+
export interface NamedNode extends Term {
|
|
22
|
+
termType: typeof NamedNodeTermType;
|
|
23
|
+
value: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* RDF/JS spec Literal
|
|
27
|
+
* @link https://rdf.js.org/data-model-spec/#literal-interface
|
|
28
|
+
*/
|
|
29
|
+
export interface BlankNode extends Term {
|
|
30
|
+
termType: typeof BlankNodeTermType;
|
|
31
|
+
value: string;
|
|
32
|
+
}
|
|
33
|
+
export interface BaseQuad {
|
|
34
|
+
subject: Term;
|
|
35
|
+
predicate: Term;
|
|
36
|
+
object: Term;
|
|
37
|
+
graph: Term;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* RDF/JS spec Quad
|
|
41
|
+
* @link https://rdf.js.org/data-model-spec/#quad-interface
|
|
42
|
+
*/
|
|
43
|
+
export interface Quad<S extends Term = Quad_Subject, P extends Term = Quad_Predicate, O extends Term = Quad_Object, G extends Term = Quad_Graph> {
|
|
44
|
+
subject: S;
|
|
45
|
+
predicate: P;
|
|
46
|
+
object: O;
|
|
47
|
+
graph: G;
|
|
48
|
+
equals(other: BaseQuad): boolean;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* RDF/JS spec Literal
|
|
52
|
+
* @link https://rdf.js.org/data-model-spec/#literal-interface
|
|
53
|
+
*/
|
|
54
|
+
export interface Literal extends Term {
|
|
55
|
+
/** Contains the constant "Literal". */
|
|
56
|
+
termType: typeof LiteralTermType;
|
|
57
|
+
/** The text value, unescaped, without language or type (example: "Brad Pitt") */
|
|
58
|
+
value: string;
|
|
59
|
+
/**
|
|
60
|
+
* The language as lowercase BCP-47 [BCP47] string (examples: "en", "en-gb")
|
|
61
|
+
* or an empty string if the literal has no language.
|
|
62
|
+
*/
|
|
63
|
+
language: string;
|
|
64
|
+
/** A NamedNode whose IRI represents the datatype of the literal. */
|
|
65
|
+
datatype: NamedNode;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* RDF/JS spec Variable
|
|
69
|
+
* @link https://rdf.js.org/data-model-spec/#variable-interface
|
|
70
|
+
*/
|
|
71
|
+
export interface Variable extends Term {
|
|
72
|
+
/** Contains the constant "Variable". */
|
|
73
|
+
termType: typeof VariableTermType;
|
|
74
|
+
/** The name of the variable without leading "?" (example: "a"). */
|
|
75
|
+
value: string;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* RDF/JS spec DefaultGraph
|
|
79
|
+
* An instance of DefaultGraph represents the default graph.
|
|
80
|
+
* It's only allowed to assign a DefaultGraph to the graph property of a Quad.
|
|
81
|
+
* @link https://rdf.js.org/data-model-spec/#defaultgraph-interface
|
|
82
|
+
*/
|
|
83
|
+
export interface DefaultGraph extends Term {
|
|
84
|
+
termType: typeof DefaultGraphTermType;
|
|
85
|
+
/** should return and empty string'' */
|
|
86
|
+
value: '';
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* RDF/JS spec DataFactory
|
|
90
|
+
*
|
|
91
|
+
* Not 100% compliant due to to practicality problems.
|
|
92
|
+
*
|
|
93
|
+
* @link https://rdf.js.org/data-model-spec/#datafactory-interface
|
|
94
|
+
*/
|
|
95
|
+
export interface RdfJsDataFactory {
|
|
96
|
+
/** Returns a new instance of NamedNode. */
|
|
97
|
+
namedNode: (value: string) => NamedNode;
|
|
98
|
+
/**
|
|
99
|
+
* Returns a new instance of BlankNode.
|
|
100
|
+
* If the value parameter is undefined a new identifier for the
|
|
101
|
+
* blank node is generated for each call.
|
|
102
|
+
*/
|
|
103
|
+
blankNode: (value?: string) => BlankNode;
|
|
104
|
+
/**
|
|
105
|
+
* Returns a new instance of Literal.
|
|
106
|
+
* If languageOrDatatype is a NamedNode, then it is used for the value of datatype.
|
|
107
|
+
* Otherwise languageOrDatatype is used for the value of language. */
|
|
108
|
+
literal: (value: string, languageOrDatatype: string | NamedNode) => Literal;
|
|
109
|
+
/** Returns a new instance of Variable. This method is optional. */
|
|
110
|
+
variable?: (value: string) => Variable;
|
|
111
|
+
/**
|
|
112
|
+
* Returns an instance of DefaultGraph.
|
|
113
|
+
*/
|
|
114
|
+
defaultGraph: () => DefaultGraph;
|
|
115
|
+
/**
|
|
116
|
+
* Returns a new instance of the specific Term subclass given by original.termType
|
|
117
|
+
* (e.g., NamedNode, BlankNode, Literal, etc.),
|
|
118
|
+
* such that newObject.equals(original) returns true.
|
|
119
|
+
* Not implemented in RDFJS, so optional.
|
|
120
|
+
*/
|
|
121
|
+
fromTerm?: (original: Term) => Term;
|
|
122
|
+
/**
|
|
123
|
+
* Returns a new instance of Quad, such that newObject.equals(original) returns true.
|
|
124
|
+
* Not implemented in RDFJS, so optional.
|
|
125
|
+
*/
|
|
126
|
+
fromQuad?: (original: Quad) => Quad;
|
|
127
|
+
/**
|
|
128
|
+
* Returns a new instance of Quad.
|
|
129
|
+
* If graph is undefined or null it MUST set graph to a DefaultGraph.
|
|
130
|
+
*/
|
|
131
|
+
quad: (subject: Term, predicate: Term, object: Term, graph?: Term) => Quad<any, any, any, any>;
|
|
132
|
+
/**
|
|
133
|
+
* Returns a new instance of Quad.
|
|
134
|
+
* If graph is undefined or null it MUST set graph to a DefaultGraph.
|
|
135
|
+
*/
|
|
136
|
+
triple: (subject: Term, predicate: Term, object: Term, graph?: Term) => Quad<any, any, any, any>;
|
|
137
|
+
/**
|
|
138
|
+
* Check for specific features/behaviour on the factory.
|
|
139
|
+
*
|
|
140
|
+
* This does not exist on the original RDF/JS spec
|
|
141
|
+
*/
|
|
142
|
+
supports: SupportTable;
|
|
143
|
+
}
|
|
144
|
+
/** A RDF/JS spec Subject */
|
|
145
|
+
export declare type Quad_Subject = NamedNode | BlankNode | Variable;
|
|
146
|
+
/** A RDF/JS spec Predicate */
|
|
147
|
+
export declare type Quad_Predicate = NamedNode | Variable;
|
|
148
|
+
/** A RDF/JS spec Object */
|
|
149
|
+
export declare type Quad_Object = NamedNode | BlankNode | Literal | Variable | Term;
|
|
150
|
+
/** A RDF/JS spec Graph */
|
|
151
|
+
export declare type Quad_Graph = NamedNode | DefaultGraph | BlankNode | Variable;
|
package/lib/tf-types.js
CHANGED
|
File without changes
|
package/lib/types.d.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import Node from './node-internal';
|
|
2
|
+
import RDFlibVariable from './variable';
|
|
3
|
+
import RDFlibBlankNode from './blank-node';
|
|
4
|
+
import Collection from './collection';
|
|
5
|
+
import RDFlibLiteral from './literal';
|
|
6
|
+
import RDFlibNamedNode from './named-node';
|
|
7
|
+
import RDFlibDefaultGraph from './default-graph';
|
|
8
|
+
import { DataFactory } from './factories/factory-types';
|
|
9
|
+
import IndexedFormula from './store';
|
|
10
|
+
import Fetcher from './fetcher';
|
|
11
|
+
import Statement from './statement';
|
|
12
|
+
import Empty from './empty';
|
|
13
|
+
import { NamedNode, Term, Quad_Subject, Quad_Predicate, Quad_Object, Quad_Graph } from './tf-types';
|
|
14
|
+
export declare const NamedNodeTermType: "NamedNode";
|
|
15
|
+
export declare const BlankNodeTermType: "BlankNode";
|
|
16
|
+
export declare const LiteralTermType: "Literal";
|
|
17
|
+
export declare const VariableTermType: "Variable";
|
|
18
|
+
export declare const DefaultGraphTermType: "DefaultGraph";
|
|
19
|
+
export declare const CollectionTermType: "Collection";
|
|
20
|
+
export declare const EmptyTermType: "Empty";
|
|
21
|
+
export declare const GraphTermType: "Graph";
|
|
22
|
+
export declare type TermType = typeof NamedNodeTermType | typeof BlankNodeTermType | typeof LiteralTermType | typeof VariableTermType | typeof DefaultGraphTermType | typeof CollectionTermType | typeof EmptyTermType | typeof GraphTermType;
|
|
23
|
+
export declare const HTMLContentType: "text/html";
|
|
24
|
+
export declare const JSONLDContentType: "application/ld+json";
|
|
25
|
+
export declare const N3ContentType: "text/n3";
|
|
26
|
+
export declare const N3LegacyContentType: "application/n3";
|
|
27
|
+
export declare const NQuadsAltContentType: "application/nquads";
|
|
28
|
+
export declare const NQuadsContentType: "application/n-quads";
|
|
29
|
+
export declare const NTriplesContentType: "application/n-triples";
|
|
30
|
+
export declare const RDFXMLContentType: "application/rdf+xml";
|
|
31
|
+
export declare const SPARQLUpdateContentType: "application/sparql-update";
|
|
32
|
+
export declare const SPARQLUpdateSingleMatchContentType: "application/sparql-update-single-match";
|
|
33
|
+
export declare const TurtleContentType: "text/turtle";
|
|
34
|
+
export declare const TurtleLegacyContentType: "application/x-turtle";
|
|
35
|
+
export declare const XHTMLContentType: "application/xhtml+xml";
|
|
36
|
+
/**
|
|
37
|
+
* A valid mime type header
|
|
38
|
+
*/
|
|
39
|
+
export declare type ContentType = typeof RDFXMLContentType | typeof HTMLContentType | typeof JSONLDContentType | typeof N3ContentType | typeof N3LegacyContentType | typeof NQuadsAltContentType | typeof NQuadsContentType | typeof SPARQLUpdateContentType | typeof SPARQLUpdateSingleMatchContentType | typeof TurtleContentType | typeof TurtleLegacyContentType | typeof XHTMLContentType;
|
|
40
|
+
/** A type for values that serves as inputs */
|
|
41
|
+
export declare type ValueType = Term | Node | Date | string | number | boolean | undefined | null | Collection;
|
|
42
|
+
/**
|
|
43
|
+
* In this project, there exist two types for the same kind of RDF concept.
|
|
44
|
+
* We have RDF/JS spec types (standardized, generic), and RDFlib types (internal, specific).
|
|
45
|
+
* When deciding which type to use in a function, it is preferable to accept generic inputs,
|
|
46
|
+
* whenever possible, and provide strict outputs.
|
|
47
|
+
* In some ways, the TF types in here are a bit more strict.
|
|
48
|
+
* Variables are missing, and the statement requires specific types of terms (e.g. NamedNode instead of Term).
|
|
49
|
+
*/
|
|
50
|
+
/** An RDF/JS Subject */
|
|
51
|
+
export declare type SubjectType = RDFlibBlankNode | RDFlibNamedNode | RDFlibVariable;
|
|
52
|
+
/** An RDF/JS Predicate */
|
|
53
|
+
export declare type PredicateType = RDFlibNamedNode | RDFlibVariable;
|
|
54
|
+
/** An RDF/JS Object */
|
|
55
|
+
export declare type ObjectType = RDFlibNamedNode | RDFlibLiteral | Collection | RDFlibBlankNode | RDFlibVariable | Empty;
|
|
56
|
+
/** An RDF/JS Graph */
|
|
57
|
+
export declare type GraphType = RDFlibDefaultGraph | RDFlibNamedNode | RDFlibVariable;
|
|
58
|
+
export interface Bindings {
|
|
59
|
+
[id: string]: Term;
|
|
60
|
+
}
|
|
61
|
+
/** All the types that a .fromValue() method might return */
|
|
62
|
+
export declare type FromValueReturns<C extends Node = any> = Term | undefined | null | Collection<C>;
|
|
63
|
+
export interface IRDFlibDataFactory extends DataFactory<RDFlibNamedNode | RDFlibBlankNode | RDFlibLiteral | Collection | Statement> {
|
|
64
|
+
fetcher: (store: IndexedFormula, options: any) => Fetcher;
|
|
65
|
+
lit: (val: string, lang?: string, dt?: NamedNode) => RDFlibLiteral;
|
|
66
|
+
graph: (features?: any, opts?: any) => IndexedFormula;
|
|
67
|
+
st: (subject: Quad_Subject, predicate: Quad_Predicate, object: Quad_Object, graph?: Quad_Graph) => Statement;
|
|
68
|
+
}
|
package/lib/types.js
CHANGED
|
File without changes
|