@nest-boot/request-context 7.7.6 → 8.0.0-beta.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.
@@ -1,328 +1,32 @@
1
1
  import { type Type } from "@nestjs/common";
2
- /**
3
- * Middleware function type for request context.
4
- * Middlewares are executed in order when running a request context.
5
- *
6
- * @typeParam T - The return type of the middleware chain
7
- * @param ctx - The current request context
8
- * @param next - Function to call the next middleware in the chain
9
- * @returns A promise resolving to the result of the middleware chain
10
- */
11
2
  export type RequestContextMiddlewareType = <T>(ctx: RequestContext, next: () => Promise<T>) => Promise<T>;
12
- /**
13
- * Options for creating a new RequestContext instance.
14
- */
15
3
  export interface RequestContextCreateOptions {
16
- /**
17
- * Unique identifier for the request context.
18
- * If not provided, a random UUID will be generated.
19
- */
20
4
  id?: string;
21
- /**
22
- * Application-level lifecycle category for this context.
23
- *
24
- * This value does not mirror NestJS `ExecutionContext.getType()`. Contexts
25
- * created by the built-in HTTP request middleware and interceptor use
26
- * `"http"`, including GraphQL resolver executions within a request. Other
27
- * integrations select categories for their lifecycle, such as `"queue"` or
28
- * `"repl"`; callers creating contexts directly may use categories such as
29
- * `"job"`.
30
- */
31
5
  type: string;
32
- /**
33
- * Parent context for creating nested/child contexts.
34
- * Child contexts can access values from parent contexts.
35
- */
36
6
  parent?: RequestContext;
37
7
  }
38
- /**
39
- * RequestContext provides a way to store and access request-scoped data
40
- * throughout the lifecycle of a request using AsyncLocalStorage.
41
- *
42
- * This is useful for storing data like the current user, request ID,
43
- * database transactions, and other request-specific information that
44
- * needs to be accessed across different parts of the application.
45
- *
46
- * @example Basic usage
47
- * ```typescript
48
- * import { RequestContext } from '@nest-boot/request-context';
49
- *
50
- * // Get the current request ID
51
- * const requestId = RequestContext.id;
52
- *
53
- * // Store a value in the context
54
- * RequestContext.set('userId', 123);
55
- *
56
- * // Retrieve a value from the context
57
- * const userId = RequestContext.get<number>('userId');
58
- * ```
59
- *
60
- * @example Running code in a new context
61
- * ```typescript
62
- * await RequestContext.run(
63
- * new RequestContext({ type: 'job' }),
64
- * async (ctx) => {
65
- * ctx.set('jobId', 'abc123');
66
- * await processJob();
67
- * }
68
- * );
69
- * ```
70
- *
71
- * @example Creating a child context
72
- * ```typescript
73
- * await RequestContext.child(async (childCtx) => {
74
- * // Child context inherits values from parent
75
- * // but can have its own values that don't affect parent
76
- * childCtx.set('tempValue', 'only in child');
77
- * });
78
- * ```
79
- */
80
8
  export declare class RequestContext {
81
- /**
82
- * Unique identifier for this request context.
83
- * Automatically generated as a UUID if not provided.
84
- */
85
9
  readonly id: string;
86
- /**
87
- * Application-level lifecycle category for this context.
88
- *
89
- * Contexts created by the built-in HTTP request middleware and interceptor
90
- * use `"http"`. Other integrations may use lifecycle categories such as
91
- * `"queue"` or `"repl"`, and callers may define their own categories. This
92
- * value is independent from the NestJS execution context type.
93
- */
94
10
  readonly type: string;
95
- /**
96
- * Parent context, if this is a child context.
97
- * Values not found in this context will be looked up in the parent.
98
- */
99
11
  readonly parent?: RequestContext;
100
- /** Internal storage map for context values. @internal */
101
12
  private readonly container;
102
- /** Async local storage backing the request context. @internal */
103
13
  private static readonly storage;
104
- /** Registered middleware map keyed by name. @internal */
105
14
  private static readonly middlewares;
106
- /** Dependency graph for middleware ordering. @internal */
107
15
  private static readonly middlewareDependencies;
108
- /** Topologically-sorted middleware execution stack. @internal */
109
16
  private static middlewaresStack;
110
- /** Creates a new RequestContext instance.
111
- * @param options - Options for creating the request context (id, type, parent)
112
- */
113
17
  constructor(options: RequestContextCreateOptions);
114
- /**
115
- * Gets a value from the context by its token.
116
- * If not found in this context, looks up the parent context.
117
- *
118
- * @typeParam T - The expected type of the value
119
- * @param token - The key to look up (string, symbol, function, or class)
120
- * @returns The value if found, otherwise undefined
121
- *
122
- * @example
123
- * ```typescript
124
- * const ctx = RequestContext.current();
125
- * const user = ctx.get<User>('currentUser');
126
- * const service = ctx.get(MyService);
127
- * ```
128
- */
129
18
  get<T>(token: string | symbol | Function | Type<T>): T | undefined;
130
- /**
131
- * Sets a value in the context.
132
- *
133
- * @typeParam T - The type of the value
134
- * @param typeOrToken - The key to store the value under
135
- * @param value - The value to store
136
- *
137
- * @example
138
- * ```typescript
139
- * const ctx = RequestContext.current();
140
- * ctx.set('userId', 123);
141
- * ctx.set(UserService, userServiceInstance);
142
- * ```
143
- */
144
19
  set<T>(typeOrToken: string | symbol | Type<T>, value: T): void;
145
- /**
146
- * Gets a value from the context, or sets it if not present.
147
- *
148
- * @typeParam T - The type of the value
149
- * @param typeOrToken - The key to look up or store under
150
- * @param value - The value to set if not already present
151
- * @returns The existing value or the newly set value
152
- *
153
- * @example
154
- * ```typescript
155
- * const ctx = RequestContext.current();
156
- * const cache = ctx.getOrSet('cache', new Map());
157
- * ```
158
- */
159
20
  getOrSet<T>(typeOrToken: string | symbol | Type<T>, value: T): T;
160
- /**
161
- * Gets a value from the current context by its key.
162
- * Static method that accesses the current context automatically.
163
- *
164
- * @typeParam T - The expected type of the value
165
- * @param key - The key to look up
166
- * @returns The value if found, otherwise undefined
167
- * @throws Error if no request context is active
168
- *
169
- * @example
170
- * ```typescript
171
- * const userId = RequestContext.get<number>('userId');
172
- * ```
173
- */
174
21
  static get<T>(key: string | symbol | Function | Type<T>): T | undefined;
175
- /**
176
- * Sets a value in the current context.
177
- * Static method that accesses the current context automatically.
178
- *
179
- * @typeParam T - The type of the value
180
- * @param key - The key to store the value under
181
- * @param value - The value to store
182
- * @throws Error if no request context is active
183
- *
184
- * @example
185
- * ```typescript
186
- * RequestContext.set('userId', 123);
187
- * ```
188
- */
189
22
  static set<T>(key: string | symbol | Type<T>, value: T): void;
190
- /**
191
- * Gets a value from the current context, or sets it if not present.
192
- * Static method that accesses the current context automatically.
193
- *
194
- * @typeParam T - The type of the value
195
- * @param key - The key to look up or store under
196
- * @param value - The value to set if not already present
197
- * @returns The existing value or the newly set value
198
- * @throws Error if no request context is active
199
- *
200
- * @example
201
- * ```typescript
202
- * const cache = RequestContext.getOrSet('cache', new Map());
203
- * ```
204
- */
205
23
  static getOrSet<T>(key: string | symbol | Type<T>, value: T): T;
206
- /**
207
- * Gets the ID of the current request context.
208
- *
209
- * @returns The unique identifier of the current context
210
- * @throws Error if no request context is active
211
- *
212
- * @example
213
- * ```typescript
214
- * console.log(`Processing request ${RequestContext.id}`);
215
- * ```
216
- */
217
24
  static get id(): string;
218
- /**
219
- * Gets the current request context.
220
- *
221
- * @returns The current RequestContext instance
222
- * @throws Error if no request context is active
223
- *
224
- * @example
225
- * ```typescript
226
- * const ctx = RequestContext.current();
227
- * console.log(ctx.type); // 'http'
228
- * ```
229
- */
230
25
  static current(): RequestContext;
231
- /**
232
- * Checks if a request context is currently active.
233
- *
234
- * @returns true if a context is active, false otherwise
235
- *
236
- * @example
237
- * ```typescript
238
- * if (RequestContext.isActive()) {
239
- * const userId = RequestContext.get('userId');
240
- * }
241
- * ```
242
- */
243
26
  static isActive(): boolean;
244
- /**
245
- * Runs a callback within a request context.
246
- * All registered middlewares are executed before the callback.
247
- *
248
- * @typeParam T - The return type of the callback
249
- * @param ctx - The request context to run within
250
- * @param callback - The function to execute within the context
251
- * @returns A promise resolving to the callback's return value
252
- *
253
- * @example
254
- * ```typescript
255
- * const result = await RequestContext.run(
256
- * new RequestContext({ type: 'job' }),
257
- * async (ctx) => {
258
- * ctx.set('jobId', 'abc123');
259
- * return await processJob();
260
- * }
261
- * );
262
- * ```
263
- */
264
27
  static run<T>(ctx: RequestContext, callback: (ctx: RequestContext) => T | Promise<T>): Promise<T>;
265
- /**
266
- * Creates and runs a child context that inherits from the current context.
267
- * Child contexts can read values from parent contexts but modifications
268
- * are isolated to the child.
269
- *
270
- * @typeParam T - The return type of the callback
271
- * @param callback - The function to execute within the child context
272
- * @returns A promise resolving to the callback's return value
273
- * @throws Error if no request context is active
274
- *
275
- * @example
276
- * ```typescript
277
- * // In parent context
278
- * RequestContext.set('userId', 123);
279
- *
280
- * await RequestContext.child(async (childCtx) => {
281
- * // Can read parent values
282
- * const userId = childCtx.get('userId'); // 123
283
- *
284
- * // Child-only values don't affect parent
285
- * childCtx.set('tempData', 'child only');
286
- * });
287
- *
288
- * // Parent context unchanged
289
- * RequestContext.get('tempData'); // undefined
290
- * ```
291
- */
292
28
  static child<T>(callback: (ctx: RequestContext) => T | Promise<T>): Promise<T>;
293
- /**
294
- * Registers a middleware to be executed when running a request context.
295
- * Middlewares are executed in dependency order.
296
- *
297
- * @param name - Unique name for the middleware
298
- * @param middleware - The middleware function to register
299
- * @param dependencies - Names of middlewares that must run before this one
300
- *
301
- * @example
302
- * ```typescript
303
- * RequestContext.registerMiddleware(
304
- * 'auth',
305
- * async (ctx, next) => {
306
- * ctx.set('user', await loadUser());
307
- * return next();
308
- * }
309
- * );
310
- *
311
- * // Middleware with dependencies
312
- * RequestContext.registerMiddleware(
313
- * 'permissions',
314
- * async (ctx, next) => {
315
- * const user = ctx.get('user');
316
- * ctx.set('permissions', await loadPermissions(user));
317
- * return next();
318
- * },
319
- * ['auth'] // Runs after 'auth' middleware
320
- * );
321
- * ```
322
- */
323
29
  static registerMiddleware(name: string, middleware: RequestContextMiddlewareType, dependencies?: string[]): void;
324
- /** Resolves middleware dependencies via topological sort. @internal */
325
30
  private static resolveDependencies;
326
- /** Rebuilds the middleware execution stack after registration changes. @internal */
327
31
  private static generateMiddlewaresStack;
328
32
  }
@@ -1,38 +1,5 @@
1
1
  import { type CallHandler, type ExecutionContext, type NestInterceptor } from "@nestjs/common";
2
2
  import { Observable } from "rxjs";
3
- /**
4
- * NestJS interceptor that creates request context for HTTP and GraphQL requests.
5
- *
6
- * This interceptor serves as a fallback for cases where the middleware doesn't
7
- * run (e.g., GraphQL resolvers). It:
8
- * - Creates a new RequestContext if one doesn't already exist
9
- * - Uses the `x-request-id` header as the context ID if provided
10
- * - Supports both HTTP and GraphQL execution contexts
11
- * - Categorizes fallback contexts as `"http"` to match contexts created by
12
- * the request middleware; NestJS may still report the resolver execution
13
- * context type as `"graphql"`
14
- *
15
- * The interceptor is automatically registered by RequestContextModule.
16
- *
17
- * @example
18
- * The interceptor is typically used automatically, but can be applied manually:
19
- * ```typescript
20
- * import { Controller, UseInterceptors } from '@nestjs/common';
21
- * import { RequestContextInterceptor } from '@nest-boot/request-context';
22
- *
23
- * @Controller()
24
- * @UseInterceptors(RequestContextInterceptor)
25
- * export class MyController {}
26
- * ```
27
- */
28
3
  export declare class RequestContextInterceptor implements NestInterceptor {
29
- /**
30
- * Intercepts the request and wraps execution in a request context.
31
- *
32
- * @typeParam T - The type of the response
33
- * @param executionContext - The NestJS execution context
34
- * @param next - The call handler for the next interceptor or handler
35
- * @returns An observable of the response
36
- */
37
4
  intercept<T>(executionContext: ExecutionContext, next: CallHandler<T>): Observable<T>;
38
5
  }
@@ -1,61 +1,25 @@
1
- "use strict";
2
1
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
2
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
3
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
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;
6
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
7
6
  };
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.RequestContextInterceptor = void 0;
10
- const common_1 = require("@nestjs/common");
11
- const rxjs_1 = require("rxjs");
12
- const request_context_1 = require("./request-context");
13
- /**
14
- * NestJS interceptor that creates request context for HTTP and GraphQL requests.
15
- *
16
- * This interceptor serves as a fallback for cases where the middleware doesn't
17
- * run (e.g., GraphQL resolvers). It:
18
- * - Creates a new RequestContext if one doesn't already exist
19
- * - Uses the `x-request-id` header as the context ID if provided
20
- * - Supports both HTTP and GraphQL execution contexts
21
- * - Categorizes fallback contexts as `"http"` to match contexts created by
22
- * the request middleware; NestJS may still report the resolver execution
23
- * context type as `"graphql"`
24
- *
25
- * The interceptor is automatically registered by RequestContextModule.
26
- *
27
- * @example
28
- * The interceptor is typically used automatically, but can be applied manually:
29
- * ```typescript
30
- * import { Controller, UseInterceptors } from '@nestjs/common';
31
- * import { RequestContextInterceptor } from '@nest-boot/request-context';
32
- *
33
- * @Controller()
34
- * @UseInterceptors(RequestContextInterceptor)
35
- * export class MyController {}
36
- * ```
37
- */
7
+ import { Injectable, } from "@nestjs/common";
8
+ import { Observable } from "rxjs";
9
+ import { RequestContext } from "./request-context.js";
38
10
  let RequestContextInterceptor = class RequestContextInterceptor {
39
- /**
40
- * Intercepts the request and wraps execution in a request context.
41
- *
42
- * @typeParam T - The type of the response
43
- * @param executionContext - The NestJS execution context
44
- * @param next - The call handler for the next interceptor or handler
45
- * @returns An observable of the response
46
- */
47
11
  intercept(executionContext, next) {
48
- if (request_context_1.RequestContext.isActive() ||
12
+ if (RequestContext.isActive() ||
49
13
  !["http", "graphql"].includes(executionContext.getType())) {
50
14
  return next.handle();
51
15
  }
52
16
  const id = (executionContext.switchToHttp().getRequest() ??
53
17
  executionContext.getArgByIndex(2).req)?.get?.("x-request-id");
54
- const ctx = new request_context_1.RequestContext({
18
+ const ctx = new RequestContext({
55
19
  id,
56
20
  type: "http",
57
21
  });
58
- return new rxjs_1.Observable((subscriber) => {
22
+ return new Observable((subscriber) => {
59
23
  let resolveTermination;
60
24
  let rejectTermination;
61
25
  let terminated = false;
@@ -69,14 +33,12 @@ let RequestContextInterceptor = class RequestContextInterceptor {
69
33
  rejectTermination = (reason) => {
70
34
  if (!terminated) {
71
35
  terminated = true;
72
- // RxJS permits arbitrary error values and they must be forwarded intact.
73
- // eslint-disable-next-line @typescript-eslint/prefer-promise-reject-errors
74
36
  reject(reason);
75
37
  }
76
38
  };
77
39
  });
78
40
  let subscribeToSource;
79
- const sourceSubscription = new rxjs_1.Observable((sourceSubscriber) => {
41
+ const sourceSubscription = new Observable((sourceSubscriber) => {
80
42
  subscribeToSource = (source) => {
81
43
  source.subscribe(sourceSubscriber);
82
44
  };
@@ -93,7 +55,7 @@ let RequestContextInterceptor = class RequestContextInterceptor {
93
55
  });
94
56
  subscriber.add(sourceSubscription);
95
57
  subscriber.add(resolveTermination);
96
- void request_context_1.RequestContext.run(ctx, async () => {
58
+ void RequestContext.run(ctx, async () => {
97
59
  if (subscriber.closed) {
98
60
  return;
99
61
  }
@@ -119,8 +81,8 @@ let RequestContextInterceptor = class RequestContextInterceptor {
119
81
  });
120
82
  }
121
83
  };
122
- exports.RequestContextInterceptor = RequestContextInterceptor;
123
- exports.RequestContextInterceptor = RequestContextInterceptor = __decorate([
124
- (0, common_1.Injectable)()
84
+ RequestContextInterceptor = __decorate([
85
+ Injectable()
125
86
  ], RequestContextInterceptor);
87
+ export { RequestContextInterceptor };
126
88
  //# sourceMappingURL=request-context.interceptor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"request-context.interceptor.js","sourceRoot":"","sources":["../src/request-context.interceptor.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAKwB;AAExB,+BAAkC;AAElC,uDAAmD;AAEnD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEI,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;IACpC;;;;;;;OAOG;IACH,SAAS,CACP,gBAAkC,EAClC,IAAoB;QAEpB,IACE,gCAAc,CAAC,QAAQ,EAAE;YACzB,CAAC,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,EACzD,CAAC;YACD,OAAO,IAAI,CAAC,MAAM,EAAE,CAAC;QACvB,CAAC;QAED,MAAM,EAAE,GAAG,CACT,gBAAgB,CAAC,YAAY,EAAE,CAAC,UAAU,EAAW;YACrD,gBAAgB,CAAC,aAAa,CAAmB,CAAC,CAAC,CAAC,GAAG,CACxD,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,CAAC;QAEzB,MAAM,GAAG,GAAG,IAAI,gCAAc,CAAC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GAAG,CAAC,kBAAkB,CAAC,CAAC;YACnC,UAAU,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;YAEnC,KAAK,gCAAc,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,IAAI,EAAE;gBACtC,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;oBACtB,OAAO;gBACT,CAAC;gBAED,IAAI,CAAC;oBACH,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;oBAC7B,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;wBACvB,iBAAiB,CAAC,MAAM,CAAC,CAAC;oBAC5B,CAAC;gBACH,CAAC;gBAAC,OAAO,GAAG,EAAE,CAAC;oBACb,iBAAiB,CAAC,GAAG,CAAC,CAAC;gBACzB,CAAC;gBAED,MAAM,WAAW,CAAC;YACpB,CAAC,CAAC,CAAC,IAAI,CACL,GAAG,EAAE;gBACH,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;oBACvB,UAAU,CAAC,QAAQ,EAAE,CAAC;gBACxB,CAAC;YACH,CAAC,EACD,CAAC,GAAY,EAAE,EAAE;gBACf,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC;oBACvB,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;gBACxB,CAAC;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AAnGY,8DAAyB;oCAAzB,yBAAyB;IADrC,IAAA,mBAAU,GAAE;GACA,yBAAyB,CAmGrC"}
1
+ {"version":3,"file":"request-context.interceptor.js","sourceRoot":"","sources":["../src/request-context.interceptor.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAGL,UAAU,GAEX,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AA4B/C,IAAM,yBAAyB,GAA/B,MAAM,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