@shaclmate/compiler 2.0.13 → 2.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/Compiler.d.ts +15 -0
- package/Compiler.js +20 -0
- package/ShapesGraphToAstTransformer.d.ts +18 -23
- package/ShapesGraphToAstTransformer.js +21 -447
- package/_ShapesGraphToAstTransformer/NodeShapeAstType.d.ts +3 -0
- package/_ShapesGraphToAstTransformer/NodeShapeAstType.js +2 -0
- package/_ShapesGraphToAstTransformer/index.d.ts +10 -0
- package/_ShapesGraphToAstTransformer/index.js +10 -0
- package/_ShapesGraphToAstTransformer/pickLiteral.d.ts +4 -0
- package/_ShapesGraphToAstTransformer/pickLiteral.js +18 -0
- package/_ShapesGraphToAstTransformer/propertyShapeNodeKinds.d.ts +4 -0
- package/_ShapesGraphToAstTransformer/propertyShapeNodeKinds.js +26 -0
- package/_ShapesGraphToAstTransformer/shapeAstName.d.ts +5 -0
- package/_ShapesGraphToAstTransformer/shapeAstName.js +28 -0
- package/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +6 -0
- package/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +165 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.d.ts +13 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.js +198 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.d.ts +12 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.js +29 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.d.ts +12 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.js +43 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.d.ts +6 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +31 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.d.ts +14 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.js +21 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.d.ts +16 -0
- package/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.js +58 -0
- package/ast/Ast.d.ts +5 -0
- package/ast/CompositeType.d.ts +13 -0
- package/ast/CompositeType.js +2 -0
- package/ast/IdentifierType.d.ts +3 -6
- package/ast/IntersectionType.d.ts +2 -2
- package/ast/ListType.d.ts +53 -0
- package/ast/ListType.js +2 -0
- package/ast/LiteralType.d.ts +4 -3
- package/ast/Name.d.ts +1 -0
- package/ast/ObjectCompositeType.d.ts +22 -0
- package/ast/ObjectCompositeType.js +2 -0
- package/ast/ObjectIntersectionType.d.ts +8 -0
- package/ast/ObjectIntersectionType.js +2 -0
- package/ast/ObjectType.d.ts +91 -19
- package/ast/ObjectType.js +26 -1
- package/ast/ObjectUnionType.d.ts +19 -0
- package/ast/ObjectUnionType.js +2 -0
- package/ast/PlaceholderType.d.ts +7 -0
- package/ast/PlaceholderType.js +2 -0
- package/ast/SetType.d.ts +1 -1
- package/ast/TermType.d.ts +11 -0
- package/ast/TermType.js +2 -0
- package/ast/Type.d.ts +11 -3
- package/ast/UnionType.d.ts +3 -3
- package/ast/index.d.ts +6 -3
- package/ast/index.js +6 -3
- package/enums/MintingStrategy.d.ts +5 -0
- package/enums/MintingStrategy.js +2 -0
- package/enums/PropertyVisibility.d.ts +2 -0
- package/enums/PropertyVisibility.js +2 -0
- package/enums/TsFeature.d.ts +5 -0
- package/enums/TsFeature.js +16 -0
- package/enums/TsObjectDeclarationType.d.ts +5 -0
- package/enums/TsObjectDeclarationType.js +2 -0
- package/enums/index.d.ts +5 -0
- package/enums/index.js +5 -0
- package/generators/Generator.d.ts +5 -0
- package/generators/Generator.js +2 -0
- package/generators/index.d.ts +2 -2
- package/generators/index.js +2 -2
- package/generators/json/AstJsonGenerator.d.ts +4 -5
- package/generators/json/AstJsonGenerator.js +31 -22
- package/generators/ts/BooleanType.d.ts +7 -3
- package/generators/ts/BooleanType.js +58 -4
- package/generators/ts/DateTimeType.d.ts +17 -0
- package/generators/ts/DateTimeType.js +58 -0
- package/generators/ts/DeclaredType.d.ts +17 -0
- package/generators/ts/DeclaredType.js +10 -0
- package/generators/ts/IdentifierType.d.ts +7 -17
- package/generators/ts/IdentifierType.js +69 -60
- package/generators/ts/Import.d.ts +18 -0
- package/generators/ts/Import.js +59 -0
- package/generators/ts/ListType.d.ts +18 -8
- package/generators/ts/ListType.js +197 -43
- package/generators/ts/LiteralType.d.ts +13 -11
- package/generators/ts/LiteralType.js +36 -51
- package/generators/ts/NumberType.d.ts +7 -3
- package/generators/ts/NumberType.js +55 -4
- package/generators/ts/ObjectType.d.ts +47 -25
- package/generators/ts/ObjectType.js +222 -49
- package/generators/ts/ObjectUnionType.d.ts +58 -0
- package/generators/ts/ObjectUnionType.js +481 -0
- package/generators/ts/OptionType.d.ts +12 -4
- package/generators/ts/OptionType.js +65 -16
- package/generators/ts/PrimitiveType.d.ts +15 -5
- package/generators/ts/PrimitiveType.js +20 -29
- package/generators/ts/SetType.d.ts +12 -4
- package/generators/ts/SetType.js +103 -29
- package/generators/ts/StringType.d.ts +8 -3
- package/generators/ts/StringType.js +57 -3
- package/generators/ts/TermType.d.ts +52 -0
- package/generators/ts/TermType.js +234 -0
- package/generators/ts/TsGenerator.d.ts +4 -12
- package/generators/ts/TsGenerator.js +44 -100
- package/generators/ts/Type.d.ts +107 -46
- package/generators/ts/Type.js +78 -61
- package/generators/ts/TypeFactory.d.ts +4 -5
- package/generators/ts/TypeFactory.js +212 -89
- package/generators/ts/UnionType.d.ts +19 -6
- package/generators/ts/UnionType.js +230 -120
- package/generators/ts/_ObjectType/IdentifierProperty.d.ts +27 -7
- package/generators/ts/_ObjectType/IdentifierProperty.js +143 -31
- package/generators/ts/_ObjectType/Property.d.ts +125 -9
- package/generators/ts/_ObjectType/Property.js +25 -3
- package/generators/ts/_ObjectType/ShaclProperty.d.ts +23 -5
- package/generators/ts/_ObjectType/ShaclProperty.js +100 -26
- package/generators/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +24 -6
- package/generators/ts/_ObjectType/TypeDiscriminatorProperty.js +75 -13
- package/generators/ts/_ObjectType/classDeclaration.d.ts +2 -1
- package/generators/ts/_ObjectType/classDeclaration.js +79 -111
- package/generators/ts/_ObjectType/createFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/createFunctionDeclaration.js +60 -0
- package/generators/ts/_ObjectType/equalsFunctionDeclaration.d.ts +2 -1
- package/generators/ts/_ObjectType/equalsFunctionDeclaration.js +12 -20
- package/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.d.ts +11 -0
- package/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +70 -0
- package/generators/ts/_ObjectType/fromJsonFunctionDeclarations.d.ts +4 -0
- package/generators/ts/_ObjectType/fromJsonFunctionDeclarations.js +78 -0
- package/generators/ts/_ObjectType/fromRdfFunctionDeclarations.d.ts +4 -0
- package/generators/ts/_ObjectType/fromRdfFunctionDeclarations.js +91 -0
- package/generators/ts/_ObjectType/hashFunctionDeclaration.d.ts +3 -3
- package/generators/ts/_ObjectType/hashFunctionDeclaration.js +11 -55
- package/generators/ts/_ObjectType/hashFunctionOrMethodDeclaration.d.ts +11 -0
- package/generators/ts/_ObjectType/hashFunctionOrMethodDeclaration.js +64 -0
- package/generators/ts/_ObjectType/index.d.ts +8 -2
- package/generators/ts/_ObjectType/index.js +8 -2
- package/generators/ts/_ObjectType/interfaceDeclaration.d.ts +3 -2
- package/generators/ts/_ObjectType/interfaceDeclaration.js +11 -2
- package/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.js +19 -0
- package/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.js +31 -0
- package/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.js +37 -0
- package/generators/ts/_ObjectType/rdfjsTermExpression.d.ts +6 -0
- package/generators/ts/{rdfjsTermExpression.js → _ObjectType/rdfjsTermExpression.js} +3 -1
- package/generators/ts/_ObjectType/sparqlFunctionDeclarations.d.ts +4 -0
- package/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +101 -0
- package/generators/ts/_ObjectType/toJsonFunctionDeclaration.d.ts +5 -0
- package/generators/ts/_ObjectType/toJsonFunctionDeclaration.js +19 -0
- package/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.d.ts +10 -0
- package/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +59 -0
- package/generators/ts/_ObjectType/toJsonReturnType.d.ts +3 -0
- package/generators/ts/_ObjectType/toJsonReturnType.js +19 -0
- package/generators/ts/_ObjectType/toRdfFunctionDeclaration.d.ts +3 -2
- package/generators/ts/_ObjectType/toRdfFunctionDeclaration.js +11 -45
- package/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.d.ts +10 -0
- package/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +67 -0
- package/generators/ts/objectInitializer.d.ts +2 -0
- package/generators/ts/objectInitializer.js +14 -0
- package/generators/ts/tsComment.d.ts +5 -0
- package/generators/ts/tsComment.js +11 -0
- package/generators/ts/tsName.d.ts +1 -1
- package/generators/ts/tsName.js +1 -0
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/input/NodeShape.d.ts +46 -0
- package/input/NodeShape.js +165 -0
- package/input/Ontology.d.ts +13 -0
- package/input/Ontology.js +30 -0
- package/input/PropertyShape.d.ts +15 -0
- package/input/PropertyShape.js +34 -0
- package/input/Shape.d.ts +4 -0
- package/input/Shape.js +2 -0
- package/input/ShapesGraph.d.ts +9 -0
- package/input/ShapesGraph.js +50 -0
- package/input/ancestorClassIris.d.ts +4 -0
- package/input/ancestorClassIris.js +21 -0
- package/input/descendantClassIris.d.ts +4 -0
- package/input/descendantClassIris.js +21 -0
- package/input/generated.d.ts +274 -0
- package/input/generated.js +1420 -0
- package/input/index.d.ts +7 -0
- package/input/index.js +7 -0
- package/input/tsFeatures.d.ts +10 -0
- package/input/tsFeatures.js +42 -0
- package/package.json +14 -8
- package/ast/MintingStrategy.d.ts +0 -8
- package/ast/MintingStrategy.js +0 -9
- package/generators/ts/Configuration.d.ts +0 -29
- package/generators/ts/Configuration.js +0 -40
- package/generators/ts/IntersectionType.d.ts +0 -14
- package/generators/ts/IntersectionType.js +0 -26
- package/generators/ts/RdfjsTermType.d.ts +0 -25
- package/generators/ts/RdfjsTermType.js +0 -46
- package/generators/ts/_ObjectType/fromRdfFunctionDeclaration.d.ts +0 -4
- package/generators/ts/_ObjectType/fromRdfFunctionDeclaration.js +0 -72
- package/generators/ts/_ObjectType/sparqlGraphPatternsClassDeclaration.d.ts +0 -4
- package/generators/ts/_ObjectType/sparqlGraphPatternsClassDeclaration.js +0 -46
- package/generators/ts/rdfjsTermExpression.d.ts +0 -5
- package/vocabularies/dashDataset.d.ts +0 -3
- package/vocabularies/dashDataset.js +0 -2370
- package/vocabularies/index.d.ts +0 -2
- package/vocabularies/index.js +0 -2
- package/vocabularies/shaclmate.d.ts +0 -15
- package/vocabularies/shaclmate.js +0 -6
|
@@ -1,58 +1,120 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { invariant } from "ts-invariant";
|
|
3
|
+
import { Import } from "../Import.js";
|
|
4
4
|
import { Property } from "./Property.js";
|
|
5
5
|
export class IdentifierProperty extends Property {
|
|
6
|
-
constructor({ mintingStrategy, ...superParameters }) {
|
|
6
|
+
constructor({ abstract, classDeclarationVisibility, lazyObjectTypeMutable, mintingStrategy, objectTypeDeclarationType, override, ...superParameters }) {
|
|
7
7
|
super(superParameters);
|
|
8
8
|
this.equalsFunction = "purifyHelpers.Equatable.booleanEquals";
|
|
9
|
-
this.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
this.mutable = false;
|
|
10
|
+
invariant(this.visibility === "public");
|
|
11
|
+
this.abstract = abstract;
|
|
12
|
+
this.classDeclarationVisibility = classDeclarationVisibility;
|
|
13
|
+
if (mintingStrategy.isJust()) {
|
|
14
|
+
this.mintingStrategy = mintingStrategy.unsafeCoerce();
|
|
15
|
+
}
|
|
16
|
+
else if (this.type.nodeKinds.has("BlankNode")) {
|
|
17
|
+
this.mintingStrategy = "blankNode";
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
this.mintingStrategy = "none";
|
|
21
|
+
}
|
|
22
|
+
this.objectTypeDeclarationType = objectTypeDeclarationType;
|
|
23
|
+
this.lazyObjectTypeMutable = lazyObjectTypeMutable;
|
|
24
|
+
this.override = override;
|
|
18
25
|
}
|
|
19
26
|
get classGetAccessorDeclaration() {
|
|
20
|
-
if (
|
|
27
|
+
if (this.abstract) {
|
|
21
28
|
return Maybe.empty();
|
|
22
29
|
}
|
|
23
30
|
let mintIdentifier;
|
|
24
|
-
switch (this.mintingStrategy
|
|
25
|
-
case
|
|
31
|
+
switch (this.mintingStrategy) {
|
|
32
|
+
case "blankNode":
|
|
33
|
+
mintIdentifier = "dataFactory.blankNode()";
|
|
34
|
+
break;
|
|
35
|
+
case "none":
|
|
36
|
+
// If there's no minting strategy the identifier will be required by the constructor and assigned to a public property.
|
|
37
|
+
return Maybe.empty();
|
|
38
|
+
case "sha256":
|
|
26
39
|
mintIdentifier =
|
|
27
40
|
"dataFactory.namedNode(`urn:shaclmate:object:${this.type}:${this.hash(sha256.create())}`)";
|
|
28
41
|
break;
|
|
29
|
-
case
|
|
42
|
+
case "uuidv4":
|
|
30
43
|
mintIdentifier =
|
|
31
44
|
"dataFactory.namedNode(`urn:shaclmate:object:${this.type}:${uuid.v4()}`)";
|
|
32
45
|
break;
|
|
33
46
|
}
|
|
34
47
|
return Maybe.of({
|
|
48
|
+
leadingTrivia: this.override ? "override " : undefined,
|
|
35
49
|
name: this.name,
|
|
36
50
|
returnType: this.type.name,
|
|
37
51
|
statements: [
|
|
38
|
-
|
|
52
|
+
this.lazyObjectTypeMutable()
|
|
53
|
+
? `return (typeof this._${this.name} !== "undefined") ? this._${this.name} : ${mintIdentifier}`
|
|
54
|
+
: `if (typeof this._${this.name} === "undefined") { this._${this.name} = ${mintIdentifier}; } return this._${this.name};`,
|
|
39
55
|
],
|
|
40
56
|
});
|
|
41
57
|
}
|
|
42
58
|
get classPropertyDeclaration() {
|
|
43
|
-
if (this.
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
if (this.abstract) {
|
|
60
|
+
// Abstract version of the accessor
|
|
61
|
+
// Work around a ts-morph bug that puts the override keyword before the abstract keyword
|
|
62
|
+
return Maybe.of({
|
|
63
|
+
hasOverrideKeyword: this.abstract && this.override ? undefined : this.override,
|
|
64
|
+
isAbstract: this.abstract && this.override ? undefined : this.abstract,
|
|
65
|
+
isReadonly: true,
|
|
66
|
+
leadingTrivia: this.abstract && this.override ? "abstract override " : undefined,
|
|
67
|
+
name: this.name,
|
|
68
|
+
type: this.type.name,
|
|
69
|
+
});
|
|
50
70
|
}
|
|
51
|
-
|
|
71
|
+
// See note in TypeFactory re: the logic of whether to declare the identifier in the class or not.
|
|
72
|
+
if (!this.classDeclarationVisibility.isJust()) {
|
|
73
|
+
return Maybe.empty();
|
|
74
|
+
}
|
|
75
|
+
switch (this.mintingStrategy) {
|
|
76
|
+
case "none":
|
|
77
|
+
// Immutable, public identifier property, no getter
|
|
78
|
+
return Maybe.of({
|
|
79
|
+
name: this.name,
|
|
80
|
+
type: this.type.name,
|
|
81
|
+
});
|
|
82
|
+
default:
|
|
83
|
+
// Mutable _identifier property that will be lazily initialized by the getter to mint the identifier
|
|
84
|
+
return Maybe.of({
|
|
85
|
+
name: `_${this.name}`,
|
|
86
|
+
scope: this.classDeclarationVisibility
|
|
87
|
+
.map(Property.visibilityToScope)
|
|
88
|
+
.unsafeCoerce(),
|
|
89
|
+
type: `${this.type.name} | undefined`,
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
get constructorParametersPropertySignature() {
|
|
94
|
+
if (this.objectTypeDeclarationType === "class" && this.abstract) {
|
|
95
|
+
return Maybe.empty();
|
|
96
|
+
}
|
|
97
|
+
return Maybe.of({
|
|
98
|
+
hasQuestionToken: this.objectTypeDeclarationType === "class" &&
|
|
99
|
+
this.mintingStrategy !== "none",
|
|
52
100
|
isReadonly: true,
|
|
53
101
|
name: this.name,
|
|
54
102
|
type: this.type.name,
|
|
55
|
-
};
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
get declarationImports() {
|
|
106
|
+
const imports = this.type.useImports.concat();
|
|
107
|
+
if (this.objectTypeDeclarationType === "class") {
|
|
108
|
+
switch (this.mintingStrategy) {
|
|
109
|
+
case "sha256":
|
|
110
|
+
imports.push(Import.SHA256);
|
|
111
|
+
break;
|
|
112
|
+
case "uuidv4":
|
|
113
|
+
imports.push(Import.UUID);
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return imports;
|
|
56
118
|
}
|
|
57
119
|
get interfacePropertySignature() {
|
|
58
120
|
return {
|
|
@@ -61,19 +123,69 @@ export class IdentifierProperty extends Property {
|
|
|
61
123
|
type: this.type.name,
|
|
62
124
|
};
|
|
63
125
|
}
|
|
126
|
+
get jsonPropertySignature() {
|
|
127
|
+
return {
|
|
128
|
+
isReadonly: true,
|
|
129
|
+
name: "@id",
|
|
130
|
+
type: "string",
|
|
131
|
+
};
|
|
132
|
+
}
|
|
64
133
|
classConstructorStatements({ variables, }) {
|
|
134
|
+
if (this.abstract) {
|
|
135
|
+
return [];
|
|
136
|
+
}
|
|
137
|
+
return this.classPropertyDeclaration
|
|
138
|
+
.map((classPropertyDeclaration) => [
|
|
139
|
+
`this.${classPropertyDeclaration.name} = ${variables.parameter};`,
|
|
140
|
+
])
|
|
141
|
+
.orDefault([]);
|
|
142
|
+
}
|
|
143
|
+
fromJsonStatements({ variables, }) {
|
|
65
144
|
return [
|
|
66
|
-
`
|
|
145
|
+
`const ${this.name} = ${this.type.fromJsonExpression({ variables: { value: variables.jsonObject } })};`,
|
|
67
146
|
];
|
|
68
147
|
}
|
|
69
148
|
fromRdfStatements({ variables, }) {
|
|
70
149
|
return [`const ${this.name} = ${variables.resource}.identifier`];
|
|
71
150
|
}
|
|
72
|
-
hashStatements(
|
|
73
|
-
return
|
|
151
|
+
hashStatements() {
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
interfaceConstructorStatements({ variables, }) {
|
|
155
|
+
return [`const ${this.name} = ${variables.parameter}`];
|
|
74
156
|
}
|
|
75
|
-
|
|
76
|
-
return Maybe.
|
|
157
|
+
jsonUiSchemaElement({ variables, }) {
|
|
158
|
+
return Maybe.of(`{ label: "Identifier", scope: \`\${${variables.scopePrefix}}/properties/${this.jsonPropertySignature.name}\`, type: "Control" }`);
|
|
159
|
+
}
|
|
160
|
+
jsonZodSchema({ variables, }) {
|
|
161
|
+
return {
|
|
162
|
+
key: this.jsonPropertySignature.name,
|
|
163
|
+
schema: `${variables.zod}.string().min(1)`,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
sparqlConstructTemplateTriples() {
|
|
167
|
+
return [];
|
|
168
|
+
}
|
|
169
|
+
sparqlWherePatterns() {
|
|
170
|
+
return [];
|
|
171
|
+
}
|
|
172
|
+
toJsonObjectMember({ variables, }) {
|
|
173
|
+
const nodeKinds = [...this.type.nodeKinds];
|
|
174
|
+
const valueToNodeKinds = nodeKinds.map((nodeKind) => {
|
|
175
|
+
switch (nodeKind) {
|
|
176
|
+
case "BlankNode":
|
|
177
|
+
return `\`_:\${${variables.value}.value}\``;
|
|
178
|
+
case "NamedNode":
|
|
179
|
+
return `${variables.value}.value`;
|
|
180
|
+
default:
|
|
181
|
+
throw new RangeError(nodeKind);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
if (valueToNodeKinds.length === 1) {
|
|
185
|
+
return `"@id": ${valueToNodeKinds[0]}`;
|
|
186
|
+
}
|
|
187
|
+
invariant(valueToNodeKinds.length === 2);
|
|
188
|
+
return `"@id": ${variables.value}.termType === "${nodeKinds[0]}" ? ${valueToNodeKinds[0]} : ${valueToNodeKinds[1]}`;
|
|
77
189
|
}
|
|
78
190
|
toRdfStatements() {
|
|
79
191
|
return [];
|
|
@@ -1,38 +1,154 @@
|
|
|
1
|
+
import type { BlankNode, Literal, NamedNode, Variable } from "@rdfjs/types";
|
|
1
2
|
import type { Maybe } from "purify-ts";
|
|
2
|
-
import type
|
|
3
|
-
import type {
|
|
3
|
+
import { type GetAccessorDeclarationStructure, type OptionalKind, type PropertyDeclarationStructure, type PropertySignatureStructure, Scope } from "ts-morph";
|
|
4
|
+
import type { PropertyVisibility } from "../../../enums/index.js";
|
|
5
|
+
import type { Import } from "../Import.js";
|
|
4
6
|
import type { Type } from "../Type.js";
|
|
5
7
|
export declare abstract class Property<TypeT extends {
|
|
8
|
+
readonly mutable: boolean;
|
|
6
9
|
readonly name: string;
|
|
7
10
|
}> {
|
|
8
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Optional get accessor to include in a class declaration of the object type.
|
|
13
|
+
*/
|
|
9
14
|
abstract readonly classGetAccessorDeclaration: Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
|
|
10
|
-
|
|
15
|
+
/**
|
|
16
|
+
* Optional property declaration to include in a class declaration of the object type.
|
|
17
|
+
*/
|
|
18
|
+
abstract readonly classPropertyDeclaration: Maybe<OptionalKind<PropertyDeclarationStructure>>;
|
|
19
|
+
/**
|
|
20
|
+
* Optional property to include in the parameters object of a class constructor.
|
|
21
|
+
*/
|
|
22
|
+
abstract readonly constructorParametersPropertySignature: Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
23
|
+
/**
|
|
24
|
+
* Function declaration that takes two values of the property and compares them, returning and purifyHelpers.Equatable.EqualsResult.
|
|
25
|
+
*/
|
|
11
26
|
abstract readonly equalsFunction: string;
|
|
27
|
+
/**
|
|
28
|
+
* Signature of the property in an interface version of the object.
|
|
29
|
+
*/
|
|
12
30
|
abstract readonly interfacePropertySignature: OptionalKind<PropertySignatureStructure>;
|
|
31
|
+
/**
|
|
32
|
+
* Signature of the property when serialized to JSON (the type of toJsonObjectMember).
|
|
33
|
+
*/
|
|
34
|
+
abstract readonly jsonPropertySignature: OptionalKind<PropertySignatureStructure>;
|
|
35
|
+
/**
|
|
36
|
+
* Is the property reassignable?
|
|
37
|
+
*/
|
|
38
|
+
abstract readonly mutable: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* TypeScript identifier-safe name of the property.
|
|
41
|
+
*/
|
|
13
42
|
readonly name: string;
|
|
43
|
+
/**
|
|
44
|
+
* Property type
|
|
45
|
+
. */
|
|
14
46
|
readonly type: TypeT;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Property visibility: private, protected, public.
|
|
49
|
+
*/
|
|
50
|
+
readonly visibility: PropertyVisibility;
|
|
51
|
+
protected readonly dataFactoryVariable: string;
|
|
52
|
+
constructor({ dataFactoryVariable, name, type, visibility, }: {
|
|
53
|
+
dataFactoryVariable: string;
|
|
18
54
|
name: string;
|
|
19
55
|
type: TypeT;
|
|
56
|
+
visibility: PropertyVisibility;
|
|
20
57
|
});
|
|
21
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Imports this property requires when declared in an object.
|
|
60
|
+
*/
|
|
61
|
+
get declarationImports(): readonly Import[];
|
|
62
|
+
protected static visibilityToScope(visibility: PropertyVisibility): Scope | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Statements to assign the parameter of described by constructorParametersPropertySignature to a class member.
|
|
65
|
+
*/
|
|
22
66
|
abstract classConstructorStatements(parameters: {
|
|
23
67
|
variables: {
|
|
24
68
|
parameter: string;
|
|
25
69
|
};
|
|
26
70
|
}): readonly string[];
|
|
71
|
+
/**
|
|
72
|
+
* Statements to deserialize JSON for this property (as described by toJsonObjectMember) to a typed value of the property.
|
|
73
|
+
*/
|
|
74
|
+
abstract fromJsonStatements(parameters: {
|
|
75
|
+
variables: {
|
|
76
|
+
jsonObject: string;
|
|
77
|
+
};
|
|
78
|
+
}): readonly string[];
|
|
79
|
+
/**
|
|
80
|
+
* Statements to deserialize RDF for this property to a typed value of the property.
|
|
81
|
+
*/
|
|
27
82
|
abstract fromRdfStatements(parameters: {
|
|
28
83
|
variables: {
|
|
84
|
+
context: string;
|
|
85
|
+
languageIn: string;
|
|
29
86
|
resource: string;
|
|
30
87
|
};
|
|
31
88
|
}): readonly string[];
|
|
89
|
+
/**
|
|
90
|
+
* Statements to hash this property using a hasher instance.
|
|
91
|
+
*/
|
|
32
92
|
abstract hashStatements(parameters: Parameters<Type["hashStatements"]>[0]): readonly string[];
|
|
33
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Companion to classConstructorStatements with a similar purpose in an interface's create() function.
|
|
95
|
+
*/
|
|
96
|
+
abstract interfaceConstructorStatements(parameters: {
|
|
97
|
+
variables: {
|
|
98
|
+
parameter: string;
|
|
99
|
+
};
|
|
100
|
+
}): readonly string[];
|
|
101
|
+
/**
|
|
102
|
+
* Element object (usually a control https://jsonforms.io/docs/uischema/controls) for a JSON Forms UI schema.
|
|
103
|
+
*/
|
|
104
|
+
abstract jsonUiSchemaElement(parameters: {
|
|
105
|
+
variables: {
|
|
106
|
+
scopePrefix: string;
|
|
107
|
+
};
|
|
108
|
+
}): Maybe<string>;
|
|
109
|
+
/**
|
|
110
|
+
* zod Object key: schema pair on the property serialized by toJsonObjectMember.
|
|
111
|
+
*/
|
|
112
|
+
abstract jsonZodSchema(parameters: {
|
|
113
|
+
variables: {
|
|
114
|
+
zod: string;
|
|
115
|
+
};
|
|
116
|
+
}): {
|
|
117
|
+
readonly key: string;
|
|
118
|
+
readonly schema: string;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* An array of SPARQL.js CONSTRUCT template triples for this property as strings (so they can incorporate runtime calls).
|
|
122
|
+
*/
|
|
123
|
+
abstract sparqlConstructTemplateTriples(parameters: {
|
|
124
|
+
variables: {
|
|
125
|
+
subject: string;
|
|
126
|
+
variablePrefix: string;
|
|
127
|
+
};
|
|
128
|
+
}): readonly string[];
|
|
129
|
+
/**
|
|
130
|
+
* An array of SPARQL.js where patterns for this property as strings (so they can incorporate runtime calls).
|
|
131
|
+
*/
|
|
132
|
+
abstract sparqlWherePatterns(parameters: {
|
|
133
|
+
variables: {
|
|
134
|
+
subject: string;
|
|
135
|
+
variablePrefix: string;
|
|
136
|
+
};
|
|
137
|
+
}): readonly string[];
|
|
138
|
+
/**
|
|
139
|
+
* property: expression to serialize a property to a JSON object member.
|
|
140
|
+
*/
|
|
141
|
+
abstract toJsonObjectMember(parameters: {
|
|
142
|
+
variables: {
|
|
143
|
+
value: string;
|
|
144
|
+
};
|
|
145
|
+
}): string;
|
|
146
|
+
/**
|
|
147
|
+
* Statements to serialize this property to an RDF resource.
|
|
148
|
+
*/
|
|
34
149
|
abstract toRdfStatements(parameters: {
|
|
35
150
|
variables: Omit<Parameters<Type["toRdfExpression"]>[0]["variables"], "predicate">;
|
|
36
151
|
}): readonly string[];
|
|
152
|
+
protected rdfjsTermExpression(rdfjsTerm: Omit<BlankNode, "equals"> | Omit<Literal, "equals"> | Omit<NamedNode, "equals"> | Omit<Variable, "equals">): string;
|
|
37
153
|
}
|
|
38
154
|
//# sourceMappingURL=Property.d.ts.map
|
|
@@ -1,11 +1,33 @@
|
|
|
1
|
+
import { Scope, } from "ts-morph";
|
|
2
|
+
import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
|
|
1
3
|
export class Property {
|
|
2
|
-
constructor({
|
|
3
|
-
this.
|
|
4
|
+
constructor({ dataFactoryVariable, name, type, visibility, }) {
|
|
5
|
+
this.dataFactoryVariable = dataFactoryVariable;
|
|
4
6
|
this.name = name;
|
|
5
7
|
this.type = type;
|
|
8
|
+
this.visibility = visibility;
|
|
6
9
|
}
|
|
7
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Imports this property requires when declared in an object.
|
|
12
|
+
*/
|
|
13
|
+
get declarationImports() {
|
|
8
14
|
return [];
|
|
9
15
|
}
|
|
16
|
+
static visibilityToScope(visibility) {
|
|
17
|
+
switch (visibility) {
|
|
18
|
+
case "private":
|
|
19
|
+
return Scope.Private;
|
|
20
|
+
case "protected":
|
|
21
|
+
return Scope.Protected;
|
|
22
|
+
case "public":
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
rdfjsTermExpression(rdfjsTerm) {
|
|
27
|
+
return rdfjsTermExpression({
|
|
28
|
+
dataFactoryVariable: this.dataFactoryVariable,
|
|
29
|
+
rdfjsTerm,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
10
32
|
}
|
|
11
33
|
//# sourceMappingURL=Property.js.map
|
|
@@ -1,25 +1,43 @@
|
|
|
1
1
|
import type * as rdfjs from "@rdfjs/types";
|
|
2
2
|
import { Maybe } from "purify-ts";
|
|
3
3
|
import type { GetAccessorDeclarationStructure, OptionalKind, PropertyDeclarationStructure, PropertySignatureStructure } from "ts-morph";
|
|
4
|
+
import type { IdentifierType } from "../IdentifierType.js";
|
|
5
|
+
import type { Import } from "../Import.js";
|
|
4
6
|
import type { Type } from "../Type.js";
|
|
5
7
|
import { Property } from "./Property.js";
|
|
6
8
|
export declare class ShaclProperty extends Property<Type> {
|
|
9
|
+
readonly mutable: boolean;
|
|
10
|
+
private readonly comment;
|
|
11
|
+
private readonly description;
|
|
12
|
+
private readonly label;
|
|
7
13
|
private readonly path;
|
|
8
|
-
constructor({ path, ...superParameters }: {
|
|
14
|
+
constructor({ comment, description, label, mutable, path, ...superParameters }: {
|
|
15
|
+
comment: Maybe<string>;
|
|
16
|
+
description: Maybe<string>;
|
|
17
|
+
label: Maybe<string>;
|
|
18
|
+
mutable: boolean;
|
|
9
19
|
path: rdfjs.NamedNode;
|
|
10
20
|
type: Type;
|
|
11
21
|
} & ConstructorParameters<typeof Property>[0]);
|
|
12
|
-
get classConstructorParametersPropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
13
22
|
get classGetAccessorDeclaration(): Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
|
|
14
|
-
get classPropertyDeclaration(): OptionalKind<PropertyDeclarationStructure
|
|
23
|
+
get classPropertyDeclaration(): Maybe<OptionalKind<PropertyDeclarationStructure>>;
|
|
24
|
+
get constructorParametersPropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
25
|
+
get declarationImports(): readonly Import[];
|
|
15
26
|
get equalsFunction(): string;
|
|
16
|
-
get importStatements(): readonly string[];
|
|
17
27
|
get interfacePropertySignature(): OptionalKind<PropertySignatureStructure>;
|
|
28
|
+
get jsonPropertySignature(): OptionalKind<PropertySignatureStructure>;
|
|
29
|
+
private get declarationComment();
|
|
18
30
|
private get pathExpression();
|
|
19
31
|
classConstructorStatements({ variables, }: Parameters<Property<Type>["classConstructorStatements"]>[0]): readonly string[];
|
|
32
|
+
fromJsonStatements({ variables, }: Parameters<Property<IdentifierType>["fromJsonStatements"]>[0]): readonly string[];
|
|
20
33
|
fromRdfStatements({ variables, }: Parameters<Property<Type>["fromRdfStatements"]>[0]): readonly string[];
|
|
21
34
|
hashStatements(parameters: Parameters<Property<Type>["hashStatements"]>[0]): readonly string[];
|
|
22
|
-
|
|
35
|
+
interfaceConstructorStatements({ variables, }: Parameters<Property<Type>["interfaceConstructorStatements"]>[0]): readonly string[];
|
|
36
|
+
jsonUiSchemaElement({ variables, }: Parameters<Property<Type>["jsonUiSchemaElement"]>[0]): Maybe<string>;
|
|
37
|
+
jsonZodSchema(parameters: Parameters<Property<Type>["jsonZodSchema"]>[0]): ReturnType<Property<Type>["jsonZodSchema"]>;
|
|
38
|
+
sparqlConstructTemplateTriples({ variables, }: Parameters<Property<Type>["sparqlConstructTemplateTriples"]>[0]): readonly string[];
|
|
39
|
+
sparqlWherePatterns({ variables, }: Parameters<Property<Type>["sparqlWherePatterns"]>[0]): readonly string[];
|
|
40
|
+
toJsonObjectMember(parameters: Parameters<Property<Type>["toJsonObjectMember"]>[0]): string;
|
|
23
41
|
toRdfStatements({ variables, }: Parameters<Property<Type>["toRdfStatements"]>[0]): readonly string[];
|
|
24
42
|
}
|
|
25
43
|
//# sourceMappingURL=ShaclProperty.d.ts.map
|
|
@@ -7,13 +7,30 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { pascalCase } from "change-case";
|
|
8
8
|
import { Maybe } from "purify-ts";
|
|
9
9
|
import { Memoize } from "typescript-memoize";
|
|
10
|
+
import { tsComment } from "../tsComment.js";
|
|
10
11
|
import { Property } from "./Property.js";
|
|
11
12
|
export class ShaclProperty extends Property {
|
|
12
|
-
constructor({ path, ...superParameters }) {
|
|
13
|
+
constructor({ comment, description, label, mutable, path, ...superParameters }) {
|
|
13
14
|
super(superParameters);
|
|
15
|
+
this.comment = comment;
|
|
16
|
+
this.description = description;
|
|
17
|
+
this.label = label;
|
|
18
|
+
this.mutable = mutable;
|
|
14
19
|
this.path = path;
|
|
15
20
|
}
|
|
16
|
-
get
|
|
21
|
+
get classGetAccessorDeclaration() {
|
|
22
|
+
return Maybe.empty();
|
|
23
|
+
}
|
|
24
|
+
get classPropertyDeclaration() {
|
|
25
|
+
return Maybe.of({
|
|
26
|
+
isReadonly: !this.mutable,
|
|
27
|
+
leadingTrivia: this.declarationComment,
|
|
28
|
+
name: this.name,
|
|
29
|
+
scope: Property.visibilityToScope(this.visibility),
|
|
30
|
+
type: this.type.name,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
get constructorParametersPropertySignature() {
|
|
17
34
|
let hasQuestionToken = false;
|
|
18
35
|
const typeNames = new Set(); // Remove duplicates with a set
|
|
19
36
|
for (const conversion of this.type.conversions) {
|
|
@@ -27,35 +44,41 @@ export class ShaclProperty extends Property {
|
|
|
27
44
|
return Maybe.of({
|
|
28
45
|
hasQuestionToken,
|
|
29
46
|
isReadonly: true,
|
|
47
|
+
leadingTrivia: this.declarationComment,
|
|
30
48
|
name: this.name,
|
|
31
49
|
type: [...typeNames].sort().join(" | "),
|
|
32
50
|
});
|
|
33
51
|
}
|
|
34
|
-
get
|
|
35
|
-
return
|
|
52
|
+
get declarationImports() {
|
|
53
|
+
return this.type.useImports;
|
|
36
54
|
}
|
|
37
|
-
get
|
|
55
|
+
get equalsFunction() {
|
|
56
|
+
return this.type.equalsFunction;
|
|
57
|
+
}
|
|
58
|
+
get interfacePropertySignature() {
|
|
38
59
|
return {
|
|
39
|
-
isReadonly:
|
|
60
|
+
isReadonly: !this.mutable,
|
|
61
|
+
leadingTrivia: this.declarationComment,
|
|
40
62
|
name: this.name,
|
|
41
63
|
type: this.type.name,
|
|
42
64
|
};
|
|
43
65
|
}
|
|
44
|
-
get
|
|
45
|
-
return this.type.equalsFunction();
|
|
46
|
-
}
|
|
47
|
-
get importStatements() {
|
|
48
|
-
return this.type.importStatements;
|
|
49
|
-
}
|
|
50
|
-
get interfacePropertySignature() {
|
|
66
|
+
get jsonPropertySignature() {
|
|
51
67
|
return {
|
|
52
68
|
isReadonly: true,
|
|
53
69
|
name: this.name,
|
|
54
|
-
type: this.type.
|
|
70
|
+
type: this.type.jsonName,
|
|
55
71
|
};
|
|
56
72
|
}
|
|
73
|
+
get declarationComment() {
|
|
74
|
+
return this.comment
|
|
75
|
+
.alt(this.description)
|
|
76
|
+
.alt(this.label)
|
|
77
|
+
.map(tsComment)
|
|
78
|
+
.extract();
|
|
79
|
+
}
|
|
57
80
|
get pathExpression() {
|
|
58
|
-
return `${this.
|
|
81
|
+
return `${this.dataFactoryVariable}.namedNode("${this.path.value}")`;
|
|
59
82
|
}
|
|
60
83
|
classConstructorStatements({ variables, }) {
|
|
61
84
|
const typeConversions = this.type.conversions;
|
|
@@ -64,12 +87,17 @@ export class ShaclProperty extends Property {
|
|
|
64
87
|
}
|
|
65
88
|
const statements = [];
|
|
66
89
|
for (const conversion of this.type.conversions) {
|
|
67
|
-
statements.push(`if (${conversion.sourceTypeCheckExpression
|
|
90
|
+
statements.push(`if (${conversion.sourceTypeCheckExpression(variables.parameter)}) { this.${this.name} = ${conversion.conversionExpression(variables.parameter)}; }`);
|
|
68
91
|
}
|
|
69
92
|
// We shouldn't need this else, since the parameter now has the never type, but have to add it to appease the TypeScript compiler
|
|
70
|
-
statements.push(`{ this.${this.name} = ${variables.parameter}
|
|
93
|
+
statements.push(`{ this.${this.name} =( ${variables.parameter}) as never;\n }`);
|
|
71
94
|
return [statements.join(" else ")];
|
|
72
95
|
}
|
|
96
|
+
fromJsonStatements({ variables, }) {
|
|
97
|
+
return [
|
|
98
|
+
`const ${this.name} = ${this.type.fromJsonExpression({ variables: { value: `${variables.jsonObject}["${this.name}"]` } })};`,
|
|
99
|
+
];
|
|
100
|
+
}
|
|
73
101
|
fromRdfStatements({ variables, }) {
|
|
74
102
|
return [
|
|
75
103
|
`const _${this.name}Either: purify.Either<rdfjsResource.Resource.ValueError, ${this.type.name}> = ${this.type.fromRdfExpression({ variables: { ...variables, predicate: this.pathExpression, resourceValues: `${variables.resource}.values(${this.pathExpression}, { unique: true })` } })};`,
|
|
@@ -80,17 +108,63 @@ export class ShaclProperty extends Property {
|
|
|
80
108
|
hashStatements(parameters) {
|
|
81
109
|
return this.type.hashStatements(parameters);
|
|
82
110
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
111
|
+
interfaceConstructorStatements({ variables, }) {
|
|
112
|
+
const typeConversions = this.type.conversions;
|
|
113
|
+
if (typeConversions.length === 1) {
|
|
114
|
+
return [`const ${this.name} = ${variables.parameter};`];
|
|
115
|
+
}
|
|
116
|
+
const statements = [`let ${this.name}: ${this.type.name};`];
|
|
117
|
+
const conversionBranches = [];
|
|
118
|
+
for (const conversion of this.type.conversions) {
|
|
119
|
+
conversionBranches.push(`if (${conversion.sourceTypeCheckExpression(variables.parameter)}) { ${this.name} = ${conversion.conversionExpression(variables.parameter)}; }`);
|
|
120
|
+
}
|
|
121
|
+
// We shouldn't need this else, since the parameter now has the never type, but have to add it to appease the TypeScript compiler
|
|
122
|
+
conversionBranches.push(`{ ${this.name} =( ${variables.parameter}) as never;\n }`);
|
|
123
|
+
statements.push(conversionBranches.join(" else "));
|
|
124
|
+
return statements;
|
|
125
|
+
}
|
|
126
|
+
jsonUiSchemaElement({ variables, }) {
|
|
127
|
+
const scope = `\`\${${variables.scopePrefix}}/properties/${this.name}\``;
|
|
128
|
+
return this.type
|
|
129
|
+
.jsonUiSchemaElement({ variables: { scopePrefix: scope } })
|
|
130
|
+
.altLazy(() => Maybe.of(`{ ${this.label.isJust() ? `label: "${this.label.unsafeCoerce()}", ` : ""}scope: ${scope}, type: "Control" }`));
|
|
131
|
+
}
|
|
132
|
+
jsonZodSchema(parameters) {
|
|
133
|
+
let schema = this.type.jsonZodSchema(parameters);
|
|
134
|
+
this.comment.alt(this.description).ifJust((description) => {
|
|
135
|
+
schema = `${schema}.describe(${JSON.stringify(description)})`;
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
key: this.name,
|
|
139
|
+
schema,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
sparqlConstructTemplateTriples({ variables, }) {
|
|
143
|
+
const objectString = `\`\${${variables.variablePrefix}}${pascalCase(this.name)}\``;
|
|
144
|
+
return this.type.sparqlConstructTemplateTriples({
|
|
145
|
+
context: "property",
|
|
146
|
+
variables: {
|
|
147
|
+
object: `${this.dataFactoryVariable}.variable!(${objectString})`,
|
|
148
|
+
predicate: this.rdfjsTermExpression(this.path),
|
|
149
|
+
subject: variables.subject,
|
|
150
|
+
variablePrefix: objectString,
|
|
151
|
+
},
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
sparqlWherePatterns({ variables, }) {
|
|
155
|
+
const objectString = `\`\${${variables.variablePrefix}}${pascalCase(this.name)}\``;
|
|
156
|
+
return this.type.sparqlWherePatterns({
|
|
157
|
+
context: "property",
|
|
86
158
|
variables: {
|
|
87
|
-
object:
|
|
88
|
-
predicate: this.
|
|
89
|
-
subject:
|
|
159
|
+
object: `${this.dataFactoryVariable}.variable!(${objectString})`,
|
|
160
|
+
predicate: this.rdfjsTermExpression(this.path),
|
|
161
|
+
subject: variables.subject,
|
|
162
|
+
variablePrefix: objectString,
|
|
90
163
|
},
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
toJsonObjectMember(parameters) {
|
|
167
|
+
return `${this.name}: ${this.type.toJsonExpression(parameters)}`;
|
|
94
168
|
}
|
|
95
169
|
toRdfStatements({ variables, }) {
|
|
96
170
|
return [
|