@opentap/runner-client 2.2.3 → 2.2.4-alpha.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/BaseClient.d.ts +24 -13
- package/lib/BaseClient.js +147 -118
- package/lib/DTOs.d.ts +0 -8
- package/lib/DTOs.js +0 -6
- package/lib/SessionClient.js +5 -17
- package/package.json +4 -3
package/lib/BaseClient.d.ts
CHANGED
|
@@ -31,7 +31,7 @@ export declare class BaseClient {
|
|
|
31
31
|
* without appending it to the baseSubject
|
|
32
32
|
* @returns Promise of an object
|
|
33
33
|
*/
|
|
34
|
-
protected request<T>(subject: string, payload?: any, options?: RequestOptions
|
|
34
|
+
protected request<T>(subject: string, payload?: any, options?: RequestOptions): Promise<T>;
|
|
35
35
|
/**
|
|
36
36
|
* Handle the error
|
|
37
37
|
* @param error
|
|
@@ -52,21 +52,32 @@ export declare class BaseClient {
|
|
|
52
52
|
*/
|
|
53
53
|
protected subscribe(subject: string, options: SubscriptionOptions): Subscription;
|
|
54
54
|
/**
|
|
55
|
-
*
|
|
56
|
-
* @param subject The subject
|
|
57
|
-
* @param payload
|
|
58
|
-
* @param options
|
|
59
|
-
* @
|
|
55
|
+
* Make a request to the runner with a chunked payload. The response will be received in chunks.
|
|
56
|
+
* @param subject The request subject.
|
|
57
|
+
* @param payload The request body which will be chunked
|
|
58
|
+
* @param options Optional request options
|
|
59
|
+
* @param rawResponse If true, the response will not be decoded
|
|
60
|
+
* @returns
|
|
60
61
|
*/
|
|
61
|
-
protected sendChunked<T>(subject: string, payload
|
|
62
|
+
protected sendChunked<T>(subject: string, payload: any, options?: RequestOptions, rawResponse?: boolean): Promise<T>;
|
|
62
63
|
/**
|
|
63
|
-
*
|
|
64
|
-
* @param
|
|
65
|
-
* @param
|
|
66
|
-
* @param options
|
|
67
|
-
* @returns
|
|
64
|
+
* Receive a chunked file specified by a request response
|
|
65
|
+
* @param requestResponse Contains a reply subject and a file descriptor which can be used to download chunks
|
|
66
|
+
* @param rawResponse If true, the response should not be decoded
|
|
67
|
+
* @param opts Request options
|
|
68
|
+
* @returns
|
|
69
|
+
*/
|
|
70
|
+
private downloadChunkedRequest;
|
|
71
|
+
/**
|
|
72
|
+
* Make a request to the runner whose response will be sent in chunked
|
|
73
|
+
* @param subject The request subject
|
|
74
|
+
* @param payload Optional request body
|
|
75
|
+
* @param options Optional request options
|
|
76
|
+
* @param rawResponse If true, the return value will not be decoded
|
|
77
|
+
* @param fullSubject If true, the base subject will not be prepended
|
|
78
|
+
* @returns
|
|
68
79
|
*/
|
|
69
|
-
protected requestChunked<T>(subject: string,
|
|
80
|
+
protected requestChunked<T>(subject: string, payload?: any, options?: RequestOptions, rawResponse?: boolean, fullSubject?: boolean): Promise<T>;
|
|
70
81
|
/**
|
|
71
82
|
* Check if the the response is an error from the server.
|
|
72
83
|
* @param {any} response
|
package/lib/BaseClient.js
CHANGED
|
@@ -45,15 +45,6 @@ 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
48
|
import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsListItem, DataGridControl, ErrorResponse, FileDescriptor, ListItemType, ProfileGroup, } from './DTOs';
|
|
58
49
|
import { Empty, ErrorCode, JSONCodec, StringCodec, connect, headers, } from 'nats.ws';
|
|
59
50
|
import { EventEmitter } from 'events';
|
|
@@ -116,14 +107,14 @@ var BaseClient = /** @class */ (function () {
|
|
|
116
107
|
* without appending it to the baseSubject
|
|
117
108
|
* @returns Promise of an object
|
|
118
109
|
*/
|
|
119
|
-
BaseClient.prototype.request = function (subject, payload, options
|
|
110
|
+
BaseClient.prototype.request = function (subject, payload, options) {
|
|
120
111
|
return __awaiter(this, void 0, void 0, function () {
|
|
121
112
|
var stringCodec, data, headers, timeout, opts;
|
|
122
113
|
var _this = this;
|
|
123
114
|
return __generator(this, function (_a) {
|
|
124
115
|
switch (_a.label) {
|
|
125
116
|
case 0:
|
|
126
|
-
subject =
|
|
117
|
+
subject = "".concat(this.baseSubject, ".Request.").concat(subject);
|
|
127
118
|
if (!this.connection)
|
|
128
119
|
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection is down! Please try again!"))];
|
|
129
120
|
if (this.connection.isClosed())
|
|
@@ -198,16 +189,16 @@ var BaseClient = /** @class */ (function () {
|
|
|
198
189
|
return this.connection.subscribe(natsSubject, options);
|
|
199
190
|
};
|
|
200
191
|
/**
|
|
201
|
-
*
|
|
202
|
-
* @param subject The subject
|
|
203
|
-
* @param payload
|
|
204
|
-
* @param options
|
|
205
|
-
* @
|
|
192
|
+
* Make a request to the runner with a chunked payload. The response will be received in chunks.
|
|
193
|
+
* @param subject The request subject.
|
|
194
|
+
* @param payload The request body which will be chunked
|
|
195
|
+
* @param options Optional request options
|
|
196
|
+
* @param rawResponse If true, the response will not be decoded
|
|
197
|
+
* @returns
|
|
206
198
|
*/
|
|
207
|
-
BaseClient.prototype.sendChunked = function (subject, payload, options) {
|
|
199
|
+
BaseClient.prototype.sendChunked = function (subject, payload, options, rawResponse) {
|
|
208
200
|
return __awaiter(this, void 0, void 0, function () {
|
|
209
|
-
var stringCodec, data, headers, opts, fileDescriptor, getChunk, dataSubject, i;
|
|
210
|
-
var _this = this;
|
|
201
|
+
var stringCodec, data, headers, opts, fileDescriptor, requestResponse, jsonCodec, response, error, getChunk, dataSubject, i;
|
|
211
202
|
return __generator(this, function (_a) {
|
|
212
203
|
switch (_a.label) {
|
|
213
204
|
case 0:
|
|
@@ -215,126 +206,164 @@ var BaseClient = /** @class */ (function () {
|
|
|
215
206
|
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection is down! Please try again!"))];
|
|
216
207
|
if (this.connection.isClosed())
|
|
217
208
|
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection has been closed! Please reconnect!"))];
|
|
209
|
+
subject = "".concat(this.baseSubject, ".Request.").concat(subject);
|
|
218
210
|
stringCodec = StringCodec();
|
|
219
|
-
|
|
211
|
+
if (payload) {
|
|
212
|
+
data = payload instanceof Uint8Array ? payload : stringCodec.encode(JSON.stringify(payload));
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
data = Empty;
|
|
216
|
+
}
|
|
220
217
|
headers = this.buildHeaders();
|
|
221
218
|
opts = __assign(__assign({}, options), { timeout: this.timeout, headers: headers });
|
|
222
219
|
fileDescriptor = new FileDescriptor(data.length);
|
|
223
220
|
if (!fileDescriptor.numberOfChunks)
|
|
224
221
|
return [2 /*return*/, Promise.reject("".concat(subject, ": File is empty!"))];
|
|
222
|
+
return [4 /*yield*/, this.connection.request(subject, stringCodec.encode(JSON.stringify(fileDescriptor)), opts)];
|
|
223
|
+
case 1:
|
|
224
|
+
requestResponse = _a.sent();
|
|
225
|
+
if (requestResponse.data.length > 0) {
|
|
226
|
+
jsonCodec = JSONCodec();
|
|
227
|
+
response = jsonCodec.decode(requestResponse.data);
|
|
228
|
+
if (this.isErrorResponse(response)) {
|
|
229
|
+
error = ErrorResponse.fromJS(response);
|
|
230
|
+
this.eventEmitter.emit(Events.ERROR, error);
|
|
231
|
+
return [2 /*return*/, Promise.reject(error)];
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
// This should never happen. If it does happen, it likely means we are targetting an incompatible Runner version.
|
|
235
|
+
if (!requestResponse.reply) {
|
|
236
|
+
return [2 /*return*/, Promise.reject('Send chunks: Runner did not return a reply subject.')];
|
|
237
|
+
}
|
|
225
238
|
getChunk = function (chunk) {
|
|
226
239
|
var offset = chunk * fileDescriptor.chunkSize;
|
|
227
240
|
return data.slice(offset, offset + fileDescriptor.chunkSize);
|
|
228
241
|
};
|
|
229
|
-
|
|
242
|
+
dataSubject = requestResponse.reply;
|
|
243
|
+
i = 0;
|
|
244
|
+
_a.label = 2;
|
|
245
|
+
case 2:
|
|
246
|
+
if (!(i < fileDescriptor.numberOfChunks)) return [3 /*break*/, 5];
|
|
247
|
+
return [4 /*yield*/, this.connection.request(dataSubject, getChunk(i), opts)];
|
|
248
|
+
case 3:
|
|
249
|
+
// The runner must acknowledge that it has received each chunk.
|
|
250
|
+
// Likewise, we must wait for the runner to acknowledge each chunk
|
|
251
|
+
// before sending the next one, because the acknowledge from the runner
|
|
252
|
+
// contains the subject where we should send the next chunk.
|
|
253
|
+
requestResponse = _a.sent();
|
|
254
|
+
dataSubject = requestResponse.reply;
|
|
255
|
+
_a.label = 4;
|
|
256
|
+
case 4:
|
|
257
|
+
i++;
|
|
258
|
+
return [3 /*break*/, 2];
|
|
259
|
+
case 5:
|
|
260
|
+
// The response to any chunked request is itself a chunked response.
|
|
261
|
+
// The last acknowledge from the runner indicates the subject where the response can be downloaded from.
|
|
262
|
+
return [2 /*return*/, this.downloadChunkedRequest(requestResponse, rawResponse, opts)];
|
|
263
|
+
}
|
|
264
|
+
});
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Receive a chunked file specified by a request response
|
|
269
|
+
* @param requestResponse Contains a reply subject and a file descriptor which can be used to download chunks
|
|
270
|
+
* @param rawResponse If true, the response should not be decoded
|
|
271
|
+
* @param opts Request options
|
|
272
|
+
* @returns
|
|
273
|
+
*/
|
|
274
|
+
BaseClient.prototype.downloadChunkedRequest = function (requestResponse, rawResponse, opts) {
|
|
275
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
276
|
+
var jsonCodec, responseBody, error, fileDescriptor, dataSubject, result, bytesReceived, i, j, resultCodec;
|
|
277
|
+
return __generator(this, function (_a) {
|
|
278
|
+
switch (_a.label) {
|
|
279
|
+
case 0:
|
|
280
|
+
if (!this.connection)
|
|
281
|
+
return [2 /*return*/, Promise.reject('Chunking: Connection is down! Please try again!')];
|
|
282
|
+
if (this.connection.isClosed())
|
|
283
|
+
return [2 /*return*/, Promise.reject("Chunking: Connection has been closed! Please reconnect!")];
|
|
284
|
+
jsonCodec = JSONCodec();
|
|
285
|
+
responseBody = jsonCodec.decode(requestResponse.data);
|
|
286
|
+
if (this.isErrorResponse(responseBody)) {
|
|
287
|
+
error = ErrorResponse.fromJS(responseBody);
|
|
288
|
+
this.eventEmitter.emit(Events.ERROR, error);
|
|
289
|
+
return [2 /*return*/, Promise.reject(error)];
|
|
290
|
+
}
|
|
291
|
+
fileDescriptor = FileDescriptor.fromJS(responseBody);
|
|
292
|
+
if (!requestResponse.reply || !fileDescriptor || fileDescriptor.numberOfChunks === 0) {
|
|
293
|
+
return [2 /*return*/, Promise.reject('Chunking: Response payload does not indicate a chunked response.')];
|
|
294
|
+
}
|
|
295
|
+
dataSubject = requestResponse.reply;
|
|
296
|
+
result = new Uint8Array(fileDescriptor.fileSize);
|
|
297
|
+
bytesReceived = 0;
|
|
298
|
+
i = 0;
|
|
299
|
+
_a.label = 1;
|
|
230
300
|
case 1:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
301
|
+
if (!(i < fileDescriptor.numberOfChunks)) return [3 /*break*/, 4];
|
|
302
|
+
return [4 /*yield*/, this.connection.request(dataSubject, Empty, opts)];
|
|
303
|
+
case 2:
|
|
304
|
+
// Send a request with an empty payload to acknowledge that we received the previous chunk
|
|
305
|
+
// The response body contains the current chunk.
|
|
306
|
+
// The reply subject of the response indicates where we can get the next chunk
|
|
307
|
+
requestResponse = _a.sent();
|
|
308
|
+
dataSubject = requestResponse.reply;
|
|
309
|
+
for (j = 0; j < requestResponse.data.length; j++) {
|
|
310
|
+
result[bytesReceived++] = requestResponse.data[j];
|
|
234
311
|
}
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
if (error) {
|
|
253
|
-
reject(error);
|
|
254
|
-
}
|
|
255
|
-
combinedResult = new Uint8Array(__spreadArray(__spreadArray([], Array.from(combinedResult), true), Array.from(message === null || message === void 0 ? void 0 : message.data), true));
|
|
256
|
-
if ((message === null || message === void 0 ? void 0 : message.data.length) === 0) {
|
|
257
|
-
resolve(combinedResult);
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
}).then(function (byteArray) {
|
|
261
|
-
var jsonCodec = JSONCodec();
|
|
262
|
-
var response = jsonCodec.decode(byteArray);
|
|
263
|
-
if (_this.isErrorResponse(response)) {
|
|
264
|
-
var error = ErrorResponse.fromJS(response);
|
|
265
|
-
_this.eventEmitter.emit(Events.ERROR, error);
|
|
266
|
-
return Promise.reject(error);
|
|
267
|
-
}
|
|
268
|
-
return Promise.resolve(response);
|
|
269
|
-
})];
|
|
312
|
+
_a.label = 3;
|
|
313
|
+
case 3:
|
|
314
|
+
i++;
|
|
315
|
+
return [3 /*break*/, 1];
|
|
316
|
+
case 4:
|
|
317
|
+
// Send an empty message to acknowledge that the final chunk was received
|
|
318
|
+
this.connection.publish(dataSubject, Empty);
|
|
319
|
+
if (bytesReceived !== fileDescriptor.fileSize) {
|
|
320
|
+
return [2 /*return*/, Promise.reject("Unexpected repsonse size. Got ".concat(bytesReceived, " bytes, but expected ").concat(fileDescriptor.fileSize, "."))];
|
|
321
|
+
}
|
|
322
|
+
// The runner skips the encoding step if the return type is a byte array, so we must also skip the decoding step in this case.
|
|
323
|
+
if (rawResponse)
|
|
324
|
+
return [2 /*return*/, Promise.resolve(result)];
|
|
325
|
+
resultCodec = JSONCodec();
|
|
326
|
+
return [2 /*return*/, resultCodec.decode(result)];
|
|
270
327
|
}
|
|
271
328
|
});
|
|
272
329
|
});
|
|
273
330
|
};
|
|
274
331
|
/**
|
|
275
|
-
*
|
|
276
|
-
* @param subject The subject
|
|
277
|
-
* @param payload
|
|
278
|
-
* @param options
|
|
279
|
-
* @
|
|
332
|
+
* Make a request to the runner whose response will be sent in chunked
|
|
333
|
+
* @param subject The request subject
|
|
334
|
+
* @param payload Optional request body
|
|
335
|
+
* @param options Optional request options
|
|
336
|
+
* @param rawResponse If true, the return value will not be decoded
|
|
337
|
+
* @param fullSubject If true, the base subject will not be prepended
|
|
338
|
+
* @returns
|
|
280
339
|
*/
|
|
281
|
-
BaseClient.prototype.requestChunked = function (subject,
|
|
340
|
+
BaseClient.prototype.requestChunked = function (subject, payload, options, rawResponse, fullSubject) {
|
|
282
341
|
return __awaiter(this, void 0, void 0, function () {
|
|
283
|
-
var
|
|
284
|
-
var _this = this;
|
|
342
|
+
var data, stringCodec, headers, opts, requestResponse;
|
|
285
343
|
return __generator(this, function (_a) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
if (!
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
var resolveIfCompleted = function () {
|
|
298
|
-
if (combinedResult.length === fileSize) {
|
|
299
|
-
subscription.unsubscribe();
|
|
300
|
-
resolve(combinedResult);
|
|
301
|
-
}
|
|
302
|
-
};
|
|
303
|
-
subscription.callback = function (error, message) {
|
|
304
|
-
if (error) {
|
|
305
|
-
reject(error);
|
|
306
|
-
}
|
|
307
|
-
combinedResult = new Uint8Array(__spreadArray(__spreadArray([], Array.from(combinedResult), true), Array.from(message === null || message === void 0 ? void 0 : message.data), true));
|
|
308
|
-
resolveIfCompleted();
|
|
309
|
-
};
|
|
310
|
-
var headers = _this.buildHeaders();
|
|
311
|
-
var opts = __assign(__assign({}, options), { timeout: _this.timeout, headers: headers });
|
|
312
|
-
// Request the file descriptor from the runner by posting the reply subject
|
|
313
|
-
return _this.request(subject, payload, opts, isFullSubject)
|
|
314
|
-
.then(function (fileDescriptor) { return FileDescriptor.fromJS(fileDescriptor); })
|
|
315
|
-
.then(function (fileDescriptor) {
|
|
316
|
-
fileSize = fileDescriptor.fileSize;
|
|
317
|
-
resolveIfCompleted();
|
|
318
|
-
})
|
|
319
|
-
.catch(function (error) {
|
|
320
|
-
subscription.unsubscribe();
|
|
321
|
-
throw error;
|
|
322
|
-
});
|
|
323
|
-
}).then(function (byteArray) {
|
|
324
|
-
if (byteArray.length !== fileSize)
|
|
325
|
-
return Promise.reject("Unexpected response size. Expected ".concat(fileSize, " bytes, but got ").concat(byteArray.length, "."));
|
|
326
|
-
// Avoid decoding the response if the expected response is bytearray
|
|
327
|
-
if (rawResponse)
|
|
328
|
-
return Promise.resolve(byteArray);
|
|
329
|
-
var jsonCodec = JSONCodec();
|
|
330
|
-
var response = jsonCodec.decode(byteArray);
|
|
331
|
-
if (_this.isErrorResponse(response)) {
|
|
332
|
-
var error = ErrorResponse.fromJS(response);
|
|
333
|
-
_this.eventEmitter.emit(Events.ERROR, error);
|
|
334
|
-
return Promise.reject(error);
|
|
344
|
+
switch (_a.label) {
|
|
345
|
+
case 0:
|
|
346
|
+
if (!this.connection)
|
|
347
|
+
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection is down! Please try again!"))];
|
|
348
|
+
if (this.connection.isClosed())
|
|
349
|
+
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection has been closed! Please reconnect!"))];
|
|
350
|
+
if (!fullSubject) {
|
|
351
|
+
subject = "".concat(this.baseSubject, ".Request.").concat(subject);
|
|
352
|
+
}
|
|
353
|
+
if (payload instanceof Uint8Array) {
|
|
354
|
+
data = payload;
|
|
335
355
|
}
|
|
336
|
-
|
|
337
|
-
|
|
356
|
+
else {
|
|
357
|
+
stringCodec = StringCodec();
|
|
358
|
+
data = payload ? stringCodec.encode(JSON.stringify(payload)) : Empty;
|
|
359
|
+
}
|
|
360
|
+
headers = this.buildHeaders();
|
|
361
|
+
opts = __assign(__assign({}, options), { timeout: this.timeout, headers: headers });
|
|
362
|
+
return [4 /*yield*/, this.connection.request(subject, data, opts)];
|
|
363
|
+
case 1:
|
|
364
|
+
requestResponse = _a.sent();
|
|
365
|
+
return [2 /*return*/, this.downloadChunkedRequest(requestResponse, rawResponse, opts)];
|
|
366
|
+
}
|
|
338
367
|
});
|
|
339
368
|
});
|
|
340
369
|
};
|
package/lib/DTOs.d.ts
CHANGED
|
@@ -442,14 +442,6 @@ export declare class Resource implements IResource {
|
|
|
442
442
|
export interface IResource {
|
|
443
443
|
source?: string | undefined;
|
|
444
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
445
|
export declare class FileDescriptor implements IFileDescriptor {
|
|
454
446
|
numberOfChunks: number;
|
|
455
447
|
fileSize: number;
|
package/lib/DTOs.js
CHANGED
|
@@ -1303,12 +1303,6 @@ var Resource = /** @class */ (function () {
|
|
|
1303
1303
|
return Resource;
|
|
1304
1304
|
}());
|
|
1305
1305
|
export { Resource };
|
|
1306
|
-
var TestPlanRequest = /** @class */ (function () {
|
|
1307
|
-
function TestPlanRequest() {
|
|
1308
|
-
}
|
|
1309
|
-
return TestPlanRequest;
|
|
1310
|
-
}());
|
|
1311
|
-
export { TestPlanRequest };
|
|
1312
1306
|
var FileDescriptor = /** @class */ (function () {
|
|
1313
1307
|
function FileDescriptor(fileSize, chunkSize) {
|
|
1314
1308
|
var _a;
|
package/lib/SessionClient.js
CHANGED
|
@@ -27,7 +27,6 @@ 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';
|
|
31
30
|
var SessionClient = /** @class */ (function (_super) {
|
|
32
31
|
__extends(SessionClient, _super);
|
|
33
32
|
function SessionClient(baseSubject, options) {
|
|
@@ -206,8 +205,7 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
206
205
|
*/
|
|
207
206
|
SessionClient.prototype.getTestPlanXML = function () {
|
|
208
207
|
// Generate a unique subject where the Runner will publish the chunks
|
|
209
|
-
|
|
210
|
-
return this.requestChunked('GetTestPlanXML', replySubject, replySubject).then(this.success()).catch(this.error());
|
|
208
|
+
return this.requestChunked('GetTestPlanXML').then(this.success()).catch(this.error());
|
|
211
209
|
};
|
|
212
210
|
/**
|
|
213
211
|
* Downloads the resource from the runner and returns it as raw bytes
|
|
@@ -219,11 +217,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
219
217
|
if (!((_a = resource.source) === null || _a === void 0 ? void 0 : _a.startsWith(runnerResourcePrefix))) {
|
|
220
218
|
return Promise.reject('The source of the provided resource is not a nats subject.');
|
|
221
219
|
}
|
|
222
|
-
var replySubject = "_INBOX.".concat(uuidv4());
|
|
223
220
|
var subject = resource.source.slice(runnerResourcePrefix.length);
|
|
224
|
-
return this.requestChunked(subject,
|
|
225
|
-
.then(this.success())
|
|
226
|
-
.catch(this.error());
|
|
221
|
+
return this.requestChunked(subject, undefined, undefined, true, true).then(this.success()).catch(this.error());
|
|
227
222
|
};
|
|
228
223
|
/**
|
|
229
224
|
* Load test plan using a test plan TapPackage from a repository
|
|
@@ -246,8 +241,7 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
246
241
|
* @return Test plan resources opened.
|
|
247
242
|
*/
|
|
248
243
|
SessionClient.prototype.resourcesOpen = function () {
|
|
249
|
-
|
|
250
|
-
return this.requestChunked('ResourcesOpen', replySubject, replySubject)
|
|
244
|
+
return this.requestChunked('ResourcesOpen')
|
|
251
245
|
.then(function (testPlanJs) { return TestPlan.fromJS(testPlanJs); })
|
|
252
246
|
.then(this.success())
|
|
253
247
|
.catch(this.error());
|
|
@@ -257,8 +251,7 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
257
251
|
* @return Test plan resources closed.
|
|
258
252
|
*/
|
|
259
253
|
SessionClient.prototype.resourcesClose = function () {
|
|
260
|
-
|
|
261
|
-
return this.requestChunked('ResourcesClose', replySubject, replySubject)
|
|
254
|
+
return this.requestChunked('ResourcesClose')
|
|
262
255
|
.then(function (testPlanJs) { return TestPlan.fromJS(testPlanJs); })
|
|
263
256
|
.then(this.success())
|
|
264
257
|
.catch(this.error());
|
|
@@ -293,12 +286,7 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
293
286
|
* @return Test plan retrieved
|
|
294
287
|
*/
|
|
295
288
|
SessionClient.prototype.getTestPlan = function (properties) {
|
|
296
|
-
|
|
297
|
-
var payload = {
|
|
298
|
-
subject: replySubject,
|
|
299
|
-
properties: properties,
|
|
300
|
-
};
|
|
301
|
-
return this.requestChunked('GetTestPlan', replySubject, payload)
|
|
289
|
+
return this.requestChunked('GetTestPlan', properties)
|
|
302
290
|
.then(function (testPlanJs) { return TestPlan.fromJS(testPlanJs); })
|
|
303
291
|
.then(this.success())
|
|
304
292
|
.catch(this.error());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentap/runner-client",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.4-alpha.1.2",
|
|
4
4
|
"description": "This is the web client for the OpenTAP Runner.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -41,11 +41,12 @@
|
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"nats.ws": "^1.9.0",
|
|
44
|
-
"uuid": "^9.0.0"
|
|
44
|
+
"uuid": "^9.0.0",
|
|
45
|
+
"events": "^3.3.0"
|
|
45
46
|
},
|
|
46
47
|
"lint-staged": {
|
|
47
48
|
"*.{ts,js,html}": [
|
|
48
49
|
"npm run lint --fix"
|
|
49
50
|
]
|
|
50
51
|
}
|
|
51
|
-
}
|
|
52
|
+
}
|