@opentap/runner-client 2.19.0-alpha.1.1 → 2.19.0-alpha.1.3
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 +1 -0
- package/lib/BaseClient.js +19 -14
- package/lib/SessionClient.js +1 -1
- package/package.json +1 -1
package/lib/BaseClient.d.ts
CHANGED
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.
|
|
265
|
+
if (!this.subscriptionConnection)
|
|
266
266
|
throw Error('Connection is not up yet! Please try again later!');
|
|
267
|
-
if (this.
|
|
267
|
+
if (this.subscriptionConnection.isClosed())
|
|
268
268
|
throw Error('Connection has been closed! Please reconnect!');
|
|
269
269
|
var natsSubject = "".concat(this.baseSubject, ".").concat(subject);
|
|
270
|
-
return this.
|
|
270
|
+
return this.subscriptionConnection.subscribe(natsSubject, options);
|
|
271
271
|
};
|
|
272
272
|
BaseClient.prototype.encode = function (payload) {
|
|
273
273
|
if (!payload) {
|
|
@@ -296,9 +296,11 @@ 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*/, connect(this.connectionOptions)
|
|
300
|
-
.then(function (
|
|
299
|
+
return [4 /*yield*/, Promise.all([connect(this.connectionOptions), connect(this.connectionOptions)])
|
|
300
|
+
.then(function (_a) {
|
|
301
|
+
var connection = _a[0], subscriptionConnection = _a[1];
|
|
301
302
|
_this.connection = connection;
|
|
303
|
+
_this.subscriptionConnection = subscriptionConnection;
|
|
302
304
|
return Promise.resolve();
|
|
303
305
|
})
|
|
304
306
|
.catch(function (error) { return Promise.reject("Failed to connect to ".concat(_this.connectionOptions.servers, " with ").concat(error)); })];
|
|
@@ -315,21 +317,24 @@ var BaseClient = /** @class */ (function () {
|
|
|
315
317
|
* Close the connection.
|
|
316
318
|
*/
|
|
317
319
|
BaseClient.prototype.close = function () {
|
|
318
|
-
var _a;
|
|
320
|
+
var _a, _b;
|
|
319
321
|
return __awaiter(this, void 0, void 0, function () {
|
|
320
322
|
var _this = this;
|
|
321
|
-
return __generator(this, function (
|
|
322
|
-
switch (
|
|
323
|
+
return __generator(this, function (_c) {
|
|
324
|
+
switch (_c.label) {
|
|
323
325
|
case 0:
|
|
324
|
-
if (!this.connection) return [3 /*break*/, 2];
|
|
325
|
-
return [4 /*yield*/, ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.close()
|
|
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 () {
|
|
326
329
|
_this.connection = null;
|
|
327
|
-
|
|
330
|
+
_this.subscriptionConnection = null;
|
|
331
|
+
})
|
|
332
|
+
.catch(function (error) {
|
|
328
333
|
throw new Error("failed to close connection: ".concat(error));
|
|
329
|
-
})
|
|
334
|
+
})];
|
|
330
335
|
case 1:
|
|
331
|
-
|
|
332
|
-
|
|
336
|
+
_c.sent();
|
|
337
|
+
_c.label = 2;
|
|
333
338
|
case 2: return [2 /*return*/];
|
|
334
339
|
}
|
|
335
340
|
});
|
package/lib/SessionClient.js
CHANGED
|
@@ -133,7 +133,7 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
133
133
|
var _this = this;
|
|
134
134
|
var jsonCodec = JSONCodec();
|
|
135
135
|
var resultSubscription = this.subscribe('OnResult', __assign({}, options));
|
|
136
|
-
var testRunSubscription = this.subscribe('
|
|
136
|
+
var testRunSubscription = this.subscribe('OnTestRun', __assign({}, options));
|
|
137
137
|
(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
138
138
|
var resultSubscription_1, resultSubscription_1_1, message, resultJs, result, e_1_1;
|
|
139
139
|
var e_1, _a;
|