Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:
gradle-home-cache-cleanup: true

- name: Build
run: DEFAULT_NPM_TAG=latest pnpm run build
run: DEFAULT_NPM_TAG=latest pnpm run build-ci

- name: Lint
run: pnpm lint
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"version": "2.10.0",
"description": "",
"scripts": {
"build": "pnpm -r build",
"build": "pnpm -r --filter=\"!./packages/ide/*\" build",
"build-ci": "pnpm -r build",
"lint": "pnpm -r lint",
"test": "pnpm -r --parallel run test --silent --forceExit",
"test-ci": "pnpm -r --parallel run --filter=\"./packages/**\" test --silent --forceExit",
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/openapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"ts-pattern": "^4.3.0",
"upper-case-first": "^2.0.2",
"yaml": "^2.2.2",
"zod": "^3.22.4",
"zod": "^3.22.4",
"zod-validation-error": "^1.5.0"
},
"devDependencies": {
Expand Down
6 changes: 4 additions & 2 deletions packages/plugins/trpc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@
"lower-case-first": "^2.0.2",
"ts-morph": "^16.0.0",
"tslib": "^2.4.1",
"upper-case-first": "^2.0.2",
"zod": "^3.22.4"
"upper-case-first": "^2.0.2"
},
"peerDependencies": {
"zod": "^3.22.4"
},
"devDependencies": {
"@trpc/next": "^10.32.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"trpc-nuxt": "^0.10.22",
"vue": "latest",
"vue-router": "latest",
"zod": "^3.23.8"
"zod": "^3.22.4"
},
"devDependencies": {
"esbuild": "^0.24.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"trpc-nuxt": "^0.11.0-beta.1",
"vue": "latest",
"vue-router": "latest",
"zod": "^3.23.8"
"zod": "^3.22.4"
},
"devDependencies": {
"esbuild": "^0.24.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"react": "18.2.0",
"react-dom": "18.2.0",
"superjson": "^2.2.1",
"zod": "^3.22.4"
"zod": "^3.22.4"
},
"devDependencies": {
"@types/eslint": "^8.44.7",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"react-dom": "^18.3.1",
"server-only": "^0.0.1",
"superjson": "^2.2.1",
"zod": "^3.23.3"
"zod": "^3.22.4"
},
"devDependencies": {
"@types/eslint": "^8.56.10",
Expand Down
14 changes: 9 additions & 5 deletions packages/runtime/src/zod-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import { z as Z } from 'zod';
* accidentally matching a less-ideal schema candidate.
*
* The helper uses a custom schema to find the candidate that results in the fewest unrecognized keys when parsing the data.
*
* The function uses `any` for parameter and return type to be compatible with various zod versions.
*/
export function smartUnion(z: typeof Z, candidates: Z.ZodSchema[]) {
export function smartUnion(z: any, candidates: any[]): any {
// strip `z.lazy`
const processedCandidates = candidates.map((candidate) => unwrapLazy(z, candidate));
const processedCandidates: Z.ZodSchema[] = candidates.map((candidate) => unwrapLazy(z, candidate));

if (processedCandidates.some((c) => !(c instanceof z.ZodObject || c instanceof z.ZodArray))) {
// fall back to plain union if not all candidates are objects or arrays
Expand All @@ -22,11 +24,13 @@ export function smartUnion(z: typeof Z, candidates: Z.ZodSchema[]) {
let resultData: any;

return z
.custom((data) => {
.custom((data: any) => {
if (Array.isArray(data)) {
const { data: result, success } = smartArrayUnion(
z,
processedCandidates.filter((c) => c instanceof z.ZodArray),
processedCandidates.filter((c) => c instanceof z.ZodArray) as Array<
Z.ZodArray<Z.ZodObject<Z.ZodRawShape>>
>,
data
);
if (success) {
Expand All @@ -36,7 +40,7 @@ export function smartUnion(z: typeof Z, candidates: Z.ZodSchema[]) {
} else {
const { data: result, success } = smartObjectUnion(
z,
processedCandidates.filter((c) => c instanceof z.ZodObject),
processedCandidates.filter((c) => c instanceof z.ZodObject) as Z.ZodObject<Z.ZodRawShape>[],
data
);
if (success) {
Expand Down
2 changes: 1 addition & 1 deletion script/test-scaffold.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ function run(cmd: string) {
}

run('npm init -y');
run('npm i --no-audit --no-fund typescript prisma@6.0.x @prisma/client@6.0.x zod decimal.js @types/node');
run('npm i --no-audit --no-fund typescript prisma@6.0.x @prisma/client@6.0.x zod@^3.22.4 decimal.js @types/node');

console.log('Test scaffold setup complete.');
Loading