@orpc/zod 0.0.0-next.a419c18 → 0.0.0-next.a45fc95

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/index.mjs CHANGED
@@ -1,6 +1,7 @@
1
- import { custom, ZodFirstPartyTypeKind } from 'zod';
1
+ import { custom, ZodFirstPartyTypeKind } from 'zod/v3';
2
2
  import wcmatch from 'wildcard-match';
3
- import { isObject, guard } from '@orpc/shared';
3
+ import { isObject, guard, toArray } from '@orpc/shared';
4
+ import { JsonSchemaXNativeType } from '@orpc/json-schema';
4
5
  import { JSONSchemaFormat } from '@orpc/openapi';
5
6
  import escapeStringRegexp from 'escape-string-regexp';
6
7
 
@@ -128,7 +129,7 @@ class ZodSmartCoercionPlugin {
128
129
  options.clientInterceptors ??= [];
129
130
  options.clientInterceptors.unshift((options2) => {
130
131
  const inputSchema = options2.procedure["~orpc"].inputSchema;
131
- if (!inputSchema || inputSchema["~standard"].vendor !== "zod") {
132
+ if (!inputSchema || inputSchema["~standard"].vendor !== "zod" || "_zod" in inputSchema) {
132
133
  return options2.next();
133
134
  }
134
135
  const coercedInput = zodCoerceInternal(inputSchema, options2.input);
@@ -390,25 +391,39 @@ function safeToDate(value) {
390
391
 
391
392
  class ZodToJsonSchemaConverter {
392
393
  maxLazyDepth;
394
+ maxStructureDepth;
393
395
  unsupportedJsonSchema;
394
396
  anyJsonSchema;
395
397
  constructor(options = {}) {
396
398
  this.maxLazyDepth = options.maxLazyDepth ?? 3;
399
+ this.maxStructureDepth = options.maxStructureDepth ?? 10;
397
400
  this.unsupportedJsonSchema = options.unsupportedJsonSchema ?? { not: {} };
398
401
  this.anyJsonSchema = options.anyJsonSchema ?? {};
399
402
  }
400
403
  condition(schema) {
401
- return schema !== void 0 && schema["~standard"].vendor === "zod";
404
+ return schema !== void 0 && schema["~standard"].vendor === "zod" && !("_zod" in schema);
402
405
  }
403
- convert(schema, options, lazyDepth = 0, isHandledCustomJSONSchema = false, isHandledZodDescription = false) {
406
+ convert(schema, options, lazyDepth = 0, isHandledCustomJSONSchema = false, isHandledZodDescription = false, structureDepth = 0) {
404
407
  const def = schema._def;
408
+ if (structureDepth > this.maxStructureDepth) {
409
+ return [false, this.anyJsonSchema];
410
+ }
411
+ if (!options.minStructureDepthForRef || options.minStructureDepthForRef <= structureDepth) {
412
+ const components = toArray(options.components);
413
+ for (const component of components) {
414
+ if (component.schema === schema && component.allowedStrategies.includes(options.strategy)) {
415
+ return [component.required, { $ref: component.ref }];
416
+ }
417
+ }
418
+ }
405
419
  if (!isHandledZodDescription && "description" in def && typeof def.description === "string") {
406
420
  const [required, json] = this.convert(
407
421
  schema,
408
422
  options,
409
423
  lazyDepth,
410
424
  isHandledCustomJSONSchema,
411
- true
425
+ true,
426
+ structureDepth
412
427
  );
413
428
  return [required, { ...json, description: def.description }];
414
429
  }
@@ -420,7 +435,8 @@ class ZodToJsonSchemaConverter {
420
435
  options,
421
436
  lazyDepth,
422
437
  true,
423
- isHandledZodDescription
438
+ isHandledZodDescription,
439
+ structureDepth
424
440
  );
425
441
  return [required, { ...json, ...customJSONSchema }];
426
442
  }
@@ -548,7 +564,11 @@ class ZodToJsonSchemaConverter {
548
564
  return [true, json];
549
565
  }
550
566
  case ZodFirstPartyTypeKind.ZodBigInt: {
551
- const json = { type: "string", pattern: "^-?[0-9]+$" };
567
+ const json = {
568
+ "type": "string",
569
+ "pattern": "^-?[0-9]+$",
570
+ "x-native-type": JsonSchemaXNativeType.BigInt
571
+ };
552
572
  return [true, json];
553
573
  }
554
574
  case ZodFirstPartyTypeKind.ZodNaN: {
@@ -558,7 +578,11 @@ class ZodToJsonSchemaConverter {
558
578
  return [true, { type: "boolean" }];
559
579
  }
560
580
  case ZodFirstPartyTypeKind.ZodDate: {
561
- const schema2 = { type: "string", format: JSONSchemaFormat.DateTime };
581
+ const schema2 = {
582
+ "type": "string",
583
+ "format": JSONSchemaFormat.DateTime,
584
+ "x-native-type": JsonSchemaXNativeType.Date
585
+ };
562
586
  return [true, schema2];
563
587
  }
564
588
  case ZodFirstPartyTypeKind.ZodNull: {
@@ -591,7 +615,7 @@ class ZodToJsonSchemaConverter {
591
615
  const schema_ = schema;
592
616
  const def2 = schema_._def;
593
617
  const json = { type: "array" };
594
- const [itemRequired, itemJson] = this.convert(def2.type, options, lazyDepth, false, false);
618
+ const [itemRequired, itemJson] = this.convert(def2.type, options, lazyDepth, false, false, structureDepth + 1);
595
619
  json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
596
620
  if (def2.exactLength) {
597
621
  json.maxItems = def2.exactLength.value;
@@ -610,7 +634,7 @@ class ZodToJsonSchemaConverter {
610
634
  const prefixItems = [];
611
635
  const json = { type: "array" };
612
636
  for (const item of schema_._def.items) {
613
- const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false);
637
+ const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false, structureDepth + 1);
614
638
  prefixItems.push(
615
639
  this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy)
616
640
  );
@@ -619,7 +643,7 @@ class ZodToJsonSchemaConverter {
619
643
  json.prefixItems = prefixItems;
620
644
  }
621
645
  if (schema_._def.rest) {
622
- const [itemRequired, itemJson] = this.convert(schema_._def.rest, options, lazyDepth, false, false);
646
+ const [itemRequired, itemJson] = this.convert(schema_._def.rest, options, lazyDepth, false, false, structureDepth + 1);
623
647
  json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
624
648
  }
625
649
  return [true, json];
@@ -630,7 +654,7 @@ class ZodToJsonSchemaConverter {
630
654
  const properties = {};
631
655
  const required = [];
632
656
  for (const [key, value] of Object.entries(schema_.shape)) {
633
- const [itemRequired, itemJson] = this.convert(value, options, lazyDepth, false, false);
657
+ const [itemRequired, itemJson] = this.convert(value, options, lazyDepth, false, false, structureDepth + 1);
634
658
  properties[key] = itemJson;
635
659
  if (itemRequired) {
636
660
  required.push(key);
@@ -648,7 +672,7 @@ class ZodToJsonSchemaConverter {
648
672
  json.additionalProperties = false;
649
673
  }
650
674
  } else {
651
- const [_, addJson] = this.convert(schema_._def.catchall, options, lazyDepth, false, false);
675
+ const [_, addJson] = this.convert(schema_._def.catchall, options, lazyDepth, false, false, structureDepth + 1);
652
676
  json.additionalProperties = addJson;
653
677
  }
654
678
  return [true, json];
@@ -656,28 +680,32 @@ class ZodToJsonSchemaConverter {
656
680
  case ZodFirstPartyTypeKind.ZodRecord: {
657
681
  const schema_ = schema;
658
682
  const json = { type: "object" };
659
- const [__, keyJson] = this.convert(schema_._def.keyType, options, lazyDepth, false, false);
683
+ const [__, keyJson] = this.convert(schema_._def.keyType, options, lazyDepth, false, false, structureDepth + 1);
660
684
  if (Object.entries(keyJson).some(([k, v]) => k !== "type" || v !== "string")) {
661
685
  json.propertyNames = keyJson;
662
686
  }
663
- const [_, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false);
687
+ const [_, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false, structureDepth + 1);
664
688
  json.additionalProperties = itemJson;
665
689
  return [true, json];
666
690
  }
667
691
  case ZodFirstPartyTypeKind.ZodSet: {
668
692
  const schema_ = schema;
669
- const json = { type: "array", uniqueItems: true };
670
- const [itemRequired, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false);
693
+ const json = {
694
+ "type": "array",
695
+ "uniqueItems": true,
696
+ "x-native-type": JsonSchemaXNativeType.Set
697
+ };
698
+ const [itemRequired, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false, structureDepth + 1);
671
699
  json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
672
700
  return [true, json];
673
701
  }
674
702
  case ZodFirstPartyTypeKind.ZodMap: {
675
703
  const schema_ = schema;
676
- const [keyRequired, keyJson] = this.convert(schema_._def.keyType, options, lazyDepth, false, false);
677
- const [valueRequired, valueJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false);
678
- return [true, {
679
- type: "array",
680
- items: {
704
+ const [keyRequired, keyJson] = this.convert(schema_._def.keyType, options, lazyDepth, false, false, structureDepth + 1);
705
+ const [valueRequired, valueJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false, structureDepth + 1);
706
+ const json = {
707
+ "type": "array",
708
+ "items": {
681
709
  type: "array",
682
710
  prefixItems: [
683
711
  this.#toArrayItemJsonSchema(keyRequired, keyJson, options.strategy),
@@ -685,8 +713,10 @@ class ZodToJsonSchemaConverter {
685
713
  ],
686
714
  maxItems: 2,
687
715
  minItems: 2
688
- }
689
- }];
716
+ },
717
+ "x-native-type": JsonSchemaXNativeType.Map
718
+ };
719
+ return [true, json];
690
720
  }
691
721
  case ZodFirstPartyTypeKind.ZodUnion:
692
722
  case ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {
@@ -694,7 +724,7 @@ class ZodToJsonSchemaConverter {
694
724
  const anyOf = [];
695
725
  let required = true;
696
726
  for (const item of schema_._def.options) {
697
- const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false);
727
+ const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false, structureDepth + 1);
698
728
  if (!itemRequired) {
699
729
  required = false;
700
730
  if (itemJson !== this.unsupportedJsonSchema) {
@@ -704,9 +734,6 @@ class ZodToJsonSchemaConverter {
704
734
  anyOf.push(itemJson);
705
735
  }
706
736
  }
707
- if (anyOf.length === 1) {
708
- return [required, anyOf[0]];
709
- }
710
737
  return [required, { anyOf }];
711
738
  }
712
739
  case ZodFirstPartyTypeKind.ZodIntersection: {
@@ -714,7 +741,7 @@ class ZodToJsonSchemaConverter {
714
741
  const allOf = [];
715
742
  let required = false;
716
743
  for (const item of [schema_._def.left, schema_._def.right]) {
717
- const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false);
744
+ const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false, structureDepth + 1);
718
745
  allOf.push(itemJson);
719
746
  if (itemRequired) {
720
747
  required = true;
@@ -723,25 +750,26 @@ class ZodToJsonSchemaConverter {
723
750
  return [required, { allOf }];
724
751
  }
725
752
  case ZodFirstPartyTypeKind.ZodLazy: {
726
- if (lazyDepth >= this.maxLazyDepth) {
753
+ const currentLazyDepth = lazyDepth + 1;
754
+ if (currentLazyDepth > this.maxLazyDepth) {
727
755
  return [false, this.anyJsonSchema];
728
756
  }
729
757
  const schema_ = schema;
730
- return this.convert(schema_._def.getter(), options, lazyDepth + 1, false, false);
758
+ return this.convert(schema_._def.getter(), options, currentLazyDepth, false, false, structureDepth);
731
759
  }
732
760
  case ZodFirstPartyTypeKind.ZodOptional: {
733
761
  const schema_ = schema;
734
- const [_, inner] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
762
+ const [_, inner] = this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
735
763
  return [false, inner];
736
764
  }
737
765
  case ZodFirstPartyTypeKind.ZodReadonly: {
738
766
  const schema_ = schema;
739
- const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
767
+ const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
740
768
  return [required, { ...json, readOnly: true }];
741
769
  }
742
770
  case ZodFirstPartyTypeKind.ZodDefault: {
743
771
  const schema_ = schema;
744
- const [_, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
772
+ const [_, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
745
773
  return [false, { default: schema_._def.defaultValue(), ...json }];
746
774
  }
747
775
  case ZodFirstPartyTypeKind.ZodEffects: {
@@ -749,15 +777,15 @@ class ZodToJsonSchemaConverter {
749
777
  if (schema_._def.effect.type === "transform" && options.strategy === "output") {
750
778
  return [false, this.anyJsonSchema];
751
779
  }
752
- return this.convert(schema_._def.schema, options, lazyDepth, false, false);
780
+ return this.convert(schema_._def.schema, options, lazyDepth, false, false, structureDepth);
753
781
  }
754
782
  case ZodFirstPartyTypeKind.ZodCatch: {
755
783
  const schema_ = schema;
756
- return this.convert(schema_._def.innerType, options, lazyDepth, false, false);
784
+ return this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
757
785
  }
758
786
  case ZodFirstPartyTypeKind.ZodBranded: {
759
787
  const schema_ = schema;
760
- return this.convert(schema_._def.type, options, lazyDepth, false, false);
788
+ return this.convert(schema_._def.type, options, lazyDepth, false, false, structureDepth);
761
789
  }
762
790
  case ZodFirstPartyTypeKind.ZodPipeline: {
763
791
  const schema_ = schema;
@@ -766,13 +794,14 @@ class ZodToJsonSchemaConverter {
766
794
  options,
767
795
  lazyDepth,
768
796
  false,
769
- false
797
+ false,
798
+ structureDepth
770
799
  );
771
800
  }
772
801
  case ZodFirstPartyTypeKind.ZodNullable: {
773
802
  const schema_ = schema;
774
- const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
775
- return [required, { anyOf: [{ type: "null" }, json] }];
803
+ const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
804
+ return [required, { anyOf: [json, { type: "null" }] }];
776
805
  }
777
806
  }
778
807
  return [true, this.unsupportedJsonSchema];
@@ -791,12 +820,17 @@ class ZodToJsonSchemaConverter {
791
820
  }
792
821
  case "regexp": {
793
822
  return {
794
- type: "string",
795
- pattern: "^\\/(.*)\\/([a-z]*)$"
823
+ "type": "string",
824
+ "pattern": "^\\/(.*)\\/([a-z]*)$",
825
+ "x-native-type": JsonSchemaXNativeType.RegExp
796
826
  };
797
827
  }
798
828
  case "url": {
799
- return { type: "string", format: JSONSchemaFormat.URI };
829
+ return {
830
+ "type": "string",
831
+ "format": JSONSchemaFormat.URI,
832
+ "x-native-type": JsonSchemaXNativeType.Url
833
+ };
800
834
  }
801
835
  }
802
836
  }
@@ -0,0 +1,314 @@
1
+ import { Context } from '@orpc/server';
2
+ import { StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
3
+ import { AnySchema } from '@orpc/contract';
4
+ import { JSONSchema, SchemaConvertOptions, ConditionalSchemaConverter } from '@orpc/openapi';
5
+ import { Interceptor } from '@orpc/shared';
6
+ import * as zod_v4_core from 'zod/v4/core';
7
+ import { $ZodType, $input, $output } from 'zod/v4/core';
8
+
9
+ /**
10
+ * @deprecated Use [Smart Coercion Plugin](https://orpc.dev/docs/openapi/plugins/smart-coercion) instead.
11
+ */
12
+ declare class experimental_ZodSmartCoercionPlugin<TContext extends Context> implements StandardHandlerPlugin<TContext> {
13
+ #private;
14
+ init(options: StandardHandlerOptions<TContext>): void;
15
+ }
16
+
17
+ interface ZodToJsonSchemaConverterOptions {
18
+ /**
19
+ * Max depth of lazy type.
20
+ *
21
+ * Used anyJsonSchema (`{}`) when exceed max depth
22
+ *
23
+ * @default 2
24
+ */
25
+ maxLazyDepth?: number;
26
+ /**
27
+ * Max depth of nested types.
28
+ *
29
+ * Used anyJsonSchema (`{}`) when exceed max depth
30
+ *
31
+ * @default 10
32
+ */
33
+ maxStructureDepth?: number;
34
+ /**
35
+ * The schema to be used to represent the any | unknown type.
36
+ *
37
+ * @default { }
38
+ */
39
+ anyJsonSchema?: Exclude<JSONSchema, boolean>;
40
+ /**
41
+ * The schema to be used when the Zod schema is unsupported.
42
+ *
43
+ * @default { not: {} }
44
+ */
45
+ unsupportedJsonSchema?: Exclude<JSONSchema, boolean>;
46
+ /**
47
+ * The schema to be used to represent the undefined type.
48
+ *
49
+ * @default { not: {} }
50
+ */
51
+ undefinedJsonSchema?: Exclude<JSONSchema, boolean>;
52
+ interceptors?: Interceptor<{
53
+ schema: $ZodType;
54
+ options: SchemaConvertOptions;
55
+ lazyDepth: number;
56
+ isHandledCustomJSONSchema: boolean;
57
+ }, [
58
+ required: boolean,
59
+ jsonSchema: Exclude<JSONSchema, boolean>
60
+ ]>[];
61
+ }
62
+ declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
63
+ #private;
64
+ private readonly maxLazyDepth;
65
+ private readonly maxStructureDepth;
66
+ private readonly anyJsonSchema;
67
+ private readonly unsupportedJsonSchema;
68
+ private readonly undefinedJsonSchema;
69
+ private readonly interceptors;
70
+ constructor(options?: ZodToJsonSchemaConverterOptions);
71
+ condition(schema: AnySchema | undefined): boolean;
72
+ convert(schema: AnySchema | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
73
+ }
74
+
75
+ /**
76
+ * Zod registry for customizing generated JSON schema, can use both for .input and .output
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * import { JSON_SCHEMA_REGISTRY } from '@orpc/zod/zod4'
81
+ *
82
+ * const user = z.object({
83
+ * name: z.string(),
84
+ * age: z.number(),
85
+ * })
86
+ *
87
+ * JSON_SCHEMA_REGISTRY.add(user, {
88
+ * examples: [{ name: 'John', age: 20 }],
89
+ * })
90
+ * ```
91
+ */
92
+ declare const JSON_SCHEMA_REGISTRY: zod_v4_core.$ZodRegistry<{
93
+ $anchor?: string;
94
+ $comment?: string;
95
+ $defs?: Record<string, JSONSchema>;
96
+ $dynamicAnchor?: string;
97
+ $dynamicRef?: string;
98
+ $id?: string;
99
+ $ref?: string;
100
+ $schema?: string;
101
+ $vocabulary?: Record<string, string>;
102
+ additionalItems?: JSONSchema;
103
+ additionalProperties?: JSONSchema;
104
+ allOf?: (JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue>[]) | undefined;
105
+ anyOf?: (JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue>[]) | undefined;
106
+ const?: typeof $input | typeof $output | undefined;
107
+ contains?: JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue> | undefined;
108
+ contentEncoding?: "7bit" | "8bit" | "base64" | "binary" | "ietf-token" | "quoted-printable" | "x-token";
109
+ contentMediaType?: string;
110
+ contentSchema?: JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue> | undefined;
111
+ default?: typeof $input | typeof $output | undefined;
112
+ definitions?: Record<string, JSONSchema>;
113
+ dependencies?: Record<string, (string[] | readonly string[]) | JSONSchema>;
114
+ dependentRequired?: Record<string, string[] | readonly string[]>;
115
+ dependentSchemas?: Record<string, JSONSchema>;
116
+ deprecated?: boolean;
117
+ description?: string;
118
+ else?: JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue> | undefined;
119
+ enum?: ((typeof $input | typeof $output)[] | readonly (typeof $input | typeof $output)[]) | undefined;
120
+ examples?: ((typeof $input | typeof $output)[] | readonly (typeof $input | typeof $output)[]) | undefined;
121
+ exclusiveMaximum?: number;
122
+ exclusiveMinimum?: number;
123
+ format?: string;
124
+ if?: JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue> | undefined;
125
+ items?: JSONSchema;
126
+ maxContains?: number;
127
+ maximum?: number;
128
+ maxItems?: number;
129
+ maxLength?: number;
130
+ maxProperties?: number;
131
+ minContains?: number;
132
+ minimum?: number;
133
+ minItems?: number;
134
+ minLength?: number;
135
+ minProperties?: number;
136
+ multipleOf?: number;
137
+ not?: JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue> | undefined;
138
+ oneOf?: (JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue>[]) | undefined;
139
+ pattern?: string;
140
+ patternProperties?: Record<string, JSONSchema>;
141
+ prefixItems?: (JSONSchema<any, JSONSchema.TypeValue>[] | readonly JSONSchema<any, JSONSchema.TypeValue>[]) | JSONSchema;
142
+ properties?: Record<string, JSONSchema>;
143
+ propertyNames?: JSONSchema;
144
+ readOnly?: boolean;
145
+ required?: string[] | readonly string[];
146
+ then?: JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue> | undefined;
147
+ title?: string;
148
+ type?: JSONSchema.TypeValue | undefined;
149
+ unevaluatedItems?: JSONSchema;
150
+ unevaluatedProperties?: JSONSchema;
151
+ uniqueItems?: boolean;
152
+ writeOnly?: boolean;
153
+ }, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
154
+ /**
155
+ * Zod registry for customizing generated JSON schema, only useful for .input
156
+ *
157
+ * @example
158
+ * ```ts
159
+ * import { JSON_SCHEMA_INPUT_REGISTRY } from '@orpc/zod/zod4'
160
+ *
161
+ * const user = z.object({
162
+ * name: z.string(),
163
+ * age: z.string().transform(v => Number(v)),
164
+ * })
165
+ *
166
+ * JSON_SCHEMA_REGISTRY.add(user, {
167
+ * examples: [{ name: 'John', age: "20" }],
168
+ * })
169
+ * ```
170
+ */
171
+ declare const JSON_SCHEMA_INPUT_REGISTRY: zod_v4_core.$ZodRegistry<{
172
+ $anchor?: string;
173
+ $comment?: string;
174
+ $defs?: Record<string, JSONSchema>;
175
+ $dynamicAnchor?: string;
176
+ $dynamicRef?: string;
177
+ $id?: string;
178
+ $ref?: string;
179
+ $schema?: string;
180
+ $vocabulary?: Record<string, string>;
181
+ additionalItems?: JSONSchema;
182
+ additionalProperties?: JSONSchema;
183
+ allOf?: (JSONSchema<typeof $input, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $input, JSONSchema.TypeValue>[]) | undefined;
184
+ anyOf?: (JSONSchema<typeof $input, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $input, JSONSchema.TypeValue>[]) | undefined;
185
+ const?: typeof $input | undefined;
186
+ contains?: JSONSchema<typeof $input, JSONSchema.TypeValue> | undefined;
187
+ contentEncoding?: "7bit" | "8bit" | "base64" | "binary" | "ietf-token" | "quoted-printable" | "x-token";
188
+ contentMediaType?: string;
189
+ contentSchema?: JSONSchema<typeof $input, JSONSchema.TypeValue> | undefined;
190
+ default?: typeof $input | undefined;
191
+ definitions?: Record<string, JSONSchema>;
192
+ dependencies?: Record<string, (string[] | readonly string[]) | JSONSchema>;
193
+ dependentRequired?: Record<string, string[] | readonly string[]>;
194
+ dependentSchemas?: Record<string, JSONSchema>;
195
+ deprecated?: boolean;
196
+ description?: string;
197
+ else?: JSONSchema<typeof $input, JSONSchema.TypeValue> | undefined;
198
+ enum?: ((typeof $input)[] | readonly (typeof $input)[]) | undefined;
199
+ examples?: ((typeof $input)[] | readonly (typeof $input)[]) | undefined;
200
+ exclusiveMaximum?: number;
201
+ exclusiveMinimum?: number;
202
+ format?: string;
203
+ if?: JSONSchema<typeof $input, JSONSchema.TypeValue> | undefined;
204
+ items?: JSONSchema;
205
+ maxContains?: number;
206
+ maximum?: number;
207
+ maxItems?: number;
208
+ maxLength?: number;
209
+ maxProperties?: number;
210
+ minContains?: number;
211
+ minimum?: number;
212
+ minItems?: number;
213
+ minLength?: number;
214
+ minProperties?: number;
215
+ multipleOf?: number;
216
+ not?: JSONSchema<typeof $input, JSONSchema.TypeValue> | undefined;
217
+ oneOf?: (JSONSchema<typeof $input, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $input, JSONSchema.TypeValue>[]) | undefined;
218
+ pattern?: string;
219
+ patternProperties?: Record<string, JSONSchema>;
220
+ prefixItems?: (JSONSchema<any, JSONSchema.TypeValue>[] | readonly JSONSchema<any, JSONSchema.TypeValue>[]) | JSONSchema;
221
+ properties?: Record<string, JSONSchema>;
222
+ propertyNames?: JSONSchema;
223
+ readOnly?: boolean;
224
+ required?: string[] | readonly string[];
225
+ then?: JSONSchema<typeof $input, JSONSchema.TypeValue> | undefined;
226
+ title?: string;
227
+ type?: JSONSchema.TypeValue | undefined;
228
+ unevaluatedItems?: JSONSchema;
229
+ unevaluatedProperties?: JSONSchema;
230
+ uniqueItems?: boolean;
231
+ writeOnly?: boolean;
232
+ }, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
233
+ /**
234
+ * Zod registry for customizing generated JSON schema, only useful for .input
235
+ *
236
+ * @example
237
+ * ```ts
238
+ * import { JSON_SCHEMA_OUTPUT_REGISTRY } from '@orpc/zod/zod4'
239
+ *
240
+ * const user = z.object({
241
+ * name: z.string(),
242
+ * age: z.string().transform(v => Number(v)),
243
+ * })
244
+ *
245
+ * JSON_SCHEMA_OUTPUT_REGISTRY.add(user, {
246
+ * examples: [{ name: 'John', age: 20 }],
247
+ * })
248
+ * ```
249
+ */
250
+ declare const JSON_SCHEMA_OUTPUT_REGISTRY: zod_v4_core.$ZodRegistry<{
251
+ $anchor?: string;
252
+ $comment?: string;
253
+ $defs?: Record<string, JSONSchema>;
254
+ $dynamicAnchor?: string;
255
+ $dynamicRef?: string;
256
+ $id?: string;
257
+ $ref?: string;
258
+ $schema?: string;
259
+ $vocabulary?: Record<string, string>;
260
+ additionalItems?: JSONSchema;
261
+ additionalProperties?: JSONSchema;
262
+ allOf?: (JSONSchema<typeof $output, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $output, JSONSchema.TypeValue>[]) | undefined;
263
+ anyOf?: (JSONSchema<typeof $output, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $output, JSONSchema.TypeValue>[]) | undefined;
264
+ const?: typeof $output | undefined;
265
+ contains?: JSONSchema<typeof $output, JSONSchema.TypeValue> | undefined;
266
+ contentEncoding?: "7bit" | "8bit" | "base64" | "binary" | "ietf-token" | "quoted-printable" | "x-token";
267
+ contentMediaType?: string;
268
+ contentSchema?: JSONSchema<typeof $output, JSONSchema.TypeValue> | undefined;
269
+ default?: typeof $output | undefined;
270
+ definitions?: Record<string, JSONSchema>;
271
+ dependencies?: Record<string, (string[] | readonly string[]) | JSONSchema>;
272
+ dependentRequired?: Record<string, string[] | readonly string[]>;
273
+ dependentSchemas?: Record<string, JSONSchema>;
274
+ deprecated?: boolean;
275
+ description?: string;
276
+ else?: JSONSchema<typeof $output, JSONSchema.TypeValue> | undefined;
277
+ enum?: ((typeof $output)[] | readonly (typeof $output)[]) | undefined;
278
+ examples?: ((typeof $output)[] | readonly (typeof $output)[]) | undefined;
279
+ exclusiveMaximum?: number;
280
+ exclusiveMinimum?: number;
281
+ format?: string;
282
+ if?: JSONSchema<typeof $output, JSONSchema.TypeValue> | undefined;
283
+ items?: JSONSchema;
284
+ maxContains?: number;
285
+ maximum?: number;
286
+ maxItems?: number;
287
+ maxLength?: number;
288
+ maxProperties?: number;
289
+ minContains?: number;
290
+ minimum?: number;
291
+ minItems?: number;
292
+ minLength?: number;
293
+ minProperties?: number;
294
+ multipleOf?: number;
295
+ not?: JSONSchema<typeof $output, JSONSchema.TypeValue> | undefined;
296
+ oneOf?: (JSONSchema<typeof $output, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $output, JSONSchema.TypeValue>[]) | undefined;
297
+ pattern?: string;
298
+ patternProperties?: Record<string, JSONSchema>;
299
+ prefixItems?: (JSONSchema<any, JSONSchema.TypeValue>[] | readonly JSONSchema<any, JSONSchema.TypeValue>[]) | JSONSchema;
300
+ properties?: Record<string, JSONSchema>;
301
+ propertyNames?: JSONSchema;
302
+ readOnly?: boolean;
303
+ required?: string[] | readonly string[];
304
+ then?: JSONSchema<typeof $output, JSONSchema.TypeValue> | undefined;
305
+ title?: string;
306
+ type?: JSONSchema.TypeValue | undefined;
307
+ unevaluatedItems?: JSONSchema;
308
+ unevaluatedProperties?: JSONSchema;
309
+ uniqueItems?: boolean;
310
+ writeOnly?: boolean;
311
+ }, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
312
+
313
+ export { JSON_SCHEMA_INPUT_REGISTRY, JSON_SCHEMA_OUTPUT_REGISTRY, JSON_SCHEMA_REGISTRY, ZodToJsonSchemaConverter, experimental_ZodSmartCoercionPlugin };
314
+ export type { ZodToJsonSchemaConverterOptions };