@animaapp/anima-sdk 0.6.4 → 0.6.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +122 -25
- package/dist/index.js +487 -455
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
var xr = Object.defineProperty, kr = Object.defineProperties;
|
|
2
2
|
var Tr = Object.getOwnPropertyDescriptors;
|
|
3
|
-
var
|
|
3
|
+
var Ft = Object.getOwnPropertySymbols;
|
|
4
4
|
var Sr = Object.prototype.hasOwnProperty, Er = Object.prototype.propertyIsEnumerable;
|
|
5
|
-
var
|
|
5
|
+
var Vt = (r) => {
|
|
6
6
|
throw TypeError(r);
|
|
7
7
|
};
|
|
8
|
-
var
|
|
8
|
+
var Lt = (r, e, t) => e in r ? xr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, u = (r, e) => {
|
|
9
9
|
for (var t in e || (e = {}))
|
|
10
|
-
Sr.call(e, t) &&
|
|
11
|
-
if (
|
|
12
|
-
for (var t of
|
|
13
|
-
Er.call(e, t) &&
|
|
10
|
+
Sr.call(e, t) && Lt(r, t, e[t]);
|
|
11
|
+
if (Ft)
|
|
12
|
+
for (var t of Ft(e))
|
|
13
|
+
Er.call(e, t) && Lt(r, t, e[t]);
|
|
14
14
|
return r;
|
|
15
15
|
}, g = (r, e) => kr(r, Tr(e));
|
|
16
|
-
var
|
|
17
|
-
var
|
|
16
|
+
var ht = (r, e, t) => e.has(r) || Vt("Cannot " + t);
|
|
17
|
+
var N = (r, e, t) => (ht(r, e, "read from private field"), t ? t.call(r) : e.get(r)), Qe = (r, e, t) => e.has(r) ? Vt("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), pt = (r, e, t, s) => (ht(r, e, "write to private field"), s ? s.call(r, t) : e.set(r, t), t), Ne = (r, e, t) => (ht(r, e, "access private method"), t);
|
|
18
18
|
var C = (r, e, t) => new Promise((s, n) => {
|
|
19
19
|
var a = (c) => {
|
|
20
20
|
try {
|
|
@@ -41,46 +41,46 @@ class de extends Error {
|
|
|
41
41
|
super(), this.name = e, this.message = t, this.detail = n, this.status = s;
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
const
|
|
44
|
+
const Qt = "Figma Token Issue";
|
|
45
45
|
class Ar extends Error {
|
|
46
46
|
constructor({
|
|
47
47
|
fileKey: e,
|
|
48
48
|
reason: t,
|
|
49
49
|
cause: s
|
|
50
50
|
}) {
|
|
51
|
-
super(
|
|
51
|
+
super(Qt), this.fileKey = e, this.reason = t, this.cause = s;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
|
-
const
|
|
55
|
-
class
|
|
54
|
+
const er = "Rate Limit Exceeded";
|
|
55
|
+
class Cr extends Error {
|
|
56
56
|
constructor({ fileKey: e, cause: t }) {
|
|
57
|
-
super(
|
|
57
|
+
super(er), this.fileKey = e, this.cause = t;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
|
-
const
|
|
61
|
-
class
|
|
60
|
+
const tr = "Request Too Large";
|
|
61
|
+
class Or extends Error {
|
|
62
62
|
constructor({ fileKey: e, cause: t }) {
|
|
63
|
-
super(
|
|
63
|
+
super(tr), this.fileKey = e, this.cause = t;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
const
|
|
67
|
-
class
|
|
66
|
+
const rr = "Not Found";
|
|
67
|
+
class Ir extends Error {
|
|
68
68
|
constructor({ fileKey: e, cause: t }) {
|
|
69
|
-
super(
|
|
69
|
+
super(rr), this.fileKey = e, this.cause = t;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
const
|
|
72
|
+
const Nr = (r) => r.message === rr, sr = "Unknown Figma API Exception";
|
|
73
73
|
class jr extends Error {
|
|
74
74
|
constructor({ fileKey: e, cause: t }) {
|
|
75
|
-
super(
|
|
75
|
+
super(sr), this.name = "UnknownFigmaApiException", this.fileKey = e, this.cause = t;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
|
-
const
|
|
78
|
+
const Kn = (r) => r.message === sr, Rr = (r) => r.message === er, Zr = (r) => [Qt, ...[
|
|
79
79
|
"Invalid Figma token",
|
|
80
80
|
"Figma token expired"
|
|
81
81
|
]].includes(
|
|
82
82
|
r.message
|
|
83
|
-
), Mr = (r) => r.message ===
|
|
83
|
+
), Mr = (r) => r.message === tr, nr = (r, e) => {
|
|
84
84
|
var s;
|
|
85
85
|
if (((s = r == null ? void 0 : r.cause) == null ? void 0 : s.message) === "Fetch Error") {
|
|
86
86
|
const { err: n, status: a } = r.cause.body;
|
|
@@ -91,24 +91,24 @@ const Gn = (r) => r.message === tr, Rr = (r) => r.message === Yt, Zr = (r) => [X
|
|
|
91
91
|
cause: r
|
|
92
92
|
});
|
|
93
93
|
if (a === 429)
|
|
94
|
-
return new
|
|
94
|
+
return new Cr({ fileKey: e, cause: r });
|
|
95
95
|
if (a === 404)
|
|
96
|
-
return new
|
|
96
|
+
return new Ir({ fileKey: e, cause: r });
|
|
97
97
|
if (a === 400 && n.includes("Request too large"))
|
|
98
|
-
return new
|
|
98
|
+
return new Or({ fileKey: e, cause: r });
|
|
99
99
|
}
|
|
100
100
|
return new jr({ fileKey: e, cause: r });
|
|
101
|
-
},
|
|
102
|
-
var Pr = Object.defineProperty, $r = Object.defineProperties, Fr = Object.getOwnPropertyDescriptors,
|
|
101
|
+
}, Xn = (r) => Nr(r) ? "NotFound" : Rr(r) ? "RateLimitExceeded" : Zr(r) ? "FigmaTokenIssue" : Mr(r) ? "RequestTooLarge" : "UnknownFigmaApiException";
|
|
102
|
+
var Pr = Object.defineProperty, $r = Object.defineProperties, Fr = Object.getOwnPropertyDescriptors, Dt = Object.getOwnPropertySymbols, Lr = Object.prototype.hasOwnProperty, Vr = Object.prototype.propertyIsEnumerable, Ut = (r, e) => (e = Symbol[r]) ? e : Symbol.for("Symbol." + r), ar = (r) => {
|
|
103
103
|
throw TypeError(r);
|
|
104
|
-
},
|
|
104
|
+
}, Wt = (r, e, t) => e in r ? Pr(r, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : r[e] = t, U = (r, e) => {
|
|
105
105
|
for (var t in e || (e = {}))
|
|
106
|
-
Lr.call(e, t) &&
|
|
107
|
-
if (
|
|
108
|
-
for (var t of
|
|
109
|
-
Vr.call(e, t) &&
|
|
106
|
+
Lr.call(e, t) && Wt(r, t, e[t]);
|
|
107
|
+
if (Dt)
|
|
108
|
+
for (var t of Dt(e))
|
|
109
|
+
Vr.call(e, t) && Wt(r, t, e[t]);
|
|
110
110
|
return r;
|
|
111
|
-
}, jt = (r, e) => $r(r, Fr(e)), Rt = (r, e, t) => e.has(r) ||
|
|
111
|
+
}, jt = (r, e) => $r(r, Fr(e)), Rt = (r, e, t) => e.has(r) || ar("Cannot " + t), T = (r, e, t) => (Rt(r, e, "read from private field"), t ? t.call(r) : e.get(r)), B = (r, e, t) => e.has(r) ? ar("Cannot add the same private member more than once") : e instanceof WeakSet ? e.add(r) : e.set(r, t), R = (r, e, t, s) => (Rt(r, e, "write to private field"), e.set(r, t), t), Q = (r, e, t) => (Rt(r, e, "access private method"), t), I = (r, e, t) => new Promise((s, n) => {
|
|
112
112
|
var a = (c) => {
|
|
113
113
|
try {
|
|
114
114
|
o(t.next(c));
|
|
@@ -123,18 +123,18 @@ var Pr = Object.defineProperty, $r = Object.defineProperties, Fr = Object.getOwn
|
|
|
123
123
|
}
|
|
124
124
|
}, o = (c) => c.done ? s(c.value) : Promise.resolve(c.value).then(a, i);
|
|
125
125
|
o((t = t.apply(r, e)).next());
|
|
126
|
-
}), Dr = (r, e, t) => (e = r[
|
|
127
|
-
function
|
|
126
|
+
}), Dr = (r, e, t) => (e = r[Ut("asyncIterator")]) ? e.call(r) : (r = r[Ut("iterator")](), e = {}, t = (s, n) => (n = r[s]) && (e[s] = (a) => new Promise((i, o, c) => (a = n.call(r, a), c = a.done, Promise.resolve(a.value).then((d) => i({ value: d, done: c }), o)))), t("next"), t("return"), e), Ur = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {};
|
|
127
|
+
function Wr(r) {
|
|
128
128
|
return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
|
|
129
129
|
}
|
|
130
|
-
var
|
|
130
|
+
var _t = { exports: {} }, zr = _t.exports, zt;
|
|
131
131
|
function Br() {
|
|
132
|
-
return
|
|
132
|
+
return zt || (zt = 1, function(r, e) {
|
|
133
133
|
(function(t, s) {
|
|
134
134
|
r.exports = s();
|
|
135
|
-
})(
|
|
136
|
-
var t = typeof Promise == "function", s = typeof self == "object" ? self : Ur, n = typeof Symbol != "undefined", a = typeof Map != "undefined", i = typeof Set != "undefined", o = typeof WeakMap != "undefined", c = typeof WeakSet != "undefined", d = typeof DataView != "undefined", f = n && typeof Symbol.iterator != "undefined", v = n && typeof Symbol.toStringTag != "undefined",
|
|
137
|
-
function
|
|
135
|
+
})(zr, function() {
|
|
136
|
+
var t = typeof Promise == "function", s = typeof self == "object" ? self : Ur, n = typeof Symbol != "undefined", a = typeof Map != "undefined", i = typeof Set != "undefined", o = typeof WeakMap != "undefined", c = typeof WeakSet != "undefined", d = typeof DataView != "undefined", f = n && typeof Symbol.iterator != "undefined", v = n && typeof Symbol.toStringTag != "undefined", j = i && typeof Set.prototype.entries == "function", M = a && typeof Map.prototype.entries == "function", F = j && Object.getPrototypeOf((/* @__PURE__ */ new Set()).entries()), z = M && Object.getPrototypeOf((/* @__PURE__ */ new Map()).entries()), se = f && typeof Array.prototype[Symbol.iterator] == "function", ge = se && Object.getPrototypeOf([][Symbol.iterator]()), ce = f && typeof String.prototype[Symbol.iterator] == "function", V = ce && Object.getPrototypeOf(""[Symbol.iterator]()), K = 8, q = -1;
|
|
137
|
+
function Ie(A) {
|
|
138
138
|
var k = typeof A;
|
|
139
139
|
if (k !== "object")
|
|
140
140
|
return k;
|
|
@@ -164,18 +164,18 @@ function Br() {
|
|
|
164
164
|
return "HTMLTableHeaderCellElement";
|
|
165
165
|
}
|
|
166
166
|
}
|
|
167
|
-
var
|
|
168
|
-
if (typeof
|
|
169
|
-
return
|
|
167
|
+
var ft = v && A[Symbol.toStringTag];
|
|
168
|
+
if (typeof ft == "string")
|
|
169
|
+
return ft;
|
|
170
170
|
var D = Object.getPrototypeOf(A);
|
|
171
|
-
return D === RegExp.prototype ? "RegExp" : D === Date.prototype ? "Date" : t && D === Promise.prototype ? "Promise" : i && D === Set.prototype ? "Set" : a && D === Map.prototype ? "Map" : c && D === WeakSet.prototype ? "WeakSet" : o && D === WeakMap.prototype ? "WeakMap" : d && D === DataView.prototype ? "DataView" : a && D ===
|
|
171
|
+
return D === RegExp.prototype ? "RegExp" : D === Date.prototype ? "Date" : t && D === Promise.prototype ? "Promise" : i && D === Set.prototype ? "Set" : a && D === Map.prototype ? "Map" : c && D === WeakSet.prototype ? "WeakSet" : o && D === WeakMap.prototype ? "WeakMap" : d && D === DataView.prototype ? "DataView" : a && D === z ? "Map Iterator" : i && D === F ? "Set Iterator" : se && D === ge ? "Array Iterator" : ce && D === V ? "String Iterator" : D === null ? "Object" : Object.prototype.toString.call(A).slice(K, q);
|
|
172
172
|
}
|
|
173
|
-
return
|
|
173
|
+
return Ie;
|
|
174
174
|
});
|
|
175
|
-
}(
|
|
175
|
+
}(_t)), _t.exports;
|
|
176
176
|
}
|
|
177
177
|
var qr = Br();
|
|
178
|
-
const Hr = /* @__PURE__ */
|
|
178
|
+
const Hr = /* @__PURE__ */ Wr(qr), Zt = typeof Buffer != "undefined", Jr = Zt && typeof Buffer.from != "undefined", Gr = Zt ? (
|
|
179
179
|
/**
|
|
180
180
|
* is value is Buffer?
|
|
181
181
|
*
|
|
@@ -253,10 +253,10 @@ function Yr(r, e, t = null) {
|
|
|
253
253
|
return e;
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
|
-
function
|
|
256
|
+
function bt(r) {
|
|
257
257
|
return Xr.has(r);
|
|
258
258
|
}
|
|
259
|
-
function
|
|
259
|
+
function Bt(r, e, t, s = null) {
|
|
260
260
|
switch (s || Ee(r)) {
|
|
261
261
|
case "Arguments":
|
|
262
262
|
case "Array":
|
|
@@ -272,7 +272,7 @@ function zt(r, e, t, s = null) {
|
|
|
272
272
|
}
|
|
273
273
|
return r;
|
|
274
274
|
}
|
|
275
|
-
const Qr = typeof globalThis != "undefined" && globalThis !== null && globalThis.Object === Object && globalThis, es = typeof global != "undefined" && global !== null && global.Object === Object && global, ts = typeof self != "undefined" && self !== null && self.Object === Object && self,
|
|
275
|
+
const Qr = typeof globalThis != "undefined" && globalThis !== null && globalThis.Object === Object && globalThis, es = typeof global != "undefined" && global !== null && global.Object === Object && global, ts = typeof self != "undefined" && self !== null && self.Object === Object && self, mt = Qr || es || ts || Function("return this")();
|
|
276
276
|
function rs(r) {
|
|
277
277
|
return r.slice(0);
|
|
278
278
|
}
|
|
@@ -298,12 +298,12 @@ function ds(r) {
|
|
|
298
298
|
return new String(r);
|
|
299
299
|
}
|
|
300
300
|
function ne(r, e) {
|
|
301
|
-
return
|
|
301
|
+
return mt[e].from ? mt[e].from(r) : new mt[e](r);
|
|
302
302
|
}
|
|
303
303
|
function P(r) {
|
|
304
304
|
return r;
|
|
305
305
|
}
|
|
306
|
-
function
|
|
306
|
+
function qt() {
|
|
307
307
|
return [];
|
|
308
308
|
}
|
|
309
309
|
function us() {
|
|
@@ -356,8 +356,8 @@ const hs = /* @__PURE__ */ new Map([
|
|
|
356
356
|
["undefined", P],
|
|
357
357
|
// collections
|
|
358
358
|
// NOTE: return empty value, because recursively copy later.
|
|
359
|
-
["Arguments",
|
|
360
|
-
["Array",
|
|
359
|
+
["Arguments", qt],
|
|
360
|
+
["Array", qt],
|
|
361
361
|
["Map", us],
|
|
362
362
|
["Object", ls],
|
|
363
363
|
["Set", fs]
|
|
@@ -374,7 +374,7 @@ const hs = /* @__PURE__ */ new Map([
|
|
|
374
374
|
]);
|
|
375
375
|
function ps() {
|
|
376
376
|
}
|
|
377
|
-
function
|
|
377
|
+
function wt(r, e = null, t = ps) {
|
|
378
378
|
arguments.length === 2 && typeof e == "function" && (t = e, e = null);
|
|
379
379
|
const s = e || Ee(r), n = hs.get(s);
|
|
380
380
|
if (s === "Object") {
|
|
@@ -384,7 +384,7 @@ function bt(r, e = null, t = ps) {
|
|
|
384
384
|
}
|
|
385
385
|
return n ? n(r, s) : r;
|
|
386
386
|
}
|
|
387
|
-
function
|
|
387
|
+
function je(r, e = {}) {
|
|
388
388
|
typeof e == "function" && (e = {
|
|
389
389
|
customizer: e
|
|
390
390
|
});
|
|
@@ -394,14 +394,14 @@ function Ie(r, e = {}) {
|
|
|
394
394
|
// TODO: max depth
|
|
395
395
|
// depth = Infinity,
|
|
396
396
|
} = e, s = Ee(r);
|
|
397
|
-
if (!
|
|
398
|
-
return
|
|
399
|
-
const n =
|
|
400
|
-
return
|
|
397
|
+
if (!bt(s))
|
|
398
|
+
return xt(r, null, null, null);
|
|
399
|
+
const n = wt(r, s, t), a = new WeakMap([[r, n]]), i = new WeakSet([r]);
|
|
400
|
+
return xt(r, n, a, i);
|
|
401
401
|
}
|
|
402
|
-
function
|
|
403
|
-
const a = Ee(r), i =
|
|
404
|
-
if (!
|
|
402
|
+
function xt(r, e, t, s, n) {
|
|
403
|
+
const a = Ee(r), i = wt(r, a);
|
|
404
|
+
if (!bt(a))
|
|
405
405
|
return i;
|
|
406
406
|
let o;
|
|
407
407
|
switch (a) {
|
|
@@ -420,13 +420,13 @@ function wt(r, e, t, s, n) {
|
|
|
420
420
|
for (let c of o) {
|
|
421
421
|
const d = Yr(r, c, a);
|
|
422
422
|
if (s.has(d))
|
|
423
|
-
|
|
423
|
+
Bt(e, c, t.get(d), a);
|
|
424
424
|
else {
|
|
425
|
-
const f = Ee(d), v =
|
|
426
|
-
|
|
425
|
+
const f = Ee(d), v = wt(d, f);
|
|
426
|
+
bt(f) && (t.set(d, v), s.add(d)), Bt(
|
|
427
427
|
e,
|
|
428
428
|
c,
|
|
429
|
-
|
|
429
|
+
xt(
|
|
430
430
|
d,
|
|
431
431
|
v,
|
|
432
432
|
t,
|
|
@@ -439,32 +439,32 @@ function wt(r, e, t, s, n) {
|
|
|
439
439
|
return e;
|
|
440
440
|
}
|
|
441
441
|
const ms = (r) => new Promise((e) => setTimeout(e, r));
|
|
442
|
-
var et,
|
|
442
|
+
var et, ye, tt, kt, ir;
|
|
443
443
|
class gs {
|
|
444
444
|
constructor({ maxAttempts: e = 3, func: t }) {
|
|
445
|
-
B(this,
|
|
445
|
+
B(this, kt), B(this, et), B(this, ye), B(this, tt), R(this, et, e), R(this, tt, t), R(this, ye, 0);
|
|
446
446
|
}
|
|
447
447
|
run() {
|
|
448
|
-
return
|
|
448
|
+
return I(this, null, function* () {
|
|
449
449
|
try {
|
|
450
450
|
return yield T(this, tt).call(this);
|
|
451
451
|
} catch (e) {
|
|
452
|
-
if (
|
|
452
|
+
if (R(this, ye, T(this, ye) + 1), T(this, ye) > T(this, et))
|
|
453
453
|
throw console.error("Max attempts reached"), e;
|
|
454
|
-
const t = Q(this,
|
|
454
|
+
const t = Q(this, kt, ir).call(this);
|
|
455
455
|
return yield ms(t), yield this.run();
|
|
456
456
|
}
|
|
457
457
|
});
|
|
458
458
|
}
|
|
459
459
|
}
|
|
460
|
-
et = /* @__PURE__ */ new WeakMap(),
|
|
461
|
-
return T(this,
|
|
460
|
+
et = /* @__PURE__ */ new WeakMap(), ye = /* @__PURE__ */ new WeakMap(), tt = /* @__PURE__ */ new WeakMap(), kt = /* @__PURE__ */ new WeakSet(), ir = function() {
|
|
461
|
+
return T(this, ye) * 1e3 * 1.5;
|
|
462
462
|
};
|
|
463
463
|
function ys() {
|
|
464
464
|
return typeof CompressionStream != "undefined";
|
|
465
465
|
}
|
|
466
466
|
function vs(r) {
|
|
467
|
-
return
|
|
467
|
+
return I(this, null, function* () {
|
|
468
468
|
const e = new Blob([r]).stream().pipeThrough(new CompressionStream("gzip")), t = [];
|
|
469
469
|
try {
|
|
470
470
|
for (var s = Dr(e), n, a, i; n = !(a = yield s.next()).done; n = !1) {
|
|
@@ -485,7 +485,7 @@ function vs(r) {
|
|
|
485
485
|
});
|
|
486
486
|
}
|
|
487
487
|
function _s(r) {
|
|
488
|
-
return
|
|
488
|
+
return I(this, null, function* () {
|
|
489
489
|
const e = yield new Blob(r).arrayBuffer();
|
|
490
490
|
return new Uint8Array(e);
|
|
491
491
|
});
|
|
@@ -505,7 +505,7 @@ class bs extends Error {
|
|
|
505
505
|
a && typeof a == "object" && "code" in a && (this.code = a.code);
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
|
-
class
|
|
508
|
+
class Ht extends Error {
|
|
509
509
|
constructor({
|
|
510
510
|
url: e,
|
|
511
511
|
method: t,
|
|
@@ -523,7 +523,7 @@ class Bt extends Error {
|
|
|
523
523
|
}
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
|
-
class
|
|
526
|
+
class Re extends Error {
|
|
527
527
|
constructor(e = {}) {
|
|
528
528
|
const { canceled: t = !1 } = e;
|
|
529
529
|
super("Abort Error"), this.name = "Abort Error", this.canceled = t;
|
|
@@ -534,25 +534,25 @@ class ws extends Error {
|
|
|
534
534
|
super(`Async API Error: ${JSON.stringify(e)}`), this.name = "Async API Error", this.body = e;
|
|
535
535
|
}
|
|
536
536
|
}
|
|
537
|
-
class
|
|
537
|
+
class gt extends Error {
|
|
538
538
|
constructor(e) {
|
|
539
539
|
super(e), this.name = "Request Validation Error";
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
|
-
function
|
|
542
|
+
function or() {
|
|
543
543
|
return Array.from(
|
|
544
544
|
{ length: 32 },
|
|
545
545
|
() => Math.floor(Math.random() * 256).toString(16).padStart(2, "0")
|
|
546
546
|
).join("");
|
|
547
547
|
}
|
|
548
|
-
function
|
|
548
|
+
function Tt() {
|
|
549
549
|
return Math.floor(Date.now() / 1e3).toString();
|
|
550
550
|
}
|
|
551
551
|
const xs = 5 * 60 * 1e3, ks = 1 * 1e3;
|
|
552
|
-
var
|
|
552
|
+
var ve, L, X, St, Et, Ze;
|
|
553
553
|
class Ts {
|
|
554
554
|
constructor({ fetch: e = globalThis.fetch.bind(globalThis), baseAddress: t }) {
|
|
555
|
-
B(this, X), B(this,
|
|
555
|
+
B(this, X), B(this, ve), B(this, L), this.baseAddress = t, R(this, ve, e), R(this, L, {}), this.plugins = [];
|
|
556
556
|
}
|
|
557
557
|
get headers() {
|
|
558
558
|
throw new Error("Missing implementation");
|
|
@@ -564,58 +564,58 @@ class Ts {
|
|
|
564
564
|
this.plugins = this.plugins.filter((t) => t.name !== e);
|
|
565
565
|
}
|
|
566
566
|
withOptions(e = {}) {
|
|
567
|
-
return
|
|
567
|
+
return R(this, L, e), this;
|
|
568
568
|
}
|
|
569
569
|
get(e) {
|
|
570
|
-
return
|
|
570
|
+
return I(this, arguments, function* (t, s = {}) {
|
|
571
571
|
const { overrideBaseAddress: n, overrideDefaultHeaders: a } = s, i = n != null ? n : this.baseAddress;
|
|
572
572
|
let o = a != null ? a : this.headers;
|
|
573
|
-
const c =
|
|
574
|
-
return
|
|
573
|
+
const c = je(T(this, L));
|
|
574
|
+
return R(this, L, {}), c.extraHeaders && (o = U(U({}, o), c.extraHeaders)), c.requestValidation && (o = jt(U({}, o), { "X-Request-Nonce": or(), "X-Request-Timestamp": Tt() })), c.async ? yield Q(this, X, Et).call(this, `${i}${t}`, c.async, { headers: o }) : yield Q(this, X, St).call(this, `${i}${t}`, c, { headers: o });
|
|
575
575
|
});
|
|
576
576
|
}
|
|
577
577
|
post(e, t) {
|
|
578
|
-
return
|
|
579
|
-
const i =
|
|
580
|
-
return
|
|
578
|
+
return I(this, arguments, function* (s, n, a = {}) {
|
|
579
|
+
const i = je(T(this, L));
|
|
580
|
+
return R(this, L, {}), Q(this, X, Ze).call(this, s, "POST", n, a, i);
|
|
581
581
|
});
|
|
582
582
|
}
|
|
583
583
|
put(e, t) {
|
|
584
|
-
return
|
|
585
|
-
const i =
|
|
586
|
-
return
|
|
584
|
+
return I(this, arguments, function* (s, n, a = {}) {
|
|
585
|
+
const i = je(T(this, L));
|
|
586
|
+
return R(this, L, {}), Q(this, X, Ze).call(this, s, "PUT", n, a, i);
|
|
587
587
|
});
|
|
588
588
|
}
|
|
589
589
|
delete(e, t) {
|
|
590
|
-
return
|
|
591
|
-
const i =
|
|
592
|
-
return
|
|
590
|
+
return I(this, arguments, function* (s, n, a = {}) {
|
|
591
|
+
const i = je(T(this, L));
|
|
592
|
+
return R(this, L, {}), Q(this, X, Ze).call(this, s, "DELETE", n, a, i);
|
|
593
593
|
});
|
|
594
594
|
}
|
|
595
595
|
patch(e, t) {
|
|
596
|
-
return
|
|
597
|
-
const i =
|
|
598
|
-
return
|
|
596
|
+
return I(this, arguments, function* (s, n, a = {}) {
|
|
597
|
+
const i = je(T(this, L));
|
|
598
|
+
return R(this, L, {}), Q(this, X, Ze).call(this, s, "PATCH", n, a, i);
|
|
599
599
|
});
|
|
600
600
|
}
|
|
601
601
|
}
|
|
602
|
-
|
|
603
|
-
return
|
|
604
|
-
const s = () =>
|
|
602
|
+
ve = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), X = /* @__PURE__ */ new WeakSet(), St = function(r, e, t) {
|
|
603
|
+
return I(this, null, function* () {
|
|
604
|
+
const s = () => I(this, null, function* () {
|
|
605
605
|
var c, d;
|
|
606
606
|
try {
|
|
607
|
-
return yield T(this,
|
|
607
|
+
return yield T(this, ve).call(this, r, U(U({}, t), e.abortSignal && { signal: e.abortSignal }));
|
|
608
608
|
} catch (f) {
|
|
609
|
-
throw f instanceof Error && f.name === "AbortError" ? new
|
|
609
|
+
throw f instanceof Error && f.name === "AbortError" ? new Re({ canceled: (d = (c = e.abortSignal) == null ? void 0 : c.aborted) != null ? d : !1 }) : f;
|
|
610
610
|
}
|
|
611
611
|
}), { headers: n } = t != null ? t : {}, a = (c, d) => {
|
|
612
612
|
var f, v;
|
|
613
613
|
return ((f = c == null ? void 0 : c.headers) == null ? void 0 : f.get(d)) || ((v = c == null ? void 0 : c.headersObject) == null ? void 0 : v[d]) || "";
|
|
614
|
-
}, i = (c) =>
|
|
614
|
+
}, i = (c) => I(this, null, function* () {
|
|
615
615
|
var d;
|
|
616
616
|
if (!c.ok) {
|
|
617
617
|
const v = yield c.text().catch();
|
|
618
|
-
throw new
|
|
618
|
+
throw new Ht({
|
|
619
619
|
url: r,
|
|
620
620
|
method: (d = t == null ? void 0 : t.method) != null ? d : "GET",
|
|
621
621
|
statusCode: c.status,
|
|
@@ -626,15 +626,15 @@ ye = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), X = /* @_
|
|
|
626
626
|
}
|
|
627
627
|
if (e.requestValidation && process.env.UI_TESTS !== !0)
|
|
628
628
|
try {
|
|
629
|
-
const v = a(c, "x-response-nonce"),
|
|
630
|
-
if (!v || v !==
|
|
631
|
-
throw new
|
|
632
|
-
const
|
|
633
|
-
if (isNaN(
|
|
634
|
-
throw new
|
|
629
|
+
const v = a(c, "x-response-nonce"), j = n == null ? void 0 : n["X-Request-Nonce"];
|
|
630
|
+
if (!v || v !== j)
|
|
631
|
+
throw new gt("Response nonce mismatch");
|
|
632
|
+
const M = Number(a(c, "x-response-timestamp")), F = Number(Tt()), z = 60 * 60 * 24;
|
|
633
|
+
if (isNaN(M) || Math.abs(F - M) > z)
|
|
634
|
+
throw new gt("Invalid response timestamp");
|
|
635
635
|
} catch (v) {
|
|
636
|
-
const
|
|
637
|
-
throw new
|
|
636
|
+
const j = v instanceof Error ? v.message : "Request validation failed";
|
|
637
|
+
throw new gt(j);
|
|
638
638
|
}
|
|
639
639
|
let f = yield c.text();
|
|
640
640
|
try {
|
|
@@ -653,8 +653,8 @@ ye = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), X = /* @_
|
|
|
653
653
|
const o = yield s();
|
|
654
654
|
return yield i(o);
|
|
655
655
|
});
|
|
656
|
-
},
|
|
657
|
-
return
|
|
656
|
+
}, Et = function(r, e, t) {
|
|
657
|
+
return I(this, null, function* () {
|
|
658
658
|
var s, n;
|
|
659
659
|
const {
|
|
660
660
|
onProgress: a,
|
|
@@ -664,13 +664,13 @@ ye = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), X = /* @_
|
|
|
664
664
|
} = e, d = `${r}/async`, f = `${r}/async/job`;
|
|
665
665
|
let v;
|
|
666
666
|
try {
|
|
667
|
-
v = yield T(this,
|
|
667
|
+
v = yield T(this, ve).call(this, d, U(U({}, t), i && { signal: i }));
|
|
668
668
|
} catch (F) {
|
|
669
|
-
throw F instanceof Error && F.name === "AbortError" ? new
|
|
669
|
+
throw F instanceof Error && F.name === "AbortError" ? new Re({ canceled: (s = i == null ? void 0 : i.aborted) != null ? s : !1 }) : F;
|
|
670
670
|
}
|
|
671
671
|
if (!v.ok) {
|
|
672
672
|
const F = yield v.text().catch();
|
|
673
|
-
throw new
|
|
673
|
+
throw new Ht({
|
|
674
674
|
url: r,
|
|
675
675
|
method: (n = t == null ? void 0 : t.method) != null ? n : "GET",
|
|
676
676
|
statusCode: v.status,
|
|
@@ -679,55 +679,55 @@ ye = /* @__PURE__ */ new WeakMap(), L = /* @__PURE__ */ new WeakMap(), X = /* @_
|
|
|
679
679
|
body: F
|
|
680
680
|
});
|
|
681
681
|
}
|
|
682
|
-
const
|
|
683
|
-
if (!
|
|
682
|
+
const j = yield v.json(), { job_id: M } = j;
|
|
683
|
+
if (!M)
|
|
684
684
|
throw new Error("Job ID not found in response");
|
|
685
|
-
return new Promise((F,
|
|
685
|
+
return new Promise((F, z) => I(this, null, function* () {
|
|
686
686
|
const se = setTimeout(() => {
|
|
687
|
-
|
|
688
|
-
}, c),
|
|
687
|
+
z(new Error("Job timed out"));
|
|
688
|
+
}, c), ge = (ce = 0) => I(this, null, function* () {
|
|
689
689
|
if (i != null && i.aborted) {
|
|
690
|
-
clearTimeout(se), T(this,
|
|
691
|
-
|
|
690
|
+
clearTimeout(se), T(this, ve).call(this, `${f}/${M}/cancel`, { method: "POST", headers: this.headers }).then(() => {
|
|
691
|
+
z(new Re({ canceled: !0 }));
|
|
692
692
|
}).catch((V) => {
|
|
693
|
-
|
|
693
|
+
z(new Re({ canceled: !1 }));
|
|
694
694
|
});
|
|
695
695
|
return;
|
|
696
696
|
}
|
|
697
697
|
try {
|
|
698
|
-
const V = yield (yield T(this,
|
|
698
|
+
const V = yield (yield T(this, ve).call(this, `${f}/${M}`, { headers: this.headers })).json();
|
|
699
699
|
if (V.status === "success") {
|
|
700
700
|
clearTimeout(se);
|
|
701
701
|
const K = V.response_json;
|
|
702
702
|
F(K);
|
|
703
703
|
} else if (V.status === "failed")
|
|
704
|
-
clearTimeout(se),
|
|
704
|
+
clearTimeout(se), z(new ws(V.response_json));
|
|
705
705
|
else {
|
|
706
706
|
a && a(V.response_json);
|
|
707
707
|
const K = o(ce);
|
|
708
|
-
setTimeout(() =>
|
|
708
|
+
setTimeout(() => ge(ce + 1), K);
|
|
709
709
|
}
|
|
710
710
|
} catch (V) {
|
|
711
|
-
|
|
711
|
+
z(V);
|
|
712
712
|
}
|
|
713
713
|
});
|
|
714
|
-
|
|
714
|
+
ge();
|
|
715
715
|
}));
|
|
716
716
|
});
|
|
717
|
-
},
|
|
718
|
-
return
|
|
717
|
+
}, Ze = function(r, e, t, s, n) {
|
|
718
|
+
return I(this, null, function* () {
|
|
719
719
|
const { overrideBaseAddress: a, overrideDefaultHeaders: i } = s, o = a != null ? a : this.baseAddress;
|
|
720
720
|
let c = i != null ? i : this.headers;
|
|
721
|
-
n.extraHeaders && (c = U(U({}, c), n.extraHeaders)), n.requestValidation && (c = jt(U({}, c), { "X-Request-Nonce":
|
|
721
|
+
n.extraHeaders && (c = U(U({}, c), n.extraHeaders)), n.requestValidation && (c = jt(U({}, c), { "X-Request-Nonce": or(), "X-Request-Timestamp": Tt() }));
|
|
722
722
|
let d = t;
|
|
723
|
-
return typeof FormData != "undefined" && t instanceof FormData ? delete c["Content-Type"] : (d = s.skipBodyJsonStringify ? t : JSON.stringify(t), n.compress && ys() && (c["Content-Encoding"] = "gzip", d = yield vs(d))), n.async ? yield Q(this, X,
|
|
723
|
+
return typeof FormData != "undefined" && t instanceof FormData ? delete c["Content-Type"] : (d = s.skipBodyJsonStringify ? t : JSON.stringify(t), n.compress && ys() && (c["Content-Encoding"] = "gzip", d = yield vs(d))), n.async ? yield Q(this, X, Et).call(this, `${o}${r}`, n.async, {
|
|
724
724
|
method: e,
|
|
725
725
|
headers: c,
|
|
726
726
|
body: d
|
|
727
|
-
}) : yield Q(this, X,
|
|
727
|
+
}) : yield Q(this, X, St).call(this, `${o}${r}`, n, { method: e, headers: c, body: d });
|
|
728
728
|
});
|
|
729
729
|
};
|
|
730
|
-
const
|
|
730
|
+
const Jt = (r, e, t, s) => r instanceof Re ? r : new bs({ resource: e, api: String(t), args: s, cause: r }), yt = (r, e) => new Proxy(e, {
|
|
731
731
|
get(t, s) {
|
|
732
732
|
return (...n) => {
|
|
733
733
|
var a;
|
|
@@ -740,51 +740,51 @@ const qt = (r, e, t, s) => r instanceof je ? r : new bs({ resource: e, api: Stri
|
|
|
740
740
|
try {
|
|
741
741
|
i = t[s](...n);
|
|
742
742
|
} catch (o) {
|
|
743
|
-
throw
|
|
743
|
+
throw Jt(o, t.resourceName, s, n);
|
|
744
744
|
}
|
|
745
745
|
return i instanceof Promise ? i.catch((o) => {
|
|
746
|
-
throw
|
|
746
|
+
throw Jt(o, t.resourceName, s, n);
|
|
747
747
|
}) : i;
|
|
748
748
|
};
|
|
749
749
|
}
|
|
750
750
|
});
|
|
751
|
-
var
|
|
751
|
+
var Me;
|
|
752
752
|
class Ss {
|
|
753
753
|
constructor(e) {
|
|
754
|
-
B(this,
|
|
754
|
+
B(this, Me), this.resourceName = "Files", R(this, Me, e);
|
|
755
755
|
}
|
|
756
756
|
get(e) {
|
|
757
|
-
return
|
|
757
|
+
return I(this, arguments, function* ({ fileKey: t, params: s = {} }) {
|
|
758
758
|
const n = new URLSearchParams(U({
|
|
759
759
|
plugin_data: "857346721138427857"
|
|
760
760
|
}, s)).toString(), a = `v1/files/${t}?${n}`;
|
|
761
|
-
return yield T(this,
|
|
761
|
+
return yield T(this, Me).get(a);
|
|
762
762
|
});
|
|
763
763
|
}
|
|
764
764
|
getImageFills(e) {
|
|
765
|
-
return
|
|
765
|
+
return I(this, arguments, function* ({ fileKey: t }) {
|
|
766
766
|
var s, n;
|
|
767
767
|
const a = `v1/files/${t}/images`;
|
|
768
|
-
return (n = (s = (yield T(this,
|
|
768
|
+
return (n = (s = (yield T(this, Me).get(a)).meta) == null ? void 0 : s.images) != null ? n : {};
|
|
769
769
|
});
|
|
770
770
|
}
|
|
771
771
|
}
|
|
772
|
-
|
|
772
|
+
Me = /* @__PURE__ */ new WeakMap();
|
|
773
773
|
const Es = (r, e, t) => {
|
|
774
774
|
const s = e.sort();
|
|
775
775
|
return `${r}-${s.join("-")}-${t}`;
|
|
776
776
|
}, As = (r) => r ? r.ts > Date.now() - 1e3 * 30 : !1;
|
|
777
|
-
var Y,
|
|
778
|
-
class
|
|
777
|
+
var Y, At, cr;
|
|
778
|
+
class Cs {
|
|
779
779
|
constructor(e) {
|
|
780
|
-
B(this,
|
|
780
|
+
B(this, At), B(this, Y), this.resourceName = "Images", R(this, Y, e);
|
|
781
781
|
}
|
|
782
782
|
/**
|
|
783
783
|
* Return the URL for the _layer_ images for the given nodes.
|
|
784
784
|
* Note: Use the `file.images` API to get the _source_ images used on the node fills, which has better quality.
|
|
785
785
|
*/
|
|
786
786
|
get(e) {
|
|
787
|
-
return
|
|
787
|
+
return I(this, arguments, function* ({ fileKey: t, nodeIds: s, format: n = "jpg", scale: a }) {
|
|
788
788
|
const i = Es(t, s, n), o = T(this, Y).cache.images.entries.get(i);
|
|
789
789
|
if (As(o))
|
|
790
790
|
return o.result;
|
|
@@ -792,7 +792,7 @@ class Os {
|
|
|
792
792
|
const c = T(this, Y).cache.images.pendingRequests.get(i);
|
|
793
793
|
if (c)
|
|
794
794
|
return c;
|
|
795
|
-
const d = Q(this,
|
|
795
|
+
const d = Q(this, At, cr).call(this, i, t, s, n, a);
|
|
796
796
|
T(this, Y).cache.images.pendingRequests.set(i, d);
|
|
797
797
|
try {
|
|
798
798
|
return yield d;
|
|
@@ -802,8 +802,8 @@ class Os {
|
|
|
802
802
|
});
|
|
803
803
|
}
|
|
804
804
|
}
|
|
805
|
-
Y = /* @__PURE__ */ new WeakMap(),
|
|
806
|
-
return
|
|
805
|
+
Y = /* @__PURE__ */ new WeakMap(), At = /* @__PURE__ */ new WeakSet(), cr = function(r, e, t, s, n) {
|
|
806
|
+
return I(this, null, function* () {
|
|
807
807
|
const a = yield T(this, Y).get(
|
|
808
808
|
`v1/images/${e}?ids=${t}&format=${s}${n ? `&scale=${n}` : ""}`
|
|
809
809
|
);
|
|
@@ -814,12 +814,12 @@ Y = /* @__PURE__ */ new WeakMap(), Et = /* @__PURE__ */ new WeakSet(), ir = func
|
|
|
814
814
|
});
|
|
815
815
|
};
|
|
816
816
|
var rt;
|
|
817
|
-
class
|
|
817
|
+
class Os {
|
|
818
818
|
constructor(e) {
|
|
819
|
-
B(this, rt), this.resourceName = "Nodes",
|
|
819
|
+
B(this, rt), this.resourceName = "Nodes", R(this, rt, e);
|
|
820
820
|
}
|
|
821
821
|
get(e) {
|
|
822
|
-
return
|
|
822
|
+
return I(this, arguments, function* ({ fileKey: t, nodeIds: s, params: n = {} }) {
|
|
823
823
|
const a = jt(U({}, n), {
|
|
824
824
|
ids: s.join(",")
|
|
825
825
|
}), i = new URLSearchParams(U({
|
|
@@ -831,7 +831,7 @@ class Cs {
|
|
|
831
831
|
}
|
|
832
832
|
rt = /* @__PURE__ */ new WeakMap();
|
|
833
833
|
var ue;
|
|
834
|
-
class
|
|
834
|
+
class dr extends Ts {
|
|
835
835
|
constructor({
|
|
836
836
|
baseAddress: e = "https://api.figma.com/",
|
|
837
837
|
fetch: t = globalThis.fetch.bind(globalThis)
|
|
@@ -841,12 +841,12 @@ class or extends Ts {
|
|
|
841
841
|
entries: /* @__PURE__ */ new Map(),
|
|
842
842
|
pendingRequests: /* @__PURE__ */ new Map()
|
|
843
843
|
}
|
|
844
|
-
}, this.files =
|
|
844
|
+
}, this.files = yt(this, new Ss(this)), this.nodes = yt(this, new Os(this)), this.images = yt(this, new Cs(this));
|
|
845
845
|
}
|
|
846
846
|
set token(e) {
|
|
847
847
|
if (!e.startsWith("figd_") && !e.startsWith("figu_"))
|
|
848
848
|
throw new Error("Invalid Figma access token");
|
|
849
|
-
|
|
849
|
+
R(this, ue, e);
|
|
850
850
|
}
|
|
851
851
|
get token() {
|
|
852
852
|
return T(this, ue);
|
|
@@ -859,10 +859,10 @@ class or extends Ts {
|
|
|
859
859
|
}
|
|
860
860
|
}
|
|
861
861
|
ue = /* @__PURE__ */ new WeakMap();
|
|
862
|
-
const
|
|
862
|
+
const Is = (a) => C(void 0, [a], function* ({
|
|
863
863
|
fileKey: r,
|
|
864
864
|
authToken: e,
|
|
865
|
-
figmaRestApi: t = new
|
|
865
|
+
figmaRestApi: t = new dr(),
|
|
866
866
|
params: s = {},
|
|
867
867
|
signal: n
|
|
868
868
|
}) {
|
|
@@ -875,13 +875,13 @@ const Ns = (a) => C(void 0, [a], function* ({
|
|
|
875
875
|
params: s
|
|
876
876
|
});
|
|
877
877
|
} catch (i) {
|
|
878
|
-
throw i instanceof Error && i.name === "AbortError" ? i : (console.error(i),
|
|
878
|
+
throw i instanceof Error && i.name === "AbortError" ? i : (console.error(i), nr(i, r));
|
|
879
879
|
}
|
|
880
|
-
}),
|
|
880
|
+
}), Yn = (i) => C(void 0, [i], function* ({
|
|
881
881
|
fileKey: r,
|
|
882
882
|
authToken: e,
|
|
883
883
|
nodeIds: t,
|
|
884
|
-
figmaRestApi: s = new
|
|
884
|
+
figmaRestApi: s = new dr(),
|
|
885
885
|
params: n = {},
|
|
886
886
|
signal: a
|
|
887
887
|
}) {
|
|
@@ -895,14 +895,14 @@ const Ns = (a) => C(void 0, [a], function* ({
|
|
|
895
895
|
params: u({}, n)
|
|
896
896
|
})).nodes;
|
|
897
897
|
} catch (o) {
|
|
898
|
-
throw o instanceof Error && o.name === "AbortError" ? o :
|
|
898
|
+
throw o instanceof Error && o.name === "AbortError" ? o : nr(o, r);
|
|
899
899
|
}
|
|
900
|
-
}),
|
|
900
|
+
}), ur = (r, e) => {
|
|
901
901
|
if (r.id === e)
|
|
902
902
|
return r;
|
|
903
903
|
if ("children" in r)
|
|
904
904
|
for (const t of r.children) {
|
|
905
|
-
const s =
|
|
905
|
+
const s = ur(t, e);
|
|
906
906
|
if (s)
|
|
907
907
|
return s;
|
|
908
908
|
}
|
|
@@ -944,10 +944,10 @@ var x;
|
|
|
944
944
|
}
|
|
945
945
|
r.joinValues = s, r.jsonStringifyReplacer = (n, a) => typeof a == "bigint" ? a.toString() : a;
|
|
946
946
|
})(x || (x = {}));
|
|
947
|
-
var
|
|
947
|
+
var Ct;
|
|
948
948
|
(function(r) {
|
|
949
949
|
r.mergeShapes = (e, t) => u(u({}, e), t);
|
|
950
|
-
})(
|
|
950
|
+
})(Ct || (Ct = {}));
|
|
951
951
|
const p = x.arrayToEnum([
|
|
952
952
|
"string",
|
|
953
953
|
"nan",
|
|
@@ -1007,8 +1007,8 @@ const p = x.arrayToEnum([
|
|
|
1007
1007
|
"invalid_intersection_types",
|
|
1008
1008
|
"not_multiple_of",
|
|
1009
1009
|
"not_finite"
|
|
1010
|
-
]),
|
|
1011
|
-
class
|
|
1010
|
+
]), Ns = (r) => JSON.stringify(r, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
1011
|
+
class W extends Error {
|
|
1012
1012
|
get errors() {
|
|
1013
1013
|
return this.issues;
|
|
1014
1014
|
}
|
|
@@ -1045,7 +1045,7 @@ class z extends Error {
|
|
|
1045
1045
|
return n(this), s;
|
|
1046
1046
|
}
|
|
1047
1047
|
static assert(e) {
|
|
1048
|
-
if (!(e instanceof
|
|
1048
|
+
if (!(e instanceof W))
|
|
1049
1049
|
throw new Error(`Not a ZodError: ${e}`);
|
|
1050
1050
|
}
|
|
1051
1051
|
toString() {
|
|
@@ -1067,7 +1067,7 @@ class z extends Error {
|
|
|
1067
1067
|
return this.flatten();
|
|
1068
1068
|
}
|
|
1069
1069
|
}
|
|
1070
|
-
|
|
1070
|
+
W.create = (r) => new W(r);
|
|
1071
1071
|
const Ae = (r, e) => {
|
|
1072
1072
|
let t;
|
|
1073
1073
|
switch (r.code) {
|
|
@@ -1124,14 +1124,14 @@ const Ae = (r, e) => {
|
|
|
1124
1124
|
}
|
|
1125
1125
|
return { message: t };
|
|
1126
1126
|
};
|
|
1127
|
-
let
|
|
1127
|
+
let lr = Ae;
|
|
1128
1128
|
function js(r) {
|
|
1129
|
-
|
|
1129
|
+
lr = r;
|
|
1130
1130
|
}
|
|
1131
|
-
function
|
|
1132
|
-
return
|
|
1131
|
+
function nt() {
|
|
1132
|
+
return lr;
|
|
1133
1133
|
}
|
|
1134
|
-
const
|
|
1134
|
+
const at = (r) => {
|
|
1135
1135
|
const { data: e, path: t, errorMaps: s, issueData: n } = r, a = [...t, ...n.path || []], i = g(u({}, n), {
|
|
1136
1136
|
path: a
|
|
1137
1137
|
});
|
|
@@ -1150,7 +1150,7 @@ const nt = (r) => {
|
|
|
1150
1150
|
});
|
|
1151
1151
|
}, Rs = [];
|
|
1152
1152
|
function h(r, e) {
|
|
1153
|
-
const t =
|
|
1153
|
+
const t = nt(), s = at({
|
|
1154
1154
|
issueData: e,
|
|
1155
1155
|
data: r.data,
|
|
1156
1156
|
path: r.path,
|
|
@@ -1167,7 +1167,7 @@ function h(r, e) {
|
|
|
1167
1167
|
});
|
|
1168
1168
|
r.common.issues.push(s);
|
|
1169
1169
|
}
|
|
1170
|
-
class
|
|
1170
|
+
class Z {
|
|
1171
1171
|
constructor() {
|
|
1172
1172
|
this.value = "valid";
|
|
1173
1173
|
}
|
|
@@ -1196,7 +1196,7 @@ class R {
|
|
|
1196
1196
|
value: i
|
|
1197
1197
|
});
|
|
1198
1198
|
}
|
|
1199
|
-
return
|
|
1199
|
+
return Z.mergeObjectSync(e, s);
|
|
1200
1200
|
});
|
|
1201
1201
|
}
|
|
1202
1202
|
static mergeObjectSync(e, t) {
|
|
@@ -1212,12 +1212,12 @@ class R {
|
|
|
1212
1212
|
}
|
|
1213
1213
|
const _ = Object.freeze({
|
|
1214
1214
|
status: "aborted"
|
|
1215
|
-
}), Te = (r) => ({ status: "dirty", value: r }), $ = (r) => ({ status: "valid", value: r }), Ot = (r) => r.status === "aborted",
|
|
1216
|
-
function
|
|
1215
|
+
}), Te = (r) => ({ status: "dirty", value: r }), $ = (r) => ({ status: "valid", value: r }), Ot = (r) => r.status === "aborted", It = (r) => r.status === "dirty", be = (r) => r.status === "valid", Fe = (r) => typeof Promise != "undefined" && r instanceof Promise;
|
|
1216
|
+
function it(r, e, t, s) {
|
|
1217
1217
|
if (typeof e == "function" ? r !== e || !0 : !e.has(r)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1218
1218
|
return e.get(r);
|
|
1219
1219
|
}
|
|
1220
|
-
function
|
|
1220
|
+
function fr(r, e, t, s, n) {
|
|
1221
1221
|
if (typeof e == "function" ? r !== e || !0 : !e.has(r)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1222
1222
|
return e.set(r, t), t;
|
|
1223
1223
|
}
|
|
@@ -1225,7 +1225,7 @@ var m;
|
|
|
1225
1225
|
(function(r) {
|
|
1226
1226
|
r.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, r.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
1227
1227
|
})(m || (m = {}));
|
|
1228
|
-
var
|
|
1228
|
+
var Pe, $e;
|
|
1229
1229
|
class te {
|
|
1230
1230
|
constructor(e, t, s, n) {
|
|
1231
1231
|
this._cachedPath = [], this.parent = e, this.data = t, this._path = s, this._key = n;
|
|
@@ -1234,8 +1234,8 @@ class te {
|
|
|
1234
1234
|
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
1235
1235
|
}
|
|
1236
1236
|
}
|
|
1237
|
-
const
|
|
1238
|
-
if (
|
|
1237
|
+
const Gt = (r, e) => {
|
|
1238
|
+
if (be(e))
|
|
1239
1239
|
return { success: !0, data: e.value };
|
|
1240
1240
|
if (!r.common.issues.length)
|
|
1241
1241
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -1244,7 +1244,7 @@ const Ht = (r, e) => {
|
|
|
1244
1244
|
get error() {
|
|
1245
1245
|
if (this._error)
|
|
1246
1246
|
return this._error;
|
|
1247
|
-
const t = new
|
|
1247
|
+
const t = new W(r.common.issues);
|
|
1248
1248
|
return this._error = t, this._error;
|
|
1249
1249
|
}
|
|
1250
1250
|
};
|
|
@@ -1280,7 +1280,7 @@ class w {
|
|
|
1280
1280
|
}
|
|
1281
1281
|
_processInputParams(e) {
|
|
1282
1282
|
return {
|
|
1283
|
-
status: new
|
|
1283
|
+
status: new Z(),
|
|
1284
1284
|
ctx: {
|
|
1285
1285
|
common: e.parent.common,
|
|
1286
1286
|
data: e.data,
|
|
@@ -1293,7 +1293,7 @@ class w {
|
|
|
1293
1293
|
}
|
|
1294
1294
|
_parseSync(e) {
|
|
1295
1295
|
const t = this._parse(e);
|
|
1296
|
-
if (
|
|
1296
|
+
if (Fe(t))
|
|
1297
1297
|
throw new Error("Synchronous parse encountered promise.");
|
|
1298
1298
|
return t;
|
|
1299
1299
|
}
|
|
@@ -1321,7 +1321,7 @@ class w {
|
|
|
1321
1321
|
data: e,
|
|
1322
1322
|
parsedType: ie(e)
|
|
1323
1323
|
}, a = this._parseSync({ data: e, path: n.path, parent: n });
|
|
1324
|
-
return
|
|
1324
|
+
return Gt(n, a);
|
|
1325
1325
|
}
|
|
1326
1326
|
"~validate"(e) {
|
|
1327
1327
|
var t, s;
|
|
@@ -1339,7 +1339,7 @@ class w {
|
|
|
1339
1339
|
if (!this["~standard"].async)
|
|
1340
1340
|
try {
|
|
1341
1341
|
const a = this._parseSync({ data: e, path: [], parent: n });
|
|
1342
|
-
return
|
|
1342
|
+
return be(a) ? {
|
|
1343
1343
|
value: a.value
|
|
1344
1344
|
} : {
|
|
1345
1345
|
issues: n.common.issues
|
|
@@ -1350,7 +1350,7 @@ class w {
|
|
|
1350
1350
|
async: !0
|
|
1351
1351
|
};
|
|
1352
1352
|
}
|
|
1353
|
-
return this._parseAsync({ data: e, path: [], parent: n }).then((a) =>
|
|
1353
|
+
return this._parseAsync({ data: e, path: [], parent: n }).then((a) => be(a) ? {
|
|
1354
1354
|
value: a.value
|
|
1355
1355
|
} : {
|
|
1356
1356
|
issues: n.common.issues
|
|
@@ -1377,8 +1377,8 @@ class w {
|
|
|
1377
1377
|
parent: null,
|
|
1378
1378
|
data: e,
|
|
1379
1379
|
parsedType: ie(e)
|
|
1380
|
-
}, n = this._parse({ data: e, path: s.path, parent: s }), a = yield
|
|
1381
|
-
return
|
|
1380
|
+
}, n = this._parse({ data: e, path: s.path, parent: s }), a = yield Fe(n) ? n : Promise.resolve(n);
|
|
1381
|
+
return Gt(s, a);
|
|
1382
1382
|
});
|
|
1383
1383
|
}
|
|
1384
1384
|
refine(e, t) {
|
|
@@ -1414,7 +1414,7 @@ class w {
|
|
|
1414
1414
|
return ee.create(this, this._def);
|
|
1415
1415
|
}
|
|
1416
1416
|
nullable() {
|
|
1417
|
-
return
|
|
1417
|
+
return me.create(this, this._def);
|
|
1418
1418
|
}
|
|
1419
1419
|
nullish() {
|
|
1420
1420
|
return this.nullable().optional();
|
|
@@ -1423,13 +1423,13 @@ class w {
|
|
|
1423
1423
|
return J.create(this);
|
|
1424
1424
|
}
|
|
1425
1425
|
promise() {
|
|
1426
|
-
return
|
|
1426
|
+
return Oe.create(this, this._def);
|
|
1427
1427
|
}
|
|
1428
1428
|
or(e) {
|
|
1429
|
-
return
|
|
1429
|
+
return Ue.create([this, e], this._def);
|
|
1430
1430
|
}
|
|
1431
1431
|
and(e) {
|
|
1432
|
-
return
|
|
1432
|
+
return We.create(this, e, this._def);
|
|
1433
1433
|
}
|
|
1434
1434
|
transform(e) {
|
|
1435
1435
|
return new G(g(u({}, b(this._def)), {
|
|
@@ -1440,7 +1440,7 @@ class w {
|
|
|
1440
1440
|
}
|
|
1441
1441
|
default(e) {
|
|
1442
1442
|
const t = typeof e == "function" ? e : () => e;
|
|
1443
|
-
return new
|
|
1443
|
+
return new Je(g(u({}, b(this._def)), {
|
|
1444
1444
|
innerType: this,
|
|
1445
1445
|
defaultValue: t,
|
|
1446
1446
|
typeName: y.ZodDefault
|
|
@@ -1454,7 +1454,7 @@ class w {
|
|
|
1454
1454
|
}
|
|
1455
1455
|
catch(e) {
|
|
1456
1456
|
const t = typeof e == "function" ? e : () => e;
|
|
1457
|
-
return new
|
|
1457
|
+
return new Ge(g(u({}, b(this._def)), {
|
|
1458
1458
|
innerType: this,
|
|
1459
1459
|
catchValue: t,
|
|
1460
1460
|
typeName: y.ZodCatch
|
|
@@ -1467,10 +1467,10 @@ class w {
|
|
|
1467
1467
|
}));
|
|
1468
1468
|
}
|
|
1469
1469
|
pipe(e) {
|
|
1470
|
-
return
|
|
1470
|
+
return Ye.create(this, e);
|
|
1471
1471
|
}
|
|
1472
1472
|
readonly() {
|
|
1473
|
-
return
|
|
1473
|
+
return Ke.create(this);
|
|
1474
1474
|
}
|
|
1475
1475
|
isOptional() {
|
|
1476
1476
|
return this.safeParse(void 0).success;
|
|
@@ -1480,22 +1480,22 @@ class w {
|
|
|
1480
1480
|
}
|
|
1481
1481
|
}
|
|
1482
1482
|
const Zs = /^c[^\s-]{8,}$/i, Ms = /^[0-9a-z]+$/, Ps = /^[0-9A-HJKMNP-TV-Z]{26}$/i, $s = /^[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, Fs = /^[a-z0-9_-]{21}$/i, Ls = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Vs = /^[-+]?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)?)??$/, Ds = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Us = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
1483
|
-
let
|
|
1484
|
-
const
|
|
1485
|
-
function
|
|
1483
|
+
let vt;
|
|
1484
|
+
const Ws = /^(?:(?: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])$/, zs = /^(?:(?: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])$/, Bs = /^(([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]))$/, qs = /^(([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])$/, Hs = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Js = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, hr = "((\\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])))", Gs = new RegExp(`^${hr}$`);
|
|
1485
|
+
function pr(r) {
|
|
1486
1486
|
let e = "([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";
|
|
1487
1487
|
return r.precision ? e = `${e}\\.\\d{${r.precision}}` : r.precision == null && (e = `${e}(\\.\\d+)?`), e;
|
|
1488
1488
|
}
|
|
1489
1489
|
function Ks(r) {
|
|
1490
|
-
return new RegExp(`^${
|
|
1490
|
+
return new RegExp(`^${pr(r)}$`);
|
|
1491
1491
|
}
|
|
1492
|
-
function
|
|
1493
|
-
let e = `${
|
|
1492
|
+
function mr(r) {
|
|
1493
|
+
let e = `${hr}T${pr(r)}`;
|
|
1494
1494
|
const t = [];
|
|
1495
1495
|
return t.push(r.local ? "Z?" : "Z"), r.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
1496
1496
|
}
|
|
1497
1497
|
function Xs(r, e) {
|
|
1498
|
-
return !!((e === "v4" || !e) &&
|
|
1498
|
+
return !!((e === "v4" || !e) && Ws.test(r) || (e === "v6" || !e) && Bs.test(r));
|
|
1499
1499
|
}
|
|
1500
1500
|
function Ys(r, e) {
|
|
1501
1501
|
if (!Ls.test(r))
|
|
@@ -1508,7 +1508,7 @@ function Ys(r, e) {
|
|
|
1508
1508
|
}
|
|
1509
1509
|
}
|
|
1510
1510
|
function Qs(r, e) {
|
|
1511
|
-
return !!((e === "v4" || !e) &&
|
|
1511
|
+
return !!((e === "v4" || !e) && zs.test(r) || (e === "v6" || !e) && qs.test(r));
|
|
1512
1512
|
}
|
|
1513
1513
|
class H extends w {
|
|
1514
1514
|
_parse(e) {
|
|
@@ -1520,7 +1520,7 @@ class H extends w {
|
|
|
1520
1520
|
received: a.parsedType
|
|
1521
1521
|
}), _;
|
|
1522
1522
|
}
|
|
1523
|
-
const s = new
|
|
1523
|
+
const s = new Z();
|
|
1524
1524
|
let n;
|
|
1525
1525
|
for (const a of this._def.checks)
|
|
1526
1526
|
if (a.kind === "min")
|
|
@@ -1565,7 +1565,7 @@ class H extends w {
|
|
|
1565
1565
|
message: a.message
|
|
1566
1566
|
}), s.dirty());
|
|
1567
1567
|
else if (a.kind === "emoji")
|
|
1568
|
-
|
|
1568
|
+
vt || (vt = new RegExp(Us, "u")), vt.test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1569
1569
|
validation: "emoji",
|
|
1570
1570
|
code: l.invalid_string,
|
|
1571
1571
|
message: a.message
|
|
@@ -1626,7 +1626,7 @@ class H extends w {
|
|
|
1626
1626
|
code: l.invalid_string,
|
|
1627
1627
|
validation: { endsWith: a.value },
|
|
1628
1628
|
message: a.message
|
|
1629
|
-
}), s.dirty()) : a.kind === "datetime" ?
|
|
1629
|
+
}), s.dirty()) : a.kind === "datetime" ? mr(a).test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1630
1630
|
code: l.invalid_string,
|
|
1631
1631
|
validation: "datetime",
|
|
1632
1632
|
message: a.message
|
|
@@ -1885,7 +1885,7 @@ function en(r, e) {
|
|
|
1885
1885
|
const t = (r.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, n = t > s ? t : s, a = parseInt(r.toFixed(n).replace(".", "")), i = parseInt(e.toFixed(n).replace(".", ""));
|
|
1886
1886
|
return a % i / Math.pow(10, n);
|
|
1887
1887
|
}
|
|
1888
|
-
class
|
|
1888
|
+
class fe extends w {
|
|
1889
1889
|
constructor() {
|
|
1890
1890
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1891
1891
|
}
|
|
@@ -1899,7 +1899,7 @@ class le extends w {
|
|
|
1899
1899
|
}), _;
|
|
1900
1900
|
}
|
|
1901
1901
|
let s;
|
|
1902
|
-
const n = new
|
|
1902
|
+
const n = new Z();
|
|
1903
1903
|
for (const a of this._def.checks)
|
|
1904
1904
|
a.kind === "int" ? x.isInteger(e.data) || (s = this._getOrReturnCtx(e, s), h(s, {
|
|
1905
1905
|
code: l.invalid_type,
|
|
@@ -1943,7 +1943,7 @@ class le extends w {
|
|
|
1943
1943
|
return this.setLimit("max", e, !1, m.toString(t));
|
|
1944
1944
|
}
|
|
1945
1945
|
setLimit(e, t, s, n) {
|
|
1946
|
-
return new
|
|
1946
|
+
return new fe(g(u({}, this._def), {
|
|
1947
1947
|
checks: [
|
|
1948
1948
|
...this._def.checks,
|
|
1949
1949
|
{
|
|
@@ -1956,7 +1956,7 @@ class le extends w {
|
|
|
1956
1956
|
}));
|
|
1957
1957
|
}
|
|
1958
1958
|
_addCheck(e) {
|
|
1959
|
-
return new
|
|
1959
|
+
return new fe(g(u({}, this._def), {
|
|
1960
1960
|
checks: [...this._def.checks, e]
|
|
1961
1961
|
}));
|
|
1962
1962
|
}
|
|
@@ -2049,12 +2049,12 @@ class le extends w {
|
|
|
2049
2049
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
2050
2050
|
}
|
|
2051
2051
|
}
|
|
2052
|
-
|
|
2052
|
+
fe.create = (r) => new fe(u({
|
|
2053
2053
|
checks: [],
|
|
2054
2054
|
typeName: y.ZodNumber,
|
|
2055
2055
|
coerce: (r == null ? void 0 : r.coerce) || !1
|
|
2056
2056
|
}, b(r)));
|
|
2057
|
-
class
|
|
2057
|
+
class he extends w {
|
|
2058
2058
|
constructor() {
|
|
2059
2059
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
2060
2060
|
}
|
|
@@ -2068,7 +2068,7 @@ class fe extends w {
|
|
|
2068
2068
|
if (this._getType(e) !== p.bigint)
|
|
2069
2069
|
return this._getInvalidInput(e);
|
|
2070
2070
|
let s;
|
|
2071
|
-
const n = new
|
|
2071
|
+
const n = new Z();
|
|
2072
2072
|
for (const a of this._def.checks)
|
|
2073
2073
|
a.kind === "min" ? (a.inclusive ? e.data < a.value : e.data <= a.value) && (s = this._getOrReturnCtx(e, s), h(s, {
|
|
2074
2074
|
code: l.too_small,
|
|
@@ -2110,7 +2110,7 @@ class fe extends w {
|
|
|
2110
2110
|
return this.setLimit("max", e, !1, m.toString(t));
|
|
2111
2111
|
}
|
|
2112
2112
|
setLimit(e, t, s, n) {
|
|
2113
|
-
return new
|
|
2113
|
+
return new he(g(u({}, this._def), {
|
|
2114
2114
|
checks: [
|
|
2115
2115
|
...this._def.checks,
|
|
2116
2116
|
{
|
|
@@ -2123,7 +2123,7 @@ class fe extends w {
|
|
|
2123
2123
|
}));
|
|
2124
2124
|
}
|
|
2125
2125
|
_addCheck(e) {
|
|
2126
|
-
return new
|
|
2126
|
+
return new he(g(u({}, this._def), {
|
|
2127
2127
|
checks: [...this._def.checks, e]
|
|
2128
2128
|
}));
|
|
2129
2129
|
}
|
|
@@ -2179,15 +2179,15 @@ class fe extends w {
|
|
|
2179
2179
|
return e;
|
|
2180
2180
|
}
|
|
2181
2181
|
}
|
|
2182
|
-
|
|
2182
|
+
he.create = (r) => {
|
|
2183
2183
|
var e;
|
|
2184
|
-
return new
|
|
2184
|
+
return new he(u({
|
|
2185
2185
|
checks: [],
|
|
2186
2186
|
typeName: y.ZodBigInt,
|
|
2187
2187
|
coerce: (e = r == null ? void 0 : r.coerce) !== null && e !== void 0 ? e : !1
|
|
2188
2188
|
}, b(r)));
|
|
2189
2189
|
};
|
|
2190
|
-
class
|
|
2190
|
+
class Le extends w {
|
|
2191
2191
|
_parse(e) {
|
|
2192
2192
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== p.boolean) {
|
|
2193
2193
|
const s = this._getOrReturnCtx(e);
|
|
@@ -2200,11 +2200,11 @@ class Fe extends w {
|
|
|
2200
2200
|
return $(e.data);
|
|
2201
2201
|
}
|
|
2202
2202
|
}
|
|
2203
|
-
|
|
2203
|
+
Le.create = (r) => new Le(u({
|
|
2204
2204
|
typeName: y.ZodBoolean,
|
|
2205
2205
|
coerce: (r == null ? void 0 : r.coerce) || !1
|
|
2206
2206
|
}, b(r)));
|
|
2207
|
-
class
|
|
2207
|
+
class we extends w {
|
|
2208
2208
|
_parse(e) {
|
|
2209
2209
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== p.date) {
|
|
2210
2210
|
const a = this._getOrReturnCtx(e);
|
|
@@ -2220,7 +2220,7 @@ class be extends w {
|
|
|
2220
2220
|
code: l.invalid_date
|
|
2221
2221
|
}), _;
|
|
2222
2222
|
}
|
|
2223
|
-
const s = new
|
|
2223
|
+
const s = new Z();
|
|
2224
2224
|
let n;
|
|
2225
2225
|
for (const a of this._def.checks)
|
|
2226
2226
|
a.kind === "min" ? e.data.getTime() < a.value && (n = this._getOrReturnCtx(e, n), h(n, {
|
|
@@ -2244,7 +2244,7 @@ class be extends w {
|
|
|
2244
2244
|
};
|
|
2245
2245
|
}
|
|
2246
2246
|
_addCheck(e) {
|
|
2247
|
-
return new
|
|
2247
|
+
return new we(g(u({}, this._def), {
|
|
2248
2248
|
checks: [...this._def.checks, e]
|
|
2249
2249
|
}));
|
|
2250
2250
|
}
|
|
@@ -2275,12 +2275,12 @@ class be extends w {
|
|
|
2275
2275
|
return e != null ? new Date(e) : null;
|
|
2276
2276
|
}
|
|
2277
2277
|
}
|
|
2278
|
-
|
|
2278
|
+
we.create = (r) => new we(u({
|
|
2279
2279
|
checks: [],
|
|
2280
2280
|
coerce: (r == null ? void 0 : r.coerce) || !1,
|
|
2281
2281
|
typeName: y.ZodDate
|
|
2282
2282
|
}, b(r)));
|
|
2283
|
-
class
|
|
2283
|
+
class ot extends w {
|
|
2284
2284
|
_parse(e) {
|
|
2285
2285
|
if (this._getType(e) !== p.symbol) {
|
|
2286
2286
|
const s = this._getOrReturnCtx(e);
|
|
@@ -2293,10 +2293,10 @@ class it extends w {
|
|
|
2293
2293
|
return $(e.data);
|
|
2294
2294
|
}
|
|
2295
2295
|
}
|
|
2296
|
-
|
|
2296
|
+
ot.create = (r) => new ot(u({
|
|
2297
2297
|
typeName: y.ZodSymbol
|
|
2298
2298
|
}, b(r)));
|
|
2299
|
-
class
|
|
2299
|
+
class Ve extends w {
|
|
2300
2300
|
_parse(e) {
|
|
2301
2301
|
if (this._getType(e) !== p.undefined) {
|
|
2302
2302
|
const s = this._getOrReturnCtx(e);
|
|
@@ -2309,10 +2309,10 @@ class Le extends w {
|
|
|
2309
2309
|
return $(e.data);
|
|
2310
2310
|
}
|
|
2311
2311
|
}
|
|
2312
|
-
|
|
2312
|
+
Ve.create = (r) => new Ve(u({
|
|
2313
2313
|
typeName: y.ZodUndefined
|
|
2314
2314
|
}, b(r)));
|
|
2315
|
-
class
|
|
2315
|
+
class De extends w {
|
|
2316
2316
|
_parse(e) {
|
|
2317
2317
|
if (this._getType(e) !== p.null) {
|
|
2318
2318
|
const s = this._getOrReturnCtx(e);
|
|
@@ -2325,10 +2325,10 @@ class Ve extends w {
|
|
|
2325
2325
|
return $(e.data);
|
|
2326
2326
|
}
|
|
2327
2327
|
}
|
|
2328
|
-
|
|
2328
|
+
De.create = (r) => new De(u({
|
|
2329
2329
|
typeName: y.ZodNull
|
|
2330
2330
|
}, b(r)));
|
|
2331
|
-
class
|
|
2331
|
+
class Ce extends w {
|
|
2332
2332
|
constructor() {
|
|
2333
2333
|
super(...arguments), this._any = !0;
|
|
2334
2334
|
}
|
|
@@ -2336,10 +2336,10 @@ class Oe extends w {
|
|
|
2336
2336
|
return $(e.data);
|
|
2337
2337
|
}
|
|
2338
2338
|
}
|
|
2339
|
-
|
|
2339
|
+
Ce.create = (r) => new Ce(u({
|
|
2340
2340
|
typeName: y.ZodAny
|
|
2341
2341
|
}, b(r)));
|
|
2342
|
-
class
|
|
2342
|
+
class _e extends w {
|
|
2343
2343
|
constructor() {
|
|
2344
2344
|
super(...arguments), this._unknown = !0;
|
|
2345
2345
|
}
|
|
@@ -2347,7 +2347,7 @@ class ve extends w {
|
|
|
2347
2347
|
return $(e.data);
|
|
2348
2348
|
}
|
|
2349
2349
|
}
|
|
2350
|
-
|
|
2350
|
+
_e.create = (r) => new _e(u({
|
|
2351
2351
|
typeName: y.ZodUnknown
|
|
2352
2352
|
}, b(r)));
|
|
2353
2353
|
class oe extends w {
|
|
@@ -2363,7 +2363,7 @@ class oe extends w {
|
|
|
2363
2363
|
oe.create = (r) => new oe(u({
|
|
2364
2364
|
typeName: y.ZodNever
|
|
2365
2365
|
}, b(r)));
|
|
2366
|
-
class
|
|
2366
|
+
class ct extends w {
|
|
2367
2367
|
_parse(e) {
|
|
2368
2368
|
if (this._getType(e) !== p.undefined) {
|
|
2369
2369
|
const s = this._getOrReturnCtx(e);
|
|
@@ -2376,7 +2376,7 @@ class ot extends w {
|
|
|
2376
2376
|
return $(e.data);
|
|
2377
2377
|
}
|
|
2378
2378
|
}
|
|
2379
|
-
|
|
2379
|
+
ct.create = (r) => new ct(u({
|
|
2380
2380
|
typeName: y.ZodVoid
|
|
2381
2381
|
}, b(r)));
|
|
2382
2382
|
class J extends w {
|
|
@@ -2415,9 +2415,9 @@ class J extends w {
|
|
|
2415
2415
|
exact: !1,
|
|
2416
2416
|
message: n.maxLength.message
|
|
2417
2417
|
}), s.dirty()), t.common.async)
|
|
2418
|
-
return Promise.all([...t.data].map((i, o) => n.type._parseAsync(new te(t, i, t.path, o)))).then((i) =>
|
|
2418
|
+
return Promise.all([...t.data].map((i, o) => n.type._parseAsync(new te(t, i, t.path, o)))).then((i) => Z.mergeArray(s, i));
|
|
2419
2419
|
const a = [...t.data].map((i, o) => n.type._parseSync(new te(t, i, t.path, o)));
|
|
2420
|
-
return
|
|
2420
|
+
return Z.mergeArray(s, a);
|
|
2421
2421
|
}
|
|
2422
2422
|
get element() {
|
|
2423
2423
|
return this._def.type;
|
|
@@ -2460,7 +2460,7 @@ function ke(r) {
|
|
|
2460
2460
|
}));
|
|
2461
2461
|
} else return r instanceof J ? new J(g(u({}, r._def), {
|
|
2462
2462
|
type: ke(r.element)
|
|
2463
|
-
})) : r instanceof ee ? ee.create(ke(r.unwrap())) : r instanceof
|
|
2463
|
+
})) : r instanceof ee ? ee.create(ke(r.unwrap())) : r instanceof me ? me.create(ke(r.unwrap())) : r instanceof re ? re.create(r.items.map((e) => ke(e))) : r;
|
|
2464
2464
|
}
|
|
2465
2465
|
class E extends w {
|
|
2466
2466
|
constructor() {
|
|
@@ -2525,15 +2525,15 @@ class E extends w {
|
|
|
2525
2525
|
return n.common.async ? Promise.resolve().then(() => C(this, null, function* () {
|
|
2526
2526
|
const d = [];
|
|
2527
2527
|
for (const f of c) {
|
|
2528
|
-
const v = yield f.key,
|
|
2528
|
+
const v = yield f.key, j = yield f.value;
|
|
2529
2529
|
d.push({
|
|
2530
2530
|
key: v,
|
|
2531
|
-
value:
|
|
2531
|
+
value: j,
|
|
2532
2532
|
alwaysSet: f.alwaysSet
|
|
2533
2533
|
});
|
|
2534
2534
|
}
|
|
2535
2535
|
return d;
|
|
2536
|
-
})).then((d) =>
|
|
2536
|
+
})).then((d) => Z.mergeObjectSync(s, d)) : Z.mergeObjectSync(s, c);
|
|
2537
2537
|
}
|
|
2538
2538
|
get shape() {
|
|
2539
2539
|
return this._def.shape();
|
|
@@ -2709,7 +2709,7 @@ class E extends w {
|
|
|
2709
2709
|
}));
|
|
2710
2710
|
}
|
|
2711
2711
|
keyof() {
|
|
2712
|
-
return
|
|
2712
|
+
return gr(x.objectKeys(this.shape));
|
|
2713
2713
|
}
|
|
2714
2714
|
}
|
|
2715
2715
|
E.create = (r, e) => new E(u({
|
|
@@ -2730,7 +2730,7 @@ E.lazycreate = (r, e) => new E(u({
|
|
|
2730
2730
|
catchall: oe.create(),
|
|
2731
2731
|
typeName: y.ZodObject
|
|
2732
2732
|
}, b(e)));
|
|
2733
|
-
class
|
|
2733
|
+
class Ue extends w {
|
|
2734
2734
|
_parse(e) {
|
|
2735
2735
|
const { ctx: t } = this._processInputParams(e), s = this._def.options;
|
|
2736
2736
|
function n(a) {
|
|
@@ -2740,7 +2740,7 @@ class De extends w {
|
|
|
2740
2740
|
for (const o of a)
|
|
2741
2741
|
if (o.result.status === "dirty")
|
|
2742
2742
|
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
2743
|
-
const i = a.map((o) => new
|
|
2743
|
+
const i = a.map((o) => new W(o.ctx.common.issues));
|
|
2744
2744
|
return h(t, {
|
|
2745
2745
|
code: l.invalid_union,
|
|
2746
2746
|
unionErrors: i
|
|
@@ -2783,7 +2783,7 @@ class De extends w {
|
|
|
2783
2783
|
}
|
|
2784
2784
|
if (a)
|
|
2785
2785
|
return t.common.issues.push(...a.ctx.common.issues), a.result;
|
|
2786
|
-
const o = i.map((c) => new
|
|
2786
|
+
const o = i.map((c) => new W(c));
|
|
2787
2787
|
return h(t, {
|
|
2788
2788
|
code: l.invalid_union,
|
|
2789
2789
|
unionErrors: o
|
|
@@ -2794,12 +2794,12 @@ class De extends w {
|
|
|
2794
2794
|
return this._def.options;
|
|
2795
2795
|
}
|
|
2796
2796
|
}
|
|
2797
|
-
|
|
2797
|
+
Ue.create = (r, e) => new Ue(u({
|
|
2798
2798
|
options: r,
|
|
2799
2799
|
typeName: y.ZodUnion
|
|
2800
2800
|
}, b(e)));
|
|
2801
|
-
const ae = (r) => r instanceof
|
|
2802
|
-
class
|
|
2801
|
+
const ae = (r) => r instanceof Be ? ae(r.schema) : r instanceof G ? ae(r.innerType()) : r instanceof qe ? [r.value] : r instanceof pe ? r.options : r instanceof He ? x.objectValues(r.enum) : r instanceof Je ? ae(r._def.innerType) : r instanceof Ve ? [void 0] : r instanceof De ? [null] : r instanceof ee ? [void 0, ...ae(r.unwrap())] : r instanceof me ? [null, ...ae(r.unwrap())] : r instanceof Mt || r instanceof Ke ? ae(r.unwrap()) : r instanceof Ge ? ae(r._def.innerType) : [];
|
|
2802
|
+
class lt extends w {
|
|
2803
2803
|
_parse(e) {
|
|
2804
2804
|
const { ctx: t } = this._processInputParams(e);
|
|
2805
2805
|
if (t.parsedType !== p.object)
|
|
@@ -2852,7 +2852,7 @@ class ut extends w {
|
|
|
2852
2852
|
n.set(o, a);
|
|
2853
2853
|
}
|
|
2854
2854
|
}
|
|
2855
|
-
return new
|
|
2855
|
+
return new lt(u({
|
|
2856
2856
|
typeName: y.ZodDiscriminatedUnion,
|
|
2857
2857
|
discriminator: e,
|
|
2858
2858
|
options: t,
|
|
@@ -2886,13 +2886,13 @@ function Nt(r, e) {
|
|
|
2886
2886
|
return { valid: !0, data: n };
|
|
2887
2887
|
} else return t === p.date && s === p.date && +r == +e ? { valid: !0, data: r } : { valid: !1 };
|
|
2888
2888
|
}
|
|
2889
|
-
class
|
|
2889
|
+
class We extends w {
|
|
2890
2890
|
_parse(e) {
|
|
2891
2891
|
const { status: t, ctx: s } = this._processInputParams(e), n = (a, i) => {
|
|
2892
2892
|
if (Ot(a) || Ot(i))
|
|
2893
2893
|
return _;
|
|
2894
2894
|
const o = Nt(a.value, i.value);
|
|
2895
|
-
return o.valid ? ((
|
|
2895
|
+
return o.valid ? ((It(a) || It(i)) && t.dirty(), { status: t.value, value: o.data }) : (h(s, {
|
|
2896
2896
|
code: l.invalid_intersection_types
|
|
2897
2897
|
}), _);
|
|
2898
2898
|
};
|
|
@@ -2918,7 +2918,7 @@ class Ue extends w {
|
|
|
2918
2918
|
}));
|
|
2919
2919
|
}
|
|
2920
2920
|
}
|
|
2921
|
-
|
|
2921
|
+
We.create = (r, e, t) => new We(u({
|
|
2922
2922
|
left: r,
|
|
2923
2923
|
right: e,
|
|
2924
2924
|
typeName: y.ZodIntersection
|
|
@@ -2951,7 +2951,7 @@ class re extends w {
|
|
|
2951
2951
|
const c = this._def.items[o] || this._def.rest;
|
|
2952
2952
|
return c ? c._parse(new te(s, i, s.path, o)) : null;
|
|
2953
2953
|
}).filter((i) => !!i);
|
|
2954
|
-
return s.common.async ? Promise.all(a).then((i) =>
|
|
2954
|
+
return s.common.async ? Promise.all(a).then((i) => Z.mergeArray(t, i)) : Z.mergeArray(t, a);
|
|
2955
2955
|
}
|
|
2956
2956
|
get items() {
|
|
2957
2957
|
return this._def.items;
|
|
@@ -2993,7 +2993,7 @@ class ze extends w {
|
|
|
2993
2993
|
value: i._parse(new te(s, s.data[o], s.path, o)),
|
|
2994
2994
|
alwaysSet: o in s.data
|
|
2995
2995
|
});
|
|
2996
|
-
return s.common.async ?
|
|
2996
|
+
return s.common.async ? Z.mergeObjectAsync(t, n) : Z.mergeObjectSync(t, n);
|
|
2997
2997
|
}
|
|
2998
2998
|
get element() {
|
|
2999
2999
|
return this._def.valueType;
|
|
@@ -3010,7 +3010,7 @@ class ze extends w {
|
|
|
3010
3010
|
}, b(t)));
|
|
3011
3011
|
}
|
|
3012
3012
|
}
|
|
3013
|
-
class
|
|
3013
|
+
class dt extends w {
|
|
3014
3014
|
get keySchema() {
|
|
3015
3015
|
return this._def.keyType;
|
|
3016
3016
|
}
|
|
@@ -3052,12 +3052,12 @@ class ct extends w {
|
|
|
3052
3052
|
}
|
|
3053
3053
|
}
|
|
3054
3054
|
}
|
|
3055
|
-
|
|
3055
|
+
dt.create = (r, e, t) => new dt(u({
|
|
3056
3056
|
valueType: e,
|
|
3057
3057
|
keyType: r,
|
|
3058
3058
|
typeName: y.ZodMap
|
|
3059
3059
|
}, b(t)));
|
|
3060
|
-
class
|
|
3060
|
+
class xe extends w {
|
|
3061
3061
|
_parse(e) {
|
|
3062
3062
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
3063
3063
|
if (s.parsedType !== p.set)
|
|
@@ -3096,12 +3096,12 @@ class we extends w {
|
|
|
3096
3096
|
return s.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
3097
3097
|
}
|
|
3098
3098
|
min(e, t) {
|
|
3099
|
-
return new
|
|
3099
|
+
return new xe(g(u({}, this._def), {
|
|
3100
3100
|
minSize: { value: e, message: m.toString(t) }
|
|
3101
3101
|
}));
|
|
3102
3102
|
}
|
|
3103
3103
|
max(e, t) {
|
|
3104
|
-
return new
|
|
3104
|
+
return new xe(g(u({}, this._def), {
|
|
3105
3105
|
maxSize: { value: e, message: m.toString(t) }
|
|
3106
3106
|
}));
|
|
3107
3107
|
}
|
|
@@ -3112,7 +3112,7 @@ class we extends w {
|
|
|
3112
3112
|
return this.min(1, e);
|
|
3113
3113
|
}
|
|
3114
3114
|
}
|
|
3115
|
-
|
|
3115
|
+
xe.create = (r, e) => new xe(u({
|
|
3116
3116
|
valueType: r,
|
|
3117
3117
|
minSize: null,
|
|
3118
3118
|
maxSize: null,
|
|
@@ -3131,13 +3131,13 @@ class Se extends w {
|
|
|
3131
3131
|
received: t.parsedType
|
|
3132
3132
|
}), _;
|
|
3133
3133
|
function s(o, c) {
|
|
3134
|
-
return
|
|
3134
|
+
return at({
|
|
3135
3135
|
data: o,
|
|
3136
3136
|
path: t.path,
|
|
3137
3137
|
errorMaps: [
|
|
3138
3138
|
t.common.contextualErrorMap,
|
|
3139
3139
|
t.schemaErrorMap,
|
|
3140
|
-
|
|
3140
|
+
nt(),
|
|
3141
3141
|
Ae
|
|
3142
3142
|
].filter((d) => !!d),
|
|
3143
3143
|
issueData: {
|
|
@@ -3147,13 +3147,13 @@ class Se extends w {
|
|
|
3147
3147
|
});
|
|
3148
3148
|
}
|
|
3149
3149
|
function n(o, c) {
|
|
3150
|
-
return
|
|
3150
|
+
return at({
|
|
3151
3151
|
data: o,
|
|
3152
3152
|
path: t.path,
|
|
3153
3153
|
errorMaps: [
|
|
3154
3154
|
t.common.contextualErrorMap,
|
|
3155
3155
|
t.schemaErrorMap,
|
|
3156
|
-
|
|
3156
|
+
nt(),
|
|
3157
3157
|
Ae
|
|
3158
3158
|
].filter((d) => !!d),
|
|
3159
3159
|
issueData: {
|
|
@@ -3163,15 +3163,15 @@ class Se extends w {
|
|
|
3163
3163
|
});
|
|
3164
3164
|
}
|
|
3165
3165
|
const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
|
|
3166
|
-
if (this._def.returns instanceof
|
|
3166
|
+
if (this._def.returns instanceof Oe) {
|
|
3167
3167
|
const o = this;
|
|
3168
3168
|
return $(function(...c) {
|
|
3169
3169
|
return C(this, null, function* () {
|
|
3170
|
-
const d = new
|
|
3171
|
-
throw d.addIssue(s(c,
|
|
3170
|
+
const d = new W([]), f = yield o._def.args.parseAsync(c, a).catch((M) => {
|
|
3171
|
+
throw d.addIssue(s(c, M)), d;
|
|
3172
3172
|
}), v = yield Reflect.apply(i, this, f);
|
|
3173
|
-
return yield o._def.returns._def.type.parseAsync(v, a).catch((
|
|
3174
|
-
throw d.addIssue(n(v,
|
|
3173
|
+
return yield o._def.returns._def.type.parseAsync(v, a).catch((M) => {
|
|
3174
|
+
throw d.addIssue(n(v, M)), d;
|
|
3175
3175
|
});
|
|
3176
3176
|
});
|
|
3177
3177
|
});
|
|
@@ -3180,10 +3180,10 @@ class Se extends w {
|
|
|
3180
3180
|
return $(function(...c) {
|
|
3181
3181
|
const d = o._def.args.safeParse(c, a);
|
|
3182
3182
|
if (!d.success)
|
|
3183
|
-
throw new
|
|
3183
|
+
throw new W([s(c, d.error)]);
|
|
3184
3184
|
const f = Reflect.apply(i, this, d.data), v = o._def.returns.safeParse(f, a);
|
|
3185
3185
|
if (!v.success)
|
|
3186
|
-
throw new
|
|
3186
|
+
throw new W([n(f, v.error)]);
|
|
3187
3187
|
return v.data;
|
|
3188
3188
|
});
|
|
3189
3189
|
}
|
|
@@ -3196,7 +3196,7 @@ class Se extends w {
|
|
|
3196
3196
|
}
|
|
3197
3197
|
args(...e) {
|
|
3198
3198
|
return new Se(g(u({}, this._def), {
|
|
3199
|
-
args: re.create(e).rest(
|
|
3199
|
+
args: re.create(e).rest(_e.create())
|
|
3200
3200
|
}));
|
|
3201
3201
|
}
|
|
3202
3202
|
returns(e) {
|
|
@@ -3212,13 +3212,13 @@ class Se extends w {
|
|
|
3212
3212
|
}
|
|
3213
3213
|
static create(e, t, s) {
|
|
3214
3214
|
return new Se(u({
|
|
3215
|
-
args: e || re.create([]).rest(
|
|
3216
|
-
returns: t ||
|
|
3215
|
+
args: e || re.create([]).rest(_e.create()),
|
|
3216
|
+
returns: t || _e.create(),
|
|
3217
3217
|
typeName: y.ZodFunction
|
|
3218
3218
|
}, b(s)));
|
|
3219
3219
|
}
|
|
3220
3220
|
}
|
|
3221
|
-
class
|
|
3221
|
+
class Be extends w {
|
|
3222
3222
|
get schema() {
|
|
3223
3223
|
return this._def.getter();
|
|
3224
3224
|
}
|
|
@@ -3227,11 +3227,11 @@ class We extends w {
|
|
|
3227
3227
|
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
3228
3228
|
}
|
|
3229
3229
|
}
|
|
3230
|
-
|
|
3230
|
+
Be.create = (r, e) => new Be(u({
|
|
3231
3231
|
getter: r,
|
|
3232
3232
|
typeName: y.ZodLazy
|
|
3233
3233
|
}, b(e)));
|
|
3234
|
-
class
|
|
3234
|
+
class qe extends w {
|
|
3235
3235
|
_parse(e) {
|
|
3236
3236
|
if (e.data !== this._def.value) {
|
|
3237
3237
|
const t = this._getOrReturnCtx(e);
|
|
@@ -3247,19 +3247,19 @@ class Be extends w {
|
|
|
3247
3247
|
return this._def.value;
|
|
3248
3248
|
}
|
|
3249
3249
|
}
|
|
3250
|
-
|
|
3250
|
+
qe.create = (r, e) => new qe(u({
|
|
3251
3251
|
value: r,
|
|
3252
3252
|
typeName: y.ZodLiteral
|
|
3253
3253
|
}, b(e)));
|
|
3254
|
-
function
|
|
3255
|
-
return new
|
|
3254
|
+
function gr(r, e) {
|
|
3255
|
+
return new pe(u({
|
|
3256
3256
|
values: r,
|
|
3257
3257
|
typeName: y.ZodEnum
|
|
3258
3258
|
}, b(e)));
|
|
3259
3259
|
}
|
|
3260
|
-
class
|
|
3260
|
+
class pe extends w {
|
|
3261
3261
|
constructor() {
|
|
3262
|
-
super(...arguments),
|
|
3262
|
+
super(...arguments), Pe.set(this, void 0);
|
|
3263
3263
|
}
|
|
3264
3264
|
_parse(e) {
|
|
3265
3265
|
if (typeof e.data != "string") {
|
|
@@ -3270,7 +3270,7 @@ class he extends w {
|
|
|
3270
3270
|
code: l.invalid_type
|
|
3271
3271
|
}), _;
|
|
3272
3272
|
}
|
|
3273
|
-
if (
|
|
3273
|
+
if (it(this, Pe) || fr(this, Pe, new Set(this._def.values)), !it(this, Pe).has(e.data)) {
|
|
3274
3274
|
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
3275
3275
|
return h(t, {
|
|
3276
3276
|
received: t.data,
|
|
@@ -3302,17 +3302,17 @@ class he extends w {
|
|
|
3302
3302
|
return e;
|
|
3303
3303
|
}
|
|
3304
3304
|
extract(e, t = this._def) {
|
|
3305
|
-
return
|
|
3305
|
+
return pe.create(e, u(u({}, this._def), t));
|
|
3306
3306
|
}
|
|
3307
3307
|
exclude(e, t = this._def) {
|
|
3308
|
-
return
|
|
3308
|
+
return pe.create(this.options.filter((s) => !e.includes(s)), u(u({}, this._def), t));
|
|
3309
3309
|
}
|
|
3310
3310
|
}
|
|
3311
|
-
|
|
3312
|
-
|
|
3313
|
-
class
|
|
3311
|
+
Pe = /* @__PURE__ */ new WeakMap();
|
|
3312
|
+
pe.create = gr;
|
|
3313
|
+
class He extends w {
|
|
3314
3314
|
constructor() {
|
|
3315
|
-
super(...arguments),
|
|
3315
|
+
super(...arguments), $e.set(this, void 0);
|
|
3316
3316
|
}
|
|
3317
3317
|
_parse(e) {
|
|
3318
3318
|
const t = x.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
@@ -3324,7 +3324,7 @@ class qe extends w {
|
|
|
3324
3324
|
code: l.invalid_type
|
|
3325
3325
|
}), _;
|
|
3326
3326
|
}
|
|
3327
|
-
if (
|
|
3327
|
+
if (it(this, $e) || fr(this, $e, new Set(x.getValidEnumValues(this._def.values))), !it(this, $e).has(e.data)) {
|
|
3328
3328
|
const n = x.objectValues(t);
|
|
3329
3329
|
return h(s, {
|
|
3330
3330
|
received: s.data,
|
|
@@ -3338,12 +3338,12 @@ class qe extends w {
|
|
|
3338
3338
|
return this._def.values;
|
|
3339
3339
|
}
|
|
3340
3340
|
}
|
|
3341
|
-
|
|
3342
|
-
|
|
3341
|
+
$e = /* @__PURE__ */ new WeakMap();
|
|
3342
|
+
He.create = (r, e) => new He(u({
|
|
3343
3343
|
values: r,
|
|
3344
3344
|
typeName: y.ZodNativeEnum
|
|
3345
3345
|
}, b(e)));
|
|
3346
|
-
class
|
|
3346
|
+
class Oe extends w {
|
|
3347
3347
|
unwrap() {
|
|
3348
3348
|
return this._def.type;
|
|
3349
3349
|
}
|
|
@@ -3362,7 +3362,7 @@ class Ce extends w {
|
|
|
3362
3362
|
})));
|
|
3363
3363
|
}
|
|
3364
3364
|
}
|
|
3365
|
-
|
|
3365
|
+
Oe.create = (r, e) => new Oe(u({
|
|
3366
3366
|
type: r,
|
|
3367
3367
|
typeName: y.ZodPromise
|
|
3368
3368
|
}, b(e)));
|
|
@@ -3432,14 +3432,14 @@ class G extends w {
|
|
|
3432
3432
|
path: s.path,
|
|
3433
3433
|
parent: s
|
|
3434
3434
|
});
|
|
3435
|
-
if (!
|
|
3435
|
+
if (!be(i))
|
|
3436
3436
|
return i;
|
|
3437
3437
|
const o = n.transform(i.value, a);
|
|
3438
3438
|
if (o instanceof Promise)
|
|
3439
3439
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
3440
3440
|
return { status: t.value, value: o };
|
|
3441
3441
|
} else
|
|
3442
|
-
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) =>
|
|
3442
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => be(i) ? Promise.resolve(n.transform(i.value, a)).then((o) => ({ status: t.value, value: o })) : i);
|
|
3443
3443
|
x.assertNever(n);
|
|
3444
3444
|
}
|
|
3445
3445
|
}
|
|
@@ -3465,7 +3465,7 @@ ee.create = (r, e) => new ee(u({
|
|
|
3465
3465
|
innerType: r,
|
|
3466
3466
|
typeName: y.ZodOptional
|
|
3467
3467
|
}, b(e)));
|
|
3468
|
-
class
|
|
3468
|
+
class me extends w {
|
|
3469
3469
|
_parse(e) {
|
|
3470
3470
|
return this._getType(e) === p.null ? $(null) : this._def.innerType._parse(e);
|
|
3471
3471
|
}
|
|
@@ -3473,11 +3473,11 @@ class pe extends w {
|
|
|
3473
3473
|
return this._def.innerType;
|
|
3474
3474
|
}
|
|
3475
3475
|
}
|
|
3476
|
-
|
|
3476
|
+
me.create = (r, e) => new me(u({
|
|
3477
3477
|
innerType: r,
|
|
3478
3478
|
typeName: y.ZodNullable
|
|
3479
3479
|
}, b(e)));
|
|
3480
|
-
class
|
|
3480
|
+
class Je extends w {
|
|
3481
3481
|
_parse(e) {
|
|
3482
3482
|
const { ctx: t } = this._processInputParams(e);
|
|
3483
3483
|
let s = t.data;
|
|
@@ -3491,12 +3491,12 @@ class He extends w {
|
|
|
3491
3491
|
return this._def.innerType;
|
|
3492
3492
|
}
|
|
3493
3493
|
}
|
|
3494
|
-
|
|
3494
|
+
Je.create = (r, e) => new Je(u({
|
|
3495
3495
|
innerType: r,
|
|
3496
3496
|
typeName: y.ZodDefault,
|
|
3497
3497
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default
|
|
3498
3498
|
}, b(e)));
|
|
3499
|
-
class
|
|
3499
|
+
class Ge extends w {
|
|
3500
3500
|
_parse(e) {
|
|
3501
3501
|
const { ctx: t } = this._processInputParams(e), s = g(u({}, t), {
|
|
3502
3502
|
common: g(u({}, t.common), {
|
|
@@ -3507,11 +3507,11 @@ class Je extends w {
|
|
|
3507
3507
|
path: s.path,
|
|
3508
3508
|
parent: u({}, s)
|
|
3509
3509
|
});
|
|
3510
|
-
return
|
|
3510
|
+
return Fe(n) ? n.then((a) => ({
|
|
3511
3511
|
status: "valid",
|
|
3512
3512
|
value: a.status === "valid" ? a.value : this._def.catchValue({
|
|
3513
3513
|
get error() {
|
|
3514
|
-
return new
|
|
3514
|
+
return new W(s.common.issues);
|
|
3515
3515
|
},
|
|
3516
3516
|
input: s.data
|
|
3517
3517
|
})
|
|
@@ -3519,7 +3519,7 @@ class Je extends w {
|
|
|
3519
3519
|
status: "valid",
|
|
3520
3520
|
value: n.status === "valid" ? n.value : this._def.catchValue({
|
|
3521
3521
|
get error() {
|
|
3522
|
-
return new
|
|
3522
|
+
return new W(s.common.issues);
|
|
3523
3523
|
},
|
|
3524
3524
|
input: s.data
|
|
3525
3525
|
})
|
|
@@ -3529,12 +3529,12 @@ class Je extends w {
|
|
|
3529
3529
|
return this._def.innerType;
|
|
3530
3530
|
}
|
|
3531
3531
|
}
|
|
3532
|
-
|
|
3532
|
+
Ge.create = (r, e) => new Ge(u({
|
|
3533
3533
|
innerType: r,
|
|
3534
3534
|
typeName: y.ZodCatch,
|
|
3535
3535
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch
|
|
3536
3536
|
}, b(e)));
|
|
3537
|
-
class
|
|
3537
|
+
class ut extends w {
|
|
3538
3538
|
_parse(e) {
|
|
3539
3539
|
if (this._getType(e) !== p.nan) {
|
|
3540
3540
|
const s = this._getOrReturnCtx(e);
|
|
@@ -3547,7 +3547,7 @@ class dt extends w {
|
|
|
3547
3547
|
return { status: "valid", value: e.data };
|
|
3548
3548
|
}
|
|
3549
3549
|
}
|
|
3550
|
-
|
|
3550
|
+
ut.create = (r) => new ut(u({
|
|
3551
3551
|
typeName: y.ZodNaN
|
|
3552
3552
|
}, b(r)));
|
|
3553
3553
|
const tn = Symbol("zod_brand");
|
|
@@ -3564,7 +3564,7 @@ class Mt extends w {
|
|
|
3564
3564
|
return this._def.type;
|
|
3565
3565
|
}
|
|
3566
3566
|
}
|
|
3567
|
-
class
|
|
3567
|
+
class Ye extends w {
|
|
3568
3568
|
_parse(e) {
|
|
3569
3569
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
3570
3570
|
if (s.common.async)
|
|
@@ -3597,47 +3597,47 @@ class Xe extends w {
|
|
|
3597
3597
|
}
|
|
3598
3598
|
}
|
|
3599
3599
|
static create(e, t) {
|
|
3600
|
-
return new
|
|
3600
|
+
return new Ye({
|
|
3601
3601
|
in: e,
|
|
3602
3602
|
out: t,
|
|
3603
3603
|
typeName: y.ZodPipeline
|
|
3604
3604
|
});
|
|
3605
3605
|
}
|
|
3606
3606
|
}
|
|
3607
|
-
class
|
|
3607
|
+
class Ke extends w {
|
|
3608
3608
|
_parse(e) {
|
|
3609
|
-
const t = this._def.innerType._parse(e), s = (n) => (
|
|
3610
|
-
return
|
|
3609
|
+
const t = this._def.innerType._parse(e), s = (n) => (be(n) && (n.value = Object.freeze(n.value)), n);
|
|
3610
|
+
return Fe(t) ? t.then((n) => s(n)) : s(t);
|
|
3611
3611
|
}
|
|
3612
3612
|
unwrap() {
|
|
3613
3613
|
return this._def.innerType;
|
|
3614
3614
|
}
|
|
3615
3615
|
}
|
|
3616
|
-
|
|
3616
|
+
Ke.create = (r, e) => new Ke(u({
|
|
3617
3617
|
innerType: r,
|
|
3618
3618
|
typeName: y.ZodReadonly
|
|
3619
3619
|
}, b(e)));
|
|
3620
|
-
function
|
|
3620
|
+
function Kt(r, e) {
|
|
3621
3621
|
const t = typeof r == "function" ? r(e) : typeof r == "string" ? { message: r } : r;
|
|
3622
3622
|
return typeof t == "string" ? { message: t } : t;
|
|
3623
3623
|
}
|
|
3624
|
-
function
|
|
3625
|
-
return r ?
|
|
3624
|
+
function yr(r, e = {}, t) {
|
|
3625
|
+
return r ? Ce.create().superRefine((s, n) => {
|
|
3626
3626
|
var a, i;
|
|
3627
3627
|
const o = r(s);
|
|
3628
3628
|
if (o instanceof Promise)
|
|
3629
3629
|
return o.then((c) => {
|
|
3630
3630
|
var d, f;
|
|
3631
3631
|
if (!c) {
|
|
3632
|
-
const v =
|
|
3633
|
-
n.addIssue(g(u({ code: "custom" }, v), { fatal:
|
|
3632
|
+
const v = Kt(e, s), j = (f = (d = v.fatal) !== null && d !== void 0 ? d : t) !== null && f !== void 0 ? f : !0;
|
|
3633
|
+
n.addIssue(g(u({ code: "custom" }, v), { fatal: j }));
|
|
3634
3634
|
}
|
|
3635
3635
|
});
|
|
3636
3636
|
if (!o) {
|
|
3637
|
-
const c =
|
|
3637
|
+
const c = Kt(e, s), d = (i = (a = c.fatal) !== null && a !== void 0 ? a : t) !== null && i !== void 0 ? i : !0;
|
|
3638
3638
|
n.addIssue(g(u({ code: "custom" }, c), { fatal: d }));
|
|
3639
3639
|
}
|
|
3640
|
-
}) :
|
|
3640
|
+
}) : Ce.create();
|
|
3641
3641
|
}
|
|
3642
3642
|
const rn = {
|
|
3643
3643
|
object: E.lazycreate
|
|
@@ -3648,80 +3648,80 @@ var y;
|
|
|
3648
3648
|
})(y || (y = {}));
|
|
3649
3649
|
const sn = (r, e = {
|
|
3650
3650
|
message: `Input not instance of ${r.name}`
|
|
3651
|
-
}) =>
|
|
3651
|
+
}) => yr((t) => t instanceof r, e), vr = H.create, _r = fe.create, nn = ut.create, an = he.create, br = Le.create, on = we.create, cn = ot.create, dn = Ve.create, un = De.create, ln = Ce.create, fn = _e.create, hn = oe.create, pn = ct.create, mn = J.create, gn = E.create, yn = E.strictCreate, vn = Ue.create, _n = lt.create, bn = We.create, wn = re.create, xn = ze.create, kn = dt.create, Tn = xe.create, Sn = Se.create, En = Be.create, An = qe.create, Cn = pe.create, On = He.create, In = Oe.create, Xt = G.create, Nn = ee.create, jn = me.create, Rn = G.createWithPreprocess, Zn = Ye.create, Mn = () => vr().optional(), Pn = () => _r().optional(), $n = () => br().optional(), Fn = {
|
|
3652
3652
|
string: (r) => H.create(g(u({}, r), { coerce: !0 })),
|
|
3653
|
-
number: (r) =>
|
|
3654
|
-
boolean: (r) =>
|
|
3653
|
+
number: (r) => fe.create(g(u({}, r), { coerce: !0 })),
|
|
3654
|
+
boolean: (r) => Le.create(g(u({}, r), {
|
|
3655
3655
|
coerce: !0
|
|
3656
3656
|
})),
|
|
3657
|
-
bigint: (r) =>
|
|
3658
|
-
date: (r) =>
|
|
3657
|
+
bigint: (r) => he.create(g(u({}, r), { coerce: !0 })),
|
|
3658
|
+
date: (r) => we.create(g(u({}, r), { coerce: !0 }))
|
|
3659
3659
|
}, Ln = _;
|
|
3660
3660
|
var S = /* @__PURE__ */ Object.freeze({
|
|
3661
3661
|
__proto__: null,
|
|
3662
3662
|
defaultErrorMap: Ae,
|
|
3663
3663
|
setErrorMap: js,
|
|
3664
|
-
getErrorMap:
|
|
3665
|
-
makeIssue:
|
|
3664
|
+
getErrorMap: nt,
|
|
3665
|
+
makeIssue: at,
|
|
3666
3666
|
EMPTY_PATH: Rs,
|
|
3667
3667
|
addIssueToContext: h,
|
|
3668
|
-
ParseStatus:
|
|
3668
|
+
ParseStatus: Z,
|
|
3669
3669
|
INVALID: _,
|
|
3670
3670
|
DIRTY: Te,
|
|
3671
3671
|
OK: $,
|
|
3672
3672
|
isAborted: Ot,
|
|
3673
|
-
isDirty:
|
|
3674
|
-
isValid:
|
|
3675
|
-
isAsync:
|
|
3673
|
+
isDirty: It,
|
|
3674
|
+
isValid: be,
|
|
3675
|
+
isAsync: Fe,
|
|
3676
3676
|
get util() {
|
|
3677
3677
|
return x;
|
|
3678
3678
|
},
|
|
3679
3679
|
get objectUtil() {
|
|
3680
|
-
return
|
|
3680
|
+
return Ct;
|
|
3681
3681
|
},
|
|
3682
3682
|
ZodParsedType: p,
|
|
3683
3683
|
getParsedType: ie,
|
|
3684
3684
|
ZodType: w,
|
|
3685
|
-
datetimeRegex:
|
|
3685
|
+
datetimeRegex: mr,
|
|
3686
3686
|
ZodString: H,
|
|
3687
|
-
ZodNumber:
|
|
3688
|
-
ZodBigInt:
|
|
3689
|
-
ZodBoolean:
|
|
3690
|
-
ZodDate:
|
|
3691
|
-
ZodSymbol:
|
|
3692
|
-
ZodUndefined:
|
|
3693
|
-
ZodNull:
|
|
3694
|
-
ZodAny:
|
|
3695
|
-
ZodUnknown:
|
|
3687
|
+
ZodNumber: fe,
|
|
3688
|
+
ZodBigInt: he,
|
|
3689
|
+
ZodBoolean: Le,
|
|
3690
|
+
ZodDate: we,
|
|
3691
|
+
ZodSymbol: ot,
|
|
3692
|
+
ZodUndefined: Ve,
|
|
3693
|
+
ZodNull: De,
|
|
3694
|
+
ZodAny: Ce,
|
|
3695
|
+
ZodUnknown: _e,
|
|
3696
3696
|
ZodNever: oe,
|
|
3697
|
-
ZodVoid:
|
|
3697
|
+
ZodVoid: ct,
|
|
3698
3698
|
ZodArray: J,
|
|
3699
3699
|
ZodObject: E,
|
|
3700
|
-
ZodUnion:
|
|
3701
|
-
ZodDiscriminatedUnion:
|
|
3702
|
-
ZodIntersection:
|
|
3700
|
+
ZodUnion: Ue,
|
|
3701
|
+
ZodDiscriminatedUnion: lt,
|
|
3702
|
+
ZodIntersection: We,
|
|
3703
3703
|
ZodTuple: re,
|
|
3704
3704
|
ZodRecord: ze,
|
|
3705
|
-
ZodMap:
|
|
3706
|
-
ZodSet:
|
|
3705
|
+
ZodMap: dt,
|
|
3706
|
+
ZodSet: xe,
|
|
3707
3707
|
ZodFunction: Se,
|
|
3708
|
-
ZodLazy:
|
|
3709
|
-
ZodLiteral:
|
|
3710
|
-
ZodEnum:
|
|
3711
|
-
ZodNativeEnum:
|
|
3712
|
-
ZodPromise:
|
|
3708
|
+
ZodLazy: Be,
|
|
3709
|
+
ZodLiteral: qe,
|
|
3710
|
+
ZodEnum: pe,
|
|
3711
|
+
ZodNativeEnum: He,
|
|
3712
|
+
ZodPromise: Oe,
|
|
3713
3713
|
ZodEffects: G,
|
|
3714
3714
|
ZodTransformer: G,
|
|
3715
3715
|
ZodOptional: ee,
|
|
3716
|
-
ZodNullable:
|
|
3717
|
-
ZodDefault:
|
|
3718
|
-
ZodCatch:
|
|
3719
|
-
ZodNaN:
|
|
3716
|
+
ZodNullable: me,
|
|
3717
|
+
ZodDefault: Je,
|
|
3718
|
+
ZodCatch: Ge,
|
|
3719
|
+
ZodNaN: ut,
|
|
3720
3720
|
BRAND: tn,
|
|
3721
3721
|
ZodBranded: Mt,
|
|
3722
|
-
ZodPipeline:
|
|
3723
|
-
ZodReadonly:
|
|
3724
|
-
custom:
|
|
3722
|
+
ZodPipeline: Ye,
|
|
3723
|
+
ZodReadonly: Ke,
|
|
3724
|
+
custom: yr,
|
|
3725
3725
|
Schema: w,
|
|
3726
3726
|
ZodSchema: w,
|
|
3727
3727
|
late: rn,
|
|
@@ -3732,11 +3732,11 @@ var S = /* @__PURE__ */ Object.freeze({
|
|
|
3732
3732
|
any: ln,
|
|
3733
3733
|
array: mn,
|
|
3734
3734
|
bigint: an,
|
|
3735
|
-
boolean:
|
|
3735
|
+
boolean: br,
|
|
3736
3736
|
date: on,
|
|
3737
3737
|
discriminatedUnion: _n,
|
|
3738
|
-
effect:
|
|
3739
|
-
enum:
|
|
3738
|
+
effect: Xt,
|
|
3739
|
+
enum: Cn,
|
|
3740
3740
|
function: Sn,
|
|
3741
3741
|
instanceof: sn,
|
|
3742
3742
|
intersection: bn,
|
|
@@ -3744,25 +3744,25 @@ var S = /* @__PURE__ */ Object.freeze({
|
|
|
3744
3744
|
literal: An,
|
|
3745
3745
|
map: kn,
|
|
3746
3746
|
nan: nn,
|
|
3747
|
-
nativeEnum:
|
|
3747
|
+
nativeEnum: On,
|
|
3748
3748
|
never: hn,
|
|
3749
3749
|
null: un,
|
|
3750
3750
|
nullable: jn,
|
|
3751
|
-
number:
|
|
3751
|
+
number: _r,
|
|
3752
3752
|
object: gn,
|
|
3753
3753
|
oboolean: $n,
|
|
3754
3754
|
onumber: Pn,
|
|
3755
|
-
optional:
|
|
3755
|
+
optional: Nn,
|
|
3756
3756
|
ostring: Mn,
|
|
3757
3757
|
pipeline: Zn,
|
|
3758
3758
|
preprocess: Rn,
|
|
3759
|
-
promise:
|
|
3759
|
+
promise: In,
|
|
3760
3760
|
record: xn,
|
|
3761
3761
|
set: Tn,
|
|
3762
3762
|
strictObject: yn,
|
|
3763
|
-
string:
|
|
3763
|
+
string: vr,
|
|
3764
3764
|
symbol: cn,
|
|
3765
|
-
transformer:
|
|
3765
|
+
transformer: Xt,
|
|
3766
3766
|
tuple: wn,
|
|
3767
3767
|
undefined: dn,
|
|
3768
3768
|
union: vn,
|
|
@@ -3770,8 +3770,8 @@ var S = /* @__PURE__ */ Object.freeze({
|
|
|
3770
3770
|
void: pn,
|
|
3771
3771
|
NEVER: Ln,
|
|
3772
3772
|
ZodIssueCode: l,
|
|
3773
|
-
quotelessJson:
|
|
3774
|
-
ZodError:
|
|
3773
|
+
quotelessJson: Ns,
|
|
3774
|
+
ZodError: W
|
|
3775
3775
|
});
|
|
3776
3776
|
const Vn = S.object({
|
|
3777
3777
|
language: S.enum(["typescript", "javascript"]).optional(),
|
|
@@ -3820,14 +3820,14 @@ const Vn = S.object({
|
|
|
3820
3820
|
throw t.cause = e.error, t;
|
|
3821
3821
|
}
|
|
3822
3822
|
return e.data;
|
|
3823
|
-
},
|
|
3823
|
+
}, Yt = /* @__PURE__ */ new Set([
|
|
3824
3824
|
"FRAME",
|
|
3825
3825
|
"INSTANCE",
|
|
3826
3826
|
"COMPONENT",
|
|
3827
3827
|
"COMPONENT_SET",
|
|
3828
3828
|
"GROUP"
|
|
3829
3829
|
]), Un = (r, e, t = { allowAutoSelectFirstNode: !0 }) => {
|
|
3830
|
-
const s =
|
|
3830
|
+
const s = ur(r.document, e);
|
|
3831
3831
|
if (!s)
|
|
3832
3832
|
return {
|
|
3833
3833
|
isValid: !1,
|
|
@@ -3835,7 +3835,7 @@ const Vn = S.object({
|
|
|
3835
3835
|
};
|
|
3836
3836
|
if (s.type === "CANVAS") {
|
|
3837
3837
|
const n = s.children.filter(
|
|
3838
|
-
(a) =>
|
|
3838
|
+
(a) => Yt.has(a.type)
|
|
3839
3839
|
);
|
|
3840
3840
|
return n.length === 0 ? {
|
|
3841
3841
|
isValid: !1,
|
|
@@ -3853,41 +3853,41 @@ const Vn = S.object({
|
|
|
3853
3853
|
reason: "Selected node is a page with multiple children"
|
|
3854
3854
|
};
|
|
3855
3855
|
}
|
|
3856
|
-
return
|
|
3856
|
+
return Yt.has(s.type) ? { isValid: !0, node: s } : {
|
|
3857
3857
|
isValid: !1,
|
|
3858
3858
|
reason: "Selected node type is not supported"
|
|
3859
3859
|
};
|
|
3860
3860
|
};
|
|
3861
|
-
var
|
|
3862
|
-
class
|
|
3861
|
+
var O, Xe, le, wr, st;
|
|
3862
|
+
class Qn {
|
|
3863
3863
|
constructor({
|
|
3864
3864
|
auth: e,
|
|
3865
3865
|
apiBaseAddress: t = "https://public-api.animaapp.com"
|
|
3866
3866
|
} = {}) {
|
|
3867
|
-
|
|
3868
|
-
|
|
3869
|
-
|
|
3870
|
-
|
|
3867
|
+
Qe(this, le);
|
|
3868
|
+
Qe(this, O);
|
|
3869
|
+
Qe(this, Xe);
|
|
3870
|
+
pt(this, Xe, t), e && (this.auth = e);
|
|
3871
3871
|
}
|
|
3872
3872
|
hasAuth() {
|
|
3873
|
-
return !!
|
|
3873
|
+
return !!N(this, O);
|
|
3874
3874
|
}
|
|
3875
3875
|
set auth(e) {
|
|
3876
|
-
|
|
3876
|
+
pt(this, O, e);
|
|
3877
3877
|
}
|
|
3878
3878
|
get headers() {
|
|
3879
3879
|
const e = {
|
|
3880
3880
|
"Content-Type": "application/json"
|
|
3881
3881
|
};
|
|
3882
|
-
return
|
|
3882
|
+
return N(this, O) && (e.Authorization = `Bearer ${N(this, O).token}`, "teamId" in N(this, O) && (e["X-Team-Id"] = N(this, O).teamId)), e;
|
|
3883
3883
|
}
|
|
3884
3884
|
generateCode(n) {
|
|
3885
3885
|
return C(this, arguments, function* (e, t = {}, s) {
|
|
3886
3886
|
var c;
|
|
3887
3887
|
const a = Dn(e.settings);
|
|
3888
|
-
e.figmaToken && (yield
|
|
3888
|
+
e.figmaToken && (yield Ne(this, le, wr).call(this, e.fileKey, e.figmaToken, e.nodesId, { allowAutoSelectFirstNode: (c = a.allowAutoSelectFirstNode) != null ? c : !0 }, s));
|
|
3889
3889
|
let i = e.tracking;
|
|
3890
|
-
|
|
3890
|
+
N(this, O) && "userId" in N(this, O) && N(this, O).userId && (i != null && i.externalId || (i = { externalId: N(this, O).userId }));
|
|
3891
3891
|
const o = {
|
|
3892
3892
|
tracking: i,
|
|
3893
3893
|
fileKey: e.fileKey,
|
|
@@ -3910,32 +3910,55 @@ class Yn {
|
|
|
3910
3910
|
enableGeneratePackageLock: a.enableGeneratePackageLock,
|
|
3911
3911
|
codegenSettings: a.codegenSettings
|
|
3912
3912
|
};
|
|
3913
|
-
return
|
|
3913
|
+
return Ne(this, le, st).call(this, "/v1/codegen", o, t, "codegen", s);
|
|
3914
|
+
});
|
|
3915
|
+
}
|
|
3916
|
+
generateCodeFromWebsite(n) {
|
|
3917
|
+
return C(this, arguments, function* (e, t = {}, s) {
|
|
3918
|
+
let a = e.tracking;
|
|
3919
|
+
N(this, O) && "userId" in N(this, O) && N(this, O).userId && (a != null && a.externalId || (a = { externalId: N(this, O).userId }));
|
|
3920
|
+
const i = {
|
|
3921
|
+
tracking: a,
|
|
3922
|
+
assetsStorage: e.assetsStorage,
|
|
3923
|
+
params: {
|
|
3924
|
+
input: {
|
|
3925
|
+
type: "url",
|
|
3926
|
+
url: e.url
|
|
3927
|
+
},
|
|
3928
|
+
conventions: {
|
|
3929
|
+
framework: e.settings.framework,
|
|
3930
|
+
language: e.settings.language,
|
|
3931
|
+
styling: e.settings.styling
|
|
3932
|
+
},
|
|
3933
|
+
assetsStorage: {
|
|
3934
|
+
type: "bundled"
|
|
3935
|
+
}
|
|
3936
|
+
}
|
|
3937
|
+
};
|
|
3938
|
+
return Ne(this, le, st).call(this, "/v1/l2c", i, t, "l2c", s);
|
|
3914
3939
|
});
|
|
3915
3940
|
}
|
|
3916
3941
|
/**
|
|
3917
|
-
* @
|
|
3918
|
-
* This API is experimental and may change or be removed in future releases.
|
|
3919
|
-
* Link2Code (l2c) flow.
|
|
3942
|
+
* @deprecated This method will be removed soon, please use `generateCodeFromWebsite` instead.
|
|
3920
3943
|
*/
|
|
3921
3944
|
generateLink2Code(n) {
|
|
3922
3945
|
return C(this, arguments, function* (e, t = {}, s) {
|
|
3923
3946
|
let a = e.tracking;
|
|
3924
|
-
|
|
3947
|
+
N(this, O) && "userId" in N(this, O) && N(this, O).userId && (a != null && a.externalId || (a = { externalId: N(this, O).userId }));
|
|
3925
3948
|
const i = {
|
|
3926
3949
|
tracking: a,
|
|
3927
3950
|
assetsStorage: e.assetsStorage,
|
|
3928
3951
|
params: e.params
|
|
3929
3952
|
};
|
|
3930
|
-
return
|
|
3953
|
+
return Ne(this, le, st).call(this, "/v1/l2c", i, t, "l2c", s);
|
|
3931
3954
|
});
|
|
3932
3955
|
}
|
|
3933
3956
|
}
|
|
3934
|
-
|
|
3957
|
+
O = new WeakMap(), Xe = new WeakMap(), le = new WeakSet(), wr = function(e, t, s, n, a) {
|
|
3935
3958
|
return C(this, null, function* () {
|
|
3936
3959
|
let i;
|
|
3937
3960
|
try {
|
|
3938
|
-
i = yield
|
|
3961
|
+
i = yield Is({
|
|
3939
3962
|
fileKey: e,
|
|
3940
3963
|
authToken: t,
|
|
3941
3964
|
params: {
|
|
@@ -3959,12 +3982,12 @@ I = new WeakMap(), Ke = new WeakMap(), xe = new WeakSet(), _r = function(e, t, s
|
|
|
3959
3982
|
reason: c.reason
|
|
3960
3983
|
});
|
|
3961
3984
|
});
|
|
3962
|
-
},
|
|
3985
|
+
}, st = function(e, t, s, n, a) {
|
|
3963
3986
|
return C(this, null, function* () {
|
|
3964
|
-
var v,
|
|
3987
|
+
var v, j, M, F, z, se, ge, ce, V;
|
|
3965
3988
|
if (this.hasAuth() === !1)
|
|
3966
3989
|
throw new Error('It needs to set "auth" before calling this method.');
|
|
3967
|
-
const i = {}, o = yield fetch(`${
|
|
3990
|
+
const i = {}, o = yield fetch(`${N(this, Xe)}${e}`, {
|
|
3968
3991
|
method: "POST",
|
|
3969
3992
|
headers: g(u({}, this.headers), {
|
|
3970
3993
|
Accept: "text/event-stream"
|
|
@@ -3977,7 +4000,7 @@ I = new WeakMap(), Ke = new WeakMap(), xe = new WeakSet(), _r = function(e, t, s
|
|
|
3977
4000
|
let q;
|
|
3978
4001
|
try {
|
|
3979
4002
|
q = JSON.parse(K);
|
|
3980
|
-
} catch (
|
|
4003
|
+
} catch (Ie) {
|
|
3981
4004
|
}
|
|
3982
4005
|
throw ((v = q == null ? void 0 : q.error) == null ? void 0 : v.name) === "ZodError" ? new de({
|
|
3983
4006
|
name: "HTTP error from Anima API",
|
|
@@ -4008,24 +4031,24 @@ I = new WeakMap(), Ke = new WeakMap(), xe = new WeakSet(), _r = function(e, t, s
|
|
|
4008
4031
|
if (K)
|
|
4009
4032
|
break;
|
|
4010
4033
|
f += d.decode(q, { stream: !0 });
|
|
4011
|
-
const
|
|
4034
|
+
const Ie = f.split(`
|
|
4012
4035
|
`);
|
|
4013
|
-
f =
|
|
4014
|
-
for (const A of
|
|
4036
|
+
f = Ie.pop() || "";
|
|
4037
|
+
for (const A of Ie)
|
|
4015
4038
|
if (!(!A.trim() || A.startsWith(":")) && A.startsWith("data: ")) {
|
|
4016
4039
|
let k;
|
|
4017
4040
|
try {
|
|
4018
4041
|
k = JSON.parse(A.slice(6));
|
|
4019
|
-
} catch (
|
|
4042
|
+
} catch (ft) {
|
|
4020
4043
|
continue;
|
|
4021
4044
|
}
|
|
4022
4045
|
switch (k.type) {
|
|
4023
4046
|
case "queueing": {
|
|
4024
|
-
typeof s == "function" ? s(k) : (
|
|
4047
|
+
typeof s == "function" ? s(k) : (j = s.onQueueing) == null || j.call(s);
|
|
4025
4048
|
break;
|
|
4026
4049
|
}
|
|
4027
4050
|
case "start": {
|
|
4028
|
-
i.sessionId = k.sessionId, typeof s == "function" ? s(k) : (
|
|
4051
|
+
i.sessionId = k.sessionId, typeof s == "function" ? s(k) : (M = s.onStart) == null || M.call(s, { sessionId: k.sessionId });
|
|
4029
4052
|
break;
|
|
4030
4053
|
}
|
|
4031
4054
|
case "pre_codegen": {
|
|
@@ -4035,7 +4058,7 @@ I = new WeakMap(), Ke = new WeakMap(), xe = new WeakSet(), _r = function(e, t, s
|
|
|
4035
4058
|
break;
|
|
4036
4059
|
}
|
|
4037
4060
|
case "assets_uploaded": {
|
|
4038
|
-
typeof s == "function" ? s(k) : (
|
|
4061
|
+
typeof s == "function" ? s(k) : (z = s.onAssetsUploaded) == null || z.call(s);
|
|
4039
4062
|
break;
|
|
4040
4063
|
}
|
|
4041
4064
|
case "assets_list": {
|
|
@@ -4043,7 +4066,7 @@ I = new WeakMap(), Ke = new WeakMap(), xe = new WeakSet(), _r = function(e, t, s
|
|
|
4043
4066
|
break;
|
|
4044
4067
|
}
|
|
4045
4068
|
case "figma_metadata": {
|
|
4046
|
-
n === "codegen" && (i.figmaFileName = k.figmaFileName, i.figmaSelectedFrameName = k.figmaSelectedFrameName, typeof s == "function" ? s(k) : (
|
|
4069
|
+
n === "codegen" && (i.figmaFileName = k.figmaFileName, i.figmaSelectedFrameName = k.figmaSelectedFrameName, typeof s == "function" ? s(k) : (ge = s.onFigmaMetadata) == null || ge.call(s, {
|
|
4047
4070
|
figmaFileName: k.figmaFileName,
|
|
4048
4071
|
figmaSelectedFrameName: k.figmaSelectedFrameName
|
|
4049
4072
|
}));
|
|
@@ -4088,7 +4111,7 @@ I = new WeakMap(), Ke = new WeakMap(), xe = new WeakSet(), _r = function(e, t, s
|
|
|
4088
4111
|
});
|
|
4089
4112
|
});
|
|
4090
4113
|
};
|
|
4091
|
-
const
|
|
4114
|
+
const ea = (r) => {
|
|
4092
4115
|
var e;
|
|
4093
4116
|
if (!r)
|
|
4094
4117
|
return [!1, "", ""];
|
|
@@ -4104,20 +4127,20 @@ const Qn = (r) => {
|
|
|
4104
4127
|
} catch (t) {
|
|
4105
4128
|
return [!1, "", ""];
|
|
4106
4129
|
}
|
|
4107
|
-
},
|
|
4130
|
+
}, ta = ({
|
|
4108
4131
|
fileKey: r,
|
|
4109
4132
|
nodeId: e,
|
|
4110
4133
|
duplicate: t
|
|
4111
4134
|
}) => {
|
|
4112
4135
|
const s = new URL("https://www.figma.com");
|
|
4113
|
-
return s.pathname = `design/${r}`, t && (s.pathname = `${s.pathname}/duplicate`), e && s.searchParams.set("node-id", e.replace(":", "-")), s;
|
|
4136
|
+
return s.pathname = `design/${r}`, t && (s.pathname = `${s.pathname}/dummy/duplicate`), e && s.searchParams.set("node-id", e.replace(":", "-")), s;
|
|
4114
4137
|
};
|
|
4115
|
-
class
|
|
4138
|
+
class ra extends Error {
|
|
4116
4139
|
constructor(e, t) {
|
|
4117
4140
|
super(e), this.response = t;
|
|
4118
4141
|
}
|
|
4119
4142
|
}
|
|
4120
|
-
const
|
|
4143
|
+
const sa = ({
|
|
4121
4144
|
files: r,
|
|
4122
4145
|
screenPath: e = "src/screens"
|
|
4123
4146
|
}) => {
|
|
@@ -4125,9 +4148,9 @@ const ra = ({
|
|
|
4125
4148
|
function n(a) {
|
|
4126
4149
|
if (s.has(a) || !r[a])
|
|
4127
4150
|
return;
|
|
4128
|
-
s.add(a), t[a] = r[a],
|
|
4151
|
+
s.add(a), t[a] = r[a], Wn(r[a].content).forEach((o) => {
|
|
4129
4152
|
try {
|
|
4130
|
-
const c =
|
|
4153
|
+
const c = zn(a, o);
|
|
4131
4154
|
if (c.startsWith("src/")) {
|
|
4132
4155
|
const d = c.split("/").slice(0, -1).join("/");
|
|
4133
4156
|
Bn(r, d).forEach((v) => {
|
|
@@ -4146,7 +4169,7 @@ const ra = ({
|
|
|
4146
4169
|
a.startsWith(e) ? n(a) : a.startsWith("src/") || (t[a] = i);
|
|
4147
4170
|
}), t;
|
|
4148
4171
|
};
|
|
4149
|
-
function
|
|
4172
|
+
function Wn(r) {
|
|
4150
4173
|
const e = /import.*?["']([^"']+)["']/g, t = /export.*from\s+["']([^"']+)["']/g, s = [];
|
|
4151
4174
|
let n;
|
|
4152
4175
|
for (; (n = e.exec(r)) !== null; )
|
|
@@ -4155,7 +4178,7 @@ function zn(r) {
|
|
|
4155
4178
|
s.push(n[1]);
|
|
4156
4179
|
return [...new Set(s)];
|
|
4157
4180
|
}
|
|
4158
|
-
function
|
|
4181
|
+
function zn(r, e) {
|
|
4159
4182
|
if (!e.startsWith("."))
|
|
4160
4183
|
return e;
|
|
4161
4184
|
const t = r.split("/").slice(0, -1), s = e.split("/"), n = [...t];
|
|
@@ -4166,7 +4189,7 @@ function Wn(r, e) {
|
|
|
4166
4189
|
function Bn(r, e) {
|
|
4167
4190
|
return Object.keys(r).filter((t) => t.startsWith(e));
|
|
4168
4191
|
}
|
|
4169
|
-
function
|
|
4192
|
+
function Pt(r, e, t) {
|
|
4170
4193
|
return new ReadableStream({
|
|
4171
4194
|
start(s) {
|
|
4172
4195
|
t.call(r, e, (n) => {
|
|
@@ -4194,12 +4217,12 @@ function br(r, e, t) {
|
|
|
4194
4217
|
}
|
|
4195
4218
|
});
|
|
4196
4219
|
}
|
|
4197
|
-
const qn = (r, e) =>
|
|
4220
|
+
const qn = (r, e) => Pt(
|
|
4198
4221
|
r,
|
|
4199
4222
|
e,
|
|
4200
4223
|
r.generateCode
|
|
4201
4224
|
);
|
|
4202
|
-
function
|
|
4225
|
+
function $t(r) {
|
|
4203
4226
|
return C(this, null, function* () {
|
|
4204
4227
|
var i, o, c, d;
|
|
4205
4228
|
const [e, t] = r.tee(), s = yield e.getReader().read();
|
|
@@ -4213,13 +4236,13 @@ function wr(r) {
|
|
|
4213
4236
|
const n = new TextEncoder(), a = t.pipeThrough(
|
|
4214
4237
|
new TransformStream({
|
|
4215
4238
|
transform(f, v) {
|
|
4216
|
-
const
|
|
4239
|
+
const j = `event: ${f.type}
|
|
4217
4240
|
data: ${JSON.stringify(
|
|
4218
4241
|
f
|
|
4219
4242
|
)}
|
|
4220
4243
|
|
|
4221
4244
|
`;
|
|
4222
|
-
v.enqueue(n.encode(
|
|
4245
|
+
v.enqueue(n.encode(j));
|
|
4223
4246
|
}
|
|
4224
4247
|
})
|
|
4225
4248
|
);
|
|
@@ -4233,44 +4256,53 @@ data: ${JSON.stringify(
|
|
|
4233
4256
|
});
|
|
4234
4257
|
});
|
|
4235
4258
|
}
|
|
4236
|
-
const
|
|
4259
|
+
const na = (r, e) => C(void 0, null, function* () {
|
|
4237
4260
|
const t = qn(r, e);
|
|
4238
|
-
return
|
|
4239
|
-
}), Hn = (r, e) =>
|
|
4261
|
+
return $t(t);
|
|
4262
|
+
}), Hn = (r, e) => Pt(
|
|
4240
4263
|
r,
|
|
4241
4264
|
e,
|
|
4242
|
-
r.
|
|
4243
|
-
),
|
|
4265
|
+
r.generateCodeFromWebsite
|
|
4266
|
+
), aa = (r, e) => C(void 0, null, function* () {
|
|
4244
4267
|
const t = Hn(r, e);
|
|
4245
|
-
return
|
|
4268
|
+
return $t(t);
|
|
4269
|
+
}), Jn = (r, e) => Pt(
|
|
4270
|
+
r,
|
|
4271
|
+
e,
|
|
4272
|
+
r.generateLink2Code
|
|
4273
|
+
), ia = (r, e) => C(void 0, null, function* () {
|
|
4274
|
+
const t = Jn(r, e);
|
|
4275
|
+
return $t(t);
|
|
4246
4276
|
});
|
|
4247
4277
|
export {
|
|
4248
|
-
|
|
4278
|
+
Qn as Anima,
|
|
4249
4279
|
de as CodegenError,
|
|
4250
4280
|
Ar as FigmaTokenIssue,
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4281
|
+
Ir as NotFound,
|
|
4282
|
+
Cr as RateLimitExceeded,
|
|
4283
|
+
Or as RequestTooLarge,
|
|
4284
|
+
ra as ResponseError,
|
|
4255
4285
|
jr as UnknownFigmaApiException,
|
|
4256
|
-
|
|
4286
|
+
aa as createCodeFromWebsiteResponseEventStream,
|
|
4287
|
+
Hn as createCodeFromWebsiteStream,
|
|
4288
|
+
na as createCodegenResponseEventStream,
|
|
4257
4289
|
qn as createCodegenStream,
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4290
|
+
ia as createLink2CodeResponseEventStream,
|
|
4291
|
+
Jn as createLink2CodeStream,
|
|
4292
|
+
ur as findChildrenNode,
|
|
4293
|
+
ta as formatToFigmaLink,
|
|
4294
|
+
Xn as getFigmaApiErrorType,
|
|
4295
|
+
Is as getFigmaFile,
|
|
4296
|
+
Yn as getFileNodes,
|
|
4297
|
+
sa as getRelatedScreenFiles,
|
|
4266
4298
|
Zr as isFigmaTokenIssue,
|
|
4267
4299
|
Un as isNodeCodegenCompatible,
|
|
4268
|
-
|
|
4300
|
+
Nr as isNotFound,
|
|
4269
4301
|
Rr as isRateLimitExceeded,
|
|
4270
4302
|
Mr as isRequestTooLarge,
|
|
4271
|
-
|
|
4272
|
-
|
|
4303
|
+
Kn as isUnknownFigmaApiException,
|
|
4304
|
+
ea as isValidFigmaUrl,
|
|
4273
4305
|
Dn as validateSettings,
|
|
4274
|
-
|
|
4306
|
+
nr as wrapFigmaApiError
|
|
4275
4307
|
};
|
|
4276
4308
|
//# sourceMappingURL=index.js.map
|