@opentap/runner-client
Version:
This is the web client for the OpenTAP Runner.
360 lines (359 loc) • 15.1 kB
TypeScript
import { BreakPoints, CommonContext, CommonSettings, DataGridControl, IMetricsConfiguration, Image, Interaction, ListItemType, LogList, MetricsConfiguration, OnTestPlanRun, OnTestStepRun, Parameter, RepositoryPackageDefinition, RepositoryPackageReference, Resource, Result, RunStatus, SessionEvent, Setting, TestPlan, TestRun, TestStepType, TestStepValidationError, WatchDog } from './DTOs';
import { ConnectionOptions, NatsError, Subscription, SubscriptionOptions } from 'nats.ws';
import { BaseClient } from './BaseClient';
export declare class SessionClient extends BaseClient {
private subscriptions;
constructor(baseSubject: string, options: ConnectionOptions);
/**
* @param sessionLogsHandler Function to be called when log list or error is received
* @param options (optional) Subscription options
* @returns Subscription object
*/
connectSessionLogs(sessionLogsHandler: (logList: LogList | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
/**
* @param eventHandler Function to be called when session event or error is received
* @param options (optional) Subscription options
* @returns Subscription object
*/
connectSessionEvents(eventHandler: (sessionEvent: SessionEvent | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): void;
/**
* @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
*/
connectSessionResults(resultHandler: (result: Result | undefined, err: NatsError | Error | null) => void, testRunHandler: (testRun: TestRun | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): [Subscription, Subscription];
/**
* @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
*/
connectTestRunEvents(testRunHandler: (testRun: TestRun | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
/**
* 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
*/
connectTestPlanRunEvents(testPlanRunId: string, handler: (event: OnTestPlanRun | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
/**
* 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
*/
connectTestPlanRunLogs(testPlanRunId: string, handler: (logList: LogList | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
/**
* 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
*/
connectTestPlanRunParameterEvents(testPlanRunId: string, handler: (event: Parameter[] | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
/**
* 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
*/
connectTestStepRunEvents(testPlanRunId: string, testStepRunId: string, handler: (testStepRunId: string | undefined, testRun: OnTestStepRun | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
/**
* 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
*/
connectTestStepRunParameterEvents(testPlanRunId: string, testStepRunId: string, handler: (event: Parameter[] | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
/**
* 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
*/
connectTestStepRunResults(testPlanRunId: string, testStepRunId: string, resultName: string, handler: (result: Result | undefined, err: NatsError | Error | null) => void, options?: SubscriptionOptions): Subscription;
/**
* Unsubscibe from session events
*/
unsubscribeSessionEvents(): void;
/**
* 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.
*/
getSessionLogs(id?: string, levels?: number[], excludedSources?: string[], filterText?: string, offset?: number, limit?: number): Promise<LogList>;
/**
* Retrieve session log indexes
* @param id (optional)
* @param level (optional)
* @param excludedSource (optional)
* @param filterText (optional)
* @param searchText (optional)
* @return Logs indexes retrieved
*/
sessionLogSearch(id: string | undefined, levels: number[] | null | undefined, excludedSources: string[] | null | undefined, filterText: string | null | undefined, searchText: string | null | undefined): Promise<number[]>;
/**
* Retrieve log sources
* @param id (optional)
* @return Logs indexes retrieved
*/
sessionLogSources(id: string | undefined): Promise<string[]>;
/**
* Retrieve session log counts
* @param id (optional)
* @return Logs indexes retrieved
*/
sessionLogCounts(id: string | undefined): Promise<{
[key: string]: number;
}>;
/**
* Retrieve log severities
* @return Log levels retrieved
*/
logLevels(): Promise<{
[key: string]: string;
}>;
/**
* Get status, with an optional testplan execution completion timeout
* @param {number | null | undefined} timeout (optional)
* @return RunStatus retrieved
*/
getStatus(timeout: number | null | undefined): Promise<RunStatus>;
/**
* Upload test plan XML
* @param xml Test Plan XML
* @return Test plan loaded. List of load errors is returned.
*/
setTestPlanXML(xml: string): Promise<string[]>;
/**
* Retrieve loaded test plan XML
* @return Test plan retrieved
*/
getTestPlanXML(): Promise<string>;
/**
* Downloads the resource from the runner and returns it as raw bytes
* @return Raw bytes representing the resource
*/
downloadResource(resource: Resource): Promise<Uint8Array>;
/**
* Load test plan using a test plan TapPackage from a repository
* @param {RepositoryPackageDefinition} packageReference
* @return Test plan loaded. List of load errors is returned.
*/
loadTestPlanFromRepository(packageReference: RepositoryPackageReference): Promise<string[]>;
/**
* Save currently loaded test plan to a repository
* @param {RepositoryPackageDefinition} packageReference
* @return Test plan uploaded.
*/
saveTestPlanToRepository(packageReference: RepositoryPackageDefinition): Promise<void>;
/**
* Test plan resources opened
* @return Test plan resources opened.
*/
resourcesOpen(): Promise<TestPlan>;
/**
* Test plan resources closed
* @return Test plan resources closed.
*/
resourcesClose(): Promise<TestPlan>;
/**
* Retrieve test plan or test step settings
* @param {string} contextId
* @return List of settings retrieved
*/
getSettings(contextId: string): Promise<Setting[]>;
/**
* Change test plan or test step settings
* @param {string} contextId
* @param {Setting[]} settings
* @return Settings changed
*/
setSettings(contextId: string, settings: Setting[]): Promise<Setting[]>;
/**
* Retrieve test plan structure
* @param {string[] | null | undefined} properties
* @return Test plan retrieved
*/
getTestPlan(properties: string[] | null | undefined): Promise<TestPlan>;
/**
* Change test plan structure
* @param {TestPlan} plan
* @return Test plan changed
*/
setTestPlan(plan: TestPlan): Promise<TestPlan>;
/**
* Set the name of the test plan
* @param {string} testPlanName
* @return {Promise<void>}
*/
setTestPlanName(testPlanName: string): Promise<void>;
/**
* Retrieve all validation errors present in the test plan
* @return Retrieved validation errors for loaded TestPlan
*/
getValidationErrors(): Promise<TestStepValidationError[]>;
/**
* Retrieve or change common test step settings
* @param {CommonSettings} commonSettings
* @return Common test step settings retrieved or changed
*/
commonStepSettings(commonSettings: CommonSettings): Promise<CommonSettings>;
/**
* 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
*/
commonStepSettingsContextMenu(propertyName: string | null, commonContext: CommonContext): Promise<CommonContext>;
/**
* Retrieve all pending user input IDs
* @return Retrieved pending user inputs
*/
getUserInputs(): Promise<string[]>;
/**
* Retrieve pending user input based on ID
* @param {string} id
* @return Retrieved pending user input
*/
getUserInput(id: string): Promise<Interaction>;
/**
* Modify or answer pending user input based on ID
* @param interaction
* @returns {Promise<Interaction>}
*/
setUserInput(interaction: Interaction): Promise<Interaction>;
/**
* 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
*/
getContextMenu(contextId: string, propertyName: string | null): Promise<Setting[]>;
/**
* 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
*/
setContextMenu(contextId: string, propertyName: string | null, contextMenu: Setting[]): Promise<Setting[]>;
/**
* Get data grid
* @param {string} contextId
* @param {string | null} propertyName
* @return DataGridControl retrieved
*/
getDataGrid(contextId: string, propertyName: string | null): Promise<DataGridControl>;
/**
* Set data grid
* @return Set data grid
*/
setDataGrid(contextId: string, propertyName: string, dataGridControl: DataGridControl): Promise<DataGridControl>;
/**
* Add item type to data grid
* @param {string} contextId
* @param {string | null} propertyName
* @param {string | null} typeName
* @return DataGridControl retrieved
*/
addDataGridItemType(contextId: string, propertyName: string | null, typeName: string | null): Promise<DataGridControl>;
/**
* Add item to data grid
* @param {string} contextId
* @param {string | null} propertyName
* @return DataGridControl retrieved
*/
addDataGridItem(contextId: string, propertyName: string | null): Promise<DataGridControl>;
/**
* Get item types available in the data grid
* @param {string} contextId
* @param {string | null} propertyName
* @return List of ListItemType retrieved
*/
getDataGridTypes(contextId: string, propertyName: string | null): Promise<ListItemType[]>;
/**
* Retrieve static available step type information.
* @return StepTypes retrieved
*/
getStepTypes(): Promise<TestStepType[]>;
/**
* Pause test plan execution at next possible test step
*/
setPauseNext(): Promise<void>;
/**
* Retrieve breakpoints set in test plan
*/
getBreakpoints(): Promise<BreakPoints>;
/**
* Set breakpoints in test plan
* @param {BreakPoints} breakPointsDto
* @return BreakPoints retrieved
*/
setBreakpoints(breakPointsDto: BreakPoints): Promise<BreakPoints>;
/**
* Jump test plan execution to step. Execution state must be 'breaking'.
* @param {string} stepId
*/
setJumpToStep(stepId: string): Promise<void>;
/**
* Execute test plan with attaching metadata
* @param {Parameter[]} parameters
* @return RunStatus retrieved
*/
runTestPlan(parameters: Parameter[]): Promise<RunStatus>;
/**
* Abort test plan execution
*/
abortTestPlan(): Promise<void>;
/**
* Shuts down session
*/
shutdown(): Promise<void>;
/**
* Retrieves installed packages in this session
*/
getImage(): Promise<Image>;
/**
* Retrieves session readiness
*/
getReadiness(): Promise<void>;
/**
* Retrieves watchdog
*/
getWatchDog(): Promise<WatchDog>;
/**
* Sets a new watchdog
* @param {WatchDog} watchDog
*/
setWatchDog(watchDog: WatchDog): Promise<WatchDog>;
/**
* Retrieve settings types used in creating a Settings TapPackage
*/
getSettingsTypes(): Promise<string[]>;
/**
* Get the metric information
* @returns Promise
*/
getMetricsConfiguration(): Promise<MetricsConfiguration>;
/**
* Set the metric information. Used for setting up which metrics should be published for polling.
* @param {IMetricsConfiguration} metricsRequest
* @returns Promise
*/
setMetricsConfiguration(metricsRequest: IMetricsConfiguration): Promise<void>;
}