@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
package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { TsFeature } from "../../../enums/TsFeature.js";
|
|
1
3
|
import { type Code } from "../ts-poet-wrapper.js";
|
|
2
4
|
export declare function ObjectType_sparqlConstructQueryStringFunctionDeclaration(this: {
|
|
5
|
+
readonly features: ReadonlySet<TsFeature>;
|
|
3
6
|
readonly filterType: Code;
|
|
4
7
|
readonly staticModuleName: string;
|
|
5
|
-
}): Code
|
|
8
|
+
}): Maybe<Code>;
|
|
6
9
|
//# sourceMappingURL=ObjectType_sparqlConstructQueryStringFunctionDeclaration.d.ts.map
|
package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructQueryStringFunctionDeclaration.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
1
2
|
import { imports } from "../imports.js";
|
|
2
3
|
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
3
4
|
import { code } from "../ts-poet-wrapper.js";
|
|
4
5
|
export function ObjectType_sparqlConstructQueryStringFunctionDeclaration() {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
if (!this.features.has("sparql")) {
|
|
7
|
+
return Maybe.empty();
|
|
8
|
+
}
|
|
9
|
+
return Maybe.of(code `\
|
|
10
|
+
export function ${syntheticNamePrefix}sparqlConstructQueryString(parameters: Parameters<typeof ${this.staticModuleName}.${syntheticNamePrefix}sparqlConstructQuery>[0] & ${imports.sparqljs}.GeneratorOptions): string {
|
|
7
11
|
return new ${imports.sparqljs}.Generator(parameters).stringify(${this.staticModuleName}.${syntheticNamePrefix}sparqlConstructQuery(parameters));
|
|
8
|
-
}
|
|
12
|
+
}`);
|
|
9
13
|
}
|
|
10
14
|
//# sourceMappingURL=ObjectType_sparqlConstructQueryStringFunctionDeclaration.js.map
|
package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectType_sparqlConstructTriplesFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectType_sparqlConstructTriplesFunctionDeclaration.d.ts.map
|
package/dist/generators/ts/_ObjectType/ObjectType_sparqlConstructTriplesFunctionDeclaration.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { rdf, rdfs } from "@tpluscode/rdf-ns-builders";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
|
+
import { imports } from "../imports.js";
|
|
4
|
+
import { rdfjsTermExpression } from "../rdfjsTermExpression.js";
|
|
5
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
6
|
+
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
7
|
+
const variables = {
|
|
8
|
+
filter: code `parameters.filter`,
|
|
9
|
+
focusIdentifier: code `parameters.focusIdentifier`,
|
|
10
|
+
variablePrefix: code `parameters.variablePrefix`,
|
|
11
|
+
};
|
|
12
|
+
export function ObjectType_sparqlConstructTriplesFunctionDeclaration() {
|
|
13
|
+
if (!this.features.has("sparql")) {
|
|
14
|
+
return Maybe.empty();
|
|
15
|
+
}
|
|
16
|
+
const rdfClassVariable = code `${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
|
|
17
|
+
const rdfTypeVariable = code `${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
|
|
18
|
+
let triplesVariableDeclarationKeyword = "const";
|
|
19
|
+
const statements = [];
|
|
20
|
+
for (const parentObjectType of this.parentObjectTypes) {
|
|
21
|
+
statements.push(code `triples = triples.concat(${parentObjectType.staticModuleName}.${syntheticNamePrefix}sparqlConstructTriples(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, variablePrefix: variables.variablePrefix }}));`);
|
|
22
|
+
triplesVariableDeclarationKeyword = "let";
|
|
23
|
+
}
|
|
24
|
+
if (this.fromRdfType.isJust()) {
|
|
25
|
+
statements.push(code `\
|
|
26
|
+
if (!parameters?.ignoreRdfType) {
|
|
27
|
+
triples.push(
|
|
28
|
+
{ subject: ${variables.focusIdentifier}, predicate: ${rdfjsTermExpression(rdf.type)}, object: ${rdfTypeVariable} },
|
|
29
|
+
{ subject: ${rdfTypeVariable}, predicate: ${rdfjsTermExpression(rdfs.subClassOf)}, object: ${rdfClassVariable} }
|
|
30
|
+
);
|
|
31
|
+
}`);
|
|
32
|
+
}
|
|
33
|
+
for (const property of this.ownProperties) {
|
|
34
|
+
if (property.recursive) {
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
property
|
|
38
|
+
.sparqlConstructTriplesExpression({
|
|
39
|
+
variables,
|
|
40
|
+
})
|
|
41
|
+
.ifJust((propertyTriples) => {
|
|
42
|
+
statements.push(code `triples = triples.concat(${propertyTriples});`);
|
|
43
|
+
triplesVariableDeclarationKeyword = "let";
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
return Maybe.of(code `\
|
|
47
|
+
export function ${syntheticNamePrefix}sparqlConstructTriples(${statements.length === 0 ? "_" : ""}parameters: { filter: ${this.filterType} | undefined; focusIdentifier: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType: boolean; variablePrefix: string }): readonly ${imports.sparqljs}.Triple[] {
|
|
48
|
+
${statements.length > 0
|
|
49
|
+
? joinCode([
|
|
50
|
+
code `${triplesVariableDeclarationKeyword} triples: ${imports.sparqljs}.Triple[] = [];`,
|
|
51
|
+
...statements,
|
|
52
|
+
code `return triples;`,
|
|
53
|
+
])
|
|
54
|
+
: "return [];"}
|
|
55
|
+
}`);
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=ObjectType_sparqlConstructTriplesFunctionDeclaration.js.map
|
package/dist/generators/ts/_ObjectType/ObjectType_sparqlWherePatternsFunctionDeclarations.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectType } from "../ObjectType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectType_sparqlWherePatternsFunctionDeclaration(this: ObjectType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectType_sparqlWherePatternsFunctionDeclarations.d.ts.map
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { rdf, rdfs } from "@tpluscode/rdf-ns-builders";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
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 } from "../ts-poet-wrapper.js";
|
|
8
|
+
const variables = {
|
|
9
|
+
filter: code `parameters.filter`,
|
|
10
|
+
preferredLanguages: code `parameters.preferredLanguages`,
|
|
11
|
+
focusIdentifier: code `parameters.focusIdentifier`,
|
|
12
|
+
variablePrefix: code `parameters.variablePrefix`,
|
|
13
|
+
};
|
|
14
|
+
export function ObjectType_sparqlWherePatternsFunctionDeclaration() {
|
|
15
|
+
if (!this.features.has("sparql")) {
|
|
16
|
+
return Maybe.empty();
|
|
17
|
+
}
|
|
18
|
+
const rdfClassVariable = code `${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfClass\`)`;
|
|
19
|
+
const rdfTypeVariable = code `${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}RdfType\`)`;
|
|
20
|
+
let patternsVariableDeclarationKeyword = "const";
|
|
21
|
+
const statements = [];
|
|
22
|
+
for (const parentObjectType of this.parentObjectTypes) {
|
|
23
|
+
statements.push(code `\
|
|
24
|
+
patterns = patterns.concat(${parentObjectType.staticModuleName}.${syntheticNamePrefix}sparqlWherePatterns(${{ filter: variables.filter, focusIdentifier: variables.focusIdentifier, ignoreRdfType: true, preferredLanguages: variables.preferredLanguages, variablePrefix: variables.variablePrefix }}));`);
|
|
25
|
+
patternsVariableDeclarationKeyword = "let";
|
|
26
|
+
}
|
|
27
|
+
if (this.fromRdfType.isJust()) {
|
|
28
|
+
const fromRdfTypeVariables = this.fromRdfTypeVariable
|
|
29
|
+
.toList()
|
|
30
|
+
.concat(this.descendantFromRdfTypeVariables);
|
|
31
|
+
statements.push(code `const rdfTypeVariable = ${rdfTypeVariable};`, code `\
|
|
32
|
+
if (!parameters?.ignoreRdfType) {
|
|
33
|
+
patterns.push(
|
|
34
|
+
${fromRdfTypeVariables.length > 1
|
|
35
|
+
? code `\
|
|
36
|
+
{
|
|
37
|
+
type: "values" as const,
|
|
38
|
+
values: [${joinCode(fromRdfTypeVariables, { on: "," })}].map((identifier) => {
|
|
39
|
+
const valuePatternRow: ${imports.sparqljs}.ValuePatternRow = {};
|
|
40
|
+
valuePatternRow[\`?\${${variables.variablePrefix}}FromRdfType\`] = identifier as ${imports.NamedNode};
|
|
41
|
+
return valuePatternRow;
|
|
42
|
+
}),
|
|
43
|
+
},
|
|
44
|
+
${snippets.sparqlInstancesOfPattern}({ rdfType: ${imports.dataFactory}.variable!(\`\${${variables.variablePrefix}}FromRdfType\`), subject: ${variables.focusIdentifier} }),`
|
|
45
|
+
: code `${snippets.sparqlInstancesOfPattern}({ rdfType: ${fromRdfTypeVariables[0]}, subject: ${variables.focusIdentifier} }),`}
|
|
46
|
+
{
|
|
47
|
+
triples: [
|
|
48
|
+
{
|
|
49
|
+
subject: ${variables.focusIdentifier},
|
|
50
|
+
predicate: ${rdfjsTermExpression(rdf.type)},
|
|
51
|
+
object: rdfTypeVariable
|
|
52
|
+
}
|
|
53
|
+
],
|
|
54
|
+
type: "bgp" as const
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
patterns: [
|
|
58
|
+
{
|
|
59
|
+
triples: [
|
|
60
|
+
{
|
|
61
|
+
subject: rdfTypeVariable,
|
|
62
|
+
predicate: {
|
|
63
|
+
items: [${rdfjsTermExpression(rdfs.subClassOf)}],
|
|
64
|
+
pathType: "+" as const,
|
|
65
|
+
type: "path" as const
|
|
66
|
+
},
|
|
67
|
+
object: ${rdfClassVariable}
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
type: "bgp" as const
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
type: "optional" as const
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
}`);
|
|
77
|
+
}
|
|
78
|
+
for (const property of this.ownProperties) {
|
|
79
|
+
if (property.recursive) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
property
|
|
83
|
+
.sparqlWherePatternsExpression({ variables })
|
|
84
|
+
.ifJust(({ condition, patterns }) => {
|
|
85
|
+
const concatStatement = code `patterns = patterns.concat(${patterns});`;
|
|
86
|
+
if (condition) {
|
|
87
|
+
statements.push(code `if (${condition}) { ${concatStatement} }`);
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
statements.push(concatStatement);
|
|
91
|
+
}
|
|
92
|
+
patternsVariableDeclarationKeyword = "let";
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return Maybe.of(code `\
|
|
96
|
+
export function ${syntheticNamePrefix}sparqlWherePatterns(${statements.length === 0 ? "_" : ""}parameters: { filter: ${this.filterType} | undefined; focusIdentifier: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType: boolean; preferredLanguages: readonly string[] | undefined; variablePrefix: string }): readonly ${snippets.SparqlPattern}[] {
|
|
97
|
+
${statements.length > 0
|
|
98
|
+
? joinCode([
|
|
99
|
+
code `${patternsVariableDeclarationKeyword} patterns: ${snippets.SparqlPattern}[] = [];`,
|
|
100
|
+
...statements,
|
|
101
|
+
code `return patterns;`,
|
|
102
|
+
])
|
|
103
|
+
: "return [];"}
|
|
104
|
+
}`);
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=ObjectType_sparqlWherePatternsFunctionDeclarations.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { type Code } from "ts-poet";
|
|
3
|
+
import type { ObjectUnionType } from "../ObjectUnionType.js";
|
|
4
|
+
export declare function ObjectUnionType_fromJsonFunctionDeclaration(this: ObjectUnionType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectUnionType_fromJsonFunctionDeclaration.d.ts.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { code } from "ts-poet";
|
|
3
|
+
import { imports } from "../imports.js";
|
|
4
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
5
|
+
export function ObjectUnionType_fromJsonFunctionDeclaration() {
|
|
6
|
+
if (!this.features.has("json")) {
|
|
7
|
+
return Maybe.empty();
|
|
8
|
+
}
|
|
9
|
+
return Maybe.of(code `\
|
|
10
|
+
export function ${syntheticNamePrefix}fromJson(json: unknown): ${imports.Either}<${imports.z}.ZodError, ${this.name}> {
|
|
11
|
+
return ${this.concreteMemberTypes.reduce((expression, memberType) => {
|
|
12
|
+
const memberTypeExpression = code `(${memberType.staticModuleName}.${syntheticNamePrefix}fromJson(json) as ${imports.Either}<${imports.z}.ZodError, ${this.name}>)`;
|
|
13
|
+
return expression !== null
|
|
14
|
+
? code `${expression}.altLazy(() => ${memberTypeExpression})`
|
|
15
|
+
: memberTypeExpression;
|
|
16
|
+
}, null)};
|
|
17
|
+
}`);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=ObjectUnionType_fromJsonFunctionDeclaration.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectUnionType } from "../ObjectUnionType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectUnionType_fromRdfFunctionDeclaration(this: ObjectUnionType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectUnionType_fromRdfFunctionDeclarations.d.ts.map
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { imports } from "../imports.js";
|
|
3
|
+
import { snippets } from "../snippets.js";
|
|
4
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
5
|
+
import { code } from "../ts-poet-wrapper.js";
|
|
6
|
+
export function ObjectUnionType_fromRdfFunctionDeclaration() {
|
|
7
|
+
if (!this.features.has("rdf")) {
|
|
8
|
+
return Maybe.empty();
|
|
9
|
+
}
|
|
10
|
+
return Maybe.of(code `\
|
|
11
|
+
export function ${syntheticNamePrefix}fromRdf(resource: ${imports.Resource}, options?: ${snippets.FromRdfOptions}): ${imports.Either}<Error, ${this.name}> {
|
|
12
|
+
return ${this.concreteMemberTypes.reduce((expression, memberType) => {
|
|
13
|
+
const memberTypeExpression = code `(${memberType.staticModuleName}.${syntheticNamePrefix}fromRdf(resource, { ...options, ignoreRdfType: false }) as ${imports.Either}<Error, ${this.name}>)`;
|
|
14
|
+
return expression !== null
|
|
15
|
+
? code `${expression}.altLazy(() => ${memberTypeExpression})`
|
|
16
|
+
: memberTypeExpression;
|
|
17
|
+
}, null)};
|
|
18
|
+
}`);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=ObjectUnionType_fromRdfFunctionDeclarations.js.map
|
package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { type Code } from "ts-poet";
|
|
3
|
+
import type { ObjectUnionType } from "../ObjectUnionType.js";
|
|
4
|
+
export declare function ObjectUnionType_jsonZodSchemaFunctionDeclaration(this: ObjectUnionType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectUnionType_jsonZodSchemaFunctionDeclaration.d.ts.map
|
package/dist/generators/ts/_ObjectUnionType/ObjectUnionType_jsonZodSchemaFunctionDeclaration.js
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { code, joinCode } from "ts-poet";
|
|
3
|
+
import { imports } from "../imports.js";
|
|
4
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
5
|
+
export function ObjectUnionType_jsonZodSchemaFunctionDeclaration() {
|
|
6
|
+
if (!this.features.has("json")) {
|
|
7
|
+
return Maybe.empty();
|
|
8
|
+
}
|
|
9
|
+
return Maybe.of(code `\
|
|
10
|
+
export function ${syntheticNamePrefix}jsonZodSchema() {
|
|
11
|
+
return ${imports.z}.discriminatedUnion("${this._discriminantProperty.name}", [${joinCode(this.concreteMemberTypes.map((memberType) => memberType.jsonZodSchema({ context: "type" })), { on: ", " })}]);
|
|
12
|
+
}`);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=ObjectUnionType_jsonZodSchemaFunctionDeclaration.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectUnionType } from "../ObjectUnionType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectUnionType_sparqlConstructTriplesFunctionDeclaration(this: ObjectUnionType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.d.ts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { pascalCase } from "change-case";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
|
+
import { imports } from "../imports.js";
|
|
4
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
5
|
+
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
6
|
+
export function ObjectUnionType_sparqlConstructTriplesFunctionDeclaration() {
|
|
7
|
+
if (!this.features.has("sparql")) {
|
|
8
|
+
return Maybe.empty();
|
|
9
|
+
}
|
|
10
|
+
return Maybe.of(code `\
|
|
11
|
+
export function ${syntheticNamePrefix}sparqlConstructTriples({ filter, focusIdentifier, variablePrefix }: { filter: ${this.filterType} | undefined; focusIdentifier: ${imports.NamedNode} | ${imports.Variable}; ignoreRdfType: boolean; variablePrefix: string }): readonly ${imports.sparqljs}.Triple[] {
|
|
12
|
+
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: ", " })}];
|
|
13
|
+
}`);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ObjectUnionType_sparqlConstructTriplesFunctionDeclaration.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectUnionType } from "../ObjectUnionType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectUnionType_sparqlWherePatternsFunctionDeclaration(this: ObjectUnionType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectUnionType_sparqlWherePatternsFunctionDeclaration.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { pascalCase } from "change-case";
|
|
2
|
+
import { Maybe } from "purify-ts";
|
|
3
|
+
import { imports } from "../imports.js";
|
|
4
|
+
import { snippets } from "../snippets.js";
|
|
5
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
6
|
+
import { code, joinCode, literalOf } from "../ts-poet-wrapper.js";
|
|
7
|
+
export function ObjectUnionType_sparqlWherePatternsFunctionDeclaration() {
|
|
8
|
+
if (!this.features.has("sparql")) {
|
|
9
|
+
return Maybe.empty();
|
|
10
|
+
}
|
|
11
|
+
return Maybe.of(code `\
|
|
12
|
+
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}[] {
|
|
13
|
+
${joinCode([
|
|
14
|
+
code `let patterns: ${snippets.SparqlPattern}[] = [];`,
|
|
15
|
+
code `\
|
|
16
|
+
if (focusIdentifier.termType === "Variable") {
|
|
17
|
+
patterns = patterns.concat(${this.identifierType.sparqlWherePatternsFunction}({
|
|
18
|
+
filter: filter?.${syntheticNamePrefix}identifier,
|
|
19
|
+
ignoreRdfType: false,
|
|
20
|
+
preferredLanguages,
|
|
21
|
+
propertyPatterns: [],
|
|
22
|
+
schema: ${this.identifierType.schema},
|
|
23
|
+
valueVariable: focusIdentifier,
|
|
24
|
+
variablePrefix,
|
|
25
|
+
}));
|
|
26
|
+
}`,
|
|
27
|
+
code `patterns.push({ patterns: [${joinCode(this.concreteMemberTypes.map((memberType) => code `${{
|
|
28
|
+
patterns: code `${memberType.staticModuleName}.${syntheticNamePrefix}sparqlWherePatterns({ filter: filter?.on?.${memberType.name}, focusIdentifier, ignoreRdfType: false, preferredLanguages, variablePrefix: \`\${variablePrefix}${pascalCase(memberType.name)}\` }).concat()`,
|
|
29
|
+
type: literalOf("group"),
|
|
30
|
+
}}`), { on: ", " })}], type: "union" });`,
|
|
31
|
+
code `return patterns;`,
|
|
32
|
+
])}
|
|
33
|
+
}`);
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=ObjectUnionType_sparqlWherePatternsFunctionDeclaration.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { type Code } from "ts-poet";
|
|
3
|
+
import type { ObjectUnionType } from "../ObjectUnionType.js";
|
|
4
|
+
export declare function ObjectUnionType_toJsonFunctionDeclaration(this: ObjectUnionType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectUnionType_toJsonFunctionDeclaration.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import { code, joinCode } from "ts-poet";
|
|
3
|
+
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
4
|
+
export function ObjectUnionType_toJsonFunctionDeclaration() {
|
|
5
|
+
if (!this.features.has("json")) {
|
|
6
|
+
return Maybe.empty();
|
|
7
|
+
}
|
|
8
|
+
return Maybe.of(code `\
|
|
9
|
+
export function ${syntheticNamePrefix}toJson(${this.thisVariable}: ${this.name}): ${this.jsonType().name} {
|
|
10
|
+
${joinCode(this.concreteMemberTypes
|
|
11
|
+
.map((memberType) => {
|
|
12
|
+
let returnExpression;
|
|
13
|
+
switch (memberType.declarationType) {
|
|
14
|
+
case "class":
|
|
15
|
+
returnExpression = code `${this.thisVariable}.${syntheticNamePrefix}toJson()`;
|
|
16
|
+
break;
|
|
17
|
+
case "interface":
|
|
18
|
+
returnExpression = code `${memberType.staticModuleName}.${syntheticNamePrefix}toJson(${this.thisVariable})`;
|
|
19
|
+
break;
|
|
20
|
+
}
|
|
21
|
+
return code `if (${memberType.staticModuleName}.is${memberType.name}(${this.thisVariable})) { return ${returnExpression}; }`;
|
|
22
|
+
})
|
|
23
|
+
.concat(code `throw new Error("unrecognized type");`))}
|
|
24
|
+
}`);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ObjectUnionType_toJsonFunctionDeclaration.js.map
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
2
|
+
import type { ObjectUnionType } from "../ObjectUnionType.js";
|
|
3
|
+
import { type Code } from "../ts-poet-wrapper.js";
|
|
4
|
+
export declare function ObjectUnionType_toRdfFunctionDeclaration(this: ObjectUnionType): Maybe<Code>;
|
|
5
|
+
//# sourceMappingURL=ObjectUnionType_toRdfFunctionDeclarations.d.ts.map
|
|
@@ -1,29 +1,12 @@
|
|
|
1
|
+
import { Maybe } from "purify-ts";
|
|
1
2
|
import { codeEquals } from "../codeEquals.js";
|
|
2
3
|
import { imports } from "../imports.js";
|
|
3
|
-
import { snippets } from "../snippets.js";
|
|
4
4
|
import { syntheticNamePrefix } from "../syntheticNamePrefix.js";
|
|
5
5
|
import { code, joinCode } from "../ts-poet-wrapper.js";
|
|
6
|
-
function
|
|
7
|
-
return code `\
|
|
8
|
-
export function ${syntheticNamePrefix}fromRdf(resource: ${imports.Resource}, options?: ${snippets.FromRdfOptions}): ${imports.Either}<Error, ${this.name}> {
|
|
9
|
-
return ${this.concreteMemberTypes.reduce((expression, memberType) => {
|
|
10
|
-
const memberTypeExpression = code `(${memberType.staticModuleName}.${syntheticNamePrefix}fromRdf(resource, { ...options, ignoreRdfType: false }) as ${imports.Either}<Error, ${this.name}>)`;
|
|
11
|
-
return expression !== null
|
|
12
|
-
? code `${expression}.altLazy(() => ${memberTypeExpression})`
|
|
13
|
-
: memberTypeExpression;
|
|
14
|
-
}, null)};
|
|
15
|
-
}`;
|
|
16
|
-
}
|
|
17
|
-
export function rdfFunctionDeclarations() {
|
|
6
|
+
export function ObjectUnionType_toRdfFunctionDeclaration() {
|
|
18
7
|
if (!this.features.has("rdf")) {
|
|
19
|
-
return
|
|
8
|
+
return Maybe.empty();
|
|
20
9
|
}
|
|
21
|
-
return [
|
|
22
|
-
ObjectUnionType_fromRdfFunctionDeclaration.bind(this)(),
|
|
23
|
-
ObjectUnionType_toRdfFunctionDeclaration.bind(this)(),
|
|
24
|
-
];
|
|
25
|
-
}
|
|
26
|
-
function ObjectUnionType_toRdfFunctionDeclaration() {
|
|
27
10
|
const parametersVariable = "_parameters";
|
|
28
11
|
const returnType = () => {
|
|
29
12
|
let returnType;
|
|
@@ -39,7 +22,7 @@ function ObjectUnionType_toRdfFunctionDeclaration() {
|
|
|
39
22
|
// The types agree
|
|
40
23
|
return returnType;
|
|
41
24
|
};
|
|
42
|
-
return code `\
|
|
25
|
+
return Maybe.of(code `\
|
|
43
26
|
export function ${syntheticNamePrefix}toRdf(${this.thisVariable}: ${this.name}, ${parametersVariable}?: { graph?: Exclude<${imports.Quad_Graph}, ${imports.Variable}>, resourceSet?: ${imports.ResourceSet} }): ${returnType()} {
|
|
44
27
|
${joinCode(this.concreteMemberTypes
|
|
45
28
|
.map((memberType) => {
|
|
@@ -55,6 +38,6 @@ ${joinCode(this.concreteMemberTypes
|
|
|
55
38
|
return code `if (${memberType.staticModuleName}.is${memberType.name}(${this.thisVariable})) { return ${returnExpression}; }`;
|
|
56
39
|
})
|
|
57
40
|
.concat(code `throw new Error("unrecognized type");`))}
|
|
58
|
-
}
|
|
41
|
+
}`);
|
|
59
42
|
}
|
|
60
|
-
//# sourceMappingURL=
|
|
43
|
+
//# sourceMappingURL=ObjectUnionType_toRdfFunctionDeclarations.js.map
|
|
@@ -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
|