@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
|
@@ -9,8 +9,8 @@ import { Memoize } from "typescript-memoize";
|
|
|
9
9
|
import { AbstractNumericType } from "./AbstractNumericType.js";
|
|
10
10
|
import { code } from "./ts-poet-wrapper.js";
|
|
11
11
|
export class IntType extends AbstractNumericType {
|
|
12
|
+
jsTypes = [{ typeof: "number" }];
|
|
12
13
|
kind = "Int";
|
|
13
|
-
typeofs = ["number"];
|
|
14
14
|
get graphqlType() {
|
|
15
15
|
return new AbstractNumericType.GraphqlType(code `${this.reusables.imports.GraphQLInt}`, this.reusables);
|
|
16
16
|
}
|
|
@@ -10,10 +10,10 @@ export declare class IriType extends AbstractIdentifierType<NamedNode> {
|
|
|
10
10
|
readonly schemaType: Code;
|
|
11
11
|
readonly valueSparqlWherePatternsFunction: Code;
|
|
12
12
|
get conversionFunction(): Maybe<AbstractIdentifierType.ConversionFunction>;
|
|
13
|
-
get
|
|
14
|
-
private get valueTypeName();
|
|
13
|
+
get expression(): Code;
|
|
15
14
|
get parseFunction(): Code;
|
|
16
15
|
protected get schemaInitializers(): readonly Code[];
|
|
16
|
+
private get valueTypeExpression();
|
|
17
17
|
fromJsonExpression({ variables, }: Parameters<AbstractIdentifierType<NamedNode>["fromJsonExpression"]>[0]): Code;
|
|
18
18
|
jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractIdentifierType<NamedNode>["jsonSchema"]>[0]): Code;
|
|
19
19
|
jsonType(parameters?: Parameters<AbstractIdentifierType<NamedNode>["jsonType"]>[0]): AbstractIdentifierType.JsonType;
|
|
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { Maybe } from "purify-ts";
|
|
8
|
+
import { invariant } from "ts-invariant";
|
|
8
9
|
import { Memoize } from "typescript-memoize";
|
|
9
10
|
import { AbstractIdentifierType } from "./AbstractIdentifierType.js";
|
|
10
11
|
import { arrayOf, code, joinCode } from "./ts-poet-wrapper.js";
|
|
@@ -13,37 +14,33 @@ export class IriType extends AbstractIdentifierType {
|
|
|
13
14
|
filterType = code `${this.reusables.snippets.IriFilter}`;
|
|
14
15
|
kind = "Iri";
|
|
15
16
|
nodeKinds = nodeKinds;
|
|
16
|
-
schemaType = code `${this.reusables.snippets.IriSchema}<${this.
|
|
17
|
+
schemaType = code `${this.reusables.snippets.IriSchema}<${this.valueTypeExpression}>`;
|
|
17
18
|
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.iriSparqlWherePatterns}`;
|
|
18
19
|
get conversionFunction() {
|
|
20
|
+
invariant(this.jsTypes.length === 1);
|
|
19
21
|
return Maybe.of({
|
|
20
|
-
code: code `${this.reusables.snippets.convertToIri}<${this.
|
|
22
|
+
code: code `${this.reusables.snippets.convertToIri}<${this.valueTypeExpression}>`,
|
|
21
23
|
sourceTypes: [
|
|
22
24
|
{
|
|
23
|
-
|
|
24
|
-
typeof: "string",
|
|
25
|
+
expression: this.valueTypeExpression,
|
|
26
|
+
jsType: { typeof: "string" },
|
|
25
27
|
},
|
|
26
28
|
{
|
|
27
|
-
|
|
28
|
-
|
|
29
|
+
expression: this.expression,
|
|
30
|
+
jsType: this.jsTypes[0],
|
|
29
31
|
},
|
|
30
32
|
],
|
|
31
33
|
});
|
|
32
34
|
}
|
|
33
|
-
get
|
|
35
|
+
get expression() {
|
|
34
36
|
if (this.in_.length > 0) {
|
|
35
|
-
return code `${this.reusables.imports.NamedNode}<${this.
|
|
37
|
+
return code `${this.reusables.imports.NamedNode}<${this.valueTypeExpression}>`;
|
|
36
38
|
}
|
|
37
39
|
return code `${this.reusables.imports.NamedNode}`;
|
|
38
40
|
}
|
|
39
|
-
get valueTypeName() {
|
|
40
|
-
return this.in_.length > 0
|
|
41
|
-
? `(${this.in_.map((in_) => `"${in_.value}"`).join(" | ")})`
|
|
42
|
-
: "string";
|
|
43
|
-
}
|
|
44
41
|
get parseFunction() {
|
|
45
42
|
if (this.in_.length > 0) {
|
|
46
|
-
return code `(identifier: string) => ${this.reusables.snippets.parseIri}(identifier).chain((identifier) => { switch (identifier.value) { ${joinCode(this.in_.map((iri) => code `case "${iri.value}": return ${this.reusables.imports.Right}(identifier as ${this.
|
|
43
|
+
return code `(identifier: string) => ${this.reusables.snippets.parseIri}(identifier).chain((identifier) => { switch (identifier.value) { ${joinCode(this.in_.map((iri) => code `case "${iri.value}": return ${this.reusables.imports.Right}(identifier as ${this.expression});`))} default: return ${this.reusables.imports.Left}(new Error("expected NamedNode identifier to be one of ${this.in_.map((iri) => iri.value).join(" ")}")); } })`;
|
|
47
44
|
}
|
|
48
45
|
return code `${this.reusables.snippets.parseIri}`;
|
|
49
46
|
}
|
|
@@ -54,8 +51,13 @@ export class IriType extends AbstractIdentifierType {
|
|
|
54
51
|
}
|
|
55
52
|
return initializers;
|
|
56
53
|
}
|
|
54
|
+
get valueTypeExpression() {
|
|
55
|
+
return this.in_.length > 0
|
|
56
|
+
? code `(${this.in_.map((in_) => `"${in_.value}"`).join(" | ")})`
|
|
57
|
+
: code `string`;
|
|
58
|
+
}
|
|
57
59
|
fromJsonExpression({ variables, }) {
|
|
58
|
-
return code `${this.reusables.imports.Either}.of<Error, ${this.
|
|
60
|
+
return code `${this.reusables.imports.Either}.of<Error, ${this.expression}>(${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@id"]))`;
|
|
59
61
|
}
|
|
60
62
|
jsonSchema({ includeDiscriminantProperty, }) {
|
|
61
63
|
let idSchema;
|
|
@@ -76,7 +78,7 @@ export class IriType extends AbstractIdentifierType {
|
|
|
76
78
|
const discriminantProperty = parameters?.includeDiscriminantProperty
|
|
77
79
|
? `, readonly termType: "NamedNode"`
|
|
78
80
|
: "";
|
|
79
|
-
return new AbstractIdentifierType.JsonType(code `{ readonly "@id": ${this.
|
|
81
|
+
return new AbstractIdentifierType.JsonType(code `{ readonly "@id": ${this.valueTypeExpression}${discriminantProperty} }`);
|
|
80
82
|
}
|
|
81
83
|
toJsonExpression({ includeDiscriminantProperty, variables, }) {
|
|
82
84
|
const discriminantProperty = includeDiscriminantProperty
|
|
@@ -98,13 +100,13 @@ __decorate([
|
|
|
98
100
|
], IriType.prototype, "conversionFunction", null);
|
|
99
101
|
__decorate([
|
|
100
102
|
Memoize()
|
|
101
|
-
], IriType.prototype, "
|
|
103
|
+
], IriType.prototype, "expression", null);
|
|
102
104
|
__decorate([
|
|
103
105
|
Memoize()
|
|
104
|
-
], IriType.prototype, "
|
|
106
|
+
], IriType.prototype, "parseFunction", null);
|
|
105
107
|
__decorate([
|
|
106
108
|
Memoize()
|
|
107
|
-
], IriType.prototype, "
|
|
109
|
+
], IriType.prototype, "valueTypeExpression", null);
|
|
108
110
|
__decorate([
|
|
109
111
|
Memoize()
|
|
110
112
|
], IriType.prototype, "jsonType", null);
|
|
@@ -7,6 +7,7 @@ declare const Super: (abstract new ({ partialType, resolveType, ...superParamete
|
|
|
7
7
|
partialType: OptionType<AbstractLazyObjectType.ObjectTypeConstraint>;
|
|
8
8
|
resolveType: OptionType<AbstractLazyObjectType.ObjectTypeConstraint>;
|
|
9
9
|
} & {
|
|
10
|
+
alias: Maybe<string>;
|
|
10
11
|
comment: Maybe<string>;
|
|
11
12
|
configuration: import("./TsGenerator.js").TsGenerator.Configuration;
|
|
12
13
|
label: Maybe<string>;
|
|
@@ -15,6 +16,7 @@ declare const Super: (abstract new ({ partialType, resolveType, ...superParamete
|
|
|
15
16
|
}) => AbstractLazyObjectType<OptionType<AbstractLazyObjectType.ObjectTypeConstraint>, OptionType<AbstractLazyObjectType.ObjectTypeConstraint>>) & {
|
|
16
17
|
readonly GraphqlType: typeof import("./AbstractType.js").AbstractType.GraphqlType;
|
|
17
18
|
readonly JsonType: typeof import("./AbstractType.js").AbstractType.JsonType;
|
|
19
|
+
JsType: typeof import("./AbstractType.js").AbstractType.JsType;
|
|
18
20
|
};
|
|
19
21
|
export declare class LazyObjectOptionType extends Super {
|
|
20
22
|
readonly graphqlArgs: Super["graphqlArgs"];
|
|
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { Maybe } from "purify-ts";
|
|
8
|
+
import { invariant } from "ts-invariant";
|
|
8
9
|
import { Memoize } from "typescript-memoize";
|
|
9
10
|
import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
|
|
10
11
|
import { code } from "./ts-poet-wrapper.js";
|
|
@@ -13,31 +14,34 @@ export class LazyObjectOptionType extends Super {
|
|
|
13
14
|
graphqlArgs = Maybe.empty();
|
|
14
15
|
kind = "LazyObjectOption";
|
|
15
16
|
get conversionFunction() {
|
|
17
|
+
invariant(this.jsTypes.length === 1);
|
|
18
|
+
invariant(this.resolveType.jsTypes.length === 1);
|
|
19
|
+
invariant(this.resolveType.itemType.jsTypes.length === 1);
|
|
16
20
|
return Maybe.of({
|
|
17
|
-
code: code `${this.reusables.snippets.convertToLazyObjectOption}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.
|
|
21
|
+
code: code `${this.reusables.snippets.convertToLazyObjectOption}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.expression}, ${this.resolveType.itemType.expression}>(${this.resolveToPartialFunction({ partialType: this.partialType.itemType, resolveType: this.resolveType.itemType })})`,
|
|
18
22
|
sourceTypes: [
|
|
19
23
|
{
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
expression: this.expression,
|
|
25
|
+
jsType: this.jsTypes[0],
|
|
22
26
|
},
|
|
23
27
|
{
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
expression: this.resolveType.expression,
|
|
29
|
+
jsType: this.resolveType.jsTypes[0],
|
|
26
30
|
},
|
|
27
31
|
{
|
|
28
|
-
|
|
29
|
-
|
|
32
|
+
expression: this.resolveType.itemType.expression,
|
|
33
|
+
jsType: this.resolveType.itemType.jsTypes[0],
|
|
30
34
|
},
|
|
31
35
|
{
|
|
32
|
-
|
|
33
|
-
typeof: "undefined",
|
|
36
|
+
expression: code `undefined`,
|
|
37
|
+
jsType: { typeof: "undefined" },
|
|
34
38
|
},
|
|
35
39
|
],
|
|
36
40
|
});
|
|
37
41
|
}
|
|
38
42
|
get runtimeClass() {
|
|
39
43
|
return {
|
|
40
|
-
name: code `${this.reusables.snippets.LazyObjectOption}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.
|
|
44
|
+
name: code `${this.reusables.snippets.LazyObjectOption}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.expression}, ${this.resolveType.itemType.expression}>`,
|
|
41
45
|
partialPropertyName: "partial",
|
|
42
46
|
rawName: code `${this.reusables.snippets.LazyObjectOption}`,
|
|
43
47
|
};
|
|
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { Maybe } from "purify-ts";
|
|
8
|
+
import { invariant } from "ts-invariant";
|
|
8
9
|
import { Memoize } from "typescript-memoize";
|
|
9
10
|
import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
|
|
10
11
|
import { code } from "./ts-poet-wrapper.js";
|
|
@@ -19,27 +20,29 @@ export class LazyObjectSetType extends AbstractLazyObjectType {
|
|
|
19
20
|
});
|
|
20
21
|
kind = "LazyObjectSet";
|
|
21
22
|
get conversionFunction() {
|
|
23
|
+
invariant(this.jsTypes.length === 1);
|
|
24
|
+
invariant(this.resolveType.jsTypes.length === 1);
|
|
22
25
|
return Maybe.of({
|
|
23
|
-
code: code `${this.reusables.snippets.convertToLazyObjectSet}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.
|
|
26
|
+
code: code `${this.reusables.snippets.convertToLazyObjectSet}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.expression}, ${this.resolveType.itemType.expression}>(${this.resolveToPartialFunction({ partialType: this.partialType.itemType, resolveType: this.resolveType.itemType })})`,
|
|
24
27
|
sourceTypes: [
|
|
25
28
|
{
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
expression: this.expression,
|
|
30
|
+
jsType: this.jsTypes[0],
|
|
28
31
|
},
|
|
29
32
|
{
|
|
30
|
-
|
|
31
|
-
|
|
33
|
+
expression: this.resolveType.expression,
|
|
34
|
+
jsType: this.resolveType.jsTypes[0],
|
|
32
35
|
},
|
|
33
36
|
{
|
|
34
|
-
|
|
35
|
-
typeof: "undefined",
|
|
37
|
+
expression: code `undefined`,
|
|
38
|
+
jsType: { typeof: "undefined" },
|
|
36
39
|
},
|
|
37
40
|
],
|
|
38
41
|
});
|
|
39
42
|
}
|
|
40
43
|
get runtimeClass() {
|
|
41
44
|
return {
|
|
42
|
-
name: code `${this.reusables.snippets.LazyObjectSet}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.
|
|
45
|
+
name: code `${this.reusables.snippets.LazyObjectSet}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.expression}, ${this.resolveType.itemType.expression}>`,
|
|
43
46
|
partialPropertyName: "partials",
|
|
44
47
|
rawName: code `${this.reusables.snippets.LazyObjectSet}`,
|
|
45
48
|
};
|
|
@@ -58,4 +61,7 @@ export class LazyObjectSetType extends AbstractLazyObjectType {
|
|
|
58
61
|
__decorate([
|
|
59
62
|
Memoize()
|
|
60
63
|
], LazyObjectSetType.prototype, "conversionFunction", null);
|
|
64
|
+
__decorate([
|
|
65
|
+
Memoize()
|
|
66
|
+
], LazyObjectSetType.prototype, "runtimeClass", null);
|
|
61
67
|
//# sourceMappingURL=LazyObjectSetType.js.map
|
|
@@ -5,6 +5,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { Maybe } from "purify-ts";
|
|
8
|
+
import { invariant } from "ts-invariant";
|
|
8
9
|
import { Memoize } from "typescript-memoize";
|
|
9
10
|
import { AbstractLazyObjectType } from "./AbstractLazyObjectType.js";
|
|
10
11
|
import { code } from "./ts-poet-wrapper.js";
|
|
@@ -12,23 +13,25 @@ export class LazyObjectType extends AbstractLazyObjectType {
|
|
|
12
13
|
graphqlArgs = Maybe.empty();
|
|
13
14
|
kind = "LazyObject";
|
|
14
15
|
get conversionFunction() {
|
|
16
|
+
invariant(this.jsTypes.length === 1);
|
|
17
|
+
invariant(this.resolveType.jsTypes.length === 1);
|
|
15
18
|
return Maybe.of({
|
|
16
|
-
code: code `${this.reusables.snippets.convertToLazyObject}<${this.resolveType.identifierTypeAlias}, ${this.partialType.
|
|
19
|
+
code: code `${this.reusables.snippets.convertToLazyObject}<${this.resolveType.identifierTypeAlias}, ${this.partialType.expression}, ${this.resolveType.expression}>(${this.resolveToPartialFunction({ partialType: this.partialType, resolveType: this.resolveType })})`,
|
|
17
20
|
sourceTypes: [
|
|
18
21
|
{
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
expression: this.expression,
|
|
23
|
+
jsType: this.jsTypes[0],
|
|
21
24
|
},
|
|
22
25
|
{
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
expression: this.resolveType.expression,
|
|
27
|
+
jsType: this.resolveType.jsTypes[0],
|
|
25
28
|
},
|
|
26
29
|
],
|
|
27
30
|
});
|
|
28
31
|
}
|
|
29
32
|
get runtimeClass() {
|
|
30
33
|
return {
|
|
31
|
-
name: code `${this.reusables.snippets.LazyObject}<${this.resolveType.identifierTypeAlias}, ${this.partialType.
|
|
34
|
+
name: code `${this.reusables.snippets.LazyObject}<${this.resolveType.identifierTypeAlias}, ${this.partialType.expression}, ${this.resolveType.expression}>`,
|
|
32
35
|
partialPropertyName: "partial",
|
|
33
36
|
rawName: code `${this.reusables.snippets.LazyObject}`,
|
|
34
37
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { NamedNode } from "@rdfjs/types";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
2
3
|
import { AbstractCollectionType } from "./AbstractCollectionType.js";
|
|
3
|
-
import type { AnonymousUnionType } from "./AnonymousUnionType.js";
|
|
4
4
|
import type { BigDecimalType } from "./BigDecimalType.js";
|
|
5
5
|
import type { BigIntType } from "./BigIntType.js";
|
|
6
6
|
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
@@ -12,30 +12,38 @@ import type { IdentifierType } from "./IdentifierType.js";
|
|
|
12
12
|
import type { IntType } from "./IntType.js";
|
|
13
13
|
import type { IriType } from "./IriType.js";
|
|
14
14
|
import type { LiteralType } from "./LiteralType.js";
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
17
|
-
import type { NamedUnionType } from "./NamedUnionType.js";
|
|
15
|
+
import type { ObjectType } from "./ObjectType.js";
|
|
16
|
+
import type { ObjectUnionType } from "./ObjectUnionType.js";
|
|
18
17
|
import type { StringType } from "./StringType.js";
|
|
19
18
|
import type { TermType } from "./TermType.js";
|
|
20
19
|
import type { Type } from "./Type.js";
|
|
21
20
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
21
|
+
import type { UnionType } from "./UnionType.js";
|
|
22
22
|
export declare class ListType<ItemTypeT extends ListType.ItemType> extends AbstractCollectionType<ItemTypeT> {
|
|
23
23
|
private readonly identifierNodeKind;
|
|
24
24
|
private readonly toRdfTypes;
|
|
25
|
+
readonly jsTypes: readonly [{
|
|
26
|
+
readonly instanceof: "Array";
|
|
27
|
+
readonly typeof: "object";
|
|
28
|
+
}];
|
|
25
29
|
readonly kind = "List";
|
|
26
30
|
constructor({ identifierNodeKind, toRdfTypes, ...superParameters }: {
|
|
27
31
|
identifierNodeKind: ListType<ItemTypeT>["identifierNodeKind"];
|
|
28
32
|
toRdfTypes: readonly NamedNode[];
|
|
29
33
|
} & ConstructorParameters<typeof AbstractCollectionType<ItemTypeT>>[0]);
|
|
34
|
+
get conversionFunction(): Maybe<AbstractCollectionType.ConversionFunction>;
|
|
35
|
+
get toRdfResourceValueTypes(): AbstractCollectionType<ItemTypeT>["toRdfResourceValueTypes"];
|
|
30
36
|
get valueSparqlConstructTriplesFunction(): Code;
|
|
31
37
|
get valueSparqlWherePatternsFunction(): Code;
|
|
38
|
+
fromJsonExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["fromJsonExpression"]>[0]): Code;
|
|
32
39
|
fromRdfResourceValuesExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["fromRdfResourceValuesExpression"]>[0]): Code;
|
|
40
|
+
jsonSchema(parameters: Parameters<AbstractCollectionType<ItemTypeT>["jsonSchema"]>[0]): Code;
|
|
33
41
|
jsonType(): AbstractCollectionType.JsonType;
|
|
34
42
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["toRdfResourceValuesExpression"]>[0]): Code;
|
|
35
43
|
toStringExpression({ variables, }: Parameters<AbstractCollectionType<ItemTypeT>["toStringExpression"]>[0]): Code;
|
|
36
44
|
}
|
|
37
45
|
export declare namespace ListType {
|
|
38
|
-
type ItemType =
|
|
46
|
+
type ItemType = BigDecimalType | BigIntType | BlankNodeType | BooleanType | DateTimeType | DateType | FloatType | IdentifierType | IntType | IriType | ListType<ListType.ItemType> | LiteralType | ObjectUnionType | ObjectType | StringType | TermType | UnionType<Type>;
|
|
39
47
|
function isItemType(type: Type): type is ItemType;
|
|
40
48
|
}
|
|
41
49
|
//# sourceMappingURL=ListType.d.ts.map
|
|
@@ -5,24 +5,48 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { rdf } from "@tpluscode/rdf-ns-builders";
|
|
8
|
+
import { Maybe } from "purify-ts";
|
|
8
9
|
import { Memoize } from "typescript-memoize";
|
|
9
10
|
import { AbstractCollectionType } from "./AbstractCollectionType.js";
|
|
10
|
-
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
11
|
+
import { code, joinCode, literalOf } from "./ts-poet-wrapper.js";
|
|
11
12
|
export class ListType extends AbstractCollectionType {
|
|
12
13
|
identifierNodeKind;
|
|
13
14
|
toRdfTypes;
|
|
15
|
+
jsTypes = [
|
|
16
|
+
{ instanceof: "Array", typeof: "object" },
|
|
17
|
+
];
|
|
14
18
|
kind = "List";
|
|
15
19
|
constructor({ identifierNodeKind, toRdfTypes, ...superParameters }) {
|
|
16
20
|
super(superParameters);
|
|
17
21
|
this.identifierNodeKind = identifierNodeKind;
|
|
18
22
|
this.toRdfTypes = toRdfTypes;
|
|
19
23
|
}
|
|
24
|
+
get conversionFunction() {
|
|
25
|
+
const itemConversionFunction = this.itemType.conversionFunction.orDefault(this.itemConversionFunctionDefault);
|
|
26
|
+
return Maybe.of({
|
|
27
|
+
code: code `${this.reusables.snippets.convertToList}(${itemConversionFunction.code}, ${literalOf(!this._mutable)})`,
|
|
28
|
+
sourceTypes: [
|
|
29
|
+
{
|
|
30
|
+
expression: code `readonly (${joinCode(itemConversionFunction.sourceTypes.map((itemSourceType) => code `${itemSourceType.expression}`), { on: " | " })})[]`,
|
|
31
|
+
jsType: { instanceof: "Array", typeof: "object" },
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
get toRdfResourceValueTypes() {
|
|
37
|
+
return new Set(["BlankNode", "NamedNode"]); // List or rdf:nil
|
|
38
|
+
}
|
|
20
39
|
get valueSparqlConstructTriplesFunction() {
|
|
21
40
|
return code `${this.reusables.snippets.listSparqlConstructTriples}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlConstructTriplesFunction})`;
|
|
22
41
|
}
|
|
23
42
|
get valueSparqlWherePatternsFunction() {
|
|
24
43
|
return code `${this.reusables.snippets.listSparqlWherePatterns}<${this.itemType.filterType}, ${this.itemType.schemaType}>(${this.itemType.valueSparqlWherePatternsFunction})`;
|
|
25
44
|
}
|
|
45
|
+
fromJsonExpression({ variables, }) {
|
|
46
|
+
return code `${this.reusables.imports.Either}.sequence<Error, ${this.itemType.expression}>(${variables.value}.map(item => (${this.itemType.fromJsonExpression({
|
|
47
|
+
variables: { value: code `item` },
|
|
48
|
+
})})))`;
|
|
49
|
+
}
|
|
26
50
|
fromRdfResourceValuesExpression({ variables, }) {
|
|
27
51
|
return joinCode([
|
|
28
52
|
variables.resourceValues,
|
|
@@ -39,22 +63,29 @@ export class ListType extends AbstractCollectionType {
|
|
|
39
63
|
code `map(valueLists => valueLists.map(valueList => valueList.toArray()${this.mutable ? ".concat()" : ""}))`, // Convert inner Resource.Values to arrays
|
|
40
64
|
], { on: "." });
|
|
41
65
|
}
|
|
66
|
+
jsonSchema(parameters) {
|
|
67
|
+
let schema = code `${this.itemType.jsonSchema(parameters)}.array()`;
|
|
68
|
+
if (!this._mutable) {
|
|
69
|
+
schema = code `${schema}.readonly()`;
|
|
70
|
+
}
|
|
71
|
+
return schema;
|
|
72
|
+
}
|
|
42
73
|
jsonType() {
|
|
43
|
-
return new AbstractCollectionType.JsonType(code `${!this.mutable ? "readonly " : ""}(${this.itemType.jsonType().
|
|
74
|
+
return new AbstractCollectionType.JsonType(code `${!this.mutable ? "readonly " : ""}(${this.itemType.jsonType().expression})[]`);
|
|
44
75
|
}
|
|
45
76
|
toRdfResourceValuesExpression({ variables, }) {
|
|
46
77
|
let mintListIdentifierFunction;
|
|
47
78
|
let mintSubListIdentifierFunction;
|
|
48
|
-
let
|
|
79
|
+
let resourceTypeExpression;
|
|
49
80
|
switch (this.identifierNodeKind) {
|
|
50
81
|
case "BlankNode": {
|
|
51
82
|
mintListIdentifierFunction =
|
|
52
83
|
mintSubListIdentifierFunction = code `(() => ${this.reusables.imports.dataFactory}.blankNode())`;
|
|
53
|
-
|
|
84
|
+
resourceTypeExpression = code `${this.reusables.imports.Resource}<${this.reusables.imports.BlankNode}>`;
|
|
54
85
|
break;
|
|
55
86
|
}
|
|
56
87
|
case "IRI": {
|
|
57
|
-
|
|
88
|
+
resourceTypeExpression = code `${this.reusables.imports.Resource}<${this.reusables.imports.NamedNode}>`;
|
|
58
89
|
throw new RangeError("list IRI minting is unsupported");
|
|
59
90
|
}
|
|
60
91
|
}
|
|
@@ -81,8 +112,8 @@ export class ListType extends AbstractCollectionType {
|
|
|
81
112
|
currentSubListResource: null,
|
|
82
113
|
listResource: ${variables.resourceSet}.resource(${mintListIdentifierFunction}()),
|
|
83
114
|
} as {
|
|
84
|
-
currentSubListResource: ${
|
|
85
|
-
listResource: ${
|
|
115
|
+
currentSubListResource: ${resourceTypeExpression} | null;
|
|
116
|
+
listResource: ${resourceTypeExpression};
|
|
86
117
|
},
|
|
87
118
|
).listResource.identifier : ${this.rdfjsTermExpression(rdf.nil)}]`;
|
|
88
119
|
}
|
|
@@ -90,6 +121,12 @@ export class ListType extends AbstractCollectionType {
|
|
|
90
121
|
return code `\`[\${${variables.value}.map(item => (${this.itemType.toStringExpression({ variables: { value: code `item` } })}))}]\``;
|
|
91
122
|
}
|
|
92
123
|
}
|
|
124
|
+
__decorate([
|
|
125
|
+
Memoize()
|
|
126
|
+
], ListType.prototype, "conversionFunction", null);
|
|
127
|
+
__decorate([
|
|
128
|
+
Memoize()
|
|
129
|
+
], ListType.prototype, "toRdfResourceValueTypes", null);
|
|
93
130
|
__decorate([
|
|
94
131
|
Memoize()
|
|
95
132
|
], ListType.prototype, "valueSparqlConstructTriplesFunction", null);
|
|
@@ -102,7 +139,6 @@ __decorate([
|
|
|
102
139
|
(function (ListType) {
|
|
103
140
|
function isItemType(type) {
|
|
104
141
|
switch (type.kind) {
|
|
105
|
-
case "AnonymousUnion":
|
|
106
142
|
case "BigDecimal":
|
|
107
143
|
case "BigInt":
|
|
108
144
|
case "BlankNode":
|
|
@@ -113,18 +149,18 @@ __decorate([
|
|
|
113
149
|
case "Identifier":
|
|
114
150
|
case "Iri":
|
|
115
151
|
case "Int":
|
|
152
|
+
case "List":
|
|
116
153
|
case "Literal":
|
|
117
|
-
case "
|
|
118
|
-
case "
|
|
119
|
-
case "NamedObjectType":
|
|
154
|
+
case "ObjectUnion":
|
|
155
|
+
case "Object":
|
|
120
156
|
case "String":
|
|
121
157
|
case "Term":
|
|
158
|
+
case "Union":
|
|
122
159
|
return true;
|
|
123
160
|
case "DefaultValue":
|
|
124
161
|
case "LazyObjectOption":
|
|
125
162
|
case "LazyObjectSet":
|
|
126
163
|
case "LazyObject":
|
|
127
|
-
case "List":
|
|
128
164
|
case "Option":
|
|
129
165
|
case "Set":
|
|
130
166
|
return false;
|
|
@@ -3,10 +3,14 @@ import { Maybe } from "purify-ts";
|
|
|
3
3
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
4
4
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
5
5
|
export declare class LiteralType extends AbstractLiteralType {
|
|
6
|
-
readonly
|
|
6
|
+
readonly expression: Code;
|
|
7
7
|
readonly conversionFunction: Maybe<AbstractLiteralType.ConversionFunction>;
|
|
8
8
|
readonly filterFunction: Code;
|
|
9
9
|
readonly filterType: Code;
|
|
10
|
+
readonly jsTypes: readonly [{
|
|
11
|
+
readonly instanceof: "Object";
|
|
12
|
+
readonly typeof: "object";
|
|
13
|
+
}];
|
|
10
14
|
readonly kind = "Literal";
|
|
11
15
|
readonly schemaType: Code;
|
|
12
16
|
readonly valueSparqlWherePatternsFunction: Code;
|
|
@@ -3,26 +3,29 @@ import { Maybe } from "purify-ts";
|
|
|
3
3
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
4
4
|
import { arrayOf, code } from "./ts-poet-wrapper.js";
|
|
5
5
|
export class LiteralType extends AbstractLiteralType {
|
|
6
|
-
|
|
6
|
+
expression = code `${this.reusables.imports.Literal}`;
|
|
7
7
|
conversionFunction = Maybe.of({
|
|
8
8
|
code: code `${this.reusables.snippets.convertToLiteral}`,
|
|
9
9
|
sourceTypes: [
|
|
10
10
|
...["bigint", "boolean", "number", "string"].map((typeof_) => ({
|
|
11
|
-
|
|
12
|
-
typeof: typeof_,
|
|
11
|
+
expression: code `${typeof_}`,
|
|
12
|
+
jsType: { typeof: typeof_ },
|
|
13
13
|
})),
|
|
14
14
|
{
|
|
15
|
-
|
|
16
|
-
typeof: "object",
|
|
15
|
+
expression: code `Date`,
|
|
16
|
+
jsType: { instanceof: "Date", typeof: "object" },
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
|
-
|
|
20
|
-
typeof: "object",
|
|
19
|
+
expression: code `${this.reusables.imports.Literal}`,
|
|
20
|
+
jsType: { instanceof: "Object", typeof: "object" },
|
|
21
21
|
},
|
|
22
22
|
],
|
|
23
23
|
});
|
|
24
24
|
filterFunction = code `${this.reusables.snippets.filterLiteral}`;
|
|
25
25
|
filterType = code `${this.reusables.snippets.LiteralFilter}`;
|
|
26
|
+
jsTypes = [
|
|
27
|
+
{ instanceof: "Object", typeof: "object" },
|
|
28
|
+
];
|
|
26
29
|
kind = "Literal";
|
|
27
30
|
schemaType = code `${this.reusables.snippets.LiteralSchema}`;
|
|
28
31
|
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.literalSparqlWherePatterns}`;
|
|
@@ -37,7 +40,7 @@ export class LiteralType extends AbstractLiteralType {
|
|
|
37
40
|
return initializers;
|
|
38
41
|
}
|
|
39
42
|
fromJsonExpression({ variables, }) {
|
|
40
|
-
return code `${this.reusables.imports.Either}.of<Error, ${this.
|
|
43
|
+
return code `${this.reusables.imports.Either}.of<Error, ${this.expression}>(${this.reusables.imports.dataFactory}.literal(${variables.value}["@value"], ${variables.value}["@language"] !== undefined ? ${variables.value}["@language"] : (${variables.value}["@type"] !== undefined ? ${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@type"]!) : undefined)))`;
|
|
41
44
|
}
|
|
42
45
|
graphqlResolveExpression(_parameters) {
|
|
43
46
|
throw new Error("not implemented");
|
|
@@ -1,56 +1,47 @@
|
|
|
1
1
|
import type { NamedNode } from "@rdfjs/types";
|
|
2
2
|
import { Maybe } from "purify-ts";
|
|
3
|
-
import { DiscriminantProperty as _DiscriminantProperty } from "./
|
|
4
|
-
import { IdentifierProperty as _IdentifierProperty } from "./
|
|
5
|
-
import type { Property as _Property } from "./
|
|
6
|
-
import { ShaclProperty as _ShaclProperty } from "./
|
|
3
|
+
import { DiscriminantProperty as _DiscriminantProperty } from "./_ObjectType/DiscriminantProperty.js";
|
|
4
|
+
import { IdentifierProperty as _IdentifierProperty } from "./_ObjectType/IdentifierProperty.js";
|
|
5
|
+
import type { Property as _Property } from "./_ObjectType/Property.js";
|
|
6
|
+
import { ShaclProperty as _ShaclProperty } from "./_ObjectType/ShaclProperty.js";
|
|
7
7
|
import { AbstractType } from "./AbstractType.js";
|
|
8
8
|
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
9
9
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
10
10
|
import type { IriType } from "./IriType.js";
|
|
11
11
|
import type { Type } from "./Type.js";
|
|
12
12
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
13
|
-
export declare class
|
|
13
|
+
export declare class ObjectType extends AbstractType {
|
|
14
14
|
protected readonly toRdfTypes: readonly NamedNode[];
|
|
15
15
|
readonly conversionFunction: Maybe<AbstractType.ConversionFunction>;
|
|
16
|
+
readonly discriminantProperty: Maybe<ObjectType.DiscriminantProperty>;
|
|
16
17
|
readonly extern: boolean;
|
|
17
18
|
readonly fromRdfType: Maybe<NamedNode>;
|
|
18
19
|
readonly graphqlArgs: AbstractType["graphqlArgs"];
|
|
19
20
|
readonly identifierType: BlankNodeType | IdentifierType | IriType;
|
|
20
|
-
readonly
|
|
21
|
-
|
|
21
|
+
readonly jsTypes: readonly [{
|
|
22
|
+
readonly instanceof: "Object";
|
|
23
|
+
readonly typeof: "object";
|
|
24
|
+
}];
|
|
25
|
+
readonly kind = "Object";
|
|
22
26
|
readonly recursive: boolean;
|
|
23
27
|
readonly referencesObjectType = true;
|
|
24
28
|
readonly synthetic: boolean;
|
|
25
|
-
readonly typeofs: "object"[];
|
|
26
29
|
readonly validationFunction: Maybe<Code>;
|
|
27
|
-
constructor({ extern, fromRdfType, identifierType,
|
|
30
|
+
constructor({ discriminantProperty, extern, fromRdfType, identifierType, lazyProperties, recursive, synthetic, toRdfTypes, ...superParameters }: {
|
|
31
|
+
discriminantProperty: Maybe<ObjectType.DiscriminantProperty>;
|
|
28
32
|
comment: Maybe<string>;
|
|
29
33
|
extern: boolean;
|
|
30
34
|
fromRdfType: Maybe<NamedNode>;
|
|
31
35
|
identifierType: BlankNodeType | IdentifierType | IriType;
|
|
32
36
|
label: Maybe<string>;
|
|
33
|
-
|
|
34
|
-
lazyChildObjectTypes: () => readonly NamedObjectType[];
|
|
35
|
-
lazyDiscriminantProperty: (namedObjectType: NamedObjectType) => NamedObjectType.DiscriminantProperty;
|
|
36
|
-
lazyDescendantObjectTypes: () => readonly NamedObjectType[];
|
|
37
|
-
lazyParentObjectTypes: () => readonly NamedObjectType[];
|
|
38
|
-
lazyProperties: (namedObjectType: NamedObjectType) => readonly NamedObjectType.Property[];
|
|
39
|
-
name: string;
|
|
37
|
+
lazyProperties: (objectType: ObjectType) => readonly ObjectType.Property[];
|
|
40
38
|
recursive: boolean;
|
|
41
39
|
synthetic: boolean;
|
|
42
40
|
toRdfTypes: readonly NamedNode[];
|
|
43
41
|
} & ConstructorParameters<typeof AbstractType>[0]);
|
|
44
|
-
get _discriminantProperty(): NamedObjectType.DiscriminantProperty;
|
|
45
|
-
get ancestorObjectTypes(): readonly NamedObjectType[];
|
|
46
|
-
get childObjectTypes(): readonly NamedObjectType[];
|
|
47
42
|
get declaration(): Maybe<Code>;
|
|
48
|
-
get descendantFromRdfTypeVariables(): readonly Code[];
|
|
49
|
-
get descendantFromRdfTypes(): readonly NamedNode[];
|
|
50
|
-
get descendantObjectTypes(): readonly NamedObjectType[];
|
|
51
|
-
get discriminantProperty(): Maybe<AbstractType.DiscriminantProperty>;
|
|
52
|
-
get discriminantValue(): string;
|
|
53
43
|
get equalsFunction(): Code;
|
|
44
|
+
get expression(): Code;
|
|
54
45
|
get filterFunction(): Code;
|
|
55
46
|
get filterType(): Code;
|
|
56
47
|
get fromRdfTypeVariable(): Maybe<Code>;
|
|
@@ -58,9 +49,8 @@ export declare class NamedObjectType extends AbstractType {
|
|
|
58
49
|
get hashFunction(): Code;
|
|
59
50
|
get identifierTypeAlias(): Code;
|
|
60
51
|
get mutable(): boolean;
|
|
61
|
-
get objectSetMethodNames():
|
|
62
|
-
get
|
|
63
|
-
get properties(): readonly NamedObjectType.Property[];
|
|
52
|
+
get objectSetMethodNames(): ObjectType.ObjectSetMethodNames;
|
|
53
|
+
get properties(): readonly ObjectType.Property[];
|
|
64
54
|
get schema(): Code;
|
|
65
55
|
get schemaType(): Code;
|
|
66
56
|
get toRdfResourceValueTypes(): AbstractType["toRdfResourceValueTypes"];
|
|
@@ -81,14 +71,9 @@ export declare class NamedObjectType extends AbstractType {
|
|
|
81
71
|
toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
|
|
82
72
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
83
73
|
toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
|
|
84
|
-
private readonly lazyAncestorObjectTypes;
|
|
85
|
-
private readonly lazyChildObjectTypes;
|
|
86
|
-
private readonly lazyDescendantObjectTypes;
|
|
87
|
-
private readonly lazyDiscriminantProperty;
|
|
88
|
-
private readonly lazyParentObjectTypes;
|
|
89
74
|
private readonly lazyProperties;
|
|
90
75
|
}
|
|
91
|
-
export declare namespace
|
|
76
|
+
export declare namespace ObjectType {
|
|
92
77
|
const IdentifierProperty: typeof _IdentifierProperty;
|
|
93
78
|
type IdentifierProperty = _IdentifierProperty;
|
|
94
79
|
type ObjectSetMethodNames = {
|
|
@@ -103,4 +88,4 @@ export declare namespace NamedObjectType {
|
|
|
103
88
|
const DiscriminantProperty: typeof _DiscriminantProperty;
|
|
104
89
|
type DiscriminantProperty = _DiscriminantProperty;
|
|
105
90
|
}
|
|
106
|
-
//# sourceMappingURL=
|
|
91
|
+
//# sourceMappingURL=ObjectType.d.ts.map
|