@ldo/traverser-shexj 0.0.1-alpha.14
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/README.md +879 -0
- package/dist/ShexJTraverser.d.ts +316 -0
- package/dist/ShexJTraverser.js +7 -0
- package/dist/ShexJTraverser.js.map +1 -0
- package/dist/ShexJTraverserDefinition.d.ts +3 -0
- package/dist/ShexJTraverserDefinition.js +291 -0
- package/dist/ShexJTraverserDefinition.js.map +1 -0
- package/dist/ShexJTraverserTypes.d.ts +317 -0
- package/dist/ShexJTraverserTypes.js +3 -0
- package/dist/ShexJTraverserTypes.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/package.json +39 -0
- package/src/ShexJTraverser.ts +7 -0
- package/src/ShexJTraverserDefinition.ts +303 -0
- package/src/ShexJTraverserTypes.ts +375 -0
- package/src/index.ts +5 -0
package/README.md
ADDED
|
@@ -0,0 +1,879 @@
|
|
|
1
|
+
# ShexJ Traverser
|
|
2
|
+
|
|
3
|
+
Traverse a ShexJ schema with custom functionality.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
```bash
|
|
7
|
+
npm i shexj-traverser
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Tutorial
|
|
11
|
+
This library uses `type-traverser`. To learn more about how type traverser can be used, go to the [Type Traverser Tutorial](https://github.com/o-development/type-traverser/blob/master/README.md#using-a-traverser).
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
There are two ways you can use the ShexJ-Traverser:
|
|
15
|
+
- A `visitor`
|
|
16
|
+
- A `transformer`
|
|
17
|
+
|
|
18
|
+
### Visitor
|
|
19
|
+
This visitor shows all the possible visitor functions you can use. Note that you do not need to define every visitor function, only the ones you care about.
|
|
20
|
+
|
|
21
|
+
Run `npm run start` to see this code in action.
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
const shexJVisitor = shexJTraverser.createVisitor<undefined>({
|
|
25
|
+
Schema: {
|
|
26
|
+
visitor: async (_item, _context) => {
|
|
27
|
+
console.log("Schema");
|
|
28
|
+
},
|
|
29
|
+
properties: {
|
|
30
|
+
startActs: async (_item, _context) => {
|
|
31
|
+
console.log("Schema.startActs");
|
|
32
|
+
},
|
|
33
|
+
start: async (_item, _context) => {
|
|
34
|
+
console.log("Schema.start");
|
|
35
|
+
},
|
|
36
|
+
imports: async (_item, _context) => {
|
|
37
|
+
console.log("Schema.imports");
|
|
38
|
+
},
|
|
39
|
+
shapes: async (_item, _context) => {
|
|
40
|
+
console.log("Schema.shape");
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
shapeExpr: async (_item, _context) => {
|
|
45
|
+
console.log("shapeExpr");
|
|
46
|
+
},
|
|
47
|
+
ShapeOr: {
|
|
48
|
+
visitor: async (_item, _context) => {
|
|
49
|
+
console.log("ShapeOr");
|
|
50
|
+
},
|
|
51
|
+
properties: {
|
|
52
|
+
id: async (_item, _context) => {
|
|
53
|
+
console.log("ShapeOr.id");
|
|
54
|
+
},
|
|
55
|
+
shapeExprs: async (_item, _context) => {
|
|
56
|
+
console.log("ShapeOr.shapeExprs");
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
ShapeAnd: {
|
|
61
|
+
visitor: async (_item, _context) => {
|
|
62
|
+
console.log("ShapeAnd");
|
|
63
|
+
},
|
|
64
|
+
properties: {
|
|
65
|
+
id: async (_item, _context) => {
|
|
66
|
+
console.log("ShapeAnd.id");
|
|
67
|
+
},
|
|
68
|
+
shapeExprs: async (_item, _context) => {
|
|
69
|
+
console.log("ShapeAnd.shapeExprs");
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
ShapeNot: {
|
|
74
|
+
visitor: async (_item, _context) => {
|
|
75
|
+
console.log("ShapeNot");
|
|
76
|
+
},
|
|
77
|
+
properties: {
|
|
78
|
+
id: async (_item, _context) => {
|
|
79
|
+
console.log("ShapeNot.id");
|
|
80
|
+
},
|
|
81
|
+
shapeExpr: async (_item, _context) => {
|
|
82
|
+
console.log("ShapeNot.shapeExpr");
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
ShapeExternal: {
|
|
87
|
+
visitor: async (_item, _context) => {
|
|
88
|
+
console.log("ShapeExternal");
|
|
89
|
+
},
|
|
90
|
+
properties: {
|
|
91
|
+
id: async (_item, _context) => {
|
|
92
|
+
console.log("ShapeExternal.id");
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
shapeExprRef: async (_item, _context) => {
|
|
97
|
+
console.log("shapeExprRef");
|
|
98
|
+
},
|
|
99
|
+
NodeConstraint: {
|
|
100
|
+
visitor: async (_item, _context) => {
|
|
101
|
+
console.log("NodeConstraint");
|
|
102
|
+
},
|
|
103
|
+
properties: {
|
|
104
|
+
id: async (_item, _context) => {
|
|
105
|
+
console.log("NodeConstraint.id");
|
|
106
|
+
},
|
|
107
|
+
datatype: async (_item, _context) => {
|
|
108
|
+
console.log("NodeConstraint.datatype");
|
|
109
|
+
},
|
|
110
|
+
values: async (_item, _context) => {
|
|
111
|
+
console.log("NodeConstraint.values");
|
|
112
|
+
},
|
|
113
|
+
length: async (_item, _context) => {
|
|
114
|
+
console.log("NodeConstraint.length");
|
|
115
|
+
},
|
|
116
|
+
minlength: async (_item, _context) => {
|
|
117
|
+
console.log("NodeConstraint.minlength");
|
|
118
|
+
},
|
|
119
|
+
maxlength: async (_item, _context) => {
|
|
120
|
+
console.log("NodeConstraint.maxlength");
|
|
121
|
+
},
|
|
122
|
+
pattern: async (_item, _context) => {
|
|
123
|
+
console.log("NodeConstraint.pattern");
|
|
124
|
+
},
|
|
125
|
+
flags: async (_item, _context) => {
|
|
126
|
+
console.log("NodeConstraint.flags");
|
|
127
|
+
},
|
|
128
|
+
mininclusive: async (_item, _context) => {
|
|
129
|
+
console.log("NodeConstraint.mininclusive");
|
|
130
|
+
},
|
|
131
|
+
minexclusive: async (_item, _context) => {
|
|
132
|
+
console.log("NodeConstraint.minexclusive");
|
|
133
|
+
},
|
|
134
|
+
maxinclusive: async (_item, _context) => {
|
|
135
|
+
console.log("NodeConstraint.maxinclusive");
|
|
136
|
+
},
|
|
137
|
+
maxexclusive: async (_item, _context) => {
|
|
138
|
+
console.log("NodeConstraint.maxexclusive");
|
|
139
|
+
},
|
|
140
|
+
totaldigits: async (_item, _context) => {
|
|
141
|
+
console.log("NodeConstraint.totaldigits");
|
|
142
|
+
},
|
|
143
|
+
fractiondigits: async (_item, _context) => {
|
|
144
|
+
console.log("NodeConstraints.fractiondigits");
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
numericLiteral: async (_item, _context) => {
|
|
149
|
+
console.log("numericLiteral");
|
|
150
|
+
},
|
|
151
|
+
valueSetValue: async (_item, _context) => {
|
|
152
|
+
console.log("valueSetValue");
|
|
153
|
+
},
|
|
154
|
+
objectValue: async (_item, _context) => {
|
|
155
|
+
console.log("objectValue");
|
|
156
|
+
},
|
|
157
|
+
ObjectLiteral: {
|
|
158
|
+
visitor: async (_item, _context) => {
|
|
159
|
+
console.log("ObjectLiteral");
|
|
160
|
+
},
|
|
161
|
+
properties: {
|
|
162
|
+
value: async (_item, _context) => {
|
|
163
|
+
console.log("ObjectLiteral.value");
|
|
164
|
+
},
|
|
165
|
+
language: async (_item, _context) => {
|
|
166
|
+
console.log("ObjectLiteral.language");
|
|
167
|
+
},
|
|
168
|
+
type: async (_item, _context) => {
|
|
169
|
+
console.log("ObjectLiteral.type");
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
IriStem: {
|
|
174
|
+
visitor: async (_item, _context) => {
|
|
175
|
+
console.log("IriStem");
|
|
176
|
+
},
|
|
177
|
+
properties: {
|
|
178
|
+
stem: async (_item, _context) => {
|
|
179
|
+
console.log("IriStem.stem");
|
|
180
|
+
},
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
IriStemRange: {
|
|
184
|
+
visitor: async (_item, _context) => {
|
|
185
|
+
console.log("IriStemRange");
|
|
186
|
+
},
|
|
187
|
+
properties: {
|
|
188
|
+
stem: async (_item, _context) => {
|
|
189
|
+
console.log("IriStemRange.stem");
|
|
190
|
+
},
|
|
191
|
+
exclusions: async (_item, _context) => {
|
|
192
|
+
console.log("IriStemRange.exclusions");
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
IriStemRangeStem: async (_item, _context) => {
|
|
197
|
+
console.log("IriStemRangeStem");
|
|
198
|
+
},
|
|
199
|
+
IriStemRangeExclusions: async (_item, _context) => {
|
|
200
|
+
console.log("IriStemRangeExclusions");
|
|
201
|
+
},
|
|
202
|
+
LiteralStem: {
|
|
203
|
+
visitor: async (_item, _context) => {
|
|
204
|
+
console.log("LiteralStem");
|
|
205
|
+
},
|
|
206
|
+
properties: {
|
|
207
|
+
stem: async (_item, _context) => {
|
|
208
|
+
console.log("LiteralStem.stem");
|
|
209
|
+
},
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
LiteralStemRange: {
|
|
213
|
+
visitor: async (_item, _context) => {
|
|
214
|
+
console.log("LiteralStemRange");
|
|
215
|
+
},
|
|
216
|
+
properties: {
|
|
217
|
+
stem: async (_item, _context) => {
|
|
218
|
+
console.log("LiteralStemRange.stem");
|
|
219
|
+
},
|
|
220
|
+
exclusions: async (_item, _context) => {
|
|
221
|
+
console.log("LiteralStemRange.exclusions");
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
},
|
|
225
|
+
LiteralStemRangeStem: async (_item, _context) => {
|
|
226
|
+
console.log("LiteralStemRangeStem");
|
|
227
|
+
},
|
|
228
|
+
LiteralStemRangeExclusions: async (_item, _context) => {
|
|
229
|
+
console.log("LiteralStemRangeExclusions");
|
|
230
|
+
},
|
|
231
|
+
Language: {
|
|
232
|
+
visitor: async (_item, _context) => {
|
|
233
|
+
console.log("Language");
|
|
234
|
+
},
|
|
235
|
+
properties: {
|
|
236
|
+
languageTag: async (_item, _context) => {
|
|
237
|
+
console.log("Language.languageTag");
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
LanguageStem: {
|
|
242
|
+
visitor: async (_item, _context) => {
|
|
243
|
+
console.log("LanguageStem");
|
|
244
|
+
},
|
|
245
|
+
properties: {
|
|
246
|
+
stem: async (_item, _context) => {
|
|
247
|
+
console.log("LanguageStem.stem");
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
LanguageStemRange: {
|
|
252
|
+
visitor: async (_item, _context) => {
|
|
253
|
+
console.log("LanguageStemRange");
|
|
254
|
+
},
|
|
255
|
+
properties: {
|
|
256
|
+
stem: async (_item, _context) => {
|
|
257
|
+
console.log("LanguageStemRange.stem");
|
|
258
|
+
},
|
|
259
|
+
exclusions: async (_item, _context) => {
|
|
260
|
+
console.log("LanguageStemRange.exclusions");
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
LanguageStemRangeStem: async (_item, _context) => {
|
|
265
|
+
console.log("LanguageStemRangeStem");
|
|
266
|
+
},
|
|
267
|
+
LanguageStemRangeExclusions: async (_item, _context) => {
|
|
268
|
+
console.log("LanguageStemRangeExclusions");
|
|
269
|
+
},
|
|
270
|
+
Wildcard: {
|
|
271
|
+
visitor: async (_item, _context) => {
|
|
272
|
+
console.log("Wildcard");
|
|
273
|
+
},
|
|
274
|
+
},
|
|
275
|
+
Shape: {
|
|
276
|
+
visitor: async (_item, _context) => {
|
|
277
|
+
console.log("Shape");
|
|
278
|
+
},
|
|
279
|
+
properties: {
|
|
280
|
+
id: async (_item, _context) => {
|
|
281
|
+
console.log("Shape.id");
|
|
282
|
+
},
|
|
283
|
+
closed: async (_item, _context) => {
|
|
284
|
+
console.log("Shape.closed");
|
|
285
|
+
},
|
|
286
|
+
extra: async (_item, _context) => {
|
|
287
|
+
console.log("Shape.extra");
|
|
288
|
+
},
|
|
289
|
+
expression: async (_item, _context) => {
|
|
290
|
+
console.log("Shape.expression");
|
|
291
|
+
},
|
|
292
|
+
semActs: async (_item, _context) => {
|
|
293
|
+
console.log("Shape.semActs");
|
|
294
|
+
},
|
|
295
|
+
annotations: async (_item, _context) => {
|
|
296
|
+
console.log("Shape.annotations");
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
},
|
|
300
|
+
tripleExpr: async (_item, _context) => {
|
|
301
|
+
console.log("tripleExpr");
|
|
302
|
+
},
|
|
303
|
+
EachOf: {
|
|
304
|
+
visitor: async (_item, _context) => {
|
|
305
|
+
console.log("EachOf");
|
|
306
|
+
},
|
|
307
|
+
properties: {
|
|
308
|
+
expressions: async (_item, _context) => {
|
|
309
|
+
console.log("EachOf.expressions");
|
|
310
|
+
},
|
|
311
|
+
id: async (_item, _context) => {
|
|
312
|
+
console.log("EachOf.id");
|
|
313
|
+
},
|
|
314
|
+
min: async (_item, _context) => {
|
|
315
|
+
console.log("EachOf.min");
|
|
316
|
+
},
|
|
317
|
+
max: async (_item, _context) => {
|
|
318
|
+
console.log("EachOf.max");
|
|
319
|
+
},
|
|
320
|
+
semActs: async (_item, _context) => {
|
|
321
|
+
console.log("EachOf.semActs");
|
|
322
|
+
},
|
|
323
|
+
annotations: async (_item, _context) => {
|
|
324
|
+
console.log("EachOf.annotations");
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
},
|
|
328
|
+
OneOf: {
|
|
329
|
+
visitor: async (_item, _context) => {
|
|
330
|
+
console.log("OneOf");
|
|
331
|
+
},
|
|
332
|
+
properties: {
|
|
333
|
+
expressions: async (_item, _context) => {
|
|
334
|
+
console.log("OneOf.expressions");
|
|
335
|
+
},
|
|
336
|
+
id: async (_item, _context) => {
|
|
337
|
+
console.log("OneOf.id");
|
|
338
|
+
},
|
|
339
|
+
min: async (_item, _context) => {
|
|
340
|
+
console.log("OneOf.min");
|
|
341
|
+
},
|
|
342
|
+
max: async (_item, _context) => {
|
|
343
|
+
console.log("OneOf.max");
|
|
344
|
+
},
|
|
345
|
+
semActs: async (_item, _context) => {
|
|
346
|
+
console.log("OneOf.semActs");
|
|
347
|
+
},
|
|
348
|
+
annotations: async (_item, _context) => {
|
|
349
|
+
console.log("OneOf.annotations");
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
},
|
|
353
|
+
TripleConstraint: {
|
|
354
|
+
visitor: async (_item, _context) => {
|
|
355
|
+
console.log("TripleConstraint");
|
|
356
|
+
},
|
|
357
|
+
properties: {
|
|
358
|
+
inverse: async (_item, _context) => {
|
|
359
|
+
console.log("TripleConstraint.inverse");
|
|
360
|
+
},
|
|
361
|
+
predicate: async (_item, _context) => {
|
|
362
|
+
console.log("TripleConstraint.predicate");
|
|
363
|
+
},
|
|
364
|
+
valueExpr: async (_item, _context) => {
|
|
365
|
+
console.log("TripleConstraint.valueExpr");
|
|
366
|
+
},
|
|
367
|
+
id: async (_item, _context) => {
|
|
368
|
+
console.log("TripleConstraint.id");
|
|
369
|
+
},
|
|
370
|
+
min: async (_item, _context) => {
|
|
371
|
+
console.log("TripleConstraint.min");
|
|
372
|
+
},
|
|
373
|
+
max: async (_item, _context) => {
|
|
374
|
+
console.log("TripleConstraint.max");
|
|
375
|
+
},
|
|
376
|
+
semActs: async (_item, _context) => {
|
|
377
|
+
console.log("TripleConstraint.semActs");
|
|
378
|
+
},
|
|
379
|
+
annotations: async (_item, _context) => {
|
|
380
|
+
console.log("TripleConstraint.annotations");
|
|
381
|
+
},
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
tripleExprRef: async (_item, _context) => {
|
|
385
|
+
console.log("tripleExprRef");
|
|
386
|
+
},
|
|
387
|
+
SemAct: {
|
|
388
|
+
visitor: async (_item, _context) => {
|
|
389
|
+
console.log("SemAct");
|
|
390
|
+
},
|
|
391
|
+
properties: {
|
|
392
|
+
name: async (_item, _context) => {
|
|
393
|
+
console.log("SemAct.name");
|
|
394
|
+
},
|
|
395
|
+
code: async (_item, _context) => {
|
|
396
|
+
console.log("SemAct.code");
|
|
397
|
+
},
|
|
398
|
+
},
|
|
399
|
+
},
|
|
400
|
+
Annotation: {
|
|
401
|
+
visitor: async (_item, _context) => {
|
|
402
|
+
console.log("Annotation");
|
|
403
|
+
},
|
|
404
|
+
properties: {
|
|
405
|
+
predicate: async (_item, _context) => {
|
|
406
|
+
console.log("Annotation.predicate");
|
|
407
|
+
},
|
|
408
|
+
object: async (_item, _context) => {
|
|
409
|
+
console.log("Annotation.object");
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
},
|
|
413
|
+
IRIREF: async (_item, _context) => {
|
|
414
|
+
console.log("IRIREF");
|
|
415
|
+
},
|
|
416
|
+
STRING: async (_item, _context) => {
|
|
417
|
+
console.log("STRING");
|
|
418
|
+
},
|
|
419
|
+
LANGTAG: async (_item, _context) => {
|
|
420
|
+
console.log("LANGTAG");
|
|
421
|
+
},
|
|
422
|
+
INTEGER: async (_item, _context) => {
|
|
423
|
+
console.log("INTEGER");
|
|
424
|
+
},
|
|
425
|
+
BOOL: async (_item, _context) => {
|
|
426
|
+
console.log("BOOL");
|
|
427
|
+
},
|
|
428
|
+
IRI: async (_item, _context) => {
|
|
429
|
+
console.log("IRI");
|
|
430
|
+
},
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
/**
|
|
434
|
+
* Sample Data
|
|
435
|
+
*/
|
|
436
|
+
const simpleSchema: Schema = {
|
|
437
|
+
type: "Schema",
|
|
438
|
+
shapes: [
|
|
439
|
+
{
|
|
440
|
+
type: "Shape",
|
|
441
|
+
id: "http://shex.io/webapps/shex.js/doc/EmployeeShape",
|
|
442
|
+
expression: {
|
|
443
|
+
type: "EachOf",
|
|
444
|
+
expressions: [
|
|
445
|
+
{
|
|
446
|
+
type: "TripleConstraint",
|
|
447
|
+
predicate: "http://xmlns.com/foaf/0.1/givenName",
|
|
448
|
+
valueExpr: {
|
|
449
|
+
type: "NodeConstraint",
|
|
450
|
+
datatype: "http://www.w3.org/2001/XMLSchema#string",
|
|
451
|
+
},
|
|
452
|
+
min: 1,
|
|
453
|
+
max: -1,
|
|
454
|
+
},
|
|
455
|
+
{
|
|
456
|
+
type: "TripleConstraint",
|
|
457
|
+
predicate: "http://xmlns.com/foaf/0.1/familyName",
|
|
458
|
+
valueExpr: {
|
|
459
|
+
type: "NodeConstraint",
|
|
460
|
+
datatype: "http://www.w3.org/2001/XMLSchema#string",
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
type: "TripleConstraint",
|
|
465
|
+
predicate: "http://xmlns.com/foaf/0.1/phone",
|
|
466
|
+
valueExpr: {
|
|
467
|
+
type: "NodeConstraint",
|
|
468
|
+
nodeKind: "iri",
|
|
469
|
+
},
|
|
470
|
+
min: 0,
|
|
471
|
+
max: -1,
|
|
472
|
+
},
|
|
473
|
+
{
|
|
474
|
+
type: "TripleConstraint",
|
|
475
|
+
predicate: "http://xmlns.com/foaf/0.1/mbox",
|
|
476
|
+
valueExpr: {
|
|
477
|
+
type: "NodeConstraint",
|
|
478
|
+
nodeKind: "iri",
|
|
479
|
+
},
|
|
480
|
+
},
|
|
481
|
+
],
|
|
482
|
+
},
|
|
483
|
+
},
|
|
484
|
+
],
|
|
485
|
+
"@context": "http://www.w3.org/ns/shex.jsonld",
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
await shexJVisitor.visit(simpleSchema, "Schema", undefined);
|
|
489
|
+
// Logs:
|
|
490
|
+
// Schema
|
|
491
|
+
// Schema.startActs
|
|
492
|
+
// Schema.start
|
|
493
|
+
// Schema.imports
|
|
494
|
+
// Schema.shape
|
|
495
|
+
// shapeExpr
|
|
496
|
+
// Shape
|
|
497
|
+
// Shape.id
|
|
498
|
+
// shapeExprRef
|
|
499
|
+
// Shape.closed
|
|
500
|
+
// Shape.extra
|
|
501
|
+
// Shape.expression
|
|
502
|
+
// tripleExpr
|
|
503
|
+
// EachOf
|
|
504
|
+
// EachOf.expressions
|
|
505
|
+
// tripleExpr
|
|
506
|
+
// TripleConstraint
|
|
507
|
+
// TripleConstraint.inverse
|
|
508
|
+
// TripleConstraint.predicate
|
|
509
|
+
// IRIREF
|
|
510
|
+
// TripleConstraint.valueExpr
|
|
511
|
+
// shapeExpr
|
|
512
|
+
// NodeConstraint
|
|
513
|
+
// NodeConstraint.id
|
|
514
|
+
// NodeConstraint.datatype
|
|
515
|
+
// IRIREF
|
|
516
|
+
// NodeConstraint.values
|
|
517
|
+
// NodeConstraint.length
|
|
518
|
+
// NodeConstraint.minlength
|
|
519
|
+
// NodeConstraint.maxlength
|
|
520
|
+
// NodeConstraint.pattern
|
|
521
|
+
// NodeConstraint.flags
|
|
522
|
+
// NodeConstraint.mininclusive
|
|
523
|
+
// NodeConstraint.minexclusive
|
|
524
|
+
// NodeConstraint.maxinclusive
|
|
525
|
+
// NodeConstraint.maxexclusive
|
|
526
|
+
// NodeConstraint.totaldigits
|
|
527
|
+
// NodeConstraints.fractiondigits
|
|
528
|
+
// TripleConstraint.id
|
|
529
|
+
// TripleConstraint.min
|
|
530
|
+
// INTEGER
|
|
531
|
+
// TripleConstraint.max
|
|
532
|
+
// INTEGER
|
|
533
|
+
// TripleConstraint.semActs
|
|
534
|
+
// TripleConstraint.annotations
|
|
535
|
+
// tripleExpr
|
|
536
|
+
// TripleConstraint
|
|
537
|
+
// TripleConstraint.inverse
|
|
538
|
+
// TripleConstraint.predicate
|
|
539
|
+
// IRIREF
|
|
540
|
+
// TripleConstraint.valueExpr
|
|
541
|
+
// shapeExpr
|
|
542
|
+
// NodeConstraint
|
|
543
|
+
// NodeConstraint.id
|
|
544
|
+
// NodeConstraint.datatype
|
|
545
|
+
// NodeConstraint.values
|
|
546
|
+
// NodeConstraint.length
|
|
547
|
+
// NodeConstraint.minlength
|
|
548
|
+
// NodeConstraint.maxlength
|
|
549
|
+
// NodeConstraint.pattern
|
|
550
|
+
// NodeConstraint.flags
|
|
551
|
+
// NodeConstraint.mininclusive
|
|
552
|
+
// NodeConstraint.minexclusive
|
|
553
|
+
// NodeConstraint.maxinclusive
|
|
554
|
+
// NodeConstraint.maxexclusive
|
|
555
|
+
// NodeConstraint.totaldigits
|
|
556
|
+
// NodeConstraints.fractiondigits
|
|
557
|
+
// TripleConstraint.id
|
|
558
|
+
// TripleConstraint.min
|
|
559
|
+
// TripleConstraint.max
|
|
560
|
+
// TripleConstraint.semActs
|
|
561
|
+
// TripleConstraint.annotations
|
|
562
|
+
// tripleExpr
|
|
563
|
+
// TripleConstraint
|
|
564
|
+
// TripleConstraint.inverse
|
|
565
|
+
// TripleConstraint.predicate
|
|
566
|
+
// IRIREF
|
|
567
|
+
// TripleConstraint.valueExpr
|
|
568
|
+
// shapeExpr
|
|
569
|
+
// NodeConstraint
|
|
570
|
+
// NodeConstraint.id
|
|
571
|
+
// NodeConstraint.datatype
|
|
572
|
+
// NodeConstraint.values
|
|
573
|
+
// NodeConstraint.length
|
|
574
|
+
// NodeConstraint.minlength
|
|
575
|
+
// NodeConstraint.maxlength
|
|
576
|
+
// NodeConstraint.pattern
|
|
577
|
+
// NodeConstraint.flags
|
|
578
|
+
// NodeConstraint.mininclusive
|
|
579
|
+
// NodeConstraint.minexclusive
|
|
580
|
+
// NodeConstraint.maxinclusive
|
|
581
|
+
// NodeConstraint.maxexclusive
|
|
582
|
+
// NodeConstraint.totaldigits
|
|
583
|
+
// NodeConstraints.fractiondigits
|
|
584
|
+
// TripleConstraint.id
|
|
585
|
+
// TripleConstraint.min
|
|
586
|
+
// INTEGER
|
|
587
|
+
// TripleConstraint.max
|
|
588
|
+
// TripleConstraint.semActs
|
|
589
|
+
// TripleConstraint.annotations
|
|
590
|
+
// tripleExpr
|
|
591
|
+
// TripleConstraint
|
|
592
|
+
// TripleConstraint.inverse
|
|
593
|
+
// TripleConstraint.predicate
|
|
594
|
+
// IRIREF
|
|
595
|
+
// TripleConstraint.valueExpr
|
|
596
|
+
// shapeExpr
|
|
597
|
+
// NodeConstraint
|
|
598
|
+
// NodeConstraint.id
|
|
599
|
+
// NodeConstraint.datatype
|
|
600
|
+
// NodeConstraint.values
|
|
601
|
+
// NodeConstraint.length
|
|
602
|
+
// NodeConstraint.minlength
|
|
603
|
+
// NodeConstraint.maxlength
|
|
604
|
+
// NodeConstraint.pattern
|
|
605
|
+
// NodeConstraint.flags
|
|
606
|
+
// NodeConstraint.mininclusive
|
|
607
|
+
// NodeConstraint.minexclusive
|
|
608
|
+
// NodeConstraint.maxinclusive
|
|
609
|
+
// NodeConstraint.maxexclusive
|
|
610
|
+
// NodeConstraint.totaldigits
|
|
611
|
+
// NodeConstraints.fractiondigits
|
|
612
|
+
// TripleConstraint.id
|
|
613
|
+
// TripleConstraint.min
|
|
614
|
+
// TripleConstraint.max
|
|
615
|
+
// TripleConstraint.semActs
|
|
616
|
+
// TripleConstraint.annotations
|
|
617
|
+
// EachOf.id
|
|
618
|
+
// EachOf.min
|
|
619
|
+
// EachOf.max
|
|
620
|
+
// EachOf.semActs
|
|
621
|
+
// EachOf.annotations
|
|
622
|
+
// Shape.semActs
|
|
623
|
+
// Shape.annotations
|
|
624
|
+
```
|
|
625
|
+
|
|
626
|
+
### Transformer
|
|
627
|
+
This transformer shows all the possible return types. Note that you do not need to define every return type yourself. This library will automatically deduce return types.
|
|
628
|
+
|
|
629
|
+
```typescript
|
|
630
|
+
const shexJTransformer = shexJTraverser.createTransformer<
|
|
631
|
+
{
|
|
632
|
+
Schema: {
|
|
633
|
+
return: string;
|
|
634
|
+
properties: {
|
|
635
|
+
startActs: string;
|
|
636
|
+
start: string;
|
|
637
|
+
imports: string;
|
|
638
|
+
shapes: string;
|
|
639
|
+
};
|
|
640
|
+
};
|
|
641
|
+
shapeExpr: {
|
|
642
|
+
return: string;
|
|
643
|
+
};
|
|
644
|
+
ShapeOr: {
|
|
645
|
+
return: string;
|
|
646
|
+
properties: {
|
|
647
|
+
id: string;
|
|
648
|
+
shapeExprs: string;
|
|
649
|
+
};
|
|
650
|
+
};
|
|
651
|
+
ShapeAnd: {
|
|
652
|
+
return: string;
|
|
653
|
+
properties: {
|
|
654
|
+
id: string;
|
|
655
|
+
shapeExprs: string;
|
|
656
|
+
};
|
|
657
|
+
};
|
|
658
|
+
ShapeNot: {
|
|
659
|
+
return: string;
|
|
660
|
+
properties: {
|
|
661
|
+
id: string;
|
|
662
|
+
shapeExpr: string;
|
|
663
|
+
};
|
|
664
|
+
};
|
|
665
|
+
ShapeExternal: {
|
|
666
|
+
return: string;
|
|
667
|
+
properties: {
|
|
668
|
+
id: string;
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
shapeExprRef: {
|
|
672
|
+
return: string;
|
|
673
|
+
};
|
|
674
|
+
NodeConstraint: {
|
|
675
|
+
return: string;
|
|
676
|
+
properties: {
|
|
677
|
+
id: string;
|
|
678
|
+
datatype: string;
|
|
679
|
+
values: string;
|
|
680
|
+
length: string;
|
|
681
|
+
minlength: string;
|
|
682
|
+
maxlength: string;
|
|
683
|
+
pattern: string;
|
|
684
|
+
flags: string;
|
|
685
|
+
mininclusive: string;
|
|
686
|
+
minexclusive: string;
|
|
687
|
+
maxinclusive: string;
|
|
688
|
+
maxexclusive: string;
|
|
689
|
+
totaldigits: string;
|
|
690
|
+
fractiondigits: string;
|
|
691
|
+
};
|
|
692
|
+
};
|
|
693
|
+
numericLiteral: {
|
|
694
|
+
return: string;
|
|
695
|
+
};
|
|
696
|
+
valueSetValue: {
|
|
697
|
+
return: string;
|
|
698
|
+
};
|
|
699
|
+
objectValue: {
|
|
700
|
+
return: string;
|
|
701
|
+
};
|
|
702
|
+
ObjectLiteral: {
|
|
703
|
+
return: string;
|
|
704
|
+
properties: {
|
|
705
|
+
value: string;
|
|
706
|
+
language: string;
|
|
707
|
+
type: string;
|
|
708
|
+
};
|
|
709
|
+
};
|
|
710
|
+
IriStem: {
|
|
711
|
+
return: string;
|
|
712
|
+
properties: {
|
|
713
|
+
stem: string;
|
|
714
|
+
};
|
|
715
|
+
};
|
|
716
|
+
IriStemRange: {
|
|
717
|
+
return: string;
|
|
718
|
+
properties: {
|
|
719
|
+
stem: string;
|
|
720
|
+
exclusions: string;
|
|
721
|
+
};
|
|
722
|
+
};
|
|
723
|
+
IriStemRangeStem: {
|
|
724
|
+
return: string;
|
|
725
|
+
};
|
|
726
|
+
IriStemRangeExclusions: {
|
|
727
|
+
return: string;
|
|
728
|
+
};
|
|
729
|
+
LiteralStem: {
|
|
730
|
+
return: string;
|
|
731
|
+
properties: {
|
|
732
|
+
stem: string;
|
|
733
|
+
};
|
|
734
|
+
};
|
|
735
|
+
LiteralStemRange: {
|
|
736
|
+
return: string;
|
|
737
|
+
properties: {
|
|
738
|
+
stem: string;
|
|
739
|
+
exclusions: string;
|
|
740
|
+
};
|
|
741
|
+
};
|
|
742
|
+
LiteralStemRangeStem: {
|
|
743
|
+
return: string;
|
|
744
|
+
};
|
|
745
|
+
LiteralStemRangeExclusions: {
|
|
746
|
+
return: string;
|
|
747
|
+
};
|
|
748
|
+
Language: {
|
|
749
|
+
return: string;
|
|
750
|
+
properties: {
|
|
751
|
+
languageTag: string;
|
|
752
|
+
};
|
|
753
|
+
};
|
|
754
|
+
LanguageStem: {
|
|
755
|
+
return: string;
|
|
756
|
+
properties: {
|
|
757
|
+
stem: string;
|
|
758
|
+
};
|
|
759
|
+
};
|
|
760
|
+
LanguageStemRangeStem: {
|
|
761
|
+
return: string;
|
|
762
|
+
};
|
|
763
|
+
LanguageStemRangeExclusions: {
|
|
764
|
+
return: string;
|
|
765
|
+
};
|
|
766
|
+
Wildcard: {
|
|
767
|
+
return: string;
|
|
768
|
+
};
|
|
769
|
+
Shape: {
|
|
770
|
+
return: string;
|
|
771
|
+
properties: {
|
|
772
|
+
id: string;
|
|
773
|
+
closed: string;
|
|
774
|
+
extra: string;
|
|
775
|
+
expression: string;
|
|
776
|
+
semActs: string;
|
|
777
|
+
annotations: string;
|
|
778
|
+
};
|
|
779
|
+
};
|
|
780
|
+
tripleExpr: {
|
|
781
|
+
return: string;
|
|
782
|
+
};
|
|
783
|
+
EachOf: {
|
|
784
|
+
return: string;
|
|
785
|
+
properties: {
|
|
786
|
+
expressions: string;
|
|
787
|
+
id: string;
|
|
788
|
+
min: string;
|
|
789
|
+
max: string;
|
|
790
|
+
semActs: string;
|
|
791
|
+
annotations: string;
|
|
792
|
+
};
|
|
793
|
+
};
|
|
794
|
+
OneOf: {
|
|
795
|
+
return: string;
|
|
796
|
+
properties: {
|
|
797
|
+
expressions: string;
|
|
798
|
+
id: string;
|
|
799
|
+
min: string;
|
|
800
|
+
max: string;
|
|
801
|
+
semActs: string;
|
|
802
|
+
annotations: string;
|
|
803
|
+
};
|
|
804
|
+
};
|
|
805
|
+
TripleConstraint: {
|
|
806
|
+
return: string;
|
|
807
|
+
properties: {
|
|
808
|
+
inverse: string;
|
|
809
|
+
predicate: string;
|
|
810
|
+
valueExpr: string;
|
|
811
|
+
id: string;
|
|
812
|
+
min: string;
|
|
813
|
+
max: string;
|
|
814
|
+
semActs: string;
|
|
815
|
+
annotations: string;
|
|
816
|
+
};
|
|
817
|
+
};
|
|
818
|
+
tripleExprRef: {
|
|
819
|
+
return: string;
|
|
820
|
+
};
|
|
821
|
+
SemAct: {
|
|
822
|
+
return: string;
|
|
823
|
+
properties: {
|
|
824
|
+
name: string;
|
|
825
|
+
code: string;
|
|
826
|
+
};
|
|
827
|
+
};
|
|
828
|
+
Annotation: {
|
|
829
|
+
return: string;
|
|
830
|
+
properties: {
|
|
831
|
+
predicate: string;
|
|
832
|
+
object: string;
|
|
833
|
+
};
|
|
834
|
+
};
|
|
835
|
+
IRIREF: {
|
|
836
|
+
return: string;
|
|
837
|
+
};
|
|
838
|
+
STRING: {
|
|
839
|
+
return: string;
|
|
840
|
+
};
|
|
841
|
+
LANGTAG: {
|
|
842
|
+
return: string;
|
|
843
|
+
};
|
|
844
|
+
INTEGER: {
|
|
845
|
+
return: string;
|
|
846
|
+
};
|
|
847
|
+
BOOL: {
|
|
848
|
+
return: string;
|
|
849
|
+
};
|
|
850
|
+
IRI: {
|
|
851
|
+
return: string;
|
|
852
|
+
};
|
|
853
|
+
},
|
|
854
|
+
undefined
|
|
855
|
+
>({
|
|
856
|
+
Schema: {
|
|
857
|
+
transformer: async (
|
|
858
|
+
item,
|
|
859
|
+
getTransformedChildren,
|
|
860
|
+
_setReturnPointer,
|
|
861
|
+
_context
|
|
862
|
+
) => {
|
|
863
|
+
const children: {
|
|
864
|
+
startActs: string;
|
|
865
|
+
start: string;
|
|
866
|
+
imports: string;
|
|
867
|
+
shapes: string;
|
|
868
|
+
} = await getTransformedChildren();
|
|
869
|
+
return `Transformer(startActs:${children.startActs},start:${children.start},imports:${children.imports},shapes:${children.shapes})`;
|
|
870
|
+
},
|
|
871
|
+
},
|
|
872
|
+
// ...
|
|
873
|
+
});
|
|
874
|
+
```
|
|
875
|
+
|
|
876
|
+
|
|
877
|
+
|
|
878
|
+
## Liscense
|
|
879
|
+
MIT
|