@learncard/core 1.1.1 → 1.1.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/core.cjs.development.js +3123 -86
- package/dist/core.cjs.development.js.map +3 -3
- package/dist/core.cjs.production.min.js +178 -178
- package/dist/core.cjs.production.min.js.map +3 -3
- package/dist/core.d.ts +2076 -63
- package/dist/core.esm.js +3123 -86
- package/dist/core.esm.js.map +3 -3
- package/package.json +2 -2
@@ -39,8 +39,8 @@ var __objRest = (source, exclude) => {
|
|
39
39
|
var __esm = (fn, res) => function __init() {
|
40
40
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
41
41
|
};
|
42
|
-
var __commonJS = (cb,
|
43
|
-
return
|
42
|
+
var __commonJS = (cb, mod2) => function __require() {
|
43
|
+
return mod2 || (0, cb[__getOwnPropNames(cb)[0]])((mod2 = { exports: {} }).exports, mod2), mod2.exports;
|
44
44
|
};
|
45
45
|
var __export = (target, all) => {
|
46
46
|
for (var name5 in all)
|
@@ -54,8 +54,8 @@ var __copyProps = (to, from4, except, desc) => {
|
|
54
54
|
}
|
55
55
|
return to;
|
56
56
|
};
|
57
|
-
var __toESM = (
|
58
|
-
var __toCommonJS = (
|
57
|
+
var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target, mod2));
|
58
|
+
var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
|
59
59
|
var __superGet = (cls, obj, key2) => __reflectGet(__getProtoOf(cls), key2, obj);
|
60
60
|
var __async = (__this, __arguments, generator) => {
|
61
61
|
return new Promise((resolve, reject) => {
|
@@ -826,20 +826,20 @@ var require_tslib = __commonJS({
|
|
826
826
|
} : function(o, v) {
|
827
827
|
o["default"] = v;
|
828
828
|
};
|
829
|
-
__importStar2 = /* @__PURE__ */ __name(function(
|
830
|
-
if (
|
831
|
-
return
|
829
|
+
__importStar2 = /* @__PURE__ */ __name(function(mod2) {
|
830
|
+
if (mod2 && mod2.__esModule)
|
831
|
+
return mod2;
|
832
832
|
var result = {};
|
833
|
-
if (
|
834
|
-
for (var k in
|
835
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(
|
836
|
-
__createBinding2(result,
|
833
|
+
if (mod2 != null) {
|
834
|
+
for (var k in mod2)
|
835
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod2, k))
|
836
|
+
__createBinding2(result, mod2, k);
|
837
837
|
}
|
838
|
-
__setModuleDefault(result,
|
838
|
+
__setModuleDefault(result, mod2);
|
839
839
|
return result;
|
840
840
|
}, "__importStar");
|
841
|
-
__importDefault2 = /* @__PURE__ */ __name(function(
|
842
|
-
return
|
841
|
+
__importDefault2 = /* @__PURE__ */ __name(function(mod2) {
|
842
|
+
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
843
843
|
}, "__importDefault");
|
844
844
|
__classPrivateFieldGet4 = /* @__PURE__ */ __name(function(receiver, state, kind, f) {
|
845
845
|
if (kind === "a" && !f)
|
@@ -3784,8 +3784,8 @@ var require_bn = __commonJS({
|
|
3784
3784
|
limbLen--;
|
3785
3785
|
limbPow = limbPow / base4 | 0;
|
3786
3786
|
var total = number.length - start;
|
3787
|
-
var
|
3788
|
-
var end = Math.min(total, total -
|
3787
|
+
var mod2 = total % limbLen;
|
3788
|
+
var end = Math.min(total, total - mod2) + start;
|
3789
3789
|
var word = 0;
|
3790
3790
|
for (var i = start; i < end; i += limbLen) {
|
3791
3791
|
word = parseBase(number, i, i + limbLen, base4);
|
@@ -3796,10 +3796,10 @@ var require_bn = __commonJS({
|
|
3796
3796
|
this._iaddn(word);
|
3797
3797
|
}
|
3798
3798
|
}
|
3799
|
-
if (
|
3799
|
+
if (mod2 !== 0) {
|
3800
3800
|
var pow = 1;
|
3801
3801
|
word = parseBase(number, i, number.length, base4);
|
3802
|
-
for (i = 0; i <
|
3802
|
+
for (i = 0; i < mod2; i++) {
|
3803
3803
|
pow *= base4;
|
3804
3804
|
}
|
3805
3805
|
this.imuln(pow);
|
@@ -5534,21 +5534,21 @@ var require_bn = __commonJS({
|
|
5534
5534
|
mod: new BN3(0)
|
5535
5535
|
};
|
5536
5536
|
}
|
5537
|
-
var div,
|
5537
|
+
var div, mod2, res;
|
5538
5538
|
if (this.negative !== 0 && num.negative === 0) {
|
5539
5539
|
res = this.neg().divmod(num, mode2);
|
5540
5540
|
if (mode2 !== "mod") {
|
5541
5541
|
div = res.div.neg();
|
5542
5542
|
}
|
5543
5543
|
if (mode2 !== "div") {
|
5544
|
-
|
5545
|
-
if (positive &&
|
5546
|
-
|
5544
|
+
mod2 = res.mod.neg();
|
5545
|
+
if (positive && mod2.negative !== 0) {
|
5546
|
+
mod2.iadd(num);
|
5547
5547
|
}
|
5548
5548
|
}
|
5549
5549
|
return {
|
5550
5550
|
div,
|
5551
|
-
mod
|
5551
|
+
mod: mod2
|
5552
5552
|
};
|
5553
5553
|
}
|
5554
5554
|
if (this.negative === 0 && num.negative !== 0) {
|
@@ -5564,14 +5564,14 @@ var require_bn = __commonJS({
|
|
5564
5564
|
if ((this.negative & num.negative) !== 0) {
|
5565
5565
|
res = this.neg().divmod(num.neg(), mode2);
|
5566
5566
|
if (mode2 !== "div") {
|
5567
|
-
|
5568
|
-
if (positive &&
|
5569
|
-
|
5567
|
+
mod2 = res.mod.neg();
|
5568
|
+
if (positive && mod2.negative !== 0) {
|
5569
|
+
mod2.isub(num);
|
5570
5570
|
}
|
5571
5571
|
}
|
5572
5572
|
return {
|
5573
5573
|
div: res.div,
|
5574
|
-
mod
|
5574
|
+
mod: mod2
|
5575
5575
|
};
|
5576
5576
|
}
|
5577
5577
|
if (num.length > this.length || this.cmp(num) < 0) {
|
@@ -5603,7 +5603,7 @@ var require_bn = __commonJS({
|
|
5603
5603
|
BN3.prototype.div = /* @__PURE__ */ __name(function div(num) {
|
5604
5604
|
return this.divmod(num, "div", false).div;
|
5605
5605
|
}, "div");
|
5606
|
-
BN3.prototype.mod = /* @__PURE__ */ __name(function
|
5606
|
+
BN3.prototype.mod = /* @__PURE__ */ __name(function mod2(num) {
|
5607
5607
|
return this.divmod(num, "mod", false).mod;
|
5608
5608
|
}, "mod");
|
5609
5609
|
BN3.prototype.umod = /* @__PURE__ */ __name(function umod(num) {
|
@@ -5613,10 +5613,10 @@ var require_bn = __commonJS({
|
|
5613
5613
|
var dm = this.divmod(num);
|
5614
5614
|
if (dm.mod.isZero())
|
5615
5615
|
return dm.div;
|
5616
|
-
var
|
5616
|
+
var mod2 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
|
5617
5617
|
var half = num.ushrn(1);
|
5618
5618
|
var r2 = num.andln(1);
|
5619
|
-
var cmp =
|
5619
|
+
var cmp = mod2.cmp(half);
|
5620
5620
|
if (cmp < 0 || r2 === 1 && cmp === 0)
|
5621
5621
|
return dm.div;
|
5622
5622
|
return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
|
@@ -6490,12 +6490,12 @@ var require_utils2 = __commonJS({
|
|
6490
6490
|
var k = num.clone();
|
6491
6491
|
for (var i = 0; i < naf.length; i++) {
|
6492
6492
|
var z;
|
6493
|
-
var
|
6493
|
+
var mod2 = k.andln(ws - 1);
|
6494
6494
|
if (k.isOdd()) {
|
6495
|
-
if (
|
6496
|
-
z = (ws >> 1) -
|
6495
|
+
if (mod2 > (ws >> 1) - 1)
|
6496
|
+
z = (ws >> 1) - mod2;
|
6497
6497
|
else
|
6498
|
-
z =
|
6498
|
+
z = mod2;
|
6499
6499
|
k.isubn(z);
|
6500
6500
|
} else {
|
6501
6501
|
z = 0;
|
@@ -23664,7 +23664,7 @@ var require_api = __commonJS({
|
|
23664
23664
|
const abnfToHtml = /* @__PURE__ */ __name(function abnfToHtml2(chars, beg, len) {
|
23665
23665
|
const NORMAL = 0;
|
23666
23666
|
const CONTROL = 1;
|
23667
|
-
const
|
23667
|
+
const INVALID2 = 2;
|
23668
23668
|
const CONTROL_BEG = `<span class="${apglib.style.CLASS_CTRLCHAR}">`;
|
23669
23669
|
const CONTROL_END = "</span>";
|
23670
23670
|
const INVALID_BEG = `<span class="${apglib.style.CLASS_NOMATCH}">`;
|
@@ -23694,7 +23694,7 @@ var require_api = __commonJS({
|
|
23694
23694
|
if (state === CONTROL) {
|
23695
23695
|
html += CONTROL_END;
|
23696
23696
|
state = NORMAL;
|
23697
|
-
} else if (state ===
|
23697
|
+
} else if (state === INVALID2) {
|
23698
23698
|
html += INVALID_END;
|
23699
23699
|
state = NORMAL;
|
23700
23700
|
}
|
@@ -23728,7 +23728,7 @@ var require_api = __commonJS({
|
|
23728
23728
|
if (state === NORMAL) {
|
23729
23729
|
html += CONTROL_BEG;
|
23730
23730
|
state = CONTROL;
|
23731
|
-
} else if (state ===
|
23731
|
+
} else if (state === INVALID2) {
|
23732
23732
|
html += INVALID_END + CONTROL_BEG;
|
23733
23733
|
state = CONTROL;
|
23734
23734
|
}
|
@@ -23744,15 +23744,15 @@ var require_api = __commonJS({
|
|
23744
23744
|
} else {
|
23745
23745
|
if (state === NORMAL) {
|
23746
23746
|
html += INVALID_BEG;
|
23747
|
-
state =
|
23747
|
+
state = INVALID2;
|
23748
23748
|
} else if (state === CONTROL) {
|
23749
23749
|
html += CONTROL_END + INVALID_BEG;
|
23750
|
-
state =
|
23750
|
+
state = INVALID2;
|
23751
23751
|
}
|
23752
23752
|
html += `\\x${apglib.utils.charToHex(ch)}`;
|
23753
23753
|
}
|
23754
23754
|
}
|
23755
|
-
if (state ===
|
23755
|
+
if (state === INVALID2) {
|
23756
23756
|
html += INVALID_END;
|
23757
23757
|
}
|
23758
23758
|
if (state === CONTROL) {
|
@@ -24728,16 +24728,16 @@ var require_secp256k12 = __commonJS({
|
|
24728
24728
|
} : function(o, v) {
|
24729
24729
|
o["default"] = v;
|
24730
24730
|
});
|
24731
|
-
var __importStar2 = exports && exports.__importStar || function(
|
24732
|
-
if (
|
24733
|
-
return
|
24731
|
+
var __importStar2 = exports && exports.__importStar || function(mod2) {
|
24732
|
+
if (mod2 && mod2.__esModule)
|
24733
|
+
return mod2;
|
24734
24734
|
var result = {};
|
24735
|
-
if (
|
24736
|
-
for (var k in
|
24737
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(
|
24738
|
-
__createBinding2(result,
|
24735
|
+
if (mod2 != null) {
|
24736
|
+
for (var k in mod2)
|
24737
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod2, k))
|
24738
|
+
__createBinding2(result, mod2, k);
|
24739
24739
|
}
|
24740
|
-
__setModuleDefault(result,
|
24740
|
+
__setModuleDefault(result, mod2);
|
24741
24741
|
return result;
|
24742
24742
|
};
|
24743
24743
|
Object.defineProperty(exports, "__esModule", { value: true });
|
@@ -24785,16 +24785,16 @@ var require_ed255192 = __commonJS({
|
|
24785
24785
|
} : function(o, v) {
|
24786
24786
|
o["default"] = v;
|
24787
24787
|
});
|
24788
|
-
var __importStar2 = exports && exports.__importStar || function(
|
24789
|
-
if (
|
24790
|
-
return
|
24788
|
+
var __importStar2 = exports && exports.__importStar || function(mod2) {
|
24789
|
+
if (mod2 && mod2.__esModule)
|
24790
|
+
return mod2;
|
24791
24791
|
var result = {};
|
24792
|
-
if (
|
24793
|
-
for (var k in
|
24794
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(
|
24795
|
-
__createBinding2(result,
|
24792
|
+
if (mod2 != null) {
|
24793
|
+
for (var k in mod2)
|
24794
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod2, k))
|
24795
|
+
__createBinding2(result, mod2, k);
|
24796
24796
|
}
|
24797
|
-
__setModuleDefault(result,
|
24797
|
+
__setModuleDefault(result, mod2);
|
24798
24798
|
return result;
|
24799
24799
|
};
|
24800
24800
|
Object.defineProperty(exports, "__esModule", { value: true });
|
@@ -24859,20 +24859,20 @@ var require_lib = __commonJS({
|
|
24859
24859
|
} : function(o, v) {
|
24860
24860
|
o["default"] = v;
|
24861
24861
|
});
|
24862
|
-
var __importStar2 = exports && exports.__importStar || function(
|
24863
|
-
if (
|
24864
|
-
return
|
24862
|
+
var __importStar2 = exports && exports.__importStar || function(mod2) {
|
24863
|
+
if (mod2 && mod2.__esModule)
|
24864
|
+
return mod2;
|
24865
24865
|
var result = {};
|
24866
|
-
if (
|
24867
|
-
for (var k in
|
24868
|
-
if (k !== "default" && Object.prototype.hasOwnProperty.call(
|
24869
|
-
__createBinding2(result,
|
24866
|
+
if (mod2 != null) {
|
24867
|
+
for (var k in mod2)
|
24868
|
+
if (k !== "default" && Object.prototype.hasOwnProperty.call(mod2, k))
|
24869
|
+
__createBinding2(result, mod2, k);
|
24870
24870
|
}
|
24871
|
-
__setModuleDefault(result,
|
24871
|
+
__setModuleDefault(result, mod2);
|
24872
24872
|
return result;
|
24873
24873
|
};
|
24874
|
-
var __importDefault2 = exports && exports.__importDefault || function(
|
24875
|
-
return
|
24874
|
+
var __importDefault2 = exports && exports.__importDefault || function(mod2) {
|
24875
|
+
return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
|
24876
24876
|
};
|
24877
24877
|
Object.defineProperty(exports, "__esModule", { value: true });
|
24878
24878
|
var varint_1 = __importDefault2(require_varint());
|
@@ -37464,9 +37464,9 @@ function is(value) {
|
|
37464
37464
|
if (isBuffer(value)) {
|
37465
37465
|
return "Buffer";
|
37466
37466
|
}
|
37467
|
-
const
|
37468
|
-
if (
|
37469
|
-
return
|
37467
|
+
const objectType2 = getObjectType(value);
|
37468
|
+
if (objectType2) {
|
37469
|
+
return objectType2;
|
37470
37470
|
}
|
37471
37471
|
return "Object";
|
37472
37472
|
}
|
@@ -40643,12 +40643,12 @@ var utils_1$1 = createCommonjsModule(function(module2, exports) {
|
|
40643
40643
|
var k = num.clone();
|
40644
40644
|
for (var i = 0; i < naf.length; i++) {
|
40645
40645
|
var z;
|
40646
|
-
var
|
40646
|
+
var mod2 = k.andln(ws - 1);
|
40647
40647
|
if (k.isOdd()) {
|
40648
|
-
if (
|
40649
|
-
z = (ws >> 1) -
|
40648
|
+
if (mod2 > (ws >> 1) - 1)
|
40649
|
+
z = (ws >> 1) - mod2;
|
40650
40650
|
else
|
40651
|
-
z =
|
40651
|
+
z = mod2;
|
40652
40652
|
k.isubn(z);
|
40653
40653
|
} else {
|
40654
40654
|
z = 0;
|
@@ -48520,7 +48520,7 @@ var getVCPlugin = /* @__PURE__ */ __name((wallet) => __async(void 0, null, funct
|
|
48520
48520
|
getTestVc: (_wallet, subject = "did:example:d23dd687a7dc6787646f2eb98d0") => {
|
48521
48521
|
const did = _wallet.pluginMethods.getSubjectDid();
|
48522
48522
|
return {
|
48523
|
-
"@context": "https://www.w3.org/2018/credentials/v1",
|
48523
|
+
"@context": ["https://www.w3.org/2018/credentials/v1"],
|
48524
48524
|
id: "http://example.org/credentials/3731",
|
48525
48525
|
type: ["VerifiableCredential"],
|
48526
48526
|
issuer: did,
|
@@ -48532,13 +48532,3050 @@ var getVCPlugin = /* @__PURE__ */ __name((wallet) => __async(void 0, null, funct
|
|
48532
48532
|
};
|
48533
48533
|
}), "getVCPlugin");
|
48534
48534
|
|
48535
|
+
// ../../node_modules/.pnpm/zod@3.17.3/node_modules/zod/lib/index.mjs
|
48536
|
+
var util;
|
48537
|
+
(function(util2) {
|
48538
|
+
function assertNever(_x) {
|
48539
|
+
throw new Error();
|
48540
|
+
}
|
48541
|
+
__name(assertNever, "assertNever");
|
48542
|
+
util2.assertNever = assertNever;
|
48543
|
+
util2.arrayToEnum = (items) => {
|
48544
|
+
const obj = {};
|
48545
|
+
for (const item of items) {
|
48546
|
+
obj[item] = item;
|
48547
|
+
}
|
48548
|
+
return obj;
|
48549
|
+
};
|
48550
|
+
util2.getValidEnumValues = (obj) => {
|
48551
|
+
const validKeys = util2.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
|
48552
|
+
const filtered = {};
|
48553
|
+
for (const k of validKeys) {
|
48554
|
+
filtered[k] = obj[k];
|
48555
|
+
}
|
48556
|
+
return util2.objectValues(filtered);
|
48557
|
+
};
|
48558
|
+
util2.objectValues = (obj) => {
|
48559
|
+
return util2.objectKeys(obj).map(function(e) {
|
48560
|
+
return obj[e];
|
48561
|
+
});
|
48562
|
+
};
|
48563
|
+
util2.objectKeys = typeof Object.keys === "function" ? (obj) => Object.keys(obj) : (object) => {
|
48564
|
+
const keys = [];
|
48565
|
+
for (const key2 in object) {
|
48566
|
+
if (Object.prototype.hasOwnProperty.call(object, key2)) {
|
48567
|
+
keys.push(key2);
|
48568
|
+
}
|
48569
|
+
}
|
48570
|
+
return keys;
|
48571
|
+
};
|
48572
|
+
util2.find = (arr, checker) => {
|
48573
|
+
for (const item of arr) {
|
48574
|
+
if (checker(item))
|
48575
|
+
return item;
|
48576
|
+
}
|
48577
|
+
return void 0;
|
48578
|
+
};
|
48579
|
+
util2.isInteger = typeof Number.isInteger === "function" ? (val) => Number.isInteger(val) : (val) => typeof val === "number" && isFinite(val) && Math.floor(val) === val;
|
48580
|
+
function joinValues(array, separator = " | ") {
|
48581
|
+
return array.map((val) => typeof val === "string" ? `'${val}'` : val).join(separator);
|
48582
|
+
}
|
48583
|
+
__name(joinValues, "joinValues");
|
48584
|
+
util2.joinValues = joinValues;
|
48585
|
+
})(util || (util = {}));
|
48586
|
+
var ZodParsedType = util.arrayToEnum([
|
48587
|
+
"string",
|
48588
|
+
"nan",
|
48589
|
+
"number",
|
48590
|
+
"integer",
|
48591
|
+
"float",
|
48592
|
+
"boolean",
|
48593
|
+
"date",
|
48594
|
+
"bigint",
|
48595
|
+
"symbol",
|
48596
|
+
"function",
|
48597
|
+
"undefined",
|
48598
|
+
"null",
|
48599
|
+
"array",
|
48600
|
+
"object",
|
48601
|
+
"unknown",
|
48602
|
+
"promise",
|
48603
|
+
"void",
|
48604
|
+
"never",
|
48605
|
+
"map",
|
48606
|
+
"set"
|
48607
|
+
]);
|
48608
|
+
var getParsedType = /* @__PURE__ */ __name((data) => {
|
48609
|
+
const t = typeof data;
|
48610
|
+
switch (t) {
|
48611
|
+
case "undefined":
|
48612
|
+
return ZodParsedType.undefined;
|
48613
|
+
case "string":
|
48614
|
+
return ZodParsedType.string;
|
48615
|
+
case "number":
|
48616
|
+
return isNaN(data) ? ZodParsedType.nan : ZodParsedType.number;
|
48617
|
+
case "boolean":
|
48618
|
+
return ZodParsedType.boolean;
|
48619
|
+
case "function":
|
48620
|
+
return ZodParsedType.function;
|
48621
|
+
case "bigint":
|
48622
|
+
return ZodParsedType.bigint;
|
48623
|
+
case "object":
|
48624
|
+
if (Array.isArray(data)) {
|
48625
|
+
return ZodParsedType.array;
|
48626
|
+
}
|
48627
|
+
if (data === null) {
|
48628
|
+
return ZodParsedType.null;
|
48629
|
+
}
|
48630
|
+
if (data.then && typeof data.then === "function" && data.catch && typeof data.catch === "function") {
|
48631
|
+
return ZodParsedType.promise;
|
48632
|
+
}
|
48633
|
+
if (typeof Map !== "undefined" && data instanceof Map) {
|
48634
|
+
return ZodParsedType.map;
|
48635
|
+
}
|
48636
|
+
if (typeof Set !== "undefined" && data instanceof Set) {
|
48637
|
+
return ZodParsedType.set;
|
48638
|
+
}
|
48639
|
+
if (typeof Date !== "undefined" && data instanceof Date) {
|
48640
|
+
return ZodParsedType.date;
|
48641
|
+
}
|
48642
|
+
return ZodParsedType.object;
|
48643
|
+
default:
|
48644
|
+
return ZodParsedType.unknown;
|
48645
|
+
}
|
48646
|
+
}, "getParsedType");
|
48647
|
+
var ZodIssueCode = util.arrayToEnum([
|
48648
|
+
"invalid_type",
|
48649
|
+
"invalid_literal",
|
48650
|
+
"custom",
|
48651
|
+
"invalid_union",
|
48652
|
+
"invalid_union_discriminator",
|
48653
|
+
"invalid_enum_value",
|
48654
|
+
"unrecognized_keys",
|
48655
|
+
"invalid_arguments",
|
48656
|
+
"invalid_return_type",
|
48657
|
+
"invalid_date",
|
48658
|
+
"invalid_string",
|
48659
|
+
"too_small",
|
48660
|
+
"too_big",
|
48661
|
+
"invalid_intersection_types",
|
48662
|
+
"not_multiple_of"
|
48663
|
+
]);
|
48664
|
+
var quotelessJson = /* @__PURE__ */ __name((obj) => {
|
48665
|
+
const json = JSON.stringify(obj, null, 2);
|
48666
|
+
return json.replace(/"([^"]+)":/g, "$1:");
|
48667
|
+
}, "quotelessJson");
|
48668
|
+
var ZodError = class extends Error {
|
48669
|
+
constructor(issues) {
|
48670
|
+
super();
|
48671
|
+
this.issues = [];
|
48672
|
+
this.addIssue = (sub) => {
|
48673
|
+
this.issues = [...this.issues, sub];
|
48674
|
+
};
|
48675
|
+
this.addIssues = (subs = []) => {
|
48676
|
+
this.issues = [...this.issues, ...subs];
|
48677
|
+
};
|
48678
|
+
const actualProto = new.target.prototype;
|
48679
|
+
if (Object.setPrototypeOf) {
|
48680
|
+
Object.setPrototypeOf(this, actualProto);
|
48681
|
+
} else {
|
48682
|
+
this.__proto__ = actualProto;
|
48683
|
+
}
|
48684
|
+
this.name = "ZodError";
|
48685
|
+
this.issues = issues;
|
48686
|
+
}
|
48687
|
+
get errors() {
|
48688
|
+
return this.issues;
|
48689
|
+
}
|
48690
|
+
format(_mapper) {
|
48691
|
+
const mapper = _mapper || function(issue) {
|
48692
|
+
return issue.message;
|
48693
|
+
};
|
48694
|
+
const fieldErrors = { _errors: [] };
|
48695
|
+
const processError = /* @__PURE__ */ __name((error) => {
|
48696
|
+
for (const issue of error.issues) {
|
48697
|
+
if (issue.code === "invalid_union") {
|
48698
|
+
issue.unionErrors.map(processError);
|
48699
|
+
} else if (issue.code === "invalid_return_type") {
|
48700
|
+
processError(issue.returnTypeError);
|
48701
|
+
} else if (issue.code === "invalid_arguments") {
|
48702
|
+
processError(issue.argumentsError);
|
48703
|
+
} else if (issue.path.length === 0) {
|
48704
|
+
fieldErrors._errors.push(mapper(issue));
|
48705
|
+
} else {
|
48706
|
+
let curr = fieldErrors;
|
48707
|
+
let i = 0;
|
48708
|
+
while (i < issue.path.length) {
|
48709
|
+
const el = issue.path[i];
|
48710
|
+
const terminal = i === issue.path.length - 1;
|
48711
|
+
if (!terminal) {
|
48712
|
+
curr[el] = curr[el] || { _errors: [] };
|
48713
|
+
} else {
|
48714
|
+
curr[el] = curr[el] || { _errors: [] };
|
48715
|
+
curr[el]._errors.push(mapper(issue));
|
48716
|
+
}
|
48717
|
+
curr = curr[el];
|
48718
|
+
i++;
|
48719
|
+
}
|
48720
|
+
}
|
48721
|
+
}
|
48722
|
+
}, "processError");
|
48723
|
+
processError(this);
|
48724
|
+
return fieldErrors;
|
48725
|
+
}
|
48726
|
+
toString() {
|
48727
|
+
return this.message;
|
48728
|
+
}
|
48729
|
+
get message() {
|
48730
|
+
return JSON.stringify(this.issues, null, 2);
|
48731
|
+
}
|
48732
|
+
get isEmpty() {
|
48733
|
+
return this.issues.length === 0;
|
48734
|
+
}
|
48735
|
+
flatten(mapper = (issue) => issue.message) {
|
48736
|
+
const fieldErrors = {};
|
48737
|
+
const formErrors = [];
|
48738
|
+
for (const sub of this.issues) {
|
48739
|
+
if (sub.path.length > 0) {
|
48740
|
+
fieldErrors[sub.path[0]] = fieldErrors[sub.path[0]] || [];
|
48741
|
+
fieldErrors[sub.path[0]].push(mapper(sub));
|
48742
|
+
} else {
|
48743
|
+
formErrors.push(mapper(sub));
|
48744
|
+
}
|
48745
|
+
}
|
48746
|
+
return { formErrors, fieldErrors };
|
48747
|
+
}
|
48748
|
+
get formErrors() {
|
48749
|
+
return this.flatten();
|
48750
|
+
}
|
48751
|
+
};
|
48752
|
+
__name(ZodError, "ZodError");
|
48753
|
+
ZodError.create = (issues) => {
|
48754
|
+
const error = new ZodError(issues);
|
48755
|
+
return error;
|
48756
|
+
};
|
48757
|
+
var defaultErrorMap = /* @__PURE__ */ __name((issue, _ctx) => {
|
48758
|
+
let message;
|
48759
|
+
switch (issue.code) {
|
48760
|
+
case ZodIssueCode.invalid_type:
|
48761
|
+
if (issue.received === ZodParsedType.undefined) {
|
48762
|
+
message = "Required";
|
48763
|
+
} else {
|
48764
|
+
message = `Expected ${issue.expected}, received ${issue.received}`;
|
48765
|
+
}
|
48766
|
+
break;
|
48767
|
+
case ZodIssueCode.invalid_literal:
|
48768
|
+
message = `Invalid literal value, expected ${JSON.stringify(issue.expected)}`;
|
48769
|
+
break;
|
48770
|
+
case ZodIssueCode.unrecognized_keys:
|
48771
|
+
message = `Unrecognized key(s) in object: ${util.joinValues(issue.keys, ", ")}`;
|
48772
|
+
break;
|
48773
|
+
case ZodIssueCode.invalid_union:
|
48774
|
+
message = `Invalid input`;
|
48775
|
+
break;
|
48776
|
+
case ZodIssueCode.invalid_union_discriminator:
|
48777
|
+
message = `Invalid discriminator value. Expected ${util.joinValues(issue.options)}`;
|
48778
|
+
break;
|
48779
|
+
case ZodIssueCode.invalid_enum_value:
|
48780
|
+
message = `Invalid enum value. Expected ${util.joinValues(issue.options)}, received '${issue.received}'`;
|
48781
|
+
break;
|
48782
|
+
case ZodIssueCode.invalid_arguments:
|
48783
|
+
message = `Invalid function arguments`;
|
48784
|
+
break;
|
48785
|
+
case ZodIssueCode.invalid_return_type:
|
48786
|
+
message = `Invalid function return type`;
|
48787
|
+
break;
|
48788
|
+
case ZodIssueCode.invalid_date:
|
48789
|
+
message = `Invalid date`;
|
48790
|
+
break;
|
48791
|
+
case ZodIssueCode.invalid_string:
|
48792
|
+
if (issue.validation !== "regex")
|
48793
|
+
message = `Invalid ${issue.validation}`;
|
48794
|
+
else
|
48795
|
+
message = "Invalid";
|
48796
|
+
break;
|
48797
|
+
case ZodIssueCode.too_small:
|
48798
|
+
if (issue.type === "array")
|
48799
|
+
message = `Array must contain ${issue.inclusive ? `at least` : `more than`} ${issue.minimum} element(s)`;
|
48800
|
+
else if (issue.type === "string")
|
48801
|
+
message = `String must contain ${issue.inclusive ? `at least` : `over`} ${issue.minimum} character(s)`;
|
48802
|
+
else if (issue.type === "number")
|
48803
|
+
message = `Number must be greater than ${issue.inclusive ? `or equal to ` : ``}${issue.minimum}`;
|
48804
|
+
else
|
48805
|
+
message = "Invalid input";
|
48806
|
+
break;
|
48807
|
+
case ZodIssueCode.too_big:
|
48808
|
+
if (issue.type === "array")
|
48809
|
+
message = `Array must contain ${issue.inclusive ? `at most` : `less than`} ${issue.maximum} element(s)`;
|
48810
|
+
else if (issue.type === "string")
|
48811
|
+
message = `String must contain ${issue.inclusive ? `at most` : `under`} ${issue.maximum} character(s)`;
|
48812
|
+
else if (issue.type === "number")
|
48813
|
+
message = `Number must be less than ${issue.inclusive ? `or equal to ` : ``}${issue.maximum}`;
|
48814
|
+
else
|
48815
|
+
message = "Invalid input";
|
48816
|
+
break;
|
48817
|
+
case ZodIssueCode.custom:
|
48818
|
+
message = `Invalid input`;
|
48819
|
+
break;
|
48820
|
+
case ZodIssueCode.invalid_intersection_types:
|
48821
|
+
message = `Intersection results could not be merged`;
|
48822
|
+
break;
|
48823
|
+
case ZodIssueCode.not_multiple_of:
|
48824
|
+
message = `Number must be a multiple of ${issue.multipleOf}`;
|
48825
|
+
break;
|
48826
|
+
default:
|
48827
|
+
message = _ctx.defaultError;
|
48828
|
+
util.assertNever(issue);
|
48829
|
+
}
|
48830
|
+
return { message };
|
48831
|
+
}, "defaultErrorMap");
|
48832
|
+
var overrideErrorMap = defaultErrorMap;
|
48833
|
+
var setErrorMap = /* @__PURE__ */ __name((map2) => {
|
48834
|
+
overrideErrorMap = map2;
|
48835
|
+
}, "setErrorMap");
|
48836
|
+
var makeIssue = /* @__PURE__ */ __name((params) => {
|
48837
|
+
const { data, path, errorMaps, issueData } = params;
|
48838
|
+
const fullPath = [...path, ...issueData.path || []];
|
48839
|
+
const fullIssue = __spreadProps(__spreadValues({}, issueData), {
|
48840
|
+
path: fullPath
|
48841
|
+
});
|
48842
|
+
let errorMessage = "";
|
48843
|
+
const maps = errorMaps.filter((m) => !!m).slice().reverse();
|
48844
|
+
for (const map2 of maps) {
|
48845
|
+
errorMessage = map2(fullIssue, { data, defaultError: errorMessage }).message;
|
48846
|
+
}
|
48847
|
+
return __spreadProps(__spreadValues({}, issueData), {
|
48848
|
+
path: fullPath,
|
48849
|
+
message: issueData.message || errorMessage
|
48850
|
+
});
|
48851
|
+
}, "makeIssue");
|
48852
|
+
var EMPTY_PATH = [];
|
48853
|
+
function addIssueToContext(ctx, issueData) {
|
48854
|
+
const issue = makeIssue({
|
48855
|
+
issueData,
|
48856
|
+
data: ctx.data,
|
48857
|
+
path: ctx.path,
|
48858
|
+
errorMaps: [
|
48859
|
+
ctx.common.contextualErrorMap,
|
48860
|
+
ctx.schemaErrorMap,
|
48861
|
+
overrideErrorMap,
|
48862
|
+
defaultErrorMap
|
48863
|
+
].filter((x) => !!x)
|
48864
|
+
});
|
48865
|
+
ctx.common.issues.push(issue);
|
48866
|
+
}
|
48867
|
+
__name(addIssueToContext, "addIssueToContext");
|
48868
|
+
var ParseStatus = class {
|
48869
|
+
constructor() {
|
48870
|
+
this.value = "valid";
|
48871
|
+
}
|
48872
|
+
dirty() {
|
48873
|
+
if (this.value === "valid")
|
48874
|
+
this.value = "dirty";
|
48875
|
+
}
|
48876
|
+
abort() {
|
48877
|
+
if (this.value !== "aborted")
|
48878
|
+
this.value = "aborted";
|
48879
|
+
}
|
48880
|
+
static mergeArray(status, results) {
|
48881
|
+
const arrayValue = [];
|
48882
|
+
for (const s of results) {
|
48883
|
+
if (s.status === "aborted")
|
48884
|
+
return INVALID;
|
48885
|
+
if (s.status === "dirty")
|
48886
|
+
status.dirty();
|
48887
|
+
arrayValue.push(s.value);
|
48888
|
+
}
|
48889
|
+
return { status: status.value, value: arrayValue };
|
48890
|
+
}
|
48891
|
+
static mergeObjectAsync(status, pairs) {
|
48892
|
+
return __async(this, null, function* () {
|
48893
|
+
const syncPairs = [];
|
48894
|
+
for (const pair of pairs) {
|
48895
|
+
syncPairs.push({
|
48896
|
+
key: yield pair.key,
|
48897
|
+
value: yield pair.value
|
48898
|
+
});
|
48899
|
+
}
|
48900
|
+
return ParseStatus.mergeObjectSync(status, syncPairs);
|
48901
|
+
});
|
48902
|
+
}
|
48903
|
+
static mergeObjectSync(status, pairs) {
|
48904
|
+
const finalObject = {};
|
48905
|
+
for (const pair of pairs) {
|
48906
|
+
const { key: key2, value } = pair;
|
48907
|
+
if (key2.status === "aborted")
|
48908
|
+
return INVALID;
|
48909
|
+
if (value.status === "aborted")
|
48910
|
+
return INVALID;
|
48911
|
+
if (key2.status === "dirty")
|
48912
|
+
status.dirty();
|
48913
|
+
if (value.status === "dirty")
|
48914
|
+
status.dirty();
|
48915
|
+
if (typeof value.value !== "undefined" || pair.alwaysSet) {
|
48916
|
+
finalObject[key2.value] = value.value;
|
48917
|
+
}
|
48918
|
+
}
|
48919
|
+
return { status: status.value, value: finalObject };
|
48920
|
+
}
|
48921
|
+
};
|
48922
|
+
__name(ParseStatus, "ParseStatus");
|
48923
|
+
var INVALID = Object.freeze({
|
48924
|
+
status: "aborted"
|
48925
|
+
});
|
48926
|
+
var DIRTY = /* @__PURE__ */ __name((value) => ({ status: "dirty", value }), "DIRTY");
|
48927
|
+
var OK = /* @__PURE__ */ __name((value) => ({ status: "valid", value }), "OK");
|
48928
|
+
var isAborted = /* @__PURE__ */ __name((x) => x.status === "aborted", "isAborted");
|
48929
|
+
var isDirty = /* @__PURE__ */ __name((x) => x.status === "dirty", "isDirty");
|
48930
|
+
var isValid = /* @__PURE__ */ __name((x) => x.status === "valid", "isValid");
|
48931
|
+
var isAsync = /* @__PURE__ */ __name((x) => typeof Promise !== void 0 && x instanceof Promise, "isAsync");
|
48932
|
+
var errorUtil;
|
48933
|
+
(function(errorUtil2) {
|
48934
|
+
errorUtil2.errToObj = (message) => typeof message === "string" ? { message } : message || {};
|
48935
|
+
errorUtil2.toString = (message) => typeof message === "string" ? message : message === null || message === void 0 ? void 0 : message.message;
|
48936
|
+
})(errorUtil || (errorUtil = {}));
|
48937
|
+
var ParseInputLazyPath = class {
|
48938
|
+
constructor(parent, value, path, key2) {
|
48939
|
+
this.parent = parent;
|
48940
|
+
this.data = value;
|
48941
|
+
this._path = path;
|
48942
|
+
this._key = key2;
|
48943
|
+
}
|
48944
|
+
get path() {
|
48945
|
+
return this._path.concat(this._key);
|
48946
|
+
}
|
48947
|
+
};
|
48948
|
+
__name(ParseInputLazyPath, "ParseInputLazyPath");
|
48949
|
+
var handleResult = /* @__PURE__ */ __name((ctx, result) => {
|
48950
|
+
if (isValid(result)) {
|
48951
|
+
return { success: true, data: result.value };
|
48952
|
+
} else {
|
48953
|
+
if (!ctx.common.issues.length) {
|
48954
|
+
throw new Error("Validation failed but no issues detected.");
|
48955
|
+
}
|
48956
|
+
const error = new ZodError(ctx.common.issues);
|
48957
|
+
return { success: false, error };
|
48958
|
+
}
|
48959
|
+
}, "handleResult");
|
48960
|
+
function processCreateParams(params) {
|
48961
|
+
if (!params)
|
48962
|
+
return {};
|
48963
|
+
const { errorMap, invalid_type_error, required_error, description } = params;
|
48964
|
+
if (errorMap && (invalid_type_error || required_error)) {
|
48965
|
+
throw new Error(`Can't use "invalid" or "required" in conjunction with custom error map.`);
|
48966
|
+
}
|
48967
|
+
if (errorMap)
|
48968
|
+
return { errorMap, description };
|
48969
|
+
const customMap = /* @__PURE__ */ __name((iss, ctx) => {
|
48970
|
+
if (iss.code !== "invalid_type")
|
48971
|
+
return { message: ctx.defaultError };
|
48972
|
+
if (typeof ctx.data === "undefined" && required_error)
|
48973
|
+
return { message: required_error };
|
48974
|
+
if (params.invalid_type_error)
|
48975
|
+
return { message: params.invalid_type_error };
|
48976
|
+
return { message: ctx.defaultError };
|
48977
|
+
}, "customMap");
|
48978
|
+
return { errorMap: customMap, description };
|
48979
|
+
}
|
48980
|
+
__name(processCreateParams, "processCreateParams");
|
48981
|
+
var ZodType = class {
|
48982
|
+
constructor(def) {
|
48983
|
+
this.spa = this.safeParseAsync;
|
48984
|
+
this.superRefine = this._refinement;
|
48985
|
+
this._def = def;
|
48986
|
+
this.parse = this.parse.bind(this);
|
48987
|
+
this.safeParse = this.safeParse.bind(this);
|
48988
|
+
this.parseAsync = this.parseAsync.bind(this);
|
48989
|
+
this.safeParseAsync = this.safeParseAsync.bind(this);
|
48990
|
+
this.spa = this.spa.bind(this);
|
48991
|
+
this.refine = this.refine.bind(this);
|
48992
|
+
this.refinement = this.refinement.bind(this);
|
48993
|
+
this.superRefine = this.superRefine.bind(this);
|
48994
|
+
this.optional = this.optional.bind(this);
|
48995
|
+
this.nullable = this.nullable.bind(this);
|
48996
|
+
this.nullish = this.nullish.bind(this);
|
48997
|
+
this.array = this.array.bind(this);
|
48998
|
+
this.promise = this.promise.bind(this);
|
48999
|
+
this.or = this.or.bind(this);
|
49000
|
+
this.and = this.and.bind(this);
|
49001
|
+
this.transform = this.transform.bind(this);
|
49002
|
+
this.default = this.default.bind(this);
|
49003
|
+
this.describe = this.describe.bind(this);
|
49004
|
+
this.isNullable = this.isNullable.bind(this);
|
49005
|
+
this.isOptional = this.isOptional.bind(this);
|
49006
|
+
}
|
49007
|
+
get description() {
|
49008
|
+
return this._def.description;
|
49009
|
+
}
|
49010
|
+
_getType(input) {
|
49011
|
+
return getParsedType(input.data);
|
49012
|
+
}
|
49013
|
+
_getOrReturnCtx(input, ctx) {
|
49014
|
+
return ctx || {
|
49015
|
+
common: input.parent.common,
|
49016
|
+
data: input.data,
|
49017
|
+
parsedType: getParsedType(input.data),
|
49018
|
+
schemaErrorMap: this._def.errorMap,
|
49019
|
+
path: input.path,
|
49020
|
+
parent: input.parent
|
49021
|
+
};
|
49022
|
+
}
|
49023
|
+
_processInputParams(input) {
|
49024
|
+
return {
|
49025
|
+
status: new ParseStatus(),
|
49026
|
+
ctx: {
|
49027
|
+
common: input.parent.common,
|
49028
|
+
data: input.data,
|
49029
|
+
parsedType: getParsedType(input.data),
|
49030
|
+
schemaErrorMap: this._def.errorMap,
|
49031
|
+
path: input.path,
|
49032
|
+
parent: input.parent
|
49033
|
+
}
|
49034
|
+
};
|
49035
|
+
}
|
49036
|
+
_parseSync(input) {
|
49037
|
+
const result = this._parse(input);
|
49038
|
+
if (isAsync(result)) {
|
49039
|
+
throw new Error("Synchronous parse encountered promise.");
|
49040
|
+
}
|
49041
|
+
return result;
|
49042
|
+
}
|
49043
|
+
_parseAsync(input) {
|
49044
|
+
const result = this._parse(input);
|
49045
|
+
return Promise.resolve(result);
|
49046
|
+
}
|
49047
|
+
parse(data, params) {
|
49048
|
+
const result = this.safeParse(data, params);
|
49049
|
+
if (result.success)
|
49050
|
+
return result.data;
|
49051
|
+
throw result.error;
|
49052
|
+
}
|
49053
|
+
safeParse(data, params) {
|
49054
|
+
var _a2;
|
49055
|
+
const ctx = {
|
49056
|
+
common: {
|
49057
|
+
issues: [],
|
49058
|
+
async: (_a2 = params === null || params === void 0 ? void 0 : params.async) !== null && _a2 !== void 0 ? _a2 : false,
|
49059
|
+
contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap
|
49060
|
+
},
|
49061
|
+
path: (params === null || params === void 0 ? void 0 : params.path) || [],
|
49062
|
+
schemaErrorMap: this._def.errorMap,
|
49063
|
+
parent: null,
|
49064
|
+
data,
|
49065
|
+
parsedType: getParsedType(data)
|
49066
|
+
};
|
49067
|
+
const result = this._parseSync({ data, path: ctx.path, parent: ctx });
|
49068
|
+
return handleResult(ctx, result);
|
49069
|
+
}
|
49070
|
+
parseAsync(data, params) {
|
49071
|
+
return __async(this, null, function* () {
|
49072
|
+
const result = yield this.safeParseAsync(data, params);
|
49073
|
+
if (result.success)
|
49074
|
+
return result.data;
|
49075
|
+
throw result.error;
|
49076
|
+
});
|
49077
|
+
}
|
49078
|
+
safeParseAsync(data, params) {
|
49079
|
+
return __async(this, null, function* () {
|
49080
|
+
const ctx = {
|
49081
|
+
common: {
|
49082
|
+
issues: [],
|
49083
|
+
contextualErrorMap: params === null || params === void 0 ? void 0 : params.errorMap,
|
49084
|
+
async: true
|
49085
|
+
},
|
49086
|
+
path: (params === null || params === void 0 ? void 0 : params.path) || [],
|
49087
|
+
schemaErrorMap: this._def.errorMap,
|
49088
|
+
parent: null,
|
49089
|
+
data,
|
49090
|
+
parsedType: getParsedType(data)
|
49091
|
+
};
|
49092
|
+
const maybeAsyncResult = this._parse({ data, path: [], parent: ctx });
|
49093
|
+
const result = yield isAsync(maybeAsyncResult) ? maybeAsyncResult : Promise.resolve(maybeAsyncResult);
|
49094
|
+
return handleResult(ctx, result);
|
49095
|
+
});
|
49096
|
+
}
|
49097
|
+
refine(check, message) {
|
49098
|
+
const getIssueProperties = /* @__PURE__ */ __name((val) => {
|
49099
|
+
if (typeof message === "string" || typeof message === "undefined") {
|
49100
|
+
return { message };
|
49101
|
+
} else if (typeof message === "function") {
|
49102
|
+
return message(val);
|
49103
|
+
} else {
|
49104
|
+
return message;
|
49105
|
+
}
|
49106
|
+
}, "getIssueProperties");
|
49107
|
+
return this._refinement((val, ctx) => {
|
49108
|
+
const result = check(val);
|
49109
|
+
const setError = /* @__PURE__ */ __name(() => ctx.addIssue(__spreadValues({
|
49110
|
+
code: ZodIssueCode.custom
|
49111
|
+
}, getIssueProperties(val))), "setError");
|
49112
|
+
if (typeof Promise !== "undefined" && result instanceof Promise) {
|
49113
|
+
return result.then((data) => {
|
49114
|
+
if (!data) {
|
49115
|
+
setError();
|
49116
|
+
return false;
|
49117
|
+
} else {
|
49118
|
+
return true;
|
49119
|
+
}
|
49120
|
+
});
|
49121
|
+
}
|
49122
|
+
if (!result) {
|
49123
|
+
setError();
|
49124
|
+
return false;
|
49125
|
+
} else {
|
49126
|
+
return true;
|
49127
|
+
}
|
49128
|
+
});
|
49129
|
+
}
|
49130
|
+
refinement(check, refinementData) {
|
49131
|
+
return this._refinement((val, ctx) => {
|
49132
|
+
if (!check(val)) {
|
49133
|
+
ctx.addIssue(typeof refinementData === "function" ? refinementData(val, ctx) : refinementData);
|
49134
|
+
return false;
|
49135
|
+
} else {
|
49136
|
+
return true;
|
49137
|
+
}
|
49138
|
+
});
|
49139
|
+
}
|
49140
|
+
_refinement(refinement) {
|
49141
|
+
return new ZodEffects({
|
49142
|
+
schema: this,
|
49143
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
49144
|
+
effect: { type: "refinement", refinement }
|
49145
|
+
});
|
49146
|
+
}
|
49147
|
+
optional() {
|
49148
|
+
return ZodOptional.create(this);
|
49149
|
+
}
|
49150
|
+
nullable() {
|
49151
|
+
return ZodNullable.create(this);
|
49152
|
+
}
|
49153
|
+
nullish() {
|
49154
|
+
return this.optional().nullable();
|
49155
|
+
}
|
49156
|
+
array() {
|
49157
|
+
return ZodArray.create(this);
|
49158
|
+
}
|
49159
|
+
promise() {
|
49160
|
+
return ZodPromise.create(this);
|
49161
|
+
}
|
49162
|
+
or(option) {
|
49163
|
+
return ZodUnion.create([this, option]);
|
49164
|
+
}
|
49165
|
+
and(incoming) {
|
49166
|
+
return ZodIntersection.create(this, incoming);
|
49167
|
+
}
|
49168
|
+
transform(transform) {
|
49169
|
+
return new ZodEffects({
|
49170
|
+
schema: this,
|
49171
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
49172
|
+
effect: { type: "transform", transform }
|
49173
|
+
});
|
49174
|
+
}
|
49175
|
+
default(def) {
|
49176
|
+
const defaultValueFunc = typeof def === "function" ? def : () => def;
|
49177
|
+
return new ZodDefault({
|
49178
|
+
innerType: this,
|
49179
|
+
defaultValue: defaultValueFunc,
|
49180
|
+
typeName: ZodFirstPartyTypeKind.ZodDefault
|
49181
|
+
});
|
49182
|
+
}
|
49183
|
+
describe(description) {
|
49184
|
+
const This = this.constructor;
|
49185
|
+
return new This(__spreadProps(__spreadValues({}, this._def), {
|
49186
|
+
description
|
49187
|
+
}));
|
49188
|
+
}
|
49189
|
+
isOptional() {
|
49190
|
+
return this.safeParse(void 0).success;
|
49191
|
+
}
|
49192
|
+
isNullable() {
|
49193
|
+
return this.safeParse(null).success;
|
49194
|
+
}
|
49195
|
+
};
|
49196
|
+
__name(ZodType, "ZodType");
|
49197
|
+
var cuidRegex = /^c[^\s-]{8,}$/i;
|
49198
|
+
var uuidRegex = /^([a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[a-f0-9]{4}-[a-f0-9]{12}|00000000-0000-0000-0000-000000000000)$/i;
|
49199
|
+
var emailRegex = /^(([^<>()[\]\.,;:\s@\"]+(\.[^<>()[\]\.,;:\s@\"]+)*)|(\".+\"))@(([^<>()[\]\.,;:\s@\"]+\.)+[^<>()[\]\.,;:\s@\"]{2,})$/i;
|
49200
|
+
var ZodString = class extends ZodType {
|
49201
|
+
constructor() {
|
49202
|
+
super(...arguments);
|
49203
|
+
this._regex = (regex, validation, message) => this.refinement((data) => regex.test(data), __spreadValues({
|
49204
|
+
validation,
|
49205
|
+
code: ZodIssueCode.invalid_string
|
49206
|
+
}, errorUtil.errToObj(message)));
|
49207
|
+
this.nonempty = (message) => this.min(1, errorUtil.errToObj(message));
|
49208
|
+
this.trim = () => new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
49209
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
49210
|
+
}));
|
49211
|
+
}
|
49212
|
+
_parse(input) {
|
49213
|
+
const parsedType = this._getType(input);
|
49214
|
+
if (parsedType !== ZodParsedType.string) {
|
49215
|
+
const ctx2 = this._getOrReturnCtx(input);
|
49216
|
+
addIssueToContext(ctx2, {
|
49217
|
+
code: ZodIssueCode.invalid_type,
|
49218
|
+
expected: ZodParsedType.string,
|
49219
|
+
received: ctx2.parsedType
|
49220
|
+
});
|
49221
|
+
return INVALID;
|
49222
|
+
}
|
49223
|
+
const status = new ParseStatus();
|
49224
|
+
let ctx = void 0;
|
49225
|
+
for (const check of this._def.checks) {
|
49226
|
+
if (check.kind === "min") {
|
49227
|
+
if (input.data.length < check.value) {
|
49228
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
49229
|
+
addIssueToContext(ctx, {
|
49230
|
+
code: ZodIssueCode.too_small,
|
49231
|
+
minimum: check.value,
|
49232
|
+
type: "string",
|
49233
|
+
inclusive: true,
|
49234
|
+
message: check.message
|
49235
|
+
});
|
49236
|
+
status.dirty();
|
49237
|
+
}
|
49238
|
+
} else if (check.kind === "max") {
|
49239
|
+
if (input.data.length > check.value) {
|
49240
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
49241
|
+
addIssueToContext(ctx, {
|
49242
|
+
code: ZodIssueCode.too_big,
|
49243
|
+
maximum: check.value,
|
49244
|
+
type: "string",
|
49245
|
+
inclusive: true,
|
49246
|
+
message: check.message
|
49247
|
+
});
|
49248
|
+
status.dirty();
|
49249
|
+
}
|
49250
|
+
} else if (check.kind === "email") {
|
49251
|
+
if (!emailRegex.test(input.data)) {
|
49252
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
49253
|
+
addIssueToContext(ctx, {
|
49254
|
+
validation: "email",
|
49255
|
+
code: ZodIssueCode.invalid_string,
|
49256
|
+
message: check.message
|
49257
|
+
});
|
49258
|
+
status.dirty();
|
49259
|
+
}
|
49260
|
+
} else if (check.kind === "uuid") {
|
49261
|
+
if (!uuidRegex.test(input.data)) {
|
49262
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
49263
|
+
addIssueToContext(ctx, {
|
49264
|
+
validation: "uuid",
|
49265
|
+
code: ZodIssueCode.invalid_string,
|
49266
|
+
message: check.message
|
49267
|
+
});
|
49268
|
+
status.dirty();
|
49269
|
+
}
|
49270
|
+
} else if (check.kind === "cuid") {
|
49271
|
+
if (!cuidRegex.test(input.data)) {
|
49272
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
49273
|
+
addIssueToContext(ctx, {
|
49274
|
+
validation: "cuid",
|
49275
|
+
code: ZodIssueCode.invalid_string,
|
49276
|
+
message: check.message
|
49277
|
+
});
|
49278
|
+
status.dirty();
|
49279
|
+
}
|
49280
|
+
} else if (check.kind === "url") {
|
49281
|
+
try {
|
49282
|
+
new URL(input.data);
|
49283
|
+
} catch (_a2) {
|
49284
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
49285
|
+
addIssueToContext(ctx, {
|
49286
|
+
validation: "url",
|
49287
|
+
code: ZodIssueCode.invalid_string,
|
49288
|
+
message: check.message
|
49289
|
+
});
|
49290
|
+
status.dirty();
|
49291
|
+
}
|
49292
|
+
} else if (check.kind === "regex") {
|
49293
|
+
check.regex.lastIndex = 0;
|
49294
|
+
const testResult = check.regex.test(input.data);
|
49295
|
+
if (!testResult) {
|
49296
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
49297
|
+
addIssueToContext(ctx, {
|
49298
|
+
validation: "regex",
|
49299
|
+
code: ZodIssueCode.invalid_string,
|
49300
|
+
message: check.message
|
49301
|
+
});
|
49302
|
+
status.dirty();
|
49303
|
+
}
|
49304
|
+
} else if (check.kind === "trim") {
|
49305
|
+
input.data = input.data.trim();
|
49306
|
+
} else {
|
49307
|
+
util.assertNever(check);
|
49308
|
+
}
|
49309
|
+
}
|
49310
|
+
return { status: status.value, value: input.data };
|
49311
|
+
}
|
49312
|
+
_addCheck(check) {
|
49313
|
+
return new ZodString(__spreadProps(__spreadValues({}, this._def), {
|
49314
|
+
checks: [...this._def.checks, check]
|
49315
|
+
}));
|
49316
|
+
}
|
49317
|
+
email(message) {
|
49318
|
+
return this._addCheck(__spreadValues({ kind: "email" }, errorUtil.errToObj(message)));
|
49319
|
+
}
|
49320
|
+
url(message) {
|
49321
|
+
return this._addCheck(__spreadValues({ kind: "url" }, errorUtil.errToObj(message)));
|
49322
|
+
}
|
49323
|
+
uuid(message) {
|
49324
|
+
return this._addCheck(__spreadValues({ kind: "uuid" }, errorUtil.errToObj(message)));
|
49325
|
+
}
|
49326
|
+
cuid(message) {
|
49327
|
+
return this._addCheck(__spreadValues({ kind: "cuid" }, errorUtil.errToObj(message)));
|
49328
|
+
}
|
49329
|
+
regex(regex, message) {
|
49330
|
+
return this._addCheck(__spreadValues({
|
49331
|
+
kind: "regex",
|
49332
|
+
regex
|
49333
|
+
}, errorUtil.errToObj(message)));
|
49334
|
+
}
|
49335
|
+
min(minLength, message) {
|
49336
|
+
return this._addCheck(__spreadValues({
|
49337
|
+
kind: "min",
|
49338
|
+
value: minLength
|
49339
|
+
}, errorUtil.errToObj(message)));
|
49340
|
+
}
|
49341
|
+
max(maxLength, message) {
|
49342
|
+
return this._addCheck(__spreadValues({
|
49343
|
+
kind: "max",
|
49344
|
+
value: maxLength
|
49345
|
+
}, errorUtil.errToObj(message)));
|
49346
|
+
}
|
49347
|
+
length(len, message) {
|
49348
|
+
return this.min(len, message).max(len, message);
|
49349
|
+
}
|
49350
|
+
get isEmail() {
|
49351
|
+
return !!this._def.checks.find((ch) => ch.kind === "email");
|
49352
|
+
}
|
49353
|
+
get isURL() {
|
49354
|
+
return !!this._def.checks.find((ch) => ch.kind === "url");
|
49355
|
+
}
|
49356
|
+
get isUUID() {
|
49357
|
+
return !!this._def.checks.find((ch) => ch.kind === "uuid");
|
49358
|
+
}
|
49359
|
+
get isCUID() {
|
49360
|
+
return !!this._def.checks.find((ch) => ch.kind === "cuid");
|
49361
|
+
}
|
49362
|
+
get minLength() {
|
49363
|
+
let min = -Infinity;
|
49364
|
+
this._def.checks.map((ch) => {
|
49365
|
+
if (ch.kind === "min") {
|
49366
|
+
if (min === null || ch.value > min) {
|
49367
|
+
min = ch.value;
|
49368
|
+
}
|
49369
|
+
}
|
49370
|
+
});
|
49371
|
+
return min;
|
49372
|
+
}
|
49373
|
+
get maxLength() {
|
49374
|
+
let max = null;
|
49375
|
+
this._def.checks.map((ch) => {
|
49376
|
+
if (ch.kind === "max") {
|
49377
|
+
if (max === null || ch.value < max) {
|
49378
|
+
max = ch.value;
|
49379
|
+
}
|
49380
|
+
}
|
49381
|
+
});
|
49382
|
+
return max;
|
49383
|
+
}
|
49384
|
+
};
|
49385
|
+
__name(ZodString, "ZodString");
|
49386
|
+
ZodString.create = (params) => {
|
49387
|
+
return new ZodString(__spreadValues({
|
49388
|
+
checks: [],
|
49389
|
+
typeName: ZodFirstPartyTypeKind.ZodString
|
49390
|
+
}, processCreateParams(params)));
|
49391
|
+
};
|
49392
|
+
function floatSafeRemainder(val, step) {
|
49393
|
+
const valDecCount = (val.toString().split(".")[1] || "").length;
|
49394
|
+
const stepDecCount = (step.toString().split(".")[1] || "").length;
|
49395
|
+
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
49396
|
+
const valInt = parseInt(val.toFixed(decCount).replace(".", ""));
|
49397
|
+
const stepInt = parseInt(step.toFixed(decCount).replace(".", ""));
|
49398
|
+
return valInt % stepInt / Math.pow(10, decCount);
|
49399
|
+
}
|
49400
|
+
__name(floatSafeRemainder, "floatSafeRemainder");
|
49401
|
+
var ZodNumber = class extends ZodType {
|
49402
|
+
constructor() {
|
49403
|
+
super(...arguments);
|
49404
|
+
this.min = this.gte;
|
49405
|
+
this.max = this.lte;
|
49406
|
+
this.step = this.multipleOf;
|
49407
|
+
}
|
49408
|
+
_parse(input) {
|
49409
|
+
const parsedType = this._getType(input);
|
49410
|
+
if (parsedType !== ZodParsedType.number) {
|
49411
|
+
const ctx2 = this._getOrReturnCtx(input);
|
49412
|
+
addIssueToContext(ctx2, {
|
49413
|
+
code: ZodIssueCode.invalid_type,
|
49414
|
+
expected: ZodParsedType.number,
|
49415
|
+
received: ctx2.parsedType
|
49416
|
+
});
|
49417
|
+
return INVALID;
|
49418
|
+
}
|
49419
|
+
let ctx = void 0;
|
49420
|
+
const status = new ParseStatus();
|
49421
|
+
for (const check of this._def.checks) {
|
49422
|
+
if (check.kind === "int") {
|
49423
|
+
if (!util.isInteger(input.data)) {
|
49424
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
49425
|
+
addIssueToContext(ctx, {
|
49426
|
+
code: ZodIssueCode.invalid_type,
|
49427
|
+
expected: "integer",
|
49428
|
+
received: "float",
|
49429
|
+
message: check.message
|
49430
|
+
});
|
49431
|
+
status.dirty();
|
49432
|
+
}
|
49433
|
+
} else if (check.kind === "min") {
|
49434
|
+
const tooSmall = check.inclusive ? input.data < check.value : input.data <= check.value;
|
49435
|
+
if (tooSmall) {
|
49436
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
49437
|
+
addIssueToContext(ctx, {
|
49438
|
+
code: ZodIssueCode.too_small,
|
49439
|
+
minimum: check.value,
|
49440
|
+
type: "number",
|
49441
|
+
inclusive: check.inclusive,
|
49442
|
+
message: check.message
|
49443
|
+
});
|
49444
|
+
status.dirty();
|
49445
|
+
}
|
49446
|
+
} else if (check.kind === "max") {
|
49447
|
+
const tooBig = check.inclusive ? input.data > check.value : input.data >= check.value;
|
49448
|
+
if (tooBig) {
|
49449
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
49450
|
+
addIssueToContext(ctx, {
|
49451
|
+
code: ZodIssueCode.too_big,
|
49452
|
+
maximum: check.value,
|
49453
|
+
type: "number",
|
49454
|
+
inclusive: check.inclusive,
|
49455
|
+
message: check.message
|
49456
|
+
});
|
49457
|
+
status.dirty();
|
49458
|
+
}
|
49459
|
+
} else if (check.kind === "multipleOf") {
|
49460
|
+
if (floatSafeRemainder(input.data, check.value) !== 0) {
|
49461
|
+
ctx = this._getOrReturnCtx(input, ctx);
|
49462
|
+
addIssueToContext(ctx, {
|
49463
|
+
code: ZodIssueCode.not_multiple_of,
|
49464
|
+
multipleOf: check.value,
|
49465
|
+
message: check.message
|
49466
|
+
});
|
49467
|
+
status.dirty();
|
49468
|
+
}
|
49469
|
+
} else {
|
49470
|
+
util.assertNever(check);
|
49471
|
+
}
|
49472
|
+
}
|
49473
|
+
return { status: status.value, value: input.data };
|
49474
|
+
}
|
49475
|
+
gte(value, message) {
|
49476
|
+
return this.setLimit("min", value, true, errorUtil.toString(message));
|
49477
|
+
}
|
49478
|
+
gt(value, message) {
|
49479
|
+
return this.setLimit("min", value, false, errorUtil.toString(message));
|
49480
|
+
}
|
49481
|
+
lte(value, message) {
|
49482
|
+
return this.setLimit("max", value, true, errorUtil.toString(message));
|
49483
|
+
}
|
49484
|
+
lt(value, message) {
|
49485
|
+
return this.setLimit("max", value, false, errorUtil.toString(message));
|
49486
|
+
}
|
49487
|
+
setLimit(kind, value, inclusive, message) {
|
49488
|
+
return new ZodNumber(__spreadProps(__spreadValues({}, this._def), {
|
49489
|
+
checks: [
|
49490
|
+
...this._def.checks,
|
49491
|
+
{
|
49492
|
+
kind,
|
49493
|
+
value,
|
49494
|
+
inclusive,
|
49495
|
+
message: errorUtil.toString(message)
|
49496
|
+
}
|
49497
|
+
]
|
49498
|
+
}));
|
49499
|
+
}
|
49500
|
+
_addCheck(check) {
|
49501
|
+
return new ZodNumber(__spreadProps(__spreadValues({}, this._def), {
|
49502
|
+
checks: [...this._def.checks, check]
|
49503
|
+
}));
|
49504
|
+
}
|
49505
|
+
int(message) {
|
49506
|
+
return this._addCheck({
|
49507
|
+
kind: "int",
|
49508
|
+
message: errorUtil.toString(message)
|
49509
|
+
});
|
49510
|
+
}
|
49511
|
+
positive(message) {
|
49512
|
+
return this._addCheck({
|
49513
|
+
kind: "min",
|
49514
|
+
value: 0,
|
49515
|
+
inclusive: false,
|
49516
|
+
message: errorUtil.toString(message)
|
49517
|
+
});
|
49518
|
+
}
|
49519
|
+
negative(message) {
|
49520
|
+
return this._addCheck({
|
49521
|
+
kind: "max",
|
49522
|
+
value: 0,
|
49523
|
+
inclusive: false,
|
49524
|
+
message: errorUtil.toString(message)
|
49525
|
+
});
|
49526
|
+
}
|
49527
|
+
nonpositive(message) {
|
49528
|
+
return this._addCheck({
|
49529
|
+
kind: "max",
|
49530
|
+
value: 0,
|
49531
|
+
inclusive: true,
|
49532
|
+
message: errorUtil.toString(message)
|
49533
|
+
});
|
49534
|
+
}
|
49535
|
+
nonnegative(message) {
|
49536
|
+
return this._addCheck({
|
49537
|
+
kind: "min",
|
49538
|
+
value: 0,
|
49539
|
+
inclusive: true,
|
49540
|
+
message: errorUtil.toString(message)
|
49541
|
+
});
|
49542
|
+
}
|
49543
|
+
multipleOf(value, message) {
|
49544
|
+
return this._addCheck({
|
49545
|
+
kind: "multipleOf",
|
49546
|
+
value,
|
49547
|
+
message: errorUtil.toString(message)
|
49548
|
+
});
|
49549
|
+
}
|
49550
|
+
get minValue() {
|
49551
|
+
let min = null;
|
49552
|
+
for (const ch of this._def.checks) {
|
49553
|
+
if (ch.kind === "min") {
|
49554
|
+
if (min === null || ch.value > min)
|
49555
|
+
min = ch.value;
|
49556
|
+
}
|
49557
|
+
}
|
49558
|
+
return min;
|
49559
|
+
}
|
49560
|
+
get maxValue() {
|
49561
|
+
let max = null;
|
49562
|
+
for (const ch of this._def.checks) {
|
49563
|
+
if (ch.kind === "max") {
|
49564
|
+
if (max === null || ch.value < max)
|
49565
|
+
max = ch.value;
|
49566
|
+
}
|
49567
|
+
}
|
49568
|
+
return max;
|
49569
|
+
}
|
49570
|
+
get isInt() {
|
49571
|
+
return !!this._def.checks.find((ch) => ch.kind === "int");
|
49572
|
+
}
|
49573
|
+
};
|
49574
|
+
__name(ZodNumber, "ZodNumber");
|
49575
|
+
ZodNumber.create = (params) => {
|
49576
|
+
return new ZodNumber(__spreadValues({
|
49577
|
+
checks: [],
|
49578
|
+
typeName: ZodFirstPartyTypeKind.ZodNumber
|
49579
|
+
}, processCreateParams(params)));
|
49580
|
+
};
|
49581
|
+
var ZodBigInt = class extends ZodType {
|
49582
|
+
_parse(input) {
|
49583
|
+
const parsedType = this._getType(input);
|
49584
|
+
if (parsedType !== ZodParsedType.bigint) {
|
49585
|
+
const ctx = this._getOrReturnCtx(input);
|
49586
|
+
addIssueToContext(ctx, {
|
49587
|
+
code: ZodIssueCode.invalid_type,
|
49588
|
+
expected: ZodParsedType.bigint,
|
49589
|
+
received: ctx.parsedType
|
49590
|
+
});
|
49591
|
+
return INVALID;
|
49592
|
+
}
|
49593
|
+
return OK(input.data);
|
49594
|
+
}
|
49595
|
+
};
|
49596
|
+
__name(ZodBigInt, "ZodBigInt");
|
49597
|
+
ZodBigInt.create = (params) => {
|
49598
|
+
return new ZodBigInt(__spreadValues({
|
49599
|
+
typeName: ZodFirstPartyTypeKind.ZodBigInt
|
49600
|
+
}, processCreateParams(params)));
|
49601
|
+
};
|
49602
|
+
var ZodBoolean = class extends ZodType {
|
49603
|
+
_parse(input) {
|
49604
|
+
const parsedType = this._getType(input);
|
49605
|
+
if (parsedType !== ZodParsedType.boolean) {
|
49606
|
+
const ctx = this._getOrReturnCtx(input);
|
49607
|
+
addIssueToContext(ctx, {
|
49608
|
+
code: ZodIssueCode.invalid_type,
|
49609
|
+
expected: ZodParsedType.boolean,
|
49610
|
+
received: ctx.parsedType
|
49611
|
+
});
|
49612
|
+
return INVALID;
|
49613
|
+
}
|
49614
|
+
return OK(input.data);
|
49615
|
+
}
|
49616
|
+
};
|
49617
|
+
__name(ZodBoolean, "ZodBoolean");
|
49618
|
+
ZodBoolean.create = (params) => {
|
49619
|
+
return new ZodBoolean(__spreadValues({
|
49620
|
+
typeName: ZodFirstPartyTypeKind.ZodBoolean
|
49621
|
+
}, processCreateParams(params)));
|
49622
|
+
};
|
49623
|
+
var ZodDate = class extends ZodType {
|
49624
|
+
_parse(input) {
|
49625
|
+
const parsedType = this._getType(input);
|
49626
|
+
if (parsedType !== ZodParsedType.date) {
|
49627
|
+
const ctx = this._getOrReturnCtx(input);
|
49628
|
+
addIssueToContext(ctx, {
|
49629
|
+
code: ZodIssueCode.invalid_type,
|
49630
|
+
expected: ZodParsedType.date,
|
49631
|
+
received: ctx.parsedType
|
49632
|
+
});
|
49633
|
+
return INVALID;
|
49634
|
+
}
|
49635
|
+
if (isNaN(input.data.getTime())) {
|
49636
|
+
const ctx = this._getOrReturnCtx(input);
|
49637
|
+
addIssueToContext(ctx, {
|
49638
|
+
code: ZodIssueCode.invalid_date
|
49639
|
+
});
|
49640
|
+
return INVALID;
|
49641
|
+
}
|
49642
|
+
return {
|
49643
|
+
status: "valid",
|
49644
|
+
value: new Date(input.data.getTime())
|
49645
|
+
};
|
49646
|
+
}
|
49647
|
+
};
|
49648
|
+
__name(ZodDate, "ZodDate");
|
49649
|
+
ZodDate.create = (params) => {
|
49650
|
+
return new ZodDate(__spreadValues({
|
49651
|
+
typeName: ZodFirstPartyTypeKind.ZodDate
|
49652
|
+
}, processCreateParams(params)));
|
49653
|
+
};
|
49654
|
+
var ZodUndefined = class extends ZodType {
|
49655
|
+
_parse(input) {
|
49656
|
+
const parsedType = this._getType(input);
|
49657
|
+
if (parsedType !== ZodParsedType.undefined) {
|
49658
|
+
const ctx = this._getOrReturnCtx(input);
|
49659
|
+
addIssueToContext(ctx, {
|
49660
|
+
code: ZodIssueCode.invalid_type,
|
49661
|
+
expected: ZodParsedType.undefined,
|
49662
|
+
received: ctx.parsedType
|
49663
|
+
});
|
49664
|
+
return INVALID;
|
49665
|
+
}
|
49666
|
+
return OK(input.data);
|
49667
|
+
}
|
49668
|
+
};
|
49669
|
+
__name(ZodUndefined, "ZodUndefined");
|
49670
|
+
ZodUndefined.create = (params) => {
|
49671
|
+
return new ZodUndefined(__spreadValues({
|
49672
|
+
typeName: ZodFirstPartyTypeKind.ZodUndefined
|
49673
|
+
}, processCreateParams(params)));
|
49674
|
+
};
|
49675
|
+
var ZodNull = class extends ZodType {
|
49676
|
+
_parse(input) {
|
49677
|
+
const parsedType = this._getType(input);
|
49678
|
+
if (parsedType !== ZodParsedType.null) {
|
49679
|
+
const ctx = this._getOrReturnCtx(input);
|
49680
|
+
addIssueToContext(ctx, {
|
49681
|
+
code: ZodIssueCode.invalid_type,
|
49682
|
+
expected: ZodParsedType.null,
|
49683
|
+
received: ctx.parsedType
|
49684
|
+
});
|
49685
|
+
return INVALID;
|
49686
|
+
}
|
49687
|
+
return OK(input.data);
|
49688
|
+
}
|
49689
|
+
};
|
49690
|
+
__name(ZodNull, "ZodNull");
|
49691
|
+
ZodNull.create = (params) => {
|
49692
|
+
return new ZodNull(__spreadValues({
|
49693
|
+
typeName: ZodFirstPartyTypeKind.ZodNull
|
49694
|
+
}, processCreateParams(params)));
|
49695
|
+
};
|
49696
|
+
var ZodAny = class extends ZodType {
|
49697
|
+
constructor() {
|
49698
|
+
super(...arguments);
|
49699
|
+
this._any = true;
|
49700
|
+
}
|
49701
|
+
_parse(input) {
|
49702
|
+
return OK(input.data);
|
49703
|
+
}
|
49704
|
+
};
|
49705
|
+
__name(ZodAny, "ZodAny");
|
49706
|
+
ZodAny.create = (params) => {
|
49707
|
+
return new ZodAny(__spreadValues({
|
49708
|
+
typeName: ZodFirstPartyTypeKind.ZodAny
|
49709
|
+
}, processCreateParams(params)));
|
49710
|
+
};
|
49711
|
+
var ZodUnknown = class extends ZodType {
|
49712
|
+
constructor() {
|
49713
|
+
super(...arguments);
|
49714
|
+
this._unknown = true;
|
49715
|
+
}
|
49716
|
+
_parse(input) {
|
49717
|
+
return OK(input.data);
|
49718
|
+
}
|
49719
|
+
};
|
49720
|
+
__name(ZodUnknown, "ZodUnknown");
|
49721
|
+
ZodUnknown.create = (params) => {
|
49722
|
+
return new ZodUnknown(__spreadValues({
|
49723
|
+
typeName: ZodFirstPartyTypeKind.ZodUnknown
|
49724
|
+
}, processCreateParams(params)));
|
49725
|
+
};
|
49726
|
+
var ZodNever = class extends ZodType {
|
49727
|
+
_parse(input) {
|
49728
|
+
const ctx = this._getOrReturnCtx(input);
|
49729
|
+
addIssueToContext(ctx, {
|
49730
|
+
code: ZodIssueCode.invalid_type,
|
49731
|
+
expected: ZodParsedType.never,
|
49732
|
+
received: ctx.parsedType
|
49733
|
+
});
|
49734
|
+
return INVALID;
|
49735
|
+
}
|
49736
|
+
};
|
49737
|
+
__name(ZodNever, "ZodNever");
|
49738
|
+
ZodNever.create = (params) => {
|
49739
|
+
return new ZodNever(__spreadValues({
|
49740
|
+
typeName: ZodFirstPartyTypeKind.ZodNever
|
49741
|
+
}, processCreateParams(params)));
|
49742
|
+
};
|
49743
|
+
var ZodVoid = class extends ZodType {
|
49744
|
+
_parse(input) {
|
49745
|
+
const parsedType = this._getType(input);
|
49746
|
+
if (parsedType !== ZodParsedType.undefined) {
|
49747
|
+
const ctx = this._getOrReturnCtx(input);
|
49748
|
+
addIssueToContext(ctx, {
|
49749
|
+
code: ZodIssueCode.invalid_type,
|
49750
|
+
expected: ZodParsedType.void,
|
49751
|
+
received: ctx.parsedType
|
49752
|
+
});
|
49753
|
+
return INVALID;
|
49754
|
+
}
|
49755
|
+
return OK(input.data);
|
49756
|
+
}
|
49757
|
+
};
|
49758
|
+
__name(ZodVoid, "ZodVoid");
|
49759
|
+
ZodVoid.create = (params) => {
|
49760
|
+
return new ZodVoid(__spreadValues({
|
49761
|
+
typeName: ZodFirstPartyTypeKind.ZodVoid
|
49762
|
+
}, processCreateParams(params)));
|
49763
|
+
};
|
49764
|
+
var ZodArray = class extends ZodType {
|
49765
|
+
_parse(input) {
|
49766
|
+
const { ctx, status } = this._processInputParams(input);
|
49767
|
+
const def = this._def;
|
49768
|
+
if (ctx.parsedType !== ZodParsedType.array) {
|
49769
|
+
addIssueToContext(ctx, {
|
49770
|
+
code: ZodIssueCode.invalid_type,
|
49771
|
+
expected: ZodParsedType.array,
|
49772
|
+
received: ctx.parsedType
|
49773
|
+
});
|
49774
|
+
return INVALID;
|
49775
|
+
}
|
49776
|
+
if (def.minLength !== null) {
|
49777
|
+
if (ctx.data.length < def.minLength.value) {
|
49778
|
+
addIssueToContext(ctx, {
|
49779
|
+
code: ZodIssueCode.too_small,
|
49780
|
+
minimum: def.minLength.value,
|
49781
|
+
type: "array",
|
49782
|
+
inclusive: true,
|
49783
|
+
message: def.minLength.message
|
49784
|
+
});
|
49785
|
+
status.dirty();
|
49786
|
+
}
|
49787
|
+
}
|
49788
|
+
if (def.maxLength !== null) {
|
49789
|
+
if (ctx.data.length > def.maxLength.value) {
|
49790
|
+
addIssueToContext(ctx, {
|
49791
|
+
code: ZodIssueCode.too_big,
|
49792
|
+
maximum: def.maxLength.value,
|
49793
|
+
type: "array",
|
49794
|
+
inclusive: true,
|
49795
|
+
message: def.maxLength.message
|
49796
|
+
});
|
49797
|
+
status.dirty();
|
49798
|
+
}
|
49799
|
+
}
|
49800
|
+
if (ctx.common.async) {
|
49801
|
+
return Promise.all(ctx.data.map((item, i) => {
|
49802
|
+
return def.type._parseAsync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
49803
|
+
})).then((result2) => {
|
49804
|
+
return ParseStatus.mergeArray(status, result2);
|
49805
|
+
});
|
49806
|
+
}
|
49807
|
+
const result = ctx.data.map((item, i) => {
|
49808
|
+
return def.type._parseSync(new ParseInputLazyPath(ctx, item, ctx.path, i));
|
49809
|
+
});
|
49810
|
+
return ParseStatus.mergeArray(status, result);
|
49811
|
+
}
|
49812
|
+
get element() {
|
49813
|
+
return this._def.type;
|
49814
|
+
}
|
49815
|
+
min(minLength, message) {
|
49816
|
+
return new ZodArray(__spreadProps(__spreadValues({}, this._def), {
|
49817
|
+
minLength: { value: minLength, message: errorUtil.toString(message) }
|
49818
|
+
}));
|
49819
|
+
}
|
49820
|
+
max(maxLength, message) {
|
49821
|
+
return new ZodArray(__spreadProps(__spreadValues({}, this._def), {
|
49822
|
+
maxLength: { value: maxLength, message: errorUtil.toString(message) }
|
49823
|
+
}));
|
49824
|
+
}
|
49825
|
+
length(len, message) {
|
49826
|
+
return this.min(len, message).max(len, message);
|
49827
|
+
}
|
49828
|
+
nonempty(message) {
|
49829
|
+
return this.min(1, message);
|
49830
|
+
}
|
49831
|
+
};
|
49832
|
+
__name(ZodArray, "ZodArray");
|
49833
|
+
ZodArray.create = (schema, params) => {
|
49834
|
+
return new ZodArray(__spreadValues({
|
49835
|
+
type: schema,
|
49836
|
+
minLength: null,
|
49837
|
+
maxLength: null,
|
49838
|
+
typeName: ZodFirstPartyTypeKind.ZodArray
|
49839
|
+
}, processCreateParams(params)));
|
49840
|
+
};
|
49841
|
+
var objectUtil;
|
49842
|
+
(function(objectUtil2) {
|
49843
|
+
objectUtil2.mergeShapes = (first2, second) => {
|
49844
|
+
return __spreadValues(__spreadValues({}, first2), second);
|
49845
|
+
};
|
49846
|
+
})(objectUtil || (objectUtil = {}));
|
49847
|
+
var AugmentFactory = /* @__PURE__ */ __name((def) => (augmentation) => {
|
49848
|
+
return new ZodObject(__spreadProps(__spreadValues({}, def), {
|
49849
|
+
shape: () => __spreadValues(__spreadValues({}, def.shape()), augmentation)
|
49850
|
+
}));
|
49851
|
+
}, "AugmentFactory");
|
49852
|
+
function deepPartialify(schema) {
|
49853
|
+
if (schema instanceof ZodObject) {
|
49854
|
+
const newShape = {};
|
49855
|
+
for (const key2 in schema.shape) {
|
49856
|
+
const fieldSchema = schema.shape[key2];
|
49857
|
+
newShape[key2] = ZodOptional.create(deepPartialify(fieldSchema));
|
49858
|
+
}
|
49859
|
+
return new ZodObject(__spreadProps(__spreadValues({}, schema._def), {
|
49860
|
+
shape: () => newShape
|
49861
|
+
}));
|
49862
|
+
} else if (schema instanceof ZodArray) {
|
49863
|
+
return ZodArray.create(deepPartialify(schema.element));
|
49864
|
+
} else if (schema instanceof ZodOptional) {
|
49865
|
+
return ZodOptional.create(deepPartialify(schema.unwrap()));
|
49866
|
+
} else if (schema instanceof ZodNullable) {
|
49867
|
+
return ZodNullable.create(deepPartialify(schema.unwrap()));
|
49868
|
+
} else if (schema instanceof ZodTuple) {
|
49869
|
+
return ZodTuple.create(schema.items.map((item) => deepPartialify(item)));
|
49870
|
+
} else {
|
49871
|
+
return schema;
|
49872
|
+
}
|
49873
|
+
}
|
49874
|
+
__name(deepPartialify, "deepPartialify");
|
49875
|
+
var ZodObject = class extends ZodType {
|
49876
|
+
constructor() {
|
49877
|
+
super(...arguments);
|
49878
|
+
this._cached = null;
|
49879
|
+
this.nonstrict = this.passthrough;
|
49880
|
+
this.augment = AugmentFactory(this._def);
|
49881
|
+
this.extend = AugmentFactory(this._def);
|
49882
|
+
}
|
49883
|
+
_getCached() {
|
49884
|
+
if (this._cached !== null)
|
49885
|
+
return this._cached;
|
49886
|
+
const shape = this._def.shape();
|
49887
|
+
const keys = util.objectKeys(shape);
|
49888
|
+
return this._cached = { shape, keys };
|
49889
|
+
}
|
49890
|
+
_parse(input) {
|
49891
|
+
const parsedType = this._getType(input);
|
49892
|
+
if (parsedType !== ZodParsedType.object) {
|
49893
|
+
const ctx2 = this._getOrReturnCtx(input);
|
49894
|
+
addIssueToContext(ctx2, {
|
49895
|
+
code: ZodIssueCode.invalid_type,
|
49896
|
+
expected: ZodParsedType.object,
|
49897
|
+
received: ctx2.parsedType
|
49898
|
+
});
|
49899
|
+
return INVALID;
|
49900
|
+
}
|
49901
|
+
const { status, ctx } = this._processInputParams(input);
|
49902
|
+
const { shape, keys: shapeKeys } = this._getCached();
|
49903
|
+
const extraKeys = [];
|
49904
|
+
for (const key2 in ctx.data) {
|
49905
|
+
if (!shapeKeys.includes(key2)) {
|
49906
|
+
extraKeys.push(key2);
|
49907
|
+
}
|
49908
|
+
}
|
49909
|
+
const pairs = [];
|
49910
|
+
for (const key2 of shapeKeys) {
|
49911
|
+
const keyValidator = shape[key2];
|
49912
|
+
const value = ctx.data[key2];
|
49913
|
+
pairs.push({
|
49914
|
+
key: { status: "valid", value: key2 },
|
49915
|
+
value: keyValidator._parse(new ParseInputLazyPath(ctx, value, ctx.path, key2)),
|
49916
|
+
alwaysSet: key2 in ctx.data
|
49917
|
+
});
|
49918
|
+
}
|
49919
|
+
if (this._def.catchall instanceof ZodNever) {
|
49920
|
+
const unknownKeys = this._def.unknownKeys;
|
49921
|
+
if (unknownKeys === "passthrough") {
|
49922
|
+
for (const key2 of extraKeys) {
|
49923
|
+
pairs.push({
|
49924
|
+
key: { status: "valid", value: key2 },
|
49925
|
+
value: { status: "valid", value: ctx.data[key2] }
|
49926
|
+
});
|
49927
|
+
}
|
49928
|
+
} else if (unknownKeys === "strict") {
|
49929
|
+
if (extraKeys.length > 0) {
|
49930
|
+
addIssueToContext(ctx, {
|
49931
|
+
code: ZodIssueCode.unrecognized_keys,
|
49932
|
+
keys: extraKeys
|
49933
|
+
});
|
49934
|
+
status.dirty();
|
49935
|
+
}
|
49936
|
+
} else if (unknownKeys === "strip")
|
49937
|
+
;
|
49938
|
+
else {
|
49939
|
+
throw new Error(`Internal ZodObject error: invalid unknownKeys value.`);
|
49940
|
+
}
|
49941
|
+
} else {
|
49942
|
+
const catchall = this._def.catchall;
|
49943
|
+
for (const key2 of extraKeys) {
|
49944
|
+
const value = ctx.data[key2];
|
49945
|
+
pairs.push({
|
49946
|
+
key: { status: "valid", value: key2 },
|
49947
|
+
value: catchall._parse(new ParseInputLazyPath(ctx, value, ctx.path, key2)),
|
49948
|
+
alwaysSet: key2 in ctx.data
|
49949
|
+
});
|
49950
|
+
}
|
49951
|
+
}
|
49952
|
+
if (ctx.common.async) {
|
49953
|
+
return Promise.resolve().then(() => __async(this, null, function* () {
|
49954
|
+
const syncPairs = [];
|
49955
|
+
for (const pair of pairs) {
|
49956
|
+
const key2 = yield pair.key;
|
49957
|
+
syncPairs.push({
|
49958
|
+
key: key2,
|
49959
|
+
value: yield pair.value,
|
49960
|
+
alwaysSet: pair.alwaysSet
|
49961
|
+
});
|
49962
|
+
}
|
49963
|
+
return syncPairs;
|
49964
|
+
})).then((syncPairs) => {
|
49965
|
+
return ParseStatus.mergeObjectSync(status, syncPairs);
|
49966
|
+
});
|
49967
|
+
} else {
|
49968
|
+
return ParseStatus.mergeObjectSync(status, pairs);
|
49969
|
+
}
|
49970
|
+
}
|
49971
|
+
get shape() {
|
49972
|
+
return this._def.shape();
|
49973
|
+
}
|
49974
|
+
strict(message) {
|
49975
|
+
errorUtil.errToObj;
|
49976
|
+
return new ZodObject(__spreadValues(__spreadProps(__spreadValues({}, this._def), {
|
49977
|
+
unknownKeys: "strict"
|
49978
|
+
}), message !== void 0 ? {
|
49979
|
+
errorMap: (issue, ctx) => {
|
49980
|
+
var _a2, _b, _c, _d;
|
49981
|
+
const defaultError = (_c = (_b = (_a2 = this._def).errorMap) === null || _b === void 0 ? void 0 : _b.call(_a2, issue, ctx).message) !== null && _c !== void 0 ? _c : ctx.defaultError;
|
49982
|
+
if (issue.code === "unrecognized_keys")
|
49983
|
+
return {
|
49984
|
+
message: (_d = errorUtil.errToObj(message).message) !== null && _d !== void 0 ? _d : defaultError
|
49985
|
+
};
|
49986
|
+
return {
|
49987
|
+
message: defaultError
|
49988
|
+
};
|
49989
|
+
}
|
49990
|
+
} : {}));
|
49991
|
+
}
|
49992
|
+
strip() {
|
49993
|
+
return new ZodObject(__spreadProps(__spreadValues({}, this._def), {
|
49994
|
+
unknownKeys: "strip"
|
49995
|
+
}));
|
49996
|
+
}
|
49997
|
+
passthrough() {
|
49998
|
+
return new ZodObject(__spreadProps(__spreadValues({}, this._def), {
|
49999
|
+
unknownKeys: "passthrough"
|
50000
|
+
}));
|
50001
|
+
}
|
50002
|
+
setKey(key2, schema) {
|
50003
|
+
return this.augment({ [key2]: schema });
|
50004
|
+
}
|
50005
|
+
merge(merging) {
|
50006
|
+
const merged = new ZodObject({
|
50007
|
+
unknownKeys: merging._def.unknownKeys,
|
50008
|
+
catchall: merging._def.catchall,
|
50009
|
+
shape: () => objectUtil.mergeShapes(this._def.shape(), merging._def.shape()),
|
50010
|
+
typeName: ZodFirstPartyTypeKind.ZodObject
|
50011
|
+
});
|
50012
|
+
return merged;
|
50013
|
+
}
|
50014
|
+
catchall(index) {
|
50015
|
+
return new ZodObject(__spreadProps(__spreadValues({}, this._def), {
|
50016
|
+
catchall: index
|
50017
|
+
}));
|
50018
|
+
}
|
50019
|
+
pick(mask) {
|
50020
|
+
const shape = {};
|
50021
|
+
util.objectKeys(mask).map((key2) => {
|
50022
|
+
if (this.shape[key2])
|
50023
|
+
shape[key2] = this.shape[key2];
|
50024
|
+
});
|
50025
|
+
return new ZodObject(__spreadProps(__spreadValues({}, this._def), {
|
50026
|
+
shape: () => shape
|
50027
|
+
}));
|
50028
|
+
}
|
50029
|
+
omit(mask) {
|
50030
|
+
const shape = {};
|
50031
|
+
util.objectKeys(this.shape).map((key2) => {
|
50032
|
+
if (util.objectKeys(mask).indexOf(key2) === -1) {
|
50033
|
+
shape[key2] = this.shape[key2];
|
50034
|
+
}
|
50035
|
+
});
|
50036
|
+
return new ZodObject(__spreadProps(__spreadValues({}, this._def), {
|
50037
|
+
shape: () => shape
|
50038
|
+
}));
|
50039
|
+
}
|
50040
|
+
deepPartial() {
|
50041
|
+
return deepPartialify(this);
|
50042
|
+
}
|
50043
|
+
partial(mask) {
|
50044
|
+
const newShape = {};
|
50045
|
+
if (mask) {
|
50046
|
+
util.objectKeys(this.shape).map((key2) => {
|
50047
|
+
if (util.objectKeys(mask).indexOf(key2) === -1) {
|
50048
|
+
newShape[key2] = this.shape[key2];
|
50049
|
+
} else {
|
50050
|
+
newShape[key2] = this.shape[key2].optional();
|
50051
|
+
}
|
50052
|
+
});
|
50053
|
+
return new ZodObject(__spreadProps(__spreadValues({}, this._def), {
|
50054
|
+
shape: () => newShape
|
50055
|
+
}));
|
50056
|
+
} else {
|
50057
|
+
for (const key2 in this.shape) {
|
50058
|
+
const fieldSchema = this.shape[key2];
|
50059
|
+
newShape[key2] = fieldSchema.optional();
|
50060
|
+
}
|
50061
|
+
}
|
50062
|
+
return new ZodObject(__spreadProps(__spreadValues({}, this._def), {
|
50063
|
+
shape: () => newShape
|
50064
|
+
}));
|
50065
|
+
}
|
50066
|
+
required() {
|
50067
|
+
const newShape = {};
|
50068
|
+
for (const key2 in this.shape) {
|
50069
|
+
const fieldSchema = this.shape[key2];
|
50070
|
+
let newField = fieldSchema;
|
50071
|
+
while (newField instanceof ZodOptional) {
|
50072
|
+
newField = newField._def.innerType;
|
50073
|
+
}
|
50074
|
+
newShape[key2] = newField;
|
50075
|
+
}
|
50076
|
+
return new ZodObject(__spreadProps(__spreadValues({}, this._def), {
|
50077
|
+
shape: () => newShape
|
50078
|
+
}));
|
50079
|
+
}
|
50080
|
+
};
|
50081
|
+
__name(ZodObject, "ZodObject");
|
50082
|
+
ZodObject.create = (shape, params) => {
|
50083
|
+
return new ZodObject(__spreadValues({
|
50084
|
+
shape: () => shape,
|
50085
|
+
unknownKeys: "strip",
|
50086
|
+
catchall: ZodNever.create(),
|
50087
|
+
typeName: ZodFirstPartyTypeKind.ZodObject
|
50088
|
+
}, processCreateParams(params)));
|
50089
|
+
};
|
50090
|
+
ZodObject.strictCreate = (shape, params) => {
|
50091
|
+
return new ZodObject(__spreadValues({
|
50092
|
+
shape: () => shape,
|
50093
|
+
unknownKeys: "strict",
|
50094
|
+
catchall: ZodNever.create(),
|
50095
|
+
typeName: ZodFirstPartyTypeKind.ZodObject
|
50096
|
+
}, processCreateParams(params)));
|
50097
|
+
};
|
50098
|
+
ZodObject.lazycreate = (shape, params) => {
|
50099
|
+
return new ZodObject(__spreadValues({
|
50100
|
+
shape,
|
50101
|
+
unknownKeys: "strip",
|
50102
|
+
catchall: ZodNever.create(),
|
50103
|
+
typeName: ZodFirstPartyTypeKind.ZodObject
|
50104
|
+
}, processCreateParams(params)));
|
50105
|
+
};
|
50106
|
+
var ZodUnion = class extends ZodType {
|
50107
|
+
_parse(input) {
|
50108
|
+
const { ctx } = this._processInputParams(input);
|
50109
|
+
const options = this._def.options;
|
50110
|
+
function handleResults(results) {
|
50111
|
+
for (const result of results) {
|
50112
|
+
if (result.result.status === "valid") {
|
50113
|
+
return result.result;
|
50114
|
+
}
|
50115
|
+
}
|
50116
|
+
for (const result of results) {
|
50117
|
+
if (result.result.status === "dirty") {
|
50118
|
+
ctx.common.issues.push(...result.ctx.common.issues);
|
50119
|
+
return result.result;
|
50120
|
+
}
|
50121
|
+
}
|
50122
|
+
const unionErrors = results.map((result) => new ZodError(result.ctx.common.issues));
|
50123
|
+
addIssueToContext(ctx, {
|
50124
|
+
code: ZodIssueCode.invalid_union,
|
50125
|
+
unionErrors
|
50126
|
+
});
|
50127
|
+
return INVALID;
|
50128
|
+
}
|
50129
|
+
__name(handleResults, "handleResults");
|
50130
|
+
if (ctx.common.async) {
|
50131
|
+
return Promise.all(options.map((option) => __async(this, null, function* () {
|
50132
|
+
const childCtx = __spreadProps(__spreadValues({}, ctx), {
|
50133
|
+
common: __spreadProps(__spreadValues({}, ctx.common), {
|
50134
|
+
issues: []
|
50135
|
+
}),
|
50136
|
+
parent: null
|
50137
|
+
});
|
50138
|
+
return {
|
50139
|
+
result: yield option._parseAsync({
|
50140
|
+
data: ctx.data,
|
50141
|
+
path: ctx.path,
|
50142
|
+
parent: childCtx
|
50143
|
+
}),
|
50144
|
+
ctx: childCtx
|
50145
|
+
};
|
50146
|
+
}))).then(handleResults);
|
50147
|
+
} else {
|
50148
|
+
let dirty = void 0;
|
50149
|
+
const issues = [];
|
50150
|
+
for (const option of options) {
|
50151
|
+
const childCtx = __spreadProps(__spreadValues({}, ctx), {
|
50152
|
+
common: __spreadProps(__spreadValues({}, ctx.common), {
|
50153
|
+
issues: []
|
50154
|
+
}),
|
50155
|
+
parent: null
|
50156
|
+
});
|
50157
|
+
const result = option._parseSync({
|
50158
|
+
data: ctx.data,
|
50159
|
+
path: ctx.path,
|
50160
|
+
parent: childCtx
|
50161
|
+
});
|
50162
|
+
if (result.status === "valid") {
|
50163
|
+
return result;
|
50164
|
+
} else if (result.status === "dirty" && !dirty) {
|
50165
|
+
dirty = { result, ctx: childCtx };
|
50166
|
+
}
|
50167
|
+
if (childCtx.common.issues.length) {
|
50168
|
+
issues.push(childCtx.common.issues);
|
50169
|
+
}
|
50170
|
+
}
|
50171
|
+
if (dirty) {
|
50172
|
+
ctx.common.issues.push(...dirty.ctx.common.issues);
|
50173
|
+
return dirty.result;
|
50174
|
+
}
|
50175
|
+
const unionErrors = issues.map((issues2) => new ZodError(issues2));
|
50176
|
+
addIssueToContext(ctx, {
|
50177
|
+
code: ZodIssueCode.invalid_union,
|
50178
|
+
unionErrors
|
50179
|
+
});
|
50180
|
+
return INVALID;
|
50181
|
+
}
|
50182
|
+
}
|
50183
|
+
get options() {
|
50184
|
+
return this._def.options;
|
50185
|
+
}
|
50186
|
+
};
|
50187
|
+
__name(ZodUnion, "ZodUnion");
|
50188
|
+
ZodUnion.create = (types, params) => {
|
50189
|
+
return new ZodUnion(__spreadValues({
|
50190
|
+
options: types,
|
50191
|
+
typeName: ZodFirstPartyTypeKind.ZodUnion
|
50192
|
+
}, processCreateParams(params)));
|
50193
|
+
};
|
50194
|
+
var ZodDiscriminatedUnion = class extends ZodType {
|
50195
|
+
_parse(input) {
|
50196
|
+
const { ctx } = this._processInputParams(input);
|
50197
|
+
if (ctx.parsedType !== ZodParsedType.object) {
|
50198
|
+
addIssueToContext(ctx, {
|
50199
|
+
code: ZodIssueCode.invalid_type,
|
50200
|
+
expected: ZodParsedType.object,
|
50201
|
+
received: ctx.parsedType
|
50202
|
+
});
|
50203
|
+
return INVALID;
|
50204
|
+
}
|
50205
|
+
const discriminator = this.discriminator;
|
50206
|
+
const discriminatorValue = ctx.data[discriminator];
|
50207
|
+
const option = this.options.get(discriminatorValue);
|
50208
|
+
if (!option) {
|
50209
|
+
addIssueToContext(ctx, {
|
50210
|
+
code: ZodIssueCode.invalid_union_discriminator,
|
50211
|
+
options: this.validDiscriminatorValues,
|
50212
|
+
path: [discriminator]
|
50213
|
+
});
|
50214
|
+
return INVALID;
|
50215
|
+
}
|
50216
|
+
if (ctx.common.async) {
|
50217
|
+
return option._parseAsync({
|
50218
|
+
data: ctx.data,
|
50219
|
+
path: ctx.path,
|
50220
|
+
parent: ctx
|
50221
|
+
});
|
50222
|
+
} else {
|
50223
|
+
return option._parseSync({
|
50224
|
+
data: ctx.data,
|
50225
|
+
path: ctx.path,
|
50226
|
+
parent: ctx
|
50227
|
+
});
|
50228
|
+
}
|
50229
|
+
}
|
50230
|
+
get discriminator() {
|
50231
|
+
return this._def.discriminator;
|
50232
|
+
}
|
50233
|
+
get validDiscriminatorValues() {
|
50234
|
+
return Array.from(this.options.keys());
|
50235
|
+
}
|
50236
|
+
get options() {
|
50237
|
+
return this._def.options;
|
50238
|
+
}
|
50239
|
+
static create(discriminator, types, params) {
|
50240
|
+
const options = /* @__PURE__ */ new Map();
|
50241
|
+
try {
|
50242
|
+
types.forEach((type) => {
|
50243
|
+
const discriminatorValue = type.shape[discriminator].value;
|
50244
|
+
options.set(discriminatorValue, type);
|
50245
|
+
});
|
50246
|
+
} catch (e) {
|
50247
|
+
throw new Error("The discriminator value could not be extracted from all the provided schemas");
|
50248
|
+
}
|
50249
|
+
if (options.size !== types.length) {
|
50250
|
+
throw new Error("Some of the discriminator values are not unique");
|
50251
|
+
}
|
50252
|
+
return new ZodDiscriminatedUnion(__spreadValues({
|
50253
|
+
typeName: ZodFirstPartyTypeKind.ZodDiscriminatedUnion,
|
50254
|
+
discriminator,
|
50255
|
+
options
|
50256
|
+
}, processCreateParams(params)));
|
50257
|
+
}
|
50258
|
+
};
|
50259
|
+
__name(ZodDiscriminatedUnion, "ZodDiscriminatedUnion");
|
50260
|
+
function mergeValues(a, b) {
|
50261
|
+
const aType = getParsedType(a);
|
50262
|
+
const bType = getParsedType(b);
|
50263
|
+
if (a === b) {
|
50264
|
+
return { valid: true, data: a };
|
50265
|
+
} else if (aType === ZodParsedType.object && bType === ZodParsedType.object) {
|
50266
|
+
const bKeys = util.objectKeys(b);
|
50267
|
+
const sharedKeys = util.objectKeys(a).filter((key2) => bKeys.indexOf(key2) !== -1);
|
50268
|
+
const newObj = __spreadValues(__spreadValues({}, a), b);
|
50269
|
+
for (const key2 of sharedKeys) {
|
50270
|
+
const sharedValue = mergeValues(a[key2], b[key2]);
|
50271
|
+
if (!sharedValue.valid) {
|
50272
|
+
return { valid: false };
|
50273
|
+
}
|
50274
|
+
newObj[key2] = sharedValue.data;
|
50275
|
+
}
|
50276
|
+
return { valid: true, data: newObj };
|
50277
|
+
} else if (aType === ZodParsedType.array && bType === ZodParsedType.array) {
|
50278
|
+
if (a.length !== b.length) {
|
50279
|
+
return { valid: false };
|
50280
|
+
}
|
50281
|
+
const newArray = [];
|
50282
|
+
for (let index = 0; index < a.length; index++) {
|
50283
|
+
const itemA = a[index];
|
50284
|
+
const itemB = b[index];
|
50285
|
+
const sharedValue = mergeValues(itemA, itemB);
|
50286
|
+
if (!sharedValue.valid) {
|
50287
|
+
return { valid: false };
|
50288
|
+
}
|
50289
|
+
newArray.push(sharedValue.data);
|
50290
|
+
}
|
50291
|
+
return { valid: true, data: newArray };
|
50292
|
+
} else if (aType === ZodParsedType.date && bType === ZodParsedType.date && +a === +b) {
|
50293
|
+
return { valid: true, data: a };
|
50294
|
+
} else {
|
50295
|
+
return { valid: false };
|
50296
|
+
}
|
50297
|
+
}
|
50298
|
+
__name(mergeValues, "mergeValues");
|
50299
|
+
var ZodIntersection = class extends ZodType {
|
50300
|
+
_parse(input) {
|
50301
|
+
const { status, ctx } = this._processInputParams(input);
|
50302
|
+
const handleParsed = /* @__PURE__ */ __name((parsedLeft, parsedRight) => {
|
50303
|
+
if (isAborted(parsedLeft) || isAborted(parsedRight)) {
|
50304
|
+
return INVALID;
|
50305
|
+
}
|
50306
|
+
const merged = mergeValues(parsedLeft.value, parsedRight.value);
|
50307
|
+
if (!merged.valid) {
|
50308
|
+
addIssueToContext(ctx, {
|
50309
|
+
code: ZodIssueCode.invalid_intersection_types
|
50310
|
+
});
|
50311
|
+
return INVALID;
|
50312
|
+
}
|
50313
|
+
if (isDirty(parsedLeft) || isDirty(parsedRight)) {
|
50314
|
+
status.dirty();
|
50315
|
+
}
|
50316
|
+
return { status: status.value, value: merged.data };
|
50317
|
+
}, "handleParsed");
|
50318
|
+
if (ctx.common.async) {
|
50319
|
+
return Promise.all([
|
50320
|
+
this._def.left._parseAsync({
|
50321
|
+
data: ctx.data,
|
50322
|
+
path: ctx.path,
|
50323
|
+
parent: ctx
|
50324
|
+
}),
|
50325
|
+
this._def.right._parseAsync({
|
50326
|
+
data: ctx.data,
|
50327
|
+
path: ctx.path,
|
50328
|
+
parent: ctx
|
50329
|
+
})
|
50330
|
+
]).then(([left, right]) => handleParsed(left, right));
|
50331
|
+
} else {
|
50332
|
+
return handleParsed(this._def.left._parseSync({
|
50333
|
+
data: ctx.data,
|
50334
|
+
path: ctx.path,
|
50335
|
+
parent: ctx
|
50336
|
+
}), this._def.right._parseSync({
|
50337
|
+
data: ctx.data,
|
50338
|
+
path: ctx.path,
|
50339
|
+
parent: ctx
|
50340
|
+
}));
|
50341
|
+
}
|
50342
|
+
}
|
50343
|
+
};
|
50344
|
+
__name(ZodIntersection, "ZodIntersection");
|
50345
|
+
ZodIntersection.create = (left, right, params) => {
|
50346
|
+
return new ZodIntersection(__spreadValues({
|
50347
|
+
left,
|
50348
|
+
right,
|
50349
|
+
typeName: ZodFirstPartyTypeKind.ZodIntersection
|
50350
|
+
}, processCreateParams(params)));
|
50351
|
+
};
|
50352
|
+
var ZodTuple = class extends ZodType {
|
50353
|
+
_parse(input) {
|
50354
|
+
const { status, ctx } = this._processInputParams(input);
|
50355
|
+
if (ctx.parsedType !== ZodParsedType.array) {
|
50356
|
+
addIssueToContext(ctx, {
|
50357
|
+
code: ZodIssueCode.invalid_type,
|
50358
|
+
expected: ZodParsedType.array,
|
50359
|
+
received: ctx.parsedType
|
50360
|
+
});
|
50361
|
+
return INVALID;
|
50362
|
+
}
|
50363
|
+
if (ctx.data.length < this._def.items.length) {
|
50364
|
+
addIssueToContext(ctx, {
|
50365
|
+
code: ZodIssueCode.too_small,
|
50366
|
+
minimum: this._def.items.length,
|
50367
|
+
inclusive: true,
|
50368
|
+
type: "array"
|
50369
|
+
});
|
50370
|
+
return INVALID;
|
50371
|
+
}
|
50372
|
+
const rest = this._def.rest;
|
50373
|
+
if (!rest && ctx.data.length > this._def.items.length) {
|
50374
|
+
addIssueToContext(ctx, {
|
50375
|
+
code: ZodIssueCode.too_big,
|
50376
|
+
maximum: this._def.items.length,
|
50377
|
+
inclusive: true,
|
50378
|
+
type: "array"
|
50379
|
+
});
|
50380
|
+
status.dirty();
|
50381
|
+
}
|
50382
|
+
const items = ctx.data.map((item, itemIndex) => {
|
50383
|
+
const schema = this._def.items[itemIndex] || this._def.rest;
|
50384
|
+
if (!schema)
|
50385
|
+
return null;
|
50386
|
+
return schema._parse(new ParseInputLazyPath(ctx, item, ctx.path, itemIndex));
|
50387
|
+
}).filter((x) => !!x);
|
50388
|
+
if (ctx.common.async) {
|
50389
|
+
return Promise.all(items).then((results) => {
|
50390
|
+
return ParseStatus.mergeArray(status, results);
|
50391
|
+
});
|
50392
|
+
} else {
|
50393
|
+
return ParseStatus.mergeArray(status, items);
|
50394
|
+
}
|
50395
|
+
}
|
50396
|
+
get items() {
|
50397
|
+
return this._def.items;
|
50398
|
+
}
|
50399
|
+
rest(rest) {
|
50400
|
+
return new ZodTuple(__spreadProps(__spreadValues({}, this._def), {
|
50401
|
+
rest
|
50402
|
+
}));
|
50403
|
+
}
|
50404
|
+
};
|
50405
|
+
__name(ZodTuple, "ZodTuple");
|
50406
|
+
ZodTuple.create = (schemas, params) => {
|
50407
|
+
return new ZodTuple(__spreadValues({
|
50408
|
+
items: schemas,
|
50409
|
+
typeName: ZodFirstPartyTypeKind.ZodTuple,
|
50410
|
+
rest: null
|
50411
|
+
}, processCreateParams(params)));
|
50412
|
+
};
|
50413
|
+
var ZodRecord = class extends ZodType {
|
50414
|
+
get keySchema() {
|
50415
|
+
return this._def.keyType;
|
50416
|
+
}
|
50417
|
+
get valueSchema() {
|
50418
|
+
return this._def.valueType;
|
50419
|
+
}
|
50420
|
+
_parse(input) {
|
50421
|
+
const { status, ctx } = this._processInputParams(input);
|
50422
|
+
if (ctx.parsedType !== ZodParsedType.object) {
|
50423
|
+
addIssueToContext(ctx, {
|
50424
|
+
code: ZodIssueCode.invalid_type,
|
50425
|
+
expected: ZodParsedType.object,
|
50426
|
+
received: ctx.parsedType
|
50427
|
+
});
|
50428
|
+
return INVALID;
|
50429
|
+
}
|
50430
|
+
const pairs = [];
|
50431
|
+
const keyType = this._def.keyType;
|
50432
|
+
const valueType = this._def.valueType;
|
50433
|
+
for (const key2 in ctx.data) {
|
50434
|
+
pairs.push({
|
50435
|
+
key: keyType._parse(new ParseInputLazyPath(ctx, key2, ctx.path, key2)),
|
50436
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, ctx.data[key2], ctx.path, key2))
|
50437
|
+
});
|
50438
|
+
}
|
50439
|
+
if (ctx.common.async) {
|
50440
|
+
return ParseStatus.mergeObjectAsync(status, pairs);
|
50441
|
+
} else {
|
50442
|
+
return ParseStatus.mergeObjectSync(status, pairs);
|
50443
|
+
}
|
50444
|
+
}
|
50445
|
+
get element() {
|
50446
|
+
return this._def.valueType;
|
50447
|
+
}
|
50448
|
+
static create(first2, second, third) {
|
50449
|
+
if (second instanceof ZodType) {
|
50450
|
+
return new ZodRecord(__spreadValues({
|
50451
|
+
keyType: first2,
|
50452
|
+
valueType: second,
|
50453
|
+
typeName: ZodFirstPartyTypeKind.ZodRecord
|
50454
|
+
}, processCreateParams(third)));
|
50455
|
+
}
|
50456
|
+
return new ZodRecord(__spreadValues({
|
50457
|
+
keyType: ZodString.create(),
|
50458
|
+
valueType: first2,
|
50459
|
+
typeName: ZodFirstPartyTypeKind.ZodRecord
|
50460
|
+
}, processCreateParams(second)));
|
50461
|
+
}
|
50462
|
+
};
|
50463
|
+
__name(ZodRecord, "ZodRecord");
|
50464
|
+
var ZodMap = class extends ZodType {
|
50465
|
+
_parse(input) {
|
50466
|
+
const { status, ctx } = this._processInputParams(input);
|
50467
|
+
if (ctx.parsedType !== ZodParsedType.map) {
|
50468
|
+
addIssueToContext(ctx, {
|
50469
|
+
code: ZodIssueCode.invalid_type,
|
50470
|
+
expected: ZodParsedType.map,
|
50471
|
+
received: ctx.parsedType
|
50472
|
+
});
|
50473
|
+
return INVALID;
|
50474
|
+
}
|
50475
|
+
const keyType = this._def.keyType;
|
50476
|
+
const valueType = this._def.valueType;
|
50477
|
+
const pairs = [...ctx.data.entries()].map(([key2, value], index) => {
|
50478
|
+
return {
|
50479
|
+
key: keyType._parse(new ParseInputLazyPath(ctx, key2, ctx.path, [index, "key"])),
|
50480
|
+
value: valueType._parse(new ParseInputLazyPath(ctx, value, ctx.path, [index, "value"]))
|
50481
|
+
};
|
50482
|
+
});
|
50483
|
+
if (ctx.common.async) {
|
50484
|
+
const finalMap = /* @__PURE__ */ new Map();
|
50485
|
+
return Promise.resolve().then(() => __async(this, null, function* () {
|
50486
|
+
for (const pair of pairs) {
|
50487
|
+
const key2 = yield pair.key;
|
50488
|
+
const value = yield pair.value;
|
50489
|
+
if (key2.status === "aborted" || value.status === "aborted") {
|
50490
|
+
return INVALID;
|
50491
|
+
}
|
50492
|
+
if (key2.status === "dirty" || value.status === "dirty") {
|
50493
|
+
status.dirty();
|
50494
|
+
}
|
50495
|
+
finalMap.set(key2.value, value.value);
|
50496
|
+
}
|
50497
|
+
return { status: status.value, value: finalMap };
|
50498
|
+
}));
|
50499
|
+
} else {
|
50500
|
+
const finalMap = /* @__PURE__ */ new Map();
|
50501
|
+
for (const pair of pairs) {
|
50502
|
+
const key2 = pair.key;
|
50503
|
+
const value = pair.value;
|
50504
|
+
if (key2.status === "aborted" || value.status === "aborted") {
|
50505
|
+
return INVALID;
|
50506
|
+
}
|
50507
|
+
if (key2.status === "dirty" || value.status === "dirty") {
|
50508
|
+
status.dirty();
|
50509
|
+
}
|
50510
|
+
finalMap.set(key2.value, value.value);
|
50511
|
+
}
|
50512
|
+
return { status: status.value, value: finalMap };
|
50513
|
+
}
|
50514
|
+
}
|
50515
|
+
};
|
50516
|
+
__name(ZodMap, "ZodMap");
|
50517
|
+
ZodMap.create = (keyType, valueType, params) => {
|
50518
|
+
return new ZodMap(__spreadValues({
|
50519
|
+
valueType,
|
50520
|
+
keyType,
|
50521
|
+
typeName: ZodFirstPartyTypeKind.ZodMap
|
50522
|
+
}, processCreateParams(params)));
|
50523
|
+
};
|
50524
|
+
var ZodSet = class extends ZodType {
|
50525
|
+
_parse(input) {
|
50526
|
+
const { status, ctx } = this._processInputParams(input);
|
50527
|
+
if (ctx.parsedType !== ZodParsedType.set) {
|
50528
|
+
addIssueToContext(ctx, {
|
50529
|
+
code: ZodIssueCode.invalid_type,
|
50530
|
+
expected: ZodParsedType.set,
|
50531
|
+
received: ctx.parsedType
|
50532
|
+
});
|
50533
|
+
return INVALID;
|
50534
|
+
}
|
50535
|
+
const def = this._def;
|
50536
|
+
if (def.minSize !== null) {
|
50537
|
+
if (ctx.data.size < def.minSize.value) {
|
50538
|
+
addIssueToContext(ctx, {
|
50539
|
+
code: ZodIssueCode.too_small,
|
50540
|
+
minimum: def.minSize.value,
|
50541
|
+
type: "set",
|
50542
|
+
inclusive: true,
|
50543
|
+
message: def.minSize.message
|
50544
|
+
});
|
50545
|
+
status.dirty();
|
50546
|
+
}
|
50547
|
+
}
|
50548
|
+
if (def.maxSize !== null) {
|
50549
|
+
if (ctx.data.size > def.maxSize.value) {
|
50550
|
+
addIssueToContext(ctx, {
|
50551
|
+
code: ZodIssueCode.too_big,
|
50552
|
+
maximum: def.maxSize.value,
|
50553
|
+
type: "set",
|
50554
|
+
inclusive: true,
|
50555
|
+
message: def.maxSize.message
|
50556
|
+
});
|
50557
|
+
status.dirty();
|
50558
|
+
}
|
50559
|
+
}
|
50560
|
+
const valueType = this._def.valueType;
|
50561
|
+
function finalizeSet(elements2) {
|
50562
|
+
const parsedSet = /* @__PURE__ */ new Set();
|
50563
|
+
for (const element of elements2) {
|
50564
|
+
if (element.status === "aborted")
|
50565
|
+
return INVALID;
|
50566
|
+
if (element.status === "dirty")
|
50567
|
+
status.dirty();
|
50568
|
+
parsedSet.add(element.value);
|
50569
|
+
}
|
50570
|
+
return { status: status.value, value: parsedSet };
|
50571
|
+
}
|
50572
|
+
__name(finalizeSet, "finalizeSet");
|
50573
|
+
const elements = [...ctx.data.values()].map((item, i) => valueType._parse(new ParseInputLazyPath(ctx, item, ctx.path, i)));
|
50574
|
+
if (ctx.common.async) {
|
50575
|
+
return Promise.all(elements).then((elements2) => finalizeSet(elements2));
|
50576
|
+
} else {
|
50577
|
+
return finalizeSet(elements);
|
50578
|
+
}
|
50579
|
+
}
|
50580
|
+
min(minSize, message) {
|
50581
|
+
return new ZodSet(__spreadProps(__spreadValues({}, this._def), {
|
50582
|
+
minSize: { value: minSize, message: errorUtil.toString(message) }
|
50583
|
+
}));
|
50584
|
+
}
|
50585
|
+
max(maxSize, message) {
|
50586
|
+
return new ZodSet(__spreadProps(__spreadValues({}, this._def), {
|
50587
|
+
maxSize: { value: maxSize, message: errorUtil.toString(message) }
|
50588
|
+
}));
|
50589
|
+
}
|
50590
|
+
size(size, message) {
|
50591
|
+
return this.min(size, message).max(size, message);
|
50592
|
+
}
|
50593
|
+
nonempty(message) {
|
50594
|
+
return this.min(1, message);
|
50595
|
+
}
|
50596
|
+
};
|
50597
|
+
__name(ZodSet, "ZodSet");
|
50598
|
+
ZodSet.create = (valueType, params) => {
|
50599
|
+
return new ZodSet(__spreadValues({
|
50600
|
+
valueType,
|
50601
|
+
minSize: null,
|
50602
|
+
maxSize: null,
|
50603
|
+
typeName: ZodFirstPartyTypeKind.ZodSet
|
50604
|
+
}, processCreateParams(params)));
|
50605
|
+
};
|
50606
|
+
var ZodFunction = class extends ZodType {
|
50607
|
+
constructor() {
|
50608
|
+
super(...arguments);
|
50609
|
+
this.validate = this.implement;
|
50610
|
+
}
|
50611
|
+
_parse(input) {
|
50612
|
+
const { ctx } = this._processInputParams(input);
|
50613
|
+
if (ctx.parsedType !== ZodParsedType.function) {
|
50614
|
+
addIssueToContext(ctx, {
|
50615
|
+
code: ZodIssueCode.invalid_type,
|
50616
|
+
expected: ZodParsedType.function,
|
50617
|
+
received: ctx.parsedType
|
50618
|
+
});
|
50619
|
+
return INVALID;
|
50620
|
+
}
|
50621
|
+
function makeArgsIssue(args, error) {
|
50622
|
+
return makeIssue({
|
50623
|
+
data: args,
|
50624
|
+
path: ctx.path,
|
50625
|
+
errorMaps: [
|
50626
|
+
ctx.common.contextualErrorMap,
|
50627
|
+
ctx.schemaErrorMap,
|
50628
|
+
overrideErrorMap,
|
50629
|
+
defaultErrorMap
|
50630
|
+
].filter((x) => !!x),
|
50631
|
+
issueData: {
|
50632
|
+
code: ZodIssueCode.invalid_arguments,
|
50633
|
+
argumentsError: error
|
50634
|
+
}
|
50635
|
+
});
|
50636
|
+
}
|
50637
|
+
__name(makeArgsIssue, "makeArgsIssue");
|
50638
|
+
function makeReturnsIssue(returns, error) {
|
50639
|
+
return makeIssue({
|
50640
|
+
data: returns,
|
50641
|
+
path: ctx.path,
|
50642
|
+
errorMaps: [
|
50643
|
+
ctx.common.contextualErrorMap,
|
50644
|
+
ctx.schemaErrorMap,
|
50645
|
+
overrideErrorMap,
|
50646
|
+
defaultErrorMap
|
50647
|
+
].filter((x) => !!x),
|
50648
|
+
issueData: {
|
50649
|
+
code: ZodIssueCode.invalid_return_type,
|
50650
|
+
returnTypeError: error
|
50651
|
+
}
|
50652
|
+
});
|
50653
|
+
}
|
50654
|
+
__name(makeReturnsIssue, "makeReturnsIssue");
|
50655
|
+
const params = { errorMap: ctx.common.contextualErrorMap };
|
50656
|
+
const fn = ctx.data;
|
50657
|
+
if (this._def.returns instanceof ZodPromise) {
|
50658
|
+
return OK((...args) => __async(this, null, function* () {
|
50659
|
+
const error = new ZodError([]);
|
50660
|
+
const parsedArgs = yield this._def.args.parseAsync(args, params).catch((e) => {
|
50661
|
+
error.addIssue(makeArgsIssue(args, e));
|
50662
|
+
throw error;
|
50663
|
+
});
|
50664
|
+
const result = yield fn(...parsedArgs);
|
50665
|
+
const parsedReturns = yield this._def.returns._def.type.parseAsync(result, params).catch((e) => {
|
50666
|
+
error.addIssue(makeReturnsIssue(result, e));
|
50667
|
+
throw error;
|
50668
|
+
});
|
50669
|
+
return parsedReturns;
|
50670
|
+
}));
|
50671
|
+
} else {
|
50672
|
+
return OK((...args) => {
|
50673
|
+
const parsedArgs = this._def.args.safeParse(args, params);
|
50674
|
+
if (!parsedArgs.success) {
|
50675
|
+
throw new ZodError([makeArgsIssue(args, parsedArgs.error)]);
|
50676
|
+
}
|
50677
|
+
const result = fn(...parsedArgs.data);
|
50678
|
+
const parsedReturns = this._def.returns.safeParse(result, params);
|
50679
|
+
if (!parsedReturns.success) {
|
50680
|
+
throw new ZodError([makeReturnsIssue(result, parsedReturns.error)]);
|
50681
|
+
}
|
50682
|
+
return parsedReturns.data;
|
50683
|
+
});
|
50684
|
+
}
|
50685
|
+
}
|
50686
|
+
parameters() {
|
50687
|
+
return this._def.args;
|
50688
|
+
}
|
50689
|
+
returnType() {
|
50690
|
+
return this._def.returns;
|
50691
|
+
}
|
50692
|
+
args(...items) {
|
50693
|
+
return new ZodFunction(__spreadProps(__spreadValues({}, this._def), {
|
50694
|
+
args: ZodTuple.create(items).rest(ZodUnknown.create())
|
50695
|
+
}));
|
50696
|
+
}
|
50697
|
+
returns(returnType) {
|
50698
|
+
return new ZodFunction(__spreadProps(__spreadValues({}, this._def), {
|
50699
|
+
returns: returnType
|
50700
|
+
}));
|
50701
|
+
}
|
50702
|
+
implement(func) {
|
50703
|
+
const validatedFunc = this.parse(func);
|
50704
|
+
return validatedFunc;
|
50705
|
+
}
|
50706
|
+
strictImplement(func) {
|
50707
|
+
const validatedFunc = this.parse(func);
|
50708
|
+
return validatedFunc;
|
50709
|
+
}
|
50710
|
+
};
|
50711
|
+
__name(ZodFunction, "ZodFunction");
|
50712
|
+
ZodFunction.create = (args, returns, params) => {
|
50713
|
+
return new ZodFunction(__spreadValues({
|
50714
|
+
args: args ? args.rest(ZodUnknown.create()) : ZodTuple.create([]).rest(ZodUnknown.create()),
|
50715
|
+
returns: returns || ZodUnknown.create(),
|
50716
|
+
typeName: ZodFirstPartyTypeKind.ZodFunction
|
50717
|
+
}, processCreateParams(params)));
|
50718
|
+
};
|
50719
|
+
var ZodLazy = class extends ZodType {
|
50720
|
+
get schema() {
|
50721
|
+
return this._def.getter();
|
50722
|
+
}
|
50723
|
+
_parse(input) {
|
50724
|
+
const { ctx } = this._processInputParams(input);
|
50725
|
+
const lazySchema = this._def.getter();
|
50726
|
+
return lazySchema._parse({ data: ctx.data, path: ctx.path, parent: ctx });
|
50727
|
+
}
|
50728
|
+
};
|
50729
|
+
__name(ZodLazy, "ZodLazy");
|
50730
|
+
ZodLazy.create = (getter, params) => {
|
50731
|
+
return new ZodLazy(__spreadValues({
|
50732
|
+
getter,
|
50733
|
+
typeName: ZodFirstPartyTypeKind.ZodLazy
|
50734
|
+
}, processCreateParams(params)));
|
50735
|
+
};
|
50736
|
+
var ZodLiteral = class extends ZodType {
|
50737
|
+
_parse(input) {
|
50738
|
+
if (input.data !== this._def.value) {
|
50739
|
+
const ctx = this._getOrReturnCtx(input);
|
50740
|
+
addIssueToContext(ctx, {
|
50741
|
+
code: ZodIssueCode.invalid_literal,
|
50742
|
+
expected: this._def.value
|
50743
|
+
});
|
50744
|
+
return INVALID;
|
50745
|
+
}
|
50746
|
+
return { status: "valid", value: input.data };
|
50747
|
+
}
|
50748
|
+
get value() {
|
50749
|
+
return this._def.value;
|
50750
|
+
}
|
50751
|
+
};
|
50752
|
+
__name(ZodLiteral, "ZodLiteral");
|
50753
|
+
ZodLiteral.create = (value, params) => {
|
50754
|
+
return new ZodLiteral(__spreadValues({
|
50755
|
+
value,
|
50756
|
+
typeName: ZodFirstPartyTypeKind.ZodLiteral
|
50757
|
+
}, processCreateParams(params)));
|
50758
|
+
};
|
50759
|
+
function createZodEnum(values, params) {
|
50760
|
+
return new ZodEnum(__spreadValues({
|
50761
|
+
values,
|
50762
|
+
typeName: ZodFirstPartyTypeKind.ZodEnum
|
50763
|
+
}, processCreateParams(params)));
|
50764
|
+
}
|
50765
|
+
__name(createZodEnum, "createZodEnum");
|
50766
|
+
var ZodEnum = class extends ZodType {
|
50767
|
+
_parse(input) {
|
50768
|
+
if (typeof input.data !== "string") {
|
50769
|
+
const ctx = this._getOrReturnCtx(input);
|
50770
|
+
const expectedValues = this._def.values;
|
50771
|
+
addIssueToContext(ctx, {
|
50772
|
+
expected: util.joinValues(expectedValues),
|
50773
|
+
received: ctx.parsedType,
|
50774
|
+
code: ZodIssueCode.invalid_type
|
50775
|
+
});
|
50776
|
+
return INVALID;
|
50777
|
+
}
|
50778
|
+
if (this._def.values.indexOf(input.data) === -1) {
|
50779
|
+
const ctx = this._getOrReturnCtx(input);
|
50780
|
+
const expectedValues = this._def.values;
|
50781
|
+
addIssueToContext(ctx, {
|
50782
|
+
received: ctx.data,
|
50783
|
+
code: ZodIssueCode.invalid_enum_value,
|
50784
|
+
options: expectedValues
|
50785
|
+
});
|
50786
|
+
return INVALID;
|
50787
|
+
}
|
50788
|
+
return OK(input.data);
|
50789
|
+
}
|
50790
|
+
get options() {
|
50791
|
+
return this._def.values;
|
50792
|
+
}
|
50793
|
+
get enum() {
|
50794
|
+
const enumValues = {};
|
50795
|
+
for (const val of this._def.values) {
|
50796
|
+
enumValues[val] = val;
|
50797
|
+
}
|
50798
|
+
return enumValues;
|
50799
|
+
}
|
50800
|
+
get Values() {
|
50801
|
+
const enumValues = {};
|
50802
|
+
for (const val of this._def.values) {
|
50803
|
+
enumValues[val] = val;
|
50804
|
+
}
|
50805
|
+
return enumValues;
|
50806
|
+
}
|
50807
|
+
get Enum() {
|
50808
|
+
const enumValues = {};
|
50809
|
+
for (const val of this._def.values) {
|
50810
|
+
enumValues[val] = val;
|
50811
|
+
}
|
50812
|
+
return enumValues;
|
50813
|
+
}
|
50814
|
+
};
|
50815
|
+
__name(ZodEnum, "ZodEnum");
|
50816
|
+
ZodEnum.create = createZodEnum;
|
50817
|
+
var ZodNativeEnum = class extends ZodType {
|
50818
|
+
_parse(input) {
|
50819
|
+
const nativeEnumValues = util.getValidEnumValues(this._def.values);
|
50820
|
+
const ctx = this._getOrReturnCtx(input);
|
50821
|
+
if (ctx.parsedType !== ZodParsedType.string && ctx.parsedType !== ZodParsedType.number) {
|
50822
|
+
const expectedValues = util.objectValues(nativeEnumValues);
|
50823
|
+
addIssueToContext(ctx, {
|
50824
|
+
expected: util.joinValues(expectedValues),
|
50825
|
+
received: ctx.parsedType,
|
50826
|
+
code: ZodIssueCode.invalid_type
|
50827
|
+
});
|
50828
|
+
return INVALID;
|
50829
|
+
}
|
50830
|
+
if (nativeEnumValues.indexOf(input.data) === -1) {
|
50831
|
+
const expectedValues = util.objectValues(nativeEnumValues);
|
50832
|
+
addIssueToContext(ctx, {
|
50833
|
+
received: ctx.data,
|
50834
|
+
code: ZodIssueCode.invalid_enum_value,
|
50835
|
+
options: expectedValues
|
50836
|
+
});
|
50837
|
+
return INVALID;
|
50838
|
+
}
|
50839
|
+
return OK(input.data);
|
50840
|
+
}
|
50841
|
+
get enum() {
|
50842
|
+
return this._def.values;
|
50843
|
+
}
|
50844
|
+
};
|
50845
|
+
__name(ZodNativeEnum, "ZodNativeEnum");
|
50846
|
+
ZodNativeEnum.create = (values, params) => {
|
50847
|
+
return new ZodNativeEnum(__spreadValues({
|
50848
|
+
values,
|
50849
|
+
typeName: ZodFirstPartyTypeKind.ZodNativeEnum
|
50850
|
+
}, processCreateParams(params)));
|
50851
|
+
};
|
50852
|
+
var ZodPromise = class extends ZodType {
|
50853
|
+
_parse(input) {
|
50854
|
+
const { ctx } = this._processInputParams(input);
|
50855
|
+
if (ctx.parsedType !== ZodParsedType.promise && ctx.common.async === false) {
|
50856
|
+
addIssueToContext(ctx, {
|
50857
|
+
code: ZodIssueCode.invalid_type,
|
50858
|
+
expected: ZodParsedType.promise,
|
50859
|
+
received: ctx.parsedType
|
50860
|
+
});
|
50861
|
+
return INVALID;
|
50862
|
+
}
|
50863
|
+
const promisified = ctx.parsedType === ZodParsedType.promise ? ctx.data : Promise.resolve(ctx.data);
|
50864
|
+
return OK(promisified.then((data) => {
|
50865
|
+
return this._def.type.parseAsync(data, {
|
50866
|
+
path: ctx.path,
|
50867
|
+
errorMap: ctx.common.contextualErrorMap
|
50868
|
+
});
|
50869
|
+
}));
|
50870
|
+
}
|
50871
|
+
};
|
50872
|
+
__name(ZodPromise, "ZodPromise");
|
50873
|
+
ZodPromise.create = (schema, params) => {
|
50874
|
+
return new ZodPromise(__spreadValues({
|
50875
|
+
type: schema,
|
50876
|
+
typeName: ZodFirstPartyTypeKind.ZodPromise
|
50877
|
+
}, processCreateParams(params)));
|
50878
|
+
};
|
50879
|
+
var ZodEffects = class extends ZodType {
|
50880
|
+
innerType() {
|
50881
|
+
return this._def.schema;
|
50882
|
+
}
|
50883
|
+
_parse(input) {
|
50884
|
+
const { status, ctx } = this._processInputParams(input);
|
50885
|
+
const effect = this._def.effect || null;
|
50886
|
+
if (effect.type === "preprocess") {
|
50887
|
+
const processed = effect.transform(ctx.data);
|
50888
|
+
if (ctx.common.async) {
|
50889
|
+
return Promise.resolve(processed).then((processed2) => {
|
50890
|
+
return this._def.schema._parseAsync({
|
50891
|
+
data: processed2,
|
50892
|
+
path: ctx.path,
|
50893
|
+
parent: ctx
|
50894
|
+
});
|
50895
|
+
});
|
50896
|
+
} else {
|
50897
|
+
return this._def.schema._parseSync({
|
50898
|
+
data: processed,
|
50899
|
+
path: ctx.path,
|
50900
|
+
parent: ctx
|
50901
|
+
});
|
50902
|
+
}
|
50903
|
+
}
|
50904
|
+
const checkCtx = {
|
50905
|
+
addIssue: (arg) => {
|
50906
|
+
addIssueToContext(ctx, arg);
|
50907
|
+
if (arg.fatal) {
|
50908
|
+
status.abort();
|
50909
|
+
} else {
|
50910
|
+
status.dirty();
|
50911
|
+
}
|
50912
|
+
},
|
50913
|
+
get path() {
|
50914
|
+
return ctx.path;
|
50915
|
+
}
|
50916
|
+
};
|
50917
|
+
checkCtx.addIssue = checkCtx.addIssue.bind(checkCtx);
|
50918
|
+
if (effect.type === "refinement") {
|
50919
|
+
const executeRefinement = /* @__PURE__ */ __name((acc) => {
|
50920
|
+
const result = effect.refinement(acc, checkCtx);
|
50921
|
+
if (ctx.common.async) {
|
50922
|
+
return Promise.resolve(result);
|
50923
|
+
}
|
50924
|
+
if (result instanceof Promise) {
|
50925
|
+
throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
50926
|
+
}
|
50927
|
+
return acc;
|
50928
|
+
}, "executeRefinement");
|
50929
|
+
if (ctx.common.async === false) {
|
50930
|
+
const inner = this._def.schema._parseSync({
|
50931
|
+
data: ctx.data,
|
50932
|
+
path: ctx.path,
|
50933
|
+
parent: ctx
|
50934
|
+
});
|
50935
|
+
if (inner.status === "aborted")
|
50936
|
+
return INVALID;
|
50937
|
+
if (inner.status === "dirty")
|
50938
|
+
status.dirty();
|
50939
|
+
executeRefinement(inner.value);
|
50940
|
+
return { status: status.value, value: inner.value };
|
50941
|
+
} else {
|
50942
|
+
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((inner) => {
|
50943
|
+
if (inner.status === "aborted")
|
50944
|
+
return INVALID;
|
50945
|
+
if (inner.status === "dirty")
|
50946
|
+
status.dirty();
|
50947
|
+
return executeRefinement(inner.value).then(() => {
|
50948
|
+
return { status: status.value, value: inner.value };
|
50949
|
+
});
|
50950
|
+
});
|
50951
|
+
}
|
50952
|
+
}
|
50953
|
+
if (effect.type === "transform") {
|
50954
|
+
if (ctx.common.async === false) {
|
50955
|
+
const base4 = this._def.schema._parseSync({
|
50956
|
+
data: ctx.data,
|
50957
|
+
path: ctx.path,
|
50958
|
+
parent: ctx
|
50959
|
+
});
|
50960
|
+
if (!isValid(base4))
|
50961
|
+
return base4;
|
50962
|
+
const result = effect.transform(base4.value, checkCtx);
|
50963
|
+
if (result instanceof Promise) {
|
50964
|
+
throw new Error(`Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.`);
|
50965
|
+
}
|
50966
|
+
return { status: status.value, value: result };
|
50967
|
+
} else {
|
50968
|
+
return this._def.schema._parseAsync({ data: ctx.data, path: ctx.path, parent: ctx }).then((base4) => {
|
50969
|
+
if (!isValid(base4))
|
50970
|
+
return base4;
|
50971
|
+
return Promise.resolve(effect.transform(base4.value, checkCtx)).then((result) => ({ status: status.value, value: result }));
|
50972
|
+
});
|
50973
|
+
}
|
50974
|
+
}
|
50975
|
+
util.assertNever(effect);
|
50976
|
+
}
|
50977
|
+
};
|
50978
|
+
__name(ZodEffects, "ZodEffects");
|
50979
|
+
ZodEffects.create = (schema, effect, params) => {
|
50980
|
+
return new ZodEffects(__spreadValues({
|
50981
|
+
schema,
|
50982
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects,
|
50983
|
+
effect
|
50984
|
+
}, processCreateParams(params)));
|
50985
|
+
};
|
50986
|
+
ZodEffects.createWithPreprocess = (preprocess, schema, params) => {
|
50987
|
+
return new ZodEffects(__spreadValues({
|
50988
|
+
schema,
|
50989
|
+
effect: { type: "preprocess", transform: preprocess },
|
50990
|
+
typeName: ZodFirstPartyTypeKind.ZodEffects
|
50991
|
+
}, processCreateParams(params)));
|
50992
|
+
};
|
50993
|
+
var ZodOptional = class extends ZodType {
|
50994
|
+
_parse(input) {
|
50995
|
+
const parsedType = this._getType(input);
|
50996
|
+
if (parsedType === ZodParsedType.undefined) {
|
50997
|
+
return OK(void 0);
|
50998
|
+
}
|
50999
|
+
return this._def.innerType._parse(input);
|
51000
|
+
}
|
51001
|
+
unwrap() {
|
51002
|
+
return this._def.innerType;
|
51003
|
+
}
|
51004
|
+
};
|
51005
|
+
__name(ZodOptional, "ZodOptional");
|
51006
|
+
ZodOptional.create = (type, params) => {
|
51007
|
+
return new ZodOptional(__spreadValues({
|
51008
|
+
innerType: type,
|
51009
|
+
typeName: ZodFirstPartyTypeKind.ZodOptional
|
51010
|
+
}, processCreateParams(params)));
|
51011
|
+
};
|
51012
|
+
var ZodNullable = class extends ZodType {
|
51013
|
+
_parse(input) {
|
51014
|
+
const parsedType = this._getType(input);
|
51015
|
+
if (parsedType === ZodParsedType.null) {
|
51016
|
+
return OK(null);
|
51017
|
+
}
|
51018
|
+
return this._def.innerType._parse(input);
|
51019
|
+
}
|
51020
|
+
unwrap() {
|
51021
|
+
return this._def.innerType;
|
51022
|
+
}
|
51023
|
+
};
|
51024
|
+
__name(ZodNullable, "ZodNullable");
|
51025
|
+
ZodNullable.create = (type, params) => {
|
51026
|
+
return new ZodNullable(__spreadValues({
|
51027
|
+
innerType: type,
|
51028
|
+
typeName: ZodFirstPartyTypeKind.ZodNullable
|
51029
|
+
}, processCreateParams(params)));
|
51030
|
+
};
|
51031
|
+
var ZodDefault = class extends ZodType {
|
51032
|
+
_parse(input) {
|
51033
|
+
const { ctx } = this._processInputParams(input);
|
51034
|
+
let data = ctx.data;
|
51035
|
+
if (ctx.parsedType === ZodParsedType.undefined) {
|
51036
|
+
data = this._def.defaultValue();
|
51037
|
+
}
|
51038
|
+
return this._def.innerType._parse({
|
51039
|
+
data,
|
51040
|
+
path: ctx.path,
|
51041
|
+
parent: ctx
|
51042
|
+
});
|
51043
|
+
}
|
51044
|
+
removeDefault() {
|
51045
|
+
return this._def.innerType;
|
51046
|
+
}
|
51047
|
+
};
|
51048
|
+
__name(ZodDefault, "ZodDefault");
|
51049
|
+
ZodDefault.create = (type, params) => {
|
51050
|
+
return new ZodOptional(__spreadValues({
|
51051
|
+
innerType: type,
|
51052
|
+
typeName: ZodFirstPartyTypeKind.ZodOptional
|
51053
|
+
}, processCreateParams(params)));
|
51054
|
+
};
|
51055
|
+
var ZodNaN = class extends ZodType {
|
51056
|
+
_parse(input) {
|
51057
|
+
const parsedType = this._getType(input);
|
51058
|
+
if (parsedType !== ZodParsedType.nan) {
|
51059
|
+
const ctx = this._getOrReturnCtx(input);
|
51060
|
+
addIssueToContext(ctx, {
|
51061
|
+
code: ZodIssueCode.invalid_type,
|
51062
|
+
expected: ZodParsedType.nan,
|
51063
|
+
received: ctx.parsedType
|
51064
|
+
});
|
51065
|
+
return INVALID;
|
51066
|
+
}
|
51067
|
+
return { status: "valid", value: input.data };
|
51068
|
+
}
|
51069
|
+
};
|
51070
|
+
__name(ZodNaN, "ZodNaN");
|
51071
|
+
ZodNaN.create = (params) => {
|
51072
|
+
return new ZodNaN(__spreadValues({
|
51073
|
+
typeName: ZodFirstPartyTypeKind.ZodNaN
|
51074
|
+
}, processCreateParams(params)));
|
51075
|
+
};
|
51076
|
+
var custom = /* @__PURE__ */ __name((check, params = {}, fatal) => {
|
51077
|
+
if (check)
|
51078
|
+
return ZodAny.create().superRefine((data, ctx) => {
|
51079
|
+
if (!check(data)) {
|
51080
|
+
const p = typeof params === "function" ? params(data) : params;
|
51081
|
+
const p2 = typeof p === "string" ? { message: p } : p;
|
51082
|
+
ctx.addIssue(__spreadProps(__spreadValues({ code: "custom" }, p2), { fatal }));
|
51083
|
+
}
|
51084
|
+
});
|
51085
|
+
return ZodAny.create();
|
51086
|
+
}, "custom");
|
51087
|
+
var late = {
|
51088
|
+
object: ZodObject.lazycreate
|
51089
|
+
};
|
51090
|
+
var ZodFirstPartyTypeKind;
|
51091
|
+
(function(ZodFirstPartyTypeKind2) {
|
51092
|
+
ZodFirstPartyTypeKind2["ZodString"] = "ZodString";
|
51093
|
+
ZodFirstPartyTypeKind2["ZodNumber"] = "ZodNumber";
|
51094
|
+
ZodFirstPartyTypeKind2["ZodNaN"] = "ZodNaN";
|
51095
|
+
ZodFirstPartyTypeKind2["ZodBigInt"] = "ZodBigInt";
|
51096
|
+
ZodFirstPartyTypeKind2["ZodBoolean"] = "ZodBoolean";
|
51097
|
+
ZodFirstPartyTypeKind2["ZodDate"] = "ZodDate";
|
51098
|
+
ZodFirstPartyTypeKind2["ZodUndefined"] = "ZodUndefined";
|
51099
|
+
ZodFirstPartyTypeKind2["ZodNull"] = "ZodNull";
|
51100
|
+
ZodFirstPartyTypeKind2["ZodAny"] = "ZodAny";
|
51101
|
+
ZodFirstPartyTypeKind2["ZodUnknown"] = "ZodUnknown";
|
51102
|
+
ZodFirstPartyTypeKind2["ZodNever"] = "ZodNever";
|
51103
|
+
ZodFirstPartyTypeKind2["ZodVoid"] = "ZodVoid";
|
51104
|
+
ZodFirstPartyTypeKind2["ZodArray"] = "ZodArray";
|
51105
|
+
ZodFirstPartyTypeKind2["ZodObject"] = "ZodObject";
|
51106
|
+
ZodFirstPartyTypeKind2["ZodUnion"] = "ZodUnion";
|
51107
|
+
ZodFirstPartyTypeKind2["ZodDiscriminatedUnion"] = "ZodDiscriminatedUnion";
|
51108
|
+
ZodFirstPartyTypeKind2["ZodIntersection"] = "ZodIntersection";
|
51109
|
+
ZodFirstPartyTypeKind2["ZodTuple"] = "ZodTuple";
|
51110
|
+
ZodFirstPartyTypeKind2["ZodRecord"] = "ZodRecord";
|
51111
|
+
ZodFirstPartyTypeKind2["ZodMap"] = "ZodMap";
|
51112
|
+
ZodFirstPartyTypeKind2["ZodSet"] = "ZodSet";
|
51113
|
+
ZodFirstPartyTypeKind2["ZodFunction"] = "ZodFunction";
|
51114
|
+
ZodFirstPartyTypeKind2["ZodLazy"] = "ZodLazy";
|
51115
|
+
ZodFirstPartyTypeKind2["ZodLiteral"] = "ZodLiteral";
|
51116
|
+
ZodFirstPartyTypeKind2["ZodEnum"] = "ZodEnum";
|
51117
|
+
ZodFirstPartyTypeKind2["ZodEffects"] = "ZodEffects";
|
51118
|
+
ZodFirstPartyTypeKind2["ZodNativeEnum"] = "ZodNativeEnum";
|
51119
|
+
ZodFirstPartyTypeKind2["ZodOptional"] = "ZodOptional";
|
51120
|
+
ZodFirstPartyTypeKind2["ZodNullable"] = "ZodNullable";
|
51121
|
+
ZodFirstPartyTypeKind2["ZodDefault"] = "ZodDefault";
|
51122
|
+
ZodFirstPartyTypeKind2["ZodPromise"] = "ZodPromise";
|
51123
|
+
})(ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {}));
|
51124
|
+
var instanceOfType = /* @__PURE__ */ __name((cls, params = {
|
51125
|
+
message: `Input not instance of ${cls.name}`
|
51126
|
+
}) => custom((data) => data instanceof cls, params, true), "instanceOfType");
|
51127
|
+
var stringType = ZodString.create;
|
51128
|
+
var numberType = ZodNumber.create;
|
51129
|
+
var nanType = ZodNaN.create;
|
51130
|
+
var bigIntType = ZodBigInt.create;
|
51131
|
+
var booleanType = ZodBoolean.create;
|
51132
|
+
var dateType = ZodDate.create;
|
51133
|
+
var undefinedType = ZodUndefined.create;
|
51134
|
+
var nullType = ZodNull.create;
|
51135
|
+
var anyType = ZodAny.create;
|
51136
|
+
var unknownType = ZodUnknown.create;
|
51137
|
+
var neverType = ZodNever.create;
|
51138
|
+
var voidType = ZodVoid.create;
|
51139
|
+
var arrayType = ZodArray.create;
|
51140
|
+
var objectType = ZodObject.create;
|
51141
|
+
var strictObjectType = ZodObject.strictCreate;
|
51142
|
+
var unionType = ZodUnion.create;
|
51143
|
+
var discriminatedUnionType = ZodDiscriminatedUnion.create;
|
51144
|
+
var intersectionType = ZodIntersection.create;
|
51145
|
+
var tupleType = ZodTuple.create;
|
51146
|
+
var recordType = ZodRecord.create;
|
51147
|
+
var mapType = ZodMap.create;
|
51148
|
+
var setType = ZodSet.create;
|
51149
|
+
var functionType = ZodFunction.create;
|
51150
|
+
var lazyType = ZodLazy.create;
|
51151
|
+
var literalType = ZodLiteral.create;
|
51152
|
+
var enumType = ZodEnum.create;
|
51153
|
+
var nativeEnumType = ZodNativeEnum.create;
|
51154
|
+
var promiseType = ZodPromise.create;
|
51155
|
+
var effectsType = ZodEffects.create;
|
51156
|
+
var optionalType = ZodOptional.create;
|
51157
|
+
var nullableType = ZodNullable.create;
|
51158
|
+
var preprocessType = ZodEffects.createWithPreprocess;
|
51159
|
+
var ostring = /* @__PURE__ */ __name(() => stringType().optional(), "ostring");
|
51160
|
+
var onumber = /* @__PURE__ */ __name(() => numberType().optional(), "onumber");
|
51161
|
+
var oboolean = /* @__PURE__ */ __name(() => booleanType().optional(), "oboolean");
|
51162
|
+
var mod = /* @__PURE__ */ Object.freeze({
|
51163
|
+
__proto__: null,
|
51164
|
+
getParsedType,
|
51165
|
+
ZodParsedType,
|
51166
|
+
makeIssue,
|
51167
|
+
EMPTY_PATH,
|
51168
|
+
addIssueToContext,
|
51169
|
+
ParseStatus,
|
51170
|
+
INVALID,
|
51171
|
+
DIRTY,
|
51172
|
+
OK,
|
51173
|
+
isAborted,
|
51174
|
+
isDirty,
|
51175
|
+
isValid,
|
51176
|
+
isAsync,
|
51177
|
+
ZodType,
|
51178
|
+
ZodString,
|
51179
|
+
ZodNumber,
|
51180
|
+
ZodBigInt,
|
51181
|
+
ZodBoolean,
|
51182
|
+
ZodDate,
|
51183
|
+
ZodUndefined,
|
51184
|
+
ZodNull,
|
51185
|
+
ZodAny,
|
51186
|
+
ZodUnknown,
|
51187
|
+
ZodNever,
|
51188
|
+
ZodVoid,
|
51189
|
+
ZodArray,
|
51190
|
+
get objectUtil() {
|
51191
|
+
return objectUtil;
|
51192
|
+
},
|
51193
|
+
ZodObject,
|
51194
|
+
ZodUnion,
|
51195
|
+
ZodDiscriminatedUnion,
|
51196
|
+
ZodIntersection,
|
51197
|
+
ZodTuple,
|
51198
|
+
ZodRecord,
|
51199
|
+
ZodMap,
|
51200
|
+
ZodSet,
|
51201
|
+
ZodFunction,
|
51202
|
+
ZodLazy,
|
51203
|
+
ZodLiteral,
|
51204
|
+
ZodEnum,
|
51205
|
+
ZodNativeEnum,
|
51206
|
+
ZodPromise,
|
51207
|
+
ZodEffects,
|
51208
|
+
ZodTransformer: ZodEffects,
|
51209
|
+
ZodOptional,
|
51210
|
+
ZodNullable,
|
51211
|
+
ZodDefault,
|
51212
|
+
ZodNaN,
|
51213
|
+
custom,
|
51214
|
+
Schema: ZodType,
|
51215
|
+
ZodSchema: ZodType,
|
51216
|
+
late,
|
51217
|
+
get ZodFirstPartyTypeKind() {
|
51218
|
+
return ZodFirstPartyTypeKind;
|
51219
|
+
},
|
51220
|
+
any: anyType,
|
51221
|
+
array: arrayType,
|
51222
|
+
bigint: bigIntType,
|
51223
|
+
boolean: booleanType,
|
51224
|
+
date: dateType,
|
51225
|
+
discriminatedUnion: discriminatedUnionType,
|
51226
|
+
effect: effectsType,
|
51227
|
+
"enum": enumType,
|
51228
|
+
"function": functionType,
|
51229
|
+
"instanceof": instanceOfType,
|
51230
|
+
intersection: intersectionType,
|
51231
|
+
lazy: lazyType,
|
51232
|
+
literal: literalType,
|
51233
|
+
map: mapType,
|
51234
|
+
nan: nanType,
|
51235
|
+
nativeEnum: nativeEnumType,
|
51236
|
+
never: neverType,
|
51237
|
+
"null": nullType,
|
51238
|
+
nullable: nullableType,
|
51239
|
+
number: numberType,
|
51240
|
+
object: objectType,
|
51241
|
+
oboolean,
|
51242
|
+
onumber,
|
51243
|
+
optional: optionalType,
|
51244
|
+
ostring,
|
51245
|
+
preprocess: preprocessType,
|
51246
|
+
promise: promiseType,
|
51247
|
+
record: recordType,
|
51248
|
+
set: setType,
|
51249
|
+
strictObject: strictObjectType,
|
51250
|
+
string: stringType,
|
51251
|
+
transformer: effectsType,
|
51252
|
+
tuple: tupleType,
|
51253
|
+
"undefined": undefinedType,
|
51254
|
+
union: unionType,
|
51255
|
+
unknown: unknownType,
|
51256
|
+
"void": voidType,
|
51257
|
+
ZodIssueCode,
|
51258
|
+
quotelessJson,
|
51259
|
+
ZodError,
|
51260
|
+
defaultErrorMap,
|
51261
|
+
get overrideErrorMap() {
|
51262
|
+
return overrideErrorMap;
|
51263
|
+
},
|
51264
|
+
setErrorMap
|
51265
|
+
});
|
51266
|
+
|
48535
51267
|
// ../learn-card-types/dist/types.esm.js
|
48536
|
-
var
|
48537
|
-
|
48538
|
-
|
48539
|
-
|
48540
|
-
|
48541
|
-
|
51268
|
+
var ContextValidator = mod.string().array();
|
51269
|
+
var AchievementCriteriaValidator = mod.object({
|
51270
|
+
type: mod.string().optional(),
|
51271
|
+
narrative: mod.string().optional()
|
51272
|
+
});
|
51273
|
+
var ImageValidator = mod.string().or(mod.object({
|
51274
|
+
id: mod.string(),
|
51275
|
+
type: mod.string(),
|
51276
|
+
caption: mod.string().optional()
|
51277
|
+
}));
|
51278
|
+
var GeoCoordinatesValidator = mod.object({
|
51279
|
+
type: mod.string().array().nonempty(),
|
51280
|
+
latitude: mod.number(),
|
51281
|
+
longitude: mod.number()
|
51282
|
+
});
|
51283
|
+
var AddressValidator = mod.object({
|
51284
|
+
type: mod.string().array().nonempty(),
|
51285
|
+
addressCountry: mod.string().optional(),
|
51286
|
+
addressCountryCode: mod.string().optional(),
|
51287
|
+
addressRegion: mod.string().optional(),
|
51288
|
+
addressLocality: mod.string().optional(),
|
51289
|
+
streetAddress: mod.string().optional(),
|
51290
|
+
postOfficeBoxNumber: mod.string().optional(),
|
51291
|
+
postalCode: mod.string().optional(),
|
51292
|
+
geo: GeoCoordinatesValidator.optional()
|
51293
|
+
});
|
51294
|
+
var IdentifierTypeValidator = mod.enum([
|
51295
|
+
"sourcedId",
|
51296
|
+
"systemId",
|
51297
|
+
"productId",
|
51298
|
+
"userName",
|
51299
|
+
"accountId",
|
51300
|
+
"emailAddress",
|
51301
|
+
"nationalIdentityNumber",
|
51302
|
+
"isbn",
|
51303
|
+
"issn",
|
51304
|
+
"lisSourcedId",
|
51305
|
+
"oneRosterSourcedId",
|
51306
|
+
"sisSourcedId",
|
51307
|
+
"ltiContextId",
|
51308
|
+
"ltiDeploymentId",
|
51309
|
+
"ltiToolId",
|
51310
|
+
"ltiPlatformId",
|
51311
|
+
"ltiUserId",
|
51312
|
+
"identifier"
|
51313
|
+
]).or(mod.string());
|
51314
|
+
var IdentifierEntryValidator = mod.object({
|
51315
|
+
type: mod.string().array().nonempty(),
|
51316
|
+
identifier: mod.string(),
|
51317
|
+
identifierType: IdentifierTypeValidator
|
51318
|
+
});
|
51319
|
+
var ProfileValidator = mod.string().or(mod.object({
|
51320
|
+
id: mod.string().optional(),
|
51321
|
+
type: mod.string().array().nonempty(),
|
51322
|
+
name: mod.string().optional(),
|
51323
|
+
url: mod.string().optional(),
|
51324
|
+
phone: mod.string().optional(),
|
51325
|
+
description: mod.string().optional(),
|
51326
|
+
endorsement: mod.any().array().optional(),
|
51327
|
+
image: ImageValidator.optional(),
|
51328
|
+
email: mod.string().email().optional(),
|
51329
|
+
address: AddressValidator.optional(),
|
51330
|
+
otherIdentifier: IdentifierEntryValidator.array().optional(),
|
51331
|
+
official: mod.string().optional(),
|
51332
|
+
parentOrg: mod.any().optional(),
|
51333
|
+
familyName: mod.string().optional(),
|
51334
|
+
givenName: mod.string().optional(),
|
51335
|
+
additionalName: mod.string().optional(),
|
51336
|
+
patronymicName: mod.string().optional(),
|
51337
|
+
honorificPrefix: mod.string().optional(),
|
51338
|
+
honorificSuffix: mod.string().optional(),
|
51339
|
+
familyNamePrefix: mod.string().optional(),
|
51340
|
+
dateOfBirth: mod.string().optional()
|
51341
|
+
}).catchall(mod.any()));
|
51342
|
+
var CredentialSubjectValidator = mod.object({ id: mod.string().optional() }).catchall(mod.any());
|
51343
|
+
var CredentialStatusValidator = mod.object({ type: mod.string(), id: mod.string() });
|
51344
|
+
var CredentialSchemaValidator = mod.object({ id: mod.string(), type: mod.string() });
|
51345
|
+
var RefreshServiceValidator = mod.object({ id: mod.string(), type: mod.string() }).catchall(mod.any());
|
51346
|
+
var UnsignedVCValidator = mod.object({
|
51347
|
+
"@context": ContextValidator,
|
51348
|
+
id: mod.string().optional(),
|
51349
|
+
type: mod.string().array().nonempty(),
|
51350
|
+
issuer: ProfileValidator,
|
51351
|
+
issuanceDate: mod.string(),
|
51352
|
+
expirationDate: mod.string().optional(),
|
51353
|
+
credentialSubject: CredentialSubjectValidator.or(CredentialSubjectValidator.array()),
|
51354
|
+
credentialStatus: CredentialStatusValidator.optional(),
|
51355
|
+
credentialSchema: CredentialSchemaValidator.array().optional(),
|
51356
|
+
refreshService: RefreshServiceValidator.optional()
|
51357
|
+
}).catchall(mod.any());
|
51358
|
+
var ProofValidator = mod.object({
|
51359
|
+
type: mod.string(),
|
51360
|
+
created: mod.string(),
|
51361
|
+
challenge: mod.string().optional(),
|
51362
|
+
domain: mod.string().optional(),
|
51363
|
+
nonce: mod.string().optional(),
|
51364
|
+
proofPurpose: mod.literal("assertionMethod"),
|
51365
|
+
verificationMethod: mod.string(),
|
51366
|
+
jws: mod.string().optional()
|
51367
|
+
}).catchall(mod.any());
|
51368
|
+
var VCValidator = UnsignedVCValidator.extend({
|
51369
|
+
proof: ProofValidator.or(ProofValidator.array())
|
51370
|
+
});
|
51371
|
+
var UnsignedVPValidator = mod.object({
|
51372
|
+
"@context": ContextValidator,
|
51373
|
+
id: mod.string().optional(),
|
51374
|
+
type: mod.string().array().nonempty(),
|
51375
|
+
verifiableCredential: VCValidator,
|
51376
|
+
holder: mod.string().optional()
|
51377
|
+
}).catchall(mod.any());
|
51378
|
+
var VPValidator = UnsignedVPValidator.extend({
|
51379
|
+
proof: ProofValidator.or(ProofValidator.array())
|
51380
|
+
});
|
51381
|
+
var AlignmentTargetTypeValidator = mod.enum([
|
51382
|
+
"ceasn:Competency",
|
51383
|
+
"ceterms:Credential",
|
51384
|
+
"CFItem",
|
51385
|
+
"CFRubric",
|
51386
|
+
"CFRubricCriterion",
|
51387
|
+
"CFRubricCriterionLevel",
|
51388
|
+
"CTDL"
|
51389
|
+
]).or(mod.string());
|
51390
|
+
var AlignmentValidator = mod.object({
|
51391
|
+
type: mod.string().array().nonempty(),
|
51392
|
+
targetCode: mod.string().optional(),
|
51393
|
+
targetDescription: mod.string().optional(),
|
51394
|
+
targetName: mod.string(),
|
51395
|
+
targetFramework: mod.string().optional(),
|
51396
|
+
targetType: AlignmentTargetTypeValidator.optional(),
|
51397
|
+
targetUrl: mod.string()
|
51398
|
+
});
|
51399
|
+
var AchievementTypeValidator = mod.enum([
|
51400
|
+
"Achievement",
|
51401
|
+
"ApprenticeshipCertificate",
|
51402
|
+
"Assessment",
|
51403
|
+
"Assignment",
|
51404
|
+
"AssociateDegree",
|
51405
|
+
"Award",
|
51406
|
+
"Badge",
|
51407
|
+
"BachelorDegree",
|
51408
|
+
"Certificate",
|
51409
|
+
"CertificateOfCompletion",
|
51410
|
+
"Certification",
|
51411
|
+
"CommunityService",
|
51412
|
+
"Competency",
|
51413
|
+
"Course",
|
51414
|
+
"CoCurricular",
|
51415
|
+
"Degree",
|
51416
|
+
"Diploma",
|
51417
|
+
"DoctoralDegree",
|
51418
|
+
"Fieldwork",
|
51419
|
+
"GeneralEducationDevelopment",
|
51420
|
+
"JourneymanCertificate",
|
51421
|
+
"LearningProgram",
|
51422
|
+
"License",
|
51423
|
+
"Membership",
|
51424
|
+
"ProfessionalDoctorate",
|
51425
|
+
"QualityAssuranceCredential",
|
51426
|
+
"MasterCertificate",
|
51427
|
+
"MasterDegree",
|
51428
|
+
"MicroCredential",
|
51429
|
+
"ResearchDoctorate",
|
51430
|
+
"SecondarySchoolDiploma"
|
51431
|
+
]).or(mod.string());
|
51432
|
+
var CriteriaValidator = mod.object({ id: mod.string().optional(), narrative: mod.string().optional() }).catchall(mod.any());
|
51433
|
+
var EndorsementSubjectValidator = mod.object({
|
51434
|
+
id: mod.string(),
|
51435
|
+
type: mod.string().array().nonempty(),
|
51436
|
+
endorsementComment: mod.string().optional()
|
51437
|
+
});
|
51438
|
+
var EndorsementCredentialValidator = UnsignedVCValidator.extend({
|
51439
|
+
credentialSubject: EndorsementSubjectValidator,
|
51440
|
+
proof: ProofValidator.or(ProofValidator.array()).optional()
|
51441
|
+
});
|
51442
|
+
var RelatedValidator = mod.object({
|
51443
|
+
id: mod.string(),
|
51444
|
+
"@language": mod.string().optional(),
|
51445
|
+
version: mod.string().optional()
|
51446
|
+
});
|
51447
|
+
var ResultTypeValidator = mod.enum([
|
51448
|
+
"GradePointAverage",
|
51449
|
+
"LetterGrade",
|
51450
|
+
"Percent",
|
51451
|
+
"PerformanceLevel",
|
51452
|
+
"PredictedScore",
|
51453
|
+
"RawScore",
|
51454
|
+
"Result",
|
51455
|
+
"RubricCriterion",
|
51456
|
+
"RubricCriterionLevel",
|
51457
|
+
"RubricScore",
|
51458
|
+
"ScaledScore",
|
51459
|
+
"Status"
|
51460
|
+
]).or(mod.string());
|
51461
|
+
var RubricCriterionValidator = mod.object({
|
51462
|
+
id: mod.string(),
|
51463
|
+
type: mod.string().array().nonempty(),
|
51464
|
+
alignment: AlignmentValidator.array().optional(),
|
51465
|
+
description: mod.string().optional(),
|
51466
|
+
level: mod.string().optional(),
|
51467
|
+
name: mod.string(),
|
51468
|
+
points: mod.string().optional()
|
51469
|
+
}).catchall(mod.any());
|
51470
|
+
var ResultDescriptionValidator = mod.object({
|
51471
|
+
id: mod.string(),
|
51472
|
+
type: mod.string().array().nonempty(),
|
51473
|
+
alignment: AlignmentValidator.array().optional(),
|
51474
|
+
allowedValue: mod.string().array().optional(),
|
51475
|
+
name: mod.string(),
|
51476
|
+
requiredLevel: mod.string().optional(),
|
51477
|
+
requiredValue: mod.string().optional(),
|
51478
|
+
resultType: ResultTypeValidator,
|
51479
|
+
rubricCriterionLevel: RubricCriterionValidator.array().optional(),
|
51480
|
+
valueMax: mod.string().optional(),
|
51481
|
+
valueMin: mod.string().optional()
|
51482
|
+
}).catchall(mod.any());
|
51483
|
+
var AchievementValidator = mod.object({
|
51484
|
+
id: mod.string().optional(),
|
51485
|
+
type: mod.string().array().nonempty(),
|
51486
|
+
alignment: AlignmentValidator.array().optional(),
|
51487
|
+
achievementType: AchievementTypeValidator.optional(),
|
51488
|
+
creator: ProfileValidator.optional(),
|
51489
|
+
creditsAvailable: mod.number().optional(),
|
51490
|
+
criteria: CriteriaValidator,
|
51491
|
+
description: mod.string(),
|
51492
|
+
endorsement: EndorsementCredentialValidator.array().optional(),
|
51493
|
+
fieldOfStudy: mod.string().optional(),
|
51494
|
+
humanCode: mod.string().optional(),
|
51495
|
+
image: ImageValidator.optional(),
|
51496
|
+
"@language": mod.string().optional(),
|
51497
|
+
name: mod.string(),
|
51498
|
+
otherIdentifier: IdentifierEntryValidator.array().optional(),
|
51499
|
+
related: RelatedValidator.array().optional(),
|
51500
|
+
resultDescription: ResultDescriptionValidator.array().optional(),
|
51501
|
+
specialization: mod.string().optional(),
|
51502
|
+
tag: mod.string().array().optional(),
|
51503
|
+
version: mod.string().optional()
|
51504
|
+
}).catchall(mod.any());
|
51505
|
+
var IdentityObjectValidator = mod.object({
|
51506
|
+
type: mod.string(),
|
51507
|
+
hashed: mod.boolean(),
|
51508
|
+
identityHash: mod.string(),
|
51509
|
+
identityType: mod.string(),
|
51510
|
+
salt: mod.string().optional()
|
51511
|
+
});
|
51512
|
+
var ResultStatusTypeValidator = mod.enum([
|
51513
|
+
"Completed",
|
51514
|
+
"Enrolled",
|
51515
|
+
"Failed",
|
51516
|
+
"InProgress",
|
51517
|
+
"OnHold",
|
51518
|
+
"Withdrew"
|
51519
|
+
]);
|
51520
|
+
var ResultValidator = mod.object({
|
51521
|
+
type: mod.string().array().nonempty(),
|
51522
|
+
achievedLevel: mod.string().optional(),
|
51523
|
+
alignment: AlignmentValidator.array().optional(),
|
51524
|
+
resultDescription: mod.string().optional(),
|
51525
|
+
status: ResultStatusTypeValidator.optional(),
|
51526
|
+
value: mod.string().optional()
|
51527
|
+
}).catchall(mod.any());
|
51528
|
+
var AchievementSubjectValidator = mod.object({
|
51529
|
+
id: mod.string().optional(),
|
51530
|
+
type: mod.string().array().nonempty(),
|
51531
|
+
activityEndDate: mod.string().optional(),
|
51532
|
+
activityStartDate: mod.string().optional(),
|
51533
|
+
creditsEarned: mod.number().optional(),
|
51534
|
+
achievement: AchievementValidator.optional(),
|
51535
|
+
identifier: IdentityObjectValidator.optional(),
|
51536
|
+
image: ImageValidator.optional(),
|
51537
|
+
licenseNumber: mod.string().optional(),
|
51538
|
+
narrative: mod.string().optional(),
|
51539
|
+
result: ResultValidator.array().optional(),
|
51540
|
+
role: mod.string().optional(),
|
51541
|
+
source: ProfileValidator.optional(),
|
51542
|
+
term: mod.string().optional()
|
51543
|
+
}).catchall(mod.any());
|
51544
|
+
var EvidenceValidator = mod.object({
|
51545
|
+
id: mod.string().optional(),
|
51546
|
+
type: mod.string().array().nonempty(),
|
51547
|
+
narrative: mod.string().optional(),
|
51548
|
+
name: mod.string().optional(),
|
51549
|
+
description: mod.string().optional(),
|
51550
|
+
genre: mod.string().optional(),
|
51551
|
+
audience: mod.string().optional()
|
51552
|
+
}).catchall(mod.any());
|
51553
|
+
var UnsignedAchievementCredentialValidator = UnsignedVCValidator.extend({
|
51554
|
+
name: mod.string().optional(),
|
51555
|
+
description: mod.string().optional(),
|
51556
|
+
image: mod.string().optional(),
|
51557
|
+
credentialSubject: AchievementSubjectValidator.or(AchievementSubjectValidator.array()),
|
51558
|
+
endorsement: UnsignedVCValidator.array().optional(),
|
51559
|
+
evidence: EvidenceValidator.array().optional()
|
51560
|
+
});
|
51561
|
+
var AchievementCredentialValidator = UnsignedAchievementCredentialValidator.extend({
|
51562
|
+
proof: ProofValidator.or(ProofValidator.array())
|
51563
|
+
});
|
51564
|
+
var VerificationStatusValidator = mod.enum(["Success", "Failed", "Error"]);
|
51565
|
+
var VerificationStatusEnum = VerificationStatusValidator.enum;
|
51566
|
+
var VerificationItemValidator = mod.object({
|
51567
|
+
check: mod.string(),
|
51568
|
+
status: VerificationStatusValidator,
|
51569
|
+
message: mod.string().optional(),
|
51570
|
+
details: mod.string().optional()
|
51571
|
+
});
|
51572
|
+
var CredentialInfoValidator = mod.object({
|
51573
|
+
title: mod.string().optional(),
|
51574
|
+
createdAt: mod.string().optional(),
|
51575
|
+
issuer: ProfileValidator.optional(),
|
51576
|
+
issuee: ProfileValidator.optional(),
|
51577
|
+
credentialSubject: CredentialSubjectValidator.optional()
|
51578
|
+
});
|
48542
51579
|
|
48543
51580
|
// ../../node_modules/.pnpm/date-fns@2.28.0/node_modules/date-fns/esm/_lib/toInteger/index.js
|
48544
51581
|
function toInteger(dirtyNumber) {
|
@@ -48604,7 +51641,7 @@ function isDate(value) {
|
|
48604
51641
|
__name(isDate, "isDate");
|
48605
51642
|
|
48606
51643
|
// ../../node_modules/.pnpm/date-fns@2.28.0/node_modules/date-fns/esm/isValid/index.js
|
48607
|
-
function
|
51644
|
+
function isValid2(dirtyDate) {
|
48608
51645
|
requiredArgs(1, arguments);
|
48609
51646
|
if (!isDate(dirtyDate) && typeof dirtyDate !== "number") {
|
48610
51647
|
return false;
|
@@ -48612,7 +51649,7 @@ function isValid(dirtyDate) {
|
|
48612
51649
|
var date = toDate(dirtyDate);
|
48613
51650
|
return !isNaN(Number(date));
|
48614
51651
|
}
|
48615
|
-
__name(
|
51652
|
+
__name(isValid2, "isValid");
|
48616
51653
|
|
48617
51654
|
// ../../node_modules/.pnpm/date-fns@2.28.0/node_modules/date-fns/esm/locale/en-US/_lib/formatDistance/index.js
|
48618
51655
|
var formatDistanceLocale = {
|
@@ -50053,7 +53090,7 @@ function format(dirtyDate, dirtyFormatStr, dirtyOptions) {
|
|
50053
53090
|
throw new RangeError("locale must contain formatLong property");
|
50054
53091
|
}
|
50055
53092
|
var originalDate = toDate(dirtyDate);
|
50056
|
-
if (!
|
53093
|
+
if (!isValid2(originalDate)) {
|
50057
53094
|
throw new RangeError("Invalid time value");
|
50058
53095
|
}
|
50059
53096
|
var timezoneOffset = getTimezoneOffsetInMilliseconds(originalDate);
|
@@ -50121,21 +53158,21 @@ var verifyCredential3 = /* @__PURE__ */ __name((wallet) => {
|
|
50121
53158
|
const verificationItems = [];
|
50122
53159
|
rawVerificationCheck.errors.forEach((error) => {
|
50123
53160
|
verificationItems.push({
|
50124
|
-
status:
|
53161
|
+
status: VerificationStatusEnum.Failed,
|
50125
53162
|
check: "hmm",
|
50126
53163
|
details: transformErrorMessage(error, credential)
|
50127
53164
|
});
|
50128
53165
|
});
|
50129
53166
|
rawVerificationCheck.warnings.forEach((warning) => {
|
50130
53167
|
verificationItems.push({
|
50131
|
-
status:
|
53168
|
+
status: VerificationStatusEnum.Error,
|
50132
53169
|
check: "hmm",
|
50133
53170
|
message: warning
|
50134
53171
|
});
|
50135
53172
|
});
|
50136
53173
|
rawVerificationCheck.checks.forEach((check) => {
|
50137
53174
|
verificationItems.push({
|
50138
|
-
status:
|
53175
|
+
status: VerificationStatusEnum.Success,
|
50139
53176
|
check,
|
50140
53177
|
message: transformCheckMessage(check, credential)
|
50141
53178
|
});
|