@shaclmate/compiler 4.0.33 → 4.0.34
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 +8 -8
- package/dist/generators/ts/AbstractCollectionType.js +28 -111
- package/dist/generators/ts/AbstractContainerType.d.ts +1 -1
- package/dist/generators/ts/AbstractDateType.d.ts +4 -9
- package/dist/generators/ts/AbstractDateType.js +2 -29
- package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -1
- package/dist/generators/ts/AbstractIdentifierType.js +0 -17
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +8 -5
- package/dist/generators/ts/AbstractLazyObjectType.js +21 -21
- package/dist/generators/ts/AbstractLiteralType.d.ts +11 -3
- package/dist/generators/ts/AbstractLiteralType.js +1 -1
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +2 -5
- package/dist/generators/ts/AbstractNamedUnionType.js +27 -58
- package/dist/generators/ts/AbstractNumericType.d.ts +9 -8
- package/dist/generators/ts/AbstractNumericType.js +18 -11
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +8 -4
- package/dist/generators/ts/AbstractPrimitiveType.js +9 -17
- package/dist/generators/ts/AbstractTermType.d.ts +8 -4
- package/dist/generators/ts/AbstractTermType.js +11 -51
- package/dist/generators/ts/AbstractType.d.ts +26 -22
- package/dist/generators/ts/AbstractType.js +4 -2
- package/dist/generators/ts/AbstractUnionType.d.ts +2 -2
- package/dist/generators/ts/AbstractUnionType.js +25 -36
- package/dist/generators/ts/AnonymousUnionType.d.ts +1 -1
- package/dist/generators/ts/AnonymousUnionType.js +3 -3
- package/dist/generators/ts/BigDecimalType.d.ts +5 -3
- package/dist/generators/ts/BigDecimalType.js +15 -42
- package/dist/generators/ts/BigIntType.d.ts +3 -4
- package/dist/generators/ts/BigIntType.js +5 -16
- package/dist/generators/ts/BlankNodeType.d.ts +7 -7
- package/dist/generators/ts/BlankNodeType.js +14 -2
- package/dist/generators/ts/BooleanType.d.ts +6 -8
- package/dist/generators/ts/BooleanType.js +18 -11
- package/dist/generators/ts/DateTimeType.d.ts +5 -1
- package/dist/generators/ts/DateTimeType.js +15 -13
- package/dist/generators/ts/DateType.d.ts +5 -1
- package/dist/generators/ts/DateType.js +16 -14
- package/dist/generators/ts/DefaultValueType.d.ts +5 -6
- package/dist/generators/ts/DefaultValueType.js +30 -64
- package/dist/generators/ts/FloatType.d.ts +3 -3
- package/dist/generators/ts/FloatType.js +5 -5
- package/dist/generators/ts/IdentifierType.d.ts +6 -6
- package/dist/generators/ts/IdentifierType.js +22 -2
- package/dist/generators/ts/IntType.d.ts +3 -3
- package/dist/generators/ts/IntType.js +5 -5
- package/dist/generators/ts/IriType.d.ts +17 -12
- package/dist/generators/ts/IriType.js +39 -29
- package/dist/generators/ts/LazyObjectOptionType.d.ts +2 -1
- package/dist/generators/ts/LazyObjectOptionType.js +23 -44
- package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectSetType.js +19 -29
- package/dist/generators/ts/LazyObjectType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectType.js +17 -25
- package/dist/generators/ts/LiteralType.d.ts +5 -3
- package/dist/generators/ts/LiteralType.js +25 -12
- package/dist/generators/ts/NamedObjectType.d.ts +6 -9
- package/dist/generators/ts/NamedObjectType.js +33 -29
- package/dist/generators/ts/NamedObjectUnionType.d.ts +3 -1
- package/dist/generators/ts/NamedObjectUnionType.js +21 -14
- package/dist/generators/ts/OptionType.d.ts +4 -4
- package/dist/generators/ts/OptionType.js +22 -45
- 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 +40 -8
- package/dist/generators/ts/Snippets.js +235 -30
- package/dist/generators/ts/StringType.d.ts +6 -9
- package/dist/generators/ts/StringType.js +17 -16
- package/dist/generators/ts/TermType.d.ts +1 -4
- package/dist/generators/ts/TermType.js +14 -8
- 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 +35 -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 +7 -16
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +26 -32
- 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 +22 -30
- 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_convertToBigDecimal.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.js +6 -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_convertToBoolean.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBoolean.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToDate.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToDate.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToDateTime.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToDateTime.js +6 -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_convertToMutableArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToMutableArray.js +14 -0
- package/dist/generators/ts/_snippets/snippets_convertToNumeric.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToNumeric.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToObject.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToObject.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToReadonlyArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToReadonlyArray.js +14 -0
- package/dist/generators/ts/_snippets/snippets_convertToString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToString.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToTerm.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToTerm.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToUnion.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToUnion.js +6 -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_toIsoDateString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_toIsoDateString.js +6 -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 +171 -226
- package/dist/input/generated.js +563 -2082
- 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
|
@@ -2,7 +2,7 @@ import { Maybe } from "purify-ts";
|
|
|
2
2
|
import { type Code } from "../ts-poet-wrapper.js";
|
|
3
3
|
import { AbstractProperty } from "./AbstractProperty.js";
|
|
4
4
|
export declare class DiscriminantProperty extends AbstractProperty<DiscriminantProperty.Type> {
|
|
5
|
-
readonly
|
|
5
|
+
readonly constructorParameter: Maybe<Code>;
|
|
6
6
|
readonly filterProperty: AbstractProperty<DiscriminantProperty.Type>["filterProperty"];
|
|
7
7
|
readonly graphqlField: AbstractProperty<DiscriminantProperty.Type>["graphqlField"];
|
|
8
8
|
readonly kind = "DiscriminantProperty";
|
|
@@ -15,17 +15,17 @@ export declare class DiscriminantProperty extends AbstractProperty<DiscriminantP
|
|
|
15
15
|
get jsonName(): string;
|
|
16
16
|
get jsonSchema(): AbstractProperty<DiscriminantProperty.Type>["jsonSchema"];
|
|
17
17
|
get jsonSignature(): Maybe<Code>;
|
|
18
|
-
private get
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
private get constValue();
|
|
19
|
+
constructorInitializer(): Maybe<Code>;
|
|
20
|
+
fromJsonInitializer(): Maybe<Code>;
|
|
21
|
+
fromRdfResourceValuesInitializer(): Maybe<Code>;
|
|
22
22
|
hashStatements({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["hashStatements"]>[0]): readonly Code[];
|
|
23
23
|
jsonUiSchemaElement({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
24
24
|
sparqlConstructTriplesExpression(): Maybe<Code>;
|
|
25
25
|
sparqlWherePatternsExpression(): ReturnType<AbstractProperty<DiscriminantProperty.Type>["sparqlWherePatternsExpression"]>;
|
|
26
|
-
|
|
26
|
+
toJsonInitializer({ variables, }: Parameters<AbstractProperty<DiscriminantProperty.Type>["toJsonInitializer"]>[0]): Maybe<Code>;
|
|
27
27
|
toRdfRdfResourceValuesStatements(): readonly Code[];
|
|
28
|
-
|
|
28
|
+
toStringInitializer(): Maybe<Code>;
|
|
29
29
|
}
|
|
30
30
|
export declare namespace DiscriminantProperty {
|
|
31
31
|
class Type {
|
|
@@ -10,7 +10,7 @@ import { removeUndefined } from "../removeUndefined.js";
|
|
|
10
10
|
import { arrayOf, code, literalOf } from "../ts-poet-wrapper.js";
|
|
11
11
|
import { AbstractProperty } from "./AbstractProperty.js";
|
|
12
12
|
export class DiscriminantProperty extends AbstractProperty {
|
|
13
|
-
|
|
13
|
+
constructorParameter = Maybe.empty();
|
|
14
14
|
filterProperty = Maybe.empty();
|
|
15
15
|
graphqlField = Maybe.empty();
|
|
16
16
|
kind = "DiscriminantProperty";
|
|
@@ -36,16 +36,16 @@ export class DiscriminantProperty extends AbstractProperty {
|
|
|
36
36
|
get jsonSignature() {
|
|
37
37
|
return Maybe.of(code `readonly "${this.jsonName}": ${this.type.name}`);
|
|
38
38
|
}
|
|
39
|
-
get
|
|
39
|
+
get constValue() {
|
|
40
40
|
return code `${literalOf(this.namedObjectType.discriminantValue)} as const`;
|
|
41
41
|
}
|
|
42
|
-
|
|
43
|
-
return
|
|
42
|
+
constructorInitializer() {
|
|
43
|
+
return Maybe.empty();
|
|
44
44
|
}
|
|
45
|
-
|
|
45
|
+
fromJsonInitializer() {
|
|
46
46
|
return Maybe.empty();
|
|
47
47
|
}
|
|
48
|
-
|
|
48
|
+
fromRdfResourceValuesInitializer() {
|
|
49
49
|
return Maybe.empty();
|
|
50
50
|
}
|
|
51
51
|
hashStatements({ variables, }) {
|
|
@@ -59,7 +59,7 @@ export class DiscriminantProperty extends AbstractProperty {
|
|
|
59
59
|
return Maybe.empty();
|
|
60
60
|
}
|
|
61
61
|
const scope = code `\`\${${variables.scopePrefix}}/properties/${this.jsonName}\``;
|
|
62
|
-
return Maybe.of(code `{ rule: { condition: { schema: { const: ${this.
|
|
62
|
+
return Maybe.of(code `{ rule: { condition: { schema: { const: ${this.constValue} }, scope: ${scope} }, effect: "HIDE" }, scope: ${scope}, type: "Control" }`);
|
|
63
63
|
}
|
|
64
64
|
sparqlConstructTriplesExpression() {
|
|
65
65
|
return Maybe.empty();
|
|
@@ -67,13 +67,13 @@ export class DiscriminantProperty extends AbstractProperty {
|
|
|
67
67
|
sparqlWherePatternsExpression() {
|
|
68
68
|
return Maybe.empty();
|
|
69
69
|
}
|
|
70
|
-
|
|
70
|
+
toJsonInitializer({ variables, }) {
|
|
71
71
|
return Maybe.of(code `"${this.jsonName}": ${variables.value}`);
|
|
72
72
|
}
|
|
73
73
|
toRdfRdfResourceValuesStatements() {
|
|
74
74
|
return [];
|
|
75
75
|
}
|
|
76
|
-
|
|
76
|
+
toStringInitializer() {
|
|
77
77
|
return Maybe.empty();
|
|
78
78
|
}
|
|
79
79
|
}
|
|
@@ -13,7 +13,7 @@ export declare class IdentifierProperty extends AbstractProperty<BlankNodeType |
|
|
|
13
13
|
type: BlankNodeType | IdentifierType | IriType;
|
|
14
14
|
typeAlias: Code;
|
|
15
15
|
} & ConstructorParameters<typeof AbstractProperty>[0]);
|
|
16
|
-
get
|
|
16
|
+
get constructorParameter(): Maybe<Code>;
|
|
17
17
|
get declaration(): Code;
|
|
18
18
|
get filterProperty(): Maybe<{
|
|
19
19
|
name: string;
|
|
@@ -23,9 +23,9 @@ export declare class IdentifierProperty extends AbstractProperty<BlankNodeType |
|
|
|
23
23
|
get jsonSchema(): AbstractProperty<IdentifierType>["jsonSchema"];
|
|
24
24
|
get jsonSignature(): Maybe<Code>;
|
|
25
25
|
accessExpression({ variables, }: Parameters<AbstractProperty<BlankNodeType | IdentifierType | IriType>["accessExpression"]>[0]): Code;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
constructorInitializer({ variables, }: Parameters<AbstractProperty<IdentifierType>["constructorInitializer"]>[0]): Maybe<Code>;
|
|
27
|
+
fromJsonInitializer({ variables, }: Parameters<AbstractProperty<IdentifierType>["fromJsonInitializer"]>[0]): Maybe<Code>;
|
|
28
|
+
fromRdfResourceValuesInitializer({ variables, }: Parameters<AbstractProperty<IdentifierType>["fromRdfResourceValuesInitializer"]>[0]): Maybe<Code>;
|
|
29
29
|
hashStatements({ variables, }: Parameters<AbstractProperty<IdentifierType>["hashStatements"]>[0]): readonly Code[];
|
|
30
30
|
jsonUiSchemaElement({ variables, }: Parameters<AbstractProperty<IdentifierType>["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
31
31
|
sparqlConstructTriplesExpression(): Maybe<Code>;
|
|
@@ -33,8 +33,8 @@ export declare class IdentifierProperty extends AbstractProperty<BlankNodeType |
|
|
|
33
33
|
condition: Code;
|
|
34
34
|
patterns: Code;
|
|
35
35
|
}>;
|
|
36
|
-
|
|
36
|
+
toJsonInitializer({ variables, }: Parameters<AbstractProperty<IdentifierType>["toJsonInitializer"]>[0]): Maybe<Code>;
|
|
37
37
|
toRdfRdfResourceValuesStatements(): readonly Code[];
|
|
38
|
-
|
|
38
|
+
toStringInitializer(parameters: Parameters<AbstractProperty<IdentifierType>["toStringInitializer"]>[0]): Maybe<Code>;
|
|
39
39
|
}
|
|
40
40
|
//# sourceMappingURL=IdentifierProperty.d.ts.map
|
|
@@ -9,9 +9,7 @@ import { rdf } from "@tpluscode/rdf-ns-builders";
|
|
|
9
9
|
import { Maybe } from "purify-ts";
|
|
10
10
|
import { invariant } from "ts-invariant";
|
|
11
11
|
import { Memoize } from "typescript-memoize";
|
|
12
|
-
import {
|
|
13
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
14
|
-
import { arrayOf, code, joinCode } from "../ts-poet-wrapper.js";
|
|
12
|
+
import { arrayOf, code, joinCode, literalOf, } from "../ts-poet-wrapper.js";
|
|
15
13
|
import { AbstractProperty } from "./AbstractProperty.js";
|
|
16
14
|
export class IdentifierProperty extends AbstractProperty {
|
|
17
15
|
typeAlias;
|
|
@@ -22,13 +20,15 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
22
20
|
super(superParameters);
|
|
23
21
|
this.typeAlias = typeAlias;
|
|
24
22
|
}
|
|
25
|
-
get
|
|
26
|
-
|
|
23
|
+
get constructorParameter() {
|
|
24
|
+
let hasQuestionToken = false;
|
|
27
25
|
const typeNames = [code `(() => ${this.typeAlias})`];
|
|
28
|
-
for (const
|
|
29
|
-
if (
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
for (const type of this.type.conversionFunction.sourceTypes) {
|
|
27
|
+
if (type.typeof === "undefined") {
|
|
28
|
+
hasQuestionToken = true;
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
typeNames.push(code `${type.name}`);
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
return Maybe.of(code `readonly ${this.name}${hasQuestionToken ? "?" : ""}: ${joinCode(typeNames, { on: "|" })};`);
|
|
@@ -43,6 +43,7 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
get graphqlField() {
|
|
46
|
+
const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
|
|
46
47
|
invariant(this.name.startsWith(syntheticNamePrefix));
|
|
47
48
|
return Maybe.of({
|
|
48
49
|
args: Maybe.empty(),
|
|
@@ -76,37 +77,32 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
76
77
|
accessExpression({ variables, }) {
|
|
77
78
|
return code `${variables.object}.${this.name}()`;
|
|
78
79
|
}
|
|
79
|
-
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
code `let ${this.name}: () => ${this.typeAlias};`,
|
|
85
|
-
];
|
|
86
|
-
const typeConversions = this.type.conversions;
|
|
87
|
-
const conversionBranches = [
|
|
88
|
-
code `if (typeof ${parameterVariable} === "function") { ${this.name} = ${parameterVariable}; }`,
|
|
89
|
-
];
|
|
90
|
-
for (const conversion of typeConversions) {
|
|
91
|
-
invariant(conversion.sourceTypeof !== "function");
|
|
92
|
-
invariant(conversion.sourceTypeof !== "undefined");
|
|
93
|
-
conversionBranches.push(code `if (${conversion.sourceTypeCheckExpression(parameterVariable)}) { ${this.name} = () => ${conversion.conversionExpression(parameterVariable)}; }`);
|
|
80
|
+
constructorInitializer({ variables, }) {
|
|
81
|
+
const nodeKinds = this.type.nodeKinds;
|
|
82
|
+
let conversionFunction;
|
|
83
|
+
if (nodeKinds.size === 2) {
|
|
84
|
+
conversionFunction = code `${this.reusables.snippets.convertToIdentifierProperty}`;
|
|
94
85
|
}
|
|
95
|
-
|
|
96
|
-
|
|
86
|
+
else {
|
|
87
|
+
invariant(nodeKinds.size === 1);
|
|
88
|
+
if (nodeKinds.has("BlankNode")) {
|
|
89
|
+
conversionFunction = code `${this.reusables.snippets.convertToBlankNodeIdentifierProperty}`;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
conversionFunction = code `${this.reusables.snippets.convertToIriIdentifierProperty}<${this.type.in_.length > 0
|
|
93
|
+
? joinCode(this.type.in_.map((in_) => code `${literalOf(in_.value)}`), { on: " | " })
|
|
94
|
+
: "string"}>`;
|
|
95
|
+
}
|
|
97
96
|
}
|
|
98
|
-
|
|
99
|
-
conversionBranches.push(code `{ ${this.name} = (${parameterVariable}) satisfies never;\n }`);
|
|
100
|
-
statements.push(joinCode(conversionBranches, { on: " else " }));
|
|
101
|
-
return statements;
|
|
97
|
+
return Maybe.of(code `${this.name}: ${conversionFunction}(${variables.parameters}.${this.name})`);
|
|
102
98
|
}
|
|
103
|
-
|
|
104
|
-
return Maybe.of(this.type.fromJsonExpression({
|
|
99
|
+
fromJsonInitializer({ variables, }) {
|
|
100
|
+
return Maybe.of(code `${this.name}: ${this.type.fromJsonExpression({
|
|
105
101
|
variables: { value: variables.jsonObject },
|
|
106
|
-
}));
|
|
102
|
+
})}`);
|
|
107
103
|
}
|
|
108
|
-
|
|
109
|
-
return Maybe.of(code `${this.type.fromRdfResourceValuesExpression({
|
|
104
|
+
fromRdfResourceValuesInitializer({ variables, }) {
|
|
105
|
+
return Maybe.of(code `${this.name}: ${this.type.fromRdfResourceValuesExpression({
|
|
110
106
|
variables: {
|
|
111
107
|
...variables,
|
|
112
108
|
propertyPath: this.rdfjsTermExpression(rdf.subject),
|
|
@@ -137,7 +133,7 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
137
133
|
}})`,
|
|
138
134
|
});
|
|
139
135
|
}
|
|
140
|
-
|
|
136
|
+
toJsonInitializer({ variables, }) {
|
|
141
137
|
const nodeKinds = [...this.type.nodeKinds];
|
|
142
138
|
const valueToNodeKinds = nodeKinds.map((nodeKind) => {
|
|
143
139
|
switch (nodeKind) {
|
|
@@ -158,13 +154,13 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
158
154
|
toRdfRdfResourceValuesStatements() {
|
|
159
155
|
return [];
|
|
160
156
|
}
|
|
161
|
-
|
|
162
|
-
return Maybe.of(this.type.toStringExpression(parameters));
|
|
157
|
+
toStringInitializer(parameters) {
|
|
158
|
+
return Maybe.of(code `${literalOf(this.name)}: ${this.type.toStringExpression(parameters)}`);
|
|
163
159
|
}
|
|
164
160
|
}
|
|
165
161
|
__decorate([
|
|
166
162
|
Memoize()
|
|
167
|
-
], IdentifierProperty.prototype, "
|
|
163
|
+
], IdentifierProperty.prototype, "constructorParameter", null);
|
|
168
164
|
__decorate([
|
|
169
165
|
Memoize()
|
|
170
166
|
], IdentifierProperty.prototype, "declaration", null);
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { invariant } from "ts-invariant";
|
|
3
|
-
import {
|
|
4
|
-
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
3
|
+
import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
|
|
5
4
|
export function NamedObjectType_createFunctionDeclaration() {
|
|
6
|
-
if (!this.features.has("create")) {
|
|
5
|
+
if (!this.configuration.features.has("create")) {
|
|
7
6
|
return Maybe.empty();
|
|
8
7
|
}
|
|
9
|
-
const parametersPropertySignatures = this.properties.flatMap((property) => property.
|
|
8
|
+
const parametersPropertySignatures = this.properties.flatMap((property) => property.constructorParameter.toList());
|
|
10
9
|
const parametersType = [];
|
|
11
10
|
if (parametersPropertySignatures.length > 0) {
|
|
12
11
|
parametersType.push(code `{ ${joinCode(parametersPropertySignatures)} }`);
|
|
@@ -17,40 +16,44 @@ export function NamedObjectType_createFunctionDeclaration() {
|
|
|
17
16
|
if (parametersType.length === 0) {
|
|
18
17
|
parametersType.push(code `object`);
|
|
19
18
|
}
|
|
20
|
-
const propertyInitializers = [];
|
|
21
|
-
const omitPropertyNames = [];
|
|
22
|
-
const propertyStatements = [];
|
|
23
|
-
for (const parentObjectType of this.parentObjectTypes) {
|
|
24
|
-
propertyInitializers.push(`...${parentObjectType.name}.create(parameters)`);
|
|
25
|
-
}
|
|
26
19
|
const parametersHasQuestionToken = this.parentObjectTypes.length === 0 &&
|
|
27
20
|
parametersPropertySignatures.every((propertySignature) => propertySignature.toCodeString([]).indexOf("?:") !== -1);
|
|
28
21
|
const parametersVariable = code `parameters${parametersHasQuestionToken ? "?" : ""}`;
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
22
|
+
const parametersSignature = code `parameters${parametersHasQuestionToken ? "?" : ""}: ${joinCode(parametersType, { on: " & " })}`;
|
|
23
|
+
const chains = [];
|
|
24
|
+
this.parentObjectTypes.forEach((parentObjectType, parentObjectTypeI) => {
|
|
25
|
+
chains.push({
|
|
26
|
+
expression: code `${parentObjectType.name}.create(parameters)`,
|
|
27
|
+
variable: `super${parentObjectTypeI}`,
|
|
35
28
|
});
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
}
|
|
29
|
+
});
|
|
30
|
+
const propertyInitializers = this.properties.flatMap((property) => property
|
|
31
|
+
.constructorInitializer({
|
|
32
|
+
variables: { parameters: parametersVariable },
|
|
33
|
+
})
|
|
34
|
+
.toList());
|
|
44
35
|
invariant(propertyInitializers.length > 0);
|
|
45
|
-
|
|
36
|
+
chains.push({
|
|
37
|
+
expression: code `${this.reusables.snippets.sequenceRecord}({ ${joinCode(propertyInitializers, { on: "," })} })`,
|
|
38
|
+
variable: "properties",
|
|
39
|
+
});
|
|
40
|
+
const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
|
|
46
41
|
return Maybe.of(code `\
|
|
47
|
-
export function create(
|
|
48
|
-
${
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
export function create(${parametersSignature}): ${this.reusables.imports.Either}<Error, ${this.name}> {
|
|
43
|
+
return ${chains.toReversed().reduce((acc, { expression, variable }, chainI) => code `(${expression}).${chainI === 0 ? "map" : "chain"}(${variable} => ${acc})`, code `\
|
|
44
|
+
{
|
|
45
|
+
const finalObject = { ${chains
|
|
46
|
+
.map((chain) => `...${chain.variable}`)
|
|
47
|
+
.join(", ")}, ${this._discriminantProperty.name}: ${literalOf(this.discriminantValue)} as const };
|
|
48
|
+
if (!globalThis.Object.prototype.hasOwnProperty.call(finalObject, "toString")) {
|
|
49
|
+
(finalObject as any).toString = ${syntheticNamePrefix}toString;
|
|
52
50
|
}
|
|
53
|
-
return
|
|
51
|
+
return finalObject;
|
|
52
|
+
}`)};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function createUnsafe(${parametersSignature}): ${this.name} {
|
|
56
|
+
return create(parameters).unsafeCoerce();
|
|
54
57
|
}`);
|
|
55
58
|
}
|
|
56
59
|
//# sourceMappingURL=NamedObjectType_createFunctionDeclaration.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function NamedObjectType_equalsFunctionDeclaration() {
|
|
4
|
-
if (!this.features.has("equals")) {
|
|
4
|
+
if (!this.configuration.features.has("equals")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
const chain = [];
|
|
@@ -7,7 +7,7 @@ const variables = {
|
|
|
7
7
|
variablePrefix: code `parameters.variablePrefix`,
|
|
8
8
|
};
|
|
9
9
|
export function NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration() {
|
|
10
|
-
if (!this.features.has("sparql")) {
|
|
10
|
+
if (!this.configuration.features.has("sparql")) {
|
|
11
11
|
return Maybe.empty();
|
|
12
12
|
}
|
|
13
13
|
const rdfClassVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
|
|
@@ -8,7 +8,7 @@ const variables = {
|
|
|
8
8
|
variablePrefix: code `parameters.variablePrefix`,
|
|
9
9
|
};
|
|
10
10
|
export function NamedObjectType_focusSparqlWherePatternsFunctionDeclaration() {
|
|
11
|
-
if (!this.features.has("sparql")) {
|
|
11
|
+
if (!this.configuration.features.has("sparql")) {
|
|
12
12
|
return Maybe.empty();
|
|
13
13
|
}
|
|
14
14
|
const rdfClassVariable = code `${this.reusables.imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
|
|
@@ -1,28 +1,19 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
3
2
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
4
|
-
const variables = {
|
|
5
|
-
jsonObject: code `${syntheticNamePrefix}json`,
|
|
6
|
-
};
|
|
7
3
|
export function NamedObjectType_fromJsonFunctionDeclaration() {
|
|
8
|
-
if (!this.features.has("json")) {
|
|
4
|
+
if (!this.configuration.features.has("json")) {
|
|
9
5
|
return Maybe.empty();
|
|
10
6
|
}
|
|
11
|
-
|
|
7
|
+
let initializers = [];
|
|
12
8
|
const statements = [];
|
|
9
|
+
const variables = {
|
|
10
|
+
jsonObject: code `${this.configuration.syntheticNamePrefix}json`,
|
|
11
|
+
};
|
|
13
12
|
this.parentObjectTypes.forEach((parentObjectType) => {
|
|
14
13
|
initializers.push(code `...${parentObjectType.name}.fromJson(${variables.jsonObject})`);
|
|
15
14
|
});
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
.fromJsonExpression({
|
|
19
|
-
variables,
|
|
20
|
-
})
|
|
21
|
-
.ifJust((propertyFromJsonExpression) => {
|
|
22
|
-
initializers.push(code `${property.name}: ${propertyFromJsonExpression}`);
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
statements.push(code `return create({ ${joinCode(initializers, { on: ", " })} });`);
|
|
15
|
+
initializers = initializers.concat(this.properties.flatMap((property) => property.fromJsonInitializer({ variables }).toList()));
|
|
16
|
+
statements.push(code `return createUnsafe({ ${joinCode(initializers, { on: ", " })} });`);
|
|
26
17
|
return Maybe.of(code `\
|
|
27
18
|
export function fromJson(${variables.jsonObject}: ${this.jsonType().name}): ${this.name} {
|
|
28
19
|
${joinCode(statements, { on: "\n" })}
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { rdf } from "@tpluscode/rdf-ns-builders";
|
|
2
2
|
import { Maybe } from "purify-ts";
|
|
3
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
4
3
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
5
|
-
const optionsVariable = `_${syntheticNamePrefix}options`;
|
|
6
|
-
const variables = {
|
|
7
|
-
context: code `${optionsVariable}.context`,
|
|
8
|
-
graph: code `${optionsVariable}.graph`,
|
|
9
|
-
ignoreRdfType: code `${optionsVariable}.ignoreRdfType`,
|
|
10
|
-
objectSet: code `${optionsVariable}.objectSet`,
|
|
11
|
-
preferredLanguages: code `${optionsVariable}.preferredLanguages`,
|
|
12
|
-
resource: code `${syntheticNamePrefix}resource`,
|
|
13
|
-
};
|
|
14
|
-
const propertyFromRdfResourceValuesExpressionVariable = {
|
|
15
|
-
context: variables.context,
|
|
16
|
-
graph: variables.graph,
|
|
17
|
-
objectSet: variables.objectSet,
|
|
18
|
-
preferredLanguages: variables.preferredLanguages,
|
|
19
|
-
resource: variables.resource,
|
|
20
|
-
};
|
|
21
4
|
export function NamedObjectType_fromRdfResourceFunctionDeclaration() {
|
|
22
|
-
if (!this.features.has("rdf")) {
|
|
5
|
+
if (!this.configuration.features.has("rdf")) {
|
|
23
6
|
return Maybe.empty();
|
|
24
7
|
}
|
|
8
|
+
const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
|
|
9
|
+
const optionsVariable = `_${syntheticNamePrefix}options`;
|
|
10
|
+
const variables = {
|
|
11
|
+
context: code `${optionsVariable}.context`,
|
|
12
|
+
graph: code `${optionsVariable}.graph`,
|
|
13
|
+
ignoreRdfType: code `${optionsVariable}.ignoreRdfType`,
|
|
14
|
+
objectSet: code `${optionsVariable}.objectSet`,
|
|
15
|
+
preferredLanguages: code `${optionsVariable}.preferredLanguages`,
|
|
16
|
+
resource: code `${syntheticNamePrefix}resource`,
|
|
17
|
+
};
|
|
18
|
+
const propertyFromRdfResourceValuesExpressionVariable = {
|
|
19
|
+
context: variables.context,
|
|
20
|
+
graph: variables.graph,
|
|
21
|
+
objectSet: variables.objectSet,
|
|
22
|
+
preferredLanguages: variables.preferredLanguages,
|
|
23
|
+
resource: variables.resource,
|
|
24
|
+
};
|
|
25
25
|
const chains = [];
|
|
26
26
|
const partials = [];
|
|
27
27
|
this.parentObjectTypes.forEach((parentObjectType, parentObjectTypeI) => {
|
|
@@ -60,20 +60,14 @@ export function NamedObjectType_fromRdfResourceFunctionDeclaration() {
|
|
|
60
60
|
variable: `_rdfTypeCheck`,
|
|
61
61
|
});
|
|
62
62
|
});
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
.ifJust((propertyFromRdfResourceValuesExpression) => {
|
|
70
|
-
propertyFromRdfResourceValuesExpressions[property.name] =
|
|
71
|
-
propertyFromRdfResourceValuesExpression;
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
if (Object.keys(propertyFromRdfResourceValuesExpressions).length > 0) {
|
|
63
|
+
const propertyFromRdfResourceValuesInitializers = this.properties.flatMap((property) => property
|
|
64
|
+
.fromRdfResourceValuesInitializer({
|
|
65
|
+
variables: propertyFromRdfResourceValuesExpressionVariable,
|
|
66
|
+
})
|
|
67
|
+
.toList());
|
|
68
|
+
if (Object.keys(propertyFromRdfResourceValuesInitializers).length > 0) {
|
|
75
69
|
chains.push({
|
|
76
|
-
expression: code `${this.reusables.snippets.sequenceRecord}(${
|
|
70
|
+
expression: code `${this.reusables.snippets.sequenceRecord}({ ${joinCode(propertyFromRdfResourceValuesInitializers, { on: ", " })} })`,
|
|
77
71
|
variable: "properties",
|
|
78
72
|
});
|
|
79
73
|
partials.push("properties");
|
|
@@ -98,7 +92,7 @@ export function NamedObjectType_fromRdfResourceFunctionDeclaration() {
|
|
|
98
92
|
else {
|
|
99
93
|
statements.push(code `return ${chains
|
|
100
94
|
.reverse()
|
|
101
|
-
.reduce((acc, { expression, variable }
|
|
95
|
+
.reduce((acc, { expression, variable }) => code `(${expression}).chain(${variable} => ${acc})`, code `(${resultExpression})`)}`);
|
|
102
96
|
}
|
|
103
97
|
return Maybe.of(code `\
|
|
104
98
|
export const _fromRdfResource: ${this.reusables.snippets._FromRdfResourceFunction}<${this.name}> = (${variables.resource}, ${optionsVariable}) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function NamedObjectType_fromRdfResourceValuesFunctionDeclaration() {
|
|
4
|
-
if (!this.features.has("rdf")) {
|
|
4
|
+
if (!this.configuration.features.has("rdf")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
return Maybe.of(code `\
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function NamedObjectType_fromRdfTypeVariableStatement() {
|
|
4
|
-
if (!this.features.has("rdf")) {
|
|
4
|
+
if (!this.configuration.features.has("rdf")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
return this.fromRdfType.map((fromRdfType) => code `\
|
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
3
2
|
import { code } from "../ts-poet-wrapper.js";
|
|
4
3
|
export function NamedObjectType_graphqlTypeVariableStatement() {
|
|
5
|
-
if (!this.features.has("graphql")) {
|
|
4
|
+
if (!this.configuration.features.has("graphql")) {
|
|
6
5
|
return Maybe.empty();
|
|
7
6
|
}
|
|
8
7
|
if (this.synthetic) {
|
|
9
8
|
return Maybe.empty();
|
|
10
9
|
}
|
|
11
10
|
return Maybe.of(code `\
|
|
12
|
-
export const GraphQL = new ${this.reusables.imports.GraphQLObjectType}<${this.name}, { objectSet: ${syntheticNamePrefix}ObjectSet }>(${{
|
|
11
|
+
export const GraphQL = new ${this.reusables.imports.GraphQLObjectType}<${this.name}, { objectSet: ${this.configuration.syntheticNamePrefix}ObjectSet }>(${{
|
|
13
12
|
description: this.comment.extract(),
|
|
14
13
|
fields: code `() => (${this.properties.reduce((fields, property) => {
|
|
15
14
|
property.graphqlField.ifJust((field) => {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
2
|
-
const hasherVariable = code `
|
|
2
|
+
const hasherVariable = code `hasher`;
|
|
3
3
|
export function NamedObjectType_hashFunctionDeclarations() {
|
|
4
|
-
if (!this.features.has("hash")) {
|
|
4
|
+
if (!this.configuration.features.has("hash")) {
|
|
5
5
|
return [];
|
|
6
6
|
}
|
|
7
7
|
const hashOwnShaclPropertiesStatements = this.properties.flatMap((property) => property.kind === "ShaclProperty"
|
|
8
8
|
? property.hashStatements({
|
|
9
|
-
depth: 0,
|
|
10
9
|
variables: {
|
|
11
10
|
hasher: hasherVariable,
|
|
12
11
|
value: property.accessExpression({
|
|
@@ -18,15 +17,14 @@ export function NamedObjectType_hashFunctionDeclarations() {
|
|
|
18
17
|
const hashShaclPropertiesStatements = [];
|
|
19
18
|
const hashStatements = [];
|
|
20
19
|
for (const parentObjectType of this.parentObjectTypes) {
|
|
21
|
-
hashShaclPropertiesStatements.push(code `${parentObjectType.name}.hashShaclProperties(${
|
|
20
|
+
hashShaclPropertiesStatements.push(code `${parentObjectType.name}.hashShaclProperties(${hasherVariable}, ${this.thisVariable});`);
|
|
22
21
|
}
|
|
23
|
-
hashStatements.push(code `${this.name}.hashShaclProperties(${
|
|
22
|
+
hashStatements.push(code `${this.name}.hashShaclProperties(${hasherVariable}, ${this.thisVariable});`);
|
|
24
23
|
hashShaclPropertiesStatements.push(...hashOwnShaclPropertiesStatements);
|
|
25
24
|
hashShaclPropertiesStatements.push(code `return ${hasherVariable};`);
|
|
26
25
|
hashStatements.push(...this.properties
|
|
27
26
|
.filter((property) => property.kind !== "ShaclProperty")
|
|
28
27
|
.flatMap((property) => property.hashStatements({
|
|
29
|
-
depth: 0,
|
|
30
28
|
variables: {
|
|
31
29
|
hasher: hasherVariable,
|
|
32
30
|
value: code `${property.accessExpression({ variables: { object: this.thisVariable } })}`,
|
|
@@ -35,11 +33,11 @@ export function NamedObjectType_hashFunctionDeclarations() {
|
|
|
35
33
|
hashStatements.push(code `return ${hasherVariable};`);
|
|
36
34
|
return [
|
|
37
35
|
code `\
|
|
38
|
-
export function hash<HasherT extends ${this.reusables.snippets.Hasher}>(${this.thisVariable}: ${this.name}
|
|
36
|
+
export function hash<HasherT extends ${this.reusables.snippets.Hasher}>(${hasherVariable}: HasherT, ${this.thisVariable}: ${this.name}): HasherT {
|
|
39
37
|
${joinCode(hashStatements)}
|
|
40
38
|
}`,
|
|
41
39
|
code `\
|
|
42
|
-
export function hashShaclProperties<HasherT extends ${this.reusables.snippets.Hasher}>(${this.thisVariable}: ${this.name}
|
|
40
|
+
export function hashShaclProperties<HasherT extends ${this.reusables.snippets.Hasher}>(${hasherVariable}: HasherT, ${this.thisVariable}: ${this.name}): HasherT {
|
|
43
41
|
${joinCode(hashShaclPropertiesStatements)}
|
|
44
42
|
}`,
|
|
45
43
|
];
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
2
1
|
import { code } from "../ts-poet-wrapper.js";
|
|
3
2
|
export function NamedObjectType_isTypeFunctionDeclaration() {
|
|
4
3
|
return code `\
|
|
5
|
-
export function is${this.name}(object: ${syntheticNamePrefix}Object): object is ${this.name} {
|
|
4
|
+
export function is${this.name}(object: ${this.configuration.syntheticNamePrefix}Object): object is ${this.name} {
|
|
6
5
|
switch (object.${this._discriminantProperty.name}) {
|
|
7
6
|
${this._discriminantProperty.type.descendantValues
|
|
8
7
|
.concat(this._discriminantProperty.type.ownValues)
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function NamedObjectType_jsonParseFunctionDeclaration() {
|
|
4
|
-
if (!this.features.has("json")) {
|
|
4
|
+
if (!this.configuration.features.has("json")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
return Maybe.of(code `\
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function NamedObjectType_jsonSchemaFunctionDeclaration() {
|
|
4
|
-
if (!this.features.has("json")) {
|
|
4
|
+
if (!this.configuration.features.has("json")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
let properties = [];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function NamedObjectType_jsonTypeAliasDeclaration() {
|
|
4
|
-
if (!this.features.has("json")) {
|
|
4
|
+
if (!this.configuration.features.has("json")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
const members = [];
|
package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
3
3
|
export function NamedObjectType_jsonUiSchemaFunctionDeclaration() {
|
|
4
|
-
if (!this.features.has("json")) {
|
|
4
|
+
if (!this.configuration.features.has("json")) {
|
|
5
5
|
return Maybe.empty();
|
|
6
6
|
}
|
|
7
7
|
const variables = { scopePrefix: code `scopePrefix` };
|