fix(realtime): add generic overload for postgres_changes event type
Adds a generic overload for on() with postgres_changes that accepts any event type, enabling reusable subscription helpers with union types like '*' | 'INSERT' | 'UPDATE' | 'DELETE'.
Fixes "No overload matches this call" error when passing generic event parameters to channel.on('postgres_changes', ...).
closes https://github.com/supabase/supabase-js/issues/1451
coverage: 95.349% (+14.0%) from 81.389% when pulling eaf16eff728faf2708c048e3404f22f0c9368e17 on 7ttp:fix/realtime11 into 30f96004cf1c9f18abd55c21bcecb2f360effc72 on supabase:master.
@7ttp thank you for this PR. Can you please add a test for the new functionality? It can go in packages/core/realtime-js/test/RealtimeChannel.postgres.test.ts. Something like:
...
const event: '*' | 'INSERT' | 'UPDATE' | 'DELETE' = 'INSERT'
// This should compile without errors (previously required `as any`)
channel.on(
'postgres_changes',
{
event,
schema: 'public',
table: 'users',
},
...
)
...
expect(channel.bindings.postgres_changes.length).toBe(1)
...
@mandarini could u please have a look at this now! and let me know if anything else is required 😁💚
@7ttp can you please rebase your PR with latest master? We made some updates in the workflows, and it will be blocked if you don't rebase