@decaf-ts/for-nest 0.1.2 → 0.1.3

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 (76) hide show
  1. package/README.md +6 -1
  2. package/dist/for-nest.cjs +1 -1
  3. package/dist/for-nest.cjs.map +1 -1
  4. package/dist/for-nest.js +1 -1
  5. package/dist/for-nest.js.map +1 -1
  6. package/lib/RepoFactory.cjs +27 -0
  7. package/lib/RepoFactory.d.ts +6 -0
  8. package/lib/RepoFactory.js.map +1 -0
  9. package/lib/constants.cjs +1 -3
  10. package/lib/constants.d.ts +0 -2
  11. package/lib/constants.js.map +1 -1
  12. package/lib/decaf-model/DecafModelModule.cjs +3 -22
  13. package/lib/decaf-model/DecafModelModule.d.ts +2 -3
  14. package/lib/decaf-model/DecafModelModule.js.map +1 -1
  15. package/lib/decaf-model/FromModelController.cjs +16 -69
  16. package/lib/decaf-model/FromModelController.d.ts +0 -49
  17. package/lib/decaf-model/FromModelController.js.map +1 -1
  18. package/lib/decoration.cjs +5 -0
  19. package/lib/decoration.js.map +1 -1
  20. package/lib/esm/RepoFactory.d.ts +6 -0
  21. package/lib/esm/RepoFactory.js +24 -0
  22. package/lib/esm/RepoFactory.js.map +1 -0
  23. package/lib/esm/constants.d.ts +0 -2
  24. package/lib/esm/constants.js +0 -2
  25. package/lib/esm/constants.js.map +1 -1
  26. package/lib/esm/decaf-model/DecafModelModule.d.ts +2 -3
  27. package/lib/esm/decaf-model/DecafModelModule.js +3 -22
  28. package/lib/esm/decaf-model/DecafModelModule.js.map +1 -1
  29. package/lib/esm/decaf-model/FromModelController.d.ts +0 -49
  30. package/lib/esm/decaf-model/FromModelController.js +16 -69
  31. package/lib/esm/decaf-model/FromModelController.js.map +1 -1
  32. package/lib/esm/decoration.js +6 -1
  33. package/lib/esm/decoration.js.map +1 -1
  34. package/lib/esm/index.d.ts +2 -3
  35. package/lib/esm/index.js +2 -3
  36. package/lib/esm/index.js.map +1 -1
  37. package/lib/esm/module.js +1 -1
  38. package/lib/esm/module.js.map +1 -1
  39. package/lib/esm/types.d.ts +0 -9
  40. package/lib/index.cjs +2 -3
  41. package/lib/index.d.ts +2 -3
  42. package/lib/index.js.map +1 -1
  43. package/lib/module.cjs +1 -1
  44. package/lib/module.js.map +1 -1
  45. package/lib/types.d.ts +0 -9
  46. package/package.json +1 -1
  47. package/lib/esm/interceptors/DecafRequestHandlerInterceptor.d.ts +0 -53
  48. package/lib/esm/interceptors/DecafRequestHandlerInterceptor.js +0 -73
  49. package/lib/esm/interceptors/DecafRequestHandlerInterceptor.js.map +0 -1
  50. package/lib/esm/interceptors/index.d.ts +0 -1
  51. package/lib/esm/interceptors/index.js +0 -2
  52. package/lib/esm/interceptors/index.js.map +0 -1
  53. package/lib/esm/request/DecafHandlerExecutor.d.ts +0 -52
  54. package/lib/esm/request/DecafHandlerExecutor.js +0 -77
  55. package/lib/esm/request/DecafHandlerExecutor.js.map +0 -1
  56. package/lib/esm/request/DecafRequestContext.d.ts +0 -26
  57. package/lib/esm/request/DecafRequestContext.js +0 -44
  58. package/lib/esm/request/DecafRequestContext.js.map +0 -1
  59. package/lib/esm/request/index.d.ts +0 -2
  60. package/lib/esm/request/index.js +0 -3
  61. package/lib/esm/request/index.js.map +0 -1
  62. package/lib/interceptors/DecafRequestHandlerInterceptor.cjs +0 -76
  63. package/lib/interceptors/DecafRequestHandlerInterceptor.d.ts +0 -53
  64. package/lib/interceptors/DecafRequestHandlerInterceptor.js.map +0 -1
  65. package/lib/interceptors/index.cjs +0 -18
  66. package/lib/interceptors/index.d.ts +0 -1
  67. package/lib/interceptors/index.js.map +0 -1
  68. package/lib/request/DecafHandlerExecutor.cjs +0 -80
  69. package/lib/request/DecafHandlerExecutor.d.ts +0 -52
  70. package/lib/request/DecafHandlerExecutor.js.map +0 -1
  71. package/lib/request/DecafRequestContext.cjs +0 -47
  72. package/lib/request/DecafRequestContext.d.ts +0 -26
  73. package/lib/request/DecafRequestContext.js.map +0 -1
  74. package/lib/request/index.cjs +0 -19
  75. package/lib/request/index.d.ts +0 -2
  76. package/lib/request/index.js.map +0 -1
@@ -1,53 +0,0 @@
1
- import { CallHandler, ExecutionContext, NestInterceptor } from "@nestjs/common";
2
- import { DecafHandlerExecutor } from "../request";
3
- /**
4
- * @description
5
- * Interceptor responsible for executing all registered Decaf request handlers
6
- * before the controller method is invoked.
7
- *
8
- * @summary
9
- * The {@link DecafRequestHandlerInterceptor} integrates the Decaf request-handling pipeline
10
- * into NestJS' interceptor mechanism. Before passing execution to the next handler in the
11
- * NestJS chain, it delegates request processing to the {@link DecafHandlerExecutor}, which
12
- * sequentially runs all registered {@link DecafRequestHandler} instances. This allows
13
- * behaviors such as authentication, logging, tenant resolution, or metadata enrichment
14
- * to occur prior to controller execution.
15
- *
16
- * @class DecafRequestHandlerInterceptor
17
- *
18
- * @example
19
- * ```ts
20
- * // Apply globally:
21
- * app.useGlobalInterceptors(new DecafRequestHandlerInterceptor(executor));
22
- *
23
- * // Or in a module:
24
- * @Module({
25
- * providers: [
26
- * DecafHandlerExecutor,
27
- * {
28
- * provide: APP_INTERCEPTOR,
29
- * useClass: DecafRequestHandlerInterceptor,
30
- * },
31
- * ],
32
- * })
33
- * export class AppModule {}
34
- * ```
35
- *
36
- * @mermaid
37
- * sequenceDiagram
38
- * participant Client
39
- * participant Interceptor
40
- * participant Executor
41
- * participant Controller
42
- *
43
- * Client->>Interceptor: HTTP Request
44
- * Interceptor->>Executor: exec(request)
45
- * Executor-->>Interceptor: handlers completed
46
- * Interceptor->>Controller: next.handle()
47
- * Controller-->>Client: Response
48
- */
49
- export declare class DecafRequestHandlerInterceptor implements NestInterceptor {
50
- private readonly executor;
51
- constructor(executor: DecafHandlerExecutor);
52
- intercept(ctx: ExecutionContext, next: CallHandler): Promise<import("rxjs").Observable<any>>;
53
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"DecafRequestHandlerInterceptor.js","sourceRoot":"","sources":["../../src/interceptors/DecafRequestHandlerInterceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAMwB;AACxB,oDAAkD;AAElD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEI,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IACzC,YAA6B,QAA8B;QAA9B,aAAQ,GAAR,QAAQ,CAAsB;IAAG,CAAC;IAE/D,KAAK,CAAC,SAAS,CAAC,GAAqB,EAAE,IAAiB;QACtD,MAAM,GAAG,GAAG,GAAG,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QAC5C,MAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC9B,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;IACvB,CAAC;CACF,CAAA;AARY,wEAA8B;yCAA9B,8BAA8B;IAD1C,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,OAAO,EAAE,CAAC;qCAEI,8BAAoB;GADhD,8BAA8B,CAQ1C"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./DecafRequestHandlerInterceptor.cjs"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- export * from "./DecafRequestHandlerInterceptor";
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/interceptors/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uEAAiD"}
@@ -1,80 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
- return c > 3 && r && Object.defineProperty(target, key, r), r;
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
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.DecafHandlerExecutor = void 0;
16
- const common_1 = require("@nestjs/common");
17
- const DecafRequestContext_1 = require("./DecafRequestContext.cjs");
18
- const constants_1 = require("./../constants.cjs");
19
- /**
20
- * @description
21
- * Executes all registered {@link DecafRequestHandler} instances for the current request,
22
- * providing them with a shared {@link DecafRequestContext}.
23
- *
24
- * @summary
25
- * The {@link DecafHandlerExecutor} class is responsible for orchestrating and executing
26
- * a sequence of request handlers. Each handler receives the same request-scoped context,
27
- * allowing coordinated processing such as authentication, metadata extraction, auditing,
28
- * and custom pipeline behavior. Handlers are injected via the {@link DECAF_HANDLERS} token,
29
- * ensuring extensibility and loose coupling.
30
- *
31
- * @class DecafHandlerExecutor
32
- *
33
- * @example
34
- * ```ts
35
- * // Example handler:
36
- * class AuthHandler implements DecafRequestHandler {
37
- * async handle(context: DecafRequestContext, req: Request) {
38
- * const token = req.headers["authorization"];
39
- * const result = MyService.doSomething(token);
40
- * context.set("my-key", result);
41
- * }
42
- * }
43
- *
44
- * // Executor usage in a request:
45
- * await executor.exec(request);
46
- * // All handlers will run in sequence
47
- * ```
48
- *
49
- * @mermaid
50
- * sequenceDiagram
51
- * participant Client
52
- * participant Executor
53
- * participant HandlerA
54
- * participant HandlerB
55
- *
56
- * Client->>Executor: exec(req)
57
- * Executor->>HandlerA: handle(context, req)
58
- * HandlerA-->>Executor: completed
59
- * Executor->>HandlerB: handle(context, req)
60
- * HandlerB-->>Executor: completed
61
- * Executor-->>Client: processing finished
62
- */
63
- let DecafHandlerExecutor = class DecafHandlerExecutor {
64
- constructor(handlers, context) {
65
- this.handlers = handlers;
66
- this.context = context;
67
- }
68
- async exec(req) {
69
- for (const handler of this.handlers) {
70
- await handler.handle(this.context, req);
71
- }
72
- }
73
- };
74
- exports.DecafHandlerExecutor = DecafHandlerExecutor;
75
- exports.DecafHandlerExecutor = DecafHandlerExecutor = __decorate([
76
- (0, common_1.Injectable)({ scope: common_1.Scope.REQUEST }),
77
- __param(0, (0, common_1.Inject)(constants_1.DECAF_HANDLERS)),
78
- __metadata("design:paramtypes", [Array, DecafRequestContext_1.DecafRequestContext])
79
- ], DecafHandlerExecutor);
80
- //# sourceMappingURL=DecafHandlerExecutor.js.map
@@ -1,52 +0,0 @@
1
- import { DecafRequestContext } from "./DecafRequestContext";
2
- import { type DecafRequestHandler } from "../types";
3
- /**
4
- * @description
5
- * Executes all registered {@link DecafRequestHandler} instances for the current request,
6
- * providing them with a shared {@link DecafRequestContext}.
7
- *
8
- * @summary
9
- * The {@link DecafHandlerExecutor} class is responsible for orchestrating and executing
10
- * a sequence of request handlers. Each handler receives the same request-scoped context,
11
- * allowing coordinated processing such as authentication, metadata extraction, auditing,
12
- * and custom pipeline behavior. Handlers are injected via the {@link DECAF_HANDLERS} token,
13
- * ensuring extensibility and loose coupling.
14
- *
15
- * @class DecafHandlerExecutor
16
- *
17
- * @example
18
- * ```ts
19
- * // Example handler:
20
- * class AuthHandler implements DecafRequestHandler {
21
- * async handle(context: DecafRequestContext, req: Request) {
22
- * const token = req.headers["authorization"];
23
- * const result = MyService.doSomething(token);
24
- * context.set("my-key", result);
25
- * }
26
- * }
27
- *
28
- * // Executor usage in a request:
29
- * await executor.exec(request);
30
- * // All handlers will run in sequence
31
- * ```
32
- *
33
- * @mermaid
34
- * sequenceDiagram
35
- * participant Client
36
- * participant Executor
37
- * participant HandlerA
38
- * participant HandlerB
39
- *
40
- * Client->>Executor: exec(req)
41
- * Executor->>HandlerA: handle(context, req)
42
- * HandlerA-->>Executor: completed
43
- * Executor->>HandlerB: handle(context, req)
44
- * HandlerB-->>Executor: completed
45
- * Executor-->>Client: processing finished
46
- */
47
- export declare class DecafHandlerExecutor {
48
- private readonly handlers;
49
- private readonly context;
50
- constructor(handlers: DecafRequestHandler[], context: DecafRequestContext);
51
- exec(req: Request): Promise<void>;
52
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"DecafHandlerExecutor.js","sourceRoot":"","sources":["../../src/request/DecafHandlerExecutor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA2D;AAC3D,mEAA4D;AAE5D,kDAA8C;AAE9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEI,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC/B,YAC2C,QAA+B,EACvD,OAA4B;QADJ,aAAQ,GAAR,QAAQ,CAAuB;QACvD,YAAO,GAAP,OAAO,CAAqB;IAC5C,CAAC;IAEJ,KAAK,CAAC,IAAI,CAAC,GAAY;QACrB,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YACpC,MAAM,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAC1C,CAAC;IACH,CAAC;CACF,CAAA;AAXY,oDAAoB;+BAApB,oBAAoB;IADhC,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,OAAO,EAAE,CAAC;IAGhC,WAAA,IAAA,eAAM,EAAC,0BAAc,CAAC,CAAA;4CACG,yCAAmB;GAHpC,oBAAoB,CAWhC"}
@@ -1,47 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
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
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.DecafRequestContext = void 0;
10
- const common_1 = require("@nestjs/common");
11
- /**
12
- * @description
13
- * Request-scoped context used to store arbitrary values for the duration of a single request.
14
- *
15
- * @summary
16
- * The {@link DecafRequestContext} class provides an isolated per-request key-value cache,
17
- * enabling services and controllers to share state or metadata without relying on global
18
- * or static variables. Keys may be strings or symbols, and cached values may hold any
19
- * serializable or non-serializable object.
20
- *
21
- * @class DecafRequestContext
22
- *
23
- * @example
24
- * ```ts
25
- * // Saving a value in the request context:
26
- * context.set("tenantId", "abc123");
27
- *
28
- * // Retrieving it later in the request lifecycle:
29
- * const tenantId = context.get<string>("tenantId");
30
- * ```
31
- */
32
- let DecafRequestContext = class DecafRequestContext {
33
- constructor() {
34
- this.cache = new Map();
35
- }
36
- set(key, value) {
37
- this.cache.set(key, value);
38
- }
39
- get(key) {
40
- return this.cache.get(key);
41
- }
42
- };
43
- exports.DecafRequestContext = DecafRequestContext;
44
- exports.DecafRequestContext = DecafRequestContext = __decorate([
45
- (0, common_1.Injectable)({ scope: common_1.Scope.REQUEST })
46
- ], DecafRequestContext);
47
- //# sourceMappingURL=DecafRequestContext.js.map
@@ -1,26 +0,0 @@
1
- /**
2
- * @description
3
- * Request-scoped context used to store arbitrary values for the duration of a single request.
4
- *
5
- * @summary
6
- * The {@link DecafRequestContext} class provides an isolated per-request key-value cache,
7
- * enabling services and controllers to share state or metadata without relying on global
8
- * or static variables. Keys may be strings or symbols, and cached values may hold any
9
- * serializable or non-serializable object.
10
- *
11
- * @class DecafRequestContext
12
- *
13
- * @example
14
- * ```ts
15
- * // Saving a value in the request context:
16
- * context.set("tenantId", "abc123");
17
- *
18
- * // Retrieving it later in the request lifecycle:
19
- * const tenantId = context.get<string>("tenantId");
20
- * ```
21
- */
22
- export declare class DecafRequestContext {
23
- private cache;
24
- set(key: string | symbol, value: any): void;
25
- get<T = any>(key: string | symbol): T | undefined;
26
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"DecafRequestContext.js","sourceRoot":"","sources":["../../src/request/DecafRequestContext.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAmD;AAEnD;;;;;;;;;;;;;;;;;;;;GAoBG;AAEI,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAAzB;QACG,UAAK,GAAG,IAAI,GAAG,EAAwB,CAAC;IASlD,CAAC;IAPC,GAAG,CAAC,GAAoB,EAAE,KAAU;QAClC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC7B,CAAC;IAED,GAAG,CAAU,GAAoB;QAC/B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;CACF,CAAA;AAVY,kDAAmB;8BAAnB,mBAAmB;IAD/B,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,OAAO,EAAE,CAAC;GACxB,mBAAmB,CAU/B"}
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./DecafRequestContext.cjs"), exports);
18
- __exportStar(require("./DecafHandlerExecutor.cjs"), exports);
19
- //# sourceMappingURL=index.js.map
@@ -1,2 +0,0 @@
1
- export * from "./DecafRequestContext";
2
- export * from "./DecafHandlerExecutor";
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/request/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,4DAAsC;AACtC,6DAAuC"}