@shaclmate/compiler 4.0.18 → 4.0.19
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/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 +154 -1
- package/dist/ast/AbstractLazyObjectType.js +6 -2
- package/dist/ast/AbstractTermType.d.ts +41 -1
- package/dist/ast/AbstractTermType.js +8 -2
- package/dist/ast/AbstractType.d.ts +13 -1
- package/dist/ast/AbstractType.js +14 -0
- package/dist/ast/DefaultValueType.d.ts +25 -0
- package/dist/ast/DefaultValueType.js +7 -0
- package/dist/ast/LiteralType.d.ts +107 -1
- package/dist/ast/LiteralType.js +12 -2
- package/dist/ast/ObjectType.d.ts +74 -1
- package/dist/ast/ObjectType.js +30 -3
- 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/ast/termToJson.d.ts +18 -0
- package/dist/ast/termToJson.js +18 -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 +76 -0
- package/dist/index.d.ts +1 -4
- package/dist/index.js +1 -3
- package/package.json +2 -4
- 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/index.d.ts +0 -2
- package/dist/generators/ts/index.js +0 -2
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
import { Resource } from "@rdfx/resource";
|
|
2
|
-
function termToJson(term) {
|
|
3
|
-
switch (term.termType) {
|
|
4
|
-
case "BlankNode":
|
|
5
|
-
return { termType: term.termType, value: term.value };
|
|
6
|
-
case "Literal":
|
|
7
|
-
return {
|
|
8
|
-
datatype: term.datatype.value,
|
|
9
|
-
language: term.language,
|
|
10
|
-
termType: term.termType,
|
|
11
|
-
value: term.value,
|
|
12
|
-
};
|
|
13
|
-
case "NamedNode":
|
|
14
|
-
return { termType: term.termType, value: term.value };
|
|
15
|
-
default:
|
|
16
|
-
throw new Error(`unsupported term type: ${term.termType}`);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function typeToJson(type) {
|
|
20
|
-
const common = {
|
|
21
|
-
kind: type.kind,
|
|
22
|
-
comment: type.comment.extract(),
|
|
23
|
-
label: type.label.extract(),
|
|
24
|
-
};
|
|
25
|
-
switch (type.kind) {
|
|
26
|
-
case "BlankNodeType":
|
|
27
|
-
case "IdentifierType":
|
|
28
|
-
case "IriType":
|
|
29
|
-
return {
|
|
30
|
-
...common,
|
|
31
|
-
hasValue: type.hasValues.length > 0
|
|
32
|
-
? type.hasValues.map(termToJson)
|
|
33
|
-
: undefined,
|
|
34
|
-
nodeKinds: [...type.nodeKinds],
|
|
35
|
-
};
|
|
36
|
-
case "IntersectionType":
|
|
37
|
-
return {
|
|
38
|
-
...common,
|
|
39
|
-
members: type.members.map((member) => ({
|
|
40
|
-
type: typeToJson(member.type),
|
|
41
|
-
})),
|
|
42
|
-
name: type.name.extract(),
|
|
43
|
-
shapeIdentifier: Resource.Identifier.toString(type.shapeIdentifier),
|
|
44
|
-
};
|
|
45
|
-
case "LazyObjectOptionType":
|
|
46
|
-
case "LazyObjectSetType":
|
|
47
|
-
case "LazyObjectType":
|
|
48
|
-
return {
|
|
49
|
-
...common,
|
|
50
|
-
partialType: typeToJson(type.partialType),
|
|
51
|
-
resolveType: typeToJson(type.resolveType),
|
|
52
|
-
};
|
|
53
|
-
case "ListType": {
|
|
54
|
-
return {
|
|
55
|
-
...common,
|
|
56
|
-
itemType: typeToJson(type.itemType),
|
|
57
|
-
mutable: type.mutable,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
case "LiteralType": {
|
|
61
|
-
return {
|
|
62
|
-
...common,
|
|
63
|
-
datatype: type.datatype.extract(),
|
|
64
|
-
hasValue: type.hasValues.length > 0
|
|
65
|
-
? type.hasValues.map(termToJson)
|
|
66
|
-
: undefined,
|
|
67
|
-
maxExclusive: type.maxExclusive.map(termToJson).extract(),
|
|
68
|
-
maxInclusive: type.maxInclusive.map(termToJson).extract(),
|
|
69
|
-
minExclusive: type.minExclusive.map(termToJson).extract(),
|
|
70
|
-
minInclusive: type.minInclusive.map(termToJson).extract(),
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
case "ObjectType":
|
|
74
|
-
return {
|
|
75
|
-
...common,
|
|
76
|
-
name: type.name.extract(),
|
|
77
|
-
shapeIdentifier: Resource.Identifier.toString(type.shapeIdentifier),
|
|
78
|
-
fromRdfType: type.fromRdfType.map(termToJson).extract(),
|
|
79
|
-
parentObjectTypes: type.parentObjectTypes.length > 0
|
|
80
|
-
? type.parentObjectTypes.map((type) => Resource.Identifier.toString(type.shapeIdentifier))
|
|
81
|
-
: undefined,
|
|
82
|
-
identifierMintingStrategy: type.identifierMintingStrategy.extract(),
|
|
83
|
-
identifierType: typeToJson(type.identifierType),
|
|
84
|
-
synthetic: type.synthetic ? true : undefined,
|
|
85
|
-
toRdfTypes: type.toRdfTypes.length > 0
|
|
86
|
-
? type.toRdfTypes.map(termToJson)
|
|
87
|
-
: undefined,
|
|
88
|
-
};
|
|
89
|
-
case "DefaultValueType":
|
|
90
|
-
case "OptionType":
|
|
91
|
-
return {
|
|
92
|
-
...common,
|
|
93
|
-
itemType: typeToJson(type.itemType),
|
|
94
|
-
};
|
|
95
|
-
case "SetType":
|
|
96
|
-
return {
|
|
97
|
-
...common,
|
|
98
|
-
itemType: typeToJson(type.itemType),
|
|
99
|
-
};
|
|
100
|
-
case "TermType":
|
|
101
|
-
return {
|
|
102
|
-
...common,
|
|
103
|
-
};
|
|
104
|
-
case "UnionType":
|
|
105
|
-
return {
|
|
106
|
-
...common,
|
|
107
|
-
members: type.members.map((member) => ({
|
|
108
|
-
discriminantValue: member.discriminantValue.extract(),
|
|
109
|
-
type: typeToJson(member.type),
|
|
110
|
-
})),
|
|
111
|
-
name: type.name.extract(),
|
|
112
|
-
shapeIdentifier: Resource.Identifier.toString(type.shapeIdentifier),
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
export class AstJsonGenerator {
|
|
117
|
-
generate(ast) {
|
|
118
|
-
return JSON.stringify({
|
|
119
|
-
objectTypes: ast.namedObjectTypes.map((objectType) => ({
|
|
120
|
-
kind: objectType.kind,
|
|
121
|
-
comment: objectType.comment.extract(),
|
|
122
|
-
identifierMintingStrategy: objectType.identifierMintingStrategy.extract(),
|
|
123
|
-
identifierType: typeToJson(objectType.identifierType),
|
|
124
|
-
label: objectType.label.extract(),
|
|
125
|
-
name: objectType.name.extract(),
|
|
126
|
-
shapeIdentifier: Resource.Identifier.toString(objectType.shapeIdentifier),
|
|
127
|
-
properties: objectType.properties.map((property) => ({
|
|
128
|
-
comment: property.comment.extract(),
|
|
129
|
-
description: property.description.extract(),
|
|
130
|
-
label: property.label.extract(),
|
|
131
|
-
mutable: property.mutable,
|
|
132
|
-
name: property.name,
|
|
133
|
-
order: property.order,
|
|
134
|
-
path: property.path,
|
|
135
|
-
recursive: property.recursive ? true : undefined,
|
|
136
|
-
shapeIdentifier: Resource.Identifier.toString(property.shapeIdentifier),
|
|
137
|
-
type: typeToJson(property.type),
|
|
138
|
-
visibility: property.visibility,
|
|
139
|
-
})),
|
|
140
|
-
})),
|
|
141
|
-
}, undefined, 2);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
//# sourceMappingURL=AstJsonGenerator.js.map
|