readiness-manager 1.2.0-rc.xf50ab1c7f → 1.2.0
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/README.md +2 -83
- package/dist/src/error.d.ts.map +1 -1
- package/dist/src/error.js.map +1 -1
- package/dist/src/index.d.ts +1 -5
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +63 -57
- package/dist/src/index.js.map +1 -1
- package/dist/src/types.d.ts +17 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- package/dist/tests/mock.d.ts.map +1 -1
- package/dist/tests/mock.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/error.ts +8 -0
- package/src/index.ts +54 -68
- package/src/spec.ts +10 -17
- package/src/types.ts +38 -0
- package/tests/mock.ts +3 -2
- package/dist/src/constants.d.ts +0 -3
- package/dist/src/constants.d.ts.map +0 -1
- package/dist/src/constants.js +0 -10
- package/dist/src/constants.js.map +0 -1
- package/src/constants.ts +0 -11
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
Controlling node application readiness state.
|
|
2
|
-
|
|
3
1
|
## Motivation
|
|
4
2
|
|
|
5
3
|
In many cases node application depends on external resources that should be available before truly starting up.
|
|
@@ -39,91 +37,12 @@ if (ReadinessManager.ready) {
|
|
|
39
37
|
}
|
|
40
38
|
```
|
|
41
39
|
|
|
42
|
-
##
|
|
43
|
-
|
|
44
|
-
### ready: boolean
|
|
45
|
-
|
|
46
|
-
Returns `true` if all the registered actions has been ran without exceptions/rejections.
|
|
47
|
-
|
|
48
|
-
### register(name: string, action: ReadyAction, debug?: boolean): void
|
|
49
|
-
|
|
50
|
-
Registers a given name and action under `ReadinessManager`, registered actions will be observed once ran in order to determine the process readiness state.
|
|
51
|
-
|
|
52
|
-
```ts
|
|
53
|
-
type ReadyAction = () => void | Promise<void>;
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
**Parameters:**
|
|
57
|
-
|
|
58
|
-
- `name` - Unique identifier for the action
|
|
59
|
-
- `action` - Function to execute (sync or async)
|
|
60
|
-
- `debug` - Optional flag to enable timing logs (default: `false`)
|
|
61
|
-
|
|
62
|
-
**Debug Mode:**
|
|
63
|
-
When `debug` is set to `true`, the manager will log the execution time for the action:
|
|
64
|
-
|
|
65
|
-
```js
|
|
66
|
-
ReadinessManager.register('database', () => connectToDB(), true);
|
|
67
|
-
// Logs: [ReadinessManager] Action "database" completed in 245ms
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
### run(): void
|
|
71
|
-
|
|
72
|
-
Runs all registered actions, once all actions are resolved successfully your'e app state will be determined as `ready`.
|
|
73
|
-
|
|
74
|
-
### onReady(callback: ReadyCallback): void
|
|
75
|
-
|
|
76
|
-
Registers a given callback on the global manager ready event.
|
|
77
|
-
|
|
78
|
-
```ts
|
|
79
|
-
type ReadyCallback = () => void;
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### onActionReady(name: string callback: ReadyCallback): void
|
|
83
|
-
|
|
84
|
-
```ts
|
|
85
|
-
type ReadyCallback = () => void;
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
Registers a given callback on a specific action completion event.
|
|
89
|
-
|
|
90
|
-
### onError(errorHandler: ActionErrorHandler): void
|
|
91
|
-
|
|
92
|
-
```ts
|
|
93
|
-
interface ActionExecutionError extends Error {
|
|
94
|
-
name: string;
|
|
95
|
-
stack: string;
|
|
96
|
-
attempt: number;
|
|
97
|
-
failReason: string;
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
type ActionRetry = () => Promise<void>;
|
|
101
|
-
|
|
102
|
-
type ActionErrorHandler = (error: ActionExecutionError, retry: ActionRetry) => void;
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
Registers given error handler under the `ReadinessManager`. Any error that will be thrown from execution one of the registered actions will trigger this handler.
|
|
106
|
-
|
|
107
|
-
> You can use the `retry` method provided to your error handler according to any failure strategy you like.
|
|
108
|
-
|
|
109
|
-
### status(): ActionsStatus
|
|
110
|
-
|
|
111
|
-
Returns a status report for current registered actions.
|
|
112
|
-
|
|
113
|
-
```ts
|
|
114
|
-
type ActionsStatus = {
|
|
115
|
-
[status in ActionStatus]: string[];
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
type ActionStatus = 'not_started' | 'pending' | 'resolved' | 'rejected';
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
### Errors handling
|
|
40
|
+
## Errors handling
|
|
122
41
|
|
|
123
42
|
You can register an error handler over the manager, which will be triggered from any thrown error from it's registered actions.
|
|
124
43
|
Once an error rises, the manager will trigger the error handler with both occurred error and a `retry` method used to re-execute the failing action if desired.
|
|
125
44
|
|
|
126
|
-
> The default error handle will just log errors to console and thus strongly recommended to register your
|
|
45
|
+
> The default error handle will just log errors to console and thus strongly recommended to register your own handler.
|
|
127
46
|
|
|
128
47
|
```js
|
|
129
48
|
// app.index.js
|
package/dist/src/error.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM;;;;CAKT,CAAC;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,MAAM;;;;CAKT,CAAC;AAMX,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;AAKjD,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,oBAAoB,EAAE,KAAK,EAAE,WAAW,KAAK,IAAI,CAAC;AAK3F,qBAAa,oBAAqB,SAAQ,KAAK;IAClC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;gBAEP,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK;CAS1D;AAKD,eAAO,MAAM,mBAAmB,EAAE,kBAA+D,CAAC"}
|
package/dist/src/error.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAIhC,QAAA,MAAM,GAAG;IAClB,qBAAqB,EAAE,yEAAyE;IAChG,sBAAsB,EAClB,8FAA8F;IAClG,uBAAuB,EAAE,yBAAyB;CAC5C,CAAC;
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":";;;AAAA,6CAA6C;AAIhC,QAAA,MAAM,GAAG;IAClB,qBAAqB,EAAE,yEAAyE;IAChG,sBAAsB,EAClB,8FAA8F;IAClG,uBAAuB,EAAE,yBAAyB;CAC5C,CAAC;AAgBX,MAAa,oBAAqB,SAAQ,KAAK;IAM3C,YAAY,IAAY,EAAE,OAAe,EAAE,KAAY;QACnD,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,OAAO,GAAG,cAAM,CAAC,uBAAuB,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC;IACpC,CAAC;CACJ;AAfD,oDAeC;AAKM,MAAM,mBAAmB,GAAuB,CAAC,WAAW,EAAE,EAAE,CAAC,YAAM,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;AAArF,QAAA,mBAAmB,uBAAkE"}
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
import { ActionExecutionError, ActionErrorHandler } from './error';
|
|
2
|
-
|
|
3
|
-
export type ReadyAction = () => unknown | Promise<unknown>;
|
|
4
|
-
export interface ActionsStatus {
|
|
5
|
-
[status: string]: string[];
|
|
6
|
-
}
|
|
2
|
+
import type { ReadyAction, ReadyCallback, ActionsStatus } from './types';
|
|
7
3
|
export interface ReadinessManager {
|
|
8
4
|
register: (name: string, action: ReadyAction, debug?: boolean) => void;
|
|
9
5
|
run: () => ReadinessManager;
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,oBAAoB,EAAuB,kBAAkB,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAU,oBAAoB,EAAuB,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAChG,OAAO,KAAK,EAAgB,WAAW,EAAE,aAAa,EAAE,aAAa,EAAsB,MAAM,SAAS,CAAC;AAO3G,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;IACvE,GAAG,EAAE,MAAM,gBAAgB,CAAC;IAC5B,OAAO,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,gBAAgB,CAAC;IACvD,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,KAAK,gBAAgB,CAAC;IAC3E,OAAO,EAAE,CAAC,YAAY,EAAE,kBAAkB,KAAK,gBAAgB,CAAC;IAChE,MAAM,EAAE,MAAM,aAAa,CAAC;IAC5B,KAAK,EAAE,OAAO,CAAC;CAClB;AAiND,QAAA,MAAM,OAAO,EAAE,gBAA6C,CAAC;AAE7D,eAAe,OAAO,CAAC;AACvB,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,CAAC"}
|
package/dist/src/index.js
CHANGED
|
@@ -1,29 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _ReadinessManagerImpl_instances, _ReadinessManagerImpl_beacons, _ReadinessManagerImpl_callbacks, _ReadinessManagerImpl_errorHandler, _ReadinessManagerImpl_execute, _ReadinessManagerImpl_updateBeacon, _ReadinessManagerImpl_trackBeaconUpdate;
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
15
|
exports.ActionExecutionError = void 0;
|
|
4
16
|
const obs_1 = require("@fiverr-private/obs");
|
|
5
17
|
const error_1 = require("./error");
|
|
6
18
|
Object.defineProperty(exports, "ActionExecutionError", { enumerable: true, get: function () { return error_1.ActionExecutionError; } });
|
|
7
|
-
const constants_1 = require("./constants");
|
|
8
|
-
const beaconsSymbol = Symbol('beacons');
|
|
9
|
-
const callbacksSymbol = Symbol('callbacks');
|
|
10
|
-
const executeSymbol = Symbol('execute');
|
|
11
|
-
const trackBeaconUpdateSymbol = Symbol('trackBeaconUpdate');
|
|
12
|
-
const updateBeaconSymbol = Symbol('updateBeacon');
|
|
13
|
-
const errorHandlerSymbol = Symbol('errorHandler');
|
|
14
19
|
let readyState = false;
|
|
15
20
|
class ReadinessManagerImpl {
|
|
16
21
|
constructor() {
|
|
17
|
-
this
|
|
18
|
-
this
|
|
19
|
-
this
|
|
20
|
-
this
|
|
22
|
+
_ReadinessManagerImpl_instances.add(this);
|
|
23
|
+
_ReadinessManagerImpl_beacons.set(this, void 0);
|
|
24
|
+
_ReadinessManagerImpl_callbacks.set(this, void 0);
|
|
25
|
+
_ReadinessManagerImpl_errorHandler.set(this, void 0);
|
|
26
|
+
__classPrivateFieldSet(this, _ReadinessManagerImpl_beacons, {}, "f");
|
|
27
|
+
__classPrivateFieldSet(this, _ReadinessManagerImpl_callbacks, [], "f");
|
|
28
|
+
__classPrivateFieldSet(this, _ReadinessManagerImpl_errorHandler, error_1.defaultErrorHandler, "f");
|
|
21
29
|
}
|
|
22
30
|
get ready() {
|
|
23
31
|
return readyState;
|
|
24
32
|
}
|
|
25
33
|
status() {
|
|
26
|
-
return Object.values(this
|
|
34
|
+
return Object.values(__classPrivateFieldGet(this, _ReadinessManagerImpl_beacons, "f")).reduce((acc, { name, status }) => {
|
|
27
35
|
const current = acc[status] || [];
|
|
28
36
|
return Object.assign(acc, { [status]: [...current, name] });
|
|
29
37
|
}, {});
|
|
@@ -32,21 +40,21 @@ class ReadinessManagerImpl {
|
|
|
32
40
|
if (this.ready) {
|
|
33
41
|
return;
|
|
34
42
|
}
|
|
35
|
-
if (this[
|
|
43
|
+
if (__classPrivateFieldGet(this, _ReadinessManagerImpl_beacons, "f")[name]) {
|
|
36
44
|
throw new Error(error_1.ERRORS.BEACON_ALREADY_EXISTS);
|
|
37
45
|
}
|
|
38
46
|
const beacon = {
|
|
39
47
|
name,
|
|
40
48
|
action,
|
|
41
49
|
callbacks: [],
|
|
42
|
-
status:
|
|
50
|
+
status: 'not_started',
|
|
43
51
|
debug,
|
|
44
52
|
};
|
|
45
|
-
Object.assign(this
|
|
53
|
+
Object.assign(__classPrivateFieldGet(this, _ReadinessManagerImpl_beacons, "f"), { [name]: beacon });
|
|
46
54
|
}
|
|
47
55
|
run() {
|
|
48
56
|
readyState = false;
|
|
49
|
-
Object.values(this
|
|
57
|
+
Object.values(__classPrivateFieldGet(this, _ReadinessManagerImpl_beacons, "f")).forEach((beacon) => __classPrivateFieldGet(this, _ReadinessManagerImpl_instances, "m", _ReadinessManagerImpl_execute).call(this, beacon));
|
|
50
58
|
return this;
|
|
51
59
|
}
|
|
52
60
|
onReady(callback) {
|
|
@@ -54,67 +62,65 @@ class ReadinessManagerImpl {
|
|
|
54
62
|
callback();
|
|
55
63
|
return this;
|
|
56
64
|
}
|
|
57
|
-
this
|
|
65
|
+
__classPrivateFieldGet(this, _ReadinessManagerImpl_callbacks, "f").push(callback);
|
|
58
66
|
return this;
|
|
59
67
|
}
|
|
60
68
|
onActionReady(name, callback) {
|
|
61
|
-
const beacon = this[
|
|
69
|
+
const beacon = __classPrivateFieldGet(this, _ReadinessManagerImpl_beacons, "f")[name];
|
|
62
70
|
if (!beacon) {
|
|
63
71
|
throw new Error(error_1.ERRORS.BEACON_DOES_NOT_EXISTS);
|
|
64
72
|
}
|
|
65
|
-
if (beacon.status ===
|
|
73
|
+
if (beacon.status === 'resolved') {
|
|
66
74
|
callback();
|
|
67
75
|
return this;
|
|
68
76
|
}
|
|
69
|
-
this[
|
|
77
|
+
__classPrivateFieldGet(this, _ReadinessManagerImpl_beacons, "f")[name].callbacks.push(callback);
|
|
70
78
|
return this;
|
|
71
79
|
}
|
|
72
80
|
onError(errorHandler) {
|
|
73
|
-
this
|
|
81
|
+
__classPrivateFieldSet(this, _ReadinessManagerImpl_errorHandler, errorHandler, "f");
|
|
74
82
|
return this;
|
|
75
83
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
if (debug && startTime !== null) {
|
|
87
|
-
const duration = Date.now() - startTime;
|
|
88
|
-
obs_1.logger.debug(`[ReadinessManager] Action "${name}" completed in ${duration}ms`);
|
|
89
|
-
}
|
|
90
|
-
update(constants_1.BeaconStatus.RESOLVED);
|
|
84
|
+
}
|
|
85
|
+
_ReadinessManagerImpl_beacons = new WeakMap(), _ReadinessManagerImpl_callbacks = new WeakMap(), _ReadinessManagerImpl_errorHandler = new WeakMap(), _ReadinessManagerImpl_instances = new WeakSet(), _ReadinessManagerImpl_execute = async function _ReadinessManagerImpl_execute(beacon, attempt = 1) {
|
|
86
|
+
const { name, action, debug } = beacon;
|
|
87
|
+
const update = (status) => __classPrivateFieldGet(this, _ReadinessManagerImpl_instances, "m", _ReadinessManagerImpl_updateBeacon).call(this, name, status);
|
|
88
|
+
update('pending');
|
|
89
|
+
const startTime = debug ? Date.now() : null;
|
|
90
|
+
try {
|
|
91
|
+
const result = action();
|
|
92
|
+
if (result instanceof Promise) {
|
|
93
|
+
await result;
|
|
91
94
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
obs_1.logger.debug(`[ReadinessManager] Action "${name}" failed after ${duration}ms`);
|
|
96
|
-
}
|
|
97
|
-
update(constants_1.BeaconStatus.REJECTED);
|
|
98
|
-
this[errorHandlerSymbol](new error_1.ActionExecutionError(name, attempt, error), () => this[executeSymbol](beacon, attempt + 1));
|
|
95
|
+
if (debug && startTime !== null) {
|
|
96
|
+
const duration = Date.now() - startTime;
|
|
97
|
+
obs_1.logger.debug(`[ReadinessManager] Action "${name}" completed in ${duration}ms`);
|
|
99
98
|
}
|
|
99
|
+
update('resolved');
|
|
100
100
|
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (debug && startTime !== null) {
|
|
103
|
+
const duration = Date.now() - startTime;
|
|
104
|
+
obs_1.logger.debug(`[ReadinessManager] Action "${name}" failed after ${duration}ms`);
|
|
105
105
|
}
|
|
106
|
-
|
|
106
|
+
update('rejected');
|
|
107
|
+
__classPrivateFieldGet(this, _ReadinessManagerImpl_errorHandler, "f").call(this, new error_1.ActionExecutionError(name, attempt, error), () => __classPrivateFieldGet(this, _ReadinessManagerImpl_instances, "m", _ReadinessManagerImpl_execute).call(this, beacon, attempt + 1));
|
|
107
108
|
}
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
readyState = Object.values(this[beaconsSymbol]).every((beacon) => beacon.status === constants_1.BeaconStatus.RESOLVED);
|
|
113
|
-
if (readyState) {
|
|
114
|
-
this[callbacksSymbol].forEach((callback) => callback());
|
|
115
|
-
}
|
|
109
|
+
}, _ReadinessManagerImpl_updateBeacon = function _ReadinessManagerImpl_updateBeacon(name, status) {
|
|
110
|
+
Object.assign(__classPrivateFieldGet(this, _ReadinessManagerImpl_beacons, "f")[name], { status });
|
|
111
|
+
if (status === 'resolved') {
|
|
112
|
+
__classPrivateFieldGet(this, _ReadinessManagerImpl_beacons, "f")[name].callbacks.forEach((callback) => callback());
|
|
116
113
|
}
|
|
117
|
-
|
|
114
|
+
__classPrivateFieldGet(this, _ReadinessManagerImpl_instances, "m", _ReadinessManagerImpl_trackBeaconUpdate).call(this);
|
|
115
|
+
}, _ReadinessManagerImpl_trackBeaconUpdate = function _ReadinessManagerImpl_trackBeaconUpdate() {
|
|
116
|
+
if (readyState) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
readyState = Object.values(__classPrivateFieldGet(this, _ReadinessManagerImpl_beacons, "f")).every((beacon) => beacon.status === 'resolved');
|
|
120
|
+
if (readyState) {
|
|
121
|
+
__classPrivateFieldGet(this, _ReadinessManagerImpl_callbacks, "f").forEach((callback) => callback());
|
|
122
|
+
}
|
|
123
|
+
};
|
|
118
124
|
const manager = new ReadinessManagerImpl();
|
|
119
125
|
exports.default = manager;
|
|
120
126
|
//# sourceMappingURL=index.js.map
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAA6C;AAC7C,mCAAgG;AAoOvF,qGApOQ,4BAAoB,OAoOR;AA9N7B,IAAI,UAAU,GAAG,KAAK,CAAC;AAsBvB,MAAM,oBAAoB;IAKtB;;QAJA,gDAAqB;QACrB,kDAA4B;QAC5B,qDAAkC;QAG9B,uBAAA,IAAI,iCAAY,EAAE,MAAA,CAAC;QACnB,uBAAA,IAAI,mCAAc,EAAE,MAAA,CAAC;QACrB,uBAAA,IAAI,sCAAiB,2BAAmB,MAAA,CAAC;IAC7C,CAAC;IAKD,IAAI,KAAK;QACL,OAAO,UAAU,CAAC;IACtB,CAAC;IAKD,MAAM;QACF,OAAO,MAAM,CAAC,MAAM,CAAC,uBAAA,IAAI,qCAAS,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE;YACjE,MAAM,OAAO,GAAG,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;YAClC,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,OAAO,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;QAChE,CAAC,EAAE,EAAmB,CAAC,CAAC;IAC5B,CAAC;IAUD,QAAQ,CAAC,IAAY,EAAE,MAAmB,EAAE,KAAK,GAAG,KAAK;QACrD,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,OAAO;QACX,CAAC;QAED,IAAI,uBAAA,IAAI,qCAAS,CAAC,IAAI,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK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,EAAE,OAAO,EAAE,KAAc,CAAC,EAAE,GAAG,EAAE,CAC7E,uBAAA,IAAI,sEAAS,MAAb,IAAI,EAAU,MAAM,EAAE,OAAO,GAAG,CAAC,CAAC,CACrC,CAAC;IACN,CAAC;AACL,CAAC,mFAQa,IAAY,EAAE,MAAoB;IAC5C,MAAM,CAAC,MAAM,CAAC,uBAAA,IAAI,qCAAS,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAG/C,IAAI,MAAM,KAAK,UAAU,EAAE,CAAC;QACxB,uBAAA,IAAI,qCAAS,CAAC,IAAI,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,uBAAA,IAAI,gFAAmB,MAAvB,IAAI,CAAqB,CAAC;AAC9B,CAAC;IAQG,IAAI,UAAU,EAAE,CAAC;QACb,OAAO;IACX,CAAC;IAED,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,uBAAA,IAAI,qCAAS,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,UAAU,CAAC,CAAC;IAE1F,IAAI,UAAU,EAAE,CAAC;QACb,uBAAA,IAAI,uCAAW,CAAC,OAAO,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC;IACtD,CAAC;AACL,CAAC;AAGL,MAAM,OAAO,GAAqB,IAAI,oBAAoB,EAAE,CAAC;AAE7D,kBAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export type ActionStatus = 'not_started' | 'pending' | 'resolved' | 'rejected';
|
|
2
|
+
export type ReadyCallback = () => void;
|
|
3
|
+
export type ReadyAction = () => unknown | Promise<unknown>;
|
|
4
|
+
export type ActionsStatus = {
|
|
5
|
+
[key in ActionStatus]?: string[];
|
|
6
|
+
};
|
|
7
|
+
export interface Beacon {
|
|
8
|
+
name: string;
|
|
9
|
+
action: ReadyAction;
|
|
10
|
+
status: ActionStatus;
|
|
11
|
+
callbacks: ReadyCallback[];
|
|
12
|
+
debug?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface BeaconsMap {
|
|
15
|
+
[name: string]: Beacon;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG,aAAa,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAK/E,MAAM,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC;AAKvC,MAAM,MAAM,WAAW,GAAG,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;AAK3D,MAAM,MAAM,aAAa,GAAG;KACvB,GAAG,IAAI,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE;CACnC,CAAC;AAKF,MAAM,WAAW,MAAM;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,WAAW,CAAC;IACpB,MAAM,EAAE,YAAY,CAAC;IACrB,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACnB;AAID,MAAM,WAAW,UAAU;IACvB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
package/dist/tests/mock.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../tests/mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"mock.d.ts","sourceRoot":"","sources":["../../tests/mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAIhD,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC1D,QAAQ,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IACrC,WAAW,EAAE,MAAM,IAAI,CAAC;CAC3B;AA+CD,QAAA,MAAM,OAAO,EAAE,oBAAqD,CAAC;AAErE,eAAe,OAAO,CAAC"}
|
package/dist/tests/mock.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock.js","sourceRoot":"","sources":["../../tests/mock.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"mock.js","sourceRoot":"","sources":["../../tests/mock.ts"],"names":[],"mappings":";;AAYA,MAAM,wBAAwB;IAA9B;QACY,WAAM,GAAG,KAAK,CAAC;IAuC3B,CAAC;IArCG,IAAI,KAAK;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;IAED,MAAM;QACF,OAAO,EAAmB,CAAC;IAC/B,CAAC;IAED,QAAQ,CAAC,OAAgB;QACrB,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC;IAC1B,CAAC;IAED,QAAQ,CAAC,KAAa,EAAE,OAAoB,EAAE,MAAgB;QAC1D,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,GAAG;QACC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,WAAW;QACP,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC;IACvB,CAAC;IAED,OAAO,CAAC,QAAuB;QAC3B,QAAQ,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,aAAa,CAAC,KAAa,EAAE,QAAuB;QAChD,QAAQ,EAAE,CAAC;QACX,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,OAAO,CAAC,aAAiC;QACrC,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AAED,MAAM,OAAO,GAAyB,IAAI,wBAAwB,EAAE,CAAC;AAErE,kBAAe,OAAO,CAAC"}
|