@shaclmate/compiler 2.0.13 → 2.0.15
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.d.ts +15 -0
- package/Compiler.js +20 -0
- package/ShapesGraphToAstTransformer.d.ts +18 -23
- package/ShapesGraphToAstTransformer.js +21 -447
- package/_ShapesGraphToAstTransformer/NodeShapeAstType.d.ts +3 -0
- package/_ShapesGraphToAstTransformer/NodeShapeAstType.js +2 -0
- package/_ShapesGraphToAstTransformer/index.d.ts +10 -0
- package/_ShapesGraphToAstTransformer/index.js +10 -0
- package/_ShapesGraphToAstTransformer/pickLiteral.d.ts +4 -0
- package/_ShapesGraphToAstTransformer/pickLiteral.js +18 -0
- package/_ShapesGraphToAstTransformer/propertyShapeNodeKinds.d.ts +4 -0
- package/_ShapesGraphToAstTransformer/propertyShapeNodeKinds.js +26 -0
- package/_ShapesGraphToAstTransformer/shapeAstName.d.ts +5 -0
- package/_ShapesGraphToAstTransformer/shapeAstName.js +28 -0
- package/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +6 -0
- package/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +178 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.d.ts +13 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.js +200 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.d.ts +12 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.js +29 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.d.ts +12 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.js +43 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.d.ts +6 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +31 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.d.ts +14 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.js +21 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.d.ts +16 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.js +58 -0
- package/ast/Ast.d.ts +5 -0
- package/ast/CompositeType.d.ts +13 -0
- package/ast/CompositeType.js +2 -0
- package/ast/IdentifierType.d.ts +3 -6
- package/ast/IntersectionType.d.ts +2 -2
- package/ast/ListType.d.ts +53 -0
- package/ast/ListType.js +2 -0
- package/ast/LiteralType.d.ts +4 -3
- package/ast/Name.d.ts +1 -0
- package/ast/ObjectCompositeType.d.ts +22 -0
- package/ast/ObjectCompositeType.js +2 -0
- package/ast/ObjectIntersectionType.d.ts +8 -0
- package/ast/ObjectIntersectionType.js +2 -0
- package/ast/ObjectType.d.ts +91 -19
- package/ast/ObjectType.js +26 -1
- package/ast/ObjectUnionType.d.ts +19 -0
- package/ast/ObjectUnionType.js +2 -0
- package/ast/PlaceholderType.d.ts +7 -0
- package/ast/PlaceholderType.js +2 -0
- package/ast/SetType.d.ts +1 -1
- package/ast/TermType.d.ts +11 -0
- package/ast/TermType.js +2 -0
- package/ast/Type.d.ts +11 -3
- package/ast/UnionType.d.ts +3 -3
- package/ast/index.d.ts +6 -3
- package/ast/index.js +6 -3
- package/enums/MintingStrategy.d.ts +5 -0
- package/enums/MintingStrategy.js +2 -0
- package/enums/PropertyVisibility.d.ts +2 -0
- package/enums/PropertyVisibility.js +2 -0
- package/enums/TsFeature.d.ts +5 -0
- package/enums/TsFeature.js +16 -0
- package/enums/TsObjectDeclarationType.d.ts +5 -0
- package/enums/TsObjectDeclarationType.js +2 -0
- package/enums/index.d.ts +5 -0
- package/enums/index.js +5 -0
- package/generators/Generator.d.ts +5 -0
- package/generators/Generator.js +2 -0
- package/generators/index.d.ts +2 -2
- package/generators/index.js +2 -2
- package/generators/json/AstJsonGenerator.d.ts +4 -5
- package/generators/json/AstJsonGenerator.js +31 -22
- package/generators/ts/BooleanType.d.ts +7 -3
- package/generators/ts/BooleanType.js +58 -4
- package/generators/ts/DateTimeType.d.ts +19 -0
- package/generators/ts/DateTimeType.js +66 -0
- package/generators/ts/DeclaredType.d.ts +17 -0
- package/generators/ts/DeclaredType.js +10 -0
- package/generators/ts/IdentifierType.d.ts +7 -17
- package/generators/ts/IdentifierType.js +69 -60
- package/generators/ts/Import.d.ts +17 -0
- package/generators/ts/Import.js +54 -0
- package/generators/ts/ListType.d.ts +19 -8
- package/generators/ts/ListType.js +206 -44
- package/generators/ts/LiteralType.d.ts +13 -11
- package/generators/ts/LiteralType.js +36 -51
- package/generators/ts/NumberType.d.ts +7 -3
- package/generators/ts/NumberType.js +55 -4
- package/generators/ts/ObjectType.d.ts +48 -25
- package/generators/ts/ObjectType.js +234 -50
- package/generators/ts/ObjectUnionType.d.ts +58 -0
- package/generators/ts/ObjectUnionType.js +450 -0
- package/generators/ts/OptionType.d.ts +14 -4
- package/generators/ts/OptionType.js +70 -20
- package/generators/ts/PrimitiveType.d.ts +15 -5
- package/generators/ts/PrimitiveType.js +27 -31
- package/generators/ts/SetType.d.ts +14 -4
- package/generators/ts/SetType.js +108 -30
- package/generators/ts/SnippetDeclarations.d.ts +11 -0
- package/generators/ts/SnippetDeclarations.js +215 -0
- package/generators/ts/StringType.d.ts +8 -3
- package/generators/ts/StringType.js +57 -3
- package/generators/ts/TermType.d.ts +54 -0
- package/generators/ts/TermType.js +242 -0
- package/generators/ts/TsGenerator.d.ts +4 -12
- package/generators/ts/TsGenerator.js +57 -99
- package/generators/ts/Type.d.ts +117 -46
- package/generators/ts/Type.js +93 -59
- package/generators/ts/TypeFactory.d.ts +4 -5
- package/generators/ts/TypeFactory.js +224 -91
- package/generators/ts/UnionType.d.ts +20 -6
- package/generators/ts/UnionType.js +230 -120
- package/generators/ts/_ObjectType/IdentifierProperty.d.ts +27 -8
- package/generators/ts/_ObjectType/IdentifierProperty.js +153 -32
- package/generators/ts/_ObjectType/Property.d.ts +139 -9
- package/generators/ts/_ObjectType/Property.js +26 -3
- package/generators/ts/_ObjectType/ShaclProperty.d.ts +24 -5
- package/generators/ts/_ObjectType/ShaclProperty.js +103 -26
- package/generators/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +23 -7
- package/generators/ts/_ObjectType/TypeDiscriminatorProperty.js +83 -14
- package/generators/ts/_ObjectType/classDeclaration.d.ts +2 -1
- package/generators/ts/_ObjectType/classDeclaration.js +79 -111
- package/generators/ts/_ObjectType/createFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/createFunctionDeclaration.js +60 -0
- package/generators/ts/_ObjectType/equalsFunctionDeclaration.d.ts +2 -1
- package/generators/ts/_ObjectType/equalsFunctionDeclaration.js +12 -20
- package/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.d.ts +11 -0
- package/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +70 -0
- package/generators/ts/_ObjectType/fromJsonFunctionDeclarations.d.ts +4 -0
- package/generators/ts/_ObjectType/fromJsonFunctionDeclarations.js +78 -0
- package/generators/ts/_ObjectType/fromRdfFunctionDeclarations.d.ts +4 -0
- package/generators/ts/_ObjectType/fromRdfFunctionDeclarations.js +91 -0
- package/generators/ts/_ObjectType/hashFunctionDeclaration.d.ts +3 -3
- package/generators/ts/_ObjectType/hashFunctionDeclaration.js +11 -55
- package/generators/ts/_ObjectType/hashFunctionOrMethodDeclaration.d.ts +11 -0
- package/generators/ts/_ObjectType/hashFunctionOrMethodDeclaration.js +64 -0
- package/generators/ts/_ObjectType/index.d.ts +8 -2
- package/generators/ts/_ObjectType/index.js +8 -2
- package/generators/ts/_ObjectType/interfaceDeclaration.d.ts +3 -2
- package/generators/ts/_ObjectType/interfaceDeclaration.js +11 -2
- package/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.js +19 -0
- package/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.js +31 -0
- package/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.js +37 -0
- package/generators/ts/_ObjectType/rdfjsTermExpression.d.ts +6 -0
- package/generators/ts/{rdfjsTermExpression.js → _ObjectType/rdfjsTermExpression.js} +3 -1
- package/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.js +21 -0
- package/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.js +20 -0
- package/generators/ts/_ObjectType/sparqlFunctionDeclarations.d.ts +4 -0
- package/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +78 -0
- package/generators/ts/_ObjectType/toJsonFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/toJsonFunctionDeclaration.js +19 -0
- package/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.d.ts +10 -0
- package/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +59 -0
- package/generators/ts/_ObjectType/toJsonReturnType.d.ts +3 -0
- package/generators/ts/_ObjectType/toJsonReturnType.js +19 -0
- package/generators/ts/_ObjectType/toRdfFunctionDeclaration.d.ts +3 -2
- package/generators/ts/_ObjectType/toRdfFunctionDeclaration.js +11 -45
- package/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.d.ts +10 -0
- package/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +67 -0
- package/generators/ts/objectInitializer.d.ts +2 -0
- package/generators/ts/objectInitializer.js +14 -0
- package/generators/ts/tsComment.d.ts +5 -0
- package/generators/ts/tsComment.js +11 -0
- package/generators/ts/tsName.d.ts +1 -1
- package/generators/ts/tsName.js +1 -0
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/input/NodeShape.d.ts +46 -0
- package/input/NodeShape.js +165 -0
- package/input/Ontology.d.ts +13 -0
- package/input/Ontology.js +30 -0
- package/input/PropertyShape.d.ts +15 -0
- package/input/PropertyShape.js +34 -0
- package/input/Shape.d.ts +4 -0
- package/input/Shape.js +2 -0
- package/input/ShapesGraph.d.ts +9 -0
- package/input/ShapesGraph.js +50 -0
- package/input/ancestorClassIris.d.ts +4 -0
- package/input/ancestorClassIris.js +21 -0
- package/input/descendantClassIris.d.ts +4 -0
- package/input/descendantClassIris.js +21 -0
- package/input/generated.d.ts +275 -0
- package/input/generated.js +1436 -0
- package/input/index.d.ts +7 -0
- package/input/index.js +7 -0
- package/input/tsFeatures.d.ts +10 -0
- package/input/tsFeatures.js +46 -0
- package/package.json +15 -9
- package/ast/MintingStrategy.d.ts +0 -8
- package/ast/MintingStrategy.js +0 -9
- package/generators/ts/Configuration.d.ts +0 -29
- package/generators/ts/Configuration.js +0 -40
- package/generators/ts/IntersectionType.d.ts +0 -14
- package/generators/ts/IntersectionType.js +0 -26
- package/generators/ts/RdfjsTermType.d.ts +0 -25
- package/generators/ts/RdfjsTermType.js +0 -46
- package/generators/ts/_ObjectType/fromRdfFunctionDeclaration.d.ts +0 -4
- package/generators/ts/_ObjectType/fromRdfFunctionDeclaration.js +0 -72
- package/generators/ts/_ObjectType/sparqlGraphPatternsClassDeclaration.d.ts +0 -4
- package/generators/ts/_ObjectType/sparqlGraphPatternsClassDeclaration.js +0 -46
- package/generators/ts/rdfjsTermExpression.d.ts +0 -5
- package/vocabularies/dashDataset.d.ts +0 -3
- package/vocabularies/dashDataset.js +0 -2370
- package/vocabularies/index.d.ts +0 -2
- package/vocabularies/index.js +0 -2
- package/vocabularies/shaclmate.d.ts +0 -15
- package/vocabularies/shaclmate.js +0 -6
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { NodeShape as ShaclCoreNodeShape } from "@shaclmate/shacl-ast";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
|
+
import { tsFeatures } from "./tsFeatures.js";
|
|
4
|
+
export class NodeShape extends ShaclCoreNodeShape {
|
|
5
|
+
constructor({ ancestorClassIris, childClassIris, descendantClassIris, generatedShaclmateNodeShape, isClass, isList, parentClassIris, shapesGraph, }) {
|
|
6
|
+
super(generatedShaclmateNodeShape, shapesGraph);
|
|
7
|
+
this.ancestorClassIris = ancestorClassIris;
|
|
8
|
+
this.childClassIris = childClassIris;
|
|
9
|
+
this.descendantClassIris = descendantClassIris;
|
|
10
|
+
this.generatedShaclmateNodeShape = generatedShaclmateNodeShape;
|
|
11
|
+
this.isClass = isClass;
|
|
12
|
+
this.isList = isList;
|
|
13
|
+
this.parentClassIris = parentClassIris;
|
|
14
|
+
}
|
|
15
|
+
get abstract() {
|
|
16
|
+
return this.generatedShaclmateNodeShape.abstract;
|
|
17
|
+
}
|
|
18
|
+
get ancestorNodeShapes() {
|
|
19
|
+
return this.isClass
|
|
20
|
+
? this.ancestorClassIris.flatMap((classIri) => this.shapesGraph.nodeShapeByIdentifier(classIri).toList())
|
|
21
|
+
: [];
|
|
22
|
+
}
|
|
23
|
+
get childNodeShapes() {
|
|
24
|
+
return this.isClass
|
|
25
|
+
? this.childClassIris.flatMap((classIri) => this.shapesGraph.nodeShapeByIdentifier(classIri).toList())
|
|
26
|
+
: [];
|
|
27
|
+
}
|
|
28
|
+
get descendantNodeShapes() {
|
|
29
|
+
return this.isClass
|
|
30
|
+
? this.descendantClassIris.flatMap((classIri) => this.shapesGraph.nodeShapeByIdentifier(classIri).toList())
|
|
31
|
+
: [];
|
|
32
|
+
}
|
|
33
|
+
get export() {
|
|
34
|
+
return this.generatedShaclmateNodeShape.export_;
|
|
35
|
+
}
|
|
36
|
+
get extern() {
|
|
37
|
+
return this.generatedShaclmateNodeShape.extern;
|
|
38
|
+
}
|
|
39
|
+
get fromRdfType() {
|
|
40
|
+
// Check for an explicit shaclmate:fromRdfType
|
|
41
|
+
const fromRdfType = this.generatedShaclmateNodeShape.fromRdfType;
|
|
42
|
+
if (fromRdfType.isJust()) {
|
|
43
|
+
return fromRdfType;
|
|
44
|
+
}
|
|
45
|
+
// No explicit shaclmate:fromRdfType
|
|
46
|
+
// If the shape is a class, not abstract, and identified by an IRI then use the shape IRI as the fromRdfType.
|
|
47
|
+
if (!this.abstract.orDefault(false) &&
|
|
48
|
+
this.isClass &&
|
|
49
|
+
this.identifier.termType === "NamedNode") {
|
|
50
|
+
return Maybe.of(this.identifier);
|
|
51
|
+
}
|
|
52
|
+
return Maybe.empty();
|
|
53
|
+
}
|
|
54
|
+
get mintingStrategy() {
|
|
55
|
+
const thisMintingStrategy = this._mintingStrategy;
|
|
56
|
+
if (thisMintingStrategy.isNothing()) {
|
|
57
|
+
for (const ancestorNodeShape of this.ancestorNodeShapes) {
|
|
58
|
+
const ancestorMintingStrategy = ancestorNodeShape._mintingStrategy;
|
|
59
|
+
if (ancestorMintingStrategy.isJust()) {
|
|
60
|
+
return ancestorMintingStrategy;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return thisMintingStrategy;
|
|
65
|
+
}
|
|
66
|
+
get mutable() {
|
|
67
|
+
return this.generatedShaclmateNodeShape.mutable;
|
|
68
|
+
}
|
|
69
|
+
get nodeKinds() {
|
|
70
|
+
const thisNodeKinds = new Set([...this.constraints.nodeKinds.orDefault(new Set())].filter((nodeKind) => nodeKind !== "Literal"));
|
|
71
|
+
const parentNodeKinds = new Set();
|
|
72
|
+
for (const parentNodeShape of this.parentNodeShapes) {
|
|
73
|
+
for (const parentNodeKind of parentNodeShape.nodeKinds) {
|
|
74
|
+
parentNodeKinds.add(parentNodeKind);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (thisNodeKinds.size === 0 && parentNodeKinds.size > 0) {
|
|
78
|
+
// No node kinds on this shape, use the parent's
|
|
79
|
+
return parentNodeKinds;
|
|
80
|
+
}
|
|
81
|
+
if (thisNodeKinds.size > 0 && parentNodeKinds.size > 0) {
|
|
82
|
+
// Node kinds on this shape and the parent's shape
|
|
83
|
+
// This node kinds must be a subset of parent node kinds.
|
|
84
|
+
for (const thisNodeKind of thisNodeKinds) {
|
|
85
|
+
if (!parentNodeKinds.has(thisNodeKind)) {
|
|
86
|
+
throw new Error(`${this} has a nodeKind ${thisNodeKind} that is not in its parent's node kinds`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
if (thisNodeKinds.size === 0) {
|
|
91
|
+
// Default: both node kinds
|
|
92
|
+
thisNodeKinds.add("BlankNode");
|
|
93
|
+
thisNodeKinds.add("NamedNode");
|
|
94
|
+
}
|
|
95
|
+
return thisNodeKinds;
|
|
96
|
+
}
|
|
97
|
+
get parentNodeShapes() {
|
|
98
|
+
return this.isClass
|
|
99
|
+
? this.parentClassIris.flatMap((classIri) => this.shapesGraph.nodeShapeByIdentifier(classIri).toList())
|
|
100
|
+
: [];
|
|
101
|
+
}
|
|
102
|
+
get shaclmateName() {
|
|
103
|
+
return this.generatedShaclmateNodeShape.name;
|
|
104
|
+
}
|
|
105
|
+
get toRdfTypes() {
|
|
106
|
+
// Look for one or more explicit shaclmate:toRdfType's
|
|
107
|
+
const toRdfTypes = this.generatedShaclmateNodeShape.toRdfTypes.concat();
|
|
108
|
+
// Ensure the toRdfTypes includes the fromRdfType if there is one
|
|
109
|
+
this.fromRdfType.ifJust((fromRdfType) => {
|
|
110
|
+
if (!toRdfTypes.some((toRdfType) => toRdfType.equals(fromRdfType))) {
|
|
111
|
+
toRdfTypes.push(fromRdfType);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
if (toRdfTypes.length === 0) {
|
|
115
|
+
// No explicit shaclmate:toRdfType's
|
|
116
|
+
// If the shape is a class, not abstract, and identified by an IRI then use the shape IRI as the fromRdfType.
|
|
117
|
+
if (!this.abstract.orDefault(false) &&
|
|
118
|
+
this.isClass &&
|
|
119
|
+
this.identifier.termType === "NamedNode") {
|
|
120
|
+
toRdfTypes.push(this.identifier);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return toRdfTypes;
|
|
124
|
+
}
|
|
125
|
+
get tsFeatures() {
|
|
126
|
+
return tsFeatures(this.generatedShaclmateNodeShape).altLazy(() => this.isDefinedBy.chain((ontology) => ontology.tsFeatures));
|
|
127
|
+
}
|
|
128
|
+
get tsImports() {
|
|
129
|
+
return this.generatedShaclmateNodeShape.tsImports;
|
|
130
|
+
}
|
|
131
|
+
get tsObjectDeclarationType() {
|
|
132
|
+
return this.generatedShaclmateNodeShape.tsObjectDeclarationType
|
|
133
|
+
.map((iri) => {
|
|
134
|
+
switch (iri.value) {
|
|
135
|
+
case "http://minorg.github.io/shaclmate/ns#_TsObjectDeclarationType_Class":
|
|
136
|
+
return "class";
|
|
137
|
+
case "http://minorg.github.io/shaclmate/ns#_TsObjectDeclarationType_Interface":
|
|
138
|
+
return "interface";
|
|
139
|
+
default:
|
|
140
|
+
throw new RangeError(iri.value);
|
|
141
|
+
}
|
|
142
|
+
})
|
|
143
|
+
.altLazy(() => this.isDefinedBy.chain((ontology) => ontology.tsObjectDeclarationType));
|
|
144
|
+
}
|
|
145
|
+
get tsObjectIdentifierPropertyName() {
|
|
146
|
+
return this.generatedShaclmateNodeShape.tsObjectIdentifierPropertyName;
|
|
147
|
+
}
|
|
148
|
+
get tsObjectTypeDiscriminatorPropertyName() {
|
|
149
|
+
return this.generatedShaclmateNodeShape
|
|
150
|
+
.tsObjectTypeDiscriminatorPropertyName;
|
|
151
|
+
}
|
|
152
|
+
get _mintingStrategy() {
|
|
153
|
+
return this.generatedShaclmateNodeShape.mintingStrategy.map((iri) => {
|
|
154
|
+
switch (iri.value) {
|
|
155
|
+
case "http://minorg.github.io/shaclmate/ns#_MintingStrategy_SHA256":
|
|
156
|
+
return "sha256";
|
|
157
|
+
case "http://minorg.github.io/shaclmate/ns#_MintingStrategy_UUIDv4":
|
|
158
|
+
return "uuidv4";
|
|
159
|
+
default:
|
|
160
|
+
throw new RangeError(iri.value);
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
//# sourceMappingURL=NodeShape.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Ontology as OwlOntology } from "@shaclmate/shacl-ast";
|
|
2
|
+
import type { Maybe } from "purify-ts";
|
|
3
|
+
import type { TsFeature, TsObjectDeclarationType } from "../enums/index.js";
|
|
4
|
+
import type * as generated from "./generated.js";
|
|
5
|
+
export declare class Ontology extends OwlOntology {
|
|
6
|
+
private readonly generatedShaclmateOntology;
|
|
7
|
+
constructor(generatedShaclmateOntology: generated.ShaclmateOntology);
|
|
8
|
+
get tsDataFactoryVariable(): Maybe<string>;
|
|
9
|
+
get tsFeatures(): Maybe<Set<TsFeature>>;
|
|
10
|
+
get tsImports(): readonly string[];
|
|
11
|
+
get tsObjectDeclarationType(): Maybe<TsObjectDeclarationType>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=Ontology.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { Ontology as OwlOntology } from "@shaclmate/shacl-ast";
|
|
2
|
+
import { tsFeatures } from "./tsFeatures.js";
|
|
3
|
+
export class Ontology extends OwlOntology {
|
|
4
|
+
constructor(generatedShaclmateOntology) {
|
|
5
|
+
super(generatedShaclmateOntology);
|
|
6
|
+
this.generatedShaclmateOntology = generatedShaclmateOntology;
|
|
7
|
+
}
|
|
8
|
+
get tsDataFactoryVariable() {
|
|
9
|
+
return this.generatedShaclmateOntology.tsDataFactoryVariable;
|
|
10
|
+
}
|
|
11
|
+
get tsFeatures() {
|
|
12
|
+
return tsFeatures(this.generatedShaclmateOntology);
|
|
13
|
+
}
|
|
14
|
+
get tsImports() {
|
|
15
|
+
return this.generatedShaclmateOntology.tsImports;
|
|
16
|
+
}
|
|
17
|
+
get tsObjectDeclarationType() {
|
|
18
|
+
return this.generatedShaclmateOntology.tsObjectDeclarationType.map((iri) => {
|
|
19
|
+
switch (iri.value) {
|
|
20
|
+
case "http://minorg.github.io/shaclmate/ns#_TsObjectDeclarationType_Class":
|
|
21
|
+
return "class";
|
|
22
|
+
case "http://minorg.github.io/shaclmate/ns#_TsObjectDeclarationType_Interface":
|
|
23
|
+
return "interface";
|
|
24
|
+
default:
|
|
25
|
+
throw new RangeError(iri.value);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=Ontology.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PropertyShape as ShaclCorePropertyShape } from "@shaclmate/shacl-ast";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
|
+
import type { PropertyVisibility } from "../enums/index.js";
|
|
4
|
+
import type { Shape } from "./Shape.js";
|
|
5
|
+
import type * as generated from "./generated.js";
|
|
6
|
+
import type { NodeShape, Ontology, PropertyGroup, ShapesGraph } from "./index.js";
|
|
7
|
+
export declare class PropertyShape extends ShaclCorePropertyShape<NodeShape, Ontology, PropertyGroup, any, Shape> {
|
|
8
|
+
private readonly generatedShaclmatePropertyShape;
|
|
9
|
+
constructor(generatedShaclmatePropertyShape: generated.ShaclmatePropertyShape, shapesGraph: ShapesGraph);
|
|
10
|
+
get extern(): Maybe<boolean>;
|
|
11
|
+
get mutable(): Maybe<boolean>;
|
|
12
|
+
get shaclmateName(): Maybe<string>;
|
|
13
|
+
get visibility(): PropertyVisibility;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=PropertyShape.d.ts.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { PropertyShape as ShaclCorePropertyShape } from "@shaclmate/shacl-ast";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
|
+
export class PropertyShape extends ShaclCorePropertyShape {
|
|
4
|
+
constructor(generatedShaclmatePropertyShape, shapesGraph) {
|
|
5
|
+
super({ ...generatedShaclmatePropertyShape, uniqueLang: Maybe.empty() }, shapesGraph);
|
|
6
|
+
this.generatedShaclmatePropertyShape = generatedShaclmatePropertyShape;
|
|
7
|
+
}
|
|
8
|
+
get extern() {
|
|
9
|
+
return this.generatedShaclmatePropertyShape.extern;
|
|
10
|
+
}
|
|
11
|
+
get mutable() {
|
|
12
|
+
return this.generatedShaclmatePropertyShape.mutable;
|
|
13
|
+
}
|
|
14
|
+
get shaclmateName() {
|
|
15
|
+
return this.generatedShaclmatePropertyShape.name;
|
|
16
|
+
}
|
|
17
|
+
get visibility() {
|
|
18
|
+
return this.generatedShaclmatePropertyShape.visibility
|
|
19
|
+
.map((iri) => {
|
|
20
|
+
switch (iri.value) {
|
|
21
|
+
case "http://minorg.github.io/shaclmate/ns#_Visibility_Private":
|
|
22
|
+
return "private";
|
|
23
|
+
case "http://minorg.github.io/shaclmate/ns#_Visibility_Protected":
|
|
24
|
+
return "protected";
|
|
25
|
+
case "http://minorg.github.io/shaclmate/ns#_Visibility_Public":
|
|
26
|
+
return "public";
|
|
27
|
+
default:
|
|
28
|
+
throw new RangeError(iri.value);
|
|
29
|
+
}
|
|
30
|
+
})
|
|
31
|
+
.orDefault("public");
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=PropertyShape.js.map
|
package/input/Shape.d.ts
ADDED
package/input/Shape.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DatasetCore } from "@rdfjs/types";
|
|
2
|
+
import { RdfjsShapesGraph } from "@shaclmate/shacl-ast";
|
|
3
|
+
import { NodeShape, Ontology, PropertyGroup, PropertyShape, type Shape } from "./index.js";
|
|
4
|
+
export declare class ShapesGraph extends RdfjsShapesGraph<NodeShape, Ontology, PropertyGroup, PropertyShape, Shape> {
|
|
5
|
+
constructor({ dataset }: {
|
|
6
|
+
dataset: DatasetCore;
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=ShapesGraph.d.ts.map
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { RdfjsShapesGraph } from "@shaclmate/shacl-ast";
|
|
2
|
+
import { owl, rdf, rdfs } from "@tpluscode/rdf-ns-builders";
|
|
3
|
+
import { ancestorClassIris } from "./ancestorClassIris.js";
|
|
4
|
+
import { descendantClassIris } from "./descendantClassIris.js";
|
|
5
|
+
import * as generated from "./generated.js";
|
|
6
|
+
import { NodeShape, Ontology, PropertyGroup, PropertyShape, } from "./index.js";
|
|
7
|
+
export class ShapesGraph extends RdfjsShapesGraph {
|
|
8
|
+
constructor({ dataset }) {
|
|
9
|
+
super({
|
|
10
|
+
dataset,
|
|
11
|
+
factory: {
|
|
12
|
+
nodeShapeFromRdf({ resource, shapesGraph, }) {
|
|
13
|
+
return generated.ShaclmateNodeShape.fromRdf({
|
|
14
|
+
ignoreRdfType: true,
|
|
15
|
+
resource,
|
|
16
|
+
}).map((generatedShape) => new NodeShape({
|
|
17
|
+
ancestorClassIris: ancestorClassIris(resource, Number.MAX_SAFE_INTEGER),
|
|
18
|
+
childClassIris: descendantClassIris(resource, 1),
|
|
19
|
+
descendantClassIris: descendantClassIris(resource, Number.MAX_SAFE_INTEGER),
|
|
20
|
+
generatedShaclmateNodeShape: generatedShape,
|
|
21
|
+
isClass: resource.isInstanceOf(owl.Class) ||
|
|
22
|
+
resource.isInstanceOf(rdfs.Class),
|
|
23
|
+
isList: resource.isSubClassOf(rdf.List),
|
|
24
|
+
parentClassIris: ancestorClassIris(resource, 1),
|
|
25
|
+
shapesGraph,
|
|
26
|
+
}));
|
|
27
|
+
},
|
|
28
|
+
ontologyFromRdf({ resource, }) {
|
|
29
|
+
return generated.ShaclmateOntology.fromRdf({
|
|
30
|
+
ignoreRdfType: true,
|
|
31
|
+
resource,
|
|
32
|
+
}).map((generatedOntology) => new Ontology(generatedOntology));
|
|
33
|
+
},
|
|
34
|
+
propertyGroupFromRdf({ resource, }) {
|
|
35
|
+
return generated.ShaclCorePropertyGroup.fromRdf({
|
|
36
|
+
ignoreRdfType: true,
|
|
37
|
+
resource,
|
|
38
|
+
}).map((generatedPropertyGroup) => new PropertyGroup(generatedPropertyGroup));
|
|
39
|
+
},
|
|
40
|
+
propertyShapeFromRdf({ resource, shapesGraph, }) {
|
|
41
|
+
return generated.ShaclmatePropertyShape.fromRdf({
|
|
42
|
+
ignoreRdfType: true,
|
|
43
|
+
resource,
|
|
44
|
+
}).map((generatedShape) => new PropertyShape(generatedShape, shapesGraph));
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=ShapesGraph.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import TermSet from "@rdfjs/term-set";
|
|
2
|
+
import { rdfs } from "@tpluscode/rdf-ns-builders";
|
|
3
|
+
export function ancestorClassIris(classResource, maxDepth) {
|
|
4
|
+
const ancestorClassIris = new TermSet();
|
|
5
|
+
function ancestorClassIrisRecursive(classResource, depth) {
|
|
6
|
+
for (const parentClassValue of classResource.values(rdfs.subClassOf)) {
|
|
7
|
+
parentClassValue.toNamedResource().ifRight((parentClassResource) => {
|
|
8
|
+
if (ancestorClassIris.has(parentClassResource.identifier)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
ancestorClassIris.add(parentClassResource.identifier);
|
|
12
|
+
if (depth < maxDepth) {
|
|
13
|
+
ancestorClassIrisRecursive(parentClassResource, depth + 1);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
ancestorClassIrisRecursive(classResource, 1);
|
|
19
|
+
return [...ancestorClassIris];
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=ancestorClassIris.js.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import TermSet from "@rdfjs/term-set";
|
|
2
|
+
import { rdfs } from "@tpluscode/rdf-ns-builders";
|
|
3
|
+
export function descendantClassIris(classResource, maxDepth) {
|
|
4
|
+
const descendantClassIris = new TermSet();
|
|
5
|
+
function descendantClassIrisRecursive(classResource, depth) {
|
|
6
|
+
for (const childClassValue of classResource.valuesOf(rdfs.subClassOf)) {
|
|
7
|
+
childClassValue.toNamedResource().ifRight((childClassResource) => {
|
|
8
|
+
if (descendantClassIris.has(childClassResource.identifier)) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
descendantClassIris.add(childClassResource.identifier);
|
|
12
|
+
if (depth < maxDepth) {
|
|
13
|
+
descendantClassIrisRecursive(childClassResource, depth + 1);
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
descendantClassIrisRecursive(classResource, 1);
|
|
19
|
+
return [...descendantClassIris];
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=descendantClassIris.js.map
|