@opensaas/stack-core 0.41.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 +35 -0
- package/dist/access/types.d.ts +2 -2
- package/dist/access/types.d.ts.map +1 -1
- package/dist/config/types.d.ts +81 -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 +103 -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,40 @@
|
|
|
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
|
+
|
|
12
|
+
## 0.42.0
|
|
13
|
+
|
|
14
|
+
### Minor Changes
|
|
15
|
+
|
|
16
|
+
- [#1214](https://github.com/OpenSaasAU/stack/pull/1214) [`11ea14a`](https://github.com/OpenSaasAU/stack/commit/11ea14aee0721f662d8592994e81dbe3cfe22941) Thanks [@borisno2](https://github.com/borisno2)! - Thread the app's Prisma client type through `TypeInfo` into every list/field hook-args type, so a hook's `context` resolves to the consumer's own `StackContext` instead of `StackContext<any>`.
|
|
17
|
+
|
|
18
|
+
Before this change, `TypeInfo` carried no client type, so `context.db` inside any hook resolved through `AccessControlledDB<any>` — a mapped type over `keyof any` that declares no named delegate. A hook's `context` was therefore assignable to nothing app-specific, forcing consumers who wanted to pass it into their own typed functions to write `context as unknown as Context`.
|
|
19
|
+
|
|
20
|
+
`TypeInfo` now has a `prisma` member (defaulted to the existing `PrismaClientLike`, so this is fully additive), and every hook-args type — `ResolveInputHookArgs`, `ValidateHookArgs`, `BeforeOperationHookArgs`, `AfterOperationHookArgs`, `BeforeTransactionHookArgs`/`AfterTransactionHookArgs`, and their field-level equivalents — types `context` off it:
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
// A hook authored the documented way now gets a context keyed to your own
|
|
24
|
+
// generated Prisma client, with no cast needed to use it elsewhere:
|
|
25
|
+
Post: list<Lists.Post.TypeInfo>({
|
|
26
|
+
hooks: {
|
|
27
|
+
validate: async ({ context }) => {
|
|
28
|
+
await myDomainFn({ context }) // ✅ context.db.post etc. are real, typed delegates
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
})
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
The CLI generator emits the new `prisma` member on each list's `Lists.<List>.TypeInfo`, pointing at your project's own generated `PrismaClient` — no config changes required, and a hook authored without `TypeInfo` is unaffected.
|
|
35
|
+
|
|
36
|
+
Because `context.db.<list>` now resolves to a real delegate instead of `any`, a pre-existing type error in a hook that previously compiled silently (e.g. a return value that didn't actually match the list's row type) can now surface as a genuine compile error. `AccessControlledDB`'s catch-all index signature is unchanged by this fix, so a misspelled delegate name (`context.db.typoedListName`) is not yet caught — that's a separate, tracked limitation.
|
|
37
|
+
|
|
3
38
|
## 0.41.0
|
|
4
39
|
|
|
5
40
|
### 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,C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AM,EAAE,OAAO,CAAC,EAC/B,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACtC,YAAY,GAAG,MAAM,CAAC,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 } 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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
@@ -1353,9 +1353,17 @@ TFieldKey extends FieldKeys<TFields>> = ExtractFieldValueType<GetFieldConfig<TFi
|
|
|
1353
1353
|
*
|
|
1354
1354
|
* @template TKey - The list key/name (e.g., 'Post', 'User')
|
|
1355
1355
|
* @template TFields - The fields configuration for the list
|
|
1356
|
+
* @template TPrisma - The consuming app's own Prisma client type. Defaults to
|
|
1357
|
+
* {@link PrismaClientLike} so a `TypeInfo` written (or defaulted) without it
|
|
1358
|
+
* keeps today's behaviour — a hook's `context` resolves to `StackContext`
|
|
1359
|
+
* over an unnamed client, same as before this member existed.
|
|
1356
1360
|
* @template TItem - The output type (Prisma model type)
|
|
1357
1361
|
* @template TCreateInput - The Prisma create input type
|
|
1358
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.
|
|
1359
1367
|
*
|
|
1360
1368
|
* @example
|
|
1361
1369
|
* ```typescript
|
|
@@ -1367,10 +1375,13 @@ TFieldKey extends FieldKeys<TFields>> = ExtractFieldValueType<GetFieldConfig<TFi
|
|
|
1367
1375
|
* create: Prisma.PostCreateInput
|
|
1368
1376
|
* update: Prisma.PostUpdateInput
|
|
1369
1377
|
* }
|
|
1378
|
+
* prisma: PrismaClient
|
|
1379
|
+
* db: CustomDB
|
|
1370
1380
|
* }
|
|
1371
1381
|
* ```
|
|
1372
1382
|
*/
|
|
1373
|
-
export interface TypeInfo<TKey extends string = string, TFields extends Record<string, any> = Record<string, any
|
|
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
|
|
1384
|
+
TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> {
|
|
1374
1385
|
key: TKey;
|
|
1375
1386
|
fields: TFields;
|
|
1376
1387
|
item: any;
|
|
@@ -1378,6 +1389,18 @@ export interface TypeInfo<TKey extends string = string, TFields extends Record<s
|
|
|
1378
1389
|
create: any;
|
|
1379
1390
|
update: any;
|
|
1380
1391
|
};
|
|
1392
|
+
/**
|
|
1393
|
+
* The consuming app's own Prisma client type, so a hook's `context` can be
|
|
1394
|
+
* keyed as `StackContext<TPrisma>`/`AccessContext<TPrisma>` instead of
|
|
1395
|
+
* resolving through the unparameterised {@link PrismaClientLike} default.
|
|
1396
|
+
*/
|
|
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;
|
|
1381
1404
|
}
|
|
1382
1405
|
export type OperationAccess<T = any> = {
|
|
1383
1406
|
query?: AccessControl<T>;
|
|
@@ -1440,20 +1463,20 @@ export type ListAccessControl<T = any> = AccessControl<T> | {
|
|
|
1440
1463
|
* - create: resolvedData is CreateInput, item is undefined
|
|
1441
1464
|
* - update: resolvedData is UpdateInput, item is the existing record
|
|
1442
1465
|
*/
|
|
1443
|
-
export type ResolveInputHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>> = {
|
|
1466
|
+
export type ResolveInputHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> = {
|
|
1444
1467
|
listKey: string;
|
|
1445
1468
|
operation: 'create';
|
|
1446
1469
|
inputData: TCreateInput;
|
|
1447
1470
|
resolvedData: TCreateInput;
|
|
1448
1471
|
item: undefined;
|
|
1449
|
-
context: import('../context/index.js').StackContext
|
|
1472
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1450
1473
|
} | {
|
|
1451
1474
|
listKey: string;
|
|
1452
1475
|
operation: 'update';
|
|
1453
1476
|
inputData: TUpdateInput;
|
|
1454
1477
|
resolvedData: TUpdateInput;
|
|
1455
1478
|
item: TOutput;
|
|
1456
|
-
context: import('../context/index.js').StackContext
|
|
1479
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1457
1480
|
};
|
|
1458
1481
|
/**
|
|
1459
1482
|
* Hook arguments for the list-level `validate` hook (renamed from `validateInput` for Keystone compatibility).
|
|
@@ -1461,13 +1484,13 @@ export type ResolveInputHookArgs<TOutput = Record<string, unknown>, TCreateInput
|
|
|
1461
1484
|
* - update: resolvedData is UpdateInput, item is the existing record
|
|
1462
1485
|
* - delete: item is the item being deleted
|
|
1463
1486
|
*/
|
|
1464
|
-
export type ValidateHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>> = {
|
|
1487
|
+
export type ValidateHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> = {
|
|
1465
1488
|
listKey: string;
|
|
1466
1489
|
operation: 'create';
|
|
1467
1490
|
inputData: TCreateInput;
|
|
1468
1491
|
resolvedData: TCreateInput;
|
|
1469
1492
|
item: undefined;
|
|
1470
|
-
context: import('../context/index.js').StackContext
|
|
1493
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1471
1494
|
addValidationError: (msg: string) => void;
|
|
1472
1495
|
} | {
|
|
1473
1496
|
listKey: string;
|
|
@@ -1475,13 +1498,13 @@ export type ValidateHookArgs<TOutput = Record<string, unknown>, TCreateInput = R
|
|
|
1475
1498
|
inputData: TUpdateInput;
|
|
1476
1499
|
resolvedData: TUpdateInput;
|
|
1477
1500
|
item: TOutput;
|
|
1478
|
-
context: import('../context/index.js').StackContext
|
|
1501
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1479
1502
|
addValidationError: (msg: string) => void;
|
|
1480
1503
|
} | {
|
|
1481
1504
|
listKey: string;
|
|
1482
1505
|
operation: 'delete';
|
|
1483
1506
|
item: TOutput;
|
|
1484
|
-
context: import('../context/index.js').StackContext
|
|
1507
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1485
1508
|
addValidationError: (msg: string) => void;
|
|
1486
1509
|
};
|
|
1487
1510
|
/**
|
|
@@ -1490,24 +1513,24 @@ export type ValidateHookArgs<TOutput = Record<string, unknown>, TCreateInput = R
|
|
|
1490
1513
|
* - update: has inputData, resolvedData, and item
|
|
1491
1514
|
* - delete: has item only
|
|
1492
1515
|
*/
|
|
1493
|
-
export type BeforeOperationHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>> = {
|
|
1516
|
+
export type BeforeOperationHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> = {
|
|
1494
1517
|
listKey: string;
|
|
1495
1518
|
operation: 'create';
|
|
1496
1519
|
inputData: TCreateInput;
|
|
1497
1520
|
resolvedData: TCreateInput;
|
|
1498
|
-
context: import('../context/index.js').StackContext
|
|
1521
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1499
1522
|
} | {
|
|
1500
1523
|
listKey: string;
|
|
1501
1524
|
operation: 'update';
|
|
1502
1525
|
inputData: TUpdateInput;
|
|
1503
1526
|
item: TOutput;
|
|
1504
1527
|
resolvedData: TUpdateInput;
|
|
1505
|
-
context: import('../context/index.js').StackContext
|
|
1528
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1506
1529
|
} | {
|
|
1507
1530
|
listKey: string;
|
|
1508
1531
|
operation: 'delete';
|
|
1509
1532
|
item: TOutput;
|
|
1510
|
-
context: import('../context/index.js').StackContext
|
|
1533
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1511
1534
|
};
|
|
1512
1535
|
/**
|
|
1513
1536
|
* Hook arguments for the list-level `afterOperation` hook.
|
|
@@ -1515,13 +1538,13 @@ export type BeforeOperationHookArgs<TOutput = Record<string, unknown>, TCreateIn
|
|
|
1515
1538
|
* - update: has item, originalItem, inputData, and resolvedData
|
|
1516
1539
|
* - delete: has originalItem only
|
|
1517
1540
|
*/
|
|
1518
|
-
export type AfterOperationHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>> = {
|
|
1541
|
+
export type AfterOperationHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> = {
|
|
1519
1542
|
listKey: string;
|
|
1520
1543
|
operation: 'create';
|
|
1521
1544
|
inputData: TCreateInput;
|
|
1522
1545
|
item: TOutput;
|
|
1523
1546
|
resolvedData: TCreateInput;
|
|
1524
|
-
context: import('../context/index.js').StackContext
|
|
1547
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1525
1548
|
} | {
|
|
1526
1549
|
listKey: string;
|
|
1527
1550
|
operation: 'update';
|
|
@@ -1529,12 +1552,12 @@ export type AfterOperationHookArgs<TOutput = Record<string, unknown>, TCreateInp
|
|
|
1529
1552
|
originalItem: TOutput;
|
|
1530
1553
|
item: TOutput;
|
|
1531
1554
|
resolvedData: TUpdateInput;
|
|
1532
|
-
context: import('../context/index.js').StackContext
|
|
1555
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1533
1556
|
} | {
|
|
1534
1557
|
listKey: string;
|
|
1535
1558
|
operation: 'delete';
|
|
1536
1559
|
originalItem: TOutput;
|
|
1537
|
-
context: import('../context/index.js').StackContext
|
|
1560
|
+
context: import('../context/index.js').StackContext<TPrisma, TDb>;
|
|
1538
1561
|
};
|
|
1539
1562
|
/**
|
|
1540
1563
|
* Hook arguments for the list-level beforeTransaction hook (#590 / ADR-0010).
|
|
@@ -1545,22 +1568,22 @@ export type AfterOperationHookArgs<TOutput = Record<string, unknown>, TCreateInp
|
|
|
1545
1568
|
* `undefined` for nested targets. For non-transactional side effects whose
|
|
1546
1569
|
* compensation pairs with `afterTransaction`.
|
|
1547
1570
|
*/
|
|
1548
|
-
export type BeforeTransactionHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>> = {
|
|
1571
|
+
export type BeforeTransactionHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> = {
|
|
1549
1572
|
listKey: string;
|
|
1550
1573
|
operation: 'create';
|
|
1551
1574
|
inputData: TCreateInput;
|
|
1552
|
-
context: import('../access/types.js').AccessContext
|
|
1575
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1553
1576
|
} | {
|
|
1554
1577
|
listKey: string;
|
|
1555
1578
|
operation: 'update';
|
|
1556
1579
|
inputData: TUpdateInput;
|
|
1557
1580
|
item: TOutput | undefined;
|
|
1558
|
-
context: import('../access/types.js').AccessContext
|
|
1581
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1559
1582
|
} | {
|
|
1560
1583
|
listKey: string;
|
|
1561
1584
|
operation: 'delete';
|
|
1562
1585
|
item: TOutput | undefined;
|
|
1563
|
-
context: import('../access/types.js').AccessContext
|
|
1586
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1564
1587
|
};
|
|
1565
1588
|
/**
|
|
1566
1589
|
* Hook arguments for the list-level afterTransaction hook (#590 / ADR-0010).
|
|
@@ -1580,21 +1603,21 @@ export type BeforeTransactionHookArgs<TOutput = Record<string, unknown>, TCreate
|
|
|
1580
1603
|
* - `rolled-back`: NO persisted `item`; the hook gets `inputData` and the
|
|
1581
1604
|
* `error` that caused the rollback so it can compensate.
|
|
1582
1605
|
*/
|
|
1583
|
-
export type AfterTransactionHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>> = {
|
|
1606
|
+
export type AfterTransactionHookArgs<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>, TPrisma extends PrismaClientLike = PrismaClientLike, TDb = AccessControlledDB<TPrisma>> = {
|
|
1584
1607
|
listKey: string;
|
|
1585
1608
|
operation: 'create';
|
|
1586
1609
|
status: 'committed';
|
|
1587
1610
|
inputData: TCreateInput;
|
|
1588
1611
|
/** Persisted row — populated for the top-level list only; `undefined` for nested lists. */
|
|
1589
1612
|
item: TOutput | undefined;
|
|
1590
|
-
context: import('../access/types.js').AccessContext
|
|
1613
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1591
1614
|
} | {
|
|
1592
1615
|
listKey: string;
|
|
1593
1616
|
operation: 'create';
|
|
1594
1617
|
status: 'rolled-back';
|
|
1595
1618
|
inputData: TCreateInput;
|
|
1596
1619
|
error: unknown;
|
|
1597
|
-
context: import('../access/types.js').AccessContext
|
|
1620
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1598
1621
|
} | {
|
|
1599
1622
|
listKey: string;
|
|
1600
1623
|
operation: 'update';
|
|
@@ -1604,7 +1627,7 @@ export type AfterTransactionHookArgs<TOutput = Record<string, unknown>, TCreateI
|
|
|
1604
1627
|
originalItem: TOutput | undefined;
|
|
1605
1628
|
/** Persisted row — populated for the top-level list only; `undefined` for nested lists. */
|
|
1606
1629
|
item: TOutput | undefined;
|
|
1607
|
-
context: import('../access/types.js').AccessContext
|
|
1630
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1608
1631
|
} | {
|
|
1609
1632
|
listKey: string;
|
|
1610
1633
|
operation: 'update';
|
|
@@ -1612,34 +1635,34 @@ export type AfterTransactionHookArgs<TOutput = Record<string, unknown>, TCreateI
|
|
|
1612
1635
|
inputData: TUpdateInput;
|
|
1613
1636
|
originalItem: TOutput | undefined;
|
|
1614
1637
|
error: unknown;
|
|
1615
|
-
context: import('../access/types.js').AccessContext
|
|
1638
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1616
1639
|
} | {
|
|
1617
1640
|
listKey: string;
|
|
1618
1641
|
operation: 'delete';
|
|
1619
1642
|
status: 'committed';
|
|
1620
1643
|
/** Pre-write row — populated for the top-level list only; `undefined` for nested lists. */
|
|
1621
1644
|
originalItem: TOutput | undefined;
|
|
1622
|
-
context: import('../access/types.js').AccessContext
|
|
1645
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1623
1646
|
} | {
|
|
1624
1647
|
listKey: string;
|
|
1625
1648
|
operation: 'delete';
|
|
1626
1649
|
status: 'rolled-back';
|
|
1627
1650
|
originalItem: TOutput | undefined;
|
|
1628
1651
|
error: unknown;
|
|
1629
|
-
context: import('../access/types.js').AccessContext
|
|
1652
|
+
context: import('../access/types.js').AccessContext<TPrisma, TDb>;
|
|
1630
1653
|
};
|
|
1631
|
-
export type Hooks<TOutput = Record<string, unknown>, TCreateInput = Record<string, unknown>, TUpdateInput = Record<string, unknown>> = {
|
|
1632
|
-
resolveInput?: (args: ResolveInputHookArgs<TOutput, TCreateInput, TUpdateInput>) => Promise<TCreateInput | TUpdateInput>;
|
|
1633
|
-
validate?: (args: ValidateHookArgs<TOutput, TCreateInput, TUpdateInput>) => Promise<void>;
|
|
1634
|
-
beforeOperation?: (args: BeforeOperationHookArgs<TOutput, TCreateInput, TUpdateInput>) => Promise<void>;
|
|
1635
|
-
afterOperation?: (args: AfterOperationHookArgs<TOutput, TCreateInput, TUpdateInput>) => 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>;
|
|
1636
1659
|
/**
|
|
1637
1660
|
* Side effect BEFORE the write's transaction opens (#590 / ADR-0010).
|
|
1638
1661
|
* Runs OUTSIDE the transaction — for non-transactional work (external API
|
|
1639
1662
|
* calls). Throwing aborts the write; the paired `afterTransaction` then fires
|
|
1640
1663
|
* with `status: 'rolled-back'`. See {@link BeforeTransactionHookArgs}.
|
|
1641
1664
|
*/
|
|
1642
|
-
beforeTransaction?: (args: BeforeTransactionHookArgs<TOutput, TCreateInput, TUpdateInput>) => Promise<void> | void;
|
|
1665
|
+
beforeTransaction?: (args: BeforeTransactionHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma, TDb>) => Promise<void> | void;
|
|
1643
1666
|
/**
|
|
1644
1667
|
* Side effect AFTER the write's transaction settles (#590 / ADR-0010).
|
|
1645
1668
|
* ALWAYS runs when `beforeTransaction` ran; receives `committed | rolled-back`
|
|
@@ -1648,11 +1671,11 @@ export type Hooks<TOutput = Record<string, unknown>, TCreateInput = Record<strin
|
|
|
1648
1671
|
* compensation half of the transaction-boundary bracket. See
|
|
1649
1672
|
* {@link AfterTransactionHookArgs}.
|
|
1650
1673
|
*/
|
|
1651
|
-
afterTransaction?: (args: AfterTransactionHookArgs<TOutput, TCreateInput, TUpdateInput>) => Promise<void> | void;
|
|
1674
|
+
afterTransaction?: (args: AfterTransactionHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma, TDb>) => Promise<void> | void;
|
|
1652
1675
|
/**
|
|
1653
1676
|
* @deprecated Use 'validate' instead. This alias is provided for backwards compatibility.
|
|
1654
1677
|
*/
|
|
1655
|
-
validateInput?: (args: ValidateHookArgs<TOutput, TCreateInput, TUpdateInput>) => Promise<void>;
|
|
1678
|
+
validateInput?: (args: ValidateHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma, TDb>) => Promise<void>;
|
|
1656
1679
|
};
|
|
1657
1680
|
/**
|
|
1658
1681
|
* A single field reference within a model-level {@link ListIndex}. Either
|
|
@@ -1707,7 +1730,7 @@ export type ListConfig<TTypeInfo extends TypeInfo> = {
|
|
|
1707
1730
|
access?: {
|
|
1708
1731
|
operation?: OperationAccess<TTypeInfo['item']>;
|
|
1709
1732
|
};
|
|
1710
|
-
hooks?: Hooks<TTypeInfo['item'], TTypeInfo['inputs']['create'], TTypeInfo['inputs']['update']>;
|
|
1733
|
+
hooks?: Hooks<TTypeInfo['item'], TTypeInfo['inputs']['create'], TTypeInfo['inputs']['update'], TTypeInfo['prisma'], TTypeInfo['db']>;
|
|
1711
1734
|
/**
|
|
1712
1735
|
* Database configuration for this list (model level)
|
|
1713
1736
|
*/
|