@opentap/runner-client 2.4.0 → 2.5.0-alpha.1.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.
@@ -1,6 +1,6 @@
1
1
  import { BaseClient } from './BaseClient';
2
2
  import { ConnectionOptions, Subscription, SubscriptionOptions } from 'nats.ws';
3
- import { ErrorResponse } from './DTOs';
3
+ import { ErrorResponse, ISessionEvent } from './DTOs';
4
4
  export interface RunnerLifetimeEvent {
5
5
  RunnerId: string;
6
6
  Subject: string;
@@ -15,4 +15,12 @@ export declare class SystemClient extends BaseClient {
15
15
  * @returns {Subscription}
16
16
  */
17
17
  subscribeLifetimeEventListener(listener: (error: ErrorResponse | null, message: RunnerLifetimeEvent | null) => void, options?: SubscriptionOptions): Subscription;
18
+ /**
19
+ * Subscribe to the lifetime event.
20
+ * @param listener
21
+ * @param {SubscriptionOptions} options
22
+ * @returns {Subscription}
23
+ */
24
+ subscribeTestPlanRunStartedEventListener(runnerId: string, runId: string, listener: (error: ErrorResponse | null, message: ISessionEvent | null) => void, options?: SubscriptionOptions): Subscription;
25
+ private parseCallbackArguments;
18
26
  }
@@ -40,20 +40,34 @@ var SystemClient = /** @class */ (function (_super) {
40
40
  SystemClient.prototype.subscribeLifetimeEventListener = function (listener, options) {
41
41
  var _this = this;
42
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
- }
43
+ listener.apply(void 0, _this.parseCallbackArguments('*.Events.Lifetime', error, message));
55
44
  } }));
56
45
  };
46
+ /**
47
+ * Subscribe to the lifetime event.
48
+ * @param listener
49
+ * @param {SubscriptionOptions} options
50
+ * @returns {Subscription}
51
+ */
52
+ SystemClient.prototype.subscribeTestPlanRunStartedEventListener = function (runnerId, runId, listener, options) {
53
+ var _this = this;
54
+ return this.subscribe("".concat(runnerId, ".Runs.").concat(runId, ".Events.*"), __assign(__assign({}, options), { callback: function (error, message) {
55
+ listener.apply(void 0, _this.parseCallbackArguments('*.Events.Lifetime', error, message));
56
+ } }));
57
+ };
58
+ SystemClient.prototype.parseCallbackArguments = function (subject, error, message) {
59
+ if (error) {
60
+ return [this.natsErrorHandler(error, subject), null];
61
+ }
62
+ try {
63
+ var jsonCodec = JSONCodec();
64
+ var data = jsonCodec.decode(message === null || message === void 0 ? void 0 : message.data);
65
+ return [null, data];
66
+ }
67
+ catch (error) {
68
+ return [this.natsErrorHandler(error, subject), null];
69
+ }
70
+ };
57
71
  return SystemClient;
58
72
  }(BaseClient));
59
73
  export { SystemClient };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentap/runner-client",
3
- "version": "2.4.0",
3
+ "version": "2.5.0-alpha.1.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",