@shaclmate/compiler 2.0.16 → 2.0.17
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/{Compiler.js → dist/Compiler.js} +2 -0
- package/{ShapesGraphToAstTransformer.js → dist/ShapesGraphToAstTransformer.js} +13 -11
- package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/transformNodeShapeToAstType.js +4 -2
- package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/transformPropertyShapeToAstType.js +2 -0
- package/{ast → dist/ast}/ListType.d.ts +1 -1
- package/dist/ast/SetType.d.ts +23 -0
- package/dist/enums/IdentifierMintingStrategy.d.ts +5 -0
- package/{generators → dist/generators}/index.d.ts +1 -0
- package/{generators → dist/generators}/index.js +1 -0
- package/{generators → dist/generators}/ts/BooleanType.js +1 -4
- package/{generators → dist/generators}/ts/DateTimeType.d.ts +4 -1
- package/{generators → dist/generators}/ts/DateTimeType.js +11 -10
- package/dist/generators/ts/DateType.d.ts +9 -0
- package/dist/generators/ts/DateType.js +11 -0
- package/{generators → dist/generators}/ts/DeclaredType.js +3 -0
- package/{generators → dist/generators}/ts/IdentifierType.js +1 -4
- package/{generators → dist/generators}/ts/ListType.d.ts +5 -4
- package/{generators → dist/generators}/ts/ListType.js +18 -7
- package/{generators → dist/generators}/ts/LiteralType.js +1 -0
- package/{generators → dist/generators}/ts/NumberType.js +1 -4
- package/{generators → dist/generators}/ts/ObjectType.d.ts +3 -3
- package/{generators → dist/generators}/ts/ObjectType.js +16 -3
- package/{generators → dist/generators}/ts/ObjectUnionType.js +5 -1
- package/{generators → dist/generators}/ts/OptionType.js +5 -2
- package/{generators → dist/generators}/ts/PrimitiveType.js +3 -1
- package/{generators → dist/generators}/ts/SetType.d.ts +3 -1
- package/{generators → dist/generators}/ts/SetType.js +16 -10
- package/{generators → dist/generators}/ts/StringType.js +1 -4
- package/{generators → dist/generators}/ts/TermType.js +9 -5
- package/{generators → dist/generators}/ts/Type.js +1 -0
- package/{generators → dist/generators}/ts/TypeFactory.js +9 -6
- package/{generators → dist/generators}/ts/UnionType.js +3 -1
- package/{generators → dist/generators}/ts/_ObjectType/IdentifierProperty.js +13 -8
- package/{generators → dist/generators}/ts/_ObjectType/Property.js +14 -0
- package/{generators → dist/generators}/ts/_ObjectType/ShaclProperty.js +5 -0
- package/{generators → dist/generators}/ts/_ObjectType/TypeDiscriminatorProperty.js +7 -2
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/{input → dist/input}/NodeShape.d.ts +1 -1
- package/{input → dist/input}/NodeShape.js +11 -4
- package/{input → dist/input}/Ontology.js +1 -0
- package/{input → dist/input}/PropertyShape.js +1 -0
- package/{input → dist/input}/generated.d.ts +2 -2
- package/{input → dist/input}/generated.js +10 -10
- package/package.json +28 -24
- package/ast/SetType.d.ts +0 -12
- package/enums/IdentifierMintingStrategy.d.ts +0 -5
- package/index.d.ts +0 -2
- package/index.js +0 -2
- /package/{Compiler.d.ts → dist/Compiler.d.ts} +0 -0
- /package/{ShapesGraphToAstTransformer.d.ts → dist/ShapesGraphToAstTransformer.d.ts} +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/NodeShapeAstType.d.ts +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/NodeShapeAstType.js +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/index.d.ts +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/index.js +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/pickLiteral.d.ts +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/pickLiteral.js +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/propertyShapeNodeKinds.d.ts +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/propertyShapeNodeKinds.js +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/shapeAstName.d.ts +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/shapeAstName.js +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/transformNodeShapeToAstType.d.ts +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/transformPropertyShapeToAstCompositeType.d.ts +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/transformPropertyShapeToAstCompositeType.js +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/transformPropertyShapeToAstIdentifierType.d.ts +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/transformPropertyShapeToAstIdentifierType.js +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/transformPropertyShapeToAstLiteralType.d.ts +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/transformPropertyShapeToAstLiteralType.js +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/transformPropertyShapeToAstObjectTypeProperty.d.ts +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/transformPropertyShapeToAstObjectTypeProperty.js +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/transformPropertyShapeToAstTermType.d.ts +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/transformPropertyShapeToAstTermType.js +0 -0
- /package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/transformPropertyShapeToAstType.d.ts +0 -0
- /package/{ast → dist/ast}/Ast.d.ts +0 -0
- /package/{ast → dist/ast}/Ast.js +0 -0
- /package/{ast → dist/ast}/CompositeType.d.ts +0 -0
- /package/{ast → dist/ast}/CompositeType.js +0 -0
- /package/{ast → dist/ast}/IdentifierType.d.ts +0 -0
- /package/{ast → dist/ast}/IdentifierType.js +0 -0
- /package/{ast → dist/ast}/IntersectionType.d.ts +0 -0
- /package/{ast → dist/ast}/IntersectionType.js +0 -0
- /package/{ast → dist/ast}/ListType.js +0 -0
- /package/{ast → dist/ast}/LiteralType.d.ts +0 -0
- /package/{ast → dist/ast}/LiteralType.js +0 -0
- /package/{ast → dist/ast}/Name.d.ts +0 -0
- /package/{ast → dist/ast}/Name.js +0 -0
- /package/{ast → dist/ast}/ObjectCompositeType.d.ts +0 -0
- /package/{ast → dist/ast}/ObjectCompositeType.js +0 -0
- /package/{ast → dist/ast}/ObjectIntersectionType.d.ts +0 -0
- /package/{ast → dist/ast}/ObjectIntersectionType.js +0 -0
- /package/{ast → dist/ast}/ObjectType.d.ts +0 -0
- /package/{ast → dist/ast}/ObjectType.js +0 -0
- /package/{ast → dist/ast}/ObjectUnionType.d.ts +0 -0
- /package/{ast → dist/ast}/ObjectUnionType.js +0 -0
- /package/{ast → dist/ast}/OptionType.d.ts +0 -0
- /package/{ast → dist/ast}/OptionType.js +0 -0
- /package/{ast → dist/ast}/PlaceholderType.d.ts +0 -0
- /package/{ast → dist/ast}/PlaceholderType.js +0 -0
- /package/{ast → dist/ast}/SetType.js +0 -0
- /package/{ast → dist/ast}/TermType.d.ts +0 -0
- /package/{ast → dist/ast}/TermType.js +0 -0
- /package/{ast → dist/ast}/Type.d.ts +0 -0
- /package/{ast → dist/ast}/Type.js +0 -0
- /package/{ast → dist/ast}/UnionType.d.ts +0 -0
- /package/{ast → dist/ast}/UnionType.js +0 -0
- /package/{ast → dist/ast}/index.d.ts +0 -0
- /package/{ast → dist/ast}/index.js +0 -0
- /package/{enums → dist/enums}/IdentifierMintingStrategy.js +0 -0
- /package/{enums → dist/enums}/PropertyVisibility.d.ts +0 -0
- /package/{enums → dist/enums}/PropertyVisibility.js +0 -0
- /package/{enums → dist/enums}/TsFeature.d.ts +0 -0
- /package/{enums → dist/enums}/TsFeature.js +0 -0
- /package/{enums → dist/enums}/TsObjectDeclarationType.d.ts +0 -0
- /package/{enums → dist/enums}/TsObjectDeclarationType.js +0 -0
- /package/{enums → dist/enums}/index.d.ts +0 -0
- /package/{enums → dist/enums}/index.js +0 -0
- /package/{generators → dist/generators}/Generator.d.ts +0 -0
- /package/{generators → dist/generators}/Generator.js +0 -0
- /package/{generators → dist/generators}/json/AstJsonGenerator.d.ts +0 -0
- /package/{generators → dist/generators}/json/AstJsonGenerator.js +0 -0
- /package/{generators → dist/generators}/json/index.d.ts +0 -0
- /package/{generators → dist/generators}/json/index.js +0 -0
- /package/{generators → dist/generators}/ts/BooleanType.d.ts +0 -0
- /package/{generators → dist/generators}/ts/DeclaredType.d.ts +0 -0
- /package/{generators → dist/generators}/ts/IdentifierType.d.ts +0 -0
- /package/{generators → dist/generators}/ts/Import.d.ts +0 -0
- /package/{generators → dist/generators}/ts/Import.js +0 -0
- /package/{generators → dist/generators}/ts/LiteralType.d.ts +0 -0
- /package/{generators → dist/generators}/ts/NumberType.d.ts +0 -0
- /package/{generators → dist/generators}/ts/ObjectUnionType.d.ts +0 -0
- /package/{generators → dist/generators}/ts/OptionType.d.ts +0 -0
- /package/{generators → dist/generators}/ts/PrimitiveType.d.ts +0 -0
- /package/{generators → dist/generators}/ts/SnippetDeclarations.d.ts +0 -0
- /package/{generators → dist/generators}/ts/SnippetDeclarations.js +0 -0
- /package/{generators → dist/generators}/ts/StringType.d.ts +0 -0
- /package/{generators → dist/generators}/ts/TermType.d.ts +0 -0
- /package/{generators → dist/generators}/ts/TsGenerator.d.ts +0 -0
- /package/{generators → dist/generators}/ts/TsGenerator.js +0 -0
- /package/{generators → dist/generators}/ts/Type.d.ts +0 -0
- /package/{generators → dist/generators}/ts/TypeFactory.d.ts +0 -0
- /package/{generators → dist/generators}/ts/UnionType.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/IdentifierProperty.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/Property.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/ShaclProperty.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/classDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/classDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/createFunctionDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/createFunctionDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/equalsFunctionDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/equalsFunctionDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/equalsFunctionOrMethodDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/fromJsonFunctionDeclarations.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/fromJsonFunctionDeclarations.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/fromRdfFunctionDeclarations.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/fromRdfFunctionDeclarations.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/fromRdfTypeVariableStatement.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/fromRdfTypeVariableStatement.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/hashFunctionDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/hashFunctionDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/hashFunctionOrMethodDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/hashFunctionOrMethodDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/index.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/index.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/interfaceDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/interfaceDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/jsonSchemaFunctionDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/jsonSchemaFunctionDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/rdfjsTermExpression.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/rdfjsTermExpression.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/sparqlFunctionDeclarations.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/sparqlFunctionDeclarations.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/toJsonFunctionDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/toJsonFunctionDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/toJsonReturnType.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/toJsonReturnType.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/toRdfFunctionDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/toRdfFunctionDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.d.ts +0 -0
- /package/{generators → dist/generators}/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +0 -0
- /package/{generators → dist/generators}/ts/index.d.ts +0 -0
- /package/{generators → dist/generators}/ts/index.js +0 -0
- /package/{generators → dist/generators}/ts/objectInitializer.d.ts +0 -0
- /package/{generators → dist/generators}/ts/objectInitializer.js +0 -0
- /package/{generators → dist/generators}/ts/stringToValidTsIdentifier.d.ts +0 -0
- /package/{generators → dist/generators}/ts/stringToValidTsIdentifier.js +0 -0
- /package/{generators → dist/generators}/ts/tsComment.d.ts +0 -0
- /package/{generators → dist/generators}/ts/tsComment.js +0 -0
- /package/{generators → dist/generators}/ts/tsName.d.ts +0 -0
- /package/{generators → dist/generators}/ts/tsName.js +0 -0
- /package/{input → dist/input}/Ontology.d.ts +0 -0
- /package/{input → dist/input}/PropertyShape.d.ts +0 -0
- /package/{input → dist/input}/Shape.d.ts +0 -0
- /package/{input → dist/input}/Shape.js +0 -0
- /package/{input → dist/input}/ShapesGraph.d.ts +0 -0
- /package/{input → dist/input}/ShapesGraph.js +0 -0
- /package/{input → dist/input}/ancestorClassIris.d.ts +0 -0
- /package/{input → dist/input}/ancestorClassIris.js +0 -0
- /package/{input → dist/input}/descendantClassIris.d.ts +0 -0
- /package/{input → dist/input}/descendantClassIris.js +0 -0
- /package/{input → dist/input}/index.d.ts +0 -0
- /package/{input → dist/input}/index.js +0 -0
- /package/{input → dist/input}/tsFeatures.d.ts +0 -0
- /package/{input → dist/input}/tsFeatures.js +0 -0
- /package/{logger.d.ts → dist/logger.d.ts} +0 -0
- /package/{logger.js → dist/logger.js} +0 -0
|
@@ -6,6 +6,7 @@ import { fromRdf } from "rdf-literal";
|
|
|
6
6
|
import { logger } from "../../logger.js";
|
|
7
7
|
import { BooleanType } from "./BooleanType.js";
|
|
8
8
|
import { DateTimeType } from "./DateTimeType.js";
|
|
9
|
+
import { DateType } from "./DateType.js";
|
|
9
10
|
import { IdentifierType } from "./IdentifierType.js";
|
|
10
11
|
import { ListType } from "./ListType.js";
|
|
11
12
|
import { LiteralType } from "./LiteralType.js";
|
|
@@ -19,9 +20,10 @@ import { TermType } from "./TermType.js";
|
|
|
19
20
|
import { UnionType } from "./UnionType.js";
|
|
20
21
|
import { tsName } from "./tsName.js";
|
|
21
22
|
export class TypeFactory {
|
|
23
|
+
cachedObjectTypePropertiesByIdentifier = new TermMap();
|
|
24
|
+
cachedObjectTypesByIdentifier = new TermMap();
|
|
25
|
+
dataFactoryVariable;
|
|
22
26
|
constructor({ dataFactoryVariable }) {
|
|
23
|
-
this.cachedObjectTypePropertiesByIdentifier = new TermMap();
|
|
24
|
-
this.cachedObjectTypesByIdentifier = new TermMap();
|
|
25
27
|
this.dataFactoryVariable = dataFactoryVariable;
|
|
26
28
|
}
|
|
27
29
|
createTypeFromAstType(astType) {
|
|
@@ -42,7 +44,7 @@ export class TypeFactory {
|
|
|
42
44
|
identifierNodeKind: astType.identifierNodeKind,
|
|
43
45
|
itemType: this.createTypeFromAstType(astType.itemType),
|
|
44
46
|
mutable: astType.mutable.orDefault(false),
|
|
45
|
-
|
|
47
|
+
identifierMintingStrategy: astType.identifierMintingStrategy,
|
|
46
48
|
toRdfTypes: astType.toRdfTypes,
|
|
47
49
|
});
|
|
48
50
|
}
|
|
@@ -76,8 +78,8 @@ export class TypeFactory {
|
|
|
76
78
|
.filter((value) => typeof value === "boolean"),
|
|
77
79
|
});
|
|
78
80
|
}
|
|
79
|
-
if (datatype.equals(xsd.dateTime)) {
|
|
80
|
-
return new DateTimeType({
|
|
81
|
+
if (datatype.equals(xsd.date) || datatype.equals(xsd.dateTime)) {
|
|
82
|
+
return new (datatype.equals(xsd.date) ? DateType : DateTimeType)({
|
|
81
83
|
dataFactoryVariable: this.dataFactoryVariable,
|
|
82
84
|
defaultValue: astType.defaultValue,
|
|
83
85
|
hasValues: astType.hasValues,
|
|
@@ -186,6 +188,7 @@ export class TypeFactory {
|
|
|
186
188
|
return new SetType({
|
|
187
189
|
dataFactoryVariable: this.dataFactoryVariable,
|
|
188
190
|
itemType: this.createTypeFromAstType(astType.itemType),
|
|
191
|
+
mutable: astType.mutable.orDefault(false),
|
|
189
192
|
minCount: astType.minCount,
|
|
190
193
|
});
|
|
191
194
|
case "TermType":
|
|
@@ -295,7 +298,7 @@ export class TypeFactory {
|
|
|
295
298
|
}
|
|
296
299
|
return properties.sort((left, right) => left.name.localeCompare(right.name));
|
|
297
300
|
},
|
|
298
|
-
|
|
301
|
+
identifierMintingStrategy: astType.identifierMintingStrategy,
|
|
299
302
|
name: tsName(astType.name),
|
|
300
303
|
toRdfTypes: astType.toRdfTypes,
|
|
301
304
|
});
|
|
@@ -10,13 +10,15 @@ import { Memoize } from "typescript-memoize";
|
|
|
10
10
|
import { Type } from "./Type.js";
|
|
11
11
|
import { objectInitializer } from "./objectInitializer.js";
|
|
12
12
|
export class UnionType extends Type {
|
|
13
|
+
kind = "UnionType";
|
|
14
|
+
memberTypes;
|
|
13
15
|
constructor({ memberTypes, name, ...superParameters }) {
|
|
14
16
|
super(superParameters);
|
|
15
|
-
this.kind = "UnionType";
|
|
16
17
|
invariant(memberTypes.length >= 2);
|
|
17
18
|
this.memberTypes = memberTypes;
|
|
18
19
|
this._name = name;
|
|
19
20
|
}
|
|
21
|
+
_name;
|
|
20
22
|
get name() {
|
|
21
23
|
if (typeof this._name === "undefined") {
|
|
22
24
|
switch (this._discriminatorProperty.kind) {
|
|
@@ -5,10 +5,15 @@ import { Import } from "../Import.js";
|
|
|
5
5
|
import { SnippetDeclarations } from "../SnippetDeclarations.js";
|
|
6
6
|
import { Property } from "./Property.js";
|
|
7
7
|
export class IdentifierProperty extends Property {
|
|
8
|
+
abstract;
|
|
9
|
+
equalsFunction = "booleanEquals";
|
|
10
|
+
mutable = false;
|
|
11
|
+
classDeclarationVisibility;
|
|
12
|
+
identifierMintingStrategy;
|
|
13
|
+
lazyObjectTypeMutable;
|
|
14
|
+
override;
|
|
8
15
|
constructor({ abstract, classDeclarationVisibility, lazyObjectTypeMutable, identifierMintingStrategy, override, ...superParameters }) {
|
|
9
16
|
super(superParameters);
|
|
10
|
-
this.equalsFunction = "booleanEquals";
|
|
11
|
-
this.mutable = false;
|
|
12
17
|
invariant(this.visibility === "public");
|
|
13
18
|
this.abstract = abstract;
|
|
14
19
|
this.classDeclarationVisibility = classDeclarationVisibility;
|
|
@@ -162,14 +167,14 @@ export class IdentifierProperty extends Property {
|
|
|
162
167
|
}
|
|
163
168
|
const statements = [];
|
|
164
169
|
for (const conversion of this.type.conversions) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
170
|
+
invariant(conversion.sourceTypeName !== "undefined");
|
|
171
|
+
statements.push(`if (${conversion.sourceTypeCheckExpression(variables.parameter)}) { this.${classPropertyDeclaration.name} = ${conversion.conversionExpression(variables.parameter)}; }`);
|
|
168
172
|
}
|
|
169
|
-
if (
|
|
170
|
-
|
|
171
|
-
statements.push(`{ this.${classPropertyDeclaration.name} =( ${variables.parameter}) as never;\n }`);
|
|
173
|
+
if (classPropertyDeclaration.name.startsWith("_")) {
|
|
174
|
+
statements.push(`if (typeof ${variables.parameter} === "undefined") { }`);
|
|
172
175
|
}
|
|
176
|
+
// We shouldn't need this else, since the parameter now has the never type, but have to add it to appease the TypeScript compiler
|
|
177
|
+
statements.push(`{ this.${classPropertyDeclaration.name} =( ${variables.parameter}) as never;\n }`);
|
|
173
178
|
return [statements.join(" else ")];
|
|
174
179
|
}
|
|
175
180
|
fromJsonStatements({ variables, }) {
|
|
@@ -1,6 +1,20 @@
|
|
|
1
1
|
import { Scope, } from "ts-morph";
|
|
2
2
|
import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
|
|
3
3
|
export class Property {
|
|
4
|
+
/**
|
|
5
|
+
* TypeScript identifier-safe name of the property.
|
|
6
|
+
*/
|
|
7
|
+
name;
|
|
8
|
+
/**
|
|
9
|
+
* Property type
|
|
10
|
+
. */
|
|
11
|
+
type;
|
|
12
|
+
/**
|
|
13
|
+
* Property visibility: private, protected, public.
|
|
14
|
+
*/
|
|
15
|
+
visibility;
|
|
16
|
+
dataFactoryVariable;
|
|
17
|
+
objectType;
|
|
4
18
|
constructor({ dataFactoryVariable, name, objectType, type, visibility, }) {
|
|
5
19
|
this.dataFactoryVariable = dataFactoryVariable;
|
|
6
20
|
this.name = name;
|
|
@@ -10,6 +10,11 @@ import { Memoize } from "typescript-memoize";
|
|
|
10
10
|
import { tsComment } from "../tsComment.js";
|
|
11
11
|
import { Property } from "./Property.js";
|
|
12
12
|
export class ShaclProperty extends Property {
|
|
13
|
+
mutable;
|
|
14
|
+
comment;
|
|
15
|
+
description;
|
|
16
|
+
label;
|
|
17
|
+
path;
|
|
13
18
|
constructor({ comment, description, label, mutable, path, ...superParameters }) {
|
|
14
19
|
super(superParameters);
|
|
15
20
|
this.comment = comment;
|
|
@@ -10,10 +10,13 @@ import { Memoize } from "typescript-memoize";
|
|
|
10
10
|
import { SnippetDeclarations } from "../SnippetDeclarations.js";
|
|
11
11
|
import { Property } from "./Property.js";
|
|
12
12
|
export class TypeDiscriminatorProperty extends Property {
|
|
13
|
+
equalsFunction = "strictEquals";
|
|
14
|
+
mutable = false;
|
|
15
|
+
value;
|
|
16
|
+
abstract;
|
|
17
|
+
override;
|
|
13
18
|
constructor({ abstract, override, type, value, ...superParameters }) {
|
|
14
19
|
super({ ...superParameters, type });
|
|
15
|
-
this.equalsFunction = "strictEquals";
|
|
16
|
-
this.mutable = false;
|
|
17
20
|
invariant(this.visibility === "public");
|
|
18
21
|
this.abstract = abstract;
|
|
19
22
|
this.override = override;
|
|
@@ -106,6 +109,8 @@ export class TypeDiscriminatorProperty extends Property {
|
|
|
106
109
|
}
|
|
107
110
|
(function (TypeDiscriminatorProperty) {
|
|
108
111
|
class Type {
|
|
112
|
+
mutable;
|
|
113
|
+
values;
|
|
109
114
|
constructor({ mutable, values, }) {
|
|
110
115
|
this.mutable = mutable;
|
|
111
116
|
this.values = values;
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -30,7 +30,7 @@ export declare class NodeShape extends ShaclCoreNodeShape<any, Ontology, Propert
|
|
|
30
30
|
get export(): Maybe<boolean>;
|
|
31
31
|
get extern(): Maybe<boolean>;
|
|
32
32
|
get fromRdfType(): Maybe<NamedNode>;
|
|
33
|
-
get
|
|
33
|
+
get identifierMintingStrategy(): Maybe<IdentifierMintingStrategy>;
|
|
34
34
|
get mutable(): Maybe<boolean>;
|
|
35
35
|
get nodeKinds(): Set<"BlankNode" | "NamedNode">;
|
|
36
36
|
get parentNodeShapes(): readonly NodeShape[];
|
|
@@ -2,6 +2,13 @@ import { NodeShape as ShaclCoreNodeShape } from "@shaclmate/shacl-ast";
|
|
|
2
2
|
import { Maybe } from "purify-ts";
|
|
3
3
|
import { tsFeatures } from "./tsFeatures.js";
|
|
4
4
|
export class NodeShape extends ShaclCoreNodeShape {
|
|
5
|
+
isClass;
|
|
6
|
+
isList;
|
|
7
|
+
ancestorClassIris;
|
|
8
|
+
childClassIris;
|
|
9
|
+
descendantClassIris;
|
|
10
|
+
generatedShaclmateNodeShape;
|
|
11
|
+
parentClassIris;
|
|
5
12
|
constructor({ ancestorClassIris, childClassIris, descendantClassIris, generatedShaclmateNodeShape, isClass, isList, parentClassIris, shapesGraph, }) {
|
|
6
13
|
super(generatedShaclmateNodeShape, shapesGraph);
|
|
7
14
|
this.ancestorClassIris = ancestorClassIris;
|
|
@@ -51,7 +58,7 @@ export class NodeShape extends ShaclCoreNodeShape {
|
|
|
51
58
|
}
|
|
52
59
|
return Maybe.empty();
|
|
53
60
|
}
|
|
54
|
-
get
|
|
61
|
+
get identifierMintingStrategy() {
|
|
55
62
|
const thisMintingStrategy = this._mintingStrategy;
|
|
56
63
|
if (thisMintingStrategy.isNothing()) {
|
|
57
64
|
for (const ancestorNodeShape of this.ancestorNodeShapes) {
|
|
@@ -150,11 +157,11 @@ export class NodeShape extends ShaclCoreNodeShape {
|
|
|
150
157
|
.tsObjectTypeDiscriminatorPropertyName;
|
|
151
158
|
}
|
|
152
159
|
get _mintingStrategy() {
|
|
153
|
-
return this.generatedShaclmateNodeShape.
|
|
160
|
+
return this.generatedShaclmateNodeShape.identifierMintingStrategy.map((iri) => {
|
|
154
161
|
switch (iri.value) {
|
|
155
|
-
case "http://minorg.github.io/shaclmate/ns#
|
|
162
|
+
case "http://minorg.github.io/shaclmate/ns#_IdentifierMintingStrategy_SHA256":
|
|
156
163
|
return "sha256";
|
|
157
|
-
case "http://minorg.github.io/shaclmate/ns#
|
|
164
|
+
case "http://minorg.github.io/shaclmate/ns#_IdentifierMintingStrategy_UUIDv4":
|
|
158
165
|
return "uuidv4";
|
|
159
166
|
default:
|
|
160
167
|
throw new RangeError(iri.value);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Ontology as OwlOntology } from "@shaclmate/shacl-ast";
|
|
2
2
|
import { tsFeatures } from "./tsFeatures.js";
|
|
3
3
|
export class Ontology extends OwlOntology {
|
|
4
|
+
generatedShaclmateOntology;
|
|
4
5
|
constructor(generatedShaclmateOntology) {
|
|
5
6
|
super(generatedShaclmateOntology);
|
|
6
7
|
this.generatedShaclmateOntology = generatedShaclmateOntology;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PropertyShape as ShaclCorePropertyShape } from "@shaclmate/shacl-ast";
|
|
2
2
|
import { Maybe } from "purify-ts";
|
|
3
3
|
export class PropertyShape extends ShaclCorePropertyShape {
|
|
4
|
+
generatedShaclmatePropertyShape;
|
|
4
5
|
constructor(generatedShaclmatePropertyShape, shapesGraph) {
|
|
5
6
|
super({ ...generatedShaclmatePropertyShape, uniqueLang: Maybe.empty() }, shapesGraph);
|
|
6
7
|
this.generatedShaclmatePropertyShape = generatedShaclmatePropertyShape;
|
|
@@ -202,7 +202,7 @@ export interface ShaclmateNodeShape extends ShaclCoreNodeShape {
|
|
|
202
202
|
readonly extern: purify.Maybe<boolean>;
|
|
203
203
|
readonly fromRdfType: purify.Maybe<rdfjs.NamedNode>;
|
|
204
204
|
readonly identifier: rdfjs.BlankNode | rdfjs.NamedNode;
|
|
205
|
-
readonly
|
|
205
|
+
readonly identifierMintingStrategy: purify.Maybe<rdfjs.NamedNode<"http://minorg.github.io/shaclmate/ns#_IdentifierMintingStrategy_SHA256" | "http://minorg.github.io/shaclmate/ns#_IdentifierMintingStrategy_UUIDv4">>;
|
|
206
206
|
readonly mutable: purify.Maybe<boolean>;
|
|
207
207
|
readonly name: purify.Maybe<string>;
|
|
208
208
|
readonly toRdfTypes: readonly rdfjs.NamedNode[];
|
|
@@ -226,7 +226,7 @@ export declare namespace ShaclmateNodeShape {
|
|
|
226
226
|
extern: purify.Maybe<boolean>;
|
|
227
227
|
fromRdfType: purify.Maybe<rdfjs.NamedNode>;
|
|
228
228
|
identifier: rdfjs.BlankNode | rdfjs.NamedNode;
|
|
229
|
-
|
|
229
|
+
identifierMintingStrategy: purify.Maybe<rdfjs.NamedNode<"http://minorg.github.io/shaclmate/ns#_IdentifierMintingStrategy_SHA256" | "http://minorg.github.io/shaclmate/ns#_IdentifierMintingStrategy_UUIDv4">>;
|
|
230
230
|
mutable: purify.Maybe<boolean>;
|
|
231
231
|
name: purify.Maybe<string>;
|
|
232
232
|
toRdfTypes: readonly rdfjs.NamedNode[];
|
|
@@ -1126,29 +1126,29 @@ export var ShaclmateNodeShape;
|
|
|
1126
1126
|
}
|
|
1127
1127
|
const fromRdfType = _fromRdfTypeEither.unsafeCoerce();
|
|
1128
1128
|
const identifier = _resource.identifier;
|
|
1129
|
-
const
|
|
1130
|
-
.values(dataFactory.namedNode("http://minorg.github.io/shaclmate/ns#
|
|
1129
|
+
const _identifierMintingStrategyEither = purify.Either.of(_resource
|
|
1130
|
+
.values(dataFactory.namedNode("http://minorg.github.io/shaclmate/ns#identifierMintingStrategy"), { unique: true })
|
|
1131
1131
|
.head()
|
|
1132
1132
|
.chain((_value) => _value.toIri().chain((iri) => {
|
|
1133
1133
|
switch (iri.value) {
|
|
1134
|
-
case "http://minorg.github.io/shaclmate/ns#
|
|
1134
|
+
case "http://minorg.github.io/shaclmate/ns#_IdentifierMintingStrategy_SHA256":
|
|
1135
1135
|
return purify.Either.of(iri);
|
|
1136
|
-
case "http://minorg.github.io/shaclmate/ns#
|
|
1136
|
+
case "http://minorg.github.io/shaclmate/ns#_IdentifierMintingStrategy_UUIDv4":
|
|
1137
1137
|
return purify.Either.of(iri);
|
|
1138
1138
|
default:
|
|
1139
1139
|
return purify.Left(new rdfjsResource.Resource.MistypedValueError({
|
|
1140
1140
|
actualValue: iri,
|
|
1141
|
-
expectedValueType: 'rdfjs.NamedNode<"http://minorg.github.io/shaclmate/ns#
|
|
1141
|
+
expectedValueType: 'rdfjs.NamedNode<"http://minorg.github.io/shaclmate/ns#_IdentifierMintingStrategy_SHA256" | "http://minorg.github.io/shaclmate/ns#_IdentifierMintingStrategy_UUIDv4">',
|
|
1142
1142
|
focusResource: _resource,
|
|
1143
|
-
predicate: dataFactory.namedNode("http://minorg.github.io/shaclmate/ns#
|
|
1143
|
+
predicate: dataFactory.namedNode("http://minorg.github.io/shaclmate/ns#identifierMintingStrategy"),
|
|
1144
1144
|
}));
|
|
1145
1145
|
}
|
|
1146
1146
|
}))
|
|
1147
1147
|
.toMaybe());
|
|
1148
|
-
if (
|
|
1149
|
-
return
|
|
1148
|
+
if (_identifierMintingStrategyEither.isLeft()) {
|
|
1149
|
+
return _identifierMintingStrategyEither;
|
|
1150
1150
|
}
|
|
1151
|
-
const
|
|
1151
|
+
const identifierMintingStrategy = _identifierMintingStrategyEither.unsafeCoerce();
|
|
1152
1152
|
const _mutableEither = purify.Either.of(_resource
|
|
1153
1153
|
.values(dataFactory.namedNode("http://minorg.github.io/shaclmate/ns#mutable"), { unique: true })
|
|
1154
1154
|
.head()
|
|
@@ -1348,7 +1348,7 @@ export var ShaclmateNodeShape;
|
|
|
1348
1348
|
extern,
|
|
1349
1349
|
fromRdfType,
|
|
1350
1350
|
identifier,
|
|
1351
|
-
|
|
1351
|
+
identifierMintingStrategy,
|
|
1352
1352
|
mutable,
|
|
1353
1353
|
name,
|
|
1354
1354
|
toRdfTypes,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@shaclmate/shacl-ast": "2.0.
|
|
3
|
+
"@shaclmate/shacl-ast": "2.0.17",
|
|
4
4
|
"@rdfjs/prefix-map": "^0.1.2",
|
|
5
5
|
"@rdfjs/term-map": "^2.0.2",
|
|
6
6
|
"@rdfjs/term-set": "^2.0.3",
|
|
@@ -20,30 +20,35 @@
|
|
|
20
20
|
"typescript-memoize": "^1.1.1"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@shaclmate/runtime": "2.0.
|
|
23
|
+
"@shaclmate/runtime": "2.0.17",
|
|
24
24
|
"oxigraph": "^0.4.0"
|
|
25
25
|
},
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"types": "./dist/index.d.ts",
|
|
29
|
+
"default": "./dist/index.js"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
26
32
|
"files": [
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"_ShapesGraphToAstTransformer/*.d.ts",
|
|
30
|
-
"_ShapesGraphToAstTransformer/*.js",
|
|
31
|
-
"ast/*.d.ts",
|
|
32
|
-
"ast/*.js",
|
|
33
|
-
"enums/*.d.ts",
|
|
34
|
-
"enums/*.js",
|
|
35
|
-
"generators/*.d.ts",
|
|
36
|
-
"generators/*.js",
|
|
37
|
-
"generators/json/*.d.ts",
|
|
38
|
-
"generators/json/*.js",
|
|
39
|
-
"generators/ts/*.d.ts",
|
|
40
|
-
"generators/ts/*.js",
|
|
41
|
-
"generators/ts/_ObjectType/*.d.ts",
|
|
42
|
-
"generators/ts/_ObjectType/*.js",
|
|
43
|
-
"input/*.d.ts",
|
|
44
|
-
"input/*.js"
|
|
33
|
+
"dist/*.d.ts",
|
|
34
|
+
"dist/*.js",
|
|
35
|
+
"dist/_ShapesGraphToAstTransformer/*.d.ts",
|
|
36
|
+
"dist/_ShapesGraphToAstTransformer/*.js",
|
|
37
|
+
"dist/ast/*.d.ts",
|
|
38
|
+
"dist/ast/*.js",
|
|
39
|
+
"dist/enums/*.d.ts",
|
|
40
|
+
"dist/enums/*.js",
|
|
41
|
+
"dist/generators/*.d.ts",
|
|
42
|
+
"dist/generators/*.js",
|
|
43
|
+
"dist/generators/json/*.d.ts",
|
|
44
|
+
"dist/generators/json/*.js",
|
|
45
|
+
"dist/generators/ts/*.d.ts",
|
|
46
|
+
"dist/generators/ts/*.js",
|
|
47
|
+
"dist/generators/ts/_ObjectType/*.d.ts",
|
|
48
|
+
"dist/generators/ts/_ObjectType/*.js",
|
|
49
|
+
"dist/input/*.d.ts",
|
|
50
|
+
"dist/input/*.js"
|
|
45
51
|
],
|
|
46
|
-
"main": "index.js",
|
|
47
52
|
"license": "Apache-2.0",
|
|
48
53
|
"name": "@shaclmate/compiler",
|
|
49
54
|
"scripts": {
|
|
@@ -51,7 +56,7 @@
|
|
|
51
56
|
"check": "biome check",
|
|
52
57
|
"check:write": "biome check --write",
|
|
53
58
|
"check:write:unsafe": "biome check --write --unsafe",
|
|
54
|
-
"clean": "rimraf
|
|
59
|
+
"clean": "rimraf dist",
|
|
55
60
|
"format": "biome format",
|
|
56
61
|
"format:write": "biome format --write",
|
|
57
62
|
"format:write:unsafe": "biome format --write --unsafe",
|
|
@@ -72,6 +77,5 @@
|
|
|
72
77
|
"url": "git+https://github.com/minorg/shaclmate"
|
|
73
78
|
},
|
|
74
79
|
"type": "module",
|
|
75
|
-
"
|
|
76
|
-
"version": "2.0.16"
|
|
80
|
+
"version": "2.0.17"
|
|
77
81
|
}
|
package/ast/SetType.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { Type } from "./Type.js";
|
|
2
|
-
/**
|
|
3
|
-
* An unordered set of items of a specific type.
|
|
4
|
-
*
|
|
5
|
-
* This is a property with sh:maxCount != 1.
|
|
6
|
-
*/
|
|
7
|
-
export interface SetType {
|
|
8
|
-
readonly itemType: Type;
|
|
9
|
-
readonly kind: "SetType";
|
|
10
|
-
readonly minCount: number;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=SetType.d.ts.map
|
package/index.d.ts
DELETED
package/index.js
DELETED
|
File without changes
|
|
File without changes
|
/package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/NodeShapeAstType.d.ts
RENAMED
|
File without changes
|
/package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/NodeShapeAstType.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/pickLiteral.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{_ShapesGraphToAstTransformer → dist/_ShapesGraphToAstTransformer}/shapeAstName.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{ast → dist/ast}/Ast.js
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|