@dismissible/nestjs-hooks 2.0.2-canary.2913ba8.0 → 2.0.3
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dismissible/nestjs-hooks",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "Lifecycle hooks interfaces for Dismissible applications",
|
|
5
5
|
"main": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"LICENSE.md"
|
|
18
18
|
],
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@dismissible/nestjs-item": "2.0.
|
|
21
|
-
"@dismissible/nestjs-request": "2.0.
|
|
20
|
+
"@dismissible/nestjs-item": "^2.0.3",
|
|
21
|
+
"@dismissible/nestjs-request": "^2.0.3"
|
|
22
22
|
},
|
|
23
23
|
"keywords": [
|
|
24
24
|
"nestjs",
|
|
@@ -36,4 +36,4 @@
|
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
38
|
"type": "commonjs"
|
|
39
|
-
}
|
|
39
|
+
}
|
|
@@ -26,6 +26,28 @@ export interface IHookResult {
|
|
|
26
26
|
/** Optional mutations to apply */
|
|
27
27
|
mutations?: IHookMutations;
|
|
28
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Mutations that can be applied by batch pre-hooks.
|
|
31
|
+
*/
|
|
32
|
+
export interface IBatchHookMutations {
|
|
33
|
+
/** Mutated item IDs (can filter or transform the array) */
|
|
34
|
+
itemIds?: string[];
|
|
35
|
+
/** Mutated user ID */
|
|
36
|
+
userId?: string;
|
|
37
|
+
/** Mutated request context */
|
|
38
|
+
context?: Partial<IRequestContext>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Result returned by batch pre-hooks.
|
|
42
|
+
*/
|
|
43
|
+
export interface IBatchHookResult {
|
|
44
|
+
/** Whether the operation should proceed */
|
|
45
|
+
proceed: boolean;
|
|
46
|
+
/** Optional reason if the operation is blocked */
|
|
47
|
+
reason?: string;
|
|
48
|
+
/** Optional mutations to apply */
|
|
49
|
+
mutations?: IBatchHookMutations;
|
|
50
|
+
}
|
|
29
51
|
/**
|
|
30
52
|
* Interface for lifecycle hooks that can intercept dismissible operations.
|
|
31
53
|
*/
|
|
@@ -81,4 +103,35 @@ export interface IDismissibleLifecycleHook {
|
|
|
81
103
|
* Called after restoring an item.
|
|
82
104
|
*/
|
|
83
105
|
onAfterRestore?(itemId: string, item: DismissibleItemDto, userId: string, context?: IRequestContext): Promise<void> | void;
|
|
106
|
+
/**
|
|
107
|
+
* Called at the start of any batch operation.
|
|
108
|
+
* Use for global concerns like authentication, rate limiting, request validation.
|
|
109
|
+
* Can filter or transform the itemIds array via mutations.
|
|
110
|
+
*/
|
|
111
|
+
onBeforeBatchRequest?(itemIds: string[], userId: string, context?: IRequestContext): Promise<IBatchHookResult> | IBatchHookResult;
|
|
112
|
+
/**
|
|
113
|
+
* Called at the end of any batch operation.
|
|
114
|
+
* Use for global concerns like audit logging, metrics, cleanup.
|
|
115
|
+
*/
|
|
116
|
+
onAfterBatchRequest?(items: DismissibleItemDto[], userId: string, context?: IRequestContext): Promise<void> | void;
|
|
117
|
+
/**
|
|
118
|
+
* Called before returning existing items in a batch operation.
|
|
119
|
+
* Only called when items exist in storage.
|
|
120
|
+
* Use for access control based on item state.
|
|
121
|
+
*/
|
|
122
|
+
onBeforeBatchGet?(itemIds: string[], items: DismissibleItemDto[], userId: string, context?: IRequestContext): Promise<IBatchHookResult> | IBatchHookResult;
|
|
123
|
+
/**
|
|
124
|
+
* Called after returning existing items in a batch operation.
|
|
125
|
+
*/
|
|
126
|
+
onAfterBatchGet?(items: DismissibleItemDto[], userId: string, context?: IRequestContext): Promise<void> | void;
|
|
127
|
+
/**
|
|
128
|
+
* Called before creating new items in a batch operation.
|
|
129
|
+
* Only receives IDs for items that don't exist yet.
|
|
130
|
+
* Use for plan limits, quota checks, etc.
|
|
131
|
+
*/
|
|
132
|
+
onBeforeBatchCreate?(itemIds: string[], userId: string, context?: IRequestContext): Promise<IBatchHookResult> | IBatchHookResult;
|
|
133
|
+
/**
|
|
134
|
+
* Called after creating new items in a batch operation.
|
|
135
|
+
*/
|
|
136
|
+
onAfterBatchCreate?(items: DismissibleItemDto[], userId: string, context?: IRequestContext): Promise<void> | void;
|
|
84
137
|
}
|