Home / Function/ useCreateCommandsConfig() — supabase Function Reference

useCreateCommandsConfig() — supabase Function Reference

Architecture documentation for the useCreateCommandsConfig() function in CreateCommands.utils.tsx from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  9bd89fd5_ec76_3658_ca41_c486edd8bac6["useCreateCommandsConfig()"]
  7691c069_7dea_faac_d384_4e20dfcccdcd["useCreateCommands()"]
  7691c069_7dea_faac_d384_4e20dfcccdcd -->|calls| 9bd89fd5_ec76_3658_ca41_c486edd8bac6
  style 9bd89fd5_ec76_3658_ca41_c486edd8bac6 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/App/CommandMenu/CreateCommands.utils.tsx lines 82–202

export function useCreateCommandsConfig() {
  let { ref } = useParams()
  ref ||= '_'
  const setPage = useSetPage()
  const { openSidebar } = useSidebarManagerSnapshot()
  const snap = useAiAssistantStateSnapshot()

  // Auth
  const authenticationOauth21 = useFlag('EnableOAuth21')

  const {
    projectAuthAll: authEnabled,
    projectEdgeFunctionAll: edgeFunctionsEnabled,
    projectStorageAll: storageEnabled,
    reportsAll: reportsEnabled,
    integrationsWrappers: integrationsWrappersEnabled,
  } = useIsFeatureEnabled([
    'project_auth:all',
    'project_edge_function:all',
    'project_storage:all',
    'reports:all',
    'integrations:wrappers',
  ])

  const {
    data: authConfig,
    isError: isAuthConfigError,
    isPending: isAuthConfigLoading,
  } = useAuthConfigQuery({ projectRef: ref })

  const { getEntitlementSetValues: getEntitledHookSet } = useCheckEntitlements('auth.hooks')
  const entitledHookSet = getEntitledHookSet()

  const { nonAvailableHooks } = useMemo(() => {
    const allHooks: Hook[] = HOOKS_DEFINITIONS.map((definition) => ({
      ...definition,
      enabled: authConfig?.[definition.enabledKey] || false,
      method: extractMethod(
        authConfig?.[definition.uriKey] || '',
        authConfig?.[definition.secretsKey] || ''
      ),
    }))

    const nonAvailableHooks: string[] = allHooks
      .filter((h) => !isValidHook(h) && !entitledHookSet.includes(h.entitlementKey))
      .map((h) => h.entitlementKey)

    return { nonAvailableHooks }
  }, [entitledHookSet, authConfig])

  const showAuthConfig = !isAuthConfigError && !isAuthConfigLoading

  const sendSmsHook = HOOKS_DEFINITIONS.find((hook) => hook.id === 'send-sms')
  const sendEmailHook = HOOKS_DEFINITIONS.find((hook) => hook.id === 'send-email')
  const customAccessTokenHook = HOOKS_DEFINITIONS.find(
    (hook) => hook.id === 'custom-access-token-claims'
  )
  const mfaVerificationHook = HOOKS_DEFINITIONS.find(
    (hook) => hook.id === 'mfa-verification-attempt'
  )
  const mfaVerificationHookEnabled =
    showAuthConfig &&
    mfaVerificationHook &&
    nonAvailableHooks.includes(mfaVerificationHook.entitlementKey)
  const passwordVerificationHook = HOOKS_DEFINITIONS.find(
    (hook) => hook.id === 'password-verification-attempt'
  )
  const passwordVerificationHookEnabled =
    showAuthConfig &&
    passwordVerificationHook &&
    nonAvailableHooks.includes(passwordVerificationHook.entitlementKey)
  const beforeUserCreatedHook = HOOKS_DEFINITIONS.find((hook) => hook.id === 'before-user-created')

  // Storage
  const { data: organization } = useSelectedOrganizationQuery()
  const isFreePlan = organization?.plan.id === 'free'
  const isVectorBucketsEnabled = useIsVectorBucketsEnabled({ projectRef: ref })
  const isAnalyticsBucketsEnabled = useIsAnalyticsBucketsEnabled({ projectRef: ref })

  // Integrations
  const { installedIntegrations } = useInstalledIntegrations()

  const installedIntegrationIds = useMemo(
    () => new Set(installedIntegrations.map((integration) => integration.id)),
    [installedIntegrations]
  )

  const allIntegrations = useMemo(
    () =>
      integrationsWrappersEnabled
        ? INTEGRATIONS
        : INTEGRATIONS.filter((x) => !x.id.endsWith('_wrapper')),
    [integrationsWrappersEnabled]
  )

  return {
    ref,
    setPage,
    openSidebar,
    snap,
    authenticationOauth21,
    authEnabled,
    edgeFunctionsEnabled,
    storageEnabled,
    sendSmsHook,
    sendEmailHook,
    customAccessTokenHook,
    mfaVerificationHook,
    mfaVerificationHookEnabled,
    passwordVerificationHook,
    passwordVerificationHookEnabled,
    beforeUserCreatedHook,
    isFreePlan,
    isVectorBucketsEnabled,
    isAnalyticsBucketsEnabled,
    installedIntegrationIds,
    integrationsWrappers: integrationsWrappersEnabled,
    allIntegrations,
    reportsEnabled,
  }
}

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free