@tsed/di 7.79.4 → 7.80.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/types-esm/common/constants/constants.d.ts +3 -0
- package/lib/types-esm/common/decorators/configuration.d.ts +8 -0
- package/lib/types-esm/common/decorators/constant.d.ts +36 -0
- package/lib/types-esm/common/decorators/controller.d.ts +42 -0
- package/lib/types-esm/common/decorators/inject.d.ts +22 -0
- package/lib/types-esm/common/decorators/injectable.d.ts +20 -0
- package/lib/types-esm/common/decorators/intercept.d.ts +10 -0
- package/lib/types-esm/common/decorators/interceptor.d.ts +10 -0
- package/lib/types-esm/common/decorators/lazyInject.d.ts +43 -0
- package/lib/types-esm/common/decorators/module.d.ts +37 -0
- package/lib/types-esm/common/decorators/opts.d.ts +41 -0
- package/lib/types-esm/common/decorators/overrideProvider.d.ts +8 -0
- package/lib/types-esm/common/decorators/scope.d.ts +8 -0
- package/lib/types-esm/common/decorators/service.d.ts +10 -0
- package/lib/types-esm/common/decorators/useOpts.d.ts +42 -0
- package/lib/types-esm/common/decorators/value.d.ts +36 -0
- package/lib/types-esm/common/domain/Container.d.ts +43 -0
- package/lib/types-esm/common/domain/ControllerProvider.d.ts +17 -0
- package/lib/types-esm/common/domain/InjectablePropertyType.d.ts +7 -0
- package/lib/types-esm/common/domain/LocalsContainer.d.ts +6 -0
- package/lib/types-esm/common/domain/Provider.d.ts +71 -0
- package/lib/types-esm/common/domain/ProviderScope.d.ts +5 -0
- package/lib/types-esm/common/domain/ProviderType.d.ts +10 -0
- package/lib/types-esm/common/errors/InjectionError.d.ts +8 -0
- package/lib/types-esm/common/errors/InvalidPropertyTokenError.d.ts +4 -0
- package/lib/types-esm/common/errors/UndefinedTokenError.d.ts +4 -0
- package/lib/types-esm/common/index.d.ts +55 -0
- package/lib/types-esm/common/interfaces/DIConfigurationOptions.d.ts +29 -0
- package/lib/types-esm/common/interfaces/DILogger.d.ts +8 -0
- package/lib/types-esm/common/interfaces/DILoggerOptions.d.ts +53 -0
- package/lib/types-esm/common/interfaces/DIResolver.d.ts +5 -0
- package/lib/types-esm/common/interfaces/ImportTokenProviderOpts.d.ts +19 -0
- package/lib/types-esm/common/interfaces/InjectableProperties.d.ts +25 -0
- package/lib/types-esm/common/interfaces/InterceptorContext.d.ts +11 -0
- package/lib/types-esm/common/interfaces/InterceptorMethods.d.ts +4 -0
- package/lib/types-esm/common/interfaces/InvokeOptions.d.ts +10 -0
- package/lib/types-esm/common/interfaces/OnDestroy.d.ts +3 -0
- package/lib/types-esm/common/interfaces/OnInit.d.ts +3 -0
- package/lib/types-esm/common/interfaces/ProviderOpts.d.ts +59 -0
- package/lib/types-esm/common/interfaces/RegistrySettings.d.ts +20 -0
- package/lib/types-esm/common/interfaces/ResolvedInvokeOptions.d.ts +12 -0
- package/lib/types-esm/common/interfaces/TokenProvider.d.ts +6 -0
- package/lib/types-esm/common/interfaces/TokenRoute.d.ts +5 -0
- package/lib/types-esm/common/registries/GlobalProviders.d.ts +58 -0
- package/lib/types-esm/common/registries/ProviderRegistry.d.ts +58 -0
- package/lib/types-esm/common/services/DIConfiguration.d.ts +57 -0
- package/lib/types-esm/common/services/DILogger.d.ts +3 -0
- package/lib/types-esm/common/services/InjectorService.d.ts +224 -0
- package/lib/types-esm/common/utils/colors.d.ts +5 -0
- package/lib/types-esm/common/utils/createContainer.d.ts +3 -0
- package/lib/types-esm/common/utils/getConfiguration.d.ts +3 -0
- package/lib/types-esm/common/utils/getConstructorDependencies.d.ts +2 -0
- package/lib/types-esm/common/utils/resolveControllers.d.ts +12 -0
- package/lib/types-esm/index.d.ts +2 -0
- package/lib/types-esm/node/decorators/injectContext.d.ts +15 -0
- package/lib/types-esm/node/domain/ContextLogger.d.ts +37 -0
- package/lib/types-esm/node/domain/DIContext.d.ts +61 -0
- package/lib/types-esm/node/index.d.ts +14 -0
- package/lib/types-esm/node/interfaces/AlterRunInContext.d.ts +3 -0
- package/lib/types-esm/node/services/DILogger.d.ts +1 -0
- package/lib/types-esm/node/services/DITest.d.ts +37 -0
- package/lib/types-esm/node/utils/asyncHookContext.d.ts +14 -0
- package/lib/types-esm/node/utils/attachLogger.d.ts +2 -0
- package/lib/types-esm/node/utils/setLoggerConfiguration.d.ts +2 -0
- package/lib/types-esm/node/utils/setLoggerFormat.d.ts +6 -0
- package/lib/types-esm/node/utils/setLoggerLevel.d.ts +6 -0
- package/package.json +19 -16
- package/vitest.config.mts +21 -0
- package/jest.config.js +0 -14
- package/lib/cjs/package.json +0 -3
- package/lib/esm/package.json +0 -3
- package/tsconfig.esm.json +0 -39
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ProviderScope } from "../domain/ProviderScope.js";
|
|
2
|
+
import type { DIResolver } from "./DIResolver.js";
|
|
3
|
+
import type { ImportTokenProviderOpts } from "./ImportTokenProviderOpts.js";
|
|
4
|
+
import type { TokenProvider } from "./TokenProvider.js";
|
|
5
|
+
declare global {
|
|
6
|
+
namespace TsED {
|
|
7
|
+
interface Context {
|
|
8
|
+
}
|
|
9
|
+
interface Configuration extends Record<string, any> {
|
|
10
|
+
scopes: {
|
|
11
|
+
[key: string]: ProviderScope;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Define a list of resolvers (it can be an external DI).
|
|
15
|
+
*/
|
|
16
|
+
resolvers: DIResolver[];
|
|
17
|
+
/**
|
|
18
|
+
* Define dependencies to build the provider
|
|
19
|
+
*/
|
|
20
|
+
imports: (TokenProvider | ImportTokenProviderOpts)[];
|
|
21
|
+
/**
|
|
22
|
+
* Mount controllers
|
|
23
|
+
*/
|
|
24
|
+
mount: Record<string, TokenProvider[]>;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export interface DIConfigurationOptions extends TsED.Configuration {
|
|
29
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
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
|
+
}
|
|
45
|
+
declare global {
|
|
46
|
+
namespace TsED {
|
|
47
|
+
interface LoggerConfiguration extends DILoggerOptions {
|
|
48
|
+
}
|
|
49
|
+
interface Configuration extends Record<string, any> {
|
|
50
|
+
logger?: LoggerConfiguration;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Type } from "@tsed/core";
|
|
2
|
+
import type { TokenProvider } from "./TokenProvider.js";
|
|
3
|
+
export type UseImportTokenProviderOpts = {
|
|
4
|
+
token: TokenProvider;
|
|
5
|
+
use: unknown;
|
|
6
|
+
};
|
|
7
|
+
export type UseClassImportTokenProviderOpts = {
|
|
8
|
+
token: TokenProvider;
|
|
9
|
+
useClass: Type | Function;
|
|
10
|
+
};
|
|
11
|
+
export type UseFactoryImportTokenProviderOpts = {
|
|
12
|
+
token: TokenProvider;
|
|
13
|
+
useFactory: (...args: unknown[]) => unknown;
|
|
14
|
+
};
|
|
15
|
+
export type UseAsyncFactoryImportTokenProviderOpts = {
|
|
16
|
+
token: TokenProvider;
|
|
17
|
+
useAsyncFactory: (...args: unknown[]) => Promise<unknown>;
|
|
18
|
+
};
|
|
19
|
+
export type ImportTokenProviderOpts = UseImportTokenProviderOpts | UseClassImportTokenProviderOpts | UseFactoryImportTokenProviderOpts | UseAsyncFactoryImportTokenProviderOpts;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { InjectablePropertyType } from "../domain/InjectablePropertyType.js";
|
|
2
|
+
import type { LocalsContainer } from "../domain/LocalsContainer.js";
|
|
3
|
+
import type { TokenProvider } from "./TokenProvider.js";
|
|
4
|
+
import type { InjectorService } from "../services/InjectorService.js";
|
|
5
|
+
import type { InvokeOptions } from "./InvokeOptions.js";
|
|
6
|
+
export interface InjectableProperty {
|
|
7
|
+
propertyKey: string;
|
|
8
|
+
}
|
|
9
|
+
export interface InjectablePropertyOptions extends InjectableProperty {
|
|
10
|
+
bindingType: InjectablePropertyType.METHOD | InjectablePropertyType.PROPERTY | InjectablePropertyType.INTERCEPTOR;
|
|
11
|
+
propertyType: string;
|
|
12
|
+
useType?: TokenProvider;
|
|
13
|
+
resolver: (injector: InjectorService, locals: LocalsContainer, options: Partial<InvokeOptions> & {
|
|
14
|
+
options: any;
|
|
15
|
+
}) => () => any;
|
|
16
|
+
options?: any;
|
|
17
|
+
}
|
|
18
|
+
export interface InjectablePropertyValue extends InjectableProperty {
|
|
19
|
+
bindingType: InjectablePropertyType.CONSTANT | InjectablePropertyType.VALUE;
|
|
20
|
+
expression: string;
|
|
21
|
+
defaultValue?: any;
|
|
22
|
+
}
|
|
23
|
+
export interface InjectableProperties {
|
|
24
|
+
[key: string]: InjectablePropertyOptions | InjectablePropertyValue;
|
|
25
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Type } from "@tsed/core";
|
|
2
|
+
export interface InterceptorNext {
|
|
3
|
+
<T>(err?: Error): T;
|
|
4
|
+
}
|
|
5
|
+
export interface InterceptorContext<Klass = Type, Opts = any> {
|
|
6
|
+
target: Klass;
|
|
7
|
+
propertyKey: string;
|
|
8
|
+
args: any[];
|
|
9
|
+
next: InterceptorNext;
|
|
10
|
+
options?: Opts;
|
|
11
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ProviderScope } from "../domain/ProviderScope.js";
|
|
2
|
+
import { TokenProvider } from "./TokenProvider.js";
|
|
3
|
+
export interface InvokeOptions<T = any> {
|
|
4
|
+
deps: any[];
|
|
5
|
+
imports: any[];
|
|
6
|
+
parent?: TokenProvider;
|
|
7
|
+
scope: ProviderScope;
|
|
8
|
+
useScope: boolean;
|
|
9
|
+
rebuild?: boolean;
|
|
10
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Type } from "@tsed/core";
|
|
2
|
+
import type { ProviderType } from "../domain/ProviderType.js";
|
|
3
|
+
import type { DIResolver } from "./DIResolver.js";
|
|
4
|
+
import type { ProviderScope } from "../domain/ProviderScope.js";
|
|
5
|
+
import type { TokenProvider } from "./TokenProvider.js";
|
|
6
|
+
export interface ProviderOpts<T = any> {
|
|
7
|
+
/**
|
|
8
|
+
* An injection token. (Typically an instance of `Type` or `InjectionToken`, but can be `any`).
|
|
9
|
+
*/
|
|
10
|
+
provide: TokenProvider;
|
|
11
|
+
/**
|
|
12
|
+
* Create alias token to retrieve the instance provider.
|
|
13
|
+
*/
|
|
14
|
+
alias?: TokenProvider;
|
|
15
|
+
/**
|
|
16
|
+
* Provider type
|
|
17
|
+
*/
|
|
18
|
+
type?: TokenProvider | ProviderType;
|
|
19
|
+
/**
|
|
20
|
+
* Instance build by the injector
|
|
21
|
+
*/
|
|
22
|
+
instance?: T;
|
|
23
|
+
/**
|
|
24
|
+
* Define dependencies to build the provider
|
|
25
|
+
*/
|
|
26
|
+
deps?: TokenProvider[];
|
|
27
|
+
/**
|
|
28
|
+
* Class to instantiate for the `token`.
|
|
29
|
+
*/
|
|
30
|
+
useClass?: Type<T>;
|
|
31
|
+
/**
|
|
32
|
+
* Provide a function to build the provider
|
|
33
|
+
*/
|
|
34
|
+
useFactory?: Function;
|
|
35
|
+
/**
|
|
36
|
+
* Provide an async function to build the provider
|
|
37
|
+
*/
|
|
38
|
+
useAsyncFactory?: Function;
|
|
39
|
+
/**
|
|
40
|
+
* Provide predefined value
|
|
41
|
+
*/
|
|
42
|
+
useValue?: any;
|
|
43
|
+
/**
|
|
44
|
+
* Scope used by the injector to build the provider.
|
|
45
|
+
*/
|
|
46
|
+
scope?: ProviderScope;
|
|
47
|
+
/**
|
|
48
|
+
* A list of resolvers which will be used to resolve missing Symbol/Class when injector invoke a Class. This property allow external DI usage.
|
|
49
|
+
*/
|
|
50
|
+
resolvers?: DIResolver[];
|
|
51
|
+
/**
|
|
52
|
+
* hooks to intercept custom events
|
|
53
|
+
*/
|
|
54
|
+
hooks?: Record<string, (instance: T, ...args: any[]) => Promise<any> | any>;
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
*/
|
|
58
|
+
[key: string]: any;
|
|
59
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import type { Provider } from "../domain/Provider.js";
|
|
3
|
+
import type { InjectorService } from "../services/InjectorService.js";
|
|
4
|
+
import type { ResolvedInvokeOptions } from "./ResolvedInvokeOptions.js";
|
|
5
|
+
/**
|
|
6
|
+
* @ignore
|
|
7
|
+
*/
|
|
8
|
+
export interface RegistrySettings {
|
|
9
|
+
injectable?: boolean;
|
|
10
|
+
model?: Type<Provider>;
|
|
11
|
+
/**
|
|
12
|
+
*
|
|
13
|
+
* @param provider
|
|
14
|
+
* @param {Map<string | Function, any>} locals
|
|
15
|
+
* @param options
|
|
16
|
+
*/
|
|
17
|
+
onInvoke?(provider: Provider, locals: Map<string | Function, any>, options: ResolvedInvokeOptions & {
|
|
18
|
+
injector: InjectorService;
|
|
19
|
+
}): void;
|
|
20
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Provider } from "../domain/Provider.js";
|
|
2
|
+
import type { ProviderScope } from "../domain/ProviderScope.js";
|
|
3
|
+
import type { TokenProvider } from "./TokenProvider.js";
|
|
4
|
+
export interface ResolvedInvokeOptions {
|
|
5
|
+
token: TokenProvider;
|
|
6
|
+
parent?: TokenProvider;
|
|
7
|
+
scope: ProviderScope;
|
|
8
|
+
deps: TokenProvider[];
|
|
9
|
+
imports: TokenProvider[];
|
|
10
|
+
provider: Provider;
|
|
11
|
+
construct(deps: TokenProvider[]): any;
|
|
12
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Type } from "@tsed/core";
|
|
2
|
+
import type { LocalsContainer } from "../domain/LocalsContainer.js";
|
|
3
|
+
import { Provider } from "../domain/Provider.js";
|
|
4
|
+
import { ProviderOpts } from "../interfaces/ProviderOpts.js";
|
|
5
|
+
import { RegistrySettings } from "../interfaces/RegistrySettings.js";
|
|
6
|
+
import { ResolvedInvokeOptions } from "../interfaces/ResolvedInvokeOptions.js";
|
|
7
|
+
import { TokenProvider } from "../interfaces/TokenProvider.js";
|
|
8
|
+
import type { InjectorService } from "../services/InjectorService.js";
|
|
9
|
+
export declare class GlobalProviderRegistry extends Map<TokenProvider, Provider> {
|
|
10
|
+
#private;
|
|
11
|
+
/**
|
|
12
|
+
* The get() method returns a specified element from a Map object.
|
|
13
|
+
* @param key Required. The key of the element to return from the Map object.
|
|
14
|
+
* @returns {T} Returns the element associated with the specified key or undefined if the key can't be found in the Map object.
|
|
15
|
+
*/
|
|
16
|
+
get(key: TokenProvider): Provider | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The has() method returns a boolean indicating whether an element with the specified key exists or not.
|
|
19
|
+
* @param key
|
|
20
|
+
* @returns {boolean}
|
|
21
|
+
*/
|
|
22
|
+
has(key: TokenProvider): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* The set() method adds or updates an element with a specified key and value to a Map object.
|
|
25
|
+
* @param key Required. The key of the element to add to the Map object.
|
|
26
|
+
* @param metadata Required. The value of the element to add to the Map object.
|
|
27
|
+
*/
|
|
28
|
+
set(key: TokenProvider, metadata: Provider): this;
|
|
29
|
+
/**
|
|
30
|
+
*
|
|
31
|
+
* @param target
|
|
32
|
+
* @param options
|
|
33
|
+
*/
|
|
34
|
+
merge(target: TokenProvider, options: Partial<ProviderOpts>): Provider<any>;
|
|
35
|
+
/**
|
|
36
|
+
* The delete() method removes the specified element from a Map object.
|
|
37
|
+
* @param key Required. The key of the element to remove from the Map object.
|
|
38
|
+
* @returns {boolean} Returns true if an element in the Map object existed and has been removed, or false if the element does not exist.
|
|
39
|
+
*/
|
|
40
|
+
delete(key: TokenProvider): boolean;
|
|
41
|
+
createRegistry(type: string, model: Type<Provider>, options?: Partial<RegistrySettings>): this;
|
|
42
|
+
onInvoke(provider: Provider, locals: LocalsContainer, options: ResolvedInvokeOptions & {
|
|
43
|
+
injector: InjectorService;
|
|
44
|
+
}): void;
|
|
45
|
+
getRegistrySettings(target: string | TokenProvider): RegistrySettings;
|
|
46
|
+
createRegisterFn(type: string): (provider: any | ProviderOpts, instance?: any) => void;
|
|
47
|
+
/**
|
|
48
|
+
*
|
|
49
|
+
* @param key
|
|
50
|
+
* @param options
|
|
51
|
+
*/
|
|
52
|
+
protected createIfNotExists(key: TokenProvider, options: Partial<ProviderOpts>): Provider;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
*
|
|
56
|
+
* @type {GlobalProviders}
|
|
57
|
+
*/
|
|
58
|
+
export declare const GlobalProviders: GlobalProviderRegistry;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Provider } from "../domain/Provider.js";
|
|
2
|
+
import type { ProviderOpts } from "../interfaces/ProviderOpts.js";
|
|
3
|
+
/**
|
|
4
|
+
* Register a provider configuration.
|
|
5
|
+
* @param {ProviderOpts<any>} provider
|
|
6
|
+
*/
|
|
7
|
+
export declare function registerProvider<Type = any>(provider: Partial<ProviderOpts<Type>>): Provider<any>;
|
|
8
|
+
/**
|
|
9
|
+
* Add a new value in the `ProviderRegistry`.
|
|
10
|
+
*
|
|
11
|
+
* #### Example with symbol definition
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
* ```typescript
|
|
15
|
+
* import {registerValue, InjectorService} from "@tsed/di";
|
|
16
|
+
*
|
|
17
|
+
* const MyValue = Symbol.from("MyValue")
|
|
18
|
+
*
|
|
19
|
+
* registerValue({token: MyValue, useValue: "myValue"});
|
|
20
|
+
*
|
|
21
|
+
* @Service()
|
|
22
|
+
* export class OtherService {
|
|
23
|
+
* constructor(@Inject(MyValue) myValue: string){
|
|
24
|
+
* console.log(myValue); /// "myValue"
|
|
25
|
+
* }
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare const registerValue: (provider: any | ProviderOpts<any>, value?: any) => void;
|
|
30
|
+
/**
|
|
31
|
+
* Add a new controller in the `ProviderRegistry`. This controller will be built when `InjectorService` will be loaded.
|
|
32
|
+
*
|
|
33
|
+
* #### Example
|
|
34
|
+
*
|
|
35
|
+
* ```typescript
|
|
36
|
+
* import {registerController, InjectorService} from "@tsed/di";
|
|
37
|
+
*
|
|
38
|
+
* export default class MyController {
|
|
39
|
+
* constructor(){}
|
|
40
|
+
* transform() {
|
|
41
|
+
* return "test";
|
|
42
|
+
* }
|
|
43
|
+
* }
|
|
44
|
+
*
|
|
45
|
+
* registerController({provide: MyController});
|
|
46
|
+
* // or
|
|
47
|
+
* registerController(MyController);
|
|
48
|
+
*
|
|
49
|
+
* const injector = new InjectorService();
|
|
50
|
+
* injector.load();
|
|
51
|
+
*
|
|
52
|
+
* const myController = injector.get<MyController>(MyController);
|
|
53
|
+
* myController.getFoo(); // test
|
|
54
|
+
* ```
|
|
55
|
+
*
|
|
56
|
+
* @param provider Provider configuration.
|
|
57
|
+
*/
|
|
58
|
+
export declare const registerController: (provider: any, instance?: any) => void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { Env } from "@tsed/core";
|
|
2
|
+
import type { ProviderScope } from "../domain/ProviderScope.js";
|
|
3
|
+
import type { DILoggerOptions } from "../interfaces/DILoggerOptions.js";
|
|
4
|
+
import type { DIResolver } from "../interfaces/DIResolver.js";
|
|
5
|
+
import type { ImportTokenProviderOpts } from "../interfaces/ImportTokenProviderOpts.js";
|
|
6
|
+
import type { TokenProvider } from "../interfaces/TokenProvider.js";
|
|
7
|
+
import type { TokenRoute } from "../interfaces/TokenRoute.js";
|
|
8
|
+
export declare class DIConfiguration {
|
|
9
|
+
readonly default: Map<string, any>;
|
|
10
|
+
protected map: Map<string, any>;
|
|
11
|
+
constructor(initialProps?: {});
|
|
12
|
+
get version(): string;
|
|
13
|
+
set version(v: string);
|
|
14
|
+
get rootDir(): string;
|
|
15
|
+
set rootDir(value: string);
|
|
16
|
+
get env(): Env;
|
|
17
|
+
set env(value: Env);
|
|
18
|
+
get scopes(): Record<string, ProviderScope>;
|
|
19
|
+
set scopes(value: Record<string, ProviderScope>);
|
|
20
|
+
get resolvers(): DIResolver[];
|
|
21
|
+
set resolvers(resolvers: DIResolver[]);
|
|
22
|
+
get imports(): (TokenProvider | ImportTokenProviderOpts)[];
|
|
23
|
+
set imports(imports: (TokenProvider | ImportTokenProviderOpts)[]);
|
|
24
|
+
get routes(): TokenRoute[];
|
|
25
|
+
set routes(routes: TokenRoute[]);
|
|
26
|
+
get logger(): Partial<DILoggerOptions>;
|
|
27
|
+
set logger(value: Partial<DILoggerOptions>);
|
|
28
|
+
get debug(): boolean;
|
|
29
|
+
set debug(debug: boolean);
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param callbackfn
|
|
33
|
+
* @param thisArg
|
|
34
|
+
*/
|
|
35
|
+
forEach(callbackfn: (value: any, index: string, map: Map<string, any>) => void, thisArg?: any): void;
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param propertyKey
|
|
39
|
+
* @param value
|
|
40
|
+
*/
|
|
41
|
+
set(propertyKey: string | Partial<TsED.Configuration>, value?: any): this;
|
|
42
|
+
setRaw(propertyKey: string, value: any): this;
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param propertyKey
|
|
46
|
+
* @param defaultValue
|
|
47
|
+
* @returns {undefined|any}
|
|
48
|
+
*/
|
|
49
|
+
get<T = any>(propertyKey: string, defaultValue?: T): T;
|
|
50
|
+
/**
|
|
51
|
+
*
|
|
52
|
+
* @param value
|
|
53
|
+
* @returns {any}
|
|
54
|
+
*/
|
|
55
|
+
resolve(value: any): any;
|
|
56
|
+
protected getRaw(propertyKey: string, defaultValue?: any): any;
|
|
57
|
+
}
|