@decaf-ts/db-decorators 0.6.0 → 0.6.2
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/LICENSE.md +21 -157
- package/README.md +571 -10
- package/dist/db-decorators.cjs +1375 -327
- package/dist/db-decorators.esm.cjs +1375 -328
- package/lib/esm/identity/decorators.d.ts +7 -0
- package/lib/esm/identity/decorators.js +11 -4
- package/lib/esm/identity/index.js +3 -3
- package/lib/esm/identity/utils.d.ts +36 -23
- package/lib/esm/identity/utils.js +38 -25
- package/lib/esm/index.d.ts +12 -27
- package/lib/esm/index.js +13 -28
- package/lib/esm/interfaces/BulkCrudOperator.d.ts +39 -0
- package/lib/esm/interfaces/BulkCrudOperator.js +1 -1
- package/lib/esm/interfaces/Contextual.d.ts +19 -2
- package/lib/esm/interfaces/Contextual.js +1 -1
- package/lib/esm/interfaces/CrudOperator.d.ts +26 -23
- package/lib/esm/interfaces/CrudOperator.js +1 -1
- package/lib/esm/interfaces/IRepository.d.ts +10 -2
- package/lib/esm/interfaces/IRepository.js +1 -1
- package/lib/esm/interfaces/index.js +5 -5
- package/lib/esm/model/constants.d.ts +11 -13
- package/lib/esm/model/constants.js +12 -14
- package/lib/esm/model/decorators.d.ts +112 -23
- package/lib/esm/model/decorators.js +119 -29
- package/lib/esm/model/index.d.ts +1 -0
- package/lib/esm/model/index.js +7 -6
- package/lib/esm/model/model.d.ts +2 -141
- package/lib/esm/model/model.js +2 -13
- package/lib/esm/model/overrides.d.ts +1 -0
- package/lib/esm/model/overrides.js +23 -0
- package/lib/esm/model/utils.d.ts +39 -0
- package/lib/esm/model/utils.js +43 -4
- package/lib/esm/model/validation.d.ts +26 -8
- package/lib/esm/model/validation.js +29 -11
- package/lib/esm/operations/Operations.d.ts +65 -3
- package/lib/esm/operations/Operations.js +68 -6
- package/lib/esm/operations/OperationsRegistry.d.ts +44 -16
- package/lib/esm/operations/OperationsRegistry.js +46 -18
- package/lib/esm/operations/constants.d.ts +34 -8
- package/lib/esm/operations/constants.js +23 -9
- package/lib/esm/operations/decorators.d.ts +140 -134
- package/lib/esm/operations/decorators.js +152 -137
- package/lib/esm/operations/index.js +6 -6
- package/lib/esm/operations/types.d.ts +10 -0
- package/lib/esm/operations/types.js +1 -1
- package/lib/esm/repository/BaseRepository.d.ts +324 -0
- package/lib/esm/repository/BaseRepository.js +309 -9
- package/lib/esm/repository/Context.d.ts +153 -2
- package/lib/esm/repository/Context.js +154 -6
- package/lib/esm/repository/Repository.d.ts +89 -0
- package/lib/esm/repository/Repository.js +96 -7
- package/lib/esm/repository/constants.d.ts +7 -0
- package/lib/esm/repository/constants.js +9 -1
- package/lib/esm/repository/errors.d.ts +61 -34
- package/lib/esm/repository/errors.js +62 -35
- package/lib/esm/repository/index.js +9 -9
- package/lib/esm/repository/types.d.ts +26 -0
- package/lib/esm/repository/types.js +1 -1
- package/lib/esm/repository/utils.d.ts +11 -0
- package/lib/esm/repository/utils.js +7 -7
- package/lib/esm/repository/wrappers.d.ts +2 -2
- package/lib/esm/repository/wrappers.js +5 -5
- package/lib/esm/validation/constants.d.ts +20 -5
- package/lib/esm/validation/constants.js +22 -7
- package/lib/esm/validation/decorators.d.ts +101 -19
- package/lib/esm/validation/decorators.js +109 -27
- package/lib/esm/validation/index.js +5 -5
- package/lib/esm/validation/validation.js +10 -2
- package/lib/esm/validation/validators/ReadOnlyValidator.d.ts +32 -8
- package/lib/esm/validation/validators/ReadOnlyValidator.js +34 -10
- package/lib/esm/validation/validators/TimestampValidator.d.ts +37 -3
- package/lib/esm/validation/validators/TimestampValidator.js +39 -5
- package/lib/esm/validation/validators/UpdateValidator.d.ts +28 -11
- package/lib/esm/validation/validators/UpdateValidator.js +23 -8
- package/lib/esm/validation/validators/index.js +4 -4
- package/lib/identity/decorators.cjs +8 -1
- package/lib/identity/decorators.d.ts +7 -0
- package/lib/identity/utils.cjs +35 -22
- package/lib/identity/utils.d.ts +36 -23
- package/lib/index.cjs +14 -28
- package/lib/index.d.ts +12 -27
- package/lib/interfaces/BulkCrudOperator.cjs +1 -1
- package/lib/interfaces/BulkCrudOperator.d.ts +39 -0
- package/lib/interfaces/Contextual.cjs +1 -1
- package/lib/interfaces/Contextual.d.ts +19 -2
- package/lib/interfaces/CrudOperator.cjs +1 -1
- package/lib/interfaces/CrudOperator.d.ts +26 -23
- package/lib/interfaces/IRepository.cjs +1 -1
- package/lib/interfaces/IRepository.d.ts +10 -2
- package/lib/model/constants.cjs +12 -14
- package/lib/model/constants.d.ts +11 -13
- package/lib/model/decorators.cjs +114 -24
- package/lib/model/decorators.d.ts +112 -23
- package/lib/model/index.cjs +2 -1
- package/lib/model/index.d.ts +1 -0
- package/lib/model/model.cjs +1 -13
- package/lib/model/model.d.ts +2 -141
- package/lib/model/overrides.cjs +25 -0
- package/lib/model/overrides.d.ts +1 -0
- package/lib/model/utils.cjs +41 -2
- package/lib/model/utils.d.ts +39 -0
- package/lib/model/validation.cjs +27 -9
- package/lib/model/validation.d.ts +26 -8
- package/lib/operations/Operations.cjs +66 -4
- package/lib/operations/Operations.d.ts +65 -3
- package/lib/operations/OperationsRegistry.cjs +45 -17
- package/lib/operations/OperationsRegistry.d.ts +44 -16
- package/lib/operations/constants.cjs +24 -10
- package/lib/operations/constants.d.ts +34 -8
- package/lib/operations/decorators.cjs +150 -135
- package/lib/operations/decorators.d.ts +140 -134
- package/lib/operations/types.cjs +1 -1
- package/lib/operations/types.d.ts +10 -0
- package/lib/repository/BaseRepository.cjs +303 -3
- package/lib/repository/BaseRepository.d.ts +324 -0
- package/lib/repository/Context.cjs +153 -5
- package/lib/repository/Context.d.ts +153 -2
- package/lib/repository/Repository.cjs +90 -1
- package/lib/repository/Repository.d.ts +89 -0
- package/lib/repository/constants.cjs +9 -1
- package/lib/repository/constants.d.ts +7 -0
- package/lib/repository/errors.cjs +62 -35
- package/lib/repository/errors.d.ts +61 -34
- package/lib/repository/types.cjs +1 -1
- package/lib/repository/types.d.ts +26 -0
- package/lib/repository/utils.cjs +3 -3
- package/lib/repository/utils.d.ts +11 -0
- package/lib/repository/wrappers.cjs +3 -3
- package/lib/repository/wrappers.d.ts +2 -2
- package/lib/validation/constants.cjs +21 -6
- package/lib/validation/constants.d.ts +20 -5
- package/lib/validation/decorators.cjs +102 -20
- package/lib/validation/decorators.d.ts +101 -19
- package/lib/validation/validation.cjs +9 -1
- package/lib/validation/validators/ReadOnlyValidator.cjs +33 -9
- package/lib/validation/validators/ReadOnlyValidator.d.ts +32 -8
- package/lib/validation/validators/TimestampValidator.cjs +38 -4
- package/lib/validation/validators/TimestampValidator.d.ts +37 -3
- package/lib/validation/validators/UpdateValidator.cjs +23 -8
- package/lib/validation/validators/UpdateValidator.d.ts +28 -11
- package/package.json +2 -2
|
@@ -1,193 +1,199 @@
|
|
|
1
1
|
import { IdOperationHandler, OperationHandler, StandardOperationHandler, UpdateOperationHandler } from "./types";
|
|
2
2
|
import { OperationKeys } from "./constants";
|
|
3
3
|
/**
|
|
4
|
-
* @
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @param
|
|
8
|
-
* @param {
|
|
9
|
-
*
|
|
10
|
-
* @see on
|
|
11
|
-
*
|
|
4
|
+
* @description Decorator for handling create and update operations
|
|
5
|
+
* @summary Defines a behavior to execute during both create and update operations
|
|
6
|
+
* @template V - Type for metadata, defaults to object
|
|
7
|
+
* @param {StandardOperationHandler<any, any, V, any, any> | UpdateOperationHandler<any, any, V, any, any>} handler - The method called upon the operation
|
|
8
|
+
* @param {V} [data] - Optional metadata to pass to the handler
|
|
9
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
12
10
|
* @function onCreateUpdate
|
|
13
|
-
*
|
|
14
|
-
* @category Decorators
|
|
11
|
+
* @category Property Decorators
|
|
15
12
|
*/
|
|
16
13
|
export declare function onCreateUpdate<V = object>(handler: StandardOperationHandler<any, any, V, any, any> | UpdateOperationHandler<any, any, V, any, any>, data?: V): (target: object, propertyKey?: any) => void;
|
|
17
14
|
/**
|
|
18
|
-
* @
|
|
19
|
-
*
|
|
20
|
-
* @
|
|
21
|
-
* @param
|
|
22
|
-
* @param {
|
|
23
|
-
*
|
|
24
|
-
* @see on
|
|
25
|
-
*
|
|
15
|
+
* @description Decorator for handling update operations
|
|
16
|
+
* @summary Defines a behavior to execute during update operations
|
|
17
|
+
* @template V - Type for metadata, defaults to object
|
|
18
|
+
* @param {UpdateOperationHandler<any, any, V, any>} handler - The method called upon the operation
|
|
19
|
+
* @param {V} [data] - Optional metadata to pass to the handler
|
|
20
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
26
21
|
* @function onUpdate
|
|
27
|
-
*
|
|
28
|
-
* @category Decorators
|
|
22
|
+
* @category Property Decorators
|
|
29
23
|
*/
|
|
30
24
|
export declare function onUpdate<V = object>(handler: UpdateOperationHandler<any, any, V, any>, data?: V): (target: object, propertyKey?: any) => void;
|
|
31
25
|
/**
|
|
32
|
-
* @
|
|
33
|
-
*
|
|
34
|
-
* @
|
|
35
|
-
* @param
|
|
36
|
-
*
|
|
37
|
-
* @
|
|
38
|
-
*
|
|
26
|
+
* @description Decorator for handling create operations
|
|
27
|
+
* @summary Defines a behavior to execute during create operations
|
|
28
|
+
* @template V - Type for metadata, defaults to object
|
|
29
|
+
* @param {StandardOperationHandler<any, any, V, any, any>} handler - The method called upon the operation
|
|
30
|
+
* @param {V} [data] - Optional metadata to pass to the handler
|
|
31
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
39
32
|
* @function onCreate
|
|
40
|
-
*
|
|
41
|
-
* @category Decorators
|
|
33
|
+
* @category Property Decorators
|
|
42
34
|
*/
|
|
43
35
|
export declare function onCreate<V = object>(handler: StandardOperationHandler<any, any, V, any, any>, data?: V): (target: object, propertyKey?: any) => void;
|
|
44
36
|
/**
|
|
45
|
-
* @
|
|
46
|
-
*
|
|
47
|
-
* @
|
|
48
|
-
* @param
|
|
49
|
-
*
|
|
50
|
-
* @
|
|
51
|
-
*
|
|
37
|
+
* @description Decorator for handling read operations
|
|
38
|
+
* @summary Defines a behavior to execute during read operations
|
|
39
|
+
* @template V - Type for metadata, defaults to object
|
|
40
|
+
* @param {IdOperationHandler<any, any, V, any, any>} handler - The method called upon the operation
|
|
41
|
+
* @param {V} [data] - Optional metadata to pass to the handler
|
|
42
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
52
43
|
* @function onRead
|
|
53
|
-
*
|
|
54
|
-
* @category Decorators
|
|
44
|
+
* @category Property Decorators
|
|
55
45
|
*/
|
|
56
46
|
export declare function onRead<V = object>(handler: IdOperationHandler<any, any, V, any, any>, data: V): (target: object, propertyKey?: any) => void;
|
|
57
47
|
/**
|
|
58
|
-
* @
|
|
59
|
-
*
|
|
60
|
-
* @
|
|
61
|
-
* @param
|
|
62
|
-
*
|
|
63
|
-
* @
|
|
64
|
-
*
|
|
48
|
+
* @description Decorator for handling delete operations
|
|
49
|
+
* @summary Defines a behavior to execute during delete operations
|
|
50
|
+
* @template V - Type for metadata, defaults to object
|
|
51
|
+
* @param {OperationHandler<any, any, V, any, any>} handler - The method called upon the operation
|
|
52
|
+
* @param {V} [data] - Optional metadata to pass to the handler
|
|
53
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
65
54
|
* @function onDelete
|
|
66
|
-
*
|
|
67
|
-
* @category Decorators
|
|
55
|
+
* @category Property Decorators
|
|
68
56
|
*/
|
|
69
57
|
export declare function onDelete<V = object>(handler: OperationHandler<any, any, V, any, any>, data: V): (target: object, propertyKey?: any) => void;
|
|
70
58
|
/**
|
|
71
|
-
* @
|
|
72
|
-
*
|
|
73
|
-
* @
|
|
74
|
-
* @param
|
|
75
|
-
*
|
|
76
|
-
* @
|
|
77
|
-
*
|
|
59
|
+
* @description Decorator for handling all operation types
|
|
60
|
+
* @summary Defines a behavior to execute during any database operation
|
|
61
|
+
* @template V - Type for metadata, defaults to object
|
|
62
|
+
* @param {OperationHandler<any, any, V, any, any>} handler - The method called upon the operation
|
|
63
|
+
* @param {V} [data] - Optional metadata to pass to the handler
|
|
64
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
78
65
|
* @function onAny
|
|
79
|
-
*
|
|
80
|
-
* @category Decorators
|
|
66
|
+
* @category Property Decorators
|
|
81
67
|
*/
|
|
82
68
|
export declare function onAny<V = object>(handler: OperationHandler<any, any, V, any, any>, data: V): (target: object, propertyKey?: any) => void;
|
|
83
69
|
/**
|
|
84
|
-
* @
|
|
85
|
-
*
|
|
86
|
-
* @
|
|
87
|
-
* @param {
|
|
88
|
-
* @param
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
70
|
+
* @description Base decorator for handling database operations
|
|
71
|
+
* @summary Defines a behavior to execute during specified database operations
|
|
72
|
+
* @template V - Type for metadata, defaults to object
|
|
73
|
+
* @param {OperationKeys[] | DBOperations} [op=DBOperations.ALL] - One or more operation types to handle
|
|
74
|
+
* @param {OperationHandler<any, any, V, any, any>} handler - The method called upon the operation
|
|
75
|
+
* @param {V} [data] - Optional metadata to pass to the handler
|
|
76
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
92
77
|
* @function on
|
|
93
|
-
*
|
|
94
|
-
* @
|
|
78
|
+
* @category Property Decorators
|
|
79
|
+
* @example
|
|
80
|
+
* // Example usage:
|
|
81
|
+
* class MyModel {
|
|
82
|
+
* @on(DBOperations.CREATE, myHandler)
|
|
83
|
+
* myProperty: string;
|
|
84
|
+
* }
|
|
95
85
|
*/
|
|
96
86
|
export declare function on<V = object>(op: OperationKeys[] | undefined, handler: OperationHandler<any, any, V, any, any>, data?: V): (target: object, propertyKey?: any) => void;
|
|
97
87
|
/**
|
|
98
|
-
* @
|
|
99
|
-
*
|
|
100
|
-
* @
|
|
101
|
-
* @param
|
|
102
|
-
*
|
|
103
|
-
* @
|
|
104
|
-
*
|
|
88
|
+
* @description Decorator for handling post-create and post-update operations
|
|
89
|
+
* @summary Defines a behavior to execute after both create and update operations
|
|
90
|
+
* @template V - Type for metadata, defaults to object
|
|
91
|
+
* @param {StandardOperationHandler<any, any, V, any, any> | UpdateOperationHandler<any, any, V, any, any>} handler - The method called after the operation
|
|
92
|
+
* @param {V} [data] - Optional metadata to pass to the handler
|
|
93
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
105
94
|
* @function afterCreateUpdate
|
|
106
|
-
*
|
|
107
|
-
* @category Decorators
|
|
95
|
+
* @category Property Decorators
|
|
108
96
|
*/
|
|
109
97
|
export declare function afterCreateUpdate<V = object>(handler: StandardOperationHandler<any, any, V, any, any> | UpdateOperationHandler<any, any, V, any, any>, data: V): (target: object, propertyKey?: any) => void;
|
|
110
98
|
/**
|
|
111
|
-
* @
|
|
112
|
-
*
|
|
113
|
-
* @
|
|
114
|
-
* @param
|
|
115
|
-
*
|
|
116
|
-
* @
|
|
117
|
-
*
|
|
99
|
+
* @description Decorator for handling post-update operations
|
|
100
|
+
* @summary Defines a behavior to execute after update operations
|
|
101
|
+
* @template V - Type for metadata, defaults to object
|
|
102
|
+
* @param {UpdateOperationHandler<any, any, V, any, any>} handler - The method called after the operation
|
|
103
|
+
* @param {V} [data] - Optional metadata to pass to the handler
|
|
104
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
118
105
|
* @function afterUpdate
|
|
119
|
-
*
|
|
120
|
-
* @category Decorators
|
|
106
|
+
* @category Property Decorators
|
|
121
107
|
*/
|
|
122
108
|
export declare function afterUpdate<V = object>(handler: UpdateOperationHandler<any, any, V, any, any>, data: V): (target: object, propertyKey?: any) => void;
|
|
123
109
|
/**
|
|
124
|
-
* @
|
|
125
|
-
*
|
|
126
|
-
* @
|
|
127
|
-
* @param
|
|
128
|
-
*
|
|
129
|
-
* @
|
|
130
|
-
*
|
|
110
|
+
* @description Decorator for handling post-create operations
|
|
111
|
+
* @summary Defines a behavior to execute after create operations
|
|
112
|
+
* @template V - Type for metadata, defaults to object
|
|
113
|
+
* @param {StandardOperationHandler<any, any, V, any, any>} handler - The method called after the operation
|
|
114
|
+
* @param {V} [data] - Optional metadata to pass to the handler
|
|
115
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
131
116
|
* @function afterCreate
|
|
132
|
-
*
|
|
133
|
-
* @category Decorators
|
|
117
|
+
* @category Property Decorators
|
|
134
118
|
*/
|
|
135
119
|
export declare function afterCreate<V = object>(handler: StandardOperationHandler<any, any, V, any, any>, data: V): (target: object, propertyKey?: any) => void;
|
|
136
120
|
/**
|
|
137
|
-
* @
|
|
138
|
-
*
|
|
139
|
-
* @
|
|
140
|
-
* @param
|
|
141
|
-
* @param {
|
|
142
|
-
*
|
|
143
|
-
* @see after
|
|
144
|
-
*
|
|
121
|
+
* @description Decorator for handling post-read operations
|
|
122
|
+
* @summary Defines a behavior to execute after read operations
|
|
123
|
+
* @template V - Type for metadata, defaults to object
|
|
124
|
+
* @param {StandardOperationHandler<any, any, V, any, any>} handler - The method called after the operation
|
|
125
|
+
* @param {V} [data] - Optional metadata to pass to the handler
|
|
126
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
145
127
|
* @function afterRead
|
|
146
|
-
*
|
|
147
|
-
* @category Decorators
|
|
128
|
+
* @category Property Decorators
|
|
148
129
|
*/
|
|
149
130
|
export declare function afterRead<V = object>(handler: StandardOperationHandler<any, any, V, any, any>, data?: V): (target: object, propertyKey?: any) => void;
|
|
150
131
|
/**
|
|
151
|
-
* @
|
|
152
|
-
*
|
|
153
|
-
* @
|
|
154
|
-
* @param
|
|
155
|
-
* @param {
|
|
156
|
-
*
|
|
157
|
-
* @see after
|
|
158
|
-
*
|
|
132
|
+
* @description Decorator for handling post-delete operations
|
|
133
|
+
* @summary Defines a behavior to execute after delete operations
|
|
134
|
+
* @template V - Type for metadata, defaults to object
|
|
135
|
+
* @param {StandardOperationHandler<any, any, V, any, any>} handler - The method called after the operation
|
|
136
|
+
* @param {V} [data] - Optional metadata to pass to the handler
|
|
137
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
159
138
|
* @function afterDelete
|
|
160
|
-
*
|
|
161
|
-
* @category Decorators
|
|
139
|
+
* @category Property Decorators
|
|
162
140
|
*/
|
|
163
141
|
export declare function afterDelete<V = object>(handler: StandardOperationHandler<any, any, V, any, any>, data?: V): (target: object, propertyKey?: any) => void;
|
|
164
142
|
/**
|
|
165
|
-
* @
|
|
166
|
-
*
|
|
167
|
-
* @
|
|
168
|
-
* @param
|
|
169
|
-
* @param {
|
|
170
|
-
*
|
|
171
|
-
* @see after
|
|
172
|
-
*
|
|
143
|
+
* @description Decorator for handling post-operation for all operation types
|
|
144
|
+
* @summary Defines a behavior to execute after any database operation
|
|
145
|
+
* @template V - Type for metadata, defaults to object
|
|
146
|
+
* @param {StandardOperationHandler<any, any, V, any, any>} handler - The method called after the operation
|
|
147
|
+
* @param {V} [data] - Optional metadata to pass to the handler
|
|
148
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
173
149
|
* @function afterAny
|
|
174
|
-
*
|
|
175
|
-
* @category Decorators
|
|
150
|
+
* @category Property Decorators
|
|
176
151
|
*/
|
|
177
152
|
export declare function afterAny<V = object>(handler: StandardOperationHandler<any, any, V, any, any>, data?: V): (target: object, propertyKey?: any) => void;
|
|
178
153
|
/**
|
|
179
|
-
* @
|
|
180
|
-
*
|
|
181
|
-
* @
|
|
182
|
-
* @param {
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* @param data
|
|
187
|
-
* @param args
|
|
154
|
+
* @description Base decorator for handling post-operation behaviors
|
|
155
|
+
* @summary Defines a behavior to execute after specified database operations
|
|
156
|
+
* @template V - Type for metadata, defaults to object
|
|
157
|
+
* @param {OperationKeys[] | DBOperations} [op=DBOperations.ALL] - One or more operation types to handle
|
|
158
|
+
* @param {OperationHandler<any, any, V, any, any>} handler - The method called after the operation
|
|
159
|
+
* @param {V} [data] - Optional metadata to pass to the handler
|
|
160
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
188
161
|
* @function after
|
|
189
|
-
*
|
|
190
|
-
* @
|
|
162
|
+
* @category Property Decorators
|
|
163
|
+
* @example
|
|
164
|
+
* // Example usage:
|
|
165
|
+
* class MyModel {
|
|
166
|
+
* @after(DBOperations.CREATE, myHandler)
|
|
167
|
+
* myProperty: string;
|
|
168
|
+
* }
|
|
191
169
|
*/
|
|
192
170
|
export declare function after<V = object>(op: OperationKeys[] | undefined, handler: OperationHandler<any, any, V, any, any>, data?: V): (target: object, propertyKey?: any) => void;
|
|
171
|
+
/**
|
|
172
|
+
* @description Core decorator factory for operation handlers
|
|
173
|
+
* @summary Creates decorators that register handlers for database operations
|
|
174
|
+
* @template V - Type for metadata, defaults to object
|
|
175
|
+
* @param {OperationKeys.ON | OperationKeys.AFTER} baseOp - Whether the handler runs during or after the operation
|
|
176
|
+
* @param {OperationKeys[]} [operation=DBOperations.ALL] - The specific operations to handle
|
|
177
|
+
* @param {OperationHandler<any, any, V, any, any>} handler - The handler function to execute
|
|
178
|
+
* @param {V} [dataToAdd] - Optional metadata to pass to the handler
|
|
179
|
+
* @return {PropertyDecorator} A decorator that can be applied to class properties
|
|
180
|
+
* @function operation
|
|
181
|
+
* @category Property Decorators
|
|
182
|
+
* @mermaid
|
|
183
|
+
* sequenceDiagram
|
|
184
|
+
* participant Client
|
|
185
|
+
* participant Decorator as @operation
|
|
186
|
+
* participant Operations as Operations Registry
|
|
187
|
+
* participant Handler
|
|
188
|
+
*
|
|
189
|
+
* Client->>Decorator: Apply to property
|
|
190
|
+
* Decorator->>Operations: Register handler
|
|
191
|
+
* Decorator->>Decorator: Store metadata
|
|
192
|
+
*
|
|
193
|
+
* Note over Client,Handler: Later, during operation execution
|
|
194
|
+
* Client->>Operations: Execute operation
|
|
195
|
+
* Operations->>Handler: Call registered handler
|
|
196
|
+
* Handler-->>Operations: Return result
|
|
197
|
+
* Operations-->>Client: Return final result
|
|
198
|
+
*/
|
|
193
199
|
export declare function operation<V = object>(baseOp: OperationKeys.ON | OperationKeys.AFTER, operation: OperationKeys[] | undefined, handler: OperationHandler<any, any, V, any, any>, dataToAdd?: V): (target: object, propertyKey?: any) => void;
|