@shaclmate/compiler 2.0.22 → 2.0.24
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/ShapesGraphToAstTransformer.d.ts +6 -5
- package/dist/ShapesGraphToAstTransformer.js +61 -17
- package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.d.ts +2 -0
- package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.js +2 -0
- package/dist/_ShapesGraphToAstTransformer/ShapeStack.d.ts +15 -0
- package/dist/_ShapesGraphToAstTransformer/ShapeStack.js +51 -0
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.d.ts +13 -0
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.js +51 -0
- package/dist/_ShapesGraphToAstTransformer/index.d.ts +5 -5
- package/dist/_ShapesGraphToAstTransformer/index.js +5 -5
- package/dist/_ShapesGraphToAstTransformer/shapeAstName.js +53 -12
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +5 -0
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +130 -54
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +175 -5
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.js +185 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.js +32 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.js +46 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.d.ts +12 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +24 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +13 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +14 -0
- package/dist/ast/Ast.d.ts +0 -1
- package/dist/ast/Curie.d.ts +14 -0
- package/dist/ast/Curie.js +21 -0
- package/dist/ast/IdentifierType.d.ts +3 -2
- package/dist/ast/ListType.d.ts +2 -1
- package/dist/ast/LiteralType.d.ts +1 -1
- package/dist/ast/Name.d.ts +40 -5
- package/dist/ast/ObjectCompositeType.d.ts +11 -0
- package/dist/ast/ObjectType.d.ts +18 -13
- package/dist/ast/ObjectUnionType.d.ts +0 -11
- package/dist/ast/OptionType.d.ts +2 -4
- package/dist/ast/SetType.d.ts +2 -7
- package/dist/ast/TermType.d.ts +12 -4
- package/dist/ast/Type.d.ts +1 -1
- package/dist/ast/index.d.ts +1 -0
- package/dist/ast/index.js +1 -0
- package/dist/enums/TsFeature.d.ts +1 -4
- package/dist/enums/TsFeature.js +1 -15
- package/dist/generators/json/AstJsonGenerator.js +26 -4
- package/dist/generators/ts/BooleanType.d.ts +4 -2
- package/dist/generators/ts/BooleanType.js +12 -3
- package/dist/generators/ts/DateTimeType.d.ts +9 -8
- package/dist/generators/ts/DateTimeType.js +32 -8
- package/dist/generators/ts/DateType.d.ts +5 -2
- package/dist/generators/ts/DateType.js +15 -1
- package/dist/generators/ts/DeclaredType.d.ts +2 -2
- package/dist/generators/ts/DeclaredType.js +2 -2
- package/dist/generators/ts/FloatType.d.ts +6 -0
- package/dist/generators/ts/FloatType.js +18 -0
- package/dist/generators/ts/IdentifierType.d.ts +17 -7
- package/dist/generators/ts/IdentifierType.js +112 -18
- package/dist/generators/ts/Import.d.ts +2 -0
- package/dist/generators/ts/Import.js +10 -0
- package/dist/generators/ts/IntType.d.ts +6 -0
- package/dist/generators/ts/IntType.js +18 -0
- package/dist/generators/ts/ListType.d.ts +15 -12
- package/dist/generators/ts/ListType.js +113 -61
- package/dist/generators/ts/LiteralType.d.ts +17 -9
- package/dist/generators/ts/LiteralType.js +92 -17
- package/dist/generators/ts/NumberType.d.ts +3 -2
- package/dist/generators/ts/NumberType.js +8 -3
- package/dist/generators/ts/ObjectType.d.ts +65 -43
- package/dist/generators/ts/ObjectType.js +143 -123
- package/dist/generators/ts/ObjectUnionType.d.ts +50 -8
- package/dist/generators/ts/ObjectUnionType.js +303 -101
- package/dist/generators/ts/OptionType.d.ts +14 -10
- package/dist/generators/ts/OptionType.js +62 -34
- package/dist/generators/ts/PrimitiveType.d.ts +23 -5
- package/dist/generators/ts/PrimitiveType.js +34 -6
- package/dist/generators/ts/SetType.d.ts +17 -13
- package/dist/generators/ts/SetType.js +76 -44
- package/dist/generators/ts/SnippetDeclarations.d.ts +13 -8
- package/dist/generators/ts/SnippetDeclarations.js +226 -101
- package/dist/generators/ts/StringType.d.ts +4 -2
- package/dist/generators/ts/StringType.js +20 -8
- package/dist/generators/ts/TermType.d.ts +29 -33
- package/dist/generators/ts/TermType.js +89 -68
- package/dist/generators/ts/TsGenerator.d.ts +2 -1
- package/dist/generators/ts/TsGenerator.js +26 -12
- package/dist/generators/ts/Type.d.ts +100 -32
- package/dist/generators/ts/Type.js +58 -54
- package/dist/generators/ts/TypeFactory.d.ts +12 -5
- package/dist/generators/ts/TypeFactory.js +380 -226
- package/dist/generators/ts/UnionType.d.ts +14 -10
- package/dist/generators/ts/UnionType.js +319 -142
- package/dist/generators/ts/_ObjectType/EagerShaclProperty.d.ts +12 -0
- package/dist/generators/ts/_ObjectType/EagerShaclProperty.js +31 -0
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +13 -12
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +59 -46
- package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +20 -13
- package/dist/generators/ts/_ObjectType/IdentifierProperty.js +198 -140
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.d.ts +100 -0
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.js +315 -0
- package/dist/generators/ts/_ObjectType/Property.d.ts +47 -46
- package/dist/generators/ts/_ObjectType/Property.js +1 -10
- package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +25 -30
- package/dist/generators/ts/_ObjectType/ShaclProperty.js +120 -85
- package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +21 -17
- package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.js +61 -53
- package/dist/generators/ts/_ObjectType/classDeclaration.js +22 -17
- package/dist/generators/ts/_ObjectType/createFunctionDeclaration.js +26 -13
- package/dist/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +8 -5
- package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.js +8 -5
- package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.js +49 -0
- package/dist/generators/ts/_ObjectType/hashFunctionOrMethodDeclarations.js +7 -8
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +7 -0
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +54 -0
- package/dist/generators/ts/_ObjectType/index.d.ts +9 -7
- package/dist/generators/ts/_ObjectType/index.js +9 -7
- package/dist/generators/ts/_ObjectType/interfaceDeclaration.js +1 -1
- package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.js +189 -0
- package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.js +28 -0
- package/dist/generators/ts/_ObjectType/objectSetMethodNames.d.ts +9 -0
- package/dist/generators/ts/_ObjectType/objectSetMethodNames.js +18 -0
- package/dist/generators/ts/_ObjectType/propertiesVariableStatement.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/propertiesVariableStatement.js +37 -0
- package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.js +144 -0
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.js +6 -5
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.js +4 -3
- package/dist/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +109 -37
- package/dist/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +6 -6
- package/dist/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +33 -24
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +9 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +86 -0
- package/dist/generators/ts/objectSetDeclarations.d.ts +8 -0
- package/dist/generators/ts/objectSetDeclarations.js +59 -0
- package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +8 -0
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +46 -0
- package/dist/generators/ts/objectSetMethodSignatures.d.ts +11 -0
- package/dist/generators/ts/objectSetMethodSignatures.js +52 -0
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +8 -0
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +393 -0
- package/dist/generators/ts/rdfjsTermExpression.d.ts +3 -0
- package/dist/generators/ts/rdfjsTermExpression.js +57 -0
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +8 -0
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +415 -0
- package/dist/generators/ts/syntheticNamePrefix.d.ts +2 -0
- package/dist/generators/ts/syntheticNamePrefix.js +2 -0
- package/dist/generators/ts/tsName.js +27 -13
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +10 -0
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +19 -0
- package/dist/input/NodeShape.d.ts +6 -8
- package/dist/input/NodeShape.js +20 -44
- package/dist/input/Ontology.d.ts +0 -3
- package/dist/input/Ontology.js +0 -9
- package/dist/input/PropertyPath.d.ts +5 -5
- package/dist/input/PropertyPath.js +14 -24
- package/dist/input/PropertyShape.d.ts +3 -1
- package/dist/input/PropertyShape.js +8 -2
- package/dist/input/ShapesGraph.js +4 -8
- package/dist/input/generated.d.ts +967 -107
- package/dist/input/generated.js +2548 -1046
- package/dist/input/tsFeatures.d.ts +3 -2
- package/dist/input/tsFeatures.js +44 -27
- package/package.json +18 -16
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.d.ts +0 -13
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.js +0 -200
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.d.ts +0 -12
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.js +0 -29
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.d.ts +0 -12
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.js +0 -43
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.d.ts +0 -14
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.js +0 -21
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.d.ts +0 -16
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.js +0 -60
- package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.js +0 -78
- package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.js +0 -91
- package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.js +0 -31
- package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.js +0 -37
- package/dist/generators/ts/_ObjectType/rdfjsTermExpression.d.ts +0 -6
- package/dist/generators/ts/_ObjectType/rdfjsTermExpression.js +0 -17
- package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectType/toJsonReturnType.d.ts +0 -3
- package/dist/generators/ts/_ObjectType/toJsonReturnType.js +0 -17
- package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.js +0 -19
|
@@ -7,33 +7,23 @@ 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 { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
10
11
|
import { tsComment } from "../tsComment.js";
|
|
11
12
|
import { Property } from "./Property.js";
|
|
12
13
|
export class ShaclProperty extends Property {
|
|
13
|
-
mutable;
|
|
14
14
|
comment;
|
|
15
15
|
description;
|
|
16
16
|
label;
|
|
17
17
|
path;
|
|
18
|
-
constructor({ comment, description, label,
|
|
18
|
+
constructor({ comment, description, label, path, ...superParameters }) {
|
|
19
19
|
super(superParameters);
|
|
20
20
|
this.comment = comment;
|
|
21
21
|
this.description = description;
|
|
22
22
|
this.label = label;
|
|
23
|
-
this.mutable = mutable;
|
|
24
23
|
this.path = path;
|
|
25
24
|
}
|
|
26
|
-
get
|
|
27
|
-
return Maybe.
|
|
28
|
-
}
|
|
29
|
-
get classPropertyDeclaration() {
|
|
30
|
-
return Maybe.of({
|
|
31
|
-
isReadonly: !this.mutable,
|
|
32
|
-
leadingTrivia: this.declarationComment,
|
|
33
|
-
name: this.name,
|
|
34
|
-
scope: Property.visibilityToScope(this.visibility),
|
|
35
|
-
type: this.type.name,
|
|
36
|
-
});
|
|
25
|
+
get equalsFunction() {
|
|
26
|
+
return Maybe.of(this.type.equalsFunction);
|
|
37
27
|
}
|
|
38
28
|
get constructorParametersPropertySignature() {
|
|
39
29
|
let hasQuestionToken = false;
|
|
@@ -54,82 +44,52 @@ export class ShaclProperty extends Property {
|
|
|
54
44
|
type: [...typeNames].sort().join(" | "),
|
|
55
45
|
});
|
|
56
46
|
}
|
|
57
|
-
|
|
58
|
-
return this.type.useImports(this.objectType.features);
|
|
59
|
-
}
|
|
60
|
-
get equalsFunction() {
|
|
61
|
-
return this.type.equalsFunction;
|
|
62
|
-
}
|
|
63
|
-
get interfacePropertySignature() {
|
|
64
|
-
return Maybe.of({
|
|
65
|
-
isReadonly: !this.mutable,
|
|
66
|
-
leadingTrivia: this.declarationComment,
|
|
67
|
-
name: this.name,
|
|
68
|
-
type: this.type.name,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
get jsonPropertySignature() {
|
|
72
|
-
return Maybe.of({
|
|
73
|
-
isReadonly: true,
|
|
74
|
-
name: this.name,
|
|
75
|
-
type: this.type.jsonName,
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
get snippetDeclarations() {
|
|
79
|
-
return this.type.snippetDeclarations(this.objectType.features);
|
|
80
|
-
}
|
|
81
|
-
get declarationComment() {
|
|
82
|
-
return this.comment
|
|
83
|
-
.alt(this.description)
|
|
84
|
-
.alt(this.label)
|
|
85
|
-
.map(tsComment)
|
|
86
|
-
.extract();
|
|
87
|
-
}
|
|
88
|
-
get pathExpression() {
|
|
89
|
-
return `${this.dataFactoryVariable}.namedNode("${this.path.value}")`;
|
|
90
|
-
}
|
|
91
|
-
classConstructorStatements({ variables, }) {
|
|
47
|
+
constructorStatements({ variables, }) {
|
|
92
48
|
const typeConversions = this.type.conversions;
|
|
93
49
|
if (typeConversions.length === 1) {
|
|
94
|
-
|
|
50
|
+
switch (this.objectType.declarationType) {
|
|
51
|
+
case "class":
|
|
52
|
+
return [`this.${this.name} = ${variables.parameter};`];
|
|
53
|
+
case "interface":
|
|
54
|
+
return [`const ${this.name} = ${variables.parameter};`];
|
|
55
|
+
}
|
|
95
56
|
}
|
|
57
|
+
let lhs;
|
|
96
58
|
const statements = [];
|
|
97
|
-
|
|
98
|
-
|
|
59
|
+
switch (this.objectType.declarationType) {
|
|
60
|
+
case "class":
|
|
61
|
+
lhs = `this.${this.name}`;
|
|
62
|
+
break;
|
|
63
|
+
case "interface":
|
|
64
|
+
lhs = this.name;
|
|
65
|
+
statements.push(`let ${this.name}: ${this.type.name};`);
|
|
66
|
+
break;
|
|
99
67
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
68
|
+
statements.push(typeConversions
|
|
69
|
+
.map((conversion) => `if (${conversion.sourceTypeCheckExpression(variables.parameter)}) { ${lhs} = ${conversion.conversionExpression(variables.parameter)}; }`)
|
|
70
|
+
// We shouldn't need this else, since the parameter now has the never type, but have to add it to appease the TypeScript compiler
|
|
71
|
+
.concat(`{ ${lhs} = (${variables.parameter}) satisfies never; }`)
|
|
72
|
+
.join(" else "));
|
|
73
|
+
return statements;
|
|
103
74
|
}
|
|
104
75
|
fromJsonStatements({ variables, }) {
|
|
105
76
|
return [
|
|
106
77
|
`const ${this.name} = ${this.type.fromJsonExpression({ variables: { value: `${variables.jsonObject}["${this.name}"]` } })};`,
|
|
107
78
|
];
|
|
108
79
|
}
|
|
109
|
-
|
|
110
|
-
return
|
|
111
|
-
`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 })` } })};`,
|
|
112
|
-
`if (_${this.name}Either.isLeft()) { return _${this.name}Either; }`,
|
|
113
|
-
`const ${this.name} = _${this.name}Either.unsafeCoerce();`,
|
|
114
|
-
];
|
|
80
|
+
get getAccessorDeclaration() {
|
|
81
|
+
return Maybe.empty();
|
|
115
82
|
}
|
|
116
83
|
hashStatements(parameters) {
|
|
117
84
|
return this.type.hashStatements(parameters);
|
|
118
85
|
}
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
for (const conversion of this.type.conversions) {
|
|
127
|
-
conversionBranches.push(`if (${conversion.sourceTypeCheckExpression(variables.parameter)}) { ${this.name} = ${conversion.conversionExpression(variables.parameter)}; }`);
|
|
128
|
-
}
|
|
129
|
-
// We shouldn't need this else, since the parameter now has the never type, but have to add it to appease the TypeScript compiler
|
|
130
|
-
conversionBranches.push(`{ ${this.name} =( ${variables.parameter}) as never;\n }`);
|
|
131
|
-
statements.push(conversionBranches.join(" else "));
|
|
132
|
-
return statements;
|
|
86
|
+
get jsonPropertySignature() {
|
|
87
|
+
return Maybe.of({
|
|
88
|
+
hasQuestionToken: this.type.jsonName.optional,
|
|
89
|
+
isReadonly: true,
|
|
90
|
+
name: this.name,
|
|
91
|
+
type: this.type.jsonName.requiredName,
|
|
92
|
+
});
|
|
133
93
|
}
|
|
134
94
|
jsonUiSchemaElement({ variables, }) {
|
|
135
95
|
const scope = `\`\${${variables.scopePrefix}}/properties/${this.name}\``;
|
|
@@ -138,7 +98,10 @@ export class ShaclProperty extends Property {
|
|
|
138
98
|
.altLazy(() => Maybe.of(`{ ${this.label.isJust() ? `label: "${this.label.unsafeCoerce()}", ` : ""}scope: ${scope}, type: "Control" }`));
|
|
139
99
|
}
|
|
140
100
|
jsonZodSchema(parameters) {
|
|
141
|
-
let schema = this.type.jsonZodSchema(
|
|
101
|
+
let schema = this.type.jsonZodSchema({
|
|
102
|
+
...parameters,
|
|
103
|
+
context: "property",
|
|
104
|
+
});
|
|
142
105
|
this.comment.alt(this.description).ifJust((description) => {
|
|
143
106
|
schema = `${schema}.describe(${JSON.stringify(description)})`;
|
|
144
107
|
});
|
|
@@ -147,13 +110,55 @@ export class ShaclProperty extends Property {
|
|
|
147
110
|
schema,
|
|
148
111
|
});
|
|
149
112
|
}
|
|
113
|
+
get propertyDeclaration() {
|
|
114
|
+
return Maybe.of({
|
|
115
|
+
isReadonly: !this.mutable,
|
|
116
|
+
leadingTrivia: this.declarationComment,
|
|
117
|
+
name: this.name,
|
|
118
|
+
scope: ShaclProperty.visibilityToScope(this.visibility),
|
|
119
|
+
type: this.type.name,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
get declarationImports() {
|
|
123
|
+
return this.type.useImports({ features: this.objectType.features });
|
|
124
|
+
}
|
|
125
|
+
get propertySignature() {
|
|
126
|
+
return Maybe.of({
|
|
127
|
+
isReadonly: !this.mutable,
|
|
128
|
+
leadingTrivia: this.declarationComment,
|
|
129
|
+
name: this.name,
|
|
130
|
+
type: this.type.name,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
snippetDeclarations(parameters) {
|
|
134
|
+
return this.type.snippetDeclarations(parameters);
|
|
135
|
+
}
|
|
136
|
+
fromRdfStatements({ variables, }) {
|
|
137
|
+
// Assume the property has the correct range and ignore the object's RDF type.
|
|
138
|
+
// This also accommodates the case where the object of a property is a dangling identifier that's not the
|
|
139
|
+
// subject of any statements.
|
|
140
|
+
const typeFromRdfExpression = this.type.fromRdfExpression({
|
|
141
|
+
variables: {
|
|
142
|
+
...variables,
|
|
143
|
+
ignoreRdfType: true,
|
|
144
|
+
predicate: this.predicate,
|
|
145
|
+
resourceValues: `purify.Either.of<Error, rdfjsResource.Resource.Values<rdfjsResource.Resource.Value>>(${variables.resource}.values(${syntheticNamePrefix}properties.${this.name}["identifier"], { unique: true }))`,
|
|
146
|
+
},
|
|
147
|
+
});
|
|
148
|
+
return [
|
|
149
|
+
`const _${this.name}Either: purify.Either<Error, ${this.type.name}> = ${typeFromRdfExpression}.chain(values => values.head());`,
|
|
150
|
+
`if (_${this.name}Either.isLeft()) { return _${this.name}Either; }`,
|
|
151
|
+
`const ${this.name} = _${this.name}Either.unsafeCoerce();`,
|
|
152
|
+
];
|
|
153
|
+
}
|
|
150
154
|
sparqlConstructTemplateTriples({ variables, }) {
|
|
151
155
|
const objectString = `\`\${${variables.variablePrefix}}${pascalCase(this.name)}\``;
|
|
152
156
|
return this.type.sparqlConstructTemplateTriples({
|
|
153
|
-
|
|
157
|
+
allowIgnoreRdfType: true,
|
|
158
|
+
context: "object",
|
|
154
159
|
variables: {
|
|
155
|
-
object:
|
|
156
|
-
predicate: this.
|
|
160
|
+
object: `dataFactory.variable!(${objectString})`,
|
|
161
|
+
predicate: this.predicate,
|
|
157
162
|
subject: variables.subject,
|
|
158
163
|
variablePrefix: objectString,
|
|
159
164
|
},
|
|
@@ -162,10 +167,12 @@ export class ShaclProperty extends Property {
|
|
|
162
167
|
sparqlWherePatterns({ variables, }) {
|
|
163
168
|
const objectString = `\`\${${variables.variablePrefix}}${pascalCase(this.name)}\``;
|
|
164
169
|
return this.type.sparqlWherePatterns({
|
|
165
|
-
|
|
170
|
+
allowIgnoreRdfType: true,
|
|
171
|
+
context: "object",
|
|
166
172
|
variables: {
|
|
167
|
-
|
|
168
|
-
|
|
173
|
+
languageIn: variables.languageIn,
|
|
174
|
+
object: `dataFactory.variable!(${objectString})`,
|
|
175
|
+
predicate: this.predicate,
|
|
169
176
|
subject: variables.subject,
|
|
170
177
|
variablePrefix: objectString,
|
|
171
178
|
},
|
|
@@ -176,13 +183,41 @@ export class ShaclProperty extends Property {
|
|
|
176
183
|
}
|
|
177
184
|
toRdfStatements({ variables, }) {
|
|
178
185
|
return [
|
|
179
|
-
`${variables.resource}.add(${this.
|
|
180
|
-
variables: { ...variables, predicate: this.
|
|
186
|
+
`${variables.resource}.add(${this.predicate}, ${this.type.toRdfExpression({
|
|
187
|
+
variables: { ...variables, predicate: this.predicate },
|
|
181
188
|
})});`,
|
|
182
189
|
];
|
|
183
190
|
}
|
|
191
|
+
get declarationComment() {
|
|
192
|
+
return this.comment
|
|
193
|
+
.alt(this.description)
|
|
194
|
+
.alt(this.label)
|
|
195
|
+
.map(tsComment)
|
|
196
|
+
.extract();
|
|
197
|
+
}
|
|
198
|
+
get predicate() {
|
|
199
|
+
return `${this.objectType.staticModuleName}.${syntheticNamePrefix}properties.${this.name}["identifier"]`;
|
|
200
|
+
}
|
|
184
201
|
}
|
|
185
202
|
__decorate([
|
|
186
203
|
Memoize()
|
|
187
|
-
], ShaclProperty.prototype, "
|
|
204
|
+
], ShaclProperty.prototype, "equalsFunction", null);
|
|
205
|
+
__decorate([
|
|
206
|
+
Memoize()
|
|
207
|
+
], ShaclProperty.prototype, "constructorParametersPropertySignature", null);
|
|
208
|
+
__decorate([
|
|
209
|
+
Memoize()
|
|
210
|
+
], ShaclProperty.prototype, "jsonPropertySignature", null);
|
|
211
|
+
__decorate([
|
|
212
|
+
Memoize()
|
|
213
|
+
], ShaclProperty.prototype, "propertyDeclaration", null);
|
|
214
|
+
__decorate([
|
|
215
|
+
Memoize()
|
|
216
|
+
], ShaclProperty.prototype, "declarationImports", null);
|
|
217
|
+
__decorate([
|
|
218
|
+
Memoize()
|
|
219
|
+
], ShaclProperty.prototype, "propertySignature", null);
|
|
220
|
+
__decorate([
|
|
221
|
+
Memoize()
|
|
222
|
+
], ShaclProperty.prototype, "predicate", null);
|
|
188
223
|
//# sourceMappingURL=ShaclProperty.js.map
|
|
@@ -1,33 +1,34 @@
|
|
|
1
|
-
import type { Import } from "generators/ts/Import.js";
|
|
2
1
|
import { Maybe } from "purify-ts";
|
|
3
2
|
import type { GetAccessorDeclarationStructure, OptionalKind, PropertyDeclarationStructure, PropertySignatureStructure } from "ts-morph";
|
|
3
|
+
import type { Import } from "../Import.js";
|
|
4
4
|
import { Property } from "./Property.js";
|
|
5
5
|
export declare class TypeDiscriminatorProperty extends Property<TypeDiscriminatorProperty.Type> {
|
|
6
|
-
readonly equalsFunction = "strictEquals";
|
|
7
|
-
readonly mutable = false;
|
|
8
|
-
readonly value: string;
|
|
9
6
|
private readonly abstract;
|
|
10
7
|
private readonly override;
|
|
11
|
-
|
|
8
|
+
readonly constructorParametersPropertySignature: Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
9
|
+
readonly declarationImports: readonly Import[];
|
|
10
|
+
readonly equalsFunction: Maybe<string>;
|
|
11
|
+
readonly getAccessorDeclaration: Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
|
|
12
|
+
readonly graphqlField: Property<TypeDiscriminatorProperty.Type>["graphqlField"];
|
|
13
|
+
readonly initializer: string;
|
|
14
|
+
readonly mutable = false;
|
|
15
|
+
readonly recursive = false;
|
|
16
|
+
constructor({ abstract, initializer, override, type, ...superParameters }: {
|
|
12
17
|
abstract: boolean;
|
|
18
|
+
initializer: string;
|
|
13
19
|
override: boolean;
|
|
14
20
|
type: TypeDiscriminatorProperty.Type;
|
|
15
|
-
value: string;
|
|
16
21
|
} & ConstructorParameters<typeof Property>[0]);
|
|
17
|
-
get classGetAccessorDeclaration(): Maybe<OptionalKind<GetAccessorDeclarationStructure>>;
|
|
18
|
-
get classPropertyDeclaration(): Maybe<OptionalKind<PropertyDeclarationStructure>>;
|
|
19
|
-
get constructorParametersPropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
20
|
-
get declarationImports(): readonly Import[];
|
|
21
|
-
get interfacePropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
22
22
|
get jsonPropertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
23
|
-
|
|
24
|
-
classConstructorStatements(): readonly string[];
|
|
23
|
+
constructorStatements(): readonly string[];
|
|
25
24
|
fromJsonStatements(): readonly string[];
|
|
26
25
|
fromRdfStatements(): readonly string[];
|
|
27
26
|
hashStatements({ variables, }: Parameters<Property<TypeDiscriminatorProperty>["hashStatements"]>[0]): readonly string[];
|
|
28
|
-
interfaceConstructorStatements(): readonly string[];
|
|
29
27
|
jsonUiSchemaElement({ variables, }: Parameters<Property<TypeDiscriminatorProperty.Type>["jsonUiSchemaElement"]>[0]): Maybe<string>;
|
|
30
28
|
jsonZodSchema({ variables, }: Parameters<Property<TypeDiscriminatorProperty.Type>["jsonZodSchema"]>[0]): ReturnType<Property<TypeDiscriminatorProperty.Type>["jsonZodSchema"]>;
|
|
29
|
+
get propertyDeclaration(): Maybe<OptionalKind<PropertyDeclarationStructure>>;
|
|
30
|
+
get propertySignature(): Maybe<OptionalKind<PropertySignatureStructure>>;
|
|
31
|
+
snippetDeclarations(): readonly string[];
|
|
31
32
|
sparqlConstructTemplateTriples(): readonly string[];
|
|
32
33
|
sparqlWherePatterns(): readonly string[];
|
|
33
34
|
toJsonObjectMember({ variables, }: Parameters<Property<TypeDiscriminatorProperty.Type>["toJsonObjectMember"]>[0]): Maybe<string>;
|
|
@@ -36,12 +37,15 @@ export declare class TypeDiscriminatorProperty extends Property<TypeDiscriminato
|
|
|
36
37
|
export declare namespace TypeDiscriminatorProperty {
|
|
37
38
|
class Type {
|
|
38
39
|
readonly mutable: boolean;
|
|
39
|
-
readonly
|
|
40
|
-
|
|
40
|
+
readonly descendantValues: readonly string[];
|
|
41
|
+
readonly ownValues: readonly string[];
|
|
42
|
+
constructor({ descendantValues, mutable, ownValues, }: {
|
|
43
|
+
descendantValues: readonly string[];
|
|
41
44
|
mutable: boolean;
|
|
42
|
-
|
|
45
|
+
ownValues: readonly string[];
|
|
43
46
|
});
|
|
44
47
|
get name(): string;
|
|
48
|
+
get values(): string[];
|
|
45
49
|
}
|
|
46
50
|
}
|
|
47
51
|
//# sourceMappingURL=TypeDiscriminatorProperty.d.ts.map
|
|
@@ -8,49 +8,25 @@ import { Maybe } from "purify-ts";
|
|
|
8
8
|
import { invariant } from "ts-invariant";
|
|
9
9
|
import { Memoize } from "typescript-memoize";
|
|
10
10
|
import { SnippetDeclarations } from "../SnippetDeclarations.js";
|
|
11
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
11
12
|
import { Property } from "./Property.js";
|
|
12
13
|
export class TypeDiscriminatorProperty extends Property {
|
|
13
|
-
equalsFunction = "strictEquals";
|
|
14
|
-
mutable = false;
|
|
15
|
-
value;
|
|
16
14
|
abstract;
|
|
17
15
|
override;
|
|
18
|
-
|
|
16
|
+
constructorParametersPropertySignature = Maybe.empty();
|
|
17
|
+
declarationImports = [];
|
|
18
|
+
equalsFunction = Maybe.of(`${syntheticNamePrefix}strictEquals`);
|
|
19
|
+
getAccessorDeclaration = Maybe.empty();
|
|
20
|
+
graphqlField = Maybe.empty();
|
|
21
|
+
initializer;
|
|
22
|
+
mutable = false;
|
|
23
|
+
recursive = false;
|
|
24
|
+
constructor({ abstract, initializer, override, type, ...superParameters }) {
|
|
19
25
|
super({ ...superParameters, type });
|
|
20
26
|
invariant(this.visibility === "public");
|
|
21
27
|
this.abstract = abstract;
|
|
28
|
+
this.initializer = initializer;
|
|
22
29
|
this.override = override;
|
|
23
|
-
this.value = value;
|
|
24
|
-
}
|
|
25
|
-
get classGetAccessorDeclaration() {
|
|
26
|
-
return Maybe.empty();
|
|
27
|
-
}
|
|
28
|
-
get classPropertyDeclaration() {
|
|
29
|
-
return Maybe.of({
|
|
30
|
-
// Work around a ts-morph bug that puts the override keyword before the abstract keyword
|
|
31
|
-
isAbstract: this.abstract && this.override ? undefined : this.abstract,
|
|
32
|
-
hasOverrideKeyword: this.abstract && this.override ? undefined : this.override,
|
|
33
|
-
initializer: !this.abstract ? `"${this.value}"` : undefined,
|
|
34
|
-
isReadonly: true,
|
|
35
|
-
leadingTrivia: this.abstract && this.override ? "abstract override " : undefined,
|
|
36
|
-
name: this.name,
|
|
37
|
-
type: !this.abstract && this.type.name === `"${this.value}"`
|
|
38
|
-
? undefined
|
|
39
|
-
: this.type.name,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
get constructorParametersPropertySignature() {
|
|
43
|
-
return Maybe.empty();
|
|
44
|
-
}
|
|
45
|
-
get declarationImports() {
|
|
46
|
-
return [];
|
|
47
|
-
}
|
|
48
|
-
get interfacePropertySignature() {
|
|
49
|
-
return Maybe.of({
|
|
50
|
-
isReadonly: true,
|
|
51
|
-
name: this.name,
|
|
52
|
-
type: this.type.name,
|
|
53
|
-
});
|
|
54
30
|
}
|
|
55
31
|
get jsonPropertySignature() {
|
|
56
32
|
return Maybe.of({
|
|
@@ -59,35 +35,31 @@ export class TypeDiscriminatorProperty extends Property {
|
|
|
59
35
|
type: this.type.name,
|
|
60
36
|
});
|
|
61
37
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
38
|
+
constructorStatements() {
|
|
39
|
+
switch (this.objectType.declarationType) {
|
|
40
|
+
case "class":
|
|
41
|
+
return [];
|
|
42
|
+
case "interface":
|
|
43
|
+
if (this.abstract) {
|
|
44
|
+
return [];
|
|
45
|
+
}
|
|
46
|
+
return [`const ${this.name} = "${this.initializer}" as const`];
|
|
66
47
|
}
|
|
67
|
-
return snippetDeclarations;
|
|
68
|
-
}
|
|
69
|
-
classConstructorStatements() {
|
|
70
|
-
return [];
|
|
71
48
|
}
|
|
72
49
|
fromJsonStatements() {
|
|
73
50
|
return this.fromRdfStatements();
|
|
74
51
|
}
|
|
75
52
|
fromRdfStatements() {
|
|
76
53
|
return !this.abstract && this.objectType.declarationType === "interface"
|
|
77
|
-
? [`const ${this.name} = "${this.
|
|
54
|
+
? [`const ${this.name} = "${this.initializer}" as const`]
|
|
78
55
|
: [];
|
|
79
56
|
}
|
|
80
57
|
hashStatements({ variables, }) {
|
|
81
58
|
return [`${variables.hasher}.update(${variables.value});`];
|
|
82
59
|
}
|
|
83
|
-
interfaceConstructorStatements() {
|
|
84
|
-
return !this.abstract
|
|
85
|
-
? [`const ${this.name} = "${this.value}" as const`]
|
|
86
|
-
: [];
|
|
87
|
-
}
|
|
88
60
|
jsonUiSchemaElement({ variables, }) {
|
|
89
61
|
const scope = `\`\${${variables.scopePrefix}}/properties/${this.name}\``;
|
|
90
|
-
return Maybe.of(`{ rule: { condition: { schema: { const: "${this.
|
|
62
|
+
return Maybe.of(`{ rule: { condition: { schema: { const: "${this.initializer}" }, scope: ${scope} }, effect: "HIDE" }, scope: ${scope}, type: "Control" }`);
|
|
91
63
|
}
|
|
92
64
|
jsonZodSchema({ variables, }) {
|
|
93
65
|
return Maybe.of({
|
|
@@ -97,6 +69,34 @@ export class TypeDiscriminatorProperty extends Property {
|
|
|
97
69
|
: `${variables.zod}.literal("${this.type.values[0]}")`,
|
|
98
70
|
});
|
|
99
71
|
}
|
|
72
|
+
get propertyDeclaration() {
|
|
73
|
+
return Maybe.of({
|
|
74
|
+
// Work around a ts-morph bug that puts the override keyword before the abstract keyword
|
|
75
|
+
isAbstract: this.abstract && this.override ? undefined : this.abstract,
|
|
76
|
+
hasOverrideKeyword: this.abstract && this.override ? undefined : this.override,
|
|
77
|
+
initializer: !this.abstract ? `"${this.initializer}"` : undefined,
|
|
78
|
+
isReadonly: true,
|
|
79
|
+
leadingTrivia: this.abstract && this.override ? "abstract override " : undefined,
|
|
80
|
+
name: this.name,
|
|
81
|
+
type: !this.abstract && this.type.name === `"${this.initializer}"`
|
|
82
|
+
? undefined
|
|
83
|
+
: this.type.name,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
get propertySignature() {
|
|
87
|
+
return Maybe.of({
|
|
88
|
+
isReadonly: true,
|
|
89
|
+
name: this.name,
|
|
90
|
+
type: this.type.name,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
snippetDeclarations() {
|
|
94
|
+
const snippetDeclarations = [];
|
|
95
|
+
if (this.objectType.features.has("equals")) {
|
|
96
|
+
snippetDeclarations.push(SnippetDeclarations.strictEquals);
|
|
97
|
+
}
|
|
98
|
+
return snippetDeclarations;
|
|
99
|
+
}
|
|
100
100
|
sparqlConstructTemplateTriples() {
|
|
101
101
|
return [];
|
|
102
102
|
}
|
|
@@ -113,18 +113,26 @@ export class TypeDiscriminatorProperty extends Property {
|
|
|
113
113
|
(function (TypeDiscriminatorProperty) {
|
|
114
114
|
class Type {
|
|
115
115
|
mutable;
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
descendantValues;
|
|
117
|
+
ownValues;
|
|
118
|
+
constructor({ descendantValues, mutable, ownValues, }) {
|
|
119
|
+
this.descendantValues = descendantValues;
|
|
118
120
|
this.mutable = mutable;
|
|
119
|
-
this.
|
|
121
|
+
this.ownValues = ownValues;
|
|
120
122
|
}
|
|
121
123
|
get name() {
|
|
122
124
|
return this.values.map((name) => `"${name}"`).join(" | ");
|
|
123
125
|
}
|
|
126
|
+
get values() {
|
|
127
|
+
return this.ownValues.concat(this.descendantValues);
|
|
128
|
+
}
|
|
124
129
|
}
|
|
125
130
|
__decorate([
|
|
126
131
|
Memoize()
|
|
127
132
|
], Type.prototype, "name", null);
|
|
133
|
+
__decorate([
|
|
134
|
+
Memoize()
|
|
135
|
+
], Type.prototype, "values", null);
|
|
128
136
|
TypeDiscriminatorProperty.Type = Type;
|
|
129
137
|
})(TypeDiscriminatorProperty || (TypeDiscriminatorProperty = {}));
|
|
130
138
|
//# sourceMappingURL=TypeDiscriminatorProperty.js.map
|
|
@@ -1,27 +1,25 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { StructureKind, } from "ts-morph";
|
|
3
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
3
4
|
import { tsComment } from "../tsComment.js";
|
|
4
5
|
import { equalsFunctionOrMethodDeclaration } from "./equalsFunctionOrMethodDeclaration.js";
|
|
5
6
|
import { hashFunctionOrMethodDeclarations } from "./hashFunctionOrMethodDeclarations.js";
|
|
6
7
|
import { toJsonFunctionOrMethodDeclaration } from "./toJsonFunctionOrMethodDeclaration.js";
|
|
7
8
|
import { toRdfFunctionOrMethodDeclaration } from "./toRdfFunctionOrMethodDeclaration.js";
|
|
8
9
|
function constructorDeclaration() {
|
|
9
|
-
const parametersPropertySignatures = this.properties.flatMap((property) => property.constructorParametersPropertySignature
|
|
10
|
-
|
|
11
|
-
.toList());
|
|
12
|
-
let parametersType;
|
|
10
|
+
const parametersPropertySignatures = this.properties.flatMap((property) => property.constructorParametersPropertySignature.toList());
|
|
11
|
+
const parametersType = [];
|
|
13
12
|
if (parametersPropertySignatures.length > 0) {
|
|
14
|
-
parametersType
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
parametersType = "";
|
|
13
|
+
parametersType.push(`{ ${parametersPropertySignatures
|
|
14
|
+
.map((propertySignature) => `readonly ${propertySignature.name}${propertySignature.hasQuestionToken ? "?" : ""}: ${propertySignature.type}`)
|
|
15
|
+
.join(", ")} }`);
|
|
18
16
|
}
|
|
19
17
|
if (this.parentObjectTypes.length > 0) {
|
|
20
18
|
// Pass up parameters
|
|
21
|
-
parametersType
|
|
19
|
+
parametersType.push(`ConstructorParameters<typeof ${this.parentObjectTypes[0].name}>[0]`);
|
|
22
20
|
}
|
|
23
21
|
if (parametersType.length === 0) {
|
|
24
|
-
parametersType
|
|
22
|
+
parametersType.push("object");
|
|
25
23
|
}
|
|
26
24
|
const statements = [];
|
|
27
25
|
if (this.parentObjectTypes.length > 0) {
|
|
@@ -29,8 +27,14 @@ function constructorDeclaration() {
|
|
|
29
27
|
// of trying to sense whether we need to or not.
|
|
30
28
|
statements.push("super(parameters);");
|
|
31
29
|
}
|
|
32
|
-
const
|
|
33
|
-
|
|
30
|
+
const parametersHasQuestionToken = this.parentObjectTypes.length === 0 &&
|
|
31
|
+
parametersPropertySignatures.every((propertySignature) => !!propertySignature.hasQuestionToken);
|
|
32
|
+
const parametersVariable = `parameters${parametersHasQuestionToken ? "?" : ""}`;
|
|
33
|
+
const propertyStatements = this.properties.flatMap((property) => property.constructorStatements({
|
|
34
|
+
variables: {
|
|
35
|
+
parameter: `${parametersVariable}.${property.name}`,
|
|
36
|
+
parameters: parametersVariable,
|
|
37
|
+
},
|
|
34
38
|
}));
|
|
35
39
|
statements.push(...propertyStatements);
|
|
36
40
|
return {
|
|
@@ -39,8 +43,9 @@ function constructorDeclaration() {
|
|
|
39
43
|
: undefined,
|
|
40
44
|
parameters: [
|
|
41
45
|
{
|
|
46
|
+
hasQuestionToken: parametersHasQuestionToken,
|
|
42
47
|
name: statements.length > 0 ? "parameters" : "_parameters",
|
|
43
|
-
type: parametersType,
|
|
48
|
+
type: parametersType.join(" & "),
|
|
44
49
|
},
|
|
45
50
|
],
|
|
46
51
|
statements,
|
|
@@ -57,8 +62,8 @@ export function classDeclaration() {
|
|
|
57
62
|
const getAccessors = [];
|
|
58
63
|
const properties = [];
|
|
59
64
|
for (const property of this.properties) {
|
|
60
|
-
property.
|
|
61
|
-
property.
|
|
65
|
+
property.propertyDeclaration.ifJust((propertyDeclaration) => properties.push(propertyDeclaration));
|
|
66
|
+
property.getAccessorDeclaration.ifJust((getAccessor) => getAccessors.push(getAccessor));
|
|
62
67
|
}
|
|
63
68
|
return Maybe.of({
|
|
64
69
|
ctors: [constructorDeclaration.bind(this)()],
|
|
@@ -104,14 +109,14 @@ function toRdfMethodDeclaration() {
|
|
|
104
109
|
}));
|
|
105
110
|
}
|
|
106
111
|
function toStringMethodDeclaration() {
|
|
107
|
-
if (!this.features.has("
|
|
112
|
+
if (!this.features.has("json")) {
|
|
108
113
|
return Maybe.empty();
|
|
109
114
|
}
|
|
110
115
|
return Maybe.of({
|
|
111
116
|
hasOverrideKeyword: this.parentObjectTypes.length > 0,
|
|
112
117
|
name: "toString",
|
|
113
118
|
returnType: "string",
|
|
114
|
-
statements: [
|
|
119
|
+
statements: [`return JSON.stringify(this.${syntheticNamePrefix}toJson());`],
|
|
115
120
|
});
|
|
116
121
|
}
|
|
117
122
|
//# sourceMappingURL=classDeclaration.js.map
|