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

Function listFn

src/commands/invites/schema.ts:62–76  ·  view source on GitHub ↗
(client: SmartThingsClient, appId?: string)

Source from the content-addressed store, hash-verified

60
61 type InvitationProviderFunction = () => Promise<InvitationWithAppDetails[]>
62 const listFn = (client: SmartThingsClient, appId?: string): InvitationProviderFunction =>
63 async (): Promise<InvitationWithAppDetails[]> => {
64 // We have to be careful to not use the method to get a single app. For more
65 // details see `getSchemaAppEnsuringOrganization` in schema-utils.
66 const apps = appId
67 ? (await client.schema.list({ includeAllOrganizations: true }))
68 .filter(app => app.endpointAppId === appId)
69 : await client.schema.list()
70 return (await Promise.all(apps.map(async app => {
71 return app.endpointAppId
72 ? (await client.invitesSchema.list(app.endpointAppId))
73 .map(invite => addAppDetails(invite, app))
74 : []
75 }))).flat()
76 }
77
78 const config: OutputItemOrListConfig<InvitationWithAppDetails> = {
79 primaryKeyName: 'id',

Callers 1

handlerFunction · 0.85

Calls 1

addAppDetailsFunction · 0.85

Tested by

no test coverage detected