@shaclmate/compiler 2.0.22 → 2.0.23
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 +1 -0
- package/dist/ShapesGraphToAstTransformer.js +56 -12
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.d.ts +13 -0
- package/dist/_ShapesGraphToAstTransformer/flattenAstObjectCompositeTypeMemberTypes.js +51 -0
- 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/transformPropertyShapeToAstCompositeType.d.ts +2 -3
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstCompositeType.js +122 -129
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstIdentifierType.d.ts +2 -2
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstLiteralType.d.ts +2 -2
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstObjectTypeProperty.js +127 -5
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstTermType.d.ts +3 -3
- package/dist/_ShapesGraphToAstTransformer/transformPropertyShapeToAstType.d.ts +2 -3
- 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 -2
- package/dist/ast/SetType.d.ts +2 -2
- package/dist/ast/TermType.d.ts +12 -4
- package/dist/ast/Type.d.ts +1 -1
- package/dist/enums/TsFeature.d.ts +1 -4
- package/dist/enums/TsFeature.js +1 -15
- package/dist/generators/json/AstJsonGenerator.js +19 -3
- package/dist/generators/ts/BooleanType.d.ts +3 -1
- package/dist/generators/ts/BooleanType.js +11 -2
- package/dist/generators/ts/DateTimeType.d.ts +8 -7
- package/dist/generators/ts/DateTimeType.js +31 -7
- 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 +12 -7
- package/dist/generators/ts/IdentifierType.js +94 -6
- 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 +98 -57
- package/dist/generators/ts/LiteralType.d.ts +10 -9
- package/dist/generators/ts/LiteralType.js +13 -2
- package/dist/generators/ts/NumberType.d.ts +2 -1
- package/dist/generators/ts/NumberType.js +7 -2
- package/dist/generators/ts/ObjectType.d.ts +66 -43
- package/dist/generators/ts/ObjectType.js +144 -123
- package/dist/generators/ts/ObjectUnionType.d.ts +49 -8
- package/dist/generators/ts/ObjectUnionType.js +290 -97
- package/dist/generators/ts/OptionType.d.ts +14 -10
- package/dist/generators/ts/OptionType.js +60 -34
- package/dist/generators/ts/PrimitiveType.d.ts +4 -4
- package/dist/generators/ts/PrimitiveType.js +18 -3
- package/dist/generators/ts/SetType.d.ts +16 -12
- package/dist/generators/ts/SetType.js +69 -40
- package/dist/generators/ts/SnippetDeclarations.d.ts +13 -8
- package/dist/generators/ts/SnippetDeclarations.js +215 -101
- package/dist/generators/ts/StringType.d.ts +3 -1
- package/dist/generators/ts/StringType.js +14 -2
- package/dist/generators/ts/TermType.d.ts +22 -14
- package/dist/generators/ts/TermType.js +53 -25
- package/dist/generators/ts/TsGenerator.d.ts +2 -1
- package/dist/generators/ts/TsGenerator.js +23 -12
- package/dist/generators/ts/Type.d.ts +89 -31
- package/dist/generators/ts/Type.js +57 -54
- package/dist/generators/ts/TypeFactory.d.ts +4 -5
- package/dist/generators/ts/TypeFactory.js +290 -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 +30 -0
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.d.ts +13 -12
- package/dist/generators/ts/_ObjectType/IdentifierPrefixProperty.js +46 -47
- package/dist/generators/ts/_ObjectType/IdentifierProperty.d.ts +20 -13
- package/dist/generators/ts/_ObjectType/IdentifierProperty.js +152 -124
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.d.ts +87 -0
- package/dist/generators/ts/_ObjectType/LazyShaclProperty.js +237 -0
- package/dist/generators/ts/_ObjectType/Property.d.ts +39 -44
- 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 +108 -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 +6 -5
- package/dist/generators/ts/_ObjectType/createFunctionDeclaration.js +5 -4
- package/dist/generators/ts/_ObjectType/equalsFunctionOrMethodDeclaration.js +5 -4
- 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 +37 -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 +152 -0
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryFunctionDeclaration.js +4 -3
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.d.ts +1 -1
- package/dist/generators/ts/_ObjectType/sparqlConstructQueryStringFunctionDeclaration.js +3 -2
- package/dist/generators/ts/_ObjectType/sparqlFunctionDeclarations.js +103 -35
- package/dist/generators/ts/_ObjectType/toJsonFunctionOrMethodDeclaration.js +6 -6
- package/dist/generators/ts/_ObjectType/toRdfFunctionOrMethodDeclaration.js +15 -13
- 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 +6 -5
- package/dist/input/PropertyPath.js +14 -22
- package/dist/input/PropertyShape.d.ts +3 -1
- package/dist/input/PropertyShape.js +8 -2
- package/dist/input/ShapesGraph.js +4 -4
- package/dist/input/generated.d.ts +923 -105
- package/dist/input/generated.js +1865 -969
- package/dist/input/tsFeatures.d.ts +3 -2
- package/dist/input/tsFeatures.js +44 -27
- package/package.json +18 -16
- 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
|
@@ -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,9 @@ export class IdentifierType extends TermType {
|
|
|
55
121
|
return valueToNamedNode;
|
|
56
122
|
}
|
|
57
123
|
}
|
|
124
|
+
graphqlResolveExpression({ variables: { value }, }) {
|
|
125
|
+
return `rdfjsResource.Resource.Identifier.toString(${value})`;
|
|
126
|
+
}
|
|
58
127
|
jsonZodSchema({ variables, }) {
|
|
59
128
|
let idSchema;
|
|
60
129
|
if (this.in_.length > 0 && this.isNamedNodeKind) {
|
|
@@ -87,14 +156,33 @@ export class IdentifierType extends TermType {
|
|
|
87
156
|
if (this.isNamedNodeKind) {
|
|
88
157
|
let expression = `${variables.resourceValue}.toIri()`;
|
|
89
158
|
if (this.in_.length > 0) {
|
|
90
|
-
|
|
159
|
+
const eitherTypeParameters = `<Error, ${this.name}>`;
|
|
160
|
+
expression = `${expression}.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} })); } } )`;
|
|
91
161
|
}
|
|
92
162
|
return expression;
|
|
93
163
|
}
|
|
94
164
|
throw new Error(`not implemented: ${this.name}`);
|
|
95
165
|
}
|
|
96
166
|
}
|
|
167
|
+
__decorate([
|
|
168
|
+
Memoize()
|
|
169
|
+
], IdentifierType.prototype, "conversions", null);
|
|
170
|
+
__decorate([
|
|
171
|
+
Memoize()
|
|
172
|
+
], IdentifierType.prototype, "fromStringFunctionDeclaration", null);
|
|
173
|
+
__decorate([
|
|
174
|
+
Memoize()
|
|
175
|
+
], IdentifierType.prototype, "graphqlName", null);
|
|
176
|
+
__decorate([
|
|
177
|
+
Memoize()
|
|
178
|
+
], IdentifierType.prototype, "isNamedNodeKind", null);
|
|
179
|
+
__decorate([
|
|
180
|
+
Memoize()
|
|
181
|
+
], IdentifierType.prototype, "jsonName", null);
|
|
97
182
|
__decorate([
|
|
98
183
|
Memoize()
|
|
99
184
|
], IdentifierType.prototype, "name", null);
|
|
185
|
+
__decorate([
|
|
186
|
+
Memoize()
|
|
187
|
+
], IdentifierType.prototype, "toStringFunctionDeclaration", null);
|
|
100
188
|
//# 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
|
|
@@ -1,18 +1,28 @@
|
|
|
1
|
-
|
|
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
|
+
};
|
|
2
7
|
import { Maybe } from "purify-ts";
|
|
8
|
+
import { rdf } from "@tpluscode/rdf-ns-builders";
|
|
9
|
+
import { Memoize } from "typescript-memoize";
|
|
3
10
|
import { Import } from "./Import.js";
|
|
4
11
|
import { SnippetDeclarations } from "./SnippetDeclarations.js";
|
|
5
12
|
import { Type } from "./Type.js";
|
|
6
13
|
import { objectInitializer } from "./objectInitializer.js";
|
|
14
|
+
import { rdfjsTermExpression } from "./rdfjsTermExpression.js";
|
|
15
|
+
import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
7
16
|
export class ListType extends Type {
|
|
8
|
-
itemType;
|
|
9
|
-
kind = "ListType";
|
|
10
|
-
identifierNodeKind;
|
|
11
|
-
identifierMintingStrategy;
|
|
12
17
|
_mutable;
|
|
18
|
+
identifierMintingStrategy;
|
|
19
|
+
identifierNodeKind;
|
|
13
20
|
toRdfTypes;
|
|
14
|
-
|
|
15
|
-
|
|
21
|
+
itemType;
|
|
22
|
+
kind = "ListType";
|
|
23
|
+
typeof = "object";
|
|
24
|
+
constructor({ identifierNodeKind, itemType, identifierMintingStrategy, mutable, toRdfTypes, }) {
|
|
25
|
+
super();
|
|
16
26
|
this.identifierNodeKind = identifierNodeKind;
|
|
17
27
|
this.itemType = itemType;
|
|
18
28
|
this.identifierMintingStrategy = identifierMintingStrategy.orDefault(identifierNodeKind === "BlankNode" ? "blankNode" : "sha256");
|
|
@@ -22,8 +32,11 @@ export class ListType extends Type {
|
|
|
22
32
|
get conversions() {
|
|
23
33
|
return [
|
|
24
34
|
{
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
// Defensive copy
|
|
36
|
+
conversionExpression: (value) => `${value}${this.mutable ? ".concat()" : ""}`,
|
|
37
|
+
// Array.isArray doesn't narrow correctly
|
|
38
|
+
// sourceTypeCheckExpression: (value) => `Array.isArray(${value})`,
|
|
39
|
+
sourceTypeCheckExpression: (value) => `typeof ${value} === "object"`,
|
|
27
40
|
sourceTypeName: this.name,
|
|
28
41
|
},
|
|
29
42
|
];
|
|
@@ -32,10 +45,13 @@ export class ListType extends Type {
|
|
|
32
45
|
return Maybe.empty();
|
|
33
46
|
}
|
|
34
47
|
get equalsFunction() {
|
|
35
|
-
return `((left, right) => arrayEquals(left, right, ${this.itemType.equalsFunction}))`;
|
|
48
|
+
return `((left, right) => ${syntheticNamePrefix}arrayEquals(left, right, ${this.itemType.equalsFunction}))`;
|
|
49
|
+
}
|
|
50
|
+
get graphqlName() {
|
|
51
|
+
return new Type.GraphqlName(`new graphql.GraphQLList(${this.itemType.graphqlName})`);
|
|
36
52
|
}
|
|
37
53
|
get jsonName() {
|
|
38
|
-
return `readonly (${this.itemType.jsonName})[]
|
|
54
|
+
return new Type.JsonName(`readonly (${this.itemType.jsonName})[]`);
|
|
39
55
|
}
|
|
40
56
|
get mutable() {
|
|
41
57
|
return this._mutable || this.itemType.mutable;
|
|
@@ -44,18 +60,21 @@ export class ListType extends Type {
|
|
|
44
60
|
return `${this._mutable ? "" : "readonly "}${this.itemType.name}[]`;
|
|
45
61
|
}
|
|
46
62
|
fromJsonExpression({ variables, }) {
|
|
47
|
-
return `${variables.value}.map(
|
|
63
|
+
return `${variables.value}.map(item => (${this.itemType.fromJsonExpression({ variables: { value: "item" } })}))`;
|
|
48
64
|
}
|
|
49
65
|
fromRdfExpression({ variables, }) {
|
|
50
66
|
const chain = [variables.resourceValues];
|
|
51
67
|
chain.push("head()");
|
|
52
68
|
chain.push("chain(value => value.toList())");
|
|
53
|
-
chain.push(`
|
|
69
|
+
chain.push(`chain(values => purify.Either.sequence(values.map(value => ${this.itemType.fromRdfExpression({ variables: { ...variables, resourceValues: "value.toValues()" } })})))`);
|
|
54
70
|
return chain.join(".");
|
|
55
71
|
}
|
|
72
|
+
graphqlResolveExpression({ variables, }) {
|
|
73
|
+
return variables.value;
|
|
74
|
+
}
|
|
56
75
|
hashStatements({ depth, variables, }) {
|
|
57
76
|
return [
|
|
58
|
-
`for (const
|
|
77
|
+
`for (const item${depth} of ${variables.value}) { ${this.itemType.hashStatements({ depth: depth + 1, variables: { ...variables, value: `item${depth}` } }).join("\n")} }`,
|
|
59
78
|
];
|
|
60
79
|
}
|
|
61
80
|
jsonUiSchemaElement(parameters) {
|
|
@@ -64,33 +83,35 @@ export class ListType extends Type {
|
|
|
64
83
|
jsonZodSchema(parameters) {
|
|
65
84
|
return `${this.itemType.jsonZodSchema(parameters)}.array()`;
|
|
66
85
|
}
|
|
67
|
-
snippetDeclarations(
|
|
86
|
+
snippetDeclarations(parameters) {
|
|
68
87
|
const snippetDeclarations = this.itemType
|
|
69
|
-
.snippetDeclarations(
|
|
88
|
+
.snippetDeclarations(parameters)
|
|
70
89
|
.concat();
|
|
71
|
-
if (features.has("equals")) {
|
|
90
|
+
if (parameters.features.has("equals")) {
|
|
72
91
|
snippetDeclarations.push(SnippetDeclarations.arrayEquals);
|
|
73
92
|
}
|
|
74
93
|
return snippetDeclarations;
|
|
75
94
|
}
|
|
76
|
-
sparqlConstructTemplateTriples(
|
|
77
|
-
switch (context) {
|
|
78
|
-
case "
|
|
79
|
-
return super.sparqlConstructTemplateTriples(
|
|
80
|
-
case "
|
|
95
|
+
sparqlConstructTemplateTriples(parameters) {
|
|
96
|
+
switch (parameters.context) {
|
|
97
|
+
case "object":
|
|
98
|
+
return super.sparqlConstructTemplateTriples(parameters);
|
|
99
|
+
case "subject": {
|
|
100
|
+
const { variables } = parameters;
|
|
81
101
|
const triples = [];
|
|
82
102
|
const listVariable = variables.subject;
|
|
83
|
-
const variable = (suffix) =>
|
|
103
|
+
const variable = (suffix) => `dataFactory.variable!(\`\${${variables.variablePrefix}}${suffix}\`)`;
|
|
84
104
|
const variablePrefix = (suffix) => `\`\${${variables.variablePrefix}}${suffix}\``;
|
|
85
105
|
{
|
|
86
106
|
// ?list rdf:first ?item0
|
|
87
107
|
const item0Variable = variable("Item0");
|
|
88
108
|
triples.push(objectInitializer({
|
|
89
109
|
subject: listVariable,
|
|
90
|
-
predicate:
|
|
110
|
+
predicate: rdfjsTermExpression(rdf.first),
|
|
91
111
|
object: item0Variable,
|
|
92
112
|
}), ...this.itemType.sparqlConstructTemplateTriples({
|
|
93
|
-
|
|
113
|
+
allowIgnoreRdfType: true,
|
|
114
|
+
context: "subject",
|
|
94
115
|
variables: {
|
|
95
116
|
subject: item0Variable,
|
|
96
117
|
variablePrefix: variablePrefix("Item0"),
|
|
@@ -102,7 +123,7 @@ export class ListType extends Type {
|
|
|
102
123
|
const rest0Variable = variable("Rest0");
|
|
103
124
|
triples.push(objectInitializer({
|
|
104
125
|
subject: listVariable,
|
|
105
|
-
predicate:
|
|
126
|
+
predicate: rdfjsTermExpression(rdf.rest),
|
|
106
127
|
object: rest0Variable,
|
|
107
128
|
}));
|
|
108
129
|
}
|
|
@@ -113,10 +134,11 @@ export class ListType extends Type {
|
|
|
113
134
|
const itemNVariable = variable("ItemN");
|
|
114
135
|
triples.push(objectInitializer({
|
|
115
136
|
subject: restNVariable,
|
|
116
|
-
predicate:
|
|
137
|
+
predicate: rdfjsTermExpression(rdf.first),
|
|
117
138
|
object: itemNVariable,
|
|
118
139
|
}), ...this.itemType.sparqlConstructTemplateTriples({
|
|
119
|
-
|
|
140
|
+
allowIgnoreRdfType: true,
|
|
141
|
+
context: "subject",
|
|
120
142
|
variables: {
|
|
121
143
|
subject: itemNVariable,
|
|
122
144
|
variablePrefix: variablePrefix("ItemN"),
|
|
@@ -126,35 +148,37 @@ export class ListType extends Type {
|
|
|
126
148
|
// ?restN rdf:rest ?restNBasic to get the rdf:rest statement in the CONSTRUCT
|
|
127
149
|
triples.push(objectInitializer({
|
|
128
150
|
subject: restNVariable,
|
|
129
|
-
predicate:
|
|
151
|
+
predicate: rdfjsTermExpression(rdf.rest),
|
|
130
152
|
object: variable("RestNBasic"),
|
|
131
153
|
}));
|
|
132
154
|
return triples;
|
|
133
155
|
}
|
|
134
156
|
}
|
|
135
157
|
}
|
|
136
|
-
sparqlWherePatterns(
|
|
158
|
+
sparqlWherePatterns(parameters) {
|
|
137
159
|
// Need to handle two cases:
|
|
138
160
|
// (1) (?s, ?p, ?list) where ?list binds to rdf:nil
|
|
139
161
|
// (2) (?s, ?p, ?list) (?list, rdf:first, "element") (?list, rdf:rest, rdf:nil) etc. where list binds to the head of a list
|
|
140
162
|
// Case (2) is case (1) with OPTIONAL graph patterns to handle actual list elements.
|
|
141
|
-
switch (context) {
|
|
142
|
-
case "
|
|
143
|
-
return super.sparqlWherePatterns(
|
|
144
|
-
case "
|
|
163
|
+
switch (parameters.context) {
|
|
164
|
+
case "object":
|
|
165
|
+
return super.sparqlWherePatterns(parameters);
|
|
166
|
+
case "subject": {
|
|
167
|
+
const { variables } = parameters;
|
|
145
168
|
const patterns = [];
|
|
146
169
|
const listVariable = variables.subject;
|
|
147
|
-
const variable = (suffix) =>
|
|
170
|
+
const variable = (suffix) => `dataFactory.variable!(\`\${${variables.variablePrefix}}${suffix}\`)`;
|
|
148
171
|
const variablePrefix = (suffix) => `\`\${${variables.variablePrefix}}${suffix}\``;
|
|
149
172
|
{
|
|
150
173
|
// ?list rdf:first ?item0
|
|
151
174
|
const item0Variable = variable("Item0");
|
|
152
175
|
patterns.push(`{ type: "bgp", triples: [${objectInitializer({
|
|
153
176
|
subject: listVariable,
|
|
154
|
-
predicate:
|
|
177
|
+
predicate: rdfjsTermExpression(rdf.first),
|
|
155
178
|
object: item0Variable,
|
|
156
179
|
})}] }`, ...this.itemType.sparqlWherePatterns({
|
|
157
|
-
|
|
180
|
+
allowIgnoreRdfType: true,
|
|
181
|
+
context: "subject",
|
|
158
182
|
variables: {
|
|
159
183
|
subject: item0Variable,
|
|
160
184
|
variablePrefix: variablePrefix("Item0"),
|
|
@@ -166,7 +190,7 @@ export class ListType extends Type {
|
|
|
166
190
|
const rest0Variable = variable("Rest0");
|
|
167
191
|
patterns.push(`{ type: "bgp", triples: [${objectInitializer({
|
|
168
192
|
subject: listVariable,
|
|
169
|
-
predicate:
|
|
193
|
+
predicate: rdfjsTermExpression(rdf.rest),
|
|
170
194
|
object: rest0Variable,
|
|
171
195
|
})}] }`);
|
|
172
196
|
}
|
|
@@ -175,7 +199,7 @@ export class ListType extends Type {
|
|
|
175
199
|
// ?list rdf:rest+ ?restN
|
|
176
200
|
optionalPatterns.push(`{ type: "bgp", triples: [${objectInitializer({
|
|
177
201
|
subject: listVariable,
|
|
178
|
-
predicate: `{ type: "path", pathType: "*", items: [${
|
|
202
|
+
predicate: `{ type: "path", pathType: "*", items: [${rdfjsTermExpression(rdf.rest)}] }`,
|
|
179
203
|
object: restNVariable,
|
|
180
204
|
})}] }`);
|
|
181
205
|
{
|
|
@@ -183,10 +207,11 @@ export class ListType extends Type {
|
|
|
183
207
|
const itemNVariable = variable("ItemN");
|
|
184
208
|
optionalPatterns.push(`{ type: "bgp", triples: [${objectInitializer({
|
|
185
209
|
subject: restNVariable,
|
|
186
|
-
predicate:
|
|
210
|
+
predicate: rdfjsTermExpression(rdf.first),
|
|
187
211
|
object: itemNVariable,
|
|
188
212
|
})}] }`, ...this.itemType.sparqlWherePatterns({
|
|
189
|
-
|
|
213
|
+
allowIgnoreRdfType: true,
|
|
214
|
+
context: "subject",
|
|
190
215
|
variables: {
|
|
191
216
|
subject: itemNVariable,
|
|
192
217
|
variablePrefix: variablePrefix("ItemN"),
|
|
@@ -196,7 +221,7 @@ export class ListType extends Type {
|
|
|
196
221
|
// ?restN rdf:rest ?restNBasic to get the rdf:rest statement in the CONSTRUCT
|
|
197
222
|
optionalPatterns.push(`{ type: "bgp", triples: [${objectInitializer({
|
|
198
223
|
subject: restNVariable,
|
|
199
|
-
predicate:
|
|
224
|
+
predicate: rdfjsTermExpression(rdf.rest),
|
|
200
225
|
object: variable("RestNBasic"),
|
|
201
226
|
})}] }`);
|
|
202
227
|
patterns.push(`{ type: "optional", patterns: [${optionalPatterns.join(", ")}] }`);
|
|
@@ -208,12 +233,12 @@ export class ListType extends Type {
|
|
|
208
233
|
toJsonExpression({ variables, }) {
|
|
209
234
|
let expression = variables.value;
|
|
210
235
|
const itemFromJsonExpression = this.itemType.fromJsonExpression({
|
|
211
|
-
variables: { value: "
|
|
236
|
+
variables: { value: "item" },
|
|
212
237
|
});
|
|
213
|
-
if (itemFromJsonExpression !== "
|
|
214
|
-
expression = `${expression}.map(
|
|
238
|
+
if (itemFromJsonExpression !== "item") {
|
|
239
|
+
expression = `${expression}.map(item => (${itemFromJsonExpression}))`;
|
|
215
240
|
}
|
|
216
|
-
return `${variables.value}.map(
|
|
241
|
+
return `${variables.value}.map(item => (${this.itemType.toJsonExpression({ variables: { value: "item" } })}))`;
|
|
217
242
|
}
|
|
218
243
|
toRdfExpression({ variables, }) {
|
|
219
244
|
let listIdentifier;
|
|
@@ -233,9 +258,9 @@ export class ListType extends Type {
|
|
|
233
258
|
throw new RangeError(this.identifierMintingStrategy);
|
|
234
259
|
case "sha256":
|
|
235
260
|
listIdentifier = `dataFactory.namedNode(\`urn:shaclmate:list:\${${variables.value}.reduce(
|
|
236
|
-
(
|
|
237
|
-
${this.itemType.hashStatements({ depth: 0, variables: { hasher: "
|
|
238
|
-
return
|
|
261
|
+
(hasher, item) => {
|
|
262
|
+
${this.itemType.hashStatements({ depth: 0, variables: { hasher: "hasher", value: "item" } }).join("\n")}
|
|
263
|
+
return hasher;
|
|
239
264
|
},
|
|
240
265
|
sha256.create(),
|
|
241
266
|
)}\`)`;
|
|
@@ -260,16 +285,16 @@ export class ListType extends Type {
|
|
|
260
285
|
const newSubListResource = ${variables.resourceSet}.${resourceSetMethodName}(${subListIdentifier}, ${objectInitializer({
|
|
261
286
|
mutateGraph: variables.mutateGraph,
|
|
262
287
|
})});
|
|
263
|
-
currentSubListResource!.add(
|
|
288
|
+
currentSubListResource!.add(${rdfjsTermExpression(rdf.rest)}, newSubListResource.identifier);
|
|
264
289
|
currentSubListResource = newSubListResource;
|
|
265
290
|
}
|
|
266
291
|
|
|
267
|
-
${this.toRdfTypes.map((rdfType) => `currentSubListResource.add(
|
|
292
|
+
${this.toRdfTypes.map((rdfType) => `currentSubListResource.add(${rdfjsTermExpression(rdf.type)}, dataFactory.namedNode("${rdfType.value}"))`).join("\n")}
|
|
268
293
|
|
|
269
|
-
currentSubListResource.add(
|
|
294
|
+
currentSubListResource.add(${rdfjsTermExpression(rdf.first)}, ${this.itemType.toRdfExpression({ variables: { mutateGraph: variables.mutateGraph, predicate: rdfjsTermExpression(rdf.first), resource: "currentSubListResource", resourceSet: variables.resourceSet, value: "item" } })});
|
|
270
295
|
|
|
271
296
|
if (itemIndex + 1 === list.length) {
|
|
272
|
-
currentSubListResource.add(
|
|
297
|
+
currentSubListResource.add(${rdfjsTermExpression(rdf.rest)}, ${rdfjsTermExpression(rdf.nil)});
|
|
273
298
|
}
|
|
274
299
|
|
|
275
300
|
return { currentSubListResource, listResource };
|
|
@@ -283,14 +308,30 @@ export class ListType extends Type {
|
|
|
283
308
|
currentSubListResource: ${mutableResourceTypeName} | null;
|
|
284
309
|
listResource: ${mutableResourceTypeName};
|
|
285
310
|
},
|
|
286
|
-
).listResource.identifier :
|
|
311
|
+
).listResource.identifier : ${rdfjsTermExpression(rdf.nil)}`;
|
|
287
312
|
}
|
|
288
|
-
useImports(
|
|
289
|
-
const imports = this.itemType.useImports(
|
|
290
|
-
if (features.has("hash") &&
|
|
313
|
+
useImports(parameters) {
|
|
314
|
+
const imports = this.itemType.useImports(parameters).concat();
|
|
315
|
+
if (parameters.features.has("hash") &&
|
|
316
|
+
this.identifierNodeKind === "NamedNode") {
|
|
291
317
|
imports.push(Import.SHA256);
|
|
292
318
|
}
|
|
293
319
|
return imports;
|
|
294
320
|
}
|
|
295
321
|
}
|
|
322
|
+
__decorate([
|
|
323
|
+
Memoize()
|
|
324
|
+
], ListType.prototype, "conversions", null);
|
|
325
|
+
__decorate([
|
|
326
|
+
Memoize()
|
|
327
|
+
], ListType.prototype, "equalsFunction", null);
|
|
328
|
+
__decorate([
|
|
329
|
+
Memoize()
|
|
330
|
+
], ListType.prototype, "graphqlName", null);
|
|
331
|
+
__decorate([
|
|
332
|
+
Memoize()
|
|
333
|
+
], ListType.prototype, "jsonName", null);
|
|
334
|
+
__decorate([
|
|
335
|
+
Memoize()
|
|
336
|
+
], ListType.prototype, "name", null);
|
|
296
337
|
//# sourceMappingURL=ListType.js.map
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import type { Literal } from "@rdfjs/types";
|
|
2
2
|
import { TermType } from "./TermType.js";
|
|
3
|
-
|
|
3
|
+
import { Type } from "./Type.js";
|
|
4
|
+
export declare class LiteralType extends TermType<Literal, Literal> {
|
|
4
5
|
private readonly languageIn;
|
|
5
6
|
constructor({ languageIn, ...superParameters }: {
|
|
6
7
|
languageIn: readonly string[];
|
|
7
|
-
} & Omit<ConstructorParameters<typeof TermType<Literal>>[0], "nodeKinds">);
|
|
8
|
-
get jsonName():
|
|
9
|
-
fromJsonExpression({ variables, }: Parameters<TermType<Literal>["fromJsonExpression"]>[0]): string;
|
|
10
|
-
hashStatements({ depth, variables, }: Parameters<TermType<Literal>["hashStatements"]>[0]): readonly string[];
|
|
11
|
-
jsonZodSchema({ variables, }: Parameters<TermType<Literal>["jsonZodSchema"]>[0]): ReturnType<TermType<Literal>["jsonZodSchema"]>;
|
|
12
|
-
propertyFromRdfResourceValueExpression({ variables, }: Parameters<TermType<Literal>["propertyFromRdfResourceValueExpression"]>[0]): string;
|
|
13
|
-
toJsonExpression({ variables, }: Parameters<TermType<Literal>["toJsonExpression"]>[0]): string;
|
|
14
|
-
protected propertyFilterRdfResourceValuesExpression({ variables, }: Parameters<TermType<Literal>["propertyFilterRdfResourceValuesExpression"]>[0]): string;
|
|
8
|
+
} & Omit<ConstructorParameters<typeof TermType<Literal, Literal>>[0], "nodeKinds">);
|
|
9
|
+
get jsonName(): Type.JsonName;
|
|
10
|
+
fromJsonExpression({ variables, }: Parameters<TermType<Literal, Literal>["fromJsonExpression"]>[0]): string;
|
|
11
|
+
hashStatements({ depth, variables, }: Parameters<TermType<Literal, Literal>["hashStatements"]>[0]): readonly string[];
|
|
12
|
+
jsonZodSchema({ variables, }: Parameters<TermType<Literal, Literal>["jsonZodSchema"]>[0]): ReturnType<TermType<Literal, Literal>["jsonZodSchema"]>;
|
|
13
|
+
propertyFromRdfResourceValueExpression({ variables, }: Parameters<TermType<Literal, Literal>["propertyFromRdfResourceValueExpression"]>[0]): string;
|
|
14
|
+
toJsonExpression({ variables, }: Parameters<TermType<Literal, Literal>["toJsonExpression"]>[0]): string;
|
|
15
|
+
protected propertyFilterRdfResourceValuesExpression({ variables, }: Parameters<TermType<Literal, Literal>["propertyFilterRdfResourceValuesExpression"]>[0]): string;
|
|
15
16
|
}
|
|
16
17
|
//# sourceMappingURL=LiteralType.d.ts.map
|