@shaclmate/compiler 4.0.18 → 4.0.20
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 +4 -1
- package/dist/ShapesGraphToAstTransformer.d.ts +4 -1
- package/dist/ShapesGraphToAstTransformer.js +9 -6
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +1 -1
- package/dist/ast/AbstractCollectionType.d.ts +10 -0
- package/dist/ast/AbstractCollectionType.js +6 -0
- package/dist/ast/AbstractCompoundType.d.ts +0 -1
- package/dist/ast/AbstractCompoundType.js +0 -3
- package/dist/ast/AbstractContainerType.d.ts +9 -1
- package/dist/ast/AbstractContainerType.js +5 -2
- package/dist/ast/AbstractLazyObjectType.d.ts +94 -1
- package/dist/ast/AbstractLazyObjectType.js +6 -2
- package/dist/ast/AbstractTermType.d.ts +11 -1
- package/dist/ast/AbstractTermType.js +7 -2
- package/dist/ast/AbstractType.d.ts +13 -1
- package/dist/ast/AbstractType.js +13 -0
- package/dist/ast/BlankNodeType.d.ts +1 -1
- package/dist/ast/DefaultValueType.d.ts +10 -0
- package/dist/ast/DefaultValueType.js +6 -0
- package/dist/ast/IdentifierType.d.ts +1 -1
- package/dist/ast/LiteralType.d.ts +17 -1
- package/dist/ast/LiteralType.js +10 -2
- package/dist/ast/ObjectCompoundType.js +1 -2
- package/dist/ast/ObjectType.d.ts +44 -1
- package/dist/ast/ObjectType.js +33 -10
- package/dist/ast/SetType.d.ts +11 -0
- package/dist/ast/SetType.js +6 -0
- package/dist/ast/UnionType.d.ts +12 -0
- package/dist/ast/UnionType.js +11 -0
- package/dist/generators/AstJsonGenerator.d.ts +6 -0
- package/dist/generators/AstJsonGenerator.js +11 -0
- package/dist/generators/Cx2Generator.d.ts +10 -0
- package/dist/generators/Cx2Generator.js +140 -0
- package/dist/generators/LabeledPropertyGraph.d.ts +42 -0
- package/dist/generators/LabeledPropertyGraph.js +2 -0
- package/dist/generators/index.d.ts +4 -2
- package/dist/generators/index.js +4 -2
- package/dist/generators/transformAstToLabeledPropertyGraph.d.ts +4 -0
- package/dist/generators/transformAstToLabeledPropertyGraph.js +75 -0
- package/dist/generators/ts/AbstractDateType.js +1 -1
- package/dist/generators/ts/AbstractIdentifierType.d.ts +2 -2
- package/dist/generators/ts/AbstractIdentifierType.js +2 -5
- package/dist/generators/ts/AbstractNamedUnionType.js +1 -1
- package/dist/generators/ts/AbstractNumericType.js +1 -1
- package/dist/generators/ts/AbstractTermType.js +2 -2
- package/dist/generators/ts/AbstractType.d.ts +17 -14
- package/dist/generators/ts/AbstractType.js +3 -1
- package/dist/generators/ts/BlankNodeType.d.ts +2 -2
- package/dist/generators/ts/BlankNodeType.js +1 -1
- package/dist/generators/ts/BooleanType.js +1 -1
- package/dist/generators/ts/DefaultValueType.js +1 -1
- package/dist/generators/ts/IdentifierType.d.ts +2 -2
- package/dist/generators/ts/IdentifierType.js +1 -1
- package/dist/generators/ts/IriType.d.ts +1 -1
- package/dist/generators/ts/IriType.js +8 -13
- package/dist/generators/ts/LazyObjectOptionType.d.ts +1 -0
- package/dist/generators/ts/LazyObjectOptionType.js +1 -1
- package/dist/generators/ts/LazyObjectType.js +1 -1
- package/dist/generators/ts/ListType.js +5 -5
- package/dist/generators/ts/NamedObjectUnionType.js +4 -1
- package/dist/generators/ts/SetType.js +1 -1
- package/dist/generators/ts/StringType.js +1 -1
- package/dist/generators/ts/TermType.js +3 -1
- package/dist/generators/ts/TsGenerator.d.ts +5 -0
- package/dist/generators/ts/TsGenerator.js +7 -1
- package/dist/generators/ts/TypeFactory.d.ts +5 -0
- package/dist/generators/ts/TypeFactory.js +35 -5
- package/dist/generators/ts/ZodGenerator.d.ts +4 -0
- package/dist/generators/ts/ZodGenerator.js +4 -1
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +4 -1
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +3 -1
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +6 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_propertiesFromRdfResourceFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionOrMethodDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +1 -0
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +16 -16
- package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.js +6 -2
- package/dist/generators/ts/_snippets/parseIri.d.ts +2 -0
- package/dist/generators/ts/_snippets/parseIri.js +12 -0
- package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +7 -5
- package/dist/generators/ts/_snippets/snippets_parseBlankNode.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_parseBlankNode.js +12 -0
- package/dist/generators/ts/_snippets/snippets_parseIdentifier.d.ts +2 -0
- package/dist/generators/ts/_snippets/snippets_parseIdentifier.js +6 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +3 -3
- package/dist/generators/ts/imports.d.ts +2 -0
- package/dist/generators/ts/imports.js +3 -1
- package/dist/generators/ts/rdfjsTermExpression.d.ts +4 -1
- package/dist/generators/ts/rdfjsTermExpression.js +2 -3
- package/dist/generators/ts/snippets.d.ts +3 -2
- package/dist/generators/ts/snippets.js +6 -4
- package/dist/generators/ts/synthesizeUberObjectUnionType.d.ts +2 -0
- package/dist/generators/ts/synthesizeUberObjectUnionType.js +4 -0
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -3
- package/dist/input/ShapesGraph.d.ts +4 -1
- package/dist/input/ShapesGraph.js +3 -2
- package/dist/input/generated.d.ts +323 -323
- package/dist/input/generated.js +19 -20
- package/package.json +6 -9
- package/dist/generators/json/AstJsonGenerator.d.ts +0 -6
- package/dist/generators/json/AstJsonGenerator.js +0 -144
- package/dist/generators/json/index.d.ts +0 -2
- package/dist/generators/json/index.js +0 -2
- package/dist/generators/ts/_snippets/snippets_blankNodeFromString.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_blankNodeFromString.js +0 -11
- package/dist/generators/ts/_snippets/snippets_identifierFromString.d.ts +0 -2
- package/dist/generators/ts/_snippets/snippets_identifierFromString.js +0 -8
- package/dist/generators/ts/index.d.ts +0 -2
- package/dist/generators/ts/index.js +0 -2
- package/dist/logger.d.ts +0 -2
- package/dist/logger.js +0 -8
package/dist/Compiler.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { Either } from "purify-ts";
|
|
2
|
+
import type { Logger } from "ts-log";
|
|
2
3
|
import type { TsFeature } from "./enums/TsFeature.js";
|
|
3
4
|
import type { Generator } from "./generators/Generator.js";
|
|
4
5
|
import type { ShapesGraph } from "./input/ShapesGraph.js";
|
|
5
6
|
export declare class Compiler {
|
|
6
7
|
private readonly generator;
|
|
8
|
+
private readonly logger;
|
|
7
9
|
private readonly tsFeaturesDefault?;
|
|
8
|
-
constructor({ generator, }: {
|
|
10
|
+
constructor({ generator, logger, }: {
|
|
9
11
|
generator: Generator;
|
|
12
|
+
logger: Logger;
|
|
10
13
|
tsFeaturesDefault?: ReadonlySet<TsFeature>;
|
|
11
14
|
});
|
|
12
15
|
compile(shapesGraph: ShapesGraph): Either<Error, string>;
|
package/dist/Compiler.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { ShapesGraphToAstTransformer } from "./ShapesGraphToAstTransformer.js";
|
|
2
2
|
export class Compiler {
|
|
3
3
|
generator;
|
|
4
|
+
logger;
|
|
4
5
|
tsFeaturesDefault;
|
|
5
|
-
constructor({ generator, }) {
|
|
6
|
+
constructor({ generator, logger, }) {
|
|
6
7
|
this.generator = generator;
|
|
8
|
+
this.logger = logger;
|
|
7
9
|
}
|
|
8
10
|
compile(shapesGraph) {
|
|
9
11
|
return new ShapesGraphToAstTransformer({
|
|
12
|
+
logger: this.logger,
|
|
10
13
|
shapesGraph,
|
|
11
14
|
tsFeaturesDefault: this.tsFeaturesDefault,
|
|
12
15
|
})
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import TermMap from "@rdfjs/term-map";
|
|
2
2
|
import type { BlankNode, NamedNode } from "@rdfjs/types";
|
|
3
3
|
import { Either } from "purify-ts";
|
|
4
|
+
import type { Logger } from "ts-log";
|
|
4
5
|
import type * as ast from "./ast/index.js";
|
|
5
6
|
import type { TsFeature } from "./enums/TsFeature.js";
|
|
6
7
|
import type * as input from "./input/index.js";
|
|
@@ -12,10 +13,12 @@ interface RelatedNodeShapes {
|
|
|
12
13
|
}
|
|
13
14
|
export declare class ShapesGraphToAstTransformer {
|
|
14
15
|
protected readonly cachedAstTypesByShapeIdentifier: TermMap<BlankNode | NamedNode, ast.Type>;
|
|
16
|
+
protected readonly logger: Logger;
|
|
15
17
|
protected readonly shapesGraph: input.ShapesGraph;
|
|
16
18
|
protected readonly relatedNodeShapesByIdentifier: TermMap<BlankNode | NamedNode, RelatedNodeShapes>;
|
|
17
19
|
protected tsFeaturesDefault: ReadonlySet<TsFeature>;
|
|
18
|
-
constructor({ shapesGraph, tsFeaturesDefault, }: {
|
|
20
|
+
constructor({ logger, shapesGraph, tsFeaturesDefault, }: {
|
|
21
|
+
logger: Logger;
|
|
19
22
|
shapesGraph: input.ShapesGraph;
|
|
20
23
|
tsFeaturesDefault?: ReadonlySet<TsFeature>;
|
|
21
24
|
});
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import TermMap from "@rdfjs/term-map";
|
|
2
|
-
import { Resource } from "@rdfx/resource";
|
|
3
2
|
import { dash } from "@tpluscode/rdf-ns-builders";
|
|
4
3
|
import { Either } from "purify-ts";
|
|
5
4
|
import { invariant } from "ts-invariant";
|
|
6
5
|
import { ShapeStack } from "./_ShapesGraphToAstTransformer/ShapeStack.js";
|
|
7
6
|
import { transformShapeToAstType } from "./_ShapesGraphToAstTransformer/transformShapeToAstType.js";
|
|
8
|
-
|
|
9
|
-
function relatedNodeShapes(shapesGraph) {
|
|
7
|
+
function relatedNodeShapes({ logger, shapesGraph, }) {
|
|
10
8
|
const immediateRelatedNodeShapes = new TermMap();
|
|
11
9
|
for (const childNodeShape of shapesGraph.nodeShapes) {
|
|
12
10
|
let childRelatedNodeShapes = immediateRelatedNodeShapes.get(childNodeShape.$identifier);
|
|
@@ -21,7 +19,7 @@ function relatedNodeShapes(shapesGraph) {
|
|
|
21
19
|
shapesGraph
|
|
22
20
|
.nodeShape(parentClassIdentifier)
|
|
23
21
|
.ifLeft((error) => {
|
|
24
|
-
logger.error("%s is rdfs:subClassOf %s which is either missing or not a node shape: %s", childNodeShape,
|
|
22
|
+
logger.error("%s is rdfs:subClassOf %s which is either missing or not a node shape: %s", childNodeShape, parentClassIdentifier, error.message);
|
|
25
23
|
})
|
|
26
24
|
.ifRight((parentNodeShape) => {
|
|
27
25
|
childRelatedNodeShapes.parents.set(parentNodeShape.$identifier, parentNodeShape);
|
|
@@ -76,11 +74,16 @@ function relatedNodeShapes(shapesGraph) {
|
|
|
76
74
|
export class ShapesGraphToAstTransformer {
|
|
77
75
|
// Members are protected so they're accessible to functions in other files
|
|
78
76
|
cachedAstTypesByShapeIdentifier = new TermMap();
|
|
77
|
+
logger;
|
|
79
78
|
shapesGraph;
|
|
80
79
|
relatedNodeShapesByIdentifier = new TermMap();
|
|
81
80
|
tsFeaturesDefault;
|
|
82
|
-
constructor({ shapesGraph, tsFeaturesDefault, }) {
|
|
83
|
-
this.
|
|
81
|
+
constructor({ logger, shapesGraph, tsFeaturesDefault, }) {
|
|
82
|
+
this.logger = logger;
|
|
83
|
+
this.relatedNodeShapesByIdentifier = relatedNodeShapes({
|
|
84
|
+
logger: this.logger,
|
|
85
|
+
shapesGraph,
|
|
86
|
+
});
|
|
84
87
|
this.shapesGraph = shapesGraph;
|
|
85
88
|
this.tsFeaturesDefault =
|
|
86
89
|
tsFeaturesDefault ??
|
|
@@ -12,6 +12,16 @@ export declare abstract class AbstractCollectionType<ItemTypeT extends AbstractC
|
|
|
12
12
|
mutable: boolean;
|
|
13
13
|
} & ConstructorParameters<typeof AbstractContainerType<ItemTypeT>>[0]);
|
|
14
14
|
equals(other: AbstractCollectionType<ItemTypeT>): boolean;
|
|
15
|
+
toJSON(): {
|
|
16
|
+
mutable: boolean | undefined;
|
|
17
|
+
itemType: any;
|
|
18
|
+
comment: string | undefined;
|
|
19
|
+
kind: string;
|
|
20
|
+
label: string | undefined;
|
|
21
|
+
name: string | undefined;
|
|
22
|
+
recursive: boolean | undefined;
|
|
23
|
+
shapeIdentifier: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string>;
|
|
24
|
+
};
|
|
15
25
|
}
|
|
16
26
|
export declare namespace AbstractCollectionType {
|
|
17
27
|
type ItemType = AbstractContainerType.ItemType;
|
|
@@ -20,6 +20,12 @@ export class AbstractCollectionType extends AbstractContainerType {
|
|
|
20
20
|
}
|
|
21
21
|
return true;
|
|
22
22
|
}
|
|
23
|
+
toJSON() {
|
|
24
|
+
return {
|
|
25
|
+
...super.toJSON(),
|
|
26
|
+
mutable: this.mutable ? true : undefined,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
23
29
|
}
|
|
24
30
|
(function (AbstractCollectionType) {
|
|
25
31
|
AbstractCollectionType.isItemType = AbstractContainerType.isItemType;
|
|
@@ -31,7 +31,6 @@ export declare abstract class AbstractCompoundType<MemberT extends AbstractCompo
|
|
|
31
31
|
get tsFeatures(): ReadonlySet<TsFeature>;
|
|
32
32
|
addMember(member: MemberT): void;
|
|
33
33
|
equals(other: AbstractCompoundType<MemberT, MemberTypeT>): boolean;
|
|
34
|
-
toString(): string;
|
|
35
34
|
}
|
|
36
35
|
export declare namespace AbstractCompoundType {
|
|
37
36
|
interface Member<TypeT extends MemberType> {
|
|
@@ -80,9 +80,6 @@ export class AbstractCompoundType extends AbstractType {
|
|
|
80
80
|
// Don't recurse
|
|
81
81
|
return this.shapeIdentifier.equals(other.shapeIdentifier);
|
|
82
82
|
}
|
|
83
|
-
toString() {
|
|
84
|
-
return `${this.kind}(memberTypes=[${this.members.map((memberType) => memberType.toString()).join(", ")}])`;
|
|
85
|
-
}
|
|
86
83
|
}
|
|
87
84
|
__decorate([
|
|
88
85
|
Memoize()
|
|
@@ -27,7 +27,15 @@ export declare abstract class AbstractContainerType<ItemTypeT extends AbstractCo
|
|
|
27
27
|
get nodeKinds(): ReadonlySet<NodeKind>;
|
|
28
28
|
get recursive(): boolean;
|
|
29
29
|
equals(other: AbstractContainerType<ItemTypeT>): boolean;
|
|
30
|
-
|
|
30
|
+
toJSON(): {
|
|
31
|
+
itemType: any;
|
|
32
|
+
comment: string | undefined;
|
|
33
|
+
kind: string;
|
|
34
|
+
label: string | undefined;
|
|
35
|
+
name: string | undefined;
|
|
36
|
+
recursive: boolean | undefined;
|
|
37
|
+
shapeIdentifier: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string>;
|
|
38
|
+
};
|
|
31
39
|
}
|
|
32
40
|
export declare namespace AbstractContainerType {
|
|
33
41
|
type ItemType = BlankNodeType | IdentifierType | IntersectionType | IriType | ListType | LiteralType | ObjectType | TermType | UnionType;
|
|
@@ -29,8 +29,11 @@ export class AbstractContainerType extends AbstractType {
|
|
|
29
29
|
}
|
|
30
30
|
return true;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
return
|
|
32
|
+
toJSON() {
|
|
33
|
+
return {
|
|
34
|
+
...super.toJSON(),
|
|
35
|
+
itemType: this.itemType.toJSON(),
|
|
36
|
+
};
|
|
34
37
|
}
|
|
35
38
|
}
|
|
36
39
|
(function (AbstractContainerType) {
|
|
@@ -18,7 +18,100 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
|
|
|
18
18
|
get nodeKinds(): ReadonlySet<NodeKind>;
|
|
19
19
|
get recursive(): boolean;
|
|
20
20
|
equals(other: AbstractLazyObjectType<PartialTypeT, ResolveTypeT>): boolean;
|
|
21
|
-
|
|
21
|
+
toJSON(): {
|
|
22
|
+
partialType: {
|
|
23
|
+
fromRdfType: import("@rdfjs/types").NamedNode<string> | undefined;
|
|
24
|
+
identifierMintingStrategy: "blankNode" | "sha256" | "uuidv4" | undefined;
|
|
25
|
+
identifierType: {
|
|
26
|
+
hasValues: readonly import("@rdfjs/types").NamedNode<string>[] | undefined;
|
|
27
|
+
in: readonly import("@rdfjs/types").NamedNode<string>[] | undefined;
|
|
28
|
+
nodeKinds: NodeKind[];
|
|
29
|
+
comment: string | undefined;
|
|
30
|
+
kind: string;
|
|
31
|
+
label: string | undefined;
|
|
32
|
+
name: string | undefined;
|
|
33
|
+
recursive: boolean | undefined;
|
|
34
|
+
shapeIdentifier: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string>;
|
|
35
|
+
};
|
|
36
|
+
parentObjectTypes: (string | import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string>)[] | undefined;
|
|
37
|
+
synthetic: boolean | undefined;
|
|
38
|
+
toRdfTypes: readonly import("@rdfjs/types").NamedNode<string>[] | undefined;
|
|
39
|
+
comment: string | undefined;
|
|
40
|
+
kind: string;
|
|
41
|
+
label: string | undefined;
|
|
42
|
+
name: string | undefined;
|
|
43
|
+
recursive: boolean | undefined;
|
|
44
|
+
shapeIdentifier: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string>;
|
|
45
|
+
} | {
|
|
46
|
+
members: {
|
|
47
|
+
discriminantValue: string | number | undefined;
|
|
48
|
+
type: any;
|
|
49
|
+
}[] | undefined;
|
|
50
|
+
comment: string | undefined;
|
|
51
|
+
kind: string;
|
|
52
|
+
label: string | undefined;
|
|
53
|
+
name: string | undefined;
|
|
54
|
+
recursive: boolean | undefined;
|
|
55
|
+
shapeIdentifier: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string>;
|
|
56
|
+
} | {
|
|
57
|
+
itemType: any;
|
|
58
|
+
comment: string | undefined;
|
|
59
|
+
kind: string;
|
|
60
|
+
label: string | undefined;
|
|
61
|
+
name: string | undefined;
|
|
62
|
+
recursive: boolean | undefined;
|
|
63
|
+
shapeIdentifier: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string>;
|
|
64
|
+
};
|
|
65
|
+
resolveType: {
|
|
66
|
+
fromRdfType: import("@rdfjs/types").NamedNode<string> | undefined;
|
|
67
|
+
identifierMintingStrategy: "blankNode" | "sha256" | "uuidv4" | undefined;
|
|
68
|
+
identifierType: {
|
|
69
|
+
hasValues: readonly import("@rdfjs/types").NamedNode<string>[] | undefined;
|
|
70
|
+
in: readonly import("@rdfjs/types").NamedNode<string>[] | undefined;
|
|
71
|
+
nodeKinds: NodeKind[];
|
|
72
|
+
comment: string | undefined;
|
|
73
|
+
kind: string;
|
|
74
|
+
label: string | undefined;
|
|
75
|
+
name: string | undefined;
|
|
76
|
+
recursive: boolean | undefined;
|
|
77
|
+
shapeIdentifier: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string>;
|
|
78
|
+
};
|
|
79
|
+
parentObjectTypes: (string | import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string>)[] | undefined;
|
|
80
|
+
synthetic: boolean | undefined;
|
|
81
|
+
toRdfTypes: readonly import("@rdfjs/types").NamedNode<string>[] | undefined;
|
|
82
|
+
comment: string | undefined;
|
|
83
|
+
kind: string;
|
|
84
|
+
label: string | undefined;
|
|
85
|
+
name: string | undefined;
|
|
86
|
+
recursive: boolean | undefined;
|
|
87
|
+
shapeIdentifier: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string>;
|
|
88
|
+
} | {
|
|
89
|
+
members: {
|
|
90
|
+
discriminantValue: string | number | undefined;
|
|
91
|
+
type: any;
|
|
92
|
+
}[] | undefined;
|
|
93
|
+
comment: string | undefined;
|
|
94
|
+
kind: string;
|
|
95
|
+
label: string | undefined;
|
|
96
|
+
name: string | undefined;
|
|
97
|
+
recursive: boolean | undefined;
|
|
98
|
+
shapeIdentifier: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string>;
|
|
99
|
+
} | {
|
|
100
|
+
itemType: any;
|
|
101
|
+
comment: string | undefined;
|
|
102
|
+
kind: string;
|
|
103
|
+
label: string | undefined;
|
|
104
|
+
name: string | undefined;
|
|
105
|
+
recursive: boolean | undefined;
|
|
106
|
+
shapeIdentifier: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string>;
|
|
107
|
+
};
|
|
108
|
+
comment: string | undefined;
|
|
109
|
+
kind: string;
|
|
110
|
+
label: string | undefined;
|
|
111
|
+
name: string | undefined;
|
|
112
|
+
recursive: boolean | undefined;
|
|
113
|
+
shapeIdentifier: import("@rdfjs/types").BlankNode | import("@rdfjs/types").NamedNode<string>;
|
|
114
|
+
};
|
|
22
115
|
}
|
|
23
116
|
export declare namespace AbstractLazyObjectType {
|
|
24
117
|
type ObjectTypeConstraint = ObjectType | ObjectUnionType;
|
|
@@ -29,8 +29,12 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
29
29
|
}
|
|
30
30
|
return true;
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
return
|
|
32
|
+
toJSON() {
|
|
33
|
+
return {
|
|
34
|
+
...super.toJSON(),
|
|
35
|
+
partialType: this.partialType.toJSON(),
|
|
36
|
+
resolveType: this.resolveType.toJSON(),
|
|
37
|
+
};
|
|
34
38
|
}
|
|
35
39
|
}
|
|
36
40
|
//# sourceMappingURL=AbstractLazyObjectType.js.map
|
|
@@ -18,6 +18,16 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
|
|
|
18
18
|
in_: readonly ConstantTermT[];
|
|
19
19
|
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
20
20
|
equals(other: AbstractTermType<ConstantTermT, _RuntimeTermT>): boolean;
|
|
21
|
-
|
|
21
|
+
toJSON(): {
|
|
22
|
+
hasValues: readonly ConstantTermT[] | undefined;
|
|
23
|
+
in: readonly ConstantTermT[] | undefined;
|
|
24
|
+
nodeKinds: import("@shaclmate/shacl-ast").NodeKind[];
|
|
25
|
+
comment: string | undefined;
|
|
26
|
+
kind: string;
|
|
27
|
+
label: string | undefined;
|
|
28
|
+
name: string | undefined;
|
|
29
|
+
recursive: boolean | undefined;
|
|
30
|
+
shapeIdentifier: BlankNode | NamedNode<string>;
|
|
31
|
+
};
|
|
22
32
|
}
|
|
23
33
|
//# sourceMappingURL=AbstractTermType.d.ts.map
|
|
@@ -35,8 +35,13 @@ export class AbstractTermType extends AbstractType {
|
|
|
35
35
|
}
|
|
36
36
|
return true;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
return
|
|
38
|
+
toJSON() {
|
|
39
|
+
return {
|
|
40
|
+
...super.toJSON(),
|
|
41
|
+
hasValues: this.hasValues.length > 0 ? this.hasValues : undefined,
|
|
42
|
+
in: this.in_.length > 0 ? this.in_ : undefined,
|
|
43
|
+
nodeKinds: [...this.nodeKinds],
|
|
44
|
+
};
|
|
40
45
|
}
|
|
41
46
|
}
|
|
42
47
|
//# sourceMappingURL=AbstractTermType.js.map
|
|
@@ -9,6 +9,10 @@ export declare abstract class AbstractType {
|
|
|
9
9
|
* Documentation comment from rdfs:comment.
|
|
10
10
|
*/
|
|
11
11
|
readonly comment: Maybe<string>;
|
|
12
|
+
/**
|
|
13
|
+
* Type discriminant
|
|
14
|
+
*/
|
|
15
|
+
abstract readonly kind: string;
|
|
12
16
|
/**
|
|
13
17
|
* Human-readable label from rdfs:label.
|
|
14
18
|
*/
|
|
@@ -38,6 +42,14 @@ export declare abstract class AbstractType {
|
|
|
38
42
|
shapeIdentifier: BlankNode | NamedNode;
|
|
39
43
|
});
|
|
40
44
|
equals(other: AbstractType): boolean;
|
|
41
|
-
|
|
45
|
+
toJSON(): {
|
|
46
|
+
comment: string | undefined;
|
|
47
|
+
kind: string;
|
|
48
|
+
label: string | undefined;
|
|
49
|
+
name: string | undefined;
|
|
50
|
+
recursive: boolean | undefined;
|
|
51
|
+
shapeIdentifier: BlankNode | NamedNode<string>;
|
|
52
|
+
};
|
|
53
|
+
toString(): string;
|
|
42
54
|
}
|
|
43
55
|
//# sourceMappingURL=AbstractType.d.ts.map
|
package/dist/ast/AbstractType.js
CHANGED
|
@@ -35,5 +35,18 @@ export class AbstractType {
|
|
|
35
35
|
}
|
|
36
36
|
return true;
|
|
37
37
|
}
|
|
38
|
+
toJSON() {
|
|
39
|
+
return {
|
|
40
|
+
comment: this.comment.extract(),
|
|
41
|
+
kind: this.kind,
|
|
42
|
+
label: this.label.extract(),
|
|
43
|
+
name: this.name.extract(),
|
|
44
|
+
recursive: this.recursive ? true : undefined,
|
|
45
|
+
shapeIdentifier: this.shapeIdentifier,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
toString() {
|
|
49
|
+
return JSON.stringify(this.toJSON());
|
|
50
|
+
}
|
|
38
51
|
}
|
|
39
52
|
//# sourceMappingURL=AbstractType.js.map
|
|
@@ -6,6 +6,6 @@ import { AbstractTermType } from "./AbstractTermType.js";
|
|
|
6
6
|
export declare class BlankNodeType extends AbstractTermType<NamedNode, BlankNode> {
|
|
7
7
|
readonly kind = "BlankNodeType";
|
|
8
8
|
readonly nodeKinds: ReadonlySet<"BlankNode">;
|
|
9
|
-
constructor(superParameters:
|
|
9
|
+
constructor(superParameters: Omit<ConstructorParameters<typeof AbstractTermType<NamedNode, BlankNode>>[0], "hasValues" | "in_">);
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=BlankNodeType.d.ts.map
|
|
@@ -17,6 +17,16 @@ export declare class DefaultValueType<ItemTypeT extends DefaultValueType.ItemTyp
|
|
|
17
17
|
defaultValue: Literal | NamedNode;
|
|
18
18
|
});
|
|
19
19
|
equals(other: DefaultValueType<ItemTypeT>): boolean;
|
|
20
|
+
toJSON(): {
|
|
21
|
+
defaultValue: Literal | NamedNode<string>;
|
|
22
|
+
itemType: any;
|
|
23
|
+
comment: string | undefined;
|
|
24
|
+
kind: string;
|
|
25
|
+
label: string | undefined;
|
|
26
|
+
name: string | undefined;
|
|
27
|
+
recursive: boolean | undefined;
|
|
28
|
+
shapeIdentifier: import("@rdfjs/types").BlankNode | NamedNode<string>;
|
|
29
|
+
};
|
|
20
30
|
}
|
|
21
31
|
export declare namespace DefaultValueType {
|
|
22
32
|
type ItemType = Exclude<AbstractContainerType.ItemType, BlankNodeType>;
|
|
@@ -30,6 +30,12 @@ export class DefaultValueType extends AbstractContainerType {
|
|
|
30
30
|
}
|
|
31
31
|
return true;
|
|
32
32
|
}
|
|
33
|
+
toJSON() {
|
|
34
|
+
return {
|
|
35
|
+
...super.toJSON(),
|
|
36
|
+
defaultValue: this.defaultValue,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
(function (DefaultValueType) {
|
|
35
41
|
function isItemType(type) {
|
|
@@ -7,6 +7,6 @@ import { AbstractTermType } from "./AbstractTermType.js";
|
|
|
7
7
|
export declare class IdentifierType extends AbstractTermType<NamedNode, BlankNode | NamedNode> {
|
|
8
8
|
readonly kind = "IdentifierType";
|
|
9
9
|
readonly nodeKinds: ReadonlySet<IdentifierNodeKind>;
|
|
10
|
-
constructor(superParameters:
|
|
10
|
+
constructor(superParameters: Omit<ConstructorParameters<typeof AbstractTermType<NamedNode, BlankNode>>[0], "hasValues" | "in_">);
|
|
11
11
|
}
|
|
12
12
|
//# sourceMappingURL=IdentifierType.d.ts.map
|
|
@@ -19,6 +19,22 @@ export declare class LiteralType extends AbstractTermType<Literal, Literal> {
|
|
|
19
19
|
minInclusive: Maybe<Literal>;
|
|
20
20
|
} & Omit<ConstructorParameters<typeof AbstractTermType<Literal, Literal>>[0], "nodeKinds">);
|
|
21
21
|
equals(other: AbstractTermType<Literal, Literal>): boolean;
|
|
22
|
-
|
|
22
|
+
toJSON(): {
|
|
23
|
+
datatype: NamedNode<string> | undefined;
|
|
24
|
+
languageIn: readonly string[] | undefined;
|
|
25
|
+
maxExclusive: Literal | undefined;
|
|
26
|
+
maxInclusive: Literal | undefined;
|
|
27
|
+
minExclusive: Literal | undefined;
|
|
28
|
+
minInclusive: Literal | undefined;
|
|
29
|
+
hasValues: readonly Literal[] | undefined;
|
|
30
|
+
in: readonly Literal[] | undefined;
|
|
31
|
+
nodeKinds: import("@shaclmate/shacl-ast").NodeKind[];
|
|
32
|
+
comment: string | undefined;
|
|
33
|
+
kind: string;
|
|
34
|
+
label: string | undefined;
|
|
35
|
+
name: string | undefined;
|
|
36
|
+
recursive: boolean | undefined;
|
|
37
|
+
shapeIdentifier: import("@rdfjs/types").BlankNode | NamedNode<string>;
|
|
38
|
+
};
|
|
23
39
|
}
|
|
24
40
|
//# sourceMappingURL=LiteralType.d.ts.map
|
package/dist/ast/LiteralType.js
CHANGED
|
@@ -43,8 +43,16 @@ export class LiteralType extends AbstractTermType {
|
|
|
43
43
|
}
|
|
44
44
|
return true;
|
|
45
45
|
}
|
|
46
|
-
|
|
47
|
-
return
|
|
46
|
+
toJSON() {
|
|
47
|
+
return {
|
|
48
|
+
...super.toJSON(),
|
|
49
|
+
datatype: this.datatype.extract(),
|
|
50
|
+
languageIn: this.languageIn.length > 0 ? this.languageIn : undefined,
|
|
51
|
+
maxExclusive: this.maxExclusive.extract(),
|
|
52
|
+
maxInclusive: this.maxInclusive.extract(),
|
|
53
|
+
minExclusive: this.minExclusive.extract(),
|
|
54
|
+
minInclusive: this.minInclusive.extract(),
|
|
55
|
+
};
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
const nodeKinds = new Set(["Literal"]);
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import TermSet from "@rdfjs/term-set";
|
|
2
|
-
import { Resource } from "@rdfx/resource";
|
|
3
2
|
import { Maybe } from "purify-ts";
|
|
4
3
|
import { invariant } from "ts-invariant";
|
|
5
4
|
import { BlankNodeType } from "./BlankNodeType.js";
|
|
@@ -79,7 +78,7 @@ export var ObjectCompoundType;
|
|
|
79
78
|
}
|
|
80
79
|
if (fromRdfTypes.size > 0 &&
|
|
81
80
|
fromRdfTypes.size !== expectUniqueFromRdfTypesCount) {
|
|
82
|
-
throw new Error(`one or more ${objectCompoundType} members ([${memberObjectTypes_.map((memberType) => memberType.toString()).join(", ")}]) lack distinguishing fromRdfType's ({${[...fromRdfTypes].
|
|
81
|
+
throw new Error(`one or more ${objectCompoundType} members ([${memberObjectTypes_.map((memberType) => memberType.toString()).join(", ")}]) lack distinguishing fromRdfType's ({${[...fromRdfTypes].join(", ")}})`);
|
|
83
82
|
}
|
|
84
83
|
return memberObjectTypes_;
|
|
85
84
|
}
|
package/dist/ast/ObjectType.d.ts
CHANGED
|
@@ -98,7 +98,30 @@ export declare class ObjectType extends AbstractType {
|
|
|
98
98
|
addProperties(...properties: readonly ObjectType.Property[]): void;
|
|
99
99
|
equals(other: ObjectType): boolean;
|
|
100
100
|
sortProperties(): void;
|
|
101
|
-
|
|
101
|
+
toJSON(): {
|
|
102
|
+
fromRdfType: NamedNode<string> | undefined;
|
|
103
|
+
identifierMintingStrategy: "blankNode" | "sha256" | "uuidv4" | undefined;
|
|
104
|
+
identifierType: {
|
|
105
|
+
hasValues: readonly NamedNode<string>[] | undefined;
|
|
106
|
+
in: readonly NamedNode<string>[] | undefined;
|
|
107
|
+
nodeKinds: NodeKind[];
|
|
108
|
+
comment: string | undefined;
|
|
109
|
+
kind: string;
|
|
110
|
+
label: string | undefined;
|
|
111
|
+
name: string | undefined;
|
|
112
|
+
recursive: boolean | undefined;
|
|
113
|
+
shapeIdentifier: BlankNode | NamedNode<string>;
|
|
114
|
+
};
|
|
115
|
+
parentObjectTypes: (string | BlankNode | NamedNode<string>)[] | undefined;
|
|
116
|
+
synthetic: boolean | undefined;
|
|
117
|
+
toRdfTypes: readonly NamedNode<string>[] | undefined;
|
|
118
|
+
comment: string | undefined;
|
|
119
|
+
kind: string;
|
|
120
|
+
label: string | undefined;
|
|
121
|
+
name: string | undefined;
|
|
122
|
+
recursive: boolean | undefined;
|
|
123
|
+
shapeIdentifier: BlankNode | NamedNode<string>;
|
|
124
|
+
};
|
|
102
125
|
}
|
|
103
126
|
export declare namespace ObjectType {
|
|
104
127
|
class Property {
|
|
@@ -165,6 +188,26 @@ export declare namespace ObjectType {
|
|
|
165
188
|
* Does the property directly or indirectly reference the ObjectType itself?
|
|
166
189
|
*/
|
|
167
190
|
get recursive(): boolean;
|
|
191
|
+
toJSON(): {
|
|
192
|
+
comment: string | undefined;
|
|
193
|
+
description: string | undefined;
|
|
194
|
+
label: string | undefined;
|
|
195
|
+
mutable: boolean | undefined;
|
|
196
|
+
name: string;
|
|
197
|
+
order: number;
|
|
198
|
+
path: string;
|
|
199
|
+
recursive: boolean | undefined;
|
|
200
|
+
shapeIdentifier: BlankNode | NamedNode<string>;
|
|
201
|
+
type: {
|
|
202
|
+
comment: string | undefined;
|
|
203
|
+
kind: string;
|
|
204
|
+
label: string | undefined;
|
|
205
|
+
name: string | undefined;
|
|
206
|
+
recursive: boolean | undefined;
|
|
207
|
+
shapeIdentifier: BlankNode | NamedNode<string>;
|
|
208
|
+
};
|
|
209
|
+
visibility: Visibility;
|
|
210
|
+
};
|
|
168
211
|
toString(): string;
|
|
169
212
|
}
|
|
170
213
|
}
|
package/dist/ast/ObjectType.js
CHANGED
|
@@ -4,7 +4,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { PropertyPath
|
|
7
|
+
import { PropertyPath } from "@rdfx/resource";
|
|
8
|
+
import { NTriplesIdentifier } from "@rdfx/string";
|
|
8
9
|
import genericToposort from "toposort";
|
|
9
10
|
import { invariant } from "ts-invariant";
|
|
10
11
|
import { Memoize } from "typescript-memoize";
|
|
@@ -166,8 +167,19 @@ export class ObjectType extends AbstractType {
|
|
|
166
167
|
return 0;
|
|
167
168
|
});
|
|
168
169
|
}
|
|
169
|
-
|
|
170
|
-
return
|
|
170
|
+
toJSON() {
|
|
171
|
+
return {
|
|
172
|
+
...super.toJSON(),
|
|
173
|
+
fromRdfType: this.fromRdfType.extract(),
|
|
174
|
+
identifierMintingStrategy: this.identifierMintingStrategy.extract(),
|
|
175
|
+
identifierType: this.identifierType.toJSON(),
|
|
176
|
+
parentObjectTypes: this.parentObjectTypes.length > 0
|
|
177
|
+
? this.parentObjectTypes.map((parentObjectType) => parentObjectType.name.extract() ??
|
|
178
|
+
parentObjectType.shapeIdentifier)
|
|
179
|
+
: undefined,
|
|
180
|
+
synthetic: this.synthetic ? true : undefined,
|
|
181
|
+
toRdfTypes: this.toRdfTypes.length > 0 ? this.toRdfTypes : undefined,
|
|
182
|
+
};
|
|
171
183
|
}
|
|
172
184
|
}
|
|
173
185
|
const nodeKinds = new Set(["BlankNode", "IRI"]);
|
|
@@ -350,8 +362,23 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
|
|
|
350
362
|
}
|
|
351
363
|
return helper([{ objectType: rootObjectType, property: rootProperty }]);
|
|
352
364
|
}
|
|
365
|
+
toJSON() {
|
|
366
|
+
return {
|
|
367
|
+
comment: this.comment.extract(),
|
|
368
|
+
description: this.description.extract(),
|
|
369
|
+
label: this.label.extract(),
|
|
370
|
+
mutable: this.mutable ? true : undefined,
|
|
371
|
+
name: this.name,
|
|
372
|
+
order: this.order,
|
|
373
|
+
path: PropertyPath.toString(this.path),
|
|
374
|
+
recursive: this.recursive ? true : undefined,
|
|
375
|
+
shapeIdentifier: this.shapeIdentifier,
|
|
376
|
+
type: this.type.toJSON(),
|
|
377
|
+
visibility: this.visibility,
|
|
378
|
+
};
|
|
379
|
+
}
|
|
353
380
|
toString() {
|
|
354
|
-
return
|
|
381
|
+
return JSON.stringify(this.toJSON());
|
|
355
382
|
}
|
|
356
383
|
}
|
|
357
384
|
__decorate([
|
|
@@ -365,18 +392,14 @@ const nodeKinds = new Set(["BlankNode", "IRI"]);
|
|
|
365
392
|
const objectTypeGraphNodes = [];
|
|
366
393
|
const objectTypeGraphEdges = [];
|
|
367
394
|
for (const objectType of objectTypes) {
|
|
368
|
-
const objectTypeShapeIdentifier =
|
|
395
|
+
const objectTypeShapeIdentifier = NTriplesIdentifier.stringify(objectType.shapeIdentifier);
|
|
369
396
|
invariant(!objectTypesByShapeIdentifier[objectTypeShapeIdentifier]);
|
|
370
397
|
objectTypesByShapeIdentifier[objectTypeShapeIdentifier] = objectType;
|
|
371
398
|
objectTypeGraphNodes.push(objectTypeShapeIdentifier);
|
|
372
399
|
for (const parentAstObjectType of objectType.parentObjectTypes) {
|
|
373
|
-
// console.log(
|
|
374
|
-
// objectTypeShapeIdentifier,
|
|
375
|
-
// Resource.Identifier.toString(parentAstObjectType.shapeIdentifier),
|
|
376
|
-
// );
|
|
377
400
|
objectTypeGraphEdges.push([
|
|
378
401
|
objectTypeShapeIdentifier,
|
|
379
|
-
|
|
402
|
+
NTriplesIdentifier.stringify(parentAstObjectType.shapeIdentifier),
|
|
380
403
|
]);
|
|
381
404
|
}
|
|
382
405
|
}
|