@shaclmate/compiler 2.0.22 → 2.0.24
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 +6 -5
- package/dist/ShapesGraphToAstTransformer.js +61 -17
- package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.d.ts +2 -0
- package/dist/_ShapesGraphToAstTransformer/InheritableShapeConstraints.js +2 -0
- package/dist/_ShapesGraphToAstTransformer/ShapeStack.d.ts +15 -0
- package/dist/_ShapesGraphToAstTransformer/ShapeStack.js +51 -0
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.d.ts +13 -0
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.js +51 -0
- package/dist/_ShapesGraphToAstTransformer/index.d.ts +5 -5
- package/dist/_ShapesGraphToAstTransformer/index.js +5 -5
- package/dist/_ShapesGraphToAstTransformer/shapeAstName.js +53 -12
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.d.ts +5 -0
- package/dist/_ShapesGraphToAstTransformer/transformNodeShapeToAstType.js +130 -54
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +175 -5
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstCompositeType.js +185 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstIdentifierType.js +32 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.d.ts +10 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstLiteralType.js +46 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.d.ts +12 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstTermType.js +24 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.d.ts +13 -0
- package/dist/_ShapesGraphToAstTransformer/transformShapeToAstType.js +14 -0
- package/dist/ast/Ast.d.ts +0 -1
- package/dist/ast/Curie.d.ts +14 -0
- package/dist/ast/Curie.js +21 -0
- package/dist/ast/IdentifierType.d.ts +3 -2
- package/dist/ast/ListType.d.ts +2 -1
- package/dist/ast/LiteralType.d.ts +1 -1
- package/dist/ast/Name.d.ts +40 -5
- package/dist/ast/ObjectCompositeType.d.ts +11 -0
- package/dist/ast/ObjectType.d.ts +18 -13
- package/dist/ast/ObjectUnionType.d.ts +0 -11
- package/dist/ast/OptionType.d.ts +2 -4
- package/dist/ast/SetType.d.ts +2 -7
- package/dist/ast/TermType.d.ts +12 -4
- package/dist/ast/Type.d.ts +1 -1
- package/dist/ast/index.d.ts +1 -0
- package/dist/ast/index.js +1 -0
- package/dist/enums/TsFeature.d.ts +1 -4
- package/dist/enums/TsFeature.js +1 -15
- package/dist/generators/json/AstJsonGenerator.js +26 -4
- package/dist/generators/ts/BooleanType.d.ts +4 -2
- package/dist/generators/ts/BooleanType.js +12 -3
- package/dist/generators/ts/DateTimeType.d.ts +9 -8
- package/dist/generators/ts/DateTimeType.js +32 -8
- package/dist/generators/ts/DateType.d.ts +5 -2
- package/dist/generators/ts/DateType.js +15 -1
- package/dist/generators/ts/DeclaredType.d.ts +2 -2
- package/dist/generators/ts/DeclaredType.js +2 -2
- package/dist/generators/ts/FloatType.d.ts +6 -0
- package/dist/generators/ts/FloatType.js +18 -0
- package/dist/generators/ts/IdentifierType.d.ts +17 -7
- package/dist/generators/ts/IdentifierType.js +112 -18
- package/dist/generators/ts/Import.d.ts +2 -0
- package/dist/generators/ts/Import.js +10 -0
- package/dist/generators/ts/IntType.d.ts +6 -0
- package/dist/generators/ts/IntType.js +18 -0
- package/dist/generators/ts/ListType.d.ts +15 -12
- package/dist/generators/ts/ListType.js +113 -61
- package/dist/generators/ts/LiteralType.d.ts +17 -9
- package/dist/generators/ts/LiteralType.js +92 -17
- package/dist/generators/ts/NumberType.d.ts +3 -2
- package/dist/generators/ts/NumberType.js +8 -3
- package/dist/generators/ts/ObjectType.d.ts +65 -43
- package/dist/generators/ts/ObjectType.js +143 -123
- package/dist/generators/ts/ObjectUnionType.d.ts +50 -8
- package/dist/generators/ts/ObjectUnionType.js +303 -101
- package/dist/generators/ts/OptionType.d.ts +14 -10
- package/dist/generators/ts/OptionType.js +62 -34
- package/dist/generators/ts/PrimitiveType.d.ts +23 -5
- package/dist/generators/ts/PrimitiveType.js +34 -6
- package/dist/generators/ts/SetType.d.ts +17 -13
- package/dist/generators/ts/SetType.js +76 -44
- package/dist/generators/ts/SnippetDeclarations.d.ts +13 -8
- package/dist/generators/ts/SnippetDeclarations.js +226 -101
- package/dist/generators/ts/StringType.d.ts +4 -2
- package/dist/generators/ts/StringType.js +20 -8
- package/dist/generators/ts/TermType.d.ts +29 -33
- package/dist/generators/ts/TermType.js +89 -68
- package/dist/generators/ts/TsGenerator.d.ts +2 -1
- package/dist/generators/ts/TsGenerator.js +26 -12
- package/dist/generators/ts/Type.d.ts +100 -32
- package/dist/generators/ts/Type.js +58 -54
- package/dist/generators/ts/TypeFactory.d.ts +12 -5
- package/dist/generators/ts/TypeFactory.js +380 -226
- package/dist/generators/ts/UnionType.d.ts +14 -10
- package/dist/generators/ts/UnionType.js +319 -142
- package/dist/generators/ts/_ObjectType/EagerShaclProperty.d.ts +12 -0
- package/dist/generators/ts/_ObjectType/EagerShaclProperty.js +31 -0
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +13 -12
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +59 -46
- package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +20 -13
- package/dist/generators/ts/_ObjectType/IdentifierProperty.js +198 -140
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.d.ts +100 -0
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.js +315 -0
- package/dist/generators/ts/_ObjectType/Property.d.ts +47 -46
- package/dist/generators/ts/_ObjectType/Property.js +1 -10
- package/dist/generators/ts/_ObjectType/ShaclProperty.d.ts +25 -30
- package/dist/generators/ts/_ObjectType/ShaclProperty.js +120 -85
- package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.d.ts +21 -17
- package/dist/generators/ts/_ObjectType/TypeDiscriminatorProperty.js +61 -53
- package/dist/generators/ts/_ObjectType/classDeclaration.js +22 -17
- package/dist/generators/ts/_ObjectType/createFunctionDeclaration.js +26 -13
- package/dist/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +8 -5
- package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/fromRdfTypeVariableStatement.js +8 -5
- package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/graphqlTypeVariableStatement.js +49 -0
- package/dist/generators/ts/_ObjectType/hashFunctionOrMethodDeclarations.js +7 -8
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.d.ts +7 -0
- package/dist/generators/ts/_ObjectType/identifierTypeDeclarations.js +54 -0
- package/dist/generators/ts/_ObjectType/index.d.ts +9 -7
- package/dist/generators/ts/_ObjectType/index.js +9 -7
- package/dist/generators/ts/_ObjectType/interfaceDeclaration.js +1 -1
- package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/jsonFunctionDeclarations.js +189 -0
- package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/jsonTypeAliasDeclaration.js +28 -0
- package/dist/generators/ts/_ObjectType/objectSetMethodNames.d.ts +9 -0
- package/dist/generators/ts/_ObjectType/objectSetMethodNames.js +18 -0
- package/dist/generators/ts/_ObjectType/propertiesVariableStatement.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/propertiesVariableStatement.js +37 -0
- package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/rdfFunctionDeclarations.js +144 -0
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.js +6 -5
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.js +4 -3
- package/dist/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +109 -37
- package/dist/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +6 -6
- package/dist/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +33 -24
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +9 -0
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +86 -0
- package/dist/generators/ts/objectSetDeclarations.d.ts +8 -0
- package/dist/generators/ts/objectSetDeclarations.js +59 -0
- package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +8 -0
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +46 -0
- package/dist/generators/ts/objectSetMethodSignatures.d.ts +11 -0
- package/dist/generators/ts/objectSetMethodSignatures.js +52 -0
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +8 -0
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +393 -0
- package/dist/generators/ts/rdfjsTermExpression.d.ts +3 -0
- package/dist/generators/ts/rdfjsTermExpression.js +57 -0
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +8 -0
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +415 -0
- package/dist/generators/ts/syntheticNamePrefix.d.ts +2 -0
- package/dist/generators/ts/syntheticNamePrefix.js +2 -0
- package/dist/generators/ts/tsName.js +27 -13
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +10 -0
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +19 -0
- package/dist/input/NodeShape.d.ts +6 -8
- package/dist/input/NodeShape.js +20 -44
- package/dist/input/Ontology.d.ts +0 -3
- package/dist/input/Ontology.js +0 -9
- package/dist/input/PropertyPath.d.ts +5 -5
- package/dist/input/PropertyPath.js +14 -24
- package/dist/input/PropertyShape.d.ts +3 -1
- package/dist/input/PropertyShape.js +8 -2
- package/dist/input/ShapesGraph.js +4 -8
- package/dist/input/generated.d.ts +967 -107
- package/dist/input/generated.js +2548 -1046
- package/dist/input/tsFeatures.d.ts +3 -2
- package/dist/input/tsFeatures.js +44 -27
- package/package.json +18 -16
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.d.ts +0 -13
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.js +0 -200
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.d.ts +0 -12
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.js +0 -29
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.d.ts +0 -12
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.js +0 -43
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.d.ts +0 -14
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.js +0 -21
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.d.ts +0 -16
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.js +0 -60
- package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/fromJsonFunctionDeclarations.js +0 -78
- package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/fromRdfFunctionDeclarations.js +0 -91
- package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonSchemaFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonUiSchemaFunctionDeclaration.js +0 -31
- package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/jsonZodSchemaFunctionDeclaration.js +0 -37
- package/dist/generators/ts/_ObjectType/rdfjsTermExpression.d.ts +0 -6
- package/dist/generators/ts/_ObjectType/rdfjsTermExpression.js +0 -17
- package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/toJsonFunctionDeclaration.js +0 -19
- package/dist/generators/ts/_ObjectType/toJsonReturnType.d.ts +0 -3
- package/dist/generators/ts/_ObjectType/toJsonReturnType.js +0 -17
- package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.d.ts +0 -5
- package/dist/generators/ts/_ObjectType/toRdfFunctionDeclaration.js +0 -19
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import type { BlankNode, NamedNode } from "@rdfjs/types";
|
|
2
|
+
import { type FunctionDeclarationStructure, type VariableStatementStructure } from "ts-morph";
|
|
2
3
|
import { TermType } from "./TermType.js";
|
|
3
|
-
import
|
|
4
|
-
export declare class IdentifierType extends TermType<BlankNode | NamedNode> {
|
|
4
|
+
import { Type } from "./Type.js";
|
|
5
|
+
export declare class IdentifierType extends TermType<NamedNode, BlankNode | NamedNode> {
|
|
5
6
|
readonly kind = "IdentifierType";
|
|
6
7
|
get conversions(): readonly Type.Conversion[];
|
|
8
|
+
get fromStringFunctionDeclaration(): FunctionDeclarationStructure;
|
|
9
|
+
get graphqlName(): Type.GraphqlName;
|
|
7
10
|
get isNamedNodeKind(): boolean;
|
|
8
|
-
get jsonName():
|
|
11
|
+
get jsonName(): Type.JsonName;
|
|
9
12
|
get name(): string;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
get toStringFunctionDeclaration(): VariableStatementStructure;
|
|
14
|
+
fromJsonExpression({ variables, }: Parameters<TermType<NamedNode, BlankNode | NamedNode>["fromJsonExpression"]>[0]): string;
|
|
15
|
+
protected fromRdfExpressionChain({ variables, }: Parameters<Type["fromRdfExpression"]>[0]): {
|
|
16
|
+
defaultValue?: string;
|
|
17
|
+
hasValues?: string;
|
|
18
|
+
languageIn?: string;
|
|
19
|
+
valueTo?: string;
|
|
20
|
+
};
|
|
21
|
+
graphqlResolveExpression({ variables: { value }, }: Parameters<Type["graphqlResolveExpression"]>[0]): string;
|
|
22
|
+
jsonZodSchema({ variables, }: Parameters<TermType<NamedNode, BlankNode | NamedNode>["jsonZodSchema"]>[0]): ReturnType<TermType<NamedNode, BlankNode | NamedNode>["jsonZodSchema"]>;
|
|
23
|
+
toJsonExpression({ variables, }: Parameters<TermType<NamedNode, BlankNode | NamedNode>["toJsonExpression"]>[0]): string;
|
|
14
24
|
}
|
|
15
25
|
//# sourceMappingURL=IdentifierType.d.ts.map
|
|
@@ -4,14 +4,16 @@ 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 { StructureKind, VariableDeclarationKind, } from "ts-morph";
|
|
7
8
|
import { Memoize } from "typescript-memoize";
|
|
8
9
|
import { TermType } from "./TermType.js";
|
|
10
|
+
import { Type } from "./Type.js";
|
|
9
11
|
export class IdentifierType extends TermType {
|
|
10
12
|
kind = "IdentifierType";
|
|
11
13
|
get conversions() {
|
|
12
14
|
return super.conversions.concat([
|
|
13
15
|
{
|
|
14
|
-
conversionExpression: (value) =>
|
|
16
|
+
conversionExpression: (value) => `dataFactory.namedNode(${value})`,
|
|
15
17
|
sourceTypeCheckExpression: (value) => `typeof ${value} === "string"`,
|
|
16
18
|
sourceTypeName: this.in_.length > 0
|
|
17
19
|
? this.in_.map((iri) => `"${iri.value}"`).join(" | ")
|
|
@@ -19,6 +21,55 @@ export class IdentifierType extends TermType {
|
|
|
19
21
|
},
|
|
20
22
|
]);
|
|
21
23
|
}
|
|
24
|
+
get fromStringFunctionDeclaration() {
|
|
25
|
+
if (this.nodeKinds.has("BlankNode") &&
|
|
26
|
+
this.nodeKinds.has("NamedNode") &&
|
|
27
|
+
this.in_.length === 0) {
|
|
28
|
+
// Wrap rdfjsResource.Resource.Identifier.fromString
|
|
29
|
+
return {
|
|
30
|
+
isExported: true,
|
|
31
|
+
kind: StructureKind.Function,
|
|
32
|
+
name: "fromString",
|
|
33
|
+
parameters: [
|
|
34
|
+
{
|
|
35
|
+
name: "identifier",
|
|
36
|
+
type: "string",
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
returnType: "purify.Either<Error, rdfjsResource.Resource.Identifier>",
|
|
40
|
+
statements: [
|
|
41
|
+
"return purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({ dataFactory, identifier }));",
|
|
42
|
+
],
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const expressions = [
|
|
46
|
+
"purify.Either.encase(() => rdfjsResource.Resource.Identifier.fromString({ dataFactory, identifier }))",
|
|
47
|
+
];
|
|
48
|
+
if (this.isNamedNodeKind) {
|
|
49
|
+
expressions.push(`chain((identifier) => (identifier.termType === "NamedNode") ? purify.Either.of(identifier) : purify.Left(new Error("expected identifier to be NamedNode")))`);
|
|
50
|
+
if (this.in_.length > 0) {
|
|
51
|
+
expressions.push(`chain((identifier) => { switch (identifier.value) { ${this.in_.map((iri) => `case "${iri.value}": return purify.Either.of(identifier as rdfjs.NamedNode<"${iri.value}">);`).join(" ")} default: return purify.Left(new Error("expected NamedNode identifier to be one of ${this.in_.map((iri) => iri.value).join(" ")}")); } })`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
isExported: true,
|
|
56
|
+
kind: StructureKind.Function,
|
|
57
|
+
name: "fromString",
|
|
58
|
+
parameters: [
|
|
59
|
+
{
|
|
60
|
+
name: "identifier",
|
|
61
|
+
type: "string",
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
returnType: `purify.Either<Error, ${this.name}>`,
|
|
65
|
+
statements: [
|
|
66
|
+
`return ${expressions.join(".")} as purify.Either<Error, ${this.name}>;`,
|
|
67
|
+
],
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
get graphqlName() {
|
|
71
|
+
return new Type.GraphqlName("graphql.GraphQLString");
|
|
72
|
+
}
|
|
22
73
|
get isNamedNodeKind() {
|
|
23
74
|
return this.nodeKinds.size === 1 && this.nodeKinds.has("NamedNode");
|
|
24
75
|
}
|
|
@@ -26,9 +77,9 @@ export class IdentifierType extends TermType {
|
|
|
26
77
|
if (this.in_.length > 0 && this.isNamedNodeKind) {
|
|
27
78
|
// Treat sh:in as a union of the IRIs
|
|
28
79
|
// rdfjs.NamedNode<"http://example.com/1" | "http://example.com/2">
|
|
29
|
-
return `{ readonly "@id": ${this.in_.map((iri) => `"${iri.value}"`).join(" | ")} }
|
|
80
|
+
return new Type.JsonName(`{ readonly "@id": ${this.in_.map((iri) => `"${iri.value}"`).join(" | ")} }`);
|
|
30
81
|
}
|
|
31
|
-
return `{ readonly "@id": string }
|
|
82
|
+
return new Type.JsonName(`{ readonly "@id": string }`);
|
|
32
83
|
}
|
|
33
84
|
get name() {
|
|
34
85
|
if (this.in_.length > 0 && this.isNamedNodeKind) {
|
|
@@ -42,9 +93,24 @@ export class IdentifierType extends TermType {
|
|
|
42
93
|
.map((nodeKind) => `rdfjs.${nodeKind}`)
|
|
43
94
|
.join(" | ")})`;
|
|
44
95
|
}
|
|
96
|
+
get toStringFunctionDeclaration() {
|
|
97
|
+
// Re-export rdfjsResource.Resource.Identifier.toString
|
|
98
|
+
return {
|
|
99
|
+
declarationKind: VariableDeclarationKind.Const,
|
|
100
|
+
isExported: true,
|
|
101
|
+
kind: StructureKind.VariableStatement,
|
|
102
|
+
declarations: [
|
|
103
|
+
{
|
|
104
|
+
initializer: "rdfjsResource.Resource.Identifier.toString",
|
|
105
|
+
leadingTrivia: "// biome-ignore lint/suspicious/noShadowRestrictedNames:",
|
|
106
|
+
name: "toString",
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
};
|
|
110
|
+
}
|
|
45
111
|
fromJsonExpression({ variables, }) {
|
|
46
|
-
const valueToBlankNode =
|
|
47
|
-
const valueToNamedNode =
|
|
112
|
+
const valueToBlankNode = `dataFactory.blankNode(${variables.value}["@id"].substring(2))`;
|
|
113
|
+
const valueToNamedNode = `dataFactory.namedNode(${variables.value}["@id"])`;
|
|
48
114
|
if (this.nodeKinds.size === 2) {
|
|
49
115
|
return `(${variables.value}["@id"].startsWith("_:") ? ${valueToBlankNode} : ${valueToNamedNode})`;
|
|
50
116
|
}
|
|
@@ -55,6 +121,29 @@ export class IdentifierType extends TermType {
|
|
|
55
121
|
return valueToNamedNode;
|
|
56
122
|
}
|
|
57
123
|
}
|
|
124
|
+
fromRdfExpressionChain({ variables, }) {
|
|
125
|
+
let valueToExpression;
|
|
126
|
+
if (this.nodeKinds.size === 2) {
|
|
127
|
+
valueToExpression = "value.toIdentifier()";
|
|
128
|
+
}
|
|
129
|
+
else if (this.isNamedNodeKind) {
|
|
130
|
+
valueToExpression = "value.toIri()";
|
|
131
|
+
if (this.in_.length > 0) {
|
|
132
|
+
const eitherTypeParameters = `<Error, ${this.name}>`;
|
|
133
|
+
valueToExpression = `${valueToExpression}.chain(iri => { switch (iri.value) { ${this.in_.map((iri) => `case "${iri.value}": return purify.Either.of${eitherTypeParameters}(iri as rdfjs.NamedNode<"${iri.value}">);`).join(" ")} default: return purify.Left${eitherTypeParameters}(new rdfjsResource.Resource.MistypedValueError({ actualValue: iri, expectedValueType: ${JSON.stringify(this.name)}, focusResource: ${variables.resource}, predicate: ${variables.predicate} })); } } )`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
throw new Error("not implemented");
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
...super.fromRdfExpressionChain,
|
|
141
|
+
valueTo: `chain(values => values.chainMap(value => ${valueToExpression}))`,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
graphqlResolveExpression({ variables: { value }, }) {
|
|
145
|
+
return `rdfjsResource.Resource.Identifier.toString(${value})`;
|
|
146
|
+
}
|
|
58
147
|
jsonZodSchema({ variables, }) {
|
|
59
148
|
let idSchema;
|
|
60
149
|
if (this.in_.length > 0 && this.isNamedNodeKind) {
|
|
@@ -80,21 +169,26 @@ export class IdentifierType extends TermType {
|
|
|
80
169
|
return valueToNamedNode;
|
|
81
170
|
}
|
|
82
171
|
}
|
|
83
|
-
propertyFromRdfResourceValueExpression({ variables, }) {
|
|
84
|
-
if (this.nodeKinds.size === 2) {
|
|
85
|
-
return `${variables.resourceValue}.toIdentifier()`;
|
|
86
|
-
}
|
|
87
|
-
if (this.isNamedNodeKind) {
|
|
88
|
-
let expression = `${variables.resourceValue}.toIri()`;
|
|
89
|
-
if (this.in_.length > 0) {
|
|
90
|
-
expression = `${expression}.chain(iri => { switch (iri.value) { ${this.in_.map((iri) => `case "${iri.value}": return purify.Either.of<rdfjsResource.Resource.ValueError, ${this.name}>(iri as rdfjs.NamedNode<"${iri.value}">);`).join(" ")} default: return purify.Left(new rdfjsResource.Resource.MistypedValueError({ actualValue: iri, expectedValueType: ${JSON.stringify(this.name)}, focusResource: ${variables.resource}, predicate: ${variables.predicate} })); } } )`;
|
|
91
|
-
}
|
|
92
|
-
return expression;
|
|
93
|
-
}
|
|
94
|
-
throw new Error(`not implemented: ${this.name}`);
|
|
95
|
-
}
|
|
96
172
|
}
|
|
173
|
+
__decorate([
|
|
174
|
+
Memoize()
|
|
175
|
+
], IdentifierType.prototype, "conversions", null);
|
|
176
|
+
__decorate([
|
|
177
|
+
Memoize()
|
|
178
|
+
], IdentifierType.prototype, "fromStringFunctionDeclaration", null);
|
|
179
|
+
__decorate([
|
|
180
|
+
Memoize()
|
|
181
|
+
], IdentifierType.prototype, "graphqlName", null);
|
|
182
|
+
__decorate([
|
|
183
|
+
Memoize()
|
|
184
|
+
], IdentifierType.prototype, "isNamedNodeKind", null);
|
|
185
|
+
__decorate([
|
|
186
|
+
Memoize()
|
|
187
|
+
], IdentifierType.prototype, "jsonName", null);
|
|
97
188
|
__decorate([
|
|
98
189
|
Memoize()
|
|
99
190
|
], IdentifierType.prototype, "name", null);
|
|
191
|
+
__decorate([
|
|
192
|
+
Memoize()
|
|
193
|
+
], IdentifierType.prototype, "toStringFunctionDeclaration", null);
|
|
100
194
|
//# sourceMappingURL=IdentifierType.js.map
|
|
@@ -4,6 +4,8 @@ export type Import = ImportDeclarationStructure | string;
|
|
|
4
4
|
* Singleton values for common imports.
|
|
5
5
|
*/
|
|
6
6
|
export declare namespace Import {
|
|
7
|
+
const GRAPHQL: Import;
|
|
8
|
+
const GRAPHQL_SCALARS: Import;
|
|
7
9
|
const PURIFY: Import;
|
|
8
10
|
const RDF_LITERAL: Import;
|
|
9
11
|
const RDFJS_RESOURCE: Import;
|
|
@@ -4,6 +4,16 @@ import { StructureKind } from "ts-morph";
|
|
|
4
4
|
*/
|
|
5
5
|
export var Import;
|
|
6
6
|
(function (Import) {
|
|
7
|
+
Import.GRAPHQL = {
|
|
8
|
+
kind: StructureKind.ImportDeclaration,
|
|
9
|
+
moduleSpecifier: "graphql",
|
|
10
|
+
namespaceImport: "graphql",
|
|
11
|
+
};
|
|
12
|
+
Import.GRAPHQL_SCALARS = {
|
|
13
|
+
kind: StructureKind.ImportDeclaration,
|
|
14
|
+
moduleSpecifier: "graphql-scalars",
|
|
15
|
+
namespaceImport: "graphqlScalars",
|
|
16
|
+
};
|
|
7
17
|
Import.PURIFY = {
|
|
8
18
|
kind: StructureKind.ImportDeclaration,
|
|
9
19
|
moduleSpecifier: "purify-ts",
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
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
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Memoize } from "typescript-memoize";
|
|
8
|
+
import { NumberType } from "./NumberType.js";
|
|
9
|
+
import { Type } from "./Type.js";
|
|
10
|
+
export class IntType extends NumberType {
|
|
11
|
+
get graphqlName() {
|
|
12
|
+
return new Type.GraphqlName("graphql.GraphQLInt");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
__decorate([
|
|
16
|
+
Memoize()
|
|
17
|
+
], IntType.prototype, "graphqlName", null);
|
|
18
|
+
//# sourceMappingURL=IntType.js.map
|
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
import type { NamedNode } from "@rdfjs/types";
|
|
2
2
|
import { Maybe } from "purify-ts";
|
|
3
|
-
import type { IdentifierMintingStrategy
|
|
3
|
+
import type { IdentifierMintingStrategy } from "../../enums/index.js";
|
|
4
4
|
import { Import } from "./Import.js";
|
|
5
5
|
import { Type } from "./Type.js";
|
|
6
6
|
export declare class ListType extends Type {
|
|
7
|
-
readonly itemType: Type;
|
|
8
|
-
readonly kind = "ListType";
|
|
9
|
-
private readonly identifierNodeKind;
|
|
10
|
-
private readonly identifierMintingStrategy;
|
|
11
7
|
private readonly _mutable;
|
|
8
|
+
private readonly identifierMintingStrategy;
|
|
9
|
+
private readonly identifierNodeKind;
|
|
12
10
|
private readonly toRdfTypes;
|
|
13
|
-
|
|
11
|
+
readonly itemType: Type;
|
|
12
|
+
readonly kind = "ListType";
|
|
13
|
+
readonly typeof = "object";
|
|
14
|
+
constructor({ identifierNodeKind, itemType, identifierMintingStrategy, mutable, toRdfTypes, }: {
|
|
14
15
|
identifierNodeKind: ListType["identifierNodeKind"];
|
|
15
16
|
itemType: Type;
|
|
16
17
|
identifierMintingStrategy: Maybe<IdentifierMintingStrategy>;
|
|
17
18
|
mutable: boolean;
|
|
18
19
|
toRdfTypes: readonly NamedNode[];
|
|
19
|
-
}
|
|
20
|
+
});
|
|
20
21
|
get conversions(): readonly Type.Conversion[];
|
|
21
22
|
get discriminatorProperty(): Maybe<Type.DiscriminatorProperty>;
|
|
22
23
|
get equalsFunction(): string;
|
|
23
|
-
get
|
|
24
|
+
get graphqlName(): Type.GraphqlName;
|
|
25
|
+
get jsonName(): Type.JsonName;
|
|
24
26
|
get mutable(): boolean;
|
|
25
27
|
get name(): string;
|
|
26
28
|
fromJsonExpression({ variables, }: Parameters<Type["fromJsonExpression"]>[0]): string;
|
|
27
29
|
fromRdfExpression({ variables, }: Parameters<Type["fromRdfExpression"]>[0]): string;
|
|
30
|
+
graphqlResolveExpression({ variables, }: Parameters<Type["graphqlResolveExpression"]>[0]): string;
|
|
28
31
|
hashStatements({ depth, variables, }: Parameters<Type["hashStatements"]>[0]): readonly string[];
|
|
29
32
|
jsonUiSchemaElement(parameters: Parameters<Type["jsonUiSchemaElement"]>[0]): ReturnType<Type["jsonUiSchemaElement"]>;
|
|
30
33
|
jsonZodSchema(parameters: Parameters<Type["jsonZodSchema"]>[0]): ReturnType<Type["jsonZodSchema"]>;
|
|
31
|
-
snippetDeclarations(
|
|
32
|
-
sparqlConstructTemplateTriples(
|
|
33
|
-
sparqlWherePatterns(
|
|
34
|
+
snippetDeclarations(parameters: Parameters<Type["snippetDeclarations"]>[0]): readonly string[];
|
|
35
|
+
sparqlConstructTemplateTriples(parameters: Parameters<Type["sparqlConstructTemplateTriples"]>[0]): readonly string[];
|
|
36
|
+
sparqlWherePatterns(parameters: Parameters<Type["sparqlWherePatterns"]>[0]): readonly string[];
|
|
34
37
|
toJsonExpression({ variables, }: Parameters<Type["toJsonExpression"]>[0]): string;
|
|
35
38
|
toRdfExpression({ variables, }: Parameters<Type["toRdfExpression"]>[0]): string;
|
|
36
|
-
useImports(
|
|
39
|
+
useImports(parameters: Parameters<Type["useImports"]>[0]): readonly Import[];
|
|
37
40
|
}
|
|
38
41
|
//# sourceMappingURL=ListType.d.ts.map
|