import { QualifiedId } from '@wireapp/api-client/src/user' ; type UserClientsContainer < T > = { [ userId ] : T ; } ; type QualifiedUserClientsContainer < T > = { [ domain ] : UserClientsContainer < T > ; } ; export function flattenUserClients < T > ( userClients , domain = '' ) { return Object . entries ( userClients ) . map ( ( [ id , data ] ) => ( { data , userId : { domain , id } } ) ) ; } param userClients return export function flattenQualifiedUserClients < T = unknown > ( userClients ) { return Object . entries ( userClients ) . reduce ( ( ids , [ domain , userClients ] ) => { return [ ... ids , ... flattenUserClients ( userClients , domain ) ] ; } , [ ] as { data : T ; userId : QualifiedId ; } [ ] ) ; }