@waitroom-io/cli 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +4259 -89
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -8,7 +8,12 @@ var __export = (target, all) => {
|
|
|
8
8
|
// src/cli.ts
|
|
9
9
|
import { Command as Command13 } from "commander";
|
|
10
10
|
|
|
11
|
-
// ../../packages/
|
|
11
|
+
// ../../packages/sdk-ts/dist/index.js
|
|
12
|
+
var __defProp2 = Object.defineProperty;
|
|
13
|
+
var __export2 = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp2(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
12
17
|
var RiskLevel = {
|
|
13
18
|
LOW: "low",
|
|
14
19
|
MEDIUM: "medium",
|
|
@@ -39,10 +44,8 @@ var PolicyAction = {
|
|
|
39
44
|
REQUIRE_APPROVAL: "require_approval",
|
|
40
45
|
FORBID: "forbid"
|
|
41
46
|
};
|
|
42
|
-
|
|
43
|
-
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
|
|
44
47
|
var external_exports = {};
|
|
45
|
-
|
|
48
|
+
__export2(external_exports, {
|
|
46
49
|
BRAND: () => BRAND,
|
|
47
50
|
DIRTY: () => DIRTY,
|
|
48
51
|
EMPTY_PATH: () => EMPTY_PATH,
|
|
@@ -151,40 +154,38 @@ __export(external_exports, {
|
|
|
151
154
|
util: () => util,
|
|
152
155
|
void: () => voidType
|
|
153
156
|
});
|
|
154
|
-
|
|
155
|
-
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
|
|
156
157
|
var util;
|
|
157
|
-
(function(
|
|
158
|
-
|
|
158
|
+
(function(util22) {
|
|
159
|
+
util22.assertEqual = (_) => {
|
|
159
160
|
};
|
|
160
161
|
function assertIs(_arg) {
|
|
161
162
|
}
|
|
162
|
-
|
|
163
|
+
util22.assertIs = assertIs;
|
|
163
164
|
function assertNever(_x) {
|
|
164
165
|
throw new Error();
|
|
165
166
|
}
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
util22.assertNever = assertNever;
|
|
168
|
+
util22.arrayToEnum = (items) => {
|
|
168
169
|
const obj = {};
|
|
169
170
|
for (const item of items) {
|
|
170
171
|
obj[item] = item;
|
|
171
172
|
}
|
|
172
173
|
return obj;
|
|
173
174
|
};
|
|
174
|
-
|
|
175
|
-
const validKeys =
|
|
175
|
+
util22.getValidEnumValues = (obj) => {
|
|
176
|
+
const validKeys = util22.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
176
177
|
const filtered = {};
|
|
177
178
|
for (const k of validKeys) {
|
|
178
179
|
filtered[k] = obj[k];
|
|
179
180
|
}
|
|
180
|
-
return
|
|
181
|
+
return util22.objectValues(filtered);
|
|
181
182
|
};
|
|
182
|
-
|
|
183
|
-
return
|
|
183
|
+
util22.objectValues = (obj) => {
|
|
184
|
+
return util22.objectKeys(obj).map(function(e) {
|
|
184
185
|
return obj[e];
|
|
185
186
|
});
|
|
186
187
|
};
|
|
187
|
-
|
|
188
|
+
util22.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
188
189
|
const keys = [];
|
|
189
190
|
for (const key in object) {
|
|
190
191
|
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
@@ -193,19 +194,19 @@ var util;
|
|
|
193
194
|
}
|
|
194
195
|
return keys;
|
|
195
196
|
};
|
|
196
|
-
|
|
197
|
+
util22.find = (arr, checker) => {
|
|
197
198
|
for (const item of arr) {
|
|
198
199
|
if (checker(item))
|
|
199
200
|
return item;
|
|
200
201
|
}
|
|
201
202
|
return void 0;
|
|
202
203
|
};
|
|
203
|
-
|
|
204
|
+
util22.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
204
205
|
function joinValues(array, separator = " | ") {
|
|
205
206
|
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
206
207
|
}
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
util22.joinValues = joinValues;
|
|
209
|
+
util22.jsonStringifyReplacer = (_, value) => {
|
|
209
210
|
if (typeof value === "bigint") {
|
|
210
211
|
return value.toString();
|
|
211
212
|
}
|
|
@@ -213,8 +214,8 @@ var util;
|
|
|
213
214
|
};
|
|
214
215
|
})(util || (util = {}));
|
|
215
216
|
var objectUtil;
|
|
216
|
-
(function(
|
|
217
|
-
|
|
217
|
+
(function(objectUtil22) {
|
|
218
|
+
objectUtil22.mergeShapes = (first, second) => {
|
|
218
219
|
return {
|
|
219
220
|
...first,
|
|
220
221
|
...second
|
|
@@ -285,8 +286,6 @@ var getParsedType = (data) => {
|
|
|
285
286
|
return ZodParsedType.unknown;
|
|
286
287
|
}
|
|
287
288
|
};
|
|
288
|
-
|
|
289
|
-
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
|
|
290
289
|
var ZodIssueCode = util.arrayToEnum([
|
|
291
290
|
"invalid_type",
|
|
292
291
|
"invalid_literal",
|
|
@@ -403,8 +402,6 @@ ZodError.create = (issues) => {
|
|
|
403
402
|
const error = new ZodError(issues);
|
|
404
403
|
return error;
|
|
405
404
|
};
|
|
406
|
-
|
|
407
|
-
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
|
|
408
405
|
var errorMap = (issue, _ctx) => {
|
|
409
406
|
let message;
|
|
410
407
|
switch (issue.code) {
|
|
@@ -506,8 +503,6 @@ var errorMap = (issue, _ctx) => {
|
|
|
506
503
|
return { message };
|
|
507
504
|
};
|
|
508
505
|
var en_default = errorMap;
|
|
509
|
-
|
|
510
|
-
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js
|
|
511
506
|
var overrideErrorMap = en_default;
|
|
512
507
|
function setErrorMap(map) {
|
|
513
508
|
overrideErrorMap = map;
|
|
@@ -515,8 +510,6 @@ function setErrorMap(map) {
|
|
|
515
510
|
function getErrorMap() {
|
|
516
511
|
return overrideErrorMap;
|
|
517
512
|
}
|
|
518
|
-
|
|
519
|
-
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
520
513
|
var makeIssue = (params) => {
|
|
521
514
|
const { data, path: path6, errorMaps, issueData } = params;
|
|
522
515
|
const fullPath = [...path6, ...issueData.path || []];
|
|
@@ -625,15 +618,11 @@ var isAborted = (x) => x.status === "aborted";
|
|
|
625
618
|
var isDirty = (x) => x.status === "dirty";
|
|
626
619
|
var isValid = (x) => x.status === "valid";
|
|
627
620
|
var isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
628
|
-
|
|
629
|
-
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
|
|
630
621
|
var errorUtil;
|
|
631
|
-
(function(
|
|
632
|
-
|
|
633
|
-
|
|
622
|
+
(function(errorUtil22) {
|
|
623
|
+
errorUtil22.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
624
|
+
errorUtil22.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
634
625
|
})(errorUtil || (errorUtil = {}));
|
|
635
|
-
|
|
636
|
-
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
637
626
|
var ParseInputLazyPath = class {
|
|
638
627
|
constructor(parent, value, path6, key) {
|
|
639
628
|
this._cachedPath = [];
|
|
@@ -675,12 +664,12 @@ var handleResult = (ctx, result) => {
|
|
|
675
664
|
function processCreateParams(params) {
|
|
676
665
|
if (!params)
|
|
677
666
|
return {};
|
|
678
|
-
const { errorMap:
|
|
679
|
-
if (
|
|
667
|
+
const { errorMap: errorMap22, invalid_type_error, required_error, description } = params;
|
|
668
|
+
if (errorMap22 && (invalid_type_error || required_error)) {
|
|
680
669
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
681
670
|
}
|
|
682
|
-
if (
|
|
683
|
-
return { errorMap:
|
|
671
|
+
if (errorMap22)
|
|
672
|
+
return { errorMap: errorMap22, description };
|
|
684
673
|
const customMap = (iss, ctx) => {
|
|
685
674
|
const { message } = params;
|
|
686
675
|
if (iss.code === "invalid_enum_value") {
|
|
@@ -3991,43 +3980,43 @@ var late = {
|
|
|
3991
3980
|
object: ZodObject.lazycreate
|
|
3992
3981
|
};
|
|
3993
3982
|
var ZodFirstPartyTypeKind;
|
|
3994
|
-
(function(
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
|
|
4018
|
-
|
|
4019
|
-
|
|
4020
|
-
|
|
4021
|
-
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
3983
|
+
(function(ZodFirstPartyTypeKind22) {
|
|
3984
|
+
ZodFirstPartyTypeKind22["ZodString"] = "ZodString";
|
|
3985
|
+
ZodFirstPartyTypeKind22["ZodNumber"] = "ZodNumber";
|
|
3986
|
+
ZodFirstPartyTypeKind22["ZodNaN"] = "ZodNaN";
|
|
3987
|
+
ZodFirstPartyTypeKind22["ZodBigInt"] = "ZodBigInt";
|
|
3988
|
+
ZodFirstPartyTypeKind22["ZodBoolean"] = "ZodBoolean";
|
|
3989
|
+
ZodFirstPartyTypeKind22["ZodDate"] = "ZodDate";
|
|
3990
|
+
ZodFirstPartyTypeKind22["ZodSymbol"] = "ZodSymbol";
|
|
3991
|
+
ZodFirstPartyTypeKind22["ZodUndefined"] = "ZodUndefined";
|
|
3992
|
+
ZodFirstPartyTypeKind22["ZodNull"] = "ZodNull";
|
|
3993
|
+
ZodFirstPartyTypeKind22["ZodAny"] = "ZodAny";
|
|
3994
|
+
ZodFirstPartyTypeKind22["ZodUnknown"] = "ZodUnknown";
|
|
3995
|
+
ZodFirstPartyTypeKind22["ZodNever"] = "ZodNever";
|
|
3996
|
+
ZodFirstPartyTypeKind22["ZodVoid"] = "ZodVoid";
|
|
3997
|
+
ZodFirstPartyTypeKind22["ZodArray"] = "ZodArray";
|
|
3998
|
+
ZodFirstPartyTypeKind22["ZodObject"] = "ZodObject";
|
|
3999
|
+
ZodFirstPartyTypeKind22["ZodUnion"] = "ZodUnion";
|
|
4000
|
+
ZodFirstPartyTypeKind22["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
|
4001
|
+
ZodFirstPartyTypeKind22["ZodIntersection"] = "ZodIntersection";
|
|
4002
|
+
ZodFirstPartyTypeKind22["ZodTuple"] = "ZodTuple";
|
|
4003
|
+
ZodFirstPartyTypeKind22["ZodRecord"] = "ZodRecord";
|
|
4004
|
+
ZodFirstPartyTypeKind22["ZodMap"] = "ZodMap";
|
|
4005
|
+
ZodFirstPartyTypeKind22["ZodSet"] = "ZodSet";
|
|
4006
|
+
ZodFirstPartyTypeKind22["ZodFunction"] = "ZodFunction";
|
|
4007
|
+
ZodFirstPartyTypeKind22["ZodLazy"] = "ZodLazy";
|
|
4008
|
+
ZodFirstPartyTypeKind22["ZodLiteral"] = "ZodLiteral";
|
|
4009
|
+
ZodFirstPartyTypeKind22["ZodEnum"] = "ZodEnum";
|
|
4010
|
+
ZodFirstPartyTypeKind22["ZodEffects"] = "ZodEffects";
|
|
4011
|
+
ZodFirstPartyTypeKind22["ZodNativeEnum"] = "ZodNativeEnum";
|
|
4012
|
+
ZodFirstPartyTypeKind22["ZodOptional"] = "ZodOptional";
|
|
4013
|
+
ZodFirstPartyTypeKind22["ZodNullable"] = "ZodNullable";
|
|
4014
|
+
ZodFirstPartyTypeKind22["ZodDefault"] = "ZodDefault";
|
|
4015
|
+
ZodFirstPartyTypeKind22["ZodCatch"] = "ZodCatch";
|
|
4016
|
+
ZodFirstPartyTypeKind22["ZodPromise"] = "ZodPromise";
|
|
4017
|
+
ZodFirstPartyTypeKind22["ZodBranded"] = "ZodBranded";
|
|
4018
|
+
ZodFirstPartyTypeKind22["ZodPipeline"] = "ZodPipeline";
|
|
4019
|
+
ZodFirstPartyTypeKind22["ZodReadonly"] = "ZodReadonly";
|
|
4031
4020
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
4032
4021
|
var instanceOfType = (cls, params = {
|
|
4033
4022
|
message: `Input not instance of ${cls.name}`
|
|
@@ -4080,8 +4069,6 @@ var coerce = {
|
|
|
4080
4069
|
date: ((arg) => ZodDate.create({ ...arg, coerce: true }))
|
|
4081
4070
|
};
|
|
4082
4071
|
var NEVER = INVALID;
|
|
4083
|
-
|
|
4084
|
-
// ../../packages/shared/dist/schemas/index.js
|
|
4085
4072
|
var MAX_JSON_SIZE = 1e4;
|
|
4086
4073
|
function jsonSizeCheck(val) {
|
|
4087
4074
|
return JSON.stringify(val).length <= MAX_JSON_SIZE;
|
|
@@ -4189,13 +4176,9 @@ var checkInFiltersSchema = external_exports.object({
|
|
|
4189
4176
|
urgency: urgencySchema.optional(),
|
|
4190
4177
|
agent_id: external_exports.string().optional()
|
|
4191
4178
|
});
|
|
4192
|
-
|
|
4193
|
-
// ../../packages/shared/dist/constants/index.js
|
|
4194
4179
|
var POLL_INITIAL_INTERVAL_MS = 2e3;
|
|
4195
4180
|
var POLL_MAX_INTERVAL_MS = 3e4;
|
|
4196
4181
|
var POLL_BACKOFF_MULTIPLIER = 1.5;
|
|
4197
|
-
|
|
4198
|
-
// ../../packages/sdk-ts/src/index.ts
|
|
4199
4182
|
var WaitroomError = class extends Error {
|
|
4200
4183
|
constructor(message, statusCode, code, details) {
|
|
4201
4184
|
super(message);
|
|
@@ -5076,6 +5059,4193 @@ async function runHook(eventName, data) {
|
|
|
5076
5059
|
});
|
|
5077
5060
|
}
|
|
5078
5061
|
|
|
5062
|
+
// ../../packages/shared/dist/types/enums.js
|
|
5063
|
+
var RiskLevel2 = {
|
|
5064
|
+
LOW: "low",
|
|
5065
|
+
MEDIUM: "medium",
|
|
5066
|
+
HIGH: "high",
|
|
5067
|
+
CRITICAL: "critical"
|
|
5068
|
+
};
|
|
5069
|
+
var Urgency2 = {
|
|
5070
|
+
LOW: "low",
|
|
5071
|
+
NORMAL: "normal",
|
|
5072
|
+
HIGH: "high",
|
|
5073
|
+
URGENT: "urgent"
|
|
5074
|
+
};
|
|
5075
|
+
var CheckInStatus2 = {
|
|
5076
|
+
PENDING: "pending",
|
|
5077
|
+
APPROVED: "approved",
|
|
5078
|
+
REJECTED: "rejected",
|
|
5079
|
+
MODIFIED: "modified",
|
|
5080
|
+
EXPIRED: "expired",
|
|
5081
|
+
WITHDRAWN: "withdrawn"
|
|
5082
|
+
};
|
|
5083
|
+
var TimeoutAction2 = {
|
|
5084
|
+
AUTO_APPROVE: "auto_approve",
|
|
5085
|
+
CANCEL: "cancel",
|
|
5086
|
+
HOLD: "hold"
|
|
5087
|
+
};
|
|
5088
|
+
var PolicyAction2 = {
|
|
5089
|
+
AUTO_APPROVE: "auto_approve",
|
|
5090
|
+
REQUIRE_APPROVAL: "require_approval",
|
|
5091
|
+
FORBID: "forbid"
|
|
5092
|
+
};
|
|
5093
|
+
|
|
5094
|
+
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
|
|
5095
|
+
var external_exports2 = {};
|
|
5096
|
+
__export(external_exports2, {
|
|
5097
|
+
BRAND: () => BRAND2,
|
|
5098
|
+
DIRTY: () => DIRTY2,
|
|
5099
|
+
EMPTY_PATH: () => EMPTY_PATH2,
|
|
5100
|
+
INVALID: () => INVALID2,
|
|
5101
|
+
NEVER: () => NEVER2,
|
|
5102
|
+
OK: () => OK2,
|
|
5103
|
+
ParseStatus: () => ParseStatus2,
|
|
5104
|
+
Schema: () => ZodType2,
|
|
5105
|
+
ZodAny: () => ZodAny2,
|
|
5106
|
+
ZodArray: () => ZodArray2,
|
|
5107
|
+
ZodBigInt: () => ZodBigInt2,
|
|
5108
|
+
ZodBoolean: () => ZodBoolean2,
|
|
5109
|
+
ZodBranded: () => ZodBranded2,
|
|
5110
|
+
ZodCatch: () => ZodCatch2,
|
|
5111
|
+
ZodDate: () => ZodDate2,
|
|
5112
|
+
ZodDefault: () => ZodDefault2,
|
|
5113
|
+
ZodDiscriminatedUnion: () => ZodDiscriminatedUnion2,
|
|
5114
|
+
ZodEffects: () => ZodEffects2,
|
|
5115
|
+
ZodEnum: () => ZodEnum2,
|
|
5116
|
+
ZodError: () => ZodError2,
|
|
5117
|
+
ZodFirstPartyTypeKind: () => ZodFirstPartyTypeKind2,
|
|
5118
|
+
ZodFunction: () => ZodFunction2,
|
|
5119
|
+
ZodIntersection: () => ZodIntersection2,
|
|
5120
|
+
ZodIssueCode: () => ZodIssueCode2,
|
|
5121
|
+
ZodLazy: () => ZodLazy2,
|
|
5122
|
+
ZodLiteral: () => ZodLiteral2,
|
|
5123
|
+
ZodMap: () => ZodMap2,
|
|
5124
|
+
ZodNaN: () => ZodNaN2,
|
|
5125
|
+
ZodNativeEnum: () => ZodNativeEnum2,
|
|
5126
|
+
ZodNever: () => ZodNever2,
|
|
5127
|
+
ZodNull: () => ZodNull2,
|
|
5128
|
+
ZodNullable: () => ZodNullable2,
|
|
5129
|
+
ZodNumber: () => ZodNumber2,
|
|
5130
|
+
ZodObject: () => ZodObject2,
|
|
5131
|
+
ZodOptional: () => ZodOptional2,
|
|
5132
|
+
ZodParsedType: () => ZodParsedType2,
|
|
5133
|
+
ZodPipeline: () => ZodPipeline2,
|
|
5134
|
+
ZodPromise: () => ZodPromise2,
|
|
5135
|
+
ZodReadonly: () => ZodReadonly2,
|
|
5136
|
+
ZodRecord: () => ZodRecord2,
|
|
5137
|
+
ZodSchema: () => ZodType2,
|
|
5138
|
+
ZodSet: () => ZodSet2,
|
|
5139
|
+
ZodString: () => ZodString2,
|
|
5140
|
+
ZodSymbol: () => ZodSymbol2,
|
|
5141
|
+
ZodTransformer: () => ZodEffects2,
|
|
5142
|
+
ZodTuple: () => ZodTuple2,
|
|
5143
|
+
ZodType: () => ZodType2,
|
|
5144
|
+
ZodUndefined: () => ZodUndefined2,
|
|
5145
|
+
ZodUnion: () => ZodUnion2,
|
|
5146
|
+
ZodUnknown: () => ZodUnknown2,
|
|
5147
|
+
ZodVoid: () => ZodVoid2,
|
|
5148
|
+
addIssueToContext: () => addIssueToContext2,
|
|
5149
|
+
any: () => anyType2,
|
|
5150
|
+
array: () => arrayType2,
|
|
5151
|
+
bigint: () => bigIntType2,
|
|
5152
|
+
boolean: () => booleanType2,
|
|
5153
|
+
coerce: () => coerce2,
|
|
5154
|
+
custom: () => custom2,
|
|
5155
|
+
date: () => dateType2,
|
|
5156
|
+
datetimeRegex: () => datetimeRegex2,
|
|
5157
|
+
defaultErrorMap: () => en_default2,
|
|
5158
|
+
discriminatedUnion: () => discriminatedUnionType2,
|
|
5159
|
+
effect: () => effectsType2,
|
|
5160
|
+
enum: () => enumType2,
|
|
5161
|
+
function: () => functionType2,
|
|
5162
|
+
getErrorMap: () => getErrorMap2,
|
|
5163
|
+
getParsedType: () => getParsedType2,
|
|
5164
|
+
instanceof: () => instanceOfType2,
|
|
5165
|
+
intersection: () => intersectionType2,
|
|
5166
|
+
isAborted: () => isAborted2,
|
|
5167
|
+
isAsync: () => isAsync2,
|
|
5168
|
+
isDirty: () => isDirty2,
|
|
5169
|
+
isValid: () => isValid2,
|
|
5170
|
+
late: () => late2,
|
|
5171
|
+
lazy: () => lazyType2,
|
|
5172
|
+
literal: () => literalType2,
|
|
5173
|
+
makeIssue: () => makeIssue2,
|
|
5174
|
+
map: () => mapType2,
|
|
5175
|
+
nan: () => nanType2,
|
|
5176
|
+
nativeEnum: () => nativeEnumType2,
|
|
5177
|
+
never: () => neverType2,
|
|
5178
|
+
null: () => nullType2,
|
|
5179
|
+
nullable: () => nullableType2,
|
|
5180
|
+
number: () => numberType2,
|
|
5181
|
+
object: () => objectType2,
|
|
5182
|
+
objectUtil: () => objectUtil2,
|
|
5183
|
+
oboolean: () => oboolean2,
|
|
5184
|
+
onumber: () => onumber2,
|
|
5185
|
+
optional: () => optionalType2,
|
|
5186
|
+
ostring: () => ostring2,
|
|
5187
|
+
pipeline: () => pipelineType2,
|
|
5188
|
+
preprocess: () => preprocessType2,
|
|
5189
|
+
promise: () => promiseType2,
|
|
5190
|
+
quotelessJson: () => quotelessJson2,
|
|
5191
|
+
record: () => recordType2,
|
|
5192
|
+
set: () => setType2,
|
|
5193
|
+
setErrorMap: () => setErrorMap2,
|
|
5194
|
+
strictObject: () => strictObjectType2,
|
|
5195
|
+
string: () => stringType2,
|
|
5196
|
+
symbol: () => symbolType2,
|
|
5197
|
+
transformer: () => effectsType2,
|
|
5198
|
+
tuple: () => tupleType2,
|
|
5199
|
+
undefined: () => undefinedType2,
|
|
5200
|
+
union: () => unionType2,
|
|
5201
|
+
unknown: () => unknownType2,
|
|
5202
|
+
util: () => util2,
|
|
5203
|
+
void: () => voidType2
|
|
5204
|
+
});
|
|
5205
|
+
|
|
5206
|
+
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
|
|
5207
|
+
var util2;
|
|
5208
|
+
(function(util3) {
|
|
5209
|
+
util3.assertEqual = (_) => {
|
|
5210
|
+
};
|
|
5211
|
+
function assertIs(_arg) {
|
|
5212
|
+
}
|
|
5213
|
+
util3.assertIs = assertIs;
|
|
5214
|
+
function assertNever(_x) {
|
|
5215
|
+
throw new Error();
|
|
5216
|
+
}
|
|
5217
|
+
util3.assertNever = assertNever;
|
|
5218
|
+
util3.arrayToEnum = (items) => {
|
|
5219
|
+
const obj = {};
|
|
5220
|
+
for (const item of items) {
|
|
5221
|
+
obj[item] = item;
|
|
5222
|
+
}
|
|
5223
|
+
return obj;
|
|
5224
|
+
};
|
|
5225
|
+
util3.getValidEnumValues = (obj) => {
|
|
5226
|
+
const validKeys = util3.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
|
5227
|
+
const filtered = {};
|
|
5228
|
+
for (const k of validKeys) {
|
|
5229
|
+
filtered[k] = obj[k];
|
|
5230
|
+
}
|
|
5231
|
+
return util3.objectValues(filtered);
|
|
5232
|
+
};
|
|
5233
|
+
util3.objectValues = (obj) => {
|
|
5234
|
+
return util3.objectKeys(obj).map(function(e) {
|
|
5235
|
+
return obj[e];
|
|
5236
|
+
});
|
|
5237
|
+
};
|
|
5238
|
+
util3.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
|
|
5239
|
+
const keys = [];
|
|
5240
|
+
for (const key in object) {
|
|
5241
|
+
if (Object.prototype.hasOwnProperty.call(object, key)) {
|
|
5242
|
+
keys.push(key);
|
|
5243
|
+
}
|
|
5244
|
+
}
|
|
5245
|
+
return keys;
|
|
5246
|
+
};
|
|
5247
|
+
util3.find = (arr, checker) => {
|
|
5248
|
+
for (const item of arr) {
|
|
5249
|
+
if (checker(item))
|
|
5250
|
+
return item;
|
|
5251
|
+
}
|
|
5252
|
+
return void 0;
|
|
5253
|
+
};
|
|
5254
|
+
util3.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
5255
|
+
function joinValues(array, separator = " | ") {
|
|
5256
|
+
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
5257
|
+
}
|
|
5258
|
+
util3.joinValues = joinValues;
|
|
5259
|
+
util3.jsonStringifyReplacer = (_, value) => {
|
|
5260
|
+
if (typeof value === "bigint") {
|
|
5261
|
+
return value.toString();
|
|
5262
|
+
}
|
|
5263
|
+
return value;
|
|
5264
|
+
};
|
|
5265
|
+
})(util2 || (util2 = {}));
|
|
5266
|
+
var objectUtil2;
|
|
5267
|
+
(function(objectUtil3) {
|
|
5268
|
+
objectUtil3.mergeShapes = (first, second) => {
|
|
5269
|
+
return {
|
|
5270
|
+
...first,
|
|
5271
|
+
...second
|
|
5272
|
+
// second overwrites first
|
|
5273
|
+
};
|
|
5274
|
+
};
|
|
5275
|
+
})(objectUtil2 || (objectUtil2 = {}));
|
|
5276
|
+
var ZodParsedType2 = util2.arrayToEnum([
|
|
5277
|
+
"string",
|
|
5278
|
+
"nan",
|
|
5279
|
+
"number",
|
|
5280
|
+
"integer",
|
|
5281
|
+
"float",
|
|
5282
|
+
"boolean",
|
|
5283
|
+
"date",
|
|
5284
|
+
"bigint",
|
|
5285
|
+
"symbol",
|
|
5286
|
+
"function",
|
|
5287
|
+
"undefined",
|
|
5288
|
+
"null",
|
|
5289
|
+
"array",
|
|
5290
|
+
"object",
|
|
5291
|
+
"unknown",
|
|
5292
|
+
"promise",
|
|
5293
|
+
"void",
|
|
5294
|
+
"never",
|
|
5295
|
+
"map",
|
|
5296
|
+
"set"
|
|
5297
|
+
]);
|
|
5298
|
+
var getParsedType2 = (data) => {
|
|
5299
|
+
const t = typeof data;
|
|
5300
|
+
switch (t) {
|
|
5301
|
+
case "undefined":
|
|
5302
|
+
return ZodParsedType2.undefined;
|
|
5303
|
+
case "string":
|
|
5304
|
+
return ZodParsedType2.string;
|
|
5305
|
+
case "number":
|
|
5306
|
+
return Number.isNaN(data) ? ZodParsedType2.nan : ZodParsedType2.number;
|
|
5307
|
+
case "boolean":
|
|
5308
|
+
return ZodParsedType2.boolean;
|
|
5309
|
+
case "function":
|
|
5310
|
+
return ZodParsedType2.function;
|
|
5311
|
+
case "bigint":
|
|
5312
|
+
return ZodParsedType2.bigint;
|
|
5313
|
+
case "symbol":
|
|
5314
|
+
return ZodParsedType2.symbol;
|
|
5315
|
+
case "object":
|
|
5316
|
+
if (Array.isArray(data)) {
|
|
5317
|
+
return ZodParsedType2.array;
|
|
5318
|
+
}
|
|
5319
|
+
if (data === null) {
|
|
5320
|
+
return ZodParsedType2.null;
|
|
5321
|
+
}
|
|
5322
|
+
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
|
5323
|
+
return ZodParsedType2.promise;
|
|
5324
|
+
}
|
|
5325
|
+
if (typeof Map !== "undefined" && data instanceof Map) {
|
|
5326
|
+
return ZodParsedType2.map;
|
|
5327
|
+
}
|
|
5328
|
+
if (typeof Set !== "undefined" && data instanceof Set) {
|
|
5329
|
+
return ZodParsedType2.set;
|
|
5330
|
+
}
|
|
5331
|
+
if (typeof Date !== "undefined" && data instanceof Date) {
|
|
5332
|
+
return ZodParsedType2.date;
|
|
5333
|
+
}
|
|
5334
|
+
return ZodParsedType2.object;
|
|
5335
|
+
default:
|
|
5336
|
+
return ZodParsedType2.unknown;
|
|
5337
|
+
}
|
|
5338
|
+
};
|
|
5339
|
+
|
|
5340
|
+
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/ZodError.js
|
|
5341
|
+
var ZodIssueCode2 = util2.arrayToEnum([
|
|
5342
|
+
"invalid_type",
|
|
5343
|
+
"invalid_literal",
|
|
5344
|
+
"custom",
|
|
5345
|
+
"invalid_union",
|
|
5346
|
+
"invalid_union_discriminator",
|
|
5347
|
+
"invalid_enum_value",
|
|
5348
|
+
"unrecognized_keys",
|
|
5349
|
+
"invalid_arguments",
|
|
5350
|
+
"invalid_return_type",
|
|
5351
|
+
"invalid_date",
|
|
5352
|
+
"invalid_string",
|
|
5353
|
+
"too_small",
|
|
5354
|
+
"too_big",
|
|
5355
|
+
"invalid_intersection_types",
|
|
5356
|
+
"not_multiple_of",
|
|
5357
|
+
"not_finite"
|
|
5358
|
+
]);
|
|
5359
|
+
var quotelessJson2 = (obj) => {
|
|
5360
|
+
const json = JSON.stringify(obj, null, 2);
|
|
5361
|
+
return json.replace(/"([^"]+)":/g, "$1:");
|
|
5362
|
+
};
|
|
5363
|
+
var ZodError2 = class _ZodError2 extends Error {
|
|
5364
|
+
get errors() {
|
|
5365
|
+
return this.issues;
|
|
5366
|
+
}
|
|
5367
|
+
constructor(issues) {
|
|
5368
|
+
super();
|
|
5369
|
+
this.issues = [];
|
|
5370
|
+
this.addIssue = (sub) => {
|
|
5371
|
+
this.issues = [...this.issues, sub];
|
|
5372
|
+
};
|
|
5373
|
+
this.addIssues = (subs = []) => {
|
|
5374
|
+
this.issues = [...this.issues, ...subs];
|
|
5375
|
+
};
|
|
5376
|
+
const actualProto = new.target.prototype;
|
|
5377
|
+
if (Object.setPrototypeOf) {
|
|
5378
|
+
Object.setPrototypeOf(this, actualProto);
|
|
5379
|
+
} else {
|
|
5380
|
+
this.__proto__ = actualProto;
|
|
5381
|
+
}
|
|
5382
|
+
this.name = "ZodError";
|
|
5383
|
+
this.issues = issues;
|
|
5384
|
+
}
|
|
5385
|
+
format(_mapper) {
|
|
5386
|
+
const mapper = _mapper || function(issue) {
|
|
5387
|
+
return issue.message;
|
|
5388
|
+
};
|
|
5389
|
+
const fieldErrors = { _errors: [] };
|
|
5390
|
+
const processError = (error) => {
|
|
5391
|
+
for (const issue of error.issues) {
|
|
5392
|
+
if (issue.code === "invalid_union") {
|
|
5393
|
+
issue.unionErrors.map(processError);
|
|
5394
|
+
} else if (issue.code === "invalid_return_type") {
|
|
5395
|
+
processError(issue.returnTypeError);
|
|
5396
|
+
} else if (issue.code === "invalid_arguments") {
|
|
5397
|
+
processError(issue.argumentsError);
|
|
5398
|
+
} else if (issue.path.length === 0) {
|
|
5399
|
+
fieldErrors._errors.push(mapper(issue));
|
|
5400
|
+
} else {
|
|
5401
|
+
let curr = fieldErrors;
|
|
5402
|
+
let i = 0;
|
|
5403
|
+
while (i < issue.path.length) {
|
|
5404
|
+
const el = issue.path[i];
|
|
5405
|
+
const terminal = i === issue.path.length - 1;
|
|
5406
|
+
if (!terminal) {
|
|
5407
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
5408
|
+
} else {
|
|
5409
|
+
curr[el] = curr[el] || { _errors: [] };
|
|
5410
|
+
curr[el]._errors.push(mapper(issue));
|
|
5411
|
+
}
|
|
5412
|
+
curr = curr[el];
|
|
5413
|
+
i++;
|
|
5414
|
+
}
|
|
5415
|
+
}
|
|
5416
|
+
}
|
|
5417
|
+
};
|
|
5418
|
+
processError(this);
|
|
5419
|
+
return fieldErrors;
|
|
5420
|
+
}
|
|
5421
|
+
static assert(value) {
|
|
5422
|
+
if (!(value instanceof _ZodError2)) {
|
|
5423
|
+
throw new Error(`Not a ZodError: ${value}`);
|
|
5424
|
+
}
|
|
5425
|
+
}
|
|
5426
|
+
toString() {
|
|
5427
|
+
return this.message;
|
|
5428
|
+
}
|
|
5429
|
+
get message() {
|
|
5430
|
+
return JSON.stringify(this.issues, util2.jsonStringifyReplacer, 2);
|
|
5431
|
+
}
|
|
5432
|
+
get isEmpty() {
|
|
5433
|
+
return this.issues.length === 0;
|
|
5434
|
+
}
|
|
5435
|
+
flatten(mapper = (issue) => issue.message) {
|
|
5436
|
+
const fieldErrors = {};
|
|
5437
|
+
const formErrors = [];
|
|
5438
|
+
for (const sub of this.issues) {
|
|
5439
|
+
if (sub.path.length > 0) {
|
|
5440
|
+
const firstEl = sub.path[0];
|
|
5441
|
+
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
5442
|
+
fieldErrors[firstEl].push(mapper(sub));
|
|
5443
|
+
} else {
|
|
5444
|
+
formErrors.push(mapper(sub));
|
|
5445
|
+
}
|
|
5446
|
+
}
|
|
5447
|
+
return { formErrors, fieldErrors };
|
|
5448
|
+
}
|
|
5449
|
+
get formErrors() {
|
|
5450
|
+
return this.flatten();
|
|
5451
|
+
}
|
|
5452
|
+
};
|
|
5453
|
+
ZodError2.create = (issues) => {
|
|
5454
|
+
const error = new ZodError2(issues);
|
|
5455
|
+
return error;
|
|
5456
|
+
};
|
|
5457
|
+
|
|
5458
|
+
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
|
|
5459
|
+
var errorMap2 = (issue, _ctx) => {
|
|
5460
|
+
let message;
|
|
5461
|
+
switch (issue.code) {
|
|
5462
|
+
case ZodIssueCode2.invalid_type:
|
|
5463
|
+
if (issue.received === ZodParsedType2.undefined) {
|
|
5464
|
+
message = "Required";
|
|
5465
|
+
} else {
|
|
5466
|
+
message = `Expected ${issue.expected}, received ${issue.received}`;
|
|
5467
|
+
}
|
|
5468
|
+
break;
|
|
5469
|
+
case ZodIssueCode2.invalid_literal:
|
|
5470
|
+
message = `Invalid literal value, expected ${JSON.stringify(issue.expected, util2.jsonStringifyReplacer)}`;
|
|
5471
|
+
break;
|
|
5472
|
+
case ZodIssueCode2.unrecognized_keys:
|
|
5473
|
+
message = `Unrecognized key(s) in object: ${util2.joinValues(issue.keys, ", ")}`;
|
|
5474
|
+
break;
|
|
5475
|
+
case ZodIssueCode2.invalid_union:
|
|
5476
|
+
message = `Invalid input`;
|
|
5477
|
+
break;
|
|
5478
|
+
case ZodIssueCode2.invalid_union_discriminator:
|
|
5479
|
+
message = `Invalid discriminator value. Expected ${util2.joinValues(issue.options)}`;
|
|
5480
|
+
break;
|
|
5481
|
+
case ZodIssueCode2.invalid_enum_value:
|
|
5482
|
+
message = `Invalid enum value. Expected ${util2.joinValues(issue.options)}, received '${issue.received}'`;
|
|
5483
|
+
break;
|
|
5484
|
+
case ZodIssueCode2.invalid_arguments:
|
|
5485
|
+
message = `Invalid function arguments`;
|
|
5486
|
+
break;
|
|
5487
|
+
case ZodIssueCode2.invalid_return_type:
|
|
5488
|
+
message = `Invalid function return type`;
|
|
5489
|
+
break;
|
|
5490
|
+
case ZodIssueCode2.invalid_date:
|
|
5491
|
+
message = `Invalid date`;
|
|
5492
|
+
break;
|
|
5493
|
+
case ZodIssueCode2.invalid_string:
|
|
5494
|
+
if (typeof issue.validation === "object") {
|
|
5495
|
+
if ("includes" in issue.validation) {
|
|
5496
|
+
message = `Invalid input: must include "${issue.validation.includes}"`;
|
|
5497
|
+
if (typeof issue.validation.position === "number") {
|
|
5498
|
+
message = `${message} at one or more positions greater than or equal to ${issue.validation.position}`;
|
|
5499
|
+
}
|
|
5500
|
+
} else if ("startsWith" in issue.validation) {
|
|
5501
|
+
message = `Invalid input: must start with "${issue.validation.startsWith}"`;
|
|
5502
|
+
} else if ("endsWith" in issue.validation) {
|
|
5503
|
+
message = `Invalid input: must end with "${issue.validation.endsWith}"`;
|
|
5504
|
+
} else {
|
|
5505
|
+
util2.assertNever(issue.validation);
|
|
5506
|
+
}
|
|
5507
|
+
} else if (issue.validation !== "regex") {
|
|
5508
|
+
message = `Invalid ${issue.validation}`;
|
|
5509
|
+
} else {
|
|
5510
|
+
message = "Invalid";
|
|
5511
|
+
}
|
|
5512
|
+
break;
|
|
5513
|
+
case ZodIssueCode2.too_small:
|
|
5514
|
+
if (issue.type === "array")
|
|
5515
|
+
message = `Array must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
|
|
5516
|
+
else if (issue.type === "string")
|
|
5517
|
+
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
5518
|
+
else if (issue.type === "number")
|
|
5519
|
+
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
5520
|
+
else if (issue.type === "bigint")
|
|
5521
|
+
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
5522
|
+
else if (issue.type === "date")
|
|
5523
|
+
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
5524
|
+
else
|
|
5525
|
+
message = "Invalid input";
|
|
5526
|
+
break;
|
|
5527
|
+
case ZodIssueCode2.too_big:
|
|
5528
|
+
if (issue.type === "array")
|
|
5529
|
+
message = `Array must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
|
|
5530
|
+
else if (issue.type === "string")
|
|
5531
|
+
message = `String must contain ${issue.exact ? `exactly` : issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
|
5532
|
+
else if (issue.type === "number")
|
|
5533
|
+
message = `Number must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
5534
|
+
else if (issue.type === "bigint")
|
|
5535
|
+
message = `BigInt must be ${issue.exact ? `exactly` : issue.inclusive ? `less than or equal to` : `less than`} ${issue.maximum}`;
|
|
5536
|
+
else if (issue.type === "date")
|
|
5537
|
+
message = `Date must be ${issue.exact ? `exactly` : issue.inclusive ? `smaller than or equal to` : `smaller than`} ${new Date(Number(issue.maximum))}`;
|
|
5538
|
+
else
|
|
5539
|
+
message = "Invalid input";
|
|
5540
|
+
break;
|
|
5541
|
+
case ZodIssueCode2.custom:
|
|
5542
|
+
message = `Invalid input`;
|
|
5543
|
+
break;
|
|
5544
|
+
case ZodIssueCode2.invalid_intersection_types:
|
|
5545
|
+
message = `Intersection results could not be merged`;
|
|
5546
|
+
break;
|
|
5547
|
+
case ZodIssueCode2.not_multiple_of:
|
|
5548
|
+
message = `Number must be a multiple of ${issue.multipleOf}`;
|
|
5549
|
+
break;
|
|
5550
|
+
case ZodIssueCode2.not_finite:
|
|
5551
|
+
message = "Number must be finite";
|
|
5552
|
+
break;
|
|
5553
|
+
default:
|
|
5554
|
+
message = _ctx.defaultError;
|
|
5555
|
+
util2.assertNever(issue);
|
|
5556
|
+
}
|
|
5557
|
+
return { message };
|
|
5558
|
+
};
|
|
5559
|
+
var en_default2 = errorMap2;
|
|
5560
|
+
|
|
5561
|
+
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/errors.js
|
|
5562
|
+
var overrideErrorMap2 = en_default2;
|
|
5563
|
+
function setErrorMap2(map) {
|
|
5564
|
+
overrideErrorMap2 = map;
|
|
5565
|
+
}
|
|
5566
|
+
function getErrorMap2() {
|
|
5567
|
+
return overrideErrorMap2;
|
|
5568
|
+
}
|
|
5569
|
+
|
|
5570
|
+
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
5571
|
+
var makeIssue2 = (params) => {
|
|
5572
|
+
const { data, path: path6, errorMaps, issueData } = params;
|
|
5573
|
+
const fullPath = [...path6, ...issueData.path || []];
|
|
5574
|
+
const fullIssue = {
|
|
5575
|
+
...issueData,
|
|
5576
|
+
path: fullPath
|
|
5577
|
+
};
|
|
5578
|
+
if (issueData.message !== void 0) {
|
|
5579
|
+
return {
|
|
5580
|
+
...issueData,
|
|
5581
|
+
path: fullPath,
|
|
5582
|
+
message: issueData.message
|
|
5583
|
+
};
|
|
5584
|
+
}
|
|
5585
|
+
let errorMessage = "";
|
|
5586
|
+
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
|
5587
|
+
for (const map of maps) {
|
|
5588
|
+
errorMessage = map(fullIssue, { data, defaultError: errorMessage }).message;
|
|
5589
|
+
}
|
|
5590
|
+
return {
|
|
5591
|
+
...issueData,
|
|
5592
|
+
path: fullPath,
|
|
5593
|
+
message: errorMessage
|
|
5594
|
+
};
|
|
5595
|
+
};
|
|
5596
|
+
var EMPTY_PATH2 = [];
|
|
5597
|
+
function addIssueToContext2(ctx, issueData) {
|
|
5598
|
+
const overrideMap = getErrorMap2();
|
|
5599
|
+
const issue = makeIssue2({
|
|
5600
|
+
issueData,
|
|
5601
|
+
data: ctx.data,
|
|
5602
|
+
path: ctx.path,
|
|
5603
|
+
errorMaps: [
|
|
5604
|
+
ctx.common.contextualErrorMap,
|
|
5605
|
+
// contextual error map is first priority
|
|
5606
|
+
ctx.schemaErrorMap,
|
|
5607
|
+
// then schema-bound map if available
|
|
5608
|
+
overrideMap,
|
|
5609
|
+
// then global override map
|
|
5610
|
+
overrideMap === en_default2 ? void 0 : en_default2
|
|
5611
|
+
// then global default map
|
|
5612
|
+
].filter((x) => !!x)
|
|
5613
|
+
});
|
|
5614
|
+
ctx.common.issues.push(issue);
|
|
5615
|
+
}
|
|
5616
|
+
var ParseStatus2 = class _ParseStatus2 {
|
|
5617
|
+
constructor() {
|
|
5618
|
+
this.value = "valid";
|
|
5619
|
+
}
|
|
5620
|
+
dirty() {
|
|
5621
|
+
if (this.value === "valid")
|
|
5622
|
+
this.value = "dirty";
|
|
5623
|
+
}
|
|
5624
|
+
abort() {
|
|
5625
|
+
if (this.value !== "aborted")
|
|
5626
|
+
this.value = "aborted";
|
|
5627
|
+
}
|
|
5628
|
+
static mergeArray(status, results) {
|
|
5629
|
+
const arrayValue = [];
|
|
5630
|
+
for (const s of results) {
|
|
5631
|
+
if (s.status === "aborted")
|
|
5632
|
+
return INVALID2;
|
|
5633
|
+
if (s.status === "dirty")
|
|
5634
|
+
status.dirty();
|
|
5635
|
+
arrayValue.push(s.value);
|
|
5636
|
+
}
|
|
5637
|
+
return { status: status.value, value: arrayValue };
|
|
5638
|
+
}
|
|
5639
|
+
static async mergeObjectAsync(status, pairs) {
|
|
5640
|
+
const syncPairs = [];
|
|
5641
|
+
for (const pair of pairs) {
|
|
5642
|
+
const key = await pair.key;
|
|
5643
|
+
const value = await pair.value;
|
|
5644
|
+
syncPairs.push({
|
|
5645
|
+
key,
|
|
5646
|
+
value
|
|
5647
|
+
});
|
|
5648
|
+
}
|
|
5649
|
+
return _ParseStatus2.mergeObjectSync(status, syncPairs);
|
|
5650
|
+
}
|
|
5651
|
+
static mergeObjectSync(status, pairs) {
|
|
5652
|
+
const finalObject = {};
|
|
5653
|
+
for (const pair of pairs) {
|
|
5654
|
+
const { key, value } = pair;
|
|
5655
|
+
if (key.status === "aborted")
|
|
5656
|
+
return INVALID2;
|
|
5657
|
+
if (value.status === "aborted")
|
|
5658
|
+
return INVALID2;
|
|
5659
|
+
if (key.status === "dirty")
|
|
5660
|
+
status.dirty();
|
|
5661
|
+
if (value.status === "dirty")
|
|
5662
|
+
status.dirty();
|
|
5663
|
+
if (key.value !== "__proto__" && (typeof value.value !== "undefined" || pair.alwaysSet)) {
|
|
5664
|
+
finalObject[key.value] = value.value;
|
|
5665
|
+
}
|
|
5666
|
+
}
|
|
5667
|
+
return { status: status.value, value: finalObject };
|
|
5668
|
+
}
|
|
5669
|
+
};
|
|
5670
|
+
var INVALID2 = Object.freeze({
|
|
5671
|
+
status: "aborted"
|
|
5672
|
+
});
|
|
5673
|
+
var DIRTY2 = (value) => ({ status: "dirty", value });
|
|
5674
|
+
var OK2 = (value) => ({ status: "valid", value });
|
|
5675
|
+
var isAborted2 = (x) => x.status === "aborted";
|
|
5676
|
+
var isDirty2 = (x) => x.status === "dirty";
|
|
5677
|
+
var isValid2 = (x) => x.status === "valid";
|
|
5678
|
+
var isAsync2 = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
5679
|
+
|
|
5680
|
+
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/errorUtil.js
|
|
5681
|
+
var errorUtil2;
|
|
5682
|
+
(function(errorUtil3) {
|
|
5683
|
+
errorUtil3.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
5684
|
+
errorUtil3.toString = (message) => typeof message === "string" ? message : message?.message;
|
|
5685
|
+
})(errorUtil2 || (errorUtil2 = {}));
|
|
5686
|
+
|
|
5687
|
+
// ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
5688
|
+
var ParseInputLazyPath2 = class {
|
|
5689
|
+
constructor(parent, value, path6, key) {
|
|
5690
|
+
this._cachedPath = [];
|
|
5691
|
+
this.parent = parent;
|
|
5692
|
+
this.data = value;
|
|
5693
|
+
this._path = path6;
|
|
5694
|
+
this._key = key;
|
|
5695
|
+
}
|
|
5696
|
+
get path() {
|
|
5697
|
+
if (!this._cachedPath.length) {
|
|
5698
|
+
if (Array.isArray(this._key)) {
|
|
5699
|
+
this._cachedPath.push(...this._path, ...this._key);
|
|
5700
|
+
} else {
|
|
5701
|
+
this._cachedPath.push(...this._path, this._key);
|
|
5702
|
+
}
|
|
5703
|
+
}
|
|
5704
|
+
return this._cachedPath;
|
|
5705
|
+
}
|
|
5706
|
+
};
|
|
5707
|
+
var handleResult2 = (ctx, result) => {
|
|
5708
|
+
if (isValid2(result)) {
|
|
5709
|
+
return { success: true, data: result.value };
|
|
5710
|
+
} else {
|
|
5711
|
+
if (!ctx.common.issues.length) {
|
|
5712
|
+
throw new Error("Validation failed but no issues detected.");
|
|
5713
|
+
}
|
|
5714
|
+
return {
|
|
5715
|
+
success: false,
|
|
5716
|
+
get error() {
|
|
5717
|
+
if (this._error)
|
|
5718
|
+
return this._error;
|
|
5719
|
+
const error = new ZodError2(ctx.common.issues);
|
|
5720
|
+
this._error = error;
|
|
5721
|
+
return this._error;
|
|
5722
|
+
}
|
|
5723
|
+
};
|
|
5724
|
+
}
|
|
5725
|
+
};
|
|
5726
|
+
function processCreateParams2(params) {
|
|
5727
|
+
if (!params)
|
|
5728
|
+
return {};
|
|
5729
|
+
const { errorMap: errorMap3, invalid_type_error, required_error, description } = params;
|
|
5730
|
+
if (errorMap3 && (invalid_type_error || required_error)) {
|
|
5731
|
+
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
5732
|
+
}
|
|
5733
|
+
if (errorMap3)
|
|
5734
|
+
return { errorMap: errorMap3, description };
|
|
5735
|
+
const customMap = (iss, ctx) => {
|
|
5736
|
+
const { message } = params;
|
|
5737
|
+
if (iss.code === "invalid_enum_value") {
|
|
5738
|
+
return { message: message ?? ctx.defaultError };
|
|
5739
|
+
}
|
|
5740
|
+
if (typeof ctx.data === "undefined") {
|
|
5741
|
+
return { message: message ?? required_error ?? ctx.defaultError };
|
|
5742
|
+
}
|
|
5743
|
+
if (iss.code !== "invalid_type")
|
|
5744
|
+
return { message: ctx.defaultError };
|
|
5745
|
+
return { message: message ?? invalid_type_error ?? ctx.defaultError };
|
|
5746
|
+
};
|
|
5747
|
+
return { errorMap: customMap, description };
|
|
5748
|
+
}
|
|
5749
|
+
var ZodType2 = class {
|
|
5750
|
+
get description() {
|
|
5751
|
+
return this._def.description;
|
|
5752
|
+
}
|
|
5753
|
+
_getType(input) {
|
|
5754
|
+
return getParsedType2(input.data);
|
|
5755
|
+
}
|
|
5756
|
+
_getOrReturnCtx(input, ctx) {
|
|
5757
|
+
return ctx || {
|
|
5758
|
+
common: input.parent.common,
|
|
5759
|
+
data: input.data,
|
|
5760
|
+
parsedType: getParsedType2(input.data),
|
|
5761
|
+
schemaErrorMap: this._def.errorMap,
|
|
5762
|
+
path: input.path,
|
|
5763
|
+
parent: input.parent
|
|
5764
|
+
};
|
|
5765
|
+
}
|
|
5766
|
+
_processInputParams(input) {
|
|
5767
|
+
return {
|
|
5768
|
+
status: new ParseStatus2(),
|
|
5769
|
+
ctx: {
|
|
5770
|
+
common: input.parent.common,
|
|
5771
|
+
data: input.data,
|
|
5772
|
+
parsedType: getParsedType2(input.data),
|
|
5773
|
+
schemaErrorMap: this._def.errorMap,
|
|
5774
|
+
path: input.path,
|
|
5775
|
+
parent: input.parent
|
|
5776
|
+
}
|
|
5777
|
+
};
|
|
5778
|
+
}
|
|
5779
|
+
_parseSync(input) {
|
|
5780
|
+
const result = this._parse(input);
|
|
5781
|
+
if (isAsync2(result)) {
|
|
5782
|
+
throw new Error("Synchronous parse encountered promise.");
|
|
5783
|
+
}
|
|
5784
|
+
return result;
|
|
5785
|
+
}
|
|
5786
|
+
_parseAsync(input) {
|
|
5787
|
+
const result = this._parse(input);
|
|
5788
|
+
return Promise.resolve(result);
|
|
5789
|
+
}
|
|
5790
|
+
parse(data, params) {
|
|
5791
|
+
const result = this.safeParse(data, params);
|
|
5792
|
+
if (result.success)
|
|
5793
|
+
return result.data;
|
|
5794
|
+
throw result.error;
|
|
5795
|
+
}
|
|
5796
|
+
safeParse(data, params) {
|
|
5797
|
+
const ctx = {
|
|
5798
|
+
common: {
|
|
5799
|
+
issues: [],
|
|
5800
|
+
async: params?.async ?? false,
|
|
5801
|
+
contextualErrorMap: params?.errorMap
|
|
5802
|
+
},
|
|
5803
|
+
path: params?.path || [],
|
|
5804
|
+
schemaErrorMap: this._def.errorMap,
|
|
5805
|
+
parent: null,
|
|
5806
|
+
data,
|
|
5807
|
+
parsedType: getParsedType2(data)
|
|
5808
|
+
};
|
|
5809
|
+
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
|
5810
|
+
return handleResult2(ctx, result);
|
|
5811
|
+
}
|
|
5812
|
+
"~validate"(data) {
|
|
5813
|
+
const ctx = {
|
|
5814
|
+
common: {
|
|
5815
|
+
issues: [],
|
|
5816
|
+
async: !!this["~standard"].async
|
|
5817
|
+
},
|
|
5818
|
+
path: [],
|
|
5819
|
+
schemaErrorMap: this._def.errorMap,
|
|
5820
|
+
parent: null,
|
|
5821
|
+
data,
|
|
5822
|
+
parsedType: getParsedType2(data)
|
|
5823
|
+
};
|
|
5824
|
+
if (!this["~standard"].async) {
|
|
5825
|
+
try {
|
|
5826
|
+
const result = this._parseSync({ data, path: [], parent: ctx });
|
|
5827
|
+
return isValid2(result) ? {
|
|
5828
|
+
value: result.value
|
|
5829
|
+
} : {
|
|
5830
|
+
issues: ctx.common.issues
|
|
5831
|
+
};
|
|
5832
|
+
} catch (err) {
|
|
5833
|
+
if (err?.message?.toLowerCase()?.includes("encountered")) {
|
|
5834
|
+
this["~standard"].async = true;
|
|
5835
|
+
}
|
|
5836
|
+
ctx.common = {
|
|
5837
|
+
issues: [],
|
|
5838
|
+
async: true
|
|
5839
|
+
};
|
|
5840
|
+
}
|
|
5841
|
+
}
|
|
5842
|
+
return this._parseAsync({ data, path: [], parent: ctx }).then((result) => isValid2(result) ? {
|
|
5843
|
+
value: result.value
|
|
5844
|
+
} : {
|
|
5845
|
+
issues: ctx.common.issues
|
|
5846
|
+
});
|
|
5847
|
+
}
|
|
5848
|
+
async parseAsync(data, params) {
|
|
5849
|
+
const result = await this.safeParseAsync(data, params);
|
|
5850
|
+
if (result.success)
|
|
5851
|
+
return result.data;
|
|
5852
|
+
throw result.error;
|
|
5853
|
+
}
|
|
5854
|
+
async safeParseAsync(data, params) {
|
|
5855
|
+
const ctx = {
|
|
5856
|
+
common: {
|
|
5857
|
+
issues: [],
|
|
5858
|
+
contextualErrorMap: params?.errorMap,
|
|
5859
|
+
async: true
|
|
5860
|
+
},
|
|
5861
|
+
path: params?.path || [],
|
|
5862
|
+
schemaErrorMap: this._def.errorMap,
|
|
5863
|
+
parent: null,
|
|
5864
|
+
data,
|
|
5865
|
+
parsedType: getParsedType2(data)
|
|
5866
|
+
};
|
|
5867
|
+
const maybeAsyncResult = this._parse({ data, path: ctx.path, parent: ctx });
|
|
5868
|
+
const result = await (isAsync2(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult));
|
|
5869
|
+
return handleResult2(ctx, result);
|
|
5870
|
+
}
|
|
5871
|
+
refine(check, message) {
|
|
5872
|
+
const getIssueProperties = (val) => {
|
|
5873
|
+
if (typeof message === "string" || typeof message === "undefined") {
|
|
5874
|
+
return { message };
|
|
5875
|
+
} else if (typeof message === "function") {
|
|
5876
|
+
return message(val);
|
|
5877
|
+
} else {
|
|
5878
|
+
return message;
|
|
5879
|
+
}
|
|
5880
|
+
};
|
|
5881
|
+
return this._refinement((val, ctx) => {
|
|
5882
|
+
const result = check(val);
|
|
5883
|
+
const setError = () => ctx.addIssue({
|
|
5884
|
+
code: ZodIssueCode2.custom,
|
|
5885
|
+
...getIssueProperties(val)
|
|
5886
|
+
});
|
|
5887
|
+
if (typeof Promise !== "undefined" && result instanceof Promise) {
|
|
5888
|
+
return result.then((data) => {
|
|
5889
|
+
if (!data) {
|
|
5890
|
+
setError();
|
|
5891
|
+
return false;
|
|
5892
|
+
} else {
|
|
5893
|
+
return true;
|
|
5894
|
+
}
|
|
5895
|
+
});
|
|
5896
|
+
}
|
|
5897
|
+
if (!result) {
|
|
5898
|
+
setError();
|
|
5899
|
+
return false;
|
|
5900
|
+
} else {
|
|
5901
|
+
return true;
|
|
5902
|
+
}
|
|
5903
|
+
});
|
|
5904
|
+
}
|
|
5905
|
+
refinement(check, refinementData) {
|
|
5906
|
+
return this._refinement((val, ctx) => {
|
|
5907
|
+
if (!check(val)) {
|
|
5908
|
+
ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
|
|
5909
|
+
return false;
|
|
5910
|
+
} else {
|
|
5911
|
+
return true;
|
|
5912
|
+
}
|
|
5913
|
+
});
|
|
5914
|
+
}
|
|
5915
|
+
_refinement(refinement) {
|
|
5916
|
+
return new ZodEffects2({
|
|
5917
|
+
schema: this,
|
|
5918
|
+
typeName: ZodFirstPartyTypeKind2.ZodEffects,
|
|
5919
|
+
effect: { type: "refinement", refinement }
|
|
5920
|
+
});
|
|
5921
|
+
}
|
|
5922
|
+
superRefine(refinement) {
|
|
5923
|
+
return this._refinement(refinement);
|
|
5924
|
+
}
|
|
5925
|
+
constructor(def) {
|
|
5926
|
+
this.spa = this.safeParseAsync;
|
|
5927
|
+
this._def = def;
|
|
5928
|
+
this.parse = this.parse.bind(this);
|
|
5929
|
+
this.safeParse = this.safeParse.bind(this);
|
|
5930
|
+
this.parseAsync = this.parseAsync.bind(this);
|
|
5931
|
+
this.safeParseAsync = this.safeParseAsync.bind(this);
|
|
5932
|
+
this.spa = this.spa.bind(this);
|
|
5933
|
+
this.refine = this.refine.bind(this);
|
|
5934
|
+
this.refinement = this.refinement.bind(this);
|
|
5935
|
+
this.superRefine = this.superRefine.bind(this);
|
|
5936
|
+
this.optional = this.optional.bind(this);
|
|
5937
|
+
this.nullable = this.nullable.bind(this);
|
|
5938
|
+
this.nullish = this.nullish.bind(this);
|
|
5939
|
+
this.array = this.array.bind(this);
|
|
5940
|
+
this.promise = this.promise.bind(this);
|
|
5941
|
+
this.or = this.or.bind(this);
|
|
5942
|
+
this.and = this.and.bind(this);
|
|
5943
|
+
this.transform = this.transform.bind(this);
|
|
5944
|
+
this.brand = this.brand.bind(this);
|
|
5945
|
+
this.default = this.default.bind(this);
|
|
5946
|
+
this.catch = this.catch.bind(this);
|
|
5947
|
+
this.describe = this.describe.bind(this);
|
|
5948
|
+
this.pipe = this.pipe.bind(this);
|
|
5949
|
+
this.readonly = this.readonly.bind(this);
|
|
5950
|
+
this.isNullable = this.isNullable.bind(this);
|
|
5951
|
+
this.isOptional = this.isOptional.bind(this);
|
|
5952
|
+
this["~standard"] = {
|
|
5953
|
+
version: 1,
|
|
5954
|
+
vendor: "zod",
|
|
5955
|
+
validate: (data) => this["~validate"](data)
|
|
5956
|
+
};
|
|
5957
|
+
}
|
|
5958
|
+
optional() {
|
|
5959
|
+
return ZodOptional2.create(this, this._def);
|
|
5960
|
+
}
|
|
5961
|
+
nullable() {
|
|
5962
|
+
return ZodNullable2.create(this, this._def);
|
|
5963
|
+
}
|
|
5964
|
+
nullish() {
|
|
5965
|
+
return this.nullable().optional();
|
|
5966
|
+
}
|
|
5967
|
+
array() {
|
|
5968
|
+
return ZodArray2.create(this);
|
|
5969
|
+
}
|
|
5970
|
+
promise() {
|
|
5971
|
+
return ZodPromise2.create(this, this._def);
|
|
5972
|
+
}
|
|
5973
|
+
or(option) {
|
|
5974
|
+
return ZodUnion2.create([this, option], this._def);
|
|
5975
|
+
}
|
|
5976
|
+
and(incoming) {
|
|
5977
|
+
return ZodIntersection2.create(this, incoming, this._def);
|
|
5978
|
+
}
|
|
5979
|
+
transform(transform) {
|
|
5980
|
+
return new ZodEffects2({
|
|
5981
|
+
...processCreateParams2(this._def),
|
|
5982
|
+
schema: this,
|
|
5983
|
+
typeName: ZodFirstPartyTypeKind2.ZodEffects,
|
|
5984
|
+
effect: { type: "transform", transform }
|
|
5985
|
+
});
|
|
5986
|
+
}
|
|
5987
|
+
default(def) {
|
|
5988
|
+
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
|
5989
|
+
return new ZodDefault2({
|
|
5990
|
+
...processCreateParams2(this._def),
|
|
5991
|
+
innerType: this,
|
|
5992
|
+
defaultValue: defaultValueFunc,
|
|
5993
|
+
typeName: ZodFirstPartyTypeKind2.ZodDefault
|
|
5994
|
+
});
|
|
5995
|
+
}
|
|
5996
|
+
brand() {
|
|
5997
|
+
return new ZodBranded2({
|
|
5998
|
+
typeName: ZodFirstPartyTypeKind2.ZodBranded,
|
|
5999
|
+
type: this,
|
|
6000
|
+
...processCreateParams2(this._def)
|
|
6001
|
+
});
|
|
6002
|
+
}
|
|
6003
|
+
catch(def) {
|
|
6004
|
+
const catchValueFunc = typeof def === "function" ? def : () => def;
|
|
6005
|
+
return new ZodCatch2({
|
|
6006
|
+
...processCreateParams2(this._def),
|
|
6007
|
+
innerType: this,
|
|
6008
|
+
catchValue: catchValueFunc,
|
|
6009
|
+
typeName: ZodFirstPartyTypeKind2.ZodCatch
|
|
6010
|
+
});
|
|
6011
|
+
}
|
|
6012
|
+
describe(description) {
|
|
6013
|
+
const This = this.constructor;
|
|
6014
|
+
return new This({
|
|
6015
|
+
...this._def,
|
|
6016
|
+
description
|
|
6017
|
+
});
|
|
6018
|
+
}
|
|
6019
|
+
pipe(target) {
|
|
6020
|
+
return ZodPipeline2.create(this, target);
|
|
6021
|
+
}
|
|
6022
|
+
readonly() {
|
|
6023
|
+
return ZodReadonly2.create(this);
|
|
6024
|
+
}
|
|
6025
|
+
isOptional() {
|
|
6026
|
+
return this.safeParse(void 0).success;
|
|
6027
|
+
}
|
|
6028
|
+
isNullable() {
|
|
6029
|
+
return this.safeParse(null).success;
|
|
6030
|
+
}
|
|
6031
|
+
};
|
|
6032
|
+
var cuidRegex2 = /^c[^\s-]{8,}$/i;
|
|
6033
|
+
var cuid2Regex2 = /^[0-9a-z]+$/;
|
|
6034
|
+
var ulidRegex2 = /^[0-9A-HJKMNP-TV-Z]{26}$/i;
|
|
6035
|
+
var uuidRegex2 = /^[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;
|
|
6036
|
+
var nanoidRegex2 = /^[a-z0-9_-]{21}$/i;
|
|
6037
|
+
var jwtRegex2 = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/;
|
|
6038
|
+
var durationRegex2 = /^[-+]?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)?)??$/;
|
|
6039
|
+
var emailRegex2 = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;
|
|
6040
|
+
var _emojiRegex2 = `^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;
|
|
6041
|
+
var emojiRegex2;
|
|
6042
|
+
var ipv4Regex2 = /^(?:(?: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])$/;
|
|
6043
|
+
var ipv4CidrRegex2 = /^(?:(?: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])$/;
|
|
6044
|
+
var ipv6Regex2 = /^(([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]))$/;
|
|
6045
|
+
var ipv6CidrRegex2 = /^(([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])$/;
|
|
6046
|
+
var base64Regex2 = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
6047
|
+
var base64urlRegex2 = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/;
|
|
6048
|
+
var dateRegexSource2 = `((\\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])))`;
|
|
6049
|
+
var dateRegex2 = new RegExp(`^${dateRegexSource2}$`);
|
|
6050
|
+
function timeRegexSource2(args) {
|
|
6051
|
+
let secondsRegexSource = `[0-5]\\d`;
|
|
6052
|
+
if (args.precision) {
|
|
6053
|
+
secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
|
|
6054
|
+
} else if (args.precision == null) {
|
|
6055
|
+
secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
|
|
6056
|
+
}
|
|
6057
|
+
const secondsQuantifier = args.precision ? "+" : "?";
|
|
6058
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
|
|
6059
|
+
}
|
|
6060
|
+
function timeRegex2(args) {
|
|
6061
|
+
return new RegExp(`^${timeRegexSource2(args)}$`);
|
|
6062
|
+
}
|
|
6063
|
+
function datetimeRegex2(args) {
|
|
6064
|
+
let regex = `${dateRegexSource2}T${timeRegexSource2(args)}`;
|
|
6065
|
+
const opts = [];
|
|
6066
|
+
opts.push(args.local ? `Z?` : `Z`);
|
|
6067
|
+
if (args.offset)
|
|
6068
|
+
opts.push(`([+-]\\d{2}:?\\d{2})`);
|
|
6069
|
+
regex = `${regex}(${opts.join("|")})`;
|
|
6070
|
+
return new RegExp(`^${regex}$`);
|
|
6071
|
+
}
|
|
6072
|
+
function isValidIP2(ip, version) {
|
|
6073
|
+
if ((version === "v4" || !version) && ipv4Regex2.test(ip)) {
|
|
6074
|
+
return true;
|
|
6075
|
+
}
|
|
6076
|
+
if ((version === "v6" || !version) && ipv6Regex2.test(ip)) {
|
|
6077
|
+
return true;
|
|
6078
|
+
}
|
|
6079
|
+
return false;
|
|
6080
|
+
}
|
|
6081
|
+
function isValidJWT2(jwt, alg) {
|
|
6082
|
+
if (!jwtRegex2.test(jwt))
|
|
6083
|
+
return false;
|
|
6084
|
+
try {
|
|
6085
|
+
const [header] = jwt.split(".");
|
|
6086
|
+
if (!header)
|
|
6087
|
+
return false;
|
|
6088
|
+
const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
|
6089
|
+
const decoded = JSON.parse(atob(base64));
|
|
6090
|
+
if (typeof decoded !== "object" || decoded === null)
|
|
6091
|
+
return false;
|
|
6092
|
+
if ("typ" in decoded && decoded?.typ !== "JWT")
|
|
6093
|
+
return false;
|
|
6094
|
+
if (!decoded.alg)
|
|
6095
|
+
return false;
|
|
6096
|
+
if (alg && decoded.alg !== alg)
|
|
6097
|
+
return false;
|
|
6098
|
+
return true;
|
|
6099
|
+
} catch {
|
|
6100
|
+
return false;
|
|
6101
|
+
}
|
|
6102
|
+
}
|
|
6103
|
+
function isValidCidr2(ip, version) {
|
|
6104
|
+
if ((version === "v4" || !version) && ipv4CidrRegex2.test(ip)) {
|
|
6105
|
+
return true;
|
|
6106
|
+
}
|
|
6107
|
+
if ((version === "v6" || !version) && ipv6CidrRegex2.test(ip)) {
|
|
6108
|
+
return true;
|
|
6109
|
+
}
|
|
6110
|
+
return false;
|
|
6111
|
+
}
|
|
6112
|
+
var ZodString2 = class _ZodString2 extends ZodType2 {
|
|
6113
|
+
_parse(input) {
|
|
6114
|
+
if (this._def.coerce) {
|
|
6115
|
+
input.data = String(input.data);
|
|
6116
|
+
}
|
|
6117
|
+
const parsedType = this._getType(input);
|
|
6118
|
+
if (parsedType !== ZodParsedType2.string) {
|
|
6119
|
+
const ctx2 = this._getOrReturnCtx(input);
|
|
6120
|
+
addIssueToContext2(ctx2, {
|
|
6121
|
+
code: ZodIssueCode2.invalid_type,
|
|
6122
|
+
expected: ZodParsedType2.string,
|
|
6123
|
+
received: ctx2.parsedType
|
|
6124
|
+
});
|
|
6125
|
+
return INVALID2;
|
|
6126
|
+
}
|
|
6127
|
+
const status = new ParseStatus2();
|
|
6128
|
+
let ctx = void 0;
|
|
6129
|
+
for (const check of this._def.checks) {
|
|
6130
|
+
if (check.kind === "min") {
|
|
6131
|
+
if (input.data.length < check.value) {
|
|
6132
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6133
|
+
addIssueToContext2(ctx, {
|
|
6134
|
+
code: ZodIssueCode2.too_small,
|
|
6135
|
+
minimum: check.value,
|
|
6136
|
+
type: "string",
|
|
6137
|
+
inclusive: true,
|
|
6138
|
+
exact: false,
|
|
6139
|
+
message: check.message
|
|
6140
|
+
});
|
|
6141
|
+
status.dirty();
|
|
6142
|
+
}
|
|
6143
|
+
} else if (check.kind === "max") {
|
|
6144
|
+
if (input.data.length > check.value) {
|
|
6145
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6146
|
+
addIssueToContext2(ctx, {
|
|
6147
|
+
code: ZodIssueCode2.too_big,
|
|
6148
|
+
maximum: check.value,
|
|
6149
|
+
type: "string",
|
|
6150
|
+
inclusive: true,
|
|
6151
|
+
exact: false,
|
|
6152
|
+
message: check.message
|
|
6153
|
+
});
|
|
6154
|
+
status.dirty();
|
|
6155
|
+
}
|
|
6156
|
+
} else if (check.kind === "length") {
|
|
6157
|
+
const tooBig = input.data.length > check.value;
|
|
6158
|
+
const tooSmall = input.data.length < check.value;
|
|
6159
|
+
if (tooBig || tooSmall) {
|
|
6160
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6161
|
+
if (tooBig) {
|
|
6162
|
+
addIssueToContext2(ctx, {
|
|
6163
|
+
code: ZodIssueCode2.too_big,
|
|
6164
|
+
maximum: check.value,
|
|
6165
|
+
type: "string",
|
|
6166
|
+
inclusive: true,
|
|
6167
|
+
exact: true,
|
|
6168
|
+
message: check.message
|
|
6169
|
+
});
|
|
6170
|
+
} else if (tooSmall) {
|
|
6171
|
+
addIssueToContext2(ctx, {
|
|
6172
|
+
code: ZodIssueCode2.too_small,
|
|
6173
|
+
minimum: check.value,
|
|
6174
|
+
type: "string",
|
|
6175
|
+
inclusive: true,
|
|
6176
|
+
exact: true,
|
|
6177
|
+
message: check.message
|
|
6178
|
+
});
|
|
6179
|
+
}
|
|
6180
|
+
status.dirty();
|
|
6181
|
+
}
|
|
6182
|
+
} else if (check.kind === "email") {
|
|
6183
|
+
if (!emailRegex2.test(input.data)) {
|
|
6184
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6185
|
+
addIssueToContext2(ctx, {
|
|
6186
|
+
validation: "email",
|
|
6187
|
+
code: ZodIssueCode2.invalid_string,
|
|
6188
|
+
message: check.message
|
|
6189
|
+
});
|
|
6190
|
+
status.dirty();
|
|
6191
|
+
}
|
|
6192
|
+
} else if (check.kind === "emoji") {
|
|
6193
|
+
if (!emojiRegex2) {
|
|
6194
|
+
emojiRegex2 = new RegExp(_emojiRegex2, "u");
|
|
6195
|
+
}
|
|
6196
|
+
if (!emojiRegex2.test(input.data)) {
|
|
6197
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6198
|
+
addIssueToContext2(ctx, {
|
|
6199
|
+
validation: "emoji",
|
|
6200
|
+
code: ZodIssueCode2.invalid_string,
|
|
6201
|
+
message: check.message
|
|
6202
|
+
});
|
|
6203
|
+
status.dirty();
|
|
6204
|
+
}
|
|
6205
|
+
} else if (check.kind === "uuid") {
|
|
6206
|
+
if (!uuidRegex2.test(input.data)) {
|
|
6207
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6208
|
+
addIssueToContext2(ctx, {
|
|
6209
|
+
validation: "uuid",
|
|
6210
|
+
code: ZodIssueCode2.invalid_string,
|
|
6211
|
+
message: check.message
|
|
6212
|
+
});
|
|
6213
|
+
status.dirty();
|
|
6214
|
+
}
|
|
6215
|
+
} else if (check.kind === "nanoid") {
|
|
6216
|
+
if (!nanoidRegex2.test(input.data)) {
|
|
6217
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6218
|
+
addIssueToContext2(ctx, {
|
|
6219
|
+
validation: "nanoid",
|
|
6220
|
+
code: ZodIssueCode2.invalid_string,
|
|
6221
|
+
message: check.message
|
|
6222
|
+
});
|
|
6223
|
+
status.dirty();
|
|
6224
|
+
}
|
|
6225
|
+
} else if (check.kind === "cuid") {
|
|
6226
|
+
if (!cuidRegex2.test(input.data)) {
|
|
6227
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6228
|
+
addIssueToContext2(ctx, {
|
|
6229
|
+
validation: "cuid",
|
|
6230
|
+
code: ZodIssueCode2.invalid_string,
|
|
6231
|
+
message: check.message
|
|
6232
|
+
});
|
|
6233
|
+
status.dirty();
|
|
6234
|
+
}
|
|
6235
|
+
} else if (check.kind === "cuid2") {
|
|
6236
|
+
if (!cuid2Regex2.test(input.data)) {
|
|
6237
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6238
|
+
addIssueToContext2(ctx, {
|
|
6239
|
+
validation: "cuid2",
|
|
6240
|
+
code: ZodIssueCode2.invalid_string,
|
|
6241
|
+
message: check.message
|
|
6242
|
+
});
|
|
6243
|
+
status.dirty();
|
|
6244
|
+
}
|
|
6245
|
+
} else if (check.kind === "ulid") {
|
|
6246
|
+
if (!ulidRegex2.test(input.data)) {
|
|
6247
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6248
|
+
addIssueToContext2(ctx, {
|
|
6249
|
+
validation: "ulid",
|
|
6250
|
+
code: ZodIssueCode2.invalid_string,
|
|
6251
|
+
message: check.message
|
|
6252
|
+
});
|
|
6253
|
+
status.dirty();
|
|
6254
|
+
}
|
|
6255
|
+
} else if (check.kind === "url") {
|
|
6256
|
+
try {
|
|
6257
|
+
new URL(input.data);
|
|
6258
|
+
} catch {
|
|
6259
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6260
|
+
addIssueToContext2(ctx, {
|
|
6261
|
+
validation: "url",
|
|
6262
|
+
code: ZodIssueCode2.invalid_string,
|
|
6263
|
+
message: check.message
|
|
6264
|
+
});
|
|
6265
|
+
status.dirty();
|
|
6266
|
+
}
|
|
6267
|
+
} else if (check.kind === "regex") {
|
|
6268
|
+
check.regex.lastIndex = 0;
|
|
6269
|
+
const testResult = check.regex.test(input.data);
|
|
6270
|
+
if (!testResult) {
|
|
6271
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6272
|
+
addIssueToContext2(ctx, {
|
|
6273
|
+
validation: "regex",
|
|
6274
|
+
code: ZodIssueCode2.invalid_string,
|
|
6275
|
+
message: check.message
|
|
6276
|
+
});
|
|
6277
|
+
status.dirty();
|
|
6278
|
+
}
|
|
6279
|
+
} else if (check.kind === "trim") {
|
|
6280
|
+
input.data = input.data.trim();
|
|
6281
|
+
} else if (check.kind === "includes") {
|
|
6282
|
+
if (!input.data.includes(check.value, check.position)) {
|
|
6283
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6284
|
+
addIssueToContext2(ctx, {
|
|
6285
|
+
code: ZodIssueCode2.invalid_string,
|
|
6286
|
+
validation: { includes: check.value, position: check.position },
|
|
6287
|
+
message: check.message
|
|
6288
|
+
});
|
|
6289
|
+
status.dirty();
|
|
6290
|
+
}
|
|
6291
|
+
} else if (check.kind === "toLowerCase") {
|
|
6292
|
+
input.data = input.data.toLowerCase();
|
|
6293
|
+
} else if (check.kind === "toUpperCase") {
|
|
6294
|
+
input.data = input.data.toUpperCase();
|
|
6295
|
+
} else if (check.kind === "startsWith") {
|
|
6296
|
+
if (!input.data.startsWith(check.value)) {
|
|
6297
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6298
|
+
addIssueToContext2(ctx, {
|
|
6299
|
+
code: ZodIssueCode2.invalid_string,
|
|
6300
|
+
validation: { startsWith: check.value },
|
|
6301
|
+
message: check.message
|
|
6302
|
+
});
|
|
6303
|
+
status.dirty();
|
|
6304
|
+
}
|
|
6305
|
+
} else if (check.kind === "endsWith") {
|
|
6306
|
+
if (!input.data.endsWith(check.value)) {
|
|
6307
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6308
|
+
addIssueToContext2(ctx, {
|
|
6309
|
+
code: ZodIssueCode2.invalid_string,
|
|
6310
|
+
validation: { endsWith: check.value },
|
|
6311
|
+
message: check.message
|
|
6312
|
+
});
|
|
6313
|
+
status.dirty();
|
|
6314
|
+
}
|
|
6315
|
+
} else if (check.kind === "datetime") {
|
|
6316
|
+
const regex = datetimeRegex2(check);
|
|
6317
|
+
if (!regex.test(input.data)) {
|
|
6318
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6319
|
+
addIssueToContext2(ctx, {
|
|
6320
|
+
code: ZodIssueCode2.invalid_string,
|
|
6321
|
+
validation: "datetime",
|
|
6322
|
+
message: check.message
|
|
6323
|
+
});
|
|
6324
|
+
status.dirty();
|
|
6325
|
+
}
|
|
6326
|
+
} else if (check.kind === "date") {
|
|
6327
|
+
const regex = dateRegex2;
|
|
6328
|
+
if (!regex.test(input.data)) {
|
|
6329
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6330
|
+
addIssueToContext2(ctx, {
|
|
6331
|
+
code: ZodIssueCode2.invalid_string,
|
|
6332
|
+
validation: "date",
|
|
6333
|
+
message: check.message
|
|
6334
|
+
});
|
|
6335
|
+
status.dirty();
|
|
6336
|
+
}
|
|
6337
|
+
} else if (check.kind === "time") {
|
|
6338
|
+
const regex = timeRegex2(check);
|
|
6339
|
+
if (!regex.test(input.data)) {
|
|
6340
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6341
|
+
addIssueToContext2(ctx, {
|
|
6342
|
+
code: ZodIssueCode2.invalid_string,
|
|
6343
|
+
validation: "time",
|
|
6344
|
+
message: check.message
|
|
6345
|
+
});
|
|
6346
|
+
status.dirty();
|
|
6347
|
+
}
|
|
6348
|
+
} else if (check.kind === "duration") {
|
|
6349
|
+
if (!durationRegex2.test(input.data)) {
|
|
6350
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6351
|
+
addIssueToContext2(ctx, {
|
|
6352
|
+
validation: "duration",
|
|
6353
|
+
code: ZodIssueCode2.invalid_string,
|
|
6354
|
+
message: check.message
|
|
6355
|
+
});
|
|
6356
|
+
status.dirty();
|
|
6357
|
+
}
|
|
6358
|
+
} else if (check.kind === "ip") {
|
|
6359
|
+
if (!isValidIP2(input.data, check.version)) {
|
|
6360
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6361
|
+
addIssueToContext2(ctx, {
|
|
6362
|
+
validation: "ip",
|
|
6363
|
+
code: ZodIssueCode2.invalid_string,
|
|
6364
|
+
message: check.message
|
|
6365
|
+
});
|
|
6366
|
+
status.dirty();
|
|
6367
|
+
}
|
|
6368
|
+
} else if (check.kind === "jwt") {
|
|
6369
|
+
if (!isValidJWT2(input.data, check.alg)) {
|
|
6370
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6371
|
+
addIssueToContext2(ctx, {
|
|
6372
|
+
validation: "jwt",
|
|
6373
|
+
code: ZodIssueCode2.invalid_string,
|
|
6374
|
+
message: check.message
|
|
6375
|
+
});
|
|
6376
|
+
status.dirty();
|
|
6377
|
+
}
|
|
6378
|
+
} else if (check.kind === "cidr") {
|
|
6379
|
+
if (!isValidCidr2(input.data, check.version)) {
|
|
6380
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6381
|
+
addIssueToContext2(ctx, {
|
|
6382
|
+
validation: "cidr",
|
|
6383
|
+
code: ZodIssueCode2.invalid_string,
|
|
6384
|
+
message: check.message
|
|
6385
|
+
});
|
|
6386
|
+
status.dirty();
|
|
6387
|
+
}
|
|
6388
|
+
} else if (check.kind === "base64") {
|
|
6389
|
+
if (!base64Regex2.test(input.data)) {
|
|
6390
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6391
|
+
addIssueToContext2(ctx, {
|
|
6392
|
+
validation: "base64",
|
|
6393
|
+
code: ZodIssueCode2.invalid_string,
|
|
6394
|
+
message: check.message
|
|
6395
|
+
});
|
|
6396
|
+
status.dirty();
|
|
6397
|
+
}
|
|
6398
|
+
} else if (check.kind === "base64url") {
|
|
6399
|
+
if (!base64urlRegex2.test(input.data)) {
|
|
6400
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6401
|
+
addIssueToContext2(ctx, {
|
|
6402
|
+
validation: "base64url",
|
|
6403
|
+
code: ZodIssueCode2.invalid_string,
|
|
6404
|
+
message: check.message
|
|
6405
|
+
});
|
|
6406
|
+
status.dirty();
|
|
6407
|
+
}
|
|
6408
|
+
} else {
|
|
6409
|
+
util2.assertNever(check);
|
|
6410
|
+
}
|
|
6411
|
+
}
|
|
6412
|
+
return { status: status.value, value: input.data };
|
|
6413
|
+
}
|
|
6414
|
+
_regex(regex, validation, message) {
|
|
6415
|
+
return this.refinement((data) => regex.test(data), {
|
|
6416
|
+
validation,
|
|
6417
|
+
code: ZodIssueCode2.invalid_string,
|
|
6418
|
+
...errorUtil2.errToObj(message)
|
|
6419
|
+
});
|
|
6420
|
+
}
|
|
6421
|
+
_addCheck(check) {
|
|
6422
|
+
return new _ZodString2({
|
|
6423
|
+
...this._def,
|
|
6424
|
+
checks: [...this._def.checks, check]
|
|
6425
|
+
});
|
|
6426
|
+
}
|
|
6427
|
+
email(message) {
|
|
6428
|
+
return this._addCheck({ kind: "email", ...errorUtil2.errToObj(message) });
|
|
6429
|
+
}
|
|
6430
|
+
url(message) {
|
|
6431
|
+
return this._addCheck({ kind: "url", ...errorUtil2.errToObj(message) });
|
|
6432
|
+
}
|
|
6433
|
+
emoji(message) {
|
|
6434
|
+
return this._addCheck({ kind: "emoji", ...errorUtil2.errToObj(message) });
|
|
6435
|
+
}
|
|
6436
|
+
uuid(message) {
|
|
6437
|
+
return this._addCheck({ kind: "uuid", ...errorUtil2.errToObj(message) });
|
|
6438
|
+
}
|
|
6439
|
+
nanoid(message) {
|
|
6440
|
+
return this._addCheck({ kind: "nanoid", ...errorUtil2.errToObj(message) });
|
|
6441
|
+
}
|
|
6442
|
+
cuid(message) {
|
|
6443
|
+
return this._addCheck({ kind: "cuid", ...errorUtil2.errToObj(message) });
|
|
6444
|
+
}
|
|
6445
|
+
cuid2(message) {
|
|
6446
|
+
return this._addCheck({ kind: "cuid2", ...errorUtil2.errToObj(message) });
|
|
6447
|
+
}
|
|
6448
|
+
ulid(message) {
|
|
6449
|
+
return this._addCheck({ kind: "ulid", ...errorUtil2.errToObj(message) });
|
|
6450
|
+
}
|
|
6451
|
+
base64(message) {
|
|
6452
|
+
return this._addCheck({ kind: "base64", ...errorUtil2.errToObj(message) });
|
|
6453
|
+
}
|
|
6454
|
+
base64url(message) {
|
|
6455
|
+
return this._addCheck({
|
|
6456
|
+
kind: "base64url",
|
|
6457
|
+
...errorUtil2.errToObj(message)
|
|
6458
|
+
});
|
|
6459
|
+
}
|
|
6460
|
+
jwt(options) {
|
|
6461
|
+
return this._addCheck({ kind: "jwt", ...errorUtil2.errToObj(options) });
|
|
6462
|
+
}
|
|
6463
|
+
ip(options) {
|
|
6464
|
+
return this._addCheck({ kind: "ip", ...errorUtil2.errToObj(options) });
|
|
6465
|
+
}
|
|
6466
|
+
cidr(options) {
|
|
6467
|
+
return this._addCheck({ kind: "cidr", ...errorUtil2.errToObj(options) });
|
|
6468
|
+
}
|
|
6469
|
+
datetime(options) {
|
|
6470
|
+
if (typeof options === "string") {
|
|
6471
|
+
return this._addCheck({
|
|
6472
|
+
kind: "datetime",
|
|
6473
|
+
precision: null,
|
|
6474
|
+
offset: false,
|
|
6475
|
+
local: false,
|
|
6476
|
+
message: options
|
|
6477
|
+
});
|
|
6478
|
+
}
|
|
6479
|
+
return this._addCheck({
|
|
6480
|
+
kind: "datetime",
|
|
6481
|
+
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
6482
|
+
offset: options?.offset ?? false,
|
|
6483
|
+
local: options?.local ?? false,
|
|
6484
|
+
...errorUtil2.errToObj(options?.message)
|
|
6485
|
+
});
|
|
6486
|
+
}
|
|
6487
|
+
date(message) {
|
|
6488
|
+
return this._addCheck({ kind: "date", message });
|
|
6489
|
+
}
|
|
6490
|
+
time(options) {
|
|
6491
|
+
if (typeof options === "string") {
|
|
6492
|
+
return this._addCheck({
|
|
6493
|
+
kind: "time",
|
|
6494
|
+
precision: null,
|
|
6495
|
+
message: options
|
|
6496
|
+
});
|
|
6497
|
+
}
|
|
6498
|
+
return this._addCheck({
|
|
6499
|
+
kind: "time",
|
|
6500
|
+
precision: typeof options?.precision === "undefined" ? null : options?.precision,
|
|
6501
|
+
...errorUtil2.errToObj(options?.message)
|
|
6502
|
+
});
|
|
6503
|
+
}
|
|
6504
|
+
duration(message) {
|
|
6505
|
+
return this._addCheck({ kind: "duration", ...errorUtil2.errToObj(message) });
|
|
6506
|
+
}
|
|
6507
|
+
regex(regex, message) {
|
|
6508
|
+
return this._addCheck({
|
|
6509
|
+
kind: "regex",
|
|
6510
|
+
regex,
|
|
6511
|
+
...errorUtil2.errToObj(message)
|
|
6512
|
+
});
|
|
6513
|
+
}
|
|
6514
|
+
includes(value, options) {
|
|
6515
|
+
return this._addCheck({
|
|
6516
|
+
kind: "includes",
|
|
6517
|
+
value,
|
|
6518
|
+
position: options?.position,
|
|
6519
|
+
...errorUtil2.errToObj(options?.message)
|
|
6520
|
+
});
|
|
6521
|
+
}
|
|
6522
|
+
startsWith(value, message) {
|
|
6523
|
+
return this._addCheck({
|
|
6524
|
+
kind: "startsWith",
|
|
6525
|
+
value,
|
|
6526
|
+
...errorUtil2.errToObj(message)
|
|
6527
|
+
});
|
|
6528
|
+
}
|
|
6529
|
+
endsWith(value, message) {
|
|
6530
|
+
return this._addCheck({
|
|
6531
|
+
kind: "endsWith",
|
|
6532
|
+
value,
|
|
6533
|
+
...errorUtil2.errToObj(message)
|
|
6534
|
+
});
|
|
6535
|
+
}
|
|
6536
|
+
min(minLength, message) {
|
|
6537
|
+
return this._addCheck({
|
|
6538
|
+
kind: "min",
|
|
6539
|
+
value: minLength,
|
|
6540
|
+
...errorUtil2.errToObj(message)
|
|
6541
|
+
});
|
|
6542
|
+
}
|
|
6543
|
+
max(maxLength, message) {
|
|
6544
|
+
return this._addCheck({
|
|
6545
|
+
kind: "max",
|
|
6546
|
+
value: maxLength,
|
|
6547
|
+
...errorUtil2.errToObj(message)
|
|
6548
|
+
});
|
|
6549
|
+
}
|
|
6550
|
+
length(len, message) {
|
|
6551
|
+
return this._addCheck({
|
|
6552
|
+
kind: "length",
|
|
6553
|
+
value: len,
|
|
6554
|
+
...errorUtil2.errToObj(message)
|
|
6555
|
+
});
|
|
6556
|
+
}
|
|
6557
|
+
/**
|
|
6558
|
+
* Equivalent to `.min(1)`
|
|
6559
|
+
*/
|
|
6560
|
+
nonempty(message) {
|
|
6561
|
+
return this.min(1, errorUtil2.errToObj(message));
|
|
6562
|
+
}
|
|
6563
|
+
trim() {
|
|
6564
|
+
return new _ZodString2({
|
|
6565
|
+
...this._def,
|
|
6566
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
6567
|
+
});
|
|
6568
|
+
}
|
|
6569
|
+
toLowerCase() {
|
|
6570
|
+
return new _ZodString2({
|
|
6571
|
+
...this._def,
|
|
6572
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
6573
|
+
});
|
|
6574
|
+
}
|
|
6575
|
+
toUpperCase() {
|
|
6576
|
+
return new _ZodString2({
|
|
6577
|
+
...this._def,
|
|
6578
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
6579
|
+
});
|
|
6580
|
+
}
|
|
6581
|
+
get isDatetime() {
|
|
6582
|
+
return !!this._def.checks.find((ch) => ch.kind === "datetime");
|
|
6583
|
+
}
|
|
6584
|
+
get isDate() {
|
|
6585
|
+
return !!this._def.checks.find((ch) => ch.kind === "date");
|
|
6586
|
+
}
|
|
6587
|
+
get isTime() {
|
|
6588
|
+
return !!this._def.checks.find((ch) => ch.kind === "time");
|
|
6589
|
+
}
|
|
6590
|
+
get isDuration() {
|
|
6591
|
+
return !!this._def.checks.find((ch) => ch.kind === "duration");
|
|
6592
|
+
}
|
|
6593
|
+
get isEmail() {
|
|
6594
|
+
return !!this._def.checks.find((ch) => ch.kind === "email");
|
|
6595
|
+
}
|
|
6596
|
+
get isURL() {
|
|
6597
|
+
return !!this._def.checks.find((ch) => ch.kind === "url");
|
|
6598
|
+
}
|
|
6599
|
+
get isEmoji() {
|
|
6600
|
+
return !!this._def.checks.find((ch) => ch.kind === "emoji");
|
|
6601
|
+
}
|
|
6602
|
+
get isUUID() {
|
|
6603
|
+
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
|
6604
|
+
}
|
|
6605
|
+
get isNANOID() {
|
|
6606
|
+
return !!this._def.checks.find((ch) => ch.kind === "nanoid");
|
|
6607
|
+
}
|
|
6608
|
+
get isCUID() {
|
|
6609
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
|
6610
|
+
}
|
|
6611
|
+
get isCUID2() {
|
|
6612
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid2");
|
|
6613
|
+
}
|
|
6614
|
+
get isULID() {
|
|
6615
|
+
return !!this._def.checks.find((ch) => ch.kind === "ulid");
|
|
6616
|
+
}
|
|
6617
|
+
get isIP() {
|
|
6618
|
+
return !!this._def.checks.find((ch) => ch.kind === "ip");
|
|
6619
|
+
}
|
|
6620
|
+
get isCIDR() {
|
|
6621
|
+
return !!this._def.checks.find((ch) => ch.kind === "cidr");
|
|
6622
|
+
}
|
|
6623
|
+
get isBase64() {
|
|
6624
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64");
|
|
6625
|
+
}
|
|
6626
|
+
get isBase64url() {
|
|
6627
|
+
return !!this._def.checks.find((ch) => ch.kind === "base64url");
|
|
6628
|
+
}
|
|
6629
|
+
get minLength() {
|
|
6630
|
+
let min = null;
|
|
6631
|
+
for (const ch of this._def.checks) {
|
|
6632
|
+
if (ch.kind === "min") {
|
|
6633
|
+
if (min === null || ch.value > min)
|
|
6634
|
+
min = ch.value;
|
|
6635
|
+
}
|
|
6636
|
+
}
|
|
6637
|
+
return min;
|
|
6638
|
+
}
|
|
6639
|
+
get maxLength() {
|
|
6640
|
+
let max = null;
|
|
6641
|
+
for (const ch of this._def.checks) {
|
|
6642
|
+
if (ch.kind === "max") {
|
|
6643
|
+
if (max === null || ch.value < max)
|
|
6644
|
+
max = ch.value;
|
|
6645
|
+
}
|
|
6646
|
+
}
|
|
6647
|
+
return max;
|
|
6648
|
+
}
|
|
6649
|
+
};
|
|
6650
|
+
ZodString2.create = (params) => {
|
|
6651
|
+
return new ZodString2({
|
|
6652
|
+
checks: [],
|
|
6653
|
+
typeName: ZodFirstPartyTypeKind2.ZodString,
|
|
6654
|
+
coerce: params?.coerce ?? false,
|
|
6655
|
+
...processCreateParams2(params)
|
|
6656
|
+
});
|
|
6657
|
+
};
|
|
6658
|
+
function floatSafeRemainder2(val, step) {
|
|
6659
|
+
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
6660
|
+
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
6661
|
+
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
6662
|
+
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
6663
|
+
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
6664
|
+
return valInt % stepInt / 10 ** decCount;
|
|
6665
|
+
}
|
|
6666
|
+
var ZodNumber2 = class _ZodNumber2 extends ZodType2 {
|
|
6667
|
+
constructor() {
|
|
6668
|
+
super(...arguments);
|
|
6669
|
+
this.min = this.gte;
|
|
6670
|
+
this.max = this.lte;
|
|
6671
|
+
this.step = this.multipleOf;
|
|
6672
|
+
}
|
|
6673
|
+
_parse(input) {
|
|
6674
|
+
if (this._def.coerce) {
|
|
6675
|
+
input.data = Number(input.data);
|
|
6676
|
+
}
|
|
6677
|
+
const parsedType = this._getType(input);
|
|
6678
|
+
if (parsedType !== ZodParsedType2.number) {
|
|
6679
|
+
const ctx2 = this._getOrReturnCtx(input);
|
|
6680
|
+
addIssueToContext2(ctx2, {
|
|
6681
|
+
code: ZodIssueCode2.invalid_type,
|
|
6682
|
+
expected: ZodParsedType2.number,
|
|
6683
|
+
received: ctx2.parsedType
|
|
6684
|
+
});
|
|
6685
|
+
return INVALID2;
|
|
6686
|
+
}
|
|
6687
|
+
let ctx = void 0;
|
|
6688
|
+
const status = new ParseStatus2();
|
|
6689
|
+
for (const check of this._def.checks) {
|
|
6690
|
+
if (check.kind === "int") {
|
|
6691
|
+
if (!util2.isInteger(input.data)) {
|
|
6692
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6693
|
+
addIssueToContext2(ctx, {
|
|
6694
|
+
code: ZodIssueCode2.invalid_type,
|
|
6695
|
+
expected: "integer",
|
|
6696
|
+
received: "float",
|
|
6697
|
+
message: check.message
|
|
6698
|
+
});
|
|
6699
|
+
status.dirty();
|
|
6700
|
+
}
|
|
6701
|
+
} else if (check.kind === "min") {
|
|
6702
|
+
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
|
|
6703
|
+
if (tooSmall) {
|
|
6704
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6705
|
+
addIssueToContext2(ctx, {
|
|
6706
|
+
code: ZodIssueCode2.too_small,
|
|
6707
|
+
minimum: check.value,
|
|
6708
|
+
type: "number",
|
|
6709
|
+
inclusive: check.inclusive,
|
|
6710
|
+
exact: false,
|
|
6711
|
+
message: check.message
|
|
6712
|
+
});
|
|
6713
|
+
status.dirty();
|
|
6714
|
+
}
|
|
6715
|
+
} else if (check.kind === "max") {
|
|
6716
|
+
const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
|
|
6717
|
+
if (tooBig) {
|
|
6718
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6719
|
+
addIssueToContext2(ctx, {
|
|
6720
|
+
code: ZodIssueCode2.too_big,
|
|
6721
|
+
maximum: check.value,
|
|
6722
|
+
type: "number",
|
|
6723
|
+
inclusive: check.inclusive,
|
|
6724
|
+
exact: false,
|
|
6725
|
+
message: check.message
|
|
6726
|
+
});
|
|
6727
|
+
status.dirty();
|
|
6728
|
+
}
|
|
6729
|
+
} else if (check.kind === "multipleOf") {
|
|
6730
|
+
if (floatSafeRemainder2(input.data, check.value) !== 0) {
|
|
6731
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6732
|
+
addIssueToContext2(ctx, {
|
|
6733
|
+
code: ZodIssueCode2.not_multiple_of,
|
|
6734
|
+
multipleOf: check.value,
|
|
6735
|
+
message: check.message
|
|
6736
|
+
});
|
|
6737
|
+
status.dirty();
|
|
6738
|
+
}
|
|
6739
|
+
} else if (check.kind === "finite") {
|
|
6740
|
+
if (!Number.isFinite(input.data)) {
|
|
6741
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6742
|
+
addIssueToContext2(ctx, {
|
|
6743
|
+
code: ZodIssueCode2.not_finite,
|
|
6744
|
+
message: check.message
|
|
6745
|
+
});
|
|
6746
|
+
status.dirty();
|
|
6747
|
+
}
|
|
6748
|
+
} else {
|
|
6749
|
+
util2.assertNever(check);
|
|
6750
|
+
}
|
|
6751
|
+
}
|
|
6752
|
+
return { status: status.value, value: input.data };
|
|
6753
|
+
}
|
|
6754
|
+
gte(value, message) {
|
|
6755
|
+
return this.setLimit("min", value, true, errorUtil2.toString(message));
|
|
6756
|
+
}
|
|
6757
|
+
gt(value, message) {
|
|
6758
|
+
return this.setLimit("min", value, false, errorUtil2.toString(message));
|
|
6759
|
+
}
|
|
6760
|
+
lte(value, message) {
|
|
6761
|
+
return this.setLimit("max", value, true, errorUtil2.toString(message));
|
|
6762
|
+
}
|
|
6763
|
+
lt(value, message) {
|
|
6764
|
+
return this.setLimit("max", value, false, errorUtil2.toString(message));
|
|
6765
|
+
}
|
|
6766
|
+
setLimit(kind, value, inclusive, message) {
|
|
6767
|
+
return new _ZodNumber2({
|
|
6768
|
+
...this._def,
|
|
6769
|
+
checks: [
|
|
6770
|
+
...this._def.checks,
|
|
6771
|
+
{
|
|
6772
|
+
kind,
|
|
6773
|
+
value,
|
|
6774
|
+
inclusive,
|
|
6775
|
+
message: errorUtil2.toString(message)
|
|
6776
|
+
}
|
|
6777
|
+
]
|
|
6778
|
+
});
|
|
6779
|
+
}
|
|
6780
|
+
_addCheck(check) {
|
|
6781
|
+
return new _ZodNumber2({
|
|
6782
|
+
...this._def,
|
|
6783
|
+
checks: [...this._def.checks, check]
|
|
6784
|
+
});
|
|
6785
|
+
}
|
|
6786
|
+
int(message) {
|
|
6787
|
+
return this._addCheck({
|
|
6788
|
+
kind: "int",
|
|
6789
|
+
message: errorUtil2.toString(message)
|
|
6790
|
+
});
|
|
6791
|
+
}
|
|
6792
|
+
positive(message) {
|
|
6793
|
+
return this._addCheck({
|
|
6794
|
+
kind: "min",
|
|
6795
|
+
value: 0,
|
|
6796
|
+
inclusive: false,
|
|
6797
|
+
message: errorUtil2.toString(message)
|
|
6798
|
+
});
|
|
6799
|
+
}
|
|
6800
|
+
negative(message) {
|
|
6801
|
+
return this._addCheck({
|
|
6802
|
+
kind: "max",
|
|
6803
|
+
value: 0,
|
|
6804
|
+
inclusive: false,
|
|
6805
|
+
message: errorUtil2.toString(message)
|
|
6806
|
+
});
|
|
6807
|
+
}
|
|
6808
|
+
nonpositive(message) {
|
|
6809
|
+
return this._addCheck({
|
|
6810
|
+
kind: "max",
|
|
6811
|
+
value: 0,
|
|
6812
|
+
inclusive: true,
|
|
6813
|
+
message: errorUtil2.toString(message)
|
|
6814
|
+
});
|
|
6815
|
+
}
|
|
6816
|
+
nonnegative(message) {
|
|
6817
|
+
return this._addCheck({
|
|
6818
|
+
kind: "min",
|
|
6819
|
+
value: 0,
|
|
6820
|
+
inclusive: true,
|
|
6821
|
+
message: errorUtil2.toString(message)
|
|
6822
|
+
});
|
|
6823
|
+
}
|
|
6824
|
+
multipleOf(value, message) {
|
|
6825
|
+
return this._addCheck({
|
|
6826
|
+
kind: "multipleOf",
|
|
6827
|
+
value,
|
|
6828
|
+
message: errorUtil2.toString(message)
|
|
6829
|
+
});
|
|
6830
|
+
}
|
|
6831
|
+
finite(message) {
|
|
6832
|
+
return this._addCheck({
|
|
6833
|
+
kind: "finite",
|
|
6834
|
+
message: errorUtil2.toString(message)
|
|
6835
|
+
});
|
|
6836
|
+
}
|
|
6837
|
+
safe(message) {
|
|
6838
|
+
return this._addCheck({
|
|
6839
|
+
kind: "min",
|
|
6840
|
+
inclusive: true,
|
|
6841
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
6842
|
+
message: errorUtil2.toString(message)
|
|
6843
|
+
})._addCheck({
|
|
6844
|
+
kind: "max",
|
|
6845
|
+
inclusive: true,
|
|
6846
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
6847
|
+
message: errorUtil2.toString(message)
|
|
6848
|
+
});
|
|
6849
|
+
}
|
|
6850
|
+
get minValue() {
|
|
6851
|
+
let min = null;
|
|
6852
|
+
for (const ch of this._def.checks) {
|
|
6853
|
+
if (ch.kind === "min") {
|
|
6854
|
+
if (min === null || ch.value > min)
|
|
6855
|
+
min = ch.value;
|
|
6856
|
+
}
|
|
6857
|
+
}
|
|
6858
|
+
return min;
|
|
6859
|
+
}
|
|
6860
|
+
get maxValue() {
|
|
6861
|
+
let max = null;
|
|
6862
|
+
for (const ch of this._def.checks) {
|
|
6863
|
+
if (ch.kind === "max") {
|
|
6864
|
+
if (max === null || ch.value < max)
|
|
6865
|
+
max = ch.value;
|
|
6866
|
+
}
|
|
6867
|
+
}
|
|
6868
|
+
return max;
|
|
6869
|
+
}
|
|
6870
|
+
get isInt() {
|
|
6871
|
+
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util2.isInteger(ch.value));
|
|
6872
|
+
}
|
|
6873
|
+
get isFinite() {
|
|
6874
|
+
let max = null;
|
|
6875
|
+
let min = null;
|
|
6876
|
+
for (const ch of this._def.checks) {
|
|
6877
|
+
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
|
6878
|
+
return true;
|
|
6879
|
+
} else if (ch.kind === "min") {
|
|
6880
|
+
if (min === null || ch.value > min)
|
|
6881
|
+
min = ch.value;
|
|
6882
|
+
} else if (ch.kind === "max") {
|
|
6883
|
+
if (max === null || ch.value < max)
|
|
6884
|
+
max = ch.value;
|
|
6885
|
+
}
|
|
6886
|
+
}
|
|
6887
|
+
return Number.isFinite(min) && Number.isFinite(max);
|
|
6888
|
+
}
|
|
6889
|
+
};
|
|
6890
|
+
ZodNumber2.create = (params) => {
|
|
6891
|
+
return new ZodNumber2({
|
|
6892
|
+
checks: [],
|
|
6893
|
+
typeName: ZodFirstPartyTypeKind2.ZodNumber,
|
|
6894
|
+
coerce: params?.coerce || false,
|
|
6895
|
+
...processCreateParams2(params)
|
|
6896
|
+
});
|
|
6897
|
+
};
|
|
6898
|
+
var ZodBigInt2 = class _ZodBigInt2 extends ZodType2 {
|
|
6899
|
+
constructor() {
|
|
6900
|
+
super(...arguments);
|
|
6901
|
+
this.min = this.gte;
|
|
6902
|
+
this.max = this.lte;
|
|
6903
|
+
}
|
|
6904
|
+
_parse(input) {
|
|
6905
|
+
if (this._def.coerce) {
|
|
6906
|
+
try {
|
|
6907
|
+
input.data = BigInt(input.data);
|
|
6908
|
+
} catch {
|
|
6909
|
+
return this._getInvalidInput(input);
|
|
6910
|
+
}
|
|
6911
|
+
}
|
|
6912
|
+
const parsedType = this._getType(input);
|
|
6913
|
+
if (parsedType !== ZodParsedType2.bigint) {
|
|
6914
|
+
return this._getInvalidInput(input);
|
|
6915
|
+
}
|
|
6916
|
+
let ctx = void 0;
|
|
6917
|
+
const status = new ParseStatus2();
|
|
6918
|
+
for (const check of this._def.checks) {
|
|
6919
|
+
if (check.kind === "min") {
|
|
6920
|
+
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
|
|
6921
|
+
if (tooSmall) {
|
|
6922
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6923
|
+
addIssueToContext2(ctx, {
|
|
6924
|
+
code: ZodIssueCode2.too_small,
|
|
6925
|
+
type: "bigint",
|
|
6926
|
+
minimum: check.value,
|
|
6927
|
+
inclusive: check.inclusive,
|
|
6928
|
+
message: check.message
|
|
6929
|
+
});
|
|
6930
|
+
status.dirty();
|
|
6931
|
+
}
|
|
6932
|
+
} else if (check.kind === "max") {
|
|
6933
|
+
const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
|
|
6934
|
+
if (tooBig) {
|
|
6935
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6936
|
+
addIssueToContext2(ctx, {
|
|
6937
|
+
code: ZodIssueCode2.too_big,
|
|
6938
|
+
type: "bigint",
|
|
6939
|
+
maximum: check.value,
|
|
6940
|
+
inclusive: check.inclusive,
|
|
6941
|
+
message: check.message
|
|
6942
|
+
});
|
|
6943
|
+
status.dirty();
|
|
6944
|
+
}
|
|
6945
|
+
} else if (check.kind === "multipleOf") {
|
|
6946
|
+
if (input.data % check.value !== BigInt(0)) {
|
|
6947
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
6948
|
+
addIssueToContext2(ctx, {
|
|
6949
|
+
code: ZodIssueCode2.not_multiple_of,
|
|
6950
|
+
multipleOf: check.value,
|
|
6951
|
+
message: check.message
|
|
6952
|
+
});
|
|
6953
|
+
status.dirty();
|
|
6954
|
+
}
|
|
6955
|
+
} else {
|
|
6956
|
+
util2.assertNever(check);
|
|
6957
|
+
}
|
|
6958
|
+
}
|
|
6959
|
+
return { status: status.value, value: input.data };
|
|
6960
|
+
}
|
|
6961
|
+
_getInvalidInput(input) {
|
|
6962
|
+
const ctx = this._getOrReturnCtx(input);
|
|
6963
|
+
addIssueToContext2(ctx, {
|
|
6964
|
+
code: ZodIssueCode2.invalid_type,
|
|
6965
|
+
expected: ZodParsedType2.bigint,
|
|
6966
|
+
received: ctx.parsedType
|
|
6967
|
+
});
|
|
6968
|
+
return INVALID2;
|
|
6969
|
+
}
|
|
6970
|
+
gte(value, message) {
|
|
6971
|
+
return this.setLimit("min", value, true, errorUtil2.toString(message));
|
|
6972
|
+
}
|
|
6973
|
+
gt(value, message) {
|
|
6974
|
+
return this.setLimit("min", value, false, errorUtil2.toString(message));
|
|
6975
|
+
}
|
|
6976
|
+
lte(value, message) {
|
|
6977
|
+
return this.setLimit("max", value, true, errorUtil2.toString(message));
|
|
6978
|
+
}
|
|
6979
|
+
lt(value, message) {
|
|
6980
|
+
return this.setLimit("max", value, false, errorUtil2.toString(message));
|
|
6981
|
+
}
|
|
6982
|
+
setLimit(kind, value, inclusive, message) {
|
|
6983
|
+
return new _ZodBigInt2({
|
|
6984
|
+
...this._def,
|
|
6985
|
+
checks: [
|
|
6986
|
+
...this._def.checks,
|
|
6987
|
+
{
|
|
6988
|
+
kind,
|
|
6989
|
+
value,
|
|
6990
|
+
inclusive,
|
|
6991
|
+
message: errorUtil2.toString(message)
|
|
6992
|
+
}
|
|
6993
|
+
]
|
|
6994
|
+
});
|
|
6995
|
+
}
|
|
6996
|
+
_addCheck(check) {
|
|
6997
|
+
return new _ZodBigInt2({
|
|
6998
|
+
...this._def,
|
|
6999
|
+
checks: [...this._def.checks, check]
|
|
7000
|
+
});
|
|
7001
|
+
}
|
|
7002
|
+
positive(message) {
|
|
7003
|
+
return this._addCheck({
|
|
7004
|
+
kind: "min",
|
|
7005
|
+
value: BigInt(0),
|
|
7006
|
+
inclusive: false,
|
|
7007
|
+
message: errorUtil2.toString(message)
|
|
7008
|
+
});
|
|
7009
|
+
}
|
|
7010
|
+
negative(message) {
|
|
7011
|
+
return this._addCheck({
|
|
7012
|
+
kind: "max",
|
|
7013
|
+
value: BigInt(0),
|
|
7014
|
+
inclusive: false,
|
|
7015
|
+
message: errorUtil2.toString(message)
|
|
7016
|
+
});
|
|
7017
|
+
}
|
|
7018
|
+
nonpositive(message) {
|
|
7019
|
+
return this._addCheck({
|
|
7020
|
+
kind: "max",
|
|
7021
|
+
value: BigInt(0),
|
|
7022
|
+
inclusive: true,
|
|
7023
|
+
message: errorUtil2.toString(message)
|
|
7024
|
+
});
|
|
7025
|
+
}
|
|
7026
|
+
nonnegative(message) {
|
|
7027
|
+
return this._addCheck({
|
|
7028
|
+
kind: "min",
|
|
7029
|
+
value: BigInt(0),
|
|
7030
|
+
inclusive: true,
|
|
7031
|
+
message: errorUtil2.toString(message)
|
|
7032
|
+
});
|
|
7033
|
+
}
|
|
7034
|
+
multipleOf(value, message) {
|
|
7035
|
+
return this._addCheck({
|
|
7036
|
+
kind: "multipleOf",
|
|
7037
|
+
value,
|
|
7038
|
+
message: errorUtil2.toString(message)
|
|
7039
|
+
});
|
|
7040
|
+
}
|
|
7041
|
+
get minValue() {
|
|
7042
|
+
let min = null;
|
|
7043
|
+
for (const ch of this._def.checks) {
|
|
7044
|
+
if (ch.kind === "min") {
|
|
7045
|
+
if (min === null || ch.value > min)
|
|
7046
|
+
min = ch.value;
|
|
7047
|
+
}
|
|
7048
|
+
}
|
|
7049
|
+
return min;
|
|
7050
|
+
}
|
|
7051
|
+
get maxValue() {
|
|
7052
|
+
let max = null;
|
|
7053
|
+
for (const ch of this._def.checks) {
|
|
7054
|
+
if (ch.kind === "max") {
|
|
7055
|
+
if (max === null || ch.value < max)
|
|
7056
|
+
max = ch.value;
|
|
7057
|
+
}
|
|
7058
|
+
}
|
|
7059
|
+
return max;
|
|
7060
|
+
}
|
|
7061
|
+
};
|
|
7062
|
+
ZodBigInt2.create = (params) => {
|
|
7063
|
+
return new ZodBigInt2({
|
|
7064
|
+
checks: [],
|
|
7065
|
+
typeName: ZodFirstPartyTypeKind2.ZodBigInt,
|
|
7066
|
+
coerce: params?.coerce ?? false,
|
|
7067
|
+
...processCreateParams2(params)
|
|
7068
|
+
});
|
|
7069
|
+
};
|
|
7070
|
+
var ZodBoolean2 = class extends ZodType2 {
|
|
7071
|
+
_parse(input) {
|
|
7072
|
+
if (this._def.coerce) {
|
|
7073
|
+
input.data = Boolean(input.data);
|
|
7074
|
+
}
|
|
7075
|
+
const parsedType = this._getType(input);
|
|
7076
|
+
if (parsedType !== ZodParsedType2.boolean) {
|
|
7077
|
+
const ctx = this._getOrReturnCtx(input);
|
|
7078
|
+
addIssueToContext2(ctx, {
|
|
7079
|
+
code: ZodIssueCode2.invalid_type,
|
|
7080
|
+
expected: ZodParsedType2.boolean,
|
|
7081
|
+
received: ctx.parsedType
|
|
7082
|
+
});
|
|
7083
|
+
return INVALID2;
|
|
7084
|
+
}
|
|
7085
|
+
return OK2(input.data);
|
|
7086
|
+
}
|
|
7087
|
+
};
|
|
7088
|
+
ZodBoolean2.create = (params) => {
|
|
7089
|
+
return new ZodBoolean2({
|
|
7090
|
+
typeName: ZodFirstPartyTypeKind2.ZodBoolean,
|
|
7091
|
+
coerce: params?.coerce || false,
|
|
7092
|
+
...processCreateParams2(params)
|
|
7093
|
+
});
|
|
7094
|
+
};
|
|
7095
|
+
var ZodDate2 = class _ZodDate2 extends ZodType2 {
|
|
7096
|
+
_parse(input) {
|
|
7097
|
+
if (this._def.coerce) {
|
|
7098
|
+
input.data = new Date(input.data);
|
|
7099
|
+
}
|
|
7100
|
+
const parsedType = this._getType(input);
|
|
7101
|
+
if (parsedType !== ZodParsedType2.date) {
|
|
7102
|
+
const ctx2 = this._getOrReturnCtx(input);
|
|
7103
|
+
addIssueToContext2(ctx2, {
|
|
7104
|
+
code: ZodIssueCode2.invalid_type,
|
|
7105
|
+
expected: ZodParsedType2.date,
|
|
7106
|
+
received: ctx2.parsedType
|
|
7107
|
+
});
|
|
7108
|
+
return INVALID2;
|
|
7109
|
+
}
|
|
7110
|
+
if (Number.isNaN(input.data.getTime())) {
|
|
7111
|
+
const ctx2 = this._getOrReturnCtx(input);
|
|
7112
|
+
addIssueToContext2(ctx2, {
|
|
7113
|
+
code: ZodIssueCode2.invalid_date
|
|
7114
|
+
});
|
|
7115
|
+
return INVALID2;
|
|
7116
|
+
}
|
|
7117
|
+
const status = new ParseStatus2();
|
|
7118
|
+
let ctx = void 0;
|
|
7119
|
+
for (const check of this._def.checks) {
|
|
7120
|
+
if (check.kind === "min") {
|
|
7121
|
+
if (input.data.getTime() < check.value) {
|
|
7122
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
7123
|
+
addIssueToContext2(ctx, {
|
|
7124
|
+
code: ZodIssueCode2.too_small,
|
|
7125
|
+
message: check.message,
|
|
7126
|
+
inclusive: true,
|
|
7127
|
+
exact: false,
|
|
7128
|
+
minimum: check.value,
|
|
7129
|
+
type: "date"
|
|
7130
|
+
});
|
|
7131
|
+
status.dirty();
|
|
7132
|
+
}
|
|
7133
|
+
} else if (check.kind === "max") {
|
|
7134
|
+
if (input.data.getTime() > check.value) {
|
|
7135
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
|
7136
|
+
addIssueToContext2(ctx, {
|
|
7137
|
+
code: ZodIssueCode2.too_big,
|
|
7138
|
+
message: check.message,
|
|
7139
|
+
inclusive: true,
|
|
7140
|
+
exact: false,
|
|
7141
|
+
maximum: check.value,
|
|
7142
|
+
type: "date"
|
|
7143
|
+
});
|
|
7144
|
+
status.dirty();
|
|
7145
|
+
}
|
|
7146
|
+
} else {
|
|
7147
|
+
util2.assertNever(check);
|
|
7148
|
+
}
|
|
7149
|
+
}
|
|
7150
|
+
return {
|
|
7151
|
+
status: status.value,
|
|
7152
|
+
value: new Date(input.data.getTime())
|
|
7153
|
+
};
|
|
7154
|
+
}
|
|
7155
|
+
_addCheck(check) {
|
|
7156
|
+
return new _ZodDate2({
|
|
7157
|
+
...this._def,
|
|
7158
|
+
checks: [...this._def.checks, check]
|
|
7159
|
+
});
|
|
7160
|
+
}
|
|
7161
|
+
min(minDate, message) {
|
|
7162
|
+
return this._addCheck({
|
|
7163
|
+
kind: "min",
|
|
7164
|
+
value: minDate.getTime(),
|
|
7165
|
+
message: errorUtil2.toString(message)
|
|
7166
|
+
});
|
|
7167
|
+
}
|
|
7168
|
+
max(maxDate, message) {
|
|
7169
|
+
return this._addCheck({
|
|
7170
|
+
kind: "max",
|
|
7171
|
+
value: maxDate.getTime(),
|
|
7172
|
+
message: errorUtil2.toString(message)
|
|
7173
|
+
});
|
|
7174
|
+
}
|
|
7175
|
+
get minDate() {
|
|
7176
|
+
let min = null;
|
|
7177
|
+
for (const ch of this._def.checks) {
|
|
7178
|
+
if (ch.kind === "min") {
|
|
7179
|
+
if (min === null || ch.value > min)
|
|
7180
|
+
min = ch.value;
|
|
7181
|
+
}
|
|
7182
|
+
}
|
|
7183
|
+
return min != null ? new Date(min) : null;
|
|
7184
|
+
}
|
|
7185
|
+
get maxDate() {
|
|
7186
|
+
let max = null;
|
|
7187
|
+
for (const ch of this._def.checks) {
|
|
7188
|
+
if (ch.kind === "max") {
|
|
7189
|
+
if (max === null || ch.value < max)
|
|
7190
|
+
max = ch.value;
|
|
7191
|
+
}
|
|
7192
|
+
}
|
|
7193
|
+
return max != null ? new Date(max) : null;
|
|
7194
|
+
}
|
|
7195
|
+
};
|
|
7196
|
+
ZodDate2.create = (params) => {
|
|
7197
|
+
return new ZodDate2({
|
|
7198
|
+
checks: [],
|
|
7199
|
+
coerce: params?.coerce || false,
|
|
7200
|
+
typeName: ZodFirstPartyTypeKind2.ZodDate,
|
|
7201
|
+
...processCreateParams2(params)
|
|
7202
|
+
});
|
|
7203
|
+
};
|
|
7204
|
+
var ZodSymbol2 = class extends ZodType2 {
|
|
7205
|
+
_parse(input) {
|
|
7206
|
+
const parsedType = this._getType(input);
|
|
7207
|
+
if (parsedType !== ZodParsedType2.symbol) {
|
|
7208
|
+
const ctx = this._getOrReturnCtx(input);
|
|
7209
|
+
addIssueToContext2(ctx, {
|
|
7210
|
+
code: ZodIssueCode2.invalid_type,
|
|
7211
|
+
expected: ZodParsedType2.symbol,
|
|
7212
|
+
received: ctx.parsedType
|
|
7213
|
+
});
|
|
7214
|
+
return INVALID2;
|
|
7215
|
+
}
|
|
7216
|
+
return OK2(input.data);
|
|
7217
|
+
}
|
|
7218
|
+
};
|
|
7219
|
+
ZodSymbol2.create = (params) => {
|
|
7220
|
+
return new ZodSymbol2({
|
|
7221
|
+
typeName: ZodFirstPartyTypeKind2.ZodSymbol,
|
|
7222
|
+
...processCreateParams2(params)
|
|
7223
|
+
});
|
|
7224
|
+
};
|
|
7225
|
+
var ZodUndefined2 = class extends ZodType2 {
|
|
7226
|
+
_parse(input) {
|
|
7227
|
+
const parsedType = this._getType(input);
|
|
7228
|
+
if (parsedType !== ZodParsedType2.undefined) {
|
|
7229
|
+
const ctx = this._getOrReturnCtx(input);
|
|
7230
|
+
addIssueToContext2(ctx, {
|
|
7231
|
+
code: ZodIssueCode2.invalid_type,
|
|
7232
|
+
expected: ZodParsedType2.undefined,
|
|
7233
|
+
received: ctx.parsedType
|
|
7234
|
+
});
|
|
7235
|
+
return INVALID2;
|
|
7236
|
+
}
|
|
7237
|
+
return OK2(input.data);
|
|
7238
|
+
}
|
|
7239
|
+
};
|
|
7240
|
+
ZodUndefined2.create = (params) => {
|
|
7241
|
+
return new ZodUndefined2({
|
|
7242
|
+
typeName: ZodFirstPartyTypeKind2.ZodUndefined,
|
|
7243
|
+
...processCreateParams2(params)
|
|
7244
|
+
});
|
|
7245
|
+
};
|
|
7246
|
+
var ZodNull2 = class extends ZodType2 {
|
|
7247
|
+
_parse(input) {
|
|
7248
|
+
const parsedType = this._getType(input);
|
|
7249
|
+
if (parsedType !== ZodParsedType2.null) {
|
|
7250
|
+
const ctx = this._getOrReturnCtx(input);
|
|
7251
|
+
addIssueToContext2(ctx, {
|
|
7252
|
+
code: ZodIssueCode2.invalid_type,
|
|
7253
|
+
expected: ZodParsedType2.null,
|
|
7254
|
+
received: ctx.parsedType
|
|
7255
|
+
});
|
|
7256
|
+
return INVALID2;
|
|
7257
|
+
}
|
|
7258
|
+
return OK2(input.data);
|
|
7259
|
+
}
|
|
7260
|
+
};
|
|
7261
|
+
ZodNull2.create = (params) => {
|
|
7262
|
+
return new ZodNull2({
|
|
7263
|
+
typeName: ZodFirstPartyTypeKind2.ZodNull,
|
|
7264
|
+
...processCreateParams2(params)
|
|
7265
|
+
});
|
|
7266
|
+
};
|
|
7267
|
+
var ZodAny2 = class extends ZodType2 {
|
|
7268
|
+
constructor() {
|
|
7269
|
+
super(...arguments);
|
|
7270
|
+
this._any = true;
|
|
7271
|
+
}
|
|
7272
|
+
_parse(input) {
|
|
7273
|
+
return OK2(input.data);
|
|
7274
|
+
}
|
|
7275
|
+
};
|
|
7276
|
+
ZodAny2.create = (params) => {
|
|
7277
|
+
return new ZodAny2({
|
|
7278
|
+
typeName: ZodFirstPartyTypeKind2.ZodAny,
|
|
7279
|
+
...processCreateParams2(params)
|
|
7280
|
+
});
|
|
7281
|
+
};
|
|
7282
|
+
var ZodUnknown2 = class extends ZodType2 {
|
|
7283
|
+
constructor() {
|
|
7284
|
+
super(...arguments);
|
|
7285
|
+
this._unknown = true;
|
|
7286
|
+
}
|
|
7287
|
+
_parse(input) {
|
|
7288
|
+
return OK2(input.data);
|
|
7289
|
+
}
|
|
7290
|
+
};
|
|
7291
|
+
ZodUnknown2.create = (params) => {
|
|
7292
|
+
return new ZodUnknown2({
|
|
7293
|
+
typeName: ZodFirstPartyTypeKind2.ZodUnknown,
|
|
7294
|
+
...processCreateParams2(params)
|
|
7295
|
+
});
|
|
7296
|
+
};
|
|
7297
|
+
var ZodNever2 = class extends ZodType2 {
|
|
7298
|
+
_parse(input) {
|
|
7299
|
+
const ctx = this._getOrReturnCtx(input);
|
|
7300
|
+
addIssueToContext2(ctx, {
|
|
7301
|
+
code: ZodIssueCode2.invalid_type,
|
|
7302
|
+
expected: ZodParsedType2.never,
|
|
7303
|
+
received: ctx.parsedType
|
|
7304
|
+
});
|
|
7305
|
+
return INVALID2;
|
|
7306
|
+
}
|
|
7307
|
+
};
|
|
7308
|
+
ZodNever2.create = (params) => {
|
|
7309
|
+
return new ZodNever2({
|
|
7310
|
+
typeName: ZodFirstPartyTypeKind2.ZodNever,
|
|
7311
|
+
...processCreateParams2(params)
|
|
7312
|
+
});
|
|
7313
|
+
};
|
|
7314
|
+
var ZodVoid2 = class extends ZodType2 {
|
|
7315
|
+
_parse(input) {
|
|
7316
|
+
const parsedType = this._getType(input);
|
|
7317
|
+
if (parsedType !== ZodParsedType2.undefined) {
|
|
7318
|
+
const ctx = this._getOrReturnCtx(input);
|
|
7319
|
+
addIssueToContext2(ctx, {
|
|
7320
|
+
code: ZodIssueCode2.invalid_type,
|
|
7321
|
+
expected: ZodParsedType2.void,
|
|
7322
|
+
received: ctx.parsedType
|
|
7323
|
+
});
|
|
7324
|
+
return INVALID2;
|
|
7325
|
+
}
|
|
7326
|
+
return OK2(input.data);
|
|
7327
|
+
}
|
|
7328
|
+
};
|
|
7329
|
+
ZodVoid2.create = (params) => {
|
|
7330
|
+
return new ZodVoid2({
|
|
7331
|
+
typeName: ZodFirstPartyTypeKind2.ZodVoid,
|
|
7332
|
+
...processCreateParams2(params)
|
|
7333
|
+
});
|
|
7334
|
+
};
|
|
7335
|
+
var ZodArray2 = class _ZodArray2 extends ZodType2 {
|
|
7336
|
+
_parse(input) {
|
|
7337
|
+
const { ctx, status } = this._processInputParams(input);
|
|
7338
|
+
const def = this._def;
|
|
7339
|
+
if (ctx.parsedType !== ZodParsedType2.array) {
|
|
7340
|
+
addIssueToContext2(ctx, {
|
|
7341
|
+
code: ZodIssueCode2.invalid_type,
|
|
7342
|
+
expected: ZodParsedType2.array,
|
|
7343
|
+
received: ctx.parsedType
|
|
7344
|
+
});
|
|
7345
|
+
return INVALID2;
|
|
7346
|
+
}
|
|
7347
|
+
if (def.exactLength !== null) {
|
|
7348
|
+
const tooBig = ctx.data.length > def.exactLength.value;
|
|
7349
|
+
const tooSmall = ctx.data.length < def.exactLength.value;
|
|
7350
|
+
if (tooBig || tooSmall) {
|
|
7351
|
+
addIssueToContext2(ctx, {
|
|
7352
|
+
code: tooBig ? ZodIssueCode2.too_big : ZodIssueCode2.too_small,
|
|
7353
|
+
minimum: tooSmall ? def.exactLength.value : void 0,
|
|
7354
|
+
maximum: tooBig ? def.exactLength.value : void 0,
|
|
7355
|
+
type: "array",
|
|
7356
|
+
inclusive: true,
|
|
7357
|
+
exact: true,
|
|
7358
|
+
message: def.exactLength.message
|
|
7359
|
+
});
|
|
7360
|
+
status.dirty();
|
|
7361
|
+
}
|
|
7362
|
+
}
|
|
7363
|
+
if (def.minLength !== null) {
|
|
7364
|
+
if (ctx.data.length < def.minLength.value) {
|
|
7365
|
+
addIssueToContext2(ctx, {
|
|
7366
|
+
code: ZodIssueCode2.too_small,
|
|
7367
|
+
minimum: def.minLength.value,
|
|
7368
|
+
type: "array",
|
|
7369
|
+
inclusive: true,
|
|
7370
|
+
exact: false,
|
|
7371
|
+
message: def.minLength.message
|
|
7372
|
+
});
|
|
7373
|
+
status.dirty();
|
|
7374
|
+
}
|
|
7375
|
+
}
|
|
7376
|
+
if (def.maxLength !== null) {
|
|
7377
|
+
if (ctx.data.length > def.maxLength.value) {
|
|
7378
|
+
addIssueToContext2(ctx, {
|
|
7379
|
+
code: ZodIssueCode2.too_big,
|
|
7380
|
+
maximum: def.maxLength.value,
|
|
7381
|
+
type: "array",
|
|
7382
|
+
inclusive: true,
|
|
7383
|
+
exact: false,
|
|
7384
|
+
message: def.maxLength.message
|
|
7385
|
+
});
|
|
7386
|
+
status.dirty();
|
|
7387
|
+
}
|
|
7388
|
+
}
|
|
7389
|
+
if (ctx.common.async) {
|
|
7390
|
+
return Promise.all([...ctx.data].map((item, i) => {
|
|
7391
|
+
return def.type._parseAsync(new ParseInputLazyPath2(ctx, item, ctx.path, i));
|
|
7392
|
+
})).then((result2) => {
|
|
7393
|
+
return ParseStatus2.mergeArray(status, result2);
|
|
7394
|
+
});
|
|
7395
|
+
}
|
|
7396
|
+
const result = [...ctx.data].map((item, i) => {
|
|
7397
|
+
return def.type._parseSync(new ParseInputLazyPath2(ctx, item, ctx.path, i));
|
|
7398
|
+
});
|
|
7399
|
+
return ParseStatus2.mergeArray(status, result);
|
|
7400
|
+
}
|
|
7401
|
+
get element() {
|
|
7402
|
+
return this._def.type;
|
|
7403
|
+
}
|
|
7404
|
+
min(minLength, message) {
|
|
7405
|
+
return new _ZodArray2({
|
|
7406
|
+
...this._def,
|
|
7407
|
+
minLength: { value: minLength, message: errorUtil2.toString(message) }
|
|
7408
|
+
});
|
|
7409
|
+
}
|
|
7410
|
+
max(maxLength, message) {
|
|
7411
|
+
return new _ZodArray2({
|
|
7412
|
+
...this._def,
|
|
7413
|
+
maxLength: { value: maxLength, message: errorUtil2.toString(message) }
|
|
7414
|
+
});
|
|
7415
|
+
}
|
|
7416
|
+
length(len, message) {
|
|
7417
|
+
return new _ZodArray2({
|
|
7418
|
+
...this._def,
|
|
7419
|
+
exactLength: { value: len, message: errorUtil2.toString(message) }
|
|
7420
|
+
});
|
|
7421
|
+
}
|
|
7422
|
+
nonempty(message) {
|
|
7423
|
+
return this.min(1, message);
|
|
7424
|
+
}
|
|
7425
|
+
};
|
|
7426
|
+
ZodArray2.create = (schema, params) => {
|
|
7427
|
+
return new ZodArray2({
|
|
7428
|
+
type: schema,
|
|
7429
|
+
minLength: null,
|
|
7430
|
+
maxLength: null,
|
|
7431
|
+
exactLength: null,
|
|
7432
|
+
typeName: ZodFirstPartyTypeKind2.ZodArray,
|
|
7433
|
+
...processCreateParams2(params)
|
|
7434
|
+
});
|
|
7435
|
+
};
|
|
7436
|
+
function deepPartialify2(schema) {
|
|
7437
|
+
if (schema instanceof ZodObject2) {
|
|
7438
|
+
const newShape = {};
|
|
7439
|
+
for (const key in schema.shape) {
|
|
7440
|
+
const fieldSchema = schema.shape[key];
|
|
7441
|
+
newShape[key] = ZodOptional2.create(deepPartialify2(fieldSchema));
|
|
7442
|
+
}
|
|
7443
|
+
return new ZodObject2({
|
|
7444
|
+
...schema._def,
|
|
7445
|
+
shape: () => newShape
|
|
7446
|
+
});
|
|
7447
|
+
} else if (schema instanceof ZodArray2) {
|
|
7448
|
+
return new ZodArray2({
|
|
7449
|
+
...schema._def,
|
|
7450
|
+
type: deepPartialify2(schema.element)
|
|
7451
|
+
});
|
|
7452
|
+
} else if (schema instanceof ZodOptional2) {
|
|
7453
|
+
return ZodOptional2.create(deepPartialify2(schema.unwrap()));
|
|
7454
|
+
} else if (schema instanceof ZodNullable2) {
|
|
7455
|
+
return ZodNullable2.create(deepPartialify2(schema.unwrap()));
|
|
7456
|
+
} else if (schema instanceof ZodTuple2) {
|
|
7457
|
+
return ZodTuple2.create(schema.items.map((item) => deepPartialify2(item)));
|
|
7458
|
+
} else {
|
|
7459
|
+
return schema;
|
|
7460
|
+
}
|
|
7461
|
+
}
|
|
7462
|
+
var ZodObject2 = class _ZodObject2 extends ZodType2 {
|
|
7463
|
+
constructor() {
|
|
7464
|
+
super(...arguments);
|
|
7465
|
+
this._cached = null;
|
|
7466
|
+
this.nonstrict = this.passthrough;
|
|
7467
|
+
this.augment = this.extend;
|
|
7468
|
+
}
|
|
7469
|
+
_getCached() {
|
|
7470
|
+
if (this._cached !== null)
|
|
7471
|
+
return this._cached;
|
|
7472
|
+
const shape = this._def.shape();
|
|
7473
|
+
const keys = util2.objectKeys(shape);
|
|
7474
|
+
this._cached = { shape, keys };
|
|
7475
|
+
return this._cached;
|
|
7476
|
+
}
|
|
7477
|
+
_parse(input) {
|
|
7478
|
+
const parsedType = this._getType(input);
|
|
7479
|
+
if (parsedType !== ZodParsedType2.object) {
|
|
7480
|
+
const ctx2 = this._getOrReturnCtx(input);
|
|
7481
|
+
addIssueToContext2(ctx2, {
|
|
7482
|
+
code: ZodIssueCode2.invalid_type,
|
|
7483
|
+
expected: ZodParsedType2.object,
|
|
7484
|
+
received: ctx2.parsedType
|
|
7485
|
+
});
|
|
7486
|
+
return INVALID2;
|
|
7487
|
+
}
|
|
7488
|
+
const { status, ctx } = this._processInputParams(input);
|
|
7489
|
+
const { shape, keys: shapeKeys } = this._getCached();
|
|
7490
|
+
const extraKeys = [];
|
|
7491
|
+
if (!(this._def.catchall instanceof ZodNever2 && this._def.unknownKeys === "strip")) {
|
|
7492
|
+
for (const key in ctx.data) {
|
|
7493
|
+
if (!shapeKeys.includes(key)) {
|
|
7494
|
+
extraKeys.push(key);
|
|
7495
|
+
}
|
|
7496
|
+
}
|
|
7497
|
+
}
|
|
7498
|
+
const pairs = [];
|
|
7499
|
+
for (const key of shapeKeys) {
|
|
7500
|
+
const keyValidator = shape[key];
|
|
7501
|
+
const value = ctx.data[key];
|
|
7502
|
+
pairs.push({
|
|
7503
|
+
key: { status: "valid", value: key },
|
|
7504
|
+
value: keyValidator._parse(new ParseInputLazyPath2(ctx, value, ctx.path, key)),
|
|
7505
|
+
alwaysSet: key in ctx.data
|
|
7506
|
+
});
|
|
7507
|
+
}
|
|
7508
|
+
if (this._def.catchall instanceof ZodNever2) {
|
|
7509
|
+
const unknownKeys = this._def.unknownKeys;
|
|
7510
|
+
if (unknownKeys === "passthrough") {
|
|
7511
|
+
for (const key of extraKeys) {
|
|
7512
|
+
pairs.push({
|
|
7513
|
+
key: { status: "valid", value: key },
|
|
7514
|
+
value: { status: "valid", value: ctx.data[key] }
|
|
7515
|
+
});
|
|
7516
|
+
}
|
|
7517
|
+
} else if (unknownKeys === "strict") {
|
|
7518
|
+
if (extraKeys.length > 0) {
|
|
7519
|
+
addIssueToContext2(ctx, {
|
|
7520
|
+
code: ZodIssueCode2.unrecognized_keys,
|
|
7521
|
+
keys: extraKeys
|
|
7522
|
+
});
|
|
7523
|
+
status.dirty();
|
|
7524
|
+
}
|
|
7525
|
+
} else if (unknownKeys === "strip") {
|
|
7526
|
+
} else {
|
|
7527
|
+
throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
|
|
7528
|
+
}
|
|
7529
|
+
} else {
|
|
7530
|
+
const catchall = this._def.catchall;
|
|
7531
|
+
for (const key of extraKeys) {
|
|
7532
|
+
const value = ctx.data[key];
|
|
7533
|
+
pairs.push({
|
|
7534
|
+
key: { status: "valid", value: key },
|
|
7535
|
+
value: catchall._parse(
|
|
7536
|
+
new ParseInputLazyPath2(ctx, value, ctx.path, key)
|
|
7537
|
+
//, ctx.child(key), value, getParsedType(value)
|
|
7538
|
+
),
|
|
7539
|
+
alwaysSet: key in ctx.data
|
|
7540
|
+
});
|
|
7541
|
+
}
|
|
7542
|
+
}
|
|
7543
|
+
if (ctx.common.async) {
|
|
7544
|
+
return Promise.resolve().then(async () => {
|
|
7545
|
+
const syncPairs = [];
|
|
7546
|
+
for (const pair of pairs) {
|
|
7547
|
+
const key = await pair.key;
|
|
7548
|
+
const value = await pair.value;
|
|
7549
|
+
syncPairs.push({
|
|
7550
|
+
key,
|
|
7551
|
+
value,
|
|
7552
|
+
alwaysSet: pair.alwaysSet
|
|
7553
|
+
});
|
|
7554
|
+
}
|
|
7555
|
+
return syncPairs;
|
|
7556
|
+
}).then((syncPairs) => {
|
|
7557
|
+
return ParseStatus2.mergeObjectSync(status, syncPairs);
|
|
7558
|
+
});
|
|
7559
|
+
} else {
|
|
7560
|
+
return ParseStatus2.mergeObjectSync(status, pairs);
|
|
7561
|
+
}
|
|
7562
|
+
}
|
|
7563
|
+
get shape() {
|
|
7564
|
+
return this._def.shape();
|
|
7565
|
+
}
|
|
7566
|
+
strict(message) {
|
|
7567
|
+
errorUtil2.errToObj;
|
|
7568
|
+
return new _ZodObject2({
|
|
7569
|
+
...this._def,
|
|
7570
|
+
unknownKeys: "strict",
|
|
7571
|
+
...message !== void 0 ? {
|
|
7572
|
+
errorMap: (issue, ctx) => {
|
|
7573
|
+
const defaultError = this._def.errorMap?.(issue, ctx).message ?? ctx.defaultError;
|
|
7574
|
+
if (issue.code === "unrecognized_keys")
|
|
7575
|
+
return {
|
|
7576
|
+
message: errorUtil2.errToObj(message).message ?? defaultError
|
|
7577
|
+
};
|
|
7578
|
+
return {
|
|
7579
|
+
message: defaultError
|
|
7580
|
+
};
|
|
7581
|
+
}
|
|
7582
|
+
} : {}
|
|
7583
|
+
});
|
|
7584
|
+
}
|
|
7585
|
+
strip() {
|
|
7586
|
+
return new _ZodObject2({
|
|
7587
|
+
...this._def,
|
|
7588
|
+
unknownKeys: "strip"
|
|
7589
|
+
});
|
|
7590
|
+
}
|
|
7591
|
+
passthrough() {
|
|
7592
|
+
return new _ZodObject2({
|
|
7593
|
+
...this._def,
|
|
7594
|
+
unknownKeys: "passthrough"
|
|
7595
|
+
});
|
|
7596
|
+
}
|
|
7597
|
+
// const AugmentFactory =
|
|
7598
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
|
7599
|
+
// <Augmentation extends ZodRawShape>(
|
|
7600
|
+
// augmentation: Augmentation
|
|
7601
|
+
// ): ZodObject<
|
|
7602
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
7603
|
+
// Def["unknownKeys"],
|
|
7604
|
+
// Def["catchall"]
|
|
7605
|
+
// > => {
|
|
7606
|
+
// return new ZodObject({
|
|
7607
|
+
// ...def,
|
|
7608
|
+
// shape: () => ({
|
|
7609
|
+
// ...def.shape(),
|
|
7610
|
+
// ...augmentation,
|
|
7611
|
+
// }),
|
|
7612
|
+
// }) as any;
|
|
7613
|
+
// };
|
|
7614
|
+
extend(augmentation) {
|
|
7615
|
+
return new _ZodObject2({
|
|
7616
|
+
...this._def,
|
|
7617
|
+
shape: () => ({
|
|
7618
|
+
...this._def.shape(),
|
|
7619
|
+
...augmentation
|
|
7620
|
+
})
|
|
7621
|
+
});
|
|
7622
|
+
}
|
|
7623
|
+
/**
|
|
7624
|
+
* Prior to zod@1.0.12 there was a bug in the
|
|
7625
|
+
* inferred type of merged objects. Please
|
|
7626
|
+
* upgrade if you are experiencing issues.
|
|
7627
|
+
*/
|
|
7628
|
+
merge(merging) {
|
|
7629
|
+
const merged = new _ZodObject2({
|
|
7630
|
+
unknownKeys: merging._def.unknownKeys,
|
|
7631
|
+
catchall: merging._def.catchall,
|
|
7632
|
+
shape: () => ({
|
|
7633
|
+
...this._def.shape(),
|
|
7634
|
+
...merging._def.shape()
|
|
7635
|
+
}),
|
|
7636
|
+
typeName: ZodFirstPartyTypeKind2.ZodObject
|
|
7637
|
+
});
|
|
7638
|
+
return merged;
|
|
7639
|
+
}
|
|
7640
|
+
// merge<
|
|
7641
|
+
// Incoming extends AnyZodObject,
|
|
7642
|
+
// Augmentation extends Incoming["shape"],
|
|
7643
|
+
// NewOutput extends {
|
|
7644
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
7645
|
+
// ? Augmentation[k]["_output"]
|
|
7646
|
+
// : k extends keyof Output
|
|
7647
|
+
// ? Output[k]
|
|
7648
|
+
// : never;
|
|
7649
|
+
// },
|
|
7650
|
+
// NewInput extends {
|
|
7651
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
7652
|
+
// ? Augmentation[k]["_input"]
|
|
7653
|
+
// : k extends keyof Input
|
|
7654
|
+
// ? Input[k]
|
|
7655
|
+
// : never;
|
|
7656
|
+
// }
|
|
7657
|
+
// >(
|
|
7658
|
+
// merging: Incoming
|
|
7659
|
+
// ): ZodObject<
|
|
7660
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
7661
|
+
// Incoming["_def"]["unknownKeys"],
|
|
7662
|
+
// Incoming["_def"]["catchall"],
|
|
7663
|
+
// NewOutput,
|
|
7664
|
+
// NewInput
|
|
7665
|
+
// > {
|
|
7666
|
+
// const merged: any = new ZodObject({
|
|
7667
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
7668
|
+
// catchall: merging._def.catchall,
|
|
7669
|
+
// shape: () =>
|
|
7670
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
7671
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
7672
|
+
// }) as any;
|
|
7673
|
+
// return merged;
|
|
7674
|
+
// }
|
|
7675
|
+
setKey(key, schema) {
|
|
7676
|
+
return this.augment({ [key]: schema });
|
|
7677
|
+
}
|
|
7678
|
+
// merge<Incoming extends AnyZodObject>(
|
|
7679
|
+
// merging: Incoming
|
|
7680
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
7681
|
+
// ZodObject<
|
|
7682
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
7683
|
+
// Incoming["_def"]["unknownKeys"],
|
|
7684
|
+
// Incoming["_def"]["catchall"]
|
|
7685
|
+
// > {
|
|
7686
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
|
7687
|
+
// // this._def.shape(),
|
|
7688
|
+
// // merging._def.shape()
|
|
7689
|
+
// // );
|
|
7690
|
+
// const merged: any = new ZodObject({
|
|
7691
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
7692
|
+
// catchall: merging._def.catchall,
|
|
7693
|
+
// shape: () =>
|
|
7694
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
7695
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
7696
|
+
// }) as any;
|
|
7697
|
+
// return merged;
|
|
7698
|
+
// }
|
|
7699
|
+
catchall(index) {
|
|
7700
|
+
return new _ZodObject2({
|
|
7701
|
+
...this._def,
|
|
7702
|
+
catchall: index
|
|
7703
|
+
});
|
|
7704
|
+
}
|
|
7705
|
+
pick(mask) {
|
|
7706
|
+
const shape = {};
|
|
7707
|
+
for (const key of util2.objectKeys(mask)) {
|
|
7708
|
+
if (mask[key] && this.shape[key]) {
|
|
7709
|
+
shape[key] = this.shape[key];
|
|
7710
|
+
}
|
|
7711
|
+
}
|
|
7712
|
+
return new _ZodObject2({
|
|
7713
|
+
...this._def,
|
|
7714
|
+
shape: () => shape
|
|
7715
|
+
});
|
|
7716
|
+
}
|
|
7717
|
+
omit(mask) {
|
|
7718
|
+
const shape = {};
|
|
7719
|
+
for (const key of util2.objectKeys(this.shape)) {
|
|
7720
|
+
if (!mask[key]) {
|
|
7721
|
+
shape[key] = this.shape[key];
|
|
7722
|
+
}
|
|
7723
|
+
}
|
|
7724
|
+
return new _ZodObject2({
|
|
7725
|
+
...this._def,
|
|
7726
|
+
shape: () => shape
|
|
7727
|
+
});
|
|
7728
|
+
}
|
|
7729
|
+
/**
|
|
7730
|
+
* @deprecated
|
|
7731
|
+
*/
|
|
7732
|
+
deepPartial() {
|
|
7733
|
+
return deepPartialify2(this);
|
|
7734
|
+
}
|
|
7735
|
+
partial(mask) {
|
|
7736
|
+
const newShape = {};
|
|
7737
|
+
for (const key of util2.objectKeys(this.shape)) {
|
|
7738
|
+
const fieldSchema = this.shape[key];
|
|
7739
|
+
if (mask && !mask[key]) {
|
|
7740
|
+
newShape[key] = fieldSchema;
|
|
7741
|
+
} else {
|
|
7742
|
+
newShape[key] = fieldSchema.optional();
|
|
7743
|
+
}
|
|
7744
|
+
}
|
|
7745
|
+
return new _ZodObject2({
|
|
7746
|
+
...this._def,
|
|
7747
|
+
shape: () => newShape
|
|
7748
|
+
});
|
|
7749
|
+
}
|
|
7750
|
+
required(mask) {
|
|
7751
|
+
const newShape = {};
|
|
7752
|
+
for (const key of util2.objectKeys(this.shape)) {
|
|
7753
|
+
if (mask && !mask[key]) {
|
|
7754
|
+
newShape[key] = this.shape[key];
|
|
7755
|
+
} else {
|
|
7756
|
+
const fieldSchema = this.shape[key];
|
|
7757
|
+
let newField = fieldSchema;
|
|
7758
|
+
while (newField instanceof ZodOptional2) {
|
|
7759
|
+
newField = newField._def.innerType;
|
|
7760
|
+
}
|
|
7761
|
+
newShape[key] = newField;
|
|
7762
|
+
}
|
|
7763
|
+
}
|
|
7764
|
+
return new _ZodObject2({
|
|
7765
|
+
...this._def,
|
|
7766
|
+
shape: () => newShape
|
|
7767
|
+
});
|
|
7768
|
+
}
|
|
7769
|
+
keyof() {
|
|
7770
|
+
return createZodEnum2(util2.objectKeys(this.shape));
|
|
7771
|
+
}
|
|
7772
|
+
};
|
|
7773
|
+
ZodObject2.create = (shape, params) => {
|
|
7774
|
+
return new ZodObject2({
|
|
7775
|
+
shape: () => shape,
|
|
7776
|
+
unknownKeys: "strip",
|
|
7777
|
+
catchall: ZodNever2.create(),
|
|
7778
|
+
typeName: ZodFirstPartyTypeKind2.ZodObject,
|
|
7779
|
+
...processCreateParams2(params)
|
|
7780
|
+
});
|
|
7781
|
+
};
|
|
7782
|
+
ZodObject2.strictCreate = (shape, params) => {
|
|
7783
|
+
return new ZodObject2({
|
|
7784
|
+
shape: () => shape,
|
|
7785
|
+
unknownKeys: "strict",
|
|
7786
|
+
catchall: ZodNever2.create(),
|
|
7787
|
+
typeName: ZodFirstPartyTypeKind2.ZodObject,
|
|
7788
|
+
...processCreateParams2(params)
|
|
7789
|
+
});
|
|
7790
|
+
};
|
|
7791
|
+
ZodObject2.lazycreate = (shape, params) => {
|
|
7792
|
+
return new ZodObject2({
|
|
7793
|
+
shape,
|
|
7794
|
+
unknownKeys: "strip",
|
|
7795
|
+
catchall: ZodNever2.create(),
|
|
7796
|
+
typeName: ZodFirstPartyTypeKind2.ZodObject,
|
|
7797
|
+
...processCreateParams2(params)
|
|
7798
|
+
});
|
|
7799
|
+
};
|
|
7800
|
+
var ZodUnion2 = class extends ZodType2 {
|
|
7801
|
+
_parse(input) {
|
|
7802
|
+
const { ctx } = this._processInputParams(input);
|
|
7803
|
+
const options = this._def.options;
|
|
7804
|
+
function handleResults(results) {
|
|
7805
|
+
for (const result of results) {
|
|
7806
|
+
if (result.result.status === "valid") {
|
|
7807
|
+
return result.result;
|
|
7808
|
+
}
|
|
7809
|
+
}
|
|
7810
|
+
for (const result of results) {
|
|
7811
|
+
if (result.result.status === "dirty") {
|
|
7812
|
+
ctx.common.issues.push(...result.ctx.common.issues);
|
|
7813
|
+
return result.result;
|
|
7814
|
+
}
|
|
7815
|
+
}
|
|
7816
|
+
const unionErrors = results.map((result) => new ZodError2(result.ctx.common.issues));
|
|
7817
|
+
addIssueToContext2(ctx, {
|
|
7818
|
+
code: ZodIssueCode2.invalid_union,
|
|
7819
|
+
unionErrors
|
|
7820
|
+
});
|
|
7821
|
+
return INVALID2;
|
|
7822
|
+
}
|
|
7823
|
+
if (ctx.common.async) {
|
|
7824
|
+
return Promise.all(options.map(async (option) => {
|
|
7825
|
+
const childCtx = {
|
|
7826
|
+
...ctx,
|
|
7827
|
+
common: {
|
|
7828
|
+
...ctx.common,
|
|
7829
|
+
issues: []
|
|
7830
|
+
},
|
|
7831
|
+
parent: null
|
|
7832
|
+
};
|
|
7833
|
+
return {
|
|
7834
|
+
result: await option._parseAsync({
|
|
7835
|
+
data: ctx.data,
|
|
7836
|
+
path: ctx.path,
|
|
7837
|
+
parent: childCtx
|
|
7838
|
+
}),
|
|
7839
|
+
ctx: childCtx
|
|
7840
|
+
};
|
|
7841
|
+
})).then(handleResults);
|
|
7842
|
+
} else {
|
|
7843
|
+
let dirty = void 0;
|
|
7844
|
+
const issues = [];
|
|
7845
|
+
for (const option of options) {
|
|
7846
|
+
const childCtx = {
|
|
7847
|
+
...ctx,
|
|
7848
|
+
common: {
|
|
7849
|
+
...ctx.common,
|
|
7850
|
+
issues: []
|
|
7851
|
+
},
|
|
7852
|
+
parent: null
|
|
7853
|
+
};
|
|
7854
|
+
const result = option._parseSync({
|
|
7855
|
+
data: ctx.data,
|
|
7856
|
+
path: ctx.path,
|
|
7857
|
+
parent: childCtx
|
|
7858
|
+
});
|
|
7859
|
+
if (result.status === "valid") {
|
|
7860
|
+
return result;
|
|
7861
|
+
} else if (result.status === "dirty" && !dirty) {
|
|
7862
|
+
dirty = { result, ctx: childCtx };
|
|
7863
|
+
}
|
|
7864
|
+
if (childCtx.common.issues.length) {
|
|
7865
|
+
issues.push(childCtx.common.issues);
|
|
7866
|
+
}
|
|
7867
|
+
}
|
|
7868
|
+
if (dirty) {
|
|
7869
|
+
ctx.common.issues.push(...dirty.ctx.common.issues);
|
|
7870
|
+
return dirty.result;
|
|
7871
|
+
}
|
|
7872
|
+
const unionErrors = issues.map((issues2) => new ZodError2(issues2));
|
|
7873
|
+
addIssueToContext2(ctx, {
|
|
7874
|
+
code: ZodIssueCode2.invalid_union,
|
|
7875
|
+
unionErrors
|
|
7876
|
+
});
|
|
7877
|
+
return INVALID2;
|
|
7878
|
+
}
|
|
7879
|
+
}
|
|
7880
|
+
get options() {
|
|
7881
|
+
return this._def.options;
|
|
7882
|
+
}
|
|
7883
|
+
};
|
|
7884
|
+
ZodUnion2.create = (types, params) => {
|
|
7885
|
+
return new ZodUnion2({
|
|
7886
|
+
options: types,
|
|
7887
|
+
typeName: ZodFirstPartyTypeKind2.ZodUnion,
|
|
7888
|
+
...processCreateParams2(params)
|
|
7889
|
+
});
|
|
7890
|
+
};
|
|
7891
|
+
var getDiscriminator2 = (type) => {
|
|
7892
|
+
if (type instanceof ZodLazy2) {
|
|
7893
|
+
return getDiscriminator2(type.schema);
|
|
7894
|
+
} else if (type instanceof ZodEffects2) {
|
|
7895
|
+
return getDiscriminator2(type.innerType());
|
|
7896
|
+
} else if (type instanceof ZodLiteral2) {
|
|
7897
|
+
return [type.value];
|
|
7898
|
+
} else if (type instanceof ZodEnum2) {
|
|
7899
|
+
return type.options;
|
|
7900
|
+
} else if (type instanceof ZodNativeEnum2) {
|
|
7901
|
+
return util2.objectValues(type.enum);
|
|
7902
|
+
} else if (type instanceof ZodDefault2) {
|
|
7903
|
+
return getDiscriminator2(type._def.innerType);
|
|
7904
|
+
} else if (type instanceof ZodUndefined2) {
|
|
7905
|
+
return [void 0];
|
|
7906
|
+
} else if (type instanceof ZodNull2) {
|
|
7907
|
+
return [null];
|
|
7908
|
+
} else if (type instanceof ZodOptional2) {
|
|
7909
|
+
return [void 0, ...getDiscriminator2(type.unwrap())];
|
|
7910
|
+
} else if (type instanceof ZodNullable2) {
|
|
7911
|
+
return [null, ...getDiscriminator2(type.unwrap())];
|
|
7912
|
+
} else if (type instanceof ZodBranded2) {
|
|
7913
|
+
return getDiscriminator2(type.unwrap());
|
|
7914
|
+
} else if (type instanceof ZodReadonly2) {
|
|
7915
|
+
return getDiscriminator2(type.unwrap());
|
|
7916
|
+
} else if (type instanceof ZodCatch2) {
|
|
7917
|
+
return getDiscriminator2(type._def.innerType);
|
|
7918
|
+
} else {
|
|
7919
|
+
return [];
|
|
7920
|
+
}
|
|
7921
|
+
};
|
|
7922
|
+
var ZodDiscriminatedUnion2 = class _ZodDiscriminatedUnion2 extends ZodType2 {
|
|
7923
|
+
_parse(input) {
|
|
7924
|
+
const { ctx } = this._processInputParams(input);
|
|
7925
|
+
if (ctx.parsedType !== ZodParsedType2.object) {
|
|
7926
|
+
addIssueToContext2(ctx, {
|
|
7927
|
+
code: ZodIssueCode2.invalid_type,
|
|
7928
|
+
expected: ZodParsedType2.object,
|
|
7929
|
+
received: ctx.parsedType
|
|
7930
|
+
});
|
|
7931
|
+
return INVALID2;
|
|
7932
|
+
}
|
|
7933
|
+
const discriminator = this.discriminator;
|
|
7934
|
+
const discriminatorValue = ctx.data[discriminator];
|
|
7935
|
+
const option = this.optionsMap.get(discriminatorValue);
|
|
7936
|
+
if (!option) {
|
|
7937
|
+
addIssueToContext2(ctx, {
|
|
7938
|
+
code: ZodIssueCode2.invalid_union_discriminator,
|
|
7939
|
+
options: Array.from(this.optionsMap.keys()),
|
|
7940
|
+
path: [discriminator]
|
|
7941
|
+
});
|
|
7942
|
+
return INVALID2;
|
|
7943
|
+
}
|
|
7944
|
+
if (ctx.common.async) {
|
|
7945
|
+
return option._parseAsync({
|
|
7946
|
+
data: ctx.data,
|
|
7947
|
+
path: ctx.path,
|
|
7948
|
+
parent: ctx
|
|
7949
|
+
});
|
|
7950
|
+
} else {
|
|
7951
|
+
return option._parseSync({
|
|
7952
|
+
data: ctx.data,
|
|
7953
|
+
path: ctx.path,
|
|
7954
|
+
parent: ctx
|
|
7955
|
+
});
|
|
7956
|
+
}
|
|
7957
|
+
}
|
|
7958
|
+
get discriminator() {
|
|
7959
|
+
return this._def.discriminator;
|
|
7960
|
+
}
|
|
7961
|
+
get options() {
|
|
7962
|
+
return this._def.options;
|
|
7963
|
+
}
|
|
7964
|
+
get optionsMap() {
|
|
7965
|
+
return this._def.optionsMap;
|
|
7966
|
+
}
|
|
7967
|
+
/**
|
|
7968
|
+
* The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
|
|
7969
|
+
* However, it only allows a union of objects, all of which need to share a discriminator property. This property must
|
|
7970
|
+
* have a different value for each object in the union.
|
|
7971
|
+
* @param discriminator the name of the discriminator property
|
|
7972
|
+
* @param types an array of object schemas
|
|
7973
|
+
* @param params
|
|
7974
|
+
*/
|
|
7975
|
+
static create(discriminator, options, params) {
|
|
7976
|
+
const optionsMap = /* @__PURE__ */ new Map();
|
|
7977
|
+
for (const type of options) {
|
|
7978
|
+
const discriminatorValues = getDiscriminator2(type.shape[discriminator]);
|
|
7979
|
+
if (!discriminatorValues.length) {
|
|
7980
|
+
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
7981
|
+
}
|
|
7982
|
+
for (const value of discriminatorValues) {
|
|
7983
|
+
if (optionsMap.has(value)) {
|
|
7984
|
+
throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
|
|
7985
|
+
}
|
|
7986
|
+
optionsMap.set(value, type);
|
|
7987
|
+
}
|
|
7988
|
+
}
|
|
7989
|
+
return new _ZodDiscriminatedUnion2({
|
|
7990
|
+
typeName: ZodFirstPartyTypeKind2.ZodDiscriminatedUnion,
|
|
7991
|
+
discriminator,
|
|
7992
|
+
options,
|
|
7993
|
+
optionsMap,
|
|
7994
|
+
...processCreateParams2(params)
|
|
7995
|
+
});
|
|
7996
|
+
}
|
|
7997
|
+
};
|
|
7998
|
+
function mergeValues2(a, b) {
|
|
7999
|
+
const aType = getParsedType2(a);
|
|
8000
|
+
const bType = getParsedType2(b);
|
|
8001
|
+
if (a === b) {
|
|
8002
|
+
return { valid: true, data: a };
|
|
8003
|
+
} else if (aType === ZodParsedType2.object && bType === ZodParsedType2.object) {
|
|
8004
|
+
const bKeys = util2.objectKeys(b);
|
|
8005
|
+
const sharedKeys = util2.objectKeys(a).filter((key) => bKeys.indexOf(key) !== -1);
|
|
8006
|
+
const newObj = { ...a, ...b };
|
|
8007
|
+
for (const key of sharedKeys) {
|
|
8008
|
+
const sharedValue = mergeValues2(a[key], b[key]);
|
|
8009
|
+
if (!sharedValue.valid) {
|
|
8010
|
+
return { valid: false };
|
|
8011
|
+
}
|
|
8012
|
+
newObj[key] = sharedValue.data;
|
|
8013
|
+
}
|
|
8014
|
+
return { valid: true, data: newObj };
|
|
8015
|
+
} else if (aType === ZodParsedType2.array && bType === ZodParsedType2.array) {
|
|
8016
|
+
if (a.length !== b.length) {
|
|
8017
|
+
return { valid: false };
|
|
8018
|
+
}
|
|
8019
|
+
const newArray = [];
|
|
8020
|
+
for (let index = 0; index < a.length; index++) {
|
|
8021
|
+
const itemA = a[index];
|
|
8022
|
+
const itemB = b[index];
|
|
8023
|
+
const sharedValue = mergeValues2(itemA, itemB);
|
|
8024
|
+
if (!sharedValue.valid) {
|
|
8025
|
+
return { valid: false };
|
|
8026
|
+
}
|
|
8027
|
+
newArray.push(sharedValue.data);
|
|
8028
|
+
}
|
|
8029
|
+
return { valid: true, data: newArray };
|
|
8030
|
+
} else if (aType === ZodParsedType2.date && bType === ZodParsedType2.date && +a === +b) {
|
|
8031
|
+
return { valid: true, data: a };
|
|
8032
|
+
} else {
|
|
8033
|
+
return { valid: false };
|
|
8034
|
+
}
|
|
8035
|
+
}
|
|
8036
|
+
var ZodIntersection2 = class extends ZodType2 {
|
|
8037
|
+
_parse(input) {
|
|
8038
|
+
const { status, ctx } = this._processInputParams(input);
|
|
8039
|
+
const handleParsed = (parsedLeft, parsedRight) => {
|
|
8040
|
+
if (isAborted2(parsedLeft) || isAborted2(parsedRight)) {
|
|
8041
|
+
return INVALID2;
|
|
8042
|
+
}
|
|
8043
|
+
const merged = mergeValues2(parsedLeft.value, parsedRight.value);
|
|
8044
|
+
if (!merged.valid) {
|
|
8045
|
+
addIssueToContext2(ctx, {
|
|
8046
|
+
code: ZodIssueCode2.invalid_intersection_types
|
|
8047
|
+
});
|
|
8048
|
+
return INVALID2;
|
|
8049
|
+
}
|
|
8050
|
+
if (isDirty2(parsedLeft) || isDirty2(parsedRight)) {
|
|
8051
|
+
status.dirty();
|
|
8052
|
+
}
|
|
8053
|
+
return { status: status.value, value: merged.data };
|
|
8054
|
+
};
|
|
8055
|
+
if (ctx.common.async) {
|
|
8056
|
+
return Promise.all([
|
|
8057
|
+
this._def.left._parseAsync({
|
|
8058
|
+
data: ctx.data,
|
|
8059
|
+
path: ctx.path,
|
|
8060
|
+
parent: ctx
|
|
8061
|
+
}),
|
|
8062
|
+
this._def.right._parseAsync({
|
|
8063
|
+
data: ctx.data,
|
|
8064
|
+
path: ctx.path,
|
|
8065
|
+
parent: ctx
|
|
8066
|
+
})
|
|
8067
|
+
]).then(([left, right]) => handleParsed(left, right));
|
|
8068
|
+
} else {
|
|
8069
|
+
return handleParsed(this._def.left._parseSync({
|
|
8070
|
+
data: ctx.data,
|
|
8071
|
+
path: ctx.path,
|
|
8072
|
+
parent: ctx
|
|
8073
|
+
}), this._def.right._parseSync({
|
|
8074
|
+
data: ctx.data,
|
|
8075
|
+
path: ctx.path,
|
|
8076
|
+
parent: ctx
|
|
8077
|
+
}));
|
|
8078
|
+
}
|
|
8079
|
+
}
|
|
8080
|
+
};
|
|
8081
|
+
ZodIntersection2.create = (left, right, params) => {
|
|
8082
|
+
return new ZodIntersection2({
|
|
8083
|
+
left,
|
|
8084
|
+
right,
|
|
8085
|
+
typeName: ZodFirstPartyTypeKind2.ZodIntersection,
|
|
8086
|
+
...processCreateParams2(params)
|
|
8087
|
+
});
|
|
8088
|
+
};
|
|
8089
|
+
var ZodTuple2 = class _ZodTuple2 extends ZodType2 {
|
|
8090
|
+
_parse(input) {
|
|
8091
|
+
const { status, ctx } = this._processInputParams(input);
|
|
8092
|
+
if (ctx.parsedType !== ZodParsedType2.array) {
|
|
8093
|
+
addIssueToContext2(ctx, {
|
|
8094
|
+
code: ZodIssueCode2.invalid_type,
|
|
8095
|
+
expected: ZodParsedType2.array,
|
|
8096
|
+
received: ctx.parsedType
|
|
8097
|
+
});
|
|
8098
|
+
return INVALID2;
|
|
8099
|
+
}
|
|
8100
|
+
if (ctx.data.length < this._def.items.length) {
|
|
8101
|
+
addIssueToContext2(ctx, {
|
|
8102
|
+
code: ZodIssueCode2.too_small,
|
|
8103
|
+
minimum: this._def.items.length,
|
|
8104
|
+
inclusive: true,
|
|
8105
|
+
exact: false,
|
|
8106
|
+
type: "array"
|
|
8107
|
+
});
|
|
8108
|
+
return INVALID2;
|
|
8109
|
+
}
|
|
8110
|
+
const rest = this._def.rest;
|
|
8111
|
+
if (!rest && ctx.data.length > this._def.items.length) {
|
|
8112
|
+
addIssueToContext2(ctx, {
|
|
8113
|
+
code: ZodIssueCode2.too_big,
|
|
8114
|
+
maximum: this._def.items.length,
|
|
8115
|
+
inclusive: true,
|
|
8116
|
+
exact: false,
|
|
8117
|
+
type: "array"
|
|
8118
|
+
});
|
|
8119
|
+
status.dirty();
|
|
8120
|
+
}
|
|
8121
|
+
const items = [...ctx.data].map((item, itemIndex) => {
|
|
8122
|
+
const schema = this._def.items[itemIndex] || this._def.rest;
|
|
8123
|
+
if (!schema)
|
|
8124
|
+
return null;
|
|
8125
|
+
return schema._parse(new ParseInputLazyPath2(ctx, item, ctx.path, itemIndex));
|
|
8126
|
+
}).filter((x) => !!x);
|
|
8127
|
+
if (ctx.common.async) {
|
|
8128
|
+
return Promise.all(items).then((results) => {
|
|
8129
|
+
return ParseStatus2.mergeArray(status, results);
|
|
8130
|
+
});
|
|
8131
|
+
} else {
|
|
8132
|
+
return ParseStatus2.mergeArray(status, items);
|
|
8133
|
+
}
|
|
8134
|
+
}
|
|
8135
|
+
get items() {
|
|
8136
|
+
return this._def.items;
|
|
8137
|
+
}
|
|
8138
|
+
rest(rest) {
|
|
8139
|
+
return new _ZodTuple2({
|
|
8140
|
+
...this._def,
|
|
8141
|
+
rest
|
|
8142
|
+
});
|
|
8143
|
+
}
|
|
8144
|
+
};
|
|
8145
|
+
ZodTuple2.create = (schemas, params) => {
|
|
8146
|
+
if (!Array.isArray(schemas)) {
|
|
8147
|
+
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
8148
|
+
}
|
|
8149
|
+
return new ZodTuple2({
|
|
8150
|
+
items: schemas,
|
|
8151
|
+
typeName: ZodFirstPartyTypeKind2.ZodTuple,
|
|
8152
|
+
rest: null,
|
|
8153
|
+
...processCreateParams2(params)
|
|
8154
|
+
});
|
|
8155
|
+
};
|
|
8156
|
+
var ZodRecord2 = class _ZodRecord2 extends ZodType2 {
|
|
8157
|
+
get keySchema() {
|
|
8158
|
+
return this._def.keyType;
|
|
8159
|
+
}
|
|
8160
|
+
get valueSchema() {
|
|
8161
|
+
return this._def.valueType;
|
|
8162
|
+
}
|
|
8163
|
+
_parse(input) {
|
|
8164
|
+
const { status, ctx } = this._processInputParams(input);
|
|
8165
|
+
if (ctx.parsedType !== ZodParsedType2.object) {
|
|
8166
|
+
addIssueToContext2(ctx, {
|
|
8167
|
+
code: ZodIssueCode2.invalid_type,
|
|
8168
|
+
expected: ZodParsedType2.object,
|
|
8169
|
+
received: ctx.parsedType
|
|
8170
|
+
});
|
|
8171
|
+
return INVALID2;
|
|
8172
|
+
}
|
|
8173
|
+
const pairs = [];
|
|
8174
|
+
const keyType = this._def.keyType;
|
|
8175
|
+
const valueType = this._def.valueType;
|
|
8176
|
+
for (const key in ctx.data) {
|
|
8177
|
+
pairs.push({
|
|
8178
|
+
key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, key)),
|
|
8179
|
+
value: valueType._parse(new ParseInputLazyPath2(ctx, ctx.data[key], ctx.path, key)),
|
|
8180
|
+
alwaysSet: key in ctx.data
|
|
8181
|
+
});
|
|
8182
|
+
}
|
|
8183
|
+
if (ctx.common.async) {
|
|
8184
|
+
return ParseStatus2.mergeObjectAsync(status, pairs);
|
|
8185
|
+
} else {
|
|
8186
|
+
return ParseStatus2.mergeObjectSync(status, pairs);
|
|
8187
|
+
}
|
|
8188
|
+
}
|
|
8189
|
+
get element() {
|
|
8190
|
+
return this._def.valueType;
|
|
8191
|
+
}
|
|
8192
|
+
static create(first, second, third) {
|
|
8193
|
+
if (second instanceof ZodType2) {
|
|
8194
|
+
return new _ZodRecord2({
|
|
8195
|
+
keyType: first,
|
|
8196
|
+
valueType: second,
|
|
8197
|
+
typeName: ZodFirstPartyTypeKind2.ZodRecord,
|
|
8198
|
+
...processCreateParams2(third)
|
|
8199
|
+
});
|
|
8200
|
+
}
|
|
8201
|
+
return new _ZodRecord2({
|
|
8202
|
+
keyType: ZodString2.create(),
|
|
8203
|
+
valueType: first,
|
|
8204
|
+
typeName: ZodFirstPartyTypeKind2.ZodRecord,
|
|
8205
|
+
...processCreateParams2(second)
|
|
8206
|
+
});
|
|
8207
|
+
}
|
|
8208
|
+
};
|
|
8209
|
+
var ZodMap2 = class extends ZodType2 {
|
|
8210
|
+
get keySchema() {
|
|
8211
|
+
return this._def.keyType;
|
|
8212
|
+
}
|
|
8213
|
+
get valueSchema() {
|
|
8214
|
+
return this._def.valueType;
|
|
8215
|
+
}
|
|
8216
|
+
_parse(input) {
|
|
8217
|
+
const { status, ctx } = this._processInputParams(input);
|
|
8218
|
+
if (ctx.parsedType !== ZodParsedType2.map) {
|
|
8219
|
+
addIssueToContext2(ctx, {
|
|
8220
|
+
code: ZodIssueCode2.invalid_type,
|
|
8221
|
+
expected: ZodParsedType2.map,
|
|
8222
|
+
received: ctx.parsedType
|
|
8223
|
+
});
|
|
8224
|
+
return INVALID2;
|
|
8225
|
+
}
|
|
8226
|
+
const keyType = this._def.keyType;
|
|
8227
|
+
const valueType = this._def.valueType;
|
|
8228
|
+
const pairs = [...ctx.data.entries()].map(([key, value], index) => {
|
|
8229
|
+
return {
|
|
8230
|
+
key: keyType._parse(new ParseInputLazyPath2(ctx, key, ctx.path, [index, "key"])),
|
|
8231
|
+
value: valueType._parse(new ParseInputLazyPath2(ctx, value, ctx.path, [index, "value"]))
|
|
8232
|
+
};
|
|
8233
|
+
});
|
|
8234
|
+
if (ctx.common.async) {
|
|
8235
|
+
const finalMap = /* @__PURE__ */ new Map();
|
|
8236
|
+
return Promise.resolve().then(async () => {
|
|
8237
|
+
for (const pair of pairs) {
|
|
8238
|
+
const key = await pair.key;
|
|
8239
|
+
const value = await pair.value;
|
|
8240
|
+
if (key.status === "aborted" || value.status === "aborted") {
|
|
8241
|
+
return INVALID2;
|
|
8242
|
+
}
|
|
8243
|
+
if (key.status === "dirty" || value.status === "dirty") {
|
|
8244
|
+
status.dirty();
|
|
8245
|
+
}
|
|
8246
|
+
finalMap.set(key.value, value.value);
|
|
8247
|
+
}
|
|
8248
|
+
return { status: status.value, value: finalMap };
|
|
8249
|
+
});
|
|
8250
|
+
} else {
|
|
8251
|
+
const finalMap = /* @__PURE__ */ new Map();
|
|
8252
|
+
for (const pair of pairs) {
|
|
8253
|
+
const key = pair.key;
|
|
8254
|
+
const value = pair.value;
|
|
8255
|
+
if (key.status === "aborted" || value.status === "aborted") {
|
|
8256
|
+
return INVALID2;
|
|
8257
|
+
}
|
|
8258
|
+
if (key.status === "dirty" || value.status === "dirty") {
|
|
8259
|
+
status.dirty();
|
|
8260
|
+
}
|
|
8261
|
+
finalMap.set(key.value, value.value);
|
|
8262
|
+
}
|
|
8263
|
+
return { status: status.value, value: finalMap };
|
|
8264
|
+
}
|
|
8265
|
+
}
|
|
8266
|
+
};
|
|
8267
|
+
ZodMap2.create = (keyType, valueType, params) => {
|
|
8268
|
+
return new ZodMap2({
|
|
8269
|
+
valueType,
|
|
8270
|
+
keyType,
|
|
8271
|
+
typeName: ZodFirstPartyTypeKind2.ZodMap,
|
|
8272
|
+
...processCreateParams2(params)
|
|
8273
|
+
});
|
|
8274
|
+
};
|
|
8275
|
+
var ZodSet2 = class _ZodSet2 extends ZodType2 {
|
|
8276
|
+
_parse(input) {
|
|
8277
|
+
const { status, ctx } = this._processInputParams(input);
|
|
8278
|
+
if (ctx.parsedType !== ZodParsedType2.set) {
|
|
8279
|
+
addIssueToContext2(ctx, {
|
|
8280
|
+
code: ZodIssueCode2.invalid_type,
|
|
8281
|
+
expected: ZodParsedType2.set,
|
|
8282
|
+
received: ctx.parsedType
|
|
8283
|
+
});
|
|
8284
|
+
return INVALID2;
|
|
8285
|
+
}
|
|
8286
|
+
const def = this._def;
|
|
8287
|
+
if (def.minSize !== null) {
|
|
8288
|
+
if (ctx.data.size < def.minSize.value) {
|
|
8289
|
+
addIssueToContext2(ctx, {
|
|
8290
|
+
code: ZodIssueCode2.too_small,
|
|
8291
|
+
minimum: def.minSize.value,
|
|
8292
|
+
type: "set",
|
|
8293
|
+
inclusive: true,
|
|
8294
|
+
exact: false,
|
|
8295
|
+
message: def.minSize.message
|
|
8296
|
+
});
|
|
8297
|
+
status.dirty();
|
|
8298
|
+
}
|
|
8299
|
+
}
|
|
8300
|
+
if (def.maxSize !== null) {
|
|
8301
|
+
if (ctx.data.size > def.maxSize.value) {
|
|
8302
|
+
addIssueToContext2(ctx, {
|
|
8303
|
+
code: ZodIssueCode2.too_big,
|
|
8304
|
+
maximum: def.maxSize.value,
|
|
8305
|
+
type: "set",
|
|
8306
|
+
inclusive: true,
|
|
8307
|
+
exact: false,
|
|
8308
|
+
message: def.maxSize.message
|
|
8309
|
+
});
|
|
8310
|
+
status.dirty();
|
|
8311
|
+
}
|
|
8312
|
+
}
|
|
8313
|
+
const valueType = this._def.valueType;
|
|
8314
|
+
function finalizeSet(elements2) {
|
|
8315
|
+
const parsedSet = /* @__PURE__ */ new Set();
|
|
8316
|
+
for (const element of elements2) {
|
|
8317
|
+
if (element.status === "aborted")
|
|
8318
|
+
return INVALID2;
|
|
8319
|
+
if (element.status === "dirty")
|
|
8320
|
+
status.dirty();
|
|
8321
|
+
parsedSet.add(element.value);
|
|
8322
|
+
}
|
|
8323
|
+
return { status: status.value, value: parsedSet };
|
|
8324
|
+
}
|
|
8325
|
+
const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath2(ctx, item, ctx.path, i)));
|
|
8326
|
+
if (ctx.common.async) {
|
|
8327
|
+
return Promise.all(elements).then((elements2) => finalizeSet(elements2));
|
|
8328
|
+
} else {
|
|
8329
|
+
return finalizeSet(elements);
|
|
8330
|
+
}
|
|
8331
|
+
}
|
|
8332
|
+
min(minSize, message) {
|
|
8333
|
+
return new _ZodSet2({
|
|
8334
|
+
...this._def,
|
|
8335
|
+
minSize: { value: minSize, message: errorUtil2.toString(message) }
|
|
8336
|
+
});
|
|
8337
|
+
}
|
|
8338
|
+
max(maxSize, message) {
|
|
8339
|
+
return new _ZodSet2({
|
|
8340
|
+
...this._def,
|
|
8341
|
+
maxSize: { value: maxSize, message: errorUtil2.toString(message) }
|
|
8342
|
+
});
|
|
8343
|
+
}
|
|
8344
|
+
size(size, message) {
|
|
8345
|
+
return this.min(size, message).max(size, message);
|
|
8346
|
+
}
|
|
8347
|
+
nonempty(message) {
|
|
8348
|
+
return this.min(1, message);
|
|
8349
|
+
}
|
|
8350
|
+
};
|
|
8351
|
+
ZodSet2.create = (valueType, params) => {
|
|
8352
|
+
return new ZodSet2({
|
|
8353
|
+
valueType,
|
|
8354
|
+
minSize: null,
|
|
8355
|
+
maxSize: null,
|
|
8356
|
+
typeName: ZodFirstPartyTypeKind2.ZodSet,
|
|
8357
|
+
...processCreateParams2(params)
|
|
8358
|
+
});
|
|
8359
|
+
};
|
|
8360
|
+
var ZodFunction2 = class _ZodFunction2 extends ZodType2 {
|
|
8361
|
+
constructor() {
|
|
8362
|
+
super(...arguments);
|
|
8363
|
+
this.validate = this.implement;
|
|
8364
|
+
}
|
|
8365
|
+
_parse(input) {
|
|
8366
|
+
const { ctx } = this._processInputParams(input);
|
|
8367
|
+
if (ctx.parsedType !== ZodParsedType2.function) {
|
|
8368
|
+
addIssueToContext2(ctx, {
|
|
8369
|
+
code: ZodIssueCode2.invalid_type,
|
|
8370
|
+
expected: ZodParsedType2.function,
|
|
8371
|
+
received: ctx.parsedType
|
|
8372
|
+
});
|
|
8373
|
+
return INVALID2;
|
|
8374
|
+
}
|
|
8375
|
+
function makeArgsIssue(args, error) {
|
|
8376
|
+
return makeIssue2({
|
|
8377
|
+
data: args,
|
|
8378
|
+
path: ctx.path,
|
|
8379
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap2(), en_default2].filter((x) => !!x),
|
|
8380
|
+
issueData: {
|
|
8381
|
+
code: ZodIssueCode2.invalid_arguments,
|
|
8382
|
+
argumentsError: error
|
|
8383
|
+
}
|
|
8384
|
+
});
|
|
8385
|
+
}
|
|
8386
|
+
function makeReturnsIssue(returns, error) {
|
|
8387
|
+
return makeIssue2({
|
|
8388
|
+
data: returns,
|
|
8389
|
+
path: ctx.path,
|
|
8390
|
+
errorMaps: [ctx.common.contextualErrorMap, ctx.schemaErrorMap, getErrorMap2(), en_default2].filter((x) => !!x),
|
|
8391
|
+
issueData: {
|
|
8392
|
+
code: ZodIssueCode2.invalid_return_type,
|
|
8393
|
+
returnTypeError: error
|
|
8394
|
+
}
|
|
8395
|
+
});
|
|
8396
|
+
}
|
|
8397
|
+
const params = { errorMap: ctx.common.contextualErrorMap };
|
|
8398
|
+
const fn = ctx.data;
|
|
8399
|
+
if (this._def.returns instanceof ZodPromise2) {
|
|
8400
|
+
const me = this;
|
|
8401
|
+
return OK2(async function(...args) {
|
|
8402
|
+
const error = new ZodError2([]);
|
|
8403
|
+
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
8404
|
+
error.addIssue(makeArgsIssue(args, e));
|
|
8405
|
+
throw error;
|
|
8406
|
+
});
|
|
8407
|
+
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
8408
|
+
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
8409
|
+
error.addIssue(makeReturnsIssue(result, e));
|
|
8410
|
+
throw error;
|
|
8411
|
+
});
|
|
8412
|
+
return parsedReturns;
|
|
8413
|
+
});
|
|
8414
|
+
} else {
|
|
8415
|
+
const me = this;
|
|
8416
|
+
return OK2(function(...args) {
|
|
8417
|
+
const parsedArgs = me._def.args.safeParse(args, params);
|
|
8418
|
+
if (!parsedArgs.success) {
|
|
8419
|
+
throw new ZodError2([makeArgsIssue(args, parsedArgs.error)]);
|
|
8420
|
+
}
|
|
8421
|
+
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
8422
|
+
const parsedReturns = me._def.returns.safeParse(result, params);
|
|
8423
|
+
if (!parsedReturns.success) {
|
|
8424
|
+
throw new ZodError2([makeReturnsIssue(result, parsedReturns.error)]);
|
|
8425
|
+
}
|
|
8426
|
+
return parsedReturns.data;
|
|
8427
|
+
});
|
|
8428
|
+
}
|
|
8429
|
+
}
|
|
8430
|
+
parameters() {
|
|
8431
|
+
return this._def.args;
|
|
8432
|
+
}
|
|
8433
|
+
returnType() {
|
|
8434
|
+
return this._def.returns;
|
|
8435
|
+
}
|
|
8436
|
+
args(...items) {
|
|
8437
|
+
return new _ZodFunction2({
|
|
8438
|
+
...this._def,
|
|
8439
|
+
args: ZodTuple2.create(items).rest(ZodUnknown2.create())
|
|
8440
|
+
});
|
|
8441
|
+
}
|
|
8442
|
+
returns(returnType) {
|
|
8443
|
+
return new _ZodFunction2({
|
|
8444
|
+
...this._def,
|
|
8445
|
+
returns: returnType
|
|
8446
|
+
});
|
|
8447
|
+
}
|
|
8448
|
+
implement(func) {
|
|
8449
|
+
const validatedFunc = this.parse(func);
|
|
8450
|
+
return validatedFunc;
|
|
8451
|
+
}
|
|
8452
|
+
strictImplement(func) {
|
|
8453
|
+
const validatedFunc = this.parse(func);
|
|
8454
|
+
return validatedFunc;
|
|
8455
|
+
}
|
|
8456
|
+
static create(args, returns, params) {
|
|
8457
|
+
return new _ZodFunction2({
|
|
8458
|
+
args: args ? args : ZodTuple2.create([]).rest(ZodUnknown2.create()),
|
|
8459
|
+
returns: returns || ZodUnknown2.create(),
|
|
8460
|
+
typeName: ZodFirstPartyTypeKind2.ZodFunction,
|
|
8461
|
+
...processCreateParams2(params)
|
|
8462
|
+
});
|
|
8463
|
+
}
|
|
8464
|
+
};
|
|
8465
|
+
var ZodLazy2 = class extends ZodType2 {
|
|
8466
|
+
get schema() {
|
|
8467
|
+
return this._def.getter();
|
|
8468
|
+
}
|
|
8469
|
+
_parse(input) {
|
|
8470
|
+
const { ctx } = this._processInputParams(input);
|
|
8471
|
+
const lazySchema = this._def.getter();
|
|
8472
|
+
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
|
8473
|
+
}
|
|
8474
|
+
};
|
|
8475
|
+
ZodLazy2.create = (getter, params) => {
|
|
8476
|
+
return new ZodLazy2({
|
|
8477
|
+
getter,
|
|
8478
|
+
typeName: ZodFirstPartyTypeKind2.ZodLazy,
|
|
8479
|
+
...processCreateParams2(params)
|
|
8480
|
+
});
|
|
8481
|
+
};
|
|
8482
|
+
var ZodLiteral2 = class extends ZodType2 {
|
|
8483
|
+
_parse(input) {
|
|
8484
|
+
if (input.data !== this._def.value) {
|
|
8485
|
+
const ctx = this._getOrReturnCtx(input);
|
|
8486
|
+
addIssueToContext2(ctx, {
|
|
8487
|
+
received: ctx.data,
|
|
8488
|
+
code: ZodIssueCode2.invalid_literal,
|
|
8489
|
+
expected: this._def.value
|
|
8490
|
+
});
|
|
8491
|
+
return INVALID2;
|
|
8492
|
+
}
|
|
8493
|
+
return { status: "valid", value: input.data };
|
|
8494
|
+
}
|
|
8495
|
+
get value() {
|
|
8496
|
+
return this._def.value;
|
|
8497
|
+
}
|
|
8498
|
+
};
|
|
8499
|
+
ZodLiteral2.create = (value, params) => {
|
|
8500
|
+
return new ZodLiteral2({
|
|
8501
|
+
value,
|
|
8502
|
+
typeName: ZodFirstPartyTypeKind2.ZodLiteral,
|
|
8503
|
+
...processCreateParams2(params)
|
|
8504
|
+
});
|
|
8505
|
+
};
|
|
8506
|
+
function createZodEnum2(values, params) {
|
|
8507
|
+
return new ZodEnum2({
|
|
8508
|
+
values,
|
|
8509
|
+
typeName: ZodFirstPartyTypeKind2.ZodEnum,
|
|
8510
|
+
...processCreateParams2(params)
|
|
8511
|
+
});
|
|
8512
|
+
}
|
|
8513
|
+
var ZodEnum2 = class _ZodEnum2 extends ZodType2 {
|
|
8514
|
+
_parse(input) {
|
|
8515
|
+
if (typeof input.data !== "string") {
|
|
8516
|
+
const ctx = this._getOrReturnCtx(input);
|
|
8517
|
+
const expectedValues = this._def.values;
|
|
8518
|
+
addIssueToContext2(ctx, {
|
|
8519
|
+
expected: util2.joinValues(expectedValues),
|
|
8520
|
+
received: ctx.parsedType,
|
|
8521
|
+
code: ZodIssueCode2.invalid_type
|
|
8522
|
+
});
|
|
8523
|
+
return INVALID2;
|
|
8524
|
+
}
|
|
8525
|
+
if (!this._cache) {
|
|
8526
|
+
this._cache = new Set(this._def.values);
|
|
8527
|
+
}
|
|
8528
|
+
if (!this._cache.has(input.data)) {
|
|
8529
|
+
const ctx = this._getOrReturnCtx(input);
|
|
8530
|
+
const expectedValues = this._def.values;
|
|
8531
|
+
addIssueToContext2(ctx, {
|
|
8532
|
+
received: ctx.data,
|
|
8533
|
+
code: ZodIssueCode2.invalid_enum_value,
|
|
8534
|
+
options: expectedValues
|
|
8535
|
+
});
|
|
8536
|
+
return INVALID2;
|
|
8537
|
+
}
|
|
8538
|
+
return OK2(input.data);
|
|
8539
|
+
}
|
|
8540
|
+
get options() {
|
|
8541
|
+
return this._def.values;
|
|
8542
|
+
}
|
|
8543
|
+
get enum() {
|
|
8544
|
+
const enumValues = {};
|
|
8545
|
+
for (const val of this._def.values) {
|
|
8546
|
+
enumValues[val] = val;
|
|
8547
|
+
}
|
|
8548
|
+
return enumValues;
|
|
8549
|
+
}
|
|
8550
|
+
get Values() {
|
|
8551
|
+
const enumValues = {};
|
|
8552
|
+
for (const val of this._def.values) {
|
|
8553
|
+
enumValues[val] = val;
|
|
8554
|
+
}
|
|
8555
|
+
return enumValues;
|
|
8556
|
+
}
|
|
8557
|
+
get Enum() {
|
|
8558
|
+
const enumValues = {};
|
|
8559
|
+
for (const val of this._def.values) {
|
|
8560
|
+
enumValues[val] = val;
|
|
8561
|
+
}
|
|
8562
|
+
return enumValues;
|
|
8563
|
+
}
|
|
8564
|
+
extract(values, newDef = this._def) {
|
|
8565
|
+
return _ZodEnum2.create(values, {
|
|
8566
|
+
...this._def,
|
|
8567
|
+
...newDef
|
|
8568
|
+
});
|
|
8569
|
+
}
|
|
8570
|
+
exclude(values, newDef = this._def) {
|
|
8571
|
+
return _ZodEnum2.create(this.options.filter((opt) => !values.includes(opt)), {
|
|
8572
|
+
...this._def,
|
|
8573
|
+
...newDef
|
|
8574
|
+
});
|
|
8575
|
+
}
|
|
8576
|
+
};
|
|
8577
|
+
ZodEnum2.create = createZodEnum2;
|
|
8578
|
+
var ZodNativeEnum2 = class extends ZodType2 {
|
|
8579
|
+
_parse(input) {
|
|
8580
|
+
const nativeEnumValues = util2.getValidEnumValues(this._def.values);
|
|
8581
|
+
const ctx = this._getOrReturnCtx(input);
|
|
8582
|
+
if (ctx.parsedType !== ZodParsedType2.string && ctx.parsedType !== ZodParsedType2.number) {
|
|
8583
|
+
const expectedValues = util2.objectValues(nativeEnumValues);
|
|
8584
|
+
addIssueToContext2(ctx, {
|
|
8585
|
+
expected: util2.joinValues(expectedValues),
|
|
8586
|
+
received: ctx.parsedType,
|
|
8587
|
+
code: ZodIssueCode2.invalid_type
|
|
8588
|
+
});
|
|
8589
|
+
return INVALID2;
|
|
8590
|
+
}
|
|
8591
|
+
if (!this._cache) {
|
|
8592
|
+
this._cache = new Set(util2.getValidEnumValues(this._def.values));
|
|
8593
|
+
}
|
|
8594
|
+
if (!this._cache.has(input.data)) {
|
|
8595
|
+
const expectedValues = util2.objectValues(nativeEnumValues);
|
|
8596
|
+
addIssueToContext2(ctx, {
|
|
8597
|
+
received: ctx.data,
|
|
8598
|
+
code: ZodIssueCode2.invalid_enum_value,
|
|
8599
|
+
options: expectedValues
|
|
8600
|
+
});
|
|
8601
|
+
return INVALID2;
|
|
8602
|
+
}
|
|
8603
|
+
return OK2(input.data);
|
|
8604
|
+
}
|
|
8605
|
+
get enum() {
|
|
8606
|
+
return this._def.values;
|
|
8607
|
+
}
|
|
8608
|
+
};
|
|
8609
|
+
ZodNativeEnum2.create = (values, params) => {
|
|
8610
|
+
return new ZodNativeEnum2({
|
|
8611
|
+
values,
|
|
8612
|
+
typeName: ZodFirstPartyTypeKind2.ZodNativeEnum,
|
|
8613
|
+
...processCreateParams2(params)
|
|
8614
|
+
});
|
|
8615
|
+
};
|
|
8616
|
+
var ZodPromise2 = class extends ZodType2 {
|
|
8617
|
+
unwrap() {
|
|
8618
|
+
return this._def.type;
|
|
8619
|
+
}
|
|
8620
|
+
_parse(input) {
|
|
8621
|
+
const { ctx } = this._processInputParams(input);
|
|
8622
|
+
if (ctx.parsedType !== ZodParsedType2.promise && ctx.common.async === false) {
|
|
8623
|
+
addIssueToContext2(ctx, {
|
|
8624
|
+
code: ZodIssueCode2.invalid_type,
|
|
8625
|
+
expected: ZodParsedType2.promise,
|
|
8626
|
+
received: ctx.parsedType
|
|
8627
|
+
});
|
|
8628
|
+
return INVALID2;
|
|
8629
|
+
}
|
|
8630
|
+
const promisified = ctx.parsedType === ZodParsedType2.promise ? ctx.data : Promise.resolve(ctx.data);
|
|
8631
|
+
return OK2(promisified.then((data) => {
|
|
8632
|
+
return this._def.type.parseAsync(data, {
|
|
8633
|
+
path: ctx.path,
|
|
8634
|
+
errorMap: ctx.common.contextualErrorMap
|
|
8635
|
+
});
|
|
8636
|
+
}));
|
|
8637
|
+
}
|
|
8638
|
+
};
|
|
8639
|
+
ZodPromise2.create = (schema, params) => {
|
|
8640
|
+
return new ZodPromise2({
|
|
8641
|
+
type: schema,
|
|
8642
|
+
typeName: ZodFirstPartyTypeKind2.ZodPromise,
|
|
8643
|
+
...processCreateParams2(params)
|
|
8644
|
+
});
|
|
8645
|
+
};
|
|
8646
|
+
var ZodEffects2 = class extends ZodType2 {
|
|
8647
|
+
innerType() {
|
|
8648
|
+
return this._def.schema;
|
|
8649
|
+
}
|
|
8650
|
+
sourceType() {
|
|
8651
|
+
return this._def.schema._def.typeName === ZodFirstPartyTypeKind2.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
8652
|
+
}
|
|
8653
|
+
_parse(input) {
|
|
8654
|
+
const { status, ctx } = this._processInputParams(input);
|
|
8655
|
+
const effect = this._def.effect || null;
|
|
8656
|
+
const checkCtx = {
|
|
8657
|
+
addIssue: (arg) => {
|
|
8658
|
+
addIssueToContext2(ctx, arg);
|
|
8659
|
+
if (arg.fatal) {
|
|
8660
|
+
status.abort();
|
|
8661
|
+
} else {
|
|
8662
|
+
status.dirty();
|
|
8663
|
+
}
|
|
8664
|
+
},
|
|
8665
|
+
get path() {
|
|
8666
|
+
return ctx.path;
|
|
8667
|
+
}
|
|
8668
|
+
};
|
|
8669
|
+
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
|
8670
|
+
if (effect.type === "preprocess") {
|
|
8671
|
+
const processed = effect.transform(ctx.data, checkCtx);
|
|
8672
|
+
if (ctx.common.async) {
|
|
8673
|
+
return Promise.resolve(processed).then(async (processed2) => {
|
|
8674
|
+
if (status.value === "aborted")
|
|
8675
|
+
return INVALID2;
|
|
8676
|
+
const result = await this._def.schema._parseAsync({
|
|
8677
|
+
data: processed2,
|
|
8678
|
+
path: ctx.path,
|
|
8679
|
+
parent: ctx
|
|
8680
|
+
});
|
|
8681
|
+
if (result.status === "aborted")
|
|
8682
|
+
return INVALID2;
|
|
8683
|
+
if (result.status === "dirty")
|
|
8684
|
+
return DIRTY2(result.value);
|
|
8685
|
+
if (status.value === "dirty")
|
|
8686
|
+
return DIRTY2(result.value);
|
|
8687
|
+
return result;
|
|
8688
|
+
});
|
|
8689
|
+
} else {
|
|
8690
|
+
if (status.value === "aborted")
|
|
8691
|
+
return INVALID2;
|
|
8692
|
+
const result = this._def.schema._parseSync({
|
|
8693
|
+
data: processed,
|
|
8694
|
+
path: ctx.path,
|
|
8695
|
+
parent: ctx
|
|
8696
|
+
});
|
|
8697
|
+
if (result.status === "aborted")
|
|
8698
|
+
return INVALID2;
|
|
8699
|
+
if (result.status === "dirty")
|
|
8700
|
+
return DIRTY2(result.value);
|
|
8701
|
+
if (status.value === "dirty")
|
|
8702
|
+
return DIRTY2(result.value);
|
|
8703
|
+
return result;
|
|
8704
|
+
}
|
|
8705
|
+
}
|
|
8706
|
+
if (effect.type === "refinement") {
|
|
8707
|
+
const executeRefinement = (acc) => {
|
|
8708
|
+
const result = effect.refinement(acc, checkCtx);
|
|
8709
|
+
if (ctx.common.async) {
|
|
8710
|
+
return Promise.resolve(result);
|
|
8711
|
+
}
|
|
8712
|
+
if (result instanceof Promise) {
|
|
8713
|
+
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
8714
|
+
}
|
|
8715
|
+
return acc;
|
|
8716
|
+
};
|
|
8717
|
+
if (ctx.common.async === false) {
|
|
8718
|
+
const inner = this._def.schema._parseSync({
|
|
8719
|
+
data: ctx.data,
|
|
8720
|
+
path: ctx.path,
|
|
8721
|
+
parent: ctx
|
|
8722
|
+
});
|
|
8723
|
+
if (inner.status === "aborted")
|
|
8724
|
+
return INVALID2;
|
|
8725
|
+
if (inner.status === "dirty")
|
|
8726
|
+
status.dirty();
|
|
8727
|
+
executeRefinement(inner.value);
|
|
8728
|
+
return { status: status.value, value: inner.value };
|
|
8729
|
+
} else {
|
|
8730
|
+
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
|
|
8731
|
+
if (inner.status === "aborted")
|
|
8732
|
+
return INVALID2;
|
|
8733
|
+
if (inner.status === "dirty")
|
|
8734
|
+
status.dirty();
|
|
8735
|
+
return executeRefinement(inner.value).then(() => {
|
|
8736
|
+
return { status: status.value, value: inner.value };
|
|
8737
|
+
});
|
|
8738
|
+
});
|
|
8739
|
+
}
|
|
8740
|
+
}
|
|
8741
|
+
if (effect.type === "transform") {
|
|
8742
|
+
if (ctx.common.async === false) {
|
|
8743
|
+
const base = this._def.schema._parseSync({
|
|
8744
|
+
data: ctx.data,
|
|
8745
|
+
path: ctx.path,
|
|
8746
|
+
parent: ctx
|
|
8747
|
+
});
|
|
8748
|
+
if (!isValid2(base))
|
|
8749
|
+
return INVALID2;
|
|
8750
|
+
const result = effect.transform(base.value, checkCtx);
|
|
8751
|
+
if (result instanceof Promise) {
|
|
8752
|
+
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
8753
|
+
}
|
|
8754
|
+
return { status: status.value, value: result };
|
|
8755
|
+
} else {
|
|
8756
|
+
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
|
|
8757
|
+
if (!isValid2(base))
|
|
8758
|
+
return INVALID2;
|
|
8759
|
+
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
8760
|
+
status: status.value,
|
|
8761
|
+
value: result
|
|
8762
|
+
}));
|
|
8763
|
+
});
|
|
8764
|
+
}
|
|
8765
|
+
}
|
|
8766
|
+
util2.assertNever(effect);
|
|
8767
|
+
}
|
|
8768
|
+
};
|
|
8769
|
+
ZodEffects2.create = (schema, effect, params) => {
|
|
8770
|
+
return new ZodEffects2({
|
|
8771
|
+
schema,
|
|
8772
|
+
typeName: ZodFirstPartyTypeKind2.ZodEffects,
|
|
8773
|
+
effect,
|
|
8774
|
+
...processCreateParams2(params)
|
|
8775
|
+
});
|
|
8776
|
+
};
|
|
8777
|
+
ZodEffects2.createWithPreprocess = (preprocess, schema, params) => {
|
|
8778
|
+
return new ZodEffects2({
|
|
8779
|
+
schema,
|
|
8780
|
+
effect: { type: "preprocess", transform: preprocess },
|
|
8781
|
+
typeName: ZodFirstPartyTypeKind2.ZodEffects,
|
|
8782
|
+
...processCreateParams2(params)
|
|
8783
|
+
});
|
|
8784
|
+
};
|
|
8785
|
+
var ZodOptional2 = class extends ZodType2 {
|
|
8786
|
+
_parse(input) {
|
|
8787
|
+
const parsedType = this._getType(input);
|
|
8788
|
+
if (parsedType === ZodParsedType2.undefined) {
|
|
8789
|
+
return OK2(void 0);
|
|
8790
|
+
}
|
|
8791
|
+
return this._def.innerType._parse(input);
|
|
8792
|
+
}
|
|
8793
|
+
unwrap() {
|
|
8794
|
+
return this._def.innerType;
|
|
8795
|
+
}
|
|
8796
|
+
};
|
|
8797
|
+
ZodOptional2.create = (type, params) => {
|
|
8798
|
+
return new ZodOptional2({
|
|
8799
|
+
innerType: type,
|
|
8800
|
+
typeName: ZodFirstPartyTypeKind2.ZodOptional,
|
|
8801
|
+
...processCreateParams2(params)
|
|
8802
|
+
});
|
|
8803
|
+
};
|
|
8804
|
+
var ZodNullable2 = class extends ZodType2 {
|
|
8805
|
+
_parse(input) {
|
|
8806
|
+
const parsedType = this._getType(input);
|
|
8807
|
+
if (parsedType === ZodParsedType2.null) {
|
|
8808
|
+
return OK2(null);
|
|
8809
|
+
}
|
|
8810
|
+
return this._def.innerType._parse(input);
|
|
8811
|
+
}
|
|
8812
|
+
unwrap() {
|
|
8813
|
+
return this._def.innerType;
|
|
8814
|
+
}
|
|
8815
|
+
};
|
|
8816
|
+
ZodNullable2.create = (type, params) => {
|
|
8817
|
+
return new ZodNullable2({
|
|
8818
|
+
innerType: type,
|
|
8819
|
+
typeName: ZodFirstPartyTypeKind2.ZodNullable,
|
|
8820
|
+
...processCreateParams2(params)
|
|
8821
|
+
});
|
|
8822
|
+
};
|
|
8823
|
+
var ZodDefault2 = class extends ZodType2 {
|
|
8824
|
+
_parse(input) {
|
|
8825
|
+
const { ctx } = this._processInputParams(input);
|
|
8826
|
+
let data = ctx.data;
|
|
8827
|
+
if (ctx.parsedType === ZodParsedType2.undefined) {
|
|
8828
|
+
data = this._def.defaultValue();
|
|
8829
|
+
}
|
|
8830
|
+
return this._def.innerType._parse({
|
|
8831
|
+
data,
|
|
8832
|
+
path: ctx.path,
|
|
8833
|
+
parent: ctx
|
|
8834
|
+
});
|
|
8835
|
+
}
|
|
8836
|
+
removeDefault() {
|
|
8837
|
+
return this._def.innerType;
|
|
8838
|
+
}
|
|
8839
|
+
};
|
|
8840
|
+
ZodDefault2.create = (type, params) => {
|
|
8841
|
+
return new ZodDefault2({
|
|
8842
|
+
innerType: type,
|
|
8843
|
+
typeName: ZodFirstPartyTypeKind2.ZodDefault,
|
|
8844
|
+
defaultValue: typeof params.default === "function" ? params.default : () => params.default,
|
|
8845
|
+
...processCreateParams2(params)
|
|
8846
|
+
});
|
|
8847
|
+
};
|
|
8848
|
+
var ZodCatch2 = class extends ZodType2 {
|
|
8849
|
+
_parse(input) {
|
|
8850
|
+
const { ctx } = this._processInputParams(input);
|
|
8851
|
+
const newCtx = {
|
|
8852
|
+
...ctx,
|
|
8853
|
+
common: {
|
|
8854
|
+
...ctx.common,
|
|
8855
|
+
issues: []
|
|
8856
|
+
}
|
|
8857
|
+
};
|
|
8858
|
+
const result = this._def.innerType._parse({
|
|
8859
|
+
data: newCtx.data,
|
|
8860
|
+
path: newCtx.path,
|
|
8861
|
+
parent: {
|
|
8862
|
+
...newCtx
|
|
8863
|
+
}
|
|
8864
|
+
});
|
|
8865
|
+
if (isAsync2(result)) {
|
|
8866
|
+
return result.then((result2) => {
|
|
8867
|
+
return {
|
|
8868
|
+
status: "valid",
|
|
8869
|
+
value: result2.status === "valid" ? result2.value : this._def.catchValue({
|
|
8870
|
+
get error() {
|
|
8871
|
+
return new ZodError2(newCtx.common.issues);
|
|
8872
|
+
},
|
|
8873
|
+
input: newCtx.data
|
|
8874
|
+
})
|
|
8875
|
+
};
|
|
8876
|
+
});
|
|
8877
|
+
} else {
|
|
8878
|
+
return {
|
|
8879
|
+
status: "valid",
|
|
8880
|
+
value: result.status === "valid" ? result.value : this._def.catchValue({
|
|
8881
|
+
get error() {
|
|
8882
|
+
return new ZodError2(newCtx.common.issues);
|
|
8883
|
+
},
|
|
8884
|
+
input: newCtx.data
|
|
8885
|
+
})
|
|
8886
|
+
};
|
|
8887
|
+
}
|
|
8888
|
+
}
|
|
8889
|
+
removeCatch() {
|
|
8890
|
+
return this._def.innerType;
|
|
8891
|
+
}
|
|
8892
|
+
};
|
|
8893
|
+
ZodCatch2.create = (type, params) => {
|
|
8894
|
+
return new ZodCatch2({
|
|
8895
|
+
innerType: type,
|
|
8896
|
+
typeName: ZodFirstPartyTypeKind2.ZodCatch,
|
|
8897
|
+
catchValue: typeof params.catch === "function" ? params.catch : () => params.catch,
|
|
8898
|
+
...processCreateParams2(params)
|
|
8899
|
+
});
|
|
8900
|
+
};
|
|
8901
|
+
var ZodNaN2 = class extends ZodType2 {
|
|
8902
|
+
_parse(input) {
|
|
8903
|
+
const parsedType = this._getType(input);
|
|
8904
|
+
if (parsedType !== ZodParsedType2.nan) {
|
|
8905
|
+
const ctx = this._getOrReturnCtx(input);
|
|
8906
|
+
addIssueToContext2(ctx, {
|
|
8907
|
+
code: ZodIssueCode2.invalid_type,
|
|
8908
|
+
expected: ZodParsedType2.nan,
|
|
8909
|
+
received: ctx.parsedType
|
|
8910
|
+
});
|
|
8911
|
+
return INVALID2;
|
|
8912
|
+
}
|
|
8913
|
+
return { status: "valid", value: input.data };
|
|
8914
|
+
}
|
|
8915
|
+
};
|
|
8916
|
+
ZodNaN2.create = (params) => {
|
|
8917
|
+
return new ZodNaN2({
|
|
8918
|
+
typeName: ZodFirstPartyTypeKind2.ZodNaN,
|
|
8919
|
+
...processCreateParams2(params)
|
|
8920
|
+
});
|
|
8921
|
+
};
|
|
8922
|
+
var BRAND2 = /* @__PURE__ */ Symbol("zod_brand");
|
|
8923
|
+
var ZodBranded2 = class extends ZodType2 {
|
|
8924
|
+
_parse(input) {
|
|
8925
|
+
const { ctx } = this._processInputParams(input);
|
|
8926
|
+
const data = ctx.data;
|
|
8927
|
+
return this._def.type._parse({
|
|
8928
|
+
data,
|
|
8929
|
+
path: ctx.path,
|
|
8930
|
+
parent: ctx
|
|
8931
|
+
});
|
|
8932
|
+
}
|
|
8933
|
+
unwrap() {
|
|
8934
|
+
return this._def.type;
|
|
8935
|
+
}
|
|
8936
|
+
};
|
|
8937
|
+
var ZodPipeline2 = class _ZodPipeline2 extends ZodType2 {
|
|
8938
|
+
_parse(input) {
|
|
8939
|
+
const { status, ctx } = this._processInputParams(input);
|
|
8940
|
+
if (ctx.common.async) {
|
|
8941
|
+
const handleAsync = async () => {
|
|
8942
|
+
const inResult = await this._def.in._parseAsync({
|
|
8943
|
+
data: ctx.data,
|
|
8944
|
+
path: ctx.path,
|
|
8945
|
+
parent: ctx
|
|
8946
|
+
});
|
|
8947
|
+
if (inResult.status === "aborted")
|
|
8948
|
+
return INVALID2;
|
|
8949
|
+
if (inResult.status === "dirty") {
|
|
8950
|
+
status.dirty();
|
|
8951
|
+
return DIRTY2(inResult.value);
|
|
8952
|
+
} else {
|
|
8953
|
+
return this._def.out._parseAsync({
|
|
8954
|
+
data: inResult.value,
|
|
8955
|
+
path: ctx.path,
|
|
8956
|
+
parent: ctx
|
|
8957
|
+
});
|
|
8958
|
+
}
|
|
8959
|
+
};
|
|
8960
|
+
return handleAsync();
|
|
8961
|
+
} else {
|
|
8962
|
+
const inResult = this._def.in._parseSync({
|
|
8963
|
+
data: ctx.data,
|
|
8964
|
+
path: ctx.path,
|
|
8965
|
+
parent: ctx
|
|
8966
|
+
});
|
|
8967
|
+
if (inResult.status === "aborted")
|
|
8968
|
+
return INVALID2;
|
|
8969
|
+
if (inResult.status === "dirty") {
|
|
8970
|
+
status.dirty();
|
|
8971
|
+
return {
|
|
8972
|
+
status: "dirty",
|
|
8973
|
+
value: inResult.value
|
|
8974
|
+
};
|
|
8975
|
+
} else {
|
|
8976
|
+
return this._def.out._parseSync({
|
|
8977
|
+
data: inResult.value,
|
|
8978
|
+
path: ctx.path,
|
|
8979
|
+
parent: ctx
|
|
8980
|
+
});
|
|
8981
|
+
}
|
|
8982
|
+
}
|
|
8983
|
+
}
|
|
8984
|
+
static create(a, b) {
|
|
8985
|
+
return new _ZodPipeline2({
|
|
8986
|
+
in: a,
|
|
8987
|
+
out: b,
|
|
8988
|
+
typeName: ZodFirstPartyTypeKind2.ZodPipeline
|
|
8989
|
+
});
|
|
8990
|
+
}
|
|
8991
|
+
};
|
|
8992
|
+
var ZodReadonly2 = class extends ZodType2 {
|
|
8993
|
+
_parse(input) {
|
|
8994
|
+
const result = this._def.innerType._parse(input);
|
|
8995
|
+
const freeze = (data) => {
|
|
8996
|
+
if (isValid2(data)) {
|
|
8997
|
+
data.value = Object.freeze(data.value);
|
|
8998
|
+
}
|
|
8999
|
+
return data;
|
|
9000
|
+
};
|
|
9001
|
+
return isAsync2(result) ? result.then((data) => freeze(data)) : freeze(result);
|
|
9002
|
+
}
|
|
9003
|
+
unwrap() {
|
|
9004
|
+
return this._def.innerType;
|
|
9005
|
+
}
|
|
9006
|
+
};
|
|
9007
|
+
ZodReadonly2.create = (type, params) => {
|
|
9008
|
+
return new ZodReadonly2({
|
|
9009
|
+
innerType: type,
|
|
9010
|
+
typeName: ZodFirstPartyTypeKind2.ZodReadonly,
|
|
9011
|
+
...processCreateParams2(params)
|
|
9012
|
+
});
|
|
9013
|
+
};
|
|
9014
|
+
function cleanParams2(params, data) {
|
|
9015
|
+
const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
|
|
9016
|
+
const p2 = typeof p === "string" ? { message: p } : p;
|
|
9017
|
+
return p2;
|
|
9018
|
+
}
|
|
9019
|
+
function custom2(check, _params = {}, fatal) {
|
|
9020
|
+
if (check)
|
|
9021
|
+
return ZodAny2.create().superRefine((data, ctx) => {
|
|
9022
|
+
const r = check(data);
|
|
9023
|
+
if (r instanceof Promise) {
|
|
9024
|
+
return r.then((r2) => {
|
|
9025
|
+
if (!r2) {
|
|
9026
|
+
const params = cleanParams2(_params, data);
|
|
9027
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
9028
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
9029
|
+
}
|
|
9030
|
+
});
|
|
9031
|
+
}
|
|
9032
|
+
if (!r) {
|
|
9033
|
+
const params = cleanParams2(_params, data);
|
|
9034
|
+
const _fatal = params.fatal ?? fatal ?? true;
|
|
9035
|
+
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
9036
|
+
}
|
|
9037
|
+
return;
|
|
9038
|
+
});
|
|
9039
|
+
return ZodAny2.create();
|
|
9040
|
+
}
|
|
9041
|
+
var late2 = {
|
|
9042
|
+
object: ZodObject2.lazycreate
|
|
9043
|
+
};
|
|
9044
|
+
var ZodFirstPartyTypeKind2;
|
|
9045
|
+
(function(ZodFirstPartyTypeKind3) {
|
|
9046
|
+
ZodFirstPartyTypeKind3["ZodString"] = "ZodString";
|
|
9047
|
+
ZodFirstPartyTypeKind3["ZodNumber"] = "ZodNumber";
|
|
9048
|
+
ZodFirstPartyTypeKind3["ZodNaN"] = "ZodNaN";
|
|
9049
|
+
ZodFirstPartyTypeKind3["ZodBigInt"] = "ZodBigInt";
|
|
9050
|
+
ZodFirstPartyTypeKind3["ZodBoolean"] = "ZodBoolean";
|
|
9051
|
+
ZodFirstPartyTypeKind3["ZodDate"] = "ZodDate";
|
|
9052
|
+
ZodFirstPartyTypeKind3["ZodSymbol"] = "ZodSymbol";
|
|
9053
|
+
ZodFirstPartyTypeKind3["ZodUndefined"] = "ZodUndefined";
|
|
9054
|
+
ZodFirstPartyTypeKind3["ZodNull"] = "ZodNull";
|
|
9055
|
+
ZodFirstPartyTypeKind3["ZodAny"] = "ZodAny";
|
|
9056
|
+
ZodFirstPartyTypeKind3["ZodUnknown"] = "ZodUnknown";
|
|
9057
|
+
ZodFirstPartyTypeKind3["ZodNever"] = "ZodNever";
|
|
9058
|
+
ZodFirstPartyTypeKind3["ZodVoid"] = "ZodVoid";
|
|
9059
|
+
ZodFirstPartyTypeKind3["ZodArray"] = "ZodArray";
|
|
9060
|
+
ZodFirstPartyTypeKind3["ZodObject"] = "ZodObject";
|
|
9061
|
+
ZodFirstPartyTypeKind3["ZodUnion"] = "ZodUnion";
|
|
9062
|
+
ZodFirstPartyTypeKind3["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
|
9063
|
+
ZodFirstPartyTypeKind3["ZodIntersection"] = "ZodIntersection";
|
|
9064
|
+
ZodFirstPartyTypeKind3["ZodTuple"] = "ZodTuple";
|
|
9065
|
+
ZodFirstPartyTypeKind3["ZodRecord"] = "ZodRecord";
|
|
9066
|
+
ZodFirstPartyTypeKind3["ZodMap"] = "ZodMap";
|
|
9067
|
+
ZodFirstPartyTypeKind3["ZodSet"] = "ZodSet";
|
|
9068
|
+
ZodFirstPartyTypeKind3["ZodFunction"] = "ZodFunction";
|
|
9069
|
+
ZodFirstPartyTypeKind3["ZodLazy"] = "ZodLazy";
|
|
9070
|
+
ZodFirstPartyTypeKind3["ZodLiteral"] = "ZodLiteral";
|
|
9071
|
+
ZodFirstPartyTypeKind3["ZodEnum"] = "ZodEnum";
|
|
9072
|
+
ZodFirstPartyTypeKind3["ZodEffects"] = "ZodEffects";
|
|
9073
|
+
ZodFirstPartyTypeKind3["ZodNativeEnum"] = "ZodNativeEnum";
|
|
9074
|
+
ZodFirstPartyTypeKind3["ZodOptional"] = "ZodOptional";
|
|
9075
|
+
ZodFirstPartyTypeKind3["ZodNullable"] = "ZodNullable";
|
|
9076
|
+
ZodFirstPartyTypeKind3["ZodDefault"] = "ZodDefault";
|
|
9077
|
+
ZodFirstPartyTypeKind3["ZodCatch"] = "ZodCatch";
|
|
9078
|
+
ZodFirstPartyTypeKind3["ZodPromise"] = "ZodPromise";
|
|
9079
|
+
ZodFirstPartyTypeKind3["ZodBranded"] = "ZodBranded";
|
|
9080
|
+
ZodFirstPartyTypeKind3["ZodPipeline"] = "ZodPipeline";
|
|
9081
|
+
ZodFirstPartyTypeKind3["ZodReadonly"] = "ZodReadonly";
|
|
9082
|
+
})(ZodFirstPartyTypeKind2 || (ZodFirstPartyTypeKind2 = {}));
|
|
9083
|
+
var instanceOfType2 = (cls, params = {
|
|
9084
|
+
message: `Input not instance of ${cls.name}`
|
|
9085
|
+
}) => custom2((data) => data instanceof cls, params);
|
|
9086
|
+
var stringType2 = ZodString2.create;
|
|
9087
|
+
var numberType2 = ZodNumber2.create;
|
|
9088
|
+
var nanType2 = ZodNaN2.create;
|
|
9089
|
+
var bigIntType2 = ZodBigInt2.create;
|
|
9090
|
+
var booleanType2 = ZodBoolean2.create;
|
|
9091
|
+
var dateType2 = ZodDate2.create;
|
|
9092
|
+
var symbolType2 = ZodSymbol2.create;
|
|
9093
|
+
var undefinedType2 = ZodUndefined2.create;
|
|
9094
|
+
var nullType2 = ZodNull2.create;
|
|
9095
|
+
var anyType2 = ZodAny2.create;
|
|
9096
|
+
var unknownType2 = ZodUnknown2.create;
|
|
9097
|
+
var neverType2 = ZodNever2.create;
|
|
9098
|
+
var voidType2 = ZodVoid2.create;
|
|
9099
|
+
var arrayType2 = ZodArray2.create;
|
|
9100
|
+
var objectType2 = ZodObject2.create;
|
|
9101
|
+
var strictObjectType2 = ZodObject2.strictCreate;
|
|
9102
|
+
var unionType2 = ZodUnion2.create;
|
|
9103
|
+
var discriminatedUnionType2 = ZodDiscriminatedUnion2.create;
|
|
9104
|
+
var intersectionType2 = ZodIntersection2.create;
|
|
9105
|
+
var tupleType2 = ZodTuple2.create;
|
|
9106
|
+
var recordType2 = ZodRecord2.create;
|
|
9107
|
+
var mapType2 = ZodMap2.create;
|
|
9108
|
+
var setType2 = ZodSet2.create;
|
|
9109
|
+
var functionType2 = ZodFunction2.create;
|
|
9110
|
+
var lazyType2 = ZodLazy2.create;
|
|
9111
|
+
var literalType2 = ZodLiteral2.create;
|
|
9112
|
+
var enumType2 = ZodEnum2.create;
|
|
9113
|
+
var nativeEnumType2 = ZodNativeEnum2.create;
|
|
9114
|
+
var promiseType2 = ZodPromise2.create;
|
|
9115
|
+
var effectsType2 = ZodEffects2.create;
|
|
9116
|
+
var optionalType2 = ZodOptional2.create;
|
|
9117
|
+
var nullableType2 = ZodNullable2.create;
|
|
9118
|
+
var preprocessType2 = ZodEffects2.createWithPreprocess;
|
|
9119
|
+
var pipelineType2 = ZodPipeline2.create;
|
|
9120
|
+
var ostring2 = () => stringType2().optional();
|
|
9121
|
+
var onumber2 = () => numberType2().optional();
|
|
9122
|
+
var oboolean2 = () => booleanType2().optional();
|
|
9123
|
+
var coerce2 = {
|
|
9124
|
+
string: ((arg) => ZodString2.create({ ...arg, coerce: true })),
|
|
9125
|
+
number: ((arg) => ZodNumber2.create({ ...arg, coerce: true })),
|
|
9126
|
+
boolean: ((arg) => ZodBoolean2.create({
|
|
9127
|
+
...arg,
|
|
9128
|
+
coerce: true
|
|
9129
|
+
})),
|
|
9130
|
+
bigint: ((arg) => ZodBigInt2.create({ ...arg, coerce: true })),
|
|
9131
|
+
date: ((arg) => ZodDate2.create({ ...arg, coerce: true }))
|
|
9132
|
+
};
|
|
9133
|
+
var NEVER2 = INVALID2;
|
|
9134
|
+
|
|
9135
|
+
// ../../packages/shared/dist/schemas/index.js
|
|
9136
|
+
var MAX_JSON_SIZE2 = 1e4;
|
|
9137
|
+
function jsonSizeCheck2(val) {
|
|
9138
|
+
return JSON.stringify(val).length <= MAX_JSON_SIZE2;
|
|
9139
|
+
}
|
|
9140
|
+
var riskLevelSchema2 = external_exports2.enum([RiskLevel2.LOW, RiskLevel2.MEDIUM, RiskLevel2.HIGH, RiskLevel2.CRITICAL]);
|
|
9141
|
+
var urgencySchema2 = external_exports2.enum([Urgency2.LOW, Urgency2.NORMAL, Urgency2.HIGH, Urgency2.URGENT]);
|
|
9142
|
+
var timeoutActionSchema2 = external_exports2.enum([TimeoutAction2.AUTO_APPROVE, TimeoutAction2.CANCEL, TimeoutAction2.HOLD]);
|
|
9143
|
+
var policyActionSchema2 = external_exports2.enum([PolicyAction2.AUTO_APPROVE, PolicyAction2.REQUIRE_APPROVAL, PolicyAction2.FORBID]);
|
|
9144
|
+
var createCheckInSchema2 = external_exports2.object({
|
|
9145
|
+
action: external_exports2.string().min(1).max(500),
|
|
9146
|
+
description: external_exports2.string().max(5e3).optional(),
|
|
9147
|
+
risk_level: riskLevelSchema2.default(RiskLevel2.MEDIUM),
|
|
9148
|
+
urgency: urgencySchema2.default(Urgency2.NORMAL),
|
|
9149
|
+
context: external_exports2.record(external_exports2.unknown()).default({}).refine(jsonSizeCheck2, "Context exceeds 10KB limit"),
|
|
9150
|
+
timeout_minutes: external_exports2.number().int().min(1).max(10080).optional(),
|
|
9151
|
+
timeout_action: timeoutActionSchema2.optional()
|
|
9152
|
+
});
|
|
9153
|
+
var approveCheckInSchema2 = external_exports2.object({
|
|
9154
|
+
reason: external_exports2.string().max(2e3).optional()
|
|
9155
|
+
});
|
|
9156
|
+
var rejectCheckInSchema2 = external_exports2.object({
|
|
9157
|
+
reason: external_exports2.string().min(1).max(2e3)
|
|
9158
|
+
});
|
|
9159
|
+
var modifyCheckInSchema2 = external_exports2.object({
|
|
9160
|
+
reason: external_exports2.string().min(1).max(2e3),
|
|
9161
|
+
modifications: external_exports2.record(external_exports2.unknown()).refine(jsonSizeCheck2, "Modifications exceeds 10KB limit")
|
|
9162
|
+
});
|
|
9163
|
+
var policyConditionSchema2 = external_exports2.object({
|
|
9164
|
+
risk_level: external_exports2.array(riskLevelSchema2).optional(),
|
|
9165
|
+
action_type: external_exports2.array(external_exports2.string()).optional(),
|
|
9166
|
+
agent_id: external_exports2.array(external_exports2.string()).optional(),
|
|
9167
|
+
min_trust_score: external_exports2.number().min(0).max(100).optional()
|
|
9168
|
+
});
|
|
9169
|
+
var policyRuleSchema2 = external_exports2.object({
|
|
9170
|
+
action: policyActionSchema2,
|
|
9171
|
+
conditions: policyConditionSchema2,
|
|
9172
|
+
reason: external_exports2.string().max(500).optional()
|
|
9173
|
+
});
|
|
9174
|
+
var trustThresholdsSchema2 = external_exports2.object({
|
|
9175
|
+
auto_approve_low: external_exports2.number().min(0).max(100),
|
|
9176
|
+
auto_approve_medium: external_exports2.number().min(0).max(100)
|
|
9177
|
+
});
|
|
9178
|
+
var roomPoliciesSchema2 = external_exports2.object({
|
|
9179
|
+
default_action: policyActionSchema2.default(PolicyAction2.REQUIRE_APPROVAL),
|
|
9180
|
+
timeout_minutes: external_exports2.number().int().min(1).max(10080).default(60),
|
|
9181
|
+
timeout_action: timeoutActionSchema2.default(TimeoutAction2.CANCEL),
|
|
9182
|
+
rules: external_exports2.array(policyRuleSchema2).default([]),
|
|
9183
|
+
trust_thresholds: trustThresholdsSchema2.optional()
|
|
9184
|
+
});
|
|
9185
|
+
var createRoomSchema2 = external_exports2.object({
|
|
9186
|
+
name: external_exports2.string().min(1).max(200),
|
|
9187
|
+
slug: external_exports2.string().min(1).max(100).regex(/^[a-z0-9-]+$/, "Slug must be lowercase alphanumeric with hyphens").optional(),
|
|
9188
|
+
description: external_exports2.string().max(2e3).optional(),
|
|
9189
|
+
policies: roomPoliciesSchema2.partial().optional()
|
|
9190
|
+
});
|
|
9191
|
+
var updateRoomSchema2 = external_exports2.object({
|
|
9192
|
+
name: external_exports2.string().min(1).max(200).optional(),
|
|
9193
|
+
description: external_exports2.string().max(2e3).nullable().optional()
|
|
9194
|
+
}).refine((obj) => Object.keys(obj).length > 0, "At least one field must be provided");
|
|
9195
|
+
var updatePoliciesSchema2 = external_exports2.object({
|
|
9196
|
+
policies: roomPoliciesSchema2
|
|
9197
|
+
});
|
|
9198
|
+
var createSignalSchema2 = external_exports2.object({
|
|
9199
|
+
type: external_exports2.string().min(1).max(200),
|
|
9200
|
+
payload: external_exports2.record(external_exports2.unknown()).default({}).refine(jsonSizeCheck2, "Payload exceeds 10KB limit")
|
|
9201
|
+
});
|
|
9202
|
+
var registerAgentSchema2 = external_exports2.object({
|
|
9203
|
+
name: external_exports2.string().min(1).max(200),
|
|
9204
|
+
description: external_exports2.string().max(2e3).optional(),
|
|
9205
|
+
platform: external_exports2.string().max(100).optional(),
|
|
9206
|
+
room_scopes: external_exports2.array(external_exports2.string()).optional()
|
|
9207
|
+
});
|
|
9208
|
+
var selfRegisterAgentSchema2 = external_exports2.object({
|
|
9209
|
+
name: external_exports2.string().min(1).max(200),
|
|
9210
|
+
description: external_exports2.string().max(2e3).optional(),
|
|
9211
|
+
platform: external_exports2.string().max(100).optional()
|
|
9212
|
+
});
|
|
9213
|
+
var updateAgentSchema2 = external_exports2.object({
|
|
9214
|
+
name: external_exports2.string().min(1).max(200).optional(),
|
|
9215
|
+
description: external_exports2.string().max(2e3).nullable().optional(),
|
|
9216
|
+
platform: external_exports2.string().max(100).nullable().optional()
|
|
9217
|
+
}).refine((obj) => Object.keys(obj).length > 0, "At least one field must be provided");
|
|
9218
|
+
var claimAgentSchema2 = external_exports2.object({
|
|
9219
|
+
claim_token: external_exports2.string().startsWith("wr_claim_", "Claim token must start with wr_claim_")
|
|
9220
|
+
});
|
|
9221
|
+
var createWatcherSchema2 = external_exports2.object({
|
|
9222
|
+
event_types: external_exports2.array(external_exports2.string().min(1)).min(1),
|
|
9223
|
+
filter: external_exports2.record(external_exports2.unknown()).optional(),
|
|
9224
|
+
webhook_url: external_exports2.string().url().optional()
|
|
9225
|
+
});
|
|
9226
|
+
var paginationSchema2 = external_exports2.object({
|
|
9227
|
+
cursor: external_exports2.string().optional(),
|
|
9228
|
+
limit: external_exports2.coerce.number().int().min(1).max(100).default(50)
|
|
9229
|
+
});
|
|
9230
|
+
var checkInFiltersSchema2 = external_exports2.object({
|
|
9231
|
+
status: external_exports2.enum([
|
|
9232
|
+
CheckInStatus2.PENDING,
|
|
9233
|
+
CheckInStatus2.APPROVED,
|
|
9234
|
+
CheckInStatus2.REJECTED,
|
|
9235
|
+
CheckInStatus2.MODIFIED,
|
|
9236
|
+
CheckInStatus2.EXPIRED,
|
|
9237
|
+
CheckInStatus2.WITHDRAWN
|
|
9238
|
+
]).optional(),
|
|
9239
|
+
risk_level: riskLevelSchema2.optional(),
|
|
9240
|
+
urgency: urgencySchema2.optional(),
|
|
9241
|
+
agent_id: external_exports2.string().optional()
|
|
9242
|
+
});
|
|
9243
|
+
|
|
9244
|
+
// ../../packages/shared/dist/constants/index.js
|
|
9245
|
+
var POLL_INITIAL_INTERVAL_MS2 = 2e3;
|
|
9246
|
+
var POLL_MAX_INTERVAL_MS2 = 3e4;
|
|
9247
|
+
var POLL_BACKOFF_MULTIPLIER2 = 1.5;
|
|
9248
|
+
|
|
5079
9249
|
// src/commands/checkin.ts
|
|
5080
9250
|
function checkinCommand() {
|
|
5081
9251
|
const cmd = new Command4("checkin").description("Check-in lifecycle commands");
|
|
@@ -5114,7 +9284,7 @@ function checkinCommand() {
|
|
|
5114
9284
|
return;
|
|
5115
9285
|
}
|
|
5116
9286
|
if (process.stderr.isTTY) spinner.text = `Waiting for decision on ${checkIn.id}...`;
|
|
5117
|
-
let interval =
|
|
9287
|
+
let interval = POLL_INITIAL_INTERVAL_MS2;
|
|
5118
9288
|
const maxWait = 3e5;
|
|
5119
9289
|
const startTime = Date.now();
|
|
5120
9290
|
while (Date.now() - startTime < maxWait) {
|
|
@@ -5126,7 +9296,7 @@ function checkinCommand() {
|
|
|
5126
9296
|
output(updated, { format: fmt, quiet: globalOpts.quiet });
|
|
5127
9297
|
return;
|
|
5128
9298
|
}
|
|
5129
|
-
interval = Math.min(interval *
|
|
9299
|
+
interval = Math.min(interval * POLL_BACKOFF_MULTIPLIER2, POLL_MAX_INTERVAL_MS2);
|
|
5130
9300
|
}
|
|
5131
9301
|
if (process.stderr.isTTY) spinner.warn("Timed out waiting for decision");
|
|
5132
9302
|
const final = await client.checkIns.getStatus(checkIn.id);
|
|
@@ -5151,7 +9321,7 @@ function checkinCommand() {
|
|
|
5151
9321
|
if (opts.watch) {
|
|
5152
9322
|
const spinner = createSpinner(`Watching ${id}...`);
|
|
5153
9323
|
if (process.stderr.isTTY) spinner.start();
|
|
5154
|
-
let interval =
|
|
9324
|
+
let interval = POLL_INITIAL_INTERVAL_MS2;
|
|
5155
9325
|
while (true) {
|
|
5156
9326
|
const checkIn = await client.checkIns.getStatus(id);
|
|
5157
9327
|
if (checkIn.status !== "pending") {
|
|
@@ -5160,7 +9330,7 @@ function checkinCommand() {
|
|
|
5160
9330
|
return;
|
|
5161
9331
|
}
|
|
5162
9332
|
await new Promise((r) => setTimeout(r, interval));
|
|
5163
|
-
interval = Math.min(interval *
|
|
9333
|
+
interval = Math.min(interval * POLL_BACKOFF_MULTIPLIER2, POLL_MAX_INTERVAL_MS2);
|
|
5164
9334
|
}
|
|
5165
9335
|
} else {
|
|
5166
9336
|
const checkIn = await client.checkIns.getStatus(id);
|