@traqula/rules-sparql-1-2 0.0.1-alpha.176 → 0.0.1-alpha.9

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.
@@ -1,158 +1,317 @@
1
- import type * as RDF from '@rdfjs/types';
2
- import type { Patch } from '@traqula/core';
1
+ import type { Localized, Node, Patch } from '@traqula/core';
3
2
  import type * as T11 from '@traqula/rules-sparql-1-1';
4
- export type BaseQuadTerm = RDF.BaseQuad & {
5
- subject: Term;
6
- predicate: Term;
7
- object: Term;
3
+ export type Sparql12Nodes = GraphRef | UpdateOperation | Update | Query | DatasetClauses | TripleCollection | TripleNesting | Pattern | SolutionModifier | Expression | Path | ContextDefinition | Wildcard | Term;
4
+ export type GraphRefBase = T11.GraphRefBase;
5
+ export type GraphRefDefault = T11.GraphRefDefault;
6
+ export type GraphRefNamed = T11.GraphRefNamed;
7
+ export type GraphRefAll = T11.GraphRefAll;
8
+ export type GraphRefSpecific = T11.GraphRefSpecific;
9
+ export type GraphRef = T11.GraphRef;
10
+ export type Quads = PatternBgp | GraphQuads;
11
+ export type GraphQuads = Node & {
12
+ type: 'graph';
13
+ graph: TermIri | TermVariable;
14
+ triples: PatternBgp;
8
15
  };
9
- export type GraphTerm = IriTerm | BlankTerm | LiteralTerm | BaseQuadTerm;
10
- export type Term = GraphTerm | VariableTerm;
11
- export type Expression = T11.Expression | BaseQuadTerm;
12
- export type Triple = Patch<T11.Triple, {
13
- subject: Term;
14
- object: Term;
15
- }>;
16
- export type IGraphNode = Patch<T11.IGraphNode, {
17
- triples: Triple[];
18
- node: ITriplesNode['node'] | Term;
19
- }>;
20
- export type ITriplesNode = Patch<T11.ITriplesNode, {
21
- triples: Triple[];
22
- }>;
23
- /**
24
- * Overrides {@link T11.Pattern}
25
- */
26
- export type Pattern = BgpPattern | BlockPattern | FilterPattern | BindPattern | ValuesPattern | Omit<SelectQuery, 'prefixes'>;
27
- export type FunctionCallExpression = Patch<T11.FunctionCallExpression, {
28
- args: Expression[];
29
- }>;
30
- export type BgpPattern = Patch<T11.BgpPattern, {
31
- triples: Triple[];
32
- }>;
33
- export type GraphQuads = Patch<T11.GraphQuads, {
34
- triples: Triple[];
35
- }>;
36
- export type VariableTerm = T11.VariableTerm;
37
- export type IriTerm<IRI extends string = string> = T11.IriTerm<IRI>;
38
- export type LiteralTerm = T11.LiteralTerm;
39
- export type BlankTerm = T11.BlankTerm;
40
- export type PropertyPath = NegatedPropertySet | {
41
- type: 'path';
42
- pathType: '|' | '/' | '^' | '+' | '*' | '?';
43
- items: (IriTerm | PropertyPath)[];
16
+ export type UpdateOperationBase = Node & {
17
+ type: 'updateOperation';
18
+ subType: string;
44
19
  };
45
- /**
46
- * Overrides {@link T11.SparqlQuery}
47
- */
48
- export type SparqlQuery = Query | Update | Pick<Update, 'base' | 'prefixes'>;
49
- /**
50
- * Overrides {@link T11.Query}
51
- */
52
- export type Query = SelectQuery | ConstructQuery | AskQuery | DescribeQuery;
53
- export type SelectQuery = Patch<T11.SelectQuery, BaseQuery>;
54
- export type Grouping = Patch<T11.Grouping, {
55
- expression: Expression;
56
- }>;
57
- export type Ordering = Patch<T11.Ordering, {
58
- expression: Expression;
59
- }>;
60
- export type ConstructQuery = Patch<T11.ConstructQuery, BaseQuery & {
61
- template?: Triple[] | undefined;
62
- }>;
63
- export type AskQuery = Patch<T11.AskQuery, BaseQuery>;
64
- export type DescribeQuery = Patch<T11.DescribeQuery, BaseQuery>;
65
- export type Update = Patch<T11.Update, {
66
- updates: UpdateOperation;
67
- }>;
68
- /**
69
- * Overrides {@link T11.UpdateOperation}
70
- */
71
- export type UpdateOperation = InsertDeleteOperation | ManagementOperation;
72
- /**
73
- * Overrides {@link T11.InsertDeleteOperation}
74
- */
75
- export type InsertDeleteOperation = InsertOperation | DeleteOperation | ModifyOperation | DeleteWhereOperation;
76
- export type InsertOperation = Patch<T11.InsertOperation, {
77
- insert: Quads[];
78
- }>;
79
- export type DeleteOperation = Patch<T11.DeleteOperation, {
80
- delete: Quads[];
81
- }>;
82
- export type ModifyOperation = Patch<T11.ModifyOperation, {
20
+ export type UpdateOperationLoad = UpdateOperationBase & {
21
+ subType: 'load';
22
+ silent: boolean;
23
+ source: TermIri;
24
+ destination?: GraphRefSpecific;
25
+ };
26
+ type UpdateOperationClearDropCreateBase = UpdateOperationBase & {
27
+ subType: 'clear' | 'drop' | 'create';
28
+ silent: boolean;
29
+ destination: GraphRef;
30
+ };
31
+ export type UpdateOperationClear = UpdateOperationClearDropCreateBase & {
32
+ subType: 'clear';
33
+ };
34
+ export type UpdateOperationDrop = UpdateOperationClearDropCreateBase & {
35
+ subType: 'drop';
36
+ };
37
+ export type UpdateOperationCreate = UpdateOperationClearDropCreateBase & {
38
+ subType: 'create';
39
+ destination: GraphRefSpecific;
40
+ };
41
+ type UpdateOperationAddMoveCopy = UpdateOperationBase & {
42
+ subType: 'add' | 'move' | 'copy';
43
+ silent: boolean;
44
+ source: GraphRefDefault | GraphRefSpecific;
45
+ destination: GraphRefDefault | GraphRefSpecific;
46
+ };
47
+ export type UpdateOperationAdd = UpdateOperationAddMoveCopy & {
48
+ subType: 'add';
49
+ };
50
+ export type UpdateOperationMove = UpdateOperationAddMoveCopy & {
51
+ subType: 'move';
52
+ };
53
+ export type UpdateOperationCopy = UpdateOperationAddMoveCopy & {
54
+ subType: 'copy';
55
+ };
56
+ type UpdateOperationInsertDeleteDelWhere = UpdateOperationBase & {
57
+ subType: 'insertdata' | 'deletedata' | 'deletewhere';
58
+ data: Quads[];
59
+ };
60
+ export type UpdateOperationInsertData = UpdateOperationInsertDeleteDelWhere & {
61
+ subType: 'insertdata';
62
+ };
63
+ export type UpdateOperationDeleteData = UpdateOperationInsertDeleteDelWhere & {
64
+ subType: 'deletedata';
65
+ };
66
+ export type UpdateOperationDeleteWhere = UpdateOperationInsertDeleteDelWhere & {
67
+ subType: 'deletewhere';
68
+ };
69
+ export type UpdateOperationModify = UpdateOperationBase & {
70
+ subType: 'modify';
71
+ graph: TermIri | undefined;
83
72
  insert: Quads[];
84
73
  delete: Quads[];
85
- where: Pattern[];
86
- }>;
87
- export type DeleteWhereOperation = Patch<T11.DeleteWhereOperation, {
88
- delete: Quads[];
89
- }>;
74
+ from: DatasetClauses;
75
+ where: PatternGroup;
76
+ };
77
+ export type UpdateOperation = UpdateOperationLoad | UpdateOperationClear | UpdateOperationDrop | UpdateOperationCreate | UpdateOperationAdd | UpdateOperationMove | UpdateOperationCopy | UpdateOperationInsertData | UpdateOperationDeleteData | UpdateOperationDeleteWhere | UpdateOperationModify;
78
+ export type Update = Node & {
79
+ type: 'update';
80
+ updates: {
81
+ operation?: UpdateOperation;
82
+ context: ContextDefinition[];
83
+ }[];
84
+ };
85
+ export type QueryBase = Node & {
86
+ type: 'query';
87
+ subType: string;
88
+ context: ContextDefinition[];
89
+ values?: PatternValues;
90
+ solutionModifiers: SolutionModifiers;
91
+ datasets: DatasetClauses;
92
+ where?: PatternGroup;
93
+ };
94
+ export type QuerySelect = QueryBase & {
95
+ subType: 'select';
96
+ variables: (TermVariable | PatternBind)[] | [Wildcard];
97
+ distinct?: true;
98
+ reduced?: true;
99
+ where: PatternGroup;
100
+ };
101
+ export type QueryConstruct = QueryBase & {
102
+ subType: 'construct';
103
+ template: PatternBgp;
104
+ where: PatternGroup;
105
+ };
106
+ export type QueryDescribe = QueryBase & {
107
+ subType: 'describe';
108
+ variables: (TermVariable | TermIri)[] | [Wildcard];
109
+ };
110
+ export type QueryAsk = QueryBase & {
111
+ subType: 'ask';
112
+ where: PatternGroup;
113
+ };
114
+ export type Query = QuerySelect | QueryConstruct | QueryDescribe | QueryAsk;
115
+ export type SparqlQuery = Query | Update;
116
+ export type DatasetClauses = Node & {
117
+ type: 'datasetClauses';
118
+ clauses: {
119
+ clauseType: 'default' | 'named';
120
+ value: TermIri;
121
+ }[];
122
+ };
123
+ export type TripleCollectionBase = Node & {
124
+ type: 'tripleCollection';
125
+ subType: string;
126
+ triples: TripleNesting[];
127
+ identifier: Term;
128
+ };
90
129
  /**
91
- * Overrides {@link T11.Quads}
130
+ * Both subject and predicate of the triples do not have a string manifestation.
92
131
  */
93
- export type Quads = BgpPattern | GraphQuads;
132
+ export type TripleCollectionList = TripleCollectionBase & {
133
+ subType: 'list';
134
+ identifier: TermBlank;
135
+ };
94
136
  /**
95
- * Overrides {@link T11.ManagementOperation}
137
+ * The subject of the triples does not have a string manifestation.
96
138
  */
97
- export type ManagementOperation = CopyMoveAddOperation | LoadOperation | CreateOperation | ClearDropOperation;
98
- export type CopyMoveAddOperation = T11.CopyMoveAddOperation;
99
- export type LoadOperation = T11.LoadOperation;
100
- export type CreateOperation = T11.CreateOperation;
101
- export type ClearDropOperation = T11.ClearDropOperation;
102
- export type GraphOrDefault = T11.GraphOrDefault;
103
- export type GraphReference = T11.GraphReference;
104
- export type Variable = T11.Variable;
105
- export type VariableExpression = Patch<T11.VariableExpression, {
106
- expression: Expression;
139
+ export type TripleCollectionBlankNodeProperties = Patch<T11.TripleCollectionBlankNodeProperties, {
140
+ triples: TripleNesting[];
141
+ identifier: TermBlank | TermVariable | TermIri;
107
142
  }>;
108
- export type BaseQuery = Patch<T11.BaseQuery, {
109
- where?: Pattern[] | undefined;
110
- values?: ValuePatternRow[] | undefined;
111
- having?: Expression[] | undefined;
112
- group?: Grouping[] | undefined;
113
- order: Ordering[] | undefined;
114
- }>;
115
- export type IriTermOrElt = T11.IriTermOrElt;
116
- export type NegatedPropertySet = T11.NegatedPropertySet;
117
- export type GroupPattern = Patch<T11.GroupPattern, {
118
- patterns: Pattern[];
119
- }>;
120
- export type GraphPattern = Patch<T11.GraphPattern, {
143
+ export type TripleCollectionReifiedTriple = TripleCollectionBase & {
144
+ subType: 'reifiedTriple';
145
+ identifier: TermVariable | TermIri | TermBlank;
146
+ };
147
+ export type TripleCollection = TripleCollectionList | TripleCollectionBlankNodeProperties | TripleCollectionReifiedTriple;
148
+ export type GraphNode = Term | TripleCollection;
149
+ export type Annotation = TripleCollectionBlankNodeProperties | TermVariable | TermIri | TermBlank;
150
+ export type TripleNesting = Node & {
151
+ type: 'triple';
152
+ subject: GraphNode;
153
+ predicate: TermIri | TermVariable | Path;
154
+ object: GraphNode;
155
+ annotations?: Annotation[];
156
+ };
157
+ export type PatternBase = Node & {
158
+ type: 'pattern';
159
+ subType: string;
160
+ };
161
+ export type PatternFilter = PatternBase & {
162
+ subType: 'filter';
163
+ expression: Expression;
164
+ };
165
+ export type PatternMinus = PatternBase & {
166
+ subType: 'minus';
121
167
  patterns: Pattern[];
122
- }>;
123
- export type MinusPattern = Patch<T11.MinusPattern, {
168
+ };
169
+ export type PatternGroup = PatternBase & {
170
+ subType: 'group';
124
171
  patterns: Pattern[];
125
- }>;
126
- export type ServicePattern = Patch<T11.ServicePattern, {
172
+ };
173
+ export type PatternOptional = PatternBase & {
174
+ subType: 'optional';
127
175
  patterns: Pattern[];
128
- }>;
129
- /**
130
- * Overrides {@link T11.BlockPattern}
131
- */
132
- export type BlockPattern = OptionalPattern | UnionPattern | GroupPattern | GraphPattern | MinusPattern | ServicePattern;
133
- export type OptionalPattern = Patch<T11.OptionalPattern, {
176
+ };
177
+ export type PatternGraph = PatternBase & {
178
+ subType: 'graph';
179
+ name: TermIri | TermVariable;
134
180
  patterns: Pattern[];
135
- }>;
136
- export type UnionPattern = Patch<T11.UnionPattern, {
181
+ };
182
+ export type PatternUnion = PatternBase & {
183
+ subType: 'union';
184
+ patterns: PatternGroup[];
185
+ };
186
+ export type BasicGraphPattern = (TripleNesting | TripleCollection)[];
187
+ export type PatternBgp = PatternBase & {
188
+ subType: 'bgp';
189
+ /**
190
+ * Only the first appearance of a subject and predicate have a string manifestation
191
+ */
192
+ triples: BasicGraphPattern;
193
+ };
194
+ export type PatternBind = PatternBase & {
195
+ subType: 'bind';
196
+ expression: Expression;
197
+ variable: TermVariable;
198
+ };
199
+ export type PatternService = PatternBase & {
200
+ subType: 'service';
201
+ name: TermIri | TermVariable;
202
+ silent: boolean;
137
203
  patterns: Pattern[];
138
- }>;
204
+ };
139
205
  /**
140
- * Overrides {@link T11.ValuePatternRow}
206
+ * A single list of assignments maps the variable identifier to the value
141
207
  */
142
- export type ValuePatternRow = Record<string, IriTerm | BlankTerm | LiteralTerm | BaseQuery | undefined>;
143
- export type FilterPattern = Patch<T11.FilterPattern, {
144
- expression: Expression;
145
- }>;
146
- export type BindPattern = Patch<T11.BindPattern, {
147
- expression: Expression;
148
- }>;
149
- export type ValuesPattern = Patch<T11.ValuesPattern, {
208
+ export type ValuePatternRow = Record<string, TermIri | TermLiteral | undefined>;
209
+ export type PatternValues = PatternBase & {
210
+ subType: 'values';
150
211
  values: ValuePatternRow[];
151
- }>;
152
- export type BaseExpression = T11.BaseExpression;
153
- export type OperationExpression = Patch<T11.OperationExpression, BaseExpression & {
154
- args: Expression[] | [Pattern];
155
- }>;
156
- export type AggregateExpression = Patch<T11.AggregateExpression, BaseExpression & {
157
- expression: Expression | T11.Wildcard;
158
- }>;
212
+ };
213
+ export type SubSelect = QuerySelect;
214
+ export type Pattern = PatternBgp | PatternGroup | PatternUnion | PatternOptional | PatternMinus | PatternGraph | PatternService | PatternFilter | PatternBind | PatternValues | SubSelect;
215
+ export type SolutionModifiers = {
216
+ group?: SolutionModifierGroup;
217
+ having?: SolutionModifierHaving;
218
+ order?: SolutionModifierOrder;
219
+ limitOffset?: SolutionModifierLimitOffset;
220
+ };
221
+ export type SolutionModifierBase = Node & {
222
+ type: 'solutionModifier';
223
+ subType: string;
224
+ };
225
+ export type SolutionModifierGroupBind = Localized & {
226
+ variable: TermVariable;
227
+ value: Expression;
228
+ };
229
+ export type SolutionModifierGroup = SolutionModifierBase & {
230
+ subType: 'group';
231
+ groupings: (Expression | SolutionModifierGroupBind)[];
232
+ };
233
+ export type SolutionModifierHaving = SolutionModifierBase & {
234
+ subType: 'having';
235
+ having: Expression[];
236
+ };
237
+ export type Ordering = Expression | (Localized & {
238
+ descending: boolean;
239
+ expression: Expression;
240
+ });
241
+ export type SolutionModifierOrder = SolutionModifierBase & {
242
+ subType: 'order';
243
+ orderDefs: Ordering[];
244
+ };
245
+ export type SolutionModifierLimitOffset = T11.SolutionModifierLimitOffset;
246
+ export type SolutionModifier = SolutionModifierGroup | SolutionModifierHaving | SolutionModifierOrder | SolutionModifierLimitOffset;
247
+ export type ExpressionBase = Node & {
248
+ type: 'expression';
249
+ subType: string;
250
+ };
251
+ type ExpressionAggregateBase = ExpressionBase & {
252
+ subType: 'aggregate';
253
+ distinct: boolean;
254
+ };
255
+ export type ExpressionAggregateDefault = ExpressionAggregateBase & {
256
+ expression: [Expression];
257
+ aggregation: string;
258
+ };
259
+ export type ExpressionAggregateOnWildcard = ExpressionAggregateBase & {
260
+ expression: [Wildcard];
261
+ aggregation: string;
262
+ };
263
+ export type ExpressionAggregateSeparator = ExpressionAggregateBase & {
264
+ expression: [Expression];
265
+ aggregation: string;
266
+ separator: string;
267
+ };
268
+ export type ExpressionAggregate = ExpressionAggregateDefault | ExpressionAggregateOnWildcard | ExpressionAggregateSeparator;
269
+ export type ExpressionOperation = ExpressionBase & {
270
+ subType: 'operation';
271
+ operator: string;
272
+ args: Expression[];
273
+ };
274
+ export type ExpressionPatternOperation = ExpressionBase & {
275
+ subType: 'patternOperation';
276
+ operator: string;
277
+ args: PatternGroup;
278
+ };
279
+ export type ExpressionFunctionCall = ExpressionBase & {
280
+ subType: 'functionCall';
281
+ function: TermIri;
282
+ distinct: boolean;
283
+ args: Expression[];
284
+ };
285
+ export type Expression = ExpressionOperation | ExpressionPatternOperation | ExpressionFunctionCall | ExpressionAggregate | TermIri | TermVariable | TermLiteral | TermTriple;
286
+ export type PropertyPathChain = T11.PropertyPathChain;
287
+ export type PathModified = T11.PathModified;
288
+ export type PathNegatedElt = T11.PathNegatedElt;
289
+ export type PathAlternativeLimited = T11.PathAlternativeLimited;
290
+ export type PathNegated = T11.PathNegated;
291
+ export type Path = T11.Path;
292
+ export type ContextDefinitionPrefix = T11.ContextDefinitionPrefix;
293
+ export type ContextDefinitionBase = T11.ContextDefinitionBase;
294
+ export type ContextDefinitionVersion = T11.ContextDefinitionBase_ & {
295
+ subType: 'version';
296
+ version: string;
297
+ };
298
+ export type ContextDefinition = T11.ContextDefinition | ContextDefinitionVersion;
299
+ export type Wildcard = T11.Wildcard;
300
+ export type TermLiteralStr = T11.TermLiteralStr;
301
+ export type TermLiteralLangStr = T11.TermLiteralLangStr;
302
+ export type TermLiteralTyped = T11.TermLiteralTyped;
303
+ export type TermLiteral = T11.TermLiteral;
304
+ export type TermVariable = T11.TermVariable;
305
+ export type TermIriFull = T11.TermIriFull;
306
+ export type TermIriPrefixed = T11.TermIriPrefixed;
307
+ export type TermIri = T11.TermIri;
308
+ export type TermBlank = T11.TermBlank;
309
+ export type TermTriple = T11.TermBase & {
310
+ subType: 'triple';
311
+ subject: Term;
312
+ predicate: TermIri | TermVariable;
313
+ object: Term;
314
+ };
315
+ export type Term = GraphTerm | TermVariable;
316
+ export type GraphTerm = TermIri | TermBlank | TermLiteral | TermTriple;
317
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"sparql12Types.js","sourceRoot":"","sources":["sparql12Types.ts"],"names":[],"mappings":"","sourcesContent":["import type * as RDF from '@rdfjs/types';\nimport type { Patch } from '@traqula/core';\nimport type * as T11 from '@traqula/rules-sparql-1-1';\n\nexport type BaseQuadTerm = RDF.BaseQuad & { subject: Term; predicate: Term; object: Term };\nexport type GraphTerm = IriTerm | BlankTerm | LiteralTerm | BaseQuadTerm;\nexport type Term = GraphTerm | VariableTerm;\n\nexport type Expression = T11.Expression | BaseQuadTerm;\n\n// Overriding other types\nexport type Triple = Patch<T11.Triple, { subject: Term; object: Term }>;\n\nexport type IGraphNode = Patch<T11.IGraphNode, { triples: Triple[]; node: ITriplesNode['node'] | Term }>;\n\nexport type ITriplesNode = Patch<T11.ITriplesNode, { triples: Triple[] }>;\n\n/**\n * Overrides {@link T11.Pattern}\n */\nexport type Pattern =\n | BgpPattern\n | BlockPattern\n | FilterPattern\n | BindPattern\n | ValuesPattern\n | Omit<SelectQuery, 'prefixes'>;\n\nexport type FunctionCallExpression = Patch<T11.FunctionCallExpression, { args: Expression[] }>;\n\nexport type BgpPattern = Patch<T11.BgpPattern, { triples: Triple[] }>;\n\nexport type GraphQuads = Patch<T11.GraphQuads, { triples: Triple[] }>;\n\nexport type VariableTerm = T11.VariableTerm;\nexport type IriTerm<IRI extends string = string> = T11.IriTerm<IRI>;\nexport type LiteralTerm = T11.LiteralTerm;\nexport type BlankTerm = T11.BlankTerm;\n\nexport type PropertyPath = NegatedPropertySet | {\n type: 'path';\n pathType: '|' | '/' | '^' | '+' | '*' | '?';\n items: (IriTerm | PropertyPath)[];\n};\n\n/**\n * Overrides {@link T11.SparqlQuery}\n */\nexport type SparqlQuery = Query | Update | Pick<Update, 'base' | 'prefixes'>;\n\n/**\n * Overrides {@link T11.Query}\n */\nexport type Query = SelectQuery | ConstructQuery | AskQuery | DescribeQuery;\n\nexport type SelectQuery = Patch<T11.SelectQuery, BaseQuery>;\n\nexport type Grouping = Patch<T11.Grouping, { expression: Expression }>;\n\nexport type Ordering = Patch<T11.Ordering, { expression: Expression }>;\n\nexport type ConstructQuery = Patch<T11.ConstructQuery, BaseQuery & { template?: Triple[] | undefined }>;\n\nexport type AskQuery = Patch<T11.AskQuery, BaseQuery>;\n\nexport type DescribeQuery = Patch<T11.DescribeQuery, BaseQuery>;\n\nexport type Update = Patch<T11.Update, { updates: UpdateOperation }>;\n\n/**\n * Overrides {@link T11.UpdateOperation}\n */\nexport type UpdateOperation = InsertDeleteOperation | ManagementOperation;\n\n/**\n * Overrides {@link T11.InsertDeleteOperation}\n */\nexport type InsertDeleteOperation = InsertOperation | DeleteOperation | ModifyOperation | DeleteWhereOperation;\n\nexport type InsertOperation = Patch<T11.InsertOperation, { insert: Quads[] }>;\n\nexport type DeleteOperation = Patch<T11.DeleteOperation, { delete: Quads[] }>;\n\nexport type ModifyOperation = Patch<T11.ModifyOperation, {\n insert: Quads[];\n delete: Quads[];\n where: Pattern[];\n}>;\n\nexport type DeleteWhereOperation = Patch<T11.DeleteWhereOperation, { delete: Quads[] }>;\n\n/**\n * Overrides {@link T11.Quads}\n */\nexport type Quads = BgpPattern | GraphQuads;\n\n/**\n * Overrides {@link T11.ManagementOperation}\n */\nexport type ManagementOperation =\n | CopyMoveAddOperation\n | LoadOperation\n | CreateOperation\n | ClearDropOperation;\n\nexport type CopyMoveAddOperation = T11.CopyMoveAddOperation;\nexport type LoadOperation = T11.LoadOperation;\nexport type CreateOperation = T11.CreateOperation;\nexport type ClearDropOperation = T11.ClearDropOperation;\nexport type GraphOrDefault = T11.GraphOrDefault;\nexport type GraphReference = T11.GraphReference;\nexport type Variable = T11.Variable;\n\nexport type VariableExpression = Patch<T11.VariableExpression, { expression: Expression }>;\n\nexport type BaseQuery = Patch<T11.BaseQuery, {\n where?: Pattern[] | undefined;\n values?: ValuePatternRow[] | undefined;\n having?: Expression[] | undefined;\n group?: Grouping[] | undefined;\n order: Ordering[] | undefined;\n}>;\n\nexport type IriTermOrElt = T11.IriTermOrElt;\nexport type NegatedPropertySet = T11.NegatedPropertySet;\n\nexport type GroupPattern = Patch<T11.GroupPattern, { patterns: Pattern[] }>;\nexport type GraphPattern = Patch<T11.GraphPattern, { patterns: Pattern[] }>;\nexport type MinusPattern = Patch<T11.MinusPattern, { patterns: Pattern[] }>;\nexport type ServicePattern = Patch<T11.ServicePattern, { patterns: Pattern[] }>;\n\n/**\n * Overrides {@link T11.BlockPattern}\n */\nexport type BlockPattern =\n | OptionalPattern\n | UnionPattern\n | GroupPattern\n | GraphPattern\n | MinusPattern\n | ServicePattern;\n\nexport type OptionalPattern = Patch<T11.OptionalPattern, { patterns: Pattern[] }>;\nexport type UnionPattern = Patch<T11.UnionPattern, { patterns: Pattern[] }>;\n\n/**\n * Overrides {@link T11.ValuePatternRow}\n */\nexport type ValuePatternRow = Record<string, IriTerm | BlankTerm | LiteralTerm | BaseQuery | undefined>;\n\nexport type FilterPattern = Patch<T11.FilterPattern, { expression: Expression }>;\nexport type BindPattern = Patch<T11.BindPattern, { expression: Expression }>;\nexport type ValuesPattern = Patch<T11.ValuesPattern, { values: ValuePatternRow[] }>;\nexport type BaseExpression = T11.BaseExpression;\n\nexport type OperationExpression = Patch<T11.OperationExpression, BaseExpression & {\n args: Expression[] | [Pattern];\n}>;\nexport type AggregateExpression = Patch<T11.AggregateExpression, BaseExpression & {\n expression: Expression | T11.Wildcard;\n}>;\n"]}
1
+ {"version":3,"file":"sparql12Types.js","sourceRoot":"","sources":["sparql12Types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Localized, Node, Patch } from '@traqula/core';\nimport type * as T11 from '@traqula/rules-sparql-1-1';\n\nexport type Sparql12Nodes =\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 = T11.GraphRefBase;\nexport type GraphRefDefault = T11.GraphRefDefault;\nexport type GraphRefNamed = T11.GraphRefNamed;\nexport type GraphRefAll = T11.GraphRefAll;\nexport type GraphRefSpecific = T11.GraphRefSpecific;\nexport type GraphRef = T11.GraphRef;\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 * Both subject and predicate of the triples do not have a string manifestation.\n */\nexport type TripleCollectionList = TripleCollectionBase & {\n subType: 'list';\n identifier: TermBlank;\n};\n/**\n * The subject of the triples does not have a string manifestation.\n */\nexport type TripleCollectionBlankNodeProperties = Patch<T11.TripleCollectionBlankNodeProperties, {\n triples: TripleNesting[];\n identifier: TermBlank | TermVariable | TermIri;\n}>;\nexport type TripleCollectionReifiedTriple = TripleCollectionBase & {\n subType: 'reifiedTriple';\n identifier: TermVariable | TermIri | TermBlank;\n};\n\nexport type TripleCollection =\n | TripleCollectionList\n | TripleCollectionBlankNodeProperties\n | TripleCollectionReifiedTriple;\n\n// https://www.w3.org/TR/sparql11-query/#rGraphNode\nexport type GraphNode = Term | TripleCollection;\nexport type Annotation = TripleCollectionBlankNodeProperties | TermVariable | TermIri | TermBlank;\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 annotations?: Annotation[];\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 =\n | Expression\n | (Localized & { descending: boolean; expression: Expression });\nexport type SolutionModifierOrder = SolutionModifierBase & {\n subType: 'order';\n orderDefs: Ordering[];\n};\nexport type SolutionModifierLimitOffset = T11.SolutionModifierLimitOffset;\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};\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 | TermTriple;\n\nexport type PropertyPathChain = T11.PropertyPathChain;\nexport type PathModified = T11.PathModified;\nexport type PathNegatedElt = T11.PathNegatedElt;\nexport type PathAlternativeLimited = T11.PathAlternativeLimited;\nexport type PathNegated = T11.PathNegated;\n// [[88]](https://www.w3.org/TR/sparql11-query/#rPath)\nexport type Path = T11.Path;\n\nexport type ContextDefinitionPrefix = T11.ContextDefinitionPrefix;\nexport type ContextDefinitionBase = T11.ContextDefinitionBase;\nexport type ContextDefinitionVersion = T11.ContextDefinitionBase_ & {\n subType: 'version';\n version: string;\n};\nexport type ContextDefinition = T11.ContextDefinition | ContextDefinitionVersion;\n\nexport type Wildcard = T11.Wildcard;\nexport type TermLiteralStr = T11.TermLiteralStr;\nexport type TermLiteralLangStr = T11.TermLiteralLangStr;\nexport type TermLiteralTyped = T11.TermLiteralTyped;\nexport type TermLiteral = T11.TermLiteral;\nexport type TermVariable = T11.TermVariable;\nexport type TermIriFull = T11.TermIriFull;\nexport type TermIriPrefixed = T11.TermIriPrefixed;\nexport type TermIri = T11.TermIri;\nexport type TermBlank = T11.TermBlank;\n\nexport type TermTriple = T11.TermBase & {\n subType: 'triple';\n subject: Term;\n predicate: TermIri | TermVariable;\n object: Term;\n};\n\nexport type Term = GraphTerm | TermVariable;\nexport type GraphTerm = TermIri | TermBlank | TermLiteral | TermTriple;\n"]}
@@ -0,0 +1,2 @@
1
+ import type { TermLiteral } from './sparql12Types';
2
+ export declare function langTagHasCorrectDomain(literal: TermLiteral): void;
@@ -0,0 +1,17 @@
1
+ import { Factory } from '@traqula/rules-sparql-1-1';
2
+ const F = new Factory();
3
+ function isLangDir(dir) {
4
+ return dir === 'ltr' || dir === 'rtl';
5
+ }
6
+ export function langTagHasCorrectDomain(literal) {
7
+ if (F.isTermLiteralLangStr(literal)) {
8
+ const dirSplit = literal.langOrIri.split('--');
9
+ if (dirSplit.length > 1) {
10
+ const [_, direction] = dirSplit;
11
+ if (!isLangDir(direction)) {
12
+ throw new Error(`language direction "${direction}" of literal "${JSON.stringify(literal)}" is not is required range 'ltr' | 'rtl'.`);
13
+ }
14
+ }
15
+ }
16
+ }
17
+ //# sourceMappingURL=validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validator.js","sourceRoot":"","sources":["validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,2BAA2B,CAAC;AAGpD,MAAM,CAAC,GAAG,IAAI,OAAO,EAAE,CAAC;AAExB,SAAS,SAAS,CAAC,GAAW;IAC5B,OAAO,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,KAAK,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAoB;IAC1D,IAAI,CAAC,CAAC,oBAAoB,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC/C,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACxB,MAAM,CAAE,CAAC,EAAE,SAAS,CAAE,GAAG,QAAQ,CAAC;YAClC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC1B,MAAM,IAAI,KAAK,CAAC,uBAAuB,SAAS,iBAAiB,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,2CAA2C,CAAC,CAAC;YACvI,CAAC;QACH,CAAC;IACH,CAAC;AACH,CAAC","sourcesContent":["import { Factory } from '@traqula/rules-sparql-1-1';\nimport type { TermLiteral } from './sparql12Types';\n\nconst F = new Factory();\n\nfunction isLangDir(dir: string): dir is 'ltr' | 'rtl' {\n return dir === 'ltr' || dir === 'rtl';\n}\n\nexport function langTagHasCorrectDomain(literal: TermLiteral): void {\n if (F.isTermLiteralLangStr(literal)) {\n const dirSplit = literal.langOrIri.split('--');\n if (dirSplit.length > 1) {\n const [ _, direction ] = dirSplit;\n if (!isLangDir(direction)) {\n throw new Error(`language direction \"${direction}\" of literal \"${JSON.stringify(literal)}\" is not is required range 'ltr' | 'rtl'.`);\n }\n }\n }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@traqula/rules-sparql-1-2",
3
3
  "type": "module",
4
- "version": "0.0.1-alpha.176+9400dc5",
4
+ "version": "0.0.1-alpha.9+427f381",
5
5
  "description": "Traqula Lexer and Grammar Rules for sparql 1.2",
6
6
  "lsd:module": true,
7
7
  "license": "MIT",
@@ -38,11 +38,8 @@
38
38
  "build:transpile": " node \"../../node_modules/esbuild/bin/esbuild\" --format=cjs --bundle --log-level=error --outfile=lib/index.cjs lib/index.ts"
39
39
  },
40
40
  "dependencies": {
41
- "@traqula/core": "^0.0.1-alpha.176+9400dc5",
42
- "@traqula/rules-sparql-1-1": "^0.0.1-alpha.176+9400dc5"
41
+ "@traqula/core": "^0.0.1-alpha.9+427f381",
42
+ "@traqula/rules-sparql-1-1": "^0.0.1-alpha.9+427f381"
43
43
  },
44
- "devDependencies": {
45
- "@rdfjs/types": "^2.0.0"
46
- },
47
- "gitHead": "9400dc5f8bda1d8c2b3d1f4cf56b308995744ba0"
44
+ "gitHead": "427f3819138dd557621cae40c761213573e60017"
48
45
  }