@orpc/zod 0.0.0-next.f17a1a0 → 0.0.0-next.f47352c

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
@@ -1,5 +1,5 @@
1
1
  <div align="center">
2
- <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 />
2
+ <image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />
3
3
  </div>
4
4
 
5
5
  <h1></h1>
@@ -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.
@@ -53,11 +53,16 @@ You can find the full documentation [here](https://orpc.unnoq.com).
53
53
  - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
54
54
  - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
55
55
  - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
56
+ - [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
56
57
  - [@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
58
  - [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
59
+ - [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
60
+ - [@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
61
  - [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
59
62
  - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
60
63
  - [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
64
+ - [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
65
+ - [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
61
66
 
62
67
  ## `@orpc/zod`
63
68
 
@@ -127,6 +132,14 @@ const InputSchema = oz.openapi(
127
132
  )
128
133
  ```
129
134
 
135
+ ## Sponsors
136
+
137
+ <p align="center">
138
+ <a href="https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg">
139
+ <img src='https://cdn.jsdelivr.net/gh/unnoq/unnoq/sponsors.svg'/>
140
+ </a>
141
+ </p>
142
+
130
143
  ## License
131
144
 
132
145
  Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
@@ -0,0 +1,81 @@
1
+ import { JSONSchema, ConditionalSchemaConverter, SchemaConvertOptions } from '@orpc/openapi';
2
+ import { ZodTypeAny, input, output, ZodTypeDef, CustomErrorParams, ZodType, ZodEffects } from 'zod';
3
+ import { Context } from '@orpc/server';
4
+ import { StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
5
+ import { AnySchema } from '@orpc/contract';
6
+
7
+ declare function getCustomJsonSchema(def: ZodTypeDef, options: {
8
+ strategy: 'input' | 'output' | 'both';
9
+ }): Exclude<JSONSchema, boolean> | undefined;
10
+ 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?: {
11
+ strategy?: TStrategy;
12
+ }): T;
13
+
14
+ type CustomParams = CustomErrorParams & {
15
+ fatal?: boolean;
16
+ };
17
+ type CustomZodDef = {
18
+ type: 'blob' | 'regexp' | 'url';
19
+ } | {
20
+ type: 'file';
21
+ mimeType?: string;
22
+ };
23
+ declare function setCustomZodDef<T extends ZodTypeDef>(def: T, custom: CustomZodDef): void;
24
+ declare function getCustomZodDef(def: ZodTypeDef): CustomZodDef | undefined;
25
+ declare function composeParams<T = unknown>(defaultMessage: (input: T) => string, params: undefined | string | CustomParams | ((input: T) => CustomParams)): (input: T) => CustomParams;
26
+
27
+ declare function blob(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<Blob, ZodTypeDef, Blob>;
28
+
29
+ declare function file(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<File, ZodTypeDef, File> & {
30
+ type(mimeType: string, params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodEffects<ZodType<File, ZodTypeDef, File>, File, File>;
31
+ };
32
+
33
+ declare function regexp(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<RegExp, ZodTypeDef, RegExp>;
34
+
35
+ declare function url(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<URL, ZodTypeDef, URL>;
36
+
37
+ declare class ZodSmartCoercionPlugin<TContext extends Context> implements StandardHandlerPlugin<TContext> {
38
+ init(options: StandardHandlerOptions<TContext>): void;
39
+ }
40
+
41
+ interface ZodToJsonSchemaOptions {
42
+ /**
43
+ * Max depth of lazy type, if it exceeds.
44
+ *
45
+ * Used `{}` when reach max depth
46
+ *
47
+ * @default 3
48
+ */
49
+ maxLazyDepth?: number;
50
+ /**
51
+ * The schema to be used when the Zod schema is unsupported.
52
+ *
53
+ * @default { not: {} }
54
+ */
55
+ unsupportedJsonSchema?: Exclude<JSONSchema, boolean>;
56
+ /**
57
+ * The schema to be used to represent the any | unknown type.
58
+ *
59
+ * @default { }
60
+ */
61
+ anyJsonSchema?: Exclude<JSONSchema, boolean>;
62
+ }
63
+ declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
64
+ #private;
65
+ private readonly maxLazyDepth;
66
+ private readonly unsupportedJsonSchema;
67
+ private readonly anyJsonSchema;
68
+ constructor(options?: ZodToJsonSchemaOptions);
69
+ condition(schema: AnySchema | undefined): boolean;
70
+ convert(schema: AnySchema | undefined, options: SchemaConvertOptions, lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
71
+ }
72
+
73
+ declare const oz: {
74
+ file: typeof file;
75
+ blob: typeof blob;
76
+ url: typeof url;
77
+ regexp: typeof regexp;
78
+ openapi: typeof customJsonSchema;
79
+ };
80
+
81
+ export { type CustomParams, type CustomZodDef, ZodSmartCoercionPlugin, ZodToJsonSchemaConverter, type ZodToJsonSchemaOptions, blob, composeParams, customJsonSchema, file, getCustomJsonSchema, getCustomZodDef, oz, regexp, setCustomZodDef, url };
@@ -0,0 +1,81 @@
1
+ import { JSONSchema, ConditionalSchemaConverter, SchemaConvertOptions } from '@orpc/openapi';
2
+ import { ZodTypeAny, input, output, ZodTypeDef, CustomErrorParams, ZodType, ZodEffects } from 'zod';
3
+ import { Context } from '@orpc/server';
4
+ import { StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
5
+ import { AnySchema } from '@orpc/contract';
6
+
7
+ declare function getCustomJsonSchema(def: ZodTypeDef, options: {
8
+ strategy: 'input' | 'output' | 'both';
9
+ }): Exclude<JSONSchema, boolean> | undefined;
10
+ 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?: {
11
+ strategy?: TStrategy;
12
+ }): T;
13
+
14
+ type CustomParams = CustomErrorParams & {
15
+ fatal?: boolean;
16
+ };
17
+ type CustomZodDef = {
18
+ type: 'blob' | 'regexp' | 'url';
19
+ } | {
20
+ type: 'file';
21
+ mimeType?: string;
22
+ };
23
+ declare function setCustomZodDef<T extends ZodTypeDef>(def: T, custom: CustomZodDef): void;
24
+ declare function getCustomZodDef(def: ZodTypeDef): CustomZodDef | undefined;
25
+ declare function composeParams<T = unknown>(defaultMessage: (input: T) => string, params: undefined | string | CustomParams | ((input: T) => CustomParams)): (input: T) => CustomParams;
26
+
27
+ declare function blob(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<Blob, ZodTypeDef, Blob>;
28
+
29
+ declare function file(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<File, ZodTypeDef, File> & {
30
+ type(mimeType: string, params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodEffects<ZodType<File, ZodTypeDef, File>, File, File>;
31
+ };
32
+
33
+ declare function regexp(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<RegExp, ZodTypeDef, RegExp>;
34
+
35
+ declare function url(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<URL, ZodTypeDef, URL>;
36
+
37
+ declare class ZodSmartCoercionPlugin<TContext extends Context> implements StandardHandlerPlugin<TContext> {
38
+ init(options: StandardHandlerOptions<TContext>): void;
39
+ }
40
+
41
+ interface ZodToJsonSchemaOptions {
42
+ /**
43
+ * Max depth of lazy type, if it exceeds.
44
+ *
45
+ * Used `{}` when reach max depth
46
+ *
47
+ * @default 3
48
+ */
49
+ maxLazyDepth?: number;
50
+ /**
51
+ * The schema to be used when the Zod schema is unsupported.
52
+ *
53
+ * @default { not: {} }
54
+ */
55
+ unsupportedJsonSchema?: Exclude<JSONSchema, boolean>;
56
+ /**
57
+ * The schema to be used to represent the any | unknown type.
58
+ *
59
+ * @default { }
60
+ */
61
+ anyJsonSchema?: Exclude<JSONSchema, boolean>;
62
+ }
63
+ declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
64
+ #private;
65
+ private readonly maxLazyDepth;
66
+ private readonly unsupportedJsonSchema;
67
+ private readonly anyJsonSchema;
68
+ constructor(options?: ZodToJsonSchemaOptions);
69
+ condition(schema: AnySchema | undefined): boolean;
70
+ convert(schema: AnySchema | undefined, options: SchemaConvertOptions, lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
71
+ }
72
+
73
+ declare const oz: {
74
+ file: typeof file;
75
+ blob: typeof blob;
76
+ url: typeof url;
77
+ regexp: typeof regexp;
78
+ openapi: typeof customJsonSchema;
79
+ };
80
+
81
+ export { type CustomParams, type CustomZodDef, ZodSmartCoercionPlugin, ZodToJsonSchemaConverter, type ZodToJsonSchemaOptions, blob, composeParams, customJsonSchema, file, getCustomJsonSchema, getCustomZodDef, oz, regexp, setCustomZodDef, url };