Home / Function/ generateAiPoliciesForTable() — supabase Function Reference

generateAiPoliciesForTable() — supabase Function Reference

Architecture documentation for the generateAiPoliciesForTable() function in Policies.utils.ts from the supabase codebase.

Entity Profile

Dependency Diagram

graph TD
  6cc9558a_5798_e9fb_8755_c4243784aa09["generateAiPoliciesForTable()"]
  96633605_f557_cebf_e67e_dd22cd27168c["generateStartingPoliciesForTable()"]
  96633605_f557_cebf_e67e_dd22cd27168c -->|calls| 6cc9558a_5798_e9fb_8755_c4243784aa09
  style 6cc9558a_5798_e9fb_8755_c4243784aa09 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

apps/studio/components/interfaces/Auth/Policies/Policies.utils.ts lines 372–399

export const generateAiPoliciesForTable = async ({
  table,
  columns,
  projectRef,
  connectionString,
}: {
  table: { name: string; schema: string }
  columns: { name: string }[]
  projectRef: string
  connectionString?: string | null
}): Promise<GeneratedPolicy[]> => {
  if (!connectionString) return []

  try {
    const aiPolicies = await generateSqlPolicy({
      tableName: table.name,
      schema: table.schema,
      columns: columns.map((col) => col.name.trim()),
      projectRef,
      connectionString: connectionString ?? '',
    })
    // AI response now includes all structured fields
    return aiPolicies as GeneratedPolicy[]
  } catch (error) {
    console.log('AI policy generation failed:', error)
    return []
  }
}

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free