@tsed/di 8.14.0 → 8.14.2-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.
- package/lib/esm/browser/decorators/injectContext.js +26 -0
- package/lib/esm/browser/fn/context.js +20 -0
- package/lib/esm/browser/fn/contextLogger.js +8 -0
- package/lib/esm/browser/index.js +5 -0
- package/lib/esm/browser/utils/asyncHookContext.js +67 -0
- package/lib/esm/common/decorators/autoInjectable.js +6 -1
- package/lib/esm/{node → common}/domain/DIContext.js +1 -1
- package/lib/esm/common/index.js +7 -0
- package/lib/esm/{node → common}/utils/attachLogger.js +1 -1
- package/lib/esm/{node → common}/utils/setLoggerFormat.js +2 -2
- package/lib/esm/{node → common}/utils/setLoggerLevel.js +1 -1
- package/lib/esm/node/exports.js +1 -0
- package/lib/esm/node/fn/context.js +1 -1
- package/lib/esm/node/index.js +1 -7
- package/lib/esm/node/services/DITest.js +2 -2
- package/lib/esm/node/utils/asyncHookContext.js +3 -0
- package/lib/types/browser/decorators/injectContext.d.ts +16 -0
- package/lib/types/browser/fn/context.d.ts +9 -0
- package/lib/types/browser/fn/contextLogger.d.ts +5 -0
- package/lib/types/browser/index.d.ts +5 -0
- package/lib/types/browser/utils/asyncHookContext.d.ts +22 -0
- package/lib/types/common/decorators/controller.d.ts +1 -1
- package/lib/types/common/decorators/inject.d.ts +1 -1
- package/lib/types/common/decorators/intercept.d.ts +1 -1
- package/lib/types/common/decorators/overrideProvider.d.ts +1 -1
- package/lib/types/{node → common}/domain/DIContext.d.ts +1 -1
- package/lib/types/common/domain/Provider.d.ts +1 -1
- package/lib/types/common/index.d.ts +7 -0
- package/lib/types/common/interfaces/RegistrySettings.d.ts +1 -1
- package/lib/types/common/registries/GlobalProviders.d.ts +1 -1
- package/lib/types/{node → common}/utils/attachLogger.d.ts +1 -1
- package/lib/types/common/utils/createContainer.d.ts +1 -1
- package/lib/types/common/utils/discoverHooks.d.ts +1 -1
- package/lib/types/common/utils/getConfiguration.d.ts +1 -1
- package/lib/types/common/utils/providerBuilder.d.ts +1 -1
- package/lib/types/node/decorators/injectContext.d.ts +1 -1
- package/lib/types/node/exports.d.ts +1 -0
- package/lib/types/node/fn/context.d.ts +1 -1
- package/lib/types/node/fn/contextLogger.d.ts +1 -1
- package/lib/types/node/index.d.ts +1 -7
- package/lib/types/node/services/DITest.d.ts +1 -1
- package/lib/types/node/utils/asyncHookContext.d.ts +4 -1
- package/package.json +14 -10
- /package/lib/esm/{node → common}/domain/ContextLogger.js +0 -0
- /package/lib/esm/{node → common}/interfaces/AlterRunInContext.js +0 -0
- /package/lib/esm/{node → common}/utils/setLoggerConfiguration.js +0 -0
- /package/lib/types/{node → common}/domain/ContextLogger.d.ts +0 -0
- /package/lib/types/{node → common}/interfaces/AlterRunInContext.d.ts +0 -0
- /package/lib/types/{node → common}/utils/setLoggerConfiguration.d.ts +0 -0
- /package/lib/types/{node → common}/utils/setLoggerFormat.d.ts +0 -0
- /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,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)
|
|
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
|
}
|
package/lib/esm/common/index.js
CHANGED
|
@@ -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";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@tsed/logger-std";
|
|
@@ -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.
|
package/lib/esm/node/index.js
CHANGED
|
@@ -2,15 +2,9 @@
|
|
|
2
2
|
* @file Automatically generated by @tsed/barrels.
|
|
3
3
|
*/
|
|
4
4
|
export * from "./decorators/injectContext.js";
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./domain/DIContext.js";
|
|
5
|
+
export * from "./exports.js";
|
|
7
6
|
export * from "./fn/context.js";
|
|
8
7
|
export * from "./fn/contextLogger.js";
|
|
9
|
-
export * from "./interfaces/AlterRunInContext.js";
|
|
10
8
|
export * from "./services/DILogger.js";
|
|
11
9
|
export * from "./services/DITest.js";
|
|
12
10
|
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 {
|
|
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
|
*/
|
|
@@ -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,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 {
|
|
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 { InjectorService, LocalsContainer } from "
|
|
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 {
|
|
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 { 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 "
|
|
1
|
+
import { DILogger } from "../index.js";
|
|
2
2
|
export declare function attachLogger($log: DILogger): void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AbstractType, Type } from "@tsed/core/types/Type.js";
|
|
2
2
|
export declare function discoverHooks(token: Type | AbstractType<any>): any;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "../registries/ProviderRegistry.js";
|
|
2
2
|
import { Store } from "@tsed/core/types/Store.js";
|
|
3
|
-
import {
|
|
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> = {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@tsed/logger-std";
|
|
@@ -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("
|
|
5
|
+
export declare function contextLogger(): import("../../index.js").ContextLogger;
|
|
@@ -2,15 +2,9 @@
|
|
|
2
2
|
* @file Automatically generated by @tsed/barrels.
|
|
3
3
|
*/
|
|
4
4
|
export * from "./decorators/injectContext.js";
|
|
5
|
-
export * from "./
|
|
6
|
-
export * from "./domain/DIContext.js";
|
|
5
|
+
export * from "./exports.js";
|
|
7
6
|
export * from "./fn/context.js";
|
|
8
7
|
export * from "./fn/contextLogger.js";
|
|
9
|
-
export * from "./interfaces/AlterRunInContext.js";
|
|
10
8
|
export * from "./services/DILogger.js";
|
|
11
9
|
export * from "./services/DITest.js";
|
|
12
10
|
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.14.
|
|
5
|
+
"version": "8.14.2-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/
|
|
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/
|
|
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,12 @@
|
|
|
29
29
|
"uuid": "^10.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tsed/barrels": "8.14.
|
|
33
|
-
"@tsed/core": "8.14.
|
|
34
|
-
"@tsed/hooks": "8.14.
|
|
35
|
-
"@tsed/logger": "^
|
|
36
|
-
"@tsed/
|
|
32
|
+
"@tsed/barrels": "8.14.2-rc.1",
|
|
33
|
+
"@tsed/core": "8.14.2-rc.1",
|
|
34
|
+
"@tsed/hooks": "8.14.2-rc.1",
|
|
35
|
+
"@tsed/logger": "^8.0.0-rc.1",
|
|
36
|
+
"@tsed/logger-std": "^8.0.0-rc.1",
|
|
37
|
+
"@tsed/typescript": "8.14.2-rc.1",
|
|
37
38
|
"cross-env": "7.0.3",
|
|
38
39
|
"eslint": "9.12.0",
|
|
39
40
|
"typescript": "5.4.5",
|
|
@@ -43,7 +44,7 @@
|
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"@tsed/core": ">=8.0.0",
|
|
45
46
|
"@tsed/hooks": ">=8.0.0",
|
|
46
|
-
"@tsed/logger": ">=
|
|
47
|
+
"@tsed/logger": ">=8.0.0-rc.1"
|
|
47
48
|
},
|
|
48
49
|
"peerDependenciesMeta": {
|
|
49
50
|
"@tsed/core": {
|
|
@@ -62,5 +63,8 @@
|
|
|
62
63
|
},
|
|
63
64
|
"homepage": "https://github.com/tsedio/tsed/tree/production/packages/di",
|
|
64
65
|
"author": "Romain Lenzotti",
|
|
65
|
-
"license": "MIT"
|
|
66
|
+
"license": "MIT",
|
|
67
|
+
"publishConfig": {
|
|
68
|
+
"tag": "rc"
|
|
69
|
+
}
|
|
66
70
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|