bunderstack-sync 0.7.0 → 0.8.0
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/package.json +8 -4
- package/src/collection.ts +43 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunderstack-sync",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "TanStack DB collections synced live to a bunderstack backend: optimistic mutations with SSE-driven realtime sync.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bun",
|
|
@@ -35,8 +35,7 @@
|
|
|
35
35
|
"test": "bun test"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"bunderstack": "0.
|
|
39
|
-
"bunderstack-query": "0.1.0"
|
|
38
|
+
"bunderstack-query": "0.7.0"
|
|
40
39
|
},
|
|
41
40
|
"devDependencies": {
|
|
42
41
|
"@tanstack/db": "0.6.16",
|
|
@@ -50,6 +49,11 @@
|
|
|
50
49
|
"@tanstack/db": "0.6.16",
|
|
51
50
|
"@tanstack/query-db-collection": "1.1.0",
|
|
52
51
|
"@tanstack/react-query": "^5.101.0",
|
|
53
|
-
"typescript": "
|
|
52
|
+
"typescript": ">=5"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"typescript": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
54
58
|
}
|
|
55
59
|
}
|
package/src/collection.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createCollection,
|
|
3
|
+
type Collection,
|
|
4
|
+
type StandardSchema,
|
|
5
|
+
} from '@tanstack/db'
|
|
2
6
|
import { queryCollectionOptions } from '@tanstack/query-db-collection'
|
|
3
7
|
import type { QueryClient } from '@tanstack/react-query'
|
|
4
8
|
import {
|
|
@@ -294,8 +298,45 @@ export function createTableCollection<
|
|
|
294
298
|
}
|
|
295
299
|
}
|
|
296
300
|
|
|
301
|
+
export type ScopedCollection<TRow extends { id: string | number }> = {
|
|
302
|
+
collection: Collection<
|
|
303
|
+
TRow,
|
|
304
|
+
string | number,
|
|
305
|
+
Record<string, any>,
|
|
306
|
+
StandardSchema<TRow>
|
|
307
|
+
>
|
|
308
|
+
loadMore: (count?: number) => Promise<void>
|
|
309
|
+
hasMore: () => boolean
|
|
310
|
+
size: () => number
|
|
311
|
+
}
|
|
312
|
+
|
|
297
313
|
export type TableCollection<
|
|
298
314
|
TRow extends { id: string | number },
|
|
299
315
|
TCreate = Partial<TRow>,
|
|
300
316
|
TUpdate = Partial<TRow>,
|
|
301
|
-
> =
|
|
317
|
+
> = {
|
|
318
|
+
collection: Collection<
|
|
319
|
+
TRow,
|
|
320
|
+
string | number,
|
|
321
|
+
Record<string, any>,
|
|
322
|
+
StandardSchema<TRow>
|
|
323
|
+
>
|
|
324
|
+
table: TableClient<TRow, TCreate, TUpdate>
|
|
325
|
+
scopedCollection: (
|
|
326
|
+
options?: ScopedCollectionOptions,
|
|
327
|
+
) => ScopedCollection<TRow>
|
|
328
|
+
collectionByIds: (
|
|
329
|
+
ids: readonly (string | number)[],
|
|
330
|
+
column?: string,
|
|
331
|
+
) => Collection<
|
|
332
|
+
TRow,
|
|
333
|
+
string | number,
|
|
334
|
+
Record<string, any>,
|
|
335
|
+
StandardSchema<TRow>
|
|
336
|
+
>
|
|
337
|
+
applyRealtimeEvent: (
|
|
338
|
+
action: 'create' | 'update' | 'delete',
|
|
339
|
+
record: Record<string, unknown>,
|
|
340
|
+
) => void
|
|
341
|
+
refetchAll: () => Promise<void>
|
|
342
|
+
}
|