@@ -5,16 +5,12 @@ import {
55 type AwsDeviceFarmArtifact ,
66 type AwsDeviceFarmArtifactGroup ,
77} from './aws-device-farm-artifacts.ts' ;
8- import type {
9- CloudWebDriverPlatform ,
10- CloudWebDriverRuntimeOptions ,
11- CloudWebDriverPrepareSession ,
12- } from './runtime.ts' ;
13- import type { DeviceLease , LeaseLifecycleContext } from '@agent-device/contracts/device' ;
8+ import type { CloudWebDriverPlatform , CloudWebDriverPrepareSession } from './runtime.ts' ;
9+ import type { LeaseLifecycleContext } from '@agent-device/contracts/device' ;
1410import { setTimeout as sleep } from 'node:timers/promises' ;
1511import { AppError } from '@agent-device/kernel/errors' ;
1612import type { RunHostCommand } from './dependencies.ts' ;
17- import { releaseOnFailure , resolveLeaseValue , type LeaseValue } from './webdriver-utils.ts' ;
13+ import { releaseOnFailure } from './webdriver-utils.ts' ;
1814
1915export const AWS_DEVICE_FARM_CAPABILITY_OVERRIDES = {
2016 install : {
@@ -72,25 +68,16 @@ export type AwsCreateRemoteAccessSessionInput = {
7268} ;
7369
7470export type AwsDeviceFarmWebDriverRuntimeOptions = {
75- clientVersion : string ;
71+ client : AwsDeviceFarmClient ;
7672 projectArn : string ;
7773 deviceArn : string ;
78- region ?: string ;
79- platform ?: CloudWebDriverPlatform ;
80- deviceName ?: string ;
74+ platform : CloudWebDriverPlatform ;
75+ deviceName : string ;
8176 appArn ?: string ;
82- sessionName ?: LeaseValue < string > ;
83- webdriverCapabilities ?:
84- | Record < string , unknown >
85- | ( ( lease : DeviceLease ) => Record < string , unknown > ) ;
86- client ?: AwsDeviceFarmClient ;
77+ sessionName ?: string ;
8778 pollIntervalMs ?: number ;
8879 startupTimeoutMs ?: number ;
8980 interactionMode ?: AwsCreateRemoteAccessSessionInput [ 'interactionMode' ] ;
90- configuration ?: AwsCreateRemoteAccessSessionInput [ 'configuration' ] ;
91- deviceId ?: CloudWebDriverRuntimeOptions [ 'deviceId' ] ;
92- requestPolicy ?: CloudWebDriverRuntimeOptions [ 'requestPolicy' ] ;
93- prepareSession ?: CloudWebDriverRuntimeOptions [ 'prepareSession' ] ;
9481} ;
9582
9683export type AwsCliDeviceFarmClientOptions = {
@@ -134,25 +121,15 @@ export function createAwsCliDeviceFarmClient(
134121}
135122
136123export function createAwsDeviceFarmPrepareSession (
137- options : Required <
138- Pick <
139- AwsDeviceFarmWebDriverRuntimeOptions ,
140- 'client' | 'platform' | 'deviceName' | 'projectArn' | 'deviceArn'
141- >
142- > &
143- Omit <
144- AwsDeviceFarmWebDriverRuntimeOptions ,
145- 'client' | 'platform' | 'deviceName' | 'clientVersion'
146- > ,
124+ options : AwsDeviceFarmWebDriverRuntimeOptions ,
147125) : CloudWebDriverPrepareSession {
148126 return async ( { lease, req, base } ) => {
149127 const remoteAccess = await options . client . createRemoteAccessSession ( {
150128 projectArn : options . projectArn ,
151129 deviceArn : options . deviceArn ,
152130 appArn : options . appArn ,
153- name : resolveLeaseValue ( options . sessionName , lease ) ?? `agent-device-${ lease . leaseId } ` ,
131+ name : options . sessionName ?? `agent-device-${ lease . leaseId } ` ,
154132 interactionMode : options . interactionMode ,
155- configuration : options . configuration ,
156133 } ) ;
157134 // The ARN is a billed session from here on; any failure short of RUNNING
158135 // must stop it before surfacing, or it bills until AWS reaps it.
@@ -173,20 +150,17 @@ export function createAwsDeviceFarmPrepareSession(
173150 throw error ;
174151 }
175152 const deviceName = running . device ?. name ?? options . deviceName ;
176- const configured =
177- typeof options . webdriverCapabilities === 'function'
178- ? options . webdriverCapabilities ( lease )
179- : ( options . webdriverCapabilities ?? { } ) ;
180153 const awsDefaults = options . platform === 'android' ? { 'appium:autoLaunch' : false } : { } ;
181154 return {
182155 ...base ,
183156 endpoint,
184157 platform : options . platform ,
185158 deviceName,
186- webdriverCapabilities : buildCloudWebDriverBaseCapabilities ( options . platform , deviceName , {
187- ...awsDefaults ,
188- ...configured ,
189- } ) ,
159+ webdriverCapabilities : buildCloudWebDriverBaseCapabilities (
160+ options . platform ,
161+ deviceName ,
162+ awsDefaults ,
163+ ) ,
190164 cleanup : async ( ) => {
191165 await options . client . stopRemoteAccessSession ( running . arn ) ;
192166 return { awsDeviceFarmSessionArn : running . arn } ;
0 commit comments