import { GQLAuthIntegrations } from "../schema/__generated__/types" ; interface Integration { enabled : boolean ; targetFilter : { admin ? : boolean ; stream ? : boolean ; } ; } interface AuthSettings { integrations : { [ index ] : Integration ; } ; } export default function enabledAuthenticationIntegrations ( auth , target ? ) { if ( auth . integrations ) { return Object . keys ( auth . integrations ) . filter ( ( key ) => { const { targetFilter , enabled } = auth . integrations [ key ] ; if ( target ) { return enabled && targetFilter [ target ] ; } return enabled && targetFilter . admin && targetFilter . stream ; } ) ; } return [ ] ; }