@nixxie-cms/core 1.0.3 → 1.1.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/CHANGES-1.1.md +134 -0
- package/context/dist/nixxie-cms-core-context.cjs.js +4 -3
- package/context/dist/nixxie-cms-core-context.esm.js +3 -2
- package/dist/declarations/src/access.d.ts +2 -2
- package/dist/declarations/src/access.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/components/Navigation.d.ts +2 -2
- package/dist/declarations/src/admin-ui/components/Navigation.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/context.d.ts +6 -6
- package/dist/declarations/src/admin-ui/context.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/Fields.d.ts +3 -3
- package/dist/declarations/src/admin-ui/utils/Fields.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/filters.d.ts +5 -5
- package/dist/declarations/src/admin-ui/utils/filters.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/useCreateItem.d.ts +3 -3
- package/dist/declarations/src/admin-ui/utils/useCreateItem.d.ts.map +1 -1
- package/dist/declarations/src/admin-ui/utils/utils.d.ts +2 -2
- package/dist/declarations/src/admin-ui/utils/utils.d.ts.map +1 -1
- package/dist/declarations/src/context.d.ts +1 -1
- package/dist/declarations/src/context.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/bigInt/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/bigInt/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/bytes/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/bytes/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/calendarDay/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/calendarDay/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/checkbox/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/checkbox/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/decimal/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/decimal/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/file/index.d.ts +4 -4
- package/dist/declarations/src/fields/types/file/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/float/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/float/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/image/index.d.ts +4 -4
- package/dist/declarations/src/fields/types/image/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/integer/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/integer/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/json/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/json/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/multiselect/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/multiselect/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/multiselect/views/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/password/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/password/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/index.d.ts +8 -8
- package/dist/declarations/src/fields/types/relationship/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/ComboboxMany.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/ComboboxMany.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/ComboboxSingle.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/ComboboxSingle.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/relationship/views/types.d.ts +3 -3
- package/dist/declarations/src/fields/types/relationship/views/types.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/select/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/select/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/text/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/text/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/timestamp/index.d.ts +3 -3
- package/dist/declarations/src/fields/types/timestamp/index.d.ts.map +1 -1
- package/dist/declarations/src/fields/types/virtual/index.d.ts +7 -7
- package/dist/declarations/src/fields/types/virtual/index.d.ts.map +1 -1
- package/dist/declarations/src/helpers.d.ts +249 -13
- package/dist/declarations/src/helpers.d.ts.map +1 -1
- package/dist/declarations/src/index.d.ts +9 -4
- package/dist/declarations/src/index.d.ts.map +1 -1
- package/dist/declarations/src/internal-unstable/admin-ui/pages/ListPage/index.d.ts.map +1 -1
- package/dist/declarations/src/lib/admin-meta.d.ts +11 -11
- package/dist/declarations/src/lib/admin-meta.d.ts.map +1 -1
- package/dist/declarations/src/lib/core/access-control.d.ts +18 -18
- package/dist/declarations/src/lib/core/access-control.d.ts.map +1 -1
- package/dist/declarations/src/lib/core/cascade.d.ts +47 -0
- package/dist/declarations/src/lib/core/cascade.d.ts.map +1 -0
- package/dist/declarations/src/lib/core/initialise-lists.d.ts +27 -24
- package/dist/declarations/src/lib/core/initialise-lists.d.ts.map +1 -1
- package/dist/declarations/src/lib/env.d.ts +9 -0
- package/dist/declarations/src/lib/env.d.ts.map +1 -0
- package/dist/declarations/src/lib/system.d.ts +1 -1
- package/dist/declarations/src/lib/system.d.ts.map +1 -1
- package/dist/declarations/src/list-features.d.ts +162 -0
- package/dist/declarations/src/list-features.d.ts.map +1 -0
- package/dist/declarations/src/schema.d.ts +24 -23
- package/dist/declarations/src/schema.d.ts.map +1 -1
- package/dist/declarations/src/session.d.ts +75 -0
- package/dist/declarations/src/session.d.ts.map +1 -1
- package/dist/declarations/src/types/admin-meta.d.ts +11 -11
- package/dist/declarations/src/types/admin-meta.d.ts.map +1 -1
- package/dist/declarations/src/types/config/access-control.d.ts +42 -42
- package/dist/declarations/src/types/config/access-control.d.ts.map +1 -1
- package/dist/declarations/src/types/config/fields.d.ts +19 -19
- package/dist/declarations/src/types/config/fields.d.ts.map +1 -1
- package/dist/declarations/src/types/config/hooks.d.ts +131 -131
- package/dist/declarations/src/types/config/hooks.d.ts.map +1 -1
- package/dist/declarations/src/types/config/index.d.ts +171 -8
- package/dist/declarations/src/types/config/index.d.ts.map +1 -1
- package/dist/declarations/src/types/config/lists.d.ts +146 -108
- package/dist/declarations/src/types/config/lists.d.ts.map +1 -1
- package/dist/declarations/src/types/context.d.ts +349 -47
- package/dist/declarations/src/types/context.d.ts.map +1 -1
- package/dist/declarations/src/types/next-fields.d.ts +28 -28
- package/dist/declarations/src/types/next-fields.d.ts.map +1 -1
- package/dist/declarations/src/types/type-info.d.ts +3 -3
- package/dist/declarations/src/types/type-info.d.ts.map +1 -1
- package/dist/{express-7559ca2d.esm.js → express-0abbce07.esm.js} +6 -6
- package/dist/{express-455ae20c.cjs.js → express-7ca6f76a.cjs.js} +6 -6
- package/dist/{index-15c8f81e.esm.js → index-5d8b0b4e.esm.js} +363 -183
- package/dist/index-6055753b.cjs.js +393 -0
- package/dist/{index-42045902.cjs.js → index-ac29f382.cjs.js} +363 -185
- package/dist/index-f1703b7b.esm.js +386 -0
- package/dist/nixxie-cms-core.cjs.js +1387 -30
- package/dist/nixxie-cms-core.esm.js +1361 -24
- package/dist/{non-null-graphql-add6bb3d.cjs.js → non-null-graphql-4a44c122.cjs.js} +1 -1
- package/dist/{non-null-graphql-a84ed64d.esm.js → non-null-graphql-8c5feaae.esm.js} +1 -1
- package/dist/{resolve-hooks-165a9ce2.cjs.js → resolve-hooks-10a5f84c.cjs.js} +240 -6
- package/dist/{resolve-hooks-6813a045.esm.js → resolve-hooks-9e676794.esm.js} +238 -7
- package/dist/{system-03e49e4f.esm.js → system-4d2a2648.esm.js} +32 -7
- package/dist/{system-a321642d.cjs.js → system-69e1a285.cjs.js} +32 -7
- package/fields/dist/nixxie-cms-core-fields.cjs.js +29 -576
- package/fields/dist/nixxie-cms-core-fields.esm.js +18 -565
- package/fields/types/bytes/dist/nixxie-cms-core-fields-types-bytes.cjs.js +4 -2
- package/fields/types/bytes/dist/nixxie-cms-core-fields-types-bytes.esm.js +4 -2
- package/fields/types/multiselect/views/dist/nixxie-cms-core-fields-types-multiselect-views.cjs.js +1 -6
- package/fields/types/multiselect/views/dist/nixxie-cms-core-fields-types-multiselect-views.esm.js +1 -6
- package/fields/types/password/dist/nixxie-cms-core-fields-types-password.cjs.js +4 -2
- package/fields/types/password/dist/nixxie-cms-core-fields-types-password.esm.js +4 -2
- package/internal-unstable/artifacts/dist/nixxie-cms-core-internal-unstable-artifacts.cjs.js +4 -3
- package/internal-unstable/artifacts/dist/nixxie-cms-core-internal-unstable-artifacts.esm.js +4 -3
- package/package.json +4 -4
- package/scripts/cli/dist/nixxie-cms-core-scripts-cli.cjs.js +4 -3
- package/scripts/cli/dist/nixxie-cms-core-scripts-cli.esm.js +4 -3
- package/scripts/dist/nixxie-cms-core-scripts.cjs.js +4 -3
- package/scripts/dist/nixxie-cms-core-scripts.esm.js +4 -3
- package/session/dist/nixxie-cms-core-session.cjs.js +286 -0
- package/session/dist/nixxie-cms-core-session.esm.js +279 -1
- package/src/access.ts +25 -25
- package/src/admin-ui/admin-meta-graphql.ts +5 -5
- package/src/admin-ui/components/CreateButtonLink.tsx +46 -46
- package/src/admin-ui/components/Navigation.tsx +3 -3
- package/src/admin-ui/context.tsx +6 -6
- package/src/admin-ui/utils/Fields.tsx +241 -241
- package/src/admin-ui/utils/actionData.ts +36 -36
- package/src/admin-ui/utils/filters.ts +148 -148
- package/src/admin-ui/utils/useCreateItem.ts +171 -171
- package/src/admin-ui/utils/utils.tsx +127 -127
- package/src/context.ts +1 -1
- package/src/fields/non-null-graphql.ts +115 -115
- package/src/fields/types/bigInt/index.ts +6 -6
- package/src/fields/types/bytes/index.ts +6 -6
- package/src/fields/types/calendarDay/index.ts +18 -19
- package/src/fields/types/checkbox/index.ts +6 -6
- package/src/fields/types/decimal/index.ts +6 -6
- package/src/fields/types/file/index.ts +8 -8
- package/src/fields/types/float/index.ts +6 -6
- package/src/fields/types/image/index.ts +8 -8
- package/src/fields/types/integer/index.ts +6 -6
- package/src/fields/types/json/index.ts +5 -5
- package/src/fields/types/multiselect/index.ts +7 -7
- package/src/fields/types/multiselect/views/index.tsx +149 -151
- package/src/fields/types/password/index.ts +6 -6
- package/src/fields/types/relationship/index.ts +13 -13
- package/src/fields/types/relationship/views/ComboboxMany.tsx +110 -110
- package/src/fields/types/relationship/views/ComboboxSingle.tsx +115 -115
- package/src/fields/types/relationship/views/ContextualActions.tsx +139 -139
- package/src/fields/types/relationship/views/index.tsx +492 -492
- package/src/fields/types/relationship/views/types.ts +46 -46
- package/src/fields/types/relationship/views/useApolloQuery.ts +185 -185
- package/src/fields/types/relationship/views/useFilter.tsx +109 -109
- package/src/fields/types/select/index.ts +6 -6
- package/src/fields/types/text/index.ts +6 -6
- package/src/fields/types/timestamp/index.ts +23 -21
- package/src/fields/types/virtual/index.ts +11 -11
- package/src/helpers.ts +773 -42
- package/src/index.ts +66 -24
- package/src/internal-unstable/admin-ui/pages/ItemPage/common.tsx +4 -4
- package/src/internal-unstable/admin-ui/pages/ItemPage/index.tsx +5 -5
- package/src/internal-unstable/admin-ui/pages/ListPage/index.tsx +8 -8
- package/src/lib/admin-meta.ts +369 -369
- package/src/lib/context/createContext.ts +5 -0
- package/src/lib/core/access-control.ts +434 -434
- package/src/lib/core/cascade.ts +236 -0
- package/src/lib/core/initialise-lists.ts +49 -33
- package/src/lib/core/mutations/index.ts +7 -0
- package/src/lib/core/mutations/nested-mutation-many-input-resolvers.ts +145 -145
- package/src/lib/core/mutations/nested-mutation-one-input-resolvers.ts +71 -71
- package/src/lib/core/queries/output-field.ts +178 -178
- package/src/lib/env.ts +50 -0
- package/src/lib/id-field.ts +2 -2
- package/src/lib/system.ts +221 -207
- package/src/lib/typescript-schema-printer.ts +227 -227
- package/src/list-features.ts +476 -0
- package/src/schema.ts +91 -22
- package/src/session.ts +225 -0
- package/src/types/admin-meta.ts +218 -218
- package/src/types/config/access-control.ts +186 -186
- package/src/types/config/fields.ts +96 -96
- package/src/types/config/hooks.ts +529 -529
- package/src/types/config/index.ts +185 -7
- package/src/types/config/lists.ts +606 -565
- package/src/types/context.ts +426 -55
- package/src/types/next-fields.ts +31 -31
- package/src/types/type-info.ts +38 -38
- package/src/types/type-tests.ts +21 -21
|
@@ -1,529 +1,529 @@
|
|
|
1
|
-
import type { BaseFieldTypeInfo,
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
type CommonArgs<
|
|
5
|
-
context:
|
|
6
|
-
/**
|
|
7
|
-
* The key of the list that the operation is occurring on
|
|
8
|
-
*/
|
|
9
|
-
listKey:
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
type
|
|
13
|
-
|
|
14
|
-
Operation extends 'create' | 'update',
|
|
15
|
-
> = (
|
|
16
|
-
args: {
|
|
17
|
-
create: {
|
|
18
|
-
operation: 'create'
|
|
19
|
-
item: undefined
|
|
20
|
-
/**
|
|
21
|
-
* The GraphQL input **before** default values are applied
|
|
22
|
-
*/
|
|
23
|
-
inputData:
|
|
24
|
-
/**
|
|
25
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
26
|
-
*/
|
|
27
|
-
resolvedData:
|
|
28
|
-
}
|
|
29
|
-
update: {
|
|
30
|
-
operation: 'update'
|
|
31
|
-
item:
|
|
32
|
-
/**
|
|
33
|
-
* The GraphQL input **before** default values are applied
|
|
34
|
-
*/
|
|
35
|
-
inputData:
|
|
36
|
-
/**
|
|
37
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
38
|
-
*/
|
|
39
|
-
resolvedData:
|
|
40
|
-
}
|
|
41
|
-
}[Operation] &
|
|
42
|
-
CommonArgs<
|
|
43
|
-
) => MaybePromise<
|
|
44
|
-
|
|
45
|
-
export type
|
|
46
|
-
/**
|
|
47
|
-
* Used to **modify the input** for create and update operations after default values and access control have been applied
|
|
48
|
-
*/
|
|
49
|
-
resolveInput?:
|
|
50
|
-
|
|
|
51
|
-
| {
|
|
52
|
-
create?:
|
|
53
|
-
update?:
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Used to **validate** if a create, update or delete operation is OK
|
|
58
|
-
*/
|
|
59
|
-
validate?:
|
|
60
|
-
| ValidateHook<
|
|
61
|
-
| {
|
|
62
|
-
create?: ValidateHook<
|
|
63
|
-
update?: ValidateHook<
|
|
64
|
-
delete?: ValidateHook<
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Used to **cause side effects** before a create, update, or delete operation once all validateInput hooks have resolved
|
|
69
|
-
*/
|
|
70
|
-
beforeOperation?:
|
|
71
|
-
|
|
|
72
|
-
| {
|
|
73
|
-
create?:
|
|
74
|
-
update?:
|
|
75
|
-
delete?:
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Used to **cause side effects** after a create, update, or delete operation operation has occurred
|
|
80
|
-
*/
|
|
81
|
-
afterOperation?:
|
|
82
|
-
|
|
|
83
|
-
| {
|
|
84
|
-
create?:
|
|
85
|
-
update?:
|
|
86
|
-
delete?:
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export type
|
|
91
|
-
resolveInput: {
|
|
92
|
-
create:
|
|
93
|
-
update:
|
|
94
|
-
}
|
|
95
|
-
validate: {
|
|
96
|
-
create: ValidateHook<
|
|
97
|
-
update: ValidateHook<
|
|
98
|
-
delete: ValidateHook<
|
|
99
|
-
}
|
|
100
|
-
beforeOperation: {
|
|
101
|
-
create:
|
|
102
|
-
update:
|
|
103
|
-
delete:
|
|
104
|
-
}
|
|
105
|
-
afterOperation: {
|
|
106
|
-
create:
|
|
107
|
-
update:
|
|
108
|
-
delete:
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export type FieldHooks<
|
|
113
|
-
|
|
114
|
-
FieldTypeInfo extends BaseFieldTypeInfo,
|
|
115
|
-
> = {
|
|
116
|
-
/**
|
|
117
|
-
* Used to **modify the input** for create and update operations after default values and access control have been applied
|
|
118
|
-
*/
|
|
119
|
-
resolveInput?:
|
|
120
|
-
| ResolveInputFieldHook<
|
|
121
|
-
| {
|
|
122
|
-
create?: ResolveInputFieldHook<
|
|
123
|
-
update?: ResolveInputFieldHook<
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Used to **validate** if a create, update or delete operation is OK
|
|
128
|
-
*/
|
|
129
|
-
validate?:
|
|
130
|
-
| ValidateFieldHook<
|
|
131
|
-
| {
|
|
132
|
-
create?: ValidateFieldHook<
|
|
133
|
-
update?: ValidateFieldHook<
|
|
134
|
-
delete?: ValidateFieldHook<
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Used to **cause side effects** before a create, update, or delete operation once all validateInput hooks have resolved
|
|
139
|
-
*/
|
|
140
|
-
beforeOperation?:
|
|
141
|
-
| BeforeOperationFieldHook<
|
|
142
|
-
| {
|
|
143
|
-
create?: BeforeOperationFieldHook<
|
|
144
|
-
update?: BeforeOperationFieldHook<
|
|
145
|
-
delete?: BeforeOperationFieldHook<
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Used to **cause side effects** after a create, update, or delete operation operation has occurred
|
|
150
|
-
*/
|
|
151
|
-
afterOperation?:
|
|
152
|
-
| AfterOperationFieldHook<
|
|
153
|
-
| {
|
|
154
|
-
create?: AfterOperationFieldHook<
|
|
155
|
-
update?: AfterOperationFieldHook<
|
|
156
|
-
delete?: AfterOperationFieldHook<
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
export type ResolvedFieldHooks<
|
|
161
|
-
|
|
162
|
-
FieldTypeInfo extends BaseFieldTypeInfo,
|
|
163
|
-
> = {
|
|
164
|
-
resolveInput: {
|
|
165
|
-
create: ResolveInputFieldHook<
|
|
166
|
-
update: ResolveInputFieldHook<
|
|
167
|
-
}
|
|
168
|
-
validate: {
|
|
169
|
-
create: ValidateFieldHook<
|
|
170
|
-
update: ValidateFieldHook<
|
|
171
|
-
delete: ValidateFieldHook<
|
|
172
|
-
}
|
|
173
|
-
beforeOperation: {
|
|
174
|
-
create: BeforeOperationFieldHook<
|
|
175
|
-
update: BeforeOperationFieldHook<
|
|
176
|
-
delete: BeforeOperationFieldHook<
|
|
177
|
-
}
|
|
178
|
-
afterOperation: {
|
|
179
|
-
create: AfterOperationFieldHook<
|
|
180
|
-
update: AfterOperationFieldHook<
|
|
181
|
-
delete: AfterOperationFieldHook<
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
type ResolveInputFieldHook<
|
|
186
|
-
|
|
187
|
-
Operation extends 'create' | 'update',
|
|
188
|
-
FieldTypeInfo extends BaseFieldTypeInfo,
|
|
189
|
-
> = (
|
|
190
|
-
args: {
|
|
191
|
-
create: {
|
|
192
|
-
operation: 'create'
|
|
193
|
-
itemField: undefined
|
|
194
|
-
item: undefined
|
|
195
|
-
/**
|
|
196
|
-
* The GraphQL input **before** default values are applied
|
|
197
|
-
*/
|
|
198
|
-
inputData:
|
|
199
|
-
inputFieldData: FieldTypeInfo['inputs']['create']
|
|
200
|
-
/**
|
|
201
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
202
|
-
*/
|
|
203
|
-
resolvedData:
|
|
204
|
-
resolvedFieldData: FieldTypeInfo['prisma']['create']
|
|
205
|
-
}
|
|
206
|
-
update: {
|
|
207
|
-
operation: 'update'
|
|
208
|
-
itemField: FieldTypeInfo['item']
|
|
209
|
-
item:
|
|
210
|
-
/**
|
|
211
|
-
* The GraphQL input **before** default values are applied
|
|
212
|
-
*/
|
|
213
|
-
inputData:
|
|
214
|
-
inputFieldData: FieldTypeInfo['inputs']['update']
|
|
215
|
-
/**
|
|
216
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
217
|
-
*/
|
|
218
|
-
resolvedData:
|
|
219
|
-
resolvedFieldData: FieldTypeInfo['prisma']['update']
|
|
220
|
-
}
|
|
221
|
-
}[Operation] &
|
|
222
|
-
CommonArgs<
|
|
223
|
-
) => MaybePromise<
|
|
224
|
-
FieldTypeInfo['prisma']['update'] | undefined // undefined represents 'don't do anything'
|
|
225
|
-
>
|
|
226
|
-
|
|
227
|
-
export type ValidateHook<
|
|
228
|
-
|
|
229
|
-
Operation extends 'create' | 'update' | 'delete',
|
|
230
|
-
> = (
|
|
231
|
-
args: {
|
|
232
|
-
create: {
|
|
233
|
-
operation: 'create'
|
|
234
|
-
item: undefined
|
|
235
|
-
/**
|
|
236
|
-
* The GraphQL input **before** default values are applied
|
|
237
|
-
*/
|
|
238
|
-
inputData:
|
|
239
|
-
/**
|
|
240
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
241
|
-
*/
|
|
242
|
-
resolvedData:
|
|
243
|
-
addValidationError: (error: string) => void
|
|
244
|
-
}
|
|
245
|
-
update: {
|
|
246
|
-
operation: 'update'
|
|
247
|
-
item:
|
|
248
|
-
/**
|
|
249
|
-
* The GraphQL input **before** default values are applied
|
|
250
|
-
*/
|
|
251
|
-
inputData:
|
|
252
|
-
/**
|
|
253
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
254
|
-
*/
|
|
255
|
-
resolvedData:
|
|
256
|
-
addValidationError: (error: string) => void
|
|
257
|
-
}
|
|
258
|
-
delete: {
|
|
259
|
-
operation: 'delete'
|
|
260
|
-
item:
|
|
261
|
-
inputData: undefined // TODO: remove?
|
|
262
|
-
resolvedData: undefined // TODO: remove?
|
|
263
|
-
addValidationError: (error: string) => void
|
|
264
|
-
}
|
|
265
|
-
}[Operation] &
|
|
266
|
-
CommonArgs<
|
|
267
|
-
) => MaybePromise<void>
|
|
268
|
-
|
|
269
|
-
export type ValidateFieldHook<
|
|
270
|
-
|
|
271
|
-
Operation extends 'create' | 'update' | 'delete',
|
|
272
|
-
FieldTypeInfo extends BaseFieldTypeInfo,
|
|
273
|
-
> = (
|
|
274
|
-
args: {
|
|
275
|
-
create: {
|
|
276
|
-
operation: 'create'
|
|
277
|
-
item: undefined
|
|
278
|
-
itemField: undefined
|
|
279
|
-
/**
|
|
280
|
-
* The GraphQL input **before** default values are applied
|
|
281
|
-
*/
|
|
282
|
-
inputData:
|
|
283
|
-
inputFieldData: FieldTypeInfo['inputs']['create']
|
|
284
|
-
/**
|
|
285
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
286
|
-
*/
|
|
287
|
-
resolvedData:
|
|
288
|
-
resolvedFieldData: FieldTypeInfo['prisma']['create']
|
|
289
|
-
}
|
|
290
|
-
update: {
|
|
291
|
-
operation: 'update'
|
|
292
|
-
item:
|
|
293
|
-
itemField: FieldTypeInfo['item']
|
|
294
|
-
/**
|
|
295
|
-
* The GraphQL input **before** default values are applied
|
|
296
|
-
*/
|
|
297
|
-
inputData:
|
|
298
|
-
inputFieldData: FieldTypeInfo['inputs']['update']
|
|
299
|
-
/**
|
|
300
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
301
|
-
*/
|
|
302
|
-
resolvedData:
|
|
303
|
-
resolvedFieldData: FieldTypeInfo['prisma']['update']
|
|
304
|
-
}
|
|
305
|
-
delete: {
|
|
306
|
-
operation: 'delete'
|
|
307
|
-
item:
|
|
308
|
-
itemField: FieldTypeInfo['item']
|
|
309
|
-
inputData: undefined
|
|
310
|
-
inputFieldData: undefined
|
|
311
|
-
resolvedData: undefined
|
|
312
|
-
resolvedFieldData: undefined
|
|
313
|
-
}
|
|
314
|
-
}[Operation] &
|
|
315
|
-
CommonArgs<
|
|
316
|
-
fieldKey:
|
|
317
|
-
addValidationError: (error: string) => void
|
|
318
|
-
}
|
|
319
|
-
) => MaybePromise<void>
|
|
320
|
-
|
|
321
|
-
type
|
|
322
|
-
|
|
323
|
-
Operation extends 'create' | 'update' | 'delete',
|
|
324
|
-
> = (
|
|
325
|
-
args: {
|
|
326
|
-
create: {
|
|
327
|
-
operation: 'create'
|
|
328
|
-
item: undefined
|
|
329
|
-
/**
|
|
330
|
-
* The GraphQL input **before** default values are applied
|
|
331
|
-
*/
|
|
332
|
-
inputData:
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
336
|
-
*/
|
|
337
|
-
resolvedData:
|
|
338
|
-
}
|
|
339
|
-
update: {
|
|
340
|
-
operation: 'update'
|
|
341
|
-
item:
|
|
342
|
-
/**
|
|
343
|
-
* The GraphQL input **before** default values are applied
|
|
344
|
-
*/
|
|
345
|
-
inputData:
|
|
346
|
-
/**
|
|
347
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
348
|
-
*/
|
|
349
|
-
resolvedData:
|
|
350
|
-
}
|
|
351
|
-
delete: {
|
|
352
|
-
operation: 'delete'
|
|
353
|
-
item:
|
|
354
|
-
/**
|
|
355
|
-
* The GraphQL input **before** default values are applied
|
|
356
|
-
*/
|
|
357
|
-
inputData: undefined
|
|
358
|
-
/**
|
|
359
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
360
|
-
*/
|
|
361
|
-
resolvedData: undefined
|
|
362
|
-
}
|
|
363
|
-
}[Operation] &
|
|
364
|
-
CommonArgs<
|
|
365
|
-
) => MaybePromise<void>
|
|
366
|
-
|
|
367
|
-
type BeforeOperationFieldHook<
|
|
368
|
-
|
|
369
|
-
Operation extends 'create' | 'update' | 'delete',
|
|
370
|
-
FieldTypeInfo extends BaseFieldTypeInfo,
|
|
371
|
-
> = (
|
|
372
|
-
args: {
|
|
373
|
-
create: {
|
|
374
|
-
operation: 'create'
|
|
375
|
-
item: undefined
|
|
376
|
-
itemField: undefined
|
|
377
|
-
/**
|
|
378
|
-
* The GraphQL input **before** default values are applied
|
|
379
|
-
*/
|
|
380
|
-
inputData:
|
|
381
|
-
inputFieldData: FieldTypeInfo['inputs']['create']
|
|
382
|
-
/**
|
|
383
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
384
|
-
*/
|
|
385
|
-
resolvedData:
|
|
386
|
-
resolvedFieldData: FieldTypeInfo['prisma']['create']
|
|
387
|
-
}
|
|
388
|
-
update: {
|
|
389
|
-
operation: 'update'
|
|
390
|
-
item:
|
|
391
|
-
itemField: FieldTypeInfo['item']
|
|
392
|
-
/**
|
|
393
|
-
* The GraphQL input **before** default values are applied
|
|
394
|
-
*/
|
|
395
|
-
inputData:
|
|
396
|
-
inputFieldData: FieldTypeInfo['inputs']['update']
|
|
397
|
-
/**
|
|
398
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
399
|
-
*/
|
|
400
|
-
resolvedData:
|
|
401
|
-
resolvedFieldData: FieldTypeInfo['prisma']['update']
|
|
402
|
-
}
|
|
403
|
-
delete: {
|
|
404
|
-
operation: 'delete'
|
|
405
|
-
item:
|
|
406
|
-
itemField: FieldTypeInfo['item']
|
|
407
|
-
/**
|
|
408
|
-
* The GraphQL input **before** default values are applied
|
|
409
|
-
*/
|
|
410
|
-
inputData: undefined
|
|
411
|
-
inputFieldData: undefined
|
|
412
|
-
/**
|
|
413
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
414
|
-
*/
|
|
415
|
-
resolvedData: undefined
|
|
416
|
-
resolvedFieldData: undefined
|
|
417
|
-
}
|
|
418
|
-
}[Operation] &
|
|
419
|
-
CommonArgs<
|
|
420
|
-
) => MaybePromise<void>
|
|
421
|
-
|
|
422
|
-
type
|
|
423
|
-
|
|
424
|
-
Operation extends 'create' | 'update' | 'delete',
|
|
425
|
-
> = (
|
|
426
|
-
args: {
|
|
427
|
-
create: {
|
|
428
|
-
operation: 'create'
|
|
429
|
-
originalItem: undefined
|
|
430
|
-
item:
|
|
431
|
-
/**
|
|
432
|
-
* The GraphQL input **before** default values are applied
|
|
433
|
-
*/
|
|
434
|
-
inputData:
|
|
435
|
-
/**
|
|
436
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
437
|
-
*/
|
|
438
|
-
resolvedData:
|
|
439
|
-
}
|
|
440
|
-
update: {
|
|
441
|
-
operation: 'update'
|
|
442
|
-
originalItem:
|
|
443
|
-
item:
|
|
444
|
-
/**
|
|
445
|
-
* The GraphQL input **before** default values are applied
|
|
446
|
-
*/
|
|
447
|
-
inputData:
|
|
448
|
-
/**
|
|
449
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
450
|
-
*/
|
|
451
|
-
resolvedData:
|
|
452
|
-
}
|
|
453
|
-
delete: {
|
|
454
|
-
operation: 'delete'
|
|
455
|
-
originalItem:
|
|
456
|
-
item: undefined
|
|
457
|
-
/**
|
|
458
|
-
* The GraphQL input **before** default values are applied
|
|
459
|
-
*/
|
|
460
|
-
inputData: undefined
|
|
461
|
-
/**
|
|
462
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
463
|
-
*/
|
|
464
|
-
resolvedData: undefined
|
|
465
|
-
}
|
|
466
|
-
}[Operation] &
|
|
467
|
-
CommonArgs<
|
|
468
|
-
) => MaybePromise<void>
|
|
469
|
-
|
|
470
|
-
type AfterOperationFieldHook<
|
|
471
|
-
|
|
472
|
-
Operation extends 'create' | 'update' | 'delete',
|
|
473
|
-
FieldTypeInfo extends BaseFieldTypeInfo,
|
|
474
|
-
> = (
|
|
475
|
-
args: {
|
|
476
|
-
create: {
|
|
477
|
-
operation: 'create'
|
|
478
|
-
originalItem: undefined
|
|
479
|
-
originalItemField: undefined
|
|
480
|
-
item:
|
|
481
|
-
itemField: FieldTypeInfo['item']
|
|
482
|
-
/**
|
|
483
|
-
* The GraphQL input **before** default values are applied
|
|
484
|
-
*/
|
|
485
|
-
inputData:
|
|
486
|
-
inputFieldData: FieldTypeInfo['inputs']['create']
|
|
487
|
-
/**
|
|
488
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
489
|
-
*/
|
|
490
|
-
resolvedData:
|
|
491
|
-
resolvedFieldData: FieldTypeInfo['prisma']['create']
|
|
492
|
-
}
|
|
493
|
-
update: {
|
|
494
|
-
operation: 'update'
|
|
495
|
-
originalItem:
|
|
496
|
-
originalItemField: FieldTypeInfo['item']
|
|
497
|
-
item:
|
|
498
|
-
itemField: FieldTypeInfo['item']
|
|
499
|
-
/**
|
|
500
|
-
* The GraphQL input **before** default values are applied
|
|
501
|
-
*/
|
|
502
|
-
inputData:
|
|
503
|
-
inputFieldData: FieldTypeInfo['inputs']['update']
|
|
504
|
-
/**
|
|
505
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
506
|
-
*/
|
|
507
|
-
resolvedData:
|
|
508
|
-
resolvedFieldData: FieldTypeInfo['prisma']['update']
|
|
509
|
-
}
|
|
510
|
-
delete: {
|
|
511
|
-
operation: 'delete'
|
|
512
|
-
originalItem:
|
|
513
|
-
originalItemField: FieldTypeInfo['item']
|
|
514
|
-
item: undefined
|
|
515
|
-
itemField: undefined
|
|
516
|
-
/**
|
|
517
|
-
* The GraphQL input **before** default values are applied
|
|
518
|
-
*/
|
|
519
|
-
inputData: undefined
|
|
520
|
-
inputFieldData: undefined
|
|
521
|
-
/**
|
|
522
|
-
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
523
|
-
*/
|
|
524
|
-
resolvedData: undefined
|
|
525
|
-
resolvedFieldData: undefined
|
|
526
|
-
}
|
|
527
|
-
}[Operation] &
|
|
528
|
-
CommonArgs<
|
|
529
|
-
) => MaybePromise<void>
|
|
1
|
+
import type { BaseFieldTypeInfo, NixxieContextFromCollectionTypeInfo, MaybePromise } from '..'
|
|
2
|
+
import type { BaseCollectionTypeInfo } from '../type-info'
|
|
3
|
+
|
|
4
|
+
type CommonArgs<CollectionTypeInfo extends BaseCollectionTypeInfo> = {
|
|
5
|
+
context: NixxieContextFromCollectionTypeInfo<CollectionTypeInfo>
|
|
6
|
+
/**
|
|
7
|
+
* The key of the list that the operation is occurring on
|
|
8
|
+
*/
|
|
9
|
+
listKey: CollectionTypeInfo['key']
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
type ResolveInputCollectionHook<
|
|
13
|
+
CollectionTypeInfo extends BaseCollectionTypeInfo,
|
|
14
|
+
Operation extends 'create' | 'update',
|
|
15
|
+
> = (
|
|
16
|
+
args: {
|
|
17
|
+
create: {
|
|
18
|
+
operation: 'create'
|
|
19
|
+
item: undefined
|
|
20
|
+
/**
|
|
21
|
+
* The GraphQL input **before** default values are applied
|
|
22
|
+
*/
|
|
23
|
+
inputData: CollectionTypeInfo['inputs']['create']
|
|
24
|
+
/**
|
|
25
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
26
|
+
*/
|
|
27
|
+
resolvedData: CollectionTypeInfo['prisma']['create']
|
|
28
|
+
}
|
|
29
|
+
update: {
|
|
30
|
+
operation: 'update'
|
|
31
|
+
item: CollectionTypeInfo['item']
|
|
32
|
+
/**
|
|
33
|
+
* The GraphQL input **before** default values are applied
|
|
34
|
+
*/
|
|
35
|
+
inputData: CollectionTypeInfo['inputs']['update']
|
|
36
|
+
/**
|
|
37
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
38
|
+
*/
|
|
39
|
+
resolvedData: CollectionTypeInfo['prisma']['update']
|
|
40
|
+
}
|
|
41
|
+
}[Operation] &
|
|
42
|
+
CommonArgs<CollectionTypeInfo>
|
|
43
|
+
) => MaybePromise<CollectionTypeInfo['prisma'][Operation]>
|
|
44
|
+
|
|
45
|
+
export type CollectionHooks<CollectionTypeInfo extends BaseCollectionTypeInfo> = {
|
|
46
|
+
/**
|
|
47
|
+
* Used to **modify the input** for create and update operations after default values and access control have been applied
|
|
48
|
+
*/
|
|
49
|
+
resolveInput?:
|
|
50
|
+
| ResolveInputCollectionHook<CollectionTypeInfo, 'create' | 'update'>
|
|
51
|
+
| {
|
|
52
|
+
create?: ResolveInputCollectionHook<CollectionTypeInfo, 'create'>
|
|
53
|
+
update?: ResolveInputCollectionHook<CollectionTypeInfo, 'update'>
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Used to **validate** if a create, update or delete operation is OK
|
|
58
|
+
*/
|
|
59
|
+
validate?:
|
|
60
|
+
| ValidateHook<CollectionTypeInfo, 'create' | 'update' | 'delete'>
|
|
61
|
+
| {
|
|
62
|
+
create?: ValidateHook<CollectionTypeInfo, 'create'>
|
|
63
|
+
update?: ValidateHook<CollectionTypeInfo, 'update'>
|
|
64
|
+
delete?: ValidateHook<CollectionTypeInfo, 'delete'>
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Used to **cause side effects** before a create, update, or delete operation once all validateInput hooks have resolved
|
|
69
|
+
*/
|
|
70
|
+
beforeOperation?:
|
|
71
|
+
| BeforeOperationCollectionHook<CollectionTypeInfo, 'create' | 'update' | 'delete'>
|
|
72
|
+
| {
|
|
73
|
+
create?: BeforeOperationCollectionHook<CollectionTypeInfo, 'create'>
|
|
74
|
+
update?: BeforeOperationCollectionHook<CollectionTypeInfo, 'update'>
|
|
75
|
+
delete?: BeforeOperationCollectionHook<CollectionTypeInfo, 'delete'>
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Used to **cause side effects** after a create, update, or delete operation operation has occurred
|
|
80
|
+
*/
|
|
81
|
+
afterOperation?:
|
|
82
|
+
| AfterOperationCollectionHook<CollectionTypeInfo, 'create' | 'update' | 'delete'>
|
|
83
|
+
| {
|
|
84
|
+
create?: AfterOperationCollectionHook<CollectionTypeInfo, 'create'>
|
|
85
|
+
update?: AfterOperationCollectionHook<CollectionTypeInfo, 'update'>
|
|
86
|
+
delete?: AfterOperationCollectionHook<CollectionTypeInfo, 'delete'>
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export type ResolvedCollectionHooks<CollectionTypeInfo extends BaseCollectionTypeInfo> = {
|
|
91
|
+
resolveInput: {
|
|
92
|
+
create: ResolveInputCollectionHook<CollectionTypeInfo, 'create'>
|
|
93
|
+
update: ResolveInputCollectionHook<CollectionTypeInfo, 'update'>
|
|
94
|
+
}
|
|
95
|
+
validate: {
|
|
96
|
+
create: ValidateHook<CollectionTypeInfo, 'create'>
|
|
97
|
+
update: ValidateHook<CollectionTypeInfo, 'update'>
|
|
98
|
+
delete: ValidateHook<CollectionTypeInfo, 'delete'>
|
|
99
|
+
}
|
|
100
|
+
beforeOperation: {
|
|
101
|
+
create: BeforeOperationCollectionHook<CollectionTypeInfo, 'create'>
|
|
102
|
+
update: BeforeOperationCollectionHook<CollectionTypeInfo, 'update'>
|
|
103
|
+
delete: BeforeOperationCollectionHook<CollectionTypeInfo, 'delete'>
|
|
104
|
+
}
|
|
105
|
+
afterOperation: {
|
|
106
|
+
create: AfterOperationCollectionHook<CollectionTypeInfo, 'create'>
|
|
107
|
+
update: AfterOperationCollectionHook<CollectionTypeInfo, 'update'>
|
|
108
|
+
delete: AfterOperationCollectionHook<CollectionTypeInfo, 'delete'>
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export type FieldHooks<
|
|
113
|
+
CollectionTypeInfo extends BaseCollectionTypeInfo,
|
|
114
|
+
FieldTypeInfo extends BaseFieldTypeInfo,
|
|
115
|
+
> = {
|
|
116
|
+
/**
|
|
117
|
+
* Used to **modify the input** for create and update operations after default values and access control have been applied
|
|
118
|
+
*/
|
|
119
|
+
resolveInput?:
|
|
120
|
+
| ResolveInputFieldHook<CollectionTypeInfo, 'create' | 'update', FieldTypeInfo>
|
|
121
|
+
| {
|
|
122
|
+
create?: ResolveInputFieldHook<CollectionTypeInfo, 'create', FieldTypeInfo>
|
|
123
|
+
update?: ResolveInputFieldHook<CollectionTypeInfo, 'update', FieldTypeInfo>
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Used to **validate** if a create, update or delete operation is OK
|
|
128
|
+
*/
|
|
129
|
+
validate?:
|
|
130
|
+
| ValidateFieldHook<CollectionTypeInfo, 'create' | 'update' | 'delete', FieldTypeInfo>
|
|
131
|
+
| {
|
|
132
|
+
create?: ValidateFieldHook<CollectionTypeInfo, 'create', FieldTypeInfo>
|
|
133
|
+
update?: ValidateFieldHook<CollectionTypeInfo, 'update', FieldTypeInfo>
|
|
134
|
+
delete?: ValidateFieldHook<CollectionTypeInfo, 'delete', FieldTypeInfo>
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Used to **cause side effects** before a create, update, or delete operation once all validateInput hooks have resolved
|
|
139
|
+
*/
|
|
140
|
+
beforeOperation?:
|
|
141
|
+
| BeforeOperationFieldHook<CollectionTypeInfo, 'create' | 'update' | 'delete', FieldTypeInfo>
|
|
142
|
+
| {
|
|
143
|
+
create?: BeforeOperationFieldHook<CollectionTypeInfo, 'create', FieldTypeInfo>
|
|
144
|
+
update?: BeforeOperationFieldHook<CollectionTypeInfo, 'update', FieldTypeInfo>
|
|
145
|
+
delete?: BeforeOperationFieldHook<CollectionTypeInfo, 'delete', FieldTypeInfo>
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Used to **cause side effects** after a create, update, or delete operation operation has occurred
|
|
150
|
+
*/
|
|
151
|
+
afterOperation?:
|
|
152
|
+
| AfterOperationFieldHook<CollectionTypeInfo, 'create' | 'update' | 'delete', FieldTypeInfo>
|
|
153
|
+
| {
|
|
154
|
+
create?: AfterOperationFieldHook<CollectionTypeInfo, 'create', FieldTypeInfo>
|
|
155
|
+
update?: AfterOperationFieldHook<CollectionTypeInfo, 'update', FieldTypeInfo>
|
|
156
|
+
delete?: AfterOperationFieldHook<CollectionTypeInfo, 'delete', FieldTypeInfo>
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export type ResolvedFieldHooks<
|
|
161
|
+
CollectionTypeInfo extends BaseCollectionTypeInfo,
|
|
162
|
+
FieldTypeInfo extends BaseFieldTypeInfo,
|
|
163
|
+
> = {
|
|
164
|
+
resolveInput: {
|
|
165
|
+
create: ResolveInputFieldHook<CollectionTypeInfo, 'create', FieldTypeInfo>
|
|
166
|
+
update: ResolveInputFieldHook<CollectionTypeInfo, 'update', FieldTypeInfo>
|
|
167
|
+
}
|
|
168
|
+
validate: {
|
|
169
|
+
create: ValidateFieldHook<CollectionTypeInfo, 'create', FieldTypeInfo>
|
|
170
|
+
update: ValidateFieldHook<CollectionTypeInfo, 'update', FieldTypeInfo>
|
|
171
|
+
delete: ValidateFieldHook<CollectionTypeInfo, 'delete', FieldTypeInfo>
|
|
172
|
+
}
|
|
173
|
+
beforeOperation: {
|
|
174
|
+
create: BeforeOperationFieldHook<CollectionTypeInfo, 'create', FieldTypeInfo>
|
|
175
|
+
update: BeforeOperationFieldHook<CollectionTypeInfo, 'update', FieldTypeInfo>
|
|
176
|
+
delete: BeforeOperationFieldHook<CollectionTypeInfo, 'delete', FieldTypeInfo>
|
|
177
|
+
}
|
|
178
|
+
afterOperation: {
|
|
179
|
+
create: AfterOperationFieldHook<CollectionTypeInfo, 'create', FieldTypeInfo>
|
|
180
|
+
update: AfterOperationFieldHook<CollectionTypeInfo, 'update', FieldTypeInfo>
|
|
181
|
+
delete: AfterOperationFieldHook<CollectionTypeInfo, 'delete', FieldTypeInfo>
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
type ResolveInputFieldHook<
|
|
186
|
+
CollectionTypeInfo extends BaseCollectionTypeInfo,
|
|
187
|
+
Operation extends 'create' | 'update',
|
|
188
|
+
FieldTypeInfo extends BaseFieldTypeInfo,
|
|
189
|
+
> = (
|
|
190
|
+
args: {
|
|
191
|
+
create: {
|
|
192
|
+
operation: 'create'
|
|
193
|
+
itemField: undefined
|
|
194
|
+
item: undefined
|
|
195
|
+
/**
|
|
196
|
+
* The GraphQL input **before** default values are applied
|
|
197
|
+
*/
|
|
198
|
+
inputData: CollectionTypeInfo['inputs']['create']
|
|
199
|
+
inputFieldData: FieldTypeInfo['inputs']['create']
|
|
200
|
+
/**
|
|
201
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
202
|
+
*/
|
|
203
|
+
resolvedData: CollectionTypeInfo['prisma']['create']
|
|
204
|
+
resolvedFieldData: FieldTypeInfo['prisma']['create']
|
|
205
|
+
}
|
|
206
|
+
update: {
|
|
207
|
+
operation: 'update'
|
|
208
|
+
itemField: FieldTypeInfo['item']
|
|
209
|
+
item: CollectionTypeInfo['item']
|
|
210
|
+
/**
|
|
211
|
+
* The GraphQL input **before** default values are applied
|
|
212
|
+
*/
|
|
213
|
+
inputData: CollectionTypeInfo['inputs']['update']
|
|
214
|
+
inputFieldData: FieldTypeInfo['inputs']['update']
|
|
215
|
+
/**
|
|
216
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
217
|
+
*/
|
|
218
|
+
resolvedData: CollectionTypeInfo['prisma']['update']
|
|
219
|
+
resolvedFieldData: FieldTypeInfo['prisma']['update']
|
|
220
|
+
}
|
|
221
|
+
}[Operation] &
|
|
222
|
+
CommonArgs<CollectionTypeInfo> & { fieldKey: CollectionTypeInfo['fields'] }
|
|
223
|
+
) => MaybePromise<
|
|
224
|
+
FieldTypeInfo['prisma']['update'] | undefined // undefined represents 'don't do anything'
|
|
225
|
+
>
|
|
226
|
+
|
|
227
|
+
export type ValidateHook<
|
|
228
|
+
CollectionTypeInfo extends BaseCollectionTypeInfo,
|
|
229
|
+
Operation extends 'create' | 'update' | 'delete',
|
|
230
|
+
> = (
|
|
231
|
+
args: {
|
|
232
|
+
create: {
|
|
233
|
+
operation: 'create'
|
|
234
|
+
item: undefined
|
|
235
|
+
/**
|
|
236
|
+
* The GraphQL input **before** default values are applied
|
|
237
|
+
*/
|
|
238
|
+
inputData: CollectionTypeInfo['inputs']['create']
|
|
239
|
+
/**
|
|
240
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
241
|
+
*/
|
|
242
|
+
resolvedData: CollectionTypeInfo['prisma']['create']
|
|
243
|
+
addValidationError: (error: string) => void
|
|
244
|
+
}
|
|
245
|
+
update: {
|
|
246
|
+
operation: 'update'
|
|
247
|
+
item: CollectionTypeInfo['item']
|
|
248
|
+
/**
|
|
249
|
+
* The GraphQL input **before** default values are applied
|
|
250
|
+
*/
|
|
251
|
+
inputData: CollectionTypeInfo['inputs']['update']
|
|
252
|
+
/**
|
|
253
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
254
|
+
*/
|
|
255
|
+
resolvedData: CollectionTypeInfo['prisma']['update']
|
|
256
|
+
addValidationError: (error: string) => void
|
|
257
|
+
}
|
|
258
|
+
delete: {
|
|
259
|
+
operation: 'delete'
|
|
260
|
+
item: CollectionTypeInfo['item']
|
|
261
|
+
inputData: undefined // TODO: remove?
|
|
262
|
+
resolvedData: undefined // TODO: remove?
|
|
263
|
+
addValidationError: (error: string) => void
|
|
264
|
+
}
|
|
265
|
+
}[Operation] &
|
|
266
|
+
CommonArgs<CollectionTypeInfo>
|
|
267
|
+
) => MaybePromise<void>
|
|
268
|
+
|
|
269
|
+
export type ValidateFieldHook<
|
|
270
|
+
CollectionTypeInfo extends BaseCollectionTypeInfo,
|
|
271
|
+
Operation extends 'create' | 'update' | 'delete',
|
|
272
|
+
FieldTypeInfo extends BaseFieldTypeInfo,
|
|
273
|
+
> = (
|
|
274
|
+
args: {
|
|
275
|
+
create: {
|
|
276
|
+
operation: 'create'
|
|
277
|
+
item: undefined
|
|
278
|
+
itemField: undefined
|
|
279
|
+
/**
|
|
280
|
+
* The GraphQL input **before** default values are applied
|
|
281
|
+
*/
|
|
282
|
+
inputData: CollectionTypeInfo['inputs']['create']
|
|
283
|
+
inputFieldData: FieldTypeInfo['inputs']['create']
|
|
284
|
+
/**
|
|
285
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
286
|
+
*/
|
|
287
|
+
resolvedData: CollectionTypeInfo['prisma']['create']
|
|
288
|
+
resolvedFieldData: FieldTypeInfo['prisma']['create']
|
|
289
|
+
}
|
|
290
|
+
update: {
|
|
291
|
+
operation: 'update'
|
|
292
|
+
item: CollectionTypeInfo['item']
|
|
293
|
+
itemField: FieldTypeInfo['item']
|
|
294
|
+
/**
|
|
295
|
+
* The GraphQL input **before** default values are applied
|
|
296
|
+
*/
|
|
297
|
+
inputData: CollectionTypeInfo['inputs']['update']
|
|
298
|
+
inputFieldData: FieldTypeInfo['inputs']['update']
|
|
299
|
+
/**
|
|
300
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
301
|
+
*/
|
|
302
|
+
resolvedData: CollectionTypeInfo['prisma']['update']
|
|
303
|
+
resolvedFieldData: FieldTypeInfo['prisma']['update']
|
|
304
|
+
}
|
|
305
|
+
delete: {
|
|
306
|
+
operation: 'delete'
|
|
307
|
+
item: CollectionTypeInfo['item']
|
|
308
|
+
itemField: FieldTypeInfo['item']
|
|
309
|
+
inputData: undefined
|
|
310
|
+
inputFieldData: undefined
|
|
311
|
+
resolvedData: undefined
|
|
312
|
+
resolvedFieldData: undefined
|
|
313
|
+
}
|
|
314
|
+
}[Operation] &
|
|
315
|
+
CommonArgs<CollectionTypeInfo> & {
|
|
316
|
+
fieldKey: CollectionTypeInfo['fields']
|
|
317
|
+
addValidationError: (error: string) => void
|
|
318
|
+
}
|
|
319
|
+
) => MaybePromise<void>
|
|
320
|
+
|
|
321
|
+
type BeforeOperationCollectionHook<
|
|
322
|
+
CollectionTypeInfo extends BaseCollectionTypeInfo,
|
|
323
|
+
Operation extends 'create' | 'update' | 'delete',
|
|
324
|
+
> = (
|
|
325
|
+
args: {
|
|
326
|
+
create: {
|
|
327
|
+
operation: 'create'
|
|
328
|
+
item: undefined
|
|
329
|
+
/**
|
|
330
|
+
* The GraphQL input **before** default values are applied
|
|
331
|
+
*/
|
|
332
|
+
inputData: CollectionTypeInfo['inputs']['create']
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
336
|
+
*/
|
|
337
|
+
resolvedData: CollectionTypeInfo['prisma']['create']
|
|
338
|
+
}
|
|
339
|
+
update: {
|
|
340
|
+
operation: 'update'
|
|
341
|
+
item: CollectionTypeInfo['item']
|
|
342
|
+
/**
|
|
343
|
+
* The GraphQL input **before** default values are applied
|
|
344
|
+
*/
|
|
345
|
+
inputData: CollectionTypeInfo['inputs']['update']
|
|
346
|
+
/**
|
|
347
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
348
|
+
*/
|
|
349
|
+
resolvedData: CollectionTypeInfo['prisma']['update']
|
|
350
|
+
}
|
|
351
|
+
delete: {
|
|
352
|
+
operation: 'delete'
|
|
353
|
+
item: CollectionTypeInfo['item']
|
|
354
|
+
/**
|
|
355
|
+
* The GraphQL input **before** default values are applied
|
|
356
|
+
*/
|
|
357
|
+
inputData: undefined
|
|
358
|
+
/**
|
|
359
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
360
|
+
*/
|
|
361
|
+
resolvedData: undefined
|
|
362
|
+
}
|
|
363
|
+
}[Operation] &
|
|
364
|
+
CommonArgs<CollectionTypeInfo>
|
|
365
|
+
) => MaybePromise<void>
|
|
366
|
+
|
|
367
|
+
type BeforeOperationFieldHook<
|
|
368
|
+
CollectionTypeInfo extends BaseCollectionTypeInfo,
|
|
369
|
+
Operation extends 'create' | 'update' | 'delete',
|
|
370
|
+
FieldTypeInfo extends BaseFieldTypeInfo,
|
|
371
|
+
> = (
|
|
372
|
+
args: {
|
|
373
|
+
create: {
|
|
374
|
+
operation: 'create'
|
|
375
|
+
item: undefined
|
|
376
|
+
itemField: undefined
|
|
377
|
+
/**
|
|
378
|
+
* The GraphQL input **before** default values are applied
|
|
379
|
+
*/
|
|
380
|
+
inputData: CollectionTypeInfo['inputs']['create']
|
|
381
|
+
inputFieldData: FieldTypeInfo['inputs']['create']
|
|
382
|
+
/**
|
|
383
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
384
|
+
*/
|
|
385
|
+
resolvedData: CollectionTypeInfo['prisma']['create']
|
|
386
|
+
resolvedFieldData: FieldTypeInfo['prisma']['create']
|
|
387
|
+
}
|
|
388
|
+
update: {
|
|
389
|
+
operation: 'update'
|
|
390
|
+
item: CollectionTypeInfo['item']
|
|
391
|
+
itemField: FieldTypeInfo['item']
|
|
392
|
+
/**
|
|
393
|
+
* The GraphQL input **before** default values are applied
|
|
394
|
+
*/
|
|
395
|
+
inputData: CollectionTypeInfo['inputs']['update']
|
|
396
|
+
inputFieldData: FieldTypeInfo['inputs']['update']
|
|
397
|
+
/**
|
|
398
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
399
|
+
*/
|
|
400
|
+
resolvedData: CollectionTypeInfo['prisma']['update']
|
|
401
|
+
resolvedFieldData: FieldTypeInfo['prisma']['update']
|
|
402
|
+
}
|
|
403
|
+
delete: {
|
|
404
|
+
operation: 'delete'
|
|
405
|
+
item: CollectionTypeInfo['item']
|
|
406
|
+
itemField: FieldTypeInfo['item']
|
|
407
|
+
/**
|
|
408
|
+
* The GraphQL input **before** default values are applied
|
|
409
|
+
*/
|
|
410
|
+
inputData: undefined
|
|
411
|
+
inputFieldData: undefined
|
|
412
|
+
/**
|
|
413
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
414
|
+
*/
|
|
415
|
+
resolvedData: undefined
|
|
416
|
+
resolvedFieldData: undefined
|
|
417
|
+
}
|
|
418
|
+
}[Operation] &
|
|
419
|
+
CommonArgs<CollectionTypeInfo> & { fieldKey: CollectionTypeInfo['fields'] }
|
|
420
|
+
) => MaybePromise<void>
|
|
421
|
+
|
|
422
|
+
type AfterOperationCollectionHook<
|
|
423
|
+
CollectionTypeInfo extends BaseCollectionTypeInfo,
|
|
424
|
+
Operation extends 'create' | 'update' | 'delete',
|
|
425
|
+
> = (
|
|
426
|
+
args: {
|
|
427
|
+
create: {
|
|
428
|
+
operation: 'create'
|
|
429
|
+
originalItem: undefined
|
|
430
|
+
item: CollectionTypeInfo['item']
|
|
431
|
+
/**
|
|
432
|
+
* The GraphQL input **before** default values are applied
|
|
433
|
+
*/
|
|
434
|
+
inputData: CollectionTypeInfo['inputs']['create']
|
|
435
|
+
/**
|
|
436
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
437
|
+
*/
|
|
438
|
+
resolvedData: CollectionTypeInfo['prisma']['create']
|
|
439
|
+
}
|
|
440
|
+
update: {
|
|
441
|
+
operation: 'update'
|
|
442
|
+
originalItem: CollectionTypeInfo['item']
|
|
443
|
+
item: CollectionTypeInfo['item']
|
|
444
|
+
/**
|
|
445
|
+
* The GraphQL input **before** default values are applied
|
|
446
|
+
*/
|
|
447
|
+
inputData: CollectionTypeInfo['inputs']['update']
|
|
448
|
+
/**
|
|
449
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
450
|
+
*/
|
|
451
|
+
resolvedData: CollectionTypeInfo['prisma']['update']
|
|
452
|
+
}
|
|
453
|
+
delete: {
|
|
454
|
+
operation: 'delete'
|
|
455
|
+
originalItem: CollectionTypeInfo['item']
|
|
456
|
+
item: undefined
|
|
457
|
+
/**
|
|
458
|
+
* The GraphQL input **before** default values are applied
|
|
459
|
+
*/
|
|
460
|
+
inputData: undefined
|
|
461
|
+
/**
|
|
462
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
463
|
+
*/
|
|
464
|
+
resolvedData: undefined
|
|
465
|
+
}
|
|
466
|
+
}[Operation] &
|
|
467
|
+
CommonArgs<CollectionTypeInfo>
|
|
468
|
+
) => MaybePromise<void>
|
|
469
|
+
|
|
470
|
+
type AfterOperationFieldHook<
|
|
471
|
+
CollectionTypeInfo extends BaseCollectionTypeInfo,
|
|
472
|
+
Operation extends 'create' | 'update' | 'delete',
|
|
473
|
+
FieldTypeInfo extends BaseFieldTypeInfo,
|
|
474
|
+
> = (
|
|
475
|
+
args: {
|
|
476
|
+
create: {
|
|
477
|
+
operation: 'create'
|
|
478
|
+
originalItem: undefined
|
|
479
|
+
originalItemField: undefined
|
|
480
|
+
item: CollectionTypeInfo['item']
|
|
481
|
+
itemField: FieldTypeInfo['item']
|
|
482
|
+
/**
|
|
483
|
+
* The GraphQL input **before** default values are applied
|
|
484
|
+
*/
|
|
485
|
+
inputData: CollectionTypeInfo['inputs']['create']
|
|
486
|
+
inputFieldData: FieldTypeInfo['inputs']['create']
|
|
487
|
+
/**
|
|
488
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
489
|
+
*/
|
|
490
|
+
resolvedData: CollectionTypeInfo['prisma']['create']
|
|
491
|
+
resolvedFieldData: FieldTypeInfo['prisma']['create']
|
|
492
|
+
}
|
|
493
|
+
update: {
|
|
494
|
+
operation: 'update'
|
|
495
|
+
originalItem: CollectionTypeInfo['item']
|
|
496
|
+
originalItemField: FieldTypeInfo['item']
|
|
497
|
+
item: CollectionTypeInfo['item']
|
|
498
|
+
itemField: FieldTypeInfo['item']
|
|
499
|
+
/**
|
|
500
|
+
* The GraphQL input **before** default values are applied
|
|
501
|
+
*/
|
|
502
|
+
inputData: CollectionTypeInfo['inputs']['update']
|
|
503
|
+
inputFieldData: FieldTypeInfo['inputs']['update']
|
|
504
|
+
/**
|
|
505
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
506
|
+
*/
|
|
507
|
+
resolvedData: CollectionTypeInfo['prisma']['update']
|
|
508
|
+
resolvedFieldData: FieldTypeInfo['prisma']['update']
|
|
509
|
+
}
|
|
510
|
+
delete: {
|
|
511
|
+
operation: 'delete'
|
|
512
|
+
originalItem: CollectionTypeInfo['item']
|
|
513
|
+
originalItemField: FieldTypeInfo['item']
|
|
514
|
+
item: undefined
|
|
515
|
+
itemField: undefined
|
|
516
|
+
/**
|
|
517
|
+
* The GraphQL input **before** default values are applied
|
|
518
|
+
*/
|
|
519
|
+
inputData: undefined
|
|
520
|
+
inputFieldData: undefined
|
|
521
|
+
/**
|
|
522
|
+
* The GraphQL input **after** being resolved by the field type's input resolver
|
|
523
|
+
*/
|
|
524
|
+
resolvedData: undefined
|
|
525
|
+
resolvedFieldData: undefined
|
|
526
|
+
}
|
|
527
|
+
}[Operation] &
|
|
528
|
+
CommonArgs<CollectionTypeInfo> & { fieldKey: CollectionTypeInfo['fields'] }
|
|
529
|
+
) => MaybePromise<void>
|