( client: SmartThingsClient, query: (orgClient: SmartThingsClient, org: OrganizationResponse) => Promise<T[]>)
| 75 | (await withLocationsAndRooms(client, [item]))[0] |
| 76 | |
| 77 | export async function forAllOrganizations<T>( |
| 78 | client: SmartThingsClient, |
| 79 | query: (orgClient: SmartThingsClient, org: OrganizationResponse) => Promise<T[]>): Promise<(T & WithOrganization)[]> { |
| 80 | const organizations = await client.organizations.list() |
| 81 | const nestedItems = await Promise.all(organizations.map(async (org) => { |
| 82 | // eslint-disable-next-line @typescript-eslint/naming-convention |
| 83 | const orgClient = client.clone({ 'X-ST-Organization': org.organizationId }) |
| 84 | const items = await query(orgClient, org) |
| 85 | return items.map(item => ({ ...item, organization: org.name })) |
| 86 | })) |
| 87 | return nestedItems.flat() |
| 88 | } |
| 89 | |
| 90 | export async function forAllNamespaces<T>( |
| 91 | client: SmartThingsClient, |
no outgoing calls
no test coverage detected