Home / Function/ getSubDetails() — supabase Function Reference

getSubDetails() — supabase Function Reference

Architecture documentation for the getSubDetails() function in Reference.ui.tsx from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  a3204ff1_abba_1b91_1937_bd7abd67ba1e["getSubDetails()"]
  7b65e0e2_6465_ff88_8734_fd54e97395dc["ParamOrTypeDetails()"]
  7b65e0e2_6465_ff88_8734_fd54e97395dc -->|calls| a3204ff1_abba_1b91_1937_bd7abd67ba1e
  0da3d3e3_1ace_0b81_9190_19ded8972320["ReturnTypeDetails()"]
  0da3d3e3_1ace_0b81_9190_19ded8972320 -->|calls| a3204ff1_abba_1b91_1937_bd7abd67ba1e
  style a3204ff1_abba_1b91_1937_bd7abd67ba1e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/docs/features/docs/Reference.ui.tsx lines 647–726

function getSubDetails(parentType: MethodTypes['params'][number] | MethodTypes['ret']) {
  let subDetails: Array<any> = []

  switch (parentType?.type?.type) {
    case 'object':
      subDetails = parentType?.type?.properties
      break
    case 'function':
      subDetails = [
        ...(parentType?.type?.params?.length === 0
          ? []
          : [
              {
                name: 'Parameters',
                type: 'callback parameters',
                isOptional: 'NA',
                params: parentType?.type?.params?.map((param) => ({
                  ...param,
                  isOptional: 'NA',
                })),
              },
            ]),
        { name: 'Return', type: parentType?.type?.ret?.type, isOptional: 'NA' },
      ]
      break
    // @ts-ignore -- Adding these fake types to take advantage of existing recursion
    case 'callback parameters':
      // @ts-ignore -- Adding these fake types to take advantage of existing recursion
      subDetails = parentType.params
      break
    case 'union':
      subDetails = parentType?.type?.subTypes?.map((subType, index) => ({
        name: `Option ${index + 1}`,
        type: { ...subType },
        isOptional: 'NA',
      }))
      break
    case 'promise':
      if (parentType?.type?.awaited?.type === 'union') {
        subDetails = parentType?.type?.awaited?.subTypes?.map((subType, index) => ({
          name: `Option ${index + 1}`,
          type: { ...subType },
          isOptional: 'NA',
        }))
      } else if (
        parentType?.type?.awaited?.type === 'object' &&
        'properties' in parentType.type.awaited
      ) {
        subDetails = (parentType.type.awaited as any).properties?.map((property) => ({
          ...property,
          isOptional: 'NA',
        }))
      } else if (parentType?.type?.awaited?.type === 'array') {
        subDetails = [
          {
            name: 'array element',
            type: (parentType?.type?.awaited as any)?.elemType,
            isOptional: 'NA',
          },
        ]
      }
      break
    case 'array':
      if (parentType.type.elemType?.type === 'union') {
        subDetails = parentType.type.elemType.subTypes.map((subType, index) => ({
          name: `Option ${index + 1}`,
          type: { ...subType },
          isOptional: 'NA',
        }))
      }
      if (parentType.type.elemType?.type === 'object') {
        subDetails = parentType.type.elemType.properties
      }
      break
  }

  subDetails?.sort((a, b) => (a.isOptional === true ? 1 : 0) - (b.isOptional === true ? 1 : 0))

  return subDetails
}

Subdomains

Frequently Asked Questions

What does getSubDetails() do?
getSubDetails() is a function in the supabase codebase.
What calls getSubDetails()?
getSubDetails() is called by 2 function(s): ParamOrTypeDetails, ReturnTypeDetails.

Analyze Your Own Codebase

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

Try Supermodel Free