@opentap/runner-client 2.3.6-alpha.1.1 → 2.4.0-alpha.1
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/lib/BaseClient.d.ts +2 -2
- package/lib/SystemClient.d.ts +18 -0
- package/lib/SystemClient.js +59 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/package.json +2 -2
package/lib/BaseClient.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsListItem, DataGridControl, ErrorResponse, FileParameter, FileResponse, ListItemType, ProfileGroup, RepositoryPackageReference, RepositorySettingsPackageDefinition, SettingsTapPackage } from './DTOs';
|
|
2
|
-
import { ConnectionOptions, Subscription, SubscriptionOptions, PublishOptions } from 'nats.ws';
|
|
2
|
+
import { ConnectionOptions, NatsError, Subscription, SubscriptionOptions, PublishOptions } from 'nats.ws';
|
|
3
3
|
interface BaseClientRequestOptions {
|
|
4
4
|
publishOptions?: PublishOptions;
|
|
5
5
|
rawResponse?: boolean;
|
|
@@ -43,7 +43,7 @@ export declare class BaseClient {
|
|
|
43
43
|
* @param subject
|
|
44
44
|
* @returns
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
protected natsErrorHandler(error: NatsError, subject: string): ErrorResponse;
|
|
47
47
|
/**
|
|
48
48
|
* Build the headers' object.
|
|
49
49
|
* @returns {MsgHdrs} Header object
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BaseClient } from './BaseClient';
|
|
2
|
+
import { ConnectionOptions, Subscription, SubscriptionOptions } from 'nats.ws';
|
|
3
|
+
import { ErrorResponse } from './DTOs';
|
|
4
|
+
export interface RunnerLifetimeEvent {
|
|
5
|
+
RunnerId: string;
|
|
6
|
+
Subject: string;
|
|
7
|
+
Discriminator: string;
|
|
8
|
+
}
|
|
9
|
+
export declare class SystemClient extends BaseClient {
|
|
10
|
+
constructor(baseSubject: string, options: ConnectionOptions);
|
|
11
|
+
/**
|
|
12
|
+
* Subscribe to the lifetime event.
|
|
13
|
+
* @param listener
|
|
14
|
+
* @param {SubscriptionOptions} options
|
|
15
|
+
* @returns {Subscription}
|
|
16
|
+
*/
|
|
17
|
+
subscribeLifetimeEventListener(listener: (error: ErrorResponse | null, message: RunnerLifetimeEvent | null) => void, options?: SubscriptionOptions): Subscription;
|
|
18
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
if (typeof b !== "function" && b !== null)
|
|
10
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
11
|
+
extendStatics(d, b);
|
|
12
|
+
function __() { this.constructor = d; }
|
|
13
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
var __assign = (this && this.__assign) || function () {
|
|
17
|
+
__assign = Object.assign || function(t) {
|
|
18
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
19
|
+
s = arguments[i];
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
21
|
+
t[p] = s[p];
|
|
22
|
+
}
|
|
23
|
+
return t;
|
|
24
|
+
};
|
|
25
|
+
return __assign.apply(this, arguments);
|
|
26
|
+
};
|
|
27
|
+
import { BaseClient } from './BaseClient';
|
|
28
|
+
import { JSONCodec } from 'nats.ws';
|
|
29
|
+
var SystemClient = /** @class */ (function (_super) {
|
|
30
|
+
__extends(SystemClient, _super);
|
|
31
|
+
function SystemClient(baseSubject, options) {
|
|
32
|
+
return _super.call(this, baseSubject, options) || this;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Subscribe to the lifetime event.
|
|
36
|
+
* @param listener
|
|
37
|
+
* @param {SubscriptionOptions} options
|
|
38
|
+
* @returns {Subscription}
|
|
39
|
+
*/
|
|
40
|
+
SystemClient.prototype.subscribeLifetimeEventListener = function (listener, options) {
|
|
41
|
+
var _this = this;
|
|
42
|
+
return this.subscribe('*.Events.Lifetime', __assign(__assign({}, options), { callback: function (error, message) {
|
|
43
|
+
if (error) {
|
|
44
|
+
listener(_this.natsErrorHandler(error, '*.Events.Lifetime'), null);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
var jsonCodec = JSONCodec();
|
|
49
|
+
var data = jsonCodec.decode(message === null || message === void 0 ? void 0 : message.data);
|
|
50
|
+
listener(null, data);
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
listener(_this.natsErrorHandler(error, '*.Events.Lifetime'), null);
|
|
54
|
+
}
|
|
55
|
+
} }));
|
|
56
|
+
};
|
|
57
|
+
return SystemClient;
|
|
58
|
+
}(BaseClient));
|
|
59
|
+
export { SystemClient };
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentap/runner-client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0-alpha.1",
|
|
4
4
|
"description": "This is the web client for the OpenTAP Runner.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -49,4 +49,4 @@
|
|
|
49
49
|
"npm run lint --fix"
|
|
50
50
|
]
|
|
51
51
|
}
|
|
52
|
-
}
|
|
52
|
+
}
|