diff --git a/apps/studio/components/interfaces/Settings/Database/JitDatabaseAccess/JitDbAccess.utils.ts b/apps/studio/components/interfaces/Settings/Database/JitDatabaseAccess/JitDbAccess.utils.ts index cfb6e1e2b43..4f54c12c627 100644 --- a/apps/studio/components/interfaces/Settings/Database/JitDatabaseAccess/JitDbAccess.utils.ts +++ b/apps/studio/components/interfaces/Settings/Database/JitDatabaseAccess/JitDbAccess.utils.ts @@ -257,7 +257,9 @@ export function mapJitMembersToUserRules( const memberMap = new Map((projectMembers ?? []).map((member) => [member.user_id, member])) const baseRoleIds = roleOptions.map((role) => role.id) - return (jitMembers ?? []).map((item) => { + return (jitMembers ?? []).flatMap((item) => { + if (!item.user_id) return [] + const mappedMember = memberMap.get(item.user_id) const assignedRoles: JitRoleGrantDraft[] = (item.user_roles ?? []).map((roleObj) => { const roleWithBranchRestriction = roleObj as typeof roleObj & { branches_only?: boolean } @@ -294,14 +296,16 @@ export function mapJitMembersToUserRules( const email = mappedMember?.primary_email ?? item.user_id const name = mappedMember?.username ?? undefined - return { - id: item.user_id, - memberId: item.user_id, - email, - name, - grants: cloneGrants(grants), - status: computeStatusFromGrants(grants), - } + return [ + { + id: item.user_id, + memberId: item.user_id, + email, + name, + grants: cloneGrants(grants), + status: computeStatusFromGrants(grants), + }, + ] }) } diff --git a/packages/api-types/types/api-v1.d.ts b/packages/api-types/types/api-v1.d.ts index 5d7c1d4b205..3cceab3eefa 100644 --- a/packages/api-types/types/api-v1.d.ts +++ b/packages/api-types/types/api-v1.d.ts @@ -3348,28 +3348,52 @@ export interface components { } } JitListAccessResponse: { - items: { - expires_at: null - invite_id: null - primary_email: string | null - /** Format: uuid */ - user_id: string - user_roles: { - allowed_networks?: { - allowed_cidrs?: { - /** Format: cidrv4 */ - cidr: string - }[] - allowed_cidrs_v6?: { - /** Format: cidrv6 */ - cidr: string + items: ( + | { + expires_at: null + invite_id: null + primary_email: string | null + /** Format: uuid */ + user_id: string + user_roles: { + allowed_networks?: { + allowed_cidrs?: { + /** Format: cidrv4 */ + cidr: string + }[] + allowed_cidrs_v6?: { + /** Format: cidrv6 */ + cidr: string + }[] + } + branches_only?: boolean + expires_at?: number + role: string }[] } - branches_only?: boolean - expires_at?: number - role: string - }[] - }[] + | { + expires_at: string + /** Format: uuid */ + invite_id: string + primary_email: string + user_id: null + user_roles: { + allowed_networks?: { + allowed_cidrs?: { + /** Format: cidrv4 */ + cidr: string + }[] + allowed_cidrs_v6?: { + /** Format: cidrv6 */ + cidr: string + }[] + } + branches_only?: boolean + expires_at?: number + role: string + }[] + } + )[] } LegacyApiKeysResponse: { enabled: boolean