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
27 changes: 26 additions & 1 deletion docs/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...);
```
6 changes: 6 additions & 0 deletions docs/reference/runtime-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ type CustomEncryption = {
decrypt: (model: string, field: FieldInfo, cipher: string) => Promise<string>;
};

type ValidationOptions = {
inputOnlyValidationForUpdate?: boolean;
};

type EnhancementOptions = {
kinds?: EnhancementKind[];
logPrismaQuery?: boolean;
Expand All @@ -72,6 +76,7 @@ type EnhancementOptions = {
transactionTimeout?: number;
transactionIsolationLevel?: TransactionIsolationLevel;
encryption?: SimpleEncryption | CustomEncryption;
validation?: ValidationOptions;
};
```

Expand All @@ -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

Expand Down