@orpc/zod 0.47.0 → 0.49.0
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 +5 -1
- package/dist/index.d.mts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.mjs +7 -2
- package/package.json +5 -5
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,9 +55,13 @@ 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.
|
63
|
+
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
64
|
+
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
61
65
|
|
62
66
|
## `@orpc/zod`
|
63
67
|
|
package/dist/index.d.mts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
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 {
|
4
|
+
import { HandlerPlugin } from '@orpc/server/plugins';
|
5
5
|
import { StandardHandlerOptions } from '@orpc/server/standard';
|
6
|
-
import {
|
6
|
+
import { AnySchema } from '@orpc/contract';
|
7
7
|
|
8
8
|
declare function getCustomJsonSchema(def: ZodTypeDef, options: {
|
9
9
|
strategy: 'input' | 'output' | 'both';
|
@@ -35,7 +35,7 @@ declare function regexp(params?: string | CustomParams | ((input: unknown) => Cu
|
|
35
35
|
|
36
36
|
declare function url(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<URL, ZodTypeDef, URL>;
|
37
37
|
|
38
|
-
declare class ZodSmartCoercionPlugin<TContext extends Context> implements
|
38
|
+
declare class ZodSmartCoercionPlugin<TContext extends Context> implements HandlerPlugin<TContext> {
|
39
39
|
init(options: StandardHandlerOptions<TContext>): void;
|
40
40
|
}
|
41
41
|
|
@@ -67,8 +67,8 @@ declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
|
|
67
67
|
private readonly unsupportedJsonSchema;
|
68
68
|
private readonly anyJsonSchema;
|
69
69
|
constructor(options?: ZodToJsonSchemaOptions);
|
70
|
-
condition(schema:
|
71
|
-
convert(schema:
|
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>];
|
72
72
|
}
|
73
73
|
|
74
74
|
declare const oz: {
|
package/dist/index.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
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 {
|
4
|
+
import { HandlerPlugin } from '@orpc/server/plugins';
|
5
5
|
import { StandardHandlerOptions } from '@orpc/server/standard';
|
6
|
-
import {
|
6
|
+
import { AnySchema } from '@orpc/contract';
|
7
7
|
|
8
8
|
declare function getCustomJsonSchema(def: ZodTypeDef, options: {
|
9
9
|
strategy: 'input' | 'output' | 'both';
|
@@ -35,7 +35,7 @@ declare function regexp(params?: string | CustomParams | ((input: unknown) => Cu
|
|
35
35
|
|
36
36
|
declare function url(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<URL, ZodTypeDef, URL>;
|
37
37
|
|
38
|
-
declare class ZodSmartCoercionPlugin<TContext extends Context> implements
|
38
|
+
declare class ZodSmartCoercionPlugin<TContext extends Context> implements HandlerPlugin<TContext> {
|
39
39
|
init(options: StandardHandlerOptions<TContext>): void;
|
40
40
|
}
|
41
41
|
|
@@ -67,8 +67,8 @@ declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
|
|
67
67
|
private readonly unsupportedJsonSchema;
|
68
68
|
private readonly anyJsonSchema;
|
69
69
|
constructor(options?: ZodToJsonSchemaOptions);
|
70
|
-
condition(schema:
|
71
|
-
convert(schema:
|
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>];
|
72
72
|
}
|
73
73
|
|
74
74
|
declare const oz: {
|
package/dist/index.mjs
CHANGED
@@ -398,7 +398,7 @@ class ZodToJsonSchemaConverter {
|
|
398
398
|
this.anyJsonSchema = options.anyJsonSchema ?? {};
|
399
399
|
}
|
400
400
|
condition(schema) {
|
401
|
-
return
|
401
|
+
return schema !== void 0 && schema["~standard"].vendor === "zod";
|
402
402
|
}
|
403
403
|
convert(schema, options, lazyDepth = 0, isHandledCustomJSONSchema = false, isHandledZodDescription = false) {
|
404
404
|
const def = schema._def;
|
@@ -656,6 +656,10 @@ class ZodToJsonSchemaConverter {
|
|
656
656
|
case ZodFirstPartyTypeKind.ZodRecord: {
|
657
657
|
const schema_ = schema;
|
658
658
|
const json = { type: "object" };
|
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
|
+
}
|
659
663
|
const [_, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false);
|
660
664
|
json.additionalProperties = itemJson;
|
661
665
|
return [true, json];
|
@@ -732,7 +736,8 @@ class ZodToJsonSchemaConverter {
|
|
732
736
|
}
|
733
737
|
case ZodFirstPartyTypeKind.ZodReadonly: {
|
734
738
|
const schema_ = schema;
|
735
|
-
|
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;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/zod",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.49.0",
|
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.
|
28
|
-
"@orpc/server": "0.
|
27
|
+
"@orpc/contract": "0.49.0",
|
28
|
+
"@orpc/server": "0.49.0"
|
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.
|
35
|
-
"@orpc/shared": "0.
|
34
|
+
"@orpc/openapi": "0.49.0",
|
35
|
+
"@orpc/shared": "0.49.0"
|
36
36
|
},
|
37
37
|
"devDependencies": {
|
38
38
|
"zod-to-json-schema": "^3.24.3"
|