@spinajs/di 2.0.180 → 2.0.182

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.
Files changed (60) hide show
  1. package/lib/cjs/array.d.ts +10 -10
  2. package/lib/cjs/array.js +13 -13
  3. package/lib/cjs/binder.d.ts +39 -39
  4. package/lib/cjs/binder.js +96 -96
  5. package/lib/cjs/container-cache.d.ts +17 -17
  6. package/lib/cjs/container-cache.js +63 -63
  7. package/lib/cjs/container.d.ts +133 -133
  8. package/lib/cjs/container.js +466 -466
  9. package/lib/cjs/container.js.map +1 -1
  10. package/lib/cjs/decorators.d.ts +141 -141
  11. package/lib/cjs/decorators.js +303 -303
  12. package/lib/cjs/enums.d.ts +31 -31
  13. package/lib/cjs/enums.js +35 -35
  14. package/lib/cjs/enums.js.map +1 -1
  15. package/lib/cjs/exceptions.d.ts +17 -17
  16. package/lib/cjs/exceptions.js +25 -25
  17. package/lib/cjs/helpers.d.ts +35 -35
  18. package/lib/cjs/helpers.js +86 -86
  19. package/lib/cjs/index.d.ts +12 -12
  20. package/lib/cjs/index.js +41 -41
  21. package/lib/cjs/interfaces.d.ts +172 -172
  22. package/lib/cjs/interfaces.js +53 -53
  23. package/lib/cjs/registry.d.ts +14 -14
  24. package/lib/cjs/registry.js +80 -80
  25. package/lib/cjs/root.d.ts +108 -108
  26. package/lib/cjs/root.js +216 -217
  27. package/lib/cjs/root.js.map +1 -1
  28. package/lib/cjs/types.d.ts +13 -13
  29. package/lib/cjs/types.js +2 -2
  30. package/lib/mjs/array.d.ts +10 -10
  31. package/lib/mjs/array.js +9 -9
  32. package/lib/mjs/binder.d.ts +39 -39
  33. package/lib/mjs/binder.js +92 -92
  34. package/lib/mjs/container-cache.d.ts +17 -17
  35. package/lib/mjs/container-cache.js +59 -59
  36. package/lib/mjs/container.d.ts +133 -133
  37. package/lib/mjs/container.js +459 -459
  38. package/lib/mjs/container.js.map +1 -1
  39. package/lib/mjs/decorators.d.ts +141 -141
  40. package/lib/mjs/decorators.js +266 -266
  41. package/lib/mjs/enums.d.ts +31 -31
  42. package/lib/mjs/enums.js +32 -32
  43. package/lib/mjs/enums.js.map +1 -1
  44. package/lib/mjs/exceptions.d.ts +17 -17
  45. package/lib/mjs/exceptions.js +19 -19
  46. package/lib/mjs/helpers.d.ts +35 -35
  47. package/lib/mjs/helpers.js +72 -72
  48. package/lib/mjs/index.d.ts +12 -12
  49. package/lib/mjs/index.js +12 -12
  50. package/lib/mjs/interfaces.d.ts +172 -172
  51. package/lib/mjs/interfaces.js +45 -45
  52. package/lib/mjs/registry.d.ts +14 -14
  53. package/lib/mjs/registry.js +76 -76
  54. package/lib/mjs/root.d.ts +108 -108
  55. package/lib/mjs/root.js +159 -159
  56. package/lib/mjs/types.d.ts +13 -13
  57. package/lib/mjs/types.js +1 -1
  58. package/lib/tsconfig.cjs.tsbuildinfo +1 -1
  59. package/lib/tsconfig.mjs.tsbuildinfo +1 -1
  60. package/package.json +2 -2
package/lib/mjs/binder.js CHANGED
@@ -1,93 +1,93 @@
1
- import { BindException } from './exceptions.js';
2
- import { ResolveType } from './enums.js';
3
- import { isFactory, isConstructor, getTypeName } from './helpers.js';
4
- import { DI } from './index.js';
5
- export class Binder {
6
- constructor(implementation, container) {
7
- this.implementation = implementation;
8
- this.container = container;
9
- this.isFactory = isFactory(implementation);
10
- this.isConstructor = isConstructor(implementation);
11
- }
12
- as(type) {
13
- this.container.Registry.register(type, this.implementation);
14
- const iType = getTypeName(this.implementation);
15
- const tType = getTypeName(type);
16
- this.container.emit(`di.registered.${iType}`, this.implementation);
17
- this.container.emit(`di.registered.${tType}`, this.implementation);
18
- return this;
19
- }
20
- /**
21
- * Add plain value to container. If value exists, it overrides content in container cache
22
- *
23
- * @param type - name of added value
24
- * @param override - if true, any value registered before is overriden by new one
25
- * @returns
26
- */
27
- asValue(type, override = false) {
28
- if (override) {
29
- if (this.container.Cache.has(type)) {
30
- this.container.Cache.remove(type);
31
- }
32
- }
33
- this.container.Cache.add(type, this.implementation);
34
- const tType = getTypeName(type);
35
- this.container.emit(`di.registered.${tType}`, this.implementation);
36
- return this;
37
- }
38
- /**
39
- *
40
- * Add plain value to container, value is stored in hashmap for quick access
41
- * eg. we have multiple value converters and we wanc o(1) access, instead searching for
42
- * converter for specific type
43
- *
44
- * @param type - name of added value
45
- * @param key - hashmap key
46
- */
47
- asMapValue(type, key) {
48
- let map = null;
49
- if (this.container.Cache.has(type)) {
50
- map = this.container.Cache.get(type)[0];
51
- }
52
- else {
53
- map = new Map();
54
- this.container.Cache.add(type, map);
55
- }
56
- map.set(key, this.implementation);
57
- const iType = getTypeName(this.implementation);
58
- const tType = getTypeName(type);
59
- this.container.emit(`di.registered.${iType}`, this.implementation);
60
- this.container.emit(`di.registered.${tType}`, this.implementation);
61
- return this;
62
- }
63
- /**
64
- * Register type as itself. Usefull when we also want to register type as self instead of base class
65
- * so we can retrieve just this specific instance.
66
- * @returns this
67
- */
68
- asSelf() {
69
- if (!this.isConstructor || this.isFactory) {
70
- throw new BindException('cannot register as self non class');
71
- }
72
- // we can safly cast to any, we checked params earlier
73
- this.container.Registry.register(this.implementation, this.implementation);
74
- const iType = getTypeName(this.implementation);
75
- this.container.emit(`di.registered.${iType}`, this.implementation);
76
- return this;
77
- }
78
- /**
79
- * Mark type as SingleInstance resolve strategy.
80
- * @returns this
81
- */
82
- singleInstance() {
83
- if (this.isFactory || !this.isConstructor) {
84
- throw new BindException('Cannot bind factory function as singleton.');
85
- }
86
- else {
87
- const descriptor = DI.RootContainer.extractDescriptor(this.implementation);
88
- descriptor.resolver = ResolveType.Singleton;
89
- }
90
- return this;
91
- }
92
- }
1
+ import { BindException } from './exceptions.js';
2
+ import { ResolveType } from './enums.js';
3
+ import { isFactory, isConstructor, getTypeName } from './helpers.js';
4
+ import { DI } from './index.js';
5
+ export class Binder {
6
+ constructor(implementation, container) {
7
+ this.implementation = implementation;
8
+ this.container = container;
9
+ this.isFactory = isFactory(implementation);
10
+ this.isConstructor = isConstructor(implementation);
11
+ }
12
+ as(type) {
13
+ this.container.Registry.register(type, this.implementation);
14
+ const iType = getTypeName(this.implementation);
15
+ const tType = getTypeName(type);
16
+ this.container.emit(`di.registered.${iType}`, this.implementation);
17
+ this.container.emit(`di.registered.${tType}`, this.implementation);
18
+ return this;
19
+ }
20
+ /**
21
+ * Add plain value to container. If value exists, it overrides content in container cache
22
+ *
23
+ * @param type - name of added value
24
+ * @param override - if true, any value registered before is overriden by new one
25
+ * @returns
26
+ */
27
+ asValue(type, override = false) {
28
+ if (override) {
29
+ if (this.container.Cache.has(type)) {
30
+ this.container.Cache.remove(type);
31
+ }
32
+ }
33
+ this.container.Cache.add(type, this.implementation);
34
+ const tType = getTypeName(type);
35
+ this.container.emit(`di.registered.${tType}`, this.implementation);
36
+ return this;
37
+ }
38
+ /**
39
+ *
40
+ * Add plain value to container, value is stored in hashmap for quick access
41
+ * eg. we have multiple value converters and we wanc o(1) access, instead searching for
42
+ * converter for specific type
43
+ *
44
+ * @param type - name of added value
45
+ * @param key - hashmap key
46
+ */
47
+ asMapValue(type, key) {
48
+ let map = null;
49
+ if (this.container.Cache.has(type)) {
50
+ map = this.container.Cache.get(type)[0];
51
+ }
52
+ else {
53
+ map = new Map();
54
+ this.container.Cache.add(type, map);
55
+ }
56
+ map.set(key, this.implementation);
57
+ const iType = getTypeName(this.implementation);
58
+ const tType = getTypeName(type);
59
+ this.container.emit(`di.registered.${iType}`, this.implementation);
60
+ this.container.emit(`di.registered.${tType}`, this.implementation);
61
+ return this;
62
+ }
63
+ /**
64
+ * Register type as itself. Usefull when we also want to register type as self instead of base class
65
+ * so we can retrieve just this specific instance.
66
+ * @returns this
67
+ */
68
+ asSelf() {
69
+ if (!this.isConstructor || this.isFactory) {
70
+ throw new BindException('cannot register as self non class');
71
+ }
72
+ // we can safly cast to any, we checked params earlier
73
+ this.container.Registry.register(this.implementation, this.implementation);
74
+ const iType = getTypeName(this.implementation);
75
+ this.container.emit(`di.registered.${iType}`, this.implementation);
76
+ return this;
77
+ }
78
+ /**
79
+ * Mark type as SingleInstance resolve strategy.
80
+ * @returns this
81
+ */
82
+ singleInstance() {
83
+ if (this.isFactory || !this.isConstructor) {
84
+ throw new BindException('Cannot bind factory function as singleton.');
85
+ }
86
+ else {
87
+ const descriptor = DI.RootContainer.extractDescriptor(this.implementation);
88
+ descriptor.resolver = ResolveType.Singleton;
89
+ }
90
+ return this;
91
+ }
92
+ }
93
93
  //# sourceMappingURL=binder.js.map
@@ -1,18 +1,18 @@
1
- import { TypedArray } from './array.js';
2
- import { IContainer } from './interfaces.js';
3
- import { Class } from './types.js';
4
- export declare class ContainerCache {
5
- private container;
6
- private cache;
7
- constructor(container: IContainer);
8
- [Symbol.iterator](): Generator<{
9
- key: string;
10
- value: any;
11
- }, void, unknown>;
12
- remove(key: string | Class<any> | TypedArray<any>, parent?: boolean): void;
13
- add(key: string | Class<any> | object, instance: any): void;
14
- has(key: string | Class<any> | object | TypedArray<any>, parent?: boolean): boolean;
15
- get(key: string | Class<any> | TypedArray<any>, parent?: boolean): any;
16
- clear(): void;
17
- }
1
+ import { TypedArray } from './array.js';
2
+ import { IContainer } from './interfaces.js';
3
+ import { Class } from './types.js';
4
+ export declare class ContainerCache {
5
+ private container;
6
+ private cache;
7
+ constructor(container: IContainer);
8
+ [Symbol.iterator](): Generator<{
9
+ key: string;
10
+ value: any;
11
+ }, void, unknown>;
12
+ remove(key: string | Class<any> | TypedArray<any>, parent?: boolean): void;
13
+ add(key: string | Class<any> | object, instance: any): void;
14
+ has(key: string | Class<any> | object | TypedArray<any>, parent?: boolean): boolean;
15
+ get(key: string | Class<any> | TypedArray<any>, parent?: boolean): any;
16
+ clear(): void;
17
+ }
18
18
  //# sourceMappingURL=container-cache.d.ts.map
@@ -1,60 +1,60 @@
1
- import { getTypeName } from './helpers.js';
2
- export class ContainerCache {
3
- constructor(container) {
4
- this.container = container;
5
- this.cache = new Map();
6
- // add to cache container
7
- // so we can inject container if needed
8
- this.add(container, container);
9
- }
10
- *[Symbol.iterator]() {
11
- for (const [key, value] of this.cache) {
12
- for (const v of value) {
13
- yield { key, value: v };
14
- }
15
- }
16
- }
17
- remove(key, parent) {
18
- if (this.has(key)) {
19
- this.cache.delete(getTypeName(key));
20
- }
21
- else if (parent && this.container.Parent) {
22
- this.container.Parent.uncache(key);
23
- }
24
- }
25
- add(key, instance) {
26
- const tName = getTypeName(key);
27
- if (this.has(key)) {
28
- if (this.cache.get(tName).indexOf(instance) === -1) {
29
- this.cache.get(tName).push(instance);
30
- }
31
- }
32
- else {
33
- this.cache.set(tName, [instance]);
34
- }
35
- }
36
- has(key, parent) {
37
- if (this.cache.has(getTypeName(key))) {
38
- return true;
39
- }
40
- if (parent && this.container.Parent) {
41
- return this.container.Parent.Cache.has(key, parent);
42
- }
43
- return false;
44
- }
45
- get(key, parent) {
46
- const tName = getTypeName(key);
47
- if (this.cache.has(tName)) {
48
- return this.cache.get(tName);
49
- }
50
- if (parent && this.container.Parent) {
51
- return this.container.Parent.Cache.get(key, parent);
52
- }
53
- return [];
54
- }
55
- clear() {
56
- this.cache.clear();
57
- this.add(this.container, this.container);
58
- }
59
- }
1
+ import { getTypeName } from './helpers.js';
2
+ export class ContainerCache {
3
+ constructor(container) {
4
+ this.container = container;
5
+ this.cache = new Map();
6
+ // add to cache container
7
+ // so we can inject container if needed
8
+ this.add(container, container);
9
+ }
10
+ *[Symbol.iterator]() {
11
+ for (const [key, value] of this.cache) {
12
+ for (const v of value) {
13
+ yield { key, value: v };
14
+ }
15
+ }
16
+ }
17
+ remove(key, parent) {
18
+ if (this.has(key)) {
19
+ this.cache.delete(getTypeName(key));
20
+ }
21
+ else if (parent && this.container.Parent) {
22
+ this.container.Parent.uncache(key);
23
+ }
24
+ }
25
+ add(key, instance) {
26
+ const tName = getTypeName(key);
27
+ if (this.has(key)) {
28
+ if (this.cache.get(tName).indexOf(instance) === -1) {
29
+ this.cache.get(tName).push(instance);
30
+ }
31
+ }
32
+ else {
33
+ this.cache.set(tName, [instance]);
34
+ }
35
+ }
36
+ has(key, parent) {
37
+ if (this.cache.has(getTypeName(key))) {
38
+ return true;
39
+ }
40
+ if (parent && this.container.Parent) {
41
+ return this.container.Parent.Cache.has(key, parent);
42
+ }
43
+ return false;
44
+ }
45
+ get(key, parent) {
46
+ const tName = getTypeName(key);
47
+ if (this.cache.has(tName)) {
48
+ return this.cache.get(tName);
49
+ }
50
+ if (parent && this.container.Parent) {
51
+ return this.container.Parent.Cache.get(key, parent);
52
+ }
53
+ return [];
54
+ }
55
+ clear() {
56
+ this.cache.clear();
57
+ this.add(this.container, this.container);
58
+ }
59
+ }
60
60
  //# sourceMappingURL=container-cache.js.map
@@ -1,134 +1,134 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import 'reflect-metadata';
3
- import { TypedArray } from './array.js';
4
- import { IBind, IContainer, IInjectDescriptor, IResolvedInjection, IToInject, AsyncService, ResolvableObject } from './interfaces.js';
5
- import { Class, Factory } from './types.js';
6
- import { EventEmitter } from 'events';
7
- import { Registry } from './registry.js';
8
- import { ContainerCache } from './container-cache.js';
9
- /**
10
- * Dependency injection container implementation
11
- */
12
- export declare class Container extends EventEmitter implements IContainer {
13
- /**
14
- * Handles information about what is registered as what
15
- * eg. that class IConfiguration should be resolved as DatabaseConfiguration etc.
16
- */
17
- private registry;
18
- /**
19
- * Singletons cache, objects that should be created only once are stored here.
20
- */
21
- private cache;
22
- /**
23
- * Parent container if avaible
24
- */
25
- private parent;
26
- /**
27
- * Returns container cache - map object with resolved classes as singletons
28
- */
29
- get Cache(): ContainerCache;
30
- get Registry(): Registry;
31
- get Parent(): IContainer;
32
- constructor(parent?: IContainer);
33
- /**
34
- * Clears container registry and cache. shorthand for container.clearCache() && container.clearRegistry()
35
- */
36
- clear(): void;
37
- dispose(): Promise<void>;
38
- /**
39
- * clears container registered types information
40
- */
41
- clearCache(): void;
42
- /**
43
- * Clears container resolved types
44
- */
45
- clearRegistry(): void;
46
- /**
47
- * Register class/interface to DI.
48
- * @param type - interface object to register
49
- * @throws {@link InvalidArgument} if type is null or undefined
50
- */
51
- register<T>(implementation: Class<T> | Factory<T> | ResolvableObject): IBind;
52
- unregister<T>(implementation: string | Class<T> | Factory<T> | ResolvableObject): void;
53
- uncache<T>(implementation: string | Class<T> | TypedArray<T>, parent?: boolean): void;
54
- /**
55
- * Creates child DI container.
56
- *
57
- */
58
- child(): IContainer;
59
- /**
60
- * Gets already resolved services. Works only for singleton classes.
61
- *
62
- * Do not try to get service by factory func, it will always return null.
63
- * If you somehowe want to cache instances created by factory functions,
64
- * factory itself should do that somehow and end user should always resolve by
65
- * assigned type
66
- *
67
- * @param serviceName - name of service to get
68
- * @returns null if no service has been resolved at given name
69
- */
70
- get<T>(service: TypedArray<T>, parent?: boolean): T[];
71
- get<T>(service: string | Class<T>, parent?: boolean): T;
72
- hasRegistered<T>(service: Class<T> | string, parent?: boolean): boolean;
73
- /**
74
- * Checks if service is already resolved and exists in container cache.
75
- * NOTE: check is only valid for classes that are singletons.
76
- *
77
- * @param service - service name or class to check
78
- * @returns true if service instance already exists, otherwise false.
79
- * @throws {@link InvalidArgument} when service is null or empty
80
- */
81
- isResolved<T>(service: string | Class<T> | TypedArray<T>, parent?: boolean): boolean;
82
- /**
83
- *
84
- * Resolves single instance of class
85
- *
86
- * @param type - what to resolve, can be class definition or factory function
87
- * @param options - options passed to constructor / factory
88
- */
89
- resolve<T>(type: string, options?: unknown[], check?: boolean, tType?: Class<T>): T;
90
- resolve<T>(type: string, check?: boolean): T;
91
- /**
92
- *
93
- * Resolves single instance of class
94
- *
95
- * @param type - what to resolve, can be class definition or factory function
96
- * @param options - options passed to constructor / factory
97
- */
98
- resolve<T>(type: Class<T>, options?: unknown[], check?: boolean): T extends AsyncService ? Promise<T> : T;
99
- resolve<T>(type: Class<T>, check?: boolean): T extends AsyncService ? Promise<T> : T;
100
- /**
101
- *
102
- * Resolves all instances of given class. Under single definition can be registered multiple implementations.
103
- *
104
- * @param type - typed array of specified type. since TS does not expose array metadata and type its uses TypedArray<T> consctruct
105
- * @param options - options passed to constructor / factory
106
- * @param check - strict check if serivice is registered in container before resolving. Default behavior is to not check and resolve
107
- *
108
- */
109
- resolve<T>(type: TypedArray<T>, options?: unknown[], check?: boolean): T extends AsyncService ? Promise<T[]> : T[];
110
- resolve<T>(type: TypedArray<T>, check?: boolean): T extends AsyncService ? Promise<T[]> : T[];
111
- getRegisteredTypes<T>(service: string | Class<T> | TypedArray<T>, parent?: boolean): (Class<unknown> | Factory<unknown>)[];
112
- private resolveType;
113
- protected getNewInstance(typeToCreate: Class<unknown> | Factory<unknown>, a?: IResolvedInjection[], options?: unknown[]): Promise<unknown> | unknown;
114
- hasRegisteredType<T>(source: Class<T> | string, type: Class<T> | string | TypedArray<T>, parent?: boolean): boolean;
115
- protected resolveDependencies(toInject: IToInject<unknown>[]): (Promise<{
116
- autoinject: boolean;
117
- autoinjectKey: string;
118
- instance: any;
119
- }> | {
120
- autoinject: boolean;
121
- autoinjectKey: string;
122
- instance: any;
123
- })[] | Promise<({
124
- autoinject: boolean;
125
- autoinjectKey: string;
126
- instance: any;
127
- } | {
128
- autoinject: boolean;
129
- autoinjectKey: string;
130
- instance: any;
131
- })[]>;
132
- extractDescriptor(type: Class<unknown>): IInjectDescriptor<unknown>;
133
- }
1
+ /// <reference types="node" resolution-mode="require"/>
2
+ import 'reflect-metadata';
3
+ import { TypedArray } from './array.js';
4
+ import { IBind, IContainer, IInjectDescriptor, IResolvedInjection, IToInject, AsyncService, ResolvableObject } from './interfaces.js';
5
+ import { Class, Factory } from './types.js';
6
+ import { EventEmitter } from 'events';
7
+ import { Registry } from './registry.js';
8
+ import { ContainerCache } from './container-cache.js';
9
+ /**
10
+ * Dependency injection container implementation
11
+ */
12
+ export declare class Container extends EventEmitter implements IContainer {
13
+ /**
14
+ * Handles information about what is registered as what
15
+ * eg. that class IConfiguration should be resolved as DatabaseConfiguration etc.
16
+ */
17
+ private registry;
18
+ /**
19
+ * Singletons cache, objects that should be created only once are stored here.
20
+ */
21
+ private cache;
22
+ /**
23
+ * Parent container if avaible
24
+ */
25
+ private parent;
26
+ /**
27
+ * Returns container cache - map object with resolved classes as singletons
28
+ */
29
+ get Cache(): ContainerCache;
30
+ get Registry(): Registry;
31
+ get Parent(): IContainer;
32
+ constructor(parent?: IContainer);
33
+ /**
34
+ * Clears container registry and cache. shorthand for container.clearCache() && container.clearRegistry()
35
+ */
36
+ clear(): void;
37
+ dispose(): Promise<void>;
38
+ /**
39
+ * clears container registered types information
40
+ */
41
+ clearCache(): void;
42
+ /**
43
+ * Clears container resolved types
44
+ */
45
+ clearRegistry(): void;
46
+ /**
47
+ * Register class/interface to DI.
48
+ * @param type - interface object to register
49
+ * @throws {@link InvalidArgument} if type is null or undefined
50
+ */
51
+ register<T>(implementation: Class<T> | Factory<T> | ResolvableObject): IBind;
52
+ unregister<T>(implementation: string | Class<T> | Factory<T> | ResolvableObject): void;
53
+ uncache<T>(implementation: string | Class<T> | TypedArray<T>, parent?: boolean): void;
54
+ /**
55
+ * Creates child DI container.
56
+ *
57
+ */
58
+ child(): IContainer;
59
+ /**
60
+ * Gets already resolved services. Works only for singleton classes.
61
+ *
62
+ * Do not try to get service by factory func, it will always return null.
63
+ * If you somehowe want to cache instances created by factory functions,
64
+ * factory itself should do that somehow and end user should always resolve by
65
+ * assigned type
66
+ *
67
+ * @param serviceName - name of service to get
68
+ * @returns null if no service has been resolved at given name
69
+ */
70
+ get<T>(service: TypedArray<T>, parent?: boolean): T[];
71
+ get<T>(service: string | Class<T>, parent?: boolean): T;
72
+ hasRegistered<T>(service: Class<T> | string, parent?: boolean): boolean;
73
+ /**
74
+ * Checks if service is already resolved and exists in container cache.
75
+ * NOTE: check is only valid for classes that are singletons.
76
+ *
77
+ * @param service - service name or class to check
78
+ * @returns true if service instance already exists, otherwise false.
79
+ * @throws {@link InvalidArgument} when service is null or empty
80
+ */
81
+ isResolved<T>(service: string | Class<T> | TypedArray<T>, parent?: boolean): boolean;
82
+ /**
83
+ *
84
+ * Resolves single instance of class
85
+ *
86
+ * @param type - what to resolve, can be class definition or factory function
87
+ * @param options - options passed to constructor / factory
88
+ */
89
+ resolve<T>(type: string, options?: unknown[], check?: boolean, tType?: Class<T>): T;
90
+ resolve<T>(type: string, check?: boolean): T;
91
+ /**
92
+ *
93
+ * Resolves single instance of class
94
+ *
95
+ * @param type - what to resolve, can be class definition or factory function
96
+ * @param options - options passed to constructor / factory
97
+ */
98
+ resolve<T>(type: Class<T>, options?: unknown[], check?: boolean): T extends AsyncService ? Promise<T> : T;
99
+ resolve<T>(type: Class<T>, check?: boolean): T extends AsyncService ? Promise<T> : T;
100
+ /**
101
+ *
102
+ * Resolves all instances of given class. Under single definition can be registered multiple implementations.
103
+ *
104
+ * @param type - typed array of specified type. since TS does not expose array metadata and type its uses TypedArray<T> consctruct
105
+ * @param options - options passed to constructor / factory
106
+ * @param check - strict check if serivice is registered in container before resolving. Default behavior is to not check and resolve
107
+ *
108
+ */
109
+ resolve<T>(type: TypedArray<T>, options?: unknown[], check?: boolean): T extends AsyncService ? Promise<T[]> : T[];
110
+ resolve<T>(type: TypedArray<T>, check?: boolean): T extends AsyncService ? Promise<T[]> : T[];
111
+ getRegisteredTypes<T>(service: string | Class<T> | TypedArray<T>, parent?: boolean): (Class<unknown> | Factory<unknown>)[];
112
+ private resolveType;
113
+ protected getNewInstance(typeToCreate: Class<unknown> | Factory<unknown>, a?: IResolvedInjection[], options?: unknown[]): Promise<unknown> | unknown;
114
+ hasRegisteredType<T>(source: Class<T> | string, type: Class<T> | string | TypedArray<T>, parent?: boolean): boolean;
115
+ protected resolveDependencies(toInject: IToInject<unknown>[]): (Promise<{
116
+ autoinject: boolean;
117
+ autoinjectKey: string;
118
+ instance: any;
119
+ }> | {
120
+ autoinject: boolean;
121
+ autoinjectKey: string;
122
+ instance: any;
123
+ })[] | Promise<({
124
+ autoinject: boolean;
125
+ autoinjectKey: string;
126
+ instance: any;
127
+ } | {
128
+ autoinject: boolean;
129
+ autoinjectKey: string;
130
+ instance: any;
131
+ })[]>;
132
+ extractDescriptor(type: Class<unknown>): IInjectDescriptor<unknown>;
133
+ }
134
134
  //# sourceMappingURL=container.d.ts.map