@opentap/runner-client 1.2.3 → 2.0.0-alpha.2.10
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 +3 -0
- package/lib/BaseClient.d.ts +17 -1
- package/lib/BaseClient.js +113 -2
- package/lib/DTOs.d.ts +43 -0
- package/lib/DTOs.js +98 -0
- package/lib/RunnerClient.d.ts +0 -3
- package/lib/RunnerClient.js +1 -3
- package/lib/SessionClient.d.ts +8 -4
- package/lib/SessionClient.js +23 -12
- package/lib/index.d.ts +1 -3
- package/lib/index.js +1 -3
- package/package.json +5 -3
package/README.md
CHANGED
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, RequestOptions, Subscription, SubscriptionOptions } from 'nats.ws
|
|
2
|
+
import { ConnectionOptions, RequestOptions, Subscription, SubscriptionOptions } from 'nats.ws';
|
|
3
3
|
export declare class BaseClient {
|
|
4
4
|
private connection;
|
|
5
5
|
private baseSubject;
|
|
@@ -48,6 +48,22 @@ 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>;
|
|
51
67
|
/**
|
|
52
68
|
* Check if the the response is an error from the server.
|
|
53
69
|
* @param {any} response
|
package/lib/BaseClient.js
CHANGED
|
@@ -45,8 +45,18 @@ 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
|
-
|
|
49
|
-
|
|
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';
|
|
58
|
+
import { Empty, ErrorCode, JSONCodec, StringCodec, connect, headers, } from 'nats.ws';
|
|
59
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
50
60
|
var DEFAULT_TIMEOUT = 6000;
|
|
51
61
|
var BaseClient = /** @class */ (function () {
|
|
52
62
|
function BaseClient(baseSubject, options) {
|
|
@@ -178,6 +188,107 @@ var BaseClient = /** @class */ (function () {
|
|
|
178
188
|
var natsSubject = "".concat(this.baseSubject, ".").concat(subject);
|
|
179
189
|
return this.connection.subscribe(natsSubject, options);
|
|
180
190
|
};
|
|
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, 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
|
+
headers = this.buildHeaders();
|
|
263
|
+
opts = __assign(__assign({}, options), { timeout: this.timeout, headers: headers });
|
|
264
|
+
return [4 /*yield*/, this.request(subject, replySubject, opts)];
|
|
265
|
+
case 1:
|
|
266
|
+
fileDescriptor = _a.sent();
|
|
267
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
268
|
+
return [2 /*return*/, new Promise(function (resolve, reject) {
|
|
269
|
+
var combinedResult = new Uint8Array([]);
|
|
270
|
+
var received = 0;
|
|
271
|
+
var subscription = _this.connection.subscribe(replySubject);
|
|
272
|
+
subscription.callback = function (error, message) {
|
|
273
|
+
if (error) {
|
|
274
|
+
reject(error);
|
|
275
|
+
}
|
|
276
|
+
combinedResult = new Uint8Array(__spreadArray(__spreadArray([], Array.from(combinedResult), true), Array.from(message === null || message === void 0 ? void 0 : message.data), true));
|
|
277
|
+
received++;
|
|
278
|
+
message.respond(Empty);
|
|
279
|
+
if (received === fileDescriptor.numberOfChunks) {
|
|
280
|
+
resolve(combinedResult);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
}).then(function (byteArray) {
|
|
284
|
+
var jsonCodec = JSONCodec();
|
|
285
|
+
var response = jsonCodec.decode(byteArray);
|
|
286
|
+
return _this.isErrorResponse(response) ? Promise.reject(ErrorResponse.fromJS(response)) : Promise.resolve(response);
|
|
287
|
+
})];
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
};
|
|
181
292
|
/**
|
|
182
293
|
* Check if the the response is an error from the server.
|
|
183
294
|
* @param {any} response
|
package/lib/DTOs.d.ts
CHANGED
|
@@ -151,6 +151,7 @@ export declare class Setting extends AnnotatedObject implements ISetting {
|
|
|
151
151
|
valueDescription?: string | undefined;
|
|
152
152
|
propertyName?: string | undefined;
|
|
153
153
|
icons?: Icon[] | undefined;
|
|
154
|
+
submit?: boolean | undefined;
|
|
154
155
|
protected _discriminator: string;
|
|
155
156
|
constructor(data?: ISetting);
|
|
156
157
|
init(_data?: any): void;
|
|
@@ -164,6 +165,7 @@ export interface ISetting extends IAnnotatedObject {
|
|
|
164
165
|
valueDescription?: string | undefined;
|
|
165
166
|
propertyName?: string | undefined;
|
|
166
167
|
icons?: Icon[] | undefined;
|
|
168
|
+
submit?: boolean | undefined;
|
|
167
169
|
}
|
|
168
170
|
export declare class Layout implements ILayout {
|
|
169
171
|
mode?: LayoutMode;
|
|
@@ -416,6 +418,45 @@ export declare class PasswordControl extends Setting implements IPasswordControl
|
|
|
416
418
|
export interface IPasswordControl extends ISetting {
|
|
417
419
|
password?: string | undefined;
|
|
418
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
|
+
}
|
|
419
460
|
export declare class ComponentSettings extends ComponentSettingsBase implements IComponentSettings {
|
|
420
461
|
settings?: Setting[] | undefined;
|
|
421
462
|
constructor(data?: IComponentSettings);
|
|
@@ -831,6 +872,7 @@ export interface ICommonContext {
|
|
|
831
872
|
export declare class Interaction implements IInteraction {
|
|
832
873
|
timeout?: string | undefined;
|
|
833
874
|
title?: string | undefined;
|
|
875
|
+
modal?: boolean | undefined;
|
|
834
876
|
settings?: Setting[] | undefined;
|
|
835
877
|
id?: string;
|
|
836
878
|
constructor(data?: IInteraction);
|
|
@@ -841,6 +883,7 @@ export declare class Interaction implements IInteraction {
|
|
|
841
883
|
export interface IInteraction {
|
|
842
884
|
timeout?: string | undefined;
|
|
843
885
|
title?: string | undefined;
|
|
886
|
+
modal?: boolean | undefined;
|
|
844
887
|
settings?: Setting[] | undefined;
|
|
845
888
|
id?: string;
|
|
846
889
|
}
|
package/lib/DTOs.js
CHANGED
|
@@ -434,6 +434,7 @@ var Setting = /** @class */ (function (_super) {
|
|
|
434
434
|
this.columnDisplayName = _data['ColumnDisplayName'] ? ColumnDisplayName.fromJS(_data['ColumnDisplayName']) : undefined;
|
|
435
435
|
this.valueDescription = _data['ValueDescription'];
|
|
436
436
|
this.propertyName = _data['PropertyName'];
|
|
437
|
+
this.submit = _data['Submit'];
|
|
437
438
|
if (Array.isArray(_data['Icons'])) {
|
|
438
439
|
this.icons = [];
|
|
439
440
|
for (var _b = 0, _c = _data['Icons']; _b < _c.length; _b++) {
|
|
@@ -523,6 +524,7 @@ var Setting = /** @class */ (function (_super) {
|
|
|
523
524
|
data['ColumnDisplayName'] = this.columnDisplayName ? this.columnDisplayName.toJSON() : undefined;
|
|
524
525
|
data['ValueDescription'] = this.valueDescription;
|
|
525
526
|
data['PropertyName'] = this.propertyName;
|
|
527
|
+
data['Submit'] = this.submit;
|
|
526
528
|
if (Array.isArray(this.icons)) {
|
|
527
529
|
data['Icons'] = [];
|
|
528
530
|
for (var _b = 0, _c = this.icons; _b < _c.length; _b++) {
|
|
@@ -1236,6 +1238,100 @@ var PasswordControl = /** @class */ (function (_super) {
|
|
|
1236
1238
|
return PasswordControl;
|
|
1237
1239
|
}(Setting));
|
|
1238
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 };
|
|
1239
1335
|
var ComponentSettings = /** @class */ (function (_super) {
|
|
1240
1336
|
__extends(ComponentSettings, _super);
|
|
1241
1337
|
function ComponentSettings(data) {
|
|
@@ -2455,6 +2551,7 @@ var Interaction = /** @class */ (function () {
|
|
|
2455
2551
|
if (_data) {
|
|
2456
2552
|
this.timeout = _data['Timeout'];
|
|
2457
2553
|
this.title = _data['Title'];
|
|
2554
|
+
this.modal = _data['Modal'];
|
|
2458
2555
|
if (Array.isArray(_data['Settings'])) {
|
|
2459
2556
|
this.settings = [];
|
|
2460
2557
|
for (var _i = 0, _a = _data['Settings']; _i < _a.length; _i++) {
|
|
@@ -2475,6 +2572,7 @@ var Interaction = /** @class */ (function () {
|
|
|
2475
2572
|
data = typeof data === 'object' ? data : {};
|
|
2476
2573
|
data['Timeout'] = this.timeout;
|
|
2477
2574
|
data['Title'] = this.title;
|
|
2575
|
+
data['Modal'] = this.modal;
|
|
2478
2576
|
if (Array.isArray(this.settings)) {
|
|
2479
2577
|
data['Settings'] = [];
|
|
2480
2578
|
for (var _i = 0, _a = this.settings; _i < _a.length; _i++) {
|
package/lib/RunnerClient.d.ts
CHANGED
|
@@ -2,9 +2,6 @@ import { Image, Session } from './DTOs';
|
|
|
2
2
|
import { BaseClient } from './BaseClient';
|
|
3
3
|
import { ConnectionOptions } from 'nats.ws';
|
|
4
4
|
export declare class RunnerClient extends BaseClient {
|
|
5
|
-
private http;
|
|
6
|
-
private baseUrl;
|
|
7
|
-
protected jsonParseReviver: ((key: string, value: any) => any) | undefined;
|
|
8
5
|
constructor(baseSubject: string, options: ConnectionOptions);
|
|
9
6
|
/**
|
|
10
7
|
* Get the created image with the specified ID.
|
package/lib/RunnerClient.js
CHANGED
|
@@ -18,9 +18,7 @@ import { BaseClient } from './BaseClient';
|
|
|
18
18
|
var RunnerClient = /** @class */ (function (_super) {
|
|
19
19
|
__extends(RunnerClient, _super);
|
|
20
20
|
function RunnerClient(baseSubject, options) {
|
|
21
|
-
|
|
22
|
-
_this.jsonParseReviver = undefined;
|
|
23
|
-
return _this;
|
|
21
|
+
return _super.call(this, baseSubject, options) || this;
|
|
24
22
|
}
|
|
25
23
|
/**
|
|
26
24
|
* Get the created image with the specified ID.
|
package/lib/SessionClient.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
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
|
-
import { ConnectionOptions, NatsError, Subscription, SubscriptionOptions } from 'nats.ws
|
|
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';
|
|
2
|
+
import { ConnectionOptions, NatsError, Subscription, SubscriptionOptions } from 'nats.ws';
|
|
3
3
|
import { BaseClient } from './BaseClient';
|
|
4
4
|
export declare class SessionClient extends BaseClient {
|
|
5
|
-
private
|
|
6
|
-
private eventsWildcardSubscription;
|
|
5
|
+
private subscriptions;
|
|
7
6
|
constructor(baseSubject: string, options: ConnectionOptions);
|
|
8
7
|
/**
|
|
9
8
|
* @param sessionLogsHandler Function to be called when log list or error is received
|
|
@@ -87,6 +86,11 @@ export declare class SessionClient extends BaseClient {
|
|
|
87
86
|
* @return Test plan retrieved
|
|
88
87
|
*/
|
|
89
88
|
getTestPlanXML(): Promise<string>;
|
|
89
|
+
/**
|
|
90
|
+
* Retrieve loaded test plan XML
|
|
91
|
+
* @return Test plan retrieved
|
|
92
|
+
*/
|
|
93
|
+
downloadResource(resource: Resource): Promise<Uint8Array>;
|
|
90
94
|
/**
|
|
91
95
|
* Load test plan using a test plan TapPackage from a repository
|
|
92
96
|
* @param {RepositoryPackageDefinition} packageReference
|
package/lib/SessionClient.js
CHANGED
|
@@ -25,12 +25,14 @@ var __assign = (this && this.__assign) || function () {
|
|
|
25
25
|
return __assign.apply(this, arguments);
|
|
26
26
|
};
|
|
27
27
|
import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Interaction, ListItemType, LogList, Result, RunStatus, SessionEvent, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog, } from './DTOs';
|
|
28
|
-
import { JSONCodec } from 'nats.ws
|
|
28
|
+
import { JSONCodec } from 'nats.ws';
|
|
29
29
|
import { BaseClient } from './BaseClient';
|
|
30
30
|
var SessionClient = /** @class */ (function (_super) {
|
|
31
31
|
__extends(SessionClient, _super);
|
|
32
32
|
function SessionClient(baseSubject, options) {
|
|
33
|
-
|
|
33
|
+
var _this = _super.call(this, baseSubject, options) || this;
|
|
34
|
+
_this.subscriptions = [];
|
|
35
|
+
return _this;
|
|
34
36
|
}
|
|
35
37
|
/**
|
|
36
38
|
* @param sessionLogsHandler Function to be called when log list or error is received
|
|
@@ -75,8 +77,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
75
77
|
eventHandler(undefined, error);
|
|
76
78
|
}
|
|
77
79
|
};
|
|
78
|
-
this.
|
|
79
|
-
this.
|
|
80
|
+
this.subscriptions.push(this.subscribe('Events', __assign(__assign({}, options), { callback: callback })));
|
|
81
|
+
this.subscriptions.push(this.subscribe('Events.*', __assign(__assign({}, options), { callback: callback })));
|
|
80
82
|
};
|
|
81
83
|
/**
|
|
82
84
|
* @param resultHandler Function to be called when result or error is received
|
|
@@ -122,12 +124,8 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
122
124
|
* Unsubscibe from session events
|
|
123
125
|
*/
|
|
124
126
|
SessionClient.prototype.unsubscribeSessionEvents = function () {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
}
|
|
128
|
-
if (this.eventsWildcardSubscription) {
|
|
129
|
-
this.eventsWildcardSubscription.unsubscribe();
|
|
130
|
-
}
|
|
127
|
+
var _a;
|
|
128
|
+
(_a = this.subscriptions) === null || _a === void 0 ? void 0 : _a.forEach(function (subscription) { return subscription.unsubscribe(); });
|
|
131
129
|
};
|
|
132
130
|
/**
|
|
133
131
|
* Retrieve session logs
|
|
@@ -199,14 +197,27 @@ var SessionClient = /** @class */ (function (_super) {
|
|
|
199
197
|
* @return Test plan loaded. List of load errors is returned.
|
|
200
198
|
*/
|
|
201
199
|
SessionClient.prototype.setTestPlanXML = function (xml) {
|
|
202
|
-
return this.
|
|
200
|
+
return this.sendChunked('SetTestPlanXML', xml).then(this.success()).catch(this.error());
|
|
203
201
|
};
|
|
204
202
|
/**
|
|
205
203
|
* Retrieve loaded test plan XML
|
|
206
204
|
* @return Test plan retrieved
|
|
207
205
|
*/
|
|
208
206
|
SessionClient.prototype.getTestPlanXML = function () {
|
|
209
|
-
return this.
|
|
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());
|
|
210
221
|
};
|
|
211
222
|
/**
|
|
212
223
|
* Load test plan using a test plan TapPackage from a repository
|
package/lib/index.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export { RunnerClient } from './RunnerClient';
|
|
2
2
|
export { SessionClient } from './SessionClient';
|
|
3
3
|
export * from './DTOs';
|
|
4
|
-
export * from 'nats.ws
|
|
5
|
-
export * from 'nats.ws/lib/nats-base-client/authenticator';
|
|
6
|
-
export * from 'nats.ws/lib/nats-base-client/error';
|
|
4
|
+
export * from 'nats.ws';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
export { RunnerClient } from './RunnerClient';
|
|
2
2
|
export { SessionClient } from './SessionClient';
|
|
3
3
|
export * from './DTOs';
|
|
4
|
-
export * from 'nats.ws
|
|
5
|
-
export * from 'nats.ws/lib/nats-base-client/authenticator';
|
|
6
|
-
export * from 'nats.ws/lib/nats-base-client/error';
|
|
4
|
+
export * from 'nats.ws';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opentap/runner-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.2.10",
|
|
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",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
13
13
|
},
|
|
14
14
|
"author": "OpenTap.io",
|
|
15
|
-
"license": "
|
|
15
|
+
"license": "MIT",
|
|
16
16
|
"files": [
|
|
17
17
|
"lib/**/*"
|
|
18
18
|
],
|
|
@@ -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}": [
|