framework-do-dede 1.0.26 → 1.0.28
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/dist/decorators/services.js +4 -2
- package/dist/dede.js +1 -0
- package/dist/di/registry.d.ts +3 -0
- package/dist/di/registry.js +7 -0
- package/package.json +1 -1
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Registry } from "../di/registry";
|
|
2
2
|
import { StorageGateway } from "../protocols/StorageGateway";
|
|
3
|
+
import { Log } from "../utils/Log";
|
|
3
4
|
export function Storage(gatewayName) {
|
|
4
5
|
return function (target, propertyKey) {
|
|
5
|
-
|
|
6
|
+
while (!Registry.isLoaded()) {
|
|
7
|
+
Log.info('Waiting for dependencies to be loaded...');
|
|
8
|
+
}
|
|
6
9
|
if (!Registry.has(gatewayName)) {
|
|
7
10
|
throw new Error(`StorageGateway ${gatewayName} not registered`);
|
|
8
11
|
}
|
|
9
12
|
const GatewayClass = Registry.resolve(gatewayName);
|
|
10
|
-
// Valida se a classe registrada é uma subclasse de StorageGateway
|
|
11
13
|
if (!(GatewayClass instanceof StorageGateway)) {
|
|
12
14
|
throw new Error(`${gatewayName} is not a valid StorageGateway`);
|
|
13
15
|
}
|
package/dist/dede.js
CHANGED
package/dist/di/registry.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import 'reflect-metadata';
|
|
|
2
2
|
declare class ComponentRegistry {
|
|
3
3
|
private static instance;
|
|
4
4
|
private dependencies;
|
|
5
|
+
private isLoading;
|
|
5
6
|
static getInstance(): ComponentRegistry;
|
|
6
7
|
register(token: string, dependency: any): void;
|
|
7
8
|
has(token: string): boolean;
|
|
@@ -10,6 +11,8 @@ declare class ComponentRegistry {
|
|
|
10
11
|
clear(token: string): void;
|
|
11
12
|
classLoader<T>(target: new (...args: any[]) => T): T;
|
|
12
13
|
inject(token: string): (target: any, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
14
|
+
loaded(): void;
|
|
15
|
+
isLoaded(): boolean;
|
|
13
16
|
}
|
|
14
17
|
export declare const Registry: ComponentRegistry;
|
|
15
18
|
export {};
|
package/dist/di/registry.js
CHANGED
|
@@ -3,6 +3,7 @@ import 'reflect-metadata';
|
|
|
3
3
|
class ComponentRegistry {
|
|
4
4
|
static instance;
|
|
5
5
|
dependencies = new Map();
|
|
6
|
+
isLoading = true;
|
|
6
7
|
static getInstance() {
|
|
7
8
|
if (!this.instance) {
|
|
8
9
|
this.instance = new ComponentRegistry();
|
|
@@ -43,5 +44,11 @@ class ComponentRegistry {
|
|
|
43
44
|
inject(token) {
|
|
44
45
|
return Inject(token);
|
|
45
46
|
}
|
|
47
|
+
loaded() {
|
|
48
|
+
this.isLoading = false;
|
|
49
|
+
}
|
|
50
|
+
isLoaded() {
|
|
51
|
+
return !this.isLoading;
|
|
52
|
+
}
|
|
46
53
|
}
|
|
47
54
|
export const Registry = ComponentRegistry.getInstance();
|