@orpc/zod 0.0.0-next.f50512c → 0.0.0-next.f5149a8
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 +7 -2
- package/dist/index.mjs +4 -7
- package/dist/zod4/index.mjs +5 -5
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
<a href="https://discord.gg/TXEbwRBvQn">
|
|
18
18
|
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
|
19
19
|
</a>
|
|
20
|
+
<a href="https://deepwiki.com/unnoq/orpc">
|
|
21
|
+
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
|
|
22
|
+
</a>
|
|
20
23
|
</div>
|
|
21
24
|
|
|
22
25
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
|
@@ -30,7 +33,8 @@
|
|
|
30
33
|
- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
|
|
31
34
|
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
32
35
|
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
33
|
-
-
|
|
36
|
+
- **🔍 First-Class OpenTelemetry**: Seamlessly integrate with OpenTelemetry for observability.
|
|
37
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more.
|
|
34
38
|
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
35
39
|
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
36
40
|
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
@@ -38,7 +42,6 @@
|
|
|
38
42
|
- **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
|
|
39
43
|
- **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
|
|
40
44
|
- **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
|
|
41
|
-
- **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.
|
|
42
45
|
|
|
43
46
|
## Documentation
|
|
44
47
|
|
|
@@ -50,9 +53,11 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
|
50
53
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
51
54
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
52
55
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
56
|
+
- [@orpc/otel](https://www.npmjs.com/package/@orpc/otel): [OpenTelemetry](https://opentelemetry.io/) integration for observability.
|
|
53
57
|
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
|
54
58
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
55
59
|
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
|
|
60
|
+
- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration.
|
|
56
61
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
57
62
|
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
|
|
58
63
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
package/dist/index.mjs
CHANGED
|
@@ -129,7 +129,7 @@ class ZodSmartCoercionPlugin {
|
|
|
129
129
|
options.clientInterceptors ??= [];
|
|
130
130
|
options.clientInterceptors.unshift((options2) => {
|
|
131
131
|
const inputSchema = options2.procedure["~orpc"].inputSchema;
|
|
132
|
-
if (!inputSchema || inputSchema["~standard"].vendor !== "zod") {
|
|
132
|
+
if (!inputSchema || inputSchema["~standard"].vendor !== "zod" || "_zod" in inputSchema) {
|
|
133
133
|
return options2.next();
|
|
134
134
|
}
|
|
135
135
|
const coercedInput = zodCoerceInternal(inputSchema, options2.input);
|
|
@@ -401,7 +401,7 @@ class ZodToJsonSchemaConverter {
|
|
|
401
401
|
this.anyJsonSchema = options.anyJsonSchema ?? {};
|
|
402
402
|
}
|
|
403
403
|
condition(schema) {
|
|
404
|
-
return schema !== void 0 && schema["~standard"].vendor === "zod";
|
|
404
|
+
return schema !== void 0 && schema["~standard"].vendor === "zod" && !("_zod" in schema);
|
|
405
405
|
}
|
|
406
406
|
convert(schema, options, lazyDepth = 0, isHandledCustomJSONSchema = false, isHandledZodDescription = false, structureDepth = 0) {
|
|
407
407
|
const def = schema._def;
|
|
@@ -724,7 +724,7 @@ class ZodToJsonSchemaConverter {
|
|
|
724
724
|
const anyOf = [];
|
|
725
725
|
let required = true;
|
|
726
726
|
for (const item of schema_._def.options) {
|
|
727
|
-
const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false, structureDepth);
|
|
727
|
+
const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false, structureDepth + 1);
|
|
728
728
|
if (!itemRequired) {
|
|
729
729
|
required = false;
|
|
730
730
|
if (itemJson !== this.unsupportedJsonSchema) {
|
|
@@ -734,9 +734,6 @@ class ZodToJsonSchemaConverter {
|
|
|
734
734
|
anyOf.push(itemJson);
|
|
735
735
|
}
|
|
736
736
|
}
|
|
737
|
-
if (anyOf.length === 1) {
|
|
738
|
-
return [required, anyOf[0]];
|
|
739
|
-
}
|
|
740
737
|
return [required, { anyOf }];
|
|
741
738
|
}
|
|
742
739
|
case ZodFirstPartyTypeKind.ZodIntersection: {
|
|
@@ -744,7 +741,7 @@ class ZodToJsonSchemaConverter {
|
|
|
744
741
|
const allOf = [];
|
|
745
742
|
let required = false;
|
|
746
743
|
for (const item of [schema_._def.left, schema_._def.right]) {
|
|
747
|
-
const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false, structureDepth);
|
|
744
|
+
const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false, structureDepth + 1);
|
|
748
745
|
allOf.push(itemJson);
|
|
749
746
|
if (itemRequired) {
|
|
750
747
|
required = true;
|
package/dist/zod4/index.mjs
CHANGED
|
@@ -8,7 +8,7 @@ class experimental_ZodSmartCoercionPlugin {
|
|
|
8
8
|
options.clientInterceptors ??= [];
|
|
9
9
|
options.clientInterceptors.unshift((options2) => {
|
|
10
10
|
const inputSchema = options2.procedure["~orpc"].inputSchema;
|
|
11
|
-
if (!inputSchema || inputSchema["~standard"].vendor !== "zod") {
|
|
11
|
+
if (!inputSchema || inputSchema["~standard"].vendor !== "zod" || !("_zod" in inputSchema)) {
|
|
12
12
|
return options2.next();
|
|
13
13
|
}
|
|
14
14
|
const coercedInput = this.#coerce(inputSchema, options2.input);
|
|
@@ -289,7 +289,7 @@ class ZodToJsonSchemaConverter {
|
|
|
289
289
|
this.interceptors = options.interceptors ?? [];
|
|
290
290
|
}
|
|
291
291
|
condition(schema) {
|
|
292
|
-
return schema !== void 0 && schema["~standard"].vendor === "zod";
|
|
292
|
+
return schema !== void 0 && schema["~standard"].vendor === "zod" && "_zod" in schema;
|
|
293
293
|
}
|
|
294
294
|
convert(schema, options) {
|
|
295
295
|
return this.#convert(schema, options, 0, 0);
|
|
@@ -446,7 +446,7 @@ class ZodToJsonSchemaConverter {
|
|
|
446
446
|
const anyOf = [];
|
|
447
447
|
let required = true;
|
|
448
448
|
for (const item of union._zod.def.options) {
|
|
449
|
-
const [itemRequired, itemJson] = this.#convert(item, options2, lazyDepth2, structureDepth);
|
|
449
|
+
const [itemRequired, itemJson] = this.#convert(item, options2, lazyDepth2, structureDepth + 1);
|
|
450
450
|
if (!itemRequired) {
|
|
451
451
|
required = false;
|
|
452
452
|
}
|
|
@@ -460,14 +460,14 @@ class ZodToJsonSchemaConverter {
|
|
|
460
460
|
}
|
|
461
461
|
}
|
|
462
462
|
}
|
|
463
|
-
return [required,
|
|
463
|
+
return [required, { anyOf }];
|
|
464
464
|
}
|
|
465
465
|
case "intersection": {
|
|
466
466
|
const intersection = schema2;
|
|
467
467
|
const json = { allOf: [] };
|
|
468
468
|
let required = false;
|
|
469
469
|
for (const item of [intersection._zod.def.left, intersection._zod.def.right]) {
|
|
470
|
-
const [itemRequired, itemJson] = this.#convert(item, options2, lazyDepth2, structureDepth);
|
|
470
|
+
const [itemRequired, itemJson] = this.#convert(item, options2, lazyDepth2, structureDepth + 1);
|
|
471
471
|
json.allOf.push(itemJson);
|
|
472
472
|
if (itemRequired) {
|
|
473
473
|
required = true;
|
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.f5149a8",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -30,18 +30,18 @@
|
|
|
30
30
|
],
|
|
31
31
|
"peerDependencies": {
|
|
32
32
|
"zod": ">=3.25.0",
|
|
33
|
-
"@orpc/contract": "0.0.0-next.
|
|
34
|
-
"@orpc/server": "0.0.0-next.
|
|
33
|
+
"@orpc/contract": "0.0.0-next.f5149a8",
|
|
34
|
+
"@orpc/server": "0.0.0-next.f5149a8"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"escape-string-regexp": "^5.0.0",
|
|
38
38
|
"wildcard-match": "^5.1.3",
|
|
39
|
-
"@orpc/
|
|
40
|
-
"@orpc/
|
|
41
|
-
"@orpc/
|
|
39
|
+
"@orpc/openapi": "0.0.0-next.f5149a8",
|
|
40
|
+
"@orpc/shared": "0.0.0-next.f5149a8",
|
|
41
|
+
"@orpc/json-schema": "0.0.0-next.f5149a8"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"zod": "^4.
|
|
44
|
+
"zod": "^4.1.12"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
47
|
"build": "unbuild",
|