@resconet/qp-bridge 0.0.1-alpha.7 → 1.0.0-alpha.26
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/README.md +638 -6
- package/index.js +1 -1
- package/index.mjs +1496 -1196
- package/lib/qp-bridge-types.d.ts +360 -0
- package/lib/qp-bridge.d.ts +244 -8
- package/package.json +1 -1
package/index.mjs
CHANGED
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
let
|
|
2
|
-
const
|
|
3
|
-
function
|
|
4
|
-
if (!
|
|
1
|
+
let ve;
|
|
2
|
+
const Fe = new Uint8Array(16);
|
|
3
|
+
function et() {
|
|
4
|
+
if (!ve && (ve = typeof crypto < "u" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !ve))
|
|
5
5
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
6
|
-
return
|
|
6
|
+
return ve(Fe);
|
|
7
7
|
}
|
|
8
|
-
const
|
|
9
|
-
for (let
|
|
10
|
-
|
|
11
|
-
function
|
|
12
|
-
return
|
|
8
|
+
const k = [];
|
|
9
|
+
for (let t = 0; t < 256; ++t)
|
|
10
|
+
k.push((t + 256).toString(16).slice(1));
|
|
11
|
+
function tt(t, e = 0) {
|
|
12
|
+
return k[t[e + 0]] + k[t[e + 1]] + k[t[e + 2]] + k[t[e + 3]] + "-" + k[t[e + 4]] + k[t[e + 5]] + "-" + k[t[e + 6]] + k[t[e + 7]] + "-" + k[t[e + 8]] + k[t[e + 9]] + "-" + k[t[e + 10]] + k[t[e + 11]] + k[t[e + 12]] + k[t[e + 13]] + k[t[e + 14]] + k[t[e + 15]];
|
|
13
13
|
}
|
|
14
|
-
const
|
|
15
|
-
randomUUID:
|
|
14
|
+
const st = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), Ae = {
|
|
15
|
+
randomUUID: st
|
|
16
16
|
};
|
|
17
|
-
function
|
|
18
|
-
if (
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
const n =
|
|
22
|
-
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128,
|
|
23
|
-
}
|
|
24
|
-
var
|
|
25
|
-
(function(
|
|
26
|
-
|
|
17
|
+
function qe(t, e, s) {
|
|
18
|
+
if (Ae.randomUUID && !e && !t)
|
|
19
|
+
return Ae.randomUUID();
|
|
20
|
+
t = t || {};
|
|
21
|
+
const n = t.random || (t.rng || et)();
|
|
22
|
+
return n[6] = n[6] & 15 | 64, n[8] = n[8] & 63 | 128, tt(n);
|
|
23
|
+
}
|
|
24
|
+
var x;
|
|
25
|
+
(function(t) {
|
|
26
|
+
t.assertEqual = (r) => r;
|
|
27
27
|
function e(r) {
|
|
28
28
|
}
|
|
29
|
-
|
|
30
|
-
function
|
|
29
|
+
t.assertIs = e;
|
|
30
|
+
function s(r) {
|
|
31
31
|
throw new Error();
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
t.assertNever = s, t.arrayToEnum = (r) => {
|
|
34
34
|
const a = {};
|
|
35
35
|
for (const i of r)
|
|
36
36
|
a[i] = i;
|
|
37
37
|
return a;
|
|
38
|
-
},
|
|
39
|
-
const a =
|
|
38
|
+
}, t.getValidEnumValues = (r) => {
|
|
39
|
+
const a = t.objectKeys(r).filter((o) => typeof r[r[o]] != "number"), i = {};
|
|
40
40
|
for (const o of a)
|
|
41
41
|
i[o] = r[o];
|
|
42
|
-
return
|
|
43
|
-
},
|
|
42
|
+
return t.objectValues(i);
|
|
43
|
+
}, t.objectValues = (r) => t.objectKeys(r).map(function(a) {
|
|
44
44
|
return r[a];
|
|
45
|
-
}),
|
|
45
|
+
}), t.objectKeys = typeof Object.keys == "function" ? (r) => Object.keys(r) : (r) => {
|
|
46
46
|
const a = [];
|
|
47
47
|
for (const i in r)
|
|
48
48
|
Object.prototype.hasOwnProperty.call(r, i) && a.push(i);
|
|
49
49
|
return a;
|
|
50
|
-
},
|
|
50
|
+
}, t.find = (r, a) => {
|
|
51
51
|
for (const i of r)
|
|
52
52
|
if (a(i))
|
|
53
53
|
return i;
|
|
54
|
-
},
|
|
54
|
+
}, t.isInteger = typeof Number.isInteger == "function" ? (r) => Number.isInteger(r) : (r) => typeof r == "number" && isFinite(r) && Math.floor(r) === r;
|
|
55
55
|
function n(r, a = " | ") {
|
|
56
56
|
return r.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
57
57
|
}
|
|
58
|
-
|
|
59
|
-
})(
|
|
60
|
-
var
|
|
61
|
-
(function(
|
|
62
|
-
|
|
58
|
+
t.joinValues = n, t.jsonStringifyReplacer = (r, a) => typeof a == "bigint" ? a.toString() : a;
|
|
59
|
+
})(x || (x = {}));
|
|
60
|
+
var Ze;
|
|
61
|
+
(function(t) {
|
|
62
|
+
t.mergeShapes = (e, s) => ({
|
|
63
63
|
...e,
|
|
64
|
-
...
|
|
64
|
+
...s
|
|
65
65
|
// second overwrites first
|
|
66
66
|
});
|
|
67
|
-
})(
|
|
68
|
-
const f =
|
|
67
|
+
})(Ze || (Ze = {}));
|
|
68
|
+
const f = x.arrayToEnum([
|
|
69
69
|
"string",
|
|
70
70
|
"nan",
|
|
71
71
|
"number",
|
|
@@ -86,14 +86,14 @@ const f = _.arrayToEnum([
|
|
|
86
86
|
"never",
|
|
87
87
|
"map",
|
|
88
88
|
"set"
|
|
89
|
-
]),
|
|
90
|
-
switch (typeof
|
|
89
|
+
]), q = (t) => {
|
|
90
|
+
switch (typeof t) {
|
|
91
91
|
case "undefined":
|
|
92
92
|
return f.undefined;
|
|
93
93
|
case "string":
|
|
94
94
|
return f.string;
|
|
95
95
|
case "number":
|
|
96
|
-
return isNaN(
|
|
96
|
+
return isNaN(t) ? f.nan : f.number;
|
|
97
97
|
case "boolean":
|
|
98
98
|
return f.boolean;
|
|
99
99
|
case "function":
|
|
@@ -103,11 +103,11 @@ const f = _.arrayToEnum([
|
|
|
103
103
|
case "symbol":
|
|
104
104
|
return f.symbol;
|
|
105
105
|
case "object":
|
|
106
|
-
return Array.isArray(
|
|
106
|
+
return Array.isArray(t) ? f.array : t === null ? f.null : t.then && typeof t.then == "function" && t.catch && typeof t.catch == "function" ? f.promise : typeof Map < "u" && t instanceof Map ? f.map : typeof Set < "u" && t instanceof Set ? f.set : typeof Date < "u" && t instanceof Date ? f.date : f.object;
|
|
107
107
|
default:
|
|
108
108
|
return f.unknown;
|
|
109
109
|
}
|
|
110
|
-
},
|
|
110
|
+
}, c = x.arrayToEnum([
|
|
111
111
|
"invalid_type",
|
|
112
112
|
"invalid_literal",
|
|
113
113
|
"custom",
|
|
@@ -124,22 +124,22 @@ const f = _.arrayToEnum([
|
|
|
124
124
|
"invalid_intersection_types",
|
|
125
125
|
"not_multiple_of",
|
|
126
126
|
"not_finite"
|
|
127
|
-
]),
|
|
128
|
-
class
|
|
127
|
+
]), nt = (t) => JSON.stringify(t, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
128
|
+
class E extends Error {
|
|
129
129
|
constructor(e) {
|
|
130
130
|
super(), this.issues = [], this.addIssue = (n) => {
|
|
131
131
|
this.issues = [...this.issues, n];
|
|
132
132
|
}, this.addIssues = (n = []) => {
|
|
133
133
|
this.issues = [...this.issues, ...n];
|
|
134
134
|
};
|
|
135
|
-
const
|
|
136
|
-
Object.setPrototypeOf ? Object.setPrototypeOf(this,
|
|
135
|
+
const s = new.target.prototype;
|
|
136
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, s) : this.__proto__ = s, this.name = "ZodError", this.issues = e;
|
|
137
137
|
}
|
|
138
138
|
get errors() {
|
|
139
139
|
return this.issues;
|
|
140
140
|
}
|
|
141
141
|
format(e) {
|
|
142
|
-
const
|
|
142
|
+
const s = e || function(a) {
|
|
143
143
|
return a.message;
|
|
144
144
|
}, n = { _errors: [] }, r = (a) => {
|
|
145
145
|
for (const i of a.issues)
|
|
@@ -150,106 +150,106 @@ class S extends Error {
|
|
|
150
150
|
else if (i.code === "invalid_arguments")
|
|
151
151
|
r(i.argumentsError);
|
|
152
152
|
else if (i.path.length === 0)
|
|
153
|
-
n._errors.push(
|
|
153
|
+
n._errors.push(s(i));
|
|
154
154
|
else {
|
|
155
155
|
let o = n, u = 0;
|
|
156
156
|
for (; u < i.path.length; ) {
|
|
157
|
-
const
|
|
158
|
-
u === i.path.length - 1 ? (o[
|
|
157
|
+
const d = i.path[u];
|
|
158
|
+
u === i.path.length - 1 ? (o[d] = o[d] || { _errors: [] }, o[d]._errors.push(s(i))) : o[d] = o[d] || { _errors: [] }, o = o[d], u++;
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
};
|
|
162
162
|
return r(this), n;
|
|
163
163
|
}
|
|
164
164
|
static assert(e) {
|
|
165
|
-
if (!(e instanceof
|
|
165
|
+
if (!(e instanceof E))
|
|
166
166
|
throw new Error(`Not a ZodError: ${e}`);
|
|
167
167
|
}
|
|
168
168
|
toString() {
|
|
169
169
|
return this.message;
|
|
170
170
|
}
|
|
171
171
|
get message() {
|
|
172
|
-
return JSON.stringify(this.issues,
|
|
172
|
+
return JSON.stringify(this.issues, x.jsonStringifyReplacer, 2);
|
|
173
173
|
}
|
|
174
174
|
get isEmpty() {
|
|
175
175
|
return this.issues.length === 0;
|
|
176
176
|
}
|
|
177
|
-
flatten(e = (
|
|
178
|
-
const
|
|
177
|
+
flatten(e = (s) => s.message) {
|
|
178
|
+
const s = {}, n = [];
|
|
179
179
|
for (const r of this.issues)
|
|
180
|
-
r.path.length > 0 ? (
|
|
181
|
-
return { formErrors: n, fieldErrors:
|
|
180
|
+
r.path.length > 0 ? (s[r.path[0]] = s[r.path[0]] || [], s[r.path[0]].push(e(r))) : n.push(e(r));
|
|
181
|
+
return { formErrors: n, fieldErrors: s };
|
|
182
182
|
}
|
|
183
183
|
get formErrors() {
|
|
184
184
|
return this.flatten();
|
|
185
185
|
}
|
|
186
186
|
}
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
let
|
|
190
|
-
switch (
|
|
191
|
-
case
|
|
192
|
-
|
|
187
|
+
E.create = (t) => new E(t);
|
|
188
|
+
const Y = (t, e) => {
|
|
189
|
+
let s;
|
|
190
|
+
switch (t.code) {
|
|
191
|
+
case c.invalid_type:
|
|
192
|
+
t.received === f.undefined ? s = "Required" : s = `Expected ${t.expected}, received ${t.received}`;
|
|
193
193
|
break;
|
|
194
|
-
case
|
|
195
|
-
|
|
194
|
+
case c.invalid_literal:
|
|
195
|
+
s = `Invalid literal value, expected ${JSON.stringify(t.expected, x.jsonStringifyReplacer)}`;
|
|
196
196
|
break;
|
|
197
|
-
case
|
|
198
|
-
|
|
197
|
+
case c.unrecognized_keys:
|
|
198
|
+
s = `Unrecognized key(s) in object: ${x.joinValues(t.keys, ", ")}`;
|
|
199
199
|
break;
|
|
200
|
-
case
|
|
201
|
-
|
|
200
|
+
case c.invalid_union:
|
|
201
|
+
s = "Invalid input";
|
|
202
202
|
break;
|
|
203
|
-
case
|
|
204
|
-
|
|
203
|
+
case c.invalid_union_discriminator:
|
|
204
|
+
s = `Invalid discriminator value. Expected ${x.joinValues(t.options)}`;
|
|
205
205
|
break;
|
|
206
|
-
case
|
|
207
|
-
|
|
206
|
+
case c.invalid_enum_value:
|
|
207
|
+
s = `Invalid enum value. Expected ${x.joinValues(t.options)}, received '${t.received}'`;
|
|
208
208
|
break;
|
|
209
|
-
case
|
|
210
|
-
|
|
209
|
+
case c.invalid_arguments:
|
|
210
|
+
s = "Invalid function arguments";
|
|
211
211
|
break;
|
|
212
|
-
case
|
|
213
|
-
|
|
212
|
+
case c.invalid_return_type:
|
|
213
|
+
s = "Invalid function return type";
|
|
214
214
|
break;
|
|
215
|
-
case
|
|
216
|
-
|
|
215
|
+
case c.invalid_date:
|
|
216
|
+
s = "Invalid date";
|
|
217
217
|
break;
|
|
218
|
-
case
|
|
219
|
-
typeof
|
|
218
|
+
case c.invalid_string:
|
|
219
|
+
typeof t.validation == "object" ? "includes" in t.validation ? (s = `Invalid input: must include "${t.validation.includes}"`, typeof t.validation.position == "number" && (s = `${s} at one or more positions greater than or equal to ${t.validation.position}`)) : "startsWith" in t.validation ? s = `Invalid input: must start with "${t.validation.startsWith}"` : "endsWith" in t.validation ? s = `Invalid input: must end with "${t.validation.endsWith}"` : x.assertNever(t.validation) : t.validation !== "regex" ? s = `Invalid ${t.validation}` : s = "Invalid";
|
|
220
220
|
break;
|
|
221
|
-
case
|
|
222
|
-
|
|
221
|
+
case c.too_small:
|
|
222
|
+
t.type === "array" ? s = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "more than"} ${t.minimum} element(s)` : t.type === "string" ? s = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at least" : "over"} ${t.minimum} character(s)` : t.type === "number" ? s = `Number must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${t.minimum}` : t.type === "date" ? s = `Date must be ${t.exact ? "exactly equal to " : t.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(t.minimum))}` : s = "Invalid input";
|
|
223
223
|
break;
|
|
224
|
-
case
|
|
225
|
-
|
|
224
|
+
case c.too_big:
|
|
225
|
+
t.type === "array" ? s = `Array must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "less than"} ${t.maximum} element(s)` : t.type === "string" ? s = `String must contain ${t.exact ? "exactly" : t.inclusive ? "at most" : "under"} ${t.maximum} character(s)` : t.type === "number" ? s = `Number must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "bigint" ? s = `BigInt must be ${t.exact ? "exactly" : t.inclusive ? "less than or equal to" : "less than"} ${t.maximum}` : t.type === "date" ? s = `Date must be ${t.exact ? "exactly" : t.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(t.maximum))}` : s = "Invalid input";
|
|
226
226
|
break;
|
|
227
|
-
case
|
|
228
|
-
|
|
227
|
+
case c.custom:
|
|
228
|
+
s = "Invalid input";
|
|
229
229
|
break;
|
|
230
|
-
case
|
|
231
|
-
|
|
230
|
+
case c.invalid_intersection_types:
|
|
231
|
+
s = "Intersection results could not be merged";
|
|
232
232
|
break;
|
|
233
|
-
case
|
|
234
|
-
|
|
233
|
+
case c.not_multiple_of:
|
|
234
|
+
s = `Number must be a multiple of ${t.multipleOf}`;
|
|
235
235
|
break;
|
|
236
|
-
case
|
|
237
|
-
|
|
236
|
+
case c.not_finite:
|
|
237
|
+
s = "Number must be finite";
|
|
238
238
|
break;
|
|
239
239
|
default:
|
|
240
|
-
|
|
240
|
+
s = e.defaultError, x.assertNever(t);
|
|
241
241
|
}
|
|
242
|
-
return { message:
|
|
242
|
+
return { message: s };
|
|
243
243
|
};
|
|
244
|
-
let
|
|
245
|
-
function
|
|
246
|
-
|
|
244
|
+
let $e = Y;
|
|
245
|
+
function rt(t) {
|
|
246
|
+
$e = t;
|
|
247
247
|
}
|
|
248
|
-
function
|
|
249
|
-
return
|
|
248
|
+
function _e() {
|
|
249
|
+
return $e;
|
|
250
250
|
}
|
|
251
|
-
const
|
|
252
|
-
const { data: e, path:
|
|
251
|
+
const xe = (t) => {
|
|
252
|
+
const { data: e, path: s, errorMaps: n, issueData: r } = t, a = [...s, ...r.path || []], i = {
|
|
253
253
|
...r,
|
|
254
254
|
path: a
|
|
255
255
|
};
|
|
@@ -260,31 +260,31 @@ const me = (s) => {
|
|
|
260
260
|
message: r.message
|
|
261
261
|
};
|
|
262
262
|
let o = "";
|
|
263
|
-
const u = n.filter((
|
|
264
|
-
for (const
|
|
265
|
-
o =
|
|
263
|
+
const u = n.filter((d) => !!d).slice().reverse();
|
|
264
|
+
for (const d of u)
|
|
265
|
+
o = d(i, { data: e, defaultError: o }).message;
|
|
266
266
|
return {
|
|
267
267
|
...r,
|
|
268
268
|
path: a,
|
|
269
269
|
message: o
|
|
270
270
|
};
|
|
271
|
-
},
|
|
272
|
-
function l(
|
|
273
|
-
const
|
|
271
|
+
}, at = [];
|
|
272
|
+
function l(t, e) {
|
|
273
|
+
const s = _e(), n = xe({
|
|
274
274
|
issueData: e,
|
|
275
|
-
data:
|
|
276
|
-
path:
|
|
275
|
+
data: t.data,
|
|
276
|
+
path: t.path,
|
|
277
277
|
errorMaps: [
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
278
|
+
t.common.contextualErrorMap,
|
|
279
|
+
t.schemaErrorMap,
|
|
280
|
+
s,
|
|
281
|
+
s === Y ? void 0 : Y
|
|
282
282
|
// then global default map
|
|
283
283
|
].filter((r) => !!r)
|
|
284
284
|
});
|
|
285
|
-
|
|
285
|
+
t.common.issues.push(n);
|
|
286
286
|
}
|
|
287
|
-
class
|
|
287
|
+
class S {
|
|
288
288
|
constructor() {
|
|
289
289
|
this.value = "valid";
|
|
290
290
|
}
|
|
@@ -294,91 +294,91 @@ class w {
|
|
|
294
294
|
abort() {
|
|
295
295
|
this.value !== "aborted" && (this.value = "aborted");
|
|
296
296
|
}
|
|
297
|
-
static mergeArray(e,
|
|
297
|
+
static mergeArray(e, s) {
|
|
298
298
|
const n = [];
|
|
299
|
-
for (const r of
|
|
299
|
+
for (const r of s) {
|
|
300
300
|
if (r.status === "aborted")
|
|
301
|
-
return
|
|
301
|
+
return y;
|
|
302
302
|
r.status === "dirty" && e.dirty(), n.push(r.value);
|
|
303
303
|
}
|
|
304
304
|
return { status: e.value, value: n };
|
|
305
305
|
}
|
|
306
|
-
static async mergeObjectAsync(e,
|
|
306
|
+
static async mergeObjectAsync(e, s) {
|
|
307
307
|
const n = [];
|
|
308
|
-
for (const r of
|
|
308
|
+
for (const r of s) {
|
|
309
309
|
const a = await r.key, i = await r.value;
|
|
310
310
|
n.push({
|
|
311
311
|
key: a,
|
|
312
312
|
value: i
|
|
313
313
|
});
|
|
314
314
|
}
|
|
315
|
-
return
|
|
315
|
+
return S.mergeObjectSync(e, n);
|
|
316
316
|
}
|
|
317
|
-
static mergeObjectSync(e,
|
|
317
|
+
static mergeObjectSync(e, s) {
|
|
318
318
|
const n = {};
|
|
319
|
-
for (const r of
|
|
319
|
+
for (const r of s) {
|
|
320
320
|
const { key: a, value: i } = r;
|
|
321
321
|
if (a.status === "aborted" || i.status === "aborted")
|
|
322
|
-
return
|
|
322
|
+
return y;
|
|
323
323
|
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || r.alwaysSet) && (n[a.value] = i.value);
|
|
324
324
|
}
|
|
325
325
|
return { status: e.value, value: n };
|
|
326
326
|
}
|
|
327
327
|
}
|
|
328
|
-
const
|
|
328
|
+
const y = Object.freeze({
|
|
329
329
|
status: "aborted"
|
|
330
|
-
}), W = (
|
|
331
|
-
function
|
|
332
|
-
if (typeof e == "function" ?
|
|
330
|
+
}), W = (t) => ({ status: "dirty", value: t }), T = (t) => ({ status: "valid", value: t }), Ne = (t) => t.status === "aborted", Me = (t) => t.status === "dirty", se = (t) => t.status === "valid", ne = (t) => typeof Promise < "u" && t instanceof Promise;
|
|
331
|
+
function be(t, e, s, n) {
|
|
332
|
+
if (typeof e == "function" ? t !== e || !n : !e.has(t))
|
|
333
333
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
334
|
-
return e.get(
|
|
334
|
+
return e.get(t);
|
|
335
335
|
}
|
|
336
|
-
function
|
|
337
|
-
if (typeof e == "function" ?
|
|
336
|
+
function Ue(t, e, s, n, r) {
|
|
337
|
+
if (typeof e == "function" ? t !== e || !r : !e.has(t))
|
|
338
338
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
339
|
-
return e.set(
|
|
339
|
+
return e.set(t, s), s;
|
|
340
340
|
}
|
|
341
|
-
var
|
|
342
|
-
(function(
|
|
343
|
-
|
|
344
|
-
})(
|
|
345
|
-
var
|
|
341
|
+
var p;
|
|
342
|
+
(function(t) {
|
|
343
|
+
t.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, t.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
344
|
+
})(p || (p = {}));
|
|
345
|
+
var F, ee;
|
|
346
346
|
class O {
|
|
347
|
-
constructor(e,
|
|
348
|
-
this._cachedPath = [], this.parent = e, this.data =
|
|
347
|
+
constructor(e, s, n, r) {
|
|
348
|
+
this._cachedPath = [], this.parent = e, this.data = s, this._path = n, this._key = r;
|
|
349
349
|
}
|
|
350
350
|
get path() {
|
|
351
351
|
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
352
352
|
}
|
|
353
353
|
}
|
|
354
|
-
const je = (
|
|
355
|
-
if (
|
|
354
|
+
const je = (t, e) => {
|
|
355
|
+
if (se(e))
|
|
356
356
|
return { success: !0, data: e.value };
|
|
357
|
-
if (!
|
|
357
|
+
if (!t.common.issues.length)
|
|
358
358
|
throw new Error("Validation failed but no issues detected.");
|
|
359
359
|
return {
|
|
360
360
|
success: !1,
|
|
361
361
|
get error() {
|
|
362
362
|
if (this._error)
|
|
363
363
|
return this._error;
|
|
364
|
-
const
|
|
365
|
-
return this._error =
|
|
364
|
+
const s = new E(t.common.issues);
|
|
365
|
+
return this._error = s, this._error;
|
|
366
366
|
}
|
|
367
367
|
};
|
|
368
368
|
};
|
|
369
|
-
function
|
|
370
|
-
if (!
|
|
369
|
+
function v(t) {
|
|
370
|
+
if (!t)
|
|
371
371
|
return {};
|
|
372
|
-
const { errorMap: e, invalid_type_error:
|
|
373
|
-
if (e && (
|
|
372
|
+
const { errorMap: e, invalid_type_error: s, required_error: n, description: r } = t;
|
|
373
|
+
if (e && (s || n))
|
|
374
374
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
375
375
|
return e ? { errorMap: e, description: r } : { errorMap: (i, o) => {
|
|
376
|
-
var u,
|
|
377
|
-
const { message: g } =
|
|
378
|
-
return i.code === "invalid_enum_value" ? { message: g ?? o.defaultError } : typeof o.data > "u" ? { message: (u = g ?? n) !== null && u !== void 0 ? u : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (
|
|
376
|
+
var u, d;
|
|
377
|
+
const { message: g } = t;
|
|
378
|
+
return i.code === "invalid_enum_value" ? { message: g ?? o.defaultError } : typeof o.data > "u" ? { message: (u = g ?? n) !== null && u !== void 0 ? u : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (d = g ?? s) !== null && d !== void 0 ? d : o.defaultError };
|
|
379
379
|
}, description: r };
|
|
380
380
|
}
|
|
381
|
-
class
|
|
381
|
+
class _ {
|
|
382
382
|
constructor(e) {
|
|
383
383
|
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this);
|
|
384
384
|
}
|
|
@@ -386,13 +386,13 @@ class v {
|
|
|
386
386
|
return this._def.description;
|
|
387
387
|
}
|
|
388
388
|
_getType(e) {
|
|
389
|
-
return
|
|
389
|
+
return q(e.data);
|
|
390
390
|
}
|
|
391
|
-
_getOrReturnCtx(e,
|
|
392
|
-
return
|
|
391
|
+
_getOrReturnCtx(e, s) {
|
|
392
|
+
return s || {
|
|
393
393
|
common: e.parent.common,
|
|
394
394
|
data: e.data,
|
|
395
|
-
parsedType:
|
|
395
|
+
parsedType: q(e.data),
|
|
396
396
|
schemaErrorMap: this._def.errorMap,
|
|
397
397
|
path: e.path,
|
|
398
398
|
parent: e.parent
|
|
@@ -400,11 +400,11 @@ class v {
|
|
|
400
400
|
}
|
|
401
401
|
_processInputParams(e) {
|
|
402
402
|
return {
|
|
403
|
-
status: new
|
|
403
|
+
status: new S(),
|
|
404
404
|
ctx: {
|
|
405
405
|
common: e.parent.common,
|
|
406
406
|
data: e.data,
|
|
407
|
-
parsedType:
|
|
407
|
+
parsedType: q(e.data),
|
|
408
408
|
schemaErrorMap: this._def.errorMap,
|
|
409
409
|
path: e.path,
|
|
410
410
|
parent: e.parent
|
|
@@ -412,75 +412,75 @@ class v {
|
|
|
412
412
|
};
|
|
413
413
|
}
|
|
414
414
|
_parseSync(e) {
|
|
415
|
-
const
|
|
416
|
-
if (
|
|
415
|
+
const s = this._parse(e);
|
|
416
|
+
if (ne(s))
|
|
417
417
|
throw new Error("Synchronous parse encountered promise.");
|
|
418
|
-
return
|
|
418
|
+
return s;
|
|
419
419
|
}
|
|
420
420
|
_parseAsync(e) {
|
|
421
|
-
const
|
|
422
|
-
return Promise.resolve(
|
|
421
|
+
const s = this._parse(e);
|
|
422
|
+
return Promise.resolve(s);
|
|
423
423
|
}
|
|
424
|
-
parse(e,
|
|
425
|
-
const n = this.safeParse(e,
|
|
424
|
+
parse(e, s) {
|
|
425
|
+
const n = this.safeParse(e, s);
|
|
426
426
|
if (n.success)
|
|
427
427
|
return n.data;
|
|
428
428
|
throw n.error;
|
|
429
429
|
}
|
|
430
|
-
safeParse(e,
|
|
430
|
+
safeParse(e, s) {
|
|
431
431
|
var n;
|
|
432
432
|
const r = {
|
|
433
433
|
common: {
|
|
434
434
|
issues: [],
|
|
435
|
-
async: (n =
|
|
436
|
-
contextualErrorMap:
|
|
435
|
+
async: (n = s == null ? void 0 : s.async) !== null && n !== void 0 ? n : !1,
|
|
436
|
+
contextualErrorMap: s == null ? void 0 : s.errorMap
|
|
437
437
|
},
|
|
438
|
-
path: (
|
|
438
|
+
path: (s == null ? void 0 : s.path) || [],
|
|
439
439
|
schemaErrorMap: this._def.errorMap,
|
|
440
440
|
parent: null,
|
|
441
441
|
data: e,
|
|
442
|
-
parsedType:
|
|
442
|
+
parsedType: q(e)
|
|
443
443
|
}, a = this._parseSync({ data: e, path: r.path, parent: r });
|
|
444
444
|
return je(r, a);
|
|
445
445
|
}
|
|
446
|
-
async parseAsync(e,
|
|
447
|
-
const n = await this.safeParseAsync(e,
|
|
446
|
+
async parseAsync(e, s) {
|
|
447
|
+
const n = await this.safeParseAsync(e, s);
|
|
448
448
|
if (n.success)
|
|
449
449
|
return n.data;
|
|
450
450
|
throw n.error;
|
|
451
451
|
}
|
|
452
|
-
async safeParseAsync(e,
|
|
452
|
+
async safeParseAsync(e, s) {
|
|
453
453
|
const n = {
|
|
454
454
|
common: {
|
|
455
455
|
issues: [],
|
|
456
|
-
contextualErrorMap:
|
|
456
|
+
contextualErrorMap: s == null ? void 0 : s.errorMap,
|
|
457
457
|
async: !0
|
|
458
458
|
},
|
|
459
|
-
path: (
|
|
459
|
+
path: (s == null ? void 0 : s.path) || [],
|
|
460
460
|
schemaErrorMap: this._def.errorMap,
|
|
461
461
|
parent: null,
|
|
462
462
|
data: e,
|
|
463
|
-
parsedType:
|
|
464
|
-
}, r = this._parse({ data: e, path: n.path, parent: n }), a = await (
|
|
463
|
+
parsedType: q(e)
|
|
464
|
+
}, r = this._parse({ data: e, path: n.path, parent: n }), a = await (ne(r) ? r : Promise.resolve(r));
|
|
465
465
|
return je(n, a);
|
|
466
466
|
}
|
|
467
|
-
refine(e,
|
|
468
|
-
const n = (r) => typeof
|
|
467
|
+
refine(e, s) {
|
|
468
|
+
const n = (r) => typeof s == "string" || typeof s > "u" ? { message: s } : typeof s == "function" ? s(r) : s;
|
|
469
469
|
return this._refinement((r, a) => {
|
|
470
470
|
const i = e(r), o = () => a.addIssue({
|
|
471
|
-
code:
|
|
471
|
+
code: c.custom,
|
|
472
472
|
...n(r)
|
|
473
473
|
});
|
|
474
474
|
return typeof Promise < "u" && i instanceof Promise ? i.then((u) => u ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
475
475
|
});
|
|
476
476
|
}
|
|
477
|
-
refinement(e,
|
|
478
|
-
return this._refinement((n, r) => e(n) ? !0 : (r.addIssue(typeof
|
|
477
|
+
refinement(e, s) {
|
|
478
|
+
return this._refinement((n, r) => e(n) ? !0 : (r.addIssue(typeof s == "function" ? s(n, r) : s), !1));
|
|
479
479
|
}
|
|
480
480
|
_refinement(e) {
|
|
481
|
-
return new
|
|
481
|
+
return new N({
|
|
482
482
|
schema: this,
|
|
483
|
-
typeName:
|
|
483
|
+
typeName: m.ZodEffects,
|
|
484
484
|
effect: { type: "refinement", refinement: e }
|
|
485
485
|
});
|
|
486
486
|
}
|
|
@@ -488,71 +488,71 @@ class v {
|
|
|
488
488
|
return this._refinement(e);
|
|
489
489
|
}
|
|
490
490
|
optional() {
|
|
491
|
-
return
|
|
491
|
+
return I.create(this, this._def);
|
|
492
492
|
}
|
|
493
493
|
nullable() {
|
|
494
|
-
return
|
|
494
|
+
return V.create(this, this._def);
|
|
495
495
|
}
|
|
496
496
|
nullish() {
|
|
497
497
|
return this.nullable().optional();
|
|
498
498
|
}
|
|
499
499
|
array() {
|
|
500
|
-
return
|
|
500
|
+
return Z.create(this, this._def);
|
|
501
501
|
}
|
|
502
502
|
promise() {
|
|
503
|
-
return
|
|
503
|
+
return X.create(this, this._def);
|
|
504
504
|
}
|
|
505
505
|
or(e) {
|
|
506
|
-
return
|
|
506
|
+
return oe.create([this, e], this._def);
|
|
507
507
|
}
|
|
508
508
|
and(e) {
|
|
509
|
-
return
|
|
509
|
+
return ce.create(this, e, this._def);
|
|
510
510
|
}
|
|
511
511
|
transform(e) {
|
|
512
|
-
return new
|
|
513
|
-
...
|
|
512
|
+
return new N({
|
|
513
|
+
...v(this._def),
|
|
514
514
|
schema: this,
|
|
515
|
-
typeName:
|
|
515
|
+
typeName: m.ZodEffects,
|
|
516
516
|
effect: { type: "transform", transform: e }
|
|
517
517
|
});
|
|
518
518
|
}
|
|
519
519
|
default(e) {
|
|
520
|
-
const
|
|
521
|
-
return new
|
|
522
|
-
...
|
|
520
|
+
const s = typeof e == "function" ? e : () => e;
|
|
521
|
+
return new he({
|
|
522
|
+
...v(this._def),
|
|
523
523
|
innerType: this,
|
|
524
|
-
defaultValue:
|
|
525
|
-
typeName:
|
|
524
|
+
defaultValue: s,
|
|
525
|
+
typeName: m.ZodDefault
|
|
526
526
|
});
|
|
527
527
|
}
|
|
528
528
|
brand() {
|
|
529
|
-
return new
|
|
530
|
-
typeName:
|
|
529
|
+
return new Oe({
|
|
530
|
+
typeName: m.ZodBranded,
|
|
531
531
|
type: this,
|
|
532
|
-
...
|
|
532
|
+
...v(this._def)
|
|
533
533
|
});
|
|
534
534
|
}
|
|
535
535
|
catch(e) {
|
|
536
|
-
const
|
|
537
|
-
return new
|
|
538
|
-
...
|
|
536
|
+
const s = typeof e == "function" ? e : () => e;
|
|
537
|
+
return new pe({
|
|
538
|
+
...v(this._def),
|
|
539
539
|
innerType: this,
|
|
540
|
-
catchValue:
|
|
541
|
-
typeName:
|
|
540
|
+
catchValue: s,
|
|
541
|
+
typeName: m.ZodCatch
|
|
542
542
|
});
|
|
543
543
|
}
|
|
544
544
|
describe(e) {
|
|
545
|
-
const
|
|
546
|
-
return new
|
|
545
|
+
const s = this.constructor;
|
|
546
|
+
return new s({
|
|
547
547
|
...this._def,
|
|
548
548
|
description: e
|
|
549
549
|
});
|
|
550
550
|
}
|
|
551
551
|
pipe(e) {
|
|
552
|
-
return
|
|
552
|
+
return ge.create(this, e);
|
|
553
553
|
}
|
|
554
554
|
readonly() {
|
|
555
|
-
return
|
|
555
|
+
return me.create(this);
|
|
556
556
|
}
|
|
557
557
|
isOptional() {
|
|
558
558
|
return this.safeParse(void 0).success;
|
|
@@ -561,40 +561,40 @@ class v {
|
|
|
561
561
|
return this.safeParse(null).success;
|
|
562
562
|
}
|
|
563
563
|
}
|
|
564
|
-
const
|
|
565
|
-
let
|
|
566
|
-
const
|
|
567
|
-
function Ve(
|
|
564
|
+
const it = /^c[^\s-]{8,}$/i, ot = /^[0-9a-z]+$/, ct = /^[0-9A-HJKMNP-TV-Z]{26}$/, dt = /^[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, ut = /^[a-z0-9_-]{21}$/i, lt = /^[-+]?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)?)??$/, ft = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, ht = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
565
|
+
let Ce;
|
|
566
|
+
const pt = /^(?:(?: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])$/, mt = /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/, gt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Le = "((\\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])))", yt = new RegExp(`^${Le}$`);
|
|
567
|
+
function Ve(t) {
|
|
568
568
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
569
|
-
return
|
|
569
|
+
return t.precision ? e = `${e}\\.\\d{${t.precision}}` : t.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
570
570
|
}
|
|
571
|
-
function
|
|
572
|
-
return new RegExp(`^${Ve(
|
|
571
|
+
function vt(t) {
|
|
572
|
+
return new RegExp(`^${Ve(t)}$`);
|
|
573
573
|
}
|
|
574
|
-
function De(
|
|
575
|
-
let e = `${
|
|
576
|
-
const
|
|
577
|
-
return
|
|
574
|
+
function De(t) {
|
|
575
|
+
let e = `${Le}T${Ve(t)}`;
|
|
576
|
+
const s = [];
|
|
577
|
+
return s.push(t.local ? "Z?" : "Z"), t.offset && s.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${s.join("|")})`, new RegExp(`^${e}$`);
|
|
578
578
|
}
|
|
579
|
-
function
|
|
580
|
-
return !!((e === "v4" || !e) &&
|
|
579
|
+
function _t(t, e) {
|
|
580
|
+
return !!((e === "v4" || !e) && pt.test(t) || (e === "v6" || !e) && mt.test(t));
|
|
581
581
|
}
|
|
582
|
-
class C extends
|
|
582
|
+
class C extends _ {
|
|
583
583
|
_parse(e) {
|
|
584
584
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
|
|
585
585
|
const a = this._getOrReturnCtx(e);
|
|
586
586
|
return l(a, {
|
|
587
|
-
code:
|
|
587
|
+
code: c.invalid_type,
|
|
588
588
|
expected: f.string,
|
|
589
589
|
received: a.parsedType
|
|
590
|
-
}),
|
|
590
|
+
}), y;
|
|
591
591
|
}
|
|
592
|
-
const n = new
|
|
592
|
+
const n = new S();
|
|
593
593
|
let r;
|
|
594
594
|
for (const a of this._def.checks)
|
|
595
595
|
if (a.kind === "min")
|
|
596
596
|
e.data.length < a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
597
|
-
code:
|
|
597
|
+
code: c.too_small,
|
|
598
598
|
minimum: a.value,
|
|
599
599
|
type: "string",
|
|
600
600
|
inclusive: !0,
|
|
@@ -603,7 +603,7 @@ class C extends v {
|
|
|
603
603
|
}), n.dirty());
|
|
604
604
|
else if (a.kind === "max")
|
|
605
605
|
e.data.length > a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
606
|
-
code:
|
|
606
|
+
code: c.too_big,
|
|
607
607
|
maximum: a.value,
|
|
608
608
|
type: "string",
|
|
609
609
|
inclusive: !0,
|
|
@@ -613,14 +613,14 @@ class C extends v {
|
|
|
613
613
|
else if (a.kind === "length") {
|
|
614
614
|
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
615
615
|
(i || o) && (r = this._getOrReturnCtx(e, r), i ? l(r, {
|
|
616
|
-
code:
|
|
616
|
+
code: c.too_big,
|
|
617
617
|
maximum: a.value,
|
|
618
618
|
type: "string",
|
|
619
619
|
inclusive: !0,
|
|
620
620
|
exact: !0,
|
|
621
621
|
message: a.message
|
|
622
622
|
}) : o && l(r, {
|
|
623
|
-
code:
|
|
623
|
+
code: c.too_small,
|
|
624
624
|
minimum: a.value,
|
|
625
625
|
type: "string",
|
|
626
626
|
inclusive: !0,
|
|
@@ -628,45 +628,45 @@ class C extends v {
|
|
|
628
628
|
message: a.message
|
|
629
629
|
}), n.dirty());
|
|
630
630
|
} else if (a.kind === "email")
|
|
631
|
-
|
|
631
|
+
ft.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
632
632
|
validation: "email",
|
|
633
|
-
code:
|
|
633
|
+
code: c.invalid_string,
|
|
634
634
|
message: a.message
|
|
635
635
|
}), n.dirty());
|
|
636
636
|
else if (a.kind === "emoji")
|
|
637
|
-
|
|
637
|
+
Ce || (Ce = new RegExp(ht, "u")), Ce.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
638
638
|
validation: "emoji",
|
|
639
|
-
code:
|
|
639
|
+
code: c.invalid_string,
|
|
640
640
|
message: a.message
|
|
641
641
|
}), n.dirty());
|
|
642
642
|
else if (a.kind === "uuid")
|
|
643
|
-
|
|
643
|
+
dt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
644
644
|
validation: "uuid",
|
|
645
|
-
code:
|
|
645
|
+
code: c.invalid_string,
|
|
646
646
|
message: a.message
|
|
647
647
|
}), n.dirty());
|
|
648
648
|
else if (a.kind === "nanoid")
|
|
649
|
-
|
|
649
|
+
ut.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
650
650
|
validation: "nanoid",
|
|
651
|
-
code:
|
|
651
|
+
code: c.invalid_string,
|
|
652
652
|
message: a.message
|
|
653
653
|
}), n.dirty());
|
|
654
654
|
else if (a.kind === "cuid")
|
|
655
|
-
|
|
655
|
+
it.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
656
656
|
validation: "cuid",
|
|
657
|
-
code:
|
|
657
|
+
code: c.invalid_string,
|
|
658
658
|
message: a.message
|
|
659
659
|
}), n.dirty());
|
|
660
660
|
else if (a.kind === "cuid2")
|
|
661
|
-
|
|
661
|
+
ot.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
662
662
|
validation: "cuid2",
|
|
663
|
-
code:
|
|
663
|
+
code: c.invalid_string,
|
|
664
664
|
message: a.message
|
|
665
665
|
}), n.dirty());
|
|
666
666
|
else if (a.kind === "ulid")
|
|
667
|
-
|
|
667
|
+
ct.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
668
668
|
validation: "ulid",
|
|
669
|
-
code:
|
|
669
|
+
code: c.invalid_string,
|
|
670
670
|
message: a.message
|
|
671
671
|
}), n.dirty());
|
|
672
672
|
else if (a.kind === "url")
|
|
@@ -675,59 +675,59 @@ class C extends v {
|
|
|
675
675
|
} catch {
|
|
676
676
|
r = this._getOrReturnCtx(e, r), l(r, {
|
|
677
677
|
validation: "url",
|
|
678
|
-
code:
|
|
678
|
+
code: c.invalid_string,
|
|
679
679
|
message: a.message
|
|
680
680
|
}), n.dirty();
|
|
681
681
|
}
|
|
682
682
|
else
|
|
683
683
|
a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
684
684
|
validation: "regex",
|
|
685
|
-
code:
|
|
685
|
+
code: c.invalid_string,
|
|
686
686
|
message: a.message
|
|
687
687
|
}), n.dirty())) : a.kind === "trim" ? e.data = e.data.trim() : a.kind === "includes" ? e.data.includes(a.value, a.position) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
688
|
-
code:
|
|
688
|
+
code: c.invalid_string,
|
|
689
689
|
validation: { includes: a.value, position: a.position },
|
|
690
690
|
message: a.message
|
|
691
691
|
}), n.dirty()) : a.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : a.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : a.kind === "startsWith" ? e.data.startsWith(a.value) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
692
|
-
code:
|
|
692
|
+
code: c.invalid_string,
|
|
693
693
|
validation: { startsWith: a.value },
|
|
694
694
|
message: a.message
|
|
695
695
|
}), n.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
696
|
-
code:
|
|
696
|
+
code: c.invalid_string,
|
|
697
697
|
validation: { endsWith: a.value },
|
|
698
698
|
message: a.message
|
|
699
699
|
}), n.dirty()) : a.kind === "datetime" ? De(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
700
|
-
code:
|
|
700
|
+
code: c.invalid_string,
|
|
701
701
|
validation: "datetime",
|
|
702
702
|
message: a.message
|
|
703
|
-
}), n.dirty()) : a.kind === "date" ?
|
|
704
|
-
code:
|
|
703
|
+
}), n.dirty()) : a.kind === "date" ? yt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
704
|
+
code: c.invalid_string,
|
|
705
705
|
validation: "date",
|
|
706
706
|
message: a.message
|
|
707
|
-
}), n.dirty()) : a.kind === "time" ?
|
|
708
|
-
code:
|
|
707
|
+
}), n.dirty()) : a.kind === "time" ? vt(a).test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
708
|
+
code: c.invalid_string,
|
|
709
709
|
validation: "time",
|
|
710
710
|
message: a.message
|
|
711
|
-
}), n.dirty()) : a.kind === "duration" ?
|
|
711
|
+
}), n.dirty()) : a.kind === "duration" ? lt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
712
712
|
validation: "duration",
|
|
713
|
-
code:
|
|
713
|
+
code: c.invalid_string,
|
|
714
714
|
message: a.message
|
|
715
|
-
}), n.dirty()) : a.kind === "ip" ?
|
|
715
|
+
}), n.dirty()) : a.kind === "ip" ? _t(e.data, a.version) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
716
716
|
validation: "ip",
|
|
717
|
-
code:
|
|
717
|
+
code: c.invalid_string,
|
|
718
718
|
message: a.message
|
|
719
|
-
}), n.dirty()) : a.kind === "base64" ?
|
|
719
|
+
}), n.dirty()) : a.kind === "base64" ? gt.test(e.data) || (r = this._getOrReturnCtx(e, r), l(r, {
|
|
720
720
|
validation: "base64",
|
|
721
|
-
code:
|
|
721
|
+
code: c.invalid_string,
|
|
722
722
|
message: a.message
|
|
723
|
-
}), n.dirty()) :
|
|
723
|
+
}), n.dirty()) : x.assertNever(a);
|
|
724
724
|
return { status: n.value, value: e.data };
|
|
725
725
|
}
|
|
726
|
-
_regex(e,
|
|
726
|
+
_regex(e, s, n) {
|
|
727
727
|
return this.refinement((r) => e.test(r), {
|
|
728
|
-
validation:
|
|
729
|
-
code:
|
|
730
|
-
...
|
|
728
|
+
validation: s,
|
|
729
|
+
code: c.invalid_string,
|
|
730
|
+
...p.errToObj(n)
|
|
731
731
|
});
|
|
732
732
|
}
|
|
733
733
|
_addCheck(e) {
|
|
@@ -737,37 +737,37 @@ class C extends v {
|
|
|
737
737
|
});
|
|
738
738
|
}
|
|
739
739
|
email(e) {
|
|
740
|
-
return this._addCheck({ kind: "email", ...
|
|
740
|
+
return this._addCheck({ kind: "email", ...p.errToObj(e) });
|
|
741
741
|
}
|
|
742
742
|
url(e) {
|
|
743
|
-
return this._addCheck({ kind: "url", ...
|
|
743
|
+
return this._addCheck({ kind: "url", ...p.errToObj(e) });
|
|
744
744
|
}
|
|
745
745
|
emoji(e) {
|
|
746
|
-
return this._addCheck({ kind: "emoji", ...
|
|
746
|
+
return this._addCheck({ kind: "emoji", ...p.errToObj(e) });
|
|
747
747
|
}
|
|
748
748
|
uuid(e) {
|
|
749
|
-
return this._addCheck({ kind: "uuid", ...
|
|
749
|
+
return this._addCheck({ kind: "uuid", ...p.errToObj(e) });
|
|
750
750
|
}
|
|
751
751
|
nanoid(e) {
|
|
752
|
-
return this._addCheck({ kind: "nanoid", ...
|
|
752
|
+
return this._addCheck({ kind: "nanoid", ...p.errToObj(e) });
|
|
753
753
|
}
|
|
754
754
|
cuid(e) {
|
|
755
|
-
return this._addCheck({ kind: "cuid", ...
|
|
755
|
+
return this._addCheck({ kind: "cuid", ...p.errToObj(e) });
|
|
756
756
|
}
|
|
757
757
|
cuid2(e) {
|
|
758
|
-
return this._addCheck({ kind: "cuid2", ...
|
|
758
|
+
return this._addCheck({ kind: "cuid2", ...p.errToObj(e) });
|
|
759
759
|
}
|
|
760
760
|
ulid(e) {
|
|
761
|
-
return this._addCheck({ kind: "ulid", ...
|
|
761
|
+
return this._addCheck({ kind: "ulid", ...p.errToObj(e) });
|
|
762
762
|
}
|
|
763
763
|
base64(e) {
|
|
764
|
-
return this._addCheck({ kind: "base64", ...
|
|
764
|
+
return this._addCheck({ kind: "base64", ...p.errToObj(e) });
|
|
765
765
|
}
|
|
766
766
|
ip(e) {
|
|
767
|
-
return this._addCheck({ kind: "ip", ...
|
|
767
|
+
return this._addCheck({ kind: "ip", ...p.errToObj(e) });
|
|
768
768
|
}
|
|
769
769
|
datetime(e) {
|
|
770
|
-
var
|
|
770
|
+
var s, n;
|
|
771
771
|
return typeof e == "string" ? this._addCheck({
|
|
772
772
|
kind: "datetime",
|
|
773
773
|
precision: null,
|
|
@@ -777,9 +777,9 @@ class C extends v {
|
|
|
777
777
|
}) : this._addCheck({
|
|
778
778
|
kind: "datetime",
|
|
779
779
|
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
780
|
-
offset: (
|
|
780
|
+
offset: (s = e == null ? void 0 : e.offset) !== null && s !== void 0 ? s : !1,
|
|
781
781
|
local: (n = e == null ? void 0 : e.local) !== null && n !== void 0 ? n : !1,
|
|
782
|
-
...
|
|
782
|
+
...p.errToObj(e == null ? void 0 : e.message)
|
|
783
783
|
});
|
|
784
784
|
}
|
|
785
785
|
date(e) {
|
|
@@ -793,60 +793,60 @@ class C extends v {
|
|
|
793
793
|
}) : this._addCheck({
|
|
794
794
|
kind: "time",
|
|
795
795
|
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
796
|
-
...
|
|
796
|
+
...p.errToObj(e == null ? void 0 : e.message)
|
|
797
797
|
});
|
|
798
798
|
}
|
|
799
799
|
duration(e) {
|
|
800
|
-
return this._addCheck({ kind: "duration", ...
|
|
800
|
+
return this._addCheck({ kind: "duration", ...p.errToObj(e) });
|
|
801
801
|
}
|
|
802
|
-
regex(e,
|
|
802
|
+
regex(e, s) {
|
|
803
803
|
return this._addCheck({
|
|
804
804
|
kind: "regex",
|
|
805
805
|
regex: e,
|
|
806
|
-
...
|
|
806
|
+
...p.errToObj(s)
|
|
807
807
|
});
|
|
808
808
|
}
|
|
809
|
-
includes(e,
|
|
809
|
+
includes(e, s) {
|
|
810
810
|
return this._addCheck({
|
|
811
811
|
kind: "includes",
|
|
812
812
|
value: e,
|
|
813
|
-
position:
|
|
814
|
-
...
|
|
813
|
+
position: s == null ? void 0 : s.position,
|
|
814
|
+
...p.errToObj(s == null ? void 0 : s.message)
|
|
815
815
|
});
|
|
816
816
|
}
|
|
817
|
-
startsWith(e,
|
|
817
|
+
startsWith(e, s) {
|
|
818
818
|
return this._addCheck({
|
|
819
819
|
kind: "startsWith",
|
|
820
820
|
value: e,
|
|
821
|
-
...
|
|
821
|
+
...p.errToObj(s)
|
|
822
822
|
});
|
|
823
823
|
}
|
|
824
|
-
endsWith(e,
|
|
824
|
+
endsWith(e, s) {
|
|
825
825
|
return this._addCheck({
|
|
826
826
|
kind: "endsWith",
|
|
827
827
|
value: e,
|
|
828
|
-
...
|
|
828
|
+
...p.errToObj(s)
|
|
829
829
|
});
|
|
830
830
|
}
|
|
831
|
-
min(e,
|
|
831
|
+
min(e, s) {
|
|
832
832
|
return this._addCheck({
|
|
833
833
|
kind: "min",
|
|
834
834
|
value: e,
|
|
835
|
-
...
|
|
835
|
+
...p.errToObj(s)
|
|
836
836
|
});
|
|
837
837
|
}
|
|
838
|
-
max(e,
|
|
838
|
+
max(e, s) {
|
|
839
839
|
return this._addCheck({
|
|
840
840
|
kind: "max",
|
|
841
841
|
value: e,
|
|
842
|
-
...
|
|
842
|
+
...p.errToObj(s)
|
|
843
843
|
});
|
|
844
844
|
}
|
|
845
|
-
length(e,
|
|
845
|
+
length(e, s) {
|
|
846
846
|
return this._addCheck({
|
|
847
847
|
kind: "length",
|
|
848
848
|
value: e,
|
|
849
|
-
...
|
|
849
|
+
...p.errToObj(s)
|
|
850
850
|
});
|
|
851
851
|
}
|
|
852
852
|
/**
|
|
@@ -854,7 +854,7 @@ class C extends v {
|
|
|
854
854
|
* @see {@link ZodString.min}
|
|
855
855
|
*/
|
|
856
856
|
nonempty(e) {
|
|
857
|
-
return this.min(1,
|
|
857
|
+
return this.min(1, p.errToObj(e));
|
|
858
858
|
}
|
|
859
859
|
trim() {
|
|
860
860
|
return new C({
|
|
@@ -918,31 +918,31 @@ class C extends v {
|
|
|
918
918
|
}
|
|
919
919
|
get minLength() {
|
|
920
920
|
let e = null;
|
|
921
|
-
for (const
|
|
922
|
-
|
|
921
|
+
for (const s of this._def.checks)
|
|
922
|
+
s.kind === "min" && (e === null || s.value > e) && (e = s.value);
|
|
923
923
|
return e;
|
|
924
924
|
}
|
|
925
925
|
get maxLength() {
|
|
926
926
|
let e = null;
|
|
927
|
-
for (const
|
|
928
|
-
|
|
927
|
+
for (const s of this._def.checks)
|
|
928
|
+
s.kind === "max" && (e === null || s.value < e) && (e = s.value);
|
|
929
929
|
return e;
|
|
930
930
|
}
|
|
931
931
|
}
|
|
932
|
-
C.create = (
|
|
932
|
+
C.create = (t) => {
|
|
933
933
|
var e;
|
|
934
934
|
return new C({
|
|
935
935
|
checks: [],
|
|
936
|
-
typeName:
|
|
937
|
-
coerce: (e =
|
|
938
|
-
...
|
|
936
|
+
typeName: m.ZodString,
|
|
937
|
+
coerce: (e = t == null ? void 0 : t.coerce) !== null && e !== void 0 ? e : !1,
|
|
938
|
+
...v(t)
|
|
939
939
|
});
|
|
940
940
|
};
|
|
941
|
-
function
|
|
942
|
-
const
|
|
941
|
+
function xt(t, e) {
|
|
942
|
+
const s = (t.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, r = s > n ? s : n, a = parseInt(t.toFixed(r).replace(".", "")), i = parseInt(e.toFixed(r).replace(".", ""));
|
|
943
943
|
return a % i / Math.pow(10, r);
|
|
944
944
|
}
|
|
945
|
-
class
|
|
945
|
+
class $ extends _ {
|
|
946
946
|
constructor() {
|
|
947
947
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
948
948
|
}
|
|
@@ -950,71 +950,71 @@ class P extends v {
|
|
|
950
950
|
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== f.number) {
|
|
951
951
|
const a = this._getOrReturnCtx(e);
|
|
952
952
|
return l(a, {
|
|
953
|
-
code:
|
|
953
|
+
code: c.invalid_type,
|
|
954
954
|
expected: f.number,
|
|
955
955
|
received: a.parsedType
|
|
956
|
-
}),
|
|
956
|
+
}), y;
|
|
957
957
|
}
|
|
958
958
|
let n;
|
|
959
|
-
const r = new
|
|
959
|
+
const r = new S();
|
|
960
960
|
for (const a of this._def.checks)
|
|
961
|
-
a.kind === "int" ?
|
|
962
|
-
code:
|
|
961
|
+
a.kind === "int" ? x.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
962
|
+
code: c.invalid_type,
|
|
963
963
|
expected: "integer",
|
|
964
964
|
received: "float",
|
|
965
965
|
message: a.message
|
|
966
966
|
}), r.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
967
|
-
code:
|
|
967
|
+
code: c.too_small,
|
|
968
968
|
minimum: a.value,
|
|
969
969
|
type: "number",
|
|
970
970
|
inclusive: a.inclusive,
|
|
971
971
|
exact: !1,
|
|
972
972
|
message: a.message
|
|
973
973
|
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
974
|
-
code:
|
|
974
|
+
code: c.too_big,
|
|
975
975
|
maximum: a.value,
|
|
976
976
|
type: "number",
|
|
977
977
|
inclusive: a.inclusive,
|
|
978
978
|
exact: !1,
|
|
979
979
|
message: a.message
|
|
980
|
-
}), r.dirty()) : a.kind === "multipleOf" ?
|
|
981
|
-
code:
|
|
980
|
+
}), r.dirty()) : a.kind === "multipleOf" ? xt(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
981
|
+
code: c.not_multiple_of,
|
|
982
982
|
multipleOf: a.value,
|
|
983
983
|
message: a.message
|
|
984
984
|
}), r.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), l(n, {
|
|
985
|
-
code:
|
|
985
|
+
code: c.not_finite,
|
|
986
986
|
message: a.message
|
|
987
|
-
}), r.dirty()) :
|
|
987
|
+
}), r.dirty()) : x.assertNever(a);
|
|
988
988
|
return { status: r.value, value: e.data };
|
|
989
989
|
}
|
|
990
|
-
gte(e,
|
|
991
|
-
return this.setLimit("min", e, !0,
|
|
990
|
+
gte(e, s) {
|
|
991
|
+
return this.setLimit("min", e, !0, p.toString(s));
|
|
992
992
|
}
|
|
993
|
-
gt(e,
|
|
994
|
-
return this.setLimit("min", e, !1,
|
|
993
|
+
gt(e, s) {
|
|
994
|
+
return this.setLimit("min", e, !1, p.toString(s));
|
|
995
995
|
}
|
|
996
|
-
lte(e,
|
|
997
|
-
return this.setLimit("max", e, !0,
|
|
996
|
+
lte(e, s) {
|
|
997
|
+
return this.setLimit("max", e, !0, p.toString(s));
|
|
998
998
|
}
|
|
999
|
-
lt(e,
|
|
1000
|
-
return this.setLimit("max", e, !1,
|
|
999
|
+
lt(e, s) {
|
|
1000
|
+
return this.setLimit("max", e, !1, p.toString(s));
|
|
1001
1001
|
}
|
|
1002
|
-
setLimit(e,
|
|
1003
|
-
return new
|
|
1002
|
+
setLimit(e, s, n, r) {
|
|
1003
|
+
return new $({
|
|
1004
1004
|
...this._def,
|
|
1005
1005
|
checks: [
|
|
1006
1006
|
...this._def.checks,
|
|
1007
1007
|
{
|
|
1008
1008
|
kind: e,
|
|
1009
|
-
value:
|
|
1009
|
+
value: s,
|
|
1010
1010
|
inclusive: n,
|
|
1011
|
-
message:
|
|
1011
|
+
message: p.toString(r)
|
|
1012
1012
|
}
|
|
1013
1013
|
]
|
|
1014
1014
|
});
|
|
1015
1015
|
}
|
|
1016
1016
|
_addCheck(e) {
|
|
1017
|
-
return new
|
|
1017
|
+
return new $({
|
|
1018
1018
|
...this._def,
|
|
1019
1019
|
checks: [...this._def.checks, e]
|
|
1020
1020
|
});
|
|
@@ -1022,7 +1022,7 @@ class P extends v {
|
|
|
1022
1022
|
int(e) {
|
|
1023
1023
|
return this._addCheck({
|
|
1024
1024
|
kind: "int",
|
|
1025
|
-
message:
|
|
1025
|
+
message: p.toString(e)
|
|
1026
1026
|
});
|
|
1027
1027
|
}
|
|
1028
1028
|
positive(e) {
|
|
@@ -1030,7 +1030,7 @@ class P extends v {
|
|
|
1030
1030
|
kind: "min",
|
|
1031
1031
|
value: 0,
|
|
1032
1032
|
inclusive: !1,
|
|
1033
|
-
message:
|
|
1033
|
+
message: p.toString(e)
|
|
1034
1034
|
});
|
|
1035
1035
|
}
|
|
1036
1036
|
negative(e) {
|
|
@@ -1038,7 +1038,7 @@ class P extends v {
|
|
|
1038
1038
|
kind: "max",
|
|
1039
1039
|
value: 0,
|
|
1040
1040
|
inclusive: !1,
|
|
1041
|
-
message:
|
|
1041
|
+
message: p.toString(e)
|
|
1042
1042
|
});
|
|
1043
1043
|
}
|
|
1044
1044
|
nonpositive(e) {
|
|
@@ -1046,7 +1046,7 @@ class P extends v {
|
|
|
1046
1046
|
kind: "max",
|
|
1047
1047
|
value: 0,
|
|
1048
1048
|
inclusive: !0,
|
|
1049
|
-
message:
|
|
1049
|
+
message: p.toString(e)
|
|
1050
1050
|
});
|
|
1051
1051
|
}
|
|
1052
1052
|
nonnegative(e) {
|
|
@@ -1054,20 +1054,20 @@ class P extends v {
|
|
|
1054
1054
|
kind: "min",
|
|
1055
1055
|
value: 0,
|
|
1056
1056
|
inclusive: !0,
|
|
1057
|
-
message:
|
|
1057
|
+
message: p.toString(e)
|
|
1058
1058
|
});
|
|
1059
1059
|
}
|
|
1060
|
-
multipleOf(e,
|
|
1060
|
+
multipleOf(e, s) {
|
|
1061
1061
|
return this._addCheck({
|
|
1062
1062
|
kind: "multipleOf",
|
|
1063
1063
|
value: e,
|
|
1064
|
-
message:
|
|
1064
|
+
message: p.toString(s)
|
|
1065
1065
|
});
|
|
1066
1066
|
}
|
|
1067
1067
|
finite(e) {
|
|
1068
1068
|
return this._addCheck({
|
|
1069
1069
|
kind: "finite",
|
|
1070
|
-
message:
|
|
1070
|
+
message: p.toString(e)
|
|
1071
1071
|
});
|
|
1072
1072
|
}
|
|
1073
1073
|
safe(e) {
|
|
@@ -1075,46 +1075,46 @@ class P extends v {
|
|
|
1075
1075
|
kind: "min",
|
|
1076
1076
|
inclusive: !0,
|
|
1077
1077
|
value: Number.MIN_SAFE_INTEGER,
|
|
1078
|
-
message:
|
|
1078
|
+
message: p.toString(e)
|
|
1079
1079
|
})._addCheck({
|
|
1080
1080
|
kind: "max",
|
|
1081
1081
|
inclusive: !0,
|
|
1082
1082
|
value: Number.MAX_SAFE_INTEGER,
|
|
1083
|
-
message:
|
|
1083
|
+
message: p.toString(e)
|
|
1084
1084
|
});
|
|
1085
1085
|
}
|
|
1086
1086
|
get minValue() {
|
|
1087
1087
|
let e = null;
|
|
1088
|
-
for (const
|
|
1089
|
-
|
|
1088
|
+
for (const s of this._def.checks)
|
|
1089
|
+
s.kind === "min" && (e === null || s.value > e) && (e = s.value);
|
|
1090
1090
|
return e;
|
|
1091
1091
|
}
|
|
1092
1092
|
get maxValue() {
|
|
1093
1093
|
let e = null;
|
|
1094
|
-
for (const
|
|
1095
|
-
|
|
1094
|
+
for (const s of this._def.checks)
|
|
1095
|
+
s.kind === "max" && (e === null || s.value < e) && (e = s.value);
|
|
1096
1096
|
return e;
|
|
1097
1097
|
}
|
|
1098
1098
|
get isInt() {
|
|
1099
|
-
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" &&
|
|
1099
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && x.isInteger(e.value));
|
|
1100
1100
|
}
|
|
1101
1101
|
get isFinite() {
|
|
1102
|
-
let e = null,
|
|
1102
|
+
let e = null, s = null;
|
|
1103
1103
|
for (const n of this._def.checks) {
|
|
1104
1104
|
if (n.kind === "finite" || n.kind === "int" || n.kind === "multipleOf")
|
|
1105
1105
|
return !0;
|
|
1106
|
-
n.kind === "min" ? (
|
|
1106
|
+
n.kind === "min" ? (s === null || n.value > s) && (s = n.value) : n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1107
1107
|
}
|
|
1108
|
-
return Number.isFinite(
|
|
1108
|
+
return Number.isFinite(s) && Number.isFinite(e);
|
|
1109
1109
|
}
|
|
1110
1110
|
}
|
|
1111
|
-
|
|
1111
|
+
$.create = (t) => new $({
|
|
1112
1112
|
checks: [],
|
|
1113
|
-
typeName:
|
|
1114
|
-
coerce: (
|
|
1115
|
-
...
|
|
1113
|
+
typeName: m.ZodNumber,
|
|
1114
|
+
coerce: (t == null ? void 0 : t.coerce) || !1,
|
|
1115
|
+
...v(t)
|
|
1116
1116
|
});
|
|
1117
|
-
class
|
|
1117
|
+
class U extends _ {
|
|
1118
1118
|
constructor() {
|
|
1119
1119
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1120
1120
|
}
|
|
@@ -1122,61 +1122,61 @@ class $ extends v {
|
|
|
1122
1122
|
if (this._def.coerce && (e.data = BigInt(e.data)), this._getType(e) !== f.bigint) {
|
|
1123
1123
|
const a = this._getOrReturnCtx(e);
|
|
1124
1124
|
return l(a, {
|
|
1125
|
-
code:
|
|
1125
|
+
code: c.invalid_type,
|
|
1126
1126
|
expected: f.bigint,
|
|
1127
1127
|
received: a.parsedType
|
|
1128
|
-
}),
|
|
1128
|
+
}), y;
|
|
1129
1129
|
}
|
|
1130
1130
|
let n;
|
|
1131
|
-
const r = new
|
|
1131
|
+
const r = new S();
|
|
1132
1132
|
for (const a of this._def.checks)
|
|
1133
1133
|
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1134
|
-
code:
|
|
1134
|
+
code: c.too_small,
|
|
1135
1135
|
type: "bigint",
|
|
1136
1136
|
minimum: a.value,
|
|
1137
1137
|
inclusive: a.inclusive,
|
|
1138
1138
|
message: a.message
|
|
1139
1139
|
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1140
|
-
code:
|
|
1140
|
+
code: c.too_big,
|
|
1141
1141
|
type: "bigint",
|
|
1142
1142
|
maximum: a.value,
|
|
1143
1143
|
inclusive: a.inclusive,
|
|
1144
1144
|
message: a.message
|
|
1145
1145
|
}), r.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), l(n, {
|
|
1146
|
-
code:
|
|
1146
|
+
code: c.not_multiple_of,
|
|
1147
1147
|
multipleOf: a.value,
|
|
1148
1148
|
message: a.message
|
|
1149
|
-
}), r.dirty()) :
|
|
1149
|
+
}), r.dirty()) : x.assertNever(a);
|
|
1150
1150
|
return { status: r.value, value: e.data };
|
|
1151
1151
|
}
|
|
1152
|
-
gte(e,
|
|
1153
|
-
return this.setLimit("min", e, !0,
|
|
1152
|
+
gte(e, s) {
|
|
1153
|
+
return this.setLimit("min", e, !0, p.toString(s));
|
|
1154
1154
|
}
|
|
1155
|
-
gt(e,
|
|
1156
|
-
return this.setLimit("min", e, !1,
|
|
1155
|
+
gt(e, s) {
|
|
1156
|
+
return this.setLimit("min", e, !1, p.toString(s));
|
|
1157
1157
|
}
|
|
1158
|
-
lte(e,
|
|
1159
|
-
return this.setLimit("max", e, !0,
|
|
1158
|
+
lte(e, s) {
|
|
1159
|
+
return this.setLimit("max", e, !0, p.toString(s));
|
|
1160
1160
|
}
|
|
1161
|
-
lt(e,
|
|
1162
|
-
return this.setLimit("max", e, !1,
|
|
1161
|
+
lt(e, s) {
|
|
1162
|
+
return this.setLimit("max", e, !1, p.toString(s));
|
|
1163
1163
|
}
|
|
1164
|
-
setLimit(e,
|
|
1165
|
-
return new
|
|
1164
|
+
setLimit(e, s, n, r) {
|
|
1165
|
+
return new U({
|
|
1166
1166
|
...this._def,
|
|
1167
1167
|
checks: [
|
|
1168
1168
|
...this._def.checks,
|
|
1169
1169
|
{
|
|
1170
1170
|
kind: e,
|
|
1171
|
-
value:
|
|
1171
|
+
value: s,
|
|
1172
1172
|
inclusive: n,
|
|
1173
|
-
message:
|
|
1173
|
+
message: p.toString(r)
|
|
1174
1174
|
}
|
|
1175
1175
|
]
|
|
1176
1176
|
});
|
|
1177
1177
|
}
|
|
1178
1178
|
_addCheck(e) {
|
|
1179
|
-
return new
|
|
1179
|
+
return new U({
|
|
1180
1180
|
...this._def,
|
|
1181
1181
|
checks: [...this._def.checks, e]
|
|
1182
1182
|
});
|
|
@@ -1186,7 +1186,7 @@ class $ extends v {
|
|
|
1186
1186
|
kind: "min",
|
|
1187
1187
|
value: BigInt(0),
|
|
1188
1188
|
inclusive: !1,
|
|
1189
|
-
message:
|
|
1189
|
+
message: p.toString(e)
|
|
1190
1190
|
});
|
|
1191
1191
|
}
|
|
1192
1192
|
negative(e) {
|
|
@@ -1194,7 +1194,7 @@ class $ extends v {
|
|
|
1194
1194
|
kind: "max",
|
|
1195
1195
|
value: BigInt(0),
|
|
1196
1196
|
inclusive: !1,
|
|
1197
|
-
message:
|
|
1197
|
+
message: p.toString(e)
|
|
1198
1198
|
});
|
|
1199
1199
|
}
|
|
1200
1200
|
nonpositive(e) {
|
|
@@ -1202,7 +1202,7 @@ class $ extends v {
|
|
|
1202
1202
|
kind: "max",
|
|
1203
1203
|
value: BigInt(0),
|
|
1204
1204
|
inclusive: !0,
|
|
1205
|
-
message:
|
|
1205
|
+
message: p.toString(e)
|
|
1206
1206
|
});
|
|
1207
1207
|
}
|
|
1208
1208
|
nonnegative(e) {
|
|
@@ -1210,90 +1210,90 @@ class $ extends v {
|
|
|
1210
1210
|
kind: "min",
|
|
1211
1211
|
value: BigInt(0),
|
|
1212
1212
|
inclusive: !0,
|
|
1213
|
-
message:
|
|
1213
|
+
message: p.toString(e)
|
|
1214
1214
|
});
|
|
1215
1215
|
}
|
|
1216
|
-
multipleOf(e,
|
|
1216
|
+
multipleOf(e, s) {
|
|
1217
1217
|
return this._addCheck({
|
|
1218
1218
|
kind: "multipleOf",
|
|
1219
1219
|
value: e,
|
|
1220
|
-
message:
|
|
1220
|
+
message: p.toString(s)
|
|
1221
1221
|
});
|
|
1222
1222
|
}
|
|
1223
1223
|
get minValue() {
|
|
1224
1224
|
let e = null;
|
|
1225
|
-
for (const
|
|
1226
|
-
|
|
1225
|
+
for (const s of this._def.checks)
|
|
1226
|
+
s.kind === "min" && (e === null || s.value > e) && (e = s.value);
|
|
1227
1227
|
return e;
|
|
1228
1228
|
}
|
|
1229
1229
|
get maxValue() {
|
|
1230
1230
|
let e = null;
|
|
1231
|
-
for (const
|
|
1232
|
-
|
|
1231
|
+
for (const s of this._def.checks)
|
|
1232
|
+
s.kind === "max" && (e === null || s.value < e) && (e = s.value);
|
|
1233
1233
|
return e;
|
|
1234
1234
|
}
|
|
1235
1235
|
}
|
|
1236
|
-
|
|
1236
|
+
U.create = (t) => {
|
|
1237
1237
|
var e;
|
|
1238
|
-
return new
|
|
1238
|
+
return new U({
|
|
1239
1239
|
checks: [],
|
|
1240
|
-
typeName:
|
|
1241
|
-
coerce: (e =
|
|
1242
|
-
...
|
|
1240
|
+
typeName: m.ZodBigInt,
|
|
1241
|
+
coerce: (e = t == null ? void 0 : t.coerce) !== null && e !== void 0 ? e : !1,
|
|
1242
|
+
...v(t)
|
|
1243
1243
|
});
|
|
1244
1244
|
};
|
|
1245
|
-
class
|
|
1245
|
+
class re extends _ {
|
|
1246
1246
|
_parse(e) {
|
|
1247
1247
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== f.boolean) {
|
|
1248
1248
|
const n = this._getOrReturnCtx(e);
|
|
1249
1249
|
return l(n, {
|
|
1250
|
-
code:
|
|
1250
|
+
code: c.invalid_type,
|
|
1251
1251
|
expected: f.boolean,
|
|
1252
1252
|
received: n.parsedType
|
|
1253
|
-
}),
|
|
1253
|
+
}), y;
|
|
1254
1254
|
}
|
|
1255
1255
|
return T(e.data);
|
|
1256
1256
|
}
|
|
1257
1257
|
}
|
|
1258
|
-
|
|
1259
|
-
typeName:
|
|
1260
|
-
coerce: (
|
|
1261
|
-
...
|
|
1258
|
+
re.create = (t) => new re({
|
|
1259
|
+
typeName: m.ZodBoolean,
|
|
1260
|
+
coerce: (t == null ? void 0 : t.coerce) || !1,
|
|
1261
|
+
...v(t)
|
|
1262
1262
|
});
|
|
1263
|
-
class z extends
|
|
1263
|
+
class z extends _ {
|
|
1264
1264
|
_parse(e) {
|
|
1265
1265
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== f.date) {
|
|
1266
1266
|
const a = this._getOrReturnCtx(e);
|
|
1267
1267
|
return l(a, {
|
|
1268
|
-
code:
|
|
1268
|
+
code: c.invalid_type,
|
|
1269
1269
|
expected: f.date,
|
|
1270
1270
|
received: a.parsedType
|
|
1271
|
-
}),
|
|
1271
|
+
}), y;
|
|
1272
1272
|
}
|
|
1273
1273
|
if (isNaN(e.data.getTime())) {
|
|
1274
1274
|
const a = this._getOrReturnCtx(e);
|
|
1275
1275
|
return l(a, {
|
|
1276
|
-
code:
|
|
1277
|
-
}),
|
|
1276
|
+
code: c.invalid_date
|
|
1277
|
+
}), y;
|
|
1278
1278
|
}
|
|
1279
|
-
const n = new
|
|
1279
|
+
const n = new S();
|
|
1280
1280
|
let r;
|
|
1281
1281
|
for (const a of this._def.checks)
|
|
1282
1282
|
a.kind === "min" ? e.data.getTime() < a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1283
|
-
code:
|
|
1283
|
+
code: c.too_small,
|
|
1284
1284
|
message: a.message,
|
|
1285
1285
|
inclusive: !0,
|
|
1286
1286
|
exact: !1,
|
|
1287
1287
|
minimum: a.value,
|
|
1288
1288
|
type: "date"
|
|
1289
1289
|
}), n.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (r = this._getOrReturnCtx(e, r), l(r, {
|
|
1290
|
-
code:
|
|
1290
|
+
code: c.too_big,
|
|
1291
1291
|
message: a.message,
|
|
1292
1292
|
inclusive: !0,
|
|
1293
1293
|
exact: !1,
|
|
1294
1294
|
maximum: a.value,
|
|
1295
1295
|
type: "date"
|
|
1296
|
-
}), n.dirty()) :
|
|
1296
|
+
}), n.dirty()) : x.assertNever(a);
|
|
1297
1297
|
return {
|
|
1298
1298
|
status: n.value,
|
|
1299
1299
|
value: new Date(e.data.getTime())
|
|
@@ -1305,91 +1305,91 @@ class z extends v {
|
|
|
1305
1305
|
checks: [...this._def.checks, e]
|
|
1306
1306
|
});
|
|
1307
1307
|
}
|
|
1308
|
-
min(e,
|
|
1308
|
+
min(e, s) {
|
|
1309
1309
|
return this._addCheck({
|
|
1310
1310
|
kind: "min",
|
|
1311
1311
|
value: e.getTime(),
|
|
1312
|
-
message:
|
|
1312
|
+
message: p.toString(s)
|
|
1313
1313
|
});
|
|
1314
1314
|
}
|
|
1315
|
-
max(e,
|
|
1315
|
+
max(e, s) {
|
|
1316
1316
|
return this._addCheck({
|
|
1317
1317
|
kind: "max",
|
|
1318
1318
|
value: e.getTime(),
|
|
1319
|
-
message:
|
|
1319
|
+
message: p.toString(s)
|
|
1320
1320
|
});
|
|
1321
1321
|
}
|
|
1322
1322
|
get minDate() {
|
|
1323
1323
|
let e = null;
|
|
1324
|
-
for (const
|
|
1325
|
-
|
|
1324
|
+
for (const s of this._def.checks)
|
|
1325
|
+
s.kind === "min" && (e === null || s.value > e) && (e = s.value);
|
|
1326
1326
|
return e != null ? new Date(e) : null;
|
|
1327
1327
|
}
|
|
1328
1328
|
get maxDate() {
|
|
1329
1329
|
let e = null;
|
|
1330
|
-
for (const
|
|
1331
|
-
|
|
1330
|
+
for (const s of this._def.checks)
|
|
1331
|
+
s.kind === "max" && (e === null || s.value < e) && (e = s.value);
|
|
1332
1332
|
return e != null ? new Date(e) : null;
|
|
1333
1333
|
}
|
|
1334
1334
|
}
|
|
1335
|
-
z.create = (
|
|
1335
|
+
z.create = (t) => new z({
|
|
1336
1336
|
checks: [],
|
|
1337
|
-
coerce: (
|
|
1338
|
-
typeName:
|
|
1339
|
-
...
|
|
1337
|
+
coerce: (t == null ? void 0 : t.coerce) || !1,
|
|
1338
|
+
typeName: m.ZodDate,
|
|
1339
|
+
...v(t)
|
|
1340
1340
|
});
|
|
1341
|
-
class
|
|
1341
|
+
class we extends _ {
|
|
1342
1342
|
_parse(e) {
|
|
1343
1343
|
if (this._getType(e) !== f.symbol) {
|
|
1344
1344
|
const n = this._getOrReturnCtx(e);
|
|
1345
1345
|
return l(n, {
|
|
1346
|
-
code:
|
|
1346
|
+
code: c.invalid_type,
|
|
1347
1347
|
expected: f.symbol,
|
|
1348
1348
|
received: n.parsedType
|
|
1349
|
-
}),
|
|
1349
|
+
}), y;
|
|
1350
1350
|
}
|
|
1351
1351
|
return T(e.data);
|
|
1352
1352
|
}
|
|
1353
1353
|
}
|
|
1354
|
-
|
|
1355
|
-
typeName:
|
|
1356
|
-
...
|
|
1354
|
+
we.create = (t) => new we({
|
|
1355
|
+
typeName: m.ZodSymbol,
|
|
1356
|
+
...v(t)
|
|
1357
1357
|
});
|
|
1358
|
-
class
|
|
1358
|
+
class ae extends _ {
|
|
1359
1359
|
_parse(e) {
|
|
1360
1360
|
if (this._getType(e) !== f.undefined) {
|
|
1361
1361
|
const n = this._getOrReturnCtx(e);
|
|
1362
1362
|
return l(n, {
|
|
1363
|
-
code:
|
|
1363
|
+
code: c.invalid_type,
|
|
1364
1364
|
expected: f.undefined,
|
|
1365
1365
|
received: n.parsedType
|
|
1366
|
-
}),
|
|
1366
|
+
}), y;
|
|
1367
1367
|
}
|
|
1368
1368
|
return T(e.data);
|
|
1369
1369
|
}
|
|
1370
1370
|
}
|
|
1371
|
-
|
|
1372
|
-
typeName:
|
|
1373
|
-
...
|
|
1371
|
+
ae.create = (t) => new ae({
|
|
1372
|
+
typeName: m.ZodUndefined,
|
|
1373
|
+
...v(t)
|
|
1374
1374
|
});
|
|
1375
|
-
class
|
|
1375
|
+
class ie extends _ {
|
|
1376
1376
|
_parse(e) {
|
|
1377
1377
|
if (this._getType(e) !== f.null) {
|
|
1378
1378
|
const n = this._getOrReturnCtx(e);
|
|
1379
1379
|
return l(n, {
|
|
1380
|
-
code:
|
|
1380
|
+
code: c.invalid_type,
|
|
1381
1381
|
expected: f.null,
|
|
1382
1382
|
received: n.parsedType
|
|
1383
|
-
}),
|
|
1383
|
+
}), y;
|
|
1384
1384
|
}
|
|
1385
1385
|
return T(e.data);
|
|
1386
1386
|
}
|
|
1387
1387
|
}
|
|
1388
|
-
|
|
1389
|
-
typeName:
|
|
1390
|
-
...
|
|
1388
|
+
ie.create = (t) => new ie({
|
|
1389
|
+
typeName: m.ZodNull,
|
|
1390
|
+
...v(t)
|
|
1391
1391
|
});
|
|
1392
|
-
class
|
|
1392
|
+
class J extends _ {
|
|
1393
1393
|
constructor() {
|
|
1394
1394
|
super(...arguments), this._any = !0;
|
|
1395
1395
|
}
|
|
@@ -1397,11 +1397,11 @@ class Y extends v {
|
|
|
1397
1397
|
return T(e.data);
|
|
1398
1398
|
}
|
|
1399
1399
|
}
|
|
1400
|
-
|
|
1401
|
-
typeName:
|
|
1402
|
-
...
|
|
1400
|
+
J.create = (t) => new J({
|
|
1401
|
+
typeName: m.ZodAny,
|
|
1402
|
+
...v(t)
|
|
1403
1403
|
});
|
|
1404
|
-
class
|
|
1404
|
+
class B extends _ {
|
|
1405
1405
|
constructor() {
|
|
1406
1406
|
super(...arguments), this._unknown = !0;
|
|
1407
1407
|
}
|
|
@@ -1409,54 +1409,54 @@ class U extends v {
|
|
|
1409
1409
|
return T(e.data);
|
|
1410
1410
|
}
|
|
1411
1411
|
}
|
|
1412
|
-
|
|
1413
|
-
typeName:
|
|
1414
|
-
...
|
|
1412
|
+
B.create = (t) => new B({
|
|
1413
|
+
typeName: m.ZodUnknown,
|
|
1414
|
+
...v(t)
|
|
1415
1415
|
});
|
|
1416
|
-
class
|
|
1416
|
+
class P extends _ {
|
|
1417
1417
|
_parse(e) {
|
|
1418
|
-
const
|
|
1419
|
-
return l(
|
|
1420
|
-
code:
|
|
1418
|
+
const s = this._getOrReturnCtx(e);
|
|
1419
|
+
return l(s, {
|
|
1420
|
+
code: c.invalid_type,
|
|
1421
1421
|
expected: f.never,
|
|
1422
|
-
received:
|
|
1423
|
-
}),
|
|
1422
|
+
received: s.parsedType
|
|
1423
|
+
}), y;
|
|
1424
1424
|
}
|
|
1425
1425
|
}
|
|
1426
|
-
|
|
1427
|
-
typeName:
|
|
1428
|
-
...
|
|
1426
|
+
P.create = (t) => new P({
|
|
1427
|
+
typeName: m.ZodNever,
|
|
1428
|
+
...v(t)
|
|
1429
1429
|
});
|
|
1430
|
-
class
|
|
1430
|
+
class ke extends _ {
|
|
1431
1431
|
_parse(e) {
|
|
1432
1432
|
if (this._getType(e) !== f.undefined) {
|
|
1433
1433
|
const n = this._getOrReturnCtx(e);
|
|
1434
1434
|
return l(n, {
|
|
1435
|
-
code:
|
|
1435
|
+
code: c.invalid_type,
|
|
1436
1436
|
expected: f.void,
|
|
1437
1437
|
received: n.parsedType
|
|
1438
|
-
}),
|
|
1438
|
+
}), y;
|
|
1439
1439
|
}
|
|
1440
1440
|
return T(e.data);
|
|
1441
1441
|
}
|
|
1442
1442
|
}
|
|
1443
|
-
|
|
1444
|
-
typeName:
|
|
1445
|
-
...
|
|
1443
|
+
ke.create = (t) => new ke({
|
|
1444
|
+
typeName: m.ZodVoid,
|
|
1445
|
+
...v(t)
|
|
1446
1446
|
});
|
|
1447
|
-
class
|
|
1447
|
+
class Z extends _ {
|
|
1448
1448
|
_parse(e) {
|
|
1449
|
-
const { ctx:
|
|
1450
|
-
if (
|
|
1451
|
-
return l(
|
|
1452
|
-
code:
|
|
1449
|
+
const { ctx: s, status: n } = this._processInputParams(e), r = this._def;
|
|
1450
|
+
if (s.parsedType !== f.array)
|
|
1451
|
+
return l(s, {
|
|
1452
|
+
code: c.invalid_type,
|
|
1453
1453
|
expected: f.array,
|
|
1454
|
-
received:
|
|
1455
|
-
}),
|
|
1454
|
+
received: s.parsedType
|
|
1455
|
+
}), y;
|
|
1456
1456
|
if (r.exactLength !== null) {
|
|
1457
|
-
const i =
|
|
1458
|
-
(i || o) && (l(
|
|
1459
|
-
code: i ?
|
|
1457
|
+
const i = s.data.length > r.exactLength.value, o = s.data.length < r.exactLength.value;
|
|
1458
|
+
(i || o) && (l(s, {
|
|
1459
|
+
code: i ? c.too_big : c.too_small,
|
|
1460
1460
|
minimum: o ? r.exactLength.value : void 0,
|
|
1461
1461
|
maximum: i ? r.exactLength.value : void 0,
|
|
1462
1462
|
type: "array",
|
|
@@ -1465,130 +1465,130 @@ class E extends v {
|
|
|
1465
1465
|
message: r.exactLength.message
|
|
1466
1466
|
}), n.dirty());
|
|
1467
1467
|
}
|
|
1468
|
-
if (r.minLength !== null &&
|
|
1469
|
-
code:
|
|
1468
|
+
if (r.minLength !== null && s.data.length < r.minLength.value && (l(s, {
|
|
1469
|
+
code: c.too_small,
|
|
1470
1470
|
minimum: r.minLength.value,
|
|
1471
1471
|
type: "array",
|
|
1472
1472
|
inclusive: !0,
|
|
1473
1473
|
exact: !1,
|
|
1474
1474
|
message: r.minLength.message
|
|
1475
|
-
}), n.dirty()), r.maxLength !== null &&
|
|
1476
|
-
code:
|
|
1475
|
+
}), n.dirty()), r.maxLength !== null && s.data.length > r.maxLength.value && (l(s, {
|
|
1476
|
+
code: c.too_big,
|
|
1477
1477
|
maximum: r.maxLength.value,
|
|
1478
1478
|
type: "array",
|
|
1479
1479
|
inclusive: !0,
|
|
1480
1480
|
exact: !1,
|
|
1481
1481
|
message: r.maxLength.message
|
|
1482
|
-
}), n.dirty()),
|
|
1483
|
-
return Promise.all([...
|
|
1484
|
-
const a = [...
|
|
1485
|
-
return
|
|
1482
|
+
}), n.dirty()), s.common.async)
|
|
1483
|
+
return Promise.all([...s.data].map((i, o) => r.type._parseAsync(new O(s, i, s.path, o)))).then((i) => S.mergeArray(n, i));
|
|
1484
|
+
const a = [...s.data].map((i, o) => r.type._parseSync(new O(s, i, s.path, o)));
|
|
1485
|
+
return S.mergeArray(n, a);
|
|
1486
1486
|
}
|
|
1487
1487
|
get element() {
|
|
1488
1488
|
return this._def.type;
|
|
1489
1489
|
}
|
|
1490
|
-
min(e,
|
|
1491
|
-
return new
|
|
1490
|
+
min(e, s) {
|
|
1491
|
+
return new Z({
|
|
1492
1492
|
...this._def,
|
|
1493
|
-
minLength: { value: e, message:
|
|
1493
|
+
minLength: { value: e, message: p.toString(s) }
|
|
1494
1494
|
});
|
|
1495
1495
|
}
|
|
1496
|
-
max(e,
|
|
1497
|
-
return new
|
|
1496
|
+
max(e, s) {
|
|
1497
|
+
return new Z({
|
|
1498
1498
|
...this._def,
|
|
1499
|
-
maxLength: { value: e, message:
|
|
1499
|
+
maxLength: { value: e, message: p.toString(s) }
|
|
1500
1500
|
});
|
|
1501
1501
|
}
|
|
1502
|
-
length(e,
|
|
1503
|
-
return new
|
|
1502
|
+
length(e, s) {
|
|
1503
|
+
return new Z({
|
|
1504
1504
|
...this._def,
|
|
1505
|
-
exactLength: { value: e, message:
|
|
1505
|
+
exactLength: { value: e, message: p.toString(s) }
|
|
1506
1506
|
});
|
|
1507
1507
|
}
|
|
1508
1508
|
nonempty(e) {
|
|
1509
1509
|
return this.min(1, e);
|
|
1510
1510
|
}
|
|
1511
1511
|
}
|
|
1512
|
-
|
|
1513
|
-
type:
|
|
1512
|
+
Z.create = (t, e) => new Z({
|
|
1513
|
+
type: t,
|
|
1514
1514
|
minLength: null,
|
|
1515
1515
|
maxLength: null,
|
|
1516
1516
|
exactLength: null,
|
|
1517
|
-
typeName:
|
|
1518
|
-
...
|
|
1517
|
+
typeName: m.ZodArray,
|
|
1518
|
+
...v(e)
|
|
1519
1519
|
});
|
|
1520
|
-
function
|
|
1521
|
-
if (
|
|
1520
|
+
function Q(t) {
|
|
1521
|
+
if (t instanceof b) {
|
|
1522
1522
|
const e = {};
|
|
1523
|
-
for (const
|
|
1524
|
-
const n =
|
|
1525
|
-
e[
|
|
1523
|
+
for (const s in t.shape) {
|
|
1524
|
+
const n = t.shape[s];
|
|
1525
|
+
e[s] = I.create(Q(n));
|
|
1526
1526
|
}
|
|
1527
|
-
return new
|
|
1528
|
-
...
|
|
1527
|
+
return new b({
|
|
1528
|
+
...t._def,
|
|
1529
1529
|
shape: () => e
|
|
1530
1530
|
});
|
|
1531
1531
|
} else
|
|
1532
|
-
return
|
|
1533
|
-
...
|
|
1534
|
-
type:
|
|
1535
|
-
}) :
|
|
1532
|
+
return t instanceof Z ? new Z({
|
|
1533
|
+
...t._def,
|
|
1534
|
+
type: Q(t.element)
|
|
1535
|
+
}) : t instanceof I ? I.create(Q(t.unwrap())) : t instanceof V ? V.create(Q(t.unwrap())) : t instanceof A ? A.create(t.items.map((e) => Q(e))) : t;
|
|
1536
1536
|
}
|
|
1537
|
-
class
|
|
1537
|
+
class b extends _ {
|
|
1538
1538
|
constructor() {
|
|
1539
1539
|
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1540
1540
|
}
|
|
1541
1541
|
_getCached() {
|
|
1542
1542
|
if (this._cached !== null)
|
|
1543
1543
|
return this._cached;
|
|
1544
|
-
const e = this._def.shape(),
|
|
1545
|
-
return this._cached = { shape: e, keys:
|
|
1544
|
+
const e = this._def.shape(), s = x.objectKeys(e);
|
|
1545
|
+
return this._cached = { shape: e, keys: s };
|
|
1546
1546
|
}
|
|
1547
1547
|
_parse(e) {
|
|
1548
1548
|
if (this._getType(e) !== f.object) {
|
|
1549
|
-
const
|
|
1550
|
-
return l(
|
|
1551
|
-
code:
|
|
1549
|
+
const d = this._getOrReturnCtx(e);
|
|
1550
|
+
return l(d, {
|
|
1551
|
+
code: c.invalid_type,
|
|
1552
1552
|
expected: f.object,
|
|
1553
|
-
received:
|
|
1554
|
-
}),
|
|
1553
|
+
received: d.parsedType
|
|
1554
|
+
}), y;
|
|
1555
1555
|
}
|
|
1556
1556
|
const { status: n, ctx: r } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1557
|
-
if (!(this._def.catchall instanceof
|
|
1558
|
-
for (const
|
|
1559
|
-
i.includes(
|
|
1557
|
+
if (!(this._def.catchall instanceof P && this._def.unknownKeys === "strip"))
|
|
1558
|
+
for (const d in r.data)
|
|
1559
|
+
i.includes(d) || o.push(d);
|
|
1560
1560
|
const u = [];
|
|
1561
|
-
for (const
|
|
1562
|
-
const g = a[
|
|
1561
|
+
for (const d of i) {
|
|
1562
|
+
const g = a[d], R = r.data[d];
|
|
1563
1563
|
u.push({
|
|
1564
|
-
key: { status: "valid", value:
|
|
1565
|
-
value: g._parse(new O(r,
|
|
1566
|
-
alwaysSet:
|
|
1564
|
+
key: { status: "valid", value: d },
|
|
1565
|
+
value: g._parse(new O(r, R, r.path, d)),
|
|
1566
|
+
alwaysSet: d in r.data
|
|
1567
1567
|
});
|
|
1568
1568
|
}
|
|
1569
|
-
if (this._def.catchall instanceof
|
|
1570
|
-
const
|
|
1571
|
-
if (
|
|
1569
|
+
if (this._def.catchall instanceof P) {
|
|
1570
|
+
const d = this._def.unknownKeys;
|
|
1571
|
+
if (d === "passthrough")
|
|
1572
1572
|
for (const g of o)
|
|
1573
1573
|
u.push({
|
|
1574
1574
|
key: { status: "valid", value: g },
|
|
1575
1575
|
value: { status: "valid", value: r.data[g] }
|
|
1576
1576
|
});
|
|
1577
|
-
else if (
|
|
1577
|
+
else if (d === "strict")
|
|
1578
1578
|
o.length > 0 && (l(r, {
|
|
1579
|
-
code:
|
|
1579
|
+
code: c.unrecognized_keys,
|
|
1580
1580
|
keys: o
|
|
1581
1581
|
}), n.dirty());
|
|
1582
|
-
else if (
|
|
1582
|
+
else if (d !== "strip")
|
|
1583
1583
|
throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1584
1584
|
} else {
|
|
1585
|
-
const
|
|
1585
|
+
const d = this._def.catchall;
|
|
1586
1586
|
for (const g of o) {
|
|
1587
|
-
const
|
|
1587
|
+
const R = r.data[g];
|
|
1588
1588
|
u.push({
|
|
1589
1589
|
key: { status: "valid", value: g },
|
|
1590
|
-
value:
|
|
1591
|
-
new O(r,
|
|
1590
|
+
value: d._parse(
|
|
1591
|
+
new O(r, R, r.path, g)
|
|
1592
1592
|
//, ctx.child(key), value, getParsedType(value)
|
|
1593
1593
|
),
|
|
1594
1594
|
alwaysSet: g in r.data
|
|
@@ -1596,31 +1596,31 @@ class k extends v {
|
|
|
1596
1596
|
}
|
|
1597
1597
|
}
|
|
1598
1598
|
return r.common.async ? Promise.resolve().then(async () => {
|
|
1599
|
-
const
|
|
1599
|
+
const d = [];
|
|
1600
1600
|
for (const g of u) {
|
|
1601
|
-
const
|
|
1602
|
-
|
|
1603
|
-
key:
|
|
1604
|
-
value:
|
|
1601
|
+
const R = await g.key, D = await g.value;
|
|
1602
|
+
d.push({
|
|
1603
|
+
key: R,
|
|
1604
|
+
value: D,
|
|
1605
1605
|
alwaysSet: g.alwaysSet
|
|
1606
1606
|
});
|
|
1607
1607
|
}
|
|
1608
|
-
return
|
|
1609
|
-
}).then((
|
|
1608
|
+
return d;
|
|
1609
|
+
}).then((d) => S.mergeObjectSync(n, d)) : S.mergeObjectSync(n, u);
|
|
1610
1610
|
}
|
|
1611
1611
|
get shape() {
|
|
1612
1612
|
return this._def.shape();
|
|
1613
1613
|
}
|
|
1614
1614
|
strict(e) {
|
|
1615
|
-
return
|
|
1615
|
+
return p.errToObj, new b({
|
|
1616
1616
|
...this._def,
|
|
1617
1617
|
unknownKeys: "strict",
|
|
1618
1618
|
...e !== void 0 ? {
|
|
1619
|
-
errorMap: (
|
|
1619
|
+
errorMap: (s, n) => {
|
|
1620
1620
|
var r, a, i, o;
|
|
1621
|
-
const u = (i = (a = (r = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(r,
|
|
1622
|
-
return
|
|
1623
|
-
message: (o =
|
|
1621
|
+
const u = (i = (a = (r = this._def).errorMap) === null || a === void 0 ? void 0 : a.call(r, s, n).message) !== null && i !== void 0 ? i : n.defaultError;
|
|
1622
|
+
return s.code === "unrecognized_keys" ? {
|
|
1623
|
+
message: (o = p.errToObj(e).message) !== null && o !== void 0 ? o : u
|
|
1624
1624
|
} : {
|
|
1625
1625
|
message: u
|
|
1626
1626
|
};
|
|
@@ -1629,13 +1629,13 @@ class k extends v {
|
|
|
1629
1629
|
});
|
|
1630
1630
|
}
|
|
1631
1631
|
strip() {
|
|
1632
|
-
return new
|
|
1632
|
+
return new b({
|
|
1633
1633
|
...this._def,
|
|
1634
1634
|
unknownKeys: "strip"
|
|
1635
1635
|
});
|
|
1636
1636
|
}
|
|
1637
1637
|
passthrough() {
|
|
1638
|
-
return new
|
|
1638
|
+
return new b({
|
|
1639
1639
|
...this._def,
|
|
1640
1640
|
unknownKeys: "passthrough"
|
|
1641
1641
|
});
|
|
@@ -1658,7 +1658,7 @@ class k extends v {
|
|
|
1658
1658
|
// }) as any;
|
|
1659
1659
|
// };
|
|
1660
1660
|
extend(e) {
|
|
1661
|
-
return new
|
|
1661
|
+
return new b({
|
|
1662
1662
|
...this._def,
|
|
1663
1663
|
shape: () => ({
|
|
1664
1664
|
...this._def.shape(),
|
|
@@ -1672,14 +1672,14 @@ class k extends v {
|
|
|
1672
1672
|
* upgrade if you are experiencing issues.
|
|
1673
1673
|
*/
|
|
1674
1674
|
merge(e) {
|
|
1675
|
-
return new
|
|
1675
|
+
return new b({
|
|
1676
1676
|
unknownKeys: e._def.unknownKeys,
|
|
1677
1677
|
catchall: e._def.catchall,
|
|
1678
1678
|
shape: () => ({
|
|
1679
1679
|
...this._def.shape(),
|
|
1680
1680
|
...e._def.shape()
|
|
1681
1681
|
}),
|
|
1682
|
-
typeName:
|
|
1682
|
+
typeName: m.ZodObject
|
|
1683
1683
|
});
|
|
1684
1684
|
}
|
|
1685
1685
|
// merge<
|
|
@@ -1717,8 +1717,8 @@ class k extends v {
|
|
|
1717
1717
|
// }) as any;
|
|
1718
1718
|
// return merged;
|
|
1719
1719
|
// }
|
|
1720
|
-
setKey(e,
|
|
1721
|
-
return this.augment({ [e]:
|
|
1720
|
+
setKey(e, s) {
|
|
1721
|
+
return this.augment({ [e]: s });
|
|
1722
1722
|
}
|
|
1723
1723
|
// merge<Incoming extends AnyZodObject>(
|
|
1724
1724
|
// merging: Incoming
|
|
@@ -1742,116 +1742,116 @@ class k extends v {
|
|
|
1742
1742
|
// return merged;
|
|
1743
1743
|
// }
|
|
1744
1744
|
catchall(e) {
|
|
1745
|
-
return new
|
|
1745
|
+
return new b({
|
|
1746
1746
|
...this._def,
|
|
1747
1747
|
catchall: e
|
|
1748
1748
|
});
|
|
1749
1749
|
}
|
|
1750
1750
|
pick(e) {
|
|
1751
|
-
const
|
|
1752
|
-
return
|
|
1753
|
-
e[n] && this.shape[n] && (
|
|
1754
|
-
}), new
|
|
1751
|
+
const s = {};
|
|
1752
|
+
return x.objectKeys(e).forEach((n) => {
|
|
1753
|
+
e[n] && this.shape[n] && (s[n] = this.shape[n]);
|
|
1754
|
+
}), new b({
|
|
1755
1755
|
...this._def,
|
|
1756
|
-
shape: () =>
|
|
1756
|
+
shape: () => s
|
|
1757
1757
|
});
|
|
1758
1758
|
}
|
|
1759
1759
|
omit(e) {
|
|
1760
|
-
const
|
|
1761
|
-
return
|
|
1762
|
-
e[n] || (
|
|
1763
|
-
}), new
|
|
1760
|
+
const s = {};
|
|
1761
|
+
return x.objectKeys(this.shape).forEach((n) => {
|
|
1762
|
+
e[n] || (s[n] = this.shape[n]);
|
|
1763
|
+
}), new b({
|
|
1764
1764
|
...this._def,
|
|
1765
|
-
shape: () =>
|
|
1765
|
+
shape: () => s
|
|
1766
1766
|
});
|
|
1767
1767
|
}
|
|
1768
1768
|
/**
|
|
1769
1769
|
* @deprecated
|
|
1770
1770
|
*/
|
|
1771
1771
|
deepPartial() {
|
|
1772
|
-
return
|
|
1772
|
+
return Q(this);
|
|
1773
1773
|
}
|
|
1774
1774
|
partial(e) {
|
|
1775
|
-
const
|
|
1776
|
-
return
|
|
1775
|
+
const s = {};
|
|
1776
|
+
return x.objectKeys(this.shape).forEach((n) => {
|
|
1777
1777
|
const r = this.shape[n];
|
|
1778
|
-
e && !e[n] ?
|
|
1779
|
-
}), new
|
|
1778
|
+
e && !e[n] ? s[n] = r : s[n] = r.optional();
|
|
1779
|
+
}), new b({
|
|
1780
1780
|
...this._def,
|
|
1781
|
-
shape: () =>
|
|
1781
|
+
shape: () => s
|
|
1782
1782
|
});
|
|
1783
1783
|
}
|
|
1784
1784
|
required(e) {
|
|
1785
|
-
const
|
|
1786
|
-
return
|
|
1785
|
+
const s = {};
|
|
1786
|
+
return x.objectKeys(this.shape).forEach((n) => {
|
|
1787
1787
|
if (e && !e[n])
|
|
1788
|
-
|
|
1788
|
+
s[n] = this.shape[n];
|
|
1789
1789
|
else {
|
|
1790
1790
|
let a = this.shape[n];
|
|
1791
|
-
for (; a instanceof
|
|
1791
|
+
for (; a instanceof I; )
|
|
1792
1792
|
a = a._def.innerType;
|
|
1793
|
-
|
|
1793
|
+
s[n] = a;
|
|
1794
1794
|
}
|
|
1795
|
-
}), new
|
|
1795
|
+
}), new b({
|
|
1796
1796
|
...this._def,
|
|
1797
|
-
shape: () =>
|
|
1797
|
+
shape: () => s
|
|
1798
1798
|
});
|
|
1799
1799
|
}
|
|
1800
1800
|
keyof() {
|
|
1801
|
-
return
|
|
1801
|
+
return Be(x.objectKeys(this.shape));
|
|
1802
1802
|
}
|
|
1803
1803
|
}
|
|
1804
|
-
|
|
1805
|
-
shape: () =>
|
|
1804
|
+
b.create = (t, e) => new b({
|
|
1805
|
+
shape: () => t,
|
|
1806
1806
|
unknownKeys: "strip",
|
|
1807
|
-
catchall:
|
|
1808
|
-
typeName:
|
|
1809
|
-
...
|
|
1807
|
+
catchall: P.create(),
|
|
1808
|
+
typeName: m.ZodObject,
|
|
1809
|
+
...v(e)
|
|
1810
1810
|
});
|
|
1811
|
-
|
|
1812
|
-
shape: () =>
|
|
1811
|
+
b.strictCreate = (t, e) => new b({
|
|
1812
|
+
shape: () => t,
|
|
1813
1813
|
unknownKeys: "strict",
|
|
1814
|
-
catchall:
|
|
1815
|
-
typeName:
|
|
1816
|
-
...
|
|
1814
|
+
catchall: P.create(),
|
|
1815
|
+
typeName: m.ZodObject,
|
|
1816
|
+
...v(e)
|
|
1817
1817
|
});
|
|
1818
|
-
|
|
1819
|
-
shape:
|
|
1818
|
+
b.lazycreate = (t, e) => new b({
|
|
1819
|
+
shape: t,
|
|
1820
1820
|
unknownKeys: "strip",
|
|
1821
|
-
catchall:
|
|
1822
|
-
typeName:
|
|
1823
|
-
...
|
|
1821
|
+
catchall: P.create(),
|
|
1822
|
+
typeName: m.ZodObject,
|
|
1823
|
+
...v(e)
|
|
1824
1824
|
});
|
|
1825
|
-
class
|
|
1825
|
+
class oe extends _ {
|
|
1826
1826
|
_parse(e) {
|
|
1827
|
-
const { ctx:
|
|
1827
|
+
const { ctx: s } = this._processInputParams(e), n = this._def.options;
|
|
1828
1828
|
function r(a) {
|
|
1829
1829
|
for (const o of a)
|
|
1830
1830
|
if (o.result.status === "valid")
|
|
1831
1831
|
return o.result;
|
|
1832
1832
|
for (const o of a)
|
|
1833
1833
|
if (o.result.status === "dirty")
|
|
1834
|
-
return
|
|
1835
|
-
const i = a.map((o) => new
|
|
1836
|
-
return l(
|
|
1837
|
-
code:
|
|
1834
|
+
return s.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1835
|
+
const i = a.map((o) => new E(o.ctx.common.issues));
|
|
1836
|
+
return l(s, {
|
|
1837
|
+
code: c.invalid_union,
|
|
1838
1838
|
unionErrors: i
|
|
1839
|
-
}),
|
|
1839
|
+
}), y;
|
|
1840
1840
|
}
|
|
1841
|
-
if (
|
|
1841
|
+
if (s.common.async)
|
|
1842
1842
|
return Promise.all(n.map(async (a) => {
|
|
1843
1843
|
const i = {
|
|
1844
|
-
...
|
|
1844
|
+
...s,
|
|
1845
1845
|
common: {
|
|
1846
|
-
...
|
|
1846
|
+
...s.common,
|
|
1847
1847
|
issues: []
|
|
1848
1848
|
},
|
|
1849
1849
|
parent: null
|
|
1850
1850
|
};
|
|
1851
1851
|
return {
|
|
1852
1852
|
result: await a._parseAsync({
|
|
1853
|
-
data:
|
|
1854
|
-
path:
|
|
1853
|
+
data: s.data,
|
|
1854
|
+
path: s.path,
|
|
1855
1855
|
parent: i
|
|
1856
1856
|
}),
|
|
1857
1857
|
ctx: i
|
|
@@ -1861,64 +1861,64 @@ class ne extends v {
|
|
|
1861
1861
|
let a;
|
|
1862
1862
|
const i = [];
|
|
1863
1863
|
for (const u of n) {
|
|
1864
|
-
const
|
|
1865
|
-
...
|
|
1864
|
+
const d = {
|
|
1865
|
+
...s,
|
|
1866
1866
|
common: {
|
|
1867
|
-
...
|
|
1867
|
+
...s.common,
|
|
1868
1868
|
issues: []
|
|
1869
1869
|
},
|
|
1870
1870
|
parent: null
|
|
1871
1871
|
}, g = u._parseSync({
|
|
1872
|
-
data:
|
|
1873
|
-
path:
|
|
1874
|
-
parent:
|
|
1872
|
+
data: s.data,
|
|
1873
|
+
path: s.path,
|
|
1874
|
+
parent: d
|
|
1875
1875
|
});
|
|
1876
1876
|
if (g.status === "valid")
|
|
1877
1877
|
return g;
|
|
1878
|
-
g.status === "dirty" && !a && (a = { result: g, ctx:
|
|
1878
|
+
g.status === "dirty" && !a && (a = { result: g, ctx: d }), d.common.issues.length && i.push(d.common.issues);
|
|
1879
1879
|
}
|
|
1880
1880
|
if (a)
|
|
1881
|
-
return
|
|
1882
|
-
const o = i.map((u) => new
|
|
1883
|
-
return l(
|
|
1884
|
-
code:
|
|
1881
|
+
return s.common.issues.push(...a.ctx.common.issues), a.result;
|
|
1882
|
+
const o = i.map((u) => new E(u));
|
|
1883
|
+
return l(s, {
|
|
1884
|
+
code: c.invalid_union,
|
|
1885
1885
|
unionErrors: o
|
|
1886
|
-
}),
|
|
1886
|
+
}), y;
|
|
1887
1887
|
}
|
|
1888
1888
|
}
|
|
1889
1889
|
get options() {
|
|
1890
1890
|
return this._def.options;
|
|
1891
1891
|
}
|
|
1892
1892
|
}
|
|
1893
|
-
|
|
1894
|
-
options:
|
|
1895
|
-
typeName:
|
|
1896
|
-
...
|
|
1893
|
+
oe.create = (t, e) => new oe({
|
|
1894
|
+
options: t,
|
|
1895
|
+
typeName: m.ZodUnion,
|
|
1896
|
+
...v(e)
|
|
1897
1897
|
});
|
|
1898
|
-
const j = (
|
|
1899
|
-
class
|
|
1898
|
+
const j = (t) => t instanceof ue ? j(t.schema) : t instanceof N ? j(t.innerType()) : t instanceof le ? [t.value] : t instanceof L ? t.options : t instanceof fe ? x.objectValues(t.enum) : t instanceof he ? j(t._def.innerType) : t instanceof ae ? [void 0] : t instanceof ie ? [null] : t instanceof I ? [void 0, ...j(t.unwrap())] : t instanceof V ? [null, ...j(t.unwrap())] : t instanceof Oe || t instanceof me ? j(t.unwrap()) : t instanceof pe ? j(t._def.innerType) : [];
|
|
1899
|
+
class Re extends _ {
|
|
1900
1900
|
_parse(e) {
|
|
1901
|
-
const { ctx:
|
|
1902
|
-
if (
|
|
1903
|
-
return l(
|
|
1904
|
-
code:
|
|
1901
|
+
const { ctx: s } = this._processInputParams(e);
|
|
1902
|
+
if (s.parsedType !== f.object)
|
|
1903
|
+
return l(s, {
|
|
1904
|
+
code: c.invalid_type,
|
|
1905
1905
|
expected: f.object,
|
|
1906
|
-
received:
|
|
1907
|
-
}),
|
|
1908
|
-
const n = this.discriminator, r =
|
|
1909
|
-
return a ?
|
|
1910
|
-
data:
|
|
1911
|
-
path:
|
|
1912
|
-
parent:
|
|
1906
|
+
received: s.parsedType
|
|
1907
|
+
}), y;
|
|
1908
|
+
const n = this.discriminator, r = s.data[n], a = this.optionsMap.get(r);
|
|
1909
|
+
return a ? s.common.async ? a._parseAsync({
|
|
1910
|
+
data: s.data,
|
|
1911
|
+
path: s.path,
|
|
1912
|
+
parent: s
|
|
1913
1913
|
}) : a._parseSync({
|
|
1914
|
-
data:
|
|
1915
|
-
path:
|
|
1916
|
-
parent:
|
|
1917
|
-
}) : (l(
|
|
1918
|
-
code:
|
|
1914
|
+
data: s.data,
|
|
1915
|
+
path: s.path,
|
|
1916
|
+
parent: s
|
|
1917
|
+
}) : (l(s, {
|
|
1918
|
+
code: c.invalid_union_discriminator,
|
|
1919
1919
|
options: Array.from(this.optionsMap.keys()),
|
|
1920
1920
|
path: [n]
|
|
1921
|
-
}),
|
|
1921
|
+
}), y);
|
|
1922
1922
|
}
|
|
1923
1923
|
get discriminator() {
|
|
1924
1924
|
return this._def.discriminator;
|
|
@@ -1937,9 +1937,9 @@ class ke extends v {
|
|
|
1937
1937
|
* @param types an array of object schemas
|
|
1938
1938
|
* @param params
|
|
1939
1939
|
*/
|
|
1940
|
-
static create(e,
|
|
1940
|
+
static create(e, s, n) {
|
|
1941
1941
|
const r = /* @__PURE__ */ new Map();
|
|
1942
|
-
for (const a of
|
|
1942
|
+
for (const a of s) {
|
|
1943
1943
|
const i = j(a.shape[e]);
|
|
1944
1944
|
if (!i.length)
|
|
1945
1945
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
@@ -1949,51 +1949,51 @@ class ke extends v {
|
|
|
1949
1949
|
r.set(o, a);
|
|
1950
1950
|
}
|
|
1951
1951
|
}
|
|
1952
|
-
return new
|
|
1953
|
-
typeName:
|
|
1952
|
+
return new Re({
|
|
1953
|
+
typeName: m.ZodDiscriminatedUnion,
|
|
1954
1954
|
discriminator: e,
|
|
1955
|
-
options:
|
|
1955
|
+
options: s,
|
|
1956
1956
|
optionsMap: r,
|
|
1957
|
-
...
|
|
1957
|
+
...v(n)
|
|
1958
1958
|
});
|
|
1959
1959
|
}
|
|
1960
1960
|
}
|
|
1961
|
-
function
|
|
1962
|
-
const
|
|
1963
|
-
if (
|
|
1964
|
-
return { valid: !0, data:
|
|
1965
|
-
if (
|
|
1966
|
-
const r =
|
|
1961
|
+
function Ie(t, e) {
|
|
1962
|
+
const s = q(t), n = q(e);
|
|
1963
|
+
if (t === e)
|
|
1964
|
+
return { valid: !0, data: t };
|
|
1965
|
+
if (s === f.object && n === f.object) {
|
|
1966
|
+
const r = x.objectKeys(e), a = x.objectKeys(t).filter((o) => r.indexOf(o) !== -1), i = { ...t, ...e };
|
|
1967
1967
|
for (const o of a) {
|
|
1968
|
-
const u =
|
|
1968
|
+
const u = Ie(t[o], e[o]);
|
|
1969
1969
|
if (!u.valid)
|
|
1970
1970
|
return { valid: !1 };
|
|
1971
1971
|
i[o] = u.data;
|
|
1972
1972
|
}
|
|
1973
1973
|
return { valid: !0, data: i };
|
|
1974
|
-
} else if (
|
|
1975
|
-
if (
|
|
1974
|
+
} else if (s === f.array && n === f.array) {
|
|
1975
|
+
if (t.length !== e.length)
|
|
1976
1976
|
return { valid: !1 };
|
|
1977
1977
|
const r = [];
|
|
1978
|
-
for (let a = 0; a <
|
|
1979
|
-
const i =
|
|
1978
|
+
for (let a = 0; a < t.length; a++) {
|
|
1979
|
+
const i = t[a], o = e[a], u = Ie(i, o);
|
|
1980
1980
|
if (!u.valid)
|
|
1981
1981
|
return { valid: !1 };
|
|
1982
1982
|
r.push(u.data);
|
|
1983
1983
|
}
|
|
1984
1984
|
return { valid: !0, data: r };
|
|
1985
1985
|
} else
|
|
1986
|
-
return
|
|
1986
|
+
return s === f.date && n === f.date && +t == +e ? { valid: !0, data: t } : { valid: !1 };
|
|
1987
1987
|
}
|
|
1988
|
-
class
|
|
1988
|
+
class ce extends _ {
|
|
1989
1989
|
_parse(e) {
|
|
1990
|
-
const { status:
|
|
1991
|
-
if (
|
|
1992
|
-
return
|
|
1993
|
-
const o =
|
|
1994
|
-
return o.valid ? ((
|
|
1995
|
-
code:
|
|
1996
|
-
}),
|
|
1990
|
+
const { status: s, ctx: n } = this._processInputParams(e), r = (a, i) => {
|
|
1991
|
+
if (Ne(a) || Ne(i))
|
|
1992
|
+
return y;
|
|
1993
|
+
const o = Ie(a.value, i.value);
|
|
1994
|
+
return o.valid ? ((Me(a) || Me(i)) && s.dirty(), { status: s.value, value: o.data }) : (l(n, {
|
|
1995
|
+
code: c.invalid_intersection_types
|
|
1996
|
+
}), y);
|
|
1997
1997
|
};
|
|
1998
1998
|
return n.common.async ? Promise.all([
|
|
1999
1999
|
this._def.left._parseAsync({
|
|
@@ -2017,63 +2017,63 @@ class re extends v {
|
|
|
2017
2017
|
}));
|
|
2018
2018
|
}
|
|
2019
2019
|
}
|
|
2020
|
-
|
|
2021
|
-
left:
|
|
2020
|
+
ce.create = (t, e, s) => new ce({
|
|
2021
|
+
left: t,
|
|
2022
2022
|
right: e,
|
|
2023
|
-
typeName:
|
|
2024
|
-
...
|
|
2023
|
+
typeName: m.ZodIntersection,
|
|
2024
|
+
...v(s)
|
|
2025
2025
|
});
|
|
2026
|
-
class
|
|
2026
|
+
class A extends _ {
|
|
2027
2027
|
_parse(e) {
|
|
2028
|
-
const { status:
|
|
2028
|
+
const { status: s, ctx: n } = this._processInputParams(e);
|
|
2029
2029
|
if (n.parsedType !== f.array)
|
|
2030
2030
|
return l(n, {
|
|
2031
|
-
code:
|
|
2031
|
+
code: c.invalid_type,
|
|
2032
2032
|
expected: f.array,
|
|
2033
2033
|
received: n.parsedType
|
|
2034
|
-
}),
|
|
2034
|
+
}), y;
|
|
2035
2035
|
if (n.data.length < this._def.items.length)
|
|
2036
2036
|
return l(n, {
|
|
2037
|
-
code:
|
|
2037
|
+
code: c.too_small,
|
|
2038
2038
|
minimum: this._def.items.length,
|
|
2039
2039
|
inclusive: !0,
|
|
2040
2040
|
exact: !1,
|
|
2041
2041
|
type: "array"
|
|
2042
|
-
}),
|
|
2042
|
+
}), y;
|
|
2043
2043
|
!this._def.rest && n.data.length > this._def.items.length && (l(n, {
|
|
2044
|
-
code:
|
|
2044
|
+
code: c.too_big,
|
|
2045
2045
|
maximum: this._def.items.length,
|
|
2046
2046
|
inclusive: !0,
|
|
2047
2047
|
exact: !1,
|
|
2048
2048
|
type: "array"
|
|
2049
|
-
}),
|
|
2049
|
+
}), s.dirty());
|
|
2050
2050
|
const a = [...n.data].map((i, o) => {
|
|
2051
2051
|
const u = this._def.items[o] || this._def.rest;
|
|
2052
2052
|
return u ? u._parse(new O(n, i, n.path, o)) : null;
|
|
2053
2053
|
}).filter((i) => !!i);
|
|
2054
|
-
return n.common.async ? Promise.all(a).then((i) =>
|
|
2054
|
+
return n.common.async ? Promise.all(a).then((i) => S.mergeArray(s, i)) : S.mergeArray(s, a);
|
|
2055
2055
|
}
|
|
2056
2056
|
get items() {
|
|
2057
2057
|
return this._def.items;
|
|
2058
2058
|
}
|
|
2059
2059
|
rest(e) {
|
|
2060
|
-
return new
|
|
2060
|
+
return new A({
|
|
2061
2061
|
...this._def,
|
|
2062
2062
|
rest: e
|
|
2063
2063
|
});
|
|
2064
2064
|
}
|
|
2065
2065
|
}
|
|
2066
|
-
|
|
2067
|
-
if (!Array.isArray(
|
|
2066
|
+
A.create = (t, e) => {
|
|
2067
|
+
if (!Array.isArray(t))
|
|
2068
2068
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2069
|
-
return new
|
|
2070
|
-
items:
|
|
2071
|
-
typeName:
|
|
2069
|
+
return new A({
|
|
2070
|
+
items: t,
|
|
2071
|
+
typeName: m.ZodTuple,
|
|
2072
2072
|
rest: null,
|
|
2073
|
-
...
|
|
2073
|
+
...v(e)
|
|
2074
2074
|
});
|
|
2075
2075
|
};
|
|
2076
|
-
class
|
|
2076
|
+
class de extends _ {
|
|
2077
2077
|
get keySchema() {
|
|
2078
2078
|
return this._def.keyType;
|
|
2079
2079
|
}
|
|
@@ -2081,13 +2081,13 @@ class ae extends v {
|
|
|
2081
2081
|
return this._def.valueType;
|
|
2082
2082
|
}
|
|
2083
2083
|
_parse(e) {
|
|
2084
|
-
const { status:
|
|
2084
|
+
const { status: s, ctx: n } = this._processInputParams(e);
|
|
2085
2085
|
if (n.parsedType !== f.object)
|
|
2086
2086
|
return l(n, {
|
|
2087
|
-
code:
|
|
2087
|
+
code: c.invalid_type,
|
|
2088
2088
|
expected: f.object,
|
|
2089
2089
|
received: n.parsedType
|
|
2090
|
-
}),
|
|
2090
|
+
}), y;
|
|
2091
2091
|
const r = [], a = this._def.keyType, i = this._def.valueType;
|
|
2092
2092
|
for (const o in n.data)
|
|
2093
2093
|
r.push({
|
|
@@ -2095,26 +2095,26 @@ class ae extends v {
|
|
|
2095
2095
|
value: i._parse(new O(n, n.data[o], n.path, o)),
|
|
2096
2096
|
alwaysSet: o in n.data
|
|
2097
2097
|
});
|
|
2098
|
-
return n.common.async ?
|
|
2098
|
+
return n.common.async ? S.mergeObjectAsync(s, r) : S.mergeObjectSync(s, r);
|
|
2099
2099
|
}
|
|
2100
2100
|
get element() {
|
|
2101
2101
|
return this._def.valueType;
|
|
2102
2102
|
}
|
|
2103
|
-
static create(e,
|
|
2104
|
-
return
|
|
2103
|
+
static create(e, s, n) {
|
|
2104
|
+
return s instanceof _ ? new de({
|
|
2105
2105
|
keyType: e,
|
|
2106
|
-
valueType:
|
|
2107
|
-
typeName:
|
|
2108
|
-
...
|
|
2109
|
-
}) : new
|
|
2106
|
+
valueType: s,
|
|
2107
|
+
typeName: m.ZodRecord,
|
|
2108
|
+
...v(n)
|
|
2109
|
+
}) : new de({
|
|
2110
2110
|
keyType: C.create(),
|
|
2111
2111
|
valueType: e,
|
|
2112
|
-
typeName:
|
|
2113
|
-
...
|
|
2112
|
+
typeName: m.ZodRecord,
|
|
2113
|
+
...v(s)
|
|
2114
2114
|
});
|
|
2115
2115
|
}
|
|
2116
2116
|
}
|
|
2117
|
-
class
|
|
2117
|
+
class Se extends _ {
|
|
2118
2118
|
get keySchema() {
|
|
2119
2119
|
return this._def.keyType;
|
|
2120
2120
|
}
|
|
@@ -2122,175 +2122,175 @@ class _e extends v {
|
|
|
2122
2122
|
return this._def.valueType;
|
|
2123
2123
|
}
|
|
2124
2124
|
_parse(e) {
|
|
2125
|
-
const { status:
|
|
2125
|
+
const { status: s, ctx: n } = this._processInputParams(e);
|
|
2126
2126
|
if (n.parsedType !== f.map)
|
|
2127
2127
|
return l(n, {
|
|
2128
|
-
code:
|
|
2128
|
+
code: c.invalid_type,
|
|
2129
2129
|
expected: f.map,
|
|
2130
2130
|
received: n.parsedType
|
|
2131
|
-
}),
|
|
2132
|
-
const r = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, u],
|
|
2133
|
-
key: r._parse(new O(n, o, n.path, [
|
|
2134
|
-
value: a._parse(new O(n, u, n.path, [
|
|
2131
|
+
}), y;
|
|
2132
|
+
const r = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, u], d) => ({
|
|
2133
|
+
key: r._parse(new O(n, o, n.path, [d, "key"])),
|
|
2134
|
+
value: a._parse(new O(n, u, n.path, [d, "value"]))
|
|
2135
2135
|
}));
|
|
2136
2136
|
if (n.common.async) {
|
|
2137
2137
|
const o = /* @__PURE__ */ new Map();
|
|
2138
2138
|
return Promise.resolve().then(async () => {
|
|
2139
2139
|
for (const u of i) {
|
|
2140
|
-
const
|
|
2141
|
-
if (
|
|
2142
|
-
return
|
|
2143
|
-
(
|
|
2140
|
+
const d = await u.key, g = await u.value;
|
|
2141
|
+
if (d.status === "aborted" || g.status === "aborted")
|
|
2142
|
+
return y;
|
|
2143
|
+
(d.status === "dirty" || g.status === "dirty") && s.dirty(), o.set(d.value, g.value);
|
|
2144
2144
|
}
|
|
2145
|
-
return { status:
|
|
2145
|
+
return { status: s.value, value: o };
|
|
2146
2146
|
});
|
|
2147
2147
|
} else {
|
|
2148
2148
|
const o = /* @__PURE__ */ new Map();
|
|
2149
2149
|
for (const u of i) {
|
|
2150
|
-
const
|
|
2151
|
-
if (
|
|
2152
|
-
return
|
|
2153
|
-
(
|
|
2150
|
+
const d = u.key, g = u.value;
|
|
2151
|
+
if (d.status === "aborted" || g.status === "aborted")
|
|
2152
|
+
return y;
|
|
2153
|
+
(d.status === "dirty" || g.status === "dirty") && s.dirty(), o.set(d.value, g.value);
|
|
2154
2154
|
}
|
|
2155
|
-
return { status:
|
|
2155
|
+
return { status: s.value, value: o };
|
|
2156
2156
|
}
|
|
2157
2157
|
}
|
|
2158
2158
|
}
|
|
2159
|
-
|
|
2159
|
+
Se.create = (t, e, s) => new Se({
|
|
2160
2160
|
valueType: e,
|
|
2161
|
-
keyType:
|
|
2162
|
-
typeName:
|
|
2163
|
-
...
|
|
2161
|
+
keyType: t,
|
|
2162
|
+
typeName: m.ZodMap,
|
|
2163
|
+
...v(s)
|
|
2164
2164
|
});
|
|
2165
|
-
class
|
|
2165
|
+
class G extends _ {
|
|
2166
2166
|
_parse(e) {
|
|
2167
|
-
const { status:
|
|
2167
|
+
const { status: s, ctx: n } = this._processInputParams(e);
|
|
2168
2168
|
if (n.parsedType !== f.set)
|
|
2169
2169
|
return l(n, {
|
|
2170
|
-
code:
|
|
2170
|
+
code: c.invalid_type,
|
|
2171
2171
|
expected: f.set,
|
|
2172
2172
|
received: n.parsedType
|
|
2173
|
-
}),
|
|
2173
|
+
}), y;
|
|
2174
2174
|
const r = this._def;
|
|
2175
2175
|
r.minSize !== null && n.data.size < r.minSize.value && (l(n, {
|
|
2176
|
-
code:
|
|
2176
|
+
code: c.too_small,
|
|
2177
2177
|
minimum: r.minSize.value,
|
|
2178
2178
|
type: "set",
|
|
2179
2179
|
inclusive: !0,
|
|
2180
2180
|
exact: !1,
|
|
2181
2181
|
message: r.minSize.message
|
|
2182
|
-
}),
|
|
2183
|
-
code:
|
|
2182
|
+
}), s.dirty()), r.maxSize !== null && n.data.size > r.maxSize.value && (l(n, {
|
|
2183
|
+
code: c.too_big,
|
|
2184
2184
|
maximum: r.maxSize.value,
|
|
2185
2185
|
type: "set",
|
|
2186
2186
|
inclusive: !0,
|
|
2187
2187
|
exact: !1,
|
|
2188
2188
|
message: r.maxSize.message
|
|
2189
|
-
}),
|
|
2189
|
+
}), s.dirty());
|
|
2190
2190
|
const a = this._def.valueType;
|
|
2191
2191
|
function i(u) {
|
|
2192
|
-
const
|
|
2192
|
+
const d = /* @__PURE__ */ new Set();
|
|
2193
2193
|
for (const g of u) {
|
|
2194
2194
|
if (g.status === "aborted")
|
|
2195
|
-
return
|
|
2196
|
-
g.status === "dirty" &&
|
|
2195
|
+
return y;
|
|
2196
|
+
g.status === "dirty" && s.dirty(), d.add(g.value);
|
|
2197
2197
|
}
|
|
2198
|
-
return { status:
|
|
2198
|
+
return { status: s.value, value: d };
|
|
2199
2199
|
}
|
|
2200
|
-
const o = [...n.data.values()].map((u,
|
|
2200
|
+
const o = [...n.data.values()].map((u, d) => a._parse(new O(n, u, n.path, d)));
|
|
2201
2201
|
return n.common.async ? Promise.all(o).then((u) => i(u)) : i(o);
|
|
2202
2202
|
}
|
|
2203
|
-
min(e,
|
|
2204
|
-
return new
|
|
2203
|
+
min(e, s) {
|
|
2204
|
+
return new G({
|
|
2205
2205
|
...this._def,
|
|
2206
|
-
minSize: { value: e, message:
|
|
2206
|
+
minSize: { value: e, message: p.toString(s) }
|
|
2207
2207
|
});
|
|
2208
2208
|
}
|
|
2209
|
-
max(e,
|
|
2210
|
-
return new
|
|
2209
|
+
max(e, s) {
|
|
2210
|
+
return new G({
|
|
2211
2211
|
...this._def,
|
|
2212
|
-
maxSize: { value: e, message:
|
|
2212
|
+
maxSize: { value: e, message: p.toString(s) }
|
|
2213
2213
|
});
|
|
2214
2214
|
}
|
|
2215
|
-
size(e,
|
|
2216
|
-
return this.min(e,
|
|
2215
|
+
size(e, s) {
|
|
2216
|
+
return this.min(e, s).max(e, s);
|
|
2217
2217
|
}
|
|
2218
2218
|
nonempty(e) {
|
|
2219
2219
|
return this.min(1, e);
|
|
2220
2220
|
}
|
|
2221
2221
|
}
|
|
2222
|
-
|
|
2223
|
-
valueType:
|
|
2222
|
+
G.create = (t, e) => new G({
|
|
2223
|
+
valueType: t,
|
|
2224
2224
|
minSize: null,
|
|
2225
2225
|
maxSize: null,
|
|
2226
|
-
typeName:
|
|
2227
|
-
...
|
|
2226
|
+
typeName: m.ZodSet,
|
|
2227
|
+
...v(e)
|
|
2228
2228
|
});
|
|
2229
|
-
class
|
|
2229
|
+
class H extends _ {
|
|
2230
2230
|
constructor() {
|
|
2231
2231
|
super(...arguments), this.validate = this.implement;
|
|
2232
2232
|
}
|
|
2233
2233
|
_parse(e) {
|
|
2234
|
-
const { ctx:
|
|
2235
|
-
if (
|
|
2236
|
-
return l(
|
|
2237
|
-
code:
|
|
2234
|
+
const { ctx: s } = this._processInputParams(e);
|
|
2235
|
+
if (s.parsedType !== f.function)
|
|
2236
|
+
return l(s, {
|
|
2237
|
+
code: c.invalid_type,
|
|
2238
2238
|
expected: f.function,
|
|
2239
|
-
received:
|
|
2240
|
-
}),
|
|
2239
|
+
received: s.parsedType
|
|
2240
|
+
}), y;
|
|
2241
2241
|
function n(o, u) {
|
|
2242
|
-
return
|
|
2242
|
+
return xe({
|
|
2243
2243
|
data: o,
|
|
2244
|
-
path:
|
|
2244
|
+
path: s.path,
|
|
2245
2245
|
errorMaps: [
|
|
2246
|
-
|
|
2247
|
-
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
].filter((
|
|
2246
|
+
s.common.contextualErrorMap,
|
|
2247
|
+
s.schemaErrorMap,
|
|
2248
|
+
_e(),
|
|
2249
|
+
Y
|
|
2250
|
+
].filter((d) => !!d),
|
|
2251
2251
|
issueData: {
|
|
2252
|
-
code:
|
|
2252
|
+
code: c.invalid_arguments,
|
|
2253
2253
|
argumentsError: u
|
|
2254
2254
|
}
|
|
2255
2255
|
});
|
|
2256
2256
|
}
|
|
2257
2257
|
function r(o, u) {
|
|
2258
|
-
return
|
|
2258
|
+
return xe({
|
|
2259
2259
|
data: o,
|
|
2260
|
-
path:
|
|
2260
|
+
path: s.path,
|
|
2261
2261
|
errorMaps: [
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
].filter((
|
|
2262
|
+
s.common.contextualErrorMap,
|
|
2263
|
+
s.schemaErrorMap,
|
|
2264
|
+
_e(),
|
|
2265
|
+
Y
|
|
2266
|
+
].filter((d) => !!d),
|
|
2267
2267
|
issueData: {
|
|
2268
|
-
code:
|
|
2268
|
+
code: c.invalid_return_type,
|
|
2269
2269
|
returnTypeError: u
|
|
2270
2270
|
}
|
|
2271
2271
|
});
|
|
2272
2272
|
}
|
|
2273
|
-
const a = { errorMap:
|
|
2274
|
-
if (this._def.returns instanceof
|
|
2273
|
+
const a = { errorMap: s.common.contextualErrorMap }, i = s.data;
|
|
2274
|
+
if (this._def.returns instanceof X) {
|
|
2275
2275
|
const o = this;
|
|
2276
2276
|
return T(async function(...u) {
|
|
2277
|
-
const
|
|
2278
|
-
throw
|
|
2279
|
-
}),
|
|
2280
|
-
return await o._def.returns._def.type.parseAsync(
|
|
2281
|
-
throw
|
|
2277
|
+
const d = new E([]), g = await o._def.args.parseAsync(u, a).catch((Ee) => {
|
|
2278
|
+
throw d.addIssue(n(u, Ee)), d;
|
|
2279
|
+
}), R = await Reflect.apply(i, this, g);
|
|
2280
|
+
return await o._def.returns._def.type.parseAsync(R, a).catch((Ee) => {
|
|
2281
|
+
throw d.addIssue(r(R, Ee)), d;
|
|
2282
2282
|
});
|
|
2283
2283
|
});
|
|
2284
2284
|
} else {
|
|
2285
2285
|
const o = this;
|
|
2286
2286
|
return T(function(...u) {
|
|
2287
|
-
const
|
|
2288
|
-
if (!
|
|
2289
|
-
throw new
|
|
2290
|
-
const g = Reflect.apply(i, this,
|
|
2291
|
-
if (!
|
|
2292
|
-
throw new
|
|
2293
|
-
return
|
|
2287
|
+
const d = o._def.args.safeParse(u, a);
|
|
2288
|
+
if (!d.success)
|
|
2289
|
+
throw new E([n(u, d.error)]);
|
|
2290
|
+
const g = Reflect.apply(i, this, d.data), R = o._def.returns.safeParse(g, a);
|
|
2291
|
+
if (!R.success)
|
|
2292
|
+
throw new E([r(g, R.error)]);
|
|
2293
|
+
return R.data;
|
|
2294
2294
|
});
|
|
2295
2295
|
}
|
|
2296
2296
|
}
|
|
@@ -2301,13 +2301,13 @@ class G extends v {
|
|
|
2301
2301
|
return this._def.returns;
|
|
2302
2302
|
}
|
|
2303
2303
|
args(...e) {
|
|
2304
|
-
return new
|
|
2304
|
+
return new H({
|
|
2305
2305
|
...this._def,
|
|
2306
|
-
args:
|
|
2306
|
+
args: A.create(e).rest(B.create())
|
|
2307
2307
|
});
|
|
2308
2308
|
}
|
|
2309
2309
|
returns(e) {
|
|
2310
|
-
return new
|
|
2310
|
+
return new H({
|
|
2311
2311
|
...this._def,
|
|
2312
2312
|
returns: e
|
|
2313
2313
|
});
|
|
@@ -2318,38 +2318,38 @@ class G extends v {
|
|
|
2318
2318
|
strictImplement(e) {
|
|
2319
2319
|
return this.parse(e);
|
|
2320
2320
|
}
|
|
2321
|
-
static create(e,
|
|
2322
|
-
return new
|
|
2323
|
-
args: e ||
|
|
2324
|
-
returns:
|
|
2325
|
-
typeName:
|
|
2326
|
-
...
|
|
2321
|
+
static create(e, s, n) {
|
|
2322
|
+
return new H({
|
|
2323
|
+
args: e || A.create([]).rest(B.create()),
|
|
2324
|
+
returns: s || B.create(),
|
|
2325
|
+
typeName: m.ZodFunction,
|
|
2326
|
+
...v(n)
|
|
2327
2327
|
});
|
|
2328
2328
|
}
|
|
2329
2329
|
}
|
|
2330
|
-
class
|
|
2330
|
+
class ue extends _ {
|
|
2331
2331
|
get schema() {
|
|
2332
2332
|
return this._def.getter();
|
|
2333
2333
|
}
|
|
2334
2334
|
_parse(e) {
|
|
2335
|
-
const { ctx:
|
|
2336
|
-
return this._def.getter()._parse({ data:
|
|
2335
|
+
const { ctx: s } = this._processInputParams(e);
|
|
2336
|
+
return this._def.getter()._parse({ data: s.data, path: s.path, parent: s });
|
|
2337
2337
|
}
|
|
2338
2338
|
}
|
|
2339
|
-
|
|
2340
|
-
getter:
|
|
2341
|
-
typeName:
|
|
2342
|
-
...
|
|
2339
|
+
ue.create = (t, e) => new ue({
|
|
2340
|
+
getter: t,
|
|
2341
|
+
typeName: m.ZodLazy,
|
|
2342
|
+
...v(e)
|
|
2343
2343
|
});
|
|
2344
|
-
class
|
|
2344
|
+
class le extends _ {
|
|
2345
2345
|
_parse(e) {
|
|
2346
2346
|
if (e.data !== this._def.value) {
|
|
2347
|
-
const
|
|
2348
|
-
return l(
|
|
2349
|
-
received:
|
|
2350
|
-
code:
|
|
2347
|
+
const s = this._getOrReturnCtx(e);
|
|
2348
|
+
return l(s, {
|
|
2349
|
+
received: s.data,
|
|
2350
|
+
code: c.invalid_literal,
|
|
2351
2351
|
expected: this._def.value
|
|
2352
|
-
}),
|
|
2352
|
+
}), y;
|
|
2353
2353
|
}
|
|
2354
2354
|
return { status: "valid", value: e.data };
|
|
2355
2355
|
}
|
|
@@ -2357,38 +2357,38 @@ class oe extends v {
|
|
|
2357
2357
|
return this._def.value;
|
|
2358
2358
|
}
|
|
2359
2359
|
}
|
|
2360
|
-
|
|
2361
|
-
value:
|
|
2362
|
-
typeName:
|
|
2363
|
-
...
|
|
2360
|
+
le.create = (t, e) => new le({
|
|
2361
|
+
value: t,
|
|
2362
|
+
typeName: m.ZodLiteral,
|
|
2363
|
+
...v(e)
|
|
2364
2364
|
});
|
|
2365
|
-
function
|
|
2366
|
-
return new
|
|
2367
|
-
values:
|
|
2368
|
-
typeName:
|
|
2369
|
-
...
|
|
2365
|
+
function Be(t, e) {
|
|
2366
|
+
return new L({
|
|
2367
|
+
values: t,
|
|
2368
|
+
typeName: m.ZodEnum,
|
|
2369
|
+
...v(e)
|
|
2370
2370
|
});
|
|
2371
2371
|
}
|
|
2372
|
-
class
|
|
2372
|
+
class L extends _ {
|
|
2373
2373
|
constructor() {
|
|
2374
|
-
super(...arguments),
|
|
2374
|
+
super(...arguments), F.set(this, void 0);
|
|
2375
2375
|
}
|
|
2376
2376
|
_parse(e) {
|
|
2377
2377
|
if (typeof e.data != "string") {
|
|
2378
|
-
const
|
|
2379
|
-
return l(
|
|
2380
|
-
expected:
|
|
2381
|
-
received:
|
|
2382
|
-
code:
|
|
2383
|
-
}),
|
|
2378
|
+
const s = this._getOrReturnCtx(e), n = this._def.values;
|
|
2379
|
+
return l(s, {
|
|
2380
|
+
expected: x.joinValues(n),
|
|
2381
|
+
received: s.parsedType,
|
|
2382
|
+
code: c.invalid_type
|
|
2383
|
+
}), y;
|
|
2384
2384
|
}
|
|
2385
|
-
if (
|
|
2386
|
-
const
|
|
2387
|
-
return l(
|
|
2388
|
-
received:
|
|
2389
|
-
code:
|
|
2385
|
+
if (be(this, F) || Ue(this, F, new Set(this._def.values)), !be(this, F).has(e.data)) {
|
|
2386
|
+
const s = this._getOrReturnCtx(e), n = this._def.values;
|
|
2387
|
+
return l(s, {
|
|
2388
|
+
received: s.data,
|
|
2389
|
+
code: c.invalid_enum_value,
|
|
2390
2390
|
options: n
|
|
2391
|
-
}),
|
|
2391
|
+
}), y;
|
|
2392
2392
|
}
|
|
2393
2393
|
return T(e.data);
|
|
2394
2394
|
}
|
|
@@ -2397,58 +2397,58 @@ class V extends v {
|
|
|
2397
2397
|
}
|
|
2398
2398
|
get enum() {
|
|
2399
2399
|
const e = {};
|
|
2400
|
-
for (const
|
|
2401
|
-
e[
|
|
2400
|
+
for (const s of this._def.values)
|
|
2401
|
+
e[s] = s;
|
|
2402
2402
|
return e;
|
|
2403
2403
|
}
|
|
2404
2404
|
get Values() {
|
|
2405
2405
|
const e = {};
|
|
2406
|
-
for (const
|
|
2407
|
-
e[
|
|
2406
|
+
for (const s of this._def.values)
|
|
2407
|
+
e[s] = s;
|
|
2408
2408
|
return e;
|
|
2409
2409
|
}
|
|
2410
2410
|
get Enum() {
|
|
2411
2411
|
const e = {};
|
|
2412
|
-
for (const
|
|
2413
|
-
e[
|
|
2412
|
+
for (const s of this._def.values)
|
|
2413
|
+
e[s] = s;
|
|
2414
2414
|
return e;
|
|
2415
2415
|
}
|
|
2416
|
-
extract(e,
|
|
2417
|
-
return
|
|
2416
|
+
extract(e, s = this._def) {
|
|
2417
|
+
return L.create(e, {
|
|
2418
2418
|
...this._def,
|
|
2419
|
-
...
|
|
2419
|
+
...s
|
|
2420
2420
|
});
|
|
2421
2421
|
}
|
|
2422
|
-
exclude(e,
|
|
2423
|
-
return
|
|
2422
|
+
exclude(e, s = this._def) {
|
|
2423
|
+
return L.create(this.options.filter((n) => !e.includes(n)), {
|
|
2424
2424
|
...this._def,
|
|
2425
|
-
...
|
|
2425
|
+
...s
|
|
2426
2426
|
});
|
|
2427
2427
|
}
|
|
2428
2428
|
}
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
class
|
|
2429
|
+
F = /* @__PURE__ */ new WeakMap();
|
|
2430
|
+
L.create = Be;
|
|
2431
|
+
class fe extends _ {
|
|
2432
2432
|
constructor() {
|
|
2433
|
-
super(...arguments),
|
|
2433
|
+
super(...arguments), ee.set(this, void 0);
|
|
2434
2434
|
}
|
|
2435
2435
|
_parse(e) {
|
|
2436
|
-
const
|
|
2436
|
+
const s = x.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
|
|
2437
2437
|
if (n.parsedType !== f.string && n.parsedType !== f.number) {
|
|
2438
|
-
const r =
|
|
2438
|
+
const r = x.objectValues(s);
|
|
2439
2439
|
return l(n, {
|
|
2440
|
-
expected:
|
|
2440
|
+
expected: x.joinValues(r),
|
|
2441
2441
|
received: n.parsedType,
|
|
2442
|
-
code:
|
|
2443
|
-
}),
|
|
2442
|
+
code: c.invalid_type
|
|
2443
|
+
}), y;
|
|
2444
2444
|
}
|
|
2445
|
-
if (
|
|
2446
|
-
const r =
|
|
2445
|
+
if (be(this, ee) || Ue(this, ee, new Set(x.getValidEnumValues(this._def.values))), !be(this, ee).has(e.data)) {
|
|
2446
|
+
const r = x.objectValues(s);
|
|
2447
2447
|
return l(n, {
|
|
2448
2448
|
received: n.data,
|
|
2449
|
-
code:
|
|
2449
|
+
code: c.invalid_enum_value,
|
|
2450
2450
|
options: r
|
|
2451
|
-
}),
|
|
2451
|
+
}), y;
|
|
2452
2452
|
}
|
|
2453
2453
|
return T(e.data);
|
|
2454
2454
|
}
|
|
@@ -2456,47 +2456,47 @@ class de extends v {
|
|
|
2456
2456
|
return this._def.values;
|
|
2457
2457
|
}
|
|
2458
2458
|
}
|
|
2459
|
-
|
|
2460
|
-
|
|
2461
|
-
values:
|
|
2462
|
-
typeName:
|
|
2463
|
-
...
|
|
2459
|
+
ee = /* @__PURE__ */ new WeakMap();
|
|
2460
|
+
fe.create = (t, e) => new fe({
|
|
2461
|
+
values: t,
|
|
2462
|
+
typeName: m.ZodNativeEnum,
|
|
2463
|
+
...v(e)
|
|
2464
2464
|
});
|
|
2465
|
-
class
|
|
2465
|
+
class X extends _ {
|
|
2466
2466
|
unwrap() {
|
|
2467
2467
|
return this._def.type;
|
|
2468
2468
|
}
|
|
2469
2469
|
_parse(e) {
|
|
2470
|
-
const { ctx:
|
|
2471
|
-
if (
|
|
2472
|
-
return l(
|
|
2473
|
-
code:
|
|
2470
|
+
const { ctx: s } = this._processInputParams(e);
|
|
2471
|
+
if (s.parsedType !== f.promise && s.common.async === !1)
|
|
2472
|
+
return l(s, {
|
|
2473
|
+
code: c.invalid_type,
|
|
2474
2474
|
expected: f.promise,
|
|
2475
|
-
received:
|
|
2476
|
-
}),
|
|
2477
|
-
const n =
|
|
2475
|
+
received: s.parsedType
|
|
2476
|
+
}), y;
|
|
2477
|
+
const n = s.parsedType === f.promise ? s.data : Promise.resolve(s.data);
|
|
2478
2478
|
return T(n.then((r) => this._def.type.parseAsync(r, {
|
|
2479
|
-
path:
|
|
2480
|
-
errorMap:
|
|
2479
|
+
path: s.path,
|
|
2480
|
+
errorMap: s.common.contextualErrorMap
|
|
2481
2481
|
})));
|
|
2482
2482
|
}
|
|
2483
2483
|
}
|
|
2484
|
-
|
|
2485
|
-
type:
|
|
2486
|
-
typeName:
|
|
2487
|
-
...
|
|
2484
|
+
X.create = (t, e) => new X({
|
|
2485
|
+
type: t,
|
|
2486
|
+
typeName: m.ZodPromise,
|
|
2487
|
+
...v(e)
|
|
2488
2488
|
});
|
|
2489
|
-
class
|
|
2489
|
+
class N extends _ {
|
|
2490
2490
|
innerType() {
|
|
2491
2491
|
return this._def.schema;
|
|
2492
2492
|
}
|
|
2493
2493
|
sourceType() {
|
|
2494
|
-
return this._def.schema._def.typeName ===
|
|
2494
|
+
return this._def.schema._def.typeName === m.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2495
2495
|
}
|
|
2496
2496
|
_parse(e) {
|
|
2497
|
-
const { status:
|
|
2497
|
+
const { status: s, ctx: n } = this._processInputParams(e), r = this._def.effect || null, a = {
|
|
2498
2498
|
addIssue: (i) => {
|
|
2499
|
-
l(n, i), i.fatal ?
|
|
2499
|
+
l(n, i), i.fatal ? s.abort() : s.dirty();
|
|
2500
2500
|
},
|
|
2501
2501
|
get path() {
|
|
2502
2502
|
return n.path;
|
|
@@ -2506,24 +2506,24 @@ class R extends v {
|
|
|
2506
2506
|
const i = r.transform(n.data, a);
|
|
2507
2507
|
if (n.common.async)
|
|
2508
2508
|
return Promise.resolve(i).then(async (o) => {
|
|
2509
|
-
if (
|
|
2510
|
-
return
|
|
2509
|
+
if (s.value === "aborted")
|
|
2510
|
+
return y;
|
|
2511
2511
|
const u = await this._def.schema._parseAsync({
|
|
2512
2512
|
data: o,
|
|
2513
2513
|
path: n.path,
|
|
2514
2514
|
parent: n
|
|
2515
2515
|
});
|
|
2516
|
-
return u.status === "aborted" ?
|
|
2516
|
+
return u.status === "aborted" ? y : u.status === "dirty" || s.value === "dirty" ? W(u.value) : u;
|
|
2517
2517
|
});
|
|
2518
2518
|
{
|
|
2519
|
-
if (
|
|
2520
|
-
return
|
|
2519
|
+
if (s.value === "aborted")
|
|
2520
|
+
return y;
|
|
2521
2521
|
const o = this._def.schema._parseSync({
|
|
2522
2522
|
data: i,
|
|
2523
2523
|
path: n.path,
|
|
2524
2524
|
parent: n
|
|
2525
2525
|
});
|
|
2526
|
-
return o.status === "aborted" ?
|
|
2526
|
+
return o.status === "aborted" ? y : o.status === "dirty" || s.value === "dirty" ? W(o.value) : o;
|
|
2527
2527
|
}
|
|
2528
2528
|
}
|
|
2529
2529
|
if (r.type === "refinement") {
|
|
@@ -2541,9 +2541,9 @@ class R extends v {
|
|
|
2541
2541
|
path: n.path,
|
|
2542
2542
|
parent: n
|
|
2543
2543
|
});
|
|
2544
|
-
return o.status === "aborted" ?
|
|
2544
|
+
return o.status === "aborted" ? y : (o.status === "dirty" && s.dirty(), i(o.value), { status: s.value, value: o.value });
|
|
2545
2545
|
} else
|
|
2546
|
-
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => o.status === "aborted" ?
|
|
2546
|
+
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => o.status === "aborted" ? y : (o.status === "dirty" && s.dirty(), i(o.value).then(() => ({ status: s.value, value: o.value }))));
|
|
2547
2547
|
}
|
|
2548
2548
|
if (r.type === "transform")
|
|
2549
2549
|
if (n.common.async === !1) {
|
|
@@ -2552,30 +2552,30 @@ class R extends v {
|
|
|
2552
2552
|
path: n.path,
|
|
2553
2553
|
parent: n
|
|
2554
2554
|
});
|
|
2555
|
-
if (!
|
|
2555
|
+
if (!se(i))
|
|
2556
2556
|
return i;
|
|
2557
2557
|
const o = r.transform(i.value, a);
|
|
2558
2558
|
if (o instanceof Promise)
|
|
2559
2559
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2560
|
-
return { status:
|
|
2560
|
+
return { status: s.value, value: o };
|
|
2561
2561
|
} else
|
|
2562
|
-
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) =>
|
|
2563
|
-
|
|
2562
|
+
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => se(i) ? Promise.resolve(r.transform(i.value, a)).then((o) => ({ status: s.value, value: o })) : i);
|
|
2563
|
+
x.assertNever(r);
|
|
2564
2564
|
}
|
|
2565
2565
|
}
|
|
2566
|
-
|
|
2567
|
-
schema:
|
|
2568
|
-
typeName:
|
|
2566
|
+
N.create = (t, e, s) => new N({
|
|
2567
|
+
schema: t,
|
|
2568
|
+
typeName: m.ZodEffects,
|
|
2569
2569
|
effect: e,
|
|
2570
|
-
...
|
|
2570
|
+
...v(s)
|
|
2571
2571
|
});
|
|
2572
|
-
|
|
2572
|
+
N.createWithPreprocess = (t, e, s) => new N({
|
|
2573
2573
|
schema: e,
|
|
2574
|
-
effect: { type: "preprocess", transform:
|
|
2575
|
-
typeName:
|
|
2576
|
-
...
|
|
2574
|
+
effect: { type: "preprocess", transform: t },
|
|
2575
|
+
typeName: m.ZodEffects,
|
|
2576
|
+
...v(s)
|
|
2577
2577
|
});
|
|
2578
|
-
class
|
|
2578
|
+
class I extends _ {
|
|
2579
2579
|
_parse(e) {
|
|
2580
2580
|
return this._getType(e) === f.undefined ? T(void 0) : this._def.innerType._parse(e);
|
|
2581
2581
|
}
|
|
@@ -2583,12 +2583,12 @@ class N extends v {
|
|
|
2583
2583
|
return this._def.innerType;
|
|
2584
2584
|
}
|
|
2585
2585
|
}
|
|
2586
|
-
|
|
2587
|
-
innerType:
|
|
2588
|
-
typeName:
|
|
2589
|
-
...
|
|
2586
|
+
I.create = (t, e) => new I({
|
|
2587
|
+
innerType: t,
|
|
2588
|
+
typeName: m.ZodOptional,
|
|
2589
|
+
...v(e)
|
|
2590
2590
|
});
|
|
2591
|
-
class
|
|
2591
|
+
class V extends _ {
|
|
2592
2592
|
_parse(e) {
|
|
2593
2593
|
return this._getType(e) === f.null ? T(null) : this._def.innerType._parse(e);
|
|
2594
2594
|
}
|
|
@@ -2596,37 +2596,37 @@ class D extends v {
|
|
|
2596
2596
|
return this._def.innerType;
|
|
2597
2597
|
}
|
|
2598
2598
|
}
|
|
2599
|
-
|
|
2600
|
-
innerType:
|
|
2601
|
-
typeName:
|
|
2602
|
-
...
|
|
2599
|
+
V.create = (t, e) => new V({
|
|
2600
|
+
innerType: t,
|
|
2601
|
+
typeName: m.ZodNullable,
|
|
2602
|
+
...v(e)
|
|
2603
2603
|
});
|
|
2604
|
-
class
|
|
2604
|
+
class he extends _ {
|
|
2605
2605
|
_parse(e) {
|
|
2606
|
-
const { ctx:
|
|
2607
|
-
let n =
|
|
2608
|
-
return
|
|
2606
|
+
const { ctx: s } = this._processInputParams(e);
|
|
2607
|
+
let n = s.data;
|
|
2608
|
+
return s.parsedType === f.undefined && (n = this._def.defaultValue()), this._def.innerType._parse({
|
|
2609
2609
|
data: n,
|
|
2610
|
-
path:
|
|
2611
|
-
parent:
|
|
2610
|
+
path: s.path,
|
|
2611
|
+
parent: s
|
|
2612
2612
|
});
|
|
2613
2613
|
}
|
|
2614
2614
|
removeDefault() {
|
|
2615
2615
|
return this._def.innerType;
|
|
2616
2616
|
}
|
|
2617
2617
|
}
|
|
2618
|
-
|
|
2619
|
-
innerType:
|
|
2620
|
-
typeName:
|
|
2618
|
+
he.create = (t, e) => new he({
|
|
2619
|
+
innerType: t,
|
|
2620
|
+
typeName: m.ZodDefault,
|
|
2621
2621
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2622
|
-
...
|
|
2622
|
+
...v(e)
|
|
2623
2623
|
});
|
|
2624
|
-
class
|
|
2624
|
+
class pe extends _ {
|
|
2625
2625
|
_parse(e) {
|
|
2626
|
-
const { ctx:
|
|
2627
|
-
...
|
|
2626
|
+
const { ctx: s } = this._processInputParams(e), n = {
|
|
2627
|
+
...s,
|
|
2628
2628
|
common: {
|
|
2629
|
-
...
|
|
2629
|
+
...s.common,
|
|
2630
2630
|
issues: []
|
|
2631
2631
|
}
|
|
2632
2632
|
}, r = this._def.innerType._parse({
|
|
@@ -2636,11 +2636,11 @@ class ue extends v {
|
|
|
2636
2636
|
...n
|
|
2637
2637
|
}
|
|
2638
2638
|
});
|
|
2639
|
-
return
|
|
2639
|
+
return ne(r) ? r.then((a) => ({
|
|
2640
2640
|
status: "valid",
|
|
2641
2641
|
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2642
2642
|
get error() {
|
|
2643
|
-
return new
|
|
2643
|
+
return new E(n.common.issues);
|
|
2644
2644
|
},
|
|
2645
2645
|
input: n.data
|
|
2646
2646
|
})
|
|
@@ -2648,7 +2648,7 @@ class ue extends v {
|
|
|
2648
2648
|
status: "valid",
|
|
2649
2649
|
value: r.status === "valid" ? r.value : this._def.catchValue({
|
|
2650
2650
|
get error() {
|
|
2651
|
-
return new
|
|
2651
|
+
return new E(n.common.issues);
|
|
2652
2652
|
},
|
|
2653
2653
|
input: n.data
|
|
2654
2654
|
})
|
|
@@ -2658,46 +2658,46 @@ class ue extends v {
|
|
|
2658
2658
|
return this._def.innerType;
|
|
2659
2659
|
}
|
|
2660
2660
|
}
|
|
2661
|
-
|
|
2662
|
-
innerType:
|
|
2663
|
-
typeName:
|
|
2661
|
+
pe.create = (t, e) => new pe({
|
|
2662
|
+
innerType: t,
|
|
2663
|
+
typeName: m.ZodCatch,
|
|
2664
2664
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2665
|
-
...
|
|
2665
|
+
...v(e)
|
|
2666
2666
|
});
|
|
2667
|
-
class
|
|
2667
|
+
class Te extends _ {
|
|
2668
2668
|
_parse(e) {
|
|
2669
2669
|
if (this._getType(e) !== f.nan) {
|
|
2670
2670
|
const n = this._getOrReturnCtx(e);
|
|
2671
2671
|
return l(n, {
|
|
2672
|
-
code:
|
|
2672
|
+
code: c.invalid_type,
|
|
2673
2673
|
expected: f.nan,
|
|
2674
2674
|
received: n.parsedType
|
|
2675
|
-
}),
|
|
2675
|
+
}), y;
|
|
2676
2676
|
}
|
|
2677
2677
|
return { status: "valid", value: e.data };
|
|
2678
2678
|
}
|
|
2679
2679
|
}
|
|
2680
|
-
|
|
2681
|
-
typeName:
|
|
2682
|
-
...
|
|
2680
|
+
Te.create = (t) => new Te({
|
|
2681
|
+
typeName: m.ZodNaN,
|
|
2682
|
+
...v(t)
|
|
2683
2683
|
});
|
|
2684
|
-
const
|
|
2685
|
-
class
|
|
2684
|
+
const bt = Symbol("zod_brand");
|
|
2685
|
+
class Oe extends _ {
|
|
2686
2686
|
_parse(e) {
|
|
2687
|
-
const { ctx:
|
|
2687
|
+
const { ctx: s } = this._processInputParams(e), n = s.data;
|
|
2688
2688
|
return this._def.type._parse({
|
|
2689
2689
|
data: n,
|
|
2690
|
-
path:
|
|
2691
|
-
parent:
|
|
2690
|
+
path: s.path,
|
|
2691
|
+
parent: s
|
|
2692
2692
|
});
|
|
2693
2693
|
}
|
|
2694
2694
|
unwrap() {
|
|
2695
2695
|
return this._def.type;
|
|
2696
2696
|
}
|
|
2697
2697
|
}
|
|
2698
|
-
class
|
|
2698
|
+
class ge extends _ {
|
|
2699
2699
|
_parse(e) {
|
|
2700
|
-
const { status:
|
|
2700
|
+
const { status: s, ctx: n } = this._processInputParams(e);
|
|
2701
2701
|
if (n.common.async)
|
|
2702
2702
|
return (async () => {
|
|
2703
2703
|
const a = await this._def.in._parseAsync({
|
|
@@ -2705,7 +2705,7 @@ class fe extends v {
|
|
|
2705
2705
|
path: n.path,
|
|
2706
2706
|
parent: n
|
|
2707
2707
|
});
|
|
2708
|
-
return a.status === "aborted" ?
|
|
2708
|
+
return a.status === "aborted" ? y : a.status === "dirty" ? (s.dirty(), W(a.value)) : this._def.out._parseAsync({
|
|
2709
2709
|
data: a.value,
|
|
2710
2710
|
path: n.path,
|
|
2711
2711
|
parent: n
|
|
@@ -2717,7 +2717,7 @@ class fe extends v {
|
|
|
2717
2717
|
path: n.path,
|
|
2718
2718
|
parent: n
|
|
2719
2719
|
});
|
|
2720
|
-
return r.status === "aborted" ?
|
|
2720
|
+
return r.status === "aborted" ? y : r.status === "dirty" ? (s.dirty(), {
|
|
2721
2721
|
status: "dirty",
|
|
2722
2722
|
value: r.value
|
|
2723
2723
|
}) : this._def.out._parseSync({
|
|
@@ -2727,277 +2727,431 @@ class fe extends v {
|
|
|
2727
2727
|
});
|
|
2728
2728
|
}
|
|
2729
2729
|
}
|
|
2730
|
-
static create(e,
|
|
2731
|
-
return new
|
|
2730
|
+
static create(e, s) {
|
|
2731
|
+
return new ge({
|
|
2732
2732
|
in: e,
|
|
2733
|
-
out:
|
|
2734
|
-
typeName:
|
|
2733
|
+
out: s,
|
|
2734
|
+
typeName: m.ZodPipeline
|
|
2735
2735
|
});
|
|
2736
2736
|
}
|
|
2737
2737
|
}
|
|
2738
|
-
class
|
|
2738
|
+
class me extends _ {
|
|
2739
2739
|
_parse(e) {
|
|
2740
|
-
const
|
|
2741
|
-
return
|
|
2740
|
+
const s = this._def.innerType._parse(e), n = (r) => (se(r) && (r.value = Object.freeze(r.value)), r);
|
|
2741
|
+
return ne(s) ? s.then((r) => n(r)) : n(s);
|
|
2742
2742
|
}
|
|
2743
2743
|
unwrap() {
|
|
2744
2744
|
return this._def.innerType;
|
|
2745
2745
|
}
|
|
2746
2746
|
}
|
|
2747
|
-
|
|
2748
|
-
innerType:
|
|
2749
|
-
typeName:
|
|
2750
|
-
...
|
|
2747
|
+
me.create = (t, e) => new me({
|
|
2748
|
+
innerType: t,
|
|
2749
|
+
typeName: m.ZodReadonly,
|
|
2750
|
+
...v(e)
|
|
2751
2751
|
});
|
|
2752
|
-
function
|
|
2753
|
-
return
|
|
2752
|
+
function ze(t, e = {}, s) {
|
|
2753
|
+
return t ? J.create().superRefine((n, r) => {
|
|
2754
2754
|
var a, i;
|
|
2755
|
-
if (!
|
|
2756
|
-
const o = typeof e == "function" ? e(n) : typeof e == "string" ? { message: e } : e, u = (i = (a = o.fatal) !== null && a !== void 0 ? a :
|
|
2757
|
-
r.addIssue({ code: "custom", ...
|
|
2755
|
+
if (!t(n)) {
|
|
2756
|
+
const o = typeof e == "function" ? e(n) : typeof e == "string" ? { message: e } : e, u = (i = (a = o.fatal) !== null && a !== void 0 ? a : s) !== null && i !== void 0 ? i : !0, d = typeof o == "string" ? { message: o } : o;
|
|
2757
|
+
r.addIssue({ code: "custom", ...d, fatal: u });
|
|
2758
2758
|
}
|
|
2759
|
-
}) :
|
|
2759
|
+
}) : J.create();
|
|
2760
2760
|
}
|
|
2761
|
-
const
|
|
2762
|
-
object:
|
|
2761
|
+
const wt = {
|
|
2762
|
+
object: b.lazycreate
|
|
2763
2763
|
};
|
|
2764
|
-
var
|
|
2765
|
-
(function(
|
|
2766
|
-
|
|
2767
|
-
})(
|
|
2768
|
-
const
|
|
2769
|
-
message: `Input not instance of ${
|
|
2770
|
-
}) =>
|
|
2771
|
-
string: (
|
|
2772
|
-
number: (
|
|
2773
|
-
boolean: (
|
|
2774
|
-
...
|
|
2764
|
+
var m;
|
|
2765
|
+
(function(t) {
|
|
2766
|
+
t.ZodString = "ZodString", t.ZodNumber = "ZodNumber", t.ZodNaN = "ZodNaN", t.ZodBigInt = "ZodBigInt", t.ZodBoolean = "ZodBoolean", t.ZodDate = "ZodDate", t.ZodSymbol = "ZodSymbol", t.ZodUndefined = "ZodUndefined", t.ZodNull = "ZodNull", t.ZodAny = "ZodAny", t.ZodUnknown = "ZodUnknown", t.ZodNever = "ZodNever", t.ZodVoid = "ZodVoid", t.ZodArray = "ZodArray", t.ZodObject = "ZodObject", t.ZodUnion = "ZodUnion", t.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", t.ZodIntersection = "ZodIntersection", t.ZodTuple = "ZodTuple", t.ZodRecord = "ZodRecord", t.ZodMap = "ZodMap", t.ZodSet = "ZodSet", t.ZodFunction = "ZodFunction", t.ZodLazy = "ZodLazy", t.ZodLiteral = "ZodLiteral", t.ZodEnum = "ZodEnum", t.ZodEffects = "ZodEffects", t.ZodNativeEnum = "ZodNativeEnum", t.ZodOptional = "ZodOptional", t.ZodNullable = "ZodNullable", t.ZodDefault = "ZodDefault", t.ZodCatch = "ZodCatch", t.ZodPromise = "ZodPromise", t.ZodBranded = "ZodBranded", t.ZodPipeline = "ZodPipeline", t.ZodReadonly = "ZodReadonly";
|
|
2767
|
+
})(m || (m = {}));
|
|
2768
|
+
const kt = (t, e = {
|
|
2769
|
+
message: `Input not instance of ${t.name}`
|
|
2770
|
+
}) => ze((s) => s instanceof t, e), Ge = C.create, Qe = $.create, St = Te.create, Tt = U.create, We = re.create, Rt = z.create, Et = we.create, Ct = ae.create, Zt = ie.create, Nt = J.create, Mt = B.create, It = P.create, Ot = ke.create, At = Z.create, jt = b.create, Pt = b.strictCreate, qt = oe.create, $t = Re.create, Ut = ce.create, Lt = A.create, Vt = de.create, Dt = Se.create, Bt = G.create, zt = H.create, Gt = ue.create, Qt = le.create, Wt = L.create, Ht = fe.create, Yt = X.create, Pe = N.create, Jt = I.create, Xt = V.create, Kt = N.createWithPreprocess, Ft = ge.create, es = () => Ge().optional(), ts = () => Qe().optional(), ss = () => We().optional(), ns = {
|
|
2771
|
+
string: (t) => C.create({ ...t, coerce: !0 }),
|
|
2772
|
+
number: (t) => $.create({ ...t, coerce: !0 }),
|
|
2773
|
+
boolean: (t) => re.create({
|
|
2774
|
+
...t,
|
|
2775
2775
|
coerce: !0
|
|
2776
2776
|
}),
|
|
2777
|
-
bigint: (
|
|
2778
|
-
date: (
|
|
2779
|
-
},
|
|
2780
|
-
var
|
|
2777
|
+
bigint: (t) => U.create({ ...t, coerce: !0 }),
|
|
2778
|
+
date: (t) => z.create({ ...t, coerce: !0 })
|
|
2779
|
+
}, rs = y;
|
|
2780
|
+
var h = /* @__PURE__ */ Object.freeze({
|
|
2781
2781
|
__proto__: null,
|
|
2782
|
-
defaultErrorMap:
|
|
2783
|
-
setErrorMap:
|
|
2784
|
-
getErrorMap:
|
|
2785
|
-
makeIssue:
|
|
2786
|
-
EMPTY_PATH:
|
|
2782
|
+
defaultErrorMap: Y,
|
|
2783
|
+
setErrorMap: rt,
|
|
2784
|
+
getErrorMap: _e,
|
|
2785
|
+
makeIssue: xe,
|
|
2786
|
+
EMPTY_PATH: at,
|
|
2787
2787
|
addIssueToContext: l,
|
|
2788
|
-
ParseStatus:
|
|
2789
|
-
INVALID:
|
|
2788
|
+
ParseStatus: S,
|
|
2789
|
+
INVALID: y,
|
|
2790
2790
|
DIRTY: W,
|
|
2791
2791
|
OK: T,
|
|
2792
|
-
isAborted:
|
|
2793
|
-
isDirty:
|
|
2794
|
-
isValid:
|
|
2795
|
-
isAsync:
|
|
2792
|
+
isAborted: Ne,
|
|
2793
|
+
isDirty: Me,
|
|
2794
|
+
isValid: se,
|
|
2795
|
+
isAsync: ne,
|
|
2796
2796
|
get util() {
|
|
2797
|
-
return
|
|
2797
|
+
return x;
|
|
2798
2798
|
},
|
|
2799
2799
|
get objectUtil() {
|
|
2800
|
-
return
|
|
2800
|
+
return Ze;
|
|
2801
2801
|
},
|
|
2802
2802
|
ZodParsedType: f,
|
|
2803
|
-
getParsedType:
|
|
2804
|
-
ZodType:
|
|
2803
|
+
getParsedType: q,
|
|
2804
|
+
ZodType: _,
|
|
2805
2805
|
datetimeRegex: De,
|
|
2806
2806
|
ZodString: C,
|
|
2807
|
-
ZodNumber:
|
|
2808
|
-
ZodBigInt:
|
|
2809
|
-
ZodBoolean:
|
|
2807
|
+
ZodNumber: $,
|
|
2808
|
+
ZodBigInt: U,
|
|
2809
|
+
ZodBoolean: re,
|
|
2810
2810
|
ZodDate: z,
|
|
2811
|
-
ZodSymbol:
|
|
2812
|
-
ZodUndefined:
|
|
2813
|
-
ZodNull:
|
|
2814
|
-
ZodAny:
|
|
2815
|
-
ZodUnknown:
|
|
2816
|
-
ZodNever:
|
|
2817
|
-
ZodVoid:
|
|
2818
|
-
ZodArray:
|
|
2819
|
-
ZodObject:
|
|
2820
|
-
ZodUnion:
|
|
2821
|
-
ZodDiscriminatedUnion:
|
|
2822
|
-
ZodIntersection:
|
|
2823
|
-
ZodTuple:
|
|
2824
|
-
ZodRecord:
|
|
2825
|
-
ZodMap:
|
|
2826
|
-
ZodSet:
|
|
2827
|
-
ZodFunction:
|
|
2828
|
-
ZodLazy:
|
|
2829
|
-
ZodLiteral:
|
|
2830
|
-
ZodEnum:
|
|
2831
|
-
ZodNativeEnum:
|
|
2832
|
-
ZodPromise:
|
|
2833
|
-
ZodEffects:
|
|
2834
|
-
ZodTransformer:
|
|
2835
|
-
ZodOptional:
|
|
2836
|
-
ZodNullable:
|
|
2837
|
-
ZodDefault:
|
|
2838
|
-
ZodCatch:
|
|
2839
|
-
ZodNaN:
|
|
2840
|
-
BRAND:
|
|
2841
|
-
ZodBranded:
|
|
2842
|
-
ZodPipeline:
|
|
2843
|
-
ZodReadonly:
|
|
2844
|
-
custom:
|
|
2845
|
-
Schema:
|
|
2846
|
-
ZodSchema:
|
|
2847
|
-
late:
|
|
2811
|
+
ZodSymbol: we,
|
|
2812
|
+
ZodUndefined: ae,
|
|
2813
|
+
ZodNull: ie,
|
|
2814
|
+
ZodAny: J,
|
|
2815
|
+
ZodUnknown: B,
|
|
2816
|
+
ZodNever: P,
|
|
2817
|
+
ZodVoid: ke,
|
|
2818
|
+
ZodArray: Z,
|
|
2819
|
+
ZodObject: b,
|
|
2820
|
+
ZodUnion: oe,
|
|
2821
|
+
ZodDiscriminatedUnion: Re,
|
|
2822
|
+
ZodIntersection: ce,
|
|
2823
|
+
ZodTuple: A,
|
|
2824
|
+
ZodRecord: de,
|
|
2825
|
+
ZodMap: Se,
|
|
2826
|
+
ZodSet: G,
|
|
2827
|
+
ZodFunction: H,
|
|
2828
|
+
ZodLazy: ue,
|
|
2829
|
+
ZodLiteral: le,
|
|
2830
|
+
ZodEnum: L,
|
|
2831
|
+
ZodNativeEnum: fe,
|
|
2832
|
+
ZodPromise: X,
|
|
2833
|
+
ZodEffects: N,
|
|
2834
|
+
ZodTransformer: N,
|
|
2835
|
+
ZodOptional: I,
|
|
2836
|
+
ZodNullable: V,
|
|
2837
|
+
ZodDefault: he,
|
|
2838
|
+
ZodCatch: pe,
|
|
2839
|
+
ZodNaN: Te,
|
|
2840
|
+
BRAND: bt,
|
|
2841
|
+
ZodBranded: Oe,
|
|
2842
|
+
ZodPipeline: ge,
|
|
2843
|
+
ZodReadonly: me,
|
|
2844
|
+
custom: ze,
|
|
2845
|
+
Schema: _,
|
|
2846
|
+
ZodSchema: _,
|
|
2847
|
+
late: wt,
|
|
2848
2848
|
get ZodFirstPartyTypeKind() {
|
|
2849
|
-
return
|
|
2849
|
+
return m;
|
|
2850
2850
|
},
|
|
2851
|
-
coerce:
|
|
2852
|
-
any:
|
|
2853
|
-
array:
|
|
2854
|
-
bigint:
|
|
2855
|
-
boolean:
|
|
2856
|
-
date:
|
|
2857
|
-
discriminatedUnion:
|
|
2858
|
-
effect:
|
|
2859
|
-
enum:
|
|
2860
|
-
function:
|
|
2861
|
-
instanceof:
|
|
2862
|
-
intersection:
|
|
2863
|
-
lazy:
|
|
2864
|
-
literal:
|
|
2865
|
-
map:
|
|
2866
|
-
nan:
|
|
2867
|
-
nativeEnum:
|
|
2868
|
-
never:
|
|
2869
|
-
null:
|
|
2870
|
-
nullable:
|
|
2871
|
-
number:
|
|
2872
|
-
object:
|
|
2873
|
-
oboolean:
|
|
2874
|
-
onumber:
|
|
2875
|
-
optional:
|
|
2876
|
-
ostring:
|
|
2877
|
-
pipeline:
|
|
2878
|
-
preprocess:
|
|
2879
|
-
promise:
|
|
2880
|
-
record:
|
|
2881
|
-
set:
|
|
2882
|
-
strictObject:
|
|
2883
|
-
string:
|
|
2884
|
-
symbol:
|
|
2885
|
-
transformer:
|
|
2886
|
-
tuple:
|
|
2887
|
-
undefined:
|
|
2888
|
-
union:
|
|
2889
|
-
unknown:
|
|
2890
|
-
void:
|
|
2891
|
-
NEVER:
|
|
2892
|
-
ZodIssueCode:
|
|
2893
|
-
quotelessJson:
|
|
2894
|
-
ZodError:
|
|
2851
|
+
coerce: ns,
|
|
2852
|
+
any: Nt,
|
|
2853
|
+
array: At,
|
|
2854
|
+
bigint: Tt,
|
|
2855
|
+
boolean: We,
|
|
2856
|
+
date: Rt,
|
|
2857
|
+
discriminatedUnion: $t,
|
|
2858
|
+
effect: Pe,
|
|
2859
|
+
enum: Wt,
|
|
2860
|
+
function: zt,
|
|
2861
|
+
instanceof: kt,
|
|
2862
|
+
intersection: Ut,
|
|
2863
|
+
lazy: Gt,
|
|
2864
|
+
literal: Qt,
|
|
2865
|
+
map: Dt,
|
|
2866
|
+
nan: St,
|
|
2867
|
+
nativeEnum: Ht,
|
|
2868
|
+
never: It,
|
|
2869
|
+
null: Zt,
|
|
2870
|
+
nullable: Xt,
|
|
2871
|
+
number: Qe,
|
|
2872
|
+
object: jt,
|
|
2873
|
+
oboolean: ss,
|
|
2874
|
+
onumber: ts,
|
|
2875
|
+
optional: Jt,
|
|
2876
|
+
ostring: es,
|
|
2877
|
+
pipeline: Ft,
|
|
2878
|
+
preprocess: Kt,
|
|
2879
|
+
promise: Yt,
|
|
2880
|
+
record: Vt,
|
|
2881
|
+
set: Bt,
|
|
2882
|
+
strictObject: Pt,
|
|
2883
|
+
string: Ge,
|
|
2884
|
+
symbol: Et,
|
|
2885
|
+
transformer: Pe,
|
|
2886
|
+
tuple: Lt,
|
|
2887
|
+
undefined: Ct,
|
|
2888
|
+
union: qt,
|
|
2889
|
+
unknown: Mt,
|
|
2890
|
+
void: Ot,
|
|
2891
|
+
NEVER: rs,
|
|
2892
|
+
ZodIssueCode: c,
|
|
2893
|
+
quotelessJson: nt,
|
|
2894
|
+
ZodError: E
|
|
2895
2895
|
});
|
|
2896
|
-
const
|
|
2897
|
-
type:
|
|
2898
|
-
id:
|
|
2899
|
-
}),
|
|
2900
|
-
status:
|
|
2901
|
-
question:
|
|
2902
|
-
answer:
|
|
2903
|
-
}),
|
|
2904
|
-
status:
|
|
2905
|
-
}),
|
|
2906
|
-
status:
|
|
2907
|
-
message:
|
|
2908
|
-
}),
|
|
2909
|
-
semanticColor:
|
|
2910
|
-
label:
|
|
2911
|
-
description:
|
|
2912
|
-
disabled:
|
|
2913
|
-
required:
|
|
2914
|
-
hidden:
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
}),
|
|
2923
|
-
|
|
2924
|
-
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2930
|
-
|
|
2931
|
-
}),
|
|
2932
|
-
|
|
2933
|
-
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2896
|
+
const w = h.object({
|
|
2897
|
+
type: h.literal("qp-bridge"),
|
|
2898
|
+
id: h.string().optional()
|
|
2899
|
+
}), as = w.extend({
|
|
2900
|
+
status: h.literal("answerChanged"),
|
|
2901
|
+
question: h.string(),
|
|
2902
|
+
answer: h.unknown()
|
|
2903
|
+
}), K = w.extend({
|
|
2904
|
+
status: h.literal("success")
|
|
2905
|
+
}), is = w.extend({
|
|
2906
|
+
status: h.literal("error"),
|
|
2907
|
+
message: h.string()
|
|
2908
|
+
}), He = h.object({
|
|
2909
|
+
semanticColor: h.string().optional(),
|
|
2910
|
+
label: h.string(),
|
|
2911
|
+
description: h.string(),
|
|
2912
|
+
disabled: h.boolean(),
|
|
2913
|
+
required: h.boolean(),
|
|
2914
|
+
hidden: h.boolean(),
|
|
2915
|
+
errorMessage: h.string().optional(),
|
|
2916
|
+
answer: h.unknown().optional()
|
|
2917
|
+
}), os = He.partial(), cs = h.object({
|
|
2918
|
+
id: h.string().uuid(),
|
|
2919
|
+
name: h.string(),
|
|
2920
|
+
mimeType: h.string(),
|
|
2921
|
+
blobUrl: h.string()
|
|
2922
|
+
}), Ye = h.record(h.unknown()), Je = h.object({
|
|
2923
|
+
label: h.string(),
|
|
2924
|
+
hidden: h.boolean(),
|
|
2925
|
+
collapsed: h.boolean()
|
|
2926
|
+
}), ds = Je.partial(), us = w.extend({
|
|
2927
|
+
action: h.literal("getQuestion"),
|
|
2928
|
+
question: h.string()
|
|
2929
|
+
}), ls = K.extend({
|
|
2930
|
+
question: He
|
|
2931
|
+
}), fs = w.extend({
|
|
2932
|
+
action: h.literal("setQuestion"),
|
|
2933
|
+
question: h.string(),
|
|
2934
|
+
questionData: os
|
|
2935
|
+
}), hs = w.extend({
|
|
2936
|
+
action: h.literal("getGroup"),
|
|
2937
|
+
group: h.string()
|
|
2938
|
+
}), ps = K.extend({
|
|
2939
|
+
group: Je
|
|
2940
|
+
}), ms = K.extend({
|
|
2941
|
+
canSave: h.boolean()
|
|
2942
|
+
}), gs = w.extend({
|
|
2943
|
+
action: h.literal("canSave")
|
|
2944
|
+
}), ys = w.extend({
|
|
2945
|
+
action: h.literal("setGroup"),
|
|
2946
|
+
group: h.string(),
|
|
2947
|
+
groupData: ds
|
|
2948
|
+
}), vs = w.extend({
|
|
2949
|
+
action: h.literal("setAnswer"),
|
|
2950
|
+
question: h.string(),
|
|
2951
|
+
answer: h.unknown()
|
|
2952
|
+
}), _s = w.extend({
|
|
2953
|
+
action: h.literal("busyIndicatorStart")
|
|
2954
|
+
}), xs = w.extend({
|
|
2955
|
+
action: h.literal("busyIndicatorEnd")
|
|
2956
|
+
}), bs = w.extend({
|
|
2957
|
+
action: h.literal("saveQuestionnaire")
|
|
2958
|
+
}), ws = w.extend({
|
|
2959
|
+
action: h.literal("completeAndCloseQuestionnaire")
|
|
2960
|
+
}), ks = w.extend({
|
|
2961
|
+
action: h.literal("executeCustomCommand"),
|
|
2962
|
+
commandName: h.string()
|
|
2963
|
+
}), Ss = w.extend({
|
|
2964
|
+
action: h.literal("fetchEntities"),
|
|
2965
|
+
fetchXml: h.string()
|
|
2966
|
+
}), Ts = K.extend({
|
|
2967
|
+
entities: h.array(Ye)
|
|
2968
|
+
}), Rs = w.extend({
|
|
2969
|
+
action: h.literal("getEntityById"),
|
|
2970
|
+
entityName: h.string(),
|
|
2971
|
+
entityId: h.string()
|
|
2972
|
+
}), Es = K.extend({
|
|
2973
|
+
entity: Ye
|
|
2974
|
+
}), Cs = w.extend({
|
|
2975
|
+
action: h.literal("repeatGroup"),
|
|
2976
|
+
parentGroupName: h.string(),
|
|
2977
|
+
groupIndex: h.number()
|
|
2978
|
+
}), Zs = w.extend({
|
|
2979
|
+
action: h.literal("addNewGroup"),
|
|
2980
|
+
groupName: h.string()
|
|
2981
|
+
}), Ns = w.extend({
|
|
2982
|
+
action: h.literal("deleteGroup"),
|
|
2983
|
+
parentGroupName: h.string(),
|
|
2984
|
+
groupIndex: h.number()
|
|
2937
2985
|
});
|
|
2938
|
-
function
|
|
2939
|
-
return
|
|
2986
|
+
function Ws(t) {
|
|
2987
|
+
return cs.safeParse(t).success;
|
|
2988
|
+
}
|
|
2989
|
+
function Ms(t) {
|
|
2990
|
+
return as.safeParse(t).success;
|
|
2991
|
+
}
|
|
2992
|
+
function Xe(t) {
|
|
2993
|
+
return w.safeParse(t).success;
|
|
2994
|
+
}
|
|
2995
|
+
function Is(t) {
|
|
2996
|
+
return K.safeParse(t).success;
|
|
2997
|
+
}
|
|
2998
|
+
function Os(t) {
|
|
2999
|
+
return is.safeParse(t).success;
|
|
2940
3000
|
}
|
|
2941
|
-
function
|
|
2942
|
-
return
|
|
3001
|
+
function Hs(t) {
|
|
3002
|
+
return us.safeParse(t).success;
|
|
2943
3003
|
}
|
|
2944
|
-
function
|
|
2945
|
-
return
|
|
3004
|
+
function As(t) {
|
|
3005
|
+
return ls.safeParse(t).success;
|
|
2946
3006
|
}
|
|
2947
|
-
function
|
|
2948
|
-
return
|
|
3007
|
+
function Ys(t) {
|
|
3008
|
+
return vs.safeParse(t).success;
|
|
2949
3009
|
}
|
|
2950
|
-
function
|
|
2951
|
-
return
|
|
3010
|
+
function Js(t) {
|
|
3011
|
+
return fs.safeParse(t).success;
|
|
2952
3012
|
}
|
|
2953
|
-
function
|
|
2954
|
-
return
|
|
3013
|
+
function Xs(t) {
|
|
3014
|
+
return ys.safeParse(t).success;
|
|
2955
3015
|
}
|
|
2956
|
-
function
|
|
2957
|
-
return
|
|
3016
|
+
function Ks(t) {
|
|
3017
|
+
return hs.safeParse(t).success;
|
|
2958
3018
|
}
|
|
2959
|
-
function
|
|
2960
|
-
return
|
|
3019
|
+
function js(t) {
|
|
3020
|
+
return ps.safeParse(t).success;
|
|
2961
3021
|
}
|
|
2962
|
-
function
|
|
2963
|
-
return
|
|
3022
|
+
function Fs(t) {
|
|
3023
|
+
return ms.safeParse(t).success;
|
|
3024
|
+
}
|
|
3025
|
+
function Ps(t) {
|
|
3026
|
+
return gs.safeParse(t).success;
|
|
3027
|
+
}
|
|
3028
|
+
function qs(t) {
|
|
3029
|
+
return _s.safeParse(t).success;
|
|
3030
|
+
}
|
|
3031
|
+
function $s(t) {
|
|
3032
|
+
return xs.safeParse(t).success;
|
|
3033
|
+
}
|
|
3034
|
+
function en(t) {
|
|
3035
|
+
return bs.safeParse(t).success;
|
|
3036
|
+
}
|
|
3037
|
+
function tn(t) {
|
|
3038
|
+
return ws.safeParse(t).success;
|
|
3039
|
+
}
|
|
3040
|
+
function sn(t) {
|
|
3041
|
+
return ks.safeParse(t).success;
|
|
3042
|
+
}
|
|
3043
|
+
function nn(t) {
|
|
3044
|
+
return qs(t) || $s(t);
|
|
3045
|
+
}
|
|
3046
|
+
function Us(t, e) {
|
|
3047
|
+
return !Xe(t) || t.id !== e || !("status" in t);
|
|
3048
|
+
}
|
|
3049
|
+
function rn(t) {
|
|
3050
|
+
return Ss.safeParse(t).success;
|
|
3051
|
+
}
|
|
3052
|
+
function Ls(t) {
|
|
3053
|
+
return Ts.safeParse(t).success;
|
|
3054
|
+
}
|
|
3055
|
+
function an(t) {
|
|
3056
|
+
return Rs.safeParse(t).success;
|
|
3057
|
+
}
|
|
3058
|
+
function Vs(t) {
|
|
3059
|
+
return Es.safeParse(t).success;
|
|
3060
|
+
}
|
|
3061
|
+
function on(t) {
|
|
3062
|
+
return Cs.safeParse(t).success;
|
|
3063
|
+
}
|
|
3064
|
+
function cn(t) {
|
|
3065
|
+
return Zs.safeParse(t).success;
|
|
3066
|
+
}
|
|
3067
|
+
function dn(t) {
|
|
3068
|
+
return Ns.safeParse(t).success;
|
|
3069
|
+
}
|
|
3070
|
+
function Ke(t) {
|
|
3071
|
+
if (t instanceof File || t instanceof Blob)
|
|
3072
|
+
return URL.createObjectURL(t);
|
|
3073
|
+
if (typeof t == "string") {
|
|
3074
|
+
if (/^data:/.test(t)) {
|
|
3075
|
+
const a = t.match(/^data:([^;]+);base64,(.*)$/);
|
|
3076
|
+
if (a) {
|
|
3077
|
+
const i = a[1], o = a[2], u = atob(o), d = new ArrayBuffer(u.length), g = new Uint8Array(d);
|
|
3078
|
+
for (let D = 0; D < u.length; D++)
|
|
3079
|
+
g[D] = u.charCodeAt(D);
|
|
3080
|
+
const R = new Blob([d], { type: i });
|
|
3081
|
+
return URL.createObjectURL(R);
|
|
3082
|
+
}
|
|
3083
|
+
throw new Error("Invalid data URL format. Only base64 data URLs are supported.");
|
|
3084
|
+
}
|
|
3085
|
+
const e = atob(t), s = new ArrayBuffer(e.length), n = new Uint8Array(s);
|
|
3086
|
+
for (let a = 0; a < e.length; a++)
|
|
3087
|
+
n[a] = e.charCodeAt(a);
|
|
3088
|
+
const r = new Blob([s]);
|
|
3089
|
+
return URL.createObjectURL(r);
|
|
3090
|
+
}
|
|
3091
|
+
if (t instanceof ArrayBuffer) {
|
|
3092
|
+
const e = new Blob([t]);
|
|
3093
|
+
return URL.createObjectURL(e);
|
|
3094
|
+
}
|
|
3095
|
+
throw new Error("Unsupported content type for blobUrl");
|
|
3096
|
+
}
|
|
3097
|
+
function un(t, e, s, n) {
|
|
3098
|
+
return {
|
|
3099
|
+
id: n ?? qe(),
|
|
3100
|
+
name: t,
|
|
3101
|
+
mimeType: e,
|
|
3102
|
+
blobUrl: Ke(s)
|
|
3103
|
+
};
|
|
2964
3104
|
}
|
|
2965
|
-
function
|
|
2966
|
-
|
|
3105
|
+
function ln(t, e) {
|
|
3106
|
+
let s = t.blobUrl;
|
|
3107
|
+
return e.content !== void 0 && (s = Ke(e.content)), {
|
|
3108
|
+
...t,
|
|
3109
|
+
...e,
|
|
3110
|
+
blobUrl: s
|
|
3111
|
+
};
|
|
2967
3112
|
}
|
|
2968
|
-
|
|
2969
|
-
|
|
3113
|
+
window.addEventListener("message", Ds);
|
|
3114
|
+
async function fn(t, e) {
|
|
3115
|
+
await M({
|
|
2970
3116
|
type: "qp-bridge",
|
|
2971
3117
|
action: "setAnswer",
|
|
2972
|
-
question:
|
|
3118
|
+
question: t,
|
|
2973
3119
|
answer: e
|
|
2974
3120
|
});
|
|
2975
3121
|
}
|
|
2976
|
-
async function
|
|
2977
|
-
return await
|
|
3122
|
+
async function hn(t) {
|
|
3123
|
+
return await Bs({
|
|
2978
3124
|
type: "qp-bridge",
|
|
2979
3125
|
action: "getQuestion",
|
|
2980
|
-
question:
|
|
3126
|
+
question: t
|
|
2981
3127
|
});
|
|
2982
3128
|
}
|
|
2983
|
-
async function
|
|
2984
|
-
await
|
|
3129
|
+
async function pn(t, e) {
|
|
3130
|
+
await M({
|
|
2985
3131
|
type: "qp-bridge",
|
|
2986
3132
|
action: "setQuestion",
|
|
2987
|
-
question:
|
|
3133
|
+
question: t,
|
|
2988
3134
|
questionData: e
|
|
2989
3135
|
});
|
|
2990
3136
|
}
|
|
2991
|
-
async function
|
|
2992
|
-
return await
|
|
3137
|
+
async function mn(t) {
|
|
3138
|
+
return await zs({
|
|
2993
3139
|
type: "qp-bridge",
|
|
2994
3140
|
action: "getGroup",
|
|
2995
|
-
group:
|
|
3141
|
+
group: t
|
|
3142
|
+
});
|
|
3143
|
+
}
|
|
3144
|
+
async function gn(t, e) {
|
|
3145
|
+
await M({
|
|
3146
|
+
type: "qp-bridge",
|
|
3147
|
+
action: "setGroup",
|
|
3148
|
+
group: t,
|
|
3149
|
+
groupData: e
|
|
2996
3150
|
});
|
|
2997
3151
|
}
|
|
2998
|
-
function
|
|
2999
|
-
const e = (
|
|
3000
|
-
|
|
3152
|
+
function yn(t) {
|
|
3153
|
+
const e = (s) => {
|
|
3154
|
+
Ms(s.data) && t(s.data.question, s.data.answer);
|
|
3001
3155
|
};
|
|
3002
3156
|
return window.addEventListener("message", e), {
|
|
3003
3157
|
cancelSubscription: () => {
|
|
@@ -3005,63 +3159,209 @@ function Es(s) {
|
|
|
3005
3159
|
}
|
|
3006
3160
|
};
|
|
3007
3161
|
}
|
|
3008
|
-
async function
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3162
|
+
async function vn(t) {
|
|
3163
|
+
await M({
|
|
3164
|
+
type: "qp-bridge",
|
|
3165
|
+
action: "busyIndicatorStart"
|
|
3166
|
+
});
|
|
3167
|
+
try {
|
|
3168
|
+
return await t();
|
|
3169
|
+
} finally {
|
|
3170
|
+
await M({
|
|
3171
|
+
type: "qp-bridge",
|
|
3172
|
+
action: "busyIndicatorEnd"
|
|
3173
|
+
});
|
|
3174
|
+
}
|
|
3175
|
+
}
|
|
3176
|
+
async function _n() {
|
|
3177
|
+
await M({
|
|
3178
|
+
type: "qp-bridge",
|
|
3179
|
+
action: "saveQuestionnaire"
|
|
3180
|
+
});
|
|
3181
|
+
}
|
|
3182
|
+
async function xn() {
|
|
3183
|
+
await M({
|
|
3184
|
+
type: "qp-bridge",
|
|
3185
|
+
action: "completeAndCloseQuestionnaire"
|
|
3186
|
+
});
|
|
3187
|
+
}
|
|
3188
|
+
async function bn(t) {
|
|
3189
|
+
await M({
|
|
3190
|
+
type: "qp-bridge",
|
|
3191
|
+
action: "executeCustomCommand",
|
|
3192
|
+
commandName: t
|
|
3193
|
+
});
|
|
3194
|
+
}
|
|
3195
|
+
const te = [];
|
|
3196
|
+
function wn(t) {
|
|
3197
|
+
return te.includes(t) || te.push(t), {
|
|
3198
|
+
cancelSubscription: () => {
|
|
3199
|
+
const e = te.indexOf(t);
|
|
3200
|
+
e !== -1 && te.splice(e, 1);
|
|
3201
|
+
}
|
|
3202
|
+
};
|
|
3203
|
+
}
|
|
3204
|
+
async function Ds(t) {
|
|
3205
|
+
try {
|
|
3206
|
+
if (Ps(t.data)) {
|
|
3207
|
+
const e = await Promise.all(te.map((n) => n())), s = {
|
|
3208
|
+
type: "qp-bridge",
|
|
3209
|
+
status: "success",
|
|
3210
|
+
id: t.data.id,
|
|
3211
|
+
canSave: e.every((n) => n)
|
|
3212
|
+
};
|
|
3213
|
+
window.parent.postMessage(s, "*");
|
|
3214
|
+
}
|
|
3215
|
+
} catch (e) {
|
|
3216
|
+
const s = {
|
|
3217
|
+
type: "qp-bridge",
|
|
3218
|
+
status: "error",
|
|
3219
|
+
id: Xe(t.data) ? t.data.id : void 0,
|
|
3220
|
+
message: e instanceof Error ? e.message : "Unknown error"
|
|
3015
3221
|
};
|
|
3016
|
-
window.
|
|
3222
|
+
window.parent.postMessage(s, "*");
|
|
3223
|
+
}
|
|
3224
|
+
}
|
|
3225
|
+
async function kn(t) {
|
|
3226
|
+
return await Gs({
|
|
3227
|
+
type: "qp-bridge",
|
|
3228
|
+
action: "fetchEntities",
|
|
3229
|
+
fetchXml: t
|
|
3017
3230
|
});
|
|
3018
3231
|
}
|
|
3019
|
-
async function
|
|
3020
|
-
return
|
|
3021
|
-
|
|
3022
|
-
|
|
3232
|
+
async function Sn(t, e) {
|
|
3233
|
+
return await Qs({
|
|
3234
|
+
type: "qp-bridge",
|
|
3235
|
+
action: "getEntityById",
|
|
3236
|
+
entityName: t,
|
|
3237
|
+
entityId: e
|
|
3238
|
+
});
|
|
3239
|
+
}
|
|
3240
|
+
async function Tn(t, e) {
|
|
3241
|
+
await M({
|
|
3242
|
+
type: "qp-bridge",
|
|
3243
|
+
action: "repeatGroup",
|
|
3244
|
+
parentGroupName: t,
|
|
3245
|
+
groupIndex: e
|
|
3023
3246
|
});
|
|
3024
3247
|
}
|
|
3025
|
-
async function
|
|
3026
|
-
|
|
3248
|
+
async function Rn(t) {
|
|
3249
|
+
await M({
|
|
3250
|
+
type: "qp-bridge",
|
|
3251
|
+
action: "addNewGroup",
|
|
3252
|
+
groupName: t
|
|
3253
|
+
});
|
|
3027
3254
|
}
|
|
3028
|
-
async function
|
|
3029
|
-
|
|
3255
|
+
async function En(t, e) {
|
|
3256
|
+
await M({
|
|
3257
|
+
type: "qp-bridge",
|
|
3258
|
+
action: "deleteGroup",
|
|
3259
|
+
parentGroupName: t,
|
|
3260
|
+
groupIndex: e
|
|
3261
|
+
});
|
|
3030
3262
|
}
|
|
3031
|
-
async function
|
|
3032
|
-
return
|
|
3033
|
-
|
|
3034
|
-
|
|
3263
|
+
async function ye(t, e) {
|
|
3264
|
+
return new Promise((s, n) => {
|
|
3265
|
+
const r = qe(), a = (i) => {
|
|
3266
|
+
if (Us(i.data, r))
|
|
3267
|
+
return;
|
|
3268
|
+
const o = e(i.data);
|
|
3269
|
+
o.success ? s(o.data) : Os(i.data) ? n(new Error(i.data.message)) : n(new Error("Unknown message received")), window.removeEventListener("message", a);
|
|
3270
|
+
};
|
|
3271
|
+
window.addEventListener("message", a), window.parent.postMessage({ ...t, id: r }, "*");
|
|
3035
3272
|
});
|
|
3036
3273
|
}
|
|
3274
|
+
async function Bs(t) {
|
|
3275
|
+
return ye(t, (e) => As(e) ? { success: !0, data: e.question } : { success: !1 });
|
|
3276
|
+
}
|
|
3277
|
+
async function zs(t) {
|
|
3278
|
+
return ye(t, (e) => js(e) ? { success: !0, data: e.group } : { success: !1 });
|
|
3279
|
+
}
|
|
3280
|
+
function M(t) {
|
|
3281
|
+
return ye(t, (e) => Is(e) ? { success: !0, data: void 0 } : { success: !1 });
|
|
3282
|
+
}
|
|
3283
|
+
async function Gs(t) {
|
|
3284
|
+
return ye(t, (e) => Ls(e) ? { success: !0, data: e.entities } : { success: !1 });
|
|
3285
|
+
}
|
|
3286
|
+
async function Qs(t) {
|
|
3287
|
+
return ye(t, (e) => Vs(e) ? { success: !0, data: e.entity } : { success: !1 });
|
|
3288
|
+
}
|
|
3037
3289
|
export {
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3290
|
+
Rn as addNewGroup,
|
|
3291
|
+
Zs as addNewGroupRequestMessageSchema,
|
|
3292
|
+
xs as busyIndicatorEndRequestMessageSchema,
|
|
3293
|
+
_s as busyIndicatorStartRequestMessageSchema,
|
|
3294
|
+
gs as canSaveRequestMessageSchema,
|
|
3295
|
+
ms as canSaveSuccessResponseMessageSchema,
|
|
3296
|
+
xn as completeAndCloseQuestionnaire,
|
|
3297
|
+
ws as completeAndCloseQuestionnaireRequestMessageSchema,
|
|
3298
|
+
un as createMediaItem,
|
|
3299
|
+
En as deleteGroup,
|
|
3300
|
+
Ns as deleteGroupRequestMessageSchema,
|
|
3301
|
+
Ye as entitySchema,
|
|
3302
|
+
bn as executeCustomCommand,
|
|
3303
|
+
ks as executeCustomCommandRequestMessageSchema,
|
|
3304
|
+
kn as fetchEntities,
|
|
3305
|
+
Ss as fetchEntitiesRequestMessageSchema,
|
|
3306
|
+
Ts as fetchEntitiesSuccessResponseMessageSchema,
|
|
3307
|
+
Sn as getEntityById,
|
|
3308
|
+
Rs as getEntityByIdRequestMessageSchema,
|
|
3309
|
+
Es as getEntityByIdSuccessResponseMessageSchema,
|
|
3310
|
+
mn as getGroup,
|
|
3311
|
+
hs as getGroupRequestMessageSchema,
|
|
3312
|
+
ps as getGroupSuccessResponseMessageSchema,
|
|
3313
|
+
hn as getQuestion,
|
|
3314
|
+
us as getQuestionRequestMessageSchema,
|
|
3315
|
+
ls as getQuestionSuccessResponseMessageSchema,
|
|
3316
|
+
ds as groupOptionalScheme,
|
|
3317
|
+
Je as groupSchema,
|
|
3318
|
+
cn as isAddNewGroupRequestMessage,
|
|
3319
|
+
$s as isBusyIndicatorEndRequestMessage,
|
|
3320
|
+
qs as isBusyIndicatorStartRequestMessage,
|
|
3321
|
+
Ps as isCanSaveRequestMessage,
|
|
3322
|
+
Fs as isCanSaveSuccessResponseMessage,
|
|
3323
|
+
tn as isCompleteAndCloseQuestionnaireRequestMessage,
|
|
3324
|
+
dn as isDeleteGroupRequestMessage,
|
|
3325
|
+
Os as isErrorMessage,
|
|
3326
|
+
sn as isExecuteCustomCommandRequestMessage,
|
|
3327
|
+
rn as isFetchEntitiesRequestMessage,
|
|
3328
|
+
Ls as isFetchEntitiesSuccessResponseMessage,
|
|
3329
|
+
an as isGetEntityByIdRequestMessage,
|
|
3330
|
+
Vs as isGetEntityByIdSuccessResponseMessage,
|
|
3331
|
+
Ks as isGetGroupRequestMessage,
|
|
3332
|
+
js as isGetGroupSuccessResponseMessage,
|
|
3333
|
+
Hs as isGetQuestionRequestMessage,
|
|
3334
|
+
As as isGetQuestionSuccessResponseMessage,
|
|
3335
|
+
Ws as isMediaItem,
|
|
3336
|
+
Us as isNotRelevantMessage,
|
|
3337
|
+
Ms as isOnAnswerChangeMessage,
|
|
3338
|
+
Xe as isQpBridgeMessage,
|
|
3339
|
+
on as isRepeatGroupRequestMessage,
|
|
3340
|
+
en as isSaveQuestionnaireRequestMessage,
|
|
3341
|
+
Ys as isSetAnswerRequestMessage,
|
|
3342
|
+
Xs as isSetGroupRequestMessage,
|
|
3343
|
+
Js as isSetQuestionRequestMessage,
|
|
3344
|
+
Is as isSuccessMessage,
|
|
3345
|
+
nn as isWithBusyIndicatorRequestMessage,
|
|
3346
|
+
cs as mediaItemSchema,
|
|
3347
|
+
yn as onAnswerChange,
|
|
3348
|
+
as as onAnswerChangeMessageSchema,
|
|
3349
|
+
wn as onSave,
|
|
3350
|
+
w as qpBridgeMessageSchema,
|
|
3351
|
+
os as questionOptionalScheme,
|
|
3352
|
+
He as questionSchema,
|
|
3353
|
+
Tn as repeatGroup,
|
|
3354
|
+
Cs as repeatGroupRequestMessageSchema,
|
|
3355
|
+
is as responseErrorMessageSchema,
|
|
3356
|
+
K as responseSuccessMessageSchema,
|
|
3357
|
+
_n as saveQuestionnaire,
|
|
3358
|
+
bs as saveQuestionnaireRequestMessageSchema,
|
|
3359
|
+
fn as setAnswer,
|
|
3360
|
+
vs as setAnswerRequestMessageSchema,
|
|
3361
|
+
gn as setGroup,
|
|
3362
|
+
ys as setGroupRequestMessageSchema,
|
|
3363
|
+
pn as setQuestion,
|
|
3364
|
+
fs as setQuestionRequestMessageSchema,
|
|
3365
|
+
ln as updateMediaItem,
|
|
3366
|
+
vn as withBusyIndicator
|
|
3067
3367
|
};
|