@telemetryos/sdk 1.12.0 → 1.13.1
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/CHANGELOG.md +37 -0
- package/README.md +118 -7
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +574 -548
- package/dist/playlist.d.ts +18 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -9,41 +9,41 @@ var b;
|
|
|
9
9
|
throw new Error();
|
|
10
10
|
}
|
|
11
11
|
a.assertNever = t, a.arrayToEnum = (n) => {
|
|
12
|
-
const
|
|
13
|
-
for (const
|
|
14
|
-
r
|
|
15
|
-
return
|
|
12
|
+
const i = {};
|
|
13
|
+
for (const r of n)
|
|
14
|
+
i[r] = r;
|
|
15
|
+
return i;
|
|
16
16
|
}, a.getValidEnumValues = (n) => {
|
|
17
|
-
const
|
|
18
|
-
for (const o of
|
|
19
|
-
|
|
20
|
-
return a.objectValues(
|
|
21
|
-
}, a.objectValues = (n) => a.objectKeys(n).map(function(
|
|
22
|
-
return n[
|
|
17
|
+
const i = a.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), r = {};
|
|
18
|
+
for (const o of i)
|
|
19
|
+
r[o] = n[o];
|
|
20
|
+
return a.objectValues(r);
|
|
21
|
+
}, a.objectValues = (n) => a.objectKeys(n).map(function(i) {
|
|
22
|
+
return n[i];
|
|
23
23
|
}), a.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
|
|
24
|
-
const
|
|
25
|
-
for (const
|
|
26
|
-
Object.prototype.hasOwnProperty.call(n,
|
|
27
|
-
return
|
|
28
|
-
}, a.find = (n,
|
|
29
|
-
for (const
|
|
30
|
-
if (r
|
|
31
|
-
return
|
|
24
|
+
const i = [];
|
|
25
|
+
for (const r in n)
|
|
26
|
+
Object.prototype.hasOwnProperty.call(n, r) && i.push(r);
|
|
27
|
+
return i;
|
|
28
|
+
}, a.find = (n, i) => {
|
|
29
|
+
for (const r of n)
|
|
30
|
+
if (i(r))
|
|
31
|
+
return r;
|
|
32
32
|
}, a.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && Number.isFinite(n) && Math.floor(n) === n;
|
|
33
|
-
function s(n,
|
|
34
|
-
return n.map((
|
|
33
|
+
function s(n, i = " | ") {
|
|
34
|
+
return n.map((r) => typeof r == "string" ? `'${r}'` : r).join(i);
|
|
35
35
|
}
|
|
36
|
-
a.joinValues = s, a.jsonStringifyReplacer = (n,
|
|
36
|
+
a.joinValues = s, a.jsonStringifyReplacer = (n, i) => typeof i == "bigint" ? i.toString() : i;
|
|
37
37
|
})(b || (b = {}));
|
|
38
|
-
var
|
|
38
|
+
var ye;
|
|
39
39
|
(function(a) {
|
|
40
40
|
a.mergeShapes = (e, t) => ({
|
|
41
41
|
...e,
|
|
42
42
|
...t
|
|
43
43
|
// second overwrites first
|
|
44
44
|
});
|
|
45
|
-
})(
|
|
46
|
-
const
|
|
45
|
+
})(ye || (ye = {}));
|
|
46
|
+
const h = b.arrayToEnum([
|
|
47
47
|
"string",
|
|
48
48
|
"nan",
|
|
49
49
|
"number",
|
|
@@ -67,23 +67,23 @@ const l = b.arrayToEnum([
|
|
|
67
67
|
]), A = (a) => {
|
|
68
68
|
switch (typeof a) {
|
|
69
69
|
case "undefined":
|
|
70
|
-
return
|
|
70
|
+
return h.undefined;
|
|
71
71
|
case "string":
|
|
72
|
-
return
|
|
72
|
+
return h.string;
|
|
73
73
|
case "number":
|
|
74
|
-
return Number.isNaN(a) ?
|
|
74
|
+
return Number.isNaN(a) ? h.nan : h.number;
|
|
75
75
|
case "boolean":
|
|
76
|
-
return
|
|
76
|
+
return h.boolean;
|
|
77
77
|
case "function":
|
|
78
|
-
return
|
|
78
|
+
return h.function;
|
|
79
79
|
case "bigint":
|
|
80
|
-
return
|
|
80
|
+
return h.bigint;
|
|
81
81
|
case "symbol":
|
|
82
|
-
return
|
|
82
|
+
return h.symbol;
|
|
83
83
|
case "object":
|
|
84
|
-
return Array.isArray(a) ?
|
|
84
|
+
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;
|
|
85
85
|
default:
|
|
86
|
-
return
|
|
86
|
+
return h.unknown;
|
|
87
87
|
}
|
|
88
88
|
}, u = b.arrayToEnum([
|
|
89
89
|
"invalid_type",
|
|
@@ -103,7 +103,7 @@ const l = b.arrayToEnum([
|
|
|
103
103
|
"not_multiple_of",
|
|
104
104
|
"not_finite"
|
|
105
105
|
]);
|
|
106
|
-
class
|
|
106
|
+
class O extends Error {
|
|
107
107
|
get errors() {
|
|
108
108
|
return this.issues;
|
|
109
109
|
}
|
|
@@ -117,30 +117,30 @@ class Z extends Error {
|
|
|
117
117
|
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
118
118
|
}
|
|
119
119
|
format(e) {
|
|
120
|
-
const t = e || function(
|
|
121
|
-
return
|
|
122
|
-
}, s = { _errors: [] }, n = (
|
|
123
|
-
for (const
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
else if (
|
|
127
|
-
n(
|
|
128
|
-
else if (
|
|
129
|
-
n(
|
|
130
|
-
else if (
|
|
131
|
-
s._errors.push(t(
|
|
120
|
+
const t = e || function(i) {
|
|
121
|
+
return i.message;
|
|
122
|
+
}, s = { _errors: [] }, n = (i) => {
|
|
123
|
+
for (const r of i.issues)
|
|
124
|
+
if (r.code === "invalid_union")
|
|
125
|
+
r.unionErrors.map(n);
|
|
126
|
+
else if (r.code === "invalid_return_type")
|
|
127
|
+
n(r.returnTypeError);
|
|
128
|
+
else if (r.code === "invalid_arguments")
|
|
129
|
+
n(r.argumentsError);
|
|
130
|
+
else if (r.path.length === 0)
|
|
131
|
+
s._errors.push(t(r));
|
|
132
132
|
else {
|
|
133
133
|
let o = s, c = 0;
|
|
134
|
-
for (; c <
|
|
135
|
-
const
|
|
136
|
-
c ===
|
|
134
|
+
for (; c < r.path.length; ) {
|
|
135
|
+
const l = r.path[c];
|
|
136
|
+
c === r.path.length - 1 ? (o[l] = o[l] || { _errors: [] }, o[l]._errors.push(t(r))) : o[l] = o[l] || { _errors: [] }, o = o[l], c++;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
140
|
return n(this), s;
|
|
141
141
|
}
|
|
142
142
|
static assert(e) {
|
|
143
|
-
if (!(e instanceof
|
|
143
|
+
if (!(e instanceof O))
|
|
144
144
|
throw new Error(`Not a ZodError: ${e}`);
|
|
145
145
|
}
|
|
146
146
|
toString() {
|
|
@@ -156,8 +156,8 @@ class Z extends Error {
|
|
|
156
156
|
const t = {}, s = [];
|
|
157
157
|
for (const n of this.issues)
|
|
158
158
|
if (n.path.length > 0) {
|
|
159
|
-
const
|
|
160
|
-
t[
|
|
159
|
+
const i = n.path[0];
|
|
160
|
+
t[i] = t[i] || [], t[i].push(e(n));
|
|
161
161
|
} else
|
|
162
162
|
s.push(e(n));
|
|
163
163
|
return { formErrors: s, fieldErrors: t };
|
|
@@ -166,12 +166,12 @@ class Z extends Error {
|
|
|
166
166
|
return this.flatten();
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
|
|
169
|
+
O.create = (a) => new O(a);
|
|
170
170
|
const ae = (a, e) => {
|
|
171
171
|
let t;
|
|
172
172
|
switch (a.code) {
|
|
173
173
|
case u.invalid_type:
|
|
174
|
-
a.received ===
|
|
174
|
+
a.received === h.undefined ? t = "Required" : t = `Expected ${a.expected}, received ${a.received}`;
|
|
175
175
|
break;
|
|
176
176
|
case u.invalid_literal:
|
|
177
177
|
t = `Invalid literal value, expected ${JSON.stringify(a.expected, b.jsonStringifyReplacer)}`;
|
|
@@ -228,23 +228,23 @@ function Me() {
|
|
|
228
228
|
return qe;
|
|
229
229
|
}
|
|
230
230
|
const Le = (a) => {
|
|
231
|
-
const { data: e, path: t, errorMaps: s, issueData: n } = a,
|
|
231
|
+
const { data: e, path: t, errorMaps: s, issueData: n } = a, i = [...t, ...n.path || []], r = {
|
|
232
232
|
...n,
|
|
233
|
-
path:
|
|
233
|
+
path: i
|
|
234
234
|
};
|
|
235
235
|
if (n.message !== void 0)
|
|
236
236
|
return {
|
|
237
237
|
...n,
|
|
238
|
-
path:
|
|
238
|
+
path: i,
|
|
239
239
|
message: n.message
|
|
240
240
|
};
|
|
241
241
|
let o = "";
|
|
242
|
-
const c = s.filter((
|
|
243
|
-
for (const
|
|
244
|
-
o =
|
|
242
|
+
const c = s.filter((l) => !!l).slice().reverse();
|
|
243
|
+
for (const l of c)
|
|
244
|
+
o = l(r, { data: e, defaultError: o }).message;
|
|
245
245
|
return {
|
|
246
246
|
...n,
|
|
247
|
-
path:
|
|
247
|
+
path: i,
|
|
248
248
|
message: o
|
|
249
249
|
};
|
|
250
250
|
};
|
|
@@ -266,7 +266,7 @@ function d(a, e) {
|
|
|
266
266
|
});
|
|
267
267
|
a.common.issues.push(s);
|
|
268
268
|
}
|
|
269
|
-
|
|
269
|
+
class S {
|
|
270
270
|
constructor() {
|
|
271
271
|
this.value = "valid";
|
|
272
272
|
}
|
|
@@ -288,33 +288,33 @@ let C = class $e {
|
|
|
288
288
|
static async mergeObjectAsync(e, t) {
|
|
289
289
|
const s = [];
|
|
290
290
|
for (const n of t) {
|
|
291
|
-
const
|
|
291
|
+
const i = await n.key, r = await n.value;
|
|
292
292
|
s.push({
|
|
293
|
-
key:
|
|
294
|
-
value:
|
|
293
|
+
key: i,
|
|
294
|
+
value: r
|
|
295
295
|
});
|
|
296
296
|
}
|
|
297
|
-
return
|
|
297
|
+
return S.mergeObjectSync(e, s);
|
|
298
298
|
}
|
|
299
299
|
static mergeObjectSync(e, t) {
|
|
300
300
|
const s = {};
|
|
301
301
|
for (const n of t) {
|
|
302
|
-
const { key:
|
|
303
|
-
if (
|
|
302
|
+
const { key: i, value: r } = n;
|
|
303
|
+
if (i.status === "aborted" || r.status === "aborted")
|
|
304
304
|
return _;
|
|
305
|
-
|
|
305
|
+
i.status === "dirty" && e.dirty(), r.status === "dirty" && e.dirty(), i.value !== "__proto__" && (typeof r.value < "u" || n.alwaysSet) && (s[i.value] = r.value);
|
|
306
306
|
}
|
|
307
307
|
return { status: e.value, value: s };
|
|
308
308
|
}
|
|
309
|
-
}
|
|
309
|
+
}
|
|
310
310
|
const _ = Object.freeze({
|
|
311
311
|
status: "aborted"
|
|
312
|
-
}),
|
|
312
|
+
}), ie = (a) => ({ status: "dirty", value: a }), C = (a) => ({ status: "valid", value: a }), ve = (a) => a.status === "aborted", be = (a) => a.status === "dirty", M = (a) => a.status === "valid", Y = (a) => typeof Promise < "u" && a instanceof Promise;
|
|
313
313
|
var p;
|
|
314
314
|
(function(a) {
|
|
315
315
|
a.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, a.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
316
316
|
})(p || (p = {}));
|
|
317
|
-
let
|
|
317
|
+
let E = class {
|
|
318
318
|
constructor(e, t, s, n) {
|
|
319
319
|
this._cachedPath = [], this.parent = e, this.data = t, this._path = s, this._key = n;
|
|
320
320
|
}
|
|
@@ -322,8 +322,8 @@ let $ = class {
|
|
|
322
322
|
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
323
323
|
}
|
|
324
324
|
};
|
|
325
|
-
const
|
|
326
|
-
if (
|
|
325
|
+
const we = (a, e) => {
|
|
326
|
+
if (M(e))
|
|
327
327
|
return { success: !0, data: e.value };
|
|
328
328
|
if (!a.common.issues.length)
|
|
329
329
|
throw new Error("Validation failed but no issues detected.");
|
|
@@ -332,7 +332,7 @@ const be = (a, e) => {
|
|
|
332
332
|
get error() {
|
|
333
333
|
if (this._error)
|
|
334
334
|
return this._error;
|
|
335
|
-
const t = new
|
|
335
|
+
const t = new O(a.common.issues);
|
|
336
336
|
return this._error = t, this._error;
|
|
337
337
|
}
|
|
338
338
|
};
|
|
@@ -343,9 +343,9 @@ function y(a) {
|
|
|
343
343
|
const { errorMap: e, invalid_type_error: t, required_error: s, description: n } = a;
|
|
344
344
|
if (e && (t || s))
|
|
345
345
|
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
346
|
-
return e ? { errorMap: e, description: n } : { errorMap: (
|
|
346
|
+
return e ? { errorMap: e, description: n } : { errorMap: (i, r) => {
|
|
347
347
|
const { message: o } = a;
|
|
348
|
-
return
|
|
348
|
+
return i.code === "invalid_enum_value" ? { message: o ?? r.defaultError } : typeof r.data > "u" ? { message: o ?? s ?? r.defaultError } : i.code !== "invalid_type" ? { message: r.defaultError } : { message: o ?? t ?? r.defaultError };
|
|
349
349
|
}, description: n };
|
|
350
350
|
}
|
|
351
351
|
let v = class {
|
|
@@ -367,7 +367,7 @@ let v = class {
|
|
|
367
367
|
}
|
|
368
368
|
_processInputParams(e) {
|
|
369
369
|
return {
|
|
370
|
-
status: new
|
|
370
|
+
status: new S(),
|
|
371
371
|
ctx: {
|
|
372
372
|
common: e.parent.common,
|
|
373
373
|
data: e.data,
|
|
@@ -407,7 +407,7 @@ let v = class {
|
|
|
407
407
|
data: e,
|
|
408
408
|
parsedType: A(e)
|
|
409
409
|
}, n = this._parseSync({ data: e, path: s.path, parent: s });
|
|
410
|
-
return
|
|
410
|
+
return we(s, n);
|
|
411
411
|
}
|
|
412
412
|
"~validate"(e) {
|
|
413
413
|
var t, s;
|
|
@@ -424,20 +424,20 @@ let v = class {
|
|
|
424
424
|
};
|
|
425
425
|
if (!this["~standard"].async)
|
|
426
426
|
try {
|
|
427
|
-
const
|
|
428
|
-
return
|
|
429
|
-
value:
|
|
427
|
+
const i = this._parseSync({ data: e, path: [], parent: n });
|
|
428
|
+
return M(i) ? {
|
|
429
|
+
value: i.value
|
|
430
430
|
} : {
|
|
431
431
|
issues: n.common.issues
|
|
432
432
|
};
|
|
433
|
-
} catch (
|
|
434
|
-
(s = (t =
|
|
433
|
+
} catch (i) {
|
|
434
|
+
(s = (t = i == null ? void 0 : i.message) == null ? void 0 : t.toLowerCase()) != null && s.includes("encountered") && (this["~standard"].async = !0), n.common = {
|
|
435
435
|
issues: [],
|
|
436
436
|
async: !0
|
|
437
437
|
};
|
|
438
438
|
}
|
|
439
|
-
return this._parseAsync({ data: e, path: [], parent: n }).then((
|
|
440
|
-
value:
|
|
439
|
+
return this._parseAsync({ data: e, path: [], parent: n }).then((i) => M(i) ? {
|
|
440
|
+
value: i.value
|
|
441
441
|
} : {
|
|
442
442
|
issues: n.common.issues
|
|
443
443
|
});
|
|
@@ -460,24 +460,24 @@ let v = class {
|
|
|
460
460
|
parent: null,
|
|
461
461
|
data: e,
|
|
462
462
|
parsedType: A(e)
|
|
463
|
-
}, n = this._parse({ data: e, path: s.path, parent: s }),
|
|
464
|
-
return
|
|
463
|
+
}, n = this._parse({ data: e, path: s.path, parent: s }), i = await (Y(n) ? n : Promise.resolve(n));
|
|
464
|
+
return we(s, i);
|
|
465
465
|
}
|
|
466
466
|
refine(e, t) {
|
|
467
467
|
const s = (n) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(n) : t;
|
|
468
|
-
return this._refinement((n,
|
|
469
|
-
const
|
|
468
|
+
return this._refinement((n, i) => {
|
|
469
|
+
const r = e(n), o = () => i.addIssue({
|
|
470
470
|
code: u.custom,
|
|
471
471
|
...s(n)
|
|
472
472
|
});
|
|
473
|
-
return typeof Promise < "u" &&
|
|
473
|
+
return typeof Promise < "u" && r instanceof Promise ? r.then((c) => c ? !0 : (o(), !1)) : r ? !0 : (o(), !1);
|
|
474
474
|
});
|
|
475
475
|
}
|
|
476
476
|
refinement(e, t) {
|
|
477
477
|
return this._refinement((s, n) => e(s) ? !0 : (n.addIssue(typeof t == "function" ? t(s, n) : t), !1));
|
|
478
478
|
}
|
|
479
479
|
_refinement(e) {
|
|
480
|
-
return new
|
|
480
|
+
return new L({
|
|
481
481
|
schema: this,
|
|
482
482
|
typeName: m.ZodEffects,
|
|
483
483
|
effect: { type: "refinement", refinement: e }
|
|
@@ -494,16 +494,16 @@ let v = class {
|
|
|
494
494
|
};
|
|
495
495
|
}
|
|
496
496
|
optional() {
|
|
497
|
-
return
|
|
497
|
+
return I.create(this, this._def);
|
|
498
498
|
}
|
|
499
499
|
nullable() {
|
|
500
|
-
return
|
|
500
|
+
return D.create(this, this._def);
|
|
501
501
|
}
|
|
502
502
|
nullish() {
|
|
503
503
|
return this.nullable().optional();
|
|
504
504
|
}
|
|
505
505
|
array() {
|
|
506
|
-
return
|
|
506
|
+
return N.create(this);
|
|
507
507
|
}
|
|
508
508
|
promise() {
|
|
509
509
|
return te.create(this, this._def);
|
|
@@ -515,7 +515,7 @@ let v = class {
|
|
|
515
515
|
return ee.create(this, e, this._def);
|
|
516
516
|
}
|
|
517
517
|
transform(e) {
|
|
518
|
-
return new
|
|
518
|
+
return new L({
|
|
519
519
|
...y(this._def),
|
|
520
520
|
schema: this,
|
|
521
521
|
typeName: m.ZodEffects,
|
|
@@ -524,7 +524,7 @@ let v = class {
|
|
|
524
524
|
}
|
|
525
525
|
default(e) {
|
|
526
526
|
const t = typeof e == "function" ? e : () => e;
|
|
527
|
-
return new
|
|
527
|
+
return new he({
|
|
528
528
|
...y(this._def),
|
|
529
529
|
innerType: this,
|
|
530
530
|
defaultValue: t,
|
|
@@ -540,7 +540,7 @@ let v = class {
|
|
|
540
540
|
}
|
|
541
541
|
catch(e) {
|
|
542
542
|
const t = typeof e == "function" ? e : () => e;
|
|
543
|
-
return new
|
|
543
|
+
return new pe({
|
|
544
544
|
...y(this._def),
|
|
545
545
|
innerType: this,
|
|
546
546
|
catchValue: t,
|
|
@@ -555,10 +555,10 @@ let v = class {
|
|
|
555
555
|
});
|
|
556
556
|
}
|
|
557
557
|
pipe(e) {
|
|
558
|
-
return
|
|
558
|
+
return _e.create(this, e);
|
|
559
559
|
}
|
|
560
560
|
readonly() {
|
|
561
|
-
return
|
|
561
|
+
return fe.create(this);
|
|
562
562
|
}
|
|
563
563
|
isOptional() {
|
|
564
564
|
return this.safeParse(void 0).success;
|
|
@@ -567,7 +567,7 @@ let v = class {
|
|
|
567
567
|
return this.safeParse(null).success;
|
|
568
568
|
}
|
|
569
569
|
};
|
|
570
|
-
const De = /^c[^\s-]{8,}$/i,
|
|
570
|
+
const De = /^c[^\s-]{8,}$/i, He = /^[0-9a-z]+$/, Ve = /^[0-9A-HJKMNP-TV-Z]{26}$/i, ze = /^[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, Be = /^[a-z0-9_-]{21}$/i, Ue = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, Ke = /^[-+]?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)?)??$/, We = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Je = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
571
571
|
let ne;
|
|
572
572
|
const Qe = /^(?:(?: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])$/, Ge = /^(?:(?: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])$/, Ye = /^(([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]))$/, Xe = /^(([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])$/, et = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, tt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, je = "((\\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])))", st = new RegExp(`^${je}$`);
|
|
573
573
|
function Pe(a) {
|
|
@@ -584,11 +584,11 @@ function at(a) {
|
|
|
584
584
|
const t = [];
|
|
585
585
|
return t.push(a.local ? "Z?" : "Z"), a.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
586
586
|
}
|
|
587
|
-
function
|
|
587
|
+
function it(a, e) {
|
|
588
588
|
return !!((e === "v4" || !e) && Qe.test(a) || (e === "v6" || !e) && Ye.test(a));
|
|
589
589
|
}
|
|
590
|
-
function
|
|
591
|
-
if (!
|
|
590
|
+
function rt(a, e) {
|
|
591
|
+
if (!Ue.test(a))
|
|
592
592
|
return !1;
|
|
593
593
|
try {
|
|
594
594
|
const [t] = a.split(".");
|
|
@@ -603,17 +603,17 @@ function it(a, e) {
|
|
|
603
603
|
function ot(a, e) {
|
|
604
604
|
return !!((e === "v4" || !e) && Ge.test(a) || (e === "v6" || !e) && Xe.test(a));
|
|
605
605
|
}
|
|
606
|
-
class
|
|
606
|
+
let re = class z extends v {
|
|
607
607
|
_parse(e) {
|
|
608
|
-
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !==
|
|
608
|
+
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
|
|
609
609
|
const n = this._getOrReturnCtx(e);
|
|
610
610
|
return d(n, {
|
|
611
611
|
code: u.invalid_type,
|
|
612
|
-
expected:
|
|
612
|
+
expected: h.string,
|
|
613
613
|
received: n.parsedType
|
|
614
614
|
}), _;
|
|
615
615
|
}
|
|
616
|
-
const t = new
|
|
616
|
+
const t = new S();
|
|
617
617
|
let s;
|
|
618
618
|
for (const n of this._def.checks)
|
|
619
619
|
if (n.kind === "min")
|
|
@@ -635,15 +635,15 @@ class I extends v {
|
|
|
635
635
|
message: n.message
|
|
636
636
|
}), t.dirty());
|
|
637
637
|
else if (n.kind === "length") {
|
|
638
|
-
const
|
|
639
|
-
(
|
|
638
|
+
const i = e.data.length > n.value, r = e.data.length < n.value;
|
|
639
|
+
(i || r) && (s = this._getOrReturnCtx(e, s), i ? d(s, {
|
|
640
640
|
code: u.too_big,
|
|
641
641
|
maximum: n.value,
|
|
642
642
|
type: "string",
|
|
643
643
|
inclusive: !0,
|
|
644
644
|
exact: !0,
|
|
645
645
|
message: n.message
|
|
646
|
-
}) :
|
|
646
|
+
}) : r && d(s, {
|
|
647
647
|
code: u.too_small,
|
|
648
648
|
minimum: n.value,
|
|
649
649
|
type: "string",
|
|
@@ -664,13 +664,13 @@ class I extends v {
|
|
|
664
664
|
message: n.message
|
|
665
665
|
}), t.dirty());
|
|
666
666
|
else if (n.kind === "uuid")
|
|
667
|
-
|
|
667
|
+
ze.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
668
668
|
validation: "uuid",
|
|
669
669
|
code: u.invalid_string,
|
|
670
670
|
message: n.message
|
|
671
671
|
}), t.dirty());
|
|
672
672
|
else if (n.kind === "nanoid")
|
|
673
|
-
|
|
673
|
+
Be.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
674
674
|
validation: "nanoid",
|
|
675
675
|
code: u.invalid_string,
|
|
676
676
|
message: n.message
|
|
@@ -682,13 +682,13 @@ class I extends v {
|
|
|
682
682
|
message: n.message
|
|
683
683
|
}), t.dirty());
|
|
684
684
|
else if (n.kind === "cuid2")
|
|
685
|
-
|
|
685
|
+
He.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
686
686
|
validation: "cuid2",
|
|
687
687
|
code: u.invalid_string,
|
|
688
688
|
message: n.message
|
|
689
689
|
}), t.dirty());
|
|
690
690
|
else if (n.kind === "ulid")
|
|
691
|
-
|
|
691
|
+
Ve.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
692
692
|
validation: "ulid",
|
|
693
693
|
code: u.invalid_string,
|
|
694
694
|
message: n.message
|
|
@@ -735,11 +735,11 @@ class I extends v {
|
|
|
735
735
|
validation: "duration",
|
|
736
736
|
code: u.invalid_string,
|
|
737
737
|
message: n.message
|
|
738
|
-
}), t.dirty()) : n.kind === "ip" ?
|
|
738
|
+
}), t.dirty()) : n.kind === "ip" ? it(e.data, n.version) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
739
739
|
validation: "ip",
|
|
740
740
|
code: u.invalid_string,
|
|
741
741
|
message: n.message
|
|
742
|
-
}), t.dirty()) : n.kind === "jwt" ?
|
|
742
|
+
}), t.dirty()) : n.kind === "jwt" ? rt(e.data, n.alg) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
743
743
|
validation: "jwt",
|
|
744
744
|
code: u.invalid_string,
|
|
745
745
|
message: n.message
|
|
@@ -766,7 +766,7 @@ class I extends v {
|
|
|
766
766
|
});
|
|
767
767
|
}
|
|
768
768
|
_addCheck(e) {
|
|
769
|
-
return new
|
|
769
|
+
return new z({
|
|
770
770
|
...this._def,
|
|
771
771
|
checks: [...this._def.checks, e]
|
|
772
772
|
});
|
|
@@ -902,19 +902,19 @@ class I extends v {
|
|
|
902
902
|
return this.min(1, p.errToObj(e));
|
|
903
903
|
}
|
|
904
904
|
trim() {
|
|
905
|
-
return new
|
|
905
|
+
return new z({
|
|
906
906
|
...this._def,
|
|
907
907
|
checks: [...this._def.checks, { kind: "trim" }]
|
|
908
908
|
});
|
|
909
909
|
}
|
|
910
910
|
toLowerCase() {
|
|
911
|
-
return new
|
|
911
|
+
return new z({
|
|
912
912
|
...this._def,
|
|
913
913
|
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
914
914
|
});
|
|
915
915
|
}
|
|
916
916
|
toUpperCase() {
|
|
917
|
-
return new
|
|
917
|
+
return new z({
|
|
918
918
|
...this._def,
|
|
919
919
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
920
920
|
});
|
|
@@ -979,32 +979,32 @@ class I extends v {
|
|
|
979
979
|
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
980
980
|
return e;
|
|
981
981
|
}
|
|
982
|
-
}
|
|
983
|
-
|
|
982
|
+
};
|
|
983
|
+
re.create = (a) => new re({
|
|
984
984
|
checks: [],
|
|
985
985
|
typeName: m.ZodString,
|
|
986
986
|
coerce: (a == null ? void 0 : a.coerce) ?? !1,
|
|
987
987
|
...y(a)
|
|
988
988
|
});
|
|
989
989
|
function ct(a, e) {
|
|
990
|
-
const t = (a.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, n = t > s ? t : s,
|
|
991
|
-
return
|
|
990
|
+
const t = (a.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, n = t > s ? t : s, i = Number.parseInt(a.toFixed(n).replace(".", "")), r = Number.parseInt(e.toFixed(n).replace(".", ""));
|
|
991
|
+
return i % r / 10 ** n;
|
|
992
992
|
}
|
|
993
|
-
let
|
|
993
|
+
let ke = class oe extends v {
|
|
994
994
|
constructor() {
|
|
995
995
|
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
996
996
|
}
|
|
997
997
|
_parse(e) {
|
|
998
|
-
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !==
|
|
998
|
+
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
|
|
999
999
|
const n = this._getOrReturnCtx(e);
|
|
1000
1000
|
return d(n, {
|
|
1001
1001
|
code: u.invalid_type,
|
|
1002
|
-
expected:
|
|
1002
|
+
expected: h.number,
|
|
1003
1003
|
received: n.parsedType
|
|
1004
1004
|
}), _;
|
|
1005
1005
|
}
|
|
1006
1006
|
let t;
|
|
1007
|
-
const s = new
|
|
1007
|
+
const s = new S();
|
|
1008
1008
|
for (const n of this._def.checks)
|
|
1009
1009
|
n.kind === "int" ? b.isInteger(e.data) || (t = this._getOrReturnCtx(e, t), d(t, {
|
|
1010
1010
|
code: u.invalid_type,
|
|
@@ -1048,7 +1048,7 @@ let we = class ie extends v {
|
|
|
1048
1048
|
return this.setLimit("max", e, !1, p.toString(t));
|
|
1049
1049
|
}
|
|
1050
1050
|
setLimit(e, t, s, n) {
|
|
1051
|
-
return new
|
|
1051
|
+
return new oe({
|
|
1052
1052
|
...this._def,
|
|
1053
1053
|
checks: [
|
|
1054
1054
|
...this._def.checks,
|
|
@@ -1062,7 +1062,7 @@ let we = class ie extends v {
|
|
|
1062
1062
|
});
|
|
1063
1063
|
}
|
|
1064
1064
|
_addCheck(e) {
|
|
1065
|
-
return new
|
|
1065
|
+
return new oe({
|
|
1066
1066
|
...this._def,
|
|
1067
1067
|
checks: [...this._def.checks, e]
|
|
1068
1068
|
});
|
|
@@ -1156,13 +1156,13 @@ let we = class ie extends v {
|
|
|
1156
1156
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
1157
1157
|
}
|
|
1158
1158
|
};
|
|
1159
|
-
|
|
1159
|
+
ke.create = (a) => new ke({
|
|
1160
1160
|
checks: [],
|
|
1161
1161
|
typeName: m.ZodNumber,
|
|
1162
1162
|
coerce: (a == null ? void 0 : a.coerce) || !1,
|
|
1163
1163
|
...y(a)
|
|
1164
1164
|
});
|
|
1165
|
-
class
|
|
1165
|
+
class U extends v {
|
|
1166
1166
|
constructor() {
|
|
1167
1167
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1168
1168
|
}
|
|
@@ -1173,10 +1173,10 @@ class H extends v {
|
|
|
1173
1173
|
} catch {
|
|
1174
1174
|
return this._getInvalidInput(e);
|
|
1175
1175
|
}
|
|
1176
|
-
if (this._getType(e) !==
|
|
1176
|
+
if (this._getType(e) !== h.bigint)
|
|
1177
1177
|
return this._getInvalidInput(e);
|
|
1178
1178
|
let t;
|
|
1179
|
-
const s = new
|
|
1179
|
+
const s = new S();
|
|
1180
1180
|
for (const n of this._def.checks)
|
|
1181
1181
|
n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (t = this._getOrReturnCtx(e, t), d(t, {
|
|
1182
1182
|
code: u.too_small,
|
|
@@ -1201,7 +1201,7 @@ class H extends v {
|
|
|
1201
1201
|
const t = this._getOrReturnCtx(e);
|
|
1202
1202
|
return d(t, {
|
|
1203
1203
|
code: u.invalid_type,
|
|
1204
|
-
expected:
|
|
1204
|
+
expected: h.bigint,
|
|
1205
1205
|
received: t.parsedType
|
|
1206
1206
|
}), _;
|
|
1207
1207
|
}
|
|
@@ -1218,7 +1218,7 @@ class H extends v {
|
|
|
1218
1218
|
return this.setLimit("max", e, !1, p.toString(t));
|
|
1219
1219
|
}
|
|
1220
1220
|
setLimit(e, t, s, n) {
|
|
1221
|
-
return new
|
|
1221
|
+
return new U({
|
|
1222
1222
|
...this._def,
|
|
1223
1223
|
checks: [
|
|
1224
1224
|
...this._def.checks,
|
|
@@ -1232,7 +1232,7 @@ class H extends v {
|
|
|
1232
1232
|
});
|
|
1233
1233
|
}
|
|
1234
1234
|
_addCheck(e) {
|
|
1235
|
-
return new
|
|
1235
|
+
return new U({
|
|
1236
1236
|
...this._def,
|
|
1237
1237
|
checks: [...this._def.checks, e]
|
|
1238
1238
|
});
|
|
@@ -1289,37 +1289,37 @@ class H extends v {
|
|
|
1289
1289
|
return e;
|
|
1290
1290
|
}
|
|
1291
1291
|
}
|
|
1292
|
-
|
|
1292
|
+
U.create = (a) => new U({
|
|
1293
1293
|
checks: [],
|
|
1294
1294
|
typeName: m.ZodBigInt,
|
|
1295
1295
|
coerce: (a == null ? void 0 : a.coerce) ?? !1,
|
|
1296
1296
|
...y(a)
|
|
1297
1297
|
});
|
|
1298
|
-
class
|
|
1298
|
+
class xe extends v {
|
|
1299
1299
|
_parse(e) {
|
|
1300
|
-
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !==
|
|
1300
|
+
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
|
|
1301
1301
|
const t = this._getOrReturnCtx(e);
|
|
1302
1302
|
return d(t, {
|
|
1303
1303
|
code: u.invalid_type,
|
|
1304
|
-
expected:
|
|
1304
|
+
expected: h.boolean,
|
|
1305
1305
|
received: t.parsedType
|
|
1306
1306
|
}), _;
|
|
1307
1307
|
}
|
|
1308
|
-
return
|
|
1308
|
+
return C(e.data);
|
|
1309
1309
|
}
|
|
1310
1310
|
}
|
|
1311
|
-
|
|
1311
|
+
xe.create = (a) => new xe({
|
|
1312
1312
|
typeName: m.ZodBoolean,
|
|
1313
1313
|
coerce: (a == null ? void 0 : a.coerce) || !1,
|
|
1314
1314
|
...y(a)
|
|
1315
1315
|
});
|
|
1316
|
-
let
|
|
1316
|
+
let Se = class Re extends v {
|
|
1317
1317
|
_parse(e) {
|
|
1318
|
-
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !==
|
|
1318
|
+
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
|
|
1319
1319
|
const n = this._getOrReturnCtx(e);
|
|
1320
1320
|
return d(n, {
|
|
1321
1321
|
code: u.invalid_type,
|
|
1322
|
-
expected:
|
|
1322
|
+
expected: h.date,
|
|
1323
1323
|
received: n.parsedType
|
|
1324
1324
|
}), _;
|
|
1325
1325
|
}
|
|
@@ -1329,7 +1329,7 @@ let xe = class Fe extends v {
|
|
|
1329
1329
|
code: u.invalid_date
|
|
1330
1330
|
}), _;
|
|
1331
1331
|
}
|
|
1332
|
-
const t = new
|
|
1332
|
+
const t = new S();
|
|
1333
1333
|
let s;
|
|
1334
1334
|
for (const n of this._def.checks)
|
|
1335
1335
|
n.kind === "min" ? e.data.getTime() < n.value && (s = this._getOrReturnCtx(e, s), d(s, {
|
|
@@ -1353,7 +1353,7 @@ let xe = class Fe extends v {
|
|
|
1353
1353
|
};
|
|
1354
1354
|
}
|
|
1355
1355
|
_addCheck(e) {
|
|
1356
|
-
return new
|
|
1356
|
+
return new Re({
|
|
1357
1357
|
...this._def,
|
|
1358
1358
|
checks: [...this._def.checks, e]
|
|
1359
1359
|
});
|
|
@@ -1385,133 +1385,133 @@ let xe = class Fe extends v {
|
|
|
1385
1385
|
return e != null ? new Date(e) : null;
|
|
1386
1386
|
}
|
|
1387
1387
|
};
|
|
1388
|
-
|
|
1388
|
+
Se.create = (a) => new Se({
|
|
1389
1389
|
checks: [],
|
|
1390
1390
|
coerce: (a == null ? void 0 : a.coerce) || !1,
|
|
1391
1391
|
typeName: m.ZodDate,
|
|
1392
1392
|
...y(a)
|
|
1393
1393
|
});
|
|
1394
|
-
class
|
|
1394
|
+
class Ce extends v {
|
|
1395
1395
|
_parse(e) {
|
|
1396
|
-
if (this._getType(e) !==
|
|
1396
|
+
if (this._getType(e) !== h.symbol) {
|
|
1397
1397
|
const t = this._getOrReturnCtx(e);
|
|
1398
1398
|
return d(t, {
|
|
1399
1399
|
code: u.invalid_type,
|
|
1400
|
-
expected:
|
|
1400
|
+
expected: h.symbol,
|
|
1401
1401
|
received: t.parsedType
|
|
1402
1402
|
}), _;
|
|
1403
1403
|
}
|
|
1404
|
-
return
|
|
1404
|
+
return C(e.data);
|
|
1405
1405
|
}
|
|
1406
1406
|
}
|
|
1407
|
-
|
|
1407
|
+
Ce.create = (a) => new Ce({
|
|
1408
1408
|
typeName: m.ZodSymbol,
|
|
1409
1409
|
...y(a)
|
|
1410
1410
|
});
|
|
1411
|
-
class
|
|
1411
|
+
class Te extends v {
|
|
1412
1412
|
_parse(e) {
|
|
1413
|
-
if (this._getType(e) !==
|
|
1413
|
+
if (this._getType(e) !== h.undefined) {
|
|
1414
1414
|
const t = this._getOrReturnCtx(e);
|
|
1415
1415
|
return d(t, {
|
|
1416
1416
|
code: u.invalid_type,
|
|
1417
|
-
expected:
|
|
1417
|
+
expected: h.undefined,
|
|
1418
1418
|
received: t.parsedType
|
|
1419
1419
|
}), _;
|
|
1420
1420
|
}
|
|
1421
|
-
return
|
|
1421
|
+
return C(e.data);
|
|
1422
1422
|
}
|
|
1423
1423
|
}
|
|
1424
|
-
|
|
1424
|
+
Te.create = (a) => new Te({
|
|
1425
1425
|
typeName: m.ZodUndefined,
|
|
1426
1426
|
...y(a)
|
|
1427
1427
|
});
|
|
1428
|
-
class
|
|
1428
|
+
class Ne extends v {
|
|
1429
1429
|
_parse(e) {
|
|
1430
|
-
if (this._getType(e) !==
|
|
1430
|
+
if (this._getType(e) !== h.null) {
|
|
1431
1431
|
const t = this._getOrReturnCtx(e);
|
|
1432
1432
|
return d(t, {
|
|
1433
1433
|
code: u.invalid_type,
|
|
1434
|
-
expected:
|
|
1434
|
+
expected: h.null,
|
|
1435
1435
|
received: t.parsedType
|
|
1436
1436
|
}), _;
|
|
1437
1437
|
}
|
|
1438
|
-
return
|
|
1438
|
+
return C(e.data);
|
|
1439
1439
|
}
|
|
1440
1440
|
}
|
|
1441
|
-
|
|
1441
|
+
Ne.create = (a) => new Ne({
|
|
1442
1442
|
typeName: m.ZodNull,
|
|
1443
1443
|
...y(a)
|
|
1444
1444
|
});
|
|
1445
|
-
class
|
|
1445
|
+
class ce extends v {
|
|
1446
1446
|
constructor() {
|
|
1447
1447
|
super(...arguments), this._any = !0;
|
|
1448
1448
|
}
|
|
1449
1449
|
_parse(e) {
|
|
1450
|
-
return
|
|
1450
|
+
return C(e.data);
|
|
1451
1451
|
}
|
|
1452
1452
|
}
|
|
1453
|
-
|
|
1453
|
+
ce.create = (a) => new ce({
|
|
1454
1454
|
typeName: m.ZodAny,
|
|
1455
1455
|
...y(a)
|
|
1456
1456
|
});
|
|
1457
|
-
class
|
|
1457
|
+
class Oe extends v {
|
|
1458
1458
|
constructor() {
|
|
1459
1459
|
super(...arguments), this._unknown = !0;
|
|
1460
1460
|
}
|
|
1461
1461
|
_parse(e) {
|
|
1462
|
-
return
|
|
1462
|
+
return C(e.data);
|
|
1463
1463
|
}
|
|
1464
1464
|
}
|
|
1465
|
-
|
|
1465
|
+
Oe.create = (a) => new Oe({
|
|
1466
1466
|
typeName: m.ZodUnknown,
|
|
1467
1467
|
...y(a)
|
|
1468
1468
|
});
|
|
1469
|
-
let
|
|
1469
|
+
let $ = class extends v {
|
|
1470
1470
|
_parse(e) {
|
|
1471
1471
|
const t = this._getOrReturnCtx(e);
|
|
1472
1472
|
return d(t, {
|
|
1473
1473
|
code: u.invalid_type,
|
|
1474
|
-
expected:
|
|
1474
|
+
expected: h.never,
|
|
1475
1475
|
received: t.parsedType
|
|
1476
1476
|
}), _;
|
|
1477
1477
|
}
|
|
1478
1478
|
};
|
|
1479
|
-
|
|
1479
|
+
$.create = (a) => new $({
|
|
1480
1480
|
typeName: m.ZodNever,
|
|
1481
1481
|
...y(a)
|
|
1482
1482
|
});
|
|
1483
1483
|
class Ze extends v {
|
|
1484
1484
|
_parse(e) {
|
|
1485
|
-
if (this._getType(e) !==
|
|
1485
|
+
if (this._getType(e) !== h.undefined) {
|
|
1486
1486
|
const t = this._getOrReturnCtx(e);
|
|
1487
1487
|
return d(t, {
|
|
1488
1488
|
code: u.invalid_type,
|
|
1489
|
-
expected:
|
|
1489
|
+
expected: h.void,
|
|
1490
1490
|
received: t.parsedType
|
|
1491
1491
|
}), _;
|
|
1492
1492
|
}
|
|
1493
|
-
return
|
|
1493
|
+
return C(e.data);
|
|
1494
1494
|
}
|
|
1495
1495
|
}
|
|
1496
1496
|
Ze.create = (a) => new Ze({
|
|
1497
1497
|
typeName: m.ZodVoid,
|
|
1498
1498
|
...y(a)
|
|
1499
1499
|
});
|
|
1500
|
-
class
|
|
1500
|
+
class N extends v {
|
|
1501
1501
|
_parse(e) {
|
|
1502
1502
|
const { ctx: t, status: s } = this._processInputParams(e), n = this._def;
|
|
1503
|
-
if (t.parsedType !==
|
|
1503
|
+
if (t.parsedType !== h.array)
|
|
1504
1504
|
return d(t, {
|
|
1505
1505
|
code: u.invalid_type,
|
|
1506
|
-
expected:
|
|
1506
|
+
expected: h.array,
|
|
1507
1507
|
received: t.parsedType
|
|
1508
1508
|
}), _;
|
|
1509
1509
|
if (n.exactLength !== null) {
|
|
1510
|
-
const
|
|
1511
|
-
(
|
|
1512
|
-
code:
|
|
1510
|
+
const r = t.data.length > n.exactLength.value, o = t.data.length < n.exactLength.value;
|
|
1511
|
+
(r || o) && (d(t, {
|
|
1512
|
+
code: r ? u.too_big : u.too_small,
|
|
1513
1513
|
minimum: o ? n.exactLength.value : void 0,
|
|
1514
|
-
maximum:
|
|
1514
|
+
maximum: r ? n.exactLength.value : void 0,
|
|
1515
1515
|
type: "array",
|
|
1516
1516
|
inclusive: !0,
|
|
1517
1517
|
exact: !0,
|
|
@@ -1533,27 +1533,27 @@ class T extends v {
|
|
|
1533
1533
|
exact: !1,
|
|
1534
1534
|
message: n.maxLength.message
|
|
1535
1535
|
}), s.dirty()), t.common.async)
|
|
1536
|
-
return Promise.all([...t.data].map((
|
|
1537
|
-
const
|
|
1538
|
-
return
|
|
1536
|
+
return Promise.all([...t.data].map((r, o) => n.type._parseAsync(new E(t, r, t.path, o)))).then((r) => S.mergeArray(s, r));
|
|
1537
|
+
const i = [...t.data].map((r, o) => n.type._parseSync(new E(t, r, t.path, o)));
|
|
1538
|
+
return S.mergeArray(s, i);
|
|
1539
1539
|
}
|
|
1540
1540
|
get element() {
|
|
1541
1541
|
return this._def.type;
|
|
1542
1542
|
}
|
|
1543
1543
|
min(e, t) {
|
|
1544
|
-
return new
|
|
1544
|
+
return new N({
|
|
1545
1545
|
...this._def,
|
|
1546
1546
|
minLength: { value: e, message: p.toString(t) }
|
|
1547
1547
|
});
|
|
1548
1548
|
}
|
|
1549
1549
|
max(e, t) {
|
|
1550
|
-
return new
|
|
1550
|
+
return new N({
|
|
1551
1551
|
...this._def,
|
|
1552
1552
|
maxLength: { value: e, message: p.toString(t) }
|
|
1553
1553
|
});
|
|
1554
1554
|
}
|
|
1555
1555
|
length(e, t) {
|
|
1556
|
-
return new
|
|
1556
|
+
return new N({
|
|
1557
1557
|
...this._def,
|
|
1558
1558
|
exactLength: { value: e, message: p.toString(t) }
|
|
1559
1559
|
});
|
|
@@ -1562,7 +1562,7 @@ class T extends v {
|
|
|
1562
1562
|
return this.min(1, e);
|
|
1563
1563
|
}
|
|
1564
1564
|
}
|
|
1565
|
-
|
|
1565
|
+
N.create = (a, e) => new N({
|
|
1566
1566
|
type: a,
|
|
1567
1567
|
minLength: null,
|
|
1568
1568
|
maxLength: null,
|
|
@@ -1570,23 +1570,23 @@ T.create = (a, e) => new T({
|
|
|
1570
1570
|
typeName: m.ZodArray,
|
|
1571
1571
|
...y(e)
|
|
1572
1572
|
});
|
|
1573
|
-
function
|
|
1574
|
-
if (a instanceof
|
|
1573
|
+
function q(a) {
|
|
1574
|
+
if (a instanceof Z) {
|
|
1575
1575
|
const e = {};
|
|
1576
1576
|
for (const t in a.shape) {
|
|
1577
1577
|
const s = a.shape[t];
|
|
1578
|
-
e[t] =
|
|
1578
|
+
e[t] = I.create(q(s));
|
|
1579
1579
|
}
|
|
1580
|
-
return new
|
|
1580
|
+
return new Z({
|
|
1581
1581
|
...a._def,
|
|
1582
1582
|
shape: () => e
|
|
1583
1583
|
});
|
|
1584
|
-
} else return a instanceof
|
|
1584
|
+
} else return a instanceof N ? new N({
|
|
1585
1585
|
...a._def,
|
|
1586
|
-
type:
|
|
1587
|
-
}) : a instanceof
|
|
1586
|
+
type: q(a.element)
|
|
1587
|
+
}) : a instanceof I ? I.create(q(a.unwrap())) : a instanceof D ? D.create(q(a.unwrap())) : a instanceof F ? F.create(a.items.map((e) => q(e))) : a;
|
|
1588
1588
|
}
|
|
1589
|
-
let
|
|
1589
|
+
let Z = class T extends v {
|
|
1590
1590
|
constructor() {
|
|
1591
1591
|
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1592
1592
|
}
|
|
@@ -1597,96 +1597,96 @@ let O = class N extends v {
|
|
|
1597
1597
|
return this._cached = { shape: e, keys: t }, this._cached;
|
|
1598
1598
|
}
|
|
1599
1599
|
_parse(e) {
|
|
1600
|
-
if (this._getType(e) !==
|
|
1600
|
+
if (this._getType(e) !== h.object) {
|
|
1601
1601
|
const c = this._getOrReturnCtx(e);
|
|
1602
1602
|
return d(c, {
|
|
1603
1603
|
code: u.invalid_type,
|
|
1604
|
-
expected:
|
|
1604
|
+
expected: h.object,
|
|
1605
1605
|
received: c.parsedType
|
|
1606
1606
|
}), _;
|
|
1607
1607
|
}
|
|
1608
|
-
const { status: t, ctx: s } = this._processInputParams(e), { shape: n, keys:
|
|
1609
|
-
if (!(this._def.catchall instanceof
|
|
1608
|
+
const { status: t, ctx: s } = this._processInputParams(e), { shape: n, keys: i } = this._getCached(), r = [];
|
|
1609
|
+
if (!(this._def.catchall instanceof $ && this._def.unknownKeys === "strip"))
|
|
1610
1610
|
for (const c in s.data)
|
|
1611
|
-
|
|
1611
|
+
i.includes(c) || r.push(c);
|
|
1612
1612
|
const o = [];
|
|
1613
|
-
for (const c of
|
|
1614
|
-
const
|
|
1613
|
+
for (const c of i) {
|
|
1614
|
+
const l = n[c], g = s.data[c];
|
|
1615
1615
|
o.push({
|
|
1616
1616
|
key: { status: "valid", value: c },
|
|
1617
|
-
value:
|
|
1617
|
+
value: l._parse(new E(s, g, s.path, c)),
|
|
1618
1618
|
alwaysSet: c in s.data
|
|
1619
1619
|
});
|
|
1620
1620
|
}
|
|
1621
|
-
if (this._def.catchall instanceof
|
|
1621
|
+
if (this._def.catchall instanceof $) {
|
|
1622
1622
|
const c = this._def.unknownKeys;
|
|
1623
1623
|
if (c === "passthrough")
|
|
1624
|
-
for (const
|
|
1624
|
+
for (const l of r)
|
|
1625
1625
|
o.push({
|
|
1626
|
-
key: { status: "valid", value:
|
|
1627
|
-
value: { status: "valid", value: s.data[
|
|
1626
|
+
key: { status: "valid", value: l },
|
|
1627
|
+
value: { status: "valid", value: s.data[l] }
|
|
1628
1628
|
});
|
|
1629
1629
|
else if (c === "strict")
|
|
1630
|
-
|
|
1630
|
+
r.length > 0 && (d(s, {
|
|
1631
1631
|
code: u.unrecognized_keys,
|
|
1632
|
-
keys:
|
|
1632
|
+
keys: r
|
|
1633
1633
|
}), t.dirty());
|
|
1634
1634
|
else if (c !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
1635
1635
|
} else {
|
|
1636
1636
|
const c = this._def.catchall;
|
|
1637
|
-
for (const
|
|
1638
|
-
const g = s.data[
|
|
1637
|
+
for (const l of r) {
|
|
1638
|
+
const g = s.data[l];
|
|
1639
1639
|
o.push({
|
|
1640
|
-
key: { status: "valid", value:
|
|
1640
|
+
key: { status: "valid", value: l },
|
|
1641
1641
|
value: c._parse(
|
|
1642
|
-
new
|
|
1642
|
+
new E(s, g, s.path, l)
|
|
1643
1643
|
//, ctx.child(key), value, getParsedType(value)
|
|
1644
1644
|
),
|
|
1645
|
-
alwaysSet:
|
|
1645
|
+
alwaysSet: l in s.data
|
|
1646
1646
|
});
|
|
1647
1647
|
}
|
|
1648
1648
|
}
|
|
1649
1649
|
return s.common.async ? Promise.resolve().then(async () => {
|
|
1650
1650
|
const c = [];
|
|
1651
|
-
for (const
|
|
1652
|
-
const g = await
|
|
1651
|
+
for (const l of o) {
|
|
1652
|
+
const g = await l.key, w = await l.value;
|
|
1653
1653
|
c.push({
|
|
1654
1654
|
key: g,
|
|
1655
1655
|
value: w,
|
|
1656
|
-
alwaysSet:
|
|
1656
|
+
alwaysSet: l.alwaysSet
|
|
1657
1657
|
});
|
|
1658
1658
|
}
|
|
1659
1659
|
return c;
|
|
1660
|
-
}).then((c) =>
|
|
1660
|
+
}).then((c) => S.mergeObjectSync(t, c)) : S.mergeObjectSync(t, o);
|
|
1661
1661
|
}
|
|
1662
1662
|
get shape() {
|
|
1663
1663
|
return this._def.shape();
|
|
1664
1664
|
}
|
|
1665
1665
|
strict(e) {
|
|
1666
|
-
return p.errToObj, new
|
|
1666
|
+
return p.errToObj, new T({
|
|
1667
1667
|
...this._def,
|
|
1668
1668
|
unknownKeys: "strict",
|
|
1669
1669
|
...e !== void 0 ? {
|
|
1670
1670
|
errorMap: (t, s) => {
|
|
1671
|
-
var n,
|
|
1672
|
-
const
|
|
1671
|
+
var n, i;
|
|
1672
|
+
const r = ((i = (n = this._def).errorMap) == null ? void 0 : i.call(n, t, s).message) ?? s.defaultError;
|
|
1673
1673
|
return t.code === "unrecognized_keys" ? {
|
|
1674
|
-
message: p.errToObj(e).message ??
|
|
1674
|
+
message: p.errToObj(e).message ?? r
|
|
1675
1675
|
} : {
|
|
1676
|
-
message:
|
|
1676
|
+
message: r
|
|
1677
1677
|
};
|
|
1678
1678
|
}
|
|
1679
1679
|
} : {}
|
|
1680
1680
|
});
|
|
1681
1681
|
}
|
|
1682
1682
|
strip() {
|
|
1683
|
-
return new
|
|
1683
|
+
return new T({
|
|
1684
1684
|
...this._def,
|
|
1685
1685
|
unknownKeys: "strip"
|
|
1686
1686
|
});
|
|
1687
1687
|
}
|
|
1688
1688
|
passthrough() {
|
|
1689
|
-
return new
|
|
1689
|
+
return new T({
|
|
1690
1690
|
...this._def,
|
|
1691
1691
|
unknownKeys: "passthrough"
|
|
1692
1692
|
});
|
|
@@ -1709,7 +1709,7 @@ let O = class N extends v {
|
|
|
1709
1709
|
// }) as any;
|
|
1710
1710
|
// };
|
|
1711
1711
|
extend(e) {
|
|
1712
|
-
return new
|
|
1712
|
+
return new T({
|
|
1713
1713
|
...this._def,
|
|
1714
1714
|
shape: () => ({
|
|
1715
1715
|
...this._def.shape(),
|
|
@@ -1723,7 +1723,7 @@ let O = class N extends v {
|
|
|
1723
1723
|
* upgrade if you are experiencing issues.
|
|
1724
1724
|
*/
|
|
1725
1725
|
merge(e) {
|
|
1726
|
-
return new
|
|
1726
|
+
return new T({
|
|
1727
1727
|
unknownKeys: e._def.unknownKeys,
|
|
1728
1728
|
catchall: e._def.catchall,
|
|
1729
1729
|
shape: () => ({
|
|
@@ -1793,7 +1793,7 @@ let O = class N extends v {
|
|
|
1793
1793
|
// return merged;
|
|
1794
1794
|
// }
|
|
1795
1795
|
catchall(e) {
|
|
1796
|
-
return new
|
|
1796
|
+
return new T({
|
|
1797
1797
|
...this._def,
|
|
1798
1798
|
catchall: e
|
|
1799
1799
|
});
|
|
@@ -1802,7 +1802,7 @@ let O = class N extends v {
|
|
|
1802
1802
|
const t = {};
|
|
1803
1803
|
for (const s of b.objectKeys(e))
|
|
1804
1804
|
e[s] && this.shape[s] && (t[s] = this.shape[s]);
|
|
1805
|
-
return new
|
|
1805
|
+
return new T({
|
|
1806
1806
|
...this._def,
|
|
1807
1807
|
shape: () => t
|
|
1808
1808
|
});
|
|
@@ -1811,7 +1811,7 @@ let O = class N extends v {
|
|
|
1811
1811
|
const t = {};
|
|
1812
1812
|
for (const s of b.objectKeys(this.shape))
|
|
1813
1813
|
e[s] || (t[s] = this.shape[s]);
|
|
1814
|
-
return new
|
|
1814
|
+
return new T({
|
|
1815
1815
|
...this._def,
|
|
1816
1816
|
shape: () => t
|
|
1817
1817
|
});
|
|
@@ -1820,7 +1820,7 @@ let O = class N extends v {
|
|
|
1820
1820
|
* @deprecated
|
|
1821
1821
|
*/
|
|
1822
1822
|
deepPartial() {
|
|
1823
|
-
return
|
|
1823
|
+
return q(this);
|
|
1824
1824
|
}
|
|
1825
1825
|
partial(e) {
|
|
1826
1826
|
const t = {};
|
|
@@ -1828,7 +1828,7 @@ let O = class N extends v {
|
|
|
1828
1828
|
const n = this.shape[s];
|
|
1829
1829
|
e && !e[s] ? t[s] = n : t[s] = n.optional();
|
|
1830
1830
|
}
|
|
1831
|
-
return new
|
|
1831
|
+
return new T({
|
|
1832
1832
|
...this._def,
|
|
1833
1833
|
shape: () => t
|
|
1834
1834
|
});
|
|
@@ -1840,59 +1840,59 @@ let O = class N extends v {
|
|
|
1840
1840
|
t[s] = this.shape[s];
|
|
1841
1841
|
else {
|
|
1842
1842
|
let n = this.shape[s];
|
|
1843
|
-
for (; n instanceof
|
|
1843
|
+
for (; n instanceof I; )
|
|
1844
1844
|
n = n._def.innerType;
|
|
1845
1845
|
t[s] = n;
|
|
1846
1846
|
}
|
|
1847
|
-
return new
|
|
1847
|
+
return new T({
|
|
1848
1848
|
...this._def,
|
|
1849
1849
|
shape: () => t
|
|
1850
1850
|
});
|
|
1851
1851
|
}
|
|
1852
1852
|
keyof() {
|
|
1853
|
-
return
|
|
1853
|
+
return Fe(b.objectKeys(this.shape));
|
|
1854
1854
|
}
|
|
1855
1855
|
};
|
|
1856
|
-
|
|
1856
|
+
Z.create = (a, e) => new Z({
|
|
1857
1857
|
shape: () => a,
|
|
1858
1858
|
unknownKeys: "strip",
|
|
1859
|
-
catchall:
|
|
1859
|
+
catchall: $.create(),
|
|
1860
1860
|
typeName: m.ZodObject,
|
|
1861
1861
|
...y(e)
|
|
1862
1862
|
});
|
|
1863
|
-
|
|
1863
|
+
Z.strictCreate = (a, e) => new Z({
|
|
1864
1864
|
shape: () => a,
|
|
1865
1865
|
unknownKeys: "strict",
|
|
1866
|
-
catchall:
|
|
1866
|
+
catchall: $.create(),
|
|
1867
1867
|
typeName: m.ZodObject,
|
|
1868
1868
|
...y(e)
|
|
1869
1869
|
});
|
|
1870
|
-
|
|
1870
|
+
Z.lazycreate = (a, e) => new Z({
|
|
1871
1871
|
shape: a,
|
|
1872
1872
|
unknownKeys: "strip",
|
|
1873
|
-
catchall:
|
|
1873
|
+
catchall: $.create(),
|
|
1874
1874
|
typeName: m.ZodObject,
|
|
1875
1875
|
...y(e)
|
|
1876
1876
|
});
|
|
1877
1877
|
let X = class extends v {
|
|
1878
1878
|
_parse(e) {
|
|
1879
1879
|
const { ctx: t } = this._processInputParams(e), s = this._def.options;
|
|
1880
|
-
function n(
|
|
1881
|
-
for (const o of
|
|
1880
|
+
function n(i) {
|
|
1881
|
+
for (const o of i)
|
|
1882
1882
|
if (o.result.status === "valid")
|
|
1883
1883
|
return o.result;
|
|
1884
|
-
for (const o of
|
|
1884
|
+
for (const o of i)
|
|
1885
1885
|
if (o.result.status === "dirty")
|
|
1886
1886
|
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1887
|
-
const
|
|
1887
|
+
const r = i.map((o) => new O(o.ctx.common.issues));
|
|
1888
1888
|
return d(t, {
|
|
1889
1889
|
code: u.invalid_union,
|
|
1890
|
-
unionErrors:
|
|
1890
|
+
unionErrors: r
|
|
1891
1891
|
}), _;
|
|
1892
1892
|
}
|
|
1893
1893
|
if (t.common.async)
|
|
1894
|
-
return Promise.all(s.map(async (
|
|
1895
|
-
const
|
|
1894
|
+
return Promise.all(s.map(async (i) => {
|
|
1895
|
+
const r = {
|
|
1896
1896
|
...t,
|
|
1897
1897
|
common: {
|
|
1898
1898
|
...t.common,
|
|
@@ -1901,19 +1901,19 @@ let X = class extends v {
|
|
|
1901
1901
|
parent: null
|
|
1902
1902
|
};
|
|
1903
1903
|
return {
|
|
1904
|
-
result: await
|
|
1904
|
+
result: await i._parseAsync({
|
|
1905
1905
|
data: t.data,
|
|
1906
1906
|
path: t.path,
|
|
1907
|
-
parent:
|
|
1907
|
+
parent: r
|
|
1908
1908
|
}),
|
|
1909
|
-
ctx:
|
|
1909
|
+
ctx: r
|
|
1910
1910
|
};
|
|
1911
1911
|
})).then(n);
|
|
1912
1912
|
{
|
|
1913
|
-
let
|
|
1914
|
-
const
|
|
1913
|
+
let i;
|
|
1914
|
+
const r = [];
|
|
1915
1915
|
for (const c of s) {
|
|
1916
|
-
const
|
|
1916
|
+
const l = {
|
|
1917
1917
|
...t,
|
|
1918
1918
|
common: {
|
|
1919
1919
|
...t.common,
|
|
@@ -1923,15 +1923,15 @@ let X = class extends v {
|
|
|
1923
1923
|
}, g = c._parseSync({
|
|
1924
1924
|
data: t.data,
|
|
1925
1925
|
path: t.path,
|
|
1926
|
-
parent:
|
|
1926
|
+
parent: l
|
|
1927
1927
|
});
|
|
1928
1928
|
if (g.status === "valid")
|
|
1929
1929
|
return g;
|
|
1930
|
-
g.status === "dirty" && !
|
|
1930
|
+
g.status === "dirty" && !i && (i = { result: g, ctx: l }), l.common.issues.length && r.push(l.common.issues);
|
|
1931
1931
|
}
|
|
1932
|
-
if (
|
|
1933
|
-
return t.common.issues.push(...
|
|
1934
|
-
const o =
|
|
1932
|
+
if (i)
|
|
1933
|
+
return t.common.issues.push(...i.ctx.common.issues), i.result;
|
|
1934
|
+
const o = r.map((c) => new O(c));
|
|
1935
1935
|
return d(t, {
|
|
1936
1936
|
code: u.invalid_union,
|
|
1937
1937
|
unionErrors: o
|
|
@@ -1947,39 +1947,39 @@ X.create = (a, e) => new X({
|
|
|
1947
1947
|
typeName: m.ZodUnion,
|
|
1948
1948
|
...y(e)
|
|
1949
1949
|
});
|
|
1950
|
-
function
|
|
1950
|
+
function ue(a, e) {
|
|
1951
1951
|
const t = A(a), s = A(e);
|
|
1952
1952
|
if (a === e)
|
|
1953
1953
|
return { valid: !0, data: a };
|
|
1954
|
-
if (t ===
|
|
1955
|
-
const n = b.objectKeys(e),
|
|
1956
|
-
for (const o of
|
|
1957
|
-
const c =
|
|
1954
|
+
if (t === h.object && s === h.object) {
|
|
1955
|
+
const n = b.objectKeys(e), i = b.objectKeys(a).filter((o) => n.indexOf(o) !== -1), r = { ...a, ...e };
|
|
1956
|
+
for (const o of i) {
|
|
1957
|
+
const c = ue(a[o], e[o]);
|
|
1958
1958
|
if (!c.valid)
|
|
1959
1959
|
return { valid: !1 };
|
|
1960
|
-
|
|
1960
|
+
r[o] = c.data;
|
|
1961
1961
|
}
|
|
1962
|
-
return { valid: !0, data:
|
|
1963
|
-
} else if (t ===
|
|
1962
|
+
return { valid: !0, data: r };
|
|
1963
|
+
} else if (t === h.array && s === h.array) {
|
|
1964
1964
|
if (a.length !== e.length)
|
|
1965
1965
|
return { valid: !1 };
|
|
1966
1966
|
const n = [];
|
|
1967
|
-
for (let
|
|
1968
|
-
const
|
|
1967
|
+
for (let i = 0; i < a.length; i++) {
|
|
1968
|
+
const r = a[i], o = e[i], c = ue(r, o);
|
|
1969
1969
|
if (!c.valid)
|
|
1970
1970
|
return { valid: !1 };
|
|
1971
1971
|
n.push(c.data);
|
|
1972
1972
|
}
|
|
1973
1973
|
return { valid: !0, data: n };
|
|
1974
|
-
} else return t ===
|
|
1974
|
+
} else return t === h.date && s === h.date && +a == +e ? { valid: !0, data: a } : { valid: !1 };
|
|
1975
1975
|
}
|
|
1976
1976
|
let ee = class extends v {
|
|
1977
1977
|
_parse(e) {
|
|
1978
|
-
const { status: t, ctx: s } = this._processInputParams(e), n = (
|
|
1979
|
-
if (
|
|
1978
|
+
const { status: t, ctx: s } = this._processInputParams(e), n = (i, r) => {
|
|
1979
|
+
if (ve(i) || ve(r))
|
|
1980
1980
|
return _;
|
|
1981
|
-
const o =
|
|
1982
|
-
return o.valid ? ((
|
|
1981
|
+
const o = ue(i.value, r.value);
|
|
1982
|
+
return o.valid ? ((be(i) || be(r)) && t.dirty(), { status: t.value, value: o.data }) : (d(s, {
|
|
1983
1983
|
code: u.invalid_intersection_types
|
|
1984
1984
|
}), _);
|
|
1985
1985
|
};
|
|
@@ -1994,7 +1994,7 @@ let ee = class extends v {
|
|
|
1994
1994
|
path: s.path,
|
|
1995
1995
|
parent: s
|
|
1996
1996
|
})
|
|
1997
|
-
]).then(([
|
|
1997
|
+
]).then(([i, r]) => n(i, r)) : n(this._def.left._parseSync({
|
|
1998
1998
|
data: s.data,
|
|
1999
1999
|
path: s.path,
|
|
2000
2000
|
parent: s
|
|
@@ -2011,13 +2011,13 @@ ee.create = (a, e, t) => new ee({
|
|
|
2011
2011
|
typeName: m.ZodIntersection,
|
|
2012
2012
|
...y(t)
|
|
2013
2013
|
});
|
|
2014
|
-
class
|
|
2014
|
+
class F extends v {
|
|
2015
2015
|
_parse(e) {
|
|
2016
2016
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2017
|
-
if (s.parsedType !==
|
|
2017
|
+
if (s.parsedType !== h.array)
|
|
2018
2018
|
return d(s, {
|
|
2019
2019
|
code: u.invalid_type,
|
|
2020
|
-
expected:
|
|
2020
|
+
expected: h.array,
|
|
2021
2021
|
received: s.parsedType
|
|
2022
2022
|
}), _;
|
|
2023
2023
|
if (s.data.length < this._def.items.length)
|
|
@@ -2035,33 +2035,33 @@ class q extends v {
|
|
|
2035
2035
|
exact: !1,
|
|
2036
2036
|
type: "array"
|
|
2037
2037
|
}), t.dirty());
|
|
2038
|
-
const n = [...s.data].map((
|
|
2039
|
-
const o = this._def.items[
|
|
2040
|
-
return o ? o._parse(new
|
|
2041
|
-
}).filter((
|
|
2042
|
-
return s.common.async ? Promise.all(n).then((
|
|
2038
|
+
const n = [...s.data].map((i, r) => {
|
|
2039
|
+
const o = this._def.items[r] || this._def.rest;
|
|
2040
|
+
return o ? o._parse(new E(s, i, s.path, r)) : null;
|
|
2041
|
+
}).filter((i) => !!i);
|
|
2042
|
+
return s.common.async ? Promise.all(n).then((i) => S.mergeArray(t, i)) : S.mergeArray(t, n);
|
|
2043
2043
|
}
|
|
2044
2044
|
get items() {
|
|
2045
2045
|
return this._def.items;
|
|
2046
2046
|
}
|
|
2047
2047
|
rest(e) {
|
|
2048
|
-
return new
|
|
2048
|
+
return new F({
|
|
2049
2049
|
...this._def,
|
|
2050
2050
|
rest: e
|
|
2051
2051
|
});
|
|
2052
2052
|
}
|
|
2053
2053
|
}
|
|
2054
|
-
|
|
2054
|
+
F.create = (a, e) => {
|
|
2055
2055
|
if (!Array.isArray(a))
|
|
2056
2056
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2057
|
-
return new
|
|
2057
|
+
return new F({
|
|
2058
2058
|
items: a,
|
|
2059
2059
|
typeName: m.ZodTuple,
|
|
2060
2060
|
rest: null,
|
|
2061
2061
|
...y(e)
|
|
2062
2062
|
});
|
|
2063
2063
|
};
|
|
2064
|
-
class
|
|
2064
|
+
class Ae extends v {
|
|
2065
2065
|
get keySchema() {
|
|
2066
2066
|
return this._def.keyType;
|
|
2067
2067
|
}
|
|
@@ -2070,40 +2070,40 @@ class Oe extends v {
|
|
|
2070
2070
|
}
|
|
2071
2071
|
_parse(e) {
|
|
2072
2072
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2073
|
-
if (s.parsedType !==
|
|
2073
|
+
if (s.parsedType !== h.map)
|
|
2074
2074
|
return d(s, {
|
|
2075
2075
|
code: u.invalid_type,
|
|
2076
|
-
expected:
|
|
2076
|
+
expected: h.map,
|
|
2077
2077
|
received: s.parsedType
|
|
2078
2078
|
}), _;
|
|
2079
|
-
const n = this._def.keyType,
|
|
2080
|
-
key: n._parse(new
|
|
2081
|
-
value:
|
|
2079
|
+
const n = this._def.keyType, i = this._def.valueType, r = [...s.data.entries()].map(([o, c], l) => ({
|
|
2080
|
+
key: n._parse(new E(s, o, s.path, [l, "key"])),
|
|
2081
|
+
value: i._parse(new E(s, c, s.path, [l, "value"]))
|
|
2082
2082
|
}));
|
|
2083
2083
|
if (s.common.async) {
|
|
2084
2084
|
const o = /* @__PURE__ */ new Map();
|
|
2085
2085
|
return Promise.resolve().then(async () => {
|
|
2086
|
-
for (const c of
|
|
2087
|
-
const
|
|
2088
|
-
if (
|
|
2086
|
+
for (const c of r) {
|
|
2087
|
+
const l = await c.key, g = await c.value;
|
|
2088
|
+
if (l.status === "aborted" || g.status === "aborted")
|
|
2089
2089
|
return _;
|
|
2090
|
-
(
|
|
2090
|
+
(l.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(l.value, g.value);
|
|
2091
2091
|
}
|
|
2092
2092
|
return { status: t.value, value: o };
|
|
2093
2093
|
});
|
|
2094
2094
|
} else {
|
|
2095
2095
|
const o = /* @__PURE__ */ new Map();
|
|
2096
|
-
for (const c of
|
|
2097
|
-
const
|
|
2098
|
-
if (
|
|
2096
|
+
for (const c of r) {
|
|
2097
|
+
const l = c.key, g = c.value;
|
|
2098
|
+
if (l.status === "aborted" || g.status === "aborted")
|
|
2099
2099
|
return _;
|
|
2100
|
-
(
|
|
2100
|
+
(l.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(l.value, g.value);
|
|
2101
2101
|
}
|
|
2102
2102
|
return { status: t.value, value: o };
|
|
2103
2103
|
}
|
|
2104
2104
|
}
|
|
2105
2105
|
}
|
|
2106
|
-
|
|
2106
|
+
Ae.create = (a, e, t) => new Ae({
|
|
2107
2107
|
valueType: e,
|
|
2108
2108
|
keyType: a,
|
|
2109
2109
|
typeName: m.ZodMap,
|
|
@@ -2112,10 +2112,10 @@ Oe.create = (a, e, t) => new Oe({
|
|
|
2112
2112
|
class K extends v {
|
|
2113
2113
|
_parse(e) {
|
|
2114
2114
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2115
|
-
if (s.parsedType !==
|
|
2115
|
+
if (s.parsedType !== h.set)
|
|
2116
2116
|
return d(s, {
|
|
2117
2117
|
code: u.invalid_type,
|
|
2118
|
-
expected:
|
|
2118
|
+
expected: h.set,
|
|
2119
2119
|
received: s.parsedType
|
|
2120
2120
|
}), _;
|
|
2121
2121
|
const n = this._def;
|
|
@@ -2134,18 +2134,18 @@ class K extends v {
|
|
|
2134
2134
|
exact: !1,
|
|
2135
2135
|
message: n.maxSize.message
|
|
2136
2136
|
}), t.dirty());
|
|
2137
|
-
const
|
|
2138
|
-
function
|
|
2139
|
-
const
|
|
2137
|
+
const i = this._def.valueType;
|
|
2138
|
+
function r(c) {
|
|
2139
|
+
const l = /* @__PURE__ */ new Set();
|
|
2140
2140
|
for (const g of c) {
|
|
2141
2141
|
if (g.status === "aborted")
|
|
2142
2142
|
return _;
|
|
2143
|
-
g.status === "dirty" && t.dirty(),
|
|
2143
|
+
g.status === "dirty" && t.dirty(), l.add(g.value);
|
|
2144
2144
|
}
|
|
2145
|
-
return { status: t.value, value:
|
|
2145
|
+
return { status: t.value, value: l };
|
|
2146
2146
|
}
|
|
2147
|
-
const o = [...s.data.values()].map((c,
|
|
2148
|
-
return s.common.async ? Promise.all(o).then((c) =>
|
|
2147
|
+
const o = [...s.data.values()].map((c, l) => i._parse(new E(s, c, s.path, l)));
|
|
2148
|
+
return s.common.async ? Promise.all(o).then((c) => r(c)) : r(o);
|
|
2149
2149
|
}
|
|
2150
2150
|
min(e, t) {
|
|
2151
2151
|
return new K({
|
|
@@ -2173,7 +2173,7 @@ K.create = (a, e) => new K({
|
|
|
2173
2173
|
typeName: m.ZodSet,
|
|
2174
2174
|
...y(e)
|
|
2175
2175
|
});
|
|
2176
|
-
class
|
|
2176
|
+
class Ie extends v {
|
|
2177
2177
|
get schema() {
|
|
2178
2178
|
return this._def.getter();
|
|
2179
2179
|
}
|
|
@@ -2182,12 +2182,12 @@ class Ae extends v {
|
|
|
2182
2182
|
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2183
2183
|
}
|
|
2184
2184
|
}
|
|
2185
|
-
|
|
2185
|
+
Ie.create = (a, e) => new Ie({
|
|
2186
2186
|
getter: a,
|
|
2187
2187
|
typeName: m.ZodLazy,
|
|
2188
2188
|
...y(e)
|
|
2189
2189
|
});
|
|
2190
|
-
let
|
|
2190
|
+
let de = class extends v {
|
|
2191
2191
|
_parse(e) {
|
|
2192
2192
|
if (e.data !== this._def.value) {
|
|
2193
2193
|
const t = this._getOrReturnCtx(e);
|
|
@@ -2203,19 +2203,19 @@ let ue = class extends v {
|
|
|
2203
2203
|
return this._def.value;
|
|
2204
2204
|
}
|
|
2205
2205
|
};
|
|
2206
|
-
|
|
2206
|
+
de.create = (a, e) => new de({
|
|
2207
2207
|
value: a,
|
|
2208
2208
|
typeName: m.ZodLiteral,
|
|
2209
2209
|
...y(e)
|
|
2210
2210
|
});
|
|
2211
|
-
function
|
|
2212
|
-
return new
|
|
2211
|
+
function Fe(a, e) {
|
|
2212
|
+
return new me({
|
|
2213
2213
|
values: a,
|
|
2214
2214
|
typeName: m.ZodEnum,
|
|
2215
2215
|
...y(e)
|
|
2216
2216
|
});
|
|
2217
2217
|
}
|
|
2218
|
-
let
|
|
2218
|
+
let me = class le extends v {
|
|
2219
2219
|
_parse(e) {
|
|
2220
2220
|
if (typeof e.data != "string") {
|
|
2221
2221
|
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
@@ -2233,7 +2233,7 @@ let fe = class de extends v {
|
|
|
2233
2233
|
options: s
|
|
2234
2234
|
}), _;
|
|
2235
2235
|
}
|
|
2236
|
-
return
|
|
2236
|
+
return C(e.data);
|
|
2237
2237
|
}
|
|
2238
2238
|
get options() {
|
|
2239
2239
|
return this._def.values;
|
|
@@ -2257,23 +2257,23 @@ let fe = class de extends v {
|
|
|
2257
2257
|
return e;
|
|
2258
2258
|
}
|
|
2259
2259
|
extract(e, t = this._def) {
|
|
2260
|
-
return
|
|
2260
|
+
return le.create(e, {
|
|
2261
2261
|
...this._def,
|
|
2262
2262
|
...t
|
|
2263
2263
|
});
|
|
2264
2264
|
}
|
|
2265
2265
|
exclude(e, t = this._def) {
|
|
2266
|
-
return
|
|
2266
|
+
return le.create(this.options.filter((s) => !e.includes(s)), {
|
|
2267
2267
|
...this._def,
|
|
2268
2268
|
...t
|
|
2269
2269
|
});
|
|
2270
2270
|
}
|
|
2271
2271
|
};
|
|
2272
|
-
|
|
2273
|
-
class
|
|
2272
|
+
me.create = Fe;
|
|
2273
|
+
class Ee extends v {
|
|
2274
2274
|
_parse(e) {
|
|
2275
2275
|
const t = b.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
2276
|
-
if (s.parsedType !==
|
|
2276
|
+
if (s.parsedType !== h.string && s.parsedType !== h.number) {
|
|
2277
2277
|
const n = b.objectValues(t);
|
|
2278
2278
|
return d(s, {
|
|
2279
2279
|
expected: b.joinValues(n),
|
|
@@ -2289,13 +2289,13 @@ class Ie extends v {
|
|
|
2289
2289
|
options: n
|
|
2290
2290
|
}), _;
|
|
2291
2291
|
}
|
|
2292
|
-
return
|
|
2292
|
+
return C(e.data);
|
|
2293
2293
|
}
|
|
2294
2294
|
get enum() {
|
|
2295
2295
|
return this._def.values;
|
|
2296
2296
|
}
|
|
2297
2297
|
}
|
|
2298
|
-
|
|
2298
|
+
Ee.create = (a, e) => new Ee({
|
|
2299
2299
|
values: a,
|
|
2300
2300
|
typeName: m.ZodNativeEnum,
|
|
2301
2301
|
...y(e)
|
|
@@ -2306,14 +2306,14 @@ let te = class extends v {
|
|
|
2306
2306
|
}
|
|
2307
2307
|
_parse(e) {
|
|
2308
2308
|
const { ctx: t } = this._processInputParams(e);
|
|
2309
|
-
if (t.parsedType !==
|
|
2309
|
+
if (t.parsedType !== h.promise && t.common.async === !1)
|
|
2310
2310
|
return d(t, {
|
|
2311
2311
|
code: u.invalid_type,
|
|
2312
|
-
expected:
|
|
2312
|
+
expected: h.promise,
|
|
2313
2313
|
received: t.parsedType
|
|
2314
2314
|
}), _;
|
|
2315
|
-
const s = t.parsedType ===
|
|
2316
|
-
return
|
|
2315
|
+
const s = t.parsedType === h.promise ? t.data : Promise.resolve(t.data);
|
|
2316
|
+
return C(s.then((n) => this._def.type.parseAsync(n, {
|
|
2317
2317
|
path: t.path,
|
|
2318
2318
|
errorMap: t.common.contextualErrorMap
|
|
2319
2319
|
})));
|
|
@@ -2324,7 +2324,7 @@ te.create = (a, e) => new te({
|
|
|
2324
2324
|
typeName: m.ZodPromise,
|
|
2325
2325
|
...y(e)
|
|
2326
2326
|
});
|
|
2327
|
-
|
|
2327
|
+
class L extends v {
|
|
2328
2328
|
innerType() {
|
|
2329
2329
|
return this._def.schema;
|
|
2330
2330
|
}
|
|
@@ -2332,18 +2332,18 @@ let D = class extends v {
|
|
|
2332
2332
|
return this._def.schema._def.typeName === m.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
2333
2333
|
}
|
|
2334
2334
|
_parse(e) {
|
|
2335
|
-
const { status: t, ctx: s } = this._processInputParams(e), n = this._def.effect || null,
|
|
2336
|
-
addIssue: (
|
|
2337
|
-
d(s,
|
|
2335
|
+
const { status: t, ctx: s } = this._processInputParams(e), n = this._def.effect || null, i = {
|
|
2336
|
+
addIssue: (r) => {
|
|
2337
|
+
d(s, r), r.fatal ? t.abort() : t.dirty();
|
|
2338
2338
|
},
|
|
2339
2339
|
get path() {
|
|
2340
2340
|
return s.path;
|
|
2341
2341
|
}
|
|
2342
2342
|
};
|
|
2343
|
-
if (
|
|
2344
|
-
const
|
|
2343
|
+
if (i.addIssue = i.addIssue.bind(i), n.type === "preprocess") {
|
|
2344
|
+
const r = n.transform(s.data, i);
|
|
2345
2345
|
if (s.common.async)
|
|
2346
|
-
return Promise.resolve(
|
|
2346
|
+
return Promise.resolve(r).then(async (o) => {
|
|
2347
2347
|
if (t.value === "aborted")
|
|
2348
2348
|
return _;
|
|
2349
2349
|
const c = await this._def.schema._parseAsync({
|
|
@@ -2351,22 +2351,22 @@ let D = class extends v {
|
|
|
2351
2351
|
path: s.path,
|
|
2352
2352
|
parent: s
|
|
2353
2353
|
});
|
|
2354
|
-
return c.status === "aborted" ? _ : c.status === "dirty" || t.value === "dirty" ?
|
|
2354
|
+
return c.status === "aborted" ? _ : c.status === "dirty" || t.value === "dirty" ? ie(c.value) : c;
|
|
2355
2355
|
});
|
|
2356
2356
|
{
|
|
2357
2357
|
if (t.value === "aborted")
|
|
2358
2358
|
return _;
|
|
2359
2359
|
const o = this._def.schema._parseSync({
|
|
2360
|
-
data:
|
|
2360
|
+
data: r,
|
|
2361
2361
|
path: s.path,
|
|
2362
2362
|
parent: s
|
|
2363
2363
|
});
|
|
2364
|
-
return o.status === "aborted" ? _ : o.status === "dirty" || t.value === "dirty" ?
|
|
2364
|
+
return o.status === "aborted" ? _ : o.status === "dirty" || t.value === "dirty" ? ie(o.value) : o;
|
|
2365
2365
|
}
|
|
2366
2366
|
}
|
|
2367
2367
|
if (n.type === "refinement") {
|
|
2368
|
-
const
|
|
2369
|
-
const c = n.refinement(o,
|
|
2368
|
+
const r = (o) => {
|
|
2369
|
+
const c = n.refinement(o, i);
|
|
2370
2370
|
if (s.common.async)
|
|
2371
2371
|
return Promise.resolve(c);
|
|
2372
2372
|
if (c instanceof Promise)
|
|
@@ -2379,74 +2379,74 @@ let D = class extends v {
|
|
|
2379
2379
|
path: s.path,
|
|
2380
2380
|
parent: s
|
|
2381
2381
|
});
|
|
2382
|
-
return o.status === "aborted" ? _ : (o.status === "dirty" && t.dirty(),
|
|
2382
|
+
return o.status === "aborted" ? _ : (o.status === "dirty" && t.dirty(), r(o.value), { status: t.value, value: o.value });
|
|
2383
2383
|
} else
|
|
2384
|
-
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? _ : (o.status === "dirty" && t.dirty(),
|
|
2384
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? _ : (o.status === "dirty" && t.dirty(), r(o.value).then(() => ({ status: t.value, value: o.value }))));
|
|
2385
2385
|
}
|
|
2386
2386
|
if (n.type === "transform")
|
|
2387
2387
|
if (s.common.async === !1) {
|
|
2388
|
-
const
|
|
2388
|
+
const r = this._def.schema._parseSync({
|
|
2389
2389
|
data: s.data,
|
|
2390
2390
|
path: s.path,
|
|
2391
2391
|
parent: s
|
|
2392
2392
|
});
|
|
2393
|
-
if (!
|
|
2393
|
+
if (!M(r))
|
|
2394
2394
|
return _;
|
|
2395
|
-
const o = n.transform(
|
|
2395
|
+
const o = n.transform(r.value, i);
|
|
2396
2396
|
if (o instanceof Promise)
|
|
2397
2397
|
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
2398
2398
|
return { status: t.value, value: o };
|
|
2399
2399
|
} else
|
|
2400
|
-
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((
|
|
2400
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((r) => M(r) ? Promise.resolve(n.transform(r.value, i)).then((o) => ({
|
|
2401
2401
|
status: t.value,
|
|
2402
2402
|
value: o
|
|
2403
2403
|
})) : _);
|
|
2404
2404
|
b.assertNever(n);
|
|
2405
2405
|
}
|
|
2406
|
-
}
|
|
2407
|
-
|
|
2406
|
+
}
|
|
2407
|
+
L.create = (a, e, t) => new L({
|
|
2408
2408
|
schema: a,
|
|
2409
2409
|
typeName: m.ZodEffects,
|
|
2410
2410
|
effect: e,
|
|
2411
2411
|
...y(t)
|
|
2412
2412
|
});
|
|
2413
|
-
|
|
2413
|
+
L.createWithPreprocess = (a, e, t) => new L({
|
|
2414
2414
|
schema: e,
|
|
2415
2415
|
effect: { type: "preprocess", transform: a },
|
|
2416
2416
|
typeName: m.ZodEffects,
|
|
2417
2417
|
...y(t)
|
|
2418
2418
|
});
|
|
2419
|
-
let
|
|
2419
|
+
let I = class extends v {
|
|
2420
2420
|
_parse(e) {
|
|
2421
|
-
return this._getType(e) ===
|
|
2421
|
+
return this._getType(e) === h.undefined ? C(void 0) : this._def.innerType._parse(e);
|
|
2422
2422
|
}
|
|
2423
2423
|
unwrap() {
|
|
2424
2424
|
return this._def.innerType;
|
|
2425
2425
|
}
|
|
2426
2426
|
};
|
|
2427
|
-
|
|
2427
|
+
I.create = (a, e) => new I({
|
|
2428
2428
|
innerType: a,
|
|
2429
2429
|
typeName: m.ZodOptional,
|
|
2430
2430
|
...y(e)
|
|
2431
2431
|
});
|
|
2432
|
-
let
|
|
2432
|
+
let D = class extends v {
|
|
2433
2433
|
_parse(e) {
|
|
2434
|
-
return this._getType(e) ===
|
|
2434
|
+
return this._getType(e) === h.null ? C(null) : this._def.innerType._parse(e);
|
|
2435
2435
|
}
|
|
2436
2436
|
unwrap() {
|
|
2437
2437
|
return this._def.innerType;
|
|
2438
2438
|
}
|
|
2439
2439
|
};
|
|
2440
|
-
|
|
2440
|
+
D.create = (a, e) => new D({
|
|
2441
2441
|
innerType: a,
|
|
2442
2442
|
typeName: m.ZodNullable,
|
|
2443
2443
|
...y(e)
|
|
2444
2444
|
});
|
|
2445
|
-
let
|
|
2445
|
+
let he = class extends v {
|
|
2446
2446
|
_parse(e) {
|
|
2447
2447
|
const { ctx: t } = this._processInputParams(e);
|
|
2448
2448
|
let s = t.data;
|
|
2449
|
-
return t.parsedType ===
|
|
2449
|
+
return t.parsedType === h.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
|
|
2450
2450
|
data: s,
|
|
2451
2451
|
path: t.path,
|
|
2452
2452
|
parent: t
|
|
@@ -2456,13 +2456,13 @@ let le = class extends v {
|
|
|
2456
2456
|
return this._def.innerType;
|
|
2457
2457
|
}
|
|
2458
2458
|
};
|
|
2459
|
-
|
|
2459
|
+
he.create = (a, e) => new he({
|
|
2460
2460
|
innerType: a,
|
|
2461
2461
|
typeName: m.ZodDefault,
|
|
2462
2462
|
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
2463
2463
|
...y(e)
|
|
2464
2464
|
});
|
|
2465
|
-
class
|
|
2465
|
+
class pe extends v {
|
|
2466
2466
|
_parse(e) {
|
|
2467
2467
|
const { ctx: t } = this._processInputParams(e), s = {
|
|
2468
2468
|
...t,
|
|
@@ -2477,11 +2477,11 @@ class he extends v {
|
|
|
2477
2477
|
...s
|
|
2478
2478
|
}
|
|
2479
2479
|
});
|
|
2480
|
-
return Y(n) ? n.then((
|
|
2480
|
+
return Y(n) ? n.then((i) => ({
|
|
2481
2481
|
status: "valid",
|
|
2482
|
-
value:
|
|
2482
|
+
value: i.status === "valid" ? i.value : this._def.catchValue({
|
|
2483
2483
|
get error() {
|
|
2484
|
-
return new
|
|
2484
|
+
return new O(s.common.issues);
|
|
2485
2485
|
},
|
|
2486
2486
|
input: s.data
|
|
2487
2487
|
})
|
|
@@ -2489,7 +2489,7 @@ class he extends v {
|
|
|
2489
2489
|
status: "valid",
|
|
2490
2490
|
value: n.status === "valid" ? n.value : this._def.catchValue({
|
|
2491
2491
|
get error() {
|
|
2492
|
-
return new
|
|
2492
|
+
return new O(s.common.issues);
|
|
2493
2493
|
},
|
|
2494
2494
|
input: s.data
|
|
2495
2495
|
})
|
|
@@ -2499,26 +2499,26 @@ class he extends v {
|
|
|
2499
2499
|
return this._def.innerType;
|
|
2500
2500
|
}
|
|
2501
2501
|
}
|
|
2502
|
-
|
|
2502
|
+
pe.create = (a, e) => new pe({
|
|
2503
2503
|
innerType: a,
|
|
2504
2504
|
typeName: m.ZodCatch,
|
|
2505
2505
|
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
2506
2506
|
...y(e)
|
|
2507
2507
|
});
|
|
2508
|
-
class
|
|
2508
|
+
class $e extends v {
|
|
2509
2509
|
_parse(e) {
|
|
2510
|
-
if (this._getType(e) !==
|
|
2510
|
+
if (this._getType(e) !== h.nan) {
|
|
2511
2511
|
const t = this._getOrReturnCtx(e);
|
|
2512
2512
|
return d(t, {
|
|
2513
2513
|
code: u.invalid_type,
|
|
2514
|
-
expected:
|
|
2514
|
+
expected: h.nan,
|
|
2515
2515
|
received: t.parsedType
|
|
2516
2516
|
}), _;
|
|
2517
2517
|
}
|
|
2518
2518
|
return { status: "valid", value: e.data };
|
|
2519
2519
|
}
|
|
2520
2520
|
}
|
|
2521
|
-
|
|
2521
|
+
$e.create = (a) => new $e({
|
|
2522
2522
|
typeName: m.ZodNaN,
|
|
2523
2523
|
...y(a)
|
|
2524
2524
|
});
|
|
@@ -2535,7 +2535,7 @@ class ut extends v {
|
|
|
2535
2535
|
return this._def.type;
|
|
2536
2536
|
}
|
|
2537
2537
|
}
|
|
2538
|
-
class
|
|
2538
|
+
class _e extends v {
|
|
2539
2539
|
_parse(e) {
|
|
2540
2540
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2541
2541
|
if (s.common.async)
|
|
@@ -2545,7 +2545,7 @@ class me extends v {
|
|
|
2545
2545
|
path: s.path,
|
|
2546
2546
|
parent: s
|
|
2547
2547
|
});
|
|
2548
|
-
return n.status === "aborted" ? _ : n.status === "dirty" ? (t.dirty(),
|
|
2548
|
+
return n.status === "aborted" ? _ : n.status === "dirty" ? (t.dirty(), ie(n.value)) : this._def.out._parseAsync({
|
|
2549
2549
|
data: n.value,
|
|
2550
2550
|
path: s.path,
|
|
2551
2551
|
parent: s
|
|
@@ -2568,23 +2568,23 @@ class me extends v {
|
|
|
2568
2568
|
}
|
|
2569
2569
|
}
|
|
2570
2570
|
static create(e, t) {
|
|
2571
|
-
return new
|
|
2571
|
+
return new _e({
|
|
2572
2572
|
in: e,
|
|
2573
2573
|
out: t,
|
|
2574
2574
|
typeName: m.ZodPipeline
|
|
2575
2575
|
});
|
|
2576
2576
|
}
|
|
2577
2577
|
}
|
|
2578
|
-
class
|
|
2578
|
+
class fe extends v {
|
|
2579
2579
|
_parse(e) {
|
|
2580
|
-
const t = this._def.innerType._parse(e), s = (n) => (
|
|
2580
|
+
const t = this._def.innerType._parse(e), s = (n) => (M(n) && (n.value = Object.freeze(n.value)), n);
|
|
2581
2581
|
return Y(t) ? t.then((n) => s(n)) : s(t);
|
|
2582
2582
|
}
|
|
2583
2583
|
unwrap() {
|
|
2584
2584
|
return this._def.innerType;
|
|
2585
2585
|
}
|
|
2586
2586
|
}
|
|
2587
|
-
|
|
2587
|
+
fe.create = (a, e) => new fe({
|
|
2588
2588
|
innerType: a,
|
|
2589
2589
|
typeName: m.ZodReadonly,
|
|
2590
2590
|
...y(e)
|
|
@@ -2593,19 +2593,19 @@ var m;
|
|
|
2593
2593
|
(function(a) {
|
|
2594
2594
|
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";
|
|
2595
2595
|
})(m || (m = {}));
|
|
2596
|
-
const dt =
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
const ht =
|
|
2596
|
+
const dt = re.create, lt = ce.create;
|
|
2597
|
+
$.create;
|
|
2598
|
+
N.create;
|
|
2599
|
+
const ht = Z.create;
|
|
2600
2600
|
X.create;
|
|
2601
2601
|
ee.create;
|
|
2602
|
-
|
|
2603
|
-
const pt =
|
|
2604
|
-
|
|
2602
|
+
F.create;
|
|
2603
|
+
const pt = de.create;
|
|
2604
|
+
me.create;
|
|
2605
2605
|
te.create;
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
const ft = "1.
|
|
2606
|
+
I.create;
|
|
2607
|
+
D.create;
|
|
2608
|
+
const ft = "1.13.1", mt = {
|
|
2609
2609
|
version: ft
|
|
2610
2610
|
};
|
|
2611
2611
|
class _t {
|
|
@@ -2856,36 +2856,36 @@ class wt {
|
|
|
2856
2856
|
referrer: e.referrer,
|
|
2857
2857
|
integrity: e.integrity
|
|
2858
2858
|
}));
|
|
2859
|
-
let
|
|
2859
|
+
let i = {};
|
|
2860
2860
|
t != null && t.headers && (t.headers instanceof Headers ? t.headers.forEach((g, w) => {
|
|
2861
|
-
|
|
2861
|
+
i[w] = g;
|
|
2862
2862
|
}) : Array.isArray(t.headers) ? t.headers.forEach(([g, w]) => {
|
|
2863
|
-
|
|
2864
|
-
}) :
|
|
2865
|
-
const
|
|
2863
|
+
i[g] = w;
|
|
2864
|
+
}) : i = t.headers);
|
|
2865
|
+
const r = await this._client.request("proxy.fetch", {
|
|
2866
2866
|
url: n,
|
|
2867
2867
|
method: (t == null ? void 0 : t.method) || "GET",
|
|
2868
|
-
headers:
|
|
2868
|
+
headers: i,
|
|
2869
2869
|
body: (s = t == null ? void 0 : t.body) !== null && s !== void 0 ? s : null
|
|
2870
2870
|
});
|
|
2871
|
-
if (!
|
|
2872
|
-
throw new TypeError(
|
|
2873
|
-
cause:
|
|
2871
|
+
if (!r.success)
|
|
2872
|
+
throw new TypeError(r.errorMessage, {
|
|
2873
|
+
cause: r.errorCause ? Error(r.errorCause) : void 0
|
|
2874
2874
|
});
|
|
2875
|
-
const o = new Headers(
|
|
2876
|
-
status:
|
|
2877
|
-
statusText:
|
|
2875
|
+
const o = new Headers(r.headers), c = {
|
|
2876
|
+
status: r.status,
|
|
2877
|
+
statusText: r.statusText,
|
|
2878
2878
|
headers: o
|
|
2879
2879
|
};
|
|
2880
|
-
let
|
|
2881
|
-
if (
|
|
2882
|
-
if (
|
|
2883
|
-
const g = atob(
|
|
2884
|
-
for (let
|
|
2885
|
-
w[
|
|
2886
|
-
|
|
2887
|
-
} else
|
|
2888
|
-
return new Response(
|
|
2880
|
+
let l = null;
|
|
2881
|
+
if (r.body !== null && r.body !== void 0)
|
|
2882
|
+
if (r.bodyType === "binary") {
|
|
2883
|
+
const g = atob(r.body), w = new Uint8Array(g.length);
|
|
2884
|
+
for (let x = 0; x < g.length; x++)
|
|
2885
|
+
w[x] = g.charCodeAt(x);
|
|
2886
|
+
l = w;
|
|
2887
|
+
} else r.bodyType === "text" ? l = r.body : r.bodyType === "json" && (l = JSON.stringify(r.body));
|
|
2888
|
+
return new Response(l, c);
|
|
2889
2889
|
}
|
|
2890
2890
|
}
|
|
2891
2891
|
class kt {
|
|
@@ -2902,7 +2902,7 @@ class kt {
|
|
|
2902
2902
|
* @returns A StoreSlice instance for the application scope
|
|
2903
2903
|
*/
|
|
2904
2904
|
get application() {
|
|
2905
|
-
return new W("application",
|
|
2905
|
+
return new W("application", void 0, this._client);
|
|
2906
2906
|
}
|
|
2907
2907
|
/**
|
|
2908
2908
|
* Provides access to the instance store scope.
|
|
@@ -2911,8 +2911,6 @@ class kt {
|
|
|
2911
2911
|
* application. This is ideal for instance-specific settings, UI state, temporary data,
|
|
2912
2912
|
* or any information that shouldn't be shared with other instances.
|
|
2913
2913
|
*
|
|
2914
|
-
* The namespace for instance data includes both the application name and the instance ID.
|
|
2915
|
-
*
|
|
2916
2914
|
* @returns A StoreSlice instance for the instance scope
|
|
2917
2915
|
*/
|
|
2918
2916
|
get instance() {
|
|
@@ -2931,7 +2929,7 @@ class kt {
|
|
|
2931
2929
|
* @returns A StoreSlice instance for the device scope
|
|
2932
2930
|
*/
|
|
2933
2931
|
get device() {
|
|
2934
|
-
return new W("device", this._client.
|
|
2932
|
+
return new W("device", this._client.deviceId, this._client);
|
|
2935
2933
|
}
|
|
2936
2934
|
/**
|
|
2937
2935
|
* Provides access to the shared store scope with a specified namespace.
|
|
@@ -3210,7 +3208,7 @@ class St {
|
|
|
3210
3208
|
return t;
|
|
3211
3209
|
}
|
|
3212
3210
|
}
|
|
3213
|
-
class
|
|
3211
|
+
class Ct {
|
|
3214
3212
|
constructor(e) {
|
|
3215
3213
|
this._client = e;
|
|
3216
3214
|
}
|
|
@@ -3251,13 +3249,13 @@ class Nt {
|
|
|
3251
3249
|
*/
|
|
3252
3250
|
async getRates(e) {
|
|
3253
3251
|
var t, s, n;
|
|
3254
|
-
const
|
|
3255
|
-
if (!
|
|
3256
|
-
throw ((t =
|
|
3257
|
-
return
|
|
3252
|
+
const i = await this._client.request("currency.getRates", e);
|
|
3253
|
+
if (!i.success || !i.rates)
|
|
3254
|
+
throw ((t = i.error) === null || t === void 0 ? void 0 : t.code) === 201 ? new Error(`Invalid base currency '${e.base}'`) : ((s = i.error) === null || s === void 0 ? void 0 : s.code) === 202 ? new Error(`Invalid target currency symbol '${e.symbols}'`) : new Error(((n = i.error) === null || n === void 0 ? void 0 : n.message) || "Failed to fetch currency rates");
|
|
3255
|
+
return i.rates;
|
|
3258
3256
|
}
|
|
3259
3257
|
}
|
|
3260
|
-
class
|
|
3258
|
+
class Tt {
|
|
3261
3259
|
constructor(e) {
|
|
3262
3260
|
this._client = e;
|
|
3263
3261
|
}
|
|
@@ -3321,10 +3319,30 @@ class Ct {
|
|
|
3321
3319
|
}, t)).success;
|
|
3322
3320
|
}
|
|
3323
3321
|
}
|
|
3322
|
+
class Nt {
|
|
3323
|
+
constructor(e) {
|
|
3324
|
+
this._originalPushState = null, this._originalReplaceState = null, this._popstateHandler = null, this._backHandler = null, this._forwardHandler = null, this._client = e;
|
|
3325
|
+
}
|
|
3326
|
+
bind() {
|
|
3327
|
+
typeof window > "u" || this._originalPushState || (this._originalPushState = history.pushState.bind(history), history.pushState = (...e) => {
|
|
3328
|
+
this._originalPushState(...e), this._sendLocationChanged();
|
|
3329
|
+
}, this._originalReplaceState = history.replaceState.bind(history), history.replaceState = (...e) => {
|
|
3330
|
+
this._originalReplaceState(...e), this._sendLocationChanged();
|
|
3331
|
+
}, this._popstateHandler = () => this._sendLocationChanged(), window.addEventListener("popstate", this._popstateHandler), this._backHandler = () => history.back(), this._forwardHandler = () => history.forward(), this._client.on("navigation.back", this._backHandler), this._client.on("navigation.forward", this._forwardHandler), this._sendLocationChanged());
|
|
3332
|
+
}
|
|
3333
|
+
unbind() {
|
|
3334
|
+
typeof window > "u" || (this._originalPushState && (history.pushState = this._originalPushState, this._originalPushState = null), this._originalReplaceState && (history.replaceState = this._originalReplaceState, this._originalReplaceState = null), this._popstateHandler && (window.removeEventListener("popstate", this._popstateHandler), this._popstateHandler = null), this._backHandler && (this._client.off("navigation.back", this._backHandler), this._backHandler = null), this._forwardHandler && (this._client.off("navigation.forward", this._forwardHandler), this._forwardHandler = null));
|
|
3335
|
+
}
|
|
3336
|
+
_sendLocationChanged() {
|
|
3337
|
+
this._client.send("navigation.locationChanged", {
|
|
3338
|
+
pathname: window.location.pathname
|
|
3339
|
+
});
|
|
3340
|
+
}
|
|
3341
|
+
}
|
|
3324
3342
|
function J(a) {
|
|
3325
3343
|
return { ...a, type: "client" };
|
|
3326
3344
|
}
|
|
3327
|
-
const
|
|
3345
|
+
const Ot = ht({
|
|
3328
3346
|
type: pt("bridge"),
|
|
3329
3347
|
name: dt(),
|
|
3330
3348
|
data: lt()
|
|
@@ -3353,9 +3371,9 @@ class Zt {
|
|
|
3353
3371
|
*/
|
|
3354
3372
|
async setRootSettingsNavigation(e) {
|
|
3355
3373
|
var t;
|
|
3356
|
-
const s = this._store.shared("root-settings-navigation"), n = (t = await s.get("navigation")) !== null && t !== void 0 ? t : {},
|
|
3357
|
-
n[
|
|
3358
|
-
applicationSpecifier:
|
|
3374
|
+
const s = this._store.shared("root-settings-navigation"), n = (t = await s.get("navigation")) !== null && t !== void 0 ? t : {}, i = this._store._client._applicationSpecifier;
|
|
3375
|
+
n[i] = {
|
|
3376
|
+
applicationSpecifier: i,
|
|
3359
3377
|
entries: e.entries
|
|
3360
3378
|
}, s.set("navigation", n);
|
|
3361
3379
|
}
|
|
@@ -3386,23 +3404,20 @@ class Zt {
|
|
|
3386
3404
|
return (e = await this._store.shared("root-settings-navigation").get("navigation")) !== null && e !== void 0 ? e : {};
|
|
3387
3405
|
}
|
|
3388
3406
|
}
|
|
3389
|
-
const
|
|
3390
|
-
function
|
|
3391
|
-
|
|
3407
|
+
const H = 1e3 * 30, ge = typeof window > "u" && typeof self < "u", B = ge ? self : window;
|
|
3408
|
+
function V(a) {
|
|
3409
|
+
ge ? self.postMessage(a) : B.parent.postMessage(a, "*");
|
|
3392
3410
|
}
|
|
3393
|
-
class
|
|
3411
|
+
class At {
|
|
3394
3412
|
/**
|
|
3395
3413
|
* Creates a new Client instance for communicating with the TelemetryOS platform.
|
|
3396
3414
|
*
|
|
3397
3415
|
* Note that creating a Client instance alone is not sufficient to begin communication.
|
|
3398
3416
|
* You must also call the bind() method to initialize event listeners and extract
|
|
3399
3417
|
* the application ID from the URL.
|
|
3400
|
-
*
|
|
3401
|
-
* @param applicationName The name of your application - must match the 'name' property
|
|
3402
|
-
* in your application's telemetry.config.json file
|
|
3403
3418
|
*/
|
|
3404
|
-
constructor(
|
|
3405
|
-
this.
|
|
3419
|
+
constructor() {
|
|
3420
|
+
this._applicationInstance = "", this._applicationSpecifier = "", this._deviceId = "", this._navigation = new Nt(this), this._messageInterceptors = /* @__PURE__ */ new Map(), this._onHandlers = /* @__PURE__ */ new Map(), this._onceHandlers = /* @__PURE__ */ new Map(), this._subscriptionNamesByHandler = /* @__PURE__ */ new Map(), this._subscriptionNamesBySubjectName = /* @__PURE__ */ new Map();
|
|
3406
3421
|
}
|
|
3407
3422
|
/**
|
|
3408
3423
|
* Provides access to the accounts API for retrieving TelemetryOS account information.
|
|
@@ -3548,7 +3563,7 @@ class Ot {
|
|
|
3548
3563
|
* @returns A Currency instance bound to this client
|
|
3549
3564
|
*/
|
|
3550
3565
|
get currency() {
|
|
3551
|
-
return new
|
|
3566
|
+
return new Ct(this);
|
|
3552
3567
|
}
|
|
3553
3568
|
/**
|
|
3554
3569
|
* Provides access to the environment API for accessing environment settings.
|
|
@@ -3565,10 +3580,7 @@ class Ot {
|
|
|
3565
3580
|
return new vt(this);
|
|
3566
3581
|
}
|
|
3567
3582
|
get mqtt() {
|
|
3568
|
-
return new
|
|
3569
|
-
}
|
|
3570
|
-
get applicationName() {
|
|
3571
|
-
return this._applicationName;
|
|
3583
|
+
return new Tt(this);
|
|
3572
3584
|
}
|
|
3573
3585
|
get applicationSpecifier() {
|
|
3574
3586
|
return this._applicationSpecifier;
|
|
@@ -3576,6 +3588,9 @@ class Ot {
|
|
|
3576
3588
|
get applicationInstance() {
|
|
3577
3589
|
return this._applicationInstance;
|
|
3578
3590
|
}
|
|
3591
|
+
get deviceId() {
|
|
3592
|
+
return this._deviceId;
|
|
3593
|
+
}
|
|
3579
3594
|
/**
|
|
3580
3595
|
* Initializes the client by setting up message listeners and extracting the application ID.
|
|
3581
3596
|
*
|
|
@@ -3592,47 +3607,47 @@ class Ot {
|
|
|
3592
3607
|
* of creating and binding their own Client instances.
|
|
3593
3608
|
*/
|
|
3594
3609
|
bind() {
|
|
3595
|
-
var e, t
|
|
3596
|
-
const
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
if (this._applicationSpecifier = (
|
|
3600
|
-
|
|
3601
|
-
|
|
3602
|
-
|
|
3603
|
-
if (!this._applicationSpecifier || this._applicationSpecifier.length !== 40)
|
|
3604
|
-
throw new Error(`Invalid applicationSpecifier: expected 40-character hash, got "${this._applicationSpecifier}"`);
|
|
3605
|
-
this._windowMessageHandler = (i) => {
|
|
3606
|
-
if (i.source === U || !i.data || typeof i.data != "object" || !("type" in i.data) || i.data.type !== "client" && i.data.type !== "bridge")
|
|
3610
|
+
var e, t;
|
|
3611
|
+
const s = new URL(B.location.href), n = s.searchParams;
|
|
3612
|
+
this._applicationInstance = n.get("applicationInstance") || "single", this._deviceId = n.get("deviceId") || this._applicationInstance;
|
|
3613
|
+
const i = s.hostname.split("."), r = /^[a-f0-9]{40}$/i;
|
|
3614
|
+
if (this._applicationSpecifier = (e = n.get("applicationSpecifier")) !== null && e !== void 0 ? e : "", (!this._applicationSpecifier || !r.test(this._applicationSpecifier)) && (this._applicationSpecifier = (t = i[0]) !== null && t !== void 0 ? t : ""), !this._applicationSpecifier || !r.test(this._applicationSpecifier))
|
|
3615
|
+
throw console.error("TelemetryOS apps require an applicationSpecifier in the URL query parameters or subdomain. Make sure your app is being served correctly through the TelemetryOS platform or development environment."), new Error(`Invalid applicationSpecifier: expected 40-character hash, got "${this._applicationSpecifier}"`);
|
|
3616
|
+
this._windowMessageHandler = (o) => {
|
|
3617
|
+
if (o.source === B || !o.data || typeof o.data != "object" || !("type" in o.data) || o.data.type !== "client" && o.data.type !== "bridge")
|
|
3607
3618
|
return;
|
|
3608
|
-
let
|
|
3609
|
-
if (
|
|
3610
|
-
const
|
|
3611
|
-
if (!
|
|
3612
|
-
|
|
3619
|
+
let c;
|
|
3620
|
+
if (o.data.type === "client") {
|
|
3621
|
+
const l = this._messageInterceptors.get(o.data.name);
|
|
3622
|
+
if (!l) {
|
|
3623
|
+
V(o.data);
|
|
3613
3624
|
return;
|
|
3614
3625
|
}
|
|
3615
|
-
|
|
3626
|
+
c = {
|
|
3627
|
+
...l(o.data.data),
|
|
3628
|
+
type: "bridge",
|
|
3629
|
+
...o.data.responseName ? { name: o.data.responseName } : {}
|
|
3630
|
+
};
|
|
3616
3631
|
}
|
|
3617
|
-
if (!
|
|
3618
|
-
const
|
|
3619
|
-
if (!
|
|
3632
|
+
if (!c) {
|
|
3633
|
+
const l = Ot.safeParse(o.data);
|
|
3634
|
+
if (!l.success)
|
|
3620
3635
|
return;
|
|
3621
|
-
|
|
3622
|
-
const
|
|
3623
|
-
if (
|
|
3624
|
-
for (const
|
|
3625
|
-
|
|
3626
|
-
if (
|
|
3627
|
-
for (const
|
|
3628
|
-
|
|
3629
|
-
this._onceHandlers.delete(
|
|
3636
|
+
c = l.data;
|
|
3637
|
+
const g = this._onHandlers.get(c.name), w = this._onceHandlers.get(c.name);
|
|
3638
|
+
if (g)
|
|
3639
|
+
for (const x of g)
|
|
3640
|
+
x(c.data);
|
|
3641
|
+
if (w) {
|
|
3642
|
+
for (const x of w)
|
|
3643
|
+
x(c.data);
|
|
3644
|
+
this._onceHandlers.delete(c.name);
|
|
3630
3645
|
}
|
|
3631
3646
|
}
|
|
3632
|
-
if (!
|
|
3633
|
-
for (let
|
|
3634
|
-
window.frames[
|
|
3635
|
-
},
|
|
3647
|
+
if (!ge)
|
|
3648
|
+
for (let l = 0; l < window.frames.length; l += 1)
|
|
3649
|
+
window.frames[l].postMessage(c, "*");
|
|
3650
|
+
}, B.addEventListener("message", this._windowMessageHandler), this._navigation.bind();
|
|
3636
3651
|
}
|
|
3637
3652
|
/**
|
|
3638
3653
|
* Removes the message event listener and cleans up resources.
|
|
@@ -3648,7 +3663,7 @@ class Ot {
|
|
|
3648
3663
|
* of managing their own Client instances.
|
|
3649
3664
|
*/
|
|
3650
3665
|
unbind() {
|
|
3651
|
-
this._windowMessageHandler &&
|
|
3666
|
+
this._windowMessageHandler && (this._navigation.unbind(), B.removeEventListener("message", this._windowMessageHandler));
|
|
3652
3667
|
}
|
|
3653
3668
|
/**
|
|
3654
3669
|
* Sends a one-way message to the TelemetryOS platform.
|
|
@@ -3666,13 +3681,12 @@ class Ot {
|
|
|
3666
3681
|
send(e, t) {
|
|
3667
3682
|
const s = J({
|
|
3668
3683
|
telemetrySdkVersion: G,
|
|
3669
|
-
applicationName: this._applicationName,
|
|
3670
3684
|
applicationSpecifier: this._applicationSpecifier,
|
|
3671
3685
|
applicationInstance: this._applicationInstance,
|
|
3672
3686
|
name: e,
|
|
3673
3687
|
data: t
|
|
3674
3688
|
});
|
|
3675
|
-
|
|
3689
|
+
V(s);
|
|
3676
3690
|
}
|
|
3677
3691
|
/**
|
|
3678
3692
|
* Sends a message to the TelemetryOS platform and waits for a response.
|
|
@@ -3695,100 +3709,97 @@ class Ot {
|
|
|
3695
3709
|
*/
|
|
3696
3710
|
request(e, t, s) {
|
|
3697
3711
|
var n;
|
|
3698
|
-
const
|
|
3712
|
+
const i = Q(), r = J({
|
|
3699
3713
|
telemetrySdkVersion: G,
|
|
3700
|
-
applicationName: this._applicationName,
|
|
3701
3714
|
applicationSpecifier: this._applicationSpecifier,
|
|
3702
3715
|
applicationInstance: this._applicationInstance,
|
|
3703
3716
|
name: e,
|
|
3704
3717
|
data: t,
|
|
3705
|
-
responseName:
|
|
3718
|
+
responseName: i
|
|
3706
3719
|
});
|
|
3707
|
-
|
|
3708
|
-
const o = (n = s == null ? void 0 : s.timeout) !== null && n !== void 0 ? n :
|
|
3709
|
-
let c = !1,
|
|
3710
|
-
const g = new Promise((
|
|
3711
|
-
|
|
3712
|
-
c ||
|
|
3713
|
-
}, this.once(
|
|
3720
|
+
V(r);
|
|
3721
|
+
const o = (n = s == null ? void 0 : s.timeout) !== null && n !== void 0 ? n : H;
|
|
3722
|
+
let c = !1, l;
|
|
3723
|
+
const g = new Promise((x) => {
|
|
3724
|
+
l = (j) => {
|
|
3725
|
+
c || x(j);
|
|
3726
|
+
}, this.once(i, l);
|
|
3714
3727
|
});
|
|
3715
3728
|
if (o === 0)
|
|
3716
3729
|
return g;
|
|
3717
|
-
const w = new Promise((
|
|
3718
|
-
const
|
|
3730
|
+
const w = new Promise((x, j) => {
|
|
3731
|
+
const P = new Error(`${e} message request with response name of ${i} timed out after ${o}`);
|
|
3719
3732
|
setTimeout(() => {
|
|
3720
|
-
c = !0, this.off(
|
|
3733
|
+
c = !0, this.off(i, l), j(P);
|
|
3721
3734
|
}, o);
|
|
3722
3735
|
});
|
|
3723
3736
|
return Promise.race([w, g]);
|
|
3724
3737
|
}
|
|
3725
3738
|
async subscribe(e, t, s) {
|
|
3726
|
-
let n,
|
|
3727
|
-
typeof t == "function" ?
|
|
3728
|
-
const
|
|
3739
|
+
let n, i;
|
|
3740
|
+
typeof t == "function" ? i = t : (n = t, i = s);
|
|
3741
|
+
const r = Q(), o = Q();
|
|
3729
3742
|
let c = this._subscriptionNamesBySubjectName.get(e);
|
|
3730
|
-
c || (c = [], this._subscriptionNamesBySubjectName.set(e, c)), c.push(
|
|
3731
|
-
const
|
|
3743
|
+
c || (c = [], this._subscriptionNamesBySubjectName.set(e, c)), c.push(r), this._subscriptionNamesByHandler.set(i, r), this.on(r, i);
|
|
3744
|
+
const l = J({
|
|
3732
3745
|
telemetrySdkVersion: G,
|
|
3733
|
-
applicationName: this._applicationName,
|
|
3734
3746
|
applicationSpecifier: this._applicationSpecifier,
|
|
3735
3747
|
applicationInstance: this._applicationInstance,
|
|
3736
3748
|
name: e,
|
|
3737
3749
|
data: n,
|
|
3738
3750
|
responseName: o,
|
|
3739
|
-
subscriptionName:
|
|
3751
|
+
subscriptionName: r
|
|
3740
3752
|
});
|
|
3741
|
-
|
|
3753
|
+
V(l);
|
|
3742
3754
|
let g = !1, w;
|
|
3743
|
-
const
|
|
3744
|
-
const se = new Error(`${e} subscribe request with subscription name of ${
|
|
3755
|
+
const x = new Promise((P, R) => {
|
|
3756
|
+
const se = new Error(`${e} subscribe request with subscription name of ${r} and response name of ${o} timed out after ${H}`);
|
|
3745
3757
|
setTimeout(() => {
|
|
3746
3758
|
g = !0, this.off(o, w), R(se);
|
|
3747
|
-
},
|
|
3748
|
-
}),
|
|
3759
|
+
}, H);
|
|
3760
|
+
}), j = new Promise((P) => {
|
|
3749
3761
|
w = (R) => {
|
|
3750
|
-
g ||
|
|
3762
|
+
g || P(R);
|
|
3751
3763
|
}, this.once(o, w);
|
|
3752
3764
|
});
|
|
3753
|
-
return Promise.race([
|
|
3765
|
+
return Promise.race([x, j]);
|
|
3754
3766
|
}
|
|
3755
3767
|
async unsubscribe(e, t, s) {
|
|
3756
|
-
let n,
|
|
3757
|
-
typeof t == "function" ?
|
|
3758
|
-
const
|
|
3768
|
+
let n, i;
|
|
3769
|
+
typeof t == "function" ? i = t : (n = t, i = s);
|
|
3770
|
+
const r = Q();
|
|
3759
3771
|
let o = [];
|
|
3760
|
-
if (
|
|
3761
|
-
const c = this._subscriptionNamesByHandler.get(
|
|
3772
|
+
if (i) {
|
|
3773
|
+
const c = this._subscriptionNamesByHandler.get(i);
|
|
3762
3774
|
if (!c)
|
|
3763
3775
|
return { success: !1 };
|
|
3764
|
-
o = [c], this._subscriptionNamesByHandler.delete(
|
|
3776
|
+
o = [c], this._subscriptionNamesByHandler.delete(i);
|
|
3765
3777
|
} else if (!this._subscriptionNamesBySubjectName.get(e))
|
|
3766
3778
|
return { success: !1 };
|
|
3767
3779
|
for await (const c of o) {
|
|
3768
|
-
this.off(c,
|
|
3769
|
-
const
|
|
3780
|
+
this.off(c, i);
|
|
3781
|
+
const l = J({
|
|
3770
3782
|
telemetrySdkVersion: G,
|
|
3771
3783
|
applicationInstance: this._applicationInstance,
|
|
3772
|
-
applicationName: this._applicationName,
|
|
3773
3784
|
applicationSpecifier: this._applicationSpecifier,
|
|
3774
3785
|
name: e,
|
|
3775
3786
|
data: n,
|
|
3776
|
-
responseName:
|
|
3787
|
+
responseName: r,
|
|
3777
3788
|
unsubscribeName: c
|
|
3778
3789
|
});
|
|
3779
|
-
|
|
3790
|
+
V(l);
|
|
3780
3791
|
let g = !1, w;
|
|
3781
|
-
const
|
|
3782
|
-
const se = new Error(`${e} unsubscribe request with unsubscribe name of ${c} and response name of ${
|
|
3792
|
+
const x = new Promise((P, R) => {
|
|
3793
|
+
const se = new Error(`${e} unsubscribe request with unsubscribe name of ${c} and response name of ${r} timed out after ${H}`);
|
|
3783
3794
|
setTimeout(() => {
|
|
3784
|
-
g = !0, this.off(
|
|
3785
|
-
},
|
|
3786
|
-
}),
|
|
3795
|
+
g = !0, this.off(r, w), R(se);
|
|
3796
|
+
}, H);
|
|
3797
|
+
}), j = new Promise((P) => {
|
|
3787
3798
|
w = (R) => {
|
|
3788
|
-
g ||
|
|
3789
|
-
}, this.once(
|
|
3799
|
+
g || P(R);
|
|
3800
|
+
}, this.once(r, w);
|
|
3790
3801
|
});
|
|
3791
|
-
if (!(await Promise.race([
|
|
3802
|
+
if (!(await Promise.race([x, j])).success)
|
|
3792
3803
|
return { success: !1 };
|
|
3793
3804
|
}
|
|
3794
3805
|
return { success: !0 };
|
|
@@ -3853,13 +3864,13 @@ class Ot {
|
|
|
3853
3864
|
const s = this._onHandlers.get(e), n = this._onceHandlers.get(e);
|
|
3854
3865
|
if (!(!s && !n)) {
|
|
3855
3866
|
if (s) {
|
|
3856
|
-
for (let
|
|
3857
|
-
t && s[
|
|
3867
|
+
for (let i = 0; i < s.length; i += 1)
|
|
3868
|
+
t && s[i] !== t || (s.splice(i, 1), i -= 1);
|
|
3858
3869
|
s.length === 0 && this._onHandlers.delete(e);
|
|
3859
3870
|
}
|
|
3860
3871
|
if (n) {
|
|
3861
|
-
for (let
|
|
3862
|
-
t && n[
|
|
3872
|
+
for (let i = 0; i < n.length; i += 1)
|
|
3873
|
+
t && n[i] !== t || (n.splice(i, 1), i -= 1);
|
|
3863
3874
|
n.length === 0 && this._onceHandlers.delete(e);
|
|
3864
3875
|
}
|
|
3865
3876
|
}
|
|
@@ -3869,7 +3880,7 @@ function Q() {
|
|
|
3869
3880
|
return Math.random().toString(36).slice(2, 9);
|
|
3870
3881
|
}
|
|
3871
3882
|
const G = mt.version;
|
|
3872
|
-
class
|
|
3883
|
+
class It {
|
|
3873
3884
|
constructor(e) {
|
|
3874
3885
|
this._client = e;
|
|
3875
3886
|
}
|
|
@@ -3918,7 +3929,7 @@ class At {
|
|
|
3918
3929
|
return !0;
|
|
3919
3930
|
}
|
|
3920
3931
|
}
|
|
3921
|
-
class
|
|
3932
|
+
class Et {
|
|
3922
3933
|
constructor(e) {
|
|
3923
3934
|
this._client = e;
|
|
3924
3935
|
}
|
|
@@ -3951,19 +3962,18 @@ class It {
|
|
|
3951
3962
|
/**
|
|
3952
3963
|
* Sets the display duration for the current page.
|
|
3953
3964
|
*
|
|
3954
|
-
*
|
|
3955
|
-
* the current page is displayed before advancing to the next page.
|
|
3965
|
+
* The timer starts from the moment of this call, not from page start.
|
|
3956
3966
|
*
|
|
3957
|
-
* @param duration The duration in
|
|
3967
|
+
* @param duration The duration in seconds
|
|
3958
3968
|
* @returns A promise that resolves to true if successful
|
|
3959
3969
|
* @example
|
|
3960
3970
|
* // Set page duration to 10 seconds
|
|
3961
|
-
* await playlist().setDuration(
|
|
3971
|
+
* await playlist().setDuration(10);
|
|
3962
3972
|
*
|
|
3963
3973
|
* @example
|
|
3964
3974
|
* // Extend duration based on content
|
|
3965
3975
|
* if (hasMoreContent) {
|
|
3966
|
-
* await playlist().setDuration(
|
|
3976
|
+
* await playlist().setDuration(30); // 30 seconds
|
|
3967
3977
|
* }
|
|
3968
3978
|
*/
|
|
3969
3979
|
async setDuration(e) {
|
|
@@ -3973,23 +3983,39 @@ class It {
|
|
|
3973
3983
|
throw new Error("Failed to set page duration");
|
|
3974
3984
|
return !0;
|
|
3975
3985
|
}
|
|
3986
|
+
/**
|
|
3987
|
+
* Gets the predefined page duration from the playlist.
|
|
3988
|
+
*
|
|
3989
|
+
* Returns the original page.duration as configured in the playlist,
|
|
3990
|
+
* not the remaining time or any value altered via setDuration.
|
|
3991
|
+
*
|
|
3992
|
+
* @returns A promise that resolves to { success: boolean, duration: number } in seconds, or 0 if undefined
|
|
3993
|
+
* @example
|
|
3994
|
+
* const { duration } = await playlist().getDuration();
|
|
3995
|
+
*/
|
|
3996
|
+
async getDuration() {
|
|
3997
|
+
const e = await this._client.request("playlist.getDuration", {});
|
|
3998
|
+
if (!e.success)
|
|
3999
|
+
throw new Error("Failed to get page duration");
|
|
4000
|
+
return { success: !0, duration: e.duration };
|
|
4001
|
+
}
|
|
3976
4002
|
}
|
|
3977
|
-
class
|
|
4003
|
+
class $t extends At {
|
|
3978
4004
|
get playlist() {
|
|
3979
|
-
return new
|
|
4005
|
+
return new Et(this);
|
|
3980
4006
|
}
|
|
3981
4007
|
get overrides() {
|
|
3982
|
-
return new
|
|
4008
|
+
return new It(this);
|
|
3983
4009
|
}
|
|
3984
4010
|
}
|
|
3985
4011
|
let f = null;
|
|
3986
|
-
function
|
|
4012
|
+
function zt() {
|
|
3987
4013
|
return f;
|
|
3988
4014
|
}
|
|
3989
|
-
function
|
|
3990
|
-
f = new
|
|
4015
|
+
function Bt(a) {
|
|
4016
|
+
f = new $t(), f.bind();
|
|
3991
4017
|
}
|
|
3992
|
-
function
|
|
4018
|
+
function Ut() {
|
|
3993
4019
|
f == null || f.unbind(), f = null;
|
|
3994
4020
|
}
|
|
3995
4021
|
function Kt(...a) {
|
|
@@ -4028,10 +4054,10 @@ function ns() {
|
|
|
4028
4054
|
function as() {
|
|
4029
4055
|
return k(f), f.users;
|
|
4030
4056
|
}
|
|
4031
|
-
function
|
|
4057
|
+
function is() {
|
|
4032
4058
|
return k(f), f.devices;
|
|
4033
4059
|
}
|
|
4034
|
-
function
|
|
4060
|
+
function rs() {
|
|
4035
4061
|
return k(f), f.proxy;
|
|
4036
4062
|
}
|
|
4037
4063
|
function os() {
|
|
@@ -4059,11 +4085,11 @@ function k(a) {
|
|
|
4059
4085
|
export {
|
|
4060
4086
|
_t as Accounts,
|
|
4061
4087
|
gt as Applications,
|
|
4062
|
-
|
|
4088
|
+
Ct as Currency,
|
|
4063
4089
|
yt as Devices,
|
|
4064
4090
|
vt as Environment,
|
|
4065
4091
|
bt as Media,
|
|
4066
|
-
|
|
4092
|
+
Tt as Mqtt,
|
|
4067
4093
|
wt as Proxy,
|
|
4068
4094
|
kt as Store,
|
|
4069
4095
|
W as StoreSlice,
|
|
@@ -4071,12 +4097,12 @@ export {
|
|
|
4071
4097
|
St as Weather,
|
|
4072
4098
|
ns as accounts,
|
|
4073
4099
|
ts as applications,
|
|
4074
|
-
|
|
4100
|
+
Bt as configure,
|
|
4075
4101
|
cs as currency,
|
|
4076
|
-
|
|
4077
|
-
|
|
4102
|
+
Ut as destroy,
|
|
4103
|
+
is as devices,
|
|
4078
4104
|
us as environment,
|
|
4079
|
-
|
|
4105
|
+
zt as globalClient,
|
|
4080
4106
|
ss as media,
|
|
4081
4107
|
hs as mqtt,
|
|
4082
4108
|
Jt as off,
|
|
@@ -4084,7 +4110,7 @@ export {
|
|
|
4084
4110
|
Wt as once,
|
|
4085
4111
|
ls as overrides,
|
|
4086
4112
|
ds as playlist,
|
|
4087
|
-
|
|
4113
|
+
rs as proxy,
|
|
4088
4114
|
Gt as request,
|
|
4089
4115
|
Qt as send,
|
|
4090
4116
|
es as store,
|