Home / Function/ recurseThroughParams() — supabase Function Reference

recurseThroughParams() — supabase Function Reference

Architecture documentation for the recurseThroughParams() function in helpers.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  be6aa80b_289e_feca_40ab_a7604504fab7["recurseThroughParams()"]
  a497a5f1_fc0b_a0c7_1eba_9f92c95550b7["generateParameters()"]
  a497a5f1_fc0b_a0c7_1eba_9f92c95550b7 -->|calls| be6aa80b_289e_feca_40ab_a7604504fab7
  6f8bb888_f260_e3d0_0f56_7e5048c6953c["generateLabelParam()"]
  be6aa80b_289e_feca_40ab_a7604504fab7 -->|calls| 6f8bb888_f260_e3d0_0f56_7e5048c6953c
  style be6aa80b_289e_feca_40ab_a7604504fab7 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/lib/refGenerator/helpers.ts lines 45–111

function recurseThroughParams(paramDefinition: any) {
  const param = { ...paramDefinition }
  const labelParams = generateLabelParam(param)

  let children: any[] | undefined
  if (param.type?.type === 'literal') {
    // skip: literal types have no children
  } else if (param.type?.type === 'intrinsic') {
    // primitive types
    if (!['string', 'number', 'boolean', 'object', 'unknown'].includes(param.type?.name)) {
      // skip for now
      //throw new Error('unexpected intrinsic type')
    }
  } else if (param.type?.dereferenced) {
    const dereferenced = param.type.dereferenced

    if (dereferenced.children) {
      children = dereferenced.children
    } else if (dereferenced.type?.declaration?.children) {
      children = dereferenced.type.declaration.children
    } else if (dereferenced.type?.type === 'query') {
      // skip: ignore types created from `typeof` for now, like `type Fetch = typeof fetch`
    } else if (dereferenced.type?.type === 'union') {
      // skip: we don't want to show unions as nested parameters
    } else if (Object.keys(dereferenced).length === 0) {
      // skip: {} have no children
    } else {
      throw new Error('unexpected case for dereferenced param type')
    }
  } else if (param.type?.type === 'reflection') {
    const declaration = param.type.declaration

    if (!declaration) {
      throw new Error('reflection must have a declaration')
    }

    if (declaration.children) {
      children = declaration.children
    } else if (declaration.signatures) {
      // skip: functions have no children
    } else if (declaration.name === '__type') {
      // skip: mostly inlined object type
    } else {
      throw new Error('unexpected case for reflection param type')
    }
  } else if (param.type?.type === 'indexedAccess') {
    // skip: too complex, e.g. PromisifyMethods<Pick<Storage, 'getItem' | 'setItem' | 'removeItem'>>
  } else if (param.type?.type === 'reference') {
    // skip: mostly unexported types
  } else if (param.type?.type === 'union') {
    // skip: we don't want to show unions as nested parameters
  } else if (param.type?.type === 'array') {
    // skip: no use for it for now
  } else {
    // skip: no use for now
    //throw new Error(`unexpected param type`)
  }

  if (children) {
    const properties = children
      .sort((a, b) => a.name?.localeCompare(b.name)) // first alphabetical
      .sort((a, b) => (a.flags?.isOptional ? 1 : -1)) // required params first
      .map((x) => recurseThroughParams(x))
    labelParams.subContent = properties
  }
  return labelParams
}

Subdomains

Frequently Asked Questions

What does recurseThroughParams() do?
recurseThroughParams() is a function in the supabase codebase.
What does recurseThroughParams() call?
recurseThroughParams() calls 1 function(s): generateLabelParam.
What calls recurseThroughParams()?
recurseThroughParams() is called by 1 function(s): generateParameters.

Analyze Your Own Codebase

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

Try Supermodel Free