| 36 | export type SimulatorListResult = SimulatorListDomainResult; |
| 37 | |
| 38 | function isSimulatorData(value: unknown): value is SimulatorData { |
| 39 | if (!value || typeof value !== 'object') { |
| 40 | return false; |
| 41 | } |
| 42 | |
| 43 | const obj = value as Record<string, unknown>; |
| 44 | if (!obj.devices || typeof obj.devices !== 'object') { |
| 45 | return false; |
| 46 | } |
| 47 | |
| 48 | const devices = obj.devices as Record<string, unknown>; |
| 49 | for (const runtime in devices) { |
| 50 | const deviceList = devices[runtime]; |
| 51 | if (!Array.isArray(deviceList)) { |
| 52 | return false; |
| 53 | } |
| 54 | |
| 55 | for (const device of deviceList) { |
| 56 | if (!device || typeof device !== 'object') { |
| 57 | return false; |
| 58 | } |
| 59 | |
| 60 | const deviceObj = device as Record<string, unknown>; |
| 61 | if ( |
| 62 | typeof deviceObj.name !== 'string' || |
| 63 | typeof deviceObj.udid !== 'string' || |
| 64 | typeof deviceObj.state !== 'string' || |
| 65 | typeof deviceObj.isAvailable !== 'boolean' |
| 66 | ) { |
| 67 | return false; |
| 68 | } |
| 69 | } |
| 70 | } |
| 71 | |
| 72 | return true; |
| 73 | } |
| 74 | |
| 75 | export async function listSimulators( |
| 76 | executor: CommandExecutor, |