@coursebuilder/adapter-drizzle 0.0.5 → 0.0.6
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/{chunk-RMRO5TA7.js → chunk-22KIKVBY.js} +2 -2
- package/dist/{chunk-PUGK2AEH.js → chunk-4HDU7QIB.js} +3 -2
- package/dist/{chunk-JQFZOCAU.js → chunk-FRNVLW7N.js} +595 -288
- package/dist/{chunk-LLWSIKQV.js → chunk-GFUUJRX7.js} +1 -1
- package/dist/{chunk-NISOQSUL.js → chunk-PFN4YUQZ.js} +2 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +5 -5
- package/dist/lib/mysql/index.cjs +673 -365
- package/dist/lib/mysql/index.cjs.map +1 -1
- package/dist/lib/mysql/index.js +3 -3
- package/dist/lib/mysql/schemas/auth/accounts.cjs +2 -1
- package/dist/lib/mysql/schemas/auth/accounts.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/accounts.js +1 -1
- package/dist/lib/mysql/schemas/auth/permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/permissions.js +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/role-permissions.js +1 -1
- package/dist/lib/mysql/schemas/auth/roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/roles.js +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.cjs +2 -1
- package/dist/lib/mysql/schemas/auth/sessions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/sessions.js +2 -2
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs +2 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-permissions.js +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.cjs +2 -1
- package/dist/lib/mysql/schemas/auth/user-roles.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/user-roles.js +1 -1
- package/dist/lib/mysql/schemas/auth/users.cjs +2 -1
- package/dist/lib/mysql/schemas/auth/users.cjs.map +1 -1
- package/dist/lib/mysql/schemas/auth/users.js +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs +2 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.cjs.map +1 -1
- package/dist/lib/mysql/schemas/communication/communication-preferences.js +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.cjs +2 -1
- package/dist/lib/mysql/schemas/content/content-contributions.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-contributions.js +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource-resource.js +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.cjs +2 -1
- package/dist/lib/mysql/schemas/content/content-resource.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/content-resource.js +1 -1
- package/dist/lib/mysql/schemas/content/contribution-types.cjs.map +1 -1
- package/dist/lib/mysql/schemas/content/contribution-types.js +1 -1
- package/dist/lib/sqlite.cjs.map +1 -1
- package/dist/lib/sqlite.d.ts +44 -45
- package/dist/lib/sqlite.js +2 -2
- package/dist/lib/utils.cjs.map +1 -1
- package/dist/lib/utils.d.ts +0 -2
- package/dist/lib/utils.js +1 -1
- package/package.json +9 -5
- package/src/index.ts +1 -1
- package/src/lib/mysql/index.ts +43 -35
- package/src/lib/mysql/schemas/auth/accounts.ts +1 -1
- package/src/lib/mysql/schemas/auth/permissions.ts +1 -1
- package/src/lib/mysql/schemas/auth/role-permissions.ts +2 -2
- package/src/lib/mysql/schemas/auth/roles.ts +1 -1
- package/src/lib/mysql/schemas/auth/sessions.ts +1 -1
- package/src/lib/mysql/schemas/auth/user-permissions.ts +2 -2
- package/src/lib/mysql/schemas/auth/user-roles.ts +2 -2
- package/src/lib/mysql/schemas/auth/users.ts +7 -6
- package/src/lib/mysql/schemas/communication/communication-preferences.ts +3 -3
- package/src/lib/mysql/schemas/content/content-contributions.ts +3 -3
- package/src/lib/mysql/schemas/content/content-resource-resource.ts +1 -1
- package/src/lib/mysql/schemas/content/content-resource.ts +3 -3
- package/src/lib/mysql/schemas/content/contribution-types.ts +1 -1
- package/src/lib/utils.ts +1 -1
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
import {
|
|
35
35
|
getSessionRelationsSchema,
|
|
36
36
|
getSessionsSchema
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-PFN4YUQZ.js";
|
|
38
38
|
import {
|
|
39
39
|
getVerificationTokensSchema
|
|
40
40
|
} from "./chunk-TMQIGK3N.js";
|
|
@@ -69,7 +69,7 @@ import {
|
|
|
69
69
|
getUserRolesSchema,
|
|
70
70
|
getUsersRelationsSchema,
|
|
71
71
|
getUsersSchema
|
|
72
|
-
} from "./chunk-
|
|
72
|
+
} from "./chunk-4HDU7QIB.js";
|
|
73
73
|
import {
|
|
74
74
|
getCommunicationChannelSchema
|
|
75
75
|
} from "./chunk-6CBAFOL3.js";
|
|
@@ -85,18 +85,27 @@ import { addSeconds, isAfter } from "date-fns";
|
|
|
85
85
|
import { and, eq, sql } from "drizzle-orm";
|
|
86
86
|
import { mysqlTable as defaultMySqlTableFn } from "drizzle-orm/mysql-core";
|
|
87
87
|
|
|
88
|
-
//
|
|
88
|
+
// ../core/dist/chunk-DFHEFTJZ.js
|
|
89
|
+
var __defProp = Object.defineProperty;
|
|
90
|
+
var __name2 = /* @__PURE__ */ __name((target, value) => __defProp(target, "name", {
|
|
91
|
+
value,
|
|
92
|
+
configurable: true
|
|
93
|
+
}), "__name");
|
|
94
|
+
|
|
95
|
+
// ../core/dist/chunk-EK2ZQYRJ.js
|
|
89
96
|
var util;
|
|
90
97
|
(function(util2) {
|
|
91
98
|
util2.assertEqual = (val) => val;
|
|
92
99
|
function assertIs(_arg) {
|
|
93
100
|
}
|
|
94
101
|
__name(assertIs, "assertIs");
|
|
102
|
+
__name2(assertIs, "assertIs");
|
|
95
103
|
util2.assertIs = assertIs;
|
|
96
104
|
function assertNever(_x) {
|
|
97
105
|
throw new Error();
|
|
98
106
|
}
|
|
99
107
|
__name(assertNever, "assertNever");
|
|
108
|
+
__name2(assertNever, "assertNever");
|
|
100
109
|
util2.assertNever = assertNever;
|
|
101
110
|
util2.arrayToEnum = (items) => {
|
|
102
111
|
const obj = {};
|
|
@@ -139,6 +148,7 @@ var util;
|
|
|
139
148
|
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
140
149
|
}
|
|
141
150
|
__name(joinValues, "joinValues");
|
|
151
|
+
__name2(joinValues, "joinValues");
|
|
142
152
|
util2.joinValues = joinValues;
|
|
143
153
|
util2.jsonStringifyReplacer = (_, value) => {
|
|
144
154
|
if (typeof value === "bigint") {
|
|
@@ -153,7 +163,6 @@ var objectUtil;
|
|
|
153
163
|
return {
|
|
154
164
|
...first,
|
|
155
165
|
...second
|
|
156
|
-
// second overwrites first
|
|
157
166
|
};
|
|
158
167
|
};
|
|
159
168
|
})(objectUtil || (objectUtil = {}));
|
|
@@ -179,7 +188,7 @@ var ZodParsedType = util.arrayToEnum([
|
|
|
179
188
|
"map",
|
|
180
189
|
"set"
|
|
181
190
|
]);
|
|
182
|
-
var getParsedType = /* @__PURE__ */
|
|
191
|
+
var getParsedType = /* @__PURE__ */ __name2((data) => {
|
|
183
192
|
const t = typeof data;
|
|
184
193
|
switch (t) {
|
|
185
194
|
case "undefined":
|
|
@@ -238,19 +247,25 @@ var ZodIssueCode = util.arrayToEnum([
|
|
|
238
247
|
"not_multiple_of",
|
|
239
248
|
"not_finite"
|
|
240
249
|
]);
|
|
241
|
-
var quotelessJson = /* @__PURE__ */
|
|
250
|
+
var quotelessJson = /* @__PURE__ */ __name2((obj) => {
|
|
242
251
|
const json = JSON.stringify(obj, null, 2);
|
|
243
252
|
return json.replace(/"([^"]+)":/g, "$1:");
|
|
244
253
|
}, "quotelessJson");
|
|
245
|
-
var ZodError = class extends Error {
|
|
254
|
+
var ZodError = /* @__PURE__ */ __name(class extends Error {
|
|
246
255
|
constructor(issues) {
|
|
247
256
|
super();
|
|
248
257
|
this.issues = [];
|
|
249
258
|
this.addIssue = (sub) => {
|
|
250
|
-
this.issues = [
|
|
259
|
+
this.issues = [
|
|
260
|
+
...this.issues,
|
|
261
|
+
sub
|
|
262
|
+
];
|
|
251
263
|
};
|
|
252
264
|
this.addIssues = (subs = []) => {
|
|
253
|
-
this.issues = [
|
|
265
|
+
this.issues = [
|
|
266
|
+
...this.issues,
|
|
267
|
+
...subs
|
|
268
|
+
];
|
|
254
269
|
};
|
|
255
270
|
const actualProto = new.target.prototype;
|
|
256
271
|
if (Object.setPrototypeOf) {
|
|
@@ -268,8 +283,10 @@ var ZodError = class extends Error {
|
|
|
268
283
|
const mapper = _mapper || function(issue) {
|
|
269
284
|
return issue.message;
|
|
270
285
|
};
|
|
271
|
-
const fieldErrors = {
|
|
272
|
-
|
|
286
|
+
const fieldErrors = {
|
|
287
|
+
_errors: []
|
|
288
|
+
};
|
|
289
|
+
const processError = /* @__PURE__ */ __name2((error) => {
|
|
273
290
|
for (const issue of error.issues) {
|
|
274
291
|
if (issue.code === "invalid_union") {
|
|
275
292
|
issue.unionErrors.map(processError);
|
|
@@ -286,9 +303,13 @@ var ZodError = class extends Error {
|
|
|
286
303
|
const el = issue.path[i];
|
|
287
304
|
const terminal = i === issue.path.length - 1;
|
|
288
305
|
if (!terminal) {
|
|
289
|
-
curr[el] = curr[el] || {
|
|
306
|
+
curr[el] = curr[el] || {
|
|
307
|
+
_errors: []
|
|
308
|
+
};
|
|
290
309
|
} else {
|
|
291
|
-
curr[el] = curr[el] || {
|
|
310
|
+
curr[el] = curr[el] || {
|
|
311
|
+
_errors: []
|
|
312
|
+
};
|
|
292
313
|
curr[el]._errors.push(mapper(issue));
|
|
293
314
|
}
|
|
294
315
|
curr = curr[el];
|
|
@@ -320,18 +341,21 @@ var ZodError = class extends Error {
|
|
|
320
341
|
formErrors.push(mapper(sub));
|
|
321
342
|
}
|
|
322
343
|
}
|
|
323
|
-
return {
|
|
344
|
+
return {
|
|
345
|
+
formErrors,
|
|
346
|
+
fieldErrors
|
|
347
|
+
};
|
|
324
348
|
}
|
|
325
349
|
get formErrors() {
|
|
326
350
|
return this.flatten();
|
|
327
351
|
}
|
|
328
|
-
};
|
|
329
|
-
|
|
352
|
+
}, "ZodError");
|
|
353
|
+
__name2(ZodError, "ZodError");
|
|
330
354
|
ZodError.create = (issues) => {
|
|
331
355
|
const error = new ZodError(issues);
|
|
332
356
|
return error;
|
|
333
357
|
};
|
|
334
|
-
var errorMap = /* @__PURE__ */
|
|
358
|
+
var errorMap = /* @__PURE__ */ __name2((issue, _ctx) => {
|
|
335
359
|
let message;
|
|
336
360
|
switch (issue.code) {
|
|
337
361
|
case ZodIssueCode.invalid_type:
|
|
@@ -427,20 +451,27 @@ var errorMap = /* @__PURE__ */ __name((issue, _ctx) => {
|
|
|
427
451
|
message = _ctx.defaultError;
|
|
428
452
|
util.assertNever(issue);
|
|
429
453
|
}
|
|
430
|
-
return {
|
|
454
|
+
return {
|
|
455
|
+
message
|
|
456
|
+
};
|
|
431
457
|
}, "errorMap");
|
|
432
458
|
var overrideErrorMap = errorMap;
|
|
433
459
|
function setErrorMap(map) {
|
|
434
460
|
overrideErrorMap = map;
|
|
435
461
|
}
|
|
436
462
|
__name(setErrorMap, "setErrorMap");
|
|
463
|
+
__name2(setErrorMap, "setErrorMap");
|
|
437
464
|
function getErrorMap() {
|
|
438
465
|
return overrideErrorMap;
|
|
439
466
|
}
|
|
440
467
|
__name(getErrorMap, "getErrorMap");
|
|
441
|
-
|
|
468
|
+
__name2(getErrorMap, "getErrorMap");
|
|
469
|
+
var makeIssue = /* @__PURE__ */ __name2((params) => {
|
|
442
470
|
const { data, path, errorMaps, issueData } = params;
|
|
443
|
-
const fullPath = [
|
|
471
|
+
const fullPath = [
|
|
472
|
+
...path,
|
|
473
|
+
...issueData.path || []
|
|
474
|
+
];
|
|
444
475
|
const fullIssue = {
|
|
445
476
|
...issueData,
|
|
446
477
|
path: fullPath
|
|
@@ -448,7 +479,10 @@ var makeIssue = /* @__PURE__ */ __name((params) => {
|
|
|
448
479
|
let errorMessage = "";
|
|
449
480
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
450
481
|
for (const map of maps) {
|
|
451
|
-
errorMessage = map(fullIssue, {
|
|
482
|
+
errorMessage = map(fullIssue, {
|
|
483
|
+
data,
|
|
484
|
+
defaultError: errorMessage
|
|
485
|
+
}).message;
|
|
452
486
|
}
|
|
453
487
|
return {
|
|
454
488
|
...issueData,
|
|
@@ -467,13 +501,13 @@ function addIssueToContext(ctx, issueData) {
|
|
|
467
501
|
ctx.schemaErrorMap,
|
|
468
502
|
getErrorMap(),
|
|
469
503
|
errorMap
|
|
470
|
-
// then global default map
|
|
471
504
|
].filter((x) => !!x)
|
|
472
505
|
});
|
|
473
506
|
ctx.common.issues.push(issue);
|
|
474
507
|
}
|
|
475
508
|
__name(addIssueToContext, "addIssueToContext");
|
|
476
|
-
|
|
509
|
+
__name2(addIssueToContext, "addIssueToContext");
|
|
510
|
+
var ParseStatus = /* @__PURE__ */ __name(class {
|
|
477
511
|
constructor() {
|
|
478
512
|
this.value = "valid";
|
|
479
513
|
}
|
|
@@ -494,7 +528,10 @@ var ParseStatus = class {
|
|
|
494
528
|
status.dirty();
|
|
495
529
|
arrayValue.push(s.value);
|
|
496
530
|
}
|
|
497
|
-
return {
|
|
531
|
+
return {
|
|
532
|
+
status: status.value,
|
|
533
|
+
value: arrayValue
|
|
534
|
+
};
|
|
498
535
|
}
|
|
499
536
|
static async mergeObjectAsync(status, pairs) {
|
|
500
537
|
const syncPairs = [];
|
|
@@ -522,25 +559,36 @@ var ParseStatus = class {
|
|
|
522
559
|
finalObject[key.value] = value.value;
|
|
523
560
|
}
|
|
524
561
|
}
|
|
525
|
-
return {
|
|
562
|
+
return {
|
|
563
|
+
status: status.value,
|
|
564
|
+
value: finalObject
|
|
565
|
+
};
|
|
526
566
|
}
|
|
527
|
-
};
|
|
528
|
-
|
|
567
|
+
}, "ParseStatus");
|
|
568
|
+
__name2(ParseStatus, "ParseStatus");
|
|
529
569
|
var INVALID = Object.freeze({
|
|
530
570
|
status: "aborted"
|
|
531
571
|
});
|
|
532
|
-
var DIRTY = /* @__PURE__ */
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
var
|
|
537
|
-
|
|
572
|
+
var DIRTY = /* @__PURE__ */ __name2((value) => ({
|
|
573
|
+
status: "dirty",
|
|
574
|
+
value
|
|
575
|
+
}), "DIRTY");
|
|
576
|
+
var OK = /* @__PURE__ */ __name2((value) => ({
|
|
577
|
+
status: "valid",
|
|
578
|
+
value
|
|
579
|
+
}), "OK");
|
|
580
|
+
var isAborted = /* @__PURE__ */ __name2((x) => x.status === "aborted", "isAborted");
|
|
581
|
+
var isDirty = /* @__PURE__ */ __name2((x) => x.status === "dirty", "isDirty");
|
|
582
|
+
var isValid = /* @__PURE__ */ __name2((x) => x.status === "valid", "isValid");
|
|
583
|
+
var isAsync = /* @__PURE__ */ __name2((x) => typeof Promise !== "undefined" && x instanceof Promise, "isAsync");
|
|
538
584
|
var errorUtil;
|
|
539
585
|
(function(errorUtil2) {
|
|
540
|
-
errorUtil2.errToObj = (message) => typeof message === "string" ? {
|
|
586
|
+
errorUtil2.errToObj = (message) => typeof message === "string" ? {
|
|
587
|
+
message
|
|
588
|
+
} : message || {};
|
|
541
589
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
542
590
|
})(errorUtil || (errorUtil = {}));
|
|
543
|
-
var ParseInputLazyPath = class {
|
|
591
|
+
var ParseInputLazyPath = /* @__PURE__ */ __name(class {
|
|
544
592
|
constructor(parent, value, path, key) {
|
|
545
593
|
this._cachedPath = [];
|
|
546
594
|
this.parent = parent;
|
|
@@ -558,11 +606,14 @@ var ParseInputLazyPath = class {
|
|
|
558
606
|
}
|
|
559
607
|
return this._cachedPath;
|
|
560
608
|
}
|
|
561
|
-
};
|
|
562
|
-
|
|
563
|
-
var handleResult = /* @__PURE__ */
|
|
609
|
+
}, "ParseInputLazyPath");
|
|
610
|
+
__name2(ParseInputLazyPath, "ParseInputLazyPath");
|
|
611
|
+
var handleResult = /* @__PURE__ */ __name2((ctx, result) => {
|
|
564
612
|
if (isValid(result)) {
|
|
565
|
-
return {
|
|
613
|
+
return {
|
|
614
|
+
success: true,
|
|
615
|
+
data: result.value
|
|
616
|
+
};
|
|
566
617
|
} else {
|
|
567
618
|
if (!ctx.common.issues.length) {
|
|
568
619
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -587,19 +638,32 @@ function processCreateParams(params) {
|
|
|
587
638
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
588
639
|
}
|
|
589
640
|
if (errorMap2)
|
|
590
|
-
return {
|
|
591
|
-
|
|
641
|
+
return {
|
|
642
|
+
errorMap: errorMap2,
|
|
643
|
+
description
|
|
644
|
+
};
|
|
645
|
+
const customMap = /* @__PURE__ */ __name2((iss, ctx) => {
|
|
592
646
|
if (iss.code !== "invalid_type")
|
|
593
|
-
return {
|
|
647
|
+
return {
|
|
648
|
+
message: ctx.defaultError
|
|
649
|
+
};
|
|
594
650
|
if (typeof ctx.data === "undefined") {
|
|
595
|
-
return {
|
|
651
|
+
return {
|
|
652
|
+
message: required_error !== null && required_error !== void 0 ? required_error : ctx.defaultError
|
|
653
|
+
};
|
|
596
654
|
}
|
|
597
|
-
return {
|
|
655
|
+
return {
|
|
656
|
+
message: invalid_type_error !== null && invalid_type_error !== void 0 ? invalid_type_error : ctx.defaultError
|
|
657
|
+
};
|
|
598
658
|
}, "customMap");
|
|
599
|
-
return {
|
|
659
|
+
return {
|
|
660
|
+
errorMap: customMap,
|
|
661
|
+
description
|
|
662
|
+
};
|
|
600
663
|
}
|
|
601
664
|
__name(processCreateParams, "processCreateParams");
|
|
602
|
-
|
|
665
|
+
__name2(processCreateParams, "processCreateParams");
|
|
666
|
+
var ZodType = /* @__PURE__ */ __name(class {
|
|
603
667
|
constructor(def) {
|
|
604
668
|
this.spa = this.safeParseAsync;
|
|
605
669
|
this._def = def;
|
|
@@ -688,7 +752,11 @@ var ZodType = class {
|
|
|
688
752
|
data,
|
|
689
753
|
parsedType: getParsedType(data)
|
|
690
754
|
};
|
|
691
|
-
const result = this._parseSync({
|
|
755
|
+
const result = this._parseSync({
|
|
756
|
+
data,
|
|
757
|
+
path: ctx.path,
|
|
758
|
+
parent: ctx
|
|
759
|
+
});
|
|
692
760
|
return handleResult(ctx, result);
|
|
693
761
|
}
|
|
694
762
|
async parseAsync(data, params) {
|
|
@@ -710,14 +778,20 @@ var ZodType = class {
|
|
|
710
778
|
data,
|
|
711
779
|
parsedType: getParsedType(data)
|
|
712
780
|
};
|
|
713
|
-
const maybeAsyncResult = this._parse({
|
|
781
|
+
const maybeAsyncResult = this._parse({
|
|
782
|
+
data,
|
|
783
|
+
path: ctx.path,
|
|
784
|
+
parent: ctx
|
|
785
|
+
});
|
|
714
786
|
const result = await (isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
|
|
715
787
|
return handleResult(ctx, result);
|
|
716
788
|
}
|
|
717
789
|
refine(check, message) {
|
|
718
|
-
const getIssueProperties = /* @__PURE__ */
|
|
790
|
+
const getIssueProperties = /* @__PURE__ */ __name2((val) => {
|
|
719
791
|
if (typeof message === "string" || typeof message === "undefined") {
|
|
720
|
-
return {
|
|
792
|
+
return {
|
|
793
|
+
message
|
|
794
|
+
};
|
|
721
795
|
} else if (typeof message === "function") {
|
|
722
796
|
return message(val);
|
|
723
797
|
} else {
|
|
@@ -726,7 +800,7 @@ var ZodType = class {
|
|
|
726
800
|
}, "getIssueProperties");
|
|
727
801
|
return this._refinement((val, ctx) => {
|
|
728
802
|
const result = check(val);
|
|
729
|
-
const setError = /* @__PURE__ */
|
|
803
|
+
const setError = /* @__PURE__ */ __name2(() => ctx.addIssue({
|
|
730
804
|
code: ZodIssueCode.custom,
|
|
731
805
|
...getIssueProperties(val)
|
|
732
806
|
}), "setError");
|
|
@@ -762,7 +836,10 @@ var ZodType = class {
|
|
|
762
836
|
return new ZodEffects({
|
|
763
837
|
schema: this,
|
|
764
838
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
765
|
-
effect: {
|
|
839
|
+
effect: {
|
|
840
|
+
type: "refinement",
|
|
841
|
+
refinement
|
|
842
|
+
}
|
|
766
843
|
});
|
|
767
844
|
}
|
|
768
845
|
superRefine(refinement) {
|
|
@@ -784,7 +861,10 @@ var ZodType = class {
|
|
|
784
861
|
return ZodPromise.create(this, this._def);
|
|
785
862
|
}
|
|
786
863
|
or(option) {
|
|
787
|
-
return ZodUnion.create([
|
|
864
|
+
return ZodUnion.create([
|
|
865
|
+
this,
|
|
866
|
+
option
|
|
867
|
+
], this._def);
|
|
788
868
|
}
|
|
789
869
|
and(incoming) {
|
|
790
870
|
return ZodIntersection.create(this, incoming, this._def);
|
|
@@ -794,7 +874,10 @@ var ZodType = class {
|
|
|
794
874
|
...processCreateParams(this._def),
|
|
795
875
|
schema: this,
|
|
796
876
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
797
|
-
effect: {
|
|
877
|
+
effect: {
|
|
878
|
+
type: "transform",
|
|
879
|
+
transform
|
|
880
|
+
}
|
|
798
881
|
});
|
|
799
882
|
}
|
|
800
883
|
default(def) {
|
|
@@ -841,8 +924,8 @@ var ZodType = class {
|
|
|
841
924
|
isNullable() {
|
|
842
925
|
return this.safeParse(null).success;
|
|
843
926
|
}
|
|
844
|
-
};
|
|
845
|
-
|
|
927
|
+
}, "ZodType");
|
|
928
|
+
__name2(ZodType, "ZodType");
|
|
846
929
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
847
930
|
var cuid2Regex = /^[a-z][a-z0-9]*$/;
|
|
848
931
|
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
@@ -852,7 +935,7 @@ var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
|
852
935
|
var emojiRegex;
|
|
853
936
|
var ipv4Regex = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/;
|
|
854
937
|
var ipv6Regex = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/;
|
|
855
|
-
var datetimeRegex = /* @__PURE__ */
|
|
938
|
+
var datetimeRegex = /* @__PURE__ */ __name2((args) => {
|
|
856
939
|
if (args.precision) {
|
|
857
940
|
if (args.offset) {
|
|
858
941
|
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
@@ -883,7 +966,8 @@ function isValidIP(ip, version) {
|
|
|
883
966
|
return false;
|
|
884
967
|
}
|
|
885
968
|
__name(isValidIP, "isValidIP");
|
|
886
|
-
|
|
969
|
+
__name2(isValidIP, "isValidIP");
|
|
970
|
+
var ZodString = /* @__PURE__ */ __name(class extends ZodType {
|
|
887
971
|
_parse(input) {
|
|
888
972
|
if (this._def.coerce) {
|
|
889
973
|
input.data = String(input.data);
|
|
@@ -891,15 +975,11 @@ var ZodString = class extends ZodType {
|
|
|
891
975
|
const parsedType = this._getType(input);
|
|
892
976
|
if (parsedType !== ZodParsedType.string) {
|
|
893
977
|
const ctx2 = this._getOrReturnCtx(input);
|
|
894
|
-
addIssueToContext(
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
received: ctx2.parsedType
|
|
900
|
-
}
|
|
901
|
-
//
|
|
902
|
-
);
|
|
978
|
+
addIssueToContext(ctx2, {
|
|
979
|
+
code: ZodIssueCode.invalid_type,
|
|
980
|
+
expected: ZodParsedType.string,
|
|
981
|
+
received: ctx2.parsedType
|
|
982
|
+
});
|
|
903
983
|
return INVALID;
|
|
904
984
|
}
|
|
905
985
|
const status = new ParseStatus();
|
|
@@ -1051,7 +1131,10 @@ var ZodString = class extends ZodType {
|
|
|
1051
1131
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
1052
1132
|
addIssueToContext(ctx, {
|
|
1053
1133
|
code: ZodIssueCode.invalid_string,
|
|
1054
|
-
validation: {
|
|
1134
|
+
validation: {
|
|
1135
|
+
includes: check.value,
|
|
1136
|
+
position: check.position
|
|
1137
|
+
},
|
|
1055
1138
|
message: check.message
|
|
1056
1139
|
});
|
|
1057
1140
|
status.dirty();
|
|
@@ -1065,7 +1148,9 @@ var ZodString = class extends ZodType {
|
|
|
1065
1148
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
1066
1149
|
addIssueToContext(ctx, {
|
|
1067
1150
|
code: ZodIssueCode.invalid_string,
|
|
1068
|
-
validation: {
|
|
1151
|
+
validation: {
|
|
1152
|
+
startsWith: check.value
|
|
1153
|
+
},
|
|
1069
1154
|
message: check.message
|
|
1070
1155
|
});
|
|
1071
1156
|
status.dirty();
|
|
@@ -1075,7 +1160,9 @@ var ZodString = class extends ZodType {
|
|
|
1075
1160
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
1076
1161
|
addIssueToContext(ctx, {
|
|
1077
1162
|
code: ZodIssueCode.invalid_string,
|
|
1078
|
-
validation: {
|
|
1163
|
+
validation: {
|
|
1164
|
+
endsWith: check.value
|
|
1165
|
+
},
|
|
1079
1166
|
message: check.message
|
|
1080
1167
|
});
|
|
1081
1168
|
status.dirty();
|
|
@@ -1105,7 +1192,10 @@ var ZodString = class extends ZodType {
|
|
|
1105
1192
|
util.assertNever(check);
|
|
1106
1193
|
}
|
|
1107
1194
|
}
|
|
1108
|
-
return {
|
|
1195
|
+
return {
|
|
1196
|
+
status: status.value,
|
|
1197
|
+
value: input.data
|
|
1198
|
+
};
|
|
1109
1199
|
}
|
|
1110
1200
|
_regex(regex, validation, message) {
|
|
1111
1201
|
return this.refinement((data) => regex.test(data), {
|
|
@@ -1117,32 +1207,59 @@ var ZodString = class extends ZodType {
|
|
|
1117
1207
|
_addCheck(check) {
|
|
1118
1208
|
return new ZodString({
|
|
1119
1209
|
...this._def,
|
|
1120
|
-
checks: [
|
|
1210
|
+
checks: [
|
|
1211
|
+
...this._def.checks,
|
|
1212
|
+
check
|
|
1213
|
+
]
|
|
1121
1214
|
});
|
|
1122
1215
|
}
|
|
1123
1216
|
email(message) {
|
|
1124
|
-
return this._addCheck({
|
|
1217
|
+
return this._addCheck({
|
|
1218
|
+
kind: "email",
|
|
1219
|
+
...errorUtil.errToObj(message)
|
|
1220
|
+
});
|
|
1125
1221
|
}
|
|
1126
1222
|
url(message) {
|
|
1127
|
-
return this._addCheck({
|
|
1223
|
+
return this._addCheck({
|
|
1224
|
+
kind: "url",
|
|
1225
|
+
...errorUtil.errToObj(message)
|
|
1226
|
+
});
|
|
1128
1227
|
}
|
|
1129
1228
|
emoji(message) {
|
|
1130
|
-
return this._addCheck({
|
|
1229
|
+
return this._addCheck({
|
|
1230
|
+
kind: "emoji",
|
|
1231
|
+
...errorUtil.errToObj(message)
|
|
1232
|
+
});
|
|
1131
1233
|
}
|
|
1132
1234
|
uuid(message) {
|
|
1133
|
-
return this._addCheck({
|
|
1235
|
+
return this._addCheck({
|
|
1236
|
+
kind: "uuid",
|
|
1237
|
+
...errorUtil.errToObj(message)
|
|
1238
|
+
});
|
|
1134
1239
|
}
|
|
1135
1240
|
cuid(message) {
|
|
1136
|
-
return this._addCheck({
|
|
1241
|
+
return this._addCheck({
|
|
1242
|
+
kind: "cuid",
|
|
1243
|
+
...errorUtil.errToObj(message)
|
|
1244
|
+
});
|
|
1137
1245
|
}
|
|
1138
1246
|
cuid2(message) {
|
|
1139
|
-
return this._addCheck({
|
|
1247
|
+
return this._addCheck({
|
|
1248
|
+
kind: "cuid2",
|
|
1249
|
+
...errorUtil.errToObj(message)
|
|
1250
|
+
});
|
|
1140
1251
|
}
|
|
1141
1252
|
ulid(message) {
|
|
1142
|
-
return this._addCheck({
|
|
1253
|
+
return this._addCheck({
|
|
1254
|
+
kind: "ulid",
|
|
1255
|
+
...errorUtil.errToObj(message)
|
|
1256
|
+
});
|
|
1143
1257
|
}
|
|
1144
1258
|
ip(options) {
|
|
1145
|
-
return this._addCheck({
|
|
1259
|
+
return this._addCheck({
|
|
1260
|
+
kind: "ip",
|
|
1261
|
+
...errorUtil.errToObj(options)
|
|
1262
|
+
});
|
|
1146
1263
|
}
|
|
1147
1264
|
datetime(options) {
|
|
1148
1265
|
var _a;
|
|
@@ -1212,28 +1329,43 @@ var ZodString = class extends ZodType {
|
|
|
1212
1329
|
});
|
|
1213
1330
|
}
|
|
1214
1331
|
/**
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1332
|
+
* @deprecated Use z.string().min(1) instead.
|
|
1333
|
+
* @see {@link ZodString.min}
|
|
1334
|
+
*/
|
|
1218
1335
|
nonempty(message) {
|
|
1219
1336
|
return this.min(1, errorUtil.errToObj(message));
|
|
1220
1337
|
}
|
|
1221
1338
|
trim() {
|
|
1222
1339
|
return new ZodString({
|
|
1223
1340
|
...this._def,
|
|
1224
|
-
checks: [
|
|
1341
|
+
checks: [
|
|
1342
|
+
...this._def.checks,
|
|
1343
|
+
{
|
|
1344
|
+
kind: "trim"
|
|
1345
|
+
}
|
|
1346
|
+
]
|
|
1225
1347
|
});
|
|
1226
1348
|
}
|
|
1227
1349
|
toLowerCase() {
|
|
1228
1350
|
return new ZodString({
|
|
1229
1351
|
...this._def,
|
|
1230
|
-
checks: [
|
|
1352
|
+
checks: [
|
|
1353
|
+
...this._def.checks,
|
|
1354
|
+
{
|
|
1355
|
+
kind: "toLowerCase"
|
|
1356
|
+
}
|
|
1357
|
+
]
|
|
1231
1358
|
});
|
|
1232
1359
|
}
|
|
1233
1360
|
toUpperCase() {
|
|
1234
1361
|
return new ZodString({
|
|
1235
1362
|
...this._def,
|
|
1236
|
-
checks: [
|
|
1363
|
+
checks: [
|
|
1364
|
+
...this._def.checks,
|
|
1365
|
+
{
|
|
1366
|
+
kind: "toUpperCase"
|
|
1367
|
+
}
|
|
1368
|
+
]
|
|
1237
1369
|
});
|
|
1238
1370
|
}
|
|
1239
1371
|
get isDatetime() {
|
|
@@ -1283,8 +1415,8 @@ var ZodString = class extends ZodType {
|
|
|
1283
1415
|
}
|
|
1284
1416
|
return max;
|
|
1285
1417
|
}
|
|
1286
|
-
};
|
|
1287
|
-
|
|
1418
|
+
}, "ZodString");
|
|
1419
|
+
__name2(ZodString, "ZodString");
|
|
1288
1420
|
ZodString.create = (params) => {
|
|
1289
1421
|
var _a;
|
|
1290
1422
|
return new ZodString({
|
|
@@ -1303,7 +1435,8 @@ function floatSafeRemainder(val, step) {
|
|
|
1303
1435
|
return valInt % stepInt / Math.pow(10, decCount);
|
|
1304
1436
|
}
|
|
1305
1437
|
__name(floatSafeRemainder, "floatSafeRemainder");
|
|
1306
|
-
|
|
1438
|
+
__name2(floatSafeRemainder, "floatSafeRemainder");
|
|
1439
|
+
var ZodNumber = /* @__PURE__ */ __name(class extends ZodType {
|
|
1307
1440
|
constructor() {
|
|
1308
1441
|
super(...arguments);
|
|
1309
1442
|
this.min = this.gte;
|
|
@@ -1389,7 +1522,10 @@ var ZodNumber = class extends ZodType {
|
|
|
1389
1522
|
util.assertNever(check);
|
|
1390
1523
|
}
|
|
1391
1524
|
}
|
|
1392
|
-
return {
|
|
1525
|
+
return {
|
|
1526
|
+
status: status.value,
|
|
1527
|
+
value: input.data
|
|
1528
|
+
};
|
|
1393
1529
|
}
|
|
1394
1530
|
gte(value, message) {
|
|
1395
1531
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
@@ -1420,7 +1556,10 @@ var ZodNumber = class extends ZodType {
|
|
|
1420
1556
|
_addCheck(check) {
|
|
1421
1557
|
return new ZodNumber({
|
|
1422
1558
|
...this._def,
|
|
1423
|
-
checks: [
|
|
1559
|
+
checks: [
|
|
1560
|
+
...this._def.checks,
|
|
1561
|
+
check
|
|
1562
|
+
]
|
|
1424
1563
|
});
|
|
1425
1564
|
}
|
|
1426
1565
|
int(message) {
|
|
@@ -1525,8 +1664,8 @@ var ZodNumber = class extends ZodType {
|
|
|
1525
1664
|
}
|
|
1526
1665
|
return Number.isFinite(min) && Number.isFinite(max);
|
|
1527
1666
|
}
|
|
1528
|
-
};
|
|
1529
|
-
|
|
1667
|
+
}, "ZodNumber");
|
|
1668
|
+
__name2(ZodNumber, "ZodNumber");
|
|
1530
1669
|
ZodNumber.create = (params) => {
|
|
1531
1670
|
return new ZodNumber({
|
|
1532
1671
|
checks: [],
|
|
@@ -1535,7 +1674,7 @@ ZodNumber.create = (params) => {
|
|
|
1535
1674
|
...processCreateParams(params)
|
|
1536
1675
|
});
|
|
1537
1676
|
};
|
|
1538
|
-
var ZodBigInt = class extends ZodType {
|
|
1677
|
+
var ZodBigInt = /* @__PURE__ */ __name(class extends ZodType {
|
|
1539
1678
|
constructor() {
|
|
1540
1679
|
super(...arguments);
|
|
1541
1680
|
this.min = this.gte;
|
|
@@ -1598,7 +1737,10 @@ var ZodBigInt = class extends ZodType {
|
|
|
1598
1737
|
util.assertNever(check);
|
|
1599
1738
|
}
|
|
1600
1739
|
}
|
|
1601
|
-
return {
|
|
1740
|
+
return {
|
|
1741
|
+
status: status.value,
|
|
1742
|
+
value: input.data
|
|
1743
|
+
};
|
|
1602
1744
|
}
|
|
1603
1745
|
gte(value, message) {
|
|
1604
1746
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
@@ -1629,7 +1771,10 @@ var ZodBigInt = class extends ZodType {
|
|
|
1629
1771
|
_addCheck(check) {
|
|
1630
1772
|
return new ZodBigInt({
|
|
1631
1773
|
...this._def,
|
|
1632
|
-
checks: [
|
|
1774
|
+
checks: [
|
|
1775
|
+
...this._def.checks,
|
|
1776
|
+
check
|
|
1777
|
+
]
|
|
1633
1778
|
});
|
|
1634
1779
|
}
|
|
1635
1780
|
positive(message) {
|
|
@@ -1691,8 +1836,8 @@ var ZodBigInt = class extends ZodType {
|
|
|
1691
1836
|
}
|
|
1692
1837
|
return max;
|
|
1693
1838
|
}
|
|
1694
|
-
};
|
|
1695
|
-
|
|
1839
|
+
}, "ZodBigInt");
|
|
1840
|
+
__name2(ZodBigInt, "ZodBigInt");
|
|
1696
1841
|
ZodBigInt.create = (params) => {
|
|
1697
1842
|
var _a;
|
|
1698
1843
|
return new ZodBigInt({
|
|
@@ -1702,7 +1847,7 @@ ZodBigInt.create = (params) => {
|
|
|
1702
1847
|
...processCreateParams(params)
|
|
1703
1848
|
});
|
|
1704
1849
|
};
|
|
1705
|
-
var ZodBoolean = class extends ZodType {
|
|
1850
|
+
var ZodBoolean = /* @__PURE__ */ __name(class extends ZodType {
|
|
1706
1851
|
_parse(input) {
|
|
1707
1852
|
if (this._def.coerce) {
|
|
1708
1853
|
input.data = Boolean(input.data);
|
|
@@ -1719,8 +1864,8 @@ var ZodBoolean = class extends ZodType {
|
|
|
1719
1864
|
}
|
|
1720
1865
|
return OK(input.data);
|
|
1721
1866
|
}
|
|
1722
|
-
};
|
|
1723
|
-
|
|
1867
|
+
}, "ZodBoolean");
|
|
1868
|
+
__name2(ZodBoolean, "ZodBoolean");
|
|
1724
1869
|
ZodBoolean.create = (params) => {
|
|
1725
1870
|
return new ZodBoolean({
|
|
1726
1871
|
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
|
@@ -1728,7 +1873,7 @@ ZodBoolean.create = (params) => {
|
|
|
1728
1873
|
...processCreateParams(params)
|
|
1729
1874
|
});
|
|
1730
1875
|
};
|
|
1731
|
-
var ZodDate = class extends ZodType {
|
|
1876
|
+
var ZodDate = /* @__PURE__ */ __name(class extends ZodType {
|
|
1732
1877
|
_parse(input) {
|
|
1733
1878
|
if (this._def.coerce) {
|
|
1734
1879
|
input.data = new Date(input.data);
|
|
@@ -1791,7 +1936,10 @@ var ZodDate = class extends ZodType {
|
|
|
1791
1936
|
_addCheck(check) {
|
|
1792
1937
|
return new ZodDate({
|
|
1793
1938
|
...this._def,
|
|
1794
|
-
checks: [
|
|
1939
|
+
checks: [
|
|
1940
|
+
...this._def.checks,
|
|
1941
|
+
check
|
|
1942
|
+
]
|
|
1795
1943
|
});
|
|
1796
1944
|
}
|
|
1797
1945
|
min(minDate, message) {
|
|
@@ -1828,8 +1976,8 @@ var ZodDate = class extends ZodType {
|
|
|
1828
1976
|
}
|
|
1829
1977
|
return max != null ? new Date(max) : null;
|
|
1830
1978
|
}
|
|
1831
|
-
};
|
|
1832
|
-
|
|
1979
|
+
}, "ZodDate");
|
|
1980
|
+
__name2(ZodDate, "ZodDate");
|
|
1833
1981
|
ZodDate.create = (params) => {
|
|
1834
1982
|
return new ZodDate({
|
|
1835
1983
|
checks: [],
|
|
@@ -1838,7 +1986,7 @@ ZodDate.create = (params) => {
|
|
|
1838
1986
|
...processCreateParams(params)
|
|
1839
1987
|
});
|
|
1840
1988
|
};
|
|
1841
|
-
var ZodSymbol = class extends ZodType {
|
|
1989
|
+
var ZodSymbol = /* @__PURE__ */ __name(class extends ZodType {
|
|
1842
1990
|
_parse(input) {
|
|
1843
1991
|
const parsedType = this._getType(input);
|
|
1844
1992
|
if (parsedType !== ZodParsedType.symbol) {
|
|
@@ -1852,15 +2000,15 @@ var ZodSymbol = class extends ZodType {
|
|
|
1852
2000
|
}
|
|
1853
2001
|
return OK(input.data);
|
|
1854
2002
|
}
|
|
1855
|
-
};
|
|
1856
|
-
|
|
2003
|
+
}, "ZodSymbol");
|
|
2004
|
+
__name2(ZodSymbol, "ZodSymbol");
|
|
1857
2005
|
ZodSymbol.create = (params) => {
|
|
1858
2006
|
return new ZodSymbol({
|
|
1859
2007
|
typeName: ZodFirstPartyTypeKind.ZodSymbol,
|
|
1860
2008
|
...processCreateParams(params)
|
|
1861
2009
|
});
|
|
1862
2010
|
};
|
|
1863
|
-
var ZodUndefined = class extends ZodType {
|
|
2011
|
+
var ZodUndefined = /* @__PURE__ */ __name(class extends ZodType {
|
|
1864
2012
|
_parse(input) {
|
|
1865
2013
|
const parsedType = this._getType(input);
|
|
1866
2014
|
if (parsedType !== ZodParsedType.undefined) {
|
|
@@ -1874,15 +2022,15 @@ var ZodUndefined = class extends ZodType {
|
|
|
1874
2022
|
}
|
|
1875
2023
|
return OK(input.data);
|
|
1876
2024
|
}
|
|
1877
|
-
};
|
|
1878
|
-
|
|
2025
|
+
}, "ZodUndefined");
|
|
2026
|
+
__name2(ZodUndefined, "ZodUndefined");
|
|
1879
2027
|
ZodUndefined.create = (params) => {
|
|
1880
2028
|
return new ZodUndefined({
|
|
1881
2029
|
typeName: ZodFirstPartyTypeKind.ZodUndefined,
|
|
1882
2030
|
...processCreateParams(params)
|
|
1883
2031
|
});
|
|
1884
2032
|
};
|
|
1885
|
-
var ZodNull = class extends ZodType {
|
|
2033
|
+
var ZodNull = /* @__PURE__ */ __name(class extends ZodType {
|
|
1886
2034
|
_parse(input) {
|
|
1887
2035
|
const parsedType = this._getType(input);
|
|
1888
2036
|
if (parsedType !== ZodParsedType.null) {
|
|
@@ -1896,15 +2044,15 @@ var ZodNull = class extends ZodType {
|
|
|
1896
2044
|
}
|
|
1897
2045
|
return OK(input.data);
|
|
1898
2046
|
}
|
|
1899
|
-
};
|
|
1900
|
-
|
|
2047
|
+
}, "ZodNull");
|
|
2048
|
+
__name2(ZodNull, "ZodNull");
|
|
1901
2049
|
ZodNull.create = (params) => {
|
|
1902
2050
|
return new ZodNull({
|
|
1903
2051
|
typeName: ZodFirstPartyTypeKind.ZodNull,
|
|
1904
2052
|
...processCreateParams(params)
|
|
1905
2053
|
});
|
|
1906
2054
|
};
|
|
1907
|
-
var ZodAny = class extends ZodType {
|
|
2055
|
+
var ZodAny = /* @__PURE__ */ __name(class extends ZodType {
|
|
1908
2056
|
constructor() {
|
|
1909
2057
|
super(...arguments);
|
|
1910
2058
|
this._any = true;
|
|
@@ -1912,15 +2060,15 @@ var ZodAny = class extends ZodType {
|
|
|
1912
2060
|
_parse(input) {
|
|
1913
2061
|
return OK(input.data);
|
|
1914
2062
|
}
|
|
1915
|
-
};
|
|
1916
|
-
|
|
2063
|
+
}, "ZodAny");
|
|
2064
|
+
__name2(ZodAny, "ZodAny");
|
|
1917
2065
|
ZodAny.create = (params) => {
|
|
1918
2066
|
return new ZodAny({
|
|
1919
2067
|
typeName: ZodFirstPartyTypeKind.ZodAny,
|
|
1920
2068
|
...processCreateParams(params)
|
|
1921
2069
|
});
|
|
1922
2070
|
};
|
|
1923
|
-
var ZodUnknown = class extends ZodType {
|
|
2071
|
+
var ZodUnknown = /* @__PURE__ */ __name(class extends ZodType {
|
|
1924
2072
|
constructor() {
|
|
1925
2073
|
super(...arguments);
|
|
1926
2074
|
this._unknown = true;
|
|
@@ -1928,15 +2076,15 @@ var ZodUnknown = class extends ZodType {
|
|
|
1928
2076
|
_parse(input) {
|
|
1929
2077
|
return OK(input.data);
|
|
1930
2078
|
}
|
|
1931
|
-
};
|
|
1932
|
-
|
|
2079
|
+
}, "ZodUnknown");
|
|
2080
|
+
__name2(ZodUnknown, "ZodUnknown");
|
|
1933
2081
|
ZodUnknown.create = (params) => {
|
|
1934
2082
|
return new ZodUnknown({
|
|
1935
2083
|
typeName: ZodFirstPartyTypeKind.ZodUnknown,
|
|
1936
2084
|
...processCreateParams(params)
|
|
1937
2085
|
});
|
|
1938
2086
|
};
|
|
1939
|
-
var ZodNever = class extends ZodType {
|
|
2087
|
+
var ZodNever = /* @__PURE__ */ __name(class extends ZodType {
|
|
1940
2088
|
_parse(input) {
|
|
1941
2089
|
const ctx = this._getOrReturnCtx(input);
|
|
1942
2090
|
addIssueToContext(ctx, {
|
|
@@ -1946,15 +2094,15 @@ var ZodNever = class extends ZodType {
|
|
|
1946
2094
|
});
|
|
1947
2095
|
return INVALID;
|
|
1948
2096
|
}
|
|
1949
|
-
};
|
|
1950
|
-
|
|
2097
|
+
}, "ZodNever");
|
|
2098
|
+
__name2(ZodNever, "ZodNever");
|
|
1951
2099
|
ZodNever.create = (params) => {
|
|
1952
2100
|
return new ZodNever({
|
|
1953
2101
|
typeName: ZodFirstPartyTypeKind.ZodNever,
|
|
1954
2102
|
...processCreateParams(params)
|
|
1955
2103
|
});
|
|
1956
2104
|
};
|
|
1957
|
-
var ZodVoid = class extends ZodType {
|
|
2105
|
+
var ZodVoid = /* @__PURE__ */ __name(class extends ZodType {
|
|
1958
2106
|
_parse(input) {
|
|
1959
2107
|
const parsedType = this._getType(input);
|
|
1960
2108
|
if (parsedType !== ZodParsedType.undefined) {
|
|
@@ -1968,15 +2116,15 @@ var ZodVoid = class extends ZodType {
|
|
|
1968
2116
|
}
|
|
1969
2117
|
return OK(input.data);
|
|
1970
2118
|
}
|
|
1971
|
-
};
|
|
1972
|
-
|
|
2119
|
+
}, "ZodVoid");
|
|
2120
|
+
__name2(ZodVoid, "ZodVoid");
|
|
1973
2121
|
ZodVoid.create = (params) => {
|
|
1974
2122
|
return new ZodVoid({
|
|
1975
2123
|
typeName: ZodFirstPartyTypeKind.ZodVoid,
|
|
1976
2124
|
...processCreateParams(params)
|
|
1977
2125
|
});
|
|
1978
2126
|
};
|
|
1979
|
-
var ZodArray = class extends ZodType {
|
|
2127
|
+
var ZodArray = /* @__PURE__ */ __name(class extends ZodType {
|
|
1980
2128
|
_parse(input) {
|
|
1981
2129
|
const { ctx, status } = this._processInputParams(input);
|
|
1982
2130
|
const def = this._def;
|
|
@@ -2031,13 +2179,17 @@ var ZodArray = class extends ZodType {
|
|
|
2031
2179
|
}
|
|
2032
2180
|
}
|
|
2033
2181
|
if (ctx.common.async) {
|
|
2034
|
-
return Promise.all([
|
|
2182
|
+
return Promise.all([
|
|
2183
|
+
...ctx.data
|
|
2184
|
+
].map((item, i) => {
|
|
2035
2185
|
return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
2036
2186
|
})).then((result2) => {
|
|
2037
2187
|
return ParseStatus.mergeArray(status, result2);
|
|
2038
2188
|
});
|
|
2039
2189
|
}
|
|
2040
|
-
const result = [
|
|
2190
|
+
const result = [
|
|
2191
|
+
...ctx.data
|
|
2192
|
+
].map((item, i) => {
|
|
2041
2193
|
return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
|
2042
2194
|
});
|
|
2043
2195
|
return ParseStatus.mergeArray(status, result);
|
|
@@ -2048,26 +2200,35 @@ var ZodArray = class extends ZodType {
|
|
|
2048
2200
|
min(minLength, message) {
|
|
2049
2201
|
return new ZodArray({
|
|
2050
2202
|
...this._def,
|
|
2051
|
-
minLength: {
|
|
2203
|
+
minLength: {
|
|
2204
|
+
value: minLength,
|
|
2205
|
+
message: errorUtil.toString(message)
|
|
2206
|
+
}
|
|
2052
2207
|
});
|
|
2053
2208
|
}
|
|
2054
2209
|
max(maxLength, message) {
|
|
2055
2210
|
return new ZodArray({
|
|
2056
2211
|
...this._def,
|
|
2057
|
-
maxLength: {
|
|
2212
|
+
maxLength: {
|
|
2213
|
+
value: maxLength,
|
|
2214
|
+
message: errorUtil.toString(message)
|
|
2215
|
+
}
|
|
2058
2216
|
});
|
|
2059
2217
|
}
|
|
2060
2218
|
length(len, message) {
|
|
2061
2219
|
return new ZodArray({
|
|
2062
2220
|
...this._def,
|
|
2063
|
-
exactLength: {
|
|
2221
|
+
exactLength: {
|
|
2222
|
+
value: len,
|
|
2223
|
+
message: errorUtil.toString(message)
|
|
2224
|
+
}
|
|
2064
2225
|
});
|
|
2065
2226
|
}
|
|
2066
2227
|
nonempty(message) {
|
|
2067
2228
|
return this.min(1, message);
|
|
2068
2229
|
}
|
|
2069
|
-
};
|
|
2070
|
-
|
|
2230
|
+
}, "ZodArray");
|
|
2231
|
+
__name2(ZodArray, "ZodArray");
|
|
2071
2232
|
ZodArray.create = (schema, params) => {
|
|
2072
2233
|
return new ZodArray({
|
|
2073
2234
|
type: schema,
|
|
@@ -2105,7 +2266,8 @@ function deepPartialify(schema) {
|
|
|
2105
2266
|
}
|
|
2106
2267
|
}
|
|
2107
2268
|
__name(deepPartialify, "deepPartialify");
|
|
2108
|
-
|
|
2269
|
+
__name2(deepPartialify, "deepPartialify");
|
|
2270
|
+
var ZodObject = /* @__PURE__ */ __name(class extends ZodType {
|
|
2109
2271
|
constructor() {
|
|
2110
2272
|
super(...arguments);
|
|
2111
2273
|
this._cached = null;
|
|
@@ -2117,7 +2279,10 @@ var ZodObject = class extends ZodType {
|
|
|
2117
2279
|
return this._cached;
|
|
2118
2280
|
const shape = this._def.shape();
|
|
2119
2281
|
const keys = util.objectKeys(shape);
|
|
2120
|
-
return this._cached = {
|
|
2282
|
+
return this._cached = {
|
|
2283
|
+
shape,
|
|
2284
|
+
keys
|
|
2285
|
+
};
|
|
2121
2286
|
}
|
|
2122
2287
|
_parse(input) {
|
|
2123
2288
|
const parsedType = this._getType(input);
|
|
@@ -2145,7 +2310,10 @@ var ZodObject = class extends ZodType {
|
|
|
2145
2310
|
const keyValidator = shape[key];
|
|
2146
2311
|
const value = ctx.data[key];
|
|
2147
2312
|
pairs.push({
|
|
2148
|
-
key: {
|
|
2313
|
+
key: {
|
|
2314
|
+
status: "valid",
|
|
2315
|
+
value: key
|
|
2316
|
+
},
|
|
2149
2317
|
value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
|
|
2150
2318
|
alwaysSet: key in ctx.data
|
|
2151
2319
|
});
|
|
@@ -2155,8 +2323,14 @@ var ZodObject = class extends ZodType {
|
|
|
2155
2323
|
if (unknownKeys === "passthrough") {
|
|
2156
2324
|
for (const key of extraKeys) {
|
|
2157
2325
|
pairs.push({
|
|
2158
|
-
key: {
|
|
2159
|
-
|
|
2326
|
+
key: {
|
|
2327
|
+
status: "valid",
|
|
2328
|
+
value: key
|
|
2329
|
+
},
|
|
2330
|
+
value: {
|
|
2331
|
+
status: "valid",
|
|
2332
|
+
value: ctx.data[key]
|
|
2333
|
+
}
|
|
2160
2334
|
});
|
|
2161
2335
|
}
|
|
2162
2336
|
} else if (unknownKeys === "strict") {
|
|
@@ -2177,11 +2351,11 @@ var ZodObject = class extends ZodType {
|
|
|
2177
2351
|
for (const key of extraKeys) {
|
|
2178
2352
|
const value = ctx.data[key];
|
|
2179
2353
|
pairs.push({
|
|
2180
|
-
key: {
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
),
|
|
2354
|
+
key: {
|
|
2355
|
+
status: "valid",
|
|
2356
|
+
value: key
|
|
2357
|
+
},
|
|
2358
|
+
value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key)),
|
|
2185
2359
|
alwaysSet: key in ctx.data
|
|
2186
2360
|
});
|
|
2187
2361
|
}
|
|
@@ -2267,10 +2441,10 @@ var ZodObject = class extends ZodType {
|
|
|
2267
2441
|
});
|
|
2268
2442
|
}
|
|
2269
2443
|
/**
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2273
|
-
|
|
2444
|
+
* Prior to zod@1.0.12 there was a bug in the
|
|
2445
|
+
* inferred type of merged objects. Please
|
|
2446
|
+
* upgrade if you are experiencing issues.
|
|
2447
|
+
*/
|
|
2274
2448
|
merge(merging) {
|
|
2275
2449
|
const merged = new ZodObject({
|
|
2276
2450
|
unknownKeys: merging._def.unknownKeys,
|
|
@@ -2319,7 +2493,9 @@ var ZodObject = class extends ZodType {
|
|
|
2319
2493
|
// return merged;
|
|
2320
2494
|
// }
|
|
2321
2495
|
setKey(key, schema) {
|
|
2322
|
-
return this.augment({
|
|
2496
|
+
return this.augment({
|
|
2497
|
+
[key]: schema
|
|
2498
|
+
});
|
|
2323
2499
|
}
|
|
2324
2500
|
// merge<Incoming extends AnyZodObject>(
|
|
2325
2501
|
// merging: Incoming
|
|
@@ -2373,8 +2549,8 @@ var ZodObject = class extends ZodType {
|
|
|
2373
2549
|
});
|
|
2374
2550
|
}
|
|
2375
2551
|
/**
|
|
2376
|
-
|
|
2377
|
-
|
|
2552
|
+
* @deprecated
|
|
2553
|
+
*/
|
|
2378
2554
|
deepPartial() {
|
|
2379
2555
|
return deepPartialify(this);
|
|
2380
2556
|
}
|
|
@@ -2415,8 +2591,8 @@ var ZodObject = class extends ZodType {
|
|
|
2415
2591
|
keyof() {
|
|
2416
2592
|
return createZodEnum(util.objectKeys(this.shape));
|
|
2417
2593
|
}
|
|
2418
|
-
};
|
|
2419
|
-
|
|
2594
|
+
}, "ZodObject");
|
|
2595
|
+
__name2(ZodObject, "ZodObject");
|
|
2420
2596
|
ZodObject.create = (shape, params) => {
|
|
2421
2597
|
return new ZodObject({
|
|
2422
2598
|
shape: () => shape,
|
|
@@ -2444,7 +2620,7 @@ ZodObject.lazycreate = (shape, params) => {
|
|
|
2444
2620
|
...processCreateParams(params)
|
|
2445
2621
|
});
|
|
2446
2622
|
};
|
|
2447
|
-
var ZodUnion = class extends ZodType {
|
|
2623
|
+
var ZodUnion = /* @__PURE__ */ __name(class extends ZodType {
|
|
2448
2624
|
_parse(input) {
|
|
2449
2625
|
const { ctx } = this._processInputParams(input);
|
|
2450
2626
|
const options = this._def.options;
|
|
@@ -2468,6 +2644,7 @@ var ZodUnion = class extends ZodType {
|
|
|
2468
2644
|
return INVALID;
|
|
2469
2645
|
}
|
|
2470
2646
|
__name(handleResults, "handleResults");
|
|
2647
|
+
__name2(handleResults, "handleResults");
|
|
2471
2648
|
if (ctx.common.async) {
|
|
2472
2649
|
return Promise.all(options.map(async (option) => {
|
|
2473
2650
|
const childCtx = {
|
|
@@ -2507,7 +2684,10 @@ var ZodUnion = class extends ZodType {
|
|
|
2507
2684
|
if (result.status === "valid") {
|
|
2508
2685
|
return result;
|
|
2509
2686
|
} else if (result.status === "dirty" && !dirty) {
|
|
2510
|
-
dirty = {
|
|
2687
|
+
dirty = {
|
|
2688
|
+
result,
|
|
2689
|
+
ctx: childCtx
|
|
2690
|
+
};
|
|
2511
2691
|
}
|
|
2512
2692
|
if (childCtx.common.issues.length) {
|
|
2513
2693
|
issues.push(childCtx.common.issues);
|
|
@@ -2528,8 +2708,8 @@ var ZodUnion = class extends ZodType {
|
|
|
2528
2708
|
get options() {
|
|
2529
2709
|
return this._def.options;
|
|
2530
2710
|
}
|
|
2531
|
-
};
|
|
2532
|
-
|
|
2711
|
+
}, "ZodUnion");
|
|
2712
|
+
__name2(ZodUnion, "ZodUnion");
|
|
2533
2713
|
ZodUnion.create = (types, params) => {
|
|
2534
2714
|
return new ZodUnion({
|
|
2535
2715
|
options: types,
|
|
@@ -2537,13 +2717,15 @@ ZodUnion.create = (types, params) => {
|
|
|
2537
2717
|
...processCreateParams(params)
|
|
2538
2718
|
});
|
|
2539
2719
|
};
|
|
2540
|
-
var getDiscriminator = /* @__PURE__ */
|
|
2720
|
+
var getDiscriminator = /* @__PURE__ */ __name2((type) => {
|
|
2541
2721
|
if (type instanceof ZodLazy) {
|
|
2542
2722
|
return getDiscriminator(type.schema);
|
|
2543
2723
|
} else if (type instanceof ZodEffects) {
|
|
2544
2724
|
return getDiscriminator(type.innerType());
|
|
2545
2725
|
} else if (type instanceof ZodLiteral) {
|
|
2546
|
-
return [
|
|
2726
|
+
return [
|
|
2727
|
+
type.value
|
|
2728
|
+
];
|
|
2547
2729
|
} else if (type instanceof ZodEnum) {
|
|
2548
2730
|
return type.options;
|
|
2549
2731
|
} else if (type instanceof ZodNativeEnum) {
|
|
@@ -2551,14 +2733,18 @@ var getDiscriminator = /* @__PURE__ */ __name((type) => {
|
|
|
2551
2733
|
} else if (type instanceof ZodDefault) {
|
|
2552
2734
|
return getDiscriminator(type._def.innerType);
|
|
2553
2735
|
} else if (type instanceof ZodUndefined) {
|
|
2554
|
-
return [
|
|
2736
|
+
return [
|
|
2737
|
+
void 0
|
|
2738
|
+
];
|
|
2555
2739
|
} else if (type instanceof ZodNull) {
|
|
2556
|
-
return [
|
|
2740
|
+
return [
|
|
2741
|
+
null
|
|
2742
|
+
];
|
|
2557
2743
|
} else {
|
|
2558
2744
|
return null;
|
|
2559
2745
|
}
|
|
2560
2746
|
}, "getDiscriminator");
|
|
2561
|
-
var ZodDiscriminatedUnion = class extends ZodType {
|
|
2747
|
+
var ZodDiscriminatedUnion = /* @__PURE__ */ __name(class extends ZodType {
|
|
2562
2748
|
_parse(input) {
|
|
2563
2749
|
const { ctx } = this._processInputParams(input);
|
|
2564
2750
|
if (ctx.parsedType !== ZodParsedType.object) {
|
|
@@ -2576,7 +2762,9 @@ var ZodDiscriminatedUnion = class extends ZodType {
|
|
|
2576
2762
|
addIssueToContext(ctx, {
|
|
2577
2763
|
code: ZodIssueCode.invalid_union_discriminator,
|
|
2578
2764
|
options: Array.from(this.optionsMap.keys()),
|
|
2579
|
-
path: [
|
|
2765
|
+
path: [
|
|
2766
|
+
discriminator
|
|
2767
|
+
]
|
|
2580
2768
|
});
|
|
2581
2769
|
return INVALID;
|
|
2582
2770
|
}
|
|
@@ -2604,13 +2792,13 @@ var ZodDiscriminatedUnion = class extends ZodType {
|
|
|
2604
2792
|
return this._def.optionsMap;
|
|
2605
2793
|
}
|
|
2606
2794
|
/**
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2795
|
+
* The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
|
|
2796
|
+
* However, it only allows a union of objects, all of which need to share a discriminator property. This property must
|
|
2797
|
+
* have a different value for each object in the union.
|
|
2798
|
+
* @param discriminator the name of the discriminator property
|
|
2799
|
+
* @param types an array of object schemas
|
|
2800
|
+
* @param params
|
|
2801
|
+
*/
|
|
2614
2802
|
static create(discriminator, options, params) {
|
|
2615
2803
|
const optionsMap = /* @__PURE__ */ new Map();
|
|
2616
2804
|
for (const type of options) {
|
|
@@ -2633,28 +2821,41 @@ var ZodDiscriminatedUnion = class extends ZodType {
|
|
|
2633
2821
|
...processCreateParams(params)
|
|
2634
2822
|
});
|
|
2635
2823
|
}
|
|
2636
|
-
};
|
|
2637
|
-
|
|
2824
|
+
}, "ZodDiscriminatedUnion");
|
|
2825
|
+
__name2(ZodDiscriminatedUnion, "ZodDiscriminatedUnion");
|
|
2638
2826
|
function mergeValues(a, b) {
|
|
2639
2827
|
const aType = getParsedType(a);
|
|
2640
2828
|
const bType = getParsedType(b);
|
|
2641
2829
|
if (a === b) {
|
|
2642
|
-
return {
|
|
2830
|
+
return {
|
|
2831
|
+
valid: true,
|
|
2832
|
+
data: a
|
|
2833
|
+
};
|
|
2643
2834
|
} else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
|
|
2644
2835
|
const bKeys = util.objectKeys(b);
|
|
2645
2836
|
const sharedKeys = util.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
2646
|
-
const newObj = {
|
|
2837
|
+
const newObj = {
|
|
2838
|
+
...a,
|
|
2839
|
+
...b
|
|
2840
|
+
};
|
|
2647
2841
|
for (const key of sharedKeys) {
|
|
2648
2842
|
const sharedValue = mergeValues(a[key], b[key]);
|
|
2649
2843
|
if (!sharedValue.valid) {
|
|
2650
|
-
return {
|
|
2844
|
+
return {
|
|
2845
|
+
valid: false
|
|
2846
|
+
};
|
|
2651
2847
|
}
|
|
2652
2848
|
newObj[key] = sharedValue.data;
|
|
2653
2849
|
}
|
|
2654
|
-
return {
|
|
2850
|
+
return {
|
|
2851
|
+
valid: true,
|
|
2852
|
+
data: newObj
|
|
2853
|
+
};
|
|
2655
2854
|
} else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
|
|
2656
2855
|
if (a.length !== b.length) {
|
|
2657
|
-
return {
|
|
2856
|
+
return {
|
|
2857
|
+
valid: false
|
|
2858
|
+
};
|
|
2658
2859
|
}
|
|
2659
2860
|
const newArray = [];
|
|
2660
2861
|
for (let index = 0; index < a.length; index++) {
|
|
@@ -2662,22 +2863,33 @@ function mergeValues(a, b) {
|
|
|
2662
2863
|
const itemB = b[index];
|
|
2663
2864
|
const sharedValue = mergeValues(itemA, itemB);
|
|
2664
2865
|
if (!sharedValue.valid) {
|
|
2665
|
-
return {
|
|
2866
|
+
return {
|
|
2867
|
+
valid: false
|
|
2868
|
+
};
|
|
2666
2869
|
}
|
|
2667
2870
|
newArray.push(sharedValue.data);
|
|
2668
2871
|
}
|
|
2669
|
-
return {
|
|
2872
|
+
return {
|
|
2873
|
+
valid: true,
|
|
2874
|
+
data: newArray
|
|
2875
|
+
};
|
|
2670
2876
|
} else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
|
|
2671
|
-
return {
|
|
2877
|
+
return {
|
|
2878
|
+
valid: true,
|
|
2879
|
+
data: a
|
|
2880
|
+
};
|
|
2672
2881
|
} else {
|
|
2673
|
-
return {
|
|
2882
|
+
return {
|
|
2883
|
+
valid: false
|
|
2884
|
+
};
|
|
2674
2885
|
}
|
|
2675
2886
|
}
|
|
2676
2887
|
__name(mergeValues, "mergeValues");
|
|
2677
|
-
|
|
2888
|
+
__name2(mergeValues, "mergeValues");
|
|
2889
|
+
var ZodIntersection = /* @__PURE__ */ __name(class extends ZodType {
|
|
2678
2890
|
_parse(input) {
|
|
2679
2891
|
const { status, ctx } = this._processInputParams(input);
|
|
2680
|
-
const handleParsed = /* @__PURE__ */
|
|
2892
|
+
const handleParsed = /* @__PURE__ */ __name2((parsedLeft, parsedRight) => {
|
|
2681
2893
|
if (isAborted(parsedLeft) || isAborted(parsedRight)) {
|
|
2682
2894
|
return INVALID;
|
|
2683
2895
|
}
|
|
@@ -2691,7 +2903,10 @@ var ZodIntersection = class extends ZodType {
|
|
|
2691
2903
|
if (isDirty(parsedLeft) || isDirty(parsedRight)) {
|
|
2692
2904
|
status.dirty();
|
|
2693
2905
|
}
|
|
2694
|
-
return {
|
|
2906
|
+
return {
|
|
2907
|
+
status: status.value,
|
|
2908
|
+
value: merged.data
|
|
2909
|
+
};
|
|
2695
2910
|
}, "handleParsed");
|
|
2696
2911
|
if (ctx.common.async) {
|
|
2697
2912
|
return Promise.all([
|
|
@@ -2718,8 +2933,8 @@ var ZodIntersection = class extends ZodType {
|
|
|
2718
2933
|
}));
|
|
2719
2934
|
}
|
|
2720
2935
|
}
|
|
2721
|
-
};
|
|
2722
|
-
|
|
2936
|
+
}, "ZodIntersection");
|
|
2937
|
+
__name2(ZodIntersection, "ZodIntersection");
|
|
2723
2938
|
ZodIntersection.create = (left, right, params) => {
|
|
2724
2939
|
return new ZodIntersection({
|
|
2725
2940
|
left,
|
|
@@ -2728,7 +2943,7 @@ ZodIntersection.create = (left, right, params) => {
|
|
|
2728
2943
|
...processCreateParams(params)
|
|
2729
2944
|
});
|
|
2730
2945
|
};
|
|
2731
|
-
var ZodTuple = class extends ZodType {
|
|
2946
|
+
var ZodTuple = /* @__PURE__ */ __name(class extends ZodType {
|
|
2732
2947
|
_parse(input) {
|
|
2733
2948
|
const { status, ctx } = this._processInputParams(input);
|
|
2734
2949
|
if (ctx.parsedType !== ZodParsedType.array) {
|
|
@@ -2760,7 +2975,9 @@ var ZodTuple = class extends ZodType {
|
|
|
2760
2975
|
});
|
|
2761
2976
|
status.dirty();
|
|
2762
2977
|
}
|
|
2763
|
-
const items = [
|
|
2978
|
+
const items = [
|
|
2979
|
+
...ctx.data
|
|
2980
|
+
].map((item, itemIndex) => {
|
|
2764
2981
|
const schema = this._def.items[itemIndex] || this._def.rest;
|
|
2765
2982
|
if (!schema)
|
|
2766
2983
|
return null;
|
|
@@ -2783,8 +3000,8 @@ var ZodTuple = class extends ZodType {
|
|
|
2783
3000
|
rest
|
|
2784
3001
|
});
|
|
2785
3002
|
}
|
|
2786
|
-
};
|
|
2787
|
-
|
|
3003
|
+
}, "ZodTuple");
|
|
3004
|
+
__name2(ZodTuple, "ZodTuple");
|
|
2788
3005
|
ZodTuple.create = (schemas, params) => {
|
|
2789
3006
|
if (!Array.isArray(schemas)) {
|
|
2790
3007
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
@@ -2796,7 +3013,7 @@ ZodTuple.create = (schemas, params) => {
|
|
|
2796
3013
|
...processCreateParams(params)
|
|
2797
3014
|
});
|
|
2798
3015
|
};
|
|
2799
|
-
var ZodRecord = class extends ZodType {
|
|
3016
|
+
var ZodRecord = /* @__PURE__ */ __name(class extends ZodType {
|
|
2800
3017
|
get keySchema() {
|
|
2801
3018
|
return this._def.keyType;
|
|
2802
3019
|
}
|
|
@@ -2847,9 +3064,9 @@ var ZodRecord = class extends ZodType {
|
|
|
2847
3064
|
...processCreateParams(second)
|
|
2848
3065
|
});
|
|
2849
3066
|
}
|
|
2850
|
-
};
|
|
2851
|
-
|
|
2852
|
-
var ZodMap = class extends ZodType {
|
|
3067
|
+
}, "ZodRecord");
|
|
3068
|
+
__name2(ZodRecord, "ZodRecord");
|
|
3069
|
+
var ZodMap = /* @__PURE__ */ __name(class extends ZodType {
|
|
2853
3070
|
get keySchema() {
|
|
2854
3071
|
return this._def.keyType;
|
|
2855
3072
|
}
|
|
@@ -2868,10 +3085,18 @@ var ZodMap = class extends ZodType {
|
|
|
2868
3085
|
}
|
|
2869
3086
|
const keyType = this._def.keyType;
|
|
2870
3087
|
const valueType = this._def.valueType;
|
|
2871
|
-
const pairs = [
|
|
3088
|
+
const pairs = [
|
|
3089
|
+
...ctx.data.entries()
|
|
3090
|
+
].map(([key, value], index) => {
|
|
2872
3091
|
return {
|
|
2873
|
-
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [
|
|
2874
|
-
|
|
3092
|
+
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, [
|
|
3093
|
+
index,
|
|
3094
|
+
"key"
|
|
3095
|
+
])),
|
|
3096
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [
|
|
3097
|
+
index,
|
|
3098
|
+
"value"
|
|
3099
|
+
]))
|
|
2875
3100
|
};
|
|
2876
3101
|
});
|
|
2877
3102
|
if (ctx.common.async) {
|
|
@@ -2888,7 +3113,10 @@ var ZodMap = class extends ZodType {
|
|
|
2888
3113
|
}
|
|
2889
3114
|
finalMap.set(key.value, value.value);
|
|
2890
3115
|
}
|
|
2891
|
-
return {
|
|
3116
|
+
return {
|
|
3117
|
+
status: status.value,
|
|
3118
|
+
value: finalMap
|
|
3119
|
+
};
|
|
2892
3120
|
});
|
|
2893
3121
|
} else {
|
|
2894
3122
|
const finalMap = /* @__PURE__ */ new Map();
|
|
@@ -2903,11 +3131,14 @@ var ZodMap = class extends ZodType {
|
|
|
2903
3131
|
}
|
|
2904
3132
|
finalMap.set(key.value, value.value);
|
|
2905
3133
|
}
|
|
2906
|
-
return {
|
|
3134
|
+
return {
|
|
3135
|
+
status: status.value,
|
|
3136
|
+
value: finalMap
|
|
3137
|
+
};
|
|
2907
3138
|
}
|
|
2908
3139
|
}
|
|
2909
|
-
};
|
|
2910
|
-
|
|
3140
|
+
}, "ZodMap");
|
|
3141
|
+
__name2(ZodMap, "ZodMap");
|
|
2911
3142
|
ZodMap.create = (keyType, valueType, params) => {
|
|
2912
3143
|
return new ZodMap({
|
|
2913
3144
|
valueType,
|
|
@@ -2916,7 +3147,7 @@ ZodMap.create = (keyType, valueType, params) => {
|
|
|
2916
3147
|
...processCreateParams(params)
|
|
2917
3148
|
});
|
|
2918
3149
|
};
|
|
2919
|
-
var ZodSet = class extends ZodType {
|
|
3150
|
+
var ZodSet = /* @__PURE__ */ __name(class extends ZodType {
|
|
2920
3151
|
_parse(input) {
|
|
2921
3152
|
const { status, ctx } = this._processInputParams(input);
|
|
2922
3153
|
if (ctx.parsedType !== ZodParsedType.set) {
|
|
@@ -2964,10 +3195,16 @@ var ZodSet = class extends ZodType {
|
|
|
2964
3195
|
status.dirty();
|
|
2965
3196
|
parsedSet.add(element.value);
|
|
2966
3197
|
}
|
|
2967
|
-
return {
|
|
3198
|
+
return {
|
|
3199
|
+
status: status.value,
|
|
3200
|
+
value: parsedSet
|
|
3201
|
+
};
|
|
2968
3202
|
}
|
|
2969
3203
|
__name(finalizeSet, "finalizeSet");
|
|
2970
|
-
|
|
3204
|
+
__name2(finalizeSet, "finalizeSet");
|
|
3205
|
+
const elements = [
|
|
3206
|
+
...ctx.data.values()
|
|
3207
|
+
].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
|
|
2971
3208
|
if (ctx.common.async) {
|
|
2972
3209
|
return Promise.all(elements).then((elements2) => finalizeSet(elements2));
|
|
2973
3210
|
} else {
|
|
@@ -2977,13 +3214,19 @@ var ZodSet = class extends ZodType {
|
|
|
2977
3214
|
min(minSize, message) {
|
|
2978
3215
|
return new ZodSet({
|
|
2979
3216
|
...this._def,
|
|
2980
|
-
minSize: {
|
|
3217
|
+
minSize: {
|
|
3218
|
+
value: minSize,
|
|
3219
|
+
message: errorUtil.toString(message)
|
|
3220
|
+
}
|
|
2981
3221
|
});
|
|
2982
3222
|
}
|
|
2983
3223
|
max(maxSize, message) {
|
|
2984
3224
|
return new ZodSet({
|
|
2985
3225
|
...this._def,
|
|
2986
|
-
maxSize: {
|
|
3226
|
+
maxSize: {
|
|
3227
|
+
value: maxSize,
|
|
3228
|
+
message: errorUtil.toString(message)
|
|
3229
|
+
}
|
|
2987
3230
|
});
|
|
2988
3231
|
}
|
|
2989
3232
|
size(size, message) {
|
|
@@ -2992,8 +3235,8 @@ var ZodSet = class extends ZodType {
|
|
|
2992
3235
|
nonempty(message) {
|
|
2993
3236
|
return this.min(1, message);
|
|
2994
3237
|
}
|
|
2995
|
-
};
|
|
2996
|
-
|
|
3238
|
+
}, "ZodSet");
|
|
3239
|
+
__name2(ZodSet, "ZodSet");
|
|
2997
3240
|
ZodSet.create = (valueType, params) => {
|
|
2998
3241
|
return new ZodSet({
|
|
2999
3242
|
valueType,
|
|
@@ -3003,7 +3246,7 @@ ZodSet.create = (valueType, params) => {
|
|
|
3003
3246
|
...processCreateParams(params)
|
|
3004
3247
|
});
|
|
3005
3248
|
};
|
|
3006
|
-
var ZodFunction = class extends ZodType {
|
|
3249
|
+
var ZodFunction = /* @__PURE__ */ __name(class extends ZodType {
|
|
3007
3250
|
constructor() {
|
|
3008
3251
|
super(...arguments);
|
|
3009
3252
|
this.validate = this.implement;
|
|
@@ -3035,6 +3278,7 @@ var ZodFunction = class extends ZodType {
|
|
|
3035
3278
|
});
|
|
3036
3279
|
}
|
|
3037
3280
|
__name(makeArgsIssue, "makeArgsIssue");
|
|
3281
|
+
__name2(makeArgsIssue, "makeArgsIssue");
|
|
3038
3282
|
function makeReturnsIssue(returns, error) {
|
|
3039
3283
|
return makeIssue({
|
|
3040
3284
|
data: returns,
|
|
@@ -3052,7 +3296,10 @@ var ZodFunction = class extends ZodType {
|
|
|
3052
3296
|
});
|
|
3053
3297
|
}
|
|
3054
3298
|
__name(makeReturnsIssue, "makeReturnsIssue");
|
|
3055
|
-
|
|
3299
|
+
__name2(makeReturnsIssue, "makeReturnsIssue");
|
|
3300
|
+
const params = {
|
|
3301
|
+
errorMap: ctx.common.contextualErrorMap
|
|
3302
|
+
};
|
|
3056
3303
|
const fn = ctx.data;
|
|
3057
3304
|
if (this._def.returns instanceof ZodPromise) {
|
|
3058
3305
|
const me = this;
|
|
@@ -3074,12 +3321,16 @@ var ZodFunction = class extends ZodType {
|
|
|
3074
3321
|
return OK(function(...args) {
|
|
3075
3322
|
const parsedArgs = me._def.args.safeParse(args, params);
|
|
3076
3323
|
if (!parsedArgs.success) {
|
|
3077
|
-
throw new ZodError([
|
|
3324
|
+
throw new ZodError([
|
|
3325
|
+
makeArgsIssue(args, parsedArgs.error)
|
|
3326
|
+
]);
|
|
3078
3327
|
}
|
|
3079
3328
|
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
3080
3329
|
const parsedReturns = me._def.returns.safeParse(result, params);
|
|
3081
3330
|
if (!parsedReturns.success) {
|
|
3082
|
-
throw new ZodError([
|
|
3331
|
+
throw new ZodError([
|
|
3332
|
+
makeReturnsIssue(result, parsedReturns.error)
|
|
3333
|
+
]);
|
|
3083
3334
|
}
|
|
3084
3335
|
return parsedReturns.data;
|
|
3085
3336
|
});
|
|
@@ -3119,19 +3370,23 @@ var ZodFunction = class extends ZodType {
|
|
|
3119
3370
|
...processCreateParams(params)
|
|
3120
3371
|
});
|
|
3121
3372
|
}
|
|
3122
|
-
};
|
|
3123
|
-
|
|
3124
|
-
var ZodLazy = class extends ZodType {
|
|
3373
|
+
}, "ZodFunction");
|
|
3374
|
+
__name2(ZodFunction, "ZodFunction");
|
|
3375
|
+
var ZodLazy = /* @__PURE__ */ __name(class extends ZodType {
|
|
3125
3376
|
get schema() {
|
|
3126
3377
|
return this._def.getter();
|
|
3127
3378
|
}
|
|
3128
3379
|
_parse(input) {
|
|
3129
3380
|
const { ctx } = this._processInputParams(input);
|
|
3130
3381
|
const lazySchema = this._def.getter();
|
|
3131
|
-
return lazySchema._parse({
|
|
3382
|
+
return lazySchema._parse({
|
|
3383
|
+
data: ctx.data,
|
|
3384
|
+
path: ctx.path,
|
|
3385
|
+
parent: ctx
|
|
3386
|
+
});
|
|
3132
3387
|
}
|
|
3133
|
-
};
|
|
3134
|
-
|
|
3388
|
+
}, "ZodLazy");
|
|
3389
|
+
__name2(ZodLazy, "ZodLazy");
|
|
3135
3390
|
ZodLazy.create = (getter, params) => {
|
|
3136
3391
|
return new ZodLazy({
|
|
3137
3392
|
getter,
|
|
@@ -3139,7 +3394,7 @@ ZodLazy.create = (getter, params) => {
|
|
|
3139
3394
|
...processCreateParams(params)
|
|
3140
3395
|
});
|
|
3141
3396
|
};
|
|
3142
|
-
var ZodLiteral = class extends ZodType {
|
|
3397
|
+
var ZodLiteral = /* @__PURE__ */ __name(class extends ZodType {
|
|
3143
3398
|
_parse(input) {
|
|
3144
3399
|
if (input.data !== this._def.value) {
|
|
3145
3400
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3150,13 +3405,16 @@ var ZodLiteral = class extends ZodType {
|
|
|
3150
3405
|
});
|
|
3151
3406
|
return INVALID;
|
|
3152
3407
|
}
|
|
3153
|
-
return {
|
|
3408
|
+
return {
|
|
3409
|
+
status: "valid",
|
|
3410
|
+
value: input.data
|
|
3411
|
+
};
|
|
3154
3412
|
}
|
|
3155
3413
|
get value() {
|
|
3156
3414
|
return this._def.value;
|
|
3157
3415
|
}
|
|
3158
|
-
};
|
|
3159
|
-
|
|
3416
|
+
}, "ZodLiteral");
|
|
3417
|
+
__name2(ZodLiteral, "ZodLiteral");
|
|
3160
3418
|
ZodLiteral.create = (value, params) => {
|
|
3161
3419
|
return new ZodLiteral({
|
|
3162
3420
|
value,
|
|
@@ -3172,7 +3430,8 @@ function createZodEnum(values, params) {
|
|
|
3172
3430
|
});
|
|
3173
3431
|
}
|
|
3174
3432
|
__name(createZodEnum, "createZodEnum");
|
|
3175
|
-
|
|
3433
|
+
__name2(createZodEnum, "createZodEnum");
|
|
3434
|
+
var ZodEnum = /* @__PURE__ */ __name(class extends ZodType {
|
|
3176
3435
|
_parse(input) {
|
|
3177
3436
|
if (typeof input.data !== "string") {
|
|
3178
3437
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3226,10 +3485,10 @@ var ZodEnum = class extends ZodType {
|
|
|
3226
3485
|
exclude(values) {
|
|
3227
3486
|
return ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
|
|
3228
3487
|
}
|
|
3229
|
-
};
|
|
3230
|
-
|
|
3488
|
+
}, "ZodEnum");
|
|
3489
|
+
__name2(ZodEnum, "ZodEnum");
|
|
3231
3490
|
ZodEnum.create = createZodEnum;
|
|
3232
|
-
var ZodNativeEnum = class extends ZodType {
|
|
3491
|
+
var ZodNativeEnum = /* @__PURE__ */ __name(class extends ZodType {
|
|
3233
3492
|
_parse(input) {
|
|
3234
3493
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3235
3494
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3256,8 +3515,8 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3256
3515
|
get enum() {
|
|
3257
3516
|
return this._def.values;
|
|
3258
3517
|
}
|
|
3259
|
-
};
|
|
3260
|
-
|
|
3518
|
+
}, "ZodNativeEnum");
|
|
3519
|
+
__name2(ZodNativeEnum, "ZodNativeEnum");
|
|
3261
3520
|
ZodNativeEnum.create = (values, params) => {
|
|
3262
3521
|
return new ZodNativeEnum({
|
|
3263
3522
|
values,
|
|
@@ -3265,7 +3524,7 @@ ZodNativeEnum.create = (values, params) => {
|
|
|
3265
3524
|
...processCreateParams(params)
|
|
3266
3525
|
});
|
|
3267
3526
|
};
|
|
3268
|
-
var ZodPromise = class extends ZodType {
|
|
3527
|
+
var ZodPromise = /* @__PURE__ */ __name(class extends ZodType {
|
|
3269
3528
|
unwrap() {
|
|
3270
3529
|
return this._def.type;
|
|
3271
3530
|
}
|
|
@@ -3287,8 +3546,8 @@ var ZodPromise = class extends ZodType {
|
|
|
3287
3546
|
});
|
|
3288
3547
|
}));
|
|
3289
3548
|
}
|
|
3290
|
-
};
|
|
3291
|
-
|
|
3549
|
+
}, "ZodPromise");
|
|
3550
|
+
__name2(ZodPromise, "ZodPromise");
|
|
3292
3551
|
ZodPromise.create = (schema, params) => {
|
|
3293
3552
|
return new ZodPromise({
|
|
3294
3553
|
type: schema,
|
|
@@ -3296,7 +3555,7 @@ ZodPromise.create = (schema, params) => {
|
|
|
3296
3555
|
...processCreateParams(params)
|
|
3297
3556
|
});
|
|
3298
3557
|
};
|
|
3299
|
-
var ZodEffects = class extends ZodType {
|
|
3558
|
+
var ZodEffects = /* @__PURE__ */ __name(class extends ZodType {
|
|
3300
3559
|
innerType() {
|
|
3301
3560
|
return this._def.schema;
|
|
3302
3561
|
}
|
|
@@ -3345,7 +3604,7 @@ var ZodEffects = class extends ZodType {
|
|
|
3345
3604
|
}
|
|
3346
3605
|
}
|
|
3347
3606
|
if (effect.type === "refinement") {
|
|
3348
|
-
const executeRefinement = /* @__PURE__ */
|
|
3607
|
+
const executeRefinement = /* @__PURE__ */ __name2((acc) => {
|
|
3349
3608
|
const result = effect.refinement(acc, checkCtx);
|
|
3350
3609
|
if (ctx.common.async) {
|
|
3351
3610
|
return Promise.resolve(result);
|
|
@@ -3366,15 +3625,25 @@ var ZodEffects = class extends ZodType {
|
|
|
3366
3625
|
if (inner.status === "dirty")
|
|
3367
3626
|
status.dirty();
|
|
3368
3627
|
executeRefinement(inner.value);
|
|
3369
|
-
return {
|
|
3628
|
+
return {
|
|
3629
|
+
status: status.value,
|
|
3630
|
+
value: inner.value
|
|
3631
|
+
};
|
|
3370
3632
|
} else {
|
|
3371
|
-
return this._def.schema._parseAsync({
|
|
3633
|
+
return this._def.schema._parseAsync({
|
|
3634
|
+
data: ctx.data,
|
|
3635
|
+
path: ctx.path,
|
|
3636
|
+
parent: ctx
|
|
3637
|
+
}).then((inner) => {
|
|
3372
3638
|
if (inner.status === "aborted")
|
|
3373
3639
|
return INVALID;
|
|
3374
3640
|
if (inner.status === "dirty")
|
|
3375
3641
|
status.dirty();
|
|
3376
3642
|
return executeRefinement(inner.value).then(() => {
|
|
3377
|
-
return {
|
|
3643
|
+
return {
|
|
3644
|
+
status: status.value,
|
|
3645
|
+
value: inner.value
|
|
3646
|
+
};
|
|
3378
3647
|
});
|
|
3379
3648
|
});
|
|
3380
3649
|
}
|
|
@@ -3392,19 +3661,29 @@ var ZodEffects = class extends ZodType {
|
|
|
3392
3661
|
if (result instanceof Promise) {
|
|
3393
3662
|
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
3394
3663
|
}
|
|
3395
|
-
return {
|
|
3664
|
+
return {
|
|
3665
|
+
status: status.value,
|
|
3666
|
+
value: result
|
|
3667
|
+
};
|
|
3396
3668
|
} else {
|
|
3397
|
-
return this._def.schema._parseAsync({
|
|
3669
|
+
return this._def.schema._parseAsync({
|
|
3670
|
+
data: ctx.data,
|
|
3671
|
+
path: ctx.path,
|
|
3672
|
+
parent: ctx
|
|
3673
|
+
}).then((base) => {
|
|
3398
3674
|
if (!isValid(base))
|
|
3399
3675
|
return base;
|
|
3400
|
-
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
3676
|
+
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
3677
|
+
status: status.value,
|
|
3678
|
+
value: result
|
|
3679
|
+
}));
|
|
3401
3680
|
});
|
|
3402
3681
|
}
|
|
3403
3682
|
}
|
|
3404
3683
|
util.assertNever(effect);
|
|
3405
3684
|
}
|
|
3406
|
-
};
|
|
3407
|
-
|
|
3685
|
+
}, "ZodEffects");
|
|
3686
|
+
__name2(ZodEffects, "ZodEffects");
|
|
3408
3687
|
ZodEffects.create = (schema, effect, params) => {
|
|
3409
3688
|
return new ZodEffects({
|
|
3410
3689
|
schema,
|
|
@@ -3416,12 +3695,15 @@ ZodEffects.create = (schema, effect, params) => {
|
|
|
3416
3695
|
ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
|
|
3417
3696
|
return new ZodEffects({
|
|
3418
3697
|
schema,
|
|
3419
|
-
effect: {
|
|
3698
|
+
effect: {
|
|
3699
|
+
type: "preprocess",
|
|
3700
|
+
transform: preprocess
|
|
3701
|
+
},
|
|
3420
3702
|
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
|
3421
3703
|
...processCreateParams(params)
|
|
3422
3704
|
});
|
|
3423
3705
|
};
|
|
3424
|
-
var ZodOptional = class extends ZodType {
|
|
3706
|
+
var ZodOptional = /* @__PURE__ */ __name(class extends ZodType {
|
|
3425
3707
|
_parse(input) {
|
|
3426
3708
|
const parsedType = this._getType(input);
|
|
3427
3709
|
if (parsedType === ZodParsedType.undefined) {
|
|
@@ -3432,8 +3714,8 @@ var ZodOptional = class extends ZodType {
|
|
|
3432
3714
|
unwrap() {
|
|
3433
3715
|
return this._def.innerType;
|
|
3434
3716
|
}
|
|
3435
|
-
};
|
|
3436
|
-
|
|
3717
|
+
}, "ZodOptional");
|
|
3718
|
+
__name2(ZodOptional, "ZodOptional");
|
|
3437
3719
|
ZodOptional.create = (type, params) => {
|
|
3438
3720
|
return new ZodOptional({
|
|
3439
3721
|
innerType: type,
|
|
@@ -3441,7 +3723,7 @@ ZodOptional.create = (type, params) => {
|
|
|
3441
3723
|
...processCreateParams(params)
|
|
3442
3724
|
});
|
|
3443
3725
|
};
|
|
3444
|
-
var ZodNullable = class extends ZodType {
|
|
3726
|
+
var ZodNullable = /* @__PURE__ */ __name(class extends ZodType {
|
|
3445
3727
|
_parse(input) {
|
|
3446
3728
|
const parsedType = this._getType(input);
|
|
3447
3729
|
if (parsedType === ZodParsedType.null) {
|
|
@@ -3452,8 +3734,8 @@ var ZodNullable = class extends ZodType {
|
|
|
3452
3734
|
unwrap() {
|
|
3453
3735
|
return this._def.innerType;
|
|
3454
3736
|
}
|
|
3455
|
-
};
|
|
3456
|
-
|
|
3737
|
+
}, "ZodNullable");
|
|
3738
|
+
__name2(ZodNullable, "ZodNullable");
|
|
3457
3739
|
ZodNullable.create = (type, params) => {
|
|
3458
3740
|
return new ZodNullable({
|
|
3459
3741
|
innerType: type,
|
|
@@ -3461,7 +3743,7 @@ ZodNullable.create = (type, params) => {
|
|
|
3461
3743
|
...processCreateParams(params)
|
|
3462
3744
|
});
|
|
3463
3745
|
};
|
|
3464
|
-
var ZodDefault = class extends ZodType {
|
|
3746
|
+
var ZodDefault = /* @__PURE__ */ __name(class extends ZodType {
|
|
3465
3747
|
_parse(input) {
|
|
3466
3748
|
const { ctx } = this._processInputParams(input);
|
|
3467
3749
|
let data = ctx.data;
|
|
@@ -3477,8 +3759,8 @@ var ZodDefault = class extends ZodType {
|
|
|
3477
3759
|
removeDefault() {
|
|
3478
3760
|
return this._def.innerType;
|
|
3479
3761
|
}
|
|
3480
|
-
};
|
|
3481
|
-
|
|
3762
|
+
}, "ZodDefault");
|
|
3763
|
+
__name2(ZodDefault, "ZodDefault");
|
|
3482
3764
|
ZodDefault.create = (type, params) => {
|
|
3483
3765
|
return new ZodDefault({
|
|
3484
3766
|
innerType: type,
|
|
@@ -3487,7 +3769,7 @@ ZodDefault.create = (type, params) => {
|
|
|
3487
3769
|
...processCreateParams(params)
|
|
3488
3770
|
});
|
|
3489
3771
|
};
|
|
3490
|
-
var ZodCatch = class extends ZodType {
|
|
3772
|
+
var ZodCatch = /* @__PURE__ */ __name(class extends ZodType {
|
|
3491
3773
|
_parse(input) {
|
|
3492
3774
|
const { ctx } = this._processInputParams(input);
|
|
3493
3775
|
const newCtx = {
|
|
@@ -3531,8 +3813,8 @@ var ZodCatch = class extends ZodType {
|
|
|
3531
3813
|
removeCatch() {
|
|
3532
3814
|
return this._def.innerType;
|
|
3533
3815
|
}
|
|
3534
|
-
};
|
|
3535
|
-
|
|
3816
|
+
}, "ZodCatch");
|
|
3817
|
+
__name2(ZodCatch, "ZodCatch");
|
|
3536
3818
|
ZodCatch.create = (type, params) => {
|
|
3537
3819
|
return new ZodCatch({
|
|
3538
3820
|
innerType: type,
|
|
@@ -3541,7 +3823,7 @@ ZodCatch.create = (type, params) => {
|
|
|
3541
3823
|
...processCreateParams(params)
|
|
3542
3824
|
});
|
|
3543
3825
|
};
|
|
3544
|
-
var ZodNaN = class extends ZodType {
|
|
3826
|
+
var ZodNaN = /* @__PURE__ */ __name(class extends ZodType {
|
|
3545
3827
|
_parse(input) {
|
|
3546
3828
|
const parsedType = this._getType(input);
|
|
3547
3829
|
if (parsedType !== ZodParsedType.nan) {
|
|
@@ -3553,10 +3835,13 @@ var ZodNaN = class extends ZodType {
|
|
|
3553
3835
|
});
|
|
3554
3836
|
return INVALID;
|
|
3555
3837
|
}
|
|
3556
|
-
return {
|
|
3838
|
+
return {
|
|
3839
|
+
status: "valid",
|
|
3840
|
+
value: input.data
|
|
3841
|
+
};
|
|
3557
3842
|
}
|
|
3558
|
-
};
|
|
3559
|
-
|
|
3843
|
+
}, "ZodNaN");
|
|
3844
|
+
__name2(ZodNaN, "ZodNaN");
|
|
3560
3845
|
ZodNaN.create = (params) => {
|
|
3561
3846
|
return new ZodNaN({
|
|
3562
3847
|
typeName: ZodFirstPartyTypeKind.ZodNaN,
|
|
@@ -3564,7 +3849,7 @@ ZodNaN.create = (params) => {
|
|
|
3564
3849
|
});
|
|
3565
3850
|
};
|
|
3566
3851
|
var BRAND = Symbol("zod_brand");
|
|
3567
|
-
var ZodBranded = class extends ZodType {
|
|
3852
|
+
var ZodBranded = /* @__PURE__ */ __name(class extends ZodType {
|
|
3568
3853
|
_parse(input) {
|
|
3569
3854
|
const { ctx } = this._processInputParams(input);
|
|
3570
3855
|
const data = ctx.data;
|
|
@@ -3577,13 +3862,13 @@ var ZodBranded = class extends ZodType {
|
|
|
3577
3862
|
unwrap() {
|
|
3578
3863
|
return this._def.type;
|
|
3579
3864
|
}
|
|
3580
|
-
};
|
|
3581
|
-
|
|
3582
|
-
var ZodPipeline = class extends ZodType {
|
|
3865
|
+
}, "ZodBranded");
|
|
3866
|
+
__name2(ZodBranded, "ZodBranded");
|
|
3867
|
+
var ZodPipeline = /* @__PURE__ */ __name(class extends ZodType {
|
|
3583
3868
|
_parse(input) {
|
|
3584
3869
|
const { status, ctx } = this._processInputParams(input);
|
|
3585
3870
|
if (ctx.common.async) {
|
|
3586
|
-
const handleAsync = /* @__PURE__ */
|
|
3871
|
+
const handleAsync = /* @__PURE__ */ __name2(async () => {
|
|
3587
3872
|
const inResult = await this._def.in._parseAsync({
|
|
3588
3873
|
data: ctx.data,
|
|
3589
3874
|
path: ctx.path,
|
|
@@ -3633,9 +3918,9 @@ var ZodPipeline = class extends ZodType {
|
|
|
3633
3918
|
typeName: ZodFirstPartyTypeKind.ZodPipeline
|
|
3634
3919
|
});
|
|
3635
3920
|
}
|
|
3636
|
-
};
|
|
3637
|
-
|
|
3638
|
-
var ZodReadonly = class extends ZodType {
|
|
3921
|
+
}, "ZodPipeline");
|
|
3922
|
+
__name2(ZodPipeline, "ZodPipeline");
|
|
3923
|
+
var ZodReadonly = /* @__PURE__ */ __name(class extends ZodType {
|
|
3639
3924
|
_parse(input) {
|
|
3640
3925
|
const result = this._def.innerType._parse(input);
|
|
3641
3926
|
if (isValid(result)) {
|
|
@@ -3643,8 +3928,8 @@ var ZodReadonly = class extends ZodType {
|
|
|
3643
3928
|
}
|
|
3644
3929
|
return result;
|
|
3645
3930
|
}
|
|
3646
|
-
};
|
|
3647
|
-
|
|
3931
|
+
}, "ZodReadonly");
|
|
3932
|
+
__name2(ZodReadonly, "ZodReadonly");
|
|
3648
3933
|
ZodReadonly.create = (type, params) => {
|
|
3649
3934
|
return new ZodReadonly({
|
|
3650
3935
|
innerType: type,
|
|
@@ -3652,15 +3937,23 @@ ZodReadonly.create = (type, params) => {
|
|
|
3652
3937
|
...processCreateParams(params)
|
|
3653
3938
|
});
|
|
3654
3939
|
};
|
|
3655
|
-
var custom = /* @__PURE__ */
|
|
3940
|
+
var custom = /* @__PURE__ */ __name2((check, params = {}, fatal) => {
|
|
3656
3941
|
if (check)
|
|
3657
3942
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
3658
3943
|
var _a, _b;
|
|
3659
3944
|
if (!check(data)) {
|
|
3660
|
-
const p = typeof params === "function" ? params(data) : typeof params === "string" ? {
|
|
3945
|
+
const p = typeof params === "function" ? params(data) : typeof params === "string" ? {
|
|
3946
|
+
message: params
|
|
3947
|
+
} : params;
|
|
3661
3948
|
const _fatal = (_b = (_a = p.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
|
|
3662
|
-
const p2 = typeof p === "string" ? {
|
|
3663
|
-
|
|
3949
|
+
const p2 = typeof p === "string" ? {
|
|
3950
|
+
message: p
|
|
3951
|
+
} : p;
|
|
3952
|
+
ctx.addIssue({
|
|
3953
|
+
code: "custom",
|
|
3954
|
+
...p2,
|
|
3955
|
+
fatal: _fatal
|
|
3956
|
+
});
|
|
3664
3957
|
}
|
|
3665
3958
|
});
|
|
3666
3959
|
return ZodAny.create();
|
|
@@ -3707,7 +4000,7 @@ var ZodFirstPartyTypeKind;
|
|
|
3707
4000
|
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
3708
4001
|
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
3709
4002
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
3710
|
-
var instanceOfType = /* @__PURE__ */
|
|
4003
|
+
var instanceOfType = /* @__PURE__ */ __name2((cls, params = {
|
|
3711
4004
|
message: `Input not instance of ${cls.name}`
|
|
3712
4005
|
}) => custom((data) => data instanceof cls, params), "instanceOfType");
|
|
3713
4006
|
var stringType = ZodString.create;
|
|
@@ -3744,18 +4037,30 @@ var optionalType = ZodOptional.create;
|
|
|
3744
4037
|
var nullableType = ZodNullable.create;
|
|
3745
4038
|
var preprocessType = ZodEffects.createWithPreprocess;
|
|
3746
4039
|
var pipelineType = ZodPipeline.create;
|
|
3747
|
-
var ostring = /* @__PURE__ */
|
|
3748
|
-
var onumber = /* @__PURE__ */
|
|
3749
|
-
var oboolean = /* @__PURE__ */
|
|
4040
|
+
var ostring = /* @__PURE__ */ __name2(() => stringType().optional(), "ostring");
|
|
4041
|
+
var onumber = /* @__PURE__ */ __name2(() => numberType().optional(), "onumber");
|
|
4042
|
+
var oboolean = /* @__PURE__ */ __name2(() => booleanType().optional(), "oboolean");
|
|
3750
4043
|
var coerce = {
|
|
3751
|
-
string: (arg) => ZodString.create({
|
|
3752
|
-
|
|
4044
|
+
string: (arg) => ZodString.create({
|
|
4045
|
+
...arg,
|
|
4046
|
+
coerce: true
|
|
4047
|
+
}),
|
|
4048
|
+
number: (arg) => ZodNumber.create({
|
|
4049
|
+
...arg,
|
|
4050
|
+
coerce: true
|
|
4051
|
+
}),
|
|
3753
4052
|
boolean: (arg) => ZodBoolean.create({
|
|
3754
4053
|
...arg,
|
|
3755
4054
|
coerce: true
|
|
3756
4055
|
}),
|
|
3757
|
-
bigint: (arg) => ZodBigInt.create({
|
|
3758
|
-
|
|
4056
|
+
bigint: (arg) => ZodBigInt.create({
|
|
4057
|
+
...arg,
|
|
4058
|
+
coerce: true
|
|
4059
|
+
}),
|
|
4060
|
+
date: (arg) => ZodDate.create({
|
|
4061
|
+
...arg,
|
|
4062
|
+
coerce: true
|
|
4063
|
+
})
|
|
3759
4064
|
};
|
|
3760
4065
|
var NEVER = INVALID;
|
|
3761
4066
|
var z = /* @__PURE__ */ Object.freeze({
|
|
@@ -3874,11 +4179,11 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
3874
4179
|
ZodError
|
|
3875
4180
|
});
|
|
3876
4181
|
|
|
3877
|
-
// ../core/schemas/video-resource.js
|
|
4182
|
+
// ../core/dist/schemas/video-resource.js
|
|
3878
4183
|
var VideoResourceSchema = z.object({
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
|
|
4184
|
+
id: z.string(),
|
|
4185
|
+
updatedAt: z.string().optional(),
|
|
4186
|
+
createdAt: z.string().optional(),
|
|
3882
4187
|
title: z.string().optional().nullable(),
|
|
3883
4188
|
duration: z.number().optional().nullable(),
|
|
3884
4189
|
muxPlaybackId: z.string().optional().nullable(),
|
|
@@ -3970,9 +4275,9 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
|
|
|
3970
4275
|
}
|
|
3971
4276
|
const query = sql`
|
|
3972
4277
|
SELECT
|
|
3973
|
-
id as
|
|
3974
|
-
CAST(updatedAt AS DATETIME) as
|
|
3975
|
-
CAST(createdAt AS DATETIME) as
|
|
4278
|
+
id as id,
|
|
4279
|
+
CAST(updatedAt AS DATETIME) as updatedAt,
|
|
4280
|
+
CAST(createdAt AS DATETIME) as createdAt,
|
|
3976
4281
|
JSON_EXTRACT (${contentResource.fields}, "$.state") AS state,
|
|
3977
4282
|
JSON_EXTRACT (${contentResource.fields}, "$.duration") AS duration,
|
|
3978
4283
|
JSON_EXTRACT (${contentResource.fields}, "$.muxPlaybackId") AS muxPlaybackId,
|
|
@@ -4081,6 +4386,8 @@ function mySqlDrizzleAdapter(client, tableFn = defaultMySqlTableFn) {
|
|
|
4081
4386
|
async deleteUser(id) {
|
|
4082
4387
|
const user = await client.select().from(users).where(eq(users.id, id)).then((res) => res[0] ?? null);
|
|
4083
4388
|
await client.delete(users).where(eq(users.id, id));
|
|
4389
|
+
await client.delete(sessions).where(eq(sessions.userId, id));
|
|
4390
|
+
await client.delete(accounts).where(eq(accounts.userId, id));
|
|
4084
4391
|
return user;
|
|
4085
4392
|
},
|
|
4086
4393
|
async unlinkAccount(account) {
|
|
@@ -4096,4 +4403,4 @@ export {
|
|
|
4096
4403
|
createTables,
|
|
4097
4404
|
mySqlDrizzleAdapter
|
|
4098
4405
|
};
|
|
4099
|
-
//# sourceMappingURL=chunk-
|
|
4406
|
+
//# sourceMappingURL=chunk-FRNVLW7N.js.map
|