@jtl-software/cloud-apps-core 3.21.0 → 3.24.0-qa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/main.js +94 -579
- package/dist/main.js.map +1 -1
- package/package.json +13 -14
package/dist/main.js
CHANGED
|
@@ -3,7 +3,8 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
|
|
|
3
3
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
4
4
|
var util;
|
|
5
5
|
(function(util2) {
|
|
6
|
-
util2.assertEqual = (
|
|
6
|
+
util2.assertEqual = (_) => {
|
|
7
|
+
};
|
|
7
8
|
function assertIs(_arg) {
|
|
8
9
|
}
|
|
9
10
|
util2.assertIs = assertIs;
|
|
@@ -47,7 +48,7 @@ var util;
|
|
|
47
48
|
}
|
|
48
49
|
return void 0;
|
|
49
50
|
};
|
|
50
|
-
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
|
|
51
|
+
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
|
|
51
52
|
function joinValues(array, separator = " | ") {
|
|
52
53
|
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
|
53
54
|
}
|
|
@@ -99,7 +100,7 @@ const getParsedType = (data) => {
|
|
|
99
100
|
case "string":
|
|
100
101
|
return ZodParsedType.string;
|
|
101
102
|
case "number":
|
|
102
|
-
return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
103
|
+
return Number.isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
|
103
104
|
case "boolean":
|
|
104
105
|
return ZodParsedType.boolean;
|
|
105
106
|
case "function":
|
|
@@ -150,10 +151,6 @@ const ZodIssueCode = util.arrayToEnum([
|
|
|
150
151
|
"not_multiple_of",
|
|
151
152
|
"not_finite"
|
|
152
153
|
]);
|
|
153
|
-
const quotelessJson = (obj) => {
|
|
154
|
-
const json = JSON.stringify(obj, null, 2);
|
|
155
|
-
return json.replace(/"([^"]+)":/g, "$1:");
|
|
156
|
-
};
|
|
157
154
|
class ZodError extends Error {
|
|
158
155
|
get errors() {
|
|
159
156
|
return this.issues;
|
|
@@ -231,8 +228,9 @@ class ZodError extends Error {
|
|
|
231
228
|
const formErrors = [];
|
|
232
229
|
for (const sub of this.issues) {
|
|
233
230
|
if (sub.path.length > 0) {
|
|
234
|
-
|
|
235
|
-
fieldErrors[
|
|
231
|
+
const firstEl = sub.path[0];
|
|
232
|
+
fieldErrors[firstEl] = fieldErrors[firstEl] || [];
|
|
233
|
+
fieldErrors[firstEl].push(mapper(sub));
|
|
236
234
|
} else {
|
|
237
235
|
formErrors.push(mapper(sub));
|
|
238
236
|
}
|
|
@@ -308,6 +306,8 @@ const errorMap = (issue, _ctx) => {
|
|
|
308
306
|
message = `String must contain ${issue.exact ? "exactly" : issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
|
309
307
|
else if (issue.type === "number")
|
|
310
308
|
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
309
|
+
else if (issue.type === "bigint")
|
|
310
|
+
message = `Number must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${issue.minimum}`;
|
|
311
311
|
else if (issue.type === "date")
|
|
312
312
|
message = `Date must be ${issue.exact ? `exactly equal to ` : issue.inclusive ? `greater than or equal to ` : `greater than `}${new Date(Number(issue.minimum))}`;
|
|
313
313
|
else
|
|
@@ -346,9 +346,6 @@ const errorMap = (issue, _ctx) => {
|
|
|
346
346
|
return { message };
|
|
347
347
|
};
|
|
348
348
|
let overrideErrorMap = errorMap;
|
|
349
|
-
function setErrorMap(map) {
|
|
350
|
-
overrideErrorMap = map;
|
|
351
|
-
}
|
|
352
349
|
function getErrorMap() {
|
|
353
350
|
return overrideErrorMap;
|
|
354
351
|
}
|
|
@@ -377,7 +374,6 @@ const makeIssue = (params) => {
|
|
|
377
374
|
message: errorMessage
|
|
378
375
|
};
|
|
379
376
|
};
|
|
380
|
-
const EMPTY_PATH = [];
|
|
381
377
|
function addIssueToContext(ctx, issueData) {
|
|
382
378
|
const overrideMap = getErrorMap();
|
|
383
379
|
const issue = makeIssue({
|
|
@@ -460,24 +456,11 @@ const isAborted = (x) => x.status === "aborted";
|
|
|
460
456
|
const isDirty = (x) => x.status === "dirty";
|
|
461
457
|
const isValid = (x) => x.status === "valid";
|
|
462
458
|
const isAsync = (x) => typeof Promise !== "undefined" && x instanceof Promise;
|
|
463
|
-
function __classPrivateFieldGet(receiver, state, kind, f) {
|
|
464
|
-
if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
465
|
-
return state.get(receiver);
|
|
466
|
-
}
|
|
467
|
-
function __classPrivateFieldSet(receiver, state, value, kind, f) {
|
|
468
|
-
if (typeof state === "function" ? receiver !== state || true : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
469
|
-
return state.set(receiver, value), value;
|
|
470
|
-
}
|
|
471
|
-
typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
|
|
472
|
-
var e = new Error(message);
|
|
473
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
474
|
-
};
|
|
475
459
|
var errorUtil;
|
|
476
460
|
(function(errorUtil2) {
|
|
477
461
|
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
|
478
|
-
errorUtil2.toString = (message) => typeof message === "string" ? message : message
|
|
462
|
+
errorUtil2.toString = (message) => typeof message === "string" ? message : message == null ? void 0 : message.message;
|
|
479
463
|
})(errorUtil || (errorUtil = {}));
|
|
480
|
-
var _ZodEnum_cache, _ZodNativeEnum_cache;
|
|
481
464
|
class ParseInputLazyPath {
|
|
482
465
|
constructor(parent, value, path, key) {
|
|
483
466
|
this._cachedPath = [];
|
|
@@ -488,7 +471,7 @@ class ParseInputLazyPath {
|
|
|
488
471
|
}
|
|
489
472
|
get path() {
|
|
490
473
|
if (!this._cachedPath.length) {
|
|
491
|
-
if (this._key
|
|
474
|
+
if (Array.isArray(this._key)) {
|
|
492
475
|
this._cachedPath.push(...this._path, ...this._key);
|
|
493
476
|
} else {
|
|
494
477
|
this._cachedPath.push(...this._path, this._key);
|
|
@@ -526,17 +509,16 @@ function processCreateParams(params) {
|
|
|
526
509
|
if (errorMap2)
|
|
527
510
|
return { errorMap: errorMap2, description };
|
|
528
511
|
const customMap = (iss, ctx) => {
|
|
529
|
-
var _a, _b;
|
|
530
512
|
const { message } = params;
|
|
531
513
|
if (iss.code === "invalid_enum_value") {
|
|
532
|
-
return { message: message
|
|
514
|
+
return { message: message ?? ctx.defaultError };
|
|
533
515
|
}
|
|
534
516
|
if (typeof ctx.data === "undefined") {
|
|
535
|
-
return { message:
|
|
517
|
+
return { message: message ?? required_error ?? ctx.defaultError };
|
|
536
518
|
}
|
|
537
519
|
if (iss.code !== "invalid_type")
|
|
538
520
|
return { message: ctx.defaultError };
|
|
539
|
-
return { message:
|
|
521
|
+
return { message: message ?? invalid_type_error ?? ctx.defaultError };
|
|
540
522
|
};
|
|
541
523
|
return { errorMap: customMap, description };
|
|
542
524
|
}
|
|
@@ -588,14 +570,13 @@ class ZodType {
|
|
|
588
570
|
throw result.error;
|
|
589
571
|
}
|
|
590
572
|
safeParse(data, params) {
|
|
591
|
-
var _a;
|
|
592
573
|
const ctx = {
|
|
593
574
|
common: {
|
|
594
575
|
issues: [],
|
|
595
|
-
async: (
|
|
596
|
-
contextualErrorMap: params
|
|
576
|
+
async: (params == null ? void 0 : params.async) ?? false,
|
|
577
|
+
contextualErrorMap: params == null ? void 0 : params.errorMap
|
|
597
578
|
},
|
|
598
|
-
path: (params
|
|
579
|
+
path: (params == null ? void 0 : params.path) || [],
|
|
599
580
|
schemaErrorMap: this._def.errorMap,
|
|
600
581
|
parent: null,
|
|
601
582
|
data,
|
|
@@ -626,7 +607,7 @@ class ZodType {
|
|
|
626
607
|
issues: ctx.common.issues
|
|
627
608
|
};
|
|
628
609
|
} catch (err) {
|
|
629
|
-
if ((_b = (_a = err
|
|
610
|
+
if ((_b = (_a = err == null ? void 0 : err.message) == null ? void 0 : _a.toLowerCase()) == null ? void 0 : _b.includes("encountered")) {
|
|
630
611
|
this["~standard"].async = true;
|
|
631
612
|
}
|
|
632
613
|
ctx.common = {
|
|
@@ -651,10 +632,10 @@ class ZodType {
|
|
|
651
632
|
const ctx = {
|
|
652
633
|
common: {
|
|
653
634
|
issues: [],
|
|
654
|
-
contextualErrorMap: params
|
|
635
|
+
contextualErrorMap: params == null ? void 0 : params.errorMap,
|
|
655
636
|
async: true
|
|
656
637
|
},
|
|
657
|
-
path: (params
|
|
638
|
+
path: (params == null ? void 0 : params.path) || [],
|
|
658
639
|
schemaErrorMap: this._def.errorMap,
|
|
659
640
|
parent: null,
|
|
660
641
|
data,
|
|
@@ -844,13 +825,14 @@ const base64urlRegex = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z
|
|
|
844
825
|
const dateRegexSource = `((\\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])))`;
|
|
845
826
|
const dateRegex = new RegExp(`^${dateRegexSource}$`);
|
|
846
827
|
function timeRegexSource(args) {
|
|
847
|
-
let
|
|
828
|
+
let secondsRegexSource = `[0-5]\\d`;
|
|
848
829
|
if (args.precision) {
|
|
849
|
-
|
|
830
|
+
secondsRegexSource = `${secondsRegexSource}\\.\\d{${args.precision}}`;
|
|
850
831
|
} else if (args.precision == null) {
|
|
851
|
-
|
|
832
|
+
secondsRegexSource = `${secondsRegexSource}(\\.\\d+)?`;
|
|
852
833
|
}
|
|
853
|
-
|
|
834
|
+
const secondsQuantifier = args.precision ? "+" : "?";
|
|
835
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${secondsRegexSource})${secondsQuantifier}`;
|
|
854
836
|
}
|
|
855
837
|
function timeRegex(args) {
|
|
856
838
|
return new RegExp(`^${timeRegexSource(args)}$`);
|
|
@@ -878,16 +860,20 @@ function isValidJWT(jwt, alg) {
|
|
|
878
860
|
return false;
|
|
879
861
|
try {
|
|
880
862
|
const [header] = jwt.split(".");
|
|
863
|
+
if (!header)
|
|
864
|
+
return false;
|
|
881
865
|
const base64 = header.replace(/-/g, "+").replace(/_/g, "/").padEnd(header.length + (4 - header.length % 4) % 4, "=");
|
|
882
866
|
const decoded = JSON.parse(atob(base64));
|
|
883
867
|
if (typeof decoded !== "object" || decoded === null)
|
|
884
868
|
return false;
|
|
885
|
-
if (
|
|
869
|
+
if ("typ" in decoded && (decoded == null ? void 0 : decoded.typ) !== "JWT")
|
|
870
|
+
return false;
|
|
871
|
+
if (!decoded.alg)
|
|
886
872
|
return false;
|
|
887
873
|
if (alg && decoded.alg !== alg)
|
|
888
874
|
return false;
|
|
889
875
|
return true;
|
|
890
|
-
} catch
|
|
876
|
+
} catch {
|
|
891
877
|
return false;
|
|
892
878
|
}
|
|
893
879
|
}
|
|
@@ -1046,7 +1032,7 @@ class ZodString extends ZodType {
|
|
|
1046
1032
|
} else if (check.kind === "url") {
|
|
1047
1033
|
try {
|
|
1048
1034
|
new URL(input.data);
|
|
1049
|
-
} catch
|
|
1035
|
+
} catch {
|
|
1050
1036
|
ctx = this._getOrReturnCtx(input, ctx);
|
|
1051
1037
|
addIssueToContext(ctx, {
|
|
1052
1038
|
validation: "url",
|
|
@@ -1258,7 +1244,6 @@ class ZodString extends ZodType {
|
|
|
1258
1244
|
return this._addCheck({ kind: "cidr", ...errorUtil.errToObj(options) });
|
|
1259
1245
|
}
|
|
1260
1246
|
datetime(options) {
|
|
1261
|
-
var _a, _b;
|
|
1262
1247
|
if (typeof options === "string") {
|
|
1263
1248
|
return this._addCheck({
|
|
1264
1249
|
kind: "datetime",
|
|
@@ -1270,10 +1255,10 @@ class ZodString extends ZodType {
|
|
|
1270
1255
|
}
|
|
1271
1256
|
return this._addCheck({
|
|
1272
1257
|
kind: "datetime",
|
|
1273
|
-
precision: typeof (options
|
|
1274
|
-
offset: (
|
|
1275
|
-
local: (
|
|
1276
|
-
...errorUtil.errToObj(options
|
|
1258
|
+
precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,
|
|
1259
|
+
offset: (options == null ? void 0 : options.offset) ?? false,
|
|
1260
|
+
local: (options == null ? void 0 : options.local) ?? false,
|
|
1261
|
+
...errorUtil.errToObj(options == null ? void 0 : options.message)
|
|
1277
1262
|
});
|
|
1278
1263
|
}
|
|
1279
1264
|
date(message) {
|
|
@@ -1289,8 +1274,8 @@ class ZodString extends ZodType {
|
|
|
1289
1274
|
}
|
|
1290
1275
|
return this._addCheck({
|
|
1291
1276
|
kind: "time",
|
|
1292
|
-
precision: typeof (options
|
|
1293
|
-
...errorUtil.errToObj(options
|
|
1277
|
+
precision: typeof (options == null ? void 0 : options.precision) === "undefined" ? null : options == null ? void 0 : options.precision,
|
|
1278
|
+
...errorUtil.errToObj(options == null ? void 0 : options.message)
|
|
1294
1279
|
});
|
|
1295
1280
|
}
|
|
1296
1281
|
duration(message) {
|
|
@@ -1307,8 +1292,8 @@ class ZodString extends ZodType {
|
|
|
1307
1292
|
return this._addCheck({
|
|
1308
1293
|
kind: "includes",
|
|
1309
1294
|
value,
|
|
1310
|
-
position: options
|
|
1311
|
-
...errorUtil.errToObj(options
|
|
1295
|
+
position: options == null ? void 0 : options.position,
|
|
1296
|
+
...errorUtil.errToObj(options == null ? void 0 : options.message)
|
|
1312
1297
|
});
|
|
1313
1298
|
}
|
|
1314
1299
|
startsWith(value, message) {
|
|
@@ -1440,11 +1425,10 @@ class ZodString extends ZodType {
|
|
|
1440
1425
|
}
|
|
1441
1426
|
}
|
|
1442
1427
|
ZodString.create = (params) => {
|
|
1443
|
-
var _a;
|
|
1444
1428
|
return new ZodString({
|
|
1445
1429
|
checks: [],
|
|
1446
1430
|
typeName: ZodFirstPartyTypeKind.ZodString,
|
|
1447
|
-
coerce: (
|
|
1431
|
+
coerce: (params == null ? void 0 : params.coerce) ?? false,
|
|
1448
1432
|
...processCreateParams(params)
|
|
1449
1433
|
});
|
|
1450
1434
|
};
|
|
@@ -1452,9 +1436,9 @@ function floatSafeRemainder(val, step) {
|
|
|
1452
1436
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
1453
1437
|
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
|
1454
1438
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
1455
|
-
const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
|
|
1456
|
-
const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
|
|
1457
|
-
return valInt % stepInt /
|
|
1439
|
+
const valInt = Number.parseInt(val.toFixed(decCount).replace(".", ""));
|
|
1440
|
+
const stepInt = Number.parseInt(step.toFixed(decCount).replace(".", ""));
|
|
1441
|
+
return valInt % stepInt / 10 ** decCount;
|
|
1458
1442
|
}
|
|
1459
1443
|
class ZodNumber extends ZodType {
|
|
1460
1444
|
constructor() {
|
|
@@ -1664,7 +1648,8 @@ class ZodNumber extends ZodType {
|
|
|
1664
1648
|
return !!this._def.checks.find((ch) => ch.kind === "int" || ch.kind === "multipleOf" && util.isInteger(ch.value));
|
|
1665
1649
|
}
|
|
1666
1650
|
get isFinite() {
|
|
1667
|
-
let max = null
|
|
1651
|
+
let max = null;
|
|
1652
|
+
let min = null;
|
|
1668
1653
|
for (const ch of this._def.checks) {
|
|
1669
1654
|
if (ch.kind === "finite" || ch.kind === "int" || ch.kind === "multipleOf") {
|
|
1670
1655
|
return true;
|
|
@@ -1683,7 +1668,7 @@ ZodNumber.create = (params) => {
|
|
|
1683
1668
|
return new ZodNumber({
|
|
1684
1669
|
checks: [],
|
|
1685
1670
|
typeName: ZodFirstPartyTypeKind.ZodNumber,
|
|
1686
|
-
coerce: (params
|
|
1671
|
+
coerce: (params == null ? void 0 : params.coerce) || false,
|
|
1687
1672
|
...processCreateParams(params)
|
|
1688
1673
|
});
|
|
1689
1674
|
};
|
|
@@ -1697,7 +1682,7 @@ class ZodBigInt extends ZodType {
|
|
|
1697
1682
|
if (this._def.coerce) {
|
|
1698
1683
|
try {
|
|
1699
1684
|
input.data = BigInt(input.data);
|
|
1700
|
-
} catch
|
|
1685
|
+
} catch {
|
|
1701
1686
|
return this._getInvalidInput(input);
|
|
1702
1687
|
}
|
|
1703
1688
|
}
|
|
@@ -1852,11 +1837,10 @@ class ZodBigInt extends ZodType {
|
|
|
1852
1837
|
}
|
|
1853
1838
|
}
|
|
1854
1839
|
ZodBigInt.create = (params) => {
|
|
1855
|
-
var _a;
|
|
1856
1840
|
return new ZodBigInt({
|
|
1857
1841
|
checks: [],
|
|
1858
1842
|
typeName: ZodFirstPartyTypeKind.ZodBigInt,
|
|
1859
|
-
coerce: (
|
|
1843
|
+
coerce: (params == null ? void 0 : params.coerce) ?? false,
|
|
1860
1844
|
...processCreateParams(params)
|
|
1861
1845
|
});
|
|
1862
1846
|
};
|
|
@@ -1881,7 +1865,7 @@ class ZodBoolean extends ZodType {
|
|
|
1881
1865
|
ZodBoolean.create = (params) => {
|
|
1882
1866
|
return new ZodBoolean({
|
|
1883
1867
|
typeName: ZodFirstPartyTypeKind.ZodBoolean,
|
|
1884
|
-
coerce: (params
|
|
1868
|
+
coerce: (params == null ? void 0 : params.coerce) || false,
|
|
1885
1869
|
...processCreateParams(params)
|
|
1886
1870
|
});
|
|
1887
1871
|
};
|
|
@@ -1900,7 +1884,7 @@ class ZodDate extends ZodType {
|
|
|
1900
1884
|
});
|
|
1901
1885
|
return INVALID;
|
|
1902
1886
|
}
|
|
1903
|
-
if (isNaN(input.data.getTime())) {
|
|
1887
|
+
if (Number.isNaN(input.data.getTime())) {
|
|
1904
1888
|
const ctx2 = this._getOrReturnCtx(input);
|
|
1905
1889
|
addIssueToContext(ctx2, {
|
|
1906
1890
|
code: ZodIssueCode.invalid_date
|
|
@@ -1989,7 +1973,7 @@ class ZodDate extends ZodType {
|
|
|
1989
1973
|
ZodDate.create = (params) => {
|
|
1990
1974
|
return new ZodDate({
|
|
1991
1975
|
checks: [],
|
|
1992
|
-
coerce: (params
|
|
1976
|
+
coerce: (params == null ? void 0 : params.coerce) || false,
|
|
1993
1977
|
typeName: ZodFirstPartyTypeKind.ZodDate,
|
|
1994
1978
|
...processCreateParams(params)
|
|
1995
1979
|
});
|
|
@@ -2264,7 +2248,8 @@ class ZodObject extends ZodType {
|
|
|
2264
2248
|
return this._cached;
|
|
2265
2249
|
const shape = this._def.shape();
|
|
2266
2250
|
const keys = util.objectKeys(shape);
|
|
2267
|
-
|
|
2251
|
+
this._cached = { shape, keys };
|
|
2252
|
+
return this._cached;
|
|
2268
2253
|
}
|
|
2269
2254
|
_parse(input) {
|
|
2270
2255
|
const parsedType = this._getType(input);
|
|
@@ -2362,11 +2347,11 @@ class ZodObject extends ZodType {
|
|
|
2362
2347
|
unknownKeys: "strict",
|
|
2363
2348
|
...message !== void 0 ? {
|
|
2364
2349
|
errorMap: (issue, ctx) => {
|
|
2365
|
-
var _a, _b
|
|
2366
|
-
const defaultError = (
|
|
2350
|
+
var _a, _b;
|
|
2351
|
+
const defaultError = ((_b = (_a = this._def).errorMap) == null ? void 0 : _b.call(_a, issue, ctx).message) ?? ctx.defaultError;
|
|
2367
2352
|
if (issue.code === "unrecognized_keys")
|
|
2368
2353
|
return {
|
|
2369
|
-
message:
|
|
2354
|
+
message: errorUtil.errToObj(message).message ?? defaultError
|
|
2370
2355
|
};
|
|
2371
2356
|
return {
|
|
2372
2357
|
message: defaultError
|
|
@@ -2497,11 +2482,11 @@ class ZodObject extends ZodType {
|
|
|
2497
2482
|
}
|
|
2498
2483
|
pick(mask) {
|
|
2499
2484
|
const shape = {};
|
|
2500
|
-
util.objectKeys(mask)
|
|
2485
|
+
for (const key of util.objectKeys(mask)) {
|
|
2501
2486
|
if (mask[key] && this.shape[key]) {
|
|
2502
2487
|
shape[key] = this.shape[key];
|
|
2503
2488
|
}
|
|
2504
|
-
}
|
|
2489
|
+
}
|
|
2505
2490
|
return new ZodObject({
|
|
2506
2491
|
...this._def,
|
|
2507
2492
|
shape: () => shape
|
|
@@ -2509,11 +2494,11 @@ class ZodObject extends ZodType {
|
|
|
2509
2494
|
}
|
|
2510
2495
|
omit(mask) {
|
|
2511
2496
|
const shape = {};
|
|
2512
|
-
util.objectKeys(this.shape)
|
|
2497
|
+
for (const key of util.objectKeys(this.shape)) {
|
|
2513
2498
|
if (!mask[key]) {
|
|
2514
2499
|
shape[key] = this.shape[key];
|
|
2515
2500
|
}
|
|
2516
|
-
}
|
|
2501
|
+
}
|
|
2517
2502
|
return new ZodObject({
|
|
2518
2503
|
...this._def,
|
|
2519
2504
|
shape: () => shape
|
|
@@ -2527,14 +2512,14 @@ class ZodObject extends ZodType {
|
|
|
2527
2512
|
}
|
|
2528
2513
|
partial(mask) {
|
|
2529
2514
|
const newShape = {};
|
|
2530
|
-
util.objectKeys(this.shape)
|
|
2515
|
+
for (const key of util.objectKeys(this.shape)) {
|
|
2531
2516
|
const fieldSchema = this.shape[key];
|
|
2532
2517
|
if (mask && !mask[key]) {
|
|
2533
2518
|
newShape[key] = fieldSchema;
|
|
2534
2519
|
} else {
|
|
2535
2520
|
newShape[key] = fieldSchema.optional();
|
|
2536
2521
|
}
|
|
2537
|
-
}
|
|
2522
|
+
}
|
|
2538
2523
|
return new ZodObject({
|
|
2539
2524
|
...this._def,
|
|
2540
2525
|
shape: () => newShape
|
|
@@ -2542,7 +2527,7 @@ class ZodObject extends ZodType {
|
|
|
2542
2527
|
}
|
|
2543
2528
|
required(mask) {
|
|
2544
2529
|
const newShape = {};
|
|
2545
|
-
util.objectKeys(this.shape)
|
|
2530
|
+
for (const key of util.objectKeys(this.shape)) {
|
|
2546
2531
|
if (mask && !mask[key]) {
|
|
2547
2532
|
newShape[key] = this.shape[key];
|
|
2548
2533
|
} else {
|
|
@@ -2553,7 +2538,7 @@ class ZodObject extends ZodType {
|
|
|
2553
2538
|
}
|
|
2554
2539
|
newShape[key] = newField;
|
|
2555
2540
|
}
|
|
2556
|
-
}
|
|
2541
|
+
}
|
|
2557
2542
|
return new ZodObject({
|
|
2558
2543
|
...this._def,
|
|
2559
2544
|
shape: () => newShape
|
|
@@ -2681,113 +2666,6 @@ ZodUnion.create = (types, params) => {
|
|
|
2681
2666
|
...processCreateParams(params)
|
|
2682
2667
|
});
|
|
2683
2668
|
};
|
|
2684
|
-
const getDiscriminator = (type) => {
|
|
2685
|
-
if (type instanceof ZodLazy) {
|
|
2686
|
-
return getDiscriminator(type.schema);
|
|
2687
|
-
} else if (type instanceof ZodEffects) {
|
|
2688
|
-
return getDiscriminator(type.innerType());
|
|
2689
|
-
} else if (type instanceof ZodLiteral) {
|
|
2690
|
-
return [type.value];
|
|
2691
|
-
} else if (type instanceof ZodEnum) {
|
|
2692
|
-
return type.options;
|
|
2693
|
-
} else if (type instanceof ZodNativeEnum) {
|
|
2694
|
-
return util.objectValues(type.enum);
|
|
2695
|
-
} else if (type instanceof ZodDefault) {
|
|
2696
|
-
return getDiscriminator(type._def.innerType);
|
|
2697
|
-
} else if (type instanceof ZodUndefined) {
|
|
2698
|
-
return [void 0];
|
|
2699
|
-
} else if (type instanceof ZodNull) {
|
|
2700
|
-
return [null];
|
|
2701
|
-
} else if (type instanceof ZodOptional) {
|
|
2702
|
-
return [void 0, ...getDiscriminator(type.unwrap())];
|
|
2703
|
-
} else if (type instanceof ZodNullable) {
|
|
2704
|
-
return [null, ...getDiscriminator(type.unwrap())];
|
|
2705
|
-
} else if (type instanceof ZodBranded) {
|
|
2706
|
-
return getDiscriminator(type.unwrap());
|
|
2707
|
-
} else if (type instanceof ZodReadonly) {
|
|
2708
|
-
return getDiscriminator(type.unwrap());
|
|
2709
|
-
} else if (type instanceof ZodCatch) {
|
|
2710
|
-
return getDiscriminator(type._def.innerType);
|
|
2711
|
-
} else {
|
|
2712
|
-
return [];
|
|
2713
|
-
}
|
|
2714
|
-
};
|
|
2715
|
-
class ZodDiscriminatedUnion extends ZodType {
|
|
2716
|
-
_parse(input) {
|
|
2717
|
-
const { ctx } = this._processInputParams(input);
|
|
2718
|
-
if (ctx.parsedType !== ZodParsedType.object) {
|
|
2719
|
-
addIssueToContext(ctx, {
|
|
2720
|
-
code: ZodIssueCode.invalid_type,
|
|
2721
|
-
expected: ZodParsedType.object,
|
|
2722
|
-
received: ctx.parsedType
|
|
2723
|
-
});
|
|
2724
|
-
return INVALID;
|
|
2725
|
-
}
|
|
2726
|
-
const discriminator = this.discriminator;
|
|
2727
|
-
const discriminatorValue = ctx.data[discriminator];
|
|
2728
|
-
const option = this.optionsMap.get(discriminatorValue);
|
|
2729
|
-
if (!option) {
|
|
2730
|
-
addIssueToContext(ctx, {
|
|
2731
|
-
code: ZodIssueCode.invalid_union_discriminator,
|
|
2732
|
-
options: Array.from(this.optionsMap.keys()),
|
|
2733
|
-
path: [discriminator]
|
|
2734
|
-
});
|
|
2735
|
-
return INVALID;
|
|
2736
|
-
}
|
|
2737
|
-
if (ctx.common.async) {
|
|
2738
|
-
return option._parseAsync({
|
|
2739
|
-
data: ctx.data,
|
|
2740
|
-
path: ctx.path,
|
|
2741
|
-
parent: ctx
|
|
2742
|
-
});
|
|
2743
|
-
} else {
|
|
2744
|
-
return option._parseSync({
|
|
2745
|
-
data: ctx.data,
|
|
2746
|
-
path: ctx.path,
|
|
2747
|
-
parent: ctx
|
|
2748
|
-
});
|
|
2749
|
-
}
|
|
2750
|
-
}
|
|
2751
|
-
get discriminator() {
|
|
2752
|
-
return this._def.discriminator;
|
|
2753
|
-
}
|
|
2754
|
-
get options() {
|
|
2755
|
-
return this._def.options;
|
|
2756
|
-
}
|
|
2757
|
-
get optionsMap() {
|
|
2758
|
-
return this._def.optionsMap;
|
|
2759
|
-
}
|
|
2760
|
-
/**
|
|
2761
|
-
* The constructor of the discriminated union schema. Its behaviour is very similar to that of the normal z.union() constructor.
|
|
2762
|
-
* However, it only allows a union of objects, all of which need to share a discriminator property. This property must
|
|
2763
|
-
* have a different value for each object in the union.
|
|
2764
|
-
* @param discriminator the name of the discriminator property
|
|
2765
|
-
* @param types an array of object schemas
|
|
2766
|
-
* @param params
|
|
2767
|
-
*/
|
|
2768
|
-
static create(discriminator, options, params) {
|
|
2769
|
-
const optionsMap = /* @__PURE__ */ new Map();
|
|
2770
|
-
for (const type of options) {
|
|
2771
|
-
const discriminatorValues = getDiscriminator(type.shape[discriminator]);
|
|
2772
|
-
if (!discriminatorValues.length) {
|
|
2773
|
-
throw new Error(`A discriminator value for key \`${discriminator}\` could not be extracted from all schema options`);
|
|
2774
|
-
}
|
|
2775
|
-
for (const value of discriminatorValues) {
|
|
2776
|
-
if (optionsMap.has(value)) {
|
|
2777
|
-
throw new Error(`Discriminator property ${String(discriminator)} has duplicate value ${String(value)}`);
|
|
2778
|
-
}
|
|
2779
|
-
optionsMap.set(value, type);
|
|
2780
|
-
}
|
|
2781
|
-
}
|
|
2782
|
-
return new ZodDiscriminatedUnion({
|
|
2783
|
-
typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
|
|
2784
|
-
discriminator,
|
|
2785
|
-
options,
|
|
2786
|
-
optionsMap,
|
|
2787
|
-
...processCreateParams(params)
|
|
2788
|
-
});
|
|
2789
|
-
}
|
|
2790
|
-
}
|
|
2791
2669
|
function mergeValues(a, b) {
|
|
2792
2670
|
const aType = getParsedType(a);
|
|
2793
2671
|
const bType = getParsedType(b);
|
|
@@ -2946,59 +2824,6 @@ ZodTuple.create = (schemas, params) => {
|
|
|
2946
2824
|
...processCreateParams(params)
|
|
2947
2825
|
});
|
|
2948
2826
|
};
|
|
2949
|
-
class ZodRecord extends ZodType {
|
|
2950
|
-
get keySchema() {
|
|
2951
|
-
return this._def.keyType;
|
|
2952
|
-
}
|
|
2953
|
-
get valueSchema() {
|
|
2954
|
-
return this._def.valueType;
|
|
2955
|
-
}
|
|
2956
|
-
_parse(input) {
|
|
2957
|
-
const { status, ctx } = this._processInputParams(input);
|
|
2958
|
-
if (ctx.parsedType !== ZodParsedType.object) {
|
|
2959
|
-
addIssueToContext(ctx, {
|
|
2960
|
-
code: ZodIssueCode.invalid_type,
|
|
2961
|
-
expected: ZodParsedType.object,
|
|
2962
|
-
received: ctx.parsedType
|
|
2963
|
-
});
|
|
2964
|
-
return INVALID;
|
|
2965
|
-
}
|
|
2966
|
-
const pairs = [];
|
|
2967
|
-
const keyType = this._def.keyType;
|
|
2968
|
-
const valueType = this._def.valueType;
|
|
2969
|
-
for (const key in ctx.data) {
|
|
2970
|
-
pairs.push({
|
|
2971
|
-
key: keyType._parse(new ParseInputLazyPath(ctx, key, ctx.path, key)),
|
|
2972
|
-
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key], ctx.path, key)),
|
|
2973
|
-
alwaysSet: key in ctx.data
|
|
2974
|
-
});
|
|
2975
|
-
}
|
|
2976
|
-
if (ctx.common.async) {
|
|
2977
|
-
return ParseStatus.mergeObjectAsync(status, pairs);
|
|
2978
|
-
} else {
|
|
2979
|
-
return ParseStatus.mergeObjectSync(status, pairs);
|
|
2980
|
-
}
|
|
2981
|
-
}
|
|
2982
|
-
get element() {
|
|
2983
|
-
return this._def.valueType;
|
|
2984
|
-
}
|
|
2985
|
-
static create(first, second, third) {
|
|
2986
|
-
if (second instanceof ZodType) {
|
|
2987
|
-
return new ZodRecord({
|
|
2988
|
-
keyType: first,
|
|
2989
|
-
valueType: second,
|
|
2990
|
-
typeName: ZodFirstPartyTypeKind.ZodRecord,
|
|
2991
|
-
...processCreateParams(third)
|
|
2992
|
-
});
|
|
2993
|
-
}
|
|
2994
|
-
return new ZodRecord({
|
|
2995
|
-
keyType: ZodString.create(),
|
|
2996
|
-
valueType: first,
|
|
2997
|
-
typeName: ZodFirstPartyTypeKind.ZodRecord,
|
|
2998
|
-
...processCreateParams(second)
|
|
2999
|
-
});
|
|
3000
|
-
}
|
|
3001
|
-
}
|
|
3002
2827
|
class ZodMap extends ZodType {
|
|
3003
2828
|
get keySchema() {
|
|
3004
2829
|
return this._def.keyType;
|
|
@@ -3150,121 +2975,6 @@ ZodSet.create = (valueType, params) => {
|
|
|
3150
2975
|
...processCreateParams(params)
|
|
3151
2976
|
});
|
|
3152
2977
|
};
|
|
3153
|
-
class ZodFunction extends ZodType {
|
|
3154
|
-
constructor() {
|
|
3155
|
-
super(...arguments);
|
|
3156
|
-
this.validate = this.implement;
|
|
3157
|
-
}
|
|
3158
|
-
_parse(input) {
|
|
3159
|
-
const { ctx } = this._processInputParams(input);
|
|
3160
|
-
if (ctx.parsedType !== ZodParsedType.function) {
|
|
3161
|
-
addIssueToContext(ctx, {
|
|
3162
|
-
code: ZodIssueCode.invalid_type,
|
|
3163
|
-
expected: ZodParsedType.function,
|
|
3164
|
-
received: ctx.parsedType
|
|
3165
|
-
});
|
|
3166
|
-
return INVALID;
|
|
3167
|
-
}
|
|
3168
|
-
function makeArgsIssue(args, error) {
|
|
3169
|
-
return makeIssue({
|
|
3170
|
-
data: args,
|
|
3171
|
-
path: ctx.path,
|
|
3172
|
-
errorMaps: [
|
|
3173
|
-
ctx.common.contextualErrorMap,
|
|
3174
|
-
ctx.schemaErrorMap,
|
|
3175
|
-
getErrorMap(),
|
|
3176
|
-
errorMap
|
|
3177
|
-
].filter((x) => !!x),
|
|
3178
|
-
issueData: {
|
|
3179
|
-
code: ZodIssueCode.invalid_arguments,
|
|
3180
|
-
argumentsError: error
|
|
3181
|
-
}
|
|
3182
|
-
});
|
|
3183
|
-
}
|
|
3184
|
-
function makeReturnsIssue(returns, error) {
|
|
3185
|
-
return makeIssue({
|
|
3186
|
-
data: returns,
|
|
3187
|
-
path: ctx.path,
|
|
3188
|
-
errorMaps: [
|
|
3189
|
-
ctx.common.contextualErrorMap,
|
|
3190
|
-
ctx.schemaErrorMap,
|
|
3191
|
-
getErrorMap(),
|
|
3192
|
-
errorMap
|
|
3193
|
-
].filter((x) => !!x),
|
|
3194
|
-
issueData: {
|
|
3195
|
-
code: ZodIssueCode.invalid_return_type,
|
|
3196
|
-
returnTypeError: error
|
|
3197
|
-
}
|
|
3198
|
-
});
|
|
3199
|
-
}
|
|
3200
|
-
const params = { errorMap: ctx.common.contextualErrorMap };
|
|
3201
|
-
const fn = ctx.data;
|
|
3202
|
-
if (this._def.returns instanceof ZodPromise) {
|
|
3203
|
-
const me = this;
|
|
3204
|
-
return OK(async function(...args) {
|
|
3205
|
-
const error = new ZodError([]);
|
|
3206
|
-
const parsedArgs = await me._def.args.parseAsync(args, params).catch((e) => {
|
|
3207
|
-
error.addIssue(makeArgsIssue(args, e));
|
|
3208
|
-
throw error;
|
|
3209
|
-
});
|
|
3210
|
-
const result = await Reflect.apply(fn, this, parsedArgs);
|
|
3211
|
-
const parsedReturns = await me._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
|
3212
|
-
error.addIssue(makeReturnsIssue(result, e));
|
|
3213
|
-
throw error;
|
|
3214
|
-
});
|
|
3215
|
-
return parsedReturns;
|
|
3216
|
-
});
|
|
3217
|
-
} else {
|
|
3218
|
-
const me = this;
|
|
3219
|
-
return OK(function(...args) {
|
|
3220
|
-
const parsedArgs = me._def.args.safeParse(args, params);
|
|
3221
|
-
if (!parsedArgs.success) {
|
|
3222
|
-
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
|
3223
|
-
}
|
|
3224
|
-
const result = Reflect.apply(fn, this, parsedArgs.data);
|
|
3225
|
-
const parsedReturns = me._def.returns.safeParse(result, params);
|
|
3226
|
-
if (!parsedReturns.success) {
|
|
3227
|
-
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
|
3228
|
-
}
|
|
3229
|
-
return parsedReturns.data;
|
|
3230
|
-
});
|
|
3231
|
-
}
|
|
3232
|
-
}
|
|
3233
|
-
parameters() {
|
|
3234
|
-
return this._def.args;
|
|
3235
|
-
}
|
|
3236
|
-
returnType() {
|
|
3237
|
-
return this._def.returns;
|
|
3238
|
-
}
|
|
3239
|
-
args(...items) {
|
|
3240
|
-
return new ZodFunction({
|
|
3241
|
-
...this._def,
|
|
3242
|
-
args: ZodTuple.create(items).rest(ZodUnknown.create())
|
|
3243
|
-
});
|
|
3244
|
-
}
|
|
3245
|
-
returns(returnType) {
|
|
3246
|
-
return new ZodFunction({
|
|
3247
|
-
...this._def,
|
|
3248
|
-
returns: returnType
|
|
3249
|
-
});
|
|
3250
|
-
}
|
|
3251
|
-
implement(func) {
|
|
3252
|
-
const validatedFunc = this.parse(func);
|
|
3253
|
-
return validatedFunc;
|
|
3254
|
-
}
|
|
3255
|
-
strictImplement(func) {
|
|
3256
|
-
const validatedFunc = this.parse(func);
|
|
3257
|
-
return validatedFunc;
|
|
3258
|
-
}
|
|
3259
|
-
static create(args, returns, params) {
|
|
3260
|
-
return new ZodFunction({
|
|
3261
|
-
args: args ? args : ZodTuple.create([]).rest(ZodUnknown.create()),
|
|
3262
|
-
returns: returns || ZodUnknown.create(),
|
|
3263
|
-
typeName: ZodFirstPartyTypeKind.ZodFunction,
|
|
3264
|
-
...processCreateParams(params)
|
|
3265
|
-
});
|
|
3266
|
-
}
|
|
3267
|
-
}
|
|
3268
2978
|
class ZodLazy extends ZodType {
|
|
3269
2979
|
get schema() {
|
|
3270
2980
|
return this._def.getter();
|
|
@@ -3314,10 +3024,6 @@ function createZodEnum(values, params) {
|
|
|
3314
3024
|
});
|
|
3315
3025
|
}
|
|
3316
3026
|
class ZodEnum extends ZodType {
|
|
3317
|
-
constructor() {
|
|
3318
|
-
super(...arguments);
|
|
3319
|
-
_ZodEnum_cache.set(this, void 0);
|
|
3320
|
-
}
|
|
3321
3027
|
_parse(input) {
|
|
3322
3028
|
if (typeof input.data !== "string") {
|
|
3323
3029
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3329,10 +3035,10 @@ class ZodEnum extends ZodType {
|
|
|
3329
3035
|
});
|
|
3330
3036
|
return INVALID;
|
|
3331
3037
|
}
|
|
3332
|
-
if (!
|
|
3333
|
-
|
|
3038
|
+
if (!this._cache) {
|
|
3039
|
+
this._cache = new Set(this._def.values);
|
|
3334
3040
|
}
|
|
3335
|
-
if (!
|
|
3041
|
+
if (!this._cache.has(input.data)) {
|
|
3336
3042
|
const ctx = this._getOrReturnCtx(input);
|
|
3337
3043
|
const expectedValues = this._def.values;
|
|
3338
3044
|
addIssueToContext(ctx, {
|
|
@@ -3381,13 +3087,8 @@ class ZodEnum extends ZodType {
|
|
|
3381
3087
|
});
|
|
3382
3088
|
}
|
|
3383
3089
|
}
|
|
3384
|
-
_ZodEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3385
3090
|
ZodEnum.create = createZodEnum;
|
|
3386
3091
|
class ZodNativeEnum extends ZodType {
|
|
3387
|
-
constructor() {
|
|
3388
|
-
super(...arguments);
|
|
3389
|
-
_ZodNativeEnum_cache.set(this, void 0);
|
|
3390
|
-
}
|
|
3391
3092
|
_parse(input) {
|
|
3392
3093
|
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
|
3393
3094
|
const ctx = this._getOrReturnCtx(input);
|
|
@@ -3400,10 +3101,10 @@ class ZodNativeEnum extends ZodType {
|
|
|
3400
3101
|
});
|
|
3401
3102
|
return INVALID;
|
|
3402
3103
|
}
|
|
3403
|
-
if (!
|
|
3404
|
-
|
|
3104
|
+
if (!this._cache) {
|
|
3105
|
+
this._cache = new Set(util.getValidEnumValues(this._def.values));
|
|
3405
3106
|
}
|
|
3406
|
-
if (!
|
|
3107
|
+
if (!this._cache.has(input.data)) {
|
|
3407
3108
|
const expectedValues = util.objectValues(nativeEnumValues);
|
|
3408
3109
|
addIssueToContext(ctx, {
|
|
3409
3110
|
received: ctx.data,
|
|
@@ -3418,7 +3119,6 @@ class ZodNativeEnum extends ZodType {
|
|
|
3418
3119
|
return this._def.values;
|
|
3419
3120
|
}
|
|
3420
3121
|
}
|
|
3421
|
-
_ZodNativeEnum_cache = /* @__PURE__ */ new WeakMap();
|
|
3422
3122
|
ZodNativeEnum.create = (values, params) => {
|
|
3423
3123
|
return new ZodNativeEnum({
|
|
3424
3124
|
values,
|
|
@@ -3559,7 +3259,7 @@ class ZodEffects extends ZodType {
|
|
|
3559
3259
|
parent: ctx
|
|
3560
3260
|
});
|
|
3561
3261
|
if (!isValid(base))
|
|
3562
|
-
return
|
|
3262
|
+
return INVALID;
|
|
3563
3263
|
const result = effect.transform(base.value, checkCtx);
|
|
3564
3264
|
if (result instanceof Promise) {
|
|
3565
3265
|
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
|
@@ -3568,8 +3268,11 @@ class ZodEffects extends ZodType {
|
|
|
3568
3268
|
} else {
|
|
3569
3269
|
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base) => {
|
|
3570
3270
|
if (!isValid(base))
|
|
3571
|
-
return
|
|
3572
|
-
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
3271
|
+
return INVALID;
|
|
3272
|
+
return Promise.resolve(effect.transform(base.value, checkCtx)).then((result) => ({
|
|
3273
|
+
status: status.value,
|
|
3274
|
+
value: result
|
|
3275
|
+
}));
|
|
3573
3276
|
});
|
|
3574
3277
|
}
|
|
3575
3278
|
}
|
|
@@ -3729,7 +3432,6 @@ ZodNaN.create = (params) => {
|
|
|
3729
3432
|
...processCreateParams(params)
|
|
3730
3433
|
});
|
|
3731
3434
|
};
|
|
3732
|
-
const BRAND = Symbol("zod_brand");
|
|
3733
3435
|
class ZodBranded extends ZodType {
|
|
3734
3436
|
_parse(input) {
|
|
3735
3437
|
const { ctx } = this._processInputParams(input);
|
|
@@ -3821,38 +3523,6 @@ ZodReadonly.create = (type, params) => {
|
|
|
3821
3523
|
...processCreateParams(params)
|
|
3822
3524
|
});
|
|
3823
3525
|
};
|
|
3824
|
-
function cleanParams(params, data) {
|
|
3825
|
-
const p = typeof params === "function" ? params(data) : typeof params === "string" ? { message: params } : params;
|
|
3826
|
-
const p2 = typeof p === "string" ? { message: p } : p;
|
|
3827
|
-
return p2;
|
|
3828
|
-
}
|
|
3829
|
-
function custom(check, _params = {}, fatal) {
|
|
3830
|
-
if (check)
|
|
3831
|
-
return ZodAny.create().superRefine((data, ctx) => {
|
|
3832
|
-
var _a, _b;
|
|
3833
|
-
const r = check(data);
|
|
3834
|
-
if (r instanceof Promise) {
|
|
3835
|
-
return r.then((r2) => {
|
|
3836
|
-
var _a2, _b2;
|
|
3837
|
-
if (!r2) {
|
|
3838
|
-
const params = cleanParams(_params, data);
|
|
3839
|
-
const _fatal = (_b2 = (_a2 = params.fatal) !== null && _a2 !== void 0 ? _a2 : fatal) !== null && _b2 !== void 0 ? _b2 : true;
|
|
3840
|
-
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
3841
|
-
}
|
|
3842
|
-
});
|
|
3843
|
-
}
|
|
3844
|
-
if (!r) {
|
|
3845
|
-
const params = cleanParams(_params, data);
|
|
3846
|
-
const _fatal = (_b = (_a = params.fatal) !== null && _a !== void 0 ? _a : fatal) !== null && _b !== void 0 ? _b : true;
|
|
3847
|
-
ctx.addIssue({ code: "custom", ...params, fatal: _fatal });
|
|
3848
|
-
}
|
|
3849
|
-
return;
|
|
3850
|
-
});
|
|
3851
|
-
return ZodAny.create();
|
|
3852
|
-
}
|
|
3853
|
-
const late = {
|
|
3854
|
-
object: ZodObject.lazycreate
|
|
3855
|
-
};
|
|
3856
3526
|
var ZodFirstPartyTypeKind;
|
|
3857
3527
|
(function(ZodFirstPartyTypeKind2) {
|
|
3858
3528
|
ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
|
|
@@ -3892,176 +3562,21 @@ var ZodFirstPartyTypeKind;
|
|
|
3892
3562
|
ZodFirstPartyTypeKind2["ZodPipeline"] = "ZodPipeline";
|
|
3893
3563
|
ZodFirstPartyTypeKind2["ZodReadonly"] = "ZodReadonly";
|
|
3894
3564
|
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
|
3895
|
-
const instanceOfType = (cls, params = {
|
|
3896
|
-
message: `Input not instance of ${cls.name}`
|
|
3897
|
-
}) => custom((data) => data instanceof cls, params);
|
|
3898
3565
|
const stringType = ZodString.create;
|
|
3899
|
-
const numberType = ZodNumber.create;
|
|
3900
|
-
const nanType = ZodNaN.create;
|
|
3901
|
-
const bigIntType = ZodBigInt.create;
|
|
3902
|
-
const booleanType = ZodBoolean.create;
|
|
3903
|
-
const dateType = ZodDate.create;
|
|
3904
|
-
const symbolType = ZodSymbol.create;
|
|
3905
|
-
const undefinedType = ZodUndefined.create;
|
|
3906
|
-
const nullType = ZodNull.create;
|
|
3907
|
-
const anyType = ZodAny.create;
|
|
3908
3566
|
const unknownType = ZodUnknown.create;
|
|
3909
|
-
|
|
3910
|
-
const voidType = ZodVoid.create;
|
|
3567
|
+
ZodNever.create;
|
|
3911
3568
|
const arrayType = ZodArray.create;
|
|
3912
3569
|
const objectType = ZodObject.create;
|
|
3913
|
-
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
const intersectionType = ZodIntersection.create;
|
|
3917
|
-
const tupleType = ZodTuple.create;
|
|
3918
|
-
const recordType = ZodRecord.create;
|
|
3919
|
-
const mapType = ZodMap.create;
|
|
3920
|
-
const setType = ZodSet.create;
|
|
3921
|
-
const functionType = ZodFunction.create;
|
|
3922
|
-
const lazyType = ZodLazy.create;
|
|
3923
|
-
const literalType = ZodLiteral.create;
|
|
3570
|
+
ZodUnion.create;
|
|
3571
|
+
ZodIntersection.create;
|
|
3572
|
+
ZodTuple.create;
|
|
3924
3573
|
const enumType = ZodEnum.create;
|
|
3925
|
-
|
|
3926
|
-
const promiseType = ZodPromise.create;
|
|
3927
|
-
const effectsType = ZodEffects.create;
|
|
3574
|
+
ZodPromise.create;
|
|
3928
3575
|
const optionalType = ZodOptional.create;
|
|
3929
|
-
|
|
3930
|
-
const
|
|
3931
|
-
|
|
3932
|
-
|
|
3933
|
-
const onumber = () => numberType().optional();
|
|
3934
|
-
const oboolean = () => booleanType().optional();
|
|
3935
|
-
const coerce = {
|
|
3936
|
-
string: (arg) => ZodString.create({ ...arg, coerce: true }),
|
|
3937
|
-
number: (arg) => ZodNumber.create({ ...arg, coerce: true }),
|
|
3938
|
-
boolean: (arg) => ZodBoolean.create({
|
|
3939
|
-
...arg,
|
|
3940
|
-
coerce: true
|
|
3941
|
-
}),
|
|
3942
|
-
bigint: (arg) => ZodBigInt.create({ ...arg, coerce: true }),
|
|
3943
|
-
date: (arg) => ZodDate.create({ ...arg, coerce: true })
|
|
3944
|
-
};
|
|
3945
|
-
const NEVER = INVALID;
|
|
3946
|
-
var z = /* @__PURE__ */ Object.freeze({
|
|
3947
|
-
__proto__: null,
|
|
3948
|
-
defaultErrorMap: errorMap,
|
|
3949
|
-
setErrorMap,
|
|
3950
|
-
getErrorMap,
|
|
3951
|
-
makeIssue,
|
|
3952
|
-
EMPTY_PATH,
|
|
3953
|
-
addIssueToContext,
|
|
3954
|
-
ParseStatus,
|
|
3955
|
-
INVALID,
|
|
3956
|
-
DIRTY,
|
|
3957
|
-
OK,
|
|
3958
|
-
isAborted,
|
|
3959
|
-
isDirty,
|
|
3960
|
-
isValid,
|
|
3961
|
-
isAsync,
|
|
3962
|
-
get util() {
|
|
3963
|
-
return util;
|
|
3964
|
-
},
|
|
3965
|
-
get objectUtil() {
|
|
3966
|
-
return objectUtil;
|
|
3967
|
-
},
|
|
3968
|
-
ZodParsedType,
|
|
3969
|
-
getParsedType,
|
|
3970
|
-
ZodType,
|
|
3971
|
-
datetimeRegex,
|
|
3972
|
-
ZodString,
|
|
3973
|
-
ZodNumber,
|
|
3974
|
-
ZodBigInt,
|
|
3975
|
-
ZodBoolean,
|
|
3976
|
-
ZodDate,
|
|
3977
|
-
ZodSymbol,
|
|
3978
|
-
ZodUndefined,
|
|
3979
|
-
ZodNull,
|
|
3980
|
-
ZodAny,
|
|
3981
|
-
ZodUnknown,
|
|
3982
|
-
ZodNever,
|
|
3983
|
-
ZodVoid,
|
|
3984
|
-
ZodArray,
|
|
3985
|
-
ZodObject,
|
|
3986
|
-
ZodUnion,
|
|
3987
|
-
ZodDiscriminatedUnion,
|
|
3988
|
-
ZodIntersection,
|
|
3989
|
-
ZodTuple,
|
|
3990
|
-
ZodRecord,
|
|
3991
|
-
ZodMap,
|
|
3992
|
-
ZodSet,
|
|
3993
|
-
ZodFunction,
|
|
3994
|
-
ZodLazy,
|
|
3995
|
-
ZodLiteral,
|
|
3996
|
-
ZodEnum,
|
|
3997
|
-
ZodNativeEnum,
|
|
3998
|
-
ZodPromise,
|
|
3999
|
-
ZodEffects,
|
|
4000
|
-
ZodTransformer: ZodEffects,
|
|
4001
|
-
ZodOptional,
|
|
4002
|
-
ZodNullable,
|
|
4003
|
-
ZodDefault,
|
|
4004
|
-
ZodCatch,
|
|
4005
|
-
ZodNaN,
|
|
4006
|
-
BRAND,
|
|
4007
|
-
ZodBranded,
|
|
4008
|
-
ZodPipeline,
|
|
4009
|
-
ZodReadonly,
|
|
4010
|
-
custom,
|
|
4011
|
-
Schema: ZodType,
|
|
4012
|
-
ZodSchema: ZodType,
|
|
4013
|
-
late,
|
|
4014
|
-
get ZodFirstPartyTypeKind() {
|
|
4015
|
-
return ZodFirstPartyTypeKind;
|
|
4016
|
-
},
|
|
4017
|
-
coerce,
|
|
4018
|
-
any: anyType,
|
|
4019
|
-
array: arrayType,
|
|
4020
|
-
bigint: bigIntType,
|
|
4021
|
-
boolean: booleanType,
|
|
4022
|
-
date: dateType,
|
|
4023
|
-
discriminatedUnion: discriminatedUnionType,
|
|
4024
|
-
effect: effectsType,
|
|
4025
|
-
"enum": enumType,
|
|
4026
|
-
"function": functionType,
|
|
4027
|
-
"instanceof": instanceOfType,
|
|
4028
|
-
intersection: intersectionType,
|
|
4029
|
-
lazy: lazyType,
|
|
4030
|
-
literal: literalType,
|
|
4031
|
-
map: mapType,
|
|
4032
|
-
nan: nanType,
|
|
4033
|
-
nativeEnum: nativeEnumType,
|
|
4034
|
-
never: neverType,
|
|
4035
|
-
"null": nullType,
|
|
4036
|
-
nullable: nullableType,
|
|
4037
|
-
number: numberType,
|
|
4038
|
-
object: objectType,
|
|
4039
|
-
oboolean,
|
|
4040
|
-
onumber,
|
|
4041
|
-
optional: optionalType,
|
|
4042
|
-
ostring,
|
|
4043
|
-
pipeline: pipelineType,
|
|
4044
|
-
preprocess: preprocessType,
|
|
4045
|
-
promise: promiseType,
|
|
4046
|
-
record: recordType,
|
|
4047
|
-
set: setType,
|
|
4048
|
-
strictObject: strictObjectType,
|
|
4049
|
-
string: stringType,
|
|
4050
|
-
symbol: symbolType,
|
|
4051
|
-
transformer: effectsType,
|
|
4052
|
-
tuple: tupleType,
|
|
4053
|
-
"undefined": undefinedType,
|
|
4054
|
-
union: unionType,
|
|
4055
|
-
unknown: unknownType,
|
|
4056
|
-
"void": voidType,
|
|
4057
|
-
NEVER,
|
|
4058
|
-
ZodIssueCode,
|
|
4059
|
-
quotelessJson,
|
|
4060
|
-
ZodError
|
|
4061
|
-
});
|
|
4062
|
-
const EventObject = z.object({
|
|
4063
|
-
topic: z.string(),
|
|
4064
|
-
payload: z.unknown()
|
|
3576
|
+
ZodNullable.create;
|
|
3577
|
+
const EventObject = objectType({
|
|
3578
|
+
topic: stringType(),
|
|
3579
|
+
payload: unknownType()
|
|
4065
3580
|
});
|
|
4066
3581
|
class AppBridgeCapability {
|
|
4067
3582
|
constructor(appBridgeMessagePort) {
|
|
@@ -4082,12 +3597,12 @@ class AppBridgeInfrastructure {
|
|
|
4082
3597
|
return new capability(this.appBridgeMessagePort);
|
|
4083
3598
|
}
|
|
4084
3599
|
}
|
|
4085
|
-
const MessageType =
|
|
4086
|
-
const ChannelMessage =
|
|
4087
|
-
id:
|
|
3600
|
+
const MessageType = enumType(["HANDSHAKE", "REQUEST", "RESPONSE", "ERROR"]);
|
|
3601
|
+
const ChannelMessage = objectType({
|
|
3602
|
+
id: stringType().min(1, "Message ID must be at least 1 character long"),
|
|
4088
3603
|
type: MessageType,
|
|
4089
|
-
subject:
|
|
4090
|
-
body:
|
|
3604
|
+
subject: stringType().min(1, "Message subject must be at least 1 character long"),
|
|
3605
|
+
body: optionalType(unknownType())
|
|
4091
3606
|
});
|
|
4092
3607
|
const _AppBridgeMessagePort = class _AppBridgeMessagePort {
|
|
4093
3608
|
constructor(messagePort) {
|
|
@@ -4217,9 +3732,9 @@ class AppBridgeEventCapability extends AppBridgeCapability {
|
|
|
4217
3732
|
listeners == null ? void 0 : listeners.forEach((t) => t(event.payload));
|
|
4218
3733
|
}
|
|
4219
3734
|
}
|
|
4220
|
-
const MethodCallBody =
|
|
4221
|
-
methodName:
|
|
4222
|
-
args:
|
|
3735
|
+
const MethodCallBody = objectType({
|
|
3736
|
+
methodName: stringType(),
|
|
3737
|
+
args: arrayType(unknownType())
|
|
4223
3738
|
});
|
|
4224
3739
|
class AppBridgeMethodCapability extends AppBridgeCapability {
|
|
4225
3740
|
constructor(appBridgeMessagePort) {
|