mirror of
https://github.com/appium/appium.git
synced 2026-05-05 18:10:24 -05:00
chore(base-driver): Add types to proxy options (#21034)
This commit is contained in:
@@ -53,12 +53,15 @@ export class JWProxy {
|
||||
/** @type {number} */
|
||||
timeout;
|
||||
|
||||
/**
|
||||
* @param {import('@appium/types').ProxyOptions} [opts={}]
|
||||
*/
|
||||
constructor(opts = {}) {
|
||||
opts = _.pick(opts, ALLOWED_OPTS);
|
||||
|
||||
const filteredOpts = _.pick(opts, ALLOWED_OPTS);
|
||||
// omit 'log' in the defaults assignment here because 'log' is a getter and we are going to set
|
||||
// it to this._log (which lies behind the getter) further down
|
||||
const options = _.defaults(_.omit(opts, 'log'), {
|
||||
/** @type {import('@appium/types').ProxyOptions} */
|
||||
const options = _.defaults(_.omit(filteredOpts, 'log'), {
|
||||
scheme: 'http',
|
||||
server: 'localhost',
|
||||
port: 4444,
|
||||
@@ -67,7 +70,7 @@ export class JWProxy {
|
||||
sessionId: null,
|
||||
timeout: DEFAULT_REQUEST_TIMEOUT,
|
||||
});
|
||||
options.scheme = options.scheme.toLowerCase();
|
||||
options.scheme = /** @type {string} */ (options.scheme).toLowerCase();
|
||||
Object.assign(this, options);
|
||||
|
||||
this._activeRequests = [];
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { AppiumLogger } from './logger';
|
||||
|
||||
/**
|
||||
* An object of HTTP headers.
|
||||
*/
|
||||
@@ -36,4 +38,59 @@ export interface ProxyResponse<T = any> {
|
||||
body: HTTPBody<T>;
|
||||
}
|
||||
|
||||
export interface ProxyOptions {
|
||||
/**
|
||||
* Downstream URL scheme
|
||||
*
|
||||
* @default 'http'
|
||||
*/
|
||||
scheme?: string;
|
||||
/**
|
||||
* Downstream server hostname
|
||||
*
|
||||
* @default 'localhost'
|
||||
*/
|
||||
server?: string;
|
||||
/**
|
||||
* Downstream server port number
|
||||
*
|
||||
* @default 4444
|
||||
*/
|
||||
port?: number;
|
||||
/**
|
||||
* Downstream server pathname prefix
|
||||
*
|
||||
* @default ''
|
||||
*/
|
||||
base?: string;
|
||||
/**
|
||||
* Upstream server pathname prefix
|
||||
*
|
||||
* @default ''
|
||||
*/
|
||||
reqBasePath?: string;
|
||||
/**
|
||||
* Initial downstream session identifier value
|
||||
*
|
||||
* @default null
|
||||
*/
|
||||
sessionId?: string | null;
|
||||
/**
|
||||
* Downstream server timeout in milliseconds
|
||||
*
|
||||
* @default 240000
|
||||
*/
|
||||
timeout?: number;
|
||||
/**
|
||||
* Proxy logger instance. If unset then a default logger is used
|
||||
*/
|
||||
log?: AppiumLogger;
|
||||
/**
|
||||
* Whether to apply HTTP Keep-Alive to the downstream server
|
||||
*
|
||||
* @default true
|
||||
*/
|
||||
keepAlive?: boolean;
|
||||
}
|
||||
|
||||
export type HTTPBody<T = any> = T;
|
||||
|
||||
Reference in New Issue
Block a user