diff --git a/docs/faq.md b/docs/faq.md index 504fb69d..db01d75a 100644 --- a/docs/faq.md +++ b/docs/faq.md @@ -64,4 +64,29 @@ No. See [here](./the-complete-guide/part1/4-access-policy/4.1-model-level.md#eva ### Is Prisma's new "prisma-client" generator supported? -No. The feature was add in [Prisma 6.6](https://github.com/prisma/prisma/releases/tag/6.6.0) but it's still in early access. We plan to work on it when Prisma pushes it to GA. +Yes, since v2.16.0. The "prisma-client" generator is introduced in [Prisma 6.6](https://github.com/prisma/prisma/releases/tag/6.6.0). When it's used, Prisma requires you to specify an output folder explicitly, and will generate TypeScript source files (instead of compiled JavaScript files) into the folder. The files should be compiled with your source tree, and you should import `PrismaClient` from that folder instead of `@prisma/client`. + +Similarly, you'll need to use the "--output" option when running `zenstack generate` to generate ZenStack files into your source tree and get them compiled together with your source code. And you should import the `enhance` function from there. + +ZModel: +```zmodel +generator client { + provider = "prisma-client" + output = "../generated/prisma/client" + moduleFormat = "cjs" +} +``` + +Running `zenstack generate`: +```bash +npx zenstack generate --output ./generated/zenstack +``` + +App code: +```ts +import { PrismaClient } from './generated/prisma/client'; +import { enhance } from './generated/zenstack/enhance'; + +const prisma = new PrismaClient(); +const db = enhance(prisma, ...); +``` diff --git a/docs/reference/runtime-api.md b/docs/reference/runtime-api.md index 4322b957..10d7cf39 100644 --- a/docs/reference/runtime-api.md +++ b/docs/reference/runtime-api.md @@ -64,6 +64,10 @@ type CustomEncryption = { decrypt: (model: string, field: FieldInfo, cipher: string) => Promise; }; +type ValidationOptions = { + inputOnlyValidationForUpdate?: boolean; +}; + type EnhancementOptions = { kinds?: EnhancementKind[]; logPrismaQuery?: boolean; @@ -72,6 +76,7 @@ type EnhancementOptions = { transactionTimeout?: number; transactionIsolationLevel?: TransactionIsolationLevel; encryption?: SimpleEncryption | CustomEncryption; + validation?: ValidationOptions; }; ``` @@ -84,6 +89,7 @@ type EnhancementOptions = { | transactionTimeout | The `timeout` option (in ms) passed to `prisma.$transaction()` call for transactions initiated by ZenStack. | Database default | | transactionIsolationLevel | The `isolationLevel` option passed to `prisma.$transaction()` call for transactions initiated by ZenStack. | Database default | | encryption | Field encryption settings. Only required when using the [field encryption](../guides/field-encryption.md) feature. | | +| validation.inputOnlyValidationForUpdate | By default, ZenStack validates an entity after "update" operation to ensure the final result satisfies validation rules as a whole. This implies if the record under update doesn't satisfy the rules prior to update, the update operation will fail even if the fields causing validation errors are not affected by the operation. You can set this option to `true` to let ZenStack only validate data contained in the input args. | false | #### Enhancement Kinds