From 8d6a710432690cc593cfc7ea9eb5cd5183055d2f Mon Sep 17 00:00:00 2001 From: Yiming Date: Fri, 13 Dec 2024 09:30:38 +0800 Subject: [PATCH 1/2] chore: exclude IDE packages from regular build (#1911) --- .github/workflows/build-test.yml | 2 +- package.json | 3 ++- packages/plugins/openapi/package.json | 2 +- packages/plugins/trpc/package.json | 6 ++++-- .../trpc/tests/projects/nuxt-trpc-v10/package.json | 2 +- .../trpc/tests/projects/nuxt-trpc-v11/package.json | 2 +- .../trpc/tests/projects/t3-trpc-v10/package.json | 2 +- .../trpc/tests/projects/t3-trpc-v11/package.json | 2 +- packages/runtime/src/zod-utils.ts | 14 +++++++++----- script/test-scaffold.ts | 2 +- 10 files changed, 22 insertions(+), 15 deletions(-) diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 717cf03b8..54868c57b 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -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 diff --git a/package.json b/package.json index c4834d97b..8e55c4ed3 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/packages/plugins/openapi/package.json b/packages/plugins/openapi/package.json index 9c9c4da71..307403477 100644 --- a/packages/plugins/openapi/package.json +++ b/packages/plugins/openapi/package.json @@ -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": { diff --git a/packages/plugins/trpc/package.json b/packages/plugins/trpc/package.json index 304ec2ac1..858e71521 100644 --- a/packages/plugins/trpc/package.json +++ b/packages/plugins/trpc/package.json @@ -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", diff --git a/packages/plugins/trpc/tests/projects/nuxt-trpc-v10/package.json b/packages/plugins/trpc/tests/projects/nuxt-trpc-v10/package.json index 9a89c1e8b..387a37f37 100644 --- a/packages/plugins/trpc/tests/projects/nuxt-trpc-v10/package.json +++ b/packages/plugins/trpc/tests/projects/nuxt-trpc-v10/package.json @@ -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", diff --git a/packages/plugins/trpc/tests/projects/nuxt-trpc-v11/package.json b/packages/plugins/trpc/tests/projects/nuxt-trpc-v11/package.json index 68a65a4ca..38b9e2919 100644 --- a/packages/plugins/trpc/tests/projects/nuxt-trpc-v11/package.json +++ b/packages/plugins/trpc/tests/projects/nuxt-trpc-v11/package.json @@ -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", diff --git a/packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json b/packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json index e26114fee..ad9203091 100644 --- a/packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json +++ b/packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json @@ -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", diff --git a/packages/plugins/trpc/tests/projects/t3-trpc-v11/package.json b/packages/plugins/trpc/tests/projects/t3-trpc-v11/package.json index 410d6c2a2..01117d261 100644 --- a/packages/plugins/trpc/tests/projects/t3-trpc-v11/package.json +++ b/packages/plugins/trpc/tests/projects/t3-trpc-v11/package.json @@ -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", diff --git a/packages/runtime/src/zod-utils.ts b/packages/runtime/src/zod-utils.ts index 47fa5a011..1ebaf9cdc 100644 --- a/packages/runtime/src/zod-utils.ts +++ b/packages/runtime/src/zod-utils.ts @@ -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 @@ -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> + >, data ); if (success) { @@ -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[], data ); if (success) { diff --git a/script/test-scaffold.ts b/script/test-scaffold.ts index fdc82d952..5904a67c7 100644 --- a/script/test-scaffold.ts +++ b/script/test-scaffold.ts @@ -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.'); From 6d53c18ab972766c54294f66baadcf360b0f5c3f Mon Sep 17 00:00:00 2001 From: Yiming Date: Fri, 13 Dec 2024 10:22:02 +0800 Subject: [PATCH 2/2] fix: preserve custom attributes as comments in logical prisma schema (#1912) --- package.json | 2 +- packages/ide/jetbrains/build.gradle.kts | 2 +- packages/ide/jetbrains/package.json | 2 +- packages/language/package.json | 2 +- packages/misc/redwood/package.json | 2 +- packages/plugins/openapi/package.json | 2 +- packages/plugins/swr/package.json | 2 +- packages/plugins/tanstack-query/package.json | 2 +- packages/plugins/trpc/package.json | 2 +- packages/runtime/package.json | 2 +- packages/schema/package.json | 2 +- packages/schema/src/plugins/enhancer/enhance/index.ts | 1 + packages/sdk/package.json | 2 +- packages/server/package.json | 2 +- packages/testtools/package.json | 2 +- 15 files changed, 15 insertions(+), 14 deletions(-) diff --git a/package.json b/package.json index 8e55c4ed3..592e05444 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zenstack-monorepo", - "version": "2.10.0", + "version": "2.10.1", "description": "", "scripts": { "build": "pnpm -r --filter=\"!./packages/ide/*\" build", diff --git a/packages/ide/jetbrains/build.gradle.kts b/packages/ide/jetbrains/build.gradle.kts index dc3a8f98e..0554f2732 100644 --- a/packages/ide/jetbrains/build.gradle.kts +++ b/packages/ide/jetbrains/build.gradle.kts @@ -9,7 +9,7 @@ plugins { } group = "dev.zenstack" -version = "2.10.0" +version = "2.10.1" repositories { mavenCentral() diff --git a/packages/ide/jetbrains/package.json b/packages/ide/jetbrains/package.json index e5e613042..9b4bbf0b3 100644 --- a/packages/ide/jetbrains/package.json +++ b/packages/ide/jetbrains/package.json @@ -1,6 +1,6 @@ { "name": "jetbrains", - "version": "2.10.0", + "version": "2.10.1", "displayName": "ZenStack JetBrains IDE Plugin", "description": "ZenStack JetBrains IDE plugin", "homepage": "https://zenstack.dev", diff --git a/packages/language/package.json b/packages/language/package.json index caa87b422..364808bdb 100644 --- a/packages/language/package.json +++ b/packages/language/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/language", - "version": "2.10.0", + "version": "2.10.1", "displayName": "ZenStack modeling language compiler", "description": "ZenStack modeling language compiler", "homepage": "https://zenstack.dev", diff --git a/packages/misc/redwood/package.json b/packages/misc/redwood/package.json index 8cfdbaa5e..0d3e055e1 100644 --- a/packages/misc/redwood/package.json +++ b/packages/misc/redwood/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/redwood", "displayName": "ZenStack RedwoodJS Integration", - "version": "2.10.0", + "version": "2.10.1", "description": "CLI and runtime for integrating ZenStack with RedwoodJS projects.", "repository": { "type": "git", diff --git a/packages/plugins/openapi/package.json b/packages/plugins/openapi/package.json index 307403477..4db0ec829 100644 --- a/packages/plugins/openapi/package.json +++ b/packages/plugins/openapi/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/openapi", "displayName": "ZenStack Plugin and Runtime for OpenAPI", - "version": "2.10.0", + "version": "2.10.1", "description": "ZenStack plugin and runtime supporting OpenAPI", "main": "index.js", "repository": { diff --git a/packages/plugins/swr/package.json b/packages/plugins/swr/package.json index 553aac1d2..365eaf67d 100644 --- a/packages/plugins/swr/package.json +++ b/packages/plugins/swr/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/swr", "displayName": "ZenStack plugin for generating SWR hooks", - "version": "2.10.0", + "version": "2.10.1", "description": "ZenStack plugin for generating SWR hooks", "main": "index.js", "repository": { diff --git a/packages/plugins/tanstack-query/package.json b/packages/plugins/tanstack-query/package.json index 22aae65e8..bae35d12b 100644 --- a/packages/plugins/tanstack-query/package.json +++ b/packages/plugins/tanstack-query/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/tanstack-query", "displayName": "ZenStack plugin for generating tanstack-query hooks", - "version": "2.10.0", + "version": "2.10.1", "description": "ZenStack plugin for generating tanstack-query hooks", "main": "index.js", "exports": { diff --git a/packages/plugins/trpc/package.json b/packages/plugins/trpc/package.json index 858e71521..cb2f436cc 100644 --- a/packages/plugins/trpc/package.json +++ b/packages/plugins/trpc/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/trpc", "displayName": "ZenStack plugin for tRPC", - "version": "2.10.0", + "version": "2.10.1", "description": "ZenStack plugin for tRPC", "main": "index.js", "repository": { diff --git a/packages/runtime/package.json b/packages/runtime/package.json index 66fec338d..10e419553 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/runtime", "displayName": "ZenStack Runtime Library", - "version": "2.10.0", + "version": "2.10.1", "description": "Runtime of ZenStack for both client-side and server-side environments.", "repository": { "type": "git", diff --git a/packages/schema/package.json b/packages/schema/package.json index 9a3f3d75e..7c12ca53f 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -3,7 +3,7 @@ "publisher": "zenstack", "displayName": "ZenStack Language Tools", "description": "FullStack enhancement for Prisma ORM: seamless integration from database to UI", - "version": "2.10.0", + "version": "2.10.1", "author": { "name": "ZenStack Team" }, diff --git a/packages/schema/src/plugins/enhancer/enhance/index.ts b/packages/schema/src/plugins/enhancer/enhance/index.ts index 51f100557..ba8c50feb 100644 --- a/packages/schema/src/plugins/enhancer/enhance/index.ts +++ b/packages/schema/src/plugins/enhancer/enhance/index.ts @@ -283,6 +283,7 @@ export function enhance(prisma: any, context?: EnhancementContext<${authTypePara output: logicalPrismaFile, overrideClientGenerationPath: prismaClientOutDir, mode: 'logical', + customAttributesAsComments: true, }); // generate the prisma client diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 52d0ce0dd..0ce487801 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/sdk", - "version": "2.10.0", + "version": "2.10.1", "description": "ZenStack plugin development SDK", "main": "index.js", "scripts": { diff --git a/packages/server/package.json b/packages/server/package.json index b9de91e73..c427dbd68 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/server", - "version": "2.10.0", + "version": "2.10.1", "displayName": "ZenStack Server-side Adapters", "description": "ZenStack server-side adapters", "homepage": "https://zenstack.dev", diff --git a/packages/testtools/package.json b/packages/testtools/package.json index 935c1e7fb..43df0aad6 100644 --- a/packages/testtools/package.json +++ b/packages/testtools/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/testtools", - "version": "2.10.0", + "version": "2.10.1", "description": "ZenStack Test Tools", "main": "index.js", "private": true,