@orpc/zod 0.0.0-next.18dad53 → 0.0.0-next.19c2a69
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/zod4/index.d.mts +3 -3
- package/dist/zod4/index.d.ts +3 -3
- package/dist/zod4/index.mjs +22 -22
- package/package.json +5 -5
package/dist/zod4/index.d.mts
CHANGED
@@ -2,7 +2,7 @@ import { Context } from '@orpc/server';
|
|
2
2
|
import { StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
|
3
3
|
import { AnySchema } from '@orpc/contract';
|
4
4
|
import { JSONSchema, SchemaConvertOptions, ConditionalSchemaConverter } from '@orpc/openapi';
|
5
|
-
import { Interceptor
|
5
|
+
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
|
|
@@ -46,7 +46,7 @@ interface experimental_ZodToJsonSchemaOptions {
|
|
46
46
|
}, [
|
47
47
|
required: boolean,
|
48
48
|
jsonSchema: Exclude<JSONSchema, boolean>
|
49
|
-
]
|
49
|
+
]>[];
|
50
50
|
}
|
51
51
|
declare class experimental_ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
|
52
52
|
#private;
|
@@ -57,7 +57,7 @@ declare class experimental_ZodToJsonSchemaConverter implements ConditionalSchema
|
|
57
57
|
private readonly interceptors;
|
58
58
|
constructor(options?: experimental_ZodToJsonSchemaOptions);
|
59
59
|
condition(schema: AnySchema | undefined): boolean;
|
60
|
-
convert(schema: AnySchema | undefined, options: SchemaConvertOptions):
|
60
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
|
61
61
|
}
|
62
62
|
|
63
63
|
/**
|
package/dist/zod4/index.d.ts
CHANGED
@@ -2,7 +2,7 @@ import { Context } from '@orpc/server';
|
|
2
2
|
import { StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
|
3
3
|
import { AnySchema } from '@orpc/contract';
|
4
4
|
import { JSONSchema, SchemaConvertOptions, ConditionalSchemaConverter } from '@orpc/openapi';
|
5
|
-
import { Interceptor
|
5
|
+
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
|
|
@@ -46,7 +46,7 @@ interface experimental_ZodToJsonSchemaOptions {
|
|
46
46
|
}, [
|
47
47
|
required: boolean,
|
48
48
|
jsonSchema: Exclude<JSONSchema, boolean>
|
49
|
-
]
|
49
|
+
]>[];
|
50
50
|
}
|
51
51
|
declare class experimental_ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
|
52
52
|
#private;
|
@@ -57,7 +57,7 @@ declare class experimental_ZodToJsonSchemaConverter implements ConditionalSchema
|
|
57
57
|
private readonly interceptors;
|
58
58
|
constructor(options?: experimental_ZodToJsonSchemaOptions);
|
59
59
|
condition(schema: AnySchema | undefined): boolean;
|
60
|
-
convert(schema: AnySchema | undefined, options: SchemaConvertOptions):
|
60
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
|
61
61
|
}
|
62
62
|
|
63
63
|
/**
|
package/dist/zod4/index.mjs
CHANGED
@@ -308,11 +308,11 @@ class experimental_ZodToJsonSchemaConverter {
|
|
308
308
|
return intercept(
|
309
309
|
this.interceptors,
|
310
310
|
{ schema, options, lazyDepth, isHandledCustomJSONSchema },
|
311
|
-
|
311
|
+
({ schema: schema2, options: options2, lazyDepth: lazyDepth2, isHandledCustomJSONSchema: isHandledCustomJSONSchema2 }) => {
|
312
312
|
if (!isHandledCustomJSONSchema2) {
|
313
313
|
const customJSONSchema = this.#getCustomJsonSchema(schema2, options2);
|
314
314
|
if (customJSONSchema) {
|
315
|
-
const [required, json] =
|
315
|
+
const [required, json] = this.#convert(schema2, options2, lazyDepth2, true);
|
316
316
|
return [required, { ...json, ...customJSONSchema }];
|
317
317
|
}
|
318
318
|
}
|
@@ -400,14 +400,14 @@ class experimental_ZodToJsonSchemaConverter {
|
|
400
400
|
if (typeof maximum === "number") {
|
401
401
|
json.maxItems = maximum;
|
402
402
|
}
|
403
|
-
json.items = this.#handleArrayItemJsonSchema(
|
403
|
+
json.items = this.#handleArrayItemJsonSchema(this.#convert(array._zod.def.element, options2, lazyDepth2), options2);
|
404
404
|
return [true, json];
|
405
405
|
}
|
406
406
|
case "object": {
|
407
407
|
const object = schema2;
|
408
408
|
const json = { type: "object" };
|
409
409
|
for (const [key, value] of Object.entries(object._zod.def.shape)) {
|
410
|
-
const [itemRequired, itemJson] =
|
410
|
+
const [itemRequired, itemJson] = this.#convert(value, options2, lazyDepth2);
|
411
411
|
json.properties ??= {};
|
412
412
|
json.properties[key] = itemJson;
|
413
413
|
if (itemRequired) {
|
@@ -419,7 +419,7 @@ class experimental_ZodToJsonSchemaConverter {
|
|
419
419
|
if (object._zod.def.catchall._zod.def.type === "never") {
|
420
420
|
json.additionalProperties = false;
|
421
421
|
} else {
|
422
|
-
const [_, addJson] =
|
422
|
+
const [_, addJson] = this.#convert(object._zod.def.catchall, options2, lazyDepth2);
|
423
423
|
json.additionalProperties = addJson;
|
424
424
|
}
|
425
425
|
}
|
@@ -430,7 +430,7 @@ class experimental_ZodToJsonSchemaConverter {
|
|
430
430
|
const anyOf = [];
|
431
431
|
let required = true;
|
432
432
|
for (const item of union._zod.def.options) {
|
433
|
-
const [itemRequired, itemJson] =
|
433
|
+
const [itemRequired, itemJson] = this.#convert(item, options2, lazyDepth2);
|
434
434
|
if (!itemRequired) {
|
435
435
|
required = false;
|
436
436
|
}
|
@@ -451,7 +451,7 @@ class experimental_ZodToJsonSchemaConverter {
|
|
451
451
|
const json = { allOf: [] };
|
452
452
|
let required = false;
|
453
453
|
for (const item of [intersection._zod.def.left, intersection._zod.def.right]) {
|
454
|
-
const [itemRequired, itemJson] =
|
454
|
+
const [itemRequired, itemJson] = this.#convert(item, options2, lazyDepth2);
|
455
455
|
json.allOf.push(itemJson);
|
456
456
|
if (itemRequired) {
|
457
457
|
required = true;
|
@@ -463,10 +463,10 @@ class experimental_ZodToJsonSchemaConverter {
|
|
463
463
|
const tuple = schema2;
|
464
464
|
const json = { type: "array", prefixItems: [] };
|
465
465
|
for (const item of tuple._zod.def.items) {
|
466
|
-
json.prefixItems.push(this.#handleArrayItemJsonSchema(
|
466
|
+
json.prefixItems.push(this.#handleArrayItemJsonSchema(this.#convert(item, options2, lazyDepth2), options2));
|
467
467
|
}
|
468
468
|
if (tuple._zod.def.rest) {
|
469
|
-
json.items = this.#handleArrayItemJsonSchema(
|
469
|
+
json.items = this.#handleArrayItemJsonSchema(this.#convert(tuple._zod.def.rest, options2, lazyDepth2), options2);
|
470
470
|
}
|
471
471
|
const { minimum, maximum } = tuple._zod.bag;
|
472
472
|
if (typeof minimum === "number") {
|
@@ -480,8 +480,8 @@ class experimental_ZodToJsonSchemaConverter {
|
|
480
480
|
case "record": {
|
481
481
|
const record = schema2;
|
482
482
|
const json = { type: "object" };
|
483
|
-
json.propertyNames =
|
484
|
-
json.additionalProperties =
|
483
|
+
json.propertyNames = this.#convert(record._zod.def.keyType, options2, lazyDepth2)[1];
|
484
|
+
json.additionalProperties = this.#convert(record._zod.def.valueType, options2, lazyDepth2)[1];
|
485
485
|
return [true, json];
|
486
486
|
}
|
487
487
|
case "map": {
|
@@ -491,8 +491,8 @@ class experimental_ZodToJsonSchemaConverter {
|
|
491
491
|
items: {
|
492
492
|
type: "array",
|
493
493
|
prefixItems: [
|
494
|
-
this.#handleArrayItemJsonSchema(
|
495
|
-
this.#handleArrayItemJsonSchema(
|
494
|
+
this.#handleArrayItemJsonSchema(this.#convert(map._zod.def.keyType, options2, lazyDepth2), options2),
|
495
|
+
this.#handleArrayItemJsonSchema(this.#convert(map._zod.def.valueType, options2, lazyDepth2), options2)
|
496
496
|
],
|
497
497
|
maxItems: 2,
|
498
498
|
minItems: 2
|
@@ -504,7 +504,7 @@ class experimental_ZodToJsonSchemaConverter {
|
|
504
504
|
return [true, {
|
505
505
|
type: "array",
|
506
506
|
uniqueItems: true,
|
507
|
-
items: this.#handleArrayItemJsonSchema(
|
507
|
+
items: this.#handleArrayItemJsonSchema(this.#convert(set._zod.def.valueType, options2, lazyDepth2), options2)
|
508
508
|
}];
|
509
509
|
}
|
510
510
|
case "enum": {
|
@@ -544,12 +544,12 @@ class experimental_ZodToJsonSchemaConverter {
|
|
544
544
|
}
|
545
545
|
case "nullable": {
|
546
546
|
const nullable = schema2;
|
547
|
-
const [required, json] =
|
547
|
+
const [required, json] = this.#convert(nullable._zod.def.innerType, options2, lazyDepth2);
|
548
548
|
return [required, { anyOf: [json, { type: "null" }] }];
|
549
549
|
}
|
550
550
|
case "nonoptional": {
|
551
551
|
const nonoptional = schema2;
|
552
|
-
const [, json] =
|
552
|
+
const [, json] = this.#convert(nonoptional._zod.def.innerType, options2, lazyDepth2);
|
553
553
|
return [true, json];
|
554
554
|
}
|
555
555
|
case "success": {
|
@@ -558,7 +558,7 @@ class experimental_ZodToJsonSchemaConverter {
|
|
558
558
|
case "default":
|
559
559
|
case "prefault": {
|
560
560
|
const default_ = schema2;
|
561
|
-
const [, json] =
|
561
|
+
const [, json] = this.#convert(default_._zod.def.innerType, options2, lazyDepth2);
|
562
562
|
return [false, {
|
563
563
|
...json,
|
564
564
|
default: default_._zod.def.defaultValue
|
@@ -566,18 +566,18 @@ class experimental_ZodToJsonSchemaConverter {
|
|
566
566
|
}
|
567
567
|
case "catch": {
|
568
568
|
const catch_ = schema2;
|
569
|
-
return
|
569
|
+
return this.#convert(catch_._zod.def.innerType, options2, lazyDepth2);
|
570
570
|
}
|
571
571
|
case "nan": {
|
572
572
|
return [true, options2.strategy === "input" ? this.unsupportedJsonSchema : { type: "null" }];
|
573
573
|
}
|
574
574
|
case "pipe": {
|
575
575
|
const pipe = schema2;
|
576
|
-
return
|
576
|
+
return this.#convert(options2.strategy === "input" ? pipe._zod.def.in : pipe._zod.def.out, options2, lazyDepth2);
|
577
577
|
}
|
578
578
|
case "readonly": {
|
579
579
|
const readonly_ = schema2;
|
580
|
-
const [required, json] =
|
580
|
+
const [required, json] = this.#convert(readonly_._zod.def.innerType, options2, lazyDepth2);
|
581
581
|
return [required, { ...json, readOnly: true }];
|
582
582
|
}
|
583
583
|
case "template_literal": {
|
@@ -589,7 +589,7 @@ class experimental_ZodToJsonSchemaConverter {
|
|
589
589
|
}
|
590
590
|
case "optional": {
|
591
591
|
const optional = schema2;
|
592
|
-
const [, json] =
|
592
|
+
const [, json] = this.#convert(optional._zod.def.innerType, options2, lazyDepth2);
|
593
593
|
return [false, json];
|
594
594
|
}
|
595
595
|
case "lazy": {
|
@@ -597,7 +597,7 @@ class experimental_ZodToJsonSchemaConverter {
|
|
597
597
|
if (lazyDepth2 >= this.maxLazyDepth) {
|
598
598
|
return [false, this.anyJsonSchema];
|
599
599
|
}
|
600
|
-
return
|
600
|
+
return this.#convert(lazy._zod.def.getter(), options2, lazyDepth2 + 1);
|
601
601
|
}
|
602
602
|
default: {
|
603
603
|
schema2._zod.def.type;
|
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.19c2a69",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -30,14 +30,14 @@
|
|
30
30
|
],
|
31
31
|
"peerDependencies": {
|
32
32
|
"zod": ">=3.24.2",
|
33
|
-
"@orpc/contract": "0.0.0-next.
|
34
|
-
"@orpc/server": "0.0.0-next.
|
33
|
+
"@orpc/contract": "0.0.0-next.19c2a69",
|
34
|
+
"@orpc/server": "0.0.0-next.19c2a69"
|
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.
|
40
|
-
"@orpc/shared": "0.0.0-next.
|
39
|
+
"@orpc/openapi": "0.0.0-next.19c2a69",
|
40
|
+
"@orpc/shared": "0.0.0-next.19c2a69"
|
41
41
|
},
|
42
42
|
"devDependencies": {
|
43
43
|
"zod": "^3.25.11",
|