@orpc/zod 0.0.0-next.3d10c98 → 0.0.0-next.3d8a81d

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/README.md CHANGED
@@ -30,7 +30,7 @@
30
30
  - **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
31
31
  - **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
32
32
  - **📝 Contract-First Development**: Optionally define your API contract before implementation.
33
- - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
33
+ - **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), Pinia Colada, and more.
34
34
  - **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
35
35
  - **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
36
36
  - **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
@@ -49,13 +49,12 @@ You can find the full documentation [here](https://orpc.unnoq.com).
49
49
  - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
50
50
  - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
51
51
  - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
52
+ - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
53
+ - [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
52
54
  - [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
53
- - [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
54
- - [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
55
- - [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
56
- - [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
55
+ - [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
57
56
  - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
58
- - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
57
+ - [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
59
58
  - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
60
59
  - [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
61
60
  - [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
package/dist/index.d.mts CHANGED
@@ -40,34 +40,43 @@ declare class ZodSmartCoercionPlugin<TContext extends Context> implements Standa
40
40
 
41
41
  interface ZodToJsonSchemaOptions {
42
42
  /**
43
- * Max depth of lazy type, if it exceeds.
43
+ * Max depth of lazy type
44
44
  *
45
- * Used `{}` when reach max depth
45
+ * Used `{}` when exceed max depth
46
46
  *
47
47
  * @default 3
48
48
  */
49
49
  maxLazyDepth?: number;
50
50
  /**
51
- * The schema to be used when the Zod schema is unsupported.
51
+ * Max depth of nested types
52
52
  *
53
- * @default { not: {} }
53
+ * Used anyJsonSchema (`{}`) when exceed max depth
54
+ *
55
+ * @default 10
54
56
  */
55
- unsupportedJsonSchema?: Exclude<JSONSchema, boolean>;
57
+ maxStructureDepth?: number;
56
58
  /**
57
59
  * The schema to be used to represent the any | unknown type.
58
60
  *
59
61
  * @default { }
60
62
  */
61
63
  anyJsonSchema?: Exclude<JSONSchema, boolean>;
64
+ /**
65
+ * The schema to be used when the Zod schema is unsupported.
66
+ *
67
+ * @default { not: {} }
68
+ */
69
+ unsupportedJsonSchema?: Exclude<JSONSchema, boolean>;
62
70
  }
63
71
  declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
64
72
  #private;
65
73
  private readonly maxLazyDepth;
74
+ private readonly maxStructureDepth;
66
75
  private readonly unsupportedJsonSchema;
67
76
  private readonly anyJsonSchema;
68
77
  constructor(options?: ZodToJsonSchemaOptions);
69
78
  condition(schema: AnySchema | undefined): boolean;
70
- convert(schema: AnySchema | undefined, options: SchemaConvertOptions, lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
79
+ convert(schema: AnySchema | undefined, options: SchemaConvertOptions, lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean, structureDepth?: number): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
71
80
  }
72
81
 
73
82
  declare const oz: {
package/dist/index.d.ts CHANGED
@@ -40,34 +40,43 @@ declare class ZodSmartCoercionPlugin<TContext extends Context> implements Standa
40
40
 
41
41
  interface ZodToJsonSchemaOptions {
42
42
  /**
43
- * Max depth of lazy type, if it exceeds.
43
+ * Max depth of lazy type
44
44
  *
45
- * Used `{}` when reach max depth
45
+ * Used `{}` when exceed max depth
46
46
  *
47
47
  * @default 3
48
48
  */
49
49
  maxLazyDepth?: number;
50
50
  /**
51
- * The schema to be used when the Zod schema is unsupported.
51
+ * Max depth of nested types
52
52
  *
53
- * @default { not: {} }
53
+ * Used anyJsonSchema (`{}`) when exceed max depth
54
+ *
55
+ * @default 10
54
56
  */
55
- unsupportedJsonSchema?: Exclude<JSONSchema, boolean>;
57
+ maxStructureDepth?: number;
56
58
  /**
57
59
  * The schema to be used to represent the any | unknown type.
58
60
  *
59
61
  * @default { }
60
62
  */
61
63
  anyJsonSchema?: Exclude<JSONSchema, boolean>;
64
+ /**
65
+ * The schema to be used when the Zod schema is unsupported.
66
+ *
67
+ * @default { not: {} }
68
+ */
69
+ unsupportedJsonSchema?: Exclude<JSONSchema, boolean>;
62
70
  }
63
71
  declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
64
72
  #private;
65
73
  private readonly maxLazyDepth;
74
+ private readonly maxStructureDepth;
66
75
  private readonly unsupportedJsonSchema;
67
76
  private readonly anyJsonSchema;
68
77
  constructor(options?: ZodToJsonSchemaOptions);
69
78
  condition(schema: AnySchema | undefined): boolean;
70
- convert(schema: AnySchema | undefined, options: SchemaConvertOptions, lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
79
+ convert(schema: AnySchema | undefined, options: SchemaConvertOptions, lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean, structureDepth?: number): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
71
80
  }
72
81
 
73
82
  declare const oz: {
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { custom, ZodFirstPartyTypeKind } from 'zod';
2
2
  import wcmatch from 'wildcard-match';
3
- import { isObject, guard } from '@orpc/shared';
3
+ import { isObject, guard, toArray } from '@orpc/shared';
4
4
  import { JSONSchemaFormat } from '@orpc/openapi';
5
5
  import escapeStringRegexp from 'escape-string-regexp';
6
6
 
@@ -390,25 +390,39 @@ function safeToDate(value) {
390
390
 
391
391
  class ZodToJsonSchemaConverter {
392
392
  maxLazyDepth;
393
+ maxStructureDepth;
393
394
  unsupportedJsonSchema;
394
395
  anyJsonSchema;
395
396
  constructor(options = {}) {
396
397
  this.maxLazyDepth = options.maxLazyDepth ?? 3;
398
+ this.maxStructureDepth = options.maxStructureDepth ?? 10;
397
399
  this.unsupportedJsonSchema = options.unsupportedJsonSchema ?? { not: {} };
398
400
  this.anyJsonSchema = options.anyJsonSchema ?? {};
399
401
  }
400
402
  condition(schema) {
401
403
  return schema !== void 0 && schema["~standard"].vendor === "zod";
402
404
  }
403
- convert(schema, options, lazyDepth = 0, isHandledCustomJSONSchema = false, isHandledZodDescription = false) {
405
+ convert(schema, options, lazyDepth = 0, isHandledCustomJSONSchema = false, isHandledZodDescription = false, structureDepth = 0) {
404
406
  const def = schema._def;
407
+ if (structureDepth > this.maxStructureDepth) {
408
+ return [false, this.anyJsonSchema];
409
+ }
410
+ if (!options.minStructureDepthForRef || options.minStructureDepthForRef <= structureDepth) {
411
+ const components = toArray(options.components);
412
+ for (const component of components) {
413
+ if (component.schema === schema && component.allowedStrategies.includes(options.strategy)) {
414
+ return [component.required, { $ref: component.ref }];
415
+ }
416
+ }
417
+ }
405
418
  if (!isHandledZodDescription && "description" in def && typeof def.description === "string") {
406
419
  const [required, json] = this.convert(
407
420
  schema,
408
421
  options,
409
422
  lazyDepth,
410
423
  isHandledCustomJSONSchema,
411
- true
424
+ true,
425
+ structureDepth
412
426
  );
413
427
  return [required, { ...json, description: def.description }];
414
428
  }
@@ -420,7 +434,8 @@ class ZodToJsonSchemaConverter {
420
434
  options,
421
435
  lazyDepth,
422
436
  true,
423
- isHandledZodDescription
437
+ isHandledZodDescription,
438
+ structureDepth
424
439
  );
425
440
  return [required, { ...json, ...customJSONSchema }];
426
441
  }
@@ -591,7 +606,7 @@ class ZodToJsonSchemaConverter {
591
606
  const schema_ = schema;
592
607
  const def2 = schema_._def;
593
608
  const json = { type: "array" };
594
- const [itemRequired, itemJson] = this.convert(def2.type, options, lazyDepth, false, false);
609
+ const [itemRequired, itemJson] = this.convert(def2.type, options, lazyDepth, false, false, structureDepth + 1);
595
610
  json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
596
611
  if (def2.exactLength) {
597
612
  json.maxItems = def2.exactLength.value;
@@ -610,7 +625,7 @@ class ZodToJsonSchemaConverter {
610
625
  const prefixItems = [];
611
626
  const json = { type: "array" };
612
627
  for (const item of schema_._def.items) {
613
- const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false);
628
+ const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false, structureDepth + 1);
614
629
  prefixItems.push(
615
630
  this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy)
616
631
  );
@@ -619,7 +634,7 @@ class ZodToJsonSchemaConverter {
619
634
  json.prefixItems = prefixItems;
620
635
  }
621
636
  if (schema_._def.rest) {
622
- const [itemRequired, itemJson] = this.convert(schema_._def.rest, options, lazyDepth, false, false);
637
+ const [itemRequired, itemJson] = this.convert(schema_._def.rest, options, lazyDepth, false, false, structureDepth + 1);
623
638
  json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
624
639
  }
625
640
  return [true, json];
@@ -630,7 +645,7 @@ class ZodToJsonSchemaConverter {
630
645
  const properties = {};
631
646
  const required = [];
632
647
  for (const [key, value] of Object.entries(schema_.shape)) {
633
- const [itemRequired, itemJson] = this.convert(value, options, lazyDepth, false, false);
648
+ const [itemRequired, itemJson] = this.convert(value, options, lazyDepth, false, false, structureDepth + 1);
634
649
  properties[key] = itemJson;
635
650
  if (itemRequired) {
636
651
  required.push(key);
@@ -648,7 +663,7 @@ class ZodToJsonSchemaConverter {
648
663
  json.additionalProperties = false;
649
664
  }
650
665
  } else {
651
- const [_, addJson] = this.convert(schema_._def.catchall, options, lazyDepth, false, false);
666
+ const [_, addJson] = this.convert(schema_._def.catchall, options, lazyDepth, false, false, structureDepth + 1);
652
667
  json.additionalProperties = addJson;
653
668
  }
654
669
  return [true, json];
@@ -656,25 +671,25 @@ class ZodToJsonSchemaConverter {
656
671
  case ZodFirstPartyTypeKind.ZodRecord: {
657
672
  const schema_ = schema;
658
673
  const json = { type: "object" };
659
- const [__, keyJson] = this.convert(schema_._def.keyType, options, lazyDepth, false, false);
674
+ const [__, keyJson] = this.convert(schema_._def.keyType, options, lazyDepth, false, false, structureDepth + 1);
660
675
  if (Object.entries(keyJson).some(([k, v]) => k !== "type" || v !== "string")) {
661
676
  json.propertyNames = keyJson;
662
677
  }
663
- const [_, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false);
678
+ const [_, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false, structureDepth + 1);
664
679
  json.additionalProperties = itemJson;
665
680
  return [true, json];
666
681
  }
667
682
  case ZodFirstPartyTypeKind.ZodSet: {
668
683
  const schema_ = schema;
669
684
  const json = { type: "array", uniqueItems: true };
670
- const [itemRequired, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false);
685
+ const [itemRequired, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false, structureDepth + 1);
671
686
  json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
672
687
  return [true, json];
673
688
  }
674
689
  case ZodFirstPartyTypeKind.ZodMap: {
675
690
  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);
691
+ const [keyRequired, keyJson] = this.convert(schema_._def.keyType, options, lazyDepth, false, false, structureDepth + 1);
692
+ const [valueRequired, valueJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false, structureDepth + 1);
678
693
  return [true, {
679
694
  type: "array",
680
695
  items: {
@@ -694,7 +709,7 @@ class ZodToJsonSchemaConverter {
694
709
  const anyOf = [];
695
710
  let required = true;
696
711
  for (const item of schema_._def.options) {
697
- const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false);
712
+ const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false, structureDepth);
698
713
  if (!itemRequired) {
699
714
  required = false;
700
715
  if (itemJson !== this.unsupportedJsonSchema) {
@@ -714,7 +729,7 @@ class ZodToJsonSchemaConverter {
714
729
  const allOf = [];
715
730
  let required = false;
716
731
  for (const item of [schema_._def.left, schema_._def.right]) {
717
- const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false);
732
+ const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false, structureDepth);
718
733
  allOf.push(itemJson);
719
734
  if (itemRequired) {
720
735
  required = true;
@@ -723,25 +738,26 @@ class ZodToJsonSchemaConverter {
723
738
  return [required, { allOf }];
724
739
  }
725
740
  case ZodFirstPartyTypeKind.ZodLazy: {
726
- if (lazyDepth >= this.maxLazyDepth) {
741
+ const currentLazyDepth = lazyDepth + 1;
742
+ if (currentLazyDepth > this.maxLazyDepth) {
727
743
  return [false, this.anyJsonSchema];
728
744
  }
729
745
  const schema_ = schema;
730
- return this.convert(schema_._def.getter(), options, lazyDepth + 1, false, false);
746
+ return this.convert(schema_._def.getter(), options, currentLazyDepth, false, false, structureDepth);
731
747
  }
732
748
  case ZodFirstPartyTypeKind.ZodOptional: {
733
749
  const schema_ = schema;
734
- const [_, inner] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
750
+ const [_, inner] = this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
735
751
  return [false, inner];
736
752
  }
737
753
  case ZodFirstPartyTypeKind.ZodReadonly: {
738
754
  const schema_ = schema;
739
- const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
755
+ const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
740
756
  return [required, { ...json, readOnly: true }];
741
757
  }
742
758
  case ZodFirstPartyTypeKind.ZodDefault: {
743
759
  const schema_ = schema;
744
- const [_, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
760
+ const [_, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
745
761
  return [false, { default: schema_._def.defaultValue(), ...json }];
746
762
  }
747
763
  case ZodFirstPartyTypeKind.ZodEffects: {
@@ -749,15 +765,15 @@ class ZodToJsonSchemaConverter {
749
765
  if (schema_._def.effect.type === "transform" && options.strategy === "output") {
750
766
  return [false, this.anyJsonSchema];
751
767
  }
752
- return this.convert(schema_._def.schema, options, lazyDepth, false, false);
768
+ return this.convert(schema_._def.schema, options, lazyDepth, false, false, structureDepth);
753
769
  }
754
770
  case ZodFirstPartyTypeKind.ZodCatch: {
755
771
  const schema_ = schema;
756
- return this.convert(schema_._def.innerType, options, lazyDepth, false, false);
772
+ return this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
757
773
  }
758
774
  case ZodFirstPartyTypeKind.ZodBranded: {
759
775
  const schema_ = schema;
760
- return this.convert(schema_._def.type, options, lazyDepth, false, false);
776
+ return this.convert(schema_._def.type, options, lazyDepth, false, false, structureDepth);
761
777
  }
762
778
  case ZodFirstPartyTypeKind.ZodPipeline: {
763
779
  const schema_ = schema;
@@ -766,13 +782,14 @@ class ZodToJsonSchemaConverter {
766
782
  options,
767
783
  lazyDepth,
768
784
  false,
769
- false
785
+ false,
786
+ structureDepth
770
787
  );
771
788
  }
772
789
  case ZodFirstPartyTypeKind.ZodNullable: {
773
790
  const schema_ = schema;
774
- const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
775
- return [required, { anyOf: [{ type: "null" }, json] }];
791
+ const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
792
+ return [required, { anyOf: [json, { type: "null" }] }];
776
793
  }
777
794
  }
778
795
  return [true, this.unsupportedJsonSchema];
@@ -0,0 +1,311 @@
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
+ declare class experimental_ZodSmartCoercionPlugin<TContext extends Context> implements StandardHandlerPlugin<TContext> {
10
+ #private;
11
+ init(options: StandardHandlerOptions<TContext>): void;
12
+ }
13
+
14
+ interface experimental_ZodToJsonSchemaOptions {
15
+ /**
16
+ * Max depth of lazy type.
17
+ *
18
+ * Used anyJsonSchema (`{}`) when exceed max depth
19
+ *
20
+ * @default 2
21
+ */
22
+ maxLazyDepth?: number;
23
+ /**
24
+ * Max depth of nested types.
25
+ *
26
+ * Used anyJsonSchema (`{}`) when exceed max depth
27
+ *
28
+ * @default 10
29
+ */
30
+ maxStructureDepth?: number;
31
+ /**
32
+ * The schema to be used to represent the any | unknown type.
33
+ *
34
+ * @default { }
35
+ */
36
+ anyJsonSchema?: Exclude<JSONSchema, boolean>;
37
+ /**
38
+ * The schema to be used when the Zod schema is unsupported.
39
+ *
40
+ * @default { not: {} }
41
+ */
42
+ unsupportedJsonSchema?: Exclude<JSONSchema, boolean>;
43
+ /**
44
+ * The schema to be used to represent the undefined type.
45
+ *
46
+ * @default { not: {} }
47
+ */
48
+ undefinedJsonSchema?: Exclude<JSONSchema, boolean>;
49
+ interceptors?: Interceptor<{
50
+ schema: $ZodType;
51
+ options: SchemaConvertOptions;
52
+ lazyDepth: number;
53
+ isHandledCustomJSONSchema: boolean;
54
+ }, [
55
+ required: boolean,
56
+ jsonSchema: Exclude<JSONSchema, boolean>
57
+ ]>[];
58
+ }
59
+ declare class experimental_ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
60
+ #private;
61
+ private readonly maxLazyDepth;
62
+ private readonly maxStructureDepth;
63
+ private readonly anyJsonSchema;
64
+ private readonly unsupportedJsonSchema;
65
+ private readonly undefinedJsonSchema;
66
+ private readonly interceptors;
67
+ constructor(options?: experimental_ZodToJsonSchemaOptions);
68
+ condition(schema: AnySchema | undefined): boolean;
69
+ convert(schema: AnySchema | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
70
+ }
71
+
72
+ /**
73
+ * Zod registry for customizing generated JSON schema, can use both for .input and .output
74
+ *
75
+ * @example
76
+ * ```ts
77
+ * import { JSON_SCHEMA_REGISTRY } from '@orpc/zod/zod4'
78
+ *
79
+ * const user = z.object({
80
+ * name: z.string(),
81
+ * age: z.number(),
82
+ * })
83
+ *
84
+ * JSON_SCHEMA_REGISTRY.add(user, {
85
+ * examples: [{ name: 'John', age: 20 }],
86
+ * })
87
+ * ```
88
+ */
89
+ declare const experimental_JSON_SCHEMA_REGISTRY: zod_v4_core.$ZodRegistry<{
90
+ $anchor?: string;
91
+ $comment?: string;
92
+ $defs?: Record<string, JSONSchema>;
93
+ $dynamicAnchor?: string;
94
+ $dynamicRef?: string;
95
+ $id?: string;
96
+ $ref?: string;
97
+ $schema?: string;
98
+ $vocabulary?: Record<string, string>;
99
+ additionalItems?: JSONSchema;
100
+ additionalProperties?: JSONSchema;
101
+ allOf?: (JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue>[]) | undefined;
102
+ anyOf?: (JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue>[]) | undefined;
103
+ const?: typeof $input | typeof $output | undefined;
104
+ contains?: JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue> | undefined;
105
+ contentEncoding?: "7bit" | "8bit" | "base64" | "binary" | "ietf-token" | "quoted-printable" | "x-token";
106
+ contentMediaType?: string;
107
+ contentSchema?: JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue> | undefined;
108
+ default?: typeof $input | typeof $output | undefined;
109
+ definitions?: Record<string, JSONSchema>;
110
+ dependencies?: Record<string, (string[] | readonly string[]) | JSONSchema>;
111
+ dependentRequired?: Record<string, string[] | readonly string[]>;
112
+ dependentSchemas?: Record<string, JSONSchema>;
113
+ deprecated?: boolean;
114
+ description?: string;
115
+ else?: JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue> | undefined;
116
+ enum?: ((typeof $input | typeof $output)[] | readonly (typeof $input | typeof $output)[]) | undefined;
117
+ examples?: ((typeof $input | typeof $output)[] | readonly (typeof $input | typeof $output)[]) | undefined;
118
+ exclusiveMaximum?: number;
119
+ exclusiveMinimum?: number;
120
+ format?: string;
121
+ if?: JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue> | undefined;
122
+ items?: JSONSchema;
123
+ maxContains?: number;
124
+ maximum?: number;
125
+ maxItems?: number;
126
+ maxLength?: number;
127
+ maxProperties?: number;
128
+ minContains?: number;
129
+ minimum?: number;
130
+ minItems?: number;
131
+ minLength?: number;
132
+ minProperties?: number;
133
+ multipleOf?: number;
134
+ not?: JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue> | undefined;
135
+ oneOf?: (JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue>[]) | undefined;
136
+ pattern?: string;
137
+ patternProperties?: Record<string, JSONSchema>;
138
+ prefixItems?: (JSONSchema<any, JSONSchema.TypeValue>[] | readonly JSONSchema<any, JSONSchema.TypeValue>[]) | JSONSchema;
139
+ properties?: Record<string, JSONSchema>;
140
+ propertyNames?: JSONSchema;
141
+ readOnly?: boolean;
142
+ required?: string[] | readonly string[];
143
+ then?: JSONSchema<typeof $input | typeof $output, JSONSchema.TypeValue> | undefined;
144
+ title?: string;
145
+ type?: JSONSchema.TypeValue | undefined;
146
+ unevaluatedItems?: JSONSchema;
147
+ unevaluatedProperties?: JSONSchema;
148
+ uniqueItems?: boolean;
149
+ writeOnly?: boolean;
150
+ }, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
151
+ /**
152
+ * Zod registry for customizing generated JSON schema, only useful for .input
153
+ *
154
+ * @example
155
+ * ```ts
156
+ * import { JSON_SCHEMA_INPUT_REGISTRY } from '@orpc/zod/zod4'
157
+ *
158
+ * const user = z.object({
159
+ * name: z.string(),
160
+ * age: z.string().transform(v => Number(v)),
161
+ * })
162
+ *
163
+ * JSON_SCHEMA_REGISTRY.add(user, {
164
+ * examples: [{ name: 'John', age: "20" }],
165
+ * })
166
+ * ```
167
+ */
168
+ declare const experimental_JSON_SCHEMA_INPUT_REGISTRY: zod_v4_core.$ZodRegistry<{
169
+ $anchor?: string;
170
+ $comment?: string;
171
+ $defs?: Record<string, JSONSchema>;
172
+ $dynamicAnchor?: string;
173
+ $dynamicRef?: string;
174
+ $id?: string;
175
+ $ref?: string;
176
+ $schema?: string;
177
+ $vocabulary?: Record<string, string>;
178
+ additionalItems?: JSONSchema;
179
+ additionalProperties?: JSONSchema;
180
+ allOf?: (JSONSchema<typeof $input, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $input, JSONSchema.TypeValue>[]) | undefined;
181
+ anyOf?: (JSONSchema<typeof $input, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $input, JSONSchema.TypeValue>[]) | undefined;
182
+ const?: typeof $input | undefined;
183
+ contains?: JSONSchema<typeof $input, JSONSchema.TypeValue> | undefined;
184
+ contentEncoding?: "7bit" | "8bit" | "base64" | "binary" | "ietf-token" | "quoted-printable" | "x-token";
185
+ contentMediaType?: string;
186
+ contentSchema?: JSONSchema<typeof $input, JSONSchema.TypeValue> | undefined;
187
+ default?: typeof $input | undefined;
188
+ definitions?: Record<string, JSONSchema>;
189
+ dependencies?: Record<string, (string[] | readonly string[]) | JSONSchema>;
190
+ dependentRequired?: Record<string, string[] | readonly string[]>;
191
+ dependentSchemas?: Record<string, JSONSchema>;
192
+ deprecated?: boolean;
193
+ description?: string;
194
+ else?: JSONSchema<typeof $input, JSONSchema.TypeValue> | undefined;
195
+ enum?: ((typeof $input)[] | readonly (typeof $input)[]) | undefined;
196
+ examples?: ((typeof $input)[] | readonly (typeof $input)[]) | undefined;
197
+ exclusiveMaximum?: number;
198
+ exclusiveMinimum?: number;
199
+ format?: string;
200
+ if?: JSONSchema<typeof $input, JSONSchema.TypeValue> | undefined;
201
+ items?: JSONSchema;
202
+ maxContains?: number;
203
+ maximum?: number;
204
+ maxItems?: number;
205
+ maxLength?: number;
206
+ maxProperties?: number;
207
+ minContains?: number;
208
+ minimum?: number;
209
+ minItems?: number;
210
+ minLength?: number;
211
+ minProperties?: number;
212
+ multipleOf?: number;
213
+ not?: JSONSchema<typeof $input, JSONSchema.TypeValue> | undefined;
214
+ oneOf?: (JSONSchema<typeof $input, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $input, JSONSchema.TypeValue>[]) | undefined;
215
+ pattern?: string;
216
+ patternProperties?: Record<string, JSONSchema>;
217
+ prefixItems?: (JSONSchema<any, JSONSchema.TypeValue>[] | readonly JSONSchema<any, JSONSchema.TypeValue>[]) | JSONSchema;
218
+ properties?: Record<string, JSONSchema>;
219
+ propertyNames?: JSONSchema;
220
+ readOnly?: boolean;
221
+ required?: string[] | readonly string[];
222
+ then?: JSONSchema<typeof $input, JSONSchema.TypeValue> | undefined;
223
+ title?: string;
224
+ type?: JSONSchema.TypeValue | undefined;
225
+ unevaluatedItems?: JSONSchema;
226
+ unevaluatedProperties?: JSONSchema;
227
+ uniqueItems?: boolean;
228
+ writeOnly?: boolean;
229
+ }, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
230
+ /**
231
+ * Zod registry for customizing generated JSON schema, only useful for .input
232
+ *
233
+ * @example
234
+ * ```ts
235
+ * import { JSON_SCHEMA_OUTPUT_REGISTRY } from '@orpc/zod/zod4'
236
+ *
237
+ * const user = z.object({
238
+ * name: z.string(),
239
+ * age: z.string().transform(v => Number(v)),
240
+ * })
241
+ *
242
+ * JSON_SCHEMA_OUTPUT_REGISTRY.add(user, {
243
+ * examples: [{ name: 'John', age: 20 }],
244
+ * })
245
+ * ```
246
+ */
247
+ declare const experimental_JSON_SCHEMA_OUTPUT_REGISTRY: zod_v4_core.$ZodRegistry<{
248
+ $anchor?: string;
249
+ $comment?: string;
250
+ $defs?: Record<string, JSONSchema>;
251
+ $dynamicAnchor?: string;
252
+ $dynamicRef?: string;
253
+ $id?: string;
254
+ $ref?: string;
255
+ $schema?: string;
256
+ $vocabulary?: Record<string, string>;
257
+ additionalItems?: JSONSchema;
258
+ additionalProperties?: JSONSchema;
259
+ allOf?: (JSONSchema<typeof $output, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $output, JSONSchema.TypeValue>[]) | undefined;
260
+ anyOf?: (JSONSchema<typeof $output, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $output, JSONSchema.TypeValue>[]) | undefined;
261
+ const?: typeof $output | undefined;
262
+ contains?: JSONSchema<typeof $output, JSONSchema.TypeValue> | undefined;
263
+ contentEncoding?: "7bit" | "8bit" | "base64" | "binary" | "ietf-token" | "quoted-printable" | "x-token";
264
+ contentMediaType?: string;
265
+ contentSchema?: JSONSchema<typeof $output, JSONSchema.TypeValue> | undefined;
266
+ default?: typeof $output | undefined;
267
+ definitions?: Record<string, JSONSchema>;
268
+ dependencies?: Record<string, (string[] | readonly string[]) | JSONSchema>;
269
+ dependentRequired?: Record<string, string[] | readonly string[]>;
270
+ dependentSchemas?: Record<string, JSONSchema>;
271
+ deprecated?: boolean;
272
+ description?: string;
273
+ else?: JSONSchema<typeof $output, JSONSchema.TypeValue> | undefined;
274
+ enum?: ((typeof $output)[] | readonly (typeof $output)[]) | undefined;
275
+ examples?: ((typeof $output)[] | readonly (typeof $output)[]) | undefined;
276
+ exclusiveMaximum?: number;
277
+ exclusiveMinimum?: number;
278
+ format?: string;
279
+ if?: JSONSchema<typeof $output, JSONSchema.TypeValue> | undefined;
280
+ items?: JSONSchema;
281
+ maxContains?: number;
282
+ maximum?: number;
283
+ maxItems?: number;
284
+ maxLength?: number;
285
+ maxProperties?: number;
286
+ minContains?: number;
287
+ minimum?: number;
288
+ minItems?: number;
289
+ minLength?: number;
290
+ minProperties?: number;
291
+ multipleOf?: number;
292
+ not?: JSONSchema<typeof $output, JSONSchema.TypeValue> | undefined;
293
+ oneOf?: (JSONSchema<typeof $output, JSONSchema.TypeValue>[] | readonly JSONSchema<typeof $output, JSONSchema.TypeValue>[]) | undefined;
294
+ pattern?: string;
295
+ patternProperties?: Record<string, JSONSchema>;
296
+ prefixItems?: (JSONSchema<any, JSONSchema.TypeValue>[] | readonly JSONSchema<any, JSONSchema.TypeValue>[]) | JSONSchema;
297
+ properties?: Record<string, JSONSchema>;
298
+ propertyNames?: JSONSchema;
299
+ readOnly?: boolean;
300
+ required?: string[] | readonly string[];
301
+ then?: JSONSchema<typeof $output, JSONSchema.TypeValue> | undefined;
302
+ title?: string;
303
+ type?: JSONSchema.TypeValue | undefined;
304
+ unevaluatedItems?: JSONSchema;
305
+ unevaluatedProperties?: JSONSchema;
306
+ uniqueItems?: boolean;
307
+ writeOnly?: boolean;
308
+ }, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
309
+
310
+ export { experimental_JSON_SCHEMA_INPUT_REGISTRY, experimental_JSON_SCHEMA_OUTPUT_REGISTRY, experimental_JSON_SCHEMA_REGISTRY, experimental_ZodSmartCoercionPlugin, experimental_ZodToJsonSchemaConverter };
311
+ export type { experimental_ZodToJsonSchemaOptions };