@corpdk/dal-codegen 2026.10.0-alpha.1 → 2026.10.0-alpha.13
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/README.md +31 -0
- package/dist/entity-lint.js +24 -0
- package/dist/entity-lint.js.map +1 -1
- package/dist/generate.js +3 -0
- package/dist/generate.js.map +1 -1
- package/dist/generators/app-bootstrap.js +53 -4
- package/dist/generators/app-bootstrap.js.map +1 -1
- package/dist/generators/entity-schema.js +40 -36
- package/dist/generators/entity-schema.js.map +1 -1
- package/dist/generators/input-zod-graphql.d.ts +8 -0
- package/dist/generators/input-zod-graphql.js +159 -0
- package/dist/generators/input-zod-graphql.js.map +1 -0
- package/dist/generators/input-zod-scalars.d.ts +5 -0
- package/dist/generators/input-zod-scalars.js +47 -0
- package/dist/generators/input-zod-scalars.js.map +1 -0
- package/dist/generators/input-zod.d.ts +3 -0
- package/dist/generators/input-zod.js +227 -0
- package/dist/generators/input-zod.js.map +1 -0
- package/dist/generators/repository-scalars.js +45 -5
- package/dist/generators/repository-scalars.js.map +1 -1
- package/dist/generators/resolvers.js +103 -31
- package/dist/generators/resolvers.js.map +1 -1
- package/dist/generators/schema-registry.d.ts +5 -0
- package/dist/generators/schema-registry.js +181 -19
- package/dist/generators/schema-registry.js.map +1 -1
- package/dist/generators/schema-utils.d.ts +2 -0
- package/dist/generators/schema-utils.js +35 -2
- package/dist/generators/schema-utils.js.map +1 -1
- package/dist/model.d.ts +1 -1
- package/dist/model.js +12 -2
- package/dist/model.js.map +1 -1
- package/dist/pg-sql-types.d.ts +6 -0
- package/dist/pg-sql-types.js +32 -0
- package/dist/pg-sql-types.js.map +1 -0
- package/dist/schema-loader.js +1 -1
- package/package.json +18 -6
- package/dist/generated/entity-records.d.ts +0 -25
- package/dist/generated/entity-records.js +0 -2
- package/dist/generated/entity-records.js.map +0 -1
- package/dist/generated/graphql-codegen.mappers.d.ts +0 -6
- package/dist/generated/graphql-codegen.mappers.js +0 -8
- package/dist/generated/graphql-codegen.mappers.js.map +0 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { collectUsedDalScalars } from "./schema-registry.js";
|
|
1
2
|
function targetRepoBasename(rel, entities) {
|
|
2
3
|
const target = entities.find((e) => e.exportName === rel.targetExportName);
|
|
3
4
|
return target?.fieldBasename ?? rel.targetExportName;
|
|
@@ -109,50 +110,72 @@ export function generateResolvers(entities) {
|
|
|
109
110
|
const e = entity.fieldBasename;
|
|
110
111
|
const list = entity.listField;
|
|
111
112
|
const full = entity.auditProfile === "full";
|
|
113
|
+
const soft = entity.deleteStrategy === "soft";
|
|
114
|
+
const includeDeletedRead = soft
|
|
115
|
+
? "includeDeleted: args.includeDeleted as boolean | null,"
|
|
116
|
+
: "";
|
|
117
|
+
const findByIdArgs = soft ? "{ id: string; includeDeleted?: boolean | null }" : "{ id: string }";
|
|
118
|
+
const findByIdOpts = soft ? "{ includeDeleted: args.includeDeleted }" : "{}";
|
|
112
119
|
const topic = `${e.toUpperCase()}_CHANGED`;
|
|
113
120
|
queryFields.push(` ${list}: async (_: unknown, args: Record<string, unknown>, ctx: DalContext, info: GraphQLResolveInfo) =>
|
|
114
121
|
(await ctx.repositories.${e}.list(
|
|
115
122
|
{
|
|
116
|
-
filter:
|
|
117
|
-
|
|
123
|
+
filter: unwrapGraphqlInputParseResult(
|
|
124
|
+
safeParseOptionalGraphqlInput("${E}Filter", args.filter),
|
|
125
|
+
) as never,
|
|
126
|
+
sort: unwrapGraphqlInputParseResult(
|
|
127
|
+
safeParseOptionalGraphqlInputList("${E}SortInput", args.sort),
|
|
128
|
+
) as never,
|
|
118
129
|
limit: args.limit as number | null,
|
|
119
|
-
|
|
130
|
+
${includeDeletedRead}
|
|
120
131
|
},
|
|
121
132
|
info,
|
|
122
133
|
)) as ResolversTypes["${E}"][],
|
|
123
134
|
|
|
124
|
-
${e}: async (_: unknown, args: {
|
|
125
|
-
(await ctx.repositories.${e}.findById(args.id, {
|
|
135
|
+
${e}: async (_: unknown, args: ${findByIdArgs}, ctx: DalContext, info: GraphQLResolveInfo) =>
|
|
136
|
+
(await ctx.repositories.${e}.findById(args.id, ${findByIdOpts}, info)) as ResolversTypes["${E}"] | null,
|
|
126
137
|
|
|
127
138
|
${e}Connection: async (_: unknown, args: Record<string, unknown>, ctx: DalContext, info: GraphQLResolveInfo) =>
|
|
128
139
|
(await ctx.repositories.${e}.listConnection(
|
|
129
140
|
{
|
|
130
|
-
filter:
|
|
131
|
-
|
|
141
|
+
filter: unwrapGraphqlInputParseResult(
|
|
142
|
+
safeParseOptionalGraphqlInput("${E}Filter", args.filter),
|
|
143
|
+
) as never,
|
|
144
|
+
sort: unwrapGraphqlInputParseResult(
|
|
145
|
+
safeParseOptionalGraphqlInputList("${E}SortInput", args.sort),
|
|
146
|
+
) as never,
|
|
132
147
|
first: args.first as number | null,
|
|
133
148
|
after: args.after as string | null,
|
|
134
149
|
last: args.last as number | null,
|
|
135
150
|
before: args.before as string | null,
|
|
136
|
-
|
|
151
|
+
${includeDeletedRead}
|
|
137
152
|
},
|
|
138
153
|
info,
|
|
139
154
|
)) as ResolversTypes["${E}Connection"],
|
|
140
155
|
|
|
141
156
|
${list}Count: (_: unknown, args: Record<string, unknown>, ctx: DalContext) =>
|
|
142
157
|
ctx.repositories.${e}.count({
|
|
143
|
-
filter:
|
|
144
|
-
|
|
158
|
+
filter: unwrapGraphqlInputParseResult(
|
|
159
|
+
safeParseOptionalGraphqlInput("${E}Filter", args.filter),
|
|
160
|
+
) as never,
|
|
161
|
+
${includeDeletedRead}
|
|
145
162
|
}),
|
|
146
163
|
|
|
147
164
|
${e}Aggregate: async (_: unknown, args: Record<string, unknown>, ctx: DalContext) =>
|
|
148
165
|
({
|
|
149
166
|
count: await ctx.repositories.${e}.count({
|
|
150
|
-
filter:
|
|
151
|
-
|
|
167
|
+
filter: unwrapGraphqlInputParseResult(
|
|
168
|
+
safeParseOptionalGraphqlInput("${E}Filter", args.filter),
|
|
169
|
+
) as never,
|
|
170
|
+
${includeDeletedRead}
|
|
152
171
|
}),
|
|
153
172
|
}) as ResolversTypes["${E}Aggregate"],`);
|
|
154
173
|
mutationFields.push(` create${E}: async (_: unknown, args: { input: Record<string, unknown> }, ctx: DalContext) => {
|
|
155
|
-
const
|
|
174
|
+
const parsed = safeParseGraphqlInput("${E}CreateInput", args.input);
|
|
175
|
+
if (!parsed.ok) {
|
|
176
|
+
return { ${e}: null, userErrors: parsed.userErrors } as ResolversTypes["Create${E}Payload"];
|
|
177
|
+
}
|
|
178
|
+
const result = await ctx.repositories.${e}.create(parsed.data as never, { actorId: ctx.actorId });
|
|
156
179
|
if (result.${e} && result.userErrors.length === 0) {
|
|
157
180
|
const event = ctx.repositories.${e}.toChangeEvent("CREATED", [result.${e}.id]);
|
|
158
181
|
ctx.pubsub.publish("${topic}", { ${e}Changed: event });
|
|
@@ -161,7 +184,15 @@ export function generateResolvers(entities) {
|
|
|
161
184
|
},
|
|
162
185
|
|
|
163
186
|
bulkCreate${E}: async (_: unknown, args: { inputs: Record<string, unknown>[]; atomic?: boolean | null }, ctx: DalContext) => {
|
|
164
|
-
const
|
|
187
|
+
const parsed = safeParseGraphqlInputList("${E}CreateInput", args.inputs);
|
|
188
|
+
if (!parsed.ok) {
|
|
189
|
+
return {
|
|
190
|
+
successCount: 0,
|
|
191
|
+
failureCount: args.inputs.length,
|
|
192
|
+
userErrors: parsed.userErrors,
|
|
193
|
+
} as ResolversTypes["BulkMutationResult"];
|
|
194
|
+
}
|
|
195
|
+
const result = await ctx.repositories.${e}.bulkCreate(parsed.data as never, { actorId: ctx.actorId }, args.atomic);
|
|
165
196
|
if ("items" in result && result.items.length > 0) {
|
|
166
197
|
const event = ctx.repositories.${e}.toChangeEvent("CREATED", result.items.map((row) => row.id));
|
|
167
198
|
ctx.pubsub.publish("${topic}", { ${e}Changed: event });
|
|
@@ -191,7 +222,15 @@ export function generateResolvers(entities) {
|
|
|
191
222
|
},
|
|
192
223
|
|
|
193
224
|
bulkDelete${E}ByFilter: async (_: unknown, args: { filter: Record<string, unknown>; confirmDeleteAll?: boolean | null }, ctx: DalContext) => {
|
|
194
|
-
const
|
|
225
|
+
const filterParsed = safeParseGraphqlInput("${E}Filter", args.filter);
|
|
226
|
+
if (!filterParsed.ok) {
|
|
227
|
+
return {
|
|
228
|
+
successCount: 0,
|
|
229
|
+
failureCount: 0,
|
|
230
|
+
userErrors: filterParsed.userErrors,
|
|
231
|
+
} as ResolversTypes["BulkMutationResult"];
|
|
232
|
+
}
|
|
233
|
+
const result = await ctx.repositories.${e}.bulkDeleteByFilter(filterParsed.data as never, { actorId: ctx.actorId }, args.confirmDeleteAll);
|
|
195
234
|
const matchedIds = "matchedIds" in result ? result.matchedIds : undefined;
|
|
196
235
|
if (result.successCount > 0 && matchedIds && matchedIds.length > 0) {
|
|
197
236
|
const event = ctx.repositories.${e}.toChangeEvent("DELETED", matchedIds);
|
|
@@ -201,7 +240,11 @@ export function generateResolvers(entities) {
|
|
|
201
240
|
},`);
|
|
202
241
|
if (full) {
|
|
203
242
|
mutationFields.push(` update${E}: async (_: unknown, args: { id: string; input: Record<string, unknown> }, ctx: DalContext) => {
|
|
204
|
-
const
|
|
243
|
+
const parsed = safeParseGraphqlInput("${E}UpdateInput", args.input);
|
|
244
|
+
if (!parsed.ok) {
|
|
245
|
+
return { ${e}: null, userErrors: parsed.userErrors } as ResolversTypes["Update${E}Payload"];
|
|
246
|
+
}
|
|
247
|
+
const result = await ctx.repositories.${e}.update(args.id, parsed.data as never, { actorId: ctx.actorId });
|
|
205
248
|
if (result.${e} && result.userErrors.length === 0) {
|
|
206
249
|
const event = ctx.repositories.${e}.toChangeEvent("UPDATED", [result.${e}.id]);
|
|
207
250
|
ctx.pubsub.publish("${topic}", { ${e}Changed: event });
|
|
@@ -210,7 +253,15 @@ export function generateResolvers(entities) {
|
|
|
210
253
|
},
|
|
211
254
|
|
|
212
255
|
bulkUpdate${E}: async (_: unknown, args: { updates: Array<{ id: string; input: Record<string, unknown> }>; atomic?: boolean | null }, ctx: DalContext) => {
|
|
213
|
-
const
|
|
256
|
+
const parsed = safeParseGraphqlInputList("${E}UpdateEntry", args.updates);
|
|
257
|
+
if (!parsed.ok) {
|
|
258
|
+
return {
|
|
259
|
+
successCount: 0,
|
|
260
|
+
failureCount: args.updates.length,
|
|
261
|
+
userErrors: parsed.userErrors,
|
|
262
|
+
} as ResolversTypes["BulkMutationResult"];
|
|
263
|
+
}
|
|
264
|
+
const result = await ctx.repositories.${e}.bulkUpdate(parsed.data as never, { actorId: ctx.actorId }, args.atomic);
|
|
214
265
|
if ("items" in result && result.items.length > 0) {
|
|
215
266
|
const event = ctx.repositories.${e}.toChangeEvent("UPDATED", result.items.map((row) => row.id));
|
|
216
267
|
ctx.pubsub.publish("${topic}", { ${e}Changed: event });
|
|
@@ -225,7 +276,23 @@ export function generateResolvers(entities) {
|
|
|
225
276
|
},
|
|
226
277
|
|
|
227
278
|
bulkUpdate${E}ByFilter: async (_: unknown, args: { filter: Record<string, unknown>; input: Record<string, unknown>; confirmUpdateAll?: boolean | null }, ctx: DalContext) => {
|
|
228
|
-
const
|
|
279
|
+
const filterParsed = safeParseGraphqlInput("${E}Filter", args.filter);
|
|
280
|
+
if (!filterParsed.ok) {
|
|
281
|
+
return {
|
|
282
|
+
successCount: 0,
|
|
283
|
+
failureCount: 0,
|
|
284
|
+
userErrors: filterParsed.userErrors,
|
|
285
|
+
} as ResolversTypes["BulkMutationResult"];
|
|
286
|
+
}
|
|
287
|
+
const inputParsed = safeParseGraphqlInput("${E}UpdateInput", args.input);
|
|
288
|
+
if (!inputParsed.ok) {
|
|
289
|
+
return {
|
|
290
|
+
successCount: 0,
|
|
291
|
+
failureCount: 0,
|
|
292
|
+
userErrors: inputParsed.userErrors,
|
|
293
|
+
} as ResolversTypes["BulkMutationResult"];
|
|
294
|
+
}
|
|
295
|
+
const result = await ctx.repositories.${e}.bulkUpdateByFilter(filterParsed.data as never, inputParsed.data as never, { actorId: ctx.actorId }, args.confirmUpdateAll);
|
|
229
296
|
const matchedIds = "matchedIds" in result ? result.matchedIds : undefined;
|
|
230
297
|
if (result.successCount > 0 && matchedIds && matchedIds.length > 0) {
|
|
231
298
|
const event = ctx.repositories.${e}.toChangeEvent("UPDATED", matchedIds);
|
|
@@ -271,22 +338,27 @@ export function generateResolvers(entities) {
|
|
|
271
338
|
const repoInitFields = entities
|
|
272
339
|
.map((e) => ` ${e.fieldBasename}: new Generated${e.graphqlType}Repository(),`)
|
|
273
340
|
.join("\n");
|
|
274
|
-
const
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return ast.value;
|
|
283
|
-
},
|
|
284
|
-
} as GraphQLScalarType,`;
|
|
341
|
+
const usedScalars = collectUsedDalScalars(entities);
|
|
342
|
+
const scalarNamesExport = usedScalars.length > 0
|
|
343
|
+
? `export const dalScalarResolvers = {
|
|
344
|
+
${usedScalars.map((s) => ` ${s}: dalGraphQLScalar("${s}"),`).join("\n")}
|
|
345
|
+
};
|
|
346
|
+
`
|
|
347
|
+
: `export const dalScalarResolvers = {};
|
|
348
|
+
`;
|
|
285
349
|
return `// AUTO-GENERATED by @corpdk/dal-codegen — do not edit
|
|
286
|
-
import {
|
|
350
|
+
import { type GraphQLResolveInfo } from "graphql";
|
|
351
|
+
import { dalGraphQLScalar } from "@corpdk/dal-core";
|
|
287
352
|
import { DataLoader } from "@corpdk/dal-core";
|
|
288
353
|
import type { Resolvers, ResolversParentTypes, ResolversTypes } from "../../graphql/resolvers.generated.js";
|
|
289
354
|
import type { PubSub } from "../generated-pubsub.js";
|
|
355
|
+
import {
|
|
356
|
+
safeParseGraphqlInput,
|
|
357
|
+
safeParseGraphqlInputList,
|
|
358
|
+
safeParseOptionalGraphqlInput,
|
|
359
|
+
safeParseOptionalGraphqlInputList,
|
|
360
|
+
unwrapGraphqlInputParseResult,
|
|
361
|
+
} from "../input-zod.js";
|
|
290
362
|
${repoImports}
|
|
291
363
|
|
|
292
364
|
export interface DalContext {
|
|
@@ -319,8 +391,8 @@ ${loaderSetup}
|
|
|
319
391
|
return ctxRef;
|
|
320
392
|
}
|
|
321
393
|
|
|
394
|
+
${scalarNamesExport}
|
|
322
395
|
export const generatedResolvers = {
|
|
323
|
-
${scalarBlock}
|
|
324
396
|
Query: {
|
|
325
397
|
hello: (_: unknown, args: { name?: string | null }): string =>
|
|
326
398
|
\`Hello, \${args.name ?? "world"}!\`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolvers.js","sourceRoot":"","sources":["../../src/generators/resolvers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolvers.js","sourceRoot":"","sources":["../../src/generators/resolvers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAE7D,SAAS,kBAAkB,CAAC,GAAqC,EAAE,QAAuB;IACxF,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,KAAK,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC3E,OAAO,MAAM,EAAE,aAAa,IAAI,GAAG,CAAC,gBAAgB,CAAC;AACvD,CAAC;AAED,SAAS,mBAAmB,CAAC,QAAuB;IAClD,MAAM,UAAU,GAAa,EAAE,CAAC;IAEhC,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC9B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;YACnC,MAAM,SAAS,GAAG,GAAG,MAAM,CAAC,aAAa,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YAE7D,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,aAAa,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,CAAC,IAAI,GAAG,CAAC,iBAAiB,EAAE,CAAC;gBACvF,MAAM,UAAU,GAAG,kBAAkB,CAA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import type { EntityModel } from "../model.js";
|
|
4
|
+
type CustomScalar = DalCustomScalarName;
|
|
3
5
|
export interface GraphqlEnumDef {
|
|
4
6
|
name: string;
|
|
5
7
|
values: string[];
|
|
6
8
|
}
|
|
9
|
+
/** Custom scalars referenced by entity columns (stable order for SDL emission). */
|
|
10
|
+
export declare function collectUsedDalScalars(entities: EntityModel[]): CustomScalar[];
|
|
7
11
|
export interface SchemaRegistry {
|
|
8
12
|
types: Map<string, GraphQLNamedType>;
|
|
9
13
|
sortDirection: GraphQLEnumType;
|
|
@@ -17,3 +21,4 @@ export declare function registryType(registry: SchemaRegistry, name: string): Gr
|
|
|
17
21
|
/** Resolves a type reference string (e.g. `ID!`, `[String!]`) from the registry. */
|
|
18
22
|
export declare function registryTypeRef(registry: SchemaRegistry, sdl: string): GraphQLType;
|
|
19
23
|
export declare function buildSchemaRegistry(entities: EntityModel[]): SchemaRegistry;
|
|
24
|
+
export {};
|
|
@@ -1,21 +1,9 @@
|
|
|
1
1
|
import { GraphQLBoolean, GraphQLEnumType, GraphQLFloat, GraphQLID, GraphQLInputObjectType, GraphQLInt, GraphQLList, GraphQLNonNull, GraphQLObjectType, GraphQLScalarType, GraphQLString, } from "graphql";
|
|
2
|
+
import { dalGraphQLScalar, } from "@corpdk/dal-core";
|
|
2
3
|
import { filterableColumns, visibleOutputColumns } from "./schema-utils.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
TimeTz: "ISO-8601 time with timezone offset.",
|
|
7
|
-
BigInt: "Signed 64-bit integer serialized as a decimal string.",
|
|
8
|
-
Decimal: "Arbitrary-precision decimal serialized as a string.",
|
|
9
|
-
IntervalMs: "Duration as signed milliseconds.",
|
|
10
|
-
};
|
|
11
|
-
function passthroughScalar(name, description) {
|
|
12
|
-
return new GraphQLScalarType({
|
|
13
|
-
name,
|
|
14
|
-
description,
|
|
15
|
-
serialize: (value) => value,
|
|
16
|
-
parseValue: (value) => value,
|
|
17
|
-
parseLiteral: (ast) => ast,
|
|
18
|
-
});
|
|
4
|
+
/** Custom scalars referenced by entity columns (stable order for SDL emission). */
|
|
5
|
+
export function collectUsedDalScalars(entities) {
|
|
6
|
+
return collectUsedTypes(entities).scalars;
|
|
19
7
|
}
|
|
20
8
|
function customScalarForColumn(col) {
|
|
21
9
|
switch (col.kind) {
|
|
@@ -31,6 +19,18 @@ function customScalarForColumn(col) {
|
|
|
31
19
|
return "TimeTz";
|
|
32
20
|
case "interval":
|
|
33
21
|
return "IntervalMs";
|
|
22
|
+
case "smallint":
|
|
23
|
+
return "SmallInt";
|
|
24
|
+
case "double":
|
|
25
|
+
return "Double";
|
|
26
|
+
case "citext":
|
|
27
|
+
return "InsensitiveString";
|
|
28
|
+
case "inet":
|
|
29
|
+
return "IP";
|
|
30
|
+
case "cidr":
|
|
31
|
+
return "CIDR";
|
|
32
|
+
case "macaddr":
|
|
33
|
+
return "MAC";
|
|
34
34
|
default:
|
|
35
35
|
return null;
|
|
36
36
|
}
|
|
@@ -47,10 +47,21 @@ function filterForColumnKind(col) {
|
|
|
47
47
|
case "varchar":
|
|
48
48
|
return "StringFilter";
|
|
49
49
|
case "smallint":
|
|
50
|
+
return "SmallIntFilter";
|
|
50
51
|
case "integer":
|
|
51
52
|
return "IntFilter";
|
|
52
|
-
case "
|
|
53
|
+
case "real":
|
|
53
54
|
return "FloatFilter";
|
|
55
|
+
case "double":
|
|
56
|
+
return "DoubleFilter";
|
|
57
|
+
case "citext":
|
|
58
|
+
return "InsensitiveStringFilter";
|
|
59
|
+
case "inet":
|
|
60
|
+
return "IPFilter";
|
|
61
|
+
case "cidr":
|
|
62
|
+
return "CIDRFilter";
|
|
63
|
+
case "macaddr":
|
|
64
|
+
return "MACFilter";
|
|
54
65
|
case "bigint":
|
|
55
66
|
return "BigIntFilter";
|
|
56
67
|
case "decimal":
|
|
@@ -108,6 +119,12 @@ function collectUsedTypes(entities) {
|
|
|
108
119
|
"BigInt",
|
|
109
120
|
"Decimal",
|
|
110
121
|
"IntervalMs",
|
|
122
|
+
"SmallInt",
|
|
123
|
+
"Double",
|
|
124
|
+
"InsensitiveString",
|
|
125
|
+
"IP",
|
|
126
|
+
"CIDR",
|
|
127
|
+
"MAC",
|
|
111
128
|
];
|
|
112
129
|
const filterOrder = [
|
|
113
130
|
"StringFilter",
|
|
@@ -115,12 +132,18 @@ function collectUsedTypes(entities) {
|
|
|
115
132
|
"DateTimeFilter",
|
|
116
133
|
"IDFilter",
|
|
117
134
|
"IntFilter",
|
|
135
|
+
"SmallIntFilter",
|
|
118
136
|
"FloatFilter",
|
|
137
|
+
"DoubleFilter",
|
|
119
138
|
"BigIntFilter",
|
|
120
139
|
"DecimalFilter",
|
|
121
140
|
"DateFilter",
|
|
122
141
|
"TimeTzFilter",
|
|
123
142
|
"IntervalMsFilter",
|
|
143
|
+
"InsensitiveStringFilter",
|
|
144
|
+
"IPFilter",
|
|
145
|
+
"CIDRFilter",
|
|
146
|
+
"MACFilter",
|
|
124
147
|
];
|
|
125
148
|
return {
|
|
126
149
|
scalars: scalarOrder.filter((s) => scalarSet.has(s)),
|
|
@@ -210,10 +233,30 @@ function buildIntFilter() {
|
|
|
210
233
|
},
|
|
211
234
|
});
|
|
212
235
|
}
|
|
236
|
+
function buildSmallIntFilter(smallInt) {
|
|
237
|
+
return new GraphQLInputObjectType({
|
|
238
|
+
name: "SmallIntFilter",
|
|
239
|
+
description: "Filter operators for smallint columns.",
|
|
240
|
+
fields: {
|
|
241
|
+
eq: { type: smallInt },
|
|
242
|
+
neq: { type: smallInt },
|
|
243
|
+
gt: { type: smallInt },
|
|
244
|
+
gte: { type: smallInt },
|
|
245
|
+
lt: { type: smallInt },
|
|
246
|
+
lte: { type: smallInt },
|
|
247
|
+
in: { type: new GraphQLList(new GraphQLNonNull(smallInt)) },
|
|
248
|
+
notIn: { type: new GraphQLList(new GraphQLNonNull(smallInt)) },
|
|
249
|
+
isNull: {
|
|
250
|
+
type: GraphQLBoolean,
|
|
251
|
+
description: "True = IS NULL; false = IS NOT NULL; nullable columns only.",
|
|
252
|
+
},
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
}
|
|
213
256
|
function buildFloatFilter() {
|
|
214
257
|
return new GraphQLInputObjectType({
|
|
215
258
|
name: "FloatFilter",
|
|
216
|
-
description: "Filter operators for
|
|
259
|
+
description: "Filter operators for real (binary32) columns.",
|
|
217
260
|
fields: {
|
|
218
261
|
eq: { type: GraphQLFloat },
|
|
219
262
|
neq: { type: GraphQLFloat },
|
|
@@ -230,6 +273,57 @@ function buildFloatFilter() {
|
|
|
230
273
|
},
|
|
231
274
|
});
|
|
232
275
|
}
|
|
276
|
+
function buildDoubleFilter(doubleScalar) {
|
|
277
|
+
return new GraphQLInputObjectType({
|
|
278
|
+
name: "DoubleFilter",
|
|
279
|
+
description: "Filter operators for double precision columns.",
|
|
280
|
+
fields: {
|
|
281
|
+
eq: { type: doubleScalar },
|
|
282
|
+
neq: { type: doubleScalar },
|
|
283
|
+
gt: { type: doubleScalar },
|
|
284
|
+
gte: { type: doubleScalar },
|
|
285
|
+
lt: { type: doubleScalar },
|
|
286
|
+
lte: { type: doubleScalar },
|
|
287
|
+
in: { type: new GraphQLList(new GraphQLNonNull(doubleScalar)) },
|
|
288
|
+
notIn: { type: new GraphQLList(new GraphQLNonNull(doubleScalar)) },
|
|
289
|
+
isNull: {
|
|
290
|
+
type: GraphQLBoolean,
|
|
291
|
+
description: "True = IS NULL; false = IS NOT NULL; nullable columns only.",
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
function buildInsensitiveStringFilter(insensitiveString) {
|
|
297
|
+
return new GraphQLInputObjectType({
|
|
298
|
+
name: "InsensitiveStringFilter",
|
|
299
|
+
description: "Filter operators for citext columns; matching is case-insensitive via PostgreSQL citext (no isCaseInsensitive flag).",
|
|
300
|
+
fields: {
|
|
301
|
+
eq: { type: insensitiveString },
|
|
302
|
+
neq: { type: insensitiveString },
|
|
303
|
+
like: { type: insensitiveString },
|
|
304
|
+
in: { type: new GraphQLList(new GraphQLNonNull(insensitiveString)) },
|
|
305
|
+
notIn: { type: new GraphQLList(new GraphQLNonNull(insensitiveString)) },
|
|
306
|
+
isNull: {
|
|
307
|
+
type: GraphQLBoolean,
|
|
308
|
+
description: "True = IS NULL; false = IS NOT NULL; nullable columns only.",
|
|
309
|
+
},
|
|
310
|
+
},
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
function buildEqNeqNetworkFilter(name, description, scalar) {
|
|
314
|
+
return new GraphQLInputObjectType({
|
|
315
|
+
name,
|
|
316
|
+
description,
|
|
317
|
+
fields: {
|
|
318
|
+
eq: { type: scalar },
|
|
319
|
+
neq: { type: scalar },
|
|
320
|
+
isNull: {
|
|
321
|
+
type: GraphQLBoolean,
|
|
322
|
+
description: "True = IS NULL; false = IS NOT NULL; nullable columns only.",
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
});
|
|
326
|
+
}
|
|
233
327
|
function buildBigIntFilter(bigInt) {
|
|
234
328
|
return new GraphQLInputObjectType({
|
|
235
329
|
name: "BigIntFilter",
|
|
@@ -243,6 +337,10 @@ function buildBigIntFilter(bigInt) {
|
|
|
243
337
|
lte: { type: bigInt },
|
|
244
338
|
in: { type: new GraphQLList(new GraphQLNonNull(bigInt)) },
|
|
245
339
|
notIn: { type: new GraphQLList(new GraphQLNonNull(bigInt)) },
|
|
340
|
+
isNull: {
|
|
341
|
+
type: GraphQLBoolean,
|
|
342
|
+
description: "True = IS NULL; false = IS NOT NULL; nullable columns only.",
|
|
343
|
+
},
|
|
246
344
|
},
|
|
247
345
|
});
|
|
248
346
|
}
|
|
@@ -259,6 +357,10 @@ function buildDecimalFilter(decimal) {
|
|
|
259
357
|
lte: { type: decimal },
|
|
260
358
|
in: { type: new GraphQLList(new GraphQLNonNull(decimal)) },
|
|
261
359
|
notIn: { type: new GraphQLList(new GraphQLNonNull(decimal)) },
|
|
360
|
+
isNull: {
|
|
361
|
+
type: GraphQLBoolean,
|
|
362
|
+
description: "True = IS NULL; false = IS NOT NULL; nullable columns only.",
|
|
363
|
+
},
|
|
262
364
|
},
|
|
263
365
|
});
|
|
264
366
|
}
|
|
@@ -315,6 +417,10 @@ function buildIntervalMsFilter(intervalMs) {
|
|
|
315
417
|
lte: { type: intervalMs },
|
|
316
418
|
in: { type: new GraphQLList(new GraphQLNonNull(intervalMs)) },
|
|
317
419
|
notIn: { type: new GraphQLList(new GraphQLNonNull(intervalMs)) },
|
|
420
|
+
isNull: {
|
|
421
|
+
type: GraphQLBoolean,
|
|
422
|
+
description: "True = IS NULL; false = IS NOT NULL; nullable columns only.",
|
|
423
|
+
},
|
|
318
424
|
},
|
|
319
425
|
});
|
|
320
426
|
}
|
|
@@ -327,6 +433,10 @@ function buildEnumFilter(enumType) {
|
|
|
327
433
|
neq: { type: enumType },
|
|
328
434
|
in: { type: new GraphQLList(new GraphQLNonNull(enumType)) },
|
|
329
435
|
notIn: { type: new GraphQLList(new GraphQLNonNull(enumType)) },
|
|
436
|
+
isNull: {
|
|
437
|
+
type: GraphQLBoolean,
|
|
438
|
+
description: "True = IS NULL; false = IS NOT NULL; nullable columns only.",
|
|
439
|
+
},
|
|
330
440
|
},
|
|
331
441
|
});
|
|
332
442
|
}
|
|
@@ -335,6 +445,7 @@ const BUILTIN_TYPES = new Map([
|
|
|
335
445
|
["Boolean", GraphQLBoolean],
|
|
336
446
|
["ID", GraphQLID],
|
|
337
447
|
["Int", GraphQLInt],
|
|
448
|
+
["Float", GraphQLFloat],
|
|
338
449
|
]);
|
|
339
450
|
/** Resolves a named type from the registry; throws if missing. */
|
|
340
451
|
export function registryType(registry, name) {
|
|
@@ -362,12 +473,26 @@ export function registryTypeRef(registry, sdl) {
|
|
|
362
473
|
}
|
|
363
474
|
return nullable ? inner : new GraphQLNonNull(inner);
|
|
364
475
|
}
|
|
476
|
+
/**
|
|
477
|
+
* dal-core holds singleton scalars built with its own `graphql` copy; codegen builds
|
|
478
|
+
* types with this package's `graphql`. Re-instantiate so GraphQLNonNull/List checks pass.
|
|
479
|
+
*/
|
|
480
|
+
function registryDalScalar(name) {
|
|
481
|
+
const source = dalGraphQLScalar(name);
|
|
482
|
+
return new GraphQLScalarType({
|
|
483
|
+
name: source.name,
|
|
484
|
+
description: source.description ?? undefined,
|
|
485
|
+
serialize: (value) => source.serialize(value),
|
|
486
|
+
parseValue: (value) => source.parseValue(value),
|
|
487
|
+
parseLiteral: (ast, variables) => source.parseLiteral(ast, variables),
|
|
488
|
+
});
|
|
489
|
+
}
|
|
365
490
|
export function buildSchemaRegistry(entities) {
|
|
366
491
|
const { scalars, filters, enums } = collectUsedTypes(entities);
|
|
367
492
|
const types = new Map();
|
|
368
493
|
const customScalars = new Map();
|
|
369
494
|
for (const scalar of scalars) {
|
|
370
|
-
const type =
|
|
495
|
+
const type = registryDalScalar(scalar);
|
|
371
496
|
customScalars.set(scalar, type);
|
|
372
497
|
types.set(scalar, type);
|
|
373
498
|
}
|
|
@@ -439,6 +564,12 @@ export function buildSchemaRegistry(entities) {
|
|
|
439
564
|
const date = customScalars.get("Date");
|
|
440
565
|
const timeTz = customScalars.get("TimeTz");
|
|
441
566
|
const intervalMs = customScalars.get("IntervalMs");
|
|
567
|
+
const smallInt = customScalars.get("SmallInt");
|
|
568
|
+
const doubleScalar = customScalars.get("Double");
|
|
569
|
+
const insensitiveString = customScalars.get("InsensitiveString");
|
|
570
|
+
const ip = customScalars.get("IP");
|
|
571
|
+
const cidr = customScalars.get("CIDR");
|
|
572
|
+
const mac = customScalars.get("MAC");
|
|
442
573
|
const filterBuilders = {
|
|
443
574
|
StringFilter: buildStringFilter,
|
|
444
575
|
BooleanFilter: buildBooleanFilter,
|
|
@@ -449,7 +580,17 @@ export function buildSchemaRegistry(entities) {
|
|
|
449
580
|
},
|
|
450
581
|
IDFilter: buildIdFilter,
|
|
451
582
|
IntFilter: buildIntFilter,
|
|
583
|
+
SmallIntFilter: () => {
|
|
584
|
+
if (!smallInt)
|
|
585
|
+
throw new Error("SmallIntFilter requires SmallInt scalar");
|
|
586
|
+
return buildSmallIntFilter(smallInt);
|
|
587
|
+
},
|
|
452
588
|
FloatFilter: buildFloatFilter,
|
|
589
|
+
DoubleFilter: () => {
|
|
590
|
+
if (!doubleScalar)
|
|
591
|
+
throw new Error("DoubleFilter requires Double scalar");
|
|
592
|
+
return buildDoubleFilter(doubleScalar);
|
|
593
|
+
},
|
|
453
594
|
BigIntFilter: () => {
|
|
454
595
|
if (!bigInt)
|
|
455
596
|
throw new Error("BigIntFilter requires BigInt scalar");
|
|
@@ -475,6 +616,27 @@ export function buildSchemaRegistry(entities) {
|
|
|
475
616
|
throw new Error("IntervalMsFilter requires IntervalMs scalar");
|
|
476
617
|
return buildIntervalMsFilter(intervalMs);
|
|
477
618
|
},
|
|
619
|
+
InsensitiveStringFilter: () => {
|
|
620
|
+
if (!insensitiveString) {
|
|
621
|
+
throw new Error("InsensitiveStringFilter requires InsensitiveString scalar");
|
|
622
|
+
}
|
|
623
|
+
return buildInsensitiveStringFilter(insensitiveString);
|
|
624
|
+
},
|
|
625
|
+
IPFilter: () => {
|
|
626
|
+
if (!ip)
|
|
627
|
+
throw new Error("IPFilter requires IP scalar");
|
|
628
|
+
return buildEqNeqNetworkFilter("IPFilter", "Filter operators for inet columns.", ip);
|
|
629
|
+
},
|
|
630
|
+
CIDRFilter: () => {
|
|
631
|
+
if (!cidr)
|
|
632
|
+
throw new Error("CIDRFilter requires CIDR scalar");
|
|
633
|
+
return buildEqNeqNetworkFilter("CIDRFilter", "Filter operators for cidr columns.", cidr);
|
|
634
|
+
},
|
|
635
|
+
MACFilter: () => {
|
|
636
|
+
if (!mac)
|
|
637
|
+
throw new Error("MACFilter requires MAC scalar");
|
|
638
|
+
return buildEqNeqNetworkFilter("MACFilter", "Filter operators for macaddr columns.", mac);
|
|
639
|
+
},
|
|
478
640
|
};
|
|
479
641
|
for (const filter of filters) {
|
|
480
642
|
const build = filterBuilders[filter];
|