@opentap/runner-client
Version:
This is the web client for the OpenTAP Runner.
793 lines (792 loc) • 35.2 kB
JavaScript
"use strict";
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.SessionClient = void 0;
var DTOs_1 = require("./DTOs");
var nats_ws_1 = require("nats.ws");
var BaseClient_1 = require("./BaseClient");
var SessionClient = /** @class */ (function (_super) {
__extends(SessionClient, _super);
function SessionClient(baseSubject, options) {
var _this = _super.call(this, baseSubject, options) || this;
_this.subscriptions = [];
return _this;
}
/**
* @param sessionLogsHandler Function to be called when log list or error is received
* @param options (optional) Subscription options
* @returns Subscription object
*/
SessionClient.prototype.connectSessionLogs = function (sessionLogsHandler, options) {
return this.subscribe('SessionLogs', __assign(__assign({}, options), { callback: function (error, encodedMessage) {
if (error) {
sessionLogsHandler(undefined, error);
return;
}
try {
var jsonCodec = (0, nats_ws_1.JSONCodec)();
var logListJson = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
var logList = DTOs_1.LogList.fromJS(logListJson);
sessionLogsHandler(logList, error);
}
catch (error) {
sessionLogsHandler(undefined, error);
}
} }));
};
/**
* @param eventHandler Function to be called when session event or error is received
* @param options (optional) Subscription options
* @returns Subscription object
*/
SessionClient.prototype.connectSessionEvents = function (eventHandler, options) {
var callback = function (error, encodedMessage) {
if (error) {
eventHandler(undefined, error);
return;
}
try {
var jsonCodec = (0, nats_ws_1.JSONCodec)();
var sessionEventJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
var sessionEvent = DTOs_1.SessionEvent.fromJS(sessionEventJs);
eventHandler(sessionEvent, error);
}
catch (error) {
eventHandler(undefined, error);
}
};
this.subscriptions.push(this.subscribe('Events', __assign(__assign({}, options), { callback: callback })));
this.subscriptions.push(this.subscribe('Events.*', __assign(__assign({}, options), { callback: callback })));
};
/**
* @param resultHandler Function to be called when result or error is received
* @param testRunHandler Function to be called when test run or error is received
* @param options (optional) Subscription options
* @returns Subscription array: Result and Test Run subscriptions
*/
SessionClient.prototype.connectSessionResults = function (resultHandler, testRunHandler, options) {
return [
this.subscribe('OnResult', __assign(__assign({}, options), { callback: function (error, encodedMessage) {
if (error) {
resultHandler(undefined, error);
return;
}
try {
var jsonCodec = (0, nats_ws_1.JSONCodec)();
var resultJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
var result = DTOs_1.Result.fromJS(resultJs);
resultHandler(result, error);
}
catch (error) {
resultHandler(undefined, error);
}
} })),
this.subscribe('OnTestRun', __assign(__assign({}, options), { callback: function (error, encodedMessage) {
if (error) {
testRunHandler(undefined, error);
return;
}
try {
var jsonCodec = (0, nats_ws_1.JSONCodec)();
var testRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
var testRun = DTOs_1.TestRun.fromJS(testRunJs);
testRunHandler(testRun, error);
}
catch (error) {
testRunHandler(undefined, error);
}
} })),
];
};
/**
* @param testRunHandler Function to be called when test run or error is received
* @param options (optional) Subscription options
* @returns Subscription array: Result and Test Run subscriptions
*/
SessionClient.prototype.connectTestRunEvents = function (testRunHandler, options) {
return this.subscribe('OnTestRun', __assign(__assign({}, options), { callback: function (error, encodedMessage) {
if (error) {
testRunHandler(undefined, error);
return;
}
try {
var jsonCodec = (0, nats_ws_1.JSONCodec)();
var testRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
var testRun = DTOs_1.TestRun.fromJS(testRunJs);
testRunHandler(testRun, error);
}
catch (error) {
testRunHandler(undefined, error);
}
} }));
};
/**
* Connect to listen to the TestPlanRun events for the given test plan run ID.
* @param {string} testPlanRunId
* @param {(event:OnTestPlanRun|undefined,err:NatsError|Error|null)=>void} handler
* @param {SubscriptionOptions} options?
* @returns Subscription
*/
SessionClient.prototype.connectTestPlanRunEvents = function (testPlanRunId, handler, options) {
return this.subscribe("PlanRun.".concat(testPlanRunId), __assign(__assign({}, options), { callback: function (error, encodedMessage) {
if (error) {
handler(undefined, error);
return;
}
try {
var jsonCodec = (0, nats_ws_1.JSONCodec)();
var onTestPlanRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
var onTestPlanRun = DTOs_1.OnTestPlanRun.fromJS(onTestPlanRunJs);
handler(onTestPlanRun, error);
}
catch (error) {
handler(undefined, error);
}
} }));
};
/**
* Connect to listen to the test plan run logs for the given test plan run ID
* @param {string} testPlanRunId
* @param {(logList:LogList|undefined,err:NatsError|Error|null)=>void} handler
* @param {SubscriptionOptions} options?
* @returns Subscription
*/
SessionClient.prototype.connectTestPlanRunLogs = function (testPlanRunId, handler, options) {
return this.subscribe("PlanRun.".concat(testPlanRunId, ".Logs"), __assign(__assign({}, options), { callback: function (error, encodedMessage) {
if (error) {
handler(undefined, error);
return;
}
try {
var jsonCodec = (0, nats_ws_1.JSONCodec)();
var logListJson = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
var logList = DTOs_1.LogList.fromJS(logListJson);
handler(logList, error);
}
catch (error) {
handler(undefined, error);
}
} }));
};
/**
* Connect to listen to the test plan run parameter events for the given test plan run ID
* @param {string} testPlanRunId
* @param {(event:Parameter[]|undefined,err:NatsError|Error|null)=>void} handler
* @param {SubscriptionOptions} options?
* @returns Subscription
*/
SessionClient.prototype.connectTestPlanRunParameterEvents = function (testPlanRunId, handler, options) {
return this.subscribe("PlanRun.".concat(testPlanRunId, ".Parameters"), __assign(__assign({}, options), { callback: function (error, encodedMessage) {
if (error) {
handler(undefined, error);
return;
}
try {
var jsonCodec = (0, nats_ws_1.JSONCodec)();
var parameterListJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
var parameterList = parameterListJs.map(function (parameterJs) { return DTOs_1.Parameter.fromJS(parameterJs); });
handler(parameterList, error);
}
catch (error) {
handler(undefined, error);
}
} }));
};
/**
* Connect to listen to the test step run events for the given test step and test plan run ID
* @param {string} testPlanRunId
* @param {string} testStepRunId
* @param {(testRun:OnTestStepRun|undefined,err:NatsError|Error|null)=>void} handler
* @param {SubscriptionOptions} options?
* @returns Subscription
*/
SessionClient.prototype.connectTestStepRunEvents = function (testPlanRunId, testStepRunId, handler, options) {
return this.subscribe("PlanRun.".concat(testPlanRunId, ".StepRun.").concat(testStepRunId), __assign(__assign({}, options), { callback: function (error, encodedMessage) {
var _a;
if (error) {
handler(undefined, undefined, error);
return;
}
try {
var jsonCodec = (0, nats_ws_1.JSONCodec)();
var onTestStepRunJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
var onTestStepRun = DTOs_1.OnTestStepRun.fromJS(onTestStepRunJs);
var stepRunId = (_a = encodedMessage.subject.match(/\.StepRun\.(.+)$/)) === null || _a === void 0 ? void 0 : _a[1];
handler(stepRunId, onTestStepRun, error);
}
catch (error) {
handler(undefined, undefined, error);
}
} }));
};
/**
* Connect to listen to the test step run parameters for the given test step and test plan run ID
* @param {string} testPlanRunId
* @param {string} testStepRunId
* @param {(event:Parameter[]|undefined,err:NatsError|Error|null)=>void} handler
* @param {SubscriptionOptions} options?
* @returns Subscription
*/
SessionClient.prototype.connectTestStepRunParameterEvents = function (testPlanRunId, testStepRunId, handler, options) {
return this.subscribe("PlanRun.".concat(testPlanRunId, ".StepRun.").concat(testStepRunId, ".Parameters"), __assign(__assign({}, options), { callback: function (error, encodedMessage) {
if (error) {
handler(undefined, error);
return;
}
try {
var jsonCodec = (0, nats_ws_1.JSONCodec)();
var parameterListJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
var parameterList = parameterListJs.map(function (parameterJs) { return DTOs_1.Parameter.fromJS(parameterJs); });
handler(parameterList, error);
}
catch (error) {
handler(undefined, error);
}
} }));
};
/**
* Connect to listen to the test step run results for the given test step and test plan run ID
* @param {string} testPlanRunId
* @param {string} testStepRunId
* @param {string} resultName
* @param {(result:Result|undefined,err:NatsError|Error|null)=>void} handler
* @param {SubscriptionOptions} options?
* @returns Subscription
*/
SessionClient.prototype.connectTestStepRunResults = function (testPlanRunId, testStepRunId, resultName, handler, options) {
return this.subscribe("PlanRun.".concat(testPlanRunId, ".StepRun.").concat(testStepRunId, ".Result.").concat(resultName), __assign(__assign({}, options), { callback: function (error, encodedMessage) {
if (error) {
handler(undefined, error);
return;
}
try {
var jsonCodec = (0, nats_ws_1.JSONCodec)();
var resultJs = jsonCodec.decode(encodedMessage === null || encodedMessage === void 0 ? void 0 : encodedMessage.data);
var result = DTOs_1.Result.fromJS(resultJs);
handler(result, error);
}
catch (error) {
handler(undefined, error);
}
} }));
};
/**
* Unsubscibe from session events
*/
SessionClient.prototype.unsubscribeSessionEvents = function () {
var _a;
(_a = this.subscriptions) === null || _a === void 0 ? void 0 : _a.forEach(function (subscription) { return subscription.unsubscribe(); });
};
/**
* Retrieve session logs
* @param id (optional)
* @param level (optional)
* @param excludedSource (optional)
* @param filterText (optional)
* @param offset (optional)
* @param limit (optional)
* @return Successfully retrieved OpenTAP log messages.
*/
SessionClient.prototype.getSessionLogs = function (id, levels, excludedSources, filterText, offset, limit) {
var getSessionLogsRequest = { id: id, levels: levels, excludedSources: excludedSources, filterText: filterText, offset: offset, limit: limit };
return this.request('GetSessionLogs', getSessionLogsRequest)
.then(function (logListJs) { return DTOs_1.LogList.fromJS(logListJs); })
.then(this.success())
.catch(this.error());
};
/**
* Retrieve session log indexes
* @param id (optional)
* @param level (optional)
* @param excludedSource (optional)
* @param filterText (optional)
* @param searchText (optional)
* @return Logs indexes retrieved
*/
SessionClient.prototype.sessionLogSearch = function (id, levels, excludedSources, filterText, searchText) {
var getSessionSearchRequest = { id: id, levels: levels, excludedSources: excludedSources, filterText: filterText, searchText: searchText };
return this.request('SessionLogSearch', getSessionSearchRequest).then(this.success()).catch(this.error());
};
/**
* Retrieve log sources
* @param id (optional)
* @return Logs indexes retrieved
*/
SessionClient.prototype.sessionLogSources = function (id) {
return this.request('SessionLogSources', id).then(this.success()).catch(this.error());
};
/**
* Retrieve session log counts
* @param id (optional)
* @return Logs indexes retrieved
*/
SessionClient.prototype.sessionLogCounts = function (id) {
return this.request('SessionLogCounts', id).then(this.success()).catch(this.error());
};
/**
* Retrieve log severities
* @return Log levels retrieved
*/
SessionClient.prototype.logLevels = function () {
return this.request('LogLevels').then(this.success()).catch(this.error());
};
/**
* Get status, with an optional testplan execution completion timeout
* @param {number | null | undefined} timeout (optional)
* @return RunStatus retrieved
*/
SessionClient.prototype.getStatus = function (timeout) {
return this.request('GetStatus', timeout)
.then(function (runStatusJs) { return DTOs_1.RunStatus.fromJS(runStatusJs); })
.then(this.success())
.catch(this.error());
};
/**
* Upload test plan XML
* @param xml Test Plan XML
* @return Test plan loaded. List of load errors is returned.
*/
SessionClient.prototype.setTestPlanXML = function (xml) {
return this.request('SetTestPlanXML', xml).then(this.success()).catch(this.error());
};
/**
* Retrieve loaded test plan XML
* @return Test plan retrieved
*/
SessionClient.prototype.getTestPlanXML = function () {
// Generate a unique subject where the Runner will publish the chunks
return this.request('GetTestPlanXML').then(this.success()).catch(this.error());
};
/**
* Downloads the resource from the runner and returns it as raw bytes
* @return Raw bytes representing the resource
*/
SessionClient.prototype.downloadResource = function (resource) {
var _a;
var runnerResourcePrefix = 'subject://';
if (!((_a = resource.source) === null || _a === void 0 ? void 0 : _a.startsWith(runnerResourcePrefix))) {
return Promise.reject('The source of the provided resource is not a nats subject.');
}
var subject = resource.source.slice(runnerResourcePrefix.length);
return this.request(subject, undefined, { rawResponse: true, fullSubject: true })
.then(this.success())
.catch(this.error());
};
/**
* Load test plan using a test plan TapPackage from a repository
* @param {RepositoryPackageDefinition} packageReference
* @return Test plan loaded. List of load errors is returned.
*/
SessionClient.prototype.loadTestPlanFromRepository = function (packageReference) {
return this.request('LoadTestPlanFromRepository', packageReference).then(this.success()).catch(this.error());
};
/**
* Save currently loaded test plan to a repository
* @param {RepositoryPackageDefinition} packageReference
* @return Test plan uploaded.
*/
SessionClient.prototype.saveTestPlanToRepository = function (packageReference) {
return this.request('SaveTestPlanToRepository', packageReference).then(this.success()).catch(this.error());
};
/**
* Test plan resources opened
* @return Test plan resources opened.
*/
SessionClient.prototype.resourcesOpen = function () {
return this.request('ResourcesOpen')
.then(function (testPlanJs) { return DTOs_1.TestPlan.fromJS(testPlanJs); })
.then(this.success())
.catch(this.error());
};
/**
* Test plan resources closed
* @return Test plan resources closed.
*/
SessionClient.prototype.resourcesClose = function () {
return this.request('ResourcesClose')
.then(function (testPlanJs) { return DTOs_1.TestPlan.fromJS(testPlanJs); })
.then(this.success())
.catch(this.error());
};
/**
* Retrieve test plan or test step settings
* @param {string} contextId
* @return List of settings retrieved
*/
SessionClient.prototype.getSettings = function (contextId) {
return this.request('GetSettings', contextId)
.then(function (settingArrayJs) { return settingArrayJs.map(function (settingJs) { return DTOs_1.Setting.fromJS(settingJs); }); })
.then(this.success())
.catch(this.error());
};
/**
* Change test plan or test step settings
* @param {string} contextId
* @param {Setting[]} settings
* @return Settings changed
*/
SessionClient.prototype.setSettings = function (contextId, settings) {
var setSettingsRequest = { contextId: contextId, settings: settings };
return this.request('SetSettings', setSettingsRequest)
.then(function (settingArrayJs) { return settingArrayJs.map(function (settingJs) { return DTOs_1.Setting.fromJS(settingJs); }); })
.then(this.success())
.catch(this.error());
};
/**
* Retrieve test plan structure
* @param {string[] | null | undefined} properties
* @return Test plan retrieved
*/
SessionClient.prototype.getTestPlan = function (properties) {
return this.request('GetTestPlan', properties)
.then(function (testPlanJs) { return DTOs_1.TestPlan.fromJS(testPlanJs); })
.then(this.success())
.catch(this.error());
};
/**
* Change test plan structure
* @param {TestPlan} plan
* @return Test plan changed
*/
SessionClient.prototype.setTestPlan = function (plan) {
return this.request('SetTestPlan', plan)
.then(function (testPlanJs) { return DTOs_1.TestPlan.fromJS(testPlanJs); })
.then(this.success())
.catch(this.error());
};
/**
* Set the name of the test plan
* @param {string} testPlanName
* @return {Promise<void>}
*/
SessionClient.prototype.setTestPlanName = function (testPlanName) {
return this.request('SetTestPlanName', testPlanName).then(this.success()).catch(this.error());
};
/**
* Retrieve all validation errors present in the test plan
* @return Retrieved validation errors for loaded TestPlan
*/
SessionClient.prototype.getValidationErrors = function () {
return this.request('GetValidationErrors')
.then(function (testStepValidationErrorArrayJs) {
return testStepValidationErrorArrayJs.map(function (testStepValidationErrorJs) { return DTOs_1.TestStepValidationError.fromJS(testStepValidationErrorJs); });
})
.then(this.success())
.catch(this.error());
};
/**
* Retrieve or change common test step settings
* @param {CommonSettings} commonSettings
* @return Common test step settings retrieved or changed
*/
SessionClient.prototype.commonStepSettings = function (commonSettings) {
return this.request('CommonStepSettings', commonSettings)
.then(function (commonSettingsJs) { return DTOs_1.CommonSettings.fromJS(commonSettingsJs); })
.then(this.success())
.catch(this.error());
};
/**
* Retrieve or invoke common test step settings context menu items
* @param {string} propertyName
* @param {TestPlan} commonContext
* @return Get context menu (right-click menu) for a property in the testplan or teststep
*/
SessionClient.prototype.commonStepSettingsContextMenu = function (propertyName, commonContext) {
var commonStepSettingsContextRequest = { propertyName: propertyName, commonContext: commonContext };
return this.request('CommonStepSettingsContextMenu', commonStepSettingsContextRequest)
.then(function (commonContextJs) { return DTOs_1.CommonContext.fromJS(commonContextJs); })
.then(this.success())
.catch(this.error());
};
/**
* Retrieve all pending user input IDs
* @return Retrieved pending user inputs
*/
SessionClient.prototype.getUserInputs = function () {
return this.request('GetUserInputs').then(this.success()).catch(this.error());
};
/**
* Retrieve pending user input based on ID
* @param {string} id
* @return Retrieved pending user input
*/
SessionClient.prototype.getUserInput = function (id) {
return this.request('GetUserInput', id)
.then(function (interactionJs) { return DTOs_1.Interaction.fromJS(interactionJs); })
.then(this.success())
.catch(this.error());
};
/**
* Modify or answer pending user input based on ID
* @param interaction
* @returns {Promise<Interaction>}
*/
SessionClient.prototype.setUserInput = function (interaction) {
return this.request('SetUserInput', interaction)
.then(function (interactionJs) { return DTOs_1.Interaction.fromJS(interactionJs); })
.then(this.success())
.catch(this.error());
};
/**
* Property context menu
* @param {string} contextId
* @param {string | null} propertyName
* @return Get context menu (right-click menu) for a property in the testplan or teststep
*/
SessionClient.prototype.getContextMenu = function (contextId, propertyName) {
var propertyReferenceRequest = {
contextId: contextId,
propertyName: propertyName,
};
return this.request('GetContextMenu', propertyReferenceRequest)
.then(function (settingArrayJs) { return settingArrayJs.map(function (settingJs) { return DTOs_1.Setting.fromJS(settingJs); }); })
.then(this.success())
.catch(this.error());
};
/**
* Property context menu
* @param {string} contextId
* @param {string | null} propertyName
* @param {Setting[]} contextMenu
* @return Set context menu (right-click menu) for a property in the testplan or teststep
*/
SessionClient.prototype.setContextMenu = function (contextId, propertyName, contextMenu) {
var setContextMenuRequest = {
contextId: contextId,
propertyName: propertyName,
contextMenu: contextMenu,
};
return this.request('SetContextMenu', setContextMenuRequest)
.then(function (settingArrayJs) { return settingArrayJs.map(function (settingJs) { return DTOs_1.Setting.fromJS(settingJs); }); })
.then(this.success())
.catch(this.error());
};
/**
* Get data grid
* @param {string} contextId
* @param {string | null} propertyName
* @return DataGridControl retrieved
*/
SessionClient.prototype.getDataGrid = function (contextId, propertyName) {
var propertyReferenceRequest = {
contextId: contextId,
propertyName: propertyName,
};
return this.request('GetDataGrid', propertyReferenceRequest)
.then(function (dataGridControlJs) { return DTOs_1.DataGridControl.fromJS(dataGridControlJs); })
.then(this.success())
.catch(this.error());
};
/**
* Set data grid
* @return Set data grid
*/
SessionClient.prototype.setDataGrid = function (contextId, propertyName, dataGridControl) {
var setDataGridRequest = { contextId: contextId, propertyName: propertyName, dataGridControl: dataGridControl };
return this.request('SetDataGrid', setDataGridRequest)
.then(function (dataGridControlJs) { return DTOs_1.DataGridControl.fromJS(dataGridControlJs); })
.then(this.success())
.catch(this.error());
};
/**
* Add item type to data grid
* @param {string} contextId
* @param {string | null} propertyName
* @param {string | null} typeName
* @return DataGridControl retrieved
*/
SessionClient.prototype.addDataGridItemType = function (contextId, propertyName, typeName) {
var addDataGridItemTypeRequest = {
contextId: contextId,
propertyName: propertyName,
typeName: typeName,
};
return this.request('AddDataGridItemType', addDataGridItemTypeRequest)
.then(function (dataGridControlJs) { return DTOs_1.DataGridControl.fromJS(dataGridControlJs); })
.then(this.success())
.catch(this.error());
};
/**
* Add item to data grid
* @param {string} contextId
* @param {string | null} propertyName
* @return DataGridControl retrieved
*/
SessionClient.prototype.addDataGridItem = function (contextId, propertyName) {
var propertyReferenceRequest = {
contextId: contextId,
propertyName: propertyName,
};
return this.request('AddDataGridItem', propertyReferenceRequest)
.then(function (dataGridControlJs) { return DTOs_1.DataGridControl.fromJS(dataGridControlJs); })
.then(this.success())
.catch(this.error());
};
/**
* Get item types available in the data grid
* @param {string} contextId
* @param {string | null} propertyName
* @return List of ListItemType retrieved
*/
SessionClient.prototype.getDataGridTypes = function (contextId, propertyName) {
var propertyReferenceRequest = {
contextId: contextId,
propertyName: propertyName,
};
return this.request('GetDataGridTypes', propertyReferenceRequest)
.then(function (listItemTypeArrayJs) { return listItemTypeArrayJs.map(function (listItemTypeJs) { return DTOs_1.ListItemType.fromJS(listItemTypeJs); }); })
.then(this.success())
.catch(this.error());
};
/**
* Retrieve static available step type information.
* @return StepTypes retrieved
*/
SessionClient.prototype.getStepTypes = function () {
return this.request('GetStepTypes')
.then(function (testStepTypeArrayJs) { return testStepTypeArrayJs.map(function (testStepTypeJs) { return DTOs_1.TestStepType.fromJS(testStepTypeJs); }); })
.then(this.success())
.catch(this.error());
};
/**
* Pause test plan execution at next possible test step
*/
SessionClient.prototype.setPauseNext = function () {
return this.request('SetPauseNext').then(this.success()).catch(this.error());
};
/**
* Retrieve breakpoints set in test plan
*/
SessionClient.prototype.getBreakpoints = function () {
return this.request('GetBreakpoints')
.then(function (breakPointsJs) { return DTOs_1.BreakPoints.fromJS(breakPointsJs); })
.then(this.success())
.catch(this.error());
};
/**
* Set breakpoints in test plan
* @param {BreakPoints} breakPointsDto
* @return BreakPoints retrieved
*/
SessionClient.prototype.setBreakpoints = function (breakPointsDto) {
return this.request('SetBreakpoints', breakPointsDto)
.then(function (breakPointsJs) { return DTOs_1.BreakPoints.fromJS(breakPointsJs); })
.then(this.success())
.catch(this.error());
};
/**
* Jump test plan execution to step. Execution state must be 'breaking'.
* @param {string} stepId
*/
SessionClient.prototype.setJumpToStep = function (stepId) {
return this.request('SetJumpToStep', stepId).then(this.success()).catch(this.error());
};
/**
* Execute test plan with attaching metadata
* @param {Parameter[]} parameters
* @return RunStatus retrieved
*/
SessionClient.prototype.runTestPlan = function (parameters) {
return this.request('RunTestPlan', parameters)
.then(function (runStatusJs) { return DTOs_1.RunStatus.fromJS(runStatusJs); })
.then(this.success())
.catch(this.error());
};
/**
* Abort test plan execution
*/
SessionClient.prototype.abortTestPlan = function () {
return this.request('AbortTestPlan').then(this.success()).catch(this.error());
};
/**
* Shuts down session
*/
SessionClient.prototype.shutdown = function () {
return this.request('Shutdown').then(this.success()).catch(this.error());
};
/**
* Retrieves installed packages in this session
*/
SessionClient.prototype.getImage = function () {
return this.request('GetImage')
.then(function (imageJs) { return DTOs_1.Image.fromJS(imageJs); })
.then(this.success())
.catch(this.error());
};
/**
* Retrieves session readiness
*/
SessionClient.prototype.getReadiness = function () {
return this.request('GetReadiness').then(this.success()).catch(this.error());
};
/**
* Retrieves watchdog
*/
SessionClient.prototype.getWatchDog = function () {
return this.request('GetWatchDog')
.then(function (watchDogJs) { return DTOs_1.WatchDog.fromJS(watchDogJs); })
.then(this.success())
.catch(this.error());
};
/**
* Sets a new watchdog
* @param {WatchDog} watchDog
*/
SessionClient.prototype.setWatchDog = function (watchDog) {
return this.request('SetWatchDog', watchDog)
.then(function (watchDogJs) { return DTOs_1.WatchDog.fromJS(watchDogJs); })
.then(this.success())
.catch(this.error());
};
/**
* Retrieve settings types used in creating a Settings TapPackage
*/
SessionClient.prototype.getSettingsTypes = function () {
return this.request('GetSettingsTypes').then(this.success()).catch(this.error());
};
/**
* Get the metric information
* @returns Promise
*/
SessionClient.prototype.getMetricsConfiguration = function () {
return this.request('GetMetricsConfiguration')
.then(function (metricsRequestJs) { return DTOs_1.MetricsConfiguration.fromJS(metricsRequestJs); })
.then(this.success())
.catch(this.error());
};
/**
* Set the metric information. Used for setting up which metrics should be published for polling.
* @param {IMetricsConfiguration} metricsRequest
* @returns Promise
*/
SessionClient.prototype.setMetricsConfiguration = function (metricsRequest) {
return this.request('SetMetricsConfiguration', metricsRequest).then(this.success()).catch(this.error());
};
return SessionClient;
}(BaseClient_1.BaseClient));
exports.SessionClient = SessionClient;