@techfinityedge/koolbase-react-native 4.2.0 → 4.2.1

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.
package/README.md CHANGED
@@ -297,26 +297,25 @@ await Koolbase.storage.delete('avatars', `user-${userId}.jpg`);
297
297
 
298
298
  ## Realtime
299
299
 
300
- Subscribe to live changes on a collection. Realtime uses the signed-in user's
301
- session, so subscribe after login. It streams `created` and `updated` events for
300
+ Subscribe to live changes on a collection. Uses the signed-in user's session, so
301
+ subscribe after login. Streams `created`, `updated`, and `deleted` events for
302
302
  collections whose read rule is `public` or `authenticated`.
303
303
 
304
304
  ```ts
305
- import { Koolbase } from '@techfinityedge/koolbase-react-native';
306
-
307
305
  const unsubscribe = Koolbase.realtime.subscribe('messages', (event) => {
308
- // event.type -> 'created' | 'updated'
309
- // event.collection -> 'messages'
310
- // event.record -> KoolbaseRecord
311
- console.log(event.type, event.record.data);
306
+ // event.type -> 'created' | 'updated' | 'deleted'
307
+ if (event.type === 'deleted') {
308
+ console.log('deleted', event.recordId); // recordId on deletes
309
+ } else {
310
+ console.log(event.type, event.record!.data); // record on created/updated
311
+ }
312
312
  });
313
313
 
314
- unsubscribe(); // stop listening
314
+ unsubscribe();
315
315
  ```
316
316
 
317
- The socket opens lazily on first `subscribe`, is shared across all subscriptions,
318
- and reconnects automatically. The project is taken from the user's session — you
319
- don't pass it.
317
+ The socket opens lazily, is shared, and reconnects automatically. The project is
318
+ taken from the user's session..
320
319
 
321
320
  ---
322
321
 
package/dist/realtime.js CHANGED
@@ -94,13 +94,18 @@ class KoolbaseRealtime {
94
94
  if (!mapped)
95
95
  return; // ignore subscribed / unsubscribed / error / unknown
96
96
  const payload = raw.payload;
97
- if (!payload || !payload.collection || !payload.record)
98
- return; // created/updated carry a record
99
- const msg = {
100
- type: mapped,
101
- collection: payload.collection,
102
- record: (0, record_1.recordFromWire)(payload.record),
103
- };
97
+ if (!payload || !payload.collection)
98
+ return;
99
+ let msg;
100
+ if (mapped === 'deleted') {
101
+ msg = { type: 'deleted', collection: payload.collection, recordId: payload.record_id };
102
+ }
103
+ else if (payload.record) {
104
+ msg = { type: mapped, collection: payload.collection, record: (0, record_1.recordFromWire)(payload.record) };
105
+ }
106
+ else {
107
+ return;
108
+ }
104
109
  (this.listeners.get(payload.collection) ?? []).forEach((cb) => cb(msg));
105
110
  };
106
111
  ws.onclose = () => {
package/dist/types.d.ts CHANGED
@@ -160,7 +160,8 @@ export interface UploadOptions {
160
160
  export interface RealtimeEvent {
161
161
  type: 'created' | 'updated' | 'deleted';
162
162
  collection: string;
163
- record: KoolbaseRecord;
163
+ record?: KoolbaseRecord;
164
+ recordId?: string;
164
165
  }
165
166
  export type RealtimeCallback = (event: RealtimeEvent) => void;
166
167
  export interface BootstrapPayload {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@techfinityedge/koolbase-react-native",
3
- "version": "4.2.0",
3
+ "version": "4.2.1",
4
4
  "description": "React Native SDK for Koolbase — auth, database, storage, realtime, feature flags, and functions in one package.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",