@abraca/mcp 1.5.0 → 1.6.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/dist/abracadabra-mcp.cjs +1425 -882
- package/dist/abracadabra-mcp.cjs.map +1 -1
- package/dist/abracadabra-mcp.esm.js +1425 -882
- package/dist/abracadabra-mcp.esm.js.map +1 -1
- package/dist/index.d.ts +1 -8705
- package/package.json +3 -3
|
@@ -216,7 +216,7 @@ var ZodError$1 = class ZodError$1 extends Error {
|
|
|
216
216
|
return this.issues.length === 0;
|
|
217
217
|
}
|
|
218
218
|
flatten(mapper = (issue) => issue.message) {
|
|
219
|
-
const fieldErrors =
|
|
219
|
+
const fieldErrors = Object.create(null);
|
|
220
220
|
const formErrors = [];
|
|
221
221
|
for (const sub of this.issues) if (sub.path.length > 0) {
|
|
222
222
|
const firstEl = sub.path[0];
|
|
@@ -3591,17 +3591,23 @@ const pipelineType = ZodPipeline.create;
|
|
|
3591
3591
|
const NEVER = Object.freeze({ status: "aborted" });
|
|
3592
3592
|
function $constructor(name, initializer, params) {
|
|
3593
3593
|
function init(inst, def) {
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3594
|
+
if (!inst._zod) Object.defineProperty(inst, "_zod", {
|
|
3595
|
+
value: {
|
|
3596
|
+
def,
|
|
3597
|
+
constr: _,
|
|
3598
|
+
traits: /* @__PURE__ */ new Set()
|
|
3599
|
+
},
|
|
3597
3600
|
enumerable: false
|
|
3598
3601
|
});
|
|
3599
|
-
(
|
|
3602
|
+
if (inst._zod.traits.has(name)) return;
|
|
3600
3603
|
inst._zod.traits.add(name);
|
|
3601
3604
|
initializer(inst, def);
|
|
3602
|
-
|
|
3603
|
-
|
|
3604
|
-
|
|
3605
|
+
const proto = _.prototype;
|
|
3606
|
+
const keys = Object.keys(proto);
|
|
3607
|
+
for (let i = 0; i < keys.length; i++) {
|
|
3608
|
+
const k = keys[i];
|
|
3609
|
+
if (!(k in inst)) inst[k] = proto[k].bind(inst);
|
|
3610
|
+
}
|
|
3605
3611
|
}
|
|
3606
3612
|
const Parent = params?.Parent ?? Object;
|
|
3607
3613
|
class Definition extends Parent {}
|
|
@@ -3627,6 +3633,12 @@ var $ZodAsyncError = class extends Error {
|
|
|
3627
3633
|
super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`);
|
|
3628
3634
|
}
|
|
3629
3635
|
};
|
|
3636
|
+
var $ZodEncodeError = class extends Error {
|
|
3637
|
+
constructor(name) {
|
|
3638
|
+
super(`Encountered unidirectional transform during encode: ${name}`);
|
|
3639
|
+
this.name = "ZodEncodeError";
|
|
3640
|
+
}
|
|
3641
|
+
};
|
|
3630
3642
|
const globalConfig = {};
|
|
3631
3643
|
function config(newConfig) {
|
|
3632
3644
|
if (newConfig) Object.assign(globalConfig, newConfig);
|
|
@@ -3663,19 +3675,26 @@ function cleanRegex(source) {
|
|
|
3663
3675
|
}
|
|
3664
3676
|
function floatSafeRemainder(val, step) {
|
|
3665
3677
|
const valDecCount = (val.toString().split(".")[1] || "").length;
|
|
3666
|
-
const
|
|
3678
|
+
const stepString = step.toString();
|
|
3679
|
+
let stepDecCount = (stepString.split(".")[1] || "").length;
|
|
3680
|
+
if (stepDecCount === 0 && /\d?e-\d?/.test(stepString)) {
|
|
3681
|
+
const match = stepString.match(/\d?e-(\d?)/);
|
|
3682
|
+
if (match?.[1]) stepDecCount = Number.parseInt(match[1]);
|
|
3683
|
+
}
|
|
3667
3684
|
const decCount = valDecCount > stepDecCount ? valDecCount : stepDecCount;
|
|
3668
3685
|
return Number.parseInt(val.toFixed(decCount).replace(".", "")) % Number.parseInt(step.toFixed(decCount).replace(".", "")) / 10 ** decCount;
|
|
3669
3686
|
}
|
|
3687
|
+
const EVALUATING = Symbol("evaluating");
|
|
3670
3688
|
function defineLazy(object, key, getter) {
|
|
3689
|
+
let value = void 0;
|
|
3671
3690
|
Object.defineProperty(object, key, {
|
|
3672
3691
|
get() {
|
|
3673
|
-
|
|
3674
|
-
|
|
3675
|
-
|
|
3676
|
-
|
|
3692
|
+
if (value === EVALUATING) return;
|
|
3693
|
+
if (value === void 0) {
|
|
3694
|
+
value = EVALUATING;
|
|
3695
|
+
value = getter();
|
|
3677
3696
|
}
|
|
3678
|
-
|
|
3697
|
+
return value;
|
|
3679
3698
|
},
|
|
3680
3699
|
set(v) {
|
|
3681
3700
|
Object.defineProperty(object, key, { value: v });
|
|
@@ -3691,10 +3710,21 @@ function assignProp(target, prop, value) {
|
|
|
3691
3710
|
configurable: true
|
|
3692
3711
|
});
|
|
3693
3712
|
}
|
|
3713
|
+
function mergeDefs(...defs) {
|
|
3714
|
+
const mergedDescriptors = {};
|
|
3715
|
+
for (const def of defs) {
|
|
3716
|
+
const descriptors = Object.getOwnPropertyDescriptors(def);
|
|
3717
|
+
Object.assign(mergedDescriptors, descriptors);
|
|
3718
|
+
}
|
|
3719
|
+
return Object.defineProperties({}, mergedDescriptors);
|
|
3720
|
+
}
|
|
3694
3721
|
function esc(str) {
|
|
3695
3722
|
return JSON.stringify(str);
|
|
3696
3723
|
}
|
|
3697
|
-
|
|
3724
|
+
function slugify(input) {
|
|
3725
|
+
return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
3726
|
+
}
|
|
3727
|
+
const captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
|
|
3698
3728
|
function isObject(data) {
|
|
3699
3729
|
return typeof data === "object" && data !== null && !Array.isArray(data);
|
|
3700
3730
|
}
|
|
@@ -3711,11 +3741,17 @@ function isPlainObject$1(o) {
|
|
|
3711
3741
|
if (isObject(o) === false) return false;
|
|
3712
3742
|
const ctor = o.constructor;
|
|
3713
3743
|
if (ctor === void 0) return true;
|
|
3744
|
+
if (typeof ctor !== "function") return true;
|
|
3714
3745
|
const prot = ctor.prototype;
|
|
3715
3746
|
if (isObject(prot) === false) return false;
|
|
3716
3747
|
if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) return false;
|
|
3717
3748
|
return true;
|
|
3718
3749
|
}
|
|
3750
|
+
function shallowClone(o) {
|
|
3751
|
+
if (isPlainObject$1(o)) return { ...o };
|
|
3752
|
+
if (Array.isArray(o)) return [...o];
|
|
3753
|
+
return o;
|
|
3754
|
+
}
|
|
3719
3755
|
const propertyKeyTypes = new Set([
|
|
3720
3756
|
"string",
|
|
3721
3757
|
"number",
|
|
@@ -3757,51 +3793,70 @@ const NUMBER_FORMAT_RANGES = {
|
|
|
3757
3793
|
float64: [-Number.MAX_VALUE, Number.MAX_VALUE]
|
|
3758
3794
|
};
|
|
3759
3795
|
function pick(schema, mask) {
|
|
3760
|
-
const newShape = {};
|
|
3761
3796
|
const currDef = schema._zod.def;
|
|
3762
|
-
|
|
3763
|
-
|
|
3764
|
-
|
|
3765
|
-
|
|
3766
|
-
|
|
3767
|
-
|
|
3768
|
-
|
|
3769
|
-
|
|
3797
|
+
const checks = currDef.checks;
|
|
3798
|
+
if (checks && checks.length > 0) throw new Error(".pick() cannot be used on object schemas containing refinements");
|
|
3799
|
+
return clone(schema, mergeDefs(schema._zod.def, {
|
|
3800
|
+
get shape() {
|
|
3801
|
+
const newShape = {};
|
|
3802
|
+
for (const key in mask) {
|
|
3803
|
+
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
3804
|
+
if (!mask[key]) continue;
|
|
3805
|
+
newShape[key] = currDef.shape[key];
|
|
3806
|
+
}
|
|
3807
|
+
assignProp(this, "shape", newShape);
|
|
3808
|
+
return newShape;
|
|
3809
|
+
},
|
|
3770
3810
|
checks: []
|
|
3771
|
-
});
|
|
3811
|
+
}));
|
|
3772
3812
|
}
|
|
3773
3813
|
function omit(schema, mask) {
|
|
3774
|
-
const newShape = { ...schema._zod.def.shape };
|
|
3775
3814
|
const currDef = schema._zod.def;
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3779
|
-
|
|
3780
|
-
|
|
3781
|
-
|
|
3782
|
-
|
|
3783
|
-
|
|
3815
|
+
const checks = currDef.checks;
|
|
3816
|
+
if (checks && checks.length > 0) throw new Error(".omit() cannot be used on object schemas containing refinements");
|
|
3817
|
+
return clone(schema, mergeDefs(schema._zod.def, {
|
|
3818
|
+
get shape() {
|
|
3819
|
+
const newShape = { ...schema._zod.def.shape };
|
|
3820
|
+
for (const key in mask) {
|
|
3821
|
+
if (!(key in currDef.shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
3822
|
+
if (!mask[key]) continue;
|
|
3823
|
+
delete newShape[key];
|
|
3824
|
+
}
|
|
3825
|
+
assignProp(this, "shape", newShape);
|
|
3826
|
+
return newShape;
|
|
3827
|
+
},
|
|
3784
3828
|
checks: []
|
|
3785
|
-
});
|
|
3829
|
+
}));
|
|
3786
3830
|
}
|
|
3787
3831
|
function extend(schema, shape) {
|
|
3788
3832
|
if (!isPlainObject$1(shape)) throw new Error("Invalid input to extend: expected a plain object");
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
}
|
|
3799
|
-
|
|
3800
|
-
|
|
3833
|
+
const checks = schema._zod.def.checks;
|
|
3834
|
+
if (checks && checks.length > 0) {
|
|
3835
|
+
const existingShape = schema._zod.def.shape;
|
|
3836
|
+
for (const key in shape) if (Object.getOwnPropertyDescriptor(existingShape, key) !== void 0) throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.");
|
|
3837
|
+
}
|
|
3838
|
+
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
3839
|
+
const _shape = {
|
|
3840
|
+
...schema._zod.def.shape,
|
|
3841
|
+
...shape
|
|
3842
|
+
};
|
|
3843
|
+
assignProp(this, "shape", _shape);
|
|
3844
|
+
return _shape;
|
|
3845
|
+
} }));
|
|
3846
|
+
}
|
|
3847
|
+
function safeExtend(schema, shape) {
|
|
3848
|
+
if (!isPlainObject$1(shape)) throw new Error("Invalid input to safeExtend: expected a plain object");
|
|
3849
|
+
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
3850
|
+
const _shape = {
|
|
3851
|
+
...schema._zod.def.shape,
|
|
3852
|
+
...shape
|
|
3853
|
+
};
|
|
3854
|
+
assignProp(this, "shape", _shape);
|
|
3855
|
+
return _shape;
|
|
3856
|
+
} }));
|
|
3801
3857
|
}
|
|
3802
3858
|
function merge(a, b) {
|
|
3803
|
-
return clone(a, {
|
|
3804
|
-
...a._zod.def,
|
|
3859
|
+
return clone(a, mergeDefs(a._zod.def, {
|
|
3805
3860
|
get shape() {
|
|
3806
3861
|
const _shape = {
|
|
3807
3862
|
...a._zod.def.shape,
|
|
@@ -3810,53 +3865,59 @@ function merge(a, b) {
|
|
|
3810
3865
|
assignProp(this, "shape", _shape);
|
|
3811
3866
|
return _shape;
|
|
3812
3867
|
},
|
|
3813
|
-
catchall
|
|
3868
|
+
get catchall() {
|
|
3869
|
+
return b._zod.def.catchall;
|
|
3870
|
+
},
|
|
3814
3871
|
checks: []
|
|
3815
|
-
});
|
|
3872
|
+
}));
|
|
3816
3873
|
}
|
|
3817
3874
|
function partial(Class, schema, mask) {
|
|
3818
|
-
const
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
|
|
3825
|
-
|
|
3826
|
-
|
|
3827
|
-
|
|
3828
|
-
|
|
3829
|
-
|
|
3830
|
-
|
|
3831
|
-
|
|
3832
|
-
|
|
3833
|
-
|
|
3834
|
-
|
|
3875
|
+
const checks = schema._zod.def.checks;
|
|
3876
|
+
if (checks && checks.length > 0) throw new Error(".partial() cannot be used on object schemas containing refinements");
|
|
3877
|
+
return clone(schema, mergeDefs(schema._zod.def, {
|
|
3878
|
+
get shape() {
|
|
3879
|
+
const oldShape = schema._zod.def.shape;
|
|
3880
|
+
const shape = { ...oldShape };
|
|
3881
|
+
if (mask) for (const key in mask) {
|
|
3882
|
+
if (!(key in oldShape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
3883
|
+
if (!mask[key]) continue;
|
|
3884
|
+
shape[key] = Class ? new Class({
|
|
3885
|
+
type: "optional",
|
|
3886
|
+
innerType: oldShape[key]
|
|
3887
|
+
}) : oldShape[key];
|
|
3888
|
+
}
|
|
3889
|
+
else for (const key in oldShape) shape[key] = Class ? new Class({
|
|
3890
|
+
type: "optional",
|
|
3891
|
+
innerType: oldShape[key]
|
|
3892
|
+
}) : oldShape[key];
|
|
3893
|
+
assignProp(this, "shape", shape);
|
|
3894
|
+
return shape;
|
|
3895
|
+
},
|
|
3835
3896
|
checks: []
|
|
3836
|
-
});
|
|
3897
|
+
}));
|
|
3837
3898
|
}
|
|
3838
3899
|
function required(Class, schema, mask) {
|
|
3839
|
-
|
|
3840
|
-
|
|
3841
|
-
|
|
3842
|
-
if (
|
|
3843
|
-
|
|
3844
|
-
|
|
3900
|
+
return clone(schema, mergeDefs(schema._zod.def, { get shape() {
|
|
3901
|
+
const oldShape = schema._zod.def.shape;
|
|
3902
|
+
const shape = { ...oldShape };
|
|
3903
|
+
if (mask) for (const key in mask) {
|
|
3904
|
+
if (!(key in shape)) throw new Error(`Unrecognized key: "${key}"`);
|
|
3905
|
+
if (!mask[key]) continue;
|
|
3906
|
+
shape[key] = new Class({
|
|
3907
|
+
type: "nonoptional",
|
|
3908
|
+
innerType: oldShape[key]
|
|
3909
|
+
});
|
|
3910
|
+
}
|
|
3911
|
+
else for (const key in oldShape) shape[key] = new Class({
|
|
3845
3912
|
type: "nonoptional",
|
|
3846
3913
|
innerType: oldShape[key]
|
|
3847
3914
|
});
|
|
3848
|
-
|
|
3849
|
-
|
|
3850
|
-
|
|
3851
|
-
innerType: oldShape[key]
|
|
3852
|
-
});
|
|
3853
|
-
return clone(schema, {
|
|
3854
|
-
...schema._zod.def,
|
|
3855
|
-
shape,
|
|
3856
|
-
checks: []
|
|
3857
|
-
});
|
|
3915
|
+
assignProp(this, "shape", shape);
|
|
3916
|
+
return shape;
|
|
3917
|
+
} }));
|
|
3858
3918
|
}
|
|
3859
3919
|
function aborted(x, startIndex = 0) {
|
|
3920
|
+
if (x.aborted === true) return true;
|
|
3860
3921
|
for (let i = startIndex; i < x.issues.length; i++) if (x.issues[i]?.continue !== true) return true;
|
|
3861
3922
|
return false;
|
|
3862
3923
|
}
|
|
@@ -3910,12 +3971,7 @@ const initializer$1 = (inst, def) => {
|
|
|
3910
3971
|
value: def,
|
|
3911
3972
|
enumerable: false
|
|
3912
3973
|
});
|
|
3913
|
-
|
|
3914
|
-
get() {
|
|
3915
|
-
return JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
3916
|
-
},
|
|
3917
|
-
enumerable: true
|
|
3918
|
-
});
|
|
3974
|
+
inst.message = JSON.stringify(def, jsonStringifyReplacer, 2);
|
|
3919
3975
|
Object.defineProperty(inst, "toString", {
|
|
3920
3976
|
value: () => inst.message,
|
|
3921
3977
|
enumerable: false
|
|
@@ -3935,10 +3991,7 @@ function flattenError(error, mapper = (issue) => issue.message) {
|
|
|
3935
3991
|
fieldErrors
|
|
3936
3992
|
};
|
|
3937
3993
|
}
|
|
3938
|
-
function formatError(error,
|
|
3939
|
-
const mapper = _mapper || function(issue) {
|
|
3940
|
-
return issue.message;
|
|
3941
|
-
};
|
|
3994
|
+
function formatError(error, mapper = (issue) => issue.message) {
|
|
3942
3995
|
const fieldErrors = { _errors: [] };
|
|
3943
3996
|
const processError = (error) => {
|
|
3944
3997
|
for (const issue of error.issues) if (issue.code === "invalid_union" && issue.errors.length) issue.errors.map((issues) => processError({ issues }));
|
|
@@ -4031,6 +4084,42 @@ const _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
4031
4084
|
};
|
|
4032
4085
|
};
|
|
4033
4086
|
const safeParseAsync$2 = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
4087
|
+
const _encode = (_Err) => (schema, value, _ctx) => {
|
|
4088
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
4089
|
+
return _parse(_Err)(schema, value, ctx);
|
|
4090
|
+
};
|
|
4091
|
+
const encode$1 = /* @__PURE__ */ _encode($ZodRealError);
|
|
4092
|
+
const _decode = (_Err) => (schema, value, _ctx) => {
|
|
4093
|
+
return _parse(_Err)(schema, value, _ctx);
|
|
4094
|
+
};
|
|
4095
|
+
const decode$1 = /* @__PURE__ */ _decode($ZodRealError);
|
|
4096
|
+
const _encodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
4097
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
4098
|
+
return _parseAsync(_Err)(schema, value, ctx);
|
|
4099
|
+
};
|
|
4100
|
+
const encodeAsync$1 = /* @__PURE__ */ _encodeAsync($ZodRealError);
|
|
4101
|
+
const _decodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
4102
|
+
return _parseAsync(_Err)(schema, value, _ctx);
|
|
4103
|
+
};
|
|
4104
|
+
const decodeAsync$1 = /* @__PURE__ */ _decodeAsync($ZodRealError);
|
|
4105
|
+
const _safeEncode = (_Err) => (schema, value, _ctx) => {
|
|
4106
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
4107
|
+
return _safeParse(_Err)(schema, value, ctx);
|
|
4108
|
+
};
|
|
4109
|
+
const safeEncode$1 = /* @__PURE__ */ _safeEncode($ZodRealError);
|
|
4110
|
+
const _safeDecode = (_Err) => (schema, value, _ctx) => {
|
|
4111
|
+
return _safeParse(_Err)(schema, value, _ctx);
|
|
4112
|
+
};
|
|
4113
|
+
const safeDecode$1 = /* @__PURE__ */ _safeDecode($ZodRealError);
|
|
4114
|
+
const _safeEncodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
4115
|
+
const ctx = _ctx ? Object.assign(_ctx, { direction: "backward" }) : { direction: "backward" };
|
|
4116
|
+
return _safeParseAsync(_Err)(schema, value, ctx);
|
|
4117
|
+
};
|
|
4118
|
+
const safeEncodeAsync$1 = /* @__PURE__ */ _safeEncodeAsync($ZodRealError);
|
|
4119
|
+
const _safeDecodeAsync = (_Err) => async (schema, value, _ctx) => {
|
|
4120
|
+
return _safeParseAsync(_Err)(schema, value, _ctx);
|
|
4121
|
+
};
|
|
4122
|
+
const safeDecodeAsync$1 = /* @__PURE__ */ _safeDecodeAsync($ZodRealError);
|
|
4034
4123
|
|
|
4035
4124
|
//#endregion
|
|
4036
4125
|
//#region node_modules/zod/v4/core/regexes.js
|
|
@@ -4044,11 +4133,11 @@ const nanoid = /^[a-zA-Z0-9_-]{21}$/;
|
|
|
4044
4133
|
const duration$1 = /^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/;
|
|
4045
4134
|
/** A regex for any UUID-like identifier: 8-4-4-4-12 hex pattern */
|
|
4046
4135
|
const guid = /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/;
|
|
4047
|
-
/** Returns a regex for validating an RFC 4122 UUID.
|
|
4136
|
+
/** Returns a regex for validating an RFC 9562/4122 UUID.
|
|
4048
4137
|
*
|
|
4049
4138
|
* @param version Optionally specify a version 1-8. If no version is specified, all versions are supported. */
|
|
4050
4139
|
const uuid = (version) => {
|
|
4051
|
-
if (!version) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000)$/;
|
|
4140
|
+
if (!version) return /^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;
|
|
4052
4141
|
return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${version}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`);
|
|
4053
4142
|
};
|
|
4054
4143
|
/** Practical email validation */
|
|
@@ -4058,13 +4147,12 @@ function emoji() {
|
|
|
4058
4147
|
return new RegExp(_emoji$1, "u");
|
|
4059
4148
|
}
|
|
4060
4149
|
const ipv4 = /^(?:(?: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])$/;
|
|
4061
|
-
const ipv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}
|
|
4150
|
+
const ipv6 = /^(([0-9a-fA-F]{1,4}:){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}|:))$/;
|
|
4062
4151
|
const cidrv4 = /^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/;
|
|
4063
4152
|
const cidrv6 = /^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/;
|
|
4064
4153
|
const base64 = /^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/;
|
|
4065
4154
|
const base64url = /^[A-Za-z0-9_-]*$/;
|
|
4066
|
-
const
|
|
4067
|
-
const e164 = /^\+(?:[0-9]){6,14}[0-9]$/;
|
|
4155
|
+
const e164 = /^\+[1-9]\d{6,14}$/;
|
|
4068
4156
|
const dateSource = `(?:(?:\\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])))`;
|
|
4069
4157
|
const date$1 = /* @__PURE__ */ new RegExp(`^${dateSource}$`);
|
|
4070
4158
|
function timeSource(args) {
|
|
@@ -4078,7 +4166,7 @@ function datetime$1(args) {
|
|
|
4078
4166
|
const time = timeSource({ precision: args.precision });
|
|
4079
4167
|
const opts = ["Z"];
|
|
4080
4168
|
if (args.local) opts.push("");
|
|
4081
|
-
if (args.offset) opts.push(`([+-]\\d
|
|
4169
|
+
if (args.offset) opts.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);
|
|
4082
4170
|
const timeRegex = `${time}(?:${opts.join("|")})`;
|
|
4083
4171
|
return new RegExp(`^${dateSource}T(?:${timeRegex})$`);
|
|
4084
4172
|
}
|
|
@@ -4086,10 +4174,10 @@ const string$1 = (params) => {
|
|
|
4086
4174
|
const regex = params ? `[\\s\\S]{${params?.minimum ?? 0},${params?.maximum ?? ""}}` : `[\\s\\S]*`;
|
|
4087
4175
|
return new RegExp(`^${regex}$`);
|
|
4088
4176
|
};
|
|
4089
|
-
const integer =
|
|
4090
|
-
const number$1 = /^-?\d+(?:\.\d+)
|
|
4091
|
-
const boolean$1 =
|
|
4092
|
-
const _null$2 =
|
|
4177
|
+
const integer = /^-?\d+$/;
|
|
4178
|
+
const number$1 = /^-?\d+(?:\.\d+)?$/;
|
|
4179
|
+
const boolean$1 = /^(?:true|false)$/i;
|
|
4180
|
+
const _null$2 = /^null$/i;
|
|
4093
4181
|
const lowercase = /^[^A-Z]*$/;
|
|
4094
4182
|
const uppercase = /^[^a-z]*$/;
|
|
4095
4183
|
|
|
@@ -4120,7 +4208,7 @@ const $ZodCheckLessThan = /* @__PURE__ */ $constructor("$ZodCheckLessThan", (ins
|
|
|
4120
4208
|
payload.issues.push({
|
|
4121
4209
|
origin,
|
|
4122
4210
|
code: "too_big",
|
|
4123
|
-
maximum: def.value,
|
|
4211
|
+
maximum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
4124
4212
|
input: payload.value,
|
|
4125
4213
|
inclusive: def.inclusive,
|
|
4126
4214
|
inst,
|
|
@@ -4142,7 +4230,7 @@ const $ZodCheckGreaterThan = /* @__PURE__ */ $constructor("$ZodCheckGreaterThan"
|
|
|
4142
4230
|
payload.issues.push({
|
|
4143
4231
|
origin,
|
|
4144
4232
|
code: "too_small",
|
|
4145
|
-
minimum: def.value,
|
|
4233
|
+
minimum: typeof def.value === "object" ? def.value.getTime() : def.value,
|
|
4146
4234
|
input: payload.value,
|
|
4147
4235
|
inclusive: def.inclusive,
|
|
4148
4236
|
inst,
|
|
@@ -4190,6 +4278,7 @@ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberForma
|
|
|
4190
4278
|
expected: origin,
|
|
4191
4279
|
format: def.format,
|
|
4192
4280
|
code: "invalid_type",
|
|
4281
|
+
continue: false,
|
|
4193
4282
|
input,
|
|
4194
4283
|
inst
|
|
4195
4284
|
});
|
|
@@ -4203,6 +4292,7 @@ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberForma
|
|
|
4203
4292
|
note: "Integers must be within the safe integer range.",
|
|
4204
4293
|
inst,
|
|
4205
4294
|
origin,
|
|
4295
|
+
inclusive: true,
|
|
4206
4296
|
continue: !def.abort
|
|
4207
4297
|
});
|
|
4208
4298
|
else payload.issues.push({
|
|
@@ -4212,6 +4302,7 @@ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberForma
|
|
|
4212
4302
|
note: "Integers must be within the safe integer range.",
|
|
4213
4303
|
inst,
|
|
4214
4304
|
origin,
|
|
4305
|
+
inclusive: true,
|
|
4215
4306
|
continue: !def.abort
|
|
4216
4307
|
});
|
|
4217
4308
|
return;
|
|
@@ -4231,7 +4322,9 @@ const $ZodCheckNumberFormat = /* @__PURE__ */ $constructor("$ZodCheckNumberForma
|
|
|
4231
4322
|
input,
|
|
4232
4323
|
code: "too_big",
|
|
4233
4324
|
maximum,
|
|
4234
|
-
|
|
4325
|
+
inclusive: true,
|
|
4326
|
+
inst,
|
|
4327
|
+
continue: !def.abort
|
|
4235
4328
|
});
|
|
4236
4329
|
};
|
|
4237
4330
|
});
|
|
@@ -4483,8 +4576,8 @@ var Doc = class {
|
|
|
4483
4576
|
//#region node_modules/zod/v4/core/versions.js
|
|
4484
4577
|
const version = {
|
|
4485
4578
|
major: 4,
|
|
4486
|
-
minor:
|
|
4487
|
-
patch:
|
|
4579
|
+
minor: 3,
|
|
4580
|
+
patch: 6
|
|
4488
4581
|
};
|
|
4489
4582
|
|
|
4490
4583
|
//#endregion
|
|
@@ -4529,7 +4622,33 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
4529
4622
|
});
|
|
4530
4623
|
return payload;
|
|
4531
4624
|
};
|
|
4625
|
+
const handleCanaryResult = (canary, payload, ctx) => {
|
|
4626
|
+
if (aborted(canary)) {
|
|
4627
|
+
canary.aborted = true;
|
|
4628
|
+
return canary;
|
|
4629
|
+
}
|
|
4630
|
+
const checkResult = runChecks(payload, checks, ctx);
|
|
4631
|
+
if (checkResult instanceof Promise) {
|
|
4632
|
+
if (ctx.async === false) throw new $ZodAsyncError();
|
|
4633
|
+
return checkResult.then((checkResult) => inst._zod.parse(checkResult, ctx));
|
|
4634
|
+
}
|
|
4635
|
+
return inst._zod.parse(checkResult, ctx);
|
|
4636
|
+
};
|
|
4532
4637
|
inst._zod.run = (payload, ctx) => {
|
|
4638
|
+
if (ctx.skipChecks) return inst._zod.parse(payload, ctx);
|
|
4639
|
+
if (ctx.direction === "backward") {
|
|
4640
|
+
const canary = inst._zod.parse({
|
|
4641
|
+
value: payload.value,
|
|
4642
|
+
issues: []
|
|
4643
|
+
}, {
|
|
4644
|
+
...ctx,
|
|
4645
|
+
skipChecks: true
|
|
4646
|
+
});
|
|
4647
|
+
if (canary instanceof Promise) return canary.then((canary) => {
|
|
4648
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
4649
|
+
});
|
|
4650
|
+
return handleCanaryResult(canary, payload, ctx);
|
|
4651
|
+
}
|
|
4533
4652
|
const result = inst._zod.parse(payload, ctx);
|
|
4534
4653
|
if (result instanceof Promise) {
|
|
4535
4654
|
if (ctx.async === false) throw new $ZodAsyncError();
|
|
@@ -4538,7 +4657,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
4538
4657
|
return runChecks(result, checks, ctx);
|
|
4539
4658
|
};
|
|
4540
4659
|
}
|
|
4541
|
-
inst
|
|
4660
|
+
defineLazy(inst, "~standard", () => ({
|
|
4542
4661
|
validate: (value) => {
|
|
4543
4662
|
try {
|
|
4544
4663
|
const r = safeParse$2(inst, value);
|
|
@@ -4549,7 +4668,7 @@ const $ZodType = /* @__PURE__ */ $constructor("$ZodType", (inst, def) => {
|
|
|
4549
4668
|
},
|
|
4550
4669
|
vendor: "zod",
|
|
4551
4670
|
version: 1
|
|
4552
|
-
};
|
|
4671
|
+
}));
|
|
4553
4672
|
});
|
|
4554
4673
|
const $ZodString = /* @__PURE__ */ $constructor("$ZodString", (inst, def) => {
|
|
4555
4674
|
$ZodType.init(inst, def);
|
|
@@ -4601,16 +4720,15 @@ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
|
4601
4720
|
$ZodStringFormat.init(inst, def);
|
|
4602
4721
|
inst._zod.check = (payload) => {
|
|
4603
4722
|
try {
|
|
4604
|
-
const
|
|
4605
|
-
const url = new URL(
|
|
4606
|
-
const href = url.href;
|
|
4723
|
+
const trimmed = payload.value.trim();
|
|
4724
|
+
const url = new URL(trimmed);
|
|
4607
4725
|
if (def.hostname) {
|
|
4608
4726
|
def.hostname.lastIndex = 0;
|
|
4609
4727
|
if (!def.hostname.test(url.hostname)) payload.issues.push({
|
|
4610
4728
|
code: "invalid_format",
|
|
4611
4729
|
format: "url",
|
|
4612
4730
|
note: "Invalid hostname",
|
|
4613
|
-
pattern: hostname
|
|
4731
|
+
pattern: def.hostname.source,
|
|
4614
4732
|
input: payload.value,
|
|
4615
4733
|
inst,
|
|
4616
4734
|
continue: !def.abort
|
|
@@ -4628,8 +4746,8 @@ const $ZodURL = /* @__PURE__ */ $constructor("$ZodURL", (inst, def) => {
|
|
|
4628
4746
|
continue: !def.abort
|
|
4629
4747
|
});
|
|
4630
4748
|
}
|
|
4631
|
-
if (
|
|
4632
|
-
else payload.value =
|
|
4749
|
+
if (def.normalize) payload.value = url.href;
|
|
4750
|
+
else payload.value = trimmed;
|
|
4633
4751
|
return;
|
|
4634
4752
|
} catch (_) {
|
|
4635
4753
|
payload.issues.push({
|
|
@@ -4689,18 +4807,12 @@ const $ZodISODuration = /* @__PURE__ */ $constructor("$ZodISODuration", (inst, d
|
|
|
4689
4807
|
const $ZodIPv4 = /* @__PURE__ */ $constructor("$ZodIPv4", (inst, def) => {
|
|
4690
4808
|
def.pattern ?? (def.pattern = ipv4);
|
|
4691
4809
|
$ZodStringFormat.init(inst, def);
|
|
4692
|
-
inst._zod.
|
|
4693
|
-
const bag = inst._zod.bag;
|
|
4694
|
-
bag.format = `ipv4`;
|
|
4695
|
-
});
|
|
4810
|
+
inst._zod.bag.format = `ipv4`;
|
|
4696
4811
|
});
|
|
4697
4812
|
const $ZodIPv6 = /* @__PURE__ */ $constructor("$ZodIPv6", (inst, def) => {
|
|
4698
4813
|
def.pattern ?? (def.pattern = ipv6);
|
|
4699
4814
|
$ZodStringFormat.init(inst, def);
|
|
4700
|
-
inst._zod.
|
|
4701
|
-
const bag = inst._zod.bag;
|
|
4702
|
-
bag.format = `ipv6`;
|
|
4703
|
-
});
|
|
4815
|
+
inst._zod.bag.format = `ipv6`;
|
|
4704
4816
|
inst._zod.check = (payload) => {
|
|
4705
4817
|
try {
|
|
4706
4818
|
new URL(`http://[${payload.value}]`);
|
|
@@ -4723,8 +4835,10 @@ const $ZodCIDRv6 = /* @__PURE__ */ $constructor("$ZodCIDRv6", (inst, def) => {
|
|
|
4723
4835
|
def.pattern ?? (def.pattern = cidrv6);
|
|
4724
4836
|
$ZodStringFormat.init(inst, def);
|
|
4725
4837
|
inst._zod.check = (payload) => {
|
|
4726
|
-
const
|
|
4838
|
+
const parts = payload.value.split("/");
|
|
4727
4839
|
try {
|
|
4840
|
+
if (parts.length !== 2) throw new Error();
|
|
4841
|
+
const [address, prefix] = parts;
|
|
4728
4842
|
if (!prefix) throw new Error();
|
|
4729
4843
|
const prefixNum = Number(prefix);
|
|
4730
4844
|
if (`${prefixNum}` !== prefix) throw new Error();
|
|
@@ -4754,9 +4868,7 @@ function isValidBase64(data) {
|
|
|
4754
4868
|
const $ZodBase64 = /* @__PURE__ */ $constructor("$ZodBase64", (inst, def) => {
|
|
4755
4869
|
def.pattern ?? (def.pattern = base64);
|
|
4756
4870
|
$ZodStringFormat.init(inst, def);
|
|
4757
|
-
inst._zod.
|
|
4758
|
-
inst._zod.bag.contentEncoding = "base64";
|
|
4759
|
-
});
|
|
4871
|
+
inst._zod.bag.contentEncoding = "base64";
|
|
4760
4872
|
inst._zod.check = (payload) => {
|
|
4761
4873
|
if (isValidBase64(payload.value)) return;
|
|
4762
4874
|
payload.issues.push({
|
|
@@ -4776,9 +4888,7 @@ function isValidBase64URL(data) {
|
|
|
4776
4888
|
const $ZodBase64URL = /* @__PURE__ */ $constructor("$ZodBase64URL", (inst, def) => {
|
|
4777
4889
|
def.pattern ?? (def.pattern = base64url);
|
|
4778
4890
|
$ZodStringFormat.init(inst, def);
|
|
4779
|
-
inst._zod.
|
|
4780
|
-
inst._zod.bag.contentEncoding = "base64url";
|
|
4781
|
-
});
|
|
4891
|
+
inst._zod.bag.contentEncoding = "base64url";
|
|
4782
4892
|
inst._zod.check = (payload) => {
|
|
4783
4893
|
if (isValidBase64URL(payload.value)) return;
|
|
4784
4894
|
payload.issues.push({
|
|
@@ -4842,7 +4952,7 @@ const $ZodNumber = /* @__PURE__ */ $constructor("$ZodNumber", (inst, def) => {
|
|
|
4842
4952
|
return payload;
|
|
4843
4953
|
};
|
|
4844
4954
|
});
|
|
4845
|
-
const $ZodNumberFormat = /* @__PURE__ */ $constructor("$
|
|
4955
|
+
const $ZodNumberFormat = /* @__PURE__ */ $constructor("$ZodNumberFormat", (inst, def) => {
|
|
4846
4956
|
$ZodCheckNumberFormat.init(inst, def);
|
|
4847
4957
|
$ZodNumber.init(inst, def);
|
|
4848
4958
|
});
|
|
@@ -4928,32 +5038,68 @@ const $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
|
|
|
4928
5038
|
return payload;
|
|
4929
5039
|
};
|
|
4930
5040
|
});
|
|
4931
|
-
function
|
|
4932
|
-
if (result.issues.length)
|
|
4933
|
-
|
|
4934
|
-
|
|
4935
|
-
|
|
4936
|
-
if (result.
|
|
4937
|
-
else final.value[key] = result.value;
|
|
4938
|
-
else final.issues.push(...prefixIssues(key, result.issues));
|
|
4939
|
-
else if (result.value === void 0) {
|
|
5041
|
+
function handlePropertyResult(result, final, key, input, isOptionalOut) {
|
|
5042
|
+
if (result.issues.length) {
|
|
5043
|
+
if (isOptionalOut && !(key in input)) return;
|
|
5044
|
+
final.issues.push(...prefixIssues(key, result.issues));
|
|
5045
|
+
}
|
|
5046
|
+
if (result.value === void 0) {
|
|
4940
5047
|
if (key in input) final.value[key] = void 0;
|
|
4941
5048
|
} else final.value[key] = result.value;
|
|
4942
5049
|
}
|
|
5050
|
+
function normalizeDef(def) {
|
|
5051
|
+
const keys = Object.keys(def.shape);
|
|
5052
|
+
for (const k of keys) if (!def.shape?.[k]?._zod?.traits?.has("$ZodType")) throw new Error(`Invalid element at key "${k}": expected a Zod schema`);
|
|
5053
|
+
const okeys = optionalKeys(def.shape);
|
|
5054
|
+
return {
|
|
5055
|
+
...def,
|
|
5056
|
+
keys,
|
|
5057
|
+
keySet: new Set(keys),
|
|
5058
|
+
numKeys: keys.length,
|
|
5059
|
+
optionalKeys: new Set(okeys)
|
|
5060
|
+
};
|
|
5061
|
+
}
|
|
5062
|
+
function handleCatchall(proms, input, payload, ctx, def, inst) {
|
|
5063
|
+
const unrecognized = [];
|
|
5064
|
+
const keySet = def.keySet;
|
|
5065
|
+
const _catchall = def.catchall._zod;
|
|
5066
|
+
const t = _catchall.def.type;
|
|
5067
|
+
const isOptionalOut = _catchall.optout === "optional";
|
|
5068
|
+
for (const key in input) {
|
|
5069
|
+
if (keySet.has(key)) continue;
|
|
5070
|
+
if (t === "never") {
|
|
5071
|
+
unrecognized.push(key);
|
|
5072
|
+
continue;
|
|
5073
|
+
}
|
|
5074
|
+
const r = _catchall.run({
|
|
5075
|
+
value: input[key],
|
|
5076
|
+
issues: []
|
|
5077
|
+
}, ctx);
|
|
5078
|
+
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
5079
|
+
else handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
5080
|
+
}
|
|
5081
|
+
if (unrecognized.length) payload.issues.push({
|
|
5082
|
+
code: "unrecognized_keys",
|
|
5083
|
+
keys: unrecognized,
|
|
5084
|
+
input,
|
|
5085
|
+
inst
|
|
5086
|
+
});
|
|
5087
|
+
if (!proms.length) return payload;
|
|
5088
|
+
return Promise.all(proms).then(() => {
|
|
5089
|
+
return payload;
|
|
5090
|
+
});
|
|
5091
|
+
}
|
|
4943
5092
|
const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
4944
5093
|
$ZodType.init(inst, def);
|
|
4945
|
-
|
|
4946
|
-
const
|
|
4947
|
-
|
|
4948
|
-
|
|
4949
|
-
|
|
4950
|
-
|
|
4951
|
-
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
optionalKeys: new Set(okeys)
|
|
4955
|
-
};
|
|
4956
|
-
});
|
|
5094
|
+
if (!Object.getOwnPropertyDescriptor(def, "shape")?.get) {
|
|
5095
|
+
const sh = def.shape;
|
|
5096
|
+
Object.defineProperty(def, "shape", { get: () => {
|
|
5097
|
+
const newSh = { ...sh };
|
|
5098
|
+
Object.defineProperty(def, "shape", { value: newSh });
|
|
5099
|
+
return newSh;
|
|
5100
|
+
} });
|
|
5101
|
+
}
|
|
5102
|
+
const _normalized = cached(() => normalizeDef(def));
|
|
4957
5103
|
defineLazy(inst._zod, "propValues", () => {
|
|
4958
5104
|
const shape = def.shape;
|
|
4959
5105
|
const propValues = {};
|
|
@@ -4966,6 +5112,42 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
4966
5112
|
}
|
|
4967
5113
|
return propValues;
|
|
4968
5114
|
});
|
|
5115
|
+
const isObject$2 = isObject;
|
|
5116
|
+
const catchall = def.catchall;
|
|
5117
|
+
let value;
|
|
5118
|
+
inst._zod.parse = (payload, ctx) => {
|
|
5119
|
+
value ?? (value = _normalized.value);
|
|
5120
|
+
const input = payload.value;
|
|
5121
|
+
if (!isObject$2(input)) {
|
|
5122
|
+
payload.issues.push({
|
|
5123
|
+
expected: "object",
|
|
5124
|
+
code: "invalid_type",
|
|
5125
|
+
input,
|
|
5126
|
+
inst
|
|
5127
|
+
});
|
|
5128
|
+
return payload;
|
|
5129
|
+
}
|
|
5130
|
+
payload.value = {};
|
|
5131
|
+
const proms = [];
|
|
5132
|
+
const shape = value.shape;
|
|
5133
|
+
for (const key of value.keys) {
|
|
5134
|
+
const el = shape[key];
|
|
5135
|
+
const isOptionalOut = el._zod.optout === "optional";
|
|
5136
|
+
const r = el._zod.run({
|
|
5137
|
+
value: input[key],
|
|
5138
|
+
issues: []
|
|
5139
|
+
}, ctx);
|
|
5140
|
+
if (r instanceof Promise) proms.push(r.then((r) => handlePropertyResult(r, payload, key, input, isOptionalOut)));
|
|
5141
|
+
else handlePropertyResult(r, payload, key, input, isOptionalOut);
|
|
5142
|
+
}
|
|
5143
|
+
if (!catchall) return proms.length ? Promise.all(proms).then(() => payload) : payload;
|
|
5144
|
+
return handleCatchall(proms, input, payload, ctx, _normalized.value, inst);
|
|
5145
|
+
};
|
|
5146
|
+
});
|
|
5147
|
+
const $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) => {
|
|
5148
|
+
$ZodObject.init(inst, def);
|
|
5149
|
+
const superParse = inst._zod.parse;
|
|
5150
|
+
const _normalized = cached(() => normalizeDef(def));
|
|
4969
5151
|
const generateFastpass = (shape) => {
|
|
4970
5152
|
const doc = new Doc([
|
|
4971
5153
|
"shape",
|
|
@@ -4981,40 +5163,48 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
4981
5163
|
const ids = Object.create(null);
|
|
4982
5164
|
let counter = 0;
|
|
4983
5165
|
for (const key of normalized.keys) ids[key] = `key_${counter++}`;
|
|
4984
|
-
doc.write(`const newResult = {}
|
|
4985
|
-
for (const key of normalized.keys)
|
|
5166
|
+
doc.write(`const newResult = {};`);
|
|
5167
|
+
for (const key of normalized.keys) {
|
|
4986
5168
|
const id = ids[key];
|
|
4987
|
-
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
4988
5169
|
const k = esc(key);
|
|
4989
|
-
|
|
5170
|
+
const isOptionalOut = shape[key]?._zod?.optout === "optional";
|
|
5171
|
+
doc.write(`const ${id} = ${parseStr(key)};`);
|
|
5172
|
+
if (isOptionalOut) doc.write(`
|
|
4990
5173
|
if (${id}.issues.length) {
|
|
4991
|
-
if (
|
|
4992
|
-
|
|
4993
|
-
|
|
4994
|
-
|
|
4995
|
-
|
|
4996
|
-
|
|
4997
|
-
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5174
|
+
if (${k} in input) {
|
|
5175
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
5176
|
+
...iss,
|
|
5177
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
5178
|
+
})));
|
|
5179
|
+
}
|
|
5180
|
+
}
|
|
5181
|
+
|
|
5182
|
+
if (${id}.value === undefined) {
|
|
5183
|
+
if (${k} in input) {
|
|
5184
|
+
newResult[${k}] = undefined;
|
|
5002
5185
|
}
|
|
5003
|
-
} else if (${id}.value === undefined) {
|
|
5004
|
-
if (${k} in input) newResult[${k}] = undefined;
|
|
5005
5186
|
} else {
|
|
5006
5187
|
newResult[${k}] = ${id}.value;
|
|
5007
5188
|
}
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
if (${id}.issues.length) payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
5189
|
+
|
|
5190
|
+
`);
|
|
5191
|
+
else doc.write(`
|
|
5192
|
+
if (${id}.issues.length) {
|
|
5193
|
+
payload.issues = payload.issues.concat(${id}.issues.map(iss => ({
|
|
5014
5194
|
...iss,
|
|
5015
|
-
path: iss.path ? [${
|
|
5016
|
-
})))
|
|
5017
|
-
|
|
5195
|
+
path: iss.path ? [${k}, ...iss.path] : [${k}]
|
|
5196
|
+
})));
|
|
5197
|
+
}
|
|
5198
|
+
|
|
5199
|
+
if (${id}.value === undefined) {
|
|
5200
|
+
if (${k} in input) {
|
|
5201
|
+
newResult[${k}] = undefined;
|
|
5202
|
+
}
|
|
5203
|
+
} else {
|
|
5204
|
+
newResult[${k}] = ${id}.value;
|
|
5205
|
+
}
|
|
5206
|
+
|
|
5207
|
+
`);
|
|
5018
5208
|
}
|
|
5019
5209
|
doc.write(`payload.value = newResult;`);
|
|
5020
5210
|
doc.write(`return payload;`);
|
|
@@ -5040,53 +5230,13 @@ const $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
|
|
|
5040
5230
|
});
|
|
5041
5231
|
return payload;
|
|
5042
5232
|
}
|
|
5043
|
-
const proms = [];
|
|
5044
5233
|
if (jit && fastEnabled && ctx?.async === false && ctx.jitless !== true) {
|
|
5045
5234
|
if (!fastpass) fastpass = generateFastpass(def.shape);
|
|
5046
5235
|
payload = fastpass(payload, ctx);
|
|
5047
|
-
|
|
5048
|
-
payload
|
|
5049
|
-
const shape = value.shape;
|
|
5050
|
-
for (const key of value.keys) {
|
|
5051
|
-
const el = shape[key];
|
|
5052
|
-
const r = el._zod.run({
|
|
5053
|
-
value: input[key],
|
|
5054
|
-
issues: []
|
|
5055
|
-
}, ctx);
|
|
5056
|
-
const isOptional = el._zod.optin === "optional" && el._zod.optout === "optional";
|
|
5057
|
-
if (r instanceof Promise) proms.push(r.then((r) => isOptional ? handleOptionalObjectResult(r, payload, key, input) : handleObjectResult(r, payload, key)));
|
|
5058
|
-
else if (isOptional) handleOptionalObjectResult(r, payload, key, input);
|
|
5059
|
-
else handleObjectResult(r, payload, key);
|
|
5060
|
-
}
|
|
5236
|
+
if (!catchall) return payload;
|
|
5237
|
+
return handleCatchall([], input, payload, ctx, value, inst);
|
|
5061
5238
|
}
|
|
5062
|
-
|
|
5063
|
-
const unrecognized = [];
|
|
5064
|
-
const keySet = value.keySet;
|
|
5065
|
-
const _catchall = catchall._zod;
|
|
5066
|
-
const t = _catchall.def.type;
|
|
5067
|
-
for (const key of Object.keys(input)) {
|
|
5068
|
-
if (keySet.has(key)) continue;
|
|
5069
|
-
if (t === "never") {
|
|
5070
|
-
unrecognized.push(key);
|
|
5071
|
-
continue;
|
|
5072
|
-
}
|
|
5073
|
-
const r = _catchall.run({
|
|
5074
|
-
value: input[key],
|
|
5075
|
-
issues: []
|
|
5076
|
-
}, ctx);
|
|
5077
|
-
if (r instanceof Promise) proms.push(r.then((r) => handleObjectResult(r, payload, key)));
|
|
5078
|
-
else handleObjectResult(r, payload, key);
|
|
5079
|
-
}
|
|
5080
|
-
if (unrecognized.length) payload.issues.push({
|
|
5081
|
-
code: "unrecognized_keys",
|
|
5082
|
-
keys: unrecognized,
|
|
5083
|
-
input,
|
|
5084
|
-
inst
|
|
5085
|
-
});
|
|
5086
|
-
if (!proms.length) return payload;
|
|
5087
|
-
return Promise.all(proms).then(() => {
|
|
5088
|
-
return payload;
|
|
5089
|
-
});
|
|
5239
|
+
return superParse(payload, ctx);
|
|
5090
5240
|
};
|
|
5091
5241
|
});
|
|
5092
5242
|
function handleUnionResults(results, final, inst, ctx) {
|
|
@@ -5094,6 +5244,11 @@ function handleUnionResults(results, final, inst, ctx) {
|
|
|
5094
5244
|
final.value = result.value;
|
|
5095
5245
|
return final;
|
|
5096
5246
|
}
|
|
5247
|
+
const nonaborted = results.filter((r) => !aborted(r));
|
|
5248
|
+
if (nonaborted.length === 1) {
|
|
5249
|
+
final.value = nonaborted[0].value;
|
|
5250
|
+
return nonaborted[0];
|
|
5251
|
+
}
|
|
5097
5252
|
final.issues.push({
|
|
5098
5253
|
code: "invalid_union",
|
|
5099
5254
|
input: final.value,
|
|
@@ -5115,7 +5270,10 @@ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
|
5115
5270
|
return new RegExp(`^(${patterns.map((p) => cleanRegex(p.source)).join("|")})$`);
|
|
5116
5271
|
}
|
|
5117
5272
|
});
|
|
5273
|
+
const single = def.options.length === 1;
|
|
5274
|
+
const first = def.options[0]._zod.run;
|
|
5118
5275
|
inst._zod.parse = (payload, ctx) => {
|
|
5276
|
+
if (single) return first(payload, ctx);
|
|
5119
5277
|
let async = false;
|
|
5120
5278
|
const results = [];
|
|
5121
5279
|
for (const option of def.options) {
|
|
@@ -5138,6 +5296,7 @@ const $ZodUnion = /* @__PURE__ */ $constructor("$ZodUnion", (inst, def) => {
|
|
|
5138
5296
|
};
|
|
5139
5297
|
});
|
|
5140
5298
|
const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnion", (inst, def) => {
|
|
5299
|
+
def.inclusive = false;
|
|
5141
5300
|
$ZodUnion.init(inst, def);
|
|
5142
5301
|
const _super = inst._zod.parse;
|
|
5143
5302
|
defineLazy(inst._zod, "propValues", () => {
|
|
@@ -5156,7 +5315,7 @@ const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUn
|
|
|
5156
5315
|
const opts = def.options;
|
|
5157
5316
|
const map = /* @__PURE__ */ new Map();
|
|
5158
5317
|
for (const o of opts) {
|
|
5159
|
-
const values = o._zod.propValues[def.discriminator];
|
|
5318
|
+
const values = o._zod.propValues?.[def.discriminator];
|
|
5160
5319
|
if (!values || values.size === 0) throw new Error(`Invalid discriminated union option at index "${def.options.indexOf(o)}"`);
|
|
5161
5320
|
for (const v of values) {
|
|
5162
5321
|
if (map.has(v)) throw new Error(`Duplicate discriminator value "${String(v)}"`);
|
|
@@ -5183,6 +5342,7 @@ const $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUn
|
|
|
5183
5342
|
code: "invalid_union",
|
|
5184
5343
|
errors: [],
|
|
5185
5344
|
note: "No matching discriminator",
|
|
5345
|
+
discriminator: def.discriminator,
|
|
5186
5346
|
input,
|
|
5187
5347
|
path: [def.discriminator],
|
|
5188
5348
|
inst
|
|
@@ -5264,8 +5424,25 @@ function mergeValues(a, b) {
|
|
|
5264
5424
|
};
|
|
5265
5425
|
}
|
|
5266
5426
|
function handleIntersectionResults(result, left, right) {
|
|
5267
|
-
|
|
5268
|
-
|
|
5427
|
+
const unrecKeys = /* @__PURE__ */ new Map();
|
|
5428
|
+
let unrecIssue;
|
|
5429
|
+
for (const iss of left.issues) if (iss.code === "unrecognized_keys") {
|
|
5430
|
+
unrecIssue ?? (unrecIssue = iss);
|
|
5431
|
+
for (const k of iss.keys) {
|
|
5432
|
+
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
5433
|
+
unrecKeys.get(k).l = true;
|
|
5434
|
+
}
|
|
5435
|
+
} else result.issues.push(iss);
|
|
5436
|
+
for (const iss of right.issues) if (iss.code === "unrecognized_keys") for (const k of iss.keys) {
|
|
5437
|
+
if (!unrecKeys.has(k)) unrecKeys.set(k, {});
|
|
5438
|
+
unrecKeys.get(k).r = true;
|
|
5439
|
+
}
|
|
5440
|
+
else result.issues.push(iss);
|
|
5441
|
+
const bothKeys = [...unrecKeys].filter(([, f]) => f.l && f.r).map(([k]) => k);
|
|
5442
|
+
if (bothKeys.length && unrecIssue) result.issues.push({
|
|
5443
|
+
...unrecIssue,
|
|
5444
|
+
keys: bothKeys
|
|
5445
|
+
});
|
|
5269
5446
|
if (aborted(result)) return result;
|
|
5270
5447
|
const merged = mergeValues(left.value, right.value);
|
|
5271
5448
|
if (!merged.valid) throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(merged.mergeErrorPath)}`);
|
|
@@ -5286,10 +5463,12 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
5286
5463
|
return payload;
|
|
5287
5464
|
}
|
|
5288
5465
|
const proms = [];
|
|
5289
|
-
|
|
5290
|
-
|
|
5466
|
+
const values = def.keyType._zod.values;
|
|
5467
|
+
if (values) {
|
|
5291
5468
|
payload.value = {};
|
|
5469
|
+
const recordKeys = /* @__PURE__ */ new Set();
|
|
5292
5470
|
for (const key of values) if (typeof key === "string" || typeof key === "number" || typeof key === "symbol") {
|
|
5471
|
+
recordKeys.add(typeof key === "number" ? key.toString() : key);
|
|
5293
5472
|
const result = def.valueType._zod.run({
|
|
5294
5473
|
value: input[key],
|
|
5295
5474
|
issues: []
|
|
@@ -5304,7 +5483,7 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
5304
5483
|
}
|
|
5305
5484
|
}
|
|
5306
5485
|
let unrecognized;
|
|
5307
|
-
for (const key in input) if (!
|
|
5486
|
+
for (const key in input) if (!recordKeys.has(key)) {
|
|
5308
5487
|
unrecognized = unrecognized ?? [];
|
|
5309
5488
|
unrecognized.push(key);
|
|
5310
5489
|
}
|
|
@@ -5318,21 +5497,29 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
5318
5497
|
payload.value = {};
|
|
5319
5498
|
for (const key of Reflect.ownKeys(input)) {
|
|
5320
5499
|
if (key === "__proto__") continue;
|
|
5321
|
-
|
|
5500
|
+
let keyResult = def.keyType._zod.run({
|
|
5322
5501
|
value: key,
|
|
5323
5502
|
issues: []
|
|
5324
5503
|
}, ctx);
|
|
5325
5504
|
if (keyResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
|
|
5505
|
+
if (typeof key === "string" && number$1.test(key) && keyResult.issues.length) {
|
|
5506
|
+
const retryResult = def.keyType._zod.run({
|
|
5507
|
+
value: Number(key),
|
|
5508
|
+
issues: []
|
|
5509
|
+
}, ctx);
|
|
5510
|
+
if (retryResult instanceof Promise) throw new Error("Async schemas not supported in object keys currently");
|
|
5511
|
+
if (retryResult.issues.length === 0) keyResult = retryResult;
|
|
5512
|
+
}
|
|
5326
5513
|
if (keyResult.issues.length) {
|
|
5327
|
-
payload.
|
|
5328
|
-
|
|
5514
|
+
if (def.mode === "loose") payload.value[key] = input[key];
|
|
5515
|
+
else payload.issues.push({
|
|
5329
5516
|
code: "invalid_key",
|
|
5517
|
+
origin: "record",
|
|
5330
5518
|
issues: keyResult.issues.map((iss) => finalizeIssue(iss, ctx, config())),
|
|
5331
5519
|
input: key,
|
|
5332
5520
|
path: [key],
|
|
5333
5521
|
inst
|
|
5334
5522
|
});
|
|
5335
|
-
payload.value[keyResult.value] = keyResult.value;
|
|
5336
5523
|
continue;
|
|
5337
5524
|
}
|
|
5338
5525
|
const result = def.valueType._zod.run({
|
|
@@ -5356,11 +5543,12 @@ const $ZodRecord = /* @__PURE__ */ $constructor("$ZodRecord", (inst, def) => {
|
|
|
5356
5543
|
const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
5357
5544
|
$ZodType.init(inst, def);
|
|
5358
5545
|
const values = getEnumValues(def.entries);
|
|
5359
|
-
|
|
5546
|
+
const valuesSet = new Set(values);
|
|
5547
|
+
inst._zod.values = valuesSet;
|
|
5360
5548
|
inst._zod.pattern = new RegExp(`^(${values.filter((k) => propertyKeyTypes.has(typeof k)).map((o) => typeof o === "string" ? escapeRegex(o) : o.toString()).join("|")})$`);
|
|
5361
5549
|
inst._zod.parse = (payload, _ctx) => {
|
|
5362
5550
|
const input = payload.value;
|
|
5363
|
-
if (
|
|
5551
|
+
if (valuesSet.has(input)) return payload;
|
|
5364
5552
|
payload.issues.push({
|
|
5365
5553
|
code: "invalid_value",
|
|
5366
5554
|
values,
|
|
@@ -5372,11 +5560,13 @@ const $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
|
|
|
5372
5560
|
});
|
|
5373
5561
|
const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
5374
5562
|
$ZodType.init(inst, def);
|
|
5375
|
-
|
|
5376
|
-
|
|
5563
|
+
if (def.values.length === 0) throw new Error("Cannot create literal schema with no valid values");
|
|
5564
|
+
const values = new Set(def.values);
|
|
5565
|
+
inst._zod.values = values;
|
|
5566
|
+
inst._zod.pattern = new RegExp(`^(${def.values.map((o) => typeof o === "string" ? escapeRegex(o) : o ? escapeRegex(o.toString()) : String(o)).join("|")})$`);
|
|
5377
5567
|
inst._zod.parse = (payload, _ctx) => {
|
|
5378
5568
|
const input = payload.value;
|
|
5379
|
-
if (
|
|
5569
|
+
if (values.has(input)) return payload;
|
|
5380
5570
|
payload.issues.push({
|
|
5381
5571
|
code: "invalid_value",
|
|
5382
5572
|
values: def.values,
|
|
@@ -5388,9 +5578,10 @@ const $ZodLiteral = /* @__PURE__ */ $constructor("$ZodLiteral", (inst, def) => {
|
|
|
5388
5578
|
});
|
|
5389
5579
|
const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def) => {
|
|
5390
5580
|
$ZodType.init(inst, def);
|
|
5391
|
-
inst._zod.parse = (payload,
|
|
5581
|
+
inst._zod.parse = (payload, ctx) => {
|
|
5582
|
+
if (ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
5392
5583
|
const _out = def.transform(payload.value, payload);
|
|
5393
|
-
if (
|
|
5584
|
+
if (ctx.async) return (_out instanceof Promise ? _out : Promise.resolve(_out)).then((output) => {
|
|
5394
5585
|
payload.value = output;
|
|
5395
5586
|
return payload;
|
|
5396
5587
|
});
|
|
@@ -5399,6 +5590,13 @@ const $ZodTransform = /* @__PURE__ */ $constructor("$ZodTransform", (inst, def)
|
|
|
5399
5590
|
return payload;
|
|
5400
5591
|
};
|
|
5401
5592
|
});
|
|
5593
|
+
function handleOptionalResult(result, input) {
|
|
5594
|
+
if (result.issues.length && input === void 0) return {
|
|
5595
|
+
issues: [],
|
|
5596
|
+
value: void 0
|
|
5597
|
+
};
|
|
5598
|
+
return result;
|
|
5599
|
+
}
|
|
5402
5600
|
const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) => {
|
|
5403
5601
|
$ZodType.init(inst, def);
|
|
5404
5602
|
inst._zod.optin = "optional";
|
|
@@ -5411,11 +5609,23 @@ const $ZodOptional = /* @__PURE__ */ $constructor("$ZodOptional", (inst, def) =>
|
|
|
5411
5609
|
return pattern ? new RegExp(`^(${cleanRegex(pattern.source)})?$`) : void 0;
|
|
5412
5610
|
});
|
|
5413
5611
|
inst._zod.parse = (payload, ctx) => {
|
|
5414
|
-
if (def.innerType._zod.optin === "optional")
|
|
5612
|
+
if (def.innerType._zod.optin === "optional") {
|
|
5613
|
+
const result = def.innerType._zod.run(payload, ctx);
|
|
5614
|
+
if (result instanceof Promise) return result.then((r) => handleOptionalResult(r, payload.value));
|
|
5615
|
+
return handleOptionalResult(result, payload.value);
|
|
5616
|
+
}
|
|
5415
5617
|
if (payload.value === void 0) return payload;
|
|
5416
5618
|
return def.innerType._zod.run(payload, ctx);
|
|
5417
5619
|
};
|
|
5418
5620
|
});
|
|
5621
|
+
const $ZodExactOptional = /* @__PURE__ */ $constructor("$ZodExactOptional", (inst, def) => {
|
|
5622
|
+
$ZodOptional.init(inst, def);
|
|
5623
|
+
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
5624
|
+
defineLazy(inst._zod, "pattern", () => def.innerType._zod.pattern);
|
|
5625
|
+
inst._zod.parse = (payload, ctx) => {
|
|
5626
|
+
return def.innerType._zod.run(payload, ctx);
|
|
5627
|
+
};
|
|
5628
|
+
});
|
|
5419
5629
|
const $ZodNullable = /* @__PURE__ */ $constructor("$ZodNullable", (inst, def) => {
|
|
5420
5630
|
$ZodType.init(inst, def);
|
|
5421
5631
|
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
@@ -5437,10 +5647,11 @@ const $ZodDefault = /* @__PURE__ */ $constructor("$ZodDefault", (inst, def) => {
|
|
|
5437
5647
|
inst._zod.optin = "optional";
|
|
5438
5648
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
5439
5649
|
inst._zod.parse = (payload, ctx) => {
|
|
5650
|
+
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
5440
5651
|
if (payload.value === void 0) {
|
|
5441
5652
|
payload.value = def.defaultValue;
|
|
5442
5653
|
/**
|
|
5443
|
-
* $ZodDefault
|
|
5654
|
+
* $ZodDefault returns the default value immediately in forward direction.
|
|
5444
5655
|
* It doesn't pass the default value into the validator ("prefault"). There's no reason to pass the default value through validation. The validity of the default is enforced by TypeScript statically. Otherwise, it's the responsibility of the user to ensure the default is valid. In the case of pipes with divergent in/out types, you can specify the default on the `in` schema of your ZodPipe to set a "prefault" for the pipe. */
|
|
5445
5656
|
return payload;
|
|
5446
5657
|
}
|
|
@@ -5458,6 +5669,7 @@ const $ZodPrefault = /* @__PURE__ */ $constructor("$ZodPrefault", (inst, def) =>
|
|
|
5458
5669
|
inst._zod.optin = "optional";
|
|
5459
5670
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
5460
5671
|
inst._zod.parse = (payload, ctx) => {
|
|
5672
|
+
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
5461
5673
|
if (payload.value === void 0) payload.value = def.defaultValue;
|
|
5462
5674
|
return def.innerType._zod.run(payload, ctx);
|
|
5463
5675
|
};
|
|
@@ -5485,10 +5697,11 @@ function handleNonOptionalResult(payload, inst) {
|
|
|
5485
5697
|
}
|
|
5486
5698
|
const $ZodCatch = /* @__PURE__ */ $constructor("$ZodCatch", (inst, def) => {
|
|
5487
5699
|
$ZodType.init(inst, def);
|
|
5488
|
-
inst._zod
|
|
5700
|
+
defineLazy(inst._zod, "optin", () => def.innerType._zod.optin);
|
|
5489
5701
|
defineLazy(inst._zod, "optout", () => def.innerType._zod.optout);
|
|
5490
5702
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
5491
5703
|
inst._zod.parse = (payload, ctx) => {
|
|
5704
|
+
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
5492
5705
|
const result = def.innerType._zod.run(payload, ctx);
|
|
5493
5706
|
if (result instanceof Promise) return result.then((result) => {
|
|
5494
5707
|
payload.value = result.value;
|
|
@@ -5519,15 +5732,24 @@ const $ZodPipe = /* @__PURE__ */ $constructor("$ZodPipe", (inst, def) => {
|
|
|
5519
5732
|
defineLazy(inst._zod, "values", () => def.in._zod.values);
|
|
5520
5733
|
defineLazy(inst._zod, "optin", () => def.in._zod.optin);
|
|
5521
5734
|
defineLazy(inst._zod, "optout", () => def.out._zod.optout);
|
|
5735
|
+
defineLazy(inst._zod, "propValues", () => def.in._zod.propValues);
|
|
5522
5736
|
inst._zod.parse = (payload, ctx) => {
|
|
5737
|
+
if (ctx.direction === "backward") {
|
|
5738
|
+
const right = def.out._zod.run(payload, ctx);
|
|
5739
|
+
if (right instanceof Promise) return right.then((right) => handlePipeResult(right, def.in, ctx));
|
|
5740
|
+
return handlePipeResult(right, def.in, ctx);
|
|
5741
|
+
}
|
|
5523
5742
|
const left = def.in._zod.run(payload, ctx);
|
|
5524
|
-
if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def, ctx));
|
|
5525
|
-
return handlePipeResult(left, def, ctx);
|
|
5743
|
+
if (left instanceof Promise) return left.then((left) => handlePipeResult(left, def.out, ctx));
|
|
5744
|
+
return handlePipeResult(left, def.out, ctx);
|
|
5526
5745
|
};
|
|
5527
5746
|
});
|
|
5528
|
-
function handlePipeResult(left,
|
|
5529
|
-
if (
|
|
5530
|
-
|
|
5747
|
+
function handlePipeResult(left, next, ctx) {
|
|
5748
|
+
if (left.issues.length) {
|
|
5749
|
+
left.aborted = true;
|
|
5750
|
+
return left;
|
|
5751
|
+
}
|
|
5752
|
+
return next._zod.run({
|
|
5531
5753
|
value: left.value,
|
|
5532
5754
|
issues: left.issues
|
|
5533
5755
|
}, ctx);
|
|
@@ -5536,9 +5758,10 @@ const $ZodReadonly = /* @__PURE__ */ $constructor("$ZodReadonly", (inst, def) =>
|
|
|
5536
5758
|
$ZodType.init(inst, def);
|
|
5537
5759
|
defineLazy(inst._zod, "propValues", () => def.innerType._zod.propValues);
|
|
5538
5760
|
defineLazy(inst._zod, "values", () => def.innerType._zod.values);
|
|
5539
|
-
defineLazy(inst._zod, "optin", () => def.innerType
|
|
5540
|
-
defineLazy(inst._zod, "optout", () => def.innerType
|
|
5761
|
+
defineLazy(inst._zod, "optin", () => def.innerType?._zod?.optin);
|
|
5762
|
+
defineLazy(inst._zod, "optout", () => def.innerType?._zod?.optout);
|
|
5541
5763
|
inst._zod.parse = (payload, ctx) => {
|
|
5764
|
+
if (ctx.direction === "backward") return def.innerType._zod.run(payload, ctx);
|
|
5542
5765
|
const result = def.innerType._zod.run(payload, ctx);
|
|
5543
5766
|
if (result instanceof Promise) return result.then(handleReadonlyResult);
|
|
5544
5767
|
return handleReadonlyResult(result);
|
|
@@ -5577,22 +5800,20 @@ function handleRefineResult(result, payload, input, inst) {
|
|
|
5577
5800
|
|
|
5578
5801
|
//#endregion
|
|
5579
5802
|
//#region node_modules/zod/v4/core/registries.js
|
|
5803
|
+
var _a$1;
|
|
5580
5804
|
var $ZodRegistry = class {
|
|
5581
5805
|
constructor() {
|
|
5582
|
-
this._map = /* @__PURE__ */ new
|
|
5806
|
+
this._map = /* @__PURE__ */ new WeakMap();
|
|
5583
5807
|
this._idmap = /* @__PURE__ */ new Map();
|
|
5584
5808
|
}
|
|
5585
5809
|
add(schema, ..._meta) {
|
|
5586
5810
|
const meta = _meta[0];
|
|
5587
5811
|
this._map.set(schema, meta);
|
|
5588
|
-
if (meta && typeof meta === "object" && "id" in meta)
|
|
5589
|
-
if (this._idmap.has(meta.id)) throw new Error(`ID ${meta.id} already exists in the registry`);
|
|
5590
|
-
this._idmap.set(meta.id, schema);
|
|
5591
|
-
}
|
|
5812
|
+
if (meta && typeof meta === "object" && "id" in meta) this._idmap.set(meta.id, schema);
|
|
5592
5813
|
return this;
|
|
5593
5814
|
}
|
|
5594
5815
|
clear() {
|
|
5595
|
-
this._map = /* @__PURE__ */ new
|
|
5816
|
+
this._map = /* @__PURE__ */ new WeakMap();
|
|
5596
5817
|
this._idmap = /* @__PURE__ */ new Map();
|
|
5597
5818
|
return this;
|
|
5598
5819
|
}
|
|
@@ -5607,10 +5828,11 @@ var $ZodRegistry = class {
|
|
|
5607
5828
|
if (p) {
|
|
5608
5829
|
const pm = { ...this.get(p) ?? {} };
|
|
5609
5830
|
delete pm.id;
|
|
5610
|
-
|
|
5831
|
+
const f = {
|
|
5611
5832
|
...pm,
|
|
5612
5833
|
...this._map.get(schema)
|
|
5613
5834
|
};
|
|
5835
|
+
return Object.keys(f).length ? f : void 0;
|
|
5614
5836
|
}
|
|
5615
5837
|
return this._map.get(schema);
|
|
5616
5838
|
}
|
|
@@ -5621,16 +5843,19 @@ var $ZodRegistry = class {
|
|
|
5621
5843
|
function registry() {
|
|
5622
5844
|
return new $ZodRegistry();
|
|
5623
5845
|
}
|
|
5624
|
-
|
|
5846
|
+
(_a$1 = globalThis).__zod_globalRegistry ?? (_a$1.__zod_globalRegistry = registry());
|
|
5847
|
+
const globalRegistry = globalThis.__zod_globalRegistry;
|
|
5625
5848
|
|
|
5626
5849
|
//#endregion
|
|
5627
5850
|
//#region node_modules/zod/v4/core/api.js
|
|
5851
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5628
5852
|
function _string(Class, params) {
|
|
5629
5853
|
return new Class({
|
|
5630
5854
|
type: "string",
|
|
5631
5855
|
...normalizeParams(params)
|
|
5632
5856
|
});
|
|
5633
5857
|
}
|
|
5858
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5634
5859
|
function _email(Class, params) {
|
|
5635
5860
|
return new Class({
|
|
5636
5861
|
type: "string",
|
|
@@ -5640,6 +5865,7 @@ function _email(Class, params) {
|
|
|
5640
5865
|
...normalizeParams(params)
|
|
5641
5866
|
});
|
|
5642
5867
|
}
|
|
5868
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5643
5869
|
function _guid(Class, params) {
|
|
5644
5870
|
return new Class({
|
|
5645
5871
|
type: "string",
|
|
@@ -5649,6 +5875,7 @@ function _guid(Class, params) {
|
|
|
5649
5875
|
...normalizeParams(params)
|
|
5650
5876
|
});
|
|
5651
5877
|
}
|
|
5878
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5652
5879
|
function _uuid(Class, params) {
|
|
5653
5880
|
return new Class({
|
|
5654
5881
|
type: "string",
|
|
@@ -5658,6 +5885,7 @@ function _uuid(Class, params) {
|
|
|
5658
5885
|
...normalizeParams(params)
|
|
5659
5886
|
});
|
|
5660
5887
|
}
|
|
5888
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5661
5889
|
function _uuidv4(Class, params) {
|
|
5662
5890
|
return new Class({
|
|
5663
5891
|
type: "string",
|
|
@@ -5668,6 +5896,7 @@ function _uuidv4(Class, params) {
|
|
|
5668
5896
|
...normalizeParams(params)
|
|
5669
5897
|
});
|
|
5670
5898
|
}
|
|
5899
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5671
5900
|
function _uuidv6(Class, params) {
|
|
5672
5901
|
return new Class({
|
|
5673
5902
|
type: "string",
|
|
@@ -5678,6 +5907,7 @@ function _uuidv6(Class, params) {
|
|
|
5678
5907
|
...normalizeParams(params)
|
|
5679
5908
|
});
|
|
5680
5909
|
}
|
|
5910
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5681
5911
|
function _uuidv7(Class, params) {
|
|
5682
5912
|
return new Class({
|
|
5683
5913
|
type: "string",
|
|
@@ -5688,6 +5918,7 @@ function _uuidv7(Class, params) {
|
|
|
5688
5918
|
...normalizeParams(params)
|
|
5689
5919
|
});
|
|
5690
5920
|
}
|
|
5921
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5691
5922
|
function _url(Class, params) {
|
|
5692
5923
|
return new Class({
|
|
5693
5924
|
type: "string",
|
|
@@ -5697,6 +5928,7 @@ function _url(Class, params) {
|
|
|
5697
5928
|
...normalizeParams(params)
|
|
5698
5929
|
});
|
|
5699
5930
|
}
|
|
5931
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5700
5932
|
function _emoji(Class, params) {
|
|
5701
5933
|
return new Class({
|
|
5702
5934
|
type: "string",
|
|
@@ -5706,6 +5938,7 @@ function _emoji(Class, params) {
|
|
|
5706
5938
|
...normalizeParams(params)
|
|
5707
5939
|
});
|
|
5708
5940
|
}
|
|
5941
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5709
5942
|
function _nanoid(Class, params) {
|
|
5710
5943
|
return new Class({
|
|
5711
5944
|
type: "string",
|
|
@@ -5715,6 +5948,7 @@ function _nanoid(Class, params) {
|
|
|
5715
5948
|
...normalizeParams(params)
|
|
5716
5949
|
});
|
|
5717
5950
|
}
|
|
5951
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5718
5952
|
function _cuid(Class, params) {
|
|
5719
5953
|
return new Class({
|
|
5720
5954
|
type: "string",
|
|
@@ -5724,6 +5958,7 @@ function _cuid(Class, params) {
|
|
|
5724
5958
|
...normalizeParams(params)
|
|
5725
5959
|
});
|
|
5726
5960
|
}
|
|
5961
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5727
5962
|
function _cuid2(Class, params) {
|
|
5728
5963
|
return new Class({
|
|
5729
5964
|
type: "string",
|
|
@@ -5733,6 +5968,7 @@ function _cuid2(Class, params) {
|
|
|
5733
5968
|
...normalizeParams(params)
|
|
5734
5969
|
});
|
|
5735
5970
|
}
|
|
5971
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5736
5972
|
function _ulid(Class, params) {
|
|
5737
5973
|
return new Class({
|
|
5738
5974
|
type: "string",
|
|
@@ -5742,6 +5978,7 @@ function _ulid(Class, params) {
|
|
|
5742
5978
|
...normalizeParams(params)
|
|
5743
5979
|
});
|
|
5744
5980
|
}
|
|
5981
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5745
5982
|
function _xid(Class, params) {
|
|
5746
5983
|
return new Class({
|
|
5747
5984
|
type: "string",
|
|
@@ -5751,6 +5988,7 @@ function _xid(Class, params) {
|
|
|
5751
5988
|
...normalizeParams(params)
|
|
5752
5989
|
});
|
|
5753
5990
|
}
|
|
5991
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5754
5992
|
function _ksuid(Class, params) {
|
|
5755
5993
|
return new Class({
|
|
5756
5994
|
type: "string",
|
|
@@ -5760,6 +5998,7 @@ function _ksuid(Class, params) {
|
|
|
5760
5998
|
...normalizeParams(params)
|
|
5761
5999
|
});
|
|
5762
6000
|
}
|
|
6001
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5763
6002
|
function _ipv4(Class, params) {
|
|
5764
6003
|
return new Class({
|
|
5765
6004
|
type: "string",
|
|
@@ -5769,6 +6008,7 @@ function _ipv4(Class, params) {
|
|
|
5769
6008
|
...normalizeParams(params)
|
|
5770
6009
|
});
|
|
5771
6010
|
}
|
|
6011
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5772
6012
|
function _ipv6(Class, params) {
|
|
5773
6013
|
return new Class({
|
|
5774
6014
|
type: "string",
|
|
@@ -5778,6 +6018,7 @@ function _ipv6(Class, params) {
|
|
|
5778
6018
|
...normalizeParams(params)
|
|
5779
6019
|
});
|
|
5780
6020
|
}
|
|
6021
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5781
6022
|
function _cidrv4(Class, params) {
|
|
5782
6023
|
return new Class({
|
|
5783
6024
|
type: "string",
|
|
@@ -5787,6 +6028,7 @@ function _cidrv4(Class, params) {
|
|
|
5787
6028
|
...normalizeParams(params)
|
|
5788
6029
|
});
|
|
5789
6030
|
}
|
|
6031
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5790
6032
|
function _cidrv6(Class, params) {
|
|
5791
6033
|
return new Class({
|
|
5792
6034
|
type: "string",
|
|
@@ -5796,6 +6038,7 @@ function _cidrv6(Class, params) {
|
|
|
5796
6038
|
...normalizeParams(params)
|
|
5797
6039
|
});
|
|
5798
6040
|
}
|
|
6041
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5799
6042
|
function _base64(Class, params) {
|
|
5800
6043
|
return new Class({
|
|
5801
6044
|
type: "string",
|
|
@@ -5805,6 +6048,7 @@ function _base64(Class, params) {
|
|
|
5805
6048
|
...normalizeParams(params)
|
|
5806
6049
|
});
|
|
5807
6050
|
}
|
|
6051
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5808
6052
|
function _base64url(Class, params) {
|
|
5809
6053
|
return new Class({
|
|
5810
6054
|
type: "string",
|
|
@@ -5814,6 +6058,7 @@ function _base64url(Class, params) {
|
|
|
5814
6058
|
...normalizeParams(params)
|
|
5815
6059
|
});
|
|
5816
6060
|
}
|
|
6061
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5817
6062
|
function _e164(Class, params) {
|
|
5818
6063
|
return new Class({
|
|
5819
6064
|
type: "string",
|
|
@@ -5823,6 +6068,7 @@ function _e164(Class, params) {
|
|
|
5823
6068
|
...normalizeParams(params)
|
|
5824
6069
|
});
|
|
5825
6070
|
}
|
|
6071
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5826
6072
|
function _jwt(Class, params) {
|
|
5827
6073
|
return new Class({
|
|
5828
6074
|
type: "string",
|
|
@@ -5832,6 +6078,7 @@ function _jwt(Class, params) {
|
|
|
5832
6078
|
...normalizeParams(params)
|
|
5833
6079
|
});
|
|
5834
6080
|
}
|
|
6081
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5835
6082
|
function _isoDateTime(Class, params) {
|
|
5836
6083
|
return new Class({
|
|
5837
6084
|
type: "string",
|
|
@@ -5843,6 +6090,7 @@ function _isoDateTime(Class, params) {
|
|
|
5843
6090
|
...normalizeParams(params)
|
|
5844
6091
|
});
|
|
5845
6092
|
}
|
|
6093
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5846
6094
|
function _isoDate(Class, params) {
|
|
5847
6095
|
return new Class({
|
|
5848
6096
|
type: "string",
|
|
@@ -5851,6 +6099,7 @@ function _isoDate(Class, params) {
|
|
|
5851
6099
|
...normalizeParams(params)
|
|
5852
6100
|
});
|
|
5853
6101
|
}
|
|
6102
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5854
6103
|
function _isoTime(Class, params) {
|
|
5855
6104
|
return new Class({
|
|
5856
6105
|
type: "string",
|
|
@@ -5860,6 +6109,7 @@ function _isoTime(Class, params) {
|
|
|
5860
6109
|
...normalizeParams(params)
|
|
5861
6110
|
});
|
|
5862
6111
|
}
|
|
6112
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5863
6113
|
function _isoDuration(Class, params) {
|
|
5864
6114
|
return new Class({
|
|
5865
6115
|
type: "string",
|
|
@@ -5868,6 +6118,7 @@ function _isoDuration(Class, params) {
|
|
|
5868
6118
|
...normalizeParams(params)
|
|
5869
6119
|
});
|
|
5870
6120
|
}
|
|
6121
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5871
6122
|
function _number(Class, params) {
|
|
5872
6123
|
return new Class({
|
|
5873
6124
|
type: "number",
|
|
@@ -5875,6 +6126,7 @@ function _number(Class, params) {
|
|
|
5875
6126
|
...normalizeParams(params)
|
|
5876
6127
|
});
|
|
5877
6128
|
}
|
|
6129
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5878
6130
|
function _int(Class, params) {
|
|
5879
6131
|
return new Class({
|
|
5880
6132
|
type: "number",
|
|
@@ -5884,27 +6136,32 @@ function _int(Class, params) {
|
|
|
5884
6136
|
...normalizeParams(params)
|
|
5885
6137
|
});
|
|
5886
6138
|
}
|
|
6139
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5887
6140
|
function _boolean(Class, params) {
|
|
5888
6141
|
return new Class({
|
|
5889
6142
|
type: "boolean",
|
|
5890
6143
|
...normalizeParams(params)
|
|
5891
6144
|
});
|
|
5892
6145
|
}
|
|
6146
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5893
6147
|
function _null$1(Class, params) {
|
|
5894
6148
|
return new Class({
|
|
5895
6149
|
type: "null",
|
|
5896
6150
|
...normalizeParams(params)
|
|
5897
6151
|
});
|
|
5898
6152
|
}
|
|
6153
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5899
6154
|
function _unknown(Class) {
|
|
5900
6155
|
return new Class({ type: "unknown" });
|
|
5901
6156
|
}
|
|
6157
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5902
6158
|
function _never(Class, params) {
|
|
5903
6159
|
return new Class({
|
|
5904
6160
|
type: "never",
|
|
5905
6161
|
...normalizeParams(params)
|
|
5906
6162
|
});
|
|
5907
6163
|
}
|
|
6164
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5908
6165
|
function _lt(value, params) {
|
|
5909
6166
|
return new $ZodCheckLessThan({
|
|
5910
6167
|
check: "less_than",
|
|
@@ -5913,6 +6170,7 @@ function _lt(value, params) {
|
|
|
5913
6170
|
inclusive: false
|
|
5914
6171
|
});
|
|
5915
6172
|
}
|
|
6173
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5916
6174
|
function _lte(value, params) {
|
|
5917
6175
|
return new $ZodCheckLessThan({
|
|
5918
6176
|
check: "less_than",
|
|
@@ -5921,6 +6179,7 @@ function _lte(value, params) {
|
|
|
5921
6179
|
inclusive: true
|
|
5922
6180
|
});
|
|
5923
6181
|
}
|
|
6182
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5924
6183
|
function _gt(value, params) {
|
|
5925
6184
|
return new $ZodCheckGreaterThan({
|
|
5926
6185
|
check: "greater_than",
|
|
@@ -5929,6 +6188,7 @@ function _gt(value, params) {
|
|
|
5929
6188
|
inclusive: false
|
|
5930
6189
|
});
|
|
5931
6190
|
}
|
|
6191
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5932
6192
|
function _gte(value, params) {
|
|
5933
6193
|
return new $ZodCheckGreaterThan({
|
|
5934
6194
|
check: "greater_than",
|
|
@@ -5937,6 +6197,7 @@ function _gte(value, params) {
|
|
|
5937
6197
|
inclusive: true
|
|
5938
6198
|
});
|
|
5939
6199
|
}
|
|
6200
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5940
6201
|
function _multipleOf(value, params) {
|
|
5941
6202
|
return new $ZodCheckMultipleOf({
|
|
5942
6203
|
check: "multiple_of",
|
|
@@ -5944,6 +6205,7 @@ function _multipleOf(value, params) {
|
|
|
5944
6205
|
value
|
|
5945
6206
|
});
|
|
5946
6207
|
}
|
|
6208
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5947
6209
|
function _maxLength(maximum, params) {
|
|
5948
6210
|
return new $ZodCheckMaxLength({
|
|
5949
6211
|
check: "max_length",
|
|
@@ -5951,6 +6213,7 @@ function _maxLength(maximum, params) {
|
|
|
5951
6213
|
maximum
|
|
5952
6214
|
});
|
|
5953
6215
|
}
|
|
6216
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5954
6217
|
function _minLength(minimum, params) {
|
|
5955
6218
|
return new $ZodCheckMinLength({
|
|
5956
6219
|
check: "min_length",
|
|
@@ -5958,6 +6221,7 @@ function _minLength(minimum, params) {
|
|
|
5958
6221
|
minimum
|
|
5959
6222
|
});
|
|
5960
6223
|
}
|
|
6224
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5961
6225
|
function _length(length, params) {
|
|
5962
6226
|
return new $ZodCheckLengthEquals({
|
|
5963
6227
|
check: "length_equals",
|
|
@@ -5965,6 +6229,7 @@ function _length(length, params) {
|
|
|
5965
6229
|
length
|
|
5966
6230
|
});
|
|
5967
6231
|
}
|
|
6232
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5968
6233
|
function _regex(pattern, params) {
|
|
5969
6234
|
return new $ZodCheckRegex({
|
|
5970
6235
|
check: "string_format",
|
|
@@ -5973,6 +6238,7 @@ function _regex(pattern, params) {
|
|
|
5973
6238
|
pattern
|
|
5974
6239
|
});
|
|
5975
6240
|
}
|
|
6241
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5976
6242
|
function _lowercase(params) {
|
|
5977
6243
|
return new $ZodCheckLowerCase({
|
|
5978
6244
|
check: "string_format",
|
|
@@ -5980,6 +6246,7 @@ function _lowercase(params) {
|
|
|
5980
6246
|
...normalizeParams(params)
|
|
5981
6247
|
});
|
|
5982
6248
|
}
|
|
6249
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5983
6250
|
function _uppercase(params) {
|
|
5984
6251
|
return new $ZodCheckUpperCase({
|
|
5985
6252
|
check: "string_format",
|
|
@@ -5987,6 +6254,7 @@ function _uppercase(params) {
|
|
|
5987
6254
|
...normalizeParams(params)
|
|
5988
6255
|
});
|
|
5989
6256
|
}
|
|
6257
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5990
6258
|
function _includes(includes, params) {
|
|
5991
6259
|
return new $ZodCheckIncludes({
|
|
5992
6260
|
check: "string_format",
|
|
@@ -5995,6 +6263,7 @@ function _includes(includes, params) {
|
|
|
5995
6263
|
includes
|
|
5996
6264
|
});
|
|
5997
6265
|
}
|
|
6266
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
5998
6267
|
function _startsWith(prefix, params) {
|
|
5999
6268
|
return new $ZodCheckStartsWith({
|
|
6000
6269
|
check: "string_format",
|
|
@@ -6003,6 +6272,7 @@ function _startsWith(prefix, params) {
|
|
|
6003
6272
|
prefix
|
|
6004
6273
|
});
|
|
6005
6274
|
}
|
|
6275
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6006
6276
|
function _endsWith(suffix, params) {
|
|
6007
6277
|
return new $ZodCheckEndsWith({
|
|
6008
6278
|
check: "string_format",
|
|
@@ -6011,24 +6281,34 @@ function _endsWith(suffix, params) {
|
|
|
6011
6281
|
suffix
|
|
6012
6282
|
});
|
|
6013
6283
|
}
|
|
6284
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6014
6285
|
function _overwrite(tx) {
|
|
6015
6286
|
return new $ZodCheckOverwrite({
|
|
6016
6287
|
check: "overwrite",
|
|
6017
6288
|
tx
|
|
6018
6289
|
});
|
|
6019
6290
|
}
|
|
6291
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6020
6292
|
function _normalize(form) {
|
|
6021
|
-
return _overwrite((input) => input.normalize(form));
|
|
6293
|
+
return /* @__PURE__ */ _overwrite((input) => input.normalize(form));
|
|
6022
6294
|
}
|
|
6295
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6023
6296
|
function _trim() {
|
|
6024
|
-
return _overwrite((input) => input.trim());
|
|
6297
|
+
return /* @__PURE__ */ _overwrite((input) => input.trim());
|
|
6025
6298
|
}
|
|
6299
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6026
6300
|
function _toLowerCase() {
|
|
6027
|
-
return _overwrite((input) => input.toLowerCase());
|
|
6301
|
+
return /* @__PURE__ */ _overwrite((input) => input.toLowerCase());
|
|
6028
6302
|
}
|
|
6303
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6029
6304
|
function _toUpperCase() {
|
|
6030
|
-
return _overwrite((input) => input.toUpperCase());
|
|
6305
|
+
return /* @__PURE__ */ _overwrite((input) => input.toUpperCase());
|
|
6306
|
+
}
|
|
6307
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6308
|
+
function _slugify() {
|
|
6309
|
+
return /* @__PURE__ */ _overwrite((input) => slugify(input));
|
|
6031
6310
|
}
|
|
6311
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6032
6312
|
function _array(Class, element, params) {
|
|
6033
6313
|
return new Class({
|
|
6034
6314
|
type: "array",
|
|
@@ -6036,6 +6316,7 @@ function _array(Class, element, params) {
|
|
|
6036
6316
|
...normalizeParams(params)
|
|
6037
6317
|
});
|
|
6038
6318
|
}
|
|
6319
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6039
6320
|
function _custom(Class, fn, _params) {
|
|
6040
6321
|
const norm = normalizeParams(_params);
|
|
6041
6322
|
norm.abort ?? (norm.abort = true);
|
|
@@ -6046,6 +6327,7 @@ function _custom(Class, fn, _params) {
|
|
|
6046
6327
|
...norm
|
|
6047
6328
|
});
|
|
6048
6329
|
}
|
|
6330
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6049
6331
|
function _refine(Class, fn, _params) {
|
|
6050
6332
|
return new Class({
|
|
6051
6333
|
type: "custom",
|
|
@@ -6054,599 +6336,802 @@ function _refine(Class, fn, _params) {
|
|
|
6054
6336
|
...normalizeParams(_params)
|
|
6055
6337
|
});
|
|
6056
6338
|
}
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
process(schema, _params = {
|
|
6071
|
-
path: [],
|
|
6072
|
-
schemaPath: []
|
|
6073
|
-
}) {
|
|
6074
|
-
var _a;
|
|
6075
|
-
const def = schema._zod.def;
|
|
6076
|
-
const formatMap = {
|
|
6077
|
-
guid: "uuid",
|
|
6078
|
-
url: "uri",
|
|
6079
|
-
datetime: "date-time",
|
|
6080
|
-
json_string: "json-string",
|
|
6081
|
-
regex: ""
|
|
6082
|
-
};
|
|
6083
|
-
const seen = this.seen.get(schema);
|
|
6084
|
-
if (seen) {
|
|
6085
|
-
seen.count++;
|
|
6086
|
-
if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
|
|
6087
|
-
return seen.schema;
|
|
6088
|
-
}
|
|
6089
|
-
const result = {
|
|
6090
|
-
schema: {},
|
|
6091
|
-
count: 1,
|
|
6092
|
-
cycle: void 0,
|
|
6093
|
-
path: _params.path
|
|
6094
|
-
};
|
|
6095
|
-
this.seen.set(schema, result);
|
|
6096
|
-
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
6097
|
-
if (overrideSchema) result.schema = overrideSchema;
|
|
6098
|
-
else {
|
|
6099
|
-
const params = {
|
|
6100
|
-
..._params,
|
|
6101
|
-
schemaPath: [..._params.schemaPath, schema],
|
|
6102
|
-
path: _params.path
|
|
6103
|
-
};
|
|
6104
|
-
const parent = schema._zod.parent;
|
|
6105
|
-
if (parent) {
|
|
6106
|
-
result.ref = parent;
|
|
6107
|
-
this.process(parent, params);
|
|
6108
|
-
this.seen.get(parent).isParent = true;
|
|
6109
|
-
} else {
|
|
6110
|
-
const _json = result.schema;
|
|
6111
|
-
switch (def.type) {
|
|
6112
|
-
case "string": {
|
|
6113
|
-
const json = _json;
|
|
6114
|
-
json.type = "string";
|
|
6115
|
-
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
|
|
6116
|
-
if (typeof minimum === "number") json.minLength = minimum;
|
|
6117
|
-
if (typeof maximum === "number") json.maxLength = maximum;
|
|
6118
|
-
if (format) {
|
|
6119
|
-
json.format = formatMap[format] ?? format;
|
|
6120
|
-
if (json.format === "") delete json.format;
|
|
6121
|
-
}
|
|
6122
|
-
if (contentEncoding) json.contentEncoding = contentEncoding;
|
|
6123
|
-
if (patterns && patterns.size > 0) {
|
|
6124
|
-
const regexes = [...patterns];
|
|
6125
|
-
if (regexes.length === 1) json.pattern = regexes[0].source;
|
|
6126
|
-
else if (regexes.length > 1) result.schema.allOf = [...regexes.map((regex) => ({
|
|
6127
|
-
...this.target === "draft-7" ? { type: "string" } : {},
|
|
6128
|
-
pattern: regex.source
|
|
6129
|
-
}))];
|
|
6130
|
-
}
|
|
6131
|
-
break;
|
|
6132
|
-
}
|
|
6133
|
-
case "number": {
|
|
6134
|
-
const json = _json;
|
|
6135
|
-
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
6136
|
-
if (typeof format === "string" && format.includes("int")) json.type = "integer";
|
|
6137
|
-
else json.type = "number";
|
|
6138
|
-
if (typeof exclusiveMinimum === "number") json.exclusiveMinimum = exclusiveMinimum;
|
|
6139
|
-
if (typeof minimum === "number") {
|
|
6140
|
-
json.minimum = minimum;
|
|
6141
|
-
if (typeof exclusiveMinimum === "number") if (exclusiveMinimum >= minimum) delete json.minimum;
|
|
6142
|
-
else delete json.exclusiveMinimum;
|
|
6143
|
-
}
|
|
6144
|
-
if (typeof exclusiveMaximum === "number") json.exclusiveMaximum = exclusiveMaximum;
|
|
6145
|
-
if (typeof maximum === "number") {
|
|
6146
|
-
json.maximum = maximum;
|
|
6147
|
-
if (typeof exclusiveMaximum === "number") if (exclusiveMaximum <= maximum) delete json.maximum;
|
|
6148
|
-
else delete json.exclusiveMaximum;
|
|
6149
|
-
}
|
|
6150
|
-
if (typeof multipleOf === "number") json.multipleOf = multipleOf;
|
|
6151
|
-
break;
|
|
6152
|
-
}
|
|
6153
|
-
case "boolean": {
|
|
6154
|
-
const json = _json;
|
|
6155
|
-
json.type = "boolean";
|
|
6156
|
-
break;
|
|
6157
|
-
}
|
|
6158
|
-
case "bigint":
|
|
6159
|
-
if (this.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
|
|
6160
|
-
break;
|
|
6161
|
-
case "symbol":
|
|
6162
|
-
if (this.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
|
|
6163
|
-
break;
|
|
6164
|
-
case "null":
|
|
6165
|
-
_json.type = "null";
|
|
6166
|
-
break;
|
|
6167
|
-
case "any": break;
|
|
6168
|
-
case "unknown": break;
|
|
6169
|
-
case "undefined":
|
|
6170
|
-
if (this.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
|
|
6171
|
-
break;
|
|
6172
|
-
case "void":
|
|
6173
|
-
if (this.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
|
|
6174
|
-
break;
|
|
6175
|
-
case "never":
|
|
6176
|
-
_json.not = {};
|
|
6177
|
-
break;
|
|
6178
|
-
case "date":
|
|
6179
|
-
if (this.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
|
|
6180
|
-
break;
|
|
6181
|
-
case "array": {
|
|
6182
|
-
const json = _json;
|
|
6183
|
-
const { minimum, maximum } = schema._zod.bag;
|
|
6184
|
-
if (typeof minimum === "number") json.minItems = minimum;
|
|
6185
|
-
if (typeof maximum === "number") json.maxItems = maximum;
|
|
6186
|
-
json.type = "array";
|
|
6187
|
-
json.items = this.process(def.element, {
|
|
6188
|
-
...params,
|
|
6189
|
-
path: [...params.path, "items"]
|
|
6190
|
-
});
|
|
6191
|
-
break;
|
|
6192
|
-
}
|
|
6193
|
-
case "object": {
|
|
6194
|
-
const json = _json;
|
|
6195
|
-
json.type = "object";
|
|
6196
|
-
json.properties = {};
|
|
6197
|
-
const shape = def.shape;
|
|
6198
|
-
for (const key in shape) json.properties[key] = this.process(shape[key], {
|
|
6199
|
-
...params,
|
|
6200
|
-
path: [
|
|
6201
|
-
...params.path,
|
|
6202
|
-
"properties",
|
|
6203
|
-
key
|
|
6204
|
-
]
|
|
6205
|
-
});
|
|
6206
|
-
const allKeys = new Set(Object.keys(shape));
|
|
6207
|
-
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
6208
|
-
const v = def.shape[key]._zod;
|
|
6209
|
-
if (this.io === "input") return v.optin === void 0;
|
|
6210
|
-
else return v.optout === void 0;
|
|
6211
|
-
}));
|
|
6212
|
-
if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
|
|
6213
|
-
if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
|
|
6214
|
-
else if (!def.catchall) {
|
|
6215
|
-
if (this.io === "output") json.additionalProperties = false;
|
|
6216
|
-
} else if (def.catchall) json.additionalProperties = this.process(def.catchall, {
|
|
6217
|
-
...params,
|
|
6218
|
-
path: [...params.path, "additionalProperties"]
|
|
6219
|
-
});
|
|
6220
|
-
break;
|
|
6221
|
-
}
|
|
6222
|
-
case "union": {
|
|
6223
|
-
const json = _json;
|
|
6224
|
-
json.anyOf = def.options.map((x, i) => this.process(x, {
|
|
6225
|
-
...params,
|
|
6226
|
-
path: [
|
|
6227
|
-
...params.path,
|
|
6228
|
-
"anyOf",
|
|
6229
|
-
i
|
|
6230
|
-
]
|
|
6231
|
-
}));
|
|
6232
|
-
break;
|
|
6233
|
-
}
|
|
6234
|
-
case "intersection": {
|
|
6235
|
-
const json = _json;
|
|
6236
|
-
const a = this.process(def.left, {
|
|
6237
|
-
...params,
|
|
6238
|
-
path: [
|
|
6239
|
-
...params.path,
|
|
6240
|
-
"allOf",
|
|
6241
|
-
0
|
|
6242
|
-
]
|
|
6243
|
-
});
|
|
6244
|
-
const b = this.process(def.right, {
|
|
6245
|
-
...params,
|
|
6246
|
-
path: [
|
|
6247
|
-
...params.path,
|
|
6248
|
-
"allOf",
|
|
6249
|
-
1
|
|
6250
|
-
]
|
|
6251
|
-
});
|
|
6252
|
-
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
6253
|
-
json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
|
|
6254
|
-
break;
|
|
6255
|
-
}
|
|
6256
|
-
case "tuple": {
|
|
6257
|
-
const json = _json;
|
|
6258
|
-
json.type = "array";
|
|
6259
|
-
const prefixItems = def.items.map((x, i) => this.process(x, {
|
|
6260
|
-
...params,
|
|
6261
|
-
path: [
|
|
6262
|
-
...params.path,
|
|
6263
|
-
"prefixItems",
|
|
6264
|
-
i
|
|
6265
|
-
]
|
|
6266
|
-
}));
|
|
6267
|
-
if (this.target === "draft-2020-12") json.prefixItems = prefixItems;
|
|
6268
|
-
else json.items = prefixItems;
|
|
6269
|
-
if (def.rest) {
|
|
6270
|
-
const rest = this.process(def.rest, {
|
|
6271
|
-
...params,
|
|
6272
|
-
path: [...params.path, "items"]
|
|
6273
|
-
});
|
|
6274
|
-
if (this.target === "draft-2020-12") json.items = rest;
|
|
6275
|
-
else json.additionalItems = rest;
|
|
6276
|
-
}
|
|
6277
|
-
if (def.rest) json.items = this.process(def.rest, {
|
|
6278
|
-
...params,
|
|
6279
|
-
path: [...params.path, "items"]
|
|
6280
|
-
});
|
|
6281
|
-
const { minimum, maximum } = schema._zod.bag;
|
|
6282
|
-
if (typeof minimum === "number") json.minItems = minimum;
|
|
6283
|
-
if (typeof maximum === "number") json.maxItems = maximum;
|
|
6284
|
-
break;
|
|
6285
|
-
}
|
|
6286
|
-
case "record": {
|
|
6287
|
-
const json = _json;
|
|
6288
|
-
json.type = "object";
|
|
6289
|
-
json.propertyNames = this.process(def.keyType, {
|
|
6290
|
-
...params,
|
|
6291
|
-
path: [...params.path, "propertyNames"]
|
|
6292
|
-
});
|
|
6293
|
-
json.additionalProperties = this.process(def.valueType, {
|
|
6294
|
-
...params,
|
|
6295
|
-
path: [...params.path, "additionalProperties"]
|
|
6296
|
-
});
|
|
6297
|
-
break;
|
|
6298
|
-
}
|
|
6299
|
-
case "map":
|
|
6300
|
-
if (this.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
|
|
6301
|
-
break;
|
|
6302
|
-
case "set":
|
|
6303
|
-
if (this.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
|
|
6304
|
-
break;
|
|
6305
|
-
case "enum": {
|
|
6306
|
-
const json = _json;
|
|
6307
|
-
const values = getEnumValues(def.entries);
|
|
6308
|
-
if (values.every((v) => typeof v === "number")) json.type = "number";
|
|
6309
|
-
if (values.every((v) => typeof v === "string")) json.type = "string";
|
|
6310
|
-
json.enum = values;
|
|
6311
|
-
break;
|
|
6312
|
-
}
|
|
6313
|
-
case "literal": {
|
|
6314
|
-
const json = _json;
|
|
6315
|
-
const vals = [];
|
|
6316
|
-
for (const val of def.values) if (val === void 0) {
|
|
6317
|
-
if (this.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
6318
|
-
} else if (typeof val === "bigint") if (this.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
6319
|
-
else vals.push(Number(val));
|
|
6320
|
-
else vals.push(val);
|
|
6321
|
-
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
6322
|
-
const val = vals[0];
|
|
6323
|
-
json.type = val === null ? "null" : typeof val;
|
|
6324
|
-
json.const = val;
|
|
6325
|
-
} else {
|
|
6326
|
-
if (vals.every((v) => typeof v === "number")) json.type = "number";
|
|
6327
|
-
if (vals.every((v) => typeof v === "string")) json.type = "string";
|
|
6328
|
-
if (vals.every((v) => typeof v === "boolean")) json.type = "string";
|
|
6329
|
-
if (vals.every((v) => v === null)) json.type = "null";
|
|
6330
|
-
json.enum = vals;
|
|
6331
|
-
}
|
|
6332
|
-
break;
|
|
6333
|
-
}
|
|
6334
|
-
case "file": {
|
|
6335
|
-
const json = _json;
|
|
6336
|
-
const file = {
|
|
6337
|
-
type: "string",
|
|
6338
|
-
format: "binary",
|
|
6339
|
-
contentEncoding: "binary"
|
|
6340
|
-
};
|
|
6341
|
-
const { minimum, maximum, mime } = schema._zod.bag;
|
|
6342
|
-
if (minimum !== void 0) file.minLength = minimum;
|
|
6343
|
-
if (maximum !== void 0) file.maxLength = maximum;
|
|
6344
|
-
if (mime) if (mime.length === 1) {
|
|
6345
|
-
file.contentMediaType = mime[0];
|
|
6346
|
-
Object.assign(json, file);
|
|
6347
|
-
} else json.anyOf = mime.map((m) => {
|
|
6348
|
-
return {
|
|
6349
|
-
...file,
|
|
6350
|
-
contentMediaType: m
|
|
6351
|
-
};
|
|
6352
|
-
});
|
|
6353
|
-
else Object.assign(json, file);
|
|
6354
|
-
break;
|
|
6355
|
-
}
|
|
6356
|
-
case "transform":
|
|
6357
|
-
if (this.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
6358
|
-
break;
|
|
6359
|
-
case "nullable":
|
|
6360
|
-
_json.anyOf = [this.process(def.innerType, params), { type: "null" }];
|
|
6361
|
-
break;
|
|
6362
|
-
case "nonoptional":
|
|
6363
|
-
this.process(def.innerType, params);
|
|
6364
|
-
result.ref = def.innerType;
|
|
6365
|
-
break;
|
|
6366
|
-
case "success": {
|
|
6367
|
-
const json = _json;
|
|
6368
|
-
json.type = "boolean";
|
|
6369
|
-
break;
|
|
6370
|
-
}
|
|
6371
|
-
case "default":
|
|
6372
|
-
this.process(def.innerType, params);
|
|
6373
|
-
result.ref = def.innerType;
|
|
6374
|
-
_json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
6375
|
-
break;
|
|
6376
|
-
case "prefault":
|
|
6377
|
-
this.process(def.innerType, params);
|
|
6378
|
-
result.ref = def.innerType;
|
|
6379
|
-
if (this.io === "input") _json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
6380
|
-
break;
|
|
6381
|
-
case "catch": {
|
|
6382
|
-
this.process(def.innerType, params);
|
|
6383
|
-
result.ref = def.innerType;
|
|
6384
|
-
let catchValue;
|
|
6385
|
-
try {
|
|
6386
|
-
catchValue = def.catchValue(void 0);
|
|
6387
|
-
} catch {
|
|
6388
|
-
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
6389
|
-
}
|
|
6390
|
-
_json.default = catchValue;
|
|
6391
|
-
break;
|
|
6392
|
-
}
|
|
6393
|
-
case "nan":
|
|
6394
|
-
if (this.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
|
|
6395
|
-
break;
|
|
6396
|
-
case "template_literal": {
|
|
6397
|
-
const json = _json;
|
|
6398
|
-
const pattern = schema._zod.pattern;
|
|
6399
|
-
if (!pattern) throw new Error("Pattern not found in template literal");
|
|
6400
|
-
json.type = "string";
|
|
6401
|
-
json.pattern = pattern.source;
|
|
6402
|
-
break;
|
|
6403
|
-
}
|
|
6404
|
-
case "pipe": {
|
|
6405
|
-
const innerType = this.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
|
|
6406
|
-
this.process(innerType, params);
|
|
6407
|
-
result.ref = innerType;
|
|
6408
|
-
break;
|
|
6409
|
-
}
|
|
6410
|
-
case "readonly":
|
|
6411
|
-
this.process(def.innerType, params);
|
|
6412
|
-
result.ref = def.innerType;
|
|
6413
|
-
_json.readOnly = true;
|
|
6414
|
-
break;
|
|
6415
|
-
case "promise":
|
|
6416
|
-
this.process(def.innerType, params);
|
|
6417
|
-
result.ref = def.innerType;
|
|
6418
|
-
break;
|
|
6419
|
-
case "optional":
|
|
6420
|
-
this.process(def.innerType, params);
|
|
6421
|
-
result.ref = def.innerType;
|
|
6422
|
-
break;
|
|
6423
|
-
case "lazy": {
|
|
6424
|
-
const innerType = schema._zod.innerType;
|
|
6425
|
-
this.process(innerType, params);
|
|
6426
|
-
result.ref = innerType;
|
|
6427
|
-
break;
|
|
6428
|
-
}
|
|
6429
|
-
case "custom":
|
|
6430
|
-
if (this.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
6431
|
-
break;
|
|
6432
|
-
default:
|
|
6433
|
-
}
|
|
6339
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6340
|
+
function _superRefine(fn) {
|
|
6341
|
+
const ch = /* @__PURE__ */ _check((payload) => {
|
|
6342
|
+
payload.addIssue = (issue$2) => {
|
|
6343
|
+
if (typeof issue$2 === "string") payload.issues.push(issue(issue$2, payload.value, ch._zod.def));
|
|
6344
|
+
else {
|
|
6345
|
+
const _issue = issue$2;
|
|
6346
|
+
if (_issue.fatal) _issue.continue = false;
|
|
6347
|
+
_issue.code ?? (_issue.code = "custom");
|
|
6348
|
+
_issue.input ?? (_issue.input = payload.value);
|
|
6349
|
+
_issue.inst ?? (_issue.inst = ch);
|
|
6350
|
+
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
6351
|
+
payload.issues.push(issue(_issue));
|
|
6434
6352
|
}
|
|
6435
|
-
}
|
|
6436
|
-
|
|
6437
|
-
|
|
6438
|
-
|
|
6439
|
-
|
|
6440
|
-
|
|
6441
|
-
|
|
6442
|
-
|
|
6443
|
-
|
|
6444
|
-
|
|
6353
|
+
};
|
|
6354
|
+
return fn(payload.value, payload);
|
|
6355
|
+
});
|
|
6356
|
+
return ch;
|
|
6357
|
+
}
|
|
6358
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6359
|
+
function _check(fn, params) {
|
|
6360
|
+
const ch = new $ZodCheck({
|
|
6361
|
+
check: "custom",
|
|
6362
|
+
...normalizeParams(params)
|
|
6363
|
+
});
|
|
6364
|
+
ch._zod.check = fn;
|
|
6365
|
+
return ch;
|
|
6366
|
+
}
|
|
6367
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6368
|
+
function describe$2(description) {
|
|
6369
|
+
const ch = new $ZodCheck({ check: "describe" });
|
|
6370
|
+
ch._zod.onattach = [(inst) => {
|
|
6371
|
+
const existing = globalRegistry.get(inst) ?? {};
|
|
6372
|
+
globalRegistry.add(inst, {
|
|
6373
|
+
...existing,
|
|
6374
|
+
description
|
|
6375
|
+
});
|
|
6376
|
+
}];
|
|
6377
|
+
ch._zod.check = () => {};
|
|
6378
|
+
return ch;
|
|
6379
|
+
}
|
|
6380
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6381
|
+
function meta$2(metadata) {
|
|
6382
|
+
const ch = new $ZodCheck({ check: "meta" });
|
|
6383
|
+
ch._zod.onattach = [(inst) => {
|
|
6384
|
+
const existing = globalRegistry.get(inst) ?? {};
|
|
6385
|
+
globalRegistry.add(inst, {
|
|
6386
|
+
...existing,
|
|
6387
|
+
...metadata
|
|
6388
|
+
});
|
|
6389
|
+
}];
|
|
6390
|
+
ch._zod.check = () => {};
|
|
6391
|
+
return ch;
|
|
6392
|
+
}
|
|
6393
|
+
|
|
6394
|
+
//#endregion
|
|
6395
|
+
//#region node_modules/zod/v4/core/to-json-schema.js
|
|
6396
|
+
function initializeContext(params) {
|
|
6397
|
+
let target = params?.target ?? "draft-2020-12";
|
|
6398
|
+
if (target === "draft-4") target = "draft-04";
|
|
6399
|
+
if (target === "draft-7") target = "draft-07";
|
|
6400
|
+
return {
|
|
6401
|
+
processors: params.processors ?? {},
|
|
6402
|
+
metadataRegistry: params?.metadata ?? globalRegistry,
|
|
6403
|
+
target,
|
|
6404
|
+
unrepresentable: params?.unrepresentable ?? "throw",
|
|
6405
|
+
override: params?.override ?? (() => {}),
|
|
6406
|
+
io: params?.io ?? "output",
|
|
6407
|
+
counter: 0,
|
|
6408
|
+
seen: /* @__PURE__ */ new Map(),
|
|
6409
|
+
cycles: params?.cycles ?? "ref",
|
|
6410
|
+
reused: params?.reused ?? "inline",
|
|
6411
|
+
external: params?.external ?? void 0
|
|
6412
|
+
};
|
|
6413
|
+
}
|
|
6414
|
+
function process$2(schema, ctx, _params = {
|
|
6415
|
+
path: [],
|
|
6416
|
+
schemaPath: []
|
|
6417
|
+
}) {
|
|
6418
|
+
var _a;
|
|
6419
|
+
const def = schema._zod.def;
|
|
6420
|
+
const seen = ctx.seen.get(schema);
|
|
6421
|
+
if (seen) {
|
|
6422
|
+
seen.count++;
|
|
6423
|
+
if (_params.schemaPath.includes(schema)) seen.cycle = _params.path;
|
|
6424
|
+
return seen.schema;
|
|
6445
6425
|
}
|
|
6446
|
-
|
|
6426
|
+
const result = {
|
|
6427
|
+
schema: {},
|
|
6428
|
+
count: 1,
|
|
6429
|
+
cycle: void 0,
|
|
6430
|
+
path: _params.path
|
|
6431
|
+
};
|
|
6432
|
+
ctx.seen.set(schema, result);
|
|
6433
|
+
const overrideSchema = schema._zod.toJSONSchema?.();
|
|
6434
|
+
if (overrideSchema) result.schema = overrideSchema;
|
|
6435
|
+
else {
|
|
6447
6436
|
const params = {
|
|
6448
|
-
|
|
6449
|
-
|
|
6450
|
-
|
|
6437
|
+
..._params,
|
|
6438
|
+
schemaPath: [..._params.schemaPath, schema],
|
|
6439
|
+
path: _params.path
|
|
6451
6440
|
};
|
|
6452
|
-
|
|
6453
|
-
|
|
6454
|
-
|
|
6455
|
-
const
|
|
6456
|
-
if (
|
|
6457
|
-
|
|
6458
|
-
|
|
6459
|
-
|
|
6460
|
-
|
|
6461
|
-
|
|
6462
|
-
|
|
6463
|
-
|
|
6464
|
-
|
|
6465
|
-
|
|
6466
|
-
|
|
6467
|
-
|
|
6468
|
-
|
|
6469
|
-
|
|
6441
|
+
if (schema._zod.processJSONSchema) schema._zod.processJSONSchema(ctx, result.schema, params);
|
|
6442
|
+
else {
|
|
6443
|
+
const _json = result.schema;
|
|
6444
|
+
const processor = ctx.processors[def.type];
|
|
6445
|
+
if (!processor) throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
|
|
6446
|
+
processor(schema, ctx, _json, params);
|
|
6447
|
+
}
|
|
6448
|
+
const parent = schema._zod.parent;
|
|
6449
|
+
if (parent) {
|
|
6450
|
+
if (!result.ref) result.ref = parent;
|
|
6451
|
+
process$2(parent, ctx, params);
|
|
6452
|
+
ctx.seen.get(parent).isParent = true;
|
|
6453
|
+
}
|
|
6454
|
+
}
|
|
6455
|
+
const meta = ctx.metadataRegistry.get(schema);
|
|
6456
|
+
if (meta) Object.assign(result.schema, meta);
|
|
6457
|
+
if (ctx.io === "input" && isTransforming(schema)) {
|
|
6458
|
+
delete result.schema.examples;
|
|
6459
|
+
delete result.schema.default;
|
|
6460
|
+
}
|
|
6461
|
+
if (ctx.io === "input" && result.schema._prefault) (_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
6462
|
+
delete result.schema._prefault;
|
|
6463
|
+
return ctx.seen.get(schema).schema;
|
|
6464
|
+
}
|
|
6465
|
+
function extractDefs(ctx, schema) {
|
|
6466
|
+
const root = ctx.seen.get(schema);
|
|
6467
|
+
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
6468
|
+
const idToSchema = /* @__PURE__ */ new Map();
|
|
6469
|
+
for (const entry of ctx.seen.entries()) {
|
|
6470
|
+
const id = ctx.metadataRegistry.get(entry[0])?.id;
|
|
6471
|
+
if (id) {
|
|
6472
|
+
const existing = idToSchema.get(id);
|
|
6473
|
+
if (existing && existing !== entry[0]) throw new Error(`Duplicate schema id "${id}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);
|
|
6474
|
+
idToSchema.set(id, entry[0]);
|
|
6475
|
+
}
|
|
6476
|
+
}
|
|
6477
|
+
const makeURI = (entry) => {
|
|
6478
|
+
const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
|
|
6479
|
+
if (ctx.external) {
|
|
6480
|
+
const externalId = ctx.external.registry.get(entry[0])?.id;
|
|
6481
|
+
const uriGenerator = ctx.external.uri ?? ((id) => id);
|
|
6482
|
+
if (externalId) return { ref: uriGenerator(externalId) };
|
|
6483
|
+
const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
|
|
6484
|
+
entry[1].defId = id;
|
|
6470
6485
|
return {
|
|
6471
|
-
defId,
|
|
6472
|
-
ref:
|
|
6486
|
+
defId: id,
|
|
6487
|
+
ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}`
|
|
6473
6488
|
};
|
|
6489
|
+
}
|
|
6490
|
+
if (entry[1] === root) return { ref: "#" };
|
|
6491
|
+
const defUriPrefix = `#/${defsSegment}/`;
|
|
6492
|
+
const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
|
|
6493
|
+
return {
|
|
6494
|
+
defId,
|
|
6495
|
+
ref: defUriPrefix + defId
|
|
6474
6496
|
};
|
|
6475
|
-
|
|
6476
|
-
|
|
6477
|
-
|
|
6478
|
-
|
|
6479
|
-
|
|
6480
|
-
|
|
6481
|
-
|
|
6482
|
-
|
|
6483
|
-
|
|
6484
|
-
|
|
6485
|
-
|
|
6486
|
-
|
|
6487
|
-
|
|
6497
|
+
};
|
|
6498
|
+
const extractToDef = (entry) => {
|
|
6499
|
+
if (entry[1].schema.$ref) return;
|
|
6500
|
+
const seen = entry[1];
|
|
6501
|
+
const { ref, defId } = makeURI(entry);
|
|
6502
|
+
seen.def = { ...seen.schema };
|
|
6503
|
+
if (defId) seen.defId = defId;
|
|
6504
|
+
const schema = seen.schema;
|
|
6505
|
+
for (const key in schema) delete schema[key];
|
|
6506
|
+
schema.$ref = ref;
|
|
6507
|
+
};
|
|
6508
|
+
if (ctx.cycles === "throw") for (const entry of ctx.seen.entries()) {
|
|
6509
|
+
const seen = entry[1];
|
|
6510
|
+
if (seen.cycle) throw new Error(`Cycle detected: #/${seen.cycle?.join("/")}/<root>
|
|
6488
6511
|
|
|
6489
6512
|
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`);
|
|
6513
|
+
}
|
|
6514
|
+
for (const entry of ctx.seen.entries()) {
|
|
6515
|
+
const seen = entry[1];
|
|
6516
|
+
if (schema === entry[0]) {
|
|
6517
|
+
extractToDef(entry);
|
|
6518
|
+
continue;
|
|
6490
6519
|
}
|
|
6491
|
-
|
|
6492
|
-
const
|
|
6493
|
-
if (schema
|
|
6520
|
+
if (ctx.external) {
|
|
6521
|
+
const ext = ctx.external.registry.get(entry[0])?.id;
|
|
6522
|
+
if (schema !== entry[0] && ext) {
|
|
6494
6523
|
extractToDef(entry);
|
|
6495
6524
|
continue;
|
|
6496
6525
|
}
|
|
6497
|
-
|
|
6498
|
-
|
|
6499
|
-
|
|
6500
|
-
|
|
6501
|
-
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
|
|
6506
|
-
|
|
6507
|
-
|
|
6508
|
-
if (seen.cycle) {
|
|
6526
|
+
}
|
|
6527
|
+
if (ctx.metadataRegistry.get(entry[0])?.id) {
|
|
6528
|
+
extractToDef(entry);
|
|
6529
|
+
continue;
|
|
6530
|
+
}
|
|
6531
|
+
if (seen.cycle) {
|
|
6532
|
+
extractToDef(entry);
|
|
6533
|
+
continue;
|
|
6534
|
+
}
|
|
6535
|
+
if (seen.count > 1) {
|
|
6536
|
+
if (ctx.reused === "ref") {
|
|
6509
6537
|
extractToDef(entry);
|
|
6510
6538
|
continue;
|
|
6511
6539
|
}
|
|
6512
|
-
if (seen.count > 1) {
|
|
6513
|
-
if (params.reused === "ref") {
|
|
6514
|
-
extractToDef(entry);
|
|
6515
|
-
continue;
|
|
6516
|
-
}
|
|
6517
|
-
}
|
|
6518
6540
|
}
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6522
|
-
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
|
|
6527
|
-
|
|
6528
|
-
|
|
6529
|
-
|
|
6530
|
-
|
|
6531
|
-
|
|
6532
|
-
|
|
6533
|
-
|
|
6534
|
-
|
|
6541
|
+
}
|
|
6542
|
+
}
|
|
6543
|
+
function finalize(ctx, schema) {
|
|
6544
|
+
const root = ctx.seen.get(schema);
|
|
6545
|
+
if (!root) throw new Error("Unprocessed schema. This is a bug in Zod.");
|
|
6546
|
+
const flattenRef = (zodSchema) => {
|
|
6547
|
+
const seen = ctx.seen.get(zodSchema);
|
|
6548
|
+
if (seen.ref === null) return;
|
|
6549
|
+
const schema = seen.def ?? seen.schema;
|
|
6550
|
+
const _cached = { ...schema };
|
|
6551
|
+
const ref = seen.ref;
|
|
6552
|
+
seen.ref = null;
|
|
6553
|
+
if (ref) {
|
|
6554
|
+
flattenRef(ref);
|
|
6555
|
+
const refSeen = ctx.seen.get(ref);
|
|
6556
|
+
const refSchema = refSeen.schema;
|
|
6557
|
+
if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
|
|
6558
|
+
schema.allOf = schema.allOf ?? [];
|
|
6559
|
+
schema.allOf.push(refSchema);
|
|
6560
|
+
} else Object.assign(schema, refSchema);
|
|
6561
|
+
Object.assign(schema, _cached);
|
|
6562
|
+
if (zodSchema._zod.parent === ref) for (const key in schema) {
|
|
6563
|
+
if (key === "$ref" || key === "allOf") continue;
|
|
6564
|
+
if (!(key in _cached)) delete schema[key];
|
|
6565
|
+
}
|
|
6566
|
+
if (refSchema.$ref && refSeen.def) for (const key in schema) {
|
|
6567
|
+
if (key === "$ref" || key === "allOf") continue;
|
|
6568
|
+
if (key in refSeen.def && JSON.stringify(schema[key]) === JSON.stringify(refSeen.def[key])) delete schema[key];
|
|
6569
|
+
}
|
|
6570
|
+
}
|
|
6571
|
+
const parent = zodSchema._zod.parent;
|
|
6572
|
+
if (parent && parent !== ref) {
|
|
6573
|
+
flattenRef(parent);
|
|
6574
|
+
const parentSeen = ctx.seen.get(parent);
|
|
6575
|
+
if (parentSeen?.schema.$ref) {
|
|
6576
|
+
schema.$ref = parentSeen.schema.$ref;
|
|
6577
|
+
if (parentSeen.def) for (const key in schema) {
|
|
6578
|
+
if (key === "$ref" || key === "allOf") continue;
|
|
6579
|
+
if (key in parentSeen.def && JSON.stringify(schema[key]) === JSON.stringify(parentSeen.def[key])) delete schema[key];
|
|
6535
6580
|
}
|
|
6536
6581
|
}
|
|
6537
|
-
if (!seen.isParent) this.override({
|
|
6538
|
-
zodSchema,
|
|
6539
|
-
jsonSchema: schema,
|
|
6540
|
-
path: seen.path ?? []
|
|
6541
|
-
});
|
|
6542
|
-
};
|
|
6543
|
-
for (const entry of [...this.seen.entries()].reverse()) flattenRef(entry[0], { target: this.target });
|
|
6544
|
-
const result = {};
|
|
6545
|
-
if (this.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
6546
|
-
else if (this.target === "draft-7") result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
6547
|
-
else console.warn(`Invalid target: ${this.target}`);
|
|
6548
|
-
if (params.external?.uri) {
|
|
6549
|
-
const id = params.external.registry.get(schema)?.id;
|
|
6550
|
-
if (!id) throw new Error("Schema is missing an `id` property");
|
|
6551
|
-
result.$id = params.external.uri(id);
|
|
6552
|
-
}
|
|
6553
|
-
Object.assign(result, root.def);
|
|
6554
|
-
const defs = params.external?.defs ?? {};
|
|
6555
|
-
for (const entry of this.seen.entries()) {
|
|
6556
|
-
const seen = entry[1];
|
|
6557
|
-
if (seen.def && seen.defId) defs[seen.defId] = seen.def;
|
|
6558
|
-
}
|
|
6559
|
-
if (params.external) {} else if (Object.keys(defs).length > 0) if (this.target === "draft-2020-12") result.$defs = defs;
|
|
6560
|
-
else result.definitions = defs;
|
|
6561
|
-
try {
|
|
6562
|
-
return JSON.parse(JSON.stringify(result));
|
|
6563
|
-
} catch (_err) {
|
|
6564
|
-
throw new Error("Error converting schema to JSON.");
|
|
6565
6582
|
}
|
|
6583
|
+
ctx.override({
|
|
6584
|
+
zodSchema,
|
|
6585
|
+
jsonSchema: schema,
|
|
6586
|
+
path: seen.path ?? []
|
|
6587
|
+
});
|
|
6588
|
+
};
|
|
6589
|
+
for (const entry of [...ctx.seen.entries()].reverse()) flattenRef(entry[0]);
|
|
6590
|
+
const result = {};
|
|
6591
|
+
if (ctx.target === "draft-2020-12") result.$schema = "https://json-schema.org/draft/2020-12/schema";
|
|
6592
|
+
else if (ctx.target === "draft-07") result.$schema = "http://json-schema.org/draft-07/schema#";
|
|
6593
|
+
else if (ctx.target === "draft-04") result.$schema = "http://json-schema.org/draft-04/schema#";
|
|
6594
|
+
else if (ctx.target === "openapi-3.0") {}
|
|
6595
|
+
if (ctx.external?.uri) {
|
|
6596
|
+
const id = ctx.external.registry.get(schema)?.id;
|
|
6597
|
+
if (!id) throw new Error("Schema is missing an `id` property");
|
|
6598
|
+
result.$id = ctx.external.uri(id);
|
|
6599
|
+
}
|
|
6600
|
+
Object.assign(result, root.def ?? root.schema);
|
|
6601
|
+
const defs = ctx.external?.defs ?? {};
|
|
6602
|
+
for (const entry of ctx.seen.entries()) {
|
|
6603
|
+
const seen = entry[1];
|
|
6604
|
+
if (seen.def && seen.defId) defs[seen.defId] = seen.def;
|
|
6605
|
+
}
|
|
6606
|
+
if (ctx.external) {} else if (Object.keys(defs).length > 0) if (ctx.target === "draft-2020-12") result.$defs = defs;
|
|
6607
|
+
else result.definitions = defs;
|
|
6608
|
+
try {
|
|
6609
|
+
const finalized = JSON.parse(JSON.stringify(result));
|
|
6610
|
+
Object.defineProperty(finalized, "~standard", {
|
|
6611
|
+
value: {
|
|
6612
|
+
...schema["~standard"],
|
|
6613
|
+
jsonSchema: {
|
|
6614
|
+
input: createStandardJSONSchemaMethod(schema, "input", ctx.processors),
|
|
6615
|
+
output: createStandardJSONSchemaMethod(schema, "output", ctx.processors)
|
|
6616
|
+
}
|
|
6617
|
+
},
|
|
6618
|
+
enumerable: false,
|
|
6619
|
+
writable: false
|
|
6620
|
+
});
|
|
6621
|
+
return finalized;
|
|
6622
|
+
} catch (_err) {
|
|
6623
|
+
throw new Error("Error converting schema to JSON.");
|
|
6624
|
+
}
|
|
6625
|
+
}
|
|
6626
|
+
function isTransforming(_schema, _ctx) {
|
|
6627
|
+
const ctx = _ctx ?? { seen: /* @__PURE__ */ new Set() };
|
|
6628
|
+
if (ctx.seen.has(_schema)) return false;
|
|
6629
|
+
ctx.seen.add(_schema);
|
|
6630
|
+
const def = _schema._zod.def;
|
|
6631
|
+
if (def.type === "transform") return true;
|
|
6632
|
+
if (def.type === "array") return isTransforming(def.element, ctx);
|
|
6633
|
+
if (def.type === "set") return isTransforming(def.valueType, ctx);
|
|
6634
|
+
if (def.type === "lazy") return isTransforming(def.getter(), ctx);
|
|
6635
|
+
if (def.type === "promise" || def.type === "optional" || def.type === "nonoptional" || def.type === "nullable" || def.type === "readonly" || def.type === "default" || def.type === "prefault") return isTransforming(def.innerType, ctx);
|
|
6636
|
+
if (def.type === "intersection") return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
6637
|
+
if (def.type === "record" || def.type === "map") return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
6638
|
+
if (def.type === "pipe") return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
6639
|
+
if (def.type === "object") {
|
|
6640
|
+
for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
|
|
6641
|
+
return false;
|
|
6642
|
+
}
|
|
6643
|
+
if (def.type === "union") {
|
|
6644
|
+
for (const option of def.options) if (isTransforming(option, ctx)) return true;
|
|
6645
|
+
return false;
|
|
6646
|
+
}
|
|
6647
|
+
if (def.type === "tuple") {
|
|
6648
|
+
for (const item of def.items) if (isTransforming(item, ctx)) return true;
|
|
6649
|
+
if (def.rest && isTransforming(def.rest, ctx)) return true;
|
|
6650
|
+
return false;
|
|
6651
|
+
}
|
|
6652
|
+
return false;
|
|
6653
|
+
}
|
|
6654
|
+
/**
|
|
6655
|
+
* Creates a toJSONSchema method for a schema instance.
|
|
6656
|
+
* This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
|
|
6657
|
+
*/
|
|
6658
|
+
const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
|
|
6659
|
+
const ctx = initializeContext({
|
|
6660
|
+
...params,
|
|
6661
|
+
processors
|
|
6662
|
+
});
|
|
6663
|
+
process$2(schema, ctx);
|
|
6664
|
+
extractDefs(ctx, schema);
|
|
6665
|
+
return finalize(ctx, schema);
|
|
6666
|
+
};
|
|
6667
|
+
const createStandardJSONSchemaMethod = (schema, io, processors = {}) => (params) => {
|
|
6668
|
+
const { libraryOptions, target } = params ?? {};
|
|
6669
|
+
const ctx = initializeContext({
|
|
6670
|
+
...libraryOptions ?? {},
|
|
6671
|
+
target,
|
|
6672
|
+
io,
|
|
6673
|
+
processors
|
|
6674
|
+
});
|
|
6675
|
+
process$2(schema, ctx);
|
|
6676
|
+
extractDefs(ctx, schema);
|
|
6677
|
+
return finalize(ctx, schema);
|
|
6678
|
+
};
|
|
6679
|
+
|
|
6680
|
+
//#endregion
|
|
6681
|
+
//#region node_modules/zod/v4/core/json-schema-processors.js
|
|
6682
|
+
const formatMap = {
|
|
6683
|
+
guid: "uuid",
|
|
6684
|
+
url: "uri",
|
|
6685
|
+
datetime: "date-time",
|
|
6686
|
+
json_string: "json-string",
|
|
6687
|
+
regex: ""
|
|
6688
|
+
};
|
|
6689
|
+
const stringProcessor = (schema, ctx, _json, _params) => {
|
|
6690
|
+
const json = _json;
|
|
6691
|
+
json.type = "string";
|
|
6692
|
+
const { minimum, maximum, format, patterns, contentEncoding } = schema._zod.bag;
|
|
6693
|
+
if (typeof minimum === "number") json.minLength = minimum;
|
|
6694
|
+
if (typeof maximum === "number") json.maxLength = maximum;
|
|
6695
|
+
if (format) {
|
|
6696
|
+
json.format = formatMap[format] ?? format;
|
|
6697
|
+
if (json.format === "") delete json.format;
|
|
6698
|
+
if (format === "time") delete json.format;
|
|
6699
|
+
}
|
|
6700
|
+
if (contentEncoding) json.contentEncoding = contentEncoding;
|
|
6701
|
+
if (patterns && patterns.size > 0) {
|
|
6702
|
+
const regexes = [...patterns];
|
|
6703
|
+
if (regexes.length === 1) json.pattern = regexes[0].source;
|
|
6704
|
+
else if (regexes.length > 1) json.allOf = [...regexes.map((regex) => ({
|
|
6705
|
+
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
6706
|
+
pattern: regex.source
|
|
6707
|
+
}))];
|
|
6708
|
+
}
|
|
6709
|
+
};
|
|
6710
|
+
const numberProcessor = (schema, ctx, _json, _params) => {
|
|
6711
|
+
const json = _json;
|
|
6712
|
+
const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
|
|
6713
|
+
if (typeof format === "string" && format.includes("int")) json.type = "integer";
|
|
6714
|
+
else json.type = "number";
|
|
6715
|
+
if (typeof exclusiveMinimum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
6716
|
+
json.minimum = exclusiveMinimum;
|
|
6717
|
+
json.exclusiveMinimum = true;
|
|
6718
|
+
} else json.exclusiveMinimum = exclusiveMinimum;
|
|
6719
|
+
if (typeof minimum === "number") {
|
|
6720
|
+
json.minimum = minimum;
|
|
6721
|
+
if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") if (exclusiveMinimum >= minimum) delete json.minimum;
|
|
6722
|
+
else delete json.exclusiveMinimum;
|
|
6723
|
+
}
|
|
6724
|
+
if (typeof exclusiveMaximum === "number") if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
6725
|
+
json.maximum = exclusiveMaximum;
|
|
6726
|
+
json.exclusiveMaximum = true;
|
|
6727
|
+
} else json.exclusiveMaximum = exclusiveMaximum;
|
|
6728
|
+
if (typeof maximum === "number") {
|
|
6729
|
+
json.maximum = maximum;
|
|
6730
|
+
if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") if (exclusiveMaximum <= maximum) delete json.maximum;
|
|
6731
|
+
else delete json.exclusiveMaximum;
|
|
6732
|
+
}
|
|
6733
|
+
if (typeof multipleOf === "number") json.multipleOf = multipleOf;
|
|
6734
|
+
};
|
|
6735
|
+
const booleanProcessor = (_schema, _ctx, json, _params) => {
|
|
6736
|
+
json.type = "boolean";
|
|
6737
|
+
};
|
|
6738
|
+
const bigintProcessor = (_schema, ctx, _json, _params) => {
|
|
6739
|
+
if (ctx.unrepresentable === "throw") throw new Error("BigInt cannot be represented in JSON Schema");
|
|
6740
|
+
};
|
|
6741
|
+
const symbolProcessor = (_schema, ctx, _json, _params) => {
|
|
6742
|
+
if (ctx.unrepresentable === "throw") throw new Error("Symbols cannot be represented in JSON Schema");
|
|
6743
|
+
};
|
|
6744
|
+
const nullProcessor = (_schema, ctx, json, _params) => {
|
|
6745
|
+
if (ctx.target === "openapi-3.0") {
|
|
6746
|
+
json.type = "string";
|
|
6747
|
+
json.nullable = true;
|
|
6748
|
+
json.enum = [null];
|
|
6749
|
+
} else json.type = "null";
|
|
6750
|
+
};
|
|
6751
|
+
const undefinedProcessor = (_schema, ctx, _json, _params) => {
|
|
6752
|
+
if (ctx.unrepresentable === "throw") throw new Error("Undefined cannot be represented in JSON Schema");
|
|
6753
|
+
};
|
|
6754
|
+
const voidProcessor = (_schema, ctx, _json, _params) => {
|
|
6755
|
+
if (ctx.unrepresentable === "throw") throw new Error("Void cannot be represented in JSON Schema");
|
|
6756
|
+
};
|
|
6757
|
+
const neverProcessor = (_schema, _ctx, json, _params) => {
|
|
6758
|
+
json.not = {};
|
|
6759
|
+
};
|
|
6760
|
+
const anyProcessor = (_schema, _ctx, _json, _params) => {};
|
|
6761
|
+
const unknownProcessor = (_schema, _ctx, _json, _params) => {};
|
|
6762
|
+
const dateProcessor = (_schema, ctx, _json, _params) => {
|
|
6763
|
+
if (ctx.unrepresentable === "throw") throw new Error("Date cannot be represented in JSON Schema");
|
|
6764
|
+
};
|
|
6765
|
+
const enumProcessor = (schema, _ctx, json, _params) => {
|
|
6766
|
+
const def = schema._zod.def;
|
|
6767
|
+
const values = getEnumValues(def.entries);
|
|
6768
|
+
if (values.every((v) => typeof v === "number")) json.type = "number";
|
|
6769
|
+
if (values.every((v) => typeof v === "string")) json.type = "string";
|
|
6770
|
+
json.enum = values;
|
|
6771
|
+
};
|
|
6772
|
+
const literalProcessor = (schema, ctx, json, _params) => {
|
|
6773
|
+
const def = schema._zod.def;
|
|
6774
|
+
const vals = [];
|
|
6775
|
+
for (const val of def.values) if (val === void 0) {
|
|
6776
|
+
if (ctx.unrepresentable === "throw") throw new Error("Literal `undefined` cannot be represented in JSON Schema");
|
|
6777
|
+
} else if (typeof val === "bigint") if (ctx.unrepresentable === "throw") throw new Error("BigInt literals cannot be represented in JSON Schema");
|
|
6778
|
+
else vals.push(Number(val));
|
|
6779
|
+
else vals.push(val);
|
|
6780
|
+
if (vals.length === 0) {} else if (vals.length === 1) {
|
|
6781
|
+
const val = vals[0];
|
|
6782
|
+
json.type = val === null ? "null" : typeof val;
|
|
6783
|
+
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") json.enum = [val];
|
|
6784
|
+
else json.const = val;
|
|
6785
|
+
} else {
|
|
6786
|
+
if (vals.every((v) => typeof v === "number")) json.type = "number";
|
|
6787
|
+
if (vals.every((v) => typeof v === "string")) json.type = "string";
|
|
6788
|
+
if (vals.every((v) => typeof v === "boolean")) json.type = "boolean";
|
|
6789
|
+
if (vals.every((v) => v === null)) json.type = "null";
|
|
6790
|
+
json.enum = vals;
|
|
6791
|
+
}
|
|
6792
|
+
};
|
|
6793
|
+
const nanProcessor = (_schema, ctx, _json, _params) => {
|
|
6794
|
+
if (ctx.unrepresentable === "throw") throw new Error("NaN cannot be represented in JSON Schema");
|
|
6795
|
+
};
|
|
6796
|
+
const templateLiteralProcessor = (schema, _ctx, json, _params) => {
|
|
6797
|
+
const _json = json;
|
|
6798
|
+
const pattern = schema._zod.pattern;
|
|
6799
|
+
if (!pattern) throw new Error("Pattern not found in template literal");
|
|
6800
|
+
_json.type = "string";
|
|
6801
|
+
_json.pattern = pattern.source;
|
|
6802
|
+
};
|
|
6803
|
+
const fileProcessor = (schema, _ctx, json, _params) => {
|
|
6804
|
+
const _json = json;
|
|
6805
|
+
const file = {
|
|
6806
|
+
type: "string",
|
|
6807
|
+
format: "binary",
|
|
6808
|
+
contentEncoding: "binary"
|
|
6809
|
+
};
|
|
6810
|
+
const { minimum, maximum, mime } = schema._zod.bag;
|
|
6811
|
+
if (minimum !== void 0) file.minLength = minimum;
|
|
6812
|
+
if (maximum !== void 0) file.maxLength = maximum;
|
|
6813
|
+
if (mime) if (mime.length === 1) {
|
|
6814
|
+
file.contentMediaType = mime[0];
|
|
6815
|
+
Object.assign(_json, file);
|
|
6816
|
+
} else {
|
|
6817
|
+
Object.assign(_json, file);
|
|
6818
|
+
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
6819
|
+
}
|
|
6820
|
+
else Object.assign(_json, file);
|
|
6821
|
+
};
|
|
6822
|
+
const successProcessor = (_schema, _ctx, json, _params) => {
|
|
6823
|
+
json.type = "boolean";
|
|
6824
|
+
};
|
|
6825
|
+
const customProcessor = (_schema, ctx, _json, _params) => {
|
|
6826
|
+
if (ctx.unrepresentable === "throw") throw new Error("Custom types cannot be represented in JSON Schema");
|
|
6827
|
+
};
|
|
6828
|
+
const functionProcessor = (_schema, ctx, _json, _params) => {
|
|
6829
|
+
if (ctx.unrepresentable === "throw") throw new Error("Function types cannot be represented in JSON Schema");
|
|
6830
|
+
};
|
|
6831
|
+
const transformProcessor = (_schema, ctx, _json, _params) => {
|
|
6832
|
+
if (ctx.unrepresentable === "throw") throw new Error("Transforms cannot be represented in JSON Schema");
|
|
6833
|
+
};
|
|
6834
|
+
const mapProcessor = (_schema, ctx, _json, _params) => {
|
|
6835
|
+
if (ctx.unrepresentable === "throw") throw new Error("Map cannot be represented in JSON Schema");
|
|
6836
|
+
};
|
|
6837
|
+
const setProcessor = (_schema, ctx, _json, _params) => {
|
|
6838
|
+
if (ctx.unrepresentable === "throw") throw new Error("Set cannot be represented in JSON Schema");
|
|
6839
|
+
};
|
|
6840
|
+
const arrayProcessor = (schema, ctx, _json, params) => {
|
|
6841
|
+
const json = _json;
|
|
6842
|
+
const def = schema._zod.def;
|
|
6843
|
+
const { minimum, maximum } = schema._zod.bag;
|
|
6844
|
+
if (typeof minimum === "number") json.minItems = minimum;
|
|
6845
|
+
if (typeof maximum === "number") json.maxItems = maximum;
|
|
6846
|
+
json.type = "array";
|
|
6847
|
+
json.items = process$2(def.element, ctx, {
|
|
6848
|
+
...params,
|
|
6849
|
+
path: [...params.path, "items"]
|
|
6850
|
+
});
|
|
6851
|
+
};
|
|
6852
|
+
const objectProcessor = (schema, ctx, _json, params) => {
|
|
6853
|
+
const json = _json;
|
|
6854
|
+
const def = schema._zod.def;
|
|
6855
|
+
json.type = "object";
|
|
6856
|
+
json.properties = {};
|
|
6857
|
+
const shape = def.shape;
|
|
6858
|
+
for (const key in shape) json.properties[key] = process$2(shape[key], ctx, {
|
|
6859
|
+
...params,
|
|
6860
|
+
path: [
|
|
6861
|
+
...params.path,
|
|
6862
|
+
"properties",
|
|
6863
|
+
key
|
|
6864
|
+
]
|
|
6865
|
+
});
|
|
6866
|
+
const allKeys = new Set(Object.keys(shape));
|
|
6867
|
+
const requiredKeys = new Set([...allKeys].filter((key) => {
|
|
6868
|
+
const v = def.shape[key]._zod;
|
|
6869
|
+
if (ctx.io === "input") return v.optin === void 0;
|
|
6870
|
+
else return v.optout === void 0;
|
|
6871
|
+
}));
|
|
6872
|
+
if (requiredKeys.size > 0) json.required = Array.from(requiredKeys);
|
|
6873
|
+
if (def.catchall?._zod.def.type === "never") json.additionalProperties = false;
|
|
6874
|
+
else if (!def.catchall) {
|
|
6875
|
+
if (ctx.io === "output") json.additionalProperties = false;
|
|
6876
|
+
} else if (def.catchall) json.additionalProperties = process$2(def.catchall, ctx, {
|
|
6877
|
+
...params,
|
|
6878
|
+
path: [...params.path, "additionalProperties"]
|
|
6879
|
+
});
|
|
6880
|
+
};
|
|
6881
|
+
const unionProcessor = (schema, ctx, json, params) => {
|
|
6882
|
+
const def = schema._zod.def;
|
|
6883
|
+
const isExclusive = def.inclusive === false;
|
|
6884
|
+
const options = def.options.map((x, i) => process$2(x, ctx, {
|
|
6885
|
+
...params,
|
|
6886
|
+
path: [
|
|
6887
|
+
...params.path,
|
|
6888
|
+
isExclusive ? "oneOf" : "anyOf",
|
|
6889
|
+
i
|
|
6890
|
+
]
|
|
6891
|
+
}));
|
|
6892
|
+
if (isExclusive) json.oneOf = options;
|
|
6893
|
+
else json.anyOf = options;
|
|
6894
|
+
};
|
|
6895
|
+
const intersectionProcessor = (schema, ctx, json, params) => {
|
|
6896
|
+
const def = schema._zod.def;
|
|
6897
|
+
const a = process$2(def.left, ctx, {
|
|
6898
|
+
...params,
|
|
6899
|
+
path: [
|
|
6900
|
+
...params.path,
|
|
6901
|
+
"allOf",
|
|
6902
|
+
0
|
|
6903
|
+
]
|
|
6904
|
+
});
|
|
6905
|
+
const b = process$2(def.right, ctx, {
|
|
6906
|
+
...params,
|
|
6907
|
+
path: [
|
|
6908
|
+
...params.path,
|
|
6909
|
+
"allOf",
|
|
6910
|
+
1
|
|
6911
|
+
]
|
|
6912
|
+
});
|
|
6913
|
+
const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
|
|
6914
|
+
json.allOf = [...isSimpleIntersection(a) ? a.allOf : [a], ...isSimpleIntersection(b) ? b.allOf : [b]];
|
|
6915
|
+
};
|
|
6916
|
+
const tupleProcessor = (schema, ctx, _json, params) => {
|
|
6917
|
+
const json = _json;
|
|
6918
|
+
const def = schema._zod.def;
|
|
6919
|
+
json.type = "array";
|
|
6920
|
+
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
6921
|
+
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
6922
|
+
const prefixItems = def.items.map((x, i) => process$2(x, ctx, {
|
|
6923
|
+
...params,
|
|
6924
|
+
path: [
|
|
6925
|
+
...params.path,
|
|
6926
|
+
prefixPath,
|
|
6927
|
+
i
|
|
6928
|
+
]
|
|
6929
|
+
}));
|
|
6930
|
+
const rest = def.rest ? process$2(def.rest, ctx, {
|
|
6931
|
+
...params,
|
|
6932
|
+
path: [
|
|
6933
|
+
...params.path,
|
|
6934
|
+
restPath,
|
|
6935
|
+
...ctx.target === "openapi-3.0" ? [def.items.length] : []
|
|
6936
|
+
]
|
|
6937
|
+
}) : null;
|
|
6938
|
+
if (ctx.target === "draft-2020-12") {
|
|
6939
|
+
json.prefixItems = prefixItems;
|
|
6940
|
+
if (rest) json.items = rest;
|
|
6941
|
+
} else if (ctx.target === "openapi-3.0") {
|
|
6942
|
+
json.items = { anyOf: prefixItems };
|
|
6943
|
+
if (rest) json.items.anyOf.push(rest);
|
|
6944
|
+
json.minItems = prefixItems.length;
|
|
6945
|
+
if (!rest) json.maxItems = prefixItems.length;
|
|
6946
|
+
} else {
|
|
6947
|
+
json.items = prefixItems;
|
|
6948
|
+
if (rest) json.additionalItems = rest;
|
|
6949
|
+
}
|
|
6950
|
+
const { minimum, maximum } = schema._zod.bag;
|
|
6951
|
+
if (typeof minimum === "number") json.minItems = minimum;
|
|
6952
|
+
if (typeof maximum === "number") json.maxItems = maximum;
|
|
6953
|
+
};
|
|
6954
|
+
const recordProcessor = (schema, ctx, _json, params) => {
|
|
6955
|
+
const json = _json;
|
|
6956
|
+
const def = schema._zod.def;
|
|
6957
|
+
json.type = "object";
|
|
6958
|
+
const keyType = def.keyType;
|
|
6959
|
+
const patterns = keyType._zod.bag?.patterns;
|
|
6960
|
+
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
6961
|
+
const valueSchema = process$2(def.valueType, ctx, {
|
|
6962
|
+
...params,
|
|
6963
|
+
path: [
|
|
6964
|
+
...params.path,
|
|
6965
|
+
"patternProperties",
|
|
6966
|
+
"*"
|
|
6967
|
+
]
|
|
6968
|
+
});
|
|
6969
|
+
json.patternProperties = {};
|
|
6970
|
+
for (const pattern of patterns) json.patternProperties[pattern.source] = valueSchema;
|
|
6971
|
+
} else {
|
|
6972
|
+
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") json.propertyNames = process$2(def.keyType, ctx, {
|
|
6973
|
+
...params,
|
|
6974
|
+
path: [...params.path, "propertyNames"]
|
|
6975
|
+
});
|
|
6976
|
+
json.additionalProperties = process$2(def.valueType, ctx, {
|
|
6977
|
+
...params,
|
|
6978
|
+
path: [...params.path, "additionalProperties"]
|
|
6979
|
+
});
|
|
6980
|
+
}
|
|
6981
|
+
const keyValues = keyType._zod.values;
|
|
6982
|
+
if (keyValues) {
|
|
6983
|
+
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
6984
|
+
if (validKeyValues.length > 0) json.required = validKeyValues;
|
|
6985
|
+
}
|
|
6986
|
+
};
|
|
6987
|
+
const nullableProcessor = (schema, ctx, json, params) => {
|
|
6988
|
+
const def = schema._zod.def;
|
|
6989
|
+
const inner = process$2(def.innerType, ctx, params);
|
|
6990
|
+
const seen = ctx.seen.get(schema);
|
|
6991
|
+
if (ctx.target === "openapi-3.0") {
|
|
6992
|
+
seen.ref = def.innerType;
|
|
6993
|
+
json.nullable = true;
|
|
6994
|
+
} else json.anyOf = [inner, { type: "null" }];
|
|
6995
|
+
};
|
|
6996
|
+
const nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
6997
|
+
const def = schema._zod.def;
|
|
6998
|
+
process$2(def.innerType, ctx, params);
|
|
6999
|
+
const seen = ctx.seen.get(schema);
|
|
7000
|
+
seen.ref = def.innerType;
|
|
7001
|
+
};
|
|
7002
|
+
const defaultProcessor = (schema, ctx, json, params) => {
|
|
7003
|
+
const def = schema._zod.def;
|
|
7004
|
+
process$2(def.innerType, ctx, params);
|
|
7005
|
+
const seen = ctx.seen.get(schema);
|
|
7006
|
+
seen.ref = def.innerType;
|
|
7007
|
+
json.default = JSON.parse(JSON.stringify(def.defaultValue));
|
|
7008
|
+
};
|
|
7009
|
+
const prefaultProcessor = (schema, ctx, json, params) => {
|
|
7010
|
+
const def = schema._zod.def;
|
|
7011
|
+
process$2(def.innerType, ctx, params);
|
|
7012
|
+
const seen = ctx.seen.get(schema);
|
|
7013
|
+
seen.ref = def.innerType;
|
|
7014
|
+
if (ctx.io === "input") json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
|
|
7015
|
+
};
|
|
7016
|
+
const catchProcessor = (schema, ctx, json, params) => {
|
|
7017
|
+
const def = schema._zod.def;
|
|
7018
|
+
process$2(def.innerType, ctx, params);
|
|
7019
|
+
const seen = ctx.seen.get(schema);
|
|
7020
|
+
seen.ref = def.innerType;
|
|
7021
|
+
let catchValue;
|
|
7022
|
+
try {
|
|
7023
|
+
catchValue = def.catchValue(void 0);
|
|
7024
|
+
} catch {
|
|
7025
|
+
throw new Error("Dynamic catch values are not supported in JSON Schema");
|
|
6566
7026
|
}
|
|
7027
|
+
json.default = catchValue;
|
|
7028
|
+
};
|
|
7029
|
+
const pipeProcessor = (schema, ctx, _json, params) => {
|
|
7030
|
+
const def = schema._zod.def;
|
|
7031
|
+
const innerType = ctx.io === "input" ? def.in._zod.def.type === "transform" ? def.out : def.in : def.out;
|
|
7032
|
+
process$2(innerType, ctx, params);
|
|
7033
|
+
const seen = ctx.seen.get(schema);
|
|
7034
|
+
seen.ref = innerType;
|
|
7035
|
+
};
|
|
7036
|
+
const readonlyProcessor = (schema, ctx, json, params) => {
|
|
7037
|
+
const def = schema._zod.def;
|
|
7038
|
+
process$2(def.innerType, ctx, params);
|
|
7039
|
+
const seen = ctx.seen.get(schema);
|
|
7040
|
+
seen.ref = def.innerType;
|
|
7041
|
+
json.readOnly = true;
|
|
7042
|
+
};
|
|
7043
|
+
const promiseProcessor = (schema, ctx, _json, params) => {
|
|
7044
|
+
const def = schema._zod.def;
|
|
7045
|
+
process$2(def.innerType, ctx, params);
|
|
7046
|
+
const seen = ctx.seen.get(schema);
|
|
7047
|
+
seen.ref = def.innerType;
|
|
7048
|
+
};
|
|
7049
|
+
const optionalProcessor = (schema, ctx, _json, params) => {
|
|
7050
|
+
const def = schema._zod.def;
|
|
7051
|
+
process$2(def.innerType, ctx, params);
|
|
7052
|
+
const seen = ctx.seen.get(schema);
|
|
7053
|
+
seen.ref = def.innerType;
|
|
7054
|
+
};
|
|
7055
|
+
const lazyProcessor = (schema, ctx, _json, params) => {
|
|
7056
|
+
const innerType = schema._zod.innerType;
|
|
7057
|
+
process$2(innerType, ctx, params);
|
|
7058
|
+
const seen = ctx.seen.get(schema);
|
|
7059
|
+
seen.ref = innerType;
|
|
7060
|
+
};
|
|
7061
|
+
const allProcessors = {
|
|
7062
|
+
string: stringProcessor,
|
|
7063
|
+
number: numberProcessor,
|
|
7064
|
+
boolean: booleanProcessor,
|
|
7065
|
+
bigint: bigintProcessor,
|
|
7066
|
+
symbol: symbolProcessor,
|
|
7067
|
+
null: nullProcessor,
|
|
7068
|
+
undefined: undefinedProcessor,
|
|
7069
|
+
void: voidProcessor,
|
|
7070
|
+
never: neverProcessor,
|
|
7071
|
+
any: anyProcessor,
|
|
7072
|
+
unknown: unknownProcessor,
|
|
7073
|
+
date: dateProcessor,
|
|
7074
|
+
enum: enumProcessor,
|
|
7075
|
+
literal: literalProcessor,
|
|
7076
|
+
nan: nanProcessor,
|
|
7077
|
+
template_literal: templateLiteralProcessor,
|
|
7078
|
+
file: fileProcessor,
|
|
7079
|
+
success: successProcessor,
|
|
7080
|
+
custom: customProcessor,
|
|
7081
|
+
function: functionProcessor,
|
|
7082
|
+
transform: transformProcessor,
|
|
7083
|
+
map: mapProcessor,
|
|
7084
|
+
set: setProcessor,
|
|
7085
|
+
array: arrayProcessor,
|
|
7086
|
+
object: objectProcessor,
|
|
7087
|
+
union: unionProcessor,
|
|
7088
|
+
intersection: intersectionProcessor,
|
|
7089
|
+
tuple: tupleProcessor,
|
|
7090
|
+
record: recordProcessor,
|
|
7091
|
+
nullable: nullableProcessor,
|
|
7092
|
+
nonoptional: nonoptionalProcessor,
|
|
7093
|
+
default: defaultProcessor,
|
|
7094
|
+
prefault: prefaultProcessor,
|
|
7095
|
+
catch: catchProcessor,
|
|
7096
|
+
pipe: pipeProcessor,
|
|
7097
|
+
readonly: readonlyProcessor,
|
|
7098
|
+
promise: promiseProcessor,
|
|
7099
|
+
optional: optionalProcessor,
|
|
7100
|
+
lazy: lazyProcessor
|
|
6567
7101
|
};
|
|
6568
|
-
function toJSONSchema(input,
|
|
6569
|
-
if (
|
|
6570
|
-
const
|
|
7102
|
+
function toJSONSchema(input, params) {
|
|
7103
|
+
if ("_idmap" in input) {
|
|
7104
|
+
const registry = input;
|
|
7105
|
+
const ctx = initializeContext({
|
|
7106
|
+
...params,
|
|
7107
|
+
processors: allProcessors
|
|
7108
|
+
});
|
|
6571
7109
|
const defs = {};
|
|
6572
|
-
for (const entry of
|
|
7110
|
+
for (const entry of registry._idmap.entries()) {
|
|
6573
7111
|
const [_, schema] = entry;
|
|
6574
|
-
|
|
7112
|
+
process$2(schema, ctx);
|
|
6575
7113
|
}
|
|
6576
7114
|
const schemas = {};
|
|
6577
|
-
|
|
6578
|
-
registry
|
|
6579
|
-
uri:
|
|
7115
|
+
ctx.external = {
|
|
7116
|
+
registry,
|
|
7117
|
+
uri: params?.uri,
|
|
6580
7118
|
defs
|
|
6581
7119
|
};
|
|
6582
|
-
for (const entry of
|
|
7120
|
+
for (const entry of registry._idmap.entries()) {
|
|
6583
7121
|
const [key, schema] = entry;
|
|
6584
|
-
|
|
6585
|
-
|
|
6586
|
-
external
|
|
6587
|
-
});
|
|
7122
|
+
extractDefs(ctx, schema);
|
|
7123
|
+
schemas[key] = finalize(ctx, schema);
|
|
6588
7124
|
}
|
|
6589
|
-
if (Object.keys(defs).length > 0) schemas.__shared = { [
|
|
7125
|
+
if (Object.keys(defs).length > 0) schemas.__shared = { [ctx.target === "draft-2020-12" ? "$defs" : "definitions"]: defs };
|
|
6590
7126
|
return { schemas };
|
|
6591
7127
|
}
|
|
6592
|
-
const
|
|
6593
|
-
|
|
6594
|
-
|
|
6595
|
-
}
|
|
6596
|
-
|
|
6597
|
-
|
|
6598
|
-
|
|
6599
|
-
ctx.seen.add(_schema);
|
|
6600
|
-
const def = _schema._zod.def;
|
|
6601
|
-
switch (def.type) {
|
|
6602
|
-
case "string":
|
|
6603
|
-
case "number":
|
|
6604
|
-
case "bigint":
|
|
6605
|
-
case "boolean":
|
|
6606
|
-
case "date":
|
|
6607
|
-
case "symbol":
|
|
6608
|
-
case "undefined":
|
|
6609
|
-
case "null":
|
|
6610
|
-
case "any":
|
|
6611
|
-
case "unknown":
|
|
6612
|
-
case "never":
|
|
6613
|
-
case "void":
|
|
6614
|
-
case "literal":
|
|
6615
|
-
case "enum":
|
|
6616
|
-
case "nan":
|
|
6617
|
-
case "file":
|
|
6618
|
-
case "template_literal": return false;
|
|
6619
|
-
case "array": return isTransforming(def.element, ctx);
|
|
6620
|
-
case "object":
|
|
6621
|
-
for (const key in def.shape) if (isTransforming(def.shape[key], ctx)) return true;
|
|
6622
|
-
return false;
|
|
6623
|
-
case "union":
|
|
6624
|
-
for (const option of def.options) if (isTransforming(option, ctx)) return true;
|
|
6625
|
-
return false;
|
|
6626
|
-
case "intersection": return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
|
|
6627
|
-
case "tuple":
|
|
6628
|
-
for (const item of def.items) if (isTransforming(item, ctx)) return true;
|
|
6629
|
-
if (def.rest && isTransforming(def.rest, ctx)) return true;
|
|
6630
|
-
return false;
|
|
6631
|
-
case "record": return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
6632
|
-
case "map": return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
6633
|
-
case "set": return isTransforming(def.valueType, ctx);
|
|
6634
|
-
case "promise":
|
|
6635
|
-
case "optional":
|
|
6636
|
-
case "nonoptional":
|
|
6637
|
-
case "nullable":
|
|
6638
|
-
case "readonly": return isTransforming(def.innerType, ctx);
|
|
6639
|
-
case "lazy": return isTransforming(def.getter(), ctx);
|
|
6640
|
-
case "default": return isTransforming(def.innerType, ctx);
|
|
6641
|
-
case "prefault": return isTransforming(def.innerType, ctx);
|
|
6642
|
-
case "custom": return false;
|
|
6643
|
-
case "transform": return true;
|
|
6644
|
-
case "pipe": return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
6645
|
-
case "success": return false;
|
|
6646
|
-
case "catch": return false;
|
|
6647
|
-
default:
|
|
6648
|
-
}
|
|
6649
|
-
throw new Error(`Unknown schema type: ${def.type}`);
|
|
7128
|
+
const ctx = initializeContext({
|
|
7129
|
+
...params,
|
|
7130
|
+
processors: allProcessors
|
|
7131
|
+
});
|
|
7132
|
+
process$2(input, ctx);
|
|
7133
|
+
extractDefs(ctx, input);
|
|
7134
|
+
return finalize(ctx, input);
|
|
6650
7135
|
}
|
|
6651
7136
|
|
|
6652
7137
|
//#endregion
|
|
@@ -6655,6 +7140,7 @@ const ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
|
|
|
6655
7140
|
if (!inst._zod) throw new Error("Uninitialized schema in ZodMiniType.");
|
|
6656
7141
|
$ZodType.init(inst, def);
|
|
6657
7142
|
inst.def = def;
|
|
7143
|
+
inst.type = def.type;
|
|
6658
7144
|
inst.parse = (data, params) => parse$1(inst, data, params, { callee: inst.parse });
|
|
6659
7145
|
inst.safeParse = (data, params) => safeParse$2(inst, data, params);
|
|
6660
7146
|
inst.parseAsync = async (data, params) => parseAsync$1(inst, data, params, { callee: inst.parseAsync });
|
|
@@ -6667,30 +7153,32 @@ const ZodMiniType = /* @__PURE__ */ $constructor("ZodMiniType", (inst, def) => {
|
|
|
6667
7153
|
def: { check: "custom" },
|
|
6668
7154
|
onattach: []
|
|
6669
7155
|
} } : ch)]
|
|
6670
|
-
});
|
|
7156
|
+
}, { parent: true });
|
|
6671
7157
|
};
|
|
7158
|
+
inst.with = inst.check;
|
|
6672
7159
|
inst.clone = (_def, params) => clone(inst, _def, params);
|
|
6673
7160
|
inst.brand = () => inst;
|
|
6674
7161
|
inst.register = ((reg, meta) => {
|
|
6675
7162
|
reg.add(inst, meta);
|
|
6676
7163
|
return inst;
|
|
6677
7164
|
});
|
|
7165
|
+
inst.apply = (fn) => fn(inst);
|
|
6678
7166
|
});
|
|
6679
7167
|
const ZodMiniObject = /* @__PURE__ */ $constructor("ZodMiniObject", (inst, def) => {
|
|
6680
7168
|
$ZodObject.init(inst, def);
|
|
6681
7169
|
ZodMiniType.init(inst, def);
|
|
6682
7170
|
defineLazy(inst, "shape", () => def.shape);
|
|
6683
7171
|
});
|
|
7172
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
6684
7173
|
function object$1(shape, params) {
|
|
6685
7174
|
return new ZodMiniObject({
|
|
6686
7175
|
type: "object",
|
|
6687
|
-
|
|
6688
|
-
assignProp(this, "shape", { ...shape });
|
|
6689
|
-
return this.shape;
|
|
6690
|
-
},
|
|
7176
|
+
shape: shape ?? {},
|
|
6691
7177
|
...normalizeParams(params)
|
|
6692
7178
|
});
|
|
6693
7179
|
}
|
|
7180
|
+
const describe$1 = describe$2;
|
|
7181
|
+
const meta$1 = meta$2;
|
|
6694
7182
|
|
|
6695
7183
|
//#endregion
|
|
6696
7184
|
//#region node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js
|
|
@@ -6847,8 +7335,14 @@ const initializer = (inst, issues) => {
|
|
|
6847
7335
|
Object.defineProperties(inst, {
|
|
6848
7336
|
format: { value: (mapper) => formatError(inst, mapper) },
|
|
6849
7337
|
flatten: { value: (mapper) => flattenError(inst, mapper) },
|
|
6850
|
-
addIssue: { value: (issue) =>
|
|
6851
|
-
|
|
7338
|
+
addIssue: { value: (issue) => {
|
|
7339
|
+
inst.issues.push(issue);
|
|
7340
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
7341
|
+
} },
|
|
7342
|
+
addIssues: { value: (issues) => {
|
|
7343
|
+
inst.issues.push(...issues);
|
|
7344
|
+
inst.message = JSON.stringify(inst.issues, jsonStringifyReplacer, 2);
|
|
7345
|
+
} },
|
|
6852
7346
|
isEmpty: { get() {
|
|
6853
7347
|
return inst.issues.length === 0;
|
|
6854
7348
|
} }
|
|
@@ -6863,23 +7357,35 @@ const parse = /* @__PURE__ */ _parse(ZodRealError);
|
|
|
6863
7357
|
const parseAsync = /* @__PURE__ */ _parseAsync(ZodRealError);
|
|
6864
7358
|
const safeParse = /* @__PURE__ */ _safeParse(ZodRealError);
|
|
6865
7359
|
const safeParseAsync = /* @__PURE__ */ _safeParseAsync(ZodRealError);
|
|
7360
|
+
const encode = /* @__PURE__ */ _encode(ZodRealError);
|
|
7361
|
+
const decode = /* @__PURE__ */ _decode(ZodRealError);
|
|
7362
|
+
const encodeAsync = /* @__PURE__ */ _encodeAsync(ZodRealError);
|
|
7363
|
+
const decodeAsync = /* @__PURE__ */ _decodeAsync(ZodRealError);
|
|
7364
|
+
const safeEncode = /* @__PURE__ */ _safeEncode(ZodRealError);
|
|
7365
|
+
const safeDecode = /* @__PURE__ */ _safeDecode(ZodRealError);
|
|
7366
|
+
const safeEncodeAsync = /* @__PURE__ */ _safeEncodeAsync(ZodRealError);
|
|
7367
|
+
const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
|
|
6866
7368
|
|
|
6867
7369
|
//#endregion
|
|
6868
7370
|
//#region node_modules/zod/v4/classic/schemas.js
|
|
6869
7371
|
const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
6870
7372
|
$ZodType.init(inst, def);
|
|
7373
|
+
Object.assign(inst["~standard"], { jsonSchema: {
|
|
7374
|
+
input: createStandardJSONSchemaMethod(inst, "input"),
|
|
7375
|
+
output: createStandardJSONSchemaMethod(inst, "output")
|
|
7376
|
+
} });
|
|
7377
|
+
inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
|
|
6871
7378
|
inst.def = def;
|
|
7379
|
+
inst.type = def.type;
|
|
6872
7380
|
Object.defineProperty(inst, "_def", { value: def });
|
|
6873
7381
|
inst.check = (...checks) => {
|
|
6874
|
-
return inst.clone({
|
|
6875
|
-
|
|
6876
|
-
|
|
6877
|
-
|
|
6878
|
-
|
|
6879
|
-
onattach: []
|
|
6880
|
-
} } : ch)]
|
|
6881
|
-
});
|
|
7382
|
+
return inst.clone(mergeDefs(def, { checks: [...def.checks ?? [], ...checks.map((ch) => typeof ch === "function" ? { _zod: {
|
|
7383
|
+
check: ch,
|
|
7384
|
+
def: { check: "custom" },
|
|
7385
|
+
onattach: []
|
|
7386
|
+
} } : ch)] }), { parent: true });
|
|
6882
7387
|
};
|
|
7388
|
+
inst.with = inst.check;
|
|
6883
7389
|
inst.clone = (def, params) => clone(inst, def, params);
|
|
6884
7390
|
inst.brand = () => inst;
|
|
6885
7391
|
inst.register = ((reg, meta) => {
|
|
@@ -6891,10 +7397,19 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
6891
7397
|
inst.parseAsync = async (data, params) => parseAsync(inst, data, params, { callee: inst.parseAsync });
|
|
6892
7398
|
inst.safeParseAsync = async (data, params) => safeParseAsync(inst, data, params);
|
|
6893
7399
|
inst.spa = inst.safeParseAsync;
|
|
7400
|
+
inst.encode = (data, params) => encode(inst, data, params);
|
|
7401
|
+
inst.decode = (data, params) => decode(inst, data, params);
|
|
7402
|
+
inst.encodeAsync = async (data, params) => encodeAsync(inst, data, params);
|
|
7403
|
+
inst.decodeAsync = async (data, params) => decodeAsync(inst, data, params);
|
|
7404
|
+
inst.safeEncode = (data, params) => safeEncode(inst, data, params);
|
|
7405
|
+
inst.safeDecode = (data, params) => safeDecode(inst, data, params);
|
|
7406
|
+
inst.safeEncodeAsync = async (data, params) => safeEncodeAsync(inst, data, params);
|
|
7407
|
+
inst.safeDecodeAsync = async (data, params) => safeDecodeAsync(inst, data, params);
|
|
6894
7408
|
inst.refine = (check, params) => inst.check(refine(check, params));
|
|
6895
7409
|
inst.superRefine = (refinement) => inst.check(superRefine(refinement));
|
|
6896
7410
|
inst.overwrite = (fn) => inst.check(_overwrite(fn));
|
|
6897
7411
|
inst.optional = () => optional(inst);
|
|
7412
|
+
inst.exactOptional = () => exactOptional(inst);
|
|
6898
7413
|
inst.nullable = () => nullable(inst);
|
|
6899
7414
|
inst.nullish = () => optional(nullable(inst));
|
|
6900
7415
|
inst.nonoptional = (params) => nonoptional(inst, params);
|
|
@@ -6926,12 +7441,14 @@ const ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
6926
7441
|
};
|
|
6927
7442
|
inst.isOptional = () => inst.safeParse(void 0).success;
|
|
6928
7443
|
inst.isNullable = () => inst.safeParse(null).success;
|
|
7444
|
+
inst.apply = (fn) => fn(inst);
|
|
6929
7445
|
return inst;
|
|
6930
7446
|
});
|
|
6931
7447
|
/** @internal */
|
|
6932
7448
|
const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
6933
7449
|
$ZodString.init(inst, def);
|
|
6934
7450
|
ZodType.init(inst, def);
|
|
7451
|
+
inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json, params);
|
|
6935
7452
|
const bag = inst._zod.bag;
|
|
6936
7453
|
inst.format = bag.format ?? null;
|
|
6937
7454
|
inst.minLength = bag.minimum ?? null;
|
|
@@ -6950,6 +7467,7 @@ const _ZodString = /* @__PURE__ */ $constructor("_ZodString", (inst, def) => {
|
|
|
6950
7467
|
inst.normalize = (...args) => inst.check(_normalize(...args));
|
|
6951
7468
|
inst.toLowerCase = () => inst.check(_toLowerCase());
|
|
6952
7469
|
inst.toUpperCase = () => inst.check(_toUpperCase());
|
|
7470
|
+
inst.slugify = () => inst.check(_slugify());
|
|
6953
7471
|
});
|
|
6954
7472
|
const ZodString = /* @__PURE__ */ $constructor("ZodString", (inst, def) => {
|
|
6955
7473
|
$ZodString.init(inst, def);
|
|
@@ -7068,6 +7586,7 @@ const ZodJWT = /* @__PURE__ */ $constructor("ZodJWT", (inst, def) => {
|
|
|
7068
7586
|
const ZodNumber = /* @__PURE__ */ $constructor("ZodNumber", (inst, def) => {
|
|
7069
7587
|
$ZodNumber.init(inst, def);
|
|
7070
7588
|
ZodType.init(inst, def);
|
|
7589
|
+
inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json, params);
|
|
7071
7590
|
inst.gt = (value, params) => inst.check(_gt(value, params));
|
|
7072
7591
|
inst.gte = (value, params) => inst.check(_gte(value, params));
|
|
7073
7592
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
@@ -7103,6 +7622,7 @@ function int(params) {
|
|
|
7103
7622
|
const ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
7104
7623
|
$ZodBoolean.init(inst, def);
|
|
7105
7624
|
ZodType.init(inst, def);
|
|
7625
|
+
inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json, params);
|
|
7106
7626
|
});
|
|
7107
7627
|
function boolean(params) {
|
|
7108
7628
|
return _boolean(ZodBoolean, params);
|
|
@@ -7110,6 +7630,7 @@ function boolean(params) {
|
|
|
7110
7630
|
const ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
7111
7631
|
$ZodNull.init(inst, def);
|
|
7112
7632
|
ZodType.init(inst, def);
|
|
7633
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nullProcessor(inst, ctx, json, params);
|
|
7113
7634
|
});
|
|
7114
7635
|
function _null(params) {
|
|
7115
7636
|
return _null$1(ZodNull, params);
|
|
@@ -7117,6 +7638,7 @@ function _null(params) {
|
|
|
7117
7638
|
const ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
7118
7639
|
$ZodUnknown.init(inst, def);
|
|
7119
7640
|
ZodType.init(inst, def);
|
|
7641
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor(inst, ctx, json, params);
|
|
7120
7642
|
});
|
|
7121
7643
|
function unknown() {
|
|
7122
7644
|
return _unknown(ZodUnknown);
|
|
@@ -7124,6 +7646,7 @@ function unknown() {
|
|
|
7124
7646
|
const ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
7125
7647
|
$ZodNever.init(inst, def);
|
|
7126
7648
|
ZodType.init(inst, def);
|
|
7649
|
+
inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json, params);
|
|
7127
7650
|
});
|
|
7128
7651
|
function never(params) {
|
|
7129
7652
|
return _never(ZodNever, params);
|
|
@@ -7131,6 +7654,7 @@ function never(params) {
|
|
|
7131
7654
|
const ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
7132
7655
|
$ZodArray.init(inst, def);
|
|
7133
7656
|
ZodType.init(inst, def);
|
|
7657
|
+
inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
|
|
7134
7658
|
inst.element = def.element;
|
|
7135
7659
|
inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
|
|
7136
7660
|
inst.nonempty = (params) => inst.check(_minLength(1, params));
|
|
@@ -7142,9 +7666,12 @@ function array(element, params) {
|
|
|
7142
7666
|
return _array(ZodArray, element, params);
|
|
7143
7667
|
}
|
|
7144
7668
|
const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
7145
|
-
$
|
|
7669
|
+
$ZodObjectJIT.init(inst, def);
|
|
7146
7670
|
ZodType.init(inst, def);
|
|
7147
|
-
|
|
7671
|
+
inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
|
|
7672
|
+
defineLazy(inst, "shape", () => {
|
|
7673
|
+
return def.shape;
|
|
7674
|
+
});
|
|
7148
7675
|
inst.keyof = () => _enum(Object.keys(inst._zod.def.shape));
|
|
7149
7676
|
inst.catchall = (catchall) => inst.clone({
|
|
7150
7677
|
...inst._zod.def,
|
|
@@ -7169,6 +7696,9 @@ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
7169
7696
|
inst.extend = (incoming) => {
|
|
7170
7697
|
return extend(inst, incoming);
|
|
7171
7698
|
};
|
|
7699
|
+
inst.safeExtend = (incoming) => {
|
|
7700
|
+
return safeExtend(inst, incoming);
|
|
7701
|
+
};
|
|
7172
7702
|
inst.merge = (other) => merge(inst, other);
|
|
7173
7703
|
inst.pick = (mask) => pick(inst, mask);
|
|
7174
7704
|
inst.omit = (mask) => omit(inst, mask);
|
|
@@ -7178,20 +7708,14 @@ const ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
7178
7708
|
function object(shape, params) {
|
|
7179
7709
|
return new ZodObject({
|
|
7180
7710
|
type: "object",
|
|
7181
|
-
|
|
7182
|
-
assignProp(this, "shape", { ...shape });
|
|
7183
|
-
return this.shape;
|
|
7184
|
-
},
|
|
7711
|
+
shape: shape ?? {},
|
|
7185
7712
|
...normalizeParams(params)
|
|
7186
7713
|
});
|
|
7187
7714
|
}
|
|
7188
7715
|
function looseObject(shape, params) {
|
|
7189
7716
|
return new ZodObject({
|
|
7190
7717
|
type: "object",
|
|
7191
|
-
|
|
7192
|
-
assignProp(this, "shape", { ...shape });
|
|
7193
|
-
return this.shape;
|
|
7194
|
-
},
|
|
7718
|
+
shape,
|
|
7195
7719
|
catchall: unknown(),
|
|
7196
7720
|
...normalizeParams(params)
|
|
7197
7721
|
});
|
|
@@ -7199,6 +7723,7 @@ function looseObject(shape, params) {
|
|
|
7199
7723
|
const ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
7200
7724
|
$ZodUnion.init(inst, def);
|
|
7201
7725
|
ZodType.init(inst, def);
|
|
7726
|
+
inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
|
|
7202
7727
|
inst.options = def.options;
|
|
7203
7728
|
});
|
|
7204
7729
|
function union(options, params) {
|
|
@@ -7223,6 +7748,7 @@ function discriminatedUnion(discriminator, options, params) {
|
|
|
7223
7748
|
const ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
7224
7749
|
$ZodIntersection.init(inst, def);
|
|
7225
7750
|
ZodType.init(inst, def);
|
|
7751
|
+
inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
|
|
7226
7752
|
});
|
|
7227
7753
|
function intersection(left, right) {
|
|
7228
7754
|
return new ZodIntersection({
|
|
@@ -7234,6 +7760,7 @@ function intersection(left, right) {
|
|
|
7234
7760
|
const ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
7235
7761
|
$ZodRecord.init(inst, def);
|
|
7236
7762
|
ZodType.init(inst, def);
|
|
7763
|
+
inst._zod.processJSONSchema = (ctx, json, params) => recordProcessor(inst, ctx, json, params);
|
|
7237
7764
|
inst.keyType = def.keyType;
|
|
7238
7765
|
inst.valueType = def.valueType;
|
|
7239
7766
|
});
|
|
@@ -7248,6 +7775,7 @@ function record(keyType, valueType, params) {
|
|
|
7248
7775
|
const ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
7249
7776
|
$ZodEnum.init(inst, def);
|
|
7250
7777
|
ZodType.init(inst, def);
|
|
7778
|
+
inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json, params);
|
|
7251
7779
|
inst.enum = def.entries;
|
|
7252
7780
|
inst.options = Object.values(def.entries);
|
|
7253
7781
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -7284,6 +7812,7 @@ function _enum(values, params) {
|
|
|
7284
7812
|
const ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
7285
7813
|
$ZodLiteral.init(inst, def);
|
|
7286
7814
|
ZodType.init(inst, def);
|
|
7815
|
+
inst._zod.processJSONSchema = (ctx, json, params) => literalProcessor(inst, ctx, json, params);
|
|
7287
7816
|
inst.values = new Set(def.values);
|
|
7288
7817
|
Object.defineProperty(inst, "value", { get() {
|
|
7289
7818
|
if (def.values.length > 1) throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");
|
|
@@ -7300,16 +7829,17 @@ function literal(value, params) {
|
|
|
7300
7829
|
const ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
7301
7830
|
$ZodTransform.init(inst, def);
|
|
7302
7831
|
ZodType.init(inst, def);
|
|
7832
|
+
inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx, json, params);
|
|
7303
7833
|
inst._zod.parse = (payload, _ctx) => {
|
|
7304
|
-
|
|
7305
|
-
|
|
7834
|
+
if (_ctx.direction === "backward") throw new $ZodEncodeError(inst.constructor.name);
|
|
7835
|
+
payload.addIssue = (issue$1) => {
|
|
7836
|
+
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, def));
|
|
7306
7837
|
else {
|
|
7307
|
-
const _issue = issue$
|
|
7838
|
+
const _issue = issue$1;
|
|
7308
7839
|
if (_issue.fatal) _issue.continue = false;
|
|
7309
7840
|
_issue.code ?? (_issue.code = "custom");
|
|
7310
7841
|
_issue.input ?? (_issue.input = payload.value);
|
|
7311
7842
|
_issue.inst ?? (_issue.inst = inst);
|
|
7312
|
-
_issue.continue ?? (_issue.continue = true);
|
|
7313
7843
|
payload.issues.push(issue(_issue));
|
|
7314
7844
|
}
|
|
7315
7845
|
};
|
|
@@ -7331,6 +7861,7 @@ function transform(fn) {
|
|
|
7331
7861
|
const ZodOptional$1 = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
7332
7862
|
$ZodOptional.init(inst, def);
|
|
7333
7863
|
ZodType.init(inst, def);
|
|
7864
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
7334
7865
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
7335
7866
|
});
|
|
7336
7867
|
function optional(innerType) {
|
|
@@ -7339,9 +7870,22 @@ function optional(innerType) {
|
|
|
7339
7870
|
innerType
|
|
7340
7871
|
});
|
|
7341
7872
|
}
|
|
7873
|
+
const ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
7874
|
+
$ZodExactOptional.init(inst, def);
|
|
7875
|
+
ZodType.init(inst, def);
|
|
7876
|
+
inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
|
|
7877
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
7878
|
+
});
|
|
7879
|
+
function exactOptional(innerType) {
|
|
7880
|
+
return new ZodExactOptional({
|
|
7881
|
+
type: "optional",
|
|
7882
|
+
innerType
|
|
7883
|
+
});
|
|
7884
|
+
}
|
|
7342
7885
|
const ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
7343
7886
|
$ZodNullable.init(inst, def);
|
|
7344
7887
|
ZodType.init(inst, def);
|
|
7888
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
|
|
7345
7889
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
7346
7890
|
});
|
|
7347
7891
|
function nullable(innerType) {
|
|
@@ -7353,6 +7897,7 @@ function nullable(innerType) {
|
|
|
7353
7897
|
const ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
7354
7898
|
$ZodDefault.init(inst, def);
|
|
7355
7899
|
ZodType.init(inst, def);
|
|
7900
|
+
inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
|
|
7356
7901
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
7357
7902
|
inst.removeDefault = inst.unwrap;
|
|
7358
7903
|
});
|
|
@@ -7361,13 +7906,14 @@ function _default(innerType, defaultValue) {
|
|
|
7361
7906
|
type: "default",
|
|
7362
7907
|
innerType,
|
|
7363
7908
|
get defaultValue() {
|
|
7364
|
-
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
7909
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
7365
7910
|
}
|
|
7366
7911
|
});
|
|
7367
7912
|
}
|
|
7368
7913
|
const ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
7369
7914
|
$ZodPrefault.init(inst, def);
|
|
7370
7915
|
ZodType.init(inst, def);
|
|
7916
|
+
inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
|
|
7371
7917
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
7372
7918
|
});
|
|
7373
7919
|
function prefault(innerType, defaultValue) {
|
|
@@ -7375,13 +7921,14 @@ function prefault(innerType, defaultValue) {
|
|
|
7375
7921
|
type: "prefault",
|
|
7376
7922
|
innerType,
|
|
7377
7923
|
get defaultValue() {
|
|
7378
|
-
return typeof defaultValue === "function" ? defaultValue() : defaultValue;
|
|
7924
|
+
return typeof defaultValue === "function" ? defaultValue() : shallowClone(defaultValue);
|
|
7379
7925
|
}
|
|
7380
7926
|
});
|
|
7381
7927
|
}
|
|
7382
7928
|
const ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
7383
7929
|
$ZodNonOptional.init(inst, def);
|
|
7384
7930
|
ZodType.init(inst, def);
|
|
7931
|
+
inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
|
|
7385
7932
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
7386
7933
|
});
|
|
7387
7934
|
function nonoptional(innerType, params) {
|
|
@@ -7394,6 +7941,7 @@ function nonoptional(innerType, params) {
|
|
|
7394
7941
|
const ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
7395
7942
|
$ZodCatch.init(inst, def);
|
|
7396
7943
|
ZodType.init(inst, def);
|
|
7944
|
+
inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
|
|
7397
7945
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
7398
7946
|
inst.removeCatch = inst.unwrap;
|
|
7399
7947
|
});
|
|
@@ -7407,6 +7955,7 @@ function _catch(innerType, catchValue) {
|
|
|
7407
7955
|
const ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
7408
7956
|
$ZodPipe.init(inst, def);
|
|
7409
7957
|
ZodType.init(inst, def);
|
|
7958
|
+
inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
|
|
7410
7959
|
inst.in = def.in;
|
|
7411
7960
|
inst.out = def.out;
|
|
7412
7961
|
});
|
|
@@ -7420,6 +7969,8 @@ function pipe(in_, out) {
|
|
|
7420
7969
|
const ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
7421
7970
|
$ZodReadonly.init(inst, def);
|
|
7422
7971
|
ZodType.init(inst, def);
|
|
7972
|
+
inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
|
|
7973
|
+
inst.unwrap = () => inst._zod.def.innerType;
|
|
7423
7974
|
});
|
|
7424
7975
|
function readonly(innerType) {
|
|
7425
7976
|
return new ZodReadonly({
|
|
@@ -7430,12 +7981,8 @@ function readonly(innerType) {
|
|
|
7430
7981
|
const ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
7431
7982
|
$ZodCustom.init(inst, def);
|
|
7432
7983
|
ZodType.init(inst, def);
|
|
7984
|
+
inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx, json, params);
|
|
7433
7985
|
});
|
|
7434
|
-
function check(fn) {
|
|
7435
|
-
const ch = new $ZodCheck({ check: "custom" });
|
|
7436
|
-
ch._zod.check = fn;
|
|
7437
|
-
return ch;
|
|
7438
|
-
}
|
|
7439
7986
|
function custom(fn, _params) {
|
|
7440
7987
|
return _custom(ZodCustom, fn ?? (() => true), _params);
|
|
7441
7988
|
}
|
|
@@ -7443,23 +7990,10 @@ function refine(fn, _params = {}) {
|
|
|
7443
7990
|
return _refine(ZodCustom, fn, _params);
|
|
7444
7991
|
}
|
|
7445
7992
|
function superRefine(fn) {
|
|
7446
|
-
|
|
7447
|
-
payload.addIssue = (issue$1) => {
|
|
7448
|
-
if (typeof issue$1 === "string") payload.issues.push(issue(issue$1, payload.value, ch._zod.def));
|
|
7449
|
-
else {
|
|
7450
|
-
const _issue = issue$1;
|
|
7451
|
-
if (_issue.fatal) _issue.continue = false;
|
|
7452
|
-
_issue.code ?? (_issue.code = "custom");
|
|
7453
|
-
_issue.input ?? (_issue.input = payload.value);
|
|
7454
|
-
_issue.inst ?? (_issue.inst = ch);
|
|
7455
|
-
_issue.continue ?? (_issue.continue = !ch._zod.def.abort);
|
|
7456
|
-
payload.issues.push(issue(_issue));
|
|
7457
|
-
}
|
|
7458
|
-
};
|
|
7459
|
-
return fn(payload.value, payload);
|
|
7460
|
-
});
|
|
7461
|
-
return ch;
|
|
7993
|
+
return _superRefine(fn);
|
|
7462
7994
|
}
|
|
7995
|
+
const describe = describe$2;
|
|
7996
|
+
const meta = meta$2;
|
|
7463
7997
|
function preprocess(fn, schema) {
|
|
7464
7998
|
return pipe(transform(fn), schema);
|
|
7465
7999
|
}
|
|
@@ -7494,7 +8028,7 @@ const CursorSchema = string();
|
|
|
7494
8028
|
* Task creation parameters, used to ask that the server create a task to represent a request.
|
|
7495
8029
|
*/
|
|
7496
8030
|
const TaskCreationParamsSchema = looseObject({
|
|
7497
|
-
ttl:
|
|
8031
|
+
ttl: number().optional(),
|
|
7498
8032
|
pollInterval: number().optional()
|
|
7499
8033
|
});
|
|
7500
8034
|
const TaskMetadataSchema = object({ ttl: number().optional() });
|
|
@@ -7700,7 +8234,8 @@ const ClientCapabilitiesSchema = object({
|
|
|
7700
8234
|
}).optional(),
|
|
7701
8235
|
elicitation: ElicitationCapabilitySchema.optional(),
|
|
7702
8236
|
roots: object({ listChanged: boolean().optional() }).optional(),
|
|
7703
|
-
tasks: ClientTasksCapabilitySchema.optional()
|
|
8237
|
+
tasks: ClientTasksCapabilitySchema.optional(),
|
|
8238
|
+
extensions: record(string(), AssertObjectSchema).optional()
|
|
7704
8239
|
});
|
|
7705
8240
|
const InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
7706
8241
|
protocolVersion: string(),
|
|
@@ -7727,7 +8262,8 @@ const ServerCapabilitiesSchema = object({
|
|
|
7727
8262
|
listChanged: boolean().optional()
|
|
7728
8263
|
}).optional(),
|
|
7729
8264
|
tools: object({ listChanged: boolean().optional() }).optional(),
|
|
7730
|
-
tasks: ServerTasksCapabilitySchema.optional()
|
|
8265
|
+
tasks: ServerTasksCapabilitySchema.optional(),
|
|
8266
|
+
extensions: record(string(), AssertObjectSchema).optional()
|
|
7731
8267
|
});
|
|
7732
8268
|
/**
|
|
7733
8269
|
* After receiving an initialize request from the client, the server sends this response.
|
|
@@ -7899,6 +8435,7 @@ const ResourceSchema = object({
|
|
|
7899
8435
|
uri: string(),
|
|
7900
8436
|
description: optional(string()),
|
|
7901
8437
|
mimeType: optional(string()),
|
|
8438
|
+
size: optional(number()),
|
|
7902
8439
|
annotations: AnnotationsSchema.optional(),
|
|
7903
8440
|
_meta: optional(looseObject({}))
|
|
7904
8441
|
});
|
|
@@ -10056,6 +10593,8 @@ var Protocol = class {
|
|
|
10056
10593
|
this._progressHandlers.clear();
|
|
10057
10594
|
this._taskProgressTokens.clear();
|
|
10058
10595
|
this._pendingDebouncedNotifications.clear();
|
|
10596
|
+
for (const info of this._timeoutInfo.values()) clearTimeout(info.timeoutId);
|
|
10597
|
+
this._timeoutInfo.clear();
|
|
10059
10598
|
for (const controller of this._requestHandlerAbortControllers.values()) controller.abort();
|
|
10060
10599
|
this._requestHandlerAbortControllers.clear();
|
|
10061
10600
|
const error = McpError.fromError(ErrorCode.ConnectionClosed, "Connection closed");
|
|
@@ -10159,7 +10698,7 @@ var Protocol = class {
|
|
|
10159
10698
|
}, capturedTransport?.sessionId);
|
|
10160
10699
|
else await capturedTransport?.send(errorResponse);
|
|
10161
10700
|
}).catch((error) => this._onerror(/* @__PURE__ */ new Error(`Failed to send response: ${error}`))).finally(() => {
|
|
10162
|
-
this._requestHandlerAbortControllers.delete(request.id);
|
|
10701
|
+
if (this._requestHandlerAbortControllers.get(request.id) === abortController) this._requestHandlerAbortControllers.delete(request.id);
|
|
10163
10702
|
});
|
|
10164
10703
|
}
|
|
10165
10704
|
_onprogress(notification) {
|
|
@@ -18187,7 +18726,10 @@ var McpServer = class {
|
|
|
18187
18726
|
if (isZodRawShapeCompat(firstArg)) {
|
|
18188
18727
|
inputSchema = rest.shift();
|
|
18189
18728
|
if (rest.length > 1 && typeof rest[0] === "object" && rest[0] !== null && !isZodRawShapeCompat(rest[0])) annotations = rest.shift();
|
|
18190
|
-
} else if (typeof firstArg === "object" && firstArg !== null)
|
|
18729
|
+
} else if (typeof firstArg === "object" && firstArg !== null) {
|
|
18730
|
+
if (Object.values(firstArg).some((v) => typeof v === "object" && v !== null)) throw new Error(`Tool ${name} expected a Zod schema or ToolAnnotations, but received an unrecognized object`);
|
|
18731
|
+
annotations = rest.shift();
|
|
18732
|
+
}
|
|
18191
18733
|
}
|
|
18192
18734
|
const callback = rest[0];
|
|
18193
18735
|
return this._createRegisteredTool(name, void 0, description, inputSchema, outputSchema, annotations, { taskSupport: "forbidden" }, void 0, callback);
|
|
@@ -18297,11 +18839,12 @@ function isZodRawShapeCompat(obj) {
|
|
|
18297
18839
|
}
|
|
18298
18840
|
/**
|
|
18299
18841
|
* Converts a provided Zod schema to a Zod object if it is a ZodRawShapeCompat,
|
|
18300
|
-
* otherwise returns the schema as is.
|
|
18842
|
+
* otherwise returns the schema as is. Throws if the value is not a valid Zod schema.
|
|
18301
18843
|
*/
|
|
18302
18844
|
function getZodSchemaObject(schema) {
|
|
18303
18845
|
if (!schema) return;
|
|
18304
18846
|
if (isZodRawShapeCompat(schema)) return objectFromShape(schema);
|
|
18847
|
+
if (!isZodSchemaInstance(schema)) throw new Error("inputSchema must be a Zod schema or raw shape, received an unrecognized object");
|
|
18305
18848
|
return schema;
|
|
18306
18849
|
}
|
|
18307
18850
|
function promptArgumentsFromSchema(schema) {
|