@opentap/runner-client 2.19.0-alpha.1.7.7872156008 → 2.19.0-alpha.1.8

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