@shaclmate/compiler 4.0.14 → 4.0.16
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/ast/ObjectCompoundType.js +1 -1
- package/dist/ast/ObjectType.d.ts +1 -1
- package/dist/ast/ObjectType.js +1 -1
- package/dist/generators/json/AstJsonGenerator.js +1 -1
- 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/DefaultValueType.js +1 -1
- package/dist/generators/ts/NamedObjectUnionType.js +1 -1
- package/dist/generators/ts/SetType.d.ts +1 -0
- package/dist/generators/ts/SetType.js +12 -0
- package/dist/generators/ts/TypeFactory.js +1 -1
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +1 -1
- package/dist/generators/ts/imports.js +4 -4
- package/dist/input/ShapesGraph.d.ts +38 -21
- package/dist/input/ShapesGraph.js +56 -58
- package/dist/input/generated.d.ts +211 -46
- package/dist/input/generated.js +2283 -677
- package/dist/input/index.d.ts +1 -3
- package/dist/input/index.js +1 -3
- package/package.json +5 -10
- 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,27 +1,44 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AbstractShapesGraph } from "@shaclmate/shacl-ast";
|
|
2
2
|
import type { Either } from "purify-ts";
|
|
3
|
-
import type {
|
|
3
|
+
import type { Ast } from "../ast/Ast.js";
|
|
4
|
+
import type { TsFeature } from "../enums/TsFeature.js";
|
|
5
|
+
import type { Generator } from "../generators/Generator.js";
|
|
4
6
|
import * as generated from "./generated.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
export declare class ShapesGraph extends AbstractShapesGraph<generated.NodeShape, generated.Ontology, generated.PropertyGroup, generated.PropertyShape> {
|
|
8
|
+
protected readonly typeFunctions: {
|
|
9
|
+
readonly NodeShape: typeof generated.NodeShape;
|
|
10
|
+
readonly Ontology: typeof generated.Ontology;
|
|
11
|
+
readonly PropertyGroup: typeof generated.PropertyGroup;
|
|
12
|
+
readonly PropertyShape: typeof generated.PropertyShape;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Compile the shapes graph using the given generator and return the generator's output.
|
|
16
|
+
*/
|
|
17
|
+
compile(parameters: {
|
|
18
|
+
generator: Generator;
|
|
19
|
+
tsFeaturesDefault?: ReadonlySet<TsFeature>;
|
|
20
|
+
}): Either<Error, string>;
|
|
21
|
+
static builder(): ShapesGraph.Builder;
|
|
22
|
+
/**
|
|
23
|
+
* Transform the shapes graph to an AST.
|
|
24
|
+
*/
|
|
25
|
+
toAst(options?: {
|
|
26
|
+
tsFeaturesDefault?: ReadonlySet<TsFeature>;
|
|
27
|
+
}): Either<Error, Ast>;
|
|
28
|
+
}
|
|
8
29
|
export declare namespace ShapesGraph {
|
|
9
|
-
class
|
|
10
|
-
protected
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
resource: Resource;
|
|
22
|
-
}): Either<Error, generated.PropertyShape>;
|
|
30
|
+
class Builder extends AbstractShapesGraph.AbstractBuilder<generated.NodeShape, generated.Ontology, generated.PropertyGroup, generated.PropertyShape> {
|
|
31
|
+
protected readonly typeFunctions: {
|
|
32
|
+
readonly NodeShape: typeof generated.NodeShape;
|
|
33
|
+
readonly Ontology: typeof generated.Ontology;
|
|
34
|
+
readonly PropertyGroup: typeof generated.PropertyGroup;
|
|
35
|
+
readonly PropertyShape: typeof generated.PropertyShape;
|
|
36
|
+
};
|
|
37
|
+
build(): ShapesGraph;
|
|
38
|
+
nodeShape(parameters?: Parameters<typeof generated.NodeShape.$create>[0]): generated.NodeShape;
|
|
39
|
+
ontology(parameters?: Parameters<typeof generated.Ontology.$create>[0]): generated.Ontology;
|
|
40
|
+
propertyGroup(parameters?: Parameters<typeof generated.PropertyGroup.$create>[0]): generated.PropertyGroup;
|
|
41
|
+
propertyShape(parameters: Parameters<typeof generated.PropertyShape.$create>[0]): generated.PropertyShape;
|
|
23
42
|
}
|
|
24
|
-
export function create(parameters: Parameters<Factory["createShapesGraph"]>[0]): Either<Error, ShapesGraph>;
|
|
25
|
-
export {};
|
|
26
43
|
}
|
|
27
44
|
//# sourceMappingURL=ShapesGraph.d.ts.map
|
|
@@ -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
|