@opentap/runner-client 2.19.0-alpha.1.3 → 2.19.0-alpha.1.5.7814515799

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