(client: SmartThingsClient, list: (T & WithLocation)[])
| 27 | } |
| 28 | |
| 29 | export const withLocations = async <T>(client: SmartThingsClient, list: (T & WithLocation)[]): Promise<(T & WithNamedLocation)[]> => { |
| 30 | const locationNameById = await buildLocationNamesById(client) |
| 31 | |
| 32 | const withLocation = <T extends WithLocation>(item: T): T & WithNamedLocation => |
| 33 | ({ ...item, location: item.locationId ? locationNameById.get(item.locationId) ?? '<invalid locationId>' : '' }) |
| 34 | |
| 35 | return list.map(item => withLocation(item)) |
| 36 | } |
| 37 | |
| 38 | export const withLocation = async <T>(client: SmartThingsClient, item: T & WithLocation): Promise<T & WithNamedLocation> => |
| 39 | (await withLocations(client, [item]))[0] |
no test coverage detected