@shaclmate/compiler 4.0.5 → 4.0.7
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/generators/ts/AbstractLazyObjectType.js +2 -2
- package/dist/generators/ts/AbstractType.d.ts +6 -6
- package/dist/generators/ts/LazyObjectOptionType.js +1 -1
- package/dist/generators/ts/LazyObjectSetType.js +1 -1
- package/dist/generators/ts/LazyObjectType.js +1 -1
- package/dist/generators/ts/ObjectType.js +19 -6
- package/dist/generators/ts/ObjectUnionType.js +23 -11
- package/dist/generators/ts/ZodGenerator.d.ts +7 -0
- package/dist/generators/ts/ZodGenerator.js +37 -0
- package/dist/generators/ts/_ObjectType/IdentifierProperty.js +1 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromJsonFunctionDeclarations.d.ts +4 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_jsonFunctionDeclarations.js → ObjectType_fromJsonFunctionDeclarations.js} +8 -64
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_fromRdfFunctionDeclaration.js +27 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonSchemaFunctionDeclaration.js +14 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonUiSchemaFunctionDeclaration.js +18 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_jsonZodSchemaFunctionDeclaration.js +30 -0
- package/dist/generators/ts/_ObjectType/ObjectType_propertiesFromRdfFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/{ObjectType_rdfFunctionDeclarations.js → ObjectType_propertiesFromRdfFunctionDeclaration.js} +5 -37
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +5 -1
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js +35 -5
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts +4 -1
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +7 -3
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.js +57 -0
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlWherePatternsFunctionDeclarations.d.ts +5 -0
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlWherePatternsFunctionDeclarations.js +106 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromJsonFunctionDeclaration.js +19 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.d.ts +5 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_fromRdfFunctionDeclarations.js +20 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.js +14 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.js +15 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlWherePatternsFunctionDeclaration.js +35 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.d.ts +5 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toJsonFunctionDeclaration.js +26 -0
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_toRdfFunctionDeclarations.d.ts +5 -0
- package/dist/generators/ts/_ObjectUnionType/{ObjectUnionType_rdfFunctionDeclarations.js → ObjectUnionType_toRdfFunctionDeclarations.js} +6 -23
- package/dist/generators/ts/_snippets/snippets_LazyObject.js +4 -4
- package/dist/generators/ts/_snippets/snippets_LazyObjectOption.js +4 -4
- package/dist/generators/ts/_snippets/snippets_LazyObjectSet.js +4 -4
- package/dist/generators/ts/_snippets/snippets_SparqlConstructTriplesFunctionParameters.js +2 -2
- package/dist/generators/ts/_snippets/snippets_SparqlWherePatternsFunctionParameters.js +3 -3
- package/dist/generators/ts/_snippets/snippets_booleanSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_dateSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_defaultValueSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_iriSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_listSparqlConstructTriples.js +5 -5
- package/dist/generators/ts/_snippets/snippets_listSparqlWherePatterns.js +2 -0
- package/dist/generators/ts/_snippets/snippets_maybeSparqlConstructTriples.js +1 -1
- package/dist/generators/ts/_snippets/snippets_maybeSparqlWherePatterns.js +3 -3
- package/dist/generators/ts/_snippets/snippets_numericSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_setSparqlConstructTriples.js +1 -1
- package/dist/generators/ts/_snippets/snippets_setSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlConstructTriples.js +2 -2
- package/dist/generators/ts/_snippets/snippets_shaclPropertySparqlWherePatterns.js +3 -3
- package/dist/generators/ts/_snippets/snippets_stringSparqlWherePatterns.js +1 -1
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +1 -0
- package/dist/generators/ts/objectSetMethodSignatures.js +1 -1
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.js +13 -8
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.js +6 -6
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +2 -2
- package/dist/generators/ts/_ObjectType/ObjectType_jsonFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_rdfFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlFunctionDeclarations.js +0 -143
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonFunctionDeclarations.js +0 -50
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_rdfFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlFunctionDeclarations.d.ts +0 -4
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlFunctionDeclarations.js +0 -45
|
@@ -36,6 +36,7 @@ function ${syntheticNamePrefix}listSparqlWherePatterns<ItemFilterT, ItemSchemaT>
|
|
|
36
36
|
},
|
|
37
37
|
...itemSparqlWherePatternsFunction({
|
|
38
38
|
filter: parameters.filter,
|
|
39
|
+
ignoreRdfType: parameters.ignoreRdfType,
|
|
39
40
|
preferredLanguages: parameters.preferredLanguages,
|
|
40
41
|
propertyPatterns: [],
|
|
41
42
|
schema: parameters.schema.item(),
|
|
@@ -91,6 +92,7 @@ function ${syntheticNamePrefix}listSparqlWherePatterns<ItemFilterT, ItemSchemaT>
|
|
|
91
92
|
},
|
|
92
93
|
...itemSparqlWherePatternsFunction({
|
|
93
94
|
filter: parameters.filter,
|
|
95
|
+
ignoreRdfType: parameters.ignoreRdfType,
|
|
94
96
|
preferredLanguages: parameters.preferredLanguages,
|
|
95
97
|
propertyPatterns: [],
|
|
96
98
|
schema: parameters.schema.item(),
|
|
@@ -5,6 +5,6 @@ import { snippets_MaybeSchema } from "./snippets_MaybeSchema.js";
|
|
|
5
5
|
import { snippets_SparqlConstructTriplesFunction } from "./snippets_SparqlConstructTriplesFunction.js";
|
|
6
6
|
export const snippets_maybeSparqlConstructTriples = conditionalOutput(`${syntheticNamePrefix}maybeSparqlConstructTriples`, code `\
|
|
7
7
|
function ${syntheticNamePrefix}maybeSparqlConstructTriples<ItemFilterT, ItemSchemaT>(itemSparqlConstructTriplesFunction: ${snippets_SparqlConstructTriplesFunction}<ItemFilterT, ItemSchemaT>): ${snippets_SparqlConstructTriplesFunction}<${snippets_MaybeFilter}<ItemFilterT>, ${snippets_MaybeSchema}<ItemSchemaT>> {
|
|
8
|
-
return ({ filter, schema, ...otherParameters }) => itemSparqlConstructTriplesFunction({ filter: filter ?? undefined, schema: schema.item()
|
|
8
|
+
return ({ filter, schema, ...otherParameters }) => itemSparqlConstructTriplesFunction({ ...otherParameters, filter: filter ?? undefined, schema: schema.item() });
|
|
9
9
|
}`);
|
|
10
10
|
//# sourceMappingURL=snippets_maybeSparqlConstructTriples.js.map
|
|
@@ -9,18 +9,18 @@ function ${syntheticNamePrefix}maybeSparqlWherePatterns<ItemFilterT, ItemSchemaT
|
|
|
9
9
|
return ({ filter, schema, ...otherParameters }) => {
|
|
10
10
|
if (filter === undefined) {
|
|
11
11
|
// Treat the item's patterns as optional
|
|
12
|
-
const [itemSparqlWherePatterns, liftSparqlPatterns] = ${snippets_liftSparqlPatterns}(itemSparqlWherePatternsFunction({ filter, schema: schema.item()
|
|
12
|
+
const [itemSparqlWherePatterns, liftSparqlPatterns] = ${snippets_liftSparqlPatterns}(itemSparqlWherePatternsFunction({ ...otherParameters, filter, schema: schema.item() }));
|
|
13
13
|
return [{ patterns: itemSparqlWherePatterns.concat(), type: "optional" }, ...liftSparqlPatterns];
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
if (filter === null) {
|
|
17
17
|
// Use FILTER NOT EXISTS around the item's patterns
|
|
18
|
-
const [itemSparqlWherePatterns, liftSparqlPatterns] = ${snippets_liftSparqlPatterns}(itemSparqlWherePatternsFunction({ schema: schema.item()
|
|
18
|
+
const [itemSparqlWherePatterns, liftSparqlPatterns] = ${snippets_liftSparqlPatterns}(itemSparqlWherePatternsFunction({ ...otherParameters, filter: undefined, schema: schema.item() }));
|
|
19
19
|
return [{ expression: { args: itemSparqlWherePatterns.concat(), operator: "notexists", type: "operation" }, lift: true, type: "filter" }, ...liftSparqlPatterns]
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
// Treat the item as required.
|
|
23
|
-
return itemSparqlWherePatternsFunction({ filter, schema: schema.item()
|
|
23
|
+
return itemSparqlWherePatternsFunction({ ...otherParameters, filter, schema: schema.item() });
|
|
24
24
|
}
|
|
25
25
|
}`);
|
|
26
26
|
//# sourceMappingURL=snippets_maybeSparqlWherePatterns.js.map
|
|
@@ -66,6 +66,6 @@ function ${syntheticNamePrefix}numericSparqlWherePatterns<T extends bigint | num
|
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
return ${snippets_termSchemaSparqlPatterns}({ filterPatterns, valueVariable
|
|
69
|
+
return ${snippets_termSchemaSparqlPatterns}({ ...otherParameters, filterPatterns, valueVariable });
|
|
70
70
|
}`);
|
|
71
71
|
//# sourceMappingURL=snippets_numericSparqlWherePatterns.js.map
|
|
@@ -5,6 +5,6 @@ import { snippets_CollectionSchema } from "./snippets_CollectionSchema.js";
|
|
|
5
5
|
import { snippets_SparqlConstructTriplesFunction } from "./snippets_SparqlConstructTriplesFunction.js";
|
|
6
6
|
export const snippets_setSparqlConstructTriples = conditionalOutput(`${syntheticNamePrefix}setSparqlConstructTriples`, code `\
|
|
7
7
|
function ${syntheticNamePrefix}setSparqlConstructTriples<ItemFilterT, ItemSchemaT>(itemSparqlConstructTriplesFunction: ${snippets_SparqlConstructTriplesFunction}<ItemFilterT, ItemSchemaT>): ${snippets_SparqlConstructTriplesFunction}<${snippets_CollectionFilter}<ItemFilterT>, ${snippets_CollectionSchema}<ItemSchemaT>> {
|
|
8
|
-
return ({
|
|
8
|
+
return ({ schema, ...otherParameters }) => itemSparqlConstructTriplesFunction({ ...otherParameters, schema: schema.item() });
|
|
9
9
|
}`);
|
|
10
10
|
//# sourceMappingURL=snippets_setSparqlConstructTriples.js.map
|
|
@@ -7,7 +7,7 @@ import { snippets_SparqlWherePatternsFunction } from "./snippets_SparqlWherePatt
|
|
|
7
7
|
export const snippets_setSparqlWherePatterns = conditionalOutput(`${syntheticNamePrefix}setSparqlWherePatterns`, code `\
|
|
8
8
|
function ${syntheticNamePrefix}setSparqlWherePatterns<ItemFilterT, ItemSchemaT>(itemSparqlWherePatternsFunction: ${snippets_SparqlWherePatternsFunction}<ItemFilterT, ItemSchemaT>): ${snippets_SparqlWherePatternsFunction}<${snippets_CollectionFilter}<ItemFilterT>, ${snippets_CollectionSchema}<ItemSchemaT>> {
|
|
9
9
|
return ({ filter, schema, ...otherParameters }) => {
|
|
10
|
-
const itemSparqlWherePatterns = itemSparqlWherePatternsFunction({ filter, schema: schema.item()
|
|
10
|
+
const itemSparqlWherePatterns = itemSparqlWherePatternsFunction({ ...otherParameters, filter, schema: schema.item() });
|
|
11
11
|
|
|
12
12
|
const minCount = filter?.${syntheticNamePrefix}minCount ?? schema.minCount ?? 0;
|
|
13
13
|
if (minCount > 0) {
|
|
@@ -5,9 +5,9 @@ import { snippets_ShaclPropertySchema } from "./snippets_ShaclPropertySchema.js"
|
|
|
5
5
|
import { snippets_SparqlConstructTriplesFunction } from "./snippets_SparqlConstructTriplesFunction.js";
|
|
6
6
|
export const snippets_shaclPropertySparqlConstructTriples = conditionalOutput(`${syntheticNamePrefix}shaclPropertySparqlConstructTriples`, code `\
|
|
7
7
|
function ${syntheticNamePrefix}shaclPropertySparqlConstructTriples<FilterT, TypeSchemaT>({ filter, focusIdentifier, ignoreRdfType, propertyName, propertySchema, typeSparqlConstructTriples, variablePrefix }: {
|
|
8
|
-
filter
|
|
8
|
+
filter: FilterT | undefined;
|
|
9
9
|
focusIdentifier: ${imports.NamedNode} | ${imports.Variable},
|
|
10
|
-
ignoreRdfType
|
|
10
|
+
ignoreRdfType: boolean;
|
|
11
11
|
propertySchema: ${snippets_ShaclPropertySchema}<TypeSchemaT>;
|
|
12
12
|
propertyName: string;
|
|
13
13
|
typeSparqlConstructTriples: ${snippets_SparqlConstructTriplesFunction}<FilterT, TypeSchemaT>;
|
|
@@ -7,10 +7,10 @@ import { snippets_SparqlWherePatternsFunction } from "./snippets_SparqlWherePatt
|
|
|
7
7
|
import { snippets_sparqlPropertyPath } from "./snippets_sparqlPropertyPath.js";
|
|
8
8
|
export const snippets_shaclPropertySparqlWherePatterns = conditionalOutput(`${syntheticNamePrefix}shaclPropertySparqlWherePatterns`, code `\
|
|
9
9
|
function ${syntheticNamePrefix}shaclPropertySparqlWherePatterns<FilterT, TypeSchemaT>({ filter, focusIdentifier, ignoreRdfType, preferredLanguages, propertyName, propertySchema, typeSparqlWherePatterns, variablePrefix }: {
|
|
10
|
-
filter
|
|
10
|
+
filter: FilterT | undefined;
|
|
11
11
|
focusIdentifier: ${imports.NamedNode} | ${imports.Variable},
|
|
12
|
-
ignoreRdfType
|
|
13
|
-
preferredLanguages
|
|
12
|
+
ignoreRdfType: boolean;
|
|
13
|
+
preferredLanguages: readonly string[] | undefined;
|
|
14
14
|
propertySchema: ${snippets_ShaclPropertySchema}<TypeSchemaT>;
|
|
15
15
|
propertyName: string;
|
|
16
16
|
typeSparqlWherePatterns: ${snippets_SparqlWherePatternsFunction}<FilterT, TypeSchemaT>;
|
|
@@ -42,6 +42,6 @@ const ${syntheticNamePrefix}stringSparqlWherePatterns: ${snippets_SparqlWherePat
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
return ${snippets_literalSchemaSparqlPatterns}({ filterPatterns, valueVariable
|
|
45
|
+
return ${snippets_literalSchemaSparqlPatterns}({ ...otherParameters, filterPatterns, valueVariable });
|
|
46
46
|
}`);
|
|
47
47
|
//# sourceMappingURL=snippets_stringSparqlWherePatterns.js.map
|
|
@@ -9,7 +9,7 @@ export function objectSetMethodSignatures(parameters) {
|
|
|
9
9
|
return {
|
|
10
10
|
object: {
|
|
11
11
|
name: methodNames.object,
|
|
12
|
-
parameters: code `${parameterNamePrefix}identifier: ${objectType.identifierTypeAlias}`,
|
|
12
|
+
parameters: code `${parameterNamePrefix}identifier: ${objectType.identifierTypeAlias}, options?: { preferredLanguages?: readonly string[]; }`,
|
|
13
13
|
returnType: code `Promise<${imports.Either}<Error, ${objectType.name}>>`,
|
|
14
14
|
},
|
|
15
15
|
objectCount: {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { snippets_FromRdfOptions } from "./_snippets/snippets_FromRdfOptions.js";
|
|
1
2
|
import { imports } from "./imports.js";
|
|
2
3
|
import { objectSetMethodSignatures } from "./objectSetMethodSignatures.js";
|
|
3
4
|
import { snippets } from "./snippets.js";
|
|
@@ -8,7 +9,7 @@ export function rdfjsDatasetObjectSetClassDeclaration({ objectTypes, objectUnion
|
|
|
8
9
|
const objectTypeType = code `\
|
|
9
10
|
{
|
|
10
11
|
${syntheticNamePrefix}filter: (filter: ObjectFilterT, value: ObjectT) => boolean;
|
|
11
|
-
${syntheticNamePrefix}fromRdf: (resource: ${imports.Resource}, options
|
|
12
|
+
${syntheticNamePrefix}fromRdf: (resource: ${imports.Resource}, options?: ${snippets_FromRdfOptions}) => ${imports.Either}<Error, ObjectT>;
|
|
12
13
|
${syntheticNamePrefix}fromRdfTypes: readonly ${imports.NamedNode}[]
|
|
13
14
|
}`;
|
|
14
15
|
const parameters = {
|
|
@@ -52,12 +53,12 @@ export class ${syntheticNamePrefix}RdfjsDatasetObjectSet implements ${syntheticN
|
|
|
52
53
|
// object
|
|
53
54
|
code `\
|
|
54
55
|
async ${methodSignatures.object.name}(${methodSignatures.object.parameters}): ${methodSignatures.object.returnType} {
|
|
55
|
-
return this.${methodSignatures.object.name}Sync(identifier);
|
|
56
|
+
return this.${methodSignatures.object.name}Sync(identifier, options);
|
|
56
57
|
}`,
|
|
57
58
|
// objectSync
|
|
58
59
|
code `\
|
|
59
60
|
${methodSignatures.object.name}Sync(${methodSignatures.object.parameters}): ${imports.Either}<Error, ${objectType.name}> {
|
|
60
|
-
return this.${methodSignatures.objects.name}Sync({ identifiers: [identifier] }).map(objects => objects[0]);
|
|
61
|
+
return this.${methodSignatures.objects.name}Sync({ identifiers: [identifier], preferredLanguages: options?.preferredLanguages }).map(objects => objects[0]);
|
|
61
62
|
}`,
|
|
62
63
|
// objectCount
|
|
63
64
|
code `\
|
|
@@ -125,6 +126,8 @@ protected ${syntheticNamePrefix}objectsSync<${typeParameters.ObjectT}, ${typePar
|
|
|
125
126
|
let offset = query?.offset ?? 0;
|
|
126
127
|
if (offset < 0) { offset = 0; }
|
|
127
128
|
|
|
129
|
+
const fromRdfOptions: ${snippets_FromRdfOptions} = { graph, objectSet: this, preferredLanguages: query?.preferredLanguages };
|
|
130
|
+
|
|
128
131
|
let resources: { object?: ObjectT, resource: ${imports.Resource} }[];
|
|
129
132
|
const resourceSet = this.${syntheticNamePrefix}resourceSet(); // Access once, in case it's instantiated lazily
|
|
130
133
|
let sortResources: boolean;
|
|
@@ -166,7 +169,7 @@ protected ${syntheticNamePrefix}objectsSync<${typeParameters.ObjectT}, ${typePar
|
|
|
166
169
|
identifierSet.add(quad.subject);
|
|
167
170
|
const resource = resourceSet.resource(quad.subject);
|
|
168
171
|
// Eagerly eliminate the majority of resources that won't match the object type
|
|
169
|
-
objectType.${syntheticNamePrefix}fromRdf(resource,
|
|
172
|
+
objectType.${syntheticNamePrefix}fromRdf(resource, fromRdfOptions).ifRight(object => {
|
|
170
173
|
resources.push({ object, resource });
|
|
171
174
|
});
|
|
172
175
|
}
|
|
@@ -181,7 +184,7 @@ protected ${syntheticNamePrefix}objectsSync<${typeParameters.ObjectT}, ${typePar
|
|
|
181
184
|
const objects: ObjectT[] = [];
|
|
182
185
|
for (let { object, resource } of resources) {
|
|
183
186
|
if (!object) {
|
|
184
|
-
const objectEither = objectType.${syntheticNamePrefix}fromRdf(resource,
|
|
187
|
+
const objectEither = objectType.${syntheticNamePrefix}fromRdf(resource, fromRdfOptions);
|
|
185
188
|
if (objectEither.isLeft()) {
|
|
186
189
|
return objectEither;
|
|
187
190
|
}
|
|
@@ -215,6 +218,8 @@ protected ${syntheticNamePrefix}objectUnionsSync<${typeParameters.ObjectT}, ${ty
|
|
|
215
218
|
let offset = query?.offset ?? 0;
|
|
216
219
|
if (offset < 0) { offset = 0; }
|
|
217
220
|
|
|
221
|
+
const fromRdfOptions: ${snippets_FromRdfOptions} = { graph, objectSet: this, preferredLanguages: query?.preferredLanguages };
|
|
222
|
+
|
|
218
223
|
let resources: { object?: ObjectT, objectType?: ${objectTypeType}, resource: ${imports.Resource} }[];
|
|
219
224
|
const resourceSet = this.${syntheticNamePrefix}resourceSet(); // Access once, in case it's instantiated lazily
|
|
220
225
|
let sortResources: boolean;
|
|
@@ -259,7 +264,7 @@ protected ${syntheticNamePrefix}objectUnionsSync<${typeParameters.ObjectT}, ${ty
|
|
|
259
264
|
// Eagerly eliminate the majority of resources that won't match the object types
|
|
260
265
|
const resource = resourceSet.resource(quad.subject);
|
|
261
266
|
for (const objectType of objectTypes) {
|
|
262
|
-
if (objectType.${syntheticNamePrefix}fromRdf(resource,
|
|
267
|
+
if (objectType.${syntheticNamePrefix}fromRdf(resource, fromRdfOptions).ifRight(object => {
|
|
263
268
|
resources.push({ object, objectType, resource });
|
|
264
269
|
}).isRight()) {
|
|
265
270
|
break;
|
|
@@ -279,11 +284,11 @@ protected ${syntheticNamePrefix}objectUnionsSync<${typeParameters.ObjectT}, ${ty
|
|
|
279
284
|
if (!object) {
|
|
280
285
|
let objectEither: ${imports.Either}<Error, ObjectT>;
|
|
281
286
|
if (objectType) {
|
|
282
|
-
objectEither = objectType.${syntheticNamePrefix}fromRdf(resource,
|
|
287
|
+
objectEither = objectType.${syntheticNamePrefix}fromRdf(resource, fromRdfOptions);
|
|
283
288
|
} else {
|
|
284
289
|
objectEither = ${imports.Left}(new Error("no object types"));
|
|
285
290
|
for (const tryObjectType of objectTypes) {
|
|
286
|
-
objectEither = tryObjectType.${syntheticNamePrefix}fromRdf(resource,
|
|
291
|
+
objectEither = tryObjectType.${syntheticNamePrefix}fromRdf(resource, fromRdfOptions);
|
|
287
292
|
if (objectEither.isRight()) {
|
|
288
293
|
objectType = tryObjectType;
|
|
289
294
|
break;
|
|
@@ -5,11 +5,11 @@ import { syntheticNamePrefix } from "./syntheticNamePrefix.js";
|
|
|
5
5
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
6
6
|
import { unsupportedObjectSetMethodDeclarations } from "./unsupportedObjectSetMethodDeclarations.js";
|
|
7
7
|
export function sparqlObjectSetClassDeclaration({ objectTypes, objectUnionTypes, }) {
|
|
8
|
-
const sparqlWherePatternsFunctionType = code `(parameters
|
|
8
|
+
const sparqlWherePatternsFunctionType = code `(parameters: { filter: ObjectFilterT | undefined; focusIdentifier: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType: boolean; preferredLanguages: readonly string[] | undefined; variablePrefix: string; }) => readonly ${imports.sparqljs}.Pattern[]`;
|
|
9
9
|
const parameters = {
|
|
10
10
|
constructObjectType: code `objectType: {\
|
|
11
|
-
${syntheticNamePrefix}fromRdf: (resource: ${imports.Resource}, options: { graph?: Exclude<${imports.Quad_Graph}, ${imports.Variable}>; objectSet: ${syntheticNamePrefix}ObjectSet }) => ${imports.Either}<Error, ObjectT>;
|
|
12
|
-
${syntheticNamePrefix}sparqlConstructQueryString: (parameters
|
|
11
|
+
${syntheticNamePrefix}fromRdf: (resource: ${imports.Resource}, options: { graph?: Exclude<${imports.Quad_Graph}, ${imports.Variable}>; objectSet: ${syntheticNamePrefix}ObjectSet; preferredLanguages?: readonly string[]; }) => ${imports.Either}<Error, ObjectT>;
|
|
12
|
+
${syntheticNamePrefix}sparqlConstructQueryString: (parameters: { filter?: ObjectFilterT; subject: ${imports.NamedNode} | ${imports.Variable}; } & Omit<${imports.sparqljs}.ConstructQuery, "prefixes" | "queryType" | "type"> & ${imports.sparqljs}.GeneratorOptions) => string;
|
|
13
13
|
${syntheticNamePrefix}sparqlWherePatterns: ${sparqlWherePatternsFunctionType};
|
|
14
14
|
}`,
|
|
15
15
|
query: code `query?: ${syntheticNamePrefix}SparqlObjectSet.Query<ObjectFilterT, ObjectIdentifierT>`,
|
|
@@ -45,7 +45,7 @@ ${joinCode([...objectTypes, ...objectUnionTypes].flatMap((objectType) => {
|
|
|
45
45
|
return [
|
|
46
46
|
code `\
|
|
47
47
|
async ${methodSignatures.object.name}(${methodSignatures.object.parameters}): ${methodSignatures.object.returnType} {
|
|
48
|
-
return (await this.${methodSignatures.objects.name}({ identifiers: [identifier] })).map(objects => objects[0]);
|
|
48
|
+
return (await this.${methodSignatures.objects.name}({ identifiers: [identifier], preferredLanguages: options?.preferredLanguages })).map(objects => objects[0]);
|
|
49
49
|
}`,
|
|
50
50
|
code `\
|
|
51
51
|
async ${methodSignatures.objectCount.name}(${methodSignatures.objectCount.parameters}): ${methodSignatures.objectCount.returnType} {
|
|
@@ -162,7 +162,7 @@ async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}):
|
|
|
162
162
|
const dataset = ${imports.datasetFactory}.dataset(quads.concat());
|
|
163
163
|
const objects: ObjectT[] = [];
|
|
164
164
|
for (const identifier of identifiers) {
|
|
165
|
-
objects.push(await liftEither(objectType.${syntheticNamePrefix}fromRdf(new ${imports.Resource}(dataset, identifier as ${imports.NamedNode}), { objectSet: this })));
|
|
165
|
+
objects.push(await liftEither(objectType.${syntheticNamePrefix}fromRdf(new ${imports.Resource}(dataset, identifier as ${imports.NamedNode}), { objectSet: this, preferredLanguages: query?.preferredLanguages })));
|
|
166
166
|
}
|
|
167
167
|
return objects;
|
|
168
168
|
});
|
|
@@ -211,7 +211,7 @@ async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}):
|
|
|
211
211
|
patterns = patterns.concat(query.where(this.${syntheticNamePrefix}objectVariable));
|
|
212
212
|
}
|
|
213
213
|
|
|
214
|
-
patterns = patterns.concat(objectType.${syntheticNamePrefix}sparqlWherePatterns({ filter: query?.filter, focusIdentifier: this.${syntheticNamePrefix}objectVariable }));
|
|
214
|
+
patterns = patterns.concat(objectType.${syntheticNamePrefix}sparqlWherePatterns({ filter: query?.filter, focusIdentifier: this.${syntheticNamePrefix}objectVariable, ignoreRdfType: false, preferredLanguages: query?.preferredLanguages, variablePrefix: this.${syntheticNamePrefix}objectVariable.value }));
|
|
215
215
|
|
|
216
216
|
patterns = ${snippets.normalizeSparqlWherePatterns}(patterns).concat();
|
|
217
217
|
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export * from "./Compiler.js";
|
|
|
3
3
|
export type { Generator } from "./generators/Generator.js";
|
|
4
4
|
export { AstJsonGenerator } from "./generators/json/AstJsonGenerator.js";
|
|
5
5
|
export { TsGenerator } from "./generators/ts/TsGenerator.js";
|
|
6
|
+
export { ZodGenerator } from "./generators/ts/ZodGenerator.js";
|
|
6
7
|
export * from "./input/ShapesGraph.js";
|
|
7
8
|
export * from "./ShapesGraphToAstTransformer.js";
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * as ast from "./ast/index.js";
|
|
|
2
2
|
export * from "./Compiler.js";
|
|
3
3
|
export { AstJsonGenerator } from "./generators/json/AstJsonGenerator.js";
|
|
4
4
|
export { TsGenerator } from "./generators/ts/TsGenerator.js";
|
|
5
|
+
export { ZodGenerator } from "./generators/ts/ZodGenerator.js";
|
|
5
6
|
export * from "./input/ShapesGraph.js";
|
|
6
7
|
export * from "./ShapesGraphToAstTransformer.js";
|
|
7
8
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@shaclmate/shacl-ast": "4.0.
|
|
3
|
+
"@shaclmate/shacl-ast": "4.0.7",
|
|
4
4
|
"@rdfjs/data-model": "~2.1.1",
|
|
5
5
|
"@rdfjs/dataset": "~2.0.2",
|
|
6
6
|
"@rdfjs/prefix-map": "~0.1.2",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
},
|
|
81
81
|
"type": "module",
|
|
82
82
|
"types": "./dist/index.d.ts",
|
|
83
|
-
"version": "4.0.
|
|
83
|
+
"version": "4.0.7"
|
|
84
84
|
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ObjectType } from "../ObjectType.js";
|
|
2
|
-
import { type Code } from "../ts-poet-wrapper.js";
|
|
3
|
-
export declare function ObjectType_sparqlFunctionDeclarations(this: ObjectType): readonly Code[];
|
|
4
|
-
//# sourceMappingURL=ObjectType_sparqlFunctionDeclarations.d.ts.map
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
import { rdf, rdfs } from "@tpluscode/rdf-ns-builders";
|
|
2
|
-
import { camelCase } from "change-case";
|
|
3
|
-
import { imports } from "../imports.js";
|
|
4
|
-
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
5
|
-
import { snippets } from "../snippets.js";
|
|
6
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
7
|
-
import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
|
|
8
|
-
import { ObjectType_sparqlConstructQueryFunctionDeclaration } from "./ObjectType_sparqlConstructQueryFunctionDeclaration.js";
|
|
9
|
-
import { ObjectType_sparqlConstructQueryStringFunctionDeclaration } from "./ObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
|
|
10
|
-
export function ObjectType_sparqlFunctionDeclarations() {
|
|
11
|
-
if (!this.features.has("sparql")) {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
const variables = {
|
|
15
|
-
filter: code `parameters?.filter`,
|
|
16
|
-
preferredLanguages: code `parameters?.preferredLanguages`,
|
|
17
|
-
focusIdentifier: code `focusIdentifier`,
|
|
18
|
-
variablePrefix: code `(parameters?.variablePrefix ?? (focusIdentifier.termType === "Variable" ? focusIdentifier.value : ${literalOf(camelCase(this.name))}))`,
|
|
19
|
-
};
|
|
20
|
-
const rdfClassVariable = code `${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
|
|
21
|
-
const rdfTypeVariable = code `${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
|
|
22
|
-
let patternsVariableDeclarationKeyword = "const";
|
|
23
|
-
let triplesVariableDeclarationKeyword = "const";
|
|
24
|
-
const sparqlConstructTriplesStatements = [];
|
|
25
|
-
const sparqlWherePatternsStatements = [];
|
|
26
|
-
for (const parentObjectType of this.parentObjectTypes) {
|
|
27
|
-
sparqlConstructTriplesStatements.push(code `triples = triples.concat(${parentObjectType.staticModuleName}.${syntheticNamePrefix}sparqlConstructTriples(${{ focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, variablePrefix: variables.variablePrefix }}));`);
|
|
28
|
-
triplesVariableDeclarationKeyword = "let";
|
|
29
|
-
sparqlWherePatternsStatements.push(code `\
|
|
30
|
-
patterns = patterns.concat(${parentObjectType.staticModuleName}.${syntheticNamePrefix}sparqlWherePatterns(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, variablePrefix: variables.variablePrefix }}));`);
|
|
31
|
-
patternsVariableDeclarationKeyword = "let";
|
|
32
|
-
}
|
|
33
|
-
if (this.fromRdfType.isJust()) {
|
|
34
|
-
const fromRdfTypeVariables = this.fromRdfTypeVariable
|
|
35
|
-
.toList()
|
|
36
|
-
.concat(this.descendantFromRdfTypeVariables);
|
|
37
|
-
sparqlConstructTriplesStatements.push(code `\
|
|
38
|
-
if (!parameters?.ignoreRdfType) {
|
|
39
|
-
triples.push(
|
|
40
|
-
{ subject: focusIdentifier, predicate: ${rdfjsTermExpression(rdf.type)}, object: ${rdfTypeVariable} },
|
|
41
|
-
{ subject: ${rdfTypeVariable}, predicate: ${rdfjsTermExpression(rdfs.subClassOf)}, object: ${rdfClassVariable} }
|
|
42
|
-
);
|
|
43
|
-
}`);
|
|
44
|
-
sparqlWherePatternsStatements.push(code `const rdfTypeVariable = ${rdfTypeVariable};`, code `\
|
|
45
|
-
if (!parameters?.ignoreRdfType) {
|
|
46
|
-
patterns.push(
|
|
47
|
-
${fromRdfTypeVariables.length > 1
|
|
48
|
-
? code `\
|
|
49
|
-
{
|
|
50
|
-
type: "values" as const,
|
|
51
|
-
values: [${joinCode(fromRdfTypeVariables, { on: "," })}].map((identifier) => {
|
|
52
|
-
const valuePatternRow: ${imports.sparqljs}.ValuePatternRow = {};
|
|
53
|
-
valuePatternRow[\`?\${${variables.variablePrefix}}FromRdfType\`] = identifier as ${imports.NamedNode};
|
|
54
|
-
return valuePatternRow;
|
|
55
|
-
}),
|
|
56
|
-
},
|
|
57
|
-
${snippets.sparqlInstancesOfPattern}({ rdfType: ${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}FromRdfType\`), subject: focusIdentifier }),`
|
|
58
|
-
: code `${snippets.sparqlInstancesOfPattern}({ rdfType: ${fromRdfTypeVariables[0]}, subject: focusIdentifier }),`}
|
|
59
|
-
{
|
|
60
|
-
triples: [
|
|
61
|
-
{
|
|
62
|
-
subject: focusIdentifier,
|
|
63
|
-
predicate: ${rdfjsTermExpression(rdf.type)},
|
|
64
|
-
object: rdfTypeVariable
|
|
65
|
-
}
|
|
66
|
-
],
|
|
67
|
-
type: "bgp" as const
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
patterns: [
|
|
71
|
-
{
|
|
72
|
-
triples: [
|
|
73
|
-
{
|
|
74
|
-
subject: rdfTypeVariable,
|
|
75
|
-
predicate: {
|
|
76
|
-
items: [${rdfjsTermExpression(rdfs.subClassOf)}],
|
|
77
|
-
pathType: "+" as const,
|
|
78
|
-
type: "path" as const
|
|
79
|
-
},
|
|
80
|
-
object: ${rdfClassVariable}
|
|
81
|
-
}
|
|
82
|
-
],
|
|
83
|
-
type: "bgp" as const
|
|
84
|
-
}
|
|
85
|
-
],
|
|
86
|
-
type: "optional" as const
|
|
87
|
-
}
|
|
88
|
-
);
|
|
89
|
-
}`);
|
|
90
|
-
}
|
|
91
|
-
for (const property of this.ownProperties) {
|
|
92
|
-
if (property.recursive) {
|
|
93
|
-
continue;
|
|
94
|
-
}
|
|
95
|
-
property
|
|
96
|
-
.sparqlConstructTriplesExpression({
|
|
97
|
-
variables,
|
|
98
|
-
})
|
|
99
|
-
.ifJust((propertyTriples) => {
|
|
100
|
-
sparqlConstructTriplesStatements.push(code `triples = triples.concat(${propertyTriples});`);
|
|
101
|
-
triplesVariableDeclarationKeyword = "let";
|
|
102
|
-
});
|
|
103
|
-
property
|
|
104
|
-
.sparqlWherePatternsExpression({ variables })
|
|
105
|
-
.ifJust(({ condition, patterns }) => {
|
|
106
|
-
const concatStatement = code `patterns = patterns.concat(${patterns});`;
|
|
107
|
-
if (condition) {
|
|
108
|
-
sparqlWherePatternsStatements.push(code `if (${condition}) { ${concatStatement} }`);
|
|
109
|
-
}
|
|
110
|
-
else {
|
|
111
|
-
sparqlWherePatternsStatements.push(concatStatement);
|
|
112
|
-
}
|
|
113
|
-
patternsVariableDeclarationKeyword = "let";
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
return [
|
|
117
|
-
ObjectType_sparqlConstructQueryFunctionDeclaration.bind(this)(),
|
|
118
|
-
ObjectType_sparqlConstructQueryStringFunctionDeclaration.bind(this)(),
|
|
119
|
-
code `\
|
|
120
|
-
export function ${syntheticNamePrefix}sparqlConstructTriples(${sparqlConstructTriplesStatements.length === 0 ? "_" : ""}parameters?: { filter?: ${this.filterType}; focusIdentifier?: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType?: boolean; variablePrefix?: string }): readonly ${imports.sparqljs}.Triple[] {
|
|
121
|
-
${sparqlConstructTriplesStatements.length > 0
|
|
122
|
-
? joinCode([
|
|
123
|
-
code `const focusIdentifier = parameters?.focusIdentifier ?? ${imports.dataFactory}.variable!(${literalOf(camelCase(this.name))});`,
|
|
124
|
-
code `${triplesVariableDeclarationKeyword} triples: ${imports.sparqljs}.Triple[] = [];`,
|
|
125
|
-
...sparqlConstructTriplesStatements,
|
|
126
|
-
code `return triples;`,
|
|
127
|
-
])
|
|
128
|
-
: "return [];"}
|
|
129
|
-
}`,
|
|
130
|
-
code `\
|
|
131
|
-
export function ${syntheticNamePrefix}sparqlWherePatterns(${sparqlWherePatternsStatements.length === 0 ? "_" : ""}parameters?: { filter?: ${this.filterType}; focusIdentifier?: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType?: boolean; preferredLanguages?: readonly string[]; variablePrefix?: string }): readonly ${snippets.SparqlPattern}[] {
|
|
132
|
-
${sparqlWherePatternsStatements.length > 0
|
|
133
|
-
? joinCode([
|
|
134
|
-
code `${patternsVariableDeclarationKeyword} patterns: ${snippets.SparqlPattern}[] = [];`,
|
|
135
|
-
code `const focusIdentifier = parameters?.focusIdentifier ?? ${imports.dataFactory}.variable!(${literalOf(camelCase(this.name))});`,
|
|
136
|
-
...sparqlWherePatternsStatements,
|
|
137
|
-
code `return patterns;`,
|
|
138
|
-
])
|
|
139
|
-
: "return [];"}
|
|
140
|
-
}`,
|
|
141
|
-
];
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=ObjectType_sparqlFunctionDeclarations.js.map
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { code, joinCode } from "ts-poet";
|
|
2
|
-
import { imports } from "../imports.js";
|
|
3
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
4
|
-
function ObjectUnionType_fromJsonFunctionDeclaration() {
|
|
5
|
-
return code `\
|
|
6
|
-
export function ${syntheticNamePrefix}fromJson(json: unknown): ${imports.Either}<${imports.z}.ZodError, ${this.name}> {
|
|
7
|
-
return ${this.concreteMemberTypes.reduce((expression, memberType) => {
|
|
8
|
-
const memberTypeExpression = code `(${memberType.staticModuleName}.${syntheticNamePrefix}fromJson(json) as ${imports.Either}<${imports.z}.ZodError, ${this.name}>)`;
|
|
9
|
-
return expression !== null
|
|
10
|
-
? code `${expression}.altLazy(() => ${memberTypeExpression})`
|
|
11
|
-
: memberTypeExpression;
|
|
12
|
-
}, null)};
|
|
13
|
-
}`;
|
|
14
|
-
}
|
|
15
|
-
export function jsonFunctionDeclarations() {
|
|
16
|
-
if (!this.features.has("json")) {
|
|
17
|
-
return [];
|
|
18
|
-
}
|
|
19
|
-
return [
|
|
20
|
-
ObjectUnionType_fromJsonFunctionDeclaration.bind(this)(),
|
|
21
|
-
jsonZodSchemaFunctionDeclaration.bind(this)(),
|
|
22
|
-
toJsonFunctionDeclaration.bind(this)(),
|
|
23
|
-
];
|
|
24
|
-
}
|
|
25
|
-
function jsonZodSchemaFunctionDeclaration() {
|
|
26
|
-
return code `\
|
|
27
|
-
export function ${syntheticNamePrefix}jsonZodSchema() {
|
|
28
|
-
return ${imports.z}.discriminatedUnion("${this._discriminantProperty.name}", [${joinCode(this.concreteMemberTypes.map((memberType) => memberType.jsonZodSchema({ context: "type" })), { on: ", " })}]);
|
|
29
|
-
}`;
|
|
30
|
-
}
|
|
31
|
-
function toJsonFunctionDeclaration() {
|
|
32
|
-
return code `\
|
|
33
|
-
export function ${syntheticNamePrefix}toJson(${this.thisVariable}: ${this.name}): ${this.jsonType().name} {
|
|
34
|
-
${joinCode(this.concreteMemberTypes
|
|
35
|
-
.map((memberType) => {
|
|
36
|
-
let returnExpression;
|
|
37
|
-
switch (memberType.declarationType) {
|
|
38
|
-
case "class":
|
|
39
|
-
returnExpression = code `${this.thisVariable}.${syntheticNamePrefix}toJson()`;
|
|
40
|
-
break;
|
|
41
|
-
case "interface":
|
|
42
|
-
returnExpression = code `${memberType.staticModuleName}.${syntheticNamePrefix}toJson(${this.thisVariable})`;
|
|
43
|
-
break;
|
|
44
|
-
}
|
|
45
|
-
return code `if (${memberType.staticModuleName}.is${memberType.name}(${this.thisVariable})) { return ${returnExpression}; }`;
|
|
46
|
-
})
|
|
47
|
-
.concat(code `throw new Error("unrecognized type");`))}
|
|
48
|
-
}`;
|
|
49
|
-
}
|
|
50
|
-
//# sourceMappingURL=ObjectUnionType_jsonFunctionDeclarations.js.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ObjectUnionType } from "../ObjectUnionType.js";
|
|
2
|
-
import { type Code } from "../ts-poet-wrapper.js";
|
|
3
|
-
export declare function rdfFunctionDeclarations(this: ObjectUnionType): readonly Code[];
|
|
4
|
-
//# sourceMappingURL=ObjectUnionType_rdfFunctionDeclarations.d.ts.map
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ObjectUnionType } from "../ObjectUnionType.js";
|
|
2
|
-
import { type Code } from "../ts-poet-wrapper.js";
|
|
3
|
-
export declare function ObjectUnionType_sparqlFunctionDeclarations(this: ObjectUnionType): readonly Code[];
|
|
4
|
-
//# sourceMappingURL=ObjectUnionType_sparqlFunctionDeclarations.d.ts.map
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { camelCase, pascalCase } from "change-case";
|
|
2
|
-
import { ObjectType_sparqlConstructQueryFunctionDeclaration } from "../_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js";
|
|
3
|
-
import { ObjectType_sparqlConstructQueryStringFunctionDeclaration } from "../_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
|
|
4
|
-
import { imports } from "../imports.js";
|
|
5
|
-
import { snippets } from "../snippets.js";
|
|
6
|
-
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
7
|
-
import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
|
|
8
|
-
export function ObjectUnionType_sparqlFunctionDeclarations() {
|
|
9
|
-
if (!this.features.has("sparql")) {
|
|
10
|
-
return [];
|
|
11
|
-
}
|
|
12
|
-
return [
|
|
13
|
-
ObjectType_sparqlConstructQueryFunctionDeclaration.bind(this)(),
|
|
14
|
-
ObjectType_sparqlConstructQueryStringFunctionDeclaration.bind(this)(),
|
|
15
|
-
code `\
|
|
16
|
-
export function ${syntheticNamePrefix}sparqlConstructTriples(parameters?: { filter?: ${this.filterType}; focusIdentifier?: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType?: boolean; variablePrefix?: string }): readonly ${imports.sparqljs}.Triple[] {
|
|
17
|
-
return [${joinCode(this.concreteMemberTypes.map((memberType) => code `...${memberType.staticModuleName}.${syntheticNamePrefix}sparqlConstructTriples({ filter: parameters?.filter?.on?.${memberType.name}, focusIdentifier: parameters?.focusIdentifier ?? ${imports.dataFactory}.variable!("${camelCase(this.name)}${pascalCase(memberType.name)}"), variablePrefix: parameters?.variablePrefix ? \`\${parameters.variablePrefix}${pascalCase(memberType.name)}\` : "${camelCase(this.name)}${pascalCase(memberType.name)}" }).concat()`), { on: ", " })}];
|
|
18
|
-
}`,
|
|
19
|
-
code `\
|
|
20
|
-
export function ${syntheticNamePrefix}sparqlWherePatterns(parameters?: { filter?: ${this.filterType}; focusIdentifier?: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType?: boolean; preferredLanguages?: readonly string[]; variablePrefix?: string }): readonly ${snippets.SparqlPattern}[] {
|
|
21
|
-
${joinCode([
|
|
22
|
-
code `let patterns: ${snippets.SparqlPattern}[] = [];`,
|
|
23
|
-
code `\
|
|
24
|
-
const focusIdentifier = parameters?.focusIdentifier ?? ${imports.dataFactory}.variable!("${camelCase(this.name)}");
|
|
25
|
-
if (focusIdentifier.termType === "Variable") {
|
|
26
|
-
patterns = patterns.concat(${this.identifierType.sparqlWherePatternsFunction}({
|
|
27
|
-
filter: parameters?.filter?.${syntheticNamePrefix}identifier,
|
|
28
|
-
ignoreRdfType: false,
|
|
29
|
-
preferredLanguages: parameters?.preferredLanguages,
|
|
30
|
-
propertyPatterns: [],
|
|
31
|
-
schema: ${this.identifierType.schema},
|
|
32
|
-
valueVariable: focusIdentifier,
|
|
33
|
-
variablePrefix: focusIdentifier.termType === "Variable" ? focusIdentifier.value : ${literalOf(camelCase(this.name))},
|
|
34
|
-
}));
|
|
35
|
-
}`,
|
|
36
|
-
code `patterns.push({ patterns: [${joinCode(this.concreteMemberTypes.map((memberType) => code `${{
|
|
37
|
-
patterns: code `${memberType.staticModuleName}.${syntheticNamePrefix}sparqlWherePatterns({ filter: parameters?.filter?.on?.${memberType.name}, focusIdentifier: parameters?.focusIdentifier ?? ${imports.dataFactory}.variable!("${camelCase(this.name)}${pascalCase(memberType.name)}"), variablePrefix: parameters?.variablePrefix ? \`\${parameters.variablePrefix}${pascalCase(memberType.name)}\` : "${camelCase(this.name)}${pascalCase(memberType.name)}" }).concat()`,
|
|
38
|
-
type: literalOf("group"),
|
|
39
|
-
}}`), { on: ", " })}], type: "union" });`,
|
|
40
|
-
code `return patterns;`,
|
|
41
|
-
])}
|
|
42
|
-
}`,
|
|
43
|
-
];
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=ObjectUnionType_sparqlFunctionDeclarations.js.map
|