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