@tsed/di 6.121.1 → 6.122.2
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/cjs/domain/DIContext.js +4 -1
- package/lib/cjs/domain/DIContext.js.map +1 -1
- package/lib/esm/domain/DIContext.js +4 -1
- package/lib/esm/domain/DIContext.js.map +1 -1
- package/lib/types/domain/ContextLogger.d.ts +1 -1
- package/lib/types/domain/DIContext.d.ts +2 -1
- package/package.json +5 -5
- package/readme.md +1 -1
|
@@ -6,6 +6,7 @@ const ContextLogger_1 = require("./ContextLogger");
|
|
|
6
6
|
const LocalsContainer_1 = require("./LocalsContainer");
|
|
7
7
|
class DIContext extends Map {
|
|
8
8
|
options;
|
|
9
|
+
opts;
|
|
9
10
|
/**
|
|
10
11
|
* The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`
|
|
11
12
|
*/
|
|
@@ -59,7 +60,9 @@ class DIContext extends Map {
|
|
|
59
60
|
async destroy() {
|
|
60
61
|
await this.container.destroy();
|
|
61
62
|
this.logger.destroy();
|
|
62
|
-
this.opts =
|
|
63
|
+
this.opts = {
|
|
64
|
+
id: this.opts.id
|
|
65
|
+
};
|
|
63
66
|
this.container = null;
|
|
64
67
|
}
|
|
65
68
|
async emit(eventName, ...args) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../../src/domain/DIContext.ts"],"names":[],"mappings":";;;AAEA,wDAAmD;AACnD,mDAAoE;AACpE,uDAAkD;AAkBlD,MAAa,SAAU,SAAQ,GAAa;
|
|
1
|
+
{"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../../src/domain/DIContext.ts"],"names":[],"mappings":";;;AAEA,wDAAmD;AACnD,mDAAoE;AACpE,uDAAkD;AAkBlD,MAAa,SAAU,SAAQ,GAAa;IAcrB;IAXrB,IAAI,CAAmB;IAEvB;;OAEG;IACI,SAAS,GAAG,IAAI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IAAA,2BAAY,EAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AA9ED,8BA8EC","sourcesContent":["import type {Env} from \"@tsed/core\";\nimport {InjectorService} from \"../services/InjectorService\";\nimport {runInContext} from \"../utils/runInContext\";\nimport {ContextLogger, ContextLoggerOptions} from \"./ContextLogger\";\nimport {LocalsContainer} from \"./LocalsContainer\";\n\nexport interface ContextMethods extends Map<any, any> {\n readonly id: string;\n readonly logger: ContextLogger;\n readonly injector: InjectorService;\n readonly container: LocalsContainer;\n readonly env: Env;\n\n destroy(): any;\n}\n\nexport interface DIContextOptions extends Omit<ContextLoggerOptions, \"dateStart\"> {\n id: string;\n injector: InjectorService;\n logger: any;\n}\n\nexport class DIContext extends Map<any, any> implements ContextMethods {\n [x: string]: any;\n\n opts: DIContextOptions;\n\n /**\n * The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`\n */\n public container = new LocalsContainer<any>();\n /**\n * Logger attached to the context request.\n */\n readonly logger: ContextLogger;\n\n constructor(readonly options: DIContextOptions) {\n super();\n this.opts = options;\n this.logger = new ContextLogger(this);\n }\n\n /**\n * Request id generated by @@contextMiddleware@@.\n *\n * ::: tip\n * By default Ts.ED generate uuid like that `uuidv4().replace(/-/gi, \"\"))`.\n * Dash are removed to simplify tracking logs in Kibana\n * :::\n *\n * ::: tip\n * Request id can by customized by changing the server configuration.\n *\n * ```typescript\n * @Configuration({\n * logger: {\n * reqIdBuilder: createUniqId // give your own id generator function\n * }\n * })\n * class Server {\n *\n * }\n * ```\n * :::\n *\n */\n get id() {\n return this.opts.id;\n }\n\n get dateStart() {\n return this.logger.dateStart;\n }\n\n get injector(): InjectorService {\n return this.opts.injector!;\n }\n\n get env() {\n return this.injector.settings.get(\"env\");\n }\n\n async destroy() {\n await this.container.destroy();\n this.logger.destroy();\n this.opts = {\n id: this.opts.id\n } as any;\n this.container = null as any;\n }\n\n async emit(eventName: string, ...args: any[]) {\n return this.injector?.emit(eventName, ...args);\n }\n\n async runInContext(next: Function) {\n next = (await this.injector?.alterAsync(\"$alterRunInContext\", next, this)) || next;\n\n return runInContext(this, next);\n }\n}\n\nexport type BaseContext = DIContext & TsED.Context;\n"]}
|
|
@@ -3,6 +3,7 @@ import { ContextLogger } from "./ContextLogger.js";
|
|
|
3
3
|
import { LocalsContainer } from "./LocalsContainer.js";
|
|
4
4
|
export class DIContext extends Map {
|
|
5
5
|
options;
|
|
6
|
+
opts;
|
|
6
7
|
/**
|
|
7
8
|
* The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`
|
|
8
9
|
*/
|
|
@@ -56,7 +57,9 @@ export class DIContext extends Map {
|
|
|
56
57
|
async destroy() {
|
|
57
58
|
await this.container.destroy();
|
|
58
59
|
this.logger.destroy();
|
|
59
|
-
this.opts =
|
|
60
|
+
this.opts = {
|
|
61
|
+
id: this.opts.id
|
|
62
|
+
};
|
|
60
63
|
this.container = null;
|
|
61
64
|
}
|
|
62
65
|
async emit(eventName, ...args) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../../src/domain/DIContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAuB,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAkBlD,MAAM,OAAO,SAAU,SAAQ,GAAa;
|
|
1
|
+
{"version":3,"file":"DIContext.js","sourceRoot":"","sources":["../../../src/domain/DIContext.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAC,aAAa,EAAuB,MAAM,iBAAiB,CAAC;AACpE,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAkBlD,MAAM,OAAO,SAAU,SAAQ,GAAa;IAcrB;IAXrB,IAAI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AAC,CAAC,IAAI,IAAI,CAAC;QAEnF,OAAO,YAAY,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;CACF","sourcesContent":["import type {Env} from \"@tsed/core\";\nimport {InjectorService} from \"../services/InjectorService\";\nimport {runInContext} from \"../utils/runInContext\";\nimport {ContextLogger, ContextLoggerOptions} from \"./ContextLogger\";\nimport {LocalsContainer} from \"./LocalsContainer\";\n\nexport interface ContextMethods extends Map<any, any> {\n readonly id: string;\n readonly logger: ContextLogger;\n readonly injector: InjectorService;\n readonly container: LocalsContainer;\n readonly env: Env;\n\n destroy(): any;\n}\n\nexport interface DIContextOptions extends Omit<ContextLoggerOptions, \"dateStart\"> {\n id: string;\n injector: InjectorService;\n logger: any;\n}\n\nexport class DIContext extends Map<any, any> implements ContextMethods {\n [x: string]: any;\n\n opts: DIContextOptions;\n\n /**\n * The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`\n */\n public container = new LocalsContainer<any>();\n /**\n * Logger attached to the context request.\n */\n readonly logger: ContextLogger;\n\n constructor(readonly options: DIContextOptions) {\n super();\n this.opts = options;\n this.logger = new ContextLogger(this);\n }\n\n /**\n * Request id generated by @@contextMiddleware@@.\n *\n * ::: tip\n * By default Ts.ED generate uuid like that `uuidv4().replace(/-/gi, \"\"))`.\n * Dash are removed to simplify tracking logs in Kibana\n * :::\n *\n * ::: tip\n * Request id can by customized by changing the server configuration.\n *\n * ```typescript\n * @Configuration({\n * logger: {\n * reqIdBuilder: createUniqId // give your own id generator function\n * }\n * })\n * class Server {\n *\n * }\n * ```\n * :::\n *\n */\n get id() {\n return this.opts.id;\n }\n\n get dateStart() {\n return this.logger.dateStart;\n }\n\n get injector(): InjectorService {\n return this.opts.injector!;\n }\n\n get env() {\n return this.injector.settings.get(\"env\");\n }\n\n async destroy() {\n await this.container.destroy();\n this.logger.destroy();\n this.opts = {\n id: this.opts.id\n } as any;\n this.container = null as any;\n }\n\n async emit(eventName: string, ...args: any[]) {\n return this.injector?.emit(eventName, ...args);\n }\n\n async runInContext(next: Function) {\n next = (await this.injector?.alterAsync(\"$alterRunInContext\", next, this)) || next;\n\n return runInContext(this, next);\n }\n}\n\nexport type BaseContext = DIContext & TsED.Context;\n"]}
|
|
@@ -14,7 +14,7 @@ export declare class ContextLogger {
|
|
|
14
14
|
protected readonly $ctx: DIContext;
|
|
15
15
|
readonly dateStart: Date;
|
|
16
16
|
constructor($ctx: DIContext);
|
|
17
|
-
get id():
|
|
17
|
+
get id(): string;
|
|
18
18
|
set maxStackSize(maxStackSize: number);
|
|
19
19
|
get hooks(): Hooks;
|
|
20
20
|
private get stack();
|
|
@@ -18,6 +18,7 @@ export interface DIContextOptions extends Omit<ContextLoggerOptions, "dateStart"
|
|
|
18
18
|
export declare class DIContext extends Map<any, any> implements ContextMethods {
|
|
19
19
|
readonly options: DIContextOptions;
|
|
20
20
|
[x: string]: any;
|
|
21
|
+
opts: DIContextOptions;
|
|
21
22
|
/**
|
|
22
23
|
* The request container used by the Ts.ED DI. It contain all services annotated with `@Scope(ProviderScope.REQUEST)`
|
|
23
24
|
*/
|
|
@@ -51,7 +52,7 @@ export declare class DIContext extends Map<any, any> implements ContextMethods {
|
|
|
51
52
|
* :::
|
|
52
53
|
*
|
|
53
54
|
*/
|
|
54
|
-
get id():
|
|
55
|
+
get id(): string;
|
|
55
56
|
get dateStart(): Date;
|
|
56
57
|
get injector(): InjectorService;
|
|
57
58
|
get env(): any;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsed/di",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.122.2",
|
|
4
4
|
"description": "DI module for Ts.ED Framework",
|
|
5
5
|
"private": false,
|
|
6
6
|
"source": "./src/index.ts",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"tslib": "2.4.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@tsed/core": "6.
|
|
27
|
+
"@tsed/core": "6.122.2",
|
|
28
28
|
"@tsed/logger": ">=6.2.0",
|
|
29
|
-
"@tsed/schema": "6.
|
|
29
|
+
"@tsed/schema": "6.122.2"
|
|
30
30
|
},
|
|
31
31
|
"peerDependencies": {
|
|
32
|
-
"@tsed/core": "^6.
|
|
32
|
+
"@tsed/core": "^6.122.2",
|
|
33
33
|
"@tsed/logger": ">=6.2.0",
|
|
34
|
-
"@tsed/schema": "^6.
|
|
34
|
+
"@tsed/schema": "^6.122.2"
|
|
35
35
|
},
|
|
36
36
|
"peerDependenciesMeta": {
|
|
37
37
|
"@tsed/core": {
|
package/readme.md
CHANGED
|
@@ -169,7 +169,7 @@ Support this project by becoming a sponsor. Your logo will show up here with a l
|
|
|
169
169
|
|
|
170
170
|
The MIT License (MIT)
|
|
171
171
|
|
|
172
|
-
Copyright (c) 2016 -
|
|
172
|
+
Copyright (c) 2016 - 2022 Romain Lenzotti
|
|
173
173
|
|
|
174
174
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
175
175
|
|