@tsed/di 8.19.5 → 8.20.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.
@@ -1,5 +1,5 @@
1
1
  import type { Type } from "@tsed/core/types/Type.js";
2
- import type { ControllerMiddlewares } from "../domain/ControllerProvider.js";
2
+ import type { ControllerMiddlewares } from "../domain/Provider.js";
3
3
  import { ProviderOpts } from "../interfaces/ProviderOpts.js";
4
4
  export type PathType = string | RegExp | (string | RegExp)[];
5
5
  export interface ControllerOptions extends Partial<ProviderOpts<any>> {
@@ -1,17 +1,4 @@
1
- import { TokenProvider } from "../interfaces/TokenProvider.js";
2
1
  import { Provider } from "./Provider.js";
3
- /**
4
- * Middleware configuration for a controller.
5
- *
6
- * Defines middleware tokens to be applied at different stages of request processing.
7
- *
8
- * @public
9
- */
10
- export interface ControllerMiddlewares {
11
- useBefore: TokenProvider[];
12
- use: TokenProvider[];
13
- useAfter: TokenProvider[];
14
- }
15
2
  /**
16
3
  * Specialized provider for HTTP controllers.
17
4
  *
@@ -33,18 +20,6 @@ export interface ControllerMiddlewares {
33
20
  *
34
21
  * @typeParam T - The type of controller class
35
22
  * @public
23
+ * @deprecated Use Provider instead.
36
24
  */
37
- export declare class ControllerProvider<T = any> extends Provider<T> {
38
- tokenRouter: string;
39
- constructor(token: TokenProvider, options?: Partial<Provider>);
40
- /**
41
- *
42
- * @returns {any[]}
43
- */
44
- get middlewares(): Partial<ControllerMiddlewares>;
45
- /**
46
- *
47
- * @param middlewares
48
- */
49
- set middlewares(middlewares: Partial<ControllerMiddlewares>);
50
- }
25
+ export declare const ControllerProvider: typeof Provider;
@@ -4,6 +4,18 @@ import type { ProviderOpts } from "../interfaces/ProviderOpts.js";
4
4
  import type { TokenProvider } from "../interfaces/TokenProvider.js";
5
5
  import { ProviderScope } from "./ProviderScope.js";
6
6
  import { ProviderType } from "./ProviderType.js";
7
+ /**
8
+ * Middleware configuration for a controller.
9
+ *
10
+ * Defines middleware tokens to be applied at different stages of request processing.
11
+ *
12
+ * @public
13
+ */
14
+ export interface ControllerMiddlewares {
15
+ useBefore: TokenProvider[];
16
+ use: TokenProvider[];
17
+ useAfter: TokenProvider[];
18
+ }
7
19
  /**
8
20
  * Callback function type for provider lifecycle hooks.
9
21
  *
@@ -33,20 +45,65 @@ export type ProviderHookCallback<T = any> = (instance: T, ...args: unknown[]) =>
33
45
  export declare class Provider<T = any> implements ProviderOpts<T> {
34
46
  #private;
35
47
  /**
36
- * Token group provider to retrieve all provider from the same type
48
+ * Global registry for storing all providers in the dependency injection system.
49
+ * Maps provider tokens to their Provider instances.
50
+ */
51
+ static readonly Registry: Map<any, Provider<any>>;
52
+ /**
53
+ * Token group provider to retrieve all providers from the same type
37
54
  */
38
55
  type: ProviderType | TokenProvider;
56
+ /**
57
+ * Array of token providers that this provider depends on
58
+ */
39
59
  deps: TokenProvider[];
60
+ /**
61
+ * Array of providers or provider arrays to be imported
62
+ */
40
63
  imports: (TokenProvider | [TokenProvider])[];
64
+ /**
65
+ * Alternative name/alias for this provider
66
+ */
41
67
  alias: string;
68
+ /**
69
+ * Priority value affecting the order of provider initialization
70
+ */
42
71
  priority: number;
72
+ /**
73
+ * Optional factory function to create provider instances
74
+ */
43
75
  useFactory?: Function;
76
+ /**
77
+ * Optional async factory function to create provider instances
78
+ */
44
79
  useAsyncFactory?: Function;
80
+ /**
81
+ * Optional static value to use instead of creating instances
82
+ */
45
83
  useValue?: unknown;
84
+ /**
85
+ * Map of lifecycle hook callbacks for this provider
86
+ */
46
87
  hooks: Record<string, ProviderHookCallback<T>>;
88
+ /**
89
+ * Router token for routing-related providers
90
+ */
91
+ tokenRouter: string;
47
92
  [key: string]: any;
93
+ /**
94
+ * Creates a new Provider instance
95
+ * @param token - The token used to identify this provider
96
+ * @param options - Optional configuration options for the provider
97
+ */
48
98
  constructor(token: TokenProvider<T>, options?: Partial<Provider>);
99
+ /**
100
+ * Get the provider's token
101
+ */
49
102
  get token(): TokenProvider;
103
+ /**
104
+ * Set the provider's token and initialize stores
105
+ * @param value - The token to set
106
+ */
50
107
  set token(value: TokenProvider);
51
108
  /**
52
109
  * @deprecated
@@ -57,10 +114,13 @@ export declare class Provider<T = any> implements ProviderOpts<T> {
57
114
  * @param value
58
115
  */
59
116
  set provide(value: TokenProvider);
117
+ /**
118
+ * Gets the class type used to instantiate this provider
119
+ */
60
120
  get useClass(): Type<T>;
61
121
  /**
62
- * Create a new store if the given value is a class. Otherwise, the value is ignored.
63
- * @param value
122
+ * Sets the class type and initializes store/hooks for this provider
123
+ * @param value - The class type to use for instantiation
64
124
  */
65
125
  set useClass(value: Type<T> | AbstractType<T>);
66
126
  get className(): string;
@@ -83,10 +143,26 @@ export declare class Provider<T = any> implements ProviderOpts<T> {
83
143
  * @param scope
84
144
  */
85
145
  set scope(scope: ProviderScope);
146
+ /**
147
+ * Gets the provider configuration settings
148
+ */
86
149
  get configuration(): Partial<TsED.Configuration>;
150
+ /**
151
+ * Sets the provider configuration settings
152
+ * @param configuration - The configuration object to set
153
+ */
87
154
  set configuration(configuration: Partial<TsED.Configuration>);
88
155
  get children(): TokenProvider[];
89
156
  set children(children: TokenProvider[]);
157
+ /**
158
+ * Gets the configured middleware stack for this provider
159
+ */
160
+ get middlewares(): Partial<ControllerMiddlewares>;
161
+ /**
162
+ * Sets middleware configuration, merging with existing middlewares
163
+ * @param middlewares - The middleware configuration to apply
164
+ */
165
+ set middlewares(middlewares: Partial<ControllerMiddlewares>);
90
166
  getArgOpts(index: number): any;
91
167
  /**
92
168
  * Retrieves a value from the provider's store.
@@ -104,15 +180,24 @@ export declare class Provider<T = any> implements ProviderOpts<T> {
104
180
  isAsync(): boolean;
105
181
  clone(): Provider;
106
182
  /**
107
- *
108
- * @returns {boolean}
183
+ * Checks if this provider has any child controllers
184
+ * @returns True if provider has children, false otherwise
109
185
  */
110
186
  hasChildren(): boolean;
111
187
  /**
112
- *
113
- * @returns {boolean}
188
+ * Checks if this provider has a parent controller
189
+ * @returns True if provider has a parent, false otherwise
114
190
  */
115
191
  hasParent(): boolean;
192
+ /**
193
+ * Returns a string representation of this provider
194
+ * @returns A string containing the provider's token, class and factory information
195
+ */
116
196
  toString(): string;
197
+ /**
198
+ * Resets the provider's factory configuration
199
+ * Clears useValue, useFactory and useAsyncFactory
200
+ * @returns This provider instance
201
+ */
117
202
  reset(): this;
118
203
  }
@@ -0,0 +1,252 @@
1
+ import type { Store } from "@tsed/core";
2
+ import type { Type } from "@tsed/core/types/Type.js";
3
+ import { Provider } from "../domain/Provider.js";
4
+ import type { ProviderOpts } from "../interfaces/ProviderOpts.js";
5
+ import type { FactoryTokenProvider } from "../interfaces/TokenProvider.js";
6
+ declare global {
7
+ namespace TsED {
8
+ interface ProviderBuilder<Token> {
9
+ /**
10
+ * Sets the provider scope
11
+ * @param scope - The scope to set for this provider
12
+ * @returns Current builder instance
13
+ */
14
+ scope(scope: Provider["scope"]): this;
15
+ /**
16
+ * Sets the provider path
17
+ * @param path - The path to set for this provider
18
+ * @returns Current builder instance
19
+ */
20
+ path(path: Provider["path"]): this;
21
+ /**
22
+ * Sets the provider alias
23
+ * @param alias - The alias to set for this provider
24
+ * @returns Current builder instance
25
+ */
26
+ alias(alias: Provider["alias"]): this;
27
+ /**
28
+ * Sets the provider hooks
29
+ * @param hooks - The hooks to set for this provider
30
+ * @returns Current builder instance
31
+ */
32
+ hooks(hooks: Provider["hooks"]): this;
33
+ /**
34
+ * Sets the provider dependencies
35
+ * @param deps - The dependencies to set for this provider
36
+ * @returns Current builder instance
37
+ */
38
+ deps(deps: Provider["deps"]): this;
39
+ /**
40
+ * Sets the provider imports
41
+ * @param imports - The imports to set for this provider
42
+ * @returns Current builder instance
43
+ */
44
+ imports(imports: Provider["imports"]): this;
45
+ /**
46
+ * Sets the provider configuration
47
+ * @param configuration - The configuration to set for this provider
48
+ * @returns Current builder instance
49
+ */
50
+ configuration(configuration: Provider["configuration"]): this;
51
+ /**
52
+ * Sets the provider priority
53
+ * @param priority - The priority to set for this provider
54
+ * @returns Current builder instance
55
+ */
56
+ priority(priority: Provider["priority"]): this;
57
+ /**
58
+ * Sets the provider type
59
+ * @param type - The type to set for this provider
60
+ * @returns Current builder instance
61
+ */
62
+ type(type: Provider["type"]): this;
63
+ /**
64
+ * Sets the provider children
65
+ * @param children - The children to set for this provider
66
+ * @returns Current builder instance
67
+ */
68
+ children(children: Provider["children"]): this;
69
+ /**
70
+ * Sets the provider middlewares
71
+ * @param middlewares - The middlewares to set for this provider
72
+ * @returns Current builder instance
73
+ */
74
+ middlewares(middlewares: Provider["middlewares"]): this;
75
+ /**
76
+ * Sets a factory function for the provider
77
+ * @param factory - Factory function that creates provider instances
78
+ * @returns Builder instance with updated factory type
79
+ */
80
+ factory<FactoryReturn>(factory: (...args: unknown[]) => FactoryReturn): TsED.ProviderBuilder<FactoryTokenProvider<FactoryReturn>>;
81
+ /**
82
+ * Sets an async factory function for the provider
83
+ * @param asyncFactory - Async factory function that creates provider instances
84
+ * @returns Builder instance with updated factory type
85
+ */
86
+ asyncFactory<FactoryReturn>(asyncFactory: (...args: unknown[]) => Promise<FactoryReturn>): TsED.ProviderBuilder<FactoryTokenProvider<FactoryReturn>>;
87
+ /**
88
+ * Sets a static value for the provider
89
+ * @param value - Value to be provided
90
+ * @returns Builder instance with value type
91
+ */
92
+ value<Value>(value: Value): TsED.ProviderBuilder<FactoryTokenProvider<Value>>;
93
+ /**
94
+ * Sets the class to be used by the provider
95
+ * @param k - Class type to be provided
96
+ * @returns Builder instance with class type
97
+ */
98
+ class<TokenKlass extends Type>(k: TokenKlass): TsED.ClassProviderBuilder<TokenKlass>;
99
+ /**
100
+ * Gets the provider's store
101
+ * @returns Provider store instance
102
+ */
103
+ store(): Store;
104
+ /**
105
+ * Gets the underlying provider instance
106
+ * @returns Provider instance
107
+ */
108
+ inspect(): Provider<Token>;
109
+ /**
110
+ * Gets the provider's token
111
+ * @returns Provider token
112
+ */
113
+ token(): Token;
114
+ /**
115
+ * Sets a value in the provider's store
116
+ * @param key - Key to store the value under
117
+ * @param value - Value to store
118
+ * @returns Current builder instance
119
+ */
120
+ set(key: string, value: unknown): this;
121
+ }
122
+ interface ClassProviderBuilder<Token extends Type> extends ProviderBuilder<Token> {
123
+ }
124
+ }
125
+ }
126
+ export declare class ProviderBuilder<Token> {
127
+ protected provider: Provider<Token>;
128
+ /**
129
+ * Creates a new Provider Builder instance
130
+ * @param options - Provider options including token and configuration
131
+ */
132
+ constructor(options: ProviderOpts<Token>);
133
+ static add<Keys extends keyof ClassProviderBuilder, Token extends Type>(property: Keys, method: (this: ClassProviderBuilder<Token>, ...args: Parameters<ClassProviderBuilder<Token>[Keys]>) => ReturnType<ClassProviderBuilder<Token>[Keys]>): typeof ProviderBuilder;
134
+ /**
135
+ * Sets the provider scope
136
+ * @param scope - The scope to set for this provider
137
+ * @returns Current builder instance
138
+ */
139
+ scope(scope: Provider["scope"]): ProviderBuilder<Token>;
140
+ /**
141
+ * Sets the provider path
142
+ * @param path - The path to set for this provider
143
+ * @returns Current builder instance
144
+ */
145
+ path(path: Provider["path"]): ProviderBuilder<Token>;
146
+ /**
147
+ * Sets the provider alias
148
+ * @param alias - The alias to set for this provider
149
+ * @returns Current builder instance
150
+ */
151
+ alias(alias: Provider["alias"]): ProviderBuilder<Token>;
152
+ /**
153
+ * Sets the provider hooks
154
+ * @param hooks - The hooks to set for this provider
155
+ * @returns Current builder instance
156
+ */
157
+ hooks(hooks: Provider["hooks"]): ProviderBuilder<Token>;
158
+ /**
159
+ * Sets the provider dependencies
160
+ * @param deps - The dependencies to set for this provider
161
+ * @returns Current builder instance
162
+ */
163
+ deps(deps: Provider["deps"]): ProviderBuilder<Token>;
164
+ /**
165
+ * Sets the provider imports
166
+ * @param imports - The imports to set for this provider
167
+ * @returns Current builder instance
168
+ */
169
+ imports(imports: Provider["imports"]): ProviderBuilder<Token>;
170
+ /**
171
+ * Sets the provider configuration
172
+ * @param configuration - The configuration to set for this provider
173
+ * @returns Current builder instance
174
+ */
175
+ configuration(configuration: Provider["configuration"]): ProviderBuilder<Token>;
176
+ /**
177
+ * Sets the provider priority
178
+ * @param priority - The priority to set for this provider
179
+ * @returns Current builder instance
180
+ */
181
+ priority(priority: Provider["priority"]): ProviderBuilder<Token>;
182
+ /**
183
+ * Sets the provider type
184
+ * @param type - The type to set for this provider
185
+ * @returns Current builder instance
186
+ */
187
+ type(type: Provider["type"]): ProviderBuilder<Token>;
188
+ /**
189
+ * Sets the provider children
190
+ * @param children - The children to set for this provider
191
+ * @returns Current builder instance
192
+ */
193
+ children(children: Provider["children"]): ProviderBuilder<Token>;
194
+ /**
195
+ * Sets the provider middlewares
196
+ * @param middlewares - The middlewares to set for this provider
197
+ * @returns Current builder instance
198
+ */
199
+ middlewares(middlewares: Provider["middlewares"]): ProviderBuilder<Token>;
200
+ /**
201
+ * Sets a factory function for the provider
202
+ * @param factory - Factory function that creates provider instances
203
+ * @returns Builder instance with updated factory type
204
+ */
205
+ factory<FactoryReturn>(factory: (...args: unknown[]) => FactoryReturn): ProviderBuilder<FactoryTokenProvider<FactoryReturn>>;
206
+ /**
207
+ * Sets an async factory function for the provider
208
+ * @param asyncFactory - Async factory function that creates provider instances
209
+ * @returns Builder instance with updated factory type
210
+ */
211
+ asyncFactory<FactoryReturn>(asyncFactory: (...args: unknown[]) => Promise<FactoryReturn>): ProviderBuilder<FactoryTokenProvider<FactoryReturn>>;
212
+ /**
213
+ * Sets a static value for the provider
214
+ * @param value - Value to be provided
215
+ * @returns Builder instance with value type
216
+ */
217
+ value<Value>(value: Value): ProviderBuilder<FactoryTokenProvider<Value>>;
218
+ /**
219
+ * Sets the class to be used by the provider
220
+ * @param k - Class type to be provided
221
+ * @returns Builder instance with class type
222
+ */
223
+ class<TokenKlass>(k: Type<TokenKlass>): ProviderBuilder<TokenKlass>;
224
+ /**
225
+ * Gets the provider's store
226
+ * @returns Provider store instance
227
+ */
228
+ store(): Store;
229
+ /**
230
+ * Gets the underlying provider instance
231
+ * @returns Provider instance
232
+ */
233
+ inspect(): Provider<Token>;
234
+ /**
235
+ * Gets the provider's token
236
+ * @returns Provider token
237
+ */
238
+ token(): Token;
239
+ /**
240
+ * Sets a value in the provider's store
241
+ * @param key - Key to store the value under
242
+ * @param value - Value to store
243
+ * @returns Current builder instance
244
+ */
245
+ set(key: string, value: unknown): ProviderBuilder<Token>;
246
+ }
247
+ type ClassProviderBuilder<Token extends Type = any> = TsED.ClassProviderBuilder<Token>;
248
+ export declare function providerBuilder(baseOpts?: Partial<ProviderOpts>): {
249
+ <Token extends Type>(token: Token, options?: Partial<ProviderOpts>): TsED.ClassProviderBuilder<Token>;
250
+ <Token extends unknown>(token: Token, options?: Partial<ProviderOpts>): TsED.ProviderBuilder<Token>;
251
+ };
252
+ export {};
@@ -0,0 +1,10 @@
1
+ import { type Type } from "@tsed/core";
2
+ import type { InterceptorMethods } from "../interfaces/InterceptorMethods.js";
3
+ import type { TokenProvider } from "../interfaces/TokenProvider.js";
4
+ declare global {
5
+ namespace TsED {
6
+ interface ClassProviderBuilder<Token extends Type> {
7
+ intercept(property: keyof InstanceType<Token>, interceptor: TokenProvider<InterceptorMethods>, options: Record<string, unknown>): this;
8
+ }
9
+ }
10
+ }
@@ -1,6 +1,5 @@
1
- import { ControllerProvider } from "../domain/ControllerProvider.js";
2
- import type { Provider } from "../domain/Provider.js";
3
- type PickedProps = "scope" | "path" | "alias" | "hooks" | "deps" | "imports" | "configuration" | "priority";
1
+ import type { ProviderOpts } from "../interfaces/ProviderOpts.js";
2
+ import type { TokenProvider } from "../interfaces/TokenProvider.js";
4
3
  /**
5
4
  * Fluent builder for registering providers programmatically.
6
5
  *
@@ -25,7 +24,10 @@ type PickedProps = "scope" | "path" | "alias" | "hooks" | "deps" | "imports" | "
25
24
  *
26
25
  * @public
27
26
  */
28
- export declare const injectable: import("../utils/providerBuilder.js").ProviderBuilderFn<Provider<any>, "type" | PickedProps>;
27
+ export declare const injectable: {
28
+ <Token extends import("@tsed/core").Type>(token: Token, options?: Partial<ProviderOpts>): TsED.ClassProviderBuilder<Token>;
29
+ <Token extends unknown>(token: Token, options?: Partial<ProviderOpts>): TsED.ProviderBuilder<Token>;
30
+ };
29
31
  /**
30
32
  * Fluent builder for registering interceptor providers.
31
33
  *
@@ -41,7 +43,10 @@ export declare const injectable: import("../utils/providerBuilder.js").ProviderB
41
43
  *
42
44
  * @public
43
45
  */
44
- export declare const interceptor: import("../utils/providerBuilder.js").ProviderBuilderFn<Provider<any>, "type" | PickedProps>;
46
+ export declare const interceptor: {
47
+ <Token extends import("@tsed/core").Type>(token: Token, options?: Partial<ProviderOpts>): TsED.ClassProviderBuilder<Token>;
48
+ <Token extends unknown>(token: Token, options?: Partial<ProviderOpts>): TsED.ProviderBuilder<Token>;
49
+ };
45
50
  /**
46
51
  * Fluent builder for registering controller providers.
47
52
  *
@@ -60,5 +65,21 @@ export declare const interceptor: import("../utils/providerBuilder.js").Provider
60
65
  *
61
66
  * @public
62
67
  */
63
- export declare const controller: import("../utils/providerBuilder.js").ProviderBuilderFn<ControllerProvider<any>, "children" | "middlewares" | PickedProps>;
68
+ export declare const controller: {
69
+ <Token extends import("@tsed/core").Type>(token: Token, options?: Partial<ProviderOpts>): TsED.ClassProviderBuilder<Token>;
70
+ <Token extends unknown>(token: Token, options?: Partial<ProviderOpts>): TsED.ProviderBuilder<Token>;
71
+ };
72
+ type Opts<Type = any> = Partial<ProviderOpts<Type>> & ({
73
+ token: TokenProvider<Type>;
74
+ } | {
75
+ /**
76
+ * @deprecated use token prop instead
77
+ */
78
+ provide: TokenProvider<Type>;
79
+ });
80
+ /**
81
+ * Register a provider configuration.
82
+ * @deprecated Since v8. Use injectable() function instead.
83
+ */
84
+ export declare function registerProvider<Type = any>({ token, provide, ...opts }: Opts<Type>): import("../index.js").Provider<any>;
64
85
  export {};
@@ -25,10 +25,12 @@ export * from "./domain/DIContext.js";
25
25
  export * from "./domain/InjectablePropertyType.js";
26
26
  export * from "./domain/LocalsContainer.js";
27
27
  export * from "./domain/Provider.js";
28
+ export * from "./domain/ProviderBuilder.js";
28
29
  export * from "./domain/ProviderScope.js";
29
30
  export * from "./domain/ProviderType.js";
30
31
  export * from "./errors/InjectionError.js";
31
32
  export * from "./errors/InvalidPropertyTokenError.js";
33
+ export * from "./extends/intercept.js";
32
34
  export * from "./fn/configuration.js";
33
35
  export * from "./fn/constant.js";
34
36
  export * from "./fn/inject.js";
@@ -55,7 +57,6 @@ export * from "./interfaces/ResolvedInvokeOptions.js";
55
57
  export * from "./interfaces/TokenProvider.js";
56
58
  export * from "./interfaces/TokenRoute.js";
57
59
  export * from "./registries/GlobalProviders.js";
58
- export * from "./registries/ProviderRegistry.js";
59
60
  export * from "./services/DIConfiguration.js";
60
61
  export * from "./services/DILogger.js";
61
62
  export * from "./services/InjectorService.js";
@@ -65,7 +66,6 @@ export * from "./utils/createContainer.js";
65
66
  export * from "./utils/discoverHooks.js";
66
67
  export * from "./utils/getConfiguration.js";
67
68
  export * from "./utils/getConstructorDependencies.js";
68
- export * from "./utils/providerBuilder.js";
69
69
  export * from "./utils/setLoggerConfiguration.js";
70
70
  export * from "./utils/setLoggerFormat.js";
71
71
  export * from "./utils/setLoggerLevel.js";
@@ -1,52 +1,7 @@
1
- import type { Type } from "@tsed/core/types/Type.js";
2
1
  import { Provider } from "../domain/Provider.js";
3
- import { ProviderOpts } from "../interfaces/ProviderOpts.js";
4
- import { RegistrySettings } from "../interfaces/RegistrySettings.js";
5
- import { TokenProvider } from "../interfaces/TokenProvider.js";
6
- export declare class GlobalProviderRegistry extends Map<TokenProvider, Provider> {
7
- #private;
8
- /**
9
- * The get() method returns a specified element from a Map object.
10
- * @param key Required. The key of the element to return from the Map object.
11
- * @returns {T} Returns the element associated with the specified key or undefined if the key can't be found in the Map object.
12
- */
13
- get(key: TokenProvider): Provider | undefined;
14
- /**
15
- * The has() method returns a boolean indicating whether an element with the specified key exists or not.
16
- * @param key
17
- * @returns {boolean}
18
- */
19
- has(key: TokenProvider): boolean;
20
- /**
21
- * The set() method adds or updates an element with a specified key and value to a Map object.
22
- * @param key Required. The key of the element to add to the Map object.
23
- * @param metadata Required. The value of the element to add to the Map object.
24
- */
25
- set(key: TokenProvider, metadata: Provider): this;
26
- /**
27
- *
28
- * @param target
29
- * @param options
30
- */
31
- merge(target: TokenProvider, options: Partial<ProviderOpts>): Provider<any>;
32
- /**
33
- * The delete() method removes the specified element from a Map object.
34
- * @param key Required. The key of the element to remove from the Map object.
35
- * @returns {boolean} Returns true if an element in the Map object existed and has been removed, or false if the element does not exist.
36
- */
37
- delete(key: TokenProvider): boolean;
38
- createRegistry(type: string | symbol, model: Type<Provider>, options?: Partial<RegistrySettings>): this;
39
- getRegistrySettings(target: TokenProvider): RegistrySettings;
40
- protected createProvider(key: TokenProvider, options: Partial<ProviderOpts<any>>): Provider<any>;
41
- /**
42
- *
43
- * @param key
44
- * @param options
45
- */
46
- protected createIfNotExists(key: TokenProvider, options: Partial<ProviderOpts>): Provider;
47
- }
48
2
  /**
49
- *
50
- * @type {GlobalProviders}
3
+ * Registry for managing global providers in the dependency injection system.
4
+ * Extends the Map class to store TokenProvider-Provider pairs.
5
+ * @deprecated Use Provider.Registry instead
51
6
  */
52
- export declare const GlobalProviders: GlobalProviderRegistry;
7
+ export declare const GlobalProviders: Map<any, Provider<any>>;
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.19.5",
5
+ "version": "8.20.0",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -29,11 +29,11 @@
29
29
  "uuid": "^10.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@tsed/barrels": "8.19.5",
33
- "@tsed/core": "8.19.5",
34
- "@tsed/hooks": "8.19.5",
32
+ "@tsed/barrels": "8.20.0",
33
+ "@tsed/core": "8.20.0",
34
+ "@tsed/hooks": "8.20.0",
35
35
  "@tsed/logger": "^8.0.0",
36
- "@tsed/typescript": "8.19.5",
36
+ "@tsed/typescript": "8.20.0",
37
37
  "cross-env": "7.0.3",
38
38
  "eslint": "9.12.0",
39
39
  "typescript": "5.9.3",
@@ -1,15 +0,0 @@
1
- import { ControllerProvider } from "../domain/ControllerProvider.js";
2
- import { ProviderType } from "../domain/ProviderType.js";
3
- import { injectable } from "../fn/injectable.js";
4
- import { GlobalProviders } from "./GlobalProviders.js";
5
- GlobalProviders.createRegistry(ProviderType.CONTROLLER, ControllerProvider);
6
- /**
7
- * Register a provider configuration.
8
- * @deprecated Since v8. Use injectable() function instead.
9
- */
10
- export function registerProvider({ token, provide, ...opts }) {
11
- return injectable(token || provide, {
12
- ...opts,
13
- token: token || provide
14
- }).inspect();
15
- }