@opensaas/stack-core 0.42.0 → 0.42.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +9 -0
- package/dist/access/types.d.ts +2 -2
- package/dist/access/types.d.ts.map +1 -1
- package/dist/config/types.d.ts +69 -58
- package/dist/config/types.d.ts.map +1 -1
- package/dist/context/index.d.ts +5 -5
- package/dist/context/index.d.ts.map +1 -1
- package/dist/context/index.js.map +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/access/types.ts +6 -2
- package/src/config/types.ts +77 -50
- package/src/context/index.ts +17 -5
- package/src/internal.ts +2 -2
- package/tsconfig.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @opensaas/stack-core
|
|
2
2
|
|
|
3
|
+
## 0.42.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#1268](https://github.com/OpenSaasAU/stack/pull/1268) [`2976f57`](https://github.com/OpenSaasAU/stack/commit/2976f57a0d80687c3a27e11c3b7ec7fa9830cdb7) Thanks [@borisno2](https://github.com/borisno2)! - Fix a hook's `context.db` under-describing rows: `TypeInfo` now carries a `db` member (the generator points it at the generated `CustomDB`), so a hook reading a virtual or transformed field off `context.db.<list>` type-checks instead of failing with `TS2339`.
|
|
8
|
+
Run `opensaas generate` after upgrading to pick up the new member on `Lists.<List>.TypeInfo`.
|
|
9
|
+
|
|
10
|
+
- [#1264](https://github.com/OpenSaasAU/stack/pull/1264) [`2e1ee3d`](https://github.com/OpenSaasAU/stack/commit/2e1ee3de446639f24331c5cebd01aeed37ca3e31) Thanks [@borisno2](https://github.com/borisno2)! - Fix `context.db.<list>.findUnique`/`findFirst`/`findMany` (and singleton `get`) in the generated `CustomDB` silently losing fragment narrowing: passing a `query` fragment compiled but the result stayed typed as the unnarrowed list payload instead of `ResultOf<typeof fragment>`. These methods now carry the same fragment overload as core's `AccessControlledDB`, so an unselected field is a compile error on the result.
|
|
11
|
+
|
|
3
12
|
## 0.42.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
package/dist/access/types.d.ts
CHANGED
|
@@ -189,10 +189,10 @@ export type StorageUtils = {
|
|
|
189
189
|
deleteFile: (providerName: string, filename: string) => Promise<void>;
|
|
190
190
|
deleteImage: (metadata: unknown) => Promise<void>;
|
|
191
191
|
};
|
|
192
|
-
export interface AccessContext<TPrisma extends PrismaClientLike = PrismaClientLike
|
|
192
|
+
export interface AccessContext<TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> {
|
|
193
193
|
session: Session | null;
|
|
194
194
|
prisma: TPrisma;
|
|
195
|
-
db:
|
|
195
|
+
db: TDb;
|
|
196
196
|
storage: StorageUtils;
|
|
197
197
|
plugins: Record<string, unknown>;
|
|
198
198
|
_isSudo: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/access/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAA;AAC3E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AAEpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,WAAW,OAAO;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,UAAU,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/C,SAAS,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;IAC9C,QAAQ,EAAE,CA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MAAM,EAAE,OAAO,CAAC,IACpC,CAAC,IAAI,EAAE,sBAAsB,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC,KAAK,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;AAEnG;;;;;;;;;GASG;AACH,MAAM,MAAM,WAAW,CACrB,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC/B,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtC,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IACpC;IACF,IAAI,CAAC,EAAE,CACL,IAAI,EAAE,OAAO,CAAC,sBAAsB,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC,KAC5F,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;IAC/B,MAAM,CAAC,EAAE,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC,CAAA;IAC9D,MAAM,CAAC,EAAE,kBAAkB,CAAC,KAAK,EAAE,YAAY,EAAE,YAAY,CAAC,CAAA;CAC/D,CAAA"}
|
package/dist/config/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AccessControl, FieldAccess, PrismaClientLike } from '../access/types.js';
|
|
1
|
+
import type { AccessControl, AccessControlledDB, FieldAccess, PrismaClientLike } from '../access/types.js';
|
|
2
2
|
import type { FilterSpec } from '../filter/types.js';
|
|
3
3
|
import type { z } from 'zod';
|
|
4
4
|
export type FieldType = 'text' | 'integer' | 'checkbox' | 'timestamp' | 'password' | 'select' | 'relationship' | string;
|
|
@@ -13,7 +13,7 @@ export type FieldResolveInputHookArgs<TTypeInfo extends TypeInfo, TFieldKey exte
|
|
|
13
13
|
inputData: TTypeInfo['inputs']['create'];
|
|
14
14
|
item: undefined;
|
|
15
15
|
resolvedData: TTypeInfo['inputs']['create'];
|
|
16
|
-
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>;
|
|
16
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
17
17
|
} | {
|
|
18
18
|
listKey: string;
|
|
19
19
|
fieldKey: TFieldKey;
|
|
@@ -21,7 +21,7 @@ export type FieldResolveInputHookArgs<TTypeInfo extends TypeInfo, TFieldKey exte
|
|
|
21
21
|
inputData: TTypeInfo['inputs']['update'];
|
|
22
22
|
item: TTypeInfo['item'];
|
|
23
23
|
resolvedData: TTypeInfo['inputs']['update'];
|
|
24
|
-
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>;
|
|
24
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
25
25
|
};
|
|
26
26
|
/** Arguments for {@link FieldHooks.validate} (and its deprecated `validateInput` alias). */
|
|
27
27
|
export type FieldValidateHookArgs<TTypeInfo extends TypeInfo, TFieldKey extends FieldKeys<TTypeInfo['fields']> = FieldKeys<TTypeInfo['fields']>> = {
|
|
@@ -31,7 +31,7 @@ export type FieldValidateHookArgs<TTypeInfo extends TypeInfo, TFieldKey extends
|
|
|
31
31
|
inputData: TTypeInfo['inputs']['create'];
|
|
32
32
|
item: undefined;
|
|
33
33
|
resolvedData: TTypeInfo['inputs']['create'];
|
|
34
|
-
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>;
|
|
34
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
35
35
|
addValidationError: (msg: string) => void;
|
|
36
36
|
} | {
|
|
37
37
|
listKey: string;
|
|
@@ -40,14 +40,14 @@ export type FieldValidateHookArgs<TTypeInfo extends TypeInfo, TFieldKey extends
|
|
|
40
40
|
inputData: TTypeInfo['inputs']['update'];
|
|
41
41
|
item: TTypeInfo['item'];
|
|
42
42
|
resolvedData: TTypeInfo['inputs']['update'];
|
|
43
|
-
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>;
|
|
43
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
44
44
|
addValidationError: (msg: string) => void;
|
|
45
45
|
} | {
|
|
46
46
|
listKey: string;
|
|
47
47
|
fieldKey: TFieldKey;
|
|
48
48
|
operation: 'delete';
|
|
49
49
|
item: TTypeInfo['item'];
|
|
50
|
-
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>;
|
|
50
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
51
51
|
addValidationError: (msg: string) => void;
|
|
52
52
|
};
|
|
53
53
|
/** Arguments for {@link FieldHooks.beforeOperation}. */
|
|
@@ -57,7 +57,7 @@ export type FieldBeforeOperationHookArgs<TTypeInfo extends TypeInfo, TFieldKey e
|
|
|
57
57
|
operation: 'create';
|
|
58
58
|
inputData: TTypeInfo['inputs']['create'];
|
|
59
59
|
resolvedData: TTypeInfo['inputs']['create'];
|
|
60
|
-
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>;
|
|
60
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
61
61
|
} | {
|
|
62
62
|
listKey: string;
|
|
63
63
|
fieldKey: TFieldKey;
|
|
@@ -65,13 +65,13 @@ export type FieldBeforeOperationHookArgs<TTypeInfo extends TypeInfo, TFieldKey e
|
|
|
65
65
|
inputData: TTypeInfo['inputs']['update'];
|
|
66
66
|
item: TTypeInfo['item'];
|
|
67
67
|
resolvedData: TTypeInfo['inputs']['update'];
|
|
68
|
-
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>;
|
|
68
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
69
69
|
} | {
|
|
70
70
|
listKey: string;
|
|
71
71
|
fieldKey: TFieldKey;
|
|
72
72
|
operation: 'delete';
|
|
73
73
|
item: TTypeInfo['item'];
|
|
74
|
-
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>;
|
|
74
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
75
75
|
};
|
|
76
76
|
/** Arguments for {@link FieldHooks.afterOperation}. */
|
|
77
77
|
export type FieldAfterOperationHookArgs<TTypeInfo extends TypeInfo, TFieldKey extends FieldKeys<TTypeInfo['fields']> = FieldKeys<TTypeInfo['fields']>> = {
|
|
@@ -81,7 +81,7 @@ export type FieldAfterOperationHookArgs<TTypeInfo extends TypeInfo, TFieldKey ex
|
|
|
81
81
|
inputData: TTypeInfo['inputs']['create'];
|
|
82
82
|
item: TTypeInfo['item'];
|
|
83
83
|
resolvedData: TTypeInfo['inputs']['create'];
|
|
84
|
-
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>;
|
|
84
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
85
85
|
} | {
|
|
86
86
|
listKey: string;
|
|
87
87
|
fieldKey: TFieldKey;
|
|
@@ -90,13 +90,13 @@ export type FieldAfterOperationHookArgs<TTypeInfo extends TypeInfo, TFieldKey ex
|
|
|
90
90
|
originalItem: TTypeInfo['item'];
|
|
91
91
|
item: TTypeInfo['item'];
|
|
92
92
|
resolvedData: TTypeInfo['inputs']['update'];
|
|
93
|
-
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>;
|
|
93
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
94
94
|
} | {
|
|
95
95
|
listKey: string;
|
|
96
96
|
fieldKey: TFieldKey;
|
|
97
97
|
operation: 'delete';
|
|
98
98
|
originalItem: TTypeInfo['item'];
|
|
99
|
-
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>;
|
|
99
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
100
100
|
};
|
|
101
101
|
/**
|
|
102
102
|
* Arguments for field-level beforeTransaction hook (#590 / ADR-0010).
|
|
@@ -115,20 +115,20 @@ export type FieldBeforeTransactionHookArgs<TTypeInfo extends TypeInfo, TFieldKey
|
|
|
115
115
|
fieldKey: TFieldKey;
|
|
116
116
|
operation: 'create';
|
|
117
117
|
inputData: TTypeInfo['inputs']['create'];
|
|
118
|
-
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>;
|
|
118
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
119
119
|
} | {
|
|
120
120
|
listKey: string;
|
|
121
121
|
fieldKey: TFieldKey;
|
|
122
122
|
operation: 'update';
|
|
123
123
|
inputData: TTypeInfo['inputs']['update'];
|
|
124
124
|
item: TTypeInfo['item'] | undefined;
|
|
125
|
-
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>;
|
|
125
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
126
126
|
} | {
|
|
127
127
|
listKey: string;
|
|
128
128
|
fieldKey: TFieldKey;
|
|
129
129
|
operation: 'delete';
|
|
130
130
|
item: TTypeInfo['item'] | undefined;
|
|
131
|
-
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>;
|
|
131
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
132
132
|
};
|
|
133
133
|
/**
|
|
134
134
|
* Arguments for field-level afterTransaction hook (#590 / ADR-0010).
|
|
@@ -154,7 +154,7 @@ export type FieldAfterTransactionHookArgs<TTypeInfo extends TypeInfo, TFieldKey
|
|
|
154
154
|
inputData: TTypeInfo['inputs']['create'];
|
|
155
155
|
/** Persisted row — populated for the top-level list only; `undefined` for nested lists. */
|
|
156
156
|
item: TTypeInfo['item'] | undefined;
|
|
157
|
-
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>;
|
|
157
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
158
158
|
} | {
|
|
159
159
|
listKey: string;
|
|
160
160
|
fieldKey: TFieldKey;
|
|
@@ -162,7 +162,7 @@ export type FieldAfterTransactionHookArgs<TTypeInfo extends TypeInfo, TFieldKey
|
|
|
162
162
|
status: 'rolled-back';
|
|
163
163
|
inputData: TTypeInfo['inputs']['create'];
|
|
164
164
|
error: unknown;
|
|
165
|
-
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>;
|
|
165
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
166
166
|
} | {
|
|
167
167
|
listKey: string;
|
|
168
168
|
fieldKey: TFieldKey;
|
|
@@ -173,7 +173,7 @@ export type FieldAfterTransactionHookArgs<TTypeInfo extends TypeInfo, TFieldKey
|
|
|
173
173
|
originalItem: TTypeInfo['item'] | undefined;
|
|
174
174
|
/** Persisted row — populated for the top-level list only; `undefined` for nested lists. */
|
|
175
175
|
item: TTypeInfo['item'] | undefined;
|
|
176
|
-
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>;
|
|
176
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
177
177
|
} | {
|
|
178
178
|
listKey: string;
|
|
179
179
|
fieldKey: TFieldKey;
|
|
@@ -182,7 +182,7 @@ export type FieldAfterTransactionHookArgs<TTypeInfo extends TypeInfo, TFieldKey
|
|
|
182
182
|
inputData: TTypeInfo['inputs']['update'];
|
|
183
183
|
originalItem: TTypeInfo['item'] | undefined;
|
|
184
184
|
error: unknown;
|
|
185
|
-
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>;
|
|
185
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
186
186
|
} | {
|
|
187
187
|
listKey: string;
|
|
188
188
|
fieldKey: TFieldKey;
|
|
@@ -190,7 +190,7 @@ export type FieldAfterTransactionHookArgs<TTypeInfo extends TypeInfo, TFieldKey
|
|
|
190
190
|
status: 'committed';
|
|
191
191
|
/** Pre-write row — populated for the top-level list only; `undefined` for nested lists. */
|
|
192
192
|
originalItem: TTypeInfo['item'] | undefined;
|
|
193
|
-
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>;
|
|
193
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
194
194
|
} | {
|
|
195
195
|
listKey: string;
|
|
196
196
|
fieldKey: TFieldKey;
|
|
@@ -198,7 +198,7 @@ export type FieldAfterTransactionHookArgs<TTypeInfo extends TypeInfo, TFieldKey
|
|
|
198
198
|
status: 'rolled-back';
|
|
199
199
|
originalItem: TTypeInfo['item'] | undefined;
|
|
200
200
|
error: unknown;
|
|
201
|
-
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>;
|
|
201
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
202
202
|
};
|
|
203
203
|
/** Arguments for {@link FieldHooks.resolveOutput}. */
|
|
204
204
|
export type FieldResolveOutputHookArgs<TTypeInfo extends TypeInfo, TFieldKey extends FieldKeys<TTypeInfo['fields']> = FieldKeys<TTypeInfo['fields']>> = {
|
|
@@ -207,7 +207,7 @@ export type FieldResolveOutputHookArgs<TTypeInfo extends TypeInfo, TFieldKey ext
|
|
|
207
207
|
item: TTypeInfo['item'];
|
|
208
208
|
listKey: string;
|
|
209
209
|
fieldName: TFieldKey;
|
|
210
|
-
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>;
|
|
210
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
211
211
|
};
|
|
212
212
|
/**
|
|
213
213
|
* Field-level hooks for data transformation and side effects
|
|
@@ -1360,6 +1360,10 @@ TFieldKey extends FieldKeys<TFields>> = ExtractFieldValueType<GetFieldConfig<TFi
|
|
|
1360
1360
|
* @template TItem - The output type (Prisma model type)
|
|
1361
1361
|
* @template TCreateInput - The Prisma create input type
|
|
1362
1362
|
* @template TUpdateInput - The Prisma update input type
|
|
1363
|
+
* @template TDb - The app's own generated `db` surface (the CLI's `CustomDB`),
|
|
1364
|
+
* with virtual and transformed fields folded into every list's payload.
|
|
1365
|
+
* Defaults to `AccessControlledDB<TPrisma>` — the plain Prisma-shaped view —
|
|
1366
|
+
* so a `TypeInfo` written (or defaulted) without it keeps today's behaviour.
|
|
1363
1367
|
*
|
|
1364
1368
|
* @example
|
|
1365
1369
|
* ```typescript
|
|
@@ -1372,11 +1376,12 @@ TFieldKey extends FieldKeys<TFields>> = ExtractFieldValueType<GetFieldConfig<TFi
|
|
|
1372
1376
|
* update: Prisma.PostUpdateInput
|
|
1373
1377
|
* }
|
|
1374
1378
|
* prisma: PrismaClient
|
|
1379
|
+
* db: CustomDB
|
|
1375
1380
|
* }
|
|
1376
1381
|
* ```
|
|
1377
1382
|
*/
|
|
1378
1383
|
export interface TypeInfo<TKey extends string = string, TFields extends Record<string, any> = Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any -- TypeInfo must accept any field record
|
|
1379
|
-
TPrisma extends PrismaClientLike = PrismaClientLike
|
|
1384
|
+
TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> {
|
|
1380
1385
|
key: TKey;
|
|
1381
1386
|
fields: TFields;
|
|
1382
1387
|
item: any;
|
|
@@ -1390,6 +1395,12 @@ TPrisma extends PrismaClientLike = PrismaClientLike> {
|
|
|
1390
1395
|
* resolving through the unparameterised {@link PrismaClientLike} default.
|
|
1391
1396
|
*/
|
|
1392
1397
|
prisma: TPrisma;
|
|
1398
|
+
/**
|
|
1399
|
+
* The app's own generated `db` surface (see {@link TDb}), so a hook's
|
|
1400
|
+
* `context.db` describes the same virtual/transformed-field-augmented rows
|
|
1401
|
+
* the app's own generated `db` surface produces for the same read (#1232).
|
|
1402
|
+
*/
|
|
1403
|
+
db: TDb;
|
|
1393
1404
|
}
|
|
1394
1405
|
export type OperationAccess<T = any> = {
|
|
1395
1406
|
query?: AccessControl<T>;
|
|
@@ -1452,20 +1463,20 @@ export type ListAccessControl<T = any> = AccessControl<T> | {
|
|
|
1452
1463
|
* - create: resolvedData is CreateInput, item is undefined
|
|
1453
1464
|
* - update: resolvedData is UpdateInput, item is the existing record
|
|
1454
1465
|
*/
|
|
1455
|
-
export type ResolveInputHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike
|
|
1466
|
+
export type ResolveInputHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> = {
|
|
1456
1467
|
listKey: string;
|
|
1457
1468
|
operation: 'create';
|
|
1458
1469
|
inputData: TCreateInput;
|
|
1459
1470
|
resolvedData: TCreateInput;
|
|
1460
1471
|
item: undefined;
|
|
1461
|
-
context: import('../context/index.js').StackContext<TPrisma>;
|
|
1472
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1462
1473
|
} | {
|
|
1463
1474
|
listKey: string;
|
|
1464
1475
|
operation: 'update';
|
|
1465
1476
|
inputData: TUpdateInput;
|
|
1466
1477
|
resolvedData: TUpdateInput;
|
|
1467
1478
|
item: TOutput;
|
|
1468
|
-
context: import('../context/index.js').StackContext<TPrisma>;
|
|
1479
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1469
1480
|
};
|
|
1470
1481
|
/**
|
|
1471
1482
|
* Hook arguments for the list-level `validate` hook (renamed from `validateInput` for Keystone compatibility).
|
|
@@ -1473,13 +1484,13 @@ export type ResolveInputHookArgs<TOutput = Record<string, unknown>, TCreateInput
|
|
|
1473
1484
|
* - update: resolvedData is UpdateInput, item is the existing record
|
|
1474
1485
|
* - delete: item is the item being deleted
|
|
1475
1486
|
*/
|
|
1476
|
-
export type ValidateHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike
|
|
1487
|
+
export type ValidateHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> = {
|
|
1477
1488
|
listKey: string;
|
|
1478
1489
|
operation: 'create';
|
|
1479
1490
|
inputData: TCreateInput;
|
|
1480
1491
|
resolvedData: TCreateInput;
|
|
1481
1492
|
item: undefined;
|
|
1482
|
-
context: import('../context/index.js').StackContext<TPrisma>;
|
|
1493
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1483
1494
|
addValidationError: (msg: string) => void;
|
|
1484
1495
|
} | {
|
|
1485
1496
|
listKey: string;
|
|
@@ -1487,13 +1498,13 @@ export type ValidateHookArgs<TOutput = Record<string, unknown>, TCreateInput = R
|
|
|
1487
1498
|
inputData: TUpdateInput;
|
|
1488
1499
|
resolvedData: TUpdateInput;
|
|
1489
1500
|
item: TOutput;
|
|
1490
|
-
context: import('../context/index.js').StackContext<TPrisma>;
|
|
1501
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1491
1502
|
addValidationError: (msg: string) => void;
|
|
1492
1503
|
} | {
|
|
1493
1504
|
listKey: string;
|
|
1494
1505
|
operation: 'delete';
|
|
1495
1506
|
item: TOutput;
|
|
1496
|
-
context: import('../context/index.js').StackContext<TPrisma>;
|
|
1507
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1497
1508
|
addValidationError: (msg: string) => void;
|
|
1498
1509
|
};
|
|
1499
1510
|
/**
|
|
@@ -1502,24 +1513,24 @@ export type ValidateHookArgs<TOutput = Record<string, unknown>, TCreateInput = R
|
|
|
1502
1513
|
* - update: has inputData, resolvedData, and item
|
|
1503
1514
|
* - delete: has item only
|
|
1504
1515
|
*/
|
|
1505
|
-
export type BeforeOperationHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike
|
|
1516
|
+
export type BeforeOperationHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> = {
|
|
1506
1517
|
listKey: string;
|
|
1507
1518
|
operation: 'create';
|
|
1508
1519
|
inputData: TCreateInput;
|
|
1509
1520
|
resolvedData: TCreateInput;
|
|
1510
|
-
context: import('../context/index.js').StackContext<TPrisma>;
|
|
1521
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1511
1522
|
} | {
|
|
1512
1523
|
listKey: string;
|
|
1513
1524
|
operation: 'update';
|
|
1514
1525
|
inputData: TUpdateInput;
|
|
1515
1526
|
item: TOutput;
|
|
1516
1527
|
resolvedData: TUpdateInput;
|
|
1517
|
-
context: import('../context/index.js').StackContext<TPrisma>;
|
|
1528
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1518
1529
|
} | {
|
|
1519
1530
|
listKey: string;
|
|
1520
1531
|
operation: 'delete';
|
|
1521
1532
|
item: TOutput;
|
|
1522
|
-
context: import('../context/index.js').StackContext<TPrisma>;
|
|
1533
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1523
1534
|
};
|
|
1524
1535
|
/**
|
|
1525
1536
|
* Hook arguments for the list-level `afterOperation` hook.
|
|
@@ -1527,13 +1538,13 @@ export type BeforeOperationHookArgs<TOutput = Record<string, unknown>, TCreateIn
|
|
|
1527
1538
|
* - update: has item, originalItem, inputData, and resolvedData
|
|
1528
1539
|
* - delete: has originalItem only
|
|
1529
1540
|
*/
|
|
1530
|
-
export type AfterOperationHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike
|
|
1541
|
+
export type AfterOperationHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> = {
|
|
1531
1542
|
listKey: string;
|
|
1532
1543
|
operation: 'create';
|
|
1533
1544
|
inputData: TCreateInput;
|
|
1534
1545
|
item: TOutput;
|
|
1535
1546
|
resolvedData: TCreateInput;
|
|
1536
|
-
context: import('../context/index.js').StackContext<TPrisma>;
|
|
1547
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1537
1548
|
} | {
|
|
1538
1549
|
listKey: string;
|
|
1539
1550
|
operation: 'update';
|
|
@@ -1541,12 +1552,12 @@ export type AfterOperationHookArgs<TOutput = Record<string, unknown>, TCreateInp
|
|
|
1541
1552
|
originalItem: TOutput;
|
|
1542
1553
|
item: TOutput;
|
|
1543
1554
|
resolvedData: TUpdateInput;
|
|
1544
|
-
context: import('../context/index.js').StackContext<TPrisma>;
|
|
1555
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1545
1556
|
} | {
|
|
1546
1557
|
listKey: string;
|
|
1547
1558
|
operation: 'delete';
|
|
1548
1559
|
originalItem: TOutput;
|
|
1549
|
-
context: import('../context/index.js').StackContext<TPrisma>;
|
|
1560
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1550
1561
|
};
|
|
1551
1562
|
/**
|
|
1552
1563
|
* Hook arguments for the list-level beforeTransaction hook (#590 / ADR-0010).
|
|
@@ -1557,22 +1568,22 @@ export type AfterOperationHookArgs<TOutput = Record<string, unknown>, TCreateInp
|
|
|
1557
1568
|
* `undefined` for nested targets. For non-transactional side effects whose
|
|
1558
1569
|
* compensation pairs with `afterTransaction`.
|
|
1559
1570
|
*/
|
|
1560
|
-
export type BeforeTransactionHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike
|
|
1571
|
+
export type BeforeTransactionHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> = {
|
|
1561
1572
|
listKey: string;
|
|
1562
1573
|
operation: 'create';
|
|
1563
1574
|
inputData: TCreateInput;
|
|
1564
|
-
context: import('../access/types.js').AccessContext<TPrisma>;
|
|
1575
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1565
1576
|
} | {
|
|
1566
1577
|
listKey: string;
|
|
1567
1578
|
operation: 'update';
|
|
1568
1579
|
inputData: TUpdateInput;
|
|
1569
1580
|
item: TOutput | undefined;
|
|
1570
|
-
context: import('../access/types.js').AccessContext<TPrisma>;
|
|
1581
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1571
1582
|
} | {
|
|
1572
1583
|
listKey: string;
|
|
1573
1584
|
operation: 'delete';
|
|
1574
1585
|
item: TOutput | undefined;
|
|
1575
|
-
context: import('../access/types.js').AccessContext<TPrisma>;
|
|
1586
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1576
1587
|
};
|
|
1577
1588
|
/**
|
|
1578
1589
|
* Hook arguments for the list-level afterTransaction hook (#590 / ADR-0010).
|
|
@@ -1592,21 +1603,21 @@ export type BeforeTransactionHookArgs<TOutput = Record<string, unknown>, TCreate
|
|
|
1592
1603
|
* - `rolled-back`: NO persisted `item`; the hook gets `inputData` and the
|
|
1593
1604
|
* `error` that caused the rollback so it can compensate.
|
|
1594
1605
|
*/
|
|
1595
|
-
export type AfterTransactionHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike
|
|
1606
|
+
export type AfterTransactionHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> = {
|
|
1596
1607
|
listKey: string;
|
|
1597
1608
|
operation: 'create';
|
|
1598
1609
|
status: 'committed';
|
|
1599
1610
|
inputData: TCreateInput;
|
|
1600
1611
|
/** Persisted row — populated for the top-level list only; `undefined` for nested lists. */
|
|
1601
1612
|
item: TOutput | undefined;
|
|
1602
|
-
context: import('../access/types.js').AccessContext<TPrisma>;
|
|
1613
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1603
1614
|
} | {
|
|
1604
1615
|
listKey: string;
|
|
1605
1616
|
operation: 'create';
|
|
1606
1617
|
status: 'rolled-back';
|
|
1607
1618
|
inputData: TCreateInput;
|
|
1608
1619
|
error: unknown;
|
|
1609
|
-
context: import('../access/types.js').AccessContext<TPrisma>;
|
|
1620
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1610
1621
|
} | {
|
|
1611
1622
|
listKey: string;
|
|
1612
1623
|
operation: 'update';
|
|
@@ -1616,7 +1627,7 @@ export type AfterTransactionHookArgs<TOutput = Record<string, unknown>, TCreateI
|
|
|
1616
1627
|
originalItem: TOutput | undefined;
|
|
1617
1628
|
/** Persisted row — populated for the top-level list only; `undefined` for nested lists. */
|
|
1618
1629
|
item: TOutput | undefined;
|
|
1619
|
-
context: import('../access/types.js').AccessContext<TPrisma>;
|
|
1630
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1620
1631
|
} | {
|
|
1621
1632
|
listKey: string;
|
|
1622
1633
|
operation: 'update';
|
|
@@ -1624,34 +1635,34 @@ export type AfterTransactionHookArgs<TOutput = Record<string, unknown>, TCreateI
|
|
|
1624
1635
|
inputData: TUpdateInput;
|
|
1625
1636
|
originalItem: TOutput | undefined;
|
|
1626
1637
|
error: unknown;
|
|
1627
|
-
context: import('../access/types.js').AccessContext<TPrisma>;
|
|
1638
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1628
1639
|
} | {
|
|
1629
1640
|
listKey: string;
|
|
1630
1641
|
operation: 'delete';
|
|
1631
1642
|
status: 'committed';
|
|
1632
1643
|
/** Pre-write row — populated for the top-level list only; `undefined` for nested lists. */
|
|
1633
1644
|
originalItem: TOutput | undefined;
|
|
1634
|
-
context: import('../access/types.js').AccessContext<TPrisma>;
|
|
1645
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1635
1646
|
} | {
|
|
1636
1647
|
listKey: string;
|
|
1637
1648
|
operation: 'delete';
|
|
1638
1649
|
status: 'rolled-back';
|
|
1639
1650
|
originalItem: TOutput | undefined;
|
|
1640
1651
|
error: unknown;
|
|
1641
|
-
context: import('../access/types.js').AccessContext<TPrisma>;
|
|
1652
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1642
1653
|
};
|
|
1643
|
-
export type Hooks<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike
|
|
1644
|
-
resolveInput?: (args: ResolveInputHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma>) => Promise<TCreateInput | TUpdateInput>;
|
|
1645
|
-
validate?: (args: ValidateHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma>) => Promise<void>;
|
|
1646
|
-
beforeOperation?: (args: BeforeOperationHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma>) => Promise<void>;
|
|
1647
|
-
afterOperation?: (args: AfterOperationHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma>) => Promise<void>;
|
|
1654
|
+
export type Hooks<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> = {
|
|
1655
|
+
resolveInput?: (args: ResolveInputHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma, TDb>) => Promise<TCreateInput | TUpdateInput>;
|
|
1656
|
+
validate?: (args: ValidateHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma, TDb>) => Promise<void>;
|
|
1657
|
+
beforeOperation?: (args: BeforeOperationHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma, TDb>) => Promise<void>;
|
|
1658
|
+
afterOperation?: (args: AfterOperationHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma, TDb>) => Promise<void>;
|
|
1648
1659
|
/**
|
|
1649
1660
|
* Side effect BEFORE the write's transaction opens (#590 / ADR-0010).
|
|
1650
1661
|
* Runs OUTSIDE the transaction — for non-transactional work (external API
|
|
1651
1662
|
* calls). Throwing aborts the write; the paired `afterTransaction` then fires
|
|
1652
1663
|
* with `status: 'rolled-back'`. See {@link BeforeTransactionHookArgs}.
|
|
1653
1664
|
*/
|
|
1654
|
-
beforeTransaction?: (args: BeforeTransactionHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma>) => Promise<void> | void;
|
|
1665
|
+
beforeTransaction?: (args: BeforeTransactionHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma, TDb>) => Promise<void> | void;
|
|
1655
1666
|
/**
|
|
1656
1667
|
* Side effect AFTER the write's transaction settles (#590 / ADR-0010).
|
|
1657
1668
|
* ALWAYS runs when `beforeTransaction` ran; receives `committed | rolled-back`
|
|
@@ -1660,11 +1671,11 @@ export type Hooks<TOutput = Record<string, unknown>, TCreateInput = Record<strin
|
|
|
1660
1671
|
* compensation half of the transaction-boundary bracket. See
|
|
1661
1672
|
* {@link AfterTransactionHookArgs}.
|
|
1662
1673
|
*/
|
|
1663
|
-
afterTransaction?: (args: AfterTransactionHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma>) => Promise<void> | void;
|
|
1674
|
+
afterTransaction?: (args: AfterTransactionHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma, TDb>) => Promise<void> | void;
|
|
1664
1675
|
/**
|
|
1665
1676
|
* @deprecated Use 'validate' instead. This alias is provided for backwards compatibility.
|
|
1666
1677
|
*/
|
|
1667
|
-
validateInput?: (args: ValidateHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma>) => Promise<void>;
|
|
1678
|
+
validateInput?: (args: ValidateHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma, TDb>) => Promise<void>;
|
|
1668
1679
|
};
|
|
1669
1680
|
/**
|
|
1670
1681
|
* A single field reference within a model-level {@link ListIndex}. Either
|
|
@@ -1719,7 +1730,7 @@ export type ListConfig<TTypeInfo extends TypeInfo> = {
|
|
|
1719
1730
|
access?: {
|
|
1720
1731
|
operation?: OperationAccess<TTypeInfo['item']>;
|
|
1721
1732
|
};
|
|
1722
|
-
hooks?: Hooks<TTypeInfo['item'], TTypeInfo['inputs']['create'], TTypeInfo['inputs']['update'], TTypeInfo['prisma']>;
|
|
1733
|
+
hooks?: Hooks<TTypeInfo['item'], TTypeInfo['inputs']['create'], TTypeInfo['inputs']['update'], TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
1723
1734
|
/**
|
|
1724
1735
|
* Database configuration for this list (model level)
|
|
1725
1736
|
*/
|