@telemetryos/sdk 1.0.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/README.md +588 -0
- package/dist/client.d.ts +7 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +210 -0
- package/dist/index.js +3839 -0
- package/dist/index.spec.d.ts +1 -0
- package/dist/overrides.d.ts +7 -0
- package/dist/playlist.d.ts +8 -0
- package/dist/test-setup.d.ts +1 -0
- package/package.json +65 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,3839 @@
|
|
|
1
|
+
var b;
|
|
2
|
+
(function(a) {
|
|
3
|
+
a.assertEqual = (n) => n;
|
|
4
|
+
function e(n) {
|
|
5
|
+
}
|
|
6
|
+
a.assertIs = e;
|
|
7
|
+
function t(n) {
|
|
8
|
+
throw new Error();
|
|
9
|
+
}
|
|
10
|
+
a.assertNever = t, a.arrayToEnum = (n) => {
|
|
11
|
+
const i = {};
|
|
12
|
+
for (const r of n)
|
|
13
|
+
i[r] = r;
|
|
14
|
+
return i;
|
|
15
|
+
}, a.getValidEnumValues = (n) => {
|
|
16
|
+
const i = a.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), r = {};
|
|
17
|
+
for (const o of i)
|
|
18
|
+
r[o] = n[o];
|
|
19
|
+
return a.objectValues(r);
|
|
20
|
+
}, a.objectValues = (n) => a.objectKeys(n).map(function(i) {
|
|
21
|
+
return n[i];
|
|
22
|
+
}), a.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
|
|
23
|
+
const i = [];
|
|
24
|
+
for (const r in n)
|
|
25
|
+
Object.prototype.hasOwnProperty.call(n, r) && i.push(r);
|
|
26
|
+
return i;
|
|
27
|
+
}, a.find = (n, i) => {
|
|
28
|
+
for (const r of n)
|
|
29
|
+
if (i(r))
|
|
30
|
+
return r;
|
|
31
|
+
}, a.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && isFinite(n) && Math.floor(n) === n;
|
|
32
|
+
function s(n, i = " | ") {
|
|
33
|
+
return n.map((r) => typeof r == "string" ? `'${r}'` : r).join(i);
|
|
34
|
+
}
|
|
35
|
+
a.joinValues = s, a.jsonStringifyReplacer = (n, i) => typeof i == "bigint" ? i.toString() : i;
|
|
36
|
+
})(b || (b = {}));
|
|
37
|
+
var Ie;
|
|
38
|
+
(function(a) {
|
|
39
|
+
a.mergeShapes = (e, t) => ({
|
|
40
|
+
...e,
|
|
41
|
+
...t
|
|
42
|
+
// second overwrites first
|
|
43
|
+
});
|
|
44
|
+
})(Ie || (Ie = {}));
|
|
45
|
+
const h = b.arrayToEnum([
|
|
46
|
+
"string",
|
|
47
|
+
"nan",
|
|
48
|
+
"number",
|
|
49
|
+
"integer",
|
|
50
|
+
"float",
|
|
51
|
+
"boolean",
|
|
52
|
+
"date",
|
|
53
|
+
"bigint",
|
|
54
|
+
"symbol",
|
|
55
|
+
"function",
|
|
56
|
+
"undefined",
|
|
57
|
+
"null",
|
|
58
|
+
"array",
|
|
59
|
+
"object",
|
|
60
|
+
"unknown",
|
|
61
|
+
"promise",
|
|
62
|
+
"void",
|
|
63
|
+
"never",
|
|
64
|
+
"map",
|
|
65
|
+
"set"
|
|
66
|
+
]), E = (a) => {
|
|
67
|
+
switch (typeof a) {
|
|
68
|
+
case "undefined":
|
|
69
|
+
return h.undefined;
|
|
70
|
+
case "string":
|
|
71
|
+
return h.string;
|
|
72
|
+
case "number":
|
|
73
|
+
return isNaN(a) ? h.nan : h.number;
|
|
74
|
+
case "boolean":
|
|
75
|
+
return h.boolean;
|
|
76
|
+
case "function":
|
|
77
|
+
return h.function;
|
|
78
|
+
case "bigint":
|
|
79
|
+
return h.bigint;
|
|
80
|
+
case "symbol":
|
|
81
|
+
return h.symbol;
|
|
82
|
+
case "object":
|
|
83
|
+
return Array.isArray(a) ? h.array : a === null ? h.null : a.then && typeof a.then == "function" && a.catch && typeof a.catch == "function" ? h.promise : typeof Map < "u" && a instanceof Map ? h.map : typeof Set < "u" && a instanceof Set ? h.set : typeof Date < "u" && a instanceof Date ? h.date : h.object;
|
|
84
|
+
default:
|
|
85
|
+
return h.unknown;
|
|
86
|
+
}
|
|
87
|
+
}, c = b.arrayToEnum([
|
|
88
|
+
"invalid_type",
|
|
89
|
+
"invalid_literal",
|
|
90
|
+
"custom",
|
|
91
|
+
"invalid_union",
|
|
92
|
+
"invalid_union_discriminator",
|
|
93
|
+
"invalid_enum_value",
|
|
94
|
+
"unrecognized_keys",
|
|
95
|
+
"invalid_arguments",
|
|
96
|
+
"invalid_return_type",
|
|
97
|
+
"invalid_date",
|
|
98
|
+
"invalid_string",
|
|
99
|
+
"too_small",
|
|
100
|
+
"too_big",
|
|
101
|
+
"invalid_intersection_types",
|
|
102
|
+
"not_multiple_of",
|
|
103
|
+
"not_finite"
|
|
104
|
+
]), et = (a) => JSON.stringify(a, null, 2).replace(/"([^"]+)":/g, "$1:");
|
|
105
|
+
let C = class qe extends Error {
|
|
106
|
+
get errors() {
|
|
107
|
+
return this.issues;
|
|
108
|
+
}
|
|
109
|
+
constructor(e) {
|
|
110
|
+
super(), this.issues = [], this.addIssue = (s) => {
|
|
111
|
+
this.issues = [...this.issues, s];
|
|
112
|
+
}, this.addIssues = (s = []) => {
|
|
113
|
+
this.issues = [...this.issues, ...s];
|
|
114
|
+
};
|
|
115
|
+
const t = new.target.prototype;
|
|
116
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
117
|
+
}
|
|
118
|
+
format(e) {
|
|
119
|
+
const t = e || function(i) {
|
|
120
|
+
return i.message;
|
|
121
|
+
}, s = { _errors: [] }, n = (i) => {
|
|
122
|
+
for (const r of i.issues)
|
|
123
|
+
if (r.code === "invalid_union")
|
|
124
|
+
r.unionErrors.map(n);
|
|
125
|
+
else if (r.code === "invalid_return_type")
|
|
126
|
+
n(r.returnTypeError);
|
|
127
|
+
else if (r.code === "invalid_arguments")
|
|
128
|
+
n(r.argumentsError);
|
|
129
|
+
else if (r.path.length === 0)
|
|
130
|
+
s._errors.push(t(r));
|
|
131
|
+
else {
|
|
132
|
+
let o = s, d = 0;
|
|
133
|
+
for (; d < r.path.length; ) {
|
|
134
|
+
const u = r.path[d];
|
|
135
|
+
d === r.path.length - 1 ? (o[u] = o[u] || { _errors: [] }, o[u]._errors.push(t(r))) : o[u] = o[u] || { _errors: [] }, o = o[u], d++;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
return n(this), s;
|
|
140
|
+
}
|
|
141
|
+
static assert(e) {
|
|
142
|
+
if (!(e instanceof qe))
|
|
143
|
+
throw new Error(`Not a ZodError: ${e}`);
|
|
144
|
+
}
|
|
145
|
+
toString() {
|
|
146
|
+
return this.message;
|
|
147
|
+
}
|
|
148
|
+
get message() {
|
|
149
|
+
return JSON.stringify(this.issues, b.jsonStringifyReplacer, 2);
|
|
150
|
+
}
|
|
151
|
+
get isEmpty() {
|
|
152
|
+
return this.issues.length === 0;
|
|
153
|
+
}
|
|
154
|
+
flatten(e = (t) => t.message) {
|
|
155
|
+
const t = {}, s = [];
|
|
156
|
+
for (const n of this.issues)
|
|
157
|
+
n.path.length > 0 ? (t[n.path[0]] = t[n.path[0]] || [], t[n.path[0]].push(e(n))) : s.push(e(n));
|
|
158
|
+
return { formErrors: s, fieldErrors: t };
|
|
159
|
+
}
|
|
160
|
+
get formErrors() {
|
|
161
|
+
return this.flatten();
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
C.create = (a) => new C(a);
|
|
165
|
+
const W = (a, e) => {
|
|
166
|
+
let t;
|
|
167
|
+
switch (a.code) {
|
|
168
|
+
case c.invalid_type:
|
|
169
|
+
a.received === h.undefined ? t = "Required" : t = `Expected ${a.expected}, received ${a.received}`;
|
|
170
|
+
break;
|
|
171
|
+
case c.invalid_literal:
|
|
172
|
+
t = `Invalid literal value, expected ${JSON.stringify(a.expected, b.jsonStringifyReplacer)}`;
|
|
173
|
+
break;
|
|
174
|
+
case c.unrecognized_keys:
|
|
175
|
+
t = `Unrecognized key(s) in object: ${b.joinValues(a.keys, ", ")}`;
|
|
176
|
+
break;
|
|
177
|
+
case c.invalid_union:
|
|
178
|
+
t = "Invalid input";
|
|
179
|
+
break;
|
|
180
|
+
case c.invalid_union_discriminator:
|
|
181
|
+
t = `Invalid discriminator value. Expected ${b.joinValues(a.options)}`;
|
|
182
|
+
break;
|
|
183
|
+
case c.invalid_enum_value:
|
|
184
|
+
t = `Invalid enum value. Expected ${b.joinValues(a.options)}, received '${a.received}'`;
|
|
185
|
+
break;
|
|
186
|
+
case c.invalid_arguments:
|
|
187
|
+
t = "Invalid function arguments";
|
|
188
|
+
break;
|
|
189
|
+
case c.invalid_return_type:
|
|
190
|
+
t = "Invalid function return type";
|
|
191
|
+
break;
|
|
192
|
+
case c.invalid_date:
|
|
193
|
+
t = "Invalid date";
|
|
194
|
+
break;
|
|
195
|
+
case c.invalid_string:
|
|
196
|
+
typeof a.validation == "object" ? "includes" in a.validation ? (t = `Invalid input: must include "${a.validation.includes}"`, typeof a.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${a.validation.position}`)) : "startsWith" in a.validation ? t = `Invalid input: must start with "${a.validation.startsWith}"` : "endsWith" in a.validation ? t = `Invalid input: must end with "${a.validation.endsWith}"` : b.assertNever(a.validation) : a.validation !== "regex" ? t = `Invalid ${a.validation}` : t = "Invalid";
|
|
197
|
+
break;
|
|
198
|
+
case c.too_small:
|
|
199
|
+
a.type === "array" ? t = `Array must contain ${a.exact ? "exactly" : a.inclusive ? "at least" : "more than"} ${a.minimum} element(s)` : a.type === "string" ? t = `String must contain ${a.exact ? "exactly" : a.inclusive ? "at least" : "over"} ${a.minimum} character(s)` : a.type === "number" ? t = `Number must be ${a.exact ? "exactly equal to " : a.inclusive ? "greater than or equal to " : "greater than "}${a.minimum}` : a.type === "date" ? t = `Date must be ${a.exact ? "exactly equal to " : a.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(a.minimum))}` : t = "Invalid input";
|
|
200
|
+
break;
|
|
201
|
+
case c.too_big:
|
|
202
|
+
a.type === "array" ? t = `Array must contain ${a.exact ? "exactly" : a.inclusive ? "at most" : "less than"} ${a.maximum} element(s)` : a.type === "string" ? t = `String must contain ${a.exact ? "exactly" : a.inclusive ? "at most" : "under"} ${a.maximum} character(s)` : a.type === "number" ? t = `Number must be ${a.exact ? "exactly" : a.inclusive ? "less than or equal to" : "less than"} ${a.maximum}` : a.type === "bigint" ? t = `BigInt must be ${a.exact ? "exactly" : a.inclusive ? "less than or equal to" : "less than"} ${a.maximum}` : a.type === "date" ? t = `Date must be ${a.exact ? "exactly" : a.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(a.maximum))}` : t = "Invalid input";
|
|
203
|
+
break;
|
|
204
|
+
case c.custom:
|
|
205
|
+
t = "Invalid input";
|
|
206
|
+
break;
|
|
207
|
+
case c.invalid_intersection_types:
|
|
208
|
+
t = "Intersection results could not be merged";
|
|
209
|
+
break;
|
|
210
|
+
case c.not_multiple_of:
|
|
211
|
+
t = `Number must be a multiple of ${a.multipleOf}`;
|
|
212
|
+
break;
|
|
213
|
+
case c.not_finite:
|
|
214
|
+
t = "Number must be finite";
|
|
215
|
+
break;
|
|
216
|
+
default:
|
|
217
|
+
t = e.defaultError, b.assertNever(a);
|
|
218
|
+
}
|
|
219
|
+
return { message: t };
|
|
220
|
+
};
|
|
221
|
+
let Be = W;
|
|
222
|
+
function tt(a) {
|
|
223
|
+
Be = a;
|
|
224
|
+
}
|
|
225
|
+
function ve() {
|
|
226
|
+
return Be;
|
|
227
|
+
}
|
|
228
|
+
const be = (a) => {
|
|
229
|
+
const { data: e, path: t, errorMaps: s, issueData: n } = a, i = [...t, ...n.path || []], r = {
|
|
230
|
+
...n,
|
|
231
|
+
path: i
|
|
232
|
+
};
|
|
233
|
+
if (n.message !== void 0)
|
|
234
|
+
return {
|
|
235
|
+
...n,
|
|
236
|
+
path: i,
|
|
237
|
+
message: n.message
|
|
238
|
+
};
|
|
239
|
+
let o = "";
|
|
240
|
+
const d = s.filter((u) => !!u).slice().reverse();
|
|
241
|
+
for (const u of d)
|
|
242
|
+
o = u(r, { data: e, defaultError: o }).message;
|
|
243
|
+
return {
|
|
244
|
+
...n,
|
|
245
|
+
path: i,
|
|
246
|
+
message: o
|
|
247
|
+
};
|
|
248
|
+
}, st = [];
|
|
249
|
+
function l(a, e) {
|
|
250
|
+
const t = ve(), s = be({
|
|
251
|
+
issueData: e,
|
|
252
|
+
data: a.data,
|
|
253
|
+
path: a.path,
|
|
254
|
+
errorMaps: [
|
|
255
|
+
a.common.contextualErrorMap,
|
|
256
|
+
// contextual error map is first priority
|
|
257
|
+
a.schemaErrorMap,
|
|
258
|
+
// then schema-bound map if available
|
|
259
|
+
t,
|
|
260
|
+
// then global override map
|
|
261
|
+
t === W ? void 0 : W
|
|
262
|
+
// then global default map
|
|
263
|
+
].filter((n) => !!n)
|
|
264
|
+
});
|
|
265
|
+
a.common.issues.push(s);
|
|
266
|
+
}
|
|
267
|
+
let Z = class Ve {
|
|
268
|
+
constructor() {
|
|
269
|
+
this.value = "valid";
|
|
270
|
+
}
|
|
271
|
+
dirty() {
|
|
272
|
+
this.value === "valid" && (this.value = "dirty");
|
|
273
|
+
}
|
|
274
|
+
abort() {
|
|
275
|
+
this.value !== "aborted" && (this.value = "aborted");
|
|
276
|
+
}
|
|
277
|
+
static mergeArray(e, t) {
|
|
278
|
+
const s = [];
|
|
279
|
+
for (const n of t) {
|
|
280
|
+
if (n.status === "aborted")
|
|
281
|
+
return f;
|
|
282
|
+
n.status === "dirty" && e.dirty(), s.push(n.value);
|
|
283
|
+
}
|
|
284
|
+
return { status: e.value, value: s };
|
|
285
|
+
}
|
|
286
|
+
static async mergeObjectAsync(e, t) {
|
|
287
|
+
const s = [];
|
|
288
|
+
for (const n of t) {
|
|
289
|
+
const i = await n.key, r = await n.value;
|
|
290
|
+
s.push({
|
|
291
|
+
key: i,
|
|
292
|
+
value: r
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
return Ve.mergeObjectSync(e, s);
|
|
296
|
+
}
|
|
297
|
+
static mergeObjectSync(e, t) {
|
|
298
|
+
const s = {};
|
|
299
|
+
for (const n of t) {
|
|
300
|
+
const { key: i, value: r } = n;
|
|
301
|
+
if (i.status === "aborted" || r.status === "aborted")
|
|
302
|
+
return f;
|
|
303
|
+
i.status === "dirty" && e.dirty(), r.status === "dirty" && e.dirty(), i.value !== "__proto__" && (typeof r.value < "u" || n.alwaysSet) && (s[i.value] = r.value);
|
|
304
|
+
}
|
|
305
|
+
return { status: e.value, value: s };
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
const f = Object.freeze({
|
|
309
|
+
status: "aborted"
|
|
310
|
+
}), ke = (a) => ({ status: "dirty", value: a }), x = (a) => ({ status: "valid", value: a }), Ee = (a) => a.status === "aborted", $e = (a) => a.status === "dirty", z = (a) => a.status === "valid", Q = (a) => typeof Promise < "u" && a instanceof Promise;
|
|
311
|
+
function we(a, e, t, s) {
|
|
312
|
+
if (typeof e == "function" ? a !== e || !0 : !e.has(a)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
313
|
+
return e.get(a);
|
|
314
|
+
}
|
|
315
|
+
function Ue(a, e, t, s, n) {
|
|
316
|
+
if (typeof e == "function" ? a !== e || !0 : !e.has(a)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
317
|
+
return e.set(a, t), t;
|
|
318
|
+
}
|
|
319
|
+
var p;
|
|
320
|
+
(function(a) {
|
|
321
|
+
a.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, a.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
322
|
+
})(p || (p = {}));
|
|
323
|
+
var G, X;
|
|
324
|
+
class A {
|
|
325
|
+
constructor(e, t, s, n) {
|
|
326
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = s, this._key = n;
|
|
327
|
+
}
|
|
328
|
+
get path() {
|
|
329
|
+
return this._cachedPath.length || (this._key instanceof Array ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
const Le = (a, e) => {
|
|
333
|
+
if (z(e))
|
|
334
|
+
return { success: !0, data: e.value };
|
|
335
|
+
if (!a.common.issues.length)
|
|
336
|
+
throw new Error("Validation failed but no issues detected.");
|
|
337
|
+
return {
|
|
338
|
+
success: !1,
|
|
339
|
+
get error() {
|
|
340
|
+
if (this._error)
|
|
341
|
+
return this._error;
|
|
342
|
+
const t = new C(a.common.issues);
|
|
343
|
+
return this._error = t, this._error;
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
};
|
|
347
|
+
function y(a) {
|
|
348
|
+
if (!a)
|
|
349
|
+
return {};
|
|
350
|
+
const { errorMap: e, invalid_type_error: t, required_error: s, description: n } = a;
|
|
351
|
+
if (e && (t || s))
|
|
352
|
+
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
353
|
+
return e ? { errorMap: e, description: n } : { errorMap: (i, r) => {
|
|
354
|
+
var o, d;
|
|
355
|
+
const { message: u } = a;
|
|
356
|
+
return i.code === "invalid_enum_value" ? { message: u ?? r.defaultError } : typeof r.data > "u" ? { message: (o = u ?? s) !== null && o !== void 0 ? o : r.defaultError } : i.code !== "invalid_type" ? { message: r.defaultError } : { message: (d = u ?? t) !== null && d !== void 0 ? d : r.defaultError };
|
|
357
|
+
}, description: n };
|
|
358
|
+
}
|
|
359
|
+
class _ {
|
|
360
|
+
get description() {
|
|
361
|
+
return this._def.description;
|
|
362
|
+
}
|
|
363
|
+
_getType(e) {
|
|
364
|
+
return E(e.data);
|
|
365
|
+
}
|
|
366
|
+
_getOrReturnCtx(e, t) {
|
|
367
|
+
return t || {
|
|
368
|
+
common: e.parent.common,
|
|
369
|
+
data: e.data,
|
|
370
|
+
parsedType: E(e.data),
|
|
371
|
+
schemaErrorMap: this._def.errorMap,
|
|
372
|
+
path: e.path,
|
|
373
|
+
parent: e.parent
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
_processInputParams(e) {
|
|
377
|
+
return {
|
|
378
|
+
status: new Z(),
|
|
379
|
+
ctx: {
|
|
380
|
+
common: e.parent.common,
|
|
381
|
+
data: e.data,
|
|
382
|
+
parsedType: E(e.data),
|
|
383
|
+
schemaErrorMap: this._def.errorMap,
|
|
384
|
+
path: e.path,
|
|
385
|
+
parent: e.parent
|
|
386
|
+
}
|
|
387
|
+
};
|
|
388
|
+
}
|
|
389
|
+
_parseSync(e) {
|
|
390
|
+
const t = this._parse(e);
|
|
391
|
+
if (Q(t))
|
|
392
|
+
throw new Error("Synchronous parse encountered promise.");
|
|
393
|
+
return t;
|
|
394
|
+
}
|
|
395
|
+
_parseAsync(e) {
|
|
396
|
+
const t = this._parse(e);
|
|
397
|
+
return Promise.resolve(t);
|
|
398
|
+
}
|
|
399
|
+
parse(e, t) {
|
|
400
|
+
const s = this.safeParse(e, t);
|
|
401
|
+
if (s.success)
|
|
402
|
+
return s.data;
|
|
403
|
+
throw s.error;
|
|
404
|
+
}
|
|
405
|
+
safeParse(e, t) {
|
|
406
|
+
var s;
|
|
407
|
+
const n = {
|
|
408
|
+
common: {
|
|
409
|
+
issues: [],
|
|
410
|
+
async: (s = t == null ? void 0 : t.async) !== null && s !== void 0 ? s : !1,
|
|
411
|
+
contextualErrorMap: t == null ? void 0 : t.errorMap
|
|
412
|
+
},
|
|
413
|
+
path: (t == null ? void 0 : t.path) || [],
|
|
414
|
+
schemaErrorMap: this._def.errorMap,
|
|
415
|
+
parent: null,
|
|
416
|
+
data: e,
|
|
417
|
+
parsedType: E(e)
|
|
418
|
+
}, i = this._parseSync({ data: e, path: n.path, parent: n });
|
|
419
|
+
return Le(n, i);
|
|
420
|
+
}
|
|
421
|
+
"~validate"(e) {
|
|
422
|
+
var t, s;
|
|
423
|
+
const n = {
|
|
424
|
+
common: {
|
|
425
|
+
issues: [],
|
|
426
|
+
async: !!this["~standard"].async
|
|
427
|
+
},
|
|
428
|
+
path: [],
|
|
429
|
+
schemaErrorMap: this._def.errorMap,
|
|
430
|
+
parent: null,
|
|
431
|
+
data: e,
|
|
432
|
+
parsedType: E(e)
|
|
433
|
+
};
|
|
434
|
+
if (!this["~standard"].async)
|
|
435
|
+
try {
|
|
436
|
+
const i = this._parseSync({ data: e, path: [], parent: n });
|
|
437
|
+
return z(i) ? {
|
|
438
|
+
value: i.value
|
|
439
|
+
} : {
|
|
440
|
+
issues: n.common.issues
|
|
441
|
+
};
|
|
442
|
+
} catch (i) {
|
|
443
|
+
!((s = (t = i == null ? void 0 : i.message) === null || t === void 0 ? void 0 : t.toLowerCase()) === null || s === void 0) && s.includes("encountered") && (this["~standard"].async = !0), n.common = {
|
|
444
|
+
issues: [],
|
|
445
|
+
async: !0
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
return this._parseAsync({ data: e, path: [], parent: n }).then((i) => z(i) ? {
|
|
449
|
+
value: i.value
|
|
450
|
+
} : {
|
|
451
|
+
issues: n.common.issues
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
async parseAsync(e, t) {
|
|
455
|
+
const s = await this.safeParseAsync(e, t);
|
|
456
|
+
if (s.success)
|
|
457
|
+
return s.data;
|
|
458
|
+
throw s.error;
|
|
459
|
+
}
|
|
460
|
+
async safeParseAsync(e, t) {
|
|
461
|
+
const s = {
|
|
462
|
+
common: {
|
|
463
|
+
issues: [],
|
|
464
|
+
contextualErrorMap: t == null ? void 0 : t.errorMap,
|
|
465
|
+
async: !0
|
|
466
|
+
},
|
|
467
|
+
path: (t == null ? void 0 : t.path) || [],
|
|
468
|
+
schemaErrorMap: this._def.errorMap,
|
|
469
|
+
parent: null,
|
|
470
|
+
data: e,
|
|
471
|
+
parsedType: E(e)
|
|
472
|
+
}, n = this._parse({ data: e, path: s.path, parent: s }), i = await (Q(n) ? n : Promise.resolve(n));
|
|
473
|
+
return Le(s, i);
|
|
474
|
+
}
|
|
475
|
+
refine(e, t) {
|
|
476
|
+
const s = (n) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(n) : t;
|
|
477
|
+
return this._refinement((n, i) => {
|
|
478
|
+
const r = e(n), o = () => i.addIssue({
|
|
479
|
+
code: c.custom,
|
|
480
|
+
...s(n)
|
|
481
|
+
});
|
|
482
|
+
return typeof Promise < "u" && r instanceof Promise ? r.then((d) => d ? !0 : (o(), !1)) : r ? !0 : (o(), !1);
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
refinement(e, t) {
|
|
486
|
+
return this._refinement((s, n) => e(s) ? !0 : (n.addIssue(typeof t == "function" ? t(s, n) : t), !1));
|
|
487
|
+
}
|
|
488
|
+
_refinement(e) {
|
|
489
|
+
return new S({
|
|
490
|
+
schema: this,
|
|
491
|
+
typeName: m.ZodEffects,
|
|
492
|
+
effect: { type: "refinement", refinement: e }
|
|
493
|
+
});
|
|
494
|
+
}
|
|
495
|
+
superRefine(e) {
|
|
496
|
+
return this._refinement(e);
|
|
497
|
+
}
|
|
498
|
+
constructor(e) {
|
|
499
|
+
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
|
|
500
|
+
version: 1,
|
|
501
|
+
vendor: "zod",
|
|
502
|
+
validate: (t) => this["~validate"](t)
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
optional() {
|
|
506
|
+
return O.create(this, this._def);
|
|
507
|
+
}
|
|
508
|
+
nullable() {
|
|
509
|
+
return M.create(this, this._def);
|
|
510
|
+
}
|
|
511
|
+
nullish() {
|
|
512
|
+
return this.nullable().optional();
|
|
513
|
+
}
|
|
514
|
+
array() {
|
|
515
|
+
return B.create(this);
|
|
516
|
+
}
|
|
517
|
+
promise() {
|
|
518
|
+
return Y.create(this, this._def);
|
|
519
|
+
}
|
|
520
|
+
or(e) {
|
|
521
|
+
return ne.create([this, e], this._def);
|
|
522
|
+
}
|
|
523
|
+
and(e) {
|
|
524
|
+
return ie.create(this, e, this._def);
|
|
525
|
+
}
|
|
526
|
+
transform(e) {
|
|
527
|
+
return new S({
|
|
528
|
+
...y(this._def),
|
|
529
|
+
schema: this,
|
|
530
|
+
typeName: m.ZodEffects,
|
|
531
|
+
effect: { type: "transform", transform: e }
|
|
532
|
+
});
|
|
533
|
+
}
|
|
534
|
+
default(e) {
|
|
535
|
+
const t = typeof e == "function" ? e : () => e;
|
|
536
|
+
return new ue({
|
|
537
|
+
...y(this._def),
|
|
538
|
+
innerType: this,
|
|
539
|
+
defaultValue: t,
|
|
540
|
+
typeName: m.ZodDefault
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
brand() {
|
|
544
|
+
return new Fe({
|
|
545
|
+
typeName: m.ZodBranded,
|
|
546
|
+
type: this,
|
|
547
|
+
...y(this._def)
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
catch(e) {
|
|
551
|
+
const t = typeof e == "function" ? e : () => e;
|
|
552
|
+
return new le({
|
|
553
|
+
...y(this._def),
|
|
554
|
+
innerType: this,
|
|
555
|
+
catchValue: t,
|
|
556
|
+
typeName: m.ZodCatch
|
|
557
|
+
});
|
|
558
|
+
}
|
|
559
|
+
describe(e) {
|
|
560
|
+
const t = this.constructor;
|
|
561
|
+
return new t({
|
|
562
|
+
...this._def,
|
|
563
|
+
description: e
|
|
564
|
+
});
|
|
565
|
+
}
|
|
566
|
+
pipe(e) {
|
|
567
|
+
return me.create(this, e);
|
|
568
|
+
}
|
|
569
|
+
readonly() {
|
|
570
|
+
return he.create(this);
|
|
571
|
+
}
|
|
572
|
+
isOptional() {
|
|
573
|
+
return this.safeParse(void 0).success;
|
|
574
|
+
}
|
|
575
|
+
isNullable() {
|
|
576
|
+
return this.safeParse(null).success;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
const at = /^c[^\s-]{8,}$/i, nt = /^[0-9a-z]+$/, it = /^[0-9A-HJKMNP-TV-Z]{26}$/i, rt = /^[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, ot = /^[a-z0-9_-]{21}$/i, dt = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, ct = /^[-+]?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)?)??$/, ut = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, lt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
580
|
+
let Ae;
|
|
581
|
+
const ht = /^(?:(?: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])$/, pt = /^(?:(?: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])$/, mt = /^(([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]))$/, ft = /^(([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])$/, yt = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, gt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Ke = "((\\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])))", _t = new RegExp(`^${Ke}$`);
|
|
582
|
+
function He(a) {
|
|
583
|
+
let e = "[0-5]\\d";
|
|
584
|
+
a.precision ? e = `${e}\\.\\d{${a.precision}}` : a.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
585
|
+
const t = a.precision ? "+" : "?";
|
|
586
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
|
|
587
|
+
}
|
|
588
|
+
function vt(a) {
|
|
589
|
+
return new RegExp(`^${He(a)}$`);
|
|
590
|
+
}
|
|
591
|
+
function We(a) {
|
|
592
|
+
let e = `${Ke}T${He(a)}`;
|
|
593
|
+
const t = [];
|
|
594
|
+
return t.push(a.local ? "Z?" : "Z"), a.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
595
|
+
}
|
|
596
|
+
function bt(a, e) {
|
|
597
|
+
return !!((e === "v4" || !e) && ht.test(a) || (e === "v6" || !e) && mt.test(a));
|
|
598
|
+
}
|
|
599
|
+
function kt(a, e) {
|
|
600
|
+
if (!dt.test(a))
|
|
601
|
+
return !1;
|
|
602
|
+
try {
|
|
603
|
+
const [t] = a.split("."), s = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), n = JSON.parse(atob(s));
|
|
604
|
+
return !(typeof n != "object" || n === null || !n.typ || !n.alg || e && n.alg !== e);
|
|
605
|
+
} catch {
|
|
606
|
+
return !1;
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
function wt(a, e) {
|
|
610
|
+
return !!((e === "v4" || !e) && pt.test(a) || (e === "v6" || !e) && ft.test(a));
|
|
611
|
+
}
|
|
612
|
+
class N extends _ {
|
|
613
|
+
_parse(e) {
|
|
614
|
+
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
|
|
615
|
+
const n = this._getOrReturnCtx(e);
|
|
616
|
+
return l(n, {
|
|
617
|
+
code: c.invalid_type,
|
|
618
|
+
expected: h.string,
|
|
619
|
+
received: n.parsedType
|
|
620
|
+
}), f;
|
|
621
|
+
}
|
|
622
|
+
const t = new Z();
|
|
623
|
+
let s;
|
|
624
|
+
for (const n of this._def.checks)
|
|
625
|
+
if (n.kind === "min")
|
|
626
|
+
e.data.length < n.value && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
627
|
+
code: c.too_small,
|
|
628
|
+
minimum: n.value,
|
|
629
|
+
type: "string",
|
|
630
|
+
inclusive: !0,
|
|
631
|
+
exact: !1,
|
|
632
|
+
message: n.message
|
|
633
|
+
}), t.dirty());
|
|
634
|
+
else if (n.kind === "max")
|
|
635
|
+
e.data.length > n.value && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
636
|
+
code: c.too_big,
|
|
637
|
+
maximum: n.value,
|
|
638
|
+
type: "string",
|
|
639
|
+
inclusive: !0,
|
|
640
|
+
exact: !1,
|
|
641
|
+
message: n.message
|
|
642
|
+
}), t.dirty());
|
|
643
|
+
else if (n.kind === "length") {
|
|
644
|
+
const i = e.data.length > n.value, r = e.data.length < n.value;
|
|
645
|
+
(i || r) && (s = this._getOrReturnCtx(e, s), i ? l(s, {
|
|
646
|
+
code: c.too_big,
|
|
647
|
+
maximum: n.value,
|
|
648
|
+
type: "string",
|
|
649
|
+
inclusive: !0,
|
|
650
|
+
exact: !0,
|
|
651
|
+
message: n.message
|
|
652
|
+
}) : r && l(s, {
|
|
653
|
+
code: c.too_small,
|
|
654
|
+
minimum: n.value,
|
|
655
|
+
type: "string",
|
|
656
|
+
inclusive: !0,
|
|
657
|
+
exact: !0,
|
|
658
|
+
message: n.message
|
|
659
|
+
}), t.dirty());
|
|
660
|
+
} else if (n.kind === "email")
|
|
661
|
+
ut.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
662
|
+
validation: "email",
|
|
663
|
+
code: c.invalid_string,
|
|
664
|
+
message: n.message
|
|
665
|
+
}), t.dirty());
|
|
666
|
+
else if (n.kind === "emoji")
|
|
667
|
+
Ae || (Ae = new RegExp(lt, "u")), Ae.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
668
|
+
validation: "emoji",
|
|
669
|
+
code: c.invalid_string,
|
|
670
|
+
message: n.message
|
|
671
|
+
}), t.dirty());
|
|
672
|
+
else if (n.kind === "uuid")
|
|
673
|
+
rt.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
674
|
+
validation: "uuid",
|
|
675
|
+
code: c.invalid_string,
|
|
676
|
+
message: n.message
|
|
677
|
+
}), t.dirty());
|
|
678
|
+
else if (n.kind === "nanoid")
|
|
679
|
+
ot.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
680
|
+
validation: "nanoid",
|
|
681
|
+
code: c.invalid_string,
|
|
682
|
+
message: n.message
|
|
683
|
+
}), t.dirty());
|
|
684
|
+
else if (n.kind === "cuid")
|
|
685
|
+
at.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
686
|
+
validation: "cuid",
|
|
687
|
+
code: c.invalid_string,
|
|
688
|
+
message: n.message
|
|
689
|
+
}), t.dirty());
|
|
690
|
+
else if (n.kind === "cuid2")
|
|
691
|
+
nt.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
692
|
+
validation: "cuid2",
|
|
693
|
+
code: c.invalid_string,
|
|
694
|
+
message: n.message
|
|
695
|
+
}), t.dirty());
|
|
696
|
+
else if (n.kind === "ulid")
|
|
697
|
+
it.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
698
|
+
validation: "ulid",
|
|
699
|
+
code: c.invalid_string,
|
|
700
|
+
message: n.message
|
|
701
|
+
}), t.dirty());
|
|
702
|
+
else if (n.kind === "url")
|
|
703
|
+
try {
|
|
704
|
+
new URL(e.data);
|
|
705
|
+
} catch {
|
|
706
|
+
s = this._getOrReturnCtx(e, s), l(s, {
|
|
707
|
+
validation: "url",
|
|
708
|
+
code: c.invalid_string,
|
|
709
|
+
message: n.message
|
|
710
|
+
}), t.dirty();
|
|
711
|
+
}
|
|
712
|
+
else n.kind === "regex" ? (n.regex.lastIndex = 0, n.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
713
|
+
validation: "regex",
|
|
714
|
+
code: c.invalid_string,
|
|
715
|
+
message: n.message
|
|
716
|
+
}), t.dirty())) : n.kind === "trim" ? e.data = e.data.trim() : n.kind === "includes" ? e.data.includes(n.value, n.position) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
717
|
+
code: c.invalid_string,
|
|
718
|
+
validation: { includes: n.value, position: n.position },
|
|
719
|
+
message: n.message
|
|
720
|
+
}), t.dirty()) : n.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : n.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : n.kind === "startsWith" ? e.data.startsWith(n.value) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
721
|
+
code: c.invalid_string,
|
|
722
|
+
validation: { startsWith: n.value },
|
|
723
|
+
message: n.message
|
|
724
|
+
}), t.dirty()) : n.kind === "endsWith" ? e.data.endsWith(n.value) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
725
|
+
code: c.invalid_string,
|
|
726
|
+
validation: { endsWith: n.value },
|
|
727
|
+
message: n.message
|
|
728
|
+
}), t.dirty()) : n.kind === "datetime" ? We(n).test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
729
|
+
code: c.invalid_string,
|
|
730
|
+
validation: "datetime",
|
|
731
|
+
message: n.message
|
|
732
|
+
}), t.dirty()) : n.kind === "date" ? _t.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
733
|
+
code: c.invalid_string,
|
|
734
|
+
validation: "date",
|
|
735
|
+
message: n.message
|
|
736
|
+
}), t.dirty()) : n.kind === "time" ? vt(n).test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
737
|
+
code: c.invalid_string,
|
|
738
|
+
validation: "time",
|
|
739
|
+
message: n.message
|
|
740
|
+
}), t.dirty()) : n.kind === "duration" ? ct.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
741
|
+
validation: "duration",
|
|
742
|
+
code: c.invalid_string,
|
|
743
|
+
message: n.message
|
|
744
|
+
}), t.dirty()) : n.kind === "ip" ? bt(e.data, n.version) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
745
|
+
validation: "ip",
|
|
746
|
+
code: c.invalid_string,
|
|
747
|
+
message: n.message
|
|
748
|
+
}), t.dirty()) : n.kind === "jwt" ? kt(e.data, n.alg) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
749
|
+
validation: "jwt",
|
|
750
|
+
code: c.invalid_string,
|
|
751
|
+
message: n.message
|
|
752
|
+
}), t.dirty()) : n.kind === "cidr" ? wt(e.data, n.version) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
753
|
+
validation: "cidr",
|
|
754
|
+
code: c.invalid_string,
|
|
755
|
+
message: n.message
|
|
756
|
+
}), t.dirty()) : n.kind === "base64" ? yt.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
757
|
+
validation: "base64",
|
|
758
|
+
code: c.invalid_string,
|
|
759
|
+
message: n.message
|
|
760
|
+
}), t.dirty()) : n.kind === "base64url" ? gt.test(e.data) || (s = this._getOrReturnCtx(e, s), l(s, {
|
|
761
|
+
validation: "base64url",
|
|
762
|
+
code: c.invalid_string,
|
|
763
|
+
message: n.message
|
|
764
|
+
}), t.dirty()) : b.assertNever(n);
|
|
765
|
+
return { status: t.value, value: e.data };
|
|
766
|
+
}
|
|
767
|
+
_regex(e, t, s) {
|
|
768
|
+
return this.refinement((n) => e.test(n), {
|
|
769
|
+
validation: t,
|
|
770
|
+
code: c.invalid_string,
|
|
771
|
+
...p.errToObj(s)
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
_addCheck(e) {
|
|
775
|
+
return new N({
|
|
776
|
+
...this._def,
|
|
777
|
+
checks: [...this._def.checks, e]
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
email(e) {
|
|
781
|
+
return this._addCheck({ kind: "email", ...p.errToObj(e) });
|
|
782
|
+
}
|
|
783
|
+
url(e) {
|
|
784
|
+
return this._addCheck({ kind: "url", ...p.errToObj(e) });
|
|
785
|
+
}
|
|
786
|
+
emoji(e) {
|
|
787
|
+
return this._addCheck({ kind: "emoji", ...p.errToObj(e) });
|
|
788
|
+
}
|
|
789
|
+
uuid(e) {
|
|
790
|
+
return this._addCheck({ kind: "uuid", ...p.errToObj(e) });
|
|
791
|
+
}
|
|
792
|
+
nanoid(e) {
|
|
793
|
+
return this._addCheck({ kind: "nanoid", ...p.errToObj(e) });
|
|
794
|
+
}
|
|
795
|
+
cuid(e) {
|
|
796
|
+
return this._addCheck({ kind: "cuid", ...p.errToObj(e) });
|
|
797
|
+
}
|
|
798
|
+
cuid2(e) {
|
|
799
|
+
return this._addCheck({ kind: "cuid2", ...p.errToObj(e) });
|
|
800
|
+
}
|
|
801
|
+
ulid(e) {
|
|
802
|
+
return this._addCheck({ kind: "ulid", ...p.errToObj(e) });
|
|
803
|
+
}
|
|
804
|
+
base64(e) {
|
|
805
|
+
return this._addCheck({ kind: "base64", ...p.errToObj(e) });
|
|
806
|
+
}
|
|
807
|
+
base64url(e) {
|
|
808
|
+
return this._addCheck({
|
|
809
|
+
kind: "base64url",
|
|
810
|
+
...p.errToObj(e)
|
|
811
|
+
});
|
|
812
|
+
}
|
|
813
|
+
jwt(e) {
|
|
814
|
+
return this._addCheck({ kind: "jwt", ...p.errToObj(e) });
|
|
815
|
+
}
|
|
816
|
+
ip(e) {
|
|
817
|
+
return this._addCheck({ kind: "ip", ...p.errToObj(e) });
|
|
818
|
+
}
|
|
819
|
+
cidr(e) {
|
|
820
|
+
return this._addCheck({ kind: "cidr", ...p.errToObj(e) });
|
|
821
|
+
}
|
|
822
|
+
datetime(e) {
|
|
823
|
+
var t, s;
|
|
824
|
+
return typeof e == "string" ? this._addCheck({
|
|
825
|
+
kind: "datetime",
|
|
826
|
+
precision: null,
|
|
827
|
+
offset: !1,
|
|
828
|
+
local: !1,
|
|
829
|
+
message: e
|
|
830
|
+
}) : this._addCheck({
|
|
831
|
+
kind: "datetime",
|
|
832
|
+
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
833
|
+
offset: (t = e == null ? void 0 : e.offset) !== null && t !== void 0 ? t : !1,
|
|
834
|
+
local: (s = e == null ? void 0 : e.local) !== null && s !== void 0 ? s : !1,
|
|
835
|
+
...p.errToObj(e == null ? void 0 : e.message)
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
date(e) {
|
|
839
|
+
return this._addCheck({ kind: "date", message: e });
|
|
840
|
+
}
|
|
841
|
+
time(e) {
|
|
842
|
+
return typeof e == "string" ? this._addCheck({
|
|
843
|
+
kind: "time",
|
|
844
|
+
precision: null,
|
|
845
|
+
message: e
|
|
846
|
+
}) : this._addCheck({
|
|
847
|
+
kind: "time",
|
|
848
|
+
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
849
|
+
...p.errToObj(e == null ? void 0 : e.message)
|
|
850
|
+
});
|
|
851
|
+
}
|
|
852
|
+
duration(e) {
|
|
853
|
+
return this._addCheck({ kind: "duration", ...p.errToObj(e) });
|
|
854
|
+
}
|
|
855
|
+
regex(e, t) {
|
|
856
|
+
return this._addCheck({
|
|
857
|
+
kind: "regex",
|
|
858
|
+
regex: e,
|
|
859
|
+
...p.errToObj(t)
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
includes(e, t) {
|
|
863
|
+
return this._addCheck({
|
|
864
|
+
kind: "includes",
|
|
865
|
+
value: e,
|
|
866
|
+
position: t == null ? void 0 : t.position,
|
|
867
|
+
...p.errToObj(t == null ? void 0 : t.message)
|
|
868
|
+
});
|
|
869
|
+
}
|
|
870
|
+
startsWith(e, t) {
|
|
871
|
+
return this._addCheck({
|
|
872
|
+
kind: "startsWith",
|
|
873
|
+
value: e,
|
|
874
|
+
...p.errToObj(t)
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
endsWith(e, t) {
|
|
878
|
+
return this._addCheck({
|
|
879
|
+
kind: "endsWith",
|
|
880
|
+
value: e,
|
|
881
|
+
...p.errToObj(t)
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
min(e, t) {
|
|
885
|
+
return this._addCheck({
|
|
886
|
+
kind: "min",
|
|
887
|
+
value: e,
|
|
888
|
+
...p.errToObj(t)
|
|
889
|
+
});
|
|
890
|
+
}
|
|
891
|
+
max(e, t) {
|
|
892
|
+
return this._addCheck({
|
|
893
|
+
kind: "max",
|
|
894
|
+
value: e,
|
|
895
|
+
...p.errToObj(t)
|
|
896
|
+
});
|
|
897
|
+
}
|
|
898
|
+
length(e, t) {
|
|
899
|
+
return this._addCheck({
|
|
900
|
+
kind: "length",
|
|
901
|
+
value: e,
|
|
902
|
+
...p.errToObj(t)
|
|
903
|
+
});
|
|
904
|
+
}
|
|
905
|
+
/**
|
|
906
|
+
* Equivalent to `.min(1)`
|
|
907
|
+
*/
|
|
908
|
+
nonempty(e) {
|
|
909
|
+
return this.min(1, p.errToObj(e));
|
|
910
|
+
}
|
|
911
|
+
trim() {
|
|
912
|
+
return new N({
|
|
913
|
+
...this._def,
|
|
914
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
915
|
+
});
|
|
916
|
+
}
|
|
917
|
+
toLowerCase() {
|
|
918
|
+
return new N({
|
|
919
|
+
...this._def,
|
|
920
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
toUpperCase() {
|
|
924
|
+
return new N({
|
|
925
|
+
...this._def,
|
|
926
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
927
|
+
});
|
|
928
|
+
}
|
|
929
|
+
get isDatetime() {
|
|
930
|
+
return !!this._def.checks.find((e) => e.kind === "datetime");
|
|
931
|
+
}
|
|
932
|
+
get isDate() {
|
|
933
|
+
return !!this._def.checks.find((e) => e.kind === "date");
|
|
934
|
+
}
|
|
935
|
+
get isTime() {
|
|
936
|
+
return !!this._def.checks.find((e) => e.kind === "time");
|
|
937
|
+
}
|
|
938
|
+
get isDuration() {
|
|
939
|
+
return !!this._def.checks.find((e) => e.kind === "duration");
|
|
940
|
+
}
|
|
941
|
+
get isEmail() {
|
|
942
|
+
return !!this._def.checks.find((e) => e.kind === "email");
|
|
943
|
+
}
|
|
944
|
+
get isURL() {
|
|
945
|
+
return !!this._def.checks.find((e) => e.kind === "url");
|
|
946
|
+
}
|
|
947
|
+
get isEmoji() {
|
|
948
|
+
return !!this._def.checks.find((e) => e.kind === "emoji");
|
|
949
|
+
}
|
|
950
|
+
get isUUID() {
|
|
951
|
+
return !!this._def.checks.find((e) => e.kind === "uuid");
|
|
952
|
+
}
|
|
953
|
+
get isNANOID() {
|
|
954
|
+
return !!this._def.checks.find((e) => e.kind === "nanoid");
|
|
955
|
+
}
|
|
956
|
+
get isCUID() {
|
|
957
|
+
return !!this._def.checks.find((e) => e.kind === "cuid");
|
|
958
|
+
}
|
|
959
|
+
get isCUID2() {
|
|
960
|
+
return !!this._def.checks.find((e) => e.kind === "cuid2");
|
|
961
|
+
}
|
|
962
|
+
get isULID() {
|
|
963
|
+
return !!this._def.checks.find((e) => e.kind === "ulid");
|
|
964
|
+
}
|
|
965
|
+
get isIP() {
|
|
966
|
+
return !!this._def.checks.find((e) => e.kind === "ip");
|
|
967
|
+
}
|
|
968
|
+
get isCIDR() {
|
|
969
|
+
return !!this._def.checks.find((e) => e.kind === "cidr");
|
|
970
|
+
}
|
|
971
|
+
get isBase64() {
|
|
972
|
+
return !!this._def.checks.find((e) => e.kind === "base64");
|
|
973
|
+
}
|
|
974
|
+
get isBase64url() {
|
|
975
|
+
return !!this._def.checks.find((e) => e.kind === "base64url");
|
|
976
|
+
}
|
|
977
|
+
get minLength() {
|
|
978
|
+
let e = null;
|
|
979
|
+
for (const t of this._def.checks)
|
|
980
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
981
|
+
return e;
|
|
982
|
+
}
|
|
983
|
+
get maxLength() {
|
|
984
|
+
let e = null;
|
|
985
|
+
for (const t of this._def.checks)
|
|
986
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
987
|
+
return e;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
N.create = (a) => {
|
|
991
|
+
var e;
|
|
992
|
+
return new N({
|
|
993
|
+
checks: [],
|
|
994
|
+
typeName: m.ZodString,
|
|
995
|
+
coerce: (e = a == null ? void 0 : a.coerce) !== null && e !== void 0 ? e : !1,
|
|
996
|
+
...y(a)
|
|
997
|
+
});
|
|
998
|
+
};
|
|
999
|
+
function xt(a, e) {
|
|
1000
|
+
const t = (a.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, n = t > s ? t : s, i = parseInt(a.toFixed(n).replace(".", "")), r = parseInt(e.toFixed(n).replace(".", ""));
|
|
1001
|
+
return i % r / Math.pow(10, n);
|
|
1002
|
+
}
|
|
1003
|
+
class R extends _ {
|
|
1004
|
+
constructor() {
|
|
1005
|
+
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1006
|
+
}
|
|
1007
|
+
_parse(e) {
|
|
1008
|
+
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
|
|
1009
|
+
const n = this._getOrReturnCtx(e);
|
|
1010
|
+
return l(n, {
|
|
1011
|
+
code: c.invalid_type,
|
|
1012
|
+
expected: h.number,
|
|
1013
|
+
received: n.parsedType
|
|
1014
|
+
}), f;
|
|
1015
|
+
}
|
|
1016
|
+
let t;
|
|
1017
|
+
const s = new Z();
|
|
1018
|
+
for (const n of this._def.checks)
|
|
1019
|
+
n.kind === "int" ? b.isInteger(e.data) || (t = this._getOrReturnCtx(e, t), l(t, {
|
|
1020
|
+
code: c.invalid_type,
|
|
1021
|
+
expected: "integer",
|
|
1022
|
+
received: "float",
|
|
1023
|
+
message: n.message
|
|
1024
|
+
}), s.dirty()) : n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (t = this._getOrReturnCtx(e, t), l(t, {
|
|
1025
|
+
code: c.too_small,
|
|
1026
|
+
minimum: n.value,
|
|
1027
|
+
type: "number",
|
|
1028
|
+
inclusive: n.inclusive,
|
|
1029
|
+
exact: !1,
|
|
1030
|
+
message: n.message
|
|
1031
|
+
}), s.dirty()) : n.kind === "max" ? (n.inclusive ? e.data > n.value : e.data >= n.value) && (t = this._getOrReturnCtx(e, t), l(t, {
|
|
1032
|
+
code: c.too_big,
|
|
1033
|
+
maximum: n.value,
|
|
1034
|
+
type: "number",
|
|
1035
|
+
inclusive: n.inclusive,
|
|
1036
|
+
exact: !1,
|
|
1037
|
+
message: n.message
|
|
1038
|
+
}), s.dirty()) : n.kind === "multipleOf" ? xt(e.data, n.value) !== 0 && (t = this._getOrReturnCtx(e, t), l(t, {
|
|
1039
|
+
code: c.not_multiple_of,
|
|
1040
|
+
multipleOf: n.value,
|
|
1041
|
+
message: n.message
|
|
1042
|
+
}), s.dirty()) : n.kind === "finite" ? Number.isFinite(e.data) || (t = this._getOrReturnCtx(e, t), l(t, {
|
|
1043
|
+
code: c.not_finite,
|
|
1044
|
+
message: n.message
|
|
1045
|
+
}), s.dirty()) : b.assertNever(n);
|
|
1046
|
+
return { status: s.value, value: e.data };
|
|
1047
|
+
}
|
|
1048
|
+
gte(e, t) {
|
|
1049
|
+
return this.setLimit("min", e, !0, p.toString(t));
|
|
1050
|
+
}
|
|
1051
|
+
gt(e, t) {
|
|
1052
|
+
return this.setLimit("min", e, !1, p.toString(t));
|
|
1053
|
+
}
|
|
1054
|
+
lte(e, t) {
|
|
1055
|
+
return this.setLimit("max", e, !0, p.toString(t));
|
|
1056
|
+
}
|
|
1057
|
+
lt(e, t) {
|
|
1058
|
+
return this.setLimit("max", e, !1, p.toString(t));
|
|
1059
|
+
}
|
|
1060
|
+
setLimit(e, t, s, n) {
|
|
1061
|
+
return new R({
|
|
1062
|
+
...this._def,
|
|
1063
|
+
checks: [
|
|
1064
|
+
...this._def.checks,
|
|
1065
|
+
{
|
|
1066
|
+
kind: e,
|
|
1067
|
+
value: t,
|
|
1068
|
+
inclusive: s,
|
|
1069
|
+
message: p.toString(n)
|
|
1070
|
+
}
|
|
1071
|
+
]
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
_addCheck(e) {
|
|
1075
|
+
return new R({
|
|
1076
|
+
...this._def,
|
|
1077
|
+
checks: [...this._def.checks, e]
|
|
1078
|
+
});
|
|
1079
|
+
}
|
|
1080
|
+
int(e) {
|
|
1081
|
+
return this._addCheck({
|
|
1082
|
+
kind: "int",
|
|
1083
|
+
message: p.toString(e)
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
positive(e) {
|
|
1087
|
+
return this._addCheck({
|
|
1088
|
+
kind: "min",
|
|
1089
|
+
value: 0,
|
|
1090
|
+
inclusive: !1,
|
|
1091
|
+
message: p.toString(e)
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
negative(e) {
|
|
1095
|
+
return this._addCheck({
|
|
1096
|
+
kind: "max",
|
|
1097
|
+
value: 0,
|
|
1098
|
+
inclusive: !1,
|
|
1099
|
+
message: p.toString(e)
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1102
|
+
nonpositive(e) {
|
|
1103
|
+
return this._addCheck({
|
|
1104
|
+
kind: "max",
|
|
1105
|
+
value: 0,
|
|
1106
|
+
inclusive: !0,
|
|
1107
|
+
message: p.toString(e)
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
nonnegative(e) {
|
|
1111
|
+
return this._addCheck({
|
|
1112
|
+
kind: "min",
|
|
1113
|
+
value: 0,
|
|
1114
|
+
inclusive: !0,
|
|
1115
|
+
message: p.toString(e)
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
multipleOf(e, t) {
|
|
1119
|
+
return this._addCheck({
|
|
1120
|
+
kind: "multipleOf",
|
|
1121
|
+
value: e,
|
|
1122
|
+
message: p.toString(t)
|
|
1123
|
+
});
|
|
1124
|
+
}
|
|
1125
|
+
finite(e) {
|
|
1126
|
+
return this._addCheck({
|
|
1127
|
+
kind: "finite",
|
|
1128
|
+
message: p.toString(e)
|
|
1129
|
+
});
|
|
1130
|
+
}
|
|
1131
|
+
safe(e) {
|
|
1132
|
+
return this._addCheck({
|
|
1133
|
+
kind: "min",
|
|
1134
|
+
inclusive: !0,
|
|
1135
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
1136
|
+
message: p.toString(e)
|
|
1137
|
+
})._addCheck({
|
|
1138
|
+
kind: "max",
|
|
1139
|
+
inclusive: !0,
|
|
1140
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
1141
|
+
message: p.toString(e)
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
get minValue() {
|
|
1145
|
+
let e = null;
|
|
1146
|
+
for (const t of this._def.checks)
|
|
1147
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1148
|
+
return e;
|
|
1149
|
+
}
|
|
1150
|
+
get maxValue() {
|
|
1151
|
+
let e = null;
|
|
1152
|
+
for (const t of this._def.checks)
|
|
1153
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1154
|
+
return e;
|
|
1155
|
+
}
|
|
1156
|
+
get isInt() {
|
|
1157
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && b.isInteger(e.value));
|
|
1158
|
+
}
|
|
1159
|
+
get isFinite() {
|
|
1160
|
+
let e = null, t = null;
|
|
1161
|
+
for (const s of this._def.checks) {
|
|
1162
|
+
if (s.kind === "finite" || s.kind === "int" || s.kind === "multipleOf")
|
|
1163
|
+
return !0;
|
|
1164
|
+
s.kind === "min" ? (t === null || s.value > t) && (t = s.value) : s.kind === "max" && (e === null || s.value < e) && (e = s.value);
|
|
1165
|
+
}
|
|
1166
|
+
return Number.isFinite(t) && Number.isFinite(e);
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
R.create = (a) => new R({
|
|
1170
|
+
checks: [],
|
|
1171
|
+
typeName: m.ZodNumber,
|
|
1172
|
+
coerce: (a == null ? void 0 : a.coerce) || !1,
|
|
1173
|
+
...y(a)
|
|
1174
|
+
});
|
|
1175
|
+
let ee = class Pe extends _ {
|
|
1176
|
+
constructor() {
|
|
1177
|
+
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1178
|
+
}
|
|
1179
|
+
_parse(e) {
|
|
1180
|
+
if (this._def.coerce)
|
|
1181
|
+
try {
|
|
1182
|
+
e.data = BigInt(e.data);
|
|
1183
|
+
} catch {
|
|
1184
|
+
return this._getInvalidInput(e);
|
|
1185
|
+
}
|
|
1186
|
+
if (this._getType(e) !== h.bigint)
|
|
1187
|
+
return this._getInvalidInput(e);
|
|
1188
|
+
let t;
|
|
1189
|
+
const s = new Z();
|
|
1190
|
+
for (const n of this._def.checks)
|
|
1191
|
+
n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (t = this._getOrReturnCtx(e, t), l(t, {
|
|
1192
|
+
code: c.too_small,
|
|
1193
|
+
type: "bigint",
|
|
1194
|
+
minimum: n.value,
|
|
1195
|
+
inclusive: n.inclusive,
|
|
1196
|
+
message: n.message
|
|
1197
|
+
}), s.dirty()) : n.kind === "max" ? (n.inclusive ? e.data > n.value : e.data >= n.value) && (t = this._getOrReturnCtx(e, t), l(t, {
|
|
1198
|
+
code: c.too_big,
|
|
1199
|
+
type: "bigint",
|
|
1200
|
+
maximum: n.value,
|
|
1201
|
+
inclusive: n.inclusive,
|
|
1202
|
+
message: n.message
|
|
1203
|
+
}), s.dirty()) : n.kind === "multipleOf" ? e.data % n.value !== BigInt(0) && (t = this._getOrReturnCtx(e, t), l(t, {
|
|
1204
|
+
code: c.not_multiple_of,
|
|
1205
|
+
multipleOf: n.value,
|
|
1206
|
+
message: n.message
|
|
1207
|
+
}), s.dirty()) : b.assertNever(n);
|
|
1208
|
+
return { status: s.value, value: e.data };
|
|
1209
|
+
}
|
|
1210
|
+
_getInvalidInput(e) {
|
|
1211
|
+
const t = this._getOrReturnCtx(e);
|
|
1212
|
+
return l(t, {
|
|
1213
|
+
code: c.invalid_type,
|
|
1214
|
+
expected: h.bigint,
|
|
1215
|
+
received: t.parsedType
|
|
1216
|
+
}), f;
|
|
1217
|
+
}
|
|
1218
|
+
gte(e, t) {
|
|
1219
|
+
return this.setLimit("min", e, !0, p.toString(t));
|
|
1220
|
+
}
|
|
1221
|
+
gt(e, t) {
|
|
1222
|
+
return this.setLimit("min", e, !1, p.toString(t));
|
|
1223
|
+
}
|
|
1224
|
+
lte(e, t) {
|
|
1225
|
+
return this.setLimit("max", e, !0, p.toString(t));
|
|
1226
|
+
}
|
|
1227
|
+
lt(e, t) {
|
|
1228
|
+
return this.setLimit("max", e, !1, p.toString(t));
|
|
1229
|
+
}
|
|
1230
|
+
setLimit(e, t, s, n) {
|
|
1231
|
+
return new Pe({
|
|
1232
|
+
...this._def,
|
|
1233
|
+
checks: [
|
|
1234
|
+
...this._def.checks,
|
|
1235
|
+
{
|
|
1236
|
+
kind: e,
|
|
1237
|
+
value: t,
|
|
1238
|
+
inclusive: s,
|
|
1239
|
+
message: p.toString(n)
|
|
1240
|
+
}
|
|
1241
|
+
]
|
|
1242
|
+
});
|
|
1243
|
+
}
|
|
1244
|
+
_addCheck(e) {
|
|
1245
|
+
return new Pe({
|
|
1246
|
+
...this._def,
|
|
1247
|
+
checks: [...this._def.checks, e]
|
|
1248
|
+
});
|
|
1249
|
+
}
|
|
1250
|
+
positive(e) {
|
|
1251
|
+
return this._addCheck({
|
|
1252
|
+
kind: "min",
|
|
1253
|
+
value: BigInt(0),
|
|
1254
|
+
inclusive: !1,
|
|
1255
|
+
message: p.toString(e)
|
|
1256
|
+
});
|
|
1257
|
+
}
|
|
1258
|
+
negative(e) {
|
|
1259
|
+
return this._addCheck({
|
|
1260
|
+
kind: "max",
|
|
1261
|
+
value: BigInt(0),
|
|
1262
|
+
inclusive: !1,
|
|
1263
|
+
message: p.toString(e)
|
|
1264
|
+
});
|
|
1265
|
+
}
|
|
1266
|
+
nonpositive(e) {
|
|
1267
|
+
return this._addCheck({
|
|
1268
|
+
kind: "max",
|
|
1269
|
+
value: BigInt(0),
|
|
1270
|
+
inclusive: !0,
|
|
1271
|
+
message: p.toString(e)
|
|
1272
|
+
});
|
|
1273
|
+
}
|
|
1274
|
+
nonnegative(e) {
|
|
1275
|
+
return this._addCheck({
|
|
1276
|
+
kind: "min",
|
|
1277
|
+
value: BigInt(0),
|
|
1278
|
+
inclusive: !0,
|
|
1279
|
+
message: p.toString(e)
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
multipleOf(e, t) {
|
|
1283
|
+
return this._addCheck({
|
|
1284
|
+
kind: "multipleOf",
|
|
1285
|
+
value: e,
|
|
1286
|
+
message: p.toString(t)
|
|
1287
|
+
});
|
|
1288
|
+
}
|
|
1289
|
+
get minValue() {
|
|
1290
|
+
let e = null;
|
|
1291
|
+
for (const t of this._def.checks)
|
|
1292
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1293
|
+
return e;
|
|
1294
|
+
}
|
|
1295
|
+
get maxValue() {
|
|
1296
|
+
let e = null;
|
|
1297
|
+
for (const t of this._def.checks)
|
|
1298
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1299
|
+
return e;
|
|
1300
|
+
}
|
|
1301
|
+
};
|
|
1302
|
+
ee.create = (a) => {
|
|
1303
|
+
var e;
|
|
1304
|
+
return new ee({
|
|
1305
|
+
checks: [],
|
|
1306
|
+
typeName: m.ZodBigInt,
|
|
1307
|
+
coerce: (e = a == null ? void 0 : a.coerce) !== null && e !== void 0 ? e : !1,
|
|
1308
|
+
...y(a)
|
|
1309
|
+
});
|
|
1310
|
+
};
|
|
1311
|
+
class te extends _ {
|
|
1312
|
+
_parse(e) {
|
|
1313
|
+
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
|
|
1314
|
+
const t = this._getOrReturnCtx(e);
|
|
1315
|
+
return l(t, {
|
|
1316
|
+
code: c.invalid_type,
|
|
1317
|
+
expected: h.boolean,
|
|
1318
|
+
received: t.parsedType
|
|
1319
|
+
}), f;
|
|
1320
|
+
}
|
|
1321
|
+
return x(e.data);
|
|
1322
|
+
}
|
|
1323
|
+
}
|
|
1324
|
+
te.create = (a) => new te({
|
|
1325
|
+
typeName: m.ZodBoolean,
|
|
1326
|
+
coerce: (a == null ? void 0 : a.coerce) || !1,
|
|
1327
|
+
...y(a)
|
|
1328
|
+
});
|
|
1329
|
+
class q extends _ {
|
|
1330
|
+
_parse(e) {
|
|
1331
|
+
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
|
|
1332
|
+
const n = this._getOrReturnCtx(e);
|
|
1333
|
+
return l(n, {
|
|
1334
|
+
code: c.invalid_type,
|
|
1335
|
+
expected: h.date,
|
|
1336
|
+
received: n.parsedType
|
|
1337
|
+
}), f;
|
|
1338
|
+
}
|
|
1339
|
+
if (isNaN(e.data.getTime())) {
|
|
1340
|
+
const n = this._getOrReturnCtx(e);
|
|
1341
|
+
return l(n, {
|
|
1342
|
+
code: c.invalid_date
|
|
1343
|
+
}), f;
|
|
1344
|
+
}
|
|
1345
|
+
const t = new Z();
|
|
1346
|
+
let s;
|
|
1347
|
+
for (const n of this._def.checks)
|
|
1348
|
+
n.kind === "min" ? e.data.getTime() < n.value && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1349
|
+
code: c.too_small,
|
|
1350
|
+
message: n.message,
|
|
1351
|
+
inclusive: !0,
|
|
1352
|
+
exact: !1,
|
|
1353
|
+
minimum: n.value,
|
|
1354
|
+
type: "date"
|
|
1355
|
+
}), t.dirty()) : n.kind === "max" ? e.data.getTime() > n.value && (s = this._getOrReturnCtx(e, s), l(s, {
|
|
1356
|
+
code: c.too_big,
|
|
1357
|
+
message: n.message,
|
|
1358
|
+
inclusive: !0,
|
|
1359
|
+
exact: !1,
|
|
1360
|
+
maximum: n.value,
|
|
1361
|
+
type: "date"
|
|
1362
|
+
}), t.dirty()) : b.assertNever(n);
|
|
1363
|
+
return {
|
|
1364
|
+
status: t.value,
|
|
1365
|
+
value: new Date(e.data.getTime())
|
|
1366
|
+
};
|
|
1367
|
+
}
|
|
1368
|
+
_addCheck(e) {
|
|
1369
|
+
return new q({
|
|
1370
|
+
...this._def,
|
|
1371
|
+
checks: [...this._def.checks, e]
|
|
1372
|
+
});
|
|
1373
|
+
}
|
|
1374
|
+
min(e, t) {
|
|
1375
|
+
return this._addCheck({
|
|
1376
|
+
kind: "min",
|
|
1377
|
+
value: e.getTime(),
|
|
1378
|
+
message: p.toString(t)
|
|
1379
|
+
});
|
|
1380
|
+
}
|
|
1381
|
+
max(e, t) {
|
|
1382
|
+
return this._addCheck({
|
|
1383
|
+
kind: "max",
|
|
1384
|
+
value: e.getTime(),
|
|
1385
|
+
message: p.toString(t)
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
get minDate() {
|
|
1389
|
+
let e = null;
|
|
1390
|
+
for (const t of this._def.checks)
|
|
1391
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1392
|
+
return e != null ? new Date(e) : null;
|
|
1393
|
+
}
|
|
1394
|
+
get maxDate() {
|
|
1395
|
+
let e = null;
|
|
1396
|
+
for (const t of this._def.checks)
|
|
1397
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1398
|
+
return e != null ? new Date(e) : null;
|
|
1399
|
+
}
|
|
1400
|
+
}
|
|
1401
|
+
q.create = (a) => new q({
|
|
1402
|
+
checks: [],
|
|
1403
|
+
coerce: (a == null ? void 0 : a.coerce) || !1,
|
|
1404
|
+
typeName: m.ZodDate,
|
|
1405
|
+
...y(a)
|
|
1406
|
+
});
|
|
1407
|
+
class xe extends _ {
|
|
1408
|
+
_parse(e) {
|
|
1409
|
+
if (this._getType(e) !== h.symbol) {
|
|
1410
|
+
const t = this._getOrReturnCtx(e);
|
|
1411
|
+
return l(t, {
|
|
1412
|
+
code: c.invalid_type,
|
|
1413
|
+
expected: h.symbol,
|
|
1414
|
+
received: t.parsedType
|
|
1415
|
+
}), f;
|
|
1416
|
+
}
|
|
1417
|
+
return x(e.data);
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
xe.create = (a) => new xe({
|
|
1421
|
+
typeName: m.ZodSymbol,
|
|
1422
|
+
...y(a)
|
|
1423
|
+
});
|
|
1424
|
+
class se extends _ {
|
|
1425
|
+
_parse(e) {
|
|
1426
|
+
if (this._getType(e) !== h.undefined) {
|
|
1427
|
+
const t = this._getOrReturnCtx(e);
|
|
1428
|
+
return l(t, {
|
|
1429
|
+
code: c.invalid_type,
|
|
1430
|
+
expected: h.undefined,
|
|
1431
|
+
received: t.parsedType
|
|
1432
|
+
}), f;
|
|
1433
|
+
}
|
|
1434
|
+
return x(e.data);
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
se.create = (a) => new se({
|
|
1438
|
+
typeName: m.ZodUndefined,
|
|
1439
|
+
...y(a)
|
|
1440
|
+
});
|
|
1441
|
+
class ae extends _ {
|
|
1442
|
+
_parse(e) {
|
|
1443
|
+
if (this._getType(e) !== h.null) {
|
|
1444
|
+
const t = this._getOrReturnCtx(e);
|
|
1445
|
+
return l(t, {
|
|
1446
|
+
code: c.invalid_type,
|
|
1447
|
+
expected: h.null,
|
|
1448
|
+
received: t.parsedType
|
|
1449
|
+
}), f;
|
|
1450
|
+
}
|
|
1451
|
+
return x(e.data);
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1454
|
+
ae.create = (a) => new ae({
|
|
1455
|
+
typeName: m.ZodNull,
|
|
1456
|
+
...y(a)
|
|
1457
|
+
});
|
|
1458
|
+
let J = class extends _ {
|
|
1459
|
+
constructor() {
|
|
1460
|
+
super(...arguments), this._any = !0;
|
|
1461
|
+
}
|
|
1462
|
+
_parse(e) {
|
|
1463
|
+
return x(e.data);
|
|
1464
|
+
}
|
|
1465
|
+
};
|
|
1466
|
+
J.create = (a) => new J({
|
|
1467
|
+
typeName: m.ZodAny,
|
|
1468
|
+
...y(a)
|
|
1469
|
+
});
|
|
1470
|
+
class D extends _ {
|
|
1471
|
+
constructor() {
|
|
1472
|
+
super(...arguments), this._unknown = !0;
|
|
1473
|
+
}
|
|
1474
|
+
_parse(e) {
|
|
1475
|
+
return x(e.data);
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
D.create = (a) => new D({
|
|
1479
|
+
typeName: m.ZodUnknown,
|
|
1480
|
+
...y(a)
|
|
1481
|
+
});
|
|
1482
|
+
let $ = class extends _ {
|
|
1483
|
+
_parse(e) {
|
|
1484
|
+
const t = this._getOrReturnCtx(e);
|
|
1485
|
+
return l(t, {
|
|
1486
|
+
code: c.invalid_type,
|
|
1487
|
+
expected: h.never,
|
|
1488
|
+
received: t.parsedType
|
|
1489
|
+
}), f;
|
|
1490
|
+
}
|
|
1491
|
+
};
|
|
1492
|
+
$.create = (a) => new $({
|
|
1493
|
+
typeName: m.ZodNever,
|
|
1494
|
+
...y(a)
|
|
1495
|
+
});
|
|
1496
|
+
class Ze extends _ {
|
|
1497
|
+
_parse(e) {
|
|
1498
|
+
if (this._getType(e) !== h.undefined) {
|
|
1499
|
+
const t = this._getOrReturnCtx(e);
|
|
1500
|
+
return l(t, {
|
|
1501
|
+
code: c.invalid_type,
|
|
1502
|
+
expected: h.void,
|
|
1503
|
+
received: t.parsedType
|
|
1504
|
+
}), f;
|
|
1505
|
+
}
|
|
1506
|
+
return x(e.data);
|
|
1507
|
+
}
|
|
1508
|
+
}
|
|
1509
|
+
Ze.create = (a) => new Ze({
|
|
1510
|
+
typeName: m.ZodVoid,
|
|
1511
|
+
...y(a)
|
|
1512
|
+
});
|
|
1513
|
+
let B = class _e extends _ {
|
|
1514
|
+
_parse(e) {
|
|
1515
|
+
const { ctx: t, status: s } = this._processInputParams(e), n = this._def;
|
|
1516
|
+
if (t.parsedType !== h.array)
|
|
1517
|
+
return l(t, {
|
|
1518
|
+
code: c.invalid_type,
|
|
1519
|
+
expected: h.array,
|
|
1520
|
+
received: t.parsedType
|
|
1521
|
+
}), f;
|
|
1522
|
+
if (n.exactLength !== null) {
|
|
1523
|
+
const r = t.data.length > n.exactLength.value, o = t.data.length < n.exactLength.value;
|
|
1524
|
+
(r || o) && (l(t, {
|
|
1525
|
+
code: r ? c.too_big : c.too_small,
|
|
1526
|
+
minimum: o ? n.exactLength.value : void 0,
|
|
1527
|
+
maximum: r ? n.exactLength.value : void 0,
|
|
1528
|
+
type: "array",
|
|
1529
|
+
inclusive: !0,
|
|
1530
|
+
exact: !0,
|
|
1531
|
+
message: n.exactLength.message
|
|
1532
|
+
}), s.dirty());
|
|
1533
|
+
}
|
|
1534
|
+
if (n.minLength !== null && t.data.length < n.minLength.value && (l(t, {
|
|
1535
|
+
code: c.too_small,
|
|
1536
|
+
minimum: n.minLength.value,
|
|
1537
|
+
type: "array",
|
|
1538
|
+
inclusive: !0,
|
|
1539
|
+
exact: !1,
|
|
1540
|
+
message: n.minLength.message
|
|
1541
|
+
}), s.dirty()), n.maxLength !== null && t.data.length > n.maxLength.value && (l(t, {
|
|
1542
|
+
code: c.too_big,
|
|
1543
|
+
maximum: n.maxLength.value,
|
|
1544
|
+
type: "array",
|
|
1545
|
+
inclusive: !0,
|
|
1546
|
+
exact: !1,
|
|
1547
|
+
message: n.maxLength.message
|
|
1548
|
+
}), s.dirty()), t.common.async)
|
|
1549
|
+
return Promise.all([...t.data].map((r, o) => n.type._parseAsync(new A(t, r, t.path, o)))).then((r) => Z.mergeArray(s, r));
|
|
1550
|
+
const i = [...t.data].map((r, o) => n.type._parseSync(new A(t, r, t.path, o)));
|
|
1551
|
+
return Z.mergeArray(s, i);
|
|
1552
|
+
}
|
|
1553
|
+
get element() {
|
|
1554
|
+
return this._def.type;
|
|
1555
|
+
}
|
|
1556
|
+
min(e, t) {
|
|
1557
|
+
return new _e({
|
|
1558
|
+
...this._def,
|
|
1559
|
+
minLength: { value: e, message: p.toString(t) }
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
max(e, t) {
|
|
1563
|
+
return new _e({
|
|
1564
|
+
...this._def,
|
|
1565
|
+
maxLength: { value: e, message: p.toString(t) }
|
|
1566
|
+
});
|
|
1567
|
+
}
|
|
1568
|
+
length(e, t) {
|
|
1569
|
+
return new _e({
|
|
1570
|
+
...this._def,
|
|
1571
|
+
exactLength: { value: e, message: p.toString(t) }
|
|
1572
|
+
});
|
|
1573
|
+
}
|
|
1574
|
+
nonempty(e) {
|
|
1575
|
+
return this.min(1, e);
|
|
1576
|
+
}
|
|
1577
|
+
};
|
|
1578
|
+
B.create = (a, e) => new B({
|
|
1579
|
+
type: a,
|
|
1580
|
+
minLength: null,
|
|
1581
|
+
maxLength: null,
|
|
1582
|
+
exactLength: null,
|
|
1583
|
+
typeName: m.ZodArray,
|
|
1584
|
+
...y(e)
|
|
1585
|
+
});
|
|
1586
|
+
function K(a) {
|
|
1587
|
+
if (a instanceof k) {
|
|
1588
|
+
const e = {};
|
|
1589
|
+
for (const t in a.shape) {
|
|
1590
|
+
const s = a.shape[t];
|
|
1591
|
+
e[t] = O.create(K(s));
|
|
1592
|
+
}
|
|
1593
|
+
return new k({
|
|
1594
|
+
...a._def,
|
|
1595
|
+
shape: () => e
|
|
1596
|
+
});
|
|
1597
|
+
} else return a instanceof B ? new B({
|
|
1598
|
+
...a._def,
|
|
1599
|
+
type: K(a.element)
|
|
1600
|
+
}) : a instanceof O ? O.create(K(a.unwrap())) : a instanceof M ? M.create(K(a.unwrap())) : a instanceof j ? j.create(a.items.map((e) => K(e))) : a;
|
|
1601
|
+
}
|
|
1602
|
+
class k extends _ {
|
|
1603
|
+
constructor() {
|
|
1604
|
+
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1605
|
+
}
|
|
1606
|
+
_getCached() {
|
|
1607
|
+
if (this._cached !== null)
|
|
1608
|
+
return this._cached;
|
|
1609
|
+
const e = this._def.shape(), t = b.objectKeys(e);
|
|
1610
|
+
return this._cached = { shape: e, keys: t };
|
|
1611
|
+
}
|
|
1612
|
+
_parse(e) {
|
|
1613
|
+
if (this._getType(e) !== h.object) {
|
|
1614
|
+
const d = this._getOrReturnCtx(e);
|
|
1615
|
+
return l(d, {
|
|
1616
|
+
code: c.invalid_type,
|
|
1617
|
+
expected: h.object,
|
|
1618
|
+
received: d.parsedType
|
|
1619
|
+
}), f;
|
|
1620
|
+
}
|
|
1621
|
+
const { status: t, ctx: s } = this._processInputParams(e), { shape: n, keys: i } = this._getCached(), r = [];
|
|
1622
|
+
if (!(this._def.catchall instanceof $ && this._def.unknownKeys === "strip"))
|
|
1623
|
+
for (const d in s.data)
|
|
1624
|
+
i.includes(d) || r.push(d);
|
|
1625
|
+
const o = [];
|
|
1626
|
+
for (const d of i) {
|
|
1627
|
+
const u = n[d], g = s.data[d];
|
|
1628
|
+
o.push({
|
|
1629
|
+
key: { status: "valid", value: d },
|
|
1630
|
+
value: u._parse(new A(s, g, s.path, d)),
|
|
1631
|
+
alwaysSet: d in s.data
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
if (this._def.catchall instanceof $) {
|
|
1635
|
+
const d = this._def.unknownKeys;
|
|
1636
|
+
if (d === "passthrough")
|
|
1637
|
+
for (const u of r)
|
|
1638
|
+
o.push({
|
|
1639
|
+
key: { status: "valid", value: u },
|
|
1640
|
+
value: { status: "valid", value: s.data[u] }
|
|
1641
|
+
});
|
|
1642
|
+
else if (d === "strict")
|
|
1643
|
+
r.length > 0 && (l(s, {
|
|
1644
|
+
code: c.unrecognized_keys,
|
|
1645
|
+
keys: r
|
|
1646
|
+
}), t.dirty());
|
|
1647
|
+
else if (d !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1648
|
+
} else {
|
|
1649
|
+
const d = this._def.catchall;
|
|
1650
|
+
for (const u of r) {
|
|
1651
|
+
const g = s.data[u];
|
|
1652
|
+
o.push({
|
|
1653
|
+
key: { status: "valid", value: u },
|
|
1654
|
+
value: d._parse(
|
|
1655
|
+
new A(s, g, s.path, u)
|
|
1656
|
+
//, ctx.child(key), value, getParsedType(value)
|
|
1657
|
+
),
|
|
1658
|
+
alwaysSet: u in s.data
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
return s.common.async ? Promise.resolve().then(async () => {
|
|
1663
|
+
const d = [];
|
|
1664
|
+
for (const u of o) {
|
|
1665
|
+
const g = await u.key, w = await u.value;
|
|
1666
|
+
d.push({
|
|
1667
|
+
key: g,
|
|
1668
|
+
value: w,
|
|
1669
|
+
alwaysSet: u.alwaysSet
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1672
|
+
return d;
|
|
1673
|
+
}).then((d) => Z.mergeObjectSync(t, d)) : Z.mergeObjectSync(t, o);
|
|
1674
|
+
}
|
|
1675
|
+
get shape() {
|
|
1676
|
+
return this._def.shape();
|
|
1677
|
+
}
|
|
1678
|
+
strict(e) {
|
|
1679
|
+
return p.errToObj, new k({
|
|
1680
|
+
...this._def,
|
|
1681
|
+
unknownKeys: "strict",
|
|
1682
|
+
...e !== void 0 ? {
|
|
1683
|
+
errorMap: (t, s) => {
|
|
1684
|
+
var n, i, r, o;
|
|
1685
|
+
const d = (r = (i = (n = this._def).errorMap) === null || i === void 0 ? void 0 : i.call(n, t, s).message) !== null && r !== void 0 ? r : s.defaultError;
|
|
1686
|
+
return t.code === "unrecognized_keys" ? {
|
|
1687
|
+
message: (o = p.errToObj(e).message) !== null && o !== void 0 ? o : d
|
|
1688
|
+
} : {
|
|
1689
|
+
message: d
|
|
1690
|
+
};
|
|
1691
|
+
}
|
|
1692
|
+
} : {}
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
strip() {
|
|
1696
|
+
return new k({
|
|
1697
|
+
...this._def,
|
|
1698
|
+
unknownKeys: "strip"
|
|
1699
|
+
});
|
|
1700
|
+
}
|
|
1701
|
+
passthrough() {
|
|
1702
|
+
return new k({
|
|
1703
|
+
...this._def,
|
|
1704
|
+
unknownKeys: "passthrough"
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
// const AugmentFactory =
|
|
1708
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
|
1709
|
+
// <Augmentation extends ZodRawShape>(
|
|
1710
|
+
// augmentation: Augmentation
|
|
1711
|
+
// ): ZodObject<
|
|
1712
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
1713
|
+
// Def["unknownKeys"],
|
|
1714
|
+
// Def["catchall"]
|
|
1715
|
+
// > => {
|
|
1716
|
+
// return new ZodObject({
|
|
1717
|
+
// ...def,
|
|
1718
|
+
// shape: () => ({
|
|
1719
|
+
// ...def.shape(),
|
|
1720
|
+
// ...augmentation,
|
|
1721
|
+
// }),
|
|
1722
|
+
// }) as any;
|
|
1723
|
+
// };
|
|
1724
|
+
extend(e) {
|
|
1725
|
+
return new k({
|
|
1726
|
+
...this._def,
|
|
1727
|
+
shape: () => ({
|
|
1728
|
+
...this._def.shape(),
|
|
1729
|
+
...e
|
|
1730
|
+
})
|
|
1731
|
+
});
|
|
1732
|
+
}
|
|
1733
|
+
/**
|
|
1734
|
+
* Prior to zod@1.0.12 there was a bug in the
|
|
1735
|
+
* inferred type of merged objects. Please
|
|
1736
|
+
* upgrade if you are experiencing issues.
|
|
1737
|
+
*/
|
|
1738
|
+
merge(e) {
|
|
1739
|
+
return new k({
|
|
1740
|
+
unknownKeys: e._def.unknownKeys,
|
|
1741
|
+
catchall: e._def.catchall,
|
|
1742
|
+
shape: () => ({
|
|
1743
|
+
...this._def.shape(),
|
|
1744
|
+
...e._def.shape()
|
|
1745
|
+
}),
|
|
1746
|
+
typeName: m.ZodObject
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
// merge<
|
|
1750
|
+
// Incoming extends AnyZodObject,
|
|
1751
|
+
// Augmentation extends Incoming["shape"],
|
|
1752
|
+
// NewOutput extends {
|
|
1753
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
1754
|
+
// ? Augmentation[k]["_output"]
|
|
1755
|
+
// : k extends keyof Output
|
|
1756
|
+
// ? Output[k]
|
|
1757
|
+
// : never;
|
|
1758
|
+
// },
|
|
1759
|
+
// NewInput extends {
|
|
1760
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
1761
|
+
// ? Augmentation[k]["_input"]
|
|
1762
|
+
// : k extends keyof Input
|
|
1763
|
+
// ? Input[k]
|
|
1764
|
+
// : never;
|
|
1765
|
+
// }
|
|
1766
|
+
// >(
|
|
1767
|
+
// merging: Incoming
|
|
1768
|
+
// ): ZodObject<
|
|
1769
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
1770
|
+
// Incoming["_def"]["unknownKeys"],
|
|
1771
|
+
// Incoming["_def"]["catchall"],
|
|
1772
|
+
// NewOutput,
|
|
1773
|
+
// NewInput
|
|
1774
|
+
// > {
|
|
1775
|
+
// const merged: any = new ZodObject({
|
|
1776
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
1777
|
+
// catchall: merging._def.catchall,
|
|
1778
|
+
// shape: () =>
|
|
1779
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
1780
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
1781
|
+
// }) as any;
|
|
1782
|
+
// return merged;
|
|
1783
|
+
// }
|
|
1784
|
+
setKey(e, t) {
|
|
1785
|
+
return this.augment({ [e]: t });
|
|
1786
|
+
}
|
|
1787
|
+
// merge<Incoming extends AnyZodObject>(
|
|
1788
|
+
// merging: Incoming
|
|
1789
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
1790
|
+
// ZodObject<
|
|
1791
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
1792
|
+
// Incoming["_def"]["unknownKeys"],
|
|
1793
|
+
// Incoming["_def"]["catchall"]
|
|
1794
|
+
// > {
|
|
1795
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
|
1796
|
+
// // this._def.shape(),
|
|
1797
|
+
// // merging._def.shape()
|
|
1798
|
+
// // );
|
|
1799
|
+
// const merged: any = new ZodObject({
|
|
1800
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
1801
|
+
// catchall: merging._def.catchall,
|
|
1802
|
+
// shape: () =>
|
|
1803
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
1804
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
1805
|
+
// }) as any;
|
|
1806
|
+
// return merged;
|
|
1807
|
+
// }
|
|
1808
|
+
catchall(e) {
|
|
1809
|
+
return new k({
|
|
1810
|
+
...this._def,
|
|
1811
|
+
catchall: e
|
|
1812
|
+
});
|
|
1813
|
+
}
|
|
1814
|
+
pick(e) {
|
|
1815
|
+
const t = {};
|
|
1816
|
+
return b.objectKeys(e).forEach((s) => {
|
|
1817
|
+
e[s] && this.shape[s] && (t[s] = this.shape[s]);
|
|
1818
|
+
}), new k({
|
|
1819
|
+
...this._def,
|
|
1820
|
+
shape: () => t
|
|
1821
|
+
});
|
|
1822
|
+
}
|
|
1823
|
+
omit(e) {
|
|
1824
|
+
const t = {};
|
|
1825
|
+
return b.objectKeys(this.shape).forEach((s) => {
|
|
1826
|
+
e[s] || (t[s] = this.shape[s]);
|
|
1827
|
+
}), new k({
|
|
1828
|
+
...this._def,
|
|
1829
|
+
shape: () => t
|
|
1830
|
+
});
|
|
1831
|
+
}
|
|
1832
|
+
/**
|
|
1833
|
+
* @deprecated
|
|
1834
|
+
*/
|
|
1835
|
+
deepPartial() {
|
|
1836
|
+
return K(this);
|
|
1837
|
+
}
|
|
1838
|
+
partial(e) {
|
|
1839
|
+
const t = {};
|
|
1840
|
+
return b.objectKeys(this.shape).forEach((s) => {
|
|
1841
|
+
const n = this.shape[s];
|
|
1842
|
+
e && !e[s] ? t[s] = n : t[s] = n.optional();
|
|
1843
|
+
}), new k({
|
|
1844
|
+
...this._def,
|
|
1845
|
+
shape: () => t
|
|
1846
|
+
});
|
|
1847
|
+
}
|
|
1848
|
+
required(e) {
|
|
1849
|
+
const t = {};
|
|
1850
|
+
return b.objectKeys(this.shape).forEach((s) => {
|
|
1851
|
+
if (e && !e[s])
|
|
1852
|
+
t[s] = this.shape[s];
|
|
1853
|
+
else {
|
|
1854
|
+
let n = this.shape[s];
|
|
1855
|
+
for (; n instanceof O; )
|
|
1856
|
+
n = n._def.innerType;
|
|
1857
|
+
t[s] = n;
|
|
1858
|
+
}
|
|
1859
|
+
}), new k({
|
|
1860
|
+
...this._def,
|
|
1861
|
+
shape: () => t
|
|
1862
|
+
});
|
|
1863
|
+
}
|
|
1864
|
+
keyof() {
|
|
1865
|
+
return Je(b.objectKeys(this.shape));
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
k.create = (a, e) => new k({
|
|
1869
|
+
shape: () => a,
|
|
1870
|
+
unknownKeys: "strip",
|
|
1871
|
+
catchall: $.create(),
|
|
1872
|
+
typeName: m.ZodObject,
|
|
1873
|
+
...y(e)
|
|
1874
|
+
});
|
|
1875
|
+
k.strictCreate = (a, e) => new k({
|
|
1876
|
+
shape: () => a,
|
|
1877
|
+
unknownKeys: "strict",
|
|
1878
|
+
catchall: $.create(),
|
|
1879
|
+
typeName: m.ZodObject,
|
|
1880
|
+
...y(e)
|
|
1881
|
+
});
|
|
1882
|
+
k.lazycreate = (a, e) => new k({
|
|
1883
|
+
shape: a,
|
|
1884
|
+
unknownKeys: "strip",
|
|
1885
|
+
catchall: $.create(),
|
|
1886
|
+
typeName: m.ZodObject,
|
|
1887
|
+
...y(e)
|
|
1888
|
+
});
|
|
1889
|
+
class ne extends _ {
|
|
1890
|
+
_parse(e) {
|
|
1891
|
+
const { ctx: t } = this._processInputParams(e), s = this._def.options;
|
|
1892
|
+
function n(i) {
|
|
1893
|
+
for (const o of i)
|
|
1894
|
+
if (o.result.status === "valid")
|
|
1895
|
+
return o.result;
|
|
1896
|
+
for (const o of i)
|
|
1897
|
+
if (o.result.status === "dirty")
|
|
1898
|
+
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1899
|
+
const r = i.map((o) => new C(o.ctx.common.issues));
|
|
1900
|
+
return l(t, {
|
|
1901
|
+
code: c.invalid_union,
|
|
1902
|
+
unionErrors: r
|
|
1903
|
+
}), f;
|
|
1904
|
+
}
|
|
1905
|
+
if (t.common.async)
|
|
1906
|
+
return Promise.all(s.map(async (i) => {
|
|
1907
|
+
const r = {
|
|
1908
|
+
...t,
|
|
1909
|
+
common: {
|
|
1910
|
+
...t.common,
|
|
1911
|
+
issues: []
|
|
1912
|
+
},
|
|
1913
|
+
parent: null
|
|
1914
|
+
};
|
|
1915
|
+
return {
|
|
1916
|
+
result: await i._parseAsync({
|
|
1917
|
+
data: t.data,
|
|
1918
|
+
path: t.path,
|
|
1919
|
+
parent: r
|
|
1920
|
+
}),
|
|
1921
|
+
ctx: r
|
|
1922
|
+
};
|
|
1923
|
+
})).then(n);
|
|
1924
|
+
{
|
|
1925
|
+
let i;
|
|
1926
|
+
const r = [];
|
|
1927
|
+
for (const d of s) {
|
|
1928
|
+
const u = {
|
|
1929
|
+
...t,
|
|
1930
|
+
common: {
|
|
1931
|
+
...t.common,
|
|
1932
|
+
issues: []
|
|
1933
|
+
},
|
|
1934
|
+
parent: null
|
|
1935
|
+
}, g = d._parseSync({
|
|
1936
|
+
data: t.data,
|
|
1937
|
+
path: t.path,
|
|
1938
|
+
parent: u
|
|
1939
|
+
});
|
|
1940
|
+
if (g.status === "valid")
|
|
1941
|
+
return g;
|
|
1942
|
+
g.status === "dirty" && !i && (i = { result: g, ctx: u }), u.common.issues.length && r.push(u.common.issues);
|
|
1943
|
+
}
|
|
1944
|
+
if (i)
|
|
1945
|
+
return t.common.issues.push(...i.ctx.common.issues), i.result;
|
|
1946
|
+
const o = r.map((d) => new C(d));
|
|
1947
|
+
return l(t, {
|
|
1948
|
+
code: c.invalid_union,
|
|
1949
|
+
unionErrors: o
|
|
1950
|
+
}), f;
|
|
1951
|
+
}
|
|
1952
|
+
}
|
|
1953
|
+
get options() {
|
|
1954
|
+
return this._def.options;
|
|
1955
|
+
}
|
|
1956
|
+
}
|
|
1957
|
+
ne.create = (a, e) => new ne({
|
|
1958
|
+
options: a,
|
|
1959
|
+
typeName: m.ZodUnion,
|
|
1960
|
+
...y(e)
|
|
1961
|
+
});
|
|
1962
|
+
const P = (a) => a instanceof oe ? P(a.schema) : a instanceof S ? P(a.innerType()) : a instanceof de ? [a.value] : a instanceof pe ? a.options : a instanceof ce ? b.objectValues(a.enum) : a instanceof ue ? P(a._def.innerType) : a instanceof se ? [void 0] : a instanceof ae ? [null] : a instanceof O ? [void 0, ...P(a.unwrap())] : a instanceof M ? [null, ...P(a.unwrap())] : a instanceof Fe || a instanceof he ? P(a.unwrap()) : a instanceof le ? P(a._def.innerType) : [];
|
|
1963
|
+
class Ce extends _ {
|
|
1964
|
+
_parse(e) {
|
|
1965
|
+
const { ctx: t } = this._processInputParams(e);
|
|
1966
|
+
if (t.parsedType !== h.object)
|
|
1967
|
+
return l(t, {
|
|
1968
|
+
code: c.invalid_type,
|
|
1969
|
+
expected: h.object,
|
|
1970
|
+
received: t.parsedType
|
|
1971
|
+
}), f;
|
|
1972
|
+
const s = this.discriminator, n = t.data[s], i = this.optionsMap.get(n);
|
|
1973
|
+
return i ? t.common.async ? i._parseAsync({
|
|
1974
|
+
data: t.data,
|
|
1975
|
+
path: t.path,
|
|
1976
|
+
parent: t
|
|
1977
|
+
}) : i._parseSync({
|
|
1978
|
+
data: t.data,
|
|
1979
|
+
path: t.path,
|
|
1980
|
+
parent: t
|
|
1981
|
+
}) : (l(t, {
|
|
1982
|
+
code: c.invalid_union_discriminator,
|
|
1983
|
+
options: Array.from(this.optionsMap.keys()),
|
|
1984
|
+
path: [s]
|
|
1985
|
+
}), f);
|
|
1986
|
+
}
|
|
1987
|
+
get discriminator() {
|
|
1988
|
+
return this._def.discriminator;
|
|
1989
|
+
}
|
|
1990
|
+
get options() {
|
|
1991
|
+
return this._def.options;
|
|
1992
|
+
}
|
|
1993
|
+
get optionsMap() {
|
|
1994
|
+
return this._def.optionsMap;
|
|
1995
|
+
}
|
|
1996
|
+
/**
|
|
1997
|
+
* The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
|
|
1998
|
+
* However, it only allows a union of objects, all of which need to share a discriminator property. This property must
|
|
1999
|
+
* have a different value for each object in the union.
|
|
2000
|
+
* @param discriminator the name of the discriminator property
|
|
2001
|
+
* @param types an array of object schemas
|
|
2002
|
+
* @param params
|
|
2003
|
+
*/
|
|
2004
|
+
static create(e, t, s) {
|
|
2005
|
+
const n = /* @__PURE__ */ new Map();
|
|
2006
|
+
for (const i of t) {
|
|
2007
|
+
const r = P(i.shape[e]);
|
|
2008
|
+
if (!r.length)
|
|
2009
|
+
throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);
|
|
2010
|
+
for (const o of r) {
|
|
2011
|
+
if (n.has(o))
|
|
2012
|
+
throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);
|
|
2013
|
+
n.set(o, i);
|
|
2014
|
+
}
|
|
2015
|
+
}
|
|
2016
|
+
return new Ce({
|
|
2017
|
+
typeName: m.ZodDiscriminatedUnion,
|
|
2018
|
+
discriminator: e,
|
|
2019
|
+
options: t,
|
|
2020
|
+
optionsMap: n,
|
|
2021
|
+
...y(s)
|
|
2022
|
+
});
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
function Re(a, e) {
|
|
2026
|
+
const t = E(a), s = E(e);
|
|
2027
|
+
if (a === e)
|
|
2028
|
+
return { valid: !0, data: a };
|
|
2029
|
+
if (t === h.object && s === h.object) {
|
|
2030
|
+
const n = b.objectKeys(e), i = b.objectKeys(a).filter((o) => n.indexOf(o) !== -1), r = { ...a, ...e };
|
|
2031
|
+
for (const o of i) {
|
|
2032
|
+
const d = Re(a[o], e[o]);
|
|
2033
|
+
if (!d.valid)
|
|
2034
|
+
return { valid: !1 };
|
|
2035
|
+
r[o] = d.data;
|
|
2036
|
+
}
|
|
2037
|
+
return { valid: !0, data: r };
|
|
2038
|
+
} else if (t === h.array && s === h.array) {
|
|
2039
|
+
if (a.length !== e.length)
|
|
2040
|
+
return { valid: !1 };
|
|
2041
|
+
const n = [];
|
|
2042
|
+
for (let i = 0; i < a.length; i++) {
|
|
2043
|
+
const r = a[i], o = e[i], d = Re(r, o);
|
|
2044
|
+
if (!d.valid)
|
|
2045
|
+
return { valid: !1 };
|
|
2046
|
+
n.push(d.data);
|
|
2047
|
+
}
|
|
2048
|
+
return { valid: !0, data: n };
|
|
2049
|
+
} else return t === h.date && s === h.date && +a == +e ? { valid: !0, data: a } : { valid: !1 };
|
|
2050
|
+
}
|
|
2051
|
+
class ie extends _ {
|
|
2052
|
+
_parse(e) {
|
|
2053
|
+
const { status: t, ctx: s } = this._processInputParams(e), n = (i, r) => {
|
|
2054
|
+
if (Ee(i) || Ee(r))
|
|
2055
|
+
return f;
|
|
2056
|
+
const o = Re(i.value, r.value);
|
|
2057
|
+
return o.valid ? (($e(i) || $e(r)) && t.dirty(), { status: t.value, value: o.data }) : (l(s, {
|
|
2058
|
+
code: c.invalid_intersection_types
|
|
2059
|
+
}), f);
|
|
2060
|
+
};
|
|
2061
|
+
return s.common.async ? Promise.all([
|
|
2062
|
+
this._def.left._parseAsync({
|
|
2063
|
+
data: s.data,
|
|
2064
|
+
path: s.path,
|
|
2065
|
+
parent: s
|
|
2066
|
+
}),
|
|
2067
|
+
this._def.right._parseAsync({
|
|
2068
|
+
data: s.data,
|
|
2069
|
+
path: s.path,
|
|
2070
|
+
parent: s
|
|
2071
|
+
})
|
|
2072
|
+
]).then(([i, r]) => n(i, r)) : n(this._def.left._parseSync({
|
|
2073
|
+
data: s.data,
|
|
2074
|
+
path: s.path,
|
|
2075
|
+
parent: s
|
|
2076
|
+
}), this._def.right._parseSync({
|
|
2077
|
+
data: s.data,
|
|
2078
|
+
path: s.path,
|
|
2079
|
+
parent: s
|
|
2080
|
+
}));
|
|
2081
|
+
}
|
|
2082
|
+
}
|
|
2083
|
+
ie.create = (a, e, t) => new ie({
|
|
2084
|
+
left: a,
|
|
2085
|
+
right: e,
|
|
2086
|
+
typeName: m.ZodIntersection,
|
|
2087
|
+
...y(t)
|
|
2088
|
+
});
|
|
2089
|
+
class j extends _ {
|
|
2090
|
+
_parse(e) {
|
|
2091
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2092
|
+
if (s.parsedType !== h.array)
|
|
2093
|
+
return l(s, {
|
|
2094
|
+
code: c.invalid_type,
|
|
2095
|
+
expected: h.array,
|
|
2096
|
+
received: s.parsedType
|
|
2097
|
+
}), f;
|
|
2098
|
+
if (s.data.length < this._def.items.length)
|
|
2099
|
+
return l(s, {
|
|
2100
|
+
code: c.too_small,
|
|
2101
|
+
minimum: this._def.items.length,
|
|
2102
|
+
inclusive: !0,
|
|
2103
|
+
exact: !1,
|
|
2104
|
+
type: "array"
|
|
2105
|
+
}), f;
|
|
2106
|
+
!this._def.rest && s.data.length > this._def.items.length && (l(s, {
|
|
2107
|
+
code: c.too_big,
|
|
2108
|
+
maximum: this._def.items.length,
|
|
2109
|
+
inclusive: !0,
|
|
2110
|
+
exact: !1,
|
|
2111
|
+
type: "array"
|
|
2112
|
+
}), t.dirty());
|
|
2113
|
+
const n = [...s.data].map((i, r) => {
|
|
2114
|
+
const o = this._def.items[r] || this._def.rest;
|
|
2115
|
+
return o ? o._parse(new A(s, i, s.path, r)) : null;
|
|
2116
|
+
}).filter((i) => !!i);
|
|
2117
|
+
return s.common.async ? Promise.all(n).then((i) => Z.mergeArray(t, i)) : Z.mergeArray(t, n);
|
|
2118
|
+
}
|
|
2119
|
+
get items() {
|
|
2120
|
+
return this._def.items;
|
|
2121
|
+
}
|
|
2122
|
+
rest(e) {
|
|
2123
|
+
return new j({
|
|
2124
|
+
...this._def,
|
|
2125
|
+
rest: e
|
|
2126
|
+
});
|
|
2127
|
+
}
|
|
2128
|
+
}
|
|
2129
|
+
j.create = (a, e) => {
|
|
2130
|
+
if (!Array.isArray(a))
|
|
2131
|
+
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2132
|
+
return new j({
|
|
2133
|
+
items: a,
|
|
2134
|
+
typeName: m.ZodTuple,
|
|
2135
|
+
rest: null,
|
|
2136
|
+
...y(e)
|
|
2137
|
+
});
|
|
2138
|
+
};
|
|
2139
|
+
class re extends _ {
|
|
2140
|
+
get keySchema() {
|
|
2141
|
+
return this._def.keyType;
|
|
2142
|
+
}
|
|
2143
|
+
get valueSchema() {
|
|
2144
|
+
return this._def.valueType;
|
|
2145
|
+
}
|
|
2146
|
+
_parse(e) {
|
|
2147
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2148
|
+
if (s.parsedType !== h.object)
|
|
2149
|
+
return l(s, {
|
|
2150
|
+
code: c.invalid_type,
|
|
2151
|
+
expected: h.object,
|
|
2152
|
+
received: s.parsedType
|
|
2153
|
+
}), f;
|
|
2154
|
+
const n = [], i = this._def.keyType, r = this._def.valueType;
|
|
2155
|
+
for (const o in s.data)
|
|
2156
|
+
n.push({
|
|
2157
|
+
key: i._parse(new A(s, o, s.path, o)),
|
|
2158
|
+
value: r._parse(new A(s, s.data[o], s.path, o)),
|
|
2159
|
+
alwaysSet: o in s.data
|
|
2160
|
+
});
|
|
2161
|
+
return s.common.async ? Z.mergeObjectAsync(t, n) : Z.mergeObjectSync(t, n);
|
|
2162
|
+
}
|
|
2163
|
+
get element() {
|
|
2164
|
+
return this._def.valueType;
|
|
2165
|
+
}
|
|
2166
|
+
static create(e, t, s) {
|
|
2167
|
+
return t instanceof _ ? new re({
|
|
2168
|
+
keyType: e,
|
|
2169
|
+
valueType: t,
|
|
2170
|
+
typeName: m.ZodRecord,
|
|
2171
|
+
...y(s)
|
|
2172
|
+
}) : new re({
|
|
2173
|
+
keyType: N.create(),
|
|
2174
|
+
valueType: e,
|
|
2175
|
+
typeName: m.ZodRecord,
|
|
2176
|
+
...y(t)
|
|
2177
|
+
});
|
|
2178
|
+
}
|
|
2179
|
+
}
|
|
2180
|
+
class Te extends _ {
|
|
2181
|
+
get keySchema() {
|
|
2182
|
+
return this._def.keyType;
|
|
2183
|
+
}
|
|
2184
|
+
get valueSchema() {
|
|
2185
|
+
return this._def.valueType;
|
|
2186
|
+
}
|
|
2187
|
+
_parse(e) {
|
|
2188
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2189
|
+
if (s.parsedType !== h.map)
|
|
2190
|
+
return l(s, {
|
|
2191
|
+
code: c.invalid_type,
|
|
2192
|
+
expected: h.map,
|
|
2193
|
+
received: s.parsedType
|
|
2194
|
+
}), f;
|
|
2195
|
+
const n = this._def.keyType, i = this._def.valueType, r = [...s.data.entries()].map(([o, d], u) => ({
|
|
2196
|
+
key: n._parse(new A(s, o, s.path, [u, "key"])),
|
|
2197
|
+
value: i._parse(new A(s, d, s.path, [u, "value"]))
|
|
2198
|
+
}));
|
|
2199
|
+
if (s.common.async) {
|
|
2200
|
+
const o = /* @__PURE__ */ new Map();
|
|
2201
|
+
return Promise.resolve().then(async () => {
|
|
2202
|
+
for (const d of r) {
|
|
2203
|
+
const u = await d.key, g = await d.value;
|
|
2204
|
+
if (u.status === "aborted" || g.status === "aborted")
|
|
2205
|
+
return f;
|
|
2206
|
+
(u.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(u.value, g.value);
|
|
2207
|
+
}
|
|
2208
|
+
return { status: t.value, value: o };
|
|
2209
|
+
});
|
|
2210
|
+
} else {
|
|
2211
|
+
const o = /* @__PURE__ */ new Map();
|
|
2212
|
+
for (const d of r) {
|
|
2213
|
+
const u = d.key, g = d.value;
|
|
2214
|
+
if (u.status === "aborted" || g.status === "aborted")
|
|
2215
|
+
return f;
|
|
2216
|
+
(u.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(u.value, g.value);
|
|
2217
|
+
}
|
|
2218
|
+
return { status: t.value, value: o };
|
|
2219
|
+
}
|
|
2220
|
+
}
|
|
2221
|
+
}
|
|
2222
|
+
Te.create = (a, e, t) => new Te({
|
|
2223
|
+
valueType: e,
|
|
2224
|
+
keyType: a,
|
|
2225
|
+
typeName: m.ZodMap,
|
|
2226
|
+
...y(t)
|
|
2227
|
+
});
|
|
2228
|
+
class V extends _ {
|
|
2229
|
+
_parse(e) {
|
|
2230
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2231
|
+
if (s.parsedType !== h.set)
|
|
2232
|
+
return l(s, {
|
|
2233
|
+
code: c.invalid_type,
|
|
2234
|
+
expected: h.set,
|
|
2235
|
+
received: s.parsedType
|
|
2236
|
+
}), f;
|
|
2237
|
+
const n = this._def;
|
|
2238
|
+
n.minSize !== null && s.data.size < n.minSize.value && (l(s, {
|
|
2239
|
+
code: c.too_small,
|
|
2240
|
+
minimum: n.minSize.value,
|
|
2241
|
+
type: "set",
|
|
2242
|
+
inclusive: !0,
|
|
2243
|
+
exact: !1,
|
|
2244
|
+
message: n.minSize.message
|
|
2245
|
+
}), t.dirty()), n.maxSize !== null && s.data.size > n.maxSize.value && (l(s, {
|
|
2246
|
+
code: c.too_big,
|
|
2247
|
+
maximum: n.maxSize.value,
|
|
2248
|
+
type: "set",
|
|
2249
|
+
inclusive: !0,
|
|
2250
|
+
exact: !1,
|
|
2251
|
+
message: n.maxSize.message
|
|
2252
|
+
}), t.dirty());
|
|
2253
|
+
const i = this._def.valueType;
|
|
2254
|
+
function r(d) {
|
|
2255
|
+
const u = /* @__PURE__ */ new Set();
|
|
2256
|
+
for (const g of d) {
|
|
2257
|
+
if (g.status === "aborted")
|
|
2258
|
+
return f;
|
|
2259
|
+
g.status === "dirty" && t.dirty(), u.add(g.value);
|
|
2260
|
+
}
|
|
2261
|
+
return { status: t.value, value: u };
|
|
2262
|
+
}
|
|
2263
|
+
const o = [...s.data.values()].map((d, u) => i._parse(new A(s, d, s.path, u)));
|
|
2264
|
+
return s.common.async ? Promise.all(o).then((d) => r(d)) : r(o);
|
|
2265
|
+
}
|
|
2266
|
+
min(e, t) {
|
|
2267
|
+
return new V({
|
|
2268
|
+
...this._def,
|
|
2269
|
+
minSize: { value: e, message: p.toString(t) }
|
|
2270
|
+
});
|
|
2271
|
+
}
|
|
2272
|
+
max(e, t) {
|
|
2273
|
+
return new V({
|
|
2274
|
+
...this._def,
|
|
2275
|
+
maxSize: { value: e, message: p.toString(t) }
|
|
2276
|
+
});
|
|
2277
|
+
}
|
|
2278
|
+
size(e, t) {
|
|
2279
|
+
return this.min(e, t).max(e, t);
|
|
2280
|
+
}
|
|
2281
|
+
nonempty(e) {
|
|
2282
|
+
return this.min(1, e);
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
V.create = (a, e) => new V({
|
|
2286
|
+
valueType: a,
|
|
2287
|
+
minSize: null,
|
|
2288
|
+
maxSize: null,
|
|
2289
|
+
typeName: m.ZodSet,
|
|
2290
|
+
...y(e)
|
|
2291
|
+
});
|
|
2292
|
+
class H extends _ {
|
|
2293
|
+
constructor() {
|
|
2294
|
+
super(...arguments), this.validate = this.implement;
|
|
2295
|
+
}
|
|
2296
|
+
_parse(e) {
|
|
2297
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2298
|
+
if (t.parsedType !== h.function)
|
|
2299
|
+
return l(t, {
|
|
2300
|
+
code: c.invalid_type,
|
|
2301
|
+
expected: h.function,
|
|
2302
|
+
received: t.parsedType
|
|
2303
|
+
}), f;
|
|
2304
|
+
function s(o, d) {
|
|
2305
|
+
return be({
|
|
2306
|
+
data: o,
|
|
2307
|
+
path: t.path,
|
|
2308
|
+
errorMaps: [
|
|
2309
|
+
t.common.contextualErrorMap,
|
|
2310
|
+
t.schemaErrorMap,
|
|
2311
|
+
ve(),
|
|
2312
|
+
W
|
|
2313
|
+
].filter((u) => !!u),
|
|
2314
|
+
issueData: {
|
|
2315
|
+
code: c.invalid_arguments,
|
|
2316
|
+
argumentsError: d
|
|
2317
|
+
}
|
|
2318
|
+
});
|
|
2319
|
+
}
|
|
2320
|
+
function n(o, d) {
|
|
2321
|
+
return be({
|
|
2322
|
+
data: o,
|
|
2323
|
+
path: t.path,
|
|
2324
|
+
errorMaps: [
|
|
2325
|
+
t.common.contextualErrorMap,
|
|
2326
|
+
t.schemaErrorMap,
|
|
2327
|
+
ve(),
|
|
2328
|
+
W
|
|
2329
|
+
].filter((u) => !!u),
|
|
2330
|
+
issueData: {
|
|
2331
|
+
code: c.invalid_return_type,
|
|
2332
|
+
returnTypeError: d
|
|
2333
|
+
}
|
|
2334
|
+
});
|
|
2335
|
+
}
|
|
2336
|
+
const i = { errorMap: t.common.contextualErrorMap }, r = t.data;
|
|
2337
|
+
if (this._def.returns instanceof Y) {
|
|
2338
|
+
const o = this;
|
|
2339
|
+
return x(async function(...d) {
|
|
2340
|
+
const u = new C([]), g = await o._def.args.parseAsync(d, i).catch((I) => {
|
|
2341
|
+
throw u.addIssue(s(d, I)), u;
|
|
2342
|
+
}), w = await Reflect.apply(r, this, g);
|
|
2343
|
+
return await o._def.returns._def.type.parseAsync(w, i).catch((I) => {
|
|
2344
|
+
throw u.addIssue(n(w, I)), u;
|
|
2345
|
+
});
|
|
2346
|
+
});
|
|
2347
|
+
} else {
|
|
2348
|
+
const o = this;
|
|
2349
|
+
return x(function(...d) {
|
|
2350
|
+
const u = o._def.args.safeParse(d, i);
|
|
2351
|
+
if (!u.success)
|
|
2352
|
+
throw new C([s(d, u.error)]);
|
|
2353
|
+
const g = Reflect.apply(r, this, u.data), w = o._def.returns.safeParse(g, i);
|
|
2354
|
+
if (!w.success)
|
|
2355
|
+
throw new C([n(g, w.error)]);
|
|
2356
|
+
return w.data;
|
|
2357
|
+
});
|
|
2358
|
+
}
|
|
2359
|
+
}
|
|
2360
|
+
parameters() {
|
|
2361
|
+
return this._def.args;
|
|
2362
|
+
}
|
|
2363
|
+
returnType() {
|
|
2364
|
+
return this._def.returns;
|
|
2365
|
+
}
|
|
2366
|
+
args(...e) {
|
|
2367
|
+
return new H({
|
|
2368
|
+
...this._def,
|
|
2369
|
+
args: j.create(e).rest(D.create())
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
2372
|
+
returns(e) {
|
|
2373
|
+
return new H({
|
|
2374
|
+
...this._def,
|
|
2375
|
+
returns: e
|
|
2376
|
+
});
|
|
2377
|
+
}
|
|
2378
|
+
implement(e) {
|
|
2379
|
+
return this.parse(e);
|
|
2380
|
+
}
|
|
2381
|
+
strictImplement(e) {
|
|
2382
|
+
return this.parse(e);
|
|
2383
|
+
}
|
|
2384
|
+
static create(e, t, s) {
|
|
2385
|
+
return new H({
|
|
2386
|
+
args: e || j.create([]).rest(D.create()),
|
|
2387
|
+
returns: t || D.create(),
|
|
2388
|
+
typeName: m.ZodFunction,
|
|
2389
|
+
...y(s)
|
|
2390
|
+
});
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
class oe extends _ {
|
|
2394
|
+
get schema() {
|
|
2395
|
+
return this._def.getter();
|
|
2396
|
+
}
|
|
2397
|
+
_parse(e) {
|
|
2398
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2399
|
+
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
oe.create = (a, e) => new oe({
|
|
2403
|
+
getter: a,
|
|
2404
|
+
typeName: m.ZodLazy,
|
|
2405
|
+
...y(e)
|
|
2406
|
+
});
|
|
2407
|
+
class de extends _ {
|
|
2408
|
+
_parse(e) {
|
|
2409
|
+
if (e.data !== this._def.value) {
|
|
2410
|
+
const t = this._getOrReturnCtx(e);
|
|
2411
|
+
return l(t, {
|
|
2412
|
+
received: t.data,
|
|
2413
|
+
code: c.invalid_literal,
|
|
2414
|
+
expected: this._def.value
|
|
2415
|
+
}), f;
|
|
2416
|
+
}
|
|
2417
|
+
return { status: "valid", value: e.data };
|
|
2418
|
+
}
|
|
2419
|
+
get value() {
|
|
2420
|
+
return this._def.value;
|
|
2421
|
+
}
|
|
2422
|
+
}
|
|
2423
|
+
de.create = (a, e) => new de({
|
|
2424
|
+
value: a,
|
|
2425
|
+
typeName: m.ZodLiteral,
|
|
2426
|
+
...y(e)
|
|
2427
|
+
});
|
|
2428
|
+
function Je(a, e) {
|
|
2429
|
+
return new pe({
|
|
2430
|
+
values: a,
|
|
2431
|
+
typeName: m.ZodEnum,
|
|
2432
|
+
...y(e)
|
|
2433
|
+
});
|
|
2434
|
+
}
|
|
2435
|
+
let pe = class Me extends _ {
|
|
2436
|
+
constructor() {
|
|
2437
|
+
super(...arguments), G.set(this, void 0);
|
|
2438
|
+
}
|
|
2439
|
+
_parse(e) {
|
|
2440
|
+
if (typeof e.data != "string") {
|
|
2441
|
+
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
2442
|
+
return l(t, {
|
|
2443
|
+
expected: b.joinValues(s),
|
|
2444
|
+
received: t.parsedType,
|
|
2445
|
+
code: c.invalid_type
|
|
2446
|
+
}), f;
|
|
2447
|
+
}
|
|
2448
|
+
if (we(this, G) || Ue(this, G, new Set(this._def.values)), !we(this, G).has(e.data)) {
|
|
2449
|
+
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
2450
|
+
return l(t, {
|
|
2451
|
+
received: t.data,
|
|
2452
|
+
code: c.invalid_enum_value,
|
|
2453
|
+
options: s
|
|
2454
|
+
}), f;
|
|
2455
|
+
}
|
|
2456
|
+
return x(e.data);
|
|
2457
|
+
}
|
|
2458
|
+
get options() {
|
|
2459
|
+
return this._def.values;
|
|
2460
|
+
}
|
|
2461
|
+
get enum() {
|
|
2462
|
+
const e = {};
|
|
2463
|
+
for (const t of this._def.values)
|
|
2464
|
+
e[t] = t;
|
|
2465
|
+
return e;
|
|
2466
|
+
}
|
|
2467
|
+
get Values() {
|
|
2468
|
+
const e = {};
|
|
2469
|
+
for (const t of this._def.values)
|
|
2470
|
+
e[t] = t;
|
|
2471
|
+
return e;
|
|
2472
|
+
}
|
|
2473
|
+
get Enum() {
|
|
2474
|
+
const e = {};
|
|
2475
|
+
for (const t of this._def.values)
|
|
2476
|
+
e[t] = t;
|
|
2477
|
+
return e;
|
|
2478
|
+
}
|
|
2479
|
+
extract(e, t = this._def) {
|
|
2480
|
+
return Me.create(e, {
|
|
2481
|
+
...this._def,
|
|
2482
|
+
...t
|
|
2483
|
+
});
|
|
2484
|
+
}
|
|
2485
|
+
exclude(e, t = this._def) {
|
|
2486
|
+
return Me.create(this.options.filter((s) => !e.includes(s)), {
|
|
2487
|
+
...this._def,
|
|
2488
|
+
...t
|
|
2489
|
+
});
|
|
2490
|
+
}
|
|
2491
|
+
};
|
|
2492
|
+
G = /* @__PURE__ */ new WeakMap();
|
|
2493
|
+
pe.create = Je;
|
|
2494
|
+
class ce extends _ {
|
|
2495
|
+
constructor() {
|
|
2496
|
+
super(...arguments), X.set(this, void 0);
|
|
2497
|
+
}
|
|
2498
|
+
_parse(e) {
|
|
2499
|
+
const t = b.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
2500
|
+
if (s.parsedType !== h.string && s.parsedType !== h.number) {
|
|
2501
|
+
const n = b.objectValues(t);
|
|
2502
|
+
return l(s, {
|
|
2503
|
+
expected: b.joinValues(n),
|
|
2504
|
+
received: s.parsedType,
|
|
2505
|
+
code: c.invalid_type
|
|
2506
|
+
}), f;
|
|
2507
|
+
}
|
|
2508
|
+
if (we(this, X) || Ue(this, X, new Set(b.getValidEnumValues(this._def.values))), !we(this, X).has(e.data)) {
|
|
2509
|
+
const n = b.objectValues(t);
|
|
2510
|
+
return l(s, {
|
|
2511
|
+
received: s.data,
|
|
2512
|
+
code: c.invalid_enum_value,
|
|
2513
|
+
options: n
|
|
2514
|
+
}), f;
|
|
2515
|
+
}
|
|
2516
|
+
return x(e.data);
|
|
2517
|
+
}
|
|
2518
|
+
get enum() {
|
|
2519
|
+
return this._def.values;
|
|
2520
|
+
}
|
|
2521
|
+
}
|
|
2522
|
+
X = /* @__PURE__ */ new WeakMap();
|
|
2523
|
+
ce.create = (a, e) => new ce({
|
|
2524
|
+
values: a,
|
|
2525
|
+
typeName: m.ZodNativeEnum,
|
|
2526
|
+
...y(e)
|
|
2527
|
+
});
|
|
2528
|
+
class Y extends _ {
|
|
2529
|
+
unwrap() {
|
|
2530
|
+
return this._def.type;
|
|
2531
|
+
}
|
|
2532
|
+
_parse(e) {
|
|
2533
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2534
|
+
if (t.parsedType !== h.promise && t.common.async === !1)
|
|
2535
|
+
return l(t, {
|
|
2536
|
+
code: c.invalid_type,
|
|
2537
|
+
expected: h.promise,
|
|
2538
|
+
received: t.parsedType
|
|
2539
|
+
}), f;
|
|
2540
|
+
const s = t.parsedType === h.promise ? t.data : Promise.resolve(t.data);
|
|
2541
|
+
return x(s.then((n) => this._def.type.parseAsync(n, {
|
|
2542
|
+
path: t.path,
|
|
2543
|
+
errorMap: t.common.contextualErrorMap
|
|
2544
|
+
})));
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
Y.create = (a, e) => new Y({
|
|
2548
|
+
type: a,
|
|
2549
|
+
typeName: m.ZodPromise,
|
|
2550
|
+
...y(e)
|
|
2551
|
+
});
|
|
2552
|
+
class S extends _ {
|
|
2553
|
+
innerType() {
|
|
2554
|
+
return this._def.schema;
|
|
2555
|
+
}
|
|
2556
|
+
sourceType() {
|
|
2557
|
+
return this._def.schema._def.typeName === m.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2558
|
+
}
|
|
2559
|
+
_parse(e) {
|
|
2560
|
+
const { status: t, ctx: s } = this._processInputParams(e), n = this._def.effect || null, i = {
|
|
2561
|
+
addIssue: (r) => {
|
|
2562
|
+
l(s, r), r.fatal ? t.abort() : t.dirty();
|
|
2563
|
+
},
|
|
2564
|
+
get path() {
|
|
2565
|
+
return s.path;
|
|
2566
|
+
}
|
|
2567
|
+
};
|
|
2568
|
+
if (i.addIssue = i.addIssue.bind(i), n.type === "preprocess") {
|
|
2569
|
+
const r = n.transform(s.data, i);
|
|
2570
|
+
if (s.common.async)
|
|
2571
|
+
return Promise.resolve(r).then(async (o) => {
|
|
2572
|
+
if (t.value === "aborted")
|
|
2573
|
+
return f;
|
|
2574
|
+
const d = await this._def.schema._parseAsync({
|
|
2575
|
+
data: o,
|
|
2576
|
+
path: s.path,
|
|
2577
|
+
parent: s
|
|
2578
|
+
});
|
|
2579
|
+
return d.status === "aborted" ? f : d.status === "dirty" || t.value === "dirty" ? ke(d.value) : d;
|
|
2580
|
+
});
|
|
2581
|
+
{
|
|
2582
|
+
if (t.value === "aborted")
|
|
2583
|
+
return f;
|
|
2584
|
+
const o = this._def.schema._parseSync({
|
|
2585
|
+
data: r,
|
|
2586
|
+
path: s.path,
|
|
2587
|
+
parent: s
|
|
2588
|
+
});
|
|
2589
|
+
return o.status === "aborted" ? f : o.status === "dirty" || t.value === "dirty" ? ke(o.value) : o;
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
if (n.type === "refinement") {
|
|
2593
|
+
const r = (o) => {
|
|
2594
|
+
const d = n.refinement(o, i);
|
|
2595
|
+
if (s.common.async)
|
|
2596
|
+
return Promise.resolve(d);
|
|
2597
|
+
if (d instanceof Promise)
|
|
2598
|
+
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2599
|
+
return o;
|
|
2600
|
+
};
|
|
2601
|
+
if (s.common.async === !1) {
|
|
2602
|
+
const o = this._def.schema._parseSync({
|
|
2603
|
+
data: s.data,
|
|
2604
|
+
path: s.path,
|
|
2605
|
+
parent: s
|
|
2606
|
+
});
|
|
2607
|
+
return o.status === "aborted" ? f : (o.status === "dirty" && t.dirty(), r(o.value), { status: t.value, value: o.value });
|
|
2608
|
+
} else
|
|
2609
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? f : (o.status === "dirty" && t.dirty(), r(o.value).then(() => ({ status: t.value, value: o.value }))));
|
|
2610
|
+
}
|
|
2611
|
+
if (n.type === "transform")
|
|
2612
|
+
if (s.common.async === !1) {
|
|
2613
|
+
const r = this._def.schema._parseSync({
|
|
2614
|
+
data: s.data,
|
|
2615
|
+
path: s.path,
|
|
2616
|
+
parent: s
|
|
2617
|
+
});
|
|
2618
|
+
if (!z(r))
|
|
2619
|
+
return r;
|
|
2620
|
+
const o = n.transform(r.value, i);
|
|
2621
|
+
if (o instanceof Promise)
|
|
2622
|
+
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2623
|
+
return { status: t.value, value: o };
|
|
2624
|
+
} else
|
|
2625
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((r) => z(r) ? Promise.resolve(n.transform(r.value, i)).then((o) => ({ status: t.value, value: o })) : r);
|
|
2626
|
+
b.assertNever(n);
|
|
2627
|
+
}
|
|
2628
|
+
}
|
|
2629
|
+
S.create = (a, e, t) => new S({
|
|
2630
|
+
schema: a,
|
|
2631
|
+
typeName: m.ZodEffects,
|
|
2632
|
+
effect: e,
|
|
2633
|
+
...y(t)
|
|
2634
|
+
});
|
|
2635
|
+
S.createWithPreprocess = (a, e, t) => new S({
|
|
2636
|
+
schema: e,
|
|
2637
|
+
effect: { type: "preprocess", transform: a },
|
|
2638
|
+
typeName: m.ZodEffects,
|
|
2639
|
+
...y(t)
|
|
2640
|
+
});
|
|
2641
|
+
let O = class extends _ {
|
|
2642
|
+
_parse(e) {
|
|
2643
|
+
return this._getType(e) === h.undefined ? x(void 0) : this._def.innerType._parse(e);
|
|
2644
|
+
}
|
|
2645
|
+
unwrap() {
|
|
2646
|
+
return this._def.innerType;
|
|
2647
|
+
}
|
|
2648
|
+
};
|
|
2649
|
+
O.create = (a, e) => new O({
|
|
2650
|
+
innerType: a,
|
|
2651
|
+
typeName: m.ZodOptional,
|
|
2652
|
+
...y(e)
|
|
2653
|
+
});
|
|
2654
|
+
let M = class extends _ {
|
|
2655
|
+
_parse(e) {
|
|
2656
|
+
return this._getType(e) === h.null ? x(null) : this._def.innerType._parse(e);
|
|
2657
|
+
}
|
|
2658
|
+
unwrap() {
|
|
2659
|
+
return this._def.innerType;
|
|
2660
|
+
}
|
|
2661
|
+
};
|
|
2662
|
+
M.create = (a, e) => new M({
|
|
2663
|
+
innerType: a,
|
|
2664
|
+
typeName: m.ZodNullable,
|
|
2665
|
+
...y(e)
|
|
2666
|
+
});
|
|
2667
|
+
class ue extends _ {
|
|
2668
|
+
_parse(e) {
|
|
2669
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2670
|
+
let s = t.data;
|
|
2671
|
+
return t.parsedType === h.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
|
|
2672
|
+
data: s,
|
|
2673
|
+
path: t.path,
|
|
2674
|
+
parent: t
|
|
2675
|
+
});
|
|
2676
|
+
}
|
|
2677
|
+
removeDefault() {
|
|
2678
|
+
return this._def.innerType;
|
|
2679
|
+
}
|
|
2680
|
+
}
|
|
2681
|
+
ue.create = (a, e) => new ue({
|
|
2682
|
+
innerType: a,
|
|
2683
|
+
typeName: m.ZodDefault,
|
|
2684
|
+
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2685
|
+
...y(e)
|
|
2686
|
+
});
|
|
2687
|
+
class le extends _ {
|
|
2688
|
+
_parse(e) {
|
|
2689
|
+
const { ctx: t } = this._processInputParams(e), s = {
|
|
2690
|
+
...t,
|
|
2691
|
+
common: {
|
|
2692
|
+
...t.common,
|
|
2693
|
+
issues: []
|
|
2694
|
+
}
|
|
2695
|
+
}, n = this._def.innerType._parse({
|
|
2696
|
+
data: s.data,
|
|
2697
|
+
path: s.path,
|
|
2698
|
+
parent: {
|
|
2699
|
+
...s
|
|
2700
|
+
}
|
|
2701
|
+
});
|
|
2702
|
+
return Q(n) ? n.then((i) => ({
|
|
2703
|
+
status: "valid",
|
|
2704
|
+
value: i.status === "valid" ? i.value : this._def.catchValue({
|
|
2705
|
+
get error() {
|
|
2706
|
+
return new C(s.common.issues);
|
|
2707
|
+
},
|
|
2708
|
+
input: s.data
|
|
2709
|
+
})
|
|
2710
|
+
})) : {
|
|
2711
|
+
status: "valid",
|
|
2712
|
+
value: n.status === "valid" ? n.value : this._def.catchValue({
|
|
2713
|
+
get error() {
|
|
2714
|
+
return new C(s.common.issues);
|
|
2715
|
+
},
|
|
2716
|
+
input: s.data
|
|
2717
|
+
})
|
|
2718
|
+
};
|
|
2719
|
+
}
|
|
2720
|
+
removeCatch() {
|
|
2721
|
+
return this._def.innerType;
|
|
2722
|
+
}
|
|
2723
|
+
}
|
|
2724
|
+
le.create = (a, e) => new le({
|
|
2725
|
+
innerType: a,
|
|
2726
|
+
typeName: m.ZodCatch,
|
|
2727
|
+
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2728
|
+
...y(e)
|
|
2729
|
+
});
|
|
2730
|
+
class Ne extends _ {
|
|
2731
|
+
_parse(e) {
|
|
2732
|
+
if (this._getType(e) !== h.nan) {
|
|
2733
|
+
const t = this._getOrReturnCtx(e);
|
|
2734
|
+
return l(t, {
|
|
2735
|
+
code: c.invalid_type,
|
|
2736
|
+
expected: h.nan,
|
|
2737
|
+
received: t.parsedType
|
|
2738
|
+
}), f;
|
|
2739
|
+
}
|
|
2740
|
+
return { status: "valid", value: e.data };
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
Ne.create = (a) => new Ne({
|
|
2744
|
+
typeName: m.ZodNaN,
|
|
2745
|
+
...y(a)
|
|
2746
|
+
});
|
|
2747
|
+
const Zt = Symbol("zod_brand");
|
|
2748
|
+
class Fe extends _ {
|
|
2749
|
+
_parse(e) {
|
|
2750
|
+
const { ctx: t } = this._processInputParams(e), s = t.data;
|
|
2751
|
+
return this._def.type._parse({
|
|
2752
|
+
data: s,
|
|
2753
|
+
path: t.path,
|
|
2754
|
+
parent: t
|
|
2755
|
+
});
|
|
2756
|
+
}
|
|
2757
|
+
unwrap() {
|
|
2758
|
+
return this._def.type;
|
|
2759
|
+
}
|
|
2760
|
+
}
|
|
2761
|
+
class me extends _ {
|
|
2762
|
+
_parse(e) {
|
|
2763
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2764
|
+
if (s.common.async)
|
|
2765
|
+
return (async () => {
|
|
2766
|
+
const n = await this._def.in._parseAsync({
|
|
2767
|
+
data: s.data,
|
|
2768
|
+
path: s.path,
|
|
2769
|
+
parent: s
|
|
2770
|
+
});
|
|
2771
|
+
return n.status === "aborted" ? f : n.status === "dirty" ? (t.dirty(), ke(n.value)) : this._def.out._parseAsync({
|
|
2772
|
+
data: n.value,
|
|
2773
|
+
path: s.path,
|
|
2774
|
+
parent: s
|
|
2775
|
+
});
|
|
2776
|
+
})();
|
|
2777
|
+
{
|
|
2778
|
+
const n = this._def.in._parseSync({
|
|
2779
|
+
data: s.data,
|
|
2780
|
+
path: s.path,
|
|
2781
|
+
parent: s
|
|
2782
|
+
});
|
|
2783
|
+
return n.status === "aborted" ? f : n.status === "dirty" ? (t.dirty(), {
|
|
2784
|
+
status: "dirty",
|
|
2785
|
+
value: n.value
|
|
2786
|
+
}) : this._def.out._parseSync({
|
|
2787
|
+
data: n.value,
|
|
2788
|
+
path: s.path,
|
|
2789
|
+
parent: s
|
|
2790
|
+
});
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
static create(e, t) {
|
|
2794
|
+
return new me({
|
|
2795
|
+
in: e,
|
|
2796
|
+
out: t,
|
|
2797
|
+
typeName: m.ZodPipeline
|
|
2798
|
+
});
|
|
2799
|
+
}
|
|
2800
|
+
}
|
|
2801
|
+
class he extends _ {
|
|
2802
|
+
_parse(e) {
|
|
2803
|
+
const t = this._def.innerType._parse(e), s = (n) => (z(n) && (n.value = Object.freeze(n.value)), n);
|
|
2804
|
+
return Q(t) ? t.then((n) => s(n)) : s(t);
|
|
2805
|
+
}
|
|
2806
|
+
unwrap() {
|
|
2807
|
+
return this._def.innerType;
|
|
2808
|
+
}
|
|
2809
|
+
}
|
|
2810
|
+
he.create = (a, e) => new he({
|
|
2811
|
+
innerType: a,
|
|
2812
|
+
typeName: m.ZodReadonly,
|
|
2813
|
+
...y(e)
|
|
2814
|
+
});
|
|
2815
|
+
function De(a, e) {
|
|
2816
|
+
const t = typeof a == "function" ? a(e) : typeof a == "string" ? { message: a } : a;
|
|
2817
|
+
return typeof t == "string" ? { message: t } : t;
|
|
2818
|
+
}
|
|
2819
|
+
function Ye(a, e = {}, t) {
|
|
2820
|
+
return a ? J.create().superRefine((s, n) => {
|
|
2821
|
+
var i, r;
|
|
2822
|
+
const o = a(s);
|
|
2823
|
+
if (o instanceof Promise)
|
|
2824
|
+
return o.then((d) => {
|
|
2825
|
+
var u, g;
|
|
2826
|
+
if (!d) {
|
|
2827
|
+
const w = De(e, s), I = (g = (u = w.fatal) !== null && u !== void 0 ? u : t) !== null && g !== void 0 ? g : !0;
|
|
2828
|
+
n.addIssue({ code: "custom", ...w, fatal: I });
|
|
2829
|
+
}
|
|
2830
|
+
});
|
|
2831
|
+
if (!o) {
|
|
2832
|
+
const d = De(e, s), u = (r = (i = d.fatal) !== null && i !== void 0 ? i : t) !== null && r !== void 0 ? r : !0;
|
|
2833
|
+
n.addIssue({ code: "custom", ...d, fatal: u });
|
|
2834
|
+
}
|
|
2835
|
+
}) : J.create();
|
|
2836
|
+
}
|
|
2837
|
+
const Tt = {
|
|
2838
|
+
object: k.lazycreate
|
|
2839
|
+
};
|
|
2840
|
+
var m;
|
|
2841
|
+
(function(a) {
|
|
2842
|
+
a.ZodString = "ZodString", a.ZodNumber = "ZodNumber", a.ZodNaN = "ZodNaN", a.ZodBigInt = "ZodBigInt", a.ZodBoolean = "ZodBoolean", a.ZodDate = "ZodDate", a.ZodSymbol = "ZodSymbol", a.ZodUndefined = "ZodUndefined", a.ZodNull = "ZodNull", a.ZodAny = "ZodAny", a.ZodUnknown = "ZodUnknown", a.ZodNever = "ZodNever", a.ZodVoid = "ZodVoid", a.ZodArray = "ZodArray", a.ZodObject = "ZodObject", a.ZodUnion = "ZodUnion", a.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", a.ZodIntersection = "ZodIntersection", a.ZodTuple = "ZodTuple", a.ZodRecord = "ZodRecord", a.ZodMap = "ZodMap", a.ZodSet = "ZodSet", a.ZodFunction = "ZodFunction", a.ZodLazy = "ZodLazy", a.ZodLiteral = "ZodLiteral", a.ZodEnum = "ZodEnum", a.ZodEffects = "ZodEffects", a.ZodNativeEnum = "ZodNativeEnum", a.ZodOptional = "ZodOptional", a.ZodNullable = "ZodNullable", a.ZodDefault = "ZodDefault", a.ZodCatch = "ZodCatch", a.ZodPromise = "ZodPromise", a.ZodBranded = "ZodBranded", a.ZodPipeline = "ZodPipeline", a.ZodReadonly = "ZodReadonly";
|
|
2843
|
+
})(m || (m = {}));
|
|
2844
|
+
const Nt = (a, e = {
|
|
2845
|
+
message: `Input not instance of ${a.name}`
|
|
2846
|
+
}) => Ye((t) => t instanceof a, e), Ge = N.create, Xe = R.create, Ct = Ne.create, St = ee.create, Qe = te.create, Ot = q.create, At = xe.create, jt = se.create, It = ae.create, Et = J.create, $t = D.create, Pt = $.create, Rt = Ze.create, Mt = B.create, Ft = k.create, Lt = k.strictCreate, Dt = ne.create, zt = Ce.create, qt = ie.create, Bt = j.create, Vt = re.create, Ut = Te.create, Kt = V.create, Ht = H.create, Wt = oe.create, Jt = de.create, Yt = pe.create, Gt = ce.create, Xt = Y.create, ze = S.create, Qt = O.create, es = M.create, ts = S.createWithPreprocess, ss = me.create, as = () => Ge().optional(), ns = () => Xe().optional(), is = () => Qe().optional(), rs = {
|
|
2847
|
+
string: (a) => N.create({ ...a, coerce: !0 }),
|
|
2848
|
+
number: (a) => R.create({ ...a, coerce: !0 }),
|
|
2849
|
+
boolean: (a) => te.create({
|
|
2850
|
+
...a,
|
|
2851
|
+
coerce: !0
|
|
2852
|
+
}),
|
|
2853
|
+
bigint: (a) => ee.create({ ...a, coerce: !0 }),
|
|
2854
|
+
date: (a) => q.create({ ...a, coerce: !0 })
|
|
2855
|
+
}, os = f;
|
|
2856
|
+
var je = /* @__PURE__ */ Object.freeze({
|
|
2857
|
+
__proto__: null,
|
|
2858
|
+
defaultErrorMap: W,
|
|
2859
|
+
setErrorMap: tt,
|
|
2860
|
+
getErrorMap: ve,
|
|
2861
|
+
makeIssue: be,
|
|
2862
|
+
EMPTY_PATH: st,
|
|
2863
|
+
addIssueToContext: l,
|
|
2864
|
+
ParseStatus: Z,
|
|
2865
|
+
INVALID: f,
|
|
2866
|
+
DIRTY: ke,
|
|
2867
|
+
OK: x,
|
|
2868
|
+
isAborted: Ee,
|
|
2869
|
+
isDirty: $e,
|
|
2870
|
+
isValid: z,
|
|
2871
|
+
isAsync: Q,
|
|
2872
|
+
get util() {
|
|
2873
|
+
return b;
|
|
2874
|
+
},
|
|
2875
|
+
get objectUtil() {
|
|
2876
|
+
return Ie;
|
|
2877
|
+
},
|
|
2878
|
+
ZodParsedType: h,
|
|
2879
|
+
getParsedType: E,
|
|
2880
|
+
ZodType: _,
|
|
2881
|
+
datetimeRegex: We,
|
|
2882
|
+
ZodString: N,
|
|
2883
|
+
ZodNumber: R,
|
|
2884
|
+
ZodBigInt: ee,
|
|
2885
|
+
ZodBoolean: te,
|
|
2886
|
+
ZodDate: q,
|
|
2887
|
+
ZodSymbol: xe,
|
|
2888
|
+
ZodUndefined: se,
|
|
2889
|
+
ZodNull: ae,
|
|
2890
|
+
ZodAny: J,
|
|
2891
|
+
ZodUnknown: D,
|
|
2892
|
+
ZodNever: $,
|
|
2893
|
+
ZodVoid: Ze,
|
|
2894
|
+
ZodArray: B,
|
|
2895
|
+
ZodObject: k,
|
|
2896
|
+
ZodUnion: ne,
|
|
2897
|
+
ZodDiscriminatedUnion: Ce,
|
|
2898
|
+
ZodIntersection: ie,
|
|
2899
|
+
ZodTuple: j,
|
|
2900
|
+
ZodRecord: re,
|
|
2901
|
+
ZodMap: Te,
|
|
2902
|
+
ZodSet: V,
|
|
2903
|
+
ZodFunction: H,
|
|
2904
|
+
ZodLazy: oe,
|
|
2905
|
+
ZodLiteral: de,
|
|
2906
|
+
ZodEnum: pe,
|
|
2907
|
+
ZodNativeEnum: ce,
|
|
2908
|
+
ZodPromise: Y,
|
|
2909
|
+
ZodEffects: S,
|
|
2910
|
+
ZodTransformer: S,
|
|
2911
|
+
ZodOptional: O,
|
|
2912
|
+
ZodNullable: M,
|
|
2913
|
+
ZodDefault: ue,
|
|
2914
|
+
ZodCatch: le,
|
|
2915
|
+
ZodNaN: Ne,
|
|
2916
|
+
BRAND: Zt,
|
|
2917
|
+
ZodBranded: Fe,
|
|
2918
|
+
ZodPipeline: me,
|
|
2919
|
+
ZodReadonly: he,
|
|
2920
|
+
custom: Ye,
|
|
2921
|
+
Schema: _,
|
|
2922
|
+
ZodSchema: _,
|
|
2923
|
+
late: Tt,
|
|
2924
|
+
get ZodFirstPartyTypeKind() {
|
|
2925
|
+
return m;
|
|
2926
|
+
},
|
|
2927
|
+
coerce: rs,
|
|
2928
|
+
any: Et,
|
|
2929
|
+
array: Mt,
|
|
2930
|
+
bigint: St,
|
|
2931
|
+
boolean: Qe,
|
|
2932
|
+
date: Ot,
|
|
2933
|
+
discriminatedUnion: zt,
|
|
2934
|
+
effect: ze,
|
|
2935
|
+
enum: Yt,
|
|
2936
|
+
function: Ht,
|
|
2937
|
+
instanceof: Nt,
|
|
2938
|
+
intersection: qt,
|
|
2939
|
+
lazy: Wt,
|
|
2940
|
+
literal: Jt,
|
|
2941
|
+
map: Ut,
|
|
2942
|
+
nan: Ct,
|
|
2943
|
+
nativeEnum: Gt,
|
|
2944
|
+
never: Pt,
|
|
2945
|
+
null: It,
|
|
2946
|
+
nullable: es,
|
|
2947
|
+
number: Xe,
|
|
2948
|
+
object: Ft,
|
|
2949
|
+
oboolean: is,
|
|
2950
|
+
onumber: ns,
|
|
2951
|
+
optional: Qt,
|
|
2952
|
+
ostring: as,
|
|
2953
|
+
pipeline: ss,
|
|
2954
|
+
preprocess: ts,
|
|
2955
|
+
promise: Xt,
|
|
2956
|
+
record: Vt,
|
|
2957
|
+
set: Kt,
|
|
2958
|
+
strictObject: Lt,
|
|
2959
|
+
string: Ge,
|
|
2960
|
+
symbol: At,
|
|
2961
|
+
transformer: ze,
|
|
2962
|
+
tuple: Bt,
|
|
2963
|
+
undefined: jt,
|
|
2964
|
+
union: Dt,
|
|
2965
|
+
unknown: $t,
|
|
2966
|
+
void: Rt,
|
|
2967
|
+
NEVER: os,
|
|
2968
|
+
ZodIssueCode: c,
|
|
2969
|
+
quotelessJson: et,
|
|
2970
|
+
ZodError: C
|
|
2971
|
+
});
|
|
2972
|
+
const ds = "1.0.0", cs = {
|
|
2973
|
+
version: ds
|
|
2974
|
+
};
|
|
2975
|
+
class us {
|
|
2976
|
+
constructor(e) {
|
|
2977
|
+
this._client = e;
|
|
2978
|
+
}
|
|
2979
|
+
/**
|
|
2980
|
+
* Retrieves information about the account associated with the current session.
|
|
2981
|
+
*
|
|
2982
|
+
* This method allows an application to get details about the TelemetryOS account
|
|
2983
|
+
* in which it is currently running.
|
|
2984
|
+
*
|
|
2985
|
+
* @returns A promise that resolves to the current account object
|
|
2986
|
+
*/
|
|
2987
|
+
async getCurrent() {
|
|
2988
|
+
return (await this._client.request("user.getCurrentAccount", {})).account;
|
|
2989
|
+
}
|
|
2990
|
+
}
|
|
2991
|
+
class ls {
|
|
2992
|
+
constructor(e) {
|
|
2993
|
+
this._client = e;
|
|
2994
|
+
}
|
|
2995
|
+
/**
|
|
2996
|
+
* Retrieves all applications with a specific mount point within the current account.
|
|
2997
|
+
*
|
|
2998
|
+
* This method allows applications that host other applications to discover compatible
|
|
2999
|
+
* applications that can be embedded. For example, a dashboard application might search
|
|
3000
|
+
* for all applications that have a 'dashboard-widget' mount point.
|
|
3001
|
+
*
|
|
3002
|
+
* The results are scoped to the current account, so only applications associated with
|
|
3003
|
+
* the same account will be returned.
|
|
3004
|
+
*
|
|
3005
|
+
* @param mountPoint The mount point identifier to search for
|
|
3006
|
+
* @returns A promise that resolves to an array of applications having the specified mount point
|
|
3007
|
+
*/
|
|
3008
|
+
async getAllByMountPoint(e) {
|
|
3009
|
+
return (await this._client.request("applications.getByMountPoint", {
|
|
3010
|
+
mountPoint: e
|
|
3011
|
+
})).applications;
|
|
3012
|
+
}
|
|
3013
|
+
/**
|
|
3014
|
+
* Retrieves an application by its name.
|
|
3015
|
+
*
|
|
3016
|
+
* This method allows finding a specific application when you know its name. It's useful
|
|
3017
|
+
* when you need to check if a particular application is available or get its details
|
|
3018
|
+
* before attempting to embed it.
|
|
3019
|
+
*
|
|
3020
|
+
* @param name The name of the application to query for
|
|
3021
|
+
* @returns A promise that resolves to the application object if found, or null if not found
|
|
3022
|
+
*/
|
|
3023
|
+
async getByName(e) {
|
|
3024
|
+
return (await this._client.request("applications.getByName", {
|
|
3025
|
+
name: e
|
|
3026
|
+
})).application;
|
|
3027
|
+
}
|
|
3028
|
+
/**
|
|
3029
|
+
* Generates a URL for embedding an application with the specified name and mount point.
|
|
3030
|
+
*
|
|
3031
|
+
* This method returns a URL that can be used in an iframe src attribute to embed
|
|
3032
|
+
* the application. The URL includes necessary parameters for the application to
|
|
3033
|
+
* understand its context and communicate with the platform.
|
|
3034
|
+
*
|
|
3035
|
+
* Only applications that are associated with the current account can be retrieved.
|
|
3036
|
+
*
|
|
3037
|
+
* @param name The name of the application to get the URL for
|
|
3038
|
+
* @param mountPoint The mount point to use when embedding the application
|
|
3039
|
+
* @returns A promise that resolves to the URL string for embedding the application
|
|
3040
|
+
*/
|
|
3041
|
+
async getUrl(e, t) {
|
|
3042
|
+
return (await this._client.request("applications.getUrl", {
|
|
3043
|
+
name: e,
|
|
3044
|
+
mountPoint: t
|
|
3045
|
+
})).url;
|
|
3046
|
+
}
|
|
3047
|
+
}
|
|
3048
|
+
function hs(a, e = console.error) {
|
|
3049
|
+
a().catch(e);
|
|
3050
|
+
}
|
|
3051
|
+
class Ns {
|
|
3052
|
+
constructor(e) {
|
|
3053
|
+
this._client = e;
|
|
3054
|
+
}
|
|
3055
|
+
async getColorScheme() {
|
|
3056
|
+
return (await this._client.request("environment.getColorScheme", {})).colorScheme;
|
|
3057
|
+
}
|
|
3058
|
+
subscribeColorScheme(e) {
|
|
3059
|
+
hs(async () => {
|
|
3060
|
+
this._client.on("environment.colorSchemeChanged", e), e(await this.getColorScheme());
|
|
3061
|
+
});
|
|
3062
|
+
}
|
|
3063
|
+
unsubscribeColorScheme(e) {
|
|
3064
|
+
this._client.off("environment.colorSchemeChanged", e);
|
|
3065
|
+
}
|
|
3066
|
+
}
|
|
3067
|
+
class ps {
|
|
3068
|
+
constructor(e) {
|
|
3069
|
+
this._client = e;
|
|
3070
|
+
}
|
|
3071
|
+
/**
|
|
3072
|
+
* Queries for media folders based on folder properties.
|
|
3073
|
+
*
|
|
3074
|
+
* This method allows you to search for media folders that match specific criteria,
|
|
3075
|
+
* such as name, ID, or other folder properties.
|
|
3076
|
+
*
|
|
3077
|
+
* @param query An object with partial MediaFolder properties to match against
|
|
3078
|
+
* @returns A promise that resolves to an array of matching media folders
|
|
3079
|
+
*/
|
|
3080
|
+
async queryFolders(e) {
|
|
3081
|
+
return (await this._client.request("media.queryMediaFolders", {
|
|
3082
|
+
query: e
|
|
3083
|
+
})).folders;
|
|
3084
|
+
}
|
|
3085
|
+
/**
|
|
3086
|
+
* Retrieves media folders that have been tagged with a specific tag.
|
|
3087
|
+
*
|
|
3088
|
+
* @param tagName The name of the tag to search for
|
|
3089
|
+
* @returns A promise that resolves to an array of media folders with the specified tag
|
|
3090
|
+
*/
|
|
3091
|
+
async getFoldersByTag(e) {
|
|
3092
|
+
return (await this._client.request("media.getMediaFoldersByTag", {
|
|
3093
|
+
tagName: e
|
|
3094
|
+
})).folders;
|
|
3095
|
+
}
|
|
3096
|
+
/**
|
|
3097
|
+
* Retrieves a specific media folder by its ID.
|
|
3098
|
+
*
|
|
3099
|
+
* @param id The unique identifier of the folder to retrieve
|
|
3100
|
+
* @returns A promise that resolves to the media folder with the specified ID
|
|
3101
|
+
*/
|
|
3102
|
+
async getFolderById(e) {
|
|
3103
|
+
return (await this._client.request("media.getMediaFolderById", {
|
|
3104
|
+
id: e
|
|
3105
|
+
})).folder;
|
|
3106
|
+
}
|
|
3107
|
+
/**
|
|
3108
|
+
* Retrieves all media content items within a specific folder.
|
|
3109
|
+
*
|
|
3110
|
+
* @param folderId The unique identifier of the folder to get content from
|
|
3111
|
+
* @returns A promise that resolves to an array of media content items in the folder
|
|
3112
|
+
*/
|
|
3113
|
+
async getMediaContentByFolderId(e) {
|
|
3114
|
+
return (await this._client.request("media.getMediaContentByFolderId", {
|
|
3115
|
+
folderId: e
|
|
3116
|
+
})).folders;
|
|
3117
|
+
}
|
|
3118
|
+
/**
|
|
3119
|
+
* Retrieves a specific media content item by its ID.
|
|
3120
|
+
*
|
|
3121
|
+
* @param id The unique identifier of the media content to retrieve
|
|
3122
|
+
* @returns A promise that resolves to the media content item with the specified ID
|
|
3123
|
+
*/
|
|
3124
|
+
async getMediaContentById(e) {
|
|
3125
|
+
return (await this._client.request("media.getMediaContentById", {
|
|
3126
|
+
id: e
|
|
3127
|
+
})).content;
|
|
3128
|
+
}
|
|
3129
|
+
}
|
|
3130
|
+
class ms {
|
|
3131
|
+
constructor(e) {
|
|
3132
|
+
this._client = e;
|
|
3133
|
+
}
|
|
3134
|
+
/**
|
|
3135
|
+
* Provides access to the application store scope.
|
|
3136
|
+
*
|
|
3137
|
+
* Data stored in the application scope is shared across all instances of your application
|
|
3138
|
+
* within the current account. Use this scope for application-wide settings, shared resources,
|
|
3139
|
+
* or any data that should be consistent across all instances.
|
|
3140
|
+
*
|
|
3141
|
+
* @returns A StoreSlice instance for the application scope
|
|
3142
|
+
*/
|
|
3143
|
+
get application() {
|
|
3144
|
+
return new fe("application", "", this._client);
|
|
3145
|
+
}
|
|
3146
|
+
/**
|
|
3147
|
+
* Provides access to the instance store scope.
|
|
3148
|
+
*
|
|
3149
|
+
* Data stored in the instance scope is only available to the current instance of your
|
|
3150
|
+
* application. This is ideal for instance-specific settings, UI state, temporary data,
|
|
3151
|
+
* or any information that shouldn't be shared with other instances.
|
|
3152
|
+
*
|
|
3153
|
+
* The namespace for instance data includes both the application name and the instance ID.
|
|
3154
|
+
*
|
|
3155
|
+
* @returns A StoreSlice instance for the instance scope
|
|
3156
|
+
*/
|
|
3157
|
+
get instance() {
|
|
3158
|
+
return new fe("instance", this._client._applicationId, this._client);
|
|
3159
|
+
}
|
|
3160
|
+
/**
|
|
3161
|
+
* Provides access to the device store scope.
|
|
3162
|
+
*
|
|
3163
|
+
* Data stored in the device scope is only available to the application on the
|
|
3164
|
+
* current physical device. This is useful for device-specific settings, caching, or
|
|
3165
|
+
* any data that should persist across application instances but only on a single device.
|
|
3166
|
+
*
|
|
3167
|
+
* Note: This scope cannot be used for Settings-related mount points as the User
|
|
3168
|
+
* Administration UI does not run on a device.
|
|
3169
|
+
*
|
|
3170
|
+
* @returns A StoreSlice instance for the device scope
|
|
3171
|
+
*/
|
|
3172
|
+
get device() {
|
|
3173
|
+
return new fe("device", this._client._applicationId, this._client);
|
|
3174
|
+
}
|
|
3175
|
+
/**
|
|
3176
|
+
* Provides access to the shared store scope with a specified namespace.
|
|
3177
|
+
*
|
|
3178
|
+
* The shared scope enables data sharing between different applications within the
|
|
3179
|
+
* same account. By specifying a common namespace, any two applications can exchange
|
|
3180
|
+
* data and communicate with each other.
|
|
3181
|
+
*
|
|
3182
|
+
* This is particularly useful for application ecosystems where multiple applications
|
|
3183
|
+
* need to coordinate or share configuration.
|
|
3184
|
+
*
|
|
3185
|
+
* @param namespace A string identifier for the shared data space
|
|
3186
|
+
* @returns A StoreSlice instance for the specified shared namespace
|
|
3187
|
+
*/
|
|
3188
|
+
shared(e) {
|
|
3189
|
+
return new fe("shared", e, this._client);
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
class fe {
|
|
3193
|
+
constructor(e, t, s) {
|
|
3194
|
+
this._kind = e, this._namespace = t, this._client = s;
|
|
3195
|
+
}
|
|
3196
|
+
/**
|
|
3197
|
+
* Saves a value in the store.
|
|
3198
|
+
*
|
|
3199
|
+
* This method stores data under the specified key within the current store scope and namespace.
|
|
3200
|
+
* The value must be serializable (can be converted to JSON). Complex objects like Date instances
|
|
3201
|
+
* will be serialized and deserialize as regular objects, losing their prototype methods.
|
|
3202
|
+
*
|
|
3203
|
+
* @param key The key to save the value under
|
|
3204
|
+
* @param value The value to store - must be JSON serializable
|
|
3205
|
+
* @returns A promise that resolves to true if the value was saved successfully
|
|
3206
|
+
*/
|
|
3207
|
+
async set(e, t) {
|
|
3208
|
+
return (await this._client.request("store.set", {
|
|
3209
|
+
kind: this._kind,
|
|
3210
|
+
namespace: this._namespace,
|
|
3211
|
+
key: e,
|
|
3212
|
+
value: t
|
|
3213
|
+
})).success;
|
|
3214
|
+
}
|
|
3215
|
+
/**
|
|
3216
|
+
* Retrieves a value from the store.
|
|
3217
|
+
*
|
|
3218
|
+
* This method fetches data stored under the specified key within the current store scope
|
|
3219
|
+
* and namespace. For real-time applications that need to respond to changes, consider
|
|
3220
|
+
* using subscribe() instead.
|
|
3221
|
+
*
|
|
3222
|
+
* @template T The expected type of the stored value
|
|
3223
|
+
* @param key The key to retrieve the value for
|
|
3224
|
+
* @returns A promise that resolves to the stored value, or undefined if the key does not exist
|
|
3225
|
+
*/
|
|
3226
|
+
async get(e) {
|
|
3227
|
+
return (await this._client.request("store.get", {
|
|
3228
|
+
kind: this._kind,
|
|
3229
|
+
namespace: this._namespace,
|
|
3230
|
+
key: e
|
|
3231
|
+
})).value;
|
|
3232
|
+
}
|
|
3233
|
+
/**
|
|
3234
|
+
* Subscribes to changes in the store for a specific key.
|
|
3235
|
+
*
|
|
3236
|
+
* This method sets up a subscription that will call the provided handler whenever
|
|
3237
|
+
* the value associated with the specified key changes. This is the recommended way
|
|
3238
|
+
* to access store data in long-running applications that need to stay responsive
|
|
3239
|
+
* to data changes.
|
|
3240
|
+
*
|
|
3241
|
+
* @param key The key to subscribe to
|
|
3242
|
+
* @param handler The callback function to call when the value changes
|
|
3243
|
+
* @returns A promise that resolves to true if the subscription was successful
|
|
3244
|
+
*/
|
|
3245
|
+
async subscribe(e, t) {
|
|
3246
|
+
return (await this._client.subscribe("store.subscribe", {
|
|
3247
|
+
kind: this._kind,
|
|
3248
|
+
namespace: this._namespace,
|
|
3249
|
+
key: e
|
|
3250
|
+
}, t)).success;
|
|
3251
|
+
}
|
|
3252
|
+
/**
|
|
3253
|
+
* Unsubscribes from changes in the store for a specific key.
|
|
3254
|
+
*
|
|
3255
|
+
* This method removes a subscription previously created with subscribe(). It can
|
|
3256
|
+
* either remove a specific handler or all handlers for the given key.
|
|
3257
|
+
*
|
|
3258
|
+
* @param key The key to unsubscribe from
|
|
3259
|
+
* @param handler Optional. The specific handler to remove. If not provided, all handlers for this key will be removed.
|
|
3260
|
+
* @returns A promise that resolves to true if the unsubscription was successful
|
|
3261
|
+
*/
|
|
3262
|
+
async unsubscribe(e, t) {
|
|
3263
|
+
return (await this._client.unsubscribe("store.unsubscribe", {
|
|
3264
|
+
kind: this._kind,
|
|
3265
|
+
namespace: this._namespace,
|
|
3266
|
+
key: e
|
|
3267
|
+
}, t)).success;
|
|
3268
|
+
}
|
|
3269
|
+
/**
|
|
3270
|
+
* Deletes a value from the store.
|
|
3271
|
+
*
|
|
3272
|
+
* This method removes the data stored under the specified key within the
|
|
3273
|
+
* current store scope and namespace.
|
|
3274
|
+
*
|
|
3275
|
+
* @param key The key to delete
|
|
3276
|
+
* @returns A promise that resolves to true if the value was deleted successfully
|
|
3277
|
+
*/
|
|
3278
|
+
async delete(e) {
|
|
3279
|
+
return (await this._client.request("store.delete", {
|
|
3280
|
+
kind: this._kind,
|
|
3281
|
+
namespace: this._namespace,
|
|
3282
|
+
key: e
|
|
3283
|
+
})).success;
|
|
3284
|
+
}
|
|
3285
|
+
}
|
|
3286
|
+
class fs {
|
|
3287
|
+
constructor(e) {
|
|
3288
|
+
this._client = e;
|
|
3289
|
+
}
|
|
3290
|
+
/**
|
|
3291
|
+
* Retrieves information about the user associated with the current session.
|
|
3292
|
+
*
|
|
3293
|
+
* This method allows an application to get details about the TelemetryOS user
|
|
3294
|
+
* who is currently using the application.
|
|
3295
|
+
*
|
|
3296
|
+
* @returns A promise that resolves to the current user result object
|
|
3297
|
+
* @example
|
|
3298
|
+
* // Get the current user information
|
|
3299
|
+
* const userResult = await users.getCurrent();
|
|
3300
|
+
* console.log(`Current user ID: ${userResult.user.id}`);
|
|
3301
|
+
*/
|
|
3302
|
+
async getCurrent() {
|
|
3303
|
+
return await this._client.request("user.getCurrentUser", {});
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
const ys = je.object({
|
|
3307
|
+
name: je.string(),
|
|
3308
|
+
data: je.any()
|
|
3309
|
+
});
|
|
3310
|
+
class gs {
|
|
3311
|
+
/**
|
|
3312
|
+
* Creates a new RootSettingsNavigation API instance.
|
|
3313
|
+
*
|
|
3314
|
+
* @param store The Store instance to use for persistence
|
|
3315
|
+
* @throws {Error} If used by an application not mounted at the 'rootSettingsNavigation' mount point
|
|
3316
|
+
*/
|
|
3317
|
+
constructor(e) {
|
|
3318
|
+
if (e._client._applicationId !== "rootSettingsNavigation")
|
|
3319
|
+
throw new Error("RootSettingsNavigation can only be used in the rootSettingsNavigation mount point");
|
|
3320
|
+
this._store = e;
|
|
3321
|
+
}
|
|
3322
|
+
/**
|
|
3323
|
+
* Registers navigation entries for the root application in the TelemetryOS admin UI.
|
|
3324
|
+
*
|
|
3325
|
+
* This method allows a root application to define its sidebar navigation structure
|
|
3326
|
+
* within the TelemetryOS administration UI. The navigation entries will appear in the
|
|
3327
|
+
* sidebar menu, allowing users to navigate to different sections of the application.
|
|
3328
|
+
*
|
|
3329
|
+
* @param navigation An object containing the navigation entries to register
|
|
3330
|
+
* @returns A promise that resolves when the navigation has been registered
|
|
3331
|
+
*/
|
|
3332
|
+
async setRootSettingsNavigation(e) {
|
|
3333
|
+
const t = this._store.shared("root-settings-navigation"), s = await t.get("navigation"), n = this._store._client._applicationId;
|
|
3334
|
+
s[n] = {
|
|
3335
|
+
applicationId: n,
|
|
3336
|
+
entries: e.entries
|
|
3337
|
+
}, t.set("navigation", s);
|
|
3338
|
+
}
|
|
3339
|
+
/**
|
|
3340
|
+
* Retrieves the current navigation entries for this root application.
|
|
3341
|
+
*
|
|
3342
|
+
* This method returns the navigation structure that was previously registered
|
|
3343
|
+
* for this application using setRootSettingsNavigation().
|
|
3344
|
+
*
|
|
3345
|
+
* @returns A promise that resolves to the navigation state for this application
|
|
3346
|
+
*/
|
|
3347
|
+
async getRootSettingsNavigation() {
|
|
3348
|
+
const e = await this._store.shared("root-settings-navigation").get("navigation"), t = this._store._client._applicationId;
|
|
3349
|
+
return e[t];
|
|
3350
|
+
}
|
|
3351
|
+
/**
|
|
3352
|
+
* Retrieves the navigation entries for all root applications.
|
|
3353
|
+
*
|
|
3354
|
+
* This method returns the navigation structures for all root applications registered
|
|
3355
|
+
* in the TelemetryOS administration UI. This can be useful for coordination between
|
|
3356
|
+
* different root applications.
|
|
3357
|
+
*
|
|
3358
|
+
* @returns A promise that resolves to the navigation state for all applications
|
|
3359
|
+
*/
|
|
3360
|
+
async getAllRootSettingsNavigation() {
|
|
3361
|
+
return this._store.shared("root-settings-navigation").get("navigation");
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
const U = 1e3 * 30;
|
|
3365
|
+
class _s {
|
|
3366
|
+
/**
|
|
3367
|
+
* Creates a new Client instance for communicating with the TelemetryOS platform.
|
|
3368
|
+
*
|
|
3369
|
+
* Note that creating a Client instance alone is not sufficient to begin communication.
|
|
3370
|
+
* You must also call the bind() method to initialize event listeners and extract
|
|
3371
|
+
* the application ID from the URL.
|
|
3372
|
+
*
|
|
3373
|
+
* @param applicationName The name of your application - must match the 'name' property
|
|
3374
|
+
* in your application's telemetry.config.json file
|
|
3375
|
+
*/
|
|
3376
|
+
constructor(e) {
|
|
3377
|
+
this._applicationName = e, this._applicationId = "", this._onHandlers = /* @__PURE__ */ new Map(), this._onceHandlers = /* @__PURE__ */ new Map(), this._subscriptionNamesByHandler = /* @__PURE__ */ new Map(), this._subscriptionNamesBySubjectName = /* @__PURE__ */ new Map();
|
|
3378
|
+
}
|
|
3379
|
+
/**
|
|
3380
|
+
* Provides access to the accounts API for retrieving TelemetryOS account information.
|
|
3381
|
+
*
|
|
3382
|
+
* This property returns a new Accounts instance that allows querying information
|
|
3383
|
+
* about the current TelemetryOS account.
|
|
3384
|
+
*
|
|
3385
|
+
* NOTE: Most application developers should use the global accounts() function
|
|
3386
|
+
* instead of accessing this property directly.
|
|
3387
|
+
*
|
|
3388
|
+
* @returns An Accounts instance bound to this client
|
|
3389
|
+
*/
|
|
3390
|
+
get accounts() {
|
|
3391
|
+
return new us(this);
|
|
3392
|
+
}
|
|
3393
|
+
/**
|
|
3394
|
+
* Provides access to the users API for retrieving TelemetryOS user information.
|
|
3395
|
+
*
|
|
3396
|
+
* This property returns a new Users instance that allows querying information
|
|
3397
|
+
* about the current TelemetryOS user.
|
|
3398
|
+
*
|
|
3399
|
+
* NOTE: Most application developers should use the global users() function
|
|
3400
|
+
* instead of accessing this property directly.
|
|
3401
|
+
*
|
|
3402
|
+
* @returns A Users instance bound to this client
|
|
3403
|
+
*/
|
|
3404
|
+
get users() {
|
|
3405
|
+
return new fs(this);
|
|
3406
|
+
}
|
|
3407
|
+
/**
|
|
3408
|
+
* Provides access to the store API for data persistence with multiple storage scopes.
|
|
3409
|
+
*
|
|
3410
|
+
* This property returns a new Store instance that allows saving, retrieving, and
|
|
3411
|
+
* subscribing to data changes across different scopes (global, local, deviceLocal, shared).
|
|
3412
|
+
*
|
|
3413
|
+
* NOTE: Most application developers should use the global store() function
|
|
3414
|
+
* instead of accessing this property directly.
|
|
3415
|
+
*
|
|
3416
|
+
* @returns A Store instance bound to this client
|
|
3417
|
+
*/
|
|
3418
|
+
get store() {
|
|
3419
|
+
return new ms(this);
|
|
3420
|
+
}
|
|
3421
|
+
/**
|
|
3422
|
+
* Provides access to the applications API for discovering and embedding other TelemetryOS applications.
|
|
3423
|
+
*
|
|
3424
|
+
* This property returns a new Applications instance that allows querying for applications
|
|
3425
|
+
* by name or mount point, and generating URLs for embedding applications in iframes.
|
|
3426
|
+
*
|
|
3427
|
+
* NOTE: Most application developers should use the global applications() function
|
|
3428
|
+
* instead of accessing this property directly.
|
|
3429
|
+
*
|
|
3430
|
+
* @returns An Applications instance bound to this client
|
|
3431
|
+
*/
|
|
3432
|
+
get applications() {
|
|
3433
|
+
return new ls(this);
|
|
3434
|
+
}
|
|
3435
|
+
/**
|
|
3436
|
+
* Provides access to the media API for working with content hosted on the TelemetryOS platform.
|
|
3437
|
+
*
|
|
3438
|
+
* This property returns a new Media instance that allows applications to browse and access
|
|
3439
|
+
* media content uploaded to TelemetryOS. Applications can query folders, retrieve content,
|
|
3440
|
+
* and access media files.
|
|
3441
|
+
*
|
|
3442
|
+
* NOTE: Most application developers should use the global media() function
|
|
3443
|
+
* instead of accessing this property directly.
|
|
3444
|
+
*
|
|
3445
|
+
* @returns A Media instance bound to this client
|
|
3446
|
+
*/
|
|
3447
|
+
get media() {
|
|
3448
|
+
return new ps(this);
|
|
3449
|
+
}
|
|
3450
|
+
/**
|
|
3451
|
+
* Provides access to the root settings navigation API for TelemetryOS administration UI integration.
|
|
3452
|
+
*
|
|
3453
|
+
* NOTE: This API is not intended for most application developers. It is specifically designed
|
|
3454
|
+
* for root applications that need to integrate with the TelemetryOS administration UI.
|
|
3455
|
+
*
|
|
3456
|
+
* This property returns a new RootSettingsNavigation instance that allows root applications
|
|
3457
|
+
* to register sidebar navigation entries in the TelemetryOS administration UI.
|
|
3458
|
+
*
|
|
3459
|
+
* Most root application developers should use the global rootSettingsNavigation() function
|
|
3460
|
+
* instead of accessing this property directly.
|
|
3461
|
+
*
|
|
3462
|
+
* @returns A RootSettingsNavigation instance bound to this client
|
|
3463
|
+
* @throws {Error} If used by an application not mounted at the 'rootSettingsNavigation' mount point
|
|
3464
|
+
*/
|
|
3465
|
+
get rootSettingsNavigation() {
|
|
3466
|
+
return new gs(this.store);
|
|
3467
|
+
}
|
|
3468
|
+
/**
|
|
3469
|
+
* Initializes the client by setting up message listeners and extracting the application ID.
|
|
3470
|
+
*
|
|
3471
|
+
* This method must be called after creating a Client instance and before using any
|
|
3472
|
+
* of its communication methods. It performs two important tasks:
|
|
3473
|
+
*
|
|
3474
|
+
* 1. Sets up an event listener for window 'message' events to receive messages
|
|
3475
|
+
* from the TelemetryOS platform
|
|
3476
|
+
* 2. Extracts the application ID from the URL's query parameters
|
|
3477
|
+
*
|
|
3478
|
+
* The application ID is used by several APIs, including the store's local and deviceLocal scopes.
|
|
3479
|
+
*
|
|
3480
|
+
* NOTE: Most application developers should use the global configure() function instead
|
|
3481
|
+
* of creating and binding their own Client instances.
|
|
3482
|
+
*/
|
|
3483
|
+
bind() {
|
|
3484
|
+
var e;
|
|
3485
|
+
const t = new URL(window.location.href).searchParams;
|
|
3486
|
+
this._applicationId = (e = t.get("telemetryApplicationId")) !== null && e !== void 0 ? e : "", this._windowMessageHandler = (s) => {
|
|
3487
|
+
if (s.source === window)
|
|
3488
|
+
return;
|
|
3489
|
+
for (let d = 0; d < window.frames.length; d += 1)
|
|
3490
|
+
window.frames[d].postMessage(s.data, "*");
|
|
3491
|
+
const n = ys.safeParse(s.data);
|
|
3492
|
+
if (!n.success)
|
|
3493
|
+
return;
|
|
3494
|
+
const i = n.data, r = this._onHandlers.get(i.name), o = this._onceHandlers.get(i.name);
|
|
3495
|
+
if (r)
|
|
3496
|
+
for (const d of r)
|
|
3497
|
+
d(i.data);
|
|
3498
|
+
if (o) {
|
|
3499
|
+
for (const d of o)
|
|
3500
|
+
d(i.data);
|
|
3501
|
+
this._onceHandlers.delete(i.name);
|
|
3502
|
+
}
|
|
3503
|
+
}, window.addEventListener("message", this._windowMessageHandler);
|
|
3504
|
+
}
|
|
3505
|
+
/**
|
|
3506
|
+
* Removes the message event listener and cleans up resources.
|
|
3507
|
+
*
|
|
3508
|
+
* Call this method when you're done with the client to prevent memory leaks
|
|
3509
|
+
* and ensure proper cleanup. After calling unbind(), the client will no longer
|
|
3510
|
+
* receive messages from the TelemetryOS platform.
|
|
3511
|
+
*
|
|
3512
|
+
* Note that this does not cancel any active subscriptions or server-side resources.
|
|
3513
|
+
* You should explicitly unsubscribe from any subscriptions before unbinding.
|
|
3514
|
+
*
|
|
3515
|
+
* NOTE: Most application developers should use the global destroy() function instead
|
|
3516
|
+
* of managing their own Client instances.
|
|
3517
|
+
*/
|
|
3518
|
+
unbind() {
|
|
3519
|
+
this._windowMessageHandler && window.removeEventListener("message", this._windowMessageHandler);
|
|
3520
|
+
}
|
|
3521
|
+
/**
|
|
3522
|
+
* Sends a one-way message to the TelemetryOS platform.
|
|
3523
|
+
*
|
|
3524
|
+
* Use this method for fire-and-forget messages where no response is expected.
|
|
3525
|
+
* The message is sent to the parent window using the postMessage API and includes
|
|
3526
|
+
* metadata such as the SDK version and application name.
|
|
3527
|
+
*
|
|
3528
|
+
* NOTE: Most application developers should use the resource-specific APIs or the global
|
|
3529
|
+
* send() function instead of using this method directly.
|
|
3530
|
+
*
|
|
3531
|
+
* @param name The name of the message type to send
|
|
3532
|
+
* @param data The data payload to include with the message
|
|
3533
|
+
*/
|
|
3534
|
+
send(e, t) {
|
|
3535
|
+
const s = {
|
|
3536
|
+
telemetrySdkVersion: ge,
|
|
3537
|
+
applicationName: this._applicationName,
|
|
3538
|
+
name: e,
|
|
3539
|
+
data: t
|
|
3540
|
+
};
|
|
3541
|
+
window.parent.postMessage(s, "*");
|
|
3542
|
+
}
|
|
3543
|
+
/**
|
|
3544
|
+
* Sends a message to the TelemetryOS platform and waits for a response.
|
|
3545
|
+
*
|
|
3546
|
+
* This method implements a request-response pattern over the postMessage API.
|
|
3547
|
+
* It generates a unique correlation ID and sets up a listener for the response.
|
|
3548
|
+
* If no response is received within the timeout period (30 seconds by default),
|
|
3549
|
+
* the promise will reject.
|
|
3550
|
+
*
|
|
3551
|
+
* NOTE: Most application developers should use the resource-specific APIs or the global
|
|
3552
|
+
* request() function instead of using this method directly.
|
|
3553
|
+
*
|
|
3554
|
+
* @template D The expected type of the response data
|
|
3555
|
+
* @param name The name of the message type (endpoint) to request
|
|
3556
|
+
* @param data The data payload to include with the request
|
|
3557
|
+
* @returns A promise that resolves with the response data when received
|
|
3558
|
+
* @throws {Error} If the request times out
|
|
3559
|
+
*/
|
|
3560
|
+
request(e, t) {
|
|
3561
|
+
const s = ye(), n = {
|
|
3562
|
+
telemetrySdkVersion: ge,
|
|
3563
|
+
applicationName: this._applicationName,
|
|
3564
|
+
name: e,
|
|
3565
|
+
data: t,
|
|
3566
|
+
responseName: s
|
|
3567
|
+
};
|
|
3568
|
+
window.parent.postMessage(n, "*");
|
|
3569
|
+
let i = !1, r;
|
|
3570
|
+
const o = new Promise((u, g) => {
|
|
3571
|
+
const w = new Error(`${e} message request with response name of ${s} timed out after ${U}`);
|
|
3572
|
+
setTimeout(() => {
|
|
3573
|
+
i = !0, this.off(s, r), g(w);
|
|
3574
|
+
}, U);
|
|
3575
|
+
}), d = new Promise((u) => {
|
|
3576
|
+
r = (g) => {
|
|
3577
|
+
i || u(g);
|
|
3578
|
+
}, this.once(s, u);
|
|
3579
|
+
});
|
|
3580
|
+
return Promise.race([o, d]);
|
|
3581
|
+
}
|
|
3582
|
+
async subscribe(e, t, s) {
|
|
3583
|
+
let n, i;
|
|
3584
|
+
typeof t == "function" ? i = t : (n = t, i = s);
|
|
3585
|
+
const r = ye(), o = ye();
|
|
3586
|
+
let d = this._subscriptionNamesBySubjectName.get(e);
|
|
3587
|
+
d || (d = [], this._subscriptionNamesBySubjectName.set(e, d)), d.push(r), this._subscriptionNamesByHandler.set(i, r), this.on(r, i);
|
|
3588
|
+
const u = {
|
|
3589
|
+
telemetrySdkVersion: ge,
|
|
3590
|
+
applicationName: this._applicationName,
|
|
3591
|
+
name: e,
|
|
3592
|
+
data: n,
|
|
3593
|
+
responseName: o,
|
|
3594
|
+
subscriptionName: r
|
|
3595
|
+
};
|
|
3596
|
+
window.parent.postMessage(u, "*");
|
|
3597
|
+
let g = !1, w;
|
|
3598
|
+
const I = new Promise((F, L) => {
|
|
3599
|
+
const Oe = new Error(`${e} subscribe request with subscription name of ${r} and response name of ${o} timed out after ${U}`);
|
|
3600
|
+
setTimeout(() => {
|
|
3601
|
+
g = !0, this.off(o, w), L(Oe);
|
|
3602
|
+
}, U);
|
|
3603
|
+
}), Se = new Promise((F) => {
|
|
3604
|
+
w = (L) => {
|
|
3605
|
+
g || F(L);
|
|
3606
|
+
}, this.on(o, F);
|
|
3607
|
+
});
|
|
3608
|
+
return Promise.race([I, Se]);
|
|
3609
|
+
}
|
|
3610
|
+
async unsubscribe(e, t, s) {
|
|
3611
|
+
let n, i;
|
|
3612
|
+
typeof t == "function" ? i = t : (n = t, i = s);
|
|
3613
|
+
const r = ye();
|
|
3614
|
+
let o = [];
|
|
3615
|
+
if (i) {
|
|
3616
|
+
const d = this._subscriptionNamesByHandler.get(i);
|
|
3617
|
+
if (!d)
|
|
3618
|
+
return { success: !1 };
|
|
3619
|
+
o = [d], this._subscriptionNamesByHandler.delete(i);
|
|
3620
|
+
} else if (!this._subscriptionNamesBySubjectName.get(e))
|
|
3621
|
+
return { success: !1 };
|
|
3622
|
+
for await (const d of o) {
|
|
3623
|
+
this.off(d, i);
|
|
3624
|
+
const u = {
|
|
3625
|
+
telemetrySdkVersion: ge,
|
|
3626
|
+
applicationName: this._applicationName,
|
|
3627
|
+
name: e,
|
|
3628
|
+
data: n,
|
|
3629
|
+
responseName: r,
|
|
3630
|
+
unsubscribeName: d
|
|
3631
|
+
};
|
|
3632
|
+
window.parent.postMessage(u, "*");
|
|
3633
|
+
let g = !1, w;
|
|
3634
|
+
const I = new Promise((F, L) => {
|
|
3635
|
+
const Oe = new Error(`${e} unsubscribe request with unsubscribe name of ${d} and response name of ${r} timed out after ${U}`);
|
|
3636
|
+
setTimeout(() => {
|
|
3637
|
+
g = !0, this.off(r, w), L(Oe);
|
|
3638
|
+
}, U);
|
|
3639
|
+
}), Se = new Promise((F) => {
|
|
3640
|
+
w = (L) => {
|
|
3641
|
+
g || F(L);
|
|
3642
|
+
}, this.once(r, F);
|
|
3643
|
+
});
|
|
3644
|
+
if (!(await Promise.race([I, Se])).success)
|
|
3645
|
+
return { success: !1 };
|
|
3646
|
+
}
|
|
3647
|
+
return { success: !0 };
|
|
3648
|
+
}
|
|
3649
|
+
/**
|
|
3650
|
+
* Registers a handler function for a specific message type.
|
|
3651
|
+
*
|
|
3652
|
+
* The handler will be called each time a message with the specified name is received.
|
|
3653
|
+
* You can register multiple handlers for the same message type, and all will be executed
|
|
3654
|
+
* when that message is received.
|
|
3655
|
+
*
|
|
3656
|
+
* Unlike subscribe(), this method only sets up a local event listener and doesn't
|
|
3657
|
+
* notify the platform of your interest in a particular message type.
|
|
3658
|
+
*
|
|
3659
|
+
* NOTE: Most application developers should use the resource-specific APIs or the global
|
|
3660
|
+
* on() function instead of using this method directly.
|
|
3661
|
+
*
|
|
3662
|
+
* @template T The expected type of the message data
|
|
3663
|
+
* @param name The name of the message type to listen for
|
|
3664
|
+
* @param handler The callback function to execute when messages are received
|
|
3665
|
+
*/
|
|
3666
|
+
on(e, t) {
|
|
3667
|
+
var s;
|
|
3668
|
+
const n = (s = this._onHandlers.get(e)) !== null && s !== void 0 ? s : [];
|
|
3669
|
+
n.length === 0 && this._onHandlers.set(e, n), n.push(t);
|
|
3670
|
+
}
|
|
3671
|
+
/**
|
|
3672
|
+
* Registers a one-time handler for a specific message type.
|
|
3673
|
+
*
|
|
3674
|
+
* Similar to the on() method, but the handler will be automatically removed
|
|
3675
|
+
* after it is called once. This is useful for initialization events or operations
|
|
3676
|
+
* that should only happen once in response to a particular message.
|
|
3677
|
+
*
|
|
3678
|
+
* NOTE: Most application developers should use the resource-specific APIs or the global
|
|
3679
|
+
* once() function instead of using this method directly.
|
|
3680
|
+
*
|
|
3681
|
+
* @template T The expected type of the message data
|
|
3682
|
+
* @param name The name of the message type to listen for
|
|
3683
|
+
* @param handler The callback function to execute when the message is received
|
|
3684
|
+
*/
|
|
3685
|
+
once(e, t) {
|
|
3686
|
+
var s;
|
|
3687
|
+
const n = (s = this._onceHandlers.get(e)) !== null && s !== void 0 ? s : [];
|
|
3688
|
+
n.length === 0 && this._onceHandlers.set(e, n), n.push(t);
|
|
3689
|
+
}
|
|
3690
|
+
/**
|
|
3691
|
+
* Removes previously registered message handlers.
|
|
3692
|
+
*
|
|
3693
|
+
* Use this method to stop receiving messages of a specific type or to remove
|
|
3694
|
+
* specific handler functions when they're no longer needed. This applies to
|
|
3695
|
+
* handlers registered with both on() and once() methods.
|
|
3696
|
+
*
|
|
3697
|
+
* NOTE: Most application developers should use the resource-specific APIs or the global
|
|
3698
|
+
* off() function instead of using this method directly.
|
|
3699
|
+
*
|
|
3700
|
+
* @template T The expected type of the message data
|
|
3701
|
+
* @param name The name of the message type to stop listening for
|
|
3702
|
+
* @param handler Optional. The specific handler function to remove. If omitted,
|
|
3703
|
+
* all handlers for this message type will be removed.
|
|
3704
|
+
*/
|
|
3705
|
+
off(e, t) {
|
|
3706
|
+
const s = this._onHandlers.get(e), n = this._onceHandlers.get(e);
|
|
3707
|
+
if (!(!s && !n)) {
|
|
3708
|
+
if (s) {
|
|
3709
|
+
for (let i = 0; i < s.length; i += 1)
|
|
3710
|
+
t && s[i] !== t || (s.splice(i, 1), i -= 1);
|
|
3711
|
+
s.length === 0 && this._onHandlers.delete(e);
|
|
3712
|
+
}
|
|
3713
|
+
if (n) {
|
|
3714
|
+
for (let i = 0; i < n.length; i += 1)
|
|
3715
|
+
t && n[i] !== t || (n.splice(i, 1), i -= 1);
|
|
3716
|
+
n.length === 0 && this._onceHandlers.delete(e);
|
|
3717
|
+
}
|
|
3718
|
+
}
|
|
3719
|
+
}
|
|
3720
|
+
}
|
|
3721
|
+
function ye() {
|
|
3722
|
+
return Math.random().toString(36).slice(2, 9);
|
|
3723
|
+
}
|
|
3724
|
+
const ge = cs.version;
|
|
3725
|
+
class vs {
|
|
3726
|
+
constructor(e) {
|
|
3727
|
+
this._client = e;
|
|
3728
|
+
}
|
|
3729
|
+
async setOverride(e) {
|
|
3730
|
+
return await this._client.request("overrides.setOverride", { name: e });
|
|
3731
|
+
}
|
|
3732
|
+
async clearOverride(e) {
|
|
3733
|
+
return await this._client.request("overrides.clearOverride", { name: e });
|
|
3734
|
+
}
|
|
3735
|
+
}
|
|
3736
|
+
class bs {
|
|
3737
|
+
constructor(e) {
|
|
3738
|
+
this._client = e;
|
|
3739
|
+
}
|
|
3740
|
+
async nextPage() {
|
|
3741
|
+
return await this._client.request("playlist.nextPage", {});
|
|
3742
|
+
}
|
|
3743
|
+
async previousPage() {
|
|
3744
|
+
return await this._client.request("playlist.previousPage", {});
|
|
3745
|
+
}
|
|
3746
|
+
async setDuration(e) {
|
|
3747
|
+
return await this._client.request("playlist.setDuration", { duration: e });
|
|
3748
|
+
}
|
|
3749
|
+
}
|
|
3750
|
+
class ks extends _s {
|
|
3751
|
+
get playlist() {
|
|
3752
|
+
return new bs(this);
|
|
3753
|
+
}
|
|
3754
|
+
get overrides() {
|
|
3755
|
+
return new vs(this);
|
|
3756
|
+
}
|
|
3757
|
+
}
|
|
3758
|
+
let v = null;
|
|
3759
|
+
function Cs() {
|
|
3760
|
+
return v;
|
|
3761
|
+
}
|
|
3762
|
+
function Ss(a) {
|
|
3763
|
+
v = new ks(a), v.bind();
|
|
3764
|
+
}
|
|
3765
|
+
function Os() {
|
|
3766
|
+
v == null || v.unbind(), v = null;
|
|
3767
|
+
}
|
|
3768
|
+
function As(...a) {
|
|
3769
|
+
return T(v), v.on(...a);
|
|
3770
|
+
}
|
|
3771
|
+
function js(...a) {
|
|
3772
|
+
return T(v), v.once(...a);
|
|
3773
|
+
}
|
|
3774
|
+
function Is(...a) {
|
|
3775
|
+
return T(v), v.off(...a);
|
|
3776
|
+
}
|
|
3777
|
+
function Es(...a) {
|
|
3778
|
+
return T(v), v.send(...a);
|
|
3779
|
+
}
|
|
3780
|
+
function $s(...a) {
|
|
3781
|
+
return T(v), v.request(...a);
|
|
3782
|
+
}
|
|
3783
|
+
function Ps(...a) {
|
|
3784
|
+
return T(v), v.subscribe(...a);
|
|
3785
|
+
}
|
|
3786
|
+
function Rs(...a) {
|
|
3787
|
+
return T(v), v.unsubscribe(...a);
|
|
3788
|
+
}
|
|
3789
|
+
function Ms() {
|
|
3790
|
+
return T(v), v.store;
|
|
3791
|
+
}
|
|
3792
|
+
function Fs() {
|
|
3793
|
+
return T(v), v.applications;
|
|
3794
|
+
}
|
|
3795
|
+
function Ls() {
|
|
3796
|
+
return T(v), v.media;
|
|
3797
|
+
}
|
|
3798
|
+
function Ds() {
|
|
3799
|
+
return T(v), v.playlist;
|
|
3800
|
+
}
|
|
3801
|
+
function zs() {
|
|
3802
|
+
return T(v), v.overrides;
|
|
3803
|
+
}
|
|
3804
|
+
function qs() {
|
|
3805
|
+
return T(v), v.accounts;
|
|
3806
|
+
}
|
|
3807
|
+
function Bs() {
|
|
3808
|
+
return T(v), v.users;
|
|
3809
|
+
}
|
|
3810
|
+
function T(a) {
|
|
3811
|
+
if (!a)
|
|
3812
|
+
throw new Error("SDK is not configured");
|
|
3813
|
+
}
|
|
3814
|
+
export {
|
|
3815
|
+
us as Accounts,
|
|
3816
|
+
ls as Applications,
|
|
3817
|
+
Ns as Environment,
|
|
3818
|
+
ps as Media,
|
|
3819
|
+
ms as Store,
|
|
3820
|
+
fs as Users,
|
|
3821
|
+
qs as accounts,
|
|
3822
|
+
Fs as applications,
|
|
3823
|
+
Ss as configure,
|
|
3824
|
+
Os as destroy,
|
|
3825
|
+
Cs as globalClient,
|
|
3826
|
+
Ls as media,
|
|
3827
|
+
Is as off,
|
|
3828
|
+
As as on,
|
|
3829
|
+
js as once,
|
|
3830
|
+
zs as overrides,
|
|
3831
|
+
Ds as playlist,
|
|
3832
|
+
$s as request,
|
|
3833
|
+
Es as send,
|
|
3834
|
+
Ms as store,
|
|
3835
|
+
Ps as subscribe,
|
|
3836
|
+
ge as telemetrySdkVersion,
|
|
3837
|
+
Rs as unsubscribe,
|
|
3838
|
+
Bs as users
|
|
3839
|
+
};
|