@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
|
@@ -33,6 +33,20 @@ export class AbstractContainerType extends AbstractType {
|
|
|
33
33
|
get toRdfResourceValueTypes() {
|
|
34
34
|
return this.itemType.toRdfResourceValueTypes;
|
|
35
35
|
}
|
|
36
|
+
get itemConversionFunctionDefault() {
|
|
37
|
+
return {
|
|
38
|
+
code: code `${this.reusables.snippets.identityConversionFunction}`,
|
|
39
|
+
sourceTypes: [
|
|
40
|
+
{
|
|
41
|
+
name: this.itemType.name,
|
|
42
|
+
typeof: this.itemType.typeofs[0],
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
get itemValidationFunctionDefault() {
|
|
48
|
+
return code `${this.reusables.snippets.identityValidationFunction}`;
|
|
49
|
+
}
|
|
36
50
|
get schemaObject() {
|
|
37
51
|
return {
|
|
38
52
|
...super.schemaObject,
|
|
@@ -43,6 +57,12 @@ export class AbstractContainerType extends AbstractType {
|
|
|
43
57
|
__decorate([
|
|
44
58
|
Memoize()
|
|
45
59
|
], AbstractContainerType.prototype, "schema", null);
|
|
60
|
+
__decorate([
|
|
61
|
+
Memoize()
|
|
62
|
+
], AbstractContainerType.prototype, "itemConversionFunctionDefault", null);
|
|
63
|
+
__decorate([
|
|
64
|
+
Memoize()
|
|
65
|
+
], AbstractContainerType.prototype, "itemValidationFunctionDefault", null);
|
|
46
66
|
(function (AbstractContainerType) {
|
|
47
67
|
AbstractContainerType.GraphqlType = AbstractType.GraphqlType;
|
|
48
68
|
function isItemType(type) {
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { NonEmptyList } from "purify-ts";
|
|
2
1
|
import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
|
|
3
2
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
4
3
|
export declare abstract class AbstractDateType extends AbstractPrimitiveType<Date> {
|
|
@@ -10,22 +9,18 @@ export declare abstract class AbstractDateType extends AbstractPrimitiveType<Dat
|
|
|
10
9
|
readonly name = "Date";
|
|
11
10
|
readonly schemaType: Code;
|
|
12
11
|
readonly valueSparqlWherePatternsFunction: Code;
|
|
13
|
-
readonly typeofs:
|
|
14
|
-
get conversions(): readonly AbstractPrimitiveType.Conversion[];
|
|
15
|
-
protected get schemaObject(): {
|
|
16
|
-
in: Code[] | undefined;
|
|
17
|
-
languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
|
|
18
|
-
kind: Code;
|
|
19
|
-
};
|
|
12
|
+
readonly typeofs: "object"[];
|
|
20
13
|
fromJsonExpression({ variables, }: Parameters<AbstractPrimitiveType<Date>["fromJsonExpression"]>[0]): Code;
|
|
21
|
-
hashStatements({ variables, }: Parameters<AbstractPrimitiveType<Date>["hashStatements"]>[0]): readonly Code[];
|
|
22
14
|
jsonType(): AbstractPrimitiveType.JsonType;
|
|
23
15
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<Date>["toRdfResourceValuesExpression"]>[0]): Code;
|
|
24
|
-
protected
|
|
16
|
+
protected fromRdfResourceValuesExpressionChain({ variables, }: Parameters<AbstractPrimitiveType<Date>["fromRdfResourceValuesExpressionChain"]>[0]): ReturnType<AbstractPrimitiveType<Date>["fromRdfResourceValuesExpressionChain"]>;
|
|
25
17
|
protected abstract fromRdfResourceValueExpression(variables: {
|
|
26
18
|
variables: {
|
|
27
19
|
value: Code;
|
|
28
20
|
};
|
|
29
21
|
}): Code;
|
|
30
22
|
}
|
|
23
|
+
export declare namespace AbstractDateType {
|
|
24
|
+
type ConversionFunction = AbstractPrimitiveType.ConversionFunction;
|
|
25
|
+
}
|
|
31
26
|
//# sourceMappingURL=AbstractDateType.d.ts.map
|
|
@@ -4,10 +4,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { NonEmptyList } from "purify-ts";
|
|
8
7
|
import { Memoize } from "typescript-memoize";
|
|
9
8
|
import { AbstractPrimitiveType } from "./AbstractPrimitiveType.js";
|
|
10
|
-
import { code
|
|
9
|
+
import { code } from "./ts-poet-wrapper.js";
|
|
11
10
|
export class AbstractDateType extends AbstractPrimitiveType {
|
|
12
11
|
equalsFunction = code `${this.reusables.snippets.dateEquals}`;
|
|
13
12
|
filterFunction = code `${this.reusables.snippets.filterDate}`;
|
|
@@ -16,32 +15,9 @@ export class AbstractDateType extends AbstractPrimitiveType {
|
|
|
16
15
|
name = "Date";
|
|
17
16
|
schemaType = code `${this.reusables.snippets.DateSchema}`;
|
|
18
17
|
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.dateSparqlWherePatterns}`;
|
|
19
|
-
typeofs =
|
|
20
|
-
get conversions() {
|
|
21
|
-
return [
|
|
22
|
-
{
|
|
23
|
-
conversionExpression: (value) => value,
|
|
24
|
-
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object" && ${value} instanceof Date`,
|
|
25
|
-
sourceTypeName: this.name,
|
|
26
|
-
sourceTypeof: "object",
|
|
27
|
-
},
|
|
28
|
-
];
|
|
29
|
-
}
|
|
30
|
-
get schemaObject() {
|
|
31
|
-
return {
|
|
32
|
-
...super.schemaObject,
|
|
33
|
-
in: this.primitiveIn.length > 0
|
|
34
|
-
? this.primitiveIn.map((inValue) => code `new Date(${literalOf(inValue.toISOString())})`)
|
|
35
|
-
: undefined,
|
|
36
|
-
};
|
|
37
|
-
}
|
|
18
|
+
typeofs = ["object"];
|
|
38
19
|
fromJsonExpression({ variables, }) {
|
|
39
|
-
return code
|
|
40
|
-
}
|
|
41
|
-
hashStatements({ variables, }) {
|
|
42
|
-
return [
|
|
43
|
-
code `${variables.hasher}.update(${variables.value}.toISOString());`,
|
|
44
|
-
];
|
|
20
|
+
return code `${this.reusables.imports.Either}.of<Error, Date>(new Date(${variables.value}))`;
|
|
45
21
|
}
|
|
46
22
|
jsonType() {
|
|
47
23
|
return new AbstractPrimitiveType.JsonType(code `string`);
|
|
@@ -49,9 +25,9 @@ export class AbstractDateType extends AbstractPrimitiveType {
|
|
|
49
25
|
toRdfResourceValuesExpression({ variables, }) {
|
|
50
26
|
return code `[${this.reusables.snippets.literalFactory}.date(${variables.value}, ${this.rdfjsTermExpression(this.datatype)})]`;
|
|
51
27
|
}
|
|
52
|
-
|
|
28
|
+
fromRdfResourceValuesExpressionChain({ variables, }) {
|
|
53
29
|
return {
|
|
54
|
-
...super.
|
|
30
|
+
...super.fromRdfResourceValuesExpressionChain({ variables }),
|
|
55
31
|
languageIn: undefined,
|
|
56
32
|
preferredLanguages: undefined,
|
|
57
33
|
valueTo: code `chain(values => values.chainMap(value => ${this.fromRdfResourceValueExpression({
|
|
@@ -60,9 +36,6 @@ export class AbstractDateType extends AbstractPrimitiveType {
|
|
|
60
36
|
};
|
|
61
37
|
}
|
|
62
38
|
}
|
|
63
|
-
__decorate([
|
|
64
|
-
Memoize()
|
|
65
|
-
], AbstractDateType.prototype, "conversions", null);
|
|
66
39
|
__decorate([
|
|
67
40
|
Memoize()
|
|
68
41
|
], AbstractDateType.prototype, "jsonType", null);
|
|
@@ -7,8 +7,11 @@ export declare abstract class AbstractIdentifierType<IdentifierT extends BlankNo
|
|
|
7
7
|
abstract readonly nodeKinds: ReadonlySet<IdentifierNodeKind>;
|
|
8
8
|
abstract readonly parseFunction: Code;
|
|
9
9
|
readonly stringifyFunction: Code;
|
|
10
|
-
get conversions(): readonly AbstractTermType.Conversion[];
|
|
11
10
|
get graphqlType(): import("./AbstractType.js").AbstractType.GraphqlType;
|
|
12
11
|
graphqlResolveExpression({ variables: { value }, }: Parameters<AbstractTermType["graphqlResolveExpression"]>[0]): Code;
|
|
13
12
|
}
|
|
13
|
+
export declare namespace AbstractIdentifierType {
|
|
14
|
+
type ConversionFunction = AbstractTermType.ConversionFunction;
|
|
15
|
+
type JsonType = AbstractTermType.JsonType;
|
|
16
|
+
}
|
|
14
17
|
//# sourceMappingURL=AbstractIdentifierType.d.ts.map
|
|
@@ -9,20 +9,6 @@ import { AbstractTermType } from "./AbstractTermType.js";
|
|
|
9
9
|
import { code } from "./ts-poet-wrapper.js";
|
|
10
10
|
export class AbstractIdentifierType extends AbstractTermType {
|
|
11
11
|
stringifyFunction = code `${this.reusables.imports.NTriplesTerm}.stringify`;
|
|
12
|
-
get conversions() {
|
|
13
|
-
const conversions = super.conversions.concat();
|
|
14
|
-
if (this.nodeKinds.has("IRI")) {
|
|
15
|
-
conversions.push({
|
|
16
|
-
conversionExpression: (value) => code `${this.reusables.imports.dataFactory}.namedNode(${value})`,
|
|
17
|
-
sourceTypeCheckExpression: (value) => code `typeof ${value} === "string"`,
|
|
18
|
-
sourceTypeName: this.in_.length > 0
|
|
19
|
-
? code `${this.in_.map((iri) => `"${iri.value}"`).join(" | ")}`
|
|
20
|
-
: code `string`,
|
|
21
|
-
sourceTypeof: "string",
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
return conversions;
|
|
25
|
-
}
|
|
26
12
|
get graphqlType() {
|
|
27
13
|
return new AbstractTermType.GraphqlType(code `${this.reusables.imports.GraphQLString}`, this.reusables);
|
|
28
14
|
}
|
|
@@ -30,9 +16,6 @@ export class AbstractIdentifierType extends AbstractTermType {
|
|
|
30
16
|
return code `${this.reusables.imports.NTriplesTerm}.stringify(${value})`;
|
|
31
17
|
}
|
|
32
18
|
}
|
|
33
|
-
__decorate([
|
|
34
|
-
Memoize()
|
|
35
|
-
], AbstractIdentifierType.prototype, "conversions", null);
|
|
36
19
|
__decorate([
|
|
37
20
|
Memoize()
|
|
38
21
|
], AbstractIdentifierType.prototype, "graphqlType", null);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Maybe
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
2
|
import { AbstractType } from "./AbstractType.js";
|
|
3
3
|
import type { NamedObjectType } from "./NamedObjectType.js";
|
|
4
4
|
import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
|
|
@@ -16,13 +16,14 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
|
|
|
16
16
|
readonly declaration: Maybe<Code>;
|
|
17
17
|
readonly discriminantProperty: AbstractType["discriminantProperty"];
|
|
18
18
|
readonly mutable = false;
|
|
19
|
-
readonly typeofs:
|
|
19
|
+
readonly typeofs: "object"[];
|
|
20
|
+
readonly validationFunction: Maybe<Code>;
|
|
20
21
|
constructor({ partialType, resolveType, ...superParameters }: {
|
|
21
22
|
partialType: PartialTypeT;
|
|
22
23
|
resolveType: ResolveTypeT;
|
|
23
24
|
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
24
|
-
get conversions(): readonly AbstractType.Conversion[];
|
|
25
25
|
get equalsFunction(): Code;
|
|
26
|
+
get hashFunction(): Code;
|
|
26
27
|
get filterFunction(): Code;
|
|
27
28
|
get filterType(): Code;
|
|
28
29
|
get graphqlType(): AbstractType.GraphqlType;
|
|
@@ -37,7 +38,6 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
|
|
|
37
38
|
partial: Code;
|
|
38
39
|
kind: Code;
|
|
39
40
|
};
|
|
40
|
-
hashStatements({ depth, variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
|
|
41
41
|
jsonSchema(parameters: Parameters<AbstractType["jsonSchema"]>[0]): Code;
|
|
42
42
|
jsonType(parameters?: Parameters<AbstractType["jsonType"]>[0]): AbstractType.JsonType;
|
|
43
43
|
jsonUiSchemaElement(parameters: Parameters<AbstractType["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
@@ -51,12 +51,16 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
|
|
|
51
51
|
resolvedObjectUnion: Code;
|
|
52
52
|
};
|
|
53
53
|
}): Code;
|
|
54
|
+
protected resolveToPartialFunction<ObjectTypeT extends AbstractLazyObjectType.ObjectTypeConstraint>({ partialType, resolveType, }: {
|
|
55
|
+
partialType: ObjectTypeT;
|
|
56
|
+
resolveType: ObjectTypeT;
|
|
57
|
+
}): Code;
|
|
54
58
|
}
|
|
55
59
|
export declare namespace AbstractLazyObjectType {
|
|
56
60
|
type ObjectTypeConstraint = NamedObjectType | NamedObjectUnionType;
|
|
57
61
|
type PartialTypeConstraint = ObjectTypeConstraint | OptionType<ObjectTypeConstraint> | SetType<ObjectTypeConstraint>;
|
|
58
62
|
type ResolveTypeConstraint = PartialTypeConstraint;
|
|
59
|
-
type
|
|
63
|
+
type ConversionFunction = AbstractType.ConversionFunction;
|
|
60
64
|
type DiscriminantProperty = AbstractType.DiscriminantProperty;
|
|
61
65
|
const GraphqlType: typeof AbstractType.GraphqlType;
|
|
62
66
|
type GraphqlType = AbstractType.GraphqlType;
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { Maybe
|
|
7
|
+
import { Maybe } from "purify-ts";
|
|
8
8
|
import { invariant } from "ts-invariant";
|
|
9
9
|
import { Memoize } from "typescript-memoize";
|
|
10
10
|
import { AbstractType } from "./AbstractType.js";
|
|
@@ -16,25 +16,19 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
16
16
|
declaration = Maybe.empty();
|
|
17
17
|
discriminantProperty = Maybe.empty();
|
|
18
18
|
mutable = false;
|
|
19
|
-
typeofs =
|
|
19
|
+
typeofs = ["object"];
|
|
20
|
+
validationFunction = Maybe.empty();
|
|
20
21
|
constructor({ partialType, resolveType, ...superParameters }) {
|
|
21
22
|
super(superParameters);
|
|
22
23
|
this.partialType = partialType;
|
|
23
24
|
this.resolveType = resolveType;
|
|
24
25
|
}
|
|
25
|
-
get conversions() {
|
|
26
|
-
return [
|
|
27
|
-
{
|
|
28
|
-
conversionExpression: (value) => value,
|
|
29
|
-
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object" && ${value} instanceof ${this.runtimeClass.rawName}`,
|
|
30
|
-
sourceTypeName: this.name,
|
|
31
|
-
sourceTypeof: "object",
|
|
32
|
-
},
|
|
33
|
-
];
|
|
34
|
-
}
|
|
35
26
|
get equalsFunction() {
|
|
36
27
|
return code `((left, right) => ${this.partialType.equalsFunction}(left.${this.runtimeClass.partialPropertyName}, right.${this.runtimeClass.partialPropertyName}))`;
|
|
37
28
|
}
|
|
29
|
+
get hashFunction() {
|
|
30
|
+
return code `((hasher, value) => ${this.partialType.hashFunction}(hasher, value.${this.runtimeClass.partialPropertyName}))`;
|
|
31
|
+
}
|
|
38
32
|
get filterFunction() {
|
|
39
33
|
return code `((filter: ${this.filterType}, value: ${this.name}) => ${this.partialType.filterFunction}(filter, value.${this.runtimeClass.partialPropertyName}))`;
|
|
40
34
|
}
|
|
@@ -77,15 +71,6 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
77
71
|
// resolved: code`() => (${this.resolveType.schema})`,
|
|
78
72
|
};
|
|
79
73
|
}
|
|
80
|
-
hashStatements({ depth, variables, }) {
|
|
81
|
-
return this.partialType.hashStatements({
|
|
82
|
-
depth: depth + 1,
|
|
83
|
-
variables: {
|
|
84
|
-
...variables,
|
|
85
|
-
value: code `${variables.value}.${this.runtimeClass.partialPropertyName}`,
|
|
86
|
-
},
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
74
|
jsonSchema(parameters) {
|
|
90
75
|
return this.partialType.jsonSchema(parameters);
|
|
91
76
|
}
|
|
@@ -126,10 +111,26 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
126
111
|
caseBlocks.push(code `default: ${variables.resolvedObjectUnion} satisfies never; throw new Error("unrecognized type");`);
|
|
127
112
|
return code `switch (${variables.resolvedObjectUnion}.${resolvedNamedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
|
|
128
113
|
}
|
|
114
|
+
resolveToPartialFunction({ partialType, resolveType, }) {
|
|
115
|
+
if (partialType.kind === "NamedObjectType") {
|
|
116
|
+
return code `${partialType.name}.createUnsafe`;
|
|
117
|
+
}
|
|
118
|
+
invariant(partialType.kind === "NamedObjectUnionType");
|
|
119
|
+
invariant(resolveType.kind === "NamedObjectUnionType");
|
|
120
|
+
invariant(partialType.members.length === resolveType.members.length);
|
|
121
|
+
const caseBlocks = resolveType.members.map(({ discriminantValues }, memberI) => {
|
|
122
|
+
return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialType.members[memberI].type.name}.createUnsafe(resolved);`;
|
|
123
|
+
});
|
|
124
|
+
caseBlocks.push(code `default: resolved satisfies never; throw new Error("unrecognized type");`);
|
|
125
|
+
return code `((resolved: ${resolveType.name}) => { switch (resolved.${resolveType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} } })`;
|
|
126
|
+
}
|
|
129
127
|
}
|
|
130
128
|
__decorate([
|
|
131
129
|
Memoize()
|
|
132
130
|
], AbstractLazyObjectType.prototype, "equalsFunction", null);
|
|
131
|
+
__decorate([
|
|
132
|
+
Memoize()
|
|
133
|
+
], AbstractLazyObjectType.prototype, "hashFunction", null);
|
|
133
134
|
__decorate([
|
|
134
135
|
Memoize()
|
|
135
136
|
], AbstractLazyObjectType.prototype, "filterFunction", null);
|
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
import type { Literal } from "@rdfjs/types";
|
|
2
2
|
import { AbstractTermType } from "./AbstractTermType.js";
|
|
3
|
+
import { type Code } from "./ts-poet-wrapper.js";
|
|
3
4
|
export declare abstract class AbstractLiteralType extends AbstractTermType<Literal, Literal> {
|
|
4
|
-
readonly nodeKinds: ReadonlySet<"Literal">;
|
|
5
5
|
protected readonly languageIn: readonly string[];
|
|
6
|
+
readonly nodeKinds: ReadonlySet<"Literal">;
|
|
6
7
|
constructor({ languageIn, ...superParameters }: {
|
|
7
8
|
languageIn: readonly string[];
|
|
8
9
|
} & ConstructorParameters<typeof AbstractTermType<Literal, Literal>>[0]);
|
|
9
10
|
get constrained(): boolean;
|
|
10
11
|
protected get schemaObject(): {
|
|
11
12
|
languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
|
|
12
|
-
|
|
13
|
+
in: Code | undefined;
|
|
14
|
+
kind: Code;
|
|
13
15
|
};
|
|
14
|
-
|
|
16
|
+
/**
|
|
17
|
+
* An expression that converts a compile-time RDF/JS Literal into a runtime TypeScript literal.
|
|
18
|
+
*
|
|
19
|
+
* For example, a string would be converted to "thestring".
|
|
20
|
+
*/
|
|
21
|
+
abstract literalExpression(literal: Literal): Code;
|
|
22
|
+
protected fromRdfResourceValuesExpressionChain({ variables, }: Parameters<AbstractTermType<Literal, Literal>["fromRdfResourceValuesExpressionChain"]>[0]): ReturnType<AbstractTermType<Literal, Literal>["fromRdfResourceValuesExpressionChain"]>;
|
|
15
23
|
}
|
|
16
24
|
export declare namespace AbstractLiteralType {
|
|
17
|
-
type
|
|
25
|
+
type ConversionFunction = AbstractTermType.ConversionFunction;
|
|
18
26
|
type DiscriminantProperty = AbstractTermType.DiscriminantProperty;
|
|
19
27
|
const GraphqlType: typeof import("./AbstractType.js").AbstractType.GraphqlType;
|
|
20
28
|
type GraphqlType = AbstractTermType.GraphqlType;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AbstractTermType } from "./AbstractTermType.js";
|
|
2
2
|
import { code, literalOf } from "./ts-poet-wrapper.js";
|
|
3
3
|
export class AbstractLiteralType extends AbstractTermType {
|
|
4
|
-
nodeKinds = nodeKinds;
|
|
5
4
|
languageIn;
|
|
5
|
+
nodeKinds = nodeKinds;
|
|
6
6
|
constructor({ languageIn, ...superParameters }) {
|
|
7
7
|
super(superParameters);
|
|
8
8
|
this.languageIn = languageIn;
|
|
@@ -16,9 +16,9 @@ export class AbstractLiteralType extends AbstractTermType {
|
|
|
16
16
|
languageIn: this.languageIn.length > 0 ? this.languageIn.map(literalOf) : undefined,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
fromRdfResourceValuesExpressionChain({ variables, }) {
|
|
20
20
|
return {
|
|
21
|
-
...super.
|
|
21
|
+
...super.fromRdfResourceValuesExpressionChain({ variables }),
|
|
22
22
|
languageIn: this.languageIn.length > 0
|
|
23
23
|
? code `chain(values => ${this.reusables.snippets.fromRdfLanguageIn}(values, ${JSON.stringify(this.languageIn)}))`
|
|
24
24
|
: undefined,
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { AbstractType } from "./AbstractType.js";
|
|
3
3
|
import { AbstractUnionType } from "./AbstractUnionType.js";
|
|
4
|
-
import type { TsFeature } from "./TsFeature.js";
|
|
5
4
|
import type { Type } from "./Type.js";
|
|
6
5
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
7
6
|
export declare abstract class AbstractNamedUnionType<MemberTypeT extends Type> extends AbstractUnionType<MemberTypeT> {
|
|
8
7
|
protected readonly _name: string;
|
|
9
|
-
|
|
10
|
-
constructor({ features, name, ...superParameters }: {
|
|
11
|
-
features: ReadonlySet<TsFeature>;
|
|
8
|
+
constructor({ name, ...superParameters }: {
|
|
12
9
|
name: string;
|
|
13
10
|
} & ConstructorParameters<typeof AbstractUnionType<MemberTypeT>>[0]);
|
|
14
11
|
get declaration(): Maybe<Code>;
|
|
15
12
|
get equalsFunction(): Code;
|
|
16
13
|
get filterFunction(): Code;
|
|
17
14
|
get filterType(): Code;
|
|
15
|
+
get hashFunction(): Code;
|
|
18
16
|
get jsonSchemaFunctionDeclaration(): Code;
|
|
19
17
|
get jsonTypeAliasDeclaration(): Code;
|
|
20
18
|
get name(): string;
|
|
@@ -23,7 +21,6 @@ export declare abstract class AbstractNamedUnionType<MemberTypeT extends Type> e
|
|
|
23
21
|
protected get staticModuleDeclarations(): Record<string, Code>;
|
|
24
22
|
fromJsonExpression({ variables, }: Parameters<AbstractType["fromJsonExpression"]>[0]): Code;
|
|
25
23
|
fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["fromRdfResourceValuesExpression"]>[0]): Code;
|
|
26
|
-
hashStatements({ depth, variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
|
|
27
24
|
jsonSchema({ context, }: Parameters<AbstractType["jsonSchema"]>[0]): Code;
|
|
28
25
|
jsonType(): AbstractType.JsonType;
|
|
29
26
|
toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
|
|
@@ -8,14 +8,11 @@ import { Maybe } from "purify-ts";
|
|
|
8
8
|
import { Memoize } from "typescript-memoize";
|
|
9
9
|
import { AbstractType } from "./AbstractType.js";
|
|
10
10
|
import { AbstractUnionType } from "./AbstractUnionType.js";
|
|
11
|
-
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
12
11
|
import { code, def, joinCode } from "./ts-poet-wrapper.js";
|
|
13
12
|
export class AbstractNamedUnionType extends AbstractUnionType {
|
|
14
13
|
_name;
|
|
15
|
-
|
|
16
|
-
constructor({ features, name, ...superParameters }) {
|
|
14
|
+
constructor({ name, ...superParameters }) {
|
|
17
15
|
super(superParameters);
|
|
18
|
-
this.features = features;
|
|
19
16
|
this._name = name;
|
|
20
17
|
}
|
|
21
18
|
get declaration() {
|
|
@@ -34,10 +31,7 @@ ${joinCode(staticModuleDeclarations
|
|
|
34
31
|
return Maybe.of(joinCode(declarations, { on: "\n\n" }));
|
|
35
32
|
}
|
|
36
33
|
get equalsFunction() {
|
|
37
|
-
|
|
38
|
-
return code `${this.name}.equals`;
|
|
39
|
-
}
|
|
40
|
-
return this.inlineEqualsFunction;
|
|
34
|
+
return code `${this.name}.equals`;
|
|
41
35
|
}
|
|
42
36
|
get filterFunction() {
|
|
43
37
|
return code `${this.name}.filter`;
|
|
@@ -45,6 +39,9 @@ ${joinCode(staticModuleDeclarations
|
|
|
45
39
|
get filterType() {
|
|
46
40
|
return code `${this.name}.Filter`;
|
|
47
41
|
}
|
|
42
|
+
get hashFunction() {
|
|
43
|
+
return code `${this.name}.hash`;
|
|
44
|
+
}
|
|
48
45
|
get jsonSchemaFunctionDeclaration() {
|
|
49
46
|
const meta = {
|
|
50
47
|
// id: this.name,
|
|
@@ -64,20 +61,14 @@ ${joinCode(staticModuleDeclarations
|
|
|
64
61
|
return this._name;
|
|
65
62
|
}
|
|
66
63
|
get valueSparqlConstructTriplesFunction() {
|
|
67
|
-
|
|
68
|
-
return code `${this.name}.valueSparqlConstructTriples`;
|
|
69
|
-
}
|
|
70
|
-
return this.inlineValueSparqlConstructTriplesFunction;
|
|
64
|
+
return code `${this.name}.valueSparqlConstructTriples`;
|
|
71
65
|
}
|
|
72
66
|
get valueSparqlWherePatternsFunction() {
|
|
73
|
-
|
|
74
|
-
return code `${this.name}.valueSparqlWherePatterns`;
|
|
75
|
-
}
|
|
76
|
-
return this.inlineValueSparqlWherePatternsFunction;
|
|
67
|
+
return code `${this.name}.valueSparqlWherePatterns`;
|
|
77
68
|
}
|
|
78
69
|
get staticModuleDeclarations() {
|
|
79
70
|
const staticModuleDeclarations = {};
|
|
80
|
-
if (this.features.has("equals")) {
|
|
71
|
+
if (this.configuration.features.has("equals")) {
|
|
81
72
|
staticModuleDeclarations[`equals`] =
|
|
82
73
|
code `export const equals = ${this.inlineEqualsFunction};`;
|
|
83
74
|
}
|
|
@@ -85,11 +76,11 @@ ${joinCode(staticModuleDeclarations
|
|
|
85
76
|
code `export type Filter = ${this.inlineFilterType};`;
|
|
86
77
|
staticModuleDeclarations[`filter`] =
|
|
87
78
|
code `export const filter = ${this.inlineFilterFunction};`;
|
|
88
|
-
if (this.features.has("hash")) {
|
|
79
|
+
if (this.configuration.features.has("hash")) {
|
|
89
80
|
staticModuleDeclarations[`hash`] =
|
|
90
|
-
code `export
|
|
81
|
+
code `export const hash = ${this.inlineHashFunction};`;
|
|
91
82
|
}
|
|
92
|
-
if (this.features.has("json")) {
|
|
83
|
+
if (this.configuration.features.has("json")) {
|
|
93
84
|
staticModuleDeclarations[`Json`] = code `\
|
|
94
85
|
${this.jsonTypeAliasDeclaration}
|
|
95
86
|
|
|
@@ -107,74 +98,49 @@ export namespace Json {
|
|
|
107
98
|
staticModuleDeclarations[`toJson`] =
|
|
108
99
|
code `export const toJson = ${this.inlineToJsonFunction};`;
|
|
109
100
|
}
|
|
110
|
-
if (this.features.has("rdf")) {
|
|
101
|
+
if (this.configuration.features.has("rdf")) {
|
|
111
102
|
staticModuleDeclarations[`fromRdfResourceValues`] =
|
|
112
103
|
code `export const fromRdfResourceValues: ${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.name}> = ${this.inlineFromRdfResourceValuesFunction};`;
|
|
113
104
|
staticModuleDeclarations[`toRdfResourceValues`] =
|
|
114
105
|
code `export const toRdfResourceValues = ${this.inlineToRdfResourceValuesFunction};`;
|
|
115
106
|
}
|
|
116
|
-
if (this.features.has("sparql")) {
|
|
107
|
+
if (this.configuration.features.has("sparql")) {
|
|
117
108
|
staticModuleDeclarations[`valueSparqlConstructTriples`] =
|
|
118
109
|
code `export const valueSparqlConstructTriples: ${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlConstructTriplesFunction};`;
|
|
119
110
|
staticModuleDeclarations[`valueSparqlWherePatterns`] =
|
|
120
111
|
code `export const valueSparqlWherePatterns: ${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlWherePatternsFunction};`;
|
|
121
112
|
}
|
|
113
|
+
const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
|
|
122
114
|
staticModuleDeclarations[`${syntheticNamePrefix}toString`] =
|
|
123
115
|
code `export const ${syntheticNamePrefix}toString = ${this.inlineToStringFunction};`;
|
|
124
116
|
return staticModuleDeclarations;
|
|
125
117
|
}
|
|
126
118
|
fromJsonExpression({ variables, }) {
|
|
127
|
-
|
|
128
|
-
return code `${this.name}.fromJson(${variables.value})`;
|
|
129
|
-
}
|
|
130
|
-
return code `${this.inlineFromJsonFunction}(${variables.value})`;
|
|
119
|
+
return code `${this.name}.fromJson(${variables.value})`;
|
|
131
120
|
}
|
|
132
121
|
fromRdfResourceValuesExpression({ variables, }) {
|
|
133
122
|
const { resourceValues: resourceValuesVariable, ...otherVariables } = variables;
|
|
134
|
-
|
|
135
|
-
return code `${this.name}.fromRdfResourceValues(${resourceValuesVariable}, ${otherVariables})`;
|
|
136
|
-
}
|
|
137
|
-
return code `${this.inlineFromRdfResourceValuesFunction}(${resourceValuesVariable}, ${otherVariables})`;
|
|
138
|
-
}
|
|
139
|
-
hashStatements({ depth, variables, }) {
|
|
140
|
-
if (this.features.has("hash")) {
|
|
141
|
-
return [
|
|
142
|
-
code `${this.name}.hash(${variables.value}, ${variables.hasher});`,
|
|
143
|
-
];
|
|
144
|
-
}
|
|
145
|
-
return this.inlineHashStatements({ depth, variables });
|
|
123
|
+
return code `${this.name}.fromRdfResourceValues(${resourceValuesVariable}, ${otherVariables})`;
|
|
146
124
|
}
|
|
147
125
|
jsonSchema({ context, }) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
return code `${this.reusables.imports.z}.lazy((): ${this.reusables.imports.z}.ZodType<${this.name}.Json> => ${expression})`;
|
|
152
|
-
}
|
|
153
|
-
return expression;
|
|
126
|
+
const expression = code `${this.name}.Json.schema()`;
|
|
127
|
+
if (context === "property" && this.recursive) {
|
|
128
|
+
return code `${this.reusables.imports.z}.lazy((): ${this.reusables.imports.z}.ZodType<${this.name}.Json> => ${expression})`;
|
|
154
129
|
}
|
|
155
|
-
return
|
|
130
|
+
return expression;
|
|
156
131
|
}
|
|
157
132
|
jsonType() {
|
|
158
|
-
|
|
159
|
-
return new AbstractType.JsonType(`${this.name}.Json`);
|
|
160
|
-
}
|
|
161
|
-
return this.inlineJsonType;
|
|
133
|
+
return new AbstractType.JsonType(`${this.name}.Json`);
|
|
162
134
|
}
|
|
163
135
|
toJsonExpression({ variables, }) {
|
|
164
|
-
|
|
165
|
-
return code `${this.name}.toJson(${variables.value})`;
|
|
166
|
-
}
|
|
167
|
-
return code `${this.inlineToJsonFunction}(${variables.value})`;
|
|
136
|
+
return code `${this.name}.toJson(${variables.value})`;
|
|
168
137
|
}
|
|
169
138
|
toRdfResourceValuesExpression({ variables, }) {
|
|
170
139
|
const { value: valueVariable, ...otherVariables } = variables;
|
|
171
|
-
|
|
172
|
-
return code `${this.name}.toRdfResourceValues(${valueVariable}, ${otherVariables})`;
|
|
173
|
-
}
|
|
174
|
-
return code `${this.inlineToRdfResourceValuesFunction}(${valueVariable}, ${otherVariables})`;
|
|
140
|
+
return code `${this.name}.toRdfResourceValues(${valueVariable}, ${otherVariables})`;
|
|
175
141
|
}
|
|
176
142
|
toStringExpression({ variables, }) {
|
|
177
|
-
return code `${this.name}.${syntheticNamePrefix}toString(${variables.value})`;
|
|
143
|
+
return code `${this.name}.${this.configuration.syntheticNamePrefix}toString(${variables.value})`;
|
|
178
144
|
}
|
|
179
145
|
}
|
|
180
146
|
__decorate([
|
|
@@ -189,6 +155,9 @@ __decorate([
|
|
|
189
155
|
__decorate([
|
|
190
156
|
Memoize()
|
|
191
157
|
], AbstractNamedUnionType.prototype, "filterType", null);
|
|
158
|
+
__decorate([
|
|
159
|
+
Memoize()
|
|
160
|
+
], AbstractNamedUnionType.prototype, "hashFunction", null);
|
|
192
161
|
__decorate([
|
|
193
162
|
Memoize()
|
|
194
163
|
], AbstractNamedUnionType.prototype, "name", null);
|
|
@@ -4,29 +4,23 @@ import { type Code } from "./ts-poet-wrapper.js";
|
|
|
4
4
|
* Abstract base class for TypeScript numeric types (bigint | number).
|
|
5
5
|
*/
|
|
6
6
|
export declare abstract class AbstractNumericType<ValueT extends bigint | number> extends AbstractPrimitiveType<ValueT> {
|
|
7
|
+
readonly hashFunction: Code;
|
|
7
8
|
abstract readonly kind: "BigIntType" | "FloatType" | "IntType";
|
|
8
9
|
get filterFunction(): Code;
|
|
9
10
|
get filterType(): Code;
|
|
10
|
-
get name(): string;
|
|
11
|
+
get name(): Code | string;
|
|
11
12
|
get schemaType(): Code;
|
|
12
13
|
get valueSparqlWherePatternsFunction(): Code;
|
|
13
|
-
protected get schemaObject(): {
|
|
14
|
-
in: Code[] | undefined;
|
|
15
|
-
languageIn: import("ts-poet/build/Node.js").Node[] | undefined;
|
|
16
|
-
kind: Code;
|
|
17
|
-
};
|
|
18
14
|
jsonSchema(_parameters: Parameters<AbstractPrimitiveType<ValueT>["jsonSchema"]>[0]): Code;
|
|
19
15
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractPrimitiveType<string>["toRdfResourceValuesExpression"]>[0]): Code;
|
|
20
|
-
protected
|
|
16
|
+
protected fromRdfResourceValuesExpressionChain({ variables, }: Parameters<AbstractPrimitiveType<ValueT>["fromRdfResourceValuesExpressionChain"]>[0]): ReturnType<AbstractPrimitiveType<ValueT>["fromRdfResourceValuesExpressionChain"]>;
|
|
21
17
|
protected abstract fromRdfResourceValueExpression(variables: {
|
|
22
18
|
variables: {
|
|
23
19
|
value: Code;
|
|
24
20
|
};
|
|
25
21
|
}): Code;
|
|
26
|
-
protected abstract literalOf(value: ValueT): string;
|
|
27
22
|
}
|
|
28
23
|
export declare namespace AbstractNumericType {
|
|
29
|
-
type Conversion = AbstractPrimitiveType.Conversion;
|
|
30
24
|
const JsonType: typeof import("./AbstractType.js").AbstractType.JsonType;
|
|
31
25
|
type JsonType = AbstractPrimitiveType.JsonType;
|
|
32
26
|
}
|