You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: versioned_docs/version-3.x/reference/runtime-api.md
-122Lines changed: 0 additions & 122 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,125 +6,3 @@ sidebar_label: Runtime API
6
6
7
7
# Runtime API Reference
8
8
9
-
This document provides references for runtime APIs exported from the `@zenstackhq/runtime` package.
10
-
11
-
### enhance
12
-
13
-
#### Description
14
-
15
-
Creates an enhanced wrapper for a `PrismaClient`. The return value has the same APIs as the original `PrismaClient`.
16
-
17
-
#### Signature
18
-
19
-
```ts
20
-
function enhance<DbClientextendsobject>(
21
-
prisma:DbClient,
22
-
context?:EnhancementContext,
23
-
options?:EnhancementOptions
24
-
):DbClient;
25
-
```
26
-
27
-
##### Parameter `prisma`
28
-
29
-
The PrismaClient instance to enhance.
30
-
31
-
##### Parameter `context`
32
-
33
-
The context to for evaluating access policies with the following typing.
34
-
35
-
```ts
36
-
typeEnhancementContext= {
37
-
user?:Record<string, unknown>
38
-
};
39
-
```
40
-
41
-
| Field | Description |
42
-
| ----- | ----------- |
43
-
| user | The user object that provides value for the `auth()` function call in access policies. If provided. Its shape should be consistent with the `User` model in your ZModel, with all fields optional except for id field(s). Pass `undefined` to represent an anonymous user, and the `auth()` function call will evaluate to `null` in that case. |
| kinds | The kinds of enhancements to apply. By default all enhancements are applied. See [the next section](#enhancement-kinds) for more details. | All enhancement kinds |
86
-
| logPrismaQuery | Whether to log queries sent to Prisma client. Log will be emitted with "info" level, so please make sure you [turn that level on](https://www.prisma.io/docs/concepts/components/prisma-client/working-with-prismaclient/logging#log-to-stdout) when creating Prisma client | false |
87
-
| errorTransformer | A function for transforming error thrown by the enhanced `PrismaClient` into a custom one. ||
88
-
| transactionMaxWait | The `maxWait` option (in ms) passed to `prisma.$transaction()` call for transactions initiated by ZenStack. | Database default |
89
-
| transactionTimeout | The `timeout` option (in ms) passed to `prisma.$transaction()` call for transactions initiated by ZenStack. | Database default |
90
-
| transactionIsolationLevel | The `isolationLevel` option passed to `prisma.$transaction()` call for transactions initiated by ZenStack. | Database default |
91
-
| encryption | Field encryption settings. Only required when using the [field encryption](../guides/field-encryption.md) feature. ||
92
-
| 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 |
93
-
94
-
#### Enhancement Kinds
95
-
96
-
Here are the kinds of enhancements available:
97
-
98
-
-`policy`
99
-
100
-
Enforces model-level and field-level access policies defined with `@@allow`, `@@deny`, `@allow`, and `@deny`.
101
-
102
-
-`validation`
103
-
104
-
Validates create and update input data against rules defined with [data validation attributes](../reference/zmodel-language#data-validation).
105
-
106
-
-`delegate`
107
-
108
-
Support for modeling [polymorphic relations](../guides/polymorphism) with delegated types pattern.
109
-
110
-
-`password`
111
-
112
-
Automatically hashes fields marked with the `@password` attribute using `bcryptjs` before saving to the database.
113
-
114
-
-`omit`
115
-
116
-
Automatically omits fields marked with the `@omit` attribute from read results.
117
-
118
-
-`encryption`
119
-
120
-
Transparently encrypt and decrypt fields marked with the `@encrypted` attribute. See [this guide](../guides/field-encryption.md) for more details.
0 commit comments