From 1be5d525c41bac0ecba3dffe0c7bbd9984031592 Mon Sep 17 00:00:00 2001 From: Yiming Date: Thu, 25 Apr 2024 08:55:31 +0800 Subject: [PATCH 1/7] chore: support for Prisma 5.13 (#1374) --- .../tests/projects/t3-trpc-v10/package.json | 4 +- packages/runtime/package.json | 2 +- packages/schema/package.json | 6 +- pnpm-lock.yaml | 76 ++++++++++++------- tests/integration/test-run/package.json | 4 +- .../nextjs/test-project/package.json | 4 +- .../frameworks/trpc/test-project/package.json | 4 +- 7 files changed, 59 insertions(+), 41 deletions(-) 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 6098ca96b..355df648c 100644 --- a/packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json +++ b/packages/plugins/trpc/tests/projects/t3-trpc-v10/package.json @@ -13,7 +13,7 @@ "start": "next start" }, "dependencies": { - "@prisma/client": "5.12.0", + "@prisma/client": "^5.13.0", "@t3-oss/env-nextjs": "^0.7.1", "@tanstack/react-query": "^4.36.1", "@trpc/client": "^10.43.6", @@ -35,7 +35,7 @@ "@typescript-eslint/parser": "^6.11.0", "eslint": "^8.54.0", "eslint-config-next": "^14.0.4", - "prisma": "5.12.0", + "prisma": "^5.13.0", "typescript": "^5.1.6" }, "ct3aMetadata": { diff --git a/packages/runtime/package.json b/packages/runtime/package.json index e1b436993..941355a43 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -92,7 +92,7 @@ "zod-validation-error": "^1.5.0" }, "peerDependencies": { - "@prisma/client": "5.0.0 - 5.12.x" + "@prisma/client": "5.0.0 - 5.13.x" }, "author": { "name": "ZenStack Team" diff --git a/packages/schema/package.json b/packages/schema/package.json index 62c3fc896..5010dc0bc 100644 --- a/packages/schema/package.json +++ b/packages/schema/package.json @@ -122,10 +122,10 @@ "zod-validation-error": "^1.5.0" }, "peerDependencies": { - "prisma": "5.0.0 - 5.12.x" + "prisma": "5.0.0 - 5.13.x" }, "devDependencies": { - "@prisma/client": "5.12.0", + "@prisma/client": "^5.13.0", "@types/async-exit-hook": "^2.0.0", "@types/pluralize": "^0.0.29", "@types/semver": "^7.3.13", @@ -137,7 +137,7 @@ "@zenstackhq/runtime": "workspace:*", "dotenv": "^16.0.3", "esbuild": "^0.15.12", - "prisma": "5.12.0", + "prisma": "^5.13.0", "renamer": "^4.0.0", "tmp": "^0.2.1", "tsc-alias": "^1.7.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8af4e228d..d08baac14 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -389,8 +389,8 @@ importers: packages/runtime: dependencies: '@prisma/client': - specifier: 5.0.0 - 5.12.x - version: 5.12.0(prisma@5.12.0) + specifier: 5.0.0 - 5.13.x + version: 5.12.0 bcryptjs: specifier: ^2.4.3 version: 2.4.3 @@ -557,8 +557,8 @@ importers: version: 1.5.0(zod@3.22.4) devDependencies: '@prisma/client': - specifier: 5.12.0 - version: 5.12.0(prisma@5.12.0) + specifier: ^5.13.0 + version: 5.13.0(prisma@5.13.0) '@types/async-exit-hook': specifier: ^2.0.0 version: 2.0.0 @@ -593,8 +593,8 @@ importers: specifier: ^0.15.12 version: 0.15.12 prisma: - specifier: 5.12.0 - version: 5.12.0 + specifier: ^5.13.0 + version: 5.13.0 renamer: specifier: ^4.0.0 version: 4.0.0 @@ -3831,17 +3831,29 @@ packages: resolution: {integrity: sha512-a5Sab1C4/icpTZVzZc5Ghpz88yQtGOyNqYXcZgOssB2uuAr+wF/MvN6bgtW32q7HHrvBki+BsZ0OuNv6EV3K9g==} dev: true - /@prisma/client@5.12.0(prisma@5.12.0): + /@prisma/client@5.12.0: resolution: {integrity: sha512-bk/+KPpRm0+IzqFCtAxrj+/TNiHzulspnO+OkysaYY/atc/eX0Gx8V3tTLxbHKVX0LKD4Hi8KKCcSbU1U72n7Q==} engines: {node: '>=16.13'} requiresBuild: true + peerDependencies: + prisma: '*' + peerDependenciesMeta: + prisma: + optional: true + dev: false + + /@prisma/client@5.13.0(prisma@5.13.0): + resolution: {integrity: sha512-uYdfpPncbZ/syJyiYBwGZS8Gt1PTNoErNYMuqHDa2r30rNSFtgTA/LXsSk55R7pdRTMi5pHkeP9B14K6nHmwkg==} + engines: {node: '>=16.13'} + requiresBuild: true peerDependencies: prisma: '*' peerDependenciesMeta: prisma: optional: true dependencies: - prisma: 5.12.0 + prisma: 5.13.0 + dev: true /@prisma/client@5.7.0: resolution: {integrity: sha512-cZmglCrfNbYpzUtz7HscVHl38e9CrUs31nrVoGUK1nIPXGgt8hT4jj2s657UXcNdQ/jBUxDgGmHyu2Nyrq1txg==} @@ -3854,28 +3866,31 @@ packages: optional: true dev: true - /@prisma/debug@5.12.0: - resolution: {integrity: sha512-wK3fQLxPLMqf5riT5ZIhl8NffPSzFUwtzFX5CH7z/oI9Swmo9UhQlUgZABIVgdXSJ5OAlmRcDZtDKaMApIl8sg==} + /@prisma/debug@5.13.0: + resolution: {integrity: sha512-699iqlEvzyCj9ETrXhs8o8wQc/eVW+FigSsHpiskSFydhjVuwTJEfj/nIYqTaWFYuxiWQRfm3r01meuW97SZaQ==} + dev: true /@prisma/debug@5.7.0: resolution: {integrity: sha512-tZ+MOjWlVvz1kOEhNYMa4QUGURY+kgOUBqLHYIV8jmCsMuvA1tWcn7qtIMLzYWCbDcQT4ZS8xDgK0R2gl6/0wA==} dev: false - /@prisma/engines-version@5.12.0-21.473ed3124229e22d881cb7addf559799debae1ab: - resolution: {integrity: sha512-6yvO8s80Tym61aB4QNtYZfWVmE3pwqe807jEtzm8C5VDe7nw8O1FGX3TXUaXmWV0fQTIAfRbeL2Gwrndabp/0g==} + /@prisma/engines-version@5.13.0-23.b9a39a7ee606c28e3455d0fd60e78c3ba82b1a2b: + resolution: {integrity: sha512-AyUuhahTINGn8auyqYdmxsN+qn0mw3eg+uhkp8zwknXYIqoT3bChG4RqNY/nfDkPvzWAPBa9mrDyBeOnWSgO6A==} + dev: true /@prisma/engines-version@5.7.0-41.79fb5193cf0a8fdbef536e4b4a159cad677ab1b9: resolution: {integrity: sha512-V6tgRVi62jRwTm0Hglky3Scwjr/AKFBFtS+MdbsBr7UOuiu1TKLPc6xfPiyEN1+bYqjEtjxwGsHgahcJsd1rNg==} dev: false - /@prisma/engines@5.12.0: - resolution: {integrity: sha512-rFNRul9JGu0d3tf8etBgmDQ4NVoDwgGrRguvQOc8i+c6g7xPjRuu4aKzMMvHWUuccvRx5+fs1KMBxQ0x2THt+Q==} + /@prisma/engines@5.13.0: + resolution: {integrity: sha512-hIFLm4H1boj6CBZx55P4xKby9jgDTeDG0Jj3iXtwaaHmlD5JmiDkZhh8+DYWkTGchu+rRF36AVROLnk0oaqhHw==} requiresBuild: true dependencies: - '@prisma/debug': 5.12.0 - '@prisma/engines-version': 5.12.0-21.473ed3124229e22d881cb7addf559799debae1ab - '@prisma/fetch-engine': 5.12.0 - '@prisma/get-platform': 5.12.0 + '@prisma/debug': 5.13.0 + '@prisma/engines-version': 5.13.0-23.b9a39a7ee606c28e3455d0fd60e78c3ba82b1a2b + '@prisma/fetch-engine': 5.13.0 + '@prisma/get-platform': 5.13.0 + dev: true /@prisma/engines@5.7.0: resolution: {integrity: sha512-TkOMgMm60n5YgEKPn9erIvFX2/QuWnl3GBo6yTRyZKk5O5KQertXiNnrYgSLy0SpsKmhovEPQb+D4l0SzyE7XA==} @@ -3887,12 +3902,13 @@ packages: '@prisma/get-platform': 5.7.0 dev: false - /@prisma/fetch-engine@5.12.0: - resolution: {integrity: sha512-qkHQbZ1hspvOwcImvqY4yj7+FUlw0+uP+6tu3g24V4ULHOXLLkvr5ZZc6vy26OF0hkbD3kcDJCeutFis3poKgg==} + /@prisma/fetch-engine@5.13.0: + resolution: {integrity: sha512-Yh4W+t6YKyqgcSEB3odBXt7QyVSm0OQlBSldQF2SNXtmOgMX8D7PF/fvH6E6qBCpjB/yeJLy/FfwfFijoHI6sA==} dependencies: - '@prisma/debug': 5.12.0 - '@prisma/engines-version': 5.12.0-21.473ed3124229e22d881cb7addf559799debae1ab - '@prisma/get-platform': 5.12.0 + '@prisma/debug': 5.13.0 + '@prisma/engines-version': 5.13.0-23.b9a39a7ee606c28e3455d0fd60e78c3ba82b1a2b + '@prisma/get-platform': 5.13.0 + dev: true /@prisma/fetch-engine@5.7.0: resolution: {integrity: sha512-zIn/qmO+N/3FYe7/L9o+yZseIU8ivh4NdPKSkQRIHfg2QVTVMnbhGoTcecbxfVubeTp+DjcbjS0H9fCuM4W04w==} @@ -3908,10 +3924,11 @@ packages: '@prisma/debug': 5.7.0 dev: false - /@prisma/get-platform@5.12.0: - resolution: {integrity: sha512-81Ptv9YJnwTArEBPQ2Lvu58sZPxy4OixKxVVgysFan6A3bFP7q8gIg15WTjsRuH4WXh6B667EM9sqoMTNu0fLQ==} + /@prisma/get-platform@5.13.0: + resolution: {integrity: sha512-B/WrQwYTzwr7qCLifQzYOmQhZcFmIFhR81xC45gweInSUn2hTEbfKUPd2keAog+y5WI5xLAFNJ3wkXplvSVkSw==} dependencies: - '@prisma/debug': 5.12.0 + '@prisma/debug': 5.13.0 + dev: true /@prisma/get-platform@5.7.0: resolution: {integrity: sha512-ZeV/Op4bZsWXuw5Tg05WwRI8BlKiRFhsixPcAM+5BKYSiUZiMKIi713tfT3drBq8+T0E1arNZgYSA9QYcglWNA==} @@ -12489,13 +12506,14 @@ packages: hasBin: true dev: true - /prisma@5.12.0: - resolution: {integrity: sha512-zxw4WSIvpsyNbpv8r7Fxgm7nwTFVmD6wbN6VuH13lClOceSANDOMl4jO3oxE6VzhjxmnEJqOGZjON2T2UpmLag==} + /prisma@5.13.0: + resolution: {integrity: sha512-kGtcJaElNRAdAGsCNykFSZ7dBKpL14Cbs+VaQ8cECxQlRPDjBlMHNFYeYt0SKovAVy2Y65JXQwB3A5+zIQwnTg==} engines: {node: '>=16.13'} hasBin: true requiresBuild: true dependencies: - '@prisma/engines': 5.12.0 + '@prisma/engines': 5.13.0 + dev: true /process-nextick-args@2.0.1: resolution: {integrity: sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag==} diff --git a/tests/integration/test-run/package.json b/tests/integration/test-run/package.json index 2a4fedfb4..fc262c950 100644 --- a/tests/integration/test-run/package.json +++ b/tests/integration/test-run/package.json @@ -10,9 +10,9 @@ "author": "", "license": "ISC", "dependencies": { - "@prisma/client": "5.12.0", + "@prisma/client": "^5.13.0", "@zenstackhq/runtime": "file:../../../packages/runtime/dist", - "prisma": "5.12.0", + "prisma": "^5.13.0", "react": "^18.2.0", "swr": "^1.3.0", "typescript": "^4.9.3", diff --git a/tests/integration/tests/frameworks/nextjs/test-project/package.json b/tests/integration/tests/frameworks/nextjs/test-project/package.json index 96500688a..2508743a6 100644 --- a/tests/integration/tests/frameworks/nextjs/test-project/package.json +++ b/tests/integration/tests/frameworks/nextjs/test-project/package.json @@ -9,7 +9,7 @@ "lint": "next lint" }, "dependencies": { - "@prisma/client": "5.12.0", + "@prisma/client": "^5.13.0", "@types/node": "18.11.18", "@types/react": "18.0.27", "@types/react-dom": "18.0.10", @@ -22,6 +22,6 @@ "zod": "^3.22.4" }, "devDependencies": { - "prisma": "5.12.0" + "prisma": "^5.13.0" } } diff --git a/tests/integration/tests/frameworks/trpc/test-project/package.json b/tests/integration/tests/frameworks/trpc/test-project/package.json index 428790638..dba55073e 100644 --- a/tests/integration/tests/frameworks/trpc/test-project/package.json +++ b/tests/integration/tests/frameworks/trpc/test-project/package.json @@ -9,7 +9,7 @@ "lint": "next lint" }, "dependencies": { - "@prisma/client": "5.12.0", + "@prisma/client": "^5.13.0", "@tanstack/react-query": "^4.22.4", "@trpc/client": "^10.34.0", "@trpc/next": "^10.34.0", @@ -26,6 +26,6 @@ "zod": "^3.22.4" }, "devDependencies": { - "prisma": "5.12.0" + "prisma": "^5.13.0" } } From da0bbd1637d7e737aa277b2a54fc6ece24a41215 Mon Sep 17 00:00:00 2001 From: Yiming Date: Thu, 25 Apr 2024 09:32:39 +0800 Subject: [PATCH 2/7] chore: bump version (#1375) --- README.md | 3 ++- 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/sdk/package.json | 2 +- packages/server/package.json | 2 +- packages/testtools/package.json | 2 +- 15 files changed, 16 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 1e07a1408..a2160c3a1 100644 --- a/README.md +++ b/README.md @@ -177,8 +177,8 @@ The following diagram gives a high-level architecture overview of ZenStack. - [Custom attributes and functions](https://zenstack.dev/docs/reference/zmodel-language#custom-attributes-and-functions) - [Multi-file schema and model inheritance](https://zenstack.dev/docs/guides/multiple-schema) +- [Polymorphic Relations](https://zenstack.dev/docs/guides/polymorphism) - Strong-typed JSON field (coming soon) -- Polymorphism (future) - 🙋🏻 [Request for an extension](https://discord.gg/Ykhr738dUe) ## Examples @@ -213,6 +213,7 @@ Check out the [Multi-tenant Todo App](https://zenstack-todo.vercel.app/) for a r - [Nuxt V3 + TanStack Query](https://github.com/zenstackhq/docs-tutorial-nuxt) - [SvelteKit](https://github.com/zenstackhq/docs-tutorial-sveltekit) - [Remix](https://github.com/zenstackhq/docs-tutorial-remix) +- [NestJS Backend API](https://github.com/zenstackhq/docs-tutorial-nestjs) - [Express Backend API](https://github.com/zenstackhq/docs-tutorial-express) - [Clerk Integration](https://github.com/zenstackhq/docs-tutorial-clerk) diff --git a/package.json b/package.json index 56cc21263..a6379cc95 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zenstack-monorepo", - "version": "2.0.0", + "version": "2.0.1", "description": "", "scripts": { "build": "pnpm -r build", diff --git a/packages/ide/jetbrains/build.gradle.kts b/packages/ide/jetbrains/build.gradle.kts index 680a35e24..e2814464f 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" +version = "2.0.1" repositories { mavenCentral() diff --git a/packages/ide/jetbrains/package.json b/packages/ide/jetbrains/package.json index 796e92da1..30cc3ab5c 100644 --- a/packages/ide/jetbrains/package.json +++ b/packages/ide/jetbrains/package.json @@ -1,6 +1,6 @@ { "name": "jetbrains", - "version": "2.0.0", + "version": "2.0.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 ca23c5bce..2895cc720 100644 --- a/packages/language/package.json +++ b/packages/language/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/language", - "version": "2.0.0", + "version": "2.0.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 a5119f967..6598da234 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", + "version": "2.0.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 ac6a46553..1a5225d58 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", + "version": "2.0.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 304469748..fcd1ac52f 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", + "version": "2.0.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 fb61ba074..7624ca49f 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", + "version": "2.0.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 ffa0a6e89..98d87e47c 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", + "version": "2.0.1", "description": "ZenStack plugin for tRPC", "main": "index.js", "repository": { diff --git a/packages/runtime/package.json b/packages/runtime/package.json index 941355a43..8f418ab7e 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", + "version": "2.0.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 5010dc0bc..c61261d7b 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", + "version": "2.0.1", "author": { "name": "ZenStack Team" }, diff --git a/packages/sdk/package.json b/packages/sdk/package.json index 82aba8ad5..4dd88be1a 100644 --- a/packages/sdk/package.json +++ b/packages/sdk/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/sdk", - "version": "2.0.0", + "version": "2.0.1", "description": "ZenStack plugin development SDK", "main": "index.js", "scripts": { diff --git a/packages/server/package.json b/packages/server/package.json index 87a709075..dce7c8a08 100644 --- a/packages/server/package.json +++ b/packages/server/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/server", - "version": "2.0.0", + "version": "2.0.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 d12aa129f..1d97794b6 100644 --- a/packages/testtools/package.json +++ b/packages/testtools/package.json @@ -1,6 +1,6 @@ { "name": "@zenstackhq/testtools", - "version": "2.0.0", + "version": "2.0.1", "description": "ZenStack Test Tools", "main": "index.js", "private": true, From 5cc8f186409b3b50ede1a5f435ab990f500f4e91 Mon Sep 17 00:00:00 2001 From: Yiming Date: Thu, 25 Apr 2024 14:03:22 +0800 Subject: [PATCH 3/7] fix(vscode): more robustly handle VSCode document URI (#1376) --- packages/schema/src/utils/ast-utils.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/packages/schema/src/utils/ast-utils.ts b/packages/schema/src/utils/ast-utils.ts index 3a255228e..83a5a6a57 100644 --- a/packages/schema/src/utils/ast-utils.ts +++ b/packages/schema/src/utils/ast-utils.ts @@ -181,15 +181,19 @@ function resolveTransitiveImportsInternal( documents: LangiumDocuments, model: Model, initialModel = model, - visited: Set = new Set(), + visited: Set = new Set(), models: Set = new Set() ): Model[] { const doc = getDocument(model); - if (initialModel !== model) { + const initialDoc = getDocument(initialModel); + + if (initialDoc.uri.fsPath.toLowerCase() !== doc.uri.fsPath.toLowerCase()) { models.add(model); } - if (!visited.has(doc.uri)) { - visited.add(doc.uri); + + const normalizedPath = doc.uri.fsPath.toLowerCase(); + if (!visited.has(normalizedPath)) { + visited.add(normalizedPath); for (const imp of model.imports) { const importedModel = resolveImport(documents, imp); if (importedModel) { From f6c6b653c018c5cde0a0a8c38b441c48c200d172 Mon Sep 17 00:00:00 2001 From: Jiasheng Date: Thu, 25 Apr 2024 14:03:51 +0800 Subject: [PATCH 4/7] fix: Auto fix code generate to the wrong place for the imported module (#1377) --- packages/schema/src/language-server/zmodel-code-action.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/schema/src/language-server/zmodel-code-action.ts b/packages/schema/src/language-server/zmodel-code-action.ts index 5b6a6c95a..f71e479ef 100644 --- a/packages/schema/src/language-server/zmodel-code-action.ts +++ b/packages/schema/src/language-server/zmodel-code-action.ts @@ -134,7 +134,7 @@ export class ZModelCodeActionProvider implements CodeActionProvider { // eslint-disable-next-line @typescript-eslint/no-non-null-assertion const endOffset = oppositeModel.$cstNode!.end - 1; - const position = document.textDocument.positionAt(endOffset); + const position = targetDocument.textDocument.positionAt(endOffset); return { title: `Add opposite relation fields on ${oppositeModel.name}`, From 54c4bd5c94de7498cb3f924a5a2ffcd7b79ff9f5 Mon Sep 17 00:00:00 2001 From: Yiming Date: Thu, 25 Apr 2024 19:09:12 +0800 Subject: [PATCH 5/7] chore: update jetbrains changelog (#1380) --- packages/ide/jetbrains/CHANGELOG.md | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/packages/ide/jetbrains/CHANGELOG.md b/packages/ide/jetbrains/CHANGELOG.md index 45dfea211..008c27d6a 100644 --- a/packages/ide/jetbrains/CHANGELOG.md +++ b/packages/ide/jetbrains/CHANGELOG.md @@ -1,26 +1,14 @@ # Changelog -## [2.0.0-alpha.2](https://github.com/zenstackhq/zenstack/compare/v2.0.0-alpha.1...v2.0.0-alpha.2) (2024-02-21) - - -### Miscellaneous Chores - -* release 2.0.0-alpha.2 ([f40d7e3](https://github.com/zenstackhq/zenstack/commit/f40d7e3718d4210137a2e131d28b5491d065b914)) - ## [Unreleased] ### Added -- Added support to complex usage of `@@index` attribute like `@@index([content(ops: raw("gin_trgm_ops"))], type: Gin)`. -### Fixed -- Fixed several ZModel validation issues related to model inheritance. +- ZenStack V2 release! -## 1.7.0 +## 1.11.0 ### Added - -- Added support to complex usage of `@@index` attribute like `@@index([content(ops: raw("gin_trgm_ops"))], type: Gin)`. - +- Added support to complex usage of `@@index` attribute like `@@index([content(ops: raw("gin_trgm_ops"))], type: Gin)`. ### Fixed - -- Fixed several ZModel validation issues related to model inheritance. +- Fixed several ZModel validation issues related to model inheritance. ## 1.7.0 From 08471d5e0932bf696e8b6929c4490f191710060d Mon Sep 17 00:00:00 2001 From: Yiming Date: Thu, 25 Apr 2024 20:54:25 +0800 Subject: [PATCH 6/7] fix: policy compilation error for deeply nested post-update rules (#1382) --- .../routers/generated/routers/Post.router.ts | 23 ------- .../routers/generated/routers/User.router.ts | 23 ------- .../enhancer/policy/expression-writer.ts | 10 ++- .../with-policy/post-update.test.ts | 65 +++++++++++++++++++ tests/regression/tests/issue-1381.test.ts | 61 +++++++++++++++++ 5 files changed, 135 insertions(+), 47 deletions(-) create mode 100644 tests/regression/tests/issue-1381.test.ts diff --git a/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/Post.router.ts b/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/Post.router.ts index 15408f3ef..fbc73cf06 100644 --- a/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/Post.router.ts +++ b/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/Post.router.ts @@ -61,29 +61,6 @@ export interface ClientType; }; - createMany: { - useMutation: ( - opts?: UseTRPCMutationOptions< - Prisma.PostCreateManyArgs, - TRPCClientErrorLike, - Prisma.BatchPayload, - Context - >, - ) => Omit< - UseTRPCMutationResult< - Prisma.BatchPayload, - TRPCClientErrorLike, - Prisma.SelectSubset, - Context - >, - 'mutateAsync' - > & { - mutateAsync: ( - variables: T, - opts?: UseTRPCMutationOptions, Prisma.BatchPayload, Context>, - ) => Promise; - }; - }; create: { useMutation: (opts?: UseTRPCMutationOptions< diff --git a/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/User.router.ts b/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/User.router.ts index cb9c8614b..c4bdb89de 100644 --- a/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/User.router.ts +++ b/packages/plugins/trpc/tests/projects/t3-trpc-v10/src/server/api/routers/generated/routers/User.router.ts @@ -61,29 +61,6 @@ export interface ClientType; }; - createMany: { - useMutation: ( - opts?: UseTRPCMutationOptions< - Prisma.UserCreateManyArgs, - TRPCClientErrorLike, - Prisma.BatchPayload, - Context - >, - ) => Omit< - UseTRPCMutationResult< - Prisma.BatchPayload, - TRPCClientErrorLike, - Prisma.SelectSubset, - Context - >, - 'mutateAsync' - > & { - mutateAsync: ( - variables: T, - opts?: UseTRPCMutationOptions, Prisma.BatchPayload, Context>, - ) => Promise; - }; - }; create: { useMutation: (opts?: UseTRPCMutationOptions< diff --git a/packages/schema/src/plugins/enhancer/policy/expression-writer.ts b/packages/schema/src/plugins/enhancer/policy/expression-writer.ts index 3ce681dad..f301e5b9d 100644 --- a/packages/schema/src/plugins/enhancer/policy/expression-writer.ts +++ b/packages/schema/src/plugins/enhancer/policy/expression-writer.ts @@ -463,7 +463,15 @@ export class ExpressionWriter { } private isFutureMemberAccess(expr: Expression): expr is MemberAccessExpr { - return isMemberAccessExpr(expr) && isFutureExpr(expr.operand); + if (!isMemberAccessExpr(expr)) { + return false; + } + + if (isFutureExpr(expr.operand)) { + return true; + } + + return this.isFutureMemberAccess(expr.operand); } private requireIdFields(dataModel: DataModel) { diff --git a/tests/integration/tests/enhancements/with-policy/post-update.test.ts b/tests/integration/tests/enhancements/with-policy/post-update.test.ts index e2d7e0156..b101356cd 100644 --- a/tests/integration/tests/enhancements/with-policy/post-update.test.ts +++ b/tests/integration/tests/enhancements/with-policy/post-update.test.ts @@ -237,6 +237,71 @@ describe('With Policy: post update', () => { ).toResolveTruthy(); }); + it('collection predicate deep-nested post-update', async () => { + const { prisma, enhance } = await loadSchema( + ` + model M1 { + id String @id @default(uuid()) + value Int + m2 M2? + @@allow('read', true) + @@allow('update', value > 0 && future().m2.m3?[value > 0]) + } + + model M2 { + id String @id @default(uuid()) + m1 M1 @relation(fields: [m1Id], references:[id]) + m1Id String @unique + m3 M3[] + @@allow('all', true) + } + + model M3 { + id String @id @default(uuid()) + value Int + m2 M2 @relation(fields: [m2Id], references:[id]) + m2Id String + + @@allow('all', true) + } + ` + ); + + const db = enhance(); + + await prisma.m1.create({ + data: { + id: '1', + value: 1, + m2: { + create: { id: '1', m3: { create: [{ id: '1', value: 0 }] } }, + }, + }, + }); + + await expect( + db.m1.update({ + where: { id: '1' }, + data: { value: 2 }, + }) + ).toBeRejectedByPolicy(); + + await prisma.m3.create({ + data: { + id: '2', + m2: { connect: { id: '1' } }, + value: 1, + }, + }); + + await expect( + db.m1.update({ + where: { id: '1' }, + data: { value: 2 }, + }) + ).toResolveTruthy(); + }); + it('nested to-many', async () => { const { enhance } = await loadSchema( ` diff --git a/tests/regression/tests/issue-1381.test.ts b/tests/regression/tests/issue-1381.test.ts new file mode 100644 index 000000000..14bf8f4b9 --- /dev/null +++ b/tests/regression/tests/issue-1381.test.ts @@ -0,0 +1,61 @@ +import { loadSchema } from '@zenstackhq/testtools'; + +describe('issue 1381', () => { + it('regression', async () => { + await loadSchema( + ` + enum MemberRole { + owner + admin + } + + enum SpaceType { + contractor + public + private + } + + model User { + id String @id @default(cuid()) + name String? + email String? @unique @lower + password String? @password @omit + memberships Membership[] + } + + model Membership { + userId String + user User @relation(fields: [userId], references: [id], onDelete: Cascade) + spaceId String + space Space @relation(fields: [spaceId], references: [id], onDelete: Cascade) + role MemberRole @deny("update", auth() == user) + @@id([userId, spaceId]) + } + + model Space { + id String @id @default(cuid()) + name String + type SpaceType @default(private) + memberships Membership[] + options Option[] + } + + model Option { + id String @id @default(cuid()) + name String? + spaceId String? + space Space? @relation(fields: [spaceId], references: [id], onDelete: SetNull) + + @@allow("update", + future().space.type in [contractor, public] && + future().space.memberships?[space.type in [contractor, public] && auth() == user && role in [owner, admin]] + ) + } + `, + { + provider: 'postgresql', + pushDb: false, + } + ); + }); +}); From 7a159489ce01320fc568c6cd2e0faeceaec3bd4f Mon Sep 17 00:00:00 2001 From: Yiming Date: Fri, 26 Apr 2024 09:16:05 +0800 Subject: [PATCH 7/7] chore: reduce CI runs (#1385) --- .github/ISSUE_TEMPLATE/bug_report.md | 4 ++-- .github/workflows/build-test.yml | 8 -------- .github/workflows/codeql.yml | 8 -------- .github/workflows/integration-test.yml | 8 -------- .github/workflows/regression-test.yml | 8 -------- 5 files changed, 2 insertions(+), 34 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 04372bc71..9812232d7 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -14,8 +14,8 @@ If applicable, add screenshots to help explain your problem. **Environment (please complete the following information):** -- ZenStack version: [e.g., 1.0.0-alpha.50] -- Prisma version: [e.g., 4.10.0] +- ZenStack version: [e.g., 2.0.0] +- Prisma version: [e.g., 5.7.0] - Database type: [e.g. Postgresql] **Additional context** diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml index 368551623..b55d4b48e 100644 --- a/.github/workflows/build-test.yml +++ b/.github/workflows/build-test.yml @@ -8,19 +8,11 @@ env: DO_NOT_TRACK: '1' on: - merge_group: - push: - branches: - - main - - dev - - release/* - - v2 pull_request: branches: - main - dev - release/* - - v2 permissions: contents: read diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 2452a7ca3..078bc693c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,19 +1,11 @@ name: Security - CodeQL on: - merge_group: - push: - branches: - - main - - dev - - release/* - - v2 pull_request: branches: - main - dev - release/* - - v2 schedule: - cron: '0 0 * * 1' diff --git a/.github/workflows/integration-test.yml b/.github/workflows/integration-test.yml index fb3c0bfb0..c558be567 100644 --- a/.github/workflows/integration-test.yml +++ b/.github/workflows/integration-test.yml @@ -8,19 +8,11 @@ env: DO_NOT_TRACK: '1' on: - merge_group: - push: - branches: - - main - - dev - - release/* - - v2 pull_request: branches: - main - dev - release/* - - v2 permissions: contents: read diff --git a/.github/workflows/regression-test.yml b/.github/workflows/regression-test.yml index 679cc2b4c..7a57920ba 100644 --- a/.github/workflows/regression-test.yml +++ b/.github/workflows/regression-test.yml @@ -8,19 +8,11 @@ env: DO_NOT_TRACK: '1' on: - merge_group: - push: - branches: - - main - - dev - - release/* - - v2 pull_request: branches: - main - dev - release/* - - v2 permissions: contents: read