@opentap/runner-client 2.0.0-alpha.2.9 → 2.0.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
 
@@ -48,22 +48,6 @@ export declare class BaseClient {
48
48
  * @returns Subscription object
49
49
  */
50
50
  protected subscribe(subject: string, options: SubscriptionOptions): Subscription;
51
- /**
52
- * Send a request to the nats server.
53
- * @param subject The subject to request
54
- * @param payload (optional)
55
- * @param options (optional)
56
- * @returns Promise of an object
57
- */
58
- protected sendChunked<T>(subject: string, payload?: any, options?: RequestOptions): Promise<T>;
59
- /**
60
- * Send a request to the nats server.
61
- * @param subject The subject to request
62
- * @param payload (optional)
63
- * @param options (optional)
64
- * @returns Promise of an object
65
- */
66
- protected requestChunked<T>(subject: string, options?: RequestOptions): Promise<T>;
67
51
  /**
68
52
  * Check if the the response is an error from the server.
69
53
  * @param {any} response
package/lib/BaseClient.js CHANGED
@@ -45,18 +45,8 @@ 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
- 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';
48
+ import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsListItem, DataGridControl, ErrorResponse, ListItemType, ProfileGroup, } from './DTOs';
58
49
  import { Empty, ErrorCode, JSONCodec, StringCodec, connect, headers, } from 'nats.ws';
59
- import { v4 as uuidv4 } from 'uuid';
60
50
  var DEFAULT_TIMEOUT = 6000;
61
51
  var BaseClient = /** @class */ (function () {
62
52
  function BaseClient(baseSubject, options) {
@@ -188,109 +178,6 @@ var BaseClient = /** @class */ (function () {
188
178
  var natsSubject = "".concat(this.baseSubject, ".").concat(subject);
189
179
  return this.connection.subscribe(natsSubject, options);
190
180
  };
191
- /**
192
- * Send a request to the nats server.
193
- * @param subject The subject to request
194
- * @param payload (optional)
195
- * @param options (optional)
196
- * @returns Promise of an object
197
- */
198
- BaseClient.prototype.sendChunked = function (subject, payload, options) {
199
- return __awaiter(this, void 0, void 0, function () {
200
- var requestSubject, stringCodec, data, headers, opts, fileDescriptor, getChunk, message, i, response, jsonCodec;
201
- return __generator(this, function (_a) {
202
- switch (_a.label) {
203
- case 0:
204
- requestSubject = "".concat(this.baseSubject, ".Request.").concat(subject);
205
- if (!this.connection)
206
- return [2 /*return*/, Promise.reject("".concat(requestSubject, ": Connection is down! Please try again!"))];
207
- if (this.connection.isClosed())
208
- return [2 /*return*/, Promise.reject("".concat(requestSubject, ": Connection has been closed! Please reconnect!"))];
209
- stringCodec = StringCodec();
210
- data = payload ? stringCodec.encode(JSON.stringify(payload)) : Empty;
211
- headers = this.buildHeaders();
212
- opts = __assign(__assign({}, options), { timeout: this.timeout, headers: headers });
213
- fileDescriptor = new FileDescriptor(data.length);
214
- if (!fileDescriptor.numberOfChunks)
215
- return [2 /*return*/, Promise.reject("".concat(requestSubject, ": File is empty!"))];
216
- getChunk = function (chunk) {
217
- var offset = chunk * fileDescriptor.chunkSize;
218
- return data.slice(offset, offset + fileDescriptor.chunkSize);
219
- };
220
- this.request(subject, fileDescriptor);
221
- i = 0;
222
- _a.label = 1;
223
- case 1:
224
- if (!(i < fileDescriptor.numberOfChunks)) return [3 /*break*/, 4];
225
- return [4 /*yield*/, this.connection.request(requestSubject, getChunk(i), opts)];
226
- case 2:
227
- message = _a.sent();
228
- _a.label = 3;
229
- case 3:
230
- i++;
231
- return [3 /*break*/, 1];
232
- case 4:
233
- if (message && message.data.length !== 0) {
234
- jsonCodec = JSONCodec();
235
- response = jsonCodec.decode(message.data);
236
- }
237
- return [2 /*return*/, this.isErrorResponse(response) ? Promise.reject(ErrorResponse.fromJS(response)) : Promise.resolve(response)];
238
- }
239
- });
240
- });
241
- };
242
- /**
243
- * Send a request to the nats server.
244
- * @param subject The subject to request
245
- * @param payload (optional)
246
- * @param options (optional)
247
- * @returns Promise of an object
248
- */
249
- BaseClient.prototype.requestChunked = function (subject, options) {
250
- return __awaiter(this, void 0, void 0, function () {
251
- var replySubject, requestSubject, stringCodec, data, headers, opts, fileDescriptor;
252
- var _this = this;
253
- return __generator(this, function (_a) {
254
- switch (_a.label) {
255
- case 0:
256
- replySubject = "_INBOX.".concat(uuidv4());
257
- requestSubject = "".concat(this.baseSubject, ".Request.").concat(subject);
258
- if (!this.connection)
259
- return [2 /*return*/, Promise.reject("".concat(requestSubject, ": Connection is down! Please try again!"))];
260
- if (this.connection.isClosed())
261
- return [2 /*return*/, Promise.reject("".concat(requestSubject, ": Connection has been closed! Please reconnect!"))];
262
- stringCodec = StringCodec();
263
- data = stringCodec.encode(JSON.stringify(replySubject));
264
- headers = this.buildHeaders();
265
- opts = __assign(__assign({}, options), { timeout: this.timeout, headers: headers });
266
- return [4 /*yield*/, this.request(subject, data, opts)];
267
- case 1:
268
- fileDescriptor = _a.sent();
269
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
270
- return [2 /*return*/, new Promise(function (resolve, reject) {
271
- var combinedResult = new Uint8Array([]);
272
- var received = 0;
273
- var subscription = _this.connection.subscribe(replySubject);
274
- subscription.callback = function (error, message) {
275
- if (error) {
276
- reject(error);
277
- }
278
- combinedResult = new Uint8Array(__spreadArray(__spreadArray([], Array.from(combinedResult), true), Array.from(message === null || message === void 0 ? void 0 : message.data), true));
279
- received++;
280
- message.respond(Empty);
281
- if (received === fileDescriptor.numberOfChunks) {
282
- resolve(combinedResult);
283
- }
284
- };
285
- }).then(function (byteArray) {
286
- var jsonCodec = JSONCodec();
287
- var response = jsonCodec.decode(byteArray);
288
- return _this.isErrorResponse(response) ? Promise.reject(ErrorResponse.fromJS(response)) : Promise.resolve(response);
289
- })];
290
- }
291
- });
292
- });
293
- };
294
181
  /**
295
182
  * Check if the the response is an error from the server.
296
183
  * @param {any} response
package/lib/DTOs.d.ts CHANGED
@@ -418,45 +418,6 @@ 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 FileDescriptor implements IFileDescriptor {
446
- numberOfChunks: number;
447
- fileSize: number;
448
- chunkSize: number;
449
- private readonly defaultChunkSize;
450
- constructor(fileSize: number, chunkSize?: number);
451
- init(_data?: any): void;
452
- static fromJS(data: any): Resource;
453
- toJSON(data?: any): any;
454
- }
455
- export interface IFileDescriptor {
456
- numberOfChunks: number;
457
- fileSize: number;
458
- chunkSize: number;
459
- }
460
421
  export declare class ComponentSettings extends ComponentSettingsBase implements IComponentSettings {
461
422
  settings?: Setting[] | undefined;
462
423
  constructor(data?: IComponentSettings);
@@ -795,6 +756,7 @@ export declare class TestStep implements ITestStep {
795
756
  typeName?: string | undefined;
796
757
  typeDisplay?: DisplayAttribute | undefined;
797
758
  name?: string | undefined;
759
+ expandedName?: string | undefined;
798
760
  protected _discriminator: string;
799
761
  constructor(data?: ITestStep);
800
762
  init(_data?: any): void;
@@ -810,6 +772,7 @@ export interface ITestStep {
810
772
  typeName?: string | undefined;
811
773
  typeDisplay?: DisplayAttribute | undefined;
812
774
  name?: string | undefined;
775
+ expandedName?: string | undefined;
813
776
  }
814
777
  export declare class TestStepType extends TestStep implements ITestStepType {
815
778
  availableChildrenTypes?: string[] | undefined;
package/lib/DTOs.js CHANGED
@@ -1238,100 +1238,6 @@ var PasswordControl = /** @class */ (function (_super) {
1238
1238
  return PasswordControl;
1239
1239
  }(Setting));
1240
1240
  export { PasswordControl };
1241
- var PictureControl = /** @class */ (function (_super) {
1242
- __extends(PictureControl, _super);
1243
- function PictureControl(data) {
1244
- var _this = _super.call(this, data) || this;
1245
- _this._discriminator = 'PictureControl';
1246
- return _this;
1247
- }
1248
- PictureControl.prototype.init = function (_data) {
1249
- _super.prototype.init.call(this, _data);
1250
- if (_data) {
1251
- this.description = _data['Description'];
1252
- this.mimeType = _data['MimeType'];
1253
- this.resource = _data['Resource'] ? Resource.fromJS(_data['Resource']) : undefined;
1254
- }
1255
- };
1256
- PictureControl.fromJS = function (data) {
1257
- data = typeof data === 'object' ? data : {};
1258
- var result = new PictureControl();
1259
- result.init(data);
1260
- return result;
1261
- };
1262
- PictureControl.prototype.toJSON = function (data) {
1263
- data = typeof data === 'object' ? data : {};
1264
- data['Description'] = this.description;
1265
- data['MimeType'] = this.mimeType;
1266
- data['Resource'] = this.resource ? this.resource.toJSON() : undefined;
1267
- _super.prototype.toJSON.call(this, data);
1268
- return data;
1269
- };
1270
- return PictureControl;
1271
- }(Setting));
1272
- export { PictureControl };
1273
- var Resource = /** @class */ (function () {
1274
- function Resource(data) {
1275
- if (data) {
1276
- for (var property in data) {
1277
- if (Object.prototype.hasOwnProperty.call(data, property))
1278
- this[property] = data[property];
1279
- }
1280
- }
1281
- }
1282
- Resource.prototype.init = function (_data) {
1283
- if (_data) {
1284
- this.source = _data['Source'];
1285
- }
1286
- };
1287
- Resource.fromJS = function (data) {
1288
- data = typeof data === 'object' ? data : {};
1289
- var result = new Resource();
1290
- result.init(data);
1291
- return result;
1292
- };
1293
- Resource.prototype.toJSON = function (data) {
1294
- data = typeof data === 'object' ? data : {};
1295
- data['Source'] = this.source;
1296
- return data;
1297
- };
1298
- return Resource;
1299
- }());
1300
- export { Resource };
1301
- var FileDescriptor = /** @class */ (function () {
1302
- function FileDescriptor(fileSize, chunkSize) {
1303
- var _a;
1304
- this.defaultChunkSize = 512000;
1305
- if (chunkSize === 0) {
1306
- throw Error('chunkSize cannot set to 0');
1307
- }
1308
- this.fileSize = fileSize;
1309
- this.chunkSize = chunkSize !== null && chunkSize !== void 0 ? chunkSize : this.defaultChunkSize;
1310
- this.numberOfChunks = Math.floor((((_a = this.fileSize) !== null && _a !== void 0 ? _a : 0) + this.chunkSize - 1) / this.chunkSize);
1311
- }
1312
- FileDescriptor.prototype.init = function (_data) {
1313
- if (_data) {
1314
- this.numberOfChunks = _data['NumberOfChunks'];
1315
- this.fileSize = _data['FileSize'];
1316
- this.chunkSize = _data['ChunkSize'];
1317
- }
1318
- };
1319
- FileDescriptor.fromJS = function (data) {
1320
- data = typeof data === 'object' ? data : {};
1321
- var result = new Resource();
1322
- result.init(data);
1323
- return result;
1324
- };
1325
- FileDescriptor.prototype.toJSON = function (data) {
1326
- data = typeof data === 'object' ? data : {};
1327
- data['NumberOfChunks'] = this.numberOfChunks;
1328
- data['FileSize'] = this.fileSize;
1329
- data['ChunkSize'] = this.chunkSize;
1330
- return data;
1331
- };
1332
- return FileDescriptor;
1333
- }());
1334
- export { FileDescriptor };
1335
1241
  var ComponentSettings = /** @class */ (function (_super) {
1336
1242
  __extends(ComponentSettings, _super);
1337
1243
  function ComponentSettings(data) {
@@ -2289,6 +2195,7 @@ var TestStep = /** @class */ (function () {
2289
2195
  this.typeName = _data['TypeName'];
2290
2196
  this.typeDisplay = _data['TypeDisplay'] ? DisplayAttribute.fromJS(_data['TypeDisplay']) : undefined;
2291
2197
  this.name = _data['Name'];
2198
+ this.expandedName = _data['ExpandedName'];
2292
2199
  }
2293
2200
  };
2294
2201
  TestStep.fromJS = function (data) {
@@ -2325,6 +2232,7 @@ var TestStep = /** @class */ (function () {
2325
2232
  data['TypeName'] = this.typeName;
2326
2233
  data['TypeDisplay'] = this.typeDisplay ? this.typeDisplay.toJSON() : undefined;
2327
2234
  data['Name'] = this.name;
2235
+ data['ExpandedName'] = this.expandedName;
2328
2236
  return data;
2329
2237
  };
2330
2238
  return TestStep;
@@ -1,4 +1,4 @@
1
- import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Interaction, ListItemType, LogList, Parameter, RepositoryPackageDefinition, RepositoryPackageReference, Resource, 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, 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,11 +86,6 @@ export declare class SessionClient extends BaseClient {
86
86
  * @return Test plan retrieved
87
87
  */
88
88
  getTestPlanXML(): Promise<string>;
89
- /**
90
- * Retrieve loaded test plan XML
91
- * @return Test plan retrieved
92
- */
93
- downloadResource(resource: Resource): Promise<Uint8Array>;
94
89
  /**
95
90
  * Load test plan using a test plan TapPackage from a repository
96
91
  * @param {RepositoryPackageDefinition} packageReference
@@ -197,27 +197,14 @@ var SessionClient = /** @class */ (function (_super) {
197
197
  * @return Test plan loaded. List of load errors is returned.
198
198
  */
199
199
  SessionClient.prototype.setTestPlanXML = function (xml) {
200
- return this.sendChunked('SetTestPlanXML', xml).then(this.success()).catch(this.error());
200
+ return this.request('SetTestPlanXML', xml).then(this.success()).catch(this.error());
201
201
  };
202
202
  /**
203
203
  * Retrieve loaded test plan XML
204
204
  * @return Test plan retrieved
205
205
  */
206
206
  SessionClient.prototype.getTestPlanXML = function () {
207
- return this.requestChunked('GetTestPlanXML').then(this.success()).catch(this.error());
208
- };
209
- /**
210
- * Retrieve loaded test plan XML
211
- * @return Test plan retrieved
212
- */
213
- SessionClient.prototype.downloadResource = function (resource) {
214
- var _a;
215
- var runnerResourcePrefix = 'subject://';
216
- if (!((_a = resource.source) === null || _a === void 0 ? void 0 : _a.startsWith(runnerResourcePrefix))) {
217
- return Promise.reject('The source of the provided resource is not a nats subject.');
218
- }
219
- var subject = resource.source.replace(runnerResourcePrefix, '');
220
- return this.requestChunked(subject).then(this.success()).catch(this.error());
207
+ return this.request('GetTestPlanXML').then(this.success()).catch(this.error());
221
208
  };
222
209
  /**
223
210
  * Load test plan using a test plan TapPackage from a repository
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opentap/runner-client",
3
- "version": "2.0.0-alpha.2.9",
3
+ "version": "2.0.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,7 +26,6 @@
26
26
  "url": "git://github.com/opentap/runner-client-web.git"
27
27
  },
28
28
  "devDependencies": {
29
- "@types/uuid": "^8.3.4",
30
29
  "@typescript-eslint/eslint-plugin": "^5.36.1",
31
30
  "@typescript-eslint/parser": "^5.36.1",
32
31
  "eslint": "^8.23.0",
@@ -39,8 +38,7 @@
39
38
  "typescript": "^4.8.2"
40
39
  },
41
40
  "dependencies": {
42
- "nats.ws": "^1.9.0",
43
- "uuid": "^9.0.0"
41
+ "nats.ws": "^1.9.0"
44
42
  },
45
43
  "lint-staged": {
46
44
  "*.{ts,js,html}": [