Home / Function/ deriveChanges() — supabase Function Reference

deriveChanges() — supabase Function Reference

Architecture documentation for the deriveChanges() function in UpdateRolesPanel.utils.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  8253f2df_37f3_8809_317b_569aec99d7d7["deriveChanges()"]
  08b3c701_2442_915a_319d_41013f9dc8ec["UpdateRolesConfirmationModal()"]
  08b3c701_2442_915a_319d_41013f9dc8ec -->|calls| 8253f2df_37f3_8809_317b_569aec99d7d7
  style 8253f2df_37f3_8809_317b_569aec99d7d7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/Organization/TeamSettings/UpdateRolesPanel/UpdateRolesPanel.utils.ts lines 58–95

export const deriveChanges = (
  original: ProjectRoleConfiguration[] = [],
  final: ProjectRoleConfiguration[] = []
) => {
  const removed: ProjectRoleConfiguration[] = []
  const added: ProjectRoleConfiguration[] = []
  const updated: {
    ref?: string
    name?: string
    originalRole: number
    originalBaseRole?: number
    updatedRole: number
  }[] = []

  original.forEach((x) => {
    const updatedRoleForProject = final.find((y) => x.ref === y.ref)
    if (updatedRoleForProject === undefined) {
      removed.push(x)
    } else if (updatedRoleForProject.roleId !== x.roleId) {
      updated.push({
        ref: updatedRoleForProject.ref,
        name: updatedRoleForProject.name,
        originalRole: x.roleId,
        originalBaseRole: x.baseRoleId,
        updatedRole: updatedRoleForProject.roleId,
      })
    }
  })

  final.forEach((x) => {
    const newRoleForProject = original.find((y) => x.ref === y.ref)
    if (newRoleForProject === undefined) {
      added.push(x)
    }
  })

  return { removed, added, updated }
}

Subdomains

Frequently Asked Questions

What does deriveChanges() do?
deriveChanges() is a function in the supabase codebase.
What calls deriveChanges()?
deriveChanges() is called by 1 function(s): UpdateRolesConfirmationModal.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free