(value: unknown)
| 641 | } |
| 642 | |
| 643 | function parseDeviceListResponse(value: unknown): SetupDevice[] { |
| 644 | if (!value || typeof value !== 'object') { |
| 645 | return []; |
| 646 | } |
| 647 | |
| 648 | const result = (value as { result?: unknown }).result; |
| 649 | if (!result || typeof result !== 'object') { |
| 650 | return []; |
| 651 | } |
| 652 | |
| 653 | const devices = (result as { devices?: unknown }).devices; |
| 654 | if (!Array.isArray(devices)) { |
| 655 | return []; |
| 656 | } |
| 657 | |
| 658 | const listed: SetupDevice[] = []; |
| 659 | for (const device of devices) { |
| 660 | if (!device || typeof device !== 'object') { |
| 661 | continue; |
| 662 | } |
| 663 | |
| 664 | const record = device as { |
| 665 | identifier?: unknown; |
| 666 | visibilityClass?: unknown; |
| 667 | connectionProperties?: { |
| 668 | pairingState?: unknown; |
| 669 | tunnelState?: unknown; |
| 670 | }; |
| 671 | deviceProperties?: { |
| 672 | name?: unknown; |
| 673 | platformIdentifier?: unknown; |
| 674 | }; |
| 675 | }; |
| 676 | |
| 677 | if (record.visibilityClass === 'Simulator') { |
| 678 | continue; |
| 679 | } |
| 680 | |
| 681 | if ( |
| 682 | typeof record.identifier !== 'string' || |
| 683 | typeof record.deviceProperties?.name !== 'string' || |
| 684 | typeof record.connectionProperties?.pairingState !== 'string' |
| 685 | ) { |
| 686 | continue; |
| 687 | } |
| 688 | |
| 689 | if (record.connectionProperties.pairingState !== 'paired') { |
| 690 | continue; |
| 691 | } |
| 692 | |
| 693 | const tunnelState = record.connectionProperties.tunnelState; |
| 694 | if ( |
| 695 | tunnelState !== 'connected' && |
| 696 | tunnelState !== undefined && |
| 697 | tunnelState !== 'disconnected' |
| 698 | ) { |
| 699 | continue; |
| 700 | } |
no test coverage detected