chore(): add RouteMatcher type
Replaces the bare tuple `[string, RegExp]` with a named type.  Used by `Driver.getProxyAvoidList()`
Narrows the type def to only allow known HTTP methods as the first item in the tuple.
MODIFY
packages/appium/lib/appium.js
packages/appium/lib/appium.js
@@ -783,6 +783,11 @@ class AppiumDriver extends DriverCore {
return dstSession && _.isFunction(dstSession.proxyActive) && dstSession.proxyActive(sessionId);
}
+ /**
+ *
+ * @param {string} sessionId
+ * @returns {import('@appium/types').RouteMatcher[]}
+ */
getProxyAvoidList(sessionId) {
const dstSession = this.sessions[sessionId];
return dstSession ? dstSession.getProxyAvoidList() : [];

MODIFY
packages/base-driver/lib/basedriver/core.js
packages/base-driver/lib/basedriver/core.js
@@ -351,7 +351,7 @@ class DriverCore {
/**
*
* @param {string} sessionId
- * @returns {[string, RegExp][]}
+ * @returns {import('@appium/types').RouteMatcher[]}
*/
getProxyAvoidList(sessionId) {
return [];

MODIFY
packages/driver-test-support/lib/unit-suite.js
packages/driver-test-support/lib/unit-suite.js
@@ -447,6 +447,7 @@ export function driverUnitTestSuite(DriverClass, defaultCaps = {}) {
const avoidStub = sandbox.stub(d, 'getProxyAvoidList');
avoidStub.returns([
['POST', /^foo/],
+ // @ts-expect-error
['BAZETE', /^bar/],
]);
(() => {

MODIFY
packages/types/lib/driver.ts
packages/types/lib/driver.ts
@@ -320,7 +320,7 @@ export interface Core {
assertFeatureEnabled(name: string): void;
validateLocatorStrategy(strategy: string, webContext?: boolean): void;
proxyActive(sessionId?: string): boolean;
- getProxyAvoidList(sessionId?: string): [string, RegExp][];
+ getProxyAvoidList(sessionId?: string): RouteMatcher[];
canProxy(sessionId?: string): boolean;
proxyRouteIsAvoided(sessionId: string, method: string, url: string): boolean;
addManagedDriver(driver: Driver): void;
@@ -615,3 +615,8 @@ export type DriverCommands<TArgs = any, TReturn = unknown> = Record<
string,
DriverCommand<TArgs, TReturn>
>;
+
+/**
+ * Tuple of an HTTP method with a regex matching a request path
+ */
+export type RouteMatcher = [HTTPMethod, RegExp];

chore(): add RouteMatcher type

Replaces the bare tuple `[string, RegExp]` with a named type.  Used by `Driver.getProxyAvoidList()`

Narrows the type def to only allow known HTTP methods as the first item in the tuple.