@shaclmate/compiler 4.0.13 → 4.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ShapesGraphToAstTransformer.js +2 -2
- package/dist/_ShapesGraphToAstTransformer/ShapeStack.js +6 -5
- package/dist/_ShapesGraphToAstTransformer/nodeShapeIdentifierMintingStrategy.d.ts +3 -2
- package/dist/_ShapesGraphToAstTransformer/nodeShapeIdentifierMintingStrategy.js +8 -5
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +2 -1
- package/dist/_ShapesGraphToAstTransformer/shapeAstTypeName.js +6 -6
- package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.d.ts +2 -1
- package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +23 -17
- package/dist/_ShapesGraphToAstTransformer/shapeOntology.d.ts +5 -0
- package/dist/_ShapesGraphToAstTransformer/shapeOntology.js +25 -0
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +23 -16
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +6 -6
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +15 -15
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +122 -118
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +10 -8
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +3 -3
- package/dist/ast/ObjectType.d.ts +3 -3
- package/dist/enums/IdentifierMintingStrategy.d.ts +4 -0
- package/dist/enums/IdentifierMintingStrategy.js +17 -1
- package/dist/enums/TsObjectDeclarationType.d.ts +4 -0
- package/dist/enums/TsObjectDeclarationType.js +15 -1
- package/dist/enums/Visibility.d.ts +6 -0
- package/dist/enums/Visibility.js +18 -0
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +3 -3
- package/dist/input/NodeShape.d.ts +8 -46
- package/dist/input/NodeShape.js +1 -153
- package/dist/input/Shape.d.ts +2 -2
- package/dist/input/ShapesGraph.d.ts +10 -10
- package/dist/input/ShapesGraph.js +11 -13
- package/dist/input/generated.d.ts +185 -152
- package/dist/input/generated.js +316 -249
- package/dist/input/index.d.ts +1 -3
- package/dist/input/index.js +1 -3
- package/package.json +2 -2
- package/dist/enums/PropertyVisibility.d.ts +0 -2
- package/dist/enums/PropertyVisibility.js +0 -2
- package/dist/input/Ontology.d.ts +0 -13
- package/dist/input/Ontology.js +0 -40
- package/dist/input/PropertyShape.d.ts +0 -20
- package/dist/input/PropertyShape.js +0 -78
package/dist/input/NodeShape.js
CHANGED
|
@@ -1,154 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
-
};
|
|
7
|
-
import { NodeShape as ShaclAstNodeShape } from "@shaclmate/shacl-ast";
|
|
8
|
-
import { rdf } from "@tpluscode/rdf-ns-builders";
|
|
9
|
-
import { Either, List } from "purify-ts";
|
|
10
|
-
import { invariant } from "ts-invariant";
|
|
11
|
-
import { Memoize } from "typescript-memoize";
|
|
12
|
-
export class NodeShape extends ShaclAstNodeShape {
|
|
13
|
-
ancestorClassIris;
|
|
14
|
-
childClassIris;
|
|
15
|
-
descendantClassIris;
|
|
16
|
-
generatedNodeShape;
|
|
17
|
-
parentClassIris;
|
|
18
|
-
isClass;
|
|
19
|
-
isList;
|
|
20
|
-
kind = "NodeShape";
|
|
21
|
-
constructor({ ancestorClassIris, childClassIris, descendantClassIris, generatedNodeShape, isClass, isList, parentClassIris, shapesGraph, }) {
|
|
22
|
-
super(generatedNodeShape, shapesGraph);
|
|
23
|
-
if (ancestorClassIris.length > 0 ||
|
|
24
|
-
childClassIris.length > 0 ||
|
|
25
|
-
descendantClassIris.length > 0 ||
|
|
26
|
-
isList ||
|
|
27
|
-
parentClassIris.length > 0) {
|
|
28
|
-
invariant(isClass);
|
|
29
|
-
}
|
|
30
|
-
this.ancestorClassIris = ancestorClassIris;
|
|
31
|
-
this.childClassIris = childClassIris;
|
|
32
|
-
this.descendantClassIris = descendantClassIris;
|
|
33
|
-
this.generatedNodeShape = generatedNodeShape;
|
|
34
|
-
this.isClass = isClass;
|
|
35
|
-
this.isList = isList;
|
|
36
|
-
this.parentClassIris = parentClassIris;
|
|
37
|
-
}
|
|
38
|
-
get abstract() {
|
|
39
|
-
return this.generatedNodeShape.abstract;
|
|
40
|
-
}
|
|
41
|
-
get ancestorNodeShapes() {
|
|
42
|
-
return Either.sequence(this.ancestorClassIris
|
|
43
|
-
.filter((classIri) => !classIri.equals(rdf.List))
|
|
44
|
-
.map((classIri) => this.shapesGraph.nodeShapeByIdentifier(classIri)));
|
|
45
|
-
}
|
|
46
|
-
get childNodeShapes() {
|
|
47
|
-
return Either.sequence(this.childClassIris.flatMap((classIri) => this.shapesGraph.nodeShapeByIdentifier(classIri)));
|
|
48
|
-
}
|
|
49
|
-
get comment() {
|
|
50
|
-
return List.head(this.comments);
|
|
51
|
-
}
|
|
52
|
-
get descendantNodeShapes() {
|
|
53
|
-
return Either.sequence(this.descendantClassIris.flatMap((classIri) => this.shapesGraph.nodeShapeByIdentifier(classIri)));
|
|
54
|
-
}
|
|
55
|
-
get discriminantValue() {
|
|
56
|
-
return this.generatedNodeShape.discriminantValue;
|
|
57
|
-
}
|
|
58
|
-
get extern() {
|
|
59
|
-
return this.generatedNodeShape.extern;
|
|
60
|
-
}
|
|
61
|
-
get fromRdfType() {
|
|
62
|
-
return this.generatedNodeShape.fromRdfType;
|
|
63
|
-
}
|
|
64
|
-
get identifierIn() {
|
|
65
|
-
return this.constraints.in_.filter((value) => value.termType === "NamedNode");
|
|
66
|
-
}
|
|
67
|
-
get identifierMintingStrategy() {
|
|
68
|
-
return this.generatedNodeShape.identifierMintingStrategy.map((iri) => {
|
|
69
|
-
switch (iri.value) {
|
|
70
|
-
case "http://purl.org/shaclmate/ontology#_IdentifierMintingStrategy_BlankNode":
|
|
71
|
-
return "blankNode";
|
|
72
|
-
case "http://purl.org/shaclmate/ontology#_IdentifierMintingStrategy_SHA256":
|
|
73
|
-
return "sha256";
|
|
74
|
-
case "http://purl.org/shaclmate/ontology#_IdentifierMintingStrategy_UUIDv4":
|
|
75
|
-
return "uuidv4";
|
|
76
|
-
default:
|
|
77
|
-
iri.value;
|
|
78
|
-
throw new RangeError(iri.value);
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
get label() {
|
|
83
|
-
return List.head(this.labels);
|
|
84
|
-
}
|
|
85
|
-
get mutable() {
|
|
86
|
-
return this.generatedNodeShape.mutable;
|
|
87
|
-
}
|
|
88
|
-
get parentNodeShapes() {
|
|
89
|
-
return Either.sequence(this.parentClassIris
|
|
90
|
-
.filter((classIri) => !classIri.equals(rdf.List))
|
|
91
|
-
.map((classIri) => this.shapesGraph.nodeShapeByIdentifier(classIri)));
|
|
92
|
-
}
|
|
93
|
-
get rdfType() {
|
|
94
|
-
return this.generatedNodeShape.rdfType;
|
|
95
|
-
}
|
|
96
|
-
get shaclmateName() {
|
|
97
|
-
return this.generatedNodeShape.name;
|
|
98
|
-
}
|
|
99
|
-
get toRdfTypes() {
|
|
100
|
-
return this.generatedNodeShape.toRdfTypes;
|
|
101
|
-
}
|
|
102
|
-
get tsFeatureExcludes() {
|
|
103
|
-
return this.generatedNodeShape.tsFeatureExcludes;
|
|
104
|
-
}
|
|
105
|
-
get tsFeatureIncludes() {
|
|
106
|
-
return this.generatedNodeShape.tsFeatureIncludes;
|
|
107
|
-
}
|
|
108
|
-
get tsImports() {
|
|
109
|
-
return this.generatedNodeShape.tsImports;
|
|
110
|
-
}
|
|
111
|
-
get tsObjectDeclarationType() {
|
|
112
|
-
return this.generatedNodeShape.tsObjectDeclarationType.map((iri) => {
|
|
113
|
-
switch (iri.value) {
|
|
114
|
-
case "http://purl.org/shaclmate/ontology#_TsObjectDeclarationType_Class":
|
|
115
|
-
return "class";
|
|
116
|
-
case "http://purl.org/shaclmate/ontology#_TsObjectDeclarationType_Interface":
|
|
117
|
-
return "interface";
|
|
118
|
-
default:
|
|
119
|
-
throw new RangeError(iri.value);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
__decorate([
|
|
125
|
-
Memoize()
|
|
126
|
-
], NodeShape.prototype, "ancestorNodeShapes", null);
|
|
127
|
-
__decorate([
|
|
128
|
-
Memoize()
|
|
129
|
-
], NodeShape.prototype, "childNodeShapes", null);
|
|
130
|
-
__decorate([
|
|
131
|
-
Memoize()
|
|
132
|
-
], NodeShape.prototype, "comment", null);
|
|
133
|
-
__decorate([
|
|
134
|
-
Memoize()
|
|
135
|
-
], NodeShape.prototype, "descendantNodeShapes", null);
|
|
136
|
-
__decorate([
|
|
137
|
-
Memoize()
|
|
138
|
-
], NodeShape.prototype, "identifierIn", null);
|
|
139
|
-
__decorate([
|
|
140
|
-
Memoize()
|
|
141
|
-
], NodeShape.prototype, "identifierMintingStrategy", null);
|
|
142
|
-
__decorate([
|
|
143
|
-
Memoize()
|
|
144
|
-
], NodeShape.prototype, "label", null);
|
|
145
|
-
__decorate([
|
|
146
|
-
Memoize()
|
|
147
|
-
], NodeShape.prototype, "parentNodeShapes", null);
|
|
148
|
-
__decorate([
|
|
149
|
-
Memoize()
|
|
150
|
-
], NodeShape.prototype, "rdfType", null);
|
|
151
|
-
__decorate([
|
|
152
|
-
Memoize()
|
|
153
|
-
], NodeShape.prototype, "tsObjectDeclarationType", null);
|
|
1
|
+
export {};
|
|
154
2
|
//# sourceMappingURL=NodeShape.js.map
|
package/dist/input/Shape.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import type * as generated from "./generated.js";
|
|
1
2
|
import type { NodeShape } from "./NodeShape.js";
|
|
2
|
-
|
|
3
|
-
export type Shape = NodeShape | PropertyShape;
|
|
3
|
+
export type Shape = NodeShape | generated.PropertyShape;
|
|
4
4
|
//# sourceMappingURL=Shape.d.ts.map
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { ShapesGraph as _ShapesGraph, type CurieFactory } from "@shaclmate/shacl-ast";
|
|
2
2
|
import type { Either } from "purify-ts";
|
|
3
3
|
import type { Resource } from "rdfjs-resource";
|
|
4
|
-
import
|
|
5
|
-
|
|
4
|
+
import * as generated from "./generated.js";
|
|
5
|
+
import type { NodeShape } from "./NodeShape.js";
|
|
6
|
+
import type { Shape } from "./Shape.js";
|
|
7
|
+
export type ShapesGraph = _ShapesGraph<NodeShape, generated.Ontology, generated.PropertyGroup, generated.PropertyShape, Shape>;
|
|
6
8
|
export declare namespace ShapesGraph {
|
|
7
|
-
class Factory extends _ShapesGraph.Factory<NodeShape, Ontology, PropertyGroup, PropertyShape, Shape> {
|
|
8
|
-
protected createNodeShape({ resource,
|
|
9
|
+
class Factory extends _ShapesGraph.Factory<NodeShape, generated.Ontology, generated.PropertyGroup, generated.PropertyShape, Shape> {
|
|
10
|
+
protected createNodeShape({ resource, }: {
|
|
9
11
|
resource: Resource;
|
|
10
|
-
shapesGraph: ShapesGraph;
|
|
11
12
|
}): Either<Error, NodeShape>;
|
|
12
13
|
protected createOntology({ resource, }: {
|
|
13
14
|
resource: Resource;
|
|
14
|
-
}): Either<Error, Ontology>;
|
|
15
|
+
}): Either<Error, generated.Ontology>;
|
|
15
16
|
protected createPropertyGroup({ resource, }: {
|
|
16
17
|
resource: Resource;
|
|
17
|
-
}): Either<Error, PropertyGroup>;
|
|
18
|
-
protected createPropertyShape({ curieFactory, resource,
|
|
18
|
+
}): Either<Error, generated.PropertyGroup>;
|
|
19
|
+
protected createPropertyShape({ curieFactory, resource, }: {
|
|
19
20
|
curieFactory: CurieFactory;
|
|
20
21
|
resource: Resource;
|
|
21
|
-
|
|
22
|
-
}): Either<Error, PropertyShape>;
|
|
22
|
+
}): Either<Error, generated.PropertyShape>;
|
|
23
23
|
}
|
|
24
24
|
export function create(parameters: Parameters<Factory["createShapesGraph"]>[0]): Either<Error, ShapesGraph>;
|
|
25
25
|
export {};
|
|
@@ -3,11 +3,10 @@ import { owl, rdf, rdfs } from "@tpluscode/rdf-ns-builders";
|
|
|
3
3
|
import { ancestorClassIris } from "./ancestorClassIris.js";
|
|
4
4
|
import { descendantClassIris } from "./descendantClassIris.js";
|
|
5
5
|
import * as generated from "./generated.js";
|
|
6
|
-
import { NodeShape, Ontology, PropertyGroup, PropertyShape, } from "./index.js";
|
|
7
6
|
export var ShapesGraph;
|
|
8
7
|
(function (ShapesGraph) {
|
|
9
8
|
class Factory extends _ShapesGraph.Factory {
|
|
10
|
-
createNodeShape({ resource,
|
|
9
|
+
createNodeShape({ resource, }) {
|
|
11
10
|
return generated.NodeShape.$fromRdfResource(resource, {
|
|
12
11
|
ignoreRdfType: true,
|
|
13
12
|
preferredLanguages: this.preferredLanguages,
|
|
@@ -17,7 +16,7 @@ export var ShapesGraph;
|
|
|
17
16
|
if (isList) {
|
|
18
17
|
isClass = true; // RDFS entailment: if A rdfs:subClassOf rdf:List then A is an rdfs:Class
|
|
19
18
|
}
|
|
20
|
-
const ancestorClassIris_ = ancestorClassIris(resource, Number.MAX_SAFE_INTEGER);
|
|
19
|
+
const ancestorClassIris_ = ancestorClassIris(resource, Number.MAX_SAFE_INTEGER).filter((ancestorClassIri) => !ancestorClassIri.equals(rdf.List));
|
|
21
20
|
if (ancestorClassIris_.length > 0) {
|
|
22
21
|
isClass = true; // RDFS entailment: if A rdfs:subClassOf B then both A and B are rdfs:Class's
|
|
23
22
|
}
|
|
@@ -25,40 +24,39 @@ export var ShapesGraph;
|
|
|
25
24
|
if (descendantClassIris_.length > 0) {
|
|
26
25
|
isClass = true; // RDFS entailment, see above
|
|
27
26
|
}
|
|
28
|
-
return
|
|
27
|
+
return {
|
|
28
|
+
...generatedShape,
|
|
29
29
|
ancestorClassIris: ancestorClassIris_,
|
|
30
30
|
childClassIris: descendantClassIris(resource, 1),
|
|
31
31
|
descendantClassIris: descendantClassIris_,
|
|
32
|
-
generatedNodeShape: generatedShape,
|
|
33
32
|
isClass,
|
|
34
33
|
isList,
|
|
35
|
-
parentClassIris: ancestorClassIris(resource, 1),
|
|
36
|
-
|
|
37
|
-
});
|
|
34
|
+
parentClassIris: ancestorClassIris(resource, 1).filter((ancestorClassIri) => !ancestorClassIri.equals(rdf.List)),
|
|
35
|
+
};
|
|
38
36
|
});
|
|
39
37
|
}
|
|
40
38
|
createOntology({ resource, }) {
|
|
41
39
|
return generated.Ontology.$fromRdfResource(resource, {
|
|
42
40
|
ignoreRdfType: true,
|
|
43
41
|
preferredLanguages: this.preferredLanguages,
|
|
44
|
-
})
|
|
42
|
+
});
|
|
45
43
|
}
|
|
46
44
|
createPropertyGroup({ resource, }) {
|
|
47
45
|
return generated.PropertyGroup.$fromRdfResource(resource, {
|
|
48
46
|
ignoreRdfType: true,
|
|
49
47
|
preferredLanguages: this.preferredLanguages,
|
|
50
|
-
})
|
|
48
|
+
});
|
|
51
49
|
}
|
|
52
|
-
createPropertyShape({ curieFactory, resource,
|
|
50
|
+
createPropertyShape({ curieFactory, resource, }) {
|
|
53
51
|
return generated.PropertyShape.$fromRdfResource(resource, {
|
|
54
52
|
ignoreRdfType: true,
|
|
55
53
|
preferredLanguages: this.preferredLanguages,
|
|
56
|
-
}).map((generatedShape) =>
|
|
54
|
+
}).map((generatedShape) => ({
|
|
57
55
|
...generatedShape,
|
|
58
56
|
path: (generatedShape.path.termType === "NamedNode"
|
|
59
57
|
? curieFactory.create(generatedShape.path).extract()
|
|
60
58
|
: undefined) ?? generatedShape.path,
|
|
61
|
-
}
|
|
59
|
+
}));
|
|
62
60
|
}
|
|
63
61
|
}
|
|
64
62
|
const factory = new Factory();
|