@tsed/di 8.0.0-rc.5 → 8.0.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/browser/di.umd.min.js +1 -1
- package/lib/browser/di.umd.min.js.map +1 -1
- package/lib/esm/common/decorators/autoInjectable.js +1 -1
- package/lib/esm/common/decorators/autoInjectable.js.map +1 -1
- package/lib/esm/common/decorators/configuration.js +7 -1
- package/lib/esm/common/decorators/configuration.js.map +1 -1
- package/lib/esm/common/decorators/controller.js +1 -1
- package/lib/esm/common/decorators/injectable.js +3 -3
- package/lib/esm/common/decorators/injectable.js.map +1 -1
- package/lib/esm/common/decorators/module.js +2 -4
- package/lib/esm/common/decorators/module.js.map +1 -1
- package/lib/esm/common/domain/Container.js +2 -2
- package/lib/esm/common/domain/Container.js.map +1 -1
- package/lib/esm/common/domain/ControllerProvider.js +2 -2
- package/lib/esm/common/domain/ControllerProvider.js.map +1 -1
- package/lib/esm/common/domain/LocalsContainer.js +1 -1
- package/lib/esm/common/domain/LocalsContainer.js.map +1 -1
- package/lib/esm/common/domain/Provider.js +44 -29
- package/lib/esm/common/domain/Provider.js.map +1 -1
- package/lib/esm/common/fn/inject.js +3 -2
- package/lib/esm/common/fn/inject.js.map +1 -1
- package/lib/esm/common/fn/injectMany.js +10 -1
- package/lib/esm/common/fn/injectMany.js.map +1 -1
- package/lib/esm/common/fn/injectable.js +2 -48
- package/lib/esm/common/fn/injectable.js.map +1 -1
- package/lib/esm/common/fn/injector.js +5 -17
- package/lib/esm/common/fn/injector.js.map +1 -1
- package/lib/esm/common/fn/lazyInject.js +4 -4
- package/lib/esm/common/fn/lazyInject.js.map +1 -1
- package/lib/esm/common/index.js +2 -3
- package/lib/esm/common/index.js.map +1 -1
- package/lib/esm/common/registries/GlobalProviders.js +8 -14
- package/lib/esm/common/registries/GlobalProviders.js.map +1 -1
- package/lib/esm/common/registries/ProviderRegistry.js +7 -3
- package/lib/esm/common/registries/ProviderRegistry.js.map +1 -1
- package/lib/esm/common/services/DIConfiguration.js +1 -14
- package/lib/esm/common/services/DIConfiguration.js.map +1 -1
- package/lib/esm/common/services/DILogger.js +3 -9
- package/lib/esm/common/services/DILogger.js.map +1 -1
- package/lib/esm/common/services/InjectorService.js +157 -157
- package/lib/esm/common/services/InjectorService.js.map +1 -1
- package/lib/esm/common/utils/discoverHooks.js +14 -0
- package/lib/esm/common/utils/discoverHooks.js.map +1 -0
- package/lib/esm/common/utils/providerBuilder.js +55 -0
- package/lib/esm/common/utils/providerBuilder.js.map +1 -0
- package/lib/esm/node/domain/ContextLogger.js +1 -1
- package/lib/esm/node/domain/ContextLogger.js.map +1 -1
- package/lib/esm/node/domain/DIContext.js.map +1 -1
- package/lib/esm/node/services/DITest.js +9 -14
- package/lib/esm/node/services/DITest.js.map +1 -1
- package/lib/esm/node/utils/attachLogger.js +4 -3
- package/lib/esm/node/utils/attachLogger.js.map +1 -1
- package/lib/esm/node/utils/setLoggerConfiguration.js +3 -3
- package/lib/esm/node/utils/setLoggerConfiguration.js.map +1 -1
- package/lib/esm/node/utils/setLoggerFormat.js +8 -7
- package/lib/esm/node/utils/setLoggerFormat.js.map +1 -1
- package/lib/esm/node/utils/setLoggerLevel.js +4 -4
- package/lib/esm/node/utils/setLoggerLevel.js.map +1 -1
- package/lib/types/common/decorators/controller.d.ts +1 -1
- package/lib/types/common/decorators/injectable.d.ts +1 -1
- package/lib/types/common/decorators/module.d.ts +0 -6
- package/lib/types/common/domain/ControllerProvider.d.ts +1 -1
- package/lib/types/common/domain/LocalsContainer.d.ts +1 -1
- package/lib/types/common/domain/Provider.d.ts +26 -7
- package/lib/types/common/fn/injectMany.d.ts +9 -0
- package/lib/types/common/fn/injectable.d.ts +403 -18
- package/lib/types/common/fn/injector.d.ts +2 -9
- package/lib/types/common/index.d.ts +2 -3
- package/lib/types/common/interfaces/DIConfigurationOptions.d.ts +0 -5
- package/lib/types/common/interfaces/InvokeOptions.d.ts +0 -5
- package/lib/types/common/interfaces/ProviderOpts.d.ts +1 -6
- package/lib/types/common/interfaces/RegistrySettings.d.ts +0 -12
- package/lib/types/common/interfaces/ResolvedInvokeOptions.d.ts +2 -2
- package/lib/types/common/registries/GlobalProviders.d.ts +1 -7
- package/lib/types/common/registries/ProviderRegistry.d.ts +12 -2
- package/lib/types/common/services/DIConfiguration.d.ts +1 -6
- package/lib/types/common/services/InjectorService.d.ts +50 -38
- package/lib/types/common/utils/discoverHooks.d.ts +2 -0
- package/lib/types/common/utils/providerBuilder.d.ts +17 -0
- package/lib/types/node/domain/ContextLogger.d.ts +1 -1
- package/lib/types/node/services/DITest.d.ts +1 -2
- package/lib/types/node/utils/attachLogger.d.ts +2 -2
- package/lib/types/node/utils/setLoggerConfiguration.d.ts +1 -2
- package/lib/types/node/utils/setLoggerFormat.d.ts +1 -3
- package/lib/types/node/utils/setLoggerLevel.d.ts +1 -3
- package/package.json +13 -11
- package/vitest.config.mts +4 -4
- package/lib/esm/common/fn/events.js +0 -31
- package/lib/esm/common/fn/events.js.map +0 -1
- package/lib/esm/common/interfaces/DIResolver.js +0 -2
- package/lib/esm/common/interfaces/DIResolver.js.map +0 -1
- package/lib/esm/common/utils/resolveControllers.js +0 -42
- package/lib/esm/common/utils/resolveControllers.js.map +0 -1
- package/lib/types/common/fn/events.d.ts +0 -23
- package/lib/types/common/interfaces/DIResolver.d.ts +0 -5
- package/lib/types/common/utils/resolveControllers.d.ts +0 -12
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
import { Hooks } from "@tsed/core";
|
|
2
1
|
import { Container } from "../domain/Container.js";
|
|
3
|
-
import { LocalsContainer } from "../domain/LocalsContainer.js";
|
|
4
2
|
import { Provider } from "../domain/Provider.js";
|
|
5
|
-
import { ProviderScope } from "../domain/ProviderScope.js";
|
|
6
3
|
import type { DILogger } from "../interfaces/DILogger.js";
|
|
7
4
|
import type { InvokeOptions } from "../interfaces/InvokeOptions.js";
|
|
8
5
|
import type { TokenProvider } from "../interfaces/TokenProvider.js";
|
|
@@ -21,27 +18,20 @@ import { DIConfiguration } from "./DIConfiguration.js";
|
|
|
21
18
|
* import MyService3 from "./services/service3.js";
|
|
22
19
|
*
|
|
23
20
|
* // When all services are imported, you can load InjectorService.
|
|
24
|
-
* const injector = new InjectorService()
|
|
25
21
|
*
|
|
26
|
-
* await injector.load();
|
|
22
|
+
* await injector().load();
|
|
27
23
|
*
|
|
28
|
-
* const myService1 = injector.get<MyService1>(
|
|
24
|
+
* const myService1 = injector.get<MyService1>(MyService1);
|
|
29
25
|
* ```
|
|
30
26
|
*/
|
|
31
27
|
export declare class InjectorService extends Container {
|
|
32
28
|
#private;
|
|
33
|
-
settings: DIConfiguration;
|
|
34
29
|
logger: DILogger;
|
|
35
|
-
readonly hooks: Hooks;
|
|
36
30
|
private resolvedConfiguration;
|
|
37
31
|
constructor();
|
|
38
|
-
get
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
* Retrieve default scope for a given provider.
|
|
42
|
-
* @param provider
|
|
43
|
-
*/
|
|
44
|
-
scopeOf(provider: Provider): ProviderScope;
|
|
32
|
+
get settings(): DIConfiguration;
|
|
33
|
+
set settings(settings: DIConfiguration);
|
|
34
|
+
isLoaded(): boolean;
|
|
45
35
|
/**
|
|
46
36
|
* Return a list of instance build by the injector.
|
|
47
37
|
*/
|
|
@@ -65,11 +55,11 @@ export declare class InjectorService extends Container {
|
|
|
65
55
|
* @param token The class or symbol registered in InjectorService.
|
|
66
56
|
* @param options
|
|
67
57
|
*/
|
|
68
|
-
get<T = any>(token: TokenProvider<T>, options?:
|
|
58
|
+
get<T = any>(token: TokenProvider<T>, options?: Partial<InvokeOptions>): T;
|
|
69
59
|
/**
|
|
70
60
|
* Return all instance of the same provider type
|
|
71
61
|
*/
|
|
72
|
-
getMany<Type = any>(type: any,
|
|
62
|
+
getMany<Type = any>(type: any, options?: Partial<InvokeOptions>): Type[];
|
|
73
63
|
/**
|
|
74
64
|
* The has() method returns a boolean indicating whether an element with the specified key exists or not.
|
|
75
65
|
*/
|
|
@@ -79,7 +69,9 @@ export declare class InjectorService extends Container {
|
|
|
79
69
|
*/
|
|
80
70
|
alias(token: TokenProvider, alias: TokenProvider): this;
|
|
81
71
|
/**
|
|
82
|
-
*
|
|
72
|
+
* Resolve the token depending on his provider configuration.
|
|
73
|
+
*
|
|
74
|
+
* If the token isn't cached, the injector will invoke the provider and cache the result.
|
|
83
75
|
*
|
|
84
76
|
* #### Example
|
|
85
77
|
*
|
|
@@ -95,11 +87,34 @@ export declare class InjectorService extends Container {
|
|
|
95
87
|
* ```
|
|
96
88
|
*
|
|
97
89
|
* @param token The injectable class to invoke. Class parameters are injected according constructor signature.
|
|
98
|
-
* @param
|
|
99
|
-
* @param options
|
|
90
|
+
* @param options {InvokeOptions} Optional options to invoke the class.
|
|
100
91
|
* @returns {Type} The class constructed.
|
|
101
92
|
*/
|
|
102
|
-
|
|
93
|
+
resolve<Type = any>(token: TokenProvider<Type>, options?: Partial<InvokeOptions>): Type;
|
|
94
|
+
/**
|
|
95
|
+
* Resolve the token depending on his provider configuration.
|
|
96
|
+
*
|
|
97
|
+
* If the token isn't cached, the injector will invoke the provider and cache the result.
|
|
98
|
+
*
|
|
99
|
+
* #### Example
|
|
100
|
+
*
|
|
101
|
+
* ```typescript
|
|
102
|
+
* import {InjectorService} from "@tsed/di";
|
|
103
|
+
* import MyService from "./services.js";
|
|
104
|
+
*
|
|
105
|
+
* class OtherService {
|
|
106
|
+
* constructor(injectorService: InjectorService) {
|
|
107
|
+
* const myService = injectorService.invoke<MyService>(MyService);
|
|
108
|
+
* }
|
|
109
|
+
* }
|
|
110
|
+
* ```
|
|
111
|
+
*
|
|
112
|
+
* @param token The injectable class to invoke. Class parameters are injected according constructor signature.
|
|
113
|
+
* @param options {InvokeOptions} Optional options to invoke the class.
|
|
114
|
+
* @returns {Type} The class constructed.
|
|
115
|
+
* @alias InjectorService.resolve
|
|
116
|
+
*/
|
|
117
|
+
invoke<Type = any>(token: TokenProvider<Type>, options?: Partial<InvokeOptions>): Type;
|
|
103
118
|
/**
|
|
104
119
|
* Build only providers which are asynchronous.
|
|
105
120
|
*/
|
|
@@ -108,17 +123,6 @@ export declare class InjectorService extends Container {
|
|
|
108
123
|
* Build only providers which are synchronous.
|
|
109
124
|
*/
|
|
110
125
|
loadSync(): void;
|
|
111
|
-
/**
|
|
112
|
-
* Boostrap injector from container and resolve configuration.
|
|
113
|
-
*
|
|
114
|
-
* @param container
|
|
115
|
-
*/
|
|
116
|
-
bootstrap(container?: Container): this;
|
|
117
|
-
/**
|
|
118
|
-
* Load injector from a given module
|
|
119
|
-
* @param rootModule
|
|
120
|
-
*/
|
|
121
|
-
loadModule(rootModule: TokenProvider): Promise<void>;
|
|
122
126
|
/**
|
|
123
127
|
* Build all providers from given container (or GlobalProviders) and emit `$onInit` event.
|
|
124
128
|
*
|
|
@@ -126,7 +130,8 @@ export declare class InjectorService extends Container {
|
|
|
126
130
|
*/
|
|
127
131
|
load(container?: Container): Promise<void>;
|
|
128
132
|
/**
|
|
129
|
-
* Load all configurations registered on providers
|
|
133
|
+
* Load all configurations registered on providers via @Configuration decorator.
|
|
134
|
+
* It inspects for each provider some fields like imports, mount, etc. to resolve the configuration.
|
|
130
135
|
*/
|
|
131
136
|
resolveConfiguration(): void;
|
|
132
137
|
/**
|
|
@@ -134,13 +139,15 @@ export declare class InjectorService extends Container {
|
|
|
134
139
|
* @param eventName The event name to emit at all services.
|
|
135
140
|
* @param args List of the parameters to give to each service.
|
|
136
141
|
* @returns A list of promises.
|
|
142
|
+
* @deprecated use $asyncEmit instead
|
|
137
143
|
*/
|
|
138
|
-
emit(eventName: string, ...args:
|
|
144
|
+
emit(eventName: string, ...args: unknown[]): Promise<void>;
|
|
139
145
|
/**
|
|
140
146
|
* Alter value attached to an event.
|
|
141
147
|
* @param eventName
|
|
142
148
|
* @param value
|
|
143
149
|
* @param args
|
|
150
|
+
* @deprecated use $alter instead
|
|
144
151
|
*/
|
|
145
152
|
alter<T = any>(eventName: string, value: any, ...args: any[]): T;
|
|
146
153
|
/**
|
|
@@ -148,12 +155,19 @@ export declare class InjectorService extends Container {
|
|
|
148
155
|
* @param eventName
|
|
149
156
|
* @param value
|
|
150
157
|
* @param args
|
|
158
|
+
* @deprecated use $asyncAlter instead
|
|
151
159
|
*/
|
|
152
160
|
alterAsync<T = any>(eventName: string, value: any, ...args: any[]): Promise<T>;
|
|
153
161
|
/**
|
|
154
162
|
* Destroy the injector and all services.
|
|
155
163
|
*/
|
|
156
164
|
destroy(): Promise<void>;
|
|
165
|
+
/**
|
|
166
|
+
* Bootstrap injector from container, resolve configuration and providers.
|
|
167
|
+
*
|
|
168
|
+
* @param container
|
|
169
|
+
*/
|
|
170
|
+
protected bootstrap(container?: Container): this;
|
|
157
171
|
/**
|
|
158
172
|
* Ensure that a provider is added to the container.
|
|
159
173
|
* @protected
|
|
@@ -161,7 +175,6 @@ export declare class InjectorService extends Container {
|
|
|
161
175
|
protected ensureProvider(token: TokenProvider, force: true): Provider;
|
|
162
176
|
protected ensureProvider(token: TokenProvider, force: false): Provider | undefined;
|
|
163
177
|
protected ensureProvider(token: TokenProvider): Provider | undefined;
|
|
164
|
-
protected getInstance(token: any): any;
|
|
165
178
|
/**
|
|
166
179
|
* Invoke a class method and inject service.
|
|
167
180
|
*
|
|
@@ -175,18 +188,17 @@ export declare class InjectorService extends Container {
|
|
|
175
188
|
* #### Example
|
|
176
189
|
*
|
|
177
190
|
* @param target
|
|
178
|
-
* @param locals
|
|
179
191
|
* @param options
|
|
180
192
|
* @private
|
|
181
193
|
*/
|
|
182
|
-
protected
|
|
194
|
+
protected invokeToken<T>(target: TokenProvider, options?: Partial<InvokeOptions>): T | Promise<T>;
|
|
183
195
|
private resolveImportsProviders;
|
|
184
196
|
/**
|
|
185
197
|
* Create options to invoke a provider or class.
|
|
186
198
|
* @param token
|
|
187
|
-
* @param locals
|
|
188
199
|
* @param options
|
|
189
200
|
*/
|
|
190
201
|
private mapInvokeOptions;
|
|
191
202
|
private registerHooks;
|
|
203
|
+
private setToCache;
|
|
192
204
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import "../registries/ProviderRegistry.js";
|
|
2
|
+
import { Store, type Type } from "@tsed/core";
|
|
3
|
+
import type { ProviderOpts } from "../interfaces/ProviderOpts.js";
|
|
4
|
+
import type { TokenProvider } from "../interfaces/TokenProvider.js";
|
|
5
|
+
type ProviderBuilder<Token extends TokenProvider, BaseProvider, T extends object> = {
|
|
6
|
+
[K in keyof T as T[K] extends (...args: any[]) => any ? never : K]: (value: T[K]) => ProviderBuilder<Token, BaseProvider, T>;
|
|
7
|
+
} & {
|
|
8
|
+
inspect(): BaseProvider;
|
|
9
|
+
store(): Store;
|
|
10
|
+
token(): Token;
|
|
11
|
+
factory(f: (...args: unknown[]) => unknown): ProviderBuilder<Token, BaseProvider, T>;
|
|
12
|
+
asyncFactory(f: (...args: unknown[]) => Promise<unknown>): ProviderBuilder<Token, BaseProvider, T>;
|
|
13
|
+
value(v: unknown): ProviderBuilder<Token, BaseProvider, T>;
|
|
14
|
+
class(c: Type): ProviderBuilder<Token, BaseProvider, T>;
|
|
15
|
+
};
|
|
16
|
+
export declare function providerBuilder<Provider, Picked extends keyof Provider>(props: string[], baseOpts?: Partial<ProviderOpts<Provider>>): <Token extends TokenProvider>(token: Token, options?: Partial<ProviderOpts<Type>>) => ProviderBuilder<Token, Provider, Pick<Provider, Picked>>;
|
|
17
|
+
export {};
|
|
@@ -24,9 +24,8 @@ export declare class DITest {
|
|
|
24
24
|
/**
|
|
25
25
|
* Return the instance from injector registry
|
|
26
26
|
* @param target
|
|
27
|
-
* @param options
|
|
28
27
|
*/
|
|
29
|
-
static get<T = any>(target: TokenProvider
|
|
28
|
+
static get<T = any>(target: TokenProvider): T;
|
|
30
29
|
static createDIContext(): DIContext;
|
|
31
30
|
protected static configure(settings?: Partial<TsED.Configuration>): Partial<TsED.Configuration>;
|
|
32
31
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { DILogger
|
|
2
|
-
export declare function attachLogger(
|
|
1
|
+
import { DILogger } from "../../common/index.js";
|
|
2
|
+
export declare function attachLogger($log: DILogger): void;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function setLoggerConfiguration(injector: InjectorService): void;
|
|
1
|
+
export declare function setLoggerConfiguration(): void;
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@tsed/di",
|
|
3
3
|
"description": "DI module for Ts.ED Framework",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"version": "8.0.0
|
|
5
|
+
"version": "8.0.0",
|
|
6
6
|
"source": "./src/index.ts",
|
|
7
7
|
"main": "./lib/esm/index.js",
|
|
8
8
|
"module": "./lib/esm/index.js",
|
|
@@ -29,11 +29,12 @@
|
|
|
29
29
|
"uuid": "^10.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tsed/barrels": "8.0.0
|
|
33
|
-
"@tsed/core": "8.0.0
|
|
32
|
+
"@tsed/barrels": "8.0.0",
|
|
33
|
+
"@tsed/core": "8.0.0",
|
|
34
|
+
"@tsed/hooks": "8.0.0",
|
|
34
35
|
"@tsed/logger": "^6.7.8",
|
|
35
|
-
"@tsed/schema": "8.0.0
|
|
36
|
-
"@tsed/typescript": "8.0.0
|
|
36
|
+
"@tsed/schema": "8.0.0",
|
|
37
|
+
"@tsed/typescript": "8.0.0",
|
|
37
38
|
"cross-env": "7.0.3",
|
|
38
39
|
"eslint": "9.12.0",
|
|
39
40
|
"typescript": "5.4.5",
|
|
@@ -41,14 +42,18 @@
|
|
|
41
42
|
"webpack": "^5.75.0"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
|
-
"@tsed/core": "8.0.0
|
|
45
|
+
"@tsed/core": "8.0.0",
|
|
46
|
+
"@tsed/hooks": "8.0.0",
|
|
45
47
|
"@tsed/logger": ">=6.7.5",
|
|
46
|
-
"@tsed/schema": "8.0.0
|
|
48
|
+
"@tsed/schema": "8.0.0"
|
|
47
49
|
},
|
|
48
50
|
"peerDependenciesMeta": {
|
|
49
51
|
"@tsed/core": {
|
|
50
52
|
"optional": false
|
|
51
53
|
},
|
|
54
|
+
"@tsed/hooks": {
|
|
55
|
+
"optional": false
|
|
56
|
+
},
|
|
52
57
|
"@tsed/logger": {
|
|
53
58
|
"optional": false
|
|
54
59
|
},
|
|
@@ -62,8 +67,5 @@
|
|
|
62
67
|
},
|
|
63
68
|
"homepage": "https://github.com/tsedio/tsed/tree/production/packages/di",
|
|
64
69
|
"author": "Romain Lenzotti",
|
|
65
|
-
"license": "MIT"
|
|
66
|
-
"publishConfig": {
|
|
67
|
-
"tag": "rc"
|
|
68
|
-
}
|
|
70
|
+
"license": "MIT"
|
|
69
71
|
}
|
package/vitest.config.mts
CHANGED
|
@@ -10,10 +10,10 @@ export default defineConfig(
|
|
|
10
10
|
coverage: {
|
|
11
11
|
...presets.test.coverage,
|
|
12
12
|
thresholds: {
|
|
13
|
-
statements:
|
|
14
|
-
branches:
|
|
15
|
-
functions:
|
|
16
|
-
lines:
|
|
13
|
+
statements: 98.69,
|
|
14
|
+
branches: 97.18,
|
|
15
|
+
functions: 96.62,
|
|
16
|
+
lines: 98.69
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { injector } from "./injector.js";
|
|
2
|
-
/**
|
|
3
|
-
* Alter value attached to an event asynchronously.
|
|
4
|
-
* @param eventName
|
|
5
|
-
* @param value
|
|
6
|
-
* @param args
|
|
7
|
-
* @param callThis
|
|
8
|
-
*/
|
|
9
|
-
export function $alterAsync(eventName, value, ...args) {
|
|
10
|
-
return injector().hooks.asyncAlter(eventName, value, args);
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Emit an event to all service. See service [lifecycle hooks](/docs/services.md#lifecycle-hooks).
|
|
14
|
-
* @param eventName The event name to emit at all services.
|
|
15
|
-
* @param args List of the parameters to give to each service.
|
|
16
|
-
* @returns A list of promises.
|
|
17
|
-
*/
|
|
18
|
-
export function $emit(eventName, ...args) {
|
|
19
|
-
return injector().hooks.asyncEmit(eventName, args);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Alter value attached to an event.
|
|
23
|
-
* @param eventName
|
|
24
|
-
* @param value
|
|
25
|
-
* @param args
|
|
26
|
-
* @param callThis
|
|
27
|
-
*/
|
|
28
|
-
export function $alter(eventName, value, ...args) {
|
|
29
|
-
return injector().hooks.alter(eventName, value, args);
|
|
30
|
-
}
|
|
31
|
-
//# sourceMappingURL=events.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../../src/common/fn/events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,QAAQ,EAAC,MAAM,eAAe,CAAC;AAEvC;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CAAU,SAAiB,EAAE,KAAU,EAAE,GAAG,IAAe;IACpF,OAAO,QAAQ,EAAE,CAAC,KAAK,CAAC,UAAU,CAAI,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AAChE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,KAAK,CAAC,SAAiB,EAAE,GAAG,IAAe;IACzD,OAAO,QAAQ,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACrD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAU,SAAiB,EAAE,KAAc,EAAE,GAAG,IAAe;IACnF,OAAO,QAAQ,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"DIResolver.js","sourceRoot":"","sources":["../../../../src/common/interfaces/DIResolver.ts"],"names":[],"mappings":""}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { isArray, isClass } from "@tsed/core";
|
|
2
|
-
import { ProviderType } from "../domain/ProviderType.js";
|
|
3
|
-
import { GlobalProviders } from "../registries/GlobalProviders.js";
|
|
4
|
-
const lookupProperties = ["mount", "imports"];
|
|
5
|
-
export function getTokens(config) {
|
|
6
|
-
if (!config) {
|
|
7
|
-
return [];
|
|
8
|
-
}
|
|
9
|
-
if (isArray(config)) {
|
|
10
|
-
return config.filter(isClass).map((value) => {
|
|
11
|
-
return { token: value };
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
return Object.keys(config).reduce((list, route) => {
|
|
15
|
-
return [
|
|
16
|
-
...list,
|
|
17
|
-
...[]
|
|
18
|
-
.concat(config[route])
|
|
19
|
-
.filter(isClass)
|
|
20
|
-
.map((token) => ({
|
|
21
|
-
route,
|
|
22
|
-
token
|
|
23
|
-
}))
|
|
24
|
-
];
|
|
25
|
-
}, []);
|
|
26
|
-
}
|
|
27
|
-
function resolveRecursively(providers) {
|
|
28
|
-
return providers
|
|
29
|
-
.map(({ token }) => GlobalProviders.get(token))
|
|
30
|
-
.filter((provider) => provider?.type === ProviderType.MODULE && provider.configuration)
|
|
31
|
-
.flatMap((provider) => resolveControllers(provider.configuration));
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Return controllers and is base route according to his configuration in module configuration.
|
|
35
|
-
*
|
|
36
|
-
* @param settings
|
|
37
|
-
*/
|
|
38
|
-
export function resolveControllers(settings) {
|
|
39
|
-
const providers = lookupProperties.flatMap((property) => getTokens(settings[property]));
|
|
40
|
-
return [...resolveRecursively(providers), ...providers].filter((provider) => !!provider.route);
|
|
41
|
-
}
|
|
42
|
-
//# sourceMappingURL=resolveControllers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolveControllers.js","sourceRoot":"","sources":["../../../../src/common/utils/resolveControllers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,OAAO,EAAC,MAAM,YAAY,CAAC;AAG5C,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EAAC,eAAe,EAAC,MAAM,kCAAkC,CAAC;AAEjE,MAAM,gBAAgB,GAAG,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;AAE9C,MAAM,UAAU,SAAS,CAAC,MAAW;IACnC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,IAAI,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACpB,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,KAAU,EAAE,EAAE;YAC/C,OAAO,EAAC,KAAK,EAAE,KAAK,EAAC,CAAC;QACxB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,IAAW,EAAE,KAAa,EAAE,EAAE;QAC/D,OAAO;YACL,GAAG,IAAI;YACP,GAAG,EAAE;iBACF,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;iBACrB,MAAM,CAAC,OAAO,CAAC;iBACf,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;gBACf,KAAK;gBACL,KAAK;aACN,CAAC,CAAC;SACN,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC;AAED,SAAS,kBAAkB,CAAC,SAAmD;IAC7E,OAAO,SAAS;SACb,GAAG,CAAC,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC5C,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,IAAI,KAAK,YAAY,CAAC,MAAM,IAAI,QAAQ,CAAC,aAAa,CAAC;SACtF,OAAO,CAAC,CAAC,QAAkB,EAAE,EAAE,CAAC,kBAAkB,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;AACjF,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,QAAqC;IACtE,MAAM,SAAS,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;IAExF,OAAO,CAAC,GAAG,kBAAkB,CAAC,SAAS,CAAC,EAAE,GAAG,SAAS,CAAC,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAU,CAAC;AAC1G,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Alter value attached to an event asynchronously.
|
|
3
|
-
* @param eventName
|
|
4
|
-
* @param value
|
|
5
|
-
* @param args
|
|
6
|
-
* @param callThis
|
|
7
|
-
*/
|
|
8
|
-
export declare function $alterAsync<T = any>(eventName: string, value: any, ...args: unknown[]): Promise<T>;
|
|
9
|
-
/**
|
|
10
|
-
* Emit an event to all service. See service [lifecycle hooks](/docs/services.md#lifecycle-hooks).
|
|
11
|
-
* @param eventName The event name to emit at all services.
|
|
12
|
-
* @param args List of the parameters to give to each service.
|
|
13
|
-
* @returns A list of promises.
|
|
14
|
-
*/
|
|
15
|
-
export declare function $emit(eventName: string, ...args: unknown[]): Promise<void>;
|
|
16
|
-
/**
|
|
17
|
-
* Alter value attached to an event.
|
|
18
|
-
* @param eventName
|
|
19
|
-
* @param value
|
|
20
|
-
* @param args
|
|
21
|
-
* @param callThis
|
|
22
|
-
*/
|
|
23
|
-
export declare function $alter<T = any>(eventName: string, value: unknown, ...args: unknown[]): T;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { TokenProvider } from "../interfaces/TokenProvider.js";
|
|
2
|
-
import { TokenRoute } from "../interfaces/TokenRoute.js";
|
|
3
|
-
export declare function getTokens(config: any): {
|
|
4
|
-
route?: string;
|
|
5
|
-
token: TokenProvider;
|
|
6
|
-
}[];
|
|
7
|
-
/**
|
|
8
|
-
* Return controllers and is base route according to his configuration in module configuration.
|
|
9
|
-
*
|
|
10
|
-
* @param settings
|
|
11
|
-
*/
|
|
12
|
-
export declare function resolveControllers(settings: Partial<TsED.Configuration>): TokenRoute[];
|