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