MCPcopy Create free account
hub / github.com/SmartThingsCommunity/smartthings-cli / withLocations

Function withLocations

src/lib/api-helpers.ts:29–36  ·  view source on GitHub ↗
(client: SmartThingsClient, list: (T & WithLocation)[])

Source from the content-addressed store, hash-verified

27}
28
29export 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
38export const withLocation = async <T>(client: SmartThingsClient, item: T & WithLocation): Promise<T & WithNamedLocation> =>
39 (await withLocations(client, [item]))[0]

Callers 5

installedAppsFunction · 0.85
withLocationFunction · 0.85
listInstalledAppsFnFunction · 0.85
installedSchemaInstancesFunction · 0.85

Calls 2

buildLocationNamesByIdFunction · 0.85
withLocationFunction · 0.85

Tested by

no test coverage detected