@wise/dynamic-flow-types 2.15.1 → 2.15.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/build/main.js +249 -70
- package/build/main.min.js +1 -1
- package/build/main.mjs +249 -70
- package/build/zod/schemas.d.ts +691 -739
- package/package.json +4 -4
package/build/main.mjs
CHANGED
|
@@ -18,7 +18,7 @@ var __spreadValues = (a, b) => {
|
|
|
18
18
|
};
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
|
|
21
|
-
// ../../node_modules/.pnpm/zod@3.
|
|
21
|
+
// ../../node_modules/.pnpm/zod@3.23.8/node_modules/zod/lib/index.mjs
|
|
22
22
|
var util;
|
|
23
23
|
(function(util2) {
|
|
24
24
|
util2.assertEqual = (val) => val;
|
|
@@ -168,7 +168,7 @@ var quotelessJson = (obj) => {
|
|
|
168
168
|
const json = JSON.stringify(obj, null, 2);
|
|
169
169
|
return json.replace(/"([^"]+)":/g, "$1:");
|
|
170
170
|
};
|
|
171
|
-
var ZodError = class extends Error {
|
|
171
|
+
var ZodError = class _ZodError extends Error {
|
|
172
172
|
constructor(issues) {
|
|
173
173
|
super();
|
|
174
174
|
this.issues = [];
|
|
@@ -226,6 +226,11 @@ var ZodError = class extends Error {
|
|
|
226
226
|
processError(this);
|
|
227
227
|
return fieldErrors;
|
|
228
228
|
}
|
|
229
|
+
static assert(value) {
|
|
230
|
+
if (!(value instanceof _ZodError)) {
|
|
231
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
229
234
|
toString() {
|
|
230
235
|
return this.message;
|
|
231
236
|
}
|
|
@@ -367,6 +372,12 @@ var makeIssue = (params) => {
|
|
|
367
372
|
const fullIssue = __spreadProps(__spreadValues({}, issueData), {
|
|
368
373
|
path: fullPath
|
|
369
374
|
});
|
|
375
|
+
if (issueData.message !== void 0) {
|
|
376
|
+
return __spreadProps(__spreadValues({}, issueData), {
|
|
377
|
+
path: fullPath,
|
|
378
|
+
message: issueData.message
|
|
379
|
+
});
|
|
380
|
+
}
|
|
370
381
|
let errorMessage = "";
|
|
371
382
|
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
372
383
|
for (const map of maps) {
|
|
@@ -374,11 +385,12 @@ var makeIssue = (params) => {
|
|
|
374
385
|
}
|
|
375
386
|
return __spreadProps(__spreadValues({}, issueData), {
|
|
376
387
|
path: fullPath,
|
|
377
|
-
message:
|
|
388
|
+
message: errorMessage
|
|
378
389
|
});
|
|
379
390
|
};
|
|
380
391
|
var EMPTY_PATH = [];
|
|
381
392
|
function addIssueToContext(ctx, issueData) {
|
|
393
|
+
const overrideMap = getErrorMap();
|
|
382
394
|
const issue = makeIssue({
|
|
383
395
|
issueData,
|
|
384
396
|
data: ctx.data,
|
|
@@ -386,8 +398,8 @@ function addIssueToContext(ctx, issueData) {
|
|
|
386
398
|
errorMaps: [
|
|
387
399
|
ctx.common.contextualErrorMap,
|
|
388
400
|
ctx.schemaErrorMap,
|
|
389
|
-
|
|
390
|
-
errorMap
|
|
401
|
+
overrideMap,
|
|
402
|
+
overrideMap === errorMap ? void 0 : errorMap
|
|
391
403
|
// then global default map
|
|
392
404
|
].filter((x) => !!x)
|
|
393
405
|
});
|
|
@@ -419,9 +431,11 @@ var ParseStatus = class _ParseStatus {
|
|
|
419
431
|
static async mergeObjectAsync(status, pairs) {
|
|
420
432
|
const syncPairs = [];
|
|
421
433
|
for (const pair of pairs) {
|
|
434
|
+
const key = await pair.key;
|
|
435
|
+
const value = await pair.value;
|
|
422
436
|
syncPairs.push({
|
|
423
|
-
key
|
|
424
|
-
value
|
|
437
|
+
key,
|
|
438
|
+
value
|
|
425
439
|
});
|
|
426
440
|
}
|
|
427
441
|
return _ParseStatus.mergeObjectSync(status, syncPairs);
|
|
@@ -454,11 +468,29 @@ var isAborted = (x) => x.status === "aborted";
|
|
|
454
468
|
var isDirty = (x) => x.status === "dirty";
|
|
455
469
|
var isValid = (x) => x.status === "valid";
|
|
456
470
|
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
471
|
+
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
472
|
+
if (kind === "a" && !f)
|
|
473
|
+
throw new TypeError("Private accessor was defined without a getter");
|
|
474
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
475
|
+
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
476
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
477
|
+
}
|
|
478
|
+
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
479
|
+
if (kind === "m")
|
|
480
|
+
throw new TypeError("Private method is not writable");
|
|
481
|
+
if (kind === "a" && !f)
|
|
482
|
+
throw new TypeError("Private accessor was defined without a setter");
|
|
483
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver))
|
|
484
|
+
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
485
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
486
|
+
}
|
|
457
487
|
var errorUtil;
|
|
458
488
|
(function(errorUtil2) {
|
|
459
489
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
460
490
|
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
461
491
|
})(errorUtil || (errorUtil = {}));
|
|
492
|
+
var _ZodEnum_cache;
|
|
493
|
+
var _ZodNativeEnum_cache;
|
|
462
494
|
var ParseInputLazyPath = class {
|
|
463
495
|
constructor(parent, value, path, key) {
|
|
464
496
|
this._cachedPath = [];
|
|
@@ -507,12 +539,17 @@ function processCreateParams(params) {
|
|
|
507
539
|
if (errorMap2)
|
|
508
540
|
return { errorMap: errorMap2, description };
|
|
509
541
|
const customMap = (iss, ctx) => {
|
|
510
|
-
|
|
511
|
-
|
|
542
|
+
var _a, _b;
|
|
543
|
+
const { message } = params;
|
|
544
|
+
if (iss.code === "invalid_enum_value") {
|
|
545
|
+
return { message: message !== null && message !== void 0 ? message : ctx.defaultError };
|
|
546
|
+
}
|
|
512
547
|
if (typeof ctx.data === "undefined") {
|
|
513
|
-
return { message:
|
|
548
|
+
return { message: (_a = message !== null && message !== void 0 ? message : required_error) !== null && _a !== void 0 ? _a : ctx.defaultError };
|
|
514
549
|
}
|
|
515
|
-
|
|
550
|
+
if (iss.code !== "invalid_type")
|
|
551
|
+
return { message: ctx.defaultError };
|
|
552
|
+
return { message: (_b = message !== null && message !== void 0 ? message : invalid_type_error) !== null && _b !== void 0 ? _b : ctx.defaultError };
|
|
516
553
|
};
|
|
517
554
|
return { errorMap: customMap, description };
|
|
518
555
|
}
|
|
@@ -754,35 +791,40 @@ var ZodType = class {
|
|
|
754
791
|
}
|
|
755
792
|
};
|
|
756
793
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
757
|
-
var cuid2Regex = /^[
|
|
794
|
+
var cuid2Regex = /^[0-9a-z]+$/;
|
|
758
795
|
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/;
|
|
759
796
|
var uuidRegex = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i;
|
|
760
|
-
var
|
|
797
|
+
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
798
|
+
var durationRegex = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/;
|
|
799
|
+
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
761
800
|
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
762
801
|
var emojiRegex;
|
|
763
|
-
var ipv4Regex = /^((
|
|
802
|
+
var ipv4Regex = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/;
|
|
764
803
|
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})))$/;
|
|
765
|
-
var
|
|
804
|
+
var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
805
|
+
var dateRegexSource = `((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))`;
|
|
806
|
+
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
807
|
+
function timeRegexSource(args) {
|
|
808
|
+
let regex = `([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d`;
|
|
766
809
|
if (args.precision) {
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${args.precision}}Z$`);
|
|
771
|
-
}
|
|
772
|
-
} else if (args.precision === 0) {
|
|
773
|
-
if (args.offset) {
|
|
774
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
775
|
-
} else {
|
|
776
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$`);
|
|
777
|
-
}
|
|
778
|
-
} else {
|
|
779
|
-
if (args.offset) {
|
|
780
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$`);
|
|
781
|
-
} else {
|
|
782
|
-
return new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$`);
|
|
783
|
-
}
|
|
810
|
+
regex = `${regex}\\.\\d{${args.precision}}`;
|
|
811
|
+
} else if (args.precision == null) {
|
|
812
|
+
regex = `${regex}(\\.\\d+)?`;
|
|
784
813
|
}
|
|
785
|
-
|
|
814
|
+
return regex;
|
|
815
|
+
}
|
|
816
|
+
function timeRegex(args) {
|
|
817
|
+
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
818
|
+
}
|
|
819
|
+
function datetimeRegex(args) {
|
|
820
|
+
let regex = `${dateRegexSource}T${timeRegexSource(args)}`;
|
|
821
|
+
const opts = [];
|
|
822
|
+
opts.push(args.local ? `Z?` : `Z`);
|
|
823
|
+
if (args.offset)
|
|
824
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
825
|
+
regex = `${regex}(${opts.join("|")})`;
|
|
826
|
+
return new RegExp(`^${regex}$`);
|
|
827
|
+
}
|
|
786
828
|
function isValidIP(ip, version) {
|
|
787
829
|
if ((version === "v4" || !version) && ipv4Regex.test(ip)) {
|
|
788
830
|
return true;
|
|
@@ -800,15 +842,11 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
800
842
|
const parsedType = this._getType(input);
|
|
801
843
|
if (parsedType !== ZodParsedType.string) {
|
|
802
844
|
const ctx2 = this._getOrReturnCtx(input);
|
|
803
|
-
addIssueToContext(
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
received: ctx2.parsedType
|
|
809
|
-
}
|
|
810
|
-
//
|
|
811
|
-
);
|
|
845
|
+
addIssueToContext(ctx2, {
|
|
846
|
+
code: ZodIssueCode.invalid_type,
|
|
847
|
+
expected: ZodParsedType.string,
|
|
848
|
+
received: ctx2.parsedType
|
|
849
|
+
});
|
|
812
850
|
return INVALID;
|
|
813
851
|
}
|
|
814
852
|
const status = new ParseStatus();
|
|
@@ -899,6 +937,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
899
937
|
});
|
|
900
938
|
status.dirty();
|
|
901
939
|
}
|
|
940
|
+
} else if (check.kind === "nanoid") {
|
|
941
|
+
if (!nanoidRegex.test(input.data)) {
|
|
942
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
943
|
+
addIssueToContext(ctx, {
|
|
944
|
+
validation: "nanoid",
|
|
945
|
+
code: ZodIssueCode.invalid_string,
|
|
946
|
+
message: check.message
|
|
947
|
+
});
|
|
948
|
+
status.dirty();
|
|
949
|
+
}
|
|
902
950
|
} else if (check.kind === "cuid") {
|
|
903
951
|
if (!cuidRegex.test(input.data)) {
|
|
904
952
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -1000,6 +1048,38 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1000
1048
|
});
|
|
1001
1049
|
status.dirty();
|
|
1002
1050
|
}
|
|
1051
|
+
} else if (check.kind === "date") {
|
|
1052
|
+
const regex = dateRegex;
|
|
1053
|
+
if (!regex.test(input.data)) {
|
|
1054
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1055
|
+
addIssueToContext(ctx, {
|
|
1056
|
+
code: ZodIssueCode.invalid_string,
|
|
1057
|
+
validation: "date",
|
|
1058
|
+
message: check.message
|
|
1059
|
+
});
|
|
1060
|
+
status.dirty();
|
|
1061
|
+
}
|
|
1062
|
+
} else if (check.kind === "time") {
|
|
1063
|
+
const regex = timeRegex(check);
|
|
1064
|
+
if (!regex.test(input.data)) {
|
|
1065
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1066
|
+
addIssueToContext(ctx, {
|
|
1067
|
+
code: ZodIssueCode.invalid_string,
|
|
1068
|
+
validation: "time",
|
|
1069
|
+
message: check.message
|
|
1070
|
+
});
|
|
1071
|
+
status.dirty();
|
|
1072
|
+
}
|
|
1073
|
+
} else if (check.kind === "duration") {
|
|
1074
|
+
if (!durationRegex.test(input.data)) {
|
|
1075
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1076
|
+
addIssueToContext(ctx, {
|
|
1077
|
+
validation: "duration",
|
|
1078
|
+
code: ZodIssueCode.invalid_string,
|
|
1079
|
+
message: check.message
|
|
1080
|
+
});
|
|
1081
|
+
status.dirty();
|
|
1082
|
+
}
|
|
1003
1083
|
} else if (check.kind === "ip") {
|
|
1004
1084
|
if (!isValidIP(input.data, check.version)) {
|
|
1005
1085
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -1010,6 +1090,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1010
1090
|
});
|
|
1011
1091
|
status.dirty();
|
|
1012
1092
|
}
|
|
1093
|
+
} else if (check.kind === "base64") {
|
|
1094
|
+
if (!base64Regex.test(input.data)) {
|
|
1095
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1096
|
+
addIssueToContext(ctx, {
|
|
1097
|
+
validation: "base64",
|
|
1098
|
+
code: ZodIssueCode.invalid_string,
|
|
1099
|
+
message: check.message
|
|
1100
|
+
});
|
|
1101
|
+
status.dirty();
|
|
1102
|
+
}
|
|
1013
1103
|
} else {
|
|
1014
1104
|
util.assertNever(check);
|
|
1015
1105
|
}
|
|
@@ -1039,6 +1129,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1039
1129
|
uuid(message) {
|
|
1040
1130
|
return this._addCheck(__spreadValues({ kind: "uuid" }, errorUtil.errToObj(message)));
|
|
1041
1131
|
}
|
|
1132
|
+
nanoid(message) {
|
|
1133
|
+
return this._addCheck(__spreadValues({ kind: "nanoid" }, errorUtil.errToObj(message)));
|
|
1134
|
+
}
|
|
1042
1135
|
cuid(message) {
|
|
1043
1136
|
return this._addCheck(__spreadValues({ kind: "cuid" }, errorUtil.errToObj(message)));
|
|
1044
1137
|
}
|
|
@@ -1048,25 +1141,49 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1048
1141
|
ulid(message) {
|
|
1049
1142
|
return this._addCheck(__spreadValues({ kind: "ulid" }, errorUtil.errToObj(message)));
|
|
1050
1143
|
}
|
|
1144
|
+
base64(message) {
|
|
1145
|
+
return this._addCheck(__spreadValues({ kind: "base64" }, errorUtil.errToObj(message)));
|
|
1146
|
+
}
|
|
1051
1147
|
ip(options) {
|
|
1052
1148
|
return this._addCheck(__spreadValues({ kind: "ip" }, errorUtil.errToObj(options)));
|
|
1053
1149
|
}
|
|
1054
1150
|
datetime(options) {
|
|
1055
|
-
var _a;
|
|
1151
|
+
var _a, _b;
|
|
1056
1152
|
if (typeof options === "string") {
|
|
1057
1153
|
return this._addCheck({
|
|
1058
1154
|
kind: "datetime",
|
|
1059
1155
|
precision: null,
|
|
1060
1156
|
offset: false,
|
|
1157
|
+
local: false,
|
|
1061
1158
|
message: options
|
|
1062
1159
|
});
|
|
1063
1160
|
}
|
|
1064
1161
|
return this._addCheck(__spreadValues({
|
|
1065
1162
|
kind: "datetime",
|
|
1066
1163
|
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision,
|
|
1067
|
-
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false
|
|
1164
|
+
offset: (_a = options === null || options === void 0 ? void 0 : options.offset) !== null && _a !== void 0 ? _a : false,
|
|
1165
|
+
local: (_b = options === null || options === void 0 ? void 0 : options.local) !== null && _b !== void 0 ? _b : false
|
|
1166
|
+
}, errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)));
|
|
1167
|
+
}
|
|
1168
|
+
date(message) {
|
|
1169
|
+
return this._addCheck({ kind: "date", message });
|
|
1170
|
+
}
|
|
1171
|
+
time(options) {
|
|
1172
|
+
if (typeof options === "string") {
|
|
1173
|
+
return this._addCheck({
|
|
1174
|
+
kind: "time",
|
|
1175
|
+
precision: null,
|
|
1176
|
+
message: options
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
return this._addCheck(__spreadValues({
|
|
1180
|
+
kind: "time",
|
|
1181
|
+
precision: typeof (options === null || options === void 0 ? void 0 : options.precision) === "undefined" ? null : options === null || options === void 0 ? void 0 : options.precision
|
|
1068
1182
|
}, errorUtil.errToObj(options === null || options === void 0 ? void 0 : options.message)));
|
|
1069
1183
|
}
|
|
1184
|
+
duration(message) {
|
|
1185
|
+
return this._addCheck(__spreadValues({ kind: "duration" }, errorUtil.errToObj(message)));
|
|
1186
|
+
}
|
|
1070
1187
|
regex(regex, message) {
|
|
1071
1188
|
return this._addCheck(__spreadValues({
|
|
1072
1189
|
kind: "regex",
|
|
@@ -1135,6 +1252,15 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1135
1252
|
get isDatetime() {
|
|
1136
1253
|
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
1137
1254
|
}
|
|
1255
|
+
get isDate() {
|
|
1256
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
1257
|
+
}
|
|
1258
|
+
get isTime() {
|
|
1259
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
1260
|
+
}
|
|
1261
|
+
get isDuration() {
|
|
1262
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
1263
|
+
}
|
|
1138
1264
|
get isEmail() {
|
|
1139
1265
|
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
1140
1266
|
}
|
|
@@ -1147,6 +1273,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1147
1273
|
get isUUID() {
|
|
1148
1274
|
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
1149
1275
|
}
|
|
1276
|
+
get isNANOID() {
|
|
1277
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
1278
|
+
}
|
|
1150
1279
|
get isCUID() {
|
|
1151
1280
|
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
1152
1281
|
}
|
|
@@ -1159,6 +1288,9 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1159
1288
|
get isIP() {
|
|
1160
1289
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
1161
1290
|
}
|
|
1291
|
+
get isBase64() {
|
|
1292
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
1293
|
+
}
|
|
1162
1294
|
get minLength() {
|
|
1163
1295
|
let min = null;
|
|
1164
1296
|
for (const ch of this._def.checks) {
|
|
@@ -2049,9 +2181,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2049
2181
|
const syncPairs = [];
|
|
2050
2182
|
for (const pair of pairs) {
|
|
2051
2183
|
const key = await pair.key;
|
|
2184
|
+
const value = await pair.value;
|
|
2052
2185
|
syncPairs.push({
|
|
2053
2186
|
key,
|
|
2054
|
-
value
|
|
2187
|
+
value,
|
|
2055
2188
|
alwaysSet: pair.alwaysSet
|
|
2056
2189
|
});
|
|
2057
2190
|
}
|
|
@@ -2378,15 +2511,25 @@ var getDiscriminator = (type) => {
|
|
|
2378
2511
|
} else if (type instanceof ZodEnum) {
|
|
2379
2512
|
return type.options;
|
|
2380
2513
|
} else if (type instanceof ZodNativeEnum) {
|
|
2381
|
-
return
|
|
2514
|
+
return util.objectValues(type.enum);
|
|
2382
2515
|
} else if (type instanceof ZodDefault) {
|
|
2383
2516
|
return getDiscriminator(type._def.innerType);
|
|
2384
2517
|
} else if (type instanceof ZodUndefined) {
|
|
2385
2518
|
return [void 0];
|
|
2386
2519
|
} else if (type instanceof ZodNull) {
|
|
2387
2520
|
return [null];
|
|
2521
|
+
} else if (type instanceof ZodOptional) {
|
|
2522
|
+
return [void 0, ...getDiscriminator(type.unwrap())];
|
|
2523
|
+
} else if (type instanceof ZodNullable) {
|
|
2524
|
+
return [null, ...getDiscriminator(type.unwrap())];
|
|
2525
|
+
} else if (type instanceof ZodBranded) {
|
|
2526
|
+
return getDiscriminator(type.unwrap());
|
|
2527
|
+
} else if (type instanceof ZodReadonly) {
|
|
2528
|
+
return getDiscriminator(type.unwrap());
|
|
2529
|
+
} else if (type instanceof ZodCatch) {
|
|
2530
|
+
return getDiscriminator(type._def.innerType);
|
|
2388
2531
|
} else {
|
|
2389
|
-
return
|
|
2532
|
+
return [];
|
|
2390
2533
|
}
|
|
2391
2534
|
};
|
|
2392
2535
|
var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
@@ -2446,7 +2589,7 @@ var ZodDiscriminatedUnion = class _ZodDiscriminatedUnion extends ZodType {
|
|
|
2446
2589
|
const optionsMap = /* @__PURE__ */ new Map();
|
|
2447
2590
|
for (const type of options) {
|
|
2448
2591
|
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
2449
|
-
if (!discriminatorValues) {
|
|
2592
|
+
if (!discriminatorValues.length) {
|
|
2450
2593
|
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
2451
2594
|
}
|
|
2452
2595
|
for (const value of discriminatorValues) {
|
|
@@ -2642,7 +2785,8 @@ var ZodRecord = class _ZodRecord extends ZodType {
|
|
|
2642
2785
|
for (const key in ctx.data) {
|
|
2643
2786
|
pairs.push({
|
|
2644
2787
|
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
2645
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key))
|
|
2788
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
|
2789
|
+
alwaysSet: key in ctx.data
|
|
2646
2790
|
});
|
|
2647
2791
|
}
|
|
2648
2792
|
if (ctx.common.async) {
|
|
@@ -2974,6 +3118,10 @@ function createZodEnum(values, params) {
|
|
|
2974
3118
|
}, processCreateParams(params)));
|
|
2975
3119
|
}
|
|
2976
3120
|
var ZodEnum = class _ZodEnum extends ZodType {
|
|
3121
|
+
constructor() {
|
|
3122
|
+
super(...arguments);
|
|
3123
|
+
_ZodEnum_cache.set(this, void 0);
|
|
3124
|
+
}
|
|
2977
3125
|
_parse(input) {
|
|
2978
3126
|
if (typeof input.data !== "string") {
|
|
2979
3127
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -2985,7 +3133,10 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
2985
3133
|
});
|
|
2986
3134
|
return INVALID;
|
|
2987
3135
|
}
|
|
2988
|
-
if (this
|
|
3136
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f")) {
|
|
3137
|
+
__classPrivateFieldSet(this, _ZodEnum_cache, new Set(this._def.values), "f");
|
|
3138
|
+
}
|
|
3139
|
+
if (!__classPrivateFieldGet(this, _ZodEnum_cache, "f").has(input.data)) {
|
|
2989
3140
|
const ctx = this._getOrReturnCtx(input);
|
|
2990
3141
|
const expectedValues = this._def.values;
|
|
2991
3142
|
addIssueToContext(ctx, {
|
|
@@ -3021,15 +3172,20 @@ var ZodEnum = class _ZodEnum extends ZodType {
|
|
|
3021
3172
|
}
|
|
3022
3173
|
return enumValues;
|
|
3023
3174
|
}
|
|
3024
|
-
extract(values) {
|
|
3025
|
-
return _ZodEnum.create(values);
|
|
3175
|
+
extract(values, newDef = this._def) {
|
|
3176
|
+
return _ZodEnum.create(values, __spreadValues(__spreadValues({}, this._def), newDef));
|
|
3026
3177
|
}
|
|
3027
|
-
exclude(values) {
|
|
3028
|
-
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)));
|
|
3178
|
+
exclude(values, newDef = this._def) {
|
|
3179
|
+
return _ZodEnum.create(this.options.filter((opt) => !values.includes(opt)), __spreadValues(__spreadValues({}, this._def), newDef));
|
|
3029
3180
|
}
|
|
3030
3181
|
};
|
|
3182
|
+
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3031
3183
|
ZodEnum.create = createZodEnum;
|
|
3032
3184
|
var ZodNativeEnum = class extends ZodType {
|
|
3185
|
+
constructor() {
|
|
3186
|
+
super(...arguments);
|
|
3187
|
+
_ZodNativeEnum_cache.set(this, void 0);
|
|
3188
|
+
}
|
|
3033
3189
|
_parse(input) {
|
|
3034
3190
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3035
3191
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3042,7 +3198,10 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3042
3198
|
});
|
|
3043
3199
|
return INVALID;
|
|
3044
3200
|
}
|
|
3045
|
-
if (
|
|
3201
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f")) {
|
|
3202
|
+
__classPrivateFieldSet(this, _ZodNativeEnum_cache, new Set(util.getValidEnumValues(this._def.values)), "f");
|
|
3203
|
+
}
|
|
3204
|
+
if (!__classPrivateFieldGet(this, _ZodNativeEnum_cache, "f").has(input.data)) {
|
|
3046
3205
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3047
3206
|
addIssueToContext(ctx, {
|
|
3048
3207
|
received: ctx.data,
|
|
@@ -3057,6 +3216,7 @@ var ZodNativeEnum = class extends ZodType {
|
|
|
3057
3216
|
return this._def.values;
|
|
3058
3217
|
}
|
|
3059
3218
|
};
|
|
3219
|
+
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3060
3220
|
ZodNativeEnum.create = (values, params) => {
|
|
3061
3221
|
return new ZodNativeEnum(__spreadValues({
|
|
3062
3222
|
values,
|
|
@@ -3118,26 +3278,38 @@ var ZodEffects = class extends ZodType {
|
|
|
3118
3278
|
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
3119
3279
|
if (effect.type === "preprocess") {
|
|
3120
3280
|
const processed = effect.transform(ctx.data, checkCtx);
|
|
3121
|
-
if (ctx.common.issues.length) {
|
|
3122
|
-
return {
|
|
3123
|
-
status: "dirty",
|
|
3124
|
-
value: ctx.data
|
|
3125
|
-
};
|
|
3126
|
-
}
|
|
3127
3281
|
if (ctx.common.async) {
|
|
3128
|
-
return Promise.resolve(processed).then((processed2) => {
|
|
3129
|
-
|
|
3282
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
|
3283
|
+
if (status.value === "aborted")
|
|
3284
|
+
return INVALID;
|
|
3285
|
+
const result = await this._def.schema._parseAsync({
|
|
3130
3286
|
data: processed2,
|
|
3131
3287
|
path: ctx.path,
|
|
3132
3288
|
parent: ctx
|
|
3133
3289
|
});
|
|
3290
|
+
if (result.status === "aborted")
|
|
3291
|
+
return INVALID;
|
|
3292
|
+
if (result.status === "dirty")
|
|
3293
|
+
return DIRTY(result.value);
|
|
3294
|
+
if (status.value === "dirty")
|
|
3295
|
+
return DIRTY(result.value);
|
|
3296
|
+
return result;
|
|
3134
3297
|
});
|
|
3135
3298
|
} else {
|
|
3136
|
-
|
|
3299
|
+
if (status.value === "aborted")
|
|
3300
|
+
return INVALID;
|
|
3301
|
+
const result = this._def.schema._parseSync({
|
|
3137
3302
|
data: processed,
|
|
3138
3303
|
path: ctx.path,
|
|
3139
3304
|
parent: ctx
|
|
3140
3305
|
});
|
|
3306
|
+
if (result.status === "aborted")
|
|
3307
|
+
return INVALID;
|
|
3308
|
+
if (result.status === "dirty")
|
|
3309
|
+
return DIRTY(result.value);
|
|
3310
|
+
if (status.value === "dirty")
|
|
3311
|
+
return DIRTY(result.value);
|
|
3312
|
+
return result;
|
|
3141
3313
|
}
|
|
3142
3314
|
}
|
|
3143
3315
|
if (effect.type === "refinement") {
|
|
@@ -3415,10 +3587,16 @@ var ZodPipeline = class _ZodPipeline extends ZodType {
|
|
|
3415
3587
|
var ZodReadonly = class extends ZodType {
|
|
3416
3588
|
_parse(input) {
|
|
3417
3589
|
const result = this._def.innerType._parse(input);
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3421
|
-
|
|
3590
|
+
const freeze = (data) => {
|
|
3591
|
+
if (isValid(data)) {
|
|
3592
|
+
data.value = Object.freeze(data.value);
|
|
3593
|
+
}
|
|
3594
|
+
return data;
|
|
3595
|
+
};
|
|
3596
|
+
return isAsync(result) ? result.then((data) => freeze(data)) : freeze(result);
|
|
3597
|
+
}
|
|
3598
|
+
unwrap() {
|
|
3599
|
+
return this._def.innerType;
|
|
3422
3600
|
}
|
|
3423
3601
|
};
|
|
3424
3602
|
ZodReadonly.create = (type, params) => {
|
|
@@ -3427,7 +3605,7 @@ ZodReadonly.create = (type, params) => {
|
|
|
3427
3605
|
typeName: ZodFirstPartyTypeKind.ZodReadonly
|
|
3428
3606
|
}, processCreateParams(params)));
|
|
3429
3607
|
};
|
|
3430
|
-
|
|
3608
|
+
function custom(check, params = {}, fatal) {
|
|
3431
3609
|
if (check)
|
|
3432
3610
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
3433
3611
|
var _a, _b;
|
|
@@ -3439,7 +3617,7 @@ var custom = (check, params = {}, fatal) => {
|
|
|
3439
3617
|
}
|
|
3440
3618
|
});
|
|
3441
3619
|
return ZodAny.create();
|
|
3442
|
-
}
|
|
3620
|
+
}
|
|
3443
3621
|
var late = {
|
|
3444
3622
|
object: ZodObject.lazycreate
|
|
3445
3623
|
};
|
|
@@ -3557,6 +3735,7 @@ var z = /* @__PURE__ */ Object.freeze({
|
|
|
3557
3735
|
ZodParsedType,
|
|
3558
3736
|
getParsedType,
|
|
3559
3737
|
ZodType,
|
|
3738
|
+
datetimeRegex,
|
|
3560
3739
|
ZodString,
|
|
3561
3740
|
ZodNumber,
|
|
3562
3741
|
ZodBigInt,
|