@shaclmate/compiler 4.0.33 → 4.0.34
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Compiler.d.ts +0 -3
- package/dist/Compiler.js +0 -2
- package/dist/ShapesGraphToAstTransformer.d.ts +1 -4
- package/dist/ShapesGraphToAstTransformer.js +1 -5
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +1 -3
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompoundType.js +4 -7
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstListType.js +0 -1
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstObjectType.js +1 -3
- package/dist/ast/AbstractCompoundType.d.ts +6 -4
- package/dist/ast/AbstractCompoundType.js +4 -37
- package/dist/ast/ObjectType.d.ts +1 -7
- package/dist/ast/ObjectType.js +1 -6
- package/dist/generators/ts/AbstractCollectionType.d.ts +8 -8
- package/dist/generators/ts/AbstractCollectionType.js +28 -111
- package/dist/generators/ts/AbstractContainerType.d.ts +1 -1
- package/dist/generators/ts/AbstractDateType.d.ts +4 -9
- package/dist/generators/ts/AbstractDateType.js +2 -29
- package/dist/generators/ts/AbstractIdentifierType.d.ts +4 -1
- package/dist/generators/ts/AbstractIdentifierType.js +0 -17
- package/dist/generators/ts/AbstractLazyObjectType.d.ts +8 -5
- package/dist/generators/ts/AbstractLazyObjectType.js +21 -21
- package/dist/generators/ts/AbstractLiteralType.d.ts +11 -3
- package/dist/generators/ts/AbstractLiteralType.js +1 -1
- package/dist/generators/ts/AbstractNamedUnionType.d.ts +2 -5
- package/dist/generators/ts/AbstractNamedUnionType.js +27 -58
- package/dist/generators/ts/AbstractNumericType.d.ts +9 -8
- package/dist/generators/ts/AbstractNumericType.js +18 -11
- package/dist/generators/ts/AbstractPrimitiveType.d.ts +8 -4
- package/dist/generators/ts/AbstractPrimitiveType.js +9 -17
- package/dist/generators/ts/AbstractTermType.d.ts +8 -4
- package/dist/generators/ts/AbstractTermType.js +11 -51
- package/dist/generators/ts/AbstractType.d.ts +26 -22
- package/dist/generators/ts/AbstractType.js +4 -2
- package/dist/generators/ts/AbstractUnionType.d.ts +2 -2
- package/dist/generators/ts/AbstractUnionType.js +25 -36
- package/dist/generators/ts/AnonymousUnionType.d.ts +1 -1
- package/dist/generators/ts/AnonymousUnionType.js +3 -3
- package/dist/generators/ts/BigDecimalType.d.ts +5 -3
- package/dist/generators/ts/BigDecimalType.js +15 -42
- package/dist/generators/ts/BigIntType.d.ts +3 -4
- package/dist/generators/ts/BigIntType.js +5 -16
- package/dist/generators/ts/BlankNodeType.d.ts +7 -7
- package/dist/generators/ts/BlankNodeType.js +14 -2
- package/dist/generators/ts/BooleanType.d.ts +6 -8
- package/dist/generators/ts/BooleanType.js +18 -11
- package/dist/generators/ts/DateTimeType.d.ts +5 -1
- package/dist/generators/ts/DateTimeType.js +15 -13
- package/dist/generators/ts/DateType.d.ts +5 -1
- package/dist/generators/ts/DateType.js +16 -14
- package/dist/generators/ts/DefaultValueType.d.ts +5 -6
- package/dist/generators/ts/DefaultValueType.js +30 -64
- package/dist/generators/ts/FloatType.d.ts +3 -3
- package/dist/generators/ts/FloatType.js +5 -5
- package/dist/generators/ts/IdentifierType.d.ts +6 -6
- package/dist/generators/ts/IdentifierType.js +22 -2
- package/dist/generators/ts/IntType.d.ts +3 -3
- package/dist/generators/ts/IntType.js +5 -5
- package/dist/generators/ts/IriType.d.ts +17 -12
- package/dist/generators/ts/IriType.js +39 -29
- package/dist/generators/ts/LazyObjectOptionType.d.ts +2 -1
- package/dist/generators/ts/LazyObjectOptionType.js +23 -44
- package/dist/generators/ts/LazyObjectSetType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectSetType.js +19 -29
- package/dist/generators/ts/LazyObjectType.d.ts +1 -1
- package/dist/generators/ts/LazyObjectType.js +17 -25
- package/dist/generators/ts/LiteralType.d.ts +5 -3
- package/dist/generators/ts/LiteralType.js +25 -12
- package/dist/generators/ts/NamedObjectType.d.ts +6 -9
- package/dist/generators/ts/NamedObjectType.js +33 -29
- package/dist/generators/ts/NamedObjectUnionType.d.ts +3 -1
- package/dist/generators/ts/NamedObjectUnionType.js +21 -14
- package/dist/generators/ts/OptionType.d.ts +4 -4
- package/dist/generators/ts/OptionType.js +22 -45
- package/dist/generators/ts/Reusables.d.ts +3 -1
- package/dist/generators/ts/Reusables.js +2 -1
- package/dist/generators/ts/SetType.d.ts +0 -1
- package/dist/generators/ts/SetType.js +4 -22
- package/dist/generators/ts/SnippetFactory.d.ts +2 -0
- package/dist/generators/ts/Snippets.d.ts +40 -8
- package/dist/generators/ts/Snippets.js +235 -30
- package/dist/generators/ts/StringType.d.ts +6 -9
- package/dist/generators/ts/StringType.js +17 -16
- package/dist/generators/ts/TermType.d.ts +1 -4
- package/dist/generators/ts/TermType.js +14 -8
- package/dist/generators/ts/TsGenerator.d.ts +14 -1
- package/dist/generators/ts/TsGenerator.js +41 -12
- package/dist/generators/ts/TypeFactory.d.ts +8 -4
- package/dist/generators/ts/TypeFactory.js +73 -49
- package/dist/generators/ts/ZodGenerator.js +6 -3
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.d.ts +27 -20
- package/dist/generators/ts/_NamedObjectType/AbstractProperty.js +4 -2
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.d.ts +7 -7
- package/dist/generators/ts/_NamedObjectType/DiscriminantProperty.js +9 -9
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.d.ts +6 -6
- package/dist/generators/ts/_NamedObjectType/IdentifierProperty.js +35 -39
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +34 -31
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +7 -16
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +26 -32
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js +2 -3
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +6 -8
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js +1 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.d.ts +2 -0
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_objectSetMethodNames.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +2 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +14 -18
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.d.ts +7 -7
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +22 -30
- package/dist/generators/ts/_snippets/snippets_DefaultValueSchema.js +3 -3
- package/dist/generators/ts/_snippets/snippets_HashFunction.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_HashFunction.js +4 -0
- package/dist/generators/ts/_snippets/snippets_PropertyPath.js +34 -24
- package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBigDecimal.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNode.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNode.js +11 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNodeIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBlankNodeIdentifierProperty.js +17 -0
- package/dist/generators/ts/_snippets/snippets_convertToBoolean.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToBoolean.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToDate.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToDate.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToDateTime.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToDateTime.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifier.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifier.js +13 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIdentifierProperty.js +21 -0
- package/dist/generators/ts/_snippets/snippets_convertToIri.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIri.js +11 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToIriIdentifierProperty.js +17 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObject.js +15 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectOption.js +31 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLazyObjectSet.js +25 -0
- package/dist/generators/ts/_snippets/snippets_convertToLiteral.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToLiteral.js +13 -0
- package/dist/generators/ts/_snippets/snippets_convertToMaybe.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToMaybe.js +19 -0
- package/dist/generators/ts/_snippets/snippets_convertToMutableArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToMutableArray.js +14 -0
- package/dist/generators/ts/_snippets/snippets_convertToNumeric.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToNumeric.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToObject.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToObject.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToReadonlyArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToReadonlyArray.js +14 -0
- package/dist/generators/ts/_snippets/snippets_convertToString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToString.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToTerm.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToTerm.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertToUnion.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertToUnion.js +6 -0
- package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_convertWithDefaultValue.js +11 -0
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_hashArray.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashArray.js +11 -0
- package/dist/generators/ts/_snippets/snippets_hashBigDecimal.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashBigDecimal.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashBoolean.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashBoolean.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashDate.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashDate.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashDateTime.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashDateTime.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashMaybe.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashMaybe.js +11 -0
- package/dist/generators/ts/_snippets/snippets_hashNumeric.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashNumeric.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashString.js +7 -0
- package/dist/generators/ts/_snippets/snippets_hashTerm.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_hashTerm.js +12 -0
- package/dist/generators/ts/_snippets/snippets_toIsoDateString.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_toIsoDateString.js +6 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +1 -1
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +7 -4
- package/dist/generators/ts/objectSetDeclarations.js +4 -34
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +1 -1
- package/dist/generators/ts/objectSetMethodSignatures.js +2 -2
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +2 -2
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +2 -2
- package/dist/input/ShapesGraph.d.ts +5 -8
- package/dist/input/ShapesGraph.js +5 -6
- package/dist/input/generated.d.ts +171 -226
- package/dist/input/generated.js +563 -2082
- package/package.json +2 -2
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.d.ts +0 -6
- package/dist/_ShapesGraphToAstTransformer/nodeShapeTsFeatures.js +0 -67
- package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyBigIntArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyBooleanArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyNumberArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyObjectArray.js +0 -6
- package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.d.ts +0 -3
- package/dist/generators/ts/_snippets/snippets_isReadonlyStringArray.js +0 -6
- package/dist/generators/ts/syntheticNamePrefix.d.ts +0 -2
- package/dist/generators/ts/syntheticNamePrefix.js +0 -2
|
@@ -7,9 +7,29 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { NodeKind } from "@shaclmate/shacl-ast";
|
|
8
8
|
import { Memoize } from "typescript-memoize";
|
|
9
9
|
import { AbstractIdentifierType } from "./AbstractIdentifierType.js";
|
|
10
|
-
import { AbstractTermType } from "./AbstractTermType.js";
|
|
11
10
|
import { arrayOf, code } from "./ts-poet-wrapper.js";
|
|
12
11
|
export class IdentifierType extends AbstractIdentifierType {
|
|
12
|
+
conversionFunction = {
|
|
13
|
+
code: code `${this.reusables.snippets.convertToIdentifier}`,
|
|
14
|
+
sourceTypes: [
|
|
15
|
+
{
|
|
16
|
+
name: code `${this.reusables.imports.BlankNode}`,
|
|
17
|
+
typeof: "object",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: code `${this.reusables.imports.NamedNode}`,
|
|
21
|
+
typeof: "object",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: "string",
|
|
25
|
+
typeof: "string",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: "undefined",
|
|
29
|
+
typeof: "undefined",
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
13
33
|
filterFunction = code `${this.reusables.snippets.filterIdentifier}`;
|
|
14
34
|
filterType = code `${this.reusables.snippets.IdentifierFilter}`;
|
|
15
35
|
parseFunction = code `${this.reusables.snippets.parseIdentifier};`;
|
|
@@ -32,7 +52,7 @@ export class IdentifierType extends AbstractIdentifierType {
|
|
|
32
52
|
const discriminantProperty = parameters?.includeDiscriminantProperty
|
|
33
53
|
? `, readonly termType: "BlankNode" | "NamedNode"`
|
|
34
54
|
: "";
|
|
35
|
-
return new
|
|
55
|
+
return new AbstractIdentifierType.JsonType(code `{ readonly "@id": string${discriminantProperty} }`);
|
|
36
56
|
}
|
|
37
57
|
jsonSchema({ includeDiscriminantProperty, }) {
|
|
38
58
|
const discriminantProperty = includeDiscriminantProperty
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { Literal } from "@rdfjs/types";
|
|
2
2
|
import { AbstractNumericType } from "./AbstractNumericType.js";
|
|
3
3
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
4
4
|
export declare class IntType extends AbstractNumericType<number> {
|
|
5
5
|
readonly kind = "IntType";
|
|
6
|
-
readonly typeofs:
|
|
6
|
+
readonly typeofs: "number"[];
|
|
7
7
|
get graphqlType(): import("./AbstractType.js").AbstractType.GraphqlType;
|
|
8
|
+
literalExpression(literal: Literal | number): Code;
|
|
8
9
|
protected fromRdfResourceValueExpression({ variables, }: Parameters<AbstractNumericType<number>["fromRdfResourceValueExpression"]>[0]): Code;
|
|
9
|
-
protected literalOf(value: number): string;
|
|
10
10
|
}
|
|
11
11
|
//# sourceMappingURL=IntType.d.ts.map
|
|
@@ -4,22 +4,22 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import {
|
|
7
|
+
import { LiteralDecoder } from "@rdfx/literal";
|
|
8
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
12
|
kind = "IntType";
|
|
13
|
-
typeofs =
|
|
13
|
+
typeofs = ["number"];
|
|
14
14
|
get graphqlType() {
|
|
15
15
|
return new AbstractNumericType.GraphqlType(code `${this.reusables.imports.GraphQLInt}`, this.reusables);
|
|
16
16
|
}
|
|
17
|
+
literalExpression(literal) {
|
|
18
|
+
return code `${typeof literal === "number" ? literal : LiteralDecoder.decodeIntLiteral(literal).unsafeCoerce()}`;
|
|
19
|
+
}
|
|
17
20
|
fromRdfResourceValueExpression({ variables, }) {
|
|
18
21
|
return code `${variables.value}.toInt(${this.primitiveIn.length > 0 ? `${JSON.stringify(this.primitiveIn)} as const` : ""})`;
|
|
19
22
|
}
|
|
20
|
-
literalOf(value) {
|
|
21
|
-
return value.toString();
|
|
22
|
-
}
|
|
23
23
|
}
|
|
24
24
|
__decorate([
|
|
25
25
|
Memoize()
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NamedNode } from "@rdfjs/types";
|
|
2
2
|
import { AbstractIdentifierType } from "./AbstractIdentifierType.js";
|
|
3
|
-
import { AbstractTermType } from "./AbstractTermType.js";
|
|
4
3
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
5
4
|
export declare class IriType extends AbstractIdentifierType<NamedNode> {
|
|
6
5
|
readonly filterFunction: Code;
|
|
@@ -9,16 +8,22 @@ export declare class IriType extends AbstractIdentifierType<NamedNode> {
|
|
|
9
8
|
readonly nodeKinds: ReadonlySet<"IRI">;
|
|
10
9
|
readonly schemaType: Code;
|
|
11
10
|
readonly valueSparqlWherePatternsFunction: Code;
|
|
12
|
-
get
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
11
|
+
get conversionFunction(): {
|
|
12
|
+
code: Code;
|
|
13
|
+
sourceTypes: ({
|
|
14
|
+
name: Code;
|
|
15
|
+
typeof: "string";
|
|
16
|
+
} | {
|
|
17
|
+
name: Code;
|
|
18
|
+
typeof: "object";
|
|
19
|
+
})[];
|
|
17
20
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
get name(): Code;
|
|
22
|
+
get parseFunction(): Code;
|
|
23
|
+
fromJsonExpression({ variables, }: Parameters<AbstractIdentifierType<NamedNode>["fromJsonExpression"]>[0]): Code;
|
|
24
|
+
jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractIdentifierType<NamedNode>["jsonSchema"]>[0]): Code;
|
|
25
|
+
jsonType(parameters?: Parameters<AbstractIdentifierType<NamedNode>["jsonType"]>[0]): AbstractIdentifierType.JsonType;
|
|
26
|
+
toJsonExpression({ includeDiscriminantProperty, variables, }: Parameters<AbstractIdentifierType<NamedNode>["toJsonExpression"]>[0]): Code;
|
|
27
|
+
protected fromRdfExpressionChain({ variables, }: Parameters<AbstractIdentifierType<NamedNode>["fromRdfExpressionChain"]>[0]): ReturnType<AbstractIdentifierType<NamedNode>["fromRdfExpressionChain"]>;
|
|
23
28
|
}
|
|
24
29
|
//# sourceMappingURL=IriType.d.ts.map
|
|
@@ -6,8 +6,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import { Memoize } from "typescript-memoize";
|
|
8
8
|
import { AbstractIdentifierType } from "./AbstractIdentifierType.js";
|
|
9
|
-
import {
|
|
10
|
-
import { arrayOf, code, joinCode } from "./ts-poet-wrapper.js";
|
|
9
|
+
import { arrayOf, code, joinCode, literalOf, } from "./ts-poet-wrapper.js";
|
|
11
10
|
export class IriType extends AbstractIdentifierType {
|
|
12
11
|
filterFunction = code `${this.reusables.snippets.filterIri}`;
|
|
13
12
|
filterType = code `${this.reusables.snippets.IriFilter}`;
|
|
@@ -15,44 +14,41 @@ export class IriType extends AbstractIdentifierType {
|
|
|
15
14
|
nodeKinds = nodeKinds;
|
|
16
15
|
schemaType = code `${this.reusables.snippets.IriSchema}`;
|
|
17
16
|
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.iriSparqlWherePatterns}`;
|
|
18
|
-
get
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
return
|
|
17
|
+
get conversionFunction() {
|
|
18
|
+
const IriT = this.in_.length > 0
|
|
19
|
+
? code `${joinCode(this.in_.map((iri) => code `${literalOf(iri.value)}`), { on: "| " })}`
|
|
20
|
+
: code `string`;
|
|
21
|
+
return {
|
|
22
|
+
code: code `${this.reusables.snippets.convertToIri}<${IriT}>`,
|
|
23
|
+
sourceTypes: [
|
|
24
|
+
{
|
|
25
|
+
name: IriT,
|
|
26
|
+
typeof: "string",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
name: this.name,
|
|
30
|
+
typeof: "object",
|
|
31
|
+
},
|
|
32
|
+
],
|
|
33
|
+
};
|
|
23
34
|
}
|
|
24
35
|
get name() {
|
|
25
36
|
if (this.in_.length > 0) {
|
|
26
37
|
// Treat sh:in as a union of the IRIs
|
|
27
38
|
// rdfjs.NamedNode<"http://example.com/1" | "http://example.com/2">
|
|
28
|
-
return code `${this.reusables.imports.NamedNode}<${this.in_
|
|
29
|
-
.map((iri) => `"${iri.value}"`)
|
|
30
|
-
.join(" | ")}>`;
|
|
39
|
+
return code `${this.reusables.imports.NamedNode}<${joinCode(this.in_.map((iri) => code `${literalOf(iri.value)}`), { on: "| " })}>`;
|
|
31
40
|
}
|
|
32
41
|
return code `${this.reusables.imports.NamedNode}`;
|
|
33
42
|
}
|
|
34
|
-
get
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
: undefined,
|
|
40
|
-
};
|
|
43
|
+
get parseFunction() {
|
|
44
|
+
if (this.in_.length > 0) {
|
|
45
|
+
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.name});`))} default: return ${this.reusables.imports.Left}(new Error("expected NamedNode identifier to be one of ${this.in_.map((iri) => iri.value).join(" ")}")); } })`;
|
|
46
|
+
}
|
|
47
|
+
return code `${this.reusables.snippets.parseIri}`;
|
|
41
48
|
}
|
|
42
49
|
fromJsonExpression({ variables, }) {
|
|
43
50
|
return code `${this.reusables.imports.dataFactory}.namedNode(${variables.value}["@id"])`;
|
|
44
51
|
}
|
|
45
|
-
jsonType(parameters) {
|
|
46
|
-
const discriminantProperty = parameters?.includeDiscriminantProperty
|
|
47
|
-
? `, readonly termType: "NamedNode"`
|
|
48
|
-
: "";
|
|
49
|
-
if (this.in_.length > 0) {
|
|
50
|
-
// Treat sh:in as a union of the IRIs
|
|
51
|
-
// rdfjs.NamedNode<"http://example.com/1" | "http://example.com/2">
|
|
52
|
-
return new AbstractTermType.JsonType(code `{ readonly "@id": ${this.in_.map((iri) => `"${iri.value}"`).join(" | ")}${discriminantProperty} }`);
|
|
53
|
-
}
|
|
54
|
-
return new AbstractTermType.JsonType(code `{ readonly "@id": string${discriminantProperty} }`);
|
|
55
|
-
}
|
|
56
52
|
jsonSchema({ includeDiscriminantProperty, }) {
|
|
57
53
|
let idSchema;
|
|
58
54
|
if (this.in_.length > 0) {
|
|
@@ -68,6 +64,17 @@ export class IriType extends AbstractIdentifierType {
|
|
|
68
64
|
: "";
|
|
69
65
|
return code `${this.reusables.imports.z}.object({ "@id": ${idSchema}${discriminantProperty} })`;
|
|
70
66
|
}
|
|
67
|
+
jsonType(parameters) {
|
|
68
|
+
const discriminantProperty = parameters?.includeDiscriminantProperty
|
|
69
|
+
? `, readonly termType: "NamedNode"`
|
|
70
|
+
: "";
|
|
71
|
+
if (this.in_.length > 0) {
|
|
72
|
+
// Treat sh:in as a union of the IRIs
|
|
73
|
+
// rdfjs.NamedNode<"http://example.com/1" | "http://example.com/2">
|
|
74
|
+
return new AbstractIdentifierType.JsonType(code `{ readonly "@id": ${this.in_.map((iri) => `"${iri.value}"`).join(" | ")}${discriminantProperty} }`);
|
|
75
|
+
}
|
|
76
|
+
return new AbstractIdentifierType.JsonType(code `{ readonly "@id": string${discriminantProperty} }`);
|
|
77
|
+
}
|
|
71
78
|
toJsonExpression({ includeDiscriminantProperty, variables, }) {
|
|
72
79
|
const discriminantProperty = includeDiscriminantProperty
|
|
73
80
|
? code `, termType: ${variables.value}.termType`
|
|
@@ -85,10 +92,13 @@ export class IriType extends AbstractIdentifierType {
|
|
|
85
92
|
}
|
|
86
93
|
__decorate([
|
|
87
94
|
Memoize()
|
|
88
|
-
], IriType.prototype, "
|
|
95
|
+
], IriType.prototype, "conversionFunction", null);
|
|
89
96
|
__decorate([
|
|
90
97
|
Memoize()
|
|
91
98
|
], IriType.prototype, "name", null);
|
|
99
|
+
__decorate([
|
|
100
|
+
Memoize()
|
|
101
|
+
], IriType.prototype, "parseFunction", null);
|
|
92
102
|
__decorate([
|
|
93
103
|
Memoize()
|
|
94
104
|
], IriType.prototype, "jsonType", null);
|
|
@@ -8,6 +8,7 @@ declare const Super: (abstract new ({ partialType, resolveType, ...superParamete
|
|
|
8
8
|
resolveType: OptionType<AbstractLazyObjectType.ObjectTypeConstraint>;
|
|
9
9
|
} & {
|
|
10
10
|
comment: Maybe<string>;
|
|
11
|
+
configuration: import("./TsGenerator.js").TsGenerator.Configuration;
|
|
11
12
|
label: Maybe<string>;
|
|
12
13
|
logger: import("ts-log").Logger;
|
|
13
14
|
reusables: import("./Reusables.js").Reusables;
|
|
@@ -18,7 +19,7 @@ declare const Super: (abstract new ({ partialType, resolveType, ...superParamete
|
|
|
18
19
|
export declare class LazyObjectOptionType extends Super {
|
|
19
20
|
readonly graphqlArgs: Super["graphqlArgs"];
|
|
20
21
|
readonly kind = "LazyObjectOptionType";
|
|
21
|
-
get
|
|
22
|
+
get conversionFunction(): AbstractLazyObjectType.ConversionFunction;
|
|
22
23
|
protected get runtimeClass(): {
|
|
23
24
|
name: Code;
|
|
24
25
|
partialPropertyName: string;
|
|
@@ -12,49 +12,28 @@ const Super = (AbstractLazyObjectType);
|
|
|
12
12
|
export class LazyObjectOptionType extends Super {
|
|
13
13
|
graphqlArgs = Maybe.empty();
|
|
14
14
|
kind = "LazyObjectOptionType";
|
|
15
|
-
get
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
conversions.push({
|
|
38
|
-
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${value}${maybeMap}, resolver: async () => ${this.reusables.imports.Right}((${value} as ${this.reusables.imports.Maybe}<${this.resolveType.itemType.name}>).unsafeCoerce()) })`,
|
|
39
|
-
sourceTypeCheckExpression: (value) => code `${this.reusables.imports.Maybe}.isMaybe(${value})`,
|
|
40
|
-
sourceTypeName: code `${this.reusables.imports.Maybe}<${this.resolveType.itemType.name}>`,
|
|
41
|
-
sourceTypeof: "object",
|
|
42
|
-
}, {
|
|
43
|
-
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${this.reusables.imports.Maybe}.of(${value})${maybeMap}, resolver: async () => ${this.reusables.imports.Right}(${value} as ${this.resolveType.itemType.name}) })`,
|
|
44
|
-
// Don't check instanceof value since the NamedObjectUnionType may be an interface
|
|
45
|
-
// Rely on the fact that this will be the last type check on an object
|
|
46
|
-
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
|
|
47
|
-
sourceTypeName: this.resolveType.itemType.name,
|
|
48
|
-
sourceTypeof: "object",
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
conversions.push({
|
|
52
|
-
conversionExpression: () => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ${this.reusables.imports.Maybe}.empty(), resolver: async () => { throw new Error("should never be called"); } })`,
|
|
53
|
-
sourceTypeCheckExpression: (value) => code `${value} === undefined`,
|
|
54
|
-
sourceTypeName: code `undefined`,
|
|
55
|
-
sourceTypeof: "undefined",
|
|
56
|
-
});
|
|
57
|
-
return conversions;
|
|
15
|
+
get conversionFunction() {
|
|
16
|
+
return {
|
|
17
|
+
code: code `${this.reusables.snippets.convertToLazyObjectOption}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.name}, ${this.resolveType.itemType.name}>(${this.resolveToPartialFunction({ partialType: this.partialType.itemType, resolveType: this.resolveType.itemType })})`,
|
|
18
|
+
sourceTypes: [
|
|
19
|
+
{
|
|
20
|
+
name: this.name,
|
|
21
|
+
typeof: "object",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: this.resolveType.name,
|
|
25
|
+
typeof: "object",
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: this.resolveType.itemType.name,
|
|
29
|
+
typeof: "object",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "undefined",
|
|
33
|
+
typeof: "undefined",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
};
|
|
58
37
|
}
|
|
59
38
|
get runtimeClass() {
|
|
60
39
|
return {
|
|
@@ -76,7 +55,7 @@ export class LazyObjectOptionType extends Super {
|
|
|
76
55
|
}
|
|
77
56
|
__decorate([
|
|
78
57
|
Memoize()
|
|
79
|
-
], LazyObjectOptionType.prototype, "
|
|
58
|
+
], LazyObjectOptionType.prototype, "conversionFunction", null);
|
|
80
59
|
__decorate([
|
|
81
60
|
Memoize()
|
|
82
61
|
], LazyObjectOptionType.prototype, "runtimeClass", null);
|
|
@@ -4,7 +4,7 @@ import { type Code } from "./ts-poet-wrapper.js";
|
|
|
4
4
|
export declare class LazyObjectSetType extends AbstractLazyObjectType<SetType<AbstractLazyObjectType.ObjectTypeConstraint>, SetType<AbstractLazyObjectType.ObjectTypeConstraint>> {
|
|
5
5
|
readonly graphqlArgs: Super["graphqlArgs"];
|
|
6
6
|
readonly kind = "LazyObjectSetType";
|
|
7
|
-
get
|
|
7
|
+
get conversionFunction(): AbstractLazyObjectType.ConversionFunction;
|
|
8
8
|
protected get runtimeClass(): {
|
|
9
9
|
name: Code;
|
|
10
10
|
partialPropertyName: string;
|
|
@@ -18,34 +18,24 @@ export class LazyObjectSetType extends AbstractLazyObjectType {
|
|
|
18
18
|
},
|
|
19
19
|
});
|
|
20
20
|
kind = "LazyObjectSetType";
|
|
21
|
-
get
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
sourceTypeof: "object",
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
conversions.push({
|
|
43
|
-
conversionExpression: () => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: [], resolver: async () => { throw new Error("should never be called"); } })`,
|
|
44
|
-
sourceTypeCheckExpression: (value) => code `${value} === undefined`,
|
|
45
|
-
sourceTypeName: code `undefined`,
|
|
46
|
-
sourceTypeof: "undefined",
|
|
47
|
-
});
|
|
48
|
-
return conversions;
|
|
21
|
+
get conversionFunction() {
|
|
22
|
+
return {
|
|
23
|
+
code: code `${this.reusables.snippets.convertToLazyObjectSet}<${this.resolveType.itemType.identifierTypeAlias}, ${this.partialType.itemType.name}, ${this.resolveType.itemType.name}>(${this.resolveToPartialFunction({ partialType: this.partialType.itemType, resolveType: this.resolveType.itemType })})`,
|
|
24
|
+
sourceTypes: [
|
|
25
|
+
{
|
|
26
|
+
name: this.name,
|
|
27
|
+
typeof: "object",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: this.resolveType.name,
|
|
31
|
+
typeof: "object",
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
name: "undefined",
|
|
35
|
+
typeof: "undefined",
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
};
|
|
49
39
|
}
|
|
50
40
|
get runtimeClass() {
|
|
51
41
|
return {
|
|
@@ -67,5 +57,5 @@ export class LazyObjectSetType extends AbstractLazyObjectType {
|
|
|
67
57
|
}
|
|
68
58
|
__decorate([
|
|
69
59
|
Memoize()
|
|
70
|
-
], LazyObjectSetType.prototype, "
|
|
60
|
+
], LazyObjectSetType.prototype, "conversionFunction", null);
|
|
71
61
|
//# sourceMappingURL=LazyObjectSetType.js.map
|
|
@@ -3,7 +3,7 @@ import { type Code } from "./ts-poet-wrapper.js";
|
|
|
3
3
|
export declare class LazyObjectType extends AbstractLazyObjectType<AbstractLazyObjectType.ObjectTypeConstraint, AbstractLazyObjectType.ObjectTypeConstraint> {
|
|
4
4
|
readonly graphqlArgs: Super["graphqlArgs"];
|
|
5
5
|
readonly kind = "LazyObjectType";
|
|
6
|
-
get
|
|
6
|
+
get conversionFunction(): AbstractLazyObjectType.ConversionFunction;
|
|
7
7
|
protected get runtimeClass(): {
|
|
8
8
|
name: Code;
|
|
9
9
|
partialPropertyName: string;
|
|
@@ -11,31 +11,20 @@ import { code } from "./ts-poet-wrapper.js";
|
|
|
11
11
|
export class LazyObjectType extends AbstractLazyObjectType {
|
|
12
12
|
graphqlArgs = Maybe.empty();
|
|
13
13
|
kind = "LazyObjectType";
|
|
14
|
-
get
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.resolveType.members.length === this.partialType.members.length) {
|
|
29
|
-
conversions.push({
|
|
30
|
-
conversionExpression: (value) => code `new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}: ((object: ${this.resolveType.name}) => { ${this.resolvedNamedObjectUnionTypeToPartialNamedObjectUnionTypeConversion({ resolvedNamedObjectUnionType: this.resolveType, partialNamedObjectUnionType: this.partialType, variables: { resolvedObjectUnion: code `object` } })} })(${value}), resolver: async () => ${this.reusables.imports.Right}(${value} as ${this.resolveType.name}) })`,
|
|
31
|
-
// Don't check instanceof value since the NamedObjectUnionType may be an interface
|
|
32
|
-
// Rely on the fact that this will be the last type check on an object
|
|
33
|
-
sourceTypeCheckExpression: (value) => code `typeof ${value} === "object"`,
|
|
34
|
-
sourceTypeName: this.resolveType.name,
|
|
35
|
-
sourceTypeof: "object",
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
return conversions;
|
|
14
|
+
get conversionFunction() {
|
|
15
|
+
return {
|
|
16
|
+
code: code `${this.reusables.snippets.convertToLazyObject}<${this.resolveType.identifierTypeAlias}, ${this.partialType.name}, ${this.resolveType.name}>(${this.resolveToPartialFunction({ partialType: this.partialType, resolveType: this.resolveType })})`,
|
|
17
|
+
sourceTypes: [
|
|
18
|
+
{
|
|
19
|
+
name: this.name,
|
|
20
|
+
typeof: "object",
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
name: this.resolveType.name,
|
|
24
|
+
typeof: "object",
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
};
|
|
39
28
|
}
|
|
40
29
|
get runtimeClass() {
|
|
41
30
|
return {
|
|
@@ -55,6 +44,9 @@ export class LazyObjectType extends AbstractLazyObjectType {
|
|
|
55
44
|
return code `${variables.value}.resolve().then(either => either.unsafeCoerce())`;
|
|
56
45
|
}
|
|
57
46
|
}
|
|
47
|
+
__decorate([
|
|
48
|
+
Memoize()
|
|
49
|
+
], LazyObjectType.prototype, "conversionFunction", null);
|
|
58
50
|
__decorate([
|
|
59
51
|
Memoize()
|
|
60
52
|
], LazyObjectType.prototype, "runtimeClass", null);
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
+
import type { Literal } from "@rdfjs/types";
|
|
1
2
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
2
3
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
3
4
|
export declare class LiteralType extends AbstractLiteralType {
|
|
5
|
+
readonly name: Code;
|
|
6
|
+
readonly conversionFunction: AbstractLiteralType.ConversionFunction;
|
|
4
7
|
readonly filterFunction: Code;
|
|
5
8
|
readonly filterType: Code;
|
|
6
9
|
readonly kind = "LiteralType";
|
|
7
|
-
readonly name: Code;
|
|
8
10
|
readonly schemaType: Code;
|
|
9
11
|
readonly valueSparqlWherePatternsFunction: Code;
|
|
10
12
|
get graphqlType(): AbstractLiteralType.GraphqlType;
|
|
11
13
|
fromJsonExpression({ variables, }: Parameters<AbstractLiteralType["fromJsonExpression"]>[0]): Code;
|
|
12
14
|
graphqlResolveExpression(_parameters: Parameters<AbstractLiteralType["graphqlResolveExpression"]>[0]): Code;
|
|
13
|
-
hashStatements({ depth, variables, }: Parameters<AbstractLiteralType["hashStatements"]>[0]): readonly Code[];
|
|
14
|
-
jsonType(parameters?: Parameters<AbstractLiteralType["jsonType"]>[0]): AbstractLiteralType.JsonType;
|
|
15
15
|
jsonSchema({ includeDiscriminantProperty, }: Parameters<AbstractLiteralType["jsonSchema"]>[0]): Code;
|
|
16
|
+
jsonType(parameters?: Parameters<AbstractLiteralType["jsonType"]>[0]): AbstractLiteralType.JsonType;
|
|
17
|
+
literalExpression(literal: Literal): Code;
|
|
16
18
|
toJsonExpression({ includeDiscriminantProperty, variables, }: Parameters<AbstractLiteralType["toJsonExpression"]>[0]): Code;
|
|
17
19
|
}
|
|
18
20
|
//# sourceMappingURL=LiteralType.d.ts.map
|
|
@@ -2,10 +2,27 @@ import { xsd } from "@tpluscode/rdf-ns-builders";
|
|
|
2
2
|
import { AbstractLiteralType } from "./AbstractLiteralType.js";
|
|
3
3
|
import { code } from "./ts-poet-wrapper.js";
|
|
4
4
|
export class LiteralType extends AbstractLiteralType {
|
|
5
|
+
name = code `${this.reusables.imports.Literal}`;
|
|
6
|
+
conversionFunction = {
|
|
7
|
+
code: code `${this.reusables.snippets.convertToLiteral}`,
|
|
8
|
+
sourceTypes: [
|
|
9
|
+
...["bigint", "boolean", "number", "string"].map((typeof_) => ({
|
|
10
|
+
name: typeof_,
|
|
11
|
+
typeof: typeof_,
|
|
12
|
+
})),
|
|
13
|
+
{
|
|
14
|
+
name: "Date",
|
|
15
|
+
typeof: "object",
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
name: code `${this.reusables.imports.Literal}`,
|
|
19
|
+
typeof: "object",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
};
|
|
5
23
|
filterFunction = code `${this.reusables.snippets.filterLiteral}`;
|
|
6
24
|
filterType = code `${this.reusables.snippets.LiteralFilter}`;
|
|
7
25
|
kind = "LiteralType";
|
|
8
|
-
name = code `${this.reusables.imports.Literal}`;
|
|
9
26
|
schemaType = code `${this.reusables.snippets.LiteralSchema}`;
|
|
10
27
|
valueSparqlWherePatternsFunction = code `${this.reusables.snippets.literalSparqlWherePatterns}`;
|
|
11
28
|
get graphqlType() {
|
|
@@ -17,12 +34,11 @@ export class LiteralType extends AbstractLiteralType {
|
|
|
17
34
|
graphqlResolveExpression(_parameters) {
|
|
18
35
|
throw new Error("not implemented");
|
|
19
36
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
];
|
|
37
|
+
jsonSchema({ includeDiscriminantProperty, }) {
|
|
38
|
+
const discriminantProperty = includeDiscriminantProperty
|
|
39
|
+
? code `, termType: ${this.reusables.imports.z}.literal("Literal")`
|
|
40
|
+
: "";
|
|
41
|
+
return code `${this.reusables.imports.z}.object({ "@language": ${this.reusables.imports.z}.string().optional()${discriminantProperty}, "@type": ${this.reusables.imports.z}.string().optional(), "@value": ${this.reusables.imports.z}.string() })`;
|
|
26
42
|
}
|
|
27
43
|
jsonType(parameters) {
|
|
28
44
|
const discriminantProperty = parameters?.includeDiscriminantProperty
|
|
@@ -30,11 +46,8 @@ export class LiteralType extends AbstractLiteralType {
|
|
|
30
46
|
: "";
|
|
31
47
|
return new AbstractLiteralType.JsonType(code `{ readonly "@language"?: string${discriminantProperty}, readonly "@type"?: string, readonly "@value": string }`);
|
|
32
48
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
? code `, termType: ${this.reusables.imports.z}.literal("Literal")`
|
|
36
|
-
: "";
|
|
37
|
-
return code `${this.reusables.imports.z}.object({ "@language": ${this.reusables.imports.z}.string().optional()${discriminantProperty}, "@type": ${this.reusables.imports.z}.string().optional(), "@value": ${this.reusables.imports.z}.string() })`;
|
|
49
|
+
literalExpression(literal) {
|
|
50
|
+
return this.rdfjsTermExpression(literal);
|
|
38
51
|
}
|
|
39
52
|
toJsonExpression({ includeDiscriminantProperty, variables, }) {
|
|
40
53
|
return code `{ "@language": ${variables.value}.language.length > 0 ? ${variables.value}.language : undefined${includeDiscriminantProperty ? `, "termType": "Literal" as const` : ""}, "@type": ${variables.value}.datatype.value !== "${xsd.string.value}" ? ${variables.value}.datatype.value : undefined, "@value": ${variables.value}.value }`;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { NamedNode } from "@rdfjs/types";
|
|
2
|
-
import { Maybe
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
3
|
import { DiscriminantProperty as _DiscriminantProperty } from "./_NamedObjectType/DiscriminantProperty.js";
|
|
4
4
|
import { IdentifierProperty as _IdentifierProperty } from "./_NamedObjectType/IdentifierProperty.js";
|
|
5
5
|
import type { Property as _Property } from "./_NamedObjectType/Property.js";
|
|
@@ -8,13 +8,11 @@ import { AbstractType } from "./AbstractType.js";
|
|
|
8
8
|
import type { BlankNodeType } from "./BlankNodeType.js";
|
|
9
9
|
import type { IdentifierType } from "./IdentifierType.js";
|
|
10
10
|
import type { IriType } from "./IriType.js";
|
|
11
|
-
import type { TsFeature } from "./TsFeature.js";
|
|
12
11
|
import type { Type } from "./Type.js";
|
|
13
12
|
import { type Code } from "./ts-poet-wrapper.js";
|
|
14
13
|
export declare class NamedObjectType extends AbstractType {
|
|
15
14
|
protected readonly toRdfTypes: readonly NamedNode[];
|
|
16
15
|
readonly extern: boolean;
|
|
17
|
-
readonly features: ReadonlySet<TsFeature>;
|
|
18
16
|
readonly fromRdfType: Maybe<NamedNode>;
|
|
19
17
|
readonly graphqlArgs: AbstractType["graphqlArgs"];
|
|
20
18
|
readonly identifierType: BlankNodeType | IdentifierType | IriType;
|
|
@@ -22,11 +20,10 @@ export declare class NamedObjectType extends AbstractType {
|
|
|
22
20
|
readonly name: string;
|
|
23
21
|
readonly recursive: boolean;
|
|
24
22
|
readonly synthetic: boolean;
|
|
25
|
-
readonly typeofs:
|
|
26
|
-
constructor({ extern,
|
|
23
|
+
readonly typeofs: "object"[];
|
|
24
|
+
constructor({ extern, fromRdfType, identifierType, lazyAncestorObjectTypes, lazyChildObjectTypes, lazyDescendantObjectTypes, lazyDiscriminantProperty, lazyParentObjectTypes, lazyProperties, name, recursive, synthetic, toRdfTypes, ...superParameters }: {
|
|
27
25
|
comment: Maybe<string>;
|
|
28
26
|
extern: boolean;
|
|
29
|
-
features: ReadonlySet<TsFeature>;
|
|
30
27
|
fromRdfType: Maybe<NamedNode>;
|
|
31
28
|
identifierType: BlankNodeType | IdentifierType | IriType;
|
|
32
29
|
label: Maybe<string>;
|
|
@@ -44,7 +41,7 @@ export declare class NamedObjectType extends AbstractType {
|
|
|
44
41
|
get _discriminantProperty(): NamedObjectType.DiscriminantProperty;
|
|
45
42
|
get ancestorObjectTypes(): readonly NamedObjectType[];
|
|
46
43
|
get childObjectTypes(): readonly NamedObjectType[];
|
|
47
|
-
get
|
|
44
|
+
get conversionFunction(): AbstractType.ConversionFunction;
|
|
48
45
|
get declaration(): Maybe<Code>;
|
|
49
46
|
get descendantFromRdfTypeVariables(): readonly Code[];
|
|
50
47
|
get descendantFromRdfTypes(): readonly NamedNode[];
|
|
@@ -56,6 +53,7 @@ export declare class NamedObjectType extends AbstractType {
|
|
|
56
53
|
get filterType(): Code;
|
|
57
54
|
get fromRdfTypeVariable(): Maybe<Code>;
|
|
58
55
|
get graphqlType(): AbstractType.GraphqlType;
|
|
56
|
+
get hashFunction(): Code;
|
|
59
57
|
get identifierTypeAlias(): Code;
|
|
60
58
|
get mutable(): boolean;
|
|
61
59
|
get objectSetMethodNames(): NamedObjectType.ObjectSetMethodNames;
|
|
@@ -75,13 +73,12 @@ export declare class NamedObjectType extends AbstractType {
|
|
|
75
73
|
value: Code;
|
|
76
74
|
};
|
|
77
75
|
}): Code;
|
|
78
|
-
hashStatements({ variables, }: Parameters<AbstractType["hashStatements"]>[0]): readonly Code[];
|
|
79
76
|
jsonSchema({ context, }: Parameters<AbstractType["jsonSchema"]>[0]): Code;
|
|
80
77
|
jsonType(): AbstractType.JsonType;
|
|
81
78
|
jsonUiSchemaElement({ variables, }: Parameters<AbstractType["jsonUiSchemaElement"]>[0]): Maybe<Code>;
|
|
82
79
|
toJsonExpression({ variables, }: Parameters<AbstractType["toJsonExpression"]>[0]): Code;
|
|
83
|
-
toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
|
|
84
80
|
toRdfResourceValuesExpression({ variables, }: Parameters<AbstractType["toRdfResourceValuesExpression"]>[0]): Code;
|
|
81
|
+
toStringExpression({ variables, }: Parameters<AbstractType["toStringExpression"]>[0]): Code;
|
|
85
82
|
private readonly lazyAncestorObjectTypes;
|
|
86
83
|
private readonly lazyChildObjectTypes;
|
|
87
84
|
private readonly lazyDescendantObjectTypes;
|