framework-do-dede 5.4.5 → 5.4.6
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.
|
@@ -39,6 +39,7 @@ declare class HookManager {
|
|
|
39
39
|
notifyBefore(): Promise<void>;
|
|
40
40
|
notifyAfter(onError: boolean): Promise<void>;
|
|
41
41
|
private buildEntry;
|
|
42
|
+
private notifyEntry;
|
|
42
43
|
}
|
|
43
44
|
export declare function DecorateUseCase(options: DecorateUseCaseOptions): <T extends UseCaseConstructor>(target: T) => T;
|
|
44
45
|
export declare function HookBefore(hookClass: HookConstructor): <T extends UseCaseConstructor>(target: T) => T;
|
|
@@ -91,7 +91,7 @@ class HookManager {
|
|
|
91
91
|
}
|
|
92
92
|
async notifyBefore() {
|
|
93
93
|
if (this.position === 'before' && this.entry?.metadata.position === 'before') {
|
|
94
|
-
await this.entry
|
|
94
|
+
await this.notifyEntry(this.entry);
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
97
|
async notifyAfter(onError) {
|
|
@@ -101,7 +101,7 @@ class HookManager {
|
|
|
101
101
|
if (onError && !this.entry.metadata.runOnError) {
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
|
-
await this.entry
|
|
104
|
+
await this.notifyEntry(this.entry);
|
|
105
105
|
}
|
|
106
106
|
buildEntry() {
|
|
107
107
|
const metadata = getHookMetadata(this.owner.constructor);
|
|
@@ -110,14 +110,25 @@ class HookManager {
|
|
|
110
110
|
return undefined;
|
|
111
111
|
}
|
|
112
112
|
const instance = new entry.hookClass();
|
|
113
|
-
|
|
113
|
+
const hookEntry = {
|
|
114
114
|
metadata: entry,
|
|
115
115
|
instance,
|
|
116
|
+
payload: undefined,
|
|
116
117
|
payloadSet: false,
|
|
117
118
|
setPayload: (payload) => {
|
|
119
|
+
hookEntry.payload = payload;
|
|
118
120
|
instance.setPayload(payload, this.owner.context);
|
|
119
121
|
},
|
|
120
122
|
};
|
|
123
|
+
return hookEntry;
|
|
124
|
+
}
|
|
125
|
+
async notifyEntry(entry) {
|
|
126
|
+
const proto = Object.getPrototypeOf(entry.instance);
|
|
127
|
+
const usesBaseNotify = proto.notify === Hook.prototype.notify;
|
|
128
|
+
if (!usesBaseNotify) {
|
|
129
|
+
await entry.instance.use(entry.payload, entry.instance.context);
|
|
130
|
+
}
|
|
131
|
+
await entry.instance.notify();
|
|
121
132
|
}
|
|
122
133
|
}
|
|
123
134
|
function buildUseCaseInstances(owner, options) {
|