@zenstackhq/orm 3.8.0-beta.1 → 3.8.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +12 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -14
- package/dist/index.d.mts +36 -16
- package/dist/index.mjs +198 -188
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -9
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
|
|
|
2
2
|
import { AnyNull, AnyNullClass, DbNull, DbNullClass, JsonNull, JsonNullClass } from "./common-types.mjs";
|
|
3
3
|
import { clone, enumerate, invariant, isPlainObject, lowerCaseFirst, upperCaseFirst } from "@zenstackhq/common-helpers";
|
|
4
4
|
import { AliasNode, AndNode, ColumnNode, ColumnUpdateNode, CompiledQuery, DefaultConnectionProvider, DefaultQueryExecutor, DeleteQueryNode, ExpressionWrapper, FromNode, IdentifierNode, InsertQueryNode, Kysely, Log, OperationNodeTransformer, OperationNodeVisitor, PrimitiveValueListNode, ReferenceNode, ReturningNode, SelectAllNode, SelectionNode, SingleConnectionProvider, TableNode, Transaction, UpdateQueryNode, ValueListNode, ValueNode, ValuesNode, WhereNode, createQueryId, expressionBuilder, sql } from "kysely";
|
|
5
|
-
import z, { ZodObject, ZodType, z
|
|
5
|
+
import z$1, { ZodObject, ZodType, z } from "zod";
|
|
6
6
|
import { fromError } from "zod-validation-error/v4";
|
|
7
7
|
import { P, match } from "ts-pattern";
|
|
8
8
|
import { ExpressionUtils } from "@zenstackhq/schema";
|
|
@@ -1832,7 +1832,7 @@ var PostgresCrudDialect = class PostgresCrudDialect extends LateralJoinDialectBa
|
|
|
1832
1832
|
return this.eb.fn("trim", [expression, sql.lit("\"")]);
|
|
1833
1833
|
}
|
|
1834
1834
|
buildArrayLength(array) {
|
|
1835
|
-
return this.eb.fn("array_length", [array]);
|
|
1835
|
+
return this.eb.fn("array_length", [array, sql.lit(1)]);
|
|
1836
1836
|
}
|
|
1837
1837
|
buildArrayValue(values, elemType) {
|
|
1838
1838
|
const arr = sql`ARRAY[${sql.join(values, sql.raw(","))}]`;
|
|
@@ -2287,7 +2287,7 @@ function createQuerySchemaFactory(clientOrSchema, options) {
|
|
|
2287
2287
|
* @see https://github.com/zenstackhq/zenstack/issues/2631
|
|
2288
2288
|
*/
|
|
2289
2289
|
function coercedDateTimeSchema() {
|
|
2290
|
-
return z
|
|
2290
|
+
return z.preprocess((val) => {
|
|
2291
2291
|
if (typeof val !== "string") return val;
|
|
2292
2292
|
if (/^\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d\d(?::\d\d)?)?$/.test(val)) {
|
|
2293
2293
|
const hasTz = val.endsWith("Z") || /[+-]\d\d(?::\d\d)?$/.test(val);
|
|
@@ -2296,10 +2296,10 @@ function coercedDateTimeSchema() {
|
|
|
2296
2296
|
}
|
|
2297
2297
|
const d = new Date(val);
|
|
2298
2298
|
return isNaN(d.getTime()) ? val : d;
|
|
2299
|
-
}, z
|
|
2300
|
-
z
|
|
2301
|
-
z
|
|
2302
|
-
z
|
|
2299
|
+
}, z.union([
|
|
2300
|
+
z.iso.datetime(),
|
|
2301
|
+
z.iso.date(),
|
|
2302
|
+
z.date()
|
|
2303
2303
|
]));
|
|
2304
2304
|
}
|
|
2305
2305
|
/**
|
|
@@ -2307,7 +2307,7 @@ function coercedDateTimeSchema() {
|
|
|
2307
2307
|
*/
|
|
2308
2308
|
var ZodSchemaFactory = class {
|
|
2309
2309
|
schemaCache = /* @__PURE__ */ new Map();
|
|
2310
|
-
schemaRegistry = z
|
|
2310
|
+
schemaRegistry = z.registry();
|
|
2311
2311
|
allFilterKinds = [...new Set(Object.values(FILTER_PROPERTY_TO_KIND))];
|
|
2312
2312
|
schema;
|
|
2313
2313
|
options;
|
|
@@ -2399,7 +2399,7 @@ var ZodSchemaFactory = class {
|
|
|
2399
2399
|
this.makeGroupBySchema(m);
|
|
2400
2400
|
}
|
|
2401
2401
|
for (const procName of Object.keys(this.schema.procedures ?? {})) if (this.isProcedureAllowed(procName)) this.makeProcedureArgsSchema(procName);
|
|
2402
|
-
return z
|
|
2402
|
+
return z.toJSONSchema(this.schemaRegistry, { unrepresentable: "any" });
|
|
2403
2403
|
}
|
|
2404
2404
|
get cacheStats() {
|
|
2405
2405
|
return {
|
|
@@ -2428,13 +2428,13 @@ var ZodSchemaFactory = class {
|
|
|
2428
2428
|
fields["omit"] = this.makeOmitSchema(model).optional().nullable();
|
|
2429
2429
|
if (!unique) {
|
|
2430
2430
|
fields["skip"] = this.makeSkipSchema().optional();
|
|
2431
|
-
if (findOne) fields["take"] = z
|
|
2431
|
+
if (findOne) fields["take"] = z.literal(1).optional();
|
|
2432
2432
|
else fields["take"] = this.makeTakeSchema().optional();
|
|
2433
2433
|
fields["orderBy"] = this.orArray(this.makeOrderBySchema(model, true, false, options), true).optional();
|
|
2434
2434
|
fields["cursor"] = this.makeCursorSchema(model, options).optional();
|
|
2435
2435
|
fields["distinct"] = this.makeDistinctSchema(model).optional();
|
|
2436
2436
|
}
|
|
2437
|
-
const baseSchema = z
|
|
2437
|
+
const baseSchema = z.strictObject(fields);
|
|
2438
2438
|
let result = this.mergePluginArgsSchema(baseSchema, operation);
|
|
2439
2439
|
result = this.refineForSelectIncludeMutuallyExclusive(result);
|
|
2440
2440
|
result = this.refineForSelectOmitMutuallyExclusive(result);
|
|
@@ -2444,7 +2444,7 @@ var ZodSchemaFactory = class {
|
|
|
2444
2444
|
return result;
|
|
2445
2445
|
}
|
|
2446
2446
|
makeExistsSchema(model, options) {
|
|
2447
|
-
const baseSchema = z
|
|
2447
|
+
const baseSchema = z.strictObject({ where: this.makeWhereSchema(model, false, false, false, options).optional() });
|
|
2448
2448
|
const result = this.mergePluginArgsSchema(baseSchema, "exists").optional();
|
|
2449
2449
|
this.registerSchema(`${model}ExistsArgs`, result);
|
|
2450
2450
|
return result;
|
|
@@ -2452,31 +2452,31 @@ var ZodSchemaFactory = class {
|
|
|
2452
2452
|
makeScalarSchema(type, attributes) {
|
|
2453
2453
|
if (this.schema.typeDefs && type in this.schema.typeDefs) return this.makeTypeDefSchema(type);
|
|
2454
2454
|
else if (this.schema.enums && type in this.schema.enums) return this.makeEnumSchema(type);
|
|
2455
|
-
else return match(type).with("String", () => this.extraValidationsEnabled ? ZodUtils.addStringValidation(z
|
|
2456
|
-
return z
|
|
2457
|
-
this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z
|
|
2458
|
-
ZodUtils.addDecimalValidation(z
|
|
2459
|
-
ZodUtils.addDecimalValidation(z
|
|
2455
|
+
else return match(type).with("String", () => this.extraValidationsEnabled ? ZodUtils.addStringValidation(z.string(), attributes) : z.string()).with("Int", () => this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z.number().int(), attributes) : z.number().int()).with("Float", () => this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z.number(), attributes) : z.number()).with("Boolean", () => z.boolean()).with("BigInt", () => z.union([this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z.number().int(), attributes) : z.number().int(), this.extraValidationsEnabled ? ZodUtils.addBigIntValidation(z.bigint(), attributes) : z.bigint()])).with("Decimal", () => {
|
|
2456
|
+
return z.union([
|
|
2457
|
+
this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z.number(), attributes) : z.number(),
|
|
2458
|
+
ZodUtils.addDecimalValidation(z.instanceof(Decimal), attributes, this.extraValidationsEnabled),
|
|
2459
|
+
ZodUtils.addDecimalValidation(z.string(), attributes, this.extraValidationsEnabled)
|
|
2460
2460
|
]);
|
|
2461
|
-
}).with("DateTime", () => this.makeDateTimeValueSchema()).with("Bytes", () => z
|
|
2461
|
+
}).with("DateTime", () => this.makeDateTimeValueSchema()).with("Bytes", () => z.instanceof(Uint8Array)).with("Json", () => this.makeJsonValueSchema()).otherwise(() => z.unknown());
|
|
2462
2462
|
}
|
|
2463
2463
|
makeEnumSchema(_enum) {
|
|
2464
2464
|
const enumDef = getEnum(this.schema, _enum);
|
|
2465
2465
|
invariant(enumDef, `Enum "${_enum}" not found in schema`);
|
|
2466
|
-
const schema = z
|
|
2466
|
+
const schema = z.enum(Object.keys(enumDef.values));
|
|
2467
2467
|
this.registerSchema(_enum, schema);
|
|
2468
2468
|
return schema;
|
|
2469
2469
|
}
|
|
2470
2470
|
makeTypeDefSchema(type) {
|
|
2471
2471
|
const typeDef = getTypeDef(this.schema, type);
|
|
2472
2472
|
invariant(typeDef, `Type definition "${type}" not found in schema`);
|
|
2473
|
-
const schema = z
|
|
2474
|
-
let fieldSchema = isTypeDef(this.schema, def.type) ? z
|
|
2473
|
+
const schema = z.looseObject(Object.fromEntries(Object.entries(typeDef.fields).map(([field, def]) => {
|
|
2474
|
+
let fieldSchema = isTypeDef(this.schema, def.type) ? z.lazy(() => this.makeTypeDefSchema(def.type)) : this.makeScalarSchema(def.type);
|
|
2475
2475
|
if (def.array) fieldSchema = fieldSchema.array();
|
|
2476
2476
|
if (def.optional) fieldSchema = fieldSchema.nullish();
|
|
2477
2477
|
return [field, fieldSchema];
|
|
2478
2478
|
})));
|
|
2479
|
-
const finalSchema = z
|
|
2479
|
+
const finalSchema = z.any().superRefine((value, ctx) => {
|
|
2480
2480
|
const parseResult = schema.safeParse(value);
|
|
2481
2481
|
if (!parseResult.success) parseResult.error.issues.forEach((issue) => ctx.addIssue(issue));
|
|
2482
2482
|
});
|
|
@@ -2492,17 +2492,17 @@ var ZodSchemaFactory = class {
|
|
|
2492
2492
|
if (fieldDef.relation) {
|
|
2493
2493
|
if (withoutRelationFields || !this.shouldIncludeRelations(options)) continue;
|
|
2494
2494
|
const allowedFilterKinds = this.getEffectiveFilterKinds(model, field);
|
|
2495
|
-
if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) fieldSchema = z
|
|
2495
|
+
if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) fieldSchema = z.never();
|
|
2496
2496
|
else {
|
|
2497
|
-
fieldSchema = z
|
|
2498
|
-
if (fieldDef.array) fieldSchema = z
|
|
2497
|
+
fieldSchema = z.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts).optional());
|
|
2498
|
+
if (fieldDef.array) fieldSchema = z.strictObject({
|
|
2499
2499
|
some: fieldSchema.optional(),
|
|
2500
2500
|
every: fieldSchema.optional(),
|
|
2501
2501
|
none: fieldSchema.optional()
|
|
2502
2502
|
});
|
|
2503
2503
|
else {
|
|
2504
2504
|
fieldSchema = this.nullableIf(fieldSchema, !fieldDef.array && !!fieldDef.optional);
|
|
2505
|
-
fieldSchema = z
|
|
2505
|
+
fieldSchema = z.union([fieldSchema, z.strictObject({
|
|
2506
2506
|
is: fieldSchema.optional(),
|
|
2507
2507
|
isNot: fieldSchema.optional()
|
|
2508
2508
|
})]);
|
|
@@ -2521,21 +2521,21 @@ var ZodSchemaFactory = class {
|
|
|
2521
2521
|
}
|
|
2522
2522
|
if (unique) {
|
|
2523
2523
|
const uniqueFields = getUniqueFields(this.schema, model);
|
|
2524
|
-
for (const uniqueField of uniqueFields) if ("defs" in uniqueField) fields[uniqueField.name] = z
|
|
2524
|
+
for (const uniqueField of uniqueFields) if ("defs" in uniqueField) fields[uniqueField.name] = z.object(Object.fromEntries(Object.entries(uniqueField.defs).map(([key, def]) => {
|
|
2525
2525
|
invariant(!def.relation, "unique field cannot be a relation");
|
|
2526
2526
|
let fieldSchema;
|
|
2527
2527
|
const enumDef = getEnum(this.schema, def.type);
|
|
2528
2528
|
if (enumDef) if (Object.keys(enumDef.values).length > 0) fieldSchema = this.makeEnumFilterSchema(def.type, !!def.optional, !!def.array, false, void 0);
|
|
2529
|
-
else fieldSchema = z
|
|
2529
|
+
else fieldSchema = z.never();
|
|
2530
2530
|
else fieldSchema = this.makePrimitiveFilterSchema(def.type, !!def.optional, false, void 0);
|
|
2531
2531
|
return [key, fieldSchema];
|
|
2532
2532
|
}))).optional();
|
|
2533
2533
|
}
|
|
2534
|
-
fields["$expr"] = z
|
|
2535
|
-
fields["AND"] = this.orArray(z
|
|
2536
|
-
fields["OR"] = z
|
|
2537
|
-
fields["NOT"] = this.orArray(z
|
|
2538
|
-
const baseWhere = z
|
|
2534
|
+
fields["$expr"] = z.custom((v) => typeof v === "function", { error: "\"$expr\" must be a function" }).optional();
|
|
2535
|
+
fields["AND"] = this.orArray(z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
|
|
2536
|
+
fields["OR"] = z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)).array().optional();
|
|
2537
|
+
fields["NOT"] = this.orArray(z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
|
|
2538
|
+
const baseWhere = z.strictObject(fields);
|
|
2539
2539
|
let result = baseWhere;
|
|
2540
2540
|
if (unique) {
|
|
2541
2541
|
const uniqueFields = getUniqueFields(this.schema, model);
|
|
@@ -2561,26 +2561,26 @@ var ZodSchemaFactory = class {
|
|
|
2561
2561
|
else if (getEnum(this.schema, fieldDef.type)) fieldSchemas[fieldName] = this.makeEnumFilterSchema(fieldDef.type, !!fieldDef.optional, !!fieldDef.array, false, void 0).optional();
|
|
2562
2562
|
else if (fieldDef.array) fieldSchemas[fieldName] = this.makeArrayFilterSchema(fieldDef.type, void 0).optional();
|
|
2563
2563
|
else fieldSchemas[fieldName] = this.makePrimitiveFilterSchema(fieldDef.type, !!fieldDef.optional, false, void 0).optional();
|
|
2564
|
-
candidates.push(z
|
|
2564
|
+
candidates.push(z.strictObject(fieldSchemas));
|
|
2565
2565
|
}
|
|
2566
|
-
const recursiveSchema = z
|
|
2567
|
-
if (array) candidates.push(z
|
|
2566
|
+
const recursiveSchema = z.lazy(() => this.makeTypedJsonFilterSchema(type, optional, false, allowedFilterKinds)).optional();
|
|
2567
|
+
if (array) candidates.push(z.strictObject({
|
|
2568
2568
|
some: recursiveSchema,
|
|
2569
2569
|
every: recursiveSchema,
|
|
2570
2570
|
none: recursiveSchema
|
|
2571
2571
|
}));
|
|
2572
|
-
else candidates.push(z
|
|
2572
|
+
else candidates.push(z.strictObject({
|
|
2573
2573
|
is: recursiveSchema,
|
|
2574
2574
|
isNot: recursiveSchema
|
|
2575
2575
|
}));
|
|
2576
2576
|
candidates.push(this.makeJsonFilterSchema(optional, allowedFilterKinds));
|
|
2577
2577
|
if (optional) {
|
|
2578
|
-
candidates.push(z
|
|
2579
|
-
candidates.push(z
|
|
2580
|
-
candidates.push(z
|
|
2581
|
-
candidates.push(z
|
|
2578
|
+
candidates.push(z.null());
|
|
2579
|
+
candidates.push(z.instanceof(DbNullClass));
|
|
2580
|
+
candidates.push(z.instanceof(JsonNullClass));
|
|
2581
|
+
candidates.push(z.instanceof(AnyNullClass));
|
|
2582
2582
|
}
|
|
2583
|
-
const result = z
|
|
2583
|
+
const result = z.union(candidates);
|
|
2584
2584
|
this.registerSchema(`${type}Filter${this.filterSchemaSuffix({
|
|
2585
2585
|
optional,
|
|
2586
2586
|
array,
|
|
@@ -2589,7 +2589,7 @@ var ZodSchemaFactory = class {
|
|
|
2589
2589
|
return result;
|
|
2590
2590
|
}
|
|
2591
2591
|
makeNullableTypedJsonMutationSchema(fieldSchema) {
|
|
2592
|
-
return z
|
|
2592
|
+
return z.any().superRefine((value, ctx) => {
|
|
2593
2593
|
if (value instanceof DbNullClass || value instanceof JsonNullClass || value === null || value === void 0) return;
|
|
2594
2594
|
const parseResult = fieldSchema.safeParse(value);
|
|
2595
2595
|
if (!parseResult.success) parseResult.error.issues.forEach((issue) => ctx.addIssue(issue));
|
|
@@ -2601,11 +2601,11 @@ var ZodSchemaFactory = class {
|
|
|
2601
2601
|
makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds) {
|
|
2602
2602
|
const enumDef = getEnum(this.schema, enumName);
|
|
2603
2603
|
invariant(enumDef, `Enum "${enumName}" not found in schema`);
|
|
2604
|
-
const baseSchema = z
|
|
2604
|
+
const baseSchema = z.enum(Object.keys(enumDef.values));
|
|
2605
2605
|
let schema;
|
|
2606
2606
|
if (array) schema = this.internalMakeArrayFilterSchema(baseSchema, allowedFilterKinds);
|
|
2607
2607
|
else {
|
|
2608
|
-
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z
|
|
2608
|
+
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z.lazy(() => this.makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds)), [
|
|
2609
2609
|
"equals",
|
|
2610
2610
|
"in",
|
|
2611
2611
|
"notIn",
|
|
@@ -2639,42 +2639,42 @@ var ZodSchemaFactory = class {
|
|
|
2639
2639
|
has: elementSchema.optional(),
|
|
2640
2640
|
hasEvery: elementSchema.array().optional(),
|
|
2641
2641
|
hasSome: elementSchema.array().optional(),
|
|
2642
|
-
isEmpty: z
|
|
2642
|
+
isEmpty: z.boolean().optional()
|
|
2643
2643
|
};
|
|
2644
2644
|
const filteredOperators = this.trimFilterOperators(operators, allowedFilterKinds);
|
|
2645
|
-
return z
|
|
2645
|
+
return z.strictObject(filteredOperators);
|
|
2646
2646
|
}
|
|
2647
2647
|
makePrimitiveFilterSchema(type, optional, withAggregations, allowedFilterKinds, withFuzzy = false, withFullText = false) {
|
|
2648
|
-
return match(type).with("String", () => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy, withFullText)).with(P.union("Int", "Float", "Decimal", "BigInt"), (type) => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)).with("Boolean", () => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)).with("DateTime", () => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)).with("Bytes", () => this.makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds)).with("Json", () => this.makeJsonFilterSchema(optional, allowedFilterKinds)).with("Unsupported", () => z
|
|
2648
|
+
return match(type).with("String", () => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy, withFullText)).with(P.union("Int", "Float", "Decimal", "BigInt"), (type) => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)).with("Boolean", () => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)).with("DateTime", () => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)).with("Bytes", () => this.makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds)).with("Json", () => this.makeJsonFilterSchema(optional, allowedFilterKinds)).with("Unsupported", () => z.never()).exhaustive();
|
|
2649
2649
|
}
|
|
2650
2650
|
makeJsonValueSchema() {
|
|
2651
|
-
const schema = z
|
|
2652
|
-
z
|
|
2653
|
-
z
|
|
2654
|
-
z
|
|
2655
|
-
z
|
|
2656
|
-
z
|
|
2657
|
-
z
|
|
2651
|
+
const schema = z.union([
|
|
2652
|
+
z.string(),
|
|
2653
|
+
z.number(),
|
|
2654
|
+
z.boolean(),
|
|
2655
|
+
z.instanceof(JsonNullClass),
|
|
2656
|
+
z.lazy(() => z.union([this.makeJsonValueSchema(), z.null()]).array()),
|
|
2657
|
+
z.record(z.string(), z.lazy(() => z.union([this.makeJsonValueSchema(), z.null()])))
|
|
2658
2658
|
]);
|
|
2659
2659
|
this.registerSchema("JsonValue", schema);
|
|
2660
2660
|
return schema;
|
|
2661
2661
|
}
|
|
2662
2662
|
makeJsonFilterSchema(optional, allowedFilterKinds) {
|
|
2663
|
-
if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) return z
|
|
2663
|
+
if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) return z.never();
|
|
2664
2664
|
const filterMembers = [
|
|
2665
2665
|
this.makeJsonValueSchema(),
|
|
2666
|
-
z
|
|
2667
|
-
z
|
|
2666
|
+
z.instanceof(DbNullClass),
|
|
2667
|
+
z.instanceof(AnyNullClass)
|
|
2668
2668
|
];
|
|
2669
|
-
if (optional) filterMembers.push(z
|
|
2670
|
-
const filterValueSchema = z
|
|
2671
|
-
const schema = z
|
|
2672
|
-
path: z
|
|
2669
|
+
if (optional) filterMembers.push(z.null());
|
|
2670
|
+
const filterValueSchema = z.union(filterMembers);
|
|
2671
|
+
const schema = z.strictObject({
|
|
2672
|
+
path: z.string().optional(),
|
|
2673
2673
|
equals: filterValueSchema.optional(),
|
|
2674
2674
|
not: filterValueSchema.optional(),
|
|
2675
|
-
string_contains: z
|
|
2676
|
-
string_starts_with: z
|
|
2677
|
-
string_ends_with: z
|
|
2675
|
+
string_contains: z.string().optional(),
|
|
2676
|
+
string_starts_with: z.string().optional(),
|
|
2677
|
+
string_ends_with: z.string().optional(),
|
|
2678
2678
|
mode: this.makeStringModeSchema().optional(),
|
|
2679
2679
|
array_contains: filterValueSchema.optional(),
|
|
2680
2680
|
array_starts_with: filterValueSchema.optional(),
|
|
@@ -2693,7 +2693,7 @@ var ZodSchemaFactory = class {
|
|
|
2693
2693
|
}
|
|
2694
2694
|
makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
2695
2695
|
const filterValueSchema = this.makeDateTimeValueSchema();
|
|
2696
|
-
const schema = this.makeCommonPrimitiveFilterSchema(filterValueSchema, optional, () => z
|
|
2696
|
+
const schema = this.makeCommonPrimitiveFilterSchema(filterValueSchema, optional, () => z.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)), withAggregations ? [
|
|
2697
2697
|
"_count",
|
|
2698
2698
|
"_min",
|
|
2699
2699
|
"_max"
|
|
@@ -2706,12 +2706,12 @@ var ZodSchemaFactory = class {
|
|
|
2706
2706
|
return schema;
|
|
2707
2707
|
}
|
|
2708
2708
|
makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
2709
|
-
const components = this.makeCommonPrimitiveFilterComponents(z
|
|
2709
|
+
const components = this.makeCommonPrimitiveFilterComponents(z.boolean(), optional, () => z.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)), ["equals", "not"], withAggregations ? [
|
|
2710
2710
|
"_count",
|
|
2711
2711
|
"_min",
|
|
2712
2712
|
"_max"
|
|
2713
2713
|
] : void 0, allowedFilterKinds);
|
|
2714
|
-
const schema = this.createUnionFilterSchema(z
|
|
2714
|
+
const schema = this.createUnionFilterSchema(z.boolean(), optional, components, allowedFilterKinds);
|
|
2715
2715
|
this.registerSchema(`BooleanFilter${this.filterSchemaSuffix({
|
|
2716
2716
|
optional,
|
|
2717
2717
|
allowedFilterKinds,
|
|
@@ -2720,8 +2720,8 @@ var ZodSchemaFactory = class {
|
|
|
2720
2720
|
return schema;
|
|
2721
2721
|
}
|
|
2722
2722
|
makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
2723
|
-
const baseSchema = z
|
|
2724
|
-
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z
|
|
2723
|
+
const baseSchema = z.instanceof(Uint8Array);
|
|
2724
|
+
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z.instanceof(Uint8Array), [
|
|
2725
2725
|
"equals",
|
|
2726
2726
|
"in",
|
|
2727
2727
|
"notIn",
|
|
@@ -2769,7 +2769,7 @@ var ZodSchemaFactory = class {
|
|
|
2769
2769
|
return this.createUnionFilterSchema(baseSchema, optional, components, allowedFilterKinds);
|
|
2770
2770
|
}
|
|
2771
2771
|
makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds) {
|
|
2772
|
-
const schema = this.makeCommonPrimitiveFilterSchema(this.makeScalarSchema(type), optional, () => z
|
|
2772
|
+
const schema = this.makeCommonPrimitiveFilterSchema(this.makeScalarSchema(type), optional, () => z.lazy(() => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)), withAggregations ? [
|
|
2773
2773
|
"_count",
|
|
2774
2774
|
"_avg",
|
|
2775
2775
|
"_sum",
|
|
@@ -2784,15 +2784,15 @@ var ZodSchemaFactory = class {
|
|
|
2784
2784
|
return schema;
|
|
2785
2785
|
}
|
|
2786
2786
|
makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy = false, withFullText = false) {
|
|
2787
|
-
const baseComponents = this.makeCommonPrimitiveFilterComponents(z
|
|
2787
|
+
const baseComponents = this.makeCommonPrimitiveFilterComponents(z.string(), optional, () => z.lazy(() => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy, withFullText)), void 0, withAggregations ? [
|
|
2788
2788
|
"_count",
|
|
2789
2789
|
"_min",
|
|
2790
2790
|
"_max"
|
|
2791
2791
|
] : void 0, allowedFilterKinds);
|
|
2792
2792
|
const stringSpecificOperators = {
|
|
2793
|
-
startsWith: z
|
|
2794
|
-
endsWith: z
|
|
2795
|
-
contains: z
|
|
2793
|
+
startsWith: z.string().optional(),
|
|
2794
|
+
endsWith: z.string().optional(),
|
|
2795
|
+
contains: z.string().optional(),
|
|
2796
2796
|
...withFuzzy && this.providerSupportsFuzzySearch ? { fuzzy: this.makeFuzzyFilterSchema().optional() } : {},
|
|
2797
2797
|
...withFullText && this.providerSupportsFullTextSearch ? { fts: this.makeFullTextFilterSchema().optional() } : {},
|
|
2798
2798
|
...this.providerSupportsCaseSensitivity ? { mode: this.makeStringModeSchema().optional() } : {}
|
|
@@ -2802,7 +2802,7 @@ var ZodSchemaFactory = class {
|
|
|
2802
2802
|
...baseComponents,
|
|
2803
2803
|
...filteredStringOperators
|
|
2804
2804
|
};
|
|
2805
|
-
const schema = this.createUnionFilterSchema(z
|
|
2805
|
+
const schema = this.createUnionFilterSchema(z.string(), optional, allComponents, allowedFilterKinds);
|
|
2806
2806
|
const featureSuffix = `${withFuzzy ? "Fuzzy" : ""}${withFullText ? "FullText" : ""}`;
|
|
2807
2807
|
this.registerSchema(`StringFilter${this.filterSchemaSuffix({
|
|
2808
2808
|
optional,
|
|
@@ -2812,24 +2812,24 @@ var ZodSchemaFactory = class {
|
|
|
2812
2812
|
return schema;
|
|
2813
2813
|
}
|
|
2814
2814
|
makeStringModeSchema() {
|
|
2815
|
-
return z
|
|
2815
|
+
return z.union([z.literal("default"), z.literal("insensitive")]);
|
|
2816
2816
|
}
|
|
2817
2817
|
makeFuzzyFilterSchema() {
|
|
2818
|
-
return z
|
|
2819
|
-
search: z
|
|
2820
|
-
mode: z
|
|
2821
|
-
z
|
|
2822
|
-
z
|
|
2823
|
-
z
|
|
2818
|
+
return z.strictObject({
|
|
2819
|
+
search: z.string().min(1),
|
|
2820
|
+
mode: z.union([
|
|
2821
|
+
z.literal("simple"),
|
|
2822
|
+
z.literal("word"),
|
|
2823
|
+
z.literal("strictWord")
|
|
2824
2824
|
]).default("simple"),
|
|
2825
|
-
threshold: z
|
|
2826
|
-
unaccent: z
|
|
2825
|
+
threshold: z.number().min(0).max(1).optional(),
|
|
2826
|
+
unaccent: z.boolean().default(false)
|
|
2827
2827
|
});
|
|
2828
2828
|
}
|
|
2829
2829
|
makeFullTextFilterSchema() {
|
|
2830
|
-
return z
|
|
2831
|
-
search: z
|
|
2832
|
-
config: z
|
|
2830
|
+
return z.strictObject({
|
|
2831
|
+
search: z.string().min(1),
|
|
2832
|
+
config: z.string().min(1).optional()
|
|
2833
2833
|
});
|
|
2834
2834
|
}
|
|
2835
2835
|
makeSelectSchema(model, options) {
|
|
@@ -2837,13 +2837,14 @@ var ZodSchemaFactory = class {
|
|
|
2837
2837
|
for (const [field, fieldDef] of this.getModelFields(model)) if (fieldDef.relation) {
|
|
2838
2838
|
if (!this.shouldIncludeRelations(options)) continue;
|
|
2839
2839
|
if (this.isModelAllowed(fieldDef.type)) fields[field] = this.makeRelationSelectIncludeSchema(model, field, options).optional();
|
|
2840
|
-
} else fields[field] = z
|
|
2840
|
+
} else if (this.options.allowQueryTimeOmitOverride === false && this.isFieldOmittedByConfig(model, field)) fields[field] = z.literal(false).optional();
|
|
2841
|
+
else fields[field] = z.boolean().optional();
|
|
2841
2842
|
if (this.shouldIncludeRelations(options)) {
|
|
2842
2843
|
const _countSchema = this.makeCountSelectionSchema(model, options);
|
|
2843
|
-
if (!(_countSchema instanceof z
|
|
2844
|
+
if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
|
|
2844
2845
|
}
|
|
2845
2846
|
this.addExtResultFields(model, fields);
|
|
2846
|
-
const result = z
|
|
2847
|
+
const result = z.strictObject(fields);
|
|
2847
2848
|
this.registerSchema(`${model}Select`, result);
|
|
2848
2849
|
return result;
|
|
2849
2850
|
}
|
|
@@ -2852,24 +2853,24 @@ var ZodSchemaFactory = class {
|
|
|
2852
2853
|
const toManyRelations = Object.values(modelDef.fields).filter((def) => def.relation && def.array);
|
|
2853
2854
|
if (toManyRelations.length > 0) {
|
|
2854
2855
|
const nextOpts = this.nextOptions(options);
|
|
2855
|
-
const schema = z
|
|
2856
|
+
const schema = z.union([z.literal(true), z.strictObject({ select: z.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
|
|
2856
2857
|
...acc,
|
|
2857
|
-
[fieldDef.name]: z
|
|
2858
|
+
[fieldDef.name]: z.union([z.boolean(), z.strictObject({ where: this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts) })]).optional()
|
|
2858
2859
|
}), {})) })]).optional();
|
|
2859
2860
|
this.registerSchema(`${model}CountSelection`, schema);
|
|
2860
2861
|
return schema;
|
|
2861
|
-
} else return z
|
|
2862
|
+
} else return z.never();
|
|
2862
2863
|
}
|
|
2863
2864
|
makeRelationSelectIncludeSchema(model, field, options) {
|
|
2864
2865
|
const fieldDef = requireField(this.schema, model, field);
|
|
2865
2866
|
const nextOpts = this.nextOptions(options);
|
|
2866
|
-
let objSchema = z
|
|
2867
|
-
...fieldDef.array || fieldDef.optional ? { where: z
|
|
2868
|
-
select: z
|
|
2869
|
-
include: z
|
|
2870
|
-
omit: z
|
|
2867
|
+
let objSchema = z.strictObject({
|
|
2868
|
+
...fieldDef.array || fieldDef.optional ? { where: z.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts)).optional() } : {},
|
|
2869
|
+
select: z.lazy(() => this.makeSelectSchema(fieldDef.type, nextOpts)).optional().nullable(),
|
|
2870
|
+
include: z.lazy(() => this.makeIncludeSchema(fieldDef.type, nextOpts)).optional().nullable(),
|
|
2871
|
+
omit: z.lazy(() => this.makeOmitSchema(fieldDef.type)).optional().nullable(),
|
|
2871
2872
|
...fieldDef.array ? {
|
|
2872
|
-
orderBy: z
|
|
2873
|
+
orderBy: z.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false, nextOpts), true)).optional(),
|
|
2873
2874
|
skip: this.makeSkipSchema().optional(),
|
|
2874
2875
|
take: this.makeTakeSchema().optional(),
|
|
2875
2876
|
cursor: this.makeCursorSchema(fieldDef.type, nextOpts).optional(),
|
|
@@ -2879,16 +2880,25 @@ var ZodSchemaFactory = class {
|
|
|
2879
2880
|
objSchema = this.refineForSelectIncludeMutuallyExclusive(objSchema);
|
|
2880
2881
|
objSchema = this.refineForSelectOmitMutuallyExclusive(objSchema);
|
|
2881
2882
|
objSchema = this.refineForSelectHasTruthyField(objSchema);
|
|
2882
|
-
const result = z
|
|
2883
|
+
const result = z.union([z.boolean(), objSchema]);
|
|
2883
2884
|
this.registerSchema(`${model}${upperCaseFirst(field)}RelationInput`, result);
|
|
2884
2885
|
return result;
|
|
2885
2886
|
}
|
|
2887
|
+
/**
|
|
2888
|
+
* Determines whether a field is configured to be omitted at the schema or client-options level
|
|
2889
|
+
* (query-level omit is excluded as it's mutually exclusive with `select`).
|
|
2890
|
+
*/
|
|
2891
|
+
isFieldOmittedByConfig(model, field) {
|
|
2892
|
+
const omitConfig = this.options.omit?.[lowerCaseFirst(model)] ?? this.options.omit?.[model];
|
|
2893
|
+
if (omitConfig && typeof omitConfig[field] === "boolean") return omitConfig[field];
|
|
2894
|
+
return !!requireField(this.schema, model, field).omit;
|
|
2895
|
+
}
|
|
2886
2896
|
makeOmitSchema(model) {
|
|
2887
2897
|
const fields = {};
|
|
2888
|
-
for (const [field, fieldDef] of this.getModelFields(model)) if (!fieldDef.relation) if (this.options.allowQueryTimeOmitOverride !== false) fields[field] = z
|
|
2889
|
-
else fields[field] = z
|
|
2898
|
+
for (const [field, fieldDef] of this.getModelFields(model)) if (!fieldDef.relation) if (this.options.allowQueryTimeOmitOverride !== false) fields[field] = z.boolean().optional();
|
|
2899
|
+
else fields[field] = z.literal(true).optional();
|
|
2890
2900
|
this.addExtResultFields(model, fields);
|
|
2891
|
-
const result = z
|
|
2901
|
+
const result = z.strictObject(fields);
|
|
2892
2902
|
this.registerSchema(`${model}OmitInput`, result);
|
|
2893
2903
|
return result;
|
|
2894
2904
|
}
|
|
@@ -2897,7 +2907,7 @@ var ZodSchemaFactory = class {
|
|
|
2897
2907
|
const resultConfig = plugin.result;
|
|
2898
2908
|
if (resultConfig) {
|
|
2899
2909
|
const modelConfig = resultConfig[lowerCaseFirst(model)];
|
|
2900
|
-
if (modelConfig) for (const field of Object.keys(modelConfig)) fields[field] = z
|
|
2910
|
+
if (modelConfig) for (const field of Object.keys(modelConfig)) fields[field] = z.boolean().optional();
|
|
2901
2911
|
}
|
|
2902
2912
|
}
|
|
2903
2913
|
}
|
|
@@ -2913,26 +2923,26 @@ var ZodSchemaFactory = class {
|
|
|
2913
2923
|
}
|
|
2914
2924
|
if (this.shouldIncludeRelations(options)) {
|
|
2915
2925
|
const _countSchema = this.makeCountSelectionSchema(model, options);
|
|
2916
|
-
if (!(_countSchema instanceof z
|
|
2926
|
+
if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
|
|
2917
2927
|
}
|
|
2918
|
-
const result = z
|
|
2928
|
+
const result = z.strictObject(fields);
|
|
2919
2929
|
this.registerSchema(`${model}Include`, result);
|
|
2920
2930
|
return result;
|
|
2921
2931
|
}
|
|
2922
2932
|
makeOrderBySchema(model, withRelation, WithAggregation, options) {
|
|
2923
2933
|
const fields = {};
|
|
2924
|
-
const sort = z
|
|
2934
|
+
const sort = z.union([z.literal("asc"), z.literal("desc")]);
|
|
2925
2935
|
const refineAtMostOneKey = (s) => s.refine((v) => Object.keys(v).length <= 1, { message: "Each orderBy element must have at most one key" });
|
|
2926
2936
|
const nextOpts = this.nextOptions(options);
|
|
2927
2937
|
for (const [field, fieldDef] of this.getModelFields(model)) if (fieldDef.relation) {
|
|
2928
|
-
if (withRelation && this.shouldIncludeRelations(options)) fields[field] = z
|
|
2938
|
+
if (withRelation && this.shouldIncludeRelations(options)) fields[field] = z.lazy(() => {
|
|
2929
2939
|
let relationOrderBy = this.makeOrderBySchema(fieldDef.type, withRelation, WithAggregation, nextOpts);
|
|
2930
2940
|
if (fieldDef.array) relationOrderBy = refineAtMostOneKey(relationOrderBy.safeExtend({ _count: sort }));
|
|
2931
2941
|
return relationOrderBy;
|
|
2932
2942
|
}).optional();
|
|
2933
|
-
} else if (fieldDef.optional) fields[field] = z
|
|
2943
|
+
} else if (fieldDef.optional) fields[field] = z.union([sort, z.strictObject({
|
|
2934
2944
|
sort,
|
|
2935
|
-
nulls: z
|
|
2945
|
+
nulls: z.union([z.literal("first"), z.literal("last")]).optional()
|
|
2936
2946
|
})]).optional();
|
|
2937
2947
|
else fields[field] = sort.optional();
|
|
2938
2948
|
if (WithAggregation) for (const agg of [
|
|
@@ -2941,31 +2951,31 @@ var ZodSchemaFactory = class {
|
|
|
2941
2951
|
"_sum",
|
|
2942
2952
|
"_min",
|
|
2943
2953
|
"_max"
|
|
2944
|
-
]) fields[agg] = z
|
|
2954
|
+
]) fields[agg] = z.lazy(() => this.makeOrderBySchema(model, true, false, options).optional());
|
|
2945
2955
|
if (this.providerSupportsFuzzySearch) {
|
|
2946
2956
|
const fuzzyFieldNames = this.getModelFields(model).filter(([, def]) => !def.relation && def.type === "String" && def.fuzzy === true).map(([name]) => name);
|
|
2947
|
-
if (fuzzyFieldNames.length > 0) fields["_fuzzyRelevance"] = z
|
|
2948
|
-
fields: z
|
|
2949
|
-
search: z
|
|
2950
|
-
mode: z
|
|
2951
|
-
z
|
|
2952
|
-
z
|
|
2953
|
-
z
|
|
2957
|
+
if (fuzzyFieldNames.length > 0) fields["_fuzzyRelevance"] = z.strictObject({
|
|
2958
|
+
fields: z.array(z.enum(fuzzyFieldNames)).min(1),
|
|
2959
|
+
search: z.string(),
|
|
2960
|
+
mode: z.union([
|
|
2961
|
+
z.literal("simple"),
|
|
2962
|
+
z.literal("word"),
|
|
2963
|
+
z.literal("strictWord")
|
|
2954
2964
|
]).default("simple"),
|
|
2955
|
-
unaccent: z
|
|
2965
|
+
unaccent: z.boolean().default(false),
|
|
2956
2966
|
sort
|
|
2957
2967
|
}).optional();
|
|
2958
2968
|
}
|
|
2959
2969
|
if (this.providerSupportsFullTextSearch) {
|
|
2960
2970
|
const fullTextFieldNames = this.getModelFields(model).filter(([, def]) => !def.relation && def.type === "String" && def.fullText === true).map(([name]) => name);
|
|
2961
|
-
if (fullTextFieldNames.length > 0) fields["_ftsRelevance"] = z
|
|
2962
|
-
fields: z
|
|
2963
|
-
search: z
|
|
2964
|
-
config: z
|
|
2971
|
+
if (fullTextFieldNames.length > 0) fields["_ftsRelevance"] = z.strictObject({
|
|
2972
|
+
fields: z.array(z.enum(fullTextFieldNames)).min(1),
|
|
2973
|
+
search: z.string().min(1),
|
|
2974
|
+
config: z.string().min(1).optional(),
|
|
2965
2975
|
sort
|
|
2966
2976
|
}).optional();
|
|
2967
2977
|
}
|
|
2968
|
-
const schema = refineAtMostOneKey(z
|
|
2978
|
+
const schema = refineAtMostOneKey(z.strictObject(fields));
|
|
2969
2979
|
let schemaId = `${model}OrderBy`;
|
|
2970
2980
|
if (withRelation) schemaId += "WithRelation";
|
|
2971
2981
|
if (WithAggregation) schemaId += "WithAggregation";
|
|
@@ -2975,7 +2985,7 @@ var ZodSchemaFactory = class {
|
|
|
2975
2985
|
}
|
|
2976
2986
|
makeDistinctSchema(model) {
|
|
2977
2987
|
const nonRelationFields = this.getModelFields(model).filter(([, def]) => !def.relation).map(([name]) => name);
|
|
2978
|
-
const schema = nonRelationFields.length > 0 ? this.orArray(z
|
|
2988
|
+
const schema = nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields), true) : z.never();
|
|
2979
2989
|
this.registerSchema(`${model}DistinctInput`, schema);
|
|
2980
2990
|
return schema;
|
|
2981
2991
|
}
|
|
@@ -2986,7 +2996,7 @@ var ZodSchemaFactory = class {
|
|
|
2986
2996
|
}
|
|
2987
2997
|
makeCreateSchema(model, options) {
|
|
2988
2998
|
const dataSchema = this.makeCreateDataSchema(model, false, [], false, options);
|
|
2989
|
-
const baseSchema = z
|
|
2999
|
+
const baseSchema = z.strictObject({
|
|
2990
3000
|
data: dataSchema,
|
|
2991
3001
|
select: this.makeSelectSchema(model, options).optional().nullable(),
|
|
2992
3002
|
include: this.makeIncludeSchema(model, options).optional().nullable(),
|
|
@@ -3035,7 +3045,7 @@ var ZodSchemaFactory = class {
|
|
|
3035
3045
|
const oppositeFieldDef = requireField(this.schema, fieldDef.type, oppositeField);
|
|
3036
3046
|
if (oppositeFieldDef.relation?.fields) excludeFields.push(...oppositeFieldDef.relation.fields);
|
|
3037
3047
|
}
|
|
3038
|
-
let fieldSchema = z
|
|
3048
|
+
let fieldSchema = z.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "create", nextOpts));
|
|
3039
3049
|
if (fieldDef.optional || fieldDef.array) fieldSchema = fieldSchema.optional();
|
|
3040
3050
|
else {
|
|
3041
3051
|
let allFksOptional = false;
|
|
@@ -3052,23 +3062,23 @@ var ZodSchemaFactory = class {
|
|
|
3052
3062
|
let fieldSchema = this.makeScalarSchema(fieldDef.type, fieldDef.attributes);
|
|
3053
3063
|
if (fieldDef.array) {
|
|
3054
3064
|
fieldSchema = ZodUtils.addListValidation(fieldSchema.array(), fieldDef.attributes);
|
|
3055
|
-
fieldSchema = z
|
|
3065
|
+
fieldSchema = z.union([fieldSchema, z.strictObject({ set: fieldSchema })]).optional();
|
|
3056
3066
|
}
|
|
3057
3067
|
if (fieldDef.optional || fieldHasDefaultValue(fieldDef)) fieldSchema = fieldSchema.optional();
|
|
3058
|
-
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z
|
|
3068
|
+
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z.union([fieldSchema, z.instanceof(DbNullClass)]);
|
|
3059
3069
|
else if (this.isTypeDefType(fieldDef.type)) fieldSchema = this.makeNullableTypedJsonMutationSchema(fieldSchema);
|
|
3060
3070
|
else fieldSchema = fieldSchema.nullable();
|
|
3061
3071
|
uncheckedVariantFields[field] = fieldSchema;
|
|
3062
3072
|
if (!fieldDef.foreignKeyFor) checkedVariantFields[field] = fieldSchema;
|
|
3063
3073
|
}
|
|
3064
3074
|
});
|
|
3065
|
-
const uncheckedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z
|
|
3066
|
-
const checkedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z
|
|
3067
|
-
const result = !hasRelation ? this.orArray(uncheckedCreateSchema, canBeArray) : z
|
|
3075
|
+
const uncheckedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(uncheckedVariantFields), modelDef.attributes) : z.strictObject(uncheckedVariantFields);
|
|
3076
|
+
const checkedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(checkedVariantFields), modelDef.attributes) : z.strictObject(checkedVariantFields);
|
|
3077
|
+
const result = !hasRelation ? this.orArray(uncheckedCreateSchema, canBeArray) : z.union([
|
|
3068
3078
|
uncheckedCreateSchema,
|
|
3069
3079
|
checkedCreateSchema,
|
|
3070
|
-
...canBeArray ? [z
|
|
3071
|
-
...canBeArray ? [z
|
|
3080
|
+
...canBeArray ? [z.array(uncheckedCreateSchema)] : [],
|
|
3081
|
+
...canBeArray ? [z.array(checkedCreateSchema)] : []
|
|
3072
3082
|
]);
|
|
3073
3083
|
const idParts = [`${model}CreateData`];
|
|
3074
3084
|
if (canBeArray) idParts.push("Array");
|
|
@@ -3093,17 +3103,17 @@ var ZodSchemaFactory = class {
|
|
|
3093
3103
|
fields["disconnect"] = this.makeDisconnectDataSchema(fieldType, array, options).optional();
|
|
3094
3104
|
fields["delete"] = this.makeDeleteRelationDataSchema(fieldType, array, true, options).optional();
|
|
3095
3105
|
}
|
|
3096
|
-
fields["update"] = array ? this.orArray(z
|
|
3106
|
+
fields["update"] = array ? this.orArray(z.strictObject({
|
|
3097
3107
|
where: this.makeWhereSchema(fieldType, true, false, false, options),
|
|
3098
3108
|
data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
3099
|
-
}), true).optional() : z
|
|
3109
|
+
}), true).optional() : z.union([z.strictObject({
|
|
3100
3110
|
where: this.makeWhereSchema(fieldType, false, false, false, options).optional(),
|
|
3101
3111
|
data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
3102
3112
|
}), this.makeUpdateDataSchema(fieldType, withoutFields, false, options)]).optional();
|
|
3103
3113
|
if (canCreateModel) {
|
|
3104
3114
|
let upsertWhere = this.makeWhereSchema(fieldType, true, false, false, options);
|
|
3105
3115
|
if (!fieldDef.array) upsertWhere = upsertWhere.optional();
|
|
3106
|
-
fields["upsert"] = this.orArray(z
|
|
3116
|
+
fields["upsert"] = this.orArray(z.strictObject({
|
|
3107
3117
|
where: upsertWhere,
|
|
3108
3118
|
create: this.makeCreateDataSchema(fieldType, false, withoutFields, false, options),
|
|
3109
3119
|
update: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
@@ -3111,14 +3121,14 @@ var ZodSchemaFactory = class {
|
|
|
3111
3121
|
}
|
|
3112
3122
|
if (array) {
|
|
3113
3123
|
fields["set"] = this.makeSetDataSchema(fieldType, true, options).optional();
|
|
3114
|
-
fields["updateMany"] = this.orArray(z
|
|
3124
|
+
fields["updateMany"] = this.orArray(z.strictObject({
|
|
3115
3125
|
where: this.makeWhereSchema(fieldType, false, true, false, options),
|
|
3116
3126
|
data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
3117
3127
|
}), true).optional();
|
|
3118
3128
|
fields["deleteMany"] = this.makeDeleteRelationDataSchema(fieldType, true, false, options).optional();
|
|
3119
3129
|
}
|
|
3120
3130
|
}
|
|
3121
|
-
return z
|
|
3131
|
+
return z.strictObject(fields);
|
|
3122
3132
|
}
|
|
3123
3133
|
makeSetDataSchema(model, canBeArray, options) {
|
|
3124
3134
|
return this.orArray(this.makeWhereSchema(model, true, false, false, options), canBeArray);
|
|
@@ -3128,23 +3138,23 @@ var ZodSchemaFactory = class {
|
|
|
3128
3138
|
}
|
|
3129
3139
|
makeDisconnectDataSchema(model, canBeArray, options) {
|
|
3130
3140
|
if (canBeArray) return this.orArray(this.makeWhereSchema(model, true, false, false, options), canBeArray);
|
|
3131
|
-
else return z
|
|
3141
|
+
else return z.union([z.boolean(), this.makeWhereSchema(model, false, false, false, options)]);
|
|
3132
3142
|
}
|
|
3133
3143
|
makeDeleteRelationDataSchema(model, toManyRelation, uniqueFilter, options) {
|
|
3134
|
-
return toManyRelation ? this.orArray(this.makeWhereSchema(model, uniqueFilter, false, false, options), true) : z
|
|
3144
|
+
return toManyRelation ? this.orArray(this.makeWhereSchema(model, uniqueFilter, false, false, options), true) : z.union([z.boolean(), this.makeWhereSchema(model, uniqueFilter, false, false, options)]);
|
|
3135
3145
|
}
|
|
3136
3146
|
makeConnectOrCreateDataSchema(model, canBeArray, withoutFields, options) {
|
|
3137
3147
|
const whereSchema = this.makeWhereSchema(model, true, false, false, options);
|
|
3138
3148
|
const createSchema = this.makeCreateDataSchema(model, false, withoutFields, false, options);
|
|
3139
|
-
return this.orArray(z
|
|
3149
|
+
return this.orArray(z.strictObject({
|
|
3140
3150
|
where: whereSchema,
|
|
3141
3151
|
create: createSchema
|
|
3142
3152
|
}), canBeArray);
|
|
3143
3153
|
}
|
|
3144
3154
|
makeCreateManyPayloadSchema(model, withoutFields, options) {
|
|
3145
|
-
const schema = z
|
|
3155
|
+
const schema = z.strictObject({
|
|
3146
3156
|
data: this.makeCreateDataSchema(model, true, withoutFields, true, options),
|
|
3147
|
-
skipDuplicates: z
|
|
3157
|
+
skipDuplicates: z.boolean().optional()
|
|
3148
3158
|
});
|
|
3149
3159
|
const idParts = [`${model}CreateManyPayload`];
|
|
3150
3160
|
if (withoutFields.length) idParts.push(`Without${withoutFields.slice().sort().join("")}`);
|
|
@@ -3152,7 +3162,7 @@ var ZodSchemaFactory = class {
|
|
|
3152
3162
|
return schema;
|
|
3153
3163
|
}
|
|
3154
3164
|
makeUpdateSchema(model, options) {
|
|
3155
|
-
const baseSchema = z
|
|
3165
|
+
const baseSchema = z.strictObject({
|
|
3156
3166
|
where: this.makeWhereSchema(model, true, false, false, options),
|
|
3157
3167
|
data: this.makeUpdateDataSchema(model, [], false, options),
|
|
3158
3168
|
select: this.makeSelectSchema(model, options).optional().nullable(),
|
|
@@ -3167,10 +3177,10 @@ var ZodSchemaFactory = class {
|
|
|
3167
3177
|
return schema;
|
|
3168
3178
|
}
|
|
3169
3179
|
makeUpdateManySchema(model, options) {
|
|
3170
|
-
const result = this.mergePluginArgsSchema(z
|
|
3180
|
+
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3171
3181
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3172
3182
|
data: this.makeUpdateDataSchema(model, [], true, options),
|
|
3173
|
-
limit: z
|
|
3183
|
+
limit: z.number().int().nonnegative().optional()
|
|
3174
3184
|
}), "updateMany");
|
|
3175
3185
|
this.registerSchema(`${model}UpdateManyArgs`, result);
|
|
3176
3186
|
return result;
|
|
@@ -3186,7 +3196,7 @@ var ZodSchemaFactory = class {
|
|
|
3186
3196
|
return schema;
|
|
3187
3197
|
}
|
|
3188
3198
|
makeUpsertSchema(model, options) {
|
|
3189
|
-
const baseSchema = z
|
|
3199
|
+
const baseSchema = z.strictObject({
|
|
3190
3200
|
where: this.makeWhereSchema(model, true, false, false, options),
|
|
3191
3201
|
create: this.makeCreateDataSchema(model, false, [], false, options),
|
|
3192
3202
|
update: this.makeUpdateDataSchema(model, [], false, options),
|
|
@@ -3222,27 +3232,27 @@ var ZodSchemaFactory = class {
|
|
|
3222
3232
|
const oppositeFieldDef = requireField(this.schema, fieldDef.type, oppositeField);
|
|
3223
3233
|
if (oppositeFieldDef.relation?.fields) excludeFields.push(...oppositeFieldDef.relation.fields);
|
|
3224
3234
|
}
|
|
3225
|
-
let fieldSchema = z
|
|
3235
|
+
let fieldSchema = z.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "update", nextOpts)).optional();
|
|
3226
3236
|
if (fieldDef.optional && !fieldDef.array) fieldSchema = fieldSchema.nullable();
|
|
3227
3237
|
checkedVariantFields[field] = fieldSchema;
|
|
3228
3238
|
if (fieldDef.array || !fieldDef.relation.references) uncheckedVariantFields[field] = fieldSchema;
|
|
3229
3239
|
} else {
|
|
3230
3240
|
let fieldSchema = this.makeScalarSchema(fieldDef.type, fieldDef.attributes);
|
|
3231
|
-
if (this.isNumericField(fieldDef)) fieldSchema = z
|
|
3232
|
-
set: this.nullableIf(z
|
|
3233
|
-
increment: z
|
|
3234
|
-
decrement: z
|
|
3235
|
-
multiply: z
|
|
3236
|
-
divide: z
|
|
3241
|
+
if (this.isNumericField(fieldDef)) fieldSchema = z.union([fieldSchema, z.object({
|
|
3242
|
+
set: this.nullableIf(z.number().optional(), !!fieldDef.optional).optional(),
|
|
3243
|
+
increment: z.number().optional(),
|
|
3244
|
+
decrement: z.number().optional(),
|
|
3245
|
+
multiply: z.number().optional(),
|
|
3246
|
+
divide: z.number().optional()
|
|
3237
3247
|
}).refine((v) => Object.keys(v).length === 1, "Only one of \"set\", \"increment\", \"decrement\", \"multiply\", or \"divide\" can be provided")]);
|
|
3238
3248
|
if (fieldDef.array) {
|
|
3239
3249
|
const arraySchema = ZodUtils.addListValidation(fieldSchema.array(), fieldDef.attributes);
|
|
3240
|
-
fieldSchema = z
|
|
3250
|
+
fieldSchema = z.union([arraySchema, z.object({
|
|
3241
3251
|
set: arraySchema.optional(),
|
|
3242
|
-
push: z
|
|
3252
|
+
push: z.union([fieldSchema, fieldSchema.array()]).optional()
|
|
3243
3253
|
}).refine((v) => Object.keys(v).length === 1, "Only one of \"set\", \"push\" can be provided")]);
|
|
3244
3254
|
}
|
|
3245
|
-
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z
|
|
3255
|
+
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z.union([fieldSchema, z.instanceof(DbNullClass)]);
|
|
3246
3256
|
else if (this.isTypeDefType(fieldDef.type)) fieldSchema = this.makeNullableTypedJsonMutationSchema(fieldSchema);
|
|
3247
3257
|
else fieldSchema = fieldSchema.nullable();
|
|
3248
3258
|
fieldSchema = fieldSchema.optional();
|
|
@@ -3250,9 +3260,9 @@ var ZodSchemaFactory = class {
|
|
|
3250
3260
|
if (!fieldDef.foreignKeyFor) checkedVariantFields[field] = fieldSchema;
|
|
3251
3261
|
}
|
|
3252
3262
|
});
|
|
3253
|
-
const uncheckedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z
|
|
3254
|
-
const checkedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z
|
|
3255
|
-
const result = !hasRelation ? uncheckedUpdateSchema : z
|
|
3263
|
+
const uncheckedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(uncheckedVariantFields), modelDef.attributes) : z.strictObject(uncheckedVariantFields);
|
|
3264
|
+
const checkedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(checkedVariantFields), modelDef.attributes) : z.strictObject(checkedVariantFields);
|
|
3265
|
+
const result = !hasRelation ? uncheckedUpdateSchema : z.union([uncheckedUpdateSchema, checkedUpdateSchema]);
|
|
3256
3266
|
const idParts = [`${model}UpdateData`];
|
|
3257
3267
|
if (withoutRelationFields) idParts.push("WithoutRelation");
|
|
3258
3268
|
if (withoutFields.length) idParts.push(`Without${withoutFields.slice().sort().join("")}`);
|
|
@@ -3260,7 +3270,7 @@ var ZodSchemaFactory = class {
|
|
|
3260
3270
|
return result;
|
|
3261
3271
|
}
|
|
3262
3272
|
makeDeleteSchema(model, options) {
|
|
3263
|
-
const baseSchema = z
|
|
3273
|
+
const baseSchema = z.strictObject({
|
|
3264
3274
|
where: this.makeWhereSchema(model, true, false, false, options),
|
|
3265
3275
|
select: this.makeSelectSchema(model, options).optional().nullable(),
|
|
3266
3276
|
include: this.makeIncludeSchema(model, options).optional().nullable(),
|
|
@@ -3274,15 +3284,15 @@ var ZodSchemaFactory = class {
|
|
|
3274
3284
|
return schema;
|
|
3275
3285
|
}
|
|
3276
3286
|
makeDeleteManySchema(model, options) {
|
|
3277
|
-
const result = this.mergePluginArgsSchema(z
|
|
3287
|
+
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3278
3288
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3279
|
-
limit: z
|
|
3289
|
+
limit: z.number().int().nonnegative().optional()
|
|
3280
3290
|
}), "deleteMany").optional();
|
|
3281
3291
|
this.registerSchema(`${model}DeleteManyArgs`, result);
|
|
3282
3292
|
return result;
|
|
3283
3293
|
}
|
|
3284
3294
|
makeCountSchema(model, options) {
|
|
3285
|
-
const result = this.mergePluginArgsSchema(z
|
|
3295
|
+
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3286
3296
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3287
3297
|
skip: this.makeSkipSchema().optional(),
|
|
3288
3298
|
take: this.makeTakeSchema().optional(),
|
|
@@ -3293,10 +3303,10 @@ var ZodSchemaFactory = class {
|
|
|
3293
3303
|
return result;
|
|
3294
3304
|
}
|
|
3295
3305
|
makeCountAggregateInputSchema(model) {
|
|
3296
|
-
const schema = z
|
|
3297
|
-
_all: z
|
|
3306
|
+
const schema = z.union([z.literal(true), z.strictObject({
|
|
3307
|
+
_all: z.literal(true).optional(),
|
|
3298
3308
|
...this.getModelFields(model).reduce((acc, [field]) => {
|
|
3299
|
-
acc[field] = z
|
|
3309
|
+
acc[field] = z.literal(true).optional();
|
|
3300
3310
|
return acc;
|
|
3301
3311
|
}, {})
|
|
3302
3312
|
})]);
|
|
@@ -3304,7 +3314,7 @@ var ZodSchemaFactory = class {
|
|
|
3304
3314
|
return schema;
|
|
3305
3315
|
}
|
|
3306
3316
|
makeAggregateSchema(model, options) {
|
|
3307
|
-
const result = this.mergePluginArgsSchema(z
|
|
3317
|
+
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3308
3318
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3309
3319
|
skip: this.makeSkipSchema().optional(),
|
|
3310
3320
|
take: this.makeTakeSchema().optional(),
|
|
@@ -3319,16 +3329,16 @@ var ZodSchemaFactory = class {
|
|
|
3319
3329
|
return result;
|
|
3320
3330
|
}
|
|
3321
3331
|
makeSumAvgInputSchema(model) {
|
|
3322
|
-
const schema = z
|
|
3323
|
-
if (this.isNumericField(fieldDef)) acc[field] = z
|
|
3332
|
+
const schema = z.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
|
|
3333
|
+
if (this.isNumericField(fieldDef)) acc[field] = z.literal(true).optional();
|
|
3324
3334
|
return acc;
|
|
3325
3335
|
}, {}));
|
|
3326
3336
|
this.registerSchema(`${model}SumAvgAggregateInput`, schema);
|
|
3327
3337
|
return schema;
|
|
3328
3338
|
}
|
|
3329
3339
|
makeMinMaxInputSchema(model) {
|
|
3330
|
-
const schema = z
|
|
3331
|
-
if (!fieldDef.relation && !fieldDef.array) acc[field] = z
|
|
3340
|
+
const schema = z.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
|
|
3341
|
+
if (!fieldDef.relation && !fieldDef.array) acc[field] = z.literal(true).optional();
|
|
3332
3342
|
return acc;
|
|
3333
3343
|
}, {}));
|
|
3334
3344
|
this.registerSchema(`${model}MinMaxAggregateInput`, schema);
|
|
@@ -3336,8 +3346,8 @@ var ZodSchemaFactory = class {
|
|
|
3336
3346
|
}
|
|
3337
3347
|
makeGroupBySchema(model, options) {
|
|
3338
3348
|
const nonRelationFields = this.getModelFields(model).filter(([, def]) => !def.relation).map(([name]) => name);
|
|
3339
|
-
const bySchema = nonRelationFields.length > 0 ? this.orArray(z
|
|
3340
|
-
const baseSchema = z
|
|
3349
|
+
const bySchema = nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields), true) : z.never();
|
|
3350
|
+
const baseSchema = z.strictObject({
|
|
3341
3351
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3342
3352
|
orderBy: this.orArray(this.makeOrderBySchema(model, false, true, options), true).optional(),
|
|
3343
3353
|
by: bySchema,
|
|
@@ -3389,7 +3399,7 @@ var ZodSchemaFactory = class {
|
|
|
3389
3399
|
if (!procDef) throw createInternalError(`Procedure not found: ${procName}`);
|
|
3390
3400
|
const shape = {};
|
|
3391
3401
|
for (const param of Object.values(procDef.params ?? {})) shape[param.name] = this.makeProcedureParamSchema(param);
|
|
3392
|
-
const schema = z
|
|
3402
|
+
const schema = z.object(shape);
|
|
3393
3403
|
this.registerSchema(`${procName}ProcArgs`, schema);
|
|
3394
3404
|
return schema;
|
|
3395
3405
|
}
|
|
@@ -3397,10 +3407,10 @@ var ZodSchemaFactory = class {
|
|
|
3397
3407
|
let schema;
|
|
3398
3408
|
if (isTypeDef(this.schema, param.type)) schema = this.makeTypeDefSchema(param.type);
|
|
3399
3409
|
else if (isEnum(this.schema, param.type)) schema = this.makeEnumSchema(param.type);
|
|
3400
|
-
else if (param.type in (this.schema.models ?? {})) schema = z
|
|
3410
|
+
else if (param.type in (this.schema.models ?? {})) schema = z.record(z.string(), z.unknown());
|
|
3401
3411
|
else {
|
|
3402
3412
|
schema = this.makeScalarSchema(param.type);
|
|
3403
|
-
if (schema instanceof z
|
|
3413
|
+
if (schema instanceof z.ZodUnknown) throw createInternalError(`Unsupported procedure parameter type: ${param.type}`);
|
|
3404
3414
|
}
|
|
3405
3415
|
if (param.array) schema = schema.array();
|
|
3406
3416
|
if (param.optional) schema = schema.optional();
|
|
@@ -3436,10 +3446,10 @@ var ZodSchemaFactory = class {
|
|
|
3436
3446
|
return result;
|
|
3437
3447
|
}
|
|
3438
3448
|
makeSkipSchema() {
|
|
3439
|
-
return z
|
|
3449
|
+
return z.number().int().nonnegative();
|
|
3440
3450
|
}
|
|
3441
3451
|
makeTakeSchema() {
|
|
3442
|
-
return z
|
|
3452
|
+
return z.number().int();
|
|
3443
3453
|
}
|
|
3444
3454
|
refineForSelectIncludeMutuallyExclusive(schema) {
|
|
3445
3455
|
return schema.refine((value) => !(value["select"] && value["include"]), "\"select\" and \"include\" cannot be used together");
|
|
@@ -3458,7 +3468,7 @@ var ZodSchemaFactory = class {
|
|
|
3458
3468
|
return nullable ? schema.nullable() : schema;
|
|
3459
3469
|
}
|
|
3460
3470
|
orArray(schema, canBeArray) {
|
|
3461
|
-
return canBeArray ? z
|
|
3471
|
+
return canBeArray ? z.union([schema, z.array(schema)]) : schema;
|
|
3462
3472
|
}
|
|
3463
3473
|
isNumericField(fieldDef) {
|
|
3464
3474
|
return NUMERIC_FIELD_TYPES.includes(fieldDef.type) && !fieldDef.array;
|
|
@@ -3520,10 +3530,10 @@ var ZodSchemaFactory = class {
|
|
|
3520
3530
|
createUnionFilterSchema(valueSchema, optional, components, allowedFilterKinds) {
|
|
3521
3531
|
if (Object.keys(components).length === 0) {
|
|
3522
3532
|
if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return this.nullableIf(valueSchema, optional);
|
|
3523
|
-
return z
|
|
3533
|
+
return z.never();
|
|
3524
3534
|
}
|
|
3525
|
-
if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return z
|
|
3526
|
-
else return z
|
|
3535
|
+
if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return z.union([this.nullableIf(valueSchema, optional), z.strictObject(components)]);
|
|
3536
|
+
else return z.strictObject(components);
|
|
3527
3537
|
}
|
|
3528
3538
|
canCreateModel(model) {
|
|
3529
3539
|
const modelDef = requireModel(this.schema, model);
|
|
@@ -7131,9 +7141,9 @@ var ClientImpl = class ClientImpl {
|
|
|
7131
7141
|
validateOptions(baseClient, options) {
|
|
7132
7142
|
if (!baseClient && !options.skipValidationForComputedFields) this.validateComputedFieldsConfig(options);
|
|
7133
7143
|
if (options.diagnostics) {
|
|
7134
|
-
const parseResult = z.object({
|
|
7135
|
-
slowQueryThresholdMs: z.number().nonnegative().optional(),
|
|
7136
|
-
slowQueryMaxRecords: z.int().nonnegative().or(z.literal(Infinity)).optional()
|
|
7144
|
+
const parseResult = z$1.object({
|
|
7145
|
+
slowQueryThresholdMs: z$1.number().nonnegative().optional(),
|
|
7146
|
+
slowQueryMaxRecords: z$1.int().nonnegative().or(z$1.literal(Infinity)).optional()
|
|
7137
7147
|
}).safeParse(options.diagnostics);
|
|
7138
7148
|
if (!parseResult.success) throw createConfigError(`Invalid diagnostics configuration: ${formatError(parseResult.error)}`);
|
|
7139
7149
|
}
|