@critical-path/svelte 0.10.2 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3279 -11
- package/dist/webmcp-state.svelte.d.ts +26 -0
- package/dist/webmcp-state.svelte.d.ts.map +1 -0
- package/package.json +3 -2
- package/src/index.test.ts +49 -1
- package/src/index.ts +1 -0
- package/src/webmcp-state.svelte.ts +78 -0
package/dist/index.js
CHANGED
|
@@ -372,12 +372,12 @@ var c = class {
|
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
};
|
|
375
|
-
function
|
|
375
|
+
function ee(e, t) {
|
|
376
376
|
return new c(e, t);
|
|
377
377
|
}
|
|
378
378
|
//#endregion
|
|
379
379
|
//#region src/attachment-state.svelte.ts
|
|
380
|
-
var
|
|
380
|
+
var te = class {
|
|
381
381
|
client;
|
|
382
382
|
filter;
|
|
383
383
|
#e = t.state(t.proxy([]));
|
|
@@ -435,12 +435,12 @@ var u = class {
|
|
|
435
435
|
}
|
|
436
436
|
}
|
|
437
437
|
};
|
|
438
|
-
function
|
|
439
|
-
return new
|
|
438
|
+
function ne(e, t) {
|
|
439
|
+
return new te(e, t);
|
|
440
440
|
}
|
|
441
441
|
//#endregion
|
|
442
442
|
//#region src/activity-state.svelte.ts
|
|
443
|
-
var
|
|
443
|
+
var re = class {
|
|
444
444
|
client;
|
|
445
445
|
taskId;
|
|
446
446
|
#e = t.state(t.proxy([]));
|
|
@@ -597,12 +597,12 @@ var f = class {
|
|
|
597
597
|
}
|
|
598
598
|
}
|
|
599
599
|
};
|
|
600
|
-
function
|
|
601
|
-
return new
|
|
600
|
+
function ie(e, t) {
|
|
601
|
+
return new re(e, t);
|
|
602
602
|
}
|
|
603
603
|
//#endregion
|
|
604
604
|
//#region src/deliverable-state.svelte.ts
|
|
605
|
-
var
|
|
605
|
+
var ae = class {
|
|
606
606
|
client;
|
|
607
607
|
projectId;
|
|
608
608
|
#e = t.state(t.proxy([]));
|
|
@@ -680,13 +680,3281 @@ var m = class {
|
|
|
680
680
|
return this.client.getDeliverableSummary(e);
|
|
681
681
|
}
|
|
682
682
|
};
|
|
683
|
+
function oe(e, t) {
|
|
684
|
+
return new ae(e, t);
|
|
685
|
+
}
|
|
686
|
+
//#endregion
|
|
687
|
+
//#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/util.js
|
|
688
|
+
var l;
|
|
689
|
+
(function(e) {
|
|
690
|
+
e.assertEqual = (e) => {};
|
|
691
|
+
function t(e) {}
|
|
692
|
+
e.assertIs = t;
|
|
693
|
+
function n(e) {
|
|
694
|
+
throw Error();
|
|
695
|
+
}
|
|
696
|
+
e.assertNever = n, e.arrayToEnum = (e) => {
|
|
697
|
+
let t = {};
|
|
698
|
+
for (let n of e) t[n] = n;
|
|
699
|
+
return t;
|
|
700
|
+
}, e.getValidEnumValues = (t) => {
|
|
701
|
+
let n = e.objectKeys(t).filter((e) => typeof t[t[e]] != "number"), r = {};
|
|
702
|
+
for (let e of n) r[e] = t[e];
|
|
703
|
+
return e.objectValues(r);
|
|
704
|
+
}, e.objectValues = (t) => e.objectKeys(t).map(function(e) {
|
|
705
|
+
return t[e];
|
|
706
|
+
}), e.objectKeys = typeof Object.keys == "function" ? (e) => Object.keys(e) : (e) => {
|
|
707
|
+
let t = [];
|
|
708
|
+
for (let n in e) Object.prototype.hasOwnProperty.call(e, n) && t.push(n);
|
|
709
|
+
return t;
|
|
710
|
+
}, e.find = (e, t) => {
|
|
711
|
+
for (let n of e) if (t(n)) return n;
|
|
712
|
+
}, e.isInteger = typeof Number.isInteger == "function" ? (e) => Number.isInteger(e) : (e) => typeof e == "number" && Number.isFinite(e) && Math.floor(e) === e;
|
|
713
|
+
function r(e, t = " | ") {
|
|
714
|
+
return e.map((e) => typeof e == "string" ? `'${e}'` : e).join(t);
|
|
715
|
+
}
|
|
716
|
+
e.joinValues = r, e.jsonStringifyReplacer = (e, t) => typeof t == "bigint" ? t.toString() : t;
|
|
717
|
+
})(l ||= {});
|
|
718
|
+
var se;
|
|
719
|
+
(function(e) {
|
|
720
|
+
e.mergeShapes = (e, t) => ({
|
|
721
|
+
...e,
|
|
722
|
+
...t
|
|
723
|
+
});
|
|
724
|
+
})(se ||= {});
|
|
725
|
+
var u = l.arrayToEnum([
|
|
726
|
+
"string",
|
|
727
|
+
"nan",
|
|
728
|
+
"number",
|
|
729
|
+
"integer",
|
|
730
|
+
"float",
|
|
731
|
+
"boolean",
|
|
732
|
+
"date",
|
|
733
|
+
"bigint",
|
|
734
|
+
"symbol",
|
|
735
|
+
"function",
|
|
736
|
+
"undefined",
|
|
737
|
+
"null",
|
|
738
|
+
"array",
|
|
739
|
+
"object",
|
|
740
|
+
"unknown",
|
|
741
|
+
"promise",
|
|
742
|
+
"void",
|
|
743
|
+
"never",
|
|
744
|
+
"map",
|
|
745
|
+
"set"
|
|
746
|
+
]), d = (e) => {
|
|
747
|
+
switch (typeof e) {
|
|
748
|
+
case "undefined": return u.undefined;
|
|
749
|
+
case "string": return u.string;
|
|
750
|
+
case "number": return Number.isNaN(e) ? u.nan : u.number;
|
|
751
|
+
case "boolean": return u.boolean;
|
|
752
|
+
case "function": return u.function;
|
|
753
|
+
case "bigint": return u.bigint;
|
|
754
|
+
case "symbol": return u.symbol;
|
|
755
|
+
case "object": return Array.isArray(e) ? u.array : e === null ? u.null : e.then && typeof e.then == "function" && e.catch && typeof e.catch == "function" ? u.promise : typeof Map < "u" && e instanceof Map ? u.map : typeof Set < "u" && e instanceof Set ? u.set : typeof Date < "u" && e instanceof Date ? u.date : u.object;
|
|
756
|
+
default: return u.unknown;
|
|
757
|
+
}
|
|
758
|
+
}, f = l.arrayToEnum([
|
|
759
|
+
"invalid_type",
|
|
760
|
+
"invalid_literal",
|
|
761
|
+
"custom",
|
|
762
|
+
"invalid_union",
|
|
763
|
+
"invalid_union_discriminator",
|
|
764
|
+
"invalid_enum_value",
|
|
765
|
+
"unrecognized_keys",
|
|
766
|
+
"invalid_arguments",
|
|
767
|
+
"invalid_return_type",
|
|
768
|
+
"invalid_date",
|
|
769
|
+
"invalid_string",
|
|
770
|
+
"too_small",
|
|
771
|
+
"too_big",
|
|
772
|
+
"invalid_intersection_types",
|
|
773
|
+
"not_multiple_of",
|
|
774
|
+
"not_finite"
|
|
775
|
+
]), p = class e extends Error {
|
|
776
|
+
get errors() {
|
|
777
|
+
return this.issues;
|
|
778
|
+
}
|
|
779
|
+
constructor(e) {
|
|
780
|
+
super(), this.issues = [], this.addIssue = (e) => {
|
|
781
|
+
this.issues = [...this.issues, e];
|
|
782
|
+
}, this.addIssues = (e = []) => {
|
|
783
|
+
this.issues = [...this.issues, ...e];
|
|
784
|
+
};
|
|
785
|
+
let t = new.target.prototype;
|
|
786
|
+
Object.setPrototypeOf ? Object.setPrototypeOf(this, t) : this.__proto__ = t, this.name = "ZodError", this.issues = e;
|
|
787
|
+
}
|
|
788
|
+
format(e) {
|
|
789
|
+
let t = e || function(e) {
|
|
790
|
+
return e.message;
|
|
791
|
+
}, n = { _errors: [] }, r = (e) => {
|
|
792
|
+
for (let i of e.issues) if (i.code === "invalid_union") i.unionErrors.map(r);
|
|
793
|
+
else if (i.code === "invalid_return_type") r(i.returnTypeError);
|
|
794
|
+
else if (i.code === "invalid_arguments") r(i.argumentsError);
|
|
795
|
+
else if (i.path.length === 0) n._errors.push(t(i));
|
|
796
|
+
else {
|
|
797
|
+
let e = n, r = 0;
|
|
798
|
+
for (; r < i.path.length;) {
|
|
799
|
+
let n = i.path[r];
|
|
800
|
+
r === i.path.length - 1 ? (e[n] = e[n] || { _errors: [] }, e[n]._errors.push(t(i))) : e[n] = e[n] || { _errors: [] }, e = e[n], r++;
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
};
|
|
804
|
+
return r(this), n;
|
|
805
|
+
}
|
|
806
|
+
static assert(t) {
|
|
807
|
+
if (!(t instanceof e)) throw Error(`Not a ZodError: ${t}`);
|
|
808
|
+
}
|
|
809
|
+
toString() {
|
|
810
|
+
return this.message;
|
|
811
|
+
}
|
|
812
|
+
get message() {
|
|
813
|
+
return JSON.stringify(this.issues, l.jsonStringifyReplacer, 2);
|
|
814
|
+
}
|
|
815
|
+
get isEmpty() {
|
|
816
|
+
return this.issues.length === 0;
|
|
817
|
+
}
|
|
818
|
+
flatten(e = (e) => e.message) {
|
|
819
|
+
let t = {}, n = [];
|
|
820
|
+
for (let r of this.issues) if (r.path.length > 0) {
|
|
821
|
+
let n = r.path[0];
|
|
822
|
+
t[n] = t[n] || [], t[n].push(e(r));
|
|
823
|
+
} else n.push(e(r));
|
|
824
|
+
return {
|
|
825
|
+
formErrors: n,
|
|
826
|
+
fieldErrors: t
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
get formErrors() {
|
|
830
|
+
return this.flatten();
|
|
831
|
+
}
|
|
832
|
+
};
|
|
833
|
+
p.create = (e) => new p(e);
|
|
834
|
+
//#endregion
|
|
835
|
+
//#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/locales/en.js
|
|
836
|
+
var m = (e, t) => {
|
|
837
|
+
let n;
|
|
838
|
+
switch (e.code) {
|
|
839
|
+
case f.invalid_type:
|
|
840
|
+
n = e.received === u.undefined ? "Required" : `Expected ${e.expected}, received ${e.received}`;
|
|
841
|
+
break;
|
|
842
|
+
case f.invalid_literal:
|
|
843
|
+
n = `Invalid literal value, expected ${JSON.stringify(e.expected, l.jsonStringifyReplacer)}`;
|
|
844
|
+
break;
|
|
845
|
+
case f.unrecognized_keys:
|
|
846
|
+
n = `Unrecognized key(s) in object: ${l.joinValues(e.keys, ", ")}`;
|
|
847
|
+
break;
|
|
848
|
+
case f.invalid_union:
|
|
849
|
+
n = "Invalid input";
|
|
850
|
+
break;
|
|
851
|
+
case f.invalid_union_discriminator:
|
|
852
|
+
n = `Invalid discriminator value. Expected ${l.joinValues(e.options)}`;
|
|
853
|
+
break;
|
|
854
|
+
case f.invalid_enum_value:
|
|
855
|
+
n = `Invalid enum value. Expected ${l.joinValues(e.options)}, received '${e.received}'`;
|
|
856
|
+
break;
|
|
857
|
+
case f.invalid_arguments:
|
|
858
|
+
n = "Invalid function arguments";
|
|
859
|
+
break;
|
|
860
|
+
case f.invalid_return_type:
|
|
861
|
+
n = "Invalid function return type";
|
|
862
|
+
break;
|
|
863
|
+
case f.invalid_date:
|
|
864
|
+
n = "Invalid date";
|
|
865
|
+
break;
|
|
866
|
+
case f.invalid_string:
|
|
867
|
+
typeof e.validation == "object" ? "includes" in e.validation ? (n = `Invalid input: must include "${e.validation.includes}"`, typeof e.validation.position == "number" && (n = `${n} at one or more positions greater than or equal to ${e.validation.position}`)) : "startsWith" in e.validation ? n = `Invalid input: must start with "${e.validation.startsWith}"` : "endsWith" in e.validation ? n = `Invalid input: must end with "${e.validation.endsWith}"` : l.assertNever(e.validation) : n = e.validation === "regex" ? "Invalid" : `Invalid ${e.validation}`;
|
|
868
|
+
break;
|
|
869
|
+
case f.too_small:
|
|
870
|
+
n = e.type === "array" ? `Array must contain ${e.exact ? "exactly" : e.inclusive ? "at least" : "more than"} ${e.minimum} element(s)` : e.type === "string" ? `String must contain ${e.exact ? "exactly" : e.inclusive ? "at least" : "over"} ${e.minimum} character(s)` : e.type === "number" || e.type === "bigint" ? `Number must be ${e.exact ? "exactly equal to " : e.inclusive ? "greater than or equal to " : "greater than "}${e.minimum}` : e.type === "date" ? `Date must be ${e.exact ? "exactly equal to " : e.inclusive ? "greater than or equal to " : "greater than "}${new Date(Number(e.minimum))}` : "Invalid input";
|
|
871
|
+
break;
|
|
872
|
+
case f.too_big:
|
|
873
|
+
n = e.type === "array" ? `Array must contain ${e.exact ? "exactly" : e.inclusive ? "at most" : "less than"} ${e.maximum} element(s)` : e.type === "string" ? `String must contain ${e.exact ? "exactly" : e.inclusive ? "at most" : "under"} ${e.maximum} character(s)` : e.type === "number" ? `Number must be ${e.exact ? "exactly" : e.inclusive ? "less than or equal to" : "less than"} ${e.maximum}` : e.type === "bigint" ? `BigInt must be ${e.exact ? "exactly" : e.inclusive ? "less than or equal to" : "less than"} ${e.maximum}` : e.type === "date" ? `Date must be ${e.exact ? "exactly" : e.inclusive ? "smaller than or equal to" : "smaller than"} ${new Date(Number(e.maximum))}` : "Invalid input";
|
|
874
|
+
break;
|
|
875
|
+
case f.custom:
|
|
876
|
+
n = "Invalid input";
|
|
877
|
+
break;
|
|
878
|
+
case f.invalid_intersection_types:
|
|
879
|
+
n = "Intersection results could not be merged";
|
|
880
|
+
break;
|
|
881
|
+
case f.not_multiple_of:
|
|
882
|
+
n = `Number must be a multiple of ${e.multipleOf}`;
|
|
883
|
+
break;
|
|
884
|
+
case f.not_finite:
|
|
885
|
+
n = "Number must be finite";
|
|
886
|
+
break;
|
|
887
|
+
default: n = t.defaultError, l.assertNever(e);
|
|
888
|
+
}
|
|
889
|
+
return { message: n };
|
|
890
|
+
}, ce = m;
|
|
891
|
+
function le() {
|
|
892
|
+
return ce;
|
|
893
|
+
}
|
|
894
|
+
//#endregion
|
|
895
|
+
//#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/helpers/parseUtil.js
|
|
896
|
+
var ue = (e) => {
|
|
897
|
+
let { data: t, path: n, errorMaps: r, issueData: i } = e, a = [...n, ...i.path || []], o = {
|
|
898
|
+
...i,
|
|
899
|
+
path: a
|
|
900
|
+
};
|
|
901
|
+
if (i.message !== void 0) return {
|
|
902
|
+
...i,
|
|
903
|
+
path: a,
|
|
904
|
+
message: i.message
|
|
905
|
+
};
|
|
906
|
+
let s = "", c = r.filter((e) => !!e).slice().reverse();
|
|
907
|
+
for (let e of c) s = e(o, {
|
|
908
|
+
data: t,
|
|
909
|
+
defaultError: s
|
|
910
|
+
}).message;
|
|
911
|
+
return {
|
|
912
|
+
...i,
|
|
913
|
+
path: a,
|
|
914
|
+
message: s
|
|
915
|
+
};
|
|
916
|
+
};
|
|
683
917
|
function h(e, t) {
|
|
684
|
-
|
|
918
|
+
let n = le(), r = ue({
|
|
919
|
+
issueData: t,
|
|
920
|
+
data: e.data,
|
|
921
|
+
path: e.path,
|
|
922
|
+
errorMaps: [
|
|
923
|
+
e.common.contextualErrorMap,
|
|
924
|
+
e.schemaErrorMap,
|
|
925
|
+
n,
|
|
926
|
+
n === m ? void 0 : m
|
|
927
|
+
].filter((e) => !!e)
|
|
928
|
+
});
|
|
929
|
+
e.common.issues.push(r);
|
|
930
|
+
}
|
|
931
|
+
var g = class e {
|
|
932
|
+
constructor() {
|
|
933
|
+
this.value = "valid";
|
|
934
|
+
}
|
|
935
|
+
dirty() {
|
|
936
|
+
this.value === "valid" && (this.value = "dirty");
|
|
937
|
+
}
|
|
938
|
+
abort() {
|
|
939
|
+
this.value !== "aborted" && (this.value = "aborted");
|
|
940
|
+
}
|
|
941
|
+
static mergeArray(e, t) {
|
|
942
|
+
let n = [];
|
|
943
|
+
for (let r of t) {
|
|
944
|
+
if (r.status === "aborted") return _;
|
|
945
|
+
r.status === "dirty" && e.dirty(), n.push(r.value);
|
|
946
|
+
}
|
|
947
|
+
return {
|
|
948
|
+
status: e.value,
|
|
949
|
+
value: n
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
static async mergeObjectAsync(t, n) {
|
|
953
|
+
let r = [];
|
|
954
|
+
for (let e of n) {
|
|
955
|
+
let t = await e.key, n = await e.value;
|
|
956
|
+
r.push({
|
|
957
|
+
key: t,
|
|
958
|
+
value: n
|
|
959
|
+
});
|
|
960
|
+
}
|
|
961
|
+
return e.mergeObjectSync(t, r);
|
|
962
|
+
}
|
|
963
|
+
static mergeObjectSync(e, t) {
|
|
964
|
+
let n = {};
|
|
965
|
+
for (let r of t) {
|
|
966
|
+
let { key: t, value: i } = r;
|
|
967
|
+
if (t.status === "aborted" || i.status === "aborted") return _;
|
|
968
|
+
t.status === "dirty" && e.dirty(), i.status === "dirty" && e.dirty(), t.value !== "__proto__" && (i.value !== void 0 || r.alwaysSet) && (n[t.value] = i.value);
|
|
969
|
+
}
|
|
970
|
+
return {
|
|
971
|
+
status: e.value,
|
|
972
|
+
value: n
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
}, _ = Object.freeze({ status: "aborted" }), de = (e) => ({
|
|
976
|
+
status: "dirty",
|
|
977
|
+
value: e
|
|
978
|
+
}), v = (e) => ({
|
|
979
|
+
status: "valid",
|
|
980
|
+
value: e
|
|
981
|
+
}), fe = (e) => e.status === "aborted", pe = (e) => e.status === "dirty", y = (e) => e.status === "valid", b = (e) => typeof Promise < "u" && e instanceof Promise, x;
|
|
982
|
+
(function(e) {
|
|
983
|
+
e.errToObj = (e) => typeof e == "string" ? { message: e } : e || {}, e.toString = (e) => typeof e == "string" ? e : e?.message;
|
|
984
|
+
})(x ||= {});
|
|
985
|
+
//#endregion
|
|
986
|
+
//#region ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/types.js
|
|
987
|
+
var S = class {
|
|
988
|
+
constructor(e, t, n, r) {
|
|
989
|
+
this._cachedPath = [], this.parent = e, this.data = t, this._path = n, this._key = r;
|
|
990
|
+
}
|
|
991
|
+
get path() {
|
|
992
|
+
return this._cachedPath.length || (Array.isArray(this._key) ? this._cachedPath.push(...this._path, ...this._key) : this._cachedPath.push(...this._path, this._key)), this._cachedPath;
|
|
993
|
+
}
|
|
994
|
+
}, me = (e, t) => {
|
|
995
|
+
if (y(t)) return {
|
|
996
|
+
success: !0,
|
|
997
|
+
data: t.value
|
|
998
|
+
};
|
|
999
|
+
if (!e.common.issues.length) throw Error("Validation failed but no issues detected.");
|
|
1000
|
+
return {
|
|
1001
|
+
success: !1,
|
|
1002
|
+
get error() {
|
|
1003
|
+
if (this._error) return this._error;
|
|
1004
|
+
let t = new p(e.common.issues);
|
|
1005
|
+
return this._error = t, this._error;
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
};
|
|
1009
|
+
function C(e) {
|
|
1010
|
+
if (!e) return {};
|
|
1011
|
+
let { errorMap: t, invalid_type_error: n, required_error: r, description: i } = e;
|
|
1012
|
+
if (t && (n || r)) throw Error("Can't use \"invalid_type_error\" or \"required_error\" in conjunction with custom error map.");
|
|
1013
|
+
return t ? {
|
|
1014
|
+
errorMap: t,
|
|
1015
|
+
description: i
|
|
1016
|
+
} : {
|
|
1017
|
+
errorMap: (t, i) => {
|
|
1018
|
+
let { message: a } = e;
|
|
1019
|
+
return t.code === "invalid_enum_value" ? { message: a ?? i.defaultError } : i.data === void 0 ? { message: a ?? r ?? i.defaultError } : t.code === "invalid_type" ? { message: a ?? n ?? i.defaultError } : { message: i.defaultError };
|
|
1020
|
+
},
|
|
1021
|
+
description: i
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
var w = class {
|
|
1025
|
+
get description() {
|
|
1026
|
+
return this._def.description;
|
|
1027
|
+
}
|
|
1028
|
+
_getType(e) {
|
|
1029
|
+
return d(e.data);
|
|
1030
|
+
}
|
|
1031
|
+
_getOrReturnCtx(e, t) {
|
|
1032
|
+
return t || {
|
|
1033
|
+
common: e.parent.common,
|
|
1034
|
+
data: e.data,
|
|
1035
|
+
parsedType: d(e.data),
|
|
1036
|
+
schemaErrorMap: this._def.errorMap,
|
|
1037
|
+
path: e.path,
|
|
1038
|
+
parent: e.parent
|
|
1039
|
+
};
|
|
1040
|
+
}
|
|
1041
|
+
_processInputParams(e) {
|
|
1042
|
+
return {
|
|
1043
|
+
status: new g(),
|
|
1044
|
+
ctx: {
|
|
1045
|
+
common: e.parent.common,
|
|
1046
|
+
data: e.data,
|
|
1047
|
+
parsedType: d(e.data),
|
|
1048
|
+
schemaErrorMap: this._def.errorMap,
|
|
1049
|
+
path: e.path,
|
|
1050
|
+
parent: e.parent
|
|
1051
|
+
}
|
|
1052
|
+
};
|
|
1053
|
+
}
|
|
1054
|
+
_parseSync(e) {
|
|
1055
|
+
let t = this._parse(e);
|
|
1056
|
+
if (b(t)) throw Error("Synchronous parse encountered promise.");
|
|
1057
|
+
return t;
|
|
1058
|
+
}
|
|
1059
|
+
_parseAsync(e) {
|
|
1060
|
+
let t = this._parse(e);
|
|
1061
|
+
return Promise.resolve(t);
|
|
1062
|
+
}
|
|
1063
|
+
parse(e, t) {
|
|
1064
|
+
let n = this.safeParse(e, t);
|
|
1065
|
+
if (n.success) return n.data;
|
|
1066
|
+
throw n.error;
|
|
1067
|
+
}
|
|
1068
|
+
safeParse(e, t) {
|
|
1069
|
+
let n = {
|
|
1070
|
+
common: {
|
|
1071
|
+
issues: [],
|
|
1072
|
+
async: t?.async ?? !1,
|
|
1073
|
+
contextualErrorMap: t?.errorMap
|
|
1074
|
+
},
|
|
1075
|
+
path: t?.path || [],
|
|
1076
|
+
schemaErrorMap: this._def.errorMap,
|
|
1077
|
+
parent: null,
|
|
1078
|
+
data: e,
|
|
1079
|
+
parsedType: d(e)
|
|
1080
|
+
};
|
|
1081
|
+
return me(n, this._parseSync({
|
|
1082
|
+
data: e,
|
|
1083
|
+
path: n.path,
|
|
1084
|
+
parent: n
|
|
1085
|
+
}));
|
|
1086
|
+
}
|
|
1087
|
+
"~validate"(e) {
|
|
1088
|
+
let t = {
|
|
1089
|
+
common: {
|
|
1090
|
+
issues: [],
|
|
1091
|
+
async: !!this["~standard"].async
|
|
1092
|
+
},
|
|
1093
|
+
path: [],
|
|
1094
|
+
schemaErrorMap: this._def.errorMap,
|
|
1095
|
+
parent: null,
|
|
1096
|
+
data: e,
|
|
1097
|
+
parsedType: d(e)
|
|
1098
|
+
};
|
|
1099
|
+
if (!this["~standard"].async) try {
|
|
1100
|
+
let n = this._parseSync({
|
|
1101
|
+
data: e,
|
|
1102
|
+
path: [],
|
|
1103
|
+
parent: t
|
|
1104
|
+
});
|
|
1105
|
+
return y(n) ? { value: n.value } : { issues: t.common.issues };
|
|
1106
|
+
} catch (e) {
|
|
1107
|
+
e?.message?.toLowerCase()?.includes("encountered") && (this["~standard"].async = !0), t.common = {
|
|
1108
|
+
issues: [],
|
|
1109
|
+
async: !0
|
|
1110
|
+
};
|
|
1111
|
+
}
|
|
1112
|
+
return this._parseAsync({
|
|
1113
|
+
data: e,
|
|
1114
|
+
path: [],
|
|
1115
|
+
parent: t
|
|
1116
|
+
}).then((e) => y(e) ? { value: e.value } : { issues: t.common.issues });
|
|
1117
|
+
}
|
|
1118
|
+
async parseAsync(e, t) {
|
|
1119
|
+
let n = await this.safeParseAsync(e, t);
|
|
1120
|
+
if (n.success) return n.data;
|
|
1121
|
+
throw n.error;
|
|
1122
|
+
}
|
|
1123
|
+
async safeParseAsync(e, t) {
|
|
1124
|
+
let n = {
|
|
1125
|
+
common: {
|
|
1126
|
+
issues: [],
|
|
1127
|
+
contextualErrorMap: t?.errorMap,
|
|
1128
|
+
async: !0
|
|
1129
|
+
},
|
|
1130
|
+
path: t?.path || [],
|
|
1131
|
+
schemaErrorMap: this._def.errorMap,
|
|
1132
|
+
parent: null,
|
|
1133
|
+
data: e,
|
|
1134
|
+
parsedType: d(e)
|
|
1135
|
+
}, r = this._parse({
|
|
1136
|
+
data: e,
|
|
1137
|
+
path: n.path,
|
|
1138
|
+
parent: n
|
|
1139
|
+
});
|
|
1140
|
+
return me(n, await (b(r) ? r : Promise.resolve(r)));
|
|
1141
|
+
}
|
|
1142
|
+
refine(e, t) {
|
|
1143
|
+
let n = (e) => typeof t == "string" || t === void 0 ? { message: t } : typeof t == "function" ? t(e) : t;
|
|
1144
|
+
return this._refinement((t, r) => {
|
|
1145
|
+
let i = e(t), a = () => r.addIssue({
|
|
1146
|
+
code: f.custom,
|
|
1147
|
+
...n(t)
|
|
1148
|
+
});
|
|
1149
|
+
return typeof Promise < "u" && i instanceof Promise ? i.then((e) => e ? !0 : (a(), !1)) : i ? !0 : (a(), !1);
|
|
1150
|
+
});
|
|
1151
|
+
}
|
|
1152
|
+
refinement(e, t) {
|
|
1153
|
+
return this._refinement((n, r) => e(n) ? !0 : (r.addIssue(typeof t == "function" ? t(n, r) : t), !1));
|
|
1154
|
+
}
|
|
1155
|
+
_refinement(e) {
|
|
1156
|
+
return new W({
|
|
1157
|
+
schema: this,
|
|
1158
|
+
typeName: Z.ZodEffects,
|
|
1159
|
+
effect: {
|
|
1160
|
+
type: "refinement",
|
|
1161
|
+
refinement: e
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
}
|
|
1165
|
+
superRefine(e) {
|
|
1166
|
+
return this._refinement(e);
|
|
1167
|
+
}
|
|
1168
|
+
constructor(e) {
|
|
1169
|
+
this.spa = this.safeParseAsync, this._def = e, this.parse = this.parse.bind(this), this.safeParse = this.safeParse.bind(this), this.parseAsync = this.parseAsync.bind(this), this.safeParseAsync = this.safeParseAsync.bind(this), this.spa = this.spa.bind(this), this.refine = this.refine.bind(this), this.refinement = this.refinement.bind(this), this.superRefine = this.superRefine.bind(this), this.optional = this.optional.bind(this), this.nullable = this.nullable.bind(this), this.nullish = this.nullish.bind(this), this.array = this.array.bind(this), this.promise = this.promise.bind(this), this.or = this.or.bind(this), this.and = this.and.bind(this), this.transform = this.transform.bind(this), this.brand = this.brand.bind(this), this.default = this.default.bind(this), this.catch = this.catch.bind(this), this.describe = this.describe.bind(this), this.pipe = this.pipe.bind(this), this.readonly = this.readonly.bind(this), this.isNullable = this.isNullable.bind(this), this.isOptional = this.isOptional.bind(this), this["~standard"] = {
|
|
1170
|
+
version: 1,
|
|
1171
|
+
vendor: "zod",
|
|
1172
|
+
validate: (e) => this["~validate"](e)
|
|
1173
|
+
};
|
|
1174
|
+
}
|
|
1175
|
+
optional() {
|
|
1176
|
+
return G.create(this, this._def);
|
|
1177
|
+
}
|
|
1178
|
+
nullable() {
|
|
1179
|
+
return K.create(this, this._def);
|
|
1180
|
+
}
|
|
1181
|
+
nullish() {
|
|
1182
|
+
return this.nullable().optional();
|
|
1183
|
+
}
|
|
1184
|
+
array() {
|
|
1185
|
+
return M.create(this);
|
|
1186
|
+
}
|
|
1187
|
+
promise() {
|
|
1188
|
+
return U.create(this, this._def);
|
|
1189
|
+
}
|
|
1190
|
+
or(e) {
|
|
1191
|
+
return F.create([this, e], this._def);
|
|
1192
|
+
}
|
|
1193
|
+
and(e) {
|
|
1194
|
+
return L.create(this, e, this._def);
|
|
1195
|
+
}
|
|
1196
|
+
transform(e) {
|
|
1197
|
+
return new W({
|
|
1198
|
+
...C(this._def),
|
|
1199
|
+
schema: this,
|
|
1200
|
+
typeName: Z.ZodEffects,
|
|
1201
|
+
effect: {
|
|
1202
|
+
type: "transform",
|
|
1203
|
+
transform: e
|
|
1204
|
+
}
|
|
1205
|
+
});
|
|
1206
|
+
}
|
|
1207
|
+
default(e) {
|
|
1208
|
+
let t = typeof e == "function" ? e : () => e;
|
|
1209
|
+
return new q({
|
|
1210
|
+
...C(this._def),
|
|
1211
|
+
innerType: this,
|
|
1212
|
+
defaultValue: t,
|
|
1213
|
+
typeName: Z.ZodDefault
|
|
1214
|
+
});
|
|
1215
|
+
}
|
|
1216
|
+
brand() {
|
|
1217
|
+
return new Qe({
|
|
1218
|
+
typeName: Z.ZodBranded,
|
|
1219
|
+
type: this,
|
|
1220
|
+
...C(this._def)
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1223
|
+
catch(e) {
|
|
1224
|
+
let t = typeof e == "function" ? e : () => e;
|
|
1225
|
+
return new J({
|
|
1226
|
+
...C(this._def),
|
|
1227
|
+
innerType: this,
|
|
1228
|
+
catchValue: t,
|
|
1229
|
+
typeName: Z.ZodCatch
|
|
1230
|
+
});
|
|
1231
|
+
}
|
|
1232
|
+
describe(e) {
|
|
1233
|
+
let t = this.constructor;
|
|
1234
|
+
return new t({
|
|
1235
|
+
...this._def,
|
|
1236
|
+
description: e
|
|
1237
|
+
});
|
|
1238
|
+
}
|
|
1239
|
+
pipe(e) {
|
|
1240
|
+
return $e.create(this, e);
|
|
1241
|
+
}
|
|
1242
|
+
readonly() {
|
|
1243
|
+
return X.create(this);
|
|
1244
|
+
}
|
|
1245
|
+
isOptional() {
|
|
1246
|
+
return this.safeParse(void 0).success;
|
|
1247
|
+
}
|
|
1248
|
+
isNullable() {
|
|
1249
|
+
return this.safeParse(null).success;
|
|
1250
|
+
}
|
|
1251
|
+
}, he = /^c[^\s-]{8,}$/i, ge = /^[0-9a-z]+$/, _e = /^[0-9A-HJKMNP-TV-Z]{26}$/i, ve = /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i, ye = /^[a-z0-9_-]{21}$/i, be = /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/, xe = /^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/, Se = /^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i, Ce = "^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", we, Te = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/, Ee = /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/, De = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/, Oe = /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/, ke = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/, Ae = /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/, je = "((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))", Me = RegExp(`^${je}$`);
|
|
1252
|
+
function Ne(e) {
|
|
1253
|
+
let t = "[0-5]\\d";
|
|
1254
|
+
e.precision ? t = `${t}\\.\\d{${e.precision}}` : e.precision ?? (t = `${t}(\\.\\d+)?`);
|
|
1255
|
+
let n = e.precision ? "+" : "?";
|
|
1256
|
+
return `([01]\\d|2[0-3]):[0-5]\\d(:${t})${n}`;
|
|
1257
|
+
}
|
|
1258
|
+
function Pe(e) {
|
|
1259
|
+
return RegExp(`^${Ne(e)}$`);
|
|
1260
|
+
}
|
|
1261
|
+
function Fe(e) {
|
|
1262
|
+
let t = `${je}T${Ne(e)}`, n = [];
|
|
1263
|
+
return n.push(e.local ? "Z?" : "Z"), e.offset && n.push("([+-]\\d{2}:?\\d{2})"), t = `${t}(${n.join("|")})`, RegExp(`^${t}$`);
|
|
1264
|
+
}
|
|
1265
|
+
function Ie(e, t) {
|
|
1266
|
+
return !!((t === "v4" || !t) && Te.test(e) || (t === "v6" || !t) && De.test(e));
|
|
1267
|
+
}
|
|
1268
|
+
function Le(e, t) {
|
|
1269
|
+
if (!be.test(e)) return !1;
|
|
1270
|
+
try {
|
|
1271
|
+
let [n] = e.split(".");
|
|
1272
|
+
if (!n) return !1;
|
|
1273
|
+
let r = n.replace(/-/g, "+").replace(/_/g, "/").padEnd(n.length + (4 - n.length % 4) % 4, "="), i = JSON.parse(atob(r));
|
|
1274
|
+
return !(typeof i != "object" || !i || "typ" in i && i?.typ !== "JWT" || !i.alg || t && i.alg !== t);
|
|
1275
|
+
} catch {
|
|
1276
|
+
return !1;
|
|
1277
|
+
}
|
|
1278
|
+
}
|
|
1279
|
+
function Re(e, t) {
|
|
1280
|
+
return !!((t === "v4" || !t) && Ee.test(e) || (t === "v6" || !t) && Oe.test(e));
|
|
1281
|
+
}
|
|
1282
|
+
var T = class e extends w {
|
|
1283
|
+
_parse(e) {
|
|
1284
|
+
if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== u.string) {
|
|
1285
|
+
let t = this._getOrReturnCtx(e);
|
|
1286
|
+
return h(t, {
|
|
1287
|
+
code: f.invalid_type,
|
|
1288
|
+
expected: u.string,
|
|
1289
|
+
received: t.parsedType
|
|
1290
|
+
}), _;
|
|
1291
|
+
}
|
|
1292
|
+
let t = new g(), n;
|
|
1293
|
+
for (let r of this._def.checks) if (r.kind === "min") e.data.length < r.value && (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1294
|
+
code: f.too_small,
|
|
1295
|
+
minimum: r.value,
|
|
1296
|
+
type: "string",
|
|
1297
|
+
inclusive: !0,
|
|
1298
|
+
exact: !1,
|
|
1299
|
+
message: r.message
|
|
1300
|
+
}), t.dirty());
|
|
1301
|
+
else if (r.kind === "max") e.data.length > r.value && (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1302
|
+
code: f.too_big,
|
|
1303
|
+
maximum: r.value,
|
|
1304
|
+
type: "string",
|
|
1305
|
+
inclusive: !0,
|
|
1306
|
+
exact: !1,
|
|
1307
|
+
message: r.message
|
|
1308
|
+
}), t.dirty());
|
|
1309
|
+
else if (r.kind === "length") {
|
|
1310
|
+
let i = e.data.length > r.value, a = e.data.length < r.value;
|
|
1311
|
+
(i || a) && (n = this._getOrReturnCtx(e, n), i ? h(n, {
|
|
1312
|
+
code: f.too_big,
|
|
1313
|
+
maximum: r.value,
|
|
1314
|
+
type: "string",
|
|
1315
|
+
inclusive: !0,
|
|
1316
|
+
exact: !0,
|
|
1317
|
+
message: r.message
|
|
1318
|
+
}) : a && h(n, {
|
|
1319
|
+
code: f.too_small,
|
|
1320
|
+
minimum: r.value,
|
|
1321
|
+
type: "string",
|
|
1322
|
+
inclusive: !0,
|
|
1323
|
+
exact: !0,
|
|
1324
|
+
message: r.message
|
|
1325
|
+
}), t.dirty());
|
|
1326
|
+
} else if (r.kind === "email") Se.test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1327
|
+
validation: "email",
|
|
1328
|
+
code: f.invalid_string,
|
|
1329
|
+
message: r.message
|
|
1330
|
+
}), t.dirty());
|
|
1331
|
+
else if (r.kind === "emoji") we ||= new RegExp(Ce, "u"), we.test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1332
|
+
validation: "emoji",
|
|
1333
|
+
code: f.invalid_string,
|
|
1334
|
+
message: r.message
|
|
1335
|
+
}), t.dirty());
|
|
1336
|
+
else if (r.kind === "uuid") ve.test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1337
|
+
validation: "uuid",
|
|
1338
|
+
code: f.invalid_string,
|
|
1339
|
+
message: r.message
|
|
1340
|
+
}), t.dirty());
|
|
1341
|
+
else if (r.kind === "nanoid") ye.test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1342
|
+
validation: "nanoid",
|
|
1343
|
+
code: f.invalid_string,
|
|
1344
|
+
message: r.message
|
|
1345
|
+
}), t.dirty());
|
|
1346
|
+
else if (r.kind === "cuid") he.test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1347
|
+
validation: "cuid",
|
|
1348
|
+
code: f.invalid_string,
|
|
1349
|
+
message: r.message
|
|
1350
|
+
}), t.dirty());
|
|
1351
|
+
else if (r.kind === "cuid2") ge.test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1352
|
+
validation: "cuid2",
|
|
1353
|
+
code: f.invalid_string,
|
|
1354
|
+
message: r.message
|
|
1355
|
+
}), t.dirty());
|
|
1356
|
+
else if (r.kind === "ulid") _e.test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1357
|
+
validation: "ulid",
|
|
1358
|
+
code: f.invalid_string,
|
|
1359
|
+
message: r.message
|
|
1360
|
+
}), t.dirty());
|
|
1361
|
+
else if (r.kind === "url") try {
|
|
1362
|
+
new URL(e.data);
|
|
1363
|
+
} catch {
|
|
1364
|
+
n = this._getOrReturnCtx(e, n), h(n, {
|
|
1365
|
+
validation: "url",
|
|
1366
|
+
code: f.invalid_string,
|
|
1367
|
+
message: r.message
|
|
1368
|
+
}), t.dirty();
|
|
1369
|
+
}
|
|
1370
|
+
else r.kind === "regex" ? (r.regex.lastIndex = 0, r.regex.test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1371
|
+
validation: "regex",
|
|
1372
|
+
code: f.invalid_string,
|
|
1373
|
+
message: r.message
|
|
1374
|
+
}), t.dirty())) : r.kind === "trim" ? e.data = e.data.trim() : r.kind === "includes" ? e.data.includes(r.value, r.position) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1375
|
+
code: f.invalid_string,
|
|
1376
|
+
validation: {
|
|
1377
|
+
includes: r.value,
|
|
1378
|
+
position: r.position
|
|
1379
|
+
},
|
|
1380
|
+
message: r.message
|
|
1381
|
+
}), t.dirty()) : r.kind === "toLowerCase" ? e.data = e.data.toLowerCase() : r.kind === "toUpperCase" ? e.data = e.data.toUpperCase() : r.kind === "startsWith" ? e.data.startsWith(r.value) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1382
|
+
code: f.invalid_string,
|
|
1383
|
+
validation: { startsWith: r.value },
|
|
1384
|
+
message: r.message
|
|
1385
|
+
}), t.dirty()) : r.kind === "endsWith" ? e.data.endsWith(r.value) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1386
|
+
code: f.invalid_string,
|
|
1387
|
+
validation: { endsWith: r.value },
|
|
1388
|
+
message: r.message
|
|
1389
|
+
}), t.dirty()) : r.kind === "datetime" ? Fe(r).test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1390
|
+
code: f.invalid_string,
|
|
1391
|
+
validation: "datetime",
|
|
1392
|
+
message: r.message
|
|
1393
|
+
}), t.dirty()) : r.kind === "date" ? Me.test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1394
|
+
code: f.invalid_string,
|
|
1395
|
+
validation: "date",
|
|
1396
|
+
message: r.message
|
|
1397
|
+
}), t.dirty()) : r.kind === "time" ? Pe(r).test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1398
|
+
code: f.invalid_string,
|
|
1399
|
+
validation: "time",
|
|
1400
|
+
message: r.message
|
|
1401
|
+
}), t.dirty()) : r.kind === "duration" ? xe.test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1402
|
+
validation: "duration",
|
|
1403
|
+
code: f.invalid_string,
|
|
1404
|
+
message: r.message
|
|
1405
|
+
}), t.dirty()) : r.kind === "ip" ? Ie(e.data, r.version) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1406
|
+
validation: "ip",
|
|
1407
|
+
code: f.invalid_string,
|
|
1408
|
+
message: r.message
|
|
1409
|
+
}), t.dirty()) : r.kind === "jwt" ? Le(e.data, r.alg) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1410
|
+
validation: "jwt",
|
|
1411
|
+
code: f.invalid_string,
|
|
1412
|
+
message: r.message
|
|
1413
|
+
}), t.dirty()) : r.kind === "cidr" ? Re(e.data, r.version) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1414
|
+
validation: "cidr",
|
|
1415
|
+
code: f.invalid_string,
|
|
1416
|
+
message: r.message
|
|
1417
|
+
}), t.dirty()) : r.kind === "base64" ? ke.test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1418
|
+
validation: "base64",
|
|
1419
|
+
code: f.invalid_string,
|
|
1420
|
+
message: r.message
|
|
1421
|
+
}), t.dirty()) : r.kind === "base64url" ? Ae.test(e.data) || (n = this._getOrReturnCtx(e, n), h(n, {
|
|
1422
|
+
validation: "base64url",
|
|
1423
|
+
code: f.invalid_string,
|
|
1424
|
+
message: r.message
|
|
1425
|
+
}), t.dirty()) : l.assertNever(r);
|
|
1426
|
+
return {
|
|
1427
|
+
status: t.value,
|
|
1428
|
+
value: e.data
|
|
1429
|
+
};
|
|
1430
|
+
}
|
|
1431
|
+
_regex(e, t, n) {
|
|
1432
|
+
return this.refinement((t) => e.test(t), {
|
|
1433
|
+
validation: t,
|
|
1434
|
+
code: f.invalid_string,
|
|
1435
|
+
...x.errToObj(n)
|
|
1436
|
+
});
|
|
1437
|
+
}
|
|
1438
|
+
_addCheck(t) {
|
|
1439
|
+
return new e({
|
|
1440
|
+
...this._def,
|
|
1441
|
+
checks: [...this._def.checks, t]
|
|
1442
|
+
});
|
|
1443
|
+
}
|
|
1444
|
+
email(e) {
|
|
1445
|
+
return this._addCheck({
|
|
1446
|
+
kind: "email",
|
|
1447
|
+
...x.errToObj(e)
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
url(e) {
|
|
1451
|
+
return this._addCheck({
|
|
1452
|
+
kind: "url",
|
|
1453
|
+
...x.errToObj(e)
|
|
1454
|
+
});
|
|
1455
|
+
}
|
|
1456
|
+
emoji(e) {
|
|
1457
|
+
return this._addCheck({
|
|
1458
|
+
kind: "emoji",
|
|
1459
|
+
...x.errToObj(e)
|
|
1460
|
+
});
|
|
1461
|
+
}
|
|
1462
|
+
uuid(e) {
|
|
1463
|
+
return this._addCheck({
|
|
1464
|
+
kind: "uuid",
|
|
1465
|
+
...x.errToObj(e)
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
nanoid(e) {
|
|
1469
|
+
return this._addCheck({
|
|
1470
|
+
kind: "nanoid",
|
|
1471
|
+
...x.errToObj(e)
|
|
1472
|
+
});
|
|
1473
|
+
}
|
|
1474
|
+
cuid(e) {
|
|
1475
|
+
return this._addCheck({
|
|
1476
|
+
kind: "cuid",
|
|
1477
|
+
...x.errToObj(e)
|
|
1478
|
+
});
|
|
1479
|
+
}
|
|
1480
|
+
cuid2(e) {
|
|
1481
|
+
return this._addCheck({
|
|
1482
|
+
kind: "cuid2",
|
|
1483
|
+
...x.errToObj(e)
|
|
1484
|
+
});
|
|
1485
|
+
}
|
|
1486
|
+
ulid(e) {
|
|
1487
|
+
return this._addCheck({
|
|
1488
|
+
kind: "ulid",
|
|
1489
|
+
...x.errToObj(e)
|
|
1490
|
+
});
|
|
1491
|
+
}
|
|
1492
|
+
base64(e) {
|
|
1493
|
+
return this._addCheck({
|
|
1494
|
+
kind: "base64",
|
|
1495
|
+
...x.errToObj(e)
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1498
|
+
base64url(e) {
|
|
1499
|
+
return this._addCheck({
|
|
1500
|
+
kind: "base64url",
|
|
1501
|
+
...x.errToObj(e)
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
jwt(e) {
|
|
1505
|
+
return this._addCheck({
|
|
1506
|
+
kind: "jwt",
|
|
1507
|
+
...x.errToObj(e)
|
|
1508
|
+
});
|
|
1509
|
+
}
|
|
1510
|
+
ip(e) {
|
|
1511
|
+
return this._addCheck({
|
|
1512
|
+
kind: "ip",
|
|
1513
|
+
...x.errToObj(e)
|
|
1514
|
+
});
|
|
1515
|
+
}
|
|
1516
|
+
cidr(e) {
|
|
1517
|
+
return this._addCheck({
|
|
1518
|
+
kind: "cidr",
|
|
1519
|
+
...x.errToObj(e)
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
datetime(e) {
|
|
1523
|
+
return typeof e == "string" ? this._addCheck({
|
|
1524
|
+
kind: "datetime",
|
|
1525
|
+
precision: null,
|
|
1526
|
+
offset: !1,
|
|
1527
|
+
local: !1,
|
|
1528
|
+
message: e
|
|
1529
|
+
}) : this._addCheck({
|
|
1530
|
+
kind: "datetime",
|
|
1531
|
+
precision: e?.precision === void 0 ? null : e?.precision,
|
|
1532
|
+
offset: e?.offset ?? !1,
|
|
1533
|
+
local: e?.local ?? !1,
|
|
1534
|
+
...x.errToObj(e?.message)
|
|
1535
|
+
});
|
|
1536
|
+
}
|
|
1537
|
+
date(e) {
|
|
1538
|
+
return this._addCheck({
|
|
1539
|
+
kind: "date",
|
|
1540
|
+
message: e
|
|
1541
|
+
});
|
|
1542
|
+
}
|
|
1543
|
+
time(e) {
|
|
1544
|
+
return typeof e == "string" ? this._addCheck({
|
|
1545
|
+
kind: "time",
|
|
1546
|
+
precision: null,
|
|
1547
|
+
message: e
|
|
1548
|
+
}) : this._addCheck({
|
|
1549
|
+
kind: "time",
|
|
1550
|
+
precision: e?.precision === void 0 ? null : e?.precision,
|
|
1551
|
+
...x.errToObj(e?.message)
|
|
1552
|
+
});
|
|
1553
|
+
}
|
|
1554
|
+
duration(e) {
|
|
1555
|
+
return this._addCheck({
|
|
1556
|
+
kind: "duration",
|
|
1557
|
+
...x.errToObj(e)
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
regex(e, t) {
|
|
1561
|
+
return this._addCheck({
|
|
1562
|
+
kind: "regex",
|
|
1563
|
+
regex: e,
|
|
1564
|
+
...x.errToObj(t)
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
includes(e, t) {
|
|
1568
|
+
return this._addCheck({
|
|
1569
|
+
kind: "includes",
|
|
1570
|
+
value: e,
|
|
1571
|
+
position: t?.position,
|
|
1572
|
+
...x.errToObj(t?.message)
|
|
1573
|
+
});
|
|
1574
|
+
}
|
|
1575
|
+
startsWith(e, t) {
|
|
1576
|
+
return this._addCheck({
|
|
1577
|
+
kind: "startsWith",
|
|
1578
|
+
value: e,
|
|
1579
|
+
...x.errToObj(t)
|
|
1580
|
+
});
|
|
1581
|
+
}
|
|
1582
|
+
endsWith(e, t) {
|
|
1583
|
+
return this._addCheck({
|
|
1584
|
+
kind: "endsWith",
|
|
1585
|
+
value: e,
|
|
1586
|
+
...x.errToObj(t)
|
|
1587
|
+
});
|
|
1588
|
+
}
|
|
1589
|
+
min(e, t) {
|
|
1590
|
+
return this._addCheck({
|
|
1591
|
+
kind: "min",
|
|
1592
|
+
value: e,
|
|
1593
|
+
...x.errToObj(t)
|
|
1594
|
+
});
|
|
1595
|
+
}
|
|
1596
|
+
max(e, t) {
|
|
1597
|
+
return this._addCheck({
|
|
1598
|
+
kind: "max",
|
|
1599
|
+
value: e,
|
|
1600
|
+
...x.errToObj(t)
|
|
1601
|
+
});
|
|
1602
|
+
}
|
|
1603
|
+
length(e, t) {
|
|
1604
|
+
return this._addCheck({
|
|
1605
|
+
kind: "length",
|
|
1606
|
+
value: e,
|
|
1607
|
+
...x.errToObj(t)
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
nonempty(e) {
|
|
1611
|
+
return this.min(1, x.errToObj(e));
|
|
1612
|
+
}
|
|
1613
|
+
trim() {
|
|
1614
|
+
return new e({
|
|
1615
|
+
...this._def,
|
|
1616
|
+
checks: [...this._def.checks, { kind: "trim" }]
|
|
1617
|
+
});
|
|
1618
|
+
}
|
|
1619
|
+
toLowerCase() {
|
|
1620
|
+
return new e({
|
|
1621
|
+
...this._def,
|
|
1622
|
+
checks: [...this._def.checks, { kind: "toLowerCase" }]
|
|
1623
|
+
});
|
|
1624
|
+
}
|
|
1625
|
+
toUpperCase() {
|
|
1626
|
+
return new e({
|
|
1627
|
+
...this._def,
|
|
1628
|
+
checks: [...this._def.checks, { kind: "toUpperCase" }]
|
|
1629
|
+
});
|
|
1630
|
+
}
|
|
1631
|
+
get isDatetime() {
|
|
1632
|
+
return !!this._def.checks.find((e) => e.kind === "datetime");
|
|
1633
|
+
}
|
|
1634
|
+
get isDate() {
|
|
1635
|
+
return !!this._def.checks.find((e) => e.kind === "date");
|
|
1636
|
+
}
|
|
1637
|
+
get isTime() {
|
|
1638
|
+
return !!this._def.checks.find((e) => e.kind === "time");
|
|
1639
|
+
}
|
|
1640
|
+
get isDuration() {
|
|
1641
|
+
return !!this._def.checks.find((e) => e.kind === "duration");
|
|
1642
|
+
}
|
|
1643
|
+
get isEmail() {
|
|
1644
|
+
return !!this._def.checks.find((e) => e.kind === "email");
|
|
1645
|
+
}
|
|
1646
|
+
get isURL() {
|
|
1647
|
+
return !!this._def.checks.find((e) => e.kind === "url");
|
|
1648
|
+
}
|
|
1649
|
+
get isEmoji() {
|
|
1650
|
+
return !!this._def.checks.find((e) => e.kind === "emoji");
|
|
1651
|
+
}
|
|
1652
|
+
get isUUID() {
|
|
1653
|
+
return !!this._def.checks.find((e) => e.kind === "uuid");
|
|
1654
|
+
}
|
|
1655
|
+
get isNANOID() {
|
|
1656
|
+
return !!this._def.checks.find((e) => e.kind === "nanoid");
|
|
1657
|
+
}
|
|
1658
|
+
get isCUID() {
|
|
1659
|
+
return !!this._def.checks.find((e) => e.kind === "cuid");
|
|
1660
|
+
}
|
|
1661
|
+
get isCUID2() {
|
|
1662
|
+
return !!this._def.checks.find((e) => e.kind === "cuid2");
|
|
1663
|
+
}
|
|
1664
|
+
get isULID() {
|
|
1665
|
+
return !!this._def.checks.find((e) => e.kind === "ulid");
|
|
1666
|
+
}
|
|
1667
|
+
get isIP() {
|
|
1668
|
+
return !!this._def.checks.find((e) => e.kind === "ip");
|
|
1669
|
+
}
|
|
1670
|
+
get isCIDR() {
|
|
1671
|
+
return !!this._def.checks.find((e) => e.kind === "cidr");
|
|
1672
|
+
}
|
|
1673
|
+
get isBase64() {
|
|
1674
|
+
return !!this._def.checks.find((e) => e.kind === "base64");
|
|
1675
|
+
}
|
|
1676
|
+
get isBase64url() {
|
|
1677
|
+
return !!this._def.checks.find((e) => e.kind === "base64url");
|
|
1678
|
+
}
|
|
1679
|
+
get minLength() {
|
|
1680
|
+
let e = null;
|
|
1681
|
+
for (let t of this._def.checks) t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1682
|
+
return e;
|
|
1683
|
+
}
|
|
1684
|
+
get maxLength() {
|
|
1685
|
+
let e = null;
|
|
1686
|
+
for (let t of this._def.checks) t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1687
|
+
return e;
|
|
1688
|
+
}
|
|
1689
|
+
};
|
|
1690
|
+
T.create = (e) => new T({
|
|
1691
|
+
checks: [],
|
|
1692
|
+
typeName: Z.ZodString,
|
|
1693
|
+
coerce: e?.coerce ?? !1,
|
|
1694
|
+
...C(e)
|
|
1695
|
+
});
|
|
1696
|
+
function ze(e, t) {
|
|
1697
|
+
let n = (e.toString().split(".")[1] || "").length, r = (t.toString().split(".")[1] || "").length, i = n > r ? n : r;
|
|
1698
|
+
return Number.parseInt(e.toFixed(i).replace(".", "")) % Number.parseInt(t.toFixed(i).replace(".", "")) / 10 ** i;
|
|
1699
|
+
}
|
|
1700
|
+
var E = class e extends w {
|
|
1701
|
+
constructor() {
|
|
1702
|
+
super(...arguments), this.min = this.gte, this.max = this.lte, this.step = this.multipleOf;
|
|
1703
|
+
}
|
|
1704
|
+
_parse(e) {
|
|
1705
|
+
if (this._def.coerce && (e.data = Number(e.data)), this._getType(e) !== u.number) {
|
|
1706
|
+
let t = this._getOrReturnCtx(e);
|
|
1707
|
+
return h(t, {
|
|
1708
|
+
code: f.invalid_type,
|
|
1709
|
+
expected: u.number,
|
|
1710
|
+
received: t.parsedType
|
|
1711
|
+
}), _;
|
|
1712
|
+
}
|
|
1713
|
+
let t, n = new g();
|
|
1714
|
+
for (let r of this._def.checks) r.kind === "int" ? l.isInteger(e.data) || (t = this._getOrReturnCtx(e, t), h(t, {
|
|
1715
|
+
code: f.invalid_type,
|
|
1716
|
+
expected: "integer",
|
|
1717
|
+
received: "float",
|
|
1718
|
+
message: r.message
|
|
1719
|
+
}), n.dirty()) : r.kind === "min" ? (r.inclusive ? e.data < r.value : e.data <= r.value) && (t = this._getOrReturnCtx(e, t), h(t, {
|
|
1720
|
+
code: f.too_small,
|
|
1721
|
+
minimum: r.value,
|
|
1722
|
+
type: "number",
|
|
1723
|
+
inclusive: r.inclusive,
|
|
1724
|
+
exact: !1,
|
|
1725
|
+
message: r.message
|
|
1726
|
+
}), n.dirty()) : r.kind === "max" ? (r.inclusive ? e.data > r.value : e.data >= r.value) && (t = this._getOrReturnCtx(e, t), h(t, {
|
|
1727
|
+
code: f.too_big,
|
|
1728
|
+
maximum: r.value,
|
|
1729
|
+
type: "number",
|
|
1730
|
+
inclusive: r.inclusive,
|
|
1731
|
+
exact: !1,
|
|
1732
|
+
message: r.message
|
|
1733
|
+
}), n.dirty()) : r.kind === "multipleOf" ? ze(e.data, r.value) !== 0 && (t = this._getOrReturnCtx(e, t), h(t, {
|
|
1734
|
+
code: f.not_multiple_of,
|
|
1735
|
+
multipleOf: r.value,
|
|
1736
|
+
message: r.message
|
|
1737
|
+
}), n.dirty()) : r.kind === "finite" ? Number.isFinite(e.data) || (t = this._getOrReturnCtx(e, t), h(t, {
|
|
1738
|
+
code: f.not_finite,
|
|
1739
|
+
message: r.message
|
|
1740
|
+
}), n.dirty()) : l.assertNever(r);
|
|
1741
|
+
return {
|
|
1742
|
+
status: n.value,
|
|
1743
|
+
value: e.data
|
|
1744
|
+
};
|
|
1745
|
+
}
|
|
1746
|
+
gte(e, t) {
|
|
1747
|
+
return this.setLimit("min", e, !0, x.toString(t));
|
|
1748
|
+
}
|
|
1749
|
+
gt(e, t) {
|
|
1750
|
+
return this.setLimit("min", e, !1, x.toString(t));
|
|
1751
|
+
}
|
|
1752
|
+
lte(e, t) {
|
|
1753
|
+
return this.setLimit("max", e, !0, x.toString(t));
|
|
1754
|
+
}
|
|
1755
|
+
lt(e, t) {
|
|
1756
|
+
return this.setLimit("max", e, !1, x.toString(t));
|
|
1757
|
+
}
|
|
1758
|
+
setLimit(t, n, r, i) {
|
|
1759
|
+
return new e({
|
|
1760
|
+
...this._def,
|
|
1761
|
+
checks: [...this._def.checks, {
|
|
1762
|
+
kind: t,
|
|
1763
|
+
value: n,
|
|
1764
|
+
inclusive: r,
|
|
1765
|
+
message: x.toString(i)
|
|
1766
|
+
}]
|
|
1767
|
+
});
|
|
1768
|
+
}
|
|
1769
|
+
_addCheck(t) {
|
|
1770
|
+
return new e({
|
|
1771
|
+
...this._def,
|
|
1772
|
+
checks: [...this._def.checks, t]
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
int(e) {
|
|
1776
|
+
return this._addCheck({
|
|
1777
|
+
kind: "int",
|
|
1778
|
+
message: x.toString(e)
|
|
1779
|
+
});
|
|
1780
|
+
}
|
|
1781
|
+
positive(e) {
|
|
1782
|
+
return this._addCheck({
|
|
1783
|
+
kind: "min",
|
|
1784
|
+
value: 0,
|
|
1785
|
+
inclusive: !1,
|
|
1786
|
+
message: x.toString(e)
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1789
|
+
negative(e) {
|
|
1790
|
+
return this._addCheck({
|
|
1791
|
+
kind: "max",
|
|
1792
|
+
value: 0,
|
|
1793
|
+
inclusive: !1,
|
|
1794
|
+
message: x.toString(e)
|
|
1795
|
+
});
|
|
1796
|
+
}
|
|
1797
|
+
nonpositive(e) {
|
|
1798
|
+
return this._addCheck({
|
|
1799
|
+
kind: "max",
|
|
1800
|
+
value: 0,
|
|
1801
|
+
inclusive: !0,
|
|
1802
|
+
message: x.toString(e)
|
|
1803
|
+
});
|
|
1804
|
+
}
|
|
1805
|
+
nonnegative(e) {
|
|
1806
|
+
return this._addCheck({
|
|
1807
|
+
kind: "min",
|
|
1808
|
+
value: 0,
|
|
1809
|
+
inclusive: !0,
|
|
1810
|
+
message: x.toString(e)
|
|
1811
|
+
});
|
|
1812
|
+
}
|
|
1813
|
+
multipleOf(e, t) {
|
|
1814
|
+
return this._addCheck({
|
|
1815
|
+
kind: "multipleOf",
|
|
1816
|
+
value: e,
|
|
1817
|
+
message: x.toString(t)
|
|
1818
|
+
});
|
|
1819
|
+
}
|
|
1820
|
+
finite(e) {
|
|
1821
|
+
return this._addCheck({
|
|
1822
|
+
kind: "finite",
|
|
1823
|
+
message: x.toString(e)
|
|
1824
|
+
});
|
|
1825
|
+
}
|
|
1826
|
+
safe(e) {
|
|
1827
|
+
return this._addCheck({
|
|
1828
|
+
kind: "min",
|
|
1829
|
+
inclusive: !0,
|
|
1830
|
+
value: -(2 ** 53 - 1),
|
|
1831
|
+
message: x.toString(e)
|
|
1832
|
+
})._addCheck({
|
|
1833
|
+
kind: "max",
|
|
1834
|
+
inclusive: !0,
|
|
1835
|
+
value: 2 ** 53 - 1,
|
|
1836
|
+
message: x.toString(e)
|
|
1837
|
+
});
|
|
1838
|
+
}
|
|
1839
|
+
get minValue() {
|
|
1840
|
+
let e = null;
|
|
1841
|
+
for (let t of this._def.checks) t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1842
|
+
return e;
|
|
1843
|
+
}
|
|
1844
|
+
get maxValue() {
|
|
1845
|
+
let e = null;
|
|
1846
|
+
for (let t of this._def.checks) t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1847
|
+
return e;
|
|
1848
|
+
}
|
|
1849
|
+
get isInt() {
|
|
1850
|
+
return !!this._def.checks.find((e) => e.kind === "int" || e.kind === "multipleOf" && l.isInteger(e.value));
|
|
1851
|
+
}
|
|
1852
|
+
get isFinite() {
|
|
1853
|
+
let e = null, t = null;
|
|
1854
|
+
for (let n of this._def.checks) if (n.kind === "finite" || n.kind === "int" || n.kind === "multipleOf") return !0;
|
|
1855
|
+
else n.kind === "min" ? (t === null || n.value > t) && (t = n.value) : n.kind === "max" && (e === null || n.value < e) && (e = n.value);
|
|
1856
|
+
return Number.isFinite(t) && Number.isFinite(e);
|
|
1857
|
+
}
|
|
1858
|
+
};
|
|
1859
|
+
E.create = (e) => new E({
|
|
1860
|
+
checks: [],
|
|
1861
|
+
typeName: Z.ZodNumber,
|
|
1862
|
+
coerce: e?.coerce || !1,
|
|
1863
|
+
...C(e)
|
|
1864
|
+
});
|
|
1865
|
+
var D = class e extends w {
|
|
1866
|
+
constructor() {
|
|
1867
|
+
super(...arguments), this.min = this.gte, this.max = this.lte;
|
|
1868
|
+
}
|
|
1869
|
+
_parse(e) {
|
|
1870
|
+
if (this._def.coerce) try {
|
|
1871
|
+
e.data = BigInt(e.data);
|
|
1872
|
+
} catch {
|
|
1873
|
+
return this._getInvalidInput(e);
|
|
1874
|
+
}
|
|
1875
|
+
if (this._getType(e) !== u.bigint) return this._getInvalidInput(e);
|
|
1876
|
+
let t, n = new g();
|
|
1877
|
+
for (let r of this._def.checks) r.kind === "min" ? (r.inclusive ? e.data < r.value : e.data <= r.value) && (t = this._getOrReturnCtx(e, t), h(t, {
|
|
1878
|
+
code: f.too_small,
|
|
1879
|
+
type: "bigint",
|
|
1880
|
+
minimum: r.value,
|
|
1881
|
+
inclusive: r.inclusive,
|
|
1882
|
+
message: r.message
|
|
1883
|
+
}), n.dirty()) : r.kind === "max" ? (r.inclusive ? e.data > r.value : e.data >= r.value) && (t = this._getOrReturnCtx(e, t), h(t, {
|
|
1884
|
+
code: f.too_big,
|
|
1885
|
+
type: "bigint",
|
|
1886
|
+
maximum: r.value,
|
|
1887
|
+
inclusive: r.inclusive,
|
|
1888
|
+
message: r.message
|
|
1889
|
+
}), n.dirty()) : r.kind === "multipleOf" ? e.data % r.value !== BigInt(0) && (t = this._getOrReturnCtx(e, t), h(t, {
|
|
1890
|
+
code: f.not_multiple_of,
|
|
1891
|
+
multipleOf: r.value,
|
|
1892
|
+
message: r.message
|
|
1893
|
+
}), n.dirty()) : l.assertNever(r);
|
|
1894
|
+
return {
|
|
1895
|
+
status: n.value,
|
|
1896
|
+
value: e.data
|
|
1897
|
+
};
|
|
1898
|
+
}
|
|
1899
|
+
_getInvalidInput(e) {
|
|
1900
|
+
let t = this._getOrReturnCtx(e);
|
|
1901
|
+
return h(t, {
|
|
1902
|
+
code: f.invalid_type,
|
|
1903
|
+
expected: u.bigint,
|
|
1904
|
+
received: t.parsedType
|
|
1905
|
+
}), _;
|
|
1906
|
+
}
|
|
1907
|
+
gte(e, t) {
|
|
1908
|
+
return this.setLimit("min", e, !0, x.toString(t));
|
|
1909
|
+
}
|
|
1910
|
+
gt(e, t) {
|
|
1911
|
+
return this.setLimit("min", e, !1, x.toString(t));
|
|
1912
|
+
}
|
|
1913
|
+
lte(e, t) {
|
|
1914
|
+
return this.setLimit("max", e, !0, x.toString(t));
|
|
1915
|
+
}
|
|
1916
|
+
lt(e, t) {
|
|
1917
|
+
return this.setLimit("max", e, !1, x.toString(t));
|
|
1918
|
+
}
|
|
1919
|
+
setLimit(t, n, r, i) {
|
|
1920
|
+
return new e({
|
|
1921
|
+
...this._def,
|
|
1922
|
+
checks: [...this._def.checks, {
|
|
1923
|
+
kind: t,
|
|
1924
|
+
value: n,
|
|
1925
|
+
inclusive: r,
|
|
1926
|
+
message: x.toString(i)
|
|
1927
|
+
}]
|
|
1928
|
+
});
|
|
1929
|
+
}
|
|
1930
|
+
_addCheck(t) {
|
|
1931
|
+
return new e({
|
|
1932
|
+
...this._def,
|
|
1933
|
+
checks: [...this._def.checks, t]
|
|
1934
|
+
});
|
|
1935
|
+
}
|
|
1936
|
+
positive(e) {
|
|
1937
|
+
return this._addCheck({
|
|
1938
|
+
kind: "min",
|
|
1939
|
+
value: BigInt(0),
|
|
1940
|
+
inclusive: !1,
|
|
1941
|
+
message: x.toString(e)
|
|
1942
|
+
});
|
|
1943
|
+
}
|
|
1944
|
+
negative(e) {
|
|
1945
|
+
return this._addCheck({
|
|
1946
|
+
kind: "max",
|
|
1947
|
+
value: BigInt(0),
|
|
1948
|
+
inclusive: !1,
|
|
1949
|
+
message: x.toString(e)
|
|
1950
|
+
});
|
|
1951
|
+
}
|
|
1952
|
+
nonpositive(e) {
|
|
1953
|
+
return this._addCheck({
|
|
1954
|
+
kind: "max",
|
|
1955
|
+
value: BigInt(0),
|
|
1956
|
+
inclusive: !0,
|
|
1957
|
+
message: x.toString(e)
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
1960
|
+
nonnegative(e) {
|
|
1961
|
+
return this._addCheck({
|
|
1962
|
+
kind: "min",
|
|
1963
|
+
value: BigInt(0),
|
|
1964
|
+
inclusive: !0,
|
|
1965
|
+
message: x.toString(e)
|
|
1966
|
+
});
|
|
1967
|
+
}
|
|
1968
|
+
multipleOf(e, t) {
|
|
1969
|
+
return this._addCheck({
|
|
1970
|
+
kind: "multipleOf",
|
|
1971
|
+
value: e,
|
|
1972
|
+
message: x.toString(t)
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1975
|
+
get minValue() {
|
|
1976
|
+
let e = null;
|
|
1977
|
+
for (let t of this._def.checks) t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
1978
|
+
return e;
|
|
1979
|
+
}
|
|
1980
|
+
get maxValue() {
|
|
1981
|
+
let e = null;
|
|
1982
|
+
for (let t of this._def.checks) t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
1983
|
+
return e;
|
|
1984
|
+
}
|
|
1985
|
+
};
|
|
1986
|
+
D.create = (e) => new D({
|
|
1987
|
+
checks: [],
|
|
1988
|
+
typeName: Z.ZodBigInt,
|
|
1989
|
+
coerce: e?.coerce ?? !1,
|
|
1990
|
+
...C(e)
|
|
1991
|
+
});
|
|
1992
|
+
var Be = class extends w {
|
|
1993
|
+
_parse(e) {
|
|
1994
|
+
if (this._def.coerce && (e.data = !!e.data), this._getType(e) !== u.boolean) {
|
|
1995
|
+
let t = this._getOrReturnCtx(e);
|
|
1996
|
+
return h(t, {
|
|
1997
|
+
code: f.invalid_type,
|
|
1998
|
+
expected: u.boolean,
|
|
1999
|
+
received: t.parsedType
|
|
2000
|
+
}), _;
|
|
2001
|
+
}
|
|
2002
|
+
return v(e.data);
|
|
2003
|
+
}
|
|
2004
|
+
};
|
|
2005
|
+
Be.create = (e) => new Be({
|
|
2006
|
+
typeName: Z.ZodBoolean,
|
|
2007
|
+
coerce: e?.coerce || !1,
|
|
2008
|
+
...C(e)
|
|
2009
|
+
});
|
|
2010
|
+
var Ve = class e extends w {
|
|
2011
|
+
_parse(e) {
|
|
2012
|
+
if (this._def.coerce && (e.data = new Date(e.data)), this._getType(e) !== u.date) {
|
|
2013
|
+
let t = this._getOrReturnCtx(e);
|
|
2014
|
+
return h(t, {
|
|
2015
|
+
code: f.invalid_type,
|
|
2016
|
+
expected: u.date,
|
|
2017
|
+
received: t.parsedType
|
|
2018
|
+
}), _;
|
|
2019
|
+
}
|
|
2020
|
+
if (Number.isNaN(e.data.getTime())) return h(this._getOrReturnCtx(e), { code: f.invalid_date }), _;
|
|
2021
|
+
let t = new g(), n;
|
|
2022
|
+
for (let r of this._def.checks) r.kind === "min" ? e.data.getTime() < r.value && (n = this._getOrReturnCtx(e, n), h(n, {
|
|
2023
|
+
code: f.too_small,
|
|
2024
|
+
message: r.message,
|
|
2025
|
+
inclusive: !0,
|
|
2026
|
+
exact: !1,
|
|
2027
|
+
minimum: r.value,
|
|
2028
|
+
type: "date"
|
|
2029
|
+
}), t.dirty()) : r.kind === "max" ? e.data.getTime() > r.value && (n = this._getOrReturnCtx(e, n), h(n, {
|
|
2030
|
+
code: f.too_big,
|
|
2031
|
+
message: r.message,
|
|
2032
|
+
inclusive: !0,
|
|
2033
|
+
exact: !1,
|
|
2034
|
+
maximum: r.value,
|
|
2035
|
+
type: "date"
|
|
2036
|
+
}), t.dirty()) : l.assertNever(r);
|
|
2037
|
+
return {
|
|
2038
|
+
status: t.value,
|
|
2039
|
+
value: new Date(e.data.getTime())
|
|
2040
|
+
};
|
|
2041
|
+
}
|
|
2042
|
+
_addCheck(t) {
|
|
2043
|
+
return new e({
|
|
2044
|
+
...this._def,
|
|
2045
|
+
checks: [...this._def.checks, t]
|
|
2046
|
+
});
|
|
2047
|
+
}
|
|
2048
|
+
min(e, t) {
|
|
2049
|
+
return this._addCheck({
|
|
2050
|
+
kind: "min",
|
|
2051
|
+
value: e.getTime(),
|
|
2052
|
+
message: x.toString(t)
|
|
2053
|
+
});
|
|
2054
|
+
}
|
|
2055
|
+
max(e, t) {
|
|
2056
|
+
return this._addCheck({
|
|
2057
|
+
kind: "max",
|
|
2058
|
+
value: e.getTime(),
|
|
2059
|
+
message: x.toString(t)
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
get minDate() {
|
|
2063
|
+
let e = null;
|
|
2064
|
+
for (let t of this._def.checks) t.kind === "min" && (e === null || t.value > e) && (e = t.value);
|
|
2065
|
+
return e == null ? null : new Date(e);
|
|
2066
|
+
}
|
|
2067
|
+
get maxDate() {
|
|
2068
|
+
let e = null;
|
|
2069
|
+
for (let t of this._def.checks) t.kind === "max" && (e === null || t.value < e) && (e = t.value);
|
|
2070
|
+
return e == null ? null : new Date(e);
|
|
2071
|
+
}
|
|
2072
|
+
};
|
|
2073
|
+
Ve.create = (e) => new Ve({
|
|
2074
|
+
checks: [],
|
|
2075
|
+
coerce: e?.coerce || !1,
|
|
2076
|
+
typeName: Z.ZodDate,
|
|
2077
|
+
...C(e)
|
|
2078
|
+
});
|
|
2079
|
+
var He = class extends w {
|
|
2080
|
+
_parse(e) {
|
|
2081
|
+
if (this._getType(e) !== u.symbol) {
|
|
2082
|
+
let t = this._getOrReturnCtx(e);
|
|
2083
|
+
return h(t, {
|
|
2084
|
+
code: f.invalid_type,
|
|
2085
|
+
expected: u.symbol,
|
|
2086
|
+
received: t.parsedType
|
|
2087
|
+
}), _;
|
|
2088
|
+
}
|
|
2089
|
+
return v(e.data);
|
|
2090
|
+
}
|
|
2091
|
+
};
|
|
2092
|
+
He.create = (e) => new He({
|
|
2093
|
+
typeName: Z.ZodSymbol,
|
|
2094
|
+
...C(e)
|
|
2095
|
+
});
|
|
2096
|
+
var O = class extends w {
|
|
2097
|
+
_parse(e) {
|
|
2098
|
+
if (this._getType(e) !== u.undefined) {
|
|
2099
|
+
let t = this._getOrReturnCtx(e);
|
|
2100
|
+
return h(t, {
|
|
2101
|
+
code: f.invalid_type,
|
|
2102
|
+
expected: u.undefined,
|
|
2103
|
+
received: t.parsedType
|
|
2104
|
+
}), _;
|
|
2105
|
+
}
|
|
2106
|
+
return v(e.data);
|
|
2107
|
+
}
|
|
2108
|
+
};
|
|
2109
|
+
O.create = (e) => new O({
|
|
2110
|
+
typeName: Z.ZodUndefined,
|
|
2111
|
+
...C(e)
|
|
2112
|
+
});
|
|
2113
|
+
var k = class extends w {
|
|
2114
|
+
_parse(e) {
|
|
2115
|
+
if (this._getType(e) !== u.null) {
|
|
2116
|
+
let t = this._getOrReturnCtx(e);
|
|
2117
|
+
return h(t, {
|
|
2118
|
+
code: f.invalid_type,
|
|
2119
|
+
expected: u.null,
|
|
2120
|
+
received: t.parsedType
|
|
2121
|
+
}), _;
|
|
2122
|
+
}
|
|
2123
|
+
return v(e.data);
|
|
2124
|
+
}
|
|
2125
|
+
};
|
|
2126
|
+
k.create = (e) => new k({
|
|
2127
|
+
typeName: Z.ZodNull,
|
|
2128
|
+
...C(e)
|
|
2129
|
+
});
|
|
2130
|
+
var Ue = class extends w {
|
|
2131
|
+
constructor() {
|
|
2132
|
+
super(...arguments), this._any = !0;
|
|
2133
|
+
}
|
|
2134
|
+
_parse(e) {
|
|
2135
|
+
return v(e.data);
|
|
2136
|
+
}
|
|
2137
|
+
};
|
|
2138
|
+
Ue.create = (e) => new Ue({
|
|
2139
|
+
typeName: Z.ZodAny,
|
|
2140
|
+
...C(e)
|
|
2141
|
+
});
|
|
2142
|
+
var A = class extends w {
|
|
2143
|
+
constructor() {
|
|
2144
|
+
super(...arguments), this._unknown = !0;
|
|
2145
|
+
}
|
|
2146
|
+
_parse(e) {
|
|
2147
|
+
return v(e.data);
|
|
2148
|
+
}
|
|
2149
|
+
};
|
|
2150
|
+
A.create = (e) => new A({
|
|
2151
|
+
typeName: Z.ZodUnknown,
|
|
2152
|
+
...C(e)
|
|
2153
|
+
});
|
|
2154
|
+
var j = class extends w {
|
|
2155
|
+
_parse(e) {
|
|
2156
|
+
let t = this._getOrReturnCtx(e);
|
|
2157
|
+
return h(t, {
|
|
2158
|
+
code: f.invalid_type,
|
|
2159
|
+
expected: u.never,
|
|
2160
|
+
received: t.parsedType
|
|
2161
|
+
}), _;
|
|
2162
|
+
}
|
|
2163
|
+
};
|
|
2164
|
+
j.create = (e) => new j({
|
|
2165
|
+
typeName: Z.ZodNever,
|
|
2166
|
+
...C(e)
|
|
2167
|
+
});
|
|
2168
|
+
var We = class extends w {
|
|
2169
|
+
_parse(e) {
|
|
2170
|
+
if (this._getType(e) !== u.undefined) {
|
|
2171
|
+
let t = this._getOrReturnCtx(e);
|
|
2172
|
+
return h(t, {
|
|
2173
|
+
code: f.invalid_type,
|
|
2174
|
+
expected: u.void,
|
|
2175
|
+
received: t.parsedType
|
|
2176
|
+
}), _;
|
|
2177
|
+
}
|
|
2178
|
+
return v(e.data);
|
|
2179
|
+
}
|
|
2180
|
+
};
|
|
2181
|
+
We.create = (e) => new We({
|
|
2182
|
+
typeName: Z.ZodVoid,
|
|
2183
|
+
...C(e)
|
|
2184
|
+
});
|
|
2185
|
+
var M = class e extends w {
|
|
2186
|
+
_parse(e) {
|
|
2187
|
+
let { ctx: t, status: n } = this._processInputParams(e), r = this._def;
|
|
2188
|
+
if (t.parsedType !== u.array) return h(t, {
|
|
2189
|
+
code: f.invalid_type,
|
|
2190
|
+
expected: u.array,
|
|
2191
|
+
received: t.parsedType
|
|
2192
|
+
}), _;
|
|
2193
|
+
if (r.exactLength !== null) {
|
|
2194
|
+
let e = t.data.length > r.exactLength.value, i = t.data.length < r.exactLength.value;
|
|
2195
|
+
(e || i) && (h(t, {
|
|
2196
|
+
code: e ? f.too_big : f.too_small,
|
|
2197
|
+
minimum: i ? r.exactLength.value : void 0,
|
|
2198
|
+
maximum: e ? r.exactLength.value : void 0,
|
|
2199
|
+
type: "array",
|
|
2200
|
+
inclusive: !0,
|
|
2201
|
+
exact: !0,
|
|
2202
|
+
message: r.exactLength.message
|
|
2203
|
+
}), n.dirty());
|
|
2204
|
+
}
|
|
2205
|
+
if (r.minLength !== null && t.data.length < r.minLength.value && (h(t, {
|
|
2206
|
+
code: f.too_small,
|
|
2207
|
+
minimum: r.minLength.value,
|
|
2208
|
+
type: "array",
|
|
2209
|
+
inclusive: !0,
|
|
2210
|
+
exact: !1,
|
|
2211
|
+
message: r.minLength.message
|
|
2212
|
+
}), n.dirty()), r.maxLength !== null && t.data.length > r.maxLength.value && (h(t, {
|
|
2213
|
+
code: f.too_big,
|
|
2214
|
+
maximum: r.maxLength.value,
|
|
2215
|
+
type: "array",
|
|
2216
|
+
inclusive: !0,
|
|
2217
|
+
exact: !1,
|
|
2218
|
+
message: r.maxLength.message
|
|
2219
|
+
}), n.dirty()), t.common.async) return Promise.all([...t.data].map((e, n) => r.type._parseAsync(new S(t, e, t.path, n)))).then((e) => g.mergeArray(n, e));
|
|
2220
|
+
let i = [...t.data].map((e, n) => r.type._parseSync(new S(t, e, t.path, n)));
|
|
2221
|
+
return g.mergeArray(n, i);
|
|
2222
|
+
}
|
|
2223
|
+
get element() {
|
|
2224
|
+
return this._def.type;
|
|
2225
|
+
}
|
|
2226
|
+
min(t, n) {
|
|
2227
|
+
return new e({
|
|
2228
|
+
...this._def,
|
|
2229
|
+
minLength: {
|
|
2230
|
+
value: t,
|
|
2231
|
+
message: x.toString(n)
|
|
2232
|
+
}
|
|
2233
|
+
});
|
|
2234
|
+
}
|
|
2235
|
+
max(t, n) {
|
|
2236
|
+
return new e({
|
|
2237
|
+
...this._def,
|
|
2238
|
+
maxLength: {
|
|
2239
|
+
value: t,
|
|
2240
|
+
message: x.toString(n)
|
|
2241
|
+
}
|
|
2242
|
+
});
|
|
2243
|
+
}
|
|
2244
|
+
length(t, n) {
|
|
2245
|
+
return new e({
|
|
2246
|
+
...this._def,
|
|
2247
|
+
exactLength: {
|
|
2248
|
+
value: t,
|
|
2249
|
+
message: x.toString(n)
|
|
2250
|
+
}
|
|
2251
|
+
});
|
|
2252
|
+
}
|
|
2253
|
+
nonempty(e) {
|
|
2254
|
+
return this.min(1, e);
|
|
2255
|
+
}
|
|
2256
|
+
};
|
|
2257
|
+
M.create = (e, t) => new M({
|
|
2258
|
+
type: e,
|
|
2259
|
+
minLength: null,
|
|
2260
|
+
maxLength: null,
|
|
2261
|
+
exactLength: null,
|
|
2262
|
+
typeName: Z.ZodArray,
|
|
2263
|
+
...C(t)
|
|
2264
|
+
});
|
|
2265
|
+
function N(e) {
|
|
2266
|
+
if (e instanceof P) {
|
|
2267
|
+
let t = {};
|
|
2268
|
+
for (let n in e.shape) {
|
|
2269
|
+
let r = e.shape[n];
|
|
2270
|
+
t[n] = G.create(N(r));
|
|
2271
|
+
}
|
|
2272
|
+
return new P({
|
|
2273
|
+
...e._def,
|
|
2274
|
+
shape: () => t
|
|
2275
|
+
});
|
|
2276
|
+
}
|
|
2277
|
+
return e instanceof M ? new M({
|
|
2278
|
+
...e._def,
|
|
2279
|
+
type: N(e.element)
|
|
2280
|
+
}) : e instanceof G ? G.create(N(e.unwrap())) : e instanceof K ? K.create(N(e.unwrap())) : e instanceof R ? R.create(e.items.map((e) => N(e))) : e;
|
|
2281
|
+
}
|
|
2282
|
+
var P = class e extends w {
|
|
2283
|
+
constructor() {
|
|
2284
|
+
super(...arguments), this._cached = null, this.nonstrict = this.passthrough, this.augment = this.extend;
|
|
2285
|
+
}
|
|
2286
|
+
_getCached() {
|
|
2287
|
+
if (this._cached !== null) return this._cached;
|
|
2288
|
+
let e = this._def.shape(), t = l.objectKeys(e);
|
|
2289
|
+
return this._cached = {
|
|
2290
|
+
shape: e,
|
|
2291
|
+
keys: t
|
|
2292
|
+
}, this._cached;
|
|
2293
|
+
}
|
|
2294
|
+
_parse(e) {
|
|
2295
|
+
if (this._getType(e) !== u.object) {
|
|
2296
|
+
let t = this._getOrReturnCtx(e);
|
|
2297
|
+
return h(t, {
|
|
2298
|
+
code: f.invalid_type,
|
|
2299
|
+
expected: u.object,
|
|
2300
|
+
received: t.parsedType
|
|
2301
|
+
}), _;
|
|
2302
|
+
}
|
|
2303
|
+
let { status: t, ctx: n } = this._processInputParams(e), { shape: r, keys: i } = this._getCached(), a = [];
|
|
2304
|
+
if (!(this._def.catchall instanceof j && this._def.unknownKeys === "strip")) for (let e in n.data) i.includes(e) || a.push(e);
|
|
2305
|
+
let o = [];
|
|
2306
|
+
for (let e of i) {
|
|
2307
|
+
let t = r[e], i = n.data[e];
|
|
2308
|
+
o.push({
|
|
2309
|
+
key: {
|
|
2310
|
+
status: "valid",
|
|
2311
|
+
value: e
|
|
2312
|
+
},
|
|
2313
|
+
value: t._parse(new S(n, i, n.path, e)),
|
|
2314
|
+
alwaysSet: e in n.data
|
|
2315
|
+
});
|
|
2316
|
+
}
|
|
2317
|
+
if (this._def.catchall instanceof j) {
|
|
2318
|
+
let e = this._def.unknownKeys;
|
|
2319
|
+
if (e === "passthrough") for (let e of a) o.push({
|
|
2320
|
+
key: {
|
|
2321
|
+
status: "valid",
|
|
2322
|
+
value: e
|
|
2323
|
+
},
|
|
2324
|
+
value: {
|
|
2325
|
+
status: "valid",
|
|
2326
|
+
value: n.data[e]
|
|
2327
|
+
}
|
|
2328
|
+
});
|
|
2329
|
+
else if (e === "strict") a.length > 0 && (h(n, {
|
|
2330
|
+
code: f.unrecognized_keys,
|
|
2331
|
+
keys: a
|
|
2332
|
+
}), t.dirty());
|
|
2333
|
+
else if (e !== "strip") throw Error("Internal ZodObject error: invalid unknownKeys value.");
|
|
2334
|
+
} else {
|
|
2335
|
+
let e = this._def.catchall;
|
|
2336
|
+
for (let t of a) {
|
|
2337
|
+
let r = n.data[t];
|
|
2338
|
+
o.push({
|
|
2339
|
+
key: {
|
|
2340
|
+
status: "valid",
|
|
2341
|
+
value: t
|
|
2342
|
+
},
|
|
2343
|
+
value: e._parse(new S(n, r, n.path, t)),
|
|
2344
|
+
alwaysSet: t in n.data
|
|
2345
|
+
});
|
|
2346
|
+
}
|
|
2347
|
+
}
|
|
2348
|
+
return n.common.async ? Promise.resolve().then(async () => {
|
|
2349
|
+
let e = [];
|
|
2350
|
+
for (let t of o) {
|
|
2351
|
+
let n = await t.key, r = await t.value;
|
|
2352
|
+
e.push({
|
|
2353
|
+
key: n,
|
|
2354
|
+
value: r,
|
|
2355
|
+
alwaysSet: t.alwaysSet
|
|
2356
|
+
});
|
|
2357
|
+
}
|
|
2358
|
+
return e;
|
|
2359
|
+
}).then((e) => g.mergeObjectSync(t, e)) : g.mergeObjectSync(t, o);
|
|
2360
|
+
}
|
|
2361
|
+
get shape() {
|
|
2362
|
+
return this._def.shape();
|
|
2363
|
+
}
|
|
2364
|
+
strict(t) {
|
|
2365
|
+
return x.errToObj, new e({
|
|
2366
|
+
...this._def,
|
|
2367
|
+
unknownKeys: "strict",
|
|
2368
|
+
...t === void 0 ? {} : { errorMap: (e, n) => {
|
|
2369
|
+
let r = this._def.errorMap?.(e, n).message ?? n.defaultError;
|
|
2370
|
+
return e.code === "unrecognized_keys" ? { message: x.errToObj(t).message ?? r } : { message: r };
|
|
2371
|
+
} }
|
|
2372
|
+
});
|
|
2373
|
+
}
|
|
2374
|
+
strip() {
|
|
2375
|
+
return new e({
|
|
2376
|
+
...this._def,
|
|
2377
|
+
unknownKeys: "strip"
|
|
2378
|
+
});
|
|
2379
|
+
}
|
|
2380
|
+
passthrough() {
|
|
2381
|
+
return new e({
|
|
2382
|
+
...this._def,
|
|
2383
|
+
unknownKeys: "passthrough"
|
|
2384
|
+
});
|
|
2385
|
+
}
|
|
2386
|
+
extend(t) {
|
|
2387
|
+
return new e({
|
|
2388
|
+
...this._def,
|
|
2389
|
+
shape: () => ({
|
|
2390
|
+
...this._def.shape(),
|
|
2391
|
+
...t
|
|
2392
|
+
})
|
|
2393
|
+
});
|
|
2394
|
+
}
|
|
2395
|
+
merge(t) {
|
|
2396
|
+
return new e({
|
|
2397
|
+
unknownKeys: t._def.unknownKeys,
|
|
2398
|
+
catchall: t._def.catchall,
|
|
2399
|
+
shape: () => ({
|
|
2400
|
+
...this._def.shape(),
|
|
2401
|
+
...t._def.shape()
|
|
2402
|
+
}),
|
|
2403
|
+
typeName: Z.ZodObject
|
|
2404
|
+
});
|
|
2405
|
+
}
|
|
2406
|
+
setKey(e, t) {
|
|
2407
|
+
return this.augment({ [e]: t });
|
|
2408
|
+
}
|
|
2409
|
+
catchall(t) {
|
|
2410
|
+
return new e({
|
|
2411
|
+
...this._def,
|
|
2412
|
+
catchall: t
|
|
2413
|
+
});
|
|
2414
|
+
}
|
|
2415
|
+
pick(t) {
|
|
2416
|
+
let n = {};
|
|
2417
|
+
for (let e of l.objectKeys(t)) t[e] && this.shape[e] && (n[e] = this.shape[e]);
|
|
2418
|
+
return new e({
|
|
2419
|
+
...this._def,
|
|
2420
|
+
shape: () => n
|
|
2421
|
+
});
|
|
2422
|
+
}
|
|
2423
|
+
omit(t) {
|
|
2424
|
+
let n = {};
|
|
2425
|
+
for (let e of l.objectKeys(this.shape)) t[e] || (n[e] = this.shape[e]);
|
|
2426
|
+
return new e({
|
|
2427
|
+
...this._def,
|
|
2428
|
+
shape: () => n
|
|
2429
|
+
});
|
|
2430
|
+
}
|
|
2431
|
+
deepPartial() {
|
|
2432
|
+
return N(this);
|
|
2433
|
+
}
|
|
2434
|
+
partial(t) {
|
|
2435
|
+
let n = {};
|
|
2436
|
+
for (let e of l.objectKeys(this.shape)) {
|
|
2437
|
+
let r = this.shape[e];
|
|
2438
|
+
n[e] = t && !t[e] ? r : r.optional();
|
|
2439
|
+
}
|
|
2440
|
+
return new e({
|
|
2441
|
+
...this._def,
|
|
2442
|
+
shape: () => n
|
|
2443
|
+
});
|
|
2444
|
+
}
|
|
2445
|
+
required(t) {
|
|
2446
|
+
let n = {};
|
|
2447
|
+
for (let e of l.objectKeys(this.shape)) if (t && !t[e]) n[e] = this.shape[e];
|
|
2448
|
+
else {
|
|
2449
|
+
let t = this.shape[e];
|
|
2450
|
+
for (; t instanceof G;) t = t._def.innerType;
|
|
2451
|
+
n[e] = t;
|
|
2452
|
+
}
|
|
2453
|
+
return new e({
|
|
2454
|
+
...this._def,
|
|
2455
|
+
shape: () => n
|
|
2456
|
+
});
|
|
2457
|
+
}
|
|
2458
|
+
keyof() {
|
|
2459
|
+
return Ze(l.objectKeys(this.shape));
|
|
2460
|
+
}
|
|
2461
|
+
};
|
|
2462
|
+
P.create = (e, t) => new P({
|
|
2463
|
+
shape: () => e,
|
|
2464
|
+
unknownKeys: "strip",
|
|
2465
|
+
catchall: j.create(),
|
|
2466
|
+
typeName: Z.ZodObject,
|
|
2467
|
+
...C(t)
|
|
2468
|
+
}), P.strictCreate = (e, t) => new P({
|
|
2469
|
+
shape: () => e,
|
|
2470
|
+
unknownKeys: "strict",
|
|
2471
|
+
catchall: j.create(),
|
|
2472
|
+
typeName: Z.ZodObject,
|
|
2473
|
+
...C(t)
|
|
2474
|
+
}), P.lazycreate = (e, t) => new P({
|
|
2475
|
+
shape: e,
|
|
2476
|
+
unknownKeys: "strip",
|
|
2477
|
+
catchall: j.create(),
|
|
2478
|
+
typeName: Z.ZodObject,
|
|
2479
|
+
...C(t)
|
|
2480
|
+
});
|
|
2481
|
+
var F = class extends w {
|
|
2482
|
+
_parse(e) {
|
|
2483
|
+
let { ctx: t } = this._processInputParams(e), n = this._def.options;
|
|
2484
|
+
function r(e) {
|
|
2485
|
+
for (let t of e) if (t.result.status === "valid") return t.result;
|
|
2486
|
+
for (let n of e) if (n.result.status === "dirty") return t.common.issues.push(...n.ctx.common.issues), n.result;
|
|
2487
|
+
let n = e.map((e) => new p(e.ctx.common.issues));
|
|
2488
|
+
return h(t, {
|
|
2489
|
+
code: f.invalid_union,
|
|
2490
|
+
unionErrors: n
|
|
2491
|
+
}), _;
|
|
2492
|
+
}
|
|
2493
|
+
if (t.common.async) return Promise.all(n.map(async (e) => {
|
|
2494
|
+
let n = {
|
|
2495
|
+
...t,
|
|
2496
|
+
common: {
|
|
2497
|
+
...t.common,
|
|
2498
|
+
issues: []
|
|
2499
|
+
},
|
|
2500
|
+
parent: null
|
|
2501
|
+
};
|
|
2502
|
+
return {
|
|
2503
|
+
result: await e._parseAsync({
|
|
2504
|
+
data: t.data,
|
|
2505
|
+
path: t.path,
|
|
2506
|
+
parent: n
|
|
2507
|
+
}),
|
|
2508
|
+
ctx: n
|
|
2509
|
+
};
|
|
2510
|
+
})).then(r);
|
|
2511
|
+
{
|
|
2512
|
+
let e, r = [];
|
|
2513
|
+
for (let i of n) {
|
|
2514
|
+
let n = {
|
|
2515
|
+
...t,
|
|
2516
|
+
common: {
|
|
2517
|
+
...t.common,
|
|
2518
|
+
issues: []
|
|
2519
|
+
},
|
|
2520
|
+
parent: null
|
|
2521
|
+
}, a = i._parseSync({
|
|
2522
|
+
data: t.data,
|
|
2523
|
+
path: t.path,
|
|
2524
|
+
parent: n
|
|
2525
|
+
});
|
|
2526
|
+
if (a.status === "valid") return a;
|
|
2527
|
+
a.status === "dirty" && !e && (e = {
|
|
2528
|
+
result: a,
|
|
2529
|
+
ctx: n
|
|
2530
|
+
}), n.common.issues.length && r.push(n.common.issues);
|
|
2531
|
+
}
|
|
2532
|
+
if (e) return t.common.issues.push(...e.ctx.common.issues), e.result;
|
|
2533
|
+
let i = r.map((e) => new p(e));
|
|
2534
|
+
return h(t, {
|
|
2535
|
+
code: f.invalid_union,
|
|
2536
|
+
unionErrors: i
|
|
2537
|
+
}), _;
|
|
2538
|
+
}
|
|
2539
|
+
}
|
|
2540
|
+
get options() {
|
|
2541
|
+
return this._def.options;
|
|
2542
|
+
}
|
|
2543
|
+
};
|
|
2544
|
+
F.create = (e, t) => new F({
|
|
2545
|
+
options: e,
|
|
2546
|
+
typeName: Z.ZodUnion,
|
|
2547
|
+
...C(t)
|
|
2548
|
+
});
|
|
2549
|
+
var I = (e) => e instanceof z ? I(e.schema) : e instanceof W ? I(e.innerType()) : e instanceof B ? [e.value] : e instanceof V ? e.options : e instanceof H ? l.objectValues(e.enum) : e instanceof q ? I(e._def.innerType) : e instanceof O ? [void 0] : e instanceof k ? [null] : e instanceof G ? [void 0, ...I(e.unwrap())] : e instanceof K ? [null, ...I(e.unwrap())] : e instanceof Qe || e instanceof X ? I(e.unwrap()) : e instanceof J ? I(e._def.innerType) : [], Ge = class e extends w {
|
|
2550
|
+
_parse(e) {
|
|
2551
|
+
let { ctx: t } = this._processInputParams(e);
|
|
2552
|
+
if (t.parsedType !== u.object) return h(t, {
|
|
2553
|
+
code: f.invalid_type,
|
|
2554
|
+
expected: u.object,
|
|
2555
|
+
received: t.parsedType
|
|
2556
|
+
}), _;
|
|
2557
|
+
let n = this.discriminator, r = t.data[n], i = this.optionsMap.get(r);
|
|
2558
|
+
return i ? t.common.async ? i._parseAsync({
|
|
2559
|
+
data: t.data,
|
|
2560
|
+
path: t.path,
|
|
2561
|
+
parent: t
|
|
2562
|
+
}) : i._parseSync({
|
|
2563
|
+
data: t.data,
|
|
2564
|
+
path: t.path,
|
|
2565
|
+
parent: t
|
|
2566
|
+
}) : (h(t, {
|
|
2567
|
+
code: f.invalid_union_discriminator,
|
|
2568
|
+
options: Array.from(this.optionsMap.keys()),
|
|
2569
|
+
path: [n]
|
|
2570
|
+
}), _);
|
|
2571
|
+
}
|
|
2572
|
+
get discriminator() {
|
|
2573
|
+
return this._def.discriminator;
|
|
2574
|
+
}
|
|
2575
|
+
get options() {
|
|
2576
|
+
return this._def.options;
|
|
2577
|
+
}
|
|
2578
|
+
get optionsMap() {
|
|
2579
|
+
return this._def.optionsMap;
|
|
2580
|
+
}
|
|
2581
|
+
static create(t, n, r) {
|
|
2582
|
+
let i = /* @__PURE__ */ new Map();
|
|
2583
|
+
for (let e of n) {
|
|
2584
|
+
let n = I(e.shape[t]);
|
|
2585
|
+
if (!n.length) throw Error(`A discriminator value for key \`${t}\` could not be extracted from all schema options`);
|
|
2586
|
+
for (let r of n) {
|
|
2587
|
+
if (i.has(r)) throw Error(`Discriminator property ${String(t)} has duplicate value ${String(r)}`);
|
|
2588
|
+
i.set(r, e);
|
|
2589
|
+
}
|
|
2590
|
+
}
|
|
2591
|
+
return new e({
|
|
2592
|
+
typeName: Z.ZodDiscriminatedUnion,
|
|
2593
|
+
discriminator: t,
|
|
2594
|
+
options: n,
|
|
2595
|
+
optionsMap: i,
|
|
2596
|
+
...C(r)
|
|
2597
|
+
});
|
|
2598
|
+
}
|
|
2599
|
+
};
|
|
2600
|
+
function Ke(e, t) {
|
|
2601
|
+
let n = d(e), r = d(t);
|
|
2602
|
+
if (e === t) return {
|
|
2603
|
+
valid: !0,
|
|
2604
|
+
data: e
|
|
2605
|
+
};
|
|
2606
|
+
if (n === u.object && r === u.object) {
|
|
2607
|
+
let n = l.objectKeys(t), r = l.objectKeys(e).filter((e) => n.indexOf(e) !== -1), i = {
|
|
2608
|
+
...e,
|
|
2609
|
+
...t
|
|
2610
|
+
};
|
|
2611
|
+
for (let n of r) {
|
|
2612
|
+
let r = Ke(e[n], t[n]);
|
|
2613
|
+
if (!r.valid) return { valid: !1 };
|
|
2614
|
+
i[n] = r.data;
|
|
2615
|
+
}
|
|
2616
|
+
return {
|
|
2617
|
+
valid: !0,
|
|
2618
|
+
data: i
|
|
2619
|
+
};
|
|
2620
|
+
}
|
|
2621
|
+
if (n === u.array && r === u.array) {
|
|
2622
|
+
if (e.length !== t.length) return { valid: !1 };
|
|
2623
|
+
let n = [];
|
|
2624
|
+
for (let r = 0; r < e.length; r++) {
|
|
2625
|
+
let i = e[r], a = t[r], o = Ke(i, a);
|
|
2626
|
+
if (!o.valid) return { valid: !1 };
|
|
2627
|
+
n.push(o.data);
|
|
2628
|
+
}
|
|
2629
|
+
return {
|
|
2630
|
+
valid: !0,
|
|
2631
|
+
data: n
|
|
2632
|
+
};
|
|
2633
|
+
}
|
|
2634
|
+
return n === u.date && r === u.date && +e == +t ? {
|
|
2635
|
+
valid: !0,
|
|
2636
|
+
data: e
|
|
2637
|
+
} : { valid: !1 };
|
|
2638
|
+
}
|
|
2639
|
+
var L = class extends w {
|
|
2640
|
+
_parse(e) {
|
|
2641
|
+
let { status: t, ctx: n } = this._processInputParams(e), r = (e, r) => {
|
|
2642
|
+
if (fe(e) || fe(r)) return _;
|
|
2643
|
+
let i = Ke(e.value, r.value);
|
|
2644
|
+
return i.valid ? ((pe(e) || pe(r)) && t.dirty(), {
|
|
2645
|
+
status: t.value,
|
|
2646
|
+
value: i.data
|
|
2647
|
+
}) : (h(n, { code: f.invalid_intersection_types }), _);
|
|
2648
|
+
};
|
|
2649
|
+
return n.common.async ? Promise.all([this._def.left._parseAsync({
|
|
2650
|
+
data: n.data,
|
|
2651
|
+
path: n.path,
|
|
2652
|
+
parent: n
|
|
2653
|
+
}), this._def.right._parseAsync({
|
|
2654
|
+
data: n.data,
|
|
2655
|
+
path: n.path,
|
|
2656
|
+
parent: n
|
|
2657
|
+
})]).then(([e, t]) => r(e, t)) : r(this._def.left._parseSync({
|
|
2658
|
+
data: n.data,
|
|
2659
|
+
path: n.path,
|
|
2660
|
+
parent: n
|
|
2661
|
+
}), this._def.right._parseSync({
|
|
2662
|
+
data: n.data,
|
|
2663
|
+
path: n.path,
|
|
2664
|
+
parent: n
|
|
2665
|
+
}));
|
|
2666
|
+
}
|
|
2667
|
+
};
|
|
2668
|
+
L.create = (e, t, n) => new L({
|
|
2669
|
+
left: e,
|
|
2670
|
+
right: t,
|
|
2671
|
+
typeName: Z.ZodIntersection,
|
|
2672
|
+
...C(n)
|
|
2673
|
+
});
|
|
2674
|
+
var R = class e extends w {
|
|
2675
|
+
_parse(e) {
|
|
2676
|
+
let { status: t, ctx: n } = this._processInputParams(e);
|
|
2677
|
+
if (n.parsedType !== u.array) return h(n, {
|
|
2678
|
+
code: f.invalid_type,
|
|
2679
|
+
expected: u.array,
|
|
2680
|
+
received: n.parsedType
|
|
2681
|
+
}), _;
|
|
2682
|
+
if (n.data.length < this._def.items.length) return h(n, {
|
|
2683
|
+
code: f.too_small,
|
|
2684
|
+
minimum: this._def.items.length,
|
|
2685
|
+
inclusive: !0,
|
|
2686
|
+
exact: !1,
|
|
2687
|
+
type: "array"
|
|
2688
|
+
}), _;
|
|
2689
|
+
!this._def.rest && n.data.length > this._def.items.length && (h(n, {
|
|
2690
|
+
code: f.too_big,
|
|
2691
|
+
maximum: this._def.items.length,
|
|
2692
|
+
inclusive: !0,
|
|
2693
|
+
exact: !1,
|
|
2694
|
+
type: "array"
|
|
2695
|
+
}), t.dirty());
|
|
2696
|
+
let r = [...n.data].map((e, t) => {
|
|
2697
|
+
let r = this._def.items[t] || this._def.rest;
|
|
2698
|
+
return r ? r._parse(new S(n, e, n.path, t)) : null;
|
|
2699
|
+
}).filter((e) => !!e);
|
|
2700
|
+
return n.common.async ? Promise.all(r).then((e) => g.mergeArray(t, e)) : g.mergeArray(t, r);
|
|
2701
|
+
}
|
|
2702
|
+
get items() {
|
|
2703
|
+
return this._def.items;
|
|
2704
|
+
}
|
|
2705
|
+
rest(t) {
|
|
2706
|
+
return new e({
|
|
2707
|
+
...this._def,
|
|
2708
|
+
rest: t
|
|
2709
|
+
});
|
|
2710
|
+
}
|
|
2711
|
+
};
|
|
2712
|
+
R.create = (e, t) => {
|
|
2713
|
+
if (!Array.isArray(e)) throw Error("You must pass an array of schemas to z.tuple([ ... ])");
|
|
2714
|
+
return new R({
|
|
2715
|
+
items: e,
|
|
2716
|
+
typeName: Z.ZodTuple,
|
|
2717
|
+
rest: null,
|
|
2718
|
+
...C(t)
|
|
2719
|
+
});
|
|
2720
|
+
};
|
|
2721
|
+
var qe = class e extends w {
|
|
2722
|
+
get keySchema() {
|
|
2723
|
+
return this._def.keyType;
|
|
2724
|
+
}
|
|
2725
|
+
get valueSchema() {
|
|
2726
|
+
return this._def.valueType;
|
|
2727
|
+
}
|
|
2728
|
+
_parse(e) {
|
|
2729
|
+
let { status: t, ctx: n } = this._processInputParams(e);
|
|
2730
|
+
if (n.parsedType !== u.object) return h(n, {
|
|
2731
|
+
code: f.invalid_type,
|
|
2732
|
+
expected: u.object,
|
|
2733
|
+
received: n.parsedType
|
|
2734
|
+
}), _;
|
|
2735
|
+
let r = [], i = this._def.keyType, a = this._def.valueType;
|
|
2736
|
+
for (let e in n.data) r.push({
|
|
2737
|
+
key: i._parse(new S(n, e, n.path, e)),
|
|
2738
|
+
value: a._parse(new S(n, n.data[e], n.path, e)),
|
|
2739
|
+
alwaysSet: e in n.data
|
|
2740
|
+
});
|
|
2741
|
+
return n.common.async ? g.mergeObjectAsync(t, r) : g.mergeObjectSync(t, r);
|
|
2742
|
+
}
|
|
2743
|
+
get element() {
|
|
2744
|
+
return this._def.valueType;
|
|
2745
|
+
}
|
|
2746
|
+
static create(t, n, r) {
|
|
2747
|
+
return n instanceof w ? new e({
|
|
2748
|
+
keyType: t,
|
|
2749
|
+
valueType: n,
|
|
2750
|
+
typeName: Z.ZodRecord,
|
|
2751
|
+
...C(r)
|
|
2752
|
+
}) : new e({
|
|
2753
|
+
keyType: T.create(),
|
|
2754
|
+
valueType: t,
|
|
2755
|
+
typeName: Z.ZodRecord,
|
|
2756
|
+
...C(n)
|
|
2757
|
+
});
|
|
2758
|
+
}
|
|
2759
|
+
}, Je = class extends w {
|
|
2760
|
+
get keySchema() {
|
|
2761
|
+
return this._def.keyType;
|
|
2762
|
+
}
|
|
2763
|
+
get valueSchema() {
|
|
2764
|
+
return this._def.valueType;
|
|
2765
|
+
}
|
|
2766
|
+
_parse(e) {
|
|
2767
|
+
let { status: t, ctx: n } = this._processInputParams(e);
|
|
2768
|
+
if (n.parsedType !== u.map) return h(n, {
|
|
2769
|
+
code: f.invalid_type,
|
|
2770
|
+
expected: u.map,
|
|
2771
|
+
received: n.parsedType
|
|
2772
|
+
}), _;
|
|
2773
|
+
let r = this._def.keyType, i = this._def.valueType, a = [...n.data.entries()].map(([e, t], a) => ({
|
|
2774
|
+
key: r._parse(new S(n, e, n.path, [a, "key"])),
|
|
2775
|
+
value: i._parse(new S(n, t, n.path, [a, "value"]))
|
|
2776
|
+
}));
|
|
2777
|
+
if (n.common.async) {
|
|
2778
|
+
let e = /* @__PURE__ */ new Map();
|
|
2779
|
+
return Promise.resolve().then(async () => {
|
|
2780
|
+
for (let n of a) {
|
|
2781
|
+
let r = await n.key, i = await n.value;
|
|
2782
|
+
if (r.status === "aborted" || i.status === "aborted") return _;
|
|
2783
|
+
(r.status === "dirty" || i.status === "dirty") && t.dirty(), e.set(r.value, i.value);
|
|
2784
|
+
}
|
|
2785
|
+
return {
|
|
2786
|
+
status: t.value,
|
|
2787
|
+
value: e
|
|
2788
|
+
};
|
|
2789
|
+
});
|
|
2790
|
+
}
|
|
2791
|
+
{
|
|
2792
|
+
let e = /* @__PURE__ */ new Map();
|
|
2793
|
+
for (let n of a) {
|
|
2794
|
+
let r = n.key, i = n.value;
|
|
2795
|
+
if (r.status === "aborted" || i.status === "aborted") return _;
|
|
2796
|
+
(r.status === "dirty" || i.status === "dirty") && t.dirty(), e.set(r.value, i.value);
|
|
2797
|
+
}
|
|
2798
|
+
return {
|
|
2799
|
+
status: t.value,
|
|
2800
|
+
value: e
|
|
2801
|
+
};
|
|
2802
|
+
}
|
|
2803
|
+
}
|
|
2804
|
+
};
|
|
2805
|
+
Je.create = (e, t, n) => new Je({
|
|
2806
|
+
valueType: t,
|
|
2807
|
+
keyType: e,
|
|
2808
|
+
typeName: Z.ZodMap,
|
|
2809
|
+
...C(n)
|
|
2810
|
+
});
|
|
2811
|
+
var Ye = class e extends w {
|
|
2812
|
+
_parse(e) {
|
|
2813
|
+
let { status: t, ctx: n } = this._processInputParams(e);
|
|
2814
|
+
if (n.parsedType !== u.set) return h(n, {
|
|
2815
|
+
code: f.invalid_type,
|
|
2816
|
+
expected: u.set,
|
|
2817
|
+
received: n.parsedType
|
|
2818
|
+
}), _;
|
|
2819
|
+
let r = this._def;
|
|
2820
|
+
r.minSize !== null && n.data.size < r.minSize.value && (h(n, {
|
|
2821
|
+
code: f.too_small,
|
|
2822
|
+
minimum: r.minSize.value,
|
|
2823
|
+
type: "set",
|
|
2824
|
+
inclusive: !0,
|
|
2825
|
+
exact: !1,
|
|
2826
|
+
message: r.minSize.message
|
|
2827
|
+
}), t.dirty()), r.maxSize !== null && n.data.size > r.maxSize.value && (h(n, {
|
|
2828
|
+
code: f.too_big,
|
|
2829
|
+
maximum: r.maxSize.value,
|
|
2830
|
+
type: "set",
|
|
2831
|
+
inclusive: !0,
|
|
2832
|
+
exact: !1,
|
|
2833
|
+
message: r.maxSize.message
|
|
2834
|
+
}), t.dirty());
|
|
2835
|
+
let i = this._def.valueType;
|
|
2836
|
+
function a(e) {
|
|
2837
|
+
let n = /* @__PURE__ */ new Set();
|
|
2838
|
+
for (let r of e) {
|
|
2839
|
+
if (r.status === "aborted") return _;
|
|
2840
|
+
r.status === "dirty" && t.dirty(), n.add(r.value);
|
|
2841
|
+
}
|
|
2842
|
+
return {
|
|
2843
|
+
status: t.value,
|
|
2844
|
+
value: n
|
|
2845
|
+
};
|
|
2846
|
+
}
|
|
2847
|
+
let o = [...n.data.values()].map((e, t) => i._parse(new S(n, e, n.path, t)));
|
|
2848
|
+
return n.common.async ? Promise.all(o).then((e) => a(e)) : a(o);
|
|
2849
|
+
}
|
|
2850
|
+
min(t, n) {
|
|
2851
|
+
return new e({
|
|
2852
|
+
...this._def,
|
|
2853
|
+
minSize: {
|
|
2854
|
+
value: t,
|
|
2855
|
+
message: x.toString(n)
|
|
2856
|
+
}
|
|
2857
|
+
});
|
|
2858
|
+
}
|
|
2859
|
+
max(t, n) {
|
|
2860
|
+
return new e({
|
|
2861
|
+
...this._def,
|
|
2862
|
+
maxSize: {
|
|
2863
|
+
value: t,
|
|
2864
|
+
message: x.toString(n)
|
|
2865
|
+
}
|
|
2866
|
+
});
|
|
2867
|
+
}
|
|
2868
|
+
size(e, t) {
|
|
2869
|
+
return this.min(e, t).max(e, t);
|
|
2870
|
+
}
|
|
2871
|
+
nonempty(e) {
|
|
2872
|
+
return this.min(1, e);
|
|
2873
|
+
}
|
|
2874
|
+
};
|
|
2875
|
+
Ye.create = (e, t) => new Ye({
|
|
2876
|
+
valueType: e,
|
|
2877
|
+
minSize: null,
|
|
2878
|
+
maxSize: null,
|
|
2879
|
+
typeName: Z.ZodSet,
|
|
2880
|
+
...C(t)
|
|
2881
|
+
});
|
|
2882
|
+
var Xe = class e extends w {
|
|
2883
|
+
constructor() {
|
|
2884
|
+
super(...arguments), this.validate = this.implement;
|
|
2885
|
+
}
|
|
2886
|
+
_parse(e) {
|
|
2887
|
+
let { ctx: t } = this._processInputParams(e);
|
|
2888
|
+
if (t.parsedType !== u.function) return h(t, {
|
|
2889
|
+
code: f.invalid_type,
|
|
2890
|
+
expected: u.function,
|
|
2891
|
+
received: t.parsedType
|
|
2892
|
+
}), _;
|
|
2893
|
+
function n(e, n) {
|
|
2894
|
+
return ue({
|
|
2895
|
+
data: e,
|
|
2896
|
+
path: t.path,
|
|
2897
|
+
errorMaps: [
|
|
2898
|
+
t.common.contextualErrorMap,
|
|
2899
|
+
t.schemaErrorMap,
|
|
2900
|
+
le(),
|
|
2901
|
+
m
|
|
2902
|
+
].filter((e) => !!e),
|
|
2903
|
+
issueData: {
|
|
2904
|
+
code: f.invalid_arguments,
|
|
2905
|
+
argumentsError: n
|
|
2906
|
+
}
|
|
2907
|
+
});
|
|
2908
|
+
}
|
|
2909
|
+
function r(e, n) {
|
|
2910
|
+
return ue({
|
|
2911
|
+
data: e,
|
|
2912
|
+
path: t.path,
|
|
2913
|
+
errorMaps: [
|
|
2914
|
+
t.common.contextualErrorMap,
|
|
2915
|
+
t.schemaErrorMap,
|
|
2916
|
+
le(),
|
|
2917
|
+
m
|
|
2918
|
+
].filter((e) => !!e),
|
|
2919
|
+
issueData: {
|
|
2920
|
+
code: f.invalid_return_type,
|
|
2921
|
+
returnTypeError: n
|
|
2922
|
+
}
|
|
2923
|
+
});
|
|
2924
|
+
}
|
|
2925
|
+
let i = { errorMap: t.common.contextualErrorMap }, a = t.data;
|
|
2926
|
+
if (this._def.returns instanceof U) {
|
|
2927
|
+
let e = this;
|
|
2928
|
+
return v(async function(...t) {
|
|
2929
|
+
let o = new p([]), s = await e._def.args.parseAsync(t, i).catch((e) => {
|
|
2930
|
+
throw o.addIssue(n(t, e)), o;
|
|
2931
|
+
}), c = await Reflect.apply(a, this, s);
|
|
2932
|
+
return await e._def.returns._def.type.parseAsync(c, i).catch((e) => {
|
|
2933
|
+
throw o.addIssue(r(c, e)), o;
|
|
2934
|
+
});
|
|
2935
|
+
});
|
|
2936
|
+
}
|
|
2937
|
+
{
|
|
2938
|
+
let e = this;
|
|
2939
|
+
return v(function(...t) {
|
|
2940
|
+
let o = e._def.args.safeParse(t, i);
|
|
2941
|
+
if (!o.success) throw new p([n(t, o.error)]);
|
|
2942
|
+
let s = Reflect.apply(a, this, o.data), c = e._def.returns.safeParse(s, i);
|
|
2943
|
+
if (!c.success) throw new p([r(s, c.error)]);
|
|
2944
|
+
return c.data;
|
|
2945
|
+
});
|
|
2946
|
+
}
|
|
2947
|
+
}
|
|
2948
|
+
parameters() {
|
|
2949
|
+
return this._def.args;
|
|
2950
|
+
}
|
|
2951
|
+
returnType() {
|
|
2952
|
+
return this._def.returns;
|
|
2953
|
+
}
|
|
2954
|
+
args(...t) {
|
|
2955
|
+
return new e({
|
|
2956
|
+
...this._def,
|
|
2957
|
+
args: R.create(t).rest(A.create())
|
|
2958
|
+
});
|
|
2959
|
+
}
|
|
2960
|
+
returns(t) {
|
|
2961
|
+
return new e({
|
|
2962
|
+
...this._def,
|
|
2963
|
+
returns: t
|
|
2964
|
+
});
|
|
2965
|
+
}
|
|
2966
|
+
implement(e) {
|
|
2967
|
+
return this.parse(e);
|
|
2968
|
+
}
|
|
2969
|
+
strictImplement(e) {
|
|
2970
|
+
return this.parse(e);
|
|
2971
|
+
}
|
|
2972
|
+
static create(t, n, r) {
|
|
2973
|
+
return new e({
|
|
2974
|
+
args: t || R.create([]).rest(A.create()),
|
|
2975
|
+
returns: n || A.create(),
|
|
2976
|
+
typeName: Z.ZodFunction,
|
|
2977
|
+
...C(r)
|
|
2978
|
+
});
|
|
2979
|
+
}
|
|
2980
|
+
}, z = class extends w {
|
|
2981
|
+
get schema() {
|
|
2982
|
+
return this._def.getter();
|
|
2983
|
+
}
|
|
2984
|
+
_parse(e) {
|
|
2985
|
+
let { ctx: t } = this._processInputParams(e);
|
|
2986
|
+
return this._def.getter()._parse({
|
|
2987
|
+
data: t.data,
|
|
2988
|
+
path: t.path,
|
|
2989
|
+
parent: t
|
|
2990
|
+
});
|
|
2991
|
+
}
|
|
2992
|
+
};
|
|
2993
|
+
z.create = (e, t) => new z({
|
|
2994
|
+
getter: e,
|
|
2995
|
+
typeName: Z.ZodLazy,
|
|
2996
|
+
...C(t)
|
|
2997
|
+
});
|
|
2998
|
+
var B = class extends w {
|
|
2999
|
+
_parse(e) {
|
|
3000
|
+
if (e.data !== this._def.value) {
|
|
3001
|
+
let t = this._getOrReturnCtx(e);
|
|
3002
|
+
return h(t, {
|
|
3003
|
+
received: t.data,
|
|
3004
|
+
code: f.invalid_literal,
|
|
3005
|
+
expected: this._def.value
|
|
3006
|
+
}), _;
|
|
3007
|
+
}
|
|
3008
|
+
return {
|
|
3009
|
+
status: "valid",
|
|
3010
|
+
value: e.data
|
|
3011
|
+
};
|
|
3012
|
+
}
|
|
3013
|
+
get value() {
|
|
3014
|
+
return this._def.value;
|
|
3015
|
+
}
|
|
3016
|
+
};
|
|
3017
|
+
B.create = (e, t) => new B({
|
|
3018
|
+
value: e,
|
|
3019
|
+
typeName: Z.ZodLiteral,
|
|
3020
|
+
...C(t)
|
|
3021
|
+
});
|
|
3022
|
+
function Ze(e, t) {
|
|
3023
|
+
return new V({
|
|
3024
|
+
values: e,
|
|
3025
|
+
typeName: Z.ZodEnum,
|
|
3026
|
+
...C(t)
|
|
3027
|
+
});
|
|
3028
|
+
}
|
|
3029
|
+
var V = class e extends w {
|
|
3030
|
+
_parse(e) {
|
|
3031
|
+
if (typeof e.data != "string") {
|
|
3032
|
+
let t = this._getOrReturnCtx(e), n = this._def.values;
|
|
3033
|
+
return h(t, {
|
|
3034
|
+
expected: l.joinValues(n),
|
|
3035
|
+
received: t.parsedType,
|
|
3036
|
+
code: f.invalid_type
|
|
3037
|
+
}), _;
|
|
3038
|
+
}
|
|
3039
|
+
if (this._cache ||= new Set(this._def.values), !this._cache.has(e.data)) {
|
|
3040
|
+
let t = this._getOrReturnCtx(e), n = this._def.values;
|
|
3041
|
+
return h(t, {
|
|
3042
|
+
received: t.data,
|
|
3043
|
+
code: f.invalid_enum_value,
|
|
3044
|
+
options: n
|
|
3045
|
+
}), _;
|
|
3046
|
+
}
|
|
3047
|
+
return v(e.data);
|
|
3048
|
+
}
|
|
3049
|
+
get options() {
|
|
3050
|
+
return this._def.values;
|
|
3051
|
+
}
|
|
3052
|
+
get enum() {
|
|
3053
|
+
let e = {};
|
|
3054
|
+
for (let t of this._def.values) e[t] = t;
|
|
3055
|
+
return e;
|
|
3056
|
+
}
|
|
3057
|
+
get Values() {
|
|
3058
|
+
let e = {};
|
|
3059
|
+
for (let t of this._def.values) e[t] = t;
|
|
3060
|
+
return e;
|
|
3061
|
+
}
|
|
3062
|
+
get Enum() {
|
|
3063
|
+
let e = {};
|
|
3064
|
+
for (let t of this._def.values) e[t] = t;
|
|
3065
|
+
return e;
|
|
3066
|
+
}
|
|
3067
|
+
extract(t, n = this._def) {
|
|
3068
|
+
return e.create(t, {
|
|
3069
|
+
...this._def,
|
|
3070
|
+
...n
|
|
3071
|
+
});
|
|
3072
|
+
}
|
|
3073
|
+
exclude(t, n = this._def) {
|
|
3074
|
+
return e.create(this.options.filter((e) => !t.includes(e)), {
|
|
3075
|
+
...this._def,
|
|
3076
|
+
...n
|
|
3077
|
+
});
|
|
3078
|
+
}
|
|
3079
|
+
};
|
|
3080
|
+
V.create = Ze;
|
|
3081
|
+
var H = class extends w {
|
|
3082
|
+
_parse(e) {
|
|
3083
|
+
let t = l.getValidEnumValues(this._def.values), n = this._getOrReturnCtx(e);
|
|
3084
|
+
if (n.parsedType !== u.string && n.parsedType !== u.number) {
|
|
3085
|
+
let e = l.objectValues(t);
|
|
3086
|
+
return h(n, {
|
|
3087
|
+
expected: l.joinValues(e),
|
|
3088
|
+
received: n.parsedType,
|
|
3089
|
+
code: f.invalid_type
|
|
3090
|
+
}), _;
|
|
3091
|
+
}
|
|
3092
|
+
if (this._cache ||= new Set(l.getValidEnumValues(this._def.values)), !this._cache.has(e.data)) {
|
|
3093
|
+
let e = l.objectValues(t);
|
|
3094
|
+
return h(n, {
|
|
3095
|
+
received: n.data,
|
|
3096
|
+
code: f.invalid_enum_value,
|
|
3097
|
+
options: e
|
|
3098
|
+
}), _;
|
|
3099
|
+
}
|
|
3100
|
+
return v(e.data);
|
|
3101
|
+
}
|
|
3102
|
+
get enum() {
|
|
3103
|
+
return this._def.values;
|
|
3104
|
+
}
|
|
3105
|
+
};
|
|
3106
|
+
H.create = (e, t) => new H({
|
|
3107
|
+
values: e,
|
|
3108
|
+
typeName: Z.ZodNativeEnum,
|
|
3109
|
+
...C(t)
|
|
3110
|
+
});
|
|
3111
|
+
var U = class extends w {
|
|
3112
|
+
unwrap() {
|
|
3113
|
+
return this._def.type;
|
|
3114
|
+
}
|
|
3115
|
+
_parse(e) {
|
|
3116
|
+
let { ctx: t } = this._processInputParams(e);
|
|
3117
|
+
return t.parsedType !== u.promise && t.common.async === !1 ? (h(t, {
|
|
3118
|
+
code: f.invalid_type,
|
|
3119
|
+
expected: u.promise,
|
|
3120
|
+
received: t.parsedType
|
|
3121
|
+
}), _) : v((t.parsedType === u.promise ? t.data : Promise.resolve(t.data)).then((e) => this._def.type.parseAsync(e, {
|
|
3122
|
+
path: t.path,
|
|
3123
|
+
errorMap: t.common.contextualErrorMap
|
|
3124
|
+
})));
|
|
3125
|
+
}
|
|
3126
|
+
};
|
|
3127
|
+
U.create = (e, t) => new U({
|
|
3128
|
+
type: e,
|
|
3129
|
+
typeName: Z.ZodPromise,
|
|
3130
|
+
...C(t)
|
|
3131
|
+
});
|
|
3132
|
+
var W = class extends w {
|
|
3133
|
+
innerType() {
|
|
3134
|
+
return this._def.schema;
|
|
3135
|
+
}
|
|
3136
|
+
sourceType() {
|
|
3137
|
+
return this._def.schema._def.typeName === Z.ZodEffects ? this._def.schema.sourceType() : this._def.schema;
|
|
3138
|
+
}
|
|
3139
|
+
_parse(e) {
|
|
3140
|
+
let { status: t, ctx: n } = this._processInputParams(e), r = this._def.effect || null, i = {
|
|
3141
|
+
addIssue: (e) => {
|
|
3142
|
+
h(n, e), e.fatal ? t.abort() : t.dirty();
|
|
3143
|
+
},
|
|
3144
|
+
get path() {
|
|
3145
|
+
return n.path;
|
|
3146
|
+
}
|
|
3147
|
+
};
|
|
3148
|
+
if (i.addIssue = i.addIssue.bind(i), r.type === "preprocess") {
|
|
3149
|
+
let e = r.transform(n.data, i);
|
|
3150
|
+
if (n.common.async) return Promise.resolve(e).then(async (e) => {
|
|
3151
|
+
if (t.value === "aborted") return _;
|
|
3152
|
+
let r = await this._def.schema._parseAsync({
|
|
3153
|
+
data: e,
|
|
3154
|
+
path: n.path,
|
|
3155
|
+
parent: n
|
|
3156
|
+
});
|
|
3157
|
+
return r.status === "aborted" ? _ : r.status === "dirty" || t.value === "dirty" ? de(r.value) : r;
|
|
3158
|
+
});
|
|
3159
|
+
{
|
|
3160
|
+
if (t.value === "aborted") return _;
|
|
3161
|
+
let r = this._def.schema._parseSync({
|
|
3162
|
+
data: e,
|
|
3163
|
+
path: n.path,
|
|
3164
|
+
parent: n
|
|
3165
|
+
});
|
|
3166
|
+
return r.status === "aborted" ? _ : r.status === "dirty" || t.value === "dirty" ? de(r.value) : r;
|
|
3167
|
+
}
|
|
3168
|
+
}
|
|
3169
|
+
if (r.type === "refinement") {
|
|
3170
|
+
let e = (e) => {
|
|
3171
|
+
let t = r.refinement(e, i);
|
|
3172
|
+
if (n.common.async) return Promise.resolve(t);
|
|
3173
|
+
if (t instanceof Promise) throw Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
3174
|
+
return e;
|
|
3175
|
+
};
|
|
3176
|
+
if (n.common.async === !1) {
|
|
3177
|
+
let r = this._def.schema._parseSync({
|
|
3178
|
+
data: n.data,
|
|
3179
|
+
path: n.path,
|
|
3180
|
+
parent: n
|
|
3181
|
+
});
|
|
3182
|
+
return r.status === "aborted" ? _ : (r.status === "dirty" && t.dirty(), e(r.value), {
|
|
3183
|
+
status: t.value,
|
|
3184
|
+
value: r.value
|
|
3185
|
+
});
|
|
3186
|
+
}
|
|
3187
|
+
return this._def.schema._parseAsync({
|
|
3188
|
+
data: n.data,
|
|
3189
|
+
path: n.path,
|
|
3190
|
+
parent: n
|
|
3191
|
+
}).then((n) => n.status === "aborted" ? _ : (n.status === "dirty" && t.dirty(), e(n.value).then(() => ({
|
|
3192
|
+
status: t.value,
|
|
3193
|
+
value: n.value
|
|
3194
|
+
}))));
|
|
3195
|
+
}
|
|
3196
|
+
if (r.type === "transform") {
|
|
3197
|
+
if (n.common.async === !1) {
|
|
3198
|
+
let e = this._def.schema._parseSync({
|
|
3199
|
+
data: n.data,
|
|
3200
|
+
path: n.path,
|
|
3201
|
+
parent: n
|
|
3202
|
+
});
|
|
3203
|
+
if (!y(e)) return _;
|
|
3204
|
+
let a = r.transform(e.value, i);
|
|
3205
|
+
if (a instanceof Promise) throw Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");
|
|
3206
|
+
return {
|
|
3207
|
+
status: t.value,
|
|
3208
|
+
value: a
|
|
3209
|
+
};
|
|
3210
|
+
}
|
|
3211
|
+
return this._def.schema._parseAsync({
|
|
3212
|
+
data: n.data,
|
|
3213
|
+
path: n.path,
|
|
3214
|
+
parent: n
|
|
3215
|
+
}).then((e) => y(e) ? Promise.resolve(r.transform(e.value, i)).then((e) => ({
|
|
3216
|
+
status: t.value,
|
|
3217
|
+
value: e
|
|
3218
|
+
})) : _);
|
|
3219
|
+
}
|
|
3220
|
+
l.assertNever(r);
|
|
3221
|
+
}
|
|
3222
|
+
};
|
|
3223
|
+
W.create = (e, t, n) => new W({
|
|
3224
|
+
schema: e,
|
|
3225
|
+
typeName: Z.ZodEffects,
|
|
3226
|
+
effect: t,
|
|
3227
|
+
...C(n)
|
|
3228
|
+
}), W.createWithPreprocess = (e, t, n) => new W({
|
|
3229
|
+
schema: t,
|
|
3230
|
+
effect: {
|
|
3231
|
+
type: "preprocess",
|
|
3232
|
+
transform: e
|
|
3233
|
+
},
|
|
3234
|
+
typeName: Z.ZodEffects,
|
|
3235
|
+
...C(n)
|
|
3236
|
+
});
|
|
3237
|
+
var G = class extends w {
|
|
3238
|
+
_parse(e) {
|
|
3239
|
+
return this._getType(e) === u.undefined ? v(void 0) : this._def.innerType._parse(e);
|
|
3240
|
+
}
|
|
3241
|
+
unwrap() {
|
|
3242
|
+
return this._def.innerType;
|
|
3243
|
+
}
|
|
3244
|
+
};
|
|
3245
|
+
G.create = (e, t) => new G({
|
|
3246
|
+
innerType: e,
|
|
3247
|
+
typeName: Z.ZodOptional,
|
|
3248
|
+
...C(t)
|
|
3249
|
+
});
|
|
3250
|
+
var K = class extends w {
|
|
3251
|
+
_parse(e) {
|
|
3252
|
+
return this._getType(e) === u.null ? v(null) : this._def.innerType._parse(e);
|
|
3253
|
+
}
|
|
3254
|
+
unwrap() {
|
|
3255
|
+
return this._def.innerType;
|
|
3256
|
+
}
|
|
3257
|
+
};
|
|
3258
|
+
K.create = (e, t) => new K({
|
|
3259
|
+
innerType: e,
|
|
3260
|
+
typeName: Z.ZodNullable,
|
|
3261
|
+
...C(t)
|
|
3262
|
+
});
|
|
3263
|
+
var q = class extends w {
|
|
3264
|
+
_parse(e) {
|
|
3265
|
+
let { ctx: t } = this._processInputParams(e), n = t.data;
|
|
3266
|
+
return t.parsedType === u.undefined && (n = this._def.defaultValue()), this._def.innerType._parse({
|
|
3267
|
+
data: n,
|
|
3268
|
+
path: t.path,
|
|
3269
|
+
parent: t
|
|
3270
|
+
});
|
|
3271
|
+
}
|
|
3272
|
+
removeDefault() {
|
|
3273
|
+
return this._def.innerType;
|
|
3274
|
+
}
|
|
3275
|
+
};
|
|
3276
|
+
q.create = (e, t) => new q({
|
|
3277
|
+
innerType: e,
|
|
3278
|
+
typeName: Z.ZodDefault,
|
|
3279
|
+
defaultValue: typeof t.default == "function" ? t.default : () => t.default,
|
|
3280
|
+
...C(t)
|
|
3281
|
+
});
|
|
3282
|
+
var J = class extends w {
|
|
3283
|
+
_parse(e) {
|
|
3284
|
+
let { ctx: t } = this._processInputParams(e), n = {
|
|
3285
|
+
...t,
|
|
3286
|
+
common: {
|
|
3287
|
+
...t.common,
|
|
3288
|
+
issues: []
|
|
3289
|
+
}
|
|
3290
|
+
}, r = this._def.innerType._parse({
|
|
3291
|
+
data: n.data,
|
|
3292
|
+
path: n.path,
|
|
3293
|
+
parent: { ...n }
|
|
3294
|
+
});
|
|
3295
|
+
return b(r) ? r.then((e) => ({
|
|
3296
|
+
status: "valid",
|
|
3297
|
+
value: e.status === "valid" ? e.value : this._def.catchValue({
|
|
3298
|
+
get error() {
|
|
3299
|
+
return new p(n.common.issues);
|
|
3300
|
+
},
|
|
3301
|
+
input: n.data
|
|
3302
|
+
})
|
|
3303
|
+
})) : {
|
|
3304
|
+
status: "valid",
|
|
3305
|
+
value: r.status === "valid" ? r.value : this._def.catchValue({
|
|
3306
|
+
get error() {
|
|
3307
|
+
return new p(n.common.issues);
|
|
3308
|
+
},
|
|
3309
|
+
input: n.data
|
|
3310
|
+
})
|
|
3311
|
+
};
|
|
3312
|
+
}
|
|
3313
|
+
removeCatch() {
|
|
3314
|
+
return this._def.innerType;
|
|
3315
|
+
}
|
|
3316
|
+
};
|
|
3317
|
+
J.create = (e, t) => new J({
|
|
3318
|
+
innerType: e,
|
|
3319
|
+
typeName: Z.ZodCatch,
|
|
3320
|
+
catchValue: typeof t.catch == "function" ? t.catch : () => t.catch,
|
|
3321
|
+
...C(t)
|
|
3322
|
+
});
|
|
3323
|
+
var Y = class extends w {
|
|
3324
|
+
_parse(e) {
|
|
3325
|
+
if (this._getType(e) !== u.nan) {
|
|
3326
|
+
let t = this._getOrReturnCtx(e);
|
|
3327
|
+
return h(t, {
|
|
3328
|
+
code: f.invalid_type,
|
|
3329
|
+
expected: u.nan,
|
|
3330
|
+
received: t.parsedType
|
|
3331
|
+
}), _;
|
|
3332
|
+
}
|
|
3333
|
+
return {
|
|
3334
|
+
status: "valid",
|
|
3335
|
+
value: e.data
|
|
3336
|
+
};
|
|
3337
|
+
}
|
|
3338
|
+
};
|
|
3339
|
+
Y.create = (e) => new Y({
|
|
3340
|
+
typeName: Z.ZodNaN,
|
|
3341
|
+
...C(e)
|
|
3342
|
+
});
|
|
3343
|
+
var Qe = class extends w {
|
|
3344
|
+
_parse(e) {
|
|
3345
|
+
let { ctx: t } = this._processInputParams(e), n = t.data;
|
|
3346
|
+
return this._def.type._parse({
|
|
3347
|
+
data: n,
|
|
3348
|
+
path: t.path,
|
|
3349
|
+
parent: t
|
|
3350
|
+
});
|
|
3351
|
+
}
|
|
3352
|
+
unwrap() {
|
|
3353
|
+
return this._def.type;
|
|
3354
|
+
}
|
|
3355
|
+
}, $e = class e extends w {
|
|
3356
|
+
_parse(e) {
|
|
3357
|
+
let { status: t, ctx: n } = this._processInputParams(e);
|
|
3358
|
+
if (n.common.async) return (async () => {
|
|
3359
|
+
let e = await this._def.in._parseAsync({
|
|
3360
|
+
data: n.data,
|
|
3361
|
+
path: n.path,
|
|
3362
|
+
parent: n
|
|
3363
|
+
});
|
|
3364
|
+
return e.status === "aborted" ? _ : e.status === "dirty" ? (t.dirty(), de(e.value)) : this._def.out._parseAsync({
|
|
3365
|
+
data: e.value,
|
|
3366
|
+
path: n.path,
|
|
3367
|
+
parent: n
|
|
3368
|
+
});
|
|
3369
|
+
})();
|
|
3370
|
+
{
|
|
3371
|
+
let e = this._def.in._parseSync({
|
|
3372
|
+
data: n.data,
|
|
3373
|
+
path: n.path,
|
|
3374
|
+
parent: n
|
|
3375
|
+
});
|
|
3376
|
+
return e.status === "aborted" ? _ : e.status === "dirty" ? (t.dirty(), {
|
|
3377
|
+
status: "dirty",
|
|
3378
|
+
value: e.value
|
|
3379
|
+
}) : this._def.out._parseSync({
|
|
3380
|
+
data: e.value,
|
|
3381
|
+
path: n.path,
|
|
3382
|
+
parent: n
|
|
3383
|
+
});
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
static create(t, n) {
|
|
3387
|
+
return new e({
|
|
3388
|
+
in: t,
|
|
3389
|
+
out: n,
|
|
3390
|
+
typeName: Z.ZodPipeline
|
|
3391
|
+
});
|
|
3392
|
+
}
|
|
3393
|
+
}, X = class extends w {
|
|
3394
|
+
_parse(e) {
|
|
3395
|
+
let t = this._def.innerType._parse(e), n = (e) => (y(e) && (e.value = Object.freeze(e.value)), e);
|
|
3396
|
+
return b(t) ? t.then((e) => n(e)) : n(t);
|
|
3397
|
+
}
|
|
3398
|
+
unwrap() {
|
|
3399
|
+
return this._def.innerType;
|
|
3400
|
+
}
|
|
3401
|
+
};
|
|
3402
|
+
X.create = (e, t) => new X({
|
|
3403
|
+
innerType: e,
|
|
3404
|
+
typeName: Z.ZodReadonly,
|
|
3405
|
+
...C(t)
|
|
3406
|
+
}), P.lazycreate;
|
|
3407
|
+
var Z;
|
|
3408
|
+
(function(e) {
|
|
3409
|
+
e.ZodString = "ZodString", e.ZodNumber = "ZodNumber", e.ZodNaN = "ZodNaN", e.ZodBigInt = "ZodBigInt", e.ZodBoolean = "ZodBoolean", e.ZodDate = "ZodDate", e.ZodSymbol = "ZodSymbol", e.ZodUndefined = "ZodUndefined", e.ZodNull = "ZodNull", e.ZodAny = "ZodAny", e.ZodUnknown = "ZodUnknown", e.ZodNever = "ZodNever", e.ZodVoid = "ZodVoid", e.ZodArray = "ZodArray", e.ZodObject = "ZodObject", e.ZodUnion = "ZodUnion", e.ZodDiscriminatedUnion = "ZodDiscriminatedUnion", e.ZodIntersection = "ZodIntersection", e.ZodTuple = "ZodTuple", e.ZodRecord = "ZodRecord", e.ZodMap = "ZodMap", e.ZodSet = "ZodSet", e.ZodFunction = "ZodFunction", e.ZodLazy = "ZodLazy", e.ZodLiteral = "ZodLiteral", e.ZodEnum = "ZodEnum", e.ZodEffects = "ZodEffects", e.ZodNativeEnum = "ZodNativeEnum", e.ZodOptional = "ZodOptional", e.ZodNullable = "ZodNullable", e.ZodDefault = "ZodDefault", e.ZodCatch = "ZodCatch", e.ZodPromise = "ZodPromise", e.ZodBranded = "ZodBranded", e.ZodPipeline = "ZodPipeline", e.ZodReadonly = "ZodReadonly";
|
|
3410
|
+
})(Z ||= {});
|
|
3411
|
+
var Q = T.create, et = E.create;
|
|
3412
|
+
Y.create, D.create, Be.create, Ve.create, He.create, O.create, k.create, Ue.create, A.create, j.create, We.create;
|
|
3413
|
+
var tt = M.create, $ = P.create;
|
|
3414
|
+
P.strictCreate, F.create, Ge.create, L.create, R.create, qe.create, Je.create, Ye.create, Xe.create, z.create, B.create;
|
|
3415
|
+
var nt = V.create;
|
|
3416
|
+
H.create, U.create, W.create, G.create, K.create, W.createWithPreprocess, $e.create;
|
|
3417
|
+
var rt = [
|
|
3418
|
+
{
|
|
3419
|
+
name: "list_projects",
|
|
3420
|
+
title: "List Projects",
|
|
3421
|
+
description: "Retrieve all projects in the workspace.",
|
|
3422
|
+
zodSchema: $({}),
|
|
3423
|
+
inputSchema: {
|
|
3424
|
+
type: "object",
|
|
3425
|
+
properties: {},
|
|
3426
|
+
additionalProperties: !1
|
|
3427
|
+
},
|
|
3428
|
+
annotations: { readOnlyHint: !0 },
|
|
3429
|
+
execute: async (e, t) => t.getProjects()
|
|
3430
|
+
},
|
|
3431
|
+
{
|
|
3432
|
+
name: "get_project",
|
|
3433
|
+
title: "Get Project",
|
|
3434
|
+
description: "Get details of a specific project by its ID.",
|
|
3435
|
+
zodSchema: $({ id: Q().describe("The project ID") }),
|
|
3436
|
+
inputSchema: {
|
|
3437
|
+
type: "object",
|
|
3438
|
+
properties: { id: {
|
|
3439
|
+
type: "string",
|
|
3440
|
+
description: "The project ID"
|
|
3441
|
+
} },
|
|
3442
|
+
required: ["id"],
|
|
3443
|
+
additionalProperties: !1
|
|
3444
|
+
},
|
|
3445
|
+
annotations: { readOnlyHint: !0 },
|
|
3446
|
+
execute: async (e, t) => t.getProject(e.id)
|
|
3447
|
+
},
|
|
3448
|
+
{
|
|
3449
|
+
name: "create_project",
|
|
3450
|
+
title: "Create Project",
|
|
3451
|
+
description: "Create a new project workspace.",
|
|
3452
|
+
zodSchema: $({
|
|
3453
|
+
name: Q().describe("Name of the project"),
|
|
3454
|
+
description: Q().optional().describe("Description of the project"),
|
|
3455
|
+
key: Q().optional().describe("Short project key/prefix (e.g. \"PROJ\")")
|
|
3456
|
+
}),
|
|
3457
|
+
inputSchema: {
|
|
3458
|
+
type: "object",
|
|
3459
|
+
properties: {
|
|
3460
|
+
name: {
|
|
3461
|
+
type: "string",
|
|
3462
|
+
description: "Name of the project"
|
|
3463
|
+
},
|
|
3464
|
+
description: {
|
|
3465
|
+
type: "string",
|
|
3466
|
+
description: "Description of the project"
|
|
3467
|
+
},
|
|
3468
|
+
key: {
|
|
3469
|
+
type: "string",
|
|
3470
|
+
description: "Short project key/prefix (e.g. \"PROJ\")"
|
|
3471
|
+
}
|
|
3472
|
+
},
|
|
3473
|
+
required: ["name"],
|
|
3474
|
+
additionalProperties: !1
|
|
3475
|
+
},
|
|
3476
|
+
execute: async (e, t) => t.createProject(e)
|
|
3477
|
+
},
|
|
3478
|
+
{
|
|
3479
|
+
name: "list_tasks",
|
|
3480
|
+
title: "List Tasks",
|
|
3481
|
+
description: "List tasks, optionally filtered by project, status, priority, or assignee.",
|
|
3482
|
+
zodSchema: $({
|
|
3483
|
+
projectId: Q().optional().describe("Filter by project ID"),
|
|
3484
|
+
status: Q().optional().describe("Filter by task status key"),
|
|
3485
|
+
priority: nt([
|
|
3486
|
+
"urgent",
|
|
3487
|
+
"high",
|
|
3488
|
+
"medium",
|
|
3489
|
+
"low",
|
|
3490
|
+
"none"
|
|
3491
|
+
]).optional().describe("Filter by priority"),
|
|
3492
|
+
assigneeId: Q().optional().describe("Filter by assignee ID")
|
|
3493
|
+
}),
|
|
3494
|
+
inputSchema: {
|
|
3495
|
+
type: "object",
|
|
3496
|
+
properties: {
|
|
3497
|
+
projectId: {
|
|
3498
|
+
type: "string",
|
|
3499
|
+
description: "Filter by project ID"
|
|
3500
|
+
},
|
|
3501
|
+
status: {
|
|
3502
|
+
type: "string",
|
|
3503
|
+
description: "Filter by task status key"
|
|
3504
|
+
},
|
|
3505
|
+
priority: {
|
|
3506
|
+
type: "string",
|
|
3507
|
+
enum: [
|
|
3508
|
+
"urgent",
|
|
3509
|
+
"high",
|
|
3510
|
+
"medium",
|
|
3511
|
+
"low",
|
|
3512
|
+
"none"
|
|
3513
|
+
],
|
|
3514
|
+
description: "Filter by priority"
|
|
3515
|
+
},
|
|
3516
|
+
assigneeId: {
|
|
3517
|
+
type: "string",
|
|
3518
|
+
description: "Filter by assignee ID"
|
|
3519
|
+
}
|
|
3520
|
+
},
|
|
3521
|
+
additionalProperties: !1
|
|
3522
|
+
},
|
|
3523
|
+
annotations: { readOnlyHint: !0 },
|
|
3524
|
+
execute: async (e, t, n) => {
|
|
3525
|
+
let r = e.projectId || n?.projectId, i = await t.getTasks(r);
|
|
3526
|
+
return e.status && (i = i.filter((t) => t.status === e.status)), e.priority && (i = i.filter((t) => t.priority === e.priority)), e.assigneeId && (i = i.filter((t) => t.assigneeId === e.assigneeId)), i;
|
|
3527
|
+
}
|
|
3528
|
+
},
|
|
3529
|
+
{
|
|
3530
|
+
name: "get_task",
|
|
3531
|
+
title: "Get Task",
|
|
3532
|
+
description: "Get task details by ID.",
|
|
3533
|
+
zodSchema: $({ id: Q().describe("The task ID") }),
|
|
3534
|
+
inputSchema: {
|
|
3535
|
+
type: "object",
|
|
3536
|
+
properties: { id: {
|
|
3537
|
+
type: "string",
|
|
3538
|
+
description: "The task ID"
|
|
3539
|
+
} },
|
|
3540
|
+
required: ["id"],
|
|
3541
|
+
additionalProperties: !1
|
|
3542
|
+
},
|
|
3543
|
+
annotations: { readOnlyHint: !0 },
|
|
3544
|
+
execute: async (e, t) => t.getTask(e.id)
|
|
3545
|
+
},
|
|
3546
|
+
{
|
|
3547
|
+
name: "create_task",
|
|
3548
|
+
title: "Create Task",
|
|
3549
|
+
description: "Create a new task within a project.",
|
|
3550
|
+
zodSchema: $({
|
|
3551
|
+
projectId: Q().optional().describe("Project ID (inferred from active view in browser if omitted)"),
|
|
3552
|
+
title: Q().describe("Title of the task"),
|
|
3553
|
+
description: Q().optional().describe("Detailed description / markdown"),
|
|
3554
|
+
status: Q().optional().describe("Status (defaults to \"todo\" or first workflow status)"),
|
|
3555
|
+
priority: nt([
|
|
3556
|
+
"urgent",
|
|
3557
|
+
"high",
|
|
3558
|
+
"medium",
|
|
3559
|
+
"low",
|
|
3560
|
+
"none"
|
|
3561
|
+
]).optional().default("none").describe("Task priority"),
|
|
3562
|
+
assigneeId: Q().optional().describe("User ID to assign task to"),
|
|
3563
|
+
dueDate: Q().optional().describe("Due date (ISO string)"),
|
|
3564
|
+
tags: tt(Q()).optional().describe("Tags for categorization"),
|
|
3565
|
+
estimatedHours: et().optional().describe("Estimated hours to complete")
|
|
3566
|
+
}),
|
|
3567
|
+
inputSchema: {
|
|
3568
|
+
type: "object",
|
|
3569
|
+
properties: {
|
|
3570
|
+
projectId: {
|
|
3571
|
+
type: "string",
|
|
3572
|
+
description: "Project ID (inferred from active view if omitted)"
|
|
3573
|
+
},
|
|
3574
|
+
title: {
|
|
3575
|
+
type: "string",
|
|
3576
|
+
description: "Title of the task"
|
|
3577
|
+
},
|
|
3578
|
+
description: {
|
|
3579
|
+
type: "string",
|
|
3580
|
+
description: "Detailed description"
|
|
3581
|
+
},
|
|
3582
|
+
status: {
|
|
3583
|
+
type: "string",
|
|
3584
|
+
description: "Status key"
|
|
3585
|
+
},
|
|
3586
|
+
priority: {
|
|
3587
|
+
type: "string",
|
|
3588
|
+
enum: [
|
|
3589
|
+
"urgent",
|
|
3590
|
+
"high",
|
|
3591
|
+
"medium",
|
|
3592
|
+
"low",
|
|
3593
|
+
"none"
|
|
3594
|
+
]
|
|
3595
|
+
},
|
|
3596
|
+
assigneeId: {
|
|
3597
|
+
type: "string",
|
|
3598
|
+
description: "User ID of assignee"
|
|
3599
|
+
},
|
|
3600
|
+
dueDate: {
|
|
3601
|
+
type: "string",
|
|
3602
|
+
description: "Due date in ISO 8601 format"
|
|
3603
|
+
},
|
|
3604
|
+
tags: {
|
|
3605
|
+
type: "array",
|
|
3606
|
+
items: { type: "string" }
|
|
3607
|
+
},
|
|
3608
|
+
estimatedHours: { type: "number" }
|
|
3609
|
+
},
|
|
3610
|
+
required: ["title"],
|
|
3611
|
+
additionalProperties: !1
|
|
3612
|
+
},
|
|
3613
|
+
execute: async (e, t, n) => {
|
|
3614
|
+
let r = e.projectId || n?.projectId;
|
|
3615
|
+
if (!r) throw Error("projectId is required to create a task, but none was provided or active in context.");
|
|
3616
|
+
let i = {
|
|
3617
|
+
projectId: r,
|
|
3618
|
+
title: e.title,
|
|
3619
|
+
description: e.description,
|
|
3620
|
+
status: e.status || "todo",
|
|
3621
|
+
priority: e.priority || "none",
|
|
3622
|
+
assigneeId: e.assigneeId,
|
|
3623
|
+
dueDate: e.dueDate,
|
|
3624
|
+
tags: e.tags || [],
|
|
3625
|
+
estimatedHours: e.estimatedHours
|
|
3626
|
+
};
|
|
3627
|
+
return t.createTask(i);
|
|
3628
|
+
}
|
|
3629
|
+
},
|
|
3630
|
+
{
|
|
3631
|
+
name: "update_task",
|
|
3632
|
+
title: "Update Task",
|
|
3633
|
+
description: "Update fields of an existing task (e.g. title, status, priority, assignee).",
|
|
3634
|
+
zodSchema: $({
|
|
3635
|
+
id: Q().describe("The task ID"),
|
|
3636
|
+
title: Q().optional(),
|
|
3637
|
+
description: Q().optional(),
|
|
3638
|
+
status: Q().optional(),
|
|
3639
|
+
priority: nt([
|
|
3640
|
+
"urgent",
|
|
3641
|
+
"high",
|
|
3642
|
+
"medium",
|
|
3643
|
+
"low",
|
|
3644
|
+
"none"
|
|
3645
|
+
]).optional(),
|
|
3646
|
+
assigneeId: Q().optional(),
|
|
3647
|
+
dueDate: Q().optional(),
|
|
3648
|
+
tags: tt(Q()).optional(),
|
|
3649
|
+
estimatedHours: et().optional(),
|
|
3650
|
+
loggedHours: et().optional()
|
|
3651
|
+
}),
|
|
3652
|
+
inputSchema: {
|
|
3653
|
+
type: "object",
|
|
3654
|
+
properties: {
|
|
3655
|
+
id: {
|
|
3656
|
+
type: "string",
|
|
3657
|
+
description: "Task ID"
|
|
3658
|
+
},
|
|
3659
|
+
title: { type: "string" },
|
|
3660
|
+
description: { type: "string" },
|
|
3661
|
+
status: { type: "string" },
|
|
3662
|
+
priority: {
|
|
3663
|
+
type: "string",
|
|
3664
|
+
enum: [
|
|
3665
|
+
"urgent",
|
|
3666
|
+
"high",
|
|
3667
|
+
"medium",
|
|
3668
|
+
"low",
|
|
3669
|
+
"none"
|
|
3670
|
+
]
|
|
3671
|
+
},
|
|
3672
|
+
assigneeId: { type: "string" },
|
|
3673
|
+
dueDate: { type: "string" },
|
|
3674
|
+
tags: {
|
|
3675
|
+
type: "array",
|
|
3676
|
+
items: { type: "string" }
|
|
3677
|
+
},
|
|
3678
|
+
estimatedHours: { type: "number" },
|
|
3679
|
+
loggedHours: { type: "number" }
|
|
3680
|
+
},
|
|
3681
|
+
required: ["id"],
|
|
3682
|
+
additionalProperties: !1
|
|
3683
|
+
},
|
|
3684
|
+
execute: async (e, t) => {
|
|
3685
|
+
let { id: n, ...r } = e;
|
|
3686
|
+
return t.updateTask(n, r);
|
|
3687
|
+
}
|
|
3688
|
+
},
|
|
3689
|
+
{
|
|
3690
|
+
name: "delete_task",
|
|
3691
|
+
title: "Delete Task",
|
|
3692
|
+
description: "Delete a task by ID.",
|
|
3693
|
+
zodSchema: $({ id: Q().describe("The task ID to delete") }),
|
|
3694
|
+
inputSchema: {
|
|
3695
|
+
type: "object",
|
|
3696
|
+
properties: { id: {
|
|
3697
|
+
type: "string",
|
|
3698
|
+
description: "The task ID"
|
|
3699
|
+
} },
|
|
3700
|
+
required: ["id"],
|
|
3701
|
+
additionalProperties: !1
|
|
3702
|
+
},
|
|
3703
|
+
annotations: { requiresConfirmation: !0 },
|
|
3704
|
+
execute: async (e, t) => ({ success: await t.deleteTask(e.id) })
|
|
3705
|
+
},
|
|
3706
|
+
{
|
|
3707
|
+
name: "list_deliverables",
|
|
3708
|
+
title: "List Deliverables",
|
|
3709
|
+
description: "List deliverables/milestones for a project.",
|
|
3710
|
+
zodSchema: $({ projectId: Q().optional().describe("Project ID") }),
|
|
3711
|
+
inputSchema: {
|
|
3712
|
+
type: "object",
|
|
3713
|
+
properties: { projectId: {
|
|
3714
|
+
type: "string",
|
|
3715
|
+
description: "Project ID"
|
|
3716
|
+
} },
|
|
3717
|
+
additionalProperties: !1
|
|
3718
|
+
},
|
|
3719
|
+
annotations: { readOnlyHint: !0 },
|
|
3720
|
+
execute: async (e, t, n) => {
|
|
3721
|
+
let r = e.projectId || n?.projectId;
|
|
3722
|
+
if (!r) throw Error("projectId is required to list deliverables.");
|
|
3723
|
+
return "getDeliverables" in t && typeof t.getDeliverables == "function" ? t.getDeliverables(r) : [];
|
|
3724
|
+
}
|
|
3725
|
+
},
|
|
3726
|
+
{
|
|
3727
|
+
name: "create_deliverable",
|
|
3728
|
+
title: "Create Deliverable",
|
|
3729
|
+
description: "Create a milestone deliverable within a project.",
|
|
3730
|
+
zodSchema: $({
|
|
3731
|
+
projectId: Q().optional(),
|
|
3732
|
+
title: Q(),
|
|
3733
|
+
description: Q().optional(),
|
|
3734
|
+
dueDate: Q().optional(),
|
|
3735
|
+
taskIds: tt(Q()).optional()
|
|
3736
|
+
}),
|
|
3737
|
+
inputSchema: {
|
|
3738
|
+
type: "object",
|
|
3739
|
+
properties: {
|
|
3740
|
+
projectId: { type: "string" },
|
|
3741
|
+
title: { type: "string" },
|
|
3742
|
+
description: { type: "string" },
|
|
3743
|
+
dueDate: { type: "string" },
|
|
3744
|
+
taskIds: {
|
|
3745
|
+
type: "array",
|
|
3746
|
+
items: { type: "string" }
|
|
3747
|
+
}
|
|
3748
|
+
},
|
|
3749
|
+
required: ["title"],
|
|
3750
|
+
additionalProperties: !1
|
|
3751
|
+
},
|
|
3752
|
+
execute: async (e, t, n) => {
|
|
3753
|
+
let r = e.projectId || n?.projectId;
|
|
3754
|
+
if (!r) throw Error("projectId is required to create a deliverable.");
|
|
3755
|
+
if ("createDeliverable" in t && typeof t.createDeliverable == "function") return t.createDeliverable({
|
|
3756
|
+
...e,
|
|
3757
|
+
projectId: r
|
|
3758
|
+
});
|
|
3759
|
+
throw Error("createDeliverable is not supported by this backend target.");
|
|
3760
|
+
}
|
|
3761
|
+
},
|
|
3762
|
+
{
|
|
3763
|
+
name: "list_comments",
|
|
3764
|
+
title: "List Comments",
|
|
3765
|
+
description: "List comments associated with a task.",
|
|
3766
|
+
zodSchema: $({ taskId: Q().describe("The task ID") }),
|
|
3767
|
+
inputSchema: {
|
|
3768
|
+
type: "object",
|
|
3769
|
+
properties: { taskId: {
|
|
3770
|
+
type: "string",
|
|
3771
|
+
description: "The task ID"
|
|
3772
|
+
} },
|
|
3773
|
+
required: ["taskId"],
|
|
3774
|
+
additionalProperties: !1
|
|
3775
|
+
},
|
|
3776
|
+
annotations: { readOnlyHint: !0 },
|
|
3777
|
+
execute: async (e, t) => "getComments" in t && typeof t.getComments == "function" ? t.getComments(e.taskId) : []
|
|
3778
|
+
},
|
|
3779
|
+
{
|
|
3780
|
+
name: "add_comment",
|
|
3781
|
+
title: "Add Comment",
|
|
3782
|
+
description: "Add a comment to a task.",
|
|
3783
|
+
zodSchema: $({
|
|
3784
|
+
taskId: Q().describe("The task ID"),
|
|
3785
|
+
content: Q().describe("Comment body/markdown"),
|
|
3786
|
+
authorId: Q().describe("Author user ID")
|
|
3787
|
+
}),
|
|
3788
|
+
inputSchema: {
|
|
3789
|
+
type: "object",
|
|
3790
|
+
properties: {
|
|
3791
|
+
taskId: {
|
|
3792
|
+
type: "string",
|
|
3793
|
+
description: "The task ID"
|
|
3794
|
+
},
|
|
3795
|
+
content: {
|
|
3796
|
+
type: "string",
|
|
3797
|
+
description: "Comment body/markdown"
|
|
3798
|
+
},
|
|
3799
|
+
authorId: {
|
|
3800
|
+
type: "string",
|
|
3801
|
+
description: "Author user ID"
|
|
3802
|
+
}
|
|
3803
|
+
},
|
|
3804
|
+
required: [
|
|
3805
|
+
"taskId",
|
|
3806
|
+
"content",
|
|
3807
|
+
"authorId"
|
|
3808
|
+
],
|
|
3809
|
+
additionalProperties: !1
|
|
3810
|
+
},
|
|
3811
|
+
execute: async (e, t) => t.addComment({
|
|
3812
|
+
taskId: e.taskId,
|
|
3813
|
+
content: e.content,
|
|
3814
|
+
authorId: e.authorId
|
|
3815
|
+
})
|
|
3816
|
+
}
|
|
3817
|
+
];
|
|
3818
|
+
new Map(rt.map((e) => [e.name, e]));
|
|
3819
|
+
//#endregion
|
|
3820
|
+
//#region ../mcp/dist/web/index.js
|
|
3821
|
+
function it(e = typeof document < "u" ? document : null) {
|
|
3822
|
+
if (!e) return null;
|
|
3823
|
+
if (!e.modelContext) {
|
|
3824
|
+
let t = /* @__PURE__ */ new Map();
|
|
3825
|
+
e.modelContext = {
|
|
3826
|
+
registerTool(e, n) {
|
|
3827
|
+
t.set(e.name, e), n?.signal && n.signal.addEventListener("abort", () => {
|
|
3828
|
+
t.delete(e.name);
|
|
3829
|
+
}, { once: !0 });
|
|
3830
|
+
},
|
|
3831
|
+
unregisterTool(e) {
|
|
3832
|
+
t.delete(e);
|
|
3833
|
+
},
|
|
3834
|
+
async getTools() {
|
|
3835
|
+
return Array.from(t.values());
|
|
3836
|
+
},
|
|
3837
|
+
async executeTool(e, n) {
|
|
3838
|
+
let r = t.get(e);
|
|
3839
|
+
if (!r) throw Error(`Tool "${e}" is not registered on modelContext.`);
|
|
3840
|
+
return r.execute(n || {});
|
|
3841
|
+
}
|
|
3842
|
+
};
|
|
3843
|
+
}
|
|
3844
|
+
return e.modelContext;
|
|
3845
|
+
}
|
|
3846
|
+
function at(e) {
|
|
3847
|
+
let t = e.document ?? (typeof document < "u" ? document : null), n = e.navigator ?? (typeof navigator < "u" ? navigator : null), r = e.window ?? (typeof window < "u" ? window : null), i;
|
|
3848
|
+
t?.modelContext ? i = t.modelContext : n?.modelContext ? i = n.modelContext : t && (i = it(t) ?? void 0);
|
|
3849
|
+
let a = e.tools ? rt.filter((t) => e.tools.includes(t.name)) : rt, o = [], s = new AbortController();
|
|
3850
|
+
e.signal && e.signal.addEventListener("abort", () => s.abort(), { once: !0 });
|
|
3851
|
+
for (let t of a) {
|
|
3852
|
+
let n = {
|
|
3853
|
+
name: t.name,
|
|
3854
|
+
title: t.title,
|
|
3855
|
+
description: t.description,
|
|
3856
|
+
inputSchema: t.inputSchema,
|
|
3857
|
+
annotations: t.annotations,
|
|
3858
|
+
execute: async (n) => {
|
|
3859
|
+
let r = e.projectId ? { projectId: e.projectId } : void 0, i = await t.execute(n, e.client, r);
|
|
3860
|
+
return e.onToolExecuted?.(t.name, n, i), i;
|
|
3861
|
+
}
|
|
3862
|
+
};
|
|
3863
|
+
if (o.push(n), i?.registerTool) try {
|
|
3864
|
+
i.registerTool(n, { signal: s.signal });
|
|
3865
|
+
} catch (e) {
|
|
3866
|
+
console.warn(`[Critical Path WebMCP] Failed to register tool "${n.name}":`, e);
|
|
3867
|
+
}
|
|
3868
|
+
}
|
|
3869
|
+
return r && (r.__CRITICAL_PATH_WEBMCP__ = {
|
|
3870
|
+
projectId: e.projectId,
|
|
3871
|
+
tools: o,
|
|
3872
|
+
execute: async (e, t) => {
|
|
3873
|
+
let n = o.find((t) => t.name === e);
|
|
3874
|
+
if (!n) throw Error(`WebMCP tool "${e}" not found in Critical Path registry.`);
|
|
3875
|
+
return n.execute(t);
|
|
3876
|
+
}
|
|
3877
|
+
}), {
|
|
3878
|
+
unregister: () => {
|
|
3879
|
+
if (s.abort(), i?.unregisterTool) for (let e of o) i.unregisterTool(e.name);
|
|
3880
|
+
r && r.__CRITICAL_PATH_WEBMCP__?.tools === o && delete r.__CRITICAL_PATH_WEBMCP__;
|
|
3881
|
+
},
|
|
3882
|
+
getRegisteredTools: () => o
|
|
3883
|
+
};
|
|
3884
|
+
}
|
|
3885
|
+
//#endregion
|
|
3886
|
+
//#region src/webmcp-state.svelte.ts
|
|
3887
|
+
var ot = class {
|
|
3888
|
+
client;
|
|
3889
|
+
options;
|
|
3890
|
+
#e = t.state(!1);
|
|
3891
|
+
get registered() {
|
|
3892
|
+
return t.get(this.#e);
|
|
3893
|
+
}
|
|
3894
|
+
set registered(e) {
|
|
3895
|
+
t.set(this.#e, e, !0);
|
|
3896
|
+
}
|
|
3897
|
+
#t = t.state(void 0);
|
|
3898
|
+
get activeProjectId() {
|
|
3899
|
+
return t.get(this.#t);
|
|
3900
|
+
}
|
|
3901
|
+
set activeProjectId(e) {
|
|
3902
|
+
t.set(this.#t, e, !0);
|
|
3903
|
+
}
|
|
3904
|
+
#n = t.state(t.proxy([]));
|
|
3905
|
+
get tools() {
|
|
3906
|
+
return t.get(this.#n);
|
|
3907
|
+
}
|
|
3908
|
+
set tools(e) {
|
|
3909
|
+
t.set(this.#n, e, !0);
|
|
3910
|
+
}
|
|
3911
|
+
#r = t.state(null);
|
|
3912
|
+
get error() {
|
|
3913
|
+
return t.get(this.#r);
|
|
3914
|
+
}
|
|
3915
|
+
set error(e) {
|
|
3916
|
+
t.set(this.#r, e, !0);
|
|
3917
|
+
}
|
|
3918
|
+
handle = null;
|
|
3919
|
+
abortController = null;
|
|
3920
|
+
constructor(e, t = {}) {
|
|
3921
|
+
this.client = e, this.options = t, this.activeProjectId = t.projectId, (t.autoRegister ?? !0) && this.register();
|
|
3922
|
+
}
|
|
3923
|
+
register() {
|
|
3924
|
+
if (!this.registered) {
|
|
3925
|
+
this.error = null;
|
|
3926
|
+
try {
|
|
3927
|
+
this.abortController = new AbortController(), this.handle = at({
|
|
3928
|
+
client: this.client,
|
|
3929
|
+
projectId: this.activeProjectId,
|
|
3930
|
+
tools: this.options.tools,
|
|
3931
|
+
signal: this.abortController.signal,
|
|
3932
|
+
document: this.options.document,
|
|
3933
|
+
navigator: this.options.navigator,
|
|
3934
|
+
window: this.options.window,
|
|
3935
|
+
onToolExecuted: (e, t, n) => {
|
|
3936
|
+
this.options.onToolExecuted?.(e, t, n);
|
|
3937
|
+
}
|
|
3938
|
+
}), this.tools = this.handle.getRegisteredTools().map((e) => e.name), this.registered = !0;
|
|
3939
|
+
} catch (e) {
|
|
3940
|
+
this.error = e instanceof Error ? e : Error(String(e)), this.registered = !1;
|
|
3941
|
+
}
|
|
3942
|
+
}
|
|
3943
|
+
}
|
|
3944
|
+
unregister() {
|
|
3945
|
+
this.registered && (this.abortController?.abort(), this.handle?.unregister(), this.handle = null, this.abortController = null, this.registered = !1, this.tools = []);
|
|
3946
|
+
}
|
|
3947
|
+
setProjectId(e) {
|
|
3948
|
+
this.activeProjectId !== e && (this.activeProjectId = e, this.registered && (this.unregister(), this.register()));
|
|
3949
|
+
}
|
|
3950
|
+
};
|
|
3951
|
+
function st(e, t) {
|
|
3952
|
+
return new ot(e, t);
|
|
685
3953
|
}
|
|
686
3954
|
//#endregion
|
|
687
3955
|
//#region src/index.ts
|
|
688
|
-
function
|
|
3956
|
+
function ct(t) {
|
|
689
3957
|
return new e(t);
|
|
690
3958
|
}
|
|
691
3959
|
//#endregion
|
|
692
|
-
export {
|
|
3960
|
+
export { te as AttachmentState, c as CommentState, ae as DeliverableState, n as ProjectState, re as TaskActivityState, i as TaskState, ot as WebMcpState, o as WorkflowState, ne as createAttachmentState, ee as createCommentState, ct as createCriticalPathClient, oe as createDeliverableState, r as createProjectState, ie as createTaskActivityState, a as createTaskState, st as createWebMcpState, s as createWorkflowState };
|