Home / Function/ convertArgumentTypes() — supabase Function Reference

convertArgumentTypes() — supabase Function Reference

Architecture documentation for the convertArgumentTypes() function in Functions.utils.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  68822530_7542_9aea_3a82_46fc0e4af2a8["convertArgumentTypes()"]
  d283a1cf_3e04_3f10_5eeb_b3619f3ec1c5["CreateFunction()"]
  d283a1cf_3e04_3f10_5eeb_b3619f3ec1c5 -->|calls| 68822530_7542_9aea_3a82_46fc0e4af2a8
  style 68822530_7542_9aea_3a82_46fc0e4af2a8 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/Database/Functions/Functions.utils.ts lines 7–34

export function convertArgumentTypes(value: string) {
  const items = value?.split(',').map((item) => item.trim())
  if (isEmpty(value) || !items || items.length === 0) return { value: [] }

  const temp = items
    .map((x) => {
      const regex = /(\w+)\s+([\w\[\]]+)(?:\s+DEFAULT\s+(.*))?/i
      const match = x.match(regex)
      if (match) {
        const [, name, type, defaultValue] = match
        let parsedDefaultValue = defaultValue ? defaultValue.trim() : undefined

        if (
          ['timestamp', 'time', 'timetz', 'timestamptz'].includes(type.toLowerCase()) &&
          parsedDefaultValue
        ) {
          parsedDefaultValue = `'${parsedDefaultValue}'`
        }

        return { name, type, defaultValue: parsedDefaultValue }
      } else {
        console.error('Error while trying to parse function arguments', x)
        return null
      }
    })
    .filter(Boolean) as { name: string; type: string; defaultValue?: string }[]
  return { value: temp }
}

Subdomains

Called By

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free