@decaf-ts/for-nest 0.2.26 → 0.2.27
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/dist/for-nest.cjs +1 -1
- package/dist/for-nest.cjs.map +1 -1
- package/dist/for-nest.js +1 -1
- package/dist/for-nest.js.map +1 -1
- package/lib/controllers.cjs +7 -2
- package/lib/controllers.js.map +1 -1
- package/lib/esm/controllers.js +7 -2
- package/lib/esm/controllers.js.map +1 -1
- package/lib/esm/index.d.ts +1 -1
- package/lib/esm/index.js +1 -1
- package/lib/esm/request/DecafRequestContext.d.ts +3 -21
- package/lib/esm/request/DecafRequestContext.js +17 -23
- package/lib/esm/request/DecafRequestContext.js.map +1 -1
- package/lib/index.cjs +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/request/DecafRequestContext.cjs +16 -22
- package/lib/request/DecafRequestContext.d.ts +3 -21
- package/lib/request/DecafRequestContext.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,30 +4,22 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { Inject, Injectable, Scope } from "@nestjs/common";
|
|
8
14
|
import { InternalError } from "@decaf-ts/db-decorators";
|
|
9
|
-
|
|
10
|
-
* @description
|
|
11
|
-
* Request-scoped context used to store arbitrary values for the duration of a single request.
|
|
12
|
-
*
|
|
13
|
-
* @summary
|
|
14
|
-
* The {@link DecafRequestContext} class provides an isolated per-request key-value cache,
|
|
15
|
-
* enabling services and controllers to share state or metadata without relying on global
|
|
16
|
-
* or static variables. Keys may be strings or symbols, and cached values may hold any
|
|
17
|
-
* serializable or non-serializable object.
|
|
18
|
-
*
|
|
19
|
-
* @class DecafRequestContext
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* // Saving a value in the request context:
|
|
24
|
-
* context.set("tenantId", "abc123");
|
|
25
|
-
*
|
|
26
|
-
* // Retrieving it later in the request lifecycle:
|
|
27
|
-
* const tenantId = context.get<string>("tenantId");
|
|
28
|
-
* ```
|
|
29
|
-
*/
|
|
15
|
+
import { REQUEST } from "@nestjs/core";
|
|
30
16
|
let DecafRequestContext = class DecafRequestContext {
|
|
17
|
+
constructor(req) {
|
|
18
|
+
this.req = req;
|
|
19
|
+
}
|
|
20
|
+
get request() {
|
|
21
|
+
return this.req;
|
|
22
|
+
}
|
|
31
23
|
put(record) {
|
|
32
24
|
let overrides;
|
|
33
25
|
try {
|
|
@@ -51,7 +43,9 @@ let DecafRequestContext = class DecafRequestContext {
|
|
|
51
43
|
}
|
|
52
44
|
};
|
|
53
45
|
DecafRequestContext = __decorate([
|
|
54
|
-
Injectable({ scope: Scope.REQUEST })
|
|
46
|
+
Injectable({ scope: Scope.REQUEST }),
|
|
47
|
+
__param(0, Inject(REQUEST)),
|
|
48
|
+
__metadata("design:paramtypes", [Request])
|
|
55
49
|
], DecafRequestContext);
|
|
56
50
|
export { DecafRequestContext };
|
|
57
51
|
//# sourceMappingURL=DecafRequestContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecafRequestContext.js","sourceRoot":"","sources":["../../../src/request/DecafRequestContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DecafRequestContext.js","sourceRoot":"","sources":["../../../src/request/DecafRequestContext.ts"],"names":[],"mappings":";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js"), exports);
|
|
|
56
56
|
* @constant
|
|
57
57
|
* @type {string}
|
|
58
58
|
*/
|
|
59
|
-
exports.VERSION = "0.2.
|
|
59
|
+
exports.VERSION = "0.2.27";
|
|
60
60
|
exports.PACKAGE_NAME = "@decaf-ts/for-nest";
|
|
61
61
|
decoration_1.Metadata.registerLibrary(exports.PACKAGE_NAME, exports.VERSION);
|
|
62
62
|
//# sourceMappingURL=index.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -5,32 +5,24 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
6
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
7
|
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
8
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
15
|
exports.DecafRequestContext = void 0;
|
|
10
16
|
const common_1 = require("@nestjs/common");
|
|
11
17
|
const db_decorators_1 = require("@decaf-ts/db-decorators");
|
|
12
|
-
|
|
13
|
-
* @description
|
|
14
|
-
* Request-scoped context used to store arbitrary values for the duration of a single request.
|
|
15
|
-
*
|
|
16
|
-
* @summary
|
|
17
|
-
* The {@link DecafRequestContext} class provides an isolated per-request key-value cache,
|
|
18
|
-
* enabling services and controllers to share state or metadata without relying on global
|
|
19
|
-
* or static variables. Keys may be strings or symbols, and cached values may hold any
|
|
20
|
-
* serializable or non-serializable object.
|
|
21
|
-
*
|
|
22
|
-
* @class DecafRequestContext
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* // Saving a value in the request context:
|
|
27
|
-
* context.set("tenantId", "abc123");
|
|
28
|
-
*
|
|
29
|
-
* // Retrieving it later in the request lifecycle:
|
|
30
|
-
* const tenantId = context.get<string>("tenantId");
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
18
|
+
const core_1 = require("@nestjs/core");
|
|
33
19
|
let DecafRequestContext = class DecafRequestContext {
|
|
20
|
+
constructor(req) {
|
|
21
|
+
this.req = req;
|
|
22
|
+
}
|
|
23
|
+
get request() {
|
|
24
|
+
return this.req;
|
|
25
|
+
}
|
|
34
26
|
put(record) {
|
|
35
27
|
let overrides;
|
|
36
28
|
try {
|
|
@@ -55,6 +47,8 @@ let DecafRequestContext = class DecafRequestContext {
|
|
|
55
47
|
};
|
|
56
48
|
exports.DecafRequestContext = DecafRequestContext;
|
|
57
49
|
exports.DecafRequestContext = DecafRequestContext = __decorate([
|
|
58
|
-
(0, common_1.Injectable)({ scope: common_1.Scope.REQUEST })
|
|
50
|
+
(0, common_1.Injectable)({ scope: common_1.Scope.REQUEST }),
|
|
51
|
+
__param(0, (0, common_1.Inject)(core_1.REQUEST)),
|
|
52
|
+
__metadata("design:paramtypes", [Request])
|
|
59
53
|
], DecafRequestContext);
|
|
60
54
|
//# sourceMappingURL=DecafRequestContext.js.map
|
|
@@ -1,27 +1,9 @@
|
|
|
1
1
|
import { DecafServerCtx } from "../constants";
|
|
2
|
-
/**
|
|
3
|
-
* @description
|
|
4
|
-
* Request-scoped context used to store arbitrary values for the duration of a single request.
|
|
5
|
-
*
|
|
6
|
-
* @summary
|
|
7
|
-
* The {@link DecafRequestContext} class provides an isolated per-request key-value cache,
|
|
8
|
-
* enabling services and controllers to share state or metadata without relying on global
|
|
9
|
-
* or static variables. Keys may be strings or symbols, and cached values may hold any
|
|
10
|
-
* serializable or non-serializable object.
|
|
11
|
-
*
|
|
12
|
-
* @class DecafRequestContext
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* // Saving a value in the request context:
|
|
17
|
-
* context.set("tenantId", "abc123");
|
|
18
|
-
*
|
|
19
|
-
* // Retrieving it later in the request lifecycle:
|
|
20
|
-
* const tenantId = context.get<string>("tenantId");
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
2
|
export declare class DecafRequestContext<C extends DecafServerCtx = DecafServerCtx> {
|
|
3
|
+
private readonly req;
|
|
24
4
|
private _ctx?;
|
|
5
|
+
constructor(req: Request);
|
|
6
|
+
get request(): Record<string | symbol, any>;
|
|
25
7
|
put(record: Record<any, any>): void;
|
|
26
8
|
applyCtx(ctx: C): void;
|
|
27
9
|
get ctx(): C;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DecafRequestContext.js","sourceRoot":"","sources":["../../src/request/DecafRequestContext.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"DecafRequestContext.js","sourceRoot":"","sources":["../../src/request/DecafRequestContext.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA2D;AAE3D,2DAAwD;AACxD,uCAAuC;AAGhC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAG9B,YAA8C,GAAY;QAAZ,QAAG,GAAH,GAAG,CAAS;IAAG,CAAC;IAE9D,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAED,GAAG,CAAC,MAAwB;QAC1B,IAAI,SAAc,CAAC;QACnB,IAAI,CAAC;YACH,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;YACtC,6DAA6D;QAC/D,CAAC;QAAC,OAAO,CAAU,EAAE,CAAC;YACpB,SAAS,GAAG,EAAE,CAAC;QACjB,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC;YAC9B,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC;SAC5C,CAAQ,CAAC;IACZ,CAAC;IAED,QAAQ,CAAC,GAAM;QACb,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAClB,CAAC;IAED,IAAI,GAAG;QACL,IAAI,CAAC,IAAI,CAAC,IAAI;YACZ,MAAM,IAAI,6BAAa,CAAC,qCAAqC,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;CACF,CAAA;AAhCY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,OAAO,EAAE,CAAC;IAItB,WAAA,IAAA,eAAM,EAAC,cAAO,CAAC,CAAA;qCAAuB,OAAO;GAH/C,mBAAmB,CAgC/B"}
|