@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
@@ -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[];
@@ -16,9 +16,10 @@ export class AbstractNamedUnionType extends AbstractUnionType {
16
16
  this._name = name;
17
17
  }
18
18
  get declaration() {
19
- const declarations = [
20
- code `export type ${def(this._name)} = ${this.inlineName};`,
21
- ];
19
+ const declarations = [];
20
+ if (this.configuration.features.has("Object.type")) {
21
+ declarations.push(code `export type ${def(this._name)} = ${this.inlineName};`);
22
+ }
22
23
  const staticModuleDeclarations = Object.entries(this.staticModuleDeclarations);
23
24
  if (staticModuleDeclarations.length > 0) {
24
25
  declarations.push(code `\
@@ -68,22 +69,26 @@ ${joinCode(staticModuleDeclarations
68
69
  }
69
70
  get staticModuleDeclarations() {
70
71
  const staticModuleDeclarations = {};
71
- if (this.configuration.features.has("equals")) {
72
+ if (this.configuration.features.has("Object.equals")) {
72
73
  staticModuleDeclarations[`equals`] =
73
74
  code `export const equals = ${this.inlineEqualsFunction};`;
74
75
  }
75
- staticModuleDeclarations[`Filter`] =
76
- code `export type Filter = ${this.inlineFilterType};`;
77
- staticModuleDeclarations[`filter`] =
78
- code `export const filter = ${this.inlineFilterFunction};`;
79
- if (this.configuration.features.has("hash")) {
76
+ if (this.configuration.features.has("Object.filter")) {
77
+ staticModuleDeclarations[`Filter`] =
78
+ code `export type Filter = ${this.inlineFilterType};`;
79
+ staticModuleDeclarations[`filter`] =
80
+ code `export const filter = ${this.inlineFilterFunction};`;
81
+ }
82
+ if (this.configuration.features.has("Object.hash")) {
80
83
  staticModuleDeclarations[`hash`] =
81
84
  code `export const hash = ${this.inlineHashFunction};`;
82
85
  }
83
- if (this.configuration.features.has("json")) {
84
- staticModuleDeclarations[`Json`] = code `\
85
- ${this.jsonTypeAliasDeclaration}
86
-
86
+ if (this.configuration.features.has("Object.JSON.type")) {
87
+ staticModuleDeclarations[`Json.type`] =
88
+ code `${this.jsonTypeAliasDeclaration}`;
89
+ }
90
+ if (this.configuration.features.has("Object.JSON.schema")) {
91
+ staticModuleDeclarations[`Json.namespace`] = code `\
87
92
  export namespace Json {
88
93
  ${this.jsonSchemaFunctionDeclaration}
89
94
 
@@ -93,34 +98,46 @@ export namespace Json {
93
98
  return ${this.reusables.imports.Right}(jsonSafeParseResult.data);
94
99
  }
95
100
  }`;
101
+ }
102
+ if (this.configuration.features.has("Object.fromJson")) {
96
103
  staticModuleDeclarations[`fromJson`] =
97
104
  code `export const fromJson = ${this.inlineFromJsonFunction};`;
98
- staticModuleDeclarations[`toJson`] =
99
- code `export const toJson = ${this.inlineToJsonFunction};`;
100
105
  }
101
- if (this.configuration.features.has("rdf")) {
106
+ if (this.configuration.features.has("Object.fromRdf")) {
102
107
  staticModuleDeclarations[`fromRdfResourceValues`] =
103
108
  code `export const fromRdfResourceValues: ${this.reusables.snippets.FromRdfResourceValuesFunction}<${this.name}> = ${this.inlineFromRdfResourceValuesFunction};`;
109
+ }
110
+ if (this.configuration.features.has("Object.toJson")) {
111
+ staticModuleDeclarations[`toJson`] =
112
+ code `export const toJson = ${this.inlineToJsonFunction};`;
113
+ }
114
+ if (this.configuration.features.has("Object.toRdf")) {
104
115
  staticModuleDeclarations[`toRdfResourceValues`] =
105
116
  code `export const toRdfResourceValues = ${this.inlineToRdfResourceValuesFunction};`;
106
117
  }
107
- if (this.configuration.features.has("sparql")) {
118
+ if (this.configuration.features.has("Object.SPARQL")) {
108
119
  staticModuleDeclarations[`valueSparqlConstructTriples`] =
109
120
  code `export const valueSparqlConstructTriples: ${this.reusables.snippets.ValueSparqlConstructTriplesFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlConstructTriplesFunction};`;
110
121
  staticModuleDeclarations[`valueSparqlWherePatterns`] =
111
122
  code `export const valueSparqlWherePatterns: ${this.reusables.snippets.ValueSparqlWherePatternsFunction}<${this.filterType}, ${this.schemaType}> = ${this.inlineValueSparqlWherePatternsFunction};`;
112
123
  }
113
- const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
114
- staticModuleDeclarations[`${syntheticNamePrefix}toString`] =
115
- code `export const ${syntheticNamePrefix}toString = ${this.inlineToStringFunction};`;
124
+ if (this.configuration.features.has("Object.toString")) {
125
+ const syntheticNamePrefix = this.configuration.syntheticNamePrefix;
126
+ staticModuleDeclarations[`${syntheticNamePrefix}toString`] =
127
+ code `export const ${syntheticNamePrefix}toString = ${this.inlineToStringFunction};`;
128
+ }
116
129
  return staticModuleDeclarations;
117
130
  }
118
131
  fromJsonExpression({ variables, }) {
119
132
  return code `${this.name}.fromJson(${variables.value})`;
120
133
  }
121
134
  fromRdfResourceValuesExpression({ variables, }) {
122
- const { resourceValues: resourceValuesVariable, ...otherVariables } = variables;
123
- 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})`;
124
141
  }
125
142
  jsonSchema({ context, }) {
126
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
@@ -84,7 +84,9 @@ export class NamedObjectType extends AbstractType {
84
84
  const declarations = [];
85
85
  if (!this.extern) {
86
86
  const staticModuleDeclarations = [];
87
- declarations.push(NamedObjectType_interfaceDeclaration.call(this));
87
+ if (this.configuration.features.has("Object.type")) {
88
+ declarations.push(NamedObjectType_interfaceDeclaration.call(this));
89
+ }
88
90
  staticModuleDeclarations.push(...NamedObjectType_createFunctionDeclaration.call(this).toList(), ...NamedObjectType_equalsFunctionDeclaration.call(this).toList(), ...NamedObjectType_hashFunctionDeclarations.call(this));
89
91
  const jsonModuleDeclarations = [
90
92
  ...NamedObjectType_jsonParseFunctionDeclaration.call(this).toList(),
@@ -95,7 +97,7 @@ export class NamedObjectType extends AbstractType {
95
97
  ? [
96
98
  code `export namespace Json { ${joinCode(jsonModuleDeclarations, { on: "\n\n" })} }`,
97
99
  ]
98
- : []), NamedObjectType_filterFunctionDeclaration.call(this), NamedObjectType_filterTypeDeclaration.call(this), ...NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.call(this).toList(), ...NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromJsonFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfResourceFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfResourceValuesFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfTypeVariableStatement.call(this).toList(), NamedObjectType_isTypeFunctionDeclaration.call(this), NamedObjectType_schemaVariableStatement.call(this), ...NamedObjectType_sparqlConstructQueryFunctionDeclaration.call({
100
+ : []), ...NamedObjectType_filterFunctionDeclaration.call(this).toList(), ...NamedObjectType_filterTypeDeclaration.call(this).toList(), ...NamedObjectType_focusSparqlConstructTriplesFunctionDeclaration.call(this).toList(), ...NamedObjectType_focusSparqlWherePatternsFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromJsonFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfResourceFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfResourceValuesFunctionDeclaration.call(this).toList(), ...NamedObjectType_fromRdfTypeVariableStatement.call(this).toList(), ...NamedObjectType_isTypeFunctionDeclaration.call(this).toList(), ...NamedObjectType_schemaVariableStatement.call(this).toList(), ...NamedObjectType_sparqlConstructQueryFunctionDeclaration.call({
99
101
  configuration: this.configuration,
100
102
  filterType: this.filterType,
101
103
  name: this.name,
@@ -113,6 +115,9 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
113
115
  }`);
114
116
  }
115
117
  }
118
+ if (declarations.length === 0) {
119
+ return Maybe.empty();
120
+ }
116
121
  return Maybe.of(joinCode(declarations, { on: "\n\n" }));
117
122
  }
118
123
  get descendantFromRdfTypeVariables() {
@@ -207,8 +212,12 @@ ${joinCode(staticModuleDeclarations, { on: "\n\n" })}
207
212
  return code `${this.name}.fromJson(${variables.value})`;
208
213
  }
209
214
  fromRdfResourceValuesExpression({ variables, }) {
210
- const { resourceValues, ...options } = variables;
211
- 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})`;
212
221
  }
213
222
  graphqlResolveExpression({ variables, }) {
214
223
  return variables.value;
@@ -73,7 +73,7 @@ export class NamedObjectUnionType extends AbstractNamedUnionType {
73
73
  };
74
74
  }
75
75
  get focusSparqlConstructTriplesFunctionDeclaration() {
76
- if (!this.configuration.features.has("sparql")) {
76
+ if (!this.configuration.features.has("Object.SPARQL")) {
77
77
  return {};
78
78
  }
79
79
  return singleEntryRecord(`focusSparqlConstructTriples`, code `\
@@ -82,7 +82,7 @@ export function focusSparqlConstructTriples({ filter, focusIdentifier, variableP
82
82
  }`);
83
83
  }
84
84
  get focusSparqlWherePatternsFunctionDeclaration() {
85
- if (!this.configuration.features.has("sparql")) {
85
+ if (!this.configuration.features.has("Object.SPARQL")) {
86
86
  return {};
87
87
  }
88
88
  return singleEntryRecord(`focusSparqlWherePatterns`, code `\
@@ -110,7 +110,7 @@ if (focusIdentifier.termType === "Variable") {
110
110
  }`);
111
111
  }
112
112
  get fromRdfResourceFunctionDeclaration() {
113
- if (!this.configuration.features.has("rdf")) {
113
+ if (!this.configuration.features.has("Object.fromRdf")) {
114
114
  return {};
115
115
  }
116
116
  return singleEntryRecord(`fromRdfResource`, code `\
@@ -123,7 +123,7 @@ export const fromRdfResource: ${this.reusables.snippets.FromRdfResourceFunction}
123
123
  }, null)};`);
124
124
  }
125
125
  get graphqlTypeVariableStatement() {
126
- if (!this.configuration.features.has("graphql")) {
126
+ if (!this.configuration.features.has("GraphQL")) {
127
127
  return {};
128
128
  }
129
129
  if (this.synthetic) {
@@ -138,6 +138,9 @@ export const GraphQL = new ${this.reusables.imports.GraphQLUnionType}(${{
138
138
  }});`);
139
139
  }
140
140
  get identifierTypeDeclarations() {
141
+ if (!this.configuration.features.has("Object.type")) {
142
+ return {};
143
+ }
141
144
  return singleEntryRecord(`Identifier`, code `\
142
145
  export type Identifier = ${this.#identifierType.name};
143
146
  export namespace Identifier {
@@ -146,6 +149,9 @@ export namespace Identifier {
146
149
  }`);
147
150
  }
148
151
  get isTypeFunctionDeclaration() {
152
+ if (!this.configuration.features.has("Object.type")) {
153
+ return {};
154
+ }
149
155
  if (this._name === `${this.configuration.syntheticNamePrefix}Object`) {
150
156
  return {};
151
157
  }
@@ -155,6 +161,9 @@ export namespace Identifier {
155
161
  }`);
156
162
  }
157
163
  get schemaVariableStatement() {
164
+ if (!this.configuration.features.has("Object.schema")) {
165
+ return {};
166
+ }
158
167
  const commonPropertiesByName = {};
159
168
  this.members.forEach((member, memberI) => {
160
169
  for (const memberTypeProperty of member.type.properties.concat(member.type.ancestorObjectTypes.flatMap((ancestorObjectType) => ancestorObjectType.properties))) {
@@ -192,7 +201,7 @@ ${{
192
201
  }} as const;`);
193
202
  }
194
203
  get toRdfResourceFunctionDeclaration() {
195
- if (!this.configuration.features.has("rdf")) {
204
+ if (!this.configuration.features.has("Object.toRdf")) {
196
205
  return {};
197
206
  }
198
207
  return singleEntryRecord(`toRdfResource`, code `\
@@ -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