UNPKG

@opentap/runner-client

Version:

This is the web client for the OpenTAP Runner.

395 lines (394 loc) 15.7 kB
import { BreakPoints, CommonContext, CommonSettings, DataGridControl, GetTestPlanReferenceResponse, IMetricsConfiguration, Image, Interaction, ListItemType, LogList, MetricsConfiguration, OnTestPlanRun, OnTestStepRun, Parameter, RepositoryPackageDefinition, RepositoryPackageReference, Resource, Result, RunStatus, SaveTestPlanToRepositoryResponse, SessionEvent, SessionEventName, Setting, TestPlan, TestStepType, TestStepValidationError, WatchDog, EditStatus } from './DTOs'; import { ConnectionOptions, NatsError, Subscription, SubscriptionOptions } from 'nats.ws'; import { BaseClient } from './BaseClient'; export declare class SessionClient extends BaseClient { private _sessionId; private static readonly sessionEventFactories; get sessionId(): string | undefined; constructor(baseSubject: string, options: ConnectionOptions); /** * Extracts the sessionId from the subject. * @param subject //OpenTap.Runner.<runnerId>.Session.<sessionId> * @returns sessionId or undefined if not found */ private getSessionIdFromSubject; /** * @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; /** * Connect to a specific session event * @param eventName The name of the session event to connect to * @param eventHandler Function to be called when session event or error is received * @param options (optional) Subscription options * @returns Subscription object */ connectSessionEvent(eventName: SessionEventName, eventHandler: (sessionEvent: SessionEvent | 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): 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: (planRunId: string | undefined, 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 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: (planRunId: string | undefined, stepRunId: string | undefined, testRun: OnTestStepRun | 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; /** * 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>; /** * Get edit status that contains undo/redo buffer count and testplan dirty status * @returns EditStatus retrieved */ getEditStatus(): Promise<EditStatus>; /** * 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>; /** * Moves the test steps as children of target step * @param TargetStepId target test step id * @param StepIds test steps ids to move */ moveStepsAsChildren(targetStepId: string, StepIds: string[]): void; /** * Moves the test steps as sibling of target step * @param TargetStepId target test step id * @param StepIds test steps ids to move */ moveSteps(targetStepId: string, StepIds: string[]): void; /** * Copy test steps * @param stepIds test step ids to copy * @return copied steps */ copySteps(StepIds: string[]): Promise<string>; /** * Paste copied test steps as sibling of target step * @param TargetStepId target test step id * @param Clipboard test steps copied to clipboard */ pasteStepsAsChildren(targetStepId: string, Clipboard: string): void; /** * Paste copied test steps as sibling of target step * @param TargetStepId target test step id * @param Clipboard test steps copied to clipboard */ pasteSteps(targetStepId: string, Clipboard: string): void; /** * Delete test steps * @param stepIds test step ids to delete */ deleteSteps(StepIds: string[]): void; /** * Undo */ testPlanUndo(): void; /** * Redo */ testPlanRedo(): void; /** * 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 with reference. */ saveTestPlanToRepository(packageReference: RepositoryPackageDefinition): Promise<SaveTestPlanToRepositoryResponse>; /** * 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>; /** * Gets the loaded test plan repository reference. * @return {Promise<GetTestPlanReferenceResponse>} */ getTestPlanReference(): Promise<GetTestPlanReferenceResponse>; /** * 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>; }