@opensaas/stack-core 0.41.0 → 0.42.0
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 +26 -0
- package/dist/config/types.d.ts +70 -58
- package/dist/config/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/config/types.ts +76 -50
- package/tsconfig.tsbuildinfo +1 -1
package/src/config/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AccessControl, FieldAccess } from '../access/types.js'
|
|
1
|
+
import type { AccessControl, FieldAccess, PrismaClientLike } from '../access/types.js'
|
|
2
2
|
import type { FilterSpec } from '../filter/types.js'
|
|
3
3
|
import type { z } from 'zod'
|
|
4
4
|
|
|
@@ -21,7 +21,7 @@ export type FieldResolveInputHookArgs<
|
|
|
21
21
|
inputData: TTypeInfo['inputs']['create']
|
|
22
22
|
item: undefined
|
|
23
23
|
resolvedData: TTypeInfo['inputs']['create']
|
|
24
|
-
context: import('../context/index.js').StackContext
|
|
24
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>
|
|
25
25
|
}
|
|
26
26
|
| {
|
|
27
27
|
listKey: string
|
|
@@ -30,7 +30,7 @@ export type FieldResolveInputHookArgs<
|
|
|
30
30
|
inputData: TTypeInfo['inputs']['update']
|
|
31
31
|
item: TTypeInfo['item']
|
|
32
32
|
resolvedData: TTypeInfo['inputs']['update']
|
|
33
|
-
context: import('../context/index.js').StackContext
|
|
33
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
/** Arguments for {@link FieldHooks.validate} (and its deprecated `validateInput` alias). */
|
|
@@ -45,7 +45,7 @@ export type FieldValidateHookArgs<
|
|
|
45
45
|
inputData: TTypeInfo['inputs']['create']
|
|
46
46
|
item: undefined
|
|
47
47
|
resolvedData: TTypeInfo['inputs']['create']
|
|
48
|
-
context: import('../context/index.js').StackContext
|
|
48
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>
|
|
49
49
|
addValidationError: (msg: string) => void
|
|
50
50
|
}
|
|
51
51
|
| {
|
|
@@ -55,7 +55,7 @@ export type FieldValidateHookArgs<
|
|
|
55
55
|
inputData: TTypeInfo['inputs']['update']
|
|
56
56
|
item: TTypeInfo['item']
|
|
57
57
|
resolvedData: TTypeInfo['inputs']['update']
|
|
58
|
-
context: import('../context/index.js').StackContext
|
|
58
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>
|
|
59
59
|
addValidationError: (msg: string) => void
|
|
60
60
|
}
|
|
61
61
|
| {
|
|
@@ -63,7 +63,7 @@ export type FieldValidateHookArgs<
|
|
|
63
63
|
fieldKey: TFieldKey
|
|
64
64
|
operation: 'delete'
|
|
65
65
|
item: TTypeInfo['item']
|
|
66
|
-
context: import('../context/index.js').StackContext
|
|
66
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>
|
|
67
67
|
addValidationError: (msg: string) => void
|
|
68
68
|
}
|
|
69
69
|
|
|
@@ -78,7 +78,7 @@ export type FieldBeforeOperationHookArgs<
|
|
|
78
78
|
operation: 'create'
|
|
79
79
|
inputData: TTypeInfo['inputs']['create']
|
|
80
80
|
resolvedData: TTypeInfo['inputs']['create']
|
|
81
|
-
context: import('../context/index.js').StackContext
|
|
81
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>
|
|
82
82
|
}
|
|
83
83
|
| {
|
|
84
84
|
listKey: string
|
|
@@ -87,14 +87,14 @@ export type FieldBeforeOperationHookArgs<
|
|
|
87
87
|
inputData: TTypeInfo['inputs']['update']
|
|
88
88
|
item: TTypeInfo['item']
|
|
89
89
|
resolvedData: TTypeInfo['inputs']['update']
|
|
90
|
-
context: import('../context/index.js').StackContext
|
|
90
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>
|
|
91
91
|
}
|
|
92
92
|
| {
|
|
93
93
|
listKey: string
|
|
94
94
|
fieldKey: TFieldKey
|
|
95
95
|
operation: 'delete'
|
|
96
96
|
item: TTypeInfo['item']
|
|
97
|
-
context: import('../context/index.js').StackContext
|
|
97
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
/** Arguments for {@link FieldHooks.afterOperation}. */
|
|
@@ -109,7 +109,7 @@ export type FieldAfterOperationHookArgs<
|
|
|
109
109
|
inputData: TTypeInfo['inputs']['create']
|
|
110
110
|
item: TTypeInfo['item']
|
|
111
111
|
resolvedData: TTypeInfo['inputs']['create']
|
|
112
|
-
context: import('../context/index.js').StackContext
|
|
112
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>
|
|
113
113
|
}
|
|
114
114
|
| {
|
|
115
115
|
listKey: string
|
|
@@ -119,14 +119,14 @@ export type FieldAfterOperationHookArgs<
|
|
|
119
119
|
originalItem: TTypeInfo['item']
|
|
120
120
|
item: TTypeInfo['item']
|
|
121
121
|
resolvedData: TTypeInfo['inputs']['update']
|
|
122
|
-
context: import('../context/index.js').StackContext
|
|
122
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>
|
|
123
123
|
}
|
|
124
124
|
| {
|
|
125
125
|
listKey: string
|
|
126
126
|
fieldKey: TFieldKey
|
|
127
127
|
operation: 'delete'
|
|
128
128
|
originalItem: TTypeInfo['item']
|
|
129
|
-
context: import('../context/index.js').StackContext
|
|
129
|
+
context: import('../context/index.js').StackContext<TTypeInfo['prisma']>
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
/**
|
|
@@ -150,7 +150,7 @@ export type FieldBeforeTransactionHookArgs<
|
|
|
150
150
|
fieldKey: TFieldKey
|
|
151
151
|
operation: 'create'
|
|
152
152
|
inputData: TTypeInfo['inputs']['create']
|
|
153
|
-
context: import('../access/types.js').AccessContext
|
|
153
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>
|
|
154
154
|
}
|
|
155
155
|
| {
|
|
156
156
|
listKey: string
|
|
@@ -158,14 +158,14 @@ export type FieldBeforeTransactionHookArgs<
|
|
|
158
158
|
operation: 'update'
|
|
159
159
|
inputData: TTypeInfo['inputs']['update']
|
|
160
160
|
item: TTypeInfo['item'] | undefined
|
|
161
|
-
context: import('../access/types.js').AccessContext
|
|
161
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>
|
|
162
162
|
}
|
|
163
163
|
| {
|
|
164
164
|
listKey: string
|
|
165
165
|
fieldKey: TFieldKey
|
|
166
166
|
operation: 'delete'
|
|
167
167
|
item: TTypeInfo['item'] | undefined
|
|
168
|
-
context: import('../access/types.js').AccessContext
|
|
168
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>
|
|
169
169
|
}
|
|
170
170
|
|
|
171
171
|
/**
|
|
@@ -196,7 +196,7 @@ export type FieldAfterTransactionHookArgs<
|
|
|
196
196
|
inputData: TTypeInfo['inputs']['create']
|
|
197
197
|
/** Persisted row — populated for the top-level list only; `undefined` for nested lists. */
|
|
198
198
|
item: TTypeInfo['item'] | undefined
|
|
199
|
-
context: import('../access/types.js').AccessContext
|
|
199
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>
|
|
200
200
|
}
|
|
201
201
|
| {
|
|
202
202
|
listKey: string
|
|
@@ -205,7 +205,7 @@ export type FieldAfterTransactionHookArgs<
|
|
|
205
205
|
status: 'rolled-back'
|
|
206
206
|
inputData: TTypeInfo['inputs']['create']
|
|
207
207
|
error: unknown
|
|
208
|
-
context: import('../access/types.js').AccessContext
|
|
208
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>
|
|
209
209
|
}
|
|
210
210
|
| {
|
|
211
211
|
listKey: string
|
|
@@ -217,7 +217,7 @@ export type FieldAfterTransactionHookArgs<
|
|
|
217
217
|
originalItem: TTypeInfo['item'] | undefined
|
|
218
218
|
/** Persisted row — populated for the top-level list only; `undefined` for nested lists. */
|
|
219
219
|
item: TTypeInfo['item'] | undefined
|
|
220
|
-
context: import('../access/types.js').AccessContext
|
|
220
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>
|
|
221
221
|
}
|
|
222
222
|
| {
|
|
223
223
|
listKey: string
|
|
@@ -227,7 +227,7 @@ export type FieldAfterTransactionHookArgs<
|
|
|
227
227
|
inputData: TTypeInfo['inputs']['update']
|
|
228
228
|
originalItem: TTypeInfo['item'] | undefined
|
|
229
229
|
error: unknown
|
|
230
|
-
context: import('../access/types.js').AccessContext
|
|
230
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>
|
|
231
231
|
}
|
|
232
232
|
| {
|
|
233
233
|
listKey: string
|
|
@@ -236,7 +236,7 @@ export type FieldAfterTransactionHookArgs<
|
|
|
236
236
|
status: 'committed'
|
|
237
237
|
/** Pre-write row — populated for the top-level list only; `undefined` for nested lists. */
|
|
238
238
|
originalItem: TTypeInfo['item'] | undefined
|
|
239
|
-
context: import('../access/types.js').AccessContext
|
|
239
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>
|
|
240
240
|
}
|
|
241
241
|
| {
|
|
242
242
|
listKey: string
|
|
@@ -245,7 +245,7 @@ export type FieldAfterTransactionHookArgs<
|
|
|
245
245
|
status: 'rolled-back'
|
|
246
246
|
originalItem: TTypeInfo['item'] | undefined
|
|
247
247
|
error: unknown
|
|
248
|
-
context: import('../access/types.js').AccessContext
|
|
248
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>
|
|
249
249
|
}
|
|
250
250
|
|
|
251
251
|
/** Arguments for {@link FieldHooks.resolveOutput}. */
|
|
@@ -258,7 +258,7 @@ export type FieldResolveOutputHookArgs<
|
|
|
258
258
|
item: TTypeInfo['item']
|
|
259
259
|
listKey: string
|
|
260
260
|
fieldName: TFieldKey
|
|
261
|
-
context: import('../access/types.js').AccessContext
|
|
261
|
+
context: import('../access/types.js').AccessContext<TTypeInfo['prisma']>
|
|
262
262
|
}
|
|
263
263
|
|
|
264
264
|
/**
|
|
@@ -1499,6 +1499,10 @@ export type GetFieldValueType<
|
|
|
1499
1499
|
*
|
|
1500
1500
|
* @template TKey - The list key/name (e.g., 'Post', 'User')
|
|
1501
1501
|
* @template TFields - The fields configuration for the list
|
|
1502
|
+
* @template TPrisma - The consuming app's own Prisma client type. Defaults to
|
|
1503
|
+
* {@link PrismaClientLike} so a `TypeInfo` written (or defaulted) without it
|
|
1504
|
+
* keeps today's behaviour — a hook's `context` resolves to `StackContext`
|
|
1505
|
+
* over an unnamed client, same as before this member existed.
|
|
1502
1506
|
* @template TItem - The output type (Prisma model type)
|
|
1503
1507
|
* @template TCreateInput - The Prisma create input type
|
|
1504
1508
|
* @template TUpdateInput - The Prisma update input type
|
|
@@ -1513,12 +1517,14 @@ export type GetFieldValueType<
|
|
|
1513
1517
|
* create: Prisma.PostCreateInput
|
|
1514
1518
|
* update: Prisma.PostUpdateInput
|
|
1515
1519
|
* }
|
|
1520
|
+
* prisma: PrismaClient
|
|
1516
1521
|
* }
|
|
1517
1522
|
* ```
|
|
1518
1523
|
*/
|
|
1519
1524
|
export interface TypeInfo<
|
|
1520
1525
|
TKey extends string = string,
|
|
1521
1526
|
TFields extends Record<string, any> = Record<string, any>, // eslint-disable-line @typescript-eslint/no-explicit-any -- TypeInfo must accept any field record
|
|
1527
|
+
TPrisma extends PrismaClientLike = PrismaClientLike,
|
|
1522
1528
|
> {
|
|
1523
1529
|
key: TKey
|
|
1524
1530
|
fields: TFields
|
|
@@ -1527,6 +1533,12 @@ export interface TypeInfo<
|
|
|
1527
1533
|
create: any // eslint-disable-line @typescript-eslint/no-explicit-any -- Prisma input types are generated and vary per list
|
|
1528
1534
|
update: any // eslint-disable-line @typescript-eslint/no-explicit-any -- Prisma input types are generated and vary per list
|
|
1529
1535
|
}
|
|
1536
|
+
/**
|
|
1537
|
+
* The consuming app's own Prisma client type, so a hook's `context` can be
|
|
1538
|
+
* keyed as `StackContext<TPrisma>`/`AccessContext<TPrisma>` instead of
|
|
1539
|
+
* resolving through the unparameterised {@link PrismaClientLike} default.
|
|
1540
|
+
*/
|
|
1541
|
+
prisma: TPrisma
|
|
1530
1542
|
}
|
|
1531
1543
|
|
|
1532
1544
|
// Generic `any` default allows OperationAccess to work with any list item type
|
|
@@ -1602,6 +1614,7 @@ export type ResolveInputHookArgs<
|
|
|
1602
1614
|
TOutput = Record<string, unknown>,
|
|
1603
1615
|
TCreateInput = Record<string, unknown>,
|
|
1604
1616
|
TUpdateInput = Record<string, unknown>,
|
|
1617
|
+
TPrisma extends PrismaClientLike = PrismaClientLike,
|
|
1605
1618
|
> =
|
|
1606
1619
|
| {
|
|
1607
1620
|
listKey: string
|
|
@@ -1609,7 +1622,7 @@ export type ResolveInputHookArgs<
|
|
|
1609
1622
|
inputData: TCreateInput
|
|
1610
1623
|
resolvedData: TCreateInput
|
|
1611
1624
|
item: undefined
|
|
1612
|
-
context: import('../context/index.js').StackContext
|
|
1625
|
+
context: import('../context/index.js').StackContext<TPrisma>
|
|
1613
1626
|
}
|
|
1614
1627
|
| {
|
|
1615
1628
|
listKey: string
|
|
@@ -1617,7 +1630,7 @@ export type ResolveInputHookArgs<
|
|
|
1617
1630
|
inputData: TUpdateInput
|
|
1618
1631
|
resolvedData: TUpdateInput
|
|
1619
1632
|
item: TOutput
|
|
1620
|
-
context: import('../context/index.js').StackContext
|
|
1633
|
+
context: import('../context/index.js').StackContext<TPrisma>
|
|
1621
1634
|
}
|
|
1622
1635
|
|
|
1623
1636
|
/**
|
|
@@ -1630,6 +1643,7 @@ export type ValidateHookArgs<
|
|
|
1630
1643
|
TOutput = Record<string, unknown>,
|
|
1631
1644
|
TCreateInput = Record<string, unknown>,
|
|
1632
1645
|
TUpdateInput = Record<string, unknown>,
|
|
1646
|
+
TPrisma extends PrismaClientLike = PrismaClientLike,
|
|
1633
1647
|
> =
|
|
1634
1648
|
| {
|
|
1635
1649
|
listKey: string
|
|
@@ -1637,7 +1651,7 @@ export type ValidateHookArgs<
|
|
|
1637
1651
|
inputData: TCreateInput
|
|
1638
1652
|
resolvedData: TCreateInput
|
|
1639
1653
|
item: undefined
|
|
1640
|
-
context: import('../context/index.js').StackContext
|
|
1654
|
+
context: import('../context/index.js').StackContext<TPrisma>
|
|
1641
1655
|
addValidationError: (msg: string) => void
|
|
1642
1656
|
}
|
|
1643
1657
|
| {
|
|
@@ -1646,14 +1660,14 @@ export type ValidateHookArgs<
|
|
|
1646
1660
|
inputData: TUpdateInput
|
|
1647
1661
|
resolvedData: TUpdateInput
|
|
1648
1662
|
item: TOutput
|
|
1649
|
-
context: import('../context/index.js').StackContext
|
|
1663
|
+
context: import('../context/index.js').StackContext<TPrisma>
|
|
1650
1664
|
addValidationError: (msg: string) => void
|
|
1651
1665
|
}
|
|
1652
1666
|
| {
|
|
1653
1667
|
listKey: string
|
|
1654
1668
|
operation: 'delete'
|
|
1655
1669
|
item: TOutput
|
|
1656
|
-
context: import('../context/index.js').StackContext
|
|
1670
|
+
context: import('../context/index.js').StackContext<TPrisma>
|
|
1657
1671
|
addValidationError: (msg: string) => void
|
|
1658
1672
|
}
|
|
1659
1673
|
|
|
@@ -1667,13 +1681,14 @@ export type BeforeOperationHookArgs<
|
|
|
1667
1681
|
TOutput = Record<string, unknown>,
|
|
1668
1682
|
TCreateInput = Record<string, unknown>,
|
|
1669
1683
|
TUpdateInput = Record<string, unknown>,
|
|
1684
|
+
TPrisma extends PrismaClientLike = PrismaClientLike,
|
|
1670
1685
|
> =
|
|
1671
1686
|
| {
|
|
1672
1687
|
listKey: string
|
|
1673
1688
|
operation: 'create'
|
|
1674
1689
|
inputData: TCreateInput
|
|
1675
1690
|
resolvedData: TCreateInput
|
|
1676
|
-
context: import('../context/index.js').StackContext
|
|
1691
|
+
context: import('../context/index.js').StackContext<TPrisma>
|
|
1677
1692
|
}
|
|
1678
1693
|
| {
|
|
1679
1694
|
listKey: string
|
|
@@ -1681,13 +1696,13 @@ export type BeforeOperationHookArgs<
|
|
|
1681
1696
|
inputData: TUpdateInput
|
|
1682
1697
|
item: TOutput
|
|
1683
1698
|
resolvedData: TUpdateInput
|
|
1684
|
-
context: import('../context/index.js').StackContext
|
|
1699
|
+
context: import('../context/index.js').StackContext<TPrisma>
|
|
1685
1700
|
}
|
|
1686
1701
|
| {
|
|
1687
1702
|
listKey: string
|
|
1688
1703
|
operation: 'delete'
|
|
1689
1704
|
item: TOutput
|
|
1690
|
-
context: import('../context/index.js').StackContext
|
|
1705
|
+
context: import('../context/index.js').StackContext<TPrisma>
|
|
1691
1706
|
}
|
|
1692
1707
|
|
|
1693
1708
|
/**
|
|
@@ -1700,6 +1715,7 @@ export type AfterOperationHookArgs<
|
|
|
1700
1715
|
TOutput = Record<string, unknown>,
|
|
1701
1716
|
TCreateInput = Record<string, unknown>,
|
|
1702
1717
|
TUpdateInput = Record<string, unknown>,
|
|
1718
|
+
TPrisma extends PrismaClientLike = PrismaClientLike,
|
|
1703
1719
|
> =
|
|
1704
1720
|
| {
|
|
1705
1721
|
listKey: string
|
|
@@ -1707,7 +1723,7 @@ export type AfterOperationHookArgs<
|
|
|
1707
1723
|
inputData: TCreateInput
|
|
1708
1724
|
item: TOutput
|
|
1709
1725
|
resolvedData: TCreateInput
|
|
1710
|
-
context: import('../context/index.js').StackContext
|
|
1726
|
+
context: import('../context/index.js').StackContext<TPrisma>
|
|
1711
1727
|
}
|
|
1712
1728
|
| {
|
|
1713
1729
|
listKey: string
|
|
@@ -1716,13 +1732,13 @@ export type AfterOperationHookArgs<
|
|
|
1716
1732
|
originalItem: TOutput
|
|
1717
1733
|
item: TOutput
|
|
1718
1734
|
resolvedData: TUpdateInput
|
|
1719
|
-
context: import('../context/index.js').StackContext
|
|
1735
|
+
context: import('../context/index.js').StackContext<TPrisma>
|
|
1720
1736
|
}
|
|
1721
1737
|
| {
|
|
1722
1738
|
listKey: string
|
|
1723
1739
|
operation: 'delete'
|
|
1724
1740
|
originalItem: TOutput
|
|
1725
|
-
context: import('../context/index.js').StackContext
|
|
1741
|
+
context: import('../context/index.js').StackContext<TPrisma>
|
|
1726
1742
|
}
|
|
1727
1743
|
|
|
1728
1744
|
/**
|
|
@@ -1738,25 +1754,26 @@ export type BeforeTransactionHookArgs<
|
|
|
1738
1754
|
TOutput = Record<string, unknown>,
|
|
1739
1755
|
TCreateInput = Record<string, unknown>,
|
|
1740
1756
|
TUpdateInput = Record<string, unknown>,
|
|
1757
|
+
TPrisma extends PrismaClientLike = PrismaClientLike,
|
|
1741
1758
|
> =
|
|
1742
1759
|
| {
|
|
1743
1760
|
listKey: string
|
|
1744
1761
|
operation: 'create'
|
|
1745
1762
|
inputData: TCreateInput
|
|
1746
|
-
context: import('../access/types.js').AccessContext
|
|
1763
|
+
context: import('../access/types.js').AccessContext<TPrisma>
|
|
1747
1764
|
}
|
|
1748
1765
|
| {
|
|
1749
1766
|
listKey: string
|
|
1750
1767
|
operation: 'update'
|
|
1751
1768
|
inputData: TUpdateInput
|
|
1752
1769
|
item: TOutput | undefined
|
|
1753
|
-
context: import('../access/types.js').AccessContext
|
|
1770
|
+
context: import('../access/types.js').AccessContext<TPrisma>
|
|
1754
1771
|
}
|
|
1755
1772
|
| {
|
|
1756
1773
|
listKey: string
|
|
1757
1774
|
operation: 'delete'
|
|
1758
1775
|
item: TOutput | undefined
|
|
1759
|
-
context: import('../access/types.js').AccessContext
|
|
1776
|
+
context: import('../access/types.js').AccessContext<TPrisma>
|
|
1760
1777
|
}
|
|
1761
1778
|
|
|
1762
1779
|
/**
|
|
@@ -1781,6 +1798,7 @@ export type AfterTransactionHookArgs<
|
|
|
1781
1798
|
TOutput = Record<string, unknown>,
|
|
1782
1799
|
TCreateInput = Record<string, unknown>,
|
|
1783
1800
|
TUpdateInput = Record<string, unknown>,
|
|
1801
|
+
TPrisma extends PrismaClientLike = PrismaClientLike,
|
|
1784
1802
|
> =
|
|
1785
1803
|
| {
|
|
1786
1804
|
listKey: string
|
|
@@ -1789,7 +1807,7 @@ export type AfterTransactionHookArgs<
|
|
|
1789
1807
|
inputData: TCreateInput
|
|
1790
1808
|
/** Persisted row — populated for the top-level list only; `undefined` for nested lists. */
|
|
1791
1809
|
item: TOutput | undefined
|
|
1792
|
-
context: import('../access/types.js').AccessContext
|
|
1810
|
+
context: import('../access/types.js').AccessContext<TPrisma>
|
|
1793
1811
|
}
|
|
1794
1812
|
| {
|
|
1795
1813
|
listKey: string
|
|
@@ -1797,7 +1815,7 @@ export type AfterTransactionHookArgs<
|
|
|
1797
1815
|
status: 'rolled-back'
|
|
1798
1816
|
inputData: TCreateInput
|
|
1799
1817
|
error: unknown
|
|
1800
|
-
context: import('../access/types.js').AccessContext
|
|
1818
|
+
context: import('../access/types.js').AccessContext<TPrisma>
|
|
1801
1819
|
}
|
|
1802
1820
|
| {
|
|
1803
1821
|
listKey: string
|
|
@@ -1808,7 +1826,7 @@ export type AfterTransactionHookArgs<
|
|
|
1808
1826
|
originalItem: TOutput | undefined
|
|
1809
1827
|
/** Persisted row — populated for the top-level list only; `undefined` for nested lists. */
|
|
1810
1828
|
item: TOutput | undefined
|
|
1811
|
-
context: import('../access/types.js').AccessContext
|
|
1829
|
+
context: import('../access/types.js').AccessContext<TPrisma>
|
|
1812
1830
|
}
|
|
1813
1831
|
| {
|
|
1814
1832
|
listKey: string
|
|
@@ -1817,7 +1835,7 @@ export type AfterTransactionHookArgs<
|
|
|
1817
1835
|
inputData: TUpdateInput
|
|
1818
1836
|
originalItem: TOutput | undefined
|
|
1819
1837
|
error: unknown
|
|
1820
|
-
context: import('../access/types.js').AccessContext
|
|
1838
|
+
context: import('../access/types.js').AccessContext<TPrisma>
|
|
1821
1839
|
}
|
|
1822
1840
|
| {
|
|
1823
1841
|
listKey: string
|
|
@@ -1825,7 +1843,7 @@ export type AfterTransactionHookArgs<
|
|
|
1825
1843
|
status: 'committed'
|
|
1826
1844
|
/** Pre-write row — populated for the top-level list only; `undefined` for nested lists. */
|
|
1827
1845
|
originalItem: TOutput | undefined
|
|
1828
|
-
context: import('../access/types.js').AccessContext
|
|
1846
|
+
context: import('../access/types.js').AccessContext<TPrisma>
|
|
1829
1847
|
}
|
|
1830
1848
|
| {
|
|
1831
1849
|
listKey: string
|
|
@@ -1833,23 +1851,24 @@ export type AfterTransactionHookArgs<
|
|
|
1833
1851
|
status: 'rolled-back'
|
|
1834
1852
|
originalItem: TOutput | undefined
|
|
1835
1853
|
error: unknown
|
|
1836
|
-
context: import('../access/types.js').AccessContext
|
|
1854
|
+
context: import('../access/types.js').AccessContext<TPrisma>
|
|
1837
1855
|
}
|
|
1838
1856
|
|
|
1839
1857
|
export type Hooks<
|
|
1840
1858
|
TOutput = Record<string, unknown>,
|
|
1841
1859
|
TCreateInput = Record<string, unknown>,
|
|
1842
1860
|
TUpdateInput = Record<string, unknown>,
|
|
1861
|
+
TPrisma extends PrismaClientLike = PrismaClientLike,
|
|
1843
1862
|
> = {
|
|
1844
1863
|
resolveInput?: (
|
|
1845
|
-
args: ResolveInputHookArgs<TOutput, TCreateInput, TUpdateInput>,
|
|
1864
|
+
args: ResolveInputHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma>,
|
|
1846
1865
|
) => Promise<TCreateInput | TUpdateInput>
|
|
1847
|
-
validate?: (args: ValidateHookArgs<TOutput, TCreateInput, TUpdateInput>) => Promise<void>
|
|
1866
|
+
validate?: (args: ValidateHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma>) => Promise<void>
|
|
1848
1867
|
beforeOperation?: (
|
|
1849
|
-
args: BeforeOperationHookArgs<TOutput, TCreateInput, TUpdateInput>,
|
|
1868
|
+
args: BeforeOperationHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma>,
|
|
1850
1869
|
) => Promise<void>
|
|
1851
1870
|
afterOperation?: (
|
|
1852
|
-
args: AfterOperationHookArgs<TOutput, TCreateInput, TUpdateInput>,
|
|
1871
|
+
args: AfterOperationHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma>,
|
|
1853
1872
|
) => Promise<void>
|
|
1854
1873
|
/**
|
|
1855
1874
|
* Side effect BEFORE the write's transaction opens (#590 / ADR-0010).
|
|
@@ -1858,7 +1877,7 @@ export type Hooks<
|
|
|
1858
1877
|
* with `status: 'rolled-back'`. See {@link BeforeTransactionHookArgs}.
|
|
1859
1878
|
*/
|
|
1860
1879
|
beforeTransaction?: (
|
|
1861
|
-
args: BeforeTransactionHookArgs<TOutput, TCreateInput, TUpdateInput>,
|
|
1880
|
+
args: BeforeTransactionHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma>,
|
|
1862
1881
|
) => Promise<void> | void
|
|
1863
1882
|
/**
|
|
1864
1883
|
* Side effect AFTER the write's transaction settles (#590 / ADR-0010).
|
|
@@ -1869,12 +1888,14 @@ export type Hooks<
|
|
|
1869
1888
|
* {@link AfterTransactionHookArgs}.
|
|
1870
1889
|
*/
|
|
1871
1890
|
afterTransaction?: (
|
|
1872
|
-
args: AfterTransactionHookArgs<TOutput, TCreateInput, TUpdateInput>,
|
|
1891
|
+
args: AfterTransactionHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma>,
|
|
1873
1892
|
) => Promise<void> | void
|
|
1874
1893
|
/**
|
|
1875
1894
|
* @deprecated Use 'validate' instead. This alias is provided for backwards compatibility.
|
|
1876
1895
|
*/
|
|
1877
|
-
validateInput?: (
|
|
1896
|
+
validateInput?: (
|
|
1897
|
+
args: ValidateHookArgs<TOutput, TCreateInput, TUpdateInput, TPrisma>,
|
|
1898
|
+
) => Promise<void>
|
|
1878
1899
|
}
|
|
1879
1900
|
|
|
1880
1901
|
/**
|
|
@@ -1938,7 +1959,12 @@ export type ListConfig<TTypeInfo extends TypeInfo> = {
|
|
|
1938
1959
|
access?: {
|
|
1939
1960
|
operation?: OperationAccess<TTypeInfo['item']>
|
|
1940
1961
|
}
|
|
1941
|
-
hooks?: Hooks<
|
|
1962
|
+
hooks?: Hooks<
|
|
1963
|
+
TTypeInfo['item'],
|
|
1964
|
+
TTypeInfo['inputs']['create'],
|
|
1965
|
+
TTypeInfo['inputs']['update'],
|
|
1966
|
+
TTypeInfo['prisma']
|
|
1967
|
+
>
|
|
1942
1968
|
/**
|
|
1943
1969
|
* Database configuration for this list (model level)
|
|
1944
1970
|
*/
|