@orpc/zod 0.0.0-next.93fa264 → 0.0.0-next.94096b2
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 +4 -4
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +35 -15
- package/dist/zod4/index.d.mts +11 -8
- package/dist/zod4/index.d.ts +11 -8
- package/dist/zod4/index.mjs +33 -21
- package/package.json +8 -8
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.
|
@@ -72,7 +72,7 @@ More schemas that [Zod](https://zod.dev/) doesn't support yet, and provides `Zod
|
|
72
72
|
|
73
73
|
```ts
|
74
74
|
import { oz } from '@orpc/zod'
|
75
|
-
import { z } from 'zod'
|
75
|
+
import { z } from 'zod/v3'
|
76
76
|
|
77
77
|
const Example = z.object({
|
78
78
|
url: oz.url(),
|
@@ -86,7 +86,7 @@ const Example = z.object({
|
|
86
86
|
|
87
87
|
```ts
|
88
88
|
import { OpenAPIGenerator } from '@orpc/openapi'
|
89
|
-
import { ZodToJsonSchemaConverter } from '@orpc/zod'
|
89
|
+
import { ZodToJsonSchemaConverter } from '@orpc/zod/zod4'
|
90
90
|
|
91
91
|
const openAPIGenerator = new OpenAPIGenerator({
|
92
92
|
schemaConverters: [new ZodToJsonSchemaConverter()],
|
@@ -111,7 +111,7 @@ const specFromRouter = await openAPIGenerator.generate(router, {
|
|
111
111
|
|
112
112
|
```ts
|
113
113
|
import { oz } from '@orpc/zod'
|
114
|
-
import
|
114
|
+
import * as z from 'zod'
|
115
115
|
|
116
116
|
const InputSchema = oz.openapi(
|
117
117
|
z.object({
|
package/dist/index.d.mts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { JSONSchema, ConditionalSchemaConverter, SchemaConvertOptions } from '@orpc/openapi';
|
2
|
-
import { ZodTypeAny, input, output, ZodTypeDef, CustomErrorParams, ZodType, ZodEffects } from 'zod';
|
2
|
+
import { ZodTypeAny, input, output, ZodTypeDef, CustomErrorParams, ZodType, ZodEffects } from 'zod/v3';
|
3
3
|
import { Context } from '@orpc/server';
|
4
4
|
import { StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
|
5
5
|
import { AnySchema } from '@orpc/contract';
|
package/dist/index.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import { JSONSchema, ConditionalSchemaConverter, SchemaConvertOptions } from '@orpc/openapi';
|
2
|
-
import { ZodTypeAny, input, output, ZodTypeDef, CustomErrorParams, ZodType, ZodEffects } from 'zod';
|
2
|
+
import { ZodTypeAny, input, output, ZodTypeDef, CustomErrorParams, ZodType, ZodEffects } from 'zod/v3';
|
3
3
|
import { Context } from '@orpc/server';
|
4
4
|
import { StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
|
5
5
|
import { AnySchema } from '@orpc/contract';
|
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
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);
|
@@ -400,7 +401,7 @@ class ZodToJsonSchemaConverter {
|
|
400
401
|
this.anyJsonSchema = options.anyJsonSchema ?? {};
|
401
402
|
}
|
402
403
|
condition(schema) {
|
403
|
-
return schema !== void 0 && schema["~standard"].vendor === "zod";
|
404
|
+
return schema !== void 0 && schema["~standard"].vendor === "zod" && !("_zod" in schema);
|
404
405
|
}
|
405
406
|
convert(schema, options, lazyDepth = 0, isHandledCustomJSONSchema = false, isHandledZodDescription = false, structureDepth = 0) {
|
406
407
|
const def = schema._def;
|
@@ -563,7 +564,11 @@ class ZodToJsonSchemaConverter {
|
|
563
564
|
return [true, json];
|
564
565
|
}
|
565
566
|
case ZodFirstPartyTypeKind.ZodBigInt: {
|
566
|
-
const json = {
|
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 = {
|
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 = {
|
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
|
-
|
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: {
|
@@ -789,7 +804,7 @@ class ZodToJsonSchemaConverter {
|
|
789
804
|
case ZodFirstPartyTypeKind.ZodNullable: {
|
790
805
|
const schema_ = schema;
|
791
806
|
const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
|
792
|
-
return [required, { anyOf: [{ type: "null" }
|
807
|
+
return [required, { anyOf: [json, { type: "null" }] }];
|
793
808
|
}
|
794
809
|
}
|
795
810
|
return [true, this.unsupportedJsonSchema];
|
@@ -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 {
|
832
|
+
return {
|
833
|
+
"type": "string",
|
834
|
+
"format": JSONSchemaFormat.URI,
|
835
|
+
"x-native-type": JsonSchemaXNativeType.Url
|
836
|
+
};
|
817
837
|
}
|
818
838
|
}
|
819
839
|
}
|
package/dist/zod4/index.d.mts
CHANGED
@@ -6,12 +6,15 @@ 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;
|
12
15
|
}
|
13
16
|
|
14
|
-
interface
|
17
|
+
interface ZodToJsonSchemaConverterOptions {
|
15
18
|
/**
|
16
19
|
* Max depth of lazy type.
|
17
20
|
*
|
@@ -56,7 +59,7 @@ interface experimental_ZodToJsonSchemaOptions {
|
|
56
59
|
jsonSchema: Exclude<JSONSchema, boolean>
|
57
60
|
]>[];
|
58
61
|
}
|
59
|
-
declare class
|
62
|
+
declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
|
60
63
|
#private;
|
61
64
|
private readonly maxLazyDepth;
|
62
65
|
private readonly maxStructureDepth;
|
@@ -64,7 +67,7 @@ declare class experimental_ZodToJsonSchemaConverter implements ConditionalSchema
|
|
64
67
|
private readonly unsupportedJsonSchema;
|
65
68
|
private readonly undefinedJsonSchema;
|
66
69
|
private readonly interceptors;
|
67
|
-
constructor(options?:
|
70
|
+
constructor(options?: ZodToJsonSchemaConverterOptions);
|
68
71
|
condition(schema: AnySchema | undefined): boolean;
|
69
72
|
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
|
70
73
|
}
|
@@ -86,7 +89,7 @@ declare class experimental_ZodToJsonSchemaConverter implements ConditionalSchema
|
|
86
89
|
* })
|
87
90
|
* ```
|
88
91
|
*/
|
89
|
-
declare const
|
92
|
+
declare const JSON_SCHEMA_REGISTRY: zod_v4_core.$ZodRegistry<{
|
90
93
|
$anchor?: string;
|
91
94
|
$comment?: string;
|
92
95
|
$defs?: Record<string, JSONSchema>;
|
@@ -165,7 +168,7 @@ declare const experimental_JSON_SCHEMA_REGISTRY: zod_v4_core.$ZodRegistry<{
|
|
165
168
|
* })
|
166
169
|
* ```
|
167
170
|
*/
|
168
|
-
declare const
|
171
|
+
declare const JSON_SCHEMA_INPUT_REGISTRY: zod_v4_core.$ZodRegistry<{
|
169
172
|
$anchor?: string;
|
170
173
|
$comment?: string;
|
171
174
|
$defs?: Record<string, JSONSchema>;
|
@@ -244,7 +247,7 @@ declare const experimental_JSON_SCHEMA_INPUT_REGISTRY: zod_v4_core.$ZodRegistry<
|
|
244
247
|
* })
|
245
248
|
* ```
|
246
249
|
*/
|
247
|
-
declare const
|
250
|
+
declare const JSON_SCHEMA_OUTPUT_REGISTRY: zod_v4_core.$ZodRegistry<{
|
248
251
|
$anchor?: string;
|
249
252
|
$comment?: string;
|
250
253
|
$defs?: Record<string, JSONSchema>;
|
@@ -307,5 +310,5 @@ declare const experimental_JSON_SCHEMA_OUTPUT_REGISTRY: zod_v4_core.$ZodRegistry
|
|
307
310
|
writeOnly?: boolean;
|
308
311
|
}, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
|
309
312
|
|
310
|
-
export {
|
311
|
-
export type {
|
313
|
+
export { JSON_SCHEMA_INPUT_REGISTRY, JSON_SCHEMA_OUTPUT_REGISTRY, JSON_SCHEMA_REGISTRY, ZodToJsonSchemaConverter, experimental_ZodSmartCoercionPlugin };
|
314
|
+
export type { ZodToJsonSchemaConverterOptions };
|
package/dist/zod4/index.d.ts
CHANGED
@@ -6,12 +6,15 @@ 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;
|
12
15
|
}
|
13
16
|
|
14
|
-
interface
|
17
|
+
interface ZodToJsonSchemaConverterOptions {
|
15
18
|
/**
|
16
19
|
* Max depth of lazy type.
|
17
20
|
*
|
@@ -56,7 +59,7 @@ interface experimental_ZodToJsonSchemaOptions {
|
|
56
59
|
jsonSchema: Exclude<JSONSchema, boolean>
|
57
60
|
]>[];
|
58
61
|
}
|
59
|
-
declare class
|
62
|
+
declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
|
60
63
|
#private;
|
61
64
|
private readonly maxLazyDepth;
|
62
65
|
private readonly maxStructureDepth;
|
@@ -64,7 +67,7 @@ declare class experimental_ZodToJsonSchemaConverter implements ConditionalSchema
|
|
64
67
|
private readonly unsupportedJsonSchema;
|
65
68
|
private readonly undefinedJsonSchema;
|
66
69
|
private readonly interceptors;
|
67
|
-
constructor(options?:
|
70
|
+
constructor(options?: ZodToJsonSchemaConverterOptions);
|
68
71
|
condition(schema: AnySchema | undefined): boolean;
|
69
72
|
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
|
70
73
|
}
|
@@ -86,7 +89,7 @@ declare class experimental_ZodToJsonSchemaConverter implements ConditionalSchema
|
|
86
89
|
* })
|
87
90
|
* ```
|
88
91
|
*/
|
89
|
-
declare const
|
92
|
+
declare const JSON_SCHEMA_REGISTRY: zod_v4_core.$ZodRegistry<{
|
90
93
|
$anchor?: string;
|
91
94
|
$comment?: string;
|
92
95
|
$defs?: Record<string, JSONSchema>;
|
@@ -165,7 +168,7 @@ declare const experimental_JSON_SCHEMA_REGISTRY: zod_v4_core.$ZodRegistry<{
|
|
165
168
|
* })
|
166
169
|
* ```
|
167
170
|
*/
|
168
|
-
declare const
|
171
|
+
declare const JSON_SCHEMA_INPUT_REGISTRY: zod_v4_core.$ZodRegistry<{
|
169
172
|
$anchor?: string;
|
170
173
|
$comment?: string;
|
171
174
|
$defs?: Record<string, JSONSchema>;
|
@@ -244,7 +247,7 @@ declare const experimental_JSON_SCHEMA_INPUT_REGISTRY: zod_v4_core.$ZodRegistry<
|
|
244
247
|
* })
|
245
248
|
* ```
|
246
249
|
*/
|
247
|
-
declare const
|
250
|
+
declare const JSON_SCHEMA_OUTPUT_REGISTRY: zod_v4_core.$ZodRegistry<{
|
248
251
|
$anchor?: string;
|
249
252
|
$comment?: string;
|
250
253
|
$defs?: Record<string, JSONSchema>;
|
@@ -307,5 +310,5 @@ declare const experimental_JSON_SCHEMA_OUTPUT_REGISTRY: zod_v4_core.$ZodRegistry
|
|
307
310
|
writeOnly?: boolean;
|
308
311
|
}, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
|
309
312
|
|
310
|
-
export {
|
311
|
-
export type {
|
313
|
+
export { JSON_SCHEMA_INPUT_REGISTRY, JSON_SCHEMA_OUTPUT_REGISTRY, JSON_SCHEMA_REGISTRY, ZodToJsonSchemaConverter, experimental_ZodSmartCoercionPlugin };
|
314
|
+
export type { ZodToJsonSchemaConverterOptions };
|
package/dist/zod4/index.mjs
CHANGED
@@ -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
|
|
@@ -7,7 +8,7 @@ class experimental_ZodSmartCoercionPlugin {
|
|
7
8
|
options.clientInterceptors ??= [];
|
8
9
|
options.clientInterceptors.unshift((options2) => {
|
9
10
|
const inputSchema = options2.procedure["~orpc"].inputSchema;
|
10
|
-
if (!inputSchema || inputSchema["~standard"].vendor !== "zod") {
|
11
|
+
if (!inputSchema || inputSchema["~standard"].vendor !== "zod" || !("_zod" in inputSchema)) {
|
11
12
|
return options2.next();
|
12
13
|
}
|
13
14
|
const coercedInput = this.#coerce(inputSchema, options2.input);
|
@@ -268,11 +269,11 @@ class experimental_ZodSmartCoercionPlugin {
|
|
268
269
|
}
|
269
270
|
}
|
270
271
|
|
271
|
-
const
|
272
|
-
const
|
273
|
-
const
|
272
|
+
const JSON_SCHEMA_REGISTRY = registry();
|
273
|
+
const JSON_SCHEMA_INPUT_REGISTRY = registry();
|
274
|
+
const JSON_SCHEMA_OUTPUT_REGISTRY = registry();
|
274
275
|
|
275
|
-
class
|
276
|
+
class ZodToJsonSchemaConverter {
|
276
277
|
maxLazyDepth;
|
277
278
|
maxStructureDepth;
|
278
279
|
anyJsonSchema;
|
@@ -288,7 +289,7 @@ class experimental_ZodToJsonSchemaConverter {
|
|
288
289
|
this.interceptors = options.interceptors ?? [];
|
289
290
|
}
|
290
291
|
condition(schema) {
|
291
|
-
return schema !== void 0 && schema["~standard"].vendor === "zod";
|
292
|
+
return schema !== void 0 && schema["~standard"].vendor === "zod" && "_zod" in schema;
|
292
293
|
}
|
293
294
|
convert(schema, options) {
|
294
295
|
return this.#convert(schema, options, 0, 0);
|
@@ -376,10 +377,18 @@ class experimental_ZodToJsonSchemaConverter {
|
|
376
377
|
return [true, { type: "boolean" }];
|
377
378
|
}
|
378
379
|
case "bigint": {
|
379
|
-
return [true, {
|
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, {
|
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": {
|
@@ -616,18 +627,19 @@ class experimental_ZodToJsonSchemaConverter {
|
|
616
627
|
);
|
617
628
|
}
|
618
629
|
#getCustomJsonSchema(schema, options) {
|
619
|
-
if (options.strategy === "input" &&
|
620
|
-
return
|
630
|
+
if (options.strategy === "input" && JSON_SCHEMA_INPUT_REGISTRY.has(schema)) {
|
631
|
+
return JSON_SCHEMA_INPUT_REGISTRY.get(schema);
|
621
632
|
}
|
622
|
-
if (options.strategy === "output" &&
|
623
|
-
return
|
633
|
+
if (options.strategy === "output" && JSON_SCHEMA_OUTPUT_REGISTRY.has(schema)) {
|
634
|
+
return JSON_SCHEMA_OUTPUT_REGISTRY.get(schema);
|
624
635
|
}
|
625
|
-
if (
|
626
|
-
return
|
636
|
+
if (JSON_SCHEMA_REGISTRY.has(schema)) {
|
637
|
+
return JSON_SCHEMA_REGISTRY.get(schema);
|
627
638
|
}
|
628
639
|
const global = globalRegistry.get(schema);
|
629
640
|
if (global) {
|
630
641
|
return {
|
642
|
+
title: global.title,
|
631
643
|
description: global.description,
|
632
644
|
examples: Array.isArray(global.examples) ? global.examples : void 0
|
633
645
|
};
|
@@ -665,4 +677,4 @@ class experimental_ZodToJsonSchemaConverter {
|
|
665
677
|
}
|
666
678
|
}
|
667
679
|
|
668
|
-
export {
|
680
|
+
export { JSON_SCHEMA_INPUT_REGISTRY, JSON_SCHEMA_OUTPUT_REGISTRY, JSON_SCHEMA_REGISTRY, ZodToJsonSchemaConverter, experimental_ZodSmartCoercionPlugin };
|
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.
|
4
|
+
"version": "0.0.0-next.94096b2",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -29,19 +29,19 @@
|
|
29
29
|
"dist"
|
30
30
|
],
|
31
31
|
"peerDependencies": {
|
32
|
-
"zod": ">=3.
|
33
|
-
"@orpc/contract": "0.0.0-next.
|
34
|
-
"@orpc/server": "0.0.0-next.
|
32
|
+
"zod": ">=3.25.0",
|
33
|
+
"@orpc/contract": "0.0.0-next.94096b2",
|
34
|
+
"@orpc/server": "0.0.0-next.94096b2"
|
35
35
|
},
|
36
36
|
"dependencies": {
|
37
37
|
"escape-string-regexp": "^5.0.0",
|
38
38
|
"wildcard-match": "^5.1.3",
|
39
|
-
"@orpc/
|
40
|
-
"@orpc/
|
39
|
+
"@orpc/json-schema": "0.0.0-next.94096b2",
|
40
|
+
"@orpc/openapi": "0.0.0-next.94096b2",
|
41
|
+
"@orpc/shared": "0.0.0-next.94096b2"
|
41
42
|
},
|
42
43
|
"devDependencies": {
|
43
|
-
"zod": "^
|
44
|
-
"zod-to-json-schema": "^3.24.5"
|
44
|
+
"zod": "^4.0.5"
|
45
45
|
},
|
46
46
|
"scripts": {
|
47
47
|
"build": "unbuild",
|