-
Notifications
You must be signed in to change notification settings - Fork 282
/
Hook.ts
256 lines (190 loc) · 7.78 KB
/
Hook.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
/* eslint-disable @typescript-eslint/no-empty-function */
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
AfterBulkSync,
AfterBulkCreate,
AfterConnect,
AfterDefine,
AfterInit,
BeforeBulkSync,
BeforeConnect,
BeforeDefine,
BeforeInit,
AfterBulkDestroy,
AfterBulkRestore,
AfterBulkUpdate,
AfterCreate,
AfterDestroy,
AfterFind,
AfterRestore,
AfterSave,
AfterUpdate,
AfterUpsert,
AfterValidate,
BeforeBulkCreate,
BeforeBulkDestroy,
BeforeBulkRestore,
BeforeBulkUpdate,
BeforeCount,
BeforeCreate,
BeforeDestroy,
BeforeFind,
BeforeFindAfterExpandIncludeAll,
BeforeFindAfterOptions,
BeforeRestore,
BeforeSave,
BeforeUpdate,
BeforeUpsert,
BeforeValidate,
Column,
Model,
Table,
ValidationFailed,
} from '../../src';
/**
* Model used to test hook decorators. Defined hooks are mocked out for testing.
*/
@Table
export class Hook extends Model {
@Column
name: string;
@BeforeValidate
static beforeValidateHook(instance: Hook, options: any): void {}
@AfterValidate
static afterValidateHook(instance: Hook, options: any): void {}
@ValidationFailed
static validationFailedHook(instance: Hook, options: any, err: any): void {}
@BeforeCreate
static beforeCreateHook(instance: Hook, options: any): void {}
@AfterCreate
static afterCreateHook(instance: Hook, options: any): void {}
@BeforeDestroy
static beforeDestroyHook(instance: Hook, options: any): void {}
@AfterDestroy
static afterDestroyHook(instance: Hook, options: any): void {}
@BeforeRestore
static beforeRestoreHook(instance: Hook, options: any): void {}
@AfterRestore
static afterRestoreHook(instance: Hook, options: any): void {}
@BeforeUpdate
static beforeUpdateHook(instance: Hook, options: any): void {}
@AfterUpdate
static afterUpdateHook(instance: Hook, options: any): void {}
// NOTE: this hook only available in Sequelize v4
@BeforeSave
static beforeSaveHook(instance: Hook, options: any): void {}
// NOTE: this hook only available in Sequelize v4
@AfterSave
static afterSaveHook(instance: Hook, options: any): void {}
// NOTE: this hook only available in Sequelize v4
@BeforeUpsert
static beforeUpsertHook(instance: Hook, options: any): void {}
// NOTE: this hook only available in Sequelize v4
@AfterUpsert
static afterUpsertHook(instance: Hook, options: any): void {}
@BeforeBulkCreate
static beforeBulkCreateHook(instances: Hook[], options: any): void {}
@AfterBulkCreate
static afterBulkCreateHook(instances: Hook[], options: any): void {}
@BeforeBulkSync
static beforeBulkSyncHook(instances: Hook[], options: any): void {}
@AfterBulkSync
static afterBulkSyncHook(instances: Hook[], options: any): void {}
@BeforeConnect
static beforeConnectHook(instances: Hook[], options: any): void {}
@AfterConnect
static afterConnectHook(instances: Hook[], options: any): void {}
@BeforeDefine
static beforeDefineHook(instances: Hook[], options: any): void {}
@AfterDefine
static afterDefineHook(instances: Hook[], options: any): void {}
@BeforeInit
static beforeInitHook(instances: Hook[], options: any): void {}
@AfterInit
static afterInitHook(instances: Hook[], options: any): void {}
@BeforeBulkDestroy
static beforeBulkDestroyHook(options: any): void {}
@AfterBulkDestroy
static afterBulkDestroyHook(options: any): void {}
@BeforeBulkRestore
static beforeBulkRestoreHook(options: any): void {}
@AfterBulkRestore
static afterBulkRestoreHook(options: any): void {}
@BeforeBulkUpdate
static beforeBulkUpdateHook(options: any): void {}
@AfterBulkUpdate
static afterBulkUpdateHook(options: any): void {}
@BeforeFind
static beforeFindHook(options: any): void {}
@BeforeFindAfterExpandIncludeAll
static beforeFindAfterExpandIncludeAllHook(options: any): void {}
@BeforeFindAfterOptions
static beforeFindAfterOptionsHook(options: any): void {}
@AfterFind
static afterFindHook(options: any): void {}
@BeforeCount
static beforeCountHook(options: any): void {}
// Hooks can also be named. This allows them to be removed at a later time using
// Model.removeHook('hookType', 'hookName'). Please be aware that hook removal does not
// work correctly in versions of Sequelize earlier than 4.4.10.
@BeforeValidate({ name: 'myBeforeValidateHook' })
static beforeValidateHookWithName(instance: Hook, options: any): void {}
@AfterValidate({ name: 'myAfterValidateHook' })
static afterValidateHookWithName(instance: Hook, options: any): void {}
@ValidationFailed({ name: 'myValidationFailedHook' })
static validationFailedHookWithName(instance: Hook, options: any, err: any): void {}
@BeforeCreate({ name: 'myBeforeCreateHook' })
static beforeCreateHookWithName(instance: Hook, options: any): void {}
@AfterCreate({ name: 'myAfterCreateHook' })
static afterCreateHookWithName(instance: Hook, options: any): void {}
@BeforeDestroy({ name: 'myBeforeDestroyHook' })
static beforeDestroyHookWithName(instance: Hook, options: any): void {}
@AfterDestroy({ name: 'myAfterDestroyHook' })
static afterDestroyHookWithName(instance: Hook, options: any): void {}
@BeforeRestore({ name: 'myBeforeRestoreHook' })
static beforeRestoreHookWithName(instance: Hook, options: any): void {}
@AfterRestore({ name: 'myAfterRestoreHook' })
static afterRestoreHookWithName(instance: Hook, options: any): void {}
@BeforeUpdate({ name: 'myBeforeUpdateHook' })
static beforeUpdateHookWithName(instance: Hook, options: any): void {}
@AfterUpdate({ name: 'myAfterUpdateHook' })
static afterUpdateHookWithName(instance: Hook, options: any): void {}
// NOTE: this hook only available in Sequelize v4
@BeforeSave({ name: 'myBeforeSaveHook' })
static beforeSaveHookWithName(instance: Hook, options: any): void {}
// NOTE: this hook only available in Sequelize v4
@AfterSave({ name: 'myAfterSaveHook' })
static afterSaveHookWithName(instance: Hook, options: any): void {}
// NOTE: this hook only available in Sequelize v4
@BeforeUpsert({ name: 'myBeforeUpsertHook' })
static beforeUpsertHookWithName(instance: Hook, options: any): void {}
// NOTE: this hook only available in Sequelize v4
@AfterUpsert({ name: 'myAfterUpsertHook' })
static afterUpsertHookWithName(instance: Hook, options: any): void {}
@BeforeBulkCreate({ name: 'myBeforeBulkCreateHook' })
static beforeBulkCreateHookWithName(instances: Hook[], options: any): void {}
@AfterBulkCreate({ name: 'myAfterBulkCreateHook' })
static afterBulkCreateHookWithName(instances: Hook[], options: any): void {}
@BeforeBulkDestroy({ name: 'myBeforeBulkDestroyHook' })
static beforeBulkDestroyHookWithName(options: any): void {}
@AfterBulkDestroy({ name: 'myAfterBulkDestroyHook' })
static afterBulkDestroyHookWithName(options: any): void {}
@BeforeBulkRestore({ name: 'myBeforeBulkRestoreHook' })
static beforeBulkRestoreHookWithName(options: any): void {}
@AfterBulkRestore({ name: 'myAfterBulkRestoreHook' })
static afterBulkRestoreHookWithName(options: any): void {}
@BeforeBulkUpdate({ name: 'myBeforeBulkUpdateHook' })
static beforeBulkUpdateHookWithName(options: any): void {}
@AfterBulkUpdate({ name: 'myAfterBulkUpdateHook' })
static afterBulkUpdateHookWithName(options: any): void {}
@BeforeFind({ name: 'myBeforeFindHook' })
static beforeFindHookWithName(options: any): void {}
@BeforeFindAfterExpandIncludeAll({ name: 'myBeforeFindAfterExpandIncludeAllHook' })
static beforeFindAfterExpandIncludeAllHookWithName(options: any): void {}
@BeforeFindAfterOptions({ name: 'myBeforeFindAfterOptionsHook' })
static beforeFindAfterOptionsHookWithName(options: any): void {}
@AfterFind({ name: 'myAfterFindHook' })
static afterFindHookWithName(options: any): void {}
@BeforeCount({ name: 'myBeforeCountHook' })
static beforeCountHookWithName(options: any): void {}
}