From c205615bd3e50caeb36ced1cad60b11d0154a66a Mon Sep 17 00:00:00 2001 From: unnoq Date: Sat, 12 Jul 2025 14:21:41 +0700 Subject: [PATCH 1/6] version --- packages/client/package.json | 2 +- packages/contract/package.json | 2 +- packages/json-schema/package.json | 2 +- packages/nest/package.json | 2 +- packages/openapi/package.json | 2 +- packages/react-query/package.json | 2 +- packages/react/package.json | 2 +- packages/shared/package.json | 2 +- packages/solid-query/package.json | 2 +- packages/svelte-query/package.json | 2 +- packages/tanstack-query/package.json | 2 +- packages/trpc/package.json | 2 +- packages/zod/package.json | 4 +- playgrounds/astro/package.json | 2 +- playgrounds/browser-extension/package.json | 2 +- playgrounds/cloudflare-worker/package.json | 2 +- playgrounds/contract-first/package.json | 2 +- playgrounds/electron/package.json | 2 +- playgrounds/nest/package.json | 2 +- playgrounds/next/package.json | 2 +- playgrounds/nuxt/package.json | 2 +- playgrounds/solid-start/package.json | 2 +- playgrounds/svelte-kit/package.json | 2 +- playgrounds/tanstack-start/package.json | 2 +- pnpm-lock.yaml | 113 +++++++++++---------- 25 files changed, 86 insertions(+), 77 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index 5f73fae41..71a40ac1c 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -70,6 +70,6 @@ "@orpc/standard-server-peer": "workspace:*" }, "devDependencies": { - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/packages/contract/package.json b/packages/contract/package.json index e574346f8..a8a6afb00 100644 --- a/packages/contract/package.json +++ b/packages/contract/package.json @@ -42,6 +42,6 @@ "devDependencies": { "arktype": "2.1.20", "valibot": "^1.1.0", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/packages/json-schema/package.json b/packages/json-schema/package.json index 373033577..c8703b4eb 100644 --- a/packages/json-schema/package.json +++ b/packages/json-schema/package.json @@ -41,6 +41,6 @@ "json-schema-typed": "^8.0.1" }, "devDependencies": { - "zod": "^3.25.74" + "zod": "^4.0.5" } } diff --git a/packages/nest/package.json b/packages/nest/package.json index 39b467f8d..feb154fe0 100644 --- a/packages/nest/package.json +++ b/packages/nest/package.json @@ -71,6 +71,6 @@ "fastify": "^5.4.0", "rxjs": "^7.8.1", "supertest": "^7.1.3", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/packages/openapi/package.json b/packages/openapi/package.json index 9f5863a10..035eed5cc 100644 --- a/packages/openapi/package.json +++ b/packages/openapi/package.json @@ -74,6 +74,6 @@ "rou3": "^0.7.3" }, "devDependencies": { - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/packages/react-query/package.json b/packages/react-query/package.json index 80ed4c811..67669b896 100644 --- a/packages/react-query/package.json +++ b/packages/react-query/package.json @@ -48,6 +48,6 @@ "devDependencies": { "@tanstack/react-query": "^5.81.5", "react": "^19.1.0", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/packages/react/package.json b/packages/react/package.json index 5e910fe01..063b50449 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -53,6 +53,6 @@ }, "devDependencies": { "react": "^19.1.0", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/packages/shared/package.json b/packages/shared/package.json index 60bf21377..d7ae549b9 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -40,6 +40,6 @@ "devDependencies": { "arktype": "2.1.20", "valibot": "^1.1.0", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/packages/solid-query/package.json b/packages/solid-query/package.json index 7d003713a..dfd71cb32 100644 --- a/packages/solid-query/package.json +++ b/packages/solid-query/package.json @@ -47,6 +47,6 @@ }, "devDependencies": { "@tanstack/solid-query": "^5.81.5", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/packages/svelte-query/package.json b/packages/svelte-query/package.json index ccc671c2a..bd412d930 100644 --- a/packages/svelte-query/package.json +++ b/packages/svelte-query/package.json @@ -47,6 +47,6 @@ }, "devDependencies": { "@tanstack/svelte-query": "^5.81.5", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/packages/tanstack-query/package.json b/packages/tanstack-query/package.json index 9ae55feb5..0ed86189e 100644 --- a/packages/tanstack-query/package.json +++ b/packages/tanstack-query/package.json @@ -50,6 +50,6 @@ "@tanstack/vue-query": "^5.81.5", "svelte": "^5.35.4", "vue": "^3.5.17", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/packages/trpc/package.json b/packages/trpc/package.json index 204523ad6..0e6852f31 100644 --- a/packages/trpc/package.json +++ b/packages/trpc/package.json @@ -44,6 +44,6 @@ }, "devDependencies": { "@trpc/server": "^11.4.3", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/packages/zod/package.json b/packages/zod/package.json index 59a08d7ad..1a3579b3a 100644 --- a/packages/zod/package.json +++ b/packages/zod/package.json @@ -42,7 +42,7 @@ "peerDependencies": { "@orpc/contract": "workspace:*", "@orpc/server": "workspace:*", - "zod": ">=3.24.2" + "zod": ">=3.25.0" }, "dependencies": { "@orpc/json-schema": "workspace:*", @@ -52,7 +52,7 @@ "wildcard-match": "^5.1.3" }, "devDependencies": { - "zod": "^3.25.76", + "zod": "^4.0.5", "zod-to-json-schema": "^3.24.6" } } diff --git a/playgrounds/astro/package.json b/playgrounds/astro/package.json index 86200d459..4960fb246 100644 --- a/playgrounds/astro/package.json +++ b/playgrounds/astro/package.json @@ -26,6 +26,6 @@ "react": "^19.1.0", "react-dom": "^19.1.0", "typescript": "^5.8.3", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/playgrounds/browser-extension/package.json b/playgrounds/browser-extension/package.json index acc25f57e..af597d503 100644 --- a/playgrounds/browser-extension/package.json +++ b/playgrounds/browser-extension/package.json @@ -29,6 +29,6 @@ "react-dom": "^19.1.0", "typescript": "^5.8.3", "wxt": "^0.20.6", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/playgrounds/cloudflare-worker/package.json b/playgrounds/cloudflare-worker/package.json index 662fc8cb7..6d476e855 100644 --- a/playgrounds/cloudflare-worker/package.json +++ b/playgrounds/cloudflare-worker/package.json @@ -24,6 +24,6 @@ "typescript": "~5.8.3", "vite": "^6.3.5", "wrangler": "^4.23.0", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/playgrounds/contract-first/package.json b/playgrounds/contract-first/package.json index ea672bac3..998769203 100644 --- a/playgrounds/contract-first/package.json +++ b/playgrounds/contract-first/package.json @@ -20,6 +20,6 @@ "@types/node": "^22.15.18", "tsx": "^4.20.3", "typescript": "^5.8.3", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/playgrounds/electron/package.json b/playgrounds/electron/package.json index 0deca2643..5d4358527 100644 --- a/playgrounds/electron/package.json +++ b/playgrounds/electron/package.json @@ -33,6 +33,6 @@ "react-dom": "^19.1.0", "typescript": "^5.8.3", "vite": "^6.3.5", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/playgrounds/nest/package.json b/playgrounds/nest/package.json index 6a30d745f..1e3864fd3 100644 --- a/playgrounds/nest/package.json +++ b/playgrounds/nest/package.json @@ -34,6 +34,6 @@ "tsconfig-paths": "^4.2.0", "typescript": "^5.8.3", "unbuild": "^3.5.0", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/playgrounds/next/package.json b/playgrounds/next/package.json index 35e49cb09..3d221e45e 100644 --- a/playgrounds/next/package.json +++ b/playgrounds/next/package.json @@ -25,6 +25,6 @@ "react": "^19.1.0", "react-dom": "^19.1.0", "typescript": "^5.8.3", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/playgrounds/nuxt/package.json b/playgrounds/nuxt/package.json index 0092af7bc..f9b6b0de3 100644 --- a/playgrounds/nuxt/package.json +++ b/playgrounds/nuxt/package.json @@ -20,6 +20,6 @@ "nuxt": "^3.17.6", "vue": "latest", "vue-router": "latest", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/playgrounds/solid-start/package.json b/playgrounds/solid-start/package.json index a1a8cd9bc..b552300c5 100644 --- a/playgrounds/solid-start/package.json +++ b/playgrounds/solid-start/package.json @@ -20,6 +20,6 @@ "solid-js": "^1.9.5", "vinxi": "^0.5.8", "vite-plugin-top-level-await": "^1.5.0", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/playgrounds/svelte-kit/package.json b/playgrounds/svelte-kit/package.json index 26944a16c..d22de9ea1 100644 --- a/playgrounds/svelte-kit/package.json +++ b/playgrounds/svelte-kit/package.json @@ -26,6 +26,6 @@ "svelte-check": "^4.2.2", "typescript": "^5.8.3", "vite": "^6.3.5", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/playgrounds/tanstack-start/package.json b/playgrounds/tanstack-start/package.json index 8395009f2..fc9022c5b 100644 --- a/playgrounds/tanstack-start/package.json +++ b/playgrounds/tanstack-start/package.json @@ -30,6 +30,6 @@ "react-dom": "^19.1.0", "vite": "^6.3.5", "vite-tsconfig-paths": "^5.1.4", - "zod": "^3.25.76" + "zod": "^4.0.5" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c4056b89a..ade9e5373 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -208,8 +208,8 @@ importers: version: link:../standard-server-peer devDependencies: zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 packages/contract: dependencies: @@ -233,8 +233,8 @@ importers: specifier: ^1.1.0 version: 1.1.0(typescript@5.8.3) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 packages/durable-event-iterator: dependencies: @@ -302,8 +302,8 @@ importers: version: 8.0.1 devDependencies: zod: - specifier: ^3.25.74 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 packages/nest: dependencies: @@ -349,7 +349,7 @@ importers: version: 11.1.3(@nestjs/common@11.1.3(reflect-metadata@0.2.2)(rxjs@7.8.2))(@nestjs/core@11.1.3)(@nestjs/platform-express@11.1.3) '@ts-rest/core': specifier: ^3.52.1 - version: 3.52.1(@types/node@22.16.3)(zod@3.25.76) + version: 3.52.1(@types/node@22.16.3)(zod@4.0.5) '@types/express': specifier: ^5.0.3 version: 5.0.3 @@ -366,8 +366,8 @@ importers: specifier: ^7.1.3 version: 7.1.3 zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 packages/openapi: dependencies: @@ -397,8 +397,8 @@ importers: version: 0.7.3 devDependencies: zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 packages/openapi-client: dependencies: @@ -441,8 +441,8 @@ importers: specifier: ^19.1.0 version: 19.1.0 zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 packages/react-query: dependencies: @@ -463,8 +463,8 @@ importers: specifier: ^19.1.0 version: 19.1.0 zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 packages/server: dependencies: @@ -525,8 +525,8 @@ importers: specifier: ^1.1.0 version: 1.1.0(typescript@5.8.3) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 packages/solid-query: dependencies: @@ -547,8 +547,8 @@ importers: specifier: ^5.81.5 version: 5.82.0(solid-js@1.9.7) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 packages/standard-server: dependencies: @@ -641,8 +641,8 @@ importers: specifier: ^5.81.5 version: 5.82.0(svelte@5.35.6) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 packages/tanstack-query: dependencies: @@ -681,8 +681,8 @@ importers: specifier: ^3.5.17 version: 3.5.17(typescript@5.8.3) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 packages/trpc: dependencies: @@ -700,8 +700,8 @@ importers: specifier: ^11.4.3 version: 11.4.3(typescript@5.8.3) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 packages/valibot: dependencies: @@ -785,11 +785,11 @@ importers: version: 5.1.4 devDependencies: zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 zod-to-json-schema: specifier: ^3.24.6 - version: 3.24.6(zod@3.25.76) + version: 3.24.6(zod@4.0.5) playgrounds/astro: devDependencies: @@ -842,8 +842,8 @@ importers: specifier: ^5.8.3 version: 5.8.3 zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 playgrounds/browser-extension: devDependencies: @@ -890,8 +890,8 @@ importers: specifier: ^0.20.6 version: 0.20.7(@types/node@22.16.3)(jiti@2.4.2)(rollup@4.44.2)(terser@5.43.1)(tsx@4.20.3)(yaml@2.8.0) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 playgrounds/cloudflare-worker: devDependencies: @@ -932,8 +932,8 @@ importers: specifier: ^4.23.0 version: 4.24.3(@cloudflare/workers-types@4.20250711.0) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 playgrounds/contract-first: devDependencies: @@ -971,8 +971,8 @@ importers: specifier: ^5.8.3 version: 5.8.3 zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 playgrounds/electron: devDependencies: @@ -1034,8 +1034,8 @@ importers: specifier: ^6.3.5 version: 6.3.5(@types/node@22.16.3)(jiti@2.4.2)(terser@5.43.1)(tsx@4.20.3)(yaml@2.8.0) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 playgrounds/nest: devDependencies: @@ -1118,8 +1118,8 @@ importers: specifier: ^3.5.0 version: 3.5.0(typescript@5.8.3)(vue@3.5.17(typescript@5.8.3)) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 playgrounds/next: devDependencies: @@ -1169,8 +1169,8 @@ importers: specifier: ^5.8.3 version: 5.8.3 zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 playgrounds/nuxt: devDependencies: @@ -1205,8 +1205,8 @@ importers: specifier: latest version: 4.5.1(vue@3.5.17(typescript@5.8.3)) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 playgrounds/solid-start: devDependencies: @@ -1247,8 +1247,8 @@ importers: specifier: ^1.5.0 version: 1.5.0(@swc/helpers@0.5.17)(rollup@4.44.2)(vite@6.3.5(@types/node@22.16.3)(jiti@2.4.2)(terser@5.43.1)(tsx@4.20.3)(yaml@2.8.0)) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 playgrounds/svelte-kit: devDependencies: @@ -1295,8 +1295,8 @@ importers: specifier: ^6.3.5 version: 6.3.5(@types/node@22.16.3)(jiti@2.4.2)(terser@5.43.1)(tsx@4.20.3)(yaml@2.8.0) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 playgrounds/tanstack-start: devDependencies: @@ -1361,8 +1361,8 @@ importers: specifier: ^5.1.4 version: 5.1.4(typescript@5.8.3)(vite@6.3.5(@types/node@22.16.3)(jiti@2.4.2)(terser@5.43.1)(tsx@4.20.3)(yaml@2.8.0)) zod: - specifier: ^3.25.76 - version: 3.25.76 + specifier: ^4.0.5 + version: 4.0.5 packages: @@ -12594,6 +12594,9 @@ packages: zod@3.25.76: resolution: {integrity: sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ==} + zod@4.0.5: + resolution: {integrity: sha512-/5UuuRPStvHXu7RS+gmvRf4NXrNxpSllGwDnCBcJZtQsKrviYXm54yDGV2KYNLT5kq0lHGcl7lqWJLgSaG+tgA==} + zwitch@2.0.4: resolution: {integrity: sha512-bXE4cR/kVZhKZX/RjPEflHaKVhUVl85noU3v6b8apfQEc1x4A+zBxjZ4lN8LqGd6WZ3dl98pY4o717VFmoPp+A==} @@ -16104,10 +16107,10 @@ snapshots: '@trysound/sax@0.2.0': {} - '@ts-rest/core@3.52.1(@types/node@22.16.3)(zod@3.25.76)': + '@ts-rest/core@3.52.1(@types/node@22.16.3)(zod@4.0.5)': optionalDependencies: '@types/node': 22.16.3 - zod: 3.25.76 + zod: 4.0.5 '@tsconfig/node10@1.0.11': {} @@ -25941,6 +25944,10 @@ snapshots: dependencies: zod: 3.25.76 + zod-to-json-schema@3.24.6(zod@4.0.5): + dependencies: + zod: 4.0.5 + zod-to-ts@1.2.0(typescript@5.8.3)(zod@3.25.76): dependencies: typescript: 5.8.3 @@ -25950,4 +25957,6 @@ snapshots: zod@3.25.76: {} + zod@4.0.5: {} + zwitch@2.0.4: {} From a91b2243ab2f2ac29fdd260064561ee144daede6 Mon Sep 17 00:00:00 2001 From: unnoq Date: Sun, 13 Jul 2025 15:50:37 +0700 Subject: [PATCH 2/6] wip --- README.md | 2 +- .../docs/advanced/validation-errors.md | 15 +- apps/content/docs/client/error-handling.md | 2 +- apps/content/docs/client/event-iterator.md | 2 +- apps/content/docs/client/server-side.md | 8 +- .../docs/contract-first/define-contract.md | 4 +- apps/content/docs/error-handling.md | 2 +- apps/content/docs/file-upload-download.md | 6 +- apps/content/docs/getting-started.md | 2 +- apps/content/docs/openapi/getting-started.md | 2 +- .../implement-contract-in-nest.md | 2 +- .../docs/openapi/openapi-specification.md | 10 +- apps/content/docs/plugins/hibernation.md | 2 +- apps/content/docs/server-action.md | 6 +- apps/content/examples/openai-streaming.md | 2 +- apps/content/package.json | 3 +- apps/content/shared/planet.ts | 2 +- packages/arktype/src/converter.test.ts | 2 +- packages/client/tests/helpers.ts | 5 +- packages/contract/src/event-iterator.test.ts | 2 +- packages/contract/src/schema-utils.test.ts | 2 +- packages/contract/src/schema.test-d.ts | 2 +- packages/contract/tests/helpers.ts | 2 +- packages/contract/tests/shared.ts | 2 +- .../src/smart-coercion-plugin.test.ts | 2 +- packages/nest/src/implement.test.ts | 2 +- .../openapi/src/openapi-generator.test.ts | 2 +- .../src/plugins/openapi-reference.test.ts | 2 +- packages/openapi/src/schema-converter.test.ts | 2 +- packages/react/src/action-form.test.ts | 2 +- .../react/src/hooks/server-action.test-d.ts | 2 +- packages/server/README.md | 2 +- packages/server/src/builder.test-d.ts | 2 +- packages/server/src/builder.test.ts | 2 +- packages/server/src/error.test.ts | 2 +- packages/server/src/procedure-client.test.ts | 2 +- .../server/src/procedure-decorated.test.ts | 2 +- packages/server/src/procedure-utils.test.ts | 2 +- packages/trpc/src/to-orpc-router.test.ts | 2 +- packages/valibot/src/converter.test.ts | 2 +- packages/zod/README.md | 4 +- packages/zod/package.json | 3 +- packages/zod/src/coercer.test.ts | 4 +- packages/zod/src/coercer.ts | 4 +- packages/zod/src/converter.components.test.ts | 2 +- packages/zod/src/converter.test.ts | 139 +----------------- packages/zod/src/converter.ts | 4 +- packages/zod/src/custom-json-schema.test-d.ts | 2 +- packages/zod/src/custom-json-schema.test.ts | 2 +- packages/zod/src/custom-json-schema.ts | 2 +- packages/zod/src/schemas/base.ts | 2 +- packages/zod/src/schemas/blob.ts | 4 +- packages/zod/src/schemas/file.ts | 4 +- packages/zod/src/schemas/regexp.ts | 4 +- packages/zod/src/schemas/url.ts | 4 +- playgrounds/astro/src/pages/api/[...rest].ts | 2 +- playgrounds/astro/src/router/planet.ts | 2 +- playgrounds/astro/src/router/sse.ts | 2 +- playgrounds/astro/src/schemas/auth.ts | 4 +- playgrounds/astro/src/schemas/planet.ts | 9 +- playgrounds/astro/src/schemas/user.ts | 66 ++++----- .../entrypoints/background/router/planet.ts | 2 +- .../entrypoints/background/router/sse.ts | 2 +- .../entrypoints/background/schemas/auth.ts | 4 +- .../entrypoints/background/schemas/planet.ts | 9 +- .../entrypoints/background/schemas/user.ts | 66 ++++----- .../cloudflare-worker/worker/dos/chat-room.ts | 2 +- .../contract-first/src/contract/planet.ts | 2 +- .../contract-first/src/contract/sse.ts | 2 +- .../contract-first/src/schemas/auth.ts | 4 +- .../contract-first/src/schemas/planet.ts | 9 +- .../contract-first/src/schemas/user.ts | 66 ++++----- .../electron/src/main/router/planet.ts | 2 +- playgrounds/electron/src/main/router/sse.ts | 2 +- playgrounds/electron/src/main/schemas/auth.ts | 4 +- .../electron/src/main/schemas/planet.ts | 9 +- playgrounds/electron/src/main/schemas/user.ts | 66 ++++----- playgrounds/electron/tsconfig.json | 27 +++- playgrounds/electron/tsconfig.web.json | 28 ---- playgrounds/nest/src/contract/planet.ts | 2 +- playgrounds/nest/src/contract/sse.ts | 2 +- playgrounds/nest/src/schemas/auth.ts | 4 +- playgrounds/nest/src/schemas/planet.ts | 13 +- playgrounds/nest/src/schemas/user.ts | 66 ++++----- playgrounds/nest/tsconfig.json | 2 +- playgrounds/next/src/app/actions.ts | 2 +- playgrounds/next/src/router/planet.ts | 2 +- playgrounds/next/src/router/sse.ts | 2 +- playgrounds/next/src/schemas/auth.ts | 4 +- playgrounds/next/src/schemas/planet.ts | 9 +- playgrounds/next/src/schemas/user.ts | 66 ++++----- playgrounds/nuxt/server/router/planet.ts | 2 +- playgrounds/nuxt/server/router/sse.ts | 2 +- playgrounds/nuxt/server/schemas/auth.ts | 4 +- playgrounds/nuxt/server/schemas/planet.ts | 9 +- playgrounds/nuxt/server/schemas/user.ts | 66 ++++----- playgrounds/solid-start/src/router/planet.ts | 2 +- playgrounds/solid-start/src/router/sse.ts | 2 +- playgrounds/solid-start/src/schemas/auth.ts | 4 +- playgrounds/solid-start/src/schemas/planet.ts | 9 +- playgrounds/solid-start/src/schemas/user.ts | 66 ++++----- playgrounds/svelte-kit/src/router/planet.ts | 2 +- playgrounds/svelte-kit/src/router/sse.ts | 2 +- playgrounds/svelte-kit/src/schemas/auth.ts | 4 +- playgrounds/svelte-kit/src/schemas/planet.ts | 9 +- playgrounds/svelte-kit/src/schemas/user.ts | 66 ++++----- .../tanstack-start/src/router/planet.ts | 2 +- playgrounds/tanstack-start/src/router/sse.ts | 2 +- .../tanstack-start/src/schemas/auth.ts | 4 +- .../tanstack-start/src/schemas/planet.ts | 9 +- .../tanstack-start/src/schemas/user.ts | 66 ++++----- pnpm-lock.yaml | 16 +- 112 files changed, 522 insertions(+), 696 deletions(-) delete mode 100644 playgrounds/electron/tsconfig.web.json diff --git a/README.md b/README.md index aa562976b..d4fd30135 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,7 @@ This is a quick overview of how to use oRPC. For more details, please refer to t ```ts import type { IncomingHttpHeaders } from 'node:http' import { ORPCError, os } from '@orpc/server' - import { z } from 'zod' + import * as z from 'zod' const PlanetSchema = z.object({ id: z.number().int().min(1), diff --git a/apps/content/docs/advanced/validation-errors.md b/apps/content/docs/advanced/validation-errors.md index e5f87514b..df2fb48cd 100644 --- a/apps/content/docs/advanced/validation-errors.md +++ b/apps/content/docs/advanced/validation-errors.md @@ -54,7 +54,7 @@ const handler = new RPCHandler(router, { ## Customizing with Middleware ```ts twoslash -import { z, ZodError } from 'zod' +import * as z from 'zod' import type { ZodIssue } from 'zod' import { onError, ORPCError, os, ValidationError } from '@orpc/server' @@ -65,7 +65,7 @@ const base = os.use(onError((error) => { && error.cause instanceof ValidationError ) { // If you only use Zod you can safely cast to ZodIssue[] - const zodError = new ZodError(error.cause.issues as ZodIssue[]) + const zodError = new z.ZodError(error.cause.issues as z.ZodIssue[]) throw new ORPCError('INPUT_VALIDATION_FAILED', { status: 422, @@ -86,8 +86,8 @@ const base = os.use(onError((error) => { })) const getting = base - .input(z.object({ id: z.string().uuid() })) - .output(z.object({ id: z.string().uuid(), name: z.string() })) + .input(z.object({ id: z.uuid() })) + .output(z.object({ id: z.uuid(), name: z.string() })) .handler(async ({ input, context }) => { return { id: input.id, name: 'name' } }) @@ -107,8 +107,7 @@ As explained in the [error handling guide](/docs/error-handling#combining-both-a import { RPCHandler } from '@orpc/server/fetch' // ---cut--- import { onError, ORPCError, os, ValidationError } from '@orpc/server' -import { z, ZodError } from 'zod' -import type { ZodIssue } from 'zod' +import * as z from 'zod' const base = os.errors({ INPUT_VALIDATION_FAILED: { @@ -121,7 +120,7 @@ const base = os.errors({ }) const example = base - .input(z.object({ id: z.string().uuid() })) + .input(z.object({ id: z.uuid() })) .handler(() => { /** do something */ }) const handler = new RPCHandler({ example }, { @@ -133,7 +132,7 @@ const handler = new RPCHandler({ example }, { && error.cause instanceof ValidationError ) { // If you only use Zod you can safely cast to ZodIssue[] - const zodError = new ZodError(error.cause.issues as ZodIssue[]) + const zodError = new z.ZodError(error.cause.issues as z.ZodIssue[]) throw new ORPCError('INPUT_VALIDATION_FAILED', { status: 422, diff --git a/apps/content/docs/client/error-handling.md b/apps/content/docs/client/error-handling.md index 94a7e4553..0595860b6 100644 --- a/apps/content/docs/client/error-handling.md +++ b/apps/content/docs/client/error-handling.md @@ -11,7 +11,7 @@ This guide explains how to handle type-safe errors in oRPC clients using [type-s ```ts twoslash import { os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' // ---cut--- import { isDefinedError, safe } from '@orpc/client' diff --git a/apps/content/docs/client/event-iterator.md b/apps/content/docs/client/event-iterator.md index db56f7147..35b03bba5 100644 --- a/apps/content/docs/client/event-iterator.md +++ b/apps/content/docs/client/event-iterator.md @@ -12,7 +12,7 @@ Simply iterate over it and await each event. ```ts twoslash import { ContractRouterClient, eventIterator, oc } from '@orpc/contract' -import { z } from 'zod' +import * as z from 'zod' const contract = { streaming: oc.output(eventIterator(z.object({ message: z.string() }))) diff --git a/apps/content/docs/client/server-side.md b/apps/content/docs/client/server-side.md index b20669d28..cc4fbb77e 100644 --- a/apps/content/docs/client/server-side.md +++ b/apps/content/docs/client/server-side.md @@ -17,7 +17,7 @@ Define your procedure and turn it into a callable procedure: ```ts twoslash import { os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' const getProcedure = os .input(z.object({ id: z.string() })) @@ -34,7 +34,7 @@ const result = await getProcedure({ id: '123' }) Alternatively, call your procedure using the `call` helper: ```ts twoslash -import { z } from 'zod' +import * as z from 'zod' import { call, os } from '@orpc/server' const getProcedure = os @@ -51,7 +51,7 @@ const result = await call(getProcedure, { id: '123' }, { Create a [router](/docs/router) based client to access multiple procedures: ```ts twoslash -import { z } from 'zod' +import * as z from 'zod' // ---cut--- import { createRouterClient, os } from '@orpc/server' @@ -70,7 +70,7 @@ const result = await client.ping() You can define a client context to pass additional information when calling procedures. This is useful for modifying procedure behavior dynamically. ```ts twoslash -import { z } from 'zod' +import * as z from 'zod' import { createRouterClient, os } from '@orpc/server' // ---cut--- interface ClientContext { diff --git a/apps/content/docs/contract-first/define-contract.md b/apps/content/docs/contract-first/define-contract.md index f5ab80185..6a40792f9 100644 --- a/apps/content/docs/contract-first/define-contract.md +++ b/apps/content/docs/contract-first/define-contract.md @@ -40,7 +40,7 @@ deno install npm:@orpc/contract@latest A procedure contract in oRPC is similar to a standard [procedure](/docs/procedure) definition, but with extraneous APIs removed to better support contract-first development. ```ts twoslash -import { z } from 'zod' +import * as z from 'zod' // ---cut--- import { oc } from '@orpc/contract' @@ -78,7 +78,7 @@ export const routerContract = { Below is a complete example demonstrating how to define a contract for a simple "Planet" service. This example extracted from our [Getting Started](/docs/getting-started) guide. ```ts twoslash -import { z } from 'zod' +import * as z from 'zod' import { oc } from '@orpc/contract' // ---cut--- export const PlanetSchema = z.object({ diff --git a/apps/content/docs/error-handling.md b/apps/content/docs/error-handling.md index 34ce00017..702d42377 100644 --- a/apps/content/docs/error-handling.md +++ b/apps/content/docs/error-handling.md @@ -52,7 +52,7 @@ For a fully type‑safe error management experience, define your error types usi ```ts twoslash import { os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' // ---cut--- const base = os.errors({ // <-- common errors RATE_LIMITED: { diff --git a/apps/content/docs/file-upload-download.md b/apps/content/docs/file-upload-download.md index fe88040e7..a3e876a7d 100644 --- a/apps/content/docs/file-upload-download.md +++ b/apps/content/docs/file-upload-download.md @@ -13,14 +13,14 @@ For files larger than 100 MB, we recommend using a dedicated upload solution or ## Validation -oRPC uses the standard [File](https://developer.mozilla.org/en-US/docs/Web/API/File) and [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects to handle file operations. To validate file uploads and downloads, you can use the `z.instanceof(File)` and `z.instanceof(Blob)` validators, or equivalent schemas in libraries like Valibot or Arktype. +oRPC uses standard [File](https://developer.mozilla.org/en-US/docs/Web/API/File) and [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) objects for file operations. ```ts twoslash import { os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' // ---cut--- const example = os - .input(z.object({ file: z.instanceof(File) })) + .input(z.object({ file: z.file() })) .output(z.object({ file: z.instanceof(File) })) .handler(async ({ input }) => { console.log(input.file.name) diff --git a/apps/content/docs/getting-started.md b/apps/content/docs/getting-started.md index 4f58e32fa..4559c06c6 100644 --- a/apps/content/docs/getting-started.md +++ b/apps/content/docs/getting-started.md @@ -50,7 +50,7 @@ We'll use [Zod](https://github.com/colinhacks/zod) for schema validation (option ```ts twoslash import type { IncomingHttpHeaders } from 'node:http' import { ORPCError, os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' const PlanetSchema = z.object({ id: z.number().int().min(1), diff --git a/apps/content/docs/openapi/getting-started.md b/apps/content/docs/openapi/getting-started.md index dc9984817..82982f64c 100644 --- a/apps/content/docs/openapi/getting-started.md +++ b/apps/content/docs/openapi/getting-started.md @@ -48,7 +48,7 @@ This snippet is based on the [Getting Started](/docs/getting-started) guide. Ple ```ts twoslash import type { IncomingHttpHeaders } from 'node:http' import { ORPCError, os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' const PlanetSchema = z.object({ id: z.number().int().min(1), diff --git a/apps/content/docs/openapi/integrations/implement-contract-in-nest.md b/apps/content/docs/openapi/integrations/implement-contract-in-nest.md index 7d71610bd..3b9bc287a 100644 --- a/apps/content/docs/openapi/integrations/implement-contract-in-nest.md +++ b/apps/content/docs/openapi/integrations/implement-contract-in-nest.md @@ -70,7 +70,7 @@ Before implementation, define your oRPC contract. This process is consistent wit ```ts import { populateContractRouterPaths } from '@orpc/nest' import { oc } from '@orpc/contract' -import { z } from 'zod' +import * as z from 'zod' export const PlanetSchema = z.object({ id: z.number().int().min(1), diff --git a/apps/content/docs/openapi/openapi-specification.md b/apps/content/docs/openapi/openapi-specification.md index d645b661c..fb7ade584 100644 --- a/apps/content/docs/openapi/openapi-specification.md +++ b/apps/content/docs/openapi/openapi-specification.md @@ -116,7 +116,7 @@ Define reusable schema components that can be referenced across your OpenAPI spe const UserSchema = z.object({ id: z.string(), name: z.string(), - email: z.string().email(), + email: z.email(), }) const PetSchema = z.object({ @@ -248,8 +248,8 @@ Zod v4 includes a native `File` schema. oRPC will detect it automatically - no e import * as z from 'zod' const InputSchema = z.object({ - file: oz.file(), - image: oz.file().mime(['image/png', 'image/jpeg']), + file: z.file(), + image: z.file().mime(['image/png', 'image/jpeg']), }) ``` @@ -301,7 +301,7 @@ JSON_SCHEMA_OUTPUT_REGISTRY.add(InputSchema, { In the [File Upload/Download](/docs/file-upload-download) guide, `z.instanceof` is used to describe file/blob schemas. However, this method prevents oRPC from recognizing file/blob schema. Instead, use the enhanced file schema approach: -```ts twoslash +```ts import { z } from 'zod' import { oz } from '@orpc/zod' @@ -316,7 +316,7 @@ const InputSchema = z.object({ If Zod alone does not cover your JSON Schema requirements, you can extend or override the generated schema: -```ts twoslash +```ts import { z } from 'zod' import { oz } from '@orpc/zod' diff --git a/apps/content/docs/plugins/hibernation.md b/apps/content/docs/plugins/hibernation.md index b87629890..77cfa7c36 100644 --- a/apps/content/docs/plugins/hibernation.md +++ b/apps/content/docs/plugins/hibernation.md @@ -76,7 +76,7 @@ import { } from '@orpc/server/hibernation' import { onError, os } from '@orpc/server' import { DurableObject } from 'cloudflare:workers' -import { z } from 'zod' +import * as z from 'zod' const base = os.$context<{ handler: RPCHandler diff --git a/apps/content/docs/server-action.md b/apps/content/docs/server-action.md index 5c33a839c..f4c5efbf8 100644 --- a/apps/content/docs/server-action.md +++ b/apps/content/docs/server-action.md @@ -13,7 +13,7 @@ Define your procedure with `.actionable` for Server Action support. ```ts twoslash import { onError, onSuccess, os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' // ---cut--- 'use server' @@ -70,7 +70,7 @@ The `.actionable` modifier supports type-safe error handling with a JSON-like er ```ts twoslash import { os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' export const someAction = os .input(z.object({ name: z.string() })) @@ -137,7 +137,7 @@ The `useServerAction` hook simplifies invoking server actions in React. ```tsx twoslash import * as React from 'react' import { os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' export const someAction = os .input(z.object({ name: z.string() })) diff --git a/apps/content/examples/openai-streaming.md b/apps/content/examples/openai-streaming.md index a340c8a4a..f9b3a2caf 100644 --- a/apps/content/examples/openai-streaming.md +++ b/apps/content/examples/openai-streaming.md @@ -13,7 +13,7 @@ This example shows how to integrate oRPC with the OpenAI Streaming API to build import { createORPCClient } from '@orpc/client' import { RPCLink } from '@orpc/client/fetch' import { os, RouterClient } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' // ---cut--- import OpenAI from 'openai' diff --git a/apps/content/package.json b/apps/content/package.json index 5b4acdf33..2cc52d595 100644 --- a/apps/content/package.json +++ b/apps/content/package.json @@ -38,6 +38,7 @@ "vitepress-plugin-llms": "^1.7.0", "vitepress-plugin-mermaid": "^2.0.17", "vitepress-plugin-shiki-twoslash": "^0.0.6", - "vue": "^3.5.17" + "vue": "^3.5.17", + "zod": "^4.0.5" } } diff --git a/apps/content/shared/planet.ts b/apps/content/shared/planet.ts index b9c256327..11fdf7695 100644 --- a/apps/content/shared/planet.ts +++ b/apps/content/shared/planet.ts @@ -1,4 +1,4 @@ -import { z } from 'zod' +import * as z from 'zod' import { oc } from '@orpc/contract' import type { RouterClient } from '@orpc/server' import { implement } from '@orpc/server' diff --git a/packages/arktype/src/converter.test.ts b/packages/arktype/src/converter.test.ts index ab878252d..3c3d42abd 100644 --- a/packages/arktype/src/converter.test.ts +++ b/packages/arktype/src/converter.test.ts @@ -1,5 +1,5 @@ import { type } from 'arktype' -import { z } from 'zod' +import * as z from 'zod' import { experimental_ArkTypeToJsonSchemaConverter as ArkTypeToJsonSchemaConverter } from './converter' it('arkTypeToJsonSchemaConverter.convert', async () => { diff --git a/packages/client/tests/helpers.ts b/packages/client/tests/helpers.ts index e87c45bc3..d273294ef 100644 --- a/packages/client/tests/helpers.ts +++ b/packages/client/tests/helpers.ts @@ -2,8 +2,7 @@ import type { RouterClient } from '@orpc/server' import { oc } from '@orpc/contract' import { implement, os } from '@orpc/server' import { RPCHandler } from '@orpc/server/fetch' -import { z } from 'zod' -import { oz } from '../../zod/src' +import * as z from 'zod' import { createORPCClient } from '../src' import { RPCLink } from '../src/adapters/fetch' @@ -29,7 +28,7 @@ export const PostListOutput = z.object({ export const PostCreateInput = z.object({ title: z.string(), - thumbnail: oz.file().optional(), + thumbnail: z.file().optional(), }) export const PostCreateOutput = PostFindOutput diff --git a/packages/contract/src/event-iterator.test.ts b/packages/contract/src/event-iterator.test.ts index 05bac9b72..a8eab060b 100644 --- a/packages/contract/src/event-iterator.test.ts +++ b/packages/contract/src/event-iterator.test.ts @@ -1,6 +1,6 @@ import { ORPCError } from '@orpc/client' import { getEventMeta, withEventMeta } from '@orpc/standard-server' -import { z } from 'zod' +import * as z from 'zod' import { ValidationError } from './error' import { eventIterator, getEventIteratorSchemaDetails } from './event-iterator' diff --git a/packages/contract/src/schema-utils.test.ts b/packages/contract/src/schema-utils.test.ts index d277c5029..015ae92c2 100644 --- a/packages/contract/src/schema-utils.test.ts +++ b/packages/contract/src/schema-utils.test.ts @@ -1,6 +1,6 @@ import { type } from 'arktype' import * as v from 'valibot' -import { z } from 'zod' +import * as z from 'zod' import { isSchemaIssue } from './schema-utils' describe('isSchemaIssue', async () => { diff --git a/packages/contract/src/schema.test-d.ts b/packages/contract/src/schema.test-d.ts index d9b325065..492eb29e9 100644 --- a/packages/contract/src/schema.test-d.ts +++ b/packages/contract/src/schema.test-d.ts @@ -1,7 +1,7 @@ import type { AnySchema, InferSchemaInput, InferSchemaOutput } from './schema' import { type as arktypeType } from 'arktype' import * as v from 'valibot' -import { z } from 'zod' +import * as z from 'zod' import { type } from './schema' const zod = z.object({ diff --git a/packages/contract/tests/helpers.ts b/packages/contract/tests/helpers.ts index ab4b8f46b..d5609eddb 100644 --- a/packages/contract/tests/helpers.ts +++ b/packages/contract/tests/helpers.ts @@ -1,4 +1,4 @@ -import { z } from 'zod' +import * as z from 'zod' import { oc } from '../src' export const NewPlanetSchema = z.object({ diff --git a/packages/contract/tests/shared.ts b/packages/contract/tests/shared.ts index b90d115de..2d9df3688 100644 --- a/packages/contract/tests/shared.ts +++ b/packages/contract/tests/shared.ts @@ -1,6 +1,6 @@ import type { Schema } from '../src' import type { Meta } from '../src/meta' -import { z } from 'zod' +import * as z from 'zod' import { ContractProcedure, eventIterator } from '../src' export const inputSchema = z.object({ input: z.number().transform(n => `${n}`) }) diff --git a/packages/json-schema/src/smart-coercion-plugin.test.ts b/packages/json-schema/src/smart-coercion-plugin.test.ts index f0a480681..e52eb5550 100644 --- a/packages/json-schema/src/smart-coercion-plugin.test.ts +++ b/packages/json-schema/src/smart-coercion-plugin.test.ts @@ -1,4 +1,4 @@ -import { z } from 'zod' +import * as z from 'zod' import { ZodToJsonSchemaConverter } from '../../zod/src' import { experimental_SmartCoercionPlugin as SmartCoercionPlugin } from './smart-coercion-plugin' diff --git a/packages/nest/src/implement.test.ts b/packages/nest/src/implement.test.ts index a333e2f02..438a6478b 100644 --- a/packages/nest/src/implement.test.ts +++ b/packages/nest/src/implement.test.ts @@ -7,7 +7,7 @@ import { implement, lazy } from '@orpc/server' import * as StandardServerNode from '@orpc/standard-server-node' import supertest from 'supertest' import { expect, it, vi } from 'vitest' -import { z } from 'zod' +import * as z from 'zod' import { Implement } from './implement' import { ORPCModule } from './module' diff --git a/packages/openapi/src/openapi-generator.test.ts b/packages/openapi/src/openapi-generator.test.ts index 9f602865a..73a75ccfe 100644 --- a/packages/openapi/src/openapi-generator.test.ts +++ b/packages/openapi/src/openapi-generator.test.ts @@ -1,6 +1,6 @@ import type { AnyContractProcedure } from '@orpc/contract' import { eventIterator, oc } from '@orpc/contract' -import { z } from 'zod' +import * as z from 'zod' import * as z4 from 'zod/v4' import { oz, ZodToJsonSchemaConverter } from '../../zod/src' import { experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverterV4 } from '../../zod/src/zod4' diff --git a/packages/openapi/src/plugins/openapi-reference.test.ts b/packages/openapi/src/plugins/openapi-reference.test.ts index 7038eefd5..292fafc43 100644 --- a/packages/openapi/src/plugins/openapi-reference.test.ts +++ b/packages/openapi/src/plugins/openapi-reference.test.ts @@ -1,5 +1,5 @@ import { os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' import { ZodToJsonSchemaConverter } from '../../../zod/src' import { OpenAPIHandler } from '../adapters/fetch/openapi-handler' import { OpenAPIGenerator } from '../openapi-generator' diff --git a/packages/openapi/src/schema-converter.test.ts b/packages/openapi/src/schema-converter.test.ts index 6306ebd66..9638acd93 100644 --- a/packages/openapi/src/schema-converter.test.ts +++ b/packages/openapi/src/schema-converter.test.ts @@ -1,4 +1,4 @@ -import { z } from 'zod' +import * as z from 'zod' import { CompositeSchemaConverter } from './schema-converter' beforeEach(() => { diff --git a/packages/react/src/action-form.test.ts b/packages/react/src/action-form.test.ts index 5651f16c1..e6d8465b2 100644 --- a/packages/react/src/action-form.test.ts +++ b/packages/react/src/action-form.test.ts @@ -1,5 +1,5 @@ import { ORPCError, os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' import { createFormAction } from './action-form' beforeEach(() => { diff --git a/packages/react/src/hooks/server-action.test-d.ts b/packages/react/src/hooks/server-action.test-d.ts index 1aa56aee1..4c08ce6ec 100644 --- a/packages/react/src/hooks/server-action.test-d.ts +++ b/packages/react/src/hooks/server-action.test-d.ts @@ -1,6 +1,6 @@ import type { ORPCError } from '@orpc/server' import { os, safe } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' import { baseErrorMap, inputSchema, outputSchema } from '../../../contract/tests/shared' import { useServerAction } from './server-action' diff --git a/packages/server/README.md b/packages/server/README.md index 5da8fb08b..f5f3b7393 100644 --- a/packages/server/README.md +++ b/packages/server/README.md @@ -66,7 +66,7 @@ Build your API or implement API contract. Read the [documentation](https://orpc. ```ts import type { IncomingHttpHeaders } from 'node:http' import { ORPCError, os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' const PlanetSchema = z.object({ id: z.number().int().min(1), diff --git a/packages/server/src/builder.test-d.ts b/packages/server/src/builder.test-d.ts index f8f6b4254..b8d8b8eff 100644 --- a/packages/server/src/builder.test-d.ts +++ b/packages/server/src/builder.test-d.ts @@ -11,7 +11,7 @@ import type { DecoratedMiddleware } from './middleware-decorated' import type { Procedure } from './procedure' import type { DecoratedProcedure } from './procedure-decorated' import type { EnhancedRouter } from './router-utils' -import { z } from 'zod' +import * as z from 'zod' import { generalSchema } from '../../contract/tests/shared' import { router } from '../tests/shared' diff --git a/packages/server/src/builder.test.ts b/packages/server/src/builder.test.ts index 9f603c336..eb9ba0f00 100644 --- a/packages/server/src/builder.test.ts +++ b/packages/server/src/builder.test.ts @@ -1,6 +1,6 @@ import type { Schema } from '@orpc/contract' import { isContractProcedure } from '@orpc/contract' -import { z } from 'zod' +import * as z from 'zod' import { baseErrorMap, baseMeta, baseRoute, generalSchema, inputSchema, outputSchema } from '../../contract/tests/shared' import { router } from '../tests/shared' import { Builder } from './builder' diff --git a/packages/server/src/error.test.ts b/packages/server/src/error.test.ts index 802df64ef..787b82458 100644 --- a/packages/server/src/error.test.ts +++ b/packages/server/src/error.test.ts @@ -1,6 +1,6 @@ import type { ErrorMap } from '@orpc/contract' import { ORPCError } from '@orpc/client' -import { z } from 'zod' +import * as z from 'zod' import { outputSchema } from '../../contract/tests/shared' import { createORPCErrorConstructorMap, validateORPCError } from './error' diff --git a/packages/server/src/procedure-client.test.ts b/packages/server/src/procedure-client.test.ts index 4d3c964aa..aa7355e92 100644 --- a/packages/server/src/procedure-client.test.ts +++ b/packages/server/src/procedure-client.test.ts @@ -1,5 +1,5 @@ import { ORPCError } from '@orpc/client' -import { z } from 'zod' +import * as z from 'zod' import { createORPCErrorConstructorMap, validateORPCError } from './error' import { isLazy, lazy, unlazy } from './lazy' import { Procedure } from './procedure' diff --git a/packages/server/src/procedure-decorated.test.ts b/packages/server/src/procedure-decorated.test.ts index 674b12dd6..863077c21 100644 --- a/packages/server/src/procedure-decorated.test.ts +++ b/packages/server/src/procedure-decorated.test.ts @@ -1,4 +1,4 @@ -import { z } from 'zod' +import * as z from 'zod' import { ping } from '../tests/shared' import { isProcedure } from './procedure' import { createActionableClient } from './procedure-action' diff --git a/packages/server/src/procedure-utils.test.ts b/packages/server/src/procedure-utils.test.ts index 53616234a..f3b00468a 100644 --- a/packages/server/src/procedure-utils.test.ts +++ b/packages/server/src/procedure-utils.test.ts @@ -1,5 +1,5 @@ import { ContractProcedure } from '@orpc/contract' -import { z } from 'zod' +import * as z from 'zod' import { contract, ping } from '../tests/shared' import { lazy, unlazy } from './lazy' import { Procedure } from './procedure' diff --git a/packages/trpc/src/to-orpc-router.test.ts b/packages/trpc/src/to-orpc-router.test.ts index 6677a6bd2..ea5afc8a6 100644 --- a/packages/trpc/src/to-orpc-router.test.ts +++ b/packages/trpc/src/to-orpc-router.test.ts @@ -1,7 +1,7 @@ import { call, createRouterClient, getEventMeta, isProcedure, ORPCError, unlazy } from '@orpc/server' import { isAsyncIteratorObject } from '@orpc/shared' import { tracked } from '@trpc/server' -import { z } from 'zod' +import * as z from 'zod' import { inputSchema, outputSchema } from '../../contract/tests/shared' import { t, trpcRouter } from '../tests/shared' import { experimental_toORPCRouter as toORPCRouter } from './to-orpc-router' diff --git a/packages/valibot/src/converter.test.ts b/packages/valibot/src/converter.test.ts index a41c33964..6f9b5cf68 100644 --- a/packages/valibot/src/converter.test.ts +++ b/packages/valibot/src/converter.test.ts @@ -1,5 +1,5 @@ import * as v from 'valibot' -import { z } from 'zod' +import * as z from 'zod' import { experimental_ValibotToJsonSchemaConverter as ValibotToJsonSchemaConverter } from './converter' it('valibotToJsonSchemaConverter.convert', async () => { diff --git a/packages/zod/README.md b/packages/zod/README.md index d50824d8c..f02e938e3 100644 --- a/packages/zod/README.md +++ b/packages/zod/README.md @@ -72,7 +72,7 @@ More schemas that [Zod](https://zod.dev/) doesn't support yet, and provides `Zod ```ts import { oz } from '@orpc/zod' -import { z } from 'zod' +import * as z from 'zod' const Example = z.object({ url: oz.url(), @@ -111,7 +111,7 @@ const specFromRouter = await openAPIGenerator.generate(router, { ```ts import { oz } from '@orpc/zod' -import { z } from 'zod' +import * as z from 'zod' const InputSchema = oz.openapi( z.object({ diff --git a/packages/zod/package.json b/packages/zod/package.json index 1a3579b3a..b5a436027 100644 --- a/packages/zod/package.json +++ b/packages/zod/package.json @@ -52,7 +52,6 @@ "wildcard-match": "^5.1.3" }, "devDependencies": { - "zod": "^4.0.5", - "zod-to-json-schema": "^3.24.6" + "zod": "^4.0.5" } } diff --git a/packages/zod/src/coercer.test.ts b/packages/zod/src/coercer.test.ts index 070974ed0..ea9a22d8c 100644 --- a/packages/zod/src/coercer.test.ts +++ b/packages/zod/src/coercer.test.ts @@ -1,5 +1,5 @@ -import type { ZodTypeAny } from 'zod' -import { z } from 'zod' +import type { ZodTypeAny } from 'zod/v3' +import { z } from 'zod/v3' import { ZodSmartCoercionPlugin } from './coercer' import { regexp } from './schemas/regexp' import { url } from './schemas/url' diff --git a/packages/zod/src/coercer.ts b/packages/zod/src/coercer.ts index e30677006..1a5b5b89c 100644 --- a/packages/zod/src/coercer.ts +++ b/packages/zod/src/coercer.ts @@ -23,9 +23,9 @@ import type { ZodTuple, ZodTypeAny, ZodUnion, -} from 'zod' +} from 'zod/v3' import { guard, isObject } from '@orpc/shared' -import { ZodFirstPartyTypeKind } from 'zod' +import { ZodFirstPartyTypeKind } from 'zod/v3' import { getCustomZodDef } from './schemas/base' export class ZodSmartCoercionPlugin implements StandardHandlerPlugin { diff --git a/packages/zod/src/converter.components.test.ts b/packages/zod/src/converter.components.test.ts index ca434ca5c..7b4858cd0 100644 --- a/packages/zod/src/converter.components.test.ts +++ b/packages/zod/src/converter.components.test.ts @@ -1,4 +1,4 @@ -import { z } from 'zod' +import { z } from 'zod/v3' import { ZodToJsonSchemaConverter } from './converter' const User = z.object({ diff --git a/packages/zod/src/converter.test.ts b/packages/zod/src/converter.test.ts index ea8ad306d..c9508035d 100644 --- a/packages/zod/src/converter.test.ts +++ b/packages/zod/src/converter.test.ts @@ -1,7 +1,6 @@ import type { JSONSchema } from '@orpc/openapi' -import type { ZodTypeAny } from 'zod' -import { z } from 'zod' -import { zodToJsonSchema } from 'zod-to-json-schema' +import type { ZodTypeAny } from 'zod/v3' +import { z } from 'zod/v3' import { ZodToJsonSchemaConverter } from './converter' import { customJsonSchema } from './custom-json-schema' import { blob } from './schemas/blob' @@ -13,7 +12,6 @@ type SchemaTestCase = { schema: ZodTypeAny input: [boolean, JSONSchema & Record] output?: [boolean, JSONSchema & Record] - ignoreZodToJsonSchema?: boolean } const stringCases: SchemaTestCase[] = [ @@ -32,7 +30,6 @@ const stringCases: SchemaTestCase[] = [ { schema: z.string().cuid(), input: [true, { type: 'string', pattern: '^[0-9A-HJKMNP-TV-Z]{26}$' }], - ignoreZodToJsonSchema: true, }, { schema: z.string().email(), @@ -144,13 +141,11 @@ const numberCases: SchemaTestCase[] = [ { schema: z.bigint(), input: [true, { 'type': 'string', 'pattern': '^-?[0-9]+$', 'x-native-type': 'bigint' }], - ignoreZodToJsonSchema: true, }, { schema: z.nan(), input: [true, { not: {} }], output: [true, { type: 'null' }], - ignoreZodToJsonSchema: true, }, ] @@ -167,7 +162,6 @@ const nativeCases: SchemaTestCase[] = [ { schema: z.date(), input: [true, { 'type': 'string', 'format': 'date-time', 'x-native-type': 'date' }], - ignoreZodToJsonSchema: true, }, { schema: z.null(), @@ -176,42 +170,34 @@ const nativeCases: SchemaTestCase[] = [ { schema: z.any(), input: [false, { }], - ignoreZodToJsonSchema: true, }, { schema: z.unknown(), input: [false, {}], - ignoreZodToJsonSchema: true, }, { schema: z.undefined(), input: [false, { not: {} }], - ignoreZodToJsonSchema: true, }, { schema: z.void(), input: [false, { not: {} }], - ignoreZodToJsonSchema: true, }, { schema: z.literal(1234), input: [true, { const: 1234 }], - ignoreZodToJsonSchema: true, }, { schema: z.literal(undefined), input: [false, { not: {} }], - ignoreZodToJsonSchema: true, }, { schema: z.enum(['a', 'b']), input: [true, { enum: ['a', 'b'] }], - ignoreZodToJsonSchema: true, }, { schema: z.nativeEnum(ExampleEnum), input: [true, { enum: ['a', 'b'] }], - ignoreZodToJsonSchema: true, }, ] @@ -219,17 +205,14 @@ const combinationCases: SchemaTestCase[] = [ { schema: z.union([z.string(), z.number()]), input: [true, { anyOf: [{ type: 'string' }, { type: 'number' }] }], - ignoreZodToJsonSchema: true, }, { schema: z.union([z.string(), z.number().optional()]), input: [false, { anyOf: [{ type: 'string' }, { type: 'number' }] }], - ignoreZodToJsonSchema: true, }, { schema: z.union([z.string(), z.undefined()]), input: [false, { type: 'string' }], - ignoreZodToJsonSchema: true, }, { schema: z.intersection(z.string(), z.number()), @@ -238,7 +221,6 @@ const combinationCases: SchemaTestCase[] = [ { schema: z.intersection(z.string().optional(), z.number().optional()), input: [false, { allOf: [{ type: 'string' }, { type: 'number' }] }], - ignoreZodToJsonSchema: true, }, ] @@ -246,18 +228,15 @@ const processedCases: SchemaTestCase[] = [ { schema: z.lazy(() => z.object({ value: z.string() })), input: [true, { type: 'object', properties: { value: { type: 'string' } }, required: ['value'] }], - ignoreZodToJsonSchema: true, }, { schema: z.lazy(() => z.object({ value: z.lazy(() => z.string()) })), input: [true, { type: 'object', properties: { value: { } } }], - ignoreZodToJsonSchema: true, }, { schema: z.string().transform(x => x), input: [true, { type: 'string' }], output: [false, {}], - ignoreZodToJsonSchema: true, }, { schema: z.string().refine(x => x.length > 0, 'not empty'), @@ -270,7 +249,6 @@ const processedCases: SchemaTestCase[] = [ { schema: z.number().catch(1), input: [true, { type: 'number' }], - ignoreZodToJsonSchema: true, }, { schema: z.number().brand<'CAT'>(), @@ -288,17 +266,14 @@ const processedCases: SchemaTestCase[] = [ { schema: z.string().nullable(), input: [true, { anyOf: [{ type: 'string' }, { type: 'null' }] }], - ignoreZodToJsonSchema: true, }, { schema: z.string().default('a'), input: [false, { default: 'a', type: 'string' }], - ignoreZodToJsonSchema: true, }, { schema: z.number().readonly(), input: [true, { type: 'number', readOnly: true }], - ignoreZodToJsonSchema: true, }, ] @@ -306,22 +281,18 @@ const unsupportedCases: SchemaTestCase[] = [ { schema: z.promise(z.string()), input: [true, { not: {} }], - ignoreZodToJsonSchema: true, }, { schema: z.symbol(), input: [true, { not: {} }], - ignoreZodToJsonSchema: true, }, { schema: z.function(), input: [true, { not: {} }], - ignoreZodToJsonSchema: true, }, { schema: z.never(), input: [true, { not: {} }], - ignoreZodToJsonSchema: true, }, ] @@ -329,32 +300,26 @@ const extendSchemaCases: SchemaTestCase[] = [ { schema: file(), input: [true, { type: 'string', contentMediaType: '*/*' }], - ignoreZodToJsonSchema: true, }, { schema: file().type('image/png'), input: [true, { type: 'string', contentMediaType: 'image/png' }], - ignoreZodToJsonSchema: true, }, { schema: blob(), input: [true, { type: 'string', contentMediaType: '*/*' }], - ignoreZodToJsonSchema: true, }, { schema: regexp(), input: [true, { 'type': 'string', 'pattern': '^\\/(.*)\\/([a-z]*)$', 'x-native-type': 'regexp' }], - ignoreZodToJsonSchema: true, }, { schema: url(), input: [true, { 'type': 'string', 'format': 'uri', 'x-native-type': 'url' }], - ignoreZodToJsonSchema: true, }, { schema: customJsonSchema(z.string(), { examples: ['a', 'b'] }), input: [true, { type: 'string', examples: ['a', 'b'] }], - ignoreZodToJsonSchema: true, }, { schema: customJsonSchema( @@ -368,12 +333,10 @@ const extendSchemaCases: SchemaTestCase[] = [ ), input: [true, { type: 'string', examples: ['input'] }], output: [true, { type: 'string', examples: ['output'] }], - ignoreZodToJsonSchema: true, }, { schema: z.string().describe('description'), input: [true, { type: 'string', description: 'description' }], - ignoreZodToJsonSchema: true, }, ] @@ -381,17 +344,14 @@ const edgeCases: SchemaTestCase[] = [ { schema: z.array(z.string()).nonempty(), input: [true, { type: 'array', items: { type: 'string' }, minItems: 1 }], - ignoreZodToJsonSchema: true, }, { schema: z.array(z.string()).min(10).max(20), input: [true, { type: 'array', items: { type: 'string' }, minItems: 10, maxItems: 20 }], - ignoreZodToJsonSchema: true, }, { schema: z.array(z.string()).length(10), input: [true, { type: 'array', items: { type: 'string' }, minItems: 10, maxItems: 10 }], - ignoreZodToJsonSchema: true, }, { schema: z.object({ value: z.string() }).strict(), @@ -404,12 +364,10 @@ const edgeCases: SchemaTestCase[] = [ { schema: z.record(z.number(), z.string()), input: [true, { type: 'object', additionalProperties: { type: 'string' }, propertyNames: { type: 'number' } }], - ignoreZodToJsonSchema: true, }, { schema: z.record(z.string().date(), z.string()), input: [true, { type: 'object', additionalProperties: { type: 'string' }, propertyNames: { type: 'string', format: 'date' } }], - ignoreZodToJsonSchema: true, }, ] @@ -422,7 +380,7 @@ describe.each([ ...extendSchemaCases, ...unsupportedCases, ...edgeCases, -])('zodToJsonSchemaConverter.convert %#', ({ schema, input, output = input, ignoreZodToJsonSchema }) => { +])('zodToJsonSchemaConverter.convert %#', ({ schema, input, output = input }) => { describe.each([ ['input'], ['output'], @@ -441,23 +399,6 @@ describe.each([ expect(required).toEqual(expectedRequired) expect(json).toEqual(expectedJson) - - if (!ignoreZodToJsonSchema) { - if (expectedRequired) { - expect(expectedJson).toEqual({ - ...zodToJsonSchema(schema, { target: 'jsonSchema2019-09', pipeStrategy: strategy, $refStrategy: 'none' }), - $schema: undefined, - }) - } - else { - expect({ - anyOf: [{ not: {} }, expectedJson], - }).toEqual({ - ...zodToJsonSchema(schema, { target: 'jsonSchema2019-09', pipeStrategy: strategy, $refStrategy: 'none' }), - $schema: undefined, - }) - } - } }) it('object', () => { @@ -472,14 +413,6 @@ describe.each([ }, required: expectedRequired ? ['value'] : undefined, }) - - if (!ignoreZodToJsonSchema) { - expect(json).toEqual({ - ...zodToJsonSchema(testSchema, { target: 'jsonSchema2019-09', pipeStrategy: strategy, $refStrategy: 'none' }), - $schema: undefined, - additionalProperties: undefined, - }) - } }) it('array', () => { @@ -491,13 +424,6 @@ describe.each([ type: 'array', items: arrayItemJsonSchema, }) - - if (!ignoreZodToJsonSchema) { - expect(json).toEqual({ - ...zodToJsonSchema(testSchema, { target: 'jsonSchema2019-09', pipeStrategy: strategy, $refStrategy: 'none' }), - $schema: undefined, - }) - } }) it('tuple', () => { @@ -513,22 +439,6 @@ describe.each([ ], items: arrayItemJsonSchema, }) - - if (!ignoreZodToJsonSchema) { - expect({ - type: 'array', - items: [ - expectedRequired ? expectedJson : { anyOf: [{ not: {} }, expectedJson] }, - expectedRequired ? expectedJson : { anyOf: [{ not: {} }, expectedJson] }, - ], - additionalItems: expectedRequired ? expectedJson : { anyOf: [{ not: {} }, expectedJson] }, - }).toEqual({ - ...zodToJsonSchema(testSchema, { target: 'jsonSchema2019-09', pipeStrategy: strategy, $refStrategy: 'none' }), - $schema: undefined, - maxItems: undefined, - minItems: undefined, - }) - } }) it('set', () => { @@ -542,18 +452,6 @@ describe.each([ 'items': arrayItemJsonSchema, 'x-native-type': 'set', }) - - if (!ignoreZodToJsonSchema) { - expect({ - type: 'array', - uniqueItems: true, - items: expectedRequired ? expectedJson : { anyOf: [{ not: {} }, expectedJson] }, - }).toEqual({ - ...zodToJsonSchema(testSchema, { target: 'jsonSchema2019-09', pipeStrategy: strategy, $refStrategy: 'none' }), - '$schema': undefined, - 'x-native-type': undefined, - }) - } }) it('map', () => { @@ -574,26 +472,6 @@ describe.each([ }, 'x-native-type': 'map', }) - - if (!ignoreZodToJsonSchema) { - expect({ - type: 'array', - items: { - maxItems: 2, - minItems: 2, - items: [ - expectedRequired ? expectedJson : { anyOf: [{ not: {} }, expectedJson] }, - { anyOf: [{ not: {} }, expectedRequired ? expectedJson : { anyOf: [{ not: {} }, expectedJson] }] }, - ], - type: 'array', - }, - }).toEqual({ - ...zodToJsonSchema(testSchema, { target: 'jsonSchema2019-09', pipeStrategy: strategy, $refStrategy: 'none' }), - '$schema': undefined, - 'maxItems': undefined, - 'x-native-type': undefined, - }) - } }) it('record', () => { @@ -605,17 +483,6 @@ describe.each([ type: 'object', additionalProperties: expectedJson, }) - - if (!ignoreZodToJsonSchema) { - expect({ - type: 'object', - additionalProperties: expectedRequired ? expectedJson : { anyOf: [{ not: {} }, expectedJson] }, - }).toEqual({ - ...zodToJsonSchema(testSchema, { target: 'jsonSchema2019-09', pipeStrategy: strategy, $refStrategy: 'none' }), - $schema: undefined, - maxItems: undefined, - }) - } }) }) }) diff --git a/packages/zod/src/converter.ts b/packages/zod/src/converter.ts index 04d14a2a3..8af5a24bd 100644 --- a/packages/zod/src/converter.ts +++ b/packages/zod/src/converter.ts @@ -31,12 +31,12 @@ import type { ZodTypeDef, ZodUnion, ZodUnionOptions, -} from 'zod' +} from 'zod/v3' import { JsonSchemaXNativeType } from '@orpc/json-schema' import { JSONSchemaFormat } from '@orpc/openapi' import { toArray } from '@orpc/shared' import escapeStringRegexp from 'escape-string-regexp' -import { ZodFirstPartyTypeKind } from 'zod' +import { ZodFirstPartyTypeKind } from 'zod/v3' import { getCustomJsonSchema } from './custom-json-schema' import { getCustomZodDef } from './schemas/base' diff --git a/packages/zod/src/custom-json-schema.test-d.ts b/packages/zod/src/custom-json-schema.test-d.ts index 416a4d763..c04e738e9 100644 --- a/packages/zod/src/custom-json-schema.test-d.ts +++ b/packages/zod/src/custom-json-schema.test-d.ts @@ -1,4 +1,4 @@ -import { z } from 'zod' +import { z } from 'zod/v3' import { customJsonSchema } from './custom-json-schema' describe('customJsonSchema', () => { diff --git a/packages/zod/src/custom-json-schema.test.ts b/packages/zod/src/custom-json-schema.test.ts index d20b71f33..ec0eccc6d 100644 --- a/packages/zod/src/custom-json-schema.test.ts +++ b/packages/zod/src/custom-json-schema.test.ts @@ -1,4 +1,4 @@ -import { z } from 'zod' +import { z } from 'zod/v3' import { customJsonSchema, getCustomJsonSchema } from './custom-json-schema' describe('custom json schema', () => { diff --git a/packages/zod/src/custom-json-schema.ts b/packages/zod/src/custom-json-schema.ts index d3b7a1938..609f7aaa4 100644 --- a/packages/zod/src/custom-json-schema.ts +++ b/packages/zod/src/custom-json-schema.ts @@ -1,5 +1,5 @@ import type { JSONSchema } from '@orpc/openapi' -import type { input, output, ZodTypeAny, ZodTypeDef } from 'zod' +import type { input, output, ZodTypeAny, ZodTypeDef } from 'zod/v3' const CUSTOM_JSON_SCHEMA_SYMBOL = Symbol('ORPC_CUSTOM_JSON_SCHEMA') const CUSTOM_JSON_SCHEMA_INPUT_SYMBOL = Symbol('ORPC_CUSTOM_JSON_SCHEMA_INPUT') diff --git a/packages/zod/src/schemas/base.ts b/packages/zod/src/schemas/base.ts index d95d0a38c..eeac4e921 100644 --- a/packages/zod/src/schemas/base.ts +++ b/packages/zod/src/schemas/base.ts @@ -1,4 +1,4 @@ -import type { CustomErrorParams, ZodTypeDef } from 'zod' +import type { CustomErrorParams, ZodTypeDef } from 'zod/v3' export type CustomParams = CustomErrorParams & { fatal?: boolean diff --git a/packages/zod/src/schemas/blob.ts b/packages/zod/src/schemas/blob.ts index 7e2768ba5..57642b29f 100644 --- a/packages/zod/src/schemas/blob.ts +++ b/packages/zod/src/schemas/blob.ts @@ -1,6 +1,6 @@ -import type { ZodType, ZodTypeDef } from 'zod' +import type { ZodType, ZodTypeDef } from 'zod/v3' import type { CustomParams } from './base' -import { custom } from 'zod' +import { custom } from 'zod/v3' import { composeParams, setCustomZodDef } from './base' export function blob( diff --git a/packages/zod/src/schemas/file.ts b/packages/zod/src/schemas/file.ts index fc9eb000c..9c7d9e5f0 100644 --- a/packages/zod/src/schemas/file.ts +++ b/packages/zod/src/schemas/file.ts @@ -1,7 +1,7 @@ -import type { ZodEffects, ZodType, ZodTypeDef } from 'zod' +import type { ZodEffects, ZodType, ZodTypeDef } from 'zod/v3' import type { CustomParams } from './base' import wcmatch from 'wildcard-match' -import { custom } from 'zod' +import { custom } from 'zod/v3' import { composeParams, setCustomZodDef } from './base' export function file( diff --git a/packages/zod/src/schemas/regexp.ts b/packages/zod/src/schemas/regexp.ts index 7f13c5139..944c6ea8e 100644 --- a/packages/zod/src/schemas/regexp.ts +++ b/packages/zod/src/schemas/regexp.ts @@ -1,6 +1,6 @@ -import type { ZodType, ZodTypeDef } from 'zod' +import type { ZodType, ZodTypeDef } from 'zod/v3' import type { CustomParams } from './base' -import { custom } from 'zod' +import { custom } from 'zod/v3' import { composeParams, setCustomZodDef } from './base' export function regexp( diff --git a/packages/zod/src/schemas/url.ts b/packages/zod/src/schemas/url.ts index fd66c8c1a..263969215 100644 --- a/packages/zod/src/schemas/url.ts +++ b/packages/zod/src/schemas/url.ts @@ -1,6 +1,6 @@ -import type { ZodType, ZodTypeDef } from 'zod' +import type { ZodType, ZodTypeDef } from 'zod/v3' import type { CustomParams } from './base' -import { custom } from 'zod' +import { custom } from 'zod/v3' import { composeParams, setCustomZodDef } from './base' export function url( diff --git a/playgrounds/astro/src/pages/api/[...rest].ts b/playgrounds/astro/src/pages/api/[...rest].ts index a82207cb5..a052fadd2 100644 --- a/playgrounds/astro/src/pages/api/[...rest].ts +++ b/playgrounds/astro/src/pages/api/[...rest].ts @@ -1,7 +1,7 @@ import '../../polyfill' import { OpenAPIHandler } from '@orpc/openapi/fetch' import { onError } from '@orpc/server' -import { ZodToJsonSchemaConverter } from '@orpc/zod' +import { experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverter } from '@orpc/zod/zod4' import { experimental_SmartCoercionPlugin as SmartCoercionPlugin } from '@orpc/json-schema' import { OpenAPIReferencePlugin } from '@orpc/openapi/plugins' import { router } from '../../router' diff --git a/playgrounds/astro/src/router/planet.ts b/playgrounds/astro/src/router/planet.ts index 9304b3234..3e74be35d 100644 --- a/playgrounds/astro/src/router/planet.ts +++ b/playgrounds/astro/src/router/planet.ts @@ -1,5 +1,5 @@ import { ORPCError } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' import { authed, pub } from '../orpc' import { NewPlanetSchema, PlanetSchema, UpdatePlanetSchema } from '../schemas/planet' import { retry } from '../middlewares/retry' diff --git a/playgrounds/astro/src/router/sse.ts b/playgrounds/astro/src/router/sse.ts index 06f0e15e9..a54cc015f 100644 --- a/playgrounds/astro/src/router/sse.ts +++ b/playgrounds/astro/src/router/sse.ts @@ -1,5 +1,5 @@ import { eventIterator, os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' const MAX_EVENTS = 5 diff --git a/playgrounds/astro/src/schemas/auth.ts b/playgrounds/astro/src/schemas/auth.ts index 5a70d7206..96a5cb07b 100644 --- a/playgrounds/astro/src/schemas/auth.ts +++ b/playgrounds/astro/src/schemas/auth.ts @@ -1,7 +1,7 @@ -import { z } from 'zod' +import * as z from 'zod' export const CredentialSchema = z.object({ - email: z.string().email(), + email: z.email(), password: z.string(), }) diff --git a/playgrounds/astro/src/schemas/planet.ts b/playgrounds/astro/src/schemas/planet.ts index 59a86e124..7e005fb9f 100644 --- a/playgrounds/astro/src/schemas/planet.ts +++ b/playgrounds/astro/src/schemas/planet.ts @@ -1,5 +1,4 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import * as z from 'zod' import { UserSchema } from './user' export type NewPlanet = z.infer @@ -9,20 +8,20 @@ export type Planet = z.infer export const NewPlanetSchema = z.object({ name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const UpdatePlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const PlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - imageUrl: z.string().url().optional(), + imageUrl: z.url().optional(), creator: UserSchema, }) diff --git a/playgrounds/astro/src/schemas/user.ts b/playgrounds/astro/src/schemas/user.ts index 875534c3c..9813c6322 100644 --- a/playgrounds/astro/src/schemas/user.ts +++ b/playgrounds/astro/src/schemas/user.ts @@ -1,39 +1,37 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import { experimental_JSON_SCHEMA_REGISTRY as JSON_SCHEMA_REGISTRY } from '@orpc/zod/zod4' +import * as z from 'zod' export type NewUser = z.infer export type User = z.infer -export const NewUserSchema = oz.openapi( - z.object({ - name: z.string(), - email: z.string().email(), - password: z.string(), - }), - { - examples: [ - { - name: 'John Doe', - email: 'john@doe.com', - password: '123456', - }, - ], - }, -) +export const NewUserSchema = z.object({ + name: z.string(), + email: z.email(), + password: z.string(), +}) -export const UserSchema = oz.openapi( - z.object({ - id: z.string(), - name: z.string(), - email: z.string().email(), - }), - { - examples: [ - { - id: '1', - name: 'John Doe', - email: 'john@doe.com', - }, - ], - }, -) +JSON_SCHEMA_REGISTRY.add(NewUserSchema, { + examples: [ + { + name: 'John Doe', + email: 'john@doe.com', + password: '123456', + }, + ], +}) + +export const UserSchema = z.object({ + id: z.string(), + name: z.string(), + email: z.email(), +}) + +JSON_SCHEMA_REGISTRY.add(UserSchema, { + examples: [ + { + id: '1', + name: 'John Doe', + email: 'john@doe.com', + }, + ], +}) diff --git a/playgrounds/browser-extension/entrypoints/background/router/planet.ts b/playgrounds/browser-extension/entrypoints/background/router/planet.ts index 9304b3234..3e74be35d 100644 --- a/playgrounds/browser-extension/entrypoints/background/router/planet.ts +++ b/playgrounds/browser-extension/entrypoints/background/router/planet.ts @@ -1,5 +1,5 @@ import { ORPCError } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' import { authed, pub } from '../orpc' import { NewPlanetSchema, PlanetSchema, UpdatePlanetSchema } from '../schemas/planet' import { retry } from '../middlewares/retry' diff --git a/playgrounds/browser-extension/entrypoints/background/router/sse.ts b/playgrounds/browser-extension/entrypoints/background/router/sse.ts index 06f0e15e9..a54cc015f 100644 --- a/playgrounds/browser-extension/entrypoints/background/router/sse.ts +++ b/playgrounds/browser-extension/entrypoints/background/router/sse.ts @@ -1,5 +1,5 @@ import { eventIterator, os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' const MAX_EVENTS = 5 diff --git a/playgrounds/browser-extension/entrypoints/background/schemas/auth.ts b/playgrounds/browser-extension/entrypoints/background/schemas/auth.ts index 5a70d7206..96a5cb07b 100644 --- a/playgrounds/browser-extension/entrypoints/background/schemas/auth.ts +++ b/playgrounds/browser-extension/entrypoints/background/schemas/auth.ts @@ -1,7 +1,7 @@ -import { z } from 'zod' +import * as z from 'zod' export const CredentialSchema = z.object({ - email: z.string().email(), + email: z.email(), password: z.string(), }) diff --git a/playgrounds/browser-extension/entrypoints/background/schemas/planet.ts b/playgrounds/browser-extension/entrypoints/background/schemas/planet.ts index 59a86e124..7e005fb9f 100644 --- a/playgrounds/browser-extension/entrypoints/background/schemas/planet.ts +++ b/playgrounds/browser-extension/entrypoints/background/schemas/planet.ts @@ -1,5 +1,4 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import * as z from 'zod' import { UserSchema } from './user' export type NewPlanet = z.infer @@ -9,20 +8,20 @@ export type Planet = z.infer export const NewPlanetSchema = z.object({ name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const UpdatePlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const PlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - imageUrl: z.string().url().optional(), + imageUrl: z.url().optional(), creator: UserSchema, }) diff --git a/playgrounds/browser-extension/entrypoints/background/schemas/user.ts b/playgrounds/browser-extension/entrypoints/background/schemas/user.ts index 875534c3c..9813c6322 100644 --- a/playgrounds/browser-extension/entrypoints/background/schemas/user.ts +++ b/playgrounds/browser-extension/entrypoints/background/schemas/user.ts @@ -1,39 +1,37 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import { experimental_JSON_SCHEMA_REGISTRY as JSON_SCHEMA_REGISTRY } from '@orpc/zod/zod4' +import * as z from 'zod' export type NewUser = z.infer export type User = z.infer -export const NewUserSchema = oz.openapi( - z.object({ - name: z.string(), - email: z.string().email(), - password: z.string(), - }), - { - examples: [ - { - name: 'John Doe', - email: 'john@doe.com', - password: '123456', - }, - ], - }, -) +export const NewUserSchema = z.object({ + name: z.string(), + email: z.email(), + password: z.string(), +}) -export const UserSchema = oz.openapi( - z.object({ - id: z.string(), - name: z.string(), - email: z.string().email(), - }), - { - examples: [ - { - id: '1', - name: 'John Doe', - email: 'john@doe.com', - }, - ], - }, -) +JSON_SCHEMA_REGISTRY.add(NewUserSchema, { + examples: [ + { + name: 'John Doe', + email: 'john@doe.com', + password: '123456', + }, + ], +}) + +export const UserSchema = z.object({ + id: z.string(), + name: z.string(), + email: z.email(), +}) + +JSON_SCHEMA_REGISTRY.add(UserSchema, { + examples: [ + { + id: '1', + name: 'John Doe', + email: 'john@doe.com', + }, + ], +}) diff --git a/playgrounds/cloudflare-worker/worker/dos/chat-room.ts b/playgrounds/cloudflare-worker/worker/dos/chat-room.ts index 1661f5b99..3d7039681 100644 --- a/playgrounds/cloudflare-worker/worker/dos/chat-room.ts +++ b/playgrounds/cloudflare-worker/worker/dos/chat-room.ts @@ -1,6 +1,6 @@ import { DurableEventIteratorObject } from '@orpc/experimental-durable-event-iterator/durable-object' import { os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' export class ChatRoom extends DurableEventIteratorObject<{ message: string }> { publishMessageRPC() { diff --git a/playgrounds/contract-first/src/contract/planet.ts b/playgrounds/contract-first/src/contract/planet.ts index cad493e8a..0e7be43fc 100644 --- a/playgrounds/contract-first/src/contract/planet.ts +++ b/playgrounds/contract-first/src/contract/planet.ts @@ -1,4 +1,4 @@ -import { z } from 'zod' +import * as z from 'zod' import { NewPlanetSchema, PlanetSchema, UpdatePlanetSchema } from '../schemas/planet' import { oc } from '@orpc/contract' diff --git a/playgrounds/contract-first/src/contract/sse.ts b/playgrounds/contract-first/src/contract/sse.ts index 652b21bcb..08e5b4b75 100644 --- a/playgrounds/contract-first/src/contract/sse.ts +++ b/playgrounds/contract-first/src/contract/sse.ts @@ -1,5 +1,5 @@ import { eventIterator, oc } from '@orpc/contract' -import { z } from 'zod' +import * as z from 'zod' export const sse = oc .route({ diff --git a/playgrounds/contract-first/src/schemas/auth.ts b/playgrounds/contract-first/src/schemas/auth.ts index 5a70d7206..96a5cb07b 100644 --- a/playgrounds/contract-first/src/schemas/auth.ts +++ b/playgrounds/contract-first/src/schemas/auth.ts @@ -1,7 +1,7 @@ -import { z } from 'zod' +import * as z from 'zod' export const CredentialSchema = z.object({ - email: z.string().email(), + email: z.email(), password: z.string(), }) diff --git a/playgrounds/contract-first/src/schemas/planet.ts b/playgrounds/contract-first/src/schemas/planet.ts index 59a86e124..7e005fb9f 100644 --- a/playgrounds/contract-first/src/schemas/planet.ts +++ b/playgrounds/contract-first/src/schemas/planet.ts @@ -1,5 +1,4 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import * as z from 'zod' import { UserSchema } from './user' export type NewPlanet = z.infer @@ -9,20 +8,20 @@ export type Planet = z.infer export const NewPlanetSchema = z.object({ name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const UpdatePlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const PlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - imageUrl: z.string().url().optional(), + imageUrl: z.url().optional(), creator: UserSchema, }) diff --git a/playgrounds/contract-first/src/schemas/user.ts b/playgrounds/contract-first/src/schemas/user.ts index 875534c3c..9813c6322 100644 --- a/playgrounds/contract-first/src/schemas/user.ts +++ b/playgrounds/contract-first/src/schemas/user.ts @@ -1,39 +1,37 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import { experimental_JSON_SCHEMA_REGISTRY as JSON_SCHEMA_REGISTRY } from '@orpc/zod/zod4' +import * as z from 'zod' export type NewUser = z.infer export type User = z.infer -export const NewUserSchema = oz.openapi( - z.object({ - name: z.string(), - email: z.string().email(), - password: z.string(), - }), - { - examples: [ - { - name: 'John Doe', - email: 'john@doe.com', - password: '123456', - }, - ], - }, -) +export const NewUserSchema = z.object({ + name: z.string(), + email: z.email(), + password: z.string(), +}) -export const UserSchema = oz.openapi( - z.object({ - id: z.string(), - name: z.string(), - email: z.string().email(), - }), - { - examples: [ - { - id: '1', - name: 'John Doe', - email: 'john@doe.com', - }, - ], - }, -) +JSON_SCHEMA_REGISTRY.add(NewUserSchema, { + examples: [ + { + name: 'John Doe', + email: 'john@doe.com', + password: '123456', + }, + ], +}) + +export const UserSchema = z.object({ + id: z.string(), + name: z.string(), + email: z.email(), +}) + +JSON_SCHEMA_REGISTRY.add(UserSchema, { + examples: [ + { + id: '1', + name: 'John Doe', + email: 'john@doe.com', + }, + ], +}) diff --git a/playgrounds/electron/src/main/router/planet.ts b/playgrounds/electron/src/main/router/planet.ts index 9304b3234..3e74be35d 100644 --- a/playgrounds/electron/src/main/router/planet.ts +++ b/playgrounds/electron/src/main/router/planet.ts @@ -1,5 +1,5 @@ import { ORPCError } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' import { authed, pub } from '../orpc' import { NewPlanetSchema, PlanetSchema, UpdatePlanetSchema } from '../schemas/planet' import { retry } from '../middlewares/retry' diff --git a/playgrounds/electron/src/main/router/sse.ts b/playgrounds/electron/src/main/router/sse.ts index 06f0e15e9..a54cc015f 100644 --- a/playgrounds/electron/src/main/router/sse.ts +++ b/playgrounds/electron/src/main/router/sse.ts @@ -1,5 +1,5 @@ import { eventIterator, os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' const MAX_EVENTS = 5 diff --git a/playgrounds/electron/src/main/schemas/auth.ts b/playgrounds/electron/src/main/schemas/auth.ts index 5a70d7206..96a5cb07b 100644 --- a/playgrounds/electron/src/main/schemas/auth.ts +++ b/playgrounds/electron/src/main/schemas/auth.ts @@ -1,7 +1,7 @@ -import { z } from 'zod' +import * as z from 'zod' export const CredentialSchema = z.object({ - email: z.string().email(), + email: z.email(), password: z.string(), }) diff --git a/playgrounds/electron/src/main/schemas/planet.ts b/playgrounds/electron/src/main/schemas/planet.ts index 59a86e124..7e005fb9f 100644 --- a/playgrounds/electron/src/main/schemas/planet.ts +++ b/playgrounds/electron/src/main/schemas/planet.ts @@ -1,5 +1,4 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import * as z from 'zod' import { UserSchema } from './user' export type NewPlanet = z.infer @@ -9,20 +8,20 @@ export type Planet = z.infer export const NewPlanetSchema = z.object({ name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const UpdatePlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const PlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - imageUrl: z.string().url().optional(), + imageUrl: z.url().optional(), creator: UserSchema, }) diff --git a/playgrounds/electron/src/main/schemas/user.ts b/playgrounds/electron/src/main/schemas/user.ts index 875534c3c..9813c6322 100644 --- a/playgrounds/electron/src/main/schemas/user.ts +++ b/playgrounds/electron/src/main/schemas/user.ts @@ -1,39 +1,37 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import { experimental_JSON_SCHEMA_REGISTRY as JSON_SCHEMA_REGISTRY } from '@orpc/zod/zod4' +import * as z from 'zod' export type NewUser = z.infer export type User = z.infer -export const NewUserSchema = oz.openapi( - z.object({ - name: z.string(), - email: z.string().email(), - password: z.string(), - }), - { - examples: [ - { - name: 'John Doe', - email: 'john@doe.com', - password: '123456', - }, - ], - }, -) +export const NewUserSchema = z.object({ + name: z.string(), + email: z.email(), + password: z.string(), +}) -export const UserSchema = oz.openapi( - z.object({ - id: z.string(), - name: z.string(), - email: z.string().email(), - }), - { - examples: [ - { - id: '1', - name: 'John Doe', - email: 'john@doe.com', - }, - ], - }, -) +JSON_SCHEMA_REGISTRY.add(NewUserSchema, { + examples: [ + { + name: 'John Doe', + email: 'john@doe.com', + password: '123456', + }, + ], +}) + +export const UserSchema = z.object({ + id: z.string(), + name: z.string(), + email: z.email(), +}) + +JSON_SCHEMA_REGISTRY.add(UserSchema, { + examples: [ + { + id: '1', + name: 'John Doe', + email: 'john@doe.com', + }, + ], +}) diff --git a/playgrounds/electron/tsconfig.json b/playgrounds/electron/tsconfig.json index 6668d7c3b..3f734e6d5 100644 --- a/playgrounds/electron/tsconfig.json +++ b/playgrounds/electron/tsconfig.json @@ -1,4 +1,27 @@ { - "references": [{ "path": "./tsconfig.node.json" }, { "path": "./tsconfig.web.json" }], - "files": [] + "extends": "@electron-toolkit/tsconfig/tsconfig.web.json", + "compilerOptions": { + "jsx": "react-jsx", + "baseUrl": ".", + "moduleResolution": "bundler", + "paths": { + "@renderer/*": [ + "src/renderer/src/*" + ] + }, + "types": ["vite/client"], + + "noImplicitReturns": false, + "noUnusedLocals": false, + "noUnusedParameters": false, + "outDir": "${configDir}/dist" + }, + "references": [{ "path": "./tsconfig.node.json" }], + "files": [], + "include": [ + "src/renderer/src/env.d.ts", + "src/renderer/src/**/*", + "src/renderer/src/**/*.tsx", + "src/preload/*.d.ts" + ] } diff --git a/playgrounds/electron/tsconfig.web.json b/playgrounds/electron/tsconfig.web.json deleted file mode 100644 index 7e5312e75..000000000 --- a/playgrounds/electron/tsconfig.web.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "extends": "@electron-toolkit/tsconfig/tsconfig.web.json", - "compilerOptions": { - "composite": true, - "jsx": "react-jsx", - "baseUrl": ".", - "moduleResolution": "bundler", - "paths": { - "@renderer/*": [ - "src/renderer/src/*" - ] - }, - "types": ["vite/client"], - - "noImplicitReturns": false, - "noUnusedLocals": false, - "noUnusedParameters": false, - "emitDeclarationOnly": true, - "outDir": "${configDir}/dist" - }, - "references": [{ "path": "./tsconfig.node.json" }], - "include": [ - "src/renderer/src/env.d.ts", - "src/renderer/src/**/*", - "src/renderer/src/**/*.tsx", - "src/preload/*.d.ts" - ] -} diff --git a/playgrounds/nest/src/contract/planet.ts b/playgrounds/nest/src/contract/planet.ts index a4318d3b8..467428fcc 100644 --- a/playgrounds/nest/src/contract/planet.ts +++ b/playgrounds/nest/src/contract/planet.ts @@ -1,4 +1,4 @@ -import { z } from 'zod' +import * as z from 'zod' import { NewPlanetSchema, PlanetSchema, UpdatePlanetSchema } from '../schemas/planet' import { oc } from '@orpc/contract' diff --git a/playgrounds/nest/src/contract/sse.ts b/playgrounds/nest/src/contract/sse.ts index 652b21bcb..08e5b4b75 100644 --- a/playgrounds/nest/src/contract/sse.ts +++ b/playgrounds/nest/src/contract/sse.ts @@ -1,5 +1,5 @@ import { eventIterator, oc } from '@orpc/contract' -import { z } from 'zod' +import * as z from 'zod' export const sse = oc .route({ diff --git a/playgrounds/nest/src/schemas/auth.ts b/playgrounds/nest/src/schemas/auth.ts index 5a70d7206..96a5cb07b 100644 --- a/playgrounds/nest/src/schemas/auth.ts +++ b/playgrounds/nest/src/schemas/auth.ts @@ -1,7 +1,7 @@ -import { z } from 'zod' +import * as z from 'zod' export const CredentialSchema = z.object({ - email: z.string().email(), + email: z.email(), password: z.string(), }) diff --git a/playgrounds/nest/src/schemas/planet.ts b/playgrounds/nest/src/schemas/planet.ts index bfb71d5d7..7e005fb9f 100644 --- a/playgrounds/nest/src/schemas/planet.ts +++ b/playgrounds/nest/src/schemas/planet.ts @@ -1,5 +1,4 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import * as z from 'zod' import { UserSchema } from './user' export type NewPlanet = z.infer @@ -9,20 +8,20 @@ export type Planet = z.infer export const NewPlanetSchema = z.object({ name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const UpdatePlanetSchema = z.object({ - id: z.coerce.number().int().min(1), + id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const PlanetSchema = z.object({ - id: z.coerce.number().int().min(1), + id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - imageUrl: z.string().url().optional(), + imageUrl: z.url().optional(), creator: UserSchema, }) diff --git a/playgrounds/nest/src/schemas/user.ts b/playgrounds/nest/src/schemas/user.ts index 875534c3c..9813c6322 100644 --- a/playgrounds/nest/src/schemas/user.ts +++ b/playgrounds/nest/src/schemas/user.ts @@ -1,39 +1,37 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import { experimental_JSON_SCHEMA_REGISTRY as JSON_SCHEMA_REGISTRY } from '@orpc/zod/zod4' +import * as z from 'zod' export type NewUser = z.infer export type User = z.infer -export const NewUserSchema = oz.openapi( - z.object({ - name: z.string(), - email: z.string().email(), - password: z.string(), - }), - { - examples: [ - { - name: 'John Doe', - email: 'john@doe.com', - password: '123456', - }, - ], - }, -) +export const NewUserSchema = z.object({ + name: z.string(), + email: z.email(), + password: z.string(), +}) -export const UserSchema = oz.openapi( - z.object({ - id: z.string(), - name: z.string(), - email: z.string().email(), - }), - { - examples: [ - { - id: '1', - name: 'John Doe', - email: 'john@doe.com', - }, - ], - }, -) +JSON_SCHEMA_REGISTRY.add(NewUserSchema, { + examples: [ + { + name: 'John Doe', + email: 'john@doe.com', + password: '123456', + }, + ], +}) + +export const UserSchema = z.object({ + id: z.string(), + name: z.string(), + email: z.email(), +}) + +JSON_SCHEMA_REGISTRY.add(UserSchema, { + examples: [ + { + id: '1', + name: 'John Doe', + email: 'john@doe.com', + }, + ], +}) diff --git a/playgrounds/nest/tsconfig.json b/playgrounds/nest/tsconfig.json index 29063fb9c..152ab38cb 100644 --- a/playgrounds/nest/tsconfig.json +++ b/playgrounds/nest/tsconfig.json @@ -14,7 +14,7 @@ "strictNullChecks": true, "noFallthroughCasesInSwitch": false, "noImplicitAny": false, - "declaration": true, + "declaration": false, "outDir": "./dist", "removeComments": true, "sourceMap": true, diff --git a/playgrounds/next/src/app/actions.ts b/playgrounds/next/src/app/actions.ts index bf085117b..8b52ede8b 100644 --- a/playgrounds/next/src/app/actions.ts +++ b/playgrounds/next/src/app/actions.ts @@ -1,7 +1,7 @@ 'use server' import { pub } from '@/orpc' -import { z } from 'zod' +import * as z from 'zod' import { createFormAction } from '@orpc/react' import { redirect } from 'next/navigation' import { onSuccess } from '@orpc/client' diff --git a/playgrounds/next/src/router/planet.ts b/playgrounds/next/src/router/planet.ts index 18207241b..e457278c8 100644 --- a/playgrounds/next/src/router/planet.ts +++ b/playgrounds/next/src/router/planet.ts @@ -1,5 +1,5 @@ import { ORPCError } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' import { authed, pub } from '../orpc' import { NewPlanetSchema, PlanetSchema, UpdatePlanetSchema } from '../schemas/planet' import { retry } from '@/middlewares/retry' diff --git a/playgrounds/next/src/router/sse.ts b/playgrounds/next/src/router/sse.ts index 06f0e15e9..a54cc015f 100644 --- a/playgrounds/next/src/router/sse.ts +++ b/playgrounds/next/src/router/sse.ts @@ -1,5 +1,5 @@ import { eventIterator, os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' const MAX_EVENTS = 5 diff --git a/playgrounds/next/src/schemas/auth.ts b/playgrounds/next/src/schemas/auth.ts index 5a70d7206..96a5cb07b 100644 --- a/playgrounds/next/src/schemas/auth.ts +++ b/playgrounds/next/src/schemas/auth.ts @@ -1,7 +1,7 @@ -import { z } from 'zod' +import * as z from 'zod' export const CredentialSchema = z.object({ - email: z.string().email(), + email: z.email(), password: z.string(), }) diff --git a/playgrounds/next/src/schemas/planet.ts b/playgrounds/next/src/schemas/planet.ts index 59a86e124..7e005fb9f 100644 --- a/playgrounds/next/src/schemas/planet.ts +++ b/playgrounds/next/src/schemas/planet.ts @@ -1,5 +1,4 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import * as z from 'zod' import { UserSchema } from './user' export type NewPlanet = z.infer @@ -9,20 +8,20 @@ export type Planet = z.infer export const NewPlanetSchema = z.object({ name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const UpdatePlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const PlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - imageUrl: z.string().url().optional(), + imageUrl: z.url().optional(), creator: UserSchema, }) diff --git a/playgrounds/next/src/schemas/user.ts b/playgrounds/next/src/schemas/user.ts index 875534c3c..9813c6322 100644 --- a/playgrounds/next/src/schemas/user.ts +++ b/playgrounds/next/src/schemas/user.ts @@ -1,39 +1,37 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import { experimental_JSON_SCHEMA_REGISTRY as JSON_SCHEMA_REGISTRY } from '@orpc/zod/zod4' +import * as z from 'zod' export type NewUser = z.infer export type User = z.infer -export const NewUserSchema = oz.openapi( - z.object({ - name: z.string(), - email: z.string().email(), - password: z.string(), - }), - { - examples: [ - { - name: 'John Doe', - email: 'john@doe.com', - password: '123456', - }, - ], - }, -) +export const NewUserSchema = z.object({ + name: z.string(), + email: z.email(), + password: z.string(), +}) -export const UserSchema = oz.openapi( - z.object({ - id: z.string(), - name: z.string(), - email: z.string().email(), - }), - { - examples: [ - { - id: '1', - name: 'John Doe', - email: 'john@doe.com', - }, - ], - }, -) +JSON_SCHEMA_REGISTRY.add(NewUserSchema, { + examples: [ + { + name: 'John Doe', + email: 'john@doe.com', + password: '123456', + }, + ], +}) + +export const UserSchema = z.object({ + id: z.string(), + name: z.string(), + email: z.email(), +}) + +JSON_SCHEMA_REGISTRY.add(UserSchema, { + examples: [ + { + id: '1', + name: 'John Doe', + email: 'john@doe.com', + }, + ], +}) diff --git a/playgrounds/nuxt/server/router/planet.ts b/playgrounds/nuxt/server/router/planet.ts index 9304b3234..3e74be35d 100644 --- a/playgrounds/nuxt/server/router/planet.ts +++ b/playgrounds/nuxt/server/router/planet.ts @@ -1,5 +1,5 @@ import { ORPCError } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' import { authed, pub } from '../orpc' import { NewPlanetSchema, PlanetSchema, UpdatePlanetSchema } from '../schemas/planet' import { retry } from '../middlewares/retry' diff --git a/playgrounds/nuxt/server/router/sse.ts b/playgrounds/nuxt/server/router/sse.ts index 06f0e15e9..a54cc015f 100644 --- a/playgrounds/nuxt/server/router/sse.ts +++ b/playgrounds/nuxt/server/router/sse.ts @@ -1,5 +1,5 @@ import { eventIterator, os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' const MAX_EVENTS = 5 diff --git a/playgrounds/nuxt/server/schemas/auth.ts b/playgrounds/nuxt/server/schemas/auth.ts index 5a70d7206..96a5cb07b 100644 --- a/playgrounds/nuxt/server/schemas/auth.ts +++ b/playgrounds/nuxt/server/schemas/auth.ts @@ -1,7 +1,7 @@ -import { z } from 'zod' +import * as z from 'zod' export const CredentialSchema = z.object({ - email: z.string().email(), + email: z.email(), password: z.string(), }) diff --git a/playgrounds/nuxt/server/schemas/planet.ts b/playgrounds/nuxt/server/schemas/planet.ts index 59a86e124..7e005fb9f 100644 --- a/playgrounds/nuxt/server/schemas/planet.ts +++ b/playgrounds/nuxt/server/schemas/planet.ts @@ -1,5 +1,4 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import * as z from 'zod' import { UserSchema } from './user' export type NewPlanet = z.infer @@ -9,20 +8,20 @@ export type Planet = z.infer export const NewPlanetSchema = z.object({ name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const UpdatePlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const PlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - imageUrl: z.string().url().optional(), + imageUrl: z.url().optional(), creator: UserSchema, }) diff --git a/playgrounds/nuxt/server/schemas/user.ts b/playgrounds/nuxt/server/schemas/user.ts index 875534c3c..9813c6322 100644 --- a/playgrounds/nuxt/server/schemas/user.ts +++ b/playgrounds/nuxt/server/schemas/user.ts @@ -1,39 +1,37 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import { experimental_JSON_SCHEMA_REGISTRY as JSON_SCHEMA_REGISTRY } from '@orpc/zod/zod4' +import * as z from 'zod' export type NewUser = z.infer export type User = z.infer -export const NewUserSchema = oz.openapi( - z.object({ - name: z.string(), - email: z.string().email(), - password: z.string(), - }), - { - examples: [ - { - name: 'John Doe', - email: 'john@doe.com', - password: '123456', - }, - ], - }, -) +export const NewUserSchema = z.object({ + name: z.string(), + email: z.email(), + password: z.string(), +}) -export const UserSchema = oz.openapi( - z.object({ - id: z.string(), - name: z.string(), - email: z.string().email(), - }), - { - examples: [ - { - id: '1', - name: 'John Doe', - email: 'john@doe.com', - }, - ], - }, -) +JSON_SCHEMA_REGISTRY.add(NewUserSchema, { + examples: [ + { + name: 'John Doe', + email: 'john@doe.com', + password: '123456', + }, + ], +}) + +export const UserSchema = z.object({ + id: z.string(), + name: z.string(), + email: z.email(), +}) + +JSON_SCHEMA_REGISTRY.add(UserSchema, { + examples: [ + { + id: '1', + name: 'John Doe', + email: 'john@doe.com', + }, + ], +}) diff --git a/playgrounds/solid-start/src/router/planet.ts b/playgrounds/solid-start/src/router/planet.ts index 9304b3234..3e74be35d 100644 --- a/playgrounds/solid-start/src/router/planet.ts +++ b/playgrounds/solid-start/src/router/planet.ts @@ -1,5 +1,5 @@ import { ORPCError } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' import { authed, pub } from '../orpc' import { NewPlanetSchema, PlanetSchema, UpdatePlanetSchema } from '../schemas/planet' import { retry } from '../middlewares/retry' diff --git a/playgrounds/solid-start/src/router/sse.ts b/playgrounds/solid-start/src/router/sse.ts index 06f0e15e9..a54cc015f 100644 --- a/playgrounds/solid-start/src/router/sse.ts +++ b/playgrounds/solid-start/src/router/sse.ts @@ -1,5 +1,5 @@ import { eventIterator, os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' const MAX_EVENTS = 5 diff --git a/playgrounds/solid-start/src/schemas/auth.ts b/playgrounds/solid-start/src/schemas/auth.ts index 5a70d7206..96a5cb07b 100644 --- a/playgrounds/solid-start/src/schemas/auth.ts +++ b/playgrounds/solid-start/src/schemas/auth.ts @@ -1,7 +1,7 @@ -import { z } from 'zod' +import * as z from 'zod' export const CredentialSchema = z.object({ - email: z.string().email(), + email: z.email(), password: z.string(), }) diff --git a/playgrounds/solid-start/src/schemas/planet.ts b/playgrounds/solid-start/src/schemas/planet.ts index 59a86e124..7e005fb9f 100644 --- a/playgrounds/solid-start/src/schemas/planet.ts +++ b/playgrounds/solid-start/src/schemas/planet.ts @@ -1,5 +1,4 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import * as z from 'zod' import { UserSchema } from './user' export type NewPlanet = z.infer @@ -9,20 +8,20 @@ export type Planet = z.infer export const NewPlanetSchema = z.object({ name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const UpdatePlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const PlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - imageUrl: z.string().url().optional(), + imageUrl: z.url().optional(), creator: UserSchema, }) diff --git a/playgrounds/solid-start/src/schemas/user.ts b/playgrounds/solid-start/src/schemas/user.ts index 875534c3c..9813c6322 100644 --- a/playgrounds/solid-start/src/schemas/user.ts +++ b/playgrounds/solid-start/src/schemas/user.ts @@ -1,39 +1,37 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import { experimental_JSON_SCHEMA_REGISTRY as JSON_SCHEMA_REGISTRY } from '@orpc/zod/zod4' +import * as z from 'zod' export type NewUser = z.infer export type User = z.infer -export const NewUserSchema = oz.openapi( - z.object({ - name: z.string(), - email: z.string().email(), - password: z.string(), - }), - { - examples: [ - { - name: 'John Doe', - email: 'john@doe.com', - password: '123456', - }, - ], - }, -) +export const NewUserSchema = z.object({ + name: z.string(), + email: z.email(), + password: z.string(), +}) -export const UserSchema = oz.openapi( - z.object({ - id: z.string(), - name: z.string(), - email: z.string().email(), - }), - { - examples: [ - { - id: '1', - name: 'John Doe', - email: 'john@doe.com', - }, - ], - }, -) +JSON_SCHEMA_REGISTRY.add(NewUserSchema, { + examples: [ + { + name: 'John Doe', + email: 'john@doe.com', + password: '123456', + }, + ], +}) + +export const UserSchema = z.object({ + id: z.string(), + name: z.string(), + email: z.email(), +}) + +JSON_SCHEMA_REGISTRY.add(UserSchema, { + examples: [ + { + id: '1', + name: 'John Doe', + email: 'john@doe.com', + }, + ], +}) diff --git a/playgrounds/svelte-kit/src/router/planet.ts b/playgrounds/svelte-kit/src/router/planet.ts index 9304b3234..3e74be35d 100644 --- a/playgrounds/svelte-kit/src/router/planet.ts +++ b/playgrounds/svelte-kit/src/router/planet.ts @@ -1,5 +1,5 @@ import { ORPCError } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' import { authed, pub } from '../orpc' import { NewPlanetSchema, PlanetSchema, UpdatePlanetSchema } from '../schemas/planet' import { retry } from '../middlewares/retry' diff --git a/playgrounds/svelte-kit/src/router/sse.ts b/playgrounds/svelte-kit/src/router/sse.ts index 06f0e15e9..a54cc015f 100644 --- a/playgrounds/svelte-kit/src/router/sse.ts +++ b/playgrounds/svelte-kit/src/router/sse.ts @@ -1,5 +1,5 @@ import { eventIterator, os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' const MAX_EVENTS = 5 diff --git a/playgrounds/svelte-kit/src/schemas/auth.ts b/playgrounds/svelte-kit/src/schemas/auth.ts index 5a70d7206..96a5cb07b 100644 --- a/playgrounds/svelte-kit/src/schemas/auth.ts +++ b/playgrounds/svelte-kit/src/schemas/auth.ts @@ -1,7 +1,7 @@ -import { z } from 'zod' +import * as z from 'zod' export const CredentialSchema = z.object({ - email: z.string().email(), + email: z.email(), password: z.string(), }) diff --git a/playgrounds/svelte-kit/src/schemas/planet.ts b/playgrounds/svelte-kit/src/schemas/planet.ts index 59a86e124..7e005fb9f 100644 --- a/playgrounds/svelte-kit/src/schemas/planet.ts +++ b/playgrounds/svelte-kit/src/schemas/planet.ts @@ -1,5 +1,4 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import * as z from 'zod' import { UserSchema } from './user' export type NewPlanet = z.infer @@ -9,20 +8,20 @@ export type Planet = z.infer export const NewPlanetSchema = z.object({ name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const UpdatePlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const PlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - imageUrl: z.string().url().optional(), + imageUrl: z.url().optional(), creator: UserSchema, }) diff --git a/playgrounds/svelte-kit/src/schemas/user.ts b/playgrounds/svelte-kit/src/schemas/user.ts index 875534c3c..9813c6322 100644 --- a/playgrounds/svelte-kit/src/schemas/user.ts +++ b/playgrounds/svelte-kit/src/schemas/user.ts @@ -1,39 +1,37 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import { experimental_JSON_SCHEMA_REGISTRY as JSON_SCHEMA_REGISTRY } from '@orpc/zod/zod4' +import * as z from 'zod' export type NewUser = z.infer export type User = z.infer -export const NewUserSchema = oz.openapi( - z.object({ - name: z.string(), - email: z.string().email(), - password: z.string(), - }), - { - examples: [ - { - name: 'John Doe', - email: 'john@doe.com', - password: '123456', - }, - ], - }, -) +export const NewUserSchema = z.object({ + name: z.string(), + email: z.email(), + password: z.string(), +}) -export const UserSchema = oz.openapi( - z.object({ - id: z.string(), - name: z.string(), - email: z.string().email(), - }), - { - examples: [ - { - id: '1', - name: 'John Doe', - email: 'john@doe.com', - }, - ], - }, -) +JSON_SCHEMA_REGISTRY.add(NewUserSchema, { + examples: [ + { + name: 'John Doe', + email: 'john@doe.com', + password: '123456', + }, + ], +}) + +export const UserSchema = z.object({ + id: z.string(), + name: z.string(), + email: z.email(), +}) + +JSON_SCHEMA_REGISTRY.add(UserSchema, { + examples: [ + { + id: '1', + name: 'John Doe', + email: 'john@doe.com', + }, + ], +}) diff --git a/playgrounds/tanstack-start/src/router/planet.ts b/playgrounds/tanstack-start/src/router/planet.ts index 9cdf17056..028ed7eb9 100644 --- a/playgrounds/tanstack-start/src/router/planet.ts +++ b/playgrounds/tanstack-start/src/router/planet.ts @@ -1,5 +1,5 @@ import { ORPCError } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' import { authed, pub } from '../orpc' import { NewPlanetSchema, PlanetSchema, UpdatePlanetSchema } from '../schemas/planet' import { retry } from '~/middlewares/retry' diff --git a/playgrounds/tanstack-start/src/router/sse.ts b/playgrounds/tanstack-start/src/router/sse.ts index 06f0e15e9..a54cc015f 100644 --- a/playgrounds/tanstack-start/src/router/sse.ts +++ b/playgrounds/tanstack-start/src/router/sse.ts @@ -1,5 +1,5 @@ import { eventIterator, os } from '@orpc/server' -import { z } from 'zod' +import * as z from 'zod' const MAX_EVENTS = 5 diff --git a/playgrounds/tanstack-start/src/schemas/auth.ts b/playgrounds/tanstack-start/src/schemas/auth.ts index 5a70d7206..96a5cb07b 100644 --- a/playgrounds/tanstack-start/src/schemas/auth.ts +++ b/playgrounds/tanstack-start/src/schemas/auth.ts @@ -1,7 +1,7 @@ -import { z } from 'zod' +import * as z from 'zod' export const CredentialSchema = z.object({ - email: z.string().email(), + email: z.email(), password: z.string(), }) diff --git a/playgrounds/tanstack-start/src/schemas/planet.ts b/playgrounds/tanstack-start/src/schemas/planet.ts index 59a86e124..7e005fb9f 100644 --- a/playgrounds/tanstack-start/src/schemas/planet.ts +++ b/playgrounds/tanstack-start/src/schemas/planet.ts @@ -1,5 +1,4 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import * as z from 'zod' import { UserSchema } from './user' export type NewPlanet = z.infer @@ -9,20 +8,20 @@ export type Planet = z.infer export const NewPlanetSchema = z.object({ name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const UpdatePlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - image: oz.file().type('image/*').optional(), + image: z.file().mime(['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif']).optional(), }) export const PlanetSchema = z.object({ id: z.number().int().min(1), name: z.string(), description: z.string().optional(), - imageUrl: z.string().url().optional(), + imageUrl: z.url().optional(), creator: UserSchema, }) diff --git a/playgrounds/tanstack-start/src/schemas/user.ts b/playgrounds/tanstack-start/src/schemas/user.ts index 875534c3c..9813c6322 100644 --- a/playgrounds/tanstack-start/src/schemas/user.ts +++ b/playgrounds/tanstack-start/src/schemas/user.ts @@ -1,39 +1,37 @@ -import { oz } from '@orpc/zod' -import { z } from 'zod' +import { experimental_JSON_SCHEMA_REGISTRY as JSON_SCHEMA_REGISTRY } from '@orpc/zod/zod4' +import * as z from 'zod' export type NewUser = z.infer export type User = z.infer -export const NewUserSchema = oz.openapi( - z.object({ - name: z.string(), - email: z.string().email(), - password: z.string(), - }), - { - examples: [ - { - name: 'John Doe', - email: 'john@doe.com', - password: '123456', - }, - ], - }, -) +export const NewUserSchema = z.object({ + name: z.string(), + email: z.email(), + password: z.string(), +}) -export const UserSchema = oz.openapi( - z.object({ - id: z.string(), - name: z.string(), - email: z.string().email(), - }), - { - examples: [ - { - id: '1', - name: 'John Doe', - email: 'john@doe.com', - }, - ], - }, -) +JSON_SCHEMA_REGISTRY.add(NewUserSchema, { + examples: [ + { + name: 'John Doe', + email: 'john@doe.com', + password: '123456', + }, + ], +}) + +export const UserSchema = z.object({ + id: z.string(), + name: z.string(), + email: z.email(), +}) + +JSON_SCHEMA_REGISTRY.add(UserSchema, { + examples: [ + { + id: '1', + name: 'John Doe', + email: 'john@doe.com', + }, + ], +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ade9e5373..9a2ca7b9f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -148,7 +148,7 @@ importers: version: 11.8.1 openai: specifier: ^5.8.2 - version: 5.9.0(ws@8.18.3)(zod@3.25.76) + version: 5.9.0(ws@8.18.3)(zod@4.0.5) pinia: specifier: ^3.0.2 version: 3.0.3(typescript@5.8.3)(vue@3.5.17(typescript@5.8.3)) @@ -176,6 +176,9 @@ importers: vue: specifier: ^3.5.17 version: 3.5.17(typescript@5.8.3) + zod: + specifier: ^4.0.5 + version: 4.0.5 packages/arktype: dependencies: @@ -787,9 +790,6 @@ importers: zod: specifier: ^4.0.5 version: 4.0.5 - zod-to-json-schema: - specifier: ^3.24.6 - version: 3.24.6(zod@4.0.5) playgrounds/astro: devDependencies: @@ -22372,10 +22372,10 @@ snapshots: is-inside-container: 1.0.0 is-wsl: 2.2.0 - openai@5.9.0(ws@8.18.3)(zod@3.25.76): + openai@5.9.0(ws@8.18.3)(zod@4.0.5): optionalDependencies: ws: 8.18.3 - zod: 3.25.76 + zod: 4.0.5 openapi-types@12.1.3: {} @@ -25944,10 +25944,6 @@ snapshots: dependencies: zod: 3.25.76 - zod-to-json-schema@3.24.6(zod@4.0.5): - dependencies: - zod: 4.0.5 - zod-to-ts@1.2.0(typescript@5.8.3)(zod@3.25.76): dependencies: typescript: 5.8.3 From 8d9ea166677f806def08ead9f01e28b63e09cdb0 Mon Sep 17 00:00:00 2001 From: unnoq Date: Sun, 13 Jul 2025 15:54:00 +0700 Subject: [PATCH 3/6] wip --- README.md | 2 +- apps/content/docs/openapi/getting-started.md | 4 +++- apps/content/docs/openapi/plugins/openapi-reference.md | 4 +++- packages/zod/README.md | 2 +- playgrounds/contract-first/src/main.ts | 2 +- playgrounds/nest/src/reference/reference.service.ts | 2 +- playgrounds/next/src/app/api/[[...rest]]/route.ts | 2 +- playgrounds/nuxt/server/routes/api/[...].ts | 2 +- playgrounds/solid-start/src/routes/api/[...rest].ts | 2 +- playgrounds/svelte-kit/src/routes/api/[...rest]/+server.ts | 2 +- playgrounds/tanstack-start/src/routes/api/$.ts | 2 +- 11 files changed, 15 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d4fd30135..a04ce9534 100644 --- a/README.md +++ b/README.md @@ -177,7 +177,7 @@ This is a quick overview of how to use oRPC. For more details, please refer to t ```ts import { OpenAPIGenerator } from '@orpc/openapi' - import { ZodToJsonSchemaConverter } from '@orpc/zod' + import { experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverter } from '@orpc/zod/zod4' const generator = new OpenAPIGenerator({ schemaConverters: [new ZodToJsonSchemaConverter()] diff --git a/apps/content/docs/openapi/getting-started.md b/apps/content/docs/openapi/getting-started.md index 82982f64c..bf4dab6ed 100644 --- a/apps/content/docs/openapi/getting-started.md +++ b/apps/content/docs/openapi/getting-started.md @@ -171,7 +171,9 @@ Just a small tweak makes your oRPC API OpenAPI-compliant! ```ts twoslash import { OpenAPIGenerator } from '@orpc/openapi' -import { ZodToJsonSchemaConverter } from '@orpc/zod' +import { + experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverter +} from '@orpc/zod/zod4' import { router } from './shared/planet' const generator = new OpenAPIGenerator({ diff --git a/apps/content/docs/openapi/plugins/openapi-reference.md b/apps/content/docs/openapi/plugins/openapi-reference.md index 8b79a5957..89c69a39c 100644 --- a/apps/content/docs/openapi/plugins/openapi-reference.md +++ b/apps/content/docs/openapi/plugins/openapi-reference.md @@ -14,7 +14,9 @@ This plugin relies on the [OpenAPI Generator](/docs/openapi/openapi-specificatio ## Setup ```ts -import { ZodToJsonSchemaConverter } from '@orpc/zod' +import { + experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverter +} from '@orpc/zod/zod4' import { OpenAPIReferencePlugin } from '@orpc/openapi/plugins' const handler = new OpenAPIHandler(router, { diff --git a/packages/zod/README.md b/packages/zod/README.md index f02e938e3..436565961 100644 --- a/packages/zod/README.md +++ b/packages/zod/README.md @@ -86,7 +86,7 @@ const Example = z.object({ ```ts import { OpenAPIGenerator } from '@orpc/openapi' -import { ZodToJsonSchemaConverter } from '@orpc/zod' +import { experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverter } from '@orpc/zod/zod4' const openAPIGenerator = new OpenAPIGenerator({ schemaConverters: [new ZodToJsonSchemaConverter()], diff --git a/playgrounds/contract-first/src/main.ts b/playgrounds/contract-first/src/main.ts index 1e03ff6be..3cd2ef81c 100644 --- a/playgrounds/contract-first/src/main.ts +++ b/playgrounds/contract-first/src/main.ts @@ -2,7 +2,7 @@ import { createServer } from 'node:http' import { OpenAPIHandler } from '@orpc/openapi/node' import { onError } from '@orpc/server' import { RPCHandler } from '@orpc/server/node' -import { ZodToJsonSchemaConverter } from '@orpc/zod' +import { experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverter } from '@orpc/zod/zod4' import { experimental_SmartCoercionPlugin as SmartCoercionPlugin } from '@orpc/json-schema' import { router } from './router' import { OpenAPIReferencePlugin } from '@orpc/openapi/plugins' diff --git a/playgrounds/nest/src/reference/reference.service.ts b/playgrounds/nest/src/reference/reference.service.ts index ec998b2f5..d86124be0 100644 --- a/playgrounds/nest/src/reference/reference.service.ts +++ b/playgrounds/nest/src/reference/reference.service.ts @@ -1,5 +1,5 @@ import { OpenAPIGenerator } from '@orpc/openapi' -import { ZodToJsonSchemaConverter } from '@orpc/zod' +import { experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverter } from '@orpc/zod/zod4' import { contract } from 'src/contract' import { CredentialSchema, TokenSchema } from 'src/schemas/auth' import { NewPlanetSchema, PlanetSchema, UpdatePlanetSchema } from 'src/schemas/planet' diff --git a/playgrounds/next/src/app/api/[[...rest]]/route.ts b/playgrounds/next/src/app/api/[[...rest]]/route.ts index b803ef9b1..50334df10 100644 --- a/playgrounds/next/src/app/api/[[...rest]]/route.ts +++ b/playgrounds/next/src/app/api/[[...rest]]/route.ts @@ -1,7 +1,7 @@ import { router } from '@/router' import { OpenAPIHandler } from '@orpc/openapi/fetch' import { onError } from '@orpc/server' -import { ZodToJsonSchemaConverter } from '@orpc/zod' +import { experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverter } from '@orpc/zod/zod4' import { experimental_SmartCoercionPlugin as SmartCoercionPlugin } from '@orpc/json-schema' import { OpenAPIReferencePlugin } from '@orpc/openapi/plugins' import '../../../polyfill' diff --git a/playgrounds/nuxt/server/routes/api/[...].ts b/playgrounds/nuxt/server/routes/api/[...].ts index 35ac7fde4..c3aae8ea3 100644 --- a/playgrounds/nuxt/server/routes/api/[...].ts +++ b/playgrounds/nuxt/server/routes/api/[...].ts @@ -1,6 +1,6 @@ import { OpenAPIHandler } from '@orpc/openapi/node' import { onError } from '@orpc/server' -import { ZodToJsonSchemaConverter } from '@orpc/zod' +import { experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverter } from '@orpc/zod/zod4' import { experimental_SmartCoercionPlugin as SmartCoercionPlugin } from '@orpc/json-schema' import { router } from '~/server/router' import { OpenAPIReferencePlugin } from '@orpc/openapi/plugins' diff --git a/playgrounds/solid-start/src/routes/api/[...rest].ts b/playgrounds/solid-start/src/routes/api/[...rest].ts index fc944ccfc..cb80fdb92 100644 --- a/playgrounds/solid-start/src/routes/api/[...rest].ts +++ b/playgrounds/solid-start/src/routes/api/[...rest].ts @@ -1,7 +1,7 @@ import type { APIEvent } from '@solidjs/start/server' import { OpenAPIHandler } from '@orpc/openapi/fetch' import { router } from '~/router' -import { ZodToJsonSchemaConverter } from '@orpc/zod' +import { experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverter } from '@orpc/zod/zod4' import { experimental_SmartCoercionPlugin as SmartCoercionPlugin } from '@orpc/json-schema' import { onError } from '@orpc/server' import { OpenAPIReferencePlugin } from '@orpc/openapi/plugins' diff --git a/playgrounds/svelte-kit/src/routes/api/[...rest]/+server.ts b/playgrounds/svelte-kit/src/routes/api/[...rest]/+server.ts index 20d223a89..b12e99bbb 100644 --- a/playgrounds/svelte-kit/src/routes/api/[...rest]/+server.ts +++ b/playgrounds/svelte-kit/src/routes/api/[...rest]/+server.ts @@ -2,7 +2,7 @@ import { OpenAPIHandler } from '@orpc/openapi/fetch' import { router } from '../../../router' import { onError } from '@orpc/server' import type { RequestHandler } from '@sveltejs/kit' -import { ZodToJsonSchemaConverter } from '@orpc/zod' +import { experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverter } from '@orpc/zod/zod4' import { experimental_SmartCoercionPlugin as SmartCoercionPlugin } from '@orpc/json-schema' import { OpenAPIReferencePlugin } from '@orpc/openapi/plugins' import '../../../polyfill' diff --git a/playgrounds/tanstack-start/src/routes/api/$.ts b/playgrounds/tanstack-start/src/routes/api/$.ts index 881457ab4..a2ce65951 100644 --- a/playgrounds/tanstack-start/src/routes/api/$.ts +++ b/playgrounds/tanstack-start/src/routes/api/$.ts @@ -1,7 +1,7 @@ import '~/polyfill' import { OpenAPIHandler } from '@orpc/openapi/fetch' -import { ZodToJsonSchemaConverter } from '@orpc/zod' +import { experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverter } from '@orpc/zod/zod4' import { experimental_SmartCoercionPlugin as SmartCoercionPlugin } from '@orpc/json-schema' import { createServerFileRoute } from '@tanstack/react-start/server' import { router } from '~/router/index' From 59e3d057e3d959574a0a03f2c00077a3d2dda7a0 Mon Sep 17 00:00:00 2001 From: unnoq Date: Sun, 13 Jul 2025 16:08:02 +0700 Subject: [PATCH 4/6] validation errors --- .../docs/advanced/validation-errors.md | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/apps/content/docs/advanced/validation-errors.md b/apps/content/docs/advanced/validation-errors.md index df2fb48cd..29d545910 100644 --- a/apps/content/docs/advanced/validation-errors.md +++ b/apps/content/docs/advanced/validation-errors.md @@ -16,8 +16,7 @@ import { RPCHandler } from '@orpc/server/fetch' import { router } from './shared/planet' // ---cut--- import { onError, ORPCError, ValidationError } from '@orpc/server' -import { ZodError } from 'zod' -import type { ZodIssue } from 'zod' +import * as z from 'zod' const handler = new RPCHandler(router, { clientInterceptors: [ @@ -28,11 +27,12 @@ const handler = new RPCHandler(router, { && error.cause instanceof ValidationError ) { // If you only use Zod you can safely cast to ZodIssue[] - const zodError = new ZodError(error.cause.issues as ZodIssue[]) + const zodError = new z.ZodError(error.cause.issues as z.core.$ZodIssue[]) throw new ORPCError('INPUT_VALIDATION_FAILED', { status: 422, - data: zodError.flatten(), + message: z.prettifyError(zodError), + data: z.flattenError(zodError), cause: error.cause, }) } @@ -54,9 +54,8 @@ const handler = new RPCHandler(router, { ## Customizing with Middleware ```ts twoslash -import * as z from 'zod' -import type { ZodIssue } from 'zod' import { onError, ORPCError, os, ValidationError } from '@orpc/server' +import * as z from 'zod' const base = os.use(onError((error) => { if ( @@ -65,11 +64,12 @@ const base = os.use(onError((error) => { && error.cause instanceof ValidationError ) { // If you only use Zod you can safely cast to ZodIssue[] - const zodError = new z.ZodError(error.cause.issues as z.ZodIssue[]) + const zodError = new z.ZodError(error.cause.issues as z.core.$ZodIssue[]) throw new ORPCError('INPUT_VALIDATION_FAILED', { status: 422, - data: zodError.flatten(), + message: z.prettifyError(zodError), + data: z.flattenError(zodError), cause: error.cause, }) } @@ -132,11 +132,12 @@ const handler = new RPCHandler({ example }, { && error.cause instanceof ValidationError ) { // If you only use Zod you can safely cast to ZodIssue[] - const zodError = new z.ZodError(error.cause.issues as z.ZodIssue[]) + const zodError = new z.ZodError(error.cause.issues as z.core.$ZodIssue[]) throw new ORPCError('INPUT_VALIDATION_FAILED', { status: 422, - data: zodError.flatten(), + message: z.prettifyError(zodError), + data: z.flattenError(zodError), cause: error.cause, }) } From 42a0ff3fb08774fb437eaead9f308ac798015e98 Mon Sep 17 00:00:00 2001 From: unnoq Date: Sun, 13 Jul 2025 16:19:16 +0700 Subject: [PATCH 5/6] sync tests --- packages/client/tests/e2e.test.ts | 9 ++--- .../src/smart-coercion-plugin.test.ts | 2 +- .../openapi/src/openapi-generator.test.ts | 34 +++++++++---------- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/packages/client/tests/e2e.test.ts b/packages/client/tests/e2e.test.ts index 3f7aebfff..e7e041b77 100644 --- a/packages/client/tests/e2e.test.ts +++ b/packages/client/tests/e2e.test.ts @@ -33,13 +33,10 @@ describe('e2e', () => { expect(error3).toBeInstanceOf(ORPCError) expect((error3 as any).code).toEqual('BAD_REQUEST') expect((error3 as any).data).toEqual({ - issues: [{ - code: 'invalid_type', - expected: 'string', - message: 'Required', + issues: [expect.objectContaining({ + message: expect.any(String), path: ['title'], - received: 'undefined', - }], + })], }) }) diff --git a/packages/json-schema/src/smart-coercion-plugin.test.ts b/packages/json-schema/src/smart-coercion-plugin.test.ts index e52eb5550..33ba307aa 100644 --- a/packages/json-schema/src/smart-coercion-plugin.test.ts +++ b/packages/json-schema/src/smart-coercion-plugin.test.ts @@ -1,5 +1,5 @@ import * as z from 'zod' -import { ZodToJsonSchemaConverter } from '../../zod/src' +import { experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverter } from '../../zod/src/zod4' import { experimental_SmartCoercionPlugin as SmartCoercionPlugin } from './smart-coercion-plugin' describe('smartCoercionPlugin', () => { diff --git a/packages/openapi/src/openapi-generator.test.ts b/packages/openapi/src/openapi-generator.test.ts index 73a75ccfe..2d1e992a6 100644 --- a/packages/openapi/src/openapi-generator.test.ts +++ b/packages/openapi/src/openapi-generator.test.ts @@ -1,9 +1,7 @@ import type { AnyContractProcedure } from '@orpc/contract' import { eventIterator, oc } from '@orpc/contract' import * as z from 'zod' -import * as z4 from 'zod/v4' -import { oz, ZodToJsonSchemaConverter } from '../../zod/src' -import { experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverterV4 } from '../../zod/src/zod4' +import { experimental_ZodToJsonSchemaConverter as ZodToJsonSchemaConverter } from '../../zod/src/zod4' import { customOpenAPIOperation } from './openapi-custom' import { OpenAPIGenerator } from './openapi-generator' @@ -241,7 +239,7 @@ const inputTests: TestCase[] = [ }, { name: 'file', - contract: oc.input(oz.file().type('image/png')), + contract: oc.input(z.file().mime(['image/png'])), expected: { '/': { post: expect.objectContaining({ @@ -1001,48 +999,48 @@ describe('openAPIGenerator', () => { describe('generator - commonSchemas', async () => { const generator = new OpenAPIGenerator({ schemaConverters: [ - new ZodToJsonSchemaConverterV4(), + new ZodToJsonSchemaConverter(), ], }) - const User = z4.object({ - id: z4.string(), + const User = z.object({ + id: z.string(), get parent() { return User.optional() }, }) - const Pet = z4.object({ - id: z4.string().transform(v => Number(v)).pipe(z4.number().min(0).max(100)), + const Pet = z.object({ + id: z.string().transform(v => Number(v)).pipe(z.number().min(0).max(100)), }) - const Params = z4.object({ + const Params = z.object({ pet: Pet, }) - const Query = z4.object({ + const Query = z.object({ user: User, }) - const Headers = z4.object({ + const Headers = z.object({ user: User, }) - const InputDetailedStructure = z4.object({ + const InputDetailedStructure = z.object({ params: Params, query: Query, headers: Headers, body: User, }) - const OutputDetailedStructure = z4.union([ - z4.object({ - status: z4.literal(200), + const OutputDetailedStructure = z.union([ + z.object({ + status: z.literal(200), headers: Headers, body: User, }), - z4.object({ - status: z4.literal(201), + z.object({ + status: z.literal(201), body: User, }), ]) From e40db829f36b9cae879fa39a6b925b34c09344e3 Mon Sep 17 00:00:00 2001 From: unnoq Date: Sun, 13 Jul 2025 16:43:20 +0700 Subject: [PATCH 6/6] improve --- apps/content/docs/openapi/openapi-specification.md | 4 ++-- packages/zod/README.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/content/docs/openapi/openapi-specification.md b/apps/content/docs/openapi/openapi-specification.md index fb7ade584..dead4d350 100644 --- a/apps/content/docs/openapi/openapi-specification.md +++ b/apps/content/docs/openapi/openapi-specification.md @@ -302,7 +302,7 @@ JSON_SCHEMA_OUTPUT_REGISTRY.add(InputSchema, { In the [File Upload/Download](/docs/file-upload-download) guide, `z.instanceof` is used to describe file/blob schemas. However, this method prevents oRPC from recognizing file/blob schema. Instead, use the enhanced file schema approach: ```ts -import { z } from 'zod' +import { z } from 'zod/v3' import { oz } from '@orpc/zod' const InputSchema = z.object({ @@ -317,7 +317,7 @@ const InputSchema = z.object({ If Zod alone does not cover your JSON Schema requirements, you can extend or override the generated schema: ```ts -import { z } from 'zod' +import { z } from 'zod/v3' import { oz } from '@orpc/zod' const InputSchema = oz.openapi( diff --git a/packages/zod/README.md b/packages/zod/README.md index 436565961..09a7dd072 100644 --- a/packages/zod/README.md +++ b/packages/zod/README.md @@ -72,7 +72,7 @@ More schemas that [Zod](https://zod.dev/) doesn't support yet, and provides `Zod ```ts import { oz } from '@orpc/zod' -import * as z from 'zod' +import { z } from 'zod/v3' const Example = z.object({ url: oz.url(),