@opentap/runner-client 2.1.3-alpha.1.4 → 2.1.3-alpha.1.6

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,7 +1,5 @@
1
- /// <reference types="node" />
2
1
  import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsListItem, DataGridControl, ErrorResponse, FileParameter, FileResponse, ListItemType, ProfileGroup, RepositoryPackageReference, RepositorySettingsPackageDefinition, SettingsTapPackage } from './DTOs';
3
2
  import { ConnectionOptions, RequestOptions, Subscription, SubscriptionOptions } from 'nats.ws';
4
- import { EventEmitter } from 'events';
5
3
  export declare class BaseClient {
6
4
  private connection;
7
5
  private baseSubject;
@@ -105,12 +103,12 @@ export declare class BaseClient {
105
103
  * @param listener
106
104
  * @returns {EventEmitter}
107
105
  */
108
- addErrorEventListener(listener: (...args: any[]) => void): EventEmitter;
106
+ addErrorEventListener(listener: (...args: any[]) => void): void;
109
107
  /**
110
108
  * Remove an error-event listener.
111
109
  * @param listener
112
110
  */
113
- removeAllErrorEventListener(): void;
111
+ removeErrorEventListener(listener: (...args: any[]) => void): void;
114
112
  /**
115
113
  * Retrieve component settings overview
116
114
  * @returns {{Promise<ComponentSettingsIdentifier[]>}}
package/lib/BaseClient.js CHANGED
@@ -58,6 +58,10 @@ import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsLi
58
58
  import { Empty, ErrorCode, JSONCodec, StringCodec, connect, headers, } from 'nats.ws';
59
59
  import { EventEmitter } from 'events';
60
60
  var DEFAULT_TIMEOUT = 6000;
61
+ var Events;
62
+ (function (Events) {
63
+ Events["ERROR"] = "error_event";
64
+ })(Events || (Events = {}));
61
65
  var BaseClient = /** @class */ (function () {
62
66
  function BaseClient(baseSubject, options) {
63
67
  this.domainAccess = new Map();
@@ -167,7 +171,7 @@ var BaseClient = /** @class */ (function () {
167
171
  default:
168
172
  errorResponse.message = error.message;
169
173
  }
170
- this.eventEmitter.emit('errorEvent', errorResponse);
174
+ this.eventEmitter.emit(Events.ERROR, errorResponse);
171
175
  return errorResponse;
172
176
  };
173
177
  /**
@@ -275,12 +279,13 @@ var BaseClient = /** @class */ (function () {
275
279
  * @returns Promise of an object
276
280
  */
277
281
  BaseClient.prototype.requestChunked = function (subject, replySubject, payload, options, isFullSubject, rawResponse) {
278
- var _a;
279
282
  return __awaiter(this, void 0, void 0, function () {
280
283
  var fileSize;
281
284
  var _this = this;
282
- return __generator(this, function (_b) {
283
- if ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.isClosed())
285
+ return __generator(this, function (_a) {
286
+ if (!this.connection)
287
+ return [2 /*return*/, Promise.reject("".concat(subject, ": Connection is down! Please try again!"))];
288
+ if (this.connection.isClosed())
284
289
  return [2 /*return*/, Promise.reject("".concat(subject, ": Connection has been closed! Please reconnect!"))];
285
290
  fileSize = -1;
286
291
  return [2 /*return*/, new Promise(function (resolve, reject) {
@@ -384,7 +389,7 @@ var BaseClient = /** @class */ (function () {
384
389
  _this.connection = null;
385
390
  }).catch(function (error) {
386
391
  throw new Error("failed to close connection: ".concat(error));
387
- }).finally(function () { return _this === null || _this === void 0 ? void 0 : _this.removeAllErrorEventListener(); }))];
392
+ }))];
388
393
  case 1:
389
394
  _b.sent();
390
395
  _b.label = 2;
@@ -426,15 +431,15 @@ var BaseClient = /** @class */ (function () {
426
431
  */
427
432
  BaseClient.prototype.addErrorEventListener = function (listener) {
428
433
  var _a;
429
- return (_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.addListener('errorEvent', listener);
434
+ (_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.addListener(Events.ERROR, listener);
430
435
  };
431
436
  /**
432
437
  * Remove an error-event listener.
433
438
  * @param listener
434
439
  */
435
- BaseClient.prototype.removeAllErrorEventListener = function () {
440
+ BaseClient.prototype.removeErrorEventListener = function (listener) {
436
441
  var _a;
437
- (_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.removeAllListeners('errorEvent');
442
+ (_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.removeListener(Events.ERROR, listener);
438
443
  };
439
444
  /**
440
445
  * Retrieve component settings overview
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentap/runner-client",
3
- "version": "2.1.3-alpha.1.4",
3
+ "version": "2.1.3-alpha.1.6",
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",