@opentap/runner-client 2.20.0-alpha.1.7.7789778780 → 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,739 @@
1
+ import { BreakPoints, CommonContext, CommonSettings, DataGridControl, Image, Interaction, ListItemType, LogList, OnTestPlanRun, OnTestStepRun, Parameter, Result, RunStatus, SessionEvent, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog, } from './DTOs';
2
+ import { JSONCodec } from 'nats.ws';
3
+ import { BaseClient } from './BaseClient';
4
+ export class SessionClient extends BaseClient {
5
+ constructor(baseSubject, options) {
6
+ super(baseSubject, options);
7
+ this.subscriptions = [];
8
+ }
9
+ /**
10
+ * @param sessionLogsHandler Function to be called when log list or error is received
11
+ * @param options (optional) Subscription options
12
+ * @returns Subscription object
13
+ */
14
+ connectSessionLogs(sessionLogsHandler, options) {
15
+ return this.subscribe('SessionLogs', Object.assign(Object.assign({}, options), { callback(error, encodedMessage) {
16
+ if (error) {
17
+ sessionLogsHandler(undefined, error);
18
+ return;
19
+ }
20
+ try {
21
+ const jsonCodec = JSONCodec();
22
+ const logListJson = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
23
+ const logList = LogList.fromJS(logListJson);
24
+ sessionLogsHandler(logList, error);
25
+ }
26
+ catch (error) {
27
+ sessionLogsHandler(undefined, error);
28
+ }
29
+ } }));
30
+ }
31
+ /**
32
+ * @param eventHandler Function to be called when session event or error is received
33
+ * @param options (optional) Subscription options
34
+ * @returns Subscription object
35
+ */
36
+ connectSessionEvents(eventHandler, options) {
37
+ const callback = (error, encodedMessage) => {
38
+ if (error) {
39
+ eventHandler(undefined, error);
40
+ return;
41
+ }
42
+ try {
43
+ const jsonCodec = JSONCodec();
44
+ const sessionEventJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
45
+ const sessionEvent = SessionEvent.fromJS(sessionEventJs);
46
+ eventHandler(sessionEvent, error);
47
+ }
48
+ catch (error) {
49
+ eventHandler(undefined, error);
50
+ }
51
+ };
52
+ this.subscriptions.push(this.subscribe('Events', Object.assign(Object.assign({}, options), { callback })));
53
+ this.subscriptions.push(this.subscribe('Events.*', Object.assign(Object.assign({}, options), { callback })));
54
+ }
55
+ /**
56
+ * @param resultHandler Function to be called when result or error is received
57
+ * @param testRunHandler Function to be called when test run or error is received
58
+ * @param options (optional) Subscription options
59
+ * @returns Subscription array: Result and Test Run subscriptions
60
+ */
61
+ connectSessionResults(resultHandler, testRunHandler, options) {
62
+ return [
63
+ this.subscribe('OnResult', Object.assign(Object.assign({}, options), { callback(error, encodedMessage) {
64
+ if (error) {
65
+ resultHandler(undefined, error);
66
+ return;
67
+ }
68
+ try {
69
+ const jsonCodec = JSONCodec();
70
+ const resultJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
71
+ const result = Result.fromJS(resultJs);
72
+ resultHandler(result, error);
73
+ }
74
+ catch (error) {
75
+ resultHandler(undefined, error);
76
+ }
77
+ } })),
78
+ this.subscribe('OnTestRun', Object.assign(Object.assign({}, options), { callback(error, encodedMessage) {
79
+ if (error) {
80
+ testRunHandler(undefined, error);
81
+ return;
82
+ }
83
+ try {
84
+ const jsonCodec = JSONCodec();
85
+ const testRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
86
+ const testRun = TestRun.fromJS(testRunJs);
87
+ testRunHandler(testRun, error);
88
+ }
89
+ catch (error) {
90
+ testRunHandler(undefined, error);
91
+ }
92
+ } })),
93
+ ];
94
+ }
95
+ /**
96
+ * @param testRunHandler Function to be called when test run or error is received
97
+ * @param options (optional) Subscription options
98
+ * @returns Subscription array: Result and Test Run subscriptions
99
+ */
100
+ connectTestRunEvents(testRunHandler, options) {
101
+ return this.subscribe('OnTestRun', Object.assign(Object.assign({}, options), { callback(error, encodedMessage) {
102
+ if (error) {
103
+ testRunHandler(undefined, error);
104
+ return;
105
+ }
106
+ try {
107
+ const jsonCodec = JSONCodec();
108
+ const testRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
109
+ const testRun = TestRun.fromJS(testRunJs);
110
+ testRunHandler(testRun, error);
111
+ }
112
+ catch (error) {
113
+ testRunHandler(undefined, error);
114
+ }
115
+ } }));
116
+ }
117
+ /**
118
+ * Connect to listen to the TestPlanRun events for the given test plan run ID.
119
+ * @param {string} testPlanRunId
120
+ * @param {(event:OnTestPlanRun|undefined,err:NatsError|Error|null)=>void} handler
121
+ * @param {SubscriptionOptions} options?
122
+ * @returns Subscription
123
+ */
124
+ connectTestPlanRunEvents(testPlanRunId, handler, options) {
125
+ return this.subscribe(`PlanRun.${testPlanRunId}`, Object.assign(Object.assign({}, options), { callback(error, encodedMessage) {
126
+ if (error) {
127
+ handler(undefined, error);
128
+ return;
129
+ }
130
+ try {
131
+ const jsonCodec = JSONCodec();
132
+ const onTestPlanRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
133
+ const onTestPlanRun = OnTestPlanRun.fromJS(onTestPlanRunJs);
134
+ handler(onTestPlanRun, error);
135
+ }
136
+ catch (error) {
137
+ handler(undefined, error);
138
+ }
139
+ } }));
140
+ }
141
+ /**
142
+ * Connect to listen to the test plan run logs for the given test plan run ID
143
+ * @param {string} testPlanRunId
144
+ * @param {(logList:LogList|undefined,err:NatsError|Error|null)=>void} handler
145
+ * @param {SubscriptionOptions} options?
146
+ * @returns Subscription
147
+ */
148
+ connectTestPlanRunLogs(testPlanRunId, handler, options) {
149
+ return this.subscribe(`PlanRun.${testPlanRunId}.Logs`, Object.assign(Object.assign({}, options), { callback(error, encodedMessage) {
150
+ if (error) {
151
+ handler(undefined, error);
152
+ return;
153
+ }
154
+ try {
155
+ const jsonCodec = JSONCodec();
156
+ const logListJson = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
157
+ const logList = LogList.fromJS(logListJson);
158
+ handler(logList, error);
159
+ }
160
+ catch (error) {
161
+ handler(undefined, error);
162
+ }
163
+ } }));
164
+ }
165
+ /**
166
+ * Connect to listen to the test plan run parameter events for the given test plan run ID
167
+ * @param {string} testPlanRunId
168
+ * @param {(event:Parameter[]|undefined,err:NatsError|Error|null)=>void} handler
169
+ * @param {SubscriptionOptions} options?
170
+ * @returns Subscription
171
+ */
172
+ connectTestPlanRunParameterEvents(testPlanRunId, handler, options) {
173
+ return this.subscribe(`PlanRun.${testPlanRunId}.Parameters`, Object.assign(Object.assign({}, options), { callback(error, encodedMessage) {
174
+ if (error) {
175
+ handler(undefined, error);
176
+ return;
177
+ }
178
+ try {
179
+ const jsonCodec = JSONCodec();
180
+ const parameterListJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
181
+ const parameterList = parameterListJs.map(parameterJs => Parameter.fromJS(parameterJs));
182
+ handler(parameterList, error);
183
+ }
184
+ catch (error) {
185
+ handler(undefined, error);
186
+ }
187
+ } }));
188
+ }
189
+ /**
190
+ * Connect to listen to the test step run events for the given test step and test plan run ID
191
+ * @param {string} testPlanRunId
192
+ * @param {string} testStepRunId
193
+ * @param {(testRun:OnTestStepRun|undefined,err:NatsError|Error|null)=>void} handler
194
+ * @param {SubscriptionOptions} options?
195
+ * @returns Subscription
196
+ */
197
+ connectTestStepRunEvents(testPlanRunId, testStepRunId, handler, options) {
198
+ return this.subscribe(`PlanRun.${testPlanRunId}.StepRun.${testStepRunId}`, Object.assign(Object.assign({}, options), { callback(error, encodedMessage) {
199
+ var _a;
200
+ if (error) {
201
+ handler(undefined, undefined, error);
202
+ return;
203
+ }
204
+ try {
205
+ const jsonCodec = JSONCodec();
206
+ const onTestStepRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
207
+ const onTestStepRun = OnTestStepRun.fromJS(onTestStepRunJs);
208
+ const stepRunId = (_a = encodedMessage.subject.match(/\.StepRun\.(.+)$/)) === null || _a === void 0 ? void 0 : _a[1];
209
+ handler(stepRunId, onTestStepRun, error);
210
+ }
211
+ catch (error) {
212
+ handler(undefined, undefined, error);
213
+ }
214
+ } }));
215
+ }
216
+ /**
217
+ * Connect to listen to the test step run parameters for the given test step and test plan run ID
218
+ * @param {string} testPlanRunId
219
+ * @param {string} testStepRunId
220
+ * @param {(event:Parameter[]|undefined,err:NatsError|Error|null)=>void} handler
221
+ * @param {SubscriptionOptions} options?
222
+ * @returns Subscription
223
+ */
224
+ connectTestStepRunParameterEvents(testPlanRunId, testStepRunId, handler, options) {
225
+ return this.subscribe(`PlanRun.${testPlanRunId}.StepRun.${testStepRunId}.Parameters`, Object.assign(Object.assign({}, options), { callback(error, encodedMessage) {
226
+ if (error) {
227
+ handler(undefined, error);
228
+ return;
229
+ }
230
+ try {
231
+ const jsonCodec = JSONCodec();
232
+ const parameterListJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
233
+ const parameterList = parameterListJs.map(parameterJs => Parameter.fromJS(parameterJs));
234
+ handler(parameterList, error);
235
+ }
236
+ catch (error) {
237
+ handler(undefined, error);
238
+ }
239
+ } }));
240
+ }
241
+ /**
242
+ * Connect to listen to the test step run results for the given test step and test plan run ID
243
+ * @param {string} testPlanRunId
244
+ * @param {string} testStepRunId
245
+ * @param {string} resultName
246
+ * @param {(result:Result|undefined,err:NatsError|Error|null)=>void} handler
247
+ * @param {SubscriptionOptions} options?
248
+ * @returns Subscription
249
+ */
250
+ connectTestStepRunResults(testPlanRunId, testStepRunId, resultName, handler, options) {
251
+ return this.subscribe(`PlanRun.${testPlanRunId}.StepRun.${testStepRunId}.Result.${resultName}`, Object.assign(Object.assign({}, options), { callback(error, encodedMessage) {
252
+ if (error) {
253
+ handler(undefined, error);
254
+ return;
255
+ }
256
+ try {
257
+ const jsonCodec = JSONCodec();
258
+ const resultJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
259
+ const result = Result.fromJS(resultJs);
260
+ handler(result, error);
261
+ }
262
+ catch (error) {
263
+ handler(undefined, error);
264
+ }
265
+ } }));
266
+ }
267
+ /**
268
+ * Unsubscibe from session events
269
+ */
270
+ unsubscribeSessionEvents() {
271
+ var _a;
272
+ (_a = this.subscriptions) === null || _a === void 0 ? void 0 : _a.forEach(subscription => subscription.unsubscribe());
273
+ }
274
+ /**
275
+ * Retrieve session logs
276
+ * @param id (optional)
277
+ * @param level (optional)
278
+ * @param excludedSource (optional)
279
+ * @param filterText (optional)
280
+ * @param offset (optional)
281
+ * @param limit (optional)
282
+ * @return Successfully retrieved OpenTAP log messages.
283
+ */
284
+ getSessionLogs(id, levels, excludedSources, filterText, offset, limit) {
285
+ const getSessionLogsRequest = { id, levels, excludedSources, filterText, offset, limit };
286
+ return this.request('GetSessionLogs', getSessionLogsRequest)
287
+ .then(logListJs => LogList.fromJS(logListJs))
288
+ .then(this.success())
289
+ .catch(this.error());
290
+ }
291
+ /**
292
+ * Retrieve session log indexes
293
+ * @param id (optional)
294
+ * @param level (optional)
295
+ * @param excludedSource (optional)
296
+ * @param filterText (optional)
297
+ * @param searchText (optional)
298
+ * @return Logs indexes retrieved
299
+ */
300
+ sessionLogSearch(id, levels, excludedSources, filterText, searchText) {
301
+ const getSessionSearchRequest = { id, levels, excludedSources, filterText, searchText };
302
+ return this.request('SessionLogSearch', getSessionSearchRequest).then(this.success()).catch(this.error());
303
+ }
304
+ /**
305
+ * Retrieve log sources
306
+ * @param id (optional)
307
+ * @return Logs indexes retrieved
308
+ */
309
+ sessionLogSources(id) {
310
+ return this.request('SessionLogSources', id).then(this.success()).catch(this.error());
311
+ }
312
+ /**
313
+ * Retrieve session log counts
314
+ * @param id (optional)
315
+ * @return Logs indexes retrieved
316
+ */
317
+ sessionLogCounts(id) {
318
+ return this.request('SessionLogCounts', id).then(this.success()).catch(this.error());
319
+ }
320
+ /**
321
+ * Retrieve log severities
322
+ * @return Log levels retrieved
323
+ */
324
+ logLevels() {
325
+ return this.request('LogLevels').then(this.success()).catch(this.error());
326
+ }
327
+ /**
328
+ * Get status, with an optional testplan execution completion timeout
329
+ * @param {number | null | undefined} timeout (optional)
330
+ * @return RunStatus retrieved
331
+ */
332
+ getStatus(timeout) {
333
+ return this.request('GetStatus', timeout)
334
+ .then(runStatusJs => RunStatus.fromJS(runStatusJs))
335
+ .then(this.success())
336
+ .catch(this.error());
337
+ }
338
+ /**
339
+ * Upload test plan XML
340
+ * @param xml Test Plan XML
341
+ * @return Test plan loaded. List of load errors is returned.
342
+ */
343
+ setTestPlanXML(xml) {
344
+ return this.request('SetTestPlanXML', xml).then(this.success()).catch(this.error());
345
+ }
346
+ /**
347
+ * Retrieve loaded test plan XML
348
+ * @return Test plan retrieved
349
+ */
350
+ getTestPlanXML() {
351
+ // Generate a unique subject where the Runner will publish the chunks
352
+ return this.request('GetTestPlanXML').then(this.success()).catch(this.error());
353
+ }
354
+ /**
355
+ * Downloads the resource from the runner and returns it as raw bytes
356
+ * @return Raw bytes representing the resource
357
+ */
358
+ downloadResource(resource) {
359
+ var _a;
360
+ const runnerResourcePrefix = 'subject://';
361
+ if (!((_a = resource.source) === null || _a === void 0 ? void 0 : _a.startsWith(runnerResourcePrefix))) {
362
+ return Promise.reject('The source of the provided resource is not a nats subject.');
363
+ }
364
+ const subject = resource.source.slice(runnerResourcePrefix.length);
365
+ return this.request(subject, undefined, { rawResponse: true, fullSubject: true })
366
+ .then(this.success())
367
+ .catch(this.error());
368
+ }
369
+ /**
370
+ * Load test plan using a test plan TapPackage from a repository
371
+ * @param {RepositoryPackageDefinition} packageReference
372
+ * @return Test plan loaded. List of load errors is returned.
373
+ */
374
+ loadTestPlanFromRepository(packageReference) {
375
+ return this.request('LoadTestPlanFromRepository', packageReference).then(this.success()).catch(this.error());
376
+ }
377
+ /**
378
+ * Save currently loaded test plan to a repository
379
+ * @param {RepositoryPackageDefinition} packageReference
380
+ * @return Test plan uploaded.
381
+ */
382
+ saveTestPlanToRepository(packageReference) {
383
+ return this.request('SaveTestPlanToRepository', packageReference).then(this.success()).catch(this.error());
384
+ }
385
+ /**
386
+ * Test plan resources opened
387
+ * @return Test plan resources opened.
388
+ */
389
+ resourcesOpen() {
390
+ return this.request('ResourcesOpen')
391
+ .then(testPlanJs => TestPlan.fromJS(testPlanJs))
392
+ .then(this.success())
393
+ .catch(this.error());
394
+ }
395
+ /**
396
+ * Test plan resources closed
397
+ * @return Test plan resources closed.
398
+ */
399
+ resourcesClose() {
400
+ return this.request('ResourcesClose')
401
+ .then(testPlanJs => TestPlan.fromJS(testPlanJs))
402
+ .then(this.success())
403
+ .catch(this.error());
404
+ }
405
+ /**
406
+ * Retrieve test plan or test step settings
407
+ * @param {string} contextId
408
+ * @return List of settings retrieved
409
+ */
410
+ getSettings(contextId) {
411
+ return this.request('GetSettings', contextId)
412
+ .then(settingArrayJs => settingArrayJs.map(settingJs => Setting.fromJS(settingJs)))
413
+ .then(this.success())
414
+ .catch(this.error());
415
+ }
416
+ /**
417
+ * Change test plan or test step settings
418
+ * @param {string} contextId
419
+ * @param {Setting[]} settings
420
+ * @return Settings changed
421
+ */
422
+ setSettings(contextId, settings) {
423
+ const setSettingsRequest = { contextId, settings };
424
+ return this.request('SetSettings', setSettingsRequest)
425
+ .then(settingArrayJs => settingArrayJs.map(settingJs => Setting.fromJS(settingJs)))
426
+ .then(this.success())
427
+ .catch(this.error());
428
+ }
429
+ /**
430
+ * Retrieve test plan structure
431
+ * @param {string[] | null | undefined} properties
432
+ * @return Test plan retrieved
433
+ */
434
+ getTestPlan(properties) {
435
+ return this.request('GetTestPlan', properties)
436
+ .then(testPlanJs => TestPlan.fromJS(testPlanJs))
437
+ .then(this.success())
438
+ .catch(this.error());
439
+ }
440
+ /**
441
+ * Change test plan structure
442
+ * @param {TestPlan} plan
443
+ * @return Test plan changed
444
+ */
445
+ setTestPlan(plan) {
446
+ return this.request('SetTestPlan', plan)
447
+ .then(testPlanJs => TestPlan.fromJS(testPlanJs))
448
+ .then(this.success())
449
+ .catch(this.error());
450
+ }
451
+ /**
452
+ * Set the name of the test plan
453
+ * @param {string} testPlanName
454
+ * @return {Promise<void>}
455
+ */
456
+ setTestPlanName(testPlanName) {
457
+ return this.request('SetTestPlanName', testPlanName).then(this.success()).catch(this.error());
458
+ }
459
+ /**
460
+ * Retrieve all validation errors present in the test plan
461
+ * @return Retrieved validation errors for loaded TestPlan
462
+ */
463
+ getValidationErrors() {
464
+ return this.request('GetValidationErrors')
465
+ .then(testStepValidationErrorArrayJs => testStepValidationErrorArrayJs.map(testStepValidationErrorJs => TestStepValidationError.fromJS(testStepValidationErrorJs)))
466
+ .then(this.success())
467
+ .catch(this.error());
468
+ }
469
+ /**
470
+ * Retrieve or change common test step settings
471
+ * @param {CommonSettings} commonSettings
472
+ * @return Common test step settings retrieved or changed
473
+ */
474
+ commonStepSettings(commonSettings) {
475
+ return this.request('CommonStepSettings', commonSettings)
476
+ .then(commonSettingsJs => CommonSettings.fromJS(commonSettingsJs))
477
+ .then(this.success())
478
+ .catch(this.error());
479
+ }
480
+ /**
481
+ * Retrieve or invoke common test step settings context menu items
482
+ * @param {string} propertyName
483
+ * @param {TestPlan} commonContext
484
+ * @return Get context menu (right-click menu) for a property in the testplan or teststep
485
+ */
486
+ commonStepSettingsContextMenu(propertyName, commonContext) {
487
+ const commonStepSettingsContextRequest = { propertyName, commonContext };
488
+ return this.request('CommonStepSettingsContextMenu', commonStepSettingsContextRequest)
489
+ .then(commonContextJs => CommonContext.fromJS(commonContextJs))
490
+ .then(this.success())
491
+ .catch(this.error());
492
+ }
493
+ /**
494
+ * Retrieve all pending user input IDs
495
+ * @return Retrieved pending user inputs
496
+ */
497
+ getUserInputs() {
498
+ return this.request('GetUserInputs').then(this.success()).catch(this.error());
499
+ }
500
+ /**
501
+ * Retrieve pending user input based on ID
502
+ * @param {string} id
503
+ * @return Retrieved pending user input
504
+ */
505
+ getUserInput(id) {
506
+ return this.request('GetUserInput', id)
507
+ .then(interactionJs => Interaction.fromJS(interactionJs))
508
+ .then(this.success())
509
+ .catch(this.error());
510
+ }
511
+ /**
512
+ * Modify or answer pending user input based on ID
513
+ * @param interaction
514
+ * @returns {Promise<Interaction>}
515
+ */
516
+ setUserInput(interaction) {
517
+ return this.request('SetUserInput', interaction)
518
+ .then(interactionJs => Interaction.fromJS(interactionJs))
519
+ .then(this.success())
520
+ .catch(this.error());
521
+ }
522
+ /**
523
+ * Property context menu
524
+ * @param {string} contextId
525
+ * @param {string | null} propertyName
526
+ * @return Get context menu (right-click menu) for a property in the testplan or teststep
527
+ */
528
+ getContextMenu(contextId, propertyName) {
529
+ const propertyReferenceRequest = {
530
+ contextId,
531
+ propertyName,
532
+ };
533
+ return this.request('GetContextMenu', propertyReferenceRequest)
534
+ .then(settingArrayJs => settingArrayJs.map(settingJs => Setting.fromJS(settingJs)))
535
+ .then(this.success())
536
+ .catch(this.error());
537
+ }
538
+ /**
539
+ * Property context menu
540
+ * @param {string} contextId
541
+ * @param {string | null} propertyName
542
+ * @param {Setting[]} contextMenu
543
+ * @return Set context menu (right-click menu) for a property in the testplan or teststep
544
+ */
545
+ setContextMenu(contextId, propertyName, contextMenu) {
546
+ const setContextMenuRequest = {
547
+ contextId,
548
+ propertyName,
549
+ contextMenu,
550
+ };
551
+ return this.request('SetContextMenu', setContextMenuRequest)
552
+ .then(settingArrayJs => settingArrayJs.map(settingJs => Setting.fromJS(settingJs)))
553
+ .then(this.success())
554
+ .catch(this.error());
555
+ }
556
+ /**
557
+ * Get data grid
558
+ * @param {string} contextId
559
+ * @param {string | null} propertyName
560
+ * @return DataGridControl retrieved
561
+ */
562
+ getDataGrid(contextId, propertyName) {
563
+ const propertyReferenceRequest = {
564
+ contextId,
565
+ propertyName,
566
+ };
567
+ return this.request('GetDataGrid', propertyReferenceRequest)
568
+ .then(dataGridControlJs => DataGridControl.fromJS(dataGridControlJs))
569
+ .then(this.success())
570
+ .catch(this.error());
571
+ }
572
+ /**
573
+ * Set data grid
574
+ * @return Set data grid
575
+ */
576
+ setDataGrid(contextId, propertyName, dataGridControl) {
577
+ const setDataGridRequest = { contextId, propertyName, dataGridControl };
578
+ return this.request('SetDataGrid', setDataGridRequest)
579
+ .then(dataGridControlJs => DataGridControl.fromJS(dataGridControlJs))
580
+ .then(this.success())
581
+ .catch(this.error());
582
+ }
583
+ /**
584
+ * Add item type to data grid
585
+ * @param {string} contextId
586
+ * @param {string | null} propertyName
587
+ * @param {string | null} typeName
588
+ * @return DataGridControl retrieved
589
+ */
590
+ addDataGridItemType(contextId, propertyName, typeName) {
591
+ const addDataGridItemTypeRequest = {
592
+ contextId,
593
+ propertyName,
594
+ typeName,
595
+ };
596
+ return this.request('AddDataGridItemType', addDataGridItemTypeRequest)
597
+ .then(dataGridControlJs => DataGridControl.fromJS(dataGridControlJs))
598
+ .then(this.success())
599
+ .catch(this.error());
600
+ }
601
+ /**
602
+ * Add item to data grid
603
+ * @param {string} contextId
604
+ * @param {string | null} propertyName
605
+ * @return DataGridControl retrieved
606
+ */
607
+ addDataGridItem(contextId, propertyName) {
608
+ const propertyReferenceRequest = {
609
+ contextId,
610
+ propertyName,
611
+ };
612
+ return this.request('AddDataGridItem', propertyReferenceRequest)
613
+ .then(dataGridControlJs => DataGridControl.fromJS(dataGridControlJs))
614
+ .then(this.success())
615
+ .catch(this.error());
616
+ }
617
+ /**
618
+ * Get item types available in the data grid
619
+ * @param {string} contextId
620
+ * @param {string | null} propertyName
621
+ * @return List of ListItemType retrieved
622
+ */
623
+ getDataGridTypes(contextId, propertyName) {
624
+ const propertyReferenceRequest = {
625
+ contextId,
626
+ propertyName,
627
+ };
628
+ return this.request('GetDataGridTypes', propertyReferenceRequest)
629
+ .then(listItemTypeArrayJs => listItemTypeArrayJs.map(listItemTypeJs => ListItemType.fromJS(listItemTypeJs)))
630
+ .then(this.success())
631
+ .catch(this.error());
632
+ }
633
+ /**
634
+ * Retrieve static available step type information.
635
+ * @return StepTypes retrieved
636
+ */
637
+ getStepTypes() {
638
+ return this.request('GetStepTypes')
639
+ .then(testStepTypeArrayJs => testStepTypeArrayJs.map(testStepTypeJs => TestStepType.fromJS(testStepTypeJs)))
640
+ .then(this.success())
641
+ .catch(this.error());
642
+ }
643
+ /**
644
+ * Pause test plan execution at next possible test step
645
+ */
646
+ setPauseNext() {
647
+ return this.request('SetPauseNext').then(this.success()).catch(this.error());
648
+ }
649
+ /**
650
+ * Retrieve breakpoints set in test plan
651
+ */
652
+ getBreakpoints() {
653
+ return this.request('GetBreakpoints')
654
+ .then(breakPointsJs => BreakPoints.fromJS(breakPointsJs))
655
+ .then(this.success())
656
+ .catch(this.error());
657
+ }
658
+ /**
659
+ * Set breakpoints in test plan
660
+ * @param {BreakPoints} breakPointsDto
661
+ * @return BreakPoints retrieved
662
+ */
663
+ setBreakpoints(breakPointsDto) {
664
+ return this.request('SetBreakpoints', breakPointsDto)
665
+ .then(breakPointsJs => BreakPoints.fromJS(breakPointsJs))
666
+ .then(this.success())
667
+ .catch(this.error());
668
+ }
669
+ /**
670
+ * Jump test plan execution to step. Execution state must be 'breaking'.
671
+ * @param {string} stepId
672
+ */
673
+ setJumpToStep(stepId) {
674
+ return this.request('SetJumpToStep', stepId).then(this.success()).catch(this.error());
675
+ }
676
+ /**
677
+ * Execute test plan with attaching metadata
678
+ * @param {Parameter[]} parameters
679
+ * @return RunStatus retrieved
680
+ */
681
+ runTestPlan(parameters) {
682
+ return this.request('RunTestPlan', parameters)
683
+ .then(runStatusJs => RunStatus.fromJS(runStatusJs))
684
+ .then(this.success())
685
+ .catch(this.error());
686
+ }
687
+ /**
688
+ * Abort test plan execution
689
+ */
690
+ abortTestPlan() {
691
+ return this.request('AbortTestPlan').then(this.success()).catch(this.error());
692
+ }
693
+ /**
694
+ * Shuts down session
695
+ */
696
+ shutdown() {
697
+ return this.request('Shutdown').then(this.success()).catch(this.error());
698
+ }
699
+ /**
700
+ * Retrieves installed packages in this session
701
+ */
702
+ getImage() {
703
+ return this.request('GetImage')
704
+ .then(imageJs => Image.fromJS(imageJs))
705
+ .then(this.success())
706
+ .catch(this.error());
707
+ }
708
+ /**
709
+ * Retrieves session readiness
710
+ */
711
+ getReadiness() {
712
+ return this.request('GetReadiness').then(this.success()).catch(this.error());
713
+ }
714
+ /**
715
+ * Retrieves watchdog
716
+ */
717
+ getWatchDog() {
718
+ return this.request('GetWatchDog')
719
+ .then(watchDogJs => WatchDog.fromJS(watchDogJs))
720
+ .then(this.success())
721
+ .catch(this.error());
722
+ }
723
+ /**
724
+ * Sets a new watchdog
725
+ * @param {WatchDog} watchDog
726
+ */
727
+ setWatchDog(watchDog) {
728
+ return this.request('SetWatchDog', watchDog)
729
+ .then(watchDogJs => WatchDog.fromJS(watchDogJs))
730
+ .then(this.success())
731
+ .catch(this.error());
732
+ }
733
+ /**
734
+ * Retrieve settings types used in creating a Settings TapPackage
735
+ */
736
+ getSettingsTypes() {
737
+ return this.request('GetSettingsTypes').then(this.success()).catch(this.error());
738
+ }
739
+ }