@spinajs/di 1.1.7 → 1.2.7

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.
@@ -1,4 +1,6 @@
1
- export declare const DI_DESCRIPTION_SYMBOL: unique symbol;
1
+ import { Class } from './types';
2
+ import { TypedArray } from './array';
3
+ export declare const DI_DESCRIPTION_SYMBOL = "__DI_INJECTION_DESCRIPTOR__";
2
4
  /**
3
5
  *
4
6
  * Class with this decorator is automatically registered in DI container an can be resolved.
@@ -6,7 +8,7 @@ export declare const DI_DESCRIPTION_SYMBOL: unique symbol;
6
8
  * to register implementation that can be resolved by framework or other parts without knowing about specific implementations eg.
7
9
  * avaible database drivers.
8
10
  *
9
- * @param as register class in DI container as something else.
11
+ * @param as - register class in DI container as something else.
10
12
  *
11
13
  * @example
12
14
  * ```typescript
@@ -25,7 +27,7 @@ export declare const DI_DESCRIPTION_SYMBOL: unique symbol;
25
27
  * ```
26
28
  *
27
29
  */
28
- export declare function Injectable(as?: Class | string): (target: any) => void;
30
+ export declare function Injectable(as?: Class<unknown> | string): (target: Class<unknown>) => void;
29
31
  /**
30
32
  * Sets dependency injection guidelines - what to inject for specified class. If multiple instances are registered at specified type,
31
33
  * only first one is resolved and injected
@@ -52,13 +54,12 @@ export declare function Injectable(as?: Class | string): (target: any) => void;
52
54
  *
53
55
  * ```
54
56
  */
55
- export declare function Inject(...args: (Class | TypedArray<any>)[]): any;
57
+ export declare function Inject(...args: (Class<any> | TypedArray<any>)[]): any;
56
58
  /**
57
59
  * Automatically injects dependency based on reflected property type. Uses experimental typescript reflection api
58
60
  * If decorator is applied to array property all registered type instances are injected, otherwise only first / only that exists
59
61
  *
60
- * @param target
61
- * @param key
62
+ * @param injectType - when injecting array of some type, type must be explicitly provided. Typescript reflection cant reflect declared array types
62
63
  * @example
63
64
  * ```javascript
64
65
  * class Foo{
@@ -79,7 +80,7 @@ export declare function Inject(...args: (Class | TypedArray<any>)[]): any;
79
80
  *
80
81
  * ```
81
82
  */
82
- export declare function Autoinject(injectType?: Class): any;
83
+ export declare function Autoinject(injectType?: Class<unknown>): any;
83
84
  /**
84
85
  * Lazy injects service to object. Use only with class properties
85
86
  *
@@ -102,7 +103,7 @@ export declare function Autoinject(injectType?: Class): any;
102
103
  *
103
104
  * ```
104
105
  */
105
- export declare function LazyInject(service: Class | string): (target?: any, key?: string) => void;
106
+ export declare function LazyInject(service: Class<any> | string): (target?: any, key?: string) => void;
106
107
  /**
107
108
  * Per child instance injection decorator - object is resolved once per container - child containers have own instances.
108
109
  */
package/lib/decorators.js CHANGED
@@ -2,17 +2,17 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Singleton = exports.NewInstance = exports.PerChildInstance = exports.LazyInject = exports.Autoinject = exports.Inject = exports.Injectable = exports.DI_DESCRIPTION_SYMBOL = void 0;
4
4
  const enums_1 = require("./enums");
5
- const root_1 = require("./root");
6
- exports.DI_DESCRIPTION_SYMBOL = Symbol.for('DI_INJECTION_DESCRIPTOR');
5
+ const DI = require("./root");
6
+ exports.DI_DESCRIPTION_SYMBOL = '__DI_INJECTION_DESCRIPTOR__';
7
7
  function AddDependency(callback) {
8
8
  return (target, propertyKey, indexOrDescriptor) => {
9
- let descriptor = target[exports.DI_DESCRIPTION_SYMBOL];
9
+ let descriptor = target.__DI_INJECTION_DESCRIPTOR__;
10
10
  if (!descriptor) {
11
11
  descriptor = {
12
12
  inject: [],
13
13
  resolver: enums_1.ResolveType.Singleton,
14
14
  };
15
- target[exports.DI_DESCRIPTION_SYMBOL] = descriptor;
15
+ target[`${exports.DI_DESCRIPTION_SYMBOL}`] = descriptor;
16
16
  }
17
17
  if (callback) {
18
18
  callback(descriptor, target, propertyKey, indexOrDescriptor);
@@ -26,7 +26,7 @@ function AddDependency(callback) {
26
26
  * to register implementation that can be resolved by framework or other parts without knowing about specific implementations eg.
27
27
  * avaible database drivers.
28
28
  *
29
- * @param as register class in DI container as something else.
29
+ * @param as - register class in DI container as something else.
30
30
  *
31
31
  * @example
32
32
  * ```typescript
@@ -48,10 +48,10 @@ function AddDependency(callback) {
48
48
  function Injectable(as) {
49
49
  return (target) => {
50
50
  if (as) {
51
- root_1.DI.register(target).as(as);
51
+ DI.register(target).as(as);
52
52
  }
53
53
  else {
54
- root_1.DI.register(target).asSelf();
54
+ DI.register(target).asSelf();
55
55
  }
56
56
  };
57
57
  }
@@ -98,8 +98,7 @@ exports.Inject = Inject;
98
98
  * Automatically injects dependency based on reflected property type. Uses experimental typescript reflection api
99
99
  * If decorator is applied to array property all registered type instances are injected, otherwise only first / only that exists
100
100
  *
101
- * @param target
102
- * @param key
101
+ * @param injectType - when injecting array of some type, type must be explicitly provided. Typescript reflection cant reflect declared array types
103
102
  * @example
104
103
  * ```javascript
105
104
  * class Foo{
@@ -162,10 +161,10 @@ function LazyInject(service) {
162
161
  // property getter
163
162
  const getter = () => {
164
163
  if (typeof service === 'string') {
165
- return root_1.DI.get(service);
164
+ return DI.get(service);
166
165
  }
167
166
  else {
168
- return root_1.DI.resolve(service);
167
+ return DI.resolve(service);
169
168
  }
170
169
  };
171
170
  // Create new property with getter and setter
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../src/decorators.ts"],"names":[],"mappings":";;;AAAA,mCAAsC;AAEtC,iCAA4B;AAEf,QAAA,qBAAqB,GAAG,MAAM,CAAC,GAAG,CAAC,yBAAyB,CAAC,CAAC;AAE3E,SAAS,aAAa,CACpB,QAKS;IAET,OAAO,CAAC,MAAW,EAAE,WAA4B,EAAE,iBAA8C,EAAE,EAAE;QACnG,IAAI,UAAU,GAA2B,MAAM,CAAC,6BAAqB,CAAC,CAAC;QACvE,IAAI,CAAC,UAAU,EAAE;YACf,UAAU,GAAG;gBACX,MAAM,EAAE,EAAE;gBACV,QAAQ,EAAE,mBAAW,CAAC,SAAS;aAChC,CAAC;YAEF,MAAM,CAAC,6BAAqB,CAAC,GAAG,UAAU,CAAC;SAC5C;QAED,IAAI,QA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AM,EAAE,GAAG,EAAE;YACjC,YAAY,EAAE,IAAI;YAClB,UAAU,EAAE,KAAK;YACjB,GAAG,EAAE,MAAM;SACZ,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAlBD,gCAkBC;AAED;;GAEG;AACH,SAAgB,gBAAgB;IAC9B,OAAO,aAAa,CAAC,CAAC,UAAsC,EAAE,EAAE;QAC9D,UAAU,CAAC,QAAQ,GAAG,mBAAW,CAAC,iBAAiB,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,4CAIC;AAED;;GAEG;AACH,SAAgB,WAAW;IACzB,OAAO,aAAa,CAAC,CAAC,UAAsC,EAAE,EAAE;QAC9D,UAAU,CAAC,QAAQ,GAAG,mBAAW,CAAC,WAAW,CAAC;IAChD,CAAC,CAAC,CAAC;AACL,CAAC;AAJD,kCAIC;AAED;;GAEG;AACH,SAAgB,SAAS;IACvB,OAAO,aAAa,EAAE,CAAC;AACzB,CAAC;AAFD,8BAEC"}
package/lib/enums.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  /**
2
2
  * How to resolve class
3
- * @enum
4
3
  */
5
4
  export declare enum ResolveType {
6
5
  /**
package/lib/enums.js CHANGED
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ResolveType = void 0;
4
4
  /**
5
5
  * How to resolve class
6
- * @enum
7
6
  */
8
7
  var ResolveType;
9
8
  (function (ResolveType) {
package/lib/enums.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,WAeX;AAfD,WAAY,WAAW;IACrB;;OAEG;IACH,uDAAS,CAAA;IAET;;OAEG;IACH,2DAAW,CAAA;IAEX;;OAEG;IACH,uEAAiB,CAAA;AACnB,CAAC,EAfW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAetB"}
1
+ {"version":3,"file":"enums.js","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,WAeX;AAfD,WAAY,WAAW;IACrB;;OAEG;IACH,uDAAS,CAAA;IAET;;OAEG;IACH,2DAAW,CAAA;IAEX;;OAEG;IACH,uEAAiB,CAAA;AACnB,CAAC,EAfW,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAetB"}
@@ -8,3 +8,5 @@ export declare class ResolveException extends Error {
8
8
  */
9
9
  constructor(message?: string);
10
10
  }
11
+ export declare class BindException extends Error {
12
+ }
package/lib/exceptions.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResolveException = void 0;
3
+ exports.BindException = exports.ResolveException = void 0;
4
4
  /**
5
5
  * Exception thrown when cannot resolve type
6
6
  */
@@ -14,4 +14,7 @@ class ResolveException extends Error {
14
14
  }
15
15
  }
16
16
  exports.ResolveException = ResolveException;
17
+ class BindException extends Error {
18
+ }
19
+ exports.BindException = BindException;
17
20
  //# sourceMappingURL=exceptions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,gBAAiB,SAAQ,KAAK;IACvC;;;OAGG;IACH,YAAY,OAAgB;QACxB,KAAK,CAAC,OAAO,CAAC,CAAC;IACnB,CAAC;CACJ;AARD,4CAQC"}
1
+ {"version":3,"file":"exceptions.js","sourceRoot":"","sources":["../src/exceptions.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,MAAa,gBAAiB,SAAQ,KAAK;IACzC;;;OAGG;IACH,YAAY,OAAgB;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;IACjB,CAAC;CACF;AARD,4CAQC;AAED,MAAa,aAAc,SAAQ,KAAK;CAAG;AAA3C,sCAA2C"}
package/lib/helpers.d.ts CHANGED
@@ -1,7 +1,18 @@
1
+ import { TypedArray } from './array';
2
+ import { AsyncModule, SyncModule } from './interfaces';
3
+ import { Factory, Class } from './types';
1
4
  /**
2
5
  * Checks if value is constructable type.
3
6
  * Checks for [[Construct]] internal function in object.
4
7
  *
5
8
  * @param value - value to test
6
9
  */
7
- export declare function isConstructor(value: any): boolean;
10
+ export declare function isConstructor(value: any): value is Class<unknown>;
11
+ export declare function isFactory(value: any): value is Factory<any>;
12
+ export declare function isObject(value: any): value is object;
13
+ export declare function isAsyncModule(value: any): value is AsyncModule;
14
+ export declare function isPromise(value: any): value is Promise<any>;
15
+ export declare function isSyncModule(value: any): value is SyncModule;
16
+ export declare function isTypedArray(value: any): value is TypedArray<any>;
17
+ export declare function uniqBy<T>(arr: T[], comparator: (a: T, b: T) => boolean): T[];
18
+ export declare function getTypeName(type: TypedArray<any> | Class<any> | string | object): string;
package/lib/helpers.js CHANGED
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isConstructor = void 0;
3
+ exports.getTypeName = exports.uniqBy = exports.isTypedArray = exports.isSyncModule = exports.isPromise = exports.isAsyncModule = exports.isObject = exports.isFactory = exports.isConstructor = void 0;
4
+ const array_1 = require("./array");
5
+ const interfaces_1 = require("./interfaces");
4
6
  /**
5
7
  * Checks if value is constructable type.
6
8
  * Checks for [[Construct]] internal function in object.
@@ -17,4 +19,42 @@ function isConstructor(value) {
17
19
  return true;
18
20
  }
19
21
  exports.isConstructor = isConstructor;
22
+ function isFactory(value) {
23
+ return !isConstructor(value) && typeof value === 'function';
24
+ }
25
+ exports.isFactory = isFactory;
26
+ function isObject(value) {
27
+ return typeof value === 'object';
28
+ }
29
+ exports.isObject = isObject;
30
+ function isAsyncModule(value) {
31
+ return value instanceof interfaces_1.AsyncModule;
32
+ }
33
+ exports.isAsyncModule = isAsyncModule;
34
+ function isPromise(value) {
35
+ return Boolean(value && typeof value.then === 'function');
36
+ }
37
+ exports.isPromise = isPromise;
38
+ function isSyncModule(value) {
39
+ return value instanceof interfaces_1.SyncModule;
40
+ }
41
+ exports.isSyncModule = isSyncModule;
42
+ function isTypedArray(value) {
43
+ return value instanceof array_1.TypedArray;
44
+ }
45
+ exports.isTypedArray = isTypedArray;
46
+ function uniqBy(arr, comparator) {
47
+ const uniques = [];
48
+ for (const a of arr) {
49
+ if (uniques.findIndex((u) => comparator(a, u)) === -1) {
50
+ uniques.push(a);
51
+ }
52
+ }
53
+ return uniques;
54
+ }
55
+ exports.uniqBy = uniqBy;
56
+ function getTypeName(type) {
57
+ return typeof type === 'string' ? type : type instanceof array_1.TypedArray ? type.Type.name : isConstructor(type) ? type.name : type.constructor.name;
58
+ }
59
+ exports.getTypeName = getTypeName;
20
60
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,KAAU;IACtC,IAAI;QACF,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;KACtC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AARD,sCAQC"}
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;;AAAA,mCAAqC;AACrC,6CAAuD;AAGvD;;;;;GAKG;AACH,SAAgB,aAAa,CAAC,KAAU;IACtC,IAAI;QACF,OAAO,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC;KACtC;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,KAAK,CAAC;KACd;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AARD,sCAQC;AAED,SAAgB,SAAS,CAAC,KAAU;IAClC,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,KAAK,UAAU,CAAC;AAC9D,CAAC;AAFD,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/index.d.ts CHANGED
@@ -4,6 +4,9 @@ export * from './decorators';
4
4
  export * from './enums';
5
5
  export * from './types';
6
6
  export * from './helpers';
7
+ export * from './container-cache';
8
+ export * from './binder';
9
+ export * from './registry';
7
10
  export * from './container';
8
- export * from './root';
11
+ export * as DI from './root';
9
12
  export * from './exceptions';
package/lib/index.js CHANGED
@@ -10,13 +10,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
10
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
11
  };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.DI = void 0;
13
14
  __exportStar(require("./interfaces"), exports);
14
15
  __exportStar(require("./array"), exports);
15
16
  __exportStar(require("./decorators"), exports);
16
17
  __exportStar(require("./enums"), exports);
17
18
  __exportStar(require("./types"), exports);
18
19
  __exportStar(require("./helpers"), exports);
20
+ __exportStar(require("./container-cache"), exports);
21
+ __exportStar(require("./binder"), exports);
22
+ __exportStar(require("./registry"), exports);
19
23
  __exportStar(require("./container"), exports);
20
- __exportStar(require("./root"), exports);
24
+ exports.DI = require("./root");
21
25
  __exportStar(require("./exceptions"), exports);
22
26
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAA6B;AAC7B,0CAAwB;AACxB,+CAA6B;AAC7B,0CAAwB;AACxB,0CAAwB;AACxB,4CAA0B;AAC1B,8CAA4B;AAC5B,yCAAuB;AACvB,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,0CAAwB;AACxB,+CAA6B;AAC7B,0CAAwB;AACxB,0CAAwB;AACxB,4CAA0B;AAC1B,oDAAkC;AAClC,2CAAyB;AACzB,6CAA2B;AAC3B,8CAA4B;AAC5B,+BAA6B;AAC7B,+CAA6B"}
@@ -1,65 +1,83 @@
1
1
  /// <reference types="node" />
2
2
  import { ResolveType } from './enums';
3
3
  import { Class, Factory } from './types';
4
- import { EventEmitter } from "events";
4
+ import { EventEmitter } from 'events';
5
+ import { TypedArray } from './array';
6
+ import { Registry } from './registry';
7
+ import { ContainerCache } from './container-cache';
5
8
  /**
6
9
  * Interface to describe DI binding behaviour
7
10
  */
8
11
  export interface IBind {
9
- /**
10
- * Private var for holding implementation type
11
- */
12
- _impl: any;
13
12
  /**
14
13
  * `as` binding (alias)
15
14
  *
16
15
  * @param type - base class that is being registered
17
16
  */
18
- as<T>(type: Class<T> | string): this;
17
+ as(type: Class<any> | string): this;
19
18
  /**
20
19
  * self bind, class should be resolved by its name. Its default behaviour.
21
20
  */
22
21
  asSelf(): this;
22
+ /**
23
+ * Registers as value, it wont be resolved or called, just stored as is in container
24
+ *
25
+ * @param type - name of type / key after whitch implementation will be resolved
26
+ */
27
+ asValue(type: string): this;
28
+ /**
29
+ * Add value as array entry, and push to array if already value exists.
30
+ * Usefull if for eg. user wants to add multiple values and not override its contents.
31
+ *
32
+ * @param type - name / or type to add
33
+ */
34
+ asArrayValue(type: string): this;
23
35
  /**
24
36
  * Registers object as single instance ( singleton )
25
37
  */
26
38
  singleInstance(): this;
27
39
  }
40
+ export interface ResolvableObject {
41
+ [key: string]: any;
42
+ }
28
43
  export interface IContainer extends EventEmitter {
29
- Cache: Map<string, any[] | any>;
30
- Registry: Map<string, any[] | any>;
44
+ Cache: ContainerCache;
45
+ Registry: Registry;
46
+ Parent: IContainer;
31
47
  clear(): void;
32
48
  clearRegistry(): void;
33
49
  clearCache(): void;
34
- register<T>(implementation: Class<T> | Factory<T>): IBind;
50
+ register<T>(implementation: Class<T> | Factory<T> | ResolvableObject): IBind;
35
51
  child(): IContainer;
36
- get<T>(service: TypedArray<T>, parent?: boolean): T[];
37
- get<T>(service: string | Class<T>, parent?: boolean): T;
38
- get<T>(service: string | Class<T> | TypedArray<T>, parent?: boolean): T | T[];
39
- getRegistered<T>(service: string | Class<T>, parent: boolean): Class<any>[];
40
- has<T>(service: string | Class<T>, parent?: boolean): boolean;
41
- hasRegistered<T>(service: Class<T> | string, parent?: boolean): boolean;
42
- resolve<T>(type: string, options?: any[], check?: boolean): T;
52
+ get<T>(service: TypedArray<T>, parent?: boolean): T[] | null;
53
+ get<T>(service: string | Class<T>, parent?: boolean): T | null;
54
+ get<T>(service: string | Class<T> | TypedArray<T>, parent?: boolean): T | T[] | null;
55
+ getRegisteredTypes<T>(service: string | Class<T> | TypedArray<T>, parent?: boolean): Array<Class<unknown> | Factory<unknown>>;
56
+ isResolved<T>(service: string | Class<T>, parent?: boolean): boolean;
57
+ hasRegistered<T>(service: Class<T> | string | TypedArray<T>, parent?: boolean): boolean;
58
+ hasRegisteredType<T>(source: Class<any> | string | TypedArray<any>, type: Class<T> | string | TypedArray<T> | object, parent?: boolean): boolean;
59
+ resolve<T>(type: string, options?: unknown[], check?: boolean): T;
43
60
  resolve<T>(type: string, check?: boolean): T;
44
- resolve<T>(type: Class<T> | Factory<T>, options?: any[] | boolean, check?: boolean): T extends AsyncModule ? Promise<T> : T;
45
- resolve<T>(type: TypedArray<T>, options?: any[] | boolean, check?: boolean): T extends AsyncModule ? Promise<T[]> : T[];
61
+ resolve<T>(type: Class<T> | Factory<T>, options?: unknown[] | boolean, check?: boolean): T extends AsyncModule ? Promise<T> : T;
62
+ resolve<T>(type: TypedArray<T>, options?: unknown[] | boolean, check?: boolean): T extends AsyncModule ? Promise<T[]> : T[];
46
63
  resolve<T>(type: Class<T> | Factory<T>, check?: boolean): T extends AsyncModule ? Promise<T> : T;
47
64
  resolve<T>(type: TypedArray<T>, check?: boolean): T extends AsyncModule ? Promise<T[]> : T[];
65
+ resolve<T>(type: Class<T> | TypedArray<T> | string, options?: unknown[] | boolean, check?: boolean): Promise<T | T[]> | T | T[];
48
66
  }
49
67
  /**
50
68
  * Injection description definition structure
51
69
  */
52
- export interface IInjectDescriptor<T = any> {
70
+ export interface IInjectDescriptor<T> {
53
71
  inject: IToInject<T>[];
54
72
  resolver: ResolveType;
55
73
  }
56
- export interface IToInject<T = any> {
57
- inject: Class<T>;
74
+ export interface IToInject<T> {
75
+ inject: Class<T> | TypedArray<T>;
58
76
  autoinject: boolean;
59
77
  autoinjectKey: string;
60
78
  }
61
79
  export interface IResolvedInjection {
62
- instance: any;
80
+ instance: unknown;
63
81
  autoinject: boolean;
64
82
  autoinjectKey: string;
65
83
  }
@@ -76,8 +94,11 @@ export declare class Module {
76
94
  get Resolved(): boolean;
77
95
  }
78
96
  export declare abstract class SyncModule extends Module {
79
- resolve(_: IContainer): void;
97
+ resolve(): void;
80
98
  }
81
99
  export declare class AsyncModule extends Module {
82
- resolveAsync(_: IContainer): Promise<void>;
100
+ resolveAsync(): Promise<void>;
101
+ }
102
+ export declare abstract class Bootstrapper {
103
+ abstract bootstrap(): Promise<void> | void;
83
104
  }
package/lib/interfaces.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AsyncModule = exports.SyncModule = exports.Module = void 0;
3
+ exports.Bootstrapper = exports.AsyncModule = exports.SyncModule = exports.Module = void 0;
4
4
  /**
5
5
  * Interface to describe DI resolve strategies. Strategies are used do
6
6
  * do some work at object creation eg. initialize objects that inherits from same class
@@ -25,15 +25,19 @@ class Module {
25
25
  }
26
26
  exports.Module = Module;
27
27
  class SyncModule extends Module {
28
- resolve(_) {
28
+ resolve() {
29
29
  this.resolved = true;
30
30
  }
31
31
  }
32
32
  exports.SyncModule = SyncModule;
33
33
  class AsyncModule extends Module {
34
- async resolveAsync(_) {
34
+ /* eslint-disable */
35
+ async resolveAsync() {
35
36
  this.resolved = true;
36
37
  }
37
38
  }
38
39
  exports.AsyncModule = AsyncModule;
40
+ class Bootstrapper {
41
+ }
42
+ exports.Bootstrapper = Bootstrapper;
39
43
  //# sourceMappingURL=interfaces.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;AAsFA;;;;;;;GAOG;AACH,+BAA+B;AAC/B,6DAA6D;AAC7D,IAAI;AAEJ,oCAAoC;AACpC,uEAAuE;AACvE,IAAI;AAEJ,MAAa,MAAM;IAAnB;QACY,aAAQ,GAAY,KAAK,CAAC;IAItC,CAAC;IAHC,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AALD,wBAKC;AAED,MAAsB,UAAW,SAAQ,MAAM;IAEtC,OAAO,CAAC,CAAa;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CAEF;AAND,gCAMC;AAED,MAAa,WAAY,SAAQ,MAAM;IAC9B,KAAK,CAAC,YAAY,CAAC,CAAa;QACrC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF;AAJD,kCAIC"}
1
+ {"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../src/interfaces.ts"],"names":[],"mappings":";;;AAkGA;;;;;;;GAOG;AACH,+BAA+B;AAC/B,6DAA6D;AAC7D,IAAI;AAEJ,oCAAoC;AACpC,uEAAuE;AACvE,IAAI;AAEJ,MAAa,MAAM;IAAnB;QACY,aAAQ,GAAG,KAAK,CAAC;IAI7B,CAAC;IAHC,IAAW,QAAQ;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;CACF;AALD,wBAKC;AAED,MAAsB,UAAW,SAAQ,MAAM;IACtC,OAAO;QACZ,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF;AAJD,gCAIC;AAED,MAAa,WAAY,SAAQ,MAAM;IACrC,oBAAoB;IACb,KAAK,CAAC,YAAY;QACvB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACvB,CAAC;CACF;AALD,kCAKC;AAED,MAAsB,YAAY;CAEjC;AAFD,oCAEC"}
@@ -0,0 +1,13 @@
1
+ import { TypedArray } from './array';
2
+ import { IContainer } from './interfaces';
3
+ import { Class, Factory } from './types';
4
+ export declare class Registry {
5
+ protected container: IContainer;
6
+ protected registry: Map<string, any[]>;
7
+ constructor(container: IContainer);
8
+ clear(): void;
9
+ register(name: string | Class<any> | TypedArray<any>, type: any): void;
10
+ hasRegisteredType(source: Class<any> | string | TypedArray<any>, type: Class<any> | string | TypedArray<any> | object, parent?: boolean): boolean;
11
+ getTypes<T>(service: string | Class<T> | TypedArray<T>, parent?: boolean): Array<Class<unknown> | Factory<unknown>>;
12
+ hasRegistered<T>(service: TypedArray<T> | Class<T> | string, parent?: boolean): boolean;
13
+ }
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Registry = void 0;
4
+ const exceptions_1 = require("@spinajs/exceptions");
5
+ const helpers_1 = require("./helpers");
6
+ class Registry {
7
+ constructor(container) {
8
+ this.container = container;
9
+ this.registry = new Map();
10
+ }
11
+ clear() {
12
+ this.registry.clear();
13
+ }
14
+ register(name, type) {
15
+ if (!(0, helpers_1.isConstructor)(type) && !(0, helpers_1.isFactory)(type) && !(0, helpers_1.isObject)(type)) {
16
+ throw new exceptions_1.InvalidOperation('cannot register type if its not an class or factory function');
17
+ }
18
+ else {
19
+ const tname = (0, helpers_1.getTypeName)(name);
20
+ if (!this.hasRegisteredType(name, type)) {
21
+ const value = this.registry.get(tname);
22
+ if (value) {
23
+ value.push(type);
24
+ }
25
+ else {
26
+ this.registry.set(tname, [type]);
27
+ }
28
+ }
29
+ }
30
+ }
31
+ hasRegisteredType(source, type, parent) {
32
+ const sourceName = (0, helpers_1.getTypeName)(source);
33
+ const targetName = (0, helpers_1.getTypeName)(type);
34
+ if (this.registry.has(sourceName)) {
35
+ return this.registry.get(sourceName).find((s) => s.name === targetName) !== undefined;
36
+ }
37
+ else if (parent && this.container.Parent) {
38
+ return this.container.Parent.hasRegisteredType(source, type, parent);
39
+ }
40
+ return false;
41
+ }
42
+ getTypes(service, parent = true) {
43
+ if (!service) {
44
+ throw new exceptions_1.InvalidArgument('argument "service" cannot be null or empty');
45
+ }
46
+ const name = (0, helpers_1.getTypeName)(service);
47
+ if (this.registry.has(name)) {
48
+ return this.registry.get(name);
49
+ }
50
+ if (this.container.Parent && parent) {
51
+ return this.container.Parent.getRegisteredTypes(service, parent);
52
+ }
53
+ return null;
54
+ }
55
+ hasRegistered(service, parent = true) {
56
+ if (this.registry.has((0, helpers_1.getTypeName)(service))) {
57
+ return true;
58
+ }
59
+ else if (parent && this.container.Parent) {
60
+ return this.container.Parent.hasRegistered(service, parent);
61
+ }
62
+ return false;
63
+ }
64
+ }
65
+ exports.Registry = Registry;
66
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.js","sourceRoot":"","sources":["../src/registry.ts"],"names":[],"mappings":";;;AAAA,oDAAwE;AAExE,uCAA4E;AAI5E,MAAa,QAAQ;IAGnB,YAAsB,SAAqB;QAArB,cAAS,GAAT,SAAS,CAAY;QAFjC,aAAQ,GAAuB,IAAI,GAAG,EAAiB,CAAC;IAEpB,CAAC;IAExC,KAAK;QACV,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;IAEM,QAAQ,CAAC,IAA2C,EAAE,IAAS;QACpE,IAAI,CAAC,IAAA,uBAAa,EAAC,IAAI,CAAC,IAAI,CAAC,IAAA,mBAAS,EAAC,IAAI,CAAC,IAAI,CAAC,IAAA,kBAAQ,EAAC,IAAI,CAAC,EAAE;YAC/D,MAAM,IAAI,6BAAgB,CAAC,8DAA8D,CAAC,CAAC;SAC5F;aAAM;YACL,MAAM,KAAK,GAAG,IAAA,qBAAW,EAAC,IAAI,CAAC,CAAC;YAChC,IAAI,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,EAAE;gBACvC,MAAM,KAAK,GAAG,IAAI,CAAC,QA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