@opentap/runner-client 2.20.0-alpha.1.8.7789948835 → 2.20.0

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.
@@ -0,0 +1,595 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ import { ComponentSettingsBase, ComponentSettingsIdentifier, ComponentSettingsListItem, DataGridControl, ErrorResponse, FileDescriptor, ListItemType, ProfileGroup, } from './DTOs';
11
+ import { Empty, ErrorCode, JSONCodec, StringCodec, connect, headers, } from 'nats.ws';
12
+ import { EventEmitter } from 'events';
13
+ import { v4 as uuidv4 } from 'uuid';
14
+ const DEFAULT_TIMEOUT = 40000; // default timeout of 40 seconds
15
+ var Events;
16
+ (function (Events) {
17
+ Events["ERROR"] = "error_event";
18
+ })(Events || (Events = {}));
19
+ export class BaseClient {
20
+ constructor(baseSubject, options) {
21
+ this.domainAccess = new Map();
22
+ this._headers = {};
23
+ this.baseSubject = baseSubject;
24
+ this.connectionOptions = Object.assign({}, options) || {};
25
+ this.connectionOptions.timeout = (options === null || options === void 0 ? void 0 : options.timeout) || DEFAULT_TIMEOUT;
26
+ this.eventEmitter = new EventEmitter();
27
+ }
28
+ /** Get request access token */
29
+ get accessToken() {
30
+ return this._accessToken;
31
+ }
32
+ /** Set request access token */
33
+ set accessToken(value) {
34
+ this._accessToken = value;
35
+ }
36
+ /** Get request headers */
37
+ get headers() {
38
+ return this._headers;
39
+ }
40
+ /** Set request headers */
41
+ set headers(value) {
42
+ this._headers = value;
43
+ }
44
+ /** Get timeout */
45
+ get timeout() {
46
+ return this._timeout || DEFAULT_TIMEOUT;
47
+ }
48
+ /** Set timeout in milliseconds. Default is 40000 milliseconds */
49
+ set timeout(value) {
50
+ this._timeout = value;
51
+ }
52
+ withTimeout(promise, timeout) {
53
+ return Promise.race([promise, new Promise((_, reject) => setTimeout(() => reject(new Error(ErrorCode.Timeout)), timeout))]);
54
+ }
55
+ /**
56
+ * Send a request to the nats server.
57
+ * @param subject The subject to request
58
+ * @param payload (optional)
59
+ * @param options (optional)
60
+ * @returns Promise of an object
61
+ */
62
+ request(subject, payload, options) {
63
+ var _a, _b;
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ // Prepend the base subject if the given subject does not start with that
66
+ if (!(options === null || options === void 0 ? void 0 : options.fullSubject)) {
67
+ subject = `${this.baseSubject}.Request.${subject}`;
68
+ }
69
+ if (!this.connection)
70
+ return Promise.reject(`${subject}: Connection is down! Please try again!`);
71
+ if (this.connection.isClosed())
72
+ return Promise.reject(`${subject}: Connection has been closed! Please reconnect!`);
73
+ const data = this.encode(payload);
74
+ const headers = this.buildHeaders();
75
+ const timeout = (options === null || options === void 0 ? void 0 : options.timeout) || this.timeout;
76
+ // Generate a unique reply subject that we can subscribe to
77
+ const replySubject = `${subject}.Reply.${uuidv4()}`;
78
+ // Larger payloads are always faster because the request time is bound
79
+ // by the number of chunks roundtrips we need to make.
80
+ // 99% of requests will fit in a single chunk which is ideal,
81
+ // because it only requires a single roundtrip, same as a regular Request call.
82
+ // If serverMaxPayload is not available for some reason, we just use a default chunk size of 512000.
83
+ // We subtract 50000 from max_payload in order to leave room for headers, which
84
+ // can be quite large since they can contain jwt tokens, which may contain all sorts of information.
85
+ const serverMaxPayload = (_b = (_a = this.connection) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.max_payload;
86
+ const chunkSize = serverMaxPayload ? serverMaxPayload - 50000 : 512000;
87
+ // The Session and the Client need to agree on the chunk size. Put it in a header.
88
+ headers.append('ChunkSize', chunkSize.toString());
89
+ // Generate a unique request ID which the Session needs to associate chunks
90
+ const requestId = uuidv4();
91
+ headers.append('RequestId', requestId);
92
+ const opts = Object.assign(Object.assign({}, options === null || options === void 0 ? void 0 : options.publishOptions), { headers, reply: replySubject });
93
+ const fileDescriptor = new FileDescriptor(data.length, chunkSize);
94
+ // Put the chunk sequence number in a header so the session knows if a chunk is missing
95
+ let chunkNumber = 1;
96
+ headers.set('ChunkNumber', chunkNumber.toString());
97
+ const getChunk = (chunk) => {
98
+ const offset = chunk * fileDescriptor.chunkSize;
99
+ return data.slice(offset, offset + fileDescriptor.chunkSize);
100
+ };
101
+ // Set up the subscription before we start publishing chunks
102
+ const subscription = this.connection.subscribe(replySubject);
103
+ // The response from the session will arrive in this promise after we have finished
104
+ // publishing chunks
105
+ const responsePromise = new Promise((resolve, reject) => {
106
+ const messages = [];
107
+ subscription.callback = (error, message) => {
108
+ var _a, _b, _c, _d;
109
+ if (error) {
110
+ return reject(error);
111
+ }
112
+ if (((_a = message.headers) === null || _a === void 0 ? void 0 : _a.code) === 503) {
113
+ return reject(Error('No responders.'));
114
+ }
115
+ // If the message isn't chunked, we can assume the message is finished after a single message has been received.
116
+ const chunkNumber = (_b = message.headers) === null || _b === void 0 ? void 0 : _b.get('ChunkNumber');
117
+ // ChunkNumber starts from 1, so this check should be correct
118
+ if (!chunkNumber) {
119
+ subscription.unsubscribe();
120
+ return resolve({ byteArray: message.data, isErrorResponse: ((_c = message.headers) === null || _c === void 0 ? void 0 : _c.get('OpenTapNatsError')) === 'true' });
121
+ }
122
+ // Put all the response chunks in an array in the order they are received
123
+ messages.push(message);
124
+ // If the chunk has a size equal to the chunkSize, we should expect another message
125
+ if (message.data.length === chunkSize) {
126
+ return;
127
+ }
128
+ // If the chunk has a length smaller than the chunkSize, the message is complete
129
+ // If the final message was received, we can safely unsubscribe
130
+ subscription.unsubscribe();
131
+ // Check if the number of the final message is equal to the number of
132
+ // messages we received. If this is not the case, we dropped a chunk,
133
+ // likely due to a network error. In this case, the entire message is invalid.
134
+ if (parseInt(chunkNumber) !== messages.length) {
135
+ return reject(Error(`Expected {finalMessageNumber} chunks, but received ${messages.length}. ` +
136
+ `The connection may have been interrupted.`));
137
+ }
138
+ // Concatenate the payloads
139
+ // When there are many chunks, doing a single allocation
140
+ // is significantly faster than concatenating arrays in sequence
141
+ const flattenedSize = messages.reduce((sum, array) => sum + array.data.length, 0);
142
+ const flattenedArray = new Uint8Array(flattenedSize);
143
+ let k = 0;
144
+ messages.forEach(m => {
145
+ for (let i = 0; i < m.data.length; i++) {
146
+ flattenedArray[k++] = m.data[i];
147
+ }
148
+ });
149
+ return resolve({ byteArray: flattenedArray, isErrorResponse: ((_d = message.headers) === null || _d === void 0 ? void 0 : _d.get('OpenTapNatsError')) === 'true' });
150
+ };
151
+ }).then(({ byteArray, isErrorResponse }) => {
152
+ if (byteArray.length === 0) {
153
+ return Promise.resolve(undefined);
154
+ }
155
+ const jsonCodec = JSONCodec();
156
+ // If a raw response is requested, we should avoid decoding the bytes.
157
+ const response = (options === null || options === void 0 ? void 0 : options.rawResponse) ? byteArray : jsonCodec.decode(byteArray);
158
+ return isErrorResponse ? Promise.reject(ErrorResponse.fromJS(response)) : Promise.resolve(response);
159
+ });
160
+ // 'Manually' publish the first chunk. This is to ensure that **at least** one chunk is published.
161
+ // This is a special case for empty payloads (which are common)
162
+ let chunk = getChunk(0);
163
+ this.connection.publish(subject, chunk, opts);
164
+ chunkNumber += 1;
165
+ for (let i = 1; i < fileDescriptor.numberOfChunks; i++) {
166
+ headers.set('ChunkNumber', chunkNumber.toString());
167
+ chunk = getChunk(i);
168
+ this.connection.publish(subject, chunk, opts);
169
+ chunkNumber += 1;
170
+ }
171
+ // In the special case where the last published chunk was full, we need to publish
172
+ // an empty message
173
+ if (data.length > 0 && data.length % fileDescriptor.chunkSize === 0) {
174
+ headers.set('ChunkNumber', chunkNumber.toString());
175
+ this.connection.publish(subject, Empty, opts);
176
+ }
177
+ // Now that we have sent the terminating chunk, the result should arrive on our promise.
178
+ return this.withTimeout(responsePromise, timeout).catch(err => {
179
+ subscription.unsubscribe();
180
+ return Promise.reject(this.natsErrorHandler(err, subject));
181
+ });
182
+ });
183
+ }
184
+ /**
185
+ * Handle the error
186
+ * @param error
187
+ * @param subject
188
+ * @returns
189
+ */
190
+ natsErrorHandler(error, subject) {
191
+ const errorResponse = new ErrorResponse(error);
192
+ errorResponse.subject = subject;
193
+ errorResponse.stackTrace = error === null || error === void 0 ? void 0 : error.stack;
194
+ switch (error === null || error === void 0 ? void 0 : error.code) {
195
+ case ErrorCode.NoResponders:
196
+ errorResponse.message = 'No Responders';
197
+ break;
198
+ default:
199
+ errorResponse.message = error.message;
200
+ }
201
+ this.eventEmitter.emit(Events.ERROR, errorResponse);
202
+ return errorResponse;
203
+ }
204
+ /**
205
+ * Build the headers' object.
206
+ * @returns {MsgHdrs} Header object
207
+ */
208
+ buildHeaders() {
209
+ var _a;
210
+ const _headers = headers();
211
+ this._accessToken && _headers.set('Authorization', this._accessToken);
212
+ (_a = this.domainAccess) === null || _a === void 0 ? void 0 : _a.forEach((value, key) => _headers.append('DomainAuthorization', `${key}|${value}`));
213
+ Object.entries(this._headers).forEach(([key, value]) => _headers.append(key, value));
214
+ return _headers;
215
+ }
216
+ /**
217
+ * Subscribes to given subject.
218
+ * @param subject The subject to subscribe
219
+ * @param options Subscription options
220
+ * @returns Subscription object
221
+ */
222
+ subscribe(subject, options) {
223
+ if (!subject)
224
+ throw Error('Subject is not defined!');
225
+ if (!this.connection)
226
+ throw Error('Connection is not up yet! Please try again later!');
227
+ if (this.connection.isClosed())
228
+ throw Error('Connection has been closed! Please reconnect!');
229
+ const natsSubject = `${this.baseSubject}.${subject}`;
230
+ return this.connection.subscribe(natsSubject, options);
231
+ }
232
+ encode(payload) {
233
+ if (!payload) {
234
+ return Empty;
235
+ }
236
+ if (payload instanceof Uint8Array) {
237
+ return payload;
238
+ }
239
+ return StringCodec().encode(JSON.stringify(payload));
240
+ }
241
+ /**
242
+ * Create a connection to the nats server.
243
+ * @param {ConnectionOptions} options
244
+ */
245
+ connect() {
246
+ return __awaiter(this, void 0, void 0, function* () {
247
+ if (!this.baseSubject)
248
+ return Promise.reject('Subject must be given');
249
+ if (this.connection)
250
+ return Promise.resolve();
251
+ try {
252
+ return yield connect(this.connectionOptions)
253
+ .then((connection) => {
254
+ this.connection = connection;
255
+ return Promise.resolve();
256
+ })
257
+ .catch((error) => Promise.reject(`Failed to connect to ${this.connectionOptions.servers} with ${error}`));
258
+ }
259
+ catch (error) {
260
+ return Promise.reject(`Failed to connect to ${this.connectionOptions.servers} with ${error}`);
261
+ }
262
+ });
263
+ }
264
+ /**
265
+ * Close the connection.
266
+ */
267
+ close() {
268
+ var _a;
269
+ return __awaiter(this, void 0, void 0, function* () {
270
+ if (this.connection) {
271
+ yield ((_a = this.connection) === null || _a === void 0 ? void 0 : _a.close().then(() => {
272
+ this.connection = null;
273
+ }).catch((error) => {
274
+ throw new Error(`failed to close connection: ${error}`);
275
+ }));
276
+ }
277
+ });
278
+ }
279
+ /**
280
+ * Add a domain specific access token to the dictionary.
281
+ * @param {string} domain
282
+ * @param {string} accessToken
283
+ */
284
+ addDomainAccessToken(domain, accessToken) {
285
+ if (!domain || !accessToken)
286
+ return;
287
+ this.domainAccess.set(domain, accessToken);
288
+ }
289
+ /**
290
+ * Generic error callback function.
291
+ * @returns
292
+ */
293
+ error() {
294
+ return error => {
295
+ throw error;
296
+ };
297
+ }
298
+ /**
299
+ * Generic success callback function.
300
+ * @returns
301
+ */
302
+ success() {
303
+ return response => response;
304
+ }
305
+ /**
306
+ * Add an error-event listener.
307
+ * @param listener
308
+ * @returns {EventEmitter}
309
+ */
310
+ addErrorEventListener(listener) {
311
+ var _a;
312
+ (_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.addListener(Events.ERROR, listener);
313
+ }
314
+ /**
315
+ * Remove an error-event listener.
316
+ * @param listener
317
+ */
318
+ removeErrorEventListener(listener) {
319
+ var _a;
320
+ (_a = this.eventEmitter) === null || _a === void 0 ? void 0 : _a.removeListener(Events.ERROR, listener);
321
+ }
322
+ /**
323
+ * Retrieve component settings overview
324
+ * @returns {{Promise<ComponentSettingsIdentifier[]>}}
325
+ */
326
+ getComponentSettingsOverview() {
327
+ return this.request('GetComponentSettingsOverview')
328
+ .then(componentSettingsIdentifiers => componentSettingsIdentifiers.map(componentSettingsIdentifier => ComponentSettingsIdentifier.fromJS(componentSettingsIdentifier)))
329
+ .then(this.success())
330
+ .catch(this.error());
331
+ }
332
+ /**
333
+ * Change componentsettings
334
+ * @param groupName
335
+ * @param name
336
+ * @param returnedSettings
337
+ * @returns {{Promise<ComponentSettingsBase>}}
338
+ */
339
+ setComponentSettings(groupName, name, returnedSettings) {
340
+ const setComponentSettingsRequest = { groupName, name, returnedSettings };
341
+ return this.request('SetComponentSettings', setComponentSettingsRequest)
342
+ .then(componentSettingsBase => ComponentSettingsBase.fromJS(componentSettingsBase))
343
+ .then(this.success())
344
+ .catch(this.error());
345
+ }
346
+ /**
347
+ * Retrieve componentsettings
348
+ * @param groupName
349
+ * @param name
350
+ * @returns {{Promise<ComponentSettingsBase>}}
351
+ */
352
+ getComponentSettings(groupName, name) {
353
+ const getComponentSettingsRequest = { groupName, name };
354
+ return this.request('GetComponentSettings', getComponentSettingsRequest)
355
+ .then(componentSettingsBase => ComponentSettingsBase.fromJS(componentSettingsBase))
356
+ .then(this.success())
357
+ .catch(this.error());
358
+ }
359
+ /**
360
+ * Retrieve componentsettings list item
361
+ * @param groupName
362
+ * @param name
363
+ * @param index
364
+ * @returns {{Promise<ComponentSettingsListItem>}}
365
+ */
366
+ getComponentSettingsListItem(groupName, name, index) {
367
+ const getComponentSettingsListItemRequest = { groupName, name, index };
368
+ return this.request('GetComponentSettingsListItem', getComponentSettingsListItemRequest)
369
+ .then(componentSettingsListItem => ComponentSettingsListItem.fromJS(componentSettingsListItem))
370
+ .then(this.success())
371
+ .catch(this.error());
372
+ }
373
+ /**
374
+ * Set componentsettings list item settings
375
+ * @param {string} groupName
376
+ * @param {string} name
377
+ * @param {number} index
378
+ * @param {ComponentSettingsListItem} item
379
+ * @returns {Promise<ComponentSettingsListItem>}
380
+ */
381
+ setComponentSettingsListItem(groupName, name, index, item) {
382
+ const setComponentSettingsListItemRequest = { groupName, name, index, item };
383
+ return this.request('SetComponentSettingsListItem', setComponentSettingsListItemRequest)
384
+ .then(componentSettingsListItem => ComponentSettingsListItem.fromJS(componentSettingsListItem))
385
+ .then(this.success())
386
+ .catch(this.error());
387
+ }
388
+ /**
389
+ * Get component setting data grid
390
+ * @param {string} groupName
391
+ * @param {string} name
392
+ * @param {number} index
393
+ * @param {string} propertyName
394
+ * @returns {Promise<DataGridControl>}
395
+ */
396
+ getComponentSettingDataGrid(groupName, name, index, propertyName) {
397
+ const getComponentSettingDataGridRequest = {
398
+ groupName,
399
+ name,
400
+ index,
401
+ propertyName,
402
+ };
403
+ return this.request('GetComponentSettingDataGrid', getComponentSettingDataGridRequest)
404
+ .then(dataGridControl => DataGridControl.fromJS(dataGridControl))
405
+ .then(this.success())
406
+ .catch(this.error());
407
+ }
408
+ /**
409
+ * Set component setting data grid
410
+ * @param {string} groupName
411
+ * @param {string} name
412
+ * @param {number} index
413
+ * @param {string} propertyName
414
+ * @param {DataGridControl} dataGridControl
415
+ * @returns {{Promise<DataGridControl>}}
416
+ */
417
+ setComponentSettingDataGrid(groupName, name, index, propertyName, dataGridControl) {
418
+ const setComponentSettingDataGridRequest = {
419
+ groupName,
420
+ name,
421
+ index,
422
+ propertyName,
423
+ dataGridControl,
424
+ };
425
+ return this.request('SetComponentSettingDataGrid', setComponentSettingDataGridRequest)
426
+ .then(dataGridControl => DataGridControl.fromJS(dataGridControl))
427
+ .then(this.success())
428
+ .catch(this.error());
429
+ }
430
+ /**
431
+ * Add component setting item type to data grid
432
+ * @param {string} groupName
433
+ * @param {string} name
434
+ * @param {number} index
435
+ * @param {string} propertyName
436
+ * @param {string} typeName
437
+ * @returns {Promise<DataGridControl>}
438
+ */
439
+ addComponentSettingDataGridItemType(groupName, name, index, propertyName, typeName) {
440
+ const addComponentSettingDataGridItemTypeRequest = {
441
+ groupName,
442
+ name,
443
+ index,
444
+ propertyName,
445
+ typeName,
446
+ };
447
+ return this.request('AddComponentSettingDataGridItemType', addComponentSettingDataGridItemTypeRequest)
448
+ .then(dataGridControl => DataGridControl.fromJS(dataGridControl))
449
+ .then(this.success())
450
+ .catch(this.error());
451
+ }
452
+ /**
453
+ * Add component setting item to data grid
454
+ * @param {string} groupName
455
+ * @param {string} name
456
+ * @param {number} index
457
+ * @param {string} propertyName
458
+ * @returns {Promise<DataGridControl>}
459
+ */
460
+ addComponentSettingDataGridItem(groupName, name, index, propertyName) {
461
+ const getComponentSettingDataGridRequest = {
462
+ groupName,
463
+ name,
464
+ index,
465
+ propertyName,
466
+ };
467
+ return this.request('AddComponentSettingDataGridItem', getComponentSettingDataGridRequest)
468
+ .then(dataGridControl => DataGridControl.fromJS(dataGridControl))
469
+ .then(this.success())
470
+ .catch(this.error());
471
+ }
472
+ /**
473
+ * Get item types available in the component setting data grid
474
+ * @param groupName
475
+ * @param name
476
+ * @param index
477
+ * @param propertyName
478
+ * @returns {Promise<ListItemType[]>}
479
+ */
480
+ getComponentSettingDataGridTypes(groupName, name, index, propertyName) {
481
+ const getComponentSettingDataGridRequest = {
482
+ groupName,
483
+ name,
484
+ index,
485
+ propertyName,
486
+ };
487
+ return this.request('GetComponentSettingDataGridTypes', getComponentSettingDataGridRequest)
488
+ .then(listItemTypes => listItemTypes.map(listItemType => ListItemType.fromJS(listItemType)))
489
+ .then(this.success())
490
+ .catch(this.error());
491
+ }
492
+ /**
493
+ * Change componentsettings profiles
494
+ * @param {ProfileGroup[]} returnedSettings
495
+ * @returns {Promise<ProfileGroup[]>}
496
+ */
497
+ setComponentSettingsProfiles(returnedSettings) {
498
+ return this.request('SetComponentSettingsProfiles', returnedSettings)
499
+ .then(profileGroups => profileGroups.map(profileGroup => ProfileGroup.fromJS(profileGroup)))
500
+ .then(this.success())
501
+ .catch(this.error());
502
+ }
503
+ /**
504
+ * Get componentsettings profiles
505
+ * @returns {Promise<ProfileGroup[]>}
506
+ */
507
+ getComponentSettingsProfiles() {
508
+ return this.request('GetComponentSettingsProfiles')
509
+ .then(profileGroups => profileGroups.map(profileGroup => ProfileGroup.fromJS(profileGroup)))
510
+ .then(this.success())
511
+ .catch(this.error());
512
+ }
513
+ /**
514
+ * Upload exported OpenTAP Settings files
515
+ * @param {FileParameter} file
516
+ * @returns {Promise<void>}
517
+ */
518
+ uploadComponentSettings(file) {
519
+ return file
520
+ ? this.request('UploadComponentSettings', file).then(this.success()).catch(this.error())
521
+ : Promise.reject('file must be defined');
522
+ }
523
+ /**
524
+ * Downloads a .TapSettings file containing the settings for a given component settings group
525
+ * @param {DownloadTapSettingsRequest} tapSettingsRequest The download request specifying the component settings group to download
526
+ * @returns {Promise<Uint8Array>} A byte array containing the downloaded .TapSettings file
527
+ */
528
+ downloadComponentSettings(tapSettingsRequest) {
529
+ return this.request('DownloadComponentSettings', tapSettingsRequest, { rawResponse: true })
530
+ .then(this.success())
531
+ .catch(this.error());
532
+ }
533
+ /**
534
+ * Load a component settings TapPackage by referencing a package in a package repository
535
+ * @param {RepositoryPackageReference} packageReference
536
+ * @returns {Promise<ErrorResponse[]>}
537
+ */
538
+ loadComponentSettingsFromRepository(packageReference) {
539
+ return this.request('LoadComponentSettingsFromRepository', packageReference)
540
+ .then(errorResponses => errorResponses.map(errorResponse => ErrorResponse.fromJS(errorResponse)))
541
+ .then(this.success())
542
+ .catch(this.error());
543
+ }
544
+ /**
545
+ * Save a TapPackage containing component settings in a package repository
546
+ * @param {RepositorySettingsPackageDefinition} repositoryPackageDefinition
547
+ * @returns {Promise<void>}
548
+ */
549
+ saveComponentSettingsToRepository(repositoryPackageDefinition) {
550
+ return repositoryPackageDefinition
551
+ ? this.request('SaveComponentSettingsToRepository', repositoryPackageDefinition).then(this.success()).catch(this.error())
552
+ : Promise.reject('repositoryPackageDefinition must be defined');
553
+ }
554
+ /**
555
+ * Retrieve types available to be added to specified component settings list
556
+ * @param {string} groupName
557
+ * @param {string} name
558
+ * @returns {Promise<ListItemType[]>}
559
+ */
560
+ getComponentSettingsListAvailableTypes(groupName, name) {
561
+ const getComponentSettingsRequest = { groupName, name };
562
+ return this.request('GetComponentSettingsListAvailableTypes', getComponentSettingsRequest)
563
+ .then(listItemTypes => listItemTypes.map(listItemType => ListItemType.fromJS(listItemType)))
564
+ .then(this.success())
565
+ .catch(this.error());
566
+ }
567
+ /**
568
+ * Adds a new item to a component settings list
569
+ * @param {string} groupName
570
+ * @param {string} name
571
+ * @param {string} typeName
572
+ * @returns {Promise<ListItemType[]>}
573
+ */
574
+ addComponentSettingsListItem(groupName, name, typeName) {
575
+ const addComponentSettingsListItemRequest = { groupName, name, typeName };
576
+ return this.request('AddComponentSettingsListItem', addComponentSettingsListItemRequest)
577
+ .then(componentSettingsBase => ComponentSettingsBase.fromJS(componentSettingsBase))
578
+ .then(this.success())
579
+ .catch(this.error());
580
+ }
581
+ /**
582
+ * Get settings package files
583
+ * @returns {Promise<string[]>}
584
+ */
585
+ getSettingsPackageFiles() {
586
+ return this.request('GetSettingsPackageFiles').then(this.success()).catch(this.error());
587
+ }
588
+ /**
589
+ * Get settings package types
590
+ * @returns {Promise<string[]>}
591
+ */
592
+ settingsPackageTypes() {
593
+ return this.request('SettingsPackageTypes').then(this.success()).catch(this.error());
594
+ }
595
+ }
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  export declare class Image implements IImage {
2
3
  name?: string | undefined;
3
4
  packages?: PackageSpecifier[];
@@ -1205,6 +1206,36 @@ export declare class TestPlanSettingsChangedEventArgs extends SessionEvent imple
1205
1206
  toJSON(data?: any): any;
1206
1207
  }
1207
1208
  export declare type ITestPlanSettingsChangedEventArgs = ISessionEvent;
1209
+ export interface IOnTestPlanRun {
1210
+ status?: string;
1211
+ userId?: string;
1212
+ }
1213
+ export declare class OnTestPlanRun implements IOnTestPlanRun {
1214
+ status?: string;
1215
+ userId?: string;
1216
+ constructor(data?: IOnTestPlanRun);
1217
+ init(_data?: any): void;
1218
+ static fromJS(data: any): OnTestPlanRun;
1219
+ toJSON(data?: any): any;
1220
+ }
1221
+ export interface IOnTestStepRun {
1222
+ status?: string;
1223
+ stepId?: string;
1224
+ parentRunId?: string;
1225
+ verdict?: string;
1226
+ duration?: string;
1227
+ }
1228
+ export declare class OnTestStepRun implements IOnTestStepRun {
1229
+ status?: string;
1230
+ stepId?: string;
1231
+ parentRunId?: string;
1232
+ verdict?: string;
1233
+ duration?: string;
1234
+ constructor(data?: IOnTestStepRun);
1235
+ init(_data?: any): void;
1236
+ static fromJS(data: any): OnTestStepRun;
1237
+ toJSON(data?: any): any;
1238
+ }
1208
1239
  export interface ITestStepRunEvent {
1209
1240
  parent?: string;
1210
1241
  testStepId?: string;