@sectester/core 0.28.0 → 0.29.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 +1 -74
- package/package.json +5 -3
- package/src/commands/Command.js.map +1 -0
- package/src/commands/CommandDispatcher.js.map +1 -0
- package/src/commands/HttpRequest.d.ts +19 -0
- package/src/commands/HttpRequest.js +20 -0
- package/src/commands/HttpRequest.js.map +1 -0
- package/src/commands/Message.js.map +1 -0
- package/src/commands/RetryStartegy.js.map +1 -0
- package/src/commands/index.d.ts +5 -0
- package/src/commands/index.js +9 -0
- package/src/commands/index.js.map +1 -0
- package/src/configuration/Configuration.d.ts +0 -2
- package/src/configuration/Configuration.js +0 -5
- package/src/configuration/Configuration.js.map +1 -1
- package/src/dispatchers/ExponentialBackoffRetryStrategy.d.ts +13 -0
- package/src/dispatchers/ExponentialBackoffRetryStrategy.js +65 -0
- package/src/dispatchers/ExponentialBackoffRetryStrategy.js.map +1 -0
- package/src/dispatchers/HttpCommandDispatcher.d.ts +14 -0
- package/src/dispatchers/HttpCommandDispatcher.js +94 -0
- package/src/dispatchers/HttpCommandDispatcher.js.map +1 -0
- package/src/dispatchers/HttpCommandDispatcherConfig.d.ts +12 -0
- package/src/dispatchers/HttpCommandDispatcherConfig.js +5 -0
- package/src/dispatchers/HttpCommandDispatcherConfig.js.map +1 -0
- package/src/dispatchers/index.d.ts +3 -0
- package/src/dispatchers/index.js +7 -0
- package/src/dispatchers/index.js.map +1 -0
- package/src/exceptions/HttpCommandError.d.ts +9 -0
- package/src/exceptions/HttpCommandError.js +18 -0
- package/src/exceptions/HttpCommandError.js.map +1 -0
- package/src/exceptions/index.d.ts +1 -0
- package/src/exceptions/index.js +1 -0
- package/src/exceptions/index.js.map +1 -1
- package/src/index.d.ts +2 -1
- package/src/index.js +2 -1
- package/src/index.js.map +1 -1
- package/src/register.js +21 -0
- package/src/register.js.map +1 -1
- package/src/bus/Command.js.map +0 -1
- package/src/bus/CommandDispatcher.js.map +0 -1
- package/src/bus/Event.d.ts +0 -7
- package/src/bus/Event.js +0 -14
- package/src/bus/Event.js.map +0 -1
- package/src/bus/EventBus.d.ts +0 -10
- package/src/bus/EventBus.js +0 -5
- package/src/bus/EventBus.js.map +0 -1
- package/src/bus/EventDispatcher.d.ts +0 -5
- package/src/bus/EventDispatcher.js +0 -5
- package/src/bus/EventDispatcher.js.map +0 -1
- package/src/bus/EventHandler.d.ts +0 -4
- package/src/bus/EventHandler.js +0 -3
- package/src/bus/EventHandler.js.map +0 -1
- package/src/bus/Message.js.map +0 -1
- package/src/bus/RetryStartegy.js.map +0 -1
- package/src/bus/decorators/bind.d.ts +0 -3
- package/src/bus/decorators/bind.js +0 -22
- package/src/bus/decorators/bind.js.map +0 -1
- package/src/bus/decorators/index.d.ts +0 -1
- package/src/bus/decorators/index.js +0 -5
- package/src/bus/decorators/index.js.map +0 -1
- package/src/bus/exceptions/EventHandlerNotFound.d.ts +0 -4
- package/src/bus/exceptions/EventHandlerNotFound.js +0 -11
- package/src/bus/exceptions/EventHandlerNotFound.js.map +0 -1
- package/src/bus/exceptions/IllegalOperation.d.ts +0 -6
- package/src/bus/exceptions/IllegalOperation.js +0 -12
- package/src/bus/exceptions/IllegalOperation.js.map +0 -1
- package/src/bus/exceptions/NoResponse.d.ts +0 -4
- package/src/bus/exceptions/NoResponse.js +0 -11
- package/src/bus/exceptions/NoResponse.js.map +0 -1
- package/src/bus/exceptions/NoSubscriptionsFound.d.ts +0 -5
- package/src/bus/exceptions/NoSubscriptionsFound.js +0 -12
- package/src/bus/exceptions/NoSubscriptionsFound.js.map +0 -1
- package/src/bus/exceptions/UnsupportedEventType.d.ts +0 -4
- package/src/bus/exceptions/UnsupportedEventType.js +0 -12
- package/src/bus/exceptions/UnsupportedEventType.js.map +0 -1
- package/src/bus/exceptions/index.d.ts +0 -5
- package/src/bus/exceptions/index.js +0 -9
- package/src/bus/exceptions/index.js.map +0 -1
- package/src/bus/index.d.ts +0 -10
- package/src/bus/index.js +0 -14
- package/src/bus/index.js.map +0 -1
- /package/src/{bus → commands}/Command.d.ts +0 -0
- /package/src/{bus → commands}/Command.js +0 -0
- /package/src/{bus → commands}/CommandDispatcher.d.ts +0 -0
- /package/src/{bus → commands}/CommandDispatcher.js +0 -0
- /package/src/{bus → commands}/Message.d.ts +0 -0
- /package/src/{bus → commands}/Message.js +0 -0
- /package/src/{bus → commands}/RetryStartegy.d.ts +0 -0
- /package/src/{bus → commands}/RetryStartegy.js +0 -0
package/README.md
CHANGED
|
@@ -164,8 +164,6 @@ await new Ping({ status: 'connected' }).execute(dispatcher);
|
|
|
164
164
|
await dispatcher.execute(new Ping({ status: 'disconnected' }));
|
|
165
165
|
```
|
|
166
166
|
|
|
167
|
-
The same is applicable for the `Event`. You just need to use the `EventDispatcher` instead of `CommandDispatcher`.
|
|
168
|
-
|
|
169
167
|
Each message have a correlation ID to ensure atomicity. The regular UUID is used, but you might also want to consider other options.
|
|
170
168
|
|
|
171
169
|
### Request-response
|
|
@@ -200,80 +198,9 @@ To adjust its behavior you can use next options:
|
|
|
200
198
|
| `expectReply` | Indicates whether to wait for a reply. By default `true`. |
|
|
201
199
|
| `ttl` | Period of time that command should be handled before being discarded. By default `10000` ms. |
|
|
202
200
|
| `type` | The name of a command. By default, it is the name of specific class. |
|
|
203
|
-
| `corelationId` | Used to ensure atomicity
|
|
201
|
+
| `corelationId` | Used to ensure atomicity. By default, random UUID. |
|
|
204
202
|
| `createdAt` | The exact date and time the command was created. |
|
|
205
203
|
|
|
206
|
-
### Publish-subscribe
|
|
207
|
-
|
|
208
|
-
When you just want to publish events without waiting for a response, it is better to use the `Event`.
|
|
209
|
-
The ideal use case for the publish-subscribe model is when you want to simply notify another service that a certain condition has occurred.
|
|
210
|
-
|
|
211
|
-
To create an instance of `Event` use the abstract class as follows:
|
|
212
|
-
|
|
213
|
-
```ts
|
|
214
|
-
import { Event } from '@sectester/core';
|
|
215
|
-
|
|
216
|
-
interface Issue {
|
|
217
|
-
name: string;
|
|
218
|
-
details: string;
|
|
219
|
-
type: string;
|
|
220
|
-
cvss?: string;
|
|
221
|
-
cwe?: string;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
class IssueDetected extends Event<Issue> {
|
|
225
|
-
constructor(payload: Issue) {
|
|
226
|
-
super(payload);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
To adjust its behavior you can use next options:
|
|
232
|
-
|
|
233
|
-
| Option | Description |
|
|
234
|
-
| :------------- | ------------------------------------------------------------------------------ |
|
|
235
|
-
| `payload` | Message that we want to transmit to the remote service. |
|
|
236
|
-
| `type` | The name of a command. By default, it is the name of specific class. |
|
|
237
|
-
| `corelationId` | Used to ensure atomicity while working with EventBus. By default, random UUID. |
|
|
238
|
-
| `createdAt` | The exact date and time the event was created. |
|
|
239
|
-
|
|
240
|
-
To create an event handler, you should implement the `Handler` interface and use the `@bind()` decorator to subscribe a handler to an event:
|
|
241
|
-
|
|
242
|
-
```ts
|
|
243
|
-
@bind(IssueDetected)
|
|
244
|
-
class IssueDetectedHandler implements EventHandler<Issue> {
|
|
245
|
-
public handle(payload: Issue): Promise<void> {
|
|
246
|
-
// implementation
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-
You can register multiple event handlers for a single event pattern and all of them will be automatically triggered in parallel.
|
|
252
|
-
|
|
253
|
-
```ts
|
|
254
|
-
@bind(IssueDetected, IssueReopened)
|
|
255
|
-
class IssueDetectedHandler implements EventHandler<Issue> {
|
|
256
|
-
public handle(payload: Issue): Promise<void> {
|
|
257
|
-
// implementation
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
You can also use a string and symbol to subscribe a handler to events:
|
|
263
|
-
|
|
264
|
-
```ts
|
|
265
|
-
const IssueReopened = Symbol('IssueReopened');
|
|
266
|
-
|
|
267
|
-
@bind('IssueDetected', IssueReopened)
|
|
268
|
-
class IssueDetectedHandler implements EventHandler<Issue> {
|
|
269
|
-
public handle(payload: Issue): Promise<void> {
|
|
270
|
-
// implementation
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
```
|
|
274
|
-
|
|
275
|
-
As soon as the `IssueDetected` event appears, the event handler takes a single argument, the data passed from the client (in this case, an event payload which has been sent over the network).
|
|
276
|
-
|
|
277
204
|
## License
|
|
278
205
|
|
|
279
206
|
Copyright © 2022 [Bright Security](https://brightsec.com/).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sectester/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"description": "The core package can be used to obtain a config including credentials from different sources, and provide a simplified abstraction to handle events and commands.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -39,11 +39,13 @@
|
|
|
39
39
|
"main": "./src/index.js",
|
|
40
40
|
"typings": "./src/index.d.ts",
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"
|
|
42
|
+
"axios": "^0.26.1",
|
|
43
43
|
"uuid": "^8.3.2",
|
|
44
|
+
"reflect-metadata": "^0.1.13",
|
|
44
45
|
"tsyringe": "^4.6.0",
|
|
45
|
-
"
|
|
46
|
+
"axios-rate-limit": "^1.3.0",
|
|
46
47
|
"form-data": "^4.0.0",
|
|
48
|
+
"chalk": "^4.1.2",
|
|
47
49
|
"tslib": "~2.3.1"
|
|
48
50
|
},
|
|
49
51
|
"peerDependencies": {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Command.js","sourceRoot":"","sources":["../../../../../packages/core/src/commands/Command.ts"],"names":[],"mappings":";;;AACA,uCAAoC;AAEpC,MAAsB,OAAc,SAAQ,iBAAU;IAIpD,YACE,OAAU,EACV,UAMI,EAAE;QAEN,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAbzD,gBAAW,GAAY,IAAI,CAAC;QAC5B,QAAG,GAAW,KAAK,CAAC;QAclC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;QACrC,IAAI,OAAO,WAAW,KAAK,SAAS,EAAE;YACpC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;SAChC;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG,CAAC,EAAE;YACtC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;SAChB;IACH,CAAC;IAEM,OAAO,CAAC,UAA6B;QAC1C,OAAO,UAAU,CAAC,OAAO,CAAO,IAAI,CAAC,CAAC;IACxC,CAAC;CACF;AA7BD,0BA6BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CommandDispatcher.js","sourceRoot":"","sources":["../../../../../packages/core/src/commands/CommandDispatcher.ts"],"names":[],"mappings":";;;AAMa,QAAA,iBAAiB,GAAkB,MAAM,CAAC,mBAAmB,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Command } from './Command';
|
|
2
|
+
import { Method } from 'axios';
|
|
3
|
+
export interface HttpOptions<T> {
|
|
4
|
+
url: string;
|
|
5
|
+
payload: T;
|
|
6
|
+
method?: Method;
|
|
7
|
+
expectReply?: boolean;
|
|
8
|
+
ttl?: number;
|
|
9
|
+
type?: string;
|
|
10
|
+
correlationId?: string;
|
|
11
|
+
params?: Record<string, unknown>;
|
|
12
|
+
createdAt?: Date;
|
|
13
|
+
}
|
|
14
|
+
export declare class HttpRequest<T = undefined, R = void> extends Command<T, R> {
|
|
15
|
+
readonly method: Method;
|
|
16
|
+
readonly url: string;
|
|
17
|
+
readonly params?: Record<string, unknown>;
|
|
18
|
+
constructor({ payload, expectReply, ttl, type, params, correlationId, createdAt, url, method }: HttpOptions<T>);
|
|
19
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpRequest = void 0;
|
|
4
|
+
const Command_1 = require("./Command");
|
|
5
|
+
class HttpRequest extends Command_1.Command {
|
|
6
|
+
constructor({ payload, expectReply, ttl, type, params, correlationId, createdAt, url = '/', method = 'GET' }) {
|
|
7
|
+
super(payload, { expectReply, ttl, type, correlationId, createdAt });
|
|
8
|
+
if (typeof url !== 'string') {
|
|
9
|
+
throw new TypeError('`url` must be string. Please provide a valid URL or path that will be used for the command.');
|
|
10
|
+
}
|
|
11
|
+
this.url = url;
|
|
12
|
+
if (typeof method !== 'string') {
|
|
13
|
+
throw new TypeError('`method` must be string. Please provide a valid HTTP method that will be used for the command.');
|
|
14
|
+
}
|
|
15
|
+
this.method = method;
|
|
16
|
+
this.params = params;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.HttpRequest = HttpRequest;
|
|
20
|
+
//# sourceMappingURL=HttpRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpRequest.js","sourceRoot":"","sources":["../../../../../packages/core/src/commands/HttpRequest.ts"],"names":[],"mappings":";;;AAAA,uCAAoC;AAepC,MAAa,WAAqC,SAAQ,iBAAa;IAKrE,YAAY,EACV,OAAO,EACP,WAAW,EACX,GAAG,EACH,IAAI,EACJ,MAAM,EACN,aAAa,EACb,SAAS,EACT,GAAG,GAAG,GAAG,EACT,MAAM,GAAG,KAAK,EACC;QACf,KAAK,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,EAAE,CAAC,CAAC;QAErE,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,MAAM,IAAI,SAAS,CACjB,6FAA6F,CAC9F,CAAC;SACH;QAED,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QAEf,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE;YAC9B,MAAM,IAAI,SAAS,CACjB,gGAAgG,CACjG,CAAC;SACH;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAnCD,kCAmCC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../../../packages/core/src/commands/Message.ts"],"names":[],"mappings":";;;AAAA,oCAAuC;AACvC,+BAA0B;AAE1B,MAAsB,OAAO;IAK3B,YACkB,OAAU,EAC1B,IAAa,EACb,aAAsB,EACtB,SAAgB;QAHA,YAAO,GAAP,OAAO,CAAG;QAK1B,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,IAAA,mBAAW,EAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,IAAA,SAAE,GAAE,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC;IAC3C,CAAC;CACF;AAfD,0BAeC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RetryStartegy.js","sourceRoot":"","sources":["../../../../../packages/core/src/commands/RetryStartegy.ts"],"names":[],"mappings":";;;AAMa,QAAA,aAAa,GAAkB,MAAM,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./Command"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./CommandDispatcher"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./HttpRequest"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./Message"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./RetryStartegy"), exports);
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/commands/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,8DAAoC;AACpC,wDAA8B;AAC9B,oDAA0B;AAC1B,0DAAgC"}
|
|
@@ -15,8 +15,6 @@ export declare class Configuration {
|
|
|
15
15
|
get container(): import("tsyringe").DependencyContainer;
|
|
16
16
|
private _credentials?;
|
|
17
17
|
get credentials(): Credentials | undefined;
|
|
18
|
-
private _bus;
|
|
19
|
-
get bus(): string;
|
|
20
18
|
private _api;
|
|
21
19
|
get api(): string;
|
|
22
20
|
private _logLevel?;
|
|
@@ -34,9 +34,6 @@ class Configuration {
|
|
|
34
34
|
get credentials() {
|
|
35
35
|
return this._credentials;
|
|
36
36
|
}
|
|
37
|
-
get bus() {
|
|
38
|
-
return this._bus;
|
|
39
|
-
}
|
|
40
37
|
get api() {
|
|
41
38
|
return this._api;
|
|
42
39
|
}
|
|
@@ -77,11 +74,9 @@ class Configuration {
|
|
|
77
74
|
throw new Error(`Please make sure that you pass correct 'hostname' option.`);
|
|
78
75
|
}
|
|
79
76
|
if (['localhost', '127.0.0.1'].includes(hostname)) {
|
|
80
|
-
this._bus = `amqp://${hostname}:5672`;
|
|
81
77
|
this._api = `http://${hostname}:8000`;
|
|
82
78
|
}
|
|
83
79
|
else {
|
|
84
|
-
this._bus = `amqps://amq.${hostname}:5672`;
|
|
85
80
|
this._api = `https://${hostname}`;
|
|
86
81
|
}
|
|
87
82
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../../../packages/core/src/configuration/Configuration.ts"],"names":[],"mappings":";;;AAAA,kEAKiC;AACjC,oCAAiC;AACjC,sCAAqC;AACrC,qDAAwD;AACxD,uCAAqC;AASrC,MAAa,aAAa;
|
|
1
|
+
{"version":3,"file":"Configuration.js","sourceRoot":"","sources":["../../../../../packages/core/src/configuration/Configuration.ts"],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,QAAQ,OAAO,CAAC;SACvC;aAAM;YACL,IAAI,CAAC,IAAI,GAAG,WAAW,QAAQ,EAAE,CAAC;SACnC;IACH,CAAC;CACF;AAnHD,sCAmHC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { RetryStrategy } from '../commands';
|
|
2
|
+
export interface ExponentialBackoffOptions {
|
|
3
|
+
maxDepth: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class ExponentialBackoffRetryStrategy implements RetryStrategy {
|
|
6
|
+
private readonly options;
|
|
7
|
+
private readonly RETRYABLE_AMQP_CODES;
|
|
8
|
+
private readonly RETRYABLE_HTTP_METHODS;
|
|
9
|
+
private readonly RETRYABLE_CODES;
|
|
10
|
+
constructor(options: ExponentialBackoffOptions);
|
|
11
|
+
acquire<T extends (...args: unknown[]) => unknown>(task: T): Promise<ReturnType<T>>;
|
|
12
|
+
private shouldRetry;
|
|
13
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExponentialBackoffRetryStrategy = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
const tsyringe_1 = require("tsyringe");
|
|
7
|
+
let ExponentialBackoffRetryStrategy = class ExponentialBackoffRetryStrategy {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.options = options;
|
|
10
|
+
this.RETRYABLE_AMQP_CODES = new Set([
|
|
11
|
+
311, 312, 313, 320, 404, 405, 406, 502, 503, 504, 505, 506
|
|
12
|
+
]);
|
|
13
|
+
this.RETRYABLE_HTTP_METHODS = new Set([
|
|
14
|
+
'get',
|
|
15
|
+
'head',
|
|
16
|
+
'options',
|
|
17
|
+
'put',
|
|
18
|
+
'delete'
|
|
19
|
+
]);
|
|
20
|
+
this.RETRYABLE_CODES = new Set([
|
|
21
|
+
'ECONNRESET',
|
|
22
|
+
'ETIMEDOUT',
|
|
23
|
+
'ECONNREFUSED',
|
|
24
|
+
'ENETUNREACH',
|
|
25
|
+
'ENOTFOUND',
|
|
26
|
+
'EADDRINUSE',
|
|
27
|
+
'EHOSTUNREACH',
|
|
28
|
+
'EPIPE',
|
|
29
|
+
'EAI_AGAIN'
|
|
30
|
+
]);
|
|
31
|
+
}
|
|
32
|
+
async acquire(task) {
|
|
33
|
+
let depth = 0;
|
|
34
|
+
for (;;) {
|
|
35
|
+
try {
|
|
36
|
+
return (await task());
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
depth++;
|
|
40
|
+
// eslint-disable-next-line max-depth
|
|
41
|
+
if (!this.shouldRetry(e) || depth > this.options.maxDepth) {
|
|
42
|
+
throw e;
|
|
43
|
+
}
|
|
44
|
+
await (0, utils_1.delay)(2 ** depth * 50);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
shouldRetry(err) {
|
|
49
|
+
const code = err.code;
|
|
50
|
+
if (typeof code === 'string') {
|
|
51
|
+
return this.RETRYABLE_CODES.has(code);
|
|
52
|
+
}
|
|
53
|
+
if (typeof code === 'number') {
|
|
54
|
+
return this.RETRYABLE_AMQP_CODES.has(+code);
|
|
55
|
+
}
|
|
56
|
+
const { status = 200, method = 'get' } = err;
|
|
57
|
+
return (status >= 500 && this.RETRYABLE_HTTP_METHODS.has(method.toLowerCase()));
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
ExponentialBackoffRetryStrategy = tslib_1.__decorate([
|
|
61
|
+
(0, tsyringe_1.injectable)(),
|
|
62
|
+
tslib_1.__metadata("design:paramtypes", [Object])
|
|
63
|
+
], ExponentialBackoffRetryStrategy);
|
|
64
|
+
exports.ExponentialBackoffRetryStrategy = ExponentialBackoffRetryStrategy;
|
|
65
|
+
//# sourceMappingURL=ExponentialBackoffRetryStrategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExponentialBackoffRetryStrategy.js","source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AAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,OAAO,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;SACvC;QAED,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE;YAC5B,OAAO,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;SAC7C;QAED,MAAM,EAAE,MAAM,GAAG,GAAG,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,GAAuB,CAAC;QAEjE,OAAO,CACL,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,sBAAsB,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC,CACvE,CAAC;IACJ,CAAC;CACF,CAAA;AA/DY,+BAA+B;IAD3C,IAAA,qBAAU,GAAE;;GACA,+BAA+B,CA+D3C;AA/DY,0EAA+B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { HttpCommandDispatcherConfig } from './HttpCommandDispatcherConfig';
|
|
2
|
+
import { CommandDispatcher, RetryStrategy, HttpRequest } from '../commands';
|
|
3
|
+
import { Logger } from '../logger';
|
|
4
|
+
export declare class HttpCommandDispatcher implements CommandDispatcher {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
private readonly retryStrategy;
|
|
7
|
+
private readonly options;
|
|
8
|
+
private readonly client;
|
|
9
|
+
constructor(logger: Logger, retryStrategy: RetryStrategy, options: HttpCommandDispatcherConfig);
|
|
10
|
+
execute<T, R>(command: HttpRequest<T, R>): Promise<R | undefined>;
|
|
11
|
+
private performHttpRequest;
|
|
12
|
+
private createHttpClient;
|
|
13
|
+
private inferHeaders;
|
|
14
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpCommandDispatcher = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const HttpCommandDispatcherConfig_1 = require("./HttpCommandDispatcherConfig");
|
|
6
|
+
const commands_1 = require("../commands");
|
|
7
|
+
const exceptions_1 = require("../exceptions");
|
|
8
|
+
const logger_1 = require("../logger");
|
|
9
|
+
const tsyringe_1 = require("tsyringe");
|
|
10
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
11
|
+
const axios_rate_limit_1 = tslib_1.__importDefault(require("axios-rate-limit"));
|
|
12
|
+
const form_data_1 = tslib_1.__importDefault(require("form-data"));
|
|
13
|
+
const stream_1 = require("stream");
|
|
14
|
+
const util_1 = require("util");
|
|
15
|
+
const http_1 = tslib_1.__importDefault(require("http"));
|
|
16
|
+
const https_1 = tslib_1.__importDefault(require("https"));
|
|
17
|
+
let HttpCommandDispatcher = class HttpCommandDispatcher {
|
|
18
|
+
constructor(logger, retryStrategy, options) {
|
|
19
|
+
this.logger = logger;
|
|
20
|
+
this.retryStrategy = retryStrategy;
|
|
21
|
+
this.options = options;
|
|
22
|
+
this.client = this.createHttpClient();
|
|
23
|
+
}
|
|
24
|
+
async execute(command) {
|
|
25
|
+
this.logger.debug('Executing an incoming command (%s): %j', command.correlationId, command);
|
|
26
|
+
const response = await this.retryStrategy.acquire(() => this.performHttpRequest(command));
|
|
27
|
+
if (!command.expectReply && response.data instanceof stream_1.Readable) {
|
|
28
|
+
// drain readable stream to avoid memory leaks
|
|
29
|
+
response.data.on('readable', response.data.read.bind(response.data));
|
|
30
|
+
await (0, util_1.promisify)(stream_1.finished)(response.data);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
this.logger.debug('Received a response to the command (%s): %j', command.correlationId, response.data);
|
|
34
|
+
return response.data;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
async performHttpRequest({ correlationId, createdAt, expectReply, method, params, payload, ttl, url }) {
|
|
38
|
+
try {
|
|
39
|
+
return await this.client.request({
|
|
40
|
+
url,
|
|
41
|
+
method,
|
|
42
|
+
params,
|
|
43
|
+
data: payload,
|
|
44
|
+
timeout: ttl,
|
|
45
|
+
headers: {
|
|
46
|
+
...this.inferHeaders(payload),
|
|
47
|
+
'x-correlation-id': correlationId,
|
|
48
|
+
'date': createdAt.toISOString()
|
|
49
|
+
},
|
|
50
|
+
...(!expectReply ? { responseType: 'stream' } : {})
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (e) {
|
|
54
|
+
const httpError = new exceptions_1.HttpCommandError(e);
|
|
55
|
+
this.logger.debug('Command (%s) has been failed:', correlationId, httpError);
|
|
56
|
+
throw httpError;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
createHttpClient() {
|
|
60
|
+
const { baseUrl, token, keepAlive = true, maxSockets = 50, timeout = 10000, rate = { limit: 10, window: 60 * 1000 } } = this.options;
|
|
61
|
+
const options = {
|
|
62
|
+
timeout,
|
|
63
|
+
httpAgent: new http_1.default.Agent({ maxSockets, keepAlive }),
|
|
64
|
+
httpsAgent: new https_1.default.Agent({ maxSockets, keepAlive }),
|
|
65
|
+
baseURL: baseUrl,
|
|
66
|
+
responseType: 'json',
|
|
67
|
+
headers: {
|
|
68
|
+
authorization: `api-key ${token}`
|
|
69
|
+
},
|
|
70
|
+
transitional: {
|
|
71
|
+
clarifyTimeoutError: true
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
return (0, axios_rate_limit_1.default)(axios_1.default.create(options), {
|
|
75
|
+
maxRequests: rate.limit,
|
|
76
|
+
perMilliseconds: rate.window
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
inferHeaders(data) {
|
|
80
|
+
let headers = {};
|
|
81
|
+
if (data instanceof form_data_1.default) {
|
|
82
|
+
headers = data.getHeaders();
|
|
83
|
+
}
|
|
84
|
+
return headers;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
HttpCommandDispatcher = tslib_1.__decorate([
|
|
88
|
+
(0, tsyringe_1.injectable)(),
|
|
89
|
+
tslib_1.__param(1, (0, tsyringe_1.inject)(commands_1.RetryStrategy)),
|
|
90
|
+
tslib_1.__param(2, (0, tsyringe_1.inject)(HttpCommandDispatcherConfig_1.HttpCommandDispatcherConfig)),
|
|
91
|
+
tslib_1.__metadata("design:paramtypes", [logger_1.Logger, Object, Object])
|
|
92
|
+
], HttpCommandDispatcher);
|
|
93
|
+
exports.HttpCommandDispatcher = HttpCommandDispatcher;
|
|
94
|
+
//# sourceMappingURL=HttpCommandDispatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpCommandDispatcher.js","sourceRoot":"","sources":["../../../../../packages/core/src/dispatchers/HttpCommandDispatcher.ts"],"names":[],"mappings":";;;;AAAA,+EAA4E;AAC5E,0CAA4E;AAC5E,8CAAiD;AACjD,sCAAmC;AACnC,uCAA8C;AAC9C,0DAAgF;AAChF,gFAAyC;AACzC,kEAAiC;AACjC,mCAA4C;AAC5C,+BAAiC;AACjC,wDAAwB;AACxB,0DAA0B;AAG1B,IAAa,qBAAqB,GAAlC,MAAa,qBAAqB;IAGhC,YACmB,MAAc,EAEd,aAA4B,EAE5B,OAAoC;QAJpC,WAAM,GAAN,MAAM,CAAQ;QAEd,kBAAa,GAAb,aAAa,CAAe;QAE5B,YAAO,GAAP,OAAO,CAA6B;QAErD,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,gBAAgB,EAAE,CAAC;IACxC,CAAC;IAEM,KAAK,CAAC,OAAO,CAClB,OAA0B;QAE1B,IAAI,CAAC,MAAM,CAAC,KAAK,CACf,wCAAwC,EACxC,OAAO,CAAC,aAAa,EACrB,OAAO,CACR,CAAC;QACF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,CACrD,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CACjC,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,WAAW,IAAI,QAAQ,CAAC,IAAI,YAAY,iBAAQ,EAAE;YAC7D,8CAA8C;YAC9C,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC,U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number;
|
|
6
|
+
keepAlive?: boolean;
|
|
7
|
+
rate?: {
|
|
8
|
+
window: number;
|
|
9
|
+
limit: number;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
export declare const HttpCommandDispatcherConfig: unique symbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpCommandDispatcherConfig.js","sourceRoot":"","sources":["../../../../../packages/core/src/dispatchers/HttpCommandDispatcherConfig.ts"],"names":[],"mappings":";;;AAYa,QAAA,2BAA2B,GAAkB,MAAM,CAC9D,6BAA6B,CAC9B,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./HttpCommandDispatcher"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./HttpCommandDispatcherConfig"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./ExponentialBackoffRetryStrategy"), exports);
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/dispatchers/index.ts"],"names":[],"mappings":";;;AAAA,kEAAwC;AACxC,wEAA8C;AAC9C,4EAAkD"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SecTesterError } from './SecTesterError';
|
|
2
|
+
import { AxiosError } from 'axios';
|
|
3
|
+
export declare class HttpCommandError extends SecTesterError {
|
|
4
|
+
readonly cause: AxiosError;
|
|
5
|
+
readonly status: number | undefined;
|
|
6
|
+
readonly code: string | undefined;
|
|
7
|
+
readonly method: string | undefined;
|
|
8
|
+
constructor(cause: AxiosError);
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpCommandError = void 0;
|
|
4
|
+
const SecTesterError_1 = require("./SecTesterError");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
class HttpCommandError extends SecTesterError_1.SecTesterError {
|
|
7
|
+
constructor(cause) {
|
|
8
|
+
super();
|
|
9
|
+
this.cause = cause;
|
|
10
|
+
const { message, code, config: { method } = {}, response: { data, status } = {} } = cause;
|
|
11
|
+
this.method = method;
|
|
12
|
+
this.message = !(0, utils_1.isStream)(data) && (0, utils_1.isPresent)(data) ? data : message;
|
|
13
|
+
this.status = status;
|
|
14
|
+
this.code = code;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.HttpCommandError = HttpCommandError;
|
|
18
|
+
//# sourceMappingURL=HttpCommandError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HttpCommandError.js","sourceRoot":"","sources":["../../../../../packages/core/src/exceptions/HttpCommandError.ts"],"names":[],"mappings":";;;AAAA,qDAAkD;AAClD,oCAA+C;AAG/C,MAAa,gBAAiB,SAAQ,+BAAc;IAKlD,YAA4B,KAAiB;QAC3C,KAAK,EAAE,CAAC;QADkB,UAAK,GAAL,KAAK,CAAY;QAE3C,MAAM,EACJ,OAAO,EACP,IAAI,EACJ,MAAM,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,EACvB,QAAQ,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,EAChC,GAAG,KAAK,CAAC;QAEV,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,CAAC,IAAA,gBAAQ,EAAC,IAAI,CAAC,IAAI,IAAA,iBAAS,EAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC;QACnE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAnBD,4CAmBC"}
|
package/src/exceptions/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,2DAAiC;AACjC,6DAAmC"}
|
package/src/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import './register';
|
|
3
|
-
export * from './
|
|
3
|
+
export * from './commands';
|
|
4
4
|
export * from './configuration';
|
|
5
5
|
export * from './credentials-provider';
|
|
6
|
+
export * from './dispatchers';
|
|
6
7
|
export * from './exceptions';
|
|
7
8
|
export * from './logger';
|
|
8
9
|
export { NumBoundaries, checkBoundaries, contains, delay, isBoolean, isDate, isFormData, isNumber, isObject, isPresent, isStream, isString, isURLSearchParams, truncate } from './utils';
|
package/src/index.js
CHANGED
|
@@ -4,9 +4,10 @@ exports.truncate = exports.isURLSearchParams = exports.isString = exports.isStre
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
require("reflect-metadata");
|
|
6
6
|
require("./register");
|
|
7
|
-
tslib_1.__exportStar(require("./
|
|
7
|
+
tslib_1.__exportStar(require("./commands"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./configuration"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./credentials-provider"), exports);
|
|
10
|
+
tslib_1.__exportStar(require("./dispatchers"), exports);
|
|
10
11
|
tslib_1.__exportStar(require("./exceptions"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./logger"), exports);
|
|
12
13
|
var utils_1 = require("./utils");
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/index.ts"],"names":[],"mappings":";;;;AAAA,4BAA0B;AAC1B,sBAAoB;AAEpB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/core/src/index.ts"],"names":[],"mappings":";;;;AAAA,4BAA0B;AAC1B,sBAAoB;AAEpB,qDAA2B;AAC3B,0DAAgC;AAChC,iEAAuC;AACvC,wDAA8B;AAC9B,uDAA6B;AAC7B,mDAAyB;AACzB,iCAeiB;AAbf,wGAAA,eAAe,OAAA;AACf,iGAAA,QAAQ,OAAA;AACR,8FAAA,KAAK,OAAA;AACL,kGAAA,SAAS,OAAA;AACT,+FAAA,MAAM,OAAA;AACN,mGAAA,UAAU,OAAA;AACV,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,kGAAA,SAAS,OAAA;AACT,iGAAA,QAAQ,OAAA;AACR,iGAAA,QAAQ,OAAA;AACR,0GAAA,iBAAiB,OAAA;AACjB,iGAAA,QAAQ,OAAA"}
|
package/src/register.js
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const commands_1 = require("./commands");
|
|
3
4
|
const configuration_1 = require("./configuration");
|
|
5
|
+
const dispatchers_1 = require("./dispatchers");
|
|
4
6
|
const logger_1 = require("./logger");
|
|
5
7
|
const tsyringe_1 = require("tsyringe");
|
|
8
|
+
tsyringe_1.container.register(commands_1.RetryStrategy, {
|
|
9
|
+
useFactory() {
|
|
10
|
+
return new dispatchers_1.ExponentialBackoffRetryStrategy({ maxDepth: 5 });
|
|
11
|
+
}
|
|
12
|
+
});
|
|
6
13
|
tsyringe_1.container.register(logger_1.Logger, {
|
|
7
14
|
useFactory: (0, tsyringe_1.instancePerContainerCachingFactory)((child) => child.isRegistered(configuration_1.Configuration, true)
|
|
8
15
|
? new logger_1.Logger(child.resolve(configuration_1.Configuration).logLevel)
|
|
9
16
|
: new logger_1.Logger())
|
|
10
17
|
});
|
|
18
|
+
tsyringe_1.container.register(commands_1.CommandDispatcher, { useClass: dispatchers_1.HttpCommandDispatcher });
|
|
19
|
+
tsyringe_1.container.register(dispatchers_1.HttpCommandDispatcherConfig, {
|
|
20
|
+
useFactory(childContainer) {
|
|
21
|
+
const configuration = childContainer.resolve(configuration_1.Configuration);
|
|
22
|
+
if (!configuration.credentials) {
|
|
23
|
+
throw new Error('Please provide credentials to establish a connection with the dispatcher.');
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
timeout: 10000,
|
|
27
|
+
baseUrl: configuration.api,
|
|
28
|
+
token: configuration.credentials.token
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
});
|
|
11
32
|
//# sourceMappingURL=register.js.map
|
package/src/register.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../../packages/core/src/register.ts"],"names":[],"mappings":";;AAAA,mDAAgD;AAChD,qCAAkC;AAClC,uCAIkB;AAElB,oBAAS,CAAC,QAAQ,CAAC,eAAM,EAAE;IACzB,UAAU,EAAE,IAAA,6CAAkC,EAAC,CAAC,KAA0B,EAAE,EAAE,CAC5E,KAAK,CAAC,YAAY,CAAC,6BAAa,EAAE,IAAI,CAAC;QACrC,CAAC,CAAC,IAAI,eAAM,CAAC,KAAK,CAAC,OAAO,CAAC,6BAAa,CAAC,CAAC,QAAQ,CAAC;QACnD,CAAC,CAAC,IAAI,eAAM,EAAE,CACjB;CACF,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"register.js","sourceRoot":"","sources":["../../../../packages/core/src/register.ts"],"names":[],"mappings":";;AAAA,yCAA8D;AAC9D,mDAAgD;AAChD,+CAIuB;AACvB,qCAAkC;AAClC,uCAIkB;AAElB,oBAAS,CAAC,QAAQ,CAAC,wBAAa,EAAE;IAChC,UAAU;QACR,OAAO,IAAI,6CAA+B,CAAC,EAAE,QAAQ,EAAE,CAAC,EAAE,CAAC,CAAC;IAC9D,CAAC;CACF,CAAC,CAAC;AAEH,oBAAS,CAAC,QAAQ,CAAC,eAAM,EAAE;IACzB,UAAU,EAAE,IAAA,6CAAkC,EAAC,CAAC,KAA0B,EAAE,EAAE,CAC5E,KAAK,CAAC,YAAY,CAAC,6BAAa,EAAE,IAAI,CAAC;QACrC,CAAC,CAAC,IAAI,eAAM,CAAC,KAAK,CAAC,OAAO,CAAC,6BAAa,CAAC,CAAC,QAAQ,CAAC;QACnD,CAAC,CAAC,IAAI,eAAM,EAAE,CACjB;CACF,CAAC,CAAC;AAEH,oBAAS,CAAC,QAAQ,CAAC,4BAAiB,EAAE,EAAE,QAAQ,EAAE,mCAAqB,EAAE,CAAC,CAAC;AAE3E,oBAAS,CAAC,QAAQ,CAAC,yCAA2B,EAAE;IAC9C,UAAU,CAAC,cAAmC;QAC5C,MAAM,aAAa,GAAG,cAAc,CAAC,OAAO,CAAC,6BAAa,CAAC,CAAC;QAE5D,IAAI,CAAC,aAAa,CAAC,WAAW,EAAE;YAC9B,MAAM,IAAI,KAAK,CACb,2EAA2E,CAC5E,CAAC;SACH;QAED,OAAO;YACL,OAAO,EAAE,KAAK;YACd,OAAO,EAAE,aAAa,CAAC,GAAG;YAC1B,KAAK,EAAE,aAAa,CAAC,WAAW,CAAC,KAAK;SACvC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
|
package/src/bus/Command.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Command.js","sourceRoot":"","sources":["../../../../../packages/core/src/bus/Command.ts"],"names":[],"mappings":";;;AACA,uCAAoC;AAEpC,MAAsB,OAAc,SAAQ,iBAAU;IAIpD,YACE,OAAU,EACV,UAMI,EAAE;QAEN,KAAK,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,aAAa,EAAE,OAAO,CAAC,SAAS,CAAC,CAAC;QAbzD,gBAAW,GAAY,IAAI,CAAC;QAC5B,QAAG,GAAW,KAAK,CAAC;QAclC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC;QACrC,IAAI,OAAO,WAAW,KAAK,SAAS,EAAE;YACpC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;SAChC;QAED,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,GAAG,CAAC,EAAE;YACtC,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;SAChB;IACH,CAAC;IAEM,OAAO,CAAC,UAA6B;QAC1C,OAAO,UAAU,CAAC,OAAO,CAAO,IAAI,CAAC,CAAC;IACxC,CAAC;CACF;AA7BD,0BA6BC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CommandDispatcher.js","sourceRoot":"","sources":["../../../../../packages/core/src/bus/CommandDispatcher.ts"],"names":[],"mappings":";;;AAMa,QAAA,iBAAiB,GAAkB,MAAM,CAAC,mBAAmB,CAAC,CAAC"}
|
package/src/bus/Event.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { EventDispatcher } from './EventDispatcher';
|
|
2
|
-
import { Message } from './Message';
|
|
3
|
-
export declare abstract class Event<T> extends Message<T> {
|
|
4
|
-
protected constructor(payload: T, type?: string, correlationId?: string, createdAt?: Date);
|
|
5
|
-
publish(dispatcher: EventDispatcher): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
export declare type EventConstructor<T = unknown> = abstract new (...args: any[]) => Event<T>;
|
package/src/bus/Event.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Event = void 0;
|
|
4
|
-
const Message_1 = require("./Message");
|
|
5
|
-
class Event extends Message_1.Message {
|
|
6
|
-
constructor(payload, type, correlationId, createdAt) {
|
|
7
|
-
super(payload, type, correlationId, createdAt);
|
|
8
|
-
}
|
|
9
|
-
publish(dispatcher) {
|
|
10
|
-
return dispatcher.publish(this);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
exports.Event = Event;
|
|
14
|
-
//# sourceMappingURL=Event.js.map
|
package/src/bus/Event.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Event.js","sourceRoot":"","sources":["../../../../../packages/core/src/bus/Event.ts"],"names":[],"mappings":";;;AACA,uCAAoC;AAEpC,MAAsB,KAAS,SAAQ,iBAAU;IAC/C,YACE,OAAU,EACV,IAAa,EACb,aAAsB,EACtB,SAAgB;QAEhB,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC;IACjD,CAAC;IAEM,OAAO,CAAC,UAA2B;QACxC,OAAO,UAAU,CAAC,OAAO,CAAI,IAAI,CAAC,CAAC;IACrC,CAAC;CACF;AAbD,sBAaC"}
|
package/src/bus/EventBus.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { CommandDispatcher } from './CommandDispatcher';
|
|
2
|
-
import { EventDispatcher } from './EventDispatcher';
|
|
3
|
-
import { EventHandlerConstructor } from './EventHandler';
|
|
4
|
-
export interface EventBus extends EventDispatcher, CommandDispatcher {
|
|
5
|
-
register(type: EventHandlerConstructor): Promise<void>;
|
|
6
|
-
unregister(type: EventHandlerConstructor): Promise<void>;
|
|
7
|
-
init?(): Promise<void>;
|
|
8
|
-
destroy?(): Promise<void>;
|
|
9
|
-
}
|
|
10
|
-
export declare const EventBus: unique symbol;
|
package/src/bus/EventBus.js
DELETED
package/src/bus/EventBus.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventBus.js","sourceRoot":"","sources":["../../../../../packages/core/src/bus/EventBus.ts"],"names":[],"mappings":";;;AAca,QAAA,QAAQ,GAAkB,MAAM,CAAC,UAAU,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventDispatcher.js","sourceRoot":"","sources":["../../../../../packages/core/src/bus/EventDispatcher.ts"],"names":[],"mappings":";;;AAMa,QAAA,eAAe,GAAkB,MAAM,CAAC,iBAAiB,CAAC,CAAC"}
|
package/src/bus/EventHandler.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventHandler.js","sourceRoot":"","sources":["../../../../../packages/core/src/bus/EventHandler.ts"],"names":[],"mappings":""}
|
package/src/bus/Message.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Message.js","sourceRoot":"","sources":["../../../../../packages/core/src/bus/Message.ts"],"names":[],"mappings":";;;AAAA,oCAAuC;AACvC,+BAA0B;AAE1B,MAAsB,OAAO;IAK3B,YACkB,OAAU,EAC1B,IAAa,EACb,aAAsB,EACtB,SAAgB;QAHA,YAAO,GAAP,OAAO,CAAG;QAK1B,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,IAAA,mBAAW,EAAC,IAAI,CAAC,CAAC;QACtC,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,IAAA,SAAE,GAAE,CAAC;QAC3C,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,IAAI,IAAI,EAAE,CAAC;IAC3C,CAAC;CACF;AAfD,0BAeC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RetryStartegy.js","sourceRoot":"","sources":["../../../../../packages/core/src/bus/RetryStartegy.ts"],"names":[],"mappings":";;;AAMa,QAAA,aAAa,GAAkB,MAAM,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.bind = void 0;
|
|
4
|
-
const Event_1 = require("../Event");
|
|
5
|
-
const exceptions_1 = require("../exceptions");
|
|
6
|
-
const bind = (...events) => target => {
|
|
7
|
-
const eventNames = events.map(event => {
|
|
8
|
-
switch (typeof event) {
|
|
9
|
-
case 'string':
|
|
10
|
-
return event;
|
|
11
|
-
case 'function':
|
|
12
|
-
return event.name;
|
|
13
|
-
case 'symbol':
|
|
14
|
-
return event.description;
|
|
15
|
-
default:
|
|
16
|
-
throw new exceptions_1.UnsupportedEventType(event);
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
Reflect.defineMetadata(Event_1.Event, eventNames, target);
|
|
20
|
-
};
|
|
21
|
-
exports.bind = bind;
|
|
22
|
-
//# sourceMappingURL=bind.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bind.js","sourceRoot":"","sources":["../../../../../../packages/core/src/bus/decorators/bind.ts"],"names":[],"mappings":";;;AAAA,oCAAmD;AACnD,8CAAqD;AAI9C,MAAM,IAAI,GACf,CAAC,GAAG,MAAmB,EAAkB,EAAE,CAC3C,MAAM,CAAC,EAAE;IACP,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE;QACpC,QAAQ,OAAO,KAAK,EAAE;YACpB,KAAK,QAAQ;gBACX,OAAO,KAAK,CAAC;YACf,KAAK,UAAU;gBACb,OAAO,KAAK,CAAC,IAAI,CAAC;YACpB,KAAK,QAAQ;gBACX,OAAO,KAAK,CAAC,WAAW,CAAC;YAC3B;gBACE,MAAM,IAAI,iCAAoB,CAAC,KAAK,CAAC,CAAC;SACzC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,cAAc,CAAC,aAAK,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC;AACpD,CAAC,CAAC;AAjBS,QAAA,IAAI,QAiBb"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './bind';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/src/bus/decorators/index.ts"],"names":[],"mappings":";;;AAAA,iDAAuB"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventHandlerNotFound = void 0;
|
|
4
|
-
const exceptions_1 = require("../../exceptions");
|
|
5
|
-
class EventHandlerNotFound extends exceptions_1.SecTesterError {
|
|
6
|
-
constructor(...eventNames) {
|
|
7
|
-
super(`Event handler not found. Please register a handler for the following events: ${eventNames.join(', ')}`);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.EventHandlerNotFound = EventHandlerNotFound;
|
|
11
|
-
//# sourceMappingURL=EventHandlerNotFound.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventHandlerNotFound.js","sourceRoot":"","sources":["../../../../../../packages/core/src/bus/exceptions/EventHandlerNotFound.ts"],"names":[],"mappings":";;;AAAA,iDAAkD;AAElD,MAAa,oBAAqB,SAAQ,2BAAc;IACtD,YAAY,GAAG,UAAoB;QACjC,KAAK,CACH,gFAAgF,UAAU,CAAC,IAAI,CAC7F,IAAI,CACL,EAAE,CACJ,CAAC;IACJ,CAAC;CACF;AARD,oDAQC"}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CommandDispatcher } from '../CommandDispatcher';
|
|
2
|
-
import { EventDispatcher } from '../EventDispatcher';
|
|
3
|
-
import { SecTesterError } from '../../exceptions';
|
|
4
|
-
export declare class IllegalOperation extends SecTesterError {
|
|
5
|
-
constructor(instance: EventDispatcher | CommandDispatcher);
|
|
6
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IllegalOperation = void 0;
|
|
4
|
-
const exceptions_1 = require("../../exceptions");
|
|
5
|
-
const utils_1 = require("../../utils");
|
|
6
|
-
class IllegalOperation extends exceptions_1.SecTesterError {
|
|
7
|
-
constructor(instance) {
|
|
8
|
-
super(`Please make sure that ${(0, utils_1.getTypeName)(instance)} established a connection with host.`);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.IllegalOperation = IllegalOperation;
|
|
12
|
-
//# sourceMappingURL=IllegalOperation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IllegalOperation.js","sourceRoot":"","sources":["../../../../../../packages/core/src/bus/exceptions/IllegalOperation.ts"],"names":[],"mappings":";;;AAEA,iDAAkD;AAClD,uCAA0C;AAE1C,MAAa,gBAAiB,SAAQ,2BAAc;IAClD,YAAY,QAA6C;QACvD,KAAK,CACH,yBAAyB,IAAA,mBAAW,EAClC,QAAQ,CACT,sCAAsC,CACxC,CAAC;IACJ,CAAC;CACF;AARD,4CAQC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NoResponse = void 0;
|
|
4
|
-
const exceptions_1 = require("../../exceptions");
|
|
5
|
-
class NoResponse extends exceptions_1.SecTesterError {
|
|
6
|
-
constructor(duration) {
|
|
7
|
-
super(`No response for ${duration} seconds.`);
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
exports.NoResponse = NoResponse;
|
|
11
|
-
//# sourceMappingURL=NoResponse.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NoResponse.js","sourceRoot":"","sources":["../../../../../../packages/core/src/bus/exceptions/NoResponse.ts"],"names":[],"mappings":";;;AAAA,iDAAkD;AAElD,MAAa,UAAW,SAAQ,2BAAc;IAC5C,YAAY,QAAgB;QAC1B,KAAK,CAAC,mBAAmB,QAAQ,WAAW,CAAC,CAAC;IAChD,CAAC;CACF;AAJD,gCAIC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NoSubscriptionsFound = void 0;
|
|
4
|
-
const exceptions_1 = require("../../exceptions");
|
|
5
|
-
const utils_1 = require("../../utils");
|
|
6
|
-
class NoSubscriptionsFound extends exceptions_1.SecTesterError {
|
|
7
|
-
constructor(handler) {
|
|
8
|
-
super(`No subscriptions found. Please use '@bind()' decorator to subscribe ${(0, utils_1.getTypeName)(handler)} to events.`);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.NoSubscriptionsFound = NoSubscriptionsFound;
|
|
12
|
-
//# sourceMappingURL=NoSubscriptionsFound.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"NoSubscriptionsFound.js","sourceRoot":"","sources":["../../../../../../packages/core/src/bus/exceptions/NoSubscriptionsFound.ts"],"names":[],"mappings":";;;AACA,iDAAkD;AAClD,uCAA0C;AAE1C,MAAa,oBAAqB,SAAQ,2BAAc;IACtD,YAAY,OAAuC;QACjD,KAAK,CACH,uEAAuE,IAAA,mBAAW,EAChF,OAAO,CACR,aAAa,CACf,CAAC;IACJ,CAAC;CACF;AARD,oDAQC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnsupportedEventType = void 0;
|
|
4
|
-
const exceptions_1 = require("../../exceptions");
|
|
5
|
-
const utils_1 = require("../../utils");
|
|
6
|
-
class UnsupportedEventType extends exceptions_1.SecTesterError {
|
|
7
|
-
constructor(event) {
|
|
8
|
-
super(`${(0, utils_1.getTypeName)(event)} cannot be used with the @bind decorator.`);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.UnsupportedEventType = UnsupportedEventType;
|
|
12
|
-
//# sourceMappingURL=UnsupportedEventType.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"UnsupportedEventType.js","sourceRoot":"","sources":["../../../../../../packages/core/src/bus/exceptions/UnsupportedEventType.ts"],"names":[],"mappings":";;;AAAA,iDAAkD;AAClD,uCAA0C;AAE1C,MAAa,oBAAqB,SAAQ,2BAAc;IACtD,YAAY,KAAc;QACxB,KAAK,CAAC,GAAG,IAAA,mBAAW,EAAC,KAAK,CAAC,2CAA2C,CAAC,CAAC;IAC1E,CAAC;CACF;AAJD,oDAIC"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./NoResponse"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./IllegalOperation"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./EventHandlerNotFound"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./NoSubscriptionsFound"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./UnsupportedEventType"), exports);
|
|
9
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../packages/core/src/bus/exceptions/index.ts"],"names":[],"mappings":";;;AAAA,uDAA6B;AAC7B,6DAAmC;AACnC,iEAAuC;AACvC,iEAAuC;AACvC,iEAAuC"}
|
package/src/bus/index.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export * from './Command';
|
|
2
|
-
export * from './CommandDispatcher';
|
|
3
|
-
export * from './Event';
|
|
4
|
-
export * from './Message';
|
|
5
|
-
export * from './EventDispatcher';
|
|
6
|
-
export * from './EventBus';
|
|
7
|
-
export * from './RetryStartegy';
|
|
8
|
-
export * from './EventHandler';
|
|
9
|
-
export * from './exceptions';
|
|
10
|
-
export * from './decorators';
|
package/src/bus/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./Command"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./CommandDispatcher"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./Event"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./Message"), exports);
|
|
8
|
-
tslib_1.__exportStar(require("./EventDispatcher"), exports);
|
|
9
|
-
tslib_1.__exportStar(require("./EventBus"), exports);
|
|
10
|
-
tslib_1.__exportStar(require("./RetryStartegy"), exports);
|
|
11
|
-
tslib_1.__exportStar(require("./EventHandler"), exports);
|
|
12
|
-
tslib_1.__exportStar(require("./exceptions"), exports);
|
|
13
|
-
tslib_1.__exportStar(require("./decorators"), exports);
|
|
14
|
-
//# sourceMappingURL=index.js.map
|
package/src/bus/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/core/src/bus/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B;AAC1B,8DAAoC;AACpC,kDAAwB;AACxB,oDAA0B;AAC1B,4DAAkC;AAClC,qDAA2B;AAC3B,0DAAgC;AAChC,yDAA+B;AAC/B,uDAA6B;AAC7B,uDAA6B"}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|