Commit c40fa93
committed
feat: use Sync Streams
# Sync Stream Migration Notes
## Motivation
This commit moves the E2EE chat demo from bucket-based sync rules to Sync Streams. The old buckets made every membership-derived dataset fan out automatically, which over-fetched encrypted payloads and forced the client to juggle parameter state. Streams let us subscribe only to the data that matters, lean on edition 2 features such as `waitForStream`, and keep the SQL definitions closer to the row-level security policies already in place.
## High-Level Changes
**PowerSync configuration.** `packages/e2ee-chat/infra/powersync/sync_rules.yaml` was replaced by `packages/e2ee-chat/infra/powersync/sync_streams.yaml`. Auto-subscribed streams now serve vault keys, identity keypairs, membership rows, room metadata, and wrapped room keys, while parameterized streams (`room_members`, `room_messages`) accept a `room_id` so the client only syncs an active room.
**Frontend integration.** The frontend now depends on `@powersync/common@1.39.0`, `@powersync/react@1.8.0`, and `@powersync/web@1.27.0`. `useQuery` calls pass stream descriptors (for example `USER_VAULT_KEYS_STREAM` and `ROOM_DETAILS_STREAM`) together with `waitForStream: true`, ensuring the initial dataset arrives before the UI renders. `useStatus` tracks `hasSynced` to gate decryption work until a stream confirms its first batch.
**Developer experience.** Stream SQL can use subqueries to double-check membership before delivering rows—something bucket parameters could not express—so the security posture matches our expectations while the client code becomes simpler.
## Opportunities
Streams expose lifecycle control that we can surface in the product. We can preload priority rooms or defer low-traffic ones to trim bandwidth, bolt on new capabilities like presence or typing indicators as additional streams, and wire `useStatus().forStream(...)` into tooling to highlight sync health. Because the SQL now lives in a single stream file, evolving RLS filters or role-based access checks should stay straightforward.1 parent 8cfcbec commit c40fa93
6 files changed
Lines changed: 197 additions & 83 deletions
File tree
- packages/e2ee-chat
- frontend
- src
- infra/powersync
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | | - | |
98 | | - | |
99 | | - | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
34 | | - | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | | - | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
81 | 86 | | |
82 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
83 | 91 | | |
84 | 92 | | |
85 | 93 | | |
86 | 94 | | |
87 | 95 | | |
88 | 96 | | |
89 | 97 | | |
| 98 | + | |
90 | 99 | | |
91 | | - | |
| 100 | + | |
92 | 101 | | |
93 | 102 | | |
94 | 103 | | |
| |||
127 | 136 | | |
128 | 137 | | |
129 | 138 | | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
130 | 146 | | |
131 | 147 | | |
132 | 148 | | |
133 | 149 | | |
| 150 | + | |
134 | 151 | | |
135 | 152 | | |
136 | 153 | | |
| |||
147 | 164 | | |
148 | 165 | | |
149 | 166 | | |
150 | | - | |
151 | 167 | | |
152 | 168 | | |
153 | 169 | | |
| |||
212 | 228 | | |
213 | 229 | | |
214 | 230 | | |
215 | | - | |
216 | 231 | | |
217 | 232 | | |
218 | | - | |
219 | 233 | | |
220 | 234 | | |
221 | 235 | | |
| |||
238 | 252 | | |
239 | 253 | | |
240 | 254 | | |
241 | | - | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
242 | 261 | | |
243 | 262 | | |
244 | 263 | | |
| |||
305 | 324 | | |
306 | 325 | | |
307 | 326 | | |
308 | | - | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
309 | 333 | | |
310 | 334 | | |
311 | 335 | | |
| |||
368 | 392 | | |
369 | 393 | | |
370 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
371 | 411 | | |
372 | 412 | | |
373 | 413 | | |
374 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
375 | 420 | | |
376 | 421 | | |
377 | 422 | | |
| |||
407 | 452 | | |
408 | 453 | | |
409 | 454 | | |
410 | | - | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
411 | 461 | | |
412 | 462 | | |
413 | 463 | | |
| |||
420 | 470 | | |
421 | 471 | | |
422 | 472 | | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
423 | 483 | | |
424 | 484 | | |
425 | 485 | | |
| |||
715 | 775 | | |
716 | 776 | | |
717 | 777 | | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
718 | 785 | | |
719 | 786 | | |
720 | 787 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
0 commit comments