@shaclmate/compiler 4.0.38 → 4.0.39
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/dist/ShapesGraphToAstTransformer.js +12 -12
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +24 -24
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +4 -4
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +16 -16
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +1 -1
- package/dist/ast/AbstractCollectionType.d.ts +1 -1
- package/dist/ast/AbstractCompoundType.d.ts +1 -1
- package/dist/ast/AbstractCompoundType.js +15 -15
- package/dist/ast/AbstractContainerType.d.ts +1 -1
- package/dist/ast/AbstractContainerType.js +15 -15
- package/dist/ast/AbstractLazyObjectType.d.ts +1 -1
- package/dist/ast/AbstractTermType.d.ts +1 -1
- package/dist/ast/BlankNodeType.d.ts +1 -1
- package/dist/ast/BlankNodeType.js +1 -1
- package/dist/ast/DefaultValueType.d.ts +1 -1
- package/dist/ast/DefaultValueType.js +2 -2
- package/dist/ast/IdentifierType.d.ts +1 -1
- package/dist/ast/IdentifierType.js +1 -1
- package/dist/ast/IntersectionType.d.ts +1 -1
- package/dist/ast/IntersectionType.js +3 -3
- package/dist/ast/IriType.d.ts +1 -1
- package/dist/ast/IriType.js +1 -1
- package/dist/ast/LazyObjectOptionType.d.ts +1 -1
- package/dist/ast/LazyObjectOptionType.js +1 -1
- package/dist/ast/LazyObjectSetType.d.ts +1 -1
- package/dist/ast/LazyObjectSetType.js +1 -1
- package/dist/ast/LazyObjectType.d.ts +1 -1
- package/dist/ast/LazyObjectType.js +1 -1
- package/dist/ast/ListType.d.ts +1 -1
- package/dist/ast/ListType.js +16 -16
- package/dist/ast/LiteralType.d.ts +1 -1
- package/dist/ast/LiteralType.js +1 -1
- package/dist/ast/ObjectCompoundType.js +3 -3
- package/dist/ast/ObjectType.d.ts +1 -1
- package/dist/ast/ObjectType.js +16 -16
- package/dist/ast/OptionType.d.ts +1 -1
- package/dist/ast/OptionType.js +1 -1
- package/dist/ast/SetType.d.ts +1 -1
- package/dist/ast/SetType.js +1 -1
- package/dist/ast/TermType.d.ts +1 -1
- package/dist/ast/TermType.js +1 -1
- package/dist/ast/Type.js +15 -15
- package/dist/ast/UnionType.d.ts +1 -1
- package/dist/ast/UnionType.js +3 -3
- package/dist/generators/transformAstToLabeledPropertyGraph.js +10 -10
- package/dist/generators/ts/AbstractCollectionType.d.ts +1 -5
- package/dist/generators/ts/AbstractCollectionType.js +6 -5
- package/dist/generators/ts/AbstractContainerType.d.ts +3 -6
- package/dist/generators/ts/AbstractContainerType.js +34 -34
- package/dist/generators/ts/AbstractDateType.d.ts +1 -1
- package/dist/generators/ts/AbstractIdentifierType.d.ts +1 -1
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +7 -10
- package/dist/generators/ts/AbstractLazyObjectType.js +20 -32
- package/dist/generators/ts/AbstractLiteralType.d.ts +1 -5
- package/dist/generators/ts/AbstractLiteralType.js +7 -6
- package/dist/generators/ts/AbstractNumericType.d.ts +1 -1
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +2 -6
- package/dist/generators/ts/AbstractPrimitiveType.js +7 -8
- package/dist/generators/ts/AbstractTermType.d.ts +1 -5
- package/dist/generators/ts/AbstractTermType.js +1 -15
- package/dist/generators/ts/AbstractType.d.ts +7 -5
- package/dist/generators/ts/AbstractType.js +12 -7
- package/dist/generators/ts/AbstractUnionType.d.ts +7 -10
- package/dist/generators/ts/AbstractUnionType.js +70 -81
- package/dist/generators/ts/AnonymousUnionType.d.ts +1 -1
- package/dist/generators/ts/AnonymousUnionType.js +1 -1
- package/dist/generators/ts/BigDecimalType.d.ts +1 -1
- package/dist/generators/ts/BigDecimalType.js +1 -1
- package/dist/generators/ts/BigIntType.d.ts +1 -1
- package/dist/generators/ts/BigIntType.js +1 -1
- package/dist/generators/ts/BlankNodeType.d.ts +1 -1
- package/dist/generators/ts/BlankNodeType.js +1 -1
- package/dist/generators/ts/BooleanType.d.ts +1 -1
- package/dist/generators/ts/BooleanType.js +2 -2
- package/dist/generators/ts/DateTimeType.d.ts +1 -1
- package/dist/generators/ts/DateTimeType.js +1 -1
- package/dist/generators/ts/DateType.d.ts +1 -1
- package/dist/generators/ts/DateType.js +1 -1
- package/dist/generators/ts/DefaultValueType.d.ts +2 -6
- package/dist/generators/ts/DefaultValueType.js +12 -15
- package/dist/generators/ts/FloatType.d.ts +1 -1
- package/dist/generators/ts/FloatType.js +1 -1
- package/dist/generators/ts/IdentifierType.d.ts +1 -1
- package/dist/generators/ts/IdentifierType.js +1 -1
- package/dist/generators/ts/IntType.d.ts +1 -1
- package/dist/generators/ts/IntType.js +1 -1
- package/dist/generators/ts/IriType.d.ts +3 -1
- package/dist/generators/ts/IriType.js +22 -17
- package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectOptionType.js +1 -1
- package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectSetType.js +1 -1
- package/dist/generators/ts/LazyObjectType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectType.js +1 -1
- package/dist/generators/ts/ListType.d.ts +1 -1
- package/dist/generators/ts/ListType.js +24 -24
- package/dist/generators/ts/LiteralType.d.ts +2 -1
- package/dist/generators/ts/LiteralType.js +9 -2
- package/dist/generators/ts/NamedObjectType.d.ts +1 -0
- package/dist/generators/ts/NamedObjectType.js +2 -1
- package/dist/generators/ts/NamedObjectUnionType.d.ts +1 -1
- package/dist/generators/ts/NamedObjectUnionType.js +6 -8
- package/dist/generators/ts/NamedUnionType.d.ts +1 -1
- package/dist/generators/ts/NamedUnionType.js +1 -1
- package/dist/generators/ts/OptionType.d.ts +1 -5
- package/dist/generators/ts/OptionType.js +2 -8
- package/dist/generators/ts/RdfjsDatasetObjectSetType.js +1 -1
- package/dist/generators/ts/SetType.d.ts +1 -1
- package/dist/generators/ts/SetType.js +1 -1
- package/dist/generators/ts/Snippets.d.ts +1 -0
- package/dist/generators/ts/Snippets.js +7 -0
- package/dist/generators/ts/StringType.d.ts +1 -1
- package/dist/generators/ts/StringType.js +2 -2
- package/dist/generators/ts/TermType.d.ts +1 -1
- package/dist/generators/ts/TermType.js +1 -1
- package/dist/generators/ts/TypeFactory.js +18 -18
- package/dist/generators/ts/ZodGenerator.js +1 -1
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +7 -7
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +8 -11
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +2 -1
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +16 -7
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +2 -1
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +6 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +3 -27
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +1 -1
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +2 -6
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +19 -23
- package/dist/generators/ts/_snippets/snippets_BooleanSchema.js +2 -2
- package/dist/generators/ts/_snippets/snippets_CollectionSchema.js +1 -1
- package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +1 -1
- package/dist/generators/ts/_snippets/snippets_IriSchema.js +2 -2
- package/dist/generators/ts/_snippets/snippets_MaybeSchema.js +2 -2
- package/dist/generators/ts/_snippets/snippets_ShaclPropertySchema.js +1 -1
- package/dist/generators/ts/_snippets/snippets_StringSchema.js +2 -2
- package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_convertToIri.js +1 -1
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_ensureRdfResourceType.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_ensureRdfResourceType.js +16 -0
- package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +2 -2
- package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.js +1 -1
- package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.js +3 -3
- package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.js +1 -1
- package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.js +1 -1
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_validateArray.js +1 -1
- package/dist/generators/ts/_snippets/snippets_validateMaybe.js +1 -1
- package/dist/generators/ts/tsComment.js +1 -1
- package/dist/input/generated.d.ts +1397 -1466
- package/dist/input/generated.js +516 -653
- package/package.json +2 -2
- package/dist/generators/ts/removeUndefined.d.ts +0 -2
- package/dist/generators/ts/removeUndefined.js +0 -17
|
@@ -103,24 +103,24 @@ export class ShapesGraphToAstTransformer {
|
|
|
103
103
|
}
|
|
104
104
|
const nodeShapeAstType = nodeShapeAstTypeEither.unsafeCoerce();
|
|
105
105
|
switch (nodeShapeAstType.kind) {
|
|
106
|
-
case "
|
|
106
|
+
case "Intersection":
|
|
107
107
|
if (nodeShapeAstType.name.isJust()) {
|
|
108
108
|
astNamedIntersectionTypes.push(nodeShapeAstType);
|
|
109
109
|
}
|
|
110
110
|
break;
|
|
111
|
-
case "
|
|
111
|
+
case "Object": {
|
|
112
112
|
invariant(nodeShapeAstType.name.isJust(), `node shape missing name: ${nodeShapeAstType.shapeIdentifier}`);
|
|
113
113
|
astObjectTypes.push(nodeShapeAstType);
|
|
114
114
|
for (const property of nodeShapeAstType.properties) {
|
|
115
115
|
switch (property.type.kind) {
|
|
116
|
-
case "
|
|
117
|
-
case "
|
|
118
|
-
case "
|
|
119
|
-
const partialItemType = property.type.partialType.kind === "
|
|
120
|
-
property.type.partialType.kind === "
|
|
116
|
+
case "LazyObjectOption":
|
|
117
|
+
case "LazyObjectSet":
|
|
118
|
+
case "LazyObject": {
|
|
119
|
+
const partialItemType = property.type.partialType.kind === "Object" ||
|
|
120
|
+
property.type.partialType.kind === "Union"
|
|
121
121
|
? property.type.partialType
|
|
122
122
|
: property.type.partialType.itemType;
|
|
123
|
-
if (partialItemType.kind === "
|
|
123
|
+
if (partialItemType.kind === "Object" &&
|
|
124
124
|
partialItemType.synthetic) {
|
|
125
125
|
const partialItemTypeName = partialItemType.name.unsafeCoerce();
|
|
126
126
|
if (!syntheticAstObjectTypesByName[partialItemTypeName]) {
|
|
@@ -133,7 +133,7 @@ export class ShapesGraphToAstTransformer {
|
|
|
133
133
|
}
|
|
134
134
|
break;
|
|
135
135
|
}
|
|
136
|
-
case "
|
|
136
|
+
case "Union":
|
|
137
137
|
if (nodeShapeAstType.name.isJust()) {
|
|
138
138
|
astNamedUnionTypes.push(nodeShapeAstType);
|
|
139
139
|
}
|
|
@@ -145,9 +145,9 @@ export class ShapesGraphToAstTransformer {
|
|
|
145
145
|
return Either.of({
|
|
146
146
|
lazyTypesCount: [...this.cachedAstTypesByShapeIdentifier.values()].reduce((acc, astType) => {
|
|
147
147
|
switch (astType.kind) {
|
|
148
|
-
case "
|
|
149
|
-
case "
|
|
150
|
-
case "
|
|
148
|
+
case "LazyObject":
|
|
149
|
+
case "LazyObjectOption":
|
|
150
|
+
case "LazyObjectSet":
|
|
151
151
|
return acc + 1;
|
|
152
152
|
default:
|
|
153
153
|
return acc;
|
|
@@ -9,12 +9,12 @@ import { transformShapeToAstType } from "./transformShapeToAstType.js";
|
|
|
9
9
|
function synthesizePartialAstObjectType({ identifierType, }) {
|
|
10
10
|
let syntheticName;
|
|
11
11
|
switch (identifierType.kind) {
|
|
12
|
-
case "
|
|
12
|
+
case "BlankNode":
|
|
13
13
|
throw new Error("should never happen");
|
|
14
|
-
case "
|
|
14
|
+
case "Identifier":
|
|
15
15
|
syntheticName = "DefaultPartial";
|
|
16
16
|
break;
|
|
17
|
-
case "
|
|
17
|
+
case "Iri":
|
|
18
18
|
syntheticName = "NamedDefaultPartial";
|
|
19
19
|
break;
|
|
20
20
|
}
|
|
@@ -92,7 +92,7 @@ function transformPropertyShapeToAstType(propertyShape, shapeStack) {
|
|
|
92
92
|
if (maxCount < minCount) {
|
|
93
93
|
maxCount = minCount;
|
|
94
94
|
}
|
|
95
|
-
if (propertyShapeAstType.kind === "
|
|
95
|
+
if (propertyShapeAstType.kind === "DefaultValue") {
|
|
96
96
|
if (minCount > 0n) {
|
|
97
97
|
return Left(new Error(`${propertyShape}: has sh:minCount > 0 and sh:defaultValue`));
|
|
98
98
|
}
|
|
@@ -135,9 +135,9 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
135
135
|
.call(this, propertyShapeResolve.unsafeCoerce(), shapeStack)
|
|
136
136
|
.chain((astResolveType) => {
|
|
137
137
|
switch (astResolveType.kind) {
|
|
138
|
-
case "
|
|
138
|
+
case "Object":
|
|
139
139
|
return Either.of(astResolveType);
|
|
140
|
-
case "
|
|
140
|
+
case "Union":
|
|
141
141
|
if (
|
|
142
142
|
// This check relies on .members being populated, which may not happen in cycles
|
|
143
143
|
astResolveType.members.length > 0 &&
|
|
@@ -157,15 +157,15 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
157
157
|
if (astResolveItemType) {
|
|
158
158
|
let astItemType;
|
|
159
159
|
switch (astType.kind) {
|
|
160
|
-
case "
|
|
161
|
-
case "
|
|
162
|
-
case "
|
|
160
|
+
case "DefaultValue":
|
|
161
|
+
case "Option":
|
|
162
|
+
case "Set":
|
|
163
163
|
astItemType = astType.itemType;
|
|
164
164
|
break;
|
|
165
|
-
case "
|
|
166
|
-
case "
|
|
165
|
+
case "LazyObjectOption":
|
|
166
|
+
case "LazyObjectSet":
|
|
167
167
|
// biome-ignore lint/suspicious/noFallthroughSwitchClause: break is unreachable
|
|
168
|
-
case "
|
|
168
|
+
case "LazyObject":
|
|
169
169
|
invariant(false, `lazy types should not appear here: ${astType.kind}`);
|
|
170
170
|
default:
|
|
171
171
|
astItemType = astType;
|
|
@@ -173,17 +173,17 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
173
173
|
}
|
|
174
174
|
let astPartialItemType;
|
|
175
175
|
switch (astItemType.kind) {
|
|
176
|
-
case "
|
|
177
|
-
case "
|
|
178
|
-
case "
|
|
176
|
+
case "BlankNode":
|
|
177
|
+
case "Identifier":
|
|
178
|
+
case "Iri":
|
|
179
179
|
astPartialItemType = synthesizePartialAstObjectType({
|
|
180
180
|
identifierType: astItemType,
|
|
181
181
|
});
|
|
182
182
|
break;
|
|
183
|
-
case "
|
|
183
|
+
case "Object":
|
|
184
184
|
astPartialItemType = astItemType;
|
|
185
185
|
break;
|
|
186
|
-
case "
|
|
186
|
+
case "Union":
|
|
187
187
|
if (!astItemType.isObjectUnionType()) {
|
|
188
188
|
return Left(new Error(`${propertyShape} partial type cannot be a ${astItemType.kind} with non-ObjectType members`));
|
|
189
189
|
}
|
|
@@ -199,18 +199,18 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
199
199
|
shapeIdentifier: propertyShape.$identifier(),
|
|
200
200
|
};
|
|
201
201
|
switch (astType.kind) {
|
|
202
|
-
case "
|
|
203
|
-
case "
|
|
204
|
-
case "
|
|
205
|
-
case "
|
|
206
|
-
case "
|
|
202
|
+
case "BlankNode":
|
|
203
|
+
case "Identifier":
|
|
204
|
+
case "Iri":
|
|
205
|
+
case "Object":
|
|
206
|
+
case "Union":
|
|
207
207
|
astType = new ast.LazyObjectType({
|
|
208
208
|
...astAbstractTypeProperties,
|
|
209
209
|
partialType: astPartialItemType,
|
|
210
210
|
resolveType: astResolveItemType,
|
|
211
211
|
});
|
|
212
212
|
break;
|
|
213
|
-
case "
|
|
213
|
+
case "Option":
|
|
214
214
|
astType = new ast.LazyObjectOptionType({
|
|
215
215
|
...astAbstractTypeProperties,
|
|
216
216
|
partialType: new ast.OptionType({
|
|
@@ -221,7 +221,7 @@ export function transformPropertyShapeToAstObjectTypeProperty({ objectType, prop
|
|
|
221
221
|
}),
|
|
222
222
|
});
|
|
223
223
|
break;
|
|
224
|
-
case "
|
|
224
|
+
case "Set":
|
|
225
225
|
astType = new ast.LazyObjectSetType({
|
|
226
226
|
...astAbstractTypeProperties,
|
|
227
227
|
partialType: new ast.SetType({
|
|
@@ -21,18 +21,18 @@ export function transformShapeToAstCompoundType(shape, shapeStack) {
|
|
|
21
21
|
let memberShapes;
|
|
22
22
|
if (andConstraintShapes.length > 0) {
|
|
23
23
|
memberShapes = andConstraintShapes;
|
|
24
|
-
compoundTypeKind = "
|
|
24
|
+
compoundTypeKind = "Intersection";
|
|
25
25
|
}
|
|
26
26
|
else if (xoneConstraintShapes.length > 0) {
|
|
27
27
|
memberShapes = xoneConstraintShapes;
|
|
28
|
-
compoundTypeKind = "
|
|
28
|
+
compoundTypeKind = "Union";
|
|
29
29
|
}
|
|
30
30
|
else {
|
|
31
31
|
return Either.of(Maybe.empty());
|
|
32
32
|
}
|
|
33
33
|
invariant(memberShapes.length > 0);
|
|
34
34
|
const memberDiscriminantValues = new Set();
|
|
35
|
-
const compoundType = new (compoundTypeKind === "
|
|
35
|
+
const compoundType = new (compoundTypeKind === "Intersection"
|
|
36
36
|
? ast.IntersectionType
|
|
37
37
|
: ast.UnionType)({
|
|
38
38
|
comment: shape.comment,
|
|
@@ -61,7 +61,7 @@ export function transformShapeToAstCompoundType(shape, shapeStack) {
|
|
|
61
61
|
return Left(new Error(`${shape} has duplicate ${compoundTypeKind} member type: ${memberType}`));
|
|
62
62
|
}
|
|
63
63
|
let memberDiscriminantValue;
|
|
64
|
-
if (compoundTypeKind === "
|
|
64
|
+
if (compoundTypeKind === "Union") {
|
|
65
65
|
if (memberShape.$type === "NodeShape") {
|
|
66
66
|
memberDiscriminantValue =
|
|
67
67
|
memberShape.discriminantValue.extract();
|
|
@@ -120,7 +120,7 @@ export function transformShapeToAstListType(shape, shapeStack) {
|
|
|
120
120
|
propertyShape: restPropertyShape,
|
|
121
121
|
})
|
|
122
122
|
.chain((restProperty) => {
|
|
123
|
-
if (restProperty.type.kind !== "
|
|
123
|
+
if (restProperty.type.kind !== "List" ||
|
|
124
124
|
!restProperty.type.shapeIdentifier.equals(nodeShape.$identifier())) {
|
|
125
125
|
return Left(new Error(`${nodeShape} rdf:rest property is not recursive into the node shape`));
|
|
126
126
|
}
|
|
@@ -11,28 +11,28 @@ import { transformPropertyShapeToAstObjectTypeProperty } from "./transformProper
|
|
|
11
11
|
import { transformShapeToAstType } from "./transformShapeToAstType.js";
|
|
12
12
|
function isObjectTypePropertyRequired(property) {
|
|
13
13
|
switch (property.type.kind) {
|
|
14
|
-
case "
|
|
14
|
+
case "DefaultValue":
|
|
15
15
|
return false;
|
|
16
|
-
case "
|
|
16
|
+
case "LazyObjectOption":
|
|
17
17
|
return false;
|
|
18
|
-
case "
|
|
18
|
+
case "LazyObjectSet":
|
|
19
19
|
return property.type.partialType.minCount > 0n;
|
|
20
|
-
case "
|
|
20
|
+
case "Option":
|
|
21
21
|
return false;
|
|
22
|
-
case "
|
|
22
|
+
case "Set":
|
|
23
23
|
return property.type.minCount > 0;
|
|
24
|
-
case "
|
|
24
|
+
case "Union":
|
|
25
25
|
return property.type.members.every((member) => isObjectTypePropertyRequired({ type: member.type }));
|
|
26
|
-
case "
|
|
27
|
-
case "
|
|
28
|
-
case "
|
|
29
|
-
case "
|
|
30
|
-
case "
|
|
31
|
-
case "
|
|
32
|
-
case "
|
|
33
|
-
case "
|
|
26
|
+
case "BlankNode":
|
|
27
|
+
case "Identifier":
|
|
28
|
+
case "Iri":
|
|
29
|
+
case "LazyObject":
|
|
30
|
+
case "List":
|
|
31
|
+
case "Literal":
|
|
32
|
+
case "Object":
|
|
33
|
+
case "Term":
|
|
34
34
|
return true;
|
|
35
|
-
case "
|
|
35
|
+
case "Intersection":
|
|
36
36
|
throw new Error("unsupported");
|
|
37
37
|
default:
|
|
38
38
|
property.type;
|
|
@@ -138,7 +138,7 @@ export function transformShapeToAstObjectType(shape, shapeStack) {
|
|
|
138
138
|
.call(this, relatedNodeShape, new ShapeStack())
|
|
139
139
|
.toMaybe()
|
|
140
140
|
.toList())
|
|
141
|
-
.filter((astType) => astType.kind === "
|
|
141
|
+
.filter((astType) => astType.kind === "Object");
|
|
142
142
|
};
|
|
143
143
|
objectType.addAncestorObjectTypes(...relatedObjectTypes(ancestorNodeShapes));
|
|
144
144
|
objectType.addChildObjectTypes(...relatedObjectTypes(childNodeShapes));
|
|
@@ -76,7 +76,7 @@ export function transformShapeToAstTermType(shape, shapeStack) {
|
|
|
76
76
|
return shapeStack.defaultValue
|
|
77
77
|
.map((defaultValue) => {
|
|
78
78
|
switch (termType.kind) {
|
|
79
|
-
case "
|
|
79
|
+
case "BlankNode":
|
|
80
80
|
return Left(new Error(`${shape}: blank node identifier types cannot have default values`));
|
|
81
81
|
}
|
|
82
82
|
switch (termType.hasValues.length) {
|
|
@@ -3,7 +3,7 @@ import { AbstractContainerType } from "./AbstractContainerType.js";
|
|
|
3
3
|
* Abstract base class for a collection of items of a single type. This is the parent of ListType and SetType.
|
|
4
4
|
*/
|
|
5
5
|
export declare abstract class AbstractCollectionType<ItemTypeT extends AbstractCollectionType.ItemType = AbstractCollectionType.ItemType> extends AbstractContainerType<ItemTypeT> {
|
|
6
|
-
abstract readonly kind: "
|
|
6
|
+
abstract readonly kind: "List" | "Set";
|
|
7
7
|
/**
|
|
8
8
|
* The collection should be mutable in generated code.
|
|
9
9
|
*/
|
|
@@ -20,7 +20,7 @@ export declare abstract class AbstractCompoundType<MemberT extends AbstractCompo
|
|
|
20
20
|
/**
|
|
21
21
|
* Type discriminant
|
|
22
22
|
*/
|
|
23
|
-
abstract readonly kind: "
|
|
23
|
+
abstract readonly kind: "Intersection" | "Union";
|
|
24
24
|
/**
|
|
25
25
|
* Was this type synthesized or did it come from SHACL?
|
|
26
26
|
*/
|
|
@@ -57,22 +57,22 @@ __decorate([
|
|
|
57
57
|
(function (AbstractCompoundType) {
|
|
58
58
|
function isMemberType(type) {
|
|
59
59
|
switch (type.kind) {
|
|
60
|
-
case "
|
|
61
|
-
case "
|
|
62
|
-
case "
|
|
63
|
-
case "
|
|
64
|
-
case "
|
|
65
|
-
case "
|
|
66
|
-
case "
|
|
67
|
-
case "
|
|
60
|
+
case "BlankNode":
|
|
61
|
+
case "Identifier":
|
|
62
|
+
case "Intersection":
|
|
63
|
+
case "Iri":
|
|
64
|
+
case "Literal":
|
|
65
|
+
case "Object":
|
|
66
|
+
case "Term":
|
|
67
|
+
case "Union":
|
|
68
68
|
return true;
|
|
69
|
-
case "
|
|
70
|
-
case "
|
|
71
|
-
case "
|
|
72
|
-
case "
|
|
73
|
-
case "
|
|
74
|
-
case "
|
|
75
|
-
case "
|
|
69
|
+
case "DefaultValue":
|
|
70
|
+
case "LazyObjectOption":
|
|
71
|
+
case "LazyObjectSet":
|
|
72
|
+
case "LazyObject":
|
|
73
|
+
case "List":
|
|
74
|
+
case "Option":
|
|
75
|
+
case "Set":
|
|
76
76
|
return false;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
@@ -14,7 +14,7 @@ import type { UnionType } from "./UnionType.js";
|
|
|
14
14
|
* Abstract base class for types that contain other types e.g., ListType, OptionType, SetType.
|
|
15
15
|
*/
|
|
16
16
|
export declare abstract class AbstractContainerType<ItemTypeT extends AbstractContainerType.ItemType = AbstractContainerType.ItemType> extends AbstractType {
|
|
17
|
-
abstract readonly kind: "
|
|
17
|
+
abstract readonly kind: "DefaultValue" | "List" | "Option" | "Set";
|
|
18
18
|
/**
|
|
19
19
|
* Container item type.
|
|
20
20
|
*
|
|
@@ -39,22 +39,22 @@ export class AbstractContainerType extends AbstractType {
|
|
|
39
39
|
(function (AbstractContainerType) {
|
|
40
40
|
function isItemType(type) {
|
|
41
41
|
switch (type.kind) {
|
|
42
|
-
case "
|
|
43
|
-
case "
|
|
44
|
-
case "
|
|
45
|
-
case "
|
|
46
|
-
case "
|
|
47
|
-
case "
|
|
48
|
-
case "
|
|
49
|
-
case "
|
|
50
|
-
case "
|
|
42
|
+
case "BlankNode":
|
|
43
|
+
case "Identifier":
|
|
44
|
+
case "Intersection":
|
|
45
|
+
case "Iri":
|
|
46
|
+
case "List":
|
|
47
|
+
case "Literal":
|
|
48
|
+
case "Object":
|
|
49
|
+
case "Term":
|
|
50
|
+
case "Union":
|
|
51
51
|
return true;
|
|
52
|
-
case "
|
|
53
|
-
case "
|
|
54
|
-
case "
|
|
55
|
-
case "
|
|
56
|
-
case "
|
|
57
|
-
case "
|
|
52
|
+
case "DefaultValue":
|
|
53
|
+
case "LazyObjectOption":
|
|
54
|
+
case "LazyObjectSet":
|
|
55
|
+
case "LazyObject":
|
|
56
|
+
case "Option":
|
|
57
|
+
case "Set":
|
|
58
58
|
return false;
|
|
59
59
|
}
|
|
60
60
|
}
|
|
@@ -8,7 +8,7 @@ import type { SetType } from "./SetType.js";
|
|
|
8
8
|
* Abstract base class of LazyObjectOptionType, LazyObjectSetType, and LazyObjectType.
|
|
9
9
|
*/
|
|
10
10
|
export declare abstract class AbstractLazyObjectType<PartialTypeT extends AbstractLazyObjectType.PartialTypeConstraint, ResolveTypeT extends AbstractLazyObjectType.ResolveTypeConstraint> extends AbstractType {
|
|
11
|
-
abstract readonly kind: "
|
|
11
|
+
abstract readonly kind: "LazyObjectOption" | "LazyObjectSet" | "LazyObject";
|
|
12
12
|
readonly partialType: PartialTypeT;
|
|
13
13
|
readonly resolveType: ResolveTypeT;
|
|
14
14
|
constructor({ partialType, resolveType, ...superParameters }: {
|
|
@@ -11,7 +11,7 @@ import { AbstractType } from "./AbstractType.js";
|
|
|
11
11
|
export declare abstract class AbstractTermType<ConstantTermT extends Literal | NamedNode = Literal | NamedNode, _RuntimeTermT extends BlankNode | Literal | NamedNode = BlankNode | Literal | NamedNode> extends AbstractType {
|
|
12
12
|
readonly hasValues: readonly ConstantTermT[];
|
|
13
13
|
readonly in_: readonly ConstantTermT[];
|
|
14
|
-
abstract readonly kind: "
|
|
14
|
+
abstract readonly kind: "BlankNode" | "Identifier" | "Iri" | "Literal" | "Term";
|
|
15
15
|
readonly recursive = false;
|
|
16
16
|
constructor({ hasValues, in_, ...superParameters }: {
|
|
17
17
|
hasValues: readonly ConstantTermT[];
|
|
@@ -4,7 +4,7 @@ import { AbstractTermType } from "./AbstractTermType.js";
|
|
|
4
4
|
* A type corresponding to sh:nodeKind sh:BlankNode.
|
|
5
5
|
*/
|
|
6
6
|
export declare class BlankNodeType extends AbstractTermType<NamedNode, BlankNode> {
|
|
7
|
-
readonly kind = "
|
|
7
|
+
readonly kind = "BlankNode";
|
|
8
8
|
readonly nodeKinds: ReadonlySet<"BlankNode">;
|
|
9
9
|
constructor(superParameters: Omit<ConstructorParameters<typeof AbstractTermType<NamedNode, BlankNode>>[0], "hasValues" | "in_">);
|
|
10
10
|
}
|
|
@@ -3,7 +3,7 @@ import { AbstractTermType } from "./AbstractTermType.js";
|
|
|
3
3
|
* A type corresponding to sh:nodeKind sh:BlankNode.
|
|
4
4
|
*/
|
|
5
5
|
export class BlankNodeType extends AbstractTermType {
|
|
6
|
-
kind = "
|
|
6
|
+
kind = "BlankNode";
|
|
7
7
|
nodeKinds = nodeKinds;
|
|
8
8
|
constructor(superParameters) {
|
|
9
9
|
super({
|
|
@@ -12,7 +12,7 @@ import type { Type } from "./Type.js";
|
|
|
12
12
|
*/
|
|
13
13
|
export declare class DefaultValueType<ItemTypeT extends DefaultValueType.ItemType = DefaultValueType.ItemType> extends AbstractContainerType<ItemTypeT> {
|
|
14
14
|
readonly defaultValue: Literal | NamedNode;
|
|
15
|
-
readonly kind = "
|
|
15
|
+
readonly kind = "DefaultValue";
|
|
16
16
|
constructor({ defaultValue, itemType, }: Pick<ConstructorParameters<typeof AbstractContainerType<ItemTypeT>>[0], "itemType"> & {
|
|
17
17
|
defaultValue: Literal | NamedNode;
|
|
18
18
|
});
|
|
@@ -10,7 +10,7 @@ import { termEquals } from "./equals.js";
|
|
|
10
10
|
*/
|
|
11
11
|
export class DefaultValueType extends AbstractContainerType {
|
|
12
12
|
defaultValue;
|
|
13
|
-
kind = "
|
|
13
|
+
kind = "DefaultValue";
|
|
14
14
|
constructor({ defaultValue, itemType, }) {
|
|
15
15
|
super({
|
|
16
16
|
comment: itemType.comment,
|
|
@@ -39,7 +39,7 @@ export class DefaultValueType extends AbstractContainerType {
|
|
|
39
39
|
}
|
|
40
40
|
(function (DefaultValueType) {
|
|
41
41
|
function isItemType(type) {
|
|
42
|
-
if (type.kind === "
|
|
42
|
+
if (type.kind === "BlankNode") {
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
45
|
return AbstractContainerType.isItemType(type);
|
|
@@ -5,7 +5,7 @@ import { AbstractTermType } from "./AbstractTermType.js";
|
|
|
5
5
|
* A type corresponding to sh:nodeKind of a blank node or IRI, and not corresponding to a node shape.
|
|
6
6
|
*/
|
|
7
7
|
export declare class IdentifierType extends AbstractTermType<NamedNode, BlankNode | NamedNode> {
|
|
8
|
-
readonly kind = "
|
|
8
|
+
readonly kind = "Identifier";
|
|
9
9
|
readonly nodeKinds: ReadonlySet<IdentifierNodeKind>;
|
|
10
10
|
constructor(superParameters: Omit<ConstructorParameters<typeof AbstractTermType<NamedNode, BlankNode>>[0], "hasValues" | "in_">);
|
|
11
11
|
}
|
|
@@ -3,7 +3,7 @@ import { AbstractTermType } from "./AbstractTermType.js";
|
|
|
3
3
|
* A type corresponding to sh:nodeKind of a blank node or IRI, and not corresponding to a node shape.
|
|
4
4
|
*/
|
|
5
5
|
export class IdentifierType extends AbstractTermType {
|
|
6
|
-
kind = "
|
|
6
|
+
kind = "Identifier";
|
|
7
7
|
nodeKinds = nodeKinds;
|
|
8
8
|
constructor(superParameters) {
|
|
9
9
|
super({
|
|
@@ -4,7 +4,7 @@ import type { ObjectIntersectionType } from "./ObjectIntersectionType.js";
|
|
|
4
4
|
* A conjunction ("and") of types, corresponding to an sh:and.
|
|
5
5
|
*/
|
|
6
6
|
export declare class IntersectionType<MemberTypeT extends IntersectionType.MemberType = IntersectionType.MemberType> extends AbstractCompoundType<AbstractCompoundType.Member<MemberTypeT>, MemberTypeT> {
|
|
7
|
-
readonly kind = "
|
|
7
|
+
readonly kind = "Intersection";
|
|
8
8
|
isObjectIntersectionType(): this is ObjectIntersectionType;
|
|
9
9
|
}
|
|
10
10
|
export declare namespace IntersectionType {
|
|
@@ -3,11 +3,11 @@ import { AbstractCompoundType } from "./AbstractCompoundType.js";
|
|
|
3
3
|
* A conjunction ("and") of types, corresponding to an sh:and.
|
|
4
4
|
*/
|
|
5
5
|
export class IntersectionType extends AbstractCompoundType {
|
|
6
|
-
kind = "
|
|
6
|
+
kind = "Intersection";
|
|
7
7
|
isObjectIntersectionType() {
|
|
8
8
|
return (this.members.length > 0 &&
|
|
9
|
-
this.members.every((member) => member.type.kind === "
|
|
10
|
-
(member.type.kind === "
|
|
9
|
+
this.members.every((member) => member.type.kind === "Object" ||
|
|
10
|
+
(member.type.kind === "Intersection" &&
|
|
11
11
|
member.type.isObjectIntersectionType())));
|
|
12
12
|
}
|
|
13
13
|
}
|
package/dist/ast/IriType.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { AbstractTermType } from "./AbstractTermType.js";
|
|
|
4
4
|
* A type corresponding to sh:nodeKind sh:IRI.
|
|
5
5
|
*/
|
|
6
6
|
export declare class IriType extends AbstractTermType<NamedNode, NamedNode> {
|
|
7
|
-
readonly kind = "
|
|
7
|
+
readonly kind = "Iri";
|
|
8
8
|
readonly nodeKinds: ReadonlySet<"IRI">;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=IriType.d.ts.map
|
package/dist/ast/IriType.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
|
|
2
2
|
import type { OptionType } from "./OptionType.js";
|
|
3
3
|
export declare class LazyObjectOptionType extends AbstractLazyObjectType<OptionType<AbstractLazyObjectType.ObjectTypeConstraint>, OptionType<AbstractLazyObjectType.ObjectTypeConstraint>> {
|
|
4
|
-
readonly kind = "
|
|
4
|
+
readonly kind = "LazyObjectOption";
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=LazyObjectOptionType.d.ts.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
|
|
2
2
|
import type { SetType } from "./SetType.js";
|
|
3
3
|
export declare class LazyObjectSetType extends AbstractLazyObjectType<SetType<AbstractLazyObjectType.ObjectTypeConstraint>, SetType<AbstractLazyObjectType.ObjectTypeConstraint>> {
|
|
4
|
-
readonly kind = "
|
|
4
|
+
readonly kind = "LazyObjectSet";
|
|
5
5
|
}
|
|
6
6
|
//# sourceMappingURL=LazyObjectSetType.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
|
|
2
2
|
export declare class LazyObjectType extends AbstractLazyObjectType<AbstractLazyObjectType.ObjectTypeConstraint, AbstractLazyObjectType.ObjectTypeConstraint> {
|
|
3
|
-
readonly kind = "
|
|
3
|
+
readonly kind = "LazyObject";
|
|
4
4
|
}
|
|
5
5
|
//# sourceMappingURL=LazyObjectType.d.ts.map
|
package/dist/ast/ListType.d.ts
CHANGED
|
@@ -22,7 +22,7 @@ export declare class ListType<ItemTypeT extends ListType.ItemType = ListType.Ite
|
|
|
22
22
|
* Type of identifier (blank or named node) to use for lists and sub-lists.
|
|
23
23
|
*/
|
|
24
24
|
readonly identifierNodeKind: IdentifierNodeKind;
|
|
25
|
-
readonly kind = "
|
|
25
|
+
readonly kind = "List";
|
|
26
26
|
/**
|
|
27
27
|
* rdf:type's that will be added to this object when it's serialized toRdf.
|
|
28
28
|
*
|
package/dist/ast/ListType.js
CHANGED
|
@@ -11,7 +11,7 @@ export class ListType extends AbstractCollectionType {
|
|
|
11
11
|
* Type of identifier (blank or named node) to use for lists and sub-lists.
|
|
12
12
|
*/
|
|
13
13
|
identifierNodeKind;
|
|
14
|
-
kind = "
|
|
14
|
+
kind = "List";
|
|
15
15
|
/**
|
|
16
16
|
* rdf:type's that will be added to this object when it's serialized toRdf.
|
|
17
17
|
*
|
|
@@ -32,22 +32,22 @@ export class ListType extends AbstractCollectionType {
|
|
|
32
32
|
(function (ListType) {
|
|
33
33
|
function isItemType(type) {
|
|
34
34
|
switch (type.kind) {
|
|
35
|
-
case "
|
|
36
|
-
case "
|
|
37
|
-
case "
|
|
38
|
-
case "
|
|
39
|
-
case "
|
|
40
|
-
case "
|
|
41
|
-
case "
|
|
42
|
-
case "
|
|
35
|
+
case "BlankNode":
|
|
36
|
+
case "Identifier":
|
|
37
|
+
case "Intersection":
|
|
38
|
+
case "Iri":
|
|
39
|
+
case "Literal":
|
|
40
|
+
case "Object":
|
|
41
|
+
case "Term":
|
|
42
|
+
case "Union":
|
|
43
43
|
return true;
|
|
44
|
-
case "
|
|
45
|
-
case "
|
|
46
|
-
case "
|
|
47
|
-
case "
|
|
48
|
-
case "
|
|
49
|
-
case "
|
|
50
|
-
case "
|
|
44
|
+
case "DefaultValue":
|
|
45
|
+
case "LazyObjectOption":
|
|
46
|
+
case "LazyObjectSet":
|
|
47
|
+
case "LazyObject":
|
|
48
|
+
case "List":
|
|
49
|
+
case "Option":
|
|
50
|
+
case "Set":
|
|
51
51
|
return false;
|
|
52
52
|
}
|
|
53
53
|
}
|