@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
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
1
2
|
import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
|
|
2
3
|
import type { SetType } from "./SetType.js";
|
|
3
4
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
4
5
|
export declare class LazyObjectSetType extends AbstractLazyObjectType<SetType<AbstractLazyObjectType.ObjectTypeConstraint>, SetType<AbstractLazyObjectType.ObjectTypeConstraint>> {
|
|
5
6
|
readonly graphqlArgs: Super["graphqlArgs"];
|
|
6
7
|
readonly kind = "LazyObjectSetType";
|
|
7
|
-
get
|
|
8
|
+
get conversionFunction(): Maybe<AbstractLazyObjectType.ConversionFunction>;
|
|
8
9
|
protected get runtimeClass(): {
|
|
9
10
|
name: Code;
|
|
10
11
|
partialPropertyName: string;
|
|
@@ -18,34 +18,24 @@ export class LazyObjectSetType extends AbstractLazyObjectType {
|
|
|
18
18
|
},
|
|
19
19
|
});
|
|
20
20
|
kind = "LazyObjectSetType";
|
|
21
|
-
get
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
sourceTypeName: code `readonly ${this.resolveType.itemType.name}[]`,
|
|
39
|
-
sourceTypeof: "object",
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
conversions.push({
|
|
43
|
-
conversionExpression: () => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: [], resolver: async () => { throw new Error("should never be called"); } })`,
|
|
44
|
-
sourceTypeCheckExpression: (value) => code `${value} === undefined`,
|
|
45
|
-
sourceTypeName: code `undefined`,
|
|
46
|
-
sourceTypeof: "undefined",
|
|
21
|
+
get conversionFunction() {
|
|
22
|
+
return Maybe.of({
|
|
23
|
+
code: code `${this.reusables.snippets.convertToLazyObjectSet}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.name}, ${this.resolveType.itemType.name}>(${this.resolveToPartialFunction({ partialType: this.partialType.itemType, resolveType: this.resolveType.itemType })})`,
|
|
24
|
+
sourceTypes: [
|
|
25
|
+
{
|
|
26
|
+
name: this.name,
|
|
27
|
+
typeof: "object",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: this.resolveType.name,
|
|
31
|
+
typeof: "object",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "undefined",
|
|
35
|
+
typeof: "undefined",
|
|
36
|
+
},
|
|
37
|
+
],
|
|
47
38
|
});
|
|
48
|
-
return conversions;
|
|
49
39
|
}
|
|
50
40
|
get runtimeClass() {
|
|
51
41
|
return {
|
|
@@ -55,7 +45,7 @@ export class LazyObjectSetType extends AbstractLazyObjectType {
|
|
|
55
45
|
};
|
|
56
46
|
}
|
|
57
47
|
fromJsonExpression(parameters) {
|
|
58
|
-
return code
|
|
48
|
+
return code `${this.partialType.fromJsonExpression(parameters)}.map(partial => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: partial, resolver: () => Promise.resolve(${this.reusables.imports.Left}(new Error("unable to resolve identifiers deserialized from JSON"))) }))`;
|
|
59
49
|
}
|
|
60
50
|
fromRdfResourceValuesExpression(parameters) {
|
|
61
51
|
const { variables } = parameters;
|
|
@@ -67,5 +57,5 @@ export class LazyObjectSetType extends AbstractLazyObjectType {
|
|
|
67
57
|
}
|
|
68
58
|
__decorate([
|
|
69
59
|
Memoize()
|
|
70
|
-
], LazyObjectSetType.prototype, "
|
|
60
|
+
], LazyObjectSetType.prototype, "conversionFunction", null);
|
|
71
61
|
//# sourceMappingURL=LazyObjectSetType.js.map
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
1
2
|
import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
|
|
2
3
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
3
4
|
export declare class LazyObjectType extends AbstractLazyObjectType<AbstractLazyObjectType.ObjectTypeConstraint, AbstractLazyObjectType.ObjectTypeConstraint> {
|
|
4
5
|
readonly graphqlArgs: Super["graphqlArgs"];
|
|
5
6
|
readonly kind = "LazyObjectType";
|
|
6
|
-
get
|
|
7
|
+
get conversionFunction(): Maybe<AbstractLazyObjectType.ConversionFunction>;
|
|
7
8
|
protected get runtimeClass(): {
|
|
8
9
|
name: Code;
|
|
9
10
|
partialPropertyName: string;
|
|
@@ -11,31 +11,20 @@ import { code } from "./ts-poet-wrapper.js";
|
|
|
11
11
|
export class LazyObjectType extends AbstractLazyObjectType {
|
|
12
12
|
graphqlArgs = Maybe.empty();
|
|
13
13
|
kind = "LazyObjectType";
|
|
14
|
-
get
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.resolveType.members.length === this.partialType.members.length) {
|
|
29
|
-
conversions.push({
|
|
30
|
-
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ((object: ${this.resolveType.name}) => { ${this.resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType: this.resolveType, partialNamedObjectUnionType: this.partialType, variables: { resolvedObjectUnion: code `object` } })} })(${value}), resolver: async () => ${this.reusables.imports.Right}(${value} as ${this.resolveType.name}) })`,
|
|
31
|
-
// Don't check instanceof value since the NamedObjectUnionType may be an interface
|
|
32
|
-
// Rely on the fact that this will be the last type check on an object
|
|
33
|
-
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
|
|
34
|
-
sourceTypeName: this.resolveType.name,
|
|
35
|
-
sourceTypeof: "object",
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return conversions;
|
|
14
|
+
get conversionFunction() {
|
|
15
|
+
return Maybe.of({
|
|
16
|
+
code: code `${this.reusables.snippets.convertToLazyObject}<${this.resolveType.identifierTypeAlias}, ${this.partialType.name}, ${this.resolveType.name}>(${this.resolveToPartialFunction({ partialType: this.partialType, resolveType: this.resolveType })})`,
|
|
17
|
+
sourceTypes: [
|
|
18
|
+
{
|
|
19
|
+
name: this.name,
|
|
20
|
+
typeof: "object",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: this.resolveType.name,
|
|
24
|
+
typeof: "object",
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
});
|
|
39
28
|
}
|
|
40
29
|
get runtimeClass() {
|
|
41
30
|
return {
|
|
@@ -45,7 +34,7 @@ export class LazyObjectType extends AbstractLazyObjectType {
|
|
|
45
34
|
};
|
|
46
35
|
}
|
|
47
36
|
fromJsonExpression(parameters) {
|
|
48
|
-
return code
|
|
37
|
+
return code `${this.partialType.fromJsonExpression(parameters)}.map(partial => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: partial, resolver: (identifier) => Promise.resolve(${this.reusables.imports.Left}(new Error(\`unable to resolve identifier \${identifier} deserialized from JSON\`))) }))`;
|
|
49
38
|
}
|
|
50
39
|
fromRdfResourceValuesExpression(parameters) {
|
|
51
40
|
const { variables } = parameters;
|
|
@@ -55,6 +44,9 @@ export class LazyObjectType extends AbstractLazyObjectType {
|
|
|
55
44
|
return code `${variables.value}.resolve().then(either => either.unsafeCoerce())`;
|
|
56
45
|
}
|
|
57
46
|
}
|
|
47
|
+
__decorate([
|
|
48
|
+
Memoize()
|
|
49
|
+
], LazyObjectType.prototype, "conversionFunction", null);
|
|
58
50
|
__decorate([
|
|
59
51
|
Memoize()
|
|
60
52
|
], LazyObjectType.prototype, "runtimeClass", null);
|
|
@@ -1,18 +1,21 @@
|
|
|
1
|
+
import type { Literal } from "@rdfjs/types";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
1
3
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
2
4
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
3
5
|
export declare class LiteralType extends AbstractLiteralType {
|
|
6
|
+
readonly name: Code;
|
|
7
|
+
readonly conversionFunction: Maybe<AbstractLiteralType.ConversionFunction>;
|
|
4
8
|
readonly filterFunction: Code;
|
|
5
9
|
readonly filterType: Code;
|
|
6
10
|
readonly kind = "LiteralType";
|
|
7
|
-
readonly name: Code;
|
|
8
11
|
readonly schemaType: Code;
|
|
9
12
|
readonly valueSparqlWherePatternsFunction: Code;
|
|
10
13
|
get graphqlType(): AbstractLiteralType.GraphqlType;
|
|
11
14
|
fromJsonExpression({ variables, }: Parameters<AbstractLiteralType["fromJsonExpression"]>[0]): Code;
|
|
12
15
|
graphqlResolveExpression(_parameters: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
|
|
13
|
-
hashStatements({ depth, variables, }: Parameters<AbstractLiteralType["hashStatements"]>[0]): readonly Code[];
|
|
14
|
-
jsonType(parameters?: Parameters<AbstractLiteralType["jsonType"]>[0]): AbstractLiteralType.JsonType;
|
|
15
16
|
jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractLiteralType["jsonSchema"]>[0]): Code;
|
|
17
|
+
jsonType(parameters?: Parameters<AbstractLiteralType["jsonType"]>[0]): AbstractLiteralType.JsonType;
|
|
18
|
+
literalExpression(literal: Literal): Code;
|
|
16
19
|
toJsonExpression({ includeDiscriminantProperty, variables, }: Parameters<AbstractLiteralType["toJsonExpression"]>[0]): Code;
|
|
17
20
|
}
|
|
18
21
|
//# sourceMappingURL=LiteralType.d.ts.map
|
|
@@ -1,28 +1,45 @@
|
|
|
1
1
|
import { xsd } from "@tpluscode/rdf-ns-builders";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
2
3
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
3
4
|
import { code } from "./ts-poet-wrapper.js";
|
|
4
5
|
export class LiteralType extends AbstractLiteralType {
|
|
6
|
+
name = code `${this.reusables.imports.Literal}`;
|
|
7
|
+
conversionFunction = Maybe.of({
|
|
8
|
+
code: code `${this.reusables.snippets.convertToLiteral}`,
|
|
9
|
+
sourceTypes: [
|
|
10
|
+
...["bigint", "boolean", "number", "string"].map((typeof_) => ({
|
|
11
|
+
name: typeof_,
|
|
12
|
+
typeof: typeof_,
|
|
13
|
+
})),
|
|
14
|
+
{
|
|
15
|
+
name: "Date",
|
|
16
|
+
typeof: "object",
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: code `${this.reusables.imports.Literal}`,
|
|
20
|
+
typeof: "object",
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
});
|
|
5
24
|
filterFunction = code `${this.reusables.snippets.filterLiteral}`;
|
|
6
25
|
filterType = code `${this.reusables.snippets.LiteralFilter}`;
|
|
7
26
|
kind = "LiteralType";
|
|
8
|
-
name = code `${this.reusables.imports.Literal}`;
|
|
9
27
|
schemaType = code `${this.reusables.snippets.LiteralSchema}`;
|
|
10
28
|
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.literalSparqlWherePatterns}`;
|
|
11
29
|
get graphqlType() {
|
|
12
30
|
throw new Error("not implemented");
|
|
13
31
|
}
|
|
14
32
|
fromJsonExpression({ variables, }) {
|
|
15
|
-
return code `${this.reusables.imports.dataFactory}.literal(${variables.value}["@value"], ${variables.value}["@language"] !== undefined ? ${variables.value}["@language"] : (${variables.value}["@type"] !== undefined ? ${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@type"]!) : undefined))`;
|
|
33
|
+
return code `${this.reusables.imports.Either}.of<Error, ${this.name}>(${this.reusables.imports.dataFactory}.literal(${variables.value}["@value"], ${variables.value}["@language"] !== undefined ? ${variables.value}["@language"] : (${variables.value}["@type"] !== undefined ? ${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@type"]!) : undefined)))`;
|
|
16
34
|
}
|
|
17
35
|
graphqlResolveExpression(_parameters) {
|
|
18
36
|
throw new Error("not implemented");
|
|
19
37
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
];
|
|
38
|
+
jsonSchema({ includeDiscriminantProperty, }) {
|
|
39
|
+
const discriminantProperty = includeDiscriminantProperty
|
|
40
|
+
? code `, termType: ${this.reusables.imports.z}.literal("Literal")`
|
|
41
|
+
: "";
|
|
42
|
+
return code `${this.reusables.imports.z}.object({ "@language": ${this.reusables.imports.z}.string().optional()${discriminantProperty}, "@type": ${this.reusables.imports.z}.string().optional(), "@value": ${this.reusables.imports.z}.string() })`;
|
|
26
43
|
}
|
|
27
44
|
jsonType(parameters) {
|
|
28
45
|
const discriminantProperty = parameters?.includeDiscriminantProperty
|
|
@@ -30,11 +47,8 @@ export class LiteralType extends AbstractLiteralType {
|
|
|
30
47
|
: "";
|
|
31
48
|
return new AbstractLiteralType.JsonType(code `{ readonly "@language"?: string${discriminantProperty}, readonly "@type"?: string, readonly "@value": string }`);
|
|
32
49
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
? code `, termType: ${this.reusables.imports.z}.literal("Literal")`
|
|
36
|
-
: "";
|
|
37
|
-
return code `${this.reusables.imports.z}.object({ "@language": ${this.reusables.imports.z}.string().optional()${discriminantProperty}, "@type": ${this.reusables.imports.z}.string().optional(), "@value": ${this.reusables.imports.z}.string() })`;
|
|
50
|
+
literalExpression(literal) {
|
|
51
|
+
return this.rdfjsTermExpression(literal);
|
|
38
52
|
}
|
|
39
53
|
toJsonExpression({ includeDiscriminantProperty, variables, }) {
|
|
40
54
|
return code `{ "@language": ${variables.value}.language.length > 0 ? ${variables.value}.language : undefined${includeDiscriminantProperty ? `, "termType": "Literal" as const` : ""}, "@type": ${variables.value}.datatype.value !== "${xsd.string.value}" ? ${variables.value}.datatype.value : undefined, "@value": ${variables.value}.value }`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NamedNode } from "@rdfjs/types";
|
|
2
|
-
import { Maybe
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
3
|
import { DiscriminantProperty as _DiscriminantProperty } from "./_NamedObjectType/DiscriminantProperty.js";
|
|
4
4
|
import { IdentifierProperty as _IdentifierProperty } from "./_NamedObjectType/IdentifierProperty.js";
|
|
5
5
|
import type { Property as _Property } from "./_NamedObjectType/Property.js";
|
|
@@ -8,13 +8,12 @@ import { AbstractType } from "./AbstractType.js";
|
|
|
8
8
|
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
9
9
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
10
10
|
import type { IriType } from "./IriType.js";
|
|
11
|
-
import type { TsFeature } from "./TsFeature.js";
|
|
12
11
|
import type { Type } from "./Type.js";
|
|
13
12
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
14
13
|
export declare class NamedObjectType extends AbstractType {
|
|
15
14
|
protected readonly toRdfTypes: readonly NamedNode[];
|
|
15
|
+
readonly conversionFunction: Maybe<AbstractType.ConversionFunction>;
|
|
16
16
|
readonly extern: boolean;
|
|
17
|
-
readonly features: ReadonlySet<TsFeature>;
|
|
18
17
|
readonly fromRdfType: Maybe<NamedNode>;
|
|
19
18
|
readonly graphqlArgs: AbstractType["graphqlArgs"];
|
|
20
19
|
readonly identifierType: BlankNodeType | IdentifierType | IriType;
|
|
@@ -22,11 +21,11 @@ export declare class NamedObjectType extends AbstractType {
|
|
|
22
21
|
readonly name: string;
|
|
23
22
|
readonly recursive: boolean;
|
|
24
23
|
readonly synthetic: boolean;
|
|
25
|
-
readonly typeofs:
|
|
26
|
-
|
|
24
|
+
readonly typeofs: "object"[];
|
|
25
|
+
readonly validationFunction: Maybe<Code>;
|
|
26
|
+
constructor({ extern, fromRdfType, identifierType, lazyAncestorObjectTypes, lazyChildObjectTypes, lazyDescendantObjectTypes, lazyDiscriminantProperty, lazyParentObjectTypes, lazyProperties, name, recursive, synthetic, toRdfTypes, ...superParameters }: {
|
|
27
27
|
comment: Maybe<string>;
|
|
28
28
|
extern: boolean;
|
|
29
|
-
features: ReadonlySet<TsFeature>;
|
|
30
29
|
fromRdfType: Maybe<NamedNode>;
|
|
31
30
|
identifierType: BlankNodeType | IdentifierType | IriType;
|
|
32
31
|
label: Maybe<string>;
|
|
@@ -44,7 +43,6 @@ export declare class NamedObjectType extends AbstractType {
|
|
|
44
43
|
get _discriminantProperty(): NamedObjectType.DiscriminantProperty;
|
|
45
44
|
get ancestorObjectTypes(): readonly NamedObjectType[];
|
|
46
45
|
get childObjectTypes(): readonly NamedObjectType[];
|
|
47
|
-
get conversions(): readonly AbstractType.Conversion[];
|
|
48
46
|
get declaration(): Maybe<Code>;
|
|
49
47
|
get descendantFromRdfTypeVariables(): readonly Code[];
|
|
50
48
|
get descendantFromRdfTypes(): readonly NamedNode[];
|
|
@@ -56,6 +54,7 @@ export declare class NamedObjectType extends AbstractType {
|
|
|
56
54
|
get filterType(): Code;
|
|
57
55
|
get fromRdfTypeVariable(): Maybe<Code>;
|
|
58
56
|
get graphqlType(): AbstractType.GraphqlType;
|
|
57
|
+
get hashFunction(): Code;
|
|
59
58
|
get identifierTypeAlias(): Code;
|
|
60
59
|
get mutable(): boolean;
|
|
61
60
|
get objectSetMethodNames(): NamedObjectType.ObjectSetMethodNames;
|
|
@@ -75,13 +74,12 @@ export declare class NamedObjectType extends AbstractType {
|
|
|
75
74
|
value: Code;
|
|
76
75
|
};
|
|
77
76
|
}): Code;
|
|
78
|
-
hashStatements({ variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
|
|
79
77
|
jsonSchema({ context, }: Parameters<AbstractType["jsonSchema"]>[0]): Code;
|
|
80
78
|
jsonType(): AbstractType.JsonType;
|
|
81
79
|
jsonUiSchemaElement({ variables, }: Parameters<AbstractType["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
82
80
|
toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
|
|
83
|
-
toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
|
|
84
81
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
82
|
+
toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
|
|
85
83
|
private readonly lazyAncestorObjectTypes;
|
|
86
84
|
private readonly lazyChildObjectTypes;
|
|
87
85
|
private readonly lazyDescendantObjectTypes;
|
|
@@ -6,7 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { NodeKind } from "@shaclmate/shacl-ast";
|
|
8
8
|
import { camelCase } from "change-case";
|
|
9
|
-
import { Maybe
|
|
9
|
+
import { Maybe } from "purify-ts";
|
|
10
10
|
import { Memoize } from "typescript-memoize";
|
|
11
11
|
import { DiscriminantProperty as _DiscriminantProperty } from "./_NamedObjectType/DiscriminantProperty.js";
|
|
12
12
|
import { IdentifierProperty as _IdentifierProperty } from "./_NamedObjectType/IdentifierProperty.js";
|
|
@@ -40,12 +40,11 @@ import { NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration } from "
|
|
|
40
40
|
import { NamedObjectType_valueSparqlWherePatternsFunctionDeclaration } from "./_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js";
|
|
41
41
|
import { ShaclProperty as _ShaclProperty } from "./_NamedObjectType/ShaclProperty.js";
|
|
42
42
|
import { AbstractType } from "./AbstractType.js";
|
|
43
|
-
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
44
43
|
import { code, def, joinCode } from "./ts-poet-wrapper.js";
|
|
45
44
|
export class NamedObjectType extends AbstractType {
|
|
46
45
|
toRdfTypes;
|
|
46
|
+
conversionFunction = Maybe.empty();
|
|
47
47
|
extern;
|
|
48
|
-
features;
|
|
49
48
|
fromRdfType;
|
|
50
49
|
graphqlArgs = Maybe.empty();
|
|
51
50
|
identifierType;
|
|
@@ -53,11 +52,11 @@ export class NamedObjectType extends AbstractType {
|
|
|
53
52
|
name;
|
|
54
53
|
recursive;
|
|
55
54
|
synthetic;
|
|
56
|
-
typeofs =
|
|
57
|
-
|
|
55
|
+
typeofs = ["object"];
|
|
56
|
+
validationFunction = Maybe.empty();
|
|
57
|
+
constructor({ extern, fromRdfType, identifierType, lazyAncestorObjectTypes, lazyChildObjectTypes, lazyDescendantObjectTypes, lazyDiscriminantProperty, lazyParentObjectTypes, lazyProperties, name, recursive, synthetic, toRdfTypes, ...superParameters }) {
|
|
58
58
|
super(superParameters);
|
|
59
59
|
this.extern = extern;
|
|
60
|
-
this.features = features;
|
|
61
60
|
this.fromRdfType = fromRdfType;
|
|
62
61
|
this.identifierType = identifierType;
|
|
63
62
|
// Lazily initialize some members in getters to avoid recursive construction
|
|
@@ -81,22 +80,12 @@ export class NamedObjectType extends AbstractType {
|
|
|
81
80
|
get childObjectTypes() {
|
|
82
81
|
return this.lazyChildObjectTypes();
|
|
83
82
|
}
|
|
84
|
-
get conversions() {
|
|
85
|
-
return [
|
|
86
|
-
{
|
|
87
|
-
conversionExpression: (value) => value,
|
|
88
|
-
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
|
|
89
|
-
sourceTypeName: this.name,
|
|
90
|
-
sourceTypeof: "object",
|
|
91
|
-
},
|
|
92
|
-
];
|
|
93
|
-
}
|
|
94
83
|
get declaration() {
|
|
95
84
|
const declarations = [];
|
|
96
85
|
if (!this.extern) {
|
|
97
86
|
const staticModuleDeclarations = [];
|
|
98
87
|
declarations.push(NamedObjectType_interfaceDeclaration.call(this));
|
|
99
|
-
staticModuleDeclarations.push(...NamedObjectType_createFunctionDeclaration.call(this).toList(), ...NamedObjectType_equalsFunctionDeclaration.
|
|
88
|
+
staticModuleDeclarations.push(...NamedObjectType_createFunctionDeclaration.call(this).toList(), ...NamedObjectType_equalsFunctionDeclaration.call(this).toList(), ...NamedObjectType_hashFunctionDeclarations.call(this));
|
|
100
89
|
const jsonModuleDeclarations = [
|
|
101
90
|
...NamedObjectType_jsonParseFunctionDeclaration.call(this).toList(),
|
|
102
91
|
...NamedObjectType_jsonSchemaFunctionDeclaration.call(this).toList(),
|
|
@@ -106,17 +95,17 @@ export class NamedObjectType extends AbstractType {
|
|
|
106
95
|
? [
|
|
107
96
|
code `export namespace Json { ${joinCode(jsonModuleDeclarations, { on: "\n\n" })} }`,
|
|
108
97
|
]
|
|
109
|
-
: []), NamedObjectType_filterFunctionDeclaration.call(this), NamedObjectType_filterTypeDeclaration.call(this), ...NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.
|
|
110
|
-
|
|
98
|
+
: []), NamedObjectType_filterFunctionDeclaration.call(this), NamedObjectType_filterTypeDeclaration.call(this), ...NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.call(this).toList(), ...NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromJsonFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfResourceFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfResourceValuesFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfTypeVariableStatement.call(this).toList(), NamedObjectType_isTypeFunctionDeclaration.call(this), NamedObjectType_schemaVariableStatement.call(this), ...NamedObjectType_sparqlConstructQueryFunctionDeclaration.call({
|
|
99
|
+
configuration: this.configuration,
|
|
111
100
|
filterType: this.filterType,
|
|
112
101
|
name: this.name,
|
|
113
102
|
reusables: this.reusables,
|
|
114
|
-
})
|
|
115
|
-
|
|
103
|
+
}).toList(), ...NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.call({
|
|
104
|
+
configuration: this.configuration,
|
|
116
105
|
filterType: this.filterType,
|
|
117
106
|
name: this.name,
|
|
118
107
|
reusables: this.reusables,
|
|
119
|
-
})
|
|
108
|
+
}).toList(), ...NamedObjectType_toJsonFunctionDeclaration.call(this).toList(), ...NamedObjectType_toRdfResourceFunctionDeclaration.call(this).toList(), ...NamedObjectType_toStringFunctionDeclarations.call(this), ...NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.call(this).toList(), ...NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.call(this).toList());
|
|
120
109
|
if (staticModuleDeclarations.length > 0) {
|
|
121
110
|
declarations.push(code `\
|
|
122
111
|
export namespace ${def(this.name)} {
|
|
@@ -161,6 +150,9 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
161
150
|
get graphqlType() {
|
|
162
151
|
return new AbstractType.GraphqlType(code `${this.name}.GraphQL`, this.reusables);
|
|
163
152
|
}
|
|
153
|
+
get hashFunction() {
|
|
154
|
+
return code `${this.name}.hash`;
|
|
155
|
+
}
|
|
164
156
|
get identifierTypeAlias() {
|
|
165
157
|
return code `${this.name}.Identifier`;
|
|
166
158
|
}
|
|
@@ -168,7 +160,10 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
168
160
|
return this.properties.some((property) => property.mutable);
|
|
169
161
|
}
|
|
170
162
|
get objectSetMethodNames() {
|
|
171
|
-
return NamedObjectType_objectSetMethodNames.call(
|
|
163
|
+
return NamedObjectType_objectSetMethodNames.call({
|
|
164
|
+
configuration: this.configuration,
|
|
165
|
+
name: this.name,
|
|
166
|
+
});
|
|
172
167
|
}
|
|
173
168
|
get parentObjectTypes() {
|
|
174
169
|
return this.lazyParentObjectTypes();
|
|
@@ -218,9 +213,6 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
218
213
|
graphqlResolveExpression({ variables, }) {
|
|
219
214
|
return variables.value;
|
|
220
215
|
}
|
|
221
|
-
hashStatements({ variables, }) {
|
|
222
|
-
return [code `${this.name}.hash(${variables.value}, ${variables.hasher});`];
|
|
223
|
-
}
|
|
224
216
|
jsonSchema({ context, }) {
|
|
225
217
|
let expression = code `${this.name}.Json.schema()`;
|
|
226
218
|
if (context === "property" &&
|
|
@@ -238,12 +230,12 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
238
230
|
toJsonExpression({ variables, }) {
|
|
239
231
|
return code `${this.name}.toJson(${variables.value})`;
|
|
240
232
|
}
|
|
241
|
-
toStringExpression({ variables, }) {
|
|
242
|
-
return code `${this.name}.${syntheticNamePrefix}toString(${variables.value})`;
|
|
243
|
-
}
|
|
244
233
|
toRdfResourceValuesExpression({ variables, }) {
|
|
245
234
|
return code `[${this.name}.toRdfResource(${variables.value}, { graph: ${variables.graph}, resourceSet: ${variables.resourceSet} }).identifier]`;
|
|
246
235
|
}
|
|
236
|
+
toStringExpression({ variables, }) {
|
|
237
|
+
return code `${this.name}.${this.configuration.syntheticNamePrefix}toString(${variables.value})`;
|
|
238
|
+
}
|
|
247
239
|
lazyAncestorObjectTypes;
|
|
248
240
|
lazyChildObjectTypes;
|
|
249
241
|
lazyDescendantObjectTypes;
|
|
@@ -260,9 +252,6 @@ __decorate([
|
|
|
260
252
|
__decorate([
|
|
261
253
|
Memoize()
|
|
262
254
|
], NamedObjectType.prototype, "childObjectTypes", null);
|
|
263
|
-
__decorate([
|
|
264
|
-
Memoize()
|
|
265
|
-
], NamedObjectType.prototype, "conversions", null);
|
|
266
255
|
__decorate([
|
|
267
256
|
Memoize()
|
|
268
257
|
], NamedObjectType.prototype, "descendantFromRdfTypeVariables", null);
|
|
@@ -293,6 +282,9 @@ __decorate([
|
|
|
293
282
|
__decorate([
|
|
294
283
|
Memoize()
|
|
295
284
|
], NamedObjectType.prototype, "graphqlType", null);
|
|
285
|
+
__decorate([
|
|
286
|
+
Memoize()
|
|
287
|
+
], NamedObjectType.prototype, "hashFunction", null);
|
|
296
288
|
__decorate([
|
|
297
289
|
Memoize()
|
|
298
290
|
], NamedObjectType.prototype, "identifierTypeAlias", null);
|
|
@@ -9,8 +9,10 @@ export declare class NamedObjectUnionType extends AbstractNamedUnionType<NamedOb
|
|
|
9
9
|
#private;
|
|
10
10
|
readonly graphqlArgs: AbstractType["graphqlArgs"];
|
|
11
11
|
readonly kind = "NamedObjectUnionType";
|
|
12
|
-
|
|
12
|
+
readonly synthetic: boolean;
|
|
13
|
+
constructor({ identifierType, synthetic, ...superParameters }: {
|
|
13
14
|
identifierType: BlankNodeType | IdentifierType | IriType;
|
|
15
|
+
synthetic: boolean;
|
|
14
16
|
} & Omit<ConstructorParameters<typeof AbstractNamedUnionType<NamedObjectType>>[0], "identifierType">);
|
|
15
17
|
get graphqlType(): AbstractType.GraphqlType;
|
|
16
18
|
get identifierTypeAlias(): Code;
|
|
@@ -14,15 +14,16 @@ import { NamedObjectType_sparqlConstructQueryStringFunctionDeclaration } from ".
|
|
|
14
14
|
import { AbstractNamedUnionType } from "./AbstractNamedUnionType.js";
|
|
15
15
|
import { AbstractType } from "./AbstractType.js";
|
|
16
16
|
import { singleEntryRecord } from "./singleEntryRecord.js";
|
|
17
|
-
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
18
17
|
import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
|
|
19
18
|
export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
20
19
|
#identifierType;
|
|
21
20
|
graphqlArgs = Maybe.empty();
|
|
22
21
|
kind = "NamedObjectUnionType";
|
|
23
|
-
|
|
22
|
+
synthetic;
|
|
23
|
+
constructor({ identifierType, synthetic, ...superParameters }) {
|
|
24
24
|
super({ ...superParameters, identifierType: Maybe.of(identifierType) });
|
|
25
25
|
this.#identifierType = identifierType;
|
|
26
|
+
this.synthetic = synthetic;
|
|
26
27
|
}
|
|
27
28
|
get graphqlType() {
|
|
28
29
|
return new AbstractType.GraphqlType(code `${this._name}.GraphQL`, this.reusables);
|
|
@@ -31,7 +32,10 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
31
32
|
return code `${this.name}.Identifier`;
|
|
32
33
|
}
|
|
33
34
|
get objectSetMethodNames() {
|
|
34
|
-
return NamedObjectType_objectSetMethodNames.call(
|
|
35
|
+
return NamedObjectType_objectSetMethodNames.call({
|
|
36
|
+
configuration: this.configuration,
|
|
37
|
+
name: this.name,
|
|
38
|
+
});
|
|
35
39
|
}
|
|
36
40
|
get schema() {
|
|
37
41
|
return code `${this.name}.schema`;
|
|
@@ -50,7 +54,7 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
50
54
|
...this.isTypeFunctionDeclaration,
|
|
51
55
|
...this.schemaVariableStatement,
|
|
52
56
|
...NamedObjectType_sparqlConstructQueryFunctionDeclaration.call({
|
|
53
|
-
|
|
57
|
+
configuration: this.configuration,
|
|
54
58
|
filterType: this.filterType,
|
|
55
59
|
name: this.name,
|
|
56
60
|
reusables: this.reusables,
|
|
@@ -58,7 +62,7 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
58
62
|
.map((code_) => singleEntryRecord(`sparqlConstructQuery`, code_))
|
|
59
63
|
.orDefault({}),
|
|
60
64
|
...NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.call({
|
|
61
|
-
|
|
65
|
+
configuration: this.configuration,
|
|
62
66
|
filterType: this.filterType,
|
|
63
67
|
name: this.name,
|
|
64
68
|
reusables: this.reusables,
|
|
@@ -69,7 +73,7 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
|
|
|
69
73
|
};
|
|
70
74
|
}
|
|
71
75
|
get focusSparqlConstructTriplesFunctionDeclaration() {
|
|
72
|
-
if (!this.features.has("sparql")) {
|
|
76
|
+
if (!this.configuration.features.has("sparql")) {
|
|
73
77
|
return {};
|
|
74
78
|
}
|
|
75
79
|
return singleEntryRecord(`focusSparqlConstructTriples`, code `\
|
|
@@ -78,7 +82,7 @@ export function focusSparqlConstructTriples({ filter, focusIdentifier, variableP
|
|
|
78
82
|
}`);
|
|
79
83
|
}
|
|
80
84
|
get focusSparqlWherePatternsFunctionDeclaration() {
|
|
81
|
-
if (!this.features.has("sparql")) {
|
|
85
|
+
if (!this.configuration.features.has("sparql")) {
|
|
82
86
|
return {};
|
|
83
87
|
}
|
|
84
88
|
return singleEntryRecord(`focusSparqlWherePatterns`, code `\
|
|
@@ -88,7 +92,7 @@ ${joinCode([
|
|
|
88
92
|
code `\
|
|
89
93
|
if (focusIdentifier.termType === "Variable") {
|
|
90
94
|
patterns = patterns.concat(${this.#identifierType.valueSparqlWherePatternsFunction}({
|
|
91
|
-
filter: filter?.${syntheticNamePrefix}identifier,
|
|
95
|
+
filter: filter?.${this.configuration.syntheticNamePrefix}identifier,
|
|
92
96
|
ignoreRdfType: false,
|
|
93
97
|
preferredLanguages,
|
|
94
98
|
propertyPatterns: [],
|
|
@@ -106,7 +110,7 @@ if (focusIdentifier.termType === "Variable") {
|
|
|
106
110
|
}`);
|
|
107
111
|
}
|
|
108
112
|
get fromRdfResourceFunctionDeclaration() {
|
|
109
|
-
if (!this.features.has("rdf")) {
|
|
113
|
+
if (!this.configuration.features.has("rdf")) {
|
|
110
114
|
return {};
|
|
111
115
|
}
|
|
112
116
|
return singleEntryRecord(`fromRdfResource`, code `\
|
|
@@ -119,14 +123,17 @@ export const fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}
|
|
|
119
123
|
}, null)};`);
|
|
120
124
|
}
|
|
121
125
|
get graphqlTypeVariableStatement() {
|
|
122
|
-
if (!this.features.has("graphql")) {
|
|
126
|
+
if (!this.configuration.features.has("graphql")) {
|
|
127
|
+
return {};
|
|
128
|
+
}
|
|
129
|
+
if (this.synthetic) {
|
|
123
130
|
return {};
|
|
124
131
|
}
|
|
125
132
|
return singleEntryRecord(`GraphQL`, code `\
|
|
126
133
|
export const GraphQL = new ${this.reusables.imports.GraphQLUnionType}(${{
|
|
127
134
|
description: this.comment.map(JSON.stringify).extract(),
|
|
128
135
|
name: this.name,
|
|
129
|
-
resolveType: code `(value: ${this.name}) => value.${syntheticNamePrefix}type`,
|
|
136
|
+
resolveType: code `(value: ${this.name}) => value.${this.configuration.syntheticNamePrefix}type`,
|
|
130
137
|
types: code `[${joinCode(this.members.map((member) => member.type.graphqlType.nullableName), { on: ", " })}]`,
|
|
131
138
|
}});`);
|
|
132
139
|
}
|
|
@@ -139,11 +146,11 @@ export namespace Identifier {
|
|
|
139
146
|
}`);
|
|
140
147
|
}
|
|
141
148
|
get isTypeFunctionDeclaration() {
|
|
142
|
-
if (this._name === `${syntheticNamePrefix}Object`) {
|
|
149
|
+
if (this._name === `${this.configuration.syntheticNamePrefix}Object`) {
|
|
143
150
|
return {};
|
|
144
151
|
}
|
|
145
152
|
return singleEntryRecord(`is${this._name}`, code `\
|
|
146
|
-
export function is${this._name}(object: ${syntheticNamePrefix}Object): object is ${this.name} {
|
|
153
|
+
export function is${this._name}(object: ${this.configuration.syntheticNamePrefix}Object): object is ${this.name} {
|
|
147
154
|
return ${joinCode(this.members.map((member) => code `${member.type.name}.is${member.type.name}(object)`), { on: " || " })};
|
|
148
155
|
}`);
|
|
149
156
|
}
|
|
@@ -185,7 +192,7 @@ ${{
|
|
|
185
192
|
}} as const;`);
|
|
186
193
|
}
|
|
187
194
|
get toRdfResourceFunctionDeclaration() {
|
|
188
|
-
if (!this.features.has("rdf")) {
|
|
195
|
+
if (!this.configuration.features.has("rdf")) {
|
|
189
196
|
return {};
|
|
190
197
|
}
|
|
191
198
|
return singleEntryRecord(`toRdfResource`, code `\
|