From c5b9d59462bc47b6db4cf0139de3663b08700f67 Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Wed, 6 Mar 2024 21:35:03 -0800 Subject: [PATCH 1/2] fix: prisma.d.ts is not properly saved --- 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/plugins/trpc/tests/projects/t3-trpc-v10/package.json | 4 ++++ packages/runtime/package.json | 2 +- packages/schema/package.json | 2 +- packages/schema/src/plugins/enhancer/enhance/index.ts | 4 ++-- packages/sdk/package.json | 2 +- packages/server/package.json | 2 +- packages/testtools/package.json | 2 +- 16 files changed, 20 insertions(+), 16 deletions(-) diff --git a/package.json b/package.json index febc93264..274647379 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zenstack-monorepo", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "description": "", "scripts": { "build": "pnpm -r build", diff --git a/packages/ide/jetbrains/build.gradle.kts b/packages/ide/jetbrains/build.gradle.kts index 4c8825117..cd51282f0 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.0.0-alpha.1" +version = "2.0.0-alpha.3" repositories { mavenCentral() diff --git a/packages/ide/jetbrains/package.json b/packages/ide/jetbrains/package.json index 47dfec1b8..45658df7a 100644 --- a/packages/ide/jetbrains/package.json +++ b/packages/ide/jetbrains/package.json @@ -1,6 +1,6 @@ { "name": "jetbrains", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "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 0b7ea3673..c4bf8bf3e 100644 --- a/packages/language/package.json +++ b/packages/language/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/language", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "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 cb75056e7..10e4b55fb 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.0.0-alpha.2", + "version": "2.0.0-alpha.3", "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 3ea7a4397..b4a539941 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.0.0-alpha.2", + "version": "2.0.0-alpha.3", "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 7af3405d2..327a8dcfc 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.0.0-alpha.2", + "version": "2.0.0-alpha.3", "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 1416132c4..8dd0d15d3 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.0.0-alpha.2", + "version": "2.0.0-alpha.3", "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 4b56afd1c..e4f8e4a05 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.0.0-alpha.2", + "version": "2.0.0-alpha.3", "description": "ZenStack plugin for tRPC", "main": "index.js", "repository": { 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 a9c99ebba..5878a8037 100644 --- a/packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json +++ b/packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json @@ -20,10 +20,14 @@ "@trpc/next": "^10.43.6", "@trpc/react-query": "^10.43.6", "@trpc/server": "^10.43.6", + "@zenstackhq/language": "file:../../../../../../.build/zenstackhq-language-2.0.0-alpha.2.tgz", + "@zenstackhq/runtime": "file:../../../../../../.build/zenstackhq-runtime-2.0.0-alpha.2.tgz", + "@zenstackhq/sdk": "file:../../../../../../.build/zenstackhq-sdk-2.0.0-alpha.2.tgz", "next": "^14.0.4", "react": "18.2.0", "react-dom": "18.2.0", "superjson": "^2.2.1", + "zenstack": "file:../../../../../../.build/zenstack-2.0.0-alpha.2.tgz", "zod": "^3.22.4" }, "devDependencies": { diff --git a/packages/runtime/package.json b/packages/runtime/package.json index 34f6ea0ed..c80bbca5f 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/runtime", "displayName": "ZenStack Runtime Library", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "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 762e20089..7269e9788 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -3,7 +3,7 @@ "publisher": "zenstack", "displayName": "ZenStack Language Tools", "description": "Build scalable web apps with minimum code by defining authorization and validation rules inside the data schema that closer to the database", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "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 63845ba1c..3010211ec 100644 --- a/packages/schema/src/plugins/enhancer/enhance/index.ts +++ b/packages/schema/src/plugins/enhancer/enhance/index.ts @@ -49,7 +49,7 @@ export async function generate(model: Model, options: PluginOptions, project: Pr `export type * from '${logicalPrismaClientDir}/index-fixed';`, { overwrite: true } ); - await saveSourceFile(prismaDts, options); + await prismaDts.save(); } else { // just reexport the prisma client const prismaDts = project.createSourceFile( @@ -57,7 +57,7 @@ export async function generate(model: Model, options: PluginOptions, project: Pr `export type * from '${getPrismaClientImportSpec(outDir, options)}';`, { overwrite: true } ); - await saveSourceFile(prismaDts, options); + await prismaDts.save(); } const enhanceTs = project.createSourceFile( diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 671f87155..5bdf1dc2b 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/sdk", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "description": "ZenStack plugin development SDK", "main": "index.js", "scripts": { diff --git a/packages/server/package.json b/packages/server/package.json index f988b0e93..59c01026a 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/server", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "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 9b9379a8d..b4741bb63 100644 --- a/packages/testtools/package.json +++ b/packages/testtools/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/testtools", - "version": "2.0.0-alpha.2", + "version": "2.0.0-alpha.3", "description": "ZenStack Test Tools", "main": "index.js", "private": true, From bc5db1b1395ab551f0078424ebd78df8647e96e8 Mon Sep 17 00:00:00 2001 From: ymc9 <104139426+ymc9@users.noreply.github.com> Date: Wed, 6 Mar 2024 21:54:04 -0800 Subject: [PATCH 2/2] bump version --- 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 +- .../trpc/tests/projects/t3-trpc-v10/.gitignore | 3 ++- .../trpc/tests/projects/t3-trpc-v10/package.json | 4 ---- packages/runtime/package.json | 2 +- packages/schema/package.json | 2 +- .../schema/src/plugins/enhancer/enhance/index.ts | 12 ++++++++---- packages/sdk/package.json | 2 +- packages/server/package.json | 2 +- packages/testtools/package.json | 2 +- 17 files changed, 24 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index 274647379..54769b34b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zenstack-monorepo", - "version": "2.0.0-alpha.3", + "version": "2.0.0-alpha.4", "description": "", "scripts": { "build": "pnpm -r build", diff --git a/packages/ide/jetbrains/build.gradle.kts b/packages/ide/jetbrains/build.gradle.kts index cd51282f0..23c8d0b7b 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.0.0-alpha.3" +version = "2.0.0-alpha.4" repositories { mavenCentral() diff --git a/packages/ide/jetbrains/package.json b/packages/ide/jetbrains/package.json index 45658df7a..db2daea8d 100644 --- a/packages/ide/jetbrains/package.json +++ b/packages/ide/jetbrains/package.json @@ -1,6 +1,6 @@ { "name": "jetbrains", - "version": "2.0.0-alpha.3", + "version": "2.0.0-alpha.4", "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 c4bf8bf3e..315e65049 100644 --- a/packages/language/package.json +++ b/packages/language/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/language", - "version": "2.0.0-alpha.3", + "version": "2.0.0-alpha.4", "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 10e4b55fb..9886151b4 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.0.0-alpha.3", + "version": "2.0.0-alpha.4", "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 b4a539941..5d191e2ff 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.0.0-alpha.3", + "version": "2.0.0-alpha.4", "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 327a8dcfc..12652665d 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.0.0-alpha.3", + "version": "2.0.0-alpha.4", "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 8dd0d15d3..3da2d8bf8 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.0.0-alpha.3", + "version": "2.0.0-alpha.4", "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 e4f8e4a05..c21bccd72 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.0.0-alpha.3", + "version": "2.0.0-alpha.4", "description": "ZenStack plugin for tRPC", "main": "index.js", "repository": { diff --git a/packages/plugins/trpc/tests/projects/t3-trpc-v10/.gitignore b/packages/plugins/trpc/tests/projects/t3-trpc-v10/.gitignore index b9331d6ce..e3f5e79f8 100644 --- a/packages/plugins/trpc/tests/projects/t3-trpc-v10/.gitignore +++ b/packages/plugins/trpc/tests/projects/t3-trpc-v10/.gitignore @@ -40,4 +40,5 @@ yarn-error.log* # typescript *.tsbuildinfo -package-lock.json \ No newline at end of file +package-lock.json +package.json \ No newline at end of file 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 5878a8037..a9c99ebba 100644 --- a/packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json +++ b/packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json @@ -20,14 +20,10 @@ "@trpc/next": "^10.43.6", "@trpc/react-query": "^10.43.6", "@trpc/server": "^10.43.6", - "@zenstackhq/language": "file:../../../../../../.build/zenstackhq-language-2.0.0-alpha.2.tgz", - "@zenstackhq/runtime": "file:../../../../../../.build/zenstackhq-runtime-2.0.0-alpha.2.tgz", - "@zenstackhq/sdk": "file:../../../../../../.build/zenstackhq-sdk-2.0.0-alpha.2.tgz", "next": "^14.0.4", "react": "18.2.0", "react-dom": "18.2.0", "superjson": "^2.2.1", - "zenstack": "file:../../../../../../.build/zenstack-2.0.0-alpha.2.tgz", "zod": "^3.22.4" }, "devDependencies": { diff --git a/packages/runtime/package.json b/packages/runtime/package.json index c80bbca5f..4dcb94daa 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,7 +1,7 @@ { "name": "@zenstackhq/runtime", "displayName": "ZenStack Runtime Library", - "version": "2.0.0-alpha.3", + "version": "2.0.0-alpha.4", "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 7269e9788..d2113958a 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -3,7 +3,7 @@ "publisher": "zenstack", "displayName": "ZenStack Language Tools", "description": "Build scalable web apps with minimum code by defining authorization and validation rules inside the data schema that closer to the database", - "version": "2.0.0-alpha.3", + "version": "2.0.0-alpha.4", "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 3010211ec..df14e0826 100644 --- a/packages/schema/src/plugins/enhancer/enhance/index.ts +++ b/packages/schema/src/plugins/enhancer/enhance/index.ts @@ -36,7 +36,9 @@ export async function generate(model: Model, options: PluginOptions, project: Pr let logicalPrismaClientDir: string | undefined; let dmmf: DMMF.Document | undefined; - if (needsLogicalClient(model)) { + const withLogicalClient = needsLogicalClient(model); + + if (withLogicalClient) { // schema contains delegate models, need to generate a logical prisma schema const result = await generateLogicalPrisma(model, options, outDir); @@ -67,16 +69,18 @@ import modelMeta from './model-meta'; import policy from './policy'; ${options.withZodSchemas ? "import * as zodSchemas from './zod';" : 'const zodSchemas = undefined;'} import { Prisma } from '${getPrismaClientImportSpec(outDir, options)}'; -${logicalPrismaClientDir ? `import { type PrismaClient } from '${logicalPrismaClientDir}/index-fixed';` : ``} +${withLogicalClient ? `import { type PrismaClient } from '${logicalPrismaClientDir}/index-fixed';` : ``} -export function enhance(prisma: DbClient, context?: EnhancementContext, options?: EnhancementOptions) { +export function enhance(prisma: DbClient, context?: EnhancementContext, options?: EnhancementOptions)${ + withLogicalClient ? ': PrismaClient' : '' + } { return createEnhancement(prisma, { modelMeta, policy, zodSchemas: zodSchemas as unknown as (ZodSchemas | undefined), prismaModule: Prisma, ...options - }, context)${logicalPrismaClientDir ? ' as PrismaClient' : ''}; + }, context)${withLogicalClient ? ' as PrismaClient' : ''}; } `, { overwrite: true } diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 5bdf1dc2b..d29ecefe1 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/sdk", - "version": "2.0.0-alpha.3", + "version": "2.0.0-alpha.4", "description": "ZenStack plugin development SDK", "main": "index.js", "scripts": { diff --git a/packages/server/package.json b/packages/server/package.json index 59c01026a..40b660ef5 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/server", - "version": "2.0.0-alpha.3", + "version": "2.0.0-alpha.4", "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 b4741bb63..35b5078cc 100644 --- a/packages/testtools/package.json +++ b/packages/testtools/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/testtools", - "version": "2.0.0-alpha.3", + "version": "2.0.0-alpha.4", "description": "ZenStack Test Tools", "main": "index.js", "private": true,