@shaclmate/compiler 4.0.39 → 4.0.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ShapesGraphToAstTransformer.d.ts +0 -8
- package/dist/ShapesGraphToAstTransformer.js +5 -85
- package/dist/_ShapesGraphToAstTransformer/shapeNodeKinds.js +128 -160
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.d.ts +1 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +0 -16
- package/dist/ast/AbstractCompoundType.d.ts +2 -1
- package/dist/ast/AbstractCompoundType.js +1 -1
- package/dist/ast/AbstractLazyObjectType.d.ts +0 -2
- package/dist/ast/Ast.d.ts +1 -3
- package/dist/ast/ListType.d.ts +1 -1
- package/dist/ast/ListType.js +1 -1
- package/dist/ast/ObjectType.d.ts +0 -12
- package/dist/ast/ObjectType.js +0 -78
- package/dist/generators/AstJsonGenerator.js +7 -3
- package/dist/generators/transformAstToLabeledPropertyGraph.js +59 -56
- package/dist/generators/ts/AbstractCollectionType.d.ts +5 -12
- package/dist/generators/ts/AbstractCollectionType.js +9 -68
- package/dist/generators/ts/AbstractContainerType.d.ts +4 -6
- package/dist/generators/ts/AbstractContainerType.js +5 -9
- package/dist/generators/ts/AbstractDateType.d.ts +6 -3
- package/dist/generators/ts/AbstractDateType.js +7 -2
- package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -0
- package/dist/generators/ts/AbstractIdentifierType.js +3 -0
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +9 -9
- package/dist/generators/ts/AbstractLazyObjectType.js +30 -19
- package/dist/generators/ts/AbstractLiteralType.d.ts +1 -0
- package/dist/generators/ts/AbstractNumericType.d.ts +1 -1
- package/dist/generators/ts/AbstractNumericType.js +9 -9
- package/dist/generators/ts/AbstractObjectSetType.d.ts +10 -9
- package/dist/generators/ts/AbstractObjectSetType.js +2 -2
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +1 -0
- package/dist/generators/ts/AbstractPrimitiveType.js +2 -2
- package/dist/generators/ts/AbstractTermType.d.ts +1 -2
- package/dist/generators/ts/AbstractTermType.js +3 -5
- package/dist/generators/ts/AbstractType.d.ts +61 -26
- package/dist/generators/ts/AbstractType.js +37 -17
- package/dist/generators/ts/BigDecimalType.d.ts +5 -1
- package/dist/generators/ts/BigDecimalType.js +6 -3
- package/dist/generators/ts/BigIntType.d.ts +3 -1
- package/dist/generators/ts/BigIntType.js +3 -3
- package/dist/generators/ts/BlankNodeType.d.ts +3 -3
- package/dist/generators/ts/BlankNodeType.js +13 -13
- package/dist/generators/ts/BooleanType.d.ts +5 -3
- package/dist/generators/ts/BooleanType.js +11 -6
- package/dist/generators/ts/DefaultValueType.d.ts +40 -2
- package/dist/generators/ts/DefaultValueType.js +14 -12
- package/dist/generators/ts/FloatType.d.ts +3 -1
- package/dist/generators/ts/FloatType.js +1 -1
- package/dist/generators/ts/GraphqlSchema.d.ts +4 -4
- package/dist/generators/ts/GraphqlSchema.js +6 -6
- package/dist/generators/ts/IdentifierType.d.ts +3 -3
- package/dist/generators/ts/IdentifierType.js +19 -17
- package/dist/generators/ts/IntType.d.ts +3 -1
- package/dist/generators/ts/IntType.js +1 -1
- package/dist/generators/ts/IriType.d.ts +2 -2
- package/dist/generators/ts/IriType.js +21 -19
- package/dist/generators/ts/LazyObjectOptionType.d.ts +2 -0
- package/dist/generators/ts/LazyObjectOptionType.js +14 -10
- package/dist/generators/ts/LazyObjectSetType.js +14 -8
- package/dist/generators/ts/LazyObjectType.js +9 -6
- package/dist/generators/ts/ListType.d.ts +13 -5
- package/dist/generators/ts/ListType.js +48 -12
- package/dist/generators/ts/LiteralType.d.ts +5 -1
- package/dist/generators/ts/LiteralType.js +11 -8
- package/dist/generators/ts/{NamedObjectType.d.ts → ObjectType.d.ts} +19 -34
- package/dist/generators/ts/ObjectType.js +282 -0
- package/dist/generators/ts/ObjectUnionType.d.ts +20 -0
- package/dist/generators/ts/{NamedObjectUnionType.js → ObjectUnionType.js} +52 -60
- package/dist/generators/ts/OptionType.d.ts +6 -2
- package/dist/generators/ts/OptionType.js +20 -15
- package/dist/generators/ts/RdfjsDatasetObjectSetType.js +8 -11
- package/dist/generators/ts/SetType.d.ts +16 -1
- package/dist/generators/ts/SetType.js +80 -2
- package/dist/generators/ts/Snippets.d.ts +3 -1
- package/dist/generators/ts/Snippets.js +18 -4
- package/dist/generators/ts/SparqlObjectSetType.js +2 -2
- package/dist/generators/ts/StringType.d.ts +5 -3
- package/dist/generators/ts/StringType.js +15 -6
- package/dist/generators/ts/TermType.d.ts +6 -2
- package/dist/generators/ts/TermType.js +15 -12
- package/dist/generators/ts/TsGenerator.d.ts +1 -1
- package/dist/generators/ts/TsGenerator.js +60 -32
- package/dist/generators/ts/Type.d.ts +4 -5
- package/dist/generators/ts/TypeFactory.d.ts +7 -8
- package/dist/generators/ts/TypeFactory.js +62 -76
- package/dist/generators/ts/{AbstractUnionType.d.ts → UnionType.d.ts} +36 -11
- package/dist/generators/ts/{AbstractUnionType.js → UnionType.js} +296 -105
- package/dist/generators/ts/ZodGenerator.d.ts +1 -1
- package/dist/generators/ts/ZodGenerator.js +21 -16
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.d.ts +9 -6
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/AbstractProperty.js +3 -3
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.d.ts +9 -13
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/DiscriminantProperty.js +22 -39
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.d.ts +1 -5
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/IdentifierProperty.js +18 -13
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_createFunctionDeclaration.js +44 -0
- package/dist/generators/ts/_ObjectType/ObjectType_equalsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js → _ObjectType/ObjectType_equalsFunctionDeclaration.js} +3 -7
- package/dist/generators/ts/_ObjectType/ObjectType_filterFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js → _ObjectType/ObjectType_filterFunctionDeclaration.js} +3 -6
- package/dist/generators/ts/_ObjectType/ObjectType_filterTypeDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_filterTypeDeclaration.js → _ObjectType/ObjectType_filterTypeDeclaration.js} +2 -5
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlConstructTriplesFunctionDeclaration.js} +2 -6
- package/dist/generators/ts/_ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_focusSparqlWherePatternsFunctionDeclaration.js} +5 -24
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclaration.js +18 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceFunctionDeclaration.js +51 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfResourceValuesFunctionDeclaration.js +15 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js → _ObjectType/ObjectType_fromRdfTypeVariableStatement.js} +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_graphqlTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js → _ObjectType/ObjectType_graphqlTypeVariableStatement.js} +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_hashFunctionDeclarations.js +41 -0
- package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/ObjectType_interfaceDeclaration.js +12 -0
- package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_isTypeFunctionDeclaration.js +20 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonParseFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js → _ObjectType/ObjectType_jsonParseFunctionDeclaration.js} +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js} +5 -11
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonTypeAliasDeclaration.js +9 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js → _ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js} +4 -6
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts → _ObjectType/ObjectType_objectSetMethodNames.d.ts} +3 -3
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_objectSetMethodNames.js → _ObjectType/ObjectType_objectSetMethodNames.js} +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_schemaVariableStatement.js +12 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts} +3 -3
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js → _ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js} +5 -5
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts → _ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts} +3 -3
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +12 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toJsonFunctionDeclaration.js +20 -0
- package/dist/generators/ts/_ObjectType/ObjectType_toRdfResourceFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js → _ObjectType/ObjectType_toRdfResourceFunctionDeclaration.js} +4 -4
- package/dist/generators/ts/_ObjectType/ObjectType_toStringFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js → _ObjectType/ObjectType_toStringFunctionDeclarations.js} +7 -14
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlConstructTriplesFunctionDeclaration.js} +3 -3
- package/dist/generators/ts/_ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/{_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js → _ObjectType/ObjectType_valueSparqlWherePatternsFunctionDeclaration.js} +3 -3
- package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.js +12 -12
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +16 -0
- package/dist/generators/ts/_snippets/snippets_convertToArraySet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToArraySet.js +8 -0
- package/dist/generators/ts/_snippets/snippets_convertToList.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToList.js +7 -0
- package/dist/generators/ts/_snippets/snippets_convertToScalarSet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToScalarSet.js +15 -0
- package/dist/input/generated.d.ts +758 -117
- package/dist/input/generated.js +636 -128
- package/package.json +4 -6
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +0 -30
- package/dist/generators/ts/AbstractNamedUnionType.js +0 -190
- package/dist/generators/ts/AnonymousUnionType.d.ts +0 -27
- package/dist/generators/ts/AnonymousUnionType.js +0 -59
- package/dist/generators/ts/NamedObjectType.js +0 -342
- package/dist/generators/ts/NamedObjectUnionType.d.ts +0 -37
- package/dist/generators/ts/NamedUnionType.d.ts +0 -11
- package/dist/generators/ts/NamedUnionType.js +0 -13
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +0 -65
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +0 -43
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +0 -80
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +0 -15
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +0 -45
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_interfaceDeclaration.js +0 -16
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js +0 -17
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +0 -16
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +0 -12
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +0 -12
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +0 -41
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.d.ts +0 -4
- package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.js +0 -25
- package/dist/generators/ts/_snippets/snippets_convertToArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_convertToArray.js +0 -8
- /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.d.ts +0 -0
- /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/Property.js +0 -0
- /package/dist/generators/ts/{_NamedObjectType → _ObjectType}/ShaclProperty.d.ts +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Maybe } from "purify-ts";
|
|
2
2
|
import { AbstractType } from "./AbstractType.js";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
3
|
+
import type { ObjectType } from "./ObjectType.js";
|
|
4
|
+
import type { ObjectUnionType } from "./ObjectUnionType.js";
|
|
5
5
|
import type { OptionType } from "./OptionType.js";
|
|
6
6
|
import type { SetType } from "./SetType.js";
|
|
7
7
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
@@ -17,24 +17,24 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
|
|
|
17
17
|
readonly discriminantProperty: AbstractType["discriminantProperty"];
|
|
18
18
|
readonly mutable = false;
|
|
19
19
|
readonly referencesObjectType = true;
|
|
20
|
-
readonly typeofs: "object"[];
|
|
21
20
|
readonly validationFunction: Maybe<Code>;
|
|
22
21
|
constructor({ partialType, resolveType, ...superParameters }: {
|
|
23
22
|
partialType: PartialTypeT;
|
|
24
23
|
resolveType: ResolveTypeT;
|
|
25
24
|
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
26
25
|
get equalsFunction(): Code;
|
|
26
|
+
get expression(): Code;
|
|
27
27
|
get filterFunction(): Code;
|
|
28
28
|
get filterType(): Code;
|
|
29
29
|
get graphqlType(): AbstractType.GraphqlType;
|
|
30
30
|
get hashFunction(): Code;
|
|
31
|
-
get
|
|
31
|
+
get jsTypes(): readonly AbstractType.JsType[];
|
|
32
32
|
get recursive(): boolean;
|
|
33
|
-
protected get schemaInitializers(): readonly Code[];
|
|
34
33
|
get schemaType(): Code;
|
|
35
34
|
get toRdfResourceValueTypes(): AbstractType["toRdfResourceValueTypes"];
|
|
36
35
|
get valueSparqlConstructTriplesFunction(): Code;
|
|
37
36
|
get valueSparqlWherePatternsFunction(): Code;
|
|
37
|
+
protected get schemaInitializers(): readonly Code[];
|
|
38
38
|
jsonSchema(parameters: Parameters<AbstractType["jsonSchema"]>[0]): Code;
|
|
39
39
|
jsonType(parameters?: Parameters<AbstractType["jsonType"]>[0]): AbstractType.JsonType;
|
|
40
40
|
jsonUiSchemaElement(parameters: Parameters<AbstractType["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
@@ -45,16 +45,16 @@ export declare abstract class AbstractLazyObjectType<PartialTypeT extends Abstra
|
|
|
45
45
|
partialType: ObjectTypeT;
|
|
46
46
|
resolveType: ObjectTypeT;
|
|
47
47
|
}): Code;
|
|
48
|
-
protected
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
protected resolvedObjectUnionTypeToPartialObjectUnionTypeConversion({ resolvedObjectUnionType, partialObjectUnionType, variables, }: {
|
|
49
|
+
resolvedObjectUnionType: ObjectUnionType;
|
|
50
|
+
partialObjectUnionType: ObjectUnionType;
|
|
51
51
|
variables: {
|
|
52
52
|
resolvedObjectUnion: Code;
|
|
53
53
|
};
|
|
54
54
|
}): Code;
|
|
55
55
|
}
|
|
56
56
|
export declare namespace AbstractLazyObjectType {
|
|
57
|
-
type ObjectTypeConstraint =
|
|
57
|
+
type ObjectTypeConstraint = ObjectType | ObjectUnionType;
|
|
58
58
|
type PartialTypeConstraint = ObjectTypeConstraint | OptionType<ObjectTypeConstraint> | SetType<ObjectTypeConstraint>;
|
|
59
59
|
type ResolveTypeConstraint = PartialTypeConstraint;
|
|
60
60
|
type ConversionFunction = AbstractType.ConversionFunction;
|
|
@@ -16,7 +16,6 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
16
16
|
discriminantProperty = Maybe.empty();
|
|
17
17
|
mutable = false;
|
|
18
18
|
referencesObjectType = true;
|
|
19
|
-
typeofs = ["object"];
|
|
20
19
|
validationFunction = Maybe.empty();
|
|
21
20
|
constructor({ partialType, resolveType, ...superParameters }) {
|
|
22
21
|
super(superParameters);
|
|
@@ -26,8 +25,11 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
26
25
|
get equalsFunction() {
|
|
27
26
|
return code `((left, right) => ${this.partialType.equalsFunction}(left.${this.runtimeClass.partialPropertyName}, right.${this.runtimeClass.partialPropertyName}))`;
|
|
28
27
|
}
|
|
28
|
+
get expression() {
|
|
29
|
+
return this.runtimeClass.name;
|
|
30
|
+
}
|
|
29
31
|
get filterFunction() {
|
|
30
|
-
return code `((filter: ${this.filterType}, value: ${this.
|
|
32
|
+
return code `((filter: ${this.filterType}, value: ${this.expression}) => ${this.partialType.filterFunction}(filter, value.${this.runtimeClass.partialPropertyName}))`;
|
|
31
33
|
}
|
|
32
34
|
get filterType() {
|
|
33
35
|
return this.partialType.filterType;
|
|
@@ -38,15 +40,18 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
38
40
|
get hashFunction() {
|
|
39
41
|
return code `((hasher, value) => ${this.partialType.hashFunction}(hasher, value.${this.runtimeClass.partialPropertyName}))`;
|
|
40
42
|
}
|
|
41
|
-
get
|
|
42
|
-
return
|
|
43
|
+
get jsTypes() {
|
|
44
|
+
return [
|
|
45
|
+
{
|
|
46
|
+
className: this.runtimeClass.rawName,
|
|
47
|
+
instanceof: "class",
|
|
48
|
+
typeof: "object",
|
|
49
|
+
},
|
|
50
|
+
];
|
|
43
51
|
}
|
|
44
52
|
get recursive() {
|
|
45
53
|
return this.partialType.recursive;
|
|
46
54
|
}
|
|
47
|
-
get schemaInitializers() {
|
|
48
|
-
return super.schemaInitializers.concat(code `get partialType() { return ${this.partialType.schema}; }`);
|
|
49
|
-
}
|
|
50
55
|
get schemaType() {
|
|
51
56
|
return code `${{
|
|
52
57
|
kind: this.kind,
|
|
@@ -62,6 +67,9 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
62
67
|
get valueSparqlWherePatternsFunction() {
|
|
63
68
|
return code `(({ schema, ...otherParameters }) => ${this.partialType.valueSparqlWherePatternsFunction}({ ...otherParameters, schema: schema.partialType }))`;
|
|
64
69
|
}
|
|
70
|
+
get schemaInitializers() {
|
|
71
|
+
return super.schemaInitializers.concat(code `get partialType() { return ${this.partialType.schema}; }`);
|
|
72
|
+
}
|
|
65
73
|
jsonSchema(parameters) {
|
|
66
74
|
return this.partialType.jsonSchema(parameters);
|
|
67
75
|
}
|
|
@@ -94,26 +102,26 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
94
102
|
});
|
|
95
103
|
}
|
|
96
104
|
resolveToPartialFunction({ partialType, resolveType, }) {
|
|
97
|
-
if (partialType.kind === "
|
|
98
|
-
return code `${partialType.
|
|
105
|
+
if (partialType.kind === "Object") {
|
|
106
|
+
return code `${partialType.alias.unsafeCoerce()}.createUnsafe`;
|
|
99
107
|
}
|
|
100
|
-
invariant(partialType.kind === "
|
|
101
|
-
invariant(resolveType.kind === "
|
|
108
|
+
invariant(partialType.kind === "ObjectUnion");
|
|
109
|
+
invariant(resolveType.kind === "ObjectUnion");
|
|
102
110
|
invariant(partialType.members.length === resolveType.members.length);
|
|
103
111
|
const caseBlocks = resolveType.members.map(({ discriminantValues }, memberI) => {
|
|
104
|
-
return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialType.members[memberI].type.
|
|
112
|
+
return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialType.members[memberI].type.alias.unsafeCoerce()}.createUnsafe(resolved);`;
|
|
105
113
|
});
|
|
106
114
|
caseBlocks.push(code `default: resolved satisfies never; throw new Error("unrecognized type");`);
|
|
107
|
-
return code `((resolved: ${resolveType.
|
|
115
|
+
return code `((resolved: ${resolveType.expression}) => { switch (resolved.${resolveType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} } })`;
|
|
108
116
|
}
|
|
109
|
-
|
|
110
|
-
invariant(
|
|
111
|
-
|
|
112
|
-
const caseBlocks =
|
|
113
|
-
return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${
|
|
117
|
+
resolvedObjectUnionTypeToPartialObjectUnionTypeConversion({ resolvedObjectUnionType, partialObjectUnionType, variables, }) {
|
|
118
|
+
invariant(resolvedObjectUnionType.members.length ===
|
|
119
|
+
partialObjectUnionType.members.length);
|
|
120
|
+
const caseBlocks = resolvedObjectUnionType.members.map(({ discriminantValues }, memberI) => {
|
|
121
|
+
return code `${discriminantValues.map((discriminantPropertyValue) => `case "${discriminantPropertyValue}":`).join("\n")} return ${partialObjectUnionType.members[memberI].type.alias.unsafeCoerce()}.create(${variables.resolvedObjectUnion});`;
|
|
114
122
|
});
|
|
115
123
|
caseBlocks.push(code `default: ${variables.resolvedObjectUnion} satisfies never; throw new Error("unrecognized type");`);
|
|
116
|
-
return code `switch (${variables.resolvedObjectUnion}.${
|
|
124
|
+
return code `switch (${variables.resolvedObjectUnion}.${resolvedObjectUnionType.discriminantProperty.unsafeCoerce().name}) { ${joinCode(caseBlocks)} }`;
|
|
117
125
|
}
|
|
118
126
|
}
|
|
119
127
|
__decorate([
|
|
@@ -125,6 +133,9 @@ __decorate([
|
|
|
125
133
|
__decorate([
|
|
126
134
|
Memoize()
|
|
127
135
|
], AbstractLazyObjectType.prototype, "hashFunction", null);
|
|
136
|
+
__decorate([
|
|
137
|
+
Memoize()
|
|
138
|
+
], AbstractLazyObjectType.prototype, "jsTypes", null);
|
|
128
139
|
__decorate([
|
|
129
140
|
Memoize()
|
|
130
141
|
], AbstractLazyObjectType.prototype, "schemaType", null);
|
|
@@ -22,6 +22,7 @@ export declare namespace AbstractLiteralType {
|
|
|
22
22
|
type DiscriminantProperty = AbstractTermType.DiscriminantProperty;
|
|
23
23
|
const GraphqlType: typeof import("./AbstractType.js").AbstractType.GraphqlType;
|
|
24
24
|
type GraphqlType = AbstractTermType.GraphqlType;
|
|
25
|
+
type JsType = AbstractTermType.JsType;
|
|
25
26
|
const JsonType: typeof import("./AbstractType.js").AbstractType.JsonType;
|
|
26
27
|
type JsonType = AbstractTermType.JsonType;
|
|
27
28
|
}
|
|
@@ -8,7 +8,7 @@ export declare abstract class AbstractNumericType<ValueT extends bigint | number
|
|
|
8
8
|
abstract readonly kind: "BigInt" | "Float" | "Int";
|
|
9
9
|
get filterFunction(): Code;
|
|
10
10
|
get filterType(): Code;
|
|
11
|
-
get
|
|
11
|
+
get expression(): Code;
|
|
12
12
|
get schemaType(): Code;
|
|
13
13
|
get valueSparqlWherePatternsFunction(): Code;
|
|
14
14
|
jsonSchema(_parameters: Parameters<AbstractPrimitiveType<ValueT>["jsonSchema"]>[0]): Code;
|
|
@@ -13,27 +13,27 @@ import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
|
13
13
|
export class AbstractNumericType extends AbstractPrimitiveType {
|
|
14
14
|
hashFunction = code `${this.reusables.snippets.hashNumeric}`;
|
|
15
15
|
get filterFunction() {
|
|
16
|
-
return code `${this.reusables.snippets.filterNumeric}<${this.
|
|
16
|
+
return code `${this.reusables.snippets.filterNumeric}<${this.jsTypes[0].typeof}>`;
|
|
17
17
|
}
|
|
18
18
|
get filterType() {
|
|
19
|
-
return code `${this.reusables.snippets.NumericFilter}<${this.
|
|
19
|
+
return code `${this.reusables.snippets.NumericFilter}<${this.jsTypes[0].typeof}>`;
|
|
20
20
|
}
|
|
21
|
-
get
|
|
21
|
+
get expression() {
|
|
22
22
|
if (this.primitiveIn.length > 0) {
|
|
23
23
|
return code `${joinCode(this.primitiveIn.map((value) => this.literalExpression(value)), { on: " | " })}`;
|
|
24
24
|
}
|
|
25
|
-
return this.
|
|
25
|
+
return code `${this.jsTypes[0].typeof}`;
|
|
26
26
|
}
|
|
27
27
|
get schemaType() {
|
|
28
|
-
return code `${this.reusables.snippets.NumericSchema}<${this.
|
|
28
|
+
return code `${this.reusables.snippets.NumericSchema}<${this.jsTypes[0].typeof}>`;
|
|
29
29
|
}
|
|
30
30
|
get valueSparqlWherePatternsFunction() {
|
|
31
|
-
return code `${this.reusables.snippets.numericSparqlWherePatterns}<${this.
|
|
31
|
+
return code `${this.reusables.snippets.numericSparqlWherePatterns}<${this.jsTypes[0].typeof}>`;
|
|
32
32
|
}
|
|
33
33
|
jsonSchema(_parameters) {
|
|
34
34
|
switch (this.primitiveIn.length) {
|
|
35
35
|
case 0:
|
|
36
|
-
return code `${this.reusables.imports.z}.${this.
|
|
36
|
+
return code `${this.reusables.imports.z}.${this.jsTypes[0].typeof}()`;
|
|
37
37
|
case 1:
|
|
38
38
|
return code `${this.reusables.imports.z}.literal(${this.literalExpression(this.primitiveIn[0])})`;
|
|
39
39
|
default:
|
|
@@ -41,7 +41,7 @@ export class AbstractNumericType extends AbstractPrimitiveType {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
toRdfResourceValuesExpression({ variables, }) {
|
|
44
|
-
return code `[${this.reusables.snippets.literalFactory}.${this.
|
|
44
|
+
return code `[${this.reusables.snippets.literalFactory}.${this.jsTypes[0].typeof}(${variables.value}, ${this.rdfjsTermExpression(this.datatype)})]`;
|
|
45
45
|
}
|
|
46
46
|
fromRdfResourceValuesExpressionChain({ variables, }) {
|
|
47
47
|
return {
|
|
@@ -62,7 +62,7 @@ __decorate([
|
|
|
62
62
|
], AbstractNumericType.prototype, "filterType", null);
|
|
63
63
|
__decorate([
|
|
64
64
|
Memoize()
|
|
65
|
-
], AbstractNumericType.prototype, "
|
|
65
|
+
], AbstractNumericType.prototype, "expression", null);
|
|
66
66
|
__decorate([
|
|
67
67
|
Memoize()
|
|
68
68
|
], AbstractNumericType.prototype, "schemaType", null);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { Maybe } from "purify-ts";
|
|
1
2
|
import type { Logger } from "ts-log";
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
3
|
+
import type { ObjectType } from "./ObjectType.js";
|
|
4
|
+
import type { ObjectUnionType } from "./ObjectUnionType.js";
|
|
4
5
|
import type { Reusables } from "./Reusables.js";
|
|
5
6
|
import type { TsGenerator } from "./TsGenerator.js";
|
|
6
7
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
@@ -8,25 +9,25 @@ export declare abstract class AbstractObjectSetType {
|
|
|
8
9
|
protected readonly configuration: TsGenerator.Configuration;
|
|
9
10
|
protected readonly logger: Logger;
|
|
10
11
|
protected readonly reusables: Reusables;
|
|
11
|
-
protected readonly namedObjectTypes: readonly
|
|
12
|
-
protected readonly namedObjectUnionTypes: readonly
|
|
12
|
+
protected readonly namedObjectTypes: readonly ObjectType[];
|
|
13
|
+
protected readonly namedObjectUnionTypes: readonly ObjectUnionType[];
|
|
13
14
|
constructor({ configuration, logger, namedObjectTypes, namedObjectUnionTypes, reusables, }: {
|
|
14
15
|
configuration: TsGenerator.Configuration;
|
|
15
16
|
logger: Logger;
|
|
16
|
-
namedObjectTypes: readonly
|
|
17
|
-
namedObjectUnionTypes: readonly
|
|
17
|
+
namedObjectTypes: readonly ObjectType[];
|
|
18
|
+
namedObjectUnionTypes: readonly ObjectUnionType[];
|
|
18
19
|
reusables: Reusables;
|
|
19
20
|
});
|
|
20
21
|
abstract readonly declaration: Code;
|
|
21
22
|
protected methodSignatures(namedObjectType: {
|
|
23
|
+
readonly alias: Maybe<string>;
|
|
22
24
|
readonly filterType: Code;
|
|
23
25
|
readonly identifierTypeAlias: Code;
|
|
24
|
-
readonly objectSetMethodNames:
|
|
25
|
-
readonly name: string;
|
|
26
|
+
readonly objectSetMethodNames: ObjectType.ObjectSetMethodNames;
|
|
26
27
|
}, options?: {
|
|
27
28
|
parameterNamePrefix?: string;
|
|
28
29
|
queryT?: string;
|
|
29
|
-
}): Readonly<Record<keyof
|
|
30
|
+
}): Readonly<Record<keyof ObjectType.ObjectSetMethodNames, {
|
|
30
31
|
readonly name: string;
|
|
31
32
|
readonly parameters: Code;
|
|
32
33
|
readonly returnType: Code;
|
|
@@ -21,7 +21,7 @@ export class AbstractObjectSetType {
|
|
|
21
21
|
object: {
|
|
22
22
|
name: methodNames.object,
|
|
23
23
|
parameters: code `${parameterNamePrefix}identifier: ${namedObjectType.identifierTypeAlias}, options?: { preferredLanguages?: readonly string[]; }`,
|
|
24
|
-
returnType: code `Promise<${this.reusables.imports.Either}<Error, ${namedObjectType.
|
|
24
|
+
returnType: code `Promise<${this.reusables.imports.Either}<Error, ${namedObjectType.alias.unsafeCoerce()}>>`,
|
|
25
25
|
},
|
|
26
26
|
objectCount: {
|
|
27
27
|
name: methodNames.objectCount,
|
|
@@ -36,7 +36,7 @@ export class AbstractObjectSetType {
|
|
|
36
36
|
objects: {
|
|
37
37
|
name: methodNames.objects,
|
|
38
38
|
parameters: code `${parameterNamePrefix}query?: ${queryT}<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>`,
|
|
39
|
-
returnType: code `Promise<${this.reusables.imports.Either}<Error, readonly ${namedObjectType.
|
|
39
|
+
returnType: code `Promise<${this.reusables.imports.Either}<Error, readonly ${namedObjectType.alias.unsafeCoerce()}[]>>`,
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
42
|
}
|
|
@@ -23,6 +23,7 @@ export declare abstract class AbstractPrimitiveType<ValueT extends bigint | bool
|
|
|
23
23
|
export declare namespace AbstractPrimitiveType {
|
|
24
24
|
type ConversionFunction = AbstractLiteralType.ConversionFunction;
|
|
25
25
|
type DiscriminantProperty = AbstractLiteralType.DiscriminantProperty;
|
|
26
|
+
type JsType = AbstractLiteralType.JsType;
|
|
26
27
|
const GraphqlType: typeof import("./AbstractType.js").AbstractType.GraphqlType;
|
|
27
28
|
type GraphqlType = AbstractLiteralType.GraphqlType;
|
|
28
29
|
const JsonType: typeof import("./AbstractType.js").AbstractType.JsonType;
|
|
@@ -29,13 +29,13 @@ export class AbstractPrimitiveType extends AbstractLiteralType {
|
|
|
29
29
|
return initializers;
|
|
30
30
|
}
|
|
31
31
|
fromJsonExpression({ variables, }) {
|
|
32
|
-
return code `${this.reusables.imports.Either}.of<Error, ${this.
|
|
32
|
+
return code `${this.reusables.imports.Either}.of<Error, ${this.expression}>(${variables.value})`;
|
|
33
33
|
}
|
|
34
34
|
graphqlResolveExpression({ variables, }) {
|
|
35
35
|
return variables.value;
|
|
36
36
|
}
|
|
37
37
|
jsonType() {
|
|
38
|
-
return new AbstractLiteralType.JsonType(this.
|
|
38
|
+
return new AbstractLiteralType.JsonType(this.expression);
|
|
39
39
|
}
|
|
40
40
|
toJsonExpression({ variables, }) {
|
|
41
41
|
return variables.value;
|
|
@@ -3,7 +3,6 @@ import { NodeKind } from "@shaclmate/shacl-ast";
|
|
|
3
3
|
import { Maybe } from "purify-ts";
|
|
4
4
|
import { AbstractType } from "./AbstractType.js";
|
|
5
5
|
import type { Type } from "./Type.js";
|
|
6
|
-
import type { Typeof } from "./Typeof.js";
|
|
7
6
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
8
7
|
/**
|
|
9
8
|
* Abstract base class for IdentifierType and LiteralType.
|
|
@@ -24,7 +23,6 @@ export declare abstract class AbstractTermType<ConstantTermT extends Literal | N
|
|
|
24
23
|
abstract readonly nodeKinds: ReadonlySet<NodeKind>;
|
|
25
24
|
readonly recursive = false;
|
|
26
25
|
readonly referencesObjectType = false;
|
|
27
|
-
readonly typeofs: readonly Typeof[];
|
|
28
26
|
readonly validationFunction: Maybe<Code>;
|
|
29
27
|
constructor({ hasValues, in_, ...superParameters }: {
|
|
30
28
|
hasValues: readonly ConstantTermT[];
|
|
@@ -60,6 +58,7 @@ export declare namespace AbstractTermType {
|
|
|
60
58
|
type DiscriminantProperty = AbstractType.DiscriminantProperty;
|
|
61
59
|
const GraphqlType: typeof AbstractType.GraphqlType;
|
|
62
60
|
type GraphqlType = AbstractType.GraphqlType;
|
|
61
|
+
type JsType = AbstractType.JsType;
|
|
63
62
|
const JsonType: typeof AbstractType.JsonType;
|
|
64
63
|
type JsonType = AbstractType.JsonType;
|
|
65
64
|
}
|
|
@@ -27,7 +27,6 @@ export class AbstractTermType extends AbstractType {
|
|
|
27
27
|
mutable = false;
|
|
28
28
|
recursive = false;
|
|
29
29
|
referencesObjectType = false;
|
|
30
|
-
typeofs = ["object"];
|
|
31
30
|
validationFunction = Maybe.empty();
|
|
32
31
|
constructor({ hasValues, in_, ...superParameters }) {
|
|
33
32
|
super(superParameters);
|
|
@@ -39,10 +38,9 @@ export class AbstractTermType extends AbstractType {
|
|
|
39
38
|
}
|
|
40
39
|
get discriminantProperty() {
|
|
41
40
|
return Maybe.of({
|
|
42
|
-
descendantValues: [],
|
|
43
41
|
jsonName: "termType",
|
|
44
42
|
name: "termType",
|
|
45
|
-
|
|
43
|
+
values: [...this.nodeKinds].map(NodeKind.toTermType),
|
|
46
44
|
type: "string",
|
|
47
45
|
});
|
|
48
46
|
}
|
|
@@ -95,11 +93,11 @@ export class AbstractTermType extends AbstractType {
|
|
|
95
93
|
valueToExpression = code `value.toTerm([${joinCode(this.in_.map((in_) => this.rdfjsTermExpression(in_)), { on: ", " })}])`;
|
|
96
94
|
}
|
|
97
95
|
else if (this.nodeKinds.size < 3) {
|
|
98
|
-
const eitherTypeParameters = code `<Error, ${this.
|
|
96
|
+
const eitherTypeParameters = code `<Error, ${this.expression}>`;
|
|
99
97
|
valueToExpression = code `value.toTerm().chain(term => {
|
|
100
98
|
switch (term.termType) {
|
|
101
99
|
${[...this.nodeKinds].map((nodeKind) => `case "${NodeKind.toTermType(nodeKind)}":`).join("\n")} return ${this.reusables.imports.Either}.of${eitherTypeParameters}(term);
|
|
102
|
-
default: return ${this.reusables.imports.Left}${eitherTypeParameters}(new ${this.reusables.imports.Resource}.MistypedTermValueError(${{ actualValue: code `term`, expectedValueType: code `${this.
|
|
100
|
+
default: return ${this.reusables.imports.Left}${eitherTypeParameters}(new ${this.reusables.imports.Resource}.MistypedTermValueError(${{ actualValue: code `term`, expectedValueType: code `${this.expression}`.toCodeString([]), focusResource: variables.resource, propertyPath: variables.propertyPath }}));
|
|
103
101
|
}})`;
|
|
104
102
|
}
|
|
105
103
|
else {
|
|
@@ -3,7 +3,6 @@ import type { Logger } from "ts-log";
|
|
|
3
3
|
import type { Reusables } from "./Reusables.js";
|
|
4
4
|
import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
|
|
5
5
|
import type { TsGenerator } from "./TsGenerator.js";
|
|
6
|
-
import type { Typeof } from "./Typeof.js";
|
|
7
6
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
8
7
|
/**
|
|
9
8
|
* Abstract base class all types.
|
|
@@ -12,6 +11,10 @@ export declare abstract class AbstractType {
|
|
|
12
11
|
protected readonly configuration: TsGenerator.Configuration;
|
|
13
12
|
protected readonly logger: Logger;
|
|
14
13
|
protected readonly reusables: Reusables;
|
|
14
|
+
/**
|
|
15
|
+
* Alias for this type.
|
|
16
|
+
*/
|
|
17
|
+
readonly alias: Maybe<string>;
|
|
15
18
|
/**
|
|
16
19
|
* Comment from rdfs:comment.
|
|
17
20
|
*/
|
|
@@ -39,6 +42,10 @@ export declare abstract class AbstractType {
|
|
|
39
42
|
* $EqualsResult.
|
|
40
43
|
*/
|
|
41
44
|
abstract readonly equalsFunction: Code;
|
|
45
|
+
/**
|
|
46
|
+
* TypeScript type expression.
|
|
47
|
+
*/
|
|
48
|
+
abstract readonly expression: Code;
|
|
42
49
|
/**
|
|
43
50
|
* A function (reference or declaration) that takes a filter of filterType (below) and a value of this type
|
|
44
51
|
* and returns true if the value passes the filter.
|
|
@@ -62,6 +69,10 @@ export declare abstract class AbstractType {
|
|
|
62
69
|
* A function (reference or declaration) that takes a Hasher and a value of this type, calls hasher.update on the value, and returns the Hasher.
|
|
63
70
|
*/
|
|
64
71
|
abstract readonly hashFunction: Code;
|
|
72
|
+
/**
|
|
73
|
+
* JavaScript type(s) the type.
|
|
74
|
+
*/
|
|
75
|
+
abstract readonly jsTypes: readonly AbstractType.JsType[];
|
|
65
76
|
/**
|
|
66
77
|
* Type discriminant.
|
|
67
78
|
*/
|
|
@@ -74,10 +85,6 @@ export declare abstract class AbstractType {
|
|
|
74
85
|
* Is a value of this type mutable?
|
|
75
86
|
*/
|
|
76
87
|
abstract readonly mutable: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* TypeScript name of the type.
|
|
79
|
-
*/
|
|
80
|
-
abstract readonly name: Code | string;
|
|
81
88
|
/**
|
|
82
89
|
* Does this type directly or indirectly reference itself?
|
|
83
90
|
*/
|
|
@@ -94,10 +101,6 @@ export declare abstract class AbstractType {
|
|
|
94
101
|
* The type(s) of the array elements produced by the toRdfResourceValuesExpression.
|
|
95
102
|
*/
|
|
96
103
|
abstract readonly toRdfResourceValueTypes: ReadonlySet<"BlankNode" | "NamedNode" | "Literal">;
|
|
97
|
-
/**
|
|
98
|
-
* JavaScript typeof(s) the type.
|
|
99
|
-
*/
|
|
100
|
-
abstract readonly typeofs: readonly Typeof[];
|
|
101
104
|
/**
|
|
102
105
|
* Function that takes
|
|
103
106
|
* - a schema of this.schemaType
|
|
@@ -133,7 +136,8 @@ export declare abstract class AbstractType {
|
|
|
133
136
|
* - variablePrefix: string prefix to use for new variables
|
|
134
137
|
*/
|
|
135
138
|
abstract readonly valueSparqlWherePatternsFunction: Code;
|
|
136
|
-
constructor({ comment, configuration, label, logger, reusables, }: {
|
|
139
|
+
constructor({ alias, comment, configuration, label, logger, reusables, }: {
|
|
140
|
+
alias: Maybe<string>;
|
|
137
141
|
comment: Maybe<string>;
|
|
138
142
|
configuration: TsGenerator.Configuration;
|
|
139
143
|
label: Maybe<string>;
|
|
@@ -160,7 +164,7 @@ export declare abstract class AbstractType {
|
|
|
160
164
|
* An expression that converts a Either<Error, rdfjsResource.Resource.Values> to a
|
|
161
165
|
* Either<Error, rdfjsResource.Resource.Values<this type>>.
|
|
162
166
|
*
|
|
163
|
-
* These expressions are used to deserialize property values in an
|
|
167
|
+
* These expressions are used to deserialize property values in an ObjectType, either directly (a property with this Type) or indirectly (a property with a Type like OptionType
|
|
164
168
|
* that has a type parameter of this Type).
|
|
165
169
|
*
|
|
166
170
|
* Some types need to filter on the set of all objects/values of a (subject, predicate). For example, all sh:hasValue values must be present in the set for any values
|
|
@@ -169,7 +173,7 @@ export declare abstract class AbstractType {
|
|
|
169
173
|
* Values may also need to be sorted. For example, specifying preferredLanguages should sort the values in the order of the specified languages so that the first value
|
|
170
174
|
* (if it exists) is always of the first preferred language.
|
|
171
175
|
*
|
|
172
|
-
* variables are runtime variables, most derived from the parameters of the
|
|
176
|
+
* variables are runtime variables, most derived from the parameters of the ObjectType's fromRdf function:
|
|
173
177
|
* context: unanticipated properties (...) passed to Object.fromRdf
|
|
174
178
|
* graph: DefaultGraph | NamedNode | undefined to match (subject, predicate, object) triples in; if undefined, match triples in all graphs
|
|
175
179
|
* ignoreRdfType: whether the RDF type of objects/object unions should be ignored
|
|
@@ -204,7 +208,7 @@ export declare abstract class AbstractType {
|
|
|
204
208
|
* Zod schema for the JSON type of this type.
|
|
205
209
|
*
|
|
206
210
|
* This method is called in two contexts:
|
|
207
|
-
* "property": from a ShaclProperty, while generating the z.object properties of an
|
|
211
|
+
* "property": from a ShaclProperty, while generating the z.object properties of an ObjectType
|
|
208
212
|
* "type": from another Type e.g., an OptionType or UnionType
|
|
209
213
|
*
|
|
210
214
|
* z.lazy() should only be returned for "property".
|
|
@@ -241,7 +245,7 @@ export declare abstract class AbstractType {
|
|
|
241
245
|
* An expression that converts a property value of this type to a value or an array of values that can be .add'd to a Resource with
|
|
242
246
|
* resource.add(predicate, convertedValue, graph)
|
|
243
247
|
*
|
|
244
|
-
* variables are runtime variables, most derived from the parameters of the
|
|
248
|
+
* variables are runtime variables, most derived from the parameters of the ObjectType's fromRdf function:
|
|
245
249
|
* graph: DefaultGraph | NamedNode | undefined to .add to; if undefined, add to the default graph
|
|
246
250
|
* propertyPath: predicate path (NamedNode) or InversePath on a predicate path
|
|
247
251
|
* resource: the Resource to .add to
|
|
@@ -271,15 +275,14 @@ export declare namespace AbstractType {
|
|
|
271
275
|
interface ConversionFunction {
|
|
272
276
|
readonly code: Code;
|
|
273
277
|
readonly sourceTypes: {
|
|
274
|
-
readonly
|
|
275
|
-
readonly
|
|
278
|
+
readonly expression: Code;
|
|
279
|
+
readonly jsType: JsType;
|
|
276
280
|
}[];
|
|
277
281
|
}
|
|
278
282
|
interface DiscriminantProperty {
|
|
279
|
-
readonly descendantValues: readonly DiscriminantProperty.Value[];
|
|
280
283
|
readonly jsonName: string;
|
|
281
284
|
readonly name: string;
|
|
282
|
-
readonly
|
|
285
|
+
readonly values: readonly DiscriminantProperty.Value[];
|
|
283
286
|
}
|
|
284
287
|
namespace DiscriminantProperty {
|
|
285
288
|
type Value = number | string;
|
|
@@ -290,14 +293,46 @@ export declare namespace AbstractType {
|
|
|
290
293
|
*/
|
|
291
294
|
readonly nullable: boolean;
|
|
292
295
|
/**
|
|
293
|
-
* The
|
|
296
|
+
* The expression of the type when it's nullable -- so it should never include "new graphql.GraphQLNonNull(...)" around it.
|
|
294
297
|
*/
|
|
295
|
-
readonly
|
|
298
|
+
readonly nullableExpression: Code;
|
|
296
299
|
private readonly reusables;
|
|
297
|
-
constructor(
|
|
300
|
+
constructor(nullableExpression: Code, reusables: Reusables, options?: {
|
|
298
301
|
nullable: boolean;
|
|
299
302
|
});
|
|
300
|
-
get
|
|
303
|
+
get expression(): Code;
|
|
304
|
+
}
|
|
305
|
+
type JsType = {
|
|
306
|
+
typeof: "bigint";
|
|
307
|
+
} | {
|
|
308
|
+
typeof: "boolean";
|
|
309
|
+
} | {
|
|
310
|
+
typeof: "function";
|
|
311
|
+
} | {
|
|
312
|
+
typeof: "number";
|
|
313
|
+
} | {
|
|
314
|
+
instanceof: "Array";
|
|
315
|
+
typeof: "object";
|
|
316
|
+
} | {
|
|
317
|
+
className: Code;
|
|
318
|
+
instanceof: "class";
|
|
319
|
+
typeof: "object";
|
|
320
|
+
} | {
|
|
321
|
+
instanceof: "Date";
|
|
322
|
+
typeof: "object";
|
|
323
|
+
} | {
|
|
324
|
+
instanceof: "Maybe";
|
|
325
|
+
typeof: "object";
|
|
326
|
+
} | {
|
|
327
|
+
instanceof: "Object";
|
|
328
|
+
typeof: "object";
|
|
329
|
+
} | {
|
|
330
|
+
typeof: "string";
|
|
331
|
+
} | {
|
|
332
|
+
typeof: "undefined";
|
|
333
|
+
};
|
|
334
|
+
namespace JsType {
|
|
335
|
+
function equals(left: JsType, right: JsType): boolean;
|
|
301
336
|
}
|
|
302
337
|
class JsonType {
|
|
303
338
|
/**
|
|
@@ -305,13 +340,13 @@ export declare namespace AbstractType {
|
|
|
305
340
|
*/
|
|
306
341
|
readonly optional: boolean;
|
|
307
342
|
/**
|
|
308
|
-
* The
|
|
343
|
+
* The expression of the type when it's required i.e. -- so it should never include "| undefined".
|
|
309
344
|
*/
|
|
310
|
-
readonly
|
|
311
|
-
constructor(
|
|
345
|
+
readonly requiredExpression: Code;
|
|
346
|
+
constructor(requiredExpression: Code, parameters?: {
|
|
312
347
|
optional: boolean;
|
|
313
348
|
});
|
|
314
|
-
get
|
|
349
|
+
get expression(): Code;
|
|
315
350
|
}
|
|
316
351
|
}
|
|
317
352
|
//# sourceMappingURL=AbstractType.d.ts.map
|