@orpc/zod 0.0.0-next.af8ac85 → 0.0.0-next.b0f324e

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 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.
@@ -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 };
@@ -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,46 +1,23 @@
1
- // ../../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/getType.js
2
- function getType(payload) {
3
- return Object.prototype.toString.call(payload).slice(8, -1);
4
- }
5
-
6
- // ../../node_modules/.pnpm/is-what@5.0.2/node_modules/is-what/dist/isPlainObject.js
7
- function isPlainObject(payload) {
8
- if (getType(payload) !== "Object")
9
- return false;
10
- const prototype = Object.getPrototypeOf(payload);
11
- return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
12
- }
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';
13
7
 
14
- // ../../node_modules/.pnpm/radash@12.1.0/node_modules/radash/dist/esm/async.mjs
15
- var guard = (func, shouldGuard) => {
16
- const _guard = (err) => {
17
- if (shouldGuard && !shouldGuard(err))
18
- throw err;
19
- return void 0;
20
- };
21
- const isPromise2 = (result) => result instanceof Promise;
22
- try {
23
- const result = func();
24
- return isPromise2(result) ? result.catch(_guard) : result;
25
- } catch (err) {
26
- return _guard(err);
8
+ class ZodSmartCoercionPlugin {
9
+ init(options) {
10
+ options.clientInterceptors ??= [];
11
+ options.clientInterceptors.unshift((options2) => {
12
+ const inputSchema = options2.procedure["~orpc"].inputSchema;
13
+ if (!inputSchema || inputSchema["~standard"].vendor !== "zod") {
14
+ return options2.next();
15
+ }
16
+ const coercedInput = zodCoerceInternal(inputSchema, options2.input, { bracketNotation: true });
17
+ return options2.next({ ...options2, input: coercedInput });
18
+ });
27
19
  }
28
- };
29
-
30
- // src/coercer.ts
31
- import {
32
- ZodFirstPartyTypeKind
33
- } from "zod";
34
- var ZodCoercer = class {
35
- coerce(schema, value) {
36
- if (!schema || schema["~standard"].vendor !== "zod") {
37
- return value;
38
- }
39
- const zodSchema = schema;
40
- const coerced = zodCoerceInternal(zodSchema, value, { bracketNotation: true });
41
- return coerced;
42
- }
43
- };
20
+ }
44
21
  function zodCoerceInternal(schema, value, options) {
45
22
  const isRoot = options?.isRoot ?? true;
46
23
  const options_ = { ...options, isRoot: false };
@@ -51,7 +28,7 @@ function zodCoerceInternal(schema, value, options) {
51
28
  }
52
29
  return zodCoerceInternal(schema, value, options_);
53
30
  }
54
- const customType = getCustomZodType(schema._def);
31
+ const customType = getCustomZodType$1(schema._def);
55
32
  if (customType === "Invalid Date") {
56
33
  if (typeof value === "string" && value.toLocaleLowerCase() === "invalid date") {
57
34
  return /* @__PURE__ */ new Date("Invalid Date");
@@ -66,9 +43,9 @@ function zodCoerceInternal(schema, value, options) {
66
43
  }
67
44
  } else if (customType === "URL") {
68
45
  if (typeof value === "string") {
69
- const url2 = guard(() => new URL(value));
70
- if (url2 !== void 0) {
71
- return url2;
46
+ const url = guard(() => new URL(value));
47
+ if (url !== void 0) {
48
+ return url;
72
49
  }
73
50
  }
74
51
  }
@@ -125,7 +102,7 @@ function zodCoerceInternal(schema, value, options) {
125
102
  if (value === void 0) {
126
103
  return [];
127
104
  }
128
- if (isPlainObject(value) && Object.keys(value).every((k) => /^[1-9]\d*$/.test(k) || k === "0")) {
105
+ if (isObject(value) && Object.keys(value).every((k) => /^[1-9]\d*$/.test(k) || k === "0")) {
129
106
  const indexes = Object.keys(value).map((k) => Number(k)).sort((a, b) => a - b);
130
107
  const arr = Array.from({ length: (indexes.at(-1) ?? -1) + 1 });
131
108
  for (const i of indexes) {
@@ -136,7 +113,7 @@ function zodCoerceInternal(schema, value, options) {
136
113
  }
137
114
  } else if (typeName === ZodFirstPartyTypeKind.ZodObject) {
138
115
  const schema_ = schema;
139
- if (isPlainObject(value)) {
116
+ if (isObject(value)) {
140
117
  const newObj = {};
141
118
  const keys = /* @__PURE__ */ new Set([
142
119
  ...Object.keys(value),
@@ -174,7 +151,7 @@ function zodCoerceInternal(schema, value, options) {
174
151
  if (value === void 0) {
175
152
  return /* @__PURE__ */ new Set();
176
153
  }
177
- if (isPlainObject(value) && Object.keys(value).every((k) => /^[1-9]\d*$/.test(k) || k === "0")) {
154
+ if (isObject(value) && Object.keys(value).every((k) => /^[1-9]\d*$/.test(k) || k === "0")) {
178
155
  const indexes = Object.keys(value).map((k) => Number(k)).sort((a, b) => a - b);
179
156
  const arr = Array.from({ length: (indexes.at(-1) ?? -1) + 1 });
180
157
  for (const i of indexes) {
@@ -197,9 +174,9 @@ function zodCoerceInternal(schema, value, options) {
197
174
  if (value === void 0) {
198
175
  return /* @__PURE__ */ new Map();
199
176
  }
200
- if (isPlainObject(value)) {
177
+ if (isObject(value)) {
201
178
  const arr = Array.from({ length: Object.keys(value).length }).fill(void 0).map(
202
- (_, i) => isPlainObject(value[i]) && Object.keys(value[i]).length === 2 && "0" in value[i] && "1" in value[i] ? [value[i]["0"], value[i]["1"]] : void 0
179
+ (_, i) => isObject(value[i]) && Object.keys(value[i]).length === 2 && "0" in value[i] && "1" in value[i] ? [value[i]["0"], value[i]["1"]] : void 0
203
180
  );
204
181
  if (arr.every((v) => !!v)) {
205
182
  return new Map(
@@ -213,7 +190,7 @@ function zodCoerceInternal(schema, value, options) {
213
190
  }
214
191
  } else if (typeName === ZodFirstPartyTypeKind.ZodRecord) {
215
192
  const schema_ = schema;
216
- if (isPlainObject(value)) {
193
+ if (isObject(value)) {
217
194
  const newObj = {};
218
195
  for (const [k, v] of Object.entries(value)) {
219
196
  const key = zodCoerceInternal(schema_._def.keyType, k, options_);
@@ -334,38 +311,15 @@ function zodCoerceInternal(schema, value, options) {
334
311
  }
335
312
  }
336
313
  }
337
- } else {
338
- const _expected = typeName;
339
- }
314
+ } else ;
340
315
  return value;
341
316
  }
342
317
 
343
- // src/converter.ts
344
- import { JSONSchemaFormat } from "@orpc/openapi";
345
-
346
- // ../../node_modules/.pnpm/escape-string-regexp@5.0.0/node_modules/escape-string-regexp/index.js
347
- function escapeStringRegexp(string) {
348
- if (typeof string !== "string") {
349
- throw new TypeError("Expected a string");
350
- }
351
- return string.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
352
- }
353
-
354
- // src/converter.ts
355
- import {
356
- ZodFirstPartyTypeKind as ZodFirstPartyTypeKind2
357
- } from "zod";
358
-
359
- // src/schemas.ts
360
- import wcmatch from "wildcard-match";
361
- import {
362
- custom
363
- } from "zod";
364
- var customZodTypeSymbol = Symbol("customZodTypeSymbol");
365
- var customZodFileMimeTypeSymbol = Symbol("customZodFileMimeTypeSymbol");
366
- var CUSTOM_JSON_SCHEMA_SYMBOL = Symbol("CUSTOM_JSON_SCHEMA");
367
- var CUSTOM_JSON_SCHEMA_INPUT_SYMBOL = Symbol("CUSTOM_JSON_SCHEMA_INPUT");
368
- 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");
369
323
  function getCustomZodType(def) {
370
324
  return customZodTypeSymbol in def ? def[customZodTypeSymbol] : void 0;
371
325
  }
@@ -483,7 +437,7 @@ function openapi(schema, custom2, options) {
483
437
  });
484
438
  return newSchema;
485
439
  }
486
- var oz = {
440
+ const oz = {
487
441
  openapi,
488
442
  file,
489
443
  blob,
@@ -492,8 +446,7 @@ var oz = {
492
446
  url
493
447
  };
494
448
 
495
- // src/converter.ts
496
- var NON_LOGIC_KEYWORDS = [
449
+ const NON_LOGIC_KEYWORDS = [
497
450
  // Core Documentation Keywords
498
451
  "$anchor",
499
452
  "$comment",
@@ -520,14 +473,24 @@ var NON_LOGIC_KEYWORDS = [
520
473
  "$dynamicAnchor",
521
474
  "$dynamicRef"
522
475
  ];
523
- var UNSUPPORTED_JSON_SCHEMA = { not: {} };
524
- var UNDEFINED_JSON_SCHEMA = { const: "undefined" };
476
+ const UNSUPPORTED_JSON_SCHEMA = { not: {} };
477
+ const UNDEFINED_JSON_SCHEMA = { const: "undefined" };
525
478
  function zodToJsonSchema(schema, options) {
526
479
  if (schema["~standard"].vendor !== "zod") {
527
480
  console.warn(`Generate JSON schema not support ${schema["~standard"].vendor} yet`);
528
481
  return {};
529
482
  }
530
483
  const schema__ = schema;
484
+ if (!options?.isHandledZodDescription && "description" in schema__._def) {
485
+ const json = zodToJsonSchema(schema__, {
486
+ ...options,
487
+ isHandledZodDescription: true
488
+ });
489
+ return {
490
+ description: schema__._def.description,
491
+ ...json
492
+ };
493
+ }
531
494
  if (!options?.isHandledCustomJSONSchema) {
532
495
  const customJSONSchema = getCustomJSONSchema(schema__._def, options);
533
496
  if (customJSONSchema) {
@@ -541,7 +504,7 @@ function zodToJsonSchema(schema, options) {
541
504
  };
542
505
  }
543
506
  }
544
- const childOptions = { ...options, isHandledCustomJSONSchema: false };
507
+ const childOptions = { ...options, isHandledCustomJSONSchema: false, isHandledZodDescription: false };
545
508
  const customType = getCustomZodType(schema__._def);
546
509
  switch (customType) {
547
510
  case "Blob": {
@@ -564,10 +527,9 @@ function zodToJsonSchema(schema, options) {
564
527
  return { type: "string", format: JSONSchemaFormat.URI };
565
528
  }
566
529
  }
567
- const _expectedCustomType = customType;
568
530
  const typeName = schema__._def.typeName;
569
531
  switch (typeName) {
570
- case ZodFirstPartyTypeKind2.ZodString: {
532
+ case ZodFirstPartyTypeKind.ZodString: {
571
533
  const schema_ = schema__;
572
534
  const json = { type: "string" };
573
535
  for (const check of schema_._def.checks) {
@@ -643,13 +605,13 @@ function zodToJsonSchema(schema, options) {
643
605
  json.pattern = "^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$";
644
606
  break;
645
607
  default: {
646
- const _expect = check.kind;
608
+ check.kind;
647
609
  }
648
610
  }
649
611
  }
650
612
  return json;
651
613
  }
652
- case ZodFirstPartyTypeKind2.ZodNumber: {
614
+ case ZodFirstPartyTypeKind.ZodNumber: {
653
615
  const schema_ = schema__;
654
616
  const json = { type: "number" };
655
617
  for (const check of schema_._def.checks) {
@@ -667,53 +629,54 @@ function zodToJsonSchema(schema, options) {
667
629
  json.multipleOf = check.value;
668
630
  break;
669
631
  default: {
670
- const _expect = check.kind;
632
+ check.kind;
671
633
  }
672
634
  }
673
635
  }
674
636
  return json;
675
637
  }
676
- case ZodFirstPartyTypeKind2.ZodNaN: {
638
+ case ZodFirstPartyTypeKind.ZodNaN: {
677
639
  return { const: "NaN" };
678
640
  }
679
- case ZodFirstPartyTypeKind2.ZodBigInt: {
641
+ case ZodFirstPartyTypeKind.ZodBigInt: {
680
642
  const json = { type: "string", pattern: "^-?[0-9]+$" };
681
643
  return json;
682
644
  }
683
- case ZodFirstPartyTypeKind2.ZodBoolean: {
645
+ case ZodFirstPartyTypeKind.ZodBoolean: {
684
646
  return { type: "boolean" };
685
647
  }
686
- case ZodFirstPartyTypeKind2.ZodDate: {
648
+ case ZodFirstPartyTypeKind.ZodDate: {
687
649
  const schema2 = { type: "string", format: JSONSchemaFormat.Date };
688
650
  return schema2;
689
651
  }
690
- case ZodFirstPartyTypeKind2.ZodNull: {
652
+ case ZodFirstPartyTypeKind.ZodNull: {
691
653
  return { type: "null" };
692
654
  }
693
- case ZodFirstPartyTypeKind2.ZodVoid:
694
- case ZodFirstPartyTypeKind2.ZodUndefined: {
655
+ case ZodFirstPartyTypeKind.ZodVoid:
656
+ case ZodFirstPartyTypeKind.ZodUndefined: {
695
657
  return UNDEFINED_JSON_SCHEMA;
696
658
  }
697
- case ZodFirstPartyTypeKind2.ZodLiteral: {
659
+ case ZodFirstPartyTypeKind.ZodLiteral: {
698
660
  const schema_ = schema__;
699
661
  return { const: schema_._def.value };
700
662
  }
701
- case ZodFirstPartyTypeKind2.ZodEnum: {
663
+ case ZodFirstPartyTypeKind.ZodEnum: {
702
664
  const schema_ = schema__;
703
665
  return {
704
666
  enum: schema_._def.values
705
667
  };
706
668
  }
707
- case ZodFirstPartyTypeKind2.ZodNativeEnum: {
669
+ case ZodFirstPartyTypeKind.ZodNativeEnum: {
708
670
  const schema_ = schema__;
709
671
  return {
710
672
  enum: Object.values(schema_._def.values)
711
673
  };
712
674
  }
713
- case ZodFirstPartyTypeKind2.ZodArray: {
675
+ case ZodFirstPartyTypeKind.ZodArray: {
714
676
  const schema_ = schema__;
715
677
  const def = schema_._def;
716
678
  const json = { type: "array" };
679
+ json.items = zodToJsonSchema(def.type, childOptions);
717
680
  if (def.exactLength) {
718
681
  json.maxItems = def.exactLength.value;
719
682
  json.minItems = def.exactLength.value;
@@ -726,7 +689,7 @@ function zodToJsonSchema(schema, options) {
726
689
  }
727
690
  return json;
728
691
  }
729
- case ZodFirstPartyTypeKind2.ZodTuple: {
692
+ case ZodFirstPartyTypeKind.ZodTuple: {
730
693
  const schema_ = schema__;
731
694
  const prefixItems = [];
732
695
  const json = { type: "array" };
@@ -744,7 +707,7 @@ function zodToJsonSchema(schema, options) {
744
707
  }
745
708
  return json;
746
709
  }
747
- case ZodFirstPartyTypeKind2.ZodObject: {
710
+ case ZodFirstPartyTypeKind.ZodObject: {
748
711
  const schema_ = schema__;
749
712
  const json = { type: "object" };
750
713
  const properties = {};
@@ -780,7 +743,7 @@ function zodToJsonSchema(schema, options) {
780
743
  }
781
744
  return json;
782
745
  }
783
- case ZodFirstPartyTypeKind2.ZodRecord: {
746
+ case ZodFirstPartyTypeKind.ZodRecord: {
784
747
  const schema_ = schema__;
785
748
  const json = { type: "object" };
786
749
  json.additionalProperties = zodToJsonSchema(
@@ -789,14 +752,14 @@ function zodToJsonSchema(schema, options) {
789
752
  );
790
753
  return json;
791
754
  }
792
- case ZodFirstPartyTypeKind2.ZodSet: {
755
+ case ZodFirstPartyTypeKind.ZodSet: {
793
756
  const schema_ = schema__;
794
757
  return {
795
758
  type: "array",
796
759
  items: zodToJsonSchema(schema_._def.valueType, childOptions)
797
760
  };
798
761
  }
799
- case ZodFirstPartyTypeKind2.ZodMap: {
762
+ case ZodFirstPartyTypeKind.ZodMap: {
800
763
  const schema_ = schema__;
801
764
  return {
802
765
  type: "array",
@@ -811,8 +774,8 @@ function zodToJsonSchema(schema, options) {
811
774
  }
812
775
  };
813
776
  }
814
- case ZodFirstPartyTypeKind2.ZodUnion:
815
- case ZodFirstPartyTypeKind2.ZodDiscriminatedUnion: {
777
+ case ZodFirstPartyTypeKind.ZodUnion:
778
+ case ZodFirstPartyTypeKind.ZodDiscriminatedUnion: {
816
779
  const schema_ = schema__;
817
780
  const anyOf = [];
818
781
  for (const s of schema_._def.options) {
@@ -820,7 +783,7 @@ function zodToJsonSchema(schema, options) {
820
783
  }
821
784
  return { anyOf };
822
785
  }
823
- case ZodFirstPartyTypeKind2.ZodIntersection: {
786
+ case ZodFirstPartyTypeKind.ZodIntersection: {
824
787
  const schema_ = schema__;
825
788
  const allOf = [];
826
789
  for (const s of [schema_._def.left, schema_._def.right]) {
@@ -828,7 +791,7 @@ function zodToJsonSchema(schema, options) {
828
791
  }
829
792
  return { allOf };
830
793
  }
831
- case ZodFirstPartyTypeKind2.ZodLazy: {
794
+ case ZodFirstPartyTypeKind.ZodLazy: {
832
795
  const schema_ = schema__;
833
796
  const maxLazyDepth = childOptions?.maxLazyDepth ?? 5;
834
797
  const lazyDepth = childOptions?.lazyDepth ?? 0;
@@ -840,49 +803,49 @@ function zodToJsonSchema(schema, options) {
840
803
  lazyDepth: lazyDepth + 1
841
804
  });
842
805
  }
843
- case ZodFirstPartyTypeKind2.ZodUnknown:
844
- case ZodFirstPartyTypeKind2.ZodAny:
806
+ case ZodFirstPartyTypeKind.ZodUnknown:
807
+ case ZodFirstPartyTypeKind.ZodAny:
845
808
  case void 0: {
846
809
  return {};
847
810
  }
848
- case ZodFirstPartyTypeKind2.ZodOptional: {
811
+ case ZodFirstPartyTypeKind.ZodOptional: {
849
812
  const schema_ = schema__;
850
813
  const inner = zodToJsonSchema(schema_._def.innerType, childOptions);
851
814
  return {
852
815
  anyOf: [UNDEFINED_JSON_SCHEMA, inner]
853
816
  };
854
817
  }
855
- case ZodFirstPartyTypeKind2.ZodReadonly: {
818
+ case ZodFirstPartyTypeKind.ZodReadonly: {
856
819
  const schema_ = schema__;
857
820
  return zodToJsonSchema(schema_._def.innerType, childOptions);
858
821
  }
859
- case ZodFirstPartyTypeKind2.ZodDefault: {
822
+ case ZodFirstPartyTypeKind.ZodDefault: {
860
823
  const schema_ = schema__;
861
824
  return zodToJsonSchema(schema_._def.innerType, childOptions);
862
825
  }
863
- case ZodFirstPartyTypeKind2.ZodEffects: {
826
+ case ZodFirstPartyTypeKind.ZodEffects: {
864
827
  const schema_ = schema__;
865
828
  if (schema_._def.effect.type === "transform" && childOptions?.mode === "output") {
866
829
  return {};
867
830
  }
868
831
  return zodToJsonSchema(schema_._def.schema, childOptions);
869
832
  }
870
- case ZodFirstPartyTypeKind2.ZodCatch: {
833
+ case ZodFirstPartyTypeKind.ZodCatch: {
871
834
  const schema_ = schema__;
872
835
  return zodToJsonSchema(schema_._def.innerType, childOptions);
873
836
  }
874
- case ZodFirstPartyTypeKind2.ZodBranded: {
837
+ case ZodFirstPartyTypeKind.ZodBranded: {
875
838
  const schema_ = schema__;
876
839
  return zodToJsonSchema(schema_._def.type, childOptions);
877
840
  }
878
- case ZodFirstPartyTypeKind2.ZodPipeline: {
841
+ case ZodFirstPartyTypeKind.ZodPipeline: {
879
842
  const schema_ = schema__;
880
843
  return zodToJsonSchema(
881
844
  childOptions?.mode === "output" ? schema_._def.out : schema_._def.in,
882
845
  childOptions
883
846
  );
884
847
  }
885
- case ZodFirstPartyTypeKind2.ZodNullable: {
848
+ case ZodFirstPartyTypeKind.ZodNullable: {
886
849
  const schema_ = schema__;
887
850
  const inner = zodToJsonSchema(schema_._def.innerType, childOptions);
888
851
  return {
@@ -890,7 +853,6 @@ function zodToJsonSchema(schema, options) {
890
853
  };
891
854
  }
892
855
  }
893
- const _expected = typeName;
894
856
  return UNSUPPORTED_JSON_SCHEMA;
895
857
  }
896
858
  function extractJSONSchema(schema, check, matches = []) {
@@ -933,7 +895,7 @@ function extractJSONSchema(schema, check, matches = []) {
933
895
  }
934
896
  return { schema, matches };
935
897
  }
936
- var ZodToJsonSchemaConverter = class {
898
+ class ZodToJsonSchemaConverter {
937
899
  condition(schema) {
938
900
  return Boolean(schema && schema["~standard"].vendor === "zod");
939
901
  }
@@ -941,23 +903,6 @@ var ZodToJsonSchemaConverter = class {
941
903
  const jsonSchema = schema;
942
904
  return zodToJsonSchema(jsonSchema, { mode: options.strategy });
943
905
  }
944
- };
945
- export {
946
- NON_LOGIC_KEYWORDS,
947
- UNDEFINED_JSON_SCHEMA,
948
- UNSUPPORTED_JSON_SCHEMA,
949
- ZodCoercer,
950
- ZodToJsonSchemaConverter,
951
- blob,
952
- file,
953
- getCustomJSONSchema,
954
- getCustomZodFileMimeType,
955
- getCustomZodType,
956
- invalidDate,
957
- openapi,
958
- oz,
959
- regexp,
960
- url,
961
- zodToJsonSchema
962
- };
963
- //# 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.af8ac85",
4
+ "version": "0.0.0-next.b0f324e",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -15,29 +15,29 @@
15
15
  ],
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/src/index.d.ts",
19
- "import": "./dist/index.js",
20
- "default": "./dist/index.js"
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/openapi": "0.0.0-next.af8ac85"
27
+ "@orpc/contract": "0.0.0-next.b0f324e",
28
+ "@orpc/openapi": "0.0.0-next.b0f324e",
29
+ "@orpc/server": "0.0.0-next.b0f324e"
33
30
  },
34
31
  "dependencies": {
32
+ "@standard-schema/spec": "^1.0.0",
33
+ "escape-string-regexp": "^5.0.0",
35
34
  "json-schema-typed": "^8.0.1",
36
35
  "wildcard-match": "^5.1.3",
37
- "zod": "^3.24.1"
36
+ "zod": "^3.24.1",
37
+ "@orpc/shared": "0.0.0-next.b0f324e"
38
38
  },
39
39
  "scripts": {
40
- "build": "tsup --clean --sourcemap --entry.index=src/index.ts --format=esm --onSuccess='tsc -b --noCheck'",
40
+ "build": "unbuild",
41
41
  "build:watch": "pnpm run build --watch",
42
42
  "type:check": "tsc -b"
43
43
  }
@@ -1,6 +0,0 @@
1
- import type { Schema } from '@orpc/contract';
2
- import type { SchemaCoercer } from '@orpc/openapi/fetch';
3
- export declare class ZodCoercer implements SchemaCoercer {
4
- coerce(schema: Schema, value: unknown): unknown;
5
- }
6
- //# sourceMappingURL=coercer.d.ts.map
@@ -1,44 +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
- export declare function zodToJsonSchema(schema: StandardSchemaV1, options?: ZodToJsonSchemaOptions): Exclude<JSONSchema.JSONSchema, boolean>;
40
- export declare class ZodToJsonSchemaConverter implements SchemaConverter {
41
- condition(schema: Schema): boolean;
42
- convert(schema: Schema, options: SchemaConvertOptions): JSONSchema.JSONSchema;
43
- }
44
- //# sourceMappingURL=converter.d.ts.map
@@ -1,4 +0,0 @@
1
- export * from './coercer';
2
- export * from './converter';
3
- export * from './schemas';
4
- //# sourceMappingURL=index.d.ts.map
@@ -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