@connectedxm/zpl-generator 0.0.2-beta.3 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/dist/index.es.js +1082 -1014
- package/dist/src/generate.d.ts +8 -10
- package/dist/src/interfaces.d.ts +37 -0
- package/dist/src/validate.d.ts +320 -152
- package/package.json +8 -4
package/dist/index.es.js
CHANGED
|
@@ -1,49 +1,49 @@
|
|
|
1
|
-
var
|
|
2
|
-
(function(
|
|
3
|
-
|
|
1
|
+
var _;
|
|
2
|
+
(function(s) {
|
|
3
|
+
s.assertEqual = (r) => {
|
|
4
4
|
};
|
|
5
|
-
function e(
|
|
5
|
+
function e(r) {
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
function t(
|
|
7
|
+
s.assertIs = e;
|
|
8
|
+
function t(r) {
|
|
9
9
|
throw new Error();
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
s.assertNever = t, s.arrayToEnum = (r) => {
|
|
12
12
|
const a = {};
|
|
13
|
-
for (const i of
|
|
13
|
+
for (const i of r)
|
|
14
14
|
a[i] = i;
|
|
15
15
|
return a;
|
|
16
|
-
},
|
|
17
|
-
const a =
|
|
16
|
+
}, s.getValidEnumValues = (r) => {
|
|
17
|
+
const a = s.objectKeys(r).filter((o) => typeof r[r[o]] != "number"), i = {};
|
|
18
18
|
for (const o of a)
|
|
19
|
-
i[o] =
|
|
20
|
-
return
|
|
21
|
-
},
|
|
22
|
-
return
|
|
23
|
-
}),
|
|
19
|
+
i[o] = r[o];
|
|
20
|
+
return s.objectValues(i);
|
|
21
|
+
}, s.objectValues = (r) => s.objectKeys(r).map(function(a) {
|
|
22
|
+
return r[a];
|
|
23
|
+
}), s.objectKeys = typeof Object.keys == "function" ? (r) => Object.keys(r) : (r) => {
|
|
24
24
|
const a = [];
|
|
25
|
-
for (const i in
|
|
26
|
-
Object.prototype.hasOwnProperty.call(
|
|
25
|
+
for (const i in r)
|
|
26
|
+
Object.prototype.hasOwnProperty.call(r, i) && a.push(i);
|
|
27
27
|
return a;
|
|
28
|
-
},
|
|
29
|
-
for (const i of
|
|
28
|
+
}, s.find = (r, a) => {
|
|
29
|
+
for (const i of r)
|
|
30
30
|
if (a(i))
|
|
31
31
|
return i;
|
|
32
|
-
},
|
|
33
|
-
function r
|
|
34
|
-
return
|
|
32
|
+
}, s.isInteger = typeof Number.isInteger == "function" ? (r) => Number.isInteger(r) : (r) => typeof r == "number" && Number.isFinite(r) && Math.floor(r) === r;
|
|
33
|
+
function n(r, a = " | ") {
|
|
34
|
+
return r.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
35
35
|
}
|
|
36
|
-
|
|
37
|
-
})(
|
|
36
|
+
s.joinValues = n, s.jsonStringifyReplacer = (r, a) => typeof a == "bigint" ? a.toString() : a;
|
|
37
|
+
})(_ || (_ = {}));
|
|
38
38
|
var pe;
|
|
39
|
-
(function(
|
|
40
|
-
|
|
39
|
+
(function(s) {
|
|
40
|
+
s.mergeShapes = (e, t) => ({
|
|
41
41
|
...e,
|
|
42
42
|
...t
|
|
43
43
|
// second overwrites first
|
|
44
44
|
});
|
|
45
45
|
})(pe || (pe = {}));
|
|
46
|
-
const u =
|
|
46
|
+
const u = _.arrayToEnum([
|
|
47
47
|
"string",
|
|
48
48
|
"nan",
|
|
49
49
|
"number",
|
|
@@ -64,14 +64,14 @@ const u = v.arrayToEnum([
|
|
|
64
64
|
"never",
|
|
65
65
|
"map",
|
|
66
66
|
"set"
|
|
67
|
-
]),
|
|
68
|
-
switch (typeof
|
|
67
|
+
]), O = (s) => {
|
|
68
|
+
switch (typeof s) {
|
|
69
69
|
case "undefined":
|
|
70
70
|
return u.undefined;
|
|
71
71
|
case "string":
|
|
72
72
|
return u.string;
|
|
73
73
|
case "number":
|
|
74
|
-
return Number.isNaN(
|
|
74
|
+
return Number.isNaN(s) ? u.nan : u.number;
|
|
75
75
|
case "boolean":
|
|
76
76
|
return u.boolean;
|
|
77
77
|
case "function":
|
|
@@ -81,11 +81,11 @@ const u = v.arrayToEnum([
|
|
|
81
81
|
case "symbol":
|
|
82
82
|
return u.symbol;
|
|
83
83
|
case "object":
|
|
84
|
-
return Array.isArray(
|
|
84
|
+
return Array.isArray(s) ? u.array : s === null ? u.null : s.then && typeof s.then == "function" && s.catch && typeof s.catch == "function" ? u.promise : typeof Map < "u" && s instanceof Map ? u.map : typeof Set < "u" && s instanceof Set ? u.set : typeof Date < "u" && s instanceof Date ? u.date : u.object;
|
|
85
85
|
default:
|
|
86
86
|
return u.unknown;
|
|
87
87
|
}
|
|
88
|
-
},
|
|
88
|
+
}, c = _.arrayToEnum([
|
|
89
89
|
"invalid_type",
|
|
90
90
|
"invalid_literal",
|
|
91
91
|
"custom",
|
|
@@ -103,15 +103,15 @@ const u = v.arrayToEnum([
|
|
|
103
103
|
"not_multiple_of",
|
|
104
104
|
"not_finite"
|
|
105
105
|
]);
|
|
106
|
-
class
|
|
106
|
+
class N extends Error {
|
|
107
107
|
get errors() {
|
|
108
108
|
return this.issues;
|
|
109
109
|
}
|
|
110
110
|
constructor(e) {
|
|
111
|
-
super(), this.issues = [], this.addIssue = (
|
|
112
|
-
this.issues = [...this.issues,
|
|
113
|
-
}, this.addIssues = (
|
|
114
|
-
this.issues = [...this.issues, ...
|
|
111
|
+
super(), this.issues = [], this.addIssue = (n) => {
|
|
112
|
+
this.issues = [...this.issues, n];
|
|
113
|
+
}, this.addIssues = (n = []) => {
|
|
114
|
+
this.issues = [...this.issues, ...n];
|
|
115
115
|
};
|
|
116
116
|
const t = new.target.prototype;
|
|
117
117
|
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
@@ -119,152 +119,152 @@ class O extends Error {
|
|
|
119
119
|
format(e) {
|
|
120
120
|
const t = e || function(a) {
|
|
121
121
|
return a.message;
|
|
122
|
-
},
|
|
122
|
+
}, n = { _errors: [] }, r = (a) => {
|
|
123
123
|
for (const i of a.issues)
|
|
124
124
|
if (i.code === "invalid_union")
|
|
125
|
-
i.unionErrors.map(
|
|
125
|
+
i.unionErrors.map(r);
|
|
126
126
|
else if (i.code === "invalid_return_type")
|
|
127
|
-
|
|
127
|
+
r(i.returnTypeError);
|
|
128
128
|
else if (i.code === "invalid_arguments")
|
|
129
|
-
|
|
129
|
+
r(i.argumentsError);
|
|
130
130
|
else if (i.path.length === 0)
|
|
131
|
-
|
|
131
|
+
n._errors.push(t(i));
|
|
132
132
|
else {
|
|
133
|
-
let o =
|
|
134
|
-
for (;
|
|
135
|
-
const
|
|
136
|
-
|
|
133
|
+
let o = n, h = 0;
|
|
134
|
+
for (; h < i.path.length; ) {
|
|
135
|
+
const f = i.path[h];
|
|
136
|
+
h === i.path.length - 1 ? (o[f] = o[f] || { _errors: [] }, o[f]._errors.push(t(i))) : o[f] = o[f] || { _errors: [] }, o = o[f], h++;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
|
-
return
|
|
140
|
+
return r(this), n;
|
|
141
141
|
}
|
|
142
142
|
static assert(e) {
|
|
143
|
-
if (!(e instanceof
|
|
143
|
+
if (!(e instanceof N))
|
|
144
144
|
throw new Error(`Not a ZodError: ${e}`);
|
|
145
145
|
}
|
|
146
146
|
toString() {
|
|
147
147
|
return this.message;
|
|
148
148
|
}
|
|
149
149
|
get message() {
|
|
150
|
-
return JSON.stringify(this.issues,
|
|
150
|
+
return JSON.stringify(this.issues, _.jsonStringifyReplacer, 2);
|
|
151
151
|
}
|
|
152
152
|
get isEmpty() {
|
|
153
153
|
return this.issues.length === 0;
|
|
154
154
|
}
|
|
155
155
|
flatten(e = (t) => t.message) {
|
|
156
|
-
const t = {},
|
|
157
|
-
for (const
|
|
158
|
-
if (
|
|
159
|
-
const a =
|
|
160
|
-
t[a] = t[a] || [], t[a].push(e(
|
|
156
|
+
const t = {}, n = [];
|
|
157
|
+
for (const r of this.issues)
|
|
158
|
+
if (r.path.length > 0) {
|
|
159
|
+
const a = r.path[0];
|
|
160
|
+
t[a] = t[a] || [], t[a].push(e(r));
|
|
161
161
|
} else
|
|
162
|
-
|
|
163
|
-
return { formErrors:
|
|
162
|
+
n.push(e(r));
|
|
163
|
+
return { formErrors: n, fieldErrors: t };
|
|
164
164
|
}
|
|
165
165
|
get formErrors() {
|
|
166
166
|
return this.flatten();
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
|
|
170
|
-
const ae = (
|
|
169
|
+
N.create = (s) => new N(s);
|
|
170
|
+
const ae = (s, e) => {
|
|
171
171
|
let t;
|
|
172
|
-
switch (
|
|
173
|
-
case
|
|
174
|
-
|
|
172
|
+
switch (s.code) {
|
|
173
|
+
case c.invalid_type:
|
|
174
|
+
s.received === u.undefined ? t = "Required" : t = `Expected ${s.expected}, received ${s.received}`;
|
|
175
175
|
break;
|
|
176
|
-
case
|
|
177
|
-
t = `Invalid literal value, expected ${JSON.stringify(
|
|
176
|
+
case c.invalid_literal:
|
|
177
|
+
t = `Invalid literal value, expected ${JSON.stringify(s.expected, _.jsonStringifyReplacer)}`;
|
|
178
178
|
break;
|
|
179
|
-
case
|
|
180
|
-
t = `Unrecognized key(s) in object: ${
|
|
179
|
+
case c.unrecognized_keys:
|
|
180
|
+
t = `Unrecognized key(s) in object: ${_.joinValues(s.keys, ", ")}`;
|
|
181
181
|
break;
|
|
182
|
-
case
|
|
182
|
+
case c.invalid_union:
|
|
183
183
|
t = "Invalid input";
|
|
184
184
|
break;
|
|
185
|
-
case
|
|
186
|
-
t = `Invalid discriminator value. Expected ${
|
|
185
|
+
case c.invalid_union_discriminator:
|
|
186
|
+
t = `Invalid discriminator value. Expected ${_.joinValues(s.options)}`;
|
|
187
187
|
break;
|
|
188
|
-
case
|
|
189
|
-
t = `Invalid enum value. Expected ${
|
|
188
|
+
case c.invalid_enum_value:
|
|
189
|
+
t = `Invalid enum value. Expected ${_.joinValues(s.options)}, received '${s.received}'`;
|
|
190
190
|
break;
|
|
191
|
-
case
|
|
191
|
+
case c.invalid_arguments:
|
|
192
192
|
t = "Invalid function arguments";
|
|
193
193
|
break;
|
|
194
|
-
case
|
|
194
|
+
case c.invalid_return_type:
|
|
195
195
|
t = "Invalid function return type";
|
|
196
196
|
break;
|
|
197
|
-
case
|
|
197
|
+
case c.invalid_date:
|
|
198
198
|
t = "Invalid date";
|
|
199
199
|
break;
|
|
200
|
-
case
|
|
201
|
-
typeof
|
|
200
|
+
case c.invalid_string:
|
|
201
|
+
typeof s.validation == "object" ? "includes" in s.validation ? (t = `Invalid input: must include "${s.validation.includes}"`, typeof s.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${s.validation.position}`)) : "startsWith" in s.validation ? t = `Invalid input: must start with "${s.validation.startsWith}"` : "endsWith" in s.validation ? t = `Invalid input: must end with "${s.validation.endsWith}"` : _.assertNever(s.validation) : s.validation !== "regex" ? t = `Invalid ${s.validation}` : t = "Invalid";
|
|
202
202
|
break;
|
|
203
|
-
case
|
|
204
|
-
|
|
203
|
+
case c.too_small:
|
|
204
|
+
s.type === "array" ? t = `Array must contain ${s.exact ? "exactly" : s.inclusive ? "at least" : "more than"} ${s.minimum} element(s)` : s.type === "string" ? t = `String must contain ${s.exact ? "exactly" : s.inclusive ? "at least" : "over"} ${s.minimum} character(s)` : s.type === "number" ? t = `Number must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${s.minimum}` : s.type === "bigint" ? t = `Number must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${s.minimum}` : s.type === "date" ? t = `Date must be ${s.exact ? "exactly equal to " : s.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(s.minimum))}` : t = "Invalid input";
|
|
205
205
|
break;
|
|
206
|
-
case
|
|
207
|
-
|
|
206
|
+
case c.too_big:
|
|
207
|
+
s.type === "array" ? t = `Array must contain ${s.exact ? "exactly" : s.inclusive ? "at most" : "less than"} ${s.maximum} element(s)` : s.type === "string" ? t = `String must contain ${s.exact ? "exactly" : s.inclusive ? "at most" : "under"} ${s.maximum} character(s)` : s.type === "number" ? t = `Number must be ${s.exact ? "exactly" : s.inclusive ? "less than or equal to" : "less than"} ${s.maximum}` : s.type === "bigint" ? t = `BigInt must be ${s.exact ? "exactly" : s.inclusive ? "less than or equal to" : "less than"} ${s.maximum}` : s.type === "date" ? t = `Date must be ${s.exact ? "exactly" : s.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(s.maximum))}` : t = "Invalid input";
|
|
208
208
|
break;
|
|
209
|
-
case
|
|
209
|
+
case c.custom:
|
|
210
210
|
t = "Invalid input";
|
|
211
211
|
break;
|
|
212
|
-
case
|
|
212
|
+
case c.invalid_intersection_types:
|
|
213
213
|
t = "Intersection results could not be merged";
|
|
214
214
|
break;
|
|
215
|
-
case
|
|
216
|
-
t = `Number must be a multiple of ${
|
|
215
|
+
case c.not_multiple_of:
|
|
216
|
+
t = `Number must be a multiple of ${s.multipleOf}`;
|
|
217
217
|
break;
|
|
218
|
-
case
|
|
218
|
+
case c.not_finite:
|
|
219
219
|
t = "Number must be finite";
|
|
220
220
|
break;
|
|
221
221
|
default:
|
|
222
|
-
t = e.defaultError,
|
|
222
|
+
t = e.defaultError, _.assertNever(s);
|
|
223
223
|
}
|
|
224
224
|
return { message: t };
|
|
225
225
|
};
|
|
226
|
-
let
|
|
227
|
-
function
|
|
228
|
-
return
|
|
226
|
+
let je = ae;
|
|
227
|
+
function Ee() {
|
|
228
|
+
return je;
|
|
229
229
|
}
|
|
230
|
-
const
|
|
231
|
-
const { data: e, path: t, errorMaps:
|
|
232
|
-
...
|
|
230
|
+
const Ie = (s) => {
|
|
231
|
+
const { data: e, path: t, errorMaps: n, issueData: r } = s, a = [...t, ...r.path || []], i = {
|
|
232
|
+
...r,
|
|
233
233
|
path: a
|
|
234
234
|
};
|
|
235
|
-
if (
|
|
235
|
+
if (r.message !== void 0)
|
|
236
236
|
return {
|
|
237
|
-
...
|
|
237
|
+
...r,
|
|
238
238
|
path: a,
|
|
239
|
-
message:
|
|
239
|
+
message: r.message
|
|
240
240
|
};
|
|
241
241
|
let o = "";
|
|
242
|
-
const
|
|
243
|
-
for (const
|
|
244
|
-
o =
|
|
242
|
+
const h = n.filter((f) => !!f).slice().reverse();
|
|
243
|
+
for (const f of h)
|
|
244
|
+
o = f(i, { data: e, defaultError: o }).message;
|
|
245
245
|
return {
|
|
246
|
-
...
|
|
246
|
+
...r,
|
|
247
247
|
path: a,
|
|
248
248
|
message: o
|
|
249
249
|
};
|
|
250
250
|
};
|
|
251
|
-
function
|
|
252
|
-
const t =
|
|
251
|
+
function d(s, e) {
|
|
252
|
+
const t = Ee(), n = Ie({
|
|
253
253
|
issueData: e,
|
|
254
|
-
data:
|
|
255
|
-
path:
|
|
254
|
+
data: s.data,
|
|
255
|
+
path: s.path,
|
|
256
256
|
errorMaps: [
|
|
257
|
-
|
|
257
|
+
s.common.contextualErrorMap,
|
|
258
258
|
// contextual error map is first priority
|
|
259
|
-
|
|
259
|
+
s.schemaErrorMap,
|
|
260
260
|
// then schema-bound map if available
|
|
261
261
|
t,
|
|
262
262
|
// then global override map
|
|
263
263
|
t === ae ? void 0 : ae
|
|
264
264
|
// then global default map
|
|
265
|
-
].filter((
|
|
265
|
+
].filter((r) => !!r)
|
|
266
266
|
});
|
|
267
|
-
|
|
267
|
+
s.common.issues.push(n);
|
|
268
268
|
}
|
|
269
269
|
class w {
|
|
270
270
|
constructor() {
|
|
@@ -277,89 +277,89 @@ class w {
|
|
|
277
277
|
this.value !== "aborted" && (this.value = "aborted");
|
|
278
278
|
}
|
|
279
279
|
static mergeArray(e, t) {
|
|
280
|
-
const
|
|
281
|
-
for (const
|
|
282
|
-
if (
|
|
280
|
+
const n = [];
|
|
281
|
+
for (const r of t) {
|
|
282
|
+
if (r.status === "aborted")
|
|
283
283
|
return m;
|
|
284
|
-
|
|
284
|
+
r.status === "dirty" && e.dirty(), n.push(r.value);
|
|
285
285
|
}
|
|
286
|
-
return { status: e.value, value:
|
|
286
|
+
return { status: e.value, value: n };
|
|
287
287
|
}
|
|
288
288
|
static async mergeObjectAsync(e, t) {
|
|
289
|
-
const
|
|
290
|
-
for (const
|
|
291
|
-
const a = await
|
|
292
|
-
|
|
289
|
+
const n = [];
|
|
290
|
+
for (const r of t) {
|
|
291
|
+
const a = await r.key, i = await r.value;
|
|
292
|
+
n.push({
|
|
293
293
|
key: a,
|
|
294
294
|
value: i
|
|
295
295
|
});
|
|
296
296
|
}
|
|
297
|
-
return w.mergeObjectSync(e,
|
|
297
|
+
return w.mergeObjectSync(e, n);
|
|
298
298
|
}
|
|
299
299
|
static mergeObjectSync(e, t) {
|
|
300
|
-
const
|
|
301
|
-
for (const
|
|
302
|
-
const { key: a, value: i } =
|
|
300
|
+
const n = {};
|
|
301
|
+
for (const r of t) {
|
|
302
|
+
const { key: a, value: i } = r;
|
|
303
303
|
if (a.status === "aborted" || i.status === "aborted")
|
|
304
304
|
return m;
|
|
305
|
-
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" ||
|
|
305
|
+
a.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), a.value !== "__proto__" && (typeof i.value < "u" || r.alwaysSet) && (n[a.value] = i.value);
|
|
306
306
|
}
|
|
307
|
-
return { status: e.value, value:
|
|
307
|
+
return { status: e.value, value: n };
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
const m = Object.freeze({
|
|
311
311
|
status: "aborted"
|
|
312
|
-
}),
|
|
312
|
+
}), z = (s) => ({ status: "dirty", value: s }), T = (s) => ({ status: "valid", value: s }), ge = (s) => s.status === "aborted", ye = (s) => s.status === "dirty", V = (s) => s.status === "valid", Y = (s) => typeof Promise < "u" && s instanceof Promise;
|
|
313
313
|
var l;
|
|
314
|
-
(function(
|
|
315
|
-
|
|
314
|
+
(function(s) {
|
|
315
|
+
s.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, s.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
316
316
|
})(l || (l = {}));
|
|
317
|
-
class
|
|
318
|
-
constructor(e, t,
|
|
319
|
-
this._cachedPath = [], this.parent = e, this.data = t, this._path =
|
|
317
|
+
class R {
|
|
318
|
+
constructor(e, t, n, r) {
|
|
319
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = n, this._key = r;
|
|
320
320
|
}
|
|
321
321
|
get path() {
|
|
322
322
|
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
323
323
|
}
|
|
324
324
|
}
|
|
325
|
-
const _e = (
|
|
326
|
-
if (
|
|
325
|
+
const _e = (s, e) => {
|
|
326
|
+
if (V(e))
|
|
327
327
|
return { success: !0, data: e.value };
|
|
328
|
-
if (!
|
|
328
|
+
if (!s.common.issues.length)
|
|
329
329
|
throw new Error("Validation failed but no issues detected.");
|
|
330
330
|
return {
|
|
331
331
|
success: !1,
|
|
332
332
|
get error() {
|
|
333
333
|
if (this._error)
|
|
334
334
|
return this._error;
|
|
335
|
-
const t = new
|
|
335
|
+
const t = new N(s.common.issues);
|
|
336
336
|
return this._error = t, this._error;
|
|
337
337
|
}
|
|
338
338
|
};
|
|
339
339
|
};
|
|
340
|
-
function g(
|
|
341
|
-
if (!
|
|
340
|
+
function g(s) {
|
|
341
|
+
if (!s)
|
|
342
342
|
return {};
|
|
343
|
-
const { errorMap: e, invalid_type_error: t, required_error:
|
|
344
|
-
if (e && (t ||
|
|
343
|
+
const { errorMap: e, invalid_type_error: t, required_error: n, description: r } = s;
|
|
344
|
+
if (e && (t || n))
|
|
345
345
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
346
|
-
return e ? { errorMap: e, description:
|
|
347
|
-
const { message:
|
|
348
|
-
return i.code === "invalid_enum_value" ? { message:
|
|
349
|
-
}, description:
|
|
346
|
+
return e ? { errorMap: e, description: r } : { errorMap: (i, o) => {
|
|
347
|
+
const { message: h } = s;
|
|
348
|
+
return i.code === "invalid_enum_value" ? { message: h ?? o.defaultError } : typeof o.data > "u" ? { message: h ?? n ?? o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: h ?? t ?? o.defaultError };
|
|
349
|
+
}, description: r };
|
|
350
350
|
}
|
|
351
|
-
class
|
|
351
|
+
class y {
|
|
352
352
|
get description() {
|
|
353
353
|
return this._def.description;
|
|
354
354
|
}
|
|
355
355
|
_getType(e) {
|
|
356
|
-
return
|
|
356
|
+
return O(e.data);
|
|
357
357
|
}
|
|
358
358
|
_getOrReturnCtx(e, t) {
|
|
359
359
|
return t || {
|
|
360
360
|
common: e.parent.common,
|
|
361
361
|
data: e.data,
|
|
362
|
-
parsedType:
|
|
362
|
+
parsedType: O(e.data),
|
|
363
363
|
schemaErrorMap: this._def.errorMap,
|
|
364
364
|
path: e.path,
|
|
365
365
|
parent: e.parent
|
|
@@ -371,7 +371,7 @@ class _ {
|
|
|
371
371
|
ctx: {
|
|
372
372
|
common: e.parent.common,
|
|
373
373
|
data: e.data,
|
|
374
|
-
parsedType:
|
|
374
|
+
parsedType: O(e.data),
|
|
375
375
|
schemaErrorMap: this._def.errorMap,
|
|
376
376
|
path: e.path,
|
|
377
377
|
parent: e.parent
|
|
@@ -380,7 +380,7 @@ class _ {
|
|
|
380
380
|
}
|
|
381
381
|
_parseSync(e) {
|
|
382
382
|
const t = this._parse(e);
|
|
383
|
-
if (
|
|
383
|
+
if (Y(t))
|
|
384
384
|
throw new Error("Synchronous parse encountered promise.");
|
|
385
385
|
return t;
|
|
386
386
|
}
|
|
@@ -389,13 +389,13 @@ class _ {
|
|
|
389
389
|
return Promise.resolve(t);
|
|
390
390
|
}
|
|
391
391
|
parse(e, t) {
|
|
392
|
-
const
|
|
393
|
-
if (
|
|
394
|
-
return
|
|
395
|
-
throw
|
|
392
|
+
const n = this.safeParse(e, t);
|
|
393
|
+
if (n.success)
|
|
394
|
+
return n.data;
|
|
395
|
+
throw n.error;
|
|
396
396
|
}
|
|
397
397
|
safeParse(e, t) {
|
|
398
|
-
const
|
|
398
|
+
const n = {
|
|
399
399
|
common: {
|
|
400
400
|
issues: [],
|
|
401
401
|
async: t?.async ?? !1,
|
|
@@ -405,9 +405,9 @@ class _ {
|
|
|
405
405
|
schemaErrorMap: this._def.errorMap,
|
|
406
406
|
parent: null,
|
|
407
407
|
data: e,
|
|
408
|
-
parsedType:
|
|
409
|
-
},
|
|
410
|
-
return _e(
|
|
408
|
+
parsedType: O(e)
|
|
409
|
+
}, r = this._parseSync({ data: e, path: n.path, parent: n });
|
|
410
|
+
return _e(n, r);
|
|
411
411
|
}
|
|
412
412
|
"~validate"(e) {
|
|
413
413
|
const t = {
|
|
@@ -419,36 +419,36 @@ class _ {
|
|
|
419
419
|
schemaErrorMap: this._def.errorMap,
|
|
420
420
|
parent: null,
|
|
421
421
|
data: e,
|
|
422
|
-
parsedType:
|
|
422
|
+
parsedType: O(e)
|
|
423
423
|
};
|
|
424
424
|
if (!this["~standard"].async)
|
|
425
425
|
try {
|
|
426
|
-
const
|
|
427
|
-
return
|
|
428
|
-
value:
|
|
426
|
+
const n = this._parseSync({ data: e, path: [], parent: t });
|
|
427
|
+
return V(n) ? {
|
|
428
|
+
value: n.value
|
|
429
429
|
} : {
|
|
430
430
|
issues: t.common.issues
|
|
431
431
|
};
|
|
432
|
-
} catch (
|
|
433
|
-
|
|
432
|
+
} catch (n) {
|
|
433
|
+
n?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0), t.common = {
|
|
434
434
|
issues: [],
|
|
435
435
|
async: !0
|
|
436
436
|
};
|
|
437
437
|
}
|
|
438
|
-
return this._parseAsync({ data: e, path: [], parent: t }).then((
|
|
439
|
-
value:
|
|
438
|
+
return this._parseAsync({ data: e, path: [], parent: t }).then((n) => V(n) ? {
|
|
439
|
+
value: n.value
|
|
440
440
|
} : {
|
|
441
441
|
issues: t.common.issues
|
|
442
442
|
});
|
|
443
443
|
}
|
|
444
444
|
async parseAsync(e, t) {
|
|
445
|
-
const
|
|
446
|
-
if (
|
|
447
|
-
return
|
|
448
|
-
throw
|
|
445
|
+
const n = await this.safeParseAsync(e, t);
|
|
446
|
+
if (n.success)
|
|
447
|
+
return n.data;
|
|
448
|
+
throw n.error;
|
|
449
449
|
}
|
|
450
450
|
async safeParseAsync(e, t) {
|
|
451
|
-
const
|
|
451
|
+
const n = {
|
|
452
452
|
common: {
|
|
453
453
|
issues: [],
|
|
454
454
|
contextualErrorMap: t?.errorMap,
|
|
@@ -458,25 +458,25 @@ class _ {
|
|
|
458
458
|
schemaErrorMap: this._def.errorMap,
|
|
459
459
|
parent: null,
|
|
460
460
|
data: e,
|
|
461
|
-
parsedType:
|
|
462
|
-
},
|
|
463
|
-
return _e(
|
|
461
|
+
parsedType: O(e)
|
|
462
|
+
}, r = this._parse({ data: e, path: n.path, parent: n }), a = await (Y(r) ? r : Promise.resolve(r));
|
|
463
|
+
return _e(n, a);
|
|
464
464
|
}
|
|
465
465
|
refine(e, t) {
|
|
466
|
-
const
|
|
467
|
-
return this._refinement((
|
|
468
|
-
const i = e(
|
|
469
|
-
code:
|
|
470
|
-
...r
|
|
466
|
+
const n = (r) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(r) : t;
|
|
467
|
+
return this._refinement((r, a) => {
|
|
468
|
+
const i = e(r), o = () => a.addIssue({
|
|
469
|
+
code: c.custom,
|
|
470
|
+
...n(r)
|
|
471
471
|
});
|
|
472
|
-
return typeof Promise < "u" && i instanceof Promise ? i.then((
|
|
472
|
+
return typeof Promise < "u" && i instanceof Promise ? i.then((h) => h ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
473
473
|
});
|
|
474
474
|
}
|
|
475
475
|
refinement(e, t) {
|
|
476
|
-
return this._refinement((
|
|
476
|
+
return this._refinement((n, r) => e(n) ? !0 : (r.addIssue(typeof t == "function" ? t(n, r) : t), !1));
|
|
477
477
|
}
|
|
478
478
|
_refinement(e) {
|
|
479
|
-
return new
|
|
479
|
+
return new I({
|
|
480
480
|
schema: this,
|
|
481
481
|
typeName: p.ZodEffects,
|
|
482
482
|
effect: { type: "refinement", refinement: e }
|
|
@@ -493,28 +493,28 @@ class _ {
|
|
|
493
493
|
};
|
|
494
494
|
}
|
|
495
495
|
optional() {
|
|
496
|
-
return
|
|
496
|
+
return A.create(this, this._def);
|
|
497
497
|
}
|
|
498
498
|
nullable() {
|
|
499
|
-
return
|
|
499
|
+
return M.create(this, this._def);
|
|
500
500
|
}
|
|
501
501
|
nullish() {
|
|
502
502
|
return this.nullable().optional();
|
|
503
503
|
}
|
|
504
504
|
array() {
|
|
505
|
-
return
|
|
505
|
+
return C.create(this);
|
|
506
506
|
}
|
|
507
507
|
promise() {
|
|
508
|
-
return
|
|
508
|
+
return K.create(this, this._def);
|
|
509
509
|
}
|
|
510
510
|
or(e) {
|
|
511
|
-
return
|
|
511
|
+
return J.create([this, e], this._def);
|
|
512
512
|
}
|
|
513
513
|
and(e) {
|
|
514
|
-
return
|
|
514
|
+
return Q.create(this, e, this._def);
|
|
515
515
|
}
|
|
516
516
|
transform(e) {
|
|
517
|
-
return new
|
|
517
|
+
return new I({
|
|
518
518
|
...g(this._def),
|
|
519
519
|
schema: this,
|
|
520
520
|
typeName: p.ZodEffects,
|
|
@@ -523,7 +523,7 @@ class _ {
|
|
|
523
523
|
}
|
|
524
524
|
default(e) {
|
|
525
525
|
const t = typeof e == "function" ? e : () => e;
|
|
526
|
-
return new
|
|
526
|
+
return new ee({
|
|
527
527
|
...g(this._def),
|
|
528
528
|
innerType: this,
|
|
529
529
|
defaultValue: t,
|
|
@@ -531,7 +531,7 @@ class _ {
|
|
|
531
531
|
});
|
|
532
532
|
}
|
|
533
533
|
brand() {
|
|
534
|
-
return new
|
|
534
|
+
return new Ne({
|
|
535
535
|
typeName: p.ZodBranded,
|
|
536
536
|
type: this,
|
|
537
537
|
...g(this._def)
|
|
@@ -539,7 +539,7 @@ class _ {
|
|
|
539
539
|
}
|
|
540
540
|
catch(e) {
|
|
541
541
|
const t = typeof e == "function" ? e : () => e;
|
|
542
|
-
return new
|
|
542
|
+
return new te({
|
|
543
543
|
...g(this._def),
|
|
544
544
|
innerType: this,
|
|
545
545
|
catchValue: t,
|
|
@@ -554,10 +554,10 @@ class _ {
|
|
|
554
554
|
});
|
|
555
555
|
}
|
|
556
556
|
pipe(e) {
|
|
557
|
-
return
|
|
557
|
+
return he.create(this, e);
|
|
558
558
|
}
|
|
559
559
|
readonly() {
|
|
560
|
-
return
|
|
560
|
+
return se.create(this);
|
|
561
561
|
}
|
|
562
562
|
isOptional() {
|
|
563
563
|
return this.safeParse(void 0).success;
|
|
@@ -566,206 +566,206 @@ class _ {
|
|
|
566
566
|
return this.safeParse(null).success;
|
|
567
567
|
}
|
|
568
568
|
}
|
|
569
|
-
const
|
|
570
|
-
let
|
|
571
|
-
const
|
|
572
|
-
function
|
|
569
|
+
const Me = /^c[^\s-]{8,}$/i, Le = /^[0-9a-z]+$/, Pe = /^[0-9A-HJKMNP-TV-Z]{26}$/i, Ve = /^[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, De = /^[a-z0-9_-]{21}$/i, Be = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, ze = /^[-+]?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)?)??$/, Fe = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Ue = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
570
|
+
let ne;
|
|
571
|
+
const We = /^(?:(?: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])$/, qe = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, Ye = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, He = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, Je = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Qe = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Ce = "((\\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])))", Xe = new RegExp(`^${Ce}$`);
|
|
572
|
+
function Se(s) {
|
|
573
573
|
let e = "[0-5]\\d";
|
|
574
|
-
|
|
575
|
-
const t =
|
|
574
|
+
s.precision ? e = `${e}\\.\\d{${s.precision}}` : s.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
575
|
+
const t = s.precision ? "+" : "?";
|
|
576
576
|
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
|
|
577
577
|
}
|
|
578
|
-
function
|
|
579
|
-
return new RegExp(`^${
|
|
578
|
+
function Ge(s) {
|
|
579
|
+
return new RegExp(`^${Se(s)}$`);
|
|
580
580
|
}
|
|
581
|
-
function
|
|
582
|
-
let e = `${Ce}T${
|
|
581
|
+
function Ke(s) {
|
|
582
|
+
let e = `${Ce}T${Se(s)}`;
|
|
583
583
|
const t = [];
|
|
584
|
-
return t.push(
|
|
584
|
+
return t.push(s.local ? "Z?" : "Z"), s.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
585
585
|
}
|
|
586
|
-
function
|
|
587
|
-
return !!((e === "v4" || !e) &&
|
|
586
|
+
function et(s, e) {
|
|
587
|
+
return !!((e === "v4" || !e) && We.test(s) || (e === "v6" || !e) && Ye.test(s));
|
|
588
588
|
}
|
|
589
|
-
function
|
|
590
|
-
if (!
|
|
589
|
+
function tt(s, e) {
|
|
590
|
+
if (!Be.test(s))
|
|
591
591
|
return !1;
|
|
592
592
|
try {
|
|
593
|
-
const [t] =
|
|
593
|
+
const [t] = s.split(".");
|
|
594
594
|
if (!t)
|
|
595
595
|
return !1;
|
|
596
|
-
const
|
|
597
|
-
return !(typeof
|
|
596
|
+
const n = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), r = JSON.parse(atob(n));
|
|
597
|
+
return !(typeof r != "object" || r === null || "typ" in r && r?.typ !== "JWT" || !r.alg || e && r.alg !== e);
|
|
598
598
|
} catch {
|
|
599
599
|
return !1;
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
-
function
|
|
603
|
-
return !!((e === "v4" || !e) &&
|
|
602
|
+
function st(s, e) {
|
|
603
|
+
return !!((e === "v4" || !e) && qe.test(s) || (e === "v6" || !e) && He.test(s));
|
|
604
604
|
}
|
|
605
|
-
class
|
|
605
|
+
class $ extends y {
|
|
606
606
|
_parse(e) {
|
|
607
607
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== u.string) {
|
|
608
608
|
const a = this._getOrReturnCtx(e);
|
|
609
|
-
return
|
|
610
|
-
code:
|
|
609
|
+
return d(a, {
|
|
610
|
+
code: c.invalid_type,
|
|
611
611
|
expected: u.string,
|
|
612
612
|
received: a.parsedType
|
|
613
613
|
}), m;
|
|
614
614
|
}
|
|
615
|
-
const
|
|
616
|
-
let
|
|
615
|
+
const n = new w();
|
|
616
|
+
let r;
|
|
617
617
|
for (const a of this._def.checks)
|
|
618
618
|
if (a.kind === "min")
|
|
619
|
-
e.data.length < a.value && (
|
|
620
|
-
code:
|
|
619
|
+
e.data.length < a.value && (r = this._getOrReturnCtx(e, r), d(r, {
|
|
620
|
+
code: c.too_small,
|
|
621
621
|
minimum: a.value,
|
|
622
622
|
type: "string",
|
|
623
623
|
inclusive: !0,
|
|
624
624
|
exact: !1,
|
|
625
625
|
message: a.message
|
|
626
|
-
}),
|
|
626
|
+
}), n.dirty());
|
|
627
627
|
else if (a.kind === "max")
|
|
628
|
-
e.data.length > a.value && (
|
|
629
|
-
code:
|
|
628
|
+
e.data.length > a.value && (r = this._getOrReturnCtx(e, r), d(r, {
|
|
629
|
+
code: c.too_big,
|
|
630
630
|
maximum: a.value,
|
|
631
631
|
type: "string",
|
|
632
632
|
inclusive: !0,
|
|
633
633
|
exact: !1,
|
|
634
634
|
message: a.message
|
|
635
|
-
}),
|
|
635
|
+
}), n.dirty());
|
|
636
636
|
else if (a.kind === "length") {
|
|
637
637
|
const i = e.data.length > a.value, o = e.data.length < a.value;
|
|
638
|
-
(i || o) && (
|
|
639
|
-
code:
|
|
638
|
+
(i || o) && (r = this._getOrReturnCtx(e, r), i ? d(r, {
|
|
639
|
+
code: c.too_big,
|
|
640
640
|
maximum: a.value,
|
|
641
641
|
type: "string",
|
|
642
642
|
inclusive: !0,
|
|
643
643
|
exact: !0,
|
|
644
644
|
message: a.message
|
|
645
|
-
}) : o &&
|
|
646
|
-
code:
|
|
645
|
+
}) : o && d(r, {
|
|
646
|
+
code: c.too_small,
|
|
647
647
|
minimum: a.value,
|
|
648
648
|
type: "string",
|
|
649
649
|
inclusive: !0,
|
|
650
650
|
exact: !0,
|
|
651
651
|
message: a.message
|
|
652
|
-
}),
|
|
652
|
+
}), n.dirty());
|
|
653
653
|
} else if (a.kind === "email")
|
|
654
|
-
Fe.test(e.data) || (
|
|
654
|
+
Fe.test(e.data) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
655
655
|
validation: "email",
|
|
656
|
-
code:
|
|
656
|
+
code: c.invalid_string,
|
|
657
657
|
message: a.message
|
|
658
|
-
}),
|
|
658
|
+
}), n.dirty());
|
|
659
659
|
else if (a.kind === "emoji")
|
|
660
|
-
|
|
660
|
+
ne || (ne = new RegExp(Ue, "u")), ne.test(e.data) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
661
661
|
validation: "emoji",
|
|
662
|
-
code:
|
|
662
|
+
code: c.invalid_string,
|
|
663
663
|
message: a.message
|
|
664
|
-
}),
|
|
664
|
+
}), n.dirty());
|
|
665
665
|
else if (a.kind === "uuid")
|
|
666
|
-
|
|
666
|
+
Ve.test(e.data) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
667
667
|
validation: "uuid",
|
|
668
|
-
code:
|
|
668
|
+
code: c.invalid_string,
|
|
669
669
|
message: a.message
|
|
670
|
-
}),
|
|
670
|
+
}), n.dirty());
|
|
671
671
|
else if (a.kind === "nanoid")
|
|
672
|
-
|
|
672
|
+
De.test(e.data) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
673
673
|
validation: "nanoid",
|
|
674
|
-
code:
|
|
674
|
+
code: c.invalid_string,
|
|
675
675
|
message: a.message
|
|
676
|
-
}),
|
|
676
|
+
}), n.dirty());
|
|
677
677
|
else if (a.kind === "cuid")
|
|
678
|
-
|
|
678
|
+
Me.test(e.data) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
679
679
|
validation: "cuid",
|
|
680
|
-
code:
|
|
680
|
+
code: c.invalid_string,
|
|
681
681
|
message: a.message
|
|
682
|
-
}),
|
|
682
|
+
}), n.dirty());
|
|
683
683
|
else if (a.kind === "cuid2")
|
|
684
|
-
|
|
684
|
+
Le.test(e.data) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
685
685
|
validation: "cuid2",
|
|
686
|
-
code:
|
|
686
|
+
code: c.invalid_string,
|
|
687
687
|
message: a.message
|
|
688
|
-
}),
|
|
688
|
+
}), n.dirty());
|
|
689
689
|
else if (a.kind === "ulid")
|
|
690
|
-
|
|
690
|
+
Pe.test(e.data) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
691
691
|
validation: "ulid",
|
|
692
|
-
code:
|
|
692
|
+
code: c.invalid_string,
|
|
693
693
|
message: a.message
|
|
694
|
-
}),
|
|
694
|
+
}), n.dirty());
|
|
695
695
|
else if (a.kind === "url")
|
|
696
696
|
try {
|
|
697
697
|
new URL(e.data);
|
|
698
698
|
} catch {
|
|
699
|
-
|
|
699
|
+
r = this._getOrReturnCtx(e, r), d(r, {
|
|
700
700
|
validation: "url",
|
|
701
|
-
code:
|
|
701
|
+
code: c.invalid_string,
|
|
702
702
|
message: a.message
|
|
703
|
-
}),
|
|
703
|
+
}), n.dirty();
|
|
704
704
|
}
|
|
705
|
-
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (
|
|
705
|
+
else a.kind === "regex" ? (a.regex.lastIndex = 0, a.regex.test(e.data) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
706
706
|
validation: "regex",
|
|
707
|
-
code:
|
|
707
|
+
code: c.invalid_string,
|
|
708
708
|
message: a.message
|
|
709
|
-
}),
|
|
710
|
-
code:
|
|
709
|
+
}), 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), d(r, {
|
|
710
|
+
code: c.invalid_string,
|
|
711
711
|
validation: { includes: a.value, position: a.position },
|
|
712
712
|
message: a.message
|
|
713
|
-
}),
|
|
714
|
-
code:
|
|
713
|
+
}), 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), d(r, {
|
|
714
|
+
code: c.invalid_string,
|
|
715
715
|
validation: { startsWith: a.value },
|
|
716
716
|
message: a.message
|
|
717
|
-
}),
|
|
718
|
-
code:
|
|
717
|
+
}), n.dirty()) : a.kind === "endsWith" ? e.data.endsWith(a.value) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
718
|
+
code: c.invalid_string,
|
|
719
719
|
validation: { endsWith: a.value },
|
|
720
720
|
message: a.message
|
|
721
|
-
}),
|
|
722
|
-
code:
|
|
721
|
+
}), n.dirty()) : a.kind === "datetime" ? Ke(a).test(e.data) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
722
|
+
code: c.invalid_string,
|
|
723
723
|
validation: "datetime",
|
|
724
724
|
message: a.message
|
|
725
|
-
}),
|
|
726
|
-
code:
|
|
725
|
+
}), n.dirty()) : a.kind === "date" ? Xe.test(e.data) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
726
|
+
code: c.invalid_string,
|
|
727
727
|
validation: "date",
|
|
728
728
|
message: a.message
|
|
729
|
-
}),
|
|
730
|
-
code:
|
|
729
|
+
}), n.dirty()) : a.kind === "time" ? Ge(a).test(e.data) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
730
|
+
code: c.invalid_string,
|
|
731
731
|
validation: "time",
|
|
732
732
|
message: a.message
|
|
733
|
-
}),
|
|
733
|
+
}), n.dirty()) : a.kind === "duration" ? ze.test(e.data) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
734
734
|
validation: "duration",
|
|
735
|
-
code:
|
|
735
|
+
code: c.invalid_string,
|
|
736
736
|
message: a.message
|
|
737
|
-
}),
|
|
737
|
+
}), n.dirty()) : a.kind === "ip" ? et(e.data, a.version) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
738
738
|
validation: "ip",
|
|
739
|
-
code:
|
|
739
|
+
code: c.invalid_string,
|
|
740
740
|
message: a.message
|
|
741
|
-
}),
|
|
741
|
+
}), n.dirty()) : a.kind === "jwt" ? tt(e.data, a.alg) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
742
742
|
validation: "jwt",
|
|
743
|
-
code:
|
|
743
|
+
code: c.invalid_string,
|
|
744
744
|
message: a.message
|
|
745
|
-
}),
|
|
745
|
+
}), n.dirty()) : a.kind === "cidr" ? st(e.data, a.version) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
746
746
|
validation: "cidr",
|
|
747
|
-
code:
|
|
747
|
+
code: c.invalid_string,
|
|
748
748
|
message: a.message
|
|
749
|
-
}),
|
|
749
|
+
}), n.dirty()) : a.kind === "base64" ? Je.test(e.data) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
750
750
|
validation: "base64",
|
|
751
|
-
code:
|
|
751
|
+
code: c.invalid_string,
|
|
752
752
|
message: a.message
|
|
753
|
-
}),
|
|
753
|
+
}), n.dirty()) : a.kind === "base64url" ? Qe.test(e.data) || (r = this._getOrReturnCtx(e, r), d(r, {
|
|
754
754
|
validation: "base64url",
|
|
755
|
-
code:
|
|
755
|
+
code: c.invalid_string,
|
|
756
756
|
message: a.message
|
|
757
|
-
}),
|
|
758
|
-
return { status:
|
|
757
|
+
}), n.dirty()) : _.assertNever(a);
|
|
758
|
+
return { status: n.value, value: e.data };
|
|
759
759
|
}
|
|
760
|
-
_regex(e, t,
|
|
761
|
-
return this.refinement((
|
|
760
|
+
_regex(e, t, n) {
|
|
761
|
+
return this.refinement((r) => e.test(r), {
|
|
762
762
|
validation: t,
|
|
763
|
-
code:
|
|
764
|
-
...l.errToObj(
|
|
763
|
+
code: c.invalid_string,
|
|
764
|
+
...l.errToObj(n)
|
|
765
765
|
});
|
|
766
766
|
}
|
|
767
767
|
_addCheck(e) {
|
|
768
|
-
return new
|
|
768
|
+
return new $({
|
|
769
769
|
...this._def,
|
|
770
770
|
checks: [...this._def.checks, e]
|
|
771
771
|
});
|
|
@@ -901,19 +901,19 @@ class R extends _ {
|
|
|
901
901
|
return this.min(1, l.errToObj(e));
|
|
902
902
|
}
|
|
903
903
|
trim() {
|
|
904
|
-
return new
|
|
904
|
+
return new $({
|
|
905
905
|
...this._def,
|
|
906
906
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
907
907
|
});
|
|
908
908
|
}
|
|
909
909
|
toLowerCase() {
|
|
910
|
-
return new
|
|
910
|
+
return new $({
|
|
911
911
|
...this._def,
|
|
912
912
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
913
913
|
});
|
|
914
914
|
}
|
|
915
915
|
toUpperCase() {
|
|
916
|
-
return new
|
|
916
|
+
return new $({
|
|
917
917
|
...this._def,
|
|
918
918
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
919
919
|
});
|
|
@@ -979,60 +979,60 @@ class R extends _ {
|
|
|
979
979
|
return e;
|
|
980
980
|
}
|
|
981
981
|
}
|
|
982
|
-
|
|
982
|
+
$.create = (s) => new $({
|
|
983
983
|
checks: [],
|
|
984
984
|
typeName: p.ZodString,
|
|
985
|
-
coerce:
|
|
986
|
-
...g(
|
|
985
|
+
coerce: s?.coerce ?? !1,
|
|
986
|
+
...g(s)
|
|
987
987
|
});
|
|
988
|
-
function
|
|
989
|
-
const t = (
|
|
990
|
-
return a % i / 10 **
|
|
988
|
+
function nt(s, e) {
|
|
989
|
+
const t = (s.toString().split(".")[1] || "").length, n = (e.toString().split(".")[1] || "").length, r = t > n ? t : n, a = Number.parseInt(s.toFixed(r).replace(".", "")), i = Number.parseInt(e.toFixed(r).replace(".", ""));
|
|
990
|
+
return a % i / 10 ** r;
|
|
991
991
|
}
|
|
992
|
-
class
|
|
992
|
+
class D extends y {
|
|
993
993
|
constructor() {
|
|
994
994
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
995
995
|
}
|
|
996
996
|
_parse(e) {
|
|
997
997
|
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== u.number) {
|
|
998
998
|
const a = this._getOrReturnCtx(e);
|
|
999
|
-
return
|
|
1000
|
-
code:
|
|
999
|
+
return d(a, {
|
|
1000
|
+
code: c.invalid_type,
|
|
1001
1001
|
expected: u.number,
|
|
1002
1002
|
received: a.parsedType
|
|
1003
1003
|
}), m;
|
|
1004
1004
|
}
|
|
1005
|
-
let
|
|
1006
|
-
const
|
|
1005
|
+
let n;
|
|
1006
|
+
const r = new w();
|
|
1007
1007
|
for (const a of this._def.checks)
|
|
1008
|
-
a.kind === "int" ?
|
|
1009
|
-
code:
|
|
1008
|
+
a.kind === "int" ? _.isInteger(e.data) || (n = this._getOrReturnCtx(e, n), d(n, {
|
|
1009
|
+
code: c.invalid_type,
|
|
1010
1010
|
expected: "integer",
|
|
1011
1011
|
received: "float",
|
|
1012
1012
|
message: a.message
|
|
1013
|
-
}),
|
|
1014
|
-
code:
|
|
1013
|
+
}), r.dirty()) : a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), d(n, {
|
|
1014
|
+
code: c.too_small,
|
|
1015
1015
|
minimum: a.value,
|
|
1016
1016
|
type: "number",
|
|
1017
1017
|
inclusive: a.inclusive,
|
|
1018
1018
|
exact: !1,
|
|
1019
1019
|
message: a.message
|
|
1020
|
-
}),
|
|
1021
|
-
code:
|
|
1020
|
+
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), d(n, {
|
|
1021
|
+
code: c.too_big,
|
|
1022
1022
|
maximum: a.value,
|
|
1023
1023
|
type: "number",
|
|
1024
1024
|
inclusive: a.inclusive,
|
|
1025
1025
|
exact: !1,
|
|
1026
1026
|
message: a.message
|
|
1027
|
-
}),
|
|
1028
|
-
code:
|
|
1027
|
+
}), r.dirty()) : a.kind === "multipleOf" ? nt(e.data, a.value) !== 0 && (n = this._getOrReturnCtx(e, n), d(n, {
|
|
1028
|
+
code: c.not_multiple_of,
|
|
1029
1029
|
multipleOf: a.value,
|
|
1030
1030
|
message: a.message
|
|
1031
|
-
}),
|
|
1032
|
-
code:
|
|
1031
|
+
}), r.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (n = this._getOrReturnCtx(e, n), d(n, {
|
|
1032
|
+
code: c.not_finite,
|
|
1033
1033
|
message: a.message
|
|
1034
|
-
}),
|
|
1035
|
-
return { status:
|
|
1034
|
+
}), r.dirty()) : _.assertNever(a);
|
|
1035
|
+
return { status: r.value, value: e.data };
|
|
1036
1036
|
}
|
|
1037
1037
|
gte(e, t) {
|
|
1038
1038
|
return this.setLimit("min", e, !0, l.toString(t));
|
|
@@ -1046,22 +1046,22 @@ class B extends _ {
|
|
|
1046
1046
|
lt(e, t) {
|
|
1047
1047
|
return this.setLimit("max", e, !1, l.toString(t));
|
|
1048
1048
|
}
|
|
1049
|
-
setLimit(e, t,
|
|
1050
|
-
return new
|
|
1049
|
+
setLimit(e, t, n, r) {
|
|
1050
|
+
return new D({
|
|
1051
1051
|
...this._def,
|
|
1052
1052
|
checks: [
|
|
1053
1053
|
...this._def.checks,
|
|
1054
1054
|
{
|
|
1055
1055
|
kind: e,
|
|
1056
1056
|
value: t,
|
|
1057
|
-
inclusive:
|
|
1058
|
-
message: l.toString(
|
|
1057
|
+
inclusive: n,
|
|
1058
|
+
message: l.toString(r)
|
|
1059
1059
|
}
|
|
1060
1060
|
]
|
|
1061
1061
|
});
|
|
1062
1062
|
}
|
|
1063
1063
|
_addCheck(e) {
|
|
1064
|
-
return new
|
|
1064
|
+
return new D({
|
|
1065
1065
|
...this._def,
|
|
1066
1066
|
checks: [...this._def.checks, e]
|
|
1067
1067
|
});
|
|
@@ -1143,25 +1143,25 @@ class B extends _ {
|
|
|
1143
1143
|
return e;
|
|
1144
1144
|
}
|
|
1145
1145
|
get isInt() {
|
|
1146
|
-
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" &&
|
|
1146
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && _.isInteger(e.value));
|
|
1147
1147
|
}
|
|
1148
1148
|
get isFinite() {
|
|
1149
1149
|
let e = null, t = null;
|
|
1150
|
-
for (const
|
|
1151
|
-
if (
|
|
1150
|
+
for (const n of this._def.checks) {
|
|
1151
|
+
if (n.kind === "finite" || n.kind === "int" || n.kind === "multipleOf")
|
|
1152
1152
|
return !0;
|
|
1153
|
-
|
|
1153
|
+
n.kind === "min" ? (t === null || n.value > t) && (t = n.value) : n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1154
1154
|
}
|
|
1155
1155
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
1156
1156
|
}
|
|
1157
1157
|
}
|
|
1158
|
-
|
|
1158
|
+
D.create = (s) => new D({
|
|
1159
1159
|
checks: [],
|
|
1160
1160
|
typeName: p.ZodNumber,
|
|
1161
|
-
coerce:
|
|
1162
|
-
...g(
|
|
1161
|
+
coerce: s?.coerce || !1,
|
|
1162
|
+
...g(s)
|
|
1163
1163
|
});
|
|
1164
|
-
class
|
|
1164
|
+
class W extends y {
|
|
1165
1165
|
constructor() {
|
|
1166
1166
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1167
1167
|
}
|
|
@@ -1174,32 +1174,32 @@ class z extends _ {
|
|
|
1174
1174
|
}
|
|
1175
1175
|
if (this._getType(e) !== u.bigint)
|
|
1176
1176
|
return this._getInvalidInput(e);
|
|
1177
|
-
let
|
|
1178
|
-
const
|
|
1177
|
+
let n;
|
|
1178
|
+
const r = new w();
|
|
1179
1179
|
for (const a of this._def.checks)
|
|
1180
|
-
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (
|
|
1181
|
-
code:
|
|
1180
|
+
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (n = this._getOrReturnCtx(e, n), d(n, {
|
|
1181
|
+
code: c.too_small,
|
|
1182
1182
|
type: "bigint",
|
|
1183
1183
|
minimum: a.value,
|
|
1184
1184
|
inclusive: a.inclusive,
|
|
1185
1185
|
message: a.message
|
|
1186
|
-
}),
|
|
1187
|
-
code:
|
|
1186
|
+
}), r.dirty()) : a.kind === "max" ? (a.inclusive ? e.data > a.value : e.data >= a.value) && (n = this._getOrReturnCtx(e, n), d(n, {
|
|
1187
|
+
code: c.too_big,
|
|
1188
1188
|
type: "bigint",
|
|
1189
1189
|
maximum: a.value,
|
|
1190
1190
|
inclusive: a.inclusive,
|
|
1191
1191
|
message: a.message
|
|
1192
|
-
}),
|
|
1193
|
-
code:
|
|
1192
|
+
}), r.dirty()) : a.kind === "multipleOf" ? e.data % a.value !== BigInt(0) && (n = this._getOrReturnCtx(e, n), d(n, {
|
|
1193
|
+
code: c.not_multiple_of,
|
|
1194
1194
|
multipleOf: a.value,
|
|
1195
1195
|
message: a.message
|
|
1196
|
-
}),
|
|
1197
|
-
return { status:
|
|
1196
|
+
}), r.dirty()) : _.assertNever(a);
|
|
1197
|
+
return { status: r.value, value: e.data };
|
|
1198
1198
|
}
|
|
1199
1199
|
_getInvalidInput(e) {
|
|
1200
1200
|
const t = this._getOrReturnCtx(e);
|
|
1201
|
-
return
|
|
1202
|
-
code:
|
|
1201
|
+
return d(t, {
|
|
1202
|
+
code: c.invalid_type,
|
|
1203
1203
|
expected: u.bigint,
|
|
1204
1204
|
received: t.parsedType
|
|
1205
1205
|
}), m;
|
|
@@ -1216,22 +1216,22 @@ class z extends _ {
|
|
|
1216
1216
|
lt(e, t) {
|
|
1217
1217
|
return this.setLimit("max", e, !1, l.toString(t));
|
|
1218
1218
|
}
|
|
1219
|
-
setLimit(e, t,
|
|
1220
|
-
return new
|
|
1219
|
+
setLimit(e, t, n, r) {
|
|
1220
|
+
return new W({
|
|
1221
1221
|
...this._def,
|
|
1222
1222
|
checks: [
|
|
1223
1223
|
...this._def.checks,
|
|
1224
1224
|
{
|
|
1225
1225
|
kind: e,
|
|
1226
1226
|
value: t,
|
|
1227
|
-
inclusive:
|
|
1228
|
-
message: l.toString(
|
|
1227
|
+
inclusive: n,
|
|
1228
|
+
message: l.toString(r)
|
|
1229
1229
|
}
|
|
1230
1230
|
]
|
|
1231
1231
|
});
|
|
1232
1232
|
}
|
|
1233
1233
|
_addCheck(e) {
|
|
1234
|
-
return new
|
|
1234
|
+
return new W({
|
|
1235
1235
|
...this._def,
|
|
1236
1236
|
checks: [...this._def.checks, e]
|
|
1237
1237
|
});
|
|
@@ -1288,71 +1288,71 @@ class z extends _ {
|
|
|
1288
1288
|
return e;
|
|
1289
1289
|
}
|
|
1290
1290
|
}
|
|
1291
|
-
|
|
1291
|
+
W.create = (s) => new W({
|
|
1292
1292
|
checks: [],
|
|
1293
1293
|
typeName: p.ZodBigInt,
|
|
1294
|
-
coerce:
|
|
1295
|
-
...g(
|
|
1294
|
+
coerce: s?.coerce ?? !1,
|
|
1295
|
+
...g(s)
|
|
1296
1296
|
});
|
|
1297
|
-
class
|
|
1297
|
+
class ie extends y {
|
|
1298
1298
|
_parse(e) {
|
|
1299
1299
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== u.boolean) {
|
|
1300
|
-
const
|
|
1301
|
-
return
|
|
1302
|
-
code:
|
|
1300
|
+
const n = this._getOrReturnCtx(e);
|
|
1301
|
+
return d(n, {
|
|
1302
|
+
code: c.invalid_type,
|
|
1303
1303
|
expected: u.boolean,
|
|
1304
|
-
received:
|
|
1304
|
+
received: n.parsedType
|
|
1305
1305
|
}), m;
|
|
1306
1306
|
}
|
|
1307
|
-
return
|
|
1307
|
+
return T(e.data);
|
|
1308
1308
|
}
|
|
1309
1309
|
}
|
|
1310
|
-
|
|
1310
|
+
ie.create = (s) => new ie({
|
|
1311
1311
|
typeName: p.ZodBoolean,
|
|
1312
|
-
coerce:
|
|
1313
|
-
...g(
|
|
1312
|
+
coerce: s?.coerce || !1,
|
|
1313
|
+
...g(s)
|
|
1314
1314
|
});
|
|
1315
|
-
class
|
|
1315
|
+
class H extends y {
|
|
1316
1316
|
_parse(e) {
|
|
1317
1317
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== u.date) {
|
|
1318
1318
|
const a = this._getOrReturnCtx(e);
|
|
1319
|
-
return
|
|
1320
|
-
code:
|
|
1319
|
+
return d(a, {
|
|
1320
|
+
code: c.invalid_type,
|
|
1321
1321
|
expected: u.date,
|
|
1322
1322
|
received: a.parsedType
|
|
1323
1323
|
}), m;
|
|
1324
1324
|
}
|
|
1325
1325
|
if (Number.isNaN(e.data.getTime())) {
|
|
1326
1326
|
const a = this._getOrReturnCtx(e);
|
|
1327
|
-
return
|
|
1328
|
-
code:
|
|
1327
|
+
return d(a, {
|
|
1328
|
+
code: c.invalid_date
|
|
1329
1329
|
}), m;
|
|
1330
1330
|
}
|
|
1331
|
-
const
|
|
1332
|
-
let
|
|
1331
|
+
const n = new w();
|
|
1332
|
+
let r;
|
|
1333
1333
|
for (const a of this._def.checks)
|
|
1334
|
-
a.kind === "min" ? e.data.getTime() < a.value && (
|
|
1335
|
-
code:
|
|
1334
|
+
a.kind === "min" ? e.data.getTime() < a.value && (r = this._getOrReturnCtx(e, r), d(r, {
|
|
1335
|
+
code: c.too_small,
|
|
1336
1336
|
message: a.message,
|
|
1337
1337
|
inclusive: !0,
|
|
1338
1338
|
exact: !1,
|
|
1339
1339
|
minimum: a.value,
|
|
1340
1340
|
type: "date"
|
|
1341
|
-
}),
|
|
1342
|
-
code:
|
|
1341
|
+
}), n.dirty()) : a.kind === "max" ? e.data.getTime() > a.value && (r = this._getOrReturnCtx(e, r), d(r, {
|
|
1342
|
+
code: c.too_big,
|
|
1343
1343
|
message: a.message,
|
|
1344
1344
|
inclusive: !0,
|
|
1345
1345
|
exact: !1,
|
|
1346
1346
|
maximum: a.value,
|
|
1347
1347
|
type: "date"
|
|
1348
|
-
}),
|
|
1348
|
+
}), n.dirty()) : _.assertNever(a);
|
|
1349
1349
|
return {
|
|
1350
|
-
status:
|
|
1350
|
+
status: n.value,
|
|
1351
1351
|
value: new Date(e.data.getTime())
|
|
1352
1352
|
};
|
|
1353
1353
|
}
|
|
1354
1354
|
_addCheck(e) {
|
|
1355
|
-
return new
|
|
1355
|
+
return new H({
|
|
1356
1356
|
...this._def,
|
|
1357
1357
|
checks: [...this._def.checks, e]
|
|
1358
1358
|
});
|
|
@@ -1384,175 +1384,175 @@ class q extends _ {
|
|
|
1384
1384
|
return e != null ? new Date(e) : null;
|
|
1385
1385
|
}
|
|
1386
1386
|
}
|
|
1387
|
-
|
|
1387
|
+
H.create = (s) => new H({
|
|
1388
1388
|
checks: [],
|
|
1389
|
-
coerce:
|
|
1389
|
+
coerce: s?.coerce || !1,
|
|
1390
1390
|
typeName: p.ZodDate,
|
|
1391
|
-
...g(
|
|
1391
|
+
...g(s)
|
|
1392
1392
|
});
|
|
1393
|
-
class
|
|
1393
|
+
class ve extends y {
|
|
1394
1394
|
_parse(e) {
|
|
1395
1395
|
if (this._getType(e) !== u.symbol) {
|
|
1396
|
-
const
|
|
1397
|
-
return
|
|
1398
|
-
code:
|
|
1396
|
+
const n = this._getOrReturnCtx(e);
|
|
1397
|
+
return d(n, {
|
|
1398
|
+
code: c.invalid_type,
|
|
1399
1399
|
expected: u.symbol,
|
|
1400
|
-
received:
|
|
1400
|
+
received: n.parsedType
|
|
1401
1401
|
}), m;
|
|
1402
1402
|
}
|
|
1403
|
-
return
|
|
1403
|
+
return T(e.data);
|
|
1404
1404
|
}
|
|
1405
1405
|
}
|
|
1406
|
-
|
|
1406
|
+
ve.create = (s) => new ve({
|
|
1407
1407
|
typeName: p.ZodSymbol,
|
|
1408
|
-
...g(
|
|
1408
|
+
...g(s)
|
|
1409
1409
|
});
|
|
1410
|
-
class
|
|
1410
|
+
class oe extends y {
|
|
1411
1411
|
_parse(e) {
|
|
1412
1412
|
if (this._getType(e) !== u.undefined) {
|
|
1413
|
-
const
|
|
1414
|
-
return
|
|
1415
|
-
code:
|
|
1413
|
+
const n = this._getOrReturnCtx(e);
|
|
1414
|
+
return d(n, {
|
|
1415
|
+
code: c.invalid_type,
|
|
1416
1416
|
expected: u.undefined,
|
|
1417
|
-
received:
|
|
1417
|
+
received: n.parsedType
|
|
1418
1418
|
}), m;
|
|
1419
1419
|
}
|
|
1420
|
-
return
|
|
1420
|
+
return T(e.data);
|
|
1421
1421
|
}
|
|
1422
1422
|
}
|
|
1423
|
-
|
|
1423
|
+
oe.create = (s) => new oe({
|
|
1424
1424
|
typeName: p.ZodUndefined,
|
|
1425
|
-
...g(
|
|
1425
|
+
...g(s)
|
|
1426
1426
|
});
|
|
1427
|
-
class
|
|
1427
|
+
class ce extends y {
|
|
1428
1428
|
_parse(e) {
|
|
1429
1429
|
if (this._getType(e) !== u.null) {
|
|
1430
|
-
const
|
|
1431
|
-
return
|
|
1432
|
-
code:
|
|
1430
|
+
const n = this._getOrReturnCtx(e);
|
|
1431
|
+
return d(n, {
|
|
1432
|
+
code: c.invalid_type,
|
|
1433
1433
|
expected: u.null,
|
|
1434
|
-
received:
|
|
1434
|
+
received: n.parsedType
|
|
1435
1435
|
}), m;
|
|
1436
1436
|
}
|
|
1437
|
-
return
|
|
1437
|
+
return T(e.data);
|
|
1438
1438
|
}
|
|
1439
1439
|
}
|
|
1440
|
-
|
|
1440
|
+
ce.create = (s) => new ce({
|
|
1441
1441
|
typeName: p.ZodNull,
|
|
1442
|
-
...g(
|
|
1442
|
+
...g(s)
|
|
1443
1443
|
});
|
|
1444
|
-
class
|
|
1444
|
+
class xe extends y {
|
|
1445
1445
|
constructor() {
|
|
1446
1446
|
super(...arguments), this._any = !0;
|
|
1447
1447
|
}
|
|
1448
1448
|
_parse(e) {
|
|
1449
|
-
return
|
|
1449
|
+
return T(e.data);
|
|
1450
1450
|
}
|
|
1451
1451
|
}
|
|
1452
|
-
|
|
1452
|
+
xe.create = (s) => new xe({
|
|
1453
1453
|
typeName: p.ZodAny,
|
|
1454
|
-
...g(
|
|
1454
|
+
...g(s)
|
|
1455
1455
|
});
|
|
1456
|
-
class
|
|
1456
|
+
class ke extends y {
|
|
1457
1457
|
constructor() {
|
|
1458
1458
|
super(...arguments), this._unknown = !0;
|
|
1459
1459
|
}
|
|
1460
1460
|
_parse(e) {
|
|
1461
|
-
return
|
|
1461
|
+
return T(e.data);
|
|
1462
1462
|
}
|
|
1463
1463
|
}
|
|
1464
|
-
|
|
1464
|
+
ke.create = (s) => new ke({
|
|
1465
1465
|
typeName: p.ZodUnknown,
|
|
1466
|
-
...g(
|
|
1466
|
+
...g(s)
|
|
1467
1467
|
});
|
|
1468
|
-
class
|
|
1468
|
+
class Z extends y {
|
|
1469
1469
|
_parse(e) {
|
|
1470
1470
|
const t = this._getOrReturnCtx(e);
|
|
1471
|
-
return
|
|
1472
|
-
code:
|
|
1471
|
+
return d(t, {
|
|
1472
|
+
code: c.invalid_type,
|
|
1473
1473
|
expected: u.never,
|
|
1474
1474
|
received: t.parsedType
|
|
1475
1475
|
}), m;
|
|
1476
1476
|
}
|
|
1477
1477
|
}
|
|
1478
|
-
|
|
1478
|
+
Z.create = (s) => new Z({
|
|
1479
1479
|
typeName: p.ZodNever,
|
|
1480
|
-
...g(
|
|
1480
|
+
...g(s)
|
|
1481
1481
|
});
|
|
1482
|
-
class
|
|
1482
|
+
class be extends y {
|
|
1483
1483
|
_parse(e) {
|
|
1484
1484
|
if (this._getType(e) !== u.undefined) {
|
|
1485
|
-
const
|
|
1486
|
-
return
|
|
1487
|
-
code:
|
|
1485
|
+
const n = this._getOrReturnCtx(e);
|
|
1486
|
+
return d(n, {
|
|
1487
|
+
code: c.invalid_type,
|
|
1488
1488
|
expected: u.void,
|
|
1489
|
-
received:
|
|
1489
|
+
received: n.parsedType
|
|
1490
1490
|
}), m;
|
|
1491
1491
|
}
|
|
1492
|
-
return
|
|
1492
|
+
return T(e.data);
|
|
1493
1493
|
}
|
|
1494
1494
|
}
|
|
1495
|
-
|
|
1495
|
+
be.create = (s) => new be({
|
|
1496
1496
|
typeName: p.ZodVoid,
|
|
1497
|
-
...g(
|
|
1497
|
+
...g(s)
|
|
1498
1498
|
});
|
|
1499
|
-
class
|
|
1499
|
+
class C extends y {
|
|
1500
1500
|
_parse(e) {
|
|
1501
|
-
const { ctx: t, status:
|
|
1501
|
+
const { ctx: t, status: n } = this._processInputParams(e), r = this._def;
|
|
1502
1502
|
if (t.parsedType !== u.array)
|
|
1503
|
-
return
|
|
1504
|
-
code:
|
|
1503
|
+
return d(t, {
|
|
1504
|
+
code: c.invalid_type,
|
|
1505
1505
|
expected: u.array,
|
|
1506
1506
|
received: t.parsedType
|
|
1507
1507
|
}), m;
|
|
1508
|
-
if (
|
|
1509
|
-
const i = t.data.length >
|
|
1510
|
-
(i || o) && (
|
|
1511
|
-
code: i ?
|
|
1512
|
-
minimum: o ?
|
|
1513
|
-
maximum: i ?
|
|
1508
|
+
if (r.exactLength !== null) {
|
|
1509
|
+
const i = t.data.length > r.exactLength.value, o = t.data.length < r.exactLength.value;
|
|
1510
|
+
(i || o) && (d(t, {
|
|
1511
|
+
code: i ? c.too_big : c.too_small,
|
|
1512
|
+
minimum: o ? r.exactLength.value : void 0,
|
|
1513
|
+
maximum: i ? r.exactLength.value : void 0,
|
|
1514
1514
|
type: "array",
|
|
1515
1515
|
inclusive: !0,
|
|
1516
1516
|
exact: !0,
|
|
1517
|
-
message:
|
|
1518
|
-
}),
|
|
1517
|
+
message: r.exactLength.message
|
|
1518
|
+
}), n.dirty());
|
|
1519
1519
|
}
|
|
1520
|
-
if (
|
|
1521
|
-
code:
|
|
1522
|
-
minimum:
|
|
1520
|
+
if (r.minLength !== null && t.data.length < r.minLength.value && (d(t, {
|
|
1521
|
+
code: c.too_small,
|
|
1522
|
+
minimum: r.minLength.value,
|
|
1523
1523
|
type: "array",
|
|
1524
1524
|
inclusive: !0,
|
|
1525
1525
|
exact: !1,
|
|
1526
|
-
message:
|
|
1527
|
-
}),
|
|
1528
|
-
code:
|
|
1529
|
-
maximum:
|
|
1526
|
+
message: r.minLength.message
|
|
1527
|
+
}), n.dirty()), r.maxLength !== null && t.data.length > r.maxLength.value && (d(t, {
|
|
1528
|
+
code: c.too_big,
|
|
1529
|
+
maximum: r.maxLength.value,
|
|
1530
1530
|
type: "array",
|
|
1531
1531
|
inclusive: !0,
|
|
1532
1532
|
exact: !1,
|
|
1533
|
-
message:
|
|
1534
|
-
}),
|
|
1535
|
-
return Promise.all([...t.data].map((i, o) =>
|
|
1536
|
-
const a = [...t.data].map((i, o) =>
|
|
1537
|
-
return w.mergeArray(
|
|
1533
|
+
message: r.maxLength.message
|
|
1534
|
+
}), n.dirty()), t.common.async)
|
|
1535
|
+
return Promise.all([...t.data].map((i, o) => r.type._parseAsync(new R(t, i, t.path, o)))).then((i) => w.mergeArray(n, i));
|
|
1536
|
+
const a = [...t.data].map((i, o) => r.type._parseSync(new R(t, i, t.path, o)));
|
|
1537
|
+
return w.mergeArray(n, a);
|
|
1538
1538
|
}
|
|
1539
1539
|
get element() {
|
|
1540
1540
|
return this._def.type;
|
|
1541
1541
|
}
|
|
1542
1542
|
min(e, t) {
|
|
1543
|
-
return new
|
|
1543
|
+
return new C({
|
|
1544
1544
|
...this._def,
|
|
1545
1545
|
minLength: { value: e, message: l.toString(t) }
|
|
1546
1546
|
});
|
|
1547
1547
|
}
|
|
1548
1548
|
max(e, t) {
|
|
1549
|
-
return new
|
|
1549
|
+
return new C({
|
|
1550
1550
|
...this._def,
|
|
1551
1551
|
maxLength: { value: e, message: l.toString(t) }
|
|
1552
1552
|
});
|
|
1553
1553
|
}
|
|
1554
1554
|
length(e, t) {
|
|
1555
|
-
return new
|
|
1555
|
+
return new C({
|
|
1556
1556
|
...this._def,
|
|
1557
1557
|
exactLength: { value: e, message: l.toString(t) }
|
|
1558
1558
|
});
|
|
@@ -1561,102 +1561,102 @@ class T extends _ {
|
|
|
1561
1561
|
return this.min(1, e);
|
|
1562
1562
|
}
|
|
1563
1563
|
}
|
|
1564
|
-
|
|
1565
|
-
type:
|
|
1564
|
+
C.create = (s, e) => new C({
|
|
1565
|
+
type: s,
|
|
1566
1566
|
minLength: null,
|
|
1567
1567
|
maxLength: null,
|
|
1568
1568
|
exactLength: null,
|
|
1569
1569
|
typeName: p.ZodArray,
|
|
1570
1570
|
...g(e)
|
|
1571
1571
|
});
|
|
1572
|
-
function
|
|
1573
|
-
if (
|
|
1572
|
+
function L(s) {
|
|
1573
|
+
if (s instanceof k) {
|
|
1574
1574
|
const e = {};
|
|
1575
|
-
for (const t in
|
|
1576
|
-
const
|
|
1577
|
-
e[t] =
|
|
1575
|
+
for (const t in s.shape) {
|
|
1576
|
+
const n = s.shape[t];
|
|
1577
|
+
e[t] = A.create(L(n));
|
|
1578
1578
|
}
|
|
1579
1579
|
return new k({
|
|
1580
|
-
...
|
|
1580
|
+
...s._def,
|
|
1581
1581
|
shape: () => e
|
|
1582
1582
|
});
|
|
1583
|
-
} else return
|
|
1584
|
-
...
|
|
1585
|
-
type:
|
|
1586
|
-
}) :
|
|
1583
|
+
} else return s instanceof C ? new C({
|
|
1584
|
+
...s._def,
|
|
1585
|
+
type: L(s.element)
|
|
1586
|
+
}) : s instanceof A ? A.create(L(s.unwrap())) : s instanceof M ? M.create(L(s.unwrap())) : s instanceof j ? j.create(s.items.map((e) => L(e))) : s;
|
|
1587
1587
|
}
|
|
1588
|
-
class k extends
|
|
1588
|
+
class k extends y {
|
|
1589
1589
|
constructor() {
|
|
1590
1590
|
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1591
1591
|
}
|
|
1592
1592
|
_getCached() {
|
|
1593
1593
|
if (this._cached !== null)
|
|
1594
1594
|
return this._cached;
|
|
1595
|
-
const e = this._def.shape(), t =
|
|
1595
|
+
const e = this._def.shape(), t = _.objectKeys(e);
|
|
1596
1596
|
return this._cached = { shape: e, keys: t }, this._cached;
|
|
1597
1597
|
}
|
|
1598
1598
|
_parse(e) {
|
|
1599
1599
|
if (this._getType(e) !== u.object) {
|
|
1600
|
-
const
|
|
1601
|
-
return
|
|
1602
|
-
code:
|
|
1600
|
+
const f = this._getOrReturnCtx(e);
|
|
1601
|
+
return d(f, {
|
|
1602
|
+
code: c.invalid_type,
|
|
1603
1603
|
expected: u.object,
|
|
1604
|
-
received:
|
|
1604
|
+
received: f.parsedType
|
|
1605
1605
|
}), m;
|
|
1606
1606
|
}
|
|
1607
|
-
const { status:
|
|
1608
|
-
if (!(this._def.catchall instanceof
|
|
1609
|
-
for (const
|
|
1610
|
-
i.includes(
|
|
1611
|
-
const
|
|
1612
|
-
for (const
|
|
1613
|
-
const
|
|
1614
|
-
|
|
1615
|
-
key: { status: "valid", value:
|
|
1616
|
-
value:
|
|
1617
|
-
alwaysSet:
|
|
1607
|
+
const { status: n, ctx: r } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1608
|
+
if (!(this._def.catchall instanceof Z && this._def.unknownKeys === "strip"))
|
|
1609
|
+
for (const f in r.data)
|
|
1610
|
+
i.includes(f) || o.push(f);
|
|
1611
|
+
const h = [];
|
|
1612
|
+
for (const f of i) {
|
|
1613
|
+
const v = a[f], B = r.data[f];
|
|
1614
|
+
h.push({
|
|
1615
|
+
key: { status: "valid", value: f },
|
|
1616
|
+
value: v._parse(new R(r, B, r.path, f)),
|
|
1617
|
+
alwaysSet: f in r.data
|
|
1618
1618
|
});
|
|
1619
1619
|
}
|
|
1620
|
-
if (this._def.catchall instanceof
|
|
1621
|
-
const
|
|
1622
|
-
if (
|
|
1623
|
-
for (const
|
|
1624
|
-
|
|
1625
|
-
key: { status: "valid", value:
|
|
1626
|
-
value: { status: "valid", value:
|
|
1620
|
+
if (this._def.catchall instanceof Z) {
|
|
1621
|
+
const f = this._def.unknownKeys;
|
|
1622
|
+
if (f === "passthrough")
|
|
1623
|
+
for (const v of o)
|
|
1624
|
+
h.push({
|
|
1625
|
+
key: { status: "valid", value: v },
|
|
1626
|
+
value: { status: "valid", value: r.data[v] }
|
|
1627
1627
|
});
|
|
1628
|
-
else if (
|
|
1629
|
-
o.length > 0 && (
|
|
1630
|
-
code:
|
|
1628
|
+
else if (f === "strict")
|
|
1629
|
+
o.length > 0 && (d(r, {
|
|
1630
|
+
code: c.unrecognized_keys,
|
|
1631
1631
|
keys: o
|
|
1632
|
-
}),
|
|
1633
|
-
else if (
|
|
1632
|
+
}), n.dirty());
|
|
1633
|
+
else if (f !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1634
1634
|
} else {
|
|
1635
|
-
const
|
|
1636
|
-
for (const
|
|
1637
|
-
const
|
|
1638
|
-
|
|
1639
|
-
key: { status: "valid", value:
|
|
1640
|
-
value:
|
|
1641
|
-
new
|
|
1635
|
+
const f = this._def.catchall;
|
|
1636
|
+
for (const v of o) {
|
|
1637
|
+
const B = r.data[v];
|
|
1638
|
+
h.push({
|
|
1639
|
+
key: { status: "valid", value: v },
|
|
1640
|
+
value: f._parse(
|
|
1641
|
+
new R(r, B, r.path, v)
|
|
1642
1642
|
//, ctx.child(key), value, getParsedType(value)
|
|
1643
1643
|
),
|
|
1644
|
-
alwaysSet:
|
|
1644
|
+
alwaysSet: v in r.data
|
|
1645
1645
|
});
|
|
1646
1646
|
}
|
|
1647
1647
|
}
|
|
1648
|
-
return
|
|
1649
|
-
const
|
|
1650
|
-
for (const
|
|
1651
|
-
const
|
|
1652
|
-
|
|
1653
|
-
key:
|
|
1654
|
-
value:
|
|
1655
|
-
alwaysSet:
|
|
1648
|
+
return r.common.async ? Promise.resolve().then(async () => {
|
|
1649
|
+
const f = [];
|
|
1650
|
+
for (const v of h) {
|
|
1651
|
+
const B = await v.key, Ze = await v.value;
|
|
1652
|
+
f.push({
|
|
1653
|
+
key: B,
|
|
1654
|
+
value: Ze,
|
|
1655
|
+
alwaysSet: v.alwaysSet
|
|
1656
1656
|
});
|
|
1657
1657
|
}
|
|
1658
|
-
return
|
|
1659
|
-
}).then((
|
|
1658
|
+
return f;
|
|
1659
|
+
}).then((f) => w.mergeObjectSync(n, f)) : w.mergeObjectSync(n, h);
|
|
1660
1660
|
}
|
|
1661
1661
|
get shape() {
|
|
1662
1662
|
return this._def.shape();
|
|
@@ -1666,12 +1666,12 @@ class k extends _ {
|
|
|
1666
1666
|
...this._def,
|
|
1667
1667
|
unknownKeys: "strict",
|
|
1668
1668
|
...e !== void 0 ? {
|
|
1669
|
-
errorMap: (t,
|
|
1670
|
-
const
|
|
1669
|
+
errorMap: (t, n) => {
|
|
1670
|
+
const r = this._def.errorMap?.(t, n).message ?? n.defaultError;
|
|
1671
1671
|
return t.code === "unrecognized_keys" ? {
|
|
1672
|
-
message: l.errToObj(e).message ??
|
|
1672
|
+
message: l.errToObj(e).message ?? r
|
|
1673
1673
|
} : {
|
|
1674
|
-
message:
|
|
1674
|
+
message: r
|
|
1675
1675
|
};
|
|
1676
1676
|
}
|
|
1677
1677
|
} : {}
|
|
@@ -1798,8 +1798,8 @@ class k extends _ {
|
|
|
1798
1798
|
}
|
|
1799
1799
|
pick(e) {
|
|
1800
1800
|
const t = {};
|
|
1801
|
-
for (const
|
|
1802
|
-
e[
|
|
1801
|
+
for (const n of _.objectKeys(e))
|
|
1802
|
+
e[n] && this.shape[n] && (t[n] = this.shape[n]);
|
|
1803
1803
|
return new k({
|
|
1804
1804
|
...this._def,
|
|
1805
1805
|
shape: () => t
|
|
@@ -1807,8 +1807,8 @@ class k extends _ {
|
|
|
1807
1807
|
}
|
|
1808
1808
|
omit(e) {
|
|
1809
1809
|
const t = {};
|
|
1810
|
-
for (const
|
|
1811
|
-
e[
|
|
1810
|
+
for (const n of _.objectKeys(this.shape))
|
|
1811
|
+
e[n] || (t[n] = this.shape[n]);
|
|
1812
1812
|
return new k({
|
|
1813
1813
|
...this._def,
|
|
1814
1814
|
shape: () => t
|
|
@@ -1818,13 +1818,13 @@ class k extends _ {
|
|
|
1818
1818
|
* @deprecated
|
|
1819
1819
|
*/
|
|
1820
1820
|
deepPartial() {
|
|
1821
|
-
return
|
|
1821
|
+
return L(this);
|
|
1822
1822
|
}
|
|
1823
1823
|
partial(e) {
|
|
1824
1824
|
const t = {};
|
|
1825
|
-
for (const
|
|
1826
|
-
const
|
|
1827
|
-
e && !e[
|
|
1825
|
+
for (const n of _.objectKeys(this.shape)) {
|
|
1826
|
+
const r = this.shape[n];
|
|
1827
|
+
e && !e[n] ? t[n] = r : t[n] = r.optional();
|
|
1828
1828
|
}
|
|
1829
1829
|
return new k({
|
|
1830
1830
|
...this._def,
|
|
@@ -1833,14 +1833,14 @@ class k extends _ {
|
|
|
1833
1833
|
}
|
|
1834
1834
|
required(e) {
|
|
1835
1835
|
const t = {};
|
|
1836
|
-
for (const
|
|
1837
|
-
if (e && !e[
|
|
1838
|
-
t[
|
|
1836
|
+
for (const n of _.objectKeys(this.shape))
|
|
1837
|
+
if (e && !e[n])
|
|
1838
|
+
t[n] = this.shape[n];
|
|
1839
1839
|
else {
|
|
1840
|
-
let a = this.shape[
|
|
1841
|
-
for (; a instanceof
|
|
1840
|
+
let a = this.shape[n];
|
|
1841
|
+
for (; a instanceof A; )
|
|
1842
1842
|
a = a._def.innerType;
|
|
1843
|
-
t[
|
|
1843
|
+
t[n] = a;
|
|
1844
1844
|
}
|
|
1845
1845
|
return new k({
|
|
1846
1846
|
...this._def,
|
|
@@ -1848,48 +1848,48 @@ class k extends _ {
|
|
|
1848
1848
|
});
|
|
1849
1849
|
}
|
|
1850
1850
|
keyof() {
|
|
1851
|
-
return
|
|
1851
|
+
return Ae(_.objectKeys(this.shape));
|
|
1852
1852
|
}
|
|
1853
1853
|
}
|
|
1854
|
-
k.create = (
|
|
1855
|
-
shape: () =>
|
|
1854
|
+
k.create = (s, e) => new k({
|
|
1855
|
+
shape: () => s,
|
|
1856
1856
|
unknownKeys: "strip",
|
|
1857
|
-
catchall:
|
|
1857
|
+
catchall: Z.create(),
|
|
1858
1858
|
typeName: p.ZodObject,
|
|
1859
1859
|
...g(e)
|
|
1860
1860
|
});
|
|
1861
|
-
k.strictCreate = (
|
|
1862
|
-
shape: () =>
|
|
1861
|
+
k.strictCreate = (s, e) => new k({
|
|
1862
|
+
shape: () => s,
|
|
1863
1863
|
unknownKeys: "strict",
|
|
1864
|
-
catchall:
|
|
1864
|
+
catchall: Z.create(),
|
|
1865
1865
|
typeName: p.ZodObject,
|
|
1866
1866
|
...g(e)
|
|
1867
1867
|
});
|
|
1868
|
-
k.lazycreate = (
|
|
1869
|
-
shape:
|
|
1868
|
+
k.lazycreate = (s, e) => new k({
|
|
1869
|
+
shape: s,
|
|
1870
1870
|
unknownKeys: "strip",
|
|
1871
|
-
catchall:
|
|
1871
|
+
catchall: Z.create(),
|
|
1872
1872
|
typeName: p.ZodObject,
|
|
1873
1873
|
...g(e)
|
|
1874
1874
|
});
|
|
1875
|
-
class
|
|
1875
|
+
class J extends y {
|
|
1876
1876
|
_parse(e) {
|
|
1877
|
-
const { ctx: t } = this._processInputParams(e),
|
|
1878
|
-
function
|
|
1877
|
+
const { ctx: t } = this._processInputParams(e), n = this._def.options;
|
|
1878
|
+
function r(a) {
|
|
1879
1879
|
for (const o of a)
|
|
1880
1880
|
if (o.result.status === "valid")
|
|
1881
1881
|
return o.result;
|
|
1882
1882
|
for (const o of a)
|
|
1883
1883
|
if (o.result.status === "dirty")
|
|
1884
1884
|
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1885
|
-
const i = a.map((o) => new
|
|
1886
|
-
return
|
|
1887
|
-
code:
|
|
1885
|
+
const i = a.map((o) => new N(o.ctx.common.issues));
|
|
1886
|
+
return d(t, {
|
|
1887
|
+
code: c.invalid_union,
|
|
1888
1888
|
unionErrors: i
|
|
1889
1889
|
}), m;
|
|
1890
1890
|
}
|
|
1891
1891
|
if (t.common.async)
|
|
1892
|
-
return Promise.all(
|
|
1892
|
+
return Promise.all(n.map(async (a) => {
|
|
1893
1893
|
const i = {
|
|
1894
1894
|
...t,
|
|
1895
1895
|
common: {
|
|
@@ -1906,32 +1906,32 @@ class H extends _ {
|
|
|
1906
1906
|
}),
|
|
1907
1907
|
ctx: i
|
|
1908
1908
|
};
|
|
1909
|
-
})).then(
|
|
1909
|
+
})).then(r);
|
|
1910
1910
|
{
|
|
1911
1911
|
let a;
|
|
1912
1912
|
const i = [];
|
|
1913
|
-
for (const
|
|
1914
|
-
const
|
|
1913
|
+
for (const h of n) {
|
|
1914
|
+
const f = {
|
|
1915
1915
|
...t,
|
|
1916
1916
|
common: {
|
|
1917
1917
|
...t.common,
|
|
1918
1918
|
issues: []
|
|
1919
1919
|
},
|
|
1920
1920
|
parent: null
|
|
1921
|
-
},
|
|
1921
|
+
}, v = h._parseSync({
|
|
1922
1922
|
data: t.data,
|
|
1923
1923
|
path: t.path,
|
|
1924
|
-
parent:
|
|
1924
|
+
parent: f
|
|
1925
1925
|
});
|
|
1926
|
-
if (
|
|
1927
|
-
return
|
|
1928
|
-
|
|
1926
|
+
if (v.status === "valid")
|
|
1927
|
+
return v;
|
|
1928
|
+
v.status === "dirty" && !a && (a = { result: v, ctx: f }), f.common.issues.length && i.push(f.common.issues);
|
|
1929
1929
|
}
|
|
1930
1930
|
if (a)
|
|
1931
1931
|
return t.common.issues.push(...a.ctx.common.issues), a.result;
|
|
1932
|
-
const o = i.map((
|
|
1933
|
-
return
|
|
1934
|
-
code:
|
|
1932
|
+
const o = i.map((h) => new N(h));
|
|
1933
|
+
return d(t, {
|
|
1934
|
+
code: c.invalid_union,
|
|
1935
1935
|
unionErrors: o
|
|
1936
1936
|
}), m;
|
|
1937
1937
|
}
|
|
@@ -1940,22 +1940,22 @@ class H extends _ {
|
|
|
1940
1940
|
return this._def.options;
|
|
1941
1941
|
}
|
|
1942
1942
|
}
|
|
1943
|
-
|
|
1944
|
-
options:
|
|
1943
|
+
J.create = (s, e) => new J({
|
|
1944
|
+
options: s,
|
|
1945
1945
|
typeName: p.ZodUnion,
|
|
1946
1946
|
...g(e)
|
|
1947
1947
|
});
|
|
1948
|
-
const
|
|
1949
|
-
class
|
|
1948
|
+
const S = (s) => s instanceof ue ? S(s.schema) : s instanceof I ? S(s.innerType()) : s instanceof X ? [s.value] : s instanceof E ? s.options : s instanceof G ? _.objectValues(s.enum) : s instanceof ee ? S(s._def.innerType) : s instanceof oe ? [void 0] : s instanceof ce ? [null] : s instanceof A ? [void 0, ...S(s.unwrap())] : s instanceof M ? [null, ...S(s.unwrap())] : s instanceof Ne || s instanceof se ? S(s.unwrap()) : s instanceof te ? S(s._def.innerType) : [];
|
|
1949
|
+
class le extends y {
|
|
1950
1950
|
_parse(e) {
|
|
1951
1951
|
const { ctx: t } = this._processInputParams(e);
|
|
1952
1952
|
if (t.parsedType !== u.object)
|
|
1953
|
-
return
|
|
1954
|
-
code:
|
|
1953
|
+
return d(t, {
|
|
1954
|
+
code: c.invalid_type,
|
|
1955
1955
|
expected: u.object,
|
|
1956
1956
|
received: t.parsedType
|
|
1957
1957
|
}), m;
|
|
1958
|
-
const
|
|
1958
|
+
const n = this.discriminator, r = t.data[n], a = this.optionsMap.get(r);
|
|
1959
1959
|
return a ? t.common.async ? a._parseAsync({
|
|
1960
1960
|
data: t.data,
|
|
1961
1961
|
path: t.path,
|
|
@@ -1964,10 +1964,10 @@ class ue extends _ {
|
|
|
1964
1964
|
data: t.data,
|
|
1965
1965
|
path: t.path,
|
|
1966
1966
|
parent: t
|
|
1967
|
-
}) : (
|
|
1968
|
-
code:
|
|
1967
|
+
}) : (d(t, {
|
|
1968
|
+
code: c.invalid_union_discriminator,
|
|
1969
1969
|
options: Array.from(this.optionsMap.keys()),
|
|
1970
|
-
path: [
|
|
1970
|
+
path: [n]
|
|
1971
1971
|
}), m);
|
|
1972
1972
|
}
|
|
1973
1973
|
get discriminator() {
|
|
@@ -1987,142 +1987,142 @@ class ue extends _ {
|
|
|
1987
1987
|
* @param types an array of object schemas
|
|
1988
1988
|
* @param params
|
|
1989
1989
|
*/
|
|
1990
|
-
static create(e, t,
|
|
1991
|
-
const
|
|
1990
|
+
static create(e, t, n) {
|
|
1991
|
+
const r = /* @__PURE__ */ new Map();
|
|
1992
1992
|
for (const a of t) {
|
|
1993
|
-
const i =
|
|
1993
|
+
const i = S(a.shape[e]);
|
|
1994
1994
|
if (!i.length)
|
|
1995
1995
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
1996
1996
|
for (const o of i) {
|
|
1997
|
-
if (
|
|
1997
|
+
if (r.has(o))
|
|
1998
1998
|
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
|
|
1999
|
-
|
|
1999
|
+
r.set(o, a);
|
|
2000
2000
|
}
|
|
2001
2001
|
}
|
|
2002
|
-
return new
|
|
2002
|
+
return new le({
|
|
2003
2003
|
typeName: p.ZodDiscriminatedUnion,
|
|
2004
2004
|
discriminator: e,
|
|
2005
2005
|
options: t,
|
|
2006
|
-
optionsMap:
|
|
2007
|
-
...g(
|
|
2006
|
+
optionsMap: r,
|
|
2007
|
+
...g(n)
|
|
2008
2008
|
});
|
|
2009
2009
|
}
|
|
2010
2010
|
}
|
|
2011
|
-
function de(
|
|
2012
|
-
const t =
|
|
2013
|
-
if (
|
|
2014
|
-
return { valid: !0, data:
|
|
2015
|
-
if (t === u.object &&
|
|
2016
|
-
const
|
|
2011
|
+
function de(s, e) {
|
|
2012
|
+
const t = O(s), n = O(e);
|
|
2013
|
+
if (s === e)
|
|
2014
|
+
return { valid: !0, data: s };
|
|
2015
|
+
if (t === u.object && n === u.object) {
|
|
2016
|
+
const r = _.objectKeys(e), a = _.objectKeys(s).filter((o) => r.indexOf(o) !== -1), i = { ...s, ...e };
|
|
2017
2017
|
for (const o of a) {
|
|
2018
|
-
const
|
|
2019
|
-
if (!
|
|
2018
|
+
const h = de(s[o], e[o]);
|
|
2019
|
+
if (!h.valid)
|
|
2020
2020
|
return { valid: !1 };
|
|
2021
|
-
i[o] =
|
|
2021
|
+
i[o] = h.data;
|
|
2022
2022
|
}
|
|
2023
2023
|
return { valid: !0, data: i };
|
|
2024
|
-
} else if (t === u.array &&
|
|
2025
|
-
if (
|
|
2024
|
+
} else if (t === u.array && n === u.array) {
|
|
2025
|
+
if (s.length !== e.length)
|
|
2026
2026
|
return { valid: !1 };
|
|
2027
|
-
const
|
|
2028
|
-
for (let a = 0; a <
|
|
2029
|
-
const i =
|
|
2030
|
-
if (!
|
|
2027
|
+
const r = [];
|
|
2028
|
+
for (let a = 0; a < s.length; a++) {
|
|
2029
|
+
const i = s[a], o = e[a], h = de(i, o);
|
|
2030
|
+
if (!h.valid)
|
|
2031
2031
|
return { valid: !1 };
|
|
2032
|
-
|
|
2032
|
+
r.push(h.data);
|
|
2033
2033
|
}
|
|
2034
|
-
return { valid: !0, data:
|
|
2035
|
-
} else return t === u.date &&
|
|
2034
|
+
return { valid: !0, data: r };
|
|
2035
|
+
} else return t === u.date && n === u.date && +s == +e ? { valid: !0, data: s } : { valid: !1 };
|
|
2036
2036
|
}
|
|
2037
|
-
class
|
|
2037
|
+
class Q extends y {
|
|
2038
2038
|
_parse(e) {
|
|
2039
|
-
const { status: t, ctx:
|
|
2039
|
+
const { status: t, ctx: n } = this._processInputParams(e), r = (a, i) => {
|
|
2040
2040
|
if (ge(a) || ge(i))
|
|
2041
2041
|
return m;
|
|
2042
2042
|
const o = de(a.value, i.value);
|
|
2043
|
-
return o.valid ? ((ye(a) || ye(i)) && t.dirty(), { status: t.value, value: o.data }) : (
|
|
2044
|
-
code:
|
|
2043
|
+
return o.valid ? ((ye(a) || ye(i)) && t.dirty(), { status: t.value, value: o.data }) : (d(n, {
|
|
2044
|
+
code: c.invalid_intersection_types
|
|
2045
2045
|
}), m);
|
|
2046
2046
|
};
|
|
2047
|
-
return
|
|
2047
|
+
return n.common.async ? Promise.all([
|
|
2048
2048
|
this._def.left._parseAsync({
|
|
2049
|
-
data:
|
|
2050
|
-
path:
|
|
2051
|
-
parent:
|
|
2049
|
+
data: n.data,
|
|
2050
|
+
path: n.path,
|
|
2051
|
+
parent: n
|
|
2052
2052
|
}),
|
|
2053
2053
|
this._def.right._parseAsync({
|
|
2054
|
-
data:
|
|
2055
|
-
path:
|
|
2056
|
-
parent:
|
|
2054
|
+
data: n.data,
|
|
2055
|
+
path: n.path,
|
|
2056
|
+
parent: n
|
|
2057
2057
|
})
|
|
2058
|
-
]).then(([a, i]) =>
|
|
2059
|
-
data:
|
|
2060
|
-
path:
|
|
2061
|
-
parent:
|
|
2058
|
+
]).then(([a, i]) => r(a, i)) : r(this._def.left._parseSync({
|
|
2059
|
+
data: n.data,
|
|
2060
|
+
path: n.path,
|
|
2061
|
+
parent: n
|
|
2062
2062
|
}), this._def.right._parseSync({
|
|
2063
|
-
data:
|
|
2064
|
-
path:
|
|
2065
|
-
parent:
|
|
2063
|
+
data: n.data,
|
|
2064
|
+
path: n.path,
|
|
2065
|
+
parent: n
|
|
2066
2066
|
}));
|
|
2067
2067
|
}
|
|
2068
2068
|
}
|
|
2069
|
-
|
|
2070
|
-
left:
|
|
2069
|
+
Q.create = (s, e, t) => new Q({
|
|
2070
|
+
left: s,
|
|
2071
2071
|
right: e,
|
|
2072
2072
|
typeName: p.ZodIntersection,
|
|
2073
2073
|
...g(t)
|
|
2074
2074
|
});
|
|
2075
|
-
class
|
|
2075
|
+
class j extends y {
|
|
2076
2076
|
_parse(e) {
|
|
2077
|
-
const { status: t, ctx:
|
|
2078
|
-
if (
|
|
2079
|
-
return
|
|
2080
|
-
code:
|
|
2077
|
+
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2078
|
+
if (n.parsedType !== u.array)
|
|
2079
|
+
return d(n, {
|
|
2080
|
+
code: c.invalid_type,
|
|
2081
2081
|
expected: u.array,
|
|
2082
|
-
received:
|
|
2082
|
+
received: n.parsedType
|
|
2083
2083
|
}), m;
|
|
2084
|
-
if (
|
|
2085
|
-
return
|
|
2086
|
-
code:
|
|
2084
|
+
if (n.data.length < this._def.items.length)
|
|
2085
|
+
return d(n, {
|
|
2086
|
+
code: c.too_small,
|
|
2087
2087
|
minimum: this._def.items.length,
|
|
2088
2088
|
inclusive: !0,
|
|
2089
2089
|
exact: !1,
|
|
2090
2090
|
type: "array"
|
|
2091
2091
|
}), m;
|
|
2092
|
-
!this._def.rest &&
|
|
2093
|
-
code:
|
|
2092
|
+
!this._def.rest && n.data.length > this._def.items.length && (d(n, {
|
|
2093
|
+
code: c.too_big,
|
|
2094
2094
|
maximum: this._def.items.length,
|
|
2095
2095
|
inclusive: !0,
|
|
2096
2096
|
exact: !1,
|
|
2097
2097
|
type: "array"
|
|
2098
2098
|
}), t.dirty());
|
|
2099
|
-
const a = [...
|
|
2100
|
-
const
|
|
2101
|
-
return
|
|
2099
|
+
const a = [...n.data].map((i, o) => {
|
|
2100
|
+
const h = this._def.items[o] || this._def.rest;
|
|
2101
|
+
return h ? h._parse(new R(n, i, n.path, o)) : null;
|
|
2102
2102
|
}).filter((i) => !!i);
|
|
2103
|
-
return
|
|
2103
|
+
return n.common.async ? Promise.all(a).then((i) => w.mergeArray(t, i)) : w.mergeArray(t, a);
|
|
2104
2104
|
}
|
|
2105
2105
|
get items() {
|
|
2106
2106
|
return this._def.items;
|
|
2107
2107
|
}
|
|
2108
2108
|
rest(e) {
|
|
2109
|
-
return new
|
|
2109
|
+
return new j({
|
|
2110
2110
|
...this._def,
|
|
2111
2111
|
rest: e
|
|
2112
2112
|
});
|
|
2113
2113
|
}
|
|
2114
2114
|
}
|
|
2115
|
-
|
|
2116
|
-
if (!Array.isArray(
|
|
2115
|
+
j.create = (s, e) => {
|
|
2116
|
+
if (!Array.isArray(s))
|
|
2117
2117
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2118
|
-
return new
|
|
2119
|
-
items:
|
|
2118
|
+
return new j({
|
|
2119
|
+
items: s,
|
|
2120
2120
|
typeName: p.ZodTuple,
|
|
2121
2121
|
rest: null,
|
|
2122
2122
|
...g(e)
|
|
2123
2123
|
});
|
|
2124
2124
|
};
|
|
2125
|
-
class
|
|
2125
|
+
class we extends y {
|
|
2126
2126
|
get keySchema() {
|
|
2127
2127
|
return this._def.keyType;
|
|
2128
2128
|
}
|
|
@@ -2130,92 +2130,92 @@ class Se extends _ {
|
|
|
2130
2130
|
return this._def.valueType;
|
|
2131
2131
|
}
|
|
2132
2132
|
_parse(e) {
|
|
2133
|
-
const { status: t, ctx:
|
|
2134
|
-
if (
|
|
2135
|
-
return
|
|
2136
|
-
code:
|
|
2133
|
+
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2134
|
+
if (n.parsedType !== u.map)
|
|
2135
|
+
return d(n, {
|
|
2136
|
+
code: c.invalid_type,
|
|
2137
2137
|
expected: u.map,
|
|
2138
|
-
received:
|
|
2138
|
+
received: n.parsedType
|
|
2139
2139
|
}), m;
|
|
2140
|
-
const
|
|
2141
|
-
key:
|
|
2142
|
-
value: a._parse(new
|
|
2140
|
+
const r = this._def.keyType, a = this._def.valueType, i = [...n.data.entries()].map(([o, h], f) => ({
|
|
2141
|
+
key: r._parse(new R(n, o, n.path, [f, "key"])),
|
|
2142
|
+
value: a._parse(new R(n, h, n.path, [f, "value"]))
|
|
2143
2143
|
}));
|
|
2144
|
-
if (
|
|
2144
|
+
if (n.common.async) {
|
|
2145
2145
|
const o = /* @__PURE__ */ new Map();
|
|
2146
2146
|
return Promise.resolve().then(async () => {
|
|
2147
|
-
for (const
|
|
2148
|
-
const
|
|
2149
|
-
if (
|
|
2147
|
+
for (const h of i) {
|
|
2148
|
+
const f = await h.key, v = await h.value;
|
|
2149
|
+
if (f.status === "aborted" || v.status === "aborted")
|
|
2150
2150
|
return m;
|
|
2151
|
-
(
|
|
2151
|
+
(f.status === "dirty" || v.status === "dirty") && t.dirty(), o.set(f.value, v.value);
|
|
2152
2152
|
}
|
|
2153
2153
|
return { status: t.value, value: o };
|
|
2154
2154
|
});
|
|
2155
2155
|
} else {
|
|
2156
2156
|
const o = /* @__PURE__ */ new Map();
|
|
2157
|
-
for (const
|
|
2158
|
-
const
|
|
2159
|
-
if (
|
|
2157
|
+
for (const h of i) {
|
|
2158
|
+
const f = h.key, v = h.value;
|
|
2159
|
+
if (f.status === "aborted" || v.status === "aborted")
|
|
2160
2160
|
return m;
|
|
2161
|
-
(
|
|
2161
|
+
(f.status === "dirty" || v.status === "dirty") && t.dirty(), o.set(f.value, v.value);
|
|
2162
2162
|
}
|
|
2163
2163
|
return { status: t.value, value: o };
|
|
2164
2164
|
}
|
|
2165
2165
|
}
|
|
2166
2166
|
}
|
|
2167
|
-
|
|
2167
|
+
we.create = (s, e, t) => new we({
|
|
2168
2168
|
valueType: e,
|
|
2169
|
-
keyType:
|
|
2169
|
+
keyType: s,
|
|
2170
2170
|
typeName: p.ZodMap,
|
|
2171
2171
|
...g(t)
|
|
2172
2172
|
});
|
|
2173
|
-
class
|
|
2173
|
+
class q extends y {
|
|
2174
2174
|
_parse(e) {
|
|
2175
|
-
const { status: t, ctx:
|
|
2176
|
-
if (
|
|
2177
|
-
return
|
|
2178
|
-
code:
|
|
2175
|
+
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2176
|
+
if (n.parsedType !== u.set)
|
|
2177
|
+
return d(n, {
|
|
2178
|
+
code: c.invalid_type,
|
|
2179
2179
|
expected: u.set,
|
|
2180
|
-
received:
|
|
2180
|
+
received: n.parsedType
|
|
2181
2181
|
}), m;
|
|
2182
|
-
const
|
|
2183
|
-
|
|
2184
|
-
code:
|
|
2185
|
-
minimum:
|
|
2182
|
+
const r = this._def;
|
|
2183
|
+
r.minSize !== null && n.data.size < r.minSize.value && (d(n, {
|
|
2184
|
+
code: c.too_small,
|
|
2185
|
+
minimum: r.minSize.value,
|
|
2186
2186
|
type: "set",
|
|
2187
2187
|
inclusive: !0,
|
|
2188
2188
|
exact: !1,
|
|
2189
|
-
message:
|
|
2190
|
-
}), t.dirty()),
|
|
2191
|
-
code:
|
|
2192
|
-
maximum:
|
|
2189
|
+
message: r.minSize.message
|
|
2190
|
+
}), t.dirty()), r.maxSize !== null && n.data.size > r.maxSize.value && (d(n, {
|
|
2191
|
+
code: c.too_big,
|
|
2192
|
+
maximum: r.maxSize.value,
|
|
2193
2193
|
type: "set",
|
|
2194
2194
|
inclusive: !0,
|
|
2195
2195
|
exact: !1,
|
|
2196
|
-
message:
|
|
2196
|
+
message: r.maxSize.message
|
|
2197
2197
|
}), t.dirty());
|
|
2198
2198
|
const a = this._def.valueType;
|
|
2199
|
-
function i(
|
|
2200
|
-
const
|
|
2201
|
-
for (const
|
|
2202
|
-
if (
|
|
2199
|
+
function i(h) {
|
|
2200
|
+
const f = /* @__PURE__ */ new Set();
|
|
2201
|
+
for (const v of h) {
|
|
2202
|
+
if (v.status === "aborted")
|
|
2203
2203
|
return m;
|
|
2204
|
-
|
|
2204
|
+
v.status === "dirty" && t.dirty(), f.add(v.value);
|
|
2205
2205
|
}
|
|
2206
|
-
return { status: t.value, value:
|
|
2206
|
+
return { status: t.value, value: f };
|
|
2207
2207
|
}
|
|
2208
|
-
const o = [...
|
|
2209
|
-
return
|
|
2208
|
+
const o = [...n.data.values()].map((h, f) => a._parse(new R(n, h, n.path, f)));
|
|
2209
|
+
return n.common.async ? Promise.all(o).then((h) => i(h)) : i(o);
|
|
2210
2210
|
}
|
|
2211
2211
|
min(e, t) {
|
|
2212
|
-
return new
|
|
2212
|
+
return new q({
|
|
2213
2213
|
...this._def,
|
|
2214
2214
|
minSize: { value: e, message: l.toString(t) }
|
|
2215
2215
|
});
|
|
2216
2216
|
}
|
|
2217
2217
|
max(e, t) {
|
|
2218
|
-
return new
|
|
2218
|
+
return new q({
|
|
2219
2219
|
...this._def,
|
|
2220
2220
|
maxSize: { value: e, message: l.toString(t) }
|
|
2221
2221
|
});
|
|
@@ -2227,14 +2227,14 @@ class F extends _ {
|
|
|
2227
2227
|
return this.min(1, e);
|
|
2228
2228
|
}
|
|
2229
2229
|
}
|
|
2230
|
-
|
|
2231
|
-
valueType:
|
|
2230
|
+
q.create = (s, e) => new q({
|
|
2231
|
+
valueType: s,
|
|
2232
2232
|
minSize: null,
|
|
2233
2233
|
maxSize: null,
|
|
2234
2234
|
typeName: p.ZodSet,
|
|
2235
2235
|
...g(e)
|
|
2236
2236
|
});
|
|
2237
|
-
class
|
|
2237
|
+
class ue extends y {
|
|
2238
2238
|
get schema() {
|
|
2239
2239
|
return this._def.getter();
|
|
2240
2240
|
}
|
|
@@ -2243,18 +2243,18 @@ class ce extends _ {
|
|
|
2243
2243
|
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2244
2244
|
}
|
|
2245
2245
|
}
|
|
2246
|
-
|
|
2247
|
-
getter:
|
|
2246
|
+
ue.create = (s, e) => new ue({
|
|
2247
|
+
getter: s,
|
|
2248
2248
|
typeName: p.ZodLazy,
|
|
2249
2249
|
...g(e)
|
|
2250
2250
|
});
|
|
2251
|
-
class
|
|
2251
|
+
class X extends y {
|
|
2252
2252
|
_parse(e) {
|
|
2253
2253
|
if (e.data !== this._def.value) {
|
|
2254
2254
|
const t = this._getOrReturnCtx(e);
|
|
2255
|
-
return
|
|
2255
|
+
return d(t, {
|
|
2256
2256
|
received: t.data,
|
|
2257
|
-
code:
|
|
2257
|
+
code: c.invalid_literal,
|
|
2258
2258
|
expected: this._def.value
|
|
2259
2259
|
}), m;
|
|
2260
2260
|
}
|
|
@@ -2264,37 +2264,37 @@ class J extends _ {
|
|
|
2264
2264
|
return this._def.value;
|
|
2265
2265
|
}
|
|
2266
2266
|
}
|
|
2267
|
-
|
|
2268
|
-
value:
|
|
2267
|
+
X.create = (s, e) => new X({
|
|
2268
|
+
value: s,
|
|
2269
2269
|
typeName: p.ZodLiteral,
|
|
2270
2270
|
...g(e)
|
|
2271
2271
|
});
|
|
2272
|
-
function
|
|
2273
|
-
return new
|
|
2274
|
-
values:
|
|
2272
|
+
function Ae(s, e) {
|
|
2273
|
+
return new E({
|
|
2274
|
+
values: s,
|
|
2275
2275
|
typeName: p.ZodEnum,
|
|
2276
2276
|
...g(e)
|
|
2277
2277
|
});
|
|
2278
2278
|
}
|
|
2279
|
-
class
|
|
2279
|
+
class E extends y {
|
|
2280
2280
|
_parse(e) {
|
|
2281
2281
|
if (typeof e.data != "string") {
|
|
2282
|
-
const t = this._getOrReturnCtx(e),
|
|
2283
|
-
return
|
|
2284
|
-
expected:
|
|
2282
|
+
const t = this._getOrReturnCtx(e), n = this._def.values;
|
|
2283
|
+
return d(t, {
|
|
2284
|
+
expected: _.joinValues(n),
|
|
2285
2285
|
received: t.parsedType,
|
|
2286
|
-
code:
|
|
2286
|
+
code: c.invalid_type
|
|
2287
2287
|
}), m;
|
|
2288
2288
|
}
|
|
2289
2289
|
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
2290
|
-
const t = this._getOrReturnCtx(e),
|
|
2291
|
-
return
|
|
2290
|
+
const t = this._getOrReturnCtx(e), n = this._def.values;
|
|
2291
|
+
return d(t, {
|
|
2292
2292
|
received: t.data,
|
|
2293
|
-
code:
|
|
2294
|
-
options:
|
|
2293
|
+
code: c.invalid_enum_value,
|
|
2294
|
+
options: n
|
|
2295
2295
|
}), m;
|
|
2296
2296
|
}
|
|
2297
|
-
return
|
|
2297
|
+
return T(e.data);
|
|
2298
2298
|
}
|
|
2299
2299
|
get options() {
|
|
2300
2300
|
return this._def.values;
|
|
@@ -2318,74 +2318,74 @@ class I extends _ {
|
|
|
2318
2318
|
return e;
|
|
2319
2319
|
}
|
|
2320
2320
|
extract(e, t = this._def) {
|
|
2321
|
-
return
|
|
2321
|
+
return E.create(e, {
|
|
2322
2322
|
...this._def,
|
|
2323
2323
|
...t
|
|
2324
2324
|
});
|
|
2325
2325
|
}
|
|
2326
2326
|
exclude(e, t = this._def) {
|
|
2327
|
-
return
|
|
2327
|
+
return E.create(this.options.filter((n) => !e.includes(n)), {
|
|
2328
2328
|
...this._def,
|
|
2329
2329
|
...t
|
|
2330
2330
|
});
|
|
2331
2331
|
}
|
|
2332
2332
|
}
|
|
2333
|
-
|
|
2334
|
-
class
|
|
2333
|
+
E.create = Ae;
|
|
2334
|
+
class G extends y {
|
|
2335
2335
|
_parse(e) {
|
|
2336
|
-
const t =
|
|
2337
|
-
if (
|
|
2338
|
-
const
|
|
2339
|
-
return
|
|
2340
|
-
expected:
|
|
2341
|
-
received:
|
|
2342
|
-
code:
|
|
2336
|
+
const t = _.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
|
|
2337
|
+
if (n.parsedType !== u.string && n.parsedType !== u.number) {
|
|
2338
|
+
const r = _.objectValues(t);
|
|
2339
|
+
return d(n, {
|
|
2340
|
+
expected: _.joinValues(r),
|
|
2341
|
+
received: n.parsedType,
|
|
2342
|
+
code: c.invalid_type
|
|
2343
2343
|
}), m;
|
|
2344
2344
|
}
|
|
2345
|
-
if (this._cache || (this._cache = new Set(
|
|
2346
|
-
const
|
|
2347
|
-
return
|
|
2348
|
-
received:
|
|
2349
|
-
code:
|
|
2350
|
-
options:
|
|
2345
|
+
if (this._cache || (this._cache = new Set(_.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
2346
|
+
const r = _.objectValues(t);
|
|
2347
|
+
return d(n, {
|
|
2348
|
+
received: n.data,
|
|
2349
|
+
code: c.invalid_enum_value,
|
|
2350
|
+
options: r
|
|
2351
2351
|
}), m;
|
|
2352
2352
|
}
|
|
2353
|
-
return
|
|
2353
|
+
return T(e.data);
|
|
2354
2354
|
}
|
|
2355
2355
|
get enum() {
|
|
2356
2356
|
return this._def.values;
|
|
2357
2357
|
}
|
|
2358
2358
|
}
|
|
2359
|
-
|
|
2360
|
-
values:
|
|
2359
|
+
G.create = (s, e) => new G({
|
|
2360
|
+
values: s,
|
|
2361
2361
|
typeName: p.ZodNativeEnum,
|
|
2362
2362
|
...g(e)
|
|
2363
2363
|
});
|
|
2364
|
-
class
|
|
2364
|
+
class K extends y {
|
|
2365
2365
|
unwrap() {
|
|
2366
2366
|
return this._def.type;
|
|
2367
2367
|
}
|
|
2368
2368
|
_parse(e) {
|
|
2369
2369
|
const { ctx: t } = this._processInputParams(e);
|
|
2370
2370
|
if (t.parsedType !== u.promise && t.common.async === !1)
|
|
2371
|
-
return
|
|
2372
|
-
code:
|
|
2371
|
+
return d(t, {
|
|
2372
|
+
code: c.invalid_type,
|
|
2373
2373
|
expected: u.promise,
|
|
2374
2374
|
received: t.parsedType
|
|
2375
2375
|
}), m;
|
|
2376
|
-
const
|
|
2377
|
-
return
|
|
2376
|
+
const n = t.parsedType === u.promise ? t.data : Promise.resolve(t.data);
|
|
2377
|
+
return T(n.then((r) => this._def.type.parseAsync(r, {
|
|
2378
2378
|
path: t.path,
|
|
2379
2379
|
errorMap: t.common.contextualErrorMap
|
|
2380
2380
|
})));
|
|
2381
2381
|
}
|
|
2382
2382
|
}
|
|
2383
|
-
|
|
2384
|
-
type:
|
|
2383
|
+
K.create = (s, e) => new K({
|
|
2384
|
+
type: s,
|
|
2385
2385
|
typeName: p.ZodPromise,
|
|
2386
2386
|
...g(e)
|
|
2387
2387
|
});
|
|
2388
|
-
class
|
|
2388
|
+
class I extends y {
|
|
2389
2389
|
innerType() {
|
|
2390
2390
|
return this._def.schema;
|
|
2391
2391
|
}
|
|
@@ -2393,122 +2393,122 @@ class M extends _ {
|
|
|
2393
2393
|
return this._def.schema._def.typeName === p.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2394
2394
|
}
|
|
2395
2395
|
_parse(e) {
|
|
2396
|
-
const { status: t, ctx:
|
|
2396
|
+
const { status: t, ctx: n } = this._processInputParams(e), r = this._def.effect || null, a = {
|
|
2397
2397
|
addIssue: (i) => {
|
|
2398
|
-
|
|
2398
|
+
d(n, i), i.fatal ? t.abort() : t.dirty();
|
|
2399
2399
|
},
|
|
2400
2400
|
get path() {
|
|
2401
|
-
return
|
|
2401
|
+
return n.path;
|
|
2402
2402
|
}
|
|
2403
2403
|
};
|
|
2404
|
-
if (a.addIssue = a.addIssue.bind(a),
|
|
2405
|
-
const i =
|
|
2406
|
-
if (
|
|
2404
|
+
if (a.addIssue = a.addIssue.bind(a), r.type === "preprocess") {
|
|
2405
|
+
const i = r.transform(n.data, a);
|
|
2406
|
+
if (n.common.async)
|
|
2407
2407
|
return Promise.resolve(i).then(async (o) => {
|
|
2408
2408
|
if (t.value === "aborted")
|
|
2409
2409
|
return m;
|
|
2410
|
-
const
|
|
2410
|
+
const h = await this._def.schema._parseAsync({
|
|
2411
2411
|
data: o,
|
|
2412
|
-
path:
|
|
2413
|
-
parent:
|
|
2412
|
+
path: n.path,
|
|
2413
|
+
parent: n
|
|
2414
2414
|
});
|
|
2415
|
-
return
|
|
2415
|
+
return h.status === "aborted" ? m : h.status === "dirty" || t.value === "dirty" ? z(h.value) : h;
|
|
2416
2416
|
});
|
|
2417
2417
|
{
|
|
2418
2418
|
if (t.value === "aborted")
|
|
2419
2419
|
return m;
|
|
2420
2420
|
const o = this._def.schema._parseSync({
|
|
2421
2421
|
data: i,
|
|
2422
|
-
path:
|
|
2423
|
-
parent:
|
|
2422
|
+
path: n.path,
|
|
2423
|
+
parent: n
|
|
2424
2424
|
});
|
|
2425
|
-
return o.status === "aborted" ? m : o.status === "dirty" || t.value === "dirty" ?
|
|
2425
|
+
return o.status === "aborted" ? m : o.status === "dirty" || t.value === "dirty" ? z(o.value) : o;
|
|
2426
2426
|
}
|
|
2427
2427
|
}
|
|
2428
|
-
if (
|
|
2428
|
+
if (r.type === "refinement") {
|
|
2429
2429
|
const i = (o) => {
|
|
2430
|
-
const
|
|
2431
|
-
if (
|
|
2432
|
-
return Promise.resolve(
|
|
2433
|
-
if (
|
|
2430
|
+
const h = r.refinement(o, a);
|
|
2431
|
+
if (n.common.async)
|
|
2432
|
+
return Promise.resolve(h);
|
|
2433
|
+
if (h instanceof Promise)
|
|
2434
2434
|
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2435
2435
|
return o;
|
|
2436
2436
|
};
|
|
2437
|
-
if (
|
|
2437
|
+
if (n.common.async === !1) {
|
|
2438
2438
|
const o = this._def.schema._parseSync({
|
|
2439
|
-
data:
|
|
2440
|
-
path:
|
|
2441
|
-
parent:
|
|
2439
|
+
data: n.data,
|
|
2440
|
+
path: n.path,
|
|
2441
|
+
parent: n
|
|
2442
2442
|
});
|
|
2443
2443
|
return o.status === "aborted" ? m : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
|
|
2444
2444
|
} else
|
|
2445
|
-
return this._def.schema._parseAsync({ data:
|
|
2445
|
+
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((o) => o.status === "aborted" ? m : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
|
|
2446
2446
|
}
|
|
2447
|
-
if (
|
|
2448
|
-
if (
|
|
2447
|
+
if (r.type === "transform")
|
|
2448
|
+
if (n.common.async === !1) {
|
|
2449
2449
|
const i = this._def.schema._parseSync({
|
|
2450
|
-
data:
|
|
2451
|
-
path:
|
|
2452
|
-
parent:
|
|
2450
|
+
data: n.data,
|
|
2451
|
+
path: n.path,
|
|
2452
|
+
parent: n
|
|
2453
2453
|
});
|
|
2454
|
-
if (!
|
|
2454
|
+
if (!V(i))
|
|
2455
2455
|
return m;
|
|
2456
|
-
const o =
|
|
2456
|
+
const o = r.transform(i.value, a);
|
|
2457
2457
|
if (o instanceof Promise)
|
|
2458
2458
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2459
2459
|
return { status: t.value, value: o };
|
|
2460
2460
|
} else
|
|
2461
|
-
return this._def.schema._parseAsync({ data:
|
|
2461
|
+
return this._def.schema._parseAsync({ data: n.data, path: n.path, parent: n }).then((i) => V(i) ? Promise.resolve(r.transform(i.value, a)).then((o) => ({
|
|
2462
2462
|
status: t.value,
|
|
2463
2463
|
value: o
|
|
2464
2464
|
})) : m);
|
|
2465
|
-
|
|
2465
|
+
_.assertNever(r);
|
|
2466
2466
|
}
|
|
2467
2467
|
}
|
|
2468
|
-
|
|
2469
|
-
schema:
|
|
2468
|
+
I.create = (s, e, t) => new I({
|
|
2469
|
+
schema: s,
|
|
2470
2470
|
typeName: p.ZodEffects,
|
|
2471
2471
|
effect: e,
|
|
2472
2472
|
...g(t)
|
|
2473
2473
|
});
|
|
2474
|
-
|
|
2474
|
+
I.createWithPreprocess = (s, e, t) => new I({
|
|
2475
2475
|
schema: e,
|
|
2476
|
-
effect: { type: "preprocess", transform:
|
|
2476
|
+
effect: { type: "preprocess", transform: s },
|
|
2477
2477
|
typeName: p.ZodEffects,
|
|
2478
2478
|
...g(t)
|
|
2479
2479
|
});
|
|
2480
|
-
class
|
|
2480
|
+
class A extends y {
|
|
2481
2481
|
_parse(e) {
|
|
2482
|
-
return this._getType(e) === u.undefined ?
|
|
2482
|
+
return this._getType(e) === u.undefined ? T(void 0) : this._def.innerType._parse(e);
|
|
2483
2483
|
}
|
|
2484
2484
|
unwrap() {
|
|
2485
2485
|
return this._def.innerType;
|
|
2486
2486
|
}
|
|
2487
2487
|
}
|
|
2488
|
-
|
|
2489
|
-
innerType:
|
|
2488
|
+
A.create = (s, e) => new A({
|
|
2489
|
+
innerType: s,
|
|
2490
2490
|
typeName: p.ZodOptional,
|
|
2491
2491
|
...g(e)
|
|
2492
2492
|
});
|
|
2493
|
-
class
|
|
2493
|
+
class M extends y {
|
|
2494
2494
|
_parse(e) {
|
|
2495
|
-
return this._getType(e) === u.null ?
|
|
2495
|
+
return this._getType(e) === u.null ? T(null) : this._def.innerType._parse(e);
|
|
2496
2496
|
}
|
|
2497
2497
|
unwrap() {
|
|
2498
2498
|
return this._def.innerType;
|
|
2499
2499
|
}
|
|
2500
2500
|
}
|
|
2501
|
-
|
|
2502
|
-
innerType:
|
|
2501
|
+
M.create = (s, e) => new M({
|
|
2502
|
+
innerType: s,
|
|
2503
2503
|
typeName: p.ZodNullable,
|
|
2504
2504
|
...g(e)
|
|
2505
2505
|
});
|
|
2506
|
-
class
|
|
2506
|
+
class ee extends y {
|
|
2507
2507
|
_parse(e) {
|
|
2508
2508
|
const { ctx: t } = this._processInputParams(e);
|
|
2509
|
-
let
|
|
2510
|
-
return t.parsedType === u.undefined && (
|
|
2511
|
-
data:
|
|
2509
|
+
let n = t.data;
|
|
2510
|
+
return t.parsedType === u.undefined && (n = this._def.defaultValue()), this._def.innerType._parse({
|
|
2511
|
+
data: n,
|
|
2512
2512
|
path: t.path,
|
|
2513
2513
|
parent: t
|
|
2514
2514
|
});
|
|
@@ -2517,42 +2517,42 @@ class G extends _ {
|
|
|
2517
2517
|
return this._def.innerType;
|
|
2518
2518
|
}
|
|
2519
2519
|
}
|
|
2520
|
-
|
|
2521
|
-
innerType:
|
|
2520
|
+
ee.create = (s, e) => new ee({
|
|
2521
|
+
innerType: s,
|
|
2522
2522
|
typeName: p.ZodDefault,
|
|
2523
2523
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2524
2524
|
...g(e)
|
|
2525
2525
|
});
|
|
2526
|
-
class
|
|
2526
|
+
class te extends y {
|
|
2527
2527
|
_parse(e) {
|
|
2528
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2528
|
+
const { ctx: t } = this._processInputParams(e), n = {
|
|
2529
2529
|
...t,
|
|
2530
2530
|
common: {
|
|
2531
2531
|
...t.common,
|
|
2532
2532
|
issues: []
|
|
2533
2533
|
}
|
|
2534
|
-
},
|
|
2535
|
-
data:
|
|
2536
|
-
path:
|
|
2534
|
+
}, r = this._def.innerType._parse({
|
|
2535
|
+
data: n.data,
|
|
2536
|
+
path: n.path,
|
|
2537
2537
|
parent: {
|
|
2538
|
-
...
|
|
2538
|
+
...n
|
|
2539
2539
|
}
|
|
2540
2540
|
});
|
|
2541
|
-
return
|
|
2541
|
+
return Y(r) ? r.then((a) => ({
|
|
2542
2542
|
status: "valid",
|
|
2543
2543
|
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2544
2544
|
get error() {
|
|
2545
|
-
return new
|
|
2545
|
+
return new N(n.common.issues);
|
|
2546
2546
|
},
|
|
2547
|
-
input:
|
|
2547
|
+
input: n.data
|
|
2548
2548
|
})
|
|
2549
2549
|
})) : {
|
|
2550
2550
|
status: "valid",
|
|
2551
|
-
value:
|
|
2551
|
+
value: r.status === "valid" ? r.value : this._def.catchValue({
|
|
2552
2552
|
get error() {
|
|
2553
|
-
return new
|
|
2553
|
+
return new N(n.common.issues);
|
|
2554
2554
|
},
|
|
2555
|
-
input:
|
|
2555
|
+
input: n.data
|
|
2556
2556
|
})
|
|
2557
2557
|
};
|
|
2558
2558
|
}
|
|
@@ -2560,34 +2560,34 @@ class K extends _ {
|
|
|
2560
2560
|
return this._def.innerType;
|
|
2561
2561
|
}
|
|
2562
2562
|
}
|
|
2563
|
-
|
|
2564
|
-
innerType:
|
|
2563
|
+
te.create = (s, e) => new te({
|
|
2564
|
+
innerType: s,
|
|
2565
2565
|
typeName: p.ZodCatch,
|
|
2566
2566
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2567
2567
|
...g(e)
|
|
2568
2568
|
});
|
|
2569
|
-
class Te extends
|
|
2569
|
+
class Te extends y {
|
|
2570
2570
|
_parse(e) {
|
|
2571
2571
|
if (this._getType(e) !== u.nan) {
|
|
2572
|
-
const
|
|
2573
|
-
return
|
|
2574
|
-
code:
|
|
2572
|
+
const n = this._getOrReturnCtx(e);
|
|
2573
|
+
return d(n, {
|
|
2574
|
+
code: c.invalid_type,
|
|
2575
2575
|
expected: u.nan,
|
|
2576
|
-
received:
|
|
2576
|
+
received: n.parsedType
|
|
2577
2577
|
}), m;
|
|
2578
2578
|
}
|
|
2579
2579
|
return { status: "valid", value: e.data };
|
|
2580
2580
|
}
|
|
2581
2581
|
}
|
|
2582
|
-
Te.create = (
|
|
2582
|
+
Te.create = (s) => new Te({
|
|
2583
2583
|
typeName: p.ZodNaN,
|
|
2584
|
-
...g(
|
|
2584
|
+
...g(s)
|
|
2585
2585
|
});
|
|
2586
|
-
class
|
|
2586
|
+
class Ne extends y {
|
|
2587
2587
|
_parse(e) {
|
|
2588
|
-
const { ctx: t } = this._processInputParams(e),
|
|
2588
|
+
const { ctx: t } = this._processInputParams(e), n = t.data;
|
|
2589
2589
|
return this._def.type._parse({
|
|
2590
|
-
data:
|
|
2590
|
+
data: n,
|
|
2591
2591
|
path: t.path,
|
|
2592
2592
|
parent: t
|
|
2593
2593
|
});
|
|
@@ -2596,78 +2596,78 @@ class Oe extends _ {
|
|
|
2596
2596
|
return this._def.type;
|
|
2597
2597
|
}
|
|
2598
2598
|
}
|
|
2599
|
-
class
|
|
2599
|
+
class he extends y {
|
|
2600
2600
|
_parse(e) {
|
|
2601
|
-
const { status: t, ctx:
|
|
2602
|
-
if (
|
|
2601
|
+
const { status: t, ctx: n } = this._processInputParams(e);
|
|
2602
|
+
if (n.common.async)
|
|
2603
2603
|
return (async () => {
|
|
2604
2604
|
const a = await this._def.in._parseAsync({
|
|
2605
|
-
data:
|
|
2606
|
-
path:
|
|
2607
|
-
parent:
|
|
2605
|
+
data: n.data,
|
|
2606
|
+
path: n.path,
|
|
2607
|
+
parent: n
|
|
2608
2608
|
});
|
|
2609
|
-
return a.status === "aborted" ? m : a.status === "dirty" ? (t.dirty(),
|
|
2609
|
+
return a.status === "aborted" ? m : a.status === "dirty" ? (t.dirty(), z(a.value)) : this._def.out._parseAsync({
|
|
2610
2610
|
data: a.value,
|
|
2611
|
-
path:
|
|
2612
|
-
parent:
|
|
2611
|
+
path: n.path,
|
|
2612
|
+
parent: n
|
|
2613
2613
|
});
|
|
2614
2614
|
})();
|
|
2615
2615
|
{
|
|
2616
|
-
const
|
|
2617
|
-
data:
|
|
2618
|
-
path:
|
|
2619
|
-
parent:
|
|
2616
|
+
const r = this._def.in._parseSync({
|
|
2617
|
+
data: n.data,
|
|
2618
|
+
path: n.path,
|
|
2619
|
+
parent: n
|
|
2620
2620
|
});
|
|
2621
|
-
return
|
|
2621
|
+
return r.status === "aborted" ? m : r.status === "dirty" ? (t.dirty(), {
|
|
2622
2622
|
status: "dirty",
|
|
2623
|
-
value:
|
|
2623
|
+
value: r.value
|
|
2624
2624
|
}) : this._def.out._parseSync({
|
|
2625
|
-
data:
|
|
2626
|
-
path:
|
|
2627
|
-
parent:
|
|
2625
|
+
data: r.value,
|
|
2626
|
+
path: n.path,
|
|
2627
|
+
parent: n
|
|
2628
2628
|
});
|
|
2629
2629
|
}
|
|
2630
2630
|
}
|
|
2631
2631
|
static create(e, t) {
|
|
2632
|
-
return new
|
|
2632
|
+
return new he({
|
|
2633
2633
|
in: e,
|
|
2634
2634
|
out: t,
|
|
2635
2635
|
typeName: p.ZodPipeline
|
|
2636
2636
|
});
|
|
2637
2637
|
}
|
|
2638
2638
|
}
|
|
2639
|
-
class
|
|
2639
|
+
class se extends y {
|
|
2640
2640
|
_parse(e) {
|
|
2641
|
-
const t = this._def.innerType._parse(e),
|
|
2642
|
-
return
|
|
2641
|
+
const t = this._def.innerType._parse(e), n = (r) => (V(r) && (r.value = Object.freeze(r.value)), r);
|
|
2642
|
+
return Y(t) ? t.then((r) => n(r)) : n(t);
|
|
2643
2643
|
}
|
|
2644
2644
|
unwrap() {
|
|
2645
2645
|
return this._def.innerType;
|
|
2646
2646
|
}
|
|
2647
2647
|
}
|
|
2648
|
-
|
|
2649
|
-
innerType:
|
|
2648
|
+
se.create = (s, e) => new se({
|
|
2649
|
+
innerType: s,
|
|
2650
2650
|
typeName: p.ZodReadonly,
|
|
2651
2651
|
...g(e)
|
|
2652
2652
|
});
|
|
2653
2653
|
var p;
|
|
2654
|
-
(function(
|
|
2655
|
-
|
|
2654
|
+
(function(s) {
|
|
2655
|
+
s.ZodString = "ZodString", s.ZodNumber = "ZodNumber", s.ZodNaN = "ZodNaN", s.ZodBigInt = "ZodBigInt", s.ZodBoolean = "ZodBoolean", s.ZodDate = "ZodDate", s.ZodSymbol = "ZodSymbol", s.ZodUndefined = "ZodUndefined", s.ZodNull = "ZodNull", s.ZodAny = "ZodAny", s.ZodUnknown = "ZodUnknown", s.ZodNever = "ZodNever", s.ZodVoid = "ZodVoid", s.ZodArray = "ZodArray", s.ZodObject = "ZodObject", s.ZodUnion = "ZodUnion", s.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", s.ZodIntersection = "ZodIntersection", s.ZodTuple = "ZodTuple", s.ZodRecord = "ZodRecord", s.ZodMap = "ZodMap", s.ZodSet = "ZodSet", s.ZodFunction = "ZodFunction", s.ZodLazy = "ZodLazy", s.ZodLiteral = "ZodLiteral", s.ZodEnum = "ZodEnum", s.ZodEffects = "ZodEffects", s.ZodNativeEnum = "ZodNativeEnum", s.ZodOptional = "ZodOptional", s.ZodNullable = "ZodNullable", s.ZodDefault = "ZodDefault", s.ZodCatch = "ZodCatch", s.ZodPromise = "ZodPromise", s.ZodBranded = "ZodBranded", s.ZodPipeline = "ZodPipeline", s.ZodReadonly = "ZodReadonly";
|
|
2656
2656
|
})(p || (p = {}));
|
|
2657
|
-
const
|
|
2657
|
+
const U = $.create, x = D.create, rt = ie.create;
|
|
2658
|
+
Z.create;
|
|
2659
|
+
const at = C.create, fe = k.create;
|
|
2660
|
+
J.create;
|
|
2661
|
+
const it = le.create;
|
|
2662
|
+
Q.create;
|
|
2658
2663
|
j.create;
|
|
2659
|
-
const
|
|
2660
|
-
H.create;
|
|
2661
|
-
const at = ue.create;
|
|
2662
|
-
Y.create;
|
|
2664
|
+
const P = X.create;
|
|
2663
2665
|
E.create;
|
|
2664
|
-
const
|
|
2665
|
-
|
|
2666
|
-
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
L.create;
|
|
2670
|
-
const it = {
|
|
2666
|
+
const b = G.create;
|
|
2667
|
+
K.create;
|
|
2668
|
+
A.create;
|
|
2669
|
+
M.create;
|
|
2670
|
+
const ot = {
|
|
2671
2671
|
Off: "O",
|
|
2672
2672
|
Normal: "N",
|
|
2673
2673
|
BackfeedAfter: "A",
|
|
@@ -2681,29 +2681,31 @@ const it = {
|
|
|
2681
2681
|
Backfeed70: "70",
|
|
2682
2682
|
Backfeed80: "80",
|
|
2683
2683
|
Backfeed90: "90"
|
|
2684
|
-
},
|
|
2684
|
+
}, ct = b(ot), dt = {
|
|
2685
2685
|
Continuous: "N",
|
|
2686
2686
|
VariableLengthContinuous: "V",
|
|
2687
2687
|
NonContinuousWebSensing: "W",
|
|
2688
2688
|
NonContinuousWebSensingAlt: "Y",
|
|
2689
2689
|
NonContinuousMarkSensing: "M",
|
|
2690
2690
|
AutoDetect: "A"
|
|
2691
|
-
},
|
|
2691
|
+
}, ut = b(dt), lt = {
|
|
2692
2692
|
DirectThermal: "D",
|
|
2693
2693
|
ThermalTransfer: "T"
|
|
2694
|
-
},
|
|
2694
|
+
}, ht = b(lt), ft = {
|
|
2695
2695
|
Invert: "I",
|
|
2696
2696
|
Normal: "N"
|
|
2697
|
-
},
|
|
2697
|
+
}, mt = b(ft), pt = {
|
|
2698
2698
|
Mirror: "Y",
|
|
2699
2699
|
Normal: "N"
|
|
2700
|
-
},
|
|
2700
|
+
}, gt = b(pt), yt = {
|
|
2701
2701
|
Normal: "A",
|
|
2702
2702
|
Half: "B"
|
|
2703
|
-
},
|
|
2703
|
+
}, _t = b(
|
|
2704
|
+
yt
|
|
2705
|
+
), vt = {
|
|
2704
2706
|
Enable: "Y",
|
|
2705
2707
|
Disable: "N"
|
|
2706
|
-
},
|
|
2708
|
+
}, xt = b(vt), kt = {
|
|
2707
2709
|
TearOff: "T",
|
|
2708
2710
|
PeelOff: "P",
|
|
2709
2711
|
Rewind: "R",
|
|
@@ -2712,99 +2714,116 @@ const it = {
|
|
|
2712
2714
|
DelayedCut: "D",
|
|
2713
2715
|
EncodeRFID: "F",
|
|
2714
2716
|
Kiosk: "K"
|
|
2715
|
-
},
|
|
2717
|
+
}, bt = b(kt), wt = {
|
|
2716
2718
|
Prepeel: "Y",
|
|
2717
2719
|
NoPrepeel: "N"
|
|
2718
|
-
},
|
|
2720
|
+
}, Tt = b(wt), Ct = {
|
|
2719
2721
|
AllMedia: "Y",
|
|
2720
2722
|
ContinuousOnly: "N"
|
|
2721
|
-
},
|
|
2723
|
+
}, St = b(Ct), At = {
|
|
2722
2724
|
NoRotation: "N",
|
|
2723
2725
|
Rotate90: "R",
|
|
2724
2726
|
Rotate180: "I",
|
|
2725
2727
|
Rotate270: "B"
|
|
2726
|
-
},
|
|
2728
|
+
}, Oe = b(At), Nt = {
|
|
2727
2729
|
Left: "L",
|
|
2728
2730
|
Right: "R",
|
|
2729
2731
|
Center: "C",
|
|
2730
2732
|
Justified: "J"
|
|
2731
|
-
},
|
|
2733
|
+
}, Ot = b(Nt), $t = {
|
|
2732
2734
|
Highest: "H",
|
|
2733
2735
|
High: "Q",
|
|
2734
2736
|
Medium: "M",
|
|
2735
2737
|
Lower: "L"
|
|
2736
|
-
},
|
|
2738
|
+
}, Rt = b($t), Zt = {
|
|
2737
2739
|
Yes: "Y",
|
|
2738
2740
|
No: "N"
|
|
2739
|
-
},
|
|
2741
|
+
}, re = b(Zt), $e = {
|
|
2740
2742
|
Start: "start",
|
|
2741
2743
|
End: "end"
|
|
2742
|
-
},
|
|
2743
|
-
|
|
2744
|
+
}, jt = b($e), Et = {
|
|
2745
|
+
account: "account",
|
|
2746
|
+
accountAttributes: "accountAttributes",
|
|
2747
|
+
accountTiers: "accountTiers",
|
|
2748
|
+
pass: "pass",
|
|
2749
|
+
passResponses: "passResponses",
|
|
2750
|
+
passAttributes: "passAttributes"
|
|
2751
|
+
}, It = b(Et), F = {
|
|
2752
|
+
None: "None",
|
|
2753
|
+
Uppercase: "Uppercase",
|
|
2754
|
+
Lowercase: "Lowercase",
|
|
2755
|
+
Capitalize: "Capitalize"
|
|
2756
|
+
}, Mt = b(F), Gt = fe({
|
|
2757
|
+
word: U(),
|
|
2744
2758
|
width: x(),
|
|
2745
2759
|
spaceWidth: x()
|
|
2746
|
-
}),
|
|
2747
|
-
name:
|
|
2760
|
+
}), me = fe({
|
|
2761
|
+
name: U(),
|
|
2748
2762
|
x: x().int(),
|
|
2749
2763
|
y: x().int(),
|
|
2750
|
-
|
|
2751
|
-
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2764
|
+
defaultValue: U(),
|
|
2765
|
+
sourceType: It,
|
|
2766
|
+
sourceLookup: U(),
|
|
2767
|
+
hideEmpty: rt()
|
|
2768
|
+
}), Lt = me.extend({
|
|
2769
|
+
type: P("text"),
|
|
2770
|
+
// ^A font, height
|
|
2771
|
+
font: U().regex(/^[A-Z0-9]$/, "Font must be a single character A-Z or 0-9"),
|
|
2772
|
+
fontOrientation: Oe,
|
|
2756
2773
|
fontHeight: x().int().min(1).max(32e3),
|
|
2757
|
-
fontWidth: x().int().min(1).max(32e3).optional(),
|
|
2758
2774
|
// ^FB maxWidth, maxLines, lineSpacing, alignment, hangingIndent
|
|
2759
2775
|
maxWidth: x().int().min(0).max(9999),
|
|
2760
2776
|
maxLines: x().int().min(1).max(9999),
|
|
2761
2777
|
lineSpacing: x().int().min(-9999).max(9999),
|
|
2762
|
-
alignment:
|
|
2778
|
+
alignment: Ot,
|
|
2763
2779
|
hangingIndent: x().int().min(0).max(9999),
|
|
2764
|
-
verticalAlignment:
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2780
|
+
verticalAlignment: jt,
|
|
2781
|
+
// CUSTOM
|
|
2782
|
+
charsPerLine: x().int().min(1).max(100),
|
|
2783
|
+
transformation: Mt,
|
|
2784
|
+
maxCharacters: x().int().min(1).max(100)
|
|
2785
|
+
}), Pt = me.extend({
|
|
2786
|
+
type: P("barcode"),
|
|
2768
2787
|
// ^BY barWidth
|
|
2769
2788
|
barWidth: x().int().min(4).max(9999),
|
|
2770
2789
|
// ^BC orientation, height, line, lineAbove, checkDigit
|
|
2771
|
-
orientation:
|
|
2790
|
+
orientation: Oe,
|
|
2772
2791
|
height: x().int().min(1).max(32e3),
|
|
2773
|
-
line:
|
|
2774
|
-
lineAbove:
|
|
2775
|
-
checkDigit:
|
|
2776
|
-
}),
|
|
2777
|
-
type:
|
|
2792
|
+
line: re,
|
|
2793
|
+
lineAbove: re,
|
|
2794
|
+
checkDigit: re
|
|
2795
|
+
}), Vt = me.extend({
|
|
2796
|
+
type: P("qrcode"),
|
|
2778
2797
|
// ^BQ orientation, model, magnification, errorCorrection, mask
|
|
2779
|
-
orientation:
|
|
2780
|
-
model:
|
|
2798
|
+
orientation: P("N"),
|
|
2799
|
+
model: P("2"),
|
|
2781
2800
|
magnification: x().int().min(1).max(100),
|
|
2782
|
-
errorCorrection:
|
|
2801
|
+
errorCorrection: Rt,
|
|
2783
2802
|
mask: x().int().min(0).max(7)
|
|
2784
|
-
}),
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
]),
|
|
2789
|
-
type:
|
|
2803
|
+
}), Dt = it("type", [
|
|
2804
|
+
Lt,
|
|
2805
|
+
Pt,
|
|
2806
|
+
Vt
|
|
2807
|
+
]), Re = fe({
|
|
2808
|
+
type: P("thermal"),
|
|
2790
2809
|
// ~TA adjustment
|
|
2791
2810
|
tearOffAdjustment: x().int().min(0).max(120),
|
|
2792
2811
|
// ~JS sequence
|
|
2793
|
-
backfeedActions:
|
|
2812
|
+
backfeedActions: ct,
|
|
2794
2813
|
// ^MN media, offset
|
|
2795
|
-
media:
|
|
2814
|
+
media: ut,
|
|
2796
2815
|
mediaOffset: x().int().min(-75).max(283),
|
|
2797
2816
|
// ^MT mediaType
|
|
2798
|
-
thermalMediaType:
|
|
2817
|
+
thermalMediaType: ht,
|
|
2799
2818
|
// ^PO orientation
|
|
2800
|
-
printOrientation:
|
|
2819
|
+
printOrientation: mt,
|
|
2801
2820
|
// ^PM mirror
|
|
2802
|
-
mirror:
|
|
2821
|
+
mirror: gt,
|
|
2803
2822
|
// ^LH x,y
|
|
2804
2823
|
labelHomeX: x().int().min(0).max(32e3),
|
|
2805
2824
|
labelHomeY: x().int().min(0).max(32e3),
|
|
2806
2825
|
// ^JM adjustment
|
|
2807
|
-
printDensityAdjustment:
|
|
2826
|
+
printDensityAdjustment: _t,
|
|
2808
2827
|
// ^PR printSpeed, slewSpeed, backfeedSpeed
|
|
2809
2828
|
printSpeed: x().int().min(1).max(14),
|
|
2810
2829
|
slewSpeed: x().int().min(1).max(14),
|
|
@@ -2812,164 +2831,213 @@ const it = {
|
|
|
2812
2831
|
// ~SD darkness
|
|
2813
2832
|
darkness: x().int().min(0).max(30),
|
|
2814
2833
|
// ^LR reverse
|
|
2815
|
-
reverse:
|
|
2834
|
+
reverse: xt,
|
|
2816
2835
|
// ^MM mode, prepeel
|
|
2817
|
-
postPrintMode:
|
|
2818
|
-
prepeel:
|
|
2836
|
+
postPrintMode: bt,
|
|
2837
|
+
prepeel: Tt,
|
|
2819
2838
|
// ^PW width
|
|
2820
2839
|
printWidth: x().int().min(2),
|
|
2821
2840
|
// ^LL length, allMedia
|
|
2822
2841
|
labelLength: x().int().min(1).max(32e3),
|
|
2823
|
-
allMedia:
|
|
2842
|
+
allMedia: St,
|
|
2824
2843
|
// Fields
|
|
2825
|
-
fields:
|
|
2844
|
+
fields: at(Dt)
|
|
2826
2845
|
});
|
|
2827
|
-
function
|
|
2828
|
-
return
|
|
2829
|
-
}
|
|
2830
|
-
function
|
|
2831
|
-
return
|
|
2832
|
-
}
|
|
2833
|
-
function
|
|
2834
|
-
if (
|
|
2835
|
-
return
|
|
2836
|
-
throw new Error(`Unsupported badge type: ${
|
|
2837
|
-
}
|
|
2838
|
-
function
|
|
2839
|
-
const
|
|
2840
|
-
for (const
|
|
2841
|
-
e
|
|
2842
|
-
|
|
2846
|
+
function Kt(s) {
|
|
2847
|
+
return Re.safeParse(s);
|
|
2848
|
+
}
|
|
2849
|
+
function es(s) {
|
|
2850
|
+
return Re.parse(s);
|
|
2851
|
+
}
|
|
2852
|
+
function ts(s, e) {
|
|
2853
|
+
if (s.type === "thermal")
|
|
2854
|
+
return Bt(s, e);
|
|
2855
|
+
throw new Error(`Unsupported badge type: ${s.type}`);
|
|
2856
|
+
}
|
|
2857
|
+
function Bt(s, e) {
|
|
2858
|
+
const t = ["^XA", zt(s)];
|
|
2859
|
+
for (const n of s.fields) {
|
|
2860
|
+
const r = Ft(n, e);
|
|
2861
|
+
r && t.push(r);
|
|
2862
|
+
}
|
|
2863
|
+
return t.push("^XZ"), t.join(`
|
|
2843
2864
|
`);
|
|
2844
2865
|
}
|
|
2845
|
-
function
|
|
2866
|
+
function zt(s) {
|
|
2846
2867
|
const t = [
|
|
2847
|
-
`~TA${String(
|
|
2848
|
-
`~JS${
|
|
2849
|
-
`^MN${
|
|
2850
|
-
`^MT${
|
|
2851
|
-
`^PO${
|
|
2852
|
-
`^PM${
|
|
2853
|
-
`^LH${
|
|
2868
|
+
`~TA${String(s.tearOffAdjustment).padStart(3, "0")}`,
|
|
2869
|
+
`~JS${s.backfeedActions}`,
|
|
2870
|
+
`^MN${s.media},${s.mediaOffset}`,
|
|
2871
|
+
`^MT${s.thermalMediaType}`,
|
|
2872
|
+
`^PO${s.printOrientation}`,
|
|
2873
|
+
`^PM${s.mirror}`,
|
|
2874
|
+
`^LH${s.labelHomeX},${s.labelHomeY}`
|
|
2854
2875
|
];
|
|
2855
|
-
return
|
|
2856
|
-
`^PR${
|
|
2857
|
-
`~SD${
|
|
2858
|
-
`^LR${
|
|
2859
|
-
`^MM${
|
|
2860
|
-
`^PW${
|
|
2861
|
-
`^LL${
|
|
2876
|
+
return s.printDensityAdjustment !== void 0 && t.push(`^JM${s.printDensityAdjustment}`), t.push(
|
|
2877
|
+
`^PR${s.printSpeed},${s.slewSpeed},${s.backfeedSpeed}`,
|
|
2878
|
+
`~SD${s.darkness}`,
|
|
2879
|
+
`^LR${s.reverse}`,
|
|
2880
|
+
`^MM${s.postPrintMode},${s.prepeel}`,
|
|
2881
|
+
`^PW${s.printWidth}`,
|
|
2882
|
+
`^LL${s.labelLength},${s.allMedia}`
|
|
2862
2883
|
), t.join(`
|
|
2863
2884
|
`);
|
|
2864
2885
|
}
|
|
2865
|
-
function
|
|
2866
|
-
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
2875
|
-
|
|
2886
|
+
function Ft(s, e) {
|
|
2887
|
+
let t = Ut(s, e);
|
|
2888
|
+
if (typeof t == "string")
|
|
2889
|
+
switch (s.type) {
|
|
2890
|
+
case "text":
|
|
2891
|
+
return t = Wt(s, t), qt(s, t);
|
|
2892
|
+
case "barcode":
|
|
2893
|
+
return Qt(s, t);
|
|
2894
|
+
case "qrcode":
|
|
2895
|
+
return Xt(s, t);
|
|
2896
|
+
default: {
|
|
2897
|
+
const n = s;
|
|
2898
|
+
throw new Error(`Unsupported field type: ${n.type}`);
|
|
2899
|
+
}
|
|
2876
2900
|
}
|
|
2877
|
-
}
|
|
2878
2901
|
}
|
|
2879
|
-
function
|
|
2880
|
-
|
|
2881
|
-
let t =
|
|
2882
|
-
n
|
|
2883
|
-
const r
|
|
2884
|
-
|
|
2885
|
-
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
|
|
2889
|
-
|
|
2890
|
-
|
|
2891
|
-
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
|
|
2898
|
-
|
|
2899
|
-
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2902
|
+
function Ut(s, e) {
|
|
2903
|
+
if (!e) return s.defaultValue ?? "";
|
|
2904
|
+
let t = [];
|
|
2905
|
+
const n = s.sourceLookup.split(",");
|
|
2906
|
+
for (const r of n)
|
|
2907
|
+
switch (s.sourceType) {
|
|
2908
|
+
case "account": {
|
|
2909
|
+
const a = e.account[r];
|
|
2910
|
+
a && t.push(a);
|
|
2911
|
+
break;
|
|
2912
|
+
}
|
|
2913
|
+
case "accountAttributes": {
|
|
2914
|
+
const a = e.accountAttributes.find(
|
|
2915
|
+
(i) => i.id === r
|
|
2916
|
+
)?.value;
|
|
2917
|
+
a && t.push(a);
|
|
2918
|
+
break;
|
|
2919
|
+
}
|
|
2920
|
+
case "accountTiers": {
|
|
2921
|
+
const a = e.accountTier?.name;
|
|
2922
|
+
a && t.push(a);
|
|
2923
|
+
break;
|
|
2924
|
+
}
|
|
2925
|
+
case "pass": {
|
|
2926
|
+
const a = e.pass[r];
|
|
2927
|
+
a && t.push(a);
|
|
2928
|
+
break;
|
|
2929
|
+
}
|
|
2930
|
+
case "passResponses": {
|
|
2931
|
+
const a = e.passResponses.find(
|
|
2932
|
+
(i) => i.name === r
|
|
2933
|
+
)?.value;
|
|
2934
|
+
a && t.push(a);
|
|
2935
|
+
break;
|
|
2936
|
+
}
|
|
2937
|
+
case "passAttributes": {
|
|
2938
|
+
const a = e.passAttributes.find(
|
|
2939
|
+
(i) => i.name === r
|
|
2940
|
+
)?.value;
|
|
2941
|
+
a && t.push(a);
|
|
2942
|
+
break;
|
|
2943
|
+
}
|
|
2944
|
+
default:
|
|
2945
|
+
t.push("");
|
|
2946
|
+
break;
|
|
2911
2947
|
}
|
|
2912
|
-
|
|
2948
|
+
return t.length === 0 ? s.hideEmpty ? void 0 : s.defaultValue ?? "" : t.join(" ");
|
|
2949
|
+
}
|
|
2950
|
+
function Wt(s, e) {
|
|
2951
|
+
switch (s.transformation) {
|
|
2952
|
+
case F.None:
|
|
2953
|
+
break;
|
|
2954
|
+
case F.Uppercase:
|
|
2955
|
+
e = e.toUpperCase();
|
|
2956
|
+
break;
|
|
2957
|
+
case F.Lowercase:
|
|
2958
|
+
e = e.toLowerCase();
|
|
2959
|
+
break;
|
|
2960
|
+
case F.Capitalize:
|
|
2961
|
+
e = e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
|
|
2962
|
+
break;
|
|
2913
2963
|
}
|
|
2914
|
-
return s;
|
|
2964
|
+
return s.maxCharacters !== void 0 && (e = e.slice(0, s.maxCharacters)), e;
|
|
2965
|
+
}
|
|
2966
|
+
function qt(s, e) {
|
|
2967
|
+
const t = s.fontOrientation, n = `^A${s.font}${t},${s.fontHeight}`, r = `^FB${s.maxWidth},${s.maxLines},${s.lineSpacing},${s.alignment},${s.hangingIndent}`, a = Yt(s, e);
|
|
2968
|
+
return `^FT${s.x},${s.y}${n}${r}^FD${a}^FS`;
|
|
2969
|
+
}
|
|
2970
|
+
function Yt(s, e) {
|
|
2971
|
+
if (s.verticalAlignment !== $e.End)
|
|
2972
|
+
return e;
|
|
2973
|
+
const t = Ht(s, e), n = Math.max(0, s.maxLines - t);
|
|
2974
|
+
return "\\&".repeat(n) + e;
|
|
2975
|
+
}
|
|
2976
|
+
function Ht(s, e) {
|
|
2977
|
+
const t = e.split("\\&");
|
|
2978
|
+
return Jt(t, s.charsPerLine);
|
|
2915
2979
|
}
|
|
2916
|
-
function
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
|
|
2923
|
-
return s;
|
|
2980
|
+
function Jt(s, e) {
|
|
2981
|
+
if (e <= 0)
|
|
2982
|
+
return s.length;
|
|
2983
|
+
let t = 0;
|
|
2984
|
+
for (const n of s)
|
|
2985
|
+
t += Math.max(1, Math.ceil(n.length / e));
|
|
2986
|
+
return t;
|
|
2924
2987
|
}
|
|
2925
|
-
function
|
|
2926
|
-
const
|
|
2927
|
-
return `^FT${
|
|
2988
|
+
function Qt(s, e) {
|
|
2989
|
+
const t = `^BY${s.barWidth}`, n = `^BC${s.orientation},${s.height},${s.line},${s.lineAbove},${s.checkDigit},N`;
|
|
2990
|
+
return `^FT${s.x},${s.y}${t}${n}^FD>;${e}^FS`;
|
|
2928
2991
|
}
|
|
2929
|
-
function
|
|
2930
|
-
const
|
|
2931
|
-
return `^FT${
|
|
2992
|
+
function Xt(s, e) {
|
|
2993
|
+
const t = `^BQ${s.orientation},${s.model},${s.magnification},${s.errorCorrection},${s.mask}`;
|
|
2994
|
+
return `^FT${s.x},${s.y}${t}^FDQA,${e}^FS`;
|
|
2932
2995
|
}
|
|
2933
2996
|
export {
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2997
|
+
Ct as AllMediaMode,
|
|
2998
|
+
ot as BackfeedAction,
|
|
2999
|
+
At as FontOrientation,
|
|
2937
3000
|
dt as MediaType,
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
|
|
2954
|
-
|
|
2955
|
-
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
|
|
2959
|
-
|
|
2960
|
-
|
|
2961
|
-
|
|
2962
|
-
|
|
2963
|
-
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
|
|
2971
|
-
|
|
2972
|
-
|
|
2973
|
-
|
|
2974
|
-
|
|
3001
|
+
pt as MirrorMode,
|
|
3002
|
+
kt as PostPrintMode,
|
|
3003
|
+
wt as PrepeelMode,
|
|
3004
|
+
yt as PrintDensityAdjustment,
|
|
3005
|
+
ft as PrintOrientation,
|
|
3006
|
+
$t as QRCodeErrorCorrection,
|
|
3007
|
+
vt as ReverseMode,
|
|
3008
|
+
Et as SourceType,
|
|
3009
|
+
Nt as TextAlignment,
|
|
3010
|
+
F as TextTransformation,
|
|
3011
|
+
lt as ThermalMediaType,
|
|
3012
|
+
$e as VerticalAlignment,
|
|
3013
|
+
Zt as YesNo,
|
|
3014
|
+
St as allMediaModeSchema,
|
|
3015
|
+
Yt as applyVerticalAlignment,
|
|
3016
|
+
ct as backfeedActionSchema,
|
|
3017
|
+
Re as badgeSchema,
|
|
3018
|
+
Pt as barcodeFieldSchema,
|
|
3019
|
+
Ht as countLines,
|
|
3020
|
+
Dt as fieldSchema,
|
|
3021
|
+
Oe as fontOrientationSchema,
|
|
3022
|
+
ts as generate,
|
|
3023
|
+
Ut as getFieldValue,
|
|
3024
|
+
ut as mediaTypeSchema,
|
|
3025
|
+
gt as mirrorModeSchema,
|
|
3026
|
+
bt as postPrintModeSchema,
|
|
3027
|
+
Tt as prepeelModeSchema,
|
|
3028
|
+
_t as printDensityAdjustmentSchema,
|
|
3029
|
+
mt as printOrientationSchema,
|
|
3030
|
+
Rt as qrCodeErrorCorrectionSchema,
|
|
3031
|
+
Vt as qrcodeFieldSchema,
|
|
3032
|
+
xt as reverseModeSchema,
|
|
3033
|
+
It as sourceTypeSchema,
|
|
3034
|
+
Ot as textAlignmentSchema,
|
|
3035
|
+
Lt as textFieldSchema,
|
|
3036
|
+
Mt as textTransformationSchema,
|
|
3037
|
+
ht as thermalMediaTypeSchema,
|
|
3038
|
+
Kt as validateBadge,
|
|
3039
|
+
es as validateBadgeOrThrow,
|
|
3040
|
+
jt as verticalAlignmentSchema,
|
|
3041
|
+
Gt as wordWidthSchema,
|
|
3042
|
+
re as yesNoSchema
|
|
2975
3043
|
};
|