@opentap/runner-client 2.0.0-alpha.2.2 → 2.0.0-alpha.2.20

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/README.md CHANGED
@@ -11,6 +11,9 @@ This is the web client for the OpenTAP Runner.
11
11
 
12
12
  ## How to install the client
13
13
 
14
+ - For Angular < 11 or webpack < 5, use version < 2
15
+ - For Angular >= 11 or webpack >= 5, use version >= 2.x.x
16
+
14
17
  Install with npm
15
18
 
16
19
  ```bash
@@ -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): 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
- import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsListItem, DataGridControl, ErrorResponse, ListItemType, ProfileGroup, } from './DTOs';
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,126 @@ 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) {
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
+ var jsonCodec = JSONCodec();
306
+ var response = jsonCodec.decode(byteArray);
307
+ return _this.isErrorResponse(response) ? Promise.reject(ErrorResponse.fromJS(response)) : Promise.resolve(response);
308
+ })];
309
+ });
310
+ });
311
+ };
181
312
  /**
182
313
  * Check if the the response is an error from the server.
183
314
  * @param {any} response
package/lib/DTOs.d.ts CHANGED
@@ -151,6 +151,7 @@ export declare class Setting extends AnnotatedObject implements ISetting {
151
151
  valueDescription?: string | undefined;
152
152
  propertyName?: string | undefined;
153
153
  icons?: Icon[] | undefined;
154
+ submit?: boolean | undefined;
154
155
  protected _discriminator: string;
155
156
  constructor(data?: ISetting);
156
157
  init(_data?: any): void;
@@ -164,6 +165,7 @@ export interface ISetting extends IAnnotatedObject {
164
165
  valueDescription?: string | undefined;
165
166
  propertyName?: string | undefined;
166
167
  icons?: Icon[] | undefined;
168
+ submit?: boolean | undefined;
167
169
  }
168
170
  export declare class Layout implements ILayout {
169
171
  mode?: LayoutMode;
@@ -416,6 +418,53 @@ export declare class PasswordControl extends Setting implements IPasswordControl
416
418
  export interface IPasswordControl extends ISetting {
417
419
  password?: string | undefined;
418
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
+ }
419
468
  export declare class ComponentSettings extends ComponentSettingsBase implements IComponentSettings {
420
469
  settings?: Setting[] | undefined;
421
470
  constructor(data?: IComponentSettings);
@@ -831,6 +880,7 @@ export interface ICommonContext {
831
880
  export declare class Interaction implements IInteraction {
832
881
  timeout?: string | undefined;
833
882
  title?: string | undefined;
883
+ modal?: boolean | undefined;
834
884
  settings?: Setting[] | undefined;
835
885
  id?: string;
836
886
  constructor(data?: IInteraction);
@@ -841,6 +891,7 @@ export declare class Interaction implements IInteraction {
841
891
  export interface IInteraction {
842
892
  timeout?: string | undefined;
843
893
  title?: string | undefined;
894
+ modal?: boolean | undefined;
844
895
  settings?: Setting[] | undefined;
845
896
  id?: string;
846
897
  }
package/lib/DTOs.js CHANGED
@@ -434,6 +434,7 @@ var Setting = /** @class */ (function (_super) {
434
434
  this.columnDisplayName = _data['ColumnDisplayName'] ? ColumnDisplayName.fromJS(_data['ColumnDisplayName']) : undefined;
435
435
  this.valueDescription = _data['ValueDescription'];
436
436
  this.propertyName = _data['PropertyName'];
437
+ this.submit = _data['Submit'];
437
438
  if (Array.isArray(_data['Icons'])) {
438
439
  this.icons = [];
439
440
  for (var _b = 0, _c = _data['Icons']; _b < _c.length; _b++) {
@@ -505,6 +506,11 @@ var Setting = /** @class */ (function (_super) {
505
506
  result_12.init(data);
506
507
  return result_12;
507
508
  }
509
+ if (data['ControlType'] === 'PictureControl') {
510
+ var result_13 = new PictureControl();
511
+ result_13.init(data);
512
+ return result_13;
513
+ }
508
514
  var result = new Setting();
509
515
  result.init(data);
510
516
  return result;
@@ -523,6 +529,7 @@ var Setting = /** @class */ (function (_super) {
523
529
  data['ColumnDisplayName'] = this.columnDisplayName ? this.columnDisplayName.toJSON() : undefined;
524
530
  data['ValueDescription'] = this.valueDescription;
525
531
  data['PropertyName'] = this.propertyName;
532
+ data['Submit'] = this.submit;
526
533
  if (Array.isArray(this.icons)) {
527
534
  data['Icons'] = [];
528
535
  for (var _b = 0, _c = this.icons; _b < _c.length; _b++) {
@@ -995,9 +1002,9 @@ var TextBoxControl = /** @class */ (function (_super) {
995
1002
  TextBoxControl.fromJS = function (data) {
996
1003
  data = typeof data === 'object' ? data : {};
997
1004
  if (data['ControlType'] === 'ComboBoxControl') {
998
- var result_13 = new ComboBoxControl();
999
- result_13.init(data);
1000
- return result_13;
1005
+ var result_14 = new ComboBoxControl();
1006
+ result_14.init(data);
1007
+ return result_14;
1001
1008
  }
1002
1009
  var result = new TextBoxControl();
1003
1010
  result.init(data);
@@ -1236,6 +1243,106 @@ var PasswordControl = /** @class */ (function (_super) {
1236
1243
  return PasswordControl;
1237
1244
  }(Setting));
1238
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 };
1239
1346
  var ComponentSettings = /** @class */ (function (_super) {
1240
1347
  __extends(ComponentSettings, _super);
1241
1348
  function ComponentSettings(data) {
@@ -1530,40 +1637,40 @@ var SessionEventArgs = /** @class */ (function () {
1530
1637
  SessionEventArgs.fromJS = function (data) {
1531
1638
  data = typeof data === 'object' ? data : {};
1532
1639
  if (data['SessionEventType'] === 'SessionStartInitiated') {
1533
- var result_14 = new SessionStartInitiated();
1534
- result_14.init(data);
1535
- return result_14;
1536
- }
1537
- if (data['SessionEventType'] === 'SessionStarted') {
1538
- var result_15 = new SessionStarted();
1640
+ var result_15 = new SessionStartInitiated();
1539
1641
  result_15.init(data);
1540
1642
  return result_15;
1541
1643
  }
1542
- if (data['SessionEventType'] === 'SessionStartFailed') {
1543
- var result_16 = new SessionStartFailed();
1644
+ if (data['SessionEventType'] === 'SessionStarted') {
1645
+ var result_16 = new SessionStarted();
1544
1646
  result_16.init(data);
1545
1647
  return result_16;
1546
1648
  }
1547
- if (data['SessionEventType'] === 'SessionShutdownInitiated') {
1548
- var result_17 = new SessionShutdownInitiated();
1649
+ if (data['SessionEventType'] === 'SessionStartFailed') {
1650
+ var result_17 = new SessionStartFailed();
1549
1651
  result_17.init(data);
1550
1652
  return result_17;
1551
1653
  }
1552
- if (data['SessionEventType'] === 'SessionShutdown') {
1553
- var result_18 = new SessionShutdown();
1654
+ if (data['SessionEventType'] === 'SessionShutdownInitiated') {
1655
+ var result_18 = new SessionShutdownInitiated();
1554
1656
  result_18.init(data);
1555
1657
  return result_18;
1556
1658
  }
1557
- if (data['SessionEventType'] === 'SessionShutdownFailed') {
1558
- var result_19 = new SessionShutdownFailed();
1659
+ if (data['SessionEventType'] === 'SessionShutdown') {
1660
+ var result_19 = new SessionShutdown();
1559
1661
  result_19.init(data);
1560
1662
  return result_19;
1561
1663
  }
1562
- if (data['SessionEventType'] === 'SessionInactivityLimitHit') {
1563
- var result_20 = new SessionInactivityLimitHit();
1664
+ if (data['SessionEventType'] === 'SessionShutdownFailed') {
1665
+ var result_20 = new SessionShutdownFailed();
1564
1666
  result_20.init(data);
1565
1667
  return result_20;
1566
1668
  }
1669
+ if (data['SessionEventType'] === 'SessionInactivityLimitHit') {
1670
+ var result_21 = new SessionInactivityLimitHit();
1671
+ result_21.init(data);
1672
+ return result_21;
1673
+ }
1567
1674
  var result = new SessionEventArgs();
1568
1675
  result.init(data);
1569
1676
  return result;
@@ -1775,20 +1882,20 @@ var ImageEventArgs = /** @class */ (function () {
1775
1882
  ImageEventArgs.fromJS = function (data) {
1776
1883
  data = typeof data === 'object' ? data : {};
1777
1884
  if (data['ImageEventType'] === 'ImageCreating') {
1778
- var result_21 = new ImageCreating();
1779
- result_21.init(data);
1780
- return result_21;
1781
- }
1782
- if (data['ImageEventType'] === 'ImageCreated') {
1783
- var result_22 = new ImageCreated();
1885
+ var result_22 = new ImageCreating();
1784
1886
  result_22.init(data);
1785
1887
  return result_22;
1786
1888
  }
1787
- if (data['ImageEventType'] === 'ImageCreationFailed') {
1788
- var result_23 = new ImageCreationFailed();
1889
+ if (data['ImageEventType'] === 'ImageCreated') {
1890
+ var result_23 = new ImageCreated();
1789
1891
  result_23.init(data);
1790
1892
  return result_23;
1791
1893
  }
1894
+ if (data['ImageEventType'] === 'ImageCreationFailed') {
1895
+ var result_24 = new ImageCreationFailed();
1896
+ result_24.init(data);
1897
+ return result_24;
1898
+ }
1792
1899
  var result = new ImageEventArgs();
1793
1900
  result.init(data);
1794
1901
  return result;
@@ -2198,9 +2305,9 @@ var TestStep = /** @class */ (function () {
2198
2305
  TestStep.fromJS = function (data) {
2199
2306
  data = typeof data === 'object' ? data : {};
2200
2307
  if (data['TestStepTypeOrInstance'] === 'TestStepType') {
2201
- var result_24 = new TestStepType();
2202
- result_24.init(data);
2203
- return result_24;
2308
+ var result_25 = new TestStepType();
2309
+ result_25.init(data);
2310
+ return result_25;
2204
2311
  }
2205
2312
  var result = new TestStep();
2206
2313
  result.init(data);
@@ -2455,6 +2562,7 @@ var Interaction = /** @class */ (function () {
2455
2562
  if (_data) {
2456
2563
  this.timeout = _data['Timeout'];
2457
2564
  this.title = _data['Title'];
2565
+ this.modal = _data['Modal'];
2458
2566
  if (Array.isArray(_data['Settings'])) {
2459
2567
  this.settings = [];
2460
2568
  for (var _i = 0, _a = _data['Settings']; _i < _a.length; _i++) {
@@ -2475,6 +2583,7 @@ var Interaction = /** @class */ (function () {
2475
2583
  data = typeof data === 'object' ? data : {};
2476
2584
  data['Timeout'] = this.timeout;
2477
2585
  data['Title'] = this.title;
2586
+ data['Modal'] = this.modal;
2478
2587
  if (Array.isArray(this.settings)) {
2479
2588
  data['Settings'] = [];
2480
2589
  for (var _i = 0, _a = this.settings; _i < _a.length; _i++) {
@@ -2857,70 +2966,70 @@ var SessionEvent = /** @class */ (function () {
2857
2966
  SessionEvent.fromJS = function (data) {
2858
2967
  data = typeof data === 'object' ? data : {};
2859
2968
  if (data['discriminator'] === 'SessionTimeoutEventArgs') {
2860
- var result_25 = new SessionTimeoutEventArgs();
2861
- result_25.init(data);
2862
- return result_25;
2863
- }
2864
- if (data['discriminator'] === 'StartingEventArgs') {
2865
- var result_26 = new StartingEventArgs();
2969
+ var result_26 = new SessionTimeoutEventArgs();
2866
2970
  result_26.init(data);
2867
2971
  return result_26;
2868
2972
  }
2869
- if (data['discriminator'] === 'StartedEventArgs') {
2870
- var result_27 = new StartedEventArgs();
2973
+ if (data['discriminator'] === 'StartingEventArgs') {
2974
+ var result_27 = new StartingEventArgs();
2871
2975
  result_27.init(data);
2872
2976
  return result_27;
2873
2977
  }
2874
- if (data['discriminator'] === 'StoppingEventArgs') {
2875
- var result_28 = new StoppingEventArgs();
2978
+ if (data['discriminator'] === 'StartedEventArgs') {
2979
+ var result_28 = new StartedEventArgs();
2876
2980
  result_28.init(data);
2877
2981
  return result_28;
2878
2982
  }
2879
- if (data['discriminator'] === 'StoppedEventArgs') {
2880
- var result_29 = new StoppedEventArgs();
2983
+ if (data['discriminator'] === 'StoppingEventArgs') {
2984
+ var result_29 = new StoppingEventArgs();
2881
2985
  result_29.init(data);
2882
2986
  return result_29;
2883
2987
  }
2884
- if (data['discriminator'] === 'TestPlanChangeEventArgs') {
2885
- var result_30 = new TestPlanChangeEventArgs();
2988
+ if (data['discriminator'] === 'StoppedEventArgs') {
2989
+ var result_30 = new StoppedEventArgs();
2886
2990
  result_30.init(data);
2887
2991
  return result_30;
2888
2992
  }
2889
- if (data['discriminator'] === 'TestPlanExecutionStateChangedEventArgs') {
2890
- var result_31 = new TestPlanExecutionStateChangedEventArgs();
2993
+ if (data['discriminator'] === 'TestPlanChangeEventArgs') {
2994
+ var result_31 = new TestPlanChangeEventArgs();
2891
2995
  result_31.init(data);
2892
2996
  return result_31;
2893
2997
  }
2894
- if (data['discriminator'] === 'SettingsChangedEventArgs') {
2895
- var result_32 = new SettingsChangedEventArgs();
2998
+ if (data['discriminator'] === 'TestPlanExecutionStateChangedEventArgs') {
2999
+ var result_32 = new TestPlanExecutionStateChangedEventArgs();
2896
3000
  result_32.init(data);
2897
3001
  return result_32;
2898
3002
  }
2899
- if (data['discriminator'] === 'TestStepChangeEventArgs') {
2900
- var result_33 = new TestStepChangeEventArgs();
3003
+ if (data['discriminator'] === 'SettingsChangedEventArgs') {
3004
+ var result_33 = new SettingsChangedEventArgs();
2901
3005
  result_33.init(data);
2902
3006
  return result_33;
2903
3007
  }
2904
- if (data['discriminator'] === 'BreakEventArgs') {
2905
- var result_34 = new BreakEventArgs();
3008
+ if (data['discriminator'] === 'TestStepChangeEventArgs') {
3009
+ var result_34 = new TestStepChangeEventArgs();
2906
3010
  result_34.init(data);
2907
3011
  return result_34;
2908
3012
  }
2909
- if (data['discriminator'] === 'UserInputRequestEventArgs') {
2910
- var result_35 = new UserInputRequestEventArgs();
3013
+ if (data['discriminator'] === 'BreakEventArgs') {
3014
+ var result_35 = new BreakEventArgs();
2911
3015
  result_35.init(data);
2912
3016
  return result_35;
2913
3017
  }
2914
- if (data['discriminator'] === 'UserInputRequestCompletedEventArgs') {
2915
- var result_36 = new UserInputRequestCompletedEventArgs();
3018
+ if (data['discriminator'] === 'UserInputRequestEventArgs') {
3019
+ var result_36 = new UserInputRequestEventArgs();
2916
3020
  result_36.init(data);
2917
3021
  return result_36;
2918
3022
  }
2919
- if (data['discriminator'] === 'TestPlanSettingsChangedEventArgs') {
2920
- var result_37 = new TestPlanSettingsChangedEventArgs();
3023
+ if (data['discriminator'] === 'UserInputRequestCompletedEventArgs') {
3024
+ var result_37 = new UserInputRequestCompletedEventArgs();
2921
3025
  result_37.init(data);
2922
3026
  return result_37;
2923
3027
  }
3028
+ if (data['discriminator'] === 'TestPlanSettingsChangedEventArgs') {
3029
+ var result_38 = new TestPlanSettingsChangedEventArgs();
3030
+ result_38.init(data);
3031
+ return result_38;
3032
+ }
2924
3033
  var result = new SessionEvent();
2925
3034
  result.init(data);
2926
3035
  return result;
@@ -1,9 +1,8 @@
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 {
5
- private eventsSubscription;
6
- private eventsWildcardSubscription;
5
+ private subscriptions;
7
6
  constructor(baseSubject: string, options: ConnectionOptions);
8
7
  /**
9
8
  * @param sessionLogsHandler Function to be called when log list or error is received
@@ -87,6 +86,11 @@ export declare class SessionClient extends BaseClient {
87
86
  * @return Test plan retrieved
88
87
  */
89
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<string>;
90
94
  /**
91
95
  * Load test plan using a test plan TapPackage from a repository
92
96
  * @param {RepositoryPackageDefinition} packageReference
@@ -27,10 +27,13 @@ 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) {
33
- return _super.call(this, baseSubject, options) || this;
34
+ var _this = _super.call(this, baseSubject, options) || this;
35
+ _this.subscriptions = [];
36
+ return _this;
34
37
  }
35
38
  /**
36
39
  * @param sessionLogsHandler Function to be called when log list or error is received
@@ -75,8 +78,8 @@ var SessionClient = /** @class */ (function (_super) {
75
78
  eventHandler(undefined, error);
76
79
  }
77
80
  };
78
- this.eventsSubscription = this.subscribe('Events', __assign(__assign({}, options), { callback: callback }));
79
- this.eventsWildcardSubscription = this.subscribe('Events.*', __assign(__assign({}, options), { callback: callback }));
81
+ this.subscriptions.push(this.subscribe('Events', __assign(__assign({}, options), { callback: callback })));
82
+ this.subscriptions.push(this.subscribe('Events.*', __assign(__assign({}, options), { callback: callback })));
80
83
  };
81
84
  /**
82
85
  * @param resultHandler Function to be called when result or error is received
@@ -122,12 +125,8 @@ var SessionClient = /** @class */ (function (_super) {
122
125
  * Unsubscibe from session events
123
126
  */
124
127
  SessionClient.prototype.unsubscribeSessionEvents = function () {
125
- if (this.eventsSubscription) {
126
- this.eventsSubscription.unsubscribe();
127
- }
128
- if (this.eventsWildcardSubscription) {
129
- this.eventsWildcardSubscription.unsubscribe();
130
- }
128
+ var _a;
129
+ (_a = this.subscriptions) === null || _a === void 0 ? void 0 : _a.forEach(function (subscription) { return subscription.unsubscribe(); });
131
130
  };
132
131
  /**
133
132
  * Retrieve session logs
@@ -199,14 +198,32 @@ var SessionClient = /** @class */ (function (_super) {
199
198
  * @return Test plan loaded. List of load errors is returned.
200
199
  */
201
200
  SessionClient.prototype.setTestPlanXML = function (xml) {
202
- return this.request('SetTestPlanXML', xml).then(this.success()).catch(this.error());
201
+ return this.sendChunked('SetTestPlanXML', xml).then(this.success()).catch(this.error());
203
202
  };
204
203
  /**
205
204
  * Retrieve loaded test plan XML
206
205
  * @return Test plan retrieved
207
206
  */
208
207
  SessionClient.prototype.getTestPlanXML = function () {
209
- return this.request('GetTestPlanXML').then(this.success()).catch(this.error());
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)
225
+ .then(this.success())
226
+ .catch(this.error());
210
227
  };
211
228
  /**
212
229
  * Load test plan using a test plan TapPackage from a repository
@@ -229,7 +246,8 @@ var SessionClient = /** @class */ (function (_super) {
229
246
  * @return Test plan resources opened.
230
247
  */
231
248
  SessionClient.prototype.resourcesOpen = function () {
232
- return this.request('ResourcesOpen')
249
+ var replySubject = "_INBOX.".concat(uuidv4());
250
+ return this.requestChunked('ResourcesOpen', replySubject, replySubject)
233
251
  .then(function (testPlanJs) { return TestPlan.fromJS(testPlanJs); })
234
252
  .then(this.success())
235
253
  .catch(this.error());
@@ -239,7 +257,8 @@ var SessionClient = /** @class */ (function (_super) {
239
257
  * @return Test plan resources closed.
240
258
  */
241
259
  SessionClient.prototype.resourcesClose = function () {
242
- return this.request('ResourcesClose')
260
+ var replySubject = "_INBOX.".concat(uuidv4());
261
+ return this.requestChunked('ResourcesClose', replySubject, replySubject)
243
262
  .then(function (testPlanJs) { return TestPlan.fromJS(testPlanJs); })
244
263
  .then(this.success())
245
264
  .catch(this.error());
@@ -274,7 +293,12 @@ var SessionClient = /** @class */ (function (_super) {
274
293
  * @return Test plan retrieved
275
294
  */
276
295
  SessionClient.prototype.getTestPlan = function (properties) {
277
- return this.request('GetTestPlan', properties)
296
+ var replySubject = "_INBOX.".concat(uuidv4());
297
+ var payload = {
298
+ subject: replySubject,
299
+ properties: properties,
300
+ };
301
+ return this.requestChunked('GetTestPlan', replySubject, payload)
278
302
  .then(function (testPlanJs) { return TestPlan.fromJS(testPlanJs); })
279
303
  .then(this.success())
280
304
  .catch(this.error());
@@ -285,7 +309,7 @@ var SessionClient = /** @class */ (function (_super) {
285
309
  * @return Test plan changed
286
310
  */
287
311
  SessionClient.prototype.setTestPlan = function (plan) {
288
- return this.request('SetTestPlan', plan)
312
+ return this.sendChunked('SetTestPlan', plan)
289
313
  .then(function (testPlanJs) { return TestPlan.fromJS(testPlanJs); })
290
314
  .then(this.success())
291
315
  .catch(this.error());
package/lib/index.js CHANGED
@@ -2,6 +2,3 @@ export { RunnerClient } from './RunnerClient';
2
2
  export { SessionClient } from './SessionClient';
3
3
  export * from './DTOs';
4
4
  export * from 'nats.ws';
5
- //export * from 'nats.ws/lib/nats-base-client/types'; // TODO: Delete this line if you are consuming this library in angular > v11. The types export will be done automatically.
6
- //export * from 'nats.ws/lib/nats-base-client/authenticator';
7
- //export * from 'nats.ws/lib/nats-base-client/error';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentap/runner-client",
3
- "version": "2.0.0-alpha.2.2",
3
+ "version": "2.0.0-alpha.2.20",
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}": [