@tsed/di 8.0.0-alpha.9 → 8.0.0-beta.10

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.
Files changed (96) hide show
  1. package/.barrelsby.json +1 -1
  2. package/lib/browser/di.umd.min.js +1 -1
  3. package/lib/browser/di.umd.min.js.map +1 -1
  4. package/lib/esm/common/decorators/autoInjectable.js +3 -5
  5. package/lib/esm/common/decorators/autoInjectable.js.map +1 -1
  6. package/lib/esm/common/decorators/constant.js +1 -4
  7. package/lib/esm/common/decorators/constant.js.map +1 -1
  8. package/lib/esm/common/decorators/controller.js +2 -5
  9. package/lib/esm/common/decorators/controller.js.map +1 -1
  10. package/lib/esm/common/decorators/inject.js +2 -7
  11. package/lib/esm/common/decorators/inject.js.map +1 -1
  12. package/lib/esm/common/decorators/injectable.js +4 -3
  13. package/lib/esm/common/decorators/injectable.js.map +1 -1
  14. package/lib/esm/common/decorators/intercept.js +1 -1
  15. package/lib/esm/common/decorators/intercept.js.map +1 -1
  16. package/lib/esm/common/decorators/interceptor.js +2 -2
  17. package/lib/esm/common/decorators/lazyInject.js +3 -4
  18. package/lib/esm/common/decorators/lazyInject.js.map +1 -1
  19. package/lib/esm/common/decorators/value.js +3 -3
  20. package/lib/esm/common/decorators/value.js.map +1 -1
  21. package/lib/esm/common/domain/ControllerProvider.js.map +1 -1
  22. package/lib/esm/common/domain/Provider.js +6 -1
  23. package/lib/esm/common/domain/Provider.js.map +1 -1
  24. package/lib/esm/common/domain/ProviderType.js +0 -2
  25. package/lib/esm/common/domain/ProviderType.js.map +1 -1
  26. package/lib/esm/common/fn/configuration.js +5 -0
  27. package/lib/esm/common/fn/configuration.js.map +1 -0
  28. package/lib/esm/common/fn/constant.js +5 -0
  29. package/lib/esm/common/fn/constant.js.map +1 -0
  30. package/lib/esm/common/fn/events.js +31 -0
  31. package/lib/esm/common/fn/events.js.map +1 -0
  32. package/lib/esm/common/fn/inject.js +26 -0
  33. package/lib/esm/common/fn/inject.js.map +1 -0
  34. package/lib/esm/common/fn/injectMany.js +6 -0
  35. package/lib/esm/common/fn/injectMany.js.map +1 -0
  36. package/lib/esm/common/fn/injectable.js +57 -0
  37. package/lib/esm/common/fn/injectable.js.map +1 -0
  38. package/lib/esm/common/fn/injector.js +36 -0
  39. package/lib/esm/common/fn/injector.js.map +1 -0
  40. package/lib/esm/common/fn/localsContainer.js +40 -0
  41. package/lib/esm/common/fn/localsContainer.js.map +1 -0
  42. package/lib/esm/common/fn/refValue.js +12 -0
  43. package/lib/esm/common/fn/refValue.js.map +1 -0
  44. package/lib/esm/common/index.js +9 -0
  45. package/lib/esm/common/index.js.map +1 -1
  46. package/lib/esm/common/registries/GlobalProviders.js +1 -5
  47. package/lib/esm/common/registries/GlobalProviders.js.map +1 -1
  48. package/lib/esm/common/registries/ProviderRegistry.js +2 -71
  49. package/lib/esm/common/registries/ProviderRegistry.js.map +1 -1
  50. package/lib/esm/common/services/DIConfiguration.js +1 -14
  51. package/lib/esm/common/services/DIConfiguration.js.map +1 -1
  52. package/lib/esm/common/services/InjectorService.js +5 -32
  53. package/lib/esm/common/services/InjectorService.js.map +1 -1
  54. package/lib/esm/node/decorators/injectContext.js +2 -10
  55. package/lib/esm/node/decorators/injectContext.js.map +1 -1
  56. package/lib/esm/node/fn/context.js +21 -0
  57. package/lib/esm/node/fn/context.js.map +1 -0
  58. package/lib/esm/node/fn/logger.js +16 -0
  59. package/lib/esm/node/fn/logger.js.map +1 -0
  60. package/lib/esm/node/index.js +2 -0
  61. package/lib/esm/node/index.js.map +1 -1
  62. package/lib/esm/node/services/DILogger.js +3 -8
  63. package/lib/esm/node/services/DILogger.js.map +1 -1
  64. package/lib/esm/node/services/DITest.js +23 -49
  65. package/lib/esm/node/services/DITest.js.map +1 -1
  66. package/lib/esm/node/utils/asyncHookContext.js +1 -2
  67. package/lib/esm/node/utils/asyncHookContext.js.map +1 -1
  68. package/lib/types/common/decorators/configuration.d.ts +1 -1
  69. package/lib/types/common/decorators/constant.d.ts +0 -2
  70. package/lib/types/common/decorators/controller.d.ts +1 -5
  71. package/lib/types/common/decorators/inject.d.ts +0 -3
  72. package/lib/types/common/decorators/interceptor.d.ts +2 -2
  73. package/lib/types/common/domain/ControllerProvider.d.ts +7 -3
  74. package/lib/types/common/domain/Provider.d.ts +1 -0
  75. package/lib/types/common/domain/ProviderType.d.ts +0 -2
  76. package/lib/types/common/fn/configuration.d.ts +2 -0
  77. package/lib/types/common/fn/constant.d.ts +2 -0
  78. package/lib/types/common/fn/events.d.ts +23 -0
  79. package/lib/types/common/fn/inject.d.ts +20 -0
  80. package/lib/types/common/fn/injectMany.d.ts +2 -0
  81. package/lib/types/common/fn/injectable.d.ts +23 -0
  82. package/lib/types/common/fn/injector.d.ts +24 -0
  83. package/lib/types/common/fn/localsContainer.d.ts +15 -0
  84. package/lib/types/common/fn/refValue.d.ts +25 -0
  85. package/lib/types/common/index.d.ts +9 -0
  86. package/lib/types/common/interfaces/DIConfigurationOptions.d.ts +5 -0
  87. package/lib/types/common/registries/ProviderRegistry.d.ts +1 -53
  88. package/lib/types/common/services/DIConfiguration.d.ts +0 -6
  89. package/lib/types/common/services/InjectorService.d.ts +2 -12
  90. package/lib/types/node/fn/context.d.ts +9 -0
  91. package/lib/types/node/fn/logger.d.ts +9 -0
  92. package/lib/types/node/index.d.ts +2 -0
  93. package/lib/types/node/services/DITest.d.ts +0 -5
  94. package/lib/types/node/utils/asyncHookContext.d.ts +1 -2
  95. package/package.json +12 -12
  96. package/readme.md +2 -4
@@ -1,5 +1,3 @@
1
- export declare function constant<Type>(expression: string): Type | undefined;
2
- export declare function constant<Type>(expression: string, defaultValue: Type | undefined): Type;
3
1
  export declare function bindConstant(target: any, propertyKey: string | symbol, expression: string, defaultValue?: any): void;
4
2
  /**
5
3
  * Return value from Configuration.
@@ -1,11 +1,7 @@
1
1
  import { Type } from "@tsed/core";
2
+ import type { ControllerMiddlewares } from "../domain/ControllerProvider.js";
2
3
  import { ProviderOpts } from "../interfaces/ProviderOpts.js";
3
4
  export type PathType = string | RegExp | (string | RegExp)[];
4
- export interface ControllerMiddlewares {
5
- useBefore: any[];
6
- use: any[];
7
- useAfter: any[];
8
- }
9
5
  export interface ControllerOptions extends Partial<ProviderOpts<any>> {
10
6
  path?: PathType;
11
7
  children?: Type<any>[];
@@ -1,8 +1,5 @@
1
1
  import { type Type } from "@tsed/core";
2
- import type { InvokeOptions } from "../interfaces/InvokeOptions.js";
3
2
  import { TokenProvider } from "../interfaces/TokenProvider.js";
4
- export declare function inject<T>(token: TokenProvider<T>, opts?: Partial<Pick<InvokeOptions, "useOpts" | "rebuild" | "locals">>): T;
5
- export declare function injectMany<T>(token: string | symbol, opts?: Partial<Pick<InvokeOptions, "useOpts" | "rebuild" | "locals">>): T[];
6
3
  export type TransformInjectedProviderCB<T, Klass = any> = (instance: T, { target, propertyKey }: {
7
4
  self: Klass;
8
5
  target: Type<Klass>;
@@ -1,6 +1,6 @@
1
1
  /**
2
- * The decorators `@Service()` declare a new service can be injected in other service or controller on there `constructor`.
3
- * All services annotated with `@Service()` are constructed one time.
2
+ * The decorators `@Interceptor()` declare a new service can be injected in other service or controller on there `constructor`.
3
+ * All services annotated with `@Interceptor()` are constructed one time.
4
4
  *
5
5
  * > `@Service()` use the `reflect-metadata` to collect and inject service on controllers or other services.
6
6
  *
@@ -1,6 +1,10 @@
1
- import { ControllerMiddlewares } from "../decorators/controller.js";
2
1
  import { TokenProvider } from "../interfaces/TokenProvider.js";
3
2
  import { Provider } from "./Provider.js";
3
+ export interface ControllerMiddlewares {
4
+ useBefore: TokenProvider[];
5
+ use: TokenProvider[];
6
+ useAfter: TokenProvider[];
7
+ }
4
8
  export declare class ControllerProvider<T = any> extends Provider<T> {
5
9
  tokenRouter: string;
6
10
  constructor(provide: TokenProvider, options?: Partial<Provider>);
@@ -8,10 +12,10 @@ export declare class ControllerProvider<T = any> extends Provider<T> {
8
12
  *
9
13
  * @returns {any[]}
10
14
  */
11
- get middlewares(): ControllerMiddlewares;
15
+ get middlewares(): Partial<ControllerMiddlewares>;
12
16
  /**
13
17
  *
14
18
  * @param middlewares
15
19
  */
16
- set middlewares(middlewares: ControllerMiddlewares);
20
+ set middlewares(middlewares: Partial<ControllerMiddlewares>);
17
21
  }
@@ -54,6 +54,7 @@ export declare class Provider<T = any> implements ProviderOpts<T> {
54
54
  get configuration(): Partial<TsED.Configuration>;
55
55
  set configuration(configuration: Partial<TsED.Configuration>);
56
56
  get children(): TokenProvider[];
57
+ set children(children: TokenProvider[]);
57
58
  get(key: string): any;
58
59
  isAsync(): boolean;
59
60
  clone(): Provider;
@@ -1,7 +1,5 @@
1
1
  export declare enum ProviderType {
2
2
  VALUE = "value",
3
- FACTORY = "factory",
4
- SERVICE = "service",
5
3
  PROVIDER = "provider",
6
4
  MODULE = "module",
7
5
  CONTROLLER = "controller",
@@ -0,0 +1,2 @@
1
+ import { DIConfiguration } from "../services/DIConfiguration.js";
2
+ export declare function configuration(): TsED.DIConfiguration & DIConfiguration;
@@ -0,0 +1,2 @@
1
+ export declare function constant<Type>(expression: string): Type | undefined;
2
+ export declare function constant<Type>(expression: string, defaultValue: Type | undefined): Type;
@@ -0,0 +1,23 @@
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;
@@ -0,0 +1,20 @@
1
+ import type { InvokeOptions } from "../interfaces/InvokeOptions.js";
2
+ import type { TokenProvider } from "../interfaces/TokenProvider.js";
3
+ /**
4
+ * Inject a provider to another provider.
5
+ *
6
+ * Use this function to inject a custom provider on constructor parameter or property.
7
+ *
8
+ * ```typescript
9
+ * @Injectable()
10
+ * export class MyService {
11
+ * connection = inject(CONNECTION);
12
+ * }
13
+ * ```
14
+ *
15
+ * @param token A token provider or token provider group
16
+ * @param opts
17
+ * @returns {Function}
18
+ * @decorator
19
+ */
20
+ export declare function inject<T>(token: TokenProvider<T>, opts?: Partial<Pick<InvokeOptions, "useOpts" | "rebuild" | "locals">>): T;
@@ -0,0 +1,2 @@
1
+ import type { InvokeOptions } from "../interfaces/InvokeOptions.js";
2
+ export declare function injectMany<T>(token: string | symbol, opts?: Partial<Pick<InvokeOptions, "useOpts" | "rebuild" | "locals">>): T[];
@@ -0,0 +1,23 @@
1
+ import "../registries/ProviderRegistry.js";
2
+ import { Store, type Type } from "@tsed/core";
3
+ import { ControllerProvider } from "../domain/ControllerProvider.js";
4
+ import type { Provider } from "../domain/Provider.js";
5
+ import type { ProviderOpts } from "../interfaces/ProviderOpts.js";
6
+ import type { TokenProvider } from "../interfaces/TokenProvider.js";
7
+ type ProviderBuilder<Token extends TokenProvider, BaseProvider, T extends object> = {
8
+ [K in keyof T as T[K] extends (...args: any[]) => any ? never : K]: (value: T[K]) => ProviderBuilder<Token, BaseProvider, T>;
9
+ } & {
10
+ inspect(): BaseProvider;
11
+ store(): Store;
12
+ token(): Token;
13
+ factory(f: (...args: unknown[]) => unknown): ProviderBuilder<Token, BaseProvider, T>;
14
+ asyncFactory(f: (...args: unknown[]) => Promise<unknown>): ProviderBuilder<Token, BaseProvider, T>;
15
+ value(v: unknown): ProviderBuilder<Token, BaseProvider, T>;
16
+ class(c: Type): ProviderBuilder<Token, BaseProvider, T>;
17
+ };
18
+ 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>>;
19
+ type PickedProps = "scope" | "path" | "alias" | "hooks" | "deps" | "resolvers" | "imports" | "configuration";
20
+ export declare const injectable: <Token extends TokenProvider>(token: Token, options?: Partial<ProviderOpts<Type>>) => ProviderBuilder<Token, Provider<any>, Pick<Provider<any>, "type" | PickedProps>>;
21
+ export declare const interceptor: <Token extends TokenProvider>(token: Token, options?: Partial<ProviderOpts<Type>>) => ProviderBuilder<Token, Provider<any>, Pick<Provider<any>, "type" | PickedProps>>;
22
+ export declare const controller: <Token extends TokenProvider>(token: Token, options?: Partial<ProviderOpts<Type>>) => ProviderBuilder<Token, ControllerProvider<any>, Pick<ControllerProvider<any>, "children" | "middlewares" | PickedProps>>;
23
+ export {};
@@ -0,0 +1,24 @@
1
+ import { InjectorService } from "../services/InjectorService.js";
2
+ type InjectorFnOpts = {
3
+ rebuild?: boolean;
4
+ logger?: any;
5
+ settings?: Partial<TsED.Configuration>;
6
+ };
7
+ /**
8
+ * Create or return the existing injector service.
9
+ *
10
+ * Example:
11
+ *
12
+ * ```typescript
13
+ * import {injector, Injectable} from "@tsed/di";
14
+ *
15
+ * @Injectable()
16
+ * class MyService {
17
+ * injector = injector();
18
+ * }
19
+ * ```
20
+ */
21
+ export declare function injector(opts?: InjectorFnOpts): InjectorService;
22
+ export declare function hasInjector(): boolean;
23
+ export declare function destroyInjector(): Promise<void>;
24
+ export {};
@@ -0,0 +1,15 @@
1
+ import { LocalsContainer } from "../domain/LocalsContainer.js";
2
+ import type { UseImportTokenProviderOpts } from "../interfaces/ImportTokenProviderOpts.js";
3
+ /**
4
+ * Get the locals container initiated by DITest or .bootstrap() method.
5
+ */
6
+ export declare function localsContainer({ providers, rebuild }?: {
7
+ providers?: UseImportTokenProviderOpts[];
8
+ rebuild?: boolean;
9
+ }): LocalsContainer;
10
+ export declare function invokeOptions(): any;
11
+ /**
12
+ * Reset the locals container.
13
+ */
14
+ export declare function detachLocalsContainer(): void;
15
+ export declare function cleanAllLocalsContainer(): void;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Get a value from the `injector.settings`.
3
+ *
4
+ * ## Example
5
+ *
6
+ * ```ts
7
+ * import {refValue, Injectable} from "@tsed/di";
8
+ *
9
+ * @Injectable()
10
+ * class Test {
11
+ * test = refValue("logger.level", "default value");
12
+ *
13
+ * constructor() {
14
+ * console.log(this.test.value); // "off"
15
+ * }
16
+ * }
17
+ *
18
+ * @param expression The expression to get the value from the `injector.settings`.
19
+ */
20
+ export declare function refValue<Type>(expression: string): {
21
+ value: Type | undefined;
22
+ };
23
+ export declare function refValue<Type>(expression: string, defaultValue: Type | undefined): {
24
+ value: Type;
25
+ };
@@ -27,6 +27,15 @@ export * from "./domain/ProviderScope.js";
27
27
  export * from "./domain/ProviderType.js";
28
28
  export * from "./errors/InjectionError.js";
29
29
  export * from "./errors/InvalidPropertyTokenError.js";
30
+ export * from "./fn/configuration.js";
31
+ export * from "./fn/constant.js";
32
+ export * from "./fn/events.js";
33
+ export * from "./fn/inject.js";
34
+ export * from "./fn/injectable.js";
35
+ export * from "./fn/injectMany.js";
36
+ export * from "./fn/injector.js";
37
+ export * from "./fn/localsContainer.js";
38
+ export * from "./fn/refValue.js";
30
39
  export * from "./interfaces/DIConfigurationOptions.js";
31
40
  export * from "./interfaces/DILogger.js";
32
41
  export * from "./interfaces/DILoggerOptions.js";
@@ -6,6 +6,11 @@ declare global {
6
6
  namespace TsED {
7
7
  interface Context {
8
8
  }
9
+ /**
10
+ * Here to allow extension on DIConfiguration base service
11
+ */
12
+ interface DIConfiguration {
13
+ }
9
14
  interface Configuration extends Record<string, any> {
10
15
  scopes: {
11
16
  [key: string]: ProviderScope;
@@ -1,58 +1,6 @@
1
- import { Provider } from "../domain/Provider.js";
2
1
  import type { ProviderOpts } from "../interfaces/ProviderOpts.js";
3
2
  /**
4
3
  * Register a provider configuration.
5
4
  * @param {ProviderOpts<any>} provider
6
5
  */
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;
6
+ export declare function registerProvider<Type = any>(provider: Partial<ProviderOpts<Type>> & Pick<ProviderOpts<Type>, "provide">): import("../index.js").Provider<any>;
@@ -47,11 +47,5 @@ export declare class DIConfiguration {
47
47
  * @returns {undefined|any}
48
48
  */
49
49
  get<T = any>(propertyKey: string, defaultValue?: T): T;
50
- /**
51
- *
52
- * @param value
53
- * @returns {any}
54
- */
55
- resolve(value: any): any;
56
50
  protected getRaw(propertyKey: string, defaultValue?: any): any;
57
51
  }
@@ -1,3 +1,4 @@
1
+ import { Hooks } from "@tsed/core";
1
2
  import { Container } from "../domain/Container.js";
2
3
  import { LocalsContainer } from "../domain/LocalsContainer.js";
3
4
  import { Provider } from "../domain/Provider.js";
@@ -32,21 +33,10 @@ export declare class InjectorService extends Container {
32
33
  settings: DIConfiguration;
33
34
  logger: DILogger;
34
35
  private resolvedConfiguration;
36
+ readonly hooks: Hooks;
35
37
  constructor();
36
38
  get resolvers(): import("../index.js").DIResolver[];
37
39
  get scopes(): Record<string, ProviderScope>;
38
- /**
39
- * Return the current injector service.
40
- */
41
- static getInstance(): InjectorService;
42
- /**
43
- * Get the locals container initiated by DITest or .bootstrap() method.
44
- */
45
- static getLocals(): LocalsContainer;
46
- /**
47
- * Reset the locals container.
48
- */
49
- static unsetLocals(): void;
50
40
  /**
51
41
  * Retrieve default scope for a given provider.
52
42
  * @param provider
@@ -0,0 +1,9 @@
1
+ import { DIContext } from "../domain/DIContext.js";
2
+ /**
3
+ * Get the current DIContext instance using async hook node.js api.
4
+ *
5
+ * ::: warning
6
+ * This function isn't available in the browser context.
7
+ * :::
8
+ */
9
+ export declare function context<Ctx = DIContext>(): Ctx;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Get the current `injector.logger` instance.
3
+ */
4
+ export declare function logger(): import("../../common/index.js").DILogger;
5
+ /**
6
+ * Get the current logger instance. If the logger() function is invoked in Request context, it will return the logger instance attached to the request context.
7
+ * Otherwise, it will return the logger instance attached to the DI context.
8
+ */
9
+ export declare function contextLogger(): import("../index.js").ContextLogger;
@@ -4,6 +4,8 @@
4
4
  export * from "./decorators/injectContext.js";
5
5
  export * from "./domain/ContextLogger.js";
6
6
  export * from "./domain/DIContext.js";
7
+ export * from "./fn/context.js";
8
+ export * from "./fn/logger.js";
7
9
  export * from "./interfaces/AlterRunInContext.js";
8
10
  export * from "./services/DILogger.js";
9
11
  export * from "./services/DITest.js";
@@ -4,12 +4,7 @@ import { DIContext } from "../domain/DIContext.js";
4
4
  * Tool to run test with lightweight DI sandbox.
5
5
  */
6
6
  export declare class DITest {
7
- static options: Partial<TsED.Configuration>;
8
- protected static _injector: InjectorService | null;
9
7
  static get injector(): InjectorService;
10
- static set injector(injector: InjectorService);
11
- static set(key: string, value: any): void;
12
- static hasInjector(): boolean;
13
8
  static create(settings?: Partial<TsED.Configuration>): Promise<void>;
14
9
  static createContainer(): Promise<void>;
15
10
  /**
@@ -8,8 +8,7 @@ export declare function getAsyncStore(): AsyncLocalStorage<{
8
8
  export declare function useContextRef(): {
9
9
  current: DIContext | undefined;
10
10
  } | undefined;
11
- export declare function useContext<Context = DIContext>(initialValue?: DIContext): Context | undefined;
12
- export declare const getContext: typeof useContext;
11
+ export declare function getContext<Context = DIContext>(initialValue?: DIContext): Context | undefined;
13
12
  export declare function runInContext<Result = unknown>(ctx: DIContext | undefined, cb: (...args: unknown[]) => Result, injector?: InjectorService): Promise<Result>;
14
13
  export declare function setContext(ctx: DIContext): void;
15
14
  export declare function bindContext(cb: any): 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.0.0-alpha.9",
5
+ "version": "8.0.0-beta.10",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
@@ -26,24 +26,24 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "tslib": "2.7.0",
29
- "uuid": "9.0.1"
29
+ "uuid": "^10.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@tsed/barrels": "8.0.0-alpha.9",
33
- "@tsed/core": "8.0.0-alpha.9",
34
- "@tsed/logger": ">=6.7.5",
35
- "@tsed/schema": "8.0.0-alpha.9",
36
- "@tsed/typescript": "8.0.0-alpha.9",
32
+ "@tsed/barrels": "8.0.0-beta.10",
33
+ "@tsed/core": "8.0.0-beta.10",
34
+ "@tsed/logger": "^6.7.8",
35
+ "@tsed/schema": "8.0.0-beta.10",
36
+ "@tsed/typescript": "8.0.0-beta.10",
37
37
  "cross-env": "7.0.3",
38
- "eslint": "9.11.1",
38
+ "eslint": "9.12.0",
39
39
  "typescript": "5.4.5",
40
- "vitest": "2.0.4",
40
+ "vitest": "2.1.2",
41
41
  "webpack": "^5.75.0"
42
42
  },
43
43
  "peerDependencies": {
44
- "@tsed/core": "8.0.0-alpha.9",
44
+ "@tsed/core": "8.0.0-beta.10",
45
45
  "@tsed/logger": ">=6.7.5",
46
- "@tsed/schema": "8.0.0-alpha.9"
46
+ "@tsed/schema": "8.0.0-beta.10"
47
47
  },
48
48
  "peerDependenciesMeta": {
49
49
  "@tsed/core": {
@@ -64,6 +64,6 @@
64
64
  "author": "Romain Lenzotti",
65
65
  "license": "MIT",
66
66
  "publishConfig": {
67
- "tag": "alpha"
67
+ "tag": "beta"
68
68
  }
69
69
  }
package/readme.md CHANGED
@@ -91,7 +91,8 @@ The `@Injectable()` attaches the metadata, thereby Ts.ED knows that this class i
91
91
  Now we have the service class already done, let's use it inside a controller:
92
92
 
93
93
  ```typescript
94
- import {Controller, Post, Body, Get} from "@tsed/common";
94
+ import {Controller} from "@tsed/di";
95
+ import {Post, Body, Get} from "@tsed/schema";
95
96
  import {CalendarsService} from "./CalendarsService.js";
96
97
  import {Calendar} from "./models/Calendar.js";
97
98
 
@@ -111,9 +112,6 @@ export class CalendarCtrl {
111
112
  }
112
113
  ```
113
114
 
114
- > Note: Controller isn't a part of `@tsed/di`. `@Controller` decorator is exposed by `@tsed/common` package because it's a specific provider
115
- > used by the Ts.ED framework. Ts.ED DI allow you to define your own Provider and decorator.
116
-
117
115
  Finally, we can load the injector and use:
118
116
 
119
117
  ```typescript