@tsed/di 8.15.1 → 8.16.0-rc.1

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 (50) hide show
  1. package/lib/esm/browser/decorators/injectContext.js +26 -0
  2. package/lib/esm/browser/fn/context.js +20 -0
  3. package/lib/esm/browser/fn/contextLogger.js +8 -0
  4. package/lib/esm/browser/index.js +5 -0
  5. package/lib/esm/browser/utils/asyncHookContext.js +67 -0
  6. package/lib/esm/common/decorators/autoInjectable.js +6 -1
  7. package/lib/esm/{node → common}/domain/DIContext.js +1 -1
  8. package/lib/esm/common/index.js +7 -0
  9. package/lib/esm/{node → common}/utils/attachLogger.js +1 -1
  10. package/lib/esm/common/utils/providerBuilder.js +4 -0
  11. package/lib/esm/{node → common}/utils/setLoggerFormat.js +2 -2
  12. package/lib/esm/{node → common}/utils/setLoggerLevel.js +1 -1
  13. package/lib/esm/node/fn/context.js +1 -1
  14. package/lib/esm/node/index.js +0 -7
  15. package/lib/esm/node/services/DITest.js +2 -2
  16. package/lib/esm/node/utils/asyncHookContext.js +3 -0
  17. package/lib/types/browser/decorators/injectContext.d.ts +16 -0
  18. package/lib/types/browser/fn/context.d.ts +9 -0
  19. package/lib/types/browser/fn/contextLogger.d.ts +5 -0
  20. package/lib/types/browser/index.d.ts +5 -0
  21. package/lib/types/browser/utils/asyncHookContext.d.ts +22 -0
  22. package/lib/types/common/decorators/controller.d.ts +1 -1
  23. package/lib/types/common/decorators/inject.d.ts +1 -1
  24. package/lib/types/common/decorators/intercept.d.ts +1 -1
  25. package/lib/types/common/decorators/overrideProvider.d.ts +1 -1
  26. package/lib/types/{node → common}/domain/DIContext.d.ts +1 -1
  27. package/lib/types/common/domain/Provider.d.ts +1 -1
  28. package/lib/types/common/index.d.ts +7 -0
  29. package/lib/types/common/interfaces/RegistrySettings.d.ts +1 -1
  30. package/lib/types/common/registries/GlobalProviders.d.ts +1 -1
  31. package/lib/types/{node → common}/utils/attachLogger.d.ts +1 -1
  32. package/lib/types/common/utils/createContainer.d.ts +1 -1
  33. package/lib/types/common/utils/discoverHooks.d.ts +1 -1
  34. package/lib/types/common/utils/getConfiguration.d.ts +1 -1
  35. package/lib/types/common/utils/providerBuilder.d.ts +2 -1
  36. package/lib/types/node/decorators/injectContext.d.ts +1 -1
  37. package/lib/types/node/fn/context.d.ts +1 -1
  38. package/lib/types/node/fn/contextLogger.d.ts +1 -1
  39. package/lib/types/node/index.d.ts +0 -7
  40. package/lib/types/node/services/DITest.d.ts +1 -1
  41. package/lib/types/node/utils/asyncHookContext.d.ts +4 -1
  42. package/package.json +13 -10
  43. /package/lib/esm/{node → common}/domain/ContextLogger.js +0 -0
  44. /package/lib/esm/{node → common}/interfaces/AlterRunInContext.js +0 -0
  45. /package/lib/esm/{node → common}/utils/setLoggerConfiguration.js +0 -0
  46. /package/lib/types/{node → common}/domain/ContextLogger.d.ts +0 -0
  47. /package/lib/types/{node → common}/interfaces/AlterRunInContext.d.ts +0 -0
  48. /package/lib/types/{node → common}/utils/setLoggerConfiguration.d.ts +0 -0
  49. /package/lib/types/{node → common}/utils/setLoggerFormat.d.ts +0 -0
  50. /package/lib/types/{node → common}/utils/setLoggerLevel.d.ts +0 -0
@@ -0,0 +1,26 @@
1
+ import { catchError } from "@tsed/core/utils/catchError.js";
2
+ import { context } from "../fn/context.js";
3
+ /**
4
+ * Inject a context like PlatformContext or any BaseContext.
5
+ *
6
+ * ```typescript
7
+ * @Injectable()
8
+ * export class MyService {
9
+ * @InjectContext()
10
+ * ctx?: Context;
11
+ * }
12
+ * ```
13
+ *
14
+ * @returns {Function}
15
+ * @decorator
16
+ */
17
+ export function InjectContext(transform = (o) => o) {
18
+ return (target, propertyKey) => {
19
+ catchError(() => Reflect.deleteProperty(target, propertyKey));
20
+ Reflect.defineProperty(target, propertyKey, {
21
+ get() {
22
+ return transform(context());
23
+ }
24
+ });
25
+ };
26
+ }
@@ -0,0 +1,20 @@
1
+ import { v4 } from "uuid";
2
+ import { DIContext } from "../../common/domain/DIContext.js";
3
+ import { injector } from "../../common/index.js";
4
+ import { getContext } from "../utils/asyncHookContext.js";
5
+ /**
6
+ * Get the current DIContext instance using async hook node.js api.
7
+ *
8
+ * ::: warning
9
+ * This function isn't available in the browser context.
10
+ * :::
11
+ */
12
+ export function context() {
13
+ return (getContext() ||
14
+ new DIContext({
15
+ id: v4(),
16
+ logger: injector().logger,
17
+ injector: injector(),
18
+ maxStackSize: 0
19
+ }));
20
+ }
@@ -0,0 +1,8 @@
1
+ import { context } from "./context.js";
2
+ /**
3
+ * 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.
4
+ * Otherwise, it will return the logger instance attached to the DI context.
5
+ */
6
+ export function contextLogger() {
7
+ return context().logger;
8
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @file Automatically generated by @tsed/barrels.
3
+ */
4
+ export * from "../common/index.js";
5
+ export * from "./utils/asyncHookContext.js";
@@ -0,0 +1,67 @@
1
+ class AsyncContextStorage {
2
+ constructor() {
3
+ this.stack = [];
4
+ }
5
+ run(store, cb) {
6
+ this.stack.push(store);
7
+ this.store = store;
8
+ try {
9
+ return cb();
10
+ }
11
+ finally {
12
+ this.stack.pop();
13
+ this.store = this.stack[this.stack.length - 1];
14
+ }
15
+ }
16
+ getStore() {
17
+ return this.store;
18
+ }
19
+ }
20
+ const storage = new AsyncContextStorage();
21
+ export function getAsyncStore() {
22
+ return storage;
23
+ }
24
+ export function useContextRef() {
25
+ return getAsyncStore().getStore();
26
+ }
27
+ export function getContext(initialValue) {
28
+ return initialValue || useContextRef()?.current;
29
+ }
30
+ export async function runInContext(ctx, cb, injector) {
31
+ const ref = useContextRef();
32
+ if (ref) {
33
+ ctx && setContext(ctx);
34
+ return cb();
35
+ }
36
+ else {
37
+ injector = ctx?.injector || injector;
38
+ cb = (injector && (await injector.alterAsync?.("$alterRunInContext", cb))) || cb;
39
+ return await Promise.resolve(storage.run({ current: ctx }, cb));
40
+ }
41
+ }
42
+ export function setContext(ctx) {
43
+ const ref = useContextRef();
44
+ if (ref && !ref.current) {
45
+ ref.current = ctx;
46
+ }
47
+ }
48
+ /**
49
+ * @deprecated
50
+ */
51
+ export function bindContext(cb) {
52
+ return cb;
53
+ }
54
+ if (typeof window !== "undefined") {
55
+ // Patch Promise.then pour propager le contexte
56
+ const origThen = Promise.prototype.then;
57
+ Promise.prototype.then = function (onFulfilled, onRejected) {
58
+ const ctx = useContextRef();
59
+ return origThen.call(this, onFulfilled && ((v) => storage.run({ current: ctx?.current }, () => onFulfilled(v))), onRejected && ((e) => storage.run({ current: ctx?.current }, () => onRejected(e))));
60
+ };
61
+ // Patch setTimeout pour propager le contexte
62
+ const origSetTimeout = window.setTimeout;
63
+ window.setTimeout = function (fn, ...args) {
64
+ const ctx = useContextRef();
65
+ return origSetTimeout(() => storage.run({ current: ctx?.current }, fn), ...args);
66
+ };
67
+ }
@@ -14,7 +14,12 @@ function resolveAutoInjectableArgs(token, args) {
14
14
  }
15
15
  else {
16
16
  const value = deps[i];
17
- const instance = isArray(value) ? inj.getMany(value[0], { locals, parent: token }) : inj.invoke(value, { locals, parent: token });
17
+ const instance = isArray(value)
18
+ ? inj.getMany(value[0], { locals, parent: token })
19
+ : inj.invoke(value, {
20
+ locals,
21
+ parent: token
22
+ });
18
23
  list.push(instance);
19
24
  }
20
25
  }
@@ -1,4 +1,4 @@
1
- import { injector, LocalsContainer } from "../../common/index.js";
1
+ import { injector, LocalsContainer } from "../index.js";
2
2
  import { ContextLogger } from "./ContextLogger.js";
3
3
  export class DIContext {
4
4
  #container;
@@ -19,7 +19,9 @@ export * from "./decorators/service.js";
19
19
  export * from "./decorators/useOpts.js";
20
20
  export * from "./decorators/value.js";
21
21
  export * from "./domain/Container.js";
22
+ export * from "./domain/ContextLogger.js";
22
23
  export * from "./domain/ControllerProvider.js";
24
+ export * from "./domain/DIContext.js";
23
25
  export * from "./domain/InjectablePropertyType.js";
24
26
  export * from "./domain/LocalsContainer.js";
25
27
  export * from "./domain/Provider.js";
@@ -37,6 +39,7 @@ export * from "./fn/lazyInject.js";
37
39
  export * from "./fn/localsContainer.js";
38
40
  export * from "./fn/logger.js";
39
41
  export * from "./fn/refValue.js";
42
+ export * from "./interfaces/AlterRunInContext.js";
40
43
  export * from "./interfaces/DIConfigurationOptions.js";
41
44
  export * from "./interfaces/DILogger.js";
42
45
  export * from "./interfaces/DILoggerOptions.js";
@@ -56,9 +59,13 @@ export * from "./registries/ProviderRegistry.js";
56
59
  export * from "./services/DIConfiguration.js";
57
60
  export * from "./services/DILogger.js";
58
61
  export * from "./services/InjectorService.js";
62
+ export * from "./utils/attachLogger.js";
59
63
  export * from "./utils/colors.js";
60
64
  export * from "./utils/createContainer.js";
61
65
  export * from "./utils/discoverHooks.js";
62
66
  export * from "./utils/getConfiguration.js";
63
67
  export * from "./utils/getConstructorDependencies.js";
64
68
  export * from "./utils/providerBuilder.js";
69
+ export * from "./utils/setLoggerConfiguration.js";
70
+ export * from "./utils/setLoggerFormat.js";
71
+ export * from "./utils/setLoggerLevel.js";
@@ -1,4 +1,4 @@
1
- import { injector } from "../../common/index.js";
1
+ import { injector } from "../index.js";
2
2
  import { setLoggerConfiguration } from "./setLoggerConfiguration.js";
3
3
  export function attachLogger($log) {
4
4
  injector().logger = $log;
@@ -52,6 +52,10 @@ export function providerBuilder(props, baseOpts = {}) {
52
52
  },
53
53
  token() {
54
54
  return provider.token;
55
+ },
56
+ set(key, value) {
57
+ this.store().set(key, value);
58
+ return this;
55
59
  }
56
60
  });
57
61
  };
@@ -1,5 +1,5 @@
1
- import { logger } from "../../common/fn/logger.js";
2
- import { injector } from "../../common/index.js";
1
+ import { logger } from "../fn/logger.js";
2
+ import { injector } from "../index.js";
3
3
  /**
4
4
  * @ignore
5
5
  */
@@ -1,4 +1,4 @@
1
- import { injector } from "../../common/index.js";
1
+ import { injector } from "../index.js";
2
2
  /**
3
3
  * @ignore
4
4
  */
@@ -1,6 +1,6 @@
1
1
  import { v4 } from "uuid";
2
+ import { DIContext } from "../../common/domain/DIContext.js";
2
3
  import { injector } from "../../common/index.js";
3
- import { DIContext } from "../domain/DIContext.js";
4
4
  import { getContext } from "../utils/asyncHookContext.js";
5
5
  /**
6
6
  * Get the current DIContext instance using async hook node.js api.
@@ -2,15 +2,8 @@
2
2
  * @file Automatically generated by @tsed/barrels.
3
3
  */
4
4
  export * from "./decorators/injectContext.js";
5
- export * from "./domain/ContextLogger.js";
6
- export * from "./domain/DIContext.js";
7
5
  export * from "./fn/context.js";
8
6
  export * from "./fn/contextLogger.js";
9
- export * from "./interfaces/AlterRunInContext.js";
10
7
  export * from "./services/DILogger.js";
11
8
  export * from "./services/DITest.js";
12
9
  export * from "./utils/asyncHookContext.js";
13
- export * from "./utils/attachLogger.js";
14
- export * from "./utils/setLoggerConfiguration.js";
15
- export * from "./utils/setLoggerFormat.js";
16
- export * from "./utils/setLoggerLevel.js";
@@ -3,11 +3,11 @@ import { getValue } from "@tsed/core/utils/getValue.js";
3
3
  import { isClass } from "@tsed/core/utils/isClass.js";
4
4
  import { isObject } from "@tsed/core/utils/isObject.js";
5
5
  import { $log } from "@tsed/logger";
6
+ import { DIContext } from "../../common/domain/DIContext.js";
6
7
  import { cleanAllLocalsContainer, detachLocalsContainer, localsContainer } from "../../common/fn/localsContainer.js";
7
8
  import { logger } from "../../common/fn/logger.js";
8
9
  import { createContainer, destroyInjector, DI_INJECTABLE_PROPS, inject, injector } from "../../common/index.js";
9
- import { DIContext } from "../domain/DIContext.js";
10
- import { setLoggerConfiguration } from "../utils/setLoggerConfiguration.js";
10
+ import { setLoggerConfiguration } from "../../common/utils/setLoggerConfiguration.js";
11
11
  /**
12
12
  * Tool to run test with lightweight DI sandbox.
13
13
  */
@@ -27,6 +27,9 @@ export function setContext(ctx) {
27
27
  ref.current = ctx;
28
28
  }
29
29
  }
30
+ /**
31
+ * @deprecated
32
+ */
30
33
  export function bindContext(cb) {
31
34
  return AsyncResource.bind(cb);
32
35
  }
@@ -0,0 +1,16 @@
1
+ import { DIContext } from "../../common/domain/DIContext.js";
2
+ /**
3
+ * Inject a context like PlatformContext or any BaseContext.
4
+ *
5
+ * ```typescript
6
+ * @Injectable()
7
+ * export class MyService {
8
+ * @InjectContext()
9
+ * ctx?: Context;
10
+ * }
11
+ * ```
12
+ *
13
+ * @returns {Function}
14
+ * @decorator
15
+ */
16
+ export declare function InjectContext(transform?: ($ctx: DIContext) => unknown): PropertyDecorator;
@@ -0,0 +1,9 @@
1
+ import { DIContext } from "../../common/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,5 @@
1
+ /**
2
+ * 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.
3
+ * Otherwise, it will return the logger instance attached to the DI context.
4
+ */
5
+ export declare function contextLogger(): import("../index.js").ContextLogger;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * @file Automatically generated by @tsed/barrels.
3
+ */
4
+ export * from "../common/index.js";
5
+ export * from "./utils/asyncHookContext.js";
@@ -0,0 +1,22 @@
1
+ import { DIContext } from "../../common/index.js";
2
+ interface AsyncStore {
3
+ current: DIContext | undefined;
4
+ }
5
+ declare class AsyncContextStorage {
6
+ private store?;
7
+ private stack;
8
+ run(store: AsyncStore, cb: (...args: any[]) => any): any;
9
+ getStore(): AsyncStore | undefined;
10
+ }
11
+ export declare function getAsyncStore(): AsyncContextStorage;
12
+ export declare function useContextRef(): AsyncStore | undefined;
13
+ export declare function getContext<Context = DIContext>(initialValue?: DIContext): Context | undefined;
14
+ export declare function runInContext<Result = unknown>(ctx: DIContext | undefined, cb: (...args: unknown[]) => Result, injector?: {
15
+ alterAsync?: (name: string, cb: any) => Promise<any>;
16
+ }): Promise<Result>;
17
+ export declare function setContext(ctx: DIContext): void;
18
+ /**
19
+ * @deprecated
20
+ */
21
+ export declare function bindContext(cb: any): any;
22
+ export {};
@@ -1,4 +1,4 @@
1
- import { Type } from "@tsed/core/types/Type.js";
1
+ import type { Type } from "@tsed/core/types/Type.js";
2
2
  import type { ControllerMiddlewares } from "../domain/ControllerProvider.js";
3
3
  import { ProviderOpts } from "../interfaces/ProviderOpts.js";
4
4
  export type PathType = string | RegExp | (string | RegExp)[];
@@ -1,4 +1,4 @@
1
- import { type Type } from "@tsed/core/types/Type.js";
1
+ import type { Type } from "@tsed/core/types/Type.js";
2
2
  import { TokenProvider } from "../interfaces/TokenProvider.js";
3
3
  export type TransformInjectedProviderCB<T, Klass = any> = (instance: T, { target, propertyKey }: {
4
4
  self: Klass;
@@ -1,4 +1,4 @@
1
- import { Type } from "@tsed/core/types/Type.js";
1
+ import type { Type } from "@tsed/core/types/Type.js";
2
2
  import type { InterceptorMethods } from "../interfaces/InterceptorMethods.js";
3
3
  import type { TokenProvider } from "../interfaces/TokenProvider.js";
4
4
  export declare function getInterceptorOptions<T>(target: Type<any>, propertyKey: string | symbol): T;
@@ -1,4 +1,4 @@
1
- import { Type } from "@tsed/core/types/Type.js";
1
+ import type { Type } from "@tsed/core/types/Type.js";
2
2
  /**
3
3
  * Override a provider which is already registered in ProviderRegistry.
4
4
  * @returns {Function}
@@ -1,4 +1,4 @@
1
- import { InjectorService, LocalsContainer } from "../../common/index.js";
1
+ import { InjectorService, LocalsContainer } from "../index.js";
2
2
  import { ContextLogger, ContextLoggerOptions } from "./ContextLogger.js";
3
3
  export interface DIContextOptions extends Omit<ContextLoggerOptions, "dateStart"> {
4
4
  id: string;
@@ -1,5 +1,5 @@
1
1
  import { Store } from "@tsed/core/types/Store.js";
2
- import { type AbstractType, Type } from "@tsed/core/types/Type.js";
2
+ import type { AbstractType, Type } from "@tsed/core/types/Type.js";
3
3
  import type { ProviderOpts } from "../interfaces/ProviderOpts.js";
4
4
  import type { TokenProvider } from "../interfaces/TokenProvider.js";
5
5
  import { ProviderScope } from "./ProviderScope.js";
@@ -19,7 +19,9 @@ export * from "./decorators/service.js";
19
19
  export * from "./decorators/useOpts.js";
20
20
  export * from "./decorators/value.js";
21
21
  export * from "./domain/Container.js";
22
+ export * from "./domain/ContextLogger.js";
22
23
  export * from "./domain/ControllerProvider.js";
24
+ export * from "./domain/DIContext.js";
23
25
  export * from "./domain/InjectablePropertyType.js";
24
26
  export * from "./domain/LocalsContainer.js";
25
27
  export * from "./domain/Provider.js";
@@ -37,6 +39,7 @@ export * from "./fn/lazyInject.js";
37
39
  export * from "./fn/localsContainer.js";
38
40
  export * from "./fn/logger.js";
39
41
  export * from "./fn/refValue.js";
42
+ export * from "./interfaces/AlterRunInContext.js";
40
43
  export * from "./interfaces/DIConfigurationOptions.js";
41
44
  export * from "./interfaces/DILogger.js";
42
45
  export * from "./interfaces/DILoggerOptions.js";
@@ -56,9 +59,13 @@ export * from "./registries/ProviderRegistry.js";
56
59
  export * from "./services/DIConfiguration.js";
57
60
  export * from "./services/DILogger.js";
58
61
  export * from "./services/InjectorService.js";
62
+ export * from "./utils/attachLogger.js";
59
63
  export * from "./utils/colors.js";
60
64
  export * from "./utils/createContainer.js";
61
65
  export * from "./utils/discoverHooks.js";
62
66
  export * from "./utils/getConfiguration.js";
63
67
  export * from "./utils/getConstructorDependencies.js";
64
68
  export * from "./utils/providerBuilder.js";
69
+ export * from "./utils/setLoggerConfiguration.js";
70
+ export * from "./utils/setLoggerFormat.js";
71
+ export * from "./utils/setLoggerLevel.js";
@@ -1,4 +1,4 @@
1
- import { Type } from "@tsed/core/types/Type.js";
1
+ import type { Type } from "@tsed/core/types/Type.js";
2
2
  import type { Provider } from "../domain/Provider.js";
3
3
  /**
4
4
  * @ignore
@@ -1,4 +1,4 @@
1
- import { Type } from "@tsed/core/types/Type.js";
1
+ import type { Type } from "@tsed/core/types/Type.js";
2
2
  import { Provider } from "../domain/Provider.js";
3
3
  import { ProviderOpts } from "../interfaces/ProviderOpts.js";
4
4
  import { RegistrySettings } from "../interfaces/RegistrySettings.js";
@@ -1,2 +1,2 @@
1
- import { DILogger } from "../../common/index.js";
1
+ import { DILogger } from "../index.js";
2
2
  export declare function attachLogger($log: DILogger): void;
@@ -1,3 +1,3 @@
1
- import { Type } from "@tsed/core/types/Type.js";
1
+ import type { Type } from "@tsed/core/types/Type.js";
2
2
  import { Container } from "../domain/Container.js";
3
3
  export declare function createContainer(rootModule?: Type<any>): Container;
@@ -1,2 +1,2 @@
1
- import { type AbstractType, type Type } from "@tsed/core/types/Type.js";
1
+ import type { AbstractType, Type } from "@tsed/core/types/Type.js";
2
2
  export declare function discoverHooks(token: Type | AbstractType<any>): any;
@@ -1,3 +1,3 @@
1
- import { Type } from "@tsed/core/types/Type.js";
1
+ import type { Type } from "@tsed/core/types/Type.js";
2
2
  export declare function mergeMount(m1?: any, m2?: any): any;
3
3
  export declare function getConfiguration(module: Type<any>, configuration?: any): any;
@@ -1,6 +1,6 @@
1
1
  import "../registries/ProviderRegistry.js";
2
2
  import { Store } from "@tsed/core/types/Store.js";
3
- import { type Type } from "@tsed/core/types/Type.js";
3
+ import type { Type } from "@tsed/core/types/Type.js";
4
4
  import type { ProviderOpts } from "../interfaces/ProviderOpts.js";
5
5
  import type { FactoryTokenProvider, TokenProvider } from "../interfaces/TokenProvider.js";
6
6
  type BaseMethodsProvider<TypeOf, BaseProvider, T extends object> = {
@@ -14,6 +14,7 @@ type ProviderBuilder<TypeOf, BaseProvider, T extends object> = BaseMethodsProvid
14
14
  asyncFactory<FactoryReturn>(f: (...args: unknown[]) => Promise<FactoryReturn>): ProviderBuilder<FactoryTokenProvider<FactoryReturn>, BaseProvider, T>;
15
15
  value<Value>(v: Value): ProviderBuilder<FactoryTokenProvider<Value>, BaseProvider, T>;
16
16
  class<TokenKlass>(c: Type<TokenKlass>): ProviderBuilder<TokenKlass, BaseProvider, T>;
17
+ set(key: string, value: any): ProviderBuilder<TypeOf, BaseProvider, T>;
17
18
  };
18
19
  export type ProviderBuilderFn<Provider, Picked extends keyof Provider> = <TypeOf extends TokenProvider>(token: TypeOf, options?: Partial<ProviderOpts<Type>>) => ProviderBuilder<TypeOf, Provider, Pick<Provider, Picked>>;
19
20
  export declare function providerBuilder<Provider, Picked extends keyof Provider>(props: string[], baseOpts?: Partial<ProviderOpts<Provider>>): ProviderBuilderFn<Provider, Picked>;
@@ -1,4 +1,4 @@
1
- import { DIContext } from "../domain/DIContext.js";
1
+ import { DIContext } from "../../common/domain/DIContext.js";
2
2
  /**
3
3
  * Inject a context like PlatformContext or any BaseContext.
4
4
  *
@@ -1,4 +1,4 @@
1
- import { DIContext } from "../domain/DIContext.js";
1
+ import { DIContext } from "../../common/domain/DIContext.js";
2
2
  /**
3
3
  * Get the current DIContext instance using async hook node.js api.
4
4
  *
@@ -2,4 +2,4 @@
2
2
  * 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.
3
3
  * Otherwise, it will return the logger instance attached to the DI context.
4
4
  */
5
- export declare function contextLogger(): import("../index.js").ContextLogger;
5
+ export declare function contextLogger(): import("../../index.js").ContextLogger;
@@ -2,15 +2,8 @@
2
2
  * @file Automatically generated by @tsed/barrels.
3
3
  */
4
4
  export * from "./decorators/injectContext.js";
5
- export * from "./domain/ContextLogger.js";
6
- export * from "./domain/DIContext.js";
7
5
  export * from "./fn/context.js";
8
6
  export * from "./fn/contextLogger.js";
9
- export * from "./interfaces/AlterRunInContext.js";
10
7
  export * from "./services/DILogger.js";
11
8
  export * from "./services/DITest.js";
12
9
  export * from "./utils/asyncHookContext.js";
13
- export * from "./utils/attachLogger.js";
14
- export * from "./utils/setLoggerConfiguration.js";
15
- export * from "./utils/setLoggerFormat.js";
16
- export * from "./utils/setLoggerLevel.js";
@@ -1,5 +1,5 @@
1
+ import { DIContext } from "../../common/domain/DIContext.js";
1
2
  import { InjectorService, TokenProvider, type UseImportTokenProviderOpts } from "../../common/index.js";
2
- import { DIContext } from "../domain/DIContext.js";
3
3
  /**
4
4
  * Tool to run test with lightweight DI sandbox.
5
5
  */
@@ -1,7 +1,7 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  import { AsyncLocalStorage } from "node:async_hooks";
3
+ import type { DIContext } from "../../common/domain/DIContext.js";
3
4
  import { InjectorService } from "../../common/index.js";
4
- import type { DIContext } from "../domain/DIContext.js";
5
5
  export declare function getAsyncStore(): AsyncLocalStorage<{
6
6
  current: DIContext | undefined;
7
7
  }>;
@@ -11,4 +11,7 @@ export declare function useContextRef(): {
11
11
  export declare function getContext<Context = DIContext>(initialValue?: DIContext): Context | undefined;
12
12
  export declare function runInContext<Result = unknown>(ctx: DIContext | undefined, cb: (...args: unknown[]) => Result, injector?: InjectorService): Promise<Result>;
13
13
  export declare function setContext(ctx: DIContext): void;
14
+ /**
15
+ * @deprecated
16
+ */
14
17
  export declare function bindContext(cb: any): any;
package/package.json CHANGED
@@ -2,17 +2,17 @@
2
2
  "name": "@tsed/di",
3
3
  "description": "DI module for Ts.ED Framework",
4
4
  "type": "module",
5
- "version": "8.15.1",
5
+ "version": "8.16.0-rc.1",
6
6
  "source": "./src/index.ts",
7
7
  "main": "./lib/esm/index.js",
8
8
  "module": "./lib/esm/index.js",
9
9
  "typings": "./lib/types/index.d.ts",
10
- "browser": "./lib/esm/common/index.js",
10
+ "browser": "./lib/esm/browser/index.js",
11
11
  "exports": {
12
12
  ".": {
13
13
  "tsed-source": "./src/index.ts",
14
14
  "types": "./lib/types/index.d.ts",
15
- "browser": "./lib/esm/common/index.js",
15
+ "browser": "./lib/esm/browser/index.js",
16
16
  "import": "./lib/esm/index.js",
17
17
  "default": "./lib/esm/index.js"
18
18
  }
@@ -29,11 +29,11 @@
29
29
  "uuid": "^10.0.0"
30
30
  },
31
31
  "devDependencies": {
32
- "@tsed/barrels": "8.15.1",
33
- "@tsed/core": "8.15.1",
34
- "@tsed/hooks": "8.15.1",
35
- "@tsed/logger": "^7.0.1",
36
- "@tsed/typescript": "8.15.1",
32
+ "@tsed/barrels": "8.16.0-rc.1",
33
+ "@tsed/core": "8.16.0-rc.1",
34
+ "@tsed/hooks": "8.16.0-rc.1",
35
+ "@tsed/logger": "^8.0.0-rc.1",
36
+ "@tsed/typescript": "8.16.0-rc.1",
37
37
  "cross-env": "7.0.3",
38
38
  "eslint": "9.12.0",
39
39
  "typescript": "5.4.5",
@@ -43,7 +43,7 @@
43
43
  "peerDependencies": {
44
44
  "@tsed/core": ">=8.0.0",
45
45
  "@tsed/hooks": ">=8.0.0",
46
- "@tsed/logger": ">=7.0.1"
46
+ "@tsed/logger": ">=8.0.0-rc.1"
47
47
  },
48
48
  "peerDependenciesMeta": {
49
49
  "@tsed/core": {
@@ -62,5 +62,8 @@
62
62
  },
63
63
  "homepage": "https://github.com/tsedio/tsed/tree/production/packages/di",
64
64
  "author": "Romain Lenzotti",
65
- "license": "MIT"
65
+ "license": "MIT",
66
+ "publishConfig": {
67
+ "tag": "rc"
68
+ }
66
69
  }