@orpc/zod 0.0.0-next.dda04c5 → 0.0.0-next.de7ca70

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
1
  import { custom, ZodFirstPartyTypeKind } from 'zod';
2
2
  import wcmatch from 'wildcard-match';
3
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
 
@@ -563,7 +564,11 @@ class ZodToJsonSchemaConverter {
563
564
  return [true, json];
564
565
  }
565
566
  case ZodFirstPartyTypeKind.ZodBigInt: {
566
- const json = { type: "string", pattern: "^-?[0-9]+$" };
567
+ const json = {
568
+ "type": "string",
569
+ "pattern": "^-?[0-9]+$",
570
+ "x-native-type": JsonSchemaXNativeType.BigInt
571
+ };
567
572
  return [true, json];
568
573
  }
569
574
  case ZodFirstPartyTypeKind.ZodNaN: {
@@ -573,7 +578,11 @@ class ZodToJsonSchemaConverter {
573
578
  return [true, { type: "boolean" }];
574
579
  }
575
580
  case ZodFirstPartyTypeKind.ZodDate: {
576
- const schema2 = { type: "string", format: JSONSchemaFormat.DateTime };
581
+ const schema2 = {
582
+ "type": "string",
583
+ "format": JSONSchemaFormat.DateTime,
584
+ "x-native-type": JsonSchemaXNativeType.Date
585
+ };
577
586
  return [true, schema2];
578
587
  }
579
588
  case ZodFirstPartyTypeKind.ZodNull: {
@@ -681,7 +690,11 @@ class ZodToJsonSchemaConverter {
681
690
  }
682
691
  case ZodFirstPartyTypeKind.ZodSet: {
683
692
  const schema_ = schema;
684
- const json = { type: "array", uniqueItems: true };
693
+ const json = {
694
+ "type": "array",
695
+ "uniqueItems": true,
696
+ "x-native-type": JsonSchemaXNativeType.Set
697
+ };
685
698
  const [itemRequired, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false, structureDepth + 1);
686
699
  json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
687
700
  return [true, json];
@@ -690,9 +703,9 @@ class ZodToJsonSchemaConverter {
690
703
  const schema_ = schema;
691
704
  const [keyRequired, keyJson] = this.convert(schema_._def.keyType, options, lazyDepth, false, false, structureDepth + 1);
692
705
  const [valueRequired, valueJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false, structureDepth + 1);
693
- return [true, {
694
- type: "array",
695
- items: {
706
+ const json = {
707
+ "type": "array",
708
+ "items": {
696
709
  type: "array",
697
710
  prefixItems: [
698
711
  this.#toArrayItemJsonSchema(keyRequired, keyJson, options.strategy),
@@ -700,8 +713,10 @@ class ZodToJsonSchemaConverter {
700
713
  ],
701
714
  maxItems: 2,
702
715
  minItems: 2
703
- }
704
- }];
716
+ },
717
+ "x-native-type": JsonSchemaXNativeType.Map
718
+ };
719
+ return [true, json];
705
720
  }
706
721
  case ZodFirstPartyTypeKind.ZodUnion:
707
722
  case ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {
@@ -808,12 +823,17 @@ class ZodToJsonSchemaConverter {
808
823
  }
809
824
  case "regexp": {
810
825
  return {
811
- type: "string",
812
- pattern: "^\\/(.*)\\/([a-z]*)$"
826
+ "type": "string",
827
+ "pattern": "^\\/(.*)\\/([a-z]*)$",
828
+ "x-native-type": JsonSchemaXNativeType.RegExp
813
829
  };
814
830
  }
815
831
  case "url": {
816
- return { type: "string", format: JSONSchemaFormat.URI };
832
+ return {
833
+ "type": "string",
834
+ "format": JSONSchemaFormat.URI,
835
+ "x-native-type": JsonSchemaXNativeType.Url
836
+ };
817
837
  }
818
838
  }
819
839
  }
@@ -6,6 +6,9 @@ import { Interceptor } from '@orpc/shared';
6
6
  import * as zod_v4_core from 'zod/v4/core';
7
7
  import { $ZodType, $input, $output } from 'zod/v4/core';
8
8
 
9
+ /**
10
+ * @deprecated Use [Smart Coercion Plugin](https://orpc.unnoq.com/docs/openapi/plugins/smart-coercion) instead.
11
+ */
9
12
  declare class experimental_ZodSmartCoercionPlugin<TContext extends Context> implements StandardHandlerPlugin<TContext> {
10
13
  #private;
11
14
  init(options: StandardHandlerOptions<TContext>): void;
@@ -6,6 +6,9 @@ import { Interceptor } from '@orpc/shared';
6
6
  import * as zod_v4_core from 'zod/v4/core';
7
7
  import { $ZodType, $input, $output } from 'zod/v4/core';
8
8
 
9
+ /**
10
+ * @deprecated Use [Smart Coercion Plugin](https://orpc.unnoq.com/docs/openapi/plugins/smart-coercion) instead.
11
+ */
9
12
  declare class experimental_ZodSmartCoercionPlugin<TContext extends Context> implements StandardHandlerPlugin<TContext> {
10
13
  #private;
11
14
  init(options: StandardHandlerOptions<TContext>): void;
@@ -1,4 +1,5 @@
1
1
  import { isObject, guard, intercept, toArray } from '@orpc/shared';
2
+ import { JsonSchemaXNativeType } from '@orpc/json-schema';
2
3
  import { JSONSchemaFormat, JSONSchemaContentEncoding } from '@orpc/openapi';
3
4
  import { registry, globalRegistry } from 'zod/v4/core';
4
5
 
@@ -376,10 +377,18 @@ class experimental_ZodToJsonSchemaConverter {
376
377
  return [true, { type: "boolean" }];
377
378
  }
378
379
  case "bigint": {
379
- return [true, { type: "string", pattern: "^-?[0-9]+$" }];
380
+ return [true, {
381
+ "type": "string",
382
+ "pattern": "^-?[0-9]+$",
383
+ "x-native-type": JsonSchemaXNativeType.BigInt
384
+ }];
380
385
  }
381
386
  case "date": {
382
- return [true, { type: "string", format: JSONSchemaFormat.DateTime }];
387
+ return [true, {
388
+ "type": "string",
389
+ "format": JSONSchemaFormat.DateTime,
390
+ "x-native-type": JsonSchemaXNativeType.Date
391
+ }];
383
392
  }
384
393
  case "null": {
385
394
  return [true, { type: "null" }];
@@ -494,8 +503,8 @@ class experimental_ZodToJsonSchemaConverter {
494
503
  case "map": {
495
504
  const map = schema2;
496
505
  return [true, {
497
- type: "array",
498
- items: {
506
+ "type": "array",
507
+ "items": {
499
508
  type: "array",
500
509
  prefixItems: [
501
510
  this.#handleArrayItemJsonSchema(this.#convert(map._zod.def.keyType, options2, lazyDepth2, structureDepth + 1), options2),
@@ -503,15 +512,17 @@ class experimental_ZodToJsonSchemaConverter {
503
512
  ],
504
513
  maxItems: 2,
505
514
  minItems: 2
506
- }
515
+ },
516
+ "x-native-type": JsonSchemaXNativeType.Map
507
517
  }];
508
518
  }
509
519
  case "set": {
510
520
  const set = schema2;
511
521
  return [true, {
512
- type: "array",
513
- uniqueItems: true,
514
- items: this.#handleArrayItemJsonSchema(this.#convert(set._zod.def.valueType, options2, lazyDepth2, structureDepth + 1), options2)
522
+ "type": "array",
523
+ "uniqueItems": true,
524
+ "items": this.#handleArrayItemJsonSchema(this.#convert(set._zod.def.valueType, options2, lazyDepth2, structureDepth + 1), options2),
525
+ "x-native-type": JsonSchemaXNativeType.Set
515
526
  }];
516
527
  }
517
528
  case "enum": {
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.dda04c5",
4
+ "version": "0.0.0-next.de7ca70",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -30,17 +30,18 @@
30
30
  ],
31
31
  "peerDependencies": {
32
32
  "zod": ">=3.24.2",
33
- "@orpc/server": "0.0.0-next.dda04c5",
34
- "@orpc/contract": "0.0.0-next.dda04c5"
33
+ "@orpc/contract": "0.0.0-next.de7ca70",
34
+ "@orpc/server": "0.0.0-next.de7ca70"
35
35
  },
36
36
  "dependencies": {
37
37
  "escape-string-regexp": "^5.0.0",
38
38
  "wildcard-match": "^5.1.3",
39
- "@orpc/openapi": "0.0.0-next.dda04c5",
40
- "@orpc/shared": "0.0.0-next.dda04c5"
39
+ "@orpc/json-schema": "0.0.0-next.de7ca70",
40
+ "@orpc/shared": "0.0.0-next.de7ca70",
41
+ "@orpc/openapi": "0.0.0-next.de7ca70"
41
42
  },
42
43
  "devDependencies": {
43
- "zod": "^3.25.67",
44
+ "zod": "^3.25.76",
44
45
  "zod-to-json-schema": "^3.24.6"
45
46
  },
46
47
  "scripts": {