@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.
@@ -0,0 +1,317 @@
1
+ import type { Annotation, BNODE, BOOL, DECIMAL, DOUBLE, EachOf, INTEGER, IRI, IRIREF, IriStem, IriStemRange, LANGTAG, Language, LanguageStem, LanguageStemRange, LiteralStem, LiteralStemRange, NodeConstraint, numericLiteral, ObjectLiteral, objectValue, OneOf, Schema, SemAct, Shape, ShapeAnd, ShapeDecl, shapeDeclLabel, shapeDeclRef, shapeExpr, shapeExprOrRef, ShapeExternal, ShapeNot, ShapeOr, STRING, TripleConstraint, tripleExpr, tripleExprLabel, tripleExprOrRef, tripleExprRef, valueSetValue, Wildcard } from "shexj";
2
+ import type { ValidateTraverserTypes } from "@ldo/type-traverser";
3
+ export type ShexJTraverserTypes = ValidateTraverserTypes<{
4
+ Schema: {
5
+ kind: "interface";
6
+ type: Schema;
7
+ properties: {
8
+ startActs: "SemAct";
9
+ start: "shapeExprOrRef";
10
+ imports: "IRIREF";
11
+ shapes: "ShapeDecl";
12
+ };
13
+ };
14
+ ShapeDecl: {
15
+ kind: "interface";
16
+ type: ShapeDecl;
17
+ properties: {
18
+ id: "shapeDeclLabel";
19
+ abstract: "BOOL";
20
+ restricts: "shapeExprOrRef";
21
+ shapeExpr: "shapeExpr";
22
+ };
23
+ };
24
+ shapeExpr: {
25
+ kind: "union";
26
+ type: shapeExpr;
27
+ typeNames: "ShapeOr" | "ShapeAnd" | "ShapeNot" | "NodeConstraint" | "Shape" | "ShapeExternal";
28
+ };
29
+ shapeExprOrRef: {
30
+ kind: "union";
31
+ type: shapeExprOrRef;
32
+ typeNames: "shapeExpr" | "shapeDeclRef";
33
+ };
34
+ ShapeOr: {
35
+ kind: "interface";
36
+ type: ShapeOr;
37
+ properties: {
38
+ shapeExprs: "shapeExprOrRef";
39
+ };
40
+ };
41
+ ShapeAnd: {
42
+ kind: "interface";
43
+ type: ShapeAnd;
44
+ properties: {
45
+ shapeExprs: "shapeExprOrRef";
46
+ };
47
+ };
48
+ ShapeNot: {
49
+ kind: "interface";
50
+ type: ShapeNot;
51
+ properties: {
52
+ shapeExpr: "shapeExprOrRef";
53
+ };
54
+ };
55
+ ShapeExternal: {
56
+ kind: "interface";
57
+ type: ShapeExternal;
58
+ properties: Record<string, never>;
59
+ };
60
+ shapeDeclRef: {
61
+ kind: "union";
62
+ type: shapeDeclRef;
63
+ typeNames: "shapeDeclLabel";
64
+ };
65
+ shapeDeclLabel: {
66
+ kind: "union";
67
+ type: shapeDeclLabel;
68
+ typeNames: "IRIREF" | "BNODE";
69
+ };
70
+ NodeConstraint: {
71
+ kind: "interface";
72
+ type: NodeConstraint;
73
+ properties: {
74
+ datatype: "IRIREF";
75
+ values: "valueSetValue";
76
+ length: "INTEGER";
77
+ minlength: "INTEGER";
78
+ maxlength: "INTEGER";
79
+ pattern: "STRING";
80
+ flags: "STRING";
81
+ mininclusive: "numericLiteral";
82
+ minexclusive: "numericLiteral";
83
+ totaldigits: "INTEGER";
84
+ fractiondigits: "INTEGER";
85
+ semActs: "SemAct";
86
+ annotations: "Annotation";
87
+ };
88
+ };
89
+ numericLiteral: {
90
+ kind: "union";
91
+ type: numericLiteral;
92
+ typeNames: "INTEGER" | "DECIMAL" | "DOUBLE";
93
+ };
94
+ valueSetValue: {
95
+ kind: "union";
96
+ type: valueSetValue;
97
+ typeNames: "objectValue" | "IriStem" | "IriStemRange" | "LiteralStem" | "LiteralStemRange" | "Language" | "LanguageStem" | "LanguageStemRange";
98
+ };
99
+ objectValue: {
100
+ kind: "union";
101
+ type: objectValue;
102
+ typeNames: "IRIREF" | "ObjectLiteral";
103
+ };
104
+ ObjectLiteral: {
105
+ kind: "interface";
106
+ type: ObjectLiteral;
107
+ properties: {
108
+ value: "STRING";
109
+ language: "STRING";
110
+ type: "STRING";
111
+ };
112
+ };
113
+ IriStem: {
114
+ kind: "interface";
115
+ type: IriStem;
116
+ properties: {
117
+ stem: "IRIREF";
118
+ };
119
+ };
120
+ IriStemRange: {
121
+ kind: "interface";
122
+ type: IriStemRange;
123
+ properties: {
124
+ stem: "IRIREF";
125
+ exclusions: "IriStemRangeExclusions";
126
+ };
127
+ };
128
+ IriStemRangeExclusions: {
129
+ kind: "union";
130
+ type: IRIREF | IriStem;
131
+ typeNames: "IRIREF" | "IriStem";
132
+ };
133
+ LiteralStem: {
134
+ kind: "interface";
135
+ type: LiteralStem;
136
+ properties: {
137
+ stem: "STRING";
138
+ };
139
+ };
140
+ LiteralStemRange: {
141
+ kind: "interface";
142
+ type: LiteralStemRange;
143
+ properties: {
144
+ stem: "LiteralStemRangeStem";
145
+ exclusions: "LiteralStemRangeExclusions";
146
+ };
147
+ };
148
+ LiteralStemRangeStem: {
149
+ kind: "union";
150
+ type: STRING | Wildcard;
151
+ typeNames: "STRING" | "Wildcard";
152
+ };
153
+ LiteralStemRangeExclusions: {
154
+ kind: "union";
155
+ type: STRING | LiteralStem;
156
+ typeNames: "STRING" | "LiteralStem";
157
+ };
158
+ Language: {
159
+ kind: "interface";
160
+ type: Language;
161
+ properties: {
162
+ languageTag: "LANGTAG";
163
+ };
164
+ };
165
+ LanguageStem: {
166
+ kind: "interface";
167
+ type: LanguageStem;
168
+ properties: {
169
+ stem: "LANGTAG";
170
+ };
171
+ };
172
+ LanguageStemRange: {
173
+ kind: "interface";
174
+ type: LanguageStemRange;
175
+ properties: {
176
+ stem: "LanguageStemRangeStem";
177
+ exclusions: "LanguageStemRangeExclusions";
178
+ };
179
+ };
180
+ LanguageStemRangeStem: {
181
+ kind: "union";
182
+ type: LANGTAG | Wildcard;
183
+ typeNames: "LANGTAG" | "Wildcard";
184
+ };
185
+ LanguageStemRangeExclusions: {
186
+ kind: "union";
187
+ type: LANGTAG | LanguageStem;
188
+ typeNames: "LANGTAG" | "LanguageStem";
189
+ };
190
+ Wildcard: {
191
+ kind: "interface";
192
+ type: Wildcard;
193
+ properties: Record<string, never>;
194
+ };
195
+ Shape: {
196
+ kind: "interface";
197
+ type: Shape;
198
+ properties: {
199
+ closed: "BOOL";
200
+ extra: "IRIREF";
201
+ extends: "shapeExprOrRef";
202
+ expression: "tripleExprOrRef";
203
+ semActs: "SemAct";
204
+ annotations: "Annotation";
205
+ };
206
+ };
207
+ tripleExpr: {
208
+ kind: "union";
209
+ type: tripleExpr;
210
+ typeNames: "EachOf" | "OneOf" | "TripleConstraint";
211
+ };
212
+ tripleExprOrRef: {
213
+ kind: "union";
214
+ type: tripleExprOrRef;
215
+ typeNames: "tripleExpr" | "tripleExprRef";
216
+ };
217
+ EachOf: {
218
+ kind: "interface";
219
+ type: EachOf;
220
+ properties: {
221
+ id: "tripleExprLabel";
222
+ min: "INTEGER";
223
+ max: "INTEGER";
224
+ expressions: "tripleExprOrRef";
225
+ semActs: "SemAct";
226
+ annotations: "Annotation";
227
+ };
228
+ };
229
+ OneOf: {
230
+ kind: "interface";
231
+ type: OneOf;
232
+ properties: {
233
+ id: "tripleExprLabel";
234
+ min: "INTEGER";
235
+ max: "INTEGER";
236
+ expressions: "tripleExprOrRef";
237
+ semActs: "SemAct";
238
+ annotations: "Annotation";
239
+ };
240
+ };
241
+ TripleConstraint: {
242
+ kind: "interface";
243
+ type: TripleConstraint;
244
+ properties: {
245
+ id: "tripleExprLabel";
246
+ min: "INTEGER";
247
+ max: "INTEGER";
248
+ inverse: "BOOL";
249
+ predicate: "IRIREF";
250
+ valueExpr: "shapeExprOrRef";
251
+ semActs: "SemAct";
252
+ annotations: "Annotation";
253
+ };
254
+ };
255
+ tripleExprRef: {
256
+ kind: "union";
257
+ type: tripleExprRef;
258
+ typeNames: "tripleExprLabel";
259
+ };
260
+ tripleExprLabel: {
261
+ kind: "union";
262
+ type: tripleExprLabel;
263
+ typeNames: "IRIREF" | "BNODE";
264
+ };
265
+ SemAct: {
266
+ kind: "interface";
267
+ type: SemAct;
268
+ properties: {
269
+ name: "IRIREF";
270
+ code: "STRING";
271
+ };
272
+ };
273
+ Annotation: {
274
+ kind: "interface";
275
+ type: Annotation;
276
+ properties: {
277
+ predicate: "IRI";
278
+ object: "objectValue";
279
+ };
280
+ };
281
+ IRIREF: {
282
+ kind: "primitive";
283
+ type: IRIREF;
284
+ };
285
+ BNODE: {
286
+ kind: "primitive";
287
+ type: BNODE;
288
+ };
289
+ INTEGER: {
290
+ kind: "primitive";
291
+ type: INTEGER;
292
+ };
293
+ STRING: {
294
+ kind: "primitive";
295
+ type: STRING;
296
+ };
297
+ DECIMAL: {
298
+ kind: "primitive";
299
+ type: DECIMAL;
300
+ };
301
+ DOUBLE: {
302
+ kind: "primitive";
303
+ type: DOUBLE;
304
+ };
305
+ LANGTAG: {
306
+ kind: "primitive";
307
+ type: LANGTAG;
308
+ };
309
+ BOOL: {
310
+ kind: "primitive";
311
+ type: BOOL;
312
+ };
313
+ IRI: {
314
+ kind: "primitive";
315
+ type: IRI;
316
+ };
317
+ }>;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=ShexJTraverserTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShexJTraverserTypes.js","sourceRoot":"","sources":["../src/ShexJTraverserTypes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ import { ShexJTraverser } from "./ShexJTraverser";
2
+ export * from "./ShexJTraverserDefinition";
3
+ export * from "./ShexJTraverserTypes";
4
+ export default ShexJTraverser;
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const ShexJTraverser_1 = require("./ShexJTraverser");
18
+ __exportStar(require("./ShexJTraverserDefinition"), exports);
19
+ __exportStar(require("./ShexJTraverserTypes"), exports);
20
+ exports.default = ShexJTraverser_1.ShexJTraverser;
21
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAkD;AAElD,6DAA2C;AAC3C,wDAAsC;AACtC,kBAAe,+BAAc,CAAC"}
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@ldo/traverser-shexj",
3
+ "version": "0.0.1-alpha.14",
4
+ "description": "A type-traverser for ShexJ",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "build": "tsc --project tsconfig.build.json",
8
+ "test": "jest --coverage",
9
+ "prepublishOnly": "npm run test && npm run build",
10
+ "lint": "eslint src/** --fix --no-error-on-unmatched-pattern"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/o-development/ldobjects.git"
15
+ },
16
+ "author": "",
17
+ "license": "MIT",
18
+ "bugs": {
19
+ "url": "https://github.com/o-development/ldobjects/issues"
20
+ },
21
+ "homepage": "https://github.com/o-development/ldobjects/tree/main/packages/traverser-shexj#readme",
22
+ "devDependencies": {
23
+ "@types/jest": "^29.0.3",
24
+ "@types/shexj": "^2.1.3",
25
+ "jest": "^29.0.3",
26
+ "ts-jest": "^29.0.2"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "src"
31
+ ],
32
+ "dependencies": {
33
+ "@ldo/type-traverser": "^0.0.1-alpha.14"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "gitHead": "5acfea4c43c07c02df9ed4e9166e61a540e26db8"
39
+ }
@@ -0,0 +1,7 @@
1
+ import { ShexJTraverserDefinition } from "./ShexJTraverserDefinition";
2
+ import type { ShexJTraverserTypes } from "./ShexJTraverserTypes";
3
+ import { Traverser } from "@ldo/type-traverser";
4
+
5
+ export const ShexJTraverser = new Traverser<ShexJTraverserTypes>(
6
+ ShexJTraverserDefinition,
7
+ );
@@ -0,0 +1,303 @@
1
+ import type { ShexJTraverserTypes } from ".";
2
+ import type { TraverserDefinition } from "@ldo/type-traverser";
3
+ import type { shapeExpr, valueSetValue } from "shexj";
4
+
5
+ export const ShexJTraverserDefinition: TraverserDefinition<ShexJTraverserTypes> =
6
+ {
7
+ Schema: {
8
+ kind: "interface",
9
+ properties: {
10
+ startActs: "SemAct",
11
+ start: "shapeExprOrRef",
12
+ imports: "IRIREF",
13
+ shapes: "ShapeDecl",
14
+ },
15
+ },
16
+ ShapeDecl: {
17
+ kind: "interface",
18
+ properties: {
19
+ id: "shapeDeclLabel",
20
+ abstract: "BOOL",
21
+ restricts: "shapeExprOrRef",
22
+ shapeExpr: "shapeExpr",
23
+ },
24
+ },
25
+ shapeExpr: {
26
+ kind: "union",
27
+ selector: (item: shapeExpr) => item.type,
28
+ },
29
+ shapeExprOrRef: {
30
+ kind: "union",
31
+ selector: (item) =>
32
+ typeof item === "string" ? "shapeDeclRef" : "shapeExpr",
33
+ },
34
+ ShapeOr: {
35
+ kind: "interface",
36
+ properties: {
37
+ shapeExprs: "shapeExprOrRef",
38
+ },
39
+ },
40
+ ShapeAnd: {
41
+ kind: "interface",
42
+ properties: {
43
+ shapeExprs: "shapeExprOrRef",
44
+ },
45
+ },
46
+ ShapeNot: {
47
+ kind: "interface",
48
+ properties: {
49
+ shapeExpr: "shapeExprOrRef",
50
+ },
51
+ },
52
+ ShapeExternal: {
53
+ kind: "interface",
54
+ properties: {},
55
+ },
56
+ shapeDeclRef: {
57
+ kind: "union",
58
+ selector: () => "shapeDeclLabel",
59
+ },
60
+ shapeDeclLabel: {
61
+ kind: "union",
62
+ selector: () => "IRIREF",
63
+ },
64
+ NodeConstraint: {
65
+ kind: "interface",
66
+ properties: {
67
+ datatype: "IRIREF",
68
+ values: "valueSetValue",
69
+ length: "INTEGER",
70
+ minlength: "INTEGER",
71
+ maxlength: "INTEGER",
72
+ pattern: "STRING",
73
+ flags: "STRING",
74
+ mininclusive: "numericLiteral",
75
+ minexclusive: "numericLiteral",
76
+ totaldigits: "INTEGER",
77
+ fractiondigits: "INTEGER",
78
+ semActs: "SemAct",
79
+ annotations: "Annotation",
80
+ },
81
+ },
82
+ numericLiteral: {
83
+ kind: "union",
84
+ selector: () => "DOUBLE",
85
+ },
86
+ valueSetValue: {
87
+ kind: "union",
88
+ selector: (item: valueSetValue) => {
89
+ if (typeof item === "string") {
90
+ return "objectValue";
91
+ } else if (
92
+ item.type &&
93
+ [
94
+ "IriStem",
95
+ "IriStemRange",
96
+ "LiteralStem",
97
+ "LiteralStemRange",
98
+ "Language",
99
+ "LanguageStem",
100
+ "LanguageStemRange",
101
+ ].includes(item.type)
102
+ ) {
103
+ return item.type as
104
+ | "IriStem"
105
+ | "IriStemRange"
106
+ | "LiteralStem"
107
+ | "LiteralStemRange"
108
+ | "Language"
109
+ | "LanguageStem"
110
+ | "LanguageStemRange";
111
+ } else {
112
+ return "objectValue";
113
+ }
114
+ },
115
+ },
116
+ objectValue: {
117
+ kind: "union",
118
+ selector: (item) =>
119
+ typeof item === "string" ? "IRIREF" : "ObjectLiteral",
120
+ },
121
+ ObjectLiteral: {
122
+ kind: "interface",
123
+ properties: {
124
+ value: "STRING",
125
+ language: "STRING",
126
+ type: "STRING",
127
+ },
128
+ },
129
+ IriStem: {
130
+ kind: "interface",
131
+ properties: {
132
+ stem: "IRIREF",
133
+ },
134
+ },
135
+ IriStemRange: {
136
+ kind: "interface",
137
+ properties: {
138
+ stem: "IRIREF",
139
+ exclusions: "IriStemRangeExclusions",
140
+ },
141
+ },
142
+ IriStemRangeExclusions: {
143
+ kind: "union",
144
+ selector: (item) => (typeof item === "string" ? "IRIREF" : "IriStem"),
145
+ },
146
+ LiteralStem: {
147
+ kind: "interface",
148
+ properties: {
149
+ stem: "STRING",
150
+ },
151
+ },
152
+ LiteralStemRange: {
153
+ kind: "interface",
154
+ properties: {
155
+ stem: "LiteralStemRangeStem",
156
+ exclusions: "LiteralStemRangeExclusions",
157
+ },
158
+ },
159
+ LiteralStemRangeStem: {
160
+ kind: "union",
161
+ selector: (item) => (typeof item === "string" ? "STRING" : "Wildcard"),
162
+ },
163
+ LiteralStemRangeExclusions: {
164
+ kind: "union",
165
+ selector: (item) => (typeof item === "string" ? "STRING" : "LiteralStem"),
166
+ },
167
+ Language: {
168
+ kind: "interface",
169
+ properties: {
170
+ languageTag: "LANGTAG",
171
+ },
172
+ },
173
+ LanguageStem: {
174
+ kind: "interface",
175
+ properties: {
176
+ stem: "LANGTAG",
177
+ },
178
+ },
179
+ LanguageStemRange: {
180
+ kind: "interface",
181
+ properties: {
182
+ stem: "LanguageStemRangeStem",
183
+ exclusions: "LanguageStemRangeExclusions",
184
+ },
185
+ },
186
+ LanguageStemRangeStem: {
187
+ kind: "union",
188
+ selector: (item) => (typeof item === "string" ? "LANGTAG" : "Wildcard"),
189
+ },
190
+ LanguageStemRangeExclusions: {
191
+ kind: "union",
192
+ selector: (item) =>
193
+ typeof item === "string" ? "LANGTAG" : "LanguageStem",
194
+ },
195
+ Wildcard: {
196
+ kind: "interface",
197
+ properties: {},
198
+ },
199
+ Shape: {
200
+ kind: "interface",
201
+ properties: {
202
+ closed: "BOOL",
203
+ extra: "IRIREF",
204
+ extends: "shapeExprOrRef",
205
+ expression: "tripleExprOrRef",
206
+ semActs: "SemAct",
207
+ annotations: "Annotation",
208
+ },
209
+ },
210
+ tripleExpr: {
211
+ kind: "union",
212
+ selector: (item) => item.type,
213
+ },
214
+ tripleExprOrRef: {
215
+ kind: "union",
216
+ selector: (item) =>
217
+ typeof item === "string" ? "tripleExprRef" : "tripleExpr",
218
+ },
219
+ EachOf: {
220
+ kind: "interface",
221
+ properties: {
222
+ id: "tripleExprLabel",
223
+ min: "INTEGER",
224
+ max: "INTEGER",
225
+ expressions: "tripleExprOrRef",
226
+ semActs: "SemAct",
227
+ annotations: "Annotation",
228
+ },
229
+ },
230
+ OneOf: {
231
+ kind: "interface",
232
+ properties: {
233
+ id: "tripleExprLabel",
234
+ min: "INTEGER",
235
+ max: "INTEGER",
236
+ expressions: "tripleExprOrRef",
237
+ semActs: "SemAct",
238
+ annotations: "Annotation",
239
+ },
240
+ },
241
+ TripleConstraint: {
242
+ kind: "interface",
243
+ properties: {
244
+ id: "tripleExprLabel",
245
+ min: "INTEGER",
246
+ max: "INTEGER",
247
+ inverse: "BOOL",
248
+ predicate: "IRIREF",
249
+ valueExpr: "shapeExprOrRef",
250
+ semActs: "SemAct",
251
+ annotations: "Annotation",
252
+ },
253
+ },
254
+ tripleExprRef: {
255
+ kind: "union",
256
+ selector: () => "tripleExprLabel",
257
+ },
258
+ tripleExprLabel: {
259
+ kind: "union",
260
+ selector: () => "IRIREF",
261
+ },
262
+ SemAct: {
263
+ kind: "interface",
264
+ properties: {
265
+ name: "IRIREF",
266
+ code: "STRING",
267
+ },
268
+ },
269
+ Annotation: {
270
+ kind: "interface",
271
+ properties: {
272
+ predicate: "IRI",
273
+ object: "objectValue",
274
+ },
275
+ },
276
+ IRIREF: {
277
+ kind: "primitive",
278
+ },
279
+ BNODE: {
280
+ kind: "primitive",
281
+ },
282
+ INTEGER: {
283
+ kind: "primitive",
284
+ },
285
+ STRING: {
286
+ kind: "primitive",
287
+ },
288
+ DECIMAL: {
289
+ kind: "primitive",
290
+ },
291
+ DOUBLE: {
292
+ kind: "primitive",
293
+ },
294
+ LANGTAG: {
295
+ kind: "primitive",
296
+ },
297
+ BOOL: {
298
+ kind: "primitive",
299
+ },
300
+ IRI: {
301
+ kind: "primitive",
302
+ },
303
+ };