@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.
Files changed (76) hide show
  1. package/dist/ShapesGraphToAstTransformer.js +10 -0
  2. package/dist/ast/Ast.d.ts +1 -0
  3. package/dist/generators/ts/AbstractNamedUnionType.js +39 -22
  4. package/dist/generators/ts/AbstractObjectSetType.d.ts +35 -0
  5. package/dist/generators/ts/AbstractObjectSetType.js +44 -0
  6. package/dist/generators/ts/GraphqlSchema.d.ts +22 -0
  7. package/dist/generators/ts/GraphqlSchema.js +87 -0
  8. package/dist/generators/ts/NamedObjectType.js +13 -4
  9. package/dist/generators/ts/NamedObjectUnionType.js +14 -5
  10. package/dist/generators/ts/ObjectSetType.d.ts +6 -0
  11. package/dist/generators/ts/ObjectSetType.js +36 -0
  12. package/dist/generators/ts/RdfjsDatasetObjectSetType.d.ts +6 -0
  13. package/dist/generators/ts/{rdfjsDatasetObjectSetClassDeclaration.js → RdfjsDatasetObjectSetType.js} +73 -69
  14. package/dist/generators/ts/Snippets.d.ts +1 -0
  15. package/dist/generators/ts/Snippets.js +7 -0
  16. package/dist/generators/ts/SparqlObjectSetType.d.ts +6 -0
  17. package/dist/generators/ts/{sparqlObjectSetClassDeclaration.js → SparqlObjectSetType.js} +40 -35
  18. package/dist/generators/ts/TsFeature.d.ts +1 -1
  19. package/dist/generators/ts/TsFeature.js +25 -7
  20. package/dist/generators/ts/TsGenerator.d.ts +7 -8
  21. package/dist/generators/ts/TsGenerator.js +141 -52
  22. package/dist/generators/ts/ZodGenerator.d.ts +1 -2
  23. package/dist/generators/ts/ZodGenerator.js +12 -12
  24. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +18 -12
  25. package/dist/generators/ts/_NamedObjectType/NamedObjectType_equalsFunctionDeclaration.js +1 -1
  26. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.d.ts +2 -1
  27. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterFunctionDeclaration.js +6 -2
  28. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.d.ts +2 -1
  29. package/dist/generators/ts/_NamedObjectType/NamedObjectType_filterTypeDeclaration.js +6 -2
  30. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.js +1 -1
  31. package/dist/generators/ts/_NamedObjectType/NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.js +1 -1
  32. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromJsonFunctionDeclaration.js +1 -1
  33. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceFunctionDeclaration.js +1 -1
  34. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfResourceValuesFunctionDeclaration.js +1 -1
  35. package/dist/generators/ts/_NamedObjectType/NamedObjectType_fromRdfTypeVariableStatement.js +1 -1
  36. package/dist/generators/ts/_NamedObjectType/NamedObjectType_graphqlTypeVariableStatement.js +1 -1
  37. package/dist/generators/ts/_NamedObjectType/NamedObjectType_hashFunctionDeclarations.js +1 -1
  38. package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.d.ts +2 -1
  39. package/dist/generators/ts/_NamedObjectType/NamedObjectType_isTypeFunctionDeclaration.js +6 -2
  40. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonParseFunctionDeclaration.js +1 -1
  41. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonSchemaFunctionDeclaration.js +1 -1
  42. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonTypeAliasDeclaration.js +1 -1
  43. package/dist/generators/ts/_NamedObjectType/NamedObjectType_jsonUiSchemaFunctionDeclaration.js +1 -1
  44. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.d.ts +2 -1
  45. package/dist/generators/ts/_NamedObjectType/NamedObjectType_schemaVariableStatement.js +6 -2
  46. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryFunctionDeclaration.js +1 -1
  47. package/dist/generators/ts/_NamedObjectType/NamedObjectType_sparqlConstructQueryStringFunctionDeclaration.js +1 -1
  48. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +3 -2
  49. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toRdfResourceFunctionDeclaration.js +1 -1
  50. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +5 -4
  51. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlConstructTriplesFunctionDeclaration.js +1 -1
  52. package/dist/generators/ts/_NamedObjectType/NamedObjectType_valueSparqlWherePatternsFunctionDeclaration.js +1 -1
  53. package/dist/generators/ts/_NamedObjectType/ShaclProperty.js +4 -2
  54. package/dist/generators/ts/_NamedObjectType/identifierTypeDeclarations.js +3 -0
  55. package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.js +2 -2
  56. package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +2 -2
  57. package/dist/generators/ts/_snippets/snippets_PropertyPath.js +12 -6
  58. package/dist/generators/ts/_snippets/snippets__FromRdfResourceFunction.js +2 -2
  59. package/dist/generators/ts/_snippets/snippets_monkeyPatchObject.d.ts +3 -0
  60. package/dist/generators/ts/_snippets/snippets_monkeyPatchObject.js +16 -0
  61. package/dist/generators/ts/_snippets/snippets_wrap_FromRdfResourceFunction.js +3 -4
  62. package/dist/input/generated.d.ts +1 -286
  63. package/dist/input/generated.js +104 -1093
  64. package/package.json +2 -2
  65. package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +0 -10
  66. package/dist/generators/ts/graphqlSchemaVariableStatement.js +0 -84
  67. package/dist/generators/ts/objectSetDeclarations.d.ts +0 -9
  68. package/dist/generators/ts/objectSetDeclarations.js +0 -30
  69. package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +0 -9
  70. package/dist/generators/ts/objectSetInterfaceDeclaration.js +0 -26
  71. package/dist/generators/ts/objectSetMethodSignatures.d.ts +0 -18
  72. package/dist/generators/ts/objectSetMethodSignatures.js +0 -31
  73. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +0 -9
  74. package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +0 -9
  75. package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.d.ts +0 -12
  76. package/dist/generators/ts/unsupportedObjectSetMethodDeclarations.js +0 -21
@@ -1,23 +1,30 @@
1
- import { objectSetMethodSignatures } from "./objectSetMethodSignatures.js";
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
- import { unsupportedObjectSetMethodDeclarations } from "./unsupportedObjectSetMethodDeclarations.js";
4
- export function rdfjsDatasetObjectSetClassDeclaration({ namedObjectTypes, namedObjectUnionTypes, }) {
5
- const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
6
- const namedObjectTypeType = code `\
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
- const parameters = {
13
- query: `query?: ${syntheticNamePrefix}ObjectSet.Query<ObjectFilterT, ObjectIdentifierT>`,
14
- };
15
- const typeParameters = {
16
- ObjectT: code `ObjectT extends { readonly $identifier: () => ObjectIdentifierT }`,
17
- ObjectFilterT: code `ObjectFilterT`,
18
- ObjectIdentifierT: code `ObjectIdentifierT extends ${this.reusables.imports.BlankNode} | ${this.reusables.imports.NamedNode}`,
19
- };
20
- return code `\
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
- ...[...namedObjectTypes, ...namedObjectUnionTypes].flatMap((namedObjectType) => {
43
- if (!this.configuration.features.has("rdf")) {
44
- return Object.values(unsupportedObjectSetMethodDeclarations.call(this, {
45
- namedObjectType,
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
- // objectSync
58
- code `\
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
- // objectCount
63
- code `\
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
- // objectCountSync
68
- code `\
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
- // objectIdentifiers
73
- code `\
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
- // objectIdentifiersSync
78
- code `\
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
- // objects
83
- code `\
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
- // 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 `\
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
- case "NamedObjectUnionType":
103
- return delegatingMethods.concat(code `\
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
- default:
110
- namedObjectType;
111
- return [];
112
- }
113
- }),
114
- ...(namedObjectTypes.length > 0
115
- ? [
116
- code `\
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
- ...(namedObjectUnionTypes.length > 0
207
- ? [
208
- code `\
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
- ], { on: "\n\n" })}
317
+ ]
318
+ : []),
319
+ ], { on: "\n\n" })}
320
320
  }`;
321
+ }
321
322
  }
322
- //# sourceMappingURL=rdfjsDatasetObjectSetClassDeclaration.js.map
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
- import { objectSetMethodSignatures } from "./objectSetMethodSignatures.js";
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
- import { unsupportedObjectSetMethodDeclarations } from "./unsupportedObjectSetMethodDeclarations.js";
4
- export function sparqlObjectSetClassDeclaration({ namedObjectTypes, namedObjectUnionTypes, }) {
5
- const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
6
- const parameters = {
7
- constructObjectType: code `namedObjectType: {\
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
- query: code `query?: ${syntheticNamePrefix}SparqlObjectSet.Query<ObjectFilterT, ObjectIdentifierT>`,
13
- selectObjectTypeType: code `namedObjectType: { focusSparqlWherePatterns: ${this.reusables.snippets.FocusSparqlWherePatternsFunction}<ObjectFilterT> }`,
14
- };
15
- 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}[]>; }`;
16
- const typeParameters = {
17
- ObjectT: code `ObjectT extends { readonly $identifier: () => ObjectIdentifierT }`,
18
- ObjectFilterT: code `ObjectFilterT`,
19
- ObjectIdentifierT: code `ObjectIdentifierT extends ${this.reusables.imports.BlankNode} | ${this.reusables.imports.NamedNode}`,
20
- };
21
- return code `\
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
- if (!this.configuration.features.has("sparql")) {
36
- return Object.values(unsupportedObjectSetMethodDeclarations.call(this, {
37
- namedObjectType,
38
- }));
39
- }
40
- const methodSignatures = objectSetMethodSignatures.call(this, {
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
- code `\
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
- code `\
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
- code `\
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
- }), { on: "\n\n" })}
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
- //# sourceMappingURL=sparqlObjectSetClassDeclaration.js.map
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", "graphql", "hash", "json", "rdf", "sparql"];
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
- "create",
3
- "equals",
4
- "graphql",
5
- "hash",
6
- "json",
7
- "rdf",
8
- "sparql",
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 typeFactory;
8
- protected readonly configuration: TsGenerator.Configuration;
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 inferFeatures(features: ReadonlySet<TsFeature>): Set<"equals" | "create" | "graphql" | "hash" | "json" | "rdf" | "sparql">;
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