-
Notifications
You must be signed in to change notification settings - Fork 13
/
data-model.d.ts
290 lines (264 loc) · 7.62 KB
/
data-model.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
/* Data Model Interfaces */
/* https://rdf.js.org/data-model-spec/ */
/**
* Contains an Iri, RDF blank Node, RDF literal, variable name, default graph, or a quad
* @see NamedNode
* @see BlankNode
* @see Literal
* @see Variable
* @see DefaultGraph
* @see BaseQuad
*/
export type Term = NamedNode | BlankNode | Literal | Variable | DefaultGraph | BaseQuad;
/**
* Contains an IRI.
*/
export interface NamedNode<Iri extends string = string> {
/**
* Contains the constant "NamedNode".
*/
termType: "NamedNode";
/**
* The IRI of the named node (example: `http://example.org/resource`)
*/
value: Iri;
/**
* @param other The term to compare with.
* @return True if and only if other has termType "NamedNode" and the same `value`.
*/
equals(other: Term | null | undefined): boolean;
}
/**
* Contains an RDF blank node.
*/
export interface BlankNode {
/**
* Contains the constant "BlankNode".
*/
termType: "BlankNode";
/**
* Blank node name as a string, without any serialization specific prefixes,
* e.g. when parsing,
* if the data was sourced from Turtle, remove _:,
* if it was sourced from RDF/XML, do not change the blank node name (example: blank3).
*/
value: string;
/**
* @param other The term to compare with.
* @return True if and only if other has termType "BlankNode" and the same `value`.
*/
equals(other: Term | null | undefined): boolean;
}
/**
* An RDF literal, containing a string with an optional language tag and/or datatype.
*/
export interface Literal {
/**
* Contains the constant "Literal".
*/
termType: "Literal";
/**
* The text value, unescaped, without language or type (example: Brad Pitt).
*/
value: string;
/**
* the language as lowercase BCP47 string (examples: en, en-gb)
* or an empty string if the literal has no language.
* @link http://tools.ietf.org/html/bcp47
*/
language: string;
/**
* A NamedNode whose IRI represents the datatype of the literal.
*/
datatype: NamedNode;
/**
* @param other The term to compare with.
* @return True if and only if other has termType "Literal"
* and the same `value`, `language`, and `datatype`.
*/
equals(other: Term | null | undefined): boolean;
}
/**
* A variable name.
*/
export interface Variable {
/**
* Contains the constant "Variable".
*/
termType: "Variable";
/**
* The name of the variable *without* leading ? (example: a).
*/
value: string;
/**
* @param other The term to compare with.
* @return True if and only if other has termType "Variable" and the same `value`.
*/
equals(other: Term | null | undefined): boolean;
}
/**
* An instance of DefaultGraph represents the default graph.
* It's only allowed to assign a DefaultGraph to the .graph property of a Quad.
*/
export interface DefaultGraph {
/**
* Contains the constant "DefaultGraph".
*/
termType: "DefaultGraph";
/**
* Contains an empty string as constant value.
*/
value: "";
/**
* @param other The term to compare with.
* @return True if and only if other has termType "DefaultGraph".
*/
equals(other: Term | null | undefined): boolean;
}
/**
* The subject, which is a NamedNode, BlankNode or Variable.
* @see NamedNode
* @see BlankNode
* @see Variable
*/
export type Quad_Subject = NamedNode | BlankNode | Quad | Variable;
/**
* The predicate, which is a NamedNode or Variable.
* @see NamedNode
* @see Variable
*/
export type Quad_Predicate = NamedNode | Variable;
/**
* The object, which is a NamedNode, Literal, BlankNode or Variable.
* @see NamedNode
* @see Literal
* @see BlankNode
* @see Variable
*/
export type Quad_Object = NamedNode | Literal | BlankNode | Quad | Variable;
/**
* The named graph, which is a DefaultGraph, NamedNode, BlankNode or Variable.
* @see DefaultGraph
* @see NamedNode
* @see BlankNode
* @see Variable
*/
export type Quad_Graph = DefaultGraph | NamedNode | BlankNode | Variable;
/**
* An RDF quad, taking any Term in its positions, containing the subject, predicate, object and graph terms.
*/
export interface BaseQuad {
/**
* Contains the constant "Quad".
*/
termType: "Quad";
/**
* Contains an empty string as constant value.
*/
value: "";
/**
* The subject.
* @see Quad_Subject
*/
subject: Term;
/**
* The predicate.
* @see Quad_Predicate
*/
predicate: Term;
/**
* The object.
* @see Quad_Object
*/
object: Term;
/**
* The named graph.
* @see Quad_Graph
*/
graph: Term;
/**
* @param other The term to compare with.
* @return True if and only if the argument is a) of the same type b) has all components equal.
*/
equals(other: Term | null | undefined): boolean;
}
/**
* An RDF quad, containing the subject, predicate, object and graph terms.
*/
export interface Quad extends BaseQuad {
/**
* The subject.
* @see Quad_Subject
*/
subject: Quad_Subject;
/**
* The predicate.
* @see Quad_Predicate
*/
predicate: Quad_Predicate;
/**
* The object.
* @see Quad_Object
*/
object: Quad_Object;
/**
* The named graph.
* @see Quad_Graph
*/
graph: Quad_Graph;
/**
* @param other The term to compare with.
* @return True if and only if the argument is a) of the same type b) has all components equal.
*/
equals(other: Term | null | undefined): boolean;
}
/**
* A factory for instantiating RDF terms and quads.
*/
export interface DataFactory<OutQuad extends BaseQuad = Quad, InQuad extends BaseQuad = OutQuad> {
/**
* @param value The IRI for the named node.
* @return A new instance of NamedNode.
* @see NamedNode
*/
namedNode<Iri extends string = string>(value: Iri): NamedNode<Iri>;
/**
* @param value The optional blank node identifier.
* @return A new instance of BlankNode.
* If the `value` parameter is undefined a new identifier
* for the blank node is generated for each call.
* @see BlankNode
*/
blankNode(value?: string): BlankNode;
/**
* @param value The literal value.
* @param languageOrDatatype The optional language or datatype.
* If `languageOrDatatype` is a NamedNode,
* then it is used for the value of `NamedNode.datatype`.
* Otherwise `languageOrDatatype` is used for the value
* of `NamedNode.language`.
* @return A new instance of Literal.
* @see Literal
*/
literal(value: string, languageOrDatatype?: string | NamedNode): Literal;
/**
* This method is optional.
* @param value The variable name
* @return A new instance of Variable.
* @see Variable
*/
variable?(value: string): Variable;
/**
* @return An instance of DefaultGraph.
*/
defaultGraph(): DefaultGraph;
/**
* @param subject The quad subject term.
* @param predicate The quad predicate term.
* @param object The quad object term.
* @param graph The quad graph term.
* @return A new instance of Quad.
* @see Quad
*/
quad(subject: InQuad['subject'], predicate: InQuad['predicate'], object: InQuad['object'], graph?: InQuad['graph']): OutQuad;
}