mirror of
https://github.com/supabase/supabase.git
synced 2026-10-12 21:05:06 +03:00
* try a really long context window to maximize caching
* update examples
* attempt to update packages and useChat
* update endpoints
* update zod
* zod
* update to v5
* message update
* Revert "zod"
This reverts commit ec39bac6b6.
* revert zod
* zod i
* fix complete endpoints
* remove async
* change to content
* type cleanup
* Revert the package bumps to rebuild them.
* Bump zod to 2.25.76 in all packages.
* Bump openai in all packages.
* Bump ai and ai-related packages.
* Remove unneeded files.
* Fix the rest of the migration stuff.
* Prettier fixes.
* add policy list tool
* refactor
* ai sdk 5 fixes
* refactor complete endpoint
* edge function prompt
* remove example
* slight prompt change
* Minor clean up
* More clean up
---------
Co-authored-by: Jordi Enric <jordi.err@gmail.com>
Co-authored-by: Ivan Vasilov <vasilov.ivan@gmail.com>
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import { tool } from 'ai'
|
|
import { getDatabasePolicies } from 'data/database-policies/database-policies-query'
|
|
import { z } from 'zod'
|
|
|
|
export const getSchemaTools = ({
|
|
projectRef,
|
|
connectionString,
|
|
authorization,
|
|
}: {
|
|
projectRef: string
|
|
connectionString: string
|
|
authorization?: string
|
|
}) => ({
|
|
list_policies: tool({
|
|
description: 'Get existing RLS policies for a given schema',
|
|
inputSchema: z.object({
|
|
schemas: z.array(z.string()).describe('The schema names to get the policies for'),
|
|
}),
|
|
execute: async ({ schemas }) => {
|
|
const data = await getDatabasePolicies(
|
|
{
|
|
projectRef,
|
|
connectionString,
|
|
schema: schemas?.join(','),
|
|
},
|
|
undefined,
|
|
{
|
|
'Content-Type': 'application/json',
|
|
...(authorization && { Authorization: authorization }),
|
|
}
|
|
)
|
|
|
|
const formattedPolicies = data
|
|
.map(
|
|
(policy) => `
|
|
Policy Name: "${policy.name}"
|
|
Action: ${policy.action}
|
|
Roles: ${policy.roles.join(', ')}
|
|
Command: ${policy.command}
|
|
Definition: ${policy.definition}
|
|
${policy.check ? `Check: ${policy.check}` : ''}
|
|
`
|
|
)
|
|
.join('\n')
|
|
|
|
return formattedPolicies
|
|
},
|
|
}),
|
|
})
|