1- export * from './lib/types' ;
2- export * from './managers/asyncHooks/hooks/types' ;
3- export * from './ExecutionContext/types' ;
1+ import { ExecutionMapUsage , ExecutionMapUsageEntry } from './lib/types' ;
2+ import { HookCallbacks } from './managers/asyncHooks/hooks/types' ;
3+ import { ExecutionContextConfig , ExecutionContextNode , ExecutionContextMap } from './ExecutionContext/types' ;
4+
5+ interface ExecutionContextAPI {
6+
7+ /**
8+ * Creates a given context for the current asynchronous execution.
9+ * Note that if this method will be called not within a AsyncResource context, it will effect current execution context.
10+ * @param context - The context to expose.
11+ */
12+ create ( context : unknown ) : void ;
13+
14+ /**
15+ * Sets the current asynchronous execution context to given value.
16+ * @param context - The new context to expose current asynchronous execution.
17+ */
18+ set ( context : unknown ) : void ;
19+
20+ /**
21+ * Gets the current asynchronous execution context.
22+ */
23+ get < T > ( ) : T ;
24+
25+ /**
26+ * Runs given callback that will be exposed to the given context.
27+ * This will expose the given context within all callbacks and promise chains that will be called from given fn.
28+ * @param fn - The function to run.
29+ * @param context - The context to expose.
30+ */
31+ run < T > ( fn : ( ) => T , context : unknown ) : T ;
32+
33+ /**
34+ * Configures current execution context manager.
35+ * [Note] Relevant for node v12.17.0 and below
36+ * @param config - the configuration to use.
37+ */
38+ config ( config : ExecutionContextConfig ) : void ;
39+
40+ /**
41+ * Monitors current execution map usage
42+ * [Note] Relevant for node v12.17.0 and below
43+ * @return {ExecutionMapUsage|undefined }
44+ */
45+ monitor ( ) : ExecutionMapUsage | undefined ;
46+ }
47+
48+ declare const context : ExecutionContextAPI ;
49+
50+ export {
51+ HookCallbacks ,
52+ ExecutionMapUsageEntry ,
53+ ExecutionMapUsage ,
54+ ExecutionContextMap ,
55+ ExecutionContextNode ,
56+ ExecutionContextConfig ,
57+ ExecutionContextAPI
58+ } ;
59+
60+ export default context ;
0 commit comments