@orpc/zod 0.0.0-next.da8ae32 → 0.0.0-next.df024bb
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 +132 -0
- package/dist/index.d.mts +89 -0
- package/dist/index.d.ts +89 -0
- package/dist/{index.js → index.mjs} +68 -109
- package/package.json +10 -13
- package/dist/src/coercer.d.ts +0 -7
- package/dist/src/converter.d.ts +0 -50
- package/dist/src/index.d.ts +0 -4
- package/dist/src/schemas.d.ts +0 -31
package/README.md
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
<div align="center">
|
2
|
+
<image align="center" src="https://orpc.unnoq.com/logo.webp" width=280 alt="oRPC logo" />
|
3
|
+
</div>
|
4
|
+
|
5
|
+
<h1></h1>
|
6
|
+
|
7
|
+
<div align="center">
|
8
|
+
<a href="https://codecov.io/gh/unnoq/orpc">
|
9
|
+
<img alt="codecov" src="https://codecov.io/gh/unnoq/orpc/branch/main/graph/badge.svg">
|
10
|
+
</a>
|
11
|
+
<a href="https://www.npmjs.com/package/@orpc/zod">
|
12
|
+
<img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Fzod?logo=npm" />
|
13
|
+
</a>
|
14
|
+
<a href="https://github.com/unnoq/orpc/blob/main/LICENSE">
|
15
|
+
<img alt="MIT License" src="https://img.shields.io/github/license/unnoq/orpc?logo=open-source-initiative" />
|
16
|
+
</a>
|
17
|
+
<a href="https://discord.gg/TXEbwRBvQn">
|
18
|
+
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
19
|
+
</a>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
23
|
+
|
24
|
+
**oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards, ensuring a smooth and enjoyable developer experience.
|
25
|
+
|
26
|
+
---
|
27
|
+
|
28
|
+
## Highlights
|
29
|
+
|
30
|
+
- **End-to-End Type Safety 🔒**: Ensure complete type safety from inputs to outputs and errors, bridging server and client seamlessly.
|
31
|
+
- **First-Class OpenAPI 📄**: Adheres to the OpenAPI standard out of the box, ensuring seamless integration and comprehensive API documentation.
|
32
|
+
- **Contract-First Development 📜**: (Optional) Define your API contract upfront and implement it with confidence.
|
33
|
+
- **Exceptional Developer Experience ✨**: Enjoy a streamlined workflow with robust typing and clear, in-code documentation.
|
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.
|
36
|
+
- **Server Actions ⚡️**: Fully compatible with React Server Actions on Next.js, TanStack Start, and more.
|
37
|
+
- **Standard Schema Support 🗂️**: Effortlessly work with Zod, Valibot, ArkType, and others right out of the box.
|
38
|
+
- **Fast & Lightweight 💨**: Built on native APIs across all runtimes – optimized for speed and efficiency.
|
39
|
+
- **Native Types 📦**: Enjoy built-in support for Date, File, Blob, BigInt, URL and more with no extra setup.
|
40
|
+
- **Lazy Router ⏱️**: Improve cold start times with our lazy routing feature.
|
41
|
+
- **SSE & Streaming 📡**: Provides SSE and streaming features – perfect for real-time notifications and AI-powered streaming responses.
|
42
|
+
- **Reusability 🔄**: Write once and reuse your code across multiple purposes effortlessly.
|
43
|
+
- **Extendability 🔌**: Easily enhance oRPC with plugins, middleware, and interceptors.
|
44
|
+
- **Reliability 🛡️**: Well-tested, fully TypeScript, production-ready, and MIT licensed for peace of mind.
|
45
|
+
- **Simplicity 💡**: Enjoy straightforward, clean code with no hidden magic.
|
46
|
+
|
47
|
+
## Documentation
|
48
|
+
|
49
|
+
You can find the full documentation [here](https://orpc.unnoq.com).
|
50
|
+
|
51
|
+
## Packages
|
52
|
+
|
53
|
+
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
54
|
+
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
55
|
+
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
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
|
+
- [@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/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
59
|
+
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
60
|
+
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
61
|
+
|
62
|
+
## `@orpc/zod`
|
63
|
+
|
64
|
+
More schemas that [Zod](https://zod.dev/) doesn't support yet, and provides `ZodToJsonSchemaConverter` for generating OpenAPI specs.
|
65
|
+
|
66
|
+
### More Schemas
|
67
|
+
|
68
|
+
- `oz.url`: Zod schema for [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) instance.
|
69
|
+
- `oz.blob`: Zod schema for [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) instance.
|
70
|
+
- `oz.file`: Zod schema for [File](https://developer.mozilla.org/en-US/docs/Web/API/File) instance.
|
71
|
+
- `oz.regexp`: Zod schema for [RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) instance.
|
72
|
+
|
73
|
+
```ts
|
74
|
+
import { oz } from '@orpc/zod'
|
75
|
+
import { z } from 'zod'
|
76
|
+
|
77
|
+
const Example = z.object({
|
78
|
+
url: oz.url(),
|
79
|
+
blob: oz.blob(),
|
80
|
+
file: oz.file().type('image/png'),
|
81
|
+
regexp: oz.regexp(),
|
82
|
+
})
|
83
|
+
```
|
84
|
+
|
85
|
+
### Generate OpenAPI Spec
|
86
|
+
|
87
|
+
```ts
|
88
|
+
import { OpenAPIGenerator } from '@orpc/openapi'
|
89
|
+
import { ZodToJsonSchemaConverter } from '@orpc/zod'
|
90
|
+
|
91
|
+
const openAPIGenerator = new OpenAPIGenerator({
|
92
|
+
schemaConverters: [new ZodToJsonSchemaConverter()],
|
93
|
+
})
|
94
|
+
|
95
|
+
const specFromContract = await openAPIGenerator.generate(contract, {
|
96
|
+
info: {
|
97
|
+
title: 'My App',
|
98
|
+
version: '0.0.0',
|
99
|
+
},
|
100
|
+
})
|
101
|
+
|
102
|
+
const specFromRouter = await openAPIGenerator.generate(router, {
|
103
|
+
info: {
|
104
|
+
title: 'My App',
|
105
|
+
version: '0.0.0',
|
106
|
+
},
|
107
|
+
})
|
108
|
+
```
|
109
|
+
|
110
|
+
### Extending the Specification
|
111
|
+
|
112
|
+
```ts
|
113
|
+
import { oz } from '@orpc/zod'
|
114
|
+
import { z } from 'zod'
|
115
|
+
|
116
|
+
const InputSchema = oz.openapi(
|
117
|
+
z.object({
|
118
|
+
name: z.string(),
|
119
|
+
}),
|
120
|
+
{
|
121
|
+
examples: [
|
122
|
+
{ name: 'Earth' },
|
123
|
+
{ name: 'Mars' },
|
124
|
+
],
|
125
|
+
// additional options...
|
126
|
+
}
|
127
|
+
)
|
128
|
+
```
|
129
|
+
|
130
|
+
## License
|
131
|
+
|
132
|
+
Distributed under the MIT License. See [LICENSE](https://github.com/unnoq/orpc/blob/main/LICENSE) for more information.
|
package/dist/index.d.mts
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
import { Context } from '@orpc/server';
|
2
|
+
import { Plugin } from '@orpc/server/plugins';
|
3
|
+
import { StandardHandlerOptions } from '@orpc/server/standard';
|
4
|
+
import { Schema } from '@orpc/contract';
|
5
|
+
import { JSONSchema, SchemaConverter, SchemaConvertOptions } from '@orpc/openapi';
|
6
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
7
|
+
import { JSONSchema as JSONSchema$1 } from 'json-schema-typed/draft-2020-12';
|
8
|
+
import { ZodTypeDef, CustomErrorParams, ZodType, ZodEffects, ZodTypeAny, input, output } from 'zod';
|
9
|
+
|
10
|
+
declare class ZodSmartCoercionPlugin<TContext extends Context> implements Plugin<TContext> {
|
11
|
+
init(options: StandardHandlerOptions<TContext>): void;
|
12
|
+
}
|
13
|
+
|
14
|
+
declare const NON_LOGIC_KEYWORDS: ("default" | "$anchor" | "$comment" | "$defs" | "$dynamicAnchor" | "$dynamicRef" | "$id" | "$schema" | "$vocabulary" | "definitions" | "deprecated" | "description" | "examples" | "format" | "readOnly" | "title" | "writeOnly" | "contentEncoding" | "contentMediaType")[];
|
15
|
+
declare const UNSUPPORTED_JSON_SCHEMA: {
|
16
|
+
not: {};
|
17
|
+
};
|
18
|
+
declare const UNDEFINED_JSON_SCHEMA: {
|
19
|
+
const: string;
|
20
|
+
};
|
21
|
+
interface ZodToJsonSchemaOptions {
|
22
|
+
/**
|
23
|
+
* Max depth of lazy type, if it exceeds.
|
24
|
+
*
|
25
|
+
* Used `{}` when reach max depth
|
26
|
+
*
|
27
|
+
* @default 5
|
28
|
+
*/
|
29
|
+
maxLazyDepth?: number;
|
30
|
+
/**
|
31
|
+
* The length used to track the depth of lazy type
|
32
|
+
*
|
33
|
+
* @internal
|
34
|
+
*/
|
35
|
+
lazyDepth?: number;
|
36
|
+
/**
|
37
|
+
* The expected json schema for input or output zod schema
|
38
|
+
*
|
39
|
+
* @default input
|
40
|
+
*/
|
41
|
+
mode?: 'input' | 'output';
|
42
|
+
/**
|
43
|
+
* Track if current level schema is handled custom json schema to prevent recursive
|
44
|
+
*
|
45
|
+
* @internal
|
46
|
+
*/
|
47
|
+
isHandledCustomJSONSchema?: boolean;
|
48
|
+
/**
|
49
|
+
* Track if current level schema is handled zod description to prevent recursive
|
50
|
+
*
|
51
|
+
* @internal
|
52
|
+
*/
|
53
|
+
isHandledZodDescription?: boolean;
|
54
|
+
}
|
55
|
+
declare function zodToJsonSchema(schema: StandardSchemaV1, options?: ZodToJsonSchemaOptions): Exclude<JSONSchema.JSONSchema, boolean>;
|
56
|
+
declare class ZodToJsonSchemaConverter implements SchemaConverter {
|
57
|
+
condition(schema: Schema): boolean;
|
58
|
+
convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
|
59
|
+
}
|
60
|
+
|
61
|
+
type CustomZodType = 'File' | 'Blob' | 'Invalid Date' | 'RegExp' | 'URL';
|
62
|
+
type CustomParams = CustomErrorParams & {
|
63
|
+
fatal?: boolean;
|
64
|
+
};
|
65
|
+
declare function getCustomZodType(def: ZodTypeDef): CustomZodType | undefined;
|
66
|
+
declare function getCustomZodFileMimeType(def: ZodTypeDef): string | undefined;
|
67
|
+
declare function getCustomJSONSchema(def: ZodTypeDef, options?: {
|
68
|
+
mode?: 'input' | 'output';
|
69
|
+
}): Exclude<JSONSchema$1, boolean> | undefined;
|
70
|
+
declare function file(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<InstanceType<typeof File>, ZodTypeDef, InstanceType<typeof File>> & {
|
71
|
+
type(mimeType: string, params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodEffects<ZodType<InstanceType<typeof File>, ZodTypeDef, InstanceType<typeof File>>, InstanceType<typeof File>, InstanceType<typeof File>>;
|
72
|
+
};
|
73
|
+
declare function blob(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<InstanceType<typeof Blob>, ZodTypeDef, InstanceType<typeof Blob>>;
|
74
|
+
declare function invalidDate(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<Date, ZodTypeDef, Date>;
|
75
|
+
declare function regexp(options?: CustomParams): ZodType<RegExp, ZodTypeDef, RegExp>;
|
76
|
+
declare function url(options?: CustomParams): ZodType<URL, ZodTypeDef, URL>;
|
77
|
+
declare function openapi<T extends ZodTypeAny, TMode extends 'input' | 'output' | 'both' = 'both'>(schema: T, custom: Exclude<JSONSchema$1<TMode extends 'input' ? input<T> : TMode extends 'output' ? output<T> : input<T> & output<T>>, boolean>, options?: {
|
78
|
+
mode: TMode;
|
79
|
+
}): ReturnType<T['refine']>;
|
80
|
+
declare const oz: {
|
81
|
+
openapi: typeof openapi;
|
82
|
+
file: typeof file;
|
83
|
+
blob: typeof blob;
|
84
|
+
invalidDate: typeof invalidDate;
|
85
|
+
regexp: typeof regexp;
|
86
|
+
url: typeof url;
|
87
|
+
};
|
88
|
+
|
89
|
+
export { type CustomZodType, NON_LOGIC_KEYWORDS, UNDEFINED_JSON_SCHEMA, UNSUPPORTED_JSON_SCHEMA, ZodSmartCoercionPlugin as ZodAutoCoercePlugin, ZodSmartCoercionPlugin, ZodToJsonSchemaConverter, type ZodToJsonSchemaOptions, blob, file, getCustomJSONSchema, getCustomZodFileMimeType, getCustomZodType, invalidDate, openapi, oz, regexp, url, zodToJsonSchema };
|
package/dist/index.d.ts
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
import { Context } from '@orpc/server';
|
2
|
+
import { Plugin } from '@orpc/server/plugins';
|
3
|
+
import { StandardHandlerOptions } from '@orpc/server/standard';
|
4
|
+
import { Schema } from '@orpc/contract';
|
5
|
+
import { JSONSchema, SchemaConverter, SchemaConvertOptions } from '@orpc/openapi';
|
6
|
+
import { StandardSchemaV1 } from '@standard-schema/spec';
|
7
|
+
import { JSONSchema as JSONSchema$1 } from 'json-schema-typed/draft-2020-12';
|
8
|
+
import { ZodTypeDef, CustomErrorParams, ZodType, ZodEffects, ZodTypeAny, input, output } from 'zod';
|
9
|
+
|
10
|
+
declare class ZodSmartCoercionPlugin<TContext extends Context> implements Plugin<TContext> {
|
11
|
+
init(options: StandardHandlerOptions<TContext>): void;
|
12
|
+
}
|
13
|
+
|
14
|
+
declare const NON_LOGIC_KEYWORDS: ("default" | "$anchor" | "$comment" | "$defs" | "$dynamicAnchor" | "$dynamicRef" | "$id" | "$schema" | "$vocabulary" | "definitions" | "deprecated" | "description" | "examples" | "format" | "readOnly" | "title" | "writeOnly" | "contentEncoding" | "contentMediaType")[];
|
15
|
+
declare const UNSUPPORTED_JSON_SCHEMA: {
|
16
|
+
not: {};
|
17
|
+
};
|
18
|
+
declare const UNDEFINED_JSON_SCHEMA: {
|
19
|
+
const: string;
|
20
|
+
};
|
21
|
+
interface ZodToJsonSchemaOptions {
|
22
|
+
/**
|
23
|
+
* Max depth of lazy type, if it exceeds.
|
24
|
+
*
|
25
|
+
* Used `{}` when reach max depth
|
26
|
+
*
|
27
|
+
* @default 5
|
28
|
+
*/
|
29
|
+
maxLazyDepth?: number;
|
30
|
+
/**
|
31
|
+
* The length used to track the depth of lazy type
|
32
|
+
*
|
33
|
+
* @internal
|
34
|
+
*/
|
35
|
+
lazyDepth?: number;
|
36
|
+
/**
|
37
|
+
* The expected json schema for input or output zod schema
|
38
|
+
*
|
39
|
+
* @default input
|
40
|
+
*/
|
41
|
+
mode?: 'input' | 'output';
|
42
|
+
/**
|
43
|
+
* Track if current level schema is handled custom json schema to prevent recursive
|
44
|
+
*
|
45
|
+
* @internal
|
46
|
+
*/
|
47
|
+
isHandledCustomJSONSchema?: boolean;
|
48
|
+
/**
|
49
|
+
* Track if current level schema is handled zod description to prevent recursive
|
50
|
+
*
|
51
|
+
* @internal
|
52
|
+
*/
|
53
|
+
isHandledZodDescription?: boolean;
|
54
|
+
}
|
55
|
+
declare function zodToJsonSchema(schema: StandardSchemaV1, options?: ZodToJsonSchemaOptions): Exclude<JSONSchema.JSONSchema, boolean>;
|
56
|
+
declare class ZodToJsonSchemaConverter implements SchemaConverter {
|
57
|
+
condition(schema: Schema): boolean;
|
58
|
+
convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
|
59
|
+
}
|
60
|
+
|
61
|
+
type CustomZodType = 'File' | 'Blob' | 'Invalid Date' | 'RegExp' | 'URL';
|
62
|
+
type CustomParams = CustomErrorParams & {
|
63
|
+
fatal?: boolean;
|
64
|
+
};
|
65
|
+
declare function getCustomZodType(def: ZodTypeDef): CustomZodType | undefined;
|
66
|
+
declare function getCustomZodFileMimeType(def: ZodTypeDef): string | undefined;
|
67
|
+
declare function getCustomJSONSchema(def: ZodTypeDef, options?: {
|
68
|
+
mode?: 'input' | 'output';
|
69
|
+
}): Exclude<JSONSchema$1, boolean> | undefined;
|
70
|
+
declare function file(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<InstanceType<typeof File>, ZodTypeDef, InstanceType<typeof File>> & {
|
71
|
+
type(mimeType: string, params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodEffects<ZodType<InstanceType<typeof File>, ZodTypeDef, InstanceType<typeof File>>, InstanceType<typeof File>, InstanceType<typeof File>>;
|
72
|
+
};
|
73
|
+
declare function blob(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<InstanceType<typeof Blob>, ZodTypeDef, InstanceType<typeof Blob>>;
|
74
|
+
declare function invalidDate(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<Date, ZodTypeDef, Date>;
|
75
|
+
declare function regexp(options?: CustomParams): ZodType<RegExp, ZodTypeDef, RegExp>;
|
76
|
+
declare function url(options?: CustomParams): ZodType<URL, ZodTypeDef, URL>;
|
77
|
+
declare function openapi<T extends ZodTypeAny, TMode extends 'input' | 'output' | 'both' = 'both'>(schema: T, custom: Exclude<JSONSchema$1<TMode extends 'input' ? input<T> : TMode extends 'output' ? output<T> : input<T> & output<T>>, boolean>, options?: {
|
78
|
+
mode: TMode;
|
79
|
+
}): ReturnType<T['refine']>;
|
80
|
+
declare const oz: {
|
81
|
+
openapi: typeof openapi;
|
82
|
+
file: typeof file;
|
83
|
+
blob: typeof blob;
|
84
|
+
invalidDate: typeof invalidDate;
|
85
|
+
regexp: typeof regexp;
|
86
|
+
url: typeof url;
|
87
|
+
};
|
88
|
+
|
89
|
+
export { type CustomZodType, NON_LOGIC_KEYWORDS, UNDEFINED_JSON_SCHEMA, UNSUPPORTED_JSON_SCHEMA, ZodSmartCoercionPlugin as ZodAutoCoercePlugin, ZodSmartCoercionPlugin, ZodToJsonSchemaConverter, type ZodToJsonSchemaOptions, blob, file, getCustomJSONSchema, getCustomZodFileMimeType, getCustomZodType, invalidDate, openapi, oz, regexp, url, zodToJsonSchema };
|
@@ -1,21 +1,23 @@
|
|
1
|
-
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
import { guard, isObject } from '@orpc/shared';
|
2
|
+
import { getCustomZodType as getCustomZodType$1 } from '@orpc/zod';
|
3
|
+
import { ZodFirstPartyTypeKind, custom } from 'zod';
|
4
|
+
import { JSONSchemaFormat } from '@orpc/openapi';
|
5
|
+
import escapeStringRegexp from 'escape-string-regexp';
|
6
|
+
import wcmatch from 'wildcard-match';
|
7
|
+
|
8
|
+
class ZodSmartCoercionPlugin {
|
9
|
+
init(options) {
|
10
|
+
options.clientInterceptors ??= [];
|
11
|
+
options.clientInterceptors.unshift((options2) => {
|
12
|
+
const inputSchema = options2.procedure["~orpc"].inputSchema;
|
11
13
|
if (!inputSchema || inputSchema["~standard"].vendor !== "zod") {
|
12
|
-
return
|
14
|
+
return options2.next();
|
13
15
|
}
|
14
|
-
const coercedInput = zodCoerceInternal(inputSchema,
|
15
|
-
return
|
16
|
+
const coercedInput = zodCoerceInternal(inputSchema, options2.input, { bracketNotation: true });
|
17
|
+
return options2.next({ ...options2, input: coercedInput });
|
16
18
|
});
|
17
19
|
}
|
18
|
-
}
|
20
|
+
}
|
19
21
|
function zodCoerceInternal(schema, value, options) {
|
20
22
|
const isRoot = options?.isRoot ?? true;
|
21
23
|
const options_ = { ...options, isRoot: false };
|
@@ -26,7 +28,7 @@ function zodCoerceInternal(schema, value, options) {
|
|
26
28
|
}
|
27
29
|
return zodCoerceInternal(schema, value, options_);
|
28
30
|
}
|
29
|
-
const customType = getCustomZodType(schema._def);
|
31
|
+
const customType = getCustomZodType$1(schema._def);
|
30
32
|
if (customType === "Invalid Date") {
|
31
33
|
if (typeof value === "string" && value.toLocaleLowerCase() === "invalid date") {
|
32
34
|
return /* @__PURE__ */ new Date("Invalid Date");
|
@@ -41,9 +43,9 @@ function zodCoerceInternal(schema, value, options) {
|
|
41
43
|
}
|
42
44
|
} else if (customType === "URL") {
|
43
45
|
if (typeof value === "string") {
|
44
|
-
const
|
45
|
-
if (
|
46
|
-
return
|
46
|
+
const url = guard(() => new URL(value));
|
47
|
+
if (url !== void 0) {
|
48
|
+
return url;
|
47
49
|
}
|
48
50
|
}
|
49
51
|
}
|
@@ -309,38 +311,15 @@ function zodCoerceInternal(schema, value, options) {
|
|
309
311
|
}
|
310
312
|
}
|
311
313
|
}
|
312
|
-
} else
|
313
|
-
const _expected = typeName;
|
314
|
-
}
|
314
|
+
} else ;
|
315
315
|
return value;
|
316
316
|
}
|
317
317
|
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
if (typeof string !== "string") {
|
324
|
-
throw new TypeError("Expected a string");
|
325
|
-
}
|
326
|
-
return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
327
|
-
}
|
328
|
-
|
329
|
-
// src/converter.ts
|
330
|
-
import {
|
331
|
-
ZodFirstPartyTypeKind as ZodFirstPartyTypeKind2
|
332
|
-
} from "zod";
|
333
|
-
|
334
|
-
// src/schemas.ts
|
335
|
-
import wcmatch from "wildcard-match";
|
336
|
-
import {
|
337
|
-
custom
|
338
|
-
} from "zod";
|
339
|
-
var customZodTypeSymbol = Symbol("customZodTypeSymbol");
|
340
|
-
var customZodFileMimeTypeSymbol = Symbol("customZodFileMimeTypeSymbol");
|
341
|
-
var CUSTOM_JSON_SCHEMA_SYMBOL = Symbol("CUSTOM_JSON_SCHEMA");
|
342
|
-
var CUSTOM_JSON_SCHEMA_INPUT_SYMBOL = Symbol("CUSTOM_JSON_SCHEMA_INPUT");
|
343
|
-
var CUSTOM_JSON_SCHEMA_OUTPUT_SYMBOL = Symbol("CUSTOM_JSON_SCHEMA_OUTPUT");
|
318
|
+
const customZodTypeSymbol = Symbol("customZodTypeSymbol");
|
319
|
+
const customZodFileMimeTypeSymbol = Symbol("customZodFileMimeTypeSymbol");
|
320
|
+
const CUSTOM_JSON_SCHEMA_SYMBOL = Symbol("CUSTOM_JSON_SCHEMA");
|
321
|
+
const CUSTOM_JSON_SCHEMA_INPUT_SYMBOL = Symbol("CUSTOM_JSON_SCHEMA_INPUT");
|
322
|
+
const CUSTOM_JSON_SCHEMA_OUTPUT_SYMBOL = Symbol("CUSTOM_JSON_SCHEMA_OUTPUT");
|
344
323
|
function getCustomZodType(def) {
|
345
324
|
return customZodTypeSymbol in def ? def[customZodTypeSymbol] : void 0;
|
346
325
|
}
|
@@ -458,7 +437,7 @@ function openapi(schema, custom2, options) {
|
|
458
437
|
});
|
459
438
|
return newSchema;
|
460
439
|
}
|
461
|
-
|
440
|
+
const oz = {
|
462
441
|
openapi,
|
463
442
|
file,
|
464
443
|
blob,
|
@@ -467,8 +446,7 @@ var oz = {
|
|
467
446
|
url
|
468
447
|
};
|
469
448
|
|
470
|
-
|
471
|
-
var NON_LOGIC_KEYWORDS = [
|
449
|
+
const NON_LOGIC_KEYWORDS = [
|
472
450
|
// Core Documentation Keywords
|
473
451
|
"$anchor",
|
474
452
|
"$comment",
|
@@ -495,8 +473,8 @@ var NON_LOGIC_KEYWORDS = [
|
|
495
473
|
"$dynamicAnchor",
|
496
474
|
"$dynamicRef"
|
497
475
|
];
|
498
|
-
|
499
|
-
|
476
|
+
const UNSUPPORTED_JSON_SCHEMA = { not: {} };
|
477
|
+
const UNDEFINED_JSON_SCHEMA = { const: "undefined" };
|
500
478
|
function zodToJsonSchema(schema, options) {
|
501
479
|
if (schema["~standard"].vendor !== "zod") {
|
502
480
|
console.warn(`Generate JSON schema not support ${schema["~standard"].vendor} yet`);
|
@@ -549,10 +527,9 @@ function zodToJsonSchema(schema, options) {
|
|
549
527
|
return { type: "string", format: JSONSchemaFormat.URI };
|
550
528
|
}
|
551
529
|
}
|
552
|
-
const _expectedCustomType = customType;
|
553
530
|
const typeName = schema__._def.typeName;
|
554
531
|
switch (typeName) {
|
555
|
-
case
|
532
|
+
case ZodFirstPartyTypeKind.ZodString: {
|
556
533
|
const schema_ = schema__;
|
557
534
|
const json = { type: "string" };
|
558
535
|
for (const check of schema_._def.checks) {
|
@@ -628,13 +605,13 @@ function zodToJsonSchema(schema, options) {
|
|
628
605
|
json.pattern = "^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$";
|
629
606
|
break;
|
630
607
|
default: {
|
631
|
-
|
608
|
+
check.kind;
|
632
609
|
}
|
633
610
|
}
|
634
611
|
}
|
635
612
|
return json;
|
636
613
|
}
|
637
|
-
case
|
614
|
+
case ZodFirstPartyTypeKind.ZodNumber: {
|
638
615
|
const schema_ = schema__;
|
639
616
|
const json = { type: "number" };
|
640
617
|
for (const check of schema_._def.checks) {
|
@@ -652,50 +629,50 @@ function zodToJsonSchema(schema, options) {
|
|
652
629
|
json.multipleOf = check.value;
|
653
630
|
break;
|
654
631
|
default: {
|
655
|
-
|
632
|
+
check.kind;
|
656
633
|
}
|
657
634
|
}
|
658
635
|
}
|
659
636
|
return json;
|
660
637
|
}
|
661
|
-
case
|
638
|
+
case ZodFirstPartyTypeKind.ZodNaN: {
|
662
639
|
return { const: "NaN" };
|
663
640
|
}
|
664
|
-
case
|
641
|
+
case ZodFirstPartyTypeKind.ZodBigInt: {
|
665
642
|
const json = { type: "string", pattern: "^-?[0-9]+$" };
|
666
643
|
return json;
|
667
644
|
}
|
668
|
-
case
|
645
|
+
case ZodFirstPartyTypeKind.ZodBoolean: {
|
669
646
|
return { type: "boolean" };
|
670
647
|
}
|
671
|
-
case
|
648
|
+
case ZodFirstPartyTypeKind.ZodDate: {
|
672
649
|
const schema2 = { type: "string", format: JSONSchemaFormat.Date };
|
673
650
|
return schema2;
|
674
651
|
}
|
675
|
-
case
|
652
|
+
case ZodFirstPartyTypeKind.ZodNull: {
|
676
653
|
return { type: "null" };
|
677
654
|
}
|
678
|
-
case
|
679
|
-
case
|
655
|
+
case ZodFirstPartyTypeKind.ZodVoid:
|
656
|
+
case ZodFirstPartyTypeKind.ZodUndefined: {
|
680
657
|
return UNDEFINED_JSON_SCHEMA;
|
681
658
|
}
|
682
|
-
case
|
659
|
+
case ZodFirstPartyTypeKind.ZodLiteral: {
|
683
660
|
const schema_ = schema__;
|
684
661
|
return { const: schema_._def.value };
|
685
662
|
}
|
686
|
-
case
|
663
|
+
case ZodFirstPartyTypeKind.ZodEnum: {
|
687
664
|
const schema_ = schema__;
|
688
665
|
return {
|
689
666
|
enum: schema_._def.values
|
690
667
|
};
|
691
668
|
}
|
692
|
-
case
|
669
|
+
case ZodFirstPartyTypeKind.ZodNativeEnum: {
|
693
670
|
const schema_ = schema__;
|
694
671
|
return {
|
695
672
|
enum: Object.values(schema_._def.values)
|
696
673
|
};
|
697
674
|
}
|
698
|
-
case
|
675
|
+
case ZodFirstPartyTypeKind.ZodArray: {
|
699
676
|
const schema_ = schema__;
|
700
677
|
const def = schema_._def;
|
701
678
|
const json = { type: "array" };
|
@@ -712,7 +689,7 @@ function zodToJsonSchema(schema, options) {
|
|
712
689
|
}
|
713
690
|
return json;
|
714
691
|
}
|
715
|
-
case
|
692
|
+
case ZodFirstPartyTypeKind.ZodTuple: {
|
716
693
|
const schema_ = schema__;
|
717
694
|
const prefixItems = [];
|
718
695
|
const json = { type: "array" };
|
@@ -730,7 +707,7 @@ function zodToJsonSchema(schema, options) {
|
|
730
707
|
}
|
731
708
|
return json;
|
732
709
|
}
|
733
|
-
case
|
710
|
+
case ZodFirstPartyTypeKind.ZodObject: {
|
734
711
|
const schema_ = schema__;
|
735
712
|
const json = { type: "object" };
|
736
713
|
const properties = {};
|
@@ -766,7 +743,7 @@ function zodToJsonSchema(schema, options) {
|
|
766
743
|
}
|
767
744
|
return json;
|
768
745
|
}
|
769
|
-
case
|
746
|
+
case ZodFirstPartyTypeKind.ZodRecord: {
|
770
747
|
const schema_ = schema__;
|
771
748
|
const json = { type: "object" };
|
772
749
|
json.additionalProperties = zodToJsonSchema(
|
@@ -775,14 +752,14 @@ function zodToJsonSchema(schema, options) {
|
|
775
752
|
);
|
776
753
|
return json;
|
777
754
|
}
|
778
|
-
case
|
755
|
+
case ZodFirstPartyTypeKind.ZodSet: {
|
779
756
|
const schema_ = schema__;
|
780
757
|
return {
|
781
758
|
type: "array",
|
782
759
|
items: zodToJsonSchema(schema_._def.valueType, childOptions)
|
783
760
|
};
|
784
761
|
}
|
785
|
-
case
|
762
|
+
case ZodFirstPartyTypeKind.ZodMap: {
|
786
763
|
const schema_ = schema__;
|
787
764
|
return {
|
788
765
|
type: "array",
|
@@ -797,8 +774,8 @@ function zodToJsonSchema(schema, options) {
|
|
797
774
|
}
|
798
775
|
};
|
799
776
|
}
|
800
|
-
case
|
801
|
-
case
|
777
|
+
case ZodFirstPartyTypeKind.ZodUnion:
|
778
|
+
case ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {
|
802
779
|
const schema_ = schema__;
|
803
780
|
const anyOf = [];
|
804
781
|
for (const s of schema_._def.options) {
|
@@ -806,7 +783,7 @@ function zodToJsonSchema(schema, options) {
|
|
806
783
|
}
|
807
784
|
return { anyOf };
|
808
785
|
}
|
809
|
-
case
|
786
|
+
case ZodFirstPartyTypeKind.ZodIntersection: {
|
810
787
|
const schema_ = schema__;
|
811
788
|
const allOf = [];
|
812
789
|
for (const s of [schema_._def.left, schema_._def.right]) {
|
@@ -814,7 +791,7 @@ function zodToJsonSchema(schema, options) {
|
|
814
791
|
}
|
815
792
|
return { allOf };
|
816
793
|
}
|
817
|
-
case
|
794
|
+
case ZodFirstPartyTypeKind.ZodLazy: {
|
818
795
|
const schema_ = schema__;
|
819
796
|
const maxLazyDepth = childOptions?.maxLazyDepth ?? 5;
|
820
797
|
const lazyDepth = childOptions?.lazyDepth ?? 0;
|
@@ -826,49 +803,49 @@ function zodToJsonSchema(schema, options) {
|
|
826
803
|
lazyDepth: lazyDepth + 1
|
827
804
|
});
|
828
805
|
}
|
829
|
-
case
|
830
|
-
case
|
806
|
+
case ZodFirstPartyTypeKind.ZodUnknown:
|
807
|
+
case ZodFirstPartyTypeKind.ZodAny:
|
831
808
|
case void 0: {
|
832
809
|
return {};
|
833
810
|
}
|
834
|
-
case
|
811
|
+
case ZodFirstPartyTypeKind.ZodOptional: {
|
835
812
|
const schema_ = schema__;
|
836
813
|
const inner = zodToJsonSchema(schema_._def.innerType, childOptions);
|
837
814
|
return {
|
838
815
|
anyOf: [UNDEFINED_JSON_SCHEMA, inner]
|
839
816
|
};
|
840
817
|
}
|
841
|
-
case
|
818
|
+
case ZodFirstPartyTypeKind.ZodReadonly: {
|
842
819
|
const schema_ = schema__;
|
843
820
|
return zodToJsonSchema(schema_._def.innerType, childOptions);
|
844
821
|
}
|
845
|
-
case
|
822
|
+
case ZodFirstPartyTypeKind.ZodDefault: {
|
846
823
|
const schema_ = schema__;
|
847
824
|
return zodToJsonSchema(schema_._def.innerType, childOptions);
|
848
825
|
}
|
849
|
-
case
|
826
|
+
case ZodFirstPartyTypeKind.ZodEffects: {
|
850
827
|
const schema_ = schema__;
|
851
828
|
if (schema_._def.effect.type === "transform" && childOptions?.mode === "output") {
|
852
829
|
return {};
|
853
830
|
}
|
854
831
|
return zodToJsonSchema(schema_._def.schema, childOptions);
|
855
832
|
}
|
856
|
-
case
|
833
|
+
case ZodFirstPartyTypeKind.ZodCatch: {
|
857
834
|
const schema_ = schema__;
|
858
835
|
return zodToJsonSchema(schema_._def.innerType, childOptions);
|
859
836
|
}
|
860
|
-
case
|
837
|
+
case ZodFirstPartyTypeKind.ZodBranded: {
|
861
838
|
const schema_ = schema__;
|
862
839
|
return zodToJsonSchema(schema_._def.type, childOptions);
|
863
840
|
}
|
864
|
-
case
|
841
|
+
case ZodFirstPartyTypeKind.ZodPipeline: {
|
865
842
|
const schema_ = schema__;
|
866
843
|
return zodToJsonSchema(
|
867
844
|
childOptions?.mode === "output" ? schema_._def.out : schema_._def.in,
|
868
845
|
childOptions
|
869
846
|
);
|
870
847
|
}
|
871
|
-
case
|
848
|
+
case ZodFirstPartyTypeKind.ZodNullable: {
|
872
849
|
const schema_ = schema__;
|
873
850
|
const inner = zodToJsonSchema(schema_._def.innerType, childOptions);
|
874
851
|
return {
|
@@ -876,7 +853,6 @@ function zodToJsonSchema(schema, options) {
|
|
876
853
|
};
|
877
854
|
}
|
878
855
|
}
|
879
|
-
const _expected = typeName;
|
880
856
|
return UNSUPPORTED_JSON_SCHEMA;
|
881
857
|
}
|
882
858
|
function extractJSONSchema(schema, check, matches = []) {
|
@@ -919,7 +895,7 @@ function extractJSONSchema(schema, check, matches = []) {
|
|
919
895
|
}
|
920
896
|
return { schema, matches };
|
921
897
|
}
|
922
|
-
|
898
|
+
class ZodToJsonSchemaConverter {
|
923
899
|
condition(schema) {
|
924
900
|
return Boolean(schema && schema["~standard"].vendor === "zod");
|
925
901
|
}
|
@@ -927,23 +903,6 @@ var ZodToJsonSchemaConverter = class {
|
|
927
903
|
const jsonSchema = schema;
|
928
904
|
return zodToJsonSchema(jsonSchema, { mode: options.strategy });
|
929
905
|
}
|
930
|
-
}
|
931
|
-
|
932
|
-
|
933
|
-
UNDEFINED_JSON_SCHEMA,
|
934
|
-
UNSUPPORTED_JSON_SCHEMA,
|
935
|
-
ZodAutoCoercePlugin,
|
936
|
-
ZodToJsonSchemaConverter,
|
937
|
-
blob,
|
938
|
-
file,
|
939
|
-
getCustomJSONSchema,
|
940
|
-
getCustomZodFileMimeType,
|
941
|
-
getCustomZodType,
|
942
|
-
invalidDate,
|
943
|
-
openapi,
|
944
|
-
oz,
|
945
|
-
regexp,
|
946
|
-
url,
|
947
|
-
zodToJsonSchema
|
948
|
-
};
|
949
|
-
//# sourceMappingURL=index.js.map
|
906
|
+
}
|
907
|
+
|
908
|
+
export { NON_LOGIC_KEYWORDS, UNDEFINED_JSON_SCHEMA, UNSUPPORTED_JSON_SCHEMA, ZodSmartCoercionPlugin as ZodAutoCoercePlugin, ZodSmartCoercionPlugin, ZodToJsonSchemaConverter, blob, file, getCustomJSONSchema, getCustomZodFileMimeType, getCustomZodType, invalidDate, openapi, oz, regexp, url, zodToJsonSchema };
|
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.df024bb",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -15,32 +15,29 @@
|
|
15
15
|
],
|
16
16
|
"exports": {
|
17
17
|
".": {
|
18
|
-
"types": "./dist/
|
19
|
-
"import": "./dist/index.
|
20
|
-
"default": "./dist/index.
|
21
|
-
},
|
22
|
-
"./🔒/*": {
|
23
|
-
"types": "./dist/src/*.d.ts"
|
18
|
+
"types": "./dist/index.d.mts",
|
19
|
+
"import": "./dist/index.mjs",
|
20
|
+
"default": "./dist/index.mjs"
|
24
21
|
}
|
25
22
|
},
|
26
23
|
"files": [
|
27
|
-
"!**/*.map",
|
28
|
-
"!**/*.tsbuildinfo",
|
29
24
|
"dist"
|
30
25
|
],
|
31
26
|
"peerDependencies": {
|
32
|
-
"@orpc/
|
33
|
-
"@orpc/server": "0.0.0-next.
|
27
|
+
"@orpc/contract": "0.0.0-next.df024bb",
|
28
|
+
"@orpc/server": "0.0.0-next.df024bb",
|
29
|
+
"@orpc/openapi": "0.0.0-next.df024bb"
|
34
30
|
},
|
35
31
|
"dependencies": {
|
36
32
|
"@standard-schema/spec": "^1.0.0",
|
33
|
+
"escape-string-regexp": "^5.0.0",
|
37
34
|
"json-schema-typed": "^8.0.1",
|
38
35
|
"wildcard-match": "^5.1.3",
|
39
36
|
"zod": "^3.24.1",
|
40
|
-
"@orpc/shared": "0.0.0-next.
|
37
|
+
"@orpc/shared": "0.0.0-next.df024bb"
|
41
38
|
},
|
42
39
|
"scripts": {
|
43
|
-
"build": "
|
40
|
+
"build": "unbuild",
|
44
41
|
"build:watch": "pnpm run build --watch",
|
45
42
|
"type:check": "tsc -b"
|
46
43
|
}
|
package/dist/src/coercer.d.ts
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
import type { Context } from '@orpc/server';
|
2
|
-
import type { Plugin } from '@orpc/server/plugins';
|
3
|
-
import type { WellCreateProcedureClientOptions } from '@orpc/server/standard';
|
4
|
-
export declare class ZodAutoCoercePlugin<TContext extends Context> implements Plugin<TContext> {
|
5
|
-
beforeCreateProcedureClient(clientOptions: WellCreateProcedureClientOptions<TContext>): void;
|
6
|
-
}
|
7
|
-
//# sourceMappingURL=coercer.d.ts.map
|
package/dist/src/converter.d.ts
DELETED
@@ -1,50 +0,0 @@
|
|
1
|
-
import type { Schema } from '@orpc/contract';
|
2
|
-
import type { JSONSchema, SchemaConverter, SchemaConvertOptions } from '@orpc/openapi';
|
3
|
-
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
4
|
-
export declare const NON_LOGIC_KEYWORDS: ("$anchor" | "$comment" | "$defs" | "$dynamicAnchor" | "$dynamicRef" | "$id" | "$schema" | "$vocabulary" | "contentEncoding" | "contentMediaType" | "default" | "definitions" | "deprecated" | "description" | "examples" | "format" | "readOnly" | "title" | "writeOnly")[];
|
5
|
-
export declare const UNSUPPORTED_JSON_SCHEMA: {
|
6
|
-
not: {};
|
7
|
-
};
|
8
|
-
export declare const UNDEFINED_JSON_SCHEMA: {
|
9
|
-
const: string;
|
10
|
-
};
|
11
|
-
export interface ZodToJsonSchemaOptions {
|
12
|
-
/**
|
13
|
-
* Max depth of lazy type, if it exceeds.
|
14
|
-
*
|
15
|
-
* Used `{}` when reach max depth
|
16
|
-
*
|
17
|
-
* @default 5
|
18
|
-
*/
|
19
|
-
maxLazyDepth?: number;
|
20
|
-
/**
|
21
|
-
* The length used to track the depth of lazy type
|
22
|
-
*
|
23
|
-
* @internal
|
24
|
-
*/
|
25
|
-
lazyDepth?: number;
|
26
|
-
/**
|
27
|
-
* The expected json schema for input or output zod schema
|
28
|
-
*
|
29
|
-
* @default input
|
30
|
-
*/
|
31
|
-
mode?: 'input' | 'output';
|
32
|
-
/**
|
33
|
-
* Track if current level schema is handled custom json schema to prevent recursive
|
34
|
-
*
|
35
|
-
* @internal
|
36
|
-
*/
|
37
|
-
isHandledCustomJSONSchema?: boolean;
|
38
|
-
/**
|
39
|
-
* Track if current level schema is handled zod description to prevent recursive
|
40
|
-
*
|
41
|
-
* @internal
|
42
|
-
*/
|
43
|
-
isHandledZodDescription?: boolean;
|
44
|
-
}
|
45
|
-
export declare function zodToJsonSchema(schema: StandardSchemaV1, options?: ZodToJsonSchemaOptions): Exclude<JSONSchema.JSONSchema, boolean>;
|
46
|
-
export declare class ZodToJsonSchemaConverter implements SchemaConverter {
|
47
|
-
condition(schema: Schema): boolean;
|
48
|
-
convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
|
49
|
-
}
|
50
|
-
//# sourceMappingURL=converter.d.ts.map
|
package/dist/src/index.d.ts
DELETED
package/dist/src/schemas.d.ts
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
import type { JSONSchema } from 'json-schema-typed/draft-2020-12';
|
2
|
-
import { type CustomErrorParams, type input, type output, type ZodEffects, type ZodType, type ZodTypeAny, type ZodTypeDef } from 'zod';
|
3
|
-
export type CustomZodType = 'File' | 'Blob' | 'Invalid Date' | 'RegExp' | 'URL';
|
4
|
-
type CustomParams = CustomErrorParams & {
|
5
|
-
fatal?: boolean;
|
6
|
-
};
|
7
|
-
export declare function getCustomZodType(def: ZodTypeDef): CustomZodType | undefined;
|
8
|
-
export declare function getCustomZodFileMimeType(def: ZodTypeDef): string | undefined;
|
9
|
-
export declare function getCustomJSONSchema(def: ZodTypeDef, options?: {
|
10
|
-
mode?: 'input' | 'output';
|
11
|
-
}): Exclude<JSONSchema, boolean> | undefined;
|
12
|
-
export declare function file(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<InstanceType<typeof File>, ZodTypeDef, InstanceType<typeof File>> & {
|
13
|
-
type(mimeType: string, params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodEffects<ZodType<InstanceType<typeof File>, ZodTypeDef, InstanceType<typeof File>>, InstanceType<typeof File>, InstanceType<typeof File>>;
|
14
|
-
};
|
15
|
-
export declare function blob(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<InstanceType<typeof Blob>, ZodTypeDef, InstanceType<typeof Blob>>;
|
16
|
-
export declare function invalidDate(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<Date, ZodTypeDef, Date>;
|
17
|
-
export declare function regexp(options?: CustomParams): ZodType<RegExp, ZodTypeDef, RegExp>;
|
18
|
-
export declare function url(options?: CustomParams): ZodType<URL, ZodTypeDef, URL>;
|
19
|
-
export declare function openapi<T extends ZodTypeAny, TMode extends 'input' | 'output' | 'both' = 'both'>(schema: T, custom: Exclude<JSONSchema<TMode extends 'input' ? input<T> : TMode extends 'output' ? output<T> : input<T> & output<T>>, boolean>, options?: {
|
20
|
-
mode: TMode;
|
21
|
-
}): ReturnType<T['refine']>;
|
22
|
-
export declare const oz: {
|
23
|
-
openapi: typeof openapi;
|
24
|
-
file: typeof file;
|
25
|
-
blob: typeof blob;
|
26
|
-
invalidDate: typeof invalidDate;
|
27
|
-
regexp: typeof regexp;
|
28
|
-
url: typeof url;
|
29
|
-
};
|
30
|
-
export {};
|
31
|
-
//# sourceMappingURL=schemas.d.ts.map
|