@ng-org/shex-orm 0.1.2

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.
Files changed (64) hide show
  1. package/README.md +240 -0
  2. package/dist/ShexJTypes.d.ts +542 -0
  3. package/dist/ShexJTypes.d.ts.map +1 -0
  4. package/dist/ShexJTypes.js +10 -0
  5. package/dist/build.d.ts +8 -0
  6. package/dist/build.d.ts.map +1 -0
  7. package/dist/build.js +72 -0
  8. package/dist/cli.d.ts +3 -0
  9. package/dist/cli.d.ts.map +1 -0
  10. package/dist/cli.js +15 -0
  11. package/dist/index.d.ts +2 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +1 -0
  14. package/dist/schema-converter/__tests__/typingTransformer.test.d.ts +2 -0
  15. package/dist/schema-converter/__tests__/typingTransformer.test.d.ts.map +1 -0
  16. package/dist/schema-converter/__tests__/typingTransformer.test.js +76 -0
  17. package/dist/schema-converter/converter.d.ts +12 -0
  18. package/dist/schema-converter/converter.d.ts.map +1 -0
  19. package/dist/schema-converter/converter.js +79 -0
  20. package/dist/schema-converter/templates/schema.ejs +8 -0
  21. package/dist/schema-converter/templates/shapeTypes.ejs +14 -0
  22. package/dist/schema-converter/templates/typings.ejs +14 -0
  23. package/dist/schema-converter/transformers/ShexJSchemaTransformer.d.ts +348 -0
  24. package/dist/schema-converter/transformers/ShexJSchemaTransformer.d.ts.map +1 -0
  25. package/dist/schema-converter/transformers/ShexJSchemaTransformer.js +239 -0
  26. package/dist/schema-converter/transformers/ShexJTypingTransformer.d.ts +366 -0
  27. package/dist/schema-converter/transformers/ShexJTypingTransformer.d.ts.map +1 -0
  28. package/dist/schema-converter/transformers/ShexJTypingTransformer.js +623 -0
  29. package/dist/schema-converter/util/ShapeInterfaceDeclaration.d.ts +5 -0
  30. package/dist/schema-converter/util/ShapeInterfaceDeclaration.d.ts.map +1 -0
  31. package/dist/schema-converter/util/ShapeInterfaceDeclaration.js +1 -0
  32. package/dist/schema-converter/util/annotateReadablePredicates.d.ts +8 -0
  33. package/dist/schema-converter/util/annotateReadablePredicates.d.ts.map +1 -0
  34. package/dist/schema-converter/util/annotateReadablePredicates.js +148 -0
  35. package/dist/schema-converter/util/dedupeObjectTypeMembers.d.ts +3 -0
  36. package/dist/schema-converter/util/dedupeObjectTypeMembers.d.ts.map +1 -0
  37. package/dist/schema-converter/util/dedupeObjectTypeMembers.js +47 -0
  38. package/dist/schema-converter/util/getRdfTypesForTripleConstraint.d.ts +4 -0
  39. package/dist/schema-converter/util/getRdfTypesForTripleConstraint.d.ts.map +1 -0
  40. package/dist/schema-converter/util/getRdfTypesForTripleConstraint.js +98 -0
  41. package/dist/types.d.ts +37 -0
  42. package/dist/types.d.ts.map +1 -0
  43. package/dist/types.js +10 -0
  44. package/dist/util/forAllShapes.d.ts +2 -0
  45. package/dist/util/forAllShapes.d.ts.map +1 -0
  46. package/dist/util/forAllShapes.js +25 -0
  47. package/package.json +67 -0
  48. package/src/ShexJTypes.ts +616 -0
  49. package/src/build.ts +106 -0
  50. package/src/cli.ts +23 -0
  51. package/src/index.ts +1 -0
  52. package/src/schema-converter/__tests__/typingTransformer.test.ts +85 -0
  53. package/src/schema-converter/converter.ts +128 -0
  54. package/src/schema-converter/templates/schema.ejs +8 -0
  55. package/src/schema-converter/templates/shapeTypes.ejs +14 -0
  56. package/src/schema-converter/templates/typings.ejs +14 -0
  57. package/src/schema-converter/transformers/ShexJSchemaTransformer.ts +284 -0
  58. package/src/schema-converter/transformers/ShexJTypingTransformer.ts +807 -0
  59. package/src/schema-converter/util/ShapeInterfaceDeclaration.ts +5 -0
  60. package/src/schema-converter/util/annotateReadablePredicates.ts +173 -0
  61. package/src/schema-converter/util/dedupeObjectTypeMembers.ts +61 -0
  62. package/src/schema-converter/util/getRdfTypesForTripleConstraint.ts +153 -0
  63. package/src/types.ts +51 -0
  64. package/src/util/forAllShapes.ts +39 -0
@@ -0,0 +1,542 @@
1
+ export {};
2
+ /**
3
+ * Structure for expressing a Shape Expression schema.
4
+ * @see <a href="http://shex.io/shex-semantics/#dfn-shapes-schema">ShEx Schema definition</a>
5
+ */
6
+ export interface Schema {
7
+ /**
8
+ * Mandatory type "Schema".
9
+ */
10
+ type: "Schema";
11
+ /**
12
+ * JSON-LD <a href="https://www.w3.org/TR/json-ld11/#the-context">@context</a> for ShEx.
13
+ */
14
+ "@context"?: "http://www.w3.org/ns/shex.jsonld" | undefined;
15
+ /**
16
+ * List of semantic actions to be executed when evaluating conformance.
17
+ */
18
+ startActs?: SemAct[] | undefined;
19
+ /**
20
+ * Identifies default starting shape expression.
21
+ */
22
+ start?: shapeExprOrRef | undefined;
23
+ /**
24
+ * List of ShEx schemas to <a href="http://shex.io/shex-semantics/#import">import</a> when processing this schema.
25
+ */
26
+ imports?: IRIREF[] | undefined;
27
+ /**
28
+ * The list of {@link ShapeDecl}s defined in this schema. Each MUST include and {@link ShapeOr#id}.
29
+ */
30
+ shapes?: ShapeDecl[] | undefined;
31
+ }
32
+ export interface semactsAndAnnotations {
33
+ /**
34
+ * List of semantic actions to be executed when evaluating conformance.
35
+ */
36
+ semActs?: SemAct[] | undefined;
37
+ /**
38
+ * List of {@link SemAct#predicate}/{@link SemAct#object} annotations.
39
+ */
40
+ annotations?: Annotation[] | undefined;
41
+ }
42
+ /**
43
+ * A declaration for a shapeExpr with added inheritance constraints.
44
+ * @see <a href="http://shex.io/shex-semantics/#dfn-shapedecl">ShEx ShapeDecl definition</a>
45
+ */
46
+ export interface ShapeDecl {
47
+ /**
48
+ * Mandatory type "ShapeDecl".
49
+ */
50
+ type: "ShapeDecl";
51
+ /**
52
+ * The identifier is an <a href="https://www.w3.org/TR/json-ld11/#node-identifiers">IRI</a> or a <a href="https://www.w3.org/TR/json-ld11/#identifying-blank-nodes">BlankNode</a>
53
+ * as expressed in <a href="https://www.w3.org/TR/json-ld11/">JSON-LD 1.1</a>.
54
+ */
55
+ id: shapeDeclLabel;
56
+ /**
57
+ * Whether this ShapeDecl participates in <a href="http://shex.io/shex-semantics/#dfn-inheritanceSubstitution">inheritance substitution</a>.
58
+ */
59
+ abstract?: BOOL | undefined;
60
+ /**
61
+ * The list of {@link shapeExprOrRef}s that a neighborhood MUST conform to in order to conform to this ShapeDecl.
62
+ */
63
+ restricts?: shapeExprOrRef[] | undefined;
64
+ /**
65
+ * The {@link shapeExpr} to which this neighborhood MUST also conform.
66
+ */
67
+ shapeExpr: shapeExpr;
68
+ }
69
+ /**
70
+ * Union of shape expression types.
71
+ * @see <a href="http://shex.io/shex-semantics/#dfn-shapeexpr">ShEx shapeExpr definition</a>
72
+ */
73
+ export type shapeExpr = ShapeOr | ShapeAnd | ShapeNot | NodeConstraint | Shape | ShapeExternal;
74
+ /**
75
+ * Union of shapeExpr and shapeDeclRef.
76
+ * @see <a href="http://shex.io/shex-semantics/#dfn-shapeexpr">ShEx shapeExpr definition</a>
77
+ */
78
+ export type shapeExprOrRef = shapeExpr | shapeDeclRef;
79
+ /**
80
+ * A non-exclusive choice of shape expressions; considered conformant if any of {@link #shapeExprs} conforms.
81
+ * @see <a href="http://shex.io/shex-semantics/#dfn-shapeor">ShEx shapeExpr definition</a>
82
+ */
83
+ export interface ShapeOr {
84
+ /**
85
+ * Mandatory type "ShapeOr".
86
+ */
87
+ type: "ShapeOr";
88
+ /**
89
+ * List of two or more {@link shapeExprOrRef}s in this disjunction.
90
+ */
91
+ shapeExprs: shapeExprOrRef[];
92
+ }
93
+ /**
94
+ * A conjunction of shape expressions; considered conformant if each conjunct conforms.
95
+ * @see <a href="http://shex.io/shex-semantics/#dfn-shapeor">ShEx shapeExpr definition</a>
96
+ */
97
+ export interface ShapeAnd {
98
+ /**
99
+ * Mandatory type "ShapeAnd".
100
+ */
101
+ type: "ShapeAnd";
102
+ /**
103
+ * List of two or more {@link shapeExprOrRef}s in this conjunction.
104
+ */
105
+ shapeExprs: shapeExprOrRef[];
106
+ }
107
+ /**
108
+ * A negated shape expressions; considered conformant if {@link #shapeExpr} is not conformant.
109
+ * @see <a href="http://shex.io/shex-semantics/#dfn-shapenot">ShEx shapeExpr definition</a>
110
+ */
111
+ export interface ShapeNot {
112
+ /**
113
+ * Mandatory type "ShapeNot".
114
+ */
115
+ type: "ShapeNot";
116
+ /**
117
+ * The {@link shapeExprOrRef} that must be non-conformant for this shape expression to be conformant.
118
+ */
119
+ shapeExpr: shapeExprOrRef;
120
+ }
121
+ /**
122
+ * A shape expression not defined in this schema or in any imported schema. The definition of this shape expression is NOT defined by ShEx.
123
+ * @see <a href="http://shex.io/shex-semantics/#dfn-shapeexternal">ShEx shapeExpr definition</a>
124
+ */
125
+ export interface ShapeExternal {
126
+ /**
127
+ * Mandatory type "ShapeExternal".
128
+ */
129
+ type: "ShapeExternal";
130
+ }
131
+ /**
132
+ * A reference a shape expression.
133
+ * The reference is an <a href="https://www.w3.org/TR/json-ld11/#node-identifiers">IRI</a> or a <a href="https://www.w3.org/TR/json-ld11/#identifying-blank-nodes">BlankNode</a>
134
+ * as expressed in <a href="https://www.w3.org/TR/json-ld11/">JSON-LD 1.1</a>.
135
+ * This is modified to also include the possibility of ShapeDecl
136
+ */
137
+ export type shapeDeclRef = shapeDeclLabel | ShapeDecl;
138
+ /**
139
+ * An identifier for a shape expression.
140
+ * The identifier is an <a href="https://www.w3.org/TR/json-ld11/#node-identifiers">IRI</a> or a <a href="https://www.w3.org/TR/json-ld11/#identifying-blank-nodes">BlankNode</a>
141
+ * as expressed in <a href="https://www.w3.org/TR/json-ld11/">JSON-LD 1.1</a>.
142
+ */
143
+ export type shapeDeclLabel = IRIREF | BNODE;
144
+ export type nodeKind = "iri" | "bnode" | "nonliteral" | "literal";
145
+ /**
146
+ * A collection of constraints on <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-node">RDF Term</a>s expected for conformance.
147
+ * The identifier is an <a href="https://www.w3.org/TR/json-ld11/#node-identifiers">IRI</a> or a <a href="https://www.w3.org/TR/json-ld11/#identifying-blank-nodes">BlankNode</a>
148
+ * as expressed in <a href="https://www.w3.org/TR/json-ld11/">JSON-LD 1.1</a>.
149
+ */
150
+ export interface NodeConstraint extends xsFacets, semactsAndAnnotations {
151
+ /**
152
+ * Mandatory type "NodeConstraint".
153
+ */
154
+ type: "NodeConstraint";
155
+ /**
156
+ * Type of <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-node">RDF Term</a> expected for a conformant RDF node.
157
+ * @see <a href="http://shex.io/shex-semantics/#nodeKind">ShEx nodeKind definition</a>
158
+ */
159
+ nodeKind?: nodeKind | undefined;
160
+ /**
161
+ * The <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-datatype-iri">RDF Literal datatype IRITerm</a> expected for a conformant RDF node.
162
+ * @see <a href="http://shex.io/shex-semantics/#datatype">ShEx datatype definition</a>
163
+ */
164
+ datatype?: IRIREF | undefined;
165
+ /**
166
+ * The set of permissible values.
167
+ * @see <a href="http://shex.io/shex-semantics/#values">ShEx values definition</a>
168
+ */
169
+ values?: valueSetValue[] | undefined;
170
+ }
171
+ /**
172
+ * The set of XML Schema Facets supported in ShEx; defers to {@link stringFacets} and {@link numericFacets}.
173
+ * @see <a href="http://shex.io/shex-semantics/#xs-string">ShEx String Facet Constraints</a> and <a href="http://shex.io/shex-semantics/#xs-numeric">ShEx Numeric Facet Constraints</a>.
174
+ */
175
+ export interface xsFacets extends stringFacets, numericFacets {
176
+ }
177
+ /**
178
+ * The set of <a href="https://www.w3.org/TR/xmlschema-2/#facets">XML Schema Facets</a> applying to <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form">lexical forms of RDF terms</a>.
179
+ * @see <a href="http://shex.io/shex-semantics/#xs-string">ShEx String Facet Constraints</a>.
180
+ */
181
+ export interface stringFacets {
182
+ /**
183
+ * Expected length of the lexical form of an RDF Term.
184
+ */
185
+ length?: INTEGER | undefined;
186
+ /**
187
+ * Expected minimum length of the lexical form of an RDF Term.
188
+ */
189
+ minlength?: INTEGER | undefined;
190
+ /**
191
+ * Expected maximum length of the lexical form of an RDF Term.
192
+ */
193
+ maxlength?: INTEGER | undefined;
194
+ /**
195
+ * Regular expression which the lexical forn of an RDF Term must match.
196
+ */
197
+ pattern?: STRING | undefined;
198
+ /**
199
+ * Optional flags for the regular expression in {@link pattern}.
200
+ */
201
+ flags?: STRING | undefined;
202
+ }
203
+ /**
204
+ * The set of <a href="https://www.w3.org/TR/xmlschema-2/#facets">XML Schema Facets</a> applying to <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-value-space">numeric values of RDF terms</a>.
205
+ * @see <a href="http://shex.io/shex-semantics/#xs-numeric">ShEx Numeric Facet Constraints</a>.
206
+ */
207
+ export interface numericFacets {
208
+ /**
209
+ * Conformant <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF Literal</a> has as a numeric value <= {@link mininclusive}.
210
+ */
211
+ mininclusive?: numericLiteral | undefined;
212
+ /**
213
+ * Conformant <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF Literal</a> has as a numeric value < {@link minexclusive}.
214
+ */
215
+ minexclusive?: numericLiteral | undefined;
216
+ /**
217
+ * Conformant <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF Literal</a> has as a numeric value > {@link maxinclusive}.
218
+ */
219
+ maxinclusive?: numericLiteral | undefined;
220
+ /**
221
+ * Conformant <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF Literal</a> has as a numeric value >= {@link maxexclusive}.
222
+ */
223
+ maxexclusive?: numericLiteral | undefined;
224
+ /**
225
+ * Conformant <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF Literal</a> has as a numeric value whose canonical form has {@link totaldigits} digits.
226
+ * @see <a href="http://shex.io/shex-semantics/#nodeSatisfies-totaldigits">ShEx totalDigits definition</a>
227
+ */
228
+ totaldigits?: INTEGER | undefined;
229
+ /**
230
+ * Conformant <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF Literal</a> has as a numeric value whose canonical form has {@link fractiondigits} digits.
231
+ * @see <a href="http://shex.io/shex-semantics/#nodeSatisfies-fractiondigits">ShEx fractionDigits definition</a>
232
+ */
233
+ fractiondigits?: INTEGER | undefined;
234
+ }
235
+ /**
236
+ * Union of numeric types in ShEx used in {@link numericFacets}s.
237
+ */
238
+ export type numericLiteral = INTEGER | DECIMAL | DOUBLE;
239
+ /**
240
+ * Union of numeric types that may appear in a value set.
241
+ * @see {@link NodeConstraint#values}.
242
+ */
243
+ export type valueSetValue = objectValue | IriStem | IriStemRange | LiteralStem | LiteralStemRange | Language | LanguageStem | LanguageStemRange;
244
+ /**
245
+ * JSON-LD representation of a URL or a Literal.
246
+ */
247
+ export type objectValue = IRIREF | ObjectLiteral;
248
+ /**
249
+ * A <a href="https://www.w3.org/TR/json-ld11/#value-objects">JSON-LD Value Object</a> used to express an <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF Literal</a>.
250
+ */
251
+ export interface ObjectLiteral {
252
+ /**
253
+ * The <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form">lexical form</a> of an RDF Literal.
254
+ */
255
+ value: STRING;
256
+ /**
257
+ * The <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-language-tag">language tag</a> of an RDF Literal.
258
+ */
259
+ language?: STRING | undefined;
260
+ /**
261
+ * The <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-datatype">datatype</a> of an RDF Literal.
262
+ */
263
+ type?: STRING | undefined;
264
+ }
265
+ /**
266
+ * Matchs an <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-iri">RDF IRI</a> starting with the character sequence in {@link stem}.
267
+ */
268
+ export interface IriStem {
269
+ /**
270
+ * Mandatory type "IriStem".
271
+ */
272
+ type: "IriStem";
273
+ /**
274
+ * substring of IRI to be matched.
275
+ */
276
+ stem: IRIREF;
277
+ }
278
+ export type iriRangeStem = IRIREF | Wildcard;
279
+ export type iriRangeExclusion = IRIREF | IriStem;
280
+ /**
281
+ * Filters a matching <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-iri">RDF IRI</a>s through a list of exclusions.
282
+ * The initial match is made on an IRI stem per {@link IriStem} or a {@link Wildcard} to accept any IRI.
283
+ * The {@link exclusion}s are either specific IRIs or {@link IRIStem}s.
284
+ */
285
+ export interface IriStemRange {
286
+ /**
287
+ * Mandatory type "IriStemRange".
288
+ */
289
+ type: "IriStemRange";
290
+ /**
291
+ * substring of IRI to be matched or a {@link Wildcard} matching any IRI.
292
+ */
293
+ stem: iriRangeStem;
294
+ /**
295
+ * IRIs or {@link IRIStem}s to exclude.
296
+ */
297
+ exclusions: iriRangeExclusion[];
298
+ }
299
+ /**
300
+ * Matchs an <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF Literal</a> starting with the character sequence in {@link stem}.
301
+ */
302
+ export interface LiteralStem {
303
+ /**
304
+ * Mandatory type "LiteralStem".
305
+ */
306
+ type: "LiteralStem";
307
+ /**
308
+ * substring of Literal to be matched.
309
+ */
310
+ stem: STRING;
311
+ }
312
+ export type literalRangeStem = string | Wildcard;
313
+ export type literalRangeExclusion = string | LiteralStem;
314
+ /**
315
+ * Filters a matching <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-literal">RDF Literal</a>s through a list of exclusions.
316
+ * The initial match is made on an Literal stem per {@link LiteralStem} or a {@link Wildcard} to accept any Literal.
317
+ * The {@link exclusion}s are either specific Literals or {@link LiteralStem}s.
318
+ */
319
+ export interface LiteralStemRange {
320
+ /**
321
+ * Mandatory type "LiteralStemRange".
322
+ */
323
+ type: "LiteralStemRange";
324
+ /**
325
+ * substring of Literal to be matched or a {@link Wildcard} matching any Literal.
326
+ */
327
+ stem: literalRangeStem;
328
+ /**
329
+ * Literals or {@link LiteralStem}s to exclude.
330
+ */
331
+ exclusions: literalRangeExclusion[];
332
+ }
333
+ /**
334
+ * An <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-language-tag">RDF Language Tag</a>.
335
+ */
336
+ export interface Language {
337
+ /**
338
+ * Mandatory type "Language".
339
+ */
340
+ type: "Language";
341
+ /**
342
+ * The <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-lexical-form">lexical representation</a> of an RDF Language Tag.
343
+ */
344
+ languageTag: LANGTAG;
345
+ }
346
+ /**
347
+ * Matchs an <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-language-tag">RDF Language Tag</a> starting with the character sequence in {@link stem}.
348
+ */
349
+ export interface LanguageStem {
350
+ /**
351
+ * Mandatory type "LanguageStem".
352
+ */
353
+ type: "LanguageStem";
354
+ /**
355
+ * substring of Language Tag to be matched.
356
+ */
357
+ stem: LANGTAG;
358
+ }
359
+ export type languageRangeStem = string | Wildcard;
360
+ export type languageRangeExclusion = string | LanguageStem;
361
+ /**
362
+ * Filters a matching <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-langugae-tag">RDF Language Tag</a>s through a list of exclusions.
363
+ * The initial match is made on an Language Tag stem per {@link Language TagStem} or a {@link Wildcard} to accept any Language Tag.
364
+ * The {@link exclusion}s are either specific Language Tags or {@link Language TagStem}s.
365
+ */
366
+ export interface LanguageStemRange {
367
+ /**
368
+ * Mandatory type "LanguageStemRange".
369
+ */
370
+ type: "LanguageStemRange";
371
+ /**
372
+ * substring of Language-Tag to be matched or a {@link Wildcard} matching any Language Tag.
373
+ */
374
+ stem: languageRangeStem;
375
+ /**
376
+ * Language Tags or {@link LanguageStem}s to exclude.
377
+ */
378
+ exclusions: languageRangeExclusion[];
379
+ }
380
+ /**
381
+ * An empty object signifying than any item may be matched.
382
+ * This is used in {@link IriStemRange}, {@link LiteralStemRange} and {@link LanguageStemRange}.
383
+ */
384
+ export interface Wildcard {
385
+ /**
386
+ * Mandatory type "Wildcard".
387
+ */
388
+ type: "Wildcard";
389
+ }
390
+ /**
391
+ * A collection of {@link tripleExpr}s which must be matched by <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-triple">RDF Triple</a>s in conformance data.
392
+ */
393
+ export interface Shape extends semactsAndAnnotations {
394
+ /**
395
+ * Mandatory type "Shape".
396
+ */
397
+ type: "Shape";
398
+ /**
399
+ * Only the predicates mentioned in the {@link expression} may appear in conformant data.
400
+ */
401
+ closed?: BOOL | undefined;
402
+ /**
403
+ * Permit extra triples with these predicates to appear in triples which don't match any {@link TripleConstraint}s mentioned in the {@link expression}.
404
+ */
405
+ extra?: IRIREF[] | undefined;
406
+ /**
407
+ * List of one or more {@link shapeExprOrRef}s that a neighborhood must satisfy in order to conform to this shape.
408
+ */
409
+ extends?: shapeExprOrRef[];
410
+ /**
411
+ * A tree of {@link tripleExpr}s specifying a set triples into or out of conformant <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-node">RDF Nodes</a>.
412
+ */
413
+ expression?: tripleExprOrRef | undefined;
414
+ }
415
+ /**
416
+ * Union of triple expression types.
417
+ * @see <a href="http://shex.io/shex-semantics/#dfn-tripleexpr">ShEx tripleExpr definition</a>
418
+ */
419
+ export type tripleExpr = EachOf | OneOf | TripleConstraint;
420
+ /**
421
+ * A tripleExpr or a label to one.
422
+ * @see <a href="http://shex.io/shex-semantics/#dfn-tripleexpr">ShEx tripleExpr definition</a>
423
+ */
424
+ export type tripleExprOrRef = tripleExpr | tripleExprRef;
425
+ /**
426
+ * Common attributes appearing in every form of {@link tripleExpr}.
427
+ */
428
+ export interface tripleExprBase extends semactsAndAnnotations {
429
+ /**
430
+ * Optional identifier for {@link tripleExpr}s for reference by {@link tripleExprRef}.
431
+ * The identifier is an <a href="https://www.w3.org/TR/json-ld11/#node-identifiers">IRI</a> or a <a href="https://www.w3.org/TR/json-ld11/#identifying-blank-nodes">BlankNode</a>
432
+ * as expressed in <a href="https://www.w3.org/TR/json-ld11/">JSON-LD 1.1</a>.
433
+ */
434
+ id?: tripleExprLabel | undefined;
435
+ /**
436
+ * Minimum number of times matching triples must appear in conformant data.
437
+ */
438
+ min?: INTEGER | undefined;
439
+ /**
440
+ * Maximum number of times matching triples must appear in conformant data.
441
+ */
442
+ max?: INTEGER | undefined;
443
+ }
444
+ /**
445
+ * A list of of triple expressions; considered conformant if there is some conforming mapping of the examined triples to the {@link #tripleExprs}.
446
+ * @see <a href="http://shex.io/shex-semantics/#dfn-eachof">ShEx EachOf definition</a>
447
+ */
448
+ export interface EachOf extends tripleExprBase {
449
+ /**
450
+ * Mandatory type "EachOf".
451
+ */
452
+ type: "EachOf";
453
+ expressions: tripleExprOrRef[];
454
+ }
455
+ /**
456
+ * An exclusive choice of triple expressions; considered conformant if exactly one of {@link #shapeExprs} conforms.
457
+ * @see <a href="http://shex.io/shex-semantics/#dfn-oneof">ShEx OneOf definition</a>
458
+ */
459
+ export interface OneOf extends tripleExprBase {
460
+ /**
461
+ * Mandatory type "OneOf".
462
+ */
463
+ type: "OneOf";
464
+ expressions: tripleExprOrRef[];
465
+ }
466
+ /**
467
+ * A template matching a number of triples attached to the node being validated.
468
+ */
469
+ export interface TripleConstraint extends tripleExprBase {
470
+ /**
471
+ * Mandatory type "TripleConstraint".
472
+ */
473
+ type: "TripleConstraint";
474
+ /**
475
+ * If false, the TripleConstraint matches the a triple composed of a focus node, the {@link predicate} and an object matching the (optional) {@link shapeExpr}.
476
+ * If true, the TripleConstraint matches the a triple composed of a subject matching the (optional) {@link shapeExpr}, the {@link predicate} and focus node.
477
+ */
478
+ inverse?: BOOL | undefined;
479
+ /**
480
+ * The predicate expected in a matching <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-triple">RDF Triple</a>.
481
+ */
482
+ predicate: IRIREF;
483
+ /**
484
+ * A {@link shapeExpr} matching a conformant <a href="https://www.w3.org/TR/rdf11-concepts/#dfn-triple">RDF Triple</a>s subject or object, depending on the value of {@link inverse}.
485
+ */
486
+ valueExpr?: shapeExprOrRef | undefined;
487
+ /**
488
+ * The property name used for creating the JSON object.
489
+ */
490
+ readablePredicate: string;
491
+ }
492
+ /**
493
+ * A reference a triple expression.
494
+ * The reference is an <a href="https://www.w3.org/TR/json-ld11/#node-identifiers">IRI</a> or a <a href="https://www.w3.org/TR/json-ld11/#identifying-blank-nodes">BlankNode</a>
495
+ * as expressed in <a href="https://www.w3.org/TR/json-ld11/">JSON-LD 1.1</a>.
496
+ */
497
+ export type tripleExprRef = tripleExprLabel;
498
+ /**
499
+ * An identifier for a triple expression.
500
+ * The identifier is an <a href="https://www.w3.org/TR/json-ld11/#node-identifiers">IRI</a> or a <a href="https://www.w3.org/TR/json-ld11/#identifying-blank-nodes">BlankNode</a>
501
+ * as expressed in <a href="https://www.w3.org/TR/json-ld11/">JSON-LD 1.1</a>.
502
+ */
503
+ export type tripleExprLabel = IRIREF | BNODE;
504
+ /**
505
+ * An extension point for Shape Expressions allowing external code to be invoked during validation.
506
+ */
507
+ export interface SemAct {
508
+ /**
509
+ * Mandatory type "SemAct".
510
+ */
511
+ type: "SemAct";
512
+ name: IRIREF;
513
+ code?: STRING | undefined;
514
+ }
515
+ /**
516
+ * An assertion about some part of a ShEx schema which has no affect on conformance checking.
517
+ * These can be useful for documentation, provenance tracking, form generation, etch.
518
+ */
519
+ export interface Annotation {
520
+ /**
521
+ * Mandatory type "Annotation".
522
+ */
523
+ type: "Annotation";
524
+ /**
525
+ * The <a href="https://www.w3.org/TR/json-ld11/#node-identifiers">RDF Predicate</a> of the annotation.
526
+ */
527
+ predicate: IRI;
528
+ /**
529
+ * A value for the above {@link predicate}.
530
+ */
531
+ object: objectValue;
532
+ }
533
+ export type IRIREF = string;
534
+ export type BNODE = string;
535
+ export type INTEGER = number;
536
+ export type STRING = string;
537
+ export type DECIMAL = number;
538
+ export type DOUBLE = number;
539
+ export type LANGTAG = string;
540
+ export type BOOL = boolean;
541
+ export type IRI = string;
542
+ //# sourceMappingURL=ShexJTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ShexJTypes.d.ts","sourceRoot":"","sources":["../src/ShexJTypes.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,CAAC;AAEV;;;GAGG;AACH,MAAM,WAAW,MAAM;IACnB;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IACf;;OAEG;IACH,UAAU,CAAC,EAAE,kCAAkC,GAAG,SAAS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AAG,KAAK,CAAC;AAE7C;;GAEG;AACH,MAAM,WAAW,MAAM;IACnB;;OAEG;IACH,IAAI,EAAE,QAAQ,CAAC;IAIf,IAAI,EAAE,MAAM,CAAC;IAKb,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACvB;;OAEG;IACH,IAAI,EAAE,YAAY,CAAC;IACnB;;OAEG;IACH,SAAS,EAAE,GAAG,CAAC;IACf;;OAEG;IACH,MAAM,EAAE,WAAW,CAAC;CACvB;AAED,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,MAAM,KAAK,GAAG,MAAM,CAAC;AAC3B,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAC7B,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAC7B,MAAM,MAAM,MAAM,GAAG,MAAM,CAAC;AAC5B,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC;AAC7B,MAAM,MAAM,IAAI,GAAG,OAAO,CAAC;AAC3B,MAAM,MAAM,GAAG,GAAG,MAAM,CAAC"}
@@ -0,0 +1,10 @@
1
+ // Copyright (c) 2025 Laurin Weger, Par le Peuple, NextGraph.org developers
2
+ // All rights reserved.
3
+ // Licensed under the Apache License, Version 2.0
4
+ // <LICENSE-APACHE2 or http://www.apache.org/licenses/LICENSE-2.0>
5
+ // or the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>,
6
+ // at your option. All files in the project carrying such
7
+ // notice may not be copied, modified, or distributed except
8
+ // according to those terms.
9
+ // SPDX-License-Identifier: Apache-2.0 OR MIT/
10
+ export {};
@@ -0,0 +1,8 @@
1
+ interface BuildOptions {
2
+ input: string;
3
+ output: string;
4
+ baseIRI?: string;
5
+ }
6
+ export declare function build({ input: inputFile, output: outputFile, baseIRI, }: BuildOptions): Promise<void>;
7
+ export {};
8
+ //# sourceMappingURL=build.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../src/build.ts"],"names":[],"mappings":"AA4BA,UAAU,YAAY;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAsB,KAAK,CAAC,EACxB,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,UAAU,EAClB,OAAyC,GAC5C,EAAE,YAAY,iBAmEd"}
package/dist/build.js ADDED
@@ -0,0 +1,72 @@
1
+ // Copyright (c) 2025 Laurin Weger, Par le Peuple, NextGraph.org developers
2
+ // All rights reserved.
3
+ // Copyright (c) 2023 Jackson Morgan
4
+ // Licensed under the Apache License, Version 2.0
5
+ // <LICENSE-APACHE2 or http://www.apache.org/licenses/LICENSE-2.0>
6
+ // or the MIT license <LICENSE-MIT or http://opensource.org/licenses/MIT>,
7
+ // at your option. All files in the project carrying such
8
+ // notice may not be copied, modified, or distributed except
9
+ // according to those terms.
10
+ // SPDX-License-Identifier: Apache-2.0 OR MIT
11
+ import fs from "fs-extra";
12
+ import path from "path";
13
+ import parser from "@shexjs/parser";
14
+ import { shexJConverter } from "./schema-converter/converter.js";
15
+ import { renderFile } from "ejs";
16
+ import prettier from "prettier";
17
+ import loading from "loading-cli";
18
+ import { dirname } from "node:path";
19
+ import { fileURLToPath } from "node:url";
20
+ import { forAllShapes } from "./util/forAllShapes.js";
21
+ import annotateReadablePredicates from "./schema-converter/util/annotateReadablePredicates.js";
22
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
23
+ // @ts-ignore
24
+ const __dirname = dirname(fileURLToPath(import.meta.url));
25
+ export async function build({ input: inputFile, output: outputFile, baseIRI = "https://nextgraph.org/shapes#", }) {
26
+ const load = loading("Preparing Environment");
27
+ load.start();
28
+ // Prepare new folder by clearing/and/or creating it
29
+ if (fs.existsSync(outputFile)) {
30
+ await fs.promises.rm(outputFile, { recursive: true });
31
+ }
32
+ await fs.promises.mkdir(outputFile);
33
+ const fileTemplates = [];
34
+ // Pre-annotate schema with readablePredicate to unify naming across outputs
35
+ fileTemplates.push("schema", "typings", "shapeTypes");
36
+ load.text = "Generating Schema Documents";
37
+ await forAllShapes(inputFile, async (fileName, shexC) => {
38
+ // Convert to ShexJ
39
+ let schema;
40
+ try {
41
+ // Prase Shex schema to JSON.
42
+ // TODO: Do we need the base IRI?
43
+ // @ts-ignore ...
44
+ schema = parser.construct(baseIRI).parse(shexC);
45
+ }
46
+ catch (err) {
47
+ const errMessage = err instanceof Error
48
+ ? err.message
49
+ : typeof err === "string"
50
+ ? err
51
+ : "Unknown Error";
52
+ console.error(`Error processing ${fileName}: ${errMessage}`);
53
+ return;
54
+ }
55
+ // Add readable predicates to schema as the single source of truth.
56
+ // @ts-ignore ...
57
+ annotateReadablePredicates(schema);
58
+ const [typings, compactSchema] = await shexJConverter(schema);
59
+ await Promise.all(fileTemplates.map(async (templateName) => {
60
+ const finalContent = await renderFile(path.join(__dirname, "schema-converter", "templates", `${templateName}.ejs`), {
61
+ typings: typings.typings,
62
+ fileName,
63
+ schema: JSON.stringify(schema, null, 2),
64
+ compactSchema: JSON.stringify(compactSchema, null, 2),
65
+ });
66
+ await fs.promises.writeFile(path.join(outputFile, `${fileName}.${templateName}.ts`), await prettier.format(finalContent, {
67
+ parser: "typescript",
68
+ }));
69
+ }));
70
+ });
71
+ load.stop();
72
+ }
package/dist/cli.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":""}