getRealtimePolicyTemplates() — supabase Function Reference
Architecture documentation for the getRealtimePolicyTemplates() function in PolicyEditorModal.constants.ts from the supabase codebase.
Entity Profile
Dependency Diagram
graph TD ecb0f3a7_06fa_5c8f_550b_082738463a11["getRealtimePolicyTemplates()"] 5cae6a1d_d69a_57ce_077f_d3f1a4cc0bff["PolicyTemplates()"] 5cae6a1d_d69a_57ce_077f_d3f1a4cc0bff -->|calls| ecb0f3a7_06fa_5c8f_550b_082738463a11 style ecb0f3a7_06fa_5c8f_550b_082738463a11 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
apps/studio/components/interfaces/Auth/Policies/PolicyEditorModal/PolicyEditorModal.constants.ts lines 176–308
export const getRealtimePolicyTemplates = (): PolicyTemplate[] => {
const results = [
{
id: 'policy-broadcast-1',
preview: false,
templateName: 'Allow listening for broadcasts for authenticated users only',
description: 'This policy allows listening for broadcasts for authenticated users only.',
statement: `
create policy "Allow listening for broadcasts for authenticated users only"
on realtime.messages for select
to authenticated
using ( realtime.messages.extension = 'broadcast' );`.trim(),
name: 'Allow listening for broadcasts for authenticated users only',
definition: "realtime.messages.extension = 'broadcast'",
check: '',
command: 'SELECT',
roles: ['authenticated'],
},
{
id: 'policy-broadcast-2',
preview: false,
templateName: 'Allow pushing broadcasts for authenticated users only',
description: 'This policy allows pushing broadcasts for authenticated users only.',
statement: `
create policy "Allow pushing broadcasts for authenticated users only"
ON realtime.messages for insert
TO authenticated
with check ( realtime.messages.extension = 'broadcast' );`.trim(),
name: 'Allow pushing broadcasts for authenticated users only',
definition: "realtime.messages.extension = 'broadcast'",
check: "realtime.messages.extension = 'broadcast'",
command: 'INSERT',
roles: ['authenticated'],
},
{
id: 'policy-broadcast-3',
preview: false,
templateName: 'Allow listening for broadcasts from a specific channel',
description: 'This policy allows listening for broadcasts from a specific channel.',
statement: `
create policy "Allow listening for broadcasts from a specific channel"
on realtime.messages for select
using ( realtime.messages.extension = 'broadcast' AND realtime.topic() = 'channel_name' );`.trim(),
name: 'Allow listening for broadcasts from a specific channel',
definition: `realtime.messages.extension = 'broadcast' AND realtime.topic() = 'channel_name'`,
check: '',
command: 'SELECT',
roles: [],
},
{
id: 'policy-broadcast-4',
preview: false,
templateName: 'Allow pushing broadcasts to specific channel',
description: 'This policy allow pushing broadcasts to specific channel.',
statement: `
create policy "Allow pushing broadcasts to specific channel"
ON realtime.messages for insert
with check ( realtime.messages.extension = 'broadcast' AND realtime.topic() = 'channel_name' );`.trim(),
name: 'Allow pushing broadcasts to specific channel',
definition: `realtime.messages.extension = 'broadcast' AND realtime.topic() = 'channel_name'`,
check: `realtime.messages.extension = 'broadcast' AND realtime.topic() = 'channel_name'`,
command: 'INSERT',
roles: [],
},
{
id: 'policy-presences-1',
preview: false,
templateName: 'Allow listening for presences on all channels for authenticated users only',
description:
'This policy enables listening for presences on all channels for all authenticated users only.',
statement: `
create policy "Allow listening for presences on all channels for authenticated users only"
on realtime.messages for select
to authenticated
using ( realtime.messages.extension = 'presence' );`.trim(),
name: 'Allow listening for presences on all channels for authenticated users only',
definition: "realtime.messages.extension = 'presence'",
check: '',
command: 'SELECT',
roles: ['authenticated'],
},
{
id: 'policy-presences-2',
preview: false,
templateName: 'Allow broadcasting presences on all channels for authenticated users only',
description:
'This policy enables broadcasting presences on all channels for all authenticated users only.',
statement: `
create policy "Allow broadcasting presences on all channels for authenticated users only"
ON realtime.messages for insert
TO authenticated
with check ( realtime.messages.extension = 'presence' );
;`.trim(),
name: 'Allow broadcasting presences on all channels for authenticated users only',
definition: "realtime.messages.extension = 'presence'",
check: "realtime.messages.extension = 'presence'",
command: 'INSERT',
roles: ['authenticated'],
},
{
id: 'policy-presences-3',
preview: false,
templateName: 'Allow listening for presences from a specific channel',
description: 'This policy enables listening for presences from a specific channel.',
statement: `
create policy "Allow listening for presences from a specific channel"
on realtime.messages for select
using ( realtime.messages.extension = 'presence' AND realtime.topic() = 'channel_name' );`.trim(),
name: 'Allow listening for presences from a specific channel',
definition: `realtime.messages.extension = 'presence' AND realtime.topic() = 'channel_name'`,
check: '',
command: 'SELECT',
roles: [],
},
{
id: 'policy-presences-4',
preview: false,
templateName: 'Publish presence to a specific channel',
description: 'This policy allows publishing presence to a specific channel.',
statement: `
create policy "Publish presence to a specific channel"
ON realtime.messages for insert
with check ( realtime.messages.extension = 'presence' AND realtime.topic() = 'channel_name' );
;`.trim(),
name: 'Publish presence to a specific channel',
definition: `realtime.messages.extension = 'presence' AND realtime.topic() = 'channel_name'`,
check: `realtime.messages.extension = 'presence' AND realtime.topic() = 'channel_name'`,
command: 'INSERT',
roles: [],
},
] as PolicyTemplate[]
return results
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does getRealtimePolicyTemplates() do?
getRealtimePolicyTemplates() is a function in the supabase codebase.
What calls getRealtimePolicyTemplates()?
getRealtimePolicyTemplates() is called by 1 function(s): PolicyTemplates.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free