@appium/base-driver
Version:
Base driver class for Appium drivers
66 lines • 3.56 kB
TypeScript
import { PROTOCOLS } from '../constants';
import type { Core, PayloadParams } from '@appium/types';
import type { Request } from 'express';
import type { RouteConfiguringFunction } from '../express/server';
export declare const CREATE_SESSION_COMMAND = "createSession";
export declare const DELETE_SESSION_COMMAND = "deleteSession";
export declare const GET_STATUS_COMMAND = "getStatus";
export declare const LIST_DRIVER_COMMANDS_COMMAND = "listCommands";
export declare const LIST_DRIVER_EXTENSIONS_COMMAND = "listExtensions";
export declare const deprecatedCommandsLogged: Set<string>;
/**
* Infer W3C vs MJSONWP from new-session capability payloads.
* @param createSessionArgs - Arguments passed to the createSession command
*/
export declare function determineProtocol(createSessionArgs: any[]): keyof typeof PROTOCOLS;
/**
* Extract and validate the sessionId from the Express route parameter.
* Express may return route params as string | string[] | undefined.
* Appium uses standard routes (e.g., /session/:sessionId) which should always be strings.
* Only `*` such as `/session/*sessionId` can return `string[]`.
* Then, this method will return the first element as the session id.
* It may break existing appium routing handling also, thus this method will log
* received parameters as well to help debugging.
* @param driver Running driver
* @param req The request in Express
* @returns The normalized sessionId (string or undefined)
*/
export declare function getSessionId(driver: Core<any>, req: Request): string | undefined;
/**
* @param command - Driver command name
* @returns Whether the command requires a session id in the URL
*/
export declare function isSessionCommand(command: string): boolean;
/**
* Validate request arguments against a route payload spec and return filtered params.
* @param paramSpec - Required/optional parameter definition from the method map
* @param args - Raw arguments (e.g. JSON body)
* @param protocol - Active protocol, used when a custom validate function is present
*/
export declare function checkParams(paramSpec: PayloadParams, args: Record<string, any>, protocol?: keyof typeof PROTOCOLS): Record<string, any>;
/**
* Build the ordered argument list for a driver command from URL params, JSON body, and route spec.
* @param requestParams - Express route parameters (e.g. sessionId, element id)
* @param jsonObj - Parsed JSON request body
* @param payloadParams - Route payload definition (required/optional/makeArgs)
*/
export declare function makeArgs(requestParams: PayloadParams, jsonObj: any, payloadParams: PayloadParams): any[];
/**
* Validate parameters for execute/executeAsync script endpoints.
* @param params - Raw execute command arguments from the client
* @param paramSpec - Optional payload spec for additional validation
*/
export declare function validateExecuteMethodParams(params: any[], paramSpec?: PayloadParams): any[];
/**
* Returns a function that registers default (and plugin) HTTP routes on an Express app for a driver.
* @param driver - Driver instance used to execute commands
*/
export declare function routeConfiguringFunction(driver: Core<any>): RouteConfiguringFunction;
/**
* Whether an incoming request should be forwarded to the driver's JWProxy for the given command.
* @param driver - Active driver
* @param req - Incoming HTTP request
* @param command - Resolved driver command name
*/
export declare function driverShouldDoJwpProxy(driver: Core<any>, req: Request, command: string): boolean;
//# sourceMappingURL=protocol.d.ts.map