ts-ioc-container 69.1.0 → 69.2.0

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.
@@ -41,5 +41,8 @@ class ClassToken extends InjectionToken_1.InjectionToken {
41
41
  isLazy: true,
42
42
  });
43
43
  }
44
+ getKey() {
45
+ return this.target;
46
+ }
44
47
  }
45
48
  exports.ClassToken = ClassToken;
@@ -21,5 +21,8 @@ class ConstantToken extends InjectionToken_1.InjectionToken {
21
21
  lazy() {
22
22
  throw new MethodNotImplementedError_1.MethodNotImplementedError('not implemented');
23
23
  }
24
+ getKey() {
25
+ throw new MethodNotImplementedError_1.MethodNotImplementedError('not implemented');
26
+ }
24
27
  }
25
28
  exports.ConstantToken = ConstantToken;
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.FunctionToken = void 0;
4
4
  const InjectionToken_1 = require("./InjectionToken");
5
+ const MethodNotImplementedError_1 = require("../errors/MethodNotImplementedError");
5
6
  class FunctionToken extends InjectionToken_1.InjectionToken {
6
7
  fn;
7
8
  _getArgsFn;
@@ -38,5 +39,8 @@ class FunctionToken extends InjectionToken_1.InjectionToken {
38
39
  isLazy: true,
39
40
  });
40
41
  }
42
+ getKey() {
43
+ throw new MethodNotImplementedError_1.MethodNotImplementedError('not implemented');
44
+ }
41
45
  }
42
46
  exports.FunctionToken = FunctionToken;
@@ -44,6 +44,9 @@ class GroupAliasToken extends InjectionToken_1.InjectionToken {
44
44
  isLazy: true,
45
45
  });
46
46
  }
47
+ getKey() {
48
+ return this.token;
49
+ }
47
50
  }
48
51
  exports.GroupAliasToken = GroupAliasToken;
49
52
  const toGroupAlias = (token) => new GroupAliasToken(token);
@@ -29,5 +29,8 @@ class GroupInstanceToken extends InjectionToken_1.InjectionToken {
29
29
  resolve(c) {
30
30
  return c.getInstances(this.isCascade).filter(this.predicate);
31
31
  }
32
+ getKey() {
33
+ throw new MethodNotImplementedError_1.MethodNotImplementedError('not implemented');
34
+ }
32
35
  }
33
36
  exports.GroupInstanceToken = GroupInstanceToken;
@@ -44,6 +44,9 @@ class SingleAliasToken extends InjectionToken_1.InjectionToken {
44
44
  isLazy: true,
45
45
  });
46
46
  }
47
+ getKey() {
48
+ return this.token;
49
+ }
47
50
  }
48
51
  exports.SingleAliasToken = SingleAliasToken;
49
52
  const toSingleAlias = (token) => new SingleAliasToken(token);
@@ -44,5 +44,8 @@ class SingleToken extends InjectionToken_1.InjectionToken {
44
44
  isLazy: true,
45
45
  });
46
46
  }
47
+ getKey() {
48
+ return this.token;
49
+ }
47
50
  }
48
51
  exports.SingleToken = SingleToken;
@@ -38,4 +38,7 @@ export class ClassToken extends InjectionToken {
38
38
  isLazy: true,
39
39
  });
40
40
  }
41
+ getKey() {
42
+ return this.target;
43
+ }
41
44
  }
@@ -18,4 +18,7 @@ export class ConstantToken extends InjectionToken {
18
18
  lazy() {
19
19
  throw new MethodNotImplementedError('not implemented');
20
20
  }
21
+ getKey() {
22
+ throw new MethodNotImplementedError('not implemented');
23
+ }
21
24
  }
@@ -1,4 +1,5 @@
1
1
  import { forwardArgs, InjectionToken } from './InjectionToken.js';
2
+ import { MethodNotImplementedError } from '../errors/MethodNotImplementedError.js';
2
3
  export class FunctionToken extends InjectionToken {
3
4
  fn;
4
5
  _getArgsFn;
@@ -35,4 +36,7 @@ export class FunctionToken extends InjectionToken {
35
36
  isLazy: true,
36
37
  });
37
38
  }
39
+ getKey() {
40
+ throw new MethodNotImplementedError('not implemented');
41
+ }
38
42
  }
@@ -41,5 +41,8 @@ export class GroupAliasToken extends InjectionToken {
41
41
  isLazy: true,
42
42
  });
43
43
  }
44
+ getKey() {
45
+ return this.token;
46
+ }
44
47
  }
45
48
  export const toGroupAlias = (token) => new GroupAliasToken(token);
@@ -26,4 +26,7 @@ export class GroupInstanceToken extends InjectionToken {
26
26
  resolve(c) {
27
27
  return c.getInstances(this.isCascade).filter(this.predicate);
28
28
  }
29
+ getKey() {
30
+ throw new MethodNotImplementedError('not implemented');
31
+ }
29
32
  }
@@ -41,5 +41,8 @@ export class SingleAliasToken extends InjectionToken {
41
41
  isLazy: true,
42
42
  });
43
43
  }
44
+ getKey() {
45
+ return this.token;
46
+ }
44
47
  }
45
48
  export const toSingleAlias = (token) => new SingleAliasToken(token);
@@ -41,4 +41,7 @@ export class SingleToken extends InjectionToken {
41
41
  isLazy: true,
42
42
  });
43
43
  }
44
+ getKey() {
45
+ return this.token;
46
+ }
44
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ts-ioc-container",
3
- "version": "69.1.0",
3
+ "version": "69.2.0",
4
4
  "description": "Fast, lightweight TypeScript dependency injection container with a clean API, scoped lifecycles, decorators, tokens, hooks, lazy injection, customizable providers, and no global container objects.",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -15,4 +15,5 @@ export declare class ClassToken<T = any> extends InjectionToken<T> {
15
15
  args(...newArgs: unknown[]): ClassToken<T>;
16
16
  argsFn(fn: (s: IContainer) => unknown[]): ClassToken<T>;
17
17
  lazy(): ClassToken<T>;
18
+ getKey(): constructor<T>;
18
19
  }
@@ -1,5 +1,6 @@
1
- import type { IContainer } from '../container/IContainer.js';
1
+ import type { DependencyKey, IContainer } from '../container/IContainer.js';
2
2
  import { InjectionToken } from './InjectionToken.js';
3
+ import { type constructor } from '../utils/basic.js';
3
4
  export declare class ConstantToken<T = any> extends InjectionToken<T> {
4
5
  private readonly token;
5
6
  constructor(token: T);
@@ -7,4 +8,5 @@ export declare class ConstantToken<T = any> extends InjectionToken<T> {
7
8
  args(...deps: unknown[]): InjectionToken<T>;
8
9
  argsFn(getArgsFn: (s: IContainer) => unknown[]): InjectionToken<T>;
9
10
  lazy(): InjectionToken<T>;
11
+ getKey(): DependencyKey | constructor<T>;
10
12
  }
@@ -1,7 +1,8 @@
1
- import type { IContainer } from '../container/IContainer.js';
1
+ import type { DependencyKey, IContainer } from '../container/IContainer.js';
2
2
  import { InjectionToken } from './InjectionToken.js';
3
3
  import { InjectFn } from '../hooks/hook.js';
4
4
  import { ArgsFn, ProviderOptions } from '../provider/IProvider.js';
5
+ import { type constructor } from '../utils/basic.js';
5
6
  export declare class FunctionToken<T = any> extends InjectionToken<T> {
6
7
  private readonly fn;
7
8
  private readonly _getArgsFn;
@@ -14,4 +15,5 @@ export declare class FunctionToken<T = any> extends InjectionToken<T> {
14
15
  args(...newArgs: unknown[]): InjectionToken<T>;
15
16
  argsFn(fn: (s: IContainer) => unknown[]): InjectionToken<T>;
16
17
  lazy(): InjectionToken<T>;
18
+ getKey(): DependencyKey | constructor<T>;
17
19
  }
@@ -17,5 +17,6 @@ export declare class GroupAliasToken<T = any> extends InjectionToken<T[]> implem
17
17
  args(...newArgs: unknown[]): GroupAliasToken<T>;
18
18
  argsFn(fn: (s: IContainer) => unknown[]): GroupAliasToken<T>;
19
19
  lazy(): GroupAliasToken<T>;
20
+ getKey(): DependencyKey;
20
21
  }
21
22
  export declare const toGroupAlias: <T>(token: DependencyKey) => GroupAliasToken<T>;
@@ -1,6 +1,6 @@
1
1
  import { InjectionToken } from './InjectionToken.js';
2
- import type { IContainer } from '../container/IContainer.js';
3
- import { Instance } from '../utils/basic.js';
2
+ import type { DependencyKey, IContainer } from '../container/IContainer.js';
3
+ import { type constructor, Instance } from '../utils/basic.js';
4
4
  export type InstancePredicate = (dep: unknown) => boolean;
5
5
  export declare class GroupInstanceToken extends InjectionToken<Instance[]> {
6
6
  private predicate;
@@ -12,4 +12,5 @@ export declare class GroupInstanceToken extends InjectionToken<Instance[]> {
12
12
  lazy(): InjectionToken<Instance[]>;
13
13
  cascade(isTrue: boolean): this;
14
14
  resolve(c: IContainer): Instance[];
15
+ getKey(): DependencyKey | constructor<Instance[]>;
15
16
  }
@@ -1,10 +1,12 @@
1
- import { type IContainer } from '../container/IContainer.js';
1
+ import { type DependencyKey, type IContainer } from '../container/IContainer.js';
2
2
  import { ArgsFn, ProviderOptions } from '../provider/IProvider.js';
3
+ import { type constructor } from '../utils/basic.js';
3
4
  export declare const forwardArgs: ArgsFn;
4
5
  export declare abstract class InjectionToken<T = any> {
5
6
  abstract resolve(s: IContainer, options?: ProviderOptions): T;
6
7
  abstract args(...deps: unknown[]): InjectionToken<T>;
7
8
  abstract argsFn(getArgsFn: (s: IContainer) => unknown[]): InjectionToken<T>;
8
9
  abstract lazy(): InjectionToken<T>;
10
+ abstract getKey(): DependencyKey | constructor<T>;
9
11
  }
10
12
  export declare function isInjectionToken(target: unknown): target is InjectionToken;
@@ -17,5 +17,6 @@ export declare class SingleAliasToken<T = any> extends InjectionToken<T> impleme
17
17
  args(...newArgs: unknown[]): SingleAliasToken<T>;
18
18
  argsFn(fn: (s: IContainer) => unknown[]): SingleAliasToken<T>;
19
19
  lazy(): SingleAliasToken<T>;
20
+ getKey(): DependencyKey;
20
21
  }
21
22
  export declare const toSingleAlias: <T>(token: DependencyKey) => SingleAliasToken<T>;
@@ -16,4 +16,5 @@ export declare class SingleToken<T = any> extends InjectionToken<T> {
16
16
  args(...newArgs: unknown[]): SingleToken<T>;
17
17
  argsFn(fn: (s: IContainer) => unknown[]): SingleToken<T>;
18
18
  lazy(): SingleToken<T>;
19
+ getKey(): DependencyKey;
19
20
  }