@shaclmate/compiler 4.0.35 → 4.0.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ShapesGraphToAstTransformer.js +10 -0
- package/dist/ast/Ast.d.ts +1 -0
- package/dist/generators/ts/AbstractNamedUnionType.js +39 -22
- package/dist/generators/ts/AbstractObjectSetType.d.ts +35 -0
- package/dist/generators/ts/AbstractObjectSetType.js +44 -0
- package/dist/generators/ts/GraphqlSchema.d.ts +22 -0
- package/dist/generators/ts/GraphqlSchema.js +87 -0
- package/dist/generators/ts/NamedObjectType.js +13 -4
- package/dist/generators/ts/NamedObjectUnionType.js +14 -5
- package/dist/generators/ts/ObjectSetType.d.ts +6 -0
- package/dist/generators/ts/ObjectSetType.js +36 -0
- package/dist/generators/ts/RdfjsDatasetObjectSetType.d.ts +6 -0
- package/dist/generators/ts/{rdfjsDatasetObjectSetClassDeclaration.js → RdfjsDatasetObjectSetType.js} +73 -69
- package/dist/generators/ts/Snippets.d.ts +1 -0
- package/dist/generators/ts/Snippets.js +7 -0
- package/dist/generators/ts/SparqlObjectSetType.d.ts +6 -0
- package/dist/generators/ts/{sparqlObjectSetClassDeclaration.js → SparqlObjectSetType.js} +40 -35
- package/dist/generators/ts/TsFeature.d.ts +1 -1
- package/dist/generators/ts/TsFeature.js +25 -7
- package/dist/generators/ts/TsGenerator.d.ts +7 -8
- package/dist/generators/ts/TsGenerator.js +141 -52
- package/dist/generators/ts/ZodGenerator.d.ts +1 -2
- package/dist/generators/ts/ZodGenerator.js +12 -12
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +18 -12
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +2 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js +6 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +2 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.js +6 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +2 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js +6 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.d.ts +2 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +6 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +3 -2
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +5 -4
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
- package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +4 -2
- package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.js +3 -0
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.js +2 -2
- package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +2 -2
- package/dist/generators/ts/_snippets/snippets_PropertyPath.js +12 -6
- package/dist/generators/ts/_snippets/snippets__FromRdfResourceFunction.js +2 -2
- package/dist/generators/ts/_snippets/snippets_monkeyPatchObject.d.ts +3 -0
- package/dist/generators/ts/_snippets/snippets_monkeyPatchObject.js +16 -0
- package/dist/generators/ts/_snippets/snippets_wrap_FromRdfResourceFunction.js +3 -4
- package/dist/input/generated.d.ts +1 -286
- package/dist/input/generated.js +104 -1093
- package/package.json +2 -2
- package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +0 -10
- package/dist/generators/ts/graphqlSchemaVariableStatement.js +0 -84
- package/dist/generators/ts/objectSetDeclarations.d.ts +0 -9
- package/dist/generators/ts/objectSetDeclarations.js +0 -30
- package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +0 -9
- package/dist/generators/ts/objectSetInterfaceDeclaration.js +0 -26
- package/dist/generators/ts/objectSetMethodSignatures.d.ts +0 -18
- package/dist/generators/ts/objectSetMethodSignatures.js +0 -31
- package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +0 -9
- package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +0 -9
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +0 -12
- package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +0 -21
package/dist/generators/ts/{rdfjsDatasetObjectSetClassDeclaration.js → RdfjsDatasetObjectSetType.js}
RENAMED
|
@@ -1,23 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Memoize } from "typescript-memoize";
|
|
8
|
+
import { AbstractObjectSetType } from "./AbstractObjectSetType.js";
|
|
2
9
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
10
|
+
export class RdfjsDatasetObjectSetType extends AbstractObjectSetType {
|
|
11
|
+
get declaration() {
|
|
12
|
+
const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
|
|
13
|
+
const namedObjectTypeType = code `\
|
|
7
14
|
{
|
|
8
15
|
filter: (filter: ObjectFilterT, value: ObjectT) => boolean;
|
|
9
16
|
fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}<ObjectT>;
|
|
10
17
|
fromRdfTypes: readonly ${this.reusables.imports.NamedNode}[]
|
|
11
18
|
}`;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const parameters = {
|
|
20
|
+
query: `query?: ${syntheticNamePrefix}ObjectSet.Query<ObjectFilterT, ObjectIdentifierT>`,
|
|
21
|
+
};
|
|
22
|
+
const typeParameters = {
|
|
23
|
+
ObjectT: code `ObjectT extends { readonly $identifier: () => ObjectIdentifierT }`,
|
|
24
|
+
ObjectFilterT: code `ObjectFilterT`,
|
|
25
|
+
ObjectIdentifierT: code `ObjectIdentifierT extends ${this.reusables.imports.BlankNode} | ${this.reusables.imports.NamedNode}`,
|
|
26
|
+
};
|
|
27
|
+
return code `\
|
|
21
28
|
export class ${syntheticNamePrefix}RdfjsDatasetObjectSet implements ${syntheticNamePrefix}ObjectSet {
|
|
22
29
|
readonly #dataset: ${this.reusables.imports.DatasetCore} | (() => ${this.reusables.imports.DatasetCore});
|
|
23
30
|
readonly #graph?: Exclude<${this.reusables.imports.Quad_Graph}, ${this.reusables.imports.Variable}>;
|
|
@@ -39,81 +46,74 @@ export class ${syntheticNamePrefix}RdfjsDatasetObjectSet implements ${syntheticN
|
|
|
39
46
|
}
|
|
40
47
|
|
|
41
48
|
${joinCode([
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
const methodSignatures = objectSetMethodSignatures.call(this, {
|
|
49
|
-
namedObjectType,
|
|
50
|
-
});
|
|
51
|
-
const delegatingMethods = [
|
|
52
|
-
// object
|
|
53
|
-
code `\
|
|
49
|
+
...[...this.namedObjectTypes, ...this.namedObjectUnionTypes].flatMap((namedObjectType) => {
|
|
50
|
+
const methodSignatures = this.methodSignatures(namedObjectType);
|
|
51
|
+
const delegatingMethods = [
|
|
52
|
+
// object
|
|
53
|
+
code `\
|
|
54
54
|
async ${methodSignatures.object.name}(${methodSignatures.object.parameters}): ${methodSignatures.object.returnType} {
|
|
55
55
|
return this.${methodSignatures.object.name}Sync(identifier, options);
|
|
56
56
|
}`,
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
// objectSync
|
|
58
|
+
code `\
|
|
59
59
|
${methodSignatures.object.name}Sync(${methodSignatures.object.parameters}): ${this.reusables.imports.Either}<Error, ${namedObjectType.name}> {
|
|
60
60
|
return this.${methodSignatures.objects.name}Sync({ identifiers: [identifier], preferredLanguages: options?.preferredLanguages }).map(objects => objects[0]);
|
|
61
61
|
}`,
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
// objectCount
|
|
63
|
+
code `\
|
|
64
64
|
async ${methodSignatures.objectCount.name}(${methodSignatures.objectCount.parameters}): ${methodSignatures.objectCount.returnType} {
|
|
65
65
|
return this.${methodSignatures.objectCount.name}Sync(query);
|
|
66
66
|
}`,
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
// objectCountSync
|
|
68
|
+
code `\
|
|
69
69
|
${methodSignatures.objectCount.name}Sync(${methodSignatures.objectCount.parameters}): ${this.reusables.imports.Either}<Error, number> {
|
|
70
70
|
return this.${methodSignatures.objects.name}Sync(query).map(objects => objects.length);
|
|
71
71
|
}`,
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
// objectIdentifiers
|
|
73
|
+
code `\
|
|
74
74
|
async ${methodSignatures.objectIdentifiers.name}(${methodSignatures.objectIdentifiers.parameters}): ${methodSignatures.objectIdentifiers.returnType} {
|
|
75
75
|
return this.${methodSignatures.objectIdentifiers.name}Sync(query);
|
|
76
76
|
}`,
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
// objectIdentifiersSync
|
|
78
|
+
code `\
|
|
79
79
|
${methodSignatures.objectIdentifiers.name}Sync(${methodSignatures.objectIdentifiers.parameters}): ${this.reusables.imports.Either}<Error, readonly ${namedObjectType.identifierTypeAlias}[]> {
|
|
80
80
|
return this.${methodSignatures.objects.name}Sync(query).map(objects => objects.map(object => object.${syntheticNamePrefix}identifier()));
|
|
81
81
|
}`,
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
// objects
|
|
83
|
+
code `\
|
|
84
84
|
async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}): ${methodSignatures.objects.returnType} {
|
|
85
85
|
return this.${methodSignatures.objects.name}Sync(query);
|
|
86
86
|
}`,
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
87
|
+
// objectsSync has per-object type logic, not just forwarding
|
|
88
|
+
];
|
|
89
|
+
const runtimeObjectType = (filterFunction, namedObjectType) => {
|
|
90
|
+
const fromRdfTypes = namedObjectType.fromRdfTypeVariable
|
|
91
|
+
.toList()
|
|
92
|
+
.concat(namedObjectType.descendantFromRdfTypeVariables);
|
|
93
|
+
return code `{ filter: ${filterFunction}, fromRdfResource: ${namedObjectType.name}.fromRdfResource, fromRdfTypes: ${fromRdfTypes.length > 0 ? code `[${joinCode(fromRdfTypes, { on: ", " })}]` : "[]"} }`;
|
|
94
|
+
};
|
|
95
|
+
switch (namedObjectType.kind) {
|
|
96
|
+
case "NamedObjectType": {
|
|
97
|
+
return delegatingMethods.concat(code `\
|
|
98
98
|
${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${this.reusables.imports.Either}<Error, readonly ${namedObjectType.name}[]> {
|
|
99
99
|
return this.#objectsSync<${namedObjectType.name}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType(namedObjectType.filterFunction, namedObjectType)}, query);
|
|
100
100
|
}`);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
101
|
+
}
|
|
102
|
+
case "NamedObjectUnionType":
|
|
103
|
+
return delegatingMethods.concat(code `\
|
|
104
104
|
${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${this.reusables.imports.Either}<Error, readonly ${namedObjectType.name}[]> {
|
|
105
105
|
return this.#objectUnionsSync<${namedObjectType.name}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>([
|
|
106
106
|
${joinCode(namedObjectType.members.map((member) => runtimeObjectType(namedObjectType.filterFunction, member.type)), { on: ", " })}
|
|
107
107
|
], query);
|
|
108
108
|
}`);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
default:
|
|
110
|
+
namedObjectType;
|
|
111
|
+
return [];
|
|
112
|
+
}
|
|
113
|
+
}),
|
|
114
|
+
...(this.namedObjectTypes.length > 0
|
|
115
|
+
? [
|
|
116
|
+
code `\
|
|
117
117
|
#objectsSync<${typeParameters.ObjectT}, ${typeParameters.ObjectFilterT}, ${typeParameters.ObjectIdentifierT}>(namedObjectType: ${namedObjectTypeType}, ${parameters.query}): ${this.reusables.imports.Either}<Error, readonly ObjectT[]> {
|
|
118
118
|
const graph = query?.graph ?? this.#graph;
|
|
119
119
|
|
|
@@ -201,11 +201,11 @@ ${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${
|
|
|
201
201
|
}
|
|
202
202
|
return ${this.reusables.imports.Right}(objects);
|
|
203
203
|
}`,
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
204
|
+
]
|
|
205
|
+
: []),
|
|
206
|
+
...(this.namedObjectUnionTypes.length > 0
|
|
207
|
+
? [
|
|
208
|
+
code `\
|
|
209
209
|
#objectUnionsSync<${typeParameters.ObjectT}, ${typeParameters.ObjectFilterT}, ${typeParameters.ObjectIdentifierT}>(namedObjectTypes: readonly ${namedObjectTypeType}[], ${parameters.query}): ${this.reusables.imports.Either}<Error, readonly ObjectT[]> {
|
|
210
210
|
const graph = query?.graph ?? this.#graph;
|
|
211
211
|
|
|
@@ -314,9 +314,13 @@ ${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${
|
|
|
314
314
|
}
|
|
315
315
|
return ${this.reusables.imports.Right}(objects);
|
|
316
316
|
}`,
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
317
|
+
]
|
|
318
|
+
: []),
|
|
319
|
+
], { on: "\n\n" })}
|
|
320
320
|
}`;
|
|
321
|
+
}
|
|
321
322
|
}
|
|
322
|
-
|
|
323
|
+
__decorate([
|
|
324
|
+
Memoize()
|
|
325
|
+
], RdfjsDatasetObjectSetType.prototype, "declaration", null);
|
|
326
|
+
//# sourceMappingURL=RdfjsDatasetObjectSetType.js.map
|
|
@@ -124,6 +124,7 @@ export declare class Snippets {
|
|
|
124
124
|
get maybeEquals(): Snippet;
|
|
125
125
|
get maybeSparqlConstructTriples(): Snippet;
|
|
126
126
|
get maybeSparqlWherePatterns(): Snippet;
|
|
127
|
+
get monkeyPatchObject(): Snippet;
|
|
127
128
|
get normalizeSparqlWherePatterns(): Snippet;
|
|
128
129
|
get numericSparqlWherePatterns(): Snippet;
|
|
129
130
|
get parseBlankNode(): Snippet;
|
|
@@ -99,6 +99,7 @@ import { snippets_MaybeSchema } from "./_snippets/snippets_MaybeSchema.js";
|
|
|
99
99
|
import { snippets_maybeEquals } from "./_snippets/snippets_maybeEquals.js";
|
|
100
100
|
import { snippets_maybeSparqlConstructTriples } from "./_snippets/snippets_maybeSparqlConstructTriples.js";
|
|
101
101
|
import { snippets_maybeSparqlWherePatterns } from "./_snippets/snippets_maybeSparqlWherePatterns.js";
|
|
102
|
+
import { snippets_monkeyPatchObject } from "./_snippets/snippets_monkeyPatchObject.js";
|
|
102
103
|
import { snippets_NumericFilter } from "./_snippets/snippets_NumericFilter.js";
|
|
103
104
|
import { snippets_NumericSchema } from "./_snippets/snippets_NumericSchema.js";
|
|
104
105
|
import { snippets_normalizeSparqlWherePatterns } from "./_snippets/snippets_normalizeSparqlWherePatterns.js";
|
|
@@ -505,6 +506,9 @@ export class Snippets {
|
|
|
505
506
|
get maybeSparqlWherePatterns() {
|
|
506
507
|
return this.snippet(snippets_maybeSparqlWherePatterns);
|
|
507
508
|
}
|
|
509
|
+
get monkeyPatchObject() {
|
|
510
|
+
return this.snippet(snippets_monkeyPatchObject);
|
|
511
|
+
}
|
|
508
512
|
get normalizeSparqlWherePatterns() {
|
|
509
513
|
return this.snippet(snippets_normalizeSparqlWherePatterns);
|
|
510
514
|
}
|
|
@@ -931,6 +935,9 @@ __decorate([
|
|
|
931
935
|
__decorate([
|
|
932
936
|
Memoize()
|
|
933
937
|
], Snippets.prototype, "maybeSparqlWherePatterns", null);
|
|
938
|
+
__decorate([
|
|
939
|
+
Memoize()
|
|
940
|
+
], Snippets.prototype, "monkeyPatchObject", null);
|
|
934
941
|
__decorate([
|
|
935
942
|
Memoize()
|
|
936
943
|
], Snippets.prototype, "normalizeSparqlWherePatterns", null);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AbstractObjectSetType } from "./AbstractObjectSetType.js";
|
|
2
|
+
import { type Code } from "./ts-poet-wrapper.js";
|
|
3
|
+
export declare class SparqlObjectSetType extends AbstractObjectSetType {
|
|
4
|
+
get declaration(): Code;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=SparqlObjectSetType.d.ts.map
|
|
@@ -1,24 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Memoize } from "typescript-memoize";
|
|
8
|
+
import { AbstractObjectSetType } from "./AbstractObjectSetType.js";
|
|
2
9
|
import { code, joinCode } from "./ts-poet-wrapper.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
10
|
+
export class SparqlObjectSetType extends AbstractObjectSetType {
|
|
11
|
+
get declaration() {
|
|
12
|
+
const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
|
|
13
|
+
const parameters = {
|
|
14
|
+
constructObjectType: code `namedObjectType: {\
|
|
8
15
|
focusSparqlWherePatterns: ${this.reusables.snippets.FocusSparqlWherePatternsFunction}<ObjectFilterT>;
|
|
9
16
|
fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}<ObjectT>;
|
|
10
17
|
sparqlConstructQueryString: (parameters: { filter?: ObjectFilterT; subject: ${this.reusables.imports.NamedNode} | ${this.reusables.imports.Variable}; } & Omit<${this.reusables.imports.sparqljs}.ConstructQuery, "prefixes" | "queryType" | "type"> & ${this.reusables.imports.sparqljs}.GeneratorOptions) => string;
|
|
11
18
|
}`,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
query: code `query?: ${syntheticNamePrefix}SparqlObjectSet.Query<ObjectFilterT, ObjectIdentifierT>`,
|
|
20
|
+
selectObjectTypeType: code `namedObjectType: { focusSparqlWherePatterns: ${this.reusables.snippets.FocusSparqlWherePatternsFunction}<ObjectFilterT> }`,
|
|
21
|
+
};
|
|
22
|
+
const sparqlClientType = code `{ queryBindings: (query: string) => Promise<readonly Record<string, ${this.reusables.imports.BlankNode} | ${this.reusables.imports.Literal} | ${this.reusables.imports.NamedNode}>[]>; queryQuads: (query: string) => Promise<readonly ${this.reusables.imports.Quad}[]>; }`;
|
|
23
|
+
const typeParameters = {
|
|
24
|
+
ObjectT: code `ObjectT extends { readonly $identifier: () => ObjectIdentifierT }`,
|
|
25
|
+
ObjectFilterT: code `ObjectFilterT`,
|
|
26
|
+
ObjectIdentifierT: code `ObjectIdentifierT extends ${this.reusables.imports.BlankNode} | ${this.reusables.imports.NamedNode}`,
|
|
27
|
+
};
|
|
28
|
+
return code `\
|
|
22
29
|
export class ${syntheticNamePrefix}SparqlObjectSet implements ${syntheticNamePrefix}ObjectSet {
|
|
23
30
|
readonly #countVariable = ${this.reusables.imports.dataFactory}.variable!("count");;
|
|
24
31
|
readonly #graph?: Exclude<${this.reusables.imports.Quad_Graph}, ${this.reusables.imports.Variable}>;
|
|
@@ -31,36 +38,30 @@ export class ${syntheticNamePrefix}SparqlObjectSet implements ${syntheticNamePre
|
|
|
31
38
|
this.#sparqlClient = sparqlClient;
|
|
32
39
|
}
|
|
33
40
|
|
|
34
|
-
${joinCode([...namedObjectTypes, ...namedObjectUnionTypes].flatMap((namedObjectType) => {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
namedObjectType,
|
|
42
|
-
queryT: `${syntheticNamePrefix}SparqlObjectSet.Query`,
|
|
43
|
-
});
|
|
44
|
-
const runtimeObjectType = namedObjectType.name;
|
|
45
|
-
return [
|
|
46
|
-
code `\
|
|
41
|
+
${joinCode([...this.namedObjectTypes, ...this.namedObjectUnionTypes].flatMap((namedObjectType) => {
|
|
42
|
+
const methodSignatures = this.methodSignatures(namedObjectType, {
|
|
43
|
+
queryT: `${syntheticNamePrefix}SparqlObjectSet.Query`,
|
|
44
|
+
});
|
|
45
|
+
const runtimeObjectType = namedObjectType.name;
|
|
46
|
+
return [
|
|
47
|
+
code `\
|
|
47
48
|
async ${methodSignatures.object.name}(${methodSignatures.object.parameters}): ${methodSignatures.object.returnType} {
|
|
48
49
|
return (await this.${methodSignatures.objects.name}({ identifiers: [identifier], preferredLanguages: options?.preferredLanguages })).map(objects => objects[0]);
|
|
49
50
|
}`,
|
|
50
|
-
|
|
51
|
+
code `\
|
|
51
52
|
async ${methodSignatures.objectCount.name}(${methodSignatures.objectCount.parameters}): ${methodSignatures.objectCount.returnType} {
|
|
52
53
|
return this.#objectCount<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType}, query);
|
|
53
54
|
}`,
|
|
54
|
-
|
|
55
|
+
code `\
|
|
55
56
|
async ${methodSignatures.objectIdentifiers.name}(${methodSignatures.objectIdentifiers.parameters}): ${methodSignatures.objectIdentifiers.returnType} {
|
|
56
57
|
return this.#objectIdentifiers<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType}, query);
|
|
57
58
|
}`,
|
|
58
|
-
|
|
59
|
+
code `\
|
|
59
60
|
async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}): ${methodSignatures.objects.returnType} {
|
|
60
61
|
return this.#objects<${namedObjectType.name}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType}, query);
|
|
61
62
|
}`,
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
];
|
|
64
|
+
}), { on: "\n\n" })}
|
|
64
65
|
|
|
65
66
|
#mapBindingsToCount(bindings: readonly Record<string, ${this.reusables.imports.BlankNode} | ${this.reusables.imports.Literal} | ${this.reusables.imports.NamedNode}>[], variable: string): ${this.reusables.imports.Either}<Error, number> {
|
|
66
67
|
if (bindings.length === 0) {
|
|
@@ -232,5 +233,9 @@ async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}):
|
|
|
232
233
|
export namespace ${syntheticNamePrefix}SparqlObjectSet {
|
|
233
234
|
export type Query<${typeParameters.ObjectFilterT}, ${typeParameters.ObjectIdentifierT}> = ${syntheticNamePrefix}ObjectSet.Query<ObjectFilterT, ObjectIdentifierT> & { readonly order?: (objectVariable: ${this.reusables.imports.Variable}) => readonly ${this.reusables.imports.sparqljs}.Ordering[]; readonly where?: (objectVariable: ${this.reusables.imports.Variable}) => readonly ${this.reusables.imports.sparqljs}.Pattern[] };
|
|
234
235
|
}`;
|
|
236
|
+
}
|
|
235
237
|
}
|
|
236
|
-
|
|
238
|
+
__decorate([
|
|
239
|
+
Memoize()
|
|
240
|
+
], SparqlObjectSetType.prototype, "declaration", null);
|
|
241
|
+
//# sourceMappingURL=SparqlObjectSetType.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type TsFeature = (typeof TS_FEATURES)[number];
|
|
2
|
-
export declare const TS_FEATURES: readonly ["create", "equals", "
|
|
2
|
+
export declare const TS_FEATURES: readonly ["GraphQL", "JSON", "Object.create", "Object.equals", "Object.filter", "Object.fromJson", "Object.fromRdf", "Object.hash", "Object.JSON", "Object.JSON.type", "Object.JSON.parse", "Object.JSON.schema", "Object.JSON.uiSchema", "Object.RDF", "Object.schema", "Object.SPARQL", "Object.toJson", "Object.toRdf", "Object.toString", "Object.type", "ObjectSet", "RDF", "RdfjsDatasetObjectSet", "SPARQL", "SparqlObjectSet"];
|
|
3
3
|
//# sourceMappingURL=TsFeature.d.ts.map
|
|
@@ -1,10 +1,28 @@
|
|
|
1
1
|
export const TS_FEATURES = [
|
|
2
|
-
"
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
2
|
+
"GraphQL",
|
|
3
|
+
"JSON",
|
|
4
|
+
"Object.create",
|
|
5
|
+
"Object.equals",
|
|
6
|
+
"Object.filter",
|
|
7
|
+
"Object.fromJson",
|
|
8
|
+
"Object.fromRdf",
|
|
9
|
+
"Object.hash",
|
|
10
|
+
"Object.JSON",
|
|
11
|
+
"Object.JSON.type",
|
|
12
|
+
"Object.JSON.parse",
|
|
13
|
+
"Object.JSON.schema",
|
|
14
|
+
"Object.JSON.uiSchema",
|
|
15
|
+
"Object.RDF",
|
|
16
|
+
"Object.schema",
|
|
17
|
+
"Object.SPARQL",
|
|
18
|
+
"Object.toJson",
|
|
19
|
+
"Object.toRdf",
|
|
20
|
+
"Object.toString",
|
|
21
|
+
"Object.type",
|
|
22
|
+
"ObjectSet",
|
|
23
|
+
"RDF",
|
|
24
|
+
"RdfjsDatasetObjectSet",
|
|
25
|
+
"SPARQL",
|
|
26
|
+
"SparqlObjectSet",
|
|
9
27
|
];
|
|
10
28
|
//# sourceMappingURL=TsFeature.js.map
|
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
import type { Logger } from "ts-log";
|
|
2
2
|
import * as ast from "../../ast/index.js";
|
|
3
3
|
import type { Generator } from "../Generator.js";
|
|
4
|
-
import { Reusables } from "./Reusables.js";
|
|
5
4
|
import type { TsFeature } from "./TsFeature.js";
|
|
6
5
|
export declare class TsGenerator implements Generator {
|
|
7
|
-
private readonly
|
|
8
|
-
|
|
9
|
-
protected readonly logger: Logger;
|
|
10
|
-
protected readonly reusables: Reusables;
|
|
6
|
+
private readonly configuration?;
|
|
7
|
+
private readonly logger;
|
|
11
8
|
constructor({ configuration, logger, }: {
|
|
12
|
-
configuration?: TsGenerator.Configuration
|
|
9
|
+
configuration?: Partial<TsGenerator.Configuration>;
|
|
13
10
|
logger: Logger;
|
|
14
11
|
});
|
|
15
12
|
generate(ast_: ast.Ast): string;
|
|
13
|
+
private objectSetTypeDeclarations;
|
|
16
14
|
/**
|
|
17
15
|
* Synthesize the $Object union.
|
|
18
16
|
*/
|
|
@@ -21,11 +19,12 @@ export declare class TsGenerator implements Generator {
|
|
|
21
19
|
export declare namespace TsGenerator {
|
|
22
20
|
interface Configuration {
|
|
23
21
|
readonly features: ReadonlySet<TsFeature>;
|
|
22
|
+
readonly finalized: true;
|
|
24
23
|
readonly syntheticNamePrefix: string;
|
|
25
24
|
}
|
|
26
25
|
namespace Configuration {
|
|
27
|
-
const default_: Configuration
|
|
28
|
-
function
|
|
26
|
+
const default_: Omit<Configuration, "finalized">;
|
|
27
|
+
function finalize(ast: ast.Ast, partialConfiguration?: Partial<Configuration>): Configuration;
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
30
|
//# sourceMappingURL=TsGenerator.d.ts.map
|