@opentap/runner-client 2.0.0-alpha.2.14 → 2.0.0-alpha.2.16

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.
@@ -28,7 +28,7 @@ export declare class BaseClient {
28
28
  * @param options (optional)
29
29
  * @returns Promise of an object
30
30
  */
31
- protected request<T>(subject: string, payload?: any, options?: RequestOptions): Promise<T>;
31
+ protected request<T>(subject: string, payload?: any, options?: RequestOptions, isFullSubject?: boolean): Promise<T>;
32
32
  /**
33
33
  * Handle the error
34
34
  * @param error
@@ -63,7 +63,7 @@ export declare class BaseClient {
63
63
  * @param options (optional)
64
64
  * @returns Promise of an object
65
65
  */
66
- protected requestChunked<T>(subject: string, options?: RequestOptions): Promise<T>;
66
+ protected requestChunked<T>(subject: string, options?: RequestOptions, isFullSubject?: boolean): Promise<T>;
67
67
  /**
68
68
  * Check if the the response is an error from the server.
69
69
  * @param {any} response
package/lib/BaseClient.js CHANGED
@@ -109,14 +109,14 @@ var BaseClient = /** @class */ (function () {
109
109
  * @param options (optional)
110
110
  * @returns Promise of an object
111
111
  */
112
- BaseClient.prototype.request = function (subject, payload, options) {
112
+ BaseClient.prototype.request = function (subject, payload, options, isFullSubject) {
113
113
  return __awaiter(this, void 0, void 0, function () {
114
114
  var stringCodec, data, headers, opts;
115
115
  var _this = this;
116
116
  return __generator(this, function (_a) {
117
117
  switch (_a.label) {
118
118
  case 0:
119
- subject = "".concat(this.baseSubject, ".Request.").concat(subject);
119
+ subject = isFullSubject ? subject : "".concat(this.baseSubject, ".Request.").concat(subject);
120
120
  if (!this.connection)
121
121
  return [2 /*return*/, Promise.reject("".concat(subject, ": Connection is down! Please try again!"))];
122
122
  if (this.connection.isClosed())
@@ -197,7 +197,7 @@ var BaseClient = /** @class */ (function () {
197
197
  */
198
198
  BaseClient.prototype.sendChunked = function (subject, payload, options) {
199
199
  return __awaiter(this, void 0, void 0, function () {
200
- var requestSubject, stringCodec, data, headers, opts, fileDescriptor, getChunk, message, i, response, jsonCodec;
200
+ var requestSubject, stringCodec, data, headers, opts, fileDescriptor, getChunk, dataSubject, message, i, response, jsonCodec;
201
201
  return __generator(this, function (_a) {
202
202
  switch (_a.label) {
203
203
  case 0:
@@ -217,19 +217,21 @@ var BaseClient = /** @class */ (function () {
217
217
  var offset = chunk * fileDescriptor.chunkSize;
218
218
  return data.slice(offset, offset + fileDescriptor.chunkSize);
219
219
  };
220
- this.request(subject, fileDescriptor);
221
- i = 0;
222
- _a.label = 1;
220
+ return [4 /*yield*/, this.request(subject, fileDescriptor)];
223
221
  case 1:
224
- if (!(i < fileDescriptor.numberOfChunks)) return [3 /*break*/, 4];
225
- return [4 /*yield*/, this.connection.request(requestSubject, getChunk(i), opts)];
222
+ dataSubject = _a.sent();
223
+ i = 0;
224
+ _a.label = 2;
226
225
  case 2:
227
- message = _a.sent();
228
- _a.label = 3;
226
+ if (!(i < fileDescriptor.numberOfChunks)) return [3 /*break*/, 5];
227
+ return [4 /*yield*/, this.connection.request(dataSubject, getChunk(i), opts)];
229
228
  case 3:
230
- i++;
231
- return [3 /*break*/, 1];
229
+ message = _a.sent();
230
+ _a.label = 4;
232
231
  case 4:
232
+ i++;
233
+ return [3 /*break*/, 2];
234
+ case 5:
233
235
  if (message && message.data.length !== 0) {
234
236
  jsonCodec = JSONCodec();
235
237
  response = jsonCodec.decode(message.data);
@@ -246,7 +248,7 @@ var BaseClient = /** @class */ (function () {
246
248
  * @param options (optional)
247
249
  * @returns Promise of an object
248
250
  */
249
- BaseClient.prototype.requestChunked = function (subject, options) {
251
+ BaseClient.prototype.requestChunked = function (subject, options, isFullSubject) {
250
252
  return __awaiter(this, void 0, void 0, function () {
251
253
  var replySubject, requestSubject, headers, opts;
252
254
  var _this = this;
@@ -261,9 +263,9 @@ var BaseClient = /** @class */ (function () {
261
263
  opts = __assign(__assign({}, options), { timeout: this.timeout, headers: headers });
262
264
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
263
265
  return [2 /*return*/, new Promise(function (resolve, reject) {
264
- var numberOfChunks = 9999;
265
- var combinedResult = new Uint8Array([]);
266
+ var numberOfChunks = -1;
266
267
  var received = 0;
268
+ var combinedResult = new Uint8Array([]);
267
269
  var resolveIfComplete = function () {
268
270
  if (received === numberOfChunks) {
269
271
  resolve(combinedResult);
@@ -279,7 +281,7 @@ var BaseClient = /** @class */ (function () {
279
281
  message.respond(Empty);
280
282
  resolveIfComplete();
281
283
  };
282
- return _this.request(subject, replySubject, opts)
284
+ return _this.request(subject, replySubject, opts, isFullSubject)
283
285
  .then(function (fileDescriptor) { return FileDescriptor.fromJS(fileDescriptor); })
284
286
  .then(function (fileDescriptor) {
285
287
  numberOfChunks = fileDescriptor.numberOfChunks;
@@ -217,7 +217,7 @@ var SessionClient = /** @class */ (function (_super) {
217
217
  return Promise.reject('The source of the provided resource is not a nats subject.');
218
218
  }
219
219
  var subject = resource.source.replace(runnerResourcePrefix, '');
220
- return this.requestChunked(subject).then(this.success()).catch(this.error());
220
+ return this.requestChunked(subject, undefined, true).then(this.success()).catch(this.error());
221
221
  };
222
222
  /**
223
223
  * 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.14",
3
+ "version": "2.0.0-alpha.2.16",
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",