@tsed/di 7.83.0 → 8.0.0-alpha.2
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/lib/browser/di.umd.min.js +1 -1
- package/lib/browser/di.umd.min.js.map +1 -1
- package/lib/cjs/common/constants/constants.js +6 -4
- package/lib/cjs/common/constants/constants.js.map +1 -1
- package/lib/cjs/common/decorators/autoInjectable.js +23 -3
- package/lib/cjs/common/decorators/autoInjectable.js.map +1 -1
- package/lib/cjs/common/decorators/constant.js +30 -11
- package/lib/cjs/common/decorators/constant.js.map +1 -1
- package/lib/cjs/common/decorators/inject.js +64 -73
- package/lib/cjs/common/decorators/inject.js.map +1 -1
- package/lib/cjs/common/decorators/intercept.js +41 -12
- package/lib/cjs/common/decorators/intercept.js.map +1 -1
- package/lib/cjs/common/decorators/lazyInject.js +13 -13
- package/lib/cjs/common/decorators/lazyInject.js.map +1 -1
- package/lib/cjs/common/decorators/opts.js +1 -1
- package/lib/cjs/common/decorators/opts.js.map +1 -1
- package/lib/cjs/common/decorators/useOpts.js +2 -6
- package/lib/cjs/common/decorators/useOpts.js.map +1 -1
- package/lib/cjs/common/decorators/value.js +18 -11
- package/lib/cjs/common/decorators/value.js.map +1 -1
- package/lib/cjs/common/domain/Container.js +3 -3
- package/lib/cjs/common/domain/Container.js.map +1 -1
- package/lib/cjs/common/domain/Provider.js +1 -1
- package/lib/cjs/common/domain/Provider.js.map +1 -1
- package/lib/cjs/common/index.js +0 -2
- package/lib/cjs/common/index.js.map +1 -1
- package/lib/cjs/common/registries/GlobalProviders.js +6 -2
- package/lib/cjs/common/registries/GlobalProviders.js.map +1 -1
- package/lib/cjs/common/services/DIConfiguration.js.map +1 -1
- package/lib/cjs/common/services/InjectorService.js +48 -165
- package/lib/cjs/common/services/InjectorService.js.map +1 -1
- package/lib/cjs/node/decorators/injectContext.js +12 -3
- package/lib/cjs/node/decorators/injectContext.js.map +1 -1
- package/lib/cjs/node/services/DITest.js +8 -3
- package/lib/cjs/node/services/DITest.js.map +1 -1
- package/lib/esm/common/constants/constants.js +5 -3
- package/lib/esm/common/constants/constants.js.map +1 -1
- package/lib/esm/common/decorators/autoInjectable.js +23 -3
- package/lib/esm/common/decorators/autoInjectable.js.map +1 -1
- package/lib/esm/common/decorators/constant.js +28 -11
- package/lib/esm/common/decorators/constant.js.map +1 -1
- package/lib/esm/common/decorators/inject.js +63 -73
- package/lib/esm/common/decorators/inject.js.map +1 -1
- package/lib/esm/common/decorators/intercept.js +40 -13
- package/lib/esm/common/decorators/intercept.js.map +1 -1
- package/lib/esm/common/decorators/lazyInject.js +14 -14
- package/lib/esm/common/decorators/lazyInject.js.map +1 -1
- package/lib/esm/common/decorators/opts.js +2 -2
- package/lib/esm/common/decorators/opts.js.map +1 -1
- package/lib/esm/common/decorators/useOpts.js +3 -7
- package/lib/esm/common/decorators/useOpts.js.map +1 -1
- package/lib/esm/common/decorators/value.js +17 -11
- package/lib/esm/common/decorators/value.js.map +1 -1
- package/lib/esm/common/domain/Container.js +3 -3
- package/lib/esm/common/domain/Container.js.map +1 -1
- package/lib/esm/common/domain/Provider.js +1 -1
- package/lib/esm/common/domain/Provider.js.map +1 -1
- package/lib/esm/common/index.js +0 -2
- package/lib/esm/common/index.js.map +1 -1
- package/lib/esm/common/registries/GlobalProviders.js +6 -2
- package/lib/esm/common/registries/GlobalProviders.js.map +1 -1
- package/lib/esm/common/services/DIConfiguration.js.map +1 -1
- package/lib/esm/common/services/InjectorService.js +50 -167
- package/lib/esm/common/services/InjectorService.js.map +1 -1
- package/lib/esm/node/decorators/injectContext.js +13 -4
- package/lib/esm/node/decorators/injectContext.js.map +1 -1
- package/lib/esm/node/services/DITest.js +10 -5
- package/lib/esm/node/services/DITest.js.map +1 -1
- package/lib/types/common/constants/constants.d.ts +5 -3
- package/lib/types/common/decorators/constant.d.ts +4 -1
- package/lib/types/common/decorators/inject.d.ts +17 -4
- package/lib/types/common/decorators/intercept.d.ts +3 -0
- package/lib/types/common/decorators/value.d.ts +2 -1
- package/lib/types/common/domain/Container.d.ts +3 -3
- package/lib/types/common/domain/Provider.d.ts +6 -6
- package/lib/types/common/index.d.ts +0 -2
- package/lib/types/common/interfaces/ImportTokenProviderOpts.d.ts +2 -2
- package/lib/types/common/interfaces/InterceptorContext.d.ts +1 -1
- package/lib/types/common/interfaces/InvokeOptions.d.ts +8 -2
- package/lib/types/common/interfaces/ProviderOpts.d.ts +1 -1
- package/lib/types/common/interfaces/RegistrySettings.d.ts +2 -1
- package/lib/types/common/interfaces/ResolvedInvokeOptions.d.ts +1 -1
- package/lib/types/common/interfaces/TokenProvider.d.ts +2 -6
- package/lib/types/common/registries/GlobalProviders.d.ts +2 -2
- package/lib/types/common/services/InjectorService.d.ts +30 -54
- package/lib/types/node/services/DITest.d.ts +1 -1
- package/lib/types-esm/common/constants/constants.d.ts +5 -3
- package/lib/types-esm/common/decorators/constant.d.ts +4 -1
- package/lib/types-esm/common/decorators/inject.d.ts +17 -4
- package/lib/types-esm/common/decorators/intercept.d.ts +3 -0
- package/lib/types-esm/common/decorators/value.d.ts +2 -1
- package/lib/types-esm/common/domain/Container.d.ts +3 -3
- package/lib/types-esm/common/domain/Provider.d.ts +6 -6
- package/lib/types-esm/common/index.d.ts +0 -2
- package/lib/types-esm/common/interfaces/ImportTokenProviderOpts.d.ts +2 -2
- package/lib/types-esm/common/interfaces/InterceptorContext.d.ts +1 -1
- package/lib/types-esm/common/interfaces/InvokeOptions.d.ts +8 -2
- package/lib/types-esm/common/interfaces/ProviderOpts.d.ts +1 -1
- package/lib/types-esm/common/interfaces/RegistrySettings.d.ts +2 -1
- package/lib/types-esm/common/interfaces/ResolvedInvokeOptions.d.ts +1 -1
- package/lib/types-esm/common/interfaces/TokenProvider.d.ts +2 -6
- package/lib/types-esm/common/registries/GlobalProviders.d.ts +2 -2
- package/lib/types-esm/common/services/InjectorService.d.ts +30 -54
- package/lib/types-esm/node/services/DITest.d.ts +1 -1
- package/package.json +13 -9
- package/vitest.config.mts +5 -5
- package/lib/cjs/common/errors/UndefinedTokenError.js +0 -11
- package/lib/cjs/common/errors/UndefinedTokenError.js.map +0 -1
- package/lib/cjs/common/interfaces/InjectableProperties.js +0 -3
- package/lib/cjs/common/interfaces/InjectableProperties.js.map +0 -1
- package/lib/esm/common/errors/UndefinedTokenError.js +0 -7
- package/lib/esm/common/errors/UndefinedTokenError.js.map +0 -1
- package/lib/esm/common/interfaces/InjectableProperties.js +0 -2
- package/lib/esm/common/interfaces/InjectableProperties.js.map +0 -1
- package/lib/types/common/errors/UndefinedTokenError.d.ts +0 -4
- package/lib/types/common/interfaces/InjectableProperties.d.ts +0 -25
- package/lib/types-esm/common/errors/UndefinedTokenError.d.ts +0 -4
- package/lib/types-esm/common/interfaces/InjectableProperties.d.ts +0 -25
|
@@ -1,12 +1,32 @@
|
|
|
1
|
+
import { isArray } from "@tsed/core";
|
|
1
2
|
import { LocalsContainer } from "../domain/LocalsContainer.js";
|
|
2
3
|
import { InjectorService } from "../services/InjectorService.js";
|
|
4
|
+
import { getConstructorDependencies } from "../utils/getConstructorDependencies.js";
|
|
5
|
+
function resolveAutoInjectableArgs(token, args) {
|
|
6
|
+
const locals = new LocalsContainer();
|
|
7
|
+
const injector = InjectorService.getInstance();
|
|
8
|
+
const deps = getConstructorDependencies(token);
|
|
9
|
+
const list = [];
|
|
10
|
+
const length = Math.max(deps.length, args.length);
|
|
11
|
+
for (let i = 0; i < length; i++) {
|
|
12
|
+
if (args[i] !== undefined) {
|
|
13
|
+
list.push(args[i]);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const value = deps[i];
|
|
17
|
+
const instance = isArray(value)
|
|
18
|
+
? injector.getMany(value[0], locals, { parent: token })
|
|
19
|
+
: injector.invoke(value, locals, { parent: token });
|
|
20
|
+
list.push(instance);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return list;
|
|
24
|
+
}
|
|
3
25
|
export function AutoInjectable() {
|
|
4
26
|
return (constr) => {
|
|
5
27
|
return class AutoInjectable extends constr {
|
|
6
28
|
constructor(...args) {
|
|
7
|
-
|
|
8
|
-
super(...InjectorService.resolveAutoInjectableArgs(constr, locals, args));
|
|
9
|
-
InjectorService.bind(this, locals);
|
|
29
|
+
super(...resolveAutoInjectableArgs(constr, args));
|
|
10
30
|
}
|
|
11
31
|
};
|
|
12
32
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autoInjectable.js","sourceRoot":"","sources":["../../../../src/common/decorators/autoInjectable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"autoInjectable.js","sourceRoot":"","sources":["../../../../src/common/decorators/autoInjectable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAY,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,8BAA8B,CAAC;AAE7D,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,0BAA0B,EAAC,MAAM,wCAAwC,CAAC;AAElF,SAAS,yBAAyB,CAAC,KAAW,EAAE,IAAe;IAC7D,MAAM,MAAM,GAAG,IAAI,eAAe,EAAE,CAAC;IACrC,MAAM,QAAQ,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;IAC/C,MAAM,IAAI,GAAoB,0BAA0B,CAAC,KAAK,CAAC,CAAC;IAChE,MAAM,IAAI,GAAU,EAAE,CAAC;IACvB,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IAElD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE;QAC/B,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,SAAS,EAAE;YACzB,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;SACpB;aAAM;YACL,MAAM,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;YACtB,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;gBAC7B,CAAC,CAAC,QAAS,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC;gBACtD,CAAC,CAAC,QAAS,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAC,MAAM,EAAE,KAAK,EAAC,CAAC,CAAC;YAErD,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;SACrB;KACF;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,CAAyD,MAAS,EAAK,EAAE;QAC9E,OAAO,MAAM,cAAe,SAAQ,MAAM;YACxC,YAAY,GAAG,IAAW;gBACxB,KAAK,CAAC,GAAG,yBAAyB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;YACpD,CAAC;SACc,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { catchError, deepClone } from "@tsed/core";
|
|
2
|
+
import { InjectorService } from "../services/InjectorService.js";
|
|
3
|
+
export function constant(expression, defaultValue) {
|
|
4
|
+
return InjectorService.getInstance().settings.get(expression, defaultValue);
|
|
5
|
+
}
|
|
6
|
+
export function bindConstant(target, propertyKey, expression, defaultValue) {
|
|
7
|
+
const symbol = Symbol();
|
|
8
|
+
catchError(() => Reflect.deleteProperty(target, propertyKey));
|
|
9
|
+
Reflect.defineProperty(target, propertyKey, {
|
|
10
|
+
get() {
|
|
11
|
+
if (this[symbol] !== undefined) {
|
|
12
|
+
return this[symbol];
|
|
13
|
+
}
|
|
14
|
+
const value = constant(expression, defaultValue);
|
|
15
|
+
this[symbol] = Object.freeze(deepClone(value));
|
|
16
|
+
return this[symbol];
|
|
17
|
+
},
|
|
18
|
+
set(value) {
|
|
19
|
+
const bean = constant(expression, defaultValue) || this[symbol];
|
|
20
|
+
if (bean === undefined && value !== undefined) {
|
|
21
|
+
this[symbol] = value;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true
|
|
26
|
+
});
|
|
27
|
+
}
|
|
4
28
|
/**
|
|
5
29
|
* Return value from Configuration.
|
|
6
30
|
*
|
|
@@ -38,14 +62,7 @@ import { InjectablePropertyType } from "../domain/InjectablePropertyType.js";
|
|
|
38
62
|
*/
|
|
39
63
|
export function Constant(expression, defaultValue) {
|
|
40
64
|
return (target, propertyKey) => {
|
|
41
|
-
|
|
42
|
-
[propertyKey]: {
|
|
43
|
-
bindingType: InjectablePropertyType.CONSTANT,
|
|
44
|
-
propertyKey,
|
|
45
|
-
expression,
|
|
46
|
-
defaultValue
|
|
47
|
-
}
|
|
48
|
-
});
|
|
65
|
+
return bindConstant(target, propertyKey, expression, defaultValue);
|
|
49
66
|
};
|
|
50
67
|
}
|
|
51
68
|
//# sourceMappingURL=constant.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../../src/common/decorators/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../../src/common/decorators/constant.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,SAAS,EAAC,MAAM,YAAY,CAAC;AACjD,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAI/D,MAAM,UAAU,QAAQ,CAAO,UAAkB,EAAE,YAA+B;IAChF,OAAO,eAAe,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;AAC9E,CAAC;AAED,MAAM,UAAU,YAAY,C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es, isPromise, Metadata, Store
|
|
2
|
-
import {
|
|
1
|
+
import { catchError, decoratorTypeOf, DecoratorTypes, isPromise, Metadata, Store } from "@tsed/core";
|
|
2
|
+
import { DI_USE_OPTIONS, DI_INJECTABLE_PROPS, DI_INVOKE_OPTIONS } from "../constants/constants.js";
|
|
3
3
|
import { InvalidPropertyTokenError } from "../errors/InvalidPropertyTokenError.js";
|
|
4
|
+
import { InjectorService } from "../services/InjectorService.js";
|
|
4
5
|
import { getConstructorDependencies, setConstructorDependencies } from "../utils/getConstructorDependencies.js";
|
|
5
|
-
export function
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export function inject(token, opts) {
|
|
7
|
+
return InjectorService.getInstance().invoke(token, opts?.locals || InjectorService.getLocals(), opts);
|
|
8
|
+
}
|
|
9
|
+
export function injectMany(token, opts) {
|
|
10
|
+
return InjectorService.getInstance().getMany(token, opts?.locals || InjectorService.getLocals(), opts);
|
|
11
|
+
}
|
|
12
|
+
function setToken(token, { target, propertyKey, parameterIndex }) {
|
|
13
|
+
const paramTypes = getConstructorDependencies(target, propertyKey);
|
|
14
|
+
const type = paramTypes[parameterIndex];
|
|
15
|
+
paramTypes[parameterIndex] = type === Array ? [token] : token;
|
|
16
|
+
Metadata.setParamTypes(target, propertyKey, paramTypes);
|
|
17
|
+
setConstructorDependencies(target, paramTypes);
|
|
18
|
+
}
|
|
19
|
+
function getTokenType(token, target, propertyKey) {
|
|
20
|
+
const useType = token || Metadata.getType(target, propertyKey);
|
|
21
|
+
if (useType === Object) {
|
|
22
|
+
throw new InvalidPropertyTokenError(target, String(propertyKey));
|
|
23
|
+
}
|
|
24
|
+
return useType;
|
|
25
|
+
}
|
|
26
|
+
function bindInjectableProperty(target, propertyKey, { token, transform = (o) => o, useOpts }) {
|
|
27
|
+
const symbol = Symbol();
|
|
28
|
+
if (!target[DI_INJECTABLE_PROPS]) {
|
|
29
|
+
Reflect.defineProperty(target, DI_INJECTABLE_PROPS, {
|
|
30
|
+
value: new Set(),
|
|
31
|
+
enumerable: false,
|
|
32
|
+
configurable: false
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
target[DI_INJECTABLE_PROPS].add(propertyKey);
|
|
36
|
+
catchError(() => Reflect.deleteProperty(target, propertyKey));
|
|
37
|
+
Reflect.defineProperty(target, propertyKey, {
|
|
38
|
+
get() {
|
|
39
|
+
const useType = getTokenType(token, target, propertyKey);
|
|
40
|
+
const originalType = Metadata.getType(target, propertyKey);
|
|
41
|
+
const invokeOpts = {
|
|
42
|
+
rebuild: !!this[DI_INVOKE_OPTIONS]?.rebuild,
|
|
43
|
+
locals: this[DI_INVOKE_OPTIONS]?.locals,
|
|
44
|
+
useOpts: useOpts || Store.from(target, propertyKey).get(DI_USE_OPTIONS)
|
|
45
|
+
};
|
|
46
|
+
if (this[symbol] === undefined) {
|
|
47
|
+
this[symbol] = originalType === Array ? injectMany(token, invokeOpts) : inject(useType, invokeOpts);
|
|
48
|
+
}
|
|
49
|
+
[].concat(this[symbol]).forEach((instance, index) => {
|
|
50
|
+
if (isPromise(this[symbol])) {
|
|
51
|
+
instance.then((result) => {
|
|
52
|
+
this[symbol][index] = result;
|
|
53
|
+
if (originalType !== Array) {
|
|
54
|
+
this[symbol] = result;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return transform(this[symbol], { self: this, target, propertyKey });
|
|
11
60
|
}
|
|
12
61
|
});
|
|
13
62
|
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
*
|
|
19
|
-
* ```typescript
|
|
20
|
-
* @Injectable()
|
|
21
|
-
* export class MyService {
|
|
22
|
-
* @Inject(CONNECTION)
|
|
23
|
-
* connection: CONNECTION;
|
|
24
|
-
* }
|
|
25
|
-
* ```
|
|
26
|
-
*
|
|
27
|
-
* @param token A token provider or token provider group
|
|
28
|
-
* @param onGet Use the given name method to inject
|
|
29
|
-
* @returns {Function}
|
|
30
|
-
* @decorator
|
|
31
|
-
*/
|
|
32
|
-
export function Inject(token, onGet = (bean) => bean) {
|
|
33
|
-
return (target, propertyKey, descriptor) => {
|
|
34
|
-
const bindingType = decoratorTypeOf([target, propertyKey, descriptor]);
|
|
63
|
+
export function Inject(token, opts = {}) {
|
|
64
|
+
opts = typeof opts === "function" ? { transform: opts } : opts;
|
|
65
|
+
return (target, propertyKey, index) => {
|
|
66
|
+
const bindingType = decoratorTypeOf([target, propertyKey, index]);
|
|
35
67
|
switch (bindingType) {
|
|
36
68
|
case DecoratorTypes.PARAM_CTOR:
|
|
37
69
|
if (token) {
|
|
38
|
-
|
|
39
|
-
const type = paramTypes[descriptor];
|
|
40
|
-
paramTypes[descriptor] = type === Array ? [token] : token;
|
|
41
|
-
Metadata.setParamTypes(target, propertyKey, paramTypes);
|
|
42
|
-
setConstructorDependencies(target, paramTypes);
|
|
70
|
+
setToken(token, { target, propertyKey, parameterIndex: index });
|
|
43
71
|
}
|
|
44
72
|
break;
|
|
45
73
|
case DecoratorTypes.PROP:
|
|
46
|
-
|
|
47
|
-
if (useType === Object) {
|
|
48
|
-
throw new InvalidPropertyTokenError(target, String(propertyKey));
|
|
49
|
-
}
|
|
50
|
-
injectProperty(target, String(propertyKey), {
|
|
51
|
-
resolver(injector, locals, { options, ...invokeOptions }) {
|
|
52
|
-
const originalType = Metadata.getType(target, propertyKey);
|
|
53
|
-
locals.set(DI_PARAM_OPTIONS, { ...options });
|
|
54
|
-
if (originalType === Array) {
|
|
55
|
-
let bean;
|
|
56
|
-
if (!bean) {
|
|
57
|
-
bean = injector.getMany(token, locals, invokeOptions);
|
|
58
|
-
locals.delete(DI_PARAM_OPTIONS);
|
|
59
|
-
}
|
|
60
|
-
bean.forEach((instance, index) => {
|
|
61
|
-
if (isPromise(bean)) {
|
|
62
|
-
instance.then((result) => {
|
|
63
|
-
bean[index] = result;
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
return () => onGet(bean);
|
|
68
|
-
}
|
|
69
|
-
let bean;
|
|
70
|
-
if (!bean) {
|
|
71
|
-
bean = injector.invoke(useType, locals, invokeOptions);
|
|
72
|
-
locals.delete(DI_PARAM_OPTIONS);
|
|
73
|
-
}
|
|
74
|
-
if (isPromise(bean)) {
|
|
75
|
-
bean.then((result) => {
|
|
76
|
-
bean = result;
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
return () => onGet(bean);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
break;
|
|
83
|
-
default:
|
|
84
|
-
throw new UnsupportedDecoratorType(Inject, [target, propertyKey, descriptor]);
|
|
74
|
+
bindInjectableProperty(target, propertyKey, { ...opts, token });
|
|
85
75
|
}
|
|
86
76
|
};
|
|
87
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../../src/common/decorators/inject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"inject.js","sourceRoot":"","sources":["../../../../src/common/decorators/inject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,cAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAY,MAAM,YAAY,CAAC;AAC9G,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAE,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AACjG,OAAO,EAAC,yBAAyB,EAAC,MAAM,wCAAwC,CAAC;AAGjF,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,0BAA0B,EAAE,0BAA0B,EAAC,MAAM,wCAAwC,CAAC;AAE9G,MAAM,UAAU,MAAM,CAAI,KAAuB,EAAE,IAAqE;IACtH,OAAO,eAAe,CAAC,WAAW,EAAE,CAAC,MAAM,CAA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import { decorateMethodsOf, decoratorTypeOf, DecoratorTypes, Store } from "@tsed/core";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { classOf, decorateMethodsOf, decoratorTypeOf, DecoratorTypes, Store } from "@tsed/core";
|
|
2
|
+
import { DI_INTERCEPTOR_OPTIONS, DI_INVOKE_OPTIONS } from "../constants/constants.js";
|
|
3
|
+
import { inject } from "./inject.js";
|
|
4
|
+
export function getInterceptorOptions(target, propertyKey) {
|
|
5
|
+
return Store.fromMethod(target, propertyKey).get(DI_INTERCEPTOR_OPTIONS);
|
|
6
|
+
}
|
|
7
|
+
export function bindIntercept(target, propertyKey, token, options) {
|
|
8
|
+
const klass = classOf(target);
|
|
9
|
+
const descriptor = Reflect.getOwnPropertyDescriptor(klass.prototype, propertyKey);
|
|
10
|
+
const originalMethod = descriptor.value;
|
|
11
|
+
const symbol = Symbol();
|
|
12
|
+
Store.fromMethod(klass, propertyKey).set(DI_INTERCEPTOR_OPTIONS, options);
|
|
13
|
+
descriptor.value = function (...args) {
|
|
14
|
+
const next = (err) => {
|
|
15
|
+
if (!err) {
|
|
16
|
+
return originalMethod.apply(this, args);
|
|
17
|
+
}
|
|
18
|
+
throw err;
|
|
19
|
+
};
|
|
20
|
+
const context = {
|
|
21
|
+
target,
|
|
22
|
+
propertyKey,
|
|
23
|
+
args,
|
|
24
|
+
options,
|
|
25
|
+
next
|
|
26
|
+
};
|
|
27
|
+
const invokeOpts = {
|
|
28
|
+
rebuild: !!this[DI_INVOKE_OPTIONS]?.rebuild,
|
|
29
|
+
locals: this[DI_INVOKE_OPTIONS]?.locals
|
|
30
|
+
};
|
|
31
|
+
this[symbol] = this[symbol] || inject(token, invokeOpts);
|
|
32
|
+
return this[symbol].intercept({
|
|
33
|
+
...context,
|
|
34
|
+
options
|
|
35
|
+
}, next);
|
|
36
|
+
};
|
|
37
|
+
return descriptor;
|
|
38
|
+
}
|
|
4
39
|
/**
|
|
5
40
|
* Attaches interceptor to method call and executes the before and after methods
|
|
6
41
|
*
|
|
@@ -10,22 +45,14 @@ import { InjectablePropertyType } from "../domain/InjectablePropertyType.js";
|
|
|
10
45
|
*/
|
|
11
46
|
export function Intercept(interceptor, options) {
|
|
12
47
|
return (...args) => {
|
|
13
|
-
const [target, propertyKey
|
|
48
|
+
const [target, propertyKey] = args;
|
|
14
49
|
const type = decoratorTypeOf(args);
|
|
15
50
|
switch (type) {
|
|
16
51
|
case DecoratorTypes.CLASS:
|
|
17
52
|
decorateMethodsOf(target, Intercept(interceptor, options));
|
|
18
53
|
break;
|
|
19
54
|
case DecoratorTypes.METHOD:
|
|
20
|
-
|
|
21
|
-
[propertyKey]: {
|
|
22
|
-
options,
|
|
23
|
-
propertyKey,
|
|
24
|
-
useType: interceptor,
|
|
25
|
-
bindingType: InjectablePropertyType.INTERCEPTOR
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
return descriptor;
|
|
55
|
+
return bindIntercept(target, propertyKey, interceptor, options);
|
|
29
56
|
}
|
|
30
57
|
};
|
|
31
58
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intercept.js","sourceRoot":"","sources":["../../../../src/common/decorators/intercept.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAuB,eAAe,EAAE,cAAc,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"intercept.js","sourceRoot":"","sources":["../../../../src/common/decorators/intercept.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,iBAAiB,EAAuB,eAAe,EAAE,cAAc,EAAE,KAAK,EAAO,MAAM,YAAY,CAAC;AACzH,OAAO,EAAC,sBAAsB,EAAE,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAKpF,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC,MAAM,UAAU,qBAAqB,CAAI,MAAiB,EAAE,WAA4B;IACtF,OAAO,KAAK,CAAC,UAAU,CAAC,MA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,OAAO,UAAU,CAAC;AACpB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAA+B,WAAoB,EAAE,OAAa;IACzF,OAAO,CAAC,GAAG,IAAyB,EAAE,EAAE;QACtC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC;QACnC,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;QACnC,QAAQ,IAAI,EAAE;YACZ,KAAK,cAAc,CAAC,KAAK;gBACvB,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;gBAC3D,MAAM;YACR,KAAK,cAAc,CAAC,MAAM;gBACxB,OAAO,aAAa,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC;SACnE;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { importPackage } from "@tsed/core";
|
|
2
|
-
import {
|
|
1
|
+
import { catchError, importPackage } from "@tsed/core";
|
|
2
|
+
import { InjectorService } from "../services/InjectorService.js";
|
|
3
3
|
/**
|
|
4
4
|
* Lazy load a provider from his package and invoke only when the provider is used
|
|
5
5
|
*
|
|
@@ -23,21 +23,21 @@ import { injectProperty } from "./inject.js";
|
|
|
23
23
|
export function LazyInject(key, resolver, { optional = false, packageName = resolver.toString() } = {}) {
|
|
24
24
|
return (target, propertyKey) => {
|
|
25
25
|
let bean, token;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
catchError(() => Reflect.deleteProperty(target, propertyKey));
|
|
27
|
+
Reflect.defineProperty(target, propertyKey, {
|
|
28
|
+
async get() {
|
|
29
|
+
if (!token) {
|
|
30
|
+
const injector = InjectorService.getInstance();
|
|
31
|
+
const exports = await importPackage(packageName, resolver, optional);
|
|
32
|
+
token = exports[key];
|
|
29
33
|
if (!token) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
if (!token) {
|
|
33
|
-
if (!optional) {
|
|
34
|
-
throw new Error(`Unable to lazy load the "${key}". The token isn\'t a valid token provider.`);
|
|
35
|
-
}
|
|
34
|
+
if (!optional) {
|
|
35
|
+
throw new Error(`Unable to lazy load the "${key}". The token isn\'t a valid token provider.`);
|
|
36
36
|
}
|
|
37
|
-
bean = token ? await injector.lazyInvoke(token) : {};
|
|
38
37
|
}
|
|
39
|
-
|
|
40
|
-
}
|
|
38
|
+
bean = token ? await injector.lazyInvoke(token) : {};
|
|
39
|
+
}
|
|
40
|
+
return bean;
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
43
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"lazyInject.js","sourceRoot":"","sources":["../../../../src/common/decorators/lazyInject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"lazyInject.js","sourceRoot":"","sources":["../../../../src/common/decorators/lazyInject.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,aAAa,EAAC,MAAM,YAAY,CAAC;AACrD,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAE/D;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,UAAU,UAAU,CACxB,GAAW,EACX,QAAmB,EACnB,EAAC,QAAQ,GAAG,KAAK,EAAE,WAAW,GAAG,QAAQ,CAAC,QAAQ,EAAE,KAAgD,EAAE;IAEtG,OAAO,CAAC,MAAW,EAAE,WAA4B,EAAc,EAAE;QAC/D,IAAI,IAAS,EAAE,KAAU,CAAC;QAE1B,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;QAC9D,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE;YAC1C,KAAK,CAAC,GAAG;gBACP,IAAI,CAAC,KAAK,EAAE;oBACV,MAAM,QAAQ,GAAG,eAAe,CAAC,WAAW,EAAE,CAAC;oBAC/C,MAAM,OAAO,GAAG,MAAM,aAAa,CAAC,WAAW,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;oBACrE,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;oBACrB,IAAI,CAAC,KAAK,EAAE;wBACV,IAAI,CAAC,QAAQ,EAAE;4BACb,MAAM,IAAI,KAAK,CAAC,4BAA4B,GAAG,6CAA6C,CAAC,CAAC;yBAC/F;qBACF;oBAED,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;iBACtD;gBAED,OAAO,IAAI,CAAC;YACd,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAW,EAAE,QAAmB;IACjE,OAAQ,UAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,EAAC,QAAQ,EAAE,IAAI,EAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { classOf } from "@tsed/core";
|
|
2
|
-
import {
|
|
2
|
+
import { DI_USE_PARAM_OPTIONS } from "../constants/constants.js";
|
|
3
3
|
import { ProviderScope } from "../domain/ProviderScope.js";
|
|
4
4
|
import { Inject } from "./inject.js";
|
|
5
5
|
import { Scope } from "./scope.js";
|
|
@@ -45,6 +45,6 @@ import { Scope } from "./scope.js";
|
|
|
45
45
|
*/
|
|
46
46
|
export function Opts(target, propertyKey, index) {
|
|
47
47
|
Scope(ProviderScope.INSTANCE)(classOf(target));
|
|
48
|
-
Inject(
|
|
48
|
+
Inject(DI_USE_PARAM_OPTIONS)(target, propertyKey, index);
|
|
49
49
|
}
|
|
50
50
|
//# sourceMappingURL=opts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opts.js","sourceRoot":"","sources":["../../../../src/common/decorators/opts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACnC,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"opts.js","sourceRoot":"","sources":["../../../../src/common/decorators/opts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAC;AACnC,OAAO,EAAC,oBAAoB,EAAC,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAC,aAAa,EAAC,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AACnC,OAAO,EAAC,KAAK,EAAC,MAAM,YAAY,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAM,UAAU,IAAI,CAAC,MAAW,EAAE,WAAwC,EAAE,KAAa;IACvF,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;IAC/C,MAAM,CAAC,oBAAoB,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC;AAC3D,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { decoratorTypeOf, DecoratorTypes, Store, UnsupportedDecoratorType } from "@tsed/core";
|
|
2
|
-
import {
|
|
2
|
+
import { DI_USE_PARAM_OPTIONS, DI_USE_OPTIONS } from "../constants/constants.js";
|
|
3
3
|
/**
|
|
4
4
|
* Add options to invoke the Service.
|
|
5
5
|
*
|
|
@@ -44,14 +44,10 @@ export function UseOpts(options) {
|
|
|
44
44
|
const bindingType = decoratorTypeOf([target, propertyKey, index]);
|
|
45
45
|
switch (bindingType) {
|
|
46
46
|
case DecoratorTypes.PARAM_CTOR:
|
|
47
|
-
Store.from(target).merge(`${
|
|
47
|
+
Store.from(target).merge(`${DI_USE_PARAM_OPTIONS}:${index}`, options);
|
|
48
48
|
break;
|
|
49
49
|
case DecoratorTypes.PROP:
|
|
50
|
-
Store.from(target).
|
|
51
|
-
[propertyKey]: {
|
|
52
|
-
options
|
|
53
|
-
}
|
|
54
|
-
});
|
|
50
|
+
Store.from(target, propertyKey).set(DI_USE_OPTIONS, options);
|
|
55
51
|
break;
|
|
56
52
|
default:
|
|
57
53
|
throw new UnsupportedDecoratorType(UseOpts, [target, propertyKey, index]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useOpts.js","sourceRoot":"","sources":["../../../../src/common/decorators/useOpts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,cAAc,EAAE,KAAK,EAAE,wBAAwB,EAAC,MAAM,YAAY,CAAC;AAC5F,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"useOpts.js","sourceRoot":"","sources":["../../../../src/common/decorators/useOpts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,eAAe,EAAE,cAAc,EAAE,KAAK,EAAE,wBAAwB,EAAC,MAAM,YAAY,CAAC;AAC5F,OAAO,EAAC,oBAAoB,EAAE,cAAc,EAAC,MAAM,2BAA2B,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,MAAM,UAAU,OAAO,CAAC,OAA6B;IACnD,OAAO,CAAC,MAAc,EAAE,WAA4B,EAAE,KAAc,EAAO,EAAE;QAC3E,MAAM,WAAW,GAAG,eAAe,CAAC,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;QAElE,QAAQ,WAAW,EAAE;YACnB,KAAK,cAAc,CAAC,UAAU;gBAC5B,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,oBAAoB,IAAI,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC;gBACtE,MAAM;YAER,KAAK,cAAc,CAAC,IAAI;gBACtB,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,GAAG,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;gBAC7D,MAAM;YAER;gBACE,MAAM,IAAI,wBAAwB,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC;SAC7E;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { catchError } from "@tsed/core";
|
|
2
|
+
import { InjectorService } from "../services/InjectorService.js";
|
|
3
|
+
export function bindValue(target, propertyKey, expression, defaultValue) {
|
|
4
|
+
const descriptor = {
|
|
5
|
+
get() {
|
|
6
|
+
return InjectorService.getInstance().settings.get(expression, defaultValue);
|
|
7
|
+
},
|
|
8
|
+
set(value) {
|
|
9
|
+
InjectorService.getInstance().settings.set(expression, value);
|
|
10
|
+
},
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true
|
|
13
|
+
};
|
|
14
|
+
catchError(() => Reflect.deleteProperty(target, propertyKey));
|
|
15
|
+
catchError(() => Reflect.defineProperty(target, propertyKey, descriptor));
|
|
16
|
+
}
|
|
4
17
|
/**
|
|
5
18
|
* Return value from Configuration.
|
|
6
19
|
*
|
|
@@ -38,14 +51,7 @@ import { InjectablePropertyType } from "../domain/InjectablePropertyType.js";
|
|
|
38
51
|
*/
|
|
39
52
|
export function Value(expression, defaultValue) {
|
|
40
53
|
return (target, propertyKey) => {
|
|
41
|
-
|
|
42
|
-
[propertyKey]: {
|
|
43
|
-
bindingType: InjectablePropertyType.VALUE,
|
|
44
|
-
propertyKey,
|
|
45
|
-
expression,
|
|
46
|
-
defaultValue
|
|
47
|
-
}
|
|
48
|
-
});
|
|
54
|
+
return bindValue(target, propertyKey, expression, defaultValue);
|
|
49
55
|
};
|
|
50
56
|
}
|
|
51
57
|
//# sourceMappingURL=value.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"value.js","sourceRoot":"","sources":["../../../../src/common/decorators/value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"value.js","sourceRoot":"","sources":["../../../../src/common/decorators/value.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,YAAY,CAAC;AACtC,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAE/D,MAAM,UAAU,SAAS,CAAC,MAAW,EAAE,WAA4B,EAAE,UAAkB,EAAE,YAAkB;IACzG,MAAM,UAAU,GAAG;QACjB,GAAG;YACD,OAAO,eAAe,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,CAAC;QAC9E,CAAC;QACD,GAAG,CAAC,KAAc;YAChB,eAAe,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAChE,CAAC;QACD,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,IAAI;KACnB,CAAC;IAEF,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC;IAC9D,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,cAAc,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,MAAM,UAAU,KAAK,CAAC,UAAkB,EAAE,YAAsB;IAC9D,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,EAAE;QAC7B,OAAO,SAAS,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC;IAClE,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -45,13 +45,13 @@ export class Container extends Map {
|
|
|
45
45
|
/**
|
|
46
46
|
* Get all providers registered in the injector container.
|
|
47
47
|
*
|
|
48
|
-
* @param
|
|
48
|
+
* @param type Filter the list by the given ProviderType.
|
|
49
49
|
* @returns {[TokenProvider , Provider<any>][]}
|
|
50
50
|
*/
|
|
51
51
|
getProviders(type) {
|
|
52
|
-
const types = [].concat(type);
|
|
52
|
+
const types = [].concat(type).map(String);
|
|
53
53
|
return [...this].reduce((providers, [_, provider]) => {
|
|
54
|
-
if (types.includes(provider.type) || !type) {
|
|
54
|
+
if (types.includes(String(provider.type)) || !type) {
|
|
55
55
|
return [...providers, provider];
|
|
56
56
|
}
|
|
57
57
|
return providers;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Container.js","sourceRoot":"","sources":["../../../../src/common/domain/Container.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,eAAe,EAAC,MAAM,kCAAkC,CAAC;AACjE,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAEvC,MAAM,OAAO,SAAU,SAAQ,GAA4B;IACzD;;;;OAIG;IACI,GAAG,CAAC,KAAoB,EAAE,WAAkC,EAAE;QACnE,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,KAAK,EAAE,IAAI,IAAI,QAAQ,CAAC,KAAK,CAAC,CAAC;QAE5E,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QAElC,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACI,WAAW,CAAC,KAAoB,EAAE,WAAkC,EAAE;QAC3E,OAAO,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;IACnC,CAAC;IAED;;;OAGG;IACI,WAAW,CAAC,KAAoB;QACrC,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IAED;;;;OAIG;IACI,WAAW,CAAC,KAAoB,EAAE,QAA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AAa,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAElF,OAAO,CAAC,GAAG,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,EAAE;YACnD,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE;gBAClD,OAAO,CAAC,GAAG,SAAS,EAAE,QAAQ,CAAC,CAAC;aACjC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC,EAAE,EAAE,CAAC,CAAC;IACT,CAAC;IAEM,YAAY,CAAC,SAAuC;QACzD,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE;YAC7B,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE;gBACvC,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;aACtD;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -27,7 +27,7 @@ export class Provider {
|
|
|
27
27
|
return this._useClass;
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* Create a new store if the given value is a class. Otherwise the value is ignored.
|
|
30
|
+
* Create a new store if the given value is a class. Otherwise, the value is ignored.
|
|
31
31
|
* @param value
|
|
32
32
|
*/
|
|
33
33
|
set useClass(value) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../../src/common/domain/Provider.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"Provider.js","sourceRoot":"","sources":["../../../../src/common/domain/Provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,EAAO,MAAM,YA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Q;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,qBAAqB,EAAE,EAAE,CAAC,CAAC;IACnD,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC1D,CAAC;IAED,OAAO;QACL,OAAO,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC;IAChC,CAAC;IAED,KAAK;QACH,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IAED;;;OAGG;IACI,WAAW;QAChB,OAAO,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;IAChC,CAAC;IAED;;;OAGG;IACI,SAAS;QACd,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAC9C,CAAC;IAED,QAAQ;QACN,OAAO;YACL,OAAO;YACP,IAAI,CAAC,IAAI;YACT,IAAI,CAAC,QAAQ,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC;YACtC,IAAI,CAAC,UAAU,IAAI,SAAS;YAC5B,IAAI,CAAC,QAAQ,IAAI,OAAO;YACxB,IAAI,CAAC,eAAe,IAAI,cAAc;SACvC;aACE,MAAM,CAAC,OAAO,CAAC;aACf,IAAI,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;CACF"}
|
package/lib/esm/common/index.js
CHANGED
|
@@ -27,13 +27,11 @@ export * from "./domain/ProviderScope.js";
|
|
|
27
27
|
export * from "./domain/ProviderType.js";
|
|
28
28
|
export * from "./errors/InjectionError.js";
|
|
29
29
|
export * from "./errors/InvalidPropertyTokenError.js";
|
|
30
|
-
export * from "./errors/UndefinedTokenError.js";
|
|
31
30
|
export * from "./interfaces/DIConfigurationOptions.js";
|
|
32
31
|
export * from "./interfaces/DILogger.js";
|
|
33
32
|
export * from "./interfaces/DILoggerOptions.js";
|
|
34
33
|
export * from "./interfaces/DIResolver.js";
|
|
35
34
|
export * from "./interfaces/ImportTokenProviderOpts.js";
|
|
36
|
-
export * from "./interfaces/InjectableProperties.js";
|
|
37
35
|
export * from "./interfaces/InterceptorContext.js";
|
|
38
36
|
export * from "./interfaces/InterceptorMethods.js";
|
|
39
37
|
export * from "./interfaces/InvokeOptions.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,0BAA0B,CAAC;AACzC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,oCAAoC,CAAC;AACnD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,sBAAsB,CAAC;AACrC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,uCAAuC,CAAC;AACtD,cAAc,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,0BAA0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c,mBAAmB,CAAC;AAClC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uCAAuC,CAAC;AACtD,cAAc,+BAA+B,CAAC"}
|
|
@@ -40,7 +40,11 @@ export class GlobalProviderRegistry extends Map {
|
|
|
40
40
|
merge(target, options) {
|
|
41
41
|
const meta = this.createIfNotExists(target, options);
|
|
42
42
|
Object.keys(options).forEach((key) => {
|
|
43
|
-
|
|
43
|
+
let value = options[key];
|
|
44
|
+
// if (key === "type") {
|
|
45
|
+
// value = String(value);
|
|
46
|
+
// }
|
|
47
|
+
meta[key] = value;
|
|
44
48
|
});
|
|
45
49
|
this.set(target, meta);
|
|
46
50
|
return meta;
|
|
@@ -69,7 +73,7 @@ export class GlobalProviderRegistry extends Map {
|
|
|
69
73
|
}
|
|
70
74
|
}
|
|
71
75
|
getRegistrySettings(target) {
|
|
72
|
-
let type =
|
|
76
|
+
let type = ProviderType.PROVIDER;
|
|
73
77
|
if (typeof target === "string") {
|
|
74
78
|
type = target;
|
|
75
79
|
}
|