bunderstack-sync 0.17.0-beta.0 → 0.17.0-beta.2

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
@@ -17,7 +17,7 @@ const api = createSyncClient<App>({ queryClient })
17
17
 
18
18
  const allPosts = api.posts.collection
19
19
  const feed = api.posts.scopedCollection({
20
- filter: { replyToId: null },
20
+ filters: { replyToId: null },
21
21
  sort: 'createdAt',
22
22
  order: 'desc',
23
23
  })
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "bunderstack-sync",
3
- "version": "0.17.0-beta.0",
3
+ "version": "0.17.0-beta.2",
4
4
  "description": "TanStack DB collections synchronized through Bunderstack's typed oRPC client and realtime iterator.",
5
5
  "keywords": [
6
6
  "bun",
7
7
  "bunderstack",
8
8
  "optimistic",
9
- "realtime",
10
9
  "orpc",
10
+ "realtime",
11
11
  "sync",
12
12
  "tanstack-db"
13
13
  ],
@@ -21,6 +21,7 @@
21
21
  "files": [
22
22
  "src",
23
23
  "!src/**/*.test.ts",
24
+ "!src/**/*.types.ts",
24
25
  "README.md",
25
26
  "LICENSE"
26
27
  ],
@@ -35,7 +36,7 @@
35
36
  "test": "bun test"
36
37
  },
37
38
  "dependencies": {
38
- "bunderstack-query": "^0.17.0-beta.0"
39
+ "bunderstack-query": "^0.17.0-beta.2"
39
40
  },
40
41
  "devDependencies": {
41
42
  "@tanstack/db": "0.6.16",
package/src/collection.ts CHANGED
@@ -62,8 +62,9 @@ export type ScopedFilterValue =
62
62
 
63
63
  export type ScopedCollectionOptions = {
64
64
  /** Equality filters, e.g. `{ replyToId: null }` — columns must be in the
65
- * table's `filterableColumns` server-side. */
66
- filter?: Record<string, ScopedFilterValue>
65
+ * table's `filterableColumns` server-side. Same name and shape as the
66
+ * `filters` accepted by the list procedure. */
67
+ filters?: Record<string, ScopedFilterValue>
67
68
  sort?: string
68
69
  order?: 'asc' | 'desc'
69
70
  /** Rows per underlying request; clamped to the server cap (200). */
@@ -74,9 +75,9 @@ export type ScopedCollectionOptions = {
74
75
 
75
76
  function matchesFilter(
76
77
  record: Record<string, unknown>,
77
- filter: Record<string, ScopedFilterValue>,
78
+ filters: Record<string, ScopedFilterValue>,
78
79
  ): boolean {
79
- for (const [col, expected] of Object.entries(filter)) {
80
+ for (const [col, expected] of Object.entries(filters)) {
80
81
  const actual = record[col]
81
82
  if (expected === null) {
82
83
  if (actual != null) return false
@@ -104,19 +105,7 @@ export function createTableCollection<
104
105
  >(config: TableCollectionConfig) {
105
106
  const table = config.procedures as TableProcedures<TRow, TCreate, TUpdate>
106
107
  const direct: DirectTableApi<TRow, TCreate, TUpdate> = {
107
- list(input = {}) {
108
- const { limit, offset, cursor, sort, order, q, count, ...filters } = input
109
- return table.list.call({
110
- limit,
111
- offset,
112
- cursor,
113
- sort,
114
- order,
115
- q,
116
- count,
117
- filters,
118
- })
119
- },
108
+ list: (input = {}) => table.list.call(input),
120
109
  get: (id) => table.get.call({ id: String(id) }),
121
110
  create: (input) => table.create.call(input),
122
111
  update: (id, input) =>
@@ -237,9 +226,9 @@ export function createTableCollection<
237
226
  MAX_LIST_LIMIT,
238
227
  )
239
228
  const initialCount = options.initialCount ?? 20
240
- const filter = options.filter ?? {}
229
+ const filters = options.filters ?? {}
241
230
  const cacheKey = stableKey({
242
- filter,
231
+ filters,
243
232
  sort: options.sort ?? null,
244
233
  order: options.order ?? null,
245
234
  pageSize,
@@ -266,7 +255,7 @@ export function createTableCollection<
266
255
  while (items.length < desiredCount) {
267
256
  const remaining = Math.min(pageSize, desiredCount - items.length)
268
257
  const page = await table.list.call({
269
- filters: filter,
258
+ ...(Object.keys(filters).length ? { filters } : {}),
270
259
  ...(options.sort ? { sort: options.sort } : {}),
271
260
  ...(options.order ? { order: options.order } : {}),
272
261
  limit: remaining,
@@ -296,7 +285,7 @@ export function createTableCollection<
296
285
  }
297
286
  registry.push({
298
287
  collection: scoped,
299
- matches: (record) => matchesFilter(record, filter),
288
+ matches: (record) => matchesFilter(record, filters),
300
289
  refetch: async () => {
301
290
  await scoped.utils.refetch()
302
291
  },
@@ -3,7 +3,6 @@ import {
3
3
  createClient,
4
4
  type AnyBunderstackApp,
5
5
  type BunderstackClient,
6
- type InferBuckets,
7
6
  type InferInsert,
8
7
  type InferSchema,
9
8
  type InferSelect,