@telemetryos/sdk 1.9.0 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.js +1112 -1002
- package/dist/react/SettingsMediaSelect.d.ts +17 -0
- package/dist/react/hooks/store.d.ts +2 -0
- package/dist/react/index.d.ts +2 -1
- package/dist/react.cjs +97 -5
- package/dist/react.js +396 -265
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,48 +1,48 @@
|
|
|
1
1
|
var b;
|
|
2
|
-
(function(
|
|
3
|
-
|
|
2
|
+
(function(a) {
|
|
3
|
+
a.assertEqual = (n) => {
|
|
4
4
|
};
|
|
5
|
-
function e(
|
|
5
|
+
function e(n) {
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
function t(
|
|
7
|
+
a.assertIs = e;
|
|
8
|
+
function t(n) {
|
|
9
9
|
throw new Error();
|
|
10
10
|
}
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
for (const
|
|
14
|
-
i
|
|
15
|
-
return
|
|
16
|
-
},
|
|
17
|
-
const
|
|
18
|
-
for (const o of
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
},
|
|
22
|
-
return
|
|
23
|
-
}),
|
|
24
|
-
const
|
|
25
|
-
for (const
|
|
26
|
-
Object.prototype.hasOwnProperty.call(
|
|
27
|
-
return
|
|
28
|
-
},
|
|
29
|
-
for (const
|
|
30
|
-
if (i
|
|
31
|
-
return
|
|
32
|
-
},
|
|
33
|
-
function s(
|
|
34
|
-
return
|
|
35
|
-
}
|
|
36
|
-
|
|
11
|
+
a.assertNever = t, a.arrayToEnum = (n) => {
|
|
12
|
+
const r = {};
|
|
13
|
+
for (const i of n)
|
|
14
|
+
r[i] = i;
|
|
15
|
+
return r;
|
|
16
|
+
}, a.getValidEnumValues = (n) => {
|
|
17
|
+
const r = a.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), i = {};
|
|
18
|
+
for (const o of r)
|
|
19
|
+
i[o] = n[o];
|
|
20
|
+
return a.objectValues(i);
|
|
21
|
+
}, a.objectValues = (n) => a.objectKeys(n).map(function(r) {
|
|
22
|
+
return n[r];
|
|
23
|
+
}), a.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
|
|
24
|
+
const r = [];
|
|
25
|
+
for (const i in n)
|
|
26
|
+
Object.prototype.hasOwnProperty.call(n, i) && r.push(i);
|
|
27
|
+
return r;
|
|
28
|
+
}, a.find = (n, r) => {
|
|
29
|
+
for (const i of n)
|
|
30
|
+
if (r(i))
|
|
31
|
+
return i;
|
|
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, r = " | ") {
|
|
34
|
+
return n.map((i) => typeof i == "string" ? `'${i}'` : i).join(r);
|
|
35
|
+
}
|
|
36
|
+
a.joinValues = s, a.jsonStringifyReplacer = (n, r) => typeof r == "bigint" ? r.toString() : r;
|
|
37
37
|
})(b || (b = {}));
|
|
38
|
-
var
|
|
39
|
-
(function(
|
|
40
|
-
|
|
38
|
+
var ge;
|
|
39
|
+
(function(a) {
|
|
40
|
+
a.mergeShapes = (e, t) => ({
|
|
41
41
|
...e,
|
|
42
42
|
...t
|
|
43
43
|
// second overwrites first
|
|
44
44
|
});
|
|
45
|
-
})(
|
|
45
|
+
})(ge || (ge = {}));
|
|
46
46
|
const l = b.arrayToEnum([
|
|
47
47
|
"string",
|
|
48
48
|
"nan",
|
|
@@ -64,14 +64,14 @@ const l = b.arrayToEnum([
|
|
|
64
64
|
"never",
|
|
65
65
|
"map",
|
|
66
66
|
"set"
|
|
67
|
-
]),
|
|
68
|
-
switch (typeof
|
|
67
|
+
]), I = (a) => {
|
|
68
|
+
switch (typeof a) {
|
|
69
69
|
case "undefined":
|
|
70
70
|
return l.undefined;
|
|
71
71
|
case "string":
|
|
72
72
|
return l.string;
|
|
73
73
|
case "number":
|
|
74
|
-
return Number.isNaN(
|
|
74
|
+
return Number.isNaN(a) ? l.nan : l.number;
|
|
75
75
|
case "boolean":
|
|
76
76
|
return l.boolean;
|
|
77
77
|
case "function":
|
|
@@ -81,11 +81,11 @@ const l = b.arrayToEnum([
|
|
|
81
81
|
case "symbol":
|
|
82
82
|
return l.symbol;
|
|
83
83
|
case "object":
|
|
84
|
-
return Array.isArray(
|
|
84
|
+
return Array.isArray(a) ? l.array : a === null ? l.null : a.then && typeof a.then == "function" && a.catch && typeof a.catch == "function" ? l.promise : typeof Map < "u" && a instanceof Map ? l.map : typeof Set < "u" && a instanceof Set ? l.set : typeof Date < "u" && a instanceof Date ? l.date : l.object;
|
|
85
85
|
default:
|
|
86
86
|
return l.unknown;
|
|
87
87
|
}
|
|
88
|
-
},
|
|
88
|
+
}, u = b.arrayToEnum([
|
|
89
89
|
"invalid_type",
|
|
90
90
|
"invalid_literal",
|
|
91
91
|
"custom",
|
|
@@ -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 C 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: [] },
|
|
123
|
-
for (const
|
|
124
|
-
if (
|
|
125
|
-
|
|
126
|
-
else if (
|
|
127
|
-
|
|
128
|
-
else if (
|
|
129
|
-
|
|
130
|
-
else if (
|
|
131
|
-
s._errors.push(t(
|
|
120
|
+
const t = e || function(r) {
|
|
121
|
+
return r.message;
|
|
122
|
+
}, s = { _errors: [] }, n = (r) => {
|
|
123
|
+
for (const i of r.issues)
|
|
124
|
+
if (i.code === "invalid_union")
|
|
125
|
+
i.unionErrors.map(n);
|
|
126
|
+
else if (i.code === "invalid_return_type")
|
|
127
|
+
n(i.returnTypeError);
|
|
128
|
+
else if (i.code === "invalid_arguments")
|
|
129
|
+
n(i.argumentsError);
|
|
130
|
+
else if (i.path.length === 0)
|
|
131
|
+
s._errors.push(t(i));
|
|
132
132
|
else {
|
|
133
133
|
let o = s, c = 0;
|
|
134
|
-
for (; c <
|
|
135
|
-
const h =
|
|
136
|
-
c ===
|
|
134
|
+
for (; c < i.path.length; ) {
|
|
135
|
+
const h = i.path[c];
|
|
136
|
+
c === i.path.length - 1 ? (o[h] = o[h] || { _errors: [] }, o[h]._errors.push(t(i))) : o[h] = o[h] || { _errors: [] }, o = o[h], c++;
|
|
137
137
|
}
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
|
-
return
|
|
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() {
|
|
@@ -154,119 +154,119 @@ class C extends Error {
|
|
|
154
154
|
}
|
|
155
155
|
flatten(e = (t) => t.message) {
|
|
156
156
|
const t = {}, s = [];
|
|
157
|
-
for (const
|
|
158
|
-
if (
|
|
159
|
-
const
|
|
160
|
-
t[
|
|
157
|
+
for (const n of this.issues)
|
|
158
|
+
if (n.path.length > 0) {
|
|
159
|
+
const r = n.path[0];
|
|
160
|
+
t[r] = t[r] || [], t[r].push(e(n));
|
|
161
161
|
} else
|
|
162
|
-
s.push(e(
|
|
162
|
+
s.push(e(n));
|
|
163
163
|
return { formErrors: s, fieldErrors: t };
|
|
164
164
|
}
|
|
165
165
|
get formErrors() {
|
|
166
166
|
return this.flatten();
|
|
167
167
|
}
|
|
168
168
|
}
|
|
169
|
-
|
|
170
|
-
const
|
|
169
|
+
O.create = (a) => new O(a);
|
|
170
|
+
const ae = (a, e) => {
|
|
171
171
|
let t;
|
|
172
|
-
switch (
|
|
173
|
-
case
|
|
174
|
-
|
|
172
|
+
switch (a.code) {
|
|
173
|
+
case u.invalid_type:
|
|
174
|
+
a.received === l.undefined ? t = "Required" : t = `Expected ${a.expected}, received ${a.received}`;
|
|
175
175
|
break;
|
|
176
|
-
case
|
|
177
|
-
t = `Invalid literal value, expected ${JSON.stringify(
|
|
176
|
+
case u.invalid_literal:
|
|
177
|
+
t = `Invalid literal value, expected ${JSON.stringify(a.expected, b.jsonStringifyReplacer)}`;
|
|
178
178
|
break;
|
|
179
|
-
case
|
|
180
|
-
t = `Unrecognized key(s) in object: ${b.joinValues(
|
|
179
|
+
case u.unrecognized_keys:
|
|
180
|
+
t = `Unrecognized key(s) in object: ${b.joinValues(a.keys, ", ")}`;
|
|
181
181
|
break;
|
|
182
|
-
case
|
|
182
|
+
case u.invalid_union:
|
|
183
183
|
t = "Invalid input";
|
|
184
184
|
break;
|
|
185
|
-
case
|
|
186
|
-
t = `Invalid discriminator value. Expected ${b.joinValues(
|
|
185
|
+
case u.invalid_union_discriminator:
|
|
186
|
+
t = `Invalid discriminator value. Expected ${b.joinValues(a.options)}`;
|
|
187
187
|
break;
|
|
188
|
-
case
|
|
189
|
-
t = `Invalid enum value. Expected ${b.joinValues(
|
|
188
|
+
case u.invalid_enum_value:
|
|
189
|
+
t = `Invalid enum value. Expected ${b.joinValues(a.options)}, received '${a.received}'`;
|
|
190
190
|
break;
|
|
191
|
-
case
|
|
191
|
+
case u.invalid_arguments:
|
|
192
192
|
t = "Invalid function arguments";
|
|
193
193
|
break;
|
|
194
|
-
case
|
|
194
|
+
case u.invalid_return_type:
|
|
195
195
|
t = "Invalid function return type";
|
|
196
196
|
break;
|
|
197
|
-
case
|
|
197
|
+
case u.invalid_date:
|
|
198
198
|
t = "Invalid date";
|
|
199
199
|
break;
|
|
200
|
-
case
|
|
201
|
-
typeof
|
|
200
|
+
case u.invalid_string:
|
|
201
|
+
typeof a.validation == "object" ? "includes" in a.validation ? (t = `Invalid input: must include "${a.validation.includes}"`, typeof a.validation.position == "number" && (t = `${t} at one or more positions greater than or equal to ${a.validation.position}`)) : "startsWith" in a.validation ? t = `Invalid input: must start with "${a.validation.startsWith}"` : "endsWith" in a.validation ? t = `Invalid input: must end with "${a.validation.endsWith}"` : b.assertNever(a.validation) : a.validation !== "regex" ? t = `Invalid ${a.validation}` : t = "Invalid";
|
|
202
202
|
break;
|
|
203
|
-
case
|
|
204
|
-
|
|
203
|
+
case u.too_small:
|
|
204
|
+
a.type === "array" ? t = `Array must contain ${a.exact ? "exactly" : a.inclusive ? "at least" : "more than"} ${a.minimum} element(s)` : a.type === "string" ? t = `String must contain ${a.exact ? "exactly" : a.inclusive ? "at least" : "over"} ${a.minimum} character(s)` : a.type === "number" ? t = `Number must be ${a.exact ? "exactly equal to " : a.inclusive ? "greater than or equal to " : "greater than "}${a.minimum}` : a.type === "bigint" ? t = `Number must be ${a.exact ? "exactly equal to " : a.inclusive ? "greater than or equal to " : "greater than "}${a.minimum}` : a.type === "date" ? t = `Date must be ${a.exact ? "exactly equal to " : a.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(a.minimum))}` : t = "Invalid input";
|
|
205
205
|
break;
|
|
206
|
-
case
|
|
207
|
-
|
|
206
|
+
case u.too_big:
|
|
207
|
+
a.type === "array" ? t = `Array must contain ${a.exact ? "exactly" : a.inclusive ? "at most" : "less than"} ${a.maximum} element(s)` : a.type === "string" ? t = `String must contain ${a.exact ? "exactly" : a.inclusive ? "at most" : "under"} ${a.maximum} character(s)` : a.type === "number" ? t = `Number must be ${a.exact ? "exactly" : a.inclusive ? "less than or equal to" : "less than"} ${a.maximum}` : a.type === "bigint" ? t = `BigInt must be ${a.exact ? "exactly" : a.inclusive ? "less than or equal to" : "less than"} ${a.maximum}` : a.type === "date" ? t = `Date must be ${a.exact ? "exactly" : a.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(a.maximum))}` : t = "Invalid input";
|
|
208
208
|
break;
|
|
209
|
-
case
|
|
209
|
+
case u.custom:
|
|
210
210
|
t = "Invalid input";
|
|
211
211
|
break;
|
|
212
|
-
case
|
|
212
|
+
case u.invalid_intersection_types:
|
|
213
213
|
t = "Intersection results could not be merged";
|
|
214
214
|
break;
|
|
215
|
-
case
|
|
216
|
-
t = `Number must be a multiple of ${
|
|
215
|
+
case u.not_multiple_of:
|
|
216
|
+
t = `Number must be a multiple of ${a.multipleOf}`;
|
|
217
217
|
break;
|
|
218
|
-
case
|
|
218
|
+
case u.not_finite:
|
|
219
219
|
t = "Number must be finite";
|
|
220
220
|
break;
|
|
221
221
|
default:
|
|
222
|
-
t = e.defaultError, b.assertNever(
|
|
222
|
+
t = e.defaultError, b.assertNever(a);
|
|
223
223
|
}
|
|
224
224
|
return { message: t };
|
|
225
225
|
};
|
|
226
|
-
let
|
|
227
|
-
function
|
|
228
|
-
return
|
|
229
|
-
}
|
|
230
|
-
const
|
|
231
|
-
const { data: e, path: t, errorMaps: s, issueData:
|
|
232
|
-
...
|
|
233
|
-
path:
|
|
226
|
+
let qe = ae;
|
|
227
|
+
function Me() {
|
|
228
|
+
return qe;
|
|
229
|
+
}
|
|
230
|
+
const Le = (a) => {
|
|
231
|
+
const { data: e, path: t, errorMaps: s, issueData: n } = a, r = [...t, ...n.path || []], i = {
|
|
232
|
+
...n,
|
|
233
|
+
path: r
|
|
234
234
|
};
|
|
235
|
-
if (
|
|
235
|
+
if (n.message !== void 0)
|
|
236
236
|
return {
|
|
237
|
-
...
|
|
238
|
-
path:
|
|
239
|
-
message:
|
|
237
|
+
...n,
|
|
238
|
+
path: r,
|
|
239
|
+
message: n.message
|
|
240
240
|
};
|
|
241
241
|
let o = "";
|
|
242
242
|
const c = s.filter((h) => !!h).slice().reverse();
|
|
243
243
|
for (const h of c)
|
|
244
|
-
o = h(
|
|
244
|
+
o = h(i, { data: e, defaultError: o }).message;
|
|
245
245
|
return {
|
|
246
|
-
...
|
|
247
|
-
path:
|
|
246
|
+
...n,
|
|
247
|
+
path: r,
|
|
248
248
|
message: o
|
|
249
249
|
};
|
|
250
250
|
};
|
|
251
|
-
function
|
|
252
|
-
const t =
|
|
251
|
+
function d(a, e) {
|
|
252
|
+
const t = Me(), s = Le({
|
|
253
253
|
issueData: e,
|
|
254
|
-
data:
|
|
255
|
-
path:
|
|
254
|
+
data: a.data,
|
|
255
|
+
path: a.path,
|
|
256
256
|
errorMaps: [
|
|
257
|
-
|
|
257
|
+
a.common.contextualErrorMap,
|
|
258
258
|
// contextual error map is first priority
|
|
259
|
-
|
|
259
|
+
a.schemaErrorMap,
|
|
260
260
|
// then schema-bound map if available
|
|
261
261
|
t,
|
|
262
262
|
// then global override map
|
|
263
|
-
t ===
|
|
263
|
+
t === ae ? void 0 : ae
|
|
264
264
|
// then global default map
|
|
265
|
-
].filter((
|
|
265
|
+
].filter((n) => !!n)
|
|
266
266
|
});
|
|
267
|
-
|
|
267
|
+
a.common.issues.push(s);
|
|
268
268
|
}
|
|
269
|
-
let
|
|
269
|
+
let C = class $e {
|
|
270
270
|
constructor() {
|
|
271
271
|
this.value = "valid";
|
|
272
272
|
}
|
|
@@ -278,88 +278,88 @@ let N = class je {
|
|
|
278
278
|
}
|
|
279
279
|
static mergeArray(e, t) {
|
|
280
280
|
const s = [];
|
|
281
|
-
for (const
|
|
282
|
-
if (
|
|
283
|
-
return
|
|
284
|
-
|
|
281
|
+
for (const n of t) {
|
|
282
|
+
if (n.status === "aborted")
|
|
283
|
+
return _;
|
|
284
|
+
n.status === "dirty" && e.dirty(), s.push(n.value);
|
|
285
285
|
}
|
|
286
286
|
return { status: e.value, value: s };
|
|
287
287
|
}
|
|
288
288
|
static async mergeObjectAsync(e, t) {
|
|
289
289
|
const s = [];
|
|
290
|
-
for (const
|
|
291
|
-
const
|
|
290
|
+
for (const n of t) {
|
|
291
|
+
const r = await n.key, i = await n.value;
|
|
292
292
|
s.push({
|
|
293
|
-
key:
|
|
294
|
-
value:
|
|
293
|
+
key: r,
|
|
294
|
+
value: i
|
|
295
295
|
});
|
|
296
296
|
}
|
|
297
|
-
return
|
|
297
|
+
return $e.mergeObjectSync(e, s);
|
|
298
298
|
}
|
|
299
299
|
static mergeObjectSync(e, t) {
|
|
300
300
|
const s = {};
|
|
301
|
-
for (const
|
|
302
|
-
const { key:
|
|
303
|
-
if (
|
|
304
|
-
return
|
|
305
|
-
|
|
301
|
+
for (const n of t) {
|
|
302
|
+
const { key: r, value: i } = n;
|
|
303
|
+
if (r.status === "aborted" || i.status === "aborted")
|
|
304
|
+
return _;
|
|
305
|
+
r.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), r.value !== "__proto__" && (typeof i.value < "u" || n.alwaysSet) && (s[r.value] = i.value);
|
|
306
306
|
}
|
|
307
307
|
return { status: e.value, value: s };
|
|
308
308
|
}
|
|
309
309
|
};
|
|
310
|
-
const
|
|
310
|
+
const _ = Object.freeze({
|
|
311
311
|
status: "aborted"
|
|
312
|
-
}),
|
|
312
|
+
}), re = (a) => ({ status: "dirty", value: a }), x = (a) => ({ status: "valid", value: a }), ye = (a) => a.status === "aborted", ve = (a) => a.status === "dirty", L = (a) => a.status === "valid", Y = (a) => typeof Promise < "u" && a instanceof Promise;
|
|
313
313
|
var p;
|
|
314
|
-
(function(
|
|
315
|
-
|
|
314
|
+
(function(a) {
|
|
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
|
|
318
|
-
constructor(e, t, s,
|
|
319
|
-
this._cachedPath = [], this.parent = e, this.data = t, this._path = s, this._key =
|
|
317
|
+
let j = class {
|
|
318
|
+
constructor(e, t, s, n) {
|
|
319
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = s, this._key = n;
|
|
320
320
|
}
|
|
321
321
|
get path() {
|
|
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
|
|
325
|
+
const be = (a, e) => {
|
|
326
326
|
if (L(e))
|
|
327
327
|
return { success: !0, data: e.value };
|
|
328
|
-
if (!
|
|
328
|
+
if (!a.common.issues.length)
|
|
329
329
|
throw new Error("Validation failed but no issues detected.");
|
|
330
330
|
return {
|
|
331
331
|
success: !1,
|
|
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
|
};
|
|
339
339
|
};
|
|
340
|
-
function y(
|
|
341
|
-
if (!
|
|
340
|
+
function y(a) {
|
|
341
|
+
if (!a)
|
|
342
342
|
return {};
|
|
343
|
-
const { errorMap: e, invalid_type_error: t, required_error: s, description:
|
|
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:
|
|
347
|
-
const { message: o } =
|
|
348
|
-
return
|
|
349
|
-
}, description:
|
|
346
|
+
return e ? { errorMap: e, description: n } : { errorMap: (r, i) => {
|
|
347
|
+
const { message: o } = a;
|
|
348
|
+
return r.code === "invalid_enum_value" ? { message: o ?? i.defaultError } : typeof i.data > "u" ? { message: o ?? s ?? i.defaultError } : r.code !== "invalid_type" ? { message: i.defaultError } : { message: o ?? t ?? i.defaultError };
|
|
349
|
+
}, description: n };
|
|
350
350
|
}
|
|
351
351
|
let v = class {
|
|
352
352
|
get description() {
|
|
353
353
|
return this._def.description;
|
|
354
354
|
}
|
|
355
355
|
_getType(e) {
|
|
356
|
-
return
|
|
356
|
+
return I(e.data);
|
|
357
357
|
}
|
|
358
358
|
_getOrReturnCtx(e, t) {
|
|
359
359
|
return t || {
|
|
360
360
|
common: e.parent.common,
|
|
361
361
|
data: e.data,
|
|
362
|
-
parsedType:
|
|
362
|
+
parsedType: I(e.data),
|
|
363
363
|
schemaErrorMap: this._def.errorMap,
|
|
364
364
|
path: e.path,
|
|
365
365
|
parent: e.parent
|
|
@@ -367,11 +367,11 @@ let v = class {
|
|
|
367
367
|
}
|
|
368
368
|
_processInputParams(e) {
|
|
369
369
|
return {
|
|
370
|
-
status: new
|
|
370
|
+
status: new C(),
|
|
371
371
|
ctx: {
|
|
372
372
|
common: e.parent.common,
|
|
373
373
|
data: e.data,
|
|
374
|
-
parsedType:
|
|
374
|
+
parsedType: I(e.data),
|
|
375
375
|
schemaErrorMap: this._def.errorMap,
|
|
376
376
|
path: e.path,
|
|
377
377
|
parent: e.parent
|
|
@@ -380,7 +380,7 @@ let v = class {
|
|
|
380
380
|
}
|
|
381
381
|
_parseSync(e) {
|
|
382
382
|
const t = this._parse(e);
|
|
383
|
-
if (
|
|
383
|
+
if (Y(t))
|
|
384
384
|
throw new Error("Synchronous parse encountered promise.");
|
|
385
385
|
return t;
|
|
386
386
|
}
|
|
@@ -405,13 +405,13 @@ let v = class {
|
|
|
405
405
|
schemaErrorMap: this._def.errorMap,
|
|
406
406
|
parent: null,
|
|
407
407
|
data: e,
|
|
408
|
-
parsedType:
|
|
409
|
-
},
|
|
410
|
-
return
|
|
408
|
+
parsedType: I(e)
|
|
409
|
+
}, n = this._parseSync({ data: e, path: s.path, parent: s });
|
|
410
|
+
return be(s, n);
|
|
411
411
|
}
|
|
412
412
|
"~validate"(e) {
|
|
413
413
|
var t, s;
|
|
414
|
-
const
|
|
414
|
+
const n = {
|
|
415
415
|
common: {
|
|
416
416
|
issues: [],
|
|
417
417
|
async: !!this["~standard"].async
|
|
@@ -420,26 +420,26 @@ let v = class {
|
|
|
420
420
|
schemaErrorMap: this._def.errorMap,
|
|
421
421
|
parent: null,
|
|
422
422
|
data: e,
|
|
423
|
-
parsedType:
|
|
423
|
+
parsedType: I(e)
|
|
424
424
|
};
|
|
425
425
|
if (!this["~standard"].async)
|
|
426
426
|
try {
|
|
427
|
-
const
|
|
428
|
-
return L(
|
|
429
|
-
value:
|
|
427
|
+
const r = this._parseSync({ data: e, path: [], parent: n });
|
|
428
|
+
return L(r) ? {
|
|
429
|
+
value: r.value
|
|
430
430
|
} : {
|
|
431
|
-
issues:
|
|
431
|
+
issues: n.common.issues
|
|
432
432
|
};
|
|
433
|
-
} catch (
|
|
434
|
-
(s = (t =
|
|
433
|
+
} catch (r) {
|
|
434
|
+
(s = (t = r == null ? void 0 : r.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:
|
|
440
|
-
value:
|
|
439
|
+
return this._parseAsync({ data: e, path: [], parent: n }).then((r) => L(r) ? {
|
|
440
|
+
value: r.value
|
|
441
441
|
} : {
|
|
442
|
-
issues:
|
|
442
|
+
issues: n.common.issues
|
|
443
443
|
});
|
|
444
444
|
}
|
|
445
445
|
async parseAsync(e, t) {
|
|
@@ -459,22 +459,22 @@ let v = class {
|
|
|
459
459
|
schemaErrorMap: this._def.errorMap,
|
|
460
460
|
parent: null,
|
|
461
461
|
data: e,
|
|
462
|
-
parsedType:
|
|
463
|
-
},
|
|
464
|
-
return
|
|
462
|
+
parsedType: I(e)
|
|
463
|
+
}, n = this._parse({ data: e, path: s.path, parent: s }), r = await (Y(n) ? n : Promise.resolve(n));
|
|
464
|
+
return be(s, r);
|
|
465
465
|
}
|
|
466
466
|
refine(e, t) {
|
|
467
|
-
const s = (
|
|
468
|
-
return this._refinement((
|
|
469
|
-
const
|
|
470
|
-
code:
|
|
471
|
-
...s(
|
|
467
|
+
const s = (n) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(n) : t;
|
|
468
|
+
return this._refinement((n, r) => {
|
|
469
|
+
const i = e(n), o = () => r.addIssue({
|
|
470
|
+
code: u.custom,
|
|
471
|
+
...s(n)
|
|
472
472
|
});
|
|
473
|
-
return typeof Promise < "u" &&
|
|
473
|
+
return typeof Promise < "u" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
474
474
|
});
|
|
475
475
|
}
|
|
476
476
|
refinement(e, t) {
|
|
477
|
-
return this._refinement((s,
|
|
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
480
|
return new D({
|
|
@@ -494,7 +494,7 @@ let v = class {
|
|
|
494
494
|
};
|
|
495
495
|
}
|
|
496
496
|
optional() {
|
|
497
|
-
return
|
|
497
|
+
return $.create(this, this._def);
|
|
498
498
|
}
|
|
499
499
|
nullable() {
|
|
500
500
|
return V.create(this, this._def);
|
|
@@ -503,13 +503,13 @@ let v = class {
|
|
|
503
503
|
return this.nullable().optional();
|
|
504
504
|
}
|
|
505
505
|
array() {
|
|
506
|
-
return
|
|
506
|
+
return T.create(this);
|
|
507
507
|
}
|
|
508
508
|
promise() {
|
|
509
509
|
return te.create(this, this._def);
|
|
510
510
|
}
|
|
511
511
|
or(e) {
|
|
512
|
-
return
|
|
512
|
+
return X.create([this, e], this._def);
|
|
513
513
|
}
|
|
514
514
|
and(e) {
|
|
515
515
|
return ee.create(this, e, this._def);
|
|
@@ -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 le({
|
|
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 he({
|
|
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 me.create(this, e);
|
|
559
559
|
}
|
|
560
560
|
readonly() {
|
|
561
|
-
return
|
|
561
|
+
return pe.create(this);
|
|
562
562
|
}
|
|
563
563
|
isOptional() {
|
|
564
564
|
return this.safeParse(void 0).success;
|
|
@@ -567,206 +567,206 @@ let v = class {
|
|
|
567
567
|
return this.safeParse(null).success;
|
|
568
568
|
}
|
|
569
569
|
};
|
|
570
|
-
const
|
|
570
|
+
const De = /^c[^\s-]{8,}$/i, Ve = /^[0-9a-z]+$/, ze = /^[0-9A-HJKMNP-TV-Z]{26}$/i, Be = /^[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, Ue = /^[a-z0-9_-]{21}$/i, He = /^[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
|
-
const
|
|
573
|
-
function
|
|
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
|
+
function Pe(a) {
|
|
574
574
|
let e = "[0-5]\\d";
|
|
575
|
-
|
|
576
|
-
const t =
|
|
575
|
+
a.precision ? e = `${e}\\.\\d{${a.precision}}` : a.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
576
|
+
const t = a.precision ? "+" : "?";
|
|
577
577
|
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
|
|
578
578
|
}
|
|
579
|
-
function nt(
|
|
580
|
-
return new RegExp(`^${
|
|
579
|
+
function nt(a) {
|
|
580
|
+
return new RegExp(`^${Pe(a)}$`);
|
|
581
581
|
}
|
|
582
|
-
function
|
|
583
|
-
let e = `${
|
|
582
|
+
function at(a) {
|
|
583
|
+
let e = `${je}T${Pe(a)}`;
|
|
584
584
|
const t = [];
|
|
585
|
-
return t.push(
|
|
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
|
|
588
|
-
return !!((e === "v4" || !e) &&
|
|
587
|
+
function rt(a, e) {
|
|
588
|
+
return !!((e === "v4" || !e) && Qe.test(a) || (e === "v6" || !e) && Ye.test(a));
|
|
589
589
|
}
|
|
590
|
-
function
|
|
591
|
-
if (!
|
|
590
|
+
function it(a, e) {
|
|
591
|
+
if (!He.test(a))
|
|
592
592
|
return !1;
|
|
593
593
|
try {
|
|
594
|
-
const [t] =
|
|
594
|
+
const [t] = a.split(".");
|
|
595
595
|
if (!t)
|
|
596
596
|
return !1;
|
|
597
|
-
const s = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="),
|
|
598
|
-
return !(typeof
|
|
597
|
+
const s = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), n = JSON.parse(atob(s));
|
|
598
|
+
return !(typeof n != "object" || n === null || "typ" in n && (n == null ? void 0 : n.typ) !== "JWT" || !n.alg || e && n.alg !== e);
|
|
599
599
|
} catch {
|
|
600
600
|
return !1;
|
|
601
601
|
}
|
|
602
602
|
}
|
|
603
|
-
function
|
|
604
|
-
return !!((e === "v4" || !e) &&
|
|
603
|
+
function ot(a, e) {
|
|
604
|
+
return !!((e === "v4" || !e) && Ge.test(a) || (e === "v6" || !e) && Xe.test(a));
|
|
605
605
|
}
|
|
606
|
-
class
|
|
606
|
+
class E extends v {
|
|
607
607
|
_parse(e) {
|
|
608
608
|
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== l.string) {
|
|
609
|
-
const
|
|
610
|
-
return
|
|
611
|
-
code:
|
|
609
|
+
const n = this._getOrReturnCtx(e);
|
|
610
|
+
return d(n, {
|
|
611
|
+
code: u.invalid_type,
|
|
612
612
|
expected: l.string,
|
|
613
|
-
received:
|
|
614
|
-
}),
|
|
613
|
+
received: n.parsedType
|
|
614
|
+
}), _;
|
|
615
615
|
}
|
|
616
|
-
const t = new
|
|
616
|
+
const t = new C();
|
|
617
617
|
let s;
|
|
618
|
-
for (const
|
|
619
|
-
if (
|
|
620
|
-
e.data.length <
|
|
621
|
-
code:
|
|
622
|
-
minimum:
|
|
618
|
+
for (const n of this._def.checks)
|
|
619
|
+
if (n.kind === "min")
|
|
620
|
+
e.data.length < n.value && (s = this._getOrReturnCtx(e, s), d(s, {
|
|
621
|
+
code: u.too_small,
|
|
622
|
+
minimum: n.value,
|
|
623
623
|
type: "string",
|
|
624
624
|
inclusive: !0,
|
|
625
625
|
exact: !1,
|
|
626
|
-
message:
|
|
626
|
+
message: n.message
|
|
627
627
|
}), t.dirty());
|
|
628
|
-
else if (
|
|
629
|
-
e.data.length >
|
|
630
|
-
code:
|
|
631
|
-
maximum:
|
|
628
|
+
else if (n.kind === "max")
|
|
629
|
+
e.data.length > n.value && (s = this._getOrReturnCtx(e, s), d(s, {
|
|
630
|
+
code: u.too_big,
|
|
631
|
+
maximum: n.value,
|
|
632
632
|
type: "string",
|
|
633
633
|
inclusive: !0,
|
|
634
634
|
exact: !1,
|
|
635
|
-
message:
|
|
635
|
+
message: n.message
|
|
636
636
|
}), t.dirty());
|
|
637
|
-
else if (
|
|
638
|
-
const
|
|
639
|
-
(
|
|
640
|
-
code:
|
|
641
|
-
maximum:
|
|
637
|
+
else if (n.kind === "length") {
|
|
638
|
+
const r = e.data.length > n.value, i = e.data.length < n.value;
|
|
639
|
+
(r || i) && (s = this._getOrReturnCtx(e, s), r ? d(s, {
|
|
640
|
+
code: u.too_big,
|
|
641
|
+
maximum: n.value,
|
|
642
642
|
type: "string",
|
|
643
643
|
inclusive: !0,
|
|
644
644
|
exact: !0,
|
|
645
|
-
message:
|
|
646
|
-
}) :
|
|
647
|
-
code:
|
|
648
|
-
minimum:
|
|
645
|
+
message: n.message
|
|
646
|
+
}) : i && d(s, {
|
|
647
|
+
code: u.too_small,
|
|
648
|
+
minimum: n.value,
|
|
649
649
|
type: "string",
|
|
650
650
|
inclusive: !0,
|
|
651
651
|
exact: !0,
|
|
652
|
-
message:
|
|
652
|
+
message: n.message
|
|
653
653
|
}), t.dirty());
|
|
654
|
-
} else if (
|
|
655
|
-
|
|
654
|
+
} else if (n.kind === "email")
|
|
655
|
+
We.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
656
656
|
validation: "email",
|
|
657
|
-
code:
|
|
658
|
-
message:
|
|
657
|
+
code: u.invalid_string,
|
|
658
|
+
message: n.message
|
|
659
659
|
}), t.dirty());
|
|
660
|
-
else if (
|
|
661
|
-
ne || (ne = new RegExp(
|
|
660
|
+
else if (n.kind === "emoji")
|
|
661
|
+
ne || (ne = new RegExp(Je, "u")), ne.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
662
662
|
validation: "emoji",
|
|
663
|
-
code:
|
|
664
|
-
message:
|
|
663
|
+
code: u.invalid_string,
|
|
664
|
+
message: n.message
|
|
665
665
|
}), t.dirty());
|
|
666
|
-
else if (
|
|
667
|
-
|
|
666
|
+
else if (n.kind === "uuid")
|
|
667
|
+
Be.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
668
668
|
validation: "uuid",
|
|
669
|
-
code:
|
|
670
|
-
message:
|
|
669
|
+
code: u.invalid_string,
|
|
670
|
+
message: n.message
|
|
671
671
|
}), t.dirty());
|
|
672
|
-
else if (
|
|
673
|
-
|
|
672
|
+
else if (n.kind === "nanoid")
|
|
673
|
+
Ue.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
674
674
|
validation: "nanoid",
|
|
675
|
-
code:
|
|
676
|
-
message:
|
|
675
|
+
code: u.invalid_string,
|
|
676
|
+
message: n.message
|
|
677
677
|
}), t.dirty());
|
|
678
|
-
else if (
|
|
679
|
-
|
|
678
|
+
else if (n.kind === "cuid")
|
|
679
|
+
De.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
680
680
|
validation: "cuid",
|
|
681
|
-
code:
|
|
682
|
-
message:
|
|
681
|
+
code: u.invalid_string,
|
|
682
|
+
message: n.message
|
|
683
683
|
}), t.dirty());
|
|
684
|
-
else if (
|
|
685
|
-
|
|
684
|
+
else if (n.kind === "cuid2")
|
|
685
|
+
Ve.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
686
686
|
validation: "cuid2",
|
|
687
|
-
code:
|
|
688
|
-
message:
|
|
687
|
+
code: u.invalid_string,
|
|
688
|
+
message: n.message
|
|
689
689
|
}), t.dirty());
|
|
690
|
-
else if (
|
|
691
|
-
|
|
690
|
+
else if (n.kind === "ulid")
|
|
691
|
+
ze.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
692
692
|
validation: "ulid",
|
|
693
|
-
code:
|
|
694
|
-
message:
|
|
693
|
+
code: u.invalid_string,
|
|
694
|
+
message: n.message
|
|
695
695
|
}), t.dirty());
|
|
696
|
-
else if (
|
|
696
|
+
else if (n.kind === "url")
|
|
697
697
|
try {
|
|
698
698
|
new URL(e.data);
|
|
699
699
|
} catch {
|
|
700
|
-
s = this._getOrReturnCtx(e, s),
|
|
700
|
+
s = this._getOrReturnCtx(e, s), d(s, {
|
|
701
701
|
validation: "url",
|
|
702
|
-
code:
|
|
703
|
-
message:
|
|
702
|
+
code: u.invalid_string,
|
|
703
|
+
message: n.message
|
|
704
704
|
}), t.dirty();
|
|
705
705
|
}
|
|
706
|
-
else
|
|
706
|
+
else n.kind === "regex" ? (n.regex.lastIndex = 0, n.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
707
707
|
validation: "regex",
|
|
708
|
-
code:
|
|
709
|
-
message:
|
|
710
|
-
}), t.dirty())) :
|
|
711
|
-
code:
|
|
712
|
-
validation: { includes:
|
|
713
|
-
message:
|
|
714
|
-
}), t.dirty()) :
|
|
715
|
-
code:
|
|
716
|
-
validation: { startsWith:
|
|
717
|
-
message:
|
|
718
|
-
}), t.dirty()) :
|
|
719
|
-
code:
|
|
720
|
-
validation: { endsWith:
|
|
721
|
-
message:
|
|
722
|
-
}), t.dirty()) :
|
|
723
|
-
code:
|
|
708
|
+
code: u.invalid_string,
|
|
709
|
+
message: n.message
|
|
710
|
+
}), t.dirty())) : n.kind === "trim" ? e.data = e.data.trim() : n.kind === "includes" ? e.data.includes(n.value, n.position) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
711
|
+
code: u.invalid_string,
|
|
712
|
+
validation: { includes: n.value, position: n.position },
|
|
713
|
+
message: n.message
|
|
714
|
+
}), t.dirty()) : n.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : n.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : n.kind === "startsWith" ? e.data.startsWith(n.value) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
715
|
+
code: u.invalid_string,
|
|
716
|
+
validation: { startsWith: n.value },
|
|
717
|
+
message: n.message
|
|
718
|
+
}), t.dirty()) : n.kind === "endsWith" ? e.data.endsWith(n.value) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
719
|
+
code: u.invalid_string,
|
|
720
|
+
validation: { endsWith: n.value },
|
|
721
|
+
message: n.message
|
|
722
|
+
}), t.dirty()) : n.kind === "datetime" ? at(n).test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
723
|
+
code: u.invalid_string,
|
|
724
724
|
validation: "datetime",
|
|
725
|
-
message:
|
|
726
|
-
}), t.dirty()) :
|
|
727
|
-
code:
|
|
725
|
+
message: n.message
|
|
726
|
+
}), t.dirty()) : n.kind === "date" ? st.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
727
|
+
code: u.invalid_string,
|
|
728
728
|
validation: "date",
|
|
729
|
-
message:
|
|
730
|
-
}), t.dirty()) :
|
|
731
|
-
code:
|
|
729
|
+
message: n.message
|
|
730
|
+
}), t.dirty()) : n.kind === "time" ? nt(n).test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
731
|
+
code: u.invalid_string,
|
|
732
732
|
validation: "time",
|
|
733
|
-
message:
|
|
734
|
-
}), t.dirty()) :
|
|
733
|
+
message: n.message
|
|
734
|
+
}), t.dirty()) : n.kind === "duration" ? Ke.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
735
735
|
validation: "duration",
|
|
736
|
-
code:
|
|
737
|
-
message:
|
|
738
|
-
}), t.dirty()) :
|
|
736
|
+
code: u.invalid_string,
|
|
737
|
+
message: n.message
|
|
738
|
+
}), t.dirty()) : n.kind === "ip" ? rt(e.data, n.version) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
739
739
|
validation: "ip",
|
|
740
|
-
code:
|
|
741
|
-
message:
|
|
742
|
-
}), t.dirty()) :
|
|
740
|
+
code: u.invalid_string,
|
|
741
|
+
message: n.message
|
|
742
|
+
}), t.dirty()) : n.kind === "jwt" ? it(e.data, n.alg) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
743
743
|
validation: "jwt",
|
|
744
|
-
code:
|
|
745
|
-
message:
|
|
746
|
-
}), t.dirty()) :
|
|
744
|
+
code: u.invalid_string,
|
|
745
|
+
message: n.message
|
|
746
|
+
}), t.dirty()) : n.kind === "cidr" ? ot(e.data, n.version) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
747
747
|
validation: "cidr",
|
|
748
|
-
code:
|
|
749
|
-
message:
|
|
750
|
-
}), t.dirty()) :
|
|
748
|
+
code: u.invalid_string,
|
|
749
|
+
message: n.message
|
|
750
|
+
}), t.dirty()) : n.kind === "base64" ? et.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
751
751
|
validation: "base64",
|
|
752
|
-
code:
|
|
753
|
-
message:
|
|
754
|
-
}), t.dirty()) :
|
|
752
|
+
code: u.invalid_string,
|
|
753
|
+
message: n.message
|
|
754
|
+
}), t.dirty()) : n.kind === "base64url" ? tt.test(e.data) || (s = this._getOrReturnCtx(e, s), d(s, {
|
|
755
755
|
validation: "base64url",
|
|
756
|
-
code:
|
|
757
|
-
message:
|
|
758
|
-
}), t.dirty()) : b.assertNever(
|
|
756
|
+
code: u.invalid_string,
|
|
757
|
+
message: n.message
|
|
758
|
+
}), t.dirty()) : b.assertNever(n);
|
|
759
759
|
return { status: t.value, value: e.data };
|
|
760
760
|
}
|
|
761
761
|
_regex(e, t, s) {
|
|
762
|
-
return this.refinement((
|
|
762
|
+
return this.refinement((n) => e.test(n), {
|
|
763
763
|
validation: t,
|
|
764
|
-
code:
|
|
764
|
+
code: u.invalid_string,
|
|
765
765
|
...p.errToObj(s)
|
|
766
766
|
});
|
|
767
767
|
}
|
|
768
768
|
_addCheck(e) {
|
|
769
|
-
return new
|
|
769
|
+
return new E({
|
|
770
770
|
...this._def,
|
|
771
771
|
checks: [...this._def.checks, e]
|
|
772
772
|
});
|
|
@@ -902,19 +902,19 @@ class A extends v {
|
|
|
902
902
|
return this.min(1, p.errToObj(e));
|
|
903
903
|
}
|
|
904
904
|
trim() {
|
|
905
|
-
return new
|
|
905
|
+
return new E({
|
|
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 E({
|
|
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 E({
|
|
918
918
|
...this._def,
|
|
919
919
|
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
920
920
|
});
|
|
@@ -980,59 +980,59 @@ class A extends v {
|
|
|
980
980
|
return e;
|
|
981
981
|
}
|
|
982
982
|
}
|
|
983
|
-
|
|
983
|
+
E.create = (a) => new E({
|
|
984
984
|
checks: [],
|
|
985
985
|
typeName: m.ZodString,
|
|
986
|
-
coerce: (
|
|
987
|
-
...y(
|
|
986
|
+
coerce: (a == null ? void 0 : a.coerce) ?? !1,
|
|
987
|
+
...y(a)
|
|
988
988
|
});
|
|
989
|
-
function
|
|
990
|
-
const t = (
|
|
991
|
-
return
|
|
989
|
+
function ct(a, e) {
|
|
990
|
+
const t = (a.toString().split(".")[1] || "").length, s = (e.toString().split(".")[1] || "").length, n = t > s ? t : s, r = Number.parseInt(a.toFixed(n).replace(".", "")), i = Number.parseInt(e.toFixed(n).replace(".", ""));
|
|
991
|
+
return r % i / 10 ** n;
|
|
992
992
|
}
|
|
993
|
-
let
|
|
993
|
+
let we = class ie 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
998
|
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== l.number) {
|
|
999
|
-
const
|
|
1000
|
-
return
|
|
1001
|
-
code:
|
|
999
|
+
const n = this._getOrReturnCtx(e);
|
|
1000
|
+
return d(n, {
|
|
1001
|
+
code: u.invalid_type,
|
|
1002
1002
|
expected: l.number,
|
|
1003
|
-
received:
|
|
1004
|
-
}),
|
|
1003
|
+
received: n.parsedType
|
|
1004
|
+
}), _;
|
|
1005
1005
|
}
|
|
1006
1006
|
let t;
|
|
1007
|
-
const s = new
|
|
1008
|
-
for (const
|
|
1009
|
-
|
|
1010
|
-
code:
|
|
1007
|
+
const s = new C();
|
|
1008
|
+
for (const n of this._def.checks)
|
|
1009
|
+
n.kind === "int" ? b.isInteger(e.data) || (t = this._getOrReturnCtx(e, t), d(t, {
|
|
1010
|
+
code: u.invalid_type,
|
|
1011
1011
|
expected: "integer",
|
|
1012
1012
|
received: "float",
|
|
1013
|
-
message:
|
|
1014
|
-
}), s.dirty()) :
|
|
1015
|
-
code:
|
|
1016
|
-
minimum:
|
|
1013
|
+
message: n.message
|
|
1014
|
+
}), s.dirty()) : n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (t = this._getOrReturnCtx(e, t), d(t, {
|
|
1015
|
+
code: u.too_small,
|
|
1016
|
+
minimum: n.value,
|
|
1017
1017
|
type: "number",
|
|
1018
|
-
inclusive:
|
|
1018
|
+
inclusive: n.inclusive,
|
|
1019
1019
|
exact: !1,
|
|
1020
|
-
message:
|
|
1021
|
-
}), s.dirty()) :
|
|
1022
|
-
code:
|
|
1023
|
-
maximum:
|
|
1020
|
+
message: n.message
|
|
1021
|
+
}), s.dirty()) : n.kind === "max" ? (n.inclusive ? e.data > n.value : e.data >= n.value) && (t = this._getOrReturnCtx(e, t), d(t, {
|
|
1022
|
+
code: u.too_big,
|
|
1023
|
+
maximum: n.value,
|
|
1024
1024
|
type: "number",
|
|
1025
|
-
inclusive:
|
|
1025
|
+
inclusive: n.inclusive,
|
|
1026
1026
|
exact: !1,
|
|
1027
|
-
message:
|
|
1028
|
-
}), s.dirty()) :
|
|
1029
|
-
code:
|
|
1030
|
-
multipleOf:
|
|
1031
|
-
message:
|
|
1032
|
-
}), s.dirty()) :
|
|
1033
|
-
code:
|
|
1034
|
-
message:
|
|
1035
|
-
}), s.dirty()) : b.assertNever(
|
|
1027
|
+
message: n.message
|
|
1028
|
+
}), s.dirty()) : n.kind === "multipleOf" ? ct(e.data, n.value) !== 0 && (t = this._getOrReturnCtx(e, t), d(t, {
|
|
1029
|
+
code: u.not_multiple_of,
|
|
1030
|
+
multipleOf: n.value,
|
|
1031
|
+
message: n.message
|
|
1032
|
+
}), s.dirty()) : n.kind === "finite" ? Number.isFinite(e.data) || (t = this._getOrReturnCtx(e, t), d(t, {
|
|
1033
|
+
code: u.not_finite,
|
|
1034
|
+
message: n.message
|
|
1035
|
+
}), s.dirty()) : b.assertNever(n);
|
|
1036
1036
|
return { status: s.value, value: e.data };
|
|
1037
1037
|
}
|
|
1038
1038
|
gte(e, t) {
|
|
@@ -1047,8 +1047,8 @@ let ke = class oe extends v {
|
|
|
1047
1047
|
lt(e, t) {
|
|
1048
1048
|
return this.setLimit("max", e, !1, p.toString(t));
|
|
1049
1049
|
}
|
|
1050
|
-
setLimit(e, t, s,
|
|
1051
|
-
return new
|
|
1050
|
+
setLimit(e, t, s, n) {
|
|
1051
|
+
return new ie({
|
|
1052
1052
|
...this._def,
|
|
1053
1053
|
checks: [
|
|
1054
1054
|
...this._def.checks,
|
|
@@ -1056,13 +1056,13 @@ let ke = class oe extends v {
|
|
|
1056
1056
|
kind: e,
|
|
1057
1057
|
value: t,
|
|
1058
1058
|
inclusive: s,
|
|
1059
|
-
message: p.toString(
|
|
1059
|
+
message: p.toString(n)
|
|
1060
1060
|
}
|
|
1061
1061
|
]
|
|
1062
1062
|
});
|
|
1063
1063
|
}
|
|
1064
1064
|
_addCheck(e) {
|
|
1065
|
-
return new
|
|
1065
|
+
return new ie({
|
|
1066
1066
|
...this._def,
|
|
1067
1067
|
checks: [...this._def.checks, e]
|
|
1068
1068
|
});
|
|
@@ -1156,13 +1156,13 @@ let ke = class oe extends v {
|
|
|
1156
1156
|
return Number.isFinite(t) && Number.isFinite(e);
|
|
1157
1157
|
}
|
|
1158
1158
|
};
|
|
1159
|
-
|
|
1159
|
+
we.create = (a) => new we({
|
|
1160
1160
|
checks: [],
|
|
1161
1161
|
typeName: m.ZodNumber,
|
|
1162
|
-
coerce: (
|
|
1163
|
-
...y(
|
|
1162
|
+
coerce: (a == null ? void 0 : a.coerce) || !1,
|
|
1163
|
+
...y(a)
|
|
1164
1164
|
});
|
|
1165
|
-
class
|
|
1165
|
+
class H extends v {
|
|
1166
1166
|
constructor() {
|
|
1167
1167
|
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1168
1168
|
}
|
|
@@ -1176,34 +1176,34 @@ class U extends v {
|
|
|
1176
1176
|
if (this._getType(e) !== l.bigint)
|
|
1177
1177
|
return this._getInvalidInput(e);
|
|
1178
1178
|
let t;
|
|
1179
|
-
const s = new
|
|
1180
|
-
for (const
|
|
1181
|
-
|
|
1182
|
-
code:
|
|
1179
|
+
const s = new C();
|
|
1180
|
+
for (const n of this._def.checks)
|
|
1181
|
+
n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (t = this._getOrReturnCtx(e, t), d(t, {
|
|
1182
|
+
code: u.too_small,
|
|
1183
1183
|
type: "bigint",
|
|
1184
|
-
minimum:
|
|
1185
|
-
inclusive:
|
|
1186
|
-
message:
|
|
1187
|
-
}), s.dirty()) :
|
|
1188
|
-
code:
|
|
1184
|
+
minimum: n.value,
|
|
1185
|
+
inclusive: n.inclusive,
|
|
1186
|
+
message: n.message
|
|
1187
|
+
}), s.dirty()) : n.kind === "max" ? (n.inclusive ? e.data > n.value : e.data >= n.value) && (t = this._getOrReturnCtx(e, t), d(t, {
|
|
1188
|
+
code: u.too_big,
|
|
1189
1189
|
type: "bigint",
|
|
1190
|
-
maximum:
|
|
1191
|
-
inclusive:
|
|
1192
|
-
message:
|
|
1193
|
-
}), s.dirty()) :
|
|
1194
|
-
code:
|
|
1195
|
-
multipleOf:
|
|
1196
|
-
message:
|
|
1197
|
-
}), s.dirty()) : b.assertNever(
|
|
1190
|
+
maximum: n.value,
|
|
1191
|
+
inclusive: n.inclusive,
|
|
1192
|
+
message: n.message
|
|
1193
|
+
}), s.dirty()) : n.kind === "multipleOf" ? e.data % n.value !== BigInt(0) && (t = this._getOrReturnCtx(e, t), d(t, {
|
|
1194
|
+
code: u.not_multiple_of,
|
|
1195
|
+
multipleOf: n.value,
|
|
1196
|
+
message: n.message
|
|
1197
|
+
}), s.dirty()) : b.assertNever(n);
|
|
1198
1198
|
return { status: s.value, value: e.data };
|
|
1199
1199
|
}
|
|
1200
1200
|
_getInvalidInput(e) {
|
|
1201
1201
|
const t = this._getOrReturnCtx(e);
|
|
1202
|
-
return
|
|
1203
|
-
code:
|
|
1202
|
+
return d(t, {
|
|
1203
|
+
code: u.invalid_type,
|
|
1204
1204
|
expected: l.bigint,
|
|
1205
1205
|
received: t.parsedType
|
|
1206
|
-
}),
|
|
1206
|
+
}), _;
|
|
1207
1207
|
}
|
|
1208
1208
|
gte(e, t) {
|
|
1209
1209
|
return this.setLimit("min", e, !0, p.toString(t));
|
|
@@ -1217,8 +1217,8 @@ class U extends v {
|
|
|
1217
1217
|
lt(e, t) {
|
|
1218
1218
|
return this.setLimit("max", e, !1, p.toString(t));
|
|
1219
1219
|
}
|
|
1220
|
-
setLimit(e, t, s,
|
|
1221
|
-
return new
|
|
1220
|
+
setLimit(e, t, s, n) {
|
|
1221
|
+
return new H({
|
|
1222
1222
|
...this._def,
|
|
1223
1223
|
checks: [
|
|
1224
1224
|
...this._def.checks,
|
|
@@ -1226,13 +1226,13 @@ class U extends v {
|
|
|
1226
1226
|
kind: e,
|
|
1227
1227
|
value: t,
|
|
1228
1228
|
inclusive: s,
|
|
1229
|
-
message: p.toString(
|
|
1229
|
+
message: p.toString(n)
|
|
1230
1230
|
}
|
|
1231
1231
|
]
|
|
1232
1232
|
});
|
|
1233
1233
|
}
|
|
1234
1234
|
_addCheck(e) {
|
|
1235
|
-
return new
|
|
1235
|
+
return new H({
|
|
1236
1236
|
...this._def,
|
|
1237
1237
|
checks: [...this._def.checks, e]
|
|
1238
1238
|
});
|
|
@@ -1289,64 +1289,64 @@ class U extends v {
|
|
|
1289
1289
|
return e;
|
|
1290
1290
|
}
|
|
1291
1291
|
}
|
|
1292
|
-
|
|
1292
|
+
H.create = (a) => new H({
|
|
1293
1293
|
checks: [],
|
|
1294
1294
|
typeName: m.ZodBigInt,
|
|
1295
|
-
coerce: (
|
|
1296
|
-
...y(
|
|
1295
|
+
coerce: (a == null ? void 0 : a.coerce) ?? !1,
|
|
1296
|
+
...y(a)
|
|
1297
1297
|
});
|
|
1298
|
-
class
|
|
1298
|
+
class ke extends v {
|
|
1299
1299
|
_parse(e) {
|
|
1300
1300
|
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== l.boolean) {
|
|
1301
1301
|
const t = this._getOrReturnCtx(e);
|
|
1302
|
-
return
|
|
1303
|
-
code:
|
|
1302
|
+
return d(t, {
|
|
1303
|
+
code: u.invalid_type,
|
|
1304
1304
|
expected: l.boolean,
|
|
1305
1305
|
received: t.parsedType
|
|
1306
|
-
}),
|
|
1306
|
+
}), _;
|
|
1307
1307
|
}
|
|
1308
1308
|
return x(e.data);
|
|
1309
1309
|
}
|
|
1310
1310
|
}
|
|
1311
|
-
|
|
1311
|
+
ke.create = (a) => new ke({
|
|
1312
1312
|
typeName: m.ZodBoolean,
|
|
1313
|
-
coerce: (
|
|
1314
|
-
...y(
|
|
1313
|
+
coerce: (a == null ? void 0 : a.coerce) || !1,
|
|
1314
|
+
...y(a)
|
|
1315
1315
|
});
|
|
1316
|
-
let
|
|
1316
|
+
let xe = class Fe extends v {
|
|
1317
1317
|
_parse(e) {
|
|
1318
1318
|
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== l.date) {
|
|
1319
|
-
const
|
|
1320
|
-
return
|
|
1321
|
-
code:
|
|
1319
|
+
const n = this._getOrReturnCtx(e);
|
|
1320
|
+
return d(n, {
|
|
1321
|
+
code: u.invalid_type,
|
|
1322
1322
|
expected: l.date,
|
|
1323
|
-
received:
|
|
1324
|
-
}),
|
|
1323
|
+
received: n.parsedType
|
|
1324
|
+
}), _;
|
|
1325
1325
|
}
|
|
1326
1326
|
if (Number.isNaN(e.data.getTime())) {
|
|
1327
|
-
const
|
|
1328
|
-
return
|
|
1329
|
-
code:
|
|
1330
|
-
}),
|
|
1327
|
+
const n = this._getOrReturnCtx(e);
|
|
1328
|
+
return d(n, {
|
|
1329
|
+
code: u.invalid_date
|
|
1330
|
+
}), _;
|
|
1331
1331
|
}
|
|
1332
|
-
const t = new
|
|
1332
|
+
const t = new C();
|
|
1333
1333
|
let s;
|
|
1334
|
-
for (const
|
|
1335
|
-
|
|
1336
|
-
code:
|
|
1337
|
-
message:
|
|
1334
|
+
for (const n of this._def.checks)
|
|
1335
|
+
n.kind === "min" ? e.data.getTime() < n.value && (s = this._getOrReturnCtx(e, s), d(s, {
|
|
1336
|
+
code: u.too_small,
|
|
1337
|
+
message: n.message,
|
|
1338
1338
|
inclusive: !0,
|
|
1339
1339
|
exact: !1,
|
|
1340
|
-
minimum:
|
|
1340
|
+
minimum: n.value,
|
|
1341
1341
|
type: "date"
|
|
1342
|
-
}), t.dirty()) :
|
|
1343
|
-
code:
|
|
1344
|
-
message:
|
|
1342
|
+
}), t.dirty()) : n.kind === "max" ? e.data.getTime() > n.value && (s = this._getOrReturnCtx(e, s), d(s, {
|
|
1343
|
+
code: u.too_big,
|
|
1344
|
+
message: n.message,
|
|
1345
1345
|
inclusive: !0,
|
|
1346
1346
|
exact: !1,
|
|
1347
|
-
maximum:
|
|
1347
|
+
maximum: n.value,
|
|
1348
1348
|
type: "date"
|
|
1349
|
-
}), t.dirty()) : b.assertNever(
|
|
1349
|
+
}), t.dirty()) : b.assertNever(n);
|
|
1350
1350
|
return {
|
|
1351
1351
|
status: t.value,
|
|
1352
1352
|
value: new Date(e.data.getTime())
|
|
@@ -1385,64 +1385,64 @@ let Se = class Fe extends v {
|
|
|
1385
1385
|
return e != null ? new Date(e) : null;
|
|
1386
1386
|
}
|
|
1387
1387
|
};
|
|
1388
|
-
|
|
1388
|
+
xe.create = (a) => new xe({
|
|
1389
1389
|
checks: [],
|
|
1390
|
-
coerce: (
|
|
1390
|
+
coerce: (a == null ? void 0 : a.coerce) || !1,
|
|
1391
1391
|
typeName: m.ZodDate,
|
|
1392
|
-
...y(
|
|
1392
|
+
...y(a)
|
|
1393
1393
|
});
|
|
1394
|
-
class
|
|
1394
|
+
class Se extends v {
|
|
1395
1395
|
_parse(e) {
|
|
1396
1396
|
if (this._getType(e) !== l.symbol) {
|
|
1397
1397
|
const t = this._getOrReturnCtx(e);
|
|
1398
|
-
return
|
|
1399
|
-
code:
|
|
1398
|
+
return d(t, {
|
|
1399
|
+
code: u.invalid_type,
|
|
1400
1400
|
expected: l.symbol,
|
|
1401
1401
|
received: t.parsedType
|
|
1402
|
-
}),
|
|
1402
|
+
}), _;
|
|
1403
1403
|
}
|
|
1404
1404
|
return x(e.data);
|
|
1405
1405
|
}
|
|
1406
1406
|
}
|
|
1407
|
-
|
|
1407
|
+
Se.create = (a) => new Se({
|
|
1408
1408
|
typeName: m.ZodSymbol,
|
|
1409
|
-
...y(
|
|
1409
|
+
...y(a)
|
|
1410
1410
|
});
|
|
1411
|
-
class
|
|
1411
|
+
class Ne extends v {
|
|
1412
1412
|
_parse(e) {
|
|
1413
1413
|
if (this._getType(e) !== l.undefined) {
|
|
1414
1414
|
const t = this._getOrReturnCtx(e);
|
|
1415
|
-
return
|
|
1416
|
-
code:
|
|
1415
|
+
return d(t, {
|
|
1416
|
+
code: u.invalid_type,
|
|
1417
1417
|
expected: l.undefined,
|
|
1418
1418
|
received: t.parsedType
|
|
1419
|
-
}),
|
|
1419
|
+
}), _;
|
|
1420
1420
|
}
|
|
1421
1421
|
return x(e.data);
|
|
1422
1422
|
}
|
|
1423
1423
|
}
|
|
1424
|
-
|
|
1424
|
+
Ne.create = (a) => new Ne({
|
|
1425
1425
|
typeName: m.ZodUndefined,
|
|
1426
|
-
...y(
|
|
1426
|
+
...y(a)
|
|
1427
1427
|
});
|
|
1428
|
-
class
|
|
1428
|
+
class Ce extends v {
|
|
1429
1429
|
_parse(e) {
|
|
1430
1430
|
if (this._getType(e) !== l.null) {
|
|
1431
1431
|
const t = this._getOrReturnCtx(e);
|
|
1432
|
-
return
|
|
1433
|
-
code:
|
|
1432
|
+
return d(t, {
|
|
1433
|
+
code: u.invalid_type,
|
|
1434
1434
|
expected: l.null,
|
|
1435
1435
|
received: t.parsedType
|
|
1436
|
-
}),
|
|
1436
|
+
}), _;
|
|
1437
1437
|
}
|
|
1438
1438
|
return x(e.data);
|
|
1439
1439
|
}
|
|
1440
1440
|
}
|
|
1441
|
-
|
|
1441
|
+
Ce.create = (a) => new Ce({
|
|
1442
1442
|
typeName: m.ZodNull,
|
|
1443
|
-
...y(
|
|
1443
|
+
...y(a)
|
|
1444
1444
|
});
|
|
1445
|
-
class
|
|
1445
|
+
class oe extends v {
|
|
1446
1446
|
constructor() {
|
|
1447
1447
|
super(...arguments), this._any = !0;
|
|
1448
1448
|
}
|
|
@@ -1450,11 +1450,11 @@ class ce extends v {
|
|
|
1450
1450
|
return x(e.data);
|
|
1451
1451
|
}
|
|
1452
1452
|
}
|
|
1453
|
-
|
|
1453
|
+
oe.create = (a) => new oe({
|
|
1454
1454
|
typeName: m.ZodAny,
|
|
1455
|
-
...y(
|
|
1455
|
+
...y(a)
|
|
1456
1456
|
});
|
|
1457
|
-
class
|
|
1457
|
+
class Te extends v {
|
|
1458
1458
|
constructor() {
|
|
1459
1459
|
super(...arguments), this._unknown = !0;
|
|
1460
1460
|
}
|
|
@@ -1462,98 +1462,98 @@ class Ze extends v {
|
|
|
1462
1462
|
return x(e.data);
|
|
1463
1463
|
}
|
|
1464
1464
|
}
|
|
1465
|
-
|
|
1465
|
+
Te.create = (a) => new Te({
|
|
1466
1466
|
typeName: m.ZodUnknown,
|
|
1467
|
-
...y(
|
|
1467
|
+
...y(a)
|
|
1468
1468
|
});
|
|
1469
|
-
let
|
|
1469
|
+
let P = class extends v {
|
|
1470
1470
|
_parse(e) {
|
|
1471
1471
|
const t = this._getOrReturnCtx(e);
|
|
1472
|
-
return
|
|
1473
|
-
code:
|
|
1472
|
+
return d(t, {
|
|
1473
|
+
code: u.invalid_type,
|
|
1474
1474
|
expected: l.never,
|
|
1475
1475
|
received: t.parsedType
|
|
1476
|
-
}),
|
|
1476
|
+
}), _;
|
|
1477
1477
|
}
|
|
1478
1478
|
};
|
|
1479
|
-
|
|
1479
|
+
P.create = (a) => new P({
|
|
1480
1480
|
typeName: m.ZodNever,
|
|
1481
|
-
...y(
|
|
1481
|
+
...y(a)
|
|
1482
1482
|
});
|
|
1483
|
-
class
|
|
1483
|
+
class Ze extends v {
|
|
1484
1484
|
_parse(e) {
|
|
1485
1485
|
if (this._getType(e) !== l.undefined) {
|
|
1486
1486
|
const t = this._getOrReturnCtx(e);
|
|
1487
|
-
return
|
|
1488
|
-
code:
|
|
1487
|
+
return d(t, {
|
|
1488
|
+
code: u.invalid_type,
|
|
1489
1489
|
expected: l.void,
|
|
1490
1490
|
received: t.parsedType
|
|
1491
|
-
}),
|
|
1491
|
+
}), _;
|
|
1492
1492
|
}
|
|
1493
1493
|
return x(e.data);
|
|
1494
1494
|
}
|
|
1495
1495
|
}
|
|
1496
|
-
|
|
1496
|
+
Ze.create = (a) => new Ze({
|
|
1497
1497
|
typeName: m.ZodVoid,
|
|
1498
|
-
...y(
|
|
1498
|
+
...y(a)
|
|
1499
1499
|
});
|
|
1500
|
-
|
|
1500
|
+
class T extends v {
|
|
1501
1501
|
_parse(e) {
|
|
1502
|
-
const { ctx: t, status: s } = this._processInputParams(e),
|
|
1502
|
+
const { ctx: t, status: s } = this._processInputParams(e), n = this._def;
|
|
1503
1503
|
if (t.parsedType !== l.array)
|
|
1504
|
-
return
|
|
1505
|
-
code:
|
|
1504
|
+
return d(t, {
|
|
1505
|
+
code: u.invalid_type,
|
|
1506
1506
|
expected: l.array,
|
|
1507
1507
|
received: t.parsedType
|
|
1508
|
-
}),
|
|
1509
|
-
if (
|
|
1510
|
-
const
|
|
1511
|
-
(
|
|
1512
|
-
code:
|
|
1513
|
-
minimum: o ?
|
|
1514
|
-
maximum:
|
|
1508
|
+
}), _;
|
|
1509
|
+
if (n.exactLength !== null) {
|
|
1510
|
+
const i = t.data.length > n.exactLength.value, o = t.data.length < n.exactLength.value;
|
|
1511
|
+
(i || o) && (d(t, {
|
|
1512
|
+
code: i ? u.too_big : u.too_small,
|
|
1513
|
+
minimum: o ? n.exactLength.value : void 0,
|
|
1514
|
+
maximum: i ? n.exactLength.value : void 0,
|
|
1515
1515
|
type: "array",
|
|
1516
1516
|
inclusive: !0,
|
|
1517
1517
|
exact: !0,
|
|
1518
|
-
message:
|
|
1518
|
+
message: n.exactLength.message
|
|
1519
1519
|
}), s.dirty());
|
|
1520
1520
|
}
|
|
1521
|
-
if (
|
|
1522
|
-
code:
|
|
1523
|
-
minimum:
|
|
1521
|
+
if (n.minLength !== null && t.data.length < n.minLength.value && (d(t, {
|
|
1522
|
+
code: u.too_small,
|
|
1523
|
+
minimum: n.minLength.value,
|
|
1524
1524
|
type: "array",
|
|
1525
1525
|
inclusive: !0,
|
|
1526
1526
|
exact: !1,
|
|
1527
|
-
message:
|
|
1528
|
-
}), s.dirty()),
|
|
1529
|
-
code:
|
|
1530
|
-
maximum:
|
|
1527
|
+
message: n.minLength.message
|
|
1528
|
+
}), s.dirty()), n.maxLength !== null && t.data.length > n.maxLength.value && (d(t, {
|
|
1529
|
+
code: u.too_big,
|
|
1530
|
+
maximum: n.maxLength.value,
|
|
1531
1531
|
type: "array",
|
|
1532
1532
|
inclusive: !0,
|
|
1533
1533
|
exact: !1,
|
|
1534
|
-
message:
|
|
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((i, o) => n.type._parseAsync(new j(t, i, t.path, o)))).then((i) => C.mergeArray(s, i));
|
|
1537
|
+
const r = [...t.data].map((i, o) => n.type._parseSync(new j(t, i, t.path, o)));
|
|
1538
|
+
return C.mergeArray(s, r);
|
|
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 T({
|
|
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 T({
|
|
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 T({
|
|
1557
1557
|
...this._def,
|
|
1558
1558
|
exactLength: { value: e, message: p.toString(t) }
|
|
1559
1559
|
});
|
|
@@ -1561,32 +1561,32 @@ let q = class Y extends v {
|
|
|
1561
1561
|
nonempty(e) {
|
|
1562
1562
|
return this.min(1, e);
|
|
1563
1563
|
}
|
|
1564
|
-
}
|
|
1565
|
-
|
|
1566
|
-
type:
|
|
1564
|
+
}
|
|
1565
|
+
T.create = (a, e) => new T({
|
|
1566
|
+
type: a,
|
|
1567
1567
|
minLength: null,
|
|
1568
1568
|
maxLength: null,
|
|
1569
1569
|
exactLength: null,
|
|
1570
1570
|
typeName: m.ZodArray,
|
|
1571
1571
|
...y(e)
|
|
1572
1572
|
});
|
|
1573
|
-
function M(
|
|
1574
|
-
if (
|
|
1573
|
+
function M(a) {
|
|
1574
|
+
if (a instanceof A) {
|
|
1575
1575
|
const e = {};
|
|
1576
|
-
for (const t in
|
|
1577
|
-
const s =
|
|
1578
|
-
e[t] =
|
|
1576
|
+
for (const t in a.shape) {
|
|
1577
|
+
const s = a.shape[t];
|
|
1578
|
+
e[t] = $.create(M(s));
|
|
1579
1579
|
}
|
|
1580
|
-
return new
|
|
1581
|
-
...
|
|
1580
|
+
return new A({
|
|
1581
|
+
...a._def,
|
|
1582
1582
|
shape: () => e
|
|
1583
1583
|
});
|
|
1584
|
-
} else return
|
|
1585
|
-
...
|
|
1586
|
-
type: M(
|
|
1587
|
-
}) :
|
|
1584
|
+
} else return a instanceof T ? new T({
|
|
1585
|
+
...a._def,
|
|
1586
|
+
type: M(a.element)
|
|
1587
|
+
}) : a instanceof $ ? $.create(M(a.unwrap())) : a instanceof V ? V.create(M(a.unwrap())) : a instanceof q ? q.create(a.items.map((e) => M(e))) : a;
|
|
1588
1588
|
}
|
|
1589
|
-
let
|
|
1589
|
+
let A = class N extends v {
|
|
1590
1590
|
constructor() {
|
|
1591
1591
|
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
1592
1592
|
}
|
|
@@ -1599,47 +1599,47 @@ let T = class S extends v {
|
|
|
1599
1599
|
_parse(e) {
|
|
1600
1600
|
if (this._getType(e) !== l.object) {
|
|
1601
1601
|
const c = this._getOrReturnCtx(e);
|
|
1602
|
-
return
|
|
1603
|
-
code:
|
|
1602
|
+
return d(c, {
|
|
1603
|
+
code: u.invalid_type,
|
|
1604
1604
|
expected: l.object,
|
|
1605
1605
|
received: c.parsedType
|
|
1606
|
-
}),
|
|
1606
|
+
}), _;
|
|
1607
1607
|
}
|
|
1608
|
-
const { status: t, ctx: s } = this._processInputParams(e), { shape:
|
|
1609
|
-
if (!(this._def.catchall instanceof
|
|
1608
|
+
const { status: t, ctx: s } = this._processInputParams(e), { shape: n, keys: r } = this._getCached(), i = [];
|
|
1609
|
+
if (!(this._def.catchall instanceof P && this._def.unknownKeys === "strip"))
|
|
1610
1610
|
for (const c in s.data)
|
|
1611
|
-
|
|
1611
|
+
r.includes(c) || i.push(c);
|
|
1612
1612
|
const o = [];
|
|
1613
|
-
for (const c of
|
|
1614
|
-
const h =
|
|
1613
|
+
for (const c of r) {
|
|
1614
|
+
const h = n[c], g = s.data[c];
|
|
1615
1615
|
o.push({
|
|
1616
1616
|
key: { status: "valid", value: c },
|
|
1617
|
-
value: h._parse(new
|
|
1617
|
+
value: h._parse(new j(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 P) {
|
|
1622
1622
|
const c = this._def.unknownKeys;
|
|
1623
1623
|
if (c === "passthrough")
|
|
1624
|
-
for (const h of
|
|
1624
|
+
for (const h of i)
|
|
1625
1625
|
o.push({
|
|
1626
1626
|
key: { status: "valid", value: h },
|
|
1627
1627
|
value: { status: "valid", value: s.data[h] }
|
|
1628
1628
|
});
|
|
1629
1629
|
else if (c === "strict")
|
|
1630
|
-
|
|
1631
|
-
code:
|
|
1632
|
-
keys:
|
|
1630
|
+
i.length > 0 && (d(s, {
|
|
1631
|
+
code: u.unrecognized_keys,
|
|
1632
|
+
keys: i
|
|
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 h of
|
|
1638
|
-
const
|
|
1637
|
+
for (const h of i) {
|
|
1638
|
+
const g = s.data[h];
|
|
1639
1639
|
o.push({
|
|
1640
1640
|
key: { status: "valid", value: h },
|
|
1641
1641
|
value: c._parse(
|
|
1642
|
-
new
|
|
1642
|
+
new j(s, g, s.path, h)
|
|
1643
1643
|
//, ctx.child(key), value, getParsedType(value)
|
|
1644
1644
|
),
|
|
1645
1645
|
alwaysSet: h in s.data
|
|
@@ -1649,44 +1649,44 @@ let T = class S extends v {
|
|
|
1649
1649
|
return s.common.async ? Promise.resolve().then(async () => {
|
|
1650
1650
|
const c = [];
|
|
1651
1651
|
for (const h of o) {
|
|
1652
|
-
const
|
|
1652
|
+
const g = await h.key, w = await h.value;
|
|
1653
1653
|
c.push({
|
|
1654
|
-
key:
|
|
1654
|
+
key: g,
|
|
1655
1655
|
value: w,
|
|
1656
1656
|
alwaysSet: h.alwaysSet
|
|
1657
1657
|
});
|
|
1658
1658
|
}
|
|
1659
1659
|
return c;
|
|
1660
|
-
}).then((c) =>
|
|
1660
|
+
}).then((c) => C.mergeObjectSync(t, c)) : C.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 N({
|
|
1667
1667
|
...this._def,
|
|
1668
1668
|
unknownKeys: "strict",
|
|
1669
1669
|
...e !== void 0 ? {
|
|
1670
1670
|
errorMap: (t, s) => {
|
|
1671
|
-
var
|
|
1672
|
-
const
|
|
1671
|
+
var n, r;
|
|
1672
|
+
const i = ((r = (n = this._def).errorMap) == null ? void 0 : r.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 ?? i
|
|
1675
1675
|
} : {
|
|
1676
|
-
message:
|
|
1676
|
+
message: i
|
|
1677
1677
|
};
|
|
1678
1678
|
}
|
|
1679
1679
|
} : {}
|
|
1680
1680
|
});
|
|
1681
1681
|
}
|
|
1682
1682
|
strip() {
|
|
1683
|
-
return new
|
|
1683
|
+
return new N({
|
|
1684
1684
|
...this._def,
|
|
1685
1685
|
unknownKeys: "strip"
|
|
1686
1686
|
});
|
|
1687
1687
|
}
|
|
1688
1688
|
passthrough() {
|
|
1689
|
-
return new
|
|
1689
|
+
return new N({
|
|
1690
1690
|
...this._def,
|
|
1691
1691
|
unknownKeys: "passthrough"
|
|
1692
1692
|
});
|
|
@@ -1709,7 +1709,7 @@ let T = class S extends v {
|
|
|
1709
1709
|
// }) as any;
|
|
1710
1710
|
// };
|
|
1711
1711
|
extend(e) {
|
|
1712
|
-
return new
|
|
1712
|
+
return new N({
|
|
1713
1713
|
...this._def,
|
|
1714
1714
|
shape: () => ({
|
|
1715
1715
|
...this._def.shape(),
|
|
@@ -1723,7 +1723,7 @@ let T = class S extends v {
|
|
|
1723
1723
|
* upgrade if you are experiencing issues.
|
|
1724
1724
|
*/
|
|
1725
1725
|
merge(e) {
|
|
1726
|
-
return new
|
|
1726
|
+
return new N({
|
|
1727
1727
|
unknownKeys: e._def.unknownKeys,
|
|
1728
1728
|
catchall: e._def.catchall,
|
|
1729
1729
|
shape: () => ({
|
|
@@ -1793,7 +1793,7 @@ let T = class S extends v {
|
|
|
1793
1793
|
// return merged;
|
|
1794
1794
|
// }
|
|
1795
1795
|
catchall(e) {
|
|
1796
|
-
return new
|
|
1796
|
+
return new N({
|
|
1797
1797
|
...this._def,
|
|
1798
1798
|
catchall: e
|
|
1799
1799
|
});
|
|
@@ -1802,7 +1802,7 @@ let T = class S 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 N({
|
|
1806
1806
|
...this._def,
|
|
1807
1807
|
shape: () => t
|
|
1808
1808
|
});
|
|
@@ -1811,7 +1811,7 @@ let T = class S 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 N({
|
|
1815
1815
|
...this._def,
|
|
1816
1816
|
shape: () => t
|
|
1817
1817
|
});
|
|
@@ -1825,10 +1825,10 @@ let T = class S extends v {
|
|
|
1825
1825
|
partial(e) {
|
|
1826
1826
|
const t = {};
|
|
1827
1827
|
for (const s of b.objectKeys(this.shape)) {
|
|
1828
|
-
const
|
|
1829
|
-
e && !e[s] ? t[s] =
|
|
1828
|
+
const n = this.shape[s];
|
|
1829
|
+
e && !e[s] ? t[s] = n : t[s] = n.optional();
|
|
1830
1830
|
}
|
|
1831
|
-
return new
|
|
1831
|
+
return new N({
|
|
1832
1832
|
...this._def,
|
|
1833
1833
|
shape: () => t
|
|
1834
1834
|
});
|
|
@@ -1839,60 +1839,60 @@ let T = class S extends v {
|
|
|
1839
1839
|
if (e && !e[s])
|
|
1840
1840
|
t[s] = this.shape[s];
|
|
1841
1841
|
else {
|
|
1842
|
-
let
|
|
1843
|
-
for (;
|
|
1844
|
-
|
|
1845
|
-
t[s] =
|
|
1842
|
+
let n = this.shape[s];
|
|
1843
|
+
for (; n instanceof $; )
|
|
1844
|
+
n = n._def.innerType;
|
|
1845
|
+
t[s] = n;
|
|
1846
1846
|
}
|
|
1847
|
-
return new
|
|
1847
|
+
return new N({
|
|
1848
1848
|
...this._def,
|
|
1849
1849
|
shape: () => t
|
|
1850
1850
|
});
|
|
1851
1851
|
}
|
|
1852
1852
|
keyof() {
|
|
1853
|
-
return
|
|
1853
|
+
return Re(b.objectKeys(this.shape));
|
|
1854
1854
|
}
|
|
1855
1855
|
};
|
|
1856
|
-
|
|
1857
|
-
shape: () =>
|
|
1856
|
+
A.create = (a, e) => new A({
|
|
1857
|
+
shape: () => a,
|
|
1858
1858
|
unknownKeys: "strip",
|
|
1859
|
-
catchall:
|
|
1859
|
+
catchall: P.create(),
|
|
1860
1860
|
typeName: m.ZodObject,
|
|
1861
1861
|
...y(e)
|
|
1862
1862
|
});
|
|
1863
|
-
|
|
1864
|
-
shape: () =>
|
|
1863
|
+
A.strictCreate = (a, e) => new A({
|
|
1864
|
+
shape: () => a,
|
|
1865
1865
|
unknownKeys: "strict",
|
|
1866
|
-
catchall:
|
|
1866
|
+
catchall: P.create(),
|
|
1867
1867
|
typeName: m.ZodObject,
|
|
1868
1868
|
...y(e)
|
|
1869
1869
|
});
|
|
1870
|
-
|
|
1871
|
-
shape:
|
|
1870
|
+
A.lazycreate = (a, e) => new A({
|
|
1871
|
+
shape: a,
|
|
1872
1872
|
unknownKeys: "strip",
|
|
1873
|
-
catchall:
|
|
1873
|
+
catchall: P.create(),
|
|
1874
1874
|
typeName: m.ZodObject,
|
|
1875
1875
|
...y(e)
|
|
1876
1876
|
});
|
|
1877
|
-
let
|
|
1877
|
+
let X = class extends v {
|
|
1878
1878
|
_parse(e) {
|
|
1879
1879
|
const { ctx: t } = this._processInputParams(e), s = this._def.options;
|
|
1880
|
-
function
|
|
1881
|
-
for (const o of
|
|
1880
|
+
function n(r) {
|
|
1881
|
+
for (const o of r)
|
|
1882
1882
|
if (o.result.status === "valid")
|
|
1883
1883
|
return o.result;
|
|
1884
|
-
for (const o of
|
|
1884
|
+
for (const o of r)
|
|
1885
1885
|
if (o.result.status === "dirty")
|
|
1886
1886
|
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
1887
|
-
const
|
|
1888
|
-
return
|
|
1889
|
-
code:
|
|
1890
|
-
unionErrors:
|
|
1891
|
-
}),
|
|
1887
|
+
const i = r.map((o) => new O(o.ctx.common.issues));
|
|
1888
|
+
return d(t, {
|
|
1889
|
+
code: u.invalid_union,
|
|
1890
|
+
unionErrors: i
|
|
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 (r) => {
|
|
1895
|
+
const i = {
|
|
1896
1896
|
...t,
|
|
1897
1897
|
common: {
|
|
1898
1898
|
...t.common,
|
|
@@ -1901,17 +1901,17 @@ let Q = class extends v {
|
|
|
1901
1901
|
parent: null
|
|
1902
1902
|
};
|
|
1903
1903
|
return {
|
|
1904
|
-
result: await
|
|
1904
|
+
result: await r._parseAsync({
|
|
1905
1905
|
data: t.data,
|
|
1906
1906
|
path: t.path,
|
|
1907
|
-
parent:
|
|
1907
|
+
parent: i
|
|
1908
1908
|
}),
|
|
1909
|
-
ctx:
|
|
1909
|
+
ctx: i
|
|
1910
1910
|
};
|
|
1911
|
-
})).then(
|
|
1911
|
+
})).then(n);
|
|
1912
1912
|
{
|
|
1913
|
-
let
|
|
1914
|
-
const
|
|
1913
|
+
let r;
|
|
1914
|
+
const i = [];
|
|
1915
1915
|
for (const c of s) {
|
|
1916
1916
|
const h = {
|
|
1917
1917
|
...t,
|
|
@@ -1920,68 +1920,68 @@ let Q = class extends v {
|
|
|
1920
1920
|
issues: []
|
|
1921
1921
|
},
|
|
1922
1922
|
parent: null
|
|
1923
|
-
},
|
|
1923
|
+
}, g = c._parseSync({
|
|
1924
1924
|
data: t.data,
|
|
1925
1925
|
path: t.path,
|
|
1926
1926
|
parent: h
|
|
1927
1927
|
});
|
|
1928
|
-
if (
|
|
1929
|
-
return
|
|
1930
|
-
|
|
1928
|
+
if (g.status === "valid")
|
|
1929
|
+
return g;
|
|
1930
|
+
g.status === "dirty" && !r && (r = { result: g, ctx: h }), h.common.issues.length && i.push(h.common.issues);
|
|
1931
1931
|
}
|
|
1932
|
-
if (
|
|
1933
|
-
return t.common.issues.push(...
|
|
1934
|
-
const o =
|
|
1935
|
-
return
|
|
1936
|
-
code:
|
|
1932
|
+
if (r)
|
|
1933
|
+
return t.common.issues.push(...r.ctx.common.issues), r.result;
|
|
1934
|
+
const o = i.map((c) => new O(c));
|
|
1935
|
+
return d(t, {
|
|
1936
|
+
code: u.invalid_union,
|
|
1937
1937
|
unionErrors: o
|
|
1938
|
-
}),
|
|
1938
|
+
}), _;
|
|
1939
1939
|
}
|
|
1940
1940
|
}
|
|
1941
1941
|
get options() {
|
|
1942
1942
|
return this._def.options;
|
|
1943
1943
|
}
|
|
1944
1944
|
};
|
|
1945
|
-
|
|
1946
|
-
options:
|
|
1945
|
+
X.create = (a, e) => new X({
|
|
1946
|
+
options: a,
|
|
1947
1947
|
typeName: m.ZodUnion,
|
|
1948
1948
|
...y(e)
|
|
1949
1949
|
});
|
|
1950
|
-
function
|
|
1951
|
-
const t =
|
|
1952
|
-
if (
|
|
1953
|
-
return { valid: !0, data:
|
|
1950
|
+
function ce(a, e) {
|
|
1951
|
+
const t = I(a), s = I(e);
|
|
1952
|
+
if (a === e)
|
|
1953
|
+
return { valid: !0, data: a };
|
|
1954
1954
|
if (t === l.object && s === l.object) {
|
|
1955
|
-
const
|
|
1956
|
-
for (const o of
|
|
1957
|
-
const c =
|
|
1955
|
+
const n = b.objectKeys(e), r = b.objectKeys(a).filter((o) => n.indexOf(o) !== -1), i = { ...a, ...e };
|
|
1956
|
+
for (const o of r) {
|
|
1957
|
+
const c = ce(a[o], e[o]);
|
|
1958
1958
|
if (!c.valid)
|
|
1959
1959
|
return { valid: !1 };
|
|
1960
|
-
|
|
1960
|
+
i[o] = c.data;
|
|
1961
1961
|
}
|
|
1962
|
-
return { valid: !0, data:
|
|
1962
|
+
return { valid: !0, data: i };
|
|
1963
1963
|
} else if (t === l.array && s === l.array) {
|
|
1964
|
-
if (
|
|
1964
|
+
if (a.length !== e.length)
|
|
1965
1965
|
return { valid: !1 };
|
|
1966
|
-
const
|
|
1967
|
-
for (let
|
|
1968
|
-
const
|
|
1966
|
+
const n = [];
|
|
1967
|
+
for (let r = 0; r < a.length; r++) {
|
|
1968
|
+
const i = a[r], o = e[r], c = ce(i, o);
|
|
1969
1969
|
if (!c.valid)
|
|
1970
1970
|
return { valid: !1 };
|
|
1971
|
-
|
|
1971
|
+
n.push(c.data);
|
|
1972
1972
|
}
|
|
1973
|
-
return { valid: !0, data:
|
|
1974
|
-
} else return t === l.date && s === l.date && +
|
|
1973
|
+
return { valid: !0, data: n };
|
|
1974
|
+
} else return t === l.date && s === l.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),
|
|
1979
|
-
if (
|
|
1980
|
-
return
|
|
1981
|
-
const o =
|
|
1982
|
-
return o.valid ? ((
|
|
1983
|
-
code:
|
|
1984
|
-
}),
|
|
1978
|
+
const { status: t, ctx: s } = this._processInputParams(e), n = (r, i) => {
|
|
1979
|
+
if (ye(r) || ye(i))
|
|
1980
|
+
return _;
|
|
1981
|
+
const o = ce(r.value, i.value);
|
|
1982
|
+
return o.valid ? ((ve(r) || ve(i)) && t.dirty(), { status: t.value, value: o.data }) : (d(s, {
|
|
1983
|
+
code: u.invalid_intersection_types
|
|
1984
|
+
}), _);
|
|
1985
1985
|
};
|
|
1986
1986
|
return s.common.async ? Promise.all([
|
|
1987
1987
|
this._def.left._parseAsync({
|
|
@@ -1994,7 +1994,7 @@ let ee = class extends v {
|
|
|
1994
1994
|
path: s.path,
|
|
1995
1995
|
parent: s
|
|
1996
1996
|
})
|
|
1997
|
-
]).then(([
|
|
1997
|
+
]).then(([r, i]) => n(r, i)) : n(this._def.left._parseSync({
|
|
1998
1998
|
data: s.data,
|
|
1999
1999
|
path: s.path,
|
|
2000
2000
|
parent: s
|
|
@@ -2005,63 +2005,63 @@ let ee = class extends v {
|
|
|
2005
2005
|
}));
|
|
2006
2006
|
}
|
|
2007
2007
|
};
|
|
2008
|
-
ee.create = (
|
|
2009
|
-
left:
|
|
2008
|
+
ee.create = (a, e, t) => new ee({
|
|
2009
|
+
left: a,
|
|
2010
2010
|
right: e,
|
|
2011
2011
|
typeName: m.ZodIntersection,
|
|
2012
2012
|
...y(t)
|
|
2013
2013
|
});
|
|
2014
|
-
class
|
|
2014
|
+
class q extends v {
|
|
2015
2015
|
_parse(e) {
|
|
2016
2016
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2017
2017
|
if (s.parsedType !== l.array)
|
|
2018
|
-
return
|
|
2019
|
-
code:
|
|
2018
|
+
return d(s, {
|
|
2019
|
+
code: u.invalid_type,
|
|
2020
2020
|
expected: l.array,
|
|
2021
2021
|
received: s.parsedType
|
|
2022
|
-
}),
|
|
2022
|
+
}), _;
|
|
2023
2023
|
if (s.data.length < this._def.items.length)
|
|
2024
|
-
return
|
|
2025
|
-
code:
|
|
2024
|
+
return d(s, {
|
|
2025
|
+
code: u.too_small,
|
|
2026
2026
|
minimum: this._def.items.length,
|
|
2027
2027
|
inclusive: !0,
|
|
2028
2028
|
exact: !1,
|
|
2029
2029
|
type: "array"
|
|
2030
|
-
}),
|
|
2031
|
-
!this._def.rest && s.data.length > this._def.items.length && (
|
|
2032
|
-
code:
|
|
2030
|
+
}), _;
|
|
2031
|
+
!this._def.rest && s.data.length > this._def.items.length && (d(s, {
|
|
2032
|
+
code: u.too_big,
|
|
2033
2033
|
maximum: this._def.items.length,
|
|
2034
2034
|
inclusive: !0,
|
|
2035
2035
|
exact: !1,
|
|
2036
2036
|
type: "array"
|
|
2037
2037
|
}), t.dirty());
|
|
2038
|
-
const
|
|
2039
|
-
const o = this._def.items[
|
|
2040
|
-
return o ? o._parse(new
|
|
2041
|
-
}).filter((
|
|
2042
|
-
return s.common.async ? Promise.all(
|
|
2038
|
+
const n = [...s.data].map((r, i) => {
|
|
2039
|
+
const o = this._def.items[i] || this._def.rest;
|
|
2040
|
+
return o ? o._parse(new j(s, r, s.path, i)) : null;
|
|
2041
|
+
}).filter((r) => !!r);
|
|
2042
|
+
return s.common.async ? Promise.all(n).then((r) => C.mergeArray(t, r)) : C.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 q({
|
|
2049
2049
|
...this._def,
|
|
2050
2050
|
rest: e
|
|
2051
2051
|
});
|
|
2052
2052
|
}
|
|
2053
2053
|
}
|
|
2054
|
-
|
|
2055
|
-
if (!Array.isArray(
|
|
2054
|
+
q.create = (a, e) => {
|
|
2055
|
+
if (!Array.isArray(a))
|
|
2056
2056
|
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2057
|
-
return new
|
|
2058
|
-
items:
|
|
2057
|
+
return new q({
|
|
2058
|
+
items: a,
|
|
2059
2059
|
typeName: m.ZodTuple,
|
|
2060
2060
|
rest: null,
|
|
2061
2061
|
...y(e)
|
|
2062
2062
|
});
|
|
2063
2063
|
};
|
|
2064
|
-
class
|
|
2064
|
+
class Oe extends v {
|
|
2065
2065
|
get keySchema() {
|
|
2066
2066
|
return this._def.keyType;
|
|
2067
2067
|
}
|
|
@@ -2071,90 +2071,90 @@ class Ae extends v {
|
|
|
2071
2071
|
_parse(e) {
|
|
2072
2072
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2073
2073
|
if (s.parsedType !== l.map)
|
|
2074
|
-
return
|
|
2075
|
-
code:
|
|
2074
|
+
return d(s, {
|
|
2075
|
+
code: u.invalid_type,
|
|
2076
2076
|
expected: l.map,
|
|
2077
2077
|
received: s.parsedType
|
|
2078
|
-
}),
|
|
2079
|
-
const
|
|
2080
|
-
key:
|
|
2081
|
-
value:
|
|
2078
|
+
}), _;
|
|
2079
|
+
const n = this._def.keyType, r = this._def.valueType, i = [...s.data.entries()].map(([o, c], h) => ({
|
|
2080
|
+
key: n._parse(new j(s, o, s.path, [h, "key"])),
|
|
2081
|
+
value: r._parse(new j(s, c, s.path, [h, "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 h = await c.key,
|
|
2088
|
-
if (h.status === "aborted" ||
|
|
2089
|
-
return
|
|
2090
|
-
(h.status === "dirty" ||
|
|
2086
|
+
for (const c of i) {
|
|
2087
|
+
const h = await c.key, g = await c.value;
|
|
2088
|
+
if (h.status === "aborted" || g.status === "aborted")
|
|
2089
|
+
return _;
|
|
2090
|
+
(h.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(h.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 h = c.key,
|
|
2098
|
-
if (h.status === "aborted" ||
|
|
2099
|
-
return
|
|
2100
|
-
(h.status === "dirty" ||
|
|
2096
|
+
for (const c of i) {
|
|
2097
|
+
const h = c.key, g = c.value;
|
|
2098
|
+
if (h.status === "aborted" || g.status === "aborted")
|
|
2099
|
+
return _;
|
|
2100
|
+
(h.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(h.value, g.value);
|
|
2101
2101
|
}
|
|
2102
2102
|
return { status: t.value, value: o };
|
|
2103
2103
|
}
|
|
2104
2104
|
}
|
|
2105
2105
|
}
|
|
2106
|
-
|
|
2106
|
+
Oe.create = (a, e, t) => new Oe({
|
|
2107
2107
|
valueType: e,
|
|
2108
|
-
keyType:
|
|
2108
|
+
keyType: a,
|
|
2109
2109
|
typeName: m.ZodMap,
|
|
2110
2110
|
...y(t)
|
|
2111
2111
|
});
|
|
2112
|
-
class
|
|
2112
|
+
class K extends v {
|
|
2113
2113
|
_parse(e) {
|
|
2114
2114
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2115
2115
|
if (s.parsedType !== l.set)
|
|
2116
|
-
return
|
|
2117
|
-
code:
|
|
2116
|
+
return d(s, {
|
|
2117
|
+
code: u.invalid_type,
|
|
2118
2118
|
expected: l.set,
|
|
2119
2119
|
received: s.parsedType
|
|
2120
|
-
}),
|
|
2121
|
-
const
|
|
2122
|
-
|
|
2123
|
-
code:
|
|
2124
|
-
minimum:
|
|
2120
|
+
}), _;
|
|
2121
|
+
const n = this._def;
|
|
2122
|
+
n.minSize !== null && s.data.size < n.minSize.value && (d(s, {
|
|
2123
|
+
code: u.too_small,
|
|
2124
|
+
minimum: n.minSize.value,
|
|
2125
2125
|
type: "set",
|
|
2126
2126
|
inclusive: !0,
|
|
2127
2127
|
exact: !1,
|
|
2128
|
-
message:
|
|
2129
|
-
}), t.dirty()),
|
|
2130
|
-
code:
|
|
2131
|
-
maximum:
|
|
2128
|
+
message: n.minSize.message
|
|
2129
|
+
}), t.dirty()), n.maxSize !== null && s.data.size > n.maxSize.value && (d(s, {
|
|
2130
|
+
code: u.too_big,
|
|
2131
|
+
maximum: n.maxSize.value,
|
|
2132
2132
|
type: "set",
|
|
2133
2133
|
inclusive: !0,
|
|
2134
2134
|
exact: !1,
|
|
2135
|
-
message:
|
|
2135
|
+
message: n.maxSize.message
|
|
2136
2136
|
}), t.dirty());
|
|
2137
|
-
const
|
|
2138
|
-
function
|
|
2137
|
+
const r = this._def.valueType;
|
|
2138
|
+
function i(c) {
|
|
2139
2139
|
const h = /* @__PURE__ */ new Set();
|
|
2140
|
-
for (const
|
|
2141
|
-
if (
|
|
2142
|
-
return
|
|
2143
|
-
|
|
2140
|
+
for (const g of c) {
|
|
2141
|
+
if (g.status === "aborted")
|
|
2142
|
+
return _;
|
|
2143
|
+
g.status === "dirty" && t.dirty(), h.add(g.value);
|
|
2144
2144
|
}
|
|
2145
2145
|
return { status: t.value, value: h };
|
|
2146
2146
|
}
|
|
2147
|
-
const o = [...s.data.values()].map((c, h) =>
|
|
2148
|
-
return s.common.async ? Promise.all(o).then((c) =>
|
|
2147
|
+
const o = [...s.data.values()].map((c, h) => r._parse(new j(s, c, s.path, h)));
|
|
2148
|
+
return s.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
2149
2149
|
}
|
|
2150
2150
|
min(e, t) {
|
|
2151
|
-
return new
|
|
2151
|
+
return new K({
|
|
2152
2152
|
...this._def,
|
|
2153
2153
|
minSize: { value: e, message: p.toString(t) }
|
|
2154
2154
|
});
|
|
2155
2155
|
}
|
|
2156
2156
|
max(e, t) {
|
|
2157
|
-
return new
|
|
2157
|
+
return new K({
|
|
2158
2158
|
...this._def,
|
|
2159
2159
|
maxSize: { value: e, message: p.toString(t) }
|
|
2160
2160
|
});
|
|
@@ -2166,14 +2166,14 @@ class H extends v {
|
|
|
2166
2166
|
return this.min(1, e);
|
|
2167
2167
|
}
|
|
2168
2168
|
}
|
|
2169
|
-
|
|
2170
|
-
valueType:
|
|
2169
|
+
K.create = (a, e) => new K({
|
|
2170
|
+
valueType: a,
|
|
2171
2171
|
minSize: null,
|
|
2172
2172
|
maxSize: null,
|
|
2173
2173
|
typeName: m.ZodSet,
|
|
2174
2174
|
...y(e)
|
|
2175
2175
|
});
|
|
2176
|
-
class
|
|
2176
|
+
class Ae extends v {
|
|
2177
2177
|
get schema() {
|
|
2178
2178
|
return this._def.getter();
|
|
2179
2179
|
}
|
|
@@ -2182,8 +2182,8 @@ class Ee extends v {
|
|
|
2182
2182
|
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2183
2183
|
}
|
|
2184
2184
|
}
|
|
2185
|
-
|
|
2186
|
-
getter:
|
|
2185
|
+
Ae.create = (a, e) => new Ae({
|
|
2186
|
+
getter: a,
|
|
2187
2187
|
typeName: m.ZodLazy,
|
|
2188
2188
|
...y(e)
|
|
2189
2189
|
});
|
|
@@ -2191,11 +2191,11 @@ let ue = class extends v {
|
|
|
2191
2191
|
_parse(e) {
|
|
2192
2192
|
if (e.data !== this._def.value) {
|
|
2193
2193
|
const t = this._getOrReturnCtx(e);
|
|
2194
|
-
return
|
|
2194
|
+
return d(t, {
|
|
2195
2195
|
received: t.data,
|
|
2196
|
-
code:
|
|
2196
|
+
code: u.invalid_literal,
|
|
2197
2197
|
expected: this._def.value
|
|
2198
|
-
}),
|
|
2198
|
+
}), _;
|
|
2199
2199
|
}
|
|
2200
2200
|
return { status: "valid", value: e.data };
|
|
2201
2201
|
}
|
|
@@ -2203,35 +2203,35 @@ let ue = class extends v {
|
|
|
2203
2203
|
return this._def.value;
|
|
2204
2204
|
}
|
|
2205
2205
|
};
|
|
2206
|
-
ue.create = (
|
|
2207
|
-
value:
|
|
2206
|
+
ue.create = (a, e) => new ue({
|
|
2207
|
+
value: a,
|
|
2208
2208
|
typeName: m.ZodLiteral,
|
|
2209
2209
|
...y(e)
|
|
2210
2210
|
});
|
|
2211
|
-
function
|
|
2212
|
-
return new
|
|
2213
|
-
values:
|
|
2211
|
+
function Re(a, e) {
|
|
2212
|
+
return new fe({
|
|
2213
|
+
values: a,
|
|
2214
2214
|
typeName: m.ZodEnum,
|
|
2215
2215
|
...y(e)
|
|
2216
2216
|
});
|
|
2217
2217
|
}
|
|
2218
|
-
let
|
|
2218
|
+
let fe = class de extends v {
|
|
2219
2219
|
_parse(e) {
|
|
2220
2220
|
if (typeof e.data != "string") {
|
|
2221
2221
|
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
2222
|
-
return
|
|
2222
|
+
return d(t, {
|
|
2223
2223
|
expected: b.joinValues(s),
|
|
2224
2224
|
received: t.parsedType,
|
|
2225
|
-
code:
|
|
2226
|
-
}),
|
|
2225
|
+
code: u.invalid_type
|
|
2226
|
+
}), _;
|
|
2227
2227
|
}
|
|
2228
2228
|
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
2229
2229
|
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
2230
|
-
return
|
|
2230
|
+
return d(t, {
|
|
2231
2231
|
received: t.data,
|
|
2232
|
-
code:
|
|
2232
|
+
code: u.invalid_enum_value,
|
|
2233
2233
|
options: s
|
|
2234
|
-
}),
|
|
2234
|
+
}), _;
|
|
2235
2235
|
}
|
|
2236
2236
|
return x(e.data);
|
|
2237
2237
|
}
|
|
@@ -2257,37 +2257,37 @@ let me = class le extends v {
|
|
|
2257
2257
|
return e;
|
|
2258
2258
|
}
|
|
2259
2259
|
extract(e, t = this._def) {
|
|
2260
|
-
return
|
|
2260
|
+
return de.create(e, {
|
|
2261
2261
|
...this._def,
|
|
2262
2262
|
...t
|
|
2263
2263
|
});
|
|
2264
2264
|
}
|
|
2265
2265
|
exclude(e, t = this._def) {
|
|
2266
|
-
return
|
|
2266
|
+
return de.create(this.options.filter((s) => !e.includes(s)), {
|
|
2267
2267
|
...this._def,
|
|
2268
2268
|
...t
|
|
2269
2269
|
});
|
|
2270
2270
|
}
|
|
2271
2271
|
};
|
|
2272
|
-
|
|
2272
|
+
fe.create = Re;
|
|
2273
2273
|
class Ie extends v {
|
|
2274
2274
|
_parse(e) {
|
|
2275
2275
|
const t = b.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
2276
2276
|
if (s.parsedType !== l.string && s.parsedType !== l.number) {
|
|
2277
|
-
const
|
|
2278
|
-
return
|
|
2279
|
-
expected: b.joinValues(
|
|
2277
|
+
const n = b.objectValues(t);
|
|
2278
|
+
return d(s, {
|
|
2279
|
+
expected: b.joinValues(n),
|
|
2280
2280
|
received: s.parsedType,
|
|
2281
|
-
code:
|
|
2282
|
-
}),
|
|
2281
|
+
code: u.invalid_type
|
|
2282
|
+
}), _;
|
|
2283
2283
|
}
|
|
2284
2284
|
if (this._cache || (this._cache = new Set(b.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
2285
|
-
const
|
|
2286
|
-
return
|
|
2285
|
+
const n = b.objectValues(t);
|
|
2286
|
+
return d(s, {
|
|
2287
2287
|
received: s.data,
|
|
2288
|
-
code:
|
|
2289
|
-
options:
|
|
2290
|
-
}),
|
|
2288
|
+
code: u.invalid_enum_value,
|
|
2289
|
+
options: n
|
|
2290
|
+
}), _;
|
|
2291
2291
|
}
|
|
2292
2292
|
return x(e.data);
|
|
2293
2293
|
}
|
|
@@ -2295,8 +2295,8 @@ class Ie extends v {
|
|
|
2295
2295
|
return this._def.values;
|
|
2296
2296
|
}
|
|
2297
2297
|
}
|
|
2298
|
-
Ie.create = (
|
|
2299
|
-
values:
|
|
2298
|
+
Ie.create = (a, e) => new Ie({
|
|
2299
|
+
values: a,
|
|
2300
2300
|
typeName: m.ZodNativeEnum,
|
|
2301
2301
|
...y(e)
|
|
2302
2302
|
});
|
|
@@ -2307,24 +2307,24 @@ let te = class extends v {
|
|
|
2307
2307
|
_parse(e) {
|
|
2308
2308
|
const { ctx: t } = this._processInputParams(e);
|
|
2309
2309
|
if (t.parsedType !== l.promise && t.common.async === !1)
|
|
2310
|
-
return
|
|
2311
|
-
code:
|
|
2310
|
+
return d(t, {
|
|
2311
|
+
code: u.invalid_type,
|
|
2312
2312
|
expected: l.promise,
|
|
2313
2313
|
received: t.parsedType
|
|
2314
|
-
}),
|
|
2314
|
+
}), _;
|
|
2315
2315
|
const s = t.parsedType === l.promise ? t.data : Promise.resolve(t.data);
|
|
2316
|
-
return x(s.then((
|
|
2316
|
+
return x(s.then((n) => this._def.type.parseAsync(n, {
|
|
2317
2317
|
path: t.path,
|
|
2318
2318
|
errorMap: t.common.contextualErrorMap
|
|
2319
2319
|
})));
|
|
2320
2320
|
}
|
|
2321
2321
|
};
|
|
2322
|
-
te.create = (
|
|
2323
|
-
type:
|
|
2322
|
+
te.create = (a, e) => new te({
|
|
2323
|
+
type: a,
|
|
2324
2324
|
typeName: m.ZodPromise,
|
|
2325
2325
|
...y(e)
|
|
2326
2326
|
});
|
|
2327
|
-
|
|
2327
|
+
let D = class extends v {
|
|
2328
2328
|
innerType() {
|
|
2329
2329
|
return this._def.schema;
|
|
2330
2330
|
}
|
|
@@ -2332,41 +2332,41 @@ class D 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),
|
|
2336
|
-
addIssue: (
|
|
2337
|
-
|
|
2335
|
+
const { status: t, ctx: s } = this._processInputParams(e), n = this._def.effect || null, r = {
|
|
2336
|
+
addIssue: (i) => {
|
|
2337
|
+
d(s, i), i.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 (r.addIssue = r.addIssue.bind(r), n.type === "preprocess") {
|
|
2344
|
+
const i = n.transform(s.data, r);
|
|
2345
2345
|
if (s.common.async)
|
|
2346
|
-
return Promise.resolve(
|
|
2346
|
+
return Promise.resolve(i).then(async (o) => {
|
|
2347
2347
|
if (t.value === "aborted")
|
|
2348
|
-
return
|
|
2348
|
+
return _;
|
|
2349
2349
|
const c = await this._def.schema._parseAsync({
|
|
2350
2350
|
data: o,
|
|
2351
2351
|
path: s.path,
|
|
2352
2352
|
parent: s
|
|
2353
2353
|
});
|
|
2354
|
-
return c.status === "aborted" ?
|
|
2354
|
+
return c.status === "aborted" ? _ : c.status === "dirty" || t.value === "dirty" ? re(c.value) : c;
|
|
2355
2355
|
});
|
|
2356
2356
|
{
|
|
2357
2357
|
if (t.value === "aborted")
|
|
2358
|
-
return
|
|
2358
|
+
return _;
|
|
2359
2359
|
const o = this._def.schema._parseSync({
|
|
2360
|
-
data:
|
|
2360
|
+
data: i,
|
|
2361
2361
|
path: s.path,
|
|
2362
2362
|
parent: s
|
|
2363
2363
|
});
|
|
2364
|
-
return o.status === "aborted" ?
|
|
2364
|
+
return o.status === "aborted" ? _ : o.status === "dirty" || t.value === "dirty" ? re(o.value) : o;
|
|
2365
2365
|
}
|
|
2366
2366
|
}
|
|
2367
|
-
if (
|
|
2368
|
-
const
|
|
2369
|
-
const c =
|
|
2367
|
+
if (n.type === "refinement") {
|
|
2368
|
+
const i = (o) => {
|
|
2369
|
+
const c = n.refinement(o, r);
|
|
2370
2370
|
if (s.common.async)
|
|
2371
2371
|
return Promise.resolve(c);
|
|
2372
2372
|
if (c instanceof Promise)
|
|
@@ -2379,44 +2379,44 @@ class D extends v {
|
|
|
2379
2379
|
path: s.path,
|
|
2380
2380
|
parent: s
|
|
2381
2381
|
});
|
|
2382
|
-
return o.status === "aborted" ?
|
|
2382
|
+
return o.status === "aborted" ? _ : (o.status === "dirty" && t.dirty(), i(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" ?
|
|
2384
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((o) => o.status === "aborted" ? _ : (o.status === "dirty" && t.dirty(), i(o.value).then(() => ({ status: t.value, value: o.value }))));
|
|
2385
2385
|
}
|
|
2386
|
-
if (
|
|
2386
|
+
if (n.type === "transform")
|
|
2387
2387
|
if (s.common.async === !1) {
|
|
2388
|
-
const
|
|
2388
|
+
const i = this._def.schema._parseSync({
|
|
2389
2389
|
data: s.data,
|
|
2390
2390
|
path: s.path,
|
|
2391
2391
|
parent: s
|
|
2392
2392
|
});
|
|
2393
|
-
if (!L(
|
|
2394
|
-
return
|
|
2395
|
-
const o =
|
|
2393
|
+
if (!L(i))
|
|
2394
|
+
return _;
|
|
2395
|
+
const o = n.transform(i.value, r);
|
|
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((i) => L(i) ? Promise.resolve(n.transform(i.value, r)).then((o) => ({
|
|
2401
2401
|
status: t.value,
|
|
2402
2402
|
value: o
|
|
2403
|
-
})) :
|
|
2404
|
-
b.assertNever(
|
|
2403
|
+
})) : _);
|
|
2404
|
+
b.assertNever(n);
|
|
2405
2405
|
}
|
|
2406
|
-
}
|
|
2407
|
-
D.create = (
|
|
2408
|
-
schema:
|
|
2406
|
+
};
|
|
2407
|
+
D.create = (a, e, t) => new D({
|
|
2408
|
+
schema: a,
|
|
2409
2409
|
typeName: m.ZodEffects,
|
|
2410
2410
|
effect: e,
|
|
2411
2411
|
...y(t)
|
|
2412
2412
|
});
|
|
2413
|
-
D.createWithPreprocess = (
|
|
2413
|
+
D.createWithPreprocess = (a, e, t) => new D({
|
|
2414
2414
|
schema: e,
|
|
2415
|
-
effect: { type: "preprocess", transform:
|
|
2415
|
+
effect: { type: "preprocess", transform: a },
|
|
2416
2416
|
typeName: m.ZodEffects,
|
|
2417
2417
|
...y(t)
|
|
2418
2418
|
});
|
|
2419
|
-
let
|
|
2419
|
+
let $ = class extends v {
|
|
2420
2420
|
_parse(e) {
|
|
2421
2421
|
return this._getType(e) === l.undefined ? x(void 0) : this._def.innerType._parse(e);
|
|
2422
2422
|
}
|
|
@@ -2424,8 +2424,8 @@ let E = class extends v {
|
|
|
2424
2424
|
return this._def.innerType;
|
|
2425
2425
|
}
|
|
2426
2426
|
};
|
|
2427
|
-
|
|
2428
|
-
innerType:
|
|
2427
|
+
$.create = (a, e) => new $({
|
|
2428
|
+
innerType: a,
|
|
2429
2429
|
typeName: m.ZodOptional,
|
|
2430
2430
|
...y(e)
|
|
2431
2431
|
});
|
|
@@ -2437,12 +2437,12 @@ let V = class extends v {
|
|
|
2437
2437
|
return this._def.innerType;
|
|
2438
2438
|
}
|
|
2439
2439
|
};
|
|
2440
|
-
V.create = (
|
|
2441
|
-
innerType:
|
|
2440
|
+
V.create = (a, e) => new V({
|
|
2441
|
+
innerType: a,
|
|
2442
2442
|
typeName: m.ZodNullable,
|
|
2443
2443
|
...y(e)
|
|
2444
2444
|
});
|
|
2445
|
-
class
|
|
2445
|
+
let le = class extends v {
|
|
2446
2446
|
_parse(e) {
|
|
2447
2447
|
const { ctx: t } = this._processInputParams(e);
|
|
2448
2448
|
let s = t.data;
|
|
@@ -2455,14 +2455,14 @@ class he extends v {
|
|
|
2455
2455
|
removeDefault() {
|
|
2456
2456
|
return this._def.innerType;
|
|
2457
2457
|
}
|
|
2458
|
-
}
|
|
2459
|
-
|
|
2460
|
-
innerType:
|
|
2458
|
+
};
|
|
2459
|
+
le.create = (a, e) => new le({
|
|
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 he extends v {
|
|
2466
2466
|
_parse(e) {
|
|
2467
2467
|
const { ctx: t } = this._processInputParams(e), s = {
|
|
2468
2468
|
...t,
|
|
@@ -2470,26 +2470,26 @@ class pe extends v {
|
|
|
2470
2470
|
...t.common,
|
|
2471
2471
|
issues: []
|
|
2472
2472
|
}
|
|
2473
|
-
},
|
|
2473
|
+
}, n = this._def.innerType._parse({
|
|
2474
2474
|
data: s.data,
|
|
2475
2475
|
path: s.path,
|
|
2476
2476
|
parent: {
|
|
2477
2477
|
...s
|
|
2478
2478
|
}
|
|
2479
2479
|
});
|
|
2480
|
-
return
|
|
2480
|
+
return Y(n) ? n.then((r) => ({
|
|
2481
2481
|
status: "valid",
|
|
2482
|
-
value:
|
|
2482
|
+
value: r.status === "valid" ? r.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
|
})
|
|
2488
2488
|
})) : {
|
|
2489
2489
|
status: "valid",
|
|
2490
|
-
value:
|
|
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,28 +2499,28 @@ class pe extends v {
|
|
|
2499
2499
|
return this._def.innerType;
|
|
2500
2500
|
}
|
|
2501
2501
|
}
|
|
2502
|
-
|
|
2503
|
-
innerType:
|
|
2502
|
+
he.create = (a, e) => new he({
|
|
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 Ee extends v {
|
|
2509
2509
|
_parse(e) {
|
|
2510
2510
|
if (this._getType(e) !== l.nan) {
|
|
2511
2511
|
const t = this._getOrReturnCtx(e);
|
|
2512
|
-
return
|
|
2513
|
-
code:
|
|
2512
|
+
return d(t, {
|
|
2513
|
+
code: u.invalid_type,
|
|
2514
2514
|
expected: l.nan,
|
|
2515
2515
|
received: t.parsedType
|
|
2516
|
-
}),
|
|
2516
|
+
}), _;
|
|
2517
2517
|
}
|
|
2518
2518
|
return { status: "valid", value: e.data };
|
|
2519
2519
|
}
|
|
2520
2520
|
}
|
|
2521
|
-
|
|
2521
|
+
Ee.create = (a) => new Ee({
|
|
2522
2522
|
typeName: m.ZodNaN,
|
|
2523
|
-
...y(
|
|
2523
|
+
...y(a)
|
|
2524
2524
|
});
|
|
2525
2525
|
class ut extends v {
|
|
2526
2526
|
_parse(e) {
|
|
@@ -2535,80 +2535,80 @@ class ut extends v {
|
|
|
2535
2535
|
return this._def.type;
|
|
2536
2536
|
}
|
|
2537
2537
|
}
|
|
2538
|
-
class
|
|
2538
|
+
class me extends v {
|
|
2539
2539
|
_parse(e) {
|
|
2540
2540
|
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2541
2541
|
if (s.common.async)
|
|
2542
2542
|
return (async () => {
|
|
2543
|
-
const
|
|
2543
|
+
const n = await this._def.in._parseAsync({
|
|
2544
2544
|
data: s.data,
|
|
2545
2545
|
path: s.path,
|
|
2546
2546
|
parent: s
|
|
2547
2547
|
});
|
|
2548
|
-
return
|
|
2549
|
-
data:
|
|
2548
|
+
return n.status === "aborted" ? _ : n.status === "dirty" ? (t.dirty(), re(n.value)) : this._def.out._parseAsync({
|
|
2549
|
+
data: n.value,
|
|
2550
2550
|
path: s.path,
|
|
2551
2551
|
parent: s
|
|
2552
2552
|
});
|
|
2553
2553
|
})();
|
|
2554
2554
|
{
|
|
2555
|
-
const
|
|
2555
|
+
const n = this._def.in._parseSync({
|
|
2556
2556
|
data: s.data,
|
|
2557
2557
|
path: s.path,
|
|
2558
2558
|
parent: s
|
|
2559
2559
|
});
|
|
2560
|
-
return
|
|
2560
|
+
return n.status === "aborted" ? _ : n.status === "dirty" ? (t.dirty(), {
|
|
2561
2561
|
status: "dirty",
|
|
2562
|
-
value:
|
|
2562
|
+
value: n.value
|
|
2563
2563
|
}) : this._def.out._parseSync({
|
|
2564
|
-
data:
|
|
2564
|
+
data: n.value,
|
|
2565
2565
|
path: s.path,
|
|
2566
2566
|
parent: s
|
|
2567
2567
|
});
|
|
2568
2568
|
}
|
|
2569
2569
|
}
|
|
2570
2570
|
static create(e, t) {
|
|
2571
|
-
return new
|
|
2571
|
+
return new me({
|
|
2572
2572
|
in: e,
|
|
2573
2573
|
out: t,
|
|
2574
2574
|
typeName: m.ZodPipeline
|
|
2575
2575
|
});
|
|
2576
2576
|
}
|
|
2577
2577
|
}
|
|
2578
|
-
class
|
|
2578
|
+
class pe extends v {
|
|
2579
2579
|
_parse(e) {
|
|
2580
|
-
const t = this._def.innerType._parse(e), s = (
|
|
2581
|
-
return
|
|
2580
|
+
const t = this._def.innerType._parse(e), s = (n) => (L(n) && (n.value = Object.freeze(n.value)), n);
|
|
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
|
-
|
|
2588
|
-
innerType:
|
|
2587
|
+
pe.create = (a, e) => new pe({
|
|
2588
|
+
innerType: a,
|
|
2589
2589
|
typeName: m.ZodReadonly,
|
|
2590
2590
|
...y(e)
|
|
2591
2591
|
});
|
|
2592
2592
|
var m;
|
|
2593
|
-
(function(
|
|
2594
|
-
|
|
2593
|
+
(function(a) {
|
|
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
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
const
|
|
2600
|
-
|
|
2596
|
+
const dt = E.create, lt = oe.create;
|
|
2597
|
+
P.create;
|
|
2598
|
+
T.create;
|
|
2599
|
+
const ht = A.create;
|
|
2600
|
+
X.create;
|
|
2601
2601
|
ee.create;
|
|
2602
|
-
|
|
2603
|
-
const
|
|
2604
|
-
|
|
2602
|
+
q.create;
|
|
2603
|
+
const pt = ue.create;
|
|
2604
|
+
fe.create;
|
|
2605
2605
|
te.create;
|
|
2606
|
-
|
|
2606
|
+
$.create;
|
|
2607
2607
|
V.create;
|
|
2608
|
-
const
|
|
2609
|
-
version:
|
|
2608
|
+
const ft = "1.11.0", mt = {
|
|
2609
|
+
version: ft
|
|
2610
2610
|
};
|
|
2611
|
-
class
|
|
2611
|
+
class _t {
|
|
2612
2612
|
constructor(e) {
|
|
2613
2613
|
this._client = e;
|
|
2614
2614
|
}
|
|
@@ -2627,7 +2627,7 @@ class gt {
|
|
|
2627
2627
|
return e.account;
|
|
2628
2628
|
}
|
|
2629
2629
|
}
|
|
2630
|
-
class
|
|
2630
|
+
class gt {
|
|
2631
2631
|
constructor(e) {
|
|
2632
2632
|
this._client = e;
|
|
2633
2633
|
}
|
|
@@ -2684,9 +2684,7 @@ class yt {
|
|
|
2684
2684
|
* ```
|
|
2685
2685
|
*/
|
|
2686
2686
|
async setDependencies(e) {
|
|
2687
|
-
return await this._client.request("applications.setDependencies", {
|
|
2688
|
-
applicationSpecifiers: e
|
|
2689
|
-
});
|
|
2687
|
+
return await this._client.request("applications.setDependencies", { applicationSpecifiers: e }, { timeout: 0 });
|
|
2690
2688
|
}
|
|
2691
2689
|
/**
|
|
2692
2690
|
* Registers a message interceptor for client messages from sub-applications.
|
|
@@ -2724,7 +2722,7 @@ class yt {
|
|
|
2724
2722
|
this._client._messageInterceptors.set(e, t);
|
|
2725
2723
|
}
|
|
2726
2724
|
}
|
|
2727
|
-
class
|
|
2725
|
+
class yt {
|
|
2728
2726
|
constructor(e) {
|
|
2729
2727
|
this._client = e;
|
|
2730
2728
|
}
|
|
@@ -2747,8 +2745,28 @@ class vt {
|
|
|
2747
2745
|
throw new Error("Failed to get device information");
|
|
2748
2746
|
return e.deviceInformation;
|
|
2749
2747
|
}
|
|
2748
|
+
/**
|
|
2749
|
+
* Retrieves the capabilities of the current device.
|
|
2750
|
+
*
|
|
2751
|
+
* Capabilities indicate what hardware and software features are available on
|
|
2752
|
+
* the device running the application. This can be used to conditionally enable
|
|
2753
|
+
* features based on what the device supports (e.g., MQTT, Bluetooth, WiFi).
|
|
2754
|
+
*
|
|
2755
|
+
* @returns A promise that resolves to an array of device capability strings
|
|
2756
|
+
* @example
|
|
2757
|
+
* const capabilities = await devices.getCapabilities();
|
|
2758
|
+
* if (capabilities.includes('mqtt')) {
|
|
2759
|
+
* // Enable MQTT features
|
|
2760
|
+
* }
|
|
2761
|
+
*/
|
|
2762
|
+
async getCapabilities() {
|
|
2763
|
+
const e = await this._client.request("devices.getCapabilities", {});
|
|
2764
|
+
if (!e.success)
|
|
2765
|
+
throw new Error("Failed to get device capabilities");
|
|
2766
|
+
return e.capabilities;
|
|
2767
|
+
}
|
|
2750
2768
|
}
|
|
2751
|
-
class
|
|
2769
|
+
class vt {
|
|
2752
2770
|
constructor(e) {
|
|
2753
2771
|
this._client = e;
|
|
2754
2772
|
}
|
|
@@ -2762,7 +2780,7 @@ class bt {
|
|
|
2762
2780
|
return (await this._client.unsubscribe("environment.unsubscribeColorScheme", {}, e)).success;
|
|
2763
2781
|
}
|
|
2764
2782
|
}
|
|
2765
|
-
class
|
|
2783
|
+
class bt {
|
|
2766
2784
|
constructor(e) {
|
|
2767
2785
|
this._client = e;
|
|
2768
2786
|
}
|
|
@@ -2807,15 +2825,28 @@ class wt {
|
|
|
2807
2825
|
id: e
|
|
2808
2826
|
})).content;
|
|
2809
2827
|
}
|
|
2828
|
+
/**
|
|
2829
|
+
* Opens a full-screen media picker dialog in the host window.
|
|
2830
|
+
* This allows users to browse folders, view media, and select an item.
|
|
2831
|
+
*
|
|
2832
|
+
* @param options Optional picker options including content type filter and current value
|
|
2833
|
+
* @returns A promise that resolves to the selected media, or null if cancelled
|
|
2834
|
+
*/
|
|
2835
|
+
async openPicker(e) {
|
|
2836
|
+
return (await this._client.request("media.openPicker", {
|
|
2837
|
+
accept: e == null ? void 0 : e.accept,
|
|
2838
|
+
currentValue: e == null ? void 0 : e.currentValue
|
|
2839
|
+
})).selection;
|
|
2840
|
+
}
|
|
2810
2841
|
}
|
|
2811
|
-
class
|
|
2842
|
+
class wt {
|
|
2812
2843
|
constructor(e) {
|
|
2813
2844
|
this._client = e;
|
|
2814
2845
|
}
|
|
2815
2846
|
async fetch(e, t) {
|
|
2816
2847
|
var s;
|
|
2817
|
-
let
|
|
2818
|
-
typeof e == "string" ?
|
|
2848
|
+
let n;
|
|
2849
|
+
typeof e == "string" ? n = e : e instanceof URL ? n = e.toString() : (n = e.url, t || (t = {
|
|
2819
2850
|
method: e.method,
|
|
2820
2851
|
headers: e.headers,
|
|
2821
2852
|
body: e.body,
|
|
@@ -2825,39 +2856,39 @@ class kt {
|
|
|
2825
2856
|
referrer: e.referrer,
|
|
2826
2857
|
integrity: e.integrity
|
|
2827
2858
|
}));
|
|
2828
|
-
let
|
|
2829
|
-
t != null && t.headers && (t.headers instanceof Headers ? t.headers.forEach((
|
|
2830
|
-
|
|
2831
|
-
}) : Array.isArray(t.headers) ? t.headers.forEach(([
|
|
2832
|
-
|
|
2833
|
-
}) :
|
|
2834
|
-
const
|
|
2835
|
-
url:
|
|
2859
|
+
let r = {};
|
|
2860
|
+
t != null && t.headers && (t.headers instanceof Headers ? t.headers.forEach((g, w) => {
|
|
2861
|
+
r[w] = g;
|
|
2862
|
+
}) : Array.isArray(t.headers) ? t.headers.forEach(([g, w]) => {
|
|
2863
|
+
r[g] = w;
|
|
2864
|
+
}) : r = t.headers);
|
|
2865
|
+
const i = await this._client.request("proxy.fetch", {
|
|
2866
|
+
url: n,
|
|
2836
2867
|
method: (t == null ? void 0 : t.method) || "GET",
|
|
2837
|
-
headers:
|
|
2868
|
+
headers: r,
|
|
2838
2869
|
body: (s = t == null ? void 0 : t.body) !== null && s !== void 0 ? s : null
|
|
2839
2870
|
});
|
|
2840
|
-
if (!
|
|
2841
|
-
throw new TypeError(
|
|
2842
|
-
cause:
|
|
2871
|
+
if (!i.success)
|
|
2872
|
+
throw new TypeError(i.errorMessage, {
|
|
2873
|
+
cause: i.errorCause ? Error(i.errorCause) : void 0
|
|
2843
2874
|
});
|
|
2844
|
-
const o = new Headers(
|
|
2845
|
-
status:
|
|
2846
|
-
statusText:
|
|
2875
|
+
const o = new Headers(i.headers), c = {
|
|
2876
|
+
status: i.status,
|
|
2877
|
+
statusText: i.statusText,
|
|
2847
2878
|
headers: o
|
|
2848
2879
|
};
|
|
2849
2880
|
let h = null;
|
|
2850
|
-
if (
|
|
2851
|
-
if (
|
|
2852
|
-
const
|
|
2853
|
-
for (let
|
|
2854
|
-
w[
|
|
2881
|
+
if (i.body !== null && i.body !== void 0)
|
|
2882
|
+
if (i.bodyType === "binary") {
|
|
2883
|
+
const g = atob(i.body), w = new Uint8Array(g.length);
|
|
2884
|
+
for (let S = 0; S < g.length; S++)
|
|
2885
|
+
w[S] = g.charCodeAt(S);
|
|
2855
2886
|
h = w;
|
|
2856
|
-
} else
|
|
2887
|
+
} else i.bodyType === "text" ? h = i.body : i.bodyType === "json" && (h = JSON.stringify(i.body));
|
|
2857
2888
|
return new Response(h, c);
|
|
2858
2889
|
}
|
|
2859
2890
|
}
|
|
2860
|
-
class
|
|
2891
|
+
class kt {
|
|
2861
2892
|
constructor(e) {
|
|
2862
2893
|
this._client = e;
|
|
2863
2894
|
}
|
|
@@ -2871,7 +2902,7 @@ class xt {
|
|
|
2871
2902
|
* @returns A StoreSlice instance for the application scope
|
|
2872
2903
|
*/
|
|
2873
2904
|
get application() {
|
|
2874
|
-
return new
|
|
2905
|
+
return new W("application", "", this._client);
|
|
2875
2906
|
}
|
|
2876
2907
|
/**
|
|
2877
2908
|
* Provides access to the instance store scope.
|
|
@@ -2885,7 +2916,7 @@ class xt {
|
|
|
2885
2916
|
* @returns A StoreSlice instance for the instance scope
|
|
2886
2917
|
*/
|
|
2887
2918
|
get instance() {
|
|
2888
|
-
return new
|
|
2919
|
+
return new W("instance", this._client.applicationInstance, this._client);
|
|
2889
2920
|
}
|
|
2890
2921
|
/**
|
|
2891
2922
|
* Provides access to the device store scope.
|
|
@@ -2900,7 +2931,7 @@ class xt {
|
|
|
2900
2931
|
* @returns A StoreSlice instance for the device scope
|
|
2901
2932
|
*/
|
|
2902
2933
|
get device() {
|
|
2903
|
-
return new
|
|
2934
|
+
return new W("device", this._client.applicationInstance, this._client);
|
|
2904
2935
|
}
|
|
2905
2936
|
/**
|
|
2906
2937
|
* Provides access to the shared store scope with a specified namespace.
|
|
@@ -2916,10 +2947,10 @@ class xt {
|
|
|
2916
2947
|
* @returns A StoreSlice instance for the specified shared namespace
|
|
2917
2948
|
*/
|
|
2918
2949
|
shared(e) {
|
|
2919
|
-
return new
|
|
2950
|
+
return new W("shared", e, this._client);
|
|
2920
2951
|
}
|
|
2921
2952
|
}
|
|
2922
|
-
class
|
|
2953
|
+
class W {
|
|
2923
2954
|
constructor(e, t, s) {
|
|
2924
2955
|
this._kind = e, this._namespace = t, this._client = s;
|
|
2925
2956
|
}
|
|
@@ -3013,7 +3044,7 @@ class K {
|
|
|
3013
3044
|
})).success;
|
|
3014
3045
|
}
|
|
3015
3046
|
}
|
|
3016
|
-
class
|
|
3047
|
+
class xt {
|
|
3017
3048
|
constructor(e) {
|
|
3018
3049
|
this._client = e;
|
|
3019
3050
|
}
|
|
@@ -3036,7 +3067,7 @@ class St {
|
|
|
3036
3067
|
return e.user;
|
|
3037
3068
|
}
|
|
3038
3069
|
}
|
|
3039
|
-
class
|
|
3070
|
+
class St {
|
|
3040
3071
|
constructor(e) {
|
|
3041
3072
|
this._client = e;
|
|
3042
3073
|
}
|
|
@@ -3179,7 +3210,7 @@ class Nt {
|
|
|
3179
3210
|
return t;
|
|
3180
3211
|
}
|
|
3181
3212
|
}
|
|
3182
|
-
class
|
|
3213
|
+
class Nt {
|
|
3183
3214
|
constructor(e) {
|
|
3184
3215
|
this._client = e;
|
|
3185
3216
|
}
|
|
@@ -3219,20 +3250,84 @@ class Ct {
|
|
|
3219
3250
|
* ```
|
|
3220
3251
|
*/
|
|
3221
3252
|
async getRates(e) {
|
|
3222
|
-
var t, s,
|
|
3223
|
-
const
|
|
3224
|
-
if (!
|
|
3225
|
-
throw ((t =
|
|
3226
|
-
return
|
|
3253
|
+
var t, s, n;
|
|
3254
|
+
const r = await this._client.request("currency.getRates", e);
|
|
3255
|
+
if (!r.success || !r.rates)
|
|
3256
|
+
throw ((t = r.error) === null || t === void 0 ? void 0 : t.code) === 201 ? new Error(`Invalid base currency '${e.base}'`) : ((s = r.error) === null || s === void 0 ? void 0 : s.code) === 202 ? new Error(`Invalid target currency symbol '${e.symbols}'`) : new Error(((n = r.error) === null || n === void 0 ? void 0 : n.message) || "Failed to fetch currency rates");
|
|
3257
|
+
return r.rates;
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
class Ct {
|
|
3261
|
+
constructor(e) {
|
|
3262
|
+
this._client = e;
|
|
3263
|
+
}
|
|
3264
|
+
async discover() {
|
|
3265
|
+
const e = await this._client.request("mqtt.discover", {});
|
|
3266
|
+
if (!e.success)
|
|
3267
|
+
throw new Error("Failed to discover MQTT brokers");
|
|
3268
|
+
return e.brokers;
|
|
3269
|
+
}
|
|
3270
|
+
async connect(e, t) {
|
|
3271
|
+
const s = await this._client.request("mqtt.connect", {
|
|
3272
|
+
brokerUrl: e,
|
|
3273
|
+
...t
|
|
3274
|
+
});
|
|
3275
|
+
if (!s.success)
|
|
3276
|
+
throw new Error("Failed to connect to MQTT broker");
|
|
3277
|
+
return s.clientId;
|
|
3278
|
+
}
|
|
3279
|
+
async disconnect(e) {
|
|
3280
|
+
if (!(await this._client.request("mqtt.disconnect", { clientId: e })).success)
|
|
3281
|
+
throw new Error("Failed to disconnect from MQTT broker");
|
|
3282
|
+
}
|
|
3283
|
+
async publish(e, t, s, n) {
|
|
3284
|
+
if (!(await this._client.request("mqtt.publish", {
|
|
3285
|
+
clientId: e,
|
|
3286
|
+
topic: t,
|
|
3287
|
+
payload: s,
|
|
3288
|
+
...n
|
|
3289
|
+
})).success)
|
|
3290
|
+
throw new Error("Failed to publish MQTT message");
|
|
3291
|
+
}
|
|
3292
|
+
async subscribe(e, t, s, n) {
|
|
3293
|
+
return (await this._client.subscribe("mqtt.subscribe", {
|
|
3294
|
+
clientId: e,
|
|
3295
|
+
topic: t,
|
|
3296
|
+
...n
|
|
3297
|
+
}, s)).success;
|
|
3298
|
+
}
|
|
3299
|
+
async unsubscribe(e, t, s) {
|
|
3300
|
+
return (await this._client.unsubscribe("mqtt.unsubscribe", {
|
|
3301
|
+
clientId: e,
|
|
3302
|
+
topic: t
|
|
3303
|
+
}, s)).success;
|
|
3304
|
+
}
|
|
3305
|
+
async getConnectionStatus(e) {
|
|
3306
|
+
const t = await this._client.request("mqtt.getConnectionStatus", {
|
|
3307
|
+
clientId: e
|
|
3308
|
+
});
|
|
3309
|
+
if (!t.success)
|
|
3310
|
+
throw new Error("Failed to get MQTT connection status");
|
|
3311
|
+
return t.status;
|
|
3312
|
+
}
|
|
3313
|
+
async subscribeConnectionStatus(e, t) {
|
|
3314
|
+
return (await this._client.subscribe("mqtt.subscribeConnectionStatus", {
|
|
3315
|
+
clientId: e
|
|
3316
|
+
}, t)).success;
|
|
3317
|
+
}
|
|
3318
|
+
async unsubscribeConnectionStatus(e, t) {
|
|
3319
|
+
return (await this._client.unsubscribe("mqtt.unsubscribeConnectionStatus", {
|
|
3320
|
+
clientId: e
|
|
3321
|
+
}, t)).success;
|
|
3227
3322
|
}
|
|
3228
3323
|
}
|
|
3229
|
-
function
|
|
3230
|
-
return { ...
|
|
3324
|
+
function J(a) {
|
|
3325
|
+
return { ...a, type: "client" };
|
|
3231
3326
|
}
|
|
3232
|
-
const Tt =
|
|
3233
|
-
type:
|
|
3234
|
-
name:
|
|
3235
|
-
data:
|
|
3327
|
+
const Tt = ht({
|
|
3328
|
+
type: pt("bridge"),
|
|
3329
|
+
name: dt(),
|
|
3330
|
+
data: lt()
|
|
3236
3331
|
});
|
|
3237
3332
|
class Zt {
|
|
3238
3333
|
/**
|
|
@@ -3258,11 +3353,11 @@ class Zt {
|
|
|
3258
3353
|
*/
|
|
3259
3354
|
async setRootSettingsNavigation(e) {
|
|
3260
3355
|
var t;
|
|
3261
|
-
const s = this._store.shared("root-settings-navigation"),
|
|
3262
|
-
|
|
3263
|
-
applicationSpecifier:
|
|
3356
|
+
const s = this._store.shared("root-settings-navigation"), n = (t = await s.get("navigation")) !== null && t !== void 0 ? t : {}, r = this._store._client._applicationSpecifier;
|
|
3357
|
+
n[r] = {
|
|
3358
|
+
applicationSpecifier: r,
|
|
3264
3359
|
entries: e.entries
|
|
3265
|
-
}, s.set("navigation",
|
|
3360
|
+
}, s.set("navigation", n);
|
|
3266
3361
|
}
|
|
3267
3362
|
/**
|
|
3268
3363
|
* Retrieves the current navigation entries for this root application.
|
|
@@ -3291,9 +3386,9 @@ class Zt {
|
|
|
3291
3386
|
return (e = await this._store.shared("root-settings-navigation").get("navigation")) !== null && e !== void 0 ? e : {};
|
|
3292
3387
|
}
|
|
3293
3388
|
}
|
|
3294
|
-
const
|
|
3295
|
-
function
|
|
3296
|
-
|
|
3389
|
+
const z = 1e3 * 30, _e = typeof window > "u" && typeof self < "u", U = _e ? self : window;
|
|
3390
|
+
function B(a) {
|
|
3391
|
+
_e ? self.postMessage(a) : U.parent.postMessage(a, "*");
|
|
3297
3392
|
}
|
|
3298
3393
|
class Ot {
|
|
3299
3394
|
/**
|
|
@@ -3321,7 +3416,7 @@ class Ot {
|
|
|
3321
3416
|
* @returns An Accounts instance bound to this client
|
|
3322
3417
|
*/
|
|
3323
3418
|
get accounts() {
|
|
3324
|
-
return new
|
|
3419
|
+
return new _t(this);
|
|
3325
3420
|
}
|
|
3326
3421
|
/**
|
|
3327
3422
|
* Provides access to the users API for retrieving TelemetryOS user information.
|
|
@@ -3335,7 +3430,7 @@ class Ot {
|
|
|
3335
3430
|
* @returns A Users instance bound to this client
|
|
3336
3431
|
*/
|
|
3337
3432
|
get users() {
|
|
3338
|
-
return new
|
|
3433
|
+
return new xt(this);
|
|
3339
3434
|
}
|
|
3340
3435
|
/**
|
|
3341
3436
|
* Provides access to the store API for data persistence with multiple storage scopes.
|
|
@@ -3349,7 +3444,7 @@ class Ot {
|
|
|
3349
3444
|
* @returns A Store instance bound to this client
|
|
3350
3445
|
*/
|
|
3351
3446
|
get store() {
|
|
3352
|
-
return new
|
|
3447
|
+
return new kt(this);
|
|
3353
3448
|
}
|
|
3354
3449
|
/**
|
|
3355
3450
|
* Provides access to the applications API for discovering other TelemetryOS applications.
|
|
@@ -3363,7 +3458,7 @@ class Ot {
|
|
|
3363
3458
|
* @returns An Applications instance bound to this client
|
|
3364
3459
|
*/
|
|
3365
3460
|
get applications() {
|
|
3366
|
-
return new
|
|
3461
|
+
return new gt(this);
|
|
3367
3462
|
}
|
|
3368
3463
|
/**
|
|
3369
3464
|
* Provides access to the media API for working with content hosted on the TelemetryOS platform.
|
|
@@ -3378,7 +3473,7 @@ class Ot {
|
|
|
3378
3473
|
* @returns A Media instance bound to this client
|
|
3379
3474
|
*/
|
|
3380
3475
|
get media() {
|
|
3381
|
-
return new
|
|
3476
|
+
return new bt(this);
|
|
3382
3477
|
}
|
|
3383
3478
|
/**
|
|
3384
3479
|
* Provides access to the proxy API for fetching third-party content through the TelemetryOS API.
|
|
@@ -3392,7 +3487,7 @@ class Ot {
|
|
|
3392
3487
|
* @returns A Proxy instance bound to this client
|
|
3393
3488
|
*/
|
|
3394
3489
|
get proxy() {
|
|
3395
|
-
return new
|
|
3490
|
+
return new wt(this);
|
|
3396
3491
|
}
|
|
3397
3492
|
/**
|
|
3398
3493
|
* Provides access to the devices API for interacting with the current device.
|
|
@@ -3407,7 +3502,7 @@ class Ot {
|
|
|
3407
3502
|
* @returns A Devices instance bound to this client
|
|
3408
3503
|
*/
|
|
3409
3504
|
get devices() {
|
|
3410
|
-
return new
|
|
3505
|
+
return new yt(this);
|
|
3411
3506
|
}
|
|
3412
3507
|
/**
|
|
3413
3508
|
* Provides access to the root settings navigation API for TelemetryOS administration UI integration.
|
|
@@ -3439,7 +3534,7 @@ class Ot {
|
|
|
3439
3534
|
* @returns A Weather instance bound to this client
|
|
3440
3535
|
*/
|
|
3441
3536
|
get weather() {
|
|
3442
|
-
return new
|
|
3537
|
+
return new St(this);
|
|
3443
3538
|
}
|
|
3444
3539
|
/**
|
|
3445
3540
|
* Provides access to the currency API for retrieving currency exchange rates.
|
|
@@ -3453,7 +3548,7 @@ class Ot {
|
|
|
3453
3548
|
* @returns A Currency instance bound to this client
|
|
3454
3549
|
*/
|
|
3455
3550
|
get currency() {
|
|
3456
|
-
return new
|
|
3551
|
+
return new Nt(this);
|
|
3457
3552
|
}
|
|
3458
3553
|
/**
|
|
3459
3554
|
* Provides access to the environment API for accessing environment settings.
|
|
@@ -3467,7 +3562,10 @@ class Ot {
|
|
|
3467
3562
|
* @returns An Environment instance bound to this client
|
|
3468
3563
|
*/
|
|
3469
3564
|
get environment() {
|
|
3470
|
-
return new
|
|
3565
|
+
return new vt(this);
|
|
3566
|
+
}
|
|
3567
|
+
get mqtt() {
|
|
3568
|
+
return new Ct(this);
|
|
3471
3569
|
}
|
|
3472
3570
|
get applicationName() {
|
|
3473
3571
|
return this._applicationName;
|
|
@@ -3495,46 +3593,46 @@ class Ot {
|
|
|
3495
3593
|
*/
|
|
3496
3594
|
bind() {
|
|
3497
3595
|
var e, t, s;
|
|
3498
|
-
const
|
|
3499
|
-
if (this._applicationInstance = (e =
|
|
3596
|
+
const n = new URL(U.location.href), r = n.searchParams;
|
|
3597
|
+
if (this._applicationInstance = (e = r.get("applicationInstance")) !== null && e !== void 0 ? e : "", !this._applicationInstance)
|
|
3500
3598
|
throw new Error("Missing applicationInstance query parameter");
|
|
3501
|
-
if (this._applicationSpecifier = (t =
|
|
3502
|
-
const
|
|
3503
|
-
this._applicationSpecifier = (s =
|
|
3599
|
+
if (this._applicationSpecifier = (t = r.get("applicationSpecifier")) !== null && t !== void 0 ? t : "", !this._applicationSpecifier) {
|
|
3600
|
+
const i = n.hostname.split(".");
|
|
3601
|
+
this._applicationSpecifier = (s = i[0]) !== null && s !== void 0 ? s : "";
|
|
3504
3602
|
}
|
|
3505
3603
|
if (!this._applicationSpecifier || this._applicationSpecifier.length !== 40)
|
|
3506
3604
|
throw new Error(`Invalid applicationSpecifier: expected 40-character hash, got "${this._applicationSpecifier}"`);
|
|
3507
|
-
this._windowMessageHandler = (
|
|
3508
|
-
if (
|
|
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")
|
|
3509
3607
|
return;
|
|
3510
3608
|
let o;
|
|
3511
|
-
if (
|
|
3512
|
-
const c = this._messageInterceptors.get(
|
|
3609
|
+
if (i.data.type === "client") {
|
|
3610
|
+
const c = this._messageInterceptors.get(i.data.name);
|
|
3513
3611
|
if (!c) {
|
|
3514
|
-
|
|
3612
|
+
B(i.data);
|
|
3515
3613
|
return;
|
|
3516
3614
|
}
|
|
3517
|
-
o = { ...c(
|
|
3615
|
+
o = { ...c(i.data.data), type: "bridge" };
|
|
3518
3616
|
}
|
|
3519
3617
|
if (!o) {
|
|
3520
|
-
const c = Tt.safeParse(
|
|
3618
|
+
const c = Tt.safeParse(i.data);
|
|
3521
3619
|
if (!c.success)
|
|
3522
3620
|
return;
|
|
3523
3621
|
o = c.data;
|
|
3524
|
-
const h = this._onHandlers.get(o.name),
|
|
3622
|
+
const h = this._onHandlers.get(o.name), g = this._onceHandlers.get(o.name);
|
|
3525
3623
|
if (h)
|
|
3526
3624
|
for (const w of h)
|
|
3527
3625
|
w(o.data);
|
|
3528
|
-
if (
|
|
3529
|
-
for (const w of
|
|
3626
|
+
if (g) {
|
|
3627
|
+
for (const w of g)
|
|
3530
3628
|
w(o.data);
|
|
3531
3629
|
this._onceHandlers.delete(o.name);
|
|
3532
3630
|
}
|
|
3533
3631
|
}
|
|
3534
|
-
if (!
|
|
3632
|
+
if (!_e)
|
|
3535
3633
|
for (let c = 0; c < window.frames.length; c += 1)
|
|
3536
3634
|
window.frames[c].postMessage(o, "*");
|
|
3537
|
-
},
|
|
3635
|
+
}, U.addEventListener("message", this._windowMessageHandler);
|
|
3538
3636
|
}
|
|
3539
3637
|
/**
|
|
3540
3638
|
* Removes the message event listener and cleans up resources.
|
|
@@ -3550,7 +3648,7 @@ class Ot {
|
|
|
3550
3648
|
* of managing their own Client instances.
|
|
3551
3649
|
*/
|
|
3552
3650
|
unbind() {
|
|
3553
|
-
this._windowMessageHandler &&
|
|
3651
|
+
this._windowMessageHandler && U.removeEventListener("message", this._windowMessageHandler);
|
|
3554
3652
|
}
|
|
3555
3653
|
/**
|
|
3556
3654
|
* Sends a one-way message to the TelemetryOS platform.
|
|
@@ -3566,7 +3664,7 @@ class Ot {
|
|
|
3566
3664
|
* @param data The data payload to include with the message
|
|
3567
3665
|
*/
|
|
3568
3666
|
send(e, t) {
|
|
3569
|
-
const s =
|
|
3667
|
+
const s = J({
|
|
3570
3668
|
telemetrySdkVersion: G,
|
|
3571
3669
|
applicationName: this._applicationName,
|
|
3572
3670
|
applicationSpecifier: this._applicationSpecifier,
|
|
@@ -3574,7 +3672,7 @@ class Ot {
|
|
|
3574
3672
|
name: e,
|
|
3575
3673
|
data: t
|
|
3576
3674
|
});
|
|
3577
|
-
|
|
3675
|
+
B(s);
|
|
3578
3676
|
}
|
|
3579
3677
|
/**
|
|
3580
3678
|
* Sends a message to the TelemetryOS platform and waits for a response.
|
|
@@ -3590,100 +3688,107 @@ class Ot {
|
|
|
3590
3688
|
* @template D The expected type of the response data
|
|
3591
3689
|
* @param name The name of the message type (endpoint) to request
|
|
3592
3690
|
* @param data The data payload to include with the request
|
|
3691
|
+
* @param options Optional configuration for this request
|
|
3692
|
+
* @param options.timeout Override the default timeout in milliseconds. Set to 0 to disable timeout.
|
|
3593
3693
|
* @returns A promise that resolves with the response data when received
|
|
3594
3694
|
* @throws {Error} If the request times out
|
|
3595
3695
|
*/
|
|
3596
|
-
request(e, t) {
|
|
3597
|
-
|
|
3696
|
+
request(e, t, s) {
|
|
3697
|
+
var n;
|
|
3698
|
+
const r = Q(), i = J({
|
|
3598
3699
|
telemetrySdkVersion: G,
|
|
3599
3700
|
applicationName: this._applicationName,
|
|
3600
3701
|
applicationSpecifier: this._applicationSpecifier,
|
|
3601
3702
|
applicationInstance: this._applicationInstance,
|
|
3602
3703
|
name: e,
|
|
3603
3704
|
data: t,
|
|
3604
|
-
responseName:
|
|
3705
|
+
responseName: r
|
|
3605
3706
|
});
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3707
|
+
B(i);
|
|
3708
|
+
const o = (n = s == null ? void 0 : s.timeout) !== null && n !== void 0 ? n : z;
|
|
3709
|
+
let c = !1, h;
|
|
3710
|
+
const g = new Promise((S) => {
|
|
3711
|
+
h = (F) => {
|
|
3712
|
+
c || S(F);
|
|
3713
|
+
}, this.once(r, h);
|
|
3714
|
+
});
|
|
3715
|
+
if (o === 0)
|
|
3716
|
+
return g;
|
|
3717
|
+
const w = new Promise((S, F) => {
|
|
3718
|
+
const Z = new Error(`${e} message request with response name of ${r} timed out after ${o}`);
|
|
3610
3719
|
setTimeout(() => {
|
|
3611
|
-
|
|
3612
|
-
},
|
|
3613
|
-
}), c = new Promise((h) => {
|
|
3614
|
-
r = (_) => {
|
|
3615
|
-
i || h(_);
|
|
3616
|
-
}, this.once(s, h);
|
|
3720
|
+
c = !0, this.off(r, h), F(Z);
|
|
3721
|
+
}, o);
|
|
3617
3722
|
});
|
|
3618
|
-
return Promise.race([
|
|
3723
|
+
return Promise.race([w, g]);
|
|
3619
3724
|
}
|
|
3620
3725
|
async subscribe(e, t, s) {
|
|
3621
|
-
let
|
|
3622
|
-
typeof t == "function" ?
|
|
3623
|
-
const
|
|
3726
|
+
let n, r;
|
|
3727
|
+
typeof t == "function" ? r = t : (n = t, r = s);
|
|
3728
|
+
const i = Q(), o = Q();
|
|
3624
3729
|
let c = this._subscriptionNamesBySubjectName.get(e);
|
|
3625
|
-
c || (c = [], this._subscriptionNamesBySubjectName.set(e, c)), c.push(
|
|
3626
|
-
const h =
|
|
3730
|
+
c || (c = [], this._subscriptionNamesBySubjectName.set(e, c)), c.push(i), this._subscriptionNamesByHandler.set(r, i), this.on(i, r);
|
|
3731
|
+
const h = J({
|
|
3627
3732
|
telemetrySdkVersion: G,
|
|
3628
3733
|
applicationName: this._applicationName,
|
|
3629
3734
|
applicationSpecifier: this._applicationSpecifier,
|
|
3630
3735
|
applicationInstance: this._applicationInstance,
|
|
3631
3736
|
name: e,
|
|
3632
|
-
data:
|
|
3737
|
+
data: n,
|
|
3633
3738
|
responseName: o,
|
|
3634
|
-
subscriptionName:
|
|
3739
|
+
subscriptionName: i
|
|
3635
3740
|
});
|
|
3636
|
-
|
|
3637
|
-
let
|
|
3638
|
-
const
|
|
3639
|
-
const
|
|
3741
|
+
B(h);
|
|
3742
|
+
let g = !1, w;
|
|
3743
|
+
const S = new Promise((Z, R) => {
|
|
3744
|
+
const se = new Error(`${e} subscribe request with subscription name of ${i} and response name of ${o} timed out after ${z}`);
|
|
3640
3745
|
setTimeout(() => {
|
|
3641
|
-
|
|
3642
|
-
},
|
|
3643
|
-
}),
|
|
3644
|
-
w = (
|
|
3645
|
-
|
|
3646
|
-
}, this.on(o,
|
|
3746
|
+
g = !0, this.off(o, w), R(se);
|
|
3747
|
+
}, z);
|
|
3748
|
+
}), F = new Promise((Z) => {
|
|
3749
|
+
w = (R) => {
|
|
3750
|
+
g || Z(R);
|
|
3751
|
+
}, this.on(o, Z);
|
|
3647
3752
|
});
|
|
3648
|
-
return Promise.race([
|
|
3753
|
+
return Promise.race([S, F]);
|
|
3649
3754
|
}
|
|
3650
3755
|
async unsubscribe(e, t, s) {
|
|
3651
|
-
let
|
|
3652
|
-
typeof t == "function" ?
|
|
3653
|
-
const
|
|
3756
|
+
let n, r;
|
|
3757
|
+
typeof t == "function" ? r = t : (n = t, r = s);
|
|
3758
|
+
const i = Q();
|
|
3654
3759
|
let o = [];
|
|
3655
|
-
if (
|
|
3656
|
-
const c = this._subscriptionNamesByHandler.get(
|
|
3760
|
+
if (r) {
|
|
3761
|
+
const c = this._subscriptionNamesByHandler.get(r);
|
|
3657
3762
|
if (!c)
|
|
3658
3763
|
return { success: !1 };
|
|
3659
|
-
o = [c], this._subscriptionNamesByHandler.delete(
|
|
3764
|
+
o = [c], this._subscriptionNamesByHandler.delete(r);
|
|
3660
3765
|
} else if (!this._subscriptionNamesBySubjectName.get(e))
|
|
3661
3766
|
return { success: !1 };
|
|
3662
3767
|
for await (const c of o) {
|
|
3663
|
-
this.off(c,
|
|
3664
|
-
const h =
|
|
3768
|
+
this.off(c, r);
|
|
3769
|
+
const h = J({
|
|
3665
3770
|
telemetrySdkVersion: G,
|
|
3666
3771
|
applicationInstance: this._applicationInstance,
|
|
3667
3772
|
applicationName: this._applicationName,
|
|
3668
3773
|
applicationSpecifier: this._applicationSpecifier,
|
|
3669
3774
|
name: e,
|
|
3670
|
-
data:
|
|
3671
|
-
responseName:
|
|
3775
|
+
data: n,
|
|
3776
|
+
responseName: i,
|
|
3672
3777
|
unsubscribeName: c
|
|
3673
3778
|
});
|
|
3674
|
-
|
|
3675
|
-
let
|
|
3676
|
-
const
|
|
3677
|
-
const
|
|
3779
|
+
B(h);
|
|
3780
|
+
let g = !1, w;
|
|
3781
|
+
const S = new Promise((Z, R) => {
|
|
3782
|
+
const se = new Error(`${e} unsubscribe request with unsubscribe name of ${c} and response name of ${i} timed out after ${z}`);
|
|
3678
3783
|
setTimeout(() => {
|
|
3679
|
-
|
|
3680
|
-
},
|
|
3681
|
-
}),
|
|
3682
|
-
w = (
|
|
3683
|
-
|
|
3684
|
-
}, this.once(
|
|
3784
|
+
g = !0, this.off(i, w), R(se);
|
|
3785
|
+
}, z);
|
|
3786
|
+
}), F = new Promise((Z) => {
|
|
3787
|
+
w = (R) => {
|
|
3788
|
+
g || Z(R);
|
|
3789
|
+
}, this.once(i, Z);
|
|
3685
3790
|
});
|
|
3686
|
-
if (!(await Promise.race([
|
|
3791
|
+
if (!(await Promise.race([S, F])).success)
|
|
3687
3792
|
return { success: !1 };
|
|
3688
3793
|
}
|
|
3689
3794
|
return { success: !0 };
|
|
@@ -3707,8 +3812,8 @@ class Ot {
|
|
|
3707
3812
|
*/
|
|
3708
3813
|
on(e, t) {
|
|
3709
3814
|
var s;
|
|
3710
|
-
const
|
|
3711
|
-
|
|
3815
|
+
const n = (s = this._onHandlers.get(e)) !== null && s !== void 0 ? s : [];
|
|
3816
|
+
n.length === 0 && this._onHandlers.set(e, n), n.push(t);
|
|
3712
3817
|
}
|
|
3713
3818
|
/**
|
|
3714
3819
|
* Registers a one-time handler for a specific message type.
|
|
@@ -3726,8 +3831,8 @@ class Ot {
|
|
|
3726
3831
|
*/
|
|
3727
3832
|
once(e, t) {
|
|
3728
3833
|
var s;
|
|
3729
|
-
const
|
|
3730
|
-
|
|
3834
|
+
const n = (s = this._onceHandlers.get(e)) !== null && s !== void 0 ? s : [];
|
|
3835
|
+
n.length === 0 && this._onceHandlers.set(e, n), n.push(t);
|
|
3731
3836
|
}
|
|
3732
3837
|
/**
|
|
3733
3838
|
* Removes previously registered message handlers.
|
|
@@ -3745,25 +3850,25 @@ class Ot {
|
|
|
3745
3850
|
* all handlers for this message type will be removed.
|
|
3746
3851
|
*/
|
|
3747
3852
|
off(e, t) {
|
|
3748
|
-
const s = this._onHandlers.get(e),
|
|
3749
|
-
if (!(!s && !
|
|
3853
|
+
const s = this._onHandlers.get(e), n = this._onceHandlers.get(e);
|
|
3854
|
+
if (!(!s && !n)) {
|
|
3750
3855
|
if (s) {
|
|
3751
|
-
for (let
|
|
3752
|
-
t && s[
|
|
3856
|
+
for (let r = 0; r < s.length; r += 1)
|
|
3857
|
+
t && s[r] !== t || (s.splice(r, 1), r -= 1);
|
|
3753
3858
|
s.length === 0 && this._onHandlers.delete(e);
|
|
3754
3859
|
}
|
|
3755
|
-
if (
|
|
3756
|
-
for (let
|
|
3757
|
-
t &&
|
|
3758
|
-
|
|
3860
|
+
if (n) {
|
|
3861
|
+
for (let r = 0; r < n.length; r += 1)
|
|
3862
|
+
t && n[r] !== t || (n.splice(r, 1), r -= 1);
|
|
3863
|
+
n.length === 0 && this._onceHandlers.delete(e);
|
|
3759
3864
|
}
|
|
3760
3865
|
}
|
|
3761
3866
|
}
|
|
3762
3867
|
}
|
|
3763
|
-
function
|
|
3868
|
+
function Q() {
|
|
3764
3869
|
return Math.random().toString(36).slice(2, 9);
|
|
3765
3870
|
}
|
|
3766
|
-
const G =
|
|
3871
|
+
const G = mt.version;
|
|
3767
3872
|
class At {
|
|
3768
3873
|
constructor(e) {
|
|
3769
3874
|
this._client = e;
|
|
@@ -3813,7 +3918,7 @@ class At {
|
|
|
3813
3918
|
return !0;
|
|
3814
3919
|
}
|
|
3815
3920
|
}
|
|
3816
|
-
class
|
|
3921
|
+
class It {
|
|
3817
3922
|
constructor(e) {
|
|
3818
3923
|
this._client = e;
|
|
3819
3924
|
}
|
|
@@ -3869,118 +3974,123 @@ class Et {
|
|
|
3869
3974
|
return !0;
|
|
3870
3975
|
}
|
|
3871
3976
|
}
|
|
3872
|
-
class
|
|
3977
|
+
class Et extends Ot {
|
|
3873
3978
|
get playlist() {
|
|
3874
|
-
return new
|
|
3979
|
+
return new It(this);
|
|
3875
3980
|
}
|
|
3876
3981
|
get overrides() {
|
|
3877
3982
|
return new At(this);
|
|
3878
3983
|
}
|
|
3879
3984
|
}
|
|
3880
3985
|
let f = null;
|
|
3881
|
-
function
|
|
3986
|
+
function Bt() {
|
|
3882
3987
|
return f;
|
|
3883
3988
|
}
|
|
3884
|
-
function
|
|
3885
|
-
f = new
|
|
3989
|
+
function Ut(a) {
|
|
3990
|
+
f = new Et(a), f.bind();
|
|
3886
3991
|
}
|
|
3887
|
-
function
|
|
3992
|
+
function Ht() {
|
|
3888
3993
|
f == null || f.unbind(), f = null;
|
|
3889
3994
|
}
|
|
3890
|
-
function
|
|
3891
|
-
return k(f), f.on(...
|
|
3995
|
+
function Kt(...a) {
|
|
3996
|
+
return k(f), f.on(...a);
|
|
3892
3997
|
}
|
|
3893
|
-
function
|
|
3894
|
-
return k(f), f.once(...
|
|
3998
|
+
function Wt(...a) {
|
|
3999
|
+
return k(f), f.once(...a);
|
|
3895
4000
|
}
|
|
3896
|
-
function
|
|
3897
|
-
return k(f), f.off(...
|
|
4001
|
+
function Jt(...a) {
|
|
4002
|
+
return k(f), f.off(...a);
|
|
3898
4003
|
}
|
|
3899
|
-
function
|
|
3900
|
-
return k(f), f.send(...
|
|
4004
|
+
function Qt(...a) {
|
|
4005
|
+
return k(f), f.send(...a);
|
|
3901
4006
|
}
|
|
3902
|
-
function
|
|
3903
|
-
return k(f), f.request(...
|
|
4007
|
+
function Gt(...a) {
|
|
4008
|
+
return k(f), f.request(...a);
|
|
3904
4009
|
}
|
|
3905
|
-
function
|
|
3906
|
-
return k(f), f.subscribe(...
|
|
4010
|
+
function Yt(...a) {
|
|
4011
|
+
return k(f), f.subscribe(...a);
|
|
3907
4012
|
}
|
|
3908
|
-
function
|
|
3909
|
-
return k(f), f.unsubscribe(...
|
|
4013
|
+
function Xt(...a) {
|
|
4014
|
+
return k(f), f.unsubscribe(...a);
|
|
3910
4015
|
}
|
|
3911
|
-
function
|
|
4016
|
+
function es() {
|
|
3912
4017
|
return k(f), f.store;
|
|
3913
4018
|
}
|
|
3914
|
-
function
|
|
4019
|
+
function ts() {
|
|
3915
4020
|
return k(f), f.applications;
|
|
3916
4021
|
}
|
|
3917
|
-
function
|
|
4022
|
+
function ss() {
|
|
3918
4023
|
return k(f), f.media;
|
|
3919
4024
|
}
|
|
3920
|
-
function
|
|
4025
|
+
function ns() {
|
|
3921
4026
|
return k(f), f.accounts;
|
|
3922
4027
|
}
|
|
3923
|
-
function
|
|
4028
|
+
function as() {
|
|
3924
4029
|
return k(f), f.users;
|
|
3925
4030
|
}
|
|
3926
|
-
function
|
|
4031
|
+
function rs() {
|
|
3927
4032
|
return k(f), f.devices;
|
|
3928
4033
|
}
|
|
3929
|
-
function
|
|
4034
|
+
function is() {
|
|
3930
4035
|
return k(f), f.proxy;
|
|
3931
4036
|
}
|
|
3932
|
-
function
|
|
4037
|
+
function os() {
|
|
3933
4038
|
return k(f), f.weather;
|
|
3934
4039
|
}
|
|
3935
|
-
function
|
|
4040
|
+
function cs() {
|
|
3936
4041
|
return k(f), f.currency;
|
|
3937
4042
|
}
|
|
3938
|
-
function
|
|
4043
|
+
function us() {
|
|
3939
4044
|
return k(f), f.environment;
|
|
3940
4045
|
}
|
|
3941
|
-
function
|
|
4046
|
+
function ds() {
|
|
3942
4047
|
return k(f), f.playlist;
|
|
3943
4048
|
}
|
|
3944
|
-
function
|
|
4049
|
+
function ls() {
|
|
3945
4050
|
return k(f), f.overrides;
|
|
3946
4051
|
}
|
|
3947
|
-
function
|
|
3948
|
-
|
|
4052
|
+
function hs() {
|
|
4053
|
+
return k(f), f.mqtt;
|
|
4054
|
+
}
|
|
4055
|
+
function k(a) {
|
|
4056
|
+
if (!a)
|
|
3949
4057
|
throw new Error("SDK is not configured");
|
|
3950
4058
|
}
|
|
3951
4059
|
export {
|
|
3952
|
-
|
|
3953
|
-
|
|
3954
|
-
|
|
3955
|
-
|
|
3956
|
-
|
|
3957
|
-
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
|
|
3967
|
-
|
|
3968
|
-
|
|
3969
|
-
|
|
3970
|
-
|
|
3971
|
-
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
4060
|
+
_t as Accounts,
|
|
4061
|
+
gt as Applications,
|
|
4062
|
+
Nt as Currency,
|
|
4063
|
+
yt as Devices,
|
|
4064
|
+
vt as Environment,
|
|
4065
|
+
bt as Media,
|
|
4066
|
+
Ct as Mqtt,
|
|
4067
|
+
wt as Proxy,
|
|
4068
|
+
kt as Store,
|
|
4069
|
+
W as StoreSlice,
|
|
4070
|
+
xt as Users,
|
|
4071
|
+
St as Weather,
|
|
4072
|
+
ns as accounts,
|
|
4073
|
+
ts as applications,
|
|
4074
|
+
Ut as configure,
|
|
4075
|
+
cs as currency,
|
|
4076
|
+
Ht as destroy,
|
|
4077
|
+
rs as devices,
|
|
4078
|
+
us as environment,
|
|
4079
|
+
Bt as globalClient,
|
|
4080
|
+
ss as media,
|
|
4081
|
+
hs as mqtt,
|
|
4082
|
+
Jt as off,
|
|
4083
|
+
Kt as on,
|
|
4084
|
+
Wt as once,
|
|
4085
|
+
ls as overrides,
|
|
4086
|
+
ds as playlist,
|
|
4087
|
+
is as proxy,
|
|
4088
|
+
Gt as request,
|
|
4089
|
+
Qt as send,
|
|
4090
|
+
es as store,
|
|
4091
|
+
Yt as subscribe,
|
|
3982
4092
|
G as telemetrySdkVersion,
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
4093
|
+
Xt as unsubscribe,
|
|
4094
|
+
as as users,
|
|
4095
|
+
os as weather
|
|
3986
4096
|
};
|