@shaclmate/compiler 2.0.22 → 2.0.23
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 +1 -0
- package/dist/ShapesGraphToAstTransformer.js +56 -12
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.d.ts +13 -0
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.js +51 -0
- 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/transformPropertyShapeToAstCompositeType.d.ts +2 -3
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.js +122 -129
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.d.ts +2 -2
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.d.ts +2 -2
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +127 -5
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.d.ts +3 -3
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.d.ts +2 -3
- 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 -2
- package/dist/ast/SetType.d.ts +2 -2
- package/dist/ast/TermType.d.ts +12 -4
- package/dist/ast/Type.d.ts +1 -1
- package/dist/enums/TsFeature.d.ts +1 -4
- package/dist/enums/TsFeature.js +1 -15
- package/dist/generators/json/AstJsonGenerator.js +19 -3
- package/dist/generators/ts/BooleanType.d.ts +3 -1
- package/dist/generators/ts/BooleanType.js +11 -2
- package/dist/generators/ts/DateTimeType.d.ts +8 -7
- package/dist/generators/ts/DateTimeType.js +31 -7
- 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 +12 -7
- package/dist/generators/ts/IdentifierType.js +94 -6
- 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 +98 -57
- package/dist/generators/ts/LiteralType.d.ts +10 -9
- package/dist/generators/ts/LiteralType.js +13 -2
- package/dist/generators/ts/NumberType.d.ts +2 -1
- package/dist/generators/ts/NumberType.js +7 -2
- package/dist/generators/ts/ObjectType.d.ts +66 -43
- package/dist/generators/ts/ObjectType.js +144 -123
- package/dist/generators/ts/ObjectUnionType.d.ts +49 -8
- package/dist/generators/ts/ObjectUnionType.js +290 -97
- package/dist/generators/ts/OptionType.d.ts +14 -10
- package/dist/generators/ts/OptionType.js +60 -34
- package/dist/generators/ts/PrimitiveType.d.ts +4 -4
- package/dist/generators/ts/PrimitiveType.js +18 -3
- package/dist/generators/ts/SetType.d.ts +16 -12
- package/dist/generators/ts/SetType.js +69 -40
- package/dist/generators/ts/SnippetDeclarations.d.ts +13 -8
- package/dist/generators/ts/SnippetDeclarations.js +215 -101
- package/dist/generators/ts/StringType.d.ts +3 -1
- package/dist/generators/ts/StringType.js +14 -2
- package/dist/generators/ts/TermType.d.ts +22 -14
- package/dist/generators/ts/TermType.js +53 -25
- package/dist/generators/ts/TsGenerator.d.ts +2 -1
- package/dist/generators/ts/TsGenerator.js +23 -12
- package/dist/generators/ts/Type.d.ts +89 -31
- package/dist/generators/ts/Type.js +57 -54
- package/dist/generators/ts/TypeFactory.d.ts +4 -5
- package/dist/generators/ts/TypeFactory.js +290 -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 +30 -0
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +13 -12
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +46 -47
- package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +20 -13
- package/dist/generators/ts/_ObjectType/IdentifierProperty.js +152 -124
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.d.ts +87 -0
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.js +237 -0
- package/dist/generators/ts/_ObjectType/Property.d.ts +39 -44
- 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 +108 -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 +6 -5
- package/dist/generators/ts/_ObjectType/createFunctionDeclaration.js +5 -4
- package/dist/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +5 -4
- 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 +37 -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 +152 -0
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.js +4 -3
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.js +3 -2
- package/dist/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +103 -35
- package/dist/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +6 -6
- package/dist/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +15 -13
- 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 +6 -5
- package/dist/input/PropertyPath.js +14 -22
- package/dist/input/PropertyShape.d.ts +3 -1
- package/dist/input/PropertyShape.js +8 -2
- package/dist/input/ShapesGraph.js +4 -4
- package/dist/input/generated.d.ts +923 -105
- package/dist/input/generated.js +1865 -969
- package/dist/input/tsFeatures.d.ts +3 -2
- package/dist/input/tsFeatures.js +44 -27
- package/package.json +18 -16
- 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
|
|
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 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,47 @@ 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
|
+
return [
|
|
141
|
+
`const _${this.name}Either: purify.Either<Error, ${this.type.name}> = ${this.type.fromRdfExpression({ variables: { ...variables, ignoreRdfType: true, predicate: this.predicate, resourceValues: `${variables.resource}.values(${syntheticNamePrefix}properties.${this.name}["identifier"], { unique: true })` } })};`,
|
|
142
|
+
`if (_${this.name}Either.isLeft()) { return _${this.name}Either; }`,
|
|
143
|
+
`const ${this.name} = _${this.name}Either.unsafeCoerce();`,
|
|
144
|
+
];
|
|
145
|
+
}
|
|
150
146
|
sparqlConstructTemplateTriples({ variables, }) {
|
|
151
147
|
const objectString = `\`\${${variables.variablePrefix}}${pascalCase(this.name)}\``;
|
|
152
148
|
return this.type.sparqlConstructTemplateTriples({
|
|
153
|
-
|
|
149
|
+
allowIgnoreRdfType: true,
|
|
150
|
+
context: "object",
|
|
154
151
|
variables: {
|
|
155
|
-
object:
|
|
156
|
-
predicate: this.
|
|
152
|
+
object: `dataFactory.variable!(${objectString})`,
|
|
153
|
+
predicate: this.predicate,
|
|
157
154
|
subject: variables.subject,
|
|
158
155
|
variablePrefix: objectString,
|
|
159
156
|
},
|
|
@@ -162,10 +159,11 @@ export class ShaclProperty extends Property {
|
|
|
162
159
|
sparqlWherePatterns({ variables, }) {
|
|
163
160
|
const objectString = `\`\${${variables.variablePrefix}}${pascalCase(this.name)}\``;
|
|
164
161
|
return this.type.sparqlWherePatterns({
|
|
165
|
-
|
|
162
|
+
allowIgnoreRdfType: true,
|
|
163
|
+
context: "object",
|
|
166
164
|
variables: {
|
|
167
|
-
object:
|
|
168
|
-
predicate: this.
|
|
165
|
+
object: `dataFactory.variable!(${objectString})`,
|
|
166
|
+
predicate: this.predicate,
|
|
169
167
|
subject: variables.subject,
|
|
170
168
|
variablePrefix: objectString,
|
|
171
169
|
},
|
|
@@ -176,13 +174,38 @@ export class ShaclProperty extends Property {
|
|
|
176
174
|
}
|
|
177
175
|
toRdfStatements({ variables, }) {
|
|
178
176
|
return [
|
|
179
|
-
`${variables.resource}.add(${this.
|
|
180
|
-
variables: { ...variables, predicate: this.
|
|
177
|
+
`${variables.resource}.add(${this.predicate}, ${this.type.toRdfExpression({
|
|
178
|
+
variables: { ...variables, predicate: this.predicate },
|
|
181
179
|
})});`,
|
|
182
180
|
];
|
|
183
181
|
}
|
|
182
|
+
get declarationComment() {
|
|
183
|
+
return this.comment
|
|
184
|
+
.alt(this.description)
|
|
185
|
+
.alt(this.label)
|
|
186
|
+
.map(tsComment)
|
|
187
|
+
.extract();
|
|
188
|
+
}
|
|
189
|
+
get predicate() {
|
|
190
|
+
return `${this.objectType.staticModuleName}.${syntheticNamePrefix}properties.${this.name}["identifier"]`;
|
|
191
|
+
}
|
|
184
192
|
}
|
|
185
193
|
__decorate([
|
|
186
194
|
Memoize()
|
|
187
|
-
], ShaclProperty.prototype, "
|
|
195
|
+
], ShaclProperty.prototype, "constructorParametersPropertySignature", null);
|
|
196
|
+
__decorate([
|
|
197
|
+
Memoize()
|
|
198
|
+
], ShaclProperty.prototype, "jsonPropertySignature", null);
|
|
199
|
+
__decorate([
|
|
200
|
+
Memoize()
|
|
201
|
+
], ShaclProperty.prototype, "propertyDeclaration", null);
|
|
202
|
+
__decorate([
|
|
203
|
+
Memoize()
|
|
204
|
+
], ShaclProperty.prototype, "declarationImports", null);
|
|
205
|
+
__decorate([
|
|
206
|
+
Memoize()
|
|
207
|
+
], ShaclProperty.prototype, "propertySignature", null);
|
|
208
|
+
__decorate([
|
|
209
|
+
Memoize()
|
|
210
|
+
], ShaclProperty.prototype, "predicate", null);
|
|
188
211
|
//# 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 = "$strictEquals";
|
|
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 = `${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,5 +1,6 @@
|
|
|
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";
|
|
@@ -29,7 +30,7 @@ function constructorDeclaration() {
|
|
|
29
30
|
// of trying to sense whether we need to or not.
|
|
30
31
|
statements.push("super(parameters);");
|
|
31
32
|
}
|
|
32
|
-
const propertyStatements = this.properties.flatMap((property) => property.
|
|
33
|
+
const propertyStatements = this.properties.flatMap((property) => property.constructorStatements({
|
|
33
34
|
variables: { parameter: `parameters.${property.name}` },
|
|
34
35
|
}));
|
|
35
36
|
statements.push(...propertyStatements);
|
|
@@ -57,8 +58,8 @@ export function classDeclaration() {
|
|
|
57
58
|
const getAccessors = [];
|
|
58
59
|
const properties = [];
|
|
59
60
|
for (const property of this.properties) {
|
|
60
|
-
property.
|
|
61
|
-
property.
|
|
61
|
+
property.propertyDeclaration.ifJust((propertyDeclaration) => properties.push(propertyDeclaration));
|
|
62
|
+
property.getAccessorDeclaration.ifJust((getAccessor) => getAccessors.push(getAccessor));
|
|
62
63
|
}
|
|
63
64
|
return Maybe.of({
|
|
64
65
|
ctors: [constructorDeclaration.bind(this)()],
|
|
@@ -104,14 +105,14 @@ function toRdfMethodDeclaration() {
|
|
|
104
105
|
}));
|
|
105
106
|
}
|
|
106
107
|
function toStringMethodDeclaration() {
|
|
107
|
-
if (!this.features.has("
|
|
108
|
+
if (!this.features.has("json")) {
|
|
108
109
|
return Maybe.empty();
|
|
109
110
|
}
|
|
110
111
|
return Maybe.of({
|
|
111
112
|
hasOverrideKeyword: this.parentObjectTypes.length > 0,
|
|
112
113
|
name: "toString",
|
|
113
114
|
returnType: "string",
|
|
114
|
-
statements: [
|
|
115
|
+
statements: [`return JSON.stringify(this.${syntheticNamePrefix}toJson());`],
|
|
115
116
|
});
|
|
116
117
|
}
|
|
117
118
|
//# sourceMappingURL=classDeclaration.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { invariant } from "ts-invariant";
|
|
3
3
|
import { StructureKind } from "ts-morph";
|
|
4
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
4
5
|
export function createFunctionDeclaration() {
|
|
5
6
|
if (!this.features.has("create")) {
|
|
6
7
|
return Maybe.empty();
|
|
@@ -17,16 +18,16 @@ export function createFunctionDeclaration() {
|
|
|
17
18
|
// Should always have at least an identifier
|
|
18
19
|
invariant(parametersPropertySignatures.length > 0);
|
|
19
20
|
const parametersType = [`{ ${parametersPropertySignatures.join(", ")} }`]
|
|
20
|
-
.concat(this.parentObjectTypes.map((parentObjectType) => `Parameters<typeof ${parentObjectType.
|
|
21
|
+
.concat(this.parentObjectTypes.map((parentObjectType) => `Parameters<typeof ${parentObjectType.staticModuleName}.${syntheticNamePrefix}create>[0]`))
|
|
21
22
|
.join(" & ");
|
|
22
23
|
const propertyInitializers = [];
|
|
23
24
|
const omitPropertyNames = [];
|
|
24
25
|
const propertyStatements = [];
|
|
25
26
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
26
|
-
propertyInitializers.push(`...${parentObjectType.
|
|
27
|
+
propertyInitializers.push(`...${parentObjectType.staticModuleName}.${syntheticNamePrefix}create(parameters)`);
|
|
27
28
|
}
|
|
28
29
|
for (const property of this.properties) {
|
|
29
|
-
const thisPropertyStatements = property.
|
|
30
|
+
const thisPropertyStatements = property.constructorStatements({
|
|
30
31
|
variables: { parameter: `parameters.${property.name}` },
|
|
31
32
|
});
|
|
32
33
|
if (thisPropertyStatements.length > 0) {
|
|
@@ -42,7 +43,7 @@ export function createFunctionDeclaration() {
|
|
|
42
43
|
return Maybe.of({
|
|
43
44
|
isExported: true,
|
|
44
45
|
kind: StructureKind.Function,
|
|
45
|
-
name:
|
|
46
|
+
name: `${syntheticNamePrefix}create`,
|
|
46
47
|
parameters: [
|
|
47
48
|
{
|
|
48
49
|
name: "parameters",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
2
3
|
export function equalsFunctionOrMethodDeclaration() {
|
|
3
4
|
if (!this.features.has("equals")) {
|
|
4
5
|
return Maybe.empty();
|
|
@@ -23,14 +24,14 @@ export function equalsFunctionOrMethodDeclaration() {
|
|
|
23
24
|
if (this.parentObjectTypes.length > 0) {
|
|
24
25
|
switch (this.declarationType) {
|
|
25
26
|
case "class": {
|
|
26
|
-
chain.push(
|
|
27
|
+
chain.push(`super.${syntheticNamePrefix}equals(other)`);
|
|
27
28
|
hasOverrideKeyword = true;
|
|
28
29
|
break;
|
|
29
30
|
}
|
|
30
31
|
case "interface": {
|
|
31
32
|
// For every parent, find the nearest equals implementation
|
|
32
33
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
33
|
-
chain.push(`${parentObjectType.
|
|
34
|
+
chain.push(`${parentObjectType.staticModuleName}.${syntheticNamePrefix}equals(left, right)`);
|
|
34
35
|
}
|
|
35
36
|
break;
|
|
36
37
|
}
|
|
@@ -41,7 +42,7 @@ export function equalsFunctionOrMethodDeclaration() {
|
|
|
41
42
|
}
|
|
42
43
|
return Maybe.of({
|
|
43
44
|
hasOverrideKeyword,
|
|
44
|
-
name:
|
|
45
|
+
name: `${syntheticNamePrefix}equals`,
|
|
45
46
|
parameters: this.declarationType === "interface"
|
|
46
47
|
? [
|
|
47
48
|
{
|
|
@@ -59,7 +60,7 @@ export function equalsFunctionOrMethodDeclaration() {
|
|
|
59
60
|
type: this.name,
|
|
60
61
|
},
|
|
61
62
|
],
|
|
62
|
-
returnType:
|
|
63
|
+
returnType: `${syntheticNamePrefix}EqualsResult`,
|
|
63
64
|
statements: [
|
|
64
65
|
`return ${chain
|
|
65
66
|
.map((chainPart, chainPartI) => chainPartI === 0 ? chainPart : `chain(() => ${chainPart})`)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { type VariableStatementStructure } from "ts-morph";
|
|
3
3
|
import type { ObjectType } from "../ObjectType.js";
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function fromRdfTypeVariableStatement(this: ObjectType): Maybe<VariableStatementStructure>;
|
|
5
5
|
//# sourceMappingURL=fromRdfTypeVariableStatement.d.ts.map
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
|
-
import { StructureKind } from "ts-morph";
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { StructureKind, VariableDeclarationKind, } from "ts-morph";
|
|
3
|
+
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
4
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
5
|
+
export function fromRdfTypeVariableStatement() {
|
|
6
|
+
if (!this.features.has("rdf")) {
|
|
5
7
|
return Maybe.empty();
|
|
6
8
|
}
|
|
7
9
|
if (this.extern) {
|
|
@@ -11,11 +13,12 @@ export function fromRdfTypeVariableDeclaration() {
|
|
|
11
13
|
return Maybe.empty();
|
|
12
14
|
}
|
|
13
15
|
return Maybe.of({
|
|
16
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
14
17
|
kind: StructureKind.VariableStatement,
|
|
15
18
|
declarations: [
|
|
16
19
|
{
|
|
17
|
-
name:
|
|
18
|
-
initializer:
|
|
20
|
+
name: `${syntheticNamePrefix}fromRdfType`,
|
|
21
|
+
initializer: rdfjsTermExpression(this.fromRdfType.unsafeCoerce()),
|
|
19
22
|
type: "rdfjs.NamedNode<string>",
|
|
20
23
|
},
|
|
21
24
|
],
|