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