Skip to content

Commit df69e89

Browse files
committed
Types.
1 parent 1e7ef3e commit df69e89

File tree

4 files changed

+66
-48
lines changed

4 files changed

+66
-48
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
## 3.0.1 (February 12, 2021)
4+
5+
- Better `types.d`.
6+
37
## 3.0.0 (January 03, 2021)
48

59
- Introduces `AsyncLocaleStorage` based implementation for node `12.7.0` and above.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-execution-context",
3-
"version": "3.0.0",
3+
"version": "3.0.1",
44
"description": "Provides execution context wrapper for node JS, can be used to create execution wrapper for handling requests and more",
55
"author": "Oded Goldglas <odedglas@gmail.com>",
66
"license": "ISC",
@@ -10,6 +10,7 @@
1010
},
1111
"homepage": "https://github.com/odedglas/node-execution-context",
1212
"main": "dist/index.js",
13+
"types": "src/types.d.ts",
1314
"scripts": {
1415
"test": "jest -c configuration/jest.config.js",
1516
"lint": "eslint .",

src/ExecutionContext/types.d.ts

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,52 +15,8 @@ interface ExecutionContextConfig {
1515
monitor: boolean;
1616
}
1717

18-
interface ExecutionContextAPI {
19-
20-
/**
21-
* Creates a given context for the current asynchronous execution.
22-
* Note that if this method will be called not within a AsyncResource context, it will effect current execution context.
23-
* @param context - The context to expose.
24-
*/
25-
create(context: unknown): void;
26-
27-
/**
28-
* Sets the current asynchronous execution context to given value.
29-
* @param context - The new context to expose current asynchronous execution.
30-
*/
31-
set(context: unknown): void;
32-
33-
/**
34-
* Gets the current asynchronous execution context.
35-
*/
36-
get<T>(): T;
37-
38-
/**
39-
* Runs given callback that will be exposed to the given context.
40-
* This will expose the given context within all callbacks and promise chains that will be called from given fn.
41-
* @param fn - The function to run.
42-
* @param context - The context to expose.
43-
*/
44-
run(fn: Function, context: unknown): unknown;
45-
46-
/**
47-
* Configures current execution context manager.
48-
* [Note] Relevant for node v12.17.0 and below
49-
* @param config - the configuration to use.
50-
*/
51-
config(config: ExecutionContextConfig): void;
52-
53-
/**
54-
* Monitors current execution map usage
55-
* [Note] Relevant for node v12.17.0 and below
56-
* @return {ExecutionMapUsage|undefined}
57-
*/
58-
monitor(): ExecutionMapUsage|undefined;
59-
}
60-
6118
export {
6219
ExecutionContextNode,
6320
ExecutionContextMap,
64-
ExecutionContextAPI,
6521
ExecutionContextConfig
6622
}

src/types.d.ts

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,60 @@
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

Comments
 (0)