@opentap/runner-client 2.0.2-alpha.2.2 → 2.1.0-alpha.1.1

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
@@ -44,7 +44,7 @@ class client {
44
44
  }
45
45
 
46
46
  ```
47
-
47
+
48
48
 
49
49
  ## How to build locally
50
50
 
@@ -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
- 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,135 @@ 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
+ if (!_this.connection) {
229
+ return Promise.reject('No nats connection.');
230
+ }
231
+ var combinedResult = new Uint8Array([]);
232
+ // Subscribe to dataSubject before sending the terminating message to ensure we are listening before the server starts responding
233
+ var subscription = _this.connection.subscribe(dataSubject);
234
+ // Publish an empty message to indicate that we are ready to listen
235
+ _this.connection.publish(dataSubject, Empty, opts);
236
+ var first = true;
237
+ subscription.callback = function (error, message) {
238
+ // The first message is the empty message we published above.
239
+ // We should discard this message before we proceed
240
+ if (first === true) {
241
+ first = false;
242
+ return;
243
+ }
244
+ if (error) {
245
+ reject(error);
246
+ }
247
+ combinedResult = new Uint8Array(__spreadArray(__spreadArray([], Array.from(combinedResult), true), Array.from(message === null || message === void 0 ? void 0 : message.data), true));
248
+ if ((message === null || message === void 0 ? void 0 : message.data.length) === 0) {
249
+ resolve(combinedResult);
250
+ }
251
+ };
252
+ }).then(function (byteArray) {
253
+ var jsonCodec = JSONCodec();
254
+ var response = jsonCodec.decode(byteArray);
255
+ return _this.isErrorResponse(response) ? Promise.reject(ErrorResponse.fromJS(response)) : Promise.resolve(response);
256
+ })];
257
+ }
258
+ });
259
+ });
260
+ };
261
+ /**
262
+ * Request an object to the nats server with chunks.
263
+ * @param subject The subject to request
264
+ * @param payload (optional)
265
+ * @param options (optional)
266
+ * @returns Promise of an object
267
+ */
268
+ BaseClient.prototype.requestChunked = function (subject, replySubject, payload, options, isFullSubject, rawResponse) {
269
+ return __awaiter(this, void 0, void 0, function () {
270
+ var fileSize;
271
+ var _this = this;
272
+ return __generator(this, function (_a) {
273
+ if (!this.connection)
274
+ return [2 /*return*/, Promise.reject("".concat(subject, ": Connection is down! Please try again!"))];
275
+ if (this.connection.isClosed())
276
+ return [2 /*return*/, Promise.reject("".concat(subject, ": Connection has been closed! Please reconnect!"))];
277
+ fileSize = -1;
278
+ return [2 /*return*/, new Promise(function (resolve, reject) {
279
+ var combinedResult = new Uint8Array([]);
280
+ // Subscribe to the subject before starting the process
281
+ var subscription = _this.connection.subscribe(replySubject);
282
+ var resolveIfCompleted = function () {
283
+ if (combinedResult.length === fileSize) {
284
+ subscription.unsubscribe();
285
+ resolve(combinedResult);
286
+ }
287
+ };
288
+ subscription.callback = function (error, message) {
289
+ if (error) {
290
+ reject(error);
291
+ }
292
+ combinedResult = new Uint8Array(__spreadArray(__spreadArray([], Array.from(combinedResult), true), Array.from(message === null || message === void 0 ? void 0 : message.data), true));
293
+ resolveIfCompleted();
294
+ };
295
+ var headers = _this.buildHeaders();
296
+ var opts = __assign(__assign({}, options), { timeout: _this.timeout, headers: headers });
297
+ // Request the file descriptor from the runner by posting the reply subject
298
+ return _this.request(subject, payload, opts, isFullSubject)
299
+ .then(function (fileDescriptor) { return FileDescriptor.fromJS(fileDescriptor); })
300
+ .then(function (fileDescriptor) {
301
+ fileSize = fileDescriptor.fileSize;
302
+ resolveIfCompleted();
303
+ })
304
+ .catch(function (error) {
305
+ subscription.unsubscribe();
306
+ throw error;
307
+ });
308
+ }).then(function (byteArray) {
309
+ if (byteArray.length !== fileSize)
310
+ return Promise.reject("Unexpected response size. Expected ".concat(fileSize, " bytes, but got ").concat(byteArray.length, "."));
311
+ // Avoid decoding the response if the expected response is bytearray
312
+ if (rawResponse)
313
+ return Promise.resolve(byteArray);
314
+ var jsonCodec = JSONCodec();
315
+ var response = jsonCodec.decode(byteArray);
316
+ return _this.isErrorResponse(response) ? Promise.reject(ErrorResponse.fromJS(response)) : Promise.resolve(response);
317
+ })];
318
+ });
319
+ });
320
+ };
181
321
  /**
182
322
  * Check if the the response is an error from the server.
183
323
  * @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);
@@ -756,7 +803,6 @@ export declare class TestStep implements ITestStep {
756
803
  typeName?: string | undefined;
757
804
  typeDisplay?: DisplayAttribute | undefined;
758
805
  name?: string | undefined;
759
- expandedName?: string | undefined;
760
806
  protected _discriminator: string;
761
807
  constructor(data?: ITestStep);
762
808
  init(_data?: any): void;
@@ -772,7 +818,6 @@ export interface ITestStep {
772
818
  typeName?: string | undefined;
773
819
  typeDisplay?: DisplayAttribute | undefined;
774
820
  name?: string | undefined;
775
- expandedName?: string | undefined;
776
821
  }
777
822
  export declare class TestStepType extends TestStep implements ITestStepType {
778
823
  availableChildrenTypes?: string[] | undefined;
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 result_13 = new ComboBoxControl();
1001
- result_13.init(data);
1002
- return result_13;
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 result_14 = new SessionStartInitiated();
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'] === 'SessionStartFailed') {
1545
- var result_16 = new SessionStartFailed();
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'] === 'SessionShutdownInitiated') {
1550
- var result_17 = new SessionShutdownInitiated();
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'] === 'SessionShutdown') {
1555
- var result_18 = new SessionShutdown();
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'] === 'SessionShutdownFailed') {
1560
- var result_19 = new SessionShutdownFailed();
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'] === 'SessionInactivityLimitHit') {
1565
- var result_20 = new SessionInactivityLimitHit();
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 result_21 = new ImageCreating();
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'] === 'ImageCreationFailed') {
1790
- var result_23 = new ImageCreationFailed();
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;
@@ -2195,15 +2300,14 @@ var TestStep = /** @class */ (function () {
2195
2300
  this.typeName = _data['TypeName'];
2196
2301
  this.typeDisplay = _data['TypeDisplay'] ? DisplayAttribute.fromJS(_data['TypeDisplay']) : undefined;
2197
2302
  this.name = _data['Name'];
2198
- this.expandedName = _data['ExpandedName'];
2199
2303
  }
2200
2304
  };
2201
2305
  TestStep.fromJS = function (data) {
2202
2306
  data = typeof data === 'object' ? data : {};
2203
2307
  if (data['TestStepTypeOrInstance'] === 'TestStepType') {
2204
- var result_24 = new TestStepType();
2205
- result_24.init(data);
2206
- return result_24;
2308
+ var result_25 = new TestStepType();
2309
+ result_25.init(data);
2310
+ return result_25;
2207
2311
  }
2208
2312
  var result = new TestStep();
2209
2313
  result.init(data);
@@ -2232,7 +2336,6 @@ var TestStep = /** @class */ (function () {
2232
2336
  data['TypeName'] = this.typeName;
2233
2337
  data['TypeDisplay'] = this.typeDisplay ? this.typeDisplay.toJSON() : undefined;
2234
2338
  data['Name'] = this.name;
2235
- data['ExpandedName'] = this.expandedName;
2236
2339
  return data;
2237
2340
  };
2238
2341
  return TestStep;
@@ -2863,70 +2966,70 @@ var SessionEvent = /** @class */ (function () {
2863
2966
  SessionEvent.fromJS = function (data) {
2864
2967
  data = typeof data === 'object' ? data : {};
2865
2968
  if (data['discriminator'] === 'SessionTimeoutEventArgs') {
2866
- var result_25 = new SessionTimeoutEventArgs();
2867
- result_25.init(data);
2868
- return result_25;
2869
- }
2870
- if (data['discriminator'] === 'StartingEventArgs') {
2871
- var result_26 = new StartingEventArgs();
2969
+ var result_26 = new SessionTimeoutEventArgs();
2872
2970
  result_26.init(data);
2873
2971
  return result_26;
2874
2972
  }
2875
- if (data['discriminator'] === 'StartedEventArgs') {
2876
- var result_27 = new StartedEventArgs();
2973
+ if (data['discriminator'] === 'StartingEventArgs') {
2974
+ var result_27 = new StartingEventArgs();
2877
2975
  result_27.init(data);
2878
2976
  return result_27;
2879
2977
  }
2880
- if (data['discriminator'] === 'StoppingEventArgs') {
2881
- var result_28 = new StoppingEventArgs();
2978
+ if (data['discriminator'] === 'StartedEventArgs') {
2979
+ var result_28 = new StartedEventArgs();
2882
2980
  result_28.init(data);
2883
2981
  return result_28;
2884
2982
  }
2885
- if (data['discriminator'] === 'StoppedEventArgs') {
2886
- var result_29 = new StoppedEventArgs();
2983
+ if (data['discriminator'] === 'StoppingEventArgs') {
2984
+ var result_29 = new StoppingEventArgs();
2887
2985
  result_29.init(data);
2888
2986
  return result_29;
2889
2987
  }
2890
- if (data['discriminator'] === 'TestPlanChangeEventArgs') {
2891
- var result_30 = new TestPlanChangeEventArgs();
2988
+ if (data['discriminator'] === 'StoppedEventArgs') {
2989
+ var result_30 = new StoppedEventArgs();
2892
2990
  result_30.init(data);
2893
2991
  return result_30;
2894
2992
  }
2895
- if (data['discriminator'] === 'TestPlanExecutionStateChangedEventArgs') {
2896
- var result_31 = new TestPlanExecutionStateChangedEventArgs();
2993
+ if (data['discriminator'] === 'TestPlanChangeEventArgs') {
2994
+ var result_31 = new TestPlanChangeEventArgs();
2897
2995
  result_31.init(data);
2898
2996
  return result_31;
2899
2997
  }
2900
- if (data['discriminator'] === 'SettingsChangedEventArgs') {
2901
- var result_32 = new SettingsChangedEventArgs();
2998
+ if (data['discriminator'] === 'TestPlanExecutionStateChangedEventArgs') {
2999
+ var result_32 = new TestPlanExecutionStateChangedEventArgs();
2902
3000
  result_32.init(data);
2903
3001
  return result_32;
2904
3002
  }
2905
- if (data['discriminator'] === 'TestStepChangeEventArgs') {
2906
- var result_33 = new TestStepChangeEventArgs();
3003
+ if (data['discriminator'] === 'SettingsChangedEventArgs') {
3004
+ var result_33 = new SettingsChangedEventArgs();
2907
3005
  result_33.init(data);
2908
3006
  return result_33;
2909
3007
  }
2910
- if (data['discriminator'] === 'BreakEventArgs') {
2911
- var result_34 = new BreakEventArgs();
3008
+ if (data['discriminator'] === 'TestStepChangeEventArgs') {
3009
+ var result_34 = new TestStepChangeEventArgs();
2912
3010
  result_34.init(data);
2913
3011
  return result_34;
2914
3012
  }
2915
- if (data['discriminator'] === 'UserInputRequestEventArgs') {
2916
- var result_35 = new UserInputRequestEventArgs();
3013
+ if (data['discriminator'] === 'BreakEventArgs') {
3014
+ var result_35 = new BreakEventArgs();
2917
3015
  result_35.init(data);
2918
3016
  return result_35;
2919
3017
  }
2920
- if (data['discriminator'] === 'UserInputRequestCompletedEventArgs') {
2921
- var result_36 = new UserInputRequestCompletedEventArgs();
3018
+ if (data['discriminator'] === 'UserInputRequestEventArgs') {
3019
+ var result_36 = new UserInputRequestEventArgs();
2922
3020
  result_36.init(data);
2923
3021
  return result_36;
2924
3022
  }
2925
- if (data['discriminator'] === 'TestPlanSettingsChangedEventArgs') {
2926
- var result_37 = new TestPlanSettingsChangedEventArgs();
3023
+ if (data['discriminator'] === 'UserInputRequestCompletedEventArgs') {
3024
+ var result_37 = new UserInputRequestCompletedEventArgs();
2927
3025
  result_37.init(data);
2928
3026
  return result_37;
2929
3027
  }
3028
+ if (data['discriminator'] === 'TestPlanSettingsChangedEventArgs') {
3029
+ var result_38 = new TestPlanSettingsChangedEventArgs();
3030
+ result_38.init(data);
3031
+ return result_38;
3032
+ }
2930
3033
  var result = new SessionEvent();
2931
3034
  result.init(data);
2932
3035
  return result;
@@ -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
+ * Downloads the resource from the runner and returns it as raw bytes
91
+ * @return Raw bytes representing the 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
@@ -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.request('SetTestPlanXML', xml).then(this.success()).catch(this.error());
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
- 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
+ * Downloads the resource from the runner and returns it as raw bytes
214
+ * @return Raw bytes representing the 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
- return this.request('ResourcesOpen')
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
- return this.request('ResourcesClose')
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
- 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)
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.request('SetTestPlan', plan)
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.2.2",
3
+ "version": "2.1.0-alpha.1.1",
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}": [