@tsed/di 7.0.0-beta.11 → 7.0.0-beta.14
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/jest.config.js +14 -0
- package/lib/cjs/decorators/controller.js.map +1 -1
- package/lib/cjs/domain/Container.js +1 -2
- package/lib/cjs/domain/Container.js.map +1 -1
- package/lib/cjs/domain/ContextLogger.js +55 -30
- package/lib/cjs/domain/ContextLogger.js.map +1 -1
- package/lib/cjs/domain/ControllerProvider.js +37 -0
- package/lib/cjs/domain/ControllerProvider.js.map +1 -0
- package/lib/cjs/domain/DIContext.js +55 -26
- package/lib/cjs/domain/DIContext.js.map +1 -1
- package/lib/cjs/domain/Provider.js +11 -1
- package/lib/cjs/domain/Provider.js.map +1 -1
- package/lib/cjs/errors/InjectionError.js +3 -2
- package/lib/cjs/errors/InjectionError.js.map +1 -1
- package/lib/cjs/errors/UndefinedTokenError.js +1 -1
- package/lib/cjs/errors/UndefinedTokenError.js.map +1 -1
- package/lib/cjs/index.js +5 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/interfaces/AlterRunInContext.js +3 -0
- package/lib/cjs/interfaces/AlterRunInContext.js.map +1 -0
- package/lib/cjs/interfaces/DIConfigurationOptions.js.map +1 -1
- package/lib/cjs/interfaces/DILoggerOptions.js +3 -0
- package/lib/cjs/interfaces/DILoggerOptions.js.map +1 -0
- package/lib/cjs/interfaces/InterceptorMethods.js.map +1 -1
- package/lib/cjs/interfaces/TokenProvider.js.map +1 -1
- package/lib/cjs/registries/GlobalProviders.js +6 -12
- package/lib/cjs/registries/GlobalProviders.js.map +1 -1
- package/lib/cjs/services/DIConfiguration.js +51 -45
- package/lib/cjs/services/DIConfiguration.js.map +1 -1
- package/lib/cjs/services/DITest.js +4 -5
- package/lib/cjs/services/DITest.js.map +1 -1
- package/lib/cjs/services/InjectorService.js +56 -73
- package/lib/cjs/services/InjectorService.js.map +1 -1
- package/lib/cjs/utils/getConfiguration.js +3 -9
- package/lib/cjs/utils/getConfiguration.js.map +1 -1
- package/lib/cjs/utils/resolveControllers.js +1 -1
- package/lib/cjs/utils/resolveControllers.js.map +1 -1
- package/lib/cjs/utils/runInContext.js +16 -6
- package/lib/cjs/utils/runInContext.js.map +1 -1
- package/lib/cjs/utils/setLoggerConfiguration.js +11 -0
- package/lib/cjs/utils/setLoggerConfiguration.js.map +1 -0
- package/lib/cjs/utils/setLoggerFormat.js +33 -0
- package/lib/cjs/utils/setLoggerFormat.js.map +1 -0
- package/lib/cjs/utils/setLoggerLevel.js +1 -2
- package/lib/cjs/utils/setLoggerLevel.js.map +1 -1
- package/lib/esm/decorators/controller.js.map +1 -1
- package/lib/esm/domain/Container.js +1 -2
- package/lib/esm/domain/Container.js.map +1 -1
- package/lib/esm/domain/ContextLogger.js +55 -30
- package/lib/esm/domain/ContextLogger.js.map +1 -1
- package/lib/esm/domain/ControllerProvider.js +33 -0
- package/lib/esm/domain/ControllerProvider.js.map +1 -0
- package/lib/esm/domain/DIContext.js +55 -26
- package/lib/esm/domain/DIContext.js.map +1 -1
- package/lib/esm/domain/Provider.js +11 -1
- package/lib/esm/domain/Provider.js.map +1 -1
- package/lib/esm/errors/InjectionError.js +3 -2
- package/lib/esm/errors/InjectionError.js.map +1 -1
- package/lib/esm/errors/UndefinedTokenError.js +1 -1
- package/lib/esm/errors/UndefinedTokenError.js.map +1 -1
- package/lib/esm/index.js +5 -0
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/interfaces/AlterRunInContext.js +2 -0
- package/lib/esm/interfaces/AlterRunInContext.js.map +1 -0
- package/lib/esm/interfaces/DIConfigurationOptions.js.map +1 -1
- package/lib/esm/interfaces/DILoggerOptions.js +2 -0
- package/lib/esm/interfaces/DILoggerOptions.js.map +1 -0
- package/lib/esm/interfaces/InterceptorMethods.js.map +1 -1
- package/lib/esm/interfaces/TokenProvider.js.map +1 -1
- package/lib/esm/registries/GlobalProviders.js +6 -12
- package/lib/esm/registries/GlobalProviders.js.map +1 -1
- package/lib/esm/services/DIConfiguration.js +52 -46
- package/lib/esm/services/DIConfiguration.js.map +1 -1
- package/lib/esm/services/DITest.js +4 -5
- package/lib/esm/services/DITest.js.map +1 -1
- package/lib/esm/services/InjectorService.js +57 -74
- package/lib/esm/services/InjectorService.js.map +1 -1
- package/lib/esm/utils/getConfiguration.js +3 -9
- package/lib/esm/utils/getConfiguration.js.map +1 -1
- package/lib/esm/utils/resolveControllers.js +1 -1
- package/lib/esm/utils/resolveControllers.js.map +1 -1
- package/lib/esm/utils/runInContext.js +15 -6
- package/lib/esm/utils/runInContext.js.map +1 -1
- package/lib/esm/utils/setLoggerConfiguration.js +7 -0
- package/lib/esm/utils/setLoggerConfiguration.js.map +1 -0
- package/lib/esm/utils/setLoggerFormat.js +29 -0
- package/lib/esm/utils/setLoggerFormat.js.map +1 -0
- package/lib/esm/utils/setLoggerLevel.js +1 -2
- package/lib/esm/utils/setLoggerLevel.js.map +1 -1
- package/lib/types/decorators/controller.d.ts +0 -1
- package/lib/types/domain/ContextLogger.d.ts +15 -18
- package/lib/types/domain/ControllerProvider.d.ts +17 -0
- package/lib/types/domain/DIContext.d.ts +15 -19
- package/lib/types/index.d.ts +5 -0
- package/lib/types/interfaces/AlterRunInContext.d.ts +4 -0
- package/lib/types/interfaces/DIConfigurationOptions.d.ts +1 -2
- package/lib/types/interfaces/DILoggerOptions.d.ts +44 -0
- package/lib/types/interfaces/InterceptorMethods.d.ts +1 -1
- package/lib/types/interfaces/TokenProvider.d.ts +1 -1
- package/lib/types/services/DIConfiguration.d.ts +17 -12
- package/lib/types/services/InjectorService.d.ts +11 -17
- package/lib/types/utils/runInContext.d.ts +2 -1
- package/lib/types/utils/setLoggerConfiguration.d.ts +2 -0
- package/lib/types/utils/setLoggerFormat.d.ts +6 -0
- package/lib/types/utils/setLoggerLevel.d.ts +1 -1
- package/package.json +14 -10
- package/readme.md +2 -1
|
@@ -1,28 +1,25 @@
|
|
|
1
|
+
import { Hooks } from "@tsed/core";
|
|
1
2
|
import { LogLevel } from "@tsed/logger";
|
|
3
|
+
import { DILogger } from "../interfaces/DILogger";
|
|
4
|
+
import type { DIContext } from "./DIContext";
|
|
2
5
|
export interface ContextLoggerOptions extends Record<string, any> {
|
|
3
6
|
id: string;
|
|
4
|
-
|
|
5
|
-
dateStart?: Date;
|
|
7
|
+
logger?: DILogger;
|
|
6
8
|
level?: "debug" | "info" | "warn" | "error" | "off" | "all";
|
|
7
9
|
maxStackSize?: number;
|
|
8
|
-
minimalRequestPicker?: (o: any) => any;
|
|
9
|
-
completeRequestPicker?: (o: any) => any;
|
|
10
|
-
ignoreLog?: (data: any) => boolean;
|
|
11
10
|
additionalProps?: Record<any, any>;
|
|
12
11
|
}
|
|
13
12
|
export declare class ContextLogger {
|
|
14
|
-
private
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
maxStackSize: number;
|
|
20
|
-
|
|
21
|
-
private
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
private level;
|
|
25
|
-
constructor(logger: any, { id, url, dateStart, ignoreUrlPatterns, minimalRequestPicker, completeRequestPicker, level, maxStackSize, ignoreLog, additionalProps }: ContextLoggerOptions);
|
|
13
|
+
#private;
|
|
14
|
+
readonly $ctx: DIContext;
|
|
15
|
+
readonly dateStart: Date;
|
|
16
|
+
constructor($ctx: DIContext);
|
|
17
|
+
get id(): any;
|
|
18
|
+
set maxStackSize(maxStackSize: number);
|
|
19
|
+
get hooks(): Hooks;
|
|
20
|
+
private get stack();
|
|
21
|
+
alterLog(cb: (data: any, level: "debug" | "info" | "warn" | "error" | "off" | "all", withRequest: boolean) => any): Hooks;
|
|
22
|
+
alterIgnoreLog(cb: (ignore: boolean, data: any) => boolean): Hooks;
|
|
26
23
|
info(obj: any): this;
|
|
27
24
|
debug(obj: any, withRequest?: boolean): this;
|
|
28
25
|
warn(obj: any): this;
|
|
@@ -37,5 +34,5 @@ export declare class ContextLogger {
|
|
|
37
34
|
*/
|
|
38
35
|
protected getDuration(): number;
|
|
39
36
|
protected getData(obj: any): any;
|
|
40
|
-
protected run(level: LogLevel, obj: any,
|
|
37
|
+
protected run(level: LogLevel, obj: any, withRequest?: boolean): void;
|
|
41
38
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ControllerMiddlewares } from "../decorators/controller";
|
|
2
|
+
import { TokenProvider } from "../interfaces/TokenProvider";
|
|
3
|
+
import { Provider } from "./Provider";
|
|
4
|
+
export declare class ControllerProvider<T = any> extends Provider<T> {
|
|
5
|
+
tokenRouter: string;
|
|
6
|
+
constructor(provide: TokenProvider, options?: Partial<Provider>);
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @returns {any[]}
|
|
10
|
+
*/
|
|
11
|
+
get middlewares(): ControllerMiddlewares;
|
|
12
|
+
/**
|
|
13
|
+
*
|
|
14
|
+
* @param middlewares
|
|
15
|
+
*/
|
|
16
|
+
set middlewares(middlewares: ControllerMiddlewares);
|
|
17
|
+
}
|
|
@@ -12,11 +12,21 @@ export interface ContextMethods extends Map<any, any> {
|
|
|
12
12
|
}
|
|
13
13
|
export interface DIContextOptions extends Omit<ContextLoggerOptions, "dateStart"> {
|
|
14
14
|
id: string;
|
|
15
|
+
injector: InjectorService;
|
|
15
16
|
logger: any;
|
|
16
|
-
injector?: InjectorService;
|
|
17
17
|
}
|
|
18
18
|
export declare class DIContext extends Map<any, any> implements ContextMethods {
|
|
19
|
+
readonly options: DIContextOptions;
|
|
19
20
|
[x: string]: any;
|
|
21
|
+
/**
|
|
22
|
+
* The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`
|
|
23
|
+
*/
|
|
24
|
+
container: LocalsContainer<any>;
|
|
25
|
+
/**
|
|
26
|
+
* Logger attached to the context request.
|
|
27
|
+
*/
|
|
28
|
+
readonly logger: ContextLogger;
|
|
29
|
+
constructor(options: DIContextOptions);
|
|
20
30
|
/**
|
|
21
31
|
* Request id generated by @@contextMiddleware@@.
|
|
22
32
|
*
|
|
@@ -41,26 +51,12 @@ export declare class DIContext extends Map<any, any> implements ContextMethods {
|
|
|
41
51
|
* :::
|
|
42
52
|
*
|
|
43
53
|
*/
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
*/
|
|
48
|
-
readonly dateStart: Date;
|
|
49
|
-
/**
|
|
50
|
-
* The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`
|
|
51
|
-
*/
|
|
52
|
-
container: LocalsContainer<any>;
|
|
53
|
-
/**
|
|
54
|
-
* Logger attached to the context request.
|
|
55
|
-
*/
|
|
56
|
-
logger: ContextLogger;
|
|
57
|
-
/**
|
|
58
|
-
*
|
|
59
|
-
*/
|
|
60
|
-
injector: InjectorService;
|
|
61
|
-
constructor({ id, injector, logger, ignoreLog, ...options }: DIContextOptions);
|
|
54
|
+
get id(): any;
|
|
55
|
+
get dateStart(): Date;
|
|
56
|
+
get injector(): InjectorService;
|
|
62
57
|
get env(): any;
|
|
63
58
|
destroy(): Promise<void>;
|
|
64
59
|
emit(eventName: string, ...args: any[]): Promise<void>;
|
|
60
|
+
runInContext(next: Function): Promise<unknown>;
|
|
65
61
|
}
|
|
66
62
|
export declare type BaseContext = DIContext & TsED.Context;
|
package/lib/types/index.d.ts
CHANGED
|
@@ -19,6 +19,7 @@ export * from "./decorators/useOpts";
|
|
|
19
19
|
export * from "./decorators/value";
|
|
20
20
|
export * from "./domain/Container";
|
|
21
21
|
export * from "./domain/ContextLogger";
|
|
22
|
+
export * from "./domain/ControllerProvider";
|
|
22
23
|
export * from "./domain/DIContext";
|
|
23
24
|
export * from "./domain/InjectablePropertyType";
|
|
24
25
|
export * from "./domain/LocalsContainer";
|
|
@@ -27,8 +28,10 @@ export * from "./domain/ProviderScope";
|
|
|
27
28
|
export * from "./domain/ProviderType";
|
|
28
29
|
export * from "./errors/InjectionError";
|
|
29
30
|
export * from "./errors/UndefinedTokenError";
|
|
31
|
+
export * from "./interfaces/AlterRunInContext";
|
|
30
32
|
export * from "./interfaces/DIConfigurationOptions";
|
|
31
33
|
export * from "./interfaces/DILogger";
|
|
34
|
+
export * from "./interfaces/DILoggerOptions";
|
|
32
35
|
export * from "./interfaces/DIResolver";
|
|
33
36
|
export * from "./interfaces/InjectableProperties";
|
|
34
37
|
export * from "./interfaces/InterceptorContext";
|
|
@@ -52,4 +55,6 @@ export * from "./utils/createContainer";
|
|
|
52
55
|
export * from "./utils/getConfiguration";
|
|
53
56
|
export * from "./utils/resolveControllers";
|
|
54
57
|
export * from "./utils/runInContext";
|
|
58
|
+
export * from "./utils/setLoggerConfiguration";
|
|
59
|
+
export * from "./utils/setLoggerFormat";
|
|
55
60
|
export * from "./utils/setLoggerLevel";
|
|
@@ -5,7 +5,7 @@ declare global {
|
|
|
5
5
|
namespace TsED {
|
|
6
6
|
interface Context {
|
|
7
7
|
}
|
|
8
|
-
interface Configuration {
|
|
8
|
+
interface Configuration extends Record<string, any> {
|
|
9
9
|
scopes: {
|
|
10
10
|
[key: string]: ProviderScope;
|
|
11
11
|
};
|
|
@@ -21,7 +21,6 @@ declare global {
|
|
|
21
21
|
* Mount controllers
|
|
22
22
|
*/
|
|
23
23
|
mount: Record<string, TokenProvider[]>;
|
|
24
|
-
[key: string]: any;
|
|
25
24
|
}
|
|
26
25
|
}
|
|
27
26
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export interface DILoggerOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Enable debug mode. By default debug is false.
|
|
4
|
+
*/
|
|
5
|
+
debug?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Enable info mode. By default debug is false.
|
|
8
|
+
*/
|
|
9
|
+
level?: "debug" | "info" | "warn" | "error" | "off";
|
|
10
|
+
/**
|
|
11
|
+
* Enable log performance tracker and disable log server.
|
|
12
|
+
*/
|
|
13
|
+
perf?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* List of regexp to ignore log.
|
|
16
|
+
*/
|
|
17
|
+
ignoreUrlPatterns?: (string | RegExp)[];
|
|
18
|
+
/**
|
|
19
|
+
* The number of space characters to use as white space in JSON output. Default is 2 (0 in production).
|
|
20
|
+
*/
|
|
21
|
+
jsonIndentation?: number;
|
|
22
|
+
/**
|
|
23
|
+
* A function called for each incoming request to create a request id.
|
|
24
|
+
* @returns {number}
|
|
25
|
+
*/
|
|
26
|
+
reqIdBuilder?: (req: any) => string;
|
|
27
|
+
/**
|
|
28
|
+
* Disable routes table displayed in the logger. By default debug is `false`.
|
|
29
|
+
*/
|
|
30
|
+
disableRoutesSummary?: boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Disable bootstrap log displayed in the logger. By default debug is `false`.
|
|
33
|
+
*/
|
|
34
|
+
disableBootstrapLog?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Specify log format. Example: `%[%d{[yyyy-MM-dd hh:mm:ss,SSS}] %p%] %m`. See [@tsed/logger configuration](https://tsedio.github.io/logger/).
|
|
37
|
+
*/
|
|
38
|
+
format?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Specify the log stack size for the context.logger. When the stack.length is reach, the logger is flushed during the request.
|
|
41
|
+
* Default size is set to 30.
|
|
42
|
+
*/
|
|
43
|
+
maxStackSize?: number;
|
|
44
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import type { Type } from "@tsed/core";
|
|
2
|
-
export declare type TokenProvider = string | symbol | Type | Function | any;
|
|
2
|
+
export declare type TokenProvider<T = any> = string | symbol | Type<T> | Function | any;
|
|
@@ -1,24 +1,31 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Env } from "@tsed/core";
|
|
2
|
+
import type { ProviderScope } from "../domain/ProviderScope";
|
|
3
|
+
import type { DILoggerOptions } from "../interfaces/DILoggerOptions";
|
|
2
4
|
import type { DIResolver } from "../interfaces/DIResolver";
|
|
3
5
|
import type { TokenProvider } from "../interfaces/TokenProvider";
|
|
4
|
-
import { TokenRoute } from "../interfaces/TokenRoute";
|
|
6
|
+
import type { TokenRoute } from "../interfaces/TokenRoute";
|
|
5
7
|
export declare class DIConfiguration {
|
|
6
8
|
readonly default: Map<string, any>;
|
|
7
9
|
protected map: Map<string, any>;
|
|
8
|
-
[key: string]: any;
|
|
9
10
|
constructor(initialProps?: {});
|
|
10
|
-
get
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
set
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
get version(): string;
|
|
12
|
+
set version(v: string);
|
|
13
|
+
get rootDir(): string;
|
|
14
|
+
set rootDir(value: string);
|
|
15
|
+
get env(): Env;
|
|
16
|
+
set env(value: Env);
|
|
17
|
+
get scopes(): Record<string, ProviderScope>;
|
|
18
|
+
set scopes(value: Record<string, ProviderScope>);
|
|
16
19
|
get resolvers(): DIResolver[];
|
|
17
20
|
set resolvers(resolvers: DIResolver[]);
|
|
18
21
|
get imports(): TokenProvider[];
|
|
19
22
|
set imports(imports: TokenProvider[]);
|
|
20
23
|
get routes(): TokenRoute[];
|
|
21
24
|
set routes(routes: TokenRoute[]);
|
|
25
|
+
get logger(): Partial<DILoggerOptions>;
|
|
26
|
+
set logger(value: Partial<DILoggerOptions>);
|
|
27
|
+
get debug(): boolean;
|
|
28
|
+
set debug(debug: boolean);
|
|
22
29
|
/**
|
|
23
30
|
*
|
|
24
31
|
* @param callbackfn
|
|
@@ -39,13 +46,11 @@ export declare class DIConfiguration {
|
|
|
39
46
|
* @returns {undefined|any}
|
|
40
47
|
*/
|
|
41
48
|
get<T = any>(propertyKey: string, defaultValue?: T): T;
|
|
42
|
-
getRaw(propertyKey: string, defaultValue?: any): any;
|
|
43
|
-
merge(obj: Partial<TsED.Configuration>): void;
|
|
49
|
+
protected getRaw(propertyKey: string, defaultValue?: any): any;
|
|
44
50
|
/**
|
|
45
51
|
*
|
|
46
52
|
* @param value
|
|
47
53
|
* @returns {any}
|
|
48
54
|
*/
|
|
49
55
|
resolve(value: any): any;
|
|
50
|
-
build(): void;
|
|
51
56
|
}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { Container } from "../domain/Container";
|
|
2
|
-
import { LocalsContainer } from "../domain/LocalsContainer";
|
|
3
2
|
import { Provider } from "../domain/Provider";
|
|
4
|
-
import { DIConfiguration } from "./DIConfiguration";
|
|
5
3
|
import { ProviderScope } from "../domain/ProviderScope";
|
|
6
4
|
import { DILogger } from "../interfaces/DILogger";
|
|
7
|
-
import { TokenProvider } from "../interfaces/TokenProvider";
|
|
8
|
-
import { InvokeOptions } from "../interfaces/InvokeOptions";
|
|
9
5
|
import { InjectablePropertyOptions, InjectablePropertyValue } from "../interfaces/InjectableProperties";
|
|
6
|
+
import { InvokeOptions } from "../interfaces/InvokeOptions";
|
|
7
|
+
import { TokenProvider } from "../interfaces/TokenProvider";
|
|
8
|
+
import { DIConfiguration } from "./DIConfiguration";
|
|
10
9
|
/**
|
|
11
10
|
* This service contain all services collected by `@Service` or services declared manually with `InjectorService.factory()` or `InjectorService.service()`.
|
|
12
11
|
*
|
|
@@ -30,16 +29,12 @@ import { InjectablePropertyOptions, InjectablePropertyValue } from "../interface
|
|
|
30
29
|
*/
|
|
31
30
|
export declare class InjectorService extends Container {
|
|
32
31
|
#private;
|
|
33
|
-
settings:
|
|
32
|
+
settings: DIConfiguration;
|
|
34
33
|
logger: DILogger;
|
|
35
34
|
private resolvedConfiguration;
|
|
36
35
|
constructor();
|
|
37
36
|
get resolvers(): import("..").DIResolver[];
|
|
38
|
-
get scopes():
|
|
39
|
-
[key: string]: ProviderScope;
|
|
40
|
-
} & {
|
|
41
|
-
[key: string]: ProviderScope;
|
|
42
|
-
};
|
|
37
|
+
get scopes(): Record<string, ProviderScope>;
|
|
43
38
|
/**
|
|
44
39
|
* Retrieve default scope for a given provider.
|
|
45
40
|
* @param provider
|
|
@@ -69,7 +64,7 @@ export declare class InjectorService extends Container {
|
|
|
69
64
|
* @param options
|
|
70
65
|
* @returns {boolean}
|
|
71
66
|
*/
|
|
72
|
-
get<T = any>(token: TokenProvider
|
|
67
|
+
get<T = any>(token: TokenProvider<T>, options?: any): T | undefined;
|
|
73
68
|
/**
|
|
74
69
|
* Return all instance of the same provider type
|
|
75
70
|
* @param type
|
|
@@ -102,12 +97,12 @@ export declare class InjectorService extends Container {
|
|
|
102
97
|
* @param options
|
|
103
98
|
* @returns {T} The class constructed.
|
|
104
99
|
*/
|
|
105
|
-
invoke<T>(token: TokenProvider, locals?: Map<TokenProvider, any>, options?: Partial<InvokeOptions<T>>): T;
|
|
100
|
+
invoke<T = any>(token: TokenProvider, locals?: Map<TokenProvider, any>, options?: Partial<InvokeOptions<T>>): T;
|
|
106
101
|
/**
|
|
107
102
|
* Build only providers which are asynchronous.
|
|
108
103
|
*/
|
|
109
|
-
loadAsync(
|
|
110
|
-
loadSync(
|
|
104
|
+
loadAsync(): Promise<void>;
|
|
105
|
+
loadSync(): void;
|
|
111
106
|
/**
|
|
112
107
|
* Boostrap injector from container and resolve configuration.
|
|
113
108
|
*
|
|
@@ -118,14 +113,13 @@ export declare class InjectorService extends Container {
|
|
|
118
113
|
* Load injector from a given module
|
|
119
114
|
* @param rootModule
|
|
120
115
|
*/
|
|
121
|
-
loadModule(rootModule: TokenProvider): Promise<
|
|
116
|
+
loadModule(rootModule: TokenProvider): Promise<void>;
|
|
122
117
|
/**
|
|
123
118
|
* Build all providers from given container (or GlobalProviders) and emit `$onInit` event.
|
|
124
119
|
*
|
|
125
120
|
* @param container
|
|
126
|
-
* @param rootModule
|
|
127
121
|
*/
|
|
128
|
-
load(container?: Container
|
|
122
|
+
load(container?: Container): Promise<void>;
|
|
129
123
|
/**
|
|
130
124
|
* Load all configurations registered on providers
|
|
131
125
|
*/
|
|
@@ -2,5 +2,6 @@
|
|
|
2
2
|
import { AsyncLocalStorage } from "async_hooks";
|
|
3
3
|
import { DIContext } from "../domain/DIContext";
|
|
4
4
|
export declare function getAsyncStore(): AsyncLocalStorage<DIContext>;
|
|
5
|
-
export declare function getContext():
|
|
5
|
+
export declare function getContext<Context = DIContext>(): Context | undefined;
|
|
6
6
|
export declare function runInContext(ctx: DIContext, cb: any): unknown;
|
|
7
|
+
export declare function bindContext(cb: any): (...args: any) => any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/di",
|
|
3
|
-
"version": "7.0.0-beta.
|
|
3
|
+
"version": "7.0.0-beta.14",
|
|
4
4
|
"description": "DI module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -17,20 +17,21 @@
|
|
|
17
17
|
"build": "yarn barrels && yarn run build:esm && yarn run build:cjs",
|
|
18
18
|
"build:cjs": "tsc --build tsconfig.compile.json",
|
|
19
19
|
"build:esm": "tsc --build tsconfig.compile.esm.json",
|
|
20
|
-
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\""
|
|
20
|
+
"barrels": "yarn barrelsby --delete -d ./src -e \"\\.spec\\.ts\" -e \"__mock__\"",
|
|
21
|
+
"test": "cross-env NODE_ENV=test yarn jest --max-workers=2"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"tslib": "2.
|
|
24
|
+
"tslib": "2.4.0"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
|
-
"@tsed/core": "7.0.0-beta.
|
|
27
|
-
"@tsed/logger": ">=6.
|
|
28
|
-
"@tsed/schema": "7.0.0-beta.
|
|
27
|
+
"@tsed/core": "7.0.0-beta.14",
|
|
28
|
+
"@tsed/logger": ">=6.2.0",
|
|
29
|
+
"@tsed/schema": "7.0.0-beta.14"
|
|
29
30
|
},
|
|
30
31
|
"peerDependencies": {
|
|
31
|
-
"@tsed/core": "^7.0.0-beta.
|
|
32
|
-
"@tsed/logger": ">=6.
|
|
33
|
-
"@tsed/schema": "^7.0.0-beta.
|
|
32
|
+
"@tsed/core": "^7.0.0-beta.14",
|
|
33
|
+
"@tsed/logger": ">=6.2.0",
|
|
34
|
+
"@tsed/schema": "^7.0.0-beta.14"
|
|
34
35
|
},
|
|
35
36
|
"peerDependenciesMeta": {
|
|
36
37
|
"@tsed/core": {
|
|
@@ -49,5 +50,8 @@
|
|
|
49
50
|
},
|
|
50
51
|
"homepage": "https://github.com/tsedio/tsed/tree/beta/packages/di",
|
|
51
52
|
"author": "Romain Lenzotti",
|
|
52
|
-
"license": "MIT"
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"tag": "beta"
|
|
56
|
+
}
|
|
53
57
|
}
|
package/readme.md
CHANGED
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
[](https://badge.fury.io/js/%40tsed%2Fcommon)
|
|
12
12
|
[](https://github.com/semantic-release/semantic-release)
|
|
13
13
|
[](https://github.com/prettier/prettier)
|
|
14
|
-
[](https://github.com/sponsors/romakita)
|
|
15
|
+
[](https://opencollective.com/tsed)
|
|
15
16
|
|
|
16
17
|
</div>
|
|
17
18
|
|