@schemavaults/app-definitions 0.6.16 → 0.6.18
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/get-app-environment.cjs +392 -247
- package/dist/index.cjs +430 -285
- package/package.json +2 -2
|
@@ -38,10 +38,123 @@ function isBrowser() {
|
|
|
38
38
|
return isWindowGlobalVariableSet;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
// ../../node_modules/.bun/zod@3.
|
|
41
|
+
// ../../node_modules/.bun/zod@3.25.8/node_modules/zod/dist/esm/v3/external.js
|
|
42
|
+
var external_exports = {};
|
|
43
|
+
__export(external_exports, {
|
|
44
|
+
BRAND: () => BRAND,
|
|
45
|
+
DIRTY: () => DIRTY,
|
|
46
|
+
EMPTY_PATH: () => EMPTY_PATH,
|
|
47
|
+
INVALID: () => INVALID,
|
|
48
|
+
NEVER: () => NEVER,
|
|
49
|
+
OK: () => OK,
|
|
50
|
+
ParseStatus: () => ParseStatus,
|
|
51
|
+
Schema: () => ZodType,
|
|
52
|
+
ZodAny: () => ZodAny,
|
|
53
|
+
ZodArray: () => ZodArray,
|
|
54
|
+
ZodBigInt: () => ZodBigInt,
|
|
55
|
+
ZodBoolean: () => ZodBoolean,
|
|
56
|
+
ZodBranded: () => ZodBranded,
|
|
57
|
+
ZodCatch: () => ZodCatch,
|
|
58
|
+
ZodDate: () => ZodDate,
|
|
59
|
+
ZodDefault: () => ZodDefault,
|
|
60
|
+
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion,
|
|
61
|
+
ZodEffects: () => ZodEffects,
|
|
62
|
+
ZodEnum: () => ZodEnum,
|
|
63
|
+
ZodError: () => ZodError,
|
|
64
|
+
ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind,
|
|
65
|
+
ZodFunction: () => ZodFunction,
|
|
66
|
+
ZodIntersection: () => ZodIntersection,
|
|
67
|
+
ZodIssueCode: () => ZodIssueCode,
|
|
68
|
+
ZodLazy: () => ZodLazy,
|
|
69
|
+
ZodLiteral: () => ZodLiteral,
|
|
70
|
+
ZodMap: () => ZodMap,
|
|
71
|
+
ZodNaN: () => ZodNaN,
|
|
72
|
+
ZodNativeEnum: () => ZodNativeEnum,
|
|
73
|
+
ZodNever: () => ZodNever,
|
|
74
|
+
ZodNull: () => ZodNull,
|
|
75
|
+
ZodNullable: () => ZodNullable,
|
|
76
|
+
ZodNumber: () => ZodNumber,
|
|
77
|
+
ZodObject: () => ZodObject,
|
|
78
|
+
ZodOptional: () => ZodOptional,
|
|
79
|
+
ZodParsedType: () => ZodParsedType,
|
|
80
|
+
ZodPipeline: () => ZodPipeline,
|
|
81
|
+
ZodPromise: () => ZodPromise,
|
|
82
|
+
ZodReadonly: () => ZodReadonly,
|
|
83
|
+
ZodRecord: () => ZodRecord,
|
|
84
|
+
ZodSchema: () => ZodType,
|
|
85
|
+
ZodSet: () => ZodSet,
|
|
86
|
+
ZodString: () => ZodString,
|
|
87
|
+
ZodSymbol: () => ZodSymbol,
|
|
88
|
+
ZodTransformer: () => ZodEffects,
|
|
89
|
+
ZodTuple: () => ZodTuple,
|
|
90
|
+
ZodType: () => ZodType,
|
|
91
|
+
ZodUndefined: () => ZodUndefined,
|
|
92
|
+
ZodUnion: () => ZodUnion,
|
|
93
|
+
ZodUnknown: () => ZodUnknown,
|
|
94
|
+
ZodVoid: () => ZodVoid,
|
|
95
|
+
addIssueToContext: () => addIssueToContext,
|
|
96
|
+
any: () => anyType,
|
|
97
|
+
array: () => arrayType,
|
|
98
|
+
bigint: () => bigIntType,
|
|
99
|
+
boolean: () => booleanType,
|
|
100
|
+
coerce: () => coerce,
|
|
101
|
+
custom: () => custom,
|
|
102
|
+
date: () => dateType,
|
|
103
|
+
datetimeRegex: () => datetimeRegex,
|
|
104
|
+
defaultErrorMap: () => en_default,
|
|
105
|
+
discriminatedUnion: () => discriminatedUnionType,
|
|
106
|
+
effect: () => effectsType,
|
|
107
|
+
enum: () => enumType,
|
|
108
|
+
function: () => functionType,
|
|
109
|
+
getErrorMap: () => getErrorMap,
|
|
110
|
+
getParsedType: () => getParsedType,
|
|
111
|
+
instanceof: () => instanceOfType,
|
|
112
|
+
intersection: () => intersectionType,
|
|
113
|
+
isAborted: () => isAborted,
|
|
114
|
+
isAsync: () => isAsync,
|
|
115
|
+
isDirty: () => isDirty,
|
|
116
|
+
isValid: () => isValid,
|
|
117
|
+
late: () => late,
|
|
118
|
+
lazy: () => lazyType,
|
|
119
|
+
literal: () => literalType,
|
|
120
|
+
makeIssue: () => makeIssue,
|
|
121
|
+
map: () => mapType,
|
|
122
|
+
nan: () => nanType,
|
|
123
|
+
nativeEnum: () => nativeEnumType,
|
|
124
|
+
never: () => neverType,
|
|
125
|
+
null: () => nullType,
|
|
126
|
+
nullable: () => nullableType,
|
|
127
|
+
number: () => numberType,
|
|
128
|
+
object: () => objectType,
|
|
129
|
+
objectUtil: () => objectUtil,
|
|
130
|
+
oboolean: () => oboolean,
|
|
131
|
+
onumber: () => onumber,
|
|
132
|
+
optional: () => optionalType,
|
|
133
|
+
ostring: () => ostring,
|
|
134
|
+
pipeline: () => pipelineType,
|
|
135
|
+
preprocess: () => preprocessType,
|
|
136
|
+
promise: () => promiseType,
|
|
137
|
+
quotelessJson: () => quotelessJson,
|
|
138
|
+
record: () => recordType,
|
|
139
|
+
set: () => setType,
|
|
140
|
+
setErrorMap: () => setErrorMap,
|
|
141
|
+
strictObject: () => strictObjectType,
|
|
142
|
+
string: () => stringType,
|
|
143
|
+
symbol: () => symbolType,
|
|
144
|
+
transformer: () => effectsType,
|
|
145
|
+
tuple: () => tupleType,
|
|
146
|
+
undefined: () => undefinedType,
|
|
147
|
+
union: () => unionType,
|
|
148
|
+
unknown: () => unknownType,
|
|
149
|
+
util: () => util,
|
|
150
|
+
void: () => voidType
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// ../../node_modules/.bun/zod@3.25.8/node_modules/zod/dist/esm/v3/helpers/util.js
|
|
42
154
|
var util;
|
|
43
155
|
(function(util2) {
|
|
44
|
-
util2.assertEqual = (
|
|
156
|
+
util2.assertEqual = (_) => {
|
|
157
|
+
};
|
|
45
158
|
function assertIs(_arg) {
|
|
46
159
|
}
|
|
47
160
|
util2.assertIs = assertIs;
|
|
@@ -85,7 +198,7 @@ var util;
|
|
|
85
198
|
}
|
|
86
199
|
return void 0;
|
|
87
200
|
};
|
|
88
|
-
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
|
|
201
|
+
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
89
202
|
function joinValues(array, separator = " | ") {
|
|
90
203
|
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
91
204
|
}
|
|
@@ -137,7 +250,7 @@ var getParsedType = (data) => {
|
|
|
137
250
|
case "string":
|
|
138
251
|
return ZodParsedType.string;
|
|
139
252
|
case "number":
|
|
140
|
-
return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
253
|
+
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
141
254
|
case "boolean":
|
|
142
255
|
return ZodParsedType.boolean;
|
|
143
256
|
case "function":
|
|
@@ -170,6 +283,8 @@ var getParsedType = (data) => {
|
|
|
170
283
|
return ZodParsedType.unknown;
|
|
171
284
|
}
|
|
172
285
|
};
|
|
286
|
+
|
|
287
|
+
// ../../node_modules/.bun/zod@3.25.8/node_modules/zod/dist/esm/v3/ZodError.js
|
|
173
288
|
var ZodIssueCode = util.arrayToEnum([
|
|
174
289
|
"invalid_type",
|
|
175
290
|
"invalid_literal",
|
|
@@ -193,6 +308,9 @@ var quotelessJson = (obj) => {
|
|
|
193
308
|
return json.replace(/"([^"]+)":/g, "$1:");
|
|
194
309
|
};
|
|
195
310
|
var ZodError = class _ZodError extends Error {
|
|
311
|
+
get errors() {
|
|
312
|
+
return this.issues;
|
|
313
|
+
}
|
|
196
314
|
constructor(issues) {
|
|
197
315
|
super();
|
|
198
316
|
this.issues = [];
|
|
@@ -211,9 +329,6 @@ var ZodError = class _ZodError extends Error {
|
|
|
211
329
|
this.name = "ZodError";
|
|
212
330
|
this.issues = issues;
|
|
213
331
|
}
|
|
214
|
-
get errors() {
|
|
215
|
-
return this.issues;
|
|
216
|
-
}
|
|
217
332
|
format(_mapper) {
|
|
218
333
|
const mapper = _mapper || function(issue) {
|
|
219
334
|
return issue.message;
|
|
@@ -285,6 +400,8 @@ ZodError.create = (issues) => {
|
|
|
285
400
|
const error = new ZodError(issues);
|
|
286
401
|
return error;
|
|
287
402
|
};
|
|
403
|
+
|
|
404
|
+
// ../../node_modules/.bun/zod@3.25.8/node_modules/zod/dist/esm/v3/locales/en.js
|
|
288
405
|
var errorMap = (issue, _ctx) => {
|
|
289
406
|
let message;
|
|
290
407
|
switch (issue.code) {
|
|
@@ -383,13 +500,18 @@ var errorMap = (issue, _ctx) => {
|
|
|
383
500
|
}
|
|
384
501
|
return { message };
|
|
385
502
|
};
|
|
386
|
-
var
|
|
503
|
+
var en_default = errorMap;
|
|
504
|
+
|
|
505
|
+
// ../../node_modules/.bun/zod@3.25.8/node_modules/zod/dist/esm/v3/errors.js
|
|
506
|
+
var overrideErrorMap = en_default;
|
|
387
507
|
function setErrorMap(map) {
|
|
388
508
|
overrideErrorMap = map;
|
|
389
509
|
}
|
|
390
510
|
function getErrorMap() {
|
|
391
511
|
return overrideErrorMap;
|
|
392
512
|
}
|
|
513
|
+
|
|
514
|
+
// ../../node_modules/.bun/zod@3.25.8/node_modules/zod/dist/esm/v3/helpers/parseUtil.js
|
|
393
515
|
var makeIssue = (params) => {
|
|
394
516
|
const { data, path, errorMaps, issueData } = params;
|
|
395
517
|
const fullPath = [...path, ...issueData.path || []];
|
|
@@ -424,9 +546,12 @@ function addIssueToContext(ctx, issueData) {
|
|
|
424
546
|
path: ctx.path,
|
|
425
547
|
errorMaps: [
|
|
426
548
|
ctx.common.contextualErrorMap,
|
|
549
|
+
// contextual error map is first priority
|
|
427
550
|
ctx.schemaErrorMap,
|
|
551
|
+
// then schema-bound map if available
|
|
428
552
|
overrideMap,
|
|
429
|
-
|
|
553
|
+
// then global override map
|
|
554
|
+
overrideMap === en_default ? void 0 : en_default
|
|
430
555
|
// then global default map
|
|
431
556
|
].filter((x) => !!x)
|
|
432
557
|
});
|
|
@@ -495,22 +620,26 @@ var isAborted = (x) => x.status === "aborted";
|
|
|
495
620
|
var isDirty = (x) => x.status === "dirty";
|
|
496
621
|
var isValid = (x) => x.status === "valid";
|
|
497
622
|
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
498
|
-
|
|
623
|
+
|
|
624
|
+
// ../../node_modules/.bun/zod@3.25.8/node_modules/zod/dist/esm/v3/helpers/errorUtil.js
|
|
625
|
+
var errorUtil;
|
|
626
|
+
(function(errorUtil2) {
|
|
627
|
+
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
628
|
+
errorUtil2.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
629
|
+
})(errorUtil || (errorUtil = {}));
|
|
630
|
+
|
|
631
|
+
// ../../node_modules/.bun/zod@3.25.8/node_modules/zod/dist/esm/v3/types.js
|
|
632
|
+
var __classPrivateFieldGet = function(receiver, state, kind, f) {
|
|
499
633
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
500
634
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
501
635
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
502
|
-
}
|
|
503
|
-
|
|
636
|
+
};
|
|
637
|
+
var __classPrivateFieldSet = function(receiver, state, value, kind, f) {
|
|
504
638
|
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
505
639
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
506
640
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
507
641
|
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
508
|
-
}
|
|
509
|
-
var errorUtil;
|
|
510
|
-
(function(errorUtil2) {
|
|
511
|
-
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
512
|
-
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
|
513
|
-
})(errorUtil || (errorUtil = {}));
|
|
642
|
+
};
|
|
514
643
|
var _ZodEnum_cache;
|
|
515
644
|
var _ZodNativeEnum_cache;
|
|
516
645
|
var ParseInputLazyPath = class {
|
|
@@ -523,7 +652,7 @@ var ParseInputLazyPath = class {
|
|
|
523
652
|
}
|
|
524
653
|
get path() {
|
|
525
654
|
if (!this._cachedPath.length) {
|
|
526
|
-
if (this._key
|
|
655
|
+
if (Array.isArray(this._key)) {
|
|
527
656
|
this._cachedPath.push(...this._path, ...this._key);
|
|
528
657
|
} else {
|
|
529
658
|
this._cachedPath.push(...this._path, this._key);
|
|
@@ -561,49 +690,20 @@ function processCreateParams(params) {
|
|
|
561
690
|
if (errorMap2)
|
|
562
691
|
return { errorMap: errorMap2, description };
|
|
563
692
|
const customMap = (iss, ctx) => {
|
|
564
|
-
var _a, _b;
|
|
565
693
|
const { message } = params;
|
|
566
694
|
if (iss.code === "invalid_enum_value") {
|
|
567
|
-
return { message: message
|
|
695
|
+
return { message: message ?? ctx.defaultError };
|
|
568
696
|
}
|
|
569
697
|
if (typeof ctx.data === "undefined") {
|
|
570
|
-
return { message:
|
|
698
|
+
return { message: message ?? required_error ?? ctx.defaultError };
|
|
571
699
|
}
|
|
572
700
|
if (iss.code !== "invalid_type")
|
|
573
701
|
return { message: ctx.defaultError };
|
|
574
|
-
return { message:
|
|
702
|
+
return { message: message ?? invalid_type_error ?? ctx.defaultError };
|
|
575
703
|
};
|
|
576
704
|
return { errorMap: customMap, description };
|
|
577
705
|
}
|
|
578
706
|
var ZodType = class {
|
|
579
|
-
constructor(def) {
|
|
580
|
-
this.spa = this.safeParseAsync;
|
|
581
|
-
this._def = def;
|
|
582
|
-
this.parse = this.parse.bind(this);
|
|
583
|
-
this.safeParse = this.safeParse.bind(this);
|
|
584
|
-
this.parseAsync = this.parseAsync.bind(this);
|
|
585
|
-
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
586
|
-
this.spa = this.spa.bind(this);
|
|
587
|
-
this.refine = this.refine.bind(this);
|
|
588
|
-
this.refinement = this.refinement.bind(this);
|
|
589
|
-
this.superRefine = this.superRefine.bind(this);
|
|
590
|
-
this.optional = this.optional.bind(this);
|
|
591
|
-
this.nullable = this.nullable.bind(this);
|
|
592
|
-
this.nullish = this.nullish.bind(this);
|
|
593
|
-
this.array = this.array.bind(this);
|
|
594
|
-
this.promise = this.promise.bind(this);
|
|
595
|
-
this.or = this.or.bind(this);
|
|
596
|
-
this.and = this.and.bind(this);
|
|
597
|
-
this.transform = this.transform.bind(this);
|
|
598
|
-
this.brand = this.brand.bind(this);
|
|
599
|
-
this.default = this.default.bind(this);
|
|
600
|
-
this.catch = this.catch.bind(this);
|
|
601
|
-
this.describe = this.describe.bind(this);
|
|
602
|
-
this.pipe = this.pipe.bind(this);
|
|
603
|
-
this.readonly = this.readonly.bind(this);
|
|
604
|
-
this.isNullable = this.isNullable.bind(this);
|
|
605
|
-
this.isOptional = this.isOptional.bind(this);
|
|
606
|
-
}
|
|
607
707
|
get description() {
|
|
608
708
|
return this._def.description;
|
|
609
709
|
}
|
|
@@ -651,14 +751,13 @@ var ZodType = class {
|
|
|
651
751
|
throw result.error;
|
|
652
752
|
}
|
|
653
753
|
safeParse(data, params) {
|
|
654
|
-
var _a;
|
|
655
754
|
const ctx = {
|
|
656
755
|
common: {
|
|
657
756
|
issues: [],
|
|
658
|
-
async:
|
|
659
|
-
contextualErrorMap: params
|
|
757
|
+
async: params?.async ?? false,
|
|
758
|
+
contextualErrorMap: params?.errorMap
|
|
660
759
|
},
|
|
661
|
-
path:
|
|
760
|
+
path: params?.path || [],
|
|
662
761
|
schemaErrorMap: this._def.errorMap,
|
|
663
762
|
parent: null,
|
|
664
763
|
data,
|
|
@@ -667,6 +766,42 @@ var ZodType = class {
|
|
|
667
766
|
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
668
767
|
return handleResult(ctx, result);
|
|
669
768
|
}
|
|
769
|
+
"~validate"(data) {
|
|
770
|
+
const ctx = {
|
|
771
|
+
common: {
|
|
772
|
+
issues: [],
|
|
773
|
+
async: !!this["~standard"].async
|
|
774
|
+
},
|
|
775
|
+
path: [],
|
|
776
|
+
schemaErrorMap: this._def.errorMap,
|
|
777
|
+
parent: null,
|
|
778
|
+
data,
|
|
779
|
+
parsedType: getParsedType(data)
|
|
780
|
+
};
|
|
781
|
+
if (!this["~standard"].async) {
|
|
782
|
+
try {
|
|
783
|
+
const result = this._parseSync({ data, path: [], parent: ctx });
|
|
784
|
+
return isValid(result) ? {
|
|
785
|
+
value: result.value
|
|
786
|
+
} : {
|
|
787
|
+
issues: ctx.common.issues
|
|
788
|
+
};
|
|
789
|
+
} catch (err) {
|
|
790
|
+
if (err?.message?.toLowerCase()?.includes("encountered")) {
|
|
791
|
+
this["~standard"].async = true;
|
|
792
|
+
}
|
|
793
|
+
ctx.common = {
|
|
794
|
+
issues: [],
|
|
795
|
+
async: true
|
|
796
|
+
};
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid(result) ? {
|
|
800
|
+
value: result.value
|
|
801
|
+
} : {
|
|
802
|
+
issues: ctx.common.issues
|
|
803
|
+
});
|
|
804
|
+
}
|
|
670
805
|
async parseAsync(data, params) {
|
|
671
806
|
const result = await this.safeParseAsync(data, params);
|
|
672
807
|
if (result.success)
|
|
@@ -677,10 +812,10 @@ var ZodType = class {
|
|
|
677
812
|
const ctx = {
|
|
678
813
|
common: {
|
|
679
814
|
issues: [],
|
|
680
|
-
contextualErrorMap: params
|
|
815
|
+
contextualErrorMap: params?.errorMap,
|
|
681
816
|
async: true
|
|
682
817
|
},
|
|
683
|
-
path:
|
|
818
|
+
path: params?.path || [],
|
|
684
819
|
schemaErrorMap: this._def.errorMap,
|
|
685
820
|
parent: null,
|
|
686
821
|
data,
|
|
@@ -744,6 +879,39 @@ var ZodType = class {
|
|
|
744
879
|
superRefine(refinement) {
|
|
745
880
|
return this._refinement(refinement);
|
|
746
881
|
}
|
|
882
|
+
constructor(def) {
|
|
883
|
+
this.spa = this.safeParseAsync;
|
|
884
|
+
this._def = def;
|
|
885
|
+
this.parse = this.parse.bind(this);
|
|
886
|
+
this.safeParse = this.safeParse.bind(this);
|
|
887
|
+
this.parseAsync = this.parseAsync.bind(this);
|
|
888
|
+
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
889
|
+
this.spa = this.spa.bind(this);
|
|
890
|
+
this.refine = this.refine.bind(this);
|
|
891
|
+
this.refinement = this.refinement.bind(this);
|
|
892
|
+
this.superRefine = this.superRefine.bind(this);
|
|
893
|
+
this.optional = this.optional.bind(this);
|
|
894
|
+
this.nullable = this.nullable.bind(this);
|
|
895
|
+
this.nullish = this.nullish.bind(this);
|
|
896
|
+
this.array = this.array.bind(this);
|
|
897
|
+
this.promise = this.promise.bind(this);
|
|
898
|
+
this.or = this.or.bind(this);
|
|
899
|
+
this.and = this.and.bind(this);
|
|
900
|
+
this.transform = this.transform.bind(this);
|
|
901
|
+
this.brand = this.brand.bind(this);
|
|
902
|
+
this.default = this.default.bind(this);
|
|
903
|
+
this.catch = this.catch.bind(this);
|
|
904
|
+
this.describe = this.describe.bind(this);
|
|
905
|
+
this.pipe = this.pipe.bind(this);
|
|
906
|
+
this.readonly = this.readonly.bind(this);
|
|
907
|
+
this.isNullable = this.isNullable.bind(this);
|
|
908
|
+
this.isOptional = this.isOptional.bind(this);
|
|
909
|
+
this["~standard"] = {
|
|
910
|
+
version: 1,
|
|
911
|
+
vendor: "zod",
|
|
912
|
+
validate: (data) => this["~validate"](data)
|
|
913
|
+
};
|
|
914
|
+
}
|
|
747
915
|
optional() {
|
|
748
916
|
return ZodOptional.create(this, this._def);
|
|
749
917
|
}
|
|
@@ -754,7 +922,7 @@ var ZodType = class {
|
|
|
754
922
|
return this.nullable().optional();
|
|
755
923
|
}
|
|
756
924
|
array() {
|
|
757
|
-
return ZodArray.create(this
|
|
925
|
+
return ZodArray.create(this);
|
|
758
926
|
}
|
|
759
927
|
promise() {
|
|
760
928
|
return ZodPromise.create(this, this._def);
|
|
@@ -820,26 +988,31 @@ var ZodType = class {
|
|
|
820
988
|
};
|
|
821
989
|
var cuidRegex = /^c[^\s-]{8,}$/i;
|
|
822
990
|
var cuid2Regex = /^[0-9a-z]+$/;
|
|
823
|
-
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}
|
|
991
|
+
var ulidRegex = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
|
|
824
992
|
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;
|
|
825
993
|
var nanoidRegex = /^[a-z0-9_-]{21}$/i;
|
|
994
|
+
var jwtRegex = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
|
826
995
|
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)?)??$/;
|
|
827
996
|
var emailRegex = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
828
997
|
var _emojiRegex = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
829
998
|
var emojiRegex;
|
|
830
999
|
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])$/;
|
|
831
|
-
var
|
|
1000
|
+
var ipv4CidrRegex = /^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/;
|
|
1001
|
+
var ipv6Regex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/;
|
|
1002
|
+
var ipv6CidrRegex = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
832
1003
|
var base64Regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
1004
|
+
var base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
|
833
1005
|
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])))`;
|
|
834
1006
|
var dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
835
1007
|
function timeRegexSource(args) {
|
|
836
|
-
let
|
|
1008
|
+
let secondsRegexSource = `[0-5]\\d`;
|
|
837
1009
|
if (args.precision) {
|
|
838
|
-
|
|
1010
|
+
secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
|
|
839
1011
|
} else if (args.precision == null) {
|
|
840
|
-
|
|
1012
|
+
secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
|
|
841
1013
|
}
|
|
842
|
-
|
|
1014
|
+
const secondsQuantifier = args.precision ? "+" : "?";
|
|
1015
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
|
|
843
1016
|
}
|
|
844
1017
|
function timeRegex(args) {
|
|
845
1018
|
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
@@ -862,6 +1035,35 @@ function isValidIP(ip, version) {
|
|
|
862
1035
|
}
|
|
863
1036
|
return false;
|
|
864
1037
|
}
|
|
1038
|
+
function isValidJWT(jwt, alg) {
|
|
1039
|
+
if (!jwtRegex.test(jwt))
|
|
1040
|
+
return false;
|
|
1041
|
+
try {
|
|
1042
|
+
const [header] = jwt.split(".");
|
|
1043
|
+
const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
|
1044
|
+
const decoded = JSON.parse(atob(base64));
|
|
1045
|
+
if (typeof decoded !== "object" || decoded === null)
|
|
1046
|
+
return false;
|
|
1047
|
+
if ("typ" in decoded && decoded?.typ !== "JWT")
|
|
1048
|
+
return false;
|
|
1049
|
+
if (!decoded.alg)
|
|
1050
|
+
return false;
|
|
1051
|
+
if (alg && decoded.alg !== alg)
|
|
1052
|
+
return false;
|
|
1053
|
+
return true;
|
|
1054
|
+
} catch {
|
|
1055
|
+
return false;
|
|
1056
|
+
}
|
|
1057
|
+
}
|
|
1058
|
+
function isValidCidr(ip, version) {
|
|
1059
|
+
if ((version === "v4" || !version) && ipv4CidrRegex.test(ip)) {
|
|
1060
|
+
return true;
|
|
1061
|
+
}
|
|
1062
|
+
if ((version === "v6" || !version) && ipv6CidrRegex.test(ip)) {
|
|
1063
|
+
return true;
|
|
1064
|
+
}
|
|
1065
|
+
return false;
|
|
1066
|
+
}
|
|
865
1067
|
var ZodString = class _ZodString extends ZodType {
|
|
866
1068
|
_parse(input) {
|
|
867
1069
|
if (this._def.coerce) {
|
|
@@ -1008,7 +1210,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1008
1210
|
} else if (check.kind === "url") {
|
|
1009
1211
|
try {
|
|
1010
1212
|
new URL(input.data);
|
|
1011
|
-
} catch
|
|
1213
|
+
} catch {
|
|
1012
1214
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
1013
1215
|
addIssueToContext(ctx, {
|
|
1014
1216
|
validation: "url",
|
|
@@ -1118,6 +1320,26 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1118
1320
|
});
|
|
1119
1321
|
status.dirty();
|
|
1120
1322
|
}
|
|
1323
|
+
} else if (check.kind === "jwt") {
|
|
1324
|
+
if (!isValidJWT(input.data, check.alg)) {
|
|
1325
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1326
|
+
addIssueToContext(ctx, {
|
|
1327
|
+
validation: "jwt",
|
|
1328
|
+
code: ZodIssueCode.invalid_string,
|
|
1329
|
+
message: check.message
|
|
1330
|
+
});
|
|
1331
|
+
status.dirty();
|
|
1332
|
+
}
|
|
1333
|
+
} else if (check.kind === "cidr") {
|
|
1334
|
+
if (!isValidCidr(input.data, check.version)) {
|
|
1335
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1336
|
+
addIssueToContext(ctx, {
|
|
1337
|
+
validation: "cidr",
|
|
1338
|
+
code: ZodIssueCode.invalid_string,
|
|
1339
|
+
message: check.message
|
|
1340
|
+
});
|
|
1341
|
+
status.dirty();
|
|
1342
|
+
}
|
|
1121
1343
|
} else if (check.kind === "base64") {
|
|
1122
1344
|
if (!base64Regex.test(input.data)) {
|
|
1123
1345
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
@@ -1128,6 +1350,16 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1128
1350
|
});
|
|
1129
1351
|
status.dirty();
|
|
1130
1352
|
}
|
|
1353
|
+
} else if (check.kind === "base64url") {
|
|
1354
|
+
if (!base64urlRegex.test(input.data)) {
|
|
1355
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
1356
|
+
addIssueToContext(ctx, {
|
|
1357
|
+
validation: "base64url",
|
|
1358
|
+
code: ZodIssueCode.invalid_string,
|
|
1359
|
+
message: check.message
|
|
1360
|
+
});
|
|
1361
|
+
status.dirty();
|
|
1362
|
+
}
|
|
1131
1363
|
} else {
|
|
1132
1364
|
util.assertNever(check);
|
|
1133
1365
|
}
|
|
@@ -1174,11 +1406,22 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1174
1406
|
base64(message) {
|
|
1175
1407
|
return this._addCheck({ kind: "base64", ...errorUtil.errToObj(message) });
|
|
1176
1408
|
}
|
|
1409
|
+
base64url(message) {
|
|
1410
|
+
return this._addCheck({
|
|
1411
|
+
kind: "base64url",
|
|
1412
|
+
...errorUtil.errToObj(message)
|
|
1413
|
+
});
|
|
1414
|
+
}
|
|
1415
|
+
jwt(options) {
|
|
1416
|
+
return this._addCheck({ kind: "jwt", ...errorUtil.errToObj(options) });
|
|
1417
|
+
}
|
|
1177
1418
|
ip(options) {
|
|
1178
1419
|
return this._addCheck({ kind: "ip", ...errorUtil.errToObj(options) });
|
|
1179
1420
|
}
|
|
1421
|
+
cidr(options) {
|
|
1422
|
+
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
|
1423
|
+
}
|
|
1180
1424
|
datetime(options) {
|
|
1181
|
-
var _a, _b;
|
|
1182
1425
|
if (typeof options === "string") {
|
|
1183
1426
|
return this._addCheck({
|
|
1184
1427
|
kind: "datetime",
|
|
@@ -1190,10 +1433,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1190
1433
|
}
|
|
1191
1434
|
return this._addCheck({
|
|
1192
1435
|
kind: "datetime",
|
|
1193
|
-
precision: typeof
|
|
1194
|
-
offset:
|
|
1195
|
-
local:
|
|
1196
|
-
...errorUtil.errToObj(options
|
|
1436
|
+
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
1437
|
+
offset: options?.offset ?? false,
|
|
1438
|
+
local: options?.local ?? false,
|
|
1439
|
+
...errorUtil.errToObj(options?.message)
|
|
1197
1440
|
});
|
|
1198
1441
|
}
|
|
1199
1442
|
date(message) {
|
|
@@ -1209,8 +1452,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1209
1452
|
}
|
|
1210
1453
|
return this._addCheck({
|
|
1211
1454
|
kind: "time",
|
|
1212
|
-
precision: typeof
|
|
1213
|
-
...errorUtil.errToObj(options
|
|
1455
|
+
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
1456
|
+
...errorUtil.errToObj(options?.message)
|
|
1214
1457
|
});
|
|
1215
1458
|
}
|
|
1216
1459
|
duration(message) {
|
|
@@ -1227,8 +1470,8 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1227
1470
|
return this._addCheck({
|
|
1228
1471
|
kind: "includes",
|
|
1229
1472
|
value,
|
|
1230
|
-
position: options
|
|
1231
|
-
...errorUtil.errToObj(options
|
|
1473
|
+
position: options?.position,
|
|
1474
|
+
...errorUtil.errToObj(options?.message)
|
|
1232
1475
|
});
|
|
1233
1476
|
}
|
|
1234
1477
|
startsWith(value, message) {
|
|
@@ -1267,8 +1510,7 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1267
1510
|
});
|
|
1268
1511
|
}
|
|
1269
1512
|
/**
|
|
1270
|
-
*
|
|
1271
|
-
* @see {@link ZodString.min}
|
|
1513
|
+
* Equivalent to `.min(1)`
|
|
1272
1514
|
*/
|
|
1273
1515
|
nonempty(message) {
|
|
1274
1516
|
return this.min(1, errorUtil.errToObj(message));
|
|
@@ -1330,9 +1572,15 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1330
1572
|
get isIP() {
|
|
1331
1573
|
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
1332
1574
|
}
|
|
1575
|
+
get isCIDR() {
|
|
1576
|
+
return !!this._def.checks.find((ch) => ch.kind === "cidr");
|
|
1577
|
+
}
|
|
1333
1578
|
get isBase64() {
|
|
1334
1579
|
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
1335
1580
|
}
|
|
1581
|
+
get isBase64url() {
|
|
1582
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64url");
|
|
1583
|
+
}
|
|
1336
1584
|
get minLength() {
|
|
1337
1585
|
let min = null;
|
|
1338
1586
|
for (const ch of this._def.checks) {
|
|
@@ -1355,11 +1603,10 @@ var ZodString = class _ZodString extends ZodType {
|
|
|
1355
1603
|
}
|
|
1356
1604
|
};
|
|
1357
1605
|
ZodString.create = (params) => {
|
|
1358
|
-
var _a;
|
|
1359
1606
|
return new ZodString({
|
|
1360
1607
|
checks: [],
|
|
1361
1608
|
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
1362
|
-
coerce:
|
|
1609
|
+
coerce: params?.coerce ?? false,
|
|
1363
1610
|
...processCreateParams(params)
|
|
1364
1611
|
});
|
|
1365
1612
|
};
|
|
@@ -1367,9 +1614,9 @@ function floatSafeRemainder(val, step) {
|
|
|
1367
1614
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
1368
1615
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
1369
1616
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
1370
|
-
const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
|
|
1371
|
-
const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
|
|
1372
|
-
return valInt % stepInt /
|
|
1617
|
+
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
1618
|
+
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
1619
|
+
return valInt % stepInt / 10 ** decCount;
|
|
1373
1620
|
}
|
|
1374
1621
|
var ZodNumber = class _ZodNumber extends ZodType {
|
|
1375
1622
|
constructor() {
|
|
@@ -1579,7 +1826,8 @@ var ZodNumber = class _ZodNumber extends ZodType {
|
|
|
1579
1826
|
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
|
1580
1827
|
}
|
|
1581
1828
|
get isFinite() {
|
|
1582
|
-
let max = null
|
|
1829
|
+
let max = null;
|
|
1830
|
+
let min = null;
|
|
1583
1831
|
for (const ch of this._def.checks) {
|
|
1584
1832
|
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
|
1585
1833
|
return true;
|
|
@@ -1598,7 +1846,7 @@ ZodNumber.create = (params) => {
|
|
|
1598
1846
|
return new ZodNumber({
|
|
1599
1847
|
checks: [],
|
|
1600
1848
|
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
1601
|
-
coerce:
|
|
1849
|
+
coerce: params?.coerce || false,
|
|
1602
1850
|
...processCreateParams(params)
|
|
1603
1851
|
});
|
|
1604
1852
|
};
|
|
@@ -1610,17 +1858,15 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1610
1858
|
}
|
|
1611
1859
|
_parse(input) {
|
|
1612
1860
|
if (this._def.coerce) {
|
|
1613
|
-
|
|
1861
|
+
try {
|
|
1862
|
+
input.data = BigInt(input.data);
|
|
1863
|
+
} catch {
|
|
1864
|
+
return this._getInvalidInput(input);
|
|
1865
|
+
}
|
|
1614
1866
|
}
|
|
1615
1867
|
const parsedType = this._getType(input);
|
|
1616
1868
|
if (parsedType !== ZodParsedType.bigint) {
|
|
1617
|
-
|
|
1618
|
-
addIssueToContext(ctx2, {
|
|
1619
|
-
code: ZodIssueCode.invalid_type,
|
|
1620
|
-
expected: ZodParsedType.bigint,
|
|
1621
|
-
received: ctx2.parsedType
|
|
1622
|
-
});
|
|
1623
|
-
return INVALID;
|
|
1869
|
+
return this._getInvalidInput(input);
|
|
1624
1870
|
}
|
|
1625
1871
|
let ctx = void 0;
|
|
1626
1872
|
const status = new ParseStatus();
|
|
@@ -1667,6 +1913,15 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1667
1913
|
}
|
|
1668
1914
|
return { status: status.value, value: input.data };
|
|
1669
1915
|
}
|
|
1916
|
+
_getInvalidInput(input) {
|
|
1917
|
+
const ctx = this._getOrReturnCtx(input);
|
|
1918
|
+
addIssueToContext(ctx, {
|
|
1919
|
+
code: ZodIssueCode.invalid_type,
|
|
1920
|
+
expected: ZodParsedType.bigint,
|
|
1921
|
+
received: ctx.parsedType
|
|
1922
|
+
});
|
|
1923
|
+
return INVALID;
|
|
1924
|
+
}
|
|
1670
1925
|
gte(value, message) {
|
|
1671
1926
|
return this.setLimit("min", value, true, errorUtil.toString(message));
|
|
1672
1927
|
}
|
|
@@ -1760,11 +2015,10 @@ var ZodBigInt = class _ZodBigInt extends ZodType {
|
|
|
1760
2015
|
}
|
|
1761
2016
|
};
|
|
1762
2017
|
ZodBigInt.create = (params) => {
|
|
1763
|
-
var _a;
|
|
1764
2018
|
return new ZodBigInt({
|
|
1765
2019
|
checks: [],
|
|
1766
2020
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
1767
|
-
coerce:
|
|
2021
|
+
coerce: params?.coerce ?? false,
|
|
1768
2022
|
...processCreateParams(params)
|
|
1769
2023
|
});
|
|
1770
2024
|
};
|
|
@@ -1789,7 +2043,7 @@ var ZodBoolean = class extends ZodType {
|
|
|
1789
2043
|
ZodBoolean.create = (params) => {
|
|
1790
2044
|
return new ZodBoolean({
|
|
1791
2045
|
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
|
1792
|
-
coerce:
|
|
2046
|
+
coerce: params?.coerce || false,
|
|
1793
2047
|
...processCreateParams(params)
|
|
1794
2048
|
});
|
|
1795
2049
|
};
|
|
@@ -1808,7 +2062,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
1808
2062
|
});
|
|
1809
2063
|
return INVALID;
|
|
1810
2064
|
}
|
|
1811
|
-
if (isNaN(input.data.getTime())) {
|
|
2065
|
+
if (Number.isNaN(input.data.getTime())) {
|
|
1812
2066
|
const ctx2 = this._getOrReturnCtx(input);
|
|
1813
2067
|
addIssueToContext(ctx2, {
|
|
1814
2068
|
code: ZodIssueCode.invalid_date
|
|
@@ -1897,7 +2151,7 @@ var ZodDate = class _ZodDate extends ZodType {
|
|
|
1897
2151
|
ZodDate.create = (params) => {
|
|
1898
2152
|
return new ZodDate({
|
|
1899
2153
|
checks: [],
|
|
1900
|
-
coerce:
|
|
2154
|
+
coerce: params?.coerce || false,
|
|
1901
2155
|
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
1902
2156
|
...processCreateParams(params)
|
|
1903
2157
|
});
|
|
@@ -2172,7 +2426,8 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2172
2426
|
return this._cached;
|
|
2173
2427
|
const shape = this._def.shape();
|
|
2174
2428
|
const keys = util.objectKeys(shape);
|
|
2175
|
-
|
|
2429
|
+
this._cached = { shape, keys };
|
|
2430
|
+
return this._cached;
|
|
2176
2431
|
}
|
|
2177
2432
|
_parse(input) {
|
|
2178
2433
|
const parsedType = this._getType(input);
|
|
@@ -2222,8 +2477,8 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2222
2477
|
});
|
|
2223
2478
|
status.dirty();
|
|
2224
2479
|
}
|
|
2225
|
-
} else if (unknownKeys === "strip")
|
|
2226
|
-
else {
|
|
2480
|
+
} else if (unknownKeys === "strip") {
|
|
2481
|
+
} else {
|
|
2227
2482
|
throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
|
|
2228
2483
|
}
|
|
2229
2484
|
} else {
|
|
@@ -2270,11 +2525,10 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2270
2525
|
unknownKeys: "strict",
|
|
2271
2526
|
...message !== void 0 ? {
|
|
2272
2527
|
errorMap: (issue, ctx) => {
|
|
2273
|
-
|
|
2274
|
-
const defaultError = (_c = (_b = (_a = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
|
|
2528
|
+
const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
|
|
2275
2529
|
if (issue.code === "unrecognized_keys")
|
|
2276
2530
|
return {
|
|
2277
|
-
message:
|
|
2531
|
+
message: errorUtil.errToObj(message).message ?? defaultError
|
|
2278
2532
|
};
|
|
2279
2533
|
return {
|
|
2280
2534
|
message: defaultError
|
|
@@ -2405,11 +2659,11 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2405
2659
|
}
|
|
2406
2660
|
pick(mask) {
|
|
2407
2661
|
const shape = {};
|
|
2408
|
-
util.objectKeys(mask)
|
|
2662
|
+
for (const key of util.objectKeys(mask)) {
|
|
2409
2663
|
if (mask[key] && this.shape[key]) {
|
|
2410
2664
|
shape[key] = this.shape[key];
|
|
2411
2665
|
}
|
|
2412
|
-
}
|
|
2666
|
+
}
|
|
2413
2667
|
return new _ZodObject({
|
|
2414
2668
|
...this._def,
|
|
2415
2669
|
shape: () => shape
|
|
@@ -2417,11 +2671,11 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2417
2671
|
}
|
|
2418
2672
|
omit(mask) {
|
|
2419
2673
|
const shape = {};
|
|
2420
|
-
util.objectKeys(this.shape)
|
|
2674
|
+
for (const key of util.objectKeys(this.shape)) {
|
|
2421
2675
|
if (!mask[key]) {
|
|
2422
2676
|
shape[key] = this.shape[key];
|
|
2423
2677
|
}
|
|
2424
|
-
}
|
|
2678
|
+
}
|
|
2425
2679
|
return new _ZodObject({
|
|
2426
2680
|
...this._def,
|
|
2427
2681
|
shape: () => shape
|
|
@@ -2435,14 +2689,14 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2435
2689
|
}
|
|
2436
2690
|
partial(mask) {
|
|
2437
2691
|
const newShape = {};
|
|
2438
|
-
util.objectKeys(this.shape)
|
|
2692
|
+
for (const key of util.objectKeys(this.shape)) {
|
|
2439
2693
|
const fieldSchema = this.shape[key];
|
|
2440
2694
|
if (mask && !mask[key]) {
|
|
2441
2695
|
newShape[key] = fieldSchema;
|
|
2442
2696
|
} else {
|
|
2443
2697
|
newShape[key] = fieldSchema.optional();
|
|
2444
2698
|
}
|
|
2445
|
-
}
|
|
2699
|
+
}
|
|
2446
2700
|
return new _ZodObject({
|
|
2447
2701
|
...this._def,
|
|
2448
2702
|
shape: () => newShape
|
|
@@ -2450,7 +2704,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2450
2704
|
}
|
|
2451
2705
|
required(mask) {
|
|
2452
2706
|
const newShape = {};
|
|
2453
|
-
util.objectKeys(this.shape)
|
|
2707
|
+
for (const key of util.objectKeys(this.shape)) {
|
|
2454
2708
|
if (mask && !mask[key]) {
|
|
2455
2709
|
newShape[key] = this.shape[key];
|
|
2456
2710
|
} else {
|
|
@@ -2461,7 +2715,7 @@ var ZodObject = class _ZodObject extends ZodType {
|
|
|
2461
2715
|
}
|
|
2462
2716
|
newShape[key] = newField;
|
|
2463
2717
|
}
|
|
2464
|
-
}
|
|
2718
|
+
}
|
|
2465
2719
|
return new _ZodObject({
|
|
2466
2720
|
...this._def,
|
|
2467
2721
|
shape: () => newShape
|
|
@@ -3077,12 +3331,7 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3077
3331
|
return makeIssue({
|
|
3078
3332
|
data: args,
|
|
3079
3333
|
path: ctx.path,
|
|
3080
|
-
errorMaps: [
|
|
3081
|
-
ctx.common.contextualErrorMap,
|
|
3082
|
-
ctx.schemaErrorMap,
|
|
3083
|
-
getErrorMap(),
|
|
3084
|
-
errorMap
|
|
3085
|
-
].filter((x) => !!x),
|
|
3334
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
|
|
3086
3335
|
issueData: {
|
|
3087
3336
|
code: ZodIssueCode.invalid_arguments,
|
|
3088
3337
|
argumentsError: error
|
|
@@ -3093,12 +3342,7 @@ var ZodFunction = class _ZodFunction extends ZodType {
|
|
|
3093
3342
|
return makeIssue({
|
|
3094
3343
|
data: returns,
|
|
3095
3344
|
path: ctx.path,
|
|
3096
|
-
errorMaps: [
|
|
3097
|
-
ctx.common.contextualErrorMap,
|
|
3098
|
-
ctx.schemaErrorMap,
|
|
3099
|
-
getErrorMap(),
|
|
3100
|
-
errorMap
|
|
3101
|
-
].filter((x) => !!x),
|
|
3345
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap(), en_default].filter((x) => !!x),
|
|
3102
3346
|
issueData: {
|
|
3103
3347
|
code: ZodIssueCode.invalid_return_type,
|
|
3104
3348
|
returnTypeError: error
|
|
@@ -3477,7 +3721,10 @@ var ZodEffects = class extends ZodType {
|
|
|
3477
3721
|
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
|
|
3478
3722
|
if (!isValid(base))
|
|
3479
3723
|
return base;
|
|
3480
|
-
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
3724
|
+
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
3725
|
+
status: status.value,
|
|
3726
|
+
value: result
|
|
3727
|
+
}));
|
|
3481
3728
|
});
|
|
3482
3729
|
}
|
|
3483
3730
|
}
|
|
@@ -3729,16 +3976,30 @@ ZodReadonly.create = (type, params) => {
|
|
|
3729
3976
|
...processCreateParams(params)
|
|
3730
3977
|
});
|
|
3731
3978
|
};
|
|
3732
|
-
function
|
|
3979
|
+
function cleanParams(params, data) {
|
|
3980
|
+
const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
|
|
3981
|
+
const p2 = typeof p === "string" ? { message: p } : p;
|
|
3982
|
+
return p2;
|
|
3983
|
+
}
|
|
3984
|
+
function custom(check, _params = {}, fatal) {
|
|
3733
3985
|
if (check)
|
|
3734
3986
|
return ZodAny.create().superRefine((data, ctx) => {
|
|
3735
|
-
|
|
3736
|
-
if (
|
|
3737
|
-
|
|
3738
|
-
|
|
3739
|
-
|
|
3740
|
-
|
|
3987
|
+
const r = check(data);
|
|
3988
|
+
if (r instanceof Promise) {
|
|
3989
|
+
return r.then((r2) => {
|
|
3990
|
+
if (!r2) {
|
|
3991
|
+
const params = cleanParams(_params, data);
|
|
3992
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
3993
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
3994
|
+
}
|
|
3995
|
+
});
|
|
3741
3996
|
}
|
|
3997
|
+
if (!r) {
|
|
3998
|
+
const params = cleanParams(_params, data);
|
|
3999
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
4000
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
4001
|
+
}
|
|
4002
|
+
return;
|
|
3742
4003
|
});
|
|
3743
4004
|
return ZodAny.create();
|
|
3744
4005
|
}
|
|
@@ -3835,122 +4096,6 @@ var coerce = {
|
|
|
3835
4096
|
date: (arg) => ZodDate.create({ ...arg, coerce: true })
|
|
3836
4097
|
};
|
|
3837
4098
|
var NEVER = INVALID;
|
|
3838
|
-
var z = /* @__PURE__ */ Object.freeze({
|
|
3839
|
-
__proto__: null,
|
|
3840
|
-
defaultErrorMap: errorMap,
|
|
3841
|
-
setErrorMap,
|
|
3842
|
-
getErrorMap,
|
|
3843
|
-
makeIssue,
|
|
3844
|
-
EMPTY_PATH,
|
|
3845
|
-
addIssueToContext,
|
|
3846
|
-
ParseStatus,
|
|
3847
|
-
INVALID,
|
|
3848
|
-
DIRTY,
|
|
3849
|
-
OK,
|
|
3850
|
-
isAborted,
|
|
3851
|
-
isDirty,
|
|
3852
|
-
isValid,
|
|
3853
|
-
isAsync,
|
|
3854
|
-
get util() {
|
|
3855
|
-
return util;
|
|
3856
|
-
},
|
|
3857
|
-
get objectUtil() {
|
|
3858
|
-
return objectUtil;
|
|
3859
|
-
},
|
|
3860
|
-
ZodParsedType,
|
|
3861
|
-
getParsedType,
|
|
3862
|
-
ZodType,
|
|
3863
|
-
datetimeRegex,
|
|
3864
|
-
ZodString,
|
|
3865
|
-
ZodNumber,
|
|
3866
|
-
ZodBigInt,
|
|
3867
|
-
ZodBoolean,
|
|
3868
|
-
ZodDate,
|
|
3869
|
-
ZodSymbol,
|
|
3870
|
-
ZodUndefined,
|
|
3871
|
-
ZodNull,
|
|
3872
|
-
ZodAny,
|
|
3873
|
-
ZodUnknown,
|
|
3874
|
-
ZodNever,
|
|
3875
|
-
ZodVoid,
|
|
3876
|
-
ZodArray,
|
|
3877
|
-
ZodObject,
|
|
3878
|
-
ZodUnion,
|
|
3879
|
-
ZodDiscriminatedUnion,
|
|
3880
|
-
ZodIntersection,
|
|
3881
|
-
ZodTuple,
|
|
3882
|
-
ZodRecord,
|
|
3883
|
-
ZodMap,
|
|
3884
|
-
ZodSet,
|
|
3885
|
-
ZodFunction,
|
|
3886
|
-
ZodLazy,
|
|
3887
|
-
ZodLiteral,
|
|
3888
|
-
ZodEnum,
|
|
3889
|
-
ZodNativeEnum,
|
|
3890
|
-
ZodPromise,
|
|
3891
|
-
ZodEffects,
|
|
3892
|
-
ZodTransformer: ZodEffects,
|
|
3893
|
-
ZodOptional,
|
|
3894
|
-
ZodNullable,
|
|
3895
|
-
ZodDefault,
|
|
3896
|
-
ZodCatch,
|
|
3897
|
-
ZodNaN,
|
|
3898
|
-
BRAND,
|
|
3899
|
-
ZodBranded,
|
|
3900
|
-
ZodPipeline,
|
|
3901
|
-
ZodReadonly,
|
|
3902
|
-
custom,
|
|
3903
|
-
Schema: ZodType,
|
|
3904
|
-
ZodSchema: ZodType,
|
|
3905
|
-
late,
|
|
3906
|
-
get ZodFirstPartyTypeKind() {
|
|
3907
|
-
return ZodFirstPartyTypeKind;
|
|
3908
|
-
},
|
|
3909
|
-
coerce,
|
|
3910
|
-
any: anyType,
|
|
3911
|
-
array: arrayType,
|
|
3912
|
-
bigint: bigIntType,
|
|
3913
|
-
boolean: booleanType,
|
|
3914
|
-
date: dateType,
|
|
3915
|
-
discriminatedUnion: discriminatedUnionType,
|
|
3916
|
-
effect: effectsType,
|
|
3917
|
-
"enum": enumType,
|
|
3918
|
-
"function": functionType,
|
|
3919
|
-
"instanceof": instanceOfType,
|
|
3920
|
-
intersection: intersectionType,
|
|
3921
|
-
lazy: lazyType,
|
|
3922
|
-
literal: literalType,
|
|
3923
|
-
map: mapType,
|
|
3924
|
-
nan: nanType,
|
|
3925
|
-
nativeEnum: nativeEnumType,
|
|
3926
|
-
never: neverType,
|
|
3927
|
-
"null": nullType,
|
|
3928
|
-
nullable: nullableType,
|
|
3929
|
-
number: numberType,
|
|
3930
|
-
object: objectType,
|
|
3931
|
-
oboolean,
|
|
3932
|
-
onumber,
|
|
3933
|
-
optional: optionalType,
|
|
3934
|
-
ostring,
|
|
3935
|
-
pipeline: pipelineType,
|
|
3936
|
-
preprocess: preprocessType,
|
|
3937
|
-
promise: promiseType,
|
|
3938
|
-
record: recordType,
|
|
3939
|
-
set: setType,
|
|
3940
|
-
strictObject: strictObjectType,
|
|
3941
|
-
string: stringType,
|
|
3942
|
-
symbol: symbolType,
|
|
3943
|
-
transformer: effectsType,
|
|
3944
|
-
tuple: tupleType,
|
|
3945
|
-
"undefined": undefinedType,
|
|
3946
|
-
union: unionType,
|
|
3947
|
-
unknown: unknownType,
|
|
3948
|
-
"void": voidType,
|
|
3949
|
-
NEVER,
|
|
3950
|
-
ZodIssueCode,
|
|
3951
|
-
quotelessJson,
|
|
3952
|
-
ZodError
|
|
3953
|
-
});
|
|
3954
4099
|
|
|
3955
4100
|
// src/app-environments.ts
|
|
3956
4101
|
var schemaVaultsAppEnvironments = [
|
|
@@ -3959,7 +4104,7 @@ var schemaVaultsAppEnvironments = [
|
|
|
3959
4104
|
"test",
|
|
3960
4105
|
"production"
|
|
3961
4106
|
];
|
|
3962
|
-
var schemaVaultsAppEnvironmentSchema =
|
|
4107
|
+
var schemaVaultsAppEnvironmentSchema = external_exports.enum(
|
|
3963
4108
|
schemaVaultsAppEnvironments
|
|
3964
4109
|
);
|
|
3965
4110
|
|