@shaclmate/compiler 4.0.14 → 4.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/dist/Compiler.d.ts +4 -1
- package/dist/Compiler.js +3 -1
- package/dist/ShapesGraphToAstTransformer.d.ts +10 -2
- package/dist/ShapesGraphToAstTransformer.js +72 -1
- package/dist/_ShapesGraphToAstTransformer/nodeShapeIdentifierMintingStrategy.js +14 -13
- package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +18 -17
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +6 -2
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +8 -8
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +10 -5
- package/dist/generators/ts/AbstractCollectionType.js +1 -7
- package/dist/generators/ts/AbstractTermType.d.ts +1 -0
- package/dist/generators/ts/AbstractTermType.js +6 -0
- package/dist/generators/ts/AbstractUnionType.d.ts +31 -9
- package/dist/generators/ts/AbstractUnionType.js +252 -126
- package/dist/generators/ts/SetType.d.ts +1 -0
- package/dist/generators/ts/SetType.js +12 -0
- package/dist/input/ShapesGraph.d.ts +38 -21
- package/dist/input/ShapesGraph.js +56 -58
- package/dist/input/generated.d.ts +204 -39
- package/dist/input/generated.js +2281 -676
- package/dist/input/index.d.ts +1 -3
- package/dist/input/index.js +1 -3
- package/package.json +2 -2
- package/dist/input/NodeShape.d.ts +0 -11
- package/dist/input/NodeShape.js +0 -2
- package/dist/input/Shape.d.ts +0 -4
- package/dist/input/Shape.js +0 -2
- package/dist/input/ancestorClassIris.d.ts +0 -4
- package/dist/input/ancestorClassIris.js +0 -24
- package/dist/input/descendantClassIris.d.ts +0 -4
- package/dist/input/descendantClassIris.js +0 -27
|
@@ -1,68 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { descendantClassIris } from "./descendantClassIris.js";
|
|
1
|
+
import { AbstractShapesGraph } from "@shaclmate/shacl-ast";
|
|
2
|
+
import { Compiler } from "../Compiler.js";
|
|
3
|
+
import { ShapesGraphToAstTransformer } from "../ShapesGraphToAstTransformer.js";
|
|
5
4
|
import * as generated from "./generated.js";
|
|
6
|
-
|
|
5
|
+
const typeFunctions = {
|
|
6
|
+
NodeShape: generated.NodeShape,
|
|
7
|
+
Ontology: generated.Ontology,
|
|
8
|
+
PropertyGroup: generated.PropertyGroup,
|
|
9
|
+
PropertyShape: generated.PropertyShape,
|
|
10
|
+
};
|
|
11
|
+
export class ShapesGraph extends AbstractShapesGraph {
|
|
12
|
+
typeFunctions = typeFunctions;
|
|
13
|
+
/**
|
|
14
|
+
* Compile the shapes graph using the given generator and return the generator's output.
|
|
15
|
+
*/
|
|
16
|
+
compile(parameters) {
|
|
17
|
+
return new Compiler(parameters).compile(this);
|
|
18
|
+
}
|
|
19
|
+
static builder() {
|
|
20
|
+
return new ShapesGraph.Builder();
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Transform the shapes graph to an AST.
|
|
24
|
+
*/
|
|
25
|
+
toAst(options) {
|
|
26
|
+
return new ShapesGraphToAstTransformer({
|
|
27
|
+
...options,
|
|
28
|
+
shapesGraph: this,
|
|
29
|
+
}).transform();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
7
32
|
(function (ShapesGraph) {
|
|
8
|
-
class
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (isList) {
|
|
17
|
-
isClass = true; // RDFS entailment: if A rdfs:subClassOf rdf:List then A is an rdfs:Class
|
|
18
|
-
}
|
|
19
|
-
const ancestorClassIris_ = ancestorClassIris(resource, Number.MAX_SAFE_INTEGER).filter((ancestorClassIri) => !ancestorClassIri.equals(rdf.List));
|
|
20
|
-
if (ancestorClassIris_.length > 0) {
|
|
21
|
-
isClass = true; // RDFS entailment: if A rdfs:subClassOf B then both A and B are rdfs:Class's
|
|
22
|
-
}
|
|
23
|
-
const descendantClassIris_ = descendantClassIris(resource, Number.MAX_SAFE_INTEGER);
|
|
24
|
-
if (descendantClassIris_.length > 0) {
|
|
25
|
-
isClass = true; // RDFS entailment, see above
|
|
26
|
-
}
|
|
27
|
-
return {
|
|
28
|
-
...generatedShape,
|
|
29
|
-
ancestorClassIris: ancestorClassIris_,
|
|
30
|
-
childClassIris: descendantClassIris(resource, 1),
|
|
31
|
-
descendantClassIris: descendantClassIris_,
|
|
32
|
-
isClass,
|
|
33
|
-
isList,
|
|
34
|
-
parentClassIris: ancestorClassIris(resource, 1).filter((ancestorClassIri) => !ancestorClassIri.equals(rdf.List)),
|
|
35
|
-
};
|
|
33
|
+
class Builder extends AbstractShapesGraph.AbstractBuilder {
|
|
34
|
+
typeFunctions = typeFunctions;
|
|
35
|
+
build() {
|
|
36
|
+
return new ShapesGraph({
|
|
37
|
+
nodeShapesByIdentifier: this.nodeShapesByIdentifier,
|
|
38
|
+
ontologiesByIdentifier: this.ontologiesByIdentifier,
|
|
39
|
+
propertyGroupsByIdentifier: this.propertyGroupsByIdentifier,
|
|
40
|
+
propertyShapesByIdentifier: this.propertyShapesByIdentifier,
|
|
36
41
|
});
|
|
37
42
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
});
|
|
43
|
+
nodeShape(parameters) {
|
|
44
|
+
const nodeShape = generated.NodeShape.$create(parameters);
|
|
45
|
+
this.add(nodeShape);
|
|
46
|
+
return nodeShape;
|
|
43
47
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
});
|
|
48
|
+
ontology(parameters) {
|
|
49
|
+
const ontology = generated.Ontology.$create(parameters);
|
|
50
|
+
this.add(ontology);
|
|
51
|
+
return ontology;
|
|
49
52
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}));
|
|
53
|
+
propertyGroup(parameters) {
|
|
54
|
+
const propertyGroup = generated.PropertyGroup.$create(parameters);
|
|
55
|
+
this.add(propertyGroup);
|
|
56
|
+
return propertyGroup;
|
|
57
|
+
}
|
|
58
|
+
propertyShape(parameters) {
|
|
59
|
+
const propertyShape = generated.PropertyShape.$create(parameters);
|
|
60
|
+
this.add(propertyShape);
|
|
61
|
+
return propertyShape;
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
|
-
|
|
63
|
-
function create(parameters) {
|
|
64
|
-
return factory.createShapesGraph(parameters);
|
|
65
|
-
}
|
|
66
|
-
ShapesGraph.create = create;
|
|
64
|
+
ShapesGraph.Builder = Builder;
|
|
67
65
|
})(ShapesGraph || (ShapesGraph = {}));
|
|
68
66
|
//# sourceMappingURL=ShapesGraph.js.map
|