@orpc/zod 0.0.0-next.1431467 → 0.0.0-next.15d9202

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
@@ -32,7 +32,7 @@
32
32
  - **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
33
33
  - **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
34
34
  - **Multi-Runtime Support 🌍**: Run your code seamlessly on Cloudflare, Deno, Bun, Node.js, and more.
35
- - **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue), Pinia Colada, and more.
35
+ - **Framework Integrations 🧩**: Supports Tanstack Query (React, Vue, Solid, Svelte), Pinia Colada, and more.
36
36
  - **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
37
37
  - **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
38
38
  - **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
@@ -55,6 +55,8 @@ You can find the full documentation [here](https://orpc.unnoq.com).
55
55
  - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
56
56
  - [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
57
57
  - [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
58
+ - [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
59
+ - [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
58
60
  - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
59
61
  - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
60
62
  - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
package/dist/index.d.mts CHANGED
@@ -1,12 +1,16 @@
1
- import { JSONSchema, ConditionalSchemaConverter } from '@orpc/openapi';
1
+ import { JSONSchema, ConditionalSchemaConverter, SchemaConvertOptions } from '@orpc/openapi';
2
2
  import { ZodTypeAny, input, output, ZodTypeDef, CustomErrorParams, ZodType, ZodEffects } from 'zod';
3
3
  import { Context } from '@orpc/server';
4
- import { Plugin } from '@orpc/server/plugins';
4
+ import { HandlerPlugin } from '@orpc/server/plugins';
5
5
  import { StandardHandlerOptions } from '@orpc/server/standard';
6
- import { Schema } from '@orpc/contract';
6
+ import { AnySchema } from '@orpc/contract';
7
7
 
8
- declare function getCustomJsonSchema(def: ZodTypeDef, strategy: 'input' | 'output' | 'both'): Exclude<JSONSchema, boolean> | undefined;
9
- declare function customJsonSchema<T extends ZodTypeAny, TStrategy extends 'input' | 'output' | 'both' = 'both'>(schema: T, custom: Exclude<JSONSchema<TStrategy extends 'input' ? input<T> : TStrategy extends 'output' ? output<T> : input<T> & output<T>>, boolean>, strategy?: TStrategy): T;
8
+ declare function getCustomJsonSchema(def: ZodTypeDef, options: {
9
+ strategy: 'input' | 'output' | 'both';
10
+ }): Exclude<JSONSchema, boolean> | undefined;
11
+ declare function customJsonSchema<T extends ZodTypeAny, TStrategy extends 'input' | 'output' | 'both' = 'both'>(schema: T, custom: Exclude<JSONSchema<TStrategy extends 'input' ? input<T> : TStrategy extends 'output' ? output<T> : input<T> & output<T>>, boolean>, options?: {
12
+ strategy?: TStrategy;
13
+ }): T;
10
14
 
11
15
  type CustomParams = CustomErrorParams & {
12
16
  fatal?: boolean;
@@ -31,7 +35,7 @@ declare function regexp(params?: string | CustomParams | ((input: unknown) => Cu
31
35
 
32
36
  declare function url(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<URL, ZodTypeDef, URL>;
33
37
 
34
- declare class ZodSmartCoercionPlugin<TContext extends Context> implements Plugin<TContext> {
38
+ declare class ZodSmartCoercionPlugin<TContext extends Context> implements HandlerPlugin<TContext> {
35
39
  init(options: StandardHandlerOptions<TContext>): void;
36
40
  }
37
41
 
@@ -58,15 +62,13 @@ interface ZodToJsonSchemaOptions {
58
62
  anyJsonSchema?: Exclude<JSONSchema, boolean>;
59
63
  }
60
64
  declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
65
+ #private;
61
66
  private readonly maxLazyDepth;
62
67
  private readonly unsupportedJsonSchema;
63
68
  private readonly anyJsonSchema;
64
69
  constructor(options?: ZodToJsonSchemaOptions);
65
- condition(schema: Schema): boolean;
66
- convert(schema: Schema, strategy: 'input' | 'output', lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
67
- private handleCustomZodDef;
68
- private getZodTypeName;
69
- private toArrayItemJsonSchema;
70
+ condition(schema: AnySchema | undefined): boolean;
71
+ convert(schema: AnySchema | undefined, options: SchemaConvertOptions, lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
70
72
  }
71
73
 
72
74
  declare const oz: {
package/dist/index.d.ts CHANGED
@@ -1,12 +1,16 @@
1
- import { JSONSchema, ConditionalSchemaConverter } from '@orpc/openapi';
1
+ import { JSONSchema, ConditionalSchemaConverter, SchemaConvertOptions } from '@orpc/openapi';
2
2
  import { ZodTypeAny, input, output, ZodTypeDef, CustomErrorParams, ZodType, ZodEffects } from 'zod';
3
3
  import { Context } from '@orpc/server';
4
- import { Plugin } from '@orpc/server/plugins';
4
+ import { HandlerPlugin } from '@orpc/server/plugins';
5
5
  import { StandardHandlerOptions } from '@orpc/server/standard';
6
- import { Schema } from '@orpc/contract';
6
+ import { AnySchema } from '@orpc/contract';
7
7
 
8
- declare function getCustomJsonSchema(def: ZodTypeDef, strategy: 'input' | 'output' | 'both'): Exclude<JSONSchema, boolean> | undefined;
9
- declare function customJsonSchema<T extends ZodTypeAny, TStrategy extends 'input' | 'output' | 'both' = 'both'>(schema: T, custom: Exclude<JSONSchema<TStrategy extends 'input' ? input<T> : TStrategy extends 'output' ? output<T> : input<T> & output<T>>, boolean>, strategy?: TStrategy): T;
8
+ declare function getCustomJsonSchema(def: ZodTypeDef, options: {
9
+ strategy: 'input' | 'output' | 'both';
10
+ }): Exclude<JSONSchema, boolean> | undefined;
11
+ declare function customJsonSchema<T extends ZodTypeAny, TStrategy extends 'input' | 'output' | 'both' = 'both'>(schema: T, custom: Exclude<JSONSchema<TStrategy extends 'input' ? input<T> : TStrategy extends 'output' ? output<T> : input<T> & output<T>>, boolean>, options?: {
12
+ strategy?: TStrategy;
13
+ }): T;
10
14
 
11
15
  type CustomParams = CustomErrorParams & {
12
16
  fatal?: boolean;
@@ -31,7 +35,7 @@ declare function regexp(params?: string | CustomParams | ((input: unknown) => Cu
31
35
 
32
36
  declare function url(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<URL, ZodTypeDef, URL>;
33
37
 
34
- declare class ZodSmartCoercionPlugin<TContext extends Context> implements Plugin<TContext> {
38
+ declare class ZodSmartCoercionPlugin<TContext extends Context> implements HandlerPlugin<TContext> {
35
39
  init(options: StandardHandlerOptions<TContext>): void;
36
40
  }
37
41
 
@@ -58,15 +62,13 @@ interface ZodToJsonSchemaOptions {
58
62
  anyJsonSchema?: Exclude<JSONSchema, boolean>;
59
63
  }
60
64
  declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
65
+ #private;
61
66
  private readonly maxLazyDepth;
62
67
  private readonly unsupportedJsonSchema;
63
68
  private readonly anyJsonSchema;
64
69
  constructor(options?: ZodToJsonSchemaOptions);
65
- condition(schema: Schema): boolean;
66
- convert(schema: Schema, strategy: 'input' | 'output', lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
67
- private handleCustomZodDef;
68
- private getZodTypeName;
69
- private toArrayItemJsonSchema;
70
+ condition(schema: AnySchema | undefined): boolean;
71
+ convert(schema: AnySchema | undefined, options: SchemaConvertOptions, lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
70
72
  }
71
73
 
72
74
  declare const oz: {
package/dist/index.mjs CHANGED
@@ -7,11 +7,11 @@ import escapeStringRegexp from 'escape-string-regexp';
7
7
  const CUSTOM_JSON_SCHEMA_SYMBOL = Symbol("ORPC_CUSTOM_JSON_SCHEMA");
8
8
  const CUSTOM_JSON_SCHEMA_INPUT_SYMBOL = Symbol("ORPC_CUSTOM_JSON_SCHEMA_INPUT");
9
9
  const CUSTOM_JSON_SCHEMA_OUTPUT_SYMBOL = Symbol("ORPC_CUSTOM_JSON_SCHEMA_OUTPUT");
10
- function getCustomJsonSchema(def, strategy) {
11
- if (strategy === "input" && CUSTOM_JSON_SCHEMA_INPUT_SYMBOL in def) {
10
+ function getCustomJsonSchema(def, options) {
11
+ if (options.strategy === "input" && CUSTOM_JSON_SCHEMA_INPUT_SYMBOL in def) {
12
12
  return def[CUSTOM_JSON_SCHEMA_INPUT_SYMBOL];
13
13
  }
14
- if (strategy === "output" && CUSTOM_JSON_SCHEMA_OUTPUT_SYMBOL in def) {
14
+ if (options.strategy === "output" && CUSTOM_JSON_SCHEMA_OUTPUT_SYMBOL in def) {
15
15
  return def[CUSTOM_JSON_SCHEMA_OUTPUT_SYMBOL];
16
16
  }
17
17
  if (CUSTOM_JSON_SCHEMA_SYMBOL in def) {
@@ -19,8 +19,8 @@ function getCustomJsonSchema(def, strategy) {
19
19
  }
20
20
  return void 0;
21
21
  }
22
- function customJsonSchema(schema, custom, strategy) {
23
- const SYMBOL = strategy === "input" ? CUSTOM_JSON_SCHEMA_INPUT_SYMBOL : strategy === "output" ? CUSTOM_JSON_SCHEMA_OUTPUT_SYMBOL : CUSTOM_JSON_SCHEMA_SYMBOL;
22
+ function customJsonSchema(schema, custom, options = {}) {
23
+ const SYMBOL = options.strategy === "input" ? CUSTOM_JSON_SCHEMA_INPUT_SYMBOL : options.strategy === "output" ? CUSTOM_JSON_SCHEMA_OUTPUT_SYMBOL : CUSTOM_JSON_SCHEMA_SYMBOL;
24
24
  const This = schema.constructor;
25
25
  const newSchema = new This({
26
26
  ...schema._def,
@@ -398,14 +398,14 @@ class ZodToJsonSchemaConverter {
398
398
  this.anyJsonSchema = options.anyJsonSchema ?? {};
399
399
  }
400
400
  condition(schema) {
401
- return Boolean(schema && schema["~standard"].vendor === "zod");
401
+ return schema !== void 0 && schema["~standard"].vendor === "zod";
402
402
  }
403
- convert(schema, strategy, lazyDepth = 0, isHandledCustomJSONSchema = false, isHandledZodDescription = false) {
403
+ convert(schema, options, lazyDepth = 0, isHandledCustomJSONSchema = false, isHandledZodDescription = false) {
404
404
  const def = schema._def;
405
405
  if (!isHandledZodDescription && "description" in def && typeof def.description === "string") {
406
406
  const [required, json] = this.convert(
407
407
  schema,
408
- strategy,
408
+ options,
409
409
  lazyDepth,
410
410
  isHandledCustomJSONSchema,
411
411
  true
@@ -413,11 +413,11 @@ class ZodToJsonSchemaConverter {
413
413
  return [required, { ...json, description: def.description }];
414
414
  }
415
415
  if (!isHandledCustomJSONSchema) {
416
- const customJSONSchema = getCustomJsonSchema(def, strategy);
416
+ const customJSONSchema = getCustomJsonSchema(def, options);
417
417
  if (customJSONSchema) {
418
418
  const [required, json] = this.convert(
419
419
  schema,
420
- strategy,
420
+ options,
421
421
  lazyDepth,
422
422
  true,
423
423
  isHandledZodDescription
@@ -425,11 +425,11 @@ class ZodToJsonSchemaConverter {
425
425
  return [required, { ...json, ...customJSONSchema }];
426
426
  }
427
427
  }
428
- const customSchema = this.handleCustomZodDef(def);
428
+ const customSchema = this.#handleCustomZodDef(def);
429
429
  if (customSchema) {
430
430
  return [true, customSchema];
431
431
  }
432
- const typeName = this.getZodTypeName(def);
432
+ const typeName = this.#getZodTypeName(def);
433
433
  switch (typeName) {
434
434
  case ZodFirstPartyTypeKind.ZodString: {
435
435
  const schema_ = schema;
@@ -552,7 +552,7 @@ class ZodToJsonSchemaConverter {
552
552
  return [true, json];
553
553
  }
554
554
  case ZodFirstPartyTypeKind.ZodNaN: {
555
- return strategy === "input" ? [true, this.unsupportedJsonSchema] : [true, { type: "null" }];
555
+ return options.strategy === "input" ? [true, this.unsupportedJsonSchema] : [true, { type: "null" }];
556
556
  }
557
557
  case ZodFirstPartyTypeKind.ZodBoolean: {
558
558
  return [true, { type: "boolean" }];
@@ -591,8 +591,8 @@ class ZodToJsonSchemaConverter {
591
591
  const schema_ = schema;
592
592
  const def2 = schema_._def;
593
593
  const json = { type: "array" };
594
- const [itemRequired, itemJson] = this.convert(def2.type, strategy, lazyDepth, false, false);
595
- json.items = this.toArrayItemJsonSchema(itemRequired, itemJson, strategy);
594
+ const [itemRequired, itemJson] = this.convert(def2.type, options, lazyDepth, false, false);
595
+ json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
596
596
  if (def2.exactLength) {
597
597
  json.maxItems = def2.exactLength.value;
598
598
  json.minItems = def2.exactLength.value;
@@ -610,17 +610,17 @@ class ZodToJsonSchemaConverter {
610
610
  const prefixItems = [];
611
611
  const json = { type: "array" };
612
612
  for (const item of schema_._def.items) {
613
- const [itemRequired, itemJson] = this.convert(item, strategy, lazyDepth, false, false);
613
+ const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false);
614
614
  prefixItems.push(
615
- this.toArrayItemJsonSchema(itemRequired, itemJson, strategy)
615
+ this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy)
616
616
  );
617
617
  }
618
618
  if (prefixItems?.length) {
619
619
  json.prefixItems = prefixItems;
620
620
  }
621
621
  if (schema_._def.rest) {
622
- const [itemRequired, itemJson] = this.convert(schema_._def.rest, strategy, lazyDepth, false, false);
623
- json.items = this.toArrayItemJsonSchema(itemRequired, itemJson, strategy);
622
+ const [itemRequired, itemJson] = this.convert(schema_._def.rest, options, lazyDepth, false, false);
623
+ json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
624
624
  }
625
625
  return [true, json];
626
626
  }
@@ -630,7 +630,7 @@ class ZodToJsonSchemaConverter {
630
630
  const properties = {};
631
631
  const required = [];
632
632
  for (const [key, value] of Object.entries(schema_.shape)) {
633
- const [itemRequired, itemJson] = this.convert(value, strategy, lazyDepth, false, false);
633
+ const [itemRequired, itemJson] = this.convert(value, options, lazyDepth, false, false);
634
634
  properties[key] = itemJson;
635
635
  if (itemRequired) {
636
636
  required.push(key);
@@ -642,13 +642,13 @@ class ZodToJsonSchemaConverter {
642
642
  if (required.length) {
643
643
  json.required = required;
644
644
  }
645
- const catchAllTypeName = this.getZodTypeName(schema_._def.catchall._def);
645
+ const catchAllTypeName = this.#getZodTypeName(schema_._def.catchall._def);
646
646
  if (catchAllTypeName === ZodFirstPartyTypeKind.ZodNever) {
647
647
  if (schema_._def.unknownKeys === "strict") {
648
648
  json.additionalProperties = false;
649
649
  }
650
650
  } else {
651
- const [_, addJson] = this.convert(schema_._def.catchall, strategy, lazyDepth, false, false);
651
+ const [_, addJson] = this.convert(schema_._def.catchall, options, lazyDepth, false, false);
652
652
  json.additionalProperties = addJson;
653
653
  }
654
654
  return [true, json];
@@ -656,28 +656,32 @@ class ZodToJsonSchemaConverter {
656
656
  case ZodFirstPartyTypeKind.ZodRecord: {
657
657
  const schema_ = schema;
658
658
  const json = { type: "object" };
659
- const [_, itemJson] = this.convert(schema_._def.valueType, strategy, lazyDepth, false, false);
659
+ const [__, keyJson] = this.convert(schema_._def.keyType, options, lazyDepth, false, false);
660
+ if (Object.entries(keyJson).some(([k, v]) => k !== "type" || v !== "string")) {
661
+ json.propertyNames = keyJson;
662
+ }
663
+ const [_, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false);
660
664
  json.additionalProperties = itemJson;
661
665
  return [true, json];
662
666
  }
663
667
  case ZodFirstPartyTypeKind.ZodSet: {
664
668
  const schema_ = schema;
665
669
  const json = { type: "array", uniqueItems: true };
666
- const [itemRequired, itemJson] = this.convert(schema_._def.valueType, strategy, lazyDepth, false, false);
667
- json.items = this.toArrayItemJsonSchema(itemRequired, itemJson, strategy);
670
+ const [itemRequired, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false);
671
+ json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
668
672
  return [true, json];
669
673
  }
670
674
  case ZodFirstPartyTypeKind.ZodMap: {
671
675
  const schema_ = schema;
672
- const [keyRequired, keyJson] = this.convert(schema_._def.keyType, strategy, lazyDepth, false, false);
673
- const [valueRequired, valueJson] = this.convert(schema_._def.valueType, strategy, lazyDepth, false, false);
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);
674
678
  return [true, {
675
679
  type: "array",
676
680
  items: {
677
681
  type: "array",
678
682
  prefixItems: [
679
- this.toArrayItemJsonSchema(keyRequired, keyJson, strategy),
680
- this.toArrayItemJsonSchema(valueRequired, valueJson, strategy)
683
+ this.#toArrayItemJsonSchema(keyRequired, keyJson, options.strategy),
684
+ this.#toArrayItemJsonSchema(valueRequired, valueJson, options.strategy)
681
685
  ],
682
686
  maxItems: 2,
683
687
  minItems: 2
@@ -690,7 +694,7 @@ class ZodToJsonSchemaConverter {
690
694
  const anyOf = [];
691
695
  let required = true;
692
696
  for (const item of schema_._def.options) {
693
- const [itemRequired, itemJson] = this.convert(item, strategy, lazyDepth, false, false);
697
+ const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false);
694
698
  if (!itemRequired) {
695
699
  required = false;
696
700
  if (itemJson !== this.unsupportedJsonSchema) {
@@ -710,7 +714,7 @@ class ZodToJsonSchemaConverter {
710
714
  const allOf = [];
711
715
  let required = false;
712
716
  for (const item of [schema_._def.left, schema_._def.right]) {
713
- const [itemRequired, itemJson] = this.convert(item, strategy, lazyDepth, false, false);
717
+ const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false);
714
718
  allOf.push(itemJson);
715
719
  if (itemRequired) {
716
720
  required = true;
@@ -723,42 +727,43 @@ class ZodToJsonSchemaConverter {
723
727
  return [false, this.anyJsonSchema];
724
728
  }
725
729
  const schema_ = schema;
726
- return this.convert(schema_._def.getter(), strategy, lazyDepth + 1, false, false);
730
+ return this.convert(schema_._def.getter(), options, lazyDepth + 1, false, false);
727
731
  }
728
732
  case ZodFirstPartyTypeKind.ZodOptional: {
729
733
  const schema_ = schema;
730
- const [_, inner] = this.convert(schema_._def.innerType, strategy, lazyDepth, false, false);
734
+ const [_, inner] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
731
735
  return [false, inner];
732
736
  }
733
737
  case ZodFirstPartyTypeKind.ZodReadonly: {
734
738
  const schema_ = schema;
735
- return this.convert(schema_._def.innerType, strategy, lazyDepth, false, false);
739
+ const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
740
+ return [required, { ...json, readOnly: true }];
736
741
  }
737
742
  case ZodFirstPartyTypeKind.ZodDefault: {
738
743
  const schema_ = schema;
739
- const [_, json] = this.convert(schema_._def.innerType, strategy, lazyDepth, false, false);
744
+ const [_, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
740
745
  return [false, { default: schema_._def.defaultValue(), ...json }];
741
746
  }
742
747
  case ZodFirstPartyTypeKind.ZodEffects: {
743
748
  const schema_ = schema;
744
- if (schema_._def.effect.type === "transform" && strategy === "output") {
749
+ if (schema_._def.effect.type === "transform" && options.strategy === "output") {
745
750
  return [false, this.anyJsonSchema];
746
751
  }
747
- return this.convert(schema_._def.schema, strategy, lazyDepth, false, false);
752
+ return this.convert(schema_._def.schema, options, lazyDepth, false, false);
748
753
  }
749
754
  case ZodFirstPartyTypeKind.ZodCatch: {
750
755
  const schema_ = schema;
751
- return this.convert(schema_._def.innerType, strategy, lazyDepth, false, false);
756
+ return this.convert(schema_._def.innerType, options, lazyDepth, false, false);
752
757
  }
753
758
  case ZodFirstPartyTypeKind.ZodBranded: {
754
759
  const schema_ = schema;
755
- return this.convert(schema_._def.type, strategy, lazyDepth, false, false);
760
+ return this.convert(schema_._def.type, options, lazyDepth, false, false);
756
761
  }
757
762
  case ZodFirstPartyTypeKind.ZodPipeline: {
758
763
  const schema_ = schema;
759
764
  return this.convert(
760
- strategy === "input" ? schema_._def.in : schema_._def.out,
761
- strategy,
765
+ options.strategy === "input" ? schema_._def.in : schema_._def.out,
766
+ options,
762
767
  lazyDepth,
763
768
  false,
764
769
  false
@@ -766,13 +771,13 @@ class ZodToJsonSchemaConverter {
766
771
  }
767
772
  case ZodFirstPartyTypeKind.ZodNullable: {
768
773
  const schema_ = schema;
769
- const [required, json] = this.convert(schema_._def.innerType, strategy, lazyDepth, false, false);
774
+ const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
770
775
  return [required, { anyOf: [{ type: "null" }, json] }];
771
776
  }
772
777
  }
773
778
  return [true, this.unsupportedJsonSchema];
774
779
  }
775
- handleCustomZodDef(def) {
780
+ #handleCustomZodDef(def) {
776
781
  const customZodDef = getCustomZodDef(def);
777
782
  if (!customZodDef) {
778
783
  return void 0;
@@ -795,10 +800,10 @@ class ZodToJsonSchemaConverter {
795
800
  }
796
801
  }
797
802
  }
798
- getZodTypeName(def) {
803
+ #getZodTypeName(def) {
799
804
  return def.typeName;
800
805
  }
801
- toArrayItemJsonSchema(required, schema, strategy) {
806
+ #toArrayItemJsonSchema(required, schema, strategy) {
802
807
  if (required) {
803
808
  return schema;
804
809
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/zod",
3
3
  "type": "module",
4
- "version": "0.0.0-next.1431467",
4
+ "version": "0.0.0-next.15d9202",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -24,15 +24,15 @@
24
24
  "dist"
25
25
  ],
26
26
  "peerDependencies": {
27
- "@orpc/contract": "0.0.0-next.1431467",
28
- "@orpc/server": "0.0.0-next.1431467"
27
+ "@orpc/contract": "0.0.0-next.15d9202",
28
+ "@orpc/server": "0.0.0-next.15d9202"
29
29
  },
30
30
  "dependencies": {
31
31
  "escape-string-regexp": "^5.0.0",
32
32
  "wildcard-match": "^5.1.3",
33
33
  "zod": "^3.24.2",
34
- "@orpc/openapi": "0.0.0-next.1431467",
35
- "@orpc/shared": "0.0.0-next.1431467"
34
+ "@orpc/openapi": "0.0.0-next.15d9202",
35
+ "@orpc/shared": "0.0.0-next.15d9202"
36
36
  },
37
37
  "devDependencies": {
38
38
  "zod-to-json-schema": "^3.24.3"