@zenstackhq/orm 3.10.1 → 3.10.2
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.d.mts +2 -2
- package/dist/index.mjs +199 -199
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -8
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { a as CoreCreateOperations, c as CoreReadOperations, d as DELEGATE_JOINE
|
|
|
3
3
|
import { AnyNull, AnyNullClass, DbNull, DbNullClass, JsonNull, JsonNullClass } from "./common-types.mjs";
|
|
4
4
|
import { clone, enumerate, invariant, isPlainObject, lowerCaseFirst, upperCaseFirst } from "@zenstackhq/common-helpers";
|
|
5
5
|
import { AliasNode, AndNode, ColumnNode, ColumnUpdateNode, CompiledQuery, DefaultConnectionProvider, DefaultQueryExecutor, DeleteQueryNode, ExpressionWrapper, FromNode, IdentifierNode, InsertQueryNode, Kysely, Log, OperationNodeTransformer, OperationNodeVisitor, PrimitiveValueListNode, RawNode, ReferenceNode, ReturningNode, SelectAllNode, SelectionNode, SingleConnectionProvider, TableNode, Transaction, UpdateQueryNode, ValueListNode, ValueNode, ValuesNode, WhereNode, createQueryId, expressionBuilder, sql } from "kysely";
|
|
6
|
-
import z, { ZodObject, ZodType, z
|
|
6
|
+
import z$1, { ZodObject, ZodType, z } from "zod";
|
|
7
7
|
import { fromError } from "zod-validation-error/v4";
|
|
8
8
|
import { P, match } from "ts-pattern";
|
|
9
9
|
import { ExpressionUtils } from "@zenstackhq/schema";
|
|
@@ -2424,7 +2424,7 @@ function haveSameSchemaInputs(a, b) {
|
|
|
2424
2424
|
* @see https://github.com/zenstackhq/zenstack/issues/2631
|
|
2425
2425
|
*/
|
|
2426
2426
|
function coercedDateTimeSchema() {
|
|
2427
|
-
return z
|
|
2427
|
+
return z.preprocess((val) => {
|
|
2428
2428
|
if (typeof val !== "string") return val;
|
|
2429
2429
|
if (/^\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d\d(?::\d\d)?)?$/.test(val)) {
|
|
2430
2430
|
const hasTz = val.endsWith("Z") || /[+-]\d\d(?::\d\d)?$/.test(val);
|
|
@@ -2433,10 +2433,10 @@ function coercedDateTimeSchema() {
|
|
|
2433
2433
|
}
|
|
2434
2434
|
const d = new Date(val);
|
|
2435
2435
|
return isNaN(d.getTime()) ? val : d;
|
|
2436
|
-
}, z
|
|
2437
|
-
z
|
|
2438
|
-
z
|
|
2439
|
-
z
|
|
2436
|
+
}, z.union([
|
|
2437
|
+
z.iso.datetime(),
|
|
2438
|
+
z.iso.date(),
|
|
2439
|
+
z.date()
|
|
2440
2440
|
]));
|
|
2441
2441
|
}
|
|
2442
2442
|
/**
|
|
@@ -2444,7 +2444,7 @@ function coercedDateTimeSchema() {
|
|
|
2444
2444
|
*/
|
|
2445
2445
|
var ZodSchemaFactory = class {
|
|
2446
2446
|
schemaCache = /* @__PURE__ */ new Map();
|
|
2447
|
-
schemaRegistry = z
|
|
2447
|
+
schemaRegistry = z.registry();
|
|
2448
2448
|
allFilterKinds = [...new Set(Object.values(FILTER_PROPERTY_TO_KIND))];
|
|
2449
2449
|
schema;
|
|
2450
2450
|
options;
|
|
@@ -2536,7 +2536,7 @@ var ZodSchemaFactory = class {
|
|
|
2536
2536
|
this.makeGroupBySchema(m);
|
|
2537
2537
|
}
|
|
2538
2538
|
for (const procName of Object.keys(this.schema.procedures ?? {})) if (this.isProcedureAllowed(procName)) this.makeProcedureArgsSchema(procName);
|
|
2539
|
-
return z
|
|
2539
|
+
return z.toJSONSchema(this.schemaRegistry, { unrepresentable: "any" });
|
|
2540
2540
|
}
|
|
2541
2541
|
get cacheStats() {
|
|
2542
2542
|
return {
|
|
@@ -2565,13 +2565,13 @@ var ZodSchemaFactory = class {
|
|
|
2565
2565
|
fields["omit"] = this.makeOmitSchema(model).optional().nullable();
|
|
2566
2566
|
if (!unique) {
|
|
2567
2567
|
fields["skip"] = this.makeSkipSchema().optional();
|
|
2568
|
-
if (findOne) fields["take"] = z
|
|
2568
|
+
if (findOne) fields["take"] = z.literal(1).optional();
|
|
2569
2569
|
else fields["take"] = this.makeTakeSchema().optional();
|
|
2570
2570
|
fields["orderBy"] = this.orArray(this.makeOrderBySchema(model, true, false, options), true).optional();
|
|
2571
2571
|
fields["cursor"] = this.makeCursorSchema(model, options).optional();
|
|
2572
2572
|
fields["distinct"] = this.makeDistinctSchema(model).optional();
|
|
2573
2573
|
}
|
|
2574
|
-
const baseSchema = z
|
|
2574
|
+
const baseSchema = z.strictObject(fields);
|
|
2575
2575
|
let result = this.mergePluginArgsSchema(baseSchema, operation);
|
|
2576
2576
|
result = this.refineForSelectIncludeMutuallyExclusive(result);
|
|
2577
2577
|
result = this.refineForSelectOmitMutuallyExclusive(result);
|
|
@@ -2581,7 +2581,7 @@ var ZodSchemaFactory = class {
|
|
|
2581
2581
|
return result;
|
|
2582
2582
|
}
|
|
2583
2583
|
makeExistsSchema(model, options) {
|
|
2584
|
-
const baseSchema = z
|
|
2584
|
+
const baseSchema = z.strictObject({ where: this.makeWhereSchema(model, false, false, false, options).optional() });
|
|
2585
2585
|
const result = this.mergePluginArgsSchema(baseSchema, "exists").optional();
|
|
2586
2586
|
this.registerSchema(`${model}ExistsArgs`, result);
|
|
2587
2587
|
return result;
|
|
@@ -2589,19 +2589,19 @@ var ZodSchemaFactory = class {
|
|
|
2589
2589
|
makeScalarSchema(type, attributes) {
|
|
2590
2590
|
if (this.schema.typeDefs && type in this.schema.typeDefs) return this.schema.typeDefs[type].base ? this.makeTypeDefSchema(type, attributes) : this.makeTypeDefSchema(type);
|
|
2591
2591
|
else if (this.schema.enums && type in this.schema.enums) return this.makeEnumSchema(type);
|
|
2592
|
-
else return match(type).with("String", () => this.extraValidationsEnabled ? ZodUtils.addStringValidation(z
|
|
2593
|
-
return z
|
|
2594
|
-
this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z
|
|
2595
|
-
ZodUtils.addDecimalValidation(z
|
|
2596
|
-
ZodUtils.addDecimalValidation(z
|
|
2592
|
+
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", () => {
|
|
2593
|
+
return z.union([
|
|
2594
|
+
this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z.number(), attributes) : z.number(),
|
|
2595
|
+
ZodUtils.addDecimalValidation(z.instanceof(Decimal), attributes, this.extraValidationsEnabled),
|
|
2596
|
+
ZodUtils.addDecimalValidation(z.string(), attributes, this.extraValidationsEnabled)
|
|
2597
2597
|
]);
|
|
2598
|
-
}).with("DateTime", () => this.makeDateTimeValueSchema()).with("Bytes", () => z
|
|
2598
|
+
}).with("DateTime", () => this.makeDateTimeValueSchema()).with("Bytes", () => z.instanceof(Uint8Array)).with("Json", () => this.makeJsonValueSchema()).otherwise(() => z.unknown());
|
|
2599
2599
|
}
|
|
2600
2600
|
isParameterizedComputedField(fieldDef) {
|
|
2601
2601
|
return !!(fieldDef.computed && fieldDef.params);
|
|
2602
2602
|
}
|
|
2603
2603
|
makeFieldArgsSchema(params) {
|
|
2604
|
-
return z
|
|
2604
|
+
return z.strictObject(Object.fromEntries(Object.entries(params).map(([name, param]) => {
|
|
2605
2605
|
let paramSchema = this.makeScalarSchema(param.type);
|
|
2606
2606
|
if (param.array) paramSchema = paramSchema.array();
|
|
2607
2607
|
if (param.optional) paramSchema = paramSchema.optional();
|
|
@@ -2609,9 +2609,9 @@ var ZodSchemaFactory = class {
|
|
|
2609
2609
|
})));
|
|
2610
2610
|
}
|
|
2611
2611
|
addComputedArgsToFilter(filterSchema, params) {
|
|
2612
|
-
const objectMembers = (filterSchema instanceof z
|
|
2612
|
+
const objectMembers = (filterSchema instanceof z.ZodUnion ? filterSchema.options : [filterSchema]).filter((m) => m instanceof z.ZodObject);
|
|
2613
2613
|
const components = Object.assign({}, ...objectMembers.map((o) => o.shape));
|
|
2614
|
-
return z
|
|
2614
|
+
return z.strictObject({
|
|
2615
2615
|
args: this.makeFieldArgsSchema(params),
|
|
2616
2616
|
...components
|
|
2617
2617
|
});
|
|
@@ -2619,7 +2619,7 @@ var ZodSchemaFactory = class {
|
|
|
2619
2619
|
makeEnumSchema(_enum) {
|
|
2620
2620
|
const enumDef = getEnum(this.schema, _enum);
|
|
2621
2621
|
invariant(enumDef, `Enum "${_enum}" not found in schema`);
|
|
2622
|
-
const schema = z
|
|
2622
|
+
const schema = z.enum(Object.keys(enumDef.values));
|
|
2623
2623
|
this.registerSchema(_enum, schema);
|
|
2624
2624
|
return schema;
|
|
2625
2625
|
}
|
|
@@ -2637,14 +2637,14 @@ var ZodSchemaFactory = class {
|
|
|
2637
2637
|
const schema = this.makeScalarSchema(typeDef.base, [...typeDef.fields["this"]?.attributes ?? [], ...fieldAttributes ?? []]);
|
|
2638
2638
|
return this.extraValidationsEnabled ? ZodUtils.addCustomValidation(schema, typeDef.attributes) : schema;
|
|
2639
2639
|
}
|
|
2640
|
-
const objectSchema = (typeDef.strict ? z
|
|
2641
|
-
let fieldSchema = isTypeDef(this.schema, def.type) && !isPrimitiveTypeDef(this.schema, def.type) ? z
|
|
2640
|
+
const objectSchema = (typeDef.strict ? z.strictObject : z.looseObject)(Object.fromEntries(Object.entries(typeDef.fields).map(([field, def]) => {
|
|
2641
|
+
let fieldSchema = isTypeDef(this.schema, def.type) && !isPrimitiveTypeDef(this.schema, def.type) ? z.lazy(() => this.makeTypeDefSchema(def.type)) : this.makeScalarSchema(def.type, this.getItemAttributes(def));
|
|
2642
2642
|
if (def.array) fieldSchema = ZodUtils.addListValidation(fieldSchema.array(), def.attributes);
|
|
2643
2643
|
if (def.optional) fieldSchema = fieldSchema.nullish();
|
|
2644
2644
|
return [field, fieldSchema];
|
|
2645
2645
|
})));
|
|
2646
2646
|
const schema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(objectSchema, typeDef.attributes) : objectSchema;
|
|
2647
|
-
const finalSchema = z
|
|
2647
|
+
const finalSchema = z.any().superRefine((value, ctx) => {
|
|
2648
2648
|
const parseResult = schema.safeParse(value);
|
|
2649
2649
|
if (!parseResult.success) parseResult.error.issues.forEach((issue) => ctx.addIssue(issue));
|
|
2650
2650
|
});
|
|
@@ -2660,17 +2660,17 @@ var ZodSchemaFactory = class {
|
|
|
2660
2660
|
if (fieldDef.relation) {
|
|
2661
2661
|
if (withoutRelationFields || !this.shouldIncludeRelations(options)) continue;
|
|
2662
2662
|
const allowedFilterKinds = this.getEffectiveFilterKinds(model, field);
|
|
2663
|
-
if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) fieldSchema = z
|
|
2663
|
+
if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) fieldSchema = z.never();
|
|
2664
2664
|
else {
|
|
2665
|
-
fieldSchema = z
|
|
2666
|
-
if (fieldDef.array) fieldSchema = z
|
|
2665
|
+
fieldSchema = z.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts).optional());
|
|
2666
|
+
if (fieldDef.array) fieldSchema = z.strictObject({
|
|
2667
2667
|
some: fieldSchema.optional(),
|
|
2668
2668
|
every: fieldSchema.optional(),
|
|
2669
2669
|
none: fieldSchema.optional()
|
|
2670
2670
|
});
|
|
2671
2671
|
else {
|
|
2672
2672
|
fieldSchema = this.nullableIf(fieldSchema, !fieldDef.array && !!fieldDef.optional);
|
|
2673
|
-
fieldSchema = z
|
|
2673
|
+
fieldSchema = z.union([fieldSchema, z.strictObject({
|
|
2674
2674
|
is: fieldSchema.optional(),
|
|
2675
2675
|
isNot: fieldSchema.optional()
|
|
2676
2676
|
})]);
|
|
@@ -2690,21 +2690,21 @@ var ZodSchemaFactory = class {
|
|
|
2690
2690
|
}
|
|
2691
2691
|
if (unique) {
|
|
2692
2692
|
const uniqueFields = getUniqueFields(this.schema, model);
|
|
2693
|
-
for (const uniqueField of uniqueFields) if ("defs" in uniqueField) fields[uniqueField.name] = z
|
|
2693
|
+
for (const uniqueField of uniqueFields) if ("defs" in uniqueField) fields[uniqueField.name] = z.object(Object.fromEntries(Object.entries(uniqueField.defs).map(([key, def]) => {
|
|
2694
2694
|
invariant(!def.relation, "unique field cannot be a relation");
|
|
2695
2695
|
let fieldSchema;
|
|
2696
2696
|
const enumDef = getEnum(this.schema, def.type);
|
|
2697
2697
|
if (enumDef) if (Object.keys(enumDef.values).length > 0) fieldSchema = this.makeEnumFilterSchema(def.type, !!def.optional, !!def.array, false, void 0);
|
|
2698
|
-
else fieldSchema = z
|
|
2698
|
+
else fieldSchema = z.never();
|
|
2699
2699
|
else fieldSchema = this.makePrimitiveFilterSchema(def.type, !!def.optional, false, void 0);
|
|
2700
2700
|
return [key, fieldSchema];
|
|
2701
2701
|
}))).optional();
|
|
2702
2702
|
}
|
|
2703
|
-
fields["$expr"] = z
|
|
2704
|
-
fields["AND"] = this.orArray(z
|
|
2705
|
-
fields["OR"] = z
|
|
2706
|
-
fields["NOT"] = this.orArray(z
|
|
2707
|
-
const baseWhere = z
|
|
2703
|
+
fields["$expr"] = z.custom((v) => typeof v === "function", { error: "\"$expr\" must be a function" }).optional();
|
|
2704
|
+
fields["AND"] = this.orArray(z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
|
|
2705
|
+
fields["OR"] = z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)).array().optional();
|
|
2706
|
+
fields["NOT"] = this.orArray(z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
|
|
2707
|
+
const baseWhere = z.strictObject(fields);
|
|
2708
2708
|
let result = baseWhere;
|
|
2709
2709
|
if (unique) {
|
|
2710
2710
|
const uniqueFields = getUniqueFields(this.schema, model);
|
|
@@ -2730,26 +2730,26 @@ var ZodSchemaFactory = class {
|
|
|
2730
2730
|
else if (getEnum(this.schema, fieldDef.type)) fieldSchemas[fieldName] = this.makeEnumFilterSchema(fieldDef.type, !!fieldDef.optional, !!fieldDef.array, false, void 0).optional();
|
|
2731
2731
|
else if (fieldDef.array) fieldSchemas[fieldName] = this.makeArrayFilterSchema(fieldDef.type, void 0).optional();
|
|
2732
2732
|
else fieldSchemas[fieldName] = this.makePrimitiveFilterSchema(this.getEffectiveFieldType(fieldDef.type), !!fieldDef.optional, false, void 0).optional();
|
|
2733
|
-
candidates.push(z
|
|
2733
|
+
candidates.push(z.strictObject(fieldSchemas));
|
|
2734
2734
|
}
|
|
2735
|
-
const recursiveSchema = z
|
|
2736
|
-
if (array) candidates.push(z
|
|
2735
|
+
const recursiveSchema = z.lazy(() => this.makeTypedJsonFilterSchema(type, optional, false, allowedFilterKinds)).optional();
|
|
2736
|
+
if (array) candidates.push(z.strictObject({
|
|
2737
2737
|
some: recursiveSchema,
|
|
2738
2738
|
every: recursiveSchema,
|
|
2739
2739
|
none: recursiveSchema
|
|
2740
2740
|
}));
|
|
2741
|
-
else candidates.push(z
|
|
2741
|
+
else candidates.push(z.strictObject({
|
|
2742
2742
|
is: recursiveSchema,
|
|
2743
2743
|
isNot: recursiveSchema
|
|
2744
2744
|
}));
|
|
2745
2745
|
candidates.push(this.makeJsonFilterSchema(optional, allowedFilterKinds));
|
|
2746
2746
|
if (optional) {
|
|
2747
|
-
candidates.push(z
|
|
2748
|
-
candidates.push(z
|
|
2749
|
-
candidates.push(z
|
|
2750
|
-
candidates.push(z
|
|
2747
|
+
candidates.push(z.null());
|
|
2748
|
+
candidates.push(z.instanceof(DbNullClass));
|
|
2749
|
+
candidates.push(z.instanceof(JsonNullClass));
|
|
2750
|
+
candidates.push(z.instanceof(AnyNullClass));
|
|
2751
2751
|
}
|
|
2752
|
-
const result = z
|
|
2752
|
+
const result = z.union(candidates);
|
|
2753
2753
|
this.registerSchema(`${type}Filter${this.filterSchemaSuffix({
|
|
2754
2754
|
optional,
|
|
2755
2755
|
array,
|
|
@@ -2758,7 +2758,7 @@ var ZodSchemaFactory = class {
|
|
|
2758
2758
|
return result;
|
|
2759
2759
|
}
|
|
2760
2760
|
makeNullableTypedJsonMutationSchema(fieldSchema) {
|
|
2761
|
-
return z
|
|
2761
|
+
return z.any().superRefine((value, ctx) => {
|
|
2762
2762
|
if (value instanceof DbNullClass || value instanceof JsonNullClass || value === null || value === void 0) return;
|
|
2763
2763
|
const parseResult = fieldSchema.safeParse(value);
|
|
2764
2764
|
if (!parseResult.success) parseResult.error.issues.forEach((issue) => ctx.addIssue(issue));
|
|
@@ -2774,11 +2774,11 @@ var ZodSchemaFactory = class {
|
|
|
2774
2774
|
makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds) {
|
|
2775
2775
|
const enumDef = getEnum(this.schema, enumName);
|
|
2776
2776
|
invariant(enumDef, `Enum "${enumName}" not found in schema`);
|
|
2777
|
-
const baseSchema = z
|
|
2777
|
+
const baseSchema = z.enum(Object.keys(enumDef.values));
|
|
2778
2778
|
let schema;
|
|
2779
2779
|
if (array) schema = this.internalMakeArrayFilterSchema(baseSchema, allowedFilterKinds);
|
|
2780
2780
|
else {
|
|
2781
|
-
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z
|
|
2781
|
+
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z.lazy(() => this.makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds)), [
|
|
2782
2782
|
"equals",
|
|
2783
2783
|
"in",
|
|
2784
2784
|
"notIn",
|
|
@@ -2812,42 +2812,42 @@ var ZodSchemaFactory = class {
|
|
|
2812
2812
|
has: elementSchema.optional(),
|
|
2813
2813
|
hasEvery: elementSchema.array().optional(),
|
|
2814
2814
|
hasSome: elementSchema.array().optional(),
|
|
2815
|
-
isEmpty: z
|
|
2815
|
+
isEmpty: z.boolean().optional()
|
|
2816
2816
|
};
|
|
2817
2817
|
const filteredOperators = this.trimFilterOperators(operators, allowedFilterKinds);
|
|
2818
|
-
return z
|
|
2818
|
+
return z.strictObject(filteredOperators);
|
|
2819
2819
|
}
|
|
2820
2820
|
makePrimitiveFilterSchema(type, optional, withAggregations, allowedFilterKinds, withFuzzy = false, withFullText = false) {
|
|
2821
|
-
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
|
|
2821
|
+
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();
|
|
2822
2822
|
}
|
|
2823
2823
|
makeJsonValueSchema() {
|
|
2824
|
-
const schema = z
|
|
2825
|
-
z
|
|
2826
|
-
z
|
|
2827
|
-
z
|
|
2828
|
-
z
|
|
2829
|
-
z
|
|
2830
|
-
z
|
|
2824
|
+
const schema = z.union([
|
|
2825
|
+
z.string(),
|
|
2826
|
+
z.number(),
|
|
2827
|
+
z.boolean(),
|
|
2828
|
+
z.instanceof(JsonNullClass),
|
|
2829
|
+
z.lazy(() => z.union([this.makeJsonValueSchema(), z.null()]).array()),
|
|
2830
|
+
z.record(z.string(), z.lazy(() => z.union([this.makeJsonValueSchema(), z.null()])))
|
|
2831
2831
|
]);
|
|
2832
2832
|
this.registerSchema("JsonValue", schema);
|
|
2833
2833
|
return schema;
|
|
2834
2834
|
}
|
|
2835
2835
|
makeJsonFilterSchema(optional, allowedFilterKinds) {
|
|
2836
|
-
if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) return z
|
|
2836
|
+
if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) return z.never();
|
|
2837
2837
|
const filterMembers = [
|
|
2838
2838
|
this.makeJsonValueSchema(),
|
|
2839
|
-
z
|
|
2840
|
-
z
|
|
2839
|
+
z.instanceof(DbNullClass),
|
|
2840
|
+
z.instanceof(AnyNullClass)
|
|
2841
2841
|
];
|
|
2842
|
-
if (optional) filterMembers.push(z
|
|
2843
|
-
const filterValueSchema = z
|
|
2844
|
-
const schema = z
|
|
2845
|
-
path: z
|
|
2842
|
+
if (optional) filterMembers.push(z.null());
|
|
2843
|
+
const filterValueSchema = z.union(filterMembers);
|
|
2844
|
+
const schema = z.strictObject({
|
|
2845
|
+
path: z.string().optional(),
|
|
2846
2846
|
equals: filterValueSchema.optional(),
|
|
2847
2847
|
not: filterValueSchema.optional(),
|
|
2848
|
-
string_contains: z
|
|
2849
|
-
string_starts_with: z
|
|
2850
|
-
string_ends_with: z
|
|
2848
|
+
string_contains: z.string().optional(),
|
|
2849
|
+
string_starts_with: z.string().optional(),
|
|
2850
|
+
string_ends_with: z.string().optional(),
|
|
2851
2851
|
mode: this.makeStringModeSchema().optional(),
|
|
2852
2852
|
array_contains: filterValueSchema.optional(),
|
|
2853
2853
|
array_starts_with: filterValueSchema.optional(),
|
|
@@ -2866,7 +2866,7 @@ var ZodSchemaFactory = class {
|
|
|
2866
2866
|
}
|
|
2867
2867
|
makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
2868
2868
|
const filterValueSchema = this.makeDateTimeValueSchema();
|
|
2869
|
-
const schema = this.makeCommonPrimitiveFilterSchema(filterValueSchema, optional, () => z
|
|
2869
|
+
const schema = this.makeCommonPrimitiveFilterSchema(filterValueSchema, optional, () => z.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)), withAggregations ? [
|
|
2870
2870
|
"_count",
|
|
2871
2871
|
"_min",
|
|
2872
2872
|
"_max"
|
|
@@ -2879,12 +2879,12 @@ var ZodSchemaFactory = class {
|
|
|
2879
2879
|
return schema;
|
|
2880
2880
|
}
|
|
2881
2881
|
makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
2882
|
-
const components = this.makeCommonPrimitiveFilterComponents(z
|
|
2882
|
+
const components = this.makeCommonPrimitiveFilterComponents(z.boolean(), optional, () => z.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)), ["equals", "not"], withAggregations ? [
|
|
2883
2883
|
"_count",
|
|
2884
2884
|
"_min",
|
|
2885
2885
|
"_max"
|
|
2886
2886
|
] : void 0, allowedFilterKinds);
|
|
2887
|
-
const schema = this.createUnionFilterSchema(z
|
|
2887
|
+
const schema = this.createUnionFilterSchema(z.boolean(), optional, components, allowedFilterKinds);
|
|
2888
2888
|
this.registerSchema(`BooleanFilter${this.filterSchemaSuffix({
|
|
2889
2889
|
optional,
|
|
2890
2890
|
allowedFilterKinds,
|
|
@@ -2893,8 +2893,8 @@ var ZodSchemaFactory = class {
|
|
|
2893
2893
|
return schema;
|
|
2894
2894
|
}
|
|
2895
2895
|
makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
2896
|
-
const baseSchema = z
|
|
2897
|
-
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z
|
|
2896
|
+
const baseSchema = z.instanceof(Uint8Array);
|
|
2897
|
+
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z.instanceof(Uint8Array), [
|
|
2898
2898
|
"equals",
|
|
2899
2899
|
"in",
|
|
2900
2900
|
"notIn",
|
|
@@ -2942,7 +2942,7 @@ var ZodSchemaFactory = class {
|
|
|
2942
2942
|
return this.createUnionFilterSchema(baseSchema, optional, components, allowedFilterKinds);
|
|
2943
2943
|
}
|
|
2944
2944
|
makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds) {
|
|
2945
|
-
const schema = this.makeCommonPrimitiveFilterSchema(this.makeScalarSchema(type), optional, () => z
|
|
2945
|
+
const schema = this.makeCommonPrimitiveFilterSchema(this.makeScalarSchema(type), optional, () => z.lazy(() => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)), withAggregations ? [
|
|
2946
2946
|
"_count",
|
|
2947
2947
|
"_avg",
|
|
2948
2948
|
"_sum",
|
|
@@ -2957,15 +2957,15 @@ var ZodSchemaFactory = class {
|
|
|
2957
2957
|
return schema;
|
|
2958
2958
|
}
|
|
2959
2959
|
makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy = false, withFullText = false) {
|
|
2960
|
-
const baseComponents = this.makeCommonPrimitiveFilterComponents(z
|
|
2960
|
+
const baseComponents = this.makeCommonPrimitiveFilterComponents(z.string(), optional, () => z.lazy(() => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy, withFullText)), void 0, withAggregations ? [
|
|
2961
2961
|
"_count",
|
|
2962
2962
|
"_min",
|
|
2963
2963
|
"_max"
|
|
2964
2964
|
] : void 0, allowedFilterKinds);
|
|
2965
2965
|
const stringSpecificOperators = {
|
|
2966
|
-
startsWith: z
|
|
2967
|
-
endsWith: z
|
|
2968
|
-
contains: z
|
|
2966
|
+
startsWith: z.string().optional(),
|
|
2967
|
+
endsWith: z.string().optional(),
|
|
2968
|
+
contains: z.string().optional(),
|
|
2969
2969
|
...withFuzzy && this.providerSupportsFuzzySearch ? { fuzzy: this.makeFuzzyFilterSchema().optional() } : {},
|
|
2970
2970
|
...withFullText && this.providerSupportsFullTextSearch ? { fts: this.makeFullTextFilterSchema().optional() } : {},
|
|
2971
2971
|
...this.providerSupportsCaseSensitivity ? { mode: this.makeStringModeSchema().optional() } : {}
|
|
@@ -2975,7 +2975,7 @@ var ZodSchemaFactory = class {
|
|
|
2975
2975
|
...baseComponents,
|
|
2976
2976
|
...filteredStringOperators
|
|
2977
2977
|
};
|
|
2978
|
-
const schema = this.createUnionFilterSchema(z
|
|
2978
|
+
const schema = this.createUnionFilterSchema(z.string(), optional, allComponents, allowedFilterKinds);
|
|
2979
2979
|
const featureSuffix = `${withFuzzy ? "Fuzzy" : ""}${withFullText ? "FullText" : ""}`;
|
|
2980
2980
|
this.registerSchema(`StringFilter${this.filterSchemaSuffix({
|
|
2981
2981
|
optional,
|
|
@@ -2985,45 +2985,45 @@ var ZodSchemaFactory = class {
|
|
|
2985
2985
|
return schema;
|
|
2986
2986
|
}
|
|
2987
2987
|
makeStringModeSchema() {
|
|
2988
|
-
return z
|
|
2988
|
+
return z.union([z.literal("default"), z.literal("insensitive")]);
|
|
2989
2989
|
}
|
|
2990
2990
|
makeFuzzyFilterSchema() {
|
|
2991
|
-
return z
|
|
2992
|
-
search: z
|
|
2993
|
-
mode: z
|
|
2994
|
-
z
|
|
2995
|
-
z
|
|
2996
|
-
z
|
|
2991
|
+
return z.strictObject({
|
|
2992
|
+
search: z.string().min(1),
|
|
2993
|
+
mode: z.union([
|
|
2994
|
+
z.literal("simple"),
|
|
2995
|
+
z.literal("word"),
|
|
2996
|
+
z.literal("strictWord")
|
|
2997
2997
|
]).default("simple"),
|
|
2998
|
-
threshold: z
|
|
2999
|
-
unaccent: z
|
|
2998
|
+
threshold: z.number().min(0).max(1).optional(),
|
|
2999
|
+
unaccent: z.boolean().default(false)
|
|
3000
3000
|
});
|
|
3001
3001
|
}
|
|
3002
3002
|
makeFullTextFilterSchema() {
|
|
3003
|
-
return z
|
|
3004
|
-
search: z
|
|
3005
|
-
config: z
|
|
3003
|
+
return z.strictObject({
|
|
3004
|
+
search: z.string().min(1),
|
|
3005
|
+
config: z.string().min(1).optional()
|
|
3006
3006
|
});
|
|
3007
3007
|
}
|
|
3008
3008
|
makeSelectSchema(model, options) {
|
|
3009
3009
|
const fields = {};
|
|
3010
3010
|
for (const [field, fieldDef] of this.getModelFields(model)) {
|
|
3011
3011
|
if (this.isParameterizedComputedField(fieldDef)) {
|
|
3012
|
-
fields[field] = z
|
|
3012
|
+
fields[field] = z.strictObject({ args: this.makeFieldArgsSchema(fieldDef.params) }).optional();
|
|
3013
3013
|
continue;
|
|
3014
3014
|
}
|
|
3015
3015
|
if (fieldDef.relation) {
|
|
3016
3016
|
if (!this.shouldIncludeRelations(options)) continue;
|
|
3017
3017
|
if (this.isModelAllowed(fieldDef.type)) fields[field] = this.makeRelationSelectIncludeSchema(model, field, options).optional();
|
|
3018
|
-
} else if (this.options.allowQueryTimeOmitOverride === false && this.isFieldOmittedByConfig(model, field)) fields[field] = z
|
|
3019
|
-
else fields[field] = z
|
|
3018
|
+
} else if (this.options.allowQueryTimeOmitOverride === false && this.isFieldOmittedByConfig(model, field)) fields[field] = z.literal(false).optional();
|
|
3019
|
+
else fields[field] = z.boolean().optional();
|
|
3020
3020
|
}
|
|
3021
3021
|
if (this.shouldIncludeRelations(options)) {
|
|
3022
3022
|
const _countSchema = this.makeCountSelectionSchema(model, options);
|
|
3023
|
-
if (!(_countSchema instanceof z
|
|
3023
|
+
if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
|
|
3024
3024
|
}
|
|
3025
3025
|
this.addExtResultFields(model, fields);
|
|
3026
|
-
const result = z
|
|
3026
|
+
const result = z.strictObject(fields);
|
|
3027
3027
|
this.registerSchema(`${model}Select`, result);
|
|
3028
3028
|
return result;
|
|
3029
3029
|
}
|
|
@@ -3032,24 +3032,24 @@ var ZodSchemaFactory = class {
|
|
|
3032
3032
|
const toManyRelations = Object.values(modelDef.fields).filter((def) => def.relation && def.array);
|
|
3033
3033
|
if (toManyRelations.length > 0) {
|
|
3034
3034
|
const nextOpts = this.nextOptions(options);
|
|
3035
|
-
const schema = z
|
|
3035
|
+
const schema = z.union([z.literal(true), z.strictObject({ select: z.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
|
|
3036
3036
|
...acc,
|
|
3037
|
-
[fieldDef.name]: z
|
|
3037
|
+
[fieldDef.name]: z.union([z.boolean(), z.strictObject({ where: this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts) })]).optional()
|
|
3038
3038
|
}), {})) })]).optional();
|
|
3039
3039
|
this.registerSchema(`${model}CountSelection`, schema);
|
|
3040
3040
|
return schema;
|
|
3041
|
-
} else return z
|
|
3041
|
+
} else return z.never();
|
|
3042
3042
|
}
|
|
3043
3043
|
makeRelationSelectIncludeSchema(model, field, options) {
|
|
3044
3044
|
const fieldDef = requireField(this.schema, model, field);
|
|
3045
3045
|
const nextOpts = this.nextOptions(options);
|
|
3046
|
-
let objSchema = z
|
|
3047
|
-
...fieldDef.array || fieldDef.optional ? { where: z
|
|
3048
|
-
select: z
|
|
3049
|
-
include: z
|
|
3050
|
-
omit: z
|
|
3046
|
+
let objSchema = z.strictObject({
|
|
3047
|
+
...fieldDef.array || fieldDef.optional ? { where: z.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts)).optional() } : {},
|
|
3048
|
+
select: z.lazy(() => this.makeSelectSchema(fieldDef.type, nextOpts)).optional().nullable(),
|
|
3049
|
+
include: z.lazy(() => this.makeIncludeSchema(fieldDef.type, nextOpts)).optional().nullable(),
|
|
3050
|
+
omit: z.lazy(() => this.makeOmitSchema(fieldDef.type)).optional().nullable(),
|
|
3051
3051
|
...fieldDef.array ? {
|
|
3052
|
-
orderBy: z
|
|
3052
|
+
orderBy: z.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false, nextOpts), true)).optional(),
|
|
3053
3053
|
skip: this.makeSkipSchema().optional(),
|
|
3054
3054
|
take: this.makeTakeSchema().optional(),
|
|
3055
3055
|
cursor: this.makeCursorSchema(fieldDef.type, nextOpts).optional(),
|
|
@@ -3059,7 +3059,7 @@ var ZodSchemaFactory = class {
|
|
|
3059
3059
|
objSchema = this.refineForSelectIncludeMutuallyExclusive(objSchema);
|
|
3060
3060
|
objSchema = this.refineForSelectOmitMutuallyExclusive(objSchema);
|
|
3061
3061
|
objSchema = this.refineForSelectHasTruthyField(objSchema);
|
|
3062
|
-
const result = z
|
|
3062
|
+
const result = z.union([z.boolean(), objSchema]);
|
|
3063
3063
|
this.registerSchema(`${model}${upperCaseFirst(field)}RelationInput`, result);
|
|
3064
3064
|
return result;
|
|
3065
3065
|
}
|
|
@@ -3076,11 +3076,11 @@ var ZodSchemaFactory = class {
|
|
|
3076
3076
|
const fields = {};
|
|
3077
3077
|
for (const [field, fieldDef] of this.getModelFields(model)) {
|
|
3078
3078
|
if (this.isParameterizedComputedField(fieldDef)) continue;
|
|
3079
|
-
if (!fieldDef.relation) if (this.options.allowQueryTimeOmitOverride !== false) fields[field] = z
|
|
3080
|
-
else fields[field] = z
|
|
3079
|
+
if (!fieldDef.relation) if (this.options.allowQueryTimeOmitOverride !== false) fields[field] = z.boolean().optional();
|
|
3080
|
+
else fields[field] = z.literal(true).optional();
|
|
3081
3081
|
}
|
|
3082
3082
|
this.addExtResultFields(model, fields);
|
|
3083
|
-
const result = z
|
|
3083
|
+
const result = z.strictObject(fields);
|
|
3084
3084
|
this.registerSchema(`${model}OmitInput`, result);
|
|
3085
3085
|
return result;
|
|
3086
3086
|
}
|
|
@@ -3089,7 +3089,7 @@ var ZodSchemaFactory = class {
|
|
|
3089
3089
|
const resultConfig = plugin.result;
|
|
3090
3090
|
if (resultConfig) {
|
|
3091
3091
|
const modelConfig = resultConfig[lowerCaseFirst(model)];
|
|
3092
|
-
if (modelConfig) for (const field of Object.keys(modelConfig)) fields[field] = z
|
|
3092
|
+
if (modelConfig) for (const field of Object.keys(modelConfig)) fields[field] = z.boolean().optional();
|
|
3093
3093
|
}
|
|
3094
3094
|
}
|
|
3095
3095
|
}
|
|
@@ -3101,35 +3101,35 @@ var ZodSchemaFactory = class {
|
|
|
3101
3101
|
if (fieldDef.relation) {
|
|
3102
3102
|
if (!this.shouldIncludeRelations(options)) continue;
|
|
3103
3103
|
if (this.isModelAllowed(fieldDef.type)) fields[field] = this.makeRelationSelectIncludeSchema(model, field, options).optional();
|
|
3104
|
-
} else if (this.isParameterizedComputedField(fieldDef)) fields[field] = z
|
|
3104
|
+
} else if (this.isParameterizedComputedField(fieldDef)) fields[field] = z.strictObject({ args: this.makeFieldArgsSchema(fieldDef.params) }).optional();
|
|
3105
3105
|
}
|
|
3106
3106
|
if (this.shouldIncludeRelations(options)) {
|
|
3107
3107
|
const _countSchema = this.makeCountSelectionSchema(model, options);
|
|
3108
|
-
if (!(_countSchema instanceof z
|
|
3108
|
+
if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
|
|
3109
3109
|
}
|
|
3110
|
-
const result = z
|
|
3110
|
+
const result = z.strictObject(fields);
|
|
3111
3111
|
this.registerSchema(`${model}Include`, result);
|
|
3112
3112
|
return result;
|
|
3113
3113
|
}
|
|
3114
3114
|
makeOrderBySchema(model, withRelation, WithAggregation, options) {
|
|
3115
3115
|
const fields = {};
|
|
3116
|
-
const sort = z
|
|
3116
|
+
const sort = z.union([z.literal("asc"), z.literal("desc")]);
|
|
3117
3117
|
const refineAtMostOneKey = (s) => s.refine((v) => Object.keys(v).length <= 1, { message: "Each orderBy element must have at most one key" });
|
|
3118
3118
|
const nextOpts = this.nextOptions(options);
|
|
3119
3119
|
for (const [field, fieldDef] of this.getModelFields(model)) if (fieldDef.relation) {
|
|
3120
|
-
if (withRelation && this.shouldIncludeRelations(options)) fields[field] = z
|
|
3120
|
+
if (withRelation && this.shouldIncludeRelations(options)) fields[field] = z.lazy(() => {
|
|
3121
3121
|
let relationOrderBy = this.makeOrderBySchema(fieldDef.type, withRelation, WithAggregation, nextOpts);
|
|
3122
3122
|
if (fieldDef.array) relationOrderBy = refineAtMostOneKey(relationOrderBy.safeExtend({ _count: sort }));
|
|
3123
3123
|
return relationOrderBy;
|
|
3124
3124
|
}).optional();
|
|
3125
|
-
} else if (fieldDef.computed && fieldDef.params) fields[field] = z
|
|
3125
|
+
} else if (fieldDef.computed && fieldDef.params) fields[field] = z.strictObject({
|
|
3126
3126
|
args: this.makeFieldArgsSchema(fieldDef.params),
|
|
3127
3127
|
sort,
|
|
3128
|
-
nulls: z
|
|
3128
|
+
nulls: z.union([z.literal("first"), z.literal("last")]).optional()
|
|
3129
3129
|
}).optional();
|
|
3130
|
-
else if (fieldDef.optional) fields[field] = z
|
|
3130
|
+
else if (fieldDef.optional) fields[field] = z.union([sort, z.strictObject({
|
|
3131
3131
|
sort,
|
|
3132
|
-
nulls: z
|
|
3132
|
+
nulls: z.union([z.literal("first"), z.literal("last")]).optional()
|
|
3133
3133
|
})]).optional();
|
|
3134
3134
|
else fields[field] = sort.optional();
|
|
3135
3135
|
if (WithAggregation) for (const agg of [
|
|
@@ -3138,31 +3138,31 @@ var ZodSchemaFactory = class {
|
|
|
3138
3138
|
"_sum",
|
|
3139
3139
|
"_min",
|
|
3140
3140
|
"_max"
|
|
3141
|
-
]) fields[agg] = z
|
|
3141
|
+
]) fields[agg] = z.lazy(() => this.makeOrderBySchema(model, true, false, options).optional());
|
|
3142
3142
|
if (this.providerSupportsFuzzySearch) {
|
|
3143
3143
|
const fuzzyFieldNames = this.getModelFields(model).filter(([, def]) => !def.relation && def.type === "String" && def.fuzzy === true).map(([name]) => name);
|
|
3144
|
-
if (fuzzyFieldNames.length > 0) fields["_fuzzyRelevance"] = z
|
|
3145
|
-
fields: z
|
|
3146
|
-
search: z
|
|
3147
|
-
mode: z
|
|
3148
|
-
z
|
|
3149
|
-
z
|
|
3150
|
-
z
|
|
3144
|
+
if (fuzzyFieldNames.length > 0) fields["_fuzzyRelevance"] = z.strictObject({
|
|
3145
|
+
fields: z.array(z.enum(fuzzyFieldNames)).min(1),
|
|
3146
|
+
search: z.string(),
|
|
3147
|
+
mode: z.union([
|
|
3148
|
+
z.literal("simple"),
|
|
3149
|
+
z.literal("word"),
|
|
3150
|
+
z.literal("strictWord")
|
|
3151
3151
|
]).default("simple"),
|
|
3152
|
-
unaccent: z
|
|
3152
|
+
unaccent: z.boolean().default(false),
|
|
3153
3153
|
sort
|
|
3154
3154
|
}).optional();
|
|
3155
3155
|
}
|
|
3156
3156
|
if (this.providerSupportsFullTextSearch) {
|
|
3157
3157
|
const fullTextFieldNames = this.getModelFields(model).filter(([, def]) => !def.relation && def.type === "String" && def.fullText === true).map(([name]) => name);
|
|
3158
|
-
if (fullTextFieldNames.length > 0) fields["_ftsRelevance"] = z
|
|
3159
|
-
fields: z
|
|
3160
|
-
search: z
|
|
3161
|
-
config: z
|
|
3158
|
+
if (fullTextFieldNames.length > 0) fields["_ftsRelevance"] = z.strictObject({
|
|
3159
|
+
fields: z.array(z.enum(fullTextFieldNames)).min(1),
|
|
3160
|
+
search: z.string().min(1),
|
|
3161
|
+
config: z.string().min(1).optional(),
|
|
3162
3162
|
sort
|
|
3163
3163
|
}).optional();
|
|
3164
3164
|
}
|
|
3165
|
-
const schema = refineAtMostOneKey(z
|
|
3165
|
+
const schema = refineAtMostOneKey(z.strictObject(fields));
|
|
3166
3166
|
let schemaId = `${model}OrderBy`;
|
|
3167
3167
|
if (withRelation) schemaId += "WithRelation";
|
|
3168
3168
|
if (WithAggregation) schemaId += "WithAggregation";
|
|
@@ -3172,7 +3172,7 @@ var ZodSchemaFactory = class {
|
|
|
3172
3172
|
}
|
|
3173
3173
|
makeDistinctSchema(model) {
|
|
3174
3174
|
const nonRelationFields = this.getModelFields(model).filter(([, def]) => !def.relation && !this.isParameterizedComputedField(def)).map(([name]) => name);
|
|
3175
|
-
const schema = nonRelationFields.length > 0 ? this.orArray(z
|
|
3175
|
+
const schema = nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields), true) : z.never();
|
|
3176
3176
|
this.registerSchema(`${model}DistinctInput`, schema);
|
|
3177
3177
|
return schema;
|
|
3178
3178
|
}
|
|
@@ -3183,7 +3183,7 @@ var ZodSchemaFactory = class {
|
|
|
3183
3183
|
}
|
|
3184
3184
|
makeCreateSchema(model, options) {
|
|
3185
3185
|
const dataSchema = this.makeCreateDataSchema(model, false, [], false, options);
|
|
3186
|
-
const baseSchema = z
|
|
3186
|
+
const baseSchema = z.strictObject({
|
|
3187
3187
|
data: dataSchema,
|
|
3188
3188
|
select: this.makeSelectSchema(model, options).optional().nullable(),
|
|
3189
3189
|
include: this.makeIncludeSchema(model, options).optional().nullable(),
|
|
@@ -3232,7 +3232,7 @@ var ZodSchemaFactory = class {
|
|
|
3232
3232
|
const oppositeFieldDef = requireField(this.schema, fieldDef.type, oppositeField);
|
|
3233
3233
|
if (oppositeFieldDef.relation?.fields) excludeFields.push(...oppositeFieldDef.relation.fields);
|
|
3234
3234
|
}
|
|
3235
|
-
let fieldSchema = z
|
|
3235
|
+
let fieldSchema = z.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "create", nextOpts));
|
|
3236
3236
|
if (fieldDef.optional || fieldDef.array) fieldSchema = fieldSchema.optional();
|
|
3237
3237
|
else {
|
|
3238
3238
|
let allFksOptional = false;
|
|
@@ -3249,23 +3249,23 @@ var ZodSchemaFactory = class {
|
|
|
3249
3249
|
let fieldSchema = this.makeScalarSchema(fieldDef.type, this.getItemAttributes(fieldDef));
|
|
3250
3250
|
if (fieldDef.array) {
|
|
3251
3251
|
fieldSchema = ZodUtils.addListValidation(fieldSchema.array(), fieldDef.attributes);
|
|
3252
|
-
fieldSchema = z
|
|
3252
|
+
fieldSchema = z.union([fieldSchema, z.strictObject({ set: fieldSchema })]).optional();
|
|
3253
3253
|
}
|
|
3254
3254
|
if (fieldDef.optional || fieldHasDefaultValue(fieldDef)) fieldSchema = fieldSchema.optional();
|
|
3255
|
-
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z
|
|
3255
|
+
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z.union([fieldSchema, z.instanceof(DbNullClass)]);
|
|
3256
3256
|
else if (this.isTypeDefType(fieldDef.type)) fieldSchema = this.makeNullableTypedJsonMutationSchema(fieldSchema);
|
|
3257
3257
|
else fieldSchema = fieldSchema.nullable();
|
|
3258
3258
|
uncheckedVariantFields[field] = fieldSchema;
|
|
3259
3259
|
if (!fieldDef.foreignKeyFor) checkedVariantFields[field] = fieldSchema;
|
|
3260
3260
|
}
|
|
3261
3261
|
});
|
|
3262
|
-
const uncheckedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z
|
|
3263
|
-
const checkedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z
|
|
3264
|
-
const result = !hasRelation ? this.orArray(uncheckedCreateSchema, canBeArray) : z
|
|
3262
|
+
const uncheckedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(uncheckedVariantFields), modelDef.attributes) : z.strictObject(uncheckedVariantFields);
|
|
3263
|
+
const checkedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(checkedVariantFields), modelDef.attributes) : z.strictObject(checkedVariantFields);
|
|
3264
|
+
const result = !hasRelation ? this.orArray(uncheckedCreateSchema, canBeArray) : z.union([
|
|
3265
3265
|
uncheckedCreateSchema,
|
|
3266
3266
|
checkedCreateSchema,
|
|
3267
|
-
...canBeArray ? [z
|
|
3268
|
-
...canBeArray ? [z
|
|
3267
|
+
...canBeArray ? [z.array(uncheckedCreateSchema)] : [],
|
|
3268
|
+
...canBeArray ? [z.array(checkedCreateSchema)] : []
|
|
3269
3269
|
]);
|
|
3270
3270
|
const idParts = [`${model}CreateData`];
|
|
3271
3271
|
if (canBeArray) idParts.push("Array");
|
|
@@ -3290,17 +3290,17 @@ var ZodSchemaFactory = class {
|
|
|
3290
3290
|
fields["disconnect"] = this.makeDisconnectDataSchema(fieldType, array, options).optional();
|
|
3291
3291
|
fields["delete"] = this.makeDeleteRelationDataSchema(fieldType, array, true, options).optional();
|
|
3292
3292
|
}
|
|
3293
|
-
fields["update"] = array ? this.orArray(z
|
|
3293
|
+
fields["update"] = array ? this.orArray(z.strictObject({
|
|
3294
3294
|
where: this.makeWhereSchema(fieldType, true, false, false, options),
|
|
3295
3295
|
data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
3296
|
-
}), true).optional() : z
|
|
3296
|
+
}), true).optional() : z.union([z.strictObject({
|
|
3297
3297
|
where: this.makeWhereSchema(fieldType, false, false, false, options).optional(),
|
|
3298
3298
|
data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
3299
3299
|
}), this.makeUpdateDataSchema(fieldType, withoutFields, false, options)]).optional();
|
|
3300
3300
|
if (canCreateModel) {
|
|
3301
3301
|
let upsertWhere = this.makeWhereSchema(fieldType, true, false, false, options);
|
|
3302
3302
|
if (!fieldDef.array) upsertWhere = upsertWhere.optional();
|
|
3303
|
-
fields["upsert"] = this.orArray(z
|
|
3303
|
+
fields["upsert"] = this.orArray(z.strictObject({
|
|
3304
3304
|
where: upsertWhere,
|
|
3305
3305
|
create: this.makeCreateDataSchema(fieldType, false, withoutFields, false, options),
|
|
3306
3306
|
update: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
@@ -3308,14 +3308,14 @@ var ZodSchemaFactory = class {
|
|
|
3308
3308
|
}
|
|
3309
3309
|
if (array) {
|
|
3310
3310
|
fields["set"] = this.makeSetDataSchema(fieldType, true, options).optional();
|
|
3311
|
-
fields["updateMany"] = this.orArray(z
|
|
3311
|
+
fields["updateMany"] = this.orArray(z.strictObject({
|
|
3312
3312
|
where: this.makeWhereSchema(fieldType, false, true, false, options),
|
|
3313
3313
|
data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
3314
3314
|
}), true).optional();
|
|
3315
3315
|
fields["deleteMany"] = this.makeDeleteRelationDataSchema(fieldType, true, false, options).optional();
|
|
3316
3316
|
}
|
|
3317
3317
|
}
|
|
3318
|
-
return z
|
|
3318
|
+
return z.strictObject(fields);
|
|
3319
3319
|
}
|
|
3320
3320
|
makeSetDataSchema(model, canBeArray, options) {
|
|
3321
3321
|
return this.orArray(this.makeWhereSchema(model, true, false, false, options), canBeArray);
|
|
@@ -3325,23 +3325,23 @@ var ZodSchemaFactory = class {
|
|
|
3325
3325
|
}
|
|
3326
3326
|
makeDisconnectDataSchema(model, canBeArray, options) {
|
|
3327
3327
|
if (canBeArray) return this.orArray(this.makeWhereSchema(model, true, false, false, options), canBeArray);
|
|
3328
|
-
else return z
|
|
3328
|
+
else return z.union([z.boolean(), this.makeWhereSchema(model, false, false, false, options)]);
|
|
3329
3329
|
}
|
|
3330
3330
|
makeDeleteRelationDataSchema(model, toManyRelation, uniqueFilter, options) {
|
|
3331
|
-
return toManyRelation ? this.orArray(this.makeWhereSchema(model, uniqueFilter, false, false, options), true) : z
|
|
3331
|
+
return toManyRelation ? this.orArray(this.makeWhereSchema(model, uniqueFilter, false, false, options), true) : z.union([z.boolean(), this.makeWhereSchema(model, uniqueFilter, false, false, options)]);
|
|
3332
3332
|
}
|
|
3333
3333
|
makeConnectOrCreateDataSchema(model, canBeArray, withoutFields, options) {
|
|
3334
3334
|
const whereSchema = this.makeWhereSchema(model, true, false, false, options);
|
|
3335
3335
|
const createSchema = this.makeCreateDataSchema(model, false, withoutFields, false, options);
|
|
3336
|
-
return this.orArray(z
|
|
3336
|
+
return this.orArray(z.strictObject({
|
|
3337
3337
|
where: whereSchema,
|
|
3338
3338
|
create: createSchema
|
|
3339
3339
|
}), canBeArray);
|
|
3340
3340
|
}
|
|
3341
3341
|
makeCreateManyPayloadSchema(model, withoutFields, options) {
|
|
3342
|
-
const schema = z
|
|
3342
|
+
const schema = z.strictObject({
|
|
3343
3343
|
data: this.makeCreateDataSchema(model, true, withoutFields, true, options),
|
|
3344
|
-
skipDuplicates: z
|
|
3344
|
+
skipDuplicates: z.boolean().optional()
|
|
3345
3345
|
});
|
|
3346
3346
|
const idParts = [`${model}CreateManyPayload`];
|
|
3347
3347
|
if (withoutFields.length) idParts.push(`Without${withoutFields.slice().sort().join("")}`);
|
|
@@ -3349,7 +3349,7 @@ var ZodSchemaFactory = class {
|
|
|
3349
3349
|
return schema;
|
|
3350
3350
|
}
|
|
3351
3351
|
makeUpdateSchema(model, options) {
|
|
3352
|
-
const baseSchema = z
|
|
3352
|
+
const baseSchema = z.strictObject({
|
|
3353
3353
|
where: this.makeWhereSchema(model, true, false, false, options),
|
|
3354
3354
|
data: this.makeUpdateDataSchema(model, [], false, options),
|
|
3355
3355
|
select: this.makeSelectSchema(model, options).optional().nullable(),
|
|
@@ -3364,10 +3364,10 @@ var ZodSchemaFactory = class {
|
|
|
3364
3364
|
return schema;
|
|
3365
3365
|
}
|
|
3366
3366
|
makeUpdateManySchema(model, options) {
|
|
3367
|
-
const result = this.mergePluginArgsSchema(z
|
|
3367
|
+
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3368
3368
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3369
3369
|
data: this.makeUpdateDataSchema(model, [], true, options),
|
|
3370
|
-
limit: z
|
|
3370
|
+
limit: z.number().int().nonnegative().optional()
|
|
3371
3371
|
}), "updateMany");
|
|
3372
3372
|
this.registerSchema(`${model}UpdateManyArgs`, result);
|
|
3373
3373
|
return result;
|
|
@@ -3383,7 +3383,7 @@ var ZodSchemaFactory = class {
|
|
|
3383
3383
|
return schema;
|
|
3384
3384
|
}
|
|
3385
3385
|
makeUpsertSchema(model, options) {
|
|
3386
|
-
const baseSchema = z
|
|
3386
|
+
const baseSchema = z.strictObject({
|
|
3387
3387
|
where: this.makeWhereSchema(model, true, false, false, options),
|
|
3388
3388
|
create: this.makeCreateDataSchema(model, false, [], false, options),
|
|
3389
3389
|
update: this.makeUpdateDataSchema(model, [], false, options),
|
|
@@ -3419,27 +3419,27 @@ var ZodSchemaFactory = class {
|
|
|
3419
3419
|
const oppositeFieldDef = requireField(this.schema, fieldDef.type, oppositeField);
|
|
3420
3420
|
if (oppositeFieldDef.relation?.fields) excludeFields.push(...oppositeFieldDef.relation.fields);
|
|
3421
3421
|
}
|
|
3422
|
-
let fieldSchema = z
|
|
3422
|
+
let fieldSchema = z.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "update", nextOpts)).optional();
|
|
3423
3423
|
if (fieldDef.optional && !fieldDef.array) fieldSchema = fieldSchema.nullable();
|
|
3424
3424
|
checkedVariantFields[field] = fieldSchema;
|
|
3425
3425
|
if (fieldDef.array || !fieldDef.relation.references) uncheckedVariantFields[field] = fieldSchema;
|
|
3426
3426
|
} else {
|
|
3427
3427
|
let fieldSchema = this.makeScalarSchema(fieldDef.type, this.getItemAttributes(fieldDef));
|
|
3428
|
-
if (this.isNumericField(fieldDef)) fieldSchema = z
|
|
3429
|
-
set: this.nullableIf(z
|
|
3430
|
-
increment: z
|
|
3431
|
-
decrement: z
|
|
3432
|
-
multiply: z
|
|
3433
|
-
divide: z
|
|
3428
|
+
if (this.isNumericField(fieldDef)) fieldSchema = z.union([fieldSchema, z.object({
|
|
3429
|
+
set: this.nullableIf(z.number().optional(), !!fieldDef.optional).optional(),
|
|
3430
|
+
increment: z.number().optional(),
|
|
3431
|
+
decrement: z.number().optional(),
|
|
3432
|
+
multiply: z.number().optional(),
|
|
3433
|
+
divide: z.number().optional()
|
|
3434
3434
|
}).refine((v) => Object.keys(v).length === 1, "Only one of \"set\", \"increment\", \"decrement\", \"multiply\", or \"divide\" can be provided")]);
|
|
3435
3435
|
if (fieldDef.array) {
|
|
3436
3436
|
const arraySchema = ZodUtils.addListValidation(fieldSchema.array(), fieldDef.attributes);
|
|
3437
|
-
fieldSchema = z
|
|
3437
|
+
fieldSchema = z.union([arraySchema, z.object({
|
|
3438
3438
|
set: arraySchema.optional(),
|
|
3439
|
-
push: z
|
|
3439
|
+
push: z.union([fieldSchema, fieldSchema.array()]).optional()
|
|
3440
3440
|
}).refine((v) => Object.keys(v).length === 1, "Only one of \"set\", \"push\" can be provided")]);
|
|
3441
3441
|
}
|
|
3442
|
-
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z
|
|
3442
|
+
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z.union([fieldSchema, z.instanceof(DbNullClass)]);
|
|
3443
3443
|
else if (this.isTypeDefType(fieldDef.type)) fieldSchema = this.makeNullableTypedJsonMutationSchema(fieldSchema);
|
|
3444
3444
|
else fieldSchema = fieldSchema.nullable();
|
|
3445
3445
|
fieldSchema = fieldSchema.optional();
|
|
@@ -3447,9 +3447,9 @@ var ZodSchemaFactory = class {
|
|
|
3447
3447
|
if (!fieldDef.foreignKeyFor) checkedVariantFields[field] = fieldSchema;
|
|
3448
3448
|
}
|
|
3449
3449
|
});
|
|
3450
|
-
const uncheckedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z
|
|
3451
|
-
const checkedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z
|
|
3452
|
-
const result = !hasRelation ? uncheckedUpdateSchema : z
|
|
3450
|
+
const uncheckedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(uncheckedVariantFields), modelDef.attributes) : z.strictObject(uncheckedVariantFields);
|
|
3451
|
+
const checkedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(checkedVariantFields), modelDef.attributes) : z.strictObject(checkedVariantFields);
|
|
3452
|
+
const result = !hasRelation ? uncheckedUpdateSchema : z.union([uncheckedUpdateSchema, checkedUpdateSchema]);
|
|
3453
3453
|
const idParts = [`${model}UpdateData`];
|
|
3454
3454
|
if (withoutRelationFields) idParts.push("WithoutRelation");
|
|
3455
3455
|
if (withoutFields.length) idParts.push(`Without${withoutFields.slice().sort().join("")}`);
|
|
@@ -3457,7 +3457,7 @@ var ZodSchemaFactory = class {
|
|
|
3457
3457
|
return result;
|
|
3458
3458
|
}
|
|
3459
3459
|
makeDeleteSchema(model, options) {
|
|
3460
|
-
const baseSchema = z
|
|
3460
|
+
const baseSchema = z.strictObject({
|
|
3461
3461
|
where: this.makeWhereSchema(model, true, false, false, options),
|
|
3462
3462
|
select: this.makeSelectSchema(model, options).optional().nullable(),
|
|
3463
3463
|
include: this.makeIncludeSchema(model, options).optional().nullable(),
|
|
@@ -3471,15 +3471,15 @@ var ZodSchemaFactory = class {
|
|
|
3471
3471
|
return schema;
|
|
3472
3472
|
}
|
|
3473
3473
|
makeDeleteManySchema(model, options) {
|
|
3474
|
-
const result = this.mergePluginArgsSchema(z
|
|
3474
|
+
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3475
3475
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3476
|
-
limit: z
|
|
3476
|
+
limit: z.number().int().nonnegative().optional()
|
|
3477
3477
|
}), "deleteMany").optional();
|
|
3478
3478
|
this.registerSchema(`${model}DeleteManyArgs`, result);
|
|
3479
3479
|
return result;
|
|
3480
3480
|
}
|
|
3481
3481
|
makeCountSchema(model, options) {
|
|
3482
|
-
const result = this.mergePluginArgsSchema(z
|
|
3482
|
+
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3483
3483
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3484
3484
|
skip: this.makeSkipSchema().optional(),
|
|
3485
3485
|
take: this.makeTakeSchema().optional(),
|
|
@@ -3490,10 +3490,10 @@ var ZodSchemaFactory = class {
|
|
|
3490
3490
|
return result;
|
|
3491
3491
|
}
|
|
3492
3492
|
makeCountAggregateInputSchema(model) {
|
|
3493
|
-
const schema = z
|
|
3494
|
-
_all: z
|
|
3493
|
+
const schema = z.union([z.literal(true), z.strictObject({
|
|
3494
|
+
_all: z.literal(true).optional(),
|
|
3495
3495
|
...this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
|
|
3496
|
-
acc[field] = this.isParameterizedComputedField(fieldDef) ? z
|
|
3496
|
+
acc[field] = this.isParameterizedComputedField(fieldDef) ? z.strictObject({ args: this.makeFieldArgsSchema(fieldDef.params) }).optional() : z.literal(true).optional();
|
|
3497
3497
|
return acc;
|
|
3498
3498
|
}, {})
|
|
3499
3499
|
})]);
|
|
@@ -3501,7 +3501,7 @@ var ZodSchemaFactory = class {
|
|
|
3501
3501
|
return schema;
|
|
3502
3502
|
}
|
|
3503
3503
|
makeAggregateSchema(model, options) {
|
|
3504
|
-
const result = this.mergePluginArgsSchema(z
|
|
3504
|
+
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3505
3505
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3506
3506
|
skip: this.makeSkipSchema().optional(),
|
|
3507
3507
|
take: this.makeTakeSchema().optional(),
|
|
@@ -3516,16 +3516,16 @@ var ZodSchemaFactory = class {
|
|
|
3516
3516
|
return result;
|
|
3517
3517
|
}
|
|
3518
3518
|
makeSumAvgInputSchema(model) {
|
|
3519
|
-
const schema = z
|
|
3520
|
-
if (this.isNumericField(fieldDef)) acc[field] = this.isParameterizedComputedField(fieldDef) ? z
|
|
3519
|
+
const schema = z.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
|
|
3520
|
+
if (this.isNumericField(fieldDef)) acc[field] = this.isParameterizedComputedField(fieldDef) ? z.strictObject({ args: this.makeFieldArgsSchema(fieldDef.params) }).optional() : z.literal(true).optional();
|
|
3521
3521
|
return acc;
|
|
3522
3522
|
}, {}));
|
|
3523
3523
|
this.registerSchema(`${model}SumAvgAggregateInput`, schema);
|
|
3524
3524
|
return schema;
|
|
3525
3525
|
}
|
|
3526
3526
|
makeMinMaxInputSchema(model) {
|
|
3527
|
-
const schema = z
|
|
3528
|
-
if (!fieldDef.relation && !fieldDef.array) acc[field] = this.isParameterizedComputedField(fieldDef) ? z
|
|
3527
|
+
const schema = z.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
|
|
3528
|
+
if (!fieldDef.relation && !fieldDef.array) acc[field] = this.isParameterizedComputedField(fieldDef) ? z.strictObject({ args: this.makeFieldArgsSchema(fieldDef.params) }).optional() : z.literal(true).optional();
|
|
3529
3529
|
return acc;
|
|
3530
3530
|
}, {}));
|
|
3531
3531
|
this.registerSchema(`${model}MinMaxAggregateInput`, schema);
|
|
@@ -3534,14 +3534,14 @@ var ZodSchemaFactory = class {
|
|
|
3534
3534
|
makeGroupBySchema(model, options) {
|
|
3535
3535
|
const nonRelationFields = this.getModelFields(model).filter(([, def]) => !def.relation && !this.isParameterizedComputedField(def)).map(([name]) => name);
|
|
3536
3536
|
const byMembers = [];
|
|
3537
|
-
if (nonRelationFields.length > 0) byMembers.push(z
|
|
3538
|
-
for (const [field, fieldDef] of this.getModelFields(model)) if (this.isParameterizedComputedField(fieldDef)) byMembers.push(z
|
|
3539
|
-
field: z
|
|
3537
|
+
if (nonRelationFields.length > 0) byMembers.push(z.enum(nonRelationFields));
|
|
3538
|
+
for (const [field, fieldDef] of this.getModelFields(model)) if (this.isParameterizedComputedField(fieldDef)) byMembers.push(z.strictObject({
|
|
3539
|
+
field: z.literal(field),
|
|
3540
3540
|
args: this.makeFieldArgsSchema(fieldDef.params)
|
|
3541
3541
|
}));
|
|
3542
|
-
const byElement = byMembers.length === 0 ? void 0 : byMembers.length === 1 ? byMembers[0] : z
|
|
3543
|
-
const bySchema = byElement ? this.orArray(byElement, true) : z
|
|
3544
|
-
const baseSchema = z
|
|
3542
|
+
const byElement = byMembers.length === 0 ? void 0 : byMembers.length === 1 ? byMembers[0] : z.union(byMembers);
|
|
3543
|
+
const bySchema = byElement ? this.orArray(byElement, true) : z.never();
|
|
3544
|
+
const baseSchema = z.strictObject({
|
|
3545
3545
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3546
3546
|
orderBy: this.orArray(this.makeOrderBySchema(model, false, true, options), true).optional(),
|
|
3547
3547
|
by: bySchema,
|
|
@@ -3593,7 +3593,7 @@ var ZodSchemaFactory = class {
|
|
|
3593
3593
|
if (!procDef) throw createInternalError(`Procedure not found: ${procName}`);
|
|
3594
3594
|
const shape = {};
|
|
3595
3595
|
for (const param of Object.values(procDef.params ?? {})) shape[param.name] = this.makeProcedureParamSchema(param);
|
|
3596
|
-
const schema = z
|
|
3596
|
+
const schema = z.object(shape);
|
|
3597
3597
|
this.registerSchema(`${procName}ProcArgs`, schema);
|
|
3598
3598
|
return schema;
|
|
3599
3599
|
}
|
|
@@ -3601,10 +3601,10 @@ var ZodSchemaFactory = class {
|
|
|
3601
3601
|
let schema;
|
|
3602
3602
|
if (isTypeDef(this.schema, param.type)) schema = this.makeTypeDefSchema(param.type);
|
|
3603
3603
|
else if (isEnum(this.schema, param.type)) schema = this.makeEnumSchema(param.type);
|
|
3604
|
-
else if (param.type in (this.schema.models ?? {})) schema = z
|
|
3604
|
+
else if (param.type in (this.schema.models ?? {})) schema = z.record(z.string(), z.unknown());
|
|
3605
3605
|
else {
|
|
3606
3606
|
schema = this.makeScalarSchema(param.type);
|
|
3607
|
-
if (schema instanceof z
|
|
3607
|
+
if (schema instanceof z.ZodUnknown) throw createInternalError(`Unsupported procedure parameter type: ${param.type}`);
|
|
3608
3608
|
}
|
|
3609
3609
|
if (param.array) schema = schema.array();
|
|
3610
3610
|
if (param.optional) schema = schema.optional();
|
|
@@ -3640,10 +3640,10 @@ var ZodSchemaFactory = class {
|
|
|
3640
3640
|
return result;
|
|
3641
3641
|
}
|
|
3642
3642
|
makeSkipSchema() {
|
|
3643
|
-
return z
|
|
3643
|
+
return z.number().int().nonnegative();
|
|
3644
3644
|
}
|
|
3645
3645
|
makeTakeSchema() {
|
|
3646
|
-
return z
|
|
3646
|
+
return z.number().int();
|
|
3647
3647
|
}
|
|
3648
3648
|
refineForSelectIncludeMutuallyExclusive(schema) {
|
|
3649
3649
|
return schema.refine((value) => !(value["select"] && value["include"]), "\"select\" and \"include\" cannot be used together");
|
|
@@ -3662,7 +3662,7 @@ var ZodSchemaFactory = class {
|
|
|
3662
3662
|
return nullable ? schema.nullable() : schema;
|
|
3663
3663
|
}
|
|
3664
3664
|
orArray(schema, canBeArray) {
|
|
3665
|
-
return canBeArray ? z
|
|
3665
|
+
return canBeArray ? z.union([schema, z.array(schema)]) : schema;
|
|
3666
3666
|
}
|
|
3667
3667
|
isNumericField(fieldDef) {
|
|
3668
3668
|
return NUMERIC_FIELD_TYPES.includes(this.getEffectiveFieldType(fieldDef.type)) && !fieldDef.array;
|
|
@@ -3724,10 +3724,10 @@ var ZodSchemaFactory = class {
|
|
|
3724
3724
|
createUnionFilterSchema(valueSchema, optional, components, allowedFilterKinds) {
|
|
3725
3725
|
if (Object.keys(components).length === 0) {
|
|
3726
3726
|
if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return this.nullableIf(valueSchema, optional);
|
|
3727
|
-
return z
|
|
3727
|
+
return z.never();
|
|
3728
3728
|
}
|
|
3729
|
-
if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return z
|
|
3730
|
-
else return z
|
|
3729
|
+
if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return z.union([this.nullableIf(valueSchema, optional), z.strictObject(components)]);
|
|
3730
|
+
else return z.strictObject(components);
|
|
3731
3731
|
}
|
|
3732
3732
|
canCreateModel(model) {
|
|
3733
3733
|
const modelDef = requireModel(this.schema, model);
|
|
@@ -7560,9 +7560,9 @@ var ClientImpl = class ClientImpl {
|
|
|
7560
7560
|
validateOptions(baseClient, options) {
|
|
7561
7561
|
if (!baseClient && !options.skipValidationForComputedFields) this.validateComputedFieldsConfig(options);
|
|
7562
7562
|
if (options.diagnostics) {
|
|
7563
|
-
const parseResult = z.object({
|
|
7564
|
-
slowQueryThresholdMs: z.number().nonnegative().optional(),
|
|
7565
|
-
slowQueryMaxRecords: z.int().nonnegative().or(z.literal(Infinity)).optional()
|
|
7563
|
+
const parseResult = z$1.object({
|
|
7564
|
+
slowQueryThresholdMs: z$1.number().nonnegative().optional(),
|
|
7565
|
+
slowQueryMaxRecords: z$1.int().nonnegative().or(z$1.literal(Infinity)).optional()
|
|
7566
7566
|
}).safeParse(options.diagnostics);
|
|
7567
7567
|
if (!parseResult.success) throw createConfigError(`Invalid diagnostics configuration: ${formatError(parseResult.error)}`);
|
|
7568
7568
|
}
|