@lad-tech/nsc-toolkit 2.0.4 → 2.0.5

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 CHANGED
@@ -1,6 +1,11 @@
1
- ## [2.0.4](https://github.com/lad-tech/nsc-toolkit/compare/v2.0.3...v2.0.4) (2025-11-05)
1
+ ## [2.0.5](https://github.com/lad-tech/nsc-toolkit/compare/v2.0.4...v2.0.5) (2026-02-12)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
- * logic for default request timeout ([#156](https://github.com/lad-tech/nsc-toolkit/issues/156)) ([2caf9db](https://github.com/lad-tech/nsc-toolkit/commit/2caf9dbef492c631e9980a24abab84a372a01312))
6
+ * ci/cd ([#163](https://github.com/lad-tech/nsc-toolkit/issues/163)) ([783b7eb](https://github.com/lad-tech/nsc-toolkit/commit/783b7ebe649962d7ffed08f20150d922258257d5))
7
+ * fix ci/cd ([#165](https://github.com/lad-tech/nsc-toolkit/issues/165)) ([c899213](https://github.com/lad-tech/nsc-toolkit/commit/c899213f1c429e9689218230b83a1da580e4e57e))
8
+ * Logic create singleton object ([#159](https://github.com/lad-tech/nsc-toolkit/issues/159)) ([eaadf01](https://github.com/lad-tech/nsc-toolkit/commit/eaadf015f9f6b733c0b4d891e8b385ca22a14106))
9
+ * publish ci/cd ([#161](https://github.com/lad-tech/nsc-toolkit/issues/161)) ([0138bfc](https://github.com/lad-tech/nsc-toolkit/commit/0138bfcd35c406637d64369f75c5d3f3e383158b))
10
+ * return npm token ([#169](https://github.com/lad-tech/nsc-toolkit/issues/169)) ([3d6a40f](https://github.com/lad-tech/nsc-toolkit/commit/3d6a40f271e775861ef8c7002c9abf7b98ff5943))
11
+ * up semantic release version ([#167](https://github.com/lad-tech/nsc-toolkit/issues/167)) ([d1d6d99](https://github.com/lad-tech/nsc-toolkit/commit/d1d6d99bf124ff6d4fc2094d1107b1155fca9d76))
package/dist/Container.js CHANGED
@@ -6,15 +6,10 @@ class Container {
6
6
  constructor() {
7
7
  this.container = new Map();
8
8
  this.singletons = new Map();
9
+ this.initializedKeys = new Set();
9
10
  }
10
11
  buildDependency(key) {
11
- const deepDependency = this.get(key);
12
- if (this.isAdapterDependency(deepDependency.dependency)) {
13
- return new deepDependency.dependency.value(...deepDependency.constructor);
14
- }
15
- if (this.isConstantDependency(deepDependency.dependency)) {
16
- return deepDependency.dependency.value;
17
- }
12
+ return this.getInstance(key);
18
13
  }
19
14
  inject(dependency) {
20
15
  if (this.isServiceDependency(dependency)) {
@@ -107,14 +102,14 @@ class Container {
107
102
  throw new Error(`Unknown dependency type for key ${key.toString()}`);
108
103
  }
109
104
  async initDependencies() {
110
- var _a, _b;
105
+ var _a;
111
106
  const initialized = [];
112
107
  for await (const [key, dependency] of this.container) {
113
- if (this.isAdapterDependency(dependency) && ((_a = dependency.options) === null || _a === void 0 ? void 0 : _a.init) && !this.singletons.has(key)) {
108
+ if (this.isAdapterDependency(dependency) && ((_a = dependency.options) === null || _a === void 0 ? void 0 : _a.init) && !this.initializedKeys.has(key)) {
114
109
  const instance = this.getInstance(key);
115
110
  await (instance === null || instance === void 0 ? void 0 : instance.init());
116
111
  initialized.push(instance);
117
- this.singletons.set(key, { value: instance, init: (_b = dependency.options) === null || _b === void 0 ? void 0 : _b.init });
112
+ this.initializedKeys.add(key);
118
113
  }
119
114
  }
120
115
  return initialized;
@@ -20,6 +20,7 @@ type ContainerValue = {
20
20
  declare class Container {
21
21
  private readonly container;
22
22
  private readonly singletons;
23
+ private readonly initializedKeys;
23
24
  private buildDependency;
24
25
  private inject;
25
26
  private isServiceDependency;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lad-tech/nsc-toolkit",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "Toolkit for create microservices around NATS",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/types/index.d.ts",
@@ -15,7 +15,7 @@
15
15
  "@commitlint/cli": "^17.2.0",
16
16
  "@commitlint/config-conventional": "^17.2.0",
17
17
  "@semantic-release/changelog": "^6.0.2",
18
- "@semantic-release/npm": "^12.0.2",
18
+ "@semantic-release/npm": "^13.1.4",
19
19
  "@types/jest": "^27.5.2",
20
20
  "@types/node": "^22.13.13",
21
21
  "eslint": "^7.32.0",