@telemetryos/root-sdk 1.13.1 → 1.14.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 +17 -0
- package/dist/client.d.ts +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +2885 -261
- package/package.json +2 -6
- package/dist/bridge-message-formatter.d.ts +0 -5
- package/dist/bridge-message-validator.d.ts +0 -14
- package/dist/bridge.cjs +0 -1
- package/dist/bridge.d.ts +0 -45
- package/dist/bridge.js +0 -51
- package/dist/client-message-formatter.d.ts +0 -5
- package/dist/client-message-validator.d.ts +0 -32
- package/dist/types-CCzf8sMT.js +0 -2613
- package/dist/types-mYnxD5LM.cjs +0 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
version: M
|
|
1
|
+
const qe = "1.14.0", Me = {
|
|
2
|
+
version: qe
|
|
4
3
|
};
|
|
5
|
-
class
|
|
4
|
+
class Le {
|
|
6
5
|
constructor(e) {
|
|
7
6
|
this._client = e;
|
|
8
7
|
}
|
|
@@ -21,7 +20,7 @@ class R {
|
|
|
21
20
|
return e.account;
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
|
-
class
|
|
23
|
+
class He {
|
|
25
24
|
constructor(e) {
|
|
26
25
|
this._client = e;
|
|
27
26
|
}
|
|
@@ -116,7 +115,7 @@ class A {
|
|
|
116
115
|
this._client._messageInterceptors.set(e, t);
|
|
117
116
|
}
|
|
118
117
|
}
|
|
119
|
-
class
|
|
118
|
+
class ze {
|
|
120
119
|
constructor(e) {
|
|
121
120
|
this._client = e;
|
|
122
121
|
}
|
|
@@ -160,7 +159,7 @@ class B {
|
|
|
160
159
|
return e.capabilities;
|
|
161
160
|
}
|
|
162
161
|
}
|
|
163
|
-
class
|
|
162
|
+
class De {
|
|
164
163
|
constructor(e) {
|
|
165
164
|
this._client = e;
|
|
166
165
|
}
|
|
@@ -174,7 +173,7 @@ class $ {
|
|
|
174
173
|
return (await this._client.unsubscribe("environment.unsubscribeColorScheme", {}, e)).success;
|
|
175
174
|
}
|
|
176
175
|
}
|
|
177
|
-
class
|
|
176
|
+
class Ve {
|
|
178
177
|
constructor(e) {
|
|
179
178
|
this._client = e;
|
|
180
179
|
}
|
|
@@ -233,7 +232,7 @@ class L {
|
|
|
233
232
|
})).selection;
|
|
234
233
|
}
|
|
235
234
|
}
|
|
236
|
-
class
|
|
235
|
+
class Be {
|
|
237
236
|
constructor(e) {
|
|
238
237
|
this._client = e;
|
|
239
238
|
}
|
|
@@ -250,39 +249,39 @@ class x {
|
|
|
250
249
|
referrer: e.referrer,
|
|
251
250
|
integrity: e.integrity
|
|
252
251
|
}));
|
|
253
|
-
let
|
|
254
|
-
t != null && t.headers && (t.headers instanceof Headers ? t.headers.forEach((
|
|
255
|
-
|
|
256
|
-
}) : Array.isArray(t.headers) ? t.headers.forEach(([
|
|
257
|
-
|
|
258
|
-
}) :
|
|
259
|
-
const
|
|
252
|
+
let r = {};
|
|
253
|
+
t != null && t.headers && (t.headers instanceof Headers ? t.headers.forEach((g, w) => {
|
|
254
|
+
r[w] = g;
|
|
255
|
+
}) : Array.isArray(t.headers) ? t.headers.forEach(([g, w]) => {
|
|
256
|
+
r[g] = w;
|
|
257
|
+
}) : r = t.headers);
|
|
258
|
+
const i = await this._client.request("proxy.fetch", {
|
|
260
259
|
url: n,
|
|
261
260
|
method: (t == null ? void 0 : t.method) || "GET",
|
|
262
|
-
headers:
|
|
261
|
+
headers: r,
|
|
263
262
|
body: (s = t == null ? void 0 : t.body) !== null && s !== void 0 ? s : null
|
|
264
263
|
});
|
|
265
|
-
if (!
|
|
266
|
-
throw new TypeError(
|
|
267
|
-
cause:
|
|
264
|
+
if (!i.success)
|
|
265
|
+
throw new TypeError(i.errorMessage, {
|
|
266
|
+
cause: i.errorCause ? Error(i.errorCause) : void 0
|
|
268
267
|
});
|
|
269
|
-
const
|
|
270
|
-
status:
|
|
271
|
-
statusText:
|
|
272
|
-
headers:
|
|
268
|
+
const o = new Headers(i.headers), c = {
|
|
269
|
+
status: i.status,
|
|
270
|
+
statusText: i.statusText,
|
|
271
|
+
headers: o
|
|
273
272
|
};
|
|
274
|
-
let
|
|
275
|
-
if (
|
|
276
|
-
if (
|
|
277
|
-
const
|
|
278
|
-
for (let
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
} else
|
|
282
|
-
return new Response(
|
|
273
|
+
let l = null;
|
|
274
|
+
if (i.body !== null && i.body !== void 0)
|
|
275
|
+
if (i.bodyType === "binary") {
|
|
276
|
+
const g = atob(i.body), w = new Uint8Array(g.length);
|
|
277
|
+
for (let T = 0; T < g.length; T++)
|
|
278
|
+
w[T] = g.charCodeAt(T);
|
|
279
|
+
l = w;
|
|
280
|
+
} else i.bodyType === "text" ? l = i.body : i.bodyType === "json" && (l = JSON.stringify(i.body));
|
|
281
|
+
return new Response(l, c);
|
|
283
282
|
}
|
|
284
283
|
}
|
|
285
|
-
class
|
|
284
|
+
class Ue {
|
|
286
285
|
constructor(e) {
|
|
287
286
|
this._client = e;
|
|
288
287
|
}
|
|
@@ -296,7 +295,7 @@ class j {
|
|
|
296
295
|
* @returns A StoreSlice instance for the application scope
|
|
297
296
|
*/
|
|
298
297
|
get application() {
|
|
299
|
-
return new
|
|
298
|
+
return new G("application", void 0, this._client);
|
|
300
299
|
}
|
|
301
300
|
/**
|
|
302
301
|
* Provides access to the instance store scope.
|
|
@@ -308,7 +307,7 @@ class j {
|
|
|
308
307
|
* @returns A StoreSlice instance for the instance scope
|
|
309
308
|
*/
|
|
310
309
|
get instance() {
|
|
311
|
-
return new
|
|
310
|
+
return new G("instance", this._client.applicationInstance, this._client);
|
|
312
311
|
}
|
|
313
312
|
/**
|
|
314
313
|
* Provides access to the device store scope.
|
|
@@ -323,7 +322,7 @@ class j {
|
|
|
323
322
|
* @returns A StoreSlice instance for the device scope
|
|
324
323
|
*/
|
|
325
324
|
get device() {
|
|
326
|
-
return new
|
|
325
|
+
return new G("device", this._client.deviceId, this._client);
|
|
327
326
|
}
|
|
328
327
|
/**
|
|
329
328
|
* Provides access to the shared store scope with a specified namespace.
|
|
@@ -339,10 +338,10 @@ class j {
|
|
|
339
338
|
* @returns A StoreSlice instance for the specified shared namespace
|
|
340
339
|
*/
|
|
341
340
|
shared(e) {
|
|
342
|
-
return new
|
|
341
|
+
return new G("shared", e, this._client);
|
|
343
342
|
}
|
|
344
343
|
}
|
|
345
|
-
class
|
|
344
|
+
class G {
|
|
346
345
|
constructor(e, t, s) {
|
|
347
346
|
this._kind = e, this._namespace = t, this._client = s;
|
|
348
347
|
}
|
|
@@ -436,7 +435,7 @@ class S {
|
|
|
436
435
|
})).success;
|
|
437
436
|
}
|
|
438
437
|
}
|
|
439
|
-
class
|
|
438
|
+
class Ke {
|
|
440
439
|
constructor(e) {
|
|
441
440
|
this._client = e;
|
|
442
441
|
}
|
|
@@ -455,11 +454,11 @@ class D {
|
|
|
455
454
|
async getCurrent() {
|
|
456
455
|
const e = await this._client.request("users.getCurrent", {});
|
|
457
456
|
if (!e.success)
|
|
458
|
-
throw new Error("Failed to fetch current user");
|
|
457
|
+
throw new Error(e.error || "Failed to fetch current user");
|
|
459
458
|
return e.user;
|
|
460
459
|
}
|
|
461
460
|
}
|
|
462
|
-
class
|
|
461
|
+
class We {
|
|
463
462
|
constructor(e) {
|
|
464
463
|
this._client = e;
|
|
465
464
|
}
|
|
@@ -602,7 +601,7 @@ class Q {
|
|
|
602
601
|
return t;
|
|
603
602
|
}
|
|
604
603
|
}
|
|
605
|
-
class
|
|
604
|
+
class Je {
|
|
606
605
|
constructor(e) {
|
|
607
606
|
this._client = e;
|
|
608
607
|
}
|
|
@@ -643,13 +642,13 @@ class U {
|
|
|
643
642
|
*/
|
|
644
643
|
async getRates(e) {
|
|
645
644
|
var t, s, n;
|
|
646
|
-
const
|
|
647
|
-
if (!
|
|
648
|
-
throw ((t =
|
|
649
|
-
return
|
|
645
|
+
const r = await this._client.request("currency.getRates", e);
|
|
646
|
+
if (!r.success || !r.rates)
|
|
647
|
+
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");
|
|
648
|
+
return r.rates;
|
|
650
649
|
}
|
|
651
650
|
}
|
|
652
|
-
class
|
|
651
|
+
class Qe {
|
|
653
652
|
constructor(e) {
|
|
654
653
|
this._client = e;
|
|
655
654
|
}
|
|
@@ -713,7 +712,7 @@ class V {
|
|
|
713
712
|
}, t)).success;
|
|
714
713
|
}
|
|
715
714
|
}
|
|
716
|
-
class
|
|
715
|
+
class Ge {
|
|
717
716
|
constructor(e) {
|
|
718
717
|
this._originalPushState = null, this._originalReplaceState = null, this._popstateHandler = null, this._backHandler = null, this._forwardHandler = null, this._client = e;
|
|
719
718
|
}
|
|
@@ -733,15 +732,2633 @@ class O {
|
|
|
733
732
|
});
|
|
734
733
|
}
|
|
735
734
|
}
|
|
735
|
+
var b;
|
|
736
|
+
(function(a) {
|
|
737
|
+
a.assertEqual = (n) => {
|
|
738
|
+
};
|
|
739
|
+
function e(n) {
|
|
740
|
+
}
|
|
741
|
+
a.assertIs = e;
|
|
742
|
+
function t(n) {
|
|
743
|
+
throw new Error();
|
|
744
|
+
}
|
|
745
|
+
a.assertNever = t, a.arrayToEnum = (n) => {
|
|
746
|
+
const r = {};
|
|
747
|
+
for (const i of n)
|
|
748
|
+
r[i] = i;
|
|
749
|
+
return r;
|
|
750
|
+
}, a.getValidEnumValues = (n) => {
|
|
751
|
+
const r = a.objectKeys(n).filter((o) => typeof n[n[o]] != "number"), i = {};
|
|
752
|
+
for (const o of r)
|
|
753
|
+
i[o] = n[o];
|
|
754
|
+
return a.objectValues(i);
|
|
755
|
+
}, a.objectValues = (n) => a.objectKeys(n).map(function(r) {
|
|
756
|
+
return n[r];
|
|
757
|
+
}), a.objectKeys = typeof Object.keys == "function" ? (n) => Object.keys(n) : (n) => {
|
|
758
|
+
const r = [];
|
|
759
|
+
for (const i in n)
|
|
760
|
+
Object.prototype.hasOwnProperty.call(n, i) && r.push(i);
|
|
761
|
+
return r;
|
|
762
|
+
}, a.find = (n, r) => {
|
|
763
|
+
for (const i of n)
|
|
764
|
+
if (r(i))
|
|
765
|
+
return i;
|
|
766
|
+
}, a.isInteger = typeof Number.isInteger == "function" ? (n) => Number.isInteger(n) : (n) => typeof n == "number" && Number.isFinite(n) && Math.floor(n) === n;
|
|
767
|
+
function s(n, r = " | ") {
|
|
768
|
+
return n.map((i) => typeof i == "string" ? `'${i}'` : i).join(r);
|
|
769
|
+
}
|
|
770
|
+
a.joinValues = s, a.jsonStringifyReplacer = (n, r) => typeof r == "bigint" ? r.toString() : r;
|
|
771
|
+
})(b || (b = {}));
|
|
772
|
+
var ge;
|
|
773
|
+
(function(a) {
|
|
774
|
+
a.mergeShapes = (e, t) => ({
|
|
775
|
+
...e,
|
|
776
|
+
...t
|
|
777
|
+
// second overwrites first
|
|
778
|
+
});
|
|
779
|
+
})(ge || (ge = {}));
|
|
780
|
+
const h = b.arrayToEnum([
|
|
781
|
+
"string",
|
|
782
|
+
"nan",
|
|
783
|
+
"number",
|
|
784
|
+
"integer",
|
|
785
|
+
"float",
|
|
786
|
+
"boolean",
|
|
787
|
+
"date",
|
|
788
|
+
"bigint",
|
|
789
|
+
"symbol",
|
|
790
|
+
"function",
|
|
791
|
+
"undefined",
|
|
792
|
+
"null",
|
|
793
|
+
"array",
|
|
794
|
+
"object",
|
|
795
|
+
"unknown",
|
|
796
|
+
"promise",
|
|
797
|
+
"void",
|
|
798
|
+
"never",
|
|
799
|
+
"map",
|
|
800
|
+
"set"
|
|
801
|
+
]), O = (a) => {
|
|
802
|
+
switch (typeof a) {
|
|
803
|
+
case "undefined":
|
|
804
|
+
return h.undefined;
|
|
805
|
+
case "string":
|
|
806
|
+
return h.string;
|
|
807
|
+
case "number":
|
|
808
|
+
return Number.isNaN(a) ? h.nan : h.number;
|
|
809
|
+
case "boolean":
|
|
810
|
+
return h.boolean;
|
|
811
|
+
case "function":
|
|
812
|
+
return h.function;
|
|
813
|
+
case "bigint":
|
|
814
|
+
return h.bigint;
|
|
815
|
+
case "symbol":
|
|
816
|
+
return h.symbol;
|
|
817
|
+
case "object":
|
|
818
|
+
return Array.isArray(a) ? h.array : a === null ? h.null : a.then && typeof a.then == "function" && a.catch && typeof a.catch == "function" ? h.promise : typeof Map < "u" && a instanceof Map ? h.map : typeof Set < "u" && a instanceof Set ? h.set : typeof Date < "u" && a instanceof Date ? h.date : h.object;
|
|
819
|
+
default:
|
|
820
|
+
return h.unknown;
|
|
821
|
+
}
|
|
822
|
+
}, d = b.arrayToEnum([
|
|
823
|
+
"invalid_type",
|
|
824
|
+
"invalid_literal",
|
|
825
|
+
"custom",
|
|
826
|
+
"invalid_union",
|
|
827
|
+
"invalid_union_discriminator",
|
|
828
|
+
"invalid_enum_value",
|
|
829
|
+
"unrecognized_keys",
|
|
830
|
+
"invalid_arguments",
|
|
831
|
+
"invalid_return_type",
|
|
832
|
+
"invalid_date",
|
|
833
|
+
"invalid_string",
|
|
834
|
+
"too_small",
|
|
835
|
+
"too_big",
|
|
836
|
+
"invalid_intersection_types",
|
|
837
|
+
"not_multiple_of",
|
|
838
|
+
"not_finite"
|
|
839
|
+
]);
|
|
840
|
+
class Z extends Error {
|
|
841
|
+
get errors() {
|
|
842
|
+
return this.issues;
|
|
843
|
+
}
|
|
844
|
+
constructor(e) {
|
|
845
|
+
super(), this.issues = [], this.addIssue = (s) => {
|
|
846
|
+
this.issues = [...this.issues, s];
|
|
847
|
+
}, this.addIssues = (s = []) => {
|
|
848
|
+
this.issues = [...this.issues, ...s];
|
|
849
|
+
};
|
|
850
|
+
const t = new.target.prototype;
|
|
851
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
852
|
+
}
|
|
853
|
+
format(e) {
|
|
854
|
+
const t = e || function(r) {
|
|
855
|
+
return r.message;
|
|
856
|
+
}, s = { _errors: [] }, n = (r) => {
|
|
857
|
+
for (const i of r.issues)
|
|
858
|
+
if (i.code === "invalid_union")
|
|
859
|
+
i.unionErrors.map(n);
|
|
860
|
+
else if (i.code === "invalid_return_type")
|
|
861
|
+
n(i.returnTypeError);
|
|
862
|
+
else if (i.code === "invalid_arguments")
|
|
863
|
+
n(i.argumentsError);
|
|
864
|
+
else if (i.path.length === 0)
|
|
865
|
+
s._errors.push(t(i));
|
|
866
|
+
else {
|
|
867
|
+
let o = s, c = 0;
|
|
868
|
+
for (; c < i.path.length; ) {
|
|
869
|
+
const l = i.path[c];
|
|
870
|
+
c === i.path.length - 1 ? (o[l] = o[l] || { _errors: [] }, o[l]._errors.push(t(i))) : o[l] = o[l] || { _errors: [] }, o = o[l], c++;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
};
|
|
874
|
+
return n(this), s;
|
|
875
|
+
}
|
|
876
|
+
static assert(e) {
|
|
877
|
+
if (!(e instanceof Z))
|
|
878
|
+
throw new Error(`Not a ZodError: ${e}`);
|
|
879
|
+
}
|
|
880
|
+
toString() {
|
|
881
|
+
return this.message;
|
|
882
|
+
}
|
|
883
|
+
get message() {
|
|
884
|
+
return JSON.stringify(this.issues, b.jsonStringifyReplacer, 2);
|
|
885
|
+
}
|
|
886
|
+
get isEmpty() {
|
|
887
|
+
return this.issues.length === 0;
|
|
888
|
+
}
|
|
889
|
+
flatten(e = (t) => t.message) {
|
|
890
|
+
const t = {}, s = [];
|
|
891
|
+
for (const n of this.issues)
|
|
892
|
+
if (n.path.length > 0) {
|
|
893
|
+
const r = n.path[0];
|
|
894
|
+
t[r] = t[r] || [], t[r].push(e(n));
|
|
895
|
+
} else
|
|
896
|
+
s.push(e(n));
|
|
897
|
+
return { formErrors: s, fieldErrors: t };
|
|
898
|
+
}
|
|
899
|
+
get formErrors() {
|
|
900
|
+
return this.flatten();
|
|
901
|
+
}
|
|
902
|
+
}
|
|
903
|
+
Z.create = (a) => new Z(a);
|
|
904
|
+
const oe = (a, e) => {
|
|
905
|
+
let t;
|
|
906
|
+
switch (a.code) {
|
|
907
|
+
case d.invalid_type:
|
|
908
|
+
a.received === h.undefined ? t = "Required" : t = `Expected ${a.expected}, received ${a.received}`;
|
|
909
|
+
break;
|
|
910
|
+
case d.invalid_literal:
|
|
911
|
+
t = `Invalid literal value, expected ${JSON.stringify(a.expected, b.jsonStringifyReplacer)}`;
|
|
912
|
+
break;
|
|
913
|
+
case d.unrecognized_keys:
|
|
914
|
+
t = `Unrecognized key(s) in object: ${b.joinValues(a.keys, ", ")}`;
|
|
915
|
+
break;
|
|
916
|
+
case d.invalid_union:
|
|
917
|
+
t = "Invalid input";
|
|
918
|
+
break;
|
|
919
|
+
case d.invalid_union_discriminator:
|
|
920
|
+
t = `Invalid discriminator value. Expected ${b.joinValues(a.options)}`;
|
|
921
|
+
break;
|
|
922
|
+
case d.invalid_enum_value:
|
|
923
|
+
t = `Invalid enum value. Expected ${b.joinValues(a.options)}, received '${a.received}'`;
|
|
924
|
+
break;
|
|
925
|
+
case d.invalid_arguments:
|
|
926
|
+
t = "Invalid function arguments";
|
|
927
|
+
break;
|
|
928
|
+
case d.invalid_return_type:
|
|
929
|
+
t = "Invalid function return type";
|
|
930
|
+
break;
|
|
931
|
+
case d.invalid_date:
|
|
932
|
+
t = "Invalid date";
|
|
933
|
+
break;
|
|
934
|
+
case d.invalid_string:
|
|
935
|
+
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";
|
|
936
|
+
break;
|
|
937
|
+
case d.too_small:
|
|
938
|
+
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";
|
|
939
|
+
break;
|
|
940
|
+
case d.too_big:
|
|
941
|
+
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";
|
|
942
|
+
break;
|
|
943
|
+
case d.custom:
|
|
944
|
+
t = "Invalid input";
|
|
945
|
+
break;
|
|
946
|
+
case d.invalid_intersection_types:
|
|
947
|
+
t = "Intersection results could not be merged";
|
|
948
|
+
break;
|
|
949
|
+
case d.not_multiple_of:
|
|
950
|
+
t = `Number must be a multiple of ${a.multipleOf}`;
|
|
951
|
+
break;
|
|
952
|
+
case d.not_finite:
|
|
953
|
+
t = "Number must be finite";
|
|
954
|
+
break;
|
|
955
|
+
default:
|
|
956
|
+
t = e.defaultError, b.assertNever(a);
|
|
957
|
+
}
|
|
958
|
+
return { message: t };
|
|
959
|
+
};
|
|
960
|
+
let Ye = oe;
|
|
961
|
+
function Xe() {
|
|
962
|
+
return Ye;
|
|
963
|
+
}
|
|
964
|
+
const et = (a) => {
|
|
965
|
+
const { data: e, path: t, errorMaps: s, issueData: n } = a, r = [...t, ...n.path || []], i = {
|
|
966
|
+
...n,
|
|
967
|
+
path: r
|
|
968
|
+
};
|
|
969
|
+
if (n.message !== void 0)
|
|
970
|
+
return {
|
|
971
|
+
...n,
|
|
972
|
+
path: r,
|
|
973
|
+
message: n.message
|
|
974
|
+
};
|
|
975
|
+
let o = "";
|
|
976
|
+
const c = s.filter((l) => !!l).slice().reverse();
|
|
977
|
+
for (const l of c)
|
|
978
|
+
o = l(i, { data: e, defaultError: o }).message;
|
|
979
|
+
return {
|
|
980
|
+
...n,
|
|
981
|
+
path: r,
|
|
982
|
+
message: o
|
|
983
|
+
};
|
|
984
|
+
};
|
|
985
|
+
function u(a, e) {
|
|
986
|
+
const t = Xe(), s = et({
|
|
987
|
+
issueData: e,
|
|
988
|
+
data: a.data,
|
|
989
|
+
path: a.path,
|
|
990
|
+
errorMaps: [
|
|
991
|
+
a.common.contextualErrorMap,
|
|
992
|
+
// contextual error map is first priority
|
|
993
|
+
a.schemaErrorMap,
|
|
994
|
+
// then schema-bound map if available
|
|
995
|
+
t,
|
|
996
|
+
// then global override map
|
|
997
|
+
t === oe ? void 0 : oe
|
|
998
|
+
// then global default map
|
|
999
|
+
].filter((n) => !!n)
|
|
1000
|
+
});
|
|
1001
|
+
a.common.issues.push(s);
|
|
1002
|
+
}
|
|
1003
|
+
class S {
|
|
1004
|
+
constructor() {
|
|
1005
|
+
this.value = "valid";
|
|
1006
|
+
}
|
|
1007
|
+
dirty() {
|
|
1008
|
+
this.value === "valid" && (this.value = "dirty");
|
|
1009
|
+
}
|
|
1010
|
+
abort() {
|
|
1011
|
+
this.value !== "aborted" && (this.value = "aborted");
|
|
1012
|
+
}
|
|
1013
|
+
static mergeArray(e, t) {
|
|
1014
|
+
const s = [];
|
|
1015
|
+
for (const n of t) {
|
|
1016
|
+
if (n.status === "aborted")
|
|
1017
|
+
return _;
|
|
1018
|
+
n.status === "dirty" && e.dirty(), s.push(n.value);
|
|
1019
|
+
}
|
|
1020
|
+
return { status: e.value, value: s };
|
|
1021
|
+
}
|
|
1022
|
+
static async mergeObjectAsync(e, t) {
|
|
1023
|
+
const s = [];
|
|
1024
|
+
for (const n of t) {
|
|
1025
|
+
const r = await n.key, i = await n.value;
|
|
1026
|
+
s.push({
|
|
1027
|
+
key: r,
|
|
1028
|
+
value: i
|
|
1029
|
+
});
|
|
1030
|
+
}
|
|
1031
|
+
return S.mergeObjectSync(e, s);
|
|
1032
|
+
}
|
|
1033
|
+
static mergeObjectSync(e, t) {
|
|
1034
|
+
const s = {};
|
|
1035
|
+
for (const n of t) {
|
|
1036
|
+
const { key: r, value: i } = n;
|
|
1037
|
+
if (r.status === "aborted" || i.status === "aborted")
|
|
1038
|
+
return _;
|
|
1039
|
+
r.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), r.value !== "__proto__" && (typeof i.value < "u" || n.alwaysSet) && (s[r.value] = i.value);
|
|
1040
|
+
}
|
|
1041
|
+
return { status: e.value, value: s };
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
const _ = Object.freeze({
|
|
1045
|
+
status: "aborted"
|
|
1046
|
+
}), ce = (a) => ({ status: "dirty", value: a }), C = (a) => ({ status: "valid", value: a }), ye = (a) => a.status === "aborted", ve = (a) => a.status === "dirty", M = (a) => a.status === "valid", te = (a) => typeof Promise < "u" && a instanceof Promise;
|
|
1047
|
+
var p;
|
|
1048
|
+
(function(a) {
|
|
1049
|
+
a.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, a.toString = (e) => typeof e == "string" ? e : e == null ? void 0 : e.message;
|
|
1050
|
+
})(p || (p = {}));
|
|
1051
|
+
class j {
|
|
1052
|
+
constructor(e, t, s, n) {
|
|
1053
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = s, this._key = n;
|
|
1054
|
+
}
|
|
1055
|
+
get path() {
|
|
1056
|
+
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
1057
|
+
}
|
|
1058
|
+
}
|
|
1059
|
+
const be = (a, e) => {
|
|
1060
|
+
if (M(e))
|
|
1061
|
+
return { success: !0, data: e.value };
|
|
1062
|
+
if (!a.common.issues.length)
|
|
1063
|
+
throw new Error("Validation failed but no issues detected.");
|
|
1064
|
+
return {
|
|
1065
|
+
success: !1,
|
|
1066
|
+
get error() {
|
|
1067
|
+
if (this._error)
|
|
1068
|
+
return this._error;
|
|
1069
|
+
const t = new Z(a.common.issues);
|
|
1070
|
+
return this._error = t, this._error;
|
|
1071
|
+
}
|
|
1072
|
+
};
|
|
1073
|
+
};
|
|
1074
|
+
function y(a) {
|
|
1075
|
+
if (!a)
|
|
1076
|
+
return {};
|
|
1077
|
+
const { errorMap: e, invalid_type_error: t, required_error: s, description: n } = a;
|
|
1078
|
+
if (e && (t || s))
|
|
1079
|
+
throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);
|
|
1080
|
+
return e ? { errorMap: e, description: n } : { errorMap: (r, i) => {
|
|
1081
|
+
const { message: o } = a;
|
|
1082
|
+
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 };
|
|
1083
|
+
}, description: n };
|
|
1084
|
+
}
|
|
1085
|
+
class v {
|
|
1086
|
+
get description() {
|
|
1087
|
+
return this._def.description;
|
|
1088
|
+
}
|
|
1089
|
+
_getType(e) {
|
|
1090
|
+
return O(e.data);
|
|
1091
|
+
}
|
|
1092
|
+
_getOrReturnCtx(e, t) {
|
|
1093
|
+
return t || {
|
|
1094
|
+
common: e.parent.common,
|
|
1095
|
+
data: e.data,
|
|
1096
|
+
parsedType: O(e.data),
|
|
1097
|
+
schemaErrorMap: this._def.errorMap,
|
|
1098
|
+
path: e.path,
|
|
1099
|
+
parent: e.parent
|
|
1100
|
+
};
|
|
1101
|
+
}
|
|
1102
|
+
_processInputParams(e) {
|
|
1103
|
+
return {
|
|
1104
|
+
status: new S(),
|
|
1105
|
+
ctx: {
|
|
1106
|
+
common: e.parent.common,
|
|
1107
|
+
data: e.data,
|
|
1108
|
+
parsedType: O(e.data),
|
|
1109
|
+
schemaErrorMap: this._def.errorMap,
|
|
1110
|
+
path: e.path,
|
|
1111
|
+
parent: e.parent
|
|
1112
|
+
}
|
|
1113
|
+
};
|
|
1114
|
+
}
|
|
1115
|
+
_parseSync(e) {
|
|
1116
|
+
const t = this._parse(e);
|
|
1117
|
+
if (te(t))
|
|
1118
|
+
throw new Error("Synchronous parse encountered promise.");
|
|
1119
|
+
return t;
|
|
1120
|
+
}
|
|
1121
|
+
_parseAsync(e) {
|
|
1122
|
+
const t = this._parse(e);
|
|
1123
|
+
return Promise.resolve(t);
|
|
1124
|
+
}
|
|
1125
|
+
parse(e, t) {
|
|
1126
|
+
const s = this.safeParse(e, t);
|
|
1127
|
+
if (s.success)
|
|
1128
|
+
return s.data;
|
|
1129
|
+
throw s.error;
|
|
1130
|
+
}
|
|
1131
|
+
safeParse(e, t) {
|
|
1132
|
+
const s = {
|
|
1133
|
+
common: {
|
|
1134
|
+
issues: [],
|
|
1135
|
+
async: (t == null ? void 0 : t.async) ?? !1,
|
|
1136
|
+
contextualErrorMap: t == null ? void 0 : t.errorMap
|
|
1137
|
+
},
|
|
1138
|
+
path: (t == null ? void 0 : t.path) || [],
|
|
1139
|
+
schemaErrorMap: this._def.errorMap,
|
|
1140
|
+
parent: null,
|
|
1141
|
+
data: e,
|
|
1142
|
+
parsedType: O(e)
|
|
1143
|
+
}, n = this._parseSync({ data: e, path: s.path, parent: s });
|
|
1144
|
+
return be(s, n);
|
|
1145
|
+
}
|
|
1146
|
+
"~validate"(e) {
|
|
1147
|
+
var t, s;
|
|
1148
|
+
const n = {
|
|
1149
|
+
common: {
|
|
1150
|
+
issues: [],
|
|
1151
|
+
async: !!this["~standard"].async
|
|
1152
|
+
},
|
|
1153
|
+
path: [],
|
|
1154
|
+
schemaErrorMap: this._def.errorMap,
|
|
1155
|
+
parent: null,
|
|
1156
|
+
data: e,
|
|
1157
|
+
parsedType: O(e)
|
|
1158
|
+
};
|
|
1159
|
+
if (!this["~standard"].async)
|
|
1160
|
+
try {
|
|
1161
|
+
const r = this._parseSync({ data: e, path: [], parent: n });
|
|
1162
|
+
return M(r) ? {
|
|
1163
|
+
value: r.value
|
|
1164
|
+
} : {
|
|
1165
|
+
issues: n.common.issues
|
|
1166
|
+
};
|
|
1167
|
+
} catch (r) {
|
|
1168
|
+
(s = (t = r == null ? void 0 : r.message) == null ? void 0 : t.toLowerCase()) != null && s.includes("encountered") && (this["~standard"].async = !0), n.common = {
|
|
1169
|
+
issues: [],
|
|
1170
|
+
async: !0
|
|
1171
|
+
};
|
|
1172
|
+
}
|
|
1173
|
+
return this._parseAsync({ data: e, path: [], parent: n }).then((r) => M(r) ? {
|
|
1174
|
+
value: r.value
|
|
1175
|
+
} : {
|
|
1176
|
+
issues: n.common.issues
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
async parseAsync(e, t) {
|
|
1180
|
+
const s = await this.safeParseAsync(e, t);
|
|
1181
|
+
if (s.success)
|
|
1182
|
+
return s.data;
|
|
1183
|
+
throw s.error;
|
|
1184
|
+
}
|
|
1185
|
+
async safeParseAsync(e, t) {
|
|
1186
|
+
const s = {
|
|
1187
|
+
common: {
|
|
1188
|
+
issues: [],
|
|
1189
|
+
contextualErrorMap: t == null ? void 0 : t.errorMap,
|
|
1190
|
+
async: !0
|
|
1191
|
+
},
|
|
1192
|
+
path: (t == null ? void 0 : t.path) || [],
|
|
1193
|
+
schemaErrorMap: this._def.errorMap,
|
|
1194
|
+
parent: null,
|
|
1195
|
+
data: e,
|
|
1196
|
+
parsedType: O(e)
|
|
1197
|
+
}, n = this._parse({ data: e, path: s.path, parent: s }), r = await (te(n) ? n : Promise.resolve(n));
|
|
1198
|
+
return be(s, r);
|
|
1199
|
+
}
|
|
1200
|
+
refine(e, t) {
|
|
1201
|
+
const s = (n) => typeof t == "string" || typeof t > "u" ? { message: t } : typeof t == "function" ? t(n) : t;
|
|
1202
|
+
return this._refinement((n, r) => {
|
|
1203
|
+
const i = e(n), o = () => r.addIssue({
|
|
1204
|
+
code: d.custom,
|
|
1205
|
+
...s(n)
|
|
1206
|
+
});
|
|
1207
|
+
return typeof Promise < "u" && i instanceof Promise ? i.then((c) => c ? !0 : (o(), !1)) : i ? !0 : (o(), !1);
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
refinement(e, t) {
|
|
1211
|
+
return this._refinement((s, n) => e(s) ? !0 : (n.addIssue(typeof t == "function" ? t(s, n) : t), !1));
|
|
1212
|
+
}
|
|
1213
|
+
_refinement(e) {
|
|
1214
|
+
return new H({
|
|
1215
|
+
schema: this,
|
|
1216
|
+
typeName: m.ZodEffects,
|
|
1217
|
+
effect: { type: "refinement", refinement: e }
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
superRefine(e) {
|
|
1221
|
+
return this._refinement(e);
|
|
1222
|
+
}
|
|
1223
|
+
constructor(e) {
|
|
1224
|
+
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
|
|
1225
|
+
version: 1,
|
|
1226
|
+
vendor: "zod",
|
|
1227
|
+
validate: (t) => this["~validate"](t)
|
|
1228
|
+
};
|
|
1229
|
+
}
|
|
1230
|
+
optional() {
|
|
1231
|
+
return E.create(this, this._def);
|
|
1232
|
+
}
|
|
1233
|
+
nullable() {
|
|
1234
|
+
return z.create(this, this._def);
|
|
1235
|
+
}
|
|
1236
|
+
nullish() {
|
|
1237
|
+
return this.nullable().optional();
|
|
1238
|
+
}
|
|
1239
|
+
array() {
|
|
1240
|
+
return N.create(this);
|
|
1241
|
+
}
|
|
1242
|
+
promise() {
|
|
1243
|
+
return re.create(this, this._def);
|
|
1244
|
+
}
|
|
1245
|
+
or(e) {
|
|
1246
|
+
return ne.create([this, e], this._def);
|
|
1247
|
+
}
|
|
1248
|
+
and(e) {
|
|
1249
|
+
return ae.create(this, e, this._def);
|
|
1250
|
+
}
|
|
1251
|
+
transform(e) {
|
|
1252
|
+
return new H({
|
|
1253
|
+
...y(this._def),
|
|
1254
|
+
schema: this,
|
|
1255
|
+
typeName: m.ZodEffects,
|
|
1256
|
+
effect: { type: "transform", transform: e }
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
default(e) {
|
|
1260
|
+
const t = typeof e == "function" ? e : () => e;
|
|
1261
|
+
return new he({
|
|
1262
|
+
...y(this._def),
|
|
1263
|
+
innerType: this,
|
|
1264
|
+
defaultValue: t,
|
|
1265
|
+
typeName: m.ZodDefault
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
brand() {
|
|
1269
|
+
return new xt({
|
|
1270
|
+
typeName: m.ZodBranded,
|
|
1271
|
+
type: this,
|
|
1272
|
+
...y(this._def)
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
catch(e) {
|
|
1276
|
+
const t = typeof e == "function" ? e : () => e;
|
|
1277
|
+
return new pe({
|
|
1278
|
+
...y(this._def),
|
|
1279
|
+
innerType: this,
|
|
1280
|
+
catchValue: t,
|
|
1281
|
+
typeName: m.ZodCatch
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
describe(e) {
|
|
1285
|
+
const t = this.constructor;
|
|
1286
|
+
return new t({
|
|
1287
|
+
...this._def,
|
|
1288
|
+
description: e
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
pipe(e) {
|
|
1292
|
+
return me.create(this, e);
|
|
1293
|
+
}
|
|
1294
|
+
readonly() {
|
|
1295
|
+
return fe.create(this);
|
|
1296
|
+
}
|
|
1297
|
+
isOptional() {
|
|
1298
|
+
return this.safeParse(void 0).success;
|
|
1299
|
+
}
|
|
1300
|
+
isNullable() {
|
|
1301
|
+
return this.safeParse(null).success;
|
|
1302
|
+
}
|
|
1303
|
+
}
|
|
1304
|
+
const tt = /^c[^\s-]{8,}$/i, st = /^[0-9a-z]+$/, nt = /^[0-9A-HJKMNP-TV-Z]{26}$/i, at = /^[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, rt = /^[a-z0-9_-]{21}$/i, it = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, ot = /^[-+]?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)?)??$/, ct = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, dt = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";
|
|
1305
|
+
let ie;
|
|
1306
|
+
const ut = /^(?:(?: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])$/, lt = /^(?:(?: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])$/, ht = /^(([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]))$/, pt = /^(([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])$/, ft = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, mt = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, Ie = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", _t = new RegExp(`^${Ie}$`);
|
|
1307
|
+
function Ee(a) {
|
|
1308
|
+
let e = "[0-5]\\d";
|
|
1309
|
+
a.precision ? e = `${e}\\.\\d{${a.precision}}` : a.precision == null && (e = `${e}(\\.\\d+)?`);
|
|
1310
|
+
const t = a.precision ? "+" : "?";
|
|
1311
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`;
|
|
1312
|
+
}
|
|
1313
|
+
function gt(a) {
|
|
1314
|
+
return new RegExp(`^${Ee(a)}$`);
|
|
1315
|
+
}
|
|
1316
|
+
function yt(a) {
|
|
1317
|
+
let e = `${Ie}T${Ee(a)}`;
|
|
1318
|
+
const t = [];
|
|
1319
|
+
return t.push(a.local ? "Z?" : "Z"), a.offset && t.push("([+-]\\d{2}:?\\d{2})"), e = `${e}(${t.join("|")})`, new RegExp(`^${e}$`);
|
|
1320
|
+
}
|
|
1321
|
+
function vt(a, e) {
|
|
1322
|
+
return !!((e === "v4" || !e) && ut.test(a) || (e === "v6" || !e) && ht.test(a));
|
|
1323
|
+
}
|
|
1324
|
+
function bt(a, e) {
|
|
1325
|
+
if (!it.test(a))
|
|
1326
|
+
return !1;
|
|
1327
|
+
try {
|
|
1328
|
+
const [t] = a.split(".");
|
|
1329
|
+
if (!t)
|
|
1330
|
+
return !1;
|
|
1331
|
+
const s = t.replace(/-/g, "+").replace(/_/g, "/").padEnd(t.length + (4 - t.length % 4) % 4, "="), n = JSON.parse(atob(s));
|
|
1332
|
+
return !(typeof n != "object" || n === null || "typ" in n && (n == null ? void 0 : n.typ) !== "JWT" || !n.alg || e && n.alg !== e);
|
|
1333
|
+
} catch {
|
|
1334
|
+
return !1;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
function wt(a, e) {
|
|
1338
|
+
return !!((e === "v4" || !e) && lt.test(a) || (e === "v6" || !e) && pt.test(a));
|
|
1339
|
+
}
|
|
1340
|
+
class I extends v {
|
|
1341
|
+
_parse(e) {
|
|
1342
|
+
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== h.string) {
|
|
1343
|
+
const n = this._getOrReturnCtx(e);
|
|
1344
|
+
return u(n, {
|
|
1345
|
+
code: d.invalid_type,
|
|
1346
|
+
expected: h.string,
|
|
1347
|
+
received: n.parsedType
|
|
1348
|
+
}), _;
|
|
1349
|
+
}
|
|
1350
|
+
const t = new S();
|
|
1351
|
+
let s;
|
|
1352
|
+
for (const n of this._def.checks)
|
|
1353
|
+
if (n.kind === "min")
|
|
1354
|
+
e.data.length < n.value && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1355
|
+
code: d.too_small,
|
|
1356
|
+
minimum: n.value,
|
|
1357
|
+
type: "string",
|
|
1358
|
+
inclusive: !0,
|
|
1359
|
+
exact: !1,
|
|
1360
|
+
message: n.message
|
|
1361
|
+
}), t.dirty());
|
|
1362
|
+
else if (n.kind === "max")
|
|
1363
|
+
e.data.length > n.value && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1364
|
+
code: d.too_big,
|
|
1365
|
+
maximum: n.value,
|
|
1366
|
+
type: "string",
|
|
1367
|
+
inclusive: !0,
|
|
1368
|
+
exact: !1,
|
|
1369
|
+
message: n.message
|
|
1370
|
+
}), t.dirty());
|
|
1371
|
+
else if (n.kind === "length") {
|
|
1372
|
+
const r = e.data.length > n.value, i = e.data.length < n.value;
|
|
1373
|
+
(r || i) && (s = this._getOrReturnCtx(e, s), r ? u(s, {
|
|
1374
|
+
code: d.too_big,
|
|
1375
|
+
maximum: n.value,
|
|
1376
|
+
type: "string",
|
|
1377
|
+
inclusive: !0,
|
|
1378
|
+
exact: !0,
|
|
1379
|
+
message: n.message
|
|
1380
|
+
}) : i && u(s, {
|
|
1381
|
+
code: d.too_small,
|
|
1382
|
+
minimum: n.value,
|
|
1383
|
+
type: "string",
|
|
1384
|
+
inclusive: !0,
|
|
1385
|
+
exact: !0,
|
|
1386
|
+
message: n.message
|
|
1387
|
+
}), t.dirty());
|
|
1388
|
+
} else if (n.kind === "email")
|
|
1389
|
+
ct.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1390
|
+
validation: "email",
|
|
1391
|
+
code: d.invalid_string,
|
|
1392
|
+
message: n.message
|
|
1393
|
+
}), t.dirty());
|
|
1394
|
+
else if (n.kind === "emoji")
|
|
1395
|
+
ie || (ie = new RegExp(dt, "u")), ie.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1396
|
+
validation: "emoji",
|
|
1397
|
+
code: d.invalid_string,
|
|
1398
|
+
message: n.message
|
|
1399
|
+
}), t.dirty());
|
|
1400
|
+
else if (n.kind === "uuid")
|
|
1401
|
+
at.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1402
|
+
validation: "uuid",
|
|
1403
|
+
code: d.invalid_string,
|
|
1404
|
+
message: n.message
|
|
1405
|
+
}), t.dirty());
|
|
1406
|
+
else if (n.kind === "nanoid")
|
|
1407
|
+
rt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1408
|
+
validation: "nanoid",
|
|
1409
|
+
code: d.invalid_string,
|
|
1410
|
+
message: n.message
|
|
1411
|
+
}), t.dirty());
|
|
1412
|
+
else if (n.kind === "cuid")
|
|
1413
|
+
tt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1414
|
+
validation: "cuid",
|
|
1415
|
+
code: d.invalid_string,
|
|
1416
|
+
message: n.message
|
|
1417
|
+
}), t.dirty());
|
|
1418
|
+
else if (n.kind === "cuid2")
|
|
1419
|
+
st.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1420
|
+
validation: "cuid2",
|
|
1421
|
+
code: d.invalid_string,
|
|
1422
|
+
message: n.message
|
|
1423
|
+
}), t.dirty());
|
|
1424
|
+
else if (n.kind === "ulid")
|
|
1425
|
+
nt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1426
|
+
validation: "ulid",
|
|
1427
|
+
code: d.invalid_string,
|
|
1428
|
+
message: n.message
|
|
1429
|
+
}), t.dirty());
|
|
1430
|
+
else if (n.kind === "url")
|
|
1431
|
+
try {
|
|
1432
|
+
new URL(e.data);
|
|
1433
|
+
} catch {
|
|
1434
|
+
s = this._getOrReturnCtx(e, s), u(s, {
|
|
1435
|
+
validation: "url",
|
|
1436
|
+
code: d.invalid_string,
|
|
1437
|
+
message: n.message
|
|
1438
|
+
}), t.dirty();
|
|
1439
|
+
}
|
|
1440
|
+
else n.kind === "regex" ? (n.regex.lastIndex = 0, n.regex.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1441
|
+
validation: "regex",
|
|
1442
|
+
code: d.invalid_string,
|
|
1443
|
+
message: n.message
|
|
1444
|
+
}), 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), u(s, {
|
|
1445
|
+
code: d.invalid_string,
|
|
1446
|
+
validation: { includes: n.value, position: n.position },
|
|
1447
|
+
message: n.message
|
|
1448
|
+
}), 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), u(s, {
|
|
1449
|
+
code: d.invalid_string,
|
|
1450
|
+
validation: { startsWith: n.value },
|
|
1451
|
+
message: n.message
|
|
1452
|
+
}), t.dirty()) : n.kind === "endsWith" ? e.data.endsWith(n.value) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1453
|
+
code: d.invalid_string,
|
|
1454
|
+
validation: { endsWith: n.value },
|
|
1455
|
+
message: n.message
|
|
1456
|
+
}), t.dirty()) : n.kind === "datetime" ? yt(n).test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1457
|
+
code: d.invalid_string,
|
|
1458
|
+
validation: "datetime",
|
|
1459
|
+
message: n.message
|
|
1460
|
+
}), t.dirty()) : n.kind === "date" ? _t.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1461
|
+
code: d.invalid_string,
|
|
1462
|
+
validation: "date",
|
|
1463
|
+
message: n.message
|
|
1464
|
+
}), t.dirty()) : n.kind === "time" ? gt(n).test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1465
|
+
code: d.invalid_string,
|
|
1466
|
+
validation: "time",
|
|
1467
|
+
message: n.message
|
|
1468
|
+
}), t.dirty()) : n.kind === "duration" ? ot.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1469
|
+
validation: "duration",
|
|
1470
|
+
code: d.invalid_string,
|
|
1471
|
+
message: n.message
|
|
1472
|
+
}), t.dirty()) : n.kind === "ip" ? vt(e.data, n.version) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1473
|
+
validation: "ip",
|
|
1474
|
+
code: d.invalid_string,
|
|
1475
|
+
message: n.message
|
|
1476
|
+
}), t.dirty()) : n.kind === "jwt" ? bt(e.data, n.alg) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1477
|
+
validation: "jwt",
|
|
1478
|
+
code: d.invalid_string,
|
|
1479
|
+
message: n.message
|
|
1480
|
+
}), t.dirty()) : n.kind === "cidr" ? wt(e.data, n.version) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1481
|
+
validation: "cidr",
|
|
1482
|
+
code: d.invalid_string,
|
|
1483
|
+
message: n.message
|
|
1484
|
+
}), t.dirty()) : n.kind === "base64" ? ft.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1485
|
+
validation: "base64",
|
|
1486
|
+
code: d.invalid_string,
|
|
1487
|
+
message: n.message
|
|
1488
|
+
}), t.dirty()) : n.kind === "base64url" ? mt.test(e.data) || (s = this._getOrReturnCtx(e, s), u(s, {
|
|
1489
|
+
validation: "base64url",
|
|
1490
|
+
code: d.invalid_string,
|
|
1491
|
+
message: n.message
|
|
1492
|
+
}), t.dirty()) : b.assertNever(n);
|
|
1493
|
+
return { status: t.value, value: e.data };
|
|
1494
|
+
}
|
|
1495
|
+
_regex(e, t, s) {
|
|
1496
|
+
return this.refinement((n) => e.test(n), {
|
|
1497
|
+
validation: t,
|
|
1498
|
+
code: d.invalid_string,
|
|
1499
|
+
...p.errToObj(s)
|
|
1500
|
+
});
|
|
1501
|
+
}
|
|
1502
|
+
_addCheck(e) {
|
|
1503
|
+
return new I({
|
|
1504
|
+
...this._def,
|
|
1505
|
+
checks: [...this._def.checks, e]
|
|
1506
|
+
});
|
|
1507
|
+
}
|
|
1508
|
+
email(e) {
|
|
1509
|
+
return this._addCheck({ kind: "email", ...p.errToObj(e) });
|
|
1510
|
+
}
|
|
1511
|
+
url(e) {
|
|
1512
|
+
return this._addCheck({ kind: "url", ...p.errToObj(e) });
|
|
1513
|
+
}
|
|
1514
|
+
emoji(e) {
|
|
1515
|
+
return this._addCheck({ kind: "emoji", ...p.errToObj(e) });
|
|
1516
|
+
}
|
|
1517
|
+
uuid(e) {
|
|
1518
|
+
return this._addCheck({ kind: "uuid", ...p.errToObj(e) });
|
|
1519
|
+
}
|
|
1520
|
+
nanoid(e) {
|
|
1521
|
+
return this._addCheck({ kind: "nanoid", ...p.errToObj(e) });
|
|
1522
|
+
}
|
|
1523
|
+
cuid(e) {
|
|
1524
|
+
return this._addCheck({ kind: "cuid", ...p.errToObj(e) });
|
|
1525
|
+
}
|
|
1526
|
+
cuid2(e) {
|
|
1527
|
+
return this._addCheck({ kind: "cuid2", ...p.errToObj(e) });
|
|
1528
|
+
}
|
|
1529
|
+
ulid(e) {
|
|
1530
|
+
return this._addCheck({ kind: "ulid", ...p.errToObj(e) });
|
|
1531
|
+
}
|
|
1532
|
+
base64(e) {
|
|
1533
|
+
return this._addCheck({ kind: "base64", ...p.errToObj(e) });
|
|
1534
|
+
}
|
|
1535
|
+
base64url(e) {
|
|
1536
|
+
return this._addCheck({
|
|
1537
|
+
kind: "base64url",
|
|
1538
|
+
...p.errToObj(e)
|
|
1539
|
+
});
|
|
1540
|
+
}
|
|
1541
|
+
jwt(e) {
|
|
1542
|
+
return this._addCheck({ kind: "jwt", ...p.errToObj(e) });
|
|
1543
|
+
}
|
|
1544
|
+
ip(e) {
|
|
1545
|
+
return this._addCheck({ kind: "ip", ...p.errToObj(e) });
|
|
1546
|
+
}
|
|
1547
|
+
cidr(e) {
|
|
1548
|
+
return this._addCheck({ kind: "cidr", ...p.errToObj(e) });
|
|
1549
|
+
}
|
|
1550
|
+
datetime(e) {
|
|
1551
|
+
return typeof e == "string" ? this._addCheck({
|
|
1552
|
+
kind: "datetime",
|
|
1553
|
+
precision: null,
|
|
1554
|
+
offset: !1,
|
|
1555
|
+
local: !1,
|
|
1556
|
+
message: e
|
|
1557
|
+
}) : this._addCheck({
|
|
1558
|
+
kind: "datetime",
|
|
1559
|
+
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
1560
|
+
offset: (e == null ? void 0 : e.offset) ?? !1,
|
|
1561
|
+
local: (e == null ? void 0 : e.local) ?? !1,
|
|
1562
|
+
...p.errToObj(e == null ? void 0 : e.message)
|
|
1563
|
+
});
|
|
1564
|
+
}
|
|
1565
|
+
date(e) {
|
|
1566
|
+
return this._addCheck({ kind: "date", message: e });
|
|
1567
|
+
}
|
|
1568
|
+
time(e) {
|
|
1569
|
+
return typeof e == "string" ? this._addCheck({
|
|
1570
|
+
kind: "time",
|
|
1571
|
+
precision: null,
|
|
1572
|
+
message: e
|
|
1573
|
+
}) : this._addCheck({
|
|
1574
|
+
kind: "time",
|
|
1575
|
+
precision: typeof (e == null ? void 0 : e.precision) > "u" ? null : e == null ? void 0 : e.precision,
|
|
1576
|
+
...p.errToObj(e == null ? void 0 : e.message)
|
|
1577
|
+
});
|
|
1578
|
+
}
|
|
1579
|
+
duration(e) {
|
|
1580
|
+
return this._addCheck({ kind: "duration", ...p.errToObj(e) });
|
|
1581
|
+
}
|
|
1582
|
+
regex(e, t) {
|
|
1583
|
+
return this._addCheck({
|
|
1584
|
+
kind: "regex",
|
|
1585
|
+
regex: e,
|
|
1586
|
+
...p.errToObj(t)
|
|
1587
|
+
});
|
|
1588
|
+
}
|
|
1589
|
+
includes(e, t) {
|
|
1590
|
+
return this._addCheck({
|
|
1591
|
+
kind: "includes",
|
|
1592
|
+
value: e,
|
|
1593
|
+
position: t == null ? void 0 : t.position,
|
|
1594
|
+
...p.errToObj(t == null ? void 0 : t.message)
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
startsWith(e, t) {
|
|
1598
|
+
return this._addCheck({
|
|
1599
|
+
kind: "startsWith",
|
|
1600
|
+
value: e,
|
|
1601
|
+
...p.errToObj(t)
|
|
1602
|
+
});
|
|
1603
|
+
}
|
|
1604
|
+
endsWith(e, t) {
|
|
1605
|
+
return this._addCheck({
|
|
1606
|
+
kind: "endsWith",
|
|
1607
|
+
value: e,
|
|
1608
|
+
...p.errToObj(t)
|
|
1609
|
+
});
|
|
1610
|
+
}
|
|
1611
|
+
min(e, t) {
|
|
1612
|
+
return this._addCheck({
|
|
1613
|
+
kind: "min",
|
|
1614
|
+
value: e,
|
|
1615
|
+
...p.errToObj(t)
|
|
1616
|
+
});
|
|
1617
|
+
}
|
|
1618
|
+
max(e, t) {
|
|
1619
|
+
return this._addCheck({
|
|
1620
|
+
kind: "max",
|
|
1621
|
+
value: e,
|
|
1622
|
+
...p.errToObj(t)
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
length(e, t) {
|
|
1626
|
+
return this._addCheck({
|
|
1627
|
+
kind: "length",
|
|
1628
|
+
value: e,
|
|
1629
|
+
...p.errToObj(t)
|
|
1630
|
+
});
|
|
1631
|
+
}
|
|
1632
|
+
/**
|
|
1633
|
+
* Equivalent to `.min(1)`
|
|
1634
|
+
*/
|
|
1635
|
+
nonempty(e) {
|
|
1636
|
+
return this.min(1, p.errToObj(e));
|
|
1637
|
+
}
|
|
1638
|
+
trim() {
|
|
1639
|
+
return new I({
|
|
1640
|
+
...this._def,
|
|
1641
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
1642
|
+
});
|
|
1643
|
+
}
|
|
1644
|
+
toLowerCase() {
|
|
1645
|
+
return new I({
|
|
1646
|
+
...this._def,
|
|
1647
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1648
|
+
});
|
|
1649
|
+
}
|
|
1650
|
+
toUpperCase() {
|
|
1651
|
+
return new I({
|
|
1652
|
+
...this._def,
|
|
1653
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
get isDatetime() {
|
|
1657
|
+
return !!this._def.checks.find((e) => e.kind === "datetime");
|
|
1658
|
+
}
|
|
1659
|
+
get isDate() {
|
|
1660
|
+
return !!this._def.checks.find((e) => e.kind === "date");
|
|
1661
|
+
}
|
|
1662
|
+
get isTime() {
|
|
1663
|
+
return !!this._def.checks.find((e) => e.kind === "time");
|
|
1664
|
+
}
|
|
1665
|
+
get isDuration() {
|
|
1666
|
+
return !!this._def.checks.find((e) => e.kind === "duration");
|
|
1667
|
+
}
|
|
1668
|
+
get isEmail() {
|
|
1669
|
+
return !!this._def.checks.find((e) => e.kind === "email");
|
|
1670
|
+
}
|
|
1671
|
+
get isURL() {
|
|
1672
|
+
return !!this._def.checks.find((e) => e.kind === "url");
|
|
1673
|
+
}
|
|
1674
|
+
get isEmoji() {
|
|
1675
|
+
return !!this._def.checks.find((e) => e.kind === "emoji");
|
|
1676
|
+
}
|
|
1677
|
+
get isUUID() {
|
|
1678
|
+
return !!this._def.checks.find((e) => e.kind === "uuid");
|
|
1679
|
+
}
|
|
1680
|
+
get isNANOID() {
|
|
1681
|
+
return !!this._def.checks.find((e) => e.kind === "nanoid");
|
|
1682
|
+
}
|
|
1683
|
+
get isCUID() {
|
|
1684
|
+
return !!this._def.checks.find((e) => e.kind === "cuid");
|
|
1685
|
+
}
|
|
1686
|
+
get isCUID2() {
|
|
1687
|
+
return !!this._def.checks.find((e) => e.kind === "cuid2");
|
|
1688
|
+
}
|
|
1689
|
+
get isULID() {
|
|
1690
|
+
return !!this._def.checks.find((e) => e.kind === "ulid");
|
|
1691
|
+
}
|
|
1692
|
+
get isIP() {
|
|
1693
|
+
return !!this._def.checks.find((e) => e.kind === "ip");
|
|
1694
|
+
}
|
|
1695
|
+
get isCIDR() {
|
|
1696
|
+
return !!this._def.checks.find((e) => e.kind === "cidr");
|
|
1697
|
+
}
|
|
1698
|
+
get isBase64() {
|
|
1699
|
+
return !!this._def.checks.find((e) => e.kind === "base64");
|
|
1700
|
+
}
|
|
1701
|
+
get isBase64url() {
|
|
1702
|
+
return !!this._def.checks.find((e) => e.kind === "base64url");
|
|
1703
|
+
}
|
|
1704
|
+
get minLength() {
|
|
1705
|
+
let e = null;
|
|
1706
|
+
for (const t of this._def.checks)
|
|
1707
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1708
|
+
return e;
|
|
1709
|
+
}
|
|
1710
|
+
get maxLength() {
|
|
1711
|
+
let e = null;
|
|
1712
|
+
for (const t of this._def.checks)
|
|
1713
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1714
|
+
return e;
|
|
1715
|
+
}
|
|
1716
|
+
}
|
|
1717
|
+
I.create = (a) => new I({
|
|
1718
|
+
checks: [],
|
|
1719
|
+
typeName: m.ZodString,
|
|
1720
|
+
coerce: (a == null ? void 0 : a.coerce) ?? !1,
|
|
1721
|
+
...y(a)
|
|
1722
|
+
});
|
|
1723
|
+
function kt(a, e) {
|
|
1724
|
+
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(".", ""));
|
|
1725
|
+
return r % i / 10 ** n;
|
|
1726
|
+
}
|
|
1727
|
+
class W extends v {
|
|
1728
|
+
constructor() {
|
|
1729
|
+
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1730
|
+
}
|
|
1731
|
+
_parse(e) {
|
|
1732
|
+
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== h.number) {
|
|
1733
|
+
const n = this._getOrReturnCtx(e);
|
|
1734
|
+
return u(n, {
|
|
1735
|
+
code: d.invalid_type,
|
|
1736
|
+
expected: h.number,
|
|
1737
|
+
received: n.parsedType
|
|
1738
|
+
}), _;
|
|
1739
|
+
}
|
|
1740
|
+
let t;
|
|
1741
|
+
const s = new S();
|
|
1742
|
+
for (const n of this._def.checks)
|
|
1743
|
+
n.kind === "int" ? b.isInteger(e.data) || (t = this._getOrReturnCtx(e, t), u(t, {
|
|
1744
|
+
code: d.invalid_type,
|
|
1745
|
+
expected: "integer",
|
|
1746
|
+
received: "float",
|
|
1747
|
+
message: n.message
|
|
1748
|
+
}), s.dirty()) : n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (t = this._getOrReturnCtx(e, t), u(t, {
|
|
1749
|
+
code: d.too_small,
|
|
1750
|
+
minimum: n.value,
|
|
1751
|
+
type: "number",
|
|
1752
|
+
inclusive: n.inclusive,
|
|
1753
|
+
exact: !1,
|
|
1754
|
+
message: n.message
|
|
1755
|
+
}), s.dirty()) : n.kind === "max" ? (n.inclusive ? e.data > n.value : e.data >= n.value) && (t = this._getOrReturnCtx(e, t), u(t, {
|
|
1756
|
+
code: d.too_big,
|
|
1757
|
+
maximum: n.value,
|
|
1758
|
+
type: "number",
|
|
1759
|
+
inclusive: n.inclusive,
|
|
1760
|
+
exact: !1,
|
|
1761
|
+
message: n.message
|
|
1762
|
+
}), s.dirty()) : n.kind === "multipleOf" ? kt(e.data, n.value) !== 0 && (t = this._getOrReturnCtx(e, t), u(t, {
|
|
1763
|
+
code: d.not_multiple_of,
|
|
1764
|
+
multipleOf: n.value,
|
|
1765
|
+
message: n.message
|
|
1766
|
+
}), s.dirty()) : n.kind === "finite" ? Number.isFinite(e.data) || (t = this._getOrReturnCtx(e, t), u(t, {
|
|
1767
|
+
code: d.not_finite,
|
|
1768
|
+
message: n.message
|
|
1769
|
+
}), s.dirty()) : b.assertNever(n);
|
|
1770
|
+
return { status: s.value, value: e.data };
|
|
1771
|
+
}
|
|
1772
|
+
gte(e, t) {
|
|
1773
|
+
return this.setLimit("min", e, !0, p.toString(t));
|
|
1774
|
+
}
|
|
1775
|
+
gt(e, t) {
|
|
1776
|
+
return this.setLimit("min", e, !1, p.toString(t));
|
|
1777
|
+
}
|
|
1778
|
+
lte(e, t) {
|
|
1779
|
+
return this.setLimit("max", e, !0, p.toString(t));
|
|
1780
|
+
}
|
|
1781
|
+
lt(e, t) {
|
|
1782
|
+
return this.setLimit("max", e, !1, p.toString(t));
|
|
1783
|
+
}
|
|
1784
|
+
setLimit(e, t, s, n) {
|
|
1785
|
+
return new W({
|
|
1786
|
+
...this._def,
|
|
1787
|
+
checks: [
|
|
1788
|
+
...this._def.checks,
|
|
1789
|
+
{
|
|
1790
|
+
kind: e,
|
|
1791
|
+
value: t,
|
|
1792
|
+
inclusive: s,
|
|
1793
|
+
message: p.toString(n)
|
|
1794
|
+
}
|
|
1795
|
+
]
|
|
1796
|
+
});
|
|
1797
|
+
}
|
|
1798
|
+
_addCheck(e) {
|
|
1799
|
+
return new W({
|
|
1800
|
+
...this._def,
|
|
1801
|
+
checks: [...this._def.checks, e]
|
|
1802
|
+
});
|
|
1803
|
+
}
|
|
1804
|
+
int(e) {
|
|
1805
|
+
return this._addCheck({
|
|
1806
|
+
kind: "int",
|
|
1807
|
+
message: p.toString(e)
|
|
1808
|
+
});
|
|
1809
|
+
}
|
|
1810
|
+
positive(e) {
|
|
1811
|
+
return this._addCheck({
|
|
1812
|
+
kind: "min",
|
|
1813
|
+
value: 0,
|
|
1814
|
+
inclusive: !1,
|
|
1815
|
+
message: p.toString(e)
|
|
1816
|
+
});
|
|
1817
|
+
}
|
|
1818
|
+
negative(e) {
|
|
1819
|
+
return this._addCheck({
|
|
1820
|
+
kind: "max",
|
|
1821
|
+
value: 0,
|
|
1822
|
+
inclusive: !1,
|
|
1823
|
+
message: p.toString(e)
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
nonpositive(e) {
|
|
1827
|
+
return this._addCheck({
|
|
1828
|
+
kind: "max",
|
|
1829
|
+
value: 0,
|
|
1830
|
+
inclusive: !0,
|
|
1831
|
+
message: p.toString(e)
|
|
1832
|
+
});
|
|
1833
|
+
}
|
|
1834
|
+
nonnegative(e) {
|
|
1835
|
+
return this._addCheck({
|
|
1836
|
+
kind: "min",
|
|
1837
|
+
value: 0,
|
|
1838
|
+
inclusive: !0,
|
|
1839
|
+
message: p.toString(e)
|
|
1840
|
+
});
|
|
1841
|
+
}
|
|
1842
|
+
multipleOf(e, t) {
|
|
1843
|
+
return this._addCheck({
|
|
1844
|
+
kind: "multipleOf",
|
|
1845
|
+
value: e,
|
|
1846
|
+
message: p.toString(t)
|
|
1847
|
+
});
|
|
1848
|
+
}
|
|
1849
|
+
finite(e) {
|
|
1850
|
+
return this._addCheck({
|
|
1851
|
+
kind: "finite",
|
|
1852
|
+
message: p.toString(e)
|
|
1853
|
+
});
|
|
1854
|
+
}
|
|
1855
|
+
safe(e) {
|
|
1856
|
+
return this._addCheck({
|
|
1857
|
+
kind: "min",
|
|
1858
|
+
inclusive: !0,
|
|
1859
|
+
value: Number.MIN_SAFE_INTEGER,
|
|
1860
|
+
message: p.toString(e)
|
|
1861
|
+
})._addCheck({
|
|
1862
|
+
kind: "max",
|
|
1863
|
+
inclusive: !0,
|
|
1864
|
+
value: Number.MAX_SAFE_INTEGER,
|
|
1865
|
+
message: p.toString(e)
|
|
1866
|
+
});
|
|
1867
|
+
}
|
|
1868
|
+
get minValue() {
|
|
1869
|
+
let e = null;
|
|
1870
|
+
for (const t of this._def.checks)
|
|
1871
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1872
|
+
return e;
|
|
1873
|
+
}
|
|
1874
|
+
get maxValue() {
|
|
1875
|
+
let e = null;
|
|
1876
|
+
for (const t of this._def.checks)
|
|
1877
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1878
|
+
return e;
|
|
1879
|
+
}
|
|
1880
|
+
get isInt() {
|
|
1881
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && b.isInteger(e.value));
|
|
1882
|
+
}
|
|
1883
|
+
get isFinite() {
|
|
1884
|
+
let e = null, t = null;
|
|
1885
|
+
for (const s of this._def.checks) {
|
|
1886
|
+
if (s.kind === "finite" || s.kind === "int" || s.kind === "multipleOf")
|
|
1887
|
+
return !0;
|
|
1888
|
+
s.kind === "min" ? (t === null || s.value > t) && (t = s.value) : s.kind === "max" && (e === null || s.value < e) && (e = s.value);
|
|
1889
|
+
}
|
|
1890
|
+
return Number.isFinite(t) && Number.isFinite(e);
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
W.create = (a) => new W({
|
|
1894
|
+
checks: [],
|
|
1895
|
+
typeName: m.ZodNumber,
|
|
1896
|
+
coerce: (a == null ? void 0 : a.coerce) || !1,
|
|
1897
|
+
...y(a)
|
|
1898
|
+
});
|
|
1899
|
+
class J extends v {
|
|
1900
|
+
constructor() {
|
|
1901
|
+
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1902
|
+
}
|
|
1903
|
+
_parse(e) {
|
|
1904
|
+
if (this._def.coerce)
|
|
1905
|
+
try {
|
|
1906
|
+
e.data = BigInt(e.data);
|
|
1907
|
+
} catch {
|
|
1908
|
+
return this._getInvalidInput(e);
|
|
1909
|
+
}
|
|
1910
|
+
if (this._getType(e) !== h.bigint)
|
|
1911
|
+
return this._getInvalidInput(e);
|
|
1912
|
+
let t;
|
|
1913
|
+
const s = new S();
|
|
1914
|
+
for (const n of this._def.checks)
|
|
1915
|
+
n.kind === "min" ? (n.inclusive ? e.data < n.value : e.data <= n.value) && (t = this._getOrReturnCtx(e, t), u(t, {
|
|
1916
|
+
code: d.too_small,
|
|
1917
|
+
type: "bigint",
|
|
1918
|
+
minimum: n.value,
|
|
1919
|
+
inclusive: n.inclusive,
|
|
1920
|
+
message: n.message
|
|
1921
|
+
}), s.dirty()) : n.kind === "max" ? (n.inclusive ? e.data > n.value : e.data >= n.value) && (t = this._getOrReturnCtx(e, t), u(t, {
|
|
1922
|
+
code: d.too_big,
|
|
1923
|
+
type: "bigint",
|
|
1924
|
+
maximum: n.value,
|
|
1925
|
+
inclusive: n.inclusive,
|
|
1926
|
+
message: n.message
|
|
1927
|
+
}), s.dirty()) : n.kind === "multipleOf" ? e.data % n.value !== BigInt(0) && (t = this._getOrReturnCtx(e, t), u(t, {
|
|
1928
|
+
code: d.not_multiple_of,
|
|
1929
|
+
multipleOf: n.value,
|
|
1930
|
+
message: n.message
|
|
1931
|
+
}), s.dirty()) : b.assertNever(n);
|
|
1932
|
+
return { status: s.value, value: e.data };
|
|
1933
|
+
}
|
|
1934
|
+
_getInvalidInput(e) {
|
|
1935
|
+
const t = this._getOrReturnCtx(e);
|
|
1936
|
+
return u(t, {
|
|
1937
|
+
code: d.invalid_type,
|
|
1938
|
+
expected: h.bigint,
|
|
1939
|
+
received: t.parsedType
|
|
1940
|
+
}), _;
|
|
1941
|
+
}
|
|
1942
|
+
gte(e, t) {
|
|
1943
|
+
return this.setLimit("min", e, !0, p.toString(t));
|
|
1944
|
+
}
|
|
1945
|
+
gt(e, t) {
|
|
1946
|
+
return this.setLimit("min", e, !1, p.toString(t));
|
|
1947
|
+
}
|
|
1948
|
+
lte(e, t) {
|
|
1949
|
+
return this.setLimit("max", e, !0, p.toString(t));
|
|
1950
|
+
}
|
|
1951
|
+
lt(e, t) {
|
|
1952
|
+
return this.setLimit("max", e, !1, p.toString(t));
|
|
1953
|
+
}
|
|
1954
|
+
setLimit(e, t, s, n) {
|
|
1955
|
+
return new J({
|
|
1956
|
+
...this._def,
|
|
1957
|
+
checks: [
|
|
1958
|
+
...this._def.checks,
|
|
1959
|
+
{
|
|
1960
|
+
kind: e,
|
|
1961
|
+
value: t,
|
|
1962
|
+
inclusive: s,
|
|
1963
|
+
message: p.toString(n)
|
|
1964
|
+
}
|
|
1965
|
+
]
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
_addCheck(e) {
|
|
1969
|
+
return new J({
|
|
1970
|
+
...this._def,
|
|
1971
|
+
checks: [...this._def.checks, e]
|
|
1972
|
+
});
|
|
1973
|
+
}
|
|
1974
|
+
positive(e) {
|
|
1975
|
+
return this._addCheck({
|
|
1976
|
+
kind: "min",
|
|
1977
|
+
value: BigInt(0),
|
|
1978
|
+
inclusive: !1,
|
|
1979
|
+
message: p.toString(e)
|
|
1980
|
+
});
|
|
1981
|
+
}
|
|
1982
|
+
negative(e) {
|
|
1983
|
+
return this._addCheck({
|
|
1984
|
+
kind: "max",
|
|
1985
|
+
value: BigInt(0),
|
|
1986
|
+
inclusive: !1,
|
|
1987
|
+
message: p.toString(e)
|
|
1988
|
+
});
|
|
1989
|
+
}
|
|
1990
|
+
nonpositive(e) {
|
|
1991
|
+
return this._addCheck({
|
|
1992
|
+
kind: "max",
|
|
1993
|
+
value: BigInt(0),
|
|
1994
|
+
inclusive: !0,
|
|
1995
|
+
message: p.toString(e)
|
|
1996
|
+
});
|
|
1997
|
+
}
|
|
1998
|
+
nonnegative(e) {
|
|
1999
|
+
return this._addCheck({
|
|
2000
|
+
kind: "min",
|
|
2001
|
+
value: BigInt(0),
|
|
2002
|
+
inclusive: !0,
|
|
2003
|
+
message: p.toString(e)
|
|
2004
|
+
});
|
|
2005
|
+
}
|
|
2006
|
+
multipleOf(e, t) {
|
|
2007
|
+
return this._addCheck({
|
|
2008
|
+
kind: "multipleOf",
|
|
2009
|
+
value: e,
|
|
2010
|
+
message: p.toString(t)
|
|
2011
|
+
});
|
|
2012
|
+
}
|
|
2013
|
+
get minValue() {
|
|
2014
|
+
let e = null;
|
|
2015
|
+
for (const t of this._def.checks)
|
|
2016
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
2017
|
+
return e;
|
|
2018
|
+
}
|
|
2019
|
+
get maxValue() {
|
|
2020
|
+
let e = null;
|
|
2021
|
+
for (const t of this._def.checks)
|
|
2022
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
2023
|
+
return e;
|
|
2024
|
+
}
|
|
2025
|
+
}
|
|
2026
|
+
J.create = (a) => new J({
|
|
2027
|
+
checks: [],
|
|
2028
|
+
typeName: m.ZodBigInt,
|
|
2029
|
+
coerce: (a == null ? void 0 : a.coerce) ?? !1,
|
|
2030
|
+
...y(a)
|
|
2031
|
+
});
|
|
2032
|
+
class we extends v {
|
|
2033
|
+
_parse(e) {
|
|
2034
|
+
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== h.boolean) {
|
|
2035
|
+
const t = this._getOrReturnCtx(e);
|
|
2036
|
+
return u(t, {
|
|
2037
|
+
code: d.invalid_type,
|
|
2038
|
+
expected: h.boolean,
|
|
2039
|
+
received: t.parsedType
|
|
2040
|
+
}), _;
|
|
2041
|
+
}
|
|
2042
|
+
return C(e.data);
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
we.create = (a) => new we({
|
|
2046
|
+
typeName: m.ZodBoolean,
|
|
2047
|
+
coerce: (a == null ? void 0 : a.coerce) || !1,
|
|
2048
|
+
...y(a)
|
|
2049
|
+
});
|
|
2050
|
+
class se extends v {
|
|
2051
|
+
_parse(e) {
|
|
2052
|
+
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== h.date) {
|
|
2053
|
+
const n = this._getOrReturnCtx(e);
|
|
2054
|
+
return u(n, {
|
|
2055
|
+
code: d.invalid_type,
|
|
2056
|
+
expected: h.date,
|
|
2057
|
+
received: n.parsedType
|
|
2058
|
+
}), _;
|
|
2059
|
+
}
|
|
2060
|
+
if (Number.isNaN(e.data.getTime())) {
|
|
2061
|
+
const n = this._getOrReturnCtx(e);
|
|
2062
|
+
return u(n, {
|
|
2063
|
+
code: d.invalid_date
|
|
2064
|
+
}), _;
|
|
2065
|
+
}
|
|
2066
|
+
const t = new S();
|
|
2067
|
+
let s;
|
|
2068
|
+
for (const n of this._def.checks)
|
|
2069
|
+
n.kind === "min" ? e.data.getTime() < n.value && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
2070
|
+
code: d.too_small,
|
|
2071
|
+
message: n.message,
|
|
2072
|
+
inclusive: !0,
|
|
2073
|
+
exact: !1,
|
|
2074
|
+
minimum: n.value,
|
|
2075
|
+
type: "date"
|
|
2076
|
+
}), t.dirty()) : n.kind === "max" ? e.data.getTime() > n.value && (s = this._getOrReturnCtx(e, s), u(s, {
|
|
2077
|
+
code: d.too_big,
|
|
2078
|
+
message: n.message,
|
|
2079
|
+
inclusive: !0,
|
|
2080
|
+
exact: !1,
|
|
2081
|
+
maximum: n.value,
|
|
2082
|
+
type: "date"
|
|
2083
|
+
}), t.dirty()) : b.assertNever(n);
|
|
2084
|
+
return {
|
|
2085
|
+
status: t.value,
|
|
2086
|
+
value: new Date(e.data.getTime())
|
|
2087
|
+
};
|
|
2088
|
+
}
|
|
2089
|
+
_addCheck(e) {
|
|
2090
|
+
return new se({
|
|
2091
|
+
...this._def,
|
|
2092
|
+
checks: [...this._def.checks, e]
|
|
2093
|
+
});
|
|
2094
|
+
}
|
|
2095
|
+
min(e, t) {
|
|
2096
|
+
return this._addCheck({
|
|
2097
|
+
kind: "min",
|
|
2098
|
+
value: e.getTime(),
|
|
2099
|
+
message: p.toString(t)
|
|
2100
|
+
});
|
|
2101
|
+
}
|
|
2102
|
+
max(e, t) {
|
|
2103
|
+
return this._addCheck({
|
|
2104
|
+
kind: "max",
|
|
2105
|
+
value: e.getTime(),
|
|
2106
|
+
message: p.toString(t)
|
|
2107
|
+
});
|
|
2108
|
+
}
|
|
2109
|
+
get minDate() {
|
|
2110
|
+
let e = null;
|
|
2111
|
+
for (const t of this._def.checks)
|
|
2112
|
+
t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
2113
|
+
return e != null ? new Date(e) : null;
|
|
2114
|
+
}
|
|
2115
|
+
get maxDate() {
|
|
2116
|
+
let e = null;
|
|
2117
|
+
for (const t of this._def.checks)
|
|
2118
|
+
t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
2119
|
+
return e != null ? new Date(e) : null;
|
|
2120
|
+
}
|
|
2121
|
+
}
|
|
2122
|
+
se.create = (a) => new se({
|
|
2123
|
+
checks: [],
|
|
2124
|
+
coerce: (a == null ? void 0 : a.coerce) || !1,
|
|
2125
|
+
typeName: m.ZodDate,
|
|
2126
|
+
...y(a)
|
|
2127
|
+
});
|
|
2128
|
+
class ke extends v {
|
|
2129
|
+
_parse(e) {
|
|
2130
|
+
if (this._getType(e) !== h.symbol) {
|
|
2131
|
+
const t = this._getOrReturnCtx(e);
|
|
2132
|
+
return u(t, {
|
|
2133
|
+
code: d.invalid_type,
|
|
2134
|
+
expected: h.symbol,
|
|
2135
|
+
received: t.parsedType
|
|
2136
|
+
}), _;
|
|
2137
|
+
}
|
|
2138
|
+
return C(e.data);
|
|
2139
|
+
}
|
|
2140
|
+
}
|
|
2141
|
+
ke.create = (a) => new ke({
|
|
2142
|
+
typeName: m.ZodSymbol,
|
|
2143
|
+
...y(a)
|
|
2144
|
+
});
|
|
2145
|
+
class xe extends v {
|
|
2146
|
+
_parse(e) {
|
|
2147
|
+
if (this._getType(e) !== h.undefined) {
|
|
2148
|
+
const t = this._getOrReturnCtx(e);
|
|
2149
|
+
return u(t, {
|
|
2150
|
+
code: d.invalid_type,
|
|
2151
|
+
expected: h.undefined,
|
|
2152
|
+
received: t.parsedType
|
|
2153
|
+
}), _;
|
|
2154
|
+
}
|
|
2155
|
+
return C(e.data);
|
|
2156
|
+
}
|
|
2157
|
+
}
|
|
2158
|
+
xe.create = (a) => new xe({
|
|
2159
|
+
typeName: m.ZodUndefined,
|
|
2160
|
+
...y(a)
|
|
2161
|
+
});
|
|
2162
|
+
class Se extends v {
|
|
2163
|
+
_parse(e) {
|
|
2164
|
+
if (this._getType(e) !== h.null) {
|
|
2165
|
+
const t = this._getOrReturnCtx(e);
|
|
2166
|
+
return u(t, {
|
|
2167
|
+
code: d.invalid_type,
|
|
2168
|
+
expected: h.null,
|
|
2169
|
+
received: t.parsedType
|
|
2170
|
+
}), _;
|
|
2171
|
+
}
|
|
2172
|
+
return C(e.data);
|
|
2173
|
+
}
|
|
2174
|
+
}
|
|
2175
|
+
Se.create = (a) => new Se({
|
|
2176
|
+
typeName: m.ZodNull,
|
|
2177
|
+
...y(a)
|
|
2178
|
+
});
|
|
2179
|
+
class de extends v {
|
|
2180
|
+
constructor() {
|
|
2181
|
+
super(...arguments), this._any = !0;
|
|
2182
|
+
}
|
|
2183
|
+
_parse(e) {
|
|
2184
|
+
return C(e.data);
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2187
|
+
de.create = (a) => new de({
|
|
2188
|
+
typeName: m.ZodAny,
|
|
2189
|
+
...y(a)
|
|
2190
|
+
});
|
|
2191
|
+
class Ce extends v {
|
|
2192
|
+
constructor() {
|
|
2193
|
+
super(...arguments), this._unknown = !0;
|
|
2194
|
+
}
|
|
2195
|
+
_parse(e) {
|
|
2196
|
+
return C(e.data);
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2199
|
+
Ce.create = (a) => new Ce({
|
|
2200
|
+
typeName: m.ZodUnknown,
|
|
2201
|
+
...y(a)
|
|
2202
|
+
});
|
|
2203
|
+
class P extends v {
|
|
2204
|
+
_parse(e) {
|
|
2205
|
+
const t = this._getOrReturnCtx(e);
|
|
2206
|
+
return u(t, {
|
|
2207
|
+
code: d.invalid_type,
|
|
2208
|
+
expected: h.never,
|
|
2209
|
+
received: t.parsedType
|
|
2210
|
+
}), _;
|
|
2211
|
+
}
|
|
2212
|
+
}
|
|
2213
|
+
P.create = (a) => new P({
|
|
2214
|
+
typeName: m.ZodNever,
|
|
2215
|
+
...y(a)
|
|
2216
|
+
});
|
|
2217
|
+
class Te extends v {
|
|
2218
|
+
_parse(e) {
|
|
2219
|
+
if (this._getType(e) !== h.undefined) {
|
|
2220
|
+
const t = this._getOrReturnCtx(e);
|
|
2221
|
+
return u(t, {
|
|
2222
|
+
code: d.invalid_type,
|
|
2223
|
+
expected: h.void,
|
|
2224
|
+
received: t.parsedType
|
|
2225
|
+
}), _;
|
|
2226
|
+
}
|
|
2227
|
+
return C(e.data);
|
|
2228
|
+
}
|
|
2229
|
+
}
|
|
2230
|
+
Te.create = (a) => new Te({
|
|
2231
|
+
typeName: m.ZodVoid,
|
|
2232
|
+
...y(a)
|
|
2233
|
+
});
|
|
2234
|
+
class N extends v {
|
|
2235
|
+
_parse(e) {
|
|
2236
|
+
const { ctx: t, status: s } = this._processInputParams(e), n = this._def;
|
|
2237
|
+
if (t.parsedType !== h.array)
|
|
2238
|
+
return u(t, {
|
|
2239
|
+
code: d.invalid_type,
|
|
2240
|
+
expected: h.array,
|
|
2241
|
+
received: t.parsedType
|
|
2242
|
+
}), _;
|
|
2243
|
+
if (n.exactLength !== null) {
|
|
2244
|
+
const i = t.data.length > n.exactLength.value, o = t.data.length < n.exactLength.value;
|
|
2245
|
+
(i || o) && (u(t, {
|
|
2246
|
+
code: i ? d.too_big : d.too_small,
|
|
2247
|
+
minimum: o ? n.exactLength.value : void 0,
|
|
2248
|
+
maximum: i ? n.exactLength.value : void 0,
|
|
2249
|
+
type: "array",
|
|
2250
|
+
inclusive: !0,
|
|
2251
|
+
exact: !0,
|
|
2252
|
+
message: n.exactLength.message
|
|
2253
|
+
}), s.dirty());
|
|
2254
|
+
}
|
|
2255
|
+
if (n.minLength !== null && t.data.length < n.minLength.value && (u(t, {
|
|
2256
|
+
code: d.too_small,
|
|
2257
|
+
minimum: n.minLength.value,
|
|
2258
|
+
type: "array",
|
|
2259
|
+
inclusive: !0,
|
|
2260
|
+
exact: !1,
|
|
2261
|
+
message: n.minLength.message
|
|
2262
|
+
}), s.dirty()), n.maxLength !== null && t.data.length > n.maxLength.value && (u(t, {
|
|
2263
|
+
code: d.too_big,
|
|
2264
|
+
maximum: n.maxLength.value,
|
|
2265
|
+
type: "array",
|
|
2266
|
+
inclusive: !0,
|
|
2267
|
+
exact: !1,
|
|
2268
|
+
message: n.maxLength.message
|
|
2269
|
+
}), s.dirty()), t.common.async)
|
|
2270
|
+
return Promise.all([...t.data].map((i, o) => n.type._parseAsync(new j(t, i, t.path, o)))).then((i) => S.mergeArray(s, i));
|
|
2271
|
+
const r = [...t.data].map((i, o) => n.type._parseSync(new j(t, i, t.path, o)));
|
|
2272
|
+
return S.mergeArray(s, r);
|
|
2273
|
+
}
|
|
2274
|
+
get element() {
|
|
2275
|
+
return this._def.type;
|
|
2276
|
+
}
|
|
2277
|
+
min(e, t) {
|
|
2278
|
+
return new N({
|
|
2279
|
+
...this._def,
|
|
2280
|
+
minLength: { value: e, message: p.toString(t) }
|
|
2281
|
+
});
|
|
2282
|
+
}
|
|
2283
|
+
max(e, t) {
|
|
2284
|
+
return new N({
|
|
2285
|
+
...this._def,
|
|
2286
|
+
maxLength: { value: e, message: p.toString(t) }
|
|
2287
|
+
});
|
|
2288
|
+
}
|
|
2289
|
+
length(e, t) {
|
|
2290
|
+
return new N({
|
|
2291
|
+
...this._def,
|
|
2292
|
+
exactLength: { value: e, message: p.toString(t) }
|
|
2293
|
+
});
|
|
2294
|
+
}
|
|
2295
|
+
nonempty(e) {
|
|
2296
|
+
return this.min(1, e);
|
|
2297
|
+
}
|
|
2298
|
+
}
|
|
2299
|
+
N.create = (a, e) => new N({
|
|
2300
|
+
type: a,
|
|
2301
|
+
minLength: null,
|
|
2302
|
+
maxLength: null,
|
|
2303
|
+
exactLength: null,
|
|
2304
|
+
typeName: m.ZodArray,
|
|
2305
|
+
...y(e)
|
|
2306
|
+
});
|
|
736
2307
|
function q(a) {
|
|
737
|
-
|
|
2308
|
+
if (a instanceof k) {
|
|
2309
|
+
const e = {};
|
|
2310
|
+
for (const t in a.shape) {
|
|
2311
|
+
const s = a.shape[t];
|
|
2312
|
+
e[t] = E.create(q(s));
|
|
2313
|
+
}
|
|
2314
|
+
return new k({
|
|
2315
|
+
...a._def,
|
|
2316
|
+
shape: () => e
|
|
2317
|
+
});
|
|
2318
|
+
} else return a instanceof N ? new N({
|
|
2319
|
+
...a._def,
|
|
2320
|
+
type: q(a.element)
|
|
2321
|
+
}) : a instanceof E ? E.create(q(a.unwrap())) : a instanceof z ? z.create(q(a.unwrap())) : a instanceof $ ? $.create(a.items.map((e) => q(e))) : a;
|
|
738
2322
|
}
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
2323
|
+
class k extends v {
|
|
2324
|
+
constructor() {
|
|
2325
|
+
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
2326
|
+
}
|
|
2327
|
+
_getCached() {
|
|
2328
|
+
if (this._cached !== null)
|
|
2329
|
+
return this._cached;
|
|
2330
|
+
const e = this._def.shape(), t = b.objectKeys(e);
|
|
2331
|
+
return this._cached = { shape: e, keys: t }, this._cached;
|
|
2332
|
+
}
|
|
2333
|
+
_parse(e) {
|
|
2334
|
+
if (this._getType(e) !== h.object) {
|
|
2335
|
+
const c = this._getOrReturnCtx(e);
|
|
2336
|
+
return u(c, {
|
|
2337
|
+
code: d.invalid_type,
|
|
2338
|
+
expected: h.object,
|
|
2339
|
+
received: c.parsedType
|
|
2340
|
+
}), _;
|
|
2341
|
+
}
|
|
2342
|
+
const { status: t, ctx: s } = this._processInputParams(e), { shape: n, keys: r } = this._getCached(), i = [];
|
|
2343
|
+
if (!(this._def.catchall instanceof P && this._def.unknownKeys === "strip"))
|
|
2344
|
+
for (const c in s.data)
|
|
2345
|
+
r.includes(c) || i.push(c);
|
|
2346
|
+
const o = [];
|
|
2347
|
+
for (const c of r) {
|
|
2348
|
+
const l = n[c], g = s.data[c];
|
|
2349
|
+
o.push({
|
|
2350
|
+
key: { status: "valid", value: c },
|
|
2351
|
+
value: l._parse(new j(s, g, s.path, c)),
|
|
2352
|
+
alwaysSet: c in s.data
|
|
2353
|
+
});
|
|
2354
|
+
}
|
|
2355
|
+
if (this._def.catchall instanceof P) {
|
|
2356
|
+
const c = this._def.unknownKeys;
|
|
2357
|
+
if (c === "passthrough")
|
|
2358
|
+
for (const l of i)
|
|
2359
|
+
o.push({
|
|
2360
|
+
key: { status: "valid", value: l },
|
|
2361
|
+
value: { status: "valid", value: s.data[l] }
|
|
2362
|
+
});
|
|
2363
|
+
else if (c === "strict")
|
|
2364
|
+
i.length > 0 && (u(s, {
|
|
2365
|
+
code: d.unrecognized_keys,
|
|
2366
|
+
keys: i
|
|
2367
|
+
}), t.dirty());
|
|
2368
|
+
else if (c !== "strip") throw new Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
2369
|
+
} else {
|
|
2370
|
+
const c = this._def.catchall;
|
|
2371
|
+
for (const l of i) {
|
|
2372
|
+
const g = s.data[l];
|
|
2373
|
+
o.push({
|
|
2374
|
+
key: { status: "valid", value: l },
|
|
2375
|
+
value: c._parse(
|
|
2376
|
+
new j(s, g, s.path, l)
|
|
2377
|
+
//, ctx.child(key), value, getParsedType(value)
|
|
2378
|
+
),
|
|
2379
|
+
alwaysSet: l in s.data
|
|
2380
|
+
});
|
|
2381
|
+
}
|
|
2382
|
+
}
|
|
2383
|
+
return s.common.async ? Promise.resolve().then(async () => {
|
|
2384
|
+
const c = [];
|
|
2385
|
+
for (const l of o) {
|
|
2386
|
+
const g = await l.key, w = await l.value;
|
|
2387
|
+
c.push({
|
|
2388
|
+
key: g,
|
|
2389
|
+
value: w,
|
|
2390
|
+
alwaysSet: l.alwaysSet
|
|
2391
|
+
});
|
|
2392
|
+
}
|
|
2393
|
+
return c;
|
|
2394
|
+
}).then((c) => S.mergeObjectSync(t, c)) : S.mergeObjectSync(t, o);
|
|
2395
|
+
}
|
|
2396
|
+
get shape() {
|
|
2397
|
+
return this._def.shape();
|
|
2398
|
+
}
|
|
2399
|
+
strict(e) {
|
|
2400
|
+
return p.errToObj, new k({
|
|
2401
|
+
...this._def,
|
|
2402
|
+
unknownKeys: "strict",
|
|
2403
|
+
...e !== void 0 ? {
|
|
2404
|
+
errorMap: (t, s) => {
|
|
2405
|
+
var n, r;
|
|
2406
|
+
const i = ((r = (n = this._def).errorMap) == null ? void 0 : r.call(n, t, s).message) ?? s.defaultError;
|
|
2407
|
+
return t.code === "unrecognized_keys" ? {
|
|
2408
|
+
message: p.errToObj(e).message ?? i
|
|
2409
|
+
} : {
|
|
2410
|
+
message: i
|
|
2411
|
+
};
|
|
2412
|
+
}
|
|
2413
|
+
} : {}
|
|
2414
|
+
});
|
|
2415
|
+
}
|
|
2416
|
+
strip() {
|
|
2417
|
+
return new k({
|
|
2418
|
+
...this._def,
|
|
2419
|
+
unknownKeys: "strip"
|
|
2420
|
+
});
|
|
2421
|
+
}
|
|
2422
|
+
passthrough() {
|
|
2423
|
+
return new k({
|
|
2424
|
+
...this._def,
|
|
2425
|
+
unknownKeys: "passthrough"
|
|
2426
|
+
});
|
|
2427
|
+
}
|
|
2428
|
+
// const AugmentFactory =
|
|
2429
|
+
// <Def extends ZodObjectDef>(def: Def) =>
|
|
2430
|
+
// <Augmentation extends ZodRawShape>(
|
|
2431
|
+
// augmentation: Augmentation
|
|
2432
|
+
// ): ZodObject<
|
|
2433
|
+
// extendShape<ReturnType<Def["shape"]>, Augmentation>,
|
|
2434
|
+
// Def["unknownKeys"],
|
|
2435
|
+
// Def["catchall"]
|
|
2436
|
+
// > => {
|
|
2437
|
+
// return new ZodObject({
|
|
2438
|
+
// ...def,
|
|
2439
|
+
// shape: () => ({
|
|
2440
|
+
// ...def.shape(),
|
|
2441
|
+
// ...augmentation,
|
|
2442
|
+
// }),
|
|
2443
|
+
// }) as any;
|
|
2444
|
+
// };
|
|
2445
|
+
extend(e) {
|
|
2446
|
+
return new k({
|
|
2447
|
+
...this._def,
|
|
2448
|
+
shape: () => ({
|
|
2449
|
+
...this._def.shape(),
|
|
2450
|
+
...e
|
|
2451
|
+
})
|
|
2452
|
+
});
|
|
2453
|
+
}
|
|
2454
|
+
/**
|
|
2455
|
+
* Prior to zod@1.0.12 there was a bug in the
|
|
2456
|
+
* inferred type of merged objects. Please
|
|
2457
|
+
* upgrade if you are experiencing issues.
|
|
2458
|
+
*/
|
|
2459
|
+
merge(e) {
|
|
2460
|
+
return new k({
|
|
2461
|
+
unknownKeys: e._def.unknownKeys,
|
|
2462
|
+
catchall: e._def.catchall,
|
|
2463
|
+
shape: () => ({
|
|
2464
|
+
...this._def.shape(),
|
|
2465
|
+
...e._def.shape()
|
|
2466
|
+
}),
|
|
2467
|
+
typeName: m.ZodObject
|
|
2468
|
+
});
|
|
2469
|
+
}
|
|
2470
|
+
// merge<
|
|
2471
|
+
// Incoming extends AnyZodObject,
|
|
2472
|
+
// Augmentation extends Incoming["shape"],
|
|
2473
|
+
// NewOutput extends {
|
|
2474
|
+
// [k in keyof Augmentation | keyof Output]: k extends keyof Augmentation
|
|
2475
|
+
// ? Augmentation[k]["_output"]
|
|
2476
|
+
// : k extends keyof Output
|
|
2477
|
+
// ? Output[k]
|
|
2478
|
+
// : never;
|
|
2479
|
+
// },
|
|
2480
|
+
// NewInput extends {
|
|
2481
|
+
// [k in keyof Augmentation | keyof Input]: k extends keyof Augmentation
|
|
2482
|
+
// ? Augmentation[k]["_input"]
|
|
2483
|
+
// : k extends keyof Input
|
|
2484
|
+
// ? Input[k]
|
|
2485
|
+
// : never;
|
|
2486
|
+
// }
|
|
2487
|
+
// >(
|
|
2488
|
+
// merging: Incoming
|
|
2489
|
+
// ): ZodObject<
|
|
2490
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
2491
|
+
// Incoming["_def"]["unknownKeys"],
|
|
2492
|
+
// Incoming["_def"]["catchall"],
|
|
2493
|
+
// NewOutput,
|
|
2494
|
+
// NewInput
|
|
2495
|
+
// > {
|
|
2496
|
+
// const merged: any = new ZodObject({
|
|
2497
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
2498
|
+
// catchall: merging._def.catchall,
|
|
2499
|
+
// shape: () =>
|
|
2500
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
2501
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
2502
|
+
// }) as any;
|
|
2503
|
+
// return merged;
|
|
2504
|
+
// }
|
|
2505
|
+
setKey(e, t) {
|
|
2506
|
+
return this.augment({ [e]: t });
|
|
2507
|
+
}
|
|
2508
|
+
// merge<Incoming extends AnyZodObject>(
|
|
2509
|
+
// merging: Incoming
|
|
2510
|
+
// ): //ZodObject<T & Incoming["_shape"], UnknownKeys, Catchall> = (merging) => {
|
|
2511
|
+
// ZodObject<
|
|
2512
|
+
// extendShape<T, ReturnType<Incoming["_def"]["shape"]>>,
|
|
2513
|
+
// Incoming["_def"]["unknownKeys"],
|
|
2514
|
+
// Incoming["_def"]["catchall"]
|
|
2515
|
+
// > {
|
|
2516
|
+
// // const mergedShape = objectUtil.mergeShapes(
|
|
2517
|
+
// // this._def.shape(),
|
|
2518
|
+
// // merging._def.shape()
|
|
2519
|
+
// // );
|
|
2520
|
+
// const merged: any = new ZodObject({
|
|
2521
|
+
// unknownKeys: merging._def.unknownKeys,
|
|
2522
|
+
// catchall: merging._def.catchall,
|
|
2523
|
+
// shape: () =>
|
|
2524
|
+
// objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
|
2525
|
+
// typeName: ZodFirstPartyTypeKind.ZodObject,
|
|
2526
|
+
// }) as any;
|
|
2527
|
+
// return merged;
|
|
2528
|
+
// }
|
|
2529
|
+
catchall(e) {
|
|
2530
|
+
return new k({
|
|
2531
|
+
...this._def,
|
|
2532
|
+
catchall: e
|
|
2533
|
+
});
|
|
2534
|
+
}
|
|
2535
|
+
pick(e) {
|
|
2536
|
+
const t = {};
|
|
2537
|
+
for (const s of b.objectKeys(e))
|
|
2538
|
+
e[s] && this.shape[s] && (t[s] = this.shape[s]);
|
|
2539
|
+
return new k({
|
|
2540
|
+
...this._def,
|
|
2541
|
+
shape: () => t
|
|
2542
|
+
});
|
|
2543
|
+
}
|
|
2544
|
+
omit(e) {
|
|
2545
|
+
const t = {};
|
|
2546
|
+
for (const s of b.objectKeys(this.shape))
|
|
2547
|
+
e[s] || (t[s] = this.shape[s]);
|
|
2548
|
+
return new k({
|
|
2549
|
+
...this._def,
|
|
2550
|
+
shape: () => t
|
|
2551
|
+
});
|
|
2552
|
+
}
|
|
2553
|
+
/**
|
|
2554
|
+
* @deprecated
|
|
2555
|
+
*/
|
|
2556
|
+
deepPartial() {
|
|
2557
|
+
return q(this);
|
|
2558
|
+
}
|
|
2559
|
+
partial(e) {
|
|
2560
|
+
const t = {};
|
|
2561
|
+
for (const s of b.objectKeys(this.shape)) {
|
|
2562
|
+
const n = this.shape[s];
|
|
2563
|
+
e && !e[s] ? t[s] = n : t[s] = n.optional();
|
|
2564
|
+
}
|
|
2565
|
+
return new k({
|
|
2566
|
+
...this._def,
|
|
2567
|
+
shape: () => t
|
|
2568
|
+
});
|
|
2569
|
+
}
|
|
2570
|
+
required(e) {
|
|
2571
|
+
const t = {};
|
|
2572
|
+
for (const s of b.objectKeys(this.shape))
|
|
2573
|
+
if (e && !e[s])
|
|
2574
|
+
t[s] = this.shape[s];
|
|
2575
|
+
else {
|
|
2576
|
+
let n = this.shape[s];
|
|
2577
|
+
for (; n instanceof E; )
|
|
2578
|
+
n = n._def.innerType;
|
|
2579
|
+
t[s] = n;
|
|
2580
|
+
}
|
|
2581
|
+
return new k({
|
|
2582
|
+
...this._def,
|
|
2583
|
+
shape: () => t
|
|
2584
|
+
});
|
|
2585
|
+
}
|
|
2586
|
+
keyof() {
|
|
2587
|
+
return je(b.objectKeys(this.shape));
|
|
2588
|
+
}
|
|
2589
|
+
}
|
|
2590
|
+
k.create = (a, e) => new k({
|
|
2591
|
+
shape: () => a,
|
|
2592
|
+
unknownKeys: "strip",
|
|
2593
|
+
catchall: P.create(),
|
|
2594
|
+
typeName: m.ZodObject,
|
|
2595
|
+
...y(e)
|
|
743
2596
|
});
|
|
744
|
-
|
|
2597
|
+
k.strictCreate = (a, e) => new k({
|
|
2598
|
+
shape: () => a,
|
|
2599
|
+
unknownKeys: "strict",
|
|
2600
|
+
catchall: P.create(),
|
|
2601
|
+
typeName: m.ZodObject,
|
|
2602
|
+
...y(e)
|
|
2603
|
+
});
|
|
2604
|
+
k.lazycreate = (a, e) => new k({
|
|
2605
|
+
shape: a,
|
|
2606
|
+
unknownKeys: "strip",
|
|
2607
|
+
catchall: P.create(),
|
|
2608
|
+
typeName: m.ZodObject,
|
|
2609
|
+
...y(e)
|
|
2610
|
+
});
|
|
2611
|
+
class ne extends v {
|
|
2612
|
+
_parse(e) {
|
|
2613
|
+
const { ctx: t } = this._processInputParams(e), s = this._def.options;
|
|
2614
|
+
function n(r) {
|
|
2615
|
+
for (const o of r)
|
|
2616
|
+
if (o.result.status === "valid")
|
|
2617
|
+
return o.result;
|
|
2618
|
+
for (const o of r)
|
|
2619
|
+
if (o.result.status === "dirty")
|
|
2620
|
+
return t.common.issues.push(...o.ctx.common.issues), o.result;
|
|
2621
|
+
const i = r.map((o) => new Z(o.ctx.common.issues));
|
|
2622
|
+
return u(t, {
|
|
2623
|
+
code: d.invalid_union,
|
|
2624
|
+
unionErrors: i
|
|
2625
|
+
}), _;
|
|
2626
|
+
}
|
|
2627
|
+
if (t.common.async)
|
|
2628
|
+
return Promise.all(s.map(async (r) => {
|
|
2629
|
+
const i = {
|
|
2630
|
+
...t,
|
|
2631
|
+
common: {
|
|
2632
|
+
...t.common,
|
|
2633
|
+
issues: []
|
|
2634
|
+
},
|
|
2635
|
+
parent: null
|
|
2636
|
+
};
|
|
2637
|
+
return {
|
|
2638
|
+
result: await r._parseAsync({
|
|
2639
|
+
data: t.data,
|
|
2640
|
+
path: t.path,
|
|
2641
|
+
parent: i
|
|
2642
|
+
}),
|
|
2643
|
+
ctx: i
|
|
2644
|
+
};
|
|
2645
|
+
})).then(n);
|
|
2646
|
+
{
|
|
2647
|
+
let r;
|
|
2648
|
+
const i = [];
|
|
2649
|
+
for (const c of s) {
|
|
2650
|
+
const l = {
|
|
2651
|
+
...t,
|
|
2652
|
+
common: {
|
|
2653
|
+
...t.common,
|
|
2654
|
+
issues: []
|
|
2655
|
+
},
|
|
2656
|
+
parent: null
|
|
2657
|
+
}, g = c._parseSync({
|
|
2658
|
+
data: t.data,
|
|
2659
|
+
path: t.path,
|
|
2660
|
+
parent: l
|
|
2661
|
+
});
|
|
2662
|
+
if (g.status === "valid")
|
|
2663
|
+
return g;
|
|
2664
|
+
g.status === "dirty" && !r && (r = { result: g, ctx: l }), l.common.issues.length && i.push(l.common.issues);
|
|
2665
|
+
}
|
|
2666
|
+
if (r)
|
|
2667
|
+
return t.common.issues.push(...r.ctx.common.issues), r.result;
|
|
2668
|
+
const o = i.map((c) => new Z(c));
|
|
2669
|
+
return u(t, {
|
|
2670
|
+
code: d.invalid_union,
|
|
2671
|
+
unionErrors: o
|
|
2672
|
+
}), _;
|
|
2673
|
+
}
|
|
2674
|
+
}
|
|
2675
|
+
get options() {
|
|
2676
|
+
return this._def.options;
|
|
2677
|
+
}
|
|
2678
|
+
}
|
|
2679
|
+
ne.create = (a, e) => new ne({
|
|
2680
|
+
options: a,
|
|
2681
|
+
typeName: m.ZodUnion,
|
|
2682
|
+
...y(e)
|
|
2683
|
+
});
|
|
2684
|
+
function ue(a, e) {
|
|
2685
|
+
const t = O(a), s = O(e);
|
|
2686
|
+
if (a === e)
|
|
2687
|
+
return { valid: !0, data: a };
|
|
2688
|
+
if (t === h.object && s === h.object) {
|
|
2689
|
+
const n = b.objectKeys(e), r = b.objectKeys(a).filter((o) => n.indexOf(o) !== -1), i = { ...a, ...e };
|
|
2690
|
+
for (const o of r) {
|
|
2691
|
+
const c = ue(a[o], e[o]);
|
|
2692
|
+
if (!c.valid)
|
|
2693
|
+
return { valid: !1 };
|
|
2694
|
+
i[o] = c.data;
|
|
2695
|
+
}
|
|
2696
|
+
return { valid: !0, data: i };
|
|
2697
|
+
} else if (t === h.array && s === h.array) {
|
|
2698
|
+
if (a.length !== e.length)
|
|
2699
|
+
return { valid: !1 };
|
|
2700
|
+
const n = [];
|
|
2701
|
+
for (let r = 0; r < a.length; r++) {
|
|
2702
|
+
const i = a[r], o = e[r], c = ue(i, o);
|
|
2703
|
+
if (!c.valid)
|
|
2704
|
+
return { valid: !1 };
|
|
2705
|
+
n.push(c.data);
|
|
2706
|
+
}
|
|
2707
|
+
return { valid: !0, data: n };
|
|
2708
|
+
} else return t === h.date && s === h.date && +a == +e ? { valid: !0, data: a } : { valid: !1 };
|
|
2709
|
+
}
|
|
2710
|
+
class ae extends v {
|
|
2711
|
+
_parse(e) {
|
|
2712
|
+
const { status: t, ctx: s } = this._processInputParams(e), n = (r, i) => {
|
|
2713
|
+
if (ye(r) || ye(i))
|
|
2714
|
+
return _;
|
|
2715
|
+
const o = ue(r.value, i.value);
|
|
2716
|
+
return o.valid ? ((ve(r) || ve(i)) && t.dirty(), { status: t.value, value: o.data }) : (u(s, {
|
|
2717
|
+
code: d.invalid_intersection_types
|
|
2718
|
+
}), _);
|
|
2719
|
+
};
|
|
2720
|
+
return s.common.async ? Promise.all([
|
|
2721
|
+
this._def.left._parseAsync({
|
|
2722
|
+
data: s.data,
|
|
2723
|
+
path: s.path,
|
|
2724
|
+
parent: s
|
|
2725
|
+
}),
|
|
2726
|
+
this._def.right._parseAsync({
|
|
2727
|
+
data: s.data,
|
|
2728
|
+
path: s.path,
|
|
2729
|
+
parent: s
|
|
2730
|
+
})
|
|
2731
|
+
]).then(([r, i]) => n(r, i)) : n(this._def.left._parseSync({
|
|
2732
|
+
data: s.data,
|
|
2733
|
+
path: s.path,
|
|
2734
|
+
parent: s
|
|
2735
|
+
}), this._def.right._parseSync({
|
|
2736
|
+
data: s.data,
|
|
2737
|
+
path: s.path,
|
|
2738
|
+
parent: s
|
|
2739
|
+
}));
|
|
2740
|
+
}
|
|
2741
|
+
}
|
|
2742
|
+
ae.create = (a, e, t) => new ae({
|
|
2743
|
+
left: a,
|
|
2744
|
+
right: e,
|
|
2745
|
+
typeName: m.ZodIntersection,
|
|
2746
|
+
...y(t)
|
|
2747
|
+
});
|
|
2748
|
+
class $ extends v {
|
|
2749
|
+
_parse(e) {
|
|
2750
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2751
|
+
if (s.parsedType !== h.array)
|
|
2752
|
+
return u(s, {
|
|
2753
|
+
code: d.invalid_type,
|
|
2754
|
+
expected: h.array,
|
|
2755
|
+
received: s.parsedType
|
|
2756
|
+
}), _;
|
|
2757
|
+
if (s.data.length < this._def.items.length)
|
|
2758
|
+
return u(s, {
|
|
2759
|
+
code: d.too_small,
|
|
2760
|
+
minimum: this._def.items.length,
|
|
2761
|
+
inclusive: !0,
|
|
2762
|
+
exact: !1,
|
|
2763
|
+
type: "array"
|
|
2764
|
+
}), _;
|
|
2765
|
+
!this._def.rest && s.data.length > this._def.items.length && (u(s, {
|
|
2766
|
+
code: d.too_big,
|
|
2767
|
+
maximum: this._def.items.length,
|
|
2768
|
+
inclusive: !0,
|
|
2769
|
+
exact: !1,
|
|
2770
|
+
type: "array"
|
|
2771
|
+
}), t.dirty());
|
|
2772
|
+
const n = [...s.data].map((r, i) => {
|
|
2773
|
+
const o = this._def.items[i] || this._def.rest;
|
|
2774
|
+
return o ? o._parse(new j(s, r, s.path, i)) : null;
|
|
2775
|
+
}).filter((r) => !!r);
|
|
2776
|
+
return s.common.async ? Promise.all(n).then((r) => S.mergeArray(t, r)) : S.mergeArray(t, n);
|
|
2777
|
+
}
|
|
2778
|
+
get items() {
|
|
2779
|
+
return this._def.items;
|
|
2780
|
+
}
|
|
2781
|
+
rest(e) {
|
|
2782
|
+
return new $({
|
|
2783
|
+
...this._def,
|
|
2784
|
+
rest: e
|
|
2785
|
+
});
|
|
2786
|
+
}
|
|
2787
|
+
}
|
|
2788
|
+
$.create = (a, e) => {
|
|
2789
|
+
if (!Array.isArray(a))
|
|
2790
|
+
throw new Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2791
|
+
return new $({
|
|
2792
|
+
items: a,
|
|
2793
|
+
typeName: m.ZodTuple,
|
|
2794
|
+
rest: null,
|
|
2795
|
+
...y(e)
|
|
2796
|
+
});
|
|
2797
|
+
};
|
|
2798
|
+
class Ne extends v {
|
|
2799
|
+
get keySchema() {
|
|
2800
|
+
return this._def.keyType;
|
|
2801
|
+
}
|
|
2802
|
+
get valueSchema() {
|
|
2803
|
+
return this._def.valueType;
|
|
2804
|
+
}
|
|
2805
|
+
_parse(e) {
|
|
2806
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2807
|
+
if (s.parsedType !== h.map)
|
|
2808
|
+
return u(s, {
|
|
2809
|
+
code: d.invalid_type,
|
|
2810
|
+
expected: h.map,
|
|
2811
|
+
received: s.parsedType
|
|
2812
|
+
}), _;
|
|
2813
|
+
const n = this._def.keyType, r = this._def.valueType, i = [...s.data.entries()].map(([o, c], l) => ({
|
|
2814
|
+
key: n._parse(new j(s, o, s.path, [l, "key"])),
|
|
2815
|
+
value: r._parse(new j(s, c, s.path, [l, "value"]))
|
|
2816
|
+
}));
|
|
2817
|
+
if (s.common.async) {
|
|
2818
|
+
const o = /* @__PURE__ */ new Map();
|
|
2819
|
+
return Promise.resolve().then(async () => {
|
|
2820
|
+
for (const c of i) {
|
|
2821
|
+
const l = await c.key, g = await c.value;
|
|
2822
|
+
if (l.status === "aborted" || g.status === "aborted")
|
|
2823
|
+
return _;
|
|
2824
|
+
(l.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(l.value, g.value);
|
|
2825
|
+
}
|
|
2826
|
+
return { status: t.value, value: o };
|
|
2827
|
+
});
|
|
2828
|
+
} else {
|
|
2829
|
+
const o = /* @__PURE__ */ new Map();
|
|
2830
|
+
for (const c of i) {
|
|
2831
|
+
const l = c.key, g = c.value;
|
|
2832
|
+
if (l.status === "aborted" || g.status === "aborted")
|
|
2833
|
+
return _;
|
|
2834
|
+
(l.status === "dirty" || g.status === "dirty") && t.dirty(), o.set(l.value, g.value);
|
|
2835
|
+
}
|
|
2836
|
+
return { status: t.value, value: o };
|
|
2837
|
+
}
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
Ne.create = (a, e, t) => new Ne({
|
|
2841
|
+
valueType: e,
|
|
2842
|
+
keyType: a,
|
|
2843
|
+
typeName: m.ZodMap,
|
|
2844
|
+
...y(t)
|
|
2845
|
+
});
|
|
2846
|
+
class Q extends v {
|
|
2847
|
+
_parse(e) {
|
|
2848
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
2849
|
+
if (s.parsedType !== h.set)
|
|
2850
|
+
return u(s, {
|
|
2851
|
+
code: d.invalid_type,
|
|
2852
|
+
expected: h.set,
|
|
2853
|
+
received: s.parsedType
|
|
2854
|
+
}), _;
|
|
2855
|
+
const n = this._def;
|
|
2856
|
+
n.minSize !== null && s.data.size < n.minSize.value && (u(s, {
|
|
2857
|
+
code: d.too_small,
|
|
2858
|
+
minimum: n.minSize.value,
|
|
2859
|
+
type: "set",
|
|
2860
|
+
inclusive: !0,
|
|
2861
|
+
exact: !1,
|
|
2862
|
+
message: n.minSize.message
|
|
2863
|
+
}), t.dirty()), n.maxSize !== null && s.data.size > n.maxSize.value && (u(s, {
|
|
2864
|
+
code: d.too_big,
|
|
2865
|
+
maximum: n.maxSize.value,
|
|
2866
|
+
type: "set",
|
|
2867
|
+
inclusive: !0,
|
|
2868
|
+
exact: !1,
|
|
2869
|
+
message: n.maxSize.message
|
|
2870
|
+
}), t.dirty());
|
|
2871
|
+
const r = this._def.valueType;
|
|
2872
|
+
function i(c) {
|
|
2873
|
+
const l = /* @__PURE__ */ new Set();
|
|
2874
|
+
for (const g of c) {
|
|
2875
|
+
if (g.status === "aborted")
|
|
2876
|
+
return _;
|
|
2877
|
+
g.status === "dirty" && t.dirty(), l.add(g.value);
|
|
2878
|
+
}
|
|
2879
|
+
return { status: t.value, value: l };
|
|
2880
|
+
}
|
|
2881
|
+
const o = [...s.data.values()].map((c, l) => r._parse(new j(s, c, s.path, l)));
|
|
2882
|
+
return s.common.async ? Promise.all(o).then((c) => i(c)) : i(o);
|
|
2883
|
+
}
|
|
2884
|
+
min(e, t) {
|
|
2885
|
+
return new Q({
|
|
2886
|
+
...this._def,
|
|
2887
|
+
minSize: { value: e, message: p.toString(t) }
|
|
2888
|
+
});
|
|
2889
|
+
}
|
|
2890
|
+
max(e, t) {
|
|
2891
|
+
return new Q({
|
|
2892
|
+
...this._def,
|
|
2893
|
+
maxSize: { value: e, message: p.toString(t) }
|
|
2894
|
+
});
|
|
2895
|
+
}
|
|
2896
|
+
size(e, t) {
|
|
2897
|
+
return this.min(e, t).max(e, t);
|
|
2898
|
+
}
|
|
2899
|
+
nonempty(e) {
|
|
2900
|
+
return this.min(1, e);
|
|
2901
|
+
}
|
|
2902
|
+
}
|
|
2903
|
+
Q.create = (a, e) => new Q({
|
|
2904
|
+
valueType: a,
|
|
2905
|
+
minSize: null,
|
|
2906
|
+
maxSize: null,
|
|
2907
|
+
typeName: m.ZodSet,
|
|
2908
|
+
...y(e)
|
|
2909
|
+
});
|
|
2910
|
+
class Ze extends v {
|
|
2911
|
+
get schema() {
|
|
2912
|
+
return this._def.getter();
|
|
2913
|
+
}
|
|
2914
|
+
_parse(e) {
|
|
2915
|
+
const { ctx: t } = this._processInputParams(e);
|
|
2916
|
+
return this._def.getter()._parse({ data: t.data, path: t.path, parent: t });
|
|
2917
|
+
}
|
|
2918
|
+
}
|
|
2919
|
+
Ze.create = (a, e) => new Ze({
|
|
2920
|
+
getter: a,
|
|
2921
|
+
typeName: m.ZodLazy,
|
|
2922
|
+
...y(e)
|
|
2923
|
+
});
|
|
2924
|
+
class le extends v {
|
|
2925
|
+
_parse(e) {
|
|
2926
|
+
if (e.data !== this._def.value) {
|
|
2927
|
+
const t = this._getOrReturnCtx(e);
|
|
2928
|
+
return u(t, {
|
|
2929
|
+
received: t.data,
|
|
2930
|
+
code: d.invalid_literal,
|
|
2931
|
+
expected: this._def.value
|
|
2932
|
+
}), _;
|
|
2933
|
+
}
|
|
2934
|
+
return { status: "valid", value: e.data };
|
|
2935
|
+
}
|
|
2936
|
+
get value() {
|
|
2937
|
+
return this._def.value;
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
le.create = (a, e) => new le({
|
|
2941
|
+
value: a,
|
|
2942
|
+
typeName: m.ZodLiteral,
|
|
2943
|
+
...y(e)
|
|
2944
|
+
});
|
|
2945
|
+
function je(a, e) {
|
|
2946
|
+
return new L({
|
|
2947
|
+
values: a,
|
|
2948
|
+
typeName: m.ZodEnum,
|
|
2949
|
+
...y(e)
|
|
2950
|
+
});
|
|
2951
|
+
}
|
|
2952
|
+
class L extends v {
|
|
2953
|
+
_parse(e) {
|
|
2954
|
+
if (typeof e.data != "string") {
|
|
2955
|
+
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
2956
|
+
return u(t, {
|
|
2957
|
+
expected: b.joinValues(s),
|
|
2958
|
+
received: t.parsedType,
|
|
2959
|
+
code: d.invalid_type
|
|
2960
|
+
}), _;
|
|
2961
|
+
}
|
|
2962
|
+
if (this._cache || (this._cache = new Set(this._def.values)), !this._cache.has(e.data)) {
|
|
2963
|
+
const t = this._getOrReturnCtx(e), s = this._def.values;
|
|
2964
|
+
return u(t, {
|
|
2965
|
+
received: t.data,
|
|
2966
|
+
code: d.invalid_enum_value,
|
|
2967
|
+
options: s
|
|
2968
|
+
}), _;
|
|
2969
|
+
}
|
|
2970
|
+
return C(e.data);
|
|
2971
|
+
}
|
|
2972
|
+
get options() {
|
|
2973
|
+
return this._def.values;
|
|
2974
|
+
}
|
|
2975
|
+
get enum() {
|
|
2976
|
+
const e = {};
|
|
2977
|
+
for (const t of this._def.values)
|
|
2978
|
+
e[t] = t;
|
|
2979
|
+
return e;
|
|
2980
|
+
}
|
|
2981
|
+
get Values() {
|
|
2982
|
+
const e = {};
|
|
2983
|
+
for (const t of this._def.values)
|
|
2984
|
+
e[t] = t;
|
|
2985
|
+
return e;
|
|
2986
|
+
}
|
|
2987
|
+
get Enum() {
|
|
2988
|
+
const e = {};
|
|
2989
|
+
for (const t of this._def.values)
|
|
2990
|
+
e[t] = t;
|
|
2991
|
+
return e;
|
|
2992
|
+
}
|
|
2993
|
+
extract(e, t = this._def) {
|
|
2994
|
+
return L.create(e, {
|
|
2995
|
+
...this._def,
|
|
2996
|
+
...t
|
|
2997
|
+
});
|
|
2998
|
+
}
|
|
2999
|
+
exclude(e, t = this._def) {
|
|
3000
|
+
return L.create(this.options.filter((s) => !e.includes(s)), {
|
|
3001
|
+
...this._def,
|
|
3002
|
+
...t
|
|
3003
|
+
});
|
|
3004
|
+
}
|
|
3005
|
+
}
|
|
3006
|
+
L.create = je;
|
|
3007
|
+
class Ae extends v {
|
|
3008
|
+
_parse(e) {
|
|
3009
|
+
const t = b.getValidEnumValues(this._def.values), s = this._getOrReturnCtx(e);
|
|
3010
|
+
if (s.parsedType !== h.string && s.parsedType !== h.number) {
|
|
3011
|
+
const n = b.objectValues(t);
|
|
3012
|
+
return u(s, {
|
|
3013
|
+
expected: b.joinValues(n),
|
|
3014
|
+
received: s.parsedType,
|
|
3015
|
+
code: d.invalid_type
|
|
3016
|
+
}), _;
|
|
3017
|
+
}
|
|
3018
|
+
if (this._cache || (this._cache = new Set(b.getValidEnumValues(this._def.values))), !this._cache.has(e.data)) {
|
|
3019
|
+
const n = b.objectValues(t);
|
|
3020
|
+
return u(s, {
|
|
3021
|
+
received: s.data,
|
|
3022
|
+
code: d.invalid_enum_value,
|
|
3023
|
+
options: n
|
|
3024
|
+
}), _;
|
|
3025
|
+
}
|
|
3026
|
+
return C(e.data);
|
|
3027
|
+
}
|
|
3028
|
+
get enum() {
|
|
3029
|
+
return this._def.values;
|
|
3030
|
+
}
|
|
3031
|
+
}
|
|
3032
|
+
Ae.create = (a, e) => new Ae({
|
|
3033
|
+
values: a,
|
|
3034
|
+
typeName: m.ZodNativeEnum,
|
|
3035
|
+
...y(e)
|
|
3036
|
+
});
|
|
3037
|
+
class re extends v {
|
|
3038
|
+
unwrap() {
|
|
3039
|
+
return this._def.type;
|
|
3040
|
+
}
|
|
3041
|
+
_parse(e) {
|
|
3042
|
+
const { ctx: t } = this._processInputParams(e);
|
|
3043
|
+
if (t.parsedType !== h.promise && t.common.async === !1)
|
|
3044
|
+
return u(t, {
|
|
3045
|
+
code: d.invalid_type,
|
|
3046
|
+
expected: h.promise,
|
|
3047
|
+
received: t.parsedType
|
|
3048
|
+
}), _;
|
|
3049
|
+
const s = t.parsedType === h.promise ? t.data : Promise.resolve(t.data);
|
|
3050
|
+
return C(s.then((n) => this._def.type.parseAsync(n, {
|
|
3051
|
+
path: t.path,
|
|
3052
|
+
errorMap: t.common.contextualErrorMap
|
|
3053
|
+
})));
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
re.create = (a, e) => new re({
|
|
3057
|
+
type: a,
|
|
3058
|
+
typeName: m.ZodPromise,
|
|
3059
|
+
...y(e)
|
|
3060
|
+
});
|
|
3061
|
+
class H extends v {
|
|
3062
|
+
innerType() {
|
|
3063
|
+
return this._def.schema;
|
|
3064
|
+
}
|
|
3065
|
+
sourceType() {
|
|
3066
|
+
return this._def.schema._def.typeName === m.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
3067
|
+
}
|
|
3068
|
+
_parse(e) {
|
|
3069
|
+
const { status: t, ctx: s } = this._processInputParams(e), n = this._def.effect || null, r = {
|
|
3070
|
+
addIssue: (i) => {
|
|
3071
|
+
u(s, i), i.fatal ? t.abort() : t.dirty();
|
|
3072
|
+
},
|
|
3073
|
+
get path() {
|
|
3074
|
+
return s.path;
|
|
3075
|
+
}
|
|
3076
|
+
};
|
|
3077
|
+
if (r.addIssue = r.addIssue.bind(r), n.type === "preprocess") {
|
|
3078
|
+
const i = n.transform(s.data, r);
|
|
3079
|
+
if (s.common.async)
|
|
3080
|
+
return Promise.resolve(i).then(async (o) => {
|
|
3081
|
+
if (t.value === "aborted")
|
|
3082
|
+
return _;
|
|
3083
|
+
const c = await this._def.schema._parseAsync({
|
|
3084
|
+
data: o,
|
|
3085
|
+
path: s.path,
|
|
3086
|
+
parent: s
|
|
3087
|
+
});
|
|
3088
|
+
return c.status === "aborted" ? _ : c.status === "dirty" || t.value === "dirty" ? ce(c.value) : c;
|
|
3089
|
+
});
|
|
3090
|
+
{
|
|
3091
|
+
if (t.value === "aborted")
|
|
3092
|
+
return _;
|
|
3093
|
+
const o = this._def.schema._parseSync({
|
|
3094
|
+
data: i,
|
|
3095
|
+
path: s.path,
|
|
3096
|
+
parent: s
|
|
3097
|
+
});
|
|
3098
|
+
return o.status === "aborted" ? _ : o.status === "dirty" || t.value === "dirty" ? ce(o.value) : o;
|
|
3099
|
+
}
|
|
3100
|
+
}
|
|
3101
|
+
if (n.type === "refinement") {
|
|
3102
|
+
const i = (o) => {
|
|
3103
|
+
const c = n.refinement(o, r);
|
|
3104
|
+
if (s.common.async)
|
|
3105
|
+
return Promise.resolve(c);
|
|
3106
|
+
if (c instanceof Promise)
|
|
3107
|
+
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
3108
|
+
return o;
|
|
3109
|
+
};
|
|
3110
|
+
if (s.common.async === !1) {
|
|
3111
|
+
const o = this._def.schema._parseSync({
|
|
3112
|
+
data: s.data,
|
|
3113
|
+
path: s.path,
|
|
3114
|
+
parent: s
|
|
3115
|
+
});
|
|
3116
|
+
return o.status === "aborted" ? _ : (o.status === "dirty" && t.dirty(), i(o.value), { status: t.value, value: o.value });
|
|
3117
|
+
} else
|
|
3118
|
+
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 }))));
|
|
3119
|
+
}
|
|
3120
|
+
if (n.type === "transform")
|
|
3121
|
+
if (s.common.async === !1) {
|
|
3122
|
+
const i = this._def.schema._parseSync({
|
|
3123
|
+
data: s.data,
|
|
3124
|
+
path: s.path,
|
|
3125
|
+
parent: s
|
|
3126
|
+
});
|
|
3127
|
+
if (!M(i))
|
|
3128
|
+
return _;
|
|
3129
|
+
const o = n.transform(i.value, r);
|
|
3130
|
+
if (o instanceof Promise)
|
|
3131
|
+
throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
3132
|
+
return { status: t.value, value: o };
|
|
3133
|
+
} else
|
|
3134
|
+
return this._def.schema._parseAsync({ data: s.data, path: s.path, parent: s }).then((i) => M(i) ? Promise.resolve(n.transform(i.value, r)).then((o) => ({
|
|
3135
|
+
status: t.value,
|
|
3136
|
+
value: o
|
|
3137
|
+
})) : _);
|
|
3138
|
+
b.assertNever(n);
|
|
3139
|
+
}
|
|
3140
|
+
}
|
|
3141
|
+
H.create = (a, e, t) => new H({
|
|
3142
|
+
schema: a,
|
|
3143
|
+
typeName: m.ZodEffects,
|
|
3144
|
+
effect: e,
|
|
3145
|
+
...y(t)
|
|
3146
|
+
});
|
|
3147
|
+
H.createWithPreprocess = (a, e, t) => new H({
|
|
3148
|
+
schema: e,
|
|
3149
|
+
effect: { type: "preprocess", transform: a },
|
|
3150
|
+
typeName: m.ZodEffects,
|
|
3151
|
+
...y(t)
|
|
3152
|
+
});
|
|
3153
|
+
class E extends v {
|
|
3154
|
+
_parse(e) {
|
|
3155
|
+
return this._getType(e) === h.undefined ? C(void 0) : this._def.innerType._parse(e);
|
|
3156
|
+
}
|
|
3157
|
+
unwrap() {
|
|
3158
|
+
return this._def.innerType;
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
E.create = (a, e) => new E({
|
|
3162
|
+
innerType: a,
|
|
3163
|
+
typeName: m.ZodOptional,
|
|
3164
|
+
...y(e)
|
|
3165
|
+
});
|
|
3166
|
+
class z extends v {
|
|
3167
|
+
_parse(e) {
|
|
3168
|
+
return this._getType(e) === h.null ? C(null) : this._def.innerType._parse(e);
|
|
3169
|
+
}
|
|
3170
|
+
unwrap() {
|
|
3171
|
+
return this._def.innerType;
|
|
3172
|
+
}
|
|
3173
|
+
}
|
|
3174
|
+
z.create = (a, e) => new z({
|
|
3175
|
+
innerType: a,
|
|
3176
|
+
typeName: m.ZodNullable,
|
|
3177
|
+
...y(e)
|
|
3178
|
+
});
|
|
3179
|
+
class he extends v {
|
|
3180
|
+
_parse(e) {
|
|
3181
|
+
const { ctx: t } = this._processInputParams(e);
|
|
3182
|
+
let s = t.data;
|
|
3183
|
+
return t.parsedType === h.undefined && (s = this._def.defaultValue()), this._def.innerType._parse({
|
|
3184
|
+
data: s,
|
|
3185
|
+
path: t.path,
|
|
3186
|
+
parent: t
|
|
3187
|
+
});
|
|
3188
|
+
}
|
|
3189
|
+
removeDefault() {
|
|
3190
|
+
return this._def.innerType;
|
|
3191
|
+
}
|
|
3192
|
+
}
|
|
3193
|
+
he.create = (a, e) => new he({
|
|
3194
|
+
innerType: a,
|
|
3195
|
+
typeName: m.ZodDefault,
|
|
3196
|
+
defaultValue: typeof e.default == "function" ? e.default : () => e.default,
|
|
3197
|
+
...y(e)
|
|
3198
|
+
});
|
|
3199
|
+
class pe extends v {
|
|
3200
|
+
_parse(e) {
|
|
3201
|
+
const { ctx: t } = this._processInputParams(e), s = {
|
|
3202
|
+
...t,
|
|
3203
|
+
common: {
|
|
3204
|
+
...t.common,
|
|
3205
|
+
issues: []
|
|
3206
|
+
}
|
|
3207
|
+
}, n = this._def.innerType._parse({
|
|
3208
|
+
data: s.data,
|
|
3209
|
+
path: s.path,
|
|
3210
|
+
parent: {
|
|
3211
|
+
...s
|
|
3212
|
+
}
|
|
3213
|
+
});
|
|
3214
|
+
return te(n) ? n.then((r) => ({
|
|
3215
|
+
status: "valid",
|
|
3216
|
+
value: r.status === "valid" ? r.value : this._def.catchValue({
|
|
3217
|
+
get error() {
|
|
3218
|
+
return new Z(s.common.issues);
|
|
3219
|
+
},
|
|
3220
|
+
input: s.data
|
|
3221
|
+
})
|
|
3222
|
+
})) : {
|
|
3223
|
+
status: "valid",
|
|
3224
|
+
value: n.status === "valid" ? n.value : this._def.catchValue({
|
|
3225
|
+
get error() {
|
|
3226
|
+
return new Z(s.common.issues);
|
|
3227
|
+
},
|
|
3228
|
+
input: s.data
|
|
3229
|
+
})
|
|
3230
|
+
};
|
|
3231
|
+
}
|
|
3232
|
+
removeCatch() {
|
|
3233
|
+
return this._def.innerType;
|
|
3234
|
+
}
|
|
3235
|
+
}
|
|
3236
|
+
pe.create = (a, e) => new pe({
|
|
3237
|
+
innerType: a,
|
|
3238
|
+
typeName: m.ZodCatch,
|
|
3239
|
+
catchValue: typeof e.catch == "function" ? e.catch : () => e.catch,
|
|
3240
|
+
...y(e)
|
|
3241
|
+
});
|
|
3242
|
+
class Oe extends v {
|
|
3243
|
+
_parse(e) {
|
|
3244
|
+
if (this._getType(e) !== h.nan) {
|
|
3245
|
+
const t = this._getOrReturnCtx(e);
|
|
3246
|
+
return u(t, {
|
|
3247
|
+
code: d.invalid_type,
|
|
3248
|
+
expected: h.nan,
|
|
3249
|
+
received: t.parsedType
|
|
3250
|
+
}), _;
|
|
3251
|
+
}
|
|
3252
|
+
return { status: "valid", value: e.data };
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3255
|
+
Oe.create = (a) => new Oe({
|
|
3256
|
+
typeName: m.ZodNaN,
|
|
3257
|
+
...y(a)
|
|
3258
|
+
});
|
|
3259
|
+
class xt extends v {
|
|
3260
|
+
_parse(e) {
|
|
3261
|
+
const { ctx: t } = this._processInputParams(e), s = t.data;
|
|
3262
|
+
return this._def.type._parse({
|
|
3263
|
+
data: s,
|
|
3264
|
+
path: t.path,
|
|
3265
|
+
parent: t
|
|
3266
|
+
});
|
|
3267
|
+
}
|
|
3268
|
+
unwrap() {
|
|
3269
|
+
return this._def.type;
|
|
3270
|
+
}
|
|
3271
|
+
}
|
|
3272
|
+
class me extends v {
|
|
3273
|
+
_parse(e) {
|
|
3274
|
+
const { status: t, ctx: s } = this._processInputParams(e);
|
|
3275
|
+
if (s.common.async)
|
|
3276
|
+
return (async () => {
|
|
3277
|
+
const n = await this._def.in._parseAsync({
|
|
3278
|
+
data: s.data,
|
|
3279
|
+
path: s.path,
|
|
3280
|
+
parent: s
|
|
3281
|
+
});
|
|
3282
|
+
return n.status === "aborted" ? _ : n.status === "dirty" ? (t.dirty(), ce(n.value)) : this._def.out._parseAsync({
|
|
3283
|
+
data: n.value,
|
|
3284
|
+
path: s.path,
|
|
3285
|
+
parent: s
|
|
3286
|
+
});
|
|
3287
|
+
})();
|
|
3288
|
+
{
|
|
3289
|
+
const n = this._def.in._parseSync({
|
|
3290
|
+
data: s.data,
|
|
3291
|
+
path: s.path,
|
|
3292
|
+
parent: s
|
|
3293
|
+
});
|
|
3294
|
+
return n.status === "aborted" ? _ : n.status === "dirty" ? (t.dirty(), {
|
|
3295
|
+
status: "dirty",
|
|
3296
|
+
value: n.value
|
|
3297
|
+
}) : this._def.out._parseSync({
|
|
3298
|
+
data: n.value,
|
|
3299
|
+
path: s.path,
|
|
3300
|
+
parent: s
|
|
3301
|
+
});
|
|
3302
|
+
}
|
|
3303
|
+
}
|
|
3304
|
+
static create(e, t) {
|
|
3305
|
+
return new me({
|
|
3306
|
+
in: e,
|
|
3307
|
+
out: t,
|
|
3308
|
+
typeName: m.ZodPipeline
|
|
3309
|
+
});
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3312
|
+
class fe extends v {
|
|
3313
|
+
_parse(e) {
|
|
3314
|
+
const t = this._def.innerType._parse(e), s = (n) => (M(n) && (n.value = Object.freeze(n.value)), n);
|
|
3315
|
+
return te(t) ? t.then((n) => s(n)) : s(t);
|
|
3316
|
+
}
|
|
3317
|
+
unwrap() {
|
|
3318
|
+
return this._def.innerType;
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3321
|
+
fe.create = (a, e) => new fe({
|
|
3322
|
+
innerType: a,
|
|
3323
|
+
typeName: m.ZodReadonly,
|
|
3324
|
+
...y(e)
|
|
3325
|
+
});
|
|
3326
|
+
var m;
|
|
3327
|
+
(function(a) {
|
|
3328
|
+
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";
|
|
3329
|
+
})(m || (m = {}));
|
|
3330
|
+
const A = I.create, Pe = de.create;
|
|
3331
|
+
P.create;
|
|
3332
|
+
N.create;
|
|
3333
|
+
const Re = k.create;
|
|
3334
|
+
ne.create;
|
|
3335
|
+
ae.create;
|
|
3336
|
+
$.create;
|
|
3337
|
+
const $e = le.create;
|
|
3338
|
+
L.create;
|
|
3339
|
+
re.create;
|
|
3340
|
+
E.create;
|
|
3341
|
+
z.create;
|
|
3342
|
+
const St = Re({
|
|
3343
|
+
type: $e("bridge"),
|
|
3344
|
+
name: A(),
|
|
3345
|
+
data: Pe()
|
|
3346
|
+
});
|
|
3347
|
+
Re({
|
|
3348
|
+
type: $e("client"),
|
|
3349
|
+
telemetrySdkVersion: A(),
|
|
3350
|
+
applicationSpecifier: A(),
|
|
3351
|
+
applicationInstance: A(),
|
|
3352
|
+
name: A(),
|
|
3353
|
+
data: Pe(),
|
|
3354
|
+
responseName: A().optional(),
|
|
3355
|
+
subscriptionName: A().optional(),
|
|
3356
|
+
unsubscribeName: A().optional()
|
|
3357
|
+
});
|
|
3358
|
+
function Y(a) {
|
|
3359
|
+
return { ...a, type: "client" };
|
|
3360
|
+
}
|
|
3361
|
+
class Ct {
|
|
745
3362
|
/**
|
|
746
3363
|
* Creates a new RootSettingsNavigation API instance.
|
|
747
3364
|
*
|
|
@@ -765,9 +3382,9 @@ class G {
|
|
|
765
3382
|
*/
|
|
766
3383
|
async setRootSettingsNavigation(e) {
|
|
767
3384
|
var t;
|
|
768
|
-
const s = this._store.shared("root-settings-navigation"), n = (t = await s.get("navigation")) !== null && t !== void 0 ? t : {},
|
|
769
|
-
n[
|
|
770
|
-
applicationSpecifier:
|
|
3385
|
+
const s = this._store.shared("root-settings-navigation"), n = (t = await s.get("navigation")) !== null && t !== void 0 ? t : {}, r = this._store._client._applicationSpecifier;
|
|
3386
|
+
n[r] = {
|
|
3387
|
+
applicationSpecifier: r,
|
|
771
3388
|
entries: e.entries
|
|
772
3389
|
}, s.set("navigation", n);
|
|
773
3390
|
}
|
|
@@ -798,11 +3415,11 @@ class G {
|
|
|
798
3415
|
return (e = await this._store.shared("root-settings-navigation").get("navigation")) !== null && e !== void 0 ? e : {};
|
|
799
3416
|
}
|
|
800
3417
|
}
|
|
801
|
-
const
|
|
802
|
-
function
|
|
803
|
-
|
|
3418
|
+
const B = 1e3 * 30, _e = typeof window > "u" && typeof self < "u", K = _e ? self : window;
|
|
3419
|
+
function U(a) {
|
|
3420
|
+
_e ? self.postMessage(a) : K.parent.postMessage(a, "*");
|
|
804
3421
|
}
|
|
805
|
-
class
|
|
3422
|
+
class Tt {
|
|
806
3423
|
/**
|
|
807
3424
|
* Creates a new Client instance for communicating with the TelemetryOS platform.
|
|
808
3425
|
*
|
|
@@ -811,7 +3428,7 @@ class J {
|
|
|
811
3428
|
* the application ID from the URL.
|
|
812
3429
|
*/
|
|
813
3430
|
constructor() {
|
|
814
|
-
this._applicationInstance = "", this._applicationSpecifier = "", this._deviceId = "", this._navigation = new
|
|
3431
|
+
this._applicationInstance = "", this._applicationSpecifier = "", this._deviceId = "", this._navigation = new Ge(this), this._messageInterceptors = /* @__PURE__ */ new Map(), this._onHandlers = /* @__PURE__ */ new Map(), this._onceHandlers = /* @__PURE__ */ new Map(), this._subscriptionNamesByHandler = /* @__PURE__ */ new Map(), this._subscriptionNamesBySubjectName = /* @__PURE__ */ new Map();
|
|
815
3432
|
}
|
|
816
3433
|
/**
|
|
817
3434
|
* Provides access to the accounts API for retrieving TelemetryOS account information.
|
|
@@ -825,7 +3442,7 @@ class J {
|
|
|
825
3442
|
* @returns An Accounts instance bound to this client
|
|
826
3443
|
*/
|
|
827
3444
|
get accounts() {
|
|
828
|
-
return new
|
|
3445
|
+
return new Le(this);
|
|
829
3446
|
}
|
|
830
3447
|
/**
|
|
831
3448
|
* Provides access to the users API for retrieving TelemetryOS user information.
|
|
@@ -839,7 +3456,7 @@ class J {
|
|
|
839
3456
|
* @returns A Users instance bound to this client
|
|
840
3457
|
*/
|
|
841
3458
|
get users() {
|
|
842
|
-
return new
|
|
3459
|
+
return new Ke(this);
|
|
843
3460
|
}
|
|
844
3461
|
/**
|
|
845
3462
|
* Provides access to the store API for data persistence with multiple storage scopes.
|
|
@@ -853,7 +3470,7 @@ class J {
|
|
|
853
3470
|
* @returns A Store instance bound to this client
|
|
854
3471
|
*/
|
|
855
3472
|
get store() {
|
|
856
|
-
return new
|
|
3473
|
+
return new Ue(this);
|
|
857
3474
|
}
|
|
858
3475
|
/**
|
|
859
3476
|
* Provides access to the applications API for discovering other TelemetryOS applications.
|
|
@@ -867,7 +3484,7 @@ class J {
|
|
|
867
3484
|
* @returns An Applications instance bound to this client
|
|
868
3485
|
*/
|
|
869
3486
|
get applications() {
|
|
870
|
-
return new
|
|
3487
|
+
return new He(this);
|
|
871
3488
|
}
|
|
872
3489
|
/**
|
|
873
3490
|
* Provides access to the media API for working with content hosted on the TelemetryOS platform.
|
|
@@ -882,7 +3499,7 @@ class J {
|
|
|
882
3499
|
* @returns A Media instance bound to this client
|
|
883
3500
|
*/
|
|
884
3501
|
get media() {
|
|
885
|
-
return new
|
|
3502
|
+
return new Ve(this);
|
|
886
3503
|
}
|
|
887
3504
|
/**
|
|
888
3505
|
* Provides access to the proxy API for fetching third-party content through the TelemetryOS API.
|
|
@@ -896,7 +3513,7 @@ class J {
|
|
|
896
3513
|
* @returns A Proxy instance bound to this client
|
|
897
3514
|
*/
|
|
898
3515
|
get proxy() {
|
|
899
|
-
return new
|
|
3516
|
+
return new Be(this);
|
|
900
3517
|
}
|
|
901
3518
|
/**
|
|
902
3519
|
* Provides access to the devices API for interacting with the current device.
|
|
@@ -911,7 +3528,7 @@ class J {
|
|
|
911
3528
|
* @returns A Devices instance bound to this client
|
|
912
3529
|
*/
|
|
913
3530
|
get devices() {
|
|
914
|
-
return new
|
|
3531
|
+
return new ze(this);
|
|
915
3532
|
}
|
|
916
3533
|
/**
|
|
917
3534
|
* Provides access to the root settings navigation API for TelemetryOS administration UI integration.
|
|
@@ -929,7 +3546,7 @@ class J {
|
|
|
929
3546
|
* @throws {Error} If used by an application not mounted at the 'rootSettingsNavigation' mount point
|
|
930
3547
|
*/
|
|
931
3548
|
get rootSettingsNavigation() {
|
|
932
|
-
return new
|
|
3549
|
+
return new Ct(this.store);
|
|
933
3550
|
}
|
|
934
3551
|
/**
|
|
935
3552
|
* Provides access to the weather API for retrieving weather data.
|
|
@@ -943,7 +3560,7 @@ class J {
|
|
|
943
3560
|
* @returns A Weather instance bound to this client
|
|
944
3561
|
*/
|
|
945
3562
|
get weather() {
|
|
946
|
-
return new
|
|
3563
|
+
return new We(this);
|
|
947
3564
|
}
|
|
948
3565
|
/**
|
|
949
3566
|
* Provides access to the currency API for retrieving currency exchange rates.
|
|
@@ -957,7 +3574,7 @@ class J {
|
|
|
957
3574
|
* @returns A Currency instance bound to this client
|
|
958
3575
|
*/
|
|
959
3576
|
get currency() {
|
|
960
|
-
return new
|
|
3577
|
+
return new Je(this);
|
|
961
3578
|
}
|
|
962
3579
|
/**
|
|
963
3580
|
* Provides access to the environment API for accessing environment settings.
|
|
@@ -971,10 +3588,10 @@ class J {
|
|
|
971
3588
|
* @returns An Environment instance bound to this client
|
|
972
3589
|
*/
|
|
973
3590
|
get environment() {
|
|
974
|
-
return new
|
|
3591
|
+
return new De(this);
|
|
975
3592
|
}
|
|
976
3593
|
get mqtt() {
|
|
977
|
-
return new
|
|
3594
|
+
return new Qe(this);
|
|
978
3595
|
}
|
|
979
3596
|
get applicationSpecifier() {
|
|
980
3597
|
return this._applicationSpecifier;
|
|
@@ -1002,46 +3619,53 @@ class J {
|
|
|
1002
3619
|
*/
|
|
1003
3620
|
bind() {
|
|
1004
3621
|
var e, t;
|
|
1005
|
-
const s = new URL(
|
|
3622
|
+
const s = new URL(K.location.href), n = s.searchParams;
|
|
1006
3623
|
this._applicationInstance = n.get("applicationInstance") || "single", this._deviceId = n.get("deviceId") || this._applicationInstance;
|
|
1007
|
-
const
|
|
1008
|
-
if (this._applicationSpecifier = (e = n.get("applicationSpecifier")) !== null && e !== void 0 ? e : "",
|
|
3624
|
+
const r = /^[a-z0-9-]{40}$/i;
|
|
3625
|
+
if (this._applicationSpecifier = (e = n.get("applicationSpecifier")) !== null && e !== void 0 ? e : "", !this._applicationSpecifier || !r.test(this._applicationSpecifier)) {
|
|
3626
|
+
const i = s.hostname.split(".");
|
|
3627
|
+
this._applicationSpecifier = (t = i[0]) !== null && t !== void 0 ? t : "";
|
|
3628
|
+
}
|
|
3629
|
+
if (!this._applicationSpecifier || !r.test(this._applicationSpecifier))
|
|
1009
3630
|
throw console.error("TelemetryOS apps require an applicationSpecifier in the URL query parameters or subdomain. Make sure your app is being served correctly through the TelemetryOS platform or development environment."), new Error(`Invalid applicationSpecifier: expected 40-character hash, got "${this._applicationSpecifier}"`);
|
|
1010
|
-
this._windowMessageHandler = (
|
|
1011
|
-
if (
|
|
3631
|
+
this._windowMessageHandler = (i) => {
|
|
3632
|
+
if (i.source === K || !i.data || typeof i.data != "object" || !("type" in i.data) || i.data.type !== "client" && i.data.type !== "bridge")
|
|
1012
3633
|
return;
|
|
1013
|
-
let
|
|
1014
|
-
if (
|
|
1015
|
-
const
|
|
1016
|
-
if (!
|
|
1017
|
-
|
|
3634
|
+
let o;
|
|
3635
|
+
if (i.data.type === "client") {
|
|
3636
|
+
const c = this._messageInterceptors.get(i.data.name);
|
|
3637
|
+
if (!c) {
|
|
3638
|
+
U(i.data);
|
|
1018
3639
|
return;
|
|
1019
3640
|
}
|
|
1020
|
-
|
|
1021
|
-
...
|
|
3641
|
+
o = {
|
|
3642
|
+
...c(i.data.data),
|
|
1022
3643
|
type: "bridge",
|
|
1023
|
-
...
|
|
3644
|
+
...i.data.responseName ? { name: i.data.responseName } : {}
|
|
1024
3645
|
};
|
|
1025
3646
|
}
|
|
1026
|
-
if (!
|
|
1027
|
-
const
|
|
1028
|
-
if (!
|
|
3647
|
+
if (!o) {
|
|
3648
|
+
const c = St.safeParse(i.data);
|
|
3649
|
+
if (!c.success) {
|
|
3650
|
+
const w = i.data;
|
|
3651
|
+
w && typeof w == "object" && w.type === "bridge" && console.warn("[sdk-client] Received a message that looks like a bridge message but failed schema validation. This may indicate a version mismatch between the SDK and the host environment.", c.error.issues);
|
|
1029
3652
|
return;
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
3653
|
+
}
|
|
3654
|
+
o = c.data;
|
|
3655
|
+
const l = this._onHandlers.get(o.name), g = this._onceHandlers.get(o.name);
|
|
3656
|
+
if (l)
|
|
3657
|
+
for (const w of l)
|
|
3658
|
+
w(o.data);
|
|
3659
|
+
if (g) {
|
|
3660
|
+
for (const w of g)
|
|
3661
|
+
w(o.data);
|
|
3662
|
+
this._onceHandlers.delete(o.name);
|
|
1039
3663
|
}
|
|
1040
3664
|
}
|
|
1041
|
-
if (!
|
|
1042
|
-
for (let
|
|
1043
|
-
window.frames[
|
|
1044
|
-
},
|
|
3665
|
+
if (!_e)
|
|
3666
|
+
for (let c = 0; c < window.frames.length; c += 1)
|
|
3667
|
+
window.frames[c].postMessage(o, "*");
|
|
3668
|
+
}, K.addEventListener("message", this._windowMessageHandler), this._navigation.bind();
|
|
1045
3669
|
}
|
|
1046
3670
|
/**
|
|
1047
3671
|
* Removes the message event listener and cleans up resources.
|
|
@@ -1057,7 +3681,7 @@ class J {
|
|
|
1057
3681
|
* of managing their own Client instances.
|
|
1058
3682
|
*/
|
|
1059
3683
|
unbind() {
|
|
1060
|
-
this._windowMessageHandler && (this._navigation.unbind(),
|
|
3684
|
+
this._windowMessageHandler && (this._navigation.unbind(), K.removeEventListener("message", this._windowMessageHandler));
|
|
1061
3685
|
}
|
|
1062
3686
|
/**
|
|
1063
3687
|
* Sends a one-way message to the TelemetryOS platform.
|
|
@@ -1073,14 +3697,14 @@ class J {
|
|
|
1073
3697
|
* @param data The data payload to include with the message
|
|
1074
3698
|
*/
|
|
1075
3699
|
send(e, t) {
|
|
1076
|
-
const s =
|
|
1077
|
-
telemetrySdkVersion:
|
|
3700
|
+
const s = Y({
|
|
3701
|
+
telemetrySdkVersion: ee,
|
|
1078
3702
|
applicationSpecifier: this._applicationSpecifier,
|
|
1079
3703
|
applicationInstance: this._applicationInstance,
|
|
1080
3704
|
name: e,
|
|
1081
3705
|
data: t
|
|
1082
3706
|
});
|
|
1083
|
-
|
|
3707
|
+
U(s);
|
|
1084
3708
|
}
|
|
1085
3709
|
/**
|
|
1086
3710
|
* Sends a message to the TelemetryOS platform and waits for a response.
|
|
@@ -1103,97 +3727,97 @@ class J {
|
|
|
1103
3727
|
*/
|
|
1104
3728
|
request(e, t, s) {
|
|
1105
3729
|
var n;
|
|
1106
|
-
const
|
|
1107
|
-
telemetrySdkVersion:
|
|
3730
|
+
const r = X(), i = Y({
|
|
3731
|
+
telemetrySdkVersion: ee,
|
|
1108
3732
|
applicationSpecifier: this._applicationSpecifier,
|
|
1109
3733
|
applicationInstance: this._applicationInstance,
|
|
1110
3734
|
name: e,
|
|
1111
3735
|
data: t,
|
|
1112
|
-
responseName:
|
|
1113
|
-
});
|
|
1114
|
-
|
|
1115
|
-
const
|
|
1116
|
-
let
|
|
1117
|
-
const
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
}, this.once(
|
|
1121
|
-
});
|
|
1122
|
-
if (
|
|
1123
|
-
return
|
|
1124
|
-
const
|
|
1125
|
-
const
|
|
3736
|
+
responseName: r
|
|
3737
|
+
});
|
|
3738
|
+
U(i);
|
|
3739
|
+
const o = (n = s == null ? void 0 : s.timeout) !== null && n !== void 0 ? n : B;
|
|
3740
|
+
let c = !1, l;
|
|
3741
|
+
const g = new Promise((T) => {
|
|
3742
|
+
l = (R) => {
|
|
3743
|
+
c || T(R);
|
|
3744
|
+
}, this.once(r, l);
|
|
3745
|
+
});
|
|
3746
|
+
if (o === 0)
|
|
3747
|
+
return g;
|
|
3748
|
+
const w = new Promise((T, R) => {
|
|
3749
|
+
const D = new Error(`${e} message request with response name of ${r} timed out after ${o}`);
|
|
1126
3750
|
setTimeout(() => {
|
|
1127
|
-
|
|
1128
|
-
},
|
|
3751
|
+
c = !0, this.off(r, l), R(D);
|
|
3752
|
+
}, o);
|
|
1129
3753
|
});
|
|
1130
|
-
return Promise.race([
|
|
3754
|
+
return Promise.race([w, g]);
|
|
1131
3755
|
}
|
|
1132
3756
|
async subscribe(e, t, s) {
|
|
1133
|
-
let n,
|
|
1134
|
-
typeof t == "function" ?
|
|
1135
|
-
const
|
|
1136
|
-
let
|
|
1137
|
-
|
|
1138
|
-
const
|
|
1139
|
-
telemetrySdkVersion:
|
|
3757
|
+
let n, r;
|
|
3758
|
+
typeof t == "function" ? r = t : (n = t, r = s);
|
|
3759
|
+
const i = X(), o = X();
|
|
3760
|
+
let c = this._subscriptionNamesBySubjectName.get(e);
|
|
3761
|
+
c || (c = [], this._subscriptionNamesBySubjectName.set(e, c)), c.push(i), this._subscriptionNamesByHandler.set(r, i), this.on(i, r);
|
|
3762
|
+
const l = Y({
|
|
3763
|
+
telemetrySdkVersion: ee,
|
|
1140
3764
|
applicationSpecifier: this._applicationSpecifier,
|
|
1141
3765
|
applicationInstance: this._applicationInstance,
|
|
1142
3766
|
name: e,
|
|
1143
3767
|
data: n,
|
|
1144
|
-
responseName:
|
|
1145
|
-
subscriptionName:
|
|
3768
|
+
responseName: o,
|
|
3769
|
+
subscriptionName: i
|
|
1146
3770
|
});
|
|
1147
|
-
|
|
1148
|
-
let
|
|
1149
|
-
const
|
|
1150
|
-
const
|
|
3771
|
+
U(l);
|
|
3772
|
+
let g = !1, w;
|
|
3773
|
+
const T = new Promise((D, F) => {
|
|
3774
|
+
const V = new Error(`${e} subscribe request with subscription name of ${i} and response name of ${o} timed out after ${B}`);
|
|
1151
3775
|
setTimeout(() => {
|
|
1152
|
-
|
|
1153
|
-
},
|
|
1154
|
-
}),
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
}, this.once(
|
|
3776
|
+
g = !0, this.off(o, w), F(V);
|
|
3777
|
+
}, B);
|
|
3778
|
+
}), R = new Promise((D) => {
|
|
3779
|
+
w = (F) => {
|
|
3780
|
+
g || D(F);
|
|
3781
|
+
}, this.once(o, w);
|
|
1158
3782
|
});
|
|
1159
|
-
return Promise.race([
|
|
3783
|
+
return Promise.race([T, R]);
|
|
1160
3784
|
}
|
|
1161
3785
|
async unsubscribe(e, t, s) {
|
|
1162
|
-
let n,
|
|
1163
|
-
typeof t == "function" ?
|
|
1164
|
-
const
|
|
1165
|
-
let
|
|
1166
|
-
if (
|
|
1167
|
-
const
|
|
1168
|
-
if (!
|
|
3786
|
+
let n, r;
|
|
3787
|
+
typeof t == "function" ? r = t : (n = t, r = s);
|
|
3788
|
+
const i = X();
|
|
3789
|
+
let o = [];
|
|
3790
|
+
if (r) {
|
|
3791
|
+
const c = this._subscriptionNamesByHandler.get(r);
|
|
3792
|
+
if (!c)
|
|
1169
3793
|
return { success: !1 };
|
|
1170
|
-
|
|
3794
|
+
o = [c], this._subscriptionNamesByHandler.delete(r);
|
|
1171
3795
|
} else if (!this._subscriptionNamesBySubjectName.get(e))
|
|
1172
3796
|
return { success: !1 };
|
|
1173
|
-
for await (const
|
|
1174
|
-
this.off(
|
|
1175
|
-
const
|
|
1176
|
-
telemetrySdkVersion:
|
|
3797
|
+
for await (const c of o) {
|
|
3798
|
+
this.off(c, r);
|
|
3799
|
+
const l = Y({
|
|
3800
|
+
telemetrySdkVersion: ee,
|
|
1177
3801
|
applicationInstance: this._applicationInstance,
|
|
1178
3802
|
applicationSpecifier: this._applicationSpecifier,
|
|
1179
3803
|
name: e,
|
|
1180
3804
|
data: n,
|
|
1181
|
-
responseName:
|
|
1182
|
-
unsubscribeName:
|
|
3805
|
+
responseName: i,
|
|
3806
|
+
unsubscribeName: c
|
|
1183
3807
|
});
|
|
1184
|
-
|
|
1185
|
-
let
|
|
1186
|
-
const
|
|
1187
|
-
const
|
|
3808
|
+
U(l);
|
|
3809
|
+
let g = !1, w;
|
|
3810
|
+
const T = new Promise((F, V) => {
|
|
3811
|
+
const Fe = new Error(`${e} unsubscribe request with unsubscribe name of ${c} and response name of ${i} timed out after ${B}`);
|
|
1188
3812
|
setTimeout(() => {
|
|
1189
|
-
|
|
1190
|
-
},
|
|
1191
|
-
}),
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
}, this.once(
|
|
3813
|
+
g = !0, this.off(i, w), V(Fe);
|
|
3814
|
+
}, B);
|
|
3815
|
+
}), R = new Promise((F) => {
|
|
3816
|
+
w = (V) => {
|
|
3817
|
+
g || F(V);
|
|
3818
|
+
}, this.once(i, w);
|
|
1195
3819
|
});
|
|
1196
|
-
if (!(await Promise.race([
|
|
3820
|
+
if (!(await Promise.race([T, R])).success)
|
|
1197
3821
|
return { success: !1 };
|
|
1198
3822
|
}
|
|
1199
3823
|
return { success: !0 };
|
|
@@ -1258,129 +3882,129 @@ class J {
|
|
|
1258
3882
|
const s = this._onHandlers.get(e), n = this._onceHandlers.get(e);
|
|
1259
3883
|
if (!(!s && !n)) {
|
|
1260
3884
|
if (s) {
|
|
1261
|
-
for (let
|
|
1262
|
-
t && s[
|
|
3885
|
+
for (let r = 0; r < s.length; r += 1)
|
|
3886
|
+
t && s[r] !== t || (s.splice(r, 1), r -= 1);
|
|
1263
3887
|
s.length === 0 && this._onHandlers.delete(e);
|
|
1264
3888
|
}
|
|
1265
3889
|
if (n) {
|
|
1266
|
-
for (let
|
|
1267
|
-
t && n[
|
|
3890
|
+
for (let r = 0; r < n.length; r += 1)
|
|
3891
|
+
t && n[r] !== t || (n.splice(r, 1), r -= 1);
|
|
1268
3892
|
n.length === 0 && this._onceHandlers.delete(e);
|
|
1269
3893
|
}
|
|
1270
3894
|
}
|
|
1271
3895
|
}
|
|
1272
3896
|
}
|
|
1273
|
-
function
|
|
3897
|
+
function X() {
|
|
1274
3898
|
return Math.random().toString(36).slice(2, 9);
|
|
1275
3899
|
}
|
|
1276
|
-
const
|
|
1277
|
-
let
|
|
1278
|
-
function
|
|
1279
|
-
return
|
|
3900
|
+
const ee = Me.version;
|
|
3901
|
+
let f = null;
|
|
3902
|
+
function Zt() {
|
|
3903
|
+
return f;
|
|
1280
3904
|
}
|
|
1281
|
-
function
|
|
1282
|
-
|
|
3905
|
+
function At(a) {
|
|
3906
|
+
Nt(), f = new Tt(), f.bind();
|
|
1283
3907
|
}
|
|
1284
|
-
function
|
|
1285
|
-
|
|
3908
|
+
function Nt() {
|
|
3909
|
+
f == null || f.unbind(), f = null;
|
|
1286
3910
|
}
|
|
1287
|
-
function
|
|
1288
|
-
return
|
|
3911
|
+
function Ot(...a) {
|
|
3912
|
+
return x(f), f.on(...a);
|
|
1289
3913
|
}
|
|
1290
|
-
function
|
|
1291
|
-
return
|
|
3914
|
+
function It(...a) {
|
|
3915
|
+
return x(f), f.once(...a);
|
|
1292
3916
|
}
|
|
1293
|
-
function
|
|
1294
|
-
return
|
|
3917
|
+
function Et(...a) {
|
|
3918
|
+
return x(f), f.off(...a);
|
|
1295
3919
|
}
|
|
1296
|
-
function
|
|
1297
|
-
return
|
|
3920
|
+
function jt(...a) {
|
|
3921
|
+
return x(f), f.send(...a);
|
|
1298
3922
|
}
|
|
1299
|
-
function
|
|
1300
|
-
return
|
|
3923
|
+
function Pt(...a) {
|
|
3924
|
+
return x(f), f.request(...a);
|
|
1301
3925
|
}
|
|
1302
|
-
function
|
|
1303
|
-
return
|
|
3926
|
+
function Rt(...a) {
|
|
3927
|
+
return x(f), f.subscribe(...a);
|
|
1304
3928
|
}
|
|
1305
|
-
function
|
|
1306
|
-
return
|
|
3929
|
+
function $t(...a) {
|
|
3930
|
+
return x(f), f.unsubscribe(...a);
|
|
1307
3931
|
}
|
|
1308
|
-
function
|
|
1309
|
-
return
|
|
3932
|
+
function Ft() {
|
|
3933
|
+
return x(f), f.store;
|
|
1310
3934
|
}
|
|
1311
|
-
function
|
|
1312
|
-
return
|
|
3935
|
+
function qt() {
|
|
3936
|
+
return x(f), f.applications;
|
|
1313
3937
|
}
|
|
1314
|
-
function
|
|
1315
|
-
return
|
|
3938
|
+
function Mt() {
|
|
3939
|
+
return x(f), f.media;
|
|
1316
3940
|
}
|
|
1317
|
-
function
|
|
1318
|
-
return
|
|
3941
|
+
function Lt() {
|
|
3942
|
+
return x(f), f.accounts;
|
|
1319
3943
|
}
|
|
1320
|
-
function
|
|
1321
|
-
return
|
|
3944
|
+
function Ht() {
|
|
3945
|
+
return x(f), f.users;
|
|
1322
3946
|
}
|
|
1323
|
-
function
|
|
1324
|
-
return
|
|
3947
|
+
function zt() {
|
|
3948
|
+
return x(f), f.devices;
|
|
1325
3949
|
}
|
|
1326
|
-
function
|
|
1327
|
-
return
|
|
3950
|
+
function Dt() {
|
|
3951
|
+
return x(f), f.proxy;
|
|
1328
3952
|
}
|
|
1329
|
-
function
|
|
1330
|
-
return
|
|
3953
|
+
function Vt() {
|
|
3954
|
+
return x(f), f.rootSettingsNavigation;
|
|
1331
3955
|
}
|
|
1332
|
-
function
|
|
1333
|
-
return
|
|
3956
|
+
function Bt() {
|
|
3957
|
+
return x(f), f.weather;
|
|
1334
3958
|
}
|
|
1335
|
-
function
|
|
1336
|
-
return
|
|
3959
|
+
function Ut() {
|
|
3960
|
+
return x(f), f.currency;
|
|
1337
3961
|
}
|
|
1338
|
-
function
|
|
1339
|
-
return
|
|
3962
|
+
function Kt() {
|
|
3963
|
+
return x(f), f.environment;
|
|
1340
3964
|
}
|
|
1341
|
-
function
|
|
1342
|
-
return
|
|
3965
|
+
function Wt() {
|
|
3966
|
+
return x(f), f.mqtt;
|
|
1343
3967
|
}
|
|
1344
|
-
function
|
|
3968
|
+
function x(a) {
|
|
1345
3969
|
if (!a)
|
|
1346
3970
|
throw new Error("SDK is not configured");
|
|
1347
3971
|
}
|
|
1348
3972
|
export {
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
3973
|
+
Le as Accounts,
|
|
3974
|
+
He as Applications,
|
|
3975
|
+
Tt as Client,
|
|
3976
|
+
Je as Currency,
|
|
3977
|
+
ze as Devices,
|
|
3978
|
+
De as Environment,
|
|
3979
|
+
Ve as Media,
|
|
3980
|
+
Qe as Mqtt,
|
|
3981
|
+
Ge as Navigation,
|
|
3982
|
+
Be as Proxy,
|
|
3983
|
+
Ue as Store,
|
|
3984
|
+
G as StoreSlice,
|
|
3985
|
+
Ke as Users,
|
|
3986
|
+
We as Weather,
|
|
3987
|
+
Lt as accounts,
|
|
3988
|
+
qt as applications,
|
|
3989
|
+
At as configure,
|
|
3990
|
+
Ut as currency,
|
|
3991
|
+
Nt as destroy,
|
|
3992
|
+
zt as devices,
|
|
3993
|
+
Kt as environment,
|
|
3994
|
+
Zt as globalClient,
|
|
3995
|
+
Mt as media,
|
|
3996
|
+
Wt as mqtt,
|
|
3997
|
+
Et as off,
|
|
3998
|
+
Ot as on,
|
|
3999
|
+
It as once,
|
|
4000
|
+
Dt as proxy,
|
|
4001
|
+
Pt as request,
|
|
4002
|
+
Vt as rootSettingsNavigation,
|
|
4003
|
+
jt as send,
|
|
4004
|
+
Ft as store,
|
|
4005
|
+
Rt as subscribe,
|
|
4006
|
+
ee as telemetrySdkVersion,
|
|
4007
|
+
$t as unsubscribe,
|
|
4008
|
+
Ht as users,
|
|
4009
|
+
Bt as weather
|
|
1386
4010
|
};
|