Home / Function/ estimateDiskCost() — supabase Function Reference

estimateDiskCost() — supabase Function Reference

Architecture documentation for the estimateDiskCost() function in BranchManagement.utils.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  64e987f3_dbda_3f4c_2573_72d778e94d78["estimateDiskCost()"]
  8505154a_957e_9e24_3406_97558e329ee1["CreateBranchModal()"]
  8505154a_957e_9e24_3406_97558e329ee1 -->|calls| 64e987f3_dbda_3f4c_2573_72d778e94d78
  style 64e987f3_dbda_3f4c_2573_72d778e94d78 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/BranchManagement/BranchManagement.utils.ts lines 40–61

export const estimateDiskCost = (disk: DiskAttributesData['attributes']) => {
  const diskType = disk.type as DiskType

  const pricing = DISK_PRICING[diskType]
  const includedGB = PLAN_DETAILS['pro'].includedDiskGB[diskType]
  const priceSize = Math.max(disk.size_gb - includedGB, 0) * pricing.storage
  const includedIOPS = DISK_LIMITS[diskType].includedIops
  const priceIOPS = Math.max(disk.iops - includedIOPS, 0) * pricing.iops

  const priceThroughput =
    diskType === DiskType.GP3 && 'throughput_mbps' in disk
      ? Math.max(disk.throughput_mbps - DISK_LIMITS[DiskType.GP3].includedThroughput, 0) *
        DISK_PRICING[DiskType.GP3].throughput
      : 0

  return {
    total: priceSize + priceIOPS + priceThroughput,
    size: priceSize,
    iops: priceIOPS,
    throughput: priceThroughput,
  }
}

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free