@opentap/runner-client 2.1.2 → 2.1.3-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 +14 -0
- package/lib/BaseClient.js +31 -6
- package/lib/DTOs.d.ts +2 -0
- package/lib/DTOs.js +2 -0
- package/package.json +2 -1
package/lib/BaseClient.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsListItem, DataGridControl, ErrorResponse, FileParameter, FileResponse, ListItemType, ProfileGroup, RepositoryPackageReference, RepositorySettingsPackageDefinition, SettingsTapPackage } from './DTOs';
|
|
2
3
|
import { ConnectionOptions, RequestOptions, Subscription, SubscriptionOptions } from 'nats.ws';
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
3
5
|
export declare class BaseClient {
|
|
4
6
|
private connection;
|
|
5
7
|
private baseSubject;
|
|
6
8
|
private connectionOptions;
|
|
7
9
|
private domainAccess;
|
|
10
|
+
private eventEmitter;
|
|
8
11
|
private _accessToken;
|
|
9
12
|
private _headers;
|
|
10
13
|
private _timeout;
|
|
@@ -97,6 +100,17 @@ export declare class BaseClient {
|
|
|
97
100
|
* @returns
|
|
98
101
|
*/
|
|
99
102
|
protected success<T>(): ((value: T) => T | PromiseLike<T>) | null | undefined;
|
|
103
|
+
/**
|
|
104
|
+
* Add an error-event listener.
|
|
105
|
+
* @param listener
|
|
106
|
+
* @returns {EventEmitter}
|
|
107
|
+
*/
|
|
108
|
+
addErrorEventListener(listener: (...args: any[]) => void): EventEmitter;
|
|
109
|
+
/**
|
|
110
|
+
* Remove an error-event listener.
|
|
111
|
+
* @param listener
|
|
112
|
+
*/
|
|
113
|
+
removeAllErrorEventListener(): void;
|
|
100
114
|
/**
|
|
101
115
|
* Retrieve component settings overview
|
|
102
116
|
* @returns {{Promise<ComponentSettingsIdentifier[]>}}
|
package/lib/BaseClient.js
CHANGED
|
@@ -56,6 +56,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
56
56
|
};
|
|
57
57
|
import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsListItem, DataGridControl, ErrorResponse, FileDescriptor, ListItemType, ProfileGroup, } from './DTOs';
|
|
58
58
|
import { Empty, ErrorCode, JSONCodec, StringCodec, connect, headers, } from 'nats.ws';
|
|
59
|
+
import { EventEmitter } from 'events';
|
|
59
60
|
var DEFAULT_TIMEOUT = 6000;
|
|
60
61
|
var BaseClient = /** @class */ (function () {
|
|
61
62
|
function BaseClient(baseSubject, options) {
|
|
@@ -64,6 +65,7 @@ var BaseClient = /** @class */ (function () {
|
|
|
64
65
|
this.baseSubject = baseSubject;
|
|
65
66
|
this.connectionOptions = __assign({}, options) || {};
|
|
66
67
|
this.connectionOptions.timeout = (options === null || options === void 0 ? void 0 : options.timeout) || DEFAULT_TIMEOUT;
|
|
68
|
+
this.eventEmitter = new EventEmitter();
|
|
67
69
|
}
|
|
68
70
|
Object.defineProperty(BaseClient.prototype, "accessToken", {
|
|
69
71
|
/** Get request access token */
|
|
@@ -135,7 +137,11 @@ var BaseClient = /** @class */ (function () {
|
|
|
135
137
|
var jsonCodec = JSONCodec();
|
|
136
138
|
response = jsonCodec.decode(message.data);
|
|
137
139
|
}
|
|
138
|
-
|
|
140
|
+
if (_this.isErrorResponse(response)) {
|
|
141
|
+
_this.eventEmitter.emit('errorEvent', response);
|
|
142
|
+
return Promise.reject(ErrorResponse.fromJS(response));
|
|
143
|
+
}
|
|
144
|
+
return Promise.resolve(response);
|
|
139
145
|
})
|
|
140
146
|
.catch(function (error) { return Promise.reject(_this.natsErrorHandler(error, subject)); })];
|
|
141
147
|
case 1: return [2 /*return*/, _a.sent()];
|
|
@@ -160,6 +166,7 @@ var BaseClient = /** @class */ (function () {
|
|
|
160
166
|
default:
|
|
161
167
|
errorResponse.message = error.message;
|
|
162
168
|
}
|
|
169
|
+
this.eventEmitter.emit('errorEvent', errorResponse);
|
|
163
170
|
return errorResponse;
|
|
164
171
|
};
|
|
165
172
|
/**
|
|
@@ -267,16 +274,17 @@ var BaseClient = /** @class */ (function () {
|
|
|
267
274
|
* @returns Promise of an object
|
|
268
275
|
*/
|
|
269
276
|
BaseClient.prototype.requestChunked = function (subject, replySubject, payload, options, isFullSubject, rawResponse) {
|
|
277
|
+
var _a;
|
|
270
278
|
return __awaiter(this, void 0, void 0, function () {
|
|
271
279
|
var fileSize;
|
|
272
280
|
var _this = this;
|
|
273
|
-
return __generator(this, function (
|
|
274
|
-
if (
|
|
275
|
-
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection is down! Please try again!"))];
|
|
276
|
-
if (this.connection.isClosed())
|
|
281
|
+
return __generator(this, function (_b) {
|
|
282
|
+
if ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.isClosed())
|
|
277
283
|
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection has been closed! Please reconnect!"))];
|
|
278
284
|
fileSize = -1;
|
|
279
285
|
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
286
|
+
if (!_this.connection)
|
|
287
|
+
return Promise.reject("".concat(subject, ": Connection is down! Please try again!"));
|
|
280
288
|
var combinedResult = new Uint8Array([]);
|
|
281
289
|
// Subscribe to the subject before starting the process
|
|
282
290
|
var subscription = _this.connection.subscribe(replySubject);
|
|
@@ -375,7 +383,7 @@ var BaseClient = /** @class */ (function () {
|
|
|
375
383
|
_this.connection = null;
|
|
376
384
|
}).catch(function (error) {
|
|
377
385
|
throw new Error("failed to close connection: ".concat(error));
|
|
378
|
-
}))];
|
|
386
|
+
}).finally(function () { return _this === null || _this === void 0 ? void 0 : _this.removeAllErrorEventListener(); }))];
|
|
379
387
|
case 1:
|
|
380
388
|
_b.sent();
|
|
381
389
|
_b.label = 2;
|
|
@@ -410,6 +418,23 @@ var BaseClient = /** @class */ (function () {
|
|
|
410
418
|
BaseClient.prototype.success = function () {
|
|
411
419
|
return function (response) { return response; };
|
|
412
420
|
};
|
|
421
|
+
/**
|
|
422
|
+
* Add an error-event listener.
|
|
423
|
+
* @param listener
|
|
424
|
+
* @returns {EventEmitter}
|
|
425
|
+
*/
|
|
426
|
+
BaseClient.prototype.addErrorEventListener = function (listener) {
|
|
427
|
+
var _a;
|
|
428
|
+
return (_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.addListener('errorEvent', listener);
|
|
429
|
+
};
|
|
430
|
+
/**
|
|
431
|
+
* Remove an error-event listener.
|
|
432
|
+
* @param listener
|
|
433
|
+
*/
|
|
434
|
+
BaseClient.prototype.removeAllErrorEventListener = function () {
|
|
435
|
+
var _a;
|
|
436
|
+
(_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.removeAllListeners('errorEvent');
|
|
437
|
+
};
|
|
413
438
|
/**
|
|
414
439
|
* Retrieve component settings overview
|
|
415
440
|
* @returns {{Promise<ComponentSettingsIdentifier[]>}}
|
package/lib/DTOs.d.ts
CHANGED
|
@@ -803,6 +803,7 @@ export declare class TestStep implements ITestStep {
|
|
|
803
803
|
typeName?: string | undefined;
|
|
804
804
|
typeDisplay?: DisplayAttribute | undefined;
|
|
805
805
|
name?: string | undefined;
|
|
806
|
+
expandedName?: string | undefined;
|
|
806
807
|
protected _discriminator: string;
|
|
807
808
|
constructor(data?: ITestStep);
|
|
808
809
|
init(_data?: any): void;
|
|
@@ -818,6 +819,7 @@ export interface ITestStep {
|
|
|
818
819
|
typeName?: string | undefined;
|
|
819
820
|
typeDisplay?: DisplayAttribute | undefined;
|
|
820
821
|
name?: string | undefined;
|
|
822
|
+
expandedName?: string | undefined;
|
|
821
823
|
}
|
|
822
824
|
export declare class TestStepType extends TestStep implements ITestStepType {
|
|
823
825
|
availableChildrenTypes?: string[] | undefined;
|
package/lib/DTOs.js
CHANGED
|
@@ -2300,6 +2300,7 @@ var TestStep = /** @class */ (function () {
|
|
|
2300
2300
|
this.typeName = _data['TypeName'];
|
|
2301
2301
|
this.typeDisplay = _data['TypeDisplay'] ? DisplayAttribute.fromJS(_data['TypeDisplay']) : undefined;
|
|
2302
2302
|
this.name = _data['Name'];
|
|
2303
|
+
this.expandedName = _data['ExpandedName'];
|
|
2303
2304
|
}
|
|
2304
2305
|
};
|
|
2305
2306
|
TestStep.fromJS = function (data) {
|
|
@@ -2336,6 +2337,7 @@ var TestStep = /** @class */ (function () {
|
|
|
2336
2337
|
data['TypeName'] = this.typeName;
|
|
2337
2338
|
data['TypeDisplay'] = this.typeDisplay ? this.typeDisplay.toJSON() : undefined;
|
|
2338
2339
|
data['Name'] = this.name;
|
|
2340
|
+
data['ExpandedName'] = this.expandedName;
|
|
2339
2341
|
return data;
|
|
2340
2342
|
};
|
|
2341
2343
|
return TestStep;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentap/runner-client",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3-alpha.1.3",
|
|
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",
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"url": "git://github.com/opentap/runner-client-web.git"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
|
+
"@types/node": "^18.11.9",
|
|
29
30
|
"@types/uuid": "^8.3.4",
|
|
30
31
|
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
|
31
32
|
"@typescript-eslint/parser": "^5.36.1",
|