@shaclmate/compiler 4.0.36 → 4.0.38

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 (42) 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 +6 -2
  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 +6 -2
  9. package/dist/generators/ts/ObjectSetType.d.ts +6 -0
  10. package/dist/generators/ts/ObjectSetType.js +36 -0
  11. package/dist/generators/ts/RdfjsDatasetObjectSetType.d.ts +6 -0
  12. package/dist/generators/ts/{rdfjsDatasetObjectSetClassDeclaration.js → RdfjsDatasetObjectSetType.js} +73 -63
  13. package/dist/generators/ts/Snippets.d.ts +1 -0
  14. package/dist/generators/ts/Snippets.js +7 -0
  15. package/dist/generators/ts/SparqlObjectSetType.d.ts +6 -0
  16. package/dist/generators/ts/{sparqlObjectSetClassDeclaration.js → SparqlObjectSetType.js} +40 -29
  17. package/dist/generators/ts/TsGenerator.d.ts +7 -8
  18. package/dist/generators/ts/TsGenerator.js +108 -77
  19. package/dist/generators/ts/ZodGenerator.d.ts +1 -2
  20. package/dist/generators/ts/ZodGenerator.js +12 -12
  21. package/dist/generators/ts/_NamedObjectType/NamedObjectType_createFunctionDeclaration.js +17 -11
  22. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toJsonFunctionDeclaration.js +2 -1
  23. package/dist/generators/ts/_NamedObjectType/NamedObjectType_toStringFunctionDeclarations.js +2 -4
  24. package/dist/generators/ts/_snippets/snippets_FromRdfResourceFunction.js +2 -2
  25. package/dist/generators/ts/_snippets/snippets_FromRdfResourceValuesFunction.js +2 -2
  26. package/dist/generators/ts/_snippets/snippets__FromRdfResourceFunction.js +2 -2
  27. package/dist/generators/ts/_snippets/snippets_monkeyPatchObject.d.ts +3 -0
  28. package/dist/generators/ts/_snippets/snippets_monkeyPatchObject.js +16 -0
  29. package/dist/generators/ts/_snippets/snippets_wrap_FromRdfResourceFunction.js +3 -4
  30. package/dist/input/generated.d.ts +1 -286
  31. package/dist/input/generated.js +28 -1015
  32. package/package.json +6 -6
  33. package/dist/generators/ts/graphqlSchemaVariableStatement.d.ts +0 -10
  34. package/dist/generators/ts/graphqlSchemaVariableStatement.js +0 -84
  35. package/dist/generators/ts/objectSetDeclarations.d.ts +0 -9
  36. package/dist/generators/ts/objectSetDeclarations.js +0 -27
  37. package/dist/generators/ts/objectSetInterfaceDeclaration.d.ts +0 -9
  38. package/dist/generators/ts/objectSetInterfaceDeclaration.js +0 -26
  39. package/dist/generators/ts/objectSetMethodSignatures.d.ts +0 -18
  40. package/dist/generators/ts/objectSetMethodSignatures.js +0 -31
  41. package/dist/generators/ts/rdfjsDatasetObjectSetClassDeclaration.d.ts +0 -9
  42. package/dist/generators/ts/sparqlObjectSetClassDeclaration.d.ts +0 -9
@@ -143,6 +143,16 @@ export class ShapesGraphToAstTransformer {
143
143
  }
144
144
  }
145
145
  return Either.of({
146
+ lazyTypesCount: [...this.cachedAstTypesByShapeIdentifier.values()].reduce((acc, astType) => {
147
+ switch (astType.kind) {
148
+ case "LazyObjectType":
149
+ case "LazyObjectOptionType":
150
+ case "LazyObjectSetType":
151
+ return acc + 1;
152
+ default:
153
+ return acc;
154
+ }
155
+ }, 0),
146
156
  namedIntersectionTypes: astNamedIntersectionTypes,
147
157
  namedObjectTypes: astObjectTypes.concat(Object.values(syntheticAstObjectTypesByName)),
148
158
  namedUnionTypes: astNamedUnionTypes,
package/dist/ast/Ast.d.ts CHANGED
@@ -2,6 +2,7 @@ import type { IntersectionType } from "./IntersectionType.js";
2
2
  import type { ObjectType } from "./ObjectType.js";
3
3
  import type { UnionType } from "./UnionType.js";
4
4
  export interface Ast {
5
+ readonly lazyTypesCount: number;
5
6
  readonly namedIntersectionTypes: readonly IntersectionType[];
6
7
  readonly namedObjectTypes: readonly ObjectType[];
7
8
  readonly namedUnionTypes: readonly UnionType[];
@@ -132,8 +132,12 @@ export namespace Json {
132
132
  return code `${this.name}.fromJson(${variables.value})`;
133
133
  }
134
134
  fromRdfResourceValuesExpression({ variables, }) {
135
- const { resourceValues: resourceValuesVariable, ...otherVariables } = variables;
136
- return code `${this.name}.fromRdfResourceValues(${resourceValuesVariable}, ${otherVariables})`;
135
+ const { resourceValues: resourceValuesVariable, ...fromRdfResourceValuesOptionsTemp } = variables;
136
+ const fromRdfResourceValuesOptions = fromRdfResourceValuesOptionsTemp;
137
+ if (!this.configuration.features.has("ObjectSet")) {
138
+ delete fromRdfResourceValuesOptions["objectSet"];
139
+ }
140
+ return code `${this.name}.fromRdfResourceValues(${resourceValuesVariable}, ${fromRdfResourceValuesOptions})`;
137
141
  }
138
142
  jsonSchema({ context, }) {
139
143
  const expression = code `${this.name}.Json.schema()`;
@@ -0,0 +1,35 @@
1
+ import type { Logger } from "ts-log";
2
+ import type { NamedObjectType } from "./NamedObjectType.js";
3
+ import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
4
+ import type { Reusables } from "./Reusables.js";
5
+ import type { TsGenerator } from "./TsGenerator.js";
6
+ import { type Code } from "./ts-poet-wrapper.js";
7
+ export declare abstract class AbstractObjectSetType {
8
+ protected readonly configuration: TsGenerator.Configuration;
9
+ protected readonly logger: Logger;
10
+ protected readonly reusables: Reusables;
11
+ protected readonly namedObjectTypes: readonly NamedObjectType[];
12
+ protected readonly namedObjectUnionTypes: readonly NamedObjectUnionType[];
13
+ constructor({ configuration, logger, namedObjectTypes, namedObjectUnionTypes, reusables, }: {
14
+ configuration: TsGenerator.Configuration;
15
+ logger: Logger;
16
+ namedObjectTypes: readonly NamedObjectType[];
17
+ namedObjectUnionTypes: readonly NamedObjectUnionType[];
18
+ reusables: Reusables;
19
+ });
20
+ abstract readonly declaration: Code;
21
+ protected methodSignatures(namedObjectType: {
22
+ readonly filterType: Code;
23
+ readonly identifierTypeAlias: Code;
24
+ readonly objectSetMethodNames: NamedObjectType.ObjectSetMethodNames;
25
+ readonly name: string;
26
+ }, options?: {
27
+ parameterNamePrefix?: string;
28
+ queryT?: string;
29
+ }): Readonly<Record<keyof NamedObjectType.ObjectSetMethodNames, {
30
+ readonly name: string;
31
+ readonly parameters: Code;
32
+ readonly returnType: Code;
33
+ }>>;
34
+ }
35
+ //# sourceMappingURL=AbstractObjectSetType.d.ts.map
@@ -0,0 +1,44 @@
1
+ import { code } from "./ts-poet-wrapper.js";
2
+ export class AbstractObjectSetType {
3
+ configuration;
4
+ logger;
5
+ reusables;
6
+ namedObjectTypes;
7
+ namedObjectUnionTypes;
8
+ constructor({ configuration, logger, namedObjectTypes, namedObjectUnionTypes, reusables, }) {
9
+ this.configuration = configuration;
10
+ this.logger = logger;
11
+ this.namedObjectTypes = namedObjectTypes;
12
+ this.namedObjectUnionTypes = namedObjectUnionTypes;
13
+ this.reusables = reusables;
14
+ }
15
+ methodSignatures(namedObjectType, options) {
16
+ const parameterNamePrefix = options?.parameterNamePrefix ?? "";
17
+ const queryT = options?.queryT ??
18
+ `${this.configuration.syntheticNamePrefix}ObjectSet.Query`;
19
+ const methodNames = namedObjectType.objectSetMethodNames;
20
+ return {
21
+ object: {
22
+ name: methodNames.object,
23
+ parameters: code `${parameterNamePrefix}identifier: ${namedObjectType.identifierTypeAlias}, options?: { preferredLanguages?: readonly string[]; }`,
24
+ returnType: code `Promise<${this.reusables.imports.Either}<Error, ${namedObjectType.name}>>`,
25
+ },
26
+ objectCount: {
27
+ name: methodNames.objectCount,
28
+ parameters: code `${parameterNamePrefix}query?: Pick<${queryT}<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>, "filter">`,
29
+ returnType: code `Promise<${this.reusables.imports.Either}<Error, number>>`,
30
+ },
31
+ objectIdentifiers: {
32
+ name: methodNames.objectIdentifiers,
33
+ parameters: code `${parameterNamePrefix}query?: ${queryT}<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>`,
34
+ returnType: code `Promise<${this.reusables.imports.Either}<Error, readonly ${namedObjectType.identifierTypeAlias}[]>>`,
35
+ },
36
+ objects: {
37
+ name: methodNames.objects,
38
+ parameters: code `${parameterNamePrefix}query?: ${queryT}<${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>`,
39
+ returnType: code `Promise<${this.reusables.imports.Either}<Error, readonly ${namedObjectType.name}[]>>`,
40
+ },
41
+ };
42
+ }
43
+ }
44
+ //# sourceMappingURL=AbstractObjectSetType.js.map
@@ -0,0 +1,22 @@
1
+ import type { Logger } from "ts-log";
2
+ import type { NamedObjectType } from "./NamedObjectType.js";
3
+ import type { NamedObjectUnionType } from "./NamedObjectUnionType.js";
4
+ import type { Reusables } from "./Reusables.js";
5
+ import type { TsGenerator } from "./TsGenerator.js";
6
+ import { type Code } from "./ts-poet-wrapper.js";
7
+ export declare class GraphqlSchema {
8
+ private readonly configuration;
9
+ private readonly reusables;
10
+ private readonly namedObjectTypes;
11
+ private readonly namedObjectUnionTypes;
12
+ constructor({ configuration, namedObjectTypes, namedObjectUnionTypes, reusables, }: {
13
+ configuration: TsGenerator.Configuration;
14
+ logger: Logger;
15
+ namedObjectTypes: readonly NamedObjectType[];
16
+ namedObjectUnionTypes: readonly NamedObjectUnionType[];
17
+ reusables: Reusables;
18
+ });
19
+ get declaration(): Code;
20
+ private get graphqlQueryObjectType();
21
+ }
22
+ //# sourceMappingURL=GraphqlSchema.d.ts.map
@@ -0,0 +1,87 @@
1
+ import { code } from "./ts-poet-wrapper.js";
2
+ export class GraphqlSchema {
3
+ configuration;
4
+ reusables;
5
+ namedObjectTypes;
6
+ namedObjectUnionTypes;
7
+ constructor({ configuration, namedObjectTypes, namedObjectUnionTypes, reusables, }) {
8
+ this.configuration = configuration;
9
+ this.namedObjectTypes = namedObjectTypes;
10
+ this.namedObjectUnionTypes = namedObjectUnionTypes;
11
+ this.reusables = reusables;
12
+ }
13
+ get declaration() {
14
+ return code `\
15
+ export const graphqlSchema = new ${this.reusables.imports.GraphQLSchema}({ query: ${this.graphqlQueryObjectType} });
16
+ `;
17
+ }
18
+ get graphqlQueryObjectType() {
19
+ const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
20
+ return code `new ${this.reusables.imports.GraphQLObjectType}<null, { objectSet: ${syntheticNamePrefix}ObjectSet }>({ name: "Query", fields: ${[
21
+ ...this.namedObjectTypes,
22
+ ...this.namedObjectUnionTypes,
23
+ ].reduce((fields, namedObjectType) => {
24
+ fields[namedObjectType.objectSetMethodNames.object] = {
25
+ args: {
26
+ identifier: {
27
+ type: code `new ${this.reusables.imports.GraphQLNonNull}(${this.reusables.imports.GraphQLID})`,
28
+ },
29
+ },
30
+ resolve: code `\
31
+ async (_source, args: { identifier: string }, { objectSet }): Promise<${namedObjectType.name}> =>
32
+ (await ${this.reusables.imports.EitherAsync}<Error, ${namedObjectType.name}>(async ({ liftEither }) =>
33
+ liftEither(await objectSet.${namedObjectType.objectSetMethodNames.object}(await liftEither(${namedObjectType.identifierTypeAlias}.parse(args.identifier))))
34
+ )).unsafeCoerce()`,
35
+ type: namedObjectType.graphqlType.name,
36
+ };
37
+ fields[namedObjectType.objectSetMethodNames.objectIdentifiers] = {
38
+ args: {
39
+ limit: {
40
+ type: code `${this.reusables.imports.GraphQLInt}`,
41
+ },
42
+ offset: {
43
+ type: code `${this.reusables.imports.GraphQLInt}`,
44
+ },
45
+ },
46
+ resolve: code `\
47
+ async (_source, args: { limit: number | null; offset: number | null; }, { objectSet }): Promise<readonly string[]> =>
48
+ (await objectSet.${namedObjectType.objectSetMethodNames.objectIdentifiers}({ limit: args.limit !== null ? args.limit : undefined, offset: args.offset !== null ? args.offset : undefined })).unsafeCoerce().map(${namedObjectType.identifierTypeAlias}.stringify)`,
49
+ type: code `new ${this.reusables.imports.GraphQLNonNull}(new ${this.reusables.imports.GraphQLList}(${this.reusables.imports.GraphQLString}))`,
50
+ };
51
+ fields[namedObjectType.objectSetMethodNames.objects] = {
52
+ args: {
53
+ identifiers: {
54
+ type: code `new ${this.reusables.imports.GraphQLList}(new ${this.reusables.imports.GraphQLNonNull}(${this.reusables.imports.GraphQLID}))`,
55
+ },
56
+ limit: {
57
+ type: code `${this.reusables.imports.GraphQLInt}`,
58
+ },
59
+ offset: {
60
+ type: code `${this.reusables.imports.GraphQLInt}`,
61
+ },
62
+ },
63
+ resolve: code `\
64
+ async (_source, args: { identifiers: readonly string[] | null; limit: number | null; offset: number | null; }, { objectSet }): Promise<readonly ${namedObjectType.name}[]> =>
65
+ (await ${this.reusables.imports.EitherAsync}<Error, readonly ${namedObjectType.name}[]>(async ({ liftEither }) => {
66
+ let filter: ${namedObjectType.filterType} | undefined;
67
+ if (args.identifiers) {
68
+ const identifiers: ${namedObjectType.identifierTypeAlias}[] = [];
69
+ for (const identifierArg of args.identifiers) {
70
+ identifiers.push(await liftEither(${namedObjectType.identifierTypeAlias}.parse(identifierArg)));
71
+ }
72
+ filter = { ${syntheticNamePrefix}identifier: { in: identifiers } };
73
+ }
74
+ return await liftEither(await objectSet.${namedObjectType.objectSetMethodNames.objects}({ filter, limit: args.limit !== null ? args.limit : undefined, offset: args.offset !== null ? args.offset : undefined }));
75
+ })).unsafeCoerce()`,
76
+ type: code `new ${this.reusables.imports.GraphQLNonNull}(new ${this.reusables.imports.GraphQLList}(${namedObjectType.graphqlType.name}))`,
77
+ };
78
+ fields[namedObjectType.objectSetMethodNames.objectCount] = {
79
+ resolve: code `\
80
+ async (_source, _args, { objectSet }): Promise<number> => (await objectSet.${namedObjectType.objectSetMethodNames.objectCount}()).unsafeCoerce()`,
81
+ type: code `new ${this.reusables.imports.GraphQLNonNull}(${this.reusables.imports.GraphQLInt})`,
82
+ };
83
+ return fields;
84
+ }, {})} })`;
85
+ }
86
+ }
87
+ //# sourceMappingURL=GraphqlSchema.js.map
@@ -212,8 +212,12 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
212
212
  return code `${this.name}.fromJson(${variables.value})`;
213
213
  }
214
214
  fromRdfResourceValuesExpression({ variables, }) {
215
- const { resourceValues, ...options } = variables;
216
- return code `${this.name}.fromRdfResourceValues(${resourceValues}, ${options})`;
215
+ const { resourceValues: resourceValuesVariable, ...fromRdfResourceValuesOptionsTemp } = variables;
216
+ const fromRdfResourceValuesOptions = fromRdfResourceValuesOptionsTemp;
217
+ if (!this.configuration.features.has("ObjectSet")) {
218
+ delete fromRdfResourceValuesOptions["objectSet"];
219
+ }
220
+ return code `${this.name}.fromRdfResourceValues(${resourceValuesVariable}, ${fromRdfResourceValuesOptions})`;
217
221
  }
218
222
  graphqlResolveExpression({ variables, }) {
219
223
  return variables.value;
@@ -0,0 +1,6 @@
1
+ import { AbstractObjectSetType } from "./AbstractObjectSetType.js";
2
+ import { type Code } from "./ts-poet-wrapper.js";
3
+ export declare class ObjectSetType extends AbstractObjectSetType {
4
+ get declaration(): Code;
5
+ }
6
+ //# sourceMappingURL=ObjectSetType.d.ts.map
@@ -0,0 +1,36 @@
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";
9
+ import { code, joinCode } from "./ts-poet-wrapper.js";
10
+ export class ObjectSetType extends AbstractObjectSetType {
11
+ get declaration() {
12
+ const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
13
+ return code `\
14
+ export interface ${syntheticNamePrefix}ObjectSet {
15
+ ${joinCode(this.namedObjectTypes
16
+ .flatMap((namedObjectType) => Object.values(this.methodSignatures(namedObjectType)))
17
+ .concat(this.namedObjectUnionTypes.flatMap((namedObjectUnionType) => Object.values(this.methodSignatures(namedObjectUnionType))))
18
+ .map((methodSignature) => code `${methodSignature.name}(${methodSignature.parameters}): ${methodSignature.returnType};`), { on: "\n\n" })}
19
+ }
20
+
21
+ export namespace ${syntheticNamePrefix}ObjectSet {
22
+ export interface Query<ObjectFilterT, ObjectIdentifierT extends ${this.reusables.imports.BlankNode} | ${this.reusables.imports.NamedNode}> {
23
+ readonly filter?: ObjectFilterT;
24
+ readonly graph?: Exclude<${this.reusables.imports.Quad_Graph}, ${this.reusables.imports.Variable}>;
25
+ readonly identifiers?: readonly ObjectIdentifierT[];
26
+ readonly limit?: number;
27
+ readonly offset?: number;
28
+ readonly preferredLanguages?: readonly string[];
29
+ }
30
+ }`;
31
+ }
32
+ }
33
+ __decorate([
34
+ Memoize()
35
+ ], ObjectSetType.prototype, "declaration", null);
36
+ //# sourceMappingURL=ObjectSetType.js.map
@@ -0,0 +1,6 @@
1
+ import { AbstractObjectSetType } from "./AbstractObjectSetType.js";
2
+ import { type Code } from "./ts-poet-wrapper.js";
3
+ export declare class RdfjsDatasetObjectSetType extends AbstractObjectSetType {
4
+ get declaration(): Code;
5
+ }
6
+ //# sourceMappingURL=RdfjsDatasetObjectSetType.d.ts.map
@@ -1,22 +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
- export function rdfjsDatasetObjectSetClassDeclaration({ namedObjectTypes, namedObjectUnionTypes, }) {
4
- const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
5
- const namedObjectTypeType = code `\
10
+ export class RdfjsDatasetObjectSetType extends AbstractObjectSetType {
11
+ get declaration() {
12
+ const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
13
+ const namedObjectTypeType = code `\
6
14
  {
7
15
  filter: (filter: ObjectFilterT, value: ObjectT) => boolean;
8
16
  fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}<ObjectT>;
9
17
  fromRdfTypes: readonly ${this.reusables.imports.NamedNode}[]
10
18
  }`;
11
- const parameters = {
12
- query: `query?: ${syntheticNamePrefix}ObjectSet.Query<ObjectFilterT, ObjectIdentifierT>`,
13
- };
14
- const typeParameters = {
15
- ObjectT: code `ObjectT extends { readonly $identifier: () => ObjectIdentifierT }`,
16
- ObjectFilterT: code `ObjectFilterT`,
17
- ObjectIdentifierT: code `ObjectIdentifierT extends ${this.reusables.imports.BlankNode} | ${this.reusables.imports.NamedNode}`,
18
- };
19
- 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 `\
20
28
  export class ${syntheticNamePrefix}RdfjsDatasetObjectSet implements ${syntheticNamePrefix}ObjectSet {
21
29
  readonly #dataset: ${this.reusables.imports.DatasetCore} | (() => ${this.reusables.imports.DatasetCore});
22
30
  readonly #graph?: Exclude<${this.reusables.imports.Quad_Graph}, ${this.reusables.imports.Variable}>;
@@ -38,76 +46,74 @@ export class ${syntheticNamePrefix}RdfjsDatasetObjectSet implements ${syntheticN
38
46
  }
39
47
 
40
48
  ${joinCode([
41
- ...[...namedObjectTypes, ...namedObjectUnionTypes].flatMap((namedObjectType) => {
42
- const methodSignatures = objectSetMethodSignatures.call(this, {
43
- namedObjectType,
44
- });
45
- const delegatingMethods = [
46
- // object
47
- code `\
49
+ ...[...this.namedObjectTypes, ...this.namedObjectUnionTypes].flatMap((namedObjectType) => {
50
+ const methodSignatures = this.methodSignatures(namedObjectType);
51
+ const delegatingMethods = [
52
+ // object
53
+ code `\
48
54
  async ${methodSignatures.object.name}(${methodSignatures.object.parameters}): ${methodSignatures.object.returnType} {
49
55
  return this.${methodSignatures.object.name}Sync(identifier, options);
50
56
  }`,
51
- // objectSync
52
- code `\
57
+ // objectSync
58
+ code `\
53
59
  ${methodSignatures.object.name}Sync(${methodSignatures.object.parameters}): ${this.reusables.imports.Either}<Error, ${namedObjectType.name}> {
54
60
  return this.${methodSignatures.objects.name}Sync({ identifiers: [identifier], preferredLanguages: options?.preferredLanguages }).map(objects => objects[0]);
55
61
  }`,
56
- // objectCount
57
- code `\
62
+ // objectCount
63
+ code `\
58
64
  async ${methodSignatures.objectCount.name}(${methodSignatures.objectCount.parameters}): ${methodSignatures.objectCount.returnType} {
59
65
  return this.${methodSignatures.objectCount.name}Sync(query);
60
66
  }`,
61
- // objectCountSync
62
- code `\
67
+ // objectCountSync
68
+ code `\
63
69
  ${methodSignatures.objectCount.name}Sync(${methodSignatures.objectCount.parameters}): ${this.reusables.imports.Either}<Error, number> {
64
70
  return this.${methodSignatures.objects.name}Sync(query).map(objects => objects.length);
65
71
  }`,
66
- // objectIdentifiers
67
- code `\
72
+ // objectIdentifiers
73
+ code `\
68
74
  async ${methodSignatures.objectIdentifiers.name}(${methodSignatures.objectIdentifiers.parameters}): ${methodSignatures.objectIdentifiers.returnType} {
69
75
  return this.${methodSignatures.objectIdentifiers.name}Sync(query);
70
76
  }`,
71
- // objectIdentifiersSync
72
- code `\
77
+ // objectIdentifiersSync
78
+ code `\
73
79
  ${methodSignatures.objectIdentifiers.name}Sync(${methodSignatures.objectIdentifiers.parameters}): ${this.reusables.imports.Either}<Error, readonly ${namedObjectType.identifierTypeAlias}[]> {
74
80
  return this.${methodSignatures.objects.name}Sync(query).map(objects => objects.map(object => object.${syntheticNamePrefix}identifier()));
75
81
  }`,
76
- // objects
77
- code `\
82
+ // objects
83
+ code `\
78
84
  async ${methodSignatures.objects.name}(${methodSignatures.objects.parameters}): ${methodSignatures.objects.returnType} {
79
85
  return this.${methodSignatures.objects.name}Sync(query);
80
86
  }`,
81
- // objectsSync has per-object type logic, not just forwarding
82
- ];
83
- const runtimeObjectType = (filterFunction, namedObjectType) => {
84
- const fromRdfTypes = namedObjectType.fromRdfTypeVariable
85
- .toList()
86
- .concat(namedObjectType.descendantFromRdfTypeVariables);
87
- return code `{ filter: ${filterFunction}, fromRdfResource: ${namedObjectType.name}.fromRdfResource, fromRdfTypes: ${fromRdfTypes.length > 0 ? code `[${joinCode(fromRdfTypes, { on: ", " })}]` : "[]"} }`;
88
- };
89
- switch (namedObjectType.kind) {
90
- case "NamedObjectType": {
91
- 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 `\
92
98
  ${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${this.reusables.imports.Either}<Error, readonly ${namedObjectType.name}[]> {
93
99
  return this.#objectsSync<${namedObjectType.name}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>(${runtimeObjectType(namedObjectType.filterFunction, namedObjectType)}, query);
94
100
  }`);
95
- }
96
- case "NamedObjectUnionType":
97
- return delegatingMethods.concat(code `\
101
+ }
102
+ case "NamedObjectUnionType":
103
+ return delegatingMethods.concat(code `\
98
104
  ${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${this.reusables.imports.Either}<Error, readonly ${namedObjectType.name}[]> {
99
105
  return this.#objectUnionsSync<${namedObjectType.name}, ${namedObjectType.filterType}, ${namedObjectType.identifierTypeAlias}>([
100
106
  ${joinCode(namedObjectType.members.map((member) => runtimeObjectType(namedObjectType.filterFunction, member.type)), { on: ", " })}
101
107
  ], query);
102
108
  }`);
103
- default:
104
- namedObjectType;
105
- return [];
106
- }
107
- }),
108
- ...(namedObjectTypes.length > 0
109
- ? [
110
- code `\
109
+ default:
110
+ namedObjectType;
111
+ return [];
112
+ }
113
+ }),
114
+ ...(this.namedObjectTypes.length > 0
115
+ ? [
116
+ code `\
111
117
  #objectsSync<${typeParameters.ObjectT}, ${typeParameters.ObjectFilterT}, ${typeParameters.ObjectIdentifierT}>(namedObjectType: ${namedObjectTypeType}, ${parameters.query}): ${this.reusables.imports.Either}<Error, readonly ObjectT[]> {
112
118
  const graph = query?.graph ?? this.#graph;
113
119
 
@@ -195,11 +201,11 @@ ${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${
195
201
  }
196
202
  return ${this.reusables.imports.Right}(objects);
197
203
  }`,
198
- ]
199
- : []),
200
- ...(namedObjectUnionTypes.length > 0
201
- ? [
202
- code `\
204
+ ]
205
+ : []),
206
+ ...(this.namedObjectUnionTypes.length > 0
207
+ ? [
208
+ code `\
203
209
  #objectUnionsSync<${typeParameters.ObjectT}, ${typeParameters.ObjectFilterT}, ${typeParameters.ObjectIdentifierT}>(namedObjectTypes: readonly ${namedObjectTypeType}[], ${parameters.query}): ${this.reusables.imports.Either}<Error, readonly ObjectT[]> {
204
210
  const graph = query?.graph ?? this.#graph;
205
211
 
@@ -308,9 +314,13 @@ ${methodSignatures.objects.name}Sync(${methodSignatures.objects.parameters}): ${
308
314
  }
309
315
  return ${this.reusables.imports.Right}(objects);
310
316
  }`,
311
- ]
312
- : []),
313
- ], { on: "\n\n" })}
317
+ ]
318
+ : []),
319
+ ], { on: "\n\n" })}
314
320
  }`;
321
+ }
315
322
  }
316
- //# 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