@animaapp/anima-sdk 0.2.8 → 0.3.0
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/.turbo/turbo-build.log +4 -4
- package/.turbo/turbo-dev.log +0 -0
- package/.turbo/turbo-test.log +21 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +17 -4
- package/dist/index.js +734 -718
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
- package/src/anima.ts +35 -13
- package/src/dataStream.ts +26 -11
- package/src/errors.ts +31 -5
- package/src/utils/figma.spec.ts +31 -0
- package/src/utils/figma.ts +6 -0
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
var fn = Object.defineProperty, hn = Object.defineProperties;
|
|
2
2
|
var pn = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var
|
|
3
|
+
var Nt = Object.getOwnPropertySymbols;
|
|
4
4
|
var mn = Object.prototype.hasOwnProperty, yn = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var
|
|
5
|
+
var Rt = (n) => {
|
|
6
6
|
throw TypeError(n);
|
|
7
7
|
};
|
|
8
|
-
var
|
|
8
|
+
var Zt = (n, e, t) => e in n ? fn(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, u = (n, e) => {
|
|
9
9
|
for (var t in e || (e = {}))
|
|
10
|
-
mn.call(e, t) &&
|
|
11
|
-
if (
|
|
12
|
-
for (var t of
|
|
13
|
-
yn.call(e, t) &&
|
|
10
|
+
mn.call(e, t) && Zt(n, t, e[t]);
|
|
11
|
+
if (Nt)
|
|
12
|
+
for (var t of Nt(e))
|
|
13
|
+
yn.call(e, t) && Zt(n, t, e[t]);
|
|
14
14
|
return n;
|
|
15
15
|
}, y = (n, e) => hn(n, pn(e));
|
|
16
|
-
var Mt = (n, e, t) => e.has(n) ||
|
|
17
|
-
var
|
|
18
|
-
var
|
|
16
|
+
var Mt = (n, e, t) => e.has(n) || Rt("Cannot " + t);
|
|
17
|
+
var H = (n, e, t) => (Mt(n, e, "read from private field"), t ? t.call(n) : e.get(n)), ut = (n, e, t) => e.has(n) ? Rt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), dt = (n, e, t, s) => (Mt(n, e, "write to private field"), s ? s.call(n, t) : e.set(n, t), t);
|
|
18
|
+
var F = (n, e, t) => new Promise((s, r) => {
|
|
19
19
|
var a = (c) => {
|
|
20
20
|
try {
|
|
21
21
|
o(t.next(c));
|
|
@@ -31,12 +31,17 @@ var P = (n, e, t) => new Promise((s, r) => {
|
|
|
31
31
|
}, o = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(a, i);
|
|
32
32
|
o((t = t.apply(n, e)).next());
|
|
33
33
|
});
|
|
34
|
-
class
|
|
35
|
-
constructor({
|
|
36
|
-
|
|
34
|
+
class de extends Error {
|
|
35
|
+
constructor({
|
|
36
|
+
name: e,
|
|
37
|
+
reason: t,
|
|
38
|
+
status: s,
|
|
39
|
+
detail: r
|
|
40
|
+
}) {
|
|
41
|
+
super(), this.name = e, this.message = t, this.detail = r, this.status = s;
|
|
37
42
|
}
|
|
38
43
|
}
|
|
39
|
-
var
|
|
44
|
+
var x;
|
|
40
45
|
(function(n) {
|
|
41
46
|
n.assertEqual = (r) => r;
|
|
42
47
|
function e(r) {
|
|
@@ -71,12 +76,12 @@ var k;
|
|
|
71
76
|
return r.map((i) => typeof i == "string" ? `'${i}'` : i).join(a);
|
|
72
77
|
}
|
|
73
78
|
n.joinValues = s, n.jsonStringifyReplacer = (r, a) => typeof a == "bigint" ? a.toString() : a;
|
|
74
|
-
})(
|
|
75
|
-
var
|
|
79
|
+
})(x || (x = {}));
|
|
80
|
+
var mt;
|
|
76
81
|
(function(n) {
|
|
77
82
|
n.mergeShapes = (e, t) => u(u({}, e), t);
|
|
78
|
-
})(
|
|
79
|
-
const p =
|
|
83
|
+
})(mt || (mt = {}));
|
|
84
|
+
const p = x.arrayToEnum([
|
|
80
85
|
"string",
|
|
81
86
|
"nan",
|
|
82
87
|
"number",
|
|
@@ -97,7 +102,7 @@ const p = k.arrayToEnum([
|
|
|
97
102
|
"never",
|
|
98
103
|
"map",
|
|
99
104
|
"set"
|
|
100
|
-
]),
|
|
105
|
+
]), ie = (n) => {
|
|
101
106
|
switch (typeof n) {
|
|
102
107
|
case "undefined":
|
|
103
108
|
return p.undefined;
|
|
@@ -118,7 +123,7 @@ const p = k.arrayToEnum([
|
|
|
118
123
|
default:
|
|
119
124
|
return p.unknown;
|
|
120
125
|
}
|
|
121
|
-
}, l =
|
|
126
|
+
}, l = x.arrayToEnum([
|
|
122
127
|
"invalid_type",
|
|
123
128
|
"invalid_literal",
|
|
124
129
|
"custom",
|
|
@@ -136,7 +141,7 @@ const p = k.arrayToEnum([
|
|
|
136
141
|
"not_multiple_of",
|
|
137
142
|
"not_finite"
|
|
138
143
|
]), gn = (n) => JSON.stringify(n, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
139
|
-
class
|
|
144
|
+
class z extends Error {
|
|
140
145
|
get errors() {
|
|
141
146
|
return this.issues;
|
|
142
147
|
}
|
|
@@ -173,14 +178,14 @@ class U extends Error {
|
|
|
173
178
|
return r(this), s;
|
|
174
179
|
}
|
|
175
180
|
static assert(e) {
|
|
176
|
-
if (!(e instanceof
|
|
181
|
+
if (!(e instanceof z))
|
|
177
182
|
throw new Error(`Not a ZodError: ${e}`);
|
|
178
183
|
}
|
|
179
184
|
toString() {
|
|
180
185
|
return this.message;
|
|
181
186
|
}
|
|
182
187
|
get message() {
|
|
183
|
-
return JSON.stringify(this.issues,
|
|
188
|
+
return JSON.stringify(this.issues, x.jsonStringifyReplacer, 2);
|
|
184
189
|
}
|
|
185
190
|
get isEmpty() {
|
|
186
191
|
return this.issues.length === 0;
|
|
@@ -195,27 +200,27 @@ class U extends Error {
|
|
|
195
200
|
return this.flatten();
|
|
196
201
|
}
|
|
197
202
|
}
|
|
198
|
-
|
|
199
|
-
const
|
|
203
|
+
z.create = (n) => new z(n);
|
|
204
|
+
const Ae = (n, e) => {
|
|
200
205
|
let t;
|
|
201
206
|
switch (n.code) {
|
|
202
207
|
case l.invalid_type:
|
|
203
208
|
n.received === p.undefined ? t = "Required" : t = `Expected ${n.expected}, received ${n.received}`;
|
|
204
209
|
break;
|
|
205
210
|
case l.invalid_literal:
|
|
206
|
-
t = `Invalid literal value, expected ${JSON.stringify(n.expected,
|
|
211
|
+
t = `Invalid literal value, expected ${JSON.stringify(n.expected, x.jsonStringifyReplacer)}`;
|
|
207
212
|
break;
|
|
208
213
|
case l.unrecognized_keys:
|
|
209
|
-
t = `Unrecognized key(s) in object: ${
|
|
214
|
+
t = `Unrecognized key(s) in object: ${x.joinValues(n.keys, ", ")}`;
|
|
210
215
|
break;
|
|
211
216
|
case l.invalid_union:
|
|
212
217
|
t = "Invalid input";
|
|
213
218
|
break;
|
|
214
219
|
case l.invalid_union_discriminator:
|
|
215
|
-
t = `Invalid discriminator value. Expected ${
|
|
220
|
+
t = `Invalid discriminator value. Expected ${x.joinValues(n.options)}`;
|
|
216
221
|
break;
|
|
217
222
|
case l.invalid_enum_value:
|
|
218
|
-
t = `Invalid enum value. Expected ${
|
|
223
|
+
t = `Invalid enum value. Expected ${x.joinValues(n.options)}, received '${n.received}'`;
|
|
219
224
|
break;
|
|
220
225
|
case l.invalid_arguments:
|
|
221
226
|
t = "Invalid function arguments";
|
|
@@ -227,7 +232,7 @@ const ke = (n, e) => {
|
|
|
227
232
|
t = "Invalid date";
|
|
228
233
|
break;
|
|
229
234
|
case l.invalid_string:
|
|
230
|
-
typeof n.validation == "object" ? "includes" in n.validation ? (t = `Invalid input: must include "${n.validation.includes}"`, typeof n.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${n.validation.position}`)) : "startsWith" in n.validation ? t = `Invalid input: must start with "${n.validation.startsWith}"` : "endsWith" in n.validation ? t = `Invalid input: must end with "${n.validation.endsWith}"` :
|
|
235
|
+
typeof n.validation == "object" ? "includes" in n.validation ? (t = `Invalid input: must include "${n.validation.includes}"`, typeof n.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${n.validation.position}`)) : "startsWith" in n.validation ? t = `Invalid input: must start with "${n.validation.startsWith}"` : "endsWith" in n.validation ? t = `Invalid input: must end with "${n.validation.endsWith}"` : x.assertNever(n.validation) : n.validation !== "regex" ? t = `Invalid ${n.validation}` : t = "Invalid";
|
|
231
236
|
break;
|
|
232
237
|
case l.too_small:
|
|
233
238
|
n.type === "array" ? t = `Array must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "more than"} ${n.minimum} element(s)` : n.type === "string" ? t = `String must contain ${n.exact ? "exactly" : n.inclusive ? "at least" : "over"} ${n.minimum} character(s)` : n.type === "number" ? t = `Number must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${n.minimum}` : n.type === "date" ? t = `Date must be ${n.exact ? "exactly equal to " : n.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(n.minimum))}` : t = "Invalid input";
|
|
@@ -248,18 +253,18 @@ const ke = (n, e) => {
|
|
|
248
253
|
t = "Number must be finite";
|
|
249
254
|
break;
|
|
250
255
|
default:
|
|
251
|
-
t = e.defaultError,
|
|
256
|
+
t = e.defaultError, x.assertNever(n);
|
|
252
257
|
}
|
|
253
258
|
return { message: t };
|
|
254
259
|
};
|
|
255
|
-
let qt =
|
|
260
|
+
let qt = Ae;
|
|
256
261
|
function vn(n) {
|
|
257
262
|
qt = n;
|
|
258
263
|
}
|
|
259
|
-
function
|
|
264
|
+
function et() {
|
|
260
265
|
return qt;
|
|
261
266
|
}
|
|
262
|
-
const
|
|
267
|
+
const tt = (n) => {
|
|
263
268
|
const { data: e, path: t, errorMaps: s, issueData: r } = n, a = [...t, ...r.path || []], i = y(u({}, r), {
|
|
264
269
|
path: a
|
|
265
270
|
});
|
|
@@ -278,7 +283,7 @@ const et = (n) => {
|
|
|
278
283
|
});
|
|
279
284
|
}, _n = [];
|
|
280
285
|
function h(n, e) {
|
|
281
|
-
const t =
|
|
286
|
+
const t = et(), s = tt({
|
|
282
287
|
issueData: e,
|
|
283
288
|
data: n.data,
|
|
284
289
|
path: n.path,
|
|
@@ -289,13 +294,13 @@ function h(n, e) {
|
|
|
289
294
|
// then schema-bound map if available
|
|
290
295
|
t,
|
|
291
296
|
// then global override map
|
|
292
|
-
t ===
|
|
297
|
+
t === Ae ? void 0 : Ae
|
|
293
298
|
// then global default map
|
|
294
299
|
].filter((r) => !!r)
|
|
295
300
|
});
|
|
296
301
|
n.common.issues.push(s);
|
|
297
302
|
}
|
|
298
|
-
class
|
|
303
|
+
class Z {
|
|
299
304
|
constructor() {
|
|
300
305
|
this.value = "valid";
|
|
301
306
|
}
|
|
@@ -315,7 +320,7 @@ class R {
|
|
|
315
320
|
return { status: e.value, value: s };
|
|
316
321
|
}
|
|
317
322
|
static mergeObjectAsync(e, t) {
|
|
318
|
-
return
|
|
323
|
+
return F(this, null, function* () {
|
|
319
324
|
const s = [];
|
|
320
325
|
for (const r of t) {
|
|
321
326
|
const a = yield r.key, i = yield r.value;
|
|
@@ -324,7 +329,7 @@ class R {
|
|
|
324
329
|
value: i
|
|
325
330
|
});
|
|
326
331
|
}
|
|
327
|
-
return
|
|
332
|
+
return Z.mergeObjectSync(e, s);
|
|
328
333
|
});
|
|
329
334
|
}
|
|
330
335
|
static mergeObjectSync(e, t) {
|
|
@@ -340,8 +345,8 @@ class R {
|
|
|
340
345
|
}
|
|
341
346
|
const v = Object.freeze({
|
|
342
347
|
status: "aborted"
|
|
343
|
-
}),
|
|
344
|
-
function
|
|
348
|
+
}), Te = (n) => ({ status: "dirty", value: n }), P = (n) => ({ status: "valid", value: n }), yt = (n) => n.status === "aborted", gt = (n) => n.status === "dirty", be = (n) => n.status === "valid", Pe = (n) => typeof Promise != "undefined" && n instanceof Promise;
|
|
349
|
+
function nt(n, e, t, s) {
|
|
345
350
|
if (typeof e == "function" ? n !== e || !0 : !e.has(n)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
346
351
|
return e.get(n);
|
|
347
352
|
}
|
|
@@ -353,8 +358,8 @@ var m;
|
|
|
353
358
|
(function(n) {
|
|
354
359
|
n.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, n.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
355
360
|
})(m || (m = {}));
|
|
356
|
-
var
|
|
357
|
-
class
|
|
361
|
+
var je, Ne;
|
|
362
|
+
class te {
|
|
358
363
|
constructor(e, t, s, r) {
|
|
359
364
|
this._cachedPath = [], this.parent = e, this.data = t, this._path = s, this._key = r;
|
|
360
365
|
}
|
|
@@ -362,8 +367,8 @@ class Q {
|
|
|
362
367
|
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
363
368
|
}
|
|
364
369
|
}
|
|
365
|
-
const
|
|
366
|
-
if (
|
|
370
|
+
const Pt = (n, e) => {
|
|
371
|
+
if (be(e))
|
|
367
372
|
return { success: !0, data: e.value };
|
|
368
373
|
if (!n.common.issues.length)
|
|
369
374
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -372,12 +377,12 @@ const $t = (n, e) => {
|
|
|
372
377
|
get error() {
|
|
373
378
|
if (this._error)
|
|
374
379
|
return this._error;
|
|
375
|
-
const t = new
|
|
380
|
+
const t = new z(n.common.issues);
|
|
376
381
|
return this._error = t, this._error;
|
|
377
382
|
}
|
|
378
383
|
};
|
|
379
384
|
};
|
|
380
|
-
function
|
|
385
|
+
function b(n) {
|
|
381
386
|
if (!n)
|
|
382
387
|
return {};
|
|
383
388
|
const { errorMap: e, invalid_type_error: t, required_error: s, description: r } = n;
|
|
@@ -389,18 +394,18 @@ function w(n) {
|
|
|
389
394
|
return i.code === "invalid_enum_value" ? { message: f != null ? f : o.defaultError } : typeof o.data == "undefined" ? { message: (c = f != null ? f : s) !== null && c !== void 0 ? c : o.defaultError } : i.code !== "invalid_type" ? { message: o.defaultError } : { message: (d = f != null ? f : t) !== null && d !== void 0 ? d : o.defaultError };
|
|
390
395
|
}, description: r };
|
|
391
396
|
}
|
|
392
|
-
class
|
|
397
|
+
class w {
|
|
393
398
|
get description() {
|
|
394
399
|
return this._def.description;
|
|
395
400
|
}
|
|
396
401
|
_getType(e) {
|
|
397
|
-
return
|
|
402
|
+
return ie(e.data);
|
|
398
403
|
}
|
|
399
404
|
_getOrReturnCtx(e, t) {
|
|
400
405
|
return t || {
|
|
401
406
|
common: e.parent.common,
|
|
402
407
|
data: e.data,
|
|
403
|
-
parsedType:
|
|
408
|
+
parsedType: ie(e.data),
|
|
404
409
|
schemaErrorMap: this._def.errorMap,
|
|
405
410
|
path: e.path,
|
|
406
411
|
parent: e.parent
|
|
@@ -408,11 +413,11 @@ class x {
|
|
|
408
413
|
}
|
|
409
414
|
_processInputParams(e) {
|
|
410
415
|
return {
|
|
411
|
-
status: new
|
|
416
|
+
status: new Z(),
|
|
412
417
|
ctx: {
|
|
413
418
|
common: e.parent.common,
|
|
414
419
|
data: e.data,
|
|
415
|
-
parsedType:
|
|
420
|
+
parsedType: ie(e.data),
|
|
416
421
|
schemaErrorMap: this._def.errorMap,
|
|
417
422
|
path: e.path,
|
|
418
423
|
parent: e.parent
|
|
@@ -421,7 +426,7 @@ class x {
|
|
|
421
426
|
}
|
|
422
427
|
_parseSync(e) {
|
|
423
428
|
const t = this._parse(e);
|
|
424
|
-
if (
|
|
429
|
+
if (Pe(t))
|
|
425
430
|
throw new Error("Synchronous parse encountered promise.");
|
|
426
431
|
return t;
|
|
427
432
|
}
|
|
@@ -447,9 +452,9 @@ class x {
|
|
|
447
452
|
schemaErrorMap: this._def.errorMap,
|
|
448
453
|
parent: null,
|
|
449
454
|
data: e,
|
|
450
|
-
parsedType:
|
|
455
|
+
parsedType: ie(e)
|
|
451
456
|
}, a = this._parseSync({ data: e, path: r.path, parent: r });
|
|
452
|
-
return
|
|
457
|
+
return Pt(r, a);
|
|
453
458
|
}
|
|
454
459
|
"~validate"(e) {
|
|
455
460
|
var t, s;
|
|
@@ -462,12 +467,12 @@ class x {
|
|
|
462
467
|
schemaErrorMap: this._def.errorMap,
|
|
463
468
|
parent: null,
|
|
464
469
|
data: e,
|
|
465
|
-
parsedType:
|
|
470
|
+
parsedType: ie(e)
|
|
466
471
|
};
|
|
467
472
|
if (!this["~standard"].async)
|
|
468
473
|
try {
|
|
469
474
|
const a = this._parseSync({ data: e, path: [], parent: r });
|
|
470
|
-
return
|
|
475
|
+
return be(a) ? {
|
|
471
476
|
value: a.value
|
|
472
477
|
} : {
|
|
473
478
|
issues: r.common.issues
|
|
@@ -478,14 +483,14 @@ class x {
|
|
|
478
483
|
async: !0
|
|
479
484
|
};
|
|
480
485
|
}
|
|
481
|
-
return this._parseAsync({ data: e, path: [], parent: r }).then((a) =>
|
|
486
|
+
return this._parseAsync({ data: e, path: [], parent: r }).then((a) => be(a) ? {
|
|
482
487
|
value: a.value
|
|
483
488
|
} : {
|
|
484
489
|
issues: r.common.issues
|
|
485
490
|
});
|
|
486
491
|
}
|
|
487
492
|
parseAsync(e, t) {
|
|
488
|
-
return
|
|
493
|
+
return F(this, null, function* () {
|
|
489
494
|
const s = yield this.safeParseAsync(e, t);
|
|
490
495
|
if (s.success)
|
|
491
496
|
return s.data;
|
|
@@ -493,7 +498,7 @@ class x {
|
|
|
493
498
|
});
|
|
494
499
|
}
|
|
495
500
|
safeParseAsync(e, t) {
|
|
496
|
-
return
|
|
501
|
+
return F(this, null, function* () {
|
|
497
502
|
const s = {
|
|
498
503
|
common: {
|
|
499
504
|
issues: [],
|
|
@@ -504,9 +509,9 @@ class x {
|
|
|
504
509
|
schemaErrorMap: this._def.errorMap,
|
|
505
510
|
parent: null,
|
|
506
511
|
data: e,
|
|
507
|
-
parsedType:
|
|
508
|
-
}, r = this._parse({ data: e, path: s.path, parent: s }), a = yield
|
|
509
|
-
return
|
|
512
|
+
parsedType: ie(e)
|
|
513
|
+
}, r = this._parse({ data: e, path: s.path, parent: s }), a = yield Pe(r) ? r : Promise.resolve(r);
|
|
514
|
+
return Pt(s, a);
|
|
510
515
|
});
|
|
511
516
|
}
|
|
512
517
|
refine(e, t) {
|
|
@@ -522,7 +527,7 @@ class x {
|
|
|
522
527
|
return this._refinement((s, r) => e(s) ? !0 : (r.addIssue(typeof t == "function" ? t(s, r) : t), !1));
|
|
523
528
|
}
|
|
524
529
|
_refinement(e) {
|
|
525
|
-
return new
|
|
530
|
+
return new G({
|
|
526
531
|
schema: this,
|
|
527
532
|
typeName: g.ZodEffects,
|
|
528
533
|
effect: { type: "refinement", refinement: e }
|
|
@@ -539,28 +544,28 @@ class x {
|
|
|
539
544
|
};
|
|
540
545
|
}
|
|
541
546
|
optional() {
|
|
542
|
-
return
|
|
547
|
+
return ee.create(this, this._def);
|
|
543
548
|
}
|
|
544
549
|
nullable() {
|
|
545
|
-
return
|
|
550
|
+
return me.create(this, this._def);
|
|
546
551
|
}
|
|
547
552
|
nullish() {
|
|
548
553
|
return this.nullable().optional();
|
|
549
554
|
}
|
|
550
555
|
array() {
|
|
551
|
-
return
|
|
556
|
+
return K.create(this);
|
|
552
557
|
}
|
|
553
558
|
promise() {
|
|
554
|
-
return
|
|
559
|
+
return Oe.create(this, this._def);
|
|
555
560
|
}
|
|
556
561
|
or(e) {
|
|
557
|
-
return
|
|
562
|
+
return Le.create([this, e], this._def);
|
|
558
563
|
}
|
|
559
564
|
and(e) {
|
|
560
|
-
return
|
|
565
|
+
return Ve.create(this, e, this._def);
|
|
561
566
|
}
|
|
562
567
|
transform(e) {
|
|
563
|
-
return new
|
|
568
|
+
return new G(y(u({}, b(this._def)), {
|
|
564
569
|
schema: this,
|
|
565
570
|
typeName: g.ZodEffects,
|
|
566
571
|
effect: { type: "transform", transform: e }
|
|
@@ -568,21 +573,21 @@ class x {
|
|
|
568
573
|
}
|
|
569
574
|
default(e) {
|
|
570
575
|
const t = typeof e == "function" ? e : () => e;
|
|
571
|
-
return new
|
|
576
|
+
return new qe(y(u({}, b(this._def)), {
|
|
572
577
|
innerType: this,
|
|
573
578
|
defaultValue: t,
|
|
574
579
|
typeName: g.ZodDefault
|
|
575
580
|
}));
|
|
576
581
|
}
|
|
577
582
|
brand() {
|
|
578
|
-
return new
|
|
583
|
+
return new Ot(u({
|
|
579
584
|
typeName: g.ZodBranded,
|
|
580
585
|
type: this
|
|
581
|
-
},
|
|
586
|
+
}, b(this._def)));
|
|
582
587
|
}
|
|
583
588
|
catch(e) {
|
|
584
589
|
const t = typeof e == "function" ? e : () => e;
|
|
585
|
-
return new
|
|
590
|
+
return new He(y(u({}, b(this._def)), {
|
|
586
591
|
innerType: this,
|
|
587
592
|
catchValue: t,
|
|
588
593
|
typeName: g.ZodCatch
|
|
@@ -595,10 +600,10 @@ class x {
|
|
|
595
600
|
}));
|
|
596
601
|
}
|
|
597
602
|
pipe(e) {
|
|
598
|
-
return
|
|
603
|
+
return Ge.create(this, e);
|
|
599
604
|
}
|
|
600
605
|
readonly() {
|
|
601
|
-
return
|
|
606
|
+
return Je.create(this);
|
|
602
607
|
}
|
|
603
608
|
isOptional() {
|
|
604
609
|
return this.safeParse(void 0).success;
|
|
@@ -607,23 +612,23 @@ class x {
|
|
|
607
612
|
return this.safeParse(null).success;
|
|
608
613
|
}
|
|
609
614
|
}
|
|
610
|
-
const bn = /^c[^\s-]{8,}$/i, wn = /^[0-9a-z]+$/, xn = /^[0-9A-HJKMNP-TV-Z]{26}$/i, kn = /^[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, Tn = /^[a-z0-9_-]{21}$/i, Sn = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,
|
|
611
|
-
let
|
|
612
|
-
const Cn = /^(?:(?: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])$/, In = /^(?:(?: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])$/,
|
|
613
|
-
function
|
|
615
|
+
const bn = /^c[^\s-]{8,}$/i, wn = /^[0-9a-z]+$/, xn = /^[0-9A-HJKMNP-TV-Z]{26}$/i, kn = /^[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, Tn = /^[a-z0-9_-]{21}$/i, Sn = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, An = /^[-+]?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)?)??$/, En = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, On = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
616
|
+
let lt;
|
|
617
|
+
const Cn = /^(?:(?: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])$/, In = /^(?:(?: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])$/, jn = /^(([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]))$/, Nn = /^(([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])$/, Zn = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Rn = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Jt = "((\\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])))", Mn = new RegExp(`^${Jt}$`);
|
|
618
|
+
function Kt(n) {
|
|
614
619
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
615
620
|
return n.precision ? e = `${e}\\.\\d{${n.precision}}` : n.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
616
621
|
}
|
|
617
|
-
function
|
|
618
|
-
return new RegExp(`^${
|
|
622
|
+
function Pn(n) {
|
|
623
|
+
return new RegExp(`^${Kt(n)}$`);
|
|
619
624
|
}
|
|
620
|
-
function
|
|
621
|
-
let e = `${Jt}T${
|
|
625
|
+
function Gt(n) {
|
|
626
|
+
let e = `${Jt}T${Kt(n)}`;
|
|
622
627
|
const t = [];
|
|
623
628
|
return t.push(n.local ? "Z?" : "Z"), n.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
624
629
|
}
|
|
625
|
-
function
|
|
626
|
-
return !!((e === "v4" || !e) && Cn.test(n) || (e === "v6" || !e) &&
|
|
630
|
+
function $n(n, e) {
|
|
631
|
+
return !!((e === "v4" || !e) && Cn.test(n) || (e === "v6" || !e) && jn.test(n));
|
|
627
632
|
}
|
|
628
633
|
function Fn(n, e) {
|
|
629
634
|
if (!Sn.test(n))
|
|
@@ -635,10 +640,10 @@ function Fn(n, e) {
|
|
|
635
640
|
return !1;
|
|
636
641
|
}
|
|
637
642
|
}
|
|
638
|
-
function
|
|
639
|
-
return !!((e === "v4" || !e) && In.test(n) || (e === "v6" || !e) &&
|
|
643
|
+
function Dn(n, e) {
|
|
644
|
+
return !!((e === "v4" || !e) && In.test(n) || (e === "v6" || !e) && Nn.test(n));
|
|
640
645
|
}
|
|
641
|
-
class
|
|
646
|
+
class J extends w {
|
|
642
647
|
_parse(e) {
|
|
643
648
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== p.string) {
|
|
644
649
|
const a = this._getOrReturnCtx(e);
|
|
@@ -648,7 +653,7 @@ class q extends x {
|
|
|
648
653
|
received: a.parsedType
|
|
649
654
|
}), v;
|
|
650
655
|
}
|
|
651
|
-
const s = new
|
|
656
|
+
const s = new Z();
|
|
652
657
|
let r;
|
|
653
658
|
for (const a of this._def.checks)
|
|
654
659
|
if (a.kind === "min")
|
|
@@ -687,13 +692,13 @@ class q extends x {
|
|
|
687
692
|
message: a.message
|
|
688
693
|
}), s.dirty());
|
|
689
694
|
} else if (a.kind === "email")
|
|
690
|
-
|
|
695
|
+
En.test(e.data) || (r = this._getOrReturnCtx(e, r), h(r, {
|
|
691
696
|
validation: "email",
|
|
692
697
|
code: l.invalid_string,
|
|
693
698
|
message: a.message
|
|
694
699
|
}), s.dirty());
|
|
695
700
|
else if (a.kind === "emoji")
|
|
696
|
-
|
|
701
|
+
lt || (lt = new RegExp(On, "u")), lt.test(e.data) || (r = this._getOrReturnCtx(e, r), h(r, {
|
|
697
702
|
validation: "emoji",
|
|
698
703
|
code: l.invalid_string,
|
|
699
704
|
message: a.message
|
|
@@ -754,7 +759,7 @@ class q extends x {
|
|
|
754
759
|
code: l.invalid_string,
|
|
755
760
|
validation: { endsWith: a.value },
|
|
756
761
|
message: a.message
|
|
757
|
-
}), s.dirty()) : a.kind === "datetime" ?
|
|
762
|
+
}), s.dirty()) : a.kind === "datetime" ? Gt(a).test(e.data) || (r = this._getOrReturnCtx(e, r), h(r, {
|
|
758
763
|
code: l.invalid_string,
|
|
759
764
|
validation: "datetime",
|
|
760
765
|
message: a.message
|
|
@@ -762,15 +767,15 @@ class q extends x {
|
|
|
762
767
|
code: l.invalid_string,
|
|
763
768
|
validation: "date",
|
|
764
769
|
message: a.message
|
|
765
|
-
}), s.dirty()) : a.kind === "time" ?
|
|
770
|
+
}), s.dirty()) : a.kind === "time" ? Pn(a).test(e.data) || (r = this._getOrReturnCtx(e, r), h(r, {
|
|
766
771
|
code: l.invalid_string,
|
|
767
772
|
validation: "time",
|
|
768
773
|
message: a.message
|
|
769
|
-
}), s.dirty()) : a.kind === "duration" ?
|
|
774
|
+
}), s.dirty()) : a.kind === "duration" ? An.test(e.data) || (r = this._getOrReturnCtx(e, r), h(r, {
|
|
770
775
|
validation: "duration",
|
|
771
776
|
code: l.invalid_string,
|
|
772
777
|
message: a.message
|
|
773
|
-
}), s.dirty()) : a.kind === "ip" ?
|
|
778
|
+
}), s.dirty()) : a.kind === "ip" ? $n(e.data, a.version) || (r = this._getOrReturnCtx(e, r), h(r, {
|
|
774
779
|
validation: "ip",
|
|
775
780
|
code: l.invalid_string,
|
|
776
781
|
message: a.message
|
|
@@ -778,19 +783,19 @@ class q extends x {
|
|
|
778
783
|
validation: "jwt",
|
|
779
784
|
code: l.invalid_string,
|
|
780
785
|
message: a.message
|
|
781
|
-
}), s.dirty()) : a.kind === "cidr" ?
|
|
786
|
+
}), s.dirty()) : a.kind === "cidr" ? Dn(e.data, a.version) || (r = this._getOrReturnCtx(e, r), h(r, {
|
|
782
787
|
validation: "cidr",
|
|
783
788
|
code: l.invalid_string,
|
|
784
789
|
message: a.message
|
|
785
|
-
}), s.dirty()) : a.kind === "base64" ?
|
|
790
|
+
}), s.dirty()) : a.kind === "base64" ? Zn.test(e.data) || (r = this._getOrReturnCtx(e, r), h(r, {
|
|
786
791
|
validation: "base64",
|
|
787
792
|
code: l.invalid_string,
|
|
788
793
|
message: a.message
|
|
789
|
-
}), s.dirty()) : a.kind === "base64url" ?
|
|
794
|
+
}), s.dirty()) : a.kind === "base64url" ? Rn.test(e.data) || (r = this._getOrReturnCtx(e, r), h(r, {
|
|
790
795
|
validation: "base64url",
|
|
791
796
|
code: l.invalid_string,
|
|
792
797
|
message: a.message
|
|
793
|
-
}), s.dirty()) :
|
|
798
|
+
}), s.dirty()) : x.assertNever(a);
|
|
794
799
|
return { status: s.value, value: e.data };
|
|
795
800
|
}
|
|
796
801
|
_regex(e, t, s) {
|
|
@@ -800,7 +805,7 @@ class q extends x {
|
|
|
800
805
|
}, m.errToObj(s)));
|
|
801
806
|
}
|
|
802
807
|
_addCheck(e) {
|
|
803
|
-
return new
|
|
808
|
+
return new J(y(u({}, this._def), {
|
|
804
809
|
checks: [...this._def.checks, e]
|
|
805
810
|
}));
|
|
806
811
|
}
|
|
@@ -926,17 +931,17 @@ class q extends x {
|
|
|
926
931
|
return this.min(1, m.errToObj(e));
|
|
927
932
|
}
|
|
928
933
|
trim() {
|
|
929
|
-
return new
|
|
934
|
+
return new J(y(u({}, this._def), {
|
|
930
935
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
931
936
|
}));
|
|
932
937
|
}
|
|
933
938
|
toLowerCase() {
|
|
934
|
-
return new
|
|
939
|
+
return new J(y(u({}, this._def), {
|
|
935
940
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
936
941
|
}));
|
|
937
942
|
}
|
|
938
943
|
toUpperCase() {
|
|
939
|
-
return new
|
|
944
|
+
return new J(y(u({}, this._def), {
|
|
940
945
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
941
946
|
}));
|
|
942
947
|
}
|
|
@@ -1001,19 +1006,19 @@ class q extends x {
|
|
|
1001
1006
|
return e;
|
|
1002
1007
|
}
|
|
1003
1008
|
}
|
|
1004
|
-
|
|
1009
|
+
J.create = (n) => {
|
|
1005
1010
|
var e;
|
|
1006
|
-
return new
|
|
1011
|
+
return new J(u({
|
|
1007
1012
|
checks: [],
|
|
1008
1013
|
typeName: g.ZodString,
|
|
1009
1014
|
coerce: (e = n == null ? void 0 : n.coerce) !== null && e !== void 0 ? e : !1
|
|
1010
|
-
},
|
|
1015
|
+
}, b(n)));
|
|
1011
1016
|
};
|
|
1012
|
-
function
|
|
1017
|
+
function Ln(n, e) {
|
|
1013
1018
|
const t = (n.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, r = t > s ? t : s, a = parseInt(n.toFixed(r).replace(".", "")), i = parseInt(e.toFixed(r).replace(".", ""));
|
|
1014
1019
|
return a % i / Math.pow(10, r);
|
|
1015
1020
|
}
|
|
1016
|
-
class
|
|
1021
|
+
class fe extends w {
|
|
1017
1022
|
constructor() {
|
|
1018
1023
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1019
1024
|
}
|
|
@@ -1027,9 +1032,9 @@ class ue extends x {
|
|
|
1027
1032
|
}), v;
|
|
1028
1033
|
}
|
|
1029
1034
|
let s;
|
|
1030
|
-
const r = new
|
|
1035
|
+
const r = new Z();
|
|
1031
1036
|
for (const a of this._def.checks)
|
|
1032
|
-
a.kind === "int" ?
|
|
1037
|
+
a.kind === "int" ? x.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), h(s, {
|
|
1033
1038
|
code: l.invalid_type,
|
|
1034
1039
|
expected: "integer",
|
|
1035
1040
|
received: "float",
|
|
@@ -1048,14 +1053,14 @@ class ue extends x {
|
|
|
1048
1053
|
inclusive: a.inclusive,
|
|
1049
1054
|
exact: !1,
|
|
1050
1055
|
message: a.message
|
|
1051
|
-
}), r.dirty()) : a.kind === "multipleOf" ?
|
|
1056
|
+
}), r.dirty()) : a.kind === "multipleOf" ? Ln(e.data, a.value) !== 0 && (s = this._getOrReturnCtx(e, s), h(s, {
|
|
1052
1057
|
code: l.not_multiple_of,
|
|
1053
1058
|
multipleOf: a.value,
|
|
1054
1059
|
message: a.message
|
|
1055
1060
|
}), r.dirty()) : a.kind === "finite" ? Number.isFinite(e.data) || (s = this._getOrReturnCtx(e, s), h(s, {
|
|
1056
1061
|
code: l.not_finite,
|
|
1057
1062
|
message: a.message
|
|
1058
|
-
}), r.dirty()) :
|
|
1063
|
+
}), r.dirty()) : x.assertNever(a);
|
|
1059
1064
|
return { status: r.value, value: e.data };
|
|
1060
1065
|
}
|
|
1061
1066
|
gte(e, t) {
|
|
@@ -1071,7 +1076,7 @@ class ue extends x {
|
|
|
1071
1076
|
return this.setLimit("max", e, !1, m.toString(t));
|
|
1072
1077
|
}
|
|
1073
1078
|
setLimit(e, t, s, r) {
|
|
1074
|
-
return new
|
|
1079
|
+
return new fe(y(u({}, this._def), {
|
|
1075
1080
|
checks: [
|
|
1076
1081
|
...this._def.checks,
|
|
1077
1082
|
{
|
|
@@ -1084,7 +1089,7 @@ class ue extends x {
|
|
|
1084
1089
|
}));
|
|
1085
1090
|
}
|
|
1086
1091
|
_addCheck(e) {
|
|
1087
|
-
return new
|
|
1092
|
+
return new fe(y(u({}, this._def), {
|
|
1088
1093
|
checks: [...this._def.checks, e]
|
|
1089
1094
|
}));
|
|
1090
1095
|
}
|
|
@@ -1165,7 +1170,7 @@ class ue extends x {
|
|
|
1165
1170
|
return e;
|
|
1166
1171
|
}
|
|
1167
1172
|
get isInt() {
|
|
1168
|
-
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" &&
|
|
1173
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && x.isInteger(e.value));
|
|
1169
1174
|
}
|
|
1170
1175
|
get isFinite() {
|
|
1171
1176
|
let e = null, t = null;
|
|
@@ -1177,12 +1182,12 @@ class ue extends x {
|
|
|
1177
1182
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
1178
1183
|
}
|
|
1179
1184
|
}
|
|
1180
|
-
|
|
1185
|
+
fe.create = (n) => new fe(u({
|
|
1181
1186
|
checks: [],
|
|
1182
1187
|
typeName: g.ZodNumber,
|
|
1183
1188
|
coerce: (n == null ? void 0 : n.coerce) || !1
|
|
1184
|
-
},
|
|
1185
|
-
class
|
|
1189
|
+
}, b(n)));
|
|
1190
|
+
class he extends w {
|
|
1186
1191
|
constructor() {
|
|
1187
1192
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1188
1193
|
}
|
|
@@ -1196,7 +1201,7 @@ class de extends x {
|
|
|
1196
1201
|
if (this._getType(e) !== p.bigint)
|
|
1197
1202
|
return this._getInvalidInput(e);
|
|
1198
1203
|
let s;
|
|
1199
|
-
const r = new
|
|
1204
|
+
const r = new Z();
|
|
1200
1205
|
for (const a of this._def.checks)
|
|
1201
1206
|
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), h(s, {
|
|
1202
1207
|
code: l.too_small,
|
|
@@ -1214,7 +1219,7 @@ class de extends x {
|
|
|
1214
1219
|
code: l.not_multiple_of,
|
|
1215
1220
|
multipleOf: a.value,
|
|
1216
1221
|
message: a.message
|
|
1217
|
-
}), r.dirty()) :
|
|
1222
|
+
}), r.dirty()) : x.assertNever(a);
|
|
1218
1223
|
return { status: r.value, value: e.data };
|
|
1219
1224
|
}
|
|
1220
1225
|
_getInvalidInput(e) {
|
|
@@ -1238,7 +1243,7 @@ class de extends x {
|
|
|
1238
1243
|
return this.setLimit("max", e, !1, m.toString(t));
|
|
1239
1244
|
}
|
|
1240
1245
|
setLimit(e, t, s, r) {
|
|
1241
|
-
return new
|
|
1246
|
+
return new he(y(u({}, this._def), {
|
|
1242
1247
|
checks: [
|
|
1243
1248
|
...this._def.checks,
|
|
1244
1249
|
{
|
|
@@ -1251,7 +1256,7 @@ class de extends x {
|
|
|
1251
1256
|
}));
|
|
1252
1257
|
}
|
|
1253
1258
|
_addCheck(e) {
|
|
1254
|
-
return new
|
|
1259
|
+
return new he(y(u({}, this._def), {
|
|
1255
1260
|
checks: [...this._def.checks, e]
|
|
1256
1261
|
}));
|
|
1257
1262
|
}
|
|
@@ -1307,15 +1312,15 @@ class de extends x {
|
|
|
1307
1312
|
return e;
|
|
1308
1313
|
}
|
|
1309
1314
|
}
|
|
1310
|
-
|
|
1315
|
+
he.create = (n) => {
|
|
1311
1316
|
var e;
|
|
1312
|
-
return new
|
|
1317
|
+
return new he(u({
|
|
1313
1318
|
checks: [],
|
|
1314
1319
|
typeName: g.ZodBigInt,
|
|
1315
1320
|
coerce: (e = n == null ? void 0 : n.coerce) !== null && e !== void 0 ? e : !1
|
|
1316
|
-
},
|
|
1321
|
+
}, b(n)));
|
|
1317
1322
|
};
|
|
1318
|
-
class
|
|
1323
|
+
class $e extends w {
|
|
1319
1324
|
_parse(e) {
|
|
1320
1325
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== p.boolean) {
|
|
1321
1326
|
const s = this._getOrReturnCtx(e);
|
|
@@ -1325,14 +1330,14 @@ class Me extends x {
|
|
|
1325
1330
|
received: s.parsedType
|
|
1326
1331
|
}), v;
|
|
1327
1332
|
}
|
|
1328
|
-
return
|
|
1333
|
+
return P(e.data);
|
|
1329
1334
|
}
|
|
1330
1335
|
}
|
|
1331
|
-
|
|
1336
|
+
$e.create = (n) => new $e(u({
|
|
1332
1337
|
typeName: g.ZodBoolean,
|
|
1333
1338
|
coerce: (n == null ? void 0 : n.coerce) || !1
|
|
1334
|
-
},
|
|
1335
|
-
class
|
|
1339
|
+
}, b(n)));
|
|
1340
|
+
class we extends w {
|
|
1336
1341
|
_parse(e) {
|
|
1337
1342
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== p.date) {
|
|
1338
1343
|
const a = this._getOrReturnCtx(e);
|
|
@@ -1348,7 +1353,7 @@ class ge extends x {
|
|
|
1348
1353
|
code: l.invalid_date
|
|
1349
1354
|
}), v;
|
|
1350
1355
|
}
|
|
1351
|
-
const s = new
|
|
1356
|
+
const s = new Z();
|
|
1352
1357
|
let r;
|
|
1353
1358
|
for (const a of this._def.checks)
|
|
1354
1359
|
a.kind === "min" ? e.data.getTime() < a.value && (r = this._getOrReturnCtx(e, r), h(r, {
|
|
@@ -1365,14 +1370,14 @@ class ge extends x {
|
|
|
1365
1370
|
exact: !1,
|
|
1366
1371
|
maximum: a.value,
|
|
1367
1372
|
type: "date"
|
|
1368
|
-
}), s.dirty()) :
|
|
1373
|
+
}), s.dirty()) : x.assertNever(a);
|
|
1369
1374
|
return {
|
|
1370
1375
|
status: s.value,
|
|
1371
1376
|
value: new Date(e.data.getTime())
|
|
1372
1377
|
};
|
|
1373
1378
|
}
|
|
1374
1379
|
_addCheck(e) {
|
|
1375
|
-
return new
|
|
1380
|
+
return new we(y(u({}, this._def), {
|
|
1376
1381
|
checks: [...this._def.checks, e]
|
|
1377
1382
|
}));
|
|
1378
1383
|
}
|
|
@@ -1403,12 +1408,12 @@ class ge extends x {
|
|
|
1403
1408
|
return e != null ? new Date(e) : null;
|
|
1404
1409
|
}
|
|
1405
1410
|
}
|
|
1406
|
-
|
|
1411
|
+
we.create = (n) => new we(u({
|
|
1407
1412
|
checks: [],
|
|
1408
1413
|
coerce: (n == null ? void 0 : n.coerce) || !1,
|
|
1409
1414
|
typeName: g.ZodDate
|
|
1410
|
-
},
|
|
1411
|
-
class
|
|
1415
|
+
}, b(n)));
|
|
1416
|
+
class st extends w {
|
|
1412
1417
|
_parse(e) {
|
|
1413
1418
|
if (this._getType(e) !== p.symbol) {
|
|
1414
1419
|
const s = this._getOrReturnCtx(e);
|
|
@@ -1418,13 +1423,13 @@ class nt extends x {
|
|
|
1418
1423
|
received: s.parsedType
|
|
1419
1424
|
}), v;
|
|
1420
1425
|
}
|
|
1421
|
-
return
|
|
1426
|
+
return P(e.data);
|
|
1422
1427
|
}
|
|
1423
1428
|
}
|
|
1424
|
-
|
|
1429
|
+
st.create = (n) => new st(u({
|
|
1425
1430
|
typeName: g.ZodSymbol
|
|
1426
|
-
},
|
|
1427
|
-
class
|
|
1431
|
+
}, b(n)));
|
|
1432
|
+
class Fe extends w {
|
|
1428
1433
|
_parse(e) {
|
|
1429
1434
|
if (this._getType(e) !== p.undefined) {
|
|
1430
1435
|
const s = this._getOrReturnCtx(e);
|
|
@@ -1434,13 +1439,13 @@ class $e extends x {
|
|
|
1434
1439
|
received: s.parsedType
|
|
1435
1440
|
}), v;
|
|
1436
1441
|
}
|
|
1437
|
-
return
|
|
1442
|
+
return P(e.data);
|
|
1438
1443
|
}
|
|
1439
1444
|
}
|
|
1440
|
-
|
|
1445
|
+
Fe.create = (n) => new Fe(u({
|
|
1441
1446
|
typeName: g.ZodUndefined
|
|
1442
|
-
},
|
|
1443
|
-
class
|
|
1447
|
+
}, b(n)));
|
|
1448
|
+
class De extends w {
|
|
1444
1449
|
_parse(e) {
|
|
1445
1450
|
if (this._getType(e) !== p.null) {
|
|
1446
1451
|
const s = this._getOrReturnCtx(e);
|
|
@@ -1450,35 +1455,35 @@ class Pe extends x {
|
|
|
1450
1455
|
received: s.parsedType
|
|
1451
1456
|
}), v;
|
|
1452
1457
|
}
|
|
1453
|
-
return
|
|
1458
|
+
return P(e.data);
|
|
1454
1459
|
}
|
|
1455
1460
|
}
|
|
1456
|
-
|
|
1461
|
+
De.create = (n) => new De(u({
|
|
1457
1462
|
typeName: g.ZodNull
|
|
1458
|
-
},
|
|
1459
|
-
class
|
|
1463
|
+
}, b(n)));
|
|
1464
|
+
class Ee extends w {
|
|
1460
1465
|
constructor() {
|
|
1461
1466
|
super(...arguments), this._any = !0;
|
|
1462
1467
|
}
|
|
1463
1468
|
_parse(e) {
|
|
1464
|
-
return
|
|
1469
|
+
return P(e.data);
|
|
1465
1470
|
}
|
|
1466
1471
|
}
|
|
1467
|
-
|
|
1472
|
+
Ee.create = (n) => new Ee(u({
|
|
1468
1473
|
typeName: g.ZodAny
|
|
1469
|
-
},
|
|
1470
|
-
class
|
|
1474
|
+
}, b(n)));
|
|
1475
|
+
class _e extends w {
|
|
1471
1476
|
constructor() {
|
|
1472
1477
|
super(...arguments), this._unknown = !0;
|
|
1473
1478
|
}
|
|
1474
1479
|
_parse(e) {
|
|
1475
|
-
return
|
|
1480
|
+
return P(e.data);
|
|
1476
1481
|
}
|
|
1477
1482
|
}
|
|
1478
|
-
|
|
1483
|
+
_e.create = (n) => new _e(u({
|
|
1479
1484
|
typeName: g.ZodUnknown
|
|
1480
|
-
},
|
|
1481
|
-
class
|
|
1485
|
+
}, b(n)));
|
|
1486
|
+
class oe extends w {
|
|
1482
1487
|
_parse(e) {
|
|
1483
1488
|
const t = this._getOrReturnCtx(e);
|
|
1484
1489
|
return h(t, {
|
|
@@ -1488,10 +1493,10 @@ class ie extends x {
|
|
|
1488
1493
|
}), v;
|
|
1489
1494
|
}
|
|
1490
1495
|
}
|
|
1491
|
-
|
|
1496
|
+
oe.create = (n) => new oe(u({
|
|
1492
1497
|
typeName: g.ZodNever
|
|
1493
|
-
},
|
|
1494
|
-
class
|
|
1498
|
+
}, b(n)));
|
|
1499
|
+
class rt extends w {
|
|
1495
1500
|
_parse(e) {
|
|
1496
1501
|
if (this._getType(e) !== p.undefined) {
|
|
1497
1502
|
const s = this._getOrReturnCtx(e);
|
|
@@ -1501,13 +1506,13 @@ class st extends x {
|
|
|
1501
1506
|
received: s.parsedType
|
|
1502
1507
|
}), v;
|
|
1503
1508
|
}
|
|
1504
|
-
return
|
|
1509
|
+
return P(e.data);
|
|
1505
1510
|
}
|
|
1506
1511
|
}
|
|
1507
|
-
|
|
1512
|
+
rt.create = (n) => new rt(u({
|
|
1508
1513
|
typeName: g.ZodVoid
|
|
1509
|
-
},
|
|
1510
|
-
class
|
|
1514
|
+
}, b(n)));
|
|
1515
|
+
class K extends w {
|
|
1511
1516
|
_parse(e) {
|
|
1512
1517
|
const { ctx: t, status: s } = this._processInputParams(e), r = this._def;
|
|
1513
1518
|
if (t.parsedType !== p.array)
|
|
@@ -1543,25 +1548,25 @@ class H extends x {
|
|
|
1543
1548
|
exact: !1,
|
|
1544
1549
|
message: r.maxLength.message
|
|
1545
1550
|
}), s.dirty()), t.common.async)
|
|
1546
|
-
return Promise.all([...t.data].map((i, o) => r.type._parseAsync(new
|
|
1547
|
-
const a = [...t.data].map((i, o) => r.type._parseSync(new
|
|
1548
|
-
return
|
|
1551
|
+
return Promise.all([...t.data].map((i, o) => r.type._parseAsync(new te(t, i, t.path, o)))).then((i) => Z.mergeArray(s, i));
|
|
1552
|
+
const a = [...t.data].map((i, o) => r.type._parseSync(new te(t, i, t.path, o)));
|
|
1553
|
+
return Z.mergeArray(s, a);
|
|
1549
1554
|
}
|
|
1550
1555
|
get element() {
|
|
1551
1556
|
return this._def.type;
|
|
1552
1557
|
}
|
|
1553
1558
|
min(e, t) {
|
|
1554
|
-
return new
|
|
1559
|
+
return new K(y(u({}, this._def), {
|
|
1555
1560
|
minLength: { value: e, message: m.toString(t) }
|
|
1556
1561
|
}));
|
|
1557
1562
|
}
|
|
1558
1563
|
max(e, t) {
|
|
1559
|
-
return new
|
|
1564
|
+
return new K(y(u({}, this._def), {
|
|
1560
1565
|
maxLength: { value: e, message: m.toString(t) }
|
|
1561
1566
|
}));
|
|
1562
1567
|
}
|
|
1563
1568
|
length(e, t) {
|
|
1564
|
-
return new
|
|
1569
|
+
return new K(y(u({}, this._def), {
|
|
1565
1570
|
exactLength: { value: e, message: m.toString(t) }
|
|
1566
1571
|
}));
|
|
1567
1572
|
}
|
|
@@ -1569,35 +1574,35 @@ class H extends x {
|
|
|
1569
1574
|
return this.min(1, e);
|
|
1570
1575
|
}
|
|
1571
1576
|
}
|
|
1572
|
-
|
|
1577
|
+
K.create = (n, e) => new K(u({
|
|
1573
1578
|
type: n,
|
|
1574
1579
|
minLength: null,
|
|
1575
1580
|
maxLength: null,
|
|
1576
1581
|
exactLength: null,
|
|
1577
1582
|
typeName: g.ZodArray
|
|
1578
|
-
},
|
|
1579
|
-
function
|
|
1583
|
+
}, b(e)));
|
|
1584
|
+
function ke(n) {
|
|
1580
1585
|
if (n instanceof S) {
|
|
1581
1586
|
const e = {};
|
|
1582
1587
|
for (const t in n.shape) {
|
|
1583
1588
|
const s = n.shape[t];
|
|
1584
|
-
e[t] =
|
|
1589
|
+
e[t] = ee.create(ke(s));
|
|
1585
1590
|
}
|
|
1586
1591
|
return new S(y(u({}, n._def), {
|
|
1587
1592
|
shape: () => e
|
|
1588
1593
|
}));
|
|
1589
|
-
} else return n instanceof
|
|
1590
|
-
type:
|
|
1591
|
-
})) : n instanceof
|
|
1594
|
+
} else return n instanceof K ? new K(y(u({}, n._def), {
|
|
1595
|
+
type: ke(n.element)
|
|
1596
|
+
})) : n instanceof ee ? ee.create(ke(n.unwrap())) : n instanceof me ? me.create(ke(n.unwrap())) : n instanceof ne ? ne.create(n.items.map((e) => ke(e))) : n;
|
|
1592
1597
|
}
|
|
1593
|
-
class S extends
|
|
1598
|
+
class S extends w {
|
|
1594
1599
|
constructor() {
|
|
1595
1600
|
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1596
1601
|
}
|
|
1597
1602
|
_getCached() {
|
|
1598
1603
|
if (this._cached !== null)
|
|
1599
1604
|
return this._cached;
|
|
1600
|
-
const e = this._def.shape(), t =
|
|
1605
|
+
const e = this._def.shape(), t = x.objectKeys(e);
|
|
1601
1606
|
return this._cached = { shape: e, keys: t };
|
|
1602
1607
|
}
|
|
1603
1608
|
_parse(e) {
|
|
@@ -1610,7 +1615,7 @@ class S extends x {
|
|
|
1610
1615
|
}), v;
|
|
1611
1616
|
}
|
|
1612
1617
|
const { status: s, ctx: r } = this._processInputParams(e), { shape: a, keys: i } = this._getCached(), o = [];
|
|
1613
|
-
if (!(this._def.catchall instanceof
|
|
1618
|
+
if (!(this._def.catchall instanceof oe && this._def.unknownKeys === "strip"))
|
|
1614
1619
|
for (const d in r.data)
|
|
1615
1620
|
i.includes(d) || o.push(d);
|
|
1616
1621
|
const c = [];
|
|
@@ -1618,11 +1623,11 @@ class S extends x {
|
|
|
1618
1623
|
const f = a[d], _ = r.data[d];
|
|
1619
1624
|
c.push({
|
|
1620
1625
|
key: { status: "valid", value: d },
|
|
1621
|
-
value: f._parse(new
|
|
1626
|
+
value: f._parse(new te(r, _, r.path, d)),
|
|
1622
1627
|
alwaysSet: d in r.data
|
|
1623
1628
|
});
|
|
1624
1629
|
}
|
|
1625
|
-
if (this._def.catchall instanceof
|
|
1630
|
+
if (this._def.catchall instanceof oe) {
|
|
1626
1631
|
const d = this._def.unknownKeys;
|
|
1627
1632
|
if (d === "passthrough")
|
|
1628
1633
|
for (const f of o)
|
|
@@ -1643,25 +1648,25 @@ class S extends x {
|
|
|
1643
1648
|
c.push({
|
|
1644
1649
|
key: { status: "valid", value: f },
|
|
1645
1650
|
value: d._parse(
|
|
1646
|
-
new
|
|
1651
|
+
new te(r, _, r.path, f)
|
|
1647
1652
|
//, ctx.child(key), value, getParsedType(value)
|
|
1648
1653
|
),
|
|
1649
1654
|
alwaysSet: f in r.data
|
|
1650
1655
|
});
|
|
1651
1656
|
}
|
|
1652
1657
|
}
|
|
1653
|
-
return r.common.async ? Promise.resolve().then(() =>
|
|
1658
|
+
return r.common.async ? Promise.resolve().then(() => F(this, null, function* () {
|
|
1654
1659
|
const d = [];
|
|
1655
1660
|
for (const f of c) {
|
|
1656
|
-
const _ = yield f.key,
|
|
1661
|
+
const _ = yield f.key, j = yield f.value;
|
|
1657
1662
|
d.push({
|
|
1658
1663
|
key: _,
|
|
1659
|
-
value:
|
|
1664
|
+
value: j,
|
|
1660
1665
|
alwaysSet: f.alwaysSet
|
|
1661
1666
|
});
|
|
1662
1667
|
}
|
|
1663
1668
|
return d;
|
|
1664
|
-
})).then((d) =>
|
|
1669
|
+
})).then((d) => Z.mergeObjectSync(s, d)) : Z.mergeObjectSync(s, c);
|
|
1665
1670
|
}
|
|
1666
1671
|
get shape() {
|
|
1667
1672
|
return this._def.shape();
|
|
@@ -1792,7 +1797,7 @@ class S extends x {
|
|
|
1792
1797
|
}
|
|
1793
1798
|
pick(e) {
|
|
1794
1799
|
const t = {};
|
|
1795
|
-
return
|
|
1800
|
+
return x.objectKeys(e).forEach((s) => {
|
|
1796
1801
|
e[s] && this.shape[s] && (t[s] = this.shape[s]);
|
|
1797
1802
|
}), new S(y(u({}, this._def), {
|
|
1798
1803
|
shape: () => t
|
|
@@ -1800,7 +1805,7 @@ class S extends x {
|
|
|
1800
1805
|
}
|
|
1801
1806
|
omit(e) {
|
|
1802
1807
|
const t = {};
|
|
1803
|
-
return
|
|
1808
|
+
return x.objectKeys(this.shape).forEach((s) => {
|
|
1804
1809
|
e[s] || (t[s] = this.shape[s]);
|
|
1805
1810
|
}), new S(y(u({}, this._def), {
|
|
1806
1811
|
shape: () => t
|
|
@@ -1810,11 +1815,11 @@ class S extends x {
|
|
|
1810
1815
|
* @deprecated
|
|
1811
1816
|
*/
|
|
1812
1817
|
deepPartial() {
|
|
1813
|
-
return
|
|
1818
|
+
return ke(this);
|
|
1814
1819
|
}
|
|
1815
1820
|
partial(e) {
|
|
1816
1821
|
const t = {};
|
|
1817
|
-
return
|
|
1822
|
+
return x.objectKeys(this.shape).forEach((s) => {
|
|
1818
1823
|
const r = this.shape[s];
|
|
1819
1824
|
e && !e[s] ? t[s] = r : t[s] = r.optional();
|
|
1820
1825
|
}), new S(y(u({}, this._def), {
|
|
@@ -1823,12 +1828,12 @@ class S extends x {
|
|
|
1823
1828
|
}
|
|
1824
1829
|
required(e) {
|
|
1825
1830
|
const t = {};
|
|
1826
|
-
return
|
|
1831
|
+
return x.objectKeys(this.shape).forEach((s) => {
|
|
1827
1832
|
if (e && !e[s])
|
|
1828
1833
|
t[s] = this.shape[s];
|
|
1829
1834
|
else {
|
|
1830
1835
|
let a = this.shape[s];
|
|
1831
|
-
for (; a instanceof
|
|
1836
|
+
for (; a instanceof ee; )
|
|
1832
1837
|
a = a._def.innerType;
|
|
1833
1838
|
t[s] = a;
|
|
1834
1839
|
}
|
|
@@ -1837,28 +1842,28 @@ class S extends x {
|
|
|
1837
1842
|
}));
|
|
1838
1843
|
}
|
|
1839
1844
|
keyof() {
|
|
1840
|
-
return Xt(
|
|
1845
|
+
return Xt(x.objectKeys(this.shape));
|
|
1841
1846
|
}
|
|
1842
1847
|
}
|
|
1843
1848
|
S.create = (n, e) => new S(u({
|
|
1844
1849
|
shape: () => n,
|
|
1845
1850
|
unknownKeys: "strip",
|
|
1846
|
-
catchall:
|
|
1851
|
+
catchall: oe.create(),
|
|
1847
1852
|
typeName: g.ZodObject
|
|
1848
|
-
},
|
|
1853
|
+
}, b(e)));
|
|
1849
1854
|
S.strictCreate = (n, e) => new S(u({
|
|
1850
1855
|
shape: () => n,
|
|
1851
1856
|
unknownKeys: "strict",
|
|
1852
|
-
catchall:
|
|
1857
|
+
catchall: oe.create(),
|
|
1853
1858
|
typeName: g.ZodObject
|
|
1854
|
-
},
|
|
1859
|
+
}, b(e)));
|
|
1855
1860
|
S.lazycreate = (n, e) => new S(u({
|
|
1856
1861
|
shape: n,
|
|
1857
1862
|
unknownKeys: "strip",
|
|
1858
|
-
catchall:
|
|
1863
|
+
catchall: oe.create(),
|
|
1859
1864
|
typeName: g.ZodObject
|
|
1860
|
-
},
|
|
1861
|
-
class
|
|
1865
|
+
}, b(e)));
|
|
1866
|
+
class Le extends w {
|
|
1862
1867
|
_parse(e) {
|
|
1863
1868
|
const { ctx: t } = this._processInputParams(e), s = this._def.options;
|
|
1864
1869
|
function r(a) {
|
|
@@ -1868,14 +1873,14 @@ class Fe extends x {
|
|
|
1868
1873
|
for (const o of a)
|
|
1869
1874
|
if (o.result.status === "dirty")
|
|
1870
1875
|
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1871
|
-
const i = a.map((o) => new
|
|
1876
|
+
const i = a.map((o) => new z(o.ctx.common.issues));
|
|
1872
1877
|
return h(t, {
|
|
1873
1878
|
code: l.invalid_union,
|
|
1874
1879
|
unionErrors: i
|
|
1875
1880
|
}), v;
|
|
1876
1881
|
}
|
|
1877
1882
|
if (t.common.async)
|
|
1878
|
-
return Promise.all(s.map((a) =>
|
|
1883
|
+
return Promise.all(s.map((a) => F(this, null, function* () {
|
|
1879
1884
|
const i = y(u({}, t), {
|
|
1880
1885
|
common: y(u({}, t.common), {
|
|
1881
1886
|
issues: []
|
|
@@ -1911,7 +1916,7 @@ class Fe extends x {
|
|
|
1911
1916
|
}
|
|
1912
1917
|
if (a)
|
|
1913
1918
|
return t.common.issues.push(...a.ctx.common.issues), a.result;
|
|
1914
|
-
const o = i.map((c) => new
|
|
1919
|
+
const o = i.map((c) => new z(c));
|
|
1915
1920
|
return h(t, {
|
|
1916
1921
|
code: l.invalid_union,
|
|
1917
1922
|
unionErrors: o
|
|
@@ -1922,12 +1927,12 @@ class Fe extends x {
|
|
|
1922
1927
|
return this._def.options;
|
|
1923
1928
|
}
|
|
1924
1929
|
}
|
|
1925
|
-
|
|
1930
|
+
Le.create = (n, e) => new Le(u({
|
|
1926
1931
|
options: n,
|
|
1927
1932
|
typeName: g.ZodUnion
|
|
1928
|
-
},
|
|
1929
|
-
const
|
|
1930
|
-
class
|
|
1933
|
+
}, b(e)));
|
|
1934
|
+
const ae = (n) => n instanceof ze ? ae(n.schema) : n instanceof G ? ae(n.innerType()) : n instanceof We ? [n.value] : n instanceof pe ? n.options : n instanceof Be ? x.objectValues(n.enum) : n instanceof qe ? ae(n._def.innerType) : n instanceof Fe ? [void 0] : n instanceof De ? [null] : n instanceof ee ? [void 0, ...ae(n.unwrap())] : n instanceof me ? [null, ...ae(n.unwrap())] : n instanceof Ot || n instanceof Je ? ae(n.unwrap()) : n instanceof He ? ae(n._def.innerType) : [];
|
|
1935
|
+
class ot extends w {
|
|
1931
1936
|
_parse(e) {
|
|
1932
1937
|
const { ctx: t } = this._processInputParams(e);
|
|
1933
1938
|
if (t.parsedType !== p.object)
|
|
@@ -1971,7 +1976,7 @@ class it extends x {
|
|
|
1971
1976
|
static create(e, t, s) {
|
|
1972
1977
|
const r = /* @__PURE__ */ new Map();
|
|
1973
1978
|
for (const a of t) {
|
|
1974
|
-
const i =
|
|
1979
|
+
const i = ae(a.shape[e]);
|
|
1975
1980
|
if (!i.length)
|
|
1976
1981
|
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
1977
1982
|
for (const o of i) {
|
|
@@ -1980,22 +1985,22 @@ class it extends x {
|
|
|
1980
1985
|
r.set(o, a);
|
|
1981
1986
|
}
|
|
1982
1987
|
}
|
|
1983
|
-
return new
|
|
1988
|
+
return new ot(u({
|
|
1984
1989
|
typeName: g.ZodDiscriminatedUnion,
|
|
1985
1990
|
discriminator: e,
|
|
1986
1991
|
options: t,
|
|
1987
1992
|
optionsMap: r
|
|
1988
|
-
},
|
|
1993
|
+
}, b(s)));
|
|
1989
1994
|
}
|
|
1990
1995
|
}
|
|
1991
|
-
function
|
|
1992
|
-
const t =
|
|
1996
|
+
function vt(n, e) {
|
|
1997
|
+
const t = ie(n), s = ie(e);
|
|
1993
1998
|
if (n === e)
|
|
1994
1999
|
return { valid: !0, data: n };
|
|
1995
2000
|
if (t === p.object && s === p.object) {
|
|
1996
|
-
const r =
|
|
2001
|
+
const r = x.objectKeys(e), a = x.objectKeys(n).filter((o) => r.indexOf(o) !== -1), i = u(u({}, n), e);
|
|
1997
2002
|
for (const o of a) {
|
|
1998
|
-
const c =
|
|
2003
|
+
const c = vt(n[o], e[o]);
|
|
1999
2004
|
if (!c.valid)
|
|
2000
2005
|
return { valid: !1 };
|
|
2001
2006
|
i[o] = c.data;
|
|
@@ -2006,7 +2011,7 @@ function gt(n, e) {
|
|
|
2006
2011
|
return { valid: !1 };
|
|
2007
2012
|
const r = [];
|
|
2008
2013
|
for (let a = 0; a < n.length; a++) {
|
|
2009
|
-
const i = n[a], o = e[a], c =
|
|
2014
|
+
const i = n[a], o = e[a], c = vt(i, o);
|
|
2010
2015
|
if (!c.valid)
|
|
2011
2016
|
return { valid: !1 };
|
|
2012
2017
|
r.push(c.data);
|
|
@@ -2014,13 +2019,13 @@ function gt(n, e) {
|
|
|
2014
2019
|
return { valid: !0, data: r };
|
|
2015
2020
|
} else return t === p.date && s === p.date && +n == +e ? { valid: !0, data: n } : { valid: !1 };
|
|
2016
2021
|
}
|
|
2017
|
-
class
|
|
2022
|
+
class Ve extends w {
|
|
2018
2023
|
_parse(e) {
|
|
2019
2024
|
const { status: t, ctx: s } = this._processInputParams(e), r = (a, i) => {
|
|
2020
|
-
if (
|
|
2025
|
+
if (yt(a) || yt(i))
|
|
2021
2026
|
return v;
|
|
2022
|
-
const o =
|
|
2023
|
-
return o.valid ? ((
|
|
2027
|
+
const o = vt(a.value, i.value);
|
|
2028
|
+
return o.valid ? ((gt(a) || gt(i)) && t.dirty(), { status: t.value, value: o.data }) : (h(s, {
|
|
2024
2029
|
code: l.invalid_intersection_types
|
|
2025
2030
|
}), v);
|
|
2026
2031
|
};
|
|
@@ -2046,12 +2051,12 @@ class Le extends x {
|
|
|
2046
2051
|
}));
|
|
2047
2052
|
}
|
|
2048
2053
|
}
|
|
2049
|
-
|
|
2054
|
+
Ve.create = (n, e, t) => new Ve(u({
|
|
2050
2055
|
left: n,
|
|
2051
2056
|
right: e,
|
|
2052
2057
|
typeName: g.ZodIntersection
|
|
2053
|
-
},
|
|
2054
|
-
class
|
|
2058
|
+
}, b(t)));
|
|
2059
|
+
class ne extends w {
|
|
2055
2060
|
_parse(e) {
|
|
2056
2061
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2057
2062
|
if (s.parsedType !== p.array)
|
|
@@ -2077,29 +2082,29 @@ class ee extends x {
|
|
|
2077
2082
|
}), t.dirty());
|
|
2078
2083
|
const a = [...s.data].map((i, o) => {
|
|
2079
2084
|
const c = this._def.items[o] || this._def.rest;
|
|
2080
|
-
return c ? c._parse(new
|
|
2085
|
+
return c ? c._parse(new te(s, i, s.path, o)) : null;
|
|
2081
2086
|
}).filter((i) => !!i);
|
|
2082
|
-
return s.common.async ? Promise.all(a).then((i) =>
|
|
2087
|
+
return s.common.async ? Promise.all(a).then((i) => Z.mergeArray(t, i)) : Z.mergeArray(t, a);
|
|
2083
2088
|
}
|
|
2084
2089
|
get items() {
|
|
2085
2090
|
return this._def.items;
|
|
2086
2091
|
}
|
|
2087
2092
|
rest(e) {
|
|
2088
|
-
return new
|
|
2093
|
+
return new ne(y(u({}, this._def), {
|
|
2089
2094
|
rest: e
|
|
2090
2095
|
}));
|
|
2091
2096
|
}
|
|
2092
2097
|
}
|
|
2093
|
-
|
|
2098
|
+
ne.create = (n, e) => {
|
|
2094
2099
|
if (!Array.isArray(n))
|
|
2095
2100
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2096
|
-
return new
|
|
2101
|
+
return new ne(u({
|
|
2097
2102
|
items: n,
|
|
2098
2103
|
typeName: g.ZodTuple,
|
|
2099
2104
|
rest: null
|
|
2100
|
-
},
|
|
2105
|
+
}, b(e)));
|
|
2101
2106
|
};
|
|
2102
|
-
class
|
|
2107
|
+
class Ue extends w {
|
|
2103
2108
|
get keySchema() {
|
|
2104
2109
|
return this._def.keyType;
|
|
2105
2110
|
}
|
|
@@ -2117,28 +2122,28 @@ class De extends x {
|
|
|
2117
2122
|
const r = [], a = this._def.keyType, i = this._def.valueType;
|
|
2118
2123
|
for (const o in s.data)
|
|
2119
2124
|
r.push({
|
|
2120
|
-
key: a._parse(new
|
|
2121
|
-
value: i._parse(new
|
|
2125
|
+
key: a._parse(new te(s, o, s.path, o)),
|
|
2126
|
+
value: i._parse(new te(s, s.data[o], s.path, o)),
|
|
2122
2127
|
alwaysSet: o in s.data
|
|
2123
2128
|
});
|
|
2124
|
-
return s.common.async ?
|
|
2129
|
+
return s.common.async ? Z.mergeObjectAsync(t, r) : Z.mergeObjectSync(t, r);
|
|
2125
2130
|
}
|
|
2126
2131
|
get element() {
|
|
2127
2132
|
return this._def.valueType;
|
|
2128
2133
|
}
|
|
2129
2134
|
static create(e, t, s) {
|
|
2130
|
-
return t instanceof
|
|
2135
|
+
return t instanceof w ? new Ue(u({
|
|
2131
2136
|
keyType: e,
|
|
2132
2137
|
valueType: t,
|
|
2133
2138
|
typeName: g.ZodRecord
|
|
2134
|
-
},
|
|
2135
|
-
keyType:
|
|
2139
|
+
}, b(s))) : new Ue(u({
|
|
2140
|
+
keyType: J.create(),
|
|
2136
2141
|
valueType: e,
|
|
2137
2142
|
typeName: g.ZodRecord
|
|
2138
|
-
},
|
|
2143
|
+
}, b(t)));
|
|
2139
2144
|
}
|
|
2140
2145
|
}
|
|
2141
|
-
class
|
|
2146
|
+
class at extends w {
|
|
2142
2147
|
get keySchema() {
|
|
2143
2148
|
return this._def.keyType;
|
|
2144
2149
|
}
|
|
@@ -2154,12 +2159,12 @@ class rt extends x {
|
|
|
2154
2159
|
received: s.parsedType
|
|
2155
2160
|
}), v;
|
|
2156
2161
|
const r = this._def.keyType, a = this._def.valueType, i = [...s.data.entries()].map(([o, c], d) => ({
|
|
2157
|
-
key: r._parse(new
|
|
2158
|
-
value: a._parse(new
|
|
2162
|
+
key: r._parse(new te(s, o, s.path, [d, "key"])),
|
|
2163
|
+
value: a._parse(new te(s, c, s.path, [d, "value"]))
|
|
2159
2164
|
}));
|
|
2160
2165
|
if (s.common.async) {
|
|
2161
2166
|
const o = /* @__PURE__ */ new Map();
|
|
2162
|
-
return Promise.resolve().then(() =>
|
|
2167
|
+
return Promise.resolve().then(() => F(this, null, function* () {
|
|
2163
2168
|
for (const c of i) {
|
|
2164
2169
|
const d = yield c.key, f = yield c.value;
|
|
2165
2170
|
if (d.status === "aborted" || f.status === "aborted")
|
|
@@ -2180,12 +2185,12 @@ class rt extends x {
|
|
|
2180
2185
|
}
|
|
2181
2186
|
}
|
|
2182
2187
|
}
|
|
2183
|
-
|
|
2188
|
+
at.create = (n, e, t) => new at(u({
|
|
2184
2189
|
valueType: e,
|
|
2185
2190
|
keyType: n,
|
|
2186
2191
|
typeName: g.ZodMap
|
|
2187
|
-
},
|
|
2188
|
-
class
|
|
2192
|
+
}, b(t)));
|
|
2193
|
+
class xe extends w {
|
|
2189
2194
|
_parse(e) {
|
|
2190
2195
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2191
2196
|
if (s.parsedType !== p.set)
|
|
@@ -2220,16 +2225,16 @@ class ve extends x {
|
|
|
2220
2225
|
}
|
|
2221
2226
|
return { status: t.value, value: d };
|
|
2222
2227
|
}
|
|
2223
|
-
const o = [...s.data.values()].map((c, d) => a._parse(new
|
|
2228
|
+
const o = [...s.data.values()].map((c, d) => a._parse(new te(s, c, s.path, d)));
|
|
2224
2229
|
return s.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
2225
2230
|
}
|
|
2226
2231
|
min(e, t) {
|
|
2227
|
-
return new
|
|
2232
|
+
return new xe(y(u({}, this._def), {
|
|
2228
2233
|
minSize: { value: e, message: m.toString(t) }
|
|
2229
2234
|
}));
|
|
2230
2235
|
}
|
|
2231
2236
|
max(e, t) {
|
|
2232
|
-
return new
|
|
2237
|
+
return new xe(y(u({}, this._def), {
|
|
2233
2238
|
maxSize: { value: e, message: m.toString(t) }
|
|
2234
2239
|
}));
|
|
2235
2240
|
}
|
|
@@ -2240,13 +2245,13 @@ class ve extends x {
|
|
|
2240
2245
|
return this.min(1, e);
|
|
2241
2246
|
}
|
|
2242
2247
|
}
|
|
2243
|
-
|
|
2248
|
+
xe.create = (n, e) => new xe(u({
|
|
2244
2249
|
valueType: n,
|
|
2245
2250
|
minSize: null,
|
|
2246
2251
|
maxSize: null,
|
|
2247
2252
|
typeName: g.ZodSet
|
|
2248
|
-
},
|
|
2249
|
-
class
|
|
2253
|
+
}, b(e)));
|
|
2254
|
+
class Se extends w {
|
|
2250
2255
|
constructor() {
|
|
2251
2256
|
super(...arguments), this.validate = this.implement;
|
|
2252
2257
|
}
|
|
@@ -2259,14 +2264,14 @@ class xe extends x {
|
|
|
2259
2264
|
received: t.parsedType
|
|
2260
2265
|
}), v;
|
|
2261
2266
|
function s(o, c) {
|
|
2262
|
-
return
|
|
2267
|
+
return tt({
|
|
2263
2268
|
data: o,
|
|
2264
2269
|
path: t.path,
|
|
2265
2270
|
errorMaps: [
|
|
2266
2271
|
t.common.contextualErrorMap,
|
|
2267
2272
|
t.schemaErrorMap,
|
|
2268
|
-
|
|
2269
|
-
|
|
2273
|
+
et(),
|
|
2274
|
+
Ae
|
|
2270
2275
|
].filter((d) => !!d),
|
|
2271
2276
|
issueData: {
|
|
2272
2277
|
code: l.invalid_arguments,
|
|
@@ -2275,14 +2280,14 @@ class xe extends x {
|
|
|
2275
2280
|
});
|
|
2276
2281
|
}
|
|
2277
2282
|
function r(o, c) {
|
|
2278
|
-
return
|
|
2283
|
+
return tt({
|
|
2279
2284
|
data: o,
|
|
2280
2285
|
path: t.path,
|
|
2281
2286
|
errorMaps: [
|
|
2282
2287
|
t.common.contextualErrorMap,
|
|
2283
2288
|
t.schemaErrorMap,
|
|
2284
|
-
|
|
2285
|
-
|
|
2289
|
+
et(),
|
|
2290
|
+
Ae
|
|
2286
2291
|
].filter((d) => !!d),
|
|
2287
2292
|
issueData: {
|
|
2288
2293
|
code: l.invalid_return_type,
|
|
@@ -2291,27 +2296,27 @@ class xe extends x {
|
|
|
2291
2296
|
});
|
|
2292
2297
|
}
|
|
2293
2298
|
const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
|
|
2294
|
-
if (this._def.returns instanceof
|
|
2299
|
+
if (this._def.returns instanceof Oe) {
|
|
2295
2300
|
const o = this;
|
|
2296
|
-
return
|
|
2297
|
-
return
|
|
2298
|
-
const d = new
|
|
2299
|
-
throw d.addIssue(s(c,
|
|
2301
|
+
return P(function(...c) {
|
|
2302
|
+
return F(this, null, function* () {
|
|
2303
|
+
const d = new z([]), f = yield o._def.args.parseAsync(c, a).catch((O) => {
|
|
2304
|
+
throw d.addIssue(s(c, O)), d;
|
|
2300
2305
|
}), _ = yield Reflect.apply(i, this, f);
|
|
2301
|
-
return yield o._def.returns._def.type.parseAsync(_, a).catch((
|
|
2302
|
-
throw d.addIssue(r(_,
|
|
2306
|
+
return yield o._def.returns._def.type.parseAsync(_, a).catch((O) => {
|
|
2307
|
+
throw d.addIssue(r(_, O)), d;
|
|
2303
2308
|
});
|
|
2304
2309
|
});
|
|
2305
2310
|
});
|
|
2306
2311
|
} else {
|
|
2307
2312
|
const o = this;
|
|
2308
|
-
return
|
|
2313
|
+
return P(function(...c) {
|
|
2309
2314
|
const d = o._def.args.safeParse(c, a);
|
|
2310
2315
|
if (!d.success)
|
|
2311
|
-
throw new
|
|
2316
|
+
throw new z([s(c, d.error)]);
|
|
2312
2317
|
const f = Reflect.apply(i, this, d.data), _ = o._def.returns.safeParse(f, a);
|
|
2313
2318
|
if (!_.success)
|
|
2314
|
-
throw new
|
|
2319
|
+
throw new z([r(f, _.error)]);
|
|
2315
2320
|
return _.data;
|
|
2316
2321
|
});
|
|
2317
2322
|
}
|
|
@@ -2323,12 +2328,12 @@ class xe extends x {
|
|
|
2323
2328
|
return this._def.returns;
|
|
2324
2329
|
}
|
|
2325
2330
|
args(...e) {
|
|
2326
|
-
return new
|
|
2327
|
-
args:
|
|
2331
|
+
return new Se(y(u({}, this._def), {
|
|
2332
|
+
args: ne.create(e).rest(_e.create())
|
|
2328
2333
|
}));
|
|
2329
2334
|
}
|
|
2330
2335
|
returns(e) {
|
|
2331
|
-
return new
|
|
2336
|
+
return new Se(y(u({}, this._def), {
|
|
2332
2337
|
returns: e
|
|
2333
2338
|
}));
|
|
2334
2339
|
}
|
|
@@ -2339,14 +2344,14 @@ class xe extends x {
|
|
|
2339
2344
|
return this.parse(e);
|
|
2340
2345
|
}
|
|
2341
2346
|
static create(e, t, s) {
|
|
2342
|
-
return new
|
|
2343
|
-
args: e ||
|
|
2344
|
-
returns: t ||
|
|
2347
|
+
return new Se(u({
|
|
2348
|
+
args: e || ne.create([]).rest(_e.create()),
|
|
2349
|
+
returns: t || _e.create(),
|
|
2345
2350
|
typeName: g.ZodFunction
|
|
2346
|
-
},
|
|
2351
|
+
}, b(s)));
|
|
2347
2352
|
}
|
|
2348
2353
|
}
|
|
2349
|
-
class
|
|
2354
|
+
class ze extends w {
|
|
2350
2355
|
get schema() {
|
|
2351
2356
|
return this._def.getter();
|
|
2352
2357
|
}
|
|
@@ -2355,11 +2360,11 @@ class Ve extends x {
|
|
|
2355
2360
|
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2356
2361
|
}
|
|
2357
2362
|
}
|
|
2358
|
-
|
|
2363
|
+
ze.create = (n, e) => new ze(u({
|
|
2359
2364
|
getter: n,
|
|
2360
2365
|
typeName: g.ZodLazy
|
|
2361
|
-
},
|
|
2362
|
-
class
|
|
2366
|
+
}, b(e)));
|
|
2367
|
+
class We extends w {
|
|
2363
2368
|
_parse(e) {
|
|
2364
2369
|
if (e.data !== this._def.value) {
|
|
2365
2370
|
const t = this._getOrReturnCtx(e);
|
|
@@ -2375,30 +2380,30 @@ class Ue extends x {
|
|
|
2375
2380
|
return this._def.value;
|
|
2376
2381
|
}
|
|
2377
2382
|
}
|
|
2378
|
-
|
|
2383
|
+
We.create = (n, e) => new We(u({
|
|
2379
2384
|
value: n,
|
|
2380
2385
|
typeName: g.ZodLiteral
|
|
2381
|
-
},
|
|
2386
|
+
}, b(e)));
|
|
2382
2387
|
function Xt(n, e) {
|
|
2383
|
-
return new
|
|
2388
|
+
return new pe(u({
|
|
2384
2389
|
values: n,
|
|
2385
2390
|
typeName: g.ZodEnum
|
|
2386
|
-
},
|
|
2391
|
+
}, b(e)));
|
|
2387
2392
|
}
|
|
2388
|
-
class
|
|
2393
|
+
class pe extends w {
|
|
2389
2394
|
constructor() {
|
|
2390
|
-
super(...arguments),
|
|
2395
|
+
super(...arguments), je.set(this, void 0);
|
|
2391
2396
|
}
|
|
2392
2397
|
_parse(e) {
|
|
2393
2398
|
if (typeof e.data != "string") {
|
|
2394
2399
|
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
2395
2400
|
return h(t, {
|
|
2396
|
-
expected:
|
|
2401
|
+
expected: x.joinValues(s),
|
|
2397
2402
|
received: t.parsedType,
|
|
2398
2403
|
code: l.invalid_type
|
|
2399
2404
|
}), v;
|
|
2400
2405
|
}
|
|
2401
|
-
if (
|
|
2406
|
+
if (nt(this, je) || Ht(this, je, new Set(this._def.values)), !nt(this, je).has(e.data)) {
|
|
2402
2407
|
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
2403
2408
|
return h(t, {
|
|
2404
2409
|
received: t.data,
|
|
@@ -2406,7 +2411,7 @@ class le extends x {
|
|
|
2406
2411
|
options: s
|
|
2407
2412
|
}), v;
|
|
2408
2413
|
}
|
|
2409
|
-
return
|
|
2414
|
+
return P(e.data);
|
|
2410
2415
|
}
|
|
2411
2416
|
get options() {
|
|
2412
2417
|
return this._def.values;
|
|
@@ -2430,48 +2435,48 @@ class le extends x {
|
|
|
2430
2435
|
return e;
|
|
2431
2436
|
}
|
|
2432
2437
|
extract(e, t = this._def) {
|
|
2433
|
-
return
|
|
2438
|
+
return pe.create(e, u(u({}, this._def), t));
|
|
2434
2439
|
}
|
|
2435
2440
|
exclude(e, t = this._def) {
|
|
2436
|
-
return
|
|
2441
|
+
return pe.create(this.options.filter((s) => !e.includes(s)), u(u({}, this._def), t));
|
|
2437
2442
|
}
|
|
2438
2443
|
}
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
class
|
|
2444
|
+
je = /* @__PURE__ */ new WeakMap();
|
|
2445
|
+
pe.create = Xt;
|
|
2446
|
+
class Be extends w {
|
|
2442
2447
|
constructor() {
|
|
2443
|
-
super(...arguments),
|
|
2448
|
+
super(...arguments), Ne.set(this, void 0);
|
|
2444
2449
|
}
|
|
2445
2450
|
_parse(e) {
|
|
2446
|
-
const t =
|
|
2451
|
+
const t = x.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
2447
2452
|
if (s.parsedType !== p.string && s.parsedType !== p.number) {
|
|
2448
|
-
const r =
|
|
2453
|
+
const r = x.objectValues(t);
|
|
2449
2454
|
return h(s, {
|
|
2450
|
-
expected:
|
|
2455
|
+
expected: x.joinValues(r),
|
|
2451
2456
|
received: s.parsedType,
|
|
2452
2457
|
code: l.invalid_type
|
|
2453
2458
|
}), v;
|
|
2454
2459
|
}
|
|
2455
|
-
if (
|
|
2456
|
-
const r =
|
|
2460
|
+
if (nt(this, Ne) || Ht(this, Ne, new Set(x.getValidEnumValues(this._def.values))), !nt(this, Ne).has(e.data)) {
|
|
2461
|
+
const r = x.objectValues(t);
|
|
2457
2462
|
return h(s, {
|
|
2458
2463
|
received: s.data,
|
|
2459
2464
|
code: l.invalid_enum_value,
|
|
2460
2465
|
options: r
|
|
2461
2466
|
}), v;
|
|
2462
2467
|
}
|
|
2463
|
-
return
|
|
2468
|
+
return P(e.data);
|
|
2464
2469
|
}
|
|
2465
2470
|
get enum() {
|
|
2466
2471
|
return this._def.values;
|
|
2467
2472
|
}
|
|
2468
2473
|
}
|
|
2469
|
-
|
|
2470
|
-
|
|
2474
|
+
Ne = /* @__PURE__ */ new WeakMap();
|
|
2475
|
+
Be.create = (n, e) => new Be(u({
|
|
2471
2476
|
values: n,
|
|
2472
2477
|
typeName: g.ZodNativeEnum
|
|
2473
|
-
},
|
|
2474
|
-
class
|
|
2478
|
+
}, b(e)));
|
|
2479
|
+
class Oe extends w {
|
|
2475
2480
|
unwrap() {
|
|
2476
2481
|
return this._def.type;
|
|
2477
2482
|
}
|
|
@@ -2484,17 +2489,17 @@ class Se extends x {
|
|
|
2484
2489
|
received: t.parsedType
|
|
2485
2490
|
}), v;
|
|
2486
2491
|
const s = t.parsedType === p.promise ? t.data : Promise.resolve(t.data);
|
|
2487
|
-
return
|
|
2492
|
+
return P(s.then((r) => this._def.type.parseAsync(r, {
|
|
2488
2493
|
path: t.path,
|
|
2489
2494
|
errorMap: t.common.contextualErrorMap
|
|
2490
2495
|
})));
|
|
2491
2496
|
}
|
|
2492
2497
|
}
|
|
2493
|
-
|
|
2498
|
+
Oe.create = (n, e) => new Oe(u({
|
|
2494
2499
|
type: n,
|
|
2495
2500
|
typeName: g.ZodPromise
|
|
2496
|
-
},
|
|
2497
|
-
class
|
|
2501
|
+
}, b(e)));
|
|
2502
|
+
class G extends w {
|
|
2498
2503
|
innerType() {
|
|
2499
2504
|
return this._def.schema;
|
|
2500
2505
|
}
|
|
@@ -2513,7 +2518,7 @@ class J extends x {
|
|
|
2513
2518
|
if (a.addIssue = a.addIssue.bind(a), r.type === "preprocess") {
|
|
2514
2519
|
const i = r.transform(s.data, a);
|
|
2515
2520
|
if (s.common.async)
|
|
2516
|
-
return Promise.resolve(i).then((o) =>
|
|
2521
|
+
return Promise.resolve(i).then((o) => F(this, null, function* () {
|
|
2517
2522
|
if (t.value === "aborted")
|
|
2518
2523
|
return v;
|
|
2519
2524
|
const c = yield this._def.schema._parseAsync({
|
|
@@ -2521,7 +2526,7 @@ class J extends x {
|
|
|
2521
2526
|
path: s.path,
|
|
2522
2527
|
parent: s
|
|
2523
2528
|
});
|
|
2524
|
-
return c.status === "aborted" ? v : c.status === "dirty" || t.value === "dirty" ?
|
|
2529
|
+
return c.status === "aborted" ? v : c.status === "dirty" || t.value === "dirty" ? Te(c.value) : c;
|
|
2525
2530
|
}));
|
|
2526
2531
|
{
|
|
2527
2532
|
if (t.value === "aborted")
|
|
@@ -2531,7 +2536,7 @@ class J extends x {
|
|
|
2531
2536
|
path: s.path,
|
|
2532
2537
|
parent: s
|
|
2533
2538
|
});
|
|
2534
|
-
return o.status === "aborted" ? v : o.status === "dirty" || t.value === "dirty" ?
|
|
2539
|
+
return o.status === "aborted" ? v : o.status === "dirty" || t.value === "dirty" ? Te(o.value) : o;
|
|
2535
2540
|
}
|
|
2536
2541
|
}
|
|
2537
2542
|
if (r.type === "refinement") {
|
|
@@ -2560,52 +2565,52 @@ class J extends x {
|
|
|
2560
2565
|
path: s.path,
|
|
2561
2566
|
parent: s
|
|
2562
2567
|
});
|
|
2563
|
-
if (!
|
|
2568
|
+
if (!be(i))
|
|
2564
2569
|
return i;
|
|
2565
2570
|
const o = r.transform(i.value, a);
|
|
2566
2571
|
if (o instanceof Promise)
|
|
2567
2572
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2568
2573
|
return { status: t.value, value: o };
|
|
2569
2574
|
} else
|
|
2570
|
-
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) =>
|
|
2571
|
-
|
|
2575
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => be(i) ? Promise.resolve(r.transform(i.value, a)).then((o) => ({ status: t.value, value: o })) : i);
|
|
2576
|
+
x.assertNever(r);
|
|
2572
2577
|
}
|
|
2573
2578
|
}
|
|
2574
|
-
|
|
2579
|
+
G.create = (n, e, t) => new G(u({
|
|
2575
2580
|
schema: n,
|
|
2576
2581
|
typeName: g.ZodEffects,
|
|
2577
2582
|
effect: e
|
|
2578
|
-
},
|
|
2579
|
-
|
|
2583
|
+
}, b(t)));
|
|
2584
|
+
G.createWithPreprocess = (n, e, t) => new G(u({
|
|
2580
2585
|
schema: e,
|
|
2581
2586
|
effect: { type: "preprocess", transform: n },
|
|
2582
2587
|
typeName: g.ZodEffects
|
|
2583
|
-
},
|
|
2584
|
-
class
|
|
2588
|
+
}, b(t)));
|
|
2589
|
+
class ee extends w {
|
|
2585
2590
|
_parse(e) {
|
|
2586
|
-
return this._getType(e) === p.undefined ?
|
|
2591
|
+
return this._getType(e) === p.undefined ? P(void 0) : this._def.innerType._parse(e);
|
|
2587
2592
|
}
|
|
2588
2593
|
unwrap() {
|
|
2589
2594
|
return this._def.innerType;
|
|
2590
2595
|
}
|
|
2591
2596
|
}
|
|
2592
|
-
|
|
2597
|
+
ee.create = (n, e) => new ee(u({
|
|
2593
2598
|
innerType: n,
|
|
2594
2599
|
typeName: g.ZodOptional
|
|
2595
|
-
},
|
|
2596
|
-
class
|
|
2600
|
+
}, b(e)));
|
|
2601
|
+
class me extends w {
|
|
2597
2602
|
_parse(e) {
|
|
2598
|
-
return this._getType(e) === p.null ?
|
|
2603
|
+
return this._getType(e) === p.null ? P(null) : this._def.innerType._parse(e);
|
|
2599
2604
|
}
|
|
2600
2605
|
unwrap() {
|
|
2601
2606
|
return this._def.innerType;
|
|
2602
2607
|
}
|
|
2603
2608
|
}
|
|
2604
|
-
|
|
2609
|
+
me.create = (n, e) => new me(u({
|
|
2605
2610
|
innerType: n,
|
|
2606
2611
|
typeName: g.ZodNullable
|
|
2607
|
-
},
|
|
2608
|
-
class
|
|
2612
|
+
}, b(e)));
|
|
2613
|
+
class qe extends w {
|
|
2609
2614
|
_parse(e) {
|
|
2610
2615
|
const { ctx: t } = this._processInputParams(e);
|
|
2611
2616
|
let s = t.data;
|
|
@@ -2619,12 +2624,12 @@ class We extends x {
|
|
|
2619
2624
|
return this._def.innerType;
|
|
2620
2625
|
}
|
|
2621
2626
|
}
|
|
2622
|
-
|
|
2627
|
+
qe.create = (n, e) => new qe(u({
|
|
2623
2628
|
innerType: n,
|
|
2624
2629
|
typeName: g.ZodDefault,
|
|
2625
2630
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default
|
|
2626
|
-
},
|
|
2627
|
-
class
|
|
2631
|
+
}, b(e)));
|
|
2632
|
+
class He extends w {
|
|
2628
2633
|
_parse(e) {
|
|
2629
2634
|
const { ctx: t } = this._processInputParams(e), s = y(u({}, t), {
|
|
2630
2635
|
common: y(u({}, t.common), {
|
|
@@ -2635,11 +2640,11 @@ class Be extends x {
|
|
|
2635
2640
|
path: s.path,
|
|
2636
2641
|
parent: u({}, s)
|
|
2637
2642
|
});
|
|
2638
|
-
return
|
|
2643
|
+
return Pe(r) ? r.then((a) => ({
|
|
2639
2644
|
status: "valid",
|
|
2640
2645
|
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
2641
2646
|
get error() {
|
|
2642
|
-
return new
|
|
2647
|
+
return new z(s.common.issues);
|
|
2643
2648
|
},
|
|
2644
2649
|
input: s.data
|
|
2645
2650
|
})
|
|
@@ -2647,7 +2652,7 @@ class Be extends x {
|
|
|
2647
2652
|
status: "valid",
|
|
2648
2653
|
value: r.status === "valid" ? r.value : this._def.catchValue({
|
|
2649
2654
|
get error() {
|
|
2650
|
-
return new
|
|
2655
|
+
return new z(s.common.issues);
|
|
2651
2656
|
},
|
|
2652
2657
|
input: s.data
|
|
2653
2658
|
})
|
|
@@ -2657,12 +2662,12 @@ class Be extends x {
|
|
|
2657
2662
|
return this._def.innerType;
|
|
2658
2663
|
}
|
|
2659
2664
|
}
|
|
2660
|
-
|
|
2665
|
+
He.create = (n, e) => new He(u({
|
|
2661
2666
|
innerType: n,
|
|
2662
2667
|
typeName: g.ZodCatch,
|
|
2663
2668
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch
|
|
2664
|
-
},
|
|
2665
|
-
class
|
|
2669
|
+
}, b(e)));
|
|
2670
|
+
class it extends w {
|
|
2666
2671
|
_parse(e) {
|
|
2667
2672
|
if (this._getType(e) !== p.nan) {
|
|
2668
2673
|
const s = this._getOrReturnCtx(e);
|
|
@@ -2675,11 +2680,11 @@ class at extends x {
|
|
|
2675
2680
|
return { status: "valid", value: e.data };
|
|
2676
2681
|
}
|
|
2677
2682
|
}
|
|
2678
|
-
|
|
2683
|
+
it.create = (n) => new it(u({
|
|
2679
2684
|
typeName: g.ZodNaN
|
|
2680
|
-
},
|
|
2685
|
+
}, b(n)));
|
|
2681
2686
|
const Vn = Symbol("zod_brand");
|
|
2682
|
-
class
|
|
2687
|
+
class Ot extends w {
|
|
2683
2688
|
_parse(e) {
|
|
2684
2689
|
const { ctx: t } = this._processInputParams(e), s = t.data;
|
|
2685
2690
|
return this._def.type._parse({
|
|
@@ -2692,17 +2697,17 @@ class At extends x {
|
|
|
2692
2697
|
return this._def.type;
|
|
2693
2698
|
}
|
|
2694
2699
|
}
|
|
2695
|
-
class
|
|
2700
|
+
class Ge extends w {
|
|
2696
2701
|
_parse(e) {
|
|
2697
2702
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2698
2703
|
if (s.common.async)
|
|
2699
|
-
return
|
|
2704
|
+
return F(this, null, function* () {
|
|
2700
2705
|
const a = yield this._def.in._parseAsync({
|
|
2701
2706
|
data: s.data,
|
|
2702
2707
|
path: s.path,
|
|
2703
2708
|
parent: s
|
|
2704
2709
|
});
|
|
2705
|
-
return a.status === "aborted" ? v : a.status === "dirty" ? (t.dirty(),
|
|
2710
|
+
return a.status === "aborted" ? v : a.status === "dirty" ? (t.dirty(), Te(a.value)) : this._def.out._parseAsync({
|
|
2706
2711
|
data: a.value,
|
|
2707
2712
|
path: s.path,
|
|
2708
2713
|
parent: s
|
|
@@ -2725,34 +2730,34 @@ class Je extends x {
|
|
|
2725
2730
|
}
|
|
2726
2731
|
}
|
|
2727
2732
|
static create(e, t) {
|
|
2728
|
-
return new
|
|
2733
|
+
return new Ge({
|
|
2729
2734
|
in: e,
|
|
2730
2735
|
out: t,
|
|
2731
2736
|
typeName: g.ZodPipeline
|
|
2732
2737
|
});
|
|
2733
2738
|
}
|
|
2734
2739
|
}
|
|
2735
|
-
class
|
|
2740
|
+
class Je extends w {
|
|
2736
2741
|
_parse(e) {
|
|
2737
|
-
const t = this._def.innerType._parse(e), s = (r) => (
|
|
2738
|
-
return
|
|
2742
|
+
const t = this._def.innerType._parse(e), s = (r) => (be(r) && (r.value = Object.freeze(r.value)), r);
|
|
2743
|
+
return Pe(t) ? t.then((r) => s(r)) : s(t);
|
|
2739
2744
|
}
|
|
2740
2745
|
unwrap() {
|
|
2741
2746
|
return this._def.innerType;
|
|
2742
2747
|
}
|
|
2743
2748
|
}
|
|
2744
|
-
|
|
2749
|
+
Je.create = (n, e) => new Je(u({
|
|
2745
2750
|
innerType: n,
|
|
2746
2751
|
typeName: g.ZodReadonly
|
|
2747
|
-
},
|
|
2752
|
+
}, b(e)));
|
|
2748
2753
|
function Yt(n, e = {}, t) {
|
|
2749
|
-
return n ?
|
|
2754
|
+
return n ? Ee.create().superRefine((s, r) => {
|
|
2750
2755
|
var a, i;
|
|
2751
2756
|
if (!n(s)) {
|
|
2752
2757
|
const o = typeof e == "function" ? e(s) : typeof e == "string" ? { message: e } : e, c = (i = (a = o.fatal) !== null && a !== void 0 ? a : t) !== null && i !== void 0 ? i : !0, d = typeof o == "string" ? { message: o } : o;
|
|
2753
2758
|
r.addIssue(y(u({ code: "custom" }, d), { fatal: c }));
|
|
2754
2759
|
}
|
|
2755
|
-
}) :
|
|
2760
|
+
}) : Ee.create();
|
|
2756
2761
|
}
|
|
2757
2762
|
const Un = {
|
|
2758
2763
|
object: S.lazycreate
|
|
@@ -2763,94 +2768,94 @@ var g;
|
|
|
2763
2768
|
})(g || (g = {}));
|
|
2764
2769
|
const zn = (n, e = {
|
|
2765
2770
|
message: `Input not instance of ${n.name}`
|
|
2766
|
-
}) => Yt((t) => t instanceof n, e), Qt =
|
|
2767
|
-
string: (n) =>
|
|
2768
|
-
number: (n) =>
|
|
2769
|
-
boolean: (n) =>
|
|
2771
|
+
}) => Yt((t) => t instanceof n, e), Qt = J.create, en = fe.create, Wn = it.create, Bn = he.create, tn = $e.create, qn = we.create, Hn = st.create, Jn = Fe.create, Kn = De.create, Gn = Ee.create, Xn = _e.create, Yn = oe.create, Qn = rt.create, es = K.create, ts = S.create, ns = S.strictCreate, ss = Le.create, rs = ot.create, as = Ve.create, is = ne.create, os = Ue.create, cs = at.create, us = xe.create, ds = Se.create, ls = ze.create, fs = We.create, hs = pe.create, ps = Be.create, ms = Oe.create, $t = G.create, ys = ee.create, gs = me.create, vs = G.createWithPreprocess, _s = Ge.create, bs = () => Qt().optional(), ws = () => en().optional(), xs = () => tn().optional(), ks = {
|
|
2772
|
+
string: (n) => J.create(y(u({}, n), { coerce: !0 })),
|
|
2773
|
+
number: (n) => fe.create(y(u({}, n), { coerce: !0 })),
|
|
2774
|
+
boolean: (n) => $e.create(y(u({}, n), {
|
|
2770
2775
|
coerce: !0
|
|
2771
2776
|
})),
|
|
2772
|
-
bigint: (n) =>
|
|
2773
|
-
date: (n) =>
|
|
2777
|
+
bigint: (n) => he.create(y(u({}, n), { coerce: !0 })),
|
|
2778
|
+
date: (n) => we.create(y(u({}, n), { coerce: !0 }))
|
|
2774
2779
|
}, Ts = v;
|
|
2775
|
-
var
|
|
2780
|
+
var I = /* @__PURE__ */ Object.freeze({
|
|
2776
2781
|
__proto__: null,
|
|
2777
|
-
defaultErrorMap:
|
|
2782
|
+
defaultErrorMap: Ae,
|
|
2778
2783
|
setErrorMap: vn,
|
|
2779
|
-
getErrorMap:
|
|
2780
|
-
makeIssue:
|
|
2784
|
+
getErrorMap: et,
|
|
2785
|
+
makeIssue: tt,
|
|
2781
2786
|
EMPTY_PATH: _n,
|
|
2782
2787
|
addIssueToContext: h,
|
|
2783
|
-
ParseStatus:
|
|
2788
|
+
ParseStatus: Z,
|
|
2784
2789
|
INVALID: v,
|
|
2785
|
-
DIRTY:
|
|
2786
|
-
OK:
|
|
2787
|
-
isAborted:
|
|
2788
|
-
isDirty:
|
|
2789
|
-
isValid:
|
|
2790
|
-
isAsync:
|
|
2790
|
+
DIRTY: Te,
|
|
2791
|
+
OK: P,
|
|
2792
|
+
isAborted: yt,
|
|
2793
|
+
isDirty: gt,
|
|
2794
|
+
isValid: be,
|
|
2795
|
+
isAsync: Pe,
|
|
2791
2796
|
get util() {
|
|
2792
|
-
return
|
|
2797
|
+
return x;
|
|
2793
2798
|
},
|
|
2794
2799
|
get objectUtil() {
|
|
2795
|
-
return
|
|
2800
|
+
return mt;
|
|
2796
2801
|
},
|
|
2797
2802
|
ZodParsedType: p,
|
|
2798
|
-
getParsedType:
|
|
2799
|
-
ZodType:
|
|
2800
|
-
datetimeRegex:
|
|
2801
|
-
ZodString:
|
|
2802
|
-
ZodNumber:
|
|
2803
|
-
ZodBigInt:
|
|
2804
|
-
ZodBoolean:
|
|
2805
|
-
ZodDate:
|
|
2806
|
-
ZodSymbol:
|
|
2807
|
-
ZodUndefined:
|
|
2808
|
-
ZodNull:
|
|
2809
|
-
ZodAny:
|
|
2810
|
-
ZodUnknown:
|
|
2811
|
-
ZodNever:
|
|
2812
|
-
ZodVoid:
|
|
2813
|
-
ZodArray:
|
|
2803
|
+
getParsedType: ie,
|
|
2804
|
+
ZodType: w,
|
|
2805
|
+
datetimeRegex: Gt,
|
|
2806
|
+
ZodString: J,
|
|
2807
|
+
ZodNumber: fe,
|
|
2808
|
+
ZodBigInt: he,
|
|
2809
|
+
ZodBoolean: $e,
|
|
2810
|
+
ZodDate: we,
|
|
2811
|
+
ZodSymbol: st,
|
|
2812
|
+
ZodUndefined: Fe,
|
|
2813
|
+
ZodNull: De,
|
|
2814
|
+
ZodAny: Ee,
|
|
2815
|
+
ZodUnknown: _e,
|
|
2816
|
+
ZodNever: oe,
|
|
2817
|
+
ZodVoid: rt,
|
|
2818
|
+
ZodArray: K,
|
|
2814
2819
|
ZodObject: S,
|
|
2815
|
-
ZodUnion:
|
|
2816
|
-
ZodDiscriminatedUnion:
|
|
2817
|
-
ZodIntersection:
|
|
2818
|
-
ZodTuple:
|
|
2819
|
-
ZodRecord:
|
|
2820
|
-
ZodMap:
|
|
2821
|
-
ZodSet:
|
|
2822
|
-
ZodFunction:
|
|
2823
|
-
ZodLazy:
|
|
2824
|
-
ZodLiteral:
|
|
2825
|
-
ZodEnum:
|
|
2826
|
-
ZodNativeEnum:
|
|
2827
|
-
ZodPromise:
|
|
2828
|
-
ZodEffects:
|
|
2829
|
-
ZodTransformer:
|
|
2830
|
-
ZodOptional:
|
|
2831
|
-
ZodNullable:
|
|
2832
|
-
ZodDefault:
|
|
2833
|
-
ZodCatch:
|
|
2834
|
-
ZodNaN:
|
|
2820
|
+
ZodUnion: Le,
|
|
2821
|
+
ZodDiscriminatedUnion: ot,
|
|
2822
|
+
ZodIntersection: Ve,
|
|
2823
|
+
ZodTuple: ne,
|
|
2824
|
+
ZodRecord: Ue,
|
|
2825
|
+
ZodMap: at,
|
|
2826
|
+
ZodSet: xe,
|
|
2827
|
+
ZodFunction: Se,
|
|
2828
|
+
ZodLazy: ze,
|
|
2829
|
+
ZodLiteral: We,
|
|
2830
|
+
ZodEnum: pe,
|
|
2831
|
+
ZodNativeEnum: Be,
|
|
2832
|
+
ZodPromise: Oe,
|
|
2833
|
+
ZodEffects: G,
|
|
2834
|
+
ZodTransformer: G,
|
|
2835
|
+
ZodOptional: ee,
|
|
2836
|
+
ZodNullable: me,
|
|
2837
|
+
ZodDefault: qe,
|
|
2838
|
+
ZodCatch: He,
|
|
2839
|
+
ZodNaN: it,
|
|
2835
2840
|
BRAND: Vn,
|
|
2836
|
-
ZodBranded:
|
|
2837
|
-
ZodPipeline:
|
|
2838
|
-
ZodReadonly:
|
|
2841
|
+
ZodBranded: Ot,
|
|
2842
|
+
ZodPipeline: Ge,
|
|
2843
|
+
ZodReadonly: Je,
|
|
2839
2844
|
custom: Yt,
|
|
2840
|
-
Schema:
|
|
2841
|
-
ZodSchema:
|
|
2845
|
+
Schema: w,
|
|
2846
|
+
ZodSchema: w,
|
|
2842
2847
|
late: Un,
|
|
2843
2848
|
get ZodFirstPartyTypeKind() {
|
|
2844
2849
|
return g;
|
|
2845
2850
|
},
|
|
2846
2851
|
coerce: ks,
|
|
2847
|
-
any:
|
|
2852
|
+
any: Gn,
|
|
2848
2853
|
array: es,
|
|
2849
2854
|
bigint: Bn,
|
|
2850
2855
|
boolean: tn,
|
|
2851
2856
|
date: qn,
|
|
2852
2857
|
discriminatedUnion: rs,
|
|
2853
|
-
effect:
|
|
2858
|
+
effect: $t,
|
|
2854
2859
|
enum: hs,
|
|
2855
2860
|
function: ds,
|
|
2856
2861
|
instanceof: zn,
|
|
@@ -2861,7 +2866,7 @@ var C = /* @__PURE__ */ Object.freeze({
|
|
|
2861
2866
|
nan: Wn,
|
|
2862
2867
|
nativeEnum: ps,
|
|
2863
2868
|
never: Yn,
|
|
2864
|
-
null:
|
|
2869
|
+
null: Kn,
|
|
2865
2870
|
nullable: gs,
|
|
2866
2871
|
number: en,
|
|
2867
2872
|
object: ts,
|
|
@@ -2877,7 +2882,7 @@ var C = /* @__PURE__ */ Object.freeze({
|
|
|
2877
2882
|
strictObject: ns,
|
|
2878
2883
|
string: Qt,
|
|
2879
2884
|
symbol: Hn,
|
|
2880
|
-
transformer:
|
|
2885
|
+
transformer: $t,
|
|
2881
2886
|
tuple: is,
|
|
2882
2887
|
undefined: Jn,
|
|
2883
2888
|
union: ss,
|
|
@@ -2886,17 +2891,17 @@ var C = /* @__PURE__ */ Object.freeze({
|
|
|
2886
2891
|
NEVER: Ts,
|
|
2887
2892
|
ZodIssueCode: l,
|
|
2888
2893
|
quotelessJson: gn,
|
|
2889
|
-
ZodError:
|
|
2894
|
+
ZodError: z
|
|
2890
2895
|
});
|
|
2891
|
-
const Ss =
|
|
2892
|
-
language:
|
|
2893
|
-
disableMarkedForExport:
|
|
2896
|
+
const Ss = I.object({
|
|
2897
|
+
language: I.enum(["typescript", "javascript"]).optional(),
|
|
2898
|
+
disableMarkedForExport: I.boolean().optional()
|
|
2894
2899
|
}).and(
|
|
2895
|
-
|
|
2896
|
-
|
|
2897
|
-
framework:
|
|
2898
|
-
model:
|
|
2899
|
-
styling:
|
|
2900
|
+
I.union([
|
|
2901
|
+
I.object({
|
|
2902
|
+
framework: I.literal("react"),
|
|
2903
|
+
model: I.string().optional(),
|
|
2904
|
+
styling: I.enum([
|
|
2900
2905
|
"plain_css",
|
|
2901
2906
|
"css_modules",
|
|
2902
2907
|
"styled_components",
|
|
@@ -2905,19 +2910,19 @@ const Ss = C.object({
|
|
|
2905
2910
|
"scss",
|
|
2906
2911
|
"inline_styles"
|
|
2907
2912
|
]),
|
|
2908
|
-
uiLibrary:
|
|
2909
|
-
enableUILibraryTheming:
|
|
2910
|
-
enableCompactStructure:
|
|
2911
|
-
enableAutoSplit:
|
|
2912
|
-
autoSplitThreshold:
|
|
2913
|
+
uiLibrary: I.enum(["mui", "antd", "radix", "shadcn"]).optional(),
|
|
2914
|
+
enableUILibraryTheming: I.boolean().optional(),
|
|
2915
|
+
enableCompactStructure: I.boolean().optional(),
|
|
2916
|
+
enableAutoSplit: I.boolean().optional(),
|
|
2917
|
+
autoSplitThreshold: I.number().optional()
|
|
2913
2918
|
}),
|
|
2914
|
-
|
|
2915
|
-
framework:
|
|
2916
|
-
styling:
|
|
2917
|
-
enableTranslation:
|
|
2919
|
+
I.object({
|
|
2920
|
+
framework: I.literal("html"),
|
|
2921
|
+
styling: I.enum(["plain_css", "inline_styles"]),
|
|
2922
|
+
enableTranslation: I.boolean().optional()
|
|
2918
2923
|
})
|
|
2919
2924
|
])
|
|
2920
|
-
),
|
|
2925
|
+
), As = (n) => {
|
|
2921
2926
|
const e = Ss.safeParse(n);
|
|
2922
2927
|
if (e.success === !1) {
|
|
2923
2928
|
const t = new Error("Invalid codegen settings");
|
|
@@ -2925,37 +2930,37 @@ const Ss = C.object({
|
|
|
2925
2930
|
}
|
|
2926
2931
|
return e.data;
|
|
2927
2932
|
};
|
|
2928
|
-
var
|
|
2929
|
-
class
|
|
2933
|
+
var V, Ke;
|
|
2934
|
+
class Rr {
|
|
2930
2935
|
constructor({
|
|
2931
2936
|
auth: e,
|
|
2932
2937
|
apiBaseAddress: t = "https://public-api.animaapp.com"
|
|
2933
2938
|
} = {}) {
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2939
|
+
ut(this, V);
|
|
2940
|
+
ut(this, Ke);
|
|
2941
|
+
dt(this, Ke, t), e && (this.auth = e);
|
|
2937
2942
|
}
|
|
2938
2943
|
hasAuth() {
|
|
2939
|
-
return !!
|
|
2944
|
+
return !!H(this, V);
|
|
2940
2945
|
}
|
|
2941
2946
|
set auth(e) {
|
|
2942
|
-
|
|
2947
|
+
dt(this, V, e);
|
|
2943
2948
|
}
|
|
2944
2949
|
get headers() {
|
|
2945
2950
|
const e = {
|
|
2946
2951
|
"Content-Type": "application/json"
|
|
2947
2952
|
};
|
|
2948
|
-
return
|
|
2953
|
+
return H(this, V) && (e.Authorization = `Bearer ${H(this, V).token}`, "teamId" in H(this, V) && (e["X-Team-Id"] = H(this, V).teamId)), e;
|
|
2949
2954
|
}
|
|
2950
2955
|
generateCode(s) {
|
|
2951
|
-
return
|
|
2952
|
-
var _,
|
|
2956
|
+
return F(this, arguments, function* (e, t = {}) {
|
|
2957
|
+
var _, j, O, C, R, B, se, ce, L, ue;
|
|
2953
2958
|
if (this.hasAuth() === !1)
|
|
2954
2959
|
throw new Error('It needs to set "auth" before calling this method.');
|
|
2955
|
-
const r = {}, a =
|
|
2960
|
+
const r = {}, a = As(e.settings);
|
|
2956
2961
|
let i = e.tracking;
|
|
2957
|
-
|
|
2958
|
-
const o = yield fetch(`${
|
|
2962
|
+
H(this, V) && "userId" in H(this, V) && H(this, V).userId && (i != null && i.externalId || (i = { externalId: H(this, V).userId }));
|
|
2963
|
+
const o = yield fetch(`${H(this, Ke)}/v1/codegen`, {
|
|
2959
2964
|
method: "POST",
|
|
2960
2965
|
headers: y(u({}, this.headers), {
|
|
2961
2966
|
Accept: "text/event-stream"
|
|
@@ -2980,20 +2985,31 @@ class Zr {
|
|
|
2980
2985
|
})
|
|
2981
2986
|
});
|
|
2982
2987
|
if (!o.ok) {
|
|
2983
|
-
|
|
2984
|
-
|
|
2985
|
-
|
|
2986
|
-
|
|
2987
|
-
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
name:
|
|
2991
|
-
reason:
|
|
2988
|
+
const q = yield o.json().catch(() => "HTTP error from Anima API");
|
|
2989
|
+
throw typeof q == "string" ? new de({
|
|
2990
|
+
name: q,
|
|
2991
|
+
reason: "Unknown",
|
|
2992
|
+
detail: { status: o.status },
|
|
2993
|
+
status: o.status
|
|
2994
|
+
}) : typeof q != "object" ? new de({
|
|
2995
|
+
name: `Error "${q}"`,
|
|
2996
|
+
reason: "Unknown",
|
|
2997
|
+
detail: { status: o.status },
|
|
2998
|
+
status: o.status
|
|
2999
|
+
}) : ((_ = q.error) == null ? void 0 : _.name) === "ZodError" ? new de({
|
|
3000
|
+
name: "HTTP error from Anima API",
|
|
3001
|
+
reason: "Invalid body payload",
|
|
3002
|
+
detail: q.error.issues,
|
|
3003
|
+
status: o.status
|
|
3004
|
+
}) : new de({
|
|
3005
|
+
name: ((j = q.error) == null ? void 0 : j.name) || "HTTP error from Anima API",
|
|
3006
|
+
reason: "Unknown",
|
|
3007
|
+
detail: { status: o.status },
|
|
2992
3008
|
status: o.status
|
|
2993
3009
|
});
|
|
2994
3010
|
}
|
|
2995
3011
|
if (!o.body)
|
|
2996
|
-
throw new
|
|
3012
|
+
throw new de({
|
|
2997
3013
|
name: "Stream Error",
|
|
2998
3014
|
reason: "Response body is null",
|
|
2999
3015
|
status: o.status
|
|
@@ -3002,73 +3018,73 @@ class Zr {
|
|
|
3002
3018
|
let f = "";
|
|
3003
3019
|
try {
|
|
3004
3020
|
for (; ; ) {
|
|
3005
|
-
const { done:
|
|
3006
|
-
if (
|
|
3021
|
+
const { done: q, value: ct } = yield c.read();
|
|
3022
|
+
if (q)
|
|
3007
3023
|
break;
|
|
3008
|
-
f += d.decode(
|
|
3009
|
-
const
|
|
3024
|
+
f += d.decode(ct, { stream: !0 });
|
|
3025
|
+
const E = f.split(`
|
|
3010
3026
|
`);
|
|
3011
|
-
f =
|
|
3012
|
-
for (const
|
|
3013
|
-
if (!(!
|
|
3014
|
-
let
|
|
3027
|
+
f = E.pop() || "";
|
|
3028
|
+
for (const ye of E)
|
|
3029
|
+
if (!(!ye.trim() || ye.startsWith(":")) && ye.startsWith("data: ")) {
|
|
3030
|
+
let k;
|
|
3015
3031
|
try {
|
|
3016
|
-
|
|
3017
|
-
} catch (
|
|
3032
|
+
k = JSON.parse(ye.slice(6));
|
|
3033
|
+
} catch ($) {
|
|
3018
3034
|
continue;
|
|
3019
3035
|
}
|
|
3020
|
-
switch (
|
|
3036
|
+
switch (k.type) {
|
|
3021
3037
|
case "queueing": {
|
|
3022
|
-
typeof t == "function" ? t(
|
|
3038
|
+
typeof t == "function" ? t(k) : (O = t.onQueueing) == null || O.call(t);
|
|
3023
3039
|
break;
|
|
3024
3040
|
}
|
|
3025
3041
|
case "start": {
|
|
3026
|
-
r.sessionId =
|
|
3042
|
+
r.sessionId = k.sessionId, typeof t == "function" ? t(k) : (C = t.onStart) == null || C.call(t, { sessionId: k.sessionId });
|
|
3027
3043
|
break;
|
|
3028
3044
|
}
|
|
3029
3045
|
case "pre_codegen": {
|
|
3030
|
-
typeof t == "function" ? t(
|
|
3046
|
+
typeof t == "function" ? t(k) : (R = t.onPreCodegen) == null || R.call(t, { message: k.message });
|
|
3031
3047
|
break;
|
|
3032
3048
|
}
|
|
3033
3049
|
case "assets_uploaded": {
|
|
3034
|
-
typeof t == "function" ? t(
|
|
3050
|
+
typeof t == "function" ? t(k) : (B = t.onAssetsUploaded) == null || B.call(t);
|
|
3035
3051
|
break;
|
|
3036
3052
|
}
|
|
3037
3053
|
case "assets_list": {
|
|
3038
|
-
r.assets =
|
|
3054
|
+
r.assets = k.payload.assets, typeof t == "function" ? t(k) : (se = t.onAssetsList) == null || se.call(t, k.payload);
|
|
3039
3055
|
break;
|
|
3040
3056
|
}
|
|
3041
3057
|
case "figma_metadata": {
|
|
3042
|
-
r.figmaFileName =
|
|
3043
|
-
figmaFileName:
|
|
3044
|
-
figmaSelectedFrameName:
|
|
3058
|
+
r.figmaFileName = k.figmaFileName, r.figmaSelectedFrameName = k.figmaSelectedFrameName, typeof t == "function" ? t(k) : (ce = t.onFigmaMetadata) == null || ce.call(t, {
|
|
3059
|
+
figmaFileName: k.figmaFileName,
|
|
3060
|
+
figmaSelectedFrameName: k.figmaSelectedFrameName
|
|
3045
3061
|
});
|
|
3046
3062
|
break;
|
|
3047
3063
|
}
|
|
3048
3064
|
case "generating_code": {
|
|
3049
|
-
|
|
3050
|
-
status:
|
|
3051
|
-
progress:
|
|
3052
|
-
files:
|
|
3065
|
+
k.payload.status === "success" && (r.files = k.payload.files), typeof t == "function" ? t(k) : (L = t.onGeneratingCode) == null || L.call(t, {
|
|
3066
|
+
status: k.payload.status,
|
|
3067
|
+
progress: k.payload.progress,
|
|
3068
|
+
files: k.payload.files
|
|
3053
3069
|
});
|
|
3054
3070
|
break;
|
|
3055
3071
|
}
|
|
3056
3072
|
case "codegen_completed": {
|
|
3057
|
-
typeof t == "function" ? t(
|
|
3073
|
+
typeof t == "function" ? t(k) : (ue = t.onCodegenCompleted) == null || ue.call(t);
|
|
3058
3074
|
break;
|
|
3059
3075
|
}
|
|
3060
3076
|
case "error":
|
|
3061
|
-
throw new
|
|
3062
|
-
name:
|
|
3063
|
-
reason:
|
|
3077
|
+
throw new de({
|
|
3078
|
+
name: k.payload.errorName,
|
|
3079
|
+
reason: k.payload.reason
|
|
3064
3080
|
});
|
|
3065
3081
|
case "done": {
|
|
3066
3082
|
if (!r.files)
|
|
3067
|
-
throw new
|
|
3083
|
+
throw new de({
|
|
3068
3084
|
name: "Invalid response",
|
|
3069
|
-
reason: "No
|
|
3085
|
+
reason: "No code generated"
|
|
3070
3086
|
});
|
|
3071
|
-
return r.tokenUsage =
|
|
3087
|
+
return r.tokenUsage = k.payload.tokenUsage, r;
|
|
3072
3088
|
}
|
|
3073
3089
|
}
|
|
3074
3090
|
}
|
|
@@ -3076,7 +3092,7 @@ class Zr {
|
|
|
3076
3092
|
} finally {
|
|
3077
3093
|
c.cancel();
|
|
3078
3094
|
}
|
|
3079
|
-
throw new
|
|
3095
|
+
throw new de({
|
|
3080
3096
|
name: "Connection",
|
|
3081
3097
|
reason: "Connection closed before the 'done' message",
|
|
3082
3098
|
status: 500
|
|
@@ -3084,7 +3100,7 @@ class Zr {
|
|
|
3084
3100
|
});
|
|
3085
3101
|
}
|
|
3086
3102
|
}
|
|
3087
|
-
|
|
3103
|
+
V = new WeakMap(), Ke = new WeakMap();
|
|
3088
3104
|
const Mr = (n) => {
|
|
3089
3105
|
var e;
|
|
3090
3106
|
if (!n)
|
|
@@ -3098,14 +3114,15 @@ const Mr = (n) => {
|
|
|
3098
3114
|
} catch (t) {
|
|
3099
3115
|
return [!1, "", ""];
|
|
3100
3116
|
}
|
|
3101
|
-
},
|
|
3117
|
+
}, Pr = ({
|
|
3102
3118
|
fileKey: n,
|
|
3103
|
-
nodeId: e
|
|
3119
|
+
nodeId: e,
|
|
3120
|
+
duplicate: t
|
|
3104
3121
|
}) => {
|
|
3105
|
-
const
|
|
3106
|
-
return
|
|
3122
|
+
const s = new URL("https://www.figma.com");
|
|
3123
|
+
return s.pathname = `design/${n}`, t && (s.pathname = `${s.pathname}/duplicate`), e && s.searchParams.set("node-id", e.replace(":", "-")), s;
|
|
3107
3124
|
};
|
|
3108
|
-
class
|
|
3125
|
+
class $r extends Error {
|
|
3109
3126
|
constructor(e, t) {
|
|
3110
3127
|
super(e), this.response = t;
|
|
3111
3128
|
}
|
|
@@ -3118,7 +3135,7 @@ const Fr = ({
|
|
|
3118
3135
|
function r(a) {
|
|
3119
3136
|
if (s.has(a) || !n[a])
|
|
3120
3137
|
return;
|
|
3121
|
-
s.add(a), t[a] = n[a],
|
|
3138
|
+
s.add(a), t[a] = n[a], Es(n[a].content).forEach((o) => {
|
|
3122
3139
|
try {
|
|
3123
3140
|
const c = Os(a, o);
|
|
3124
3141
|
if (c.startsWith("src/")) {
|
|
@@ -3139,7 +3156,7 @@ const Fr = ({
|
|
|
3139
3156
|
a.startsWith(e) ? r(a) : a.startsWith("src/") || (t[a] = i);
|
|
3140
3157
|
}), t;
|
|
3141
3158
|
};
|
|
3142
|
-
function
|
|
3159
|
+
function Es(n) {
|
|
3143
3160
|
const e = /import.*?["']([^"']+)["']/g, t = /export.*from\s+["']([^"']+)["']/g, s = [];
|
|
3144
3161
|
let r;
|
|
3145
3162
|
for (; (r = e.exec(n)) !== null; )
|
|
@@ -3166,46 +3183,46 @@ class Is extends Error {
|
|
|
3166
3183
|
}
|
|
3167
3184
|
}
|
|
3168
3185
|
const sn = "Rate Limit Exceeded";
|
|
3169
|
-
class
|
|
3186
|
+
class js extends Error {
|
|
3170
3187
|
constructor({ fileKey: e }) {
|
|
3171
3188
|
super(sn), this.fileKey = e;
|
|
3172
3189
|
}
|
|
3173
3190
|
}
|
|
3174
3191
|
const rn = "Not Found";
|
|
3175
|
-
class
|
|
3192
|
+
class Ns extends Error {
|
|
3176
3193
|
constructor({ fileKey: e }) {
|
|
3177
3194
|
super(rn), this.fileKey = e;
|
|
3178
3195
|
}
|
|
3179
3196
|
}
|
|
3180
|
-
const
|
|
3181
|
-
class
|
|
3197
|
+
const Zs = (n) => n.message === rn, an = "Unknown Figma API Exception";
|
|
3198
|
+
class Rs extends Error {
|
|
3182
3199
|
constructor({ fileKey: e, cause: t }) {
|
|
3183
3200
|
super(an), this.name = "UnknownFigmaApiException", this.fileKey = e, this.cause = t;
|
|
3184
3201
|
}
|
|
3185
3202
|
}
|
|
3186
|
-
const
|
|
3203
|
+
const Dr = (n) => n.message === an, Ms = (n) => n.message === sn, Ps = (n) => [nn, ...[
|
|
3187
3204
|
"Invalid Figma token",
|
|
3188
3205
|
"Figma token expired"
|
|
3189
3206
|
]].includes(
|
|
3190
3207
|
n.message
|
|
3191
|
-
),
|
|
3208
|
+
), $s = (n, e) => {
|
|
3192
3209
|
var s, r, a, i;
|
|
3193
3210
|
const t = ((s = n == null ? void 0 : n.cause) == null ? void 0 : s.body) || n.body;
|
|
3194
3211
|
throw (t == null ? void 0 : t.status) === 403 ? new Is({
|
|
3195
3212
|
fileKey: e,
|
|
3196
3213
|
reason: (((a = (r = n == null ? void 0 : n.cause) == null ? void 0 : r.body) == null ? void 0 : a.reason) || ((i = n.body) == null ? void 0 : i.reason) || "Access denied").toString()
|
|
3197
|
-
}) : (t == null ? void 0 : t.status) === 429 ? new
|
|
3198
|
-
},
|
|
3199
|
-
var Fs = Object.defineProperty,
|
|
3214
|
+
}) : (t == null ? void 0 : t.status) === 429 ? new js({ fileKey: e }) : (t == null ? void 0 : t.status) === 404 ? new Ns({ fileKey: e }) : new Rs({ fileKey: e, cause: n });
|
|
3215
|
+
}, Lr = (n) => Zs(n) ? "NotFound" : Ms(n) ? "RateLimitExceeded" : Ps(n) ? "FigmaTokenIssue" : "UnknownFigmaApiException";
|
|
3216
|
+
var Fs = Object.defineProperty, Ds = Object.defineProperties, Ls = Object.getOwnPropertyDescriptors, Ft = Object.getOwnPropertySymbols, Vs = Object.prototype.hasOwnProperty, Us = Object.prototype.propertyIsEnumerable, Dt = (n, e) => (e = Symbol[n]) ? e : Symbol.for("Symbol." + n), on = (n) => {
|
|
3200
3217
|
throw TypeError(n);
|
|
3201
|
-
},
|
|
3218
|
+
}, Lt = (n, e, t) => e in n ? Fs(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, U = (n, e) => {
|
|
3202
3219
|
for (var t in e || (e = {}))
|
|
3203
|
-
Vs.call(e, t) &&
|
|
3220
|
+
Vs.call(e, t) && Lt(n, t, e[t]);
|
|
3204
3221
|
if (Ft)
|
|
3205
3222
|
for (var t of Ft(e))
|
|
3206
|
-
Us.call(e, t) &&
|
|
3223
|
+
Us.call(e, t) && Lt(n, t, e[t]);
|
|
3207
3224
|
return n;
|
|
3208
|
-
},
|
|
3225
|
+
}, Ct = (n, e) => Ds(n, Ls(e)), It = (n, e, t) => e.has(n) || on("Cannot " + t), T = (n, e, t) => (It(n, e, "read from private field"), t ? t.call(n) : e.get(n)), W = (n, e, t) => e.has(n) ? on("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(n) : e.set(n, t), N = (n, e, t, s) => (It(n, e, "write to private field"), e.set(n, t), t), Q = (n, e, t) => (It(n, e, "access private method"), t), A = (n, e, t) => new Promise((s, r) => {
|
|
3209
3226
|
var a = (c) => {
|
|
3210
3227
|
try {
|
|
3211
3228
|
o(t.next(c));
|
|
@@ -3220,59 +3237,59 @@ var Fs = Object.defineProperty, Ls = Object.defineProperties, Ds = Object.getOwn
|
|
|
3220
3237
|
}
|
|
3221
3238
|
}, o = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(a, i);
|
|
3222
3239
|
o((t = t.apply(n, e)).next());
|
|
3223
|
-
}), zs = (n, e, t) => (e = n[
|
|
3240
|
+
}), zs = (n, e, t) => (e = n[Dt("asyncIterator")]) ? e.call(n) : (n = n[Dt("iterator")](), e = {}, t = (s, r) => (r = n[s]) && (e[s] = (a) => new Promise((i, o, c) => (a = r.call(n, a), c = a.done, Promise.resolve(a.value).then((d) => i({ value: d, done: c }), o)))), t("next"), t("return"), e), Ws = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {};
|
|
3224
3241
|
function Bs(n) {
|
|
3225
3242
|
return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
|
|
3226
3243
|
}
|
|
3227
|
-
var
|
|
3244
|
+
var _t = { exports: {} }, qs = _t.exports, Vt;
|
|
3228
3245
|
function Hs() {
|
|
3229
3246
|
return Vt || (Vt = 1, function(n, e) {
|
|
3230
3247
|
(function(t, s) {
|
|
3231
3248
|
n.exports = s();
|
|
3232
3249
|
})(qs, function() {
|
|
3233
|
-
var t = typeof Promise == "function", s = typeof self == "object" ? self : Ws, r = typeof Symbol != "undefined", a = typeof Map != "undefined", i = typeof Set != "undefined", o = typeof WeakMap != "undefined", c = typeof WeakSet != "undefined", d = typeof DataView != "undefined", f = r && typeof Symbol.iterator != "undefined", _ = r && typeof Symbol.toStringTag != "undefined",
|
|
3234
|
-
function
|
|
3235
|
-
var
|
|
3236
|
-
if (
|
|
3237
|
-
return
|
|
3238
|
-
if (
|
|
3250
|
+
var t = typeof Promise == "function", s = typeof self == "object" ? self : Ws, r = typeof Symbol != "undefined", a = typeof Map != "undefined", i = typeof Set != "undefined", o = typeof WeakMap != "undefined", c = typeof WeakSet != "undefined", d = typeof DataView != "undefined", f = r && typeof Symbol.iterator != "undefined", _ = r && typeof Symbol.toStringTag != "undefined", j = i && typeof Set.prototype.entries == "function", O = a && typeof Map.prototype.entries == "function", C = j && Object.getPrototypeOf((/* @__PURE__ */ new Set()).entries()), R = O && Object.getPrototypeOf((/* @__PURE__ */ new Map()).entries()), B = f && typeof Array.prototype[Symbol.iterator] == "function", se = B && Object.getPrototypeOf([][Symbol.iterator]()), ce = f && typeof String.prototype[Symbol.iterator] == "function", L = ce && Object.getPrototypeOf(""[Symbol.iterator]()), ue = 8, q = -1;
|
|
3251
|
+
function ct(E) {
|
|
3252
|
+
var ye = typeof E;
|
|
3253
|
+
if (ye !== "object")
|
|
3254
|
+
return ye;
|
|
3255
|
+
if (E === null)
|
|
3239
3256
|
return "null";
|
|
3240
|
-
if (
|
|
3257
|
+
if (E === s)
|
|
3241
3258
|
return "global";
|
|
3242
|
-
if (Array.isArray(
|
|
3259
|
+
if (Array.isArray(E) && (_ === !1 || !(Symbol.toStringTag in E)))
|
|
3243
3260
|
return "Array";
|
|
3244
3261
|
if (typeof window == "object" && window !== null) {
|
|
3245
|
-
if (typeof window.location == "object" &&
|
|
3262
|
+
if (typeof window.location == "object" && E === window.location)
|
|
3246
3263
|
return "Location";
|
|
3247
|
-
if (typeof window.document == "object" &&
|
|
3264
|
+
if (typeof window.document == "object" && E === window.document)
|
|
3248
3265
|
return "Document";
|
|
3249
3266
|
if (typeof window.navigator == "object") {
|
|
3250
|
-
if (typeof window.navigator.mimeTypes == "object" &&
|
|
3267
|
+
if (typeof window.navigator.mimeTypes == "object" && E === window.navigator.mimeTypes)
|
|
3251
3268
|
return "MimeTypeArray";
|
|
3252
|
-
if (typeof window.navigator.plugins == "object" &&
|
|
3269
|
+
if (typeof window.navigator.plugins == "object" && E === window.navigator.plugins)
|
|
3253
3270
|
return "PluginArray";
|
|
3254
3271
|
}
|
|
3255
|
-
if ((typeof window.HTMLElement == "function" || typeof window.HTMLElement == "object") &&
|
|
3256
|
-
if (
|
|
3272
|
+
if ((typeof window.HTMLElement == "function" || typeof window.HTMLElement == "object") && E instanceof window.HTMLElement) {
|
|
3273
|
+
if (E.tagName === "BLOCKQUOTE")
|
|
3257
3274
|
return "HTMLQuoteElement";
|
|
3258
|
-
if (
|
|
3275
|
+
if (E.tagName === "TD")
|
|
3259
3276
|
return "HTMLTableDataCellElement";
|
|
3260
|
-
if (
|
|
3277
|
+
if (E.tagName === "TH")
|
|
3261
3278
|
return "HTMLTableHeaderCellElement";
|
|
3262
3279
|
}
|
|
3263
3280
|
}
|
|
3264
|
-
var
|
|
3265
|
-
if (typeof
|
|
3266
|
-
return
|
|
3267
|
-
var
|
|
3268
|
-
return
|
|
3281
|
+
var k = _ && E[Symbol.toStringTag];
|
|
3282
|
+
if (typeof k == "string")
|
|
3283
|
+
return k;
|
|
3284
|
+
var $ = Object.getPrototypeOf(E);
|
|
3285
|
+
return $ === RegExp.prototype ? "RegExp" : $ === Date.prototype ? "Date" : t && $ === Promise.prototype ? "Promise" : i && $ === Set.prototype ? "Set" : a && $ === Map.prototype ? "Map" : c && $ === WeakSet.prototype ? "WeakSet" : o && $ === WeakMap.prototype ? "WeakMap" : d && $ === DataView.prototype ? "DataView" : a && $ === R ? "Map Iterator" : i && $ === C ? "Set Iterator" : B && $ === se ? "Array Iterator" : ce && $ === L ? "String Iterator" : $ === null ? "Object" : Object.prototype.toString.call(E).slice(ue, q);
|
|
3269
3286
|
}
|
|
3270
|
-
return
|
|
3287
|
+
return ct;
|
|
3271
3288
|
});
|
|
3272
|
-
}(
|
|
3289
|
+
}(_t)), _t.exports;
|
|
3273
3290
|
}
|
|
3274
3291
|
var Js = Hs();
|
|
3275
|
-
const
|
|
3292
|
+
const Ks = /* @__PURE__ */ Bs(Js), jt = typeof Buffer != "undefined", Gs = jt && typeof Buffer.from != "undefined", Xs = jt ? (
|
|
3276
3293
|
/**
|
|
3277
3294
|
* is value is Buffer?
|
|
3278
3295
|
*
|
|
@@ -3293,7 +3310,7 @@ const Gs = /* @__PURE__ */ Bs(Js), It = typeof Buffer != "undefined", Ks = It &&
|
|
|
3293
3310
|
function() {
|
|
3294
3311
|
return !1;
|
|
3295
3312
|
}
|
|
3296
|
-
), Ys =
|
|
3313
|
+
), Ys = Gs ? (
|
|
3297
3314
|
/**
|
|
3298
3315
|
* copy Buffer
|
|
3299
3316
|
*
|
|
@@ -3303,7 +3320,7 @@ const Gs = /* @__PURE__ */ Bs(Js), It = typeof Buffer != "undefined", Ks = It &&
|
|
|
3303
3320
|
function(n) {
|
|
3304
3321
|
return Buffer.from(n);
|
|
3305
3322
|
}
|
|
3306
|
-
) :
|
|
3323
|
+
) : jt ? (
|
|
3307
3324
|
/**
|
|
3308
3325
|
* copy Buffer
|
|
3309
3326
|
*
|
|
@@ -3328,8 +3345,8 @@ const Gs = /* @__PURE__ */ Bs(Js), It = typeof Buffer != "undefined", Ks = It &&
|
|
|
3328
3345
|
return n;
|
|
3329
3346
|
}
|
|
3330
3347
|
);
|
|
3331
|
-
function
|
|
3332
|
-
return Xs(n) ? "Buffer" :
|
|
3348
|
+
function Ce(n) {
|
|
3349
|
+
return Xs(n) ? "Buffer" : Ks(n);
|
|
3333
3350
|
}
|
|
3334
3351
|
const Qs = /* @__PURE__ */ new Set([
|
|
3335
3352
|
"Arguments",
|
|
@@ -3339,7 +3356,7 @@ const Qs = /* @__PURE__ */ new Set([
|
|
|
3339
3356
|
"Set"
|
|
3340
3357
|
]);
|
|
3341
3358
|
function er(n, e, t = null) {
|
|
3342
|
-
switch (t ||
|
|
3359
|
+
switch (t || Ce(n)) {
|
|
3343
3360
|
case "Arguments":
|
|
3344
3361
|
case "Array":
|
|
3345
3362
|
case "Object":
|
|
@@ -3350,11 +3367,11 @@ function er(n, e, t = null) {
|
|
|
3350
3367
|
return e;
|
|
3351
3368
|
}
|
|
3352
3369
|
}
|
|
3353
|
-
function
|
|
3370
|
+
function bt(n) {
|
|
3354
3371
|
return Qs.has(n);
|
|
3355
3372
|
}
|
|
3356
3373
|
function Ut(n, e, t, s = null) {
|
|
3357
|
-
switch (s ||
|
|
3374
|
+
switch (s || Ce(n)) {
|
|
3358
3375
|
case "Arguments":
|
|
3359
3376
|
case "Array":
|
|
3360
3377
|
case "Object":
|
|
@@ -3369,7 +3386,7 @@ function Ut(n, e, t, s = null) {
|
|
|
3369
3386
|
}
|
|
3370
3387
|
return n;
|
|
3371
3388
|
}
|
|
3372
|
-
const tr = typeof globalThis != "undefined" && globalThis !== null && globalThis.Object === Object && globalThis, nr = typeof global != "undefined" && global !== null && global.Object === Object && global, sr = typeof self != "undefined" && self !== null && self.Object === Object && self,
|
|
3389
|
+
const tr = typeof globalThis != "undefined" && globalThis !== null && globalThis.Object === Object && globalThis, nr = typeof global != "undefined" && global !== null && global.Object === Object && global, sr = typeof self != "undefined" && self !== null && self.Object === Object && self, ft = tr || nr || sr || Function("return this")();
|
|
3373
3390
|
function rr(n) {
|
|
3374
3391
|
return n.slice(0);
|
|
3375
3392
|
}
|
|
@@ -3394,8 +3411,8 @@ function dr(n) {
|
|
|
3394
3411
|
function lr(n) {
|
|
3395
3412
|
return new String(n);
|
|
3396
3413
|
}
|
|
3397
|
-
function
|
|
3398
|
-
return
|
|
3414
|
+
function re(n, e) {
|
|
3415
|
+
return ft[e].from ? ft[e].from(n) : new ft[e](n);
|
|
3399
3416
|
}
|
|
3400
3417
|
function M(n) {
|
|
3401
3418
|
return n;
|
|
@@ -3424,15 +3441,15 @@ const mr = /* @__PURE__ */ new Map([
|
|
|
3424
3441
|
["String", lr],
|
|
3425
3442
|
// typed arrays
|
|
3426
3443
|
// TODO: pass bound function
|
|
3427
|
-
["Float32Array",
|
|
3428
|
-
["Float64Array",
|
|
3429
|
-
["Int16Array",
|
|
3430
|
-
["Int32Array",
|
|
3431
|
-
["Int8Array",
|
|
3432
|
-
["Uint16Array",
|
|
3433
|
-
["Uint32Array",
|
|
3434
|
-
["Uint8Array",
|
|
3435
|
-
["Uint8ClampedArray",
|
|
3444
|
+
["Float32Array", re],
|
|
3445
|
+
["Float64Array", re],
|
|
3446
|
+
["Int16Array", re],
|
|
3447
|
+
["Int32Array", re],
|
|
3448
|
+
["Int8Array", re],
|
|
3449
|
+
["Uint16Array", re],
|
|
3450
|
+
["Uint32Array", re],
|
|
3451
|
+
["Uint8Array", re],
|
|
3452
|
+
["Uint8ClampedArray", re],
|
|
3436
3453
|
// shallow copy
|
|
3437
3454
|
["Array Iterator", M],
|
|
3438
3455
|
["Map Iterator", M],
|
|
@@ -3471,9 +3488,9 @@ const mr = /* @__PURE__ */ new Map([
|
|
|
3471
3488
|
]);
|
|
3472
3489
|
function yr() {
|
|
3473
3490
|
}
|
|
3474
|
-
function
|
|
3491
|
+
function wt(n, e = null, t = yr) {
|
|
3475
3492
|
arguments.length === 2 && typeof e == "function" && (t = e, e = null);
|
|
3476
|
-
const s = e ||
|
|
3493
|
+
const s = e || Ce(n), r = mr.get(s);
|
|
3477
3494
|
if (s === "Object") {
|
|
3478
3495
|
const a = t(n, s);
|
|
3479
3496
|
if (a !== void 0)
|
|
@@ -3481,7 +3498,7 @@ function bt(n, e = null, t = yr) {
|
|
|
3481
3498
|
}
|
|
3482
3499
|
return r ? r(n, s) : n;
|
|
3483
3500
|
}
|
|
3484
|
-
function
|
|
3501
|
+
function Ie(n, e = {}) {
|
|
3485
3502
|
typeof e == "function" && (e = {
|
|
3486
3503
|
customizer: e
|
|
3487
3504
|
});
|
|
@@ -3490,15 +3507,15 @@ function Oe(n, e = {}) {
|
|
|
3490
3507
|
customizer: t
|
|
3491
3508
|
// TODO: max depth
|
|
3492
3509
|
// depth = Infinity,
|
|
3493
|
-
} = e, s =
|
|
3494
|
-
if (!
|
|
3495
|
-
return
|
|
3496
|
-
const r =
|
|
3497
|
-
return
|
|
3498
|
-
}
|
|
3499
|
-
function
|
|
3500
|
-
const a =
|
|
3501
|
-
if (!
|
|
3510
|
+
} = e, s = Ce(n);
|
|
3511
|
+
if (!bt(s))
|
|
3512
|
+
return xt(n, null, null, null);
|
|
3513
|
+
const r = wt(n, s, t), a = new WeakMap([[n, r]]), i = new WeakSet([n]);
|
|
3514
|
+
return xt(n, r, a, i);
|
|
3515
|
+
}
|
|
3516
|
+
function xt(n, e, t, s, r) {
|
|
3517
|
+
const a = Ce(n), i = wt(n, a);
|
|
3518
|
+
if (!bt(a))
|
|
3502
3519
|
return i;
|
|
3503
3520
|
let o;
|
|
3504
3521
|
switch (a) {
|
|
@@ -3519,11 +3536,11 @@ function wt(n, e, t, s, r) {
|
|
|
3519
3536
|
if (s.has(d))
|
|
3520
3537
|
Ut(e, c, t.get(d), a);
|
|
3521
3538
|
else {
|
|
3522
|
-
const f =
|
|
3523
|
-
|
|
3539
|
+
const f = Ce(d), _ = wt(d, f);
|
|
3540
|
+
bt(f) && (t.set(d, _), s.add(d)), Ut(
|
|
3524
3541
|
e,
|
|
3525
3542
|
c,
|
|
3526
|
-
|
|
3543
|
+
xt(
|
|
3527
3544
|
d,
|
|
3528
3545
|
_,
|
|
3529
3546
|
t,
|
|
@@ -3536,32 +3553,32 @@ function wt(n, e, t, s, r) {
|
|
|
3536
3553
|
return e;
|
|
3537
3554
|
}
|
|
3538
3555
|
const gr = (n) => new Promise((e) => setTimeout(e, n));
|
|
3539
|
-
var
|
|
3556
|
+
var Xe, ge, Ye, kt, cn;
|
|
3540
3557
|
class vr {
|
|
3541
3558
|
constructor({ maxAttempts: e = 3, func: t }) {
|
|
3542
|
-
|
|
3559
|
+
W(this, kt), W(this, Xe), W(this, ge), W(this, Ye), N(this, Xe, e), N(this, Ye, t), N(this, ge, 0);
|
|
3543
3560
|
}
|
|
3544
3561
|
run() {
|
|
3545
|
-
return
|
|
3562
|
+
return A(this, null, function* () {
|
|
3546
3563
|
try {
|
|
3547
|
-
return yield T(this,
|
|
3564
|
+
return yield T(this, Ye).call(this);
|
|
3548
3565
|
} catch (e) {
|
|
3549
|
-
if (
|
|
3566
|
+
if (N(this, ge, T(this, ge) + 1), T(this, ge) > T(this, Xe))
|
|
3550
3567
|
throw console.error("Max attempts reached"), e;
|
|
3551
|
-
const t =
|
|
3568
|
+
const t = Q(this, kt, cn).call(this);
|
|
3552
3569
|
return yield gr(t), yield this.run();
|
|
3553
3570
|
}
|
|
3554
3571
|
});
|
|
3555
3572
|
}
|
|
3556
3573
|
}
|
|
3557
|
-
|
|
3558
|
-
return T(this,
|
|
3574
|
+
Xe = /* @__PURE__ */ new WeakMap(), ge = /* @__PURE__ */ new WeakMap(), Ye = /* @__PURE__ */ new WeakMap(), kt = /* @__PURE__ */ new WeakSet(), cn = function() {
|
|
3575
|
+
return T(this, ge) * 1e3 * 1.5;
|
|
3559
3576
|
};
|
|
3560
3577
|
function _r() {
|
|
3561
3578
|
return typeof CompressionStream != "undefined";
|
|
3562
3579
|
}
|
|
3563
3580
|
function br(n) {
|
|
3564
|
-
return
|
|
3581
|
+
return A(this, null, function* () {
|
|
3565
3582
|
const e = new Blob([n]).stream().pipeThrough(new CompressionStream("gzip")), t = [];
|
|
3566
3583
|
try {
|
|
3567
3584
|
for (var s = zs(e), r, a, i; r = !(a = yield s.next()).done; r = !1) {
|
|
@@ -3582,7 +3599,7 @@ function br(n) {
|
|
|
3582
3599
|
});
|
|
3583
3600
|
}
|
|
3584
3601
|
function wr(n) {
|
|
3585
|
-
return
|
|
3602
|
+
return A(this, null, function* () {
|
|
3586
3603
|
const e = yield new Blob(n).arrayBuffer();
|
|
3587
3604
|
return new Uint8Array(e);
|
|
3588
3605
|
});
|
|
@@ -3620,7 +3637,7 @@ class Wt extends Error {
|
|
|
3620
3637
|
}
|
|
3621
3638
|
}
|
|
3622
3639
|
}
|
|
3623
|
-
class
|
|
3640
|
+
class Ze extends Error {
|
|
3624
3641
|
constructor(e = {}) {
|
|
3625
3642
|
const { canceled: t = !1 } = e;
|
|
3626
3643
|
super("Abort Error"), this.name = "Abort Error", this.canceled = t;
|
|
@@ -3631,7 +3648,7 @@ class kr extends Error {
|
|
|
3631
3648
|
super(`Async API Error: ${JSON.stringify(e)}`), this.name = "Async API Error", this.body = e;
|
|
3632
3649
|
}
|
|
3633
3650
|
}
|
|
3634
|
-
class
|
|
3651
|
+
class ht extends Error {
|
|
3635
3652
|
constructor(e) {
|
|
3636
3653
|
super(e), this.name = "Request Validation Error";
|
|
3637
3654
|
}
|
|
@@ -3642,14 +3659,14 @@ function un() {
|
|
|
3642
3659
|
() => Math.floor(Math.random() * 256).toString(16).padStart(2, "0")
|
|
3643
3660
|
).join("");
|
|
3644
3661
|
}
|
|
3645
|
-
function
|
|
3662
|
+
function Tt() {
|
|
3646
3663
|
return Math.floor(Date.now() / 1e3).toString();
|
|
3647
3664
|
}
|
|
3648
3665
|
const Tr = 5 * 60 * 1e3, Sr = 1 * 1e3;
|
|
3649
|
-
var
|
|
3650
|
-
class
|
|
3666
|
+
var ve, D, X, St, At, Re;
|
|
3667
|
+
class Ar {
|
|
3651
3668
|
constructor({ fetch: e = globalThis.fetch.bind(globalThis), baseAddress: t }) {
|
|
3652
|
-
|
|
3669
|
+
W(this, X), W(this, ve), W(this, D), this.baseAddress = t, N(this, ve, e), N(this, D, {}), this.plugins = [];
|
|
3653
3670
|
}
|
|
3654
3671
|
get headers() {
|
|
3655
3672
|
throw new Error("Missing implementation");
|
|
@@ -3661,54 +3678,54 @@ class Er {
|
|
|
3661
3678
|
this.plugins = this.plugins.filter((t) => t.name !== e);
|
|
3662
3679
|
}
|
|
3663
3680
|
withOptions(e = {}) {
|
|
3664
|
-
return
|
|
3681
|
+
return N(this, D, e), this;
|
|
3665
3682
|
}
|
|
3666
3683
|
get(e) {
|
|
3667
|
-
return
|
|
3684
|
+
return A(this, arguments, function* (t, s = {}) {
|
|
3668
3685
|
const { overrideBaseAddress: r, overrideDefaultHeaders: a } = s, i = r != null ? r : this.baseAddress;
|
|
3669
3686
|
let o = a != null ? a : this.headers;
|
|
3670
|
-
const c =
|
|
3671
|
-
return
|
|
3687
|
+
const c = Ie(T(this, D));
|
|
3688
|
+
return N(this, D, {}), c.extraHeaders && (o = U(U({}, o), c.extraHeaders)), c.requestValidation && (o = Ct(U({}, o), { "X-Request-Nonce": un(), "X-Request-Timestamp": Tt() })), c.async ? yield Q(this, X, At).call(this, `${i}${t}`, c.async, { headers: o }) : yield Q(this, X, St).call(this, `${i}${t}`, c, { headers: o });
|
|
3672
3689
|
});
|
|
3673
3690
|
}
|
|
3674
3691
|
post(e, t) {
|
|
3675
|
-
return
|
|
3676
|
-
const i =
|
|
3677
|
-
return
|
|
3692
|
+
return A(this, arguments, function* (s, r, a = {}) {
|
|
3693
|
+
const i = Ie(T(this, D));
|
|
3694
|
+
return N(this, D, {}), Q(this, X, Re).call(this, s, "POST", r, a, i);
|
|
3678
3695
|
});
|
|
3679
3696
|
}
|
|
3680
3697
|
put(e, t) {
|
|
3681
|
-
return
|
|
3682
|
-
const i =
|
|
3683
|
-
return
|
|
3698
|
+
return A(this, arguments, function* (s, r, a = {}) {
|
|
3699
|
+
const i = Ie(T(this, D));
|
|
3700
|
+
return N(this, D, {}), Q(this, X, Re).call(this, s, "PUT", r, a, i);
|
|
3684
3701
|
});
|
|
3685
3702
|
}
|
|
3686
3703
|
delete(e, t) {
|
|
3687
|
-
return
|
|
3688
|
-
const i =
|
|
3689
|
-
return
|
|
3704
|
+
return A(this, arguments, function* (s, r, a = {}) {
|
|
3705
|
+
const i = Ie(T(this, D));
|
|
3706
|
+
return N(this, D, {}), Q(this, X, Re).call(this, s, "DELETE", r, a, i);
|
|
3690
3707
|
});
|
|
3691
3708
|
}
|
|
3692
3709
|
patch(e, t) {
|
|
3693
|
-
return
|
|
3694
|
-
const i =
|
|
3695
|
-
return
|
|
3710
|
+
return A(this, arguments, function* (s, r, a = {}) {
|
|
3711
|
+
const i = Ie(T(this, D));
|
|
3712
|
+
return N(this, D, {}), Q(this, X, Re).call(this, s, "PATCH", r, a, i);
|
|
3696
3713
|
});
|
|
3697
3714
|
}
|
|
3698
3715
|
}
|
|
3699
|
-
|
|
3700
|
-
return
|
|
3701
|
-
const s = () =>
|
|
3716
|
+
ve = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakSet(), St = function(n, e, t) {
|
|
3717
|
+
return A(this, null, function* () {
|
|
3718
|
+
const s = () => A(this, null, function* () {
|
|
3702
3719
|
var c, d;
|
|
3703
3720
|
try {
|
|
3704
|
-
return yield T(this,
|
|
3721
|
+
return yield T(this, ve).call(this, n, U(U({}, t), e.abortSignal && { signal: e.abortSignal }));
|
|
3705
3722
|
} catch (f) {
|
|
3706
|
-
throw f instanceof Error && f.name === "AbortError" ? new
|
|
3723
|
+
throw f instanceof Error && f.name === "AbortError" ? new Ze({ canceled: (d = (c = e.abortSignal) == null ? void 0 : c.aborted) != null ? d : !1 }) : f;
|
|
3707
3724
|
}
|
|
3708
3725
|
}), { headers: r } = t != null ? t : {}, a = (c, d) => {
|
|
3709
3726
|
var f, _;
|
|
3710
3727
|
return ((f = c == null ? void 0 : c.headers) == null ? void 0 : f.get(d)) || ((_ = c == null ? void 0 : c.headersObject) == null ? void 0 : _[d]) || "";
|
|
3711
|
-
}, i = (c) =>
|
|
3728
|
+
}, i = (c) => A(this, null, function* () {
|
|
3712
3729
|
var d;
|
|
3713
3730
|
if (!c.ok) {
|
|
3714
3731
|
const _ = yield c.text().catch();
|
|
@@ -3723,15 +3740,15 @@ pe = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), G = /* @_
|
|
|
3723
3740
|
}
|
|
3724
3741
|
if (e.requestValidation && process.env.UI_TESTS !== !0)
|
|
3725
3742
|
try {
|
|
3726
|
-
const _ = a(c, "x-response-nonce"),
|
|
3727
|
-
if (!_ || _ !==
|
|
3728
|
-
throw new
|
|
3729
|
-
const
|
|
3730
|
-
if (isNaN(
|
|
3731
|
-
throw new
|
|
3743
|
+
const _ = a(c, "x-response-nonce"), j = r == null ? void 0 : r["X-Request-Nonce"];
|
|
3744
|
+
if (!_ || _ !== j)
|
|
3745
|
+
throw new ht("Response nonce mismatch");
|
|
3746
|
+
const O = Number(a(c, "x-response-timestamp")), C = Number(Tt()), R = 60 * 60 * 24;
|
|
3747
|
+
if (isNaN(O) || Math.abs(C - O) > R)
|
|
3748
|
+
throw new ht("Invalid response timestamp");
|
|
3732
3749
|
} catch (_) {
|
|
3733
|
-
const
|
|
3734
|
-
throw new
|
|
3750
|
+
const j = _ instanceof Error ? _.message : "Request validation failed";
|
|
3751
|
+
throw new ht(j);
|
|
3735
3752
|
}
|
|
3736
3753
|
let f = yield c.text();
|
|
3737
3754
|
try {
|
|
@@ -3750,8 +3767,8 @@ pe = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), G = /* @_
|
|
|
3750
3767
|
const o = yield s();
|
|
3751
3768
|
return yield i(o);
|
|
3752
3769
|
});
|
|
3753
|
-
},
|
|
3754
|
-
return
|
|
3770
|
+
}, At = function(n, e, t) {
|
|
3771
|
+
return A(this, null, function* () {
|
|
3755
3772
|
var s, r;
|
|
3756
3773
|
const {
|
|
3757
3774
|
onProgress: a,
|
|
@@ -3761,70 +3778,70 @@ pe = /* @__PURE__ */ new WeakMap(), F = /* @__PURE__ */ new WeakMap(), G = /* @_
|
|
|
3761
3778
|
} = e, d = `${n}/async`, f = `${n}/async/job`;
|
|
3762
3779
|
let _;
|
|
3763
3780
|
try {
|
|
3764
|
-
_ = yield T(this,
|
|
3765
|
-
} catch (
|
|
3766
|
-
throw
|
|
3781
|
+
_ = yield T(this, ve).call(this, d, U(U({}, t), i && { signal: i }));
|
|
3782
|
+
} catch (C) {
|
|
3783
|
+
throw C instanceof Error && C.name === "AbortError" ? new Ze({ canceled: (s = i == null ? void 0 : i.aborted) != null ? s : !1 }) : C;
|
|
3767
3784
|
}
|
|
3768
3785
|
if (!_.ok) {
|
|
3769
|
-
const
|
|
3786
|
+
const C = yield _.text().catch();
|
|
3770
3787
|
throw new Wt({
|
|
3771
3788
|
url: n,
|
|
3772
3789
|
method: (r = t == null ? void 0 : t.method) != null ? r : "GET",
|
|
3773
3790
|
statusCode: _.status,
|
|
3774
3791
|
requestHeaders: this.headers,
|
|
3775
3792
|
responseHeaders: _.headers,
|
|
3776
|
-
body:
|
|
3793
|
+
body: C
|
|
3777
3794
|
});
|
|
3778
3795
|
}
|
|
3779
|
-
const
|
|
3780
|
-
if (!
|
|
3796
|
+
const j = yield _.json(), { job_id: O } = j;
|
|
3797
|
+
if (!O)
|
|
3781
3798
|
throw new Error("Job ID not found in response");
|
|
3782
|
-
return new Promise((
|
|
3783
|
-
const
|
|
3784
|
-
|
|
3785
|
-
}, c),
|
|
3799
|
+
return new Promise((C, R) => A(this, null, function* () {
|
|
3800
|
+
const B = setTimeout(() => {
|
|
3801
|
+
R(new Error("Job timed out"));
|
|
3802
|
+
}, c), se = (ce = 0) => A(this, null, function* () {
|
|
3786
3803
|
if (i != null && i.aborted) {
|
|
3787
|
-
clearTimeout(
|
|
3788
|
-
|
|
3789
|
-
}).catch((
|
|
3790
|
-
|
|
3804
|
+
clearTimeout(B), T(this, ve).call(this, `${f}/${O}/cancel`, { method: "POST", headers: this.headers }).then(() => {
|
|
3805
|
+
R(new Ze({ canceled: !0 }));
|
|
3806
|
+
}).catch((L) => {
|
|
3807
|
+
R(new Ze({ canceled: !1 }));
|
|
3791
3808
|
});
|
|
3792
3809
|
return;
|
|
3793
3810
|
}
|
|
3794
3811
|
try {
|
|
3795
|
-
const
|
|
3796
|
-
if (
|
|
3797
|
-
clearTimeout(
|
|
3798
|
-
const
|
|
3799
|
-
|
|
3800
|
-
} else if (
|
|
3801
|
-
clearTimeout(
|
|
3812
|
+
const L = yield (yield T(this, ve).call(this, `${f}/${O}`, { headers: this.headers })).json();
|
|
3813
|
+
if (L.status === "success") {
|
|
3814
|
+
clearTimeout(B);
|
|
3815
|
+
const ue = L.response_json;
|
|
3816
|
+
C(ue);
|
|
3817
|
+
} else if (L.status === "failed")
|
|
3818
|
+
clearTimeout(B), R(new kr(L.response_json));
|
|
3802
3819
|
else {
|
|
3803
|
-
a && a(
|
|
3804
|
-
const
|
|
3805
|
-
setTimeout(() =>
|
|
3820
|
+
a && a(L.response_json);
|
|
3821
|
+
const ue = o(ce);
|
|
3822
|
+
setTimeout(() => se(ce + 1), ue);
|
|
3806
3823
|
}
|
|
3807
|
-
} catch (
|
|
3808
|
-
|
|
3824
|
+
} catch (L) {
|
|
3825
|
+
R(L);
|
|
3809
3826
|
}
|
|
3810
3827
|
});
|
|
3811
|
-
|
|
3828
|
+
se();
|
|
3812
3829
|
}));
|
|
3813
3830
|
});
|
|
3814
|
-
},
|
|
3815
|
-
return
|
|
3831
|
+
}, Re = function(n, e, t, s, r) {
|
|
3832
|
+
return A(this, null, function* () {
|
|
3816
3833
|
const { overrideBaseAddress: a, overrideDefaultHeaders: i } = s, o = a != null ? a : this.baseAddress;
|
|
3817
3834
|
let c = i != null ? i : this.headers;
|
|
3818
|
-
r.extraHeaders && (c =
|
|
3835
|
+
r.extraHeaders && (c = U(U({}, c), r.extraHeaders)), r.requestValidation && (c = Ct(U({}, c), { "X-Request-Nonce": un(), "X-Request-Timestamp": Tt() }));
|
|
3819
3836
|
let d = s.skipBodyJsonStringify ? t : JSON.stringify(t);
|
|
3820
|
-
return r.compress && _r() && (c["Content-Encoding"] = "gzip", d = yield br(d)), r.async ? yield
|
|
3837
|
+
return r.compress && _r() && (c["Content-Encoding"] = "gzip", d = yield br(d)), r.async ? yield Q(this, X, At).call(this, `${o}${n}`, r.async, {
|
|
3821
3838
|
method: e,
|
|
3822
3839
|
headers: c,
|
|
3823
3840
|
body: d
|
|
3824
|
-
}) : yield
|
|
3841
|
+
}) : yield Q(this, X, St).call(this, `${o}${n}`, r, { method: e, headers: c, body: d });
|
|
3825
3842
|
});
|
|
3826
3843
|
};
|
|
3827
|
-
const Bt = (n, e, t, s) => n instanceof
|
|
3844
|
+
const Bt = (n, e, t, s) => n instanceof Ze ? n : new xr({ resource: e, api: String(t), args: s, cause: n }), pt = (n, e) => new Proxy(e, {
|
|
3828
3845
|
get(t, s) {
|
|
3829
3846
|
return (...r) => {
|
|
3830
3847
|
var a;
|
|
@@ -3845,118 +3862,118 @@ const Bt = (n, e, t, s) => n instanceof Ne ? n : new xr({ resource: e, api: Stri
|
|
|
3845
3862
|
};
|
|
3846
3863
|
}
|
|
3847
3864
|
});
|
|
3848
|
-
var
|
|
3849
|
-
class
|
|
3865
|
+
var Me;
|
|
3866
|
+
class Er {
|
|
3850
3867
|
constructor(e) {
|
|
3851
|
-
|
|
3868
|
+
W(this, Me), this.resourceName = "Files", N(this, Me, e);
|
|
3852
3869
|
}
|
|
3853
3870
|
get(e) {
|
|
3854
|
-
return
|
|
3855
|
-
const r = new URLSearchParams(
|
|
3871
|
+
return A(this, arguments, function* ({ fileKey: t, params: s = {} }) {
|
|
3872
|
+
const r = new URLSearchParams(U({
|
|
3856
3873
|
plugin_data: "857346721138427857"
|
|
3857
3874
|
}, s)).toString(), a = `v1/files/${t}?${r}`;
|
|
3858
|
-
return yield T(this,
|
|
3875
|
+
return yield T(this, Me).get(a);
|
|
3859
3876
|
});
|
|
3860
3877
|
}
|
|
3861
3878
|
getImageFills(e) {
|
|
3862
|
-
return
|
|
3879
|
+
return A(this, arguments, function* ({ fileKey: t }) {
|
|
3863
3880
|
var s, r;
|
|
3864
3881
|
const a = `v1/files/${t}/images`;
|
|
3865
|
-
return (r = (s = (yield T(this,
|
|
3882
|
+
return (r = (s = (yield T(this, Me).get(a)).meta) == null ? void 0 : s.images) != null ? r : {};
|
|
3866
3883
|
});
|
|
3867
3884
|
}
|
|
3868
3885
|
}
|
|
3869
|
-
|
|
3886
|
+
Me = /* @__PURE__ */ new WeakMap();
|
|
3870
3887
|
const Or = (n, e, t) => {
|
|
3871
3888
|
const s = e.sort();
|
|
3872
3889
|
return `${n}-${s.join("-")}-${t}`;
|
|
3873
3890
|
}, Cr = (n) => n ? n.ts > Date.now() - 1e3 * 30 : !1;
|
|
3874
|
-
var
|
|
3891
|
+
var Y, Et, dn;
|
|
3875
3892
|
class Ir {
|
|
3876
3893
|
constructor(e) {
|
|
3877
|
-
|
|
3894
|
+
W(this, Et), W(this, Y), this.resourceName = "Images", N(this, Y, e);
|
|
3878
3895
|
}
|
|
3879
3896
|
/**
|
|
3880
3897
|
* Return the URL for the _layer_ images for the given nodes.
|
|
3881
3898
|
* Note: Use the `file.images` API to get the _source_ images used on the node fills, which has better quality.
|
|
3882
3899
|
*/
|
|
3883
3900
|
get(e) {
|
|
3884
|
-
return
|
|
3885
|
-
const i = Or(t, s, r), o = T(this,
|
|
3901
|
+
return A(this, arguments, function* ({ fileKey: t, nodeIds: s, format: r = "jpg", scale: a }) {
|
|
3902
|
+
const i = Or(t, s, r), o = T(this, Y).cache.images.entries.get(i);
|
|
3886
3903
|
if (Cr(o))
|
|
3887
3904
|
return o.result;
|
|
3888
|
-
o && T(this,
|
|
3889
|
-
const c = T(this,
|
|
3905
|
+
o && T(this, Y).cache.images.entries.delete(i);
|
|
3906
|
+
const c = T(this, Y).cache.images.pendingRequests.get(i);
|
|
3890
3907
|
if (c)
|
|
3891
3908
|
return c;
|
|
3892
|
-
const d =
|
|
3893
|
-
T(this,
|
|
3909
|
+
const d = Q(this, Et, dn).call(this, i, t, s, r, a);
|
|
3910
|
+
T(this, Y).cache.images.pendingRequests.set(i, d);
|
|
3894
3911
|
try {
|
|
3895
3912
|
return yield d;
|
|
3896
3913
|
} finally {
|
|
3897
|
-
T(this,
|
|
3914
|
+
T(this, Y).cache.images.pendingRequests.delete(i);
|
|
3898
3915
|
}
|
|
3899
3916
|
});
|
|
3900
3917
|
}
|
|
3901
3918
|
}
|
|
3902
|
-
|
|
3903
|
-
return
|
|
3904
|
-
const a = yield T(this,
|
|
3919
|
+
Y = /* @__PURE__ */ new WeakMap(), Et = /* @__PURE__ */ new WeakSet(), dn = function(n, e, t, s, r) {
|
|
3920
|
+
return A(this, null, function* () {
|
|
3921
|
+
const a = yield T(this, Y).get(
|
|
3905
3922
|
`v1/images/${e}?ids=${t}&format=${s}${r ? `&scale=${r}` : ""}`
|
|
3906
3923
|
);
|
|
3907
|
-
return T(this,
|
|
3924
|
+
return T(this, Y).cache.images.entries.set(n, {
|
|
3908
3925
|
result: a,
|
|
3909
3926
|
ts: Date.now()
|
|
3910
3927
|
}), a;
|
|
3911
3928
|
});
|
|
3912
3929
|
};
|
|
3913
|
-
var
|
|
3914
|
-
class
|
|
3930
|
+
var Qe;
|
|
3931
|
+
class jr {
|
|
3915
3932
|
constructor(e) {
|
|
3916
|
-
|
|
3933
|
+
W(this, Qe), this.resourceName = "Nodes", N(this, Qe, e);
|
|
3917
3934
|
}
|
|
3918
3935
|
get(e) {
|
|
3919
|
-
return
|
|
3920
|
-
const a =
|
|
3936
|
+
return A(this, arguments, function* ({ fileKey: t, nodeIds: s, params: r = {} }) {
|
|
3937
|
+
const a = Ct(U({}, r), {
|
|
3921
3938
|
ids: s.join(",")
|
|
3922
|
-
}), i = new URLSearchParams(
|
|
3939
|
+
}), i = new URLSearchParams(U({
|
|
3923
3940
|
plugin_data: "857346721138427857"
|
|
3924
3941
|
}, a)).toString(), o = `v1/files/${t}/nodes?${i}`;
|
|
3925
|
-
return yield T(this,
|
|
3942
|
+
return yield T(this, Qe).get(o);
|
|
3926
3943
|
});
|
|
3927
3944
|
}
|
|
3928
3945
|
}
|
|
3929
|
-
|
|
3930
|
-
var
|
|
3931
|
-
class ln extends
|
|
3946
|
+
Qe = /* @__PURE__ */ new WeakMap();
|
|
3947
|
+
var le;
|
|
3948
|
+
class ln extends Ar {
|
|
3932
3949
|
constructor({
|
|
3933
3950
|
baseAddress: e = "https://api.figma.com/",
|
|
3934
3951
|
fetch: t = globalThis.fetch.bind(globalThis)
|
|
3935
3952
|
} = {}) {
|
|
3936
|
-
super({ fetch: t, baseAddress: e }),
|
|
3953
|
+
super({ fetch: t, baseAddress: e }), W(this, le, ""), this.cache = {
|
|
3937
3954
|
images: {
|
|
3938
3955
|
entries: /* @__PURE__ */ new Map(),
|
|
3939
3956
|
pendingRequests: /* @__PURE__ */ new Map()
|
|
3940
3957
|
}
|
|
3941
|
-
}, this.files =
|
|
3958
|
+
}, this.files = pt(this, new Er(this)), this.nodes = pt(this, new jr(this)), this.images = pt(this, new Ir(this));
|
|
3942
3959
|
}
|
|
3943
3960
|
set token(e) {
|
|
3944
3961
|
if (!e.startsWith("figd_") && !e.startsWith("figu_"))
|
|
3945
3962
|
throw new Error("Invalid Figma access token");
|
|
3946
|
-
|
|
3963
|
+
N(this, le, e);
|
|
3947
3964
|
}
|
|
3948
3965
|
get token() {
|
|
3949
|
-
return T(this,
|
|
3966
|
+
return T(this, le);
|
|
3950
3967
|
}
|
|
3951
3968
|
get headers() {
|
|
3952
3969
|
const e = {
|
|
3953
3970
|
"Content-Type": "application/json"
|
|
3954
3971
|
};
|
|
3955
|
-
return T(this,
|
|
3972
|
+
return T(this, le).startsWith("figd_") ? e["X-FIGMA-TOKEN"] = T(this, le) : T(this, le).startsWith("figu_") && (e.Authorization = `Bearer ${T(this, le)}`), e;
|
|
3956
3973
|
}
|
|
3957
3974
|
}
|
|
3958
|
-
|
|
3959
|
-
const Vr = (r) =>
|
|
3975
|
+
le = /* @__PURE__ */ new WeakMap();
|
|
3976
|
+
const Vr = (r) => F(void 0, [r], function* ({
|
|
3960
3977
|
fileKey: n,
|
|
3961
3978
|
authToken: e,
|
|
3962
3979
|
figmaRestApi: t = new ln(),
|
|
@@ -3971,7 +3988,7 @@ const Vr = (r) => P(void 0, [r], function* ({
|
|
|
3971
3988
|
} catch (a) {
|
|
3972
3989
|
throw console.error(a), a;
|
|
3973
3990
|
}
|
|
3974
|
-
}), Ur = (a) =>
|
|
3991
|
+
}), Ur = (a) => F(void 0, [a], function* ({
|
|
3975
3992
|
fileKey: n,
|
|
3976
3993
|
authToken: e,
|
|
3977
3994
|
nodeIds: t,
|
|
@@ -3986,15 +4003,12 @@ const Vr = (r) => P(void 0, [r], function* ({
|
|
|
3986
4003
|
params: u({}, r)
|
|
3987
4004
|
})).nodes;
|
|
3988
4005
|
} catch (i) {
|
|
3989
|
-
return
|
|
4006
|
+
return $s(i, n);
|
|
3990
4007
|
}
|
|
3991
|
-
}),
|
|
4008
|
+
}), Nr = (n, e) => new ReadableStream({
|
|
3992
4009
|
start(t) {
|
|
3993
4010
|
n.generateCode(e, (s) => {
|
|
3994
|
-
s.type === "error"
|
|
3995
|
-
type: "error",
|
|
3996
|
-
payload: { message: s.payload.reason }
|
|
3997
|
-
})) : t.enqueue(s), (s.type === "aborted" || s.type === "error") && t.close();
|
|
4011
|
+
s.type === "error" || t.enqueue(s), (s.type === "aborted" || s.type === "error") && t.close();
|
|
3998
4012
|
}).then((s) => {
|
|
3999
4013
|
t.enqueue({
|
|
4000
4014
|
type: "done",
|
|
@@ -4007,32 +4021,34 @@ const Vr = (r) => P(void 0, [r], function* ({
|
|
|
4007
4021
|
t.enqueue({
|
|
4008
4022
|
type: "error",
|
|
4009
4023
|
payload: {
|
|
4024
|
+
name: "name" in s ? s.name : "Unknown error",
|
|
4010
4025
|
message: "message" in s ? s.message : "Unknown",
|
|
4011
|
-
status: "status" in s ? s.status : void 0
|
|
4026
|
+
status: "status" in s ? s.status : void 0,
|
|
4027
|
+
detail: "detail" in s ? s.detail : void 0
|
|
4012
4028
|
}
|
|
4013
4029
|
}), t.close();
|
|
4014
4030
|
});
|
|
4015
4031
|
}
|
|
4016
|
-
}), zr = (n, e) =>
|
|
4017
|
-
var c, d, f, _,
|
|
4018
|
-
const t =
|
|
4032
|
+
}), zr = (n, e) => F(void 0, null, function* () {
|
|
4033
|
+
var c, d, f, _, j, O, C;
|
|
4034
|
+
const t = Nr(n, e), [s, r] = t.tee(), a = yield s.getReader().read();
|
|
4019
4035
|
if (a.done || !a.value || ((c = a.value) == null ? void 0 : c.type) === "error" && ((f = (d = a.value) == null ? void 0 : d.payload) != null && f.status))
|
|
4020
4036
|
return new Response(JSON.stringify(a.value), {
|
|
4021
|
-
status: ((_ = a.value) == null ? void 0 : _.type) === "error" && (
|
|
4037
|
+
status: ((_ = a.value) == null ? void 0 : _.type) === "error" && (C = (O = (j = a.value) == null ? void 0 : j.payload) == null ? void 0 : O.status) != null ? C : 500,
|
|
4022
4038
|
headers: {
|
|
4023
4039
|
"Content-Type": "application/json"
|
|
4024
4040
|
}
|
|
4025
4041
|
});
|
|
4026
4042
|
const i = new TextEncoder(), o = r.pipeThrough(
|
|
4027
4043
|
new TransformStream({
|
|
4028
|
-
transform(
|
|
4029
|
-
const
|
|
4044
|
+
transform(R, B) {
|
|
4045
|
+
const se = `event: ${R.type}
|
|
4030
4046
|
data: ${JSON.stringify(
|
|
4031
|
-
|
|
4047
|
+
R
|
|
4032
4048
|
)}
|
|
4033
4049
|
|
|
4034
4050
|
`;
|
|
4035
|
-
|
|
4051
|
+
B.enqueue(i.encode(se));
|
|
4036
4052
|
}
|
|
4037
4053
|
})
|
|
4038
4054
|
);
|
|
@@ -4046,26 +4062,26 @@ data: ${JSON.stringify(
|
|
|
4046
4062
|
});
|
|
4047
4063
|
});
|
|
4048
4064
|
export {
|
|
4049
|
-
|
|
4050
|
-
|
|
4065
|
+
Rr as Anima,
|
|
4066
|
+
de as CodegenError,
|
|
4051
4067
|
Is as FigmaTokenIssue,
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4068
|
+
Ns as NotFound,
|
|
4069
|
+
js as RateLimitExceeded,
|
|
4070
|
+
$r as ResponseError,
|
|
4071
|
+
Rs as UnknownFigmaApiException,
|
|
4056
4072
|
zr as createCodegenResponseEventStream,
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
|
|
4073
|
+
Nr as createCodegenStream,
|
|
4074
|
+
Pr as formatToFigmaLink,
|
|
4075
|
+
Lr as getFigmaApiErrorType,
|
|
4060
4076
|
Vr as getFigmaFile,
|
|
4061
4077
|
Ur as getFileNodes,
|
|
4062
4078
|
Fr as getRelatedScreenFiles,
|
|
4063
|
-
|
|
4064
|
-
|
|
4065
|
-
|
|
4079
|
+
$s as handleFigmaApiError,
|
|
4080
|
+
Ps as isFigmaTokenIssue,
|
|
4081
|
+
Zs as isNotFound,
|
|
4066
4082
|
Ms as isRateLimitExceeded,
|
|
4067
|
-
|
|
4083
|
+
Dr as isUnknownFigmaApiException,
|
|
4068
4084
|
Mr as isValidFigmaUrl,
|
|
4069
|
-
|
|
4085
|
+
As as validateSettings
|
|
4070
4086
|
};
|
|
4071
4087
|
//# sourceMappingURL=index.js.map
|