mirror of
https://github.com/supabase/supabase.git
synced 2026-10-16 14:49:10 +03:00
* add edge function knowledge * deploy edge function mutaton * add edge function block with deploy * update function url * update tools * editor sql * add templates * use monaco editor * hook up templates * fixes * add behind feature flag * preview docs * move editor * initialPrompt * consolidate widgets * remove generic editor * move logic * fix ts * include schema metadata * Fix width of save snippet button * Set tooltip position * Use inlineLink component * Remove unnecessary z index * Lint * Lint import statements in EditorPanel * fixes * fix keyboard shortcut * show/hide results and invalidation * fix focus issues in widget * fixes * fix ts * Support cmd enter shortcut to run query in InlineEditor * Update InlineEditorPreview to use admonition * prompt updates * add discussion url to preview * schemas array * One last clean up --------- Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
23 lines
649 B
TypeScript
23 lines
649 B
TypeScript
import { PostgresPolicy } from '@supabase/postgres-meta'
|
|
|
|
export const generatePolicyCreateSQL = (policy: PostgresPolicy) => {
|
|
let expression = ''
|
|
if (policy.definition !== null && policy.definition !== undefined) {
|
|
expression += `USING (${policy.definition})${
|
|
policy.check === null || policy.check === undefined ? ';' : ''
|
|
}\n`
|
|
}
|
|
if (policy.check !== null && policy.check !== undefined) {
|
|
expression += `WITH CHECK (${policy.check});\n`
|
|
}
|
|
|
|
return `
|
|
ALTER POLICY "${policy.name}"
|
|
ON "${policy.schema}"."${policy.table}"
|
|
AS ${policy.action}
|
|
FOR ${policy.command}
|
|
TO ${policy.roles.join(', ')}
|
|
${expression}
|
|
`.trim()
|
|
}
|