@lad-tech/nsc-toolkit 1.15.0 → 1.15.1
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/CHANGELOG.md +3 -3
- package/dist/Container.js +2 -1
- package/dist/types/Container.d.ts +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
## [1.15.1](https://github.com/lad-tech/nsc-toolkit/compare/v1.15.0...v1.15.1) (2023-08-16)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Bug Fixes
|
|
5
5
|
|
|
6
|
-
*
|
|
6
|
+
* singlton inject ([9627f1c](https://github.com/lad-tech/nsc-toolkit/commit/9627f1c6c5b82e73b910a8480697dcafa1abd14f))
|
package/dist/Container.js
CHANGED
|
@@ -107,13 +107,14 @@ class Container {
|
|
|
107
107
|
throw new Error(`Unknown dependency type for key ${key.toString()}`);
|
|
108
108
|
}
|
|
109
109
|
async initDependencies() {
|
|
110
|
-
var _a;
|
|
110
|
+
var _a, _b;
|
|
111
111
|
const initialized = [];
|
|
112
112
|
for await (const [key, dependency] of this.container) {
|
|
113
113
|
if (this.isAdapterDependency(dependency) && ((_a = dependency.options) === null || _a === void 0 ? void 0 : _a.init) && !this.singltons.has(key)) {
|
|
114
114
|
const instance = this.getInstance(key);
|
|
115
115
|
await (instance === null || instance === void 0 ? void 0 : instance.init());
|
|
116
116
|
initialized.push(instance);
|
|
117
|
+
this.singltons.set(key, { value: instance, init: (_b = dependency.options) === null || _b === void 0 ? void 0 : _b.init });
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
return initialized;
|
|
@@ -29,7 +29,7 @@ declare class Container {
|
|
|
29
29
|
bind<R extends Record<string, any>>(key: symbol, type: typeof DependencyType.CONSTANT, value: R): void;
|
|
30
30
|
symbol(key: symbol): {
|
|
31
31
|
to: {
|
|
32
|
-
Adapter: <R extends Record<string, any>>(value: Adapter<R & import("./interfaces").GracefulShutdownAdditionalService & {
|
|
32
|
+
Adapter: <R extends Record<string, any>>(value: Adapter<R> | Adapter<R & import("./interfaces").GracefulShutdownAdditionalService & {
|
|
33
33
|
init: () => Promise<any>;
|
|
34
34
|
}>, options?: AdapterOptions) => void;
|
|
35
35
|
Singlton: <R_1 extends Record<string, any>>(value: Adapter<R_1>) => void;
|