@shaclmate/compiler 4.0.33 → 4.0.35
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Compiler.d.ts +0 -3
- package/dist/Compiler.js +0 -2
- package/dist/ShapesGraphToAstTransformer.d.ts +1 -4
- package/dist/ShapesGraphToAstTransformer.js +1 -5
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +1 -3
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +4 -7
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +0 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +1 -3
- package/dist/ast/AbstractCompoundType.d.ts +6 -4
- package/dist/ast/AbstractCompoundType.js +4 -37
- package/dist/ast/ObjectType.d.ts +1 -7
- package/dist/ast/ObjectType.js +1 -6
- package/dist/generators/ts/AbstractCollectionType.d.ts +9 -8
- package/dist/generators/ts/AbstractCollectionType.js +38 -120
- package/dist/generators/ts/AbstractContainerType.d.ts +3 -1
- package/dist/generators/ts/AbstractContainerType.js +20 -0
- package/dist/generators/ts/AbstractDateType.d.ts +5 -10
- package/dist/generators/ts/AbstractDateType.js +5 -32
- package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -1
- package/dist/generators/ts/AbstractIdentifierType.js +0 -17
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +9 -5
- package/dist/generators/ts/AbstractLazyObjectType.js +22 -21
- package/dist/generators/ts/AbstractLiteralType.d.ts +12 -4
- package/dist/generators/ts/AbstractLiteralType.js +3 -3
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +2 -5
- package/dist/generators/ts/AbstractNamedUnionType.js +27 -58
- package/dist/generators/ts/AbstractNumericType.d.ts +3 -9
- package/dist/generators/ts/AbstractNumericType.js +6 -13
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +9 -4
- package/dist/generators/ts/AbstractPrimitiveType.js +11 -18
- package/dist/generators/ts/AbstractTermType.d.ts +10 -5
- package/dist/generators/ts/AbstractTermType.js +14 -53
- package/dist/generators/ts/AbstractType.d.ts +39 -24
- package/dist/generators/ts/AbstractType.js +4 -2
- package/dist/generators/ts/AbstractUnionType.d.ts +3 -2
- package/dist/generators/ts/AbstractUnionType.js +29 -39
- package/dist/generators/ts/AnonymousUnionType.d.ts +1 -1
- package/dist/generators/ts/AnonymousUnionType.js +3 -3
- package/dist/generators/ts/BigDecimalType.d.ts +7 -4
- package/dist/generators/ts/BigDecimalType.js +11 -45
- package/dist/generators/ts/BigIntType.d.ts +3 -4
- package/dist/generators/ts/BigIntType.js +6 -17
- package/dist/generators/ts/BlankNodeType.d.ts +8 -7
- package/dist/generators/ts/BlankNodeType.js +18 -5
- package/dist/generators/ts/BooleanType.d.ts +6 -9
- package/dist/generators/ts/BooleanType.js +9 -16
- package/dist/generators/ts/DateTimeType.d.ts +4 -1
- package/dist/generators/ts/DateTimeType.js +6 -13
- package/dist/generators/ts/DateType.d.ts +4 -1
- package/dist/generators/ts/DateType.js +7 -14
- package/dist/generators/ts/DefaultValueType.d.ts +6 -6
- package/dist/generators/ts/DefaultValueType.js +30 -63
- package/dist/generators/ts/FloatType.d.ts +3 -3
- package/dist/generators/ts/FloatType.js +5 -5
- package/dist/generators/ts/IdentifierType.d.ts +7 -6
- package/dist/generators/ts/IdentifierType.js +26 -5
- package/dist/generators/ts/IntType.d.ts +3 -3
- package/dist/generators/ts/IntType.js +5 -5
- package/dist/generators/ts/IriType.d.ts +9 -12
- package/dist/generators/ts/IriType.js +43 -32
- package/dist/generators/ts/LazyObjectOptionType.d.ts +2 -1
- package/dist/generators/ts/LazyObjectOptionType.js +23 -44
- package/dist/generators/ts/LazyObjectSetType.d.ts +2 -1
- package/dist/generators/ts/LazyObjectSetType.js +19 -29
- package/dist/generators/ts/LazyObjectType.d.ts +2 -1
- package/dist/generators/ts/LazyObjectType.js +18 -26
- package/dist/generators/ts/LiteralType.d.ts +6 -3
- package/dist/generators/ts/LiteralType.js +27 -13
- package/dist/generators/ts/NamedObjectType.d.ts +7 -9
- package/dist/generators/ts/NamedObjectType.js +24 -32
- package/dist/generators/ts/NamedObjectUnionType.d.ts +3 -1
- package/dist/generators/ts/NamedObjectUnionType.js +21 -14
- package/dist/generators/ts/OptionType.d.ts +6 -5
- package/dist/generators/ts/OptionType.js +31 -51
- package/dist/generators/ts/Reusables.d.ts +3 -1
- package/dist/generators/ts/Reusables.js +2 -1
- package/dist/generators/ts/SetType.d.ts +0 -1
- package/dist/generators/ts/SetType.js +4 -22
- package/dist/generators/ts/SnippetFactory.d.ts +2 -0
- package/dist/generators/ts/Snippets.d.ts +36 -8
- package/dist/generators/ts/Snippets.js +207 -30
- package/dist/generators/ts/StringType.d.ts +6 -10
- package/dist/generators/ts/StringType.js +8 -21
- package/dist/generators/ts/TermType.d.ts +2 -4
- package/dist/generators/ts/TermType.js +6 -10
- package/dist/generators/ts/TsGenerator.d.ts +14 -1
- package/dist/generators/ts/TsGenerator.js +41 -12
- package/dist/generators/ts/TypeFactory.d.ts +8 -4
- package/dist/generators/ts/TypeFactory.js +73 -49
- package/dist/generators/ts/ZodGenerator.js +6 -3
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +27 -20
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +4 -2
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +7 -7
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +9 -9
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +6 -6
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +36 -39
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +34 -31
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +31 -19
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +30 -36
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js +2 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +6 -8
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js +1 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts +2 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +14 -18
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +7 -7
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +41 -29
- package/dist/generators/ts/_snippets/snippets_ConversionFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_ConversionFunction.js +4 -0
- package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +3 -3
- package/dist/generators/ts/_snippets/snippets_HashFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_HashFunction.js +4 -0
- package/dist/generators/ts/_snippets/snippets_PropertyPath.js +34 -24
- package/dist/generators/ts/_snippets/snippets_ValidationFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_ValidationFunction.js +4 -0
- package/dist/generators/ts/_snippets/snippets_convertToArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToArray.js +8 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNode.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNode.js +11 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNodeIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNodeIdentifierProperty.js +17 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifier.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifier.js +13 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.js +21 -0
- package/dist/generators/ts/_snippets/snippets_convertToIri.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIri.js +11 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.js +17 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +15 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +31 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +25 -0
- package/dist/generators/ts/_snippets/snippets_convertToLiteral.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLiteral.js +13 -0
- package/dist/generators/ts/_snippets/snippets_convertToMaybe.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToMaybe.js +19 -0
- package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.js +11 -0
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_hashArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashArray.js +11 -0
- package/dist/generators/ts/_snippets/snippets_hashBigDecimal.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashBigDecimal.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashBoolean.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashBoolean.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashDate.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashDate.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashDateTime.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashDateTime.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashMaybe.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashMaybe.js +11 -0
- package/dist/generators/ts/_snippets/snippets_hashNumeric.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashNumeric.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashString.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashTerm.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashTerm.js +12 -0
- package/dist/generators/ts/_snippets/snippets_identityConversionFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_identityConversionFunction.js +6 -0
- package/dist/generators/ts/_snippets/snippets_identityValidationFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_identityValidationFunction.js +6 -0
- package/dist/generators/ts/_snippets/snippets_toIsoDateString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_toIsoDateString.js +6 -0
- package/dist/generators/ts/_snippets/snippets_validateArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_validateArray.js +13 -0
- package/dist/generators/ts/_snippets/snippets_validateMaybe.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_validateMaybe.js +7 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +1 -1
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +7 -4
- package/dist/generators/ts/objectSetDeclarations.js +4 -34
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +1 -1
- package/dist/generators/ts/objectSetMethodSignatures.js +2 -2
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +2 -2
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +2 -2
- package/dist/input/ShapesGraph.d.ts +5 -8
- package/dist/input/ShapesGraph.js +5 -6
- package/dist/input/generated.d.ts +175 -230
- package/dist/input/generated.js +226 -1748
- package/package.json +2 -2
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.d.ts +0 -6
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +0 -67
- package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.js +0 -6
- package/dist/generators/ts/syntheticNamePrefix.d.ts +0 -2
- package/dist/generators/ts/syntheticNamePrefix.js +0 -2
|
@@ -8,17 +8,28 @@ import { IriType } from "./IriType.js";
|
|
|
8
8
|
import { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
9
9
|
import { objectSetDeclarations } from "./objectSetDeclarations.js";
|
|
10
10
|
import { Reusables } from "./Reusables.js";
|
|
11
|
-
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
12
11
|
import { TypeFactory } from "./TypeFactory.js";
|
|
13
12
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
14
13
|
export class TsGenerator {
|
|
15
14
|
typeFactory;
|
|
15
|
+
configuration;
|
|
16
16
|
logger;
|
|
17
17
|
reusables;
|
|
18
|
-
constructor({ logger }) {
|
|
18
|
+
constructor({ configuration, logger, }) {
|
|
19
|
+
if (!configuration) {
|
|
20
|
+
configuration = TsGenerator.Configuration.default_;
|
|
21
|
+
}
|
|
22
|
+
this.configuration = {
|
|
23
|
+
...configuration,
|
|
24
|
+
features: TsGenerator.Configuration.inferFeatures(configuration.features),
|
|
25
|
+
};
|
|
19
26
|
this.logger = logger;
|
|
20
|
-
this.reusables = new Reusables({
|
|
27
|
+
this.reusables = new Reusables({
|
|
28
|
+
configuration: this.configuration,
|
|
29
|
+
logger,
|
|
30
|
+
});
|
|
21
31
|
this.typeFactory = new TypeFactory({
|
|
32
|
+
configuration: this.configuration,
|
|
22
33
|
logger,
|
|
23
34
|
reusables: this.reusables,
|
|
24
35
|
});
|
|
@@ -52,7 +63,7 @@ export class TsGenerator {
|
|
|
52
63
|
case 0:
|
|
53
64
|
break;
|
|
54
65
|
case 1:
|
|
55
|
-
declarations.push(code `type ${syntheticNamePrefix}Object = ${namedObjectTypesNameSorted[0].name};`);
|
|
66
|
+
declarations.push(code `type ${this.configuration.syntheticNamePrefix}Object = ${namedObjectTypesNameSorted[0].name};`);
|
|
56
67
|
break;
|
|
57
68
|
default: {
|
|
58
69
|
const uberObjectUnionType = this.synthesizeUberObjectUnionType(namedObjectTypesToposorted.toReversed());
|
|
@@ -89,6 +100,7 @@ export class TsGenerator {
|
|
|
89
100
|
if (nodeKinds.size === 2) {
|
|
90
101
|
identifierType = new IdentifierType({
|
|
91
102
|
comment: Maybe.empty(),
|
|
103
|
+
configuration: this.configuration,
|
|
92
104
|
label: Maybe.empty(),
|
|
93
105
|
logger: this.logger,
|
|
94
106
|
reusables: this.reusables,
|
|
@@ -99,6 +111,7 @@ export class TsGenerator {
|
|
|
99
111
|
case "BlankNode":
|
|
100
112
|
identifierType = new BlankNodeType({
|
|
101
113
|
comment: Maybe.empty(),
|
|
114
|
+
configuration: this.configuration,
|
|
102
115
|
label: Maybe.empty(),
|
|
103
116
|
logger: this.logger,
|
|
104
117
|
reusables: this.reusables,
|
|
@@ -107,6 +120,7 @@ export class TsGenerator {
|
|
|
107
120
|
case "IRI":
|
|
108
121
|
identifierType = new IriType({
|
|
109
122
|
comment: Maybe.empty(),
|
|
123
|
+
configuration: this.configuration,
|
|
110
124
|
hasValues: [],
|
|
111
125
|
in_: [],
|
|
112
126
|
label: Maybe.empty(),
|
|
@@ -118,13 +132,7 @@ export class TsGenerator {
|
|
|
118
132
|
}
|
|
119
133
|
return new NamedObjectUnionType({
|
|
120
134
|
comment: Maybe.empty(),
|
|
121
|
-
|
|
122
|
-
for (const feature of namedObjectType.features) {
|
|
123
|
-
features.add(feature);
|
|
124
|
-
}
|
|
125
|
-
features.delete("graphql");
|
|
126
|
-
return features;
|
|
127
|
-
}, new Set()),
|
|
135
|
+
configuration: this.configuration,
|
|
128
136
|
identifierType,
|
|
129
137
|
label: Maybe.empty(),
|
|
130
138
|
logger: this.logger,
|
|
@@ -132,10 +140,31 @@ export class TsGenerator {
|
|
|
132
140
|
discriminantValue: Maybe.empty(),
|
|
133
141
|
type: namedObjectType,
|
|
134
142
|
})),
|
|
135
|
-
name: `${syntheticNamePrefix}Object`,
|
|
143
|
+
name: `${this.configuration.syntheticNamePrefix}Object`,
|
|
136
144
|
recursive: false,
|
|
137
145
|
reusables: this.reusables,
|
|
146
|
+
synthetic: true,
|
|
138
147
|
});
|
|
139
148
|
}
|
|
140
149
|
}
|
|
150
|
+
(function (TsGenerator) {
|
|
151
|
+
let Configuration;
|
|
152
|
+
(function (Configuration) {
|
|
153
|
+
Configuration.default_ = {
|
|
154
|
+
features: new Set(["create", "equals", "hash", "json", "rdf"]),
|
|
155
|
+
syntheticNamePrefix: "$",
|
|
156
|
+
};
|
|
157
|
+
function inferFeatures(features) {
|
|
158
|
+
const inferredFeatures = new Set(features);
|
|
159
|
+
if (inferredFeatures.has("graphql") || inferredFeatures.has("sparql")) {
|
|
160
|
+
inferredFeatures.add("rdf");
|
|
161
|
+
}
|
|
162
|
+
if (inferredFeatures.has("json") || inferredFeatures.has("rdf")) {
|
|
163
|
+
inferredFeatures.add("create");
|
|
164
|
+
}
|
|
165
|
+
return inferredFeatures;
|
|
166
|
+
}
|
|
167
|
+
Configuration.inferFeatures = inferFeatures;
|
|
168
|
+
})(Configuration = TsGenerator.Configuration || (TsGenerator.Configuration = {}));
|
|
169
|
+
})(TsGenerator || (TsGenerator = {}));
|
|
141
170
|
//# sourceMappingURL=TsGenerator.js.map
|
|
@@ -6,19 +6,22 @@ import { NamedObjectType } from "./NamedObjectType.js";
|
|
|
6
6
|
import { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
7
7
|
import { NamedUnionType } from "./NamedUnionType.js";
|
|
8
8
|
import type { Reusables } from "./Reusables.js";
|
|
9
|
+
import type { TsGenerator } from "./TsGenerator.js";
|
|
9
10
|
import type { Type } from "./Type.js";
|
|
10
11
|
export declare class TypeFactory {
|
|
12
|
+
private readonly configuration;
|
|
13
|
+
private readonly logger;
|
|
14
|
+
private readonly reusables;
|
|
11
15
|
private cachedNamedObjectUnionTypesByShapeIdentifier;
|
|
12
16
|
private cachedObjectTypePropertiesByShapeIdentifier;
|
|
13
17
|
private cachedObjectTypesByShapeIdentifier;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
constructor({ logger, reusables }: {
|
|
18
|
+
constructor({ configuration, logger, reusables, }: {
|
|
19
|
+
configuration: TsGenerator.Configuration;
|
|
17
20
|
logger: Logger;
|
|
18
21
|
reusables: Reusables;
|
|
19
22
|
});
|
|
20
|
-
createNamedObjectUnionType(astType: ast.ObjectUnionType): NamedObjectUnionType;
|
|
21
23
|
createNamedObjectType(astType: ast.ObjectType): NamedObjectType;
|
|
24
|
+
createNamedObjectUnionType(astType: ast.ObjectUnionType): NamedObjectUnionType;
|
|
22
25
|
createType(astType: ast.Type, parameters?: {
|
|
23
26
|
defaultValue?: Literal | NamedNode;
|
|
24
27
|
}): Type;
|
|
@@ -36,5 +39,6 @@ export declare class TypeFactory {
|
|
|
36
39
|
private createOptionType;
|
|
37
40
|
private createSetType;
|
|
38
41
|
private createTermType;
|
|
42
|
+
private tsName;
|
|
39
43
|
}
|
|
40
44
|
//# sourceMappingURL=TypeFactory.d.ts.map
|
|
@@ -30,43 +30,20 @@ import { NamedUnionType } from "./NamedUnionType.js";
|
|
|
30
30
|
import { OptionType } from "./OptionType.js";
|
|
31
31
|
import { SetType } from "./SetType.js";
|
|
32
32
|
import { StringType } from "./StringType.js";
|
|
33
|
-
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
34
33
|
import { TermType } from "./TermType.js";
|
|
35
34
|
import { code } from "./ts-poet-wrapper.js";
|
|
36
35
|
export class TypeFactory {
|
|
36
|
+
configuration;
|
|
37
|
+
logger;
|
|
38
|
+
reusables;
|
|
37
39
|
cachedNamedObjectUnionTypesByShapeIdentifier = new TermMap();
|
|
38
40
|
cachedObjectTypePropertiesByShapeIdentifier = new TermMap();
|
|
39
41
|
cachedObjectTypesByShapeIdentifier = new TermMap();
|
|
40
|
-
logger
|
|
41
|
-
|
|
42
|
-
constructor({ logger, reusables }) {
|
|
42
|
+
constructor({ configuration, logger, reusables, }) {
|
|
43
|
+
this.configuration = configuration;
|
|
43
44
|
this.logger = logger;
|
|
44
45
|
this.reusables = reusables;
|
|
45
46
|
}
|
|
46
|
-
createNamedObjectUnionType(astType) {
|
|
47
|
-
{
|
|
48
|
-
const cachedNamedObjectUnionType = this.cachedNamedObjectUnionTypesByShapeIdentifier.get(astType.shapeIdentifier);
|
|
49
|
-
if (cachedNamedObjectUnionType) {
|
|
50
|
-
return cachedNamedObjectUnionType;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
const namedObjectUnionType = new NamedObjectUnionType({
|
|
54
|
-
comment: astType.comment,
|
|
55
|
-
features: astType.tsFeatures,
|
|
56
|
-
identifierType: this.createIdentifierType(ast.ObjectCompoundType.identifierType(astType)),
|
|
57
|
-
label: astType.label,
|
|
58
|
-
logger: this.logger,
|
|
59
|
-
members: ast.ObjectCompoundType.memberObjectTypes(astType).map((namedObjectType) => ({
|
|
60
|
-
discriminantValue: Maybe.empty(),
|
|
61
|
-
type: this.createNamedObjectType(namedObjectType),
|
|
62
|
-
})),
|
|
63
|
-
name: tsName(astType.name.unsafeCoerce()),
|
|
64
|
-
recursive: astType.recursive,
|
|
65
|
-
reusables: this.reusables,
|
|
66
|
-
});
|
|
67
|
-
this.cachedNamedObjectUnionTypesByShapeIdentifier.set(astType.shapeIdentifier, namedObjectUnionType);
|
|
68
|
-
return namedObjectUnionType;
|
|
69
|
-
}
|
|
70
47
|
createNamedObjectType(astType) {
|
|
71
48
|
{
|
|
72
49
|
const cachedObjectType = this.cachedObjectTypesByShapeIdentifier.get(astType.shapeIdentifier);
|
|
@@ -75,13 +52,13 @@ export class TypeFactory {
|
|
|
75
52
|
}
|
|
76
53
|
}
|
|
77
54
|
const identifierType = this.createIdentifierType(astType.identifierType);
|
|
78
|
-
const name = tsName(astType.name.unsafeCoerce(), {
|
|
55
|
+
const name = this.tsName(astType.name.unsafeCoerce(), {
|
|
79
56
|
synthetic: astType.synthetic,
|
|
80
57
|
});
|
|
81
58
|
const namedObjectType = new NamedObjectType({
|
|
82
59
|
comment: astType.comment,
|
|
60
|
+
configuration: this.configuration,
|
|
83
61
|
extern: astType.extern,
|
|
84
|
-
features: astType.tsFeatures,
|
|
85
62
|
fromRdfType: astType.fromRdfType,
|
|
86
63
|
identifierType,
|
|
87
64
|
label: astType.label,
|
|
@@ -95,8 +72,9 @@ export class TypeFactory {
|
|
|
95
72
|
discriminantDescendantValues.add(descendantObjectType.discriminantValue);
|
|
96
73
|
}
|
|
97
74
|
return new NamedObjectType.DiscriminantProperty({
|
|
75
|
+
configuration: this.configuration,
|
|
98
76
|
logger: this.logger,
|
|
99
|
-
name: `${syntheticNamePrefix}type`,
|
|
77
|
+
name: `${this.configuration.syntheticNamePrefix}type`,
|
|
100
78
|
namedObjectType,
|
|
101
79
|
reusables: this.reusables,
|
|
102
80
|
type: new NamedObjectType.DiscriminantProperty.Type({
|
|
@@ -116,7 +94,7 @@ export class TypeFactory {
|
|
|
116
94
|
if (left.order > right.order) {
|
|
117
95
|
return 1;
|
|
118
96
|
}
|
|
119
|
-
return tsName(left.name).localeCompare(tsName(right.name));
|
|
97
|
+
return this.tsName(left.name).localeCompare(this.tsName(right.name));
|
|
120
98
|
})
|
|
121
99
|
.map((astProperty) => this.createObjectTypeProperty({
|
|
122
100
|
astObjectTypeProperty: astProperty,
|
|
@@ -124,8 +102,9 @@ export class TypeFactory {
|
|
|
124
102
|
}));
|
|
125
103
|
properties.splice(0, 0, namedObjectType._discriminantProperty);
|
|
126
104
|
properties.splice(0, 0, new NamedObjectType.IdentifierProperty({
|
|
105
|
+
configuration: this.configuration,
|
|
127
106
|
logger: this.logger,
|
|
128
|
-
name: `${syntheticNamePrefix}identifier`,
|
|
107
|
+
name: `${this.configuration.syntheticNamePrefix}identifier`,
|
|
129
108
|
namedObjectType,
|
|
130
109
|
reusables: this.reusables,
|
|
131
110
|
type: identifierType,
|
|
@@ -143,6 +122,31 @@ export class TypeFactory {
|
|
|
143
122
|
this.cachedObjectTypesByShapeIdentifier.set(astType.shapeIdentifier, namedObjectType);
|
|
144
123
|
return namedObjectType;
|
|
145
124
|
}
|
|
125
|
+
createNamedObjectUnionType(astType) {
|
|
126
|
+
{
|
|
127
|
+
const cachedNamedObjectUnionType = this.cachedNamedObjectUnionTypesByShapeIdentifier.get(astType.shapeIdentifier);
|
|
128
|
+
if (cachedNamedObjectUnionType) {
|
|
129
|
+
return cachedNamedObjectUnionType;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
const namedObjectUnionType = new NamedObjectUnionType({
|
|
133
|
+
comment: astType.comment,
|
|
134
|
+
configuration: this.configuration,
|
|
135
|
+
identifierType: this.createIdentifierType(ast.ObjectCompoundType.identifierType(astType)),
|
|
136
|
+
label: astType.label,
|
|
137
|
+
logger: this.logger,
|
|
138
|
+
members: ast.ObjectCompoundType.memberObjectTypes(astType).map((namedObjectType) => ({
|
|
139
|
+
discriminantValue: Maybe.empty(),
|
|
140
|
+
type: this.createNamedObjectType(namedObjectType),
|
|
141
|
+
})),
|
|
142
|
+
name: this.tsName(astType.name.unsafeCoerce()),
|
|
143
|
+
recursive: astType.recursive,
|
|
144
|
+
reusables: this.reusables,
|
|
145
|
+
synthetic: astType.synthetic,
|
|
146
|
+
});
|
|
147
|
+
this.cachedNamedObjectUnionTypesByShapeIdentifier.set(astType.shapeIdentifier, namedObjectUnionType);
|
|
148
|
+
return namedObjectUnionType;
|
|
149
|
+
}
|
|
146
150
|
createType(astType, parameters) {
|
|
147
151
|
switch (astType.kind) {
|
|
148
152
|
case "BlankNodeType":
|
|
@@ -184,7 +188,7 @@ export class TypeFactory {
|
|
|
184
188
|
return astType.name
|
|
185
189
|
.map((name) => new NamedUnionType({
|
|
186
190
|
comment: astType.comment,
|
|
187
|
-
|
|
191
|
+
configuration: this.configuration,
|
|
188
192
|
identifierType: Maybe.empty(),
|
|
189
193
|
label: astType.label,
|
|
190
194
|
logger: this.logger,
|
|
@@ -198,6 +202,7 @@ export class TypeFactory {
|
|
|
198
202
|
}))
|
|
199
203
|
.orDefaultLazy(() => new AnonymousUnionType({
|
|
200
204
|
comment: astType.comment,
|
|
205
|
+
configuration: this.configuration,
|
|
201
206
|
label: astType.label,
|
|
202
207
|
identifierType: Maybe.empty(),
|
|
203
208
|
logger: this.logger,
|
|
@@ -212,6 +217,7 @@ export class TypeFactory {
|
|
|
212
217
|
createBlankNodeType(astType) {
|
|
213
218
|
return new BlankNodeType({
|
|
214
219
|
comment: astType.comment,
|
|
220
|
+
configuration: this.configuration,
|
|
215
221
|
label: astType.label,
|
|
216
222
|
logger: this.logger,
|
|
217
223
|
reusables: this.reusables,
|
|
@@ -224,6 +230,7 @@ export class TypeFactory {
|
|
|
224
230
|
invariant(DefaultValueType.isItemType(itemType));
|
|
225
231
|
return new DefaultValueType({
|
|
226
232
|
comment: astType.comment,
|
|
233
|
+
configuration: this.configuration,
|
|
227
234
|
defaultValue: astType.defaultValue,
|
|
228
235
|
itemType,
|
|
229
236
|
label: astType.label,
|
|
@@ -238,6 +245,7 @@ export class TypeFactory {
|
|
|
238
245
|
case "IdentifierType":
|
|
239
246
|
return new IdentifierType({
|
|
240
247
|
comment: astType.comment,
|
|
248
|
+
configuration: this.configuration,
|
|
241
249
|
label: astType.label,
|
|
242
250
|
logger: this.logger,
|
|
243
251
|
reusables: this.reusables,
|
|
@@ -249,6 +257,7 @@ export class TypeFactory {
|
|
|
249
257
|
createIriType(astType) {
|
|
250
258
|
return new IriType({
|
|
251
259
|
comment: astType.comment,
|
|
260
|
+
configuration: this.configuration,
|
|
252
261
|
hasValues: astType.hasValues,
|
|
253
262
|
in_: astType.in_,
|
|
254
263
|
label: astType.label,
|
|
@@ -259,6 +268,7 @@ export class TypeFactory {
|
|
|
259
268
|
createLazyObjectOptionType(astType) {
|
|
260
269
|
return new LazyObjectOptionType({
|
|
261
270
|
comment: astType.comment,
|
|
271
|
+
configuration: this.configuration,
|
|
262
272
|
label: astType.label,
|
|
263
273
|
logger: this.logger,
|
|
264
274
|
partialType: this.createOptionType(astType.partialType),
|
|
@@ -269,6 +279,7 @@ export class TypeFactory {
|
|
|
269
279
|
createLazyObjectSetType(astType) {
|
|
270
280
|
return new LazyObjectSetType({
|
|
271
281
|
comment: astType.comment,
|
|
282
|
+
configuration: this.configuration,
|
|
272
283
|
label: astType.label,
|
|
273
284
|
logger: this.logger,
|
|
274
285
|
partialType: this.createSetType(astType.partialType),
|
|
@@ -279,6 +290,7 @@ export class TypeFactory {
|
|
|
279
290
|
createLazyObjectType(astType) {
|
|
280
291
|
return new LazyObjectType({
|
|
281
292
|
comment: astType.comment,
|
|
293
|
+
configuration: this.configuration,
|
|
282
294
|
label: astType.label,
|
|
283
295
|
logger: this.logger,
|
|
284
296
|
partialType: this.createType(astType.partialType),
|
|
@@ -291,6 +303,7 @@ export class TypeFactory {
|
|
|
291
303
|
invariant(ListType.isItemType(itemType));
|
|
292
304
|
return new ListType({
|
|
293
305
|
comment: astType.comment,
|
|
306
|
+
configuration: this.configuration,
|
|
294
307
|
identifierNodeKind: astType.identifierNodeKind,
|
|
295
308
|
itemType,
|
|
296
309
|
label: astType.label,
|
|
@@ -327,6 +340,7 @@ export class TypeFactory {
|
|
|
327
340
|
case "bigdecimal":
|
|
328
341
|
return new BigDecimalType({
|
|
329
342
|
comment: astType.comment,
|
|
343
|
+
configuration: this.configuration,
|
|
330
344
|
hasValues: astType.hasValues,
|
|
331
345
|
in_: astType.in_,
|
|
332
346
|
label: astType.label,
|
|
@@ -337,6 +351,7 @@ export class TypeFactory {
|
|
|
337
351
|
case "bigint":
|
|
338
352
|
return new BigIntType({
|
|
339
353
|
comment: astType.comment,
|
|
354
|
+
configuration: this.configuration,
|
|
340
355
|
datatype,
|
|
341
356
|
hasValues: astType.hasValues,
|
|
342
357
|
in_: astType.in_,
|
|
@@ -349,6 +364,7 @@ export class TypeFactory {
|
|
|
349
364
|
case "boolean":
|
|
350
365
|
return new BooleanType({
|
|
351
366
|
comment: astType.comment,
|
|
367
|
+
configuration: this.configuration,
|
|
352
368
|
datatype,
|
|
353
369
|
hasValues: astType.hasValues,
|
|
354
370
|
label: astType.label,
|
|
@@ -362,6 +378,7 @@ export class TypeFactory {
|
|
|
362
378
|
case "datetime":
|
|
363
379
|
return new (datatypeDefinition.kind === "date" ? DateType : DateTimeType)({
|
|
364
380
|
comment: astType.comment,
|
|
381
|
+
configuration: this.configuration,
|
|
365
382
|
datatype,
|
|
366
383
|
hasValues: astType.hasValues,
|
|
367
384
|
in_: astType.in_,
|
|
@@ -377,6 +394,7 @@ export class TypeFactory {
|
|
|
377
394
|
case "int":
|
|
378
395
|
return new (datatypeDefinition.kind === "float" ? FloatType : IntType)({
|
|
379
396
|
comment: astType.comment,
|
|
397
|
+
configuration: this.configuration,
|
|
380
398
|
datatype,
|
|
381
399
|
hasValues: astType.hasValues,
|
|
382
400
|
in_: astType.in_,
|
|
@@ -392,6 +410,7 @@ export class TypeFactory {
|
|
|
392
410
|
if (!datatype.equals(rdf.langString)) {
|
|
393
411
|
return new StringType({
|
|
394
412
|
comment: astType.comment,
|
|
413
|
+
configuration: this.configuration,
|
|
395
414
|
datatype,
|
|
396
415
|
hasValues: astType.hasValues,
|
|
397
416
|
in_: astType.in_,
|
|
@@ -420,6 +439,7 @@ export class TypeFactory {
|
|
|
420
439
|
// }
|
|
421
440
|
return new LiteralType({
|
|
422
441
|
comment: astType.comment,
|
|
442
|
+
configuration: this.configuration,
|
|
423
443
|
hasValues: astType.hasValues,
|
|
424
444
|
in_: astType.in_,
|
|
425
445
|
label: astType.label,
|
|
@@ -437,13 +457,14 @@ export class TypeFactory {
|
|
|
437
457
|
}
|
|
438
458
|
const property = new NamedObjectType.ShaclProperty({
|
|
439
459
|
comment: astObjectTypeProperty.comment,
|
|
460
|
+
configuration: this.configuration,
|
|
440
461
|
description: astObjectTypeProperty.description,
|
|
441
462
|
display: astObjectTypeProperty.display,
|
|
442
463
|
label: astObjectTypeProperty.label,
|
|
443
464
|
logger: this.logger,
|
|
444
465
|
mutable: astObjectTypeProperty.mutable,
|
|
445
466
|
namedObjectType,
|
|
446
|
-
name: tsName(astObjectTypeProperty.name),
|
|
467
|
+
name: this.tsName(astObjectTypeProperty.name),
|
|
447
468
|
path: astObjectTypeProperty.path,
|
|
448
469
|
recursive: !!astObjectTypeProperty.recursive,
|
|
449
470
|
reusables: this.reusables,
|
|
@@ -457,6 +478,7 @@ export class TypeFactory {
|
|
|
457
478
|
invariant(OptionType.isItemType(itemType));
|
|
458
479
|
return new OptionType({
|
|
459
480
|
comment: astType.comment,
|
|
481
|
+
configuration: this.configuration,
|
|
460
482
|
itemType,
|
|
461
483
|
label: astType.label,
|
|
462
484
|
logger: this.logger,
|
|
@@ -468,6 +490,7 @@ export class TypeFactory {
|
|
|
468
490
|
invariant(SetType.isItemType(itemType));
|
|
469
491
|
return new SetType({
|
|
470
492
|
comment: astType.comment,
|
|
493
|
+
configuration: this.configuration,
|
|
471
494
|
itemType,
|
|
472
495
|
label: astType.label,
|
|
473
496
|
logger: this.logger,
|
|
@@ -479,6 +502,7 @@ export class TypeFactory {
|
|
|
479
502
|
createTermType(astType) {
|
|
480
503
|
return new TermType({
|
|
481
504
|
comment: astType.comment,
|
|
505
|
+
configuration: this.configuration,
|
|
482
506
|
hasValues: astType.hasValues,
|
|
483
507
|
in_: astType.in_,
|
|
484
508
|
label: astType.label,
|
|
@@ -487,21 +511,21 @@ export class TypeFactory {
|
|
|
487
511
|
reusables: this.reusables,
|
|
488
512
|
});
|
|
489
513
|
}
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
514
|
+
tsName(name, options) {
|
|
515
|
+
if (name[0] === "$") {
|
|
516
|
+
return name;
|
|
517
|
+
}
|
|
518
|
+
// Adapted from https://github.com/sindresorhus/to-valid-identifier , MIT license
|
|
519
|
+
if (reservedTsIdentifiers.has(name)) {
|
|
520
|
+
// We prefix with underscore to avoid any potential conflicts with the Base62 encoded string.
|
|
521
|
+
return `$_${name}$`;
|
|
522
|
+
}
|
|
523
|
+
let tsName = name.replaceAll(/\P{ID_Continue}/gu, (x) => `$${base62.encodeInteger(x.codePointAt(0))}$`);
|
|
524
|
+
if (options?.synthetic) {
|
|
525
|
+
tsName = `${this.configuration.syntheticNamePrefix}${tsName}`;
|
|
526
|
+
}
|
|
527
|
+
return tsName;
|
|
503
528
|
}
|
|
504
|
-
return tsName;
|
|
505
529
|
}
|
|
506
530
|
const reservedTsIdentifiers = reservedTsIdentifiers_({
|
|
507
531
|
includeGlobalProperties: true,
|
|
@@ -3,14 +3,17 @@ import * as ast from "../../ast/index.js";
|
|
|
3
3
|
import { NamedObjectType_jsonSchemaFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js";
|
|
4
4
|
import { NamedObjectType_jsonTypeAliasDeclaration } from "./_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js";
|
|
5
5
|
import { Reusables } from "./Reusables.js";
|
|
6
|
+
import { TsGenerator } from "./TsGenerator.js";
|
|
6
7
|
import { TypeFactory } from "./TypeFactory.js";
|
|
7
8
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
8
9
|
export class ZodGenerator {
|
|
9
10
|
reusables;
|
|
10
11
|
typeFactory;
|
|
11
12
|
constructor({ logger }) {
|
|
12
|
-
|
|
13
|
+
const configuration = TsGenerator.Configuration.default_;
|
|
14
|
+
this.reusables = new Reusables({ configuration, logger });
|
|
13
15
|
this.typeFactory = new TypeFactory({
|
|
16
|
+
configuration,
|
|
14
17
|
logger,
|
|
15
18
|
reusables: this.reusables,
|
|
16
19
|
});
|
|
@@ -20,10 +23,10 @@ export class ZodGenerator {
|
|
|
20
23
|
for (const namedObjectType of ast.ObjectType.toposort(ast_.namedObjectTypes).map((astObjectType) => this.typeFactory.createNamedObjectType(astObjectType))) {
|
|
21
24
|
declarations.push(code `\
|
|
22
25
|
export namespace ${namedObjectType.name} {
|
|
23
|
-
${joinCode(NamedObjectType_jsonTypeAliasDeclaration.
|
|
26
|
+
${joinCode(NamedObjectType_jsonTypeAliasDeclaration.call(namedObjectType).toList())}
|
|
24
27
|
|
|
25
28
|
export namespace Json {
|
|
26
|
-
${joinCode(NamedObjectType_jsonSchemaFunctionDeclaration.
|
|
29
|
+
${joinCode(NamedObjectType_jsonSchemaFunctionDeclaration.call(namedObjectType).toList())}
|
|
27
30
|
}
|
|
28
31
|
}`);
|
|
29
32
|
}
|
|
@@ -3,17 +3,18 @@ import type { Logger } from "ts-log";
|
|
|
3
3
|
import type { NamedObjectType } from "../NamedObjectType.js";
|
|
4
4
|
import type { Reusables } from "../Reusables.js";
|
|
5
5
|
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
6
|
+
import type { TsGenerator } from "../TsGenerator.js";
|
|
6
7
|
import type { Type } from "../Type.js";
|
|
7
8
|
import { type Code } from "../ts-poet-wrapper.js";
|
|
8
9
|
export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterFunction" | "mutable" | "name" | "schema">> {
|
|
10
|
+
protected readonly configuration: TsGenerator.Configuration;
|
|
9
11
|
protected readonly logger: Logger;
|
|
10
12
|
protected readonly namedObjectType: NamedObjectType;
|
|
11
13
|
protected readonly reusables: Reusables;
|
|
12
|
-
protected readonly rdfjsTermExpression: (parameters: Parameters<typeof rdfjsTermExpression>[0]) => Code;
|
|
13
14
|
/**
|
|
14
|
-
* Optional
|
|
15
|
+
* Optional parameter to include in the parameters object of constructor function.
|
|
15
16
|
*/
|
|
16
|
-
abstract readonly
|
|
17
|
+
abstract readonly constructorParameter: Maybe<Code>;
|
|
17
18
|
/**
|
|
18
19
|
* Property declaration to include in a class or interface declaration of the object type.
|
|
19
20
|
*/
|
|
@@ -38,18 +39,18 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterF
|
|
|
38
39
|
type: Code;
|
|
39
40
|
}>;
|
|
40
41
|
/**
|
|
41
|
-
* zod
|
|
42
|
+
* zod object key: schema.
|
|
42
43
|
*/
|
|
43
44
|
abstract readonly jsonSchema: Maybe<{
|
|
44
45
|
readonly key: string;
|
|
45
46
|
readonly schema: Code;
|
|
46
47
|
}>;
|
|
47
48
|
/**
|
|
48
|
-
* Signature of the property when serialized to JSON
|
|
49
|
+
* Signature of the property when serialized to JSON.
|
|
49
50
|
*/
|
|
50
51
|
abstract readonly jsonSignature: Maybe<Code>;
|
|
51
52
|
/**
|
|
52
|
-
* Property type
|
|
53
|
+
* Property type discriminant e.g., "ShaclProperty".
|
|
53
54
|
*/
|
|
54
55
|
abstract readonly kind: string;
|
|
55
56
|
/**
|
|
@@ -68,7 +69,8 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterF
|
|
|
68
69
|
* Property type
|
|
69
70
|
. */
|
|
70
71
|
readonly type: TypeT;
|
|
71
|
-
constructor({ logger, name, namedObjectType, reusables, type, }: {
|
|
72
|
+
constructor({ configuration, logger, name, namedObjectType, reusables, type, }: {
|
|
73
|
+
configuration: TsGenerator.Configuration;
|
|
72
74
|
logger: Logger;
|
|
73
75
|
name: string;
|
|
74
76
|
namedObjectType: NamedObjectType;
|
|
@@ -92,26 +94,25 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterF
|
|
|
92
94
|
};
|
|
93
95
|
}): Code;
|
|
94
96
|
/**
|
|
95
|
-
*
|
|
97
|
+
* Initializer (name: value) from a constructor parameter.
|
|
96
98
|
*/
|
|
97
|
-
abstract
|
|
99
|
+
abstract constructorInitializer(parameters: {
|
|
98
100
|
variables: {
|
|
99
|
-
parameter: Code;
|
|
100
101
|
parameters: Code;
|
|
101
102
|
};
|
|
102
|
-
}):
|
|
103
|
+
}): Maybe<Code>;
|
|
103
104
|
/**
|
|
104
|
-
*
|
|
105
|
+
* Initializer (name: value) from a JSON object.
|
|
105
106
|
*/
|
|
106
|
-
abstract
|
|
107
|
+
abstract fromJsonInitializer(parameters: {
|
|
107
108
|
variables: {
|
|
108
109
|
jsonObject: Code;
|
|
109
110
|
};
|
|
110
111
|
}): Maybe<Code>;
|
|
111
112
|
/**
|
|
112
|
-
*
|
|
113
|
+
* Initializer (name: value) from a rdfjsResource.Resource to a Either<Error, this property type>.
|
|
113
114
|
*/
|
|
114
|
-
abstract
|
|
115
|
+
abstract fromRdfResourceValuesInitializer(parameters: {
|
|
115
116
|
variables: {
|
|
116
117
|
context: Code;
|
|
117
118
|
graph: Code;
|
|
@@ -123,7 +124,12 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterF
|
|
|
123
124
|
/**
|
|
124
125
|
* Statements to hash this property using a hasher instance.
|
|
125
126
|
*/
|
|
126
|
-
abstract hashStatements(parameters:
|
|
127
|
+
abstract hashStatements(parameters: {
|
|
128
|
+
variables: {
|
|
129
|
+
hasher: Code;
|
|
130
|
+
value: Code;
|
|
131
|
+
};
|
|
132
|
+
}): readonly Code[];
|
|
127
133
|
/**
|
|
128
134
|
* Element object (usually a control https://jsonforms.io/docs/uischema/controls) for a JSON Forms UI schema.
|
|
129
135
|
*/
|
|
@@ -176,9 +182,9 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterF
|
|
|
176
182
|
patterns: Code;
|
|
177
183
|
}>;
|
|
178
184
|
/**
|
|
179
|
-
*
|
|
185
|
+
* Initializer (name: value) to JSON.
|
|
180
186
|
*/
|
|
181
|
-
abstract
|
|
187
|
+
abstract toJsonInitializer(parameters: {
|
|
182
188
|
variables: {
|
|
183
189
|
value: Code;
|
|
184
190
|
};
|
|
@@ -190,12 +196,13 @@ export declare abstract class AbstractProperty<TypeT extends Pick<Type, "filterF
|
|
|
190
196
|
variables: Omit<Parameters<Type["toRdfResourceValuesExpression"]>[0]["variables"], "propertyPath">;
|
|
191
197
|
}): readonly Code[];
|
|
192
198
|
/**
|
|
193
|
-
*
|
|
199
|
+
* Initializer (name: value) to serialize this property to a human-readable string (toString).
|
|
194
200
|
*/
|
|
195
|
-
abstract
|
|
201
|
+
abstract toStringInitializer(parameters: {
|
|
196
202
|
variables: {
|
|
197
203
|
value: Code;
|
|
198
204
|
};
|
|
199
205
|
}): Maybe<Code>;
|
|
206
|
+
protected readonly rdfjsTermExpression: (parameters: Parameters<typeof rdfjsTermExpression>[0]) => Code;
|
|
200
207
|
}
|
|
201
208
|
//# sourceMappingURL=AbstractProperty.d.ts.map
|
|
@@ -10,10 +10,10 @@ import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
|
10
10
|
import { removeUndefined } from "../removeUndefined.js";
|
|
11
11
|
import { code, literalOf } from "../ts-poet-wrapper.js";
|
|
12
12
|
export class AbstractProperty {
|
|
13
|
+
configuration;
|
|
13
14
|
logger;
|
|
14
15
|
namedObjectType;
|
|
15
16
|
reusables;
|
|
16
|
-
rdfjsTermExpression;
|
|
17
17
|
/**
|
|
18
18
|
* TypeScript identifier-safe name of the property.
|
|
19
19
|
*/
|
|
@@ -22,7 +22,8 @@ export class AbstractProperty {
|
|
|
22
22
|
* Property type
|
|
23
23
|
. */
|
|
24
24
|
type;
|
|
25
|
-
constructor({ logger, name, namedObjectType, reusables, type, }) {
|
|
25
|
+
constructor({ configuration, logger, name, namedObjectType, reusables, type, }) {
|
|
26
|
+
this.configuration = configuration;
|
|
26
27
|
this.logger = logger;
|
|
27
28
|
this.name = name;
|
|
28
29
|
this.namedObjectType = namedObjectType;
|
|
@@ -54,6 +55,7 @@ export class AbstractProperty {
|
|
|
54
55
|
accessExpression({ variables }) {
|
|
55
56
|
return code `${variables.object}.${this.name}`;
|
|
56
57
|
}
|
|
58
|
+
rdfjsTermExpression;
|
|
57
59
|
}
|
|
58
60
|
__decorate([
|
|
59
61
|
Memoize()
|