@opentap/runner-client 2.3.0-alpha.1.1 → 2.3.0-alpha.2.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/lib/BaseClient.d.ts +11 -19
- package/lib/BaseClient.js +82 -148
- package/lib/DTOs.d.ts +1 -10
- package/lib/DTOs.js +2 -9
- package/lib/SessionClient.js +7 -19
- package/package.json +4 -3
package/lib/BaseClient.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsListItem, DataGridControl, ErrorResponse, FileParameter, FileResponse, ListItemType, ProfileGroup, RepositoryPackageReference, RepositorySettingsPackageDefinition, SettingsTapPackage } from './DTOs';
|
|
2
|
-
import { ConnectionOptions,
|
|
2
|
+
import { ConnectionOptions, RequestOptions, Subscription, SubscriptionOptions } from 'nats.ws';
|
|
3
3
|
export declare class BaseClient {
|
|
4
4
|
private connection;
|
|
5
5
|
private baseSubject;
|
|
@@ -9,6 +9,7 @@ export declare class BaseClient {
|
|
|
9
9
|
private _accessToken;
|
|
10
10
|
private _headers;
|
|
11
11
|
private _timeout;
|
|
12
|
+
private _chunkSize;
|
|
12
13
|
/** Get request access token */
|
|
13
14
|
get accessToken(): string;
|
|
14
15
|
/** Set request access token */
|
|
@@ -27,11 +28,9 @@ export declare class BaseClient {
|
|
|
27
28
|
* @param subject The subject to request
|
|
28
29
|
* @param payload (optional)
|
|
29
30
|
* @param options (optional)
|
|
30
|
-
* @param isFullSubject (optional) If true, use the subject as request subject
|
|
31
|
-
* without appending it to the baseSubject
|
|
32
31
|
* @returns Promise of an object
|
|
33
32
|
*/
|
|
34
|
-
protected request<T>(subject: string, payload?: any, options?: RequestOptions,
|
|
33
|
+
protected request<T>(subject: string, payload?: any, options?: RequestOptions, rawResponse?: boolean, fullSubject?: boolean): Promise<T>;
|
|
35
34
|
/**
|
|
36
35
|
* Handle the error
|
|
37
36
|
* @param error
|
|
@@ -52,21 +51,14 @@ export declare class BaseClient {
|
|
|
52
51
|
*/
|
|
53
52
|
protected subscribe(subject: string, options: SubscriptionOptions): Subscription;
|
|
54
53
|
/**
|
|
55
|
-
*
|
|
56
|
-
* @param
|
|
57
|
-
* @param
|
|
58
|
-
* @param options
|
|
59
|
-
* @returns
|
|
60
|
-
*/
|
|
61
|
-
protected sendChunked<T>(subject: string, payload?: any, options?: RequestOptions): Promise<T>;
|
|
62
|
-
/**
|
|
63
|
-
* Request an object to the nats server with chunks.
|
|
64
|
-
* @param subject The subject to request
|
|
65
|
-
* @param payload (optional)
|
|
66
|
-
* @param options (optional)
|
|
67
|
-
* @returns Promise of an object
|
|
54
|
+
* Receive a chunked file specified by a request response
|
|
55
|
+
* @param requestResponse Contains a reply subject and a file descriptor which can be used to download chunks
|
|
56
|
+
* @param rawResponse If true, the response should not be decoded
|
|
57
|
+
* @param opts Request options
|
|
58
|
+
* @returns
|
|
68
59
|
*/
|
|
69
|
-
|
|
60
|
+
private downloadChunkedRequest;
|
|
61
|
+
protected encode(payload: any): Uint8Array;
|
|
70
62
|
/**
|
|
71
63
|
* Check if the the response is an error from the server.
|
|
72
64
|
* @param {any} response
|
|
@@ -77,7 +69,7 @@ export declare class BaseClient {
|
|
|
77
69
|
* Create a connection to the nats server.
|
|
78
70
|
* @param {ConnectionOptions} options
|
|
79
71
|
*/
|
|
80
|
-
connect(): Promise<
|
|
72
|
+
connect(): Promise<void>;
|
|
81
73
|
/**
|
|
82
74
|
* Close the connection.
|
|
83
75
|
*/
|
package/lib/BaseClient.js
CHANGED
|
@@ -66,6 +66,7 @@ var BaseClient = /** @class */ (function () {
|
|
|
66
66
|
function BaseClient(baseSubject, options) {
|
|
67
67
|
this.domainAccess = new Map();
|
|
68
68
|
this._headers = new Headers();
|
|
69
|
+
this._chunkSize = 512000;
|
|
69
70
|
this.baseSubject = baseSubject;
|
|
70
71
|
this.connectionOptions = __assign({}, options) || {};
|
|
71
72
|
this.connectionOptions.timeout = (options === null || options === void 0 ? void 0 : options.timeout) || DEFAULT_TIMEOUT;
|
|
@@ -112,39 +113,60 @@ var BaseClient = /** @class */ (function () {
|
|
|
112
113
|
* @param subject The subject to request
|
|
113
114
|
* @param payload (optional)
|
|
114
115
|
* @param options (optional)
|
|
115
|
-
* @param isFullSubject (optional) If true, use the subject as request subject
|
|
116
|
-
* without appending it to the baseSubject
|
|
117
116
|
* @returns Promise of an object
|
|
118
117
|
*/
|
|
119
|
-
BaseClient.prototype.request = function (subject, payload, options,
|
|
118
|
+
BaseClient.prototype.request = function (subject, payload, options, rawResponse, fullSubject) {
|
|
120
119
|
return __awaiter(this, void 0, void 0, function () {
|
|
121
|
-
var
|
|
122
|
-
var _this = this;
|
|
120
|
+
var data, headers, timeout, opts, fileDescriptor, getChunk, requestResponse, dataSubject, i, result, error;
|
|
123
121
|
return __generator(this, function (_a) {
|
|
124
122
|
switch (_a.label) {
|
|
125
123
|
case 0:
|
|
126
|
-
subject
|
|
124
|
+
// Prepend the base subject if the given subject does not start with that
|
|
125
|
+
if (!fullSubject) {
|
|
126
|
+
subject = "".concat(this.baseSubject, ".Request.").concat(subject);
|
|
127
|
+
}
|
|
127
128
|
if (!this.connection)
|
|
128
129
|
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection is down! Please try again!"))];
|
|
129
130
|
if (this.connection.isClosed())
|
|
130
131
|
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection has been closed! Please reconnect!"))];
|
|
131
|
-
|
|
132
|
-
data = payload ? stringCodec.encode(JSON.stringify(payload)) : Empty;
|
|
132
|
+
data = this.encode(payload);
|
|
133
133
|
headers = this.buildHeaders();
|
|
134
|
+
headers.append('ChunkSize', this._chunkSize.toString());
|
|
134
135
|
timeout = (options === null || options === void 0 ? void 0 : options.timeout) || this.timeout;
|
|
135
136
|
opts = __assign(__assign({}, options), { timeout: timeout, headers: headers });
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
case
|
|
137
|
+
fileDescriptor = new FileDescriptor(data.length, this._chunkSize);
|
|
138
|
+
getChunk = function (chunk) {
|
|
139
|
+
var offset = chunk * fileDescriptor.chunkSize;
|
|
140
|
+
return data.slice(offset, offset + fileDescriptor.chunkSize);
|
|
141
|
+
};
|
|
142
|
+
dataSubject = subject;
|
|
143
|
+
i = 0;
|
|
144
|
+
_a.label = 1;
|
|
145
|
+
case 1:
|
|
146
|
+
if (!(i < fileDescriptor.numberOfChunks)) return [3 /*break*/, 4];
|
|
147
|
+
return [4 /*yield*/, this.connection.request(dataSubject, getChunk(i), opts)];
|
|
148
|
+
case 2:
|
|
149
|
+
requestResponse = _a.sent();
|
|
150
|
+
dataSubject = requestResponse.reply;
|
|
151
|
+
_a.label = 3;
|
|
152
|
+
case 3:
|
|
153
|
+
i++;
|
|
154
|
+
return [3 /*break*/, 1];
|
|
155
|
+
case 4:
|
|
156
|
+
if (!(fileDescriptor.fileSize % fileDescriptor.chunkSize === 0)) return [3 /*break*/, 6];
|
|
157
|
+
return [4 /*yield*/, this.connection.request(dataSubject, Empty, opts)];
|
|
158
|
+
case 5:
|
|
159
|
+
requestResponse = _a.sent();
|
|
160
|
+
_a.label = 6;
|
|
161
|
+
case 6: return [4 /*yield*/, this.downloadChunkedRequest(requestResponse, rawResponse, opts)];
|
|
162
|
+
case 7:
|
|
163
|
+
result = _a.sent();
|
|
164
|
+
if (this.isErrorResponse(result)) {
|
|
165
|
+
error = ErrorResponse.fromJS(result);
|
|
166
|
+
this.eventEmitter.emit(Events.ERROR, error);
|
|
167
|
+
return [2 /*return*/, Promise.reject(error)];
|
|
168
|
+
}
|
|
169
|
+
return [2 /*return*/, result];
|
|
148
170
|
}
|
|
149
171
|
});
|
|
150
172
|
});
|
|
@@ -198,145 +220,57 @@ var BaseClient = /** @class */ (function () {
|
|
|
198
220
|
return this.connection.subscribe(natsSubject, options);
|
|
199
221
|
};
|
|
200
222
|
/**
|
|
201
|
-
*
|
|
202
|
-
* @param
|
|
203
|
-
* @param
|
|
204
|
-
* @param options
|
|
205
|
-
* @returns
|
|
223
|
+
* Receive a chunked file specified by a request response
|
|
224
|
+
* @param requestResponse Contains a reply subject and a file descriptor which can be used to download chunks
|
|
225
|
+
* @param rawResponse If true, the response should not be decoded
|
|
226
|
+
* @param opts Request options
|
|
227
|
+
* @returns
|
|
206
228
|
*/
|
|
207
|
-
BaseClient.prototype.
|
|
229
|
+
BaseClient.prototype.downloadChunkedRequest = function (requestResponse, rawResponse, opts) {
|
|
208
230
|
return __awaiter(this, void 0, void 0, function () {
|
|
209
|
-
var
|
|
210
|
-
var _this = this;
|
|
231
|
+
var result, resultCodec;
|
|
211
232
|
return __generator(this, function (_a) {
|
|
212
233
|
switch (_a.label) {
|
|
213
234
|
case 0:
|
|
214
235
|
if (!this.connection)
|
|
215
|
-
return [2 /*return*/, Promise.reject(
|
|
236
|
+
return [2 /*return*/, Promise.reject('Chunking: Connection is down! Please try again!')];
|
|
216
237
|
if (this.connection.isClosed())
|
|
217
|
-
return [2 /*return*/, Promise.reject("
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
headers = this.buildHeaders();
|
|
221
|
-
opts = __assign(__assign({}, options), { timeout: this.timeout, headers: headers });
|
|
222
|
-
fileDescriptor = new FileDescriptor(data.length);
|
|
223
|
-
if (!fileDescriptor.numberOfChunks)
|
|
224
|
-
return [2 /*return*/, Promise.reject("".concat(subject, ": File is empty!"))];
|
|
225
|
-
getChunk = function (chunk) {
|
|
226
|
-
var offset = chunk * fileDescriptor.chunkSize;
|
|
227
|
-
return data.slice(offset, offset + fileDescriptor.chunkSize);
|
|
228
|
-
};
|
|
229
|
-
return [4 /*yield*/, this.request(subject, fileDescriptor, opts)];
|
|
238
|
+
return [2 /*return*/, Promise.reject("Chunking: Connection has been closed! Please reconnect!")];
|
|
239
|
+
result = new Uint8Array([]);
|
|
240
|
+
_a.label = 1;
|
|
230
241
|
case 1:
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
242
|
+
result = new Uint8Array(__spreadArray(__spreadArray([], Array.from(result), true), Array.from(requestResponse.data), true));
|
|
243
|
+
// Acknowledge that the final chunk was received
|
|
244
|
+
if (requestResponse.data.length < this._chunkSize) {
|
|
245
|
+
this.connection.publish(requestResponse.reply, Empty, opts);
|
|
246
|
+
return [3 /*break*/, 4];
|
|
247
|
+
}
|
|
248
|
+
return [4 /*yield*/, this.connection.request(requestResponse.reply, Empty, opts)];
|
|
249
|
+
case 2:
|
|
250
|
+
requestResponse = _a.sent();
|
|
251
|
+
_a.label = 3;
|
|
252
|
+
case 3: return [3 /*break*/, 1];
|
|
253
|
+
case 4:
|
|
254
|
+
if (result.length !== 0) {
|
|
255
|
+
// 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.
|
|
256
|
+
if (rawResponse)
|
|
257
|
+
return [2 /*return*/, Promise.resolve(result)];
|
|
258
|
+
resultCodec = JSONCodec();
|
|
259
|
+
return [2 /*return*/, resultCodec.decode(result)];
|
|
234
260
|
}
|
|
235
|
-
return [2 /*return
|
|
236
|
-
if (!_this.connection) {
|
|
237
|
-
return Promise.reject('No nats connection.');
|
|
238
|
-
}
|
|
239
|
-
var combinedResult = new Uint8Array([]);
|
|
240
|
-
// Subscribe to dataSubject before sending the terminating message to ensure we are listening before the server starts responding
|
|
241
|
-
var subscription = _this.connection.subscribe(dataSubject);
|
|
242
|
-
// Publish an empty message to indicate that we are ready to listen
|
|
243
|
-
_this.connection.publish(dataSubject, Empty, opts);
|
|
244
|
-
var first = true;
|
|
245
|
-
subscription.callback = function (error, message) {
|
|
246
|
-
// The first message is the empty message we published above.
|
|
247
|
-
// We should discard this message before we proceed
|
|
248
|
-
if (first === true) {
|
|
249
|
-
first = false;
|
|
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
|
-
})];
|
|
261
|
+
return [2 /*return*/];
|
|
270
262
|
}
|
|
271
263
|
});
|
|
272
264
|
});
|
|
273
265
|
};
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
283
|
-
var fileSize;
|
|
284
|
-
var _this = this;
|
|
285
|
-
return __generator(this, function (_a) {
|
|
286
|
-
if (!this.connection)
|
|
287
|
-
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection is down! Please try again!"))];
|
|
288
|
-
if (this.connection.isClosed())
|
|
289
|
-
return [2 /*return*/, Promise.reject("".concat(subject, ": Connection has been closed! Please reconnect!"))];
|
|
290
|
-
fileSize = -1;
|
|
291
|
-
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
292
|
-
if (!_this.connection)
|
|
293
|
-
return Promise.reject("".concat(subject, ": Connection is down! Please try again!"));
|
|
294
|
-
var combinedResult = new Uint8Array([]);
|
|
295
|
-
// Subscribe to the subject before starting the process
|
|
296
|
-
var subscription = _this.connection.subscribe(replySubject);
|
|
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);
|
|
335
|
-
}
|
|
336
|
-
return Promise.resolve(response);
|
|
337
|
-
})];
|
|
338
|
-
});
|
|
339
|
-
});
|
|
266
|
+
BaseClient.prototype.encode = function (payload) {
|
|
267
|
+
if (!payload) {
|
|
268
|
+
return Empty;
|
|
269
|
+
}
|
|
270
|
+
if (payload instanceof Uint8Array) {
|
|
271
|
+
return payload;
|
|
272
|
+
}
|
|
273
|
+
return StringCodec().encode(JSON.stringify(payload));
|
|
340
274
|
};
|
|
341
275
|
/**
|
|
342
276
|
* Check if the the response is an error from the server.
|
|
@@ -360,14 +294,14 @@ var BaseClient = /** @class */ (function () {
|
|
|
360
294
|
if (!this.baseSubject)
|
|
361
295
|
return [2 /*return*/, Promise.reject('Subject must be given')];
|
|
362
296
|
if (this.connection)
|
|
363
|
-
return [2 /*return*/, Promise.resolve(
|
|
297
|
+
return [2 /*return*/, Promise.resolve()];
|
|
364
298
|
_a.label = 1;
|
|
365
299
|
case 1:
|
|
366
300
|
_a.trys.push([1, 3, , 4]);
|
|
367
301
|
return [4 /*yield*/, connect(this.connectionOptions)
|
|
368
302
|
.then(function (connection) {
|
|
369
303
|
_this.connection = connection;
|
|
370
|
-
return
|
|
304
|
+
return Promise.resolve();
|
|
371
305
|
})
|
|
372
306
|
.catch(function (error) { return Promise.reject("Failed to connect to ".concat(_this.connectionOptions.servers, " with ").concat(error)); })];
|
|
373
307
|
case 2: return [2 /*return*/, _a.sent()];
|
package/lib/DTOs.d.ts
CHANGED
|
@@ -442,20 +442,11 @@ 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;
|
|
456
448
|
chunkSize: number;
|
|
457
|
-
|
|
458
|
-
constructor(fileSize: number, chunkSize?: number);
|
|
449
|
+
constructor(fileSize: number, chunkSize: number);
|
|
459
450
|
init(_data?: any): void;
|
|
460
451
|
static fromJS(data: any): FileDescriptor;
|
|
461
452
|
toJSON(data?: any): any;
|
package/lib/DTOs.js
CHANGED
|
@@ -1303,21 +1303,14 @@ 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;
|
|
1315
|
-
this.defaultChunkSize = 512000;
|
|
1316
1309
|
if (chunkSize === 0) {
|
|
1317
1310
|
throw Error('chunkSize cannot set to 0');
|
|
1318
1311
|
}
|
|
1319
1312
|
this.fileSize = fileSize;
|
|
1320
|
-
this.chunkSize = chunkSize
|
|
1313
|
+
this.chunkSize = chunkSize;
|
|
1321
1314
|
this.numberOfChunks = Math.floor((((_a = this.fileSize) !== null && _a !== void 0 ? _a : 0) + this.chunkSize - 1) / this.chunkSize);
|
|
1322
1315
|
}
|
|
1323
1316
|
FileDescriptor.prototype.init = function (_data) {
|
|
@@ -1329,7 +1322,7 @@ var FileDescriptor = /** @class */ (function () {
|
|
|
1329
1322
|
};
|
|
1330
1323
|
FileDescriptor.fromJS = function (data) {
|
|
1331
1324
|
data = typeof data === 'object' ? data : {};
|
|
1332
|
-
var result = new FileDescriptor(0);
|
|
1325
|
+
var result = new FileDescriptor(0, 512000);
|
|
1333
1326
|
result.init(data);
|
|
1334
1327
|
return result;
|
|
1335
1328
|
};
|
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) {
|
|
@@ -198,7 +197,7 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
198
197
|
* @return Test plan loaded. List of load errors is returned.
|
|
199
198
|
*/
|
|
200
199
|
SessionClient.prototype.setTestPlanXML = function (xml) {
|
|
201
|
-
return this.
|
|
200
|
+
return this.request('SetTestPlanXML', xml).then(this.success()).catch(this.error());
|
|
202
201
|
};
|
|
203
202
|
/**
|
|
204
203
|
* Retrieve loaded test plan XML
|
|
@@ -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.request('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.
|
|
225
|
-
.then(this.success())
|
|
226
|
-
.catch(this.error());
|
|
221
|
+
return this.request(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.request('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.request('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.request('GetTestPlan', properties)
|
|
302
290
|
.then(function (testPlanJs) { return TestPlan.fromJS(testPlanJs); })
|
|
303
291
|
.then(this.success())
|
|
304
292
|
.catch(this.error());
|
|
@@ -309,7 +297,7 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
309
297
|
* @return Test plan changed
|
|
310
298
|
*/
|
|
311
299
|
SessionClient.prototype.setTestPlan = function (plan) {
|
|
312
|
-
return this.
|
|
300
|
+
return this.request('SetTestPlan', plan)
|
|
313
301
|
.then(function (testPlanJs) { return TestPlan.fromJS(testPlanJs); })
|
|
314
302
|
.then(this.success())
|
|
315
303
|
.catch(this.error());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentap/runner-client",
|
|
3
|
-
"version": "2.3.0-alpha.
|
|
3
|
+
"version": "2.3.0-alpha.2.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",
|
|
@@ -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
|
+
}
|