@traqula/rules-sparql-1-1 0.0.1-alpha.176 → 0.0.1
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/lib/RoundTripTypes.d.ts +379 -0
- package/lib/RoundTripTypes.js +2 -0
- package/lib/RoundTripTypes.js.map +1 -0
- package/lib/Sparql11types.d.ts +18 -245
- package/lib/Sparql11types.js.map +1 -1
- package/lib/SparqlParser.d.ts +13 -4
- package/lib/SparqlParser.js +7 -4
- package/lib/SparqlParser.js.map +1 -1
- package/lib/expressionHelpers.d.ts +8 -19
- package/lib/expressionHelpers.js +40 -103
- package/lib/expressionHelpers.js.map +1 -1
- package/lib/factory.d.ts +447 -0
- package/lib/factory.js +105 -0
- package/lib/factory.js.map +1 -0
- package/lib/factoryMixins/ContextFactory.d.ts +38 -0
- package/lib/factoryMixins/ContextFactory.js +30 -0
- package/lib/factoryMixins/ContextFactory.js.map +1 -0
- package/lib/factoryMixins/ExpressionFactory.d.ts +60 -0
- package/lib/factoryMixins/ExpressionFactory.js +83 -0
- package/lib/factoryMixins/ExpressionFactory.js.map +1 -0
- package/lib/factoryMixins/GraphRefFactory.d.ts +43 -0
- package/lib/factoryMixins/GraphRefFactory.js +51 -0
- package/lib/factoryMixins/GraphRefFactory.js.map +1 -0
- package/lib/factoryMixins/PathFactory.d.ts +51 -0
- package/lib/factoryMixins/PathFactory.js +68 -0
- package/lib/factoryMixins/PathFactory.js.map +1 -0
- package/lib/factoryMixins/Patternfactory.d.ts +55 -0
- package/lib/factoryMixins/Patternfactory.js +98 -0
- package/lib/factoryMixins/Patternfactory.js.map +1 -0
- package/lib/factoryMixins/QueryFactory.d.ts +41 -0
- package/lib/factoryMixins/QueryFactory.js +43 -0
- package/lib/factoryMixins/QueryFactory.js.map +1 -0
- package/lib/factoryMixins/SolutionModifiersFactory.d.ts +43 -0
- package/lib/factoryMixins/SolutionModifiersFactory.js +55 -0
- package/lib/factoryMixins/SolutionModifiersFactory.js.map +1 -0
- package/lib/factoryMixins/TermFactory.d.ts +76 -0
- package/lib/factoryMixins/TermFactory.js +84 -0
- package/lib/factoryMixins/TermFactory.js.map +1 -0
- package/lib/factoryMixins/UpdateOperationFactory.d.ts +68 -0
- package/lib/factoryMixins/UpdateOperationFactory.js +126 -0
- package/lib/factoryMixins/UpdateOperationFactory.js.map +1 -0
- package/lib/factoryMixins/mixins.d.ts +14 -0
- package/lib/factoryMixins/mixins.js +20 -0
- package/lib/factoryMixins/mixins.js.map +1 -0
- package/lib/grammar/builtIn.d.ts +59 -59
- package/lib/grammar/builtIn.js +50 -57
- package/lib/grammar/builtIn.js.map +1 -1
- package/lib/grammar/dataSetClause.d.ts +22 -9
- package/lib/grammar/dataSetClause.js +57 -14
- package/lib/grammar/dataSetClause.js.map +1 -1
- package/lib/grammar/expression.d.ts +12 -16
- package/lib/grammar/expression.js +224 -296
- package/lib/grammar/expression.js.map +1 -1
- package/lib/grammar/general.d.ts +8 -8
- package/lib/grammar/general.js +59 -94
- package/lib/grammar/general.js.map +1 -1
- package/lib/grammar/literals.d.ts +16 -13
- package/lib/grammar/literals.js +161 -144
- package/lib/grammar/literals.js.map +1 -1
- package/lib/grammar/propertyPaths.d.ts +16 -12
- package/lib/grammar/propertyPaths.js +100 -129
- package/lib/grammar/propertyPaths.js.map +1 -1
- package/lib/grammar/queryUnit/queryUnit.d.ts +13 -17
- package/lib/grammar/queryUnit/queryUnit.js +195 -329
- package/lib/grammar/queryUnit/queryUnit.js.map +1 -1
- package/lib/grammar/solutionModifier.d.ts +12 -11
- package/lib/grammar/solutionModifier.js +125 -109
- package/lib/grammar/solutionModifier.js.map +1 -1
- package/lib/grammar/tripleBlock.d.ts +24 -33
- package/lib/grammar/tripleBlock.js +172 -126
- package/lib/grammar/tripleBlock.js.map +1 -1
- package/lib/grammar/updateUnit/updateUnit.d.ts +28 -33
- package/lib/grammar/updateUnit/updateUnit.js +282 -367
- package/lib/grammar/updateUnit/updateUnit.js.map +1 -1
- package/lib/grammar/whereClause.d.ts +20 -19
- package/lib/grammar/whereClause.js +232 -245
- package/lib/grammar/whereClause.js.map +1 -1
- package/lib/grammar-helpers/utils.d.ts +0 -4
- package/lib/grammar-helpers/utils.js +0 -37
- package/lib/grammar-helpers/utils.js.map +1 -1
- package/lib/index.cjs +3061 -2438
- package/lib/index.d.ts +4 -2
- package/lib/index.js +4 -2
- package/lib/index.js.map +1 -1
- package/lib/lexer/lexer.d.ts +4 -3
- package/lib/lexer/lexer.js +11 -7
- package/lib/lexer/lexer.js.map +1 -1
- package/lib/lexer/terminals.d.ts +0 -34
- package/lib/lexer/terminals.js +35 -37
- package/lib/lexer/terminals.js.map +1 -1
- package/lib/utils.d.ts +0 -3
- package/lib/utils.js +0 -6
- package/lib/utils.js.map +1 -1
- package/lib/validation/validators.d.ts +14 -0
- package/lib/validation/validators.js +235 -0
- package/lib/validation/validators.js.map +1 -0
- package/package.json +6 -8
- package/lib/Wildcard.d.ts +0 -9
- package/lib/Wildcard.js +0 -19
- package/lib/Wildcard.js.map +0 -1
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import type { Localized, Node } from '@traqula/core';
|
|
2
|
+
export type Sparql11Nodes = GraphRef | UpdateOperation | Update | Query | DatasetClauses | TripleCollection | TripleNesting | Pattern | SolutionModifier | Expression | Path | ContextDefinition | Wildcard | Term;
|
|
3
|
+
export type GraphRefBase = Node & {
|
|
4
|
+
type: 'graphRef';
|
|
5
|
+
subType: string;
|
|
6
|
+
};
|
|
7
|
+
export type GraphRefDefault = GraphRefBase & {
|
|
8
|
+
subType: 'default';
|
|
9
|
+
};
|
|
10
|
+
export type GraphRefNamed = GraphRefBase & {
|
|
11
|
+
subType: 'named';
|
|
12
|
+
};
|
|
13
|
+
export type GraphRefAll = GraphRefBase & {
|
|
14
|
+
subType: 'all';
|
|
15
|
+
};
|
|
16
|
+
export type GraphRefSpecific = GraphRefBase & {
|
|
17
|
+
subType: 'specific';
|
|
18
|
+
graph: TermIri;
|
|
19
|
+
};
|
|
20
|
+
export type GraphRef = GraphRefDefault | GraphRefNamed | GraphRefAll | GraphRefSpecific;
|
|
21
|
+
export type Quads = PatternBgp | GraphQuads;
|
|
22
|
+
export type GraphQuads = Node & {
|
|
23
|
+
type: 'graph';
|
|
24
|
+
graph: TermIri | TermVariable;
|
|
25
|
+
triples: PatternBgp;
|
|
26
|
+
};
|
|
27
|
+
export type UpdateOperationBase = Node & {
|
|
28
|
+
type: 'updateOperation';
|
|
29
|
+
subType: string;
|
|
30
|
+
};
|
|
31
|
+
export type UpdateOperationLoad = UpdateOperationBase & {
|
|
32
|
+
subType: 'load';
|
|
33
|
+
silent: boolean;
|
|
34
|
+
source: TermIri;
|
|
35
|
+
destination?: GraphRefSpecific;
|
|
36
|
+
};
|
|
37
|
+
type UpdateOperationClearDropCreateBase = UpdateOperationBase & {
|
|
38
|
+
subType: 'clear' | 'drop' | 'create';
|
|
39
|
+
silent: boolean;
|
|
40
|
+
destination: GraphRef;
|
|
41
|
+
};
|
|
42
|
+
export type UpdateOperationClear = UpdateOperationClearDropCreateBase & {
|
|
43
|
+
subType: 'clear';
|
|
44
|
+
};
|
|
45
|
+
export type UpdateOperationDrop = UpdateOperationClearDropCreateBase & {
|
|
46
|
+
subType: 'drop';
|
|
47
|
+
};
|
|
48
|
+
export type UpdateOperationCreate = UpdateOperationClearDropCreateBase & {
|
|
49
|
+
subType: 'create';
|
|
50
|
+
destination: GraphRefSpecific;
|
|
51
|
+
};
|
|
52
|
+
type UpdateOperationAddMoveCopy = UpdateOperationBase & {
|
|
53
|
+
subType: 'add' | 'move' | 'copy';
|
|
54
|
+
silent: boolean;
|
|
55
|
+
source: GraphRefDefault | GraphRefSpecific;
|
|
56
|
+
destination: GraphRefDefault | GraphRefSpecific;
|
|
57
|
+
};
|
|
58
|
+
export type UpdateOperationAdd = UpdateOperationAddMoveCopy & {
|
|
59
|
+
subType: 'add';
|
|
60
|
+
};
|
|
61
|
+
export type UpdateOperationMove = UpdateOperationAddMoveCopy & {
|
|
62
|
+
subType: 'move';
|
|
63
|
+
};
|
|
64
|
+
export type UpdateOperationCopy = UpdateOperationAddMoveCopy & {
|
|
65
|
+
subType: 'copy';
|
|
66
|
+
};
|
|
67
|
+
type UpdateOperationInsertDeleteDelWhere = UpdateOperationBase & {
|
|
68
|
+
subType: 'insertdata' | 'deletedata' | 'deletewhere';
|
|
69
|
+
data: Quads[];
|
|
70
|
+
};
|
|
71
|
+
export type UpdateOperationInsertData = UpdateOperationInsertDeleteDelWhere & {
|
|
72
|
+
subType: 'insertdata';
|
|
73
|
+
};
|
|
74
|
+
export type UpdateOperationDeleteData = UpdateOperationInsertDeleteDelWhere & {
|
|
75
|
+
subType: 'deletedata';
|
|
76
|
+
};
|
|
77
|
+
export type UpdateOperationDeleteWhere = UpdateOperationInsertDeleteDelWhere & {
|
|
78
|
+
subType: 'deletewhere';
|
|
79
|
+
};
|
|
80
|
+
export type UpdateOperationModify = UpdateOperationBase & {
|
|
81
|
+
subType: 'modify';
|
|
82
|
+
graph: TermIri | undefined;
|
|
83
|
+
insert: Quads[];
|
|
84
|
+
delete: Quads[];
|
|
85
|
+
from: DatasetClauses;
|
|
86
|
+
where: PatternGroup;
|
|
87
|
+
};
|
|
88
|
+
export type UpdateOperation = UpdateOperationLoad | UpdateOperationClear | UpdateOperationDrop | UpdateOperationCreate | UpdateOperationAdd | UpdateOperationMove | UpdateOperationCopy | UpdateOperationInsertData | UpdateOperationDeleteData | UpdateOperationDeleteWhere | UpdateOperationModify;
|
|
89
|
+
export type Update = Node & {
|
|
90
|
+
type: 'update';
|
|
91
|
+
updates: {
|
|
92
|
+
operation?: UpdateOperation;
|
|
93
|
+
context: ContextDefinition[];
|
|
94
|
+
}[];
|
|
95
|
+
};
|
|
96
|
+
export type QueryBase = Node & {
|
|
97
|
+
type: 'query';
|
|
98
|
+
subType: string;
|
|
99
|
+
context: ContextDefinition[];
|
|
100
|
+
values?: PatternValues;
|
|
101
|
+
solutionModifiers: SolutionModifiers;
|
|
102
|
+
datasets: DatasetClauses;
|
|
103
|
+
where?: PatternGroup;
|
|
104
|
+
};
|
|
105
|
+
export type QuerySelect = QueryBase & {
|
|
106
|
+
subType: 'select';
|
|
107
|
+
variables: (TermVariable | PatternBind)[] | [Wildcard];
|
|
108
|
+
distinct?: true;
|
|
109
|
+
reduced?: true;
|
|
110
|
+
where: PatternGroup;
|
|
111
|
+
};
|
|
112
|
+
export type QueryConstruct = QueryBase & {
|
|
113
|
+
subType: 'construct';
|
|
114
|
+
template: PatternBgp;
|
|
115
|
+
where: PatternGroup;
|
|
116
|
+
};
|
|
117
|
+
export type QueryDescribe = QueryBase & {
|
|
118
|
+
subType: 'describe';
|
|
119
|
+
variables: (TermVariable | TermIri)[] | [Wildcard];
|
|
120
|
+
};
|
|
121
|
+
export type QueryAsk = QueryBase & {
|
|
122
|
+
subType: 'ask';
|
|
123
|
+
where: PatternGroup;
|
|
124
|
+
};
|
|
125
|
+
export type Query = QuerySelect | QueryConstruct | QueryDescribe | QueryAsk;
|
|
126
|
+
export type SparqlQuery = Query | Update;
|
|
127
|
+
export type DatasetClauses = Node & {
|
|
128
|
+
type: 'datasetClauses';
|
|
129
|
+
clauses: {
|
|
130
|
+
clauseType: 'default' | 'named';
|
|
131
|
+
value: TermIri;
|
|
132
|
+
}[];
|
|
133
|
+
};
|
|
134
|
+
export type TripleCollectionBase = Node & {
|
|
135
|
+
type: 'tripleCollection';
|
|
136
|
+
subType: string;
|
|
137
|
+
triples: TripleNesting[];
|
|
138
|
+
identifier: Term;
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* The subject of the triples does not have a string manifestation.
|
|
142
|
+
*/
|
|
143
|
+
export type TripleCollectionList = TripleCollectionBase & {
|
|
144
|
+
subType: 'list';
|
|
145
|
+
identifier: TermBlank;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Bot subject and predicate of the triples do not have a string manifestation.
|
|
149
|
+
*/
|
|
150
|
+
export type TripleCollectionBlankNodeProperties = TripleCollectionBase & {
|
|
151
|
+
subType: 'blankNodeProperties';
|
|
152
|
+
identifier: TermBlank;
|
|
153
|
+
};
|
|
154
|
+
export type TripleCollection = TripleCollectionList | TripleCollectionBlankNodeProperties;
|
|
155
|
+
export type GraphNode = Term | TripleCollection;
|
|
156
|
+
export type TripleNesting = Node & {
|
|
157
|
+
type: 'triple';
|
|
158
|
+
subject: GraphNode;
|
|
159
|
+
predicate: TermIri | TermVariable | Path;
|
|
160
|
+
object: GraphNode;
|
|
161
|
+
};
|
|
162
|
+
export type PatternBase = Node & {
|
|
163
|
+
type: 'pattern';
|
|
164
|
+
subType: string;
|
|
165
|
+
};
|
|
166
|
+
export type PatternFilter = PatternBase & {
|
|
167
|
+
subType: 'filter';
|
|
168
|
+
expression: Expression;
|
|
169
|
+
};
|
|
170
|
+
export type PatternMinus = PatternBase & {
|
|
171
|
+
subType: 'minus';
|
|
172
|
+
patterns: Pattern[];
|
|
173
|
+
};
|
|
174
|
+
export type PatternGroup = PatternBase & {
|
|
175
|
+
subType: 'group';
|
|
176
|
+
patterns: Pattern[];
|
|
177
|
+
};
|
|
178
|
+
export type PatternOptional = PatternBase & {
|
|
179
|
+
subType: 'optional';
|
|
180
|
+
patterns: Pattern[];
|
|
181
|
+
};
|
|
182
|
+
export type PatternGraph = PatternBase & {
|
|
183
|
+
subType: 'graph';
|
|
184
|
+
name: TermIri | TermVariable;
|
|
185
|
+
patterns: Pattern[];
|
|
186
|
+
};
|
|
187
|
+
export type PatternUnion = PatternBase & {
|
|
188
|
+
subType: 'union';
|
|
189
|
+
patterns: PatternGroup[];
|
|
190
|
+
};
|
|
191
|
+
export type BasicGraphPattern = (TripleNesting | TripleCollection)[];
|
|
192
|
+
export type PatternBgp = PatternBase & {
|
|
193
|
+
subType: 'bgp';
|
|
194
|
+
/**
|
|
195
|
+
* Only the first appearance of a subject and predicate have a string manifestation
|
|
196
|
+
*/
|
|
197
|
+
triples: BasicGraphPattern;
|
|
198
|
+
};
|
|
199
|
+
export type PatternBind = PatternBase & {
|
|
200
|
+
subType: 'bind';
|
|
201
|
+
expression: Expression;
|
|
202
|
+
variable: TermVariable;
|
|
203
|
+
};
|
|
204
|
+
export type PatternService = PatternBase & {
|
|
205
|
+
subType: 'service';
|
|
206
|
+
name: TermIri | TermVariable;
|
|
207
|
+
silent: boolean;
|
|
208
|
+
patterns: Pattern[];
|
|
209
|
+
};
|
|
210
|
+
/**
|
|
211
|
+
* A single list of assignments maps the variable identifier to the value
|
|
212
|
+
*/
|
|
213
|
+
export type ValuePatternRow = Record<string, TermIri | TermLiteral | undefined>;
|
|
214
|
+
export type PatternValues = PatternBase & {
|
|
215
|
+
subType: 'values';
|
|
216
|
+
values: ValuePatternRow[];
|
|
217
|
+
};
|
|
218
|
+
export type SubSelect = QuerySelect;
|
|
219
|
+
export type Pattern = PatternBgp | PatternGroup | PatternUnion | PatternOptional | PatternMinus | PatternGraph | PatternService | PatternFilter | PatternBind | PatternValues | SubSelect;
|
|
220
|
+
export type SolutionModifiers = {
|
|
221
|
+
group?: SolutionModifierGroup;
|
|
222
|
+
having?: SolutionModifierHaving;
|
|
223
|
+
order?: SolutionModifierOrder;
|
|
224
|
+
limitOffset?: SolutionModifierLimitOffset;
|
|
225
|
+
};
|
|
226
|
+
export type SolutionModifierBase = Node & {
|
|
227
|
+
type: 'solutionModifier';
|
|
228
|
+
subType: string;
|
|
229
|
+
};
|
|
230
|
+
export type SolutionModifierGroupBind = Localized & {
|
|
231
|
+
variable: TermVariable;
|
|
232
|
+
value: Expression;
|
|
233
|
+
};
|
|
234
|
+
export type SolutionModifierGroup = SolutionModifierBase & {
|
|
235
|
+
subType: 'group';
|
|
236
|
+
groupings: (Expression | SolutionModifierGroupBind)[];
|
|
237
|
+
};
|
|
238
|
+
export type SolutionModifierHaving = SolutionModifierBase & {
|
|
239
|
+
subType: 'having';
|
|
240
|
+
having: Expression[];
|
|
241
|
+
};
|
|
242
|
+
export type Ordering = Localized & {
|
|
243
|
+
descending: boolean;
|
|
244
|
+
expression: Expression;
|
|
245
|
+
};
|
|
246
|
+
export type SolutionModifierOrder = SolutionModifierBase & {
|
|
247
|
+
subType: 'order';
|
|
248
|
+
orderDefs: Ordering[];
|
|
249
|
+
};
|
|
250
|
+
export type SolutionModifierLimitOffset = SolutionModifierBase & {
|
|
251
|
+
subType: 'limitOffset';
|
|
252
|
+
limit: number | undefined;
|
|
253
|
+
offset: number | undefined;
|
|
254
|
+
};
|
|
255
|
+
export type SolutionModifier = SolutionModifierGroup | SolutionModifierHaving | SolutionModifierOrder | SolutionModifierLimitOffset;
|
|
256
|
+
export type ExpressionBase = Node & {
|
|
257
|
+
type: 'expression';
|
|
258
|
+
subType: string;
|
|
259
|
+
};
|
|
260
|
+
type ExpressionAggregateBase = ExpressionBase & {
|
|
261
|
+
subType: 'aggregate';
|
|
262
|
+
distinct: boolean;
|
|
263
|
+
expression: [Expression | Wildcard];
|
|
264
|
+
};
|
|
265
|
+
export type ExpressionAggregateDefault = ExpressionAggregateBase & {
|
|
266
|
+
expression: [Expression];
|
|
267
|
+
aggregation: string;
|
|
268
|
+
};
|
|
269
|
+
export type ExpressionAggregateOnWildcard = ExpressionAggregateBase & {
|
|
270
|
+
expression: [Wildcard];
|
|
271
|
+
aggregation: string;
|
|
272
|
+
};
|
|
273
|
+
export type ExpressionAggregateSeparator = ExpressionAggregateBase & {
|
|
274
|
+
expression: [Expression];
|
|
275
|
+
aggregation: string;
|
|
276
|
+
separator: string;
|
|
277
|
+
};
|
|
278
|
+
export type ExpressionAggregate = ExpressionAggregateDefault | ExpressionAggregateOnWildcard | ExpressionAggregateSeparator;
|
|
279
|
+
export type ExpressionOperation = ExpressionBase & {
|
|
280
|
+
subType: 'operation';
|
|
281
|
+
operator: string;
|
|
282
|
+
args: Expression[];
|
|
283
|
+
};
|
|
284
|
+
export type ExpressionPatternOperation = ExpressionBase & {
|
|
285
|
+
subType: 'patternOperation';
|
|
286
|
+
operator: string;
|
|
287
|
+
args: PatternGroup;
|
|
288
|
+
};
|
|
289
|
+
export type ExpressionFunctionCall = ExpressionBase & {
|
|
290
|
+
subType: 'functionCall';
|
|
291
|
+
function: TermIri;
|
|
292
|
+
distinct: boolean;
|
|
293
|
+
args: Expression[];
|
|
294
|
+
};
|
|
295
|
+
export type Expression = ExpressionOperation | ExpressionPatternOperation | ExpressionFunctionCall | ExpressionAggregate | TermIri | TermVariable | TermLiteral;
|
|
296
|
+
export type PropertyPathBase = Node & {
|
|
297
|
+
type: 'path';
|
|
298
|
+
subType: string;
|
|
299
|
+
};
|
|
300
|
+
export type PropertyPathChain = PropertyPathBase & {
|
|
301
|
+
subType: '|' | '/';
|
|
302
|
+
items: Path[];
|
|
303
|
+
};
|
|
304
|
+
export type PathModified = PropertyPathBase & {
|
|
305
|
+
subType: '?' | '*' | '+' | '^';
|
|
306
|
+
items: [Path];
|
|
307
|
+
};
|
|
308
|
+
export type PathNegatedElt = PropertyPathBase & {
|
|
309
|
+
subType: '^';
|
|
310
|
+
items: [TermIri];
|
|
311
|
+
};
|
|
312
|
+
export type PathAlternativeLimited = PropertyPathBase & {
|
|
313
|
+
subType: '|';
|
|
314
|
+
items: (TermIri | PathNegatedElt)[];
|
|
315
|
+
};
|
|
316
|
+
export type PathNegated = PropertyPathBase & {
|
|
317
|
+
subType: '!';
|
|
318
|
+
items: [TermIri | PathNegatedElt | PathAlternativeLimited];
|
|
319
|
+
};
|
|
320
|
+
export type Path = TermIri | PropertyPathChain | PathModified | PathNegated;
|
|
321
|
+
export type PathPure = PropertyPathChain | PathModified | PathNegated;
|
|
322
|
+
export type ContextDefinitionBase_ = Node & {
|
|
323
|
+
type: 'contextDef';
|
|
324
|
+
subType: string;
|
|
325
|
+
};
|
|
326
|
+
export type ContextDefinitionPrefix = ContextDefinitionBase_ & {
|
|
327
|
+
subType: 'prefix';
|
|
328
|
+
key: string;
|
|
329
|
+
value: TermIriFull;
|
|
330
|
+
};
|
|
331
|
+
export type ContextDefinitionBase = ContextDefinitionBase_ & {
|
|
332
|
+
subType: 'base';
|
|
333
|
+
value: TermIriFull;
|
|
334
|
+
};
|
|
335
|
+
export type ContextDefinition = ContextDefinitionPrefix | ContextDefinitionBase;
|
|
336
|
+
export type Wildcard = Node & {
|
|
337
|
+
type: 'wildcard';
|
|
338
|
+
};
|
|
339
|
+
export type TermBase = Node & {
|
|
340
|
+
type: 'term';
|
|
341
|
+
subType: string;
|
|
342
|
+
};
|
|
343
|
+
export type TermLiteralBase = TermBase & {
|
|
344
|
+
subType: 'literal';
|
|
345
|
+
value: string;
|
|
346
|
+
};
|
|
347
|
+
export type TermLiteralStr = TermLiteralBase & {
|
|
348
|
+
langOrIri: undefined;
|
|
349
|
+
};
|
|
350
|
+
export type TermLiteralLangStr = TermLiteralBase & {
|
|
351
|
+
langOrIri: string;
|
|
352
|
+
};
|
|
353
|
+
export type TermLiteralTyped = TermLiteralBase & {
|
|
354
|
+
langOrIri: TermIri;
|
|
355
|
+
};
|
|
356
|
+
export type TermLiteral = TermLiteralStr | TermLiteralLangStr | TermLiteralTyped;
|
|
357
|
+
export type TermVariable = TermBase & {
|
|
358
|
+
subType: 'variable';
|
|
359
|
+
value: string;
|
|
360
|
+
};
|
|
361
|
+
export type TermIriBase = TermBase & {
|
|
362
|
+
subType: 'namedNode';
|
|
363
|
+
};
|
|
364
|
+
export type TermIriFull = TermIriBase & {
|
|
365
|
+
value: string;
|
|
366
|
+
};
|
|
367
|
+
export type TermIriPrefixed = TermIriBase & {
|
|
368
|
+
value: string;
|
|
369
|
+
prefix: string;
|
|
370
|
+
};
|
|
371
|
+
export type TermIri = TermIriFull | TermIriPrefixed;
|
|
372
|
+
export type TermBlank = TermBase & {
|
|
373
|
+
subType: 'blankNode';
|
|
374
|
+
} & {
|
|
375
|
+
label: string;
|
|
376
|
+
};
|
|
377
|
+
export type GraphTerm = TermIri | TermBlank | TermLiteral;
|
|
378
|
+
export type Term = GraphTerm | TermVariable;
|
|
379
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoundTripTypes.js","sourceRoot":"","sources":["RoundTripTypes.ts"],"names":[],"mappings":"","sourcesContent":["import type { Localized, Node } from '@traqula/core';\n\nexport type Sparql11Nodes =\n | GraphRef\n | UpdateOperation\n | Update\n | Query\n | DatasetClauses\n | TripleCollection\n | TripleNesting\n | Pattern\n | SolutionModifier\n | Expression\n | Path\n | ContextDefinition\n | Wildcard\n | Term;\n\nexport type GraphRefBase = Node & {\n type: 'graphRef';\n subType: string;\n};\nexport type GraphRefDefault = GraphRefBase & {\n subType: 'default';\n};\nexport type GraphRefNamed = GraphRefBase & {\n subType: 'named';\n};\nexport type GraphRefAll = GraphRefBase & {\n subType: 'all';\n};\nexport type GraphRefSpecific = GraphRefBase & {\n subType: 'specific';\n graph: TermIri;\n};\nexport type GraphRef =\n | GraphRefDefault\n | GraphRefNamed\n | GraphRefAll\n | GraphRefSpecific;\n\nexport type Quads = PatternBgp | GraphQuads;\n\nexport type GraphQuads = Node & {\n type: 'graph';\n graph: TermIri | TermVariable;\n triples: PatternBgp;\n};\n\n// https://www.w3.org/TR/sparql11-query/#rUpdate1\nexport type UpdateOperationBase = Node & { type: 'updateOperation'; subType: string };\nexport type UpdateOperationLoad = UpdateOperationBase & {\n subType: 'load';\n silent: boolean;\n source: TermIri;\n destination?: GraphRefSpecific;\n};\ntype UpdateOperationClearDropCreateBase = UpdateOperationBase & {\n subType: 'clear' | 'drop' | 'create';\n silent: boolean;\n destination: GraphRef;\n};\nexport type UpdateOperationClear = UpdateOperationClearDropCreateBase & { subType: 'clear' };\nexport type UpdateOperationDrop = UpdateOperationClearDropCreateBase & { subType: 'drop' };\nexport type UpdateOperationCreate = UpdateOperationClearDropCreateBase & {\n subType: 'create';\n destination: GraphRefSpecific;\n};\ntype UpdateOperationAddMoveCopy = UpdateOperationBase & {\n subType: 'add' | 'move' | 'copy';\n silent: boolean;\n source: GraphRefDefault | GraphRefSpecific;\n destination: GraphRefDefault | GraphRefSpecific;\n};\nexport type UpdateOperationAdd = UpdateOperationAddMoveCopy & { subType: 'add' };\nexport type UpdateOperationMove = UpdateOperationAddMoveCopy & { subType: 'move' };\nexport type UpdateOperationCopy = UpdateOperationAddMoveCopy & { subType: 'copy' };\ntype UpdateOperationInsertDeleteDelWhere = UpdateOperationBase & {\n subType: 'insertdata' | 'deletedata' | 'deletewhere';\n data: Quads[];\n};\nexport type UpdateOperationInsertData = UpdateOperationInsertDeleteDelWhere & { subType: 'insertdata' };\nexport type UpdateOperationDeleteData = UpdateOperationInsertDeleteDelWhere & { subType: 'deletedata' };\nexport type UpdateOperationDeleteWhere = UpdateOperationInsertDeleteDelWhere & { subType: 'deletewhere' };\nexport type UpdateOperationModify = UpdateOperationBase & {\n subType: 'modify';\n graph: TermIri | undefined;\n insert: Quads[];\n delete: Quads[];\n from: DatasetClauses;\n where: PatternGroup;\n};\nexport type UpdateOperation =\n | UpdateOperationLoad\n | UpdateOperationClear\n | UpdateOperationDrop\n | UpdateOperationCreate\n | UpdateOperationAdd\n | UpdateOperationMove\n | UpdateOperationCopy\n | UpdateOperationInsertData\n | UpdateOperationDeleteData\n | UpdateOperationDeleteWhere\n | UpdateOperationModify;\n\n// https://www.w3.org/TR/sparql11-query/#rUpdate\nexport type Update = Node & {\n type: 'update';\n updates: {\n operation?: UpdateOperation;\n context: ContextDefinition[];\n }[];\n};\n\n// https://www.w3.org/TR/sparql11-query/#rQueryUnit\nexport type QueryBase = Node & {\n type: 'query';\n subType: string;\n\n context: ContextDefinition[];\n values?: PatternValues;\n solutionModifiers: SolutionModifiers;\n datasets: DatasetClauses;\n where?: PatternGroup;\n};\nexport type QuerySelect = QueryBase & {\n subType: 'select';\n variables: (TermVariable | PatternBind)[] | [Wildcard];\n distinct?: true;\n reduced?: true;\n where: PatternGroup;\n};\nexport type QueryConstruct = QueryBase & {\n subType: 'construct';\n template: PatternBgp;\n where: PatternGroup;\n};\nexport type QueryDescribe = QueryBase & {\n subType: 'describe';\n variables: (TermVariable | TermIri)[] | [Wildcard];\n};\nexport type QueryAsk = QueryBase & {\n subType: 'ask';\n where: PatternGroup;\n};\nexport type Query =\n | QuerySelect\n | QueryConstruct\n | QueryDescribe\n | QueryAsk;\n\nexport type SparqlQuery = Query | Update;\n\n// https://www.w3.org/TR/sparql11-query/#rDatasetClause\nexport type DatasetClauses = Node & {\n type: 'datasetClauses';\n clauses: { clauseType: 'default' | 'named'; value: TermIri }[];\n};\n\n// https://www.w3.org/TR/sparql11-query/#rGraphNode\nexport type TripleCollectionBase = Node & {\n type: 'tripleCollection';\n subType: string;\n triples: TripleNesting[];\n identifier: Term;\n};\n/**\n * The subject of the triples does not have a string manifestation.\n */\nexport type TripleCollectionList = TripleCollectionBase & {\n subType: 'list';\n identifier: TermBlank;\n};\n/**\n * Bot subject and predicate of the triples do not have a string manifestation.\n */\nexport type TripleCollectionBlankNodeProperties = TripleCollectionBase & {\n subType: 'blankNodeProperties';\n identifier: TermBlank;\n};\nexport type TripleCollection =\n | TripleCollectionList\n | TripleCollectionBlankNodeProperties;\n\n// https://www.w3.org/TR/sparql11-query/#rGraphNode\nexport type GraphNode = Term | TripleCollection;\n\n// https://www.w3.org/TR/sparql11-query/#rTriplesBlock\nexport type TripleNesting = Node & {\n type: 'triple';\n subject: GraphNode;\n predicate: TermIri | TermVariable | Path;\n object: GraphNode;\n};\n\nexport type PatternBase = Node & { type: 'pattern'; subType: string };\nexport type PatternFilter = PatternBase & {\n subType: 'filter';\n expression: Expression;\n};\nexport type PatternMinus = PatternBase & {\n subType: 'minus';\n patterns: Pattern[];\n};\n\nexport type PatternGroup = PatternBase & {\n subType: 'group';\n patterns: Pattern[];\n};\nexport type PatternOptional = PatternBase & {\n subType: 'optional';\n patterns: Pattern[];\n};\nexport type PatternGraph = PatternBase & {\n subType: 'graph';\n name: TermIri | TermVariable;\n patterns: Pattern[];\n};\nexport type PatternUnion = PatternBase & {\n subType: 'union';\n patterns: PatternGroup[];\n};\nexport type BasicGraphPattern = (TripleNesting | TripleCollection)[];\nexport type PatternBgp = PatternBase & {\n subType: 'bgp';\n /**\n * Only the first appearance of a subject and predicate have a string manifestation\n */\n triples: BasicGraphPattern;\n};\nexport type PatternBind = PatternBase & {\n subType: 'bind';\n expression: Expression;\n variable: TermVariable;\n};\nexport type PatternService = PatternBase & {\n subType: 'service';\n name: TermIri | TermVariable;\n silent: boolean;\n patterns: Pattern[];\n};\n/**\n * A single list of assignments maps the variable identifier to the value\n */\nexport type ValuePatternRow = Record<string, TermIri | TermLiteral | undefined>;\nexport type PatternValues = PatternBase & {\n subType: 'values';\n values: ValuePatternRow[];\n};\nexport type SubSelect = QuerySelect;\n\nexport type Pattern =\n | PatternBgp\n | PatternGroup\n | PatternUnion\n | PatternOptional\n | PatternMinus\n | PatternGraph\n | PatternService\n | PatternFilter\n | PatternBind\n | PatternValues\n | SubSelect;\n\nexport type SolutionModifiers = {\n group?: SolutionModifierGroup;\n having?: SolutionModifierHaving;\n order?: SolutionModifierOrder;\n limitOffset?: SolutionModifierLimitOffset;\n};\nexport type SolutionModifierBase = Node & { type: 'solutionModifier'; subType: string };\nexport type SolutionModifierGroupBind = Localized & {\n variable: TermVariable;\n value: Expression;\n};\nexport type SolutionModifierGroup = SolutionModifierBase & {\n subType: 'group';\n groupings: (Expression | SolutionModifierGroupBind)[];\n};\nexport type SolutionModifierHaving = SolutionModifierBase & {\n subType: 'having';\n having: Expression[];\n};\nexport type Ordering = Localized & {\n descending: boolean;\n expression: Expression;\n};\nexport type SolutionModifierOrder = SolutionModifierBase & {\n subType: 'order';\n orderDefs: Ordering[];\n};\nexport type SolutionModifierLimitOffset = SolutionModifierBase\n & { subType: 'limitOffset'; limit: number | undefined; offset: number | undefined };\n\nexport type SolutionModifier =\n | SolutionModifierGroup\n | SolutionModifierHaving\n | SolutionModifierOrder\n | SolutionModifierLimitOffset;\n\nexport type ExpressionBase = Node & { type: 'expression'; subType: string };\n\ntype ExpressionAggregateBase = ExpressionBase & {\n subType: 'aggregate';\n distinct: boolean;\n expression: [Expression | Wildcard];\n};\nexport type ExpressionAggregateDefault = ExpressionAggregateBase & {\n expression: [Expression];\n aggregation: string;\n};\nexport type ExpressionAggregateOnWildcard = ExpressionAggregateBase & {\n expression: [Wildcard];\n aggregation: string;\n};\nexport type ExpressionAggregateSeparator = ExpressionAggregateBase & {\n expression: [Expression];\n aggregation: string;\n separator: string;\n};\nexport type ExpressionAggregate =\n | ExpressionAggregateDefault\n | ExpressionAggregateOnWildcard\n | ExpressionAggregateSeparator;\n\nexport type ExpressionOperation = ExpressionBase & {\n subType: 'operation';\n operator: string;\n args: Expression[];\n};\n\nexport type ExpressionPatternOperation = ExpressionBase & {\n subType: 'patternOperation';\n operator: string;\n // Can be a pattern in case of exists and not exists\n args: PatternGroup;\n};\n\nexport type ExpressionFunctionCall = ExpressionBase & {\n subType: 'functionCall';\n function: TermIri;\n distinct: boolean;\n args: Expression[];\n};\n\nexport type Expression =\n | ExpressionOperation\n | ExpressionPatternOperation\n | ExpressionFunctionCall\n | ExpressionAggregate\n | TermIri\n | TermVariable\n | TermLiteral;\n\nexport type PropertyPathBase = Node & { type: 'path'; subType: string };\nexport type PropertyPathChain = PropertyPathBase & {\n subType: '|' | '/';\n items: Path[];\n};\n\nexport type PathModified = PropertyPathBase & {\n subType: '?' | '*' | '+' | '^';\n items: [Path];\n};\n\nexport type PathNegatedElt = PropertyPathBase & {\n subType: '^';\n items: [TermIri];\n};\n\nexport type PathAlternativeLimited = PropertyPathBase & {\n subType: '|';\n items: (TermIri | PathNegatedElt)[];\n};\n\nexport type PathNegated = PropertyPathBase & {\n subType: '!';\n items: [TermIri | PathNegatedElt | PathAlternativeLimited];\n};\n\n// [[88]](https://www.w3.org/TR/sparql11-query/#rPath)\nexport type Path =\n | TermIri\n | PropertyPathChain\n | PathModified\n | PathNegated;\nexport type PathPure = PropertyPathChain | PathModified | PathNegated;\n\nexport type ContextDefinitionBase_ = Node & { type: 'contextDef'; subType: string };\nexport type ContextDefinitionPrefix = ContextDefinitionBase_ & {\n subType: 'prefix';\n key: string;\n value: TermIriFull;\n};\nexport type ContextDefinitionBase = ContextDefinitionBase_ & {\n subType: 'base';\n value: TermIriFull;\n};\nexport type ContextDefinition = ContextDefinitionPrefix | ContextDefinitionBase;\n\nexport type Wildcard = Node & {\n type: 'wildcard';\n};\n\nexport type TermBase = Node & { type: 'term'; subType: string };\nexport type TermLiteralBase = TermBase & {\n subType: 'literal';\n value: string;\n};\nexport type TermLiteralStr = TermLiteralBase & { langOrIri: undefined };\nexport type TermLiteralLangStr = TermLiteralBase & { langOrIri: string };\nexport type TermLiteralTyped = TermLiteralBase & { langOrIri: TermIri };\nexport type TermLiteral = TermLiteralStr | TermLiteralLangStr | TermLiteralTyped;\n\nexport type TermVariable = TermBase & {\n subType: 'variable';\n value: string;\n};\n\nexport type TermIriBase = TermBase & { subType: 'namedNode' };\nexport type TermIriFull = TermIriBase & { value: string };\nexport type TermIriPrefixed = TermIriBase & {\n value: string;\n prefix: string;\n};\nexport type TermIri = TermIriFull | TermIriPrefixed;\n\nexport type TermBlank = TermBase & { subType: 'blankNode' } & { label: string };\n\nexport type GraphTerm = TermIri | TermBlank | TermLiteral;\nexport type Term = GraphTerm | TermVariable;\n"]}
|
package/lib/Sparql11types.d.ts
CHANGED
|
@@ -1,248 +1,20 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
import type { CommonIRIs } from './grammar-helpers/utils';
|
|
5
|
-
import type { Wildcard } from './Wildcard';
|
|
6
|
-
type RdfJsTerm = Term | BaseQuadTerm;
|
|
7
|
-
export type BaseQuadTerm = RDF.BaseQuad & {
|
|
8
|
-
subject: RdfJsTerm;
|
|
9
|
-
predicate: RdfJsTerm;
|
|
10
|
-
object: RdfJsTerm;
|
|
11
|
-
};
|
|
12
|
-
export type GraphTerm = IriTerm | BlankTerm | LiteralTerm;
|
|
13
|
-
export type Term = GraphTerm | VariableTerm;
|
|
14
|
-
export type VerbA = IriTerm<CommonIRIs.TYPE>;
|
|
15
|
-
export type Triple = {
|
|
16
|
-
subject: Term;
|
|
17
|
-
predicate: IriTerm | VariableTerm | PropertyPath;
|
|
18
|
-
object: Term;
|
|
19
|
-
};
|
|
20
|
-
export interface IGraphNode {
|
|
21
|
-
node: ITriplesNode['node'] | Term;
|
|
22
|
-
triples: Triple[];
|
|
23
|
-
}
|
|
24
|
-
export interface ITriplesNode {
|
|
25
|
-
node: IriTerm | BlankNode;
|
|
26
|
-
triples: Triple[];
|
|
27
|
-
}
|
|
28
|
-
export type Pattern = BgpPattern | BlockPattern | FilterPattern | BindPattern | ValuesPattern | Omit<SelectQuery, 'prefixes'>;
|
|
29
|
-
export type Expression = OperationExpression | FunctionCallExpression | AggregateExpression | Expression[] | IriTerm | VariableTerm | LiteralTerm;
|
|
30
|
-
export interface FunctionCallExpression extends BaseExpression {
|
|
31
|
-
type: 'functionCall';
|
|
32
|
-
function: IriTerm;
|
|
33
|
-
args: Expression[];
|
|
34
|
-
}
|
|
1
|
+
import type { GeneratorRule, ParserRule } from '@traqula/core';
|
|
2
|
+
import type { Factory } from './factory';
|
|
3
|
+
export type SparqlRule<
|
|
35
4
|
/**
|
|
36
|
-
*
|
|
5
|
+
* Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.
|
|
37
6
|
*/
|
|
38
|
-
|
|
39
|
-
type: 'bgp';
|
|
40
|
-
triples: Triple[];
|
|
41
|
-
}
|
|
42
|
-
export interface GraphQuads {
|
|
43
|
-
type: 'graph';
|
|
44
|
-
name: IriTerm | VariableTerm;
|
|
45
|
-
triples: Triple[];
|
|
46
|
-
}
|
|
47
|
-
export type VariableTerm = RDF.Variable;
|
|
48
|
-
export type IriTerm<IRI extends string = string> = RDF.NamedNode<IRI>;
|
|
49
|
-
export type LiteralTerm = RDF.Literal;
|
|
50
|
-
export type BlankTerm = RDF.BlankNode;
|
|
51
|
-
export type PropertyPath = NegatedPropertySet | {
|
|
52
|
-
type: 'path';
|
|
53
|
-
pathType: '|' | '/' | '^' | '+' | '*' | '?';
|
|
54
|
-
items: (IriTerm | PropertyPath)[];
|
|
55
|
-
};
|
|
56
|
-
export type SparqlQuery = Query | Update | Pick<Update, 'base' | 'prefixes'>;
|
|
57
|
-
export type Query = SelectQuery | ConstructQuery | AskQuery | DescribeQuery;
|
|
58
|
-
export interface SelectQuery extends BaseQuery {
|
|
59
|
-
queryType: 'SELECT';
|
|
60
|
-
variables: Variable[] | [Wildcard];
|
|
61
|
-
distinct?: true | undefined;
|
|
62
|
-
reduced?: true | undefined;
|
|
63
|
-
}
|
|
64
|
-
export interface Grouping {
|
|
65
|
-
expression: Expression;
|
|
66
|
-
variable?: VariableTerm;
|
|
67
|
-
}
|
|
68
|
-
export interface Ordering {
|
|
69
|
-
expression: Expression;
|
|
70
|
-
descending?: true | undefined;
|
|
71
|
-
}
|
|
72
|
-
export interface ConstructQuery extends BaseQuery {
|
|
73
|
-
queryType: 'CONSTRUCT';
|
|
74
|
-
template?: Triple[] | undefined;
|
|
75
|
-
}
|
|
76
|
-
export interface AskQuery extends BaseQuery {
|
|
77
|
-
queryType: 'ASK';
|
|
78
|
-
}
|
|
79
|
-
export interface DescribeQuery extends BaseQuery {
|
|
80
|
-
queryType: 'DESCRIBE';
|
|
81
|
-
variables: (VariableTerm | IriTerm)[] | [Wildcard];
|
|
82
|
-
}
|
|
83
|
-
export interface Update {
|
|
84
|
-
type: 'update';
|
|
85
|
-
base?: string | undefined;
|
|
86
|
-
prefixes: Record<string, string>;
|
|
87
|
-
updates: UpdateOperation[];
|
|
88
|
-
}
|
|
89
|
-
export type UpdateOperation = InsertDeleteOperation | ManagementOperation;
|
|
90
|
-
export type InsertDeleteOperation = InsertOperation | DeleteOperation | ModifyOperation | DeleteWhereOperation;
|
|
91
|
-
export interface InsertOperation {
|
|
92
|
-
updateType: 'insert';
|
|
93
|
-
insert: Quads[];
|
|
94
|
-
}
|
|
95
|
-
export interface DeleteOperation {
|
|
96
|
-
updateType: 'delete';
|
|
97
|
-
delete: Quads[];
|
|
98
|
-
}
|
|
99
|
-
export interface ModifyOperation {
|
|
100
|
-
updateType: 'insertdelete';
|
|
101
|
-
insert: Quads[];
|
|
102
|
-
delete: Quads[];
|
|
103
|
-
graph?: IriTerm;
|
|
104
|
-
using?: {
|
|
105
|
-
default: IriTerm[];
|
|
106
|
-
named: IriTerm[];
|
|
107
|
-
};
|
|
108
|
-
where: Pattern[];
|
|
109
|
-
}
|
|
110
|
-
export interface DeleteWhereOperation {
|
|
111
|
-
updateType: 'deletewhere';
|
|
112
|
-
delete: Quads[];
|
|
113
|
-
}
|
|
114
|
-
export type Quads = BgpPattern | GraphQuads;
|
|
115
|
-
export type ManagementOperation = CopyMoveAddOperation | LoadOperation | CreateOperation | ClearDropOperation;
|
|
116
|
-
export interface CopyMoveAddOperation {
|
|
117
|
-
type: 'copy' | 'move' | 'add';
|
|
118
|
-
silent: boolean;
|
|
119
|
-
source: GraphOrDefault;
|
|
120
|
-
destination: GraphOrDefault;
|
|
121
|
-
}
|
|
122
|
-
export interface LoadOperation {
|
|
123
|
-
type: 'load';
|
|
124
|
-
silent: boolean;
|
|
125
|
-
source: IriTerm;
|
|
126
|
-
destination?: IriTerm;
|
|
127
|
-
}
|
|
128
|
-
export interface CreateOperation {
|
|
129
|
-
type: 'create';
|
|
130
|
-
silent: boolean;
|
|
131
|
-
graph: GraphOrDefault;
|
|
132
|
-
}
|
|
133
|
-
export interface ClearDropOperation {
|
|
134
|
-
type: 'clear' | 'drop';
|
|
135
|
-
silent: boolean;
|
|
136
|
-
graph: GraphReference;
|
|
137
|
-
}
|
|
138
|
-
export interface GraphOrDefault {
|
|
139
|
-
type?: 'graph';
|
|
140
|
-
name?: IriTerm | undefined;
|
|
141
|
-
default?: true | undefined;
|
|
142
|
-
}
|
|
143
|
-
export interface GraphReference extends GraphOrDefault {
|
|
144
|
-
named?: true | undefined;
|
|
145
|
-
all?: true | undefined;
|
|
146
|
-
}
|
|
7
|
+
NameType extends string = string,
|
|
147
8
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
9
|
+
* Type that will be returned after a correct parse of this rule.
|
|
10
|
+
* This type will be the return type of calling SUBRULE with this grammar rule.
|
|
150
11
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
export
|
|
157
|
-
type: 'query';
|
|
158
|
-
base?: string | undefined;
|
|
159
|
-
prefixes: Record<string, string>;
|
|
160
|
-
from?: {
|
|
161
|
-
default: IriTerm[];
|
|
162
|
-
named: IriTerm[];
|
|
163
|
-
} | undefined;
|
|
164
|
-
where?: Pattern[] | undefined;
|
|
165
|
-
values?: ValuePatternRow[] | undefined;
|
|
166
|
-
having?: Expression[] | undefined;
|
|
167
|
-
group?: Grouping[] | undefined;
|
|
168
|
-
order?: Ordering[] | undefined;
|
|
169
|
-
limit?: number | undefined;
|
|
170
|
-
offset?: number | undefined;
|
|
171
|
-
}
|
|
172
|
-
export type IriTermOrElt = IriTerm | {
|
|
173
|
-
type: 'path';
|
|
174
|
-
pathType: '^';
|
|
175
|
-
items: [IriTerm];
|
|
176
|
-
};
|
|
177
|
-
export interface NegatedPropertySet {
|
|
178
|
-
type: 'path';
|
|
179
|
-
pathType: '!';
|
|
180
|
-
items: [IriTermOrElt] | [
|
|
181
|
-
{
|
|
182
|
-
type: 'path';
|
|
183
|
-
pathType: '|';
|
|
184
|
-
items: (IriTermOrElt)[];
|
|
185
|
-
}
|
|
186
|
-
];
|
|
187
|
-
}
|
|
188
|
-
export interface GroupPattern {
|
|
189
|
-
type: 'group';
|
|
190
|
-
patterns: Pattern[];
|
|
191
|
-
}
|
|
192
|
-
export interface GraphPattern {
|
|
193
|
-
type: 'graph';
|
|
194
|
-
name: IriTerm | VariableTerm;
|
|
195
|
-
patterns: Pattern[];
|
|
196
|
-
}
|
|
197
|
-
export interface MinusPattern {
|
|
198
|
-
type: 'minus';
|
|
199
|
-
patterns: Pattern[];
|
|
200
|
-
}
|
|
201
|
-
export interface ServicePattern {
|
|
202
|
-
type: 'service';
|
|
203
|
-
name: IriTerm | VariableTerm;
|
|
204
|
-
silent: boolean;
|
|
205
|
-
patterns: Pattern[];
|
|
206
|
-
}
|
|
207
|
-
export type BlockPattern = OptionalPattern | UnionPattern | GroupPattern | GraphPattern | MinusPattern | ServicePattern;
|
|
208
|
-
export interface OptionalPattern {
|
|
209
|
-
type: 'optional';
|
|
210
|
-
patterns: Pattern[];
|
|
211
|
-
}
|
|
212
|
-
export interface UnionPattern {
|
|
213
|
-
type: 'union';
|
|
214
|
-
patterns: Pattern[];
|
|
215
|
-
}
|
|
216
|
-
export type ValuePatternRow = Record<string, IriTerm | BlankTerm | LiteralTerm | undefined>;
|
|
217
|
-
export interface FilterPattern {
|
|
218
|
-
type: 'filter';
|
|
219
|
-
expression: Expression;
|
|
220
|
-
}
|
|
221
|
-
export interface BindPattern {
|
|
222
|
-
type: 'bind';
|
|
223
|
-
expression: Expression;
|
|
224
|
-
variable: VariableTerm;
|
|
225
|
-
}
|
|
226
|
-
export interface ValuesPattern {
|
|
227
|
-
type: 'values';
|
|
228
|
-
values: ValuePatternRow[];
|
|
229
|
-
}
|
|
230
|
-
export interface BaseExpression {
|
|
231
|
-
type: string;
|
|
232
|
-
distinct?: boolean | undefined;
|
|
233
|
-
}
|
|
234
|
-
export interface OperationExpression extends BaseExpression {
|
|
235
|
-
type: 'operation';
|
|
236
|
-
operator: string;
|
|
237
|
-
args: (Expression)[] | [Pattern];
|
|
238
|
-
}
|
|
239
|
-
export interface AggregateExpression extends BaseExpression {
|
|
240
|
-
type: 'aggregate';
|
|
241
|
-
expression: Expression | Wildcard;
|
|
242
|
-
aggregation: string;
|
|
243
|
-
separator?: string | undefined;
|
|
244
|
-
}
|
|
245
|
-
export type SparqlRule<
|
|
12
|
+
ReturnType = unknown, GenInputType = ReturnType,
|
|
13
|
+
/**
|
|
14
|
+
* Function arguments that can be given to convey the state of the current parse operation.
|
|
15
|
+
*/
|
|
16
|
+
ParamType = undefined> = SparqlGrammarRule<NameType, ReturnType, ParamType> & SparqlGeneratorRule<NameType, GenInputType, ParamType>;
|
|
17
|
+
export type SparqlGeneratorRule<
|
|
246
18
|
/**
|
|
247
19
|
* Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.
|
|
248
20
|
*/
|
|
@@ -255,7 +27,9 @@ ReturnType = unknown,
|
|
|
255
27
|
/**
|
|
256
28
|
* Function arguments that can be given to convey the state of the current parse operation.
|
|
257
29
|
*/
|
|
258
|
-
ParamType = undefined> =
|
|
30
|
+
ParamType = undefined> = GeneratorRule<{
|
|
31
|
+
factory: Factory;
|
|
32
|
+
}, NameType, ReturnType, ParamType>;
|
|
259
33
|
export type SparqlGrammarRule<
|
|
260
34
|
/**
|
|
261
35
|
* Name of grammar rule, should be a strict subtype of string like 'myGrammarRule'.
|
|
@@ -272,9 +46,9 @@ ReturnType = unknown,
|
|
|
272
46
|
ParamType = undefined> = ParserRule<SparqlContext, NameType, ReturnType, ParamType>;
|
|
273
47
|
export interface SparqlContext {
|
|
274
48
|
/**
|
|
275
|
-
* Data-
|
|
49
|
+
* Data-factoryMixins to be used when constructing rdf primitives.
|
|
276
50
|
*/
|
|
277
|
-
|
|
51
|
+
factory: Factory;
|
|
278
52
|
/**
|
|
279
53
|
* Current scoped prefixes. Used for resolving prefixed names.
|
|
280
54
|
*/
|
|
@@ -292,4 +66,3 @@ export interface SparqlContext {
|
|
|
292
66
|
*/
|
|
293
67
|
parseMode: Set<'canParseVars' | 'canCreateBlankNodes' | 'inAggregate' | 'canParseAggregate' | string>;
|
|
294
68
|
}
|
|
295
|
-
export {};
|