1 | import { ContextId, HostComponentInfo } from '../injector/instance-wrapper';
|
2 | export declare function createContextId(): ContextId;
|
3 | export type ContextIdResolverFn = (info: HostComponentInfo) => ContextId;
|
4 | export interface ContextIdResolver {
|
5 | /**
|
6 | * Payload associated with the custom context id
|
7 | */
|
8 | payload: unknown;
|
9 | /**
|
10 | * A context id resolver function
|
11 | */
|
12 | resolve: ContextIdResolverFn;
|
13 | }
|
14 | export interface ContextIdStrategy<T = any> {
|
15 | /**
|
16 | * Allows to attach a parent context id to the existing child context id.
|
17 | * This lets you construct durable DI sub-trees that can be shared between contexts.
|
18 | * @param contextId auto-generated child context id
|
19 | * @param request request object
|
20 | */
|
21 | attach(contextId: ContextId, request: T): ContextIdResolverFn | ContextIdResolver | undefined;
|
22 | }
|
23 | export declare class ContextIdFactory {
|
24 | private static strategy?;
|
25 | /**
|
26 | * Generates a context identifier based on the request object.
|
27 | */
|
28 | static create(): ContextId;
|
29 | /**
|
30 | * Generates a random identifier to track asynchronous execution context.
|
31 | * @param request request object
|
32 | */
|
33 | static getByRequest<T extends Record<any, any> = any>(request: T, propsToInspect?: string[]): ContextId;
|
34 | /**
|
35 | * Registers a custom context id strategy that lets you attach
|
36 | * a parent context id to the existing context id object.
|
37 | * @param strategy strategy instance
|
38 | */
|
39 | static apply(strategy: ContextIdStrategy): void;
|
40 | private static isContextIdResolverWithPayload;
|
41 | }
|