@shaclmate/compiler 4.0.4 → 4.0.6
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 +2 -2
- package/dist/generators/ts/ObjectUnionType.js +2 -2
- package/dist/generators/ts/UnionType.js +2 -2
- package/dist/generators/ts/_ObjectType/IdentifierProperty.js +1 -0
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts +1 -0
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js +29 -3
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_ObjectType/ObjectType_sparqlFunctionDeclarations.js +13 -16
- package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_sparqlFunctionDeclarations.js +16 -17
- 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/package.json +2 -2
|
@@ -59,10 +59,10 @@ export class AbstractLazyObjectType extends AbstractType {
|
|
|
59
59
|
}}`;
|
|
60
60
|
}
|
|
61
61
|
get sparqlConstructTriplesFunction() {
|
|
62
|
-
return code `(({ schema, ...otherParameters }) => ${this.partialType.sparqlConstructTriplesFunction}({ schema: schema.partial()
|
|
62
|
+
return code `(({ schema, ...otherParameters }) => ${this.partialType.sparqlConstructTriplesFunction}({ ...otherParameters, schema: schema.partial() }))`;
|
|
63
63
|
}
|
|
64
64
|
get sparqlWherePatternsFunction() {
|
|
65
|
-
return code `(({ schema, ...otherParameters }) => ${this.partialType.sparqlWherePatternsFunction}({ schema: schema.partial()
|
|
65
|
+
return code `(({ schema, ...otherParameters }) => ${this.partialType.sparqlWherePatternsFunction}({ ...otherParameters, schema: schema.partial() }))`;
|
|
66
66
|
}
|
|
67
67
|
get schemaObject() {
|
|
68
68
|
return {
|
|
@@ -69,23 +69,23 @@ export declare abstract class AbstractType {
|
|
|
69
69
|
* A SparqlConstructTriplesFunction (reference or declaration) that returns an array of sparqljs.Triple's for a property of this type.
|
|
70
70
|
*
|
|
71
71
|
* The function takes a parameters object (type: SparqlConstructTriplesFunctionParameters) with the following parameters:
|
|
72
|
-
* - filter
|
|
73
|
-
* - ignoreRdfType
|
|
72
|
+
* - filter: an instance of filterType | undefined
|
|
73
|
+
* - ignoreRdfType: boolean
|
|
74
74
|
* - schema: instance of this.schemaType
|
|
75
75
|
* - valueVariable: rdfjs.Variable of the value of this type
|
|
76
|
-
* - variablePrefix: prefix to use for new variables
|
|
76
|
+
* - variablePrefix: string prefix to use for new variables
|
|
77
77
|
*/
|
|
78
78
|
abstract readonly sparqlConstructTriplesFunction: Code;
|
|
79
79
|
/**
|
|
80
80
|
* A SparqlWherePatternsFunction (reference or declaration) that returns an array of SparqlPattern's for a property of this type.
|
|
81
81
|
*
|
|
82
82
|
* The function takes a parameters object (type: SparqlWherePatternsFunctionParameters) with the following parameters:
|
|
83
|
-
* - filter
|
|
84
|
-
* - preferredLanguages: array of preferred language code (strings)
|
|
83
|
+
* - filter: an instance of filterType | undefined
|
|
84
|
+
* - preferredLanguages: array of preferred language code (strings) | undefined
|
|
85
85
|
* - propertyPatterns: array of sparqljs.Pattern's for the property; may be empty
|
|
86
86
|
* - schema: instance of this.schemaType
|
|
87
87
|
* - valueVariable: rdfjs.Variable of the value of this type
|
|
88
|
-
* - variablePrefix: prefix to use for new variables
|
|
88
|
+
* - variablePrefix: string prefix to use for new variables
|
|
89
89
|
*/
|
|
90
90
|
abstract readonly sparqlWherePatternsFunction: Code;
|
|
91
91
|
/**
|
|
@@ -75,7 +75,7 @@ export class LazyObjectOptionType extends Super {
|
|
|
75
75
|
}
|
|
76
76
|
fromRdfExpression(parameters) {
|
|
77
77
|
const { variables } = parameters;
|
|
78
|
-
return code `${this.partialType.fromRdfExpression(parameters)}.map(values => values.map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: (identifier) => ${variables.objectSet}.${this.resolveType.itemType.objectSetMethodNames.object}(identifier) })))`;
|
|
78
|
+
return code `${this.partialType.fromRdfExpression(parameters)}.map(values => values.map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: (identifier, options) => ${variables.objectSet}.${this.resolveType.itemType.objectSetMethodNames.object}(identifier, options) })))`;
|
|
79
79
|
}
|
|
80
80
|
graphqlResolveExpression({ variables, }) {
|
|
81
81
|
return code `${variables.value}.resolve().then(either => either.unsafeCoerce().extractNullable())`;
|
|
@@ -66,7 +66,7 @@ export class LazyObjectSetType extends AbstractLazyObjectType {
|
|
|
66
66
|
}
|
|
67
67
|
fromRdfExpression(parameters) {
|
|
68
68
|
const { variables } = parameters;
|
|
69
|
-
return code `${this.partialType.fromRdfExpression(parameters)}.map(values => values.map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: (identifiers) => ${variables.objectSet}.${this.resolveType.itemType.objectSetMethodNames.objects}({ identifiers }) })))`;
|
|
69
|
+
return code `${this.partialType.fromRdfExpression(parameters)}.map(values => values.map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: (identifiers, options) => ${variables.objectSet}.${this.resolveType.itemType.objectSetMethodNames.objects}({ identifiers, ...options }) })))`;
|
|
70
70
|
}
|
|
71
71
|
graphqlResolveExpression({ variables, }) {
|
|
72
72
|
return code `(${variables.value}.resolve({ limit: ${variables.args}.limit, offset: ${variables.args}.offset })).then(either => either.unsafeCoerce())`;
|
|
@@ -50,7 +50,7 @@ export class LazyObjectType extends AbstractLazyObjectType {
|
|
|
50
50
|
}
|
|
51
51
|
fromRdfExpression(parameters) {
|
|
52
52
|
const { variables } = parameters;
|
|
53
|
-
return code `${this.partialType.fromRdfExpression(parameters)}.map(values => values.map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: (identifier) => ${variables.objectSet}.${this.resolveType.objectSetMethodNames.object}(identifier) })))`;
|
|
53
|
+
return code `${this.partialType.fromRdfExpression(parameters)}.map(values => values.map(${this.runtimeClass.partialPropertyName} => new ${this.runtimeClass.name}({ ${this.runtimeClass.partialPropertyName}, resolver: (identifier, options) => ${variables.objectSet}.${this.resolveType.objectSetMethodNames.object}(identifier, options) })))`;
|
|
54
54
|
}
|
|
55
55
|
graphqlResolveExpression({ variables, }) {
|
|
56
56
|
return code `${variables.value}.resolve().then(either => either.unsafeCoerce())`;
|
|
@@ -201,10 +201,10 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
201
201
|
return code `typeof ${this.schema}`;
|
|
202
202
|
}
|
|
203
203
|
get sparqlConstructTriplesFunction() {
|
|
204
|
-
return code `(({ ignoreRdfType,
|
|
204
|
+
return code `(({ filter, ignoreRdfType, valueVariable, variablePrefix }: ${snippets.SparqlConstructTriplesFunctionParameters}<${this.filterType}, ${this.schemaType}>) => ${this.staticModuleName}.${syntheticNamePrefix}sparqlConstructTriples({ filter, focusIdentifier: valueVariable, ignoreRdfType, variablePrefix }))`;
|
|
205
205
|
}
|
|
206
206
|
get sparqlWherePatternsFunction() {
|
|
207
|
-
return code `(({ ignoreRdfType,
|
|
207
|
+
return code `(({ filter, ignoreRdfType, preferredLanguages, propertyPatterns, valueVariable, variablePrefix }: ${snippets.SparqlWherePatternsFunctionParameters}<${this.filterType}, ${this.schemaType}>) => (propertyPatterns as readonly ${snippets.SparqlPattern}[]).concat(${this.staticModuleName}.${syntheticNamePrefix}sparqlWherePatterns({ filter, focusIdentifier: valueVariable, ignoreRdfType, preferredLanguages, variablePrefix })))`;
|
|
208
208
|
}
|
|
209
209
|
get toRdfjsResourceType() {
|
|
210
210
|
if (this.parentObjectTypes.length > 0) {
|
|
@@ -120,10 +120,10 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
|
|
|
120
120
|
return code `typeof ${this.schema}`;
|
|
121
121
|
}
|
|
122
122
|
get sparqlConstructTriplesFunction() {
|
|
123
|
-
return code `(({ ignoreRdfType, schema, ...otherParameters }: ${snippets.SparqlConstructTriplesFunctionParameters}<${this.filterType}, ${this.schemaType}>) => ${this.staticModuleName}.${syntheticNamePrefix}sparqlConstructTriples(otherParameters))`;
|
|
123
|
+
return code `(({ ignoreRdfType, schema, valueVariable, ...otherParameters }: ${snippets.SparqlConstructTriplesFunctionParameters}<${this.filterType}, ${this.schemaType}>) => ${this.staticModuleName}.${syntheticNamePrefix}sparqlConstructTriples({ ...otherParameters, focusIdentifier: valueVariable, ignoreRdfType: false }))`;
|
|
124
124
|
}
|
|
125
125
|
get sparqlWherePatternsFunction() {
|
|
126
|
-
return code `(({ ignoreRdfType, propertyPatterns, schema, valueVariable, ...otherParameters }: ${snippets.SparqlWherePatternsFunctionParameters}<${this.filterType}, ${this.schemaType}>) => (propertyPatterns as readonly ${snippets.SparqlPattern}[]).concat(${this.staticModuleName}.${syntheticNamePrefix}sparqlWherePatterns({ focusIdentifier: valueVariable,
|
|
126
|
+
return code `(({ ignoreRdfType, propertyPatterns, schema, valueVariable, ...otherParameters }: ${snippets.SparqlWherePatternsFunctionParameters}<${this.filterType}, ${this.schemaType}>) => (propertyPatterns as readonly ${snippets.SparqlPattern}[]).concat(${this.staticModuleName}.${syntheticNamePrefix}sparqlWherePatterns({ ...otherParameters, focusIdentifier: valueVariable, ignoreRdfType: false })))`;
|
|
127
127
|
}
|
|
128
128
|
get staticModuleName() {
|
|
129
129
|
return this.name;
|
|
@@ -294,7 +294,7 @@ ${memberType.discriminantValues.map((discriminantValue) => `case "${discriminant
|
|
|
294
294
|
let triples: ${imports.sparqljs}.Triple[] = [];
|
|
295
295
|
|
|
296
296
|
${joinCode(this.memberTypes.map((memberType) => code `\
|
|
297
|
-
triples = triples.concat(${memberType.sparqlConstructTriplesFunction}({ filter: filter?.on?.["${memberType.discriminantValues[0]}"], ignoreRdfType: false, schema: schema.members["${memberType.discriminantValues[0]}"].type
|
|
297
|
+
triples = triples.concat(${memberType.sparqlConstructTriplesFunction}({ ...otherParameters, filter: filter?.on?.["${memberType.discriminantValues[0]}"], ignoreRdfType: false, schema: schema.members["${memberType.discriminantValues[0]}"].type }));`))}
|
|
298
298
|
|
|
299
299
|
return triples;
|
|
300
300
|
})`;
|
|
@@ -305,7 +305,7 @@ triples = triples.concat(${memberType.sparqlConstructTriplesFunction}({ filter:
|
|
|
305
305
|
const unionPatterns: ${imports.sparqljs}.GroupPattern[] = [];
|
|
306
306
|
|
|
307
307
|
${joinCode(this.memberTypes.map((memberType) => code `\
|
|
308
|
-
unionPatterns.push({ patterns: ${memberType.sparqlWherePatternsFunction}({ filter: filter?.on?.["${memberType.discriminantValues[0]}"], ignoreRdfType: false, schema: schema.members["${memberType.discriminantValues[0]}"].type
|
|
308
|
+
unionPatterns.push({ patterns: ${memberType.sparqlWherePatternsFunction}({ ...otherParameters, filter: filter?.on?.["${memberType.discriminantValues[0]}"], ignoreRdfType: false, schema: schema.members["${memberType.discriminantValues[0]}"].type }).concat(), type: "group" });`))}
|
|
309
309
|
|
|
310
310
|
return [{ patterns: unionPatterns, type: "union" }];
|
|
311
311
|
})`;
|
|
@@ -300,6 +300,7 @@ export class IdentifierProperty extends AbstractProperty {
|
|
|
300
300
|
condition: code `${variables.focusIdentifier}.termType === "Variable"`,
|
|
301
301
|
patterns: code `${this.type.sparqlWherePatternsFunction}(${{
|
|
302
302
|
filter: code `${variables.filter}?.${this.name}`,
|
|
303
|
+
ignoreRdfType: true, // Unused
|
|
303
304
|
preferredLanguages: variables.preferredLanguages,
|
|
304
305
|
propertyPatterns: code `[]`,
|
|
305
306
|
schema: code `${this.objectType.staticModuleName}.${syntheticNamePrefix}schema.properties.${this.objectType.identifierProperty.name}.type()`,
|
package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type Code } from "../ts-poet-wrapper.js";
|
|
2
2
|
export declare function ObjectType_sparqlConstructQueryFunctionDeclaration(this: {
|
|
3
3
|
readonly filterType: Code;
|
|
4
|
+
readonly name: string;
|
|
4
5
|
readonly staticModuleName: string;
|
|
5
6
|
}): Code;
|
|
6
7
|
//# sourceMappingURL=ObjectType_sparqlConstructQueryFunctionDeclaration.d.ts.map
|
package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js
CHANGED
|
@@ -1,12 +1,38 @@
|
|
|
1
|
+
import { camelCase } from "change-case";
|
|
1
2
|
import { imports } from "../imports.js";
|
|
2
3
|
import { snippets } from "../snippets.js";
|
|
3
4
|
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
4
5
|
import { code } from "../ts-poet-wrapper.js";
|
|
5
6
|
export function ObjectType_sparqlConstructQueryFunctionDeclaration() {
|
|
6
7
|
return code `\
|
|
7
|
-
export function ${syntheticNamePrefix}sparqlConstructQuery(
|
|
8
|
-
const
|
|
9
|
-
|
|
8
|
+
export function ${syntheticNamePrefix}sparqlConstructQuery({ filter, ignoreRdfType, preferredLanguages, prefixes, subject, ...queryParameters }: { filter?: ${this.filterType}; ignoreRdfType?: boolean; prefixes?: { [prefix: string]: string }; preferredLanguages?: readonly string[]; subject: ${imports.NamedNode} | ${imports.Variable} } & Omit<${imports.sparqljs}.ConstructQuery, "prefixes" | "queryType" | "type">): ${imports.sparqljs}.ConstructQuery {
|
|
9
|
+
const variablePrefix = subject.termType === "Variable" ? subject.value : "${camelCase(this.name)}";
|
|
10
|
+
|
|
11
|
+
return {
|
|
12
|
+
...queryParameters,
|
|
13
|
+
prefixes: prefixes ?? {},
|
|
14
|
+
queryType: "CONSTRUCT",
|
|
15
|
+
template: (queryParameters.template ?? []).concat(
|
|
16
|
+
${this.staticModuleName}.${syntheticNamePrefix}sparqlConstructTriples({
|
|
17
|
+
filter,
|
|
18
|
+
focusIdentifier: subject,
|
|
19
|
+
ignoreRdfType: !!ignoreRdfType,
|
|
20
|
+
variablePrefix
|
|
21
|
+
})
|
|
22
|
+
),
|
|
23
|
+
type: "query",
|
|
24
|
+
where: (queryParameters.where ?? []).concat(
|
|
25
|
+
${snippets.normalizeSparqlWherePatterns}(
|
|
26
|
+
${this.staticModuleName}.${syntheticNamePrefix}sparqlWherePatterns({
|
|
27
|
+
filter,
|
|
28
|
+
focusIdentifier: subject,
|
|
29
|
+
ignoreRdfType: !!ignoreRdfType,
|
|
30
|
+
preferredLanguages,
|
|
31
|
+
variablePrefix
|
|
32
|
+
})
|
|
33
|
+
)
|
|
34
|
+
)
|
|
35
|
+
};
|
|
10
36
|
}`;
|
|
11
37
|
}
|
|
12
38
|
//# sourceMappingURL=ObjectType_sparqlConstructQueryFunctionDeclaration.js.map
|
package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js
CHANGED
|
@@ -3,7 +3,7 @@ import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
|
3
3
|
import { code } from "../ts-poet-wrapper.js";
|
|
4
4
|
export function ObjectType_sparqlConstructQueryStringFunctionDeclaration() {
|
|
5
5
|
return code `\
|
|
6
|
-
export function ${syntheticNamePrefix}sparqlConstructQueryString(parameters
|
|
6
|
+
export function ${syntheticNamePrefix}sparqlConstructQueryString(parameters: Parameters<typeof ${this.staticModuleName}.${syntheticNamePrefix}sparqlConstructQuery>[0] & ${imports.sparqljs}.GeneratorOptions): string {
|
|
7
7
|
return new ${imports.sparqljs}.Generator(parameters).stringify(${this.staticModuleName}.${syntheticNamePrefix}sparqlConstructQuery(parameters));
|
|
8
8
|
}`;
|
|
9
9
|
}
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { rdf, rdfs } from "@tpluscode/rdf-ns-builders";
|
|
2
|
-
import { camelCase } from "change-case";
|
|
3
2
|
import { imports } from "../imports.js";
|
|
4
3
|
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
5
4
|
import { snippets } from "../snippets.js";
|
|
6
5
|
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
7
|
-
import { code, joinCode
|
|
6
|
+
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
8
7
|
import { ObjectType_sparqlConstructQueryFunctionDeclaration } from "./ObjectType_sparqlConstructQueryFunctionDeclaration.js";
|
|
9
8
|
import { ObjectType_sparqlConstructQueryStringFunctionDeclaration } from "./ObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
|
|
10
9
|
export function ObjectType_sparqlFunctionDeclarations() {
|
|
@@ -12,10 +11,10 @@ export function ObjectType_sparqlFunctionDeclarations() {
|
|
|
12
11
|
return [];
|
|
13
12
|
}
|
|
14
13
|
const variables = {
|
|
15
|
-
filter: code `parameters
|
|
16
|
-
preferredLanguages: code `parameters
|
|
17
|
-
focusIdentifier: code `focusIdentifier`,
|
|
18
|
-
variablePrefix: code `
|
|
14
|
+
filter: code `parameters.filter`,
|
|
15
|
+
preferredLanguages: code `parameters.preferredLanguages`,
|
|
16
|
+
focusIdentifier: code `parameters.focusIdentifier`,
|
|
17
|
+
variablePrefix: code `parameters.variablePrefix`,
|
|
19
18
|
};
|
|
20
19
|
const rdfClassVariable = code `${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
|
|
21
20
|
const rdfTypeVariable = code `${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
|
|
@@ -24,10 +23,10 @@ export function ObjectType_sparqlFunctionDeclarations() {
|
|
|
24
23
|
const sparqlConstructTriplesStatements = [];
|
|
25
24
|
const sparqlWherePatternsStatements = [];
|
|
26
25
|
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 }}));`);
|
|
26
|
+
sparqlConstructTriplesStatements.push(code `triples = triples.concat(${parentObjectType.staticModuleName}.${syntheticNamePrefix}sparqlConstructTriples(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, variablePrefix: variables.variablePrefix }}));`);
|
|
28
27
|
triplesVariableDeclarationKeyword = "let";
|
|
29
28
|
sparqlWherePatternsStatements.push(code `\
|
|
30
|
-
patterns = patterns.concat(${parentObjectType.staticModuleName}.${syntheticNamePrefix}sparqlWherePatterns(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, variablePrefix: variables.variablePrefix }}));`);
|
|
29
|
+
patterns = patterns.concat(${parentObjectType.staticModuleName}.${syntheticNamePrefix}sparqlWherePatterns(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, preferredLanguages: variables.preferredLanguages, variablePrefix: variables.variablePrefix }}));`);
|
|
31
30
|
patternsVariableDeclarationKeyword = "let";
|
|
32
31
|
}
|
|
33
32
|
if (this.fromRdfType.isJust()) {
|
|
@@ -37,7 +36,7 @@ patterns = patterns.concat(${parentObjectType.staticModuleName}.${syntheticNameP
|
|
|
37
36
|
sparqlConstructTriplesStatements.push(code `\
|
|
38
37
|
if (!parameters?.ignoreRdfType) {
|
|
39
38
|
triples.push(
|
|
40
|
-
{ subject: focusIdentifier, predicate: ${rdfjsTermExpression(rdf.type)}, object: ${rdfTypeVariable} },
|
|
39
|
+
{ subject: ${variables.focusIdentifier}, predicate: ${rdfjsTermExpression(rdf.type)}, object: ${rdfTypeVariable} },
|
|
41
40
|
{ subject: ${rdfTypeVariable}, predicate: ${rdfjsTermExpression(rdfs.subClassOf)}, object: ${rdfClassVariable} }
|
|
42
41
|
);
|
|
43
42
|
}`);
|
|
@@ -54,12 +53,12 @@ if (!parameters?.ignoreRdfType) {
|
|
|
54
53
|
return valuePatternRow;
|
|
55
54
|
}),
|
|
56
55
|
},
|
|
57
|
-
${snippets.sparqlInstancesOfPattern}({ rdfType: ${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}FromRdfType\`), subject: focusIdentifier }),`
|
|
58
|
-
: code `${snippets.sparqlInstancesOfPattern}({ rdfType: ${fromRdfTypeVariables[0]}, subject: focusIdentifier }),`}
|
|
56
|
+
${snippets.sparqlInstancesOfPattern}({ rdfType: ${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}FromRdfType\`), subject: ${variables.focusIdentifier} }),`
|
|
57
|
+
: code `${snippets.sparqlInstancesOfPattern}({ rdfType: ${fromRdfTypeVariables[0]}, subject: ${variables.focusIdentifier} }),`}
|
|
59
58
|
{
|
|
60
59
|
triples: [
|
|
61
60
|
{
|
|
62
|
-
subject: focusIdentifier,
|
|
61
|
+
subject: ${variables.focusIdentifier},
|
|
63
62
|
predicate: ${rdfjsTermExpression(rdf.type)},
|
|
64
63
|
object: rdfTypeVariable
|
|
65
64
|
}
|
|
@@ -117,10 +116,9 @@ if (!parameters?.ignoreRdfType) {
|
|
|
117
116
|
ObjectType_sparqlConstructQueryFunctionDeclaration.bind(this)(),
|
|
118
117
|
ObjectType_sparqlConstructQueryStringFunctionDeclaration.bind(this)(),
|
|
119
118
|
code `\
|
|
120
|
-
export function ${syntheticNamePrefix}sparqlConstructTriples(${sparqlConstructTriplesStatements.length === 0 ? "_" : ""}parameters
|
|
119
|
+
export function ${syntheticNamePrefix}sparqlConstructTriples(${sparqlConstructTriplesStatements.length === 0 ? "_" : ""}parameters: { filter: ${this.filterType} | undefined; focusIdentifier: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType: boolean; variablePrefix: string }): readonly ${imports.sparqljs}.Triple[] {
|
|
121
120
|
${sparqlConstructTriplesStatements.length > 0
|
|
122
121
|
? joinCode([
|
|
123
|
-
code `const focusIdentifier = parameters?.focusIdentifier ?? ${imports.dataFactory}.variable!(${literalOf(camelCase(this.name))});`,
|
|
124
122
|
code `${triplesVariableDeclarationKeyword} triples: ${imports.sparqljs}.Triple[] = [];`,
|
|
125
123
|
...sparqlConstructTriplesStatements,
|
|
126
124
|
code `return triples;`,
|
|
@@ -128,11 +126,10 @@ ${sparqlConstructTriplesStatements.length > 0
|
|
|
128
126
|
: "return [];"}
|
|
129
127
|
}`,
|
|
130
128
|
code `\
|
|
131
|
-
export function ${syntheticNamePrefix}sparqlWherePatterns(${sparqlWherePatternsStatements.length === 0 ? "_" : ""}parameters
|
|
129
|
+
export function ${syntheticNamePrefix}sparqlWherePatterns(${sparqlWherePatternsStatements.length === 0 ? "_" : ""}parameters: { filter: ${this.filterType} | undefined; focusIdentifier: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType: boolean; preferredLanguages: readonly string[] | undefined; variablePrefix: string }): readonly ${snippets.SparqlPattern}[] {
|
|
132
130
|
${sparqlWherePatternsStatements.length > 0
|
|
133
131
|
? joinCode([
|
|
134
132
|
code `${patternsVariableDeclarationKeyword} patterns: ${snippets.SparqlPattern}[] = [];`,
|
|
135
|
-
code `const focusIdentifier = parameters?.focusIdentifier ?? ${imports.dataFactory}.variable!(${literalOf(camelCase(this.name))});`,
|
|
136
133
|
...sparqlWherePatternsStatements,
|
|
137
134
|
code `return patterns;`,
|
|
138
135
|
])
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pascalCase } from "change-case";
|
|
2
2
|
import { ObjectType_sparqlConstructQueryFunctionDeclaration } from "../_ObjectType/ObjectType_sparqlConstructQueryFunctionDeclaration.js";
|
|
3
3
|
import { ObjectType_sparqlConstructQueryStringFunctionDeclaration } from "../_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js";
|
|
4
4
|
import { imports } from "../imports.js";
|
|
@@ -13,28 +13,27 @@ export function ObjectUnionType_sparqlFunctionDeclarations() {
|
|
|
13
13
|
ObjectType_sparqlConstructQueryFunctionDeclaration.bind(this)(),
|
|
14
14
|
ObjectType_sparqlConstructQueryStringFunctionDeclaration.bind(this)(),
|
|
15
15
|
code `\
|
|
16
|
-
export function ${syntheticNamePrefix}sparqlConstructTriples(
|
|
17
|
-
return [${joinCode(this.concreteMemberTypes.map((memberType) => code `...${memberType.staticModuleName}.${syntheticNamePrefix}sparqlConstructTriples({ filter:
|
|
16
|
+
export function ${syntheticNamePrefix}sparqlConstructTriples({ filter, focusIdentifier, variablePrefix }: { filter: ${this.filterType} | undefined; 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: filter?.on?.${memberType.name}, focusIdentifier, ignoreRdfType: false, variablePrefix: \`\${variablePrefix}${pascalCase(memberType.name)}\` }).concat()`), { on: ", " })}];
|
|
18
18
|
}`,
|
|
19
19
|
code `\
|
|
20
|
-
export function ${syntheticNamePrefix}sparqlWherePatterns(
|
|
20
|
+
export function ${syntheticNamePrefix}sparqlWherePatterns({ filter, focusIdentifier, preferredLanguages, variablePrefix }: { filter: ${this.filterType} | undefined; focusIdentifier: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType: boolean; preferredLanguages: readonly string[] | undefined; variablePrefix: string }): readonly ${snippets.SparqlPattern}[] {
|
|
21
21
|
${joinCode([
|
|
22
22
|
code `let patterns: ${snippets.SparqlPattern}[] = [];`,
|
|
23
23
|
code `\
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}`,
|
|
24
|
+
if (focusIdentifier.termType === "Variable") {
|
|
25
|
+
patterns = patterns.concat(${this.identifierType.sparqlWherePatternsFunction}({
|
|
26
|
+
filter: filter?.${syntheticNamePrefix}identifier,
|
|
27
|
+
ignoreRdfType: false,
|
|
28
|
+
preferredLanguages,
|
|
29
|
+
propertyPatterns: [],
|
|
30
|
+
schema: ${this.identifierType.schema},
|
|
31
|
+
valueVariable: focusIdentifier,
|
|
32
|
+
variablePrefix,
|
|
33
|
+
}));
|
|
34
|
+
}`,
|
|
36
35
|
code `patterns.push({ patterns: [${joinCode(this.concreteMemberTypes.map((memberType) => code `${{
|
|
37
|
-
patterns: code `${memberType.staticModuleName}.${syntheticNamePrefix}sparqlWherePatterns({ filter:
|
|
36
|
+
patterns: code `${memberType.staticModuleName}.${syntheticNamePrefix}sparqlWherePatterns({ filter: filter?.on?.${memberType.name}, focusIdentifier, ignoreRdfType: false, preferredLanguages, variablePrefix: \`\${variablePrefix}${pascalCase(memberType.name)}\` }).concat()`,
|
|
38
37
|
type: literalOf("group"),
|
|
39
38
|
}}`), { on: ", " })}], type: "union" });`,
|
|
40
39
|
code `return patterns;`,
|
|
@@ -7,18 +7,18 @@ export const snippets_LazyObject = conditionalOutput(`${syntheticNamePrefix}Lazy
|
|
|
7
7
|
*/
|
|
8
8
|
export class ${syntheticNamePrefix}LazyObject<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: ObjectIdentifierT }> {
|
|
9
9
|
readonly partial: PartialObjectT;
|
|
10
|
-
private readonly resolver: (identifier: ObjectIdentifierT) => Promise<${imports.Either}<Error, ResolvedObjectT>>;
|
|
10
|
+
private readonly resolver: (identifier: ObjectIdentifierT, options?: { preferredLanguages?: readonly string[] }) => Promise<${imports.Either}<Error, ResolvedObjectT>>;
|
|
11
11
|
|
|
12
12
|
constructor({ partial, resolver }: {
|
|
13
13
|
partial: PartialObjectT
|
|
14
|
-
resolver: (identifier: ObjectIdentifierT) => Promise<${imports.Either}<Error, ResolvedObjectT>>,
|
|
14
|
+
resolver: (identifier: ObjectIdentifierT, options?: { preferredLanguages?: readonly string[] }) => Promise<${imports.Either}<Error, ResolvedObjectT>>,
|
|
15
15
|
}) {
|
|
16
16
|
this.partial = partial;
|
|
17
17
|
this.resolver = resolver;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
resolve(): Promise<${imports.Either}<Error, ResolvedObjectT>> {
|
|
21
|
-
return this.resolver(this.partial.${syntheticNamePrefix}identifier);
|
|
20
|
+
resolve(options?: { preferredLanguages?: readonly string[] }): Promise<${imports.Either}<Error, ResolvedObjectT>> {
|
|
21
|
+
return this.resolver(this.partial.${syntheticNamePrefix}identifier, options);
|
|
22
22
|
}
|
|
23
23
|
}`);
|
|
24
24
|
//# sourceMappingURL=snippets_LazyObject.js.map
|
|
@@ -7,21 +7,21 @@ export const snippets_LazyObjectOption = conditionalOutput(`${syntheticNamePrefi
|
|
|
7
7
|
*/
|
|
8
8
|
export class ${syntheticNamePrefix}LazyObjectOption<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: ObjectIdentifierT }> {
|
|
9
9
|
readonly partial: ${imports.Maybe}<PartialObjectT>;
|
|
10
|
-
private readonly resolver: (identifier: ObjectIdentifierT) => Promise<${imports.Either}<Error, ResolvedObjectT>>;
|
|
10
|
+
private readonly resolver: (identifier: ObjectIdentifierT, options?: { preferredLanguages?: readonly string[] }) => Promise<${imports.Either}<Error, ResolvedObjectT>>;
|
|
11
11
|
|
|
12
12
|
constructor({ partial, resolver }: {
|
|
13
13
|
partial: ${imports.Maybe}<PartialObjectT>
|
|
14
|
-
resolver: (identifier: ObjectIdentifierT) => Promise<${imports.Either}<Error, ResolvedObjectT>>,
|
|
14
|
+
resolver: (identifier: ObjectIdentifierT, options?: { preferredLanguages?: readonly string[] }) => Promise<${imports.Either}<Error, ResolvedObjectT>>,
|
|
15
15
|
}) {
|
|
16
16
|
this.partial = partial;
|
|
17
17
|
this.resolver = resolver;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
async resolve(): Promise<${imports.Either}<Error, ${imports.Maybe}<ResolvedObjectT>>> {
|
|
20
|
+
async resolve(options?: { preferredLanguages?: readonly string[] }): Promise<${imports.Either}<Error, ${imports.Maybe}<ResolvedObjectT>>> {
|
|
21
21
|
if (this.partial.isNothing()) {
|
|
22
22
|
return ${imports.Right}(${imports.Maybe}.empty());
|
|
23
23
|
}
|
|
24
|
-
return (await this.resolver(this.partial.unsafeCoerce().${syntheticNamePrefix}identifier)).map(${imports.Maybe}.of);
|
|
24
|
+
return (await this.resolver(this.partial.unsafeCoerce().${syntheticNamePrefix}identifier, options)).map(${imports.Maybe}.of);
|
|
25
25
|
}
|
|
26
26
|
}`);
|
|
27
27
|
//# sourceMappingURL=snippets_LazyObjectOption.js.map
|
|
@@ -7,11 +7,11 @@ export const snippets_LazyObjectSet = conditionalOutput(`${syntheticNamePrefix}L
|
|
|
7
7
|
*/
|
|
8
8
|
export class ${syntheticNamePrefix}LazyObjectSet<ObjectIdentifierT extends ${imports.BlankNode} | ${imports.NamedNode}, PartialObjectT extends { ${syntheticNamePrefix}identifier: ObjectIdentifierT }, ResolvedObjectT extends { ${syntheticNamePrefix}identifier: ObjectIdentifierT }> {
|
|
9
9
|
readonly partials: readonly PartialObjectT[];
|
|
10
|
-
private readonly resolver: (identifiers: readonly ObjectIdentifierT[]) => Promise<${imports.Either}<Error, readonly ResolvedObjectT[]>>;
|
|
10
|
+
private readonly resolver: (identifiers: readonly ObjectIdentifierT[], options?: { preferredLanguages?: readonly string[] }) => Promise<${imports.Either}<Error, readonly ResolvedObjectT[]>>;
|
|
11
11
|
|
|
12
12
|
constructor({ partials, resolver }: {
|
|
13
13
|
partials: readonly PartialObjectT[]
|
|
14
|
-
resolver: (identifiers: readonly ObjectIdentifierT[]) => Promise<${imports.Either}<Error, readonly ResolvedObjectT[]>>,
|
|
14
|
+
resolver: (identifiers: readonly ObjectIdentifierT[], options?: { preferredLanguages?: readonly string[] }) => Promise<${imports.Either}<Error, readonly ResolvedObjectT[]>>,
|
|
15
15
|
}) {
|
|
16
16
|
this.partials = partials;
|
|
17
17
|
this.resolver = resolver;
|
|
@@ -21,7 +21,7 @@ export class ${syntheticNamePrefix}LazyObjectSet<ObjectIdentifierT extends ${imp
|
|
|
21
21
|
return this.partials.length;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
async resolve(options?: { limit?: number; offset?: number }): Promise<${imports.Either}<Error, readonly ResolvedObjectT[]>> {
|
|
24
|
+
async resolve(options?: { limit?: number; offset?: number; preferredLanguages?: readonly string[] }): Promise<${imports.Either}<Error, readonly ResolvedObjectT[]>> {
|
|
25
25
|
if (this.partials.length === 0) {
|
|
26
26
|
return ${imports.Right}([]);
|
|
27
27
|
}
|
|
@@ -36,7 +36,7 @@ export class ${syntheticNamePrefix}LazyObjectSet<ObjectIdentifierT extends ${imp
|
|
|
36
36
|
offset = 0;
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
return await this.resolver(this.partials.slice(offset, offset + limit).map(partial => partial.${syntheticNamePrefix}identifier));
|
|
39
|
+
return await this.resolver(this.partials.slice(offset, offset + limit).map(partial => partial.${syntheticNamePrefix}identifier), { preferredLanguages: options?.preferredLanguages });
|
|
40
40
|
}
|
|
41
41
|
}`);
|
|
42
42
|
//# sourceMappingURL=snippets_LazyObjectSet.js.map
|
|
@@ -3,8 +3,8 @@ import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
|
3
3
|
import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
4
4
|
export const snippets_SparqlConstructTriplesFunctionParameters = conditionalOutput(`${syntheticNamePrefix}SparqlConstructTriplesFunctionParameters`, code `\
|
|
5
5
|
type ${syntheticNamePrefix}SparqlConstructTriplesFunctionParameters<FilterT, SchemaT> = Readonly<{
|
|
6
|
-
filter
|
|
7
|
-
ignoreRdfType
|
|
6
|
+
filter: FilterT | undefined;
|
|
7
|
+
ignoreRdfType: boolean;
|
|
8
8
|
schema: SchemaT;
|
|
9
9
|
valueVariable: ${imports.Variable};
|
|
10
10
|
variablePrefix: string;
|
|
@@ -4,9 +4,9 @@ import { code, conditionalOutput } from "../ts-poet-wrapper.js";
|
|
|
4
4
|
import { snippets_SparqlPattern } from "./snippets_SparqlPattern.js";
|
|
5
5
|
export const snippets_SparqlWherePatternsFunctionParameters = conditionalOutput(`${syntheticNamePrefix}SparqlWherePatternsFunctionParameters`, code `\
|
|
6
6
|
type ${syntheticNamePrefix}SparqlWherePatternsFunctionParameters<FilterT, SchemaT> = Readonly<{
|
|
7
|
-
filter
|
|
8
|
-
ignoreRdfType
|
|
9
|
-
preferredLanguages
|
|
7
|
+
filter: FilterT | undefined;
|
|
8
|
+
ignoreRdfType: boolean;
|
|
9
|
+
preferredLanguages: readonly string[] | undefined;
|
|
10
10
|
propertyPatterns: readonly ${snippets_SparqlPattern}[];
|
|
11
11
|
schema: SchemaT;
|
|
12
12
|
valueVariable: ${imports.Variable};
|
|
@@ -17,6 +17,6 @@ const ${syntheticNamePrefix}booleanSparqlWherePatterns: ${snippets_SparqlWherePa
|
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
return ${snippets_termSchemaSparqlPatterns}({ filterPatterns, valueVariable
|
|
20
|
+
return ${snippets_termSchemaSparqlPatterns}({ ...otherParameters, filterPatterns, valueVariable });
|
|
21
21
|
}`);
|
|
22
22
|
//# sourceMappingURL=snippets_booleanSparqlWherePatterns.js.map
|
|
@@ -74,6 +74,6 @@ const ${syntheticNamePrefix}dateSparqlWherePatterns: ${snippets_SparqlWherePatte
|
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
-
return ${snippets_termSchemaSparqlPatterns}({ filterPatterns, schema, valueVariable
|
|
77
|
+
return ${snippets_termSchemaSparqlPatterns}({ ...otherParameters, filterPatterns, schema, valueVariable });
|
|
78
78
|
}`);
|
|
79
79
|
//# sourceMappingURL=snippets_dateSparqlWherePatterns.js.map
|
|
@@ -6,7 +6,7 @@ import { snippets_SparqlWherePatternsFunction } from "./snippets_SparqlWherePatt
|
|
|
6
6
|
export const snippets_defaultValueSparqlWherePatterns = conditionalOutput(`${syntheticNamePrefix}defaultValueSparqlWherePatterns`, code `\
|
|
7
7
|
function ${syntheticNamePrefix}defaultValueSparqlWherePatterns<ItemFilterT, ItemSchemaT>(itemSparqlWherePatternsFunction: ${snippets_SparqlWherePatternsFunction}<ItemFilterT, ItemSchemaT>): ${snippets_SparqlWherePatternsFunction}<ItemFilterT, ${snippets_DefaultValueSchema}<ItemSchemaT>> {
|
|
8
8
|
return ({ schema, ...otherParameters }) => {
|
|
9
|
-
const [itemSparqlWherePatterns, liftSparqlPatterns] = ${snippets_liftSparqlPatterns}(itemSparqlWherePatternsFunction({ schema: schema.item()
|
|
9
|
+
const [itemSparqlWherePatterns, liftSparqlPatterns] = ${snippets_liftSparqlPatterns}(itemSparqlWherePatternsFunction({ ...otherParameters, schema: schema.item() }));
|
|
10
10
|
return [{ patterns: itemSparqlWherePatterns.concat(), type: "optional" }, ...liftSparqlPatterns];
|
|
11
11
|
}
|
|
12
12
|
}`);
|
|
@@ -15,6 +15,6 @@ const ${syntheticNamePrefix}iriSparqlWherePatterns: ${snippets_SparqlWherePatter
|
|
|
15
15
|
filterPatterns.push(${snippets_sparqlValueInPattern}({ lift: true, valueVariable, valueIn: filter.in }));
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
return ${snippets_termSchemaSparqlPatterns}({ filterPatterns, valueVariable
|
|
18
|
+
return ${snippets_termSchemaSparqlPatterns}({ ...otherParameters, filterPatterns, valueVariable });
|
|
19
19
|
};`);
|
|
20
20
|
//# sourceMappingURL=snippets_iriSparqlWherePatterns.js.map
|
|
@@ -7,16 +7,16 @@ import { snippets_RdfVocabularies } from "./snippets_RdfVocabularies.js";
|
|
|
7
7
|
import { snippets_SparqlConstructTriplesFunction } from "./snippets_SparqlConstructTriplesFunction.js";
|
|
8
8
|
export const snippets_listSparqlConstructTriples = conditionalOutput(`${syntheticNamePrefix}listSparqlConstructTriples`, code `\
|
|
9
9
|
function ${syntheticNamePrefix}listSparqlConstructTriples<ItemFilterT, ItemSchemaT>(itemSparqlConstructTriplesFunction: ${snippets_SparqlConstructTriplesFunction}<ItemFilterT, ItemSchemaT>): ${snippets_SparqlConstructTriplesFunction}<${snippets_CollectionFilter}<ItemFilterT>, ${snippets_CollectionSchema}<ItemSchemaT>> {
|
|
10
|
-
return ({ filter, schema, valueVariable: listVariable,
|
|
10
|
+
return ({ filter, schema, valueVariable: listVariable, variablePrefix: variablePrefixPrefix }) => {
|
|
11
11
|
let triples: ${imports.sparqljs}.Triple[] = [];
|
|
12
|
-
const variable = (suffix: string) => ${imports.dataFactory}.variable!(\`\${
|
|
13
|
-
const variablePrefix = (suffix: string) => \`\${
|
|
12
|
+
const variable = (suffix: string) => ${imports.dataFactory}.variable!(\`\${variablePrefixPrefix}\${suffix}\`);
|
|
13
|
+
const variablePrefix = (suffix: string) => \`\${variablePrefixPrefix}\${suffix}\`;
|
|
14
14
|
|
|
15
15
|
{
|
|
16
16
|
// ?list rdf:first ?item0
|
|
17
17
|
const item0Variable = variable("Item0");
|
|
18
18
|
triples.push({ subject: listVariable, predicate: ${snippets_RdfVocabularies}.rdf.first, object: item0Variable });
|
|
19
|
-
triples = triples.concat(itemSparqlConstructTriplesFunction({ filter, schema: schema.item(), valueVariable: item0Variable, variablePrefix: variablePrefix("Item0") }));
|
|
19
|
+
triples = triples.concat(itemSparqlConstructTriplesFunction({ filter, ignoreRdfType: false, schema: schema.item(), valueVariable: item0Variable, variablePrefix: variablePrefix("Item0") }));
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
{
|
|
@@ -31,7 +31,7 @@ function ${syntheticNamePrefix}listSparqlConstructTriples<ItemFilterT, ItemSchem
|
|
|
31
31
|
// ?rest rdf:first ?itemN
|
|
32
32
|
const itemNVariable = variable("ItemN");
|
|
33
33
|
triples.push({ subject: restNVariable, predicate: ${snippets_RdfVocabularies}.rdf.first, object: itemNVariable });
|
|
34
|
-
triples = triples.concat(itemSparqlConstructTriplesFunction({ filter, schema: schema.item(), valueVariable: itemNVariable, variablePrefix: variablePrefix("ItemN") }));
|
|
34
|
+
triples = triples.concat(itemSparqlConstructTriplesFunction({ filter, ignoreRdfType: false, schema: schema.item(), valueVariable: itemNVariable, variablePrefix: variablePrefix("ItemN") }));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// ?restN rdf:rest ?restNBasic to get the rdf:rest statement in the CONSTRUCT
|
|
@@ -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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
-
"@shaclmate/shacl-ast": "4.0.
|
|
3
|
+
"@shaclmate/shacl-ast": "4.0.6",
|
|
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.6"
|
|
84
84
|
}
|