readiness-manager 1.1.1 → 1.1.4
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.
- package/CHANGELOG.md +19 -2
- package/package.json +1 -1
- package/src/index.js +1 -1
- package/src/types.d.ts +40 -0
- package/tests/mock.d.ts +9 -0
- package/src/type.d.ts +0 -36
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
# CHANGELOG
|
|
2
2
|
|
|
3
|
-
## 1.1.
|
|
3
|
+
## 1.1.4 (7 April 2022)
|
|
4
|
+
|
|
5
|
+
- Fix beacon initial execution, attempt was passed as index of the `forEach`.
|
|
6
|
+
|
|
7
|
+
## 1.1.3 (2 August 2021)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- Fix `test/mocks` manager types.
|
|
12
|
+
|
|
13
|
+
## 1.1.2 (1 August 2021)
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- Align `package.json` `types` entry.
|
|
18
|
+
- Fix `ReadinessManager` interface declaration.
|
|
19
|
+
|
|
20
|
+
## 1.1.1 (2 March 2021)
|
|
4
21
|
|
|
5
22
|
### Bug Fixes
|
|
6
23
|
|
|
@@ -16,4 +33,4 @@
|
|
|
16
33
|
|
|
17
34
|
### Improvements
|
|
18
35
|
|
|
19
|
-
- Adding `chain` option to manager api methods.
|
|
36
|
+
- Adding `chain` option to manager api methods.
|
package/package.json
CHANGED
package/src/index.js
CHANGED
package/src/types.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
type ReadyCallback = () => void;
|
|
2
|
+
type ReadyAction = () => unknown | Promise<unknown>;
|
|
3
|
+
type ActionRetry = () => Promise<unknown>;
|
|
4
|
+
type ActionStatus = 'not_started' | 'pending' | 'resolved' | 'rejected';
|
|
5
|
+
|
|
6
|
+
interface Beacon {
|
|
7
|
+
name: string;
|
|
8
|
+
action: ReadyAction;
|
|
9
|
+
status: ActionStatus;
|
|
10
|
+
callbacks: ReadyCallback[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
type BeaconsMap = { [name: string] : Beacon };
|
|
14
|
+
|
|
15
|
+
export interface ActionExecutionError extends Error {
|
|
16
|
+
name: string;
|
|
17
|
+
stack: string;
|
|
18
|
+
attempt: number;
|
|
19
|
+
failReason: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type ActionErrorHandler = (error: ActionExecutionError, retry: ActionRetry) => void;
|
|
23
|
+
|
|
24
|
+
export type ActionsStatus = {
|
|
25
|
+
[status in ActionStatus]: string[];
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export interface ReadinessManager {
|
|
29
|
+
register: (name: string, action: ReadyAction) => void;
|
|
30
|
+
run: () => ReadinessManager;
|
|
31
|
+
onReady:(callback: ReadyCallback) => ReadinessManager;
|
|
32
|
+
onActionReady:(name: string, callback: ReadyCallback) => ReadinessManager;
|
|
33
|
+
onError:(errorHandler: ActionErrorHandler) => ReadinessManager;
|
|
34
|
+
status:() => ActionsStatus;
|
|
35
|
+
ready: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
declare const manager: ReadinessManager;
|
|
39
|
+
|
|
40
|
+
export default manager;
|
package/tests/mock.d.ts
ADDED
package/src/type.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
type ReadyCallback = () => void;
|
|
2
|
-
type ReadyAction = () => void|Promise<void>;
|
|
3
|
-
type ActionRetry = () => Promise<void>;
|
|
4
|
-
type ActionStatus = 'not_started' | 'pending' | 'resolved' | 'rejected';
|
|
5
|
-
|
|
6
|
-
interface Beacon {
|
|
7
|
-
name: string;
|
|
8
|
-
action: ReadyAction;
|
|
9
|
-
status: ActionStatus;
|
|
10
|
-
callbacks: ReadyCallback[];
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
type BeaconsMap = { [name: string] : Beacon };
|
|
14
|
-
|
|
15
|
-
interface ActionExecutionError extends Error {
|
|
16
|
-
name: string;
|
|
17
|
-
stack: string;
|
|
18
|
-
attempt: number;
|
|
19
|
-
failReason: string;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type ActionErrorHandler = (error: ActionExecutionError, retry: ActionRetry) => void;
|
|
23
|
-
|
|
24
|
-
type ActionsStatus = {
|
|
25
|
-
[status in ActionStatus]: string[];
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
interface ReadinessManager {
|
|
29
|
-
register: (name: string, action: ReadyAction) => void;
|
|
30
|
-
run: () => void;
|
|
31
|
-
onReady:(callback: ReadyCallback) => void;
|
|
32
|
-
onActionReady:(name: string, callback: ReadyCallback) => void;
|
|
33
|
-
onError:(errorHandler: ActionErrorHandler) => void;
|
|
34
|
-
status:() => ActionsStatus;
|
|
35
|
-
ready: boolean;
|
|
36
|
-
}
|