@opentap/runner-client 2.0.2-alpha.1.1 → 2.0.2-alpha.1.2
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 +19 -1
- package/lib/BaseClient.js +136 -3
- package/lib/DTOs.d.ts +47 -0
- package/lib/DTOs.js +163 -58
- package/lib/SessionClient.d.ts +6 -1
- package/lib/SessionClient.js +32 -6
- package/package.json +4 -2
package/lib/BaseClient.d.ts
CHANGED
|
@@ -26,9 +26,11 @@ export declare class BaseClient {
|
|
|
26
26
|
* @param subject The subject to request
|
|
27
27
|
* @param payload (optional)
|
|
28
28
|
* @param options (optional)
|
|
29
|
+
* @param isFullSubject (optional) If true, use the subject as request subject
|
|
30
|
+
* without appending it to the baseSubject
|
|
29
31
|
* @returns Promise of an object
|
|
30
32
|
*/
|
|
31
|
-
protected request<T>(subject: string, payload?: any, options?: RequestOptions): Promise<T>;
|
|
33
|
+
protected request<T>(subject: string, payload?: any, options?: RequestOptions, isFullSubject?: boolean): Promise<T>;
|
|
32
34
|
/**
|
|
33
35
|
* Handle the error
|
|
34
36
|
* @param error
|
|
@@ -48,6 +50,22 @@ export declare class BaseClient {
|
|
|
48
50
|
* @returns Subscription object
|
|
49
51
|
*/
|
|
50
52
|
protected subscribe(subject: string, options: SubscriptionOptions): Subscription;
|
|
53
|
+
/**
|
|
54
|
+
* Send an object to the nats server with chunks.
|
|
55
|
+
* @param subject The subject to request
|
|
56
|
+
* @param payload (optional)
|
|
57
|
+
* @param options (optional)
|
|
58
|
+
* @returns Promise of an object
|
|
59
|
+
*/
|
|
60
|
+
protected sendChunked<T>(subject: string, payload?: any, options?: RequestOptions): Promise<T>;
|
|
61
|
+
/**
|
|
62
|
+
* Request an object to the nats server with chunks.
|
|
63
|
+
* @param subject The subject to request
|
|
64
|
+
* @param payload (optional)
|
|
65
|
+
* @param options (optional)
|
|
66
|
+
* @returns Promise of an object
|
|
67
|
+
*/
|
|
68
|
+
protected requestChunked<T>(subject: string, replySubject: string, payload: any, options?: RequestOptions, isFullSubject?: boolean, rawResponse?: boolean): Promise<T>;
|
|
51
69
|
/**
|
|
52
70
|
* Check if the the response is an error from the server.
|
|
53
71
|
* @param {any} response
|
package/lib/BaseClient.js
CHANGED
|
@@ -45,7 +45,16 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
45
45
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
49
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
50
|
+
if (ar || !(i in from)) {
|
|
51
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
52
|
+
ar[i] = from[i];
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
|
+
};
|
|
57
|
+
import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsListItem, DataGridControl, ErrorResponse, FileDescriptor, ListItemType, ProfileGroup, } from './DTOs';
|
|
49
58
|
import { Empty, ErrorCode, JSONCodec, StringCodec, connect, headers, } from 'nats.ws';
|
|
50
59
|
var DEFAULT_TIMEOUT = 6000;
|
|
51
60
|
var BaseClient = /** @class */ (function () {
|
|
@@ -97,16 +106,18 @@ var BaseClient = /** @class */ (function () {
|
|
|
97
106
|
* @param subject The subject to request
|
|
98
107
|
* @param payload (optional)
|
|
99
108
|
* @param options (optional)
|
|
109
|
+
* @param isFullSubject (optional) If true, use the subject as request subject
|
|
110
|
+
* without appending it to the baseSubject
|
|
100
111
|
* @returns Promise of an object
|
|
101
112
|
*/
|
|
102
|
-
BaseClient.prototype.request = function (subject, payload, options) {
|
|
113
|
+
BaseClient.prototype.request = function (subject, payload, options, isFullSubject) {
|
|
103
114
|
return __awaiter(this, void 0, void 0, function () {
|
|
104
115
|
var stringCodec, data, headers, opts;
|
|
105
116
|
var _this = this;
|
|
106
117
|
return __generator(this, function (_a) {
|
|
107
118
|
switch (_a.label) {
|
|
108
119
|
case 0:
|
|
109
|
-
subject = "".concat(this.baseSubject, ".Request.").concat(subject);
|
|
120
|
+
subject = isFullSubject ? subject : "".concat(this.baseSubject, ".Request.").concat(subject);
|
|
110
121
|
if (!this.connection)
|
|
111
122
|
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection is down! Please try again!"))];
|
|
112
123
|
if (this.connection.isClosed())
|
|
@@ -178,6 +189,128 @@ var BaseClient = /** @class */ (function () {
|
|
|
178
189
|
var natsSubject = "".concat(this.baseSubject, ".").concat(subject);
|
|
179
190
|
return this.connection.subscribe(natsSubject, options);
|
|
180
191
|
};
|
|
192
|
+
/**
|
|
193
|
+
* Send an object to the nats server with chunks.
|
|
194
|
+
* @param subject The subject to request
|
|
195
|
+
* @param payload (optional)
|
|
196
|
+
* @param options (optional)
|
|
197
|
+
* @returns Promise of an object
|
|
198
|
+
*/
|
|
199
|
+
BaseClient.prototype.sendChunked = function (subject, payload, options) {
|
|
200
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
201
|
+
var stringCodec, data, headers, opts, fileDescriptor, getChunk, dataSubject, i;
|
|
202
|
+
var _this = this;
|
|
203
|
+
return __generator(this, function (_a) {
|
|
204
|
+
switch (_a.label) {
|
|
205
|
+
case 0:
|
|
206
|
+
if (!this.connection)
|
|
207
|
+
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection is down! Please try again!"))];
|
|
208
|
+
if (this.connection.isClosed())
|
|
209
|
+
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection has been closed! Please reconnect!"))];
|
|
210
|
+
stringCodec = StringCodec();
|
|
211
|
+
data = payload ? stringCodec.encode(JSON.stringify(payload)) : Empty;
|
|
212
|
+
headers = this.buildHeaders();
|
|
213
|
+
opts = __assign(__assign({}, options), { timeout: this.timeout, headers: headers });
|
|
214
|
+
fileDescriptor = new FileDescriptor(data.length);
|
|
215
|
+
if (!fileDescriptor.numberOfChunks)
|
|
216
|
+
return [2 /*return*/, Promise.reject("".concat(subject, ": File is empty!"))];
|
|
217
|
+
getChunk = function (chunk) {
|
|
218
|
+
var offset = chunk * fileDescriptor.chunkSize;
|
|
219
|
+
return data.slice(offset, offset + fileDescriptor.chunkSize);
|
|
220
|
+
};
|
|
221
|
+
return [4 /*yield*/, this.request(subject, fileDescriptor, opts)];
|
|
222
|
+
case 1:
|
|
223
|
+
dataSubject = _a.sent();
|
|
224
|
+
for (i = 0; i < fileDescriptor.numberOfChunks; i++) {
|
|
225
|
+
this.connection.publish(dataSubject, getChunk(i), opts);
|
|
226
|
+
}
|
|
227
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
228
|
+
var combinedResult = new Uint8Array([]);
|
|
229
|
+
// Subscribe to dataSubject before sending the terminating message to ensure we are listening before the server starts responding
|
|
230
|
+
var subscription = _this.connection.subscribe(dataSubject);
|
|
231
|
+
// Publish an empty message to indicate that we are ready to listen
|
|
232
|
+
_this.connection.publish(dataSubject, Empty, opts);
|
|
233
|
+
var first = true;
|
|
234
|
+
subscription.callback = function (error, message) {
|
|
235
|
+
if (error) {
|
|
236
|
+
reject(error);
|
|
237
|
+
}
|
|
238
|
+
combinedResult = new Uint8Array(__spreadArray(__spreadArray([], Array.from(combinedResult), true), Array.from(message === null || message === void 0 ? void 0 : message.data), true));
|
|
239
|
+
// We shouldn't resolve after the first message since this is going to be the empty message we just sent
|
|
240
|
+
// We should resolve after the server terminates the message with an empty message
|
|
241
|
+
if (first === false && (message === null || message === void 0 ? void 0 : message.data.length) === 0) {
|
|
242
|
+
resolve(combinedResult);
|
|
243
|
+
}
|
|
244
|
+
first = false;
|
|
245
|
+
};
|
|
246
|
+
}).then(function (byteArray) {
|
|
247
|
+
var jsonCodec = JSONCodec();
|
|
248
|
+
var response = jsonCodec.decode(byteArray);
|
|
249
|
+
return _this.isErrorResponse(response) ? Promise.reject(ErrorResponse.fromJS(response)) : Promise.resolve(response);
|
|
250
|
+
})];
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
};
|
|
255
|
+
/**
|
|
256
|
+
* Request an object to the nats server with chunks.
|
|
257
|
+
* @param subject The subject to request
|
|
258
|
+
* @param payload (optional)
|
|
259
|
+
* @param options (optional)
|
|
260
|
+
* @returns Promise of an object
|
|
261
|
+
*/
|
|
262
|
+
BaseClient.prototype.requestChunked = function (subject, replySubject, payload, options, isFullSubject, rawResponse) {
|
|
263
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
264
|
+
var fileSize;
|
|
265
|
+
var _this = this;
|
|
266
|
+
return __generator(this, function (_a) {
|
|
267
|
+
if (!this.connection)
|
|
268
|
+
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection is down! Please try again!"))];
|
|
269
|
+
if (this.connection.isClosed())
|
|
270
|
+
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection has been closed! Please reconnect!"))];
|
|
271
|
+
fileSize = -1;
|
|
272
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
273
|
+
var combinedResult = new Uint8Array([]);
|
|
274
|
+
// Subscribe to the subject before starting the process
|
|
275
|
+
var subscription = _this.connection.subscribe(replySubject);
|
|
276
|
+
var resolveIfCompleted = function () {
|
|
277
|
+
if (combinedResult.length === fileSize) {
|
|
278
|
+
subscription.unsubscribe();
|
|
279
|
+
resolve(combinedResult);
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
subscription.callback = function (error, message) {
|
|
283
|
+
if (error) {
|
|
284
|
+
reject(error);
|
|
285
|
+
}
|
|
286
|
+
combinedResult = new Uint8Array(__spreadArray(__spreadArray([], Array.from(combinedResult), true), Array.from(message === null || message === void 0 ? void 0 : message.data), true));
|
|
287
|
+
resolveIfCompleted();
|
|
288
|
+
};
|
|
289
|
+
var headers = _this.buildHeaders();
|
|
290
|
+
var opts = __assign(__assign({}, options), { timeout: _this.timeout, headers: headers });
|
|
291
|
+
// Request the file descriptor from the runner by posting the reply subject
|
|
292
|
+
return _this.request(subject, payload, opts, isFullSubject)
|
|
293
|
+
.then(function (fileDescriptor) { return FileDescriptor.fromJS(fileDescriptor); })
|
|
294
|
+
.then(function (fileDescriptor) {
|
|
295
|
+
fileSize = fileDescriptor.fileSize;
|
|
296
|
+
resolveIfCompleted();
|
|
297
|
+
})
|
|
298
|
+
.catch(function (error) {
|
|
299
|
+
subscription.unsubscribe();
|
|
300
|
+
throw error;
|
|
301
|
+
});
|
|
302
|
+
}).then(function (byteArray) {
|
|
303
|
+
if (byteArray.length !== fileSize)
|
|
304
|
+
return Promise.reject("Unexpected response size. Expected ".concat(fileSize, " bytes, but got ").concat(byteArray.length, "."));
|
|
305
|
+
if (rawResponse)
|
|
306
|
+
return Promise.resolve(byteArray);
|
|
307
|
+
var jsonCodec = JSONCodec();
|
|
308
|
+
var response = jsonCodec.decode(byteArray);
|
|
309
|
+
return _this.isErrorResponse(response) ? Promise.reject(ErrorResponse.fromJS(response)) : Promise.resolve(response);
|
|
310
|
+
})];
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
};
|
|
181
314
|
/**
|
|
182
315
|
* Check if the the response is an error from the server.
|
|
183
316
|
* @param {any} response
|
package/lib/DTOs.d.ts
CHANGED
|
@@ -418,6 +418,53 @@ export declare class PasswordControl extends Setting implements IPasswordControl
|
|
|
418
418
|
export interface IPasswordControl extends ISetting {
|
|
419
419
|
password?: string | undefined;
|
|
420
420
|
}
|
|
421
|
+
export declare class PictureControl extends Setting implements IPictureControl {
|
|
422
|
+
description?: string | undefined;
|
|
423
|
+
mimeType?: string | undefined;
|
|
424
|
+
resource?: Resource | undefined;
|
|
425
|
+
constructor(data?: IPictureControl);
|
|
426
|
+
init(_data?: any): void;
|
|
427
|
+
static fromJS(data: any): PictureControl;
|
|
428
|
+
toJSON(data?: any): any;
|
|
429
|
+
}
|
|
430
|
+
export interface IPictureControl extends ISetting {
|
|
431
|
+
description?: string | undefined;
|
|
432
|
+
mimeType?: string | undefined;
|
|
433
|
+
resource?: Resource | undefined;
|
|
434
|
+
}
|
|
435
|
+
export declare class Resource implements IResource {
|
|
436
|
+
source?: string | undefined;
|
|
437
|
+
constructor(data?: IResource);
|
|
438
|
+
init(_data?: any): void;
|
|
439
|
+
static fromJS(data: any): Resource;
|
|
440
|
+
toJSON(data?: any): any;
|
|
441
|
+
}
|
|
442
|
+
export interface IResource {
|
|
443
|
+
source?: string | undefined;
|
|
444
|
+
}
|
|
445
|
+
export declare class TestPlanRequest implements ITestPlanRequest {
|
|
446
|
+
properties?: string[] | null | undefined;
|
|
447
|
+
subject?: string | undefined;
|
|
448
|
+
}
|
|
449
|
+
export interface ITestPlanRequest {
|
|
450
|
+
properties?: string[] | null | undefined;
|
|
451
|
+
subject?: string | undefined;
|
|
452
|
+
}
|
|
453
|
+
export declare class FileDescriptor implements IFileDescriptor {
|
|
454
|
+
numberOfChunks: number;
|
|
455
|
+
fileSize: number;
|
|
456
|
+
chunkSize: number;
|
|
457
|
+
private readonly defaultChunkSize;
|
|
458
|
+
constructor(fileSize: number, chunkSize?: number);
|
|
459
|
+
init(_data?: any): void;
|
|
460
|
+
static fromJS(data: any): FileDescriptor;
|
|
461
|
+
toJSON(data?: any): any;
|
|
462
|
+
}
|
|
463
|
+
export interface IFileDescriptor {
|
|
464
|
+
numberOfChunks: number;
|
|
465
|
+
fileSize: number;
|
|
466
|
+
chunkSize: number;
|
|
467
|
+
}
|
|
421
468
|
export declare class ComponentSettings extends ComponentSettingsBase implements IComponentSettings {
|
|
422
469
|
settings?: Setting[] | undefined;
|
|
423
470
|
constructor(data?: IComponentSettings);
|
package/lib/DTOs.js
CHANGED
|
@@ -506,6 +506,11 @@ var Setting = /** @class */ (function (_super) {
|
|
|
506
506
|
result_12.init(data);
|
|
507
507
|
return result_12;
|
|
508
508
|
}
|
|
509
|
+
if (data['ControlType'] === 'PictureControl') {
|
|
510
|
+
var result_13 = new PictureControl();
|
|
511
|
+
result_13.init(data);
|
|
512
|
+
return result_13;
|
|
513
|
+
}
|
|
509
514
|
var result = new Setting();
|
|
510
515
|
result.init(data);
|
|
511
516
|
return result;
|
|
@@ -997,9 +1002,9 @@ var TextBoxControl = /** @class */ (function (_super) {
|
|
|
997
1002
|
TextBoxControl.fromJS = function (data) {
|
|
998
1003
|
data = typeof data === 'object' ? data : {};
|
|
999
1004
|
if (data['ControlType'] === 'ComboBoxControl') {
|
|
1000
|
-
var
|
|
1001
|
-
|
|
1002
|
-
return
|
|
1005
|
+
var result_14 = new ComboBoxControl();
|
|
1006
|
+
result_14.init(data);
|
|
1007
|
+
return result_14;
|
|
1003
1008
|
}
|
|
1004
1009
|
var result = new TextBoxControl();
|
|
1005
1010
|
result.init(data);
|
|
@@ -1238,6 +1243,106 @@ var PasswordControl = /** @class */ (function (_super) {
|
|
|
1238
1243
|
return PasswordControl;
|
|
1239
1244
|
}(Setting));
|
|
1240
1245
|
export { PasswordControl };
|
|
1246
|
+
var PictureControl = /** @class */ (function (_super) {
|
|
1247
|
+
__extends(PictureControl, _super);
|
|
1248
|
+
function PictureControl(data) {
|
|
1249
|
+
var _this = _super.call(this, data) || this;
|
|
1250
|
+
_this._discriminator = 'PictureControl';
|
|
1251
|
+
return _this;
|
|
1252
|
+
}
|
|
1253
|
+
PictureControl.prototype.init = function (_data) {
|
|
1254
|
+
_super.prototype.init.call(this, _data);
|
|
1255
|
+
if (_data) {
|
|
1256
|
+
this.description = _data['Description'];
|
|
1257
|
+
this.mimeType = _data['MimeType'];
|
|
1258
|
+
this.resource = _data['Resource'] ? Resource.fromJS(_data['Resource']) : undefined;
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
PictureControl.fromJS = function (data) {
|
|
1262
|
+
data = typeof data === 'object' ? data : {};
|
|
1263
|
+
var result = new PictureControl();
|
|
1264
|
+
result.init(data);
|
|
1265
|
+
return result;
|
|
1266
|
+
};
|
|
1267
|
+
PictureControl.prototype.toJSON = function (data) {
|
|
1268
|
+
data = typeof data === 'object' ? data : {};
|
|
1269
|
+
data['Description'] = this.description;
|
|
1270
|
+
data['MimeType'] = this.mimeType;
|
|
1271
|
+
data['Resource'] = this.resource ? this.resource.toJSON() : undefined;
|
|
1272
|
+
_super.prototype.toJSON.call(this, data);
|
|
1273
|
+
return data;
|
|
1274
|
+
};
|
|
1275
|
+
return PictureControl;
|
|
1276
|
+
}(Setting));
|
|
1277
|
+
export { PictureControl };
|
|
1278
|
+
var Resource = /** @class */ (function () {
|
|
1279
|
+
function Resource(data) {
|
|
1280
|
+
if (data) {
|
|
1281
|
+
for (var property in data) {
|
|
1282
|
+
if (Object.prototype.hasOwnProperty.call(data, property))
|
|
1283
|
+
this[property] = data[property];
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
}
|
|
1287
|
+
Resource.prototype.init = function (_data) {
|
|
1288
|
+
if (_data) {
|
|
1289
|
+
this.source = _data['Source'];
|
|
1290
|
+
}
|
|
1291
|
+
};
|
|
1292
|
+
Resource.fromJS = function (data) {
|
|
1293
|
+
data = typeof data === 'object' ? data : {};
|
|
1294
|
+
var result = new Resource();
|
|
1295
|
+
result.init(data);
|
|
1296
|
+
return result;
|
|
1297
|
+
};
|
|
1298
|
+
Resource.prototype.toJSON = function (data) {
|
|
1299
|
+
data = typeof data === 'object' ? data : {};
|
|
1300
|
+
data['Source'] = this.source;
|
|
1301
|
+
return data;
|
|
1302
|
+
};
|
|
1303
|
+
return Resource;
|
|
1304
|
+
}());
|
|
1305
|
+
export { Resource };
|
|
1306
|
+
var TestPlanRequest = /** @class */ (function () {
|
|
1307
|
+
function TestPlanRequest() {
|
|
1308
|
+
}
|
|
1309
|
+
return TestPlanRequest;
|
|
1310
|
+
}());
|
|
1311
|
+
export { TestPlanRequest };
|
|
1312
|
+
var FileDescriptor = /** @class */ (function () {
|
|
1313
|
+
function FileDescriptor(fileSize, chunkSize) {
|
|
1314
|
+
var _a;
|
|
1315
|
+
this.defaultChunkSize = 512000;
|
|
1316
|
+
if (chunkSize === 0) {
|
|
1317
|
+
throw Error('chunkSize cannot set to 0');
|
|
1318
|
+
}
|
|
1319
|
+
this.fileSize = fileSize;
|
|
1320
|
+
this.chunkSize = chunkSize !== null && chunkSize !== void 0 ? chunkSize : this.defaultChunkSize;
|
|
1321
|
+
this.numberOfChunks = Math.floor((((_a = this.fileSize) !== null && _a !== void 0 ? _a : 0) + this.chunkSize - 1) / this.chunkSize);
|
|
1322
|
+
}
|
|
1323
|
+
FileDescriptor.prototype.init = function (_data) {
|
|
1324
|
+
if (_data) {
|
|
1325
|
+
this.numberOfChunks = _data['NumberOfChunks'];
|
|
1326
|
+
this.fileSize = _data['FileSize'];
|
|
1327
|
+
this.chunkSize = _data['ChunkSize'];
|
|
1328
|
+
}
|
|
1329
|
+
};
|
|
1330
|
+
FileDescriptor.fromJS = function (data) {
|
|
1331
|
+
data = typeof data === 'object' ? data : {};
|
|
1332
|
+
var result = new FileDescriptor(0);
|
|
1333
|
+
result.init(data);
|
|
1334
|
+
return result;
|
|
1335
|
+
};
|
|
1336
|
+
FileDescriptor.prototype.toJSON = function (data) {
|
|
1337
|
+
data = typeof data === 'object' ? data : {};
|
|
1338
|
+
data['NumberOfChunks'] = this.numberOfChunks;
|
|
1339
|
+
data['FileSize'] = this.fileSize;
|
|
1340
|
+
data['ChunkSize'] = this.chunkSize;
|
|
1341
|
+
return data;
|
|
1342
|
+
};
|
|
1343
|
+
return FileDescriptor;
|
|
1344
|
+
}());
|
|
1345
|
+
export { FileDescriptor };
|
|
1241
1346
|
var ComponentSettings = /** @class */ (function (_super) {
|
|
1242
1347
|
__extends(ComponentSettings, _super);
|
|
1243
1348
|
function ComponentSettings(data) {
|
|
@@ -1532,40 +1637,40 @@ var SessionEventArgs = /** @class */ (function () {
|
|
|
1532
1637
|
SessionEventArgs.fromJS = function (data) {
|
|
1533
1638
|
data = typeof data === 'object' ? data : {};
|
|
1534
1639
|
if (data['SessionEventType'] === 'SessionStartInitiated') {
|
|
1535
|
-
var
|
|
1536
|
-
result_14.init(data);
|
|
1537
|
-
return result_14;
|
|
1538
|
-
}
|
|
1539
|
-
if (data['SessionEventType'] === 'SessionStarted') {
|
|
1540
|
-
var result_15 = new SessionStarted();
|
|
1640
|
+
var result_15 = new SessionStartInitiated();
|
|
1541
1641
|
result_15.init(data);
|
|
1542
1642
|
return result_15;
|
|
1543
1643
|
}
|
|
1544
|
-
if (data['SessionEventType'] === '
|
|
1545
|
-
var result_16 = new
|
|
1644
|
+
if (data['SessionEventType'] === 'SessionStarted') {
|
|
1645
|
+
var result_16 = new SessionStarted();
|
|
1546
1646
|
result_16.init(data);
|
|
1547
1647
|
return result_16;
|
|
1548
1648
|
}
|
|
1549
|
-
if (data['SessionEventType'] === '
|
|
1550
|
-
var result_17 = new
|
|
1649
|
+
if (data['SessionEventType'] === 'SessionStartFailed') {
|
|
1650
|
+
var result_17 = new SessionStartFailed();
|
|
1551
1651
|
result_17.init(data);
|
|
1552
1652
|
return result_17;
|
|
1553
1653
|
}
|
|
1554
|
-
if (data['SessionEventType'] === '
|
|
1555
|
-
var result_18 = new
|
|
1654
|
+
if (data['SessionEventType'] === 'SessionShutdownInitiated') {
|
|
1655
|
+
var result_18 = new SessionShutdownInitiated();
|
|
1556
1656
|
result_18.init(data);
|
|
1557
1657
|
return result_18;
|
|
1558
1658
|
}
|
|
1559
|
-
if (data['SessionEventType'] === '
|
|
1560
|
-
var result_19 = new
|
|
1659
|
+
if (data['SessionEventType'] === 'SessionShutdown') {
|
|
1660
|
+
var result_19 = new SessionShutdown();
|
|
1561
1661
|
result_19.init(data);
|
|
1562
1662
|
return result_19;
|
|
1563
1663
|
}
|
|
1564
|
-
if (data['SessionEventType'] === '
|
|
1565
|
-
var result_20 = new
|
|
1664
|
+
if (data['SessionEventType'] === 'SessionShutdownFailed') {
|
|
1665
|
+
var result_20 = new SessionShutdownFailed();
|
|
1566
1666
|
result_20.init(data);
|
|
1567
1667
|
return result_20;
|
|
1568
1668
|
}
|
|
1669
|
+
if (data['SessionEventType'] === 'SessionInactivityLimitHit') {
|
|
1670
|
+
var result_21 = new SessionInactivityLimitHit();
|
|
1671
|
+
result_21.init(data);
|
|
1672
|
+
return result_21;
|
|
1673
|
+
}
|
|
1569
1674
|
var result = new SessionEventArgs();
|
|
1570
1675
|
result.init(data);
|
|
1571
1676
|
return result;
|
|
@@ -1777,20 +1882,20 @@ var ImageEventArgs = /** @class */ (function () {
|
|
|
1777
1882
|
ImageEventArgs.fromJS = function (data) {
|
|
1778
1883
|
data = typeof data === 'object' ? data : {};
|
|
1779
1884
|
if (data['ImageEventType'] === 'ImageCreating') {
|
|
1780
|
-
var
|
|
1781
|
-
result_21.init(data);
|
|
1782
|
-
return result_21;
|
|
1783
|
-
}
|
|
1784
|
-
if (data['ImageEventType'] === 'ImageCreated') {
|
|
1785
|
-
var result_22 = new ImageCreated();
|
|
1885
|
+
var result_22 = new ImageCreating();
|
|
1786
1886
|
result_22.init(data);
|
|
1787
1887
|
return result_22;
|
|
1788
1888
|
}
|
|
1789
|
-
if (data['ImageEventType'] === '
|
|
1790
|
-
var result_23 = new
|
|
1889
|
+
if (data['ImageEventType'] === 'ImageCreated') {
|
|
1890
|
+
var result_23 = new ImageCreated();
|
|
1791
1891
|
result_23.init(data);
|
|
1792
1892
|
return result_23;
|
|
1793
1893
|
}
|
|
1894
|
+
if (data['ImageEventType'] === 'ImageCreationFailed') {
|
|
1895
|
+
var result_24 = new ImageCreationFailed();
|
|
1896
|
+
result_24.init(data);
|
|
1897
|
+
return result_24;
|
|
1898
|
+
}
|
|
1794
1899
|
var result = new ImageEventArgs();
|
|
1795
1900
|
result.init(data);
|
|
1796
1901
|
return result;
|
|
@@ -2201,9 +2306,9 @@ var TestStep = /** @class */ (function () {
|
|
|
2201
2306
|
TestStep.fromJS = function (data) {
|
|
2202
2307
|
data = typeof data === 'object' ? data : {};
|
|
2203
2308
|
if (data['TestStepTypeOrInstance'] === 'TestStepType') {
|
|
2204
|
-
var
|
|
2205
|
-
|
|
2206
|
-
return
|
|
2309
|
+
var result_25 = new TestStepType();
|
|
2310
|
+
result_25.init(data);
|
|
2311
|
+
return result_25;
|
|
2207
2312
|
}
|
|
2208
2313
|
var result = new TestStep();
|
|
2209
2314
|
result.init(data);
|
|
@@ -2863,70 +2968,70 @@ var SessionEvent = /** @class */ (function () {
|
|
|
2863
2968
|
SessionEvent.fromJS = function (data) {
|
|
2864
2969
|
data = typeof data === 'object' ? data : {};
|
|
2865
2970
|
if (data['discriminator'] === 'SessionTimeoutEventArgs') {
|
|
2866
|
-
var
|
|
2867
|
-
result_25.init(data);
|
|
2868
|
-
return result_25;
|
|
2869
|
-
}
|
|
2870
|
-
if (data['discriminator'] === 'StartingEventArgs') {
|
|
2871
|
-
var result_26 = new StartingEventArgs();
|
|
2971
|
+
var result_26 = new SessionTimeoutEventArgs();
|
|
2872
2972
|
result_26.init(data);
|
|
2873
2973
|
return result_26;
|
|
2874
2974
|
}
|
|
2875
|
-
if (data['discriminator'] === '
|
|
2876
|
-
var result_27 = new
|
|
2975
|
+
if (data['discriminator'] === 'StartingEventArgs') {
|
|
2976
|
+
var result_27 = new StartingEventArgs();
|
|
2877
2977
|
result_27.init(data);
|
|
2878
2978
|
return result_27;
|
|
2879
2979
|
}
|
|
2880
|
-
if (data['discriminator'] === '
|
|
2881
|
-
var result_28 = new
|
|
2980
|
+
if (data['discriminator'] === 'StartedEventArgs') {
|
|
2981
|
+
var result_28 = new StartedEventArgs();
|
|
2882
2982
|
result_28.init(data);
|
|
2883
2983
|
return result_28;
|
|
2884
2984
|
}
|
|
2885
|
-
if (data['discriminator'] === '
|
|
2886
|
-
var result_29 = new
|
|
2985
|
+
if (data['discriminator'] === 'StoppingEventArgs') {
|
|
2986
|
+
var result_29 = new StoppingEventArgs();
|
|
2887
2987
|
result_29.init(data);
|
|
2888
2988
|
return result_29;
|
|
2889
2989
|
}
|
|
2890
|
-
if (data['discriminator'] === '
|
|
2891
|
-
var result_30 = new
|
|
2990
|
+
if (data['discriminator'] === 'StoppedEventArgs') {
|
|
2991
|
+
var result_30 = new StoppedEventArgs();
|
|
2892
2992
|
result_30.init(data);
|
|
2893
2993
|
return result_30;
|
|
2894
2994
|
}
|
|
2895
|
-
if (data['discriminator'] === '
|
|
2896
|
-
var result_31 = new
|
|
2995
|
+
if (data['discriminator'] === 'TestPlanChangeEventArgs') {
|
|
2996
|
+
var result_31 = new TestPlanChangeEventArgs();
|
|
2897
2997
|
result_31.init(data);
|
|
2898
2998
|
return result_31;
|
|
2899
2999
|
}
|
|
2900
|
-
if (data['discriminator'] === '
|
|
2901
|
-
var result_32 = new
|
|
3000
|
+
if (data['discriminator'] === 'TestPlanExecutionStateChangedEventArgs') {
|
|
3001
|
+
var result_32 = new TestPlanExecutionStateChangedEventArgs();
|
|
2902
3002
|
result_32.init(data);
|
|
2903
3003
|
return result_32;
|
|
2904
3004
|
}
|
|
2905
|
-
if (data['discriminator'] === '
|
|
2906
|
-
var result_33 = new
|
|
3005
|
+
if (data['discriminator'] === 'SettingsChangedEventArgs') {
|
|
3006
|
+
var result_33 = new SettingsChangedEventArgs();
|
|
2907
3007
|
result_33.init(data);
|
|
2908
3008
|
return result_33;
|
|
2909
3009
|
}
|
|
2910
|
-
if (data['discriminator'] === '
|
|
2911
|
-
var result_34 = new
|
|
3010
|
+
if (data['discriminator'] === 'TestStepChangeEventArgs') {
|
|
3011
|
+
var result_34 = new TestStepChangeEventArgs();
|
|
2912
3012
|
result_34.init(data);
|
|
2913
3013
|
return result_34;
|
|
2914
3014
|
}
|
|
2915
|
-
if (data['discriminator'] === '
|
|
2916
|
-
var result_35 = new
|
|
3015
|
+
if (data['discriminator'] === 'BreakEventArgs') {
|
|
3016
|
+
var result_35 = new BreakEventArgs();
|
|
2917
3017
|
result_35.init(data);
|
|
2918
3018
|
return result_35;
|
|
2919
3019
|
}
|
|
2920
|
-
if (data['discriminator'] === '
|
|
2921
|
-
var result_36 = new
|
|
3020
|
+
if (data['discriminator'] === 'UserInputRequestEventArgs') {
|
|
3021
|
+
var result_36 = new UserInputRequestEventArgs();
|
|
2922
3022
|
result_36.init(data);
|
|
2923
3023
|
return result_36;
|
|
2924
3024
|
}
|
|
2925
|
-
if (data['discriminator'] === '
|
|
2926
|
-
var result_37 = new
|
|
3025
|
+
if (data['discriminator'] === 'UserInputRequestCompletedEventArgs') {
|
|
3026
|
+
var result_37 = new UserInputRequestCompletedEventArgs();
|
|
2927
3027
|
result_37.init(data);
|
|
2928
3028
|
return result_37;
|
|
2929
3029
|
}
|
|
3030
|
+
if (data['discriminator'] === 'TestPlanSettingsChangedEventArgs') {
|
|
3031
|
+
var result_38 = new TestPlanSettingsChangedEventArgs();
|
|
3032
|
+
result_38.init(data);
|
|
3033
|
+
return result_38;
|
|
3034
|
+
}
|
|
2930
3035
|
var result = new SessionEvent();
|
|
2931
3036
|
result.init(data);
|
|
2932
3037
|
return result;
|
package/lib/SessionClient.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Interaction, ListItemType, LogList, Parameter, RepositoryPackageDefinition, RepositoryPackageReference, Result, 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 } 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 {
|
|
@@ -86,6 +86,11 @@ export declare class SessionClient extends BaseClient {
|
|
|
86
86
|
* @return Test plan retrieved
|
|
87
87
|
*/
|
|
88
88
|
getTestPlanXML(): Promise<string>;
|
|
89
|
+
/**
|
|
90
|
+
* Returns the resource in a base64 encoded string
|
|
91
|
+
* @return The resource pointed to by `resource`
|
|
92
|
+
*/
|
|
93
|
+
downloadResource(resource: Resource): Promise<Uint8Array>;
|
|
89
94
|
/**
|
|
90
95
|
* Load test plan using a test plan TapPackage from a repository
|
|
91
96
|
* @param {RepositoryPackageDefinition} packageReference
|
package/lib/SessionClient.js
CHANGED
|
@@ -27,6 +27,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
27
27
|
import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Interaction, ListItemType, LogList, Result, RunStatus, SessionEvent, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog, } from './DTOs';
|
|
28
28
|
import { JSONCodec } from 'nats.ws';
|
|
29
29
|
import { BaseClient } from './BaseClient';
|
|
30
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
30
31
|
var SessionClient = /** @class */ (function (_super) {
|
|
31
32
|
__extends(SessionClient, _super);
|
|
32
33
|
function SessionClient(baseSubject, options) {
|
|
@@ -197,14 +198,32 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
197
198
|
* @return Test plan loaded. List of load errors is returned.
|
|
198
199
|
*/
|
|
199
200
|
SessionClient.prototype.setTestPlanXML = function (xml) {
|
|
200
|
-
return this.
|
|
201
|
+
return this.sendChunked('SetTestPlanXML', xml).then(this.success()).catch(this.error());
|
|
201
202
|
};
|
|
202
203
|
/**
|
|
203
204
|
* Retrieve loaded test plan XML
|
|
204
205
|
* @return Test plan retrieved
|
|
205
206
|
*/
|
|
206
207
|
SessionClient.prototype.getTestPlanXML = function () {
|
|
207
|
-
|
|
208
|
+
// Generate a unique subject where the Runner will publish the chunks
|
|
209
|
+
var replySubject = "_INBOX.".concat(uuidv4());
|
|
210
|
+
return this.requestChunked('GetTestPlanXML', replySubject, replySubject).then(this.success()).catch(this.error());
|
|
211
|
+
};
|
|
212
|
+
/**
|
|
213
|
+
* Returns the resource in a base64 encoded string
|
|
214
|
+
* @return The resource pointed to by `resource`
|
|
215
|
+
*/
|
|
216
|
+
SessionClient.prototype.downloadResource = function (resource) {
|
|
217
|
+
var _a;
|
|
218
|
+
var runnerResourcePrefix = 'subject://';
|
|
219
|
+
if (!((_a = resource.source) === null || _a === void 0 ? void 0 : _a.startsWith(runnerResourcePrefix))) {
|
|
220
|
+
return Promise.reject('The source of the provided resource is not a nats subject.');
|
|
221
|
+
}
|
|
222
|
+
var replySubject = "_INBOX.".concat(uuidv4());
|
|
223
|
+
var subject = resource.source.slice(runnerResourcePrefix.length);
|
|
224
|
+
return this.requestChunked(subject, replySubject, replySubject, undefined, true, true)
|
|
225
|
+
.then(this.success())
|
|
226
|
+
.catch(this.error());
|
|
208
227
|
};
|
|
209
228
|
/**
|
|
210
229
|
* Load test plan using a test plan TapPackage from a repository
|
|
@@ -227,7 +246,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
227
246
|
* @return Test plan resources opened.
|
|
228
247
|
*/
|
|
229
248
|
SessionClient.prototype.resourcesOpen = function () {
|
|
230
|
-
|
|
249
|
+
var replySubject = "_INBOX.".concat(uuidv4());
|
|
250
|
+
return this.requestChunked('ResourcesOpen', replySubject, replySubject)
|
|
231
251
|
.then(function (testPlanJs) { return TestPlan.fromJS(testPlanJs); })
|
|
232
252
|
.then(this.success())
|
|
233
253
|
.catch(this.error());
|
|
@@ -237,7 +257,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
237
257
|
* @return Test plan resources closed.
|
|
238
258
|
*/
|
|
239
259
|
SessionClient.prototype.resourcesClose = function () {
|
|
240
|
-
|
|
260
|
+
var replySubject = "_INBOX.".concat(uuidv4());
|
|
261
|
+
return this.requestChunked('ResourcesClose', replySubject, replySubject)
|
|
241
262
|
.then(function (testPlanJs) { return TestPlan.fromJS(testPlanJs); })
|
|
242
263
|
.then(this.success())
|
|
243
264
|
.catch(this.error());
|
|
@@ -272,7 +293,12 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
272
293
|
* @return Test plan retrieved
|
|
273
294
|
*/
|
|
274
295
|
SessionClient.prototype.getTestPlan = function (properties) {
|
|
275
|
-
|
|
296
|
+
var replySubject = "_INBOX.".concat(uuidv4());
|
|
297
|
+
var payload = {
|
|
298
|
+
subject: replySubject,
|
|
299
|
+
properties: properties,
|
|
300
|
+
};
|
|
301
|
+
return this.requestChunked('GetTestPlan', replySubject, payload)
|
|
276
302
|
.then(function (testPlanJs) { return TestPlan.fromJS(testPlanJs); })
|
|
277
303
|
.then(this.success())
|
|
278
304
|
.catch(this.error());
|
|
@@ -283,7 +309,7 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
283
309
|
* @return Test plan changed
|
|
284
310
|
*/
|
|
285
311
|
SessionClient.prototype.setTestPlan = function (plan) {
|
|
286
|
-
return this.
|
|
312
|
+
return this.sendChunked('SetTestPlan', plan)
|
|
287
313
|
.then(function (testPlanJs) { return TestPlan.fromJS(testPlanJs); })
|
|
288
314
|
.then(this.success())
|
|
289
315
|
.catch(this.error());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentap/runner-client",
|
|
3
|
-
"version": "2.0.2-alpha.1.
|
|
3
|
+
"version": "2.0.2-alpha.1.2",
|
|
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/uuid": "^8.3.4",
|
|
29
30
|
"@typescript-eslint/eslint-plugin": "^5.36.1",
|
|
30
31
|
"@typescript-eslint/parser": "^5.36.1",
|
|
31
32
|
"eslint": "^8.23.0",
|
|
@@ -38,7 +39,8 @@
|
|
|
38
39
|
"typescript": "^4.8.2"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"nats.ws": "^1.9.0"
|
|
42
|
+
"nats.ws": "^1.9.0",
|
|
43
|
+
"uuid": "^9.0.0"
|
|
42
44
|
},
|
|
43
45
|
"lint-staged": {
|
|
44
46
|
"*.{ts,js,html}": [
|