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

Function forAllOrganizations

src/lib/api-helpers.ts:77–88  ·  view source on GitHub ↗
(
		client: SmartThingsClient,
		query: (orgClient: SmartThingsClient, org: OrganizationResponse) => Promise<T[]>)

Source from the content-addressed store, hash-verified

75 (await withLocationsAndRooms(client, [item]))[0]
76
77export 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
90export async function forAllNamespaces<T>(
91 client: SmartThingsClient,

Callers 6

handlerFunction · 0.85
listItemsFunction · 0.85
listDriversFunction · 0.85
listChannelsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected