squarefi-bff-api-module 1.36.14 → 1.36.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,4 @@
1
1
  export const createWalletTransactionsConfig = (walletId) => ({
2
2
  channelName: `wallet-transactions-${walletId}`,
3
- table: 'transactions',
4
- filter: `wallet_id=eq.${walletId}`,
3
+ event: 'tx',
5
4
  });
@@ -1,9 +1,7 @@
1
1
  export interface SubscriptionConfig {
2
2
  channelName: string;
3
- table: string;
4
- schema?: string;
5
- event?: 'INSERT' | 'UPDATE' | 'DELETE' | '*';
6
- filter?: string;
3
+ /** Broadcast event name emitted by the database trigger (realtime.send). */
4
+ event: string;
7
5
  }
8
6
  export interface UseSupabaseSubscriptionProps {
9
7
  config: SubscriptionConfig;
@@ -13,14 +13,12 @@ export const useSupabaseSubscription = ({ config, callback, enabled = true, key
13
13
  supabaseClient.removeChannel(subscriptionRef.current);
14
14
  subscriptionRef.current = null;
15
15
  }
16
+ // The channel name IS the broadcast topic — it must match what the DB trigger sends
17
+ // (`wallet-transactions-<walletId>`). `key` only re-triggers the effect (see deps), it must
18
+ // never override the topic, otherwise the client subscribes to the wrong channel.
16
19
  const subscription = supabaseClient
17
- .channel(key || config.channelName)
18
- .on('postgres_changes', {
19
- event: config.event || '*',
20
- schema: config.schema || 'public',
21
- table: config.table,
22
- ...(config.filter && { filter: config.filter }),
23
- }, (payload) => callbackRef.current(payload))
20
+ .channel(config.channelName, { config: { private: true } })
21
+ .on('broadcast', { event: config.event }, (payload) => callbackRef.current(payload))
24
22
  .subscribe();
25
23
  subscriptionRef.current = subscription;
26
24
  return () => {
@@ -29,7 +27,7 @@ export const useSupabaseSubscription = ({ config, callback, enabled = true, key
29
27
  subscriptionRef.current = null;
30
28
  }
31
29
  };
32
- }, [enabled, config.channelName, config.table, config.schema, config.event, config.filter, supabaseClient, key]);
30
+ }, [enabled, config.channelName, config.event, supabaseClient, key]);
33
31
  return {
34
32
  isConnected: !!subscriptionRef.current,
35
33
  isClientAvailable: !!supabaseClient,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "squarefi-bff-api-module",
3
- "version": "1.36.14",
3
+ "version": "1.36.16",
4
4
  "description": "Squarefi BFF API client module",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",