framework-do-dede 1.0.29 → 1.0.30
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 +20 -21
- package/dist/di/registry.d.ts +0 -1
- package/dist/di/registry.js +0 -6
- package/package.json +1 -1
|
@@ -2,28 +2,27 @@ import { Registry } from "../di/registry";
|
|
|
2
2
|
import { StorageGateway } from "../protocols/StorageGateway";
|
|
3
3
|
export function Storage(gatewayName) {
|
|
4
4
|
return function (target, propertyKey) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
const instanceSymbol = Symbol();
|
|
14
|
-
Object.defineProperty(target, propertyKey, {
|
|
15
|
-
get: function () {
|
|
16
|
-
if (!this[instanceSymbol]) {
|
|
17
|
-
this[instanceSymbol] = GatewayClass;
|
|
5
|
+
const instanceSymbol = Symbol();
|
|
6
|
+
Object.defineProperty(target, propertyKey, {
|
|
7
|
+
get: function () {
|
|
8
|
+
if (!this[instanceSymbol]) {
|
|
9
|
+
// Lazy load the gateway when the property is first accessed
|
|
10
|
+
if (!Registry.has(gatewayName)) {
|
|
11
|
+
throw new Error(`StorageGateway ${gatewayName} not registered`);
|
|
18
12
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
13
|
+
const GatewayClass = Registry.resolve(gatewayName);
|
|
14
|
+
if (!(GatewayClass instanceof StorageGateway)) {
|
|
15
|
+
throw new Error(`${gatewayName} is not a valid StorageGateway`);
|
|
16
|
+
}
|
|
17
|
+
this[instanceSymbol] = GatewayClass;
|
|
18
|
+
}
|
|
19
|
+
return this[instanceSymbol];
|
|
20
|
+
},
|
|
21
|
+
set: () => {
|
|
22
|
+
throw new Error('Cannot assign new value to @Storage() property');
|
|
23
|
+
},
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true
|
|
27
26
|
});
|
|
28
27
|
};
|
|
29
28
|
}
|
package/dist/di/registry.d.ts
CHANGED
|
@@ -12,7 +12,6 @@ declare class ComponentRegistry {
|
|
|
12
12
|
classLoader<T>(target: new (...args: any[]) => T): T;
|
|
13
13
|
inject(token: string): (target: any, propertyKey: string | symbol | undefined, parameterIndex: number) => void;
|
|
14
14
|
loaded(): void;
|
|
15
|
-
whenLoaded(callback: () => void): void;
|
|
16
15
|
}
|
|
17
16
|
export declare const Registry: ComponentRegistry;
|
|
18
17
|
export {};
|
package/dist/di/registry.js
CHANGED