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