@opentap/runner-client 2.19.0-alpha.1.3 → 2.19.0-alpha.1.5

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.
@@ -9,7 +9,6 @@ interface BaseClientRequestOptions {
9
9
  }
10
10
  export declare class BaseClient {
11
11
  private connection;
12
- private subscriptionConnection;
13
12
  private baseSubject;
14
13
  private connectionOptions;
15
14
  private domainAccess;
package/lib/BaseClient.js CHANGED
@@ -262,12 +262,12 @@ var BaseClient = /** @class */ (function () {
262
262
  BaseClient.prototype.subscribe = function (subject, options) {
263
263
  if (!subject)
264
264
  throw Error('Subject is not defined!');
265
- if (!this.subscriptionConnection)
265
+ if (!this.connection)
266
266
  throw Error('Connection is not up yet! Please try again later!');
267
- if (this.subscriptionConnection.isClosed())
267
+ if (this.connection.isClosed())
268
268
  throw Error('Connection has been closed! Please reconnect!');
269
269
  var natsSubject = "".concat(this.baseSubject, ".").concat(subject);
270
- return this.subscriptionConnection.subscribe(natsSubject, options);
270
+ return this.connection.subscribe(natsSubject, options);
271
271
  };
272
272
  BaseClient.prototype.encode = function (payload) {
273
273
  if (!payload) {
@@ -296,11 +296,9 @@ var BaseClient = /** @class */ (function () {
296
296
  _a.label = 1;
297
297
  case 1:
298
298
  _a.trys.push([1, 3, , 4]);
299
- return [4 /*yield*/, Promise.all([connect(this.connectionOptions), connect(this.connectionOptions)])
300
- .then(function (_a) {
301
- var connection = _a[0], subscriptionConnection = _a[1];
299
+ return [4 /*yield*/, connect(this.connectionOptions)
300
+ .then(function (connection) {
302
301
  _this.connection = connection;
303
- _this.subscriptionConnection = subscriptionConnection;
304
302
  return Promise.resolve();
305
303
  })
306
304
  .catch(function (error) { return Promise.reject("Failed to connect to ".concat(_this.connectionOptions.servers, " with ").concat(error)); })];
@@ -317,24 +315,21 @@ var BaseClient = /** @class */ (function () {
317
315
  * Close the connection.
318
316
  */
319
317
  BaseClient.prototype.close = function () {
320
- var _a, _b;
318
+ var _a;
321
319
  return __awaiter(this, void 0, void 0, function () {
322
320
  var _this = this;
323
- return __generator(this, function (_c) {
324
- switch (_c.label) {
321
+ return __generator(this, function (_b) {
322
+ switch (_b.label) {
325
323
  case 0:
326
- if (!(this.connection || this.subscriptionConnection)) return [3 /*break*/, 2];
327
- return [4 /*yield*/, Promise.all([(_a = this.connection) === null || _a === void 0 ? void 0 : _a.close(), (_b = this.subscriptionConnection) === null || _b === void 0 ? void 0 : _b.close()])
328
- .then(function () {
324
+ if (!this.connection) return [3 /*break*/, 2];
325
+ return [4 /*yield*/, ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.close().then(function () {
329
326
  _this.connection = null;
330
- _this.subscriptionConnection = null;
331
- })
332
- .catch(function (error) {
327
+ }).catch(function (error) {
333
328
  throw new Error("failed to close connection: ".concat(error));
334
- })];
329
+ }))];
335
330
  case 1:
336
- _c.sent();
337
- _c.label = 2;
331
+ _b.sent();
332
+ _b.label = 2;
338
333
  case 2: return [2 /*return*/];
339
334
  }
340
335
  });
@@ -1,4 +1,4 @@
1
- import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Interaction, ListItemType, LogList, Parameter, RepositoryPackageDefinition, RepositoryPackageReference, Result, Resource, RunStatus, SessionEvent, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog } from './DTOs';
1
+ import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Interaction, ListItemType, LogList, Parameter, RepositoryPackageDefinition, RepositoryPackageReference, Result, Resource, RunStatus, SessionEvent, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog, TestPlanRunEvent } from './DTOs';
2
2
  import { ConnectionOptions, NatsError, Subscription, SubscriptionOptions } from 'nats.ws';
3
3
  import { BaseClient } from './BaseClient';
4
4
  export declare class SessionClient extends BaseClient {
@@ -23,6 +23,59 @@ export declare class SessionClient extends BaseClient {
23
23
  * @returns Subscription array: Result and Test Run subscriptions
24
24
  */
25
25
  connectSessionResults(resultHandler: (result: Result | undefined, err: NatsError | Error | null) => void, testRunHandler: (testRun: TestRun | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): [Subscription, Subscription];
26
+ connectTestStepRunStartedEvents(resultHandler: (result: Result | undefined, err: NatsError | Error | null) => void, testRunHandler: (testRun: TestRun | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): [Subscription, Subscription];
27
+ /**
28
+ * Connect to listen to the TestPlanRun events for the given test plan run ID.
29
+ * @param {string} testPlanRunId
30
+ * @param {(event:TestPlanRunEvent|undefined,err:NatsError|Error|null)=>void} handler
31
+ * @param {SubscriptionOptions} options?
32
+ * @returns Subscription
33
+ */
34
+ connectTestPlanRunEvents(testPlanRunId: string, handler: (event: TestPlanRunEvent | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
35
+ /**
36
+ * Connect to listen to the test plan run logs for the given test plan run ID
37
+ * @param {string} testPlanRunId
38
+ * @param {(logList:LogList|undefined,err:NatsError|Error|null)=>void} handler
39
+ * @param {SubscriptionOptions} options?
40
+ * @returns Subscription
41
+ */
42
+ connectTestPlanRunLogs(testPlanRunId: string, handler: (logList: LogList | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
43
+ /**
44
+ * Connect to listen to the test plan run parameter events for the given test plan run ID
45
+ * @param {string} testPlanRunId
46
+ * @param {(event:Parameter[]|undefined,err:NatsError|Error|null)=>void} handler
47
+ * @param {SubscriptionOptions} options?
48
+ * @returns Subscription
49
+ */
50
+ connectTestPlanRunParameterEvents(testPlanRunId: string, handler: (event: Parameter[] | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
51
+ /**
52
+ * Connect to listen to the test step run events for the given test step and test plan run ID
53
+ * @param {string} testPlanRunId
54
+ * @param {string} testStepRunId
55
+ * @param {(testRun:TestStepRunEvent|undefined,err:NatsError|Error|null)=>void} handler
56
+ * @param {SubscriptionOptions} options?
57
+ * @returns Subscription
58
+ */
59
+ connectTestStepRunEvents(testPlanRunId: string, testStepRunId: string, handler: (testStepRunId: string | undefined, testRun: TestRun | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
60
+ /**
61
+ * Connect to listen to the test step run parameters for the given test step and test plan run ID
62
+ * @param {string} testPlanRunId
63
+ * @param {string} testStepRunId
64
+ * @param {(event:Parameter[]|undefined,err:NatsError|Error|null)=>void} handler
65
+ * @param {SubscriptionOptions} options?
66
+ * @returns Subscription
67
+ */
68
+ connectTestStepRunParameterEvents(testPlanRunId: string, testStepRunId: string, handler: (event: Parameter[] | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
69
+ /**
70
+ * Connect to listen to the test step run results for the given test step and test plan run ID
71
+ * @param {string} testPlanRunId
72
+ * @param {string} testStepRunId
73
+ * @param {string} resultName
74
+ * @param {(result:Result|undefined,err:NatsError|Error|null)=>void} handler
75
+ * @param {SubscriptionOptions} options?
76
+ * @returns Subscription
77
+ */
78
+ connectTestStepRunResults(testPlanRunId: string, testStepRunId: string, resultName: string, handler: (result: Result | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
26
79
  /**
27
80
  * Unsubscibe from session events
28
81
  */
@@ -24,50 +24,7 @@ var __assign = (this && this.__assign) || function () {
24
24
  };
25
25
  return __assign.apply(this, arguments);
26
26
  };
27
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
- return new (P || (P = Promise))(function (resolve, reject) {
30
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
- step((generator = generator.apply(thisArg, _arguments || [])).next());
34
- });
35
- };
36
- var __generator = (this && this.__generator) || function (thisArg, body) {
37
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
38
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
39
- function verb(n) { return function (v) { return step([n, v]); }; }
40
- function step(op) {
41
- if (f) throw new TypeError("Generator is already executing.");
42
- while (_) try {
43
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
44
- if (y = 0, t) op = [op[0] & 2, t.value];
45
- switch (op[0]) {
46
- case 0: case 1: t = op; break;
47
- case 4: _.label++; return { value: op[1], done: false };
48
- case 5: _.label++; y = op[1]; op = [0]; continue;
49
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
50
- default:
51
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
52
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
53
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
54
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
55
- if (t[2]) _.ops.pop();
56
- _.trys.pop(); continue;
57
- }
58
- op = body.call(thisArg, _);
59
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
60
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
61
- }
62
- };
63
- var __asyncValues = (this && this.__asyncValues) || function (o) {
64
- if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
65
- var m = o[Symbol.asyncIterator], i;
66
- return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
67
- function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
68
- function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
69
- };
70
- import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Interaction, ListItemType, LogList, Result, RunStatus, SessionEvent, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog, } from './DTOs';
27
+ import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Interaction, ListItemType, LogList, Parameter, Result, RunStatus, SessionEvent, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog, TestPlanRunEvent, } from './DTOs';
71
28
  import { JSONCodec } from 'nats.ws';
72
29
  import { BaseClient } from './BaseClient';
73
30
  var SessionClient = /** @class */ (function (_super) {
@@ -130,99 +87,222 @@ var SessionClient = /** @class */ (function (_super) {
130
87
  * @returns Subscription array: Result and Test Run subscriptions
131
88
  */
132
89
  SessionClient.prototype.connectSessionResults = function (resultHandler, testRunHandler, options) {
133
- var _this = this;
134
- var jsonCodec = JSONCodec();
135
- var resultSubscription = this.subscribe('OnResult', __assign({}, options));
136
- var testRunSubscription = this.subscribe('OnTestRun', __assign({}, options));
137
- (function () { return __awaiter(_this, void 0, void 0, function () {
138
- var resultSubscription_1, resultSubscription_1_1, message, resultJs, result, e_1_1;
139
- var e_1, _a;
140
- return __generator(this, function (_b) {
141
- switch (_b.label) {
142
- case 0:
143
- _b.trys.push([0, 5, 6, 11]);
144
- resultSubscription_1 = __asyncValues(resultSubscription);
145
- _b.label = 1;
146
- case 1: return [4 /*yield*/, resultSubscription_1.next()];
147
- case 2:
148
- if (!(resultSubscription_1_1 = _b.sent(), !resultSubscription_1_1.done)) return [3 /*break*/, 4];
149
- message = resultSubscription_1_1.value;
150
- try {
151
- resultJs = jsonCodec.decode(message === null || message === void 0 ? void 0 : message.data);
152
- result = Result.fromJS(resultJs);
153
- resultHandler(result, null);
154
- }
155
- catch (error) {
156
- resultHandler(undefined, error);
157
- }
158
- _b.label = 3;
159
- case 3: return [3 /*break*/, 1];
160
- case 4: return [3 /*break*/, 11];
161
- case 5:
162
- e_1_1 = _b.sent();
163
- e_1 = { error: e_1_1 };
164
- return [3 /*break*/, 11];
165
- case 6:
166
- _b.trys.push([6, , 9, 10]);
167
- if (!(resultSubscription_1_1 && !resultSubscription_1_1.done && (_a = resultSubscription_1.return))) return [3 /*break*/, 8];
168
- return [4 /*yield*/, _a.call(resultSubscription_1)];
169
- case 7:
170
- _b.sent();
171
- _b.label = 8;
172
- case 8: return [3 /*break*/, 10];
173
- case 9:
174
- if (e_1) throw e_1.error;
175
- return [7 /*endfinally*/];
176
- case 10: return [7 /*endfinally*/];
177
- case 11: return [2 /*return*/];
90
+ return [
91
+ this.subscribe('OnResult', __assign(__assign({}, options), { callback: function (error, encodedMessage) {
92
+ if (error) {
93
+ resultHandler(undefined, error);
94
+ return;
95
+ }
96
+ try {
97
+ var jsonCodec = JSONCodec();
98
+ var resultJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
99
+ var result = Result.fromJS(resultJs);
100
+ resultHandler(result, error);
101
+ }
102
+ catch (error) {
103
+ resultHandler(undefined, error);
104
+ }
105
+ } })),
106
+ this.subscribe('OnTestRun', __assign(__assign({}, options), { callback: function (error, encodedMessage) {
107
+ if (error) {
108
+ testRunHandler(undefined, error);
109
+ return;
110
+ }
111
+ try {
112
+ var jsonCodec = JSONCodec();
113
+ var testRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
114
+ var testRun = TestRun.fromJS(testRunJs);
115
+ testRunHandler(testRun, error);
116
+ }
117
+ catch (error) {
118
+ testRunHandler(undefined, error);
119
+ }
120
+ } })),
121
+ ];
122
+ };
123
+ SessionClient.prototype.connectTestStepRunStartedEvents = function (resultHandler, testRunHandler, options) {
124
+ return [
125
+ this.subscribe('OnResult', __assign(__assign({}, options), { callback: function (error, encodedMessage) {
126
+ if (error) {
127
+ resultHandler(undefined, error);
128
+ return;
129
+ }
130
+ try {
131
+ var jsonCodec = JSONCodec();
132
+ var resultJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
133
+ var result = Result.fromJS(resultJs);
134
+ resultHandler(result, error);
135
+ }
136
+ catch (error) {
137
+ resultHandler(undefined, error);
138
+ }
139
+ } })),
140
+ this.subscribe('OnTestRun', __assign(__assign({}, options), { callback: function (error, encodedMessage) {
141
+ if (error) {
142
+ testRunHandler(undefined, error);
143
+ return;
144
+ }
145
+ try {
146
+ var jsonCodec = JSONCodec();
147
+ var testRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
148
+ var testRun = TestRun.fromJS(testRunJs);
149
+ testRunHandler(testRun, error);
150
+ }
151
+ catch (error) {
152
+ testRunHandler(undefined, error);
153
+ }
154
+ } })),
155
+ ];
156
+ };
157
+ /**
158
+ * Connect to listen to the TestPlanRun events for the given test plan run ID.
159
+ * @param {string} testPlanRunId
160
+ * @param {(event:TestPlanRunEvent|undefined,err:NatsError|Error|null)=>void} handler
161
+ * @param {SubscriptionOptions} options?
162
+ * @returns Subscription
163
+ */
164
+ SessionClient.prototype.connectTestPlanRunEvents = function (testPlanRunId, handler, options) {
165
+ return this.subscribe("PlanRun.".concat(testPlanRunId), __assign(__assign({}, options), { callback: function (error, encodedMessage) {
166
+ if (error) {
167
+ handler(undefined, error);
168
+ return;
169
+ }
170
+ try {
171
+ var jsonCodec = JSONCodec();
172
+ var testPlanRunEventJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
173
+ var testPlanRunEvent = TestPlanRunEvent.fromJS(testPlanRunEventJs);
174
+ handler(testPlanRunEvent, error);
175
+ }
176
+ catch (error) {
177
+ handler(undefined, error);
178
+ }
179
+ } }));
180
+ };
181
+ /**
182
+ * Connect to listen to the test plan run logs for the given test plan run ID
183
+ * @param {string} testPlanRunId
184
+ * @param {(logList:LogList|undefined,err:NatsError|Error|null)=>void} handler
185
+ * @param {SubscriptionOptions} options?
186
+ * @returns Subscription
187
+ */
188
+ SessionClient.prototype.connectTestPlanRunLogs = function (testPlanRunId, handler, options) {
189
+ return this.subscribe("PlanRun.".concat(testPlanRunId, ".Logs"), __assign(__assign({}, options), { callback: function (error, encodedMessage) {
190
+ if (error) {
191
+ handler(undefined, error);
192
+ return;
193
+ }
194
+ try {
195
+ var jsonCodec = JSONCodec();
196
+ var logListJson = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
197
+ var logList = LogList.fromJS(logListJson);
198
+ handler(logList, error);
199
+ }
200
+ catch (error) {
201
+ handler(undefined, error);
202
+ }
203
+ } }));
204
+ };
205
+ /**
206
+ * Connect to listen to the test plan run parameter events for the given test plan run ID
207
+ * @param {string} testPlanRunId
208
+ * @param {(event:Parameter[]|undefined,err:NatsError|Error|null)=>void} handler
209
+ * @param {SubscriptionOptions} options?
210
+ * @returns Subscription
211
+ */
212
+ SessionClient.prototype.connectTestPlanRunParameterEvents = function (testPlanRunId, handler, options) {
213
+ return this.subscribe("PlanRun.".concat(testPlanRunId, ".Parameters"), __assign(__assign({}, options), { callback: function (error, encodedMessage) {
214
+ if (error) {
215
+ handler(undefined, error);
216
+ return;
217
+ }
218
+ try {
219
+ var jsonCodec = JSONCodec();
220
+ var parameterListJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
221
+ var parameterList = parameterListJs.map(function (parameterJs) { return Parameter.fromJS(parameterJs); });
222
+ handler(parameterList, error);
223
+ }
224
+ catch (error) {
225
+ handler(undefined, error);
226
+ }
227
+ } }));
228
+ };
229
+ /**
230
+ * Connect to listen to the test step run events for the given test step and test plan run ID
231
+ * @param {string} testPlanRunId
232
+ * @param {string} testStepRunId
233
+ * @param {(testRun:TestStepRunEvent|undefined,err:NatsError|Error|null)=>void} handler
234
+ * @param {SubscriptionOptions} options?
235
+ * @returns Subscription
236
+ */
237
+ SessionClient.prototype.connectTestStepRunEvents = function (testPlanRunId, testStepRunId, handler, options) {
238
+ return this.subscribe("PlanRun.".concat(testPlanRunId, ".StepRun.").concat(testStepRunId), __assign(__assign({}, options), { callback: function (error, encodedMessage) {
239
+ var _a;
240
+ if (error) {
241
+ handler(undefined, undefined, error);
242
+ return;
178
243
  }
179
- });
180
- }); })();
181
- (function () { return __awaiter(_this, void 0, void 0, function () {
182
- var testRunSubscription_1, testRunSubscription_1_1, message, testRunJs, testRun, e_2_1;
183
- var e_2, _a;
184
- return __generator(this, function (_b) {
185
- switch (_b.label) {
186
- case 0:
187
- _b.trys.push([0, 5, 6, 11]);
188
- testRunSubscription_1 = __asyncValues(testRunSubscription);
189
- _b.label = 1;
190
- case 1: return [4 /*yield*/, testRunSubscription_1.next()];
191
- case 2:
192
- if (!(testRunSubscription_1_1 = _b.sent(), !testRunSubscription_1_1.done)) return [3 /*break*/, 4];
193
- message = testRunSubscription_1_1.value;
194
- try {
195
- testRunJs = jsonCodec.decode(message === null || message === void 0 ? void 0 : message.data);
196
- testRun = TestRun.fromJS(testRunJs);
197
- testRunHandler(testRun, null);
198
- }
199
- catch (error) {
200
- testRunHandler(undefined, error);
201
- }
202
- _b.label = 3;
203
- case 3: return [3 /*break*/, 1];
204
- case 4: return [3 /*break*/, 11];
205
- case 5:
206
- e_2_1 = _b.sent();
207
- e_2 = { error: e_2_1 };
208
- return [3 /*break*/, 11];
209
- case 6:
210
- _b.trys.push([6, , 9, 10]);
211
- if (!(testRunSubscription_1_1 && !testRunSubscription_1_1.done && (_a = testRunSubscription_1.return))) return [3 /*break*/, 8];
212
- return [4 /*yield*/, _a.call(testRunSubscription_1)];
213
- case 7:
214
- _b.sent();
215
- _b.label = 8;
216
- case 8: return [3 /*break*/, 10];
217
- case 9:
218
- if (e_2) throw e_2.error;
219
- return [7 /*endfinally*/];
220
- case 10: return [7 /*endfinally*/];
221
- case 11: return [2 /*return*/];
244
+ try {
245
+ var jsonCodec = JSONCodec();
246
+ var testRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
247
+ var testRun = TestRun.fromJS(testRunJs);
248
+ var stepRunId = (_a = encodedMessage.subject.match(/\.StepRun\.(.+)$/)) === null || _a === void 0 ? void 0 : _a[0];
249
+ handler(stepRunId, testRun, error);
250
+ }
251
+ catch (error) {
252
+ handler(undefined, undefined, error);
253
+ }
254
+ } }));
255
+ };
256
+ /**
257
+ * Connect to listen to the test step run parameters for the given test step and test plan run ID
258
+ * @param {string} testPlanRunId
259
+ * @param {string} testStepRunId
260
+ * @param {(event:Parameter[]|undefined,err:NatsError|Error|null)=>void} handler
261
+ * @param {SubscriptionOptions} options?
262
+ * @returns Subscription
263
+ */
264
+ SessionClient.prototype.connectTestStepRunParameterEvents = function (testPlanRunId, testStepRunId, handler, options) {
265
+ return this.subscribe("PlanRun.".concat(testPlanRunId, ".StepRun.").concat(testStepRunId, ".Parameters"), __assign(__assign({}, options), { callback: function (error, encodedMessage) {
266
+ if (error) {
267
+ handler(undefined, error);
268
+ return;
222
269
  }
223
- });
224
- }); })();
225
- return [resultSubscription, testRunSubscription];
270
+ try {
271
+ var jsonCodec = JSONCodec();
272
+ var parameterListJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
273
+ var parameterList = parameterListJs.map(function (parameterJs) { return Parameter.fromJS(parameterJs); });
274
+ handler(parameterList, error);
275
+ }
276
+ catch (error) {
277
+ handler(undefined, error);
278
+ }
279
+ } }));
280
+ };
281
+ /**
282
+ * Connect to listen to the test step run results for the given test step and test plan run ID
283
+ * @param {string} testPlanRunId
284
+ * @param {string} testStepRunId
285
+ * @param {string} resultName
286
+ * @param {(result:Result|undefined,err:NatsError|Error|null)=>void} handler
287
+ * @param {SubscriptionOptions} options?
288
+ * @returns Subscription
289
+ */
290
+ SessionClient.prototype.connectTestStepRunResults = function (testPlanRunId, testStepRunId, resultName, handler, options) {
291
+ return this.subscribe("PlanRun.".concat(testPlanRunId, ".StepRun.").concat(testStepRunId, ".Result.").concat(resultName), __assign(__assign({}, options), { callback: function (error, encodedMessage) {
292
+ if (error) {
293
+ handler(undefined, error);
294
+ return;
295
+ }
296
+ try {
297
+ var jsonCodec = JSONCodec();
298
+ var resultJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
299
+ var result = Result.fromJS(resultJs);
300
+ handler(result, error);
301
+ }
302
+ catch (error) {
303
+ handler(undefined, error);
304
+ }
305
+ } }));
226
306
  };
227
307
  /**
228
308
  * Unsubscibe from session events
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentap/runner-client",
3
- "version": "2.19.0-alpha.1.3",
3
+ "version": "2.19.0-alpha.1.5",
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",