@kevisual/router 0.0.38 → 0.0.39

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.
@@ -579,8 +579,8 @@ class QueryRouter {
579
579
  setContext(ctx) {
580
580
  this.context = ctx;
581
581
  }
582
- getList(filter) {
583
- return this.routes.filter(filter || (() => true)).map((r) => {
582
+ getList() {
583
+ return this.routes.map((r) => {
584
584
  return pick$1(r, pickValue);
585
585
  });
586
586
  }
@@ -1867,8 +1867,8 @@ class Doc {
1867
1867
 
1868
1868
  const version = {
1869
1869
  major: 4,
1870
- minor: 2,
1871
- patch: 1,
1870
+ minor: 1,
1871
+ patch: 13,
1872
1872
  };
1873
1873
 
1874
1874
  const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
@@ -1938,6 +1938,16 @@ const $ZodType = /*@__PURE__*/ $constructor("$ZodType", (inst, def) => {
1938
1938
  }
1939
1939
  return payload;
1940
1940
  };
1941
+ // const handleChecksResult = (
1942
+ // checkResult: ParsePayload,
1943
+ // originalResult: ParsePayload,
1944
+ // ctx: ParseContextInternal
1945
+ // ): util.MaybeAsync<ParsePayload> => {
1946
+ // // if the checks mutated the value && there are no issues, re-parse the result
1947
+ // if (checkResult.value !== originalResult.value && !checkResult.issues.length)
1948
+ // return inst._zod.parse(checkResult, ctx);
1949
+ // return originalResult;
1950
+ // };
1941
1951
  const handleCanaryResult = (canary, payload, ctx) => {
1942
1952
  // abort if the canary is aborted
1943
1953
  if (aborted(canary)) {
@@ -3575,659 +3585,6 @@ function _check(fn, params) {
3575
3585
  return ch;
3576
3586
  }
3577
3587
 
3578
- // function initializeContext<T extends schemas.$ZodType>(inputs: JSONSchemaGeneratorParams<T>): ToJSONSchemaContext<T> {
3579
- // return {
3580
- // processor: inputs.processor,
3581
- // metadataRegistry: inputs.metadata ?? globalRegistry,
3582
- // target: inputs.target ?? "draft-2020-12",
3583
- // unrepresentable: inputs.unrepresentable ?? "throw",
3584
- // };
3585
- // }
3586
- function initializeContext(params) {
3587
- // Normalize target: convert old non-hyphenated versions to hyphenated versions
3588
- let target = params?.target ?? "draft-2020-12";
3589
- if (target === "draft-4")
3590
- target = "draft-04";
3591
- if (target === "draft-7")
3592
- target = "draft-07";
3593
- return {
3594
- processors: params.processors ?? {},
3595
- metadataRegistry: params?.metadata ?? globalRegistry,
3596
- target,
3597
- unrepresentable: params?.unrepresentable ?? "throw",
3598
- override: params?.override ?? (() => { }),
3599
- io: params?.io ?? "output",
3600
- counter: 0,
3601
- seen: new Map(),
3602
- cycles: params?.cycles ?? "ref",
3603
- reused: params?.reused ?? "inline",
3604
- external: params?.external ?? undefined,
3605
- };
3606
- }
3607
- function process(schema, ctx, _params = { path: [], schemaPath: [] }) {
3608
- var _a;
3609
- const def = schema._zod.def;
3610
- // check for schema in seens
3611
- const seen = ctx.seen.get(schema);
3612
- if (seen) {
3613
- seen.count++;
3614
- // check if cycle
3615
- const isCycle = _params.schemaPath.includes(schema);
3616
- if (isCycle) {
3617
- seen.cycle = _params.path;
3618
- }
3619
- return seen.schema;
3620
- }
3621
- // initialize
3622
- const result = { schema: {}, count: 1, cycle: undefined, path: _params.path };
3623
- ctx.seen.set(schema, result);
3624
- // custom method overrides default behavior
3625
- const overrideSchema = schema._zod.toJSONSchema?.();
3626
- if (overrideSchema) {
3627
- result.schema = overrideSchema;
3628
- }
3629
- else {
3630
- const params = {
3631
- ..._params,
3632
- schemaPath: [..._params.schemaPath, schema],
3633
- path: _params.path,
3634
- };
3635
- const parent = schema._zod.parent;
3636
- if (parent) {
3637
- // schema was cloned from another schema
3638
- result.ref = parent;
3639
- process(parent, ctx, params);
3640
- ctx.seen.get(parent).isParent = true;
3641
- }
3642
- else if (schema._zod.processJSONSchema) {
3643
- schema._zod.processJSONSchema(ctx, result.schema, params);
3644
- }
3645
- else {
3646
- const _json = result.schema;
3647
- const processor = ctx.processors[def.type];
3648
- if (!processor) {
3649
- throw new Error(`[toJSONSchema]: Non-representable type encountered: ${def.type}`);
3650
- }
3651
- processor(schema, ctx, _json, params);
3652
- }
3653
- }
3654
- // metadata
3655
- const meta = ctx.metadataRegistry.get(schema);
3656
- if (meta)
3657
- Object.assign(result.schema, meta);
3658
- if (ctx.io === "input" && isTransforming(schema)) {
3659
- // examples/defaults only apply to output type of pipe
3660
- delete result.schema.examples;
3661
- delete result.schema.default;
3662
- }
3663
- // set prefault as default
3664
- if (ctx.io === "input" && result.schema._prefault)
3665
- (_a = result.schema).default ?? (_a.default = result.schema._prefault);
3666
- delete result.schema._prefault;
3667
- // pulling fresh from ctx.seen in case it was overwritten
3668
- const _result = ctx.seen.get(schema);
3669
- return _result.schema;
3670
- }
3671
- function extractDefs(ctx, schema
3672
- // params: EmitParams
3673
- ) {
3674
- // iterate over seen map;
3675
- const root = ctx.seen.get(schema);
3676
- if (!root)
3677
- throw new Error("Unprocessed schema. This is a bug in Zod.");
3678
- // returns a ref to the schema
3679
- // defId will be empty if the ref points to an external schema (or #)
3680
- const makeURI = (entry) => {
3681
- // comparing the seen objects because sometimes
3682
- // multiple schemas map to the same seen object.
3683
- // e.g. lazy
3684
- // external is configured
3685
- const defsSegment = ctx.target === "draft-2020-12" ? "$defs" : "definitions";
3686
- if (ctx.external) {
3687
- const externalId = ctx.external.registry.get(entry[0])?.id; // ?? "__shared";// `__schema${ctx.counter++}`;
3688
- // check if schema is in the external registry
3689
- const uriGenerator = ctx.external.uri ?? ((id) => id);
3690
- if (externalId) {
3691
- return { ref: uriGenerator(externalId) };
3692
- }
3693
- // otherwise, add to __shared
3694
- const id = entry[1].defId ?? entry[1].schema.id ?? `schema${ctx.counter++}`;
3695
- entry[1].defId = id; // set defId so it will be reused if needed
3696
- return { defId: id, ref: `${uriGenerator("__shared")}#/${defsSegment}/${id}` };
3697
- }
3698
- if (entry[1] === root) {
3699
- return { ref: "#" };
3700
- }
3701
- // self-contained schema
3702
- const uriPrefix = `#`;
3703
- const defUriPrefix = `${uriPrefix}/${defsSegment}/`;
3704
- const defId = entry[1].schema.id ?? `__schema${ctx.counter++}`;
3705
- return { defId, ref: defUriPrefix + defId };
3706
- };
3707
- // stored cached version in `def` property
3708
- // remove all properties, set $ref
3709
- const extractToDef = (entry) => {
3710
- // if the schema is already a reference, do not extract it
3711
- if (entry[1].schema.$ref) {
3712
- return;
3713
- }
3714
- const seen = entry[1];
3715
- const { ref, defId } = makeURI(entry);
3716
- seen.def = { ...seen.schema };
3717
- // defId won't be set if the schema is a reference to an external schema
3718
- // or if the schema is the root schema
3719
- if (defId)
3720
- seen.defId = defId;
3721
- // wipe away all properties except $ref
3722
- const schema = seen.schema;
3723
- for (const key in schema) {
3724
- delete schema[key];
3725
- }
3726
- schema.$ref = ref;
3727
- };
3728
- // throw on cycles
3729
- // break cycles
3730
- if (ctx.cycles === "throw") {
3731
- for (const entry of ctx.seen.entries()) {
3732
- const seen = entry[1];
3733
- if (seen.cycle) {
3734
- throw new Error("Cycle detected: " +
3735
- `#/${seen.cycle?.join("/")}/<root>` +
3736
- '\n\nSet the `cycles` parameter to `"ref"` to resolve cyclical schemas with defs.');
3737
- }
3738
- }
3739
- }
3740
- // extract schemas into $defs
3741
- for (const entry of ctx.seen.entries()) {
3742
- const seen = entry[1];
3743
- // convert root schema to # $ref
3744
- if (schema === entry[0]) {
3745
- extractToDef(entry); // this has special handling for the root schema
3746
- continue;
3747
- }
3748
- // extract schemas that are in the external registry
3749
- if (ctx.external) {
3750
- const ext = ctx.external.registry.get(entry[0])?.id;
3751
- if (schema !== entry[0] && ext) {
3752
- extractToDef(entry);
3753
- continue;
3754
- }
3755
- }
3756
- // extract schemas with `id` meta
3757
- const id = ctx.metadataRegistry.get(entry[0])?.id;
3758
- if (id) {
3759
- extractToDef(entry);
3760
- continue;
3761
- }
3762
- // break cycles
3763
- if (seen.cycle) {
3764
- // any
3765
- extractToDef(entry);
3766
- continue;
3767
- }
3768
- // extract reused schemas
3769
- if (seen.count > 1) {
3770
- if (ctx.reused === "ref") {
3771
- extractToDef(entry);
3772
- // biome-ignore lint:
3773
- continue;
3774
- }
3775
- }
3776
- }
3777
- }
3778
- function finalize(ctx, schema) {
3779
- //
3780
- // iterate over seen map;
3781
- const root = ctx.seen.get(schema);
3782
- if (!root)
3783
- throw new Error("Unprocessed schema. This is a bug in Zod.");
3784
- // flatten _refs
3785
- const flattenRef = (zodSchema) => {
3786
- const seen = ctx.seen.get(zodSchema);
3787
- const schema = seen.def ?? seen.schema;
3788
- const _cached = { ...schema };
3789
- // already seen
3790
- if (seen.ref === null) {
3791
- return;
3792
- }
3793
- // flatten ref if defined
3794
- const ref = seen.ref;
3795
- seen.ref = null; // prevent recursion
3796
- if (ref) {
3797
- flattenRef(ref);
3798
- // merge referenced schema into current
3799
- const refSchema = ctx.seen.get(ref).schema;
3800
- if (refSchema.$ref && (ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0")) {
3801
- schema.allOf = schema.allOf ?? [];
3802
- schema.allOf.push(refSchema);
3803
- }
3804
- else {
3805
- Object.assign(schema, refSchema);
3806
- Object.assign(schema, _cached); // prevent overwriting any fields in the original schema
3807
- }
3808
- }
3809
- // execute overrides
3810
- if (!seen.isParent)
3811
- ctx.override({
3812
- zodSchema: zodSchema,
3813
- jsonSchema: schema,
3814
- path: seen.path ?? [],
3815
- });
3816
- };
3817
- for (const entry of [...ctx.seen.entries()].reverse()) {
3818
- flattenRef(entry[0]);
3819
- }
3820
- const result = {};
3821
- if (ctx.target === "draft-2020-12") {
3822
- result.$schema = "https://json-schema.org/draft/2020-12/schema";
3823
- }
3824
- else if (ctx.target === "draft-07") {
3825
- result.$schema = "http://json-schema.org/draft-07/schema#";
3826
- }
3827
- else if (ctx.target === "draft-04") {
3828
- result.$schema = "http://json-schema.org/draft-04/schema#";
3829
- }
3830
- else if (ctx.target === "openapi-3.0") ;
3831
- else ;
3832
- if (ctx.external?.uri) {
3833
- const id = ctx.external.registry.get(schema)?.id;
3834
- if (!id)
3835
- throw new Error("Schema is missing an `id` property");
3836
- result.$id = ctx.external.uri(id);
3837
- }
3838
- Object.assign(result, root.def ?? root.schema);
3839
- // build defs object
3840
- const defs = ctx.external?.defs ?? {};
3841
- for (const entry of ctx.seen.entries()) {
3842
- const seen = entry[1];
3843
- if (seen.def && seen.defId) {
3844
- defs[seen.defId] = seen.def;
3845
- }
3846
- }
3847
- // set definitions in result
3848
- if (ctx.external) ;
3849
- else {
3850
- if (Object.keys(defs).length > 0) {
3851
- if (ctx.target === "draft-2020-12") {
3852
- result.$defs = defs;
3853
- }
3854
- else {
3855
- result.definitions = defs;
3856
- }
3857
- }
3858
- }
3859
- try {
3860
- // this "finalizes" this schema and ensures all cycles are removed
3861
- // each call to finalize() is functionally independent
3862
- // though the seen map is shared
3863
- const finalized = JSON.parse(JSON.stringify(result));
3864
- Object.defineProperty(finalized, "~standard", {
3865
- value: {
3866
- ...schema["~standard"],
3867
- jsonSchema: {
3868
- input: createStandardJSONSchemaMethod(schema, "input"),
3869
- output: createStandardJSONSchemaMethod(schema, "output"),
3870
- },
3871
- },
3872
- enumerable: false,
3873
- writable: false,
3874
- });
3875
- return finalized;
3876
- }
3877
- catch (_err) {
3878
- throw new Error("Error converting schema to JSON.");
3879
- }
3880
- }
3881
- function isTransforming(_schema, _ctx) {
3882
- const ctx = _ctx ?? { seen: new Set() };
3883
- if (ctx.seen.has(_schema))
3884
- return false;
3885
- ctx.seen.add(_schema);
3886
- const def = _schema._zod.def;
3887
- if (def.type === "transform")
3888
- return true;
3889
- if (def.type === "array")
3890
- return isTransforming(def.element, ctx);
3891
- if (def.type === "set")
3892
- return isTransforming(def.valueType, ctx);
3893
- if (def.type === "lazy")
3894
- return isTransforming(def.getter(), ctx);
3895
- if (def.type === "promise" ||
3896
- def.type === "optional" ||
3897
- def.type === "nonoptional" ||
3898
- def.type === "nullable" ||
3899
- def.type === "readonly" ||
3900
- def.type === "default" ||
3901
- def.type === "prefault") {
3902
- return isTransforming(def.innerType, ctx);
3903
- }
3904
- if (def.type === "intersection") {
3905
- return isTransforming(def.left, ctx) || isTransforming(def.right, ctx);
3906
- }
3907
- if (def.type === "record" || def.type === "map") {
3908
- return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
3909
- }
3910
- if (def.type === "pipe") {
3911
- return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
3912
- }
3913
- if (def.type === "object") {
3914
- for (const key in def.shape) {
3915
- if (isTransforming(def.shape[key], ctx))
3916
- return true;
3917
- }
3918
- return false;
3919
- }
3920
- if (def.type === "union") {
3921
- for (const option of def.options) {
3922
- if (isTransforming(option, ctx))
3923
- return true;
3924
- }
3925
- return false;
3926
- }
3927
- if (def.type === "tuple") {
3928
- for (const item of def.items) {
3929
- if (isTransforming(item, ctx))
3930
- return true;
3931
- }
3932
- if (def.rest && isTransforming(def.rest, ctx))
3933
- return true;
3934
- return false;
3935
- }
3936
- return false;
3937
- }
3938
- /**
3939
- * Creates a toJSONSchema method for a schema instance.
3940
- * This encapsulates the logic of initializing context, processing, extracting defs, and finalizing.
3941
- */
3942
- const createToJSONSchemaMethod = (schema, processors = {}) => (params) => {
3943
- const ctx = initializeContext({ ...params, processors });
3944
- process(schema, ctx);
3945
- extractDefs(ctx, schema);
3946
- return finalize(ctx, schema);
3947
- };
3948
- const createStandardJSONSchemaMethod = (schema, io) => (params) => {
3949
- const { libraryOptions, target } = params ?? {};
3950
- const ctx = initializeContext({ ...(libraryOptions ?? {}), target, io, processors: {} });
3951
- process(schema, ctx);
3952
- extractDefs(ctx, schema);
3953
- return finalize(ctx, schema);
3954
- };
3955
-
3956
- const formatMap = {
3957
- guid: "uuid",
3958
- url: "uri",
3959
- datetime: "date-time",
3960
- json_string: "json-string",
3961
- regex: "", // do not set
3962
- };
3963
- // ==================== SIMPLE TYPE PROCESSORS ====================
3964
- const stringProcessor = (schema, ctx, _json, _params) => {
3965
- const json = _json;
3966
- json.type = "string";
3967
- const { minimum, maximum, format, patterns, contentEncoding } = schema._zod
3968
- .bag;
3969
- if (typeof minimum === "number")
3970
- json.minLength = minimum;
3971
- if (typeof maximum === "number")
3972
- json.maxLength = maximum;
3973
- // custom pattern overrides format
3974
- if (format) {
3975
- json.format = formatMap[format] ?? format;
3976
- if (json.format === "")
3977
- delete json.format; // empty format is not valid
3978
- }
3979
- if (contentEncoding)
3980
- json.contentEncoding = contentEncoding;
3981
- if (patterns && patterns.size > 0) {
3982
- const regexes = [...patterns];
3983
- if (regexes.length === 1)
3984
- json.pattern = regexes[0].source;
3985
- else if (regexes.length > 1) {
3986
- json.allOf = [
3987
- ...regexes.map((regex) => ({
3988
- ...(ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0"
3989
- ? { type: "string" }
3990
- : {}),
3991
- pattern: regex.source,
3992
- })),
3993
- ];
3994
- }
3995
- }
3996
- };
3997
- const numberProcessor = (schema, ctx, _json, _params) => {
3998
- const json = _json;
3999
- const { minimum, maximum, format, multipleOf, exclusiveMaximum, exclusiveMinimum } = schema._zod.bag;
4000
- if (typeof format === "string" && format.includes("int"))
4001
- json.type = "integer";
4002
- else
4003
- json.type = "number";
4004
- if (typeof exclusiveMinimum === "number") {
4005
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
4006
- json.minimum = exclusiveMinimum;
4007
- json.exclusiveMinimum = true;
4008
- }
4009
- else {
4010
- json.exclusiveMinimum = exclusiveMinimum;
4011
- }
4012
- }
4013
- if (typeof minimum === "number") {
4014
- json.minimum = minimum;
4015
- if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
4016
- if (exclusiveMinimum >= minimum)
4017
- delete json.minimum;
4018
- else
4019
- delete json.exclusiveMinimum;
4020
- }
4021
- }
4022
- if (typeof exclusiveMaximum === "number") {
4023
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
4024
- json.maximum = exclusiveMaximum;
4025
- json.exclusiveMaximum = true;
4026
- }
4027
- else {
4028
- json.exclusiveMaximum = exclusiveMaximum;
4029
- }
4030
- }
4031
- if (typeof maximum === "number") {
4032
- json.maximum = maximum;
4033
- if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
4034
- if (exclusiveMaximum <= maximum)
4035
- delete json.maximum;
4036
- else
4037
- delete json.exclusiveMaximum;
4038
- }
4039
- }
4040
- if (typeof multipleOf === "number")
4041
- json.multipleOf = multipleOf;
4042
- };
4043
- const booleanProcessor = (_schema, _ctx, json, _params) => {
4044
- json.type = "boolean";
4045
- };
4046
- const neverProcessor = (_schema, _ctx, json, _params) => {
4047
- json.not = {};
4048
- };
4049
- const anyProcessor = (_schema, _ctx, _json, _params) => {
4050
- // empty schema accepts anything
4051
- };
4052
- const unknownProcessor = (_schema, _ctx, _json, _params) => {
4053
- // empty schema accepts anything
4054
- };
4055
- const enumProcessor = (schema, _ctx, json, _params) => {
4056
- const def = schema._zod.def;
4057
- const values = getEnumValues(def.entries);
4058
- // Number enums can have both string and number values
4059
- if (values.every((v) => typeof v === "number"))
4060
- json.type = "number";
4061
- if (values.every((v) => typeof v === "string"))
4062
- json.type = "string";
4063
- json.enum = values;
4064
- };
4065
- const customProcessor = (_schema, ctx, _json, _params) => {
4066
- if (ctx.unrepresentable === "throw") {
4067
- throw new Error("Custom types cannot be represented in JSON Schema");
4068
- }
4069
- };
4070
- const transformProcessor = (_schema, ctx, _json, _params) => {
4071
- if (ctx.unrepresentable === "throw") {
4072
- throw new Error("Transforms cannot be represented in JSON Schema");
4073
- }
4074
- };
4075
- // ==================== COMPOSITE TYPE PROCESSORS ====================
4076
- const arrayProcessor = (schema, ctx, _json, params) => {
4077
- const json = _json;
4078
- const def = schema._zod.def;
4079
- const { minimum, maximum } = schema._zod.bag;
4080
- if (typeof minimum === "number")
4081
- json.minItems = minimum;
4082
- if (typeof maximum === "number")
4083
- json.maxItems = maximum;
4084
- json.type = "array";
4085
- json.items = process(def.element, ctx, { ...params, path: [...params.path, "items"] });
4086
- };
4087
- const objectProcessor = (schema, ctx, _json, params) => {
4088
- const json = _json;
4089
- const def = schema._zod.def;
4090
- json.type = "object";
4091
- json.properties = {};
4092
- const shape = def.shape;
4093
- for (const key in shape) {
4094
- json.properties[key] = process(shape[key], ctx, {
4095
- ...params,
4096
- path: [...params.path, "properties", key],
4097
- });
4098
- }
4099
- // required keys
4100
- const allKeys = new Set(Object.keys(shape));
4101
- const requiredKeys = new Set([...allKeys].filter((key) => {
4102
- const v = def.shape[key]._zod;
4103
- if (ctx.io === "input") {
4104
- return v.optin === undefined;
4105
- }
4106
- else {
4107
- return v.optout === undefined;
4108
- }
4109
- }));
4110
- if (requiredKeys.size > 0) {
4111
- json.required = Array.from(requiredKeys);
4112
- }
4113
- // catchall
4114
- if (def.catchall?._zod.def.type === "never") {
4115
- // strict
4116
- json.additionalProperties = false;
4117
- }
4118
- else if (!def.catchall) {
4119
- // regular
4120
- if (ctx.io === "output")
4121
- json.additionalProperties = false;
4122
- }
4123
- else if (def.catchall) {
4124
- json.additionalProperties = process(def.catchall, ctx, {
4125
- ...params,
4126
- path: [...params.path, "additionalProperties"],
4127
- });
4128
- }
4129
- };
4130
- const unionProcessor = (schema, ctx, json, params) => {
4131
- const def = schema._zod.def;
4132
- // Exclusive unions (inclusive === false) use oneOf (exactly one match) instead of anyOf (one or more matches)
4133
- // This includes both z.xor() and discriminated unions
4134
- const isExclusive = def.inclusive === false;
4135
- const options = def.options.map((x, i) => process(x, ctx, {
4136
- ...params,
4137
- path: [...params.path, isExclusive ? "oneOf" : "anyOf", i],
4138
- }));
4139
- if (isExclusive) {
4140
- json.oneOf = options;
4141
- }
4142
- else {
4143
- json.anyOf = options;
4144
- }
4145
- };
4146
- const intersectionProcessor = (schema, ctx, json, params) => {
4147
- const def = schema._zod.def;
4148
- const a = process(def.left, ctx, {
4149
- ...params,
4150
- path: [...params.path, "allOf", 0],
4151
- });
4152
- const b = process(def.right, ctx, {
4153
- ...params,
4154
- path: [...params.path, "allOf", 1],
4155
- });
4156
- const isSimpleIntersection = (val) => "allOf" in val && Object.keys(val).length === 1;
4157
- const allOf = [
4158
- ...(isSimpleIntersection(a) ? a.allOf : [a]),
4159
- ...(isSimpleIntersection(b) ? b.allOf : [b]),
4160
- ];
4161
- json.allOf = allOf;
4162
- };
4163
- const nullableProcessor = (schema, ctx, json, params) => {
4164
- const def = schema._zod.def;
4165
- const inner = process(def.innerType, ctx, params);
4166
- const seen = ctx.seen.get(schema);
4167
- if (ctx.target === "openapi-3.0") {
4168
- seen.ref = def.innerType;
4169
- json.nullable = true;
4170
- }
4171
- else {
4172
- json.anyOf = [inner, { type: "null" }];
4173
- }
4174
- };
4175
- const nonoptionalProcessor = (schema, ctx, _json, params) => {
4176
- const def = schema._zod.def;
4177
- process(def.innerType, ctx, params);
4178
- const seen = ctx.seen.get(schema);
4179
- seen.ref = def.innerType;
4180
- };
4181
- const defaultProcessor = (schema, ctx, json, params) => {
4182
- const def = schema._zod.def;
4183
- process(def.innerType, ctx, params);
4184
- const seen = ctx.seen.get(schema);
4185
- seen.ref = def.innerType;
4186
- json.default = JSON.parse(JSON.stringify(def.defaultValue));
4187
- };
4188
- const prefaultProcessor = (schema, ctx, json, params) => {
4189
- const def = schema._zod.def;
4190
- process(def.innerType, ctx, params);
4191
- const seen = ctx.seen.get(schema);
4192
- seen.ref = def.innerType;
4193
- if (ctx.io === "input")
4194
- json._prefault = JSON.parse(JSON.stringify(def.defaultValue));
4195
- };
4196
- const catchProcessor = (schema, ctx, json, params) => {
4197
- const def = schema._zod.def;
4198
- process(def.innerType, ctx, params);
4199
- const seen = ctx.seen.get(schema);
4200
- seen.ref = def.innerType;
4201
- let catchValue;
4202
- try {
4203
- catchValue = def.catchValue(undefined);
4204
- }
4205
- catch {
4206
- throw new Error("Dynamic catch values are not supported in JSON Schema");
4207
- }
4208
- json.default = catchValue;
4209
- };
4210
- const pipeProcessor = (schema, ctx, _json, params) => {
4211
- const def = schema._zod.def;
4212
- const innerType = ctx.io === "input" ? (def.in._zod.def.type === "transform" ? def.out : def.in) : def.out;
4213
- process(innerType, ctx, params);
4214
- const seen = ctx.seen.get(schema);
4215
- seen.ref = innerType;
4216
- };
4217
- const readonlyProcessor = (schema, ctx, json, params) => {
4218
- const def = schema._zod.def;
4219
- process(def.innerType, ctx, params);
4220
- const seen = ctx.seen.get(schema);
4221
- seen.ref = def.innerType;
4222
- json.readOnly = true;
4223
- };
4224
- const optionalProcessor = (schema, ctx, _json, params) => {
4225
- const def = schema._zod.def;
4226
- process(def.innerType, ctx, params);
4227
- const seen = ctx.seen.get(schema);
4228
- seen.ref = def.innerType;
4229
- };
4230
-
4231
3588
  const ZodISODateTime = /*@__PURE__*/ $constructor("ZodISODateTime", (inst, def) => {
4232
3589
  $ZodISODateTime.init(inst, def);
4233
3590
  ZodStringFormat.init(inst, def);
@@ -4319,13 +3676,6 @@ const safeDecodeAsync = /* @__PURE__ */ _safeDecodeAsync(ZodRealError);
4319
3676
 
4320
3677
  const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
4321
3678
  $ZodType.init(inst, def);
4322
- Object.assign(inst["~standard"], {
4323
- jsonSchema: {
4324
- input: createStandardJSONSchemaMethod(inst, "input"),
4325
- output: createStandardJSONSchemaMethod(inst, "output"),
4326
- },
4327
- });
4328
- inst.toJSONSchema = createToJSONSchemaMethod(inst, {});
4329
3679
  inst.def = def;
4330
3680
  inst.type = def.type;
4331
3681
  Object.defineProperty(inst, "_def", { value: def });
@@ -4407,7 +3757,6 @@ const ZodType = /*@__PURE__*/ $constructor("ZodType", (inst, def) => {
4407
3757
  const _ZodString = /*@__PURE__*/ $constructor("_ZodString", (inst, def) => {
4408
3758
  $ZodString.init(inst, def);
4409
3759
  ZodType.init(inst, def);
4410
- inst._zod.processJSONSchema = (ctx, json, params) => stringProcessor(inst, ctx, json);
4411
3760
  const bag = inst._zod.bag;
4412
3761
  inst.format = bag.format ?? null;
4413
3762
  inst.minLength = bag.minimum ?? null;
@@ -4565,7 +3914,6 @@ const ZodJWT = /*@__PURE__*/ $constructor("ZodJWT", (inst, def) => {
4565
3914
  const ZodNumber = /*@__PURE__*/ $constructor("ZodNumber", (inst, def) => {
4566
3915
  $ZodNumber.init(inst, def);
4567
3916
  ZodType.init(inst, def);
4568
- inst._zod.processJSONSchema = (ctx, json, params) => numberProcessor(inst, ctx, json);
4569
3917
  inst.gt = (value, params) => inst.check(_gt(value, params));
4570
3918
  inst.gte = (value, params) => inst.check(_gte(value, params));
4571
3919
  inst.min = (value, params) => inst.check(_gte(value, params));
@@ -4604,7 +3952,6 @@ function int(params) {
4604
3952
  const ZodBoolean = /*@__PURE__*/ $constructor("ZodBoolean", (inst, def) => {
4605
3953
  $ZodBoolean.init(inst, def);
4606
3954
  ZodType.init(inst, def);
4607
- inst._zod.processJSONSchema = (ctx, json, params) => booleanProcessor(inst, ctx, json);
4608
3955
  });
4609
3956
  function boolean(params) {
4610
3957
  return _boolean(ZodBoolean, params);
@@ -4612,7 +3959,6 @@ function boolean(params) {
4612
3959
  const ZodAny = /*@__PURE__*/ $constructor("ZodAny", (inst, def) => {
4613
3960
  $ZodAny.init(inst, def);
4614
3961
  ZodType.init(inst, def);
4615
- inst._zod.processJSONSchema = (ctx, json, params) => anyProcessor();
4616
3962
  });
4617
3963
  function any() {
4618
3964
  return _any(ZodAny);
@@ -4620,7 +3966,6 @@ function any() {
4620
3966
  const ZodUnknown = /*@__PURE__*/ $constructor("ZodUnknown", (inst, def) => {
4621
3967
  $ZodUnknown.init(inst, def);
4622
3968
  ZodType.init(inst, def);
4623
- inst._zod.processJSONSchema = (ctx, json, params) => unknownProcessor();
4624
3969
  });
4625
3970
  function unknown() {
4626
3971
  return _unknown(ZodUnknown);
@@ -4628,7 +3973,6 @@ function unknown() {
4628
3973
  const ZodNever = /*@__PURE__*/ $constructor("ZodNever", (inst, def) => {
4629
3974
  $ZodNever.init(inst, def);
4630
3975
  ZodType.init(inst, def);
4631
- inst._zod.processJSONSchema = (ctx, json, params) => neverProcessor(inst, ctx, json);
4632
3976
  });
4633
3977
  function never(params) {
4634
3978
  return _never(ZodNever, params);
@@ -4636,7 +3980,6 @@ function never(params) {
4636
3980
  const ZodArray = /*@__PURE__*/ $constructor("ZodArray", (inst, def) => {
4637
3981
  $ZodArray.init(inst, def);
4638
3982
  ZodType.init(inst, def);
4639
- inst._zod.processJSONSchema = (ctx, json, params) => arrayProcessor(inst, ctx, json, params);
4640
3983
  inst.element = def.element;
4641
3984
  inst.min = (minLength, params) => inst.check(_minLength(minLength, params));
4642
3985
  inst.nonempty = (params) => inst.check(_minLength(1, params));
@@ -4650,7 +3993,6 @@ function array(element, params) {
4650
3993
  const ZodObject = /*@__PURE__*/ $constructor("ZodObject", (inst, def) => {
4651
3994
  $ZodObjectJIT.init(inst, def);
4652
3995
  ZodType.init(inst, def);
4653
- inst._zod.processJSONSchema = (ctx, json, params) => objectProcessor(inst, ctx, json, params);
4654
3996
  defineLazy(inst, "shape", () => {
4655
3997
  return def.shape;
4656
3998
  });
@@ -4683,7 +4025,6 @@ function object(shape, params) {
4683
4025
  const ZodUnion = /*@__PURE__*/ $constructor("ZodUnion", (inst, def) => {
4684
4026
  $ZodUnion.init(inst, def);
4685
4027
  ZodType.init(inst, def);
4686
- inst._zod.processJSONSchema = (ctx, json, params) => unionProcessor(inst, ctx, json, params);
4687
4028
  inst.options = def.options;
4688
4029
  });
4689
4030
  function union(options, params) {
@@ -4696,7 +4037,6 @@ function union(options, params) {
4696
4037
  const ZodIntersection = /*@__PURE__*/ $constructor("ZodIntersection", (inst, def) => {
4697
4038
  $ZodIntersection.init(inst, def);
4698
4039
  ZodType.init(inst, def);
4699
- inst._zod.processJSONSchema = (ctx, json, params) => intersectionProcessor(inst, ctx, json, params);
4700
4040
  });
4701
4041
  function intersection(left, right) {
4702
4042
  return new ZodIntersection({
@@ -4708,7 +4048,6 @@ function intersection(left, right) {
4708
4048
  const ZodEnum = /*@__PURE__*/ $constructor("ZodEnum", (inst, def) => {
4709
4049
  $ZodEnum.init(inst, def);
4710
4050
  ZodType.init(inst, def);
4711
- inst._zod.processJSONSchema = (ctx, json, params) => enumProcessor(inst, ctx, json);
4712
4051
  inst.enum = def.entries;
4713
4052
  inst.options = Object.values(def.entries);
4714
4053
  const keys = new Set(Object.keys(def.entries));
@@ -4756,7 +4095,6 @@ function _enum(values, params) {
4756
4095
  const ZodTransform = /*@__PURE__*/ $constructor("ZodTransform", (inst, def) => {
4757
4096
  $ZodTransform.init(inst, def);
4758
4097
  ZodType.init(inst, def);
4759
- inst._zod.processJSONSchema = (ctx, json, params) => transformProcessor(inst, ctx);
4760
4098
  inst._zod.parse = (payload, _ctx) => {
4761
4099
  if (_ctx.direction === "backward") {
4762
4100
  throw new $ZodEncodeError(inst.constructor.name);
@@ -4797,7 +4135,6 @@ function transform(fn) {
4797
4135
  const ZodOptional = /*@__PURE__*/ $constructor("ZodOptional", (inst, def) => {
4798
4136
  $ZodOptional.init(inst, def);
4799
4137
  ZodType.init(inst, def);
4800
- inst._zod.processJSONSchema = (ctx, json, params) => optionalProcessor(inst, ctx, json, params);
4801
4138
  inst.unwrap = () => inst._zod.def.innerType;
4802
4139
  });
4803
4140
  function optional(innerType) {
@@ -4809,7 +4146,6 @@ function optional(innerType) {
4809
4146
  const ZodNullable = /*@__PURE__*/ $constructor("ZodNullable", (inst, def) => {
4810
4147
  $ZodNullable.init(inst, def);
4811
4148
  ZodType.init(inst, def);
4812
- inst._zod.processJSONSchema = (ctx, json, params) => nullableProcessor(inst, ctx, json, params);
4813
4149
  inst.unwrap = () => inst._zod.def.innerType;
4814
4150
  });
4815
4151
  function nullable(innerType) {
@@ -4821,7 +4157,6 @@ function nullable(innerType) {
4821
4157
  const ZodDefault = /*@__PURE__*/ $constructor("ZodDefault", (inst, def) => {
4822
4158
  $ZodDefault.init(inst, def);
4823
4159
  ZodType.init(inst, def);
4824
- inst._zod.processJSONSchema = (ctx, json, params) => defaultProcessor(inst, ctx, json, params);
4825
4160
  inst.unwrap = () => inst._zod.def.innerType;
4826
4161
  inst.removeDefault = inst.unwrap;
4827
4162
  });
@@ -4837,7 +4172,6 @@ function _default(innerType, defaultValue) {
4837
4172
  const ZodPrefault = /*@__PURE__*/ $constructor("ZodPrefault", (inst, def) => {
4838
4173
  $ZodPrefault.init(inst, def);
4839
4174
  ZodType.init(inst, def);
4840
- inst._zod.processJSONSchema = (ctx, json, params) => prefaultProcessor(inst, ctx, json, params);
4841
4175
  inst.unwrap = () => inst._zod.def.innerType;
4842
4176
  });
4843
4177
  function prefault(innerType, defaultValue) {
@@ -4852,7 +4186,6 @@ function prefault(innerType, defaultValue) {
4852
4186
  const ZodNonOptional = /*@__PURE__*/ $constructor("ZodNonOptional", (inst, def) => {
4853
4187
  $ZodNonOptional.init(inst, def);
4854
4188
  ZodType.init(inst, def);
4855
- inst._zod.processJSONSchema = (ctx, json, params) => nonoptionalProcessor(inst, ctx, json, params);
4856
4189
  inst.unwrap = () => inst._zod.def.innerType;
4857
4190
  });
4858
4191
  function nonoptional(innerType, params) {
@@ -4865,7 +4198,6 @@ function nonoptional(innerType, params) {
4865
4198
  const ZodCatch = /*@__PURE__*/ $constructor("ZodCatch", (inst, def) => {
4866
4199
  $ZodCatch.init(inst, def);
4867
4200
  ZodType.init(inst, def);
4868
- inst._zod.processJSONSchema = (ctx, json, params) => catchProcessor(inst, ctx, json, params);
4869
4201
  inst.unwrap = () => inst._zod.def.innerType;
4870
4202
  inst.removeCatch = inst.unwrap;
4871
4203
  });
@@ -4879,7 +4211,6 @@ function _catch(innerType, catchValue) {
4879
4211
  const ZodPipe = /*@__PURE__*/ $constructor("ZodPipe", (inst, def) => {
4880
4212
  $ZodPipe.init(inst, def);
4881
4213
  ZodType.init(inst, def);
4882
- inst._zod.processJSONSchema = (ctx, json, params) => pipeProcessor(inst, ctx, json, params);
4883
4214
  inst.in = def.in;
4884
4215
  inst.out = def.out;
4885
4216
  });
@@ -4894,7 +4225,6 @@ function pipe(in_, out) {
4894
4225
  const ZodReadonly = /*@__PURE__*/ $constructor("ZodReadonly", (inst, def) => {
4895
4226
  $ZodReadonly.init(inst, def);
4896
4227
  ZodType.init(inst, def);
4897
- inst._zod.processJSONSchema = (ctx, json, params) => readonlyProcessor(inst, ctx, json, params);
4898
4228
  inst.unwrap = () => inst._zod.def.innerType;
4899
4229
  });
4900
4230
  function readonly(innerType) {
@@ -4906,7 +4236,6 @@ function readonly(innerType) {
4906
4236
  const ZodCustom = /*@__PURE__*/ $constructor("ZodCustom", (inst, def) => {
4907
4237
  $ZodCustom.init(inst, def);
4908
4238
  ZodType.init(inst, def);
4909
- inst._zod.processJSONSchema = (ctx, json, params) => customProcessor(inst, ctx);
4910
4239
  });
4911
4240
  function refine(fn, _params = {}) {
4912
4241
  return _refine(ZodCustom, fn, _params);