@powersync/service-module-postgres-storage 0.18.0 → 0.19.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.
Files changed (64) hide show
  1. package/CHANGELOG.md +39 -0
  2. package/dist/migrations/scripts/1788000000000-sync-config-version-label.d.ts +3 -0
  3. package/dist/migrations/scripts/1788000000000-sync-config-version-label.js +12 -0
  4. package/dist/migrations/scripts/1788000000000-sync-config-version-label.js.map +1 -0
  5. package/dist/storage/PostgresBucketStorageFactory.d.ts +1 -0
  6. package/dist/storage/PostgresBucketStorageFactory.js +14 -7
  7. package/dist/storage/PostgresBucketStorageFactory.js.map +1 -1
  8. package/dist/storage/PostgresStorageProvider.js +2 -1
  9. package/dist/storage/PostgresStorageProvider.js.map +1 -1
  10. package/dist/storage/PostgresSyncRulesStorage.d.ts +4 -3
  11. package/dist/storage/PostgresSyncRulesStorage.js +17 -5
  12. package/dist/storage/PostgresSyncRulesStorage.js.map +1 -1
  13. package/dist/storage/batch/PostgresBucketBatch.d.ts +2 -2
  14. package/dist/storage/batch/PostgresBucketBatch.js +8 -5
  15. package/dist/storage/batch/PostgresBucketBatch.js.map +1 -1
  16. package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.d.ts +1 -1
  17. package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js +2 -2
  18. package/dist/storage/checkpoints/PostgresWriteCheckpointAPI.js.map +1 -1
  19. package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.js +5 -1
  20. package/dist/storage/sync-rules/PostgresPersistedSyncConfigContent.js.map +1 -1
  21. package/dist/types/models/ActiveCheckpoint.d.ts +2 -2
  22. package/dist/types/models/ActiveCheckpoint.js +3 -2
  23. package/dist/types/models/ActiveCheckpoint.js.map +1 -1
  24. package/dist/types/models/ActiveCheckpointNotification.d.ts +2 -2
  25. package/dist/types/models/BucketData.d.ts +6 -6
  26. package/dist/types/models/BucketData.js +7 -6
  27. package/dist/types/models/BucketData.js.map +1 -1
  28. package/dist/types/models/CurrentData.d.ts +1 -1
  29. package/dist/types/models/CurrentData.js +2 -1
  30. package/dist/types/models/CurrentData.js.map +1 -1
  31. package/dist/types/models/SdkReporting.d.ts +3 -3
  32. package/dist/types/models/SdkReporting.js +3 -5
  33. package/dist/types/models/SdkReporting.js.map +1 -1
  34. package/dist/types/models/SourceTable.d.ts +7 -7
  35. package/dist/types/models/SourceTable.js +7 -6
  36. package/dist/types/models/SourceTable.js.map +1 -1
  37. package/dist/types/models/SyncRules.d.ts +11 -10
  38. package/dist/types/models/SyncRules.js +12 -11
  39. package/dist/types/models/SyncRules.js.map +1 -1
  40. package/dist/types/models/WriteCheckpoint.d.ts +2 -2
  41. package/dist/types/models/WriteCheckpoint.js +3 -2
  42. package/dist/types/models/WriteCheckpoint.js.map +1 -1
  43. package/dist/types/types.d.ts +2 -0
  44. package/package.json +8 -8
  45. package/src/migrations/scripts/1788000000000-sync-config-version-label.ts +18 -0
  46. package/src/storage/PostgresBucketStorageFactory.ts +15 -7
  47. package/src/storage/PostgresStorageProvider.ts +2 -1
  48. package/src/storage/PostgresSyncRulesStorage.ts +21 -6
  49. package/src/storage/batch/PostgresBucketBatch.ts +9 -6
  50. package/src/storage/checkpoints/PostgresWriteCheckpointAPI.ts +2 -2
  51. package/src/storage/sync-rules/PostgresPersistedSyncConfigContent.ts +8 -1
  52. package/src/types/models/ActiveCheckpoint.ts +3 -2
  53. package/src/types/models/BucketData.ts +7 -6
  54. package/src/types/models/CurrentData.ts +2 -1
  55. package/src/types/models/SdkReporting.ts +4 -4
  56. package/src/types/models/SourceTable.ts +7 -6
  57. package/src/types/models/SyncRules.ts +12 -11
  58. package/src/types/models/WriteCheckpoint.ts +3 -2
  59. package/test/src/__snapshots__/storage_sync.test.ts.snap +0 -995
  60. package/test/src/checkpoint_notifications.test.ts +8 -2
  61. package/test/src/storage.test.ts +12 -4
  62. package/test/src/storage_compacting.test.ts +2 -2
  63. package/test/src/util.ts +1 -1
  64. package/tsconfig.tsbuildinfo +1 -1
@@ -1989,998 +1989,3 @@ exports[`sync - postgres > storage v2 > sync updates to parameter query only 2`]
1989
1989
  },
1990
1990
  ]
1991
1991
  `;
1992
-
1993
- exports[`sync - postgres > storage v3 > can override priority when subscribing to stream 1`] = `
1994
- [
1995
- {
1996
- "checkpoint": {
1997
- "buckets": [
1998
- {
1999
- "bucket": "1#todos|0["a"]",
2000
- "checksum": -1712802421,
2001
- "count": 1,
2002
- "priority": 0,
2003
- "subscriptions": [
2004
- {
2005
- "sub": 0,
2006
- },
2007
- {
2008
- "sub": 1,
2009
- },
2010
- ],
2011
- },
2012
- {
2013
- "bucket": "1#todos|0["b"]",
2014
- "checksum": -1291414318,
2015
- "count": 1,
2016
- "priority": 3,
2017
- "subscriptions": [
2018
- {
2019
- "sub": 1,
2020
- },
2021
- ],
2022
- },
2023
- ],
2024
- "last_op_id": "2",
2025
- "streams": [
2026
- {
2027
- "errors": [],
2028
- "is_default": false,
2029
- "name": "todos",
2030
- },
2031
- ],
2032
- "write_checkpoint": undefined,
2033
- },
2034
- },
2035
- {
2036
- "data": {
2037
- "after": "0",
2038
- "bucket": "1#todos|0["a"]",
2039
- "data": [
2040
- {
2041
- "checksum": 2582164875,
2042
- "data": "{"id":"a","description":"Test 1"}",
2043
- "object_id": "a",
2044
- "object_type": "test",
2045
- "op": "PUT",
2046
- "op_id": "1",
2047
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2048
- },
2049
- ],
2050
- "has_more": false,
2051
- "next_after": "1",
2052
- },
2053
- },
2054
- {
2055
- "partial_checkpoint_complete": {
2056
- "last_op_id": "2",
2057
- "priority": 0,
2058
- },
2059
- },
2060
- {
2061
- "data": {
2062
- "after": "0",
2063
- "bucket": "1#todos|0["b"]",
2064
- "data": [
2065
- {
2066
- "checksum": 3003552978,
2067
- "data": "{"id":"b","description":"Test 2"}",
2068
- "object_id": "b",
2069
- "object_type": "test",
2070
- "op": "PUT",
2071
- "op_id": "2",
2072
- "subkey": "243b0e26-87b2-578a-993c-5ac5b6f7fd64",
2073
- },
2074
- ],
2075
- "has_more": false,
2076
- "next_after": "2",
2077
- },
2078
- },
2079
- {
2080
- "checkpoint_complete": {
2081
- "last_op_id": "2",
2082
- },
2083
- },
2084
- ]
2085
- `;
2086
-
2087
- exports[`sync - postgres > storage v3 > compacting data - invalidate checkpoint 1`] = `
2088
- [
2089
- {
2090
- "checkpoint": {
2091
- "buckets": [
2092
- {
2093
- "bucket": "1#mybucket[]",
2094
- "checksum": -93886621,
2095
- "count": 2,
2096
- "priority": 3,
2097
- "subscriptions": [
2098
- {
2099
- "default": 0,
2100
- },
2101
- ],
2102
- },
2103
- ],
2104
- "last_op_id": "2",
2105
- "streams": [
2106
- {
2107
- "errors": [],
2108
- "is_default": true,
2109
- "name": "mybucket",
2110
- },
2111
- ],
2112
- "write_checkpoint": undefined,
2113
- },
2114
- },
2115
- ]
2116
- `;
2117
-
2118
- exports[`sync - postgres > storage v3 > compacting data - invalidate checkpoint 2`] = `
2119
- [
2120
- {
2121
- "data": {
2122
- "after": "0",
2123
- "bucket": "1#mybucket[]",
2124
- "data": [
2125
- {
2126
- "checksum": -93886621,
2127
- "op": "CLEAR",
2128
- "op_id": "2",
2129
- },
2130
- ],
2131
- "has_more": false,
2132
- "next_after": "2",
2133
- },
2134
- },
2135
- {
2136
- "checkpoint_diff": {
2137
- "last_op_id": "4",
2138
- "removed_buckets": [],
2139
- "updated_buckets": [
2140
- {
2141
- "bucket": "1#mybucket[]",
2142
- "checksum": 499012468,
2143
- "count": 4,
2144
- "priority": 3,
2145
- "subscriptions": [
2146
- {
2147
- "default": 0,
2148
- },
2149
- ],
2150
- },
2151
- ],
2152
- "write_checkpoint": undefined,
2153
- },
2154
- },
2155
- {
2156
- "data": {
2157
- "after": "2",
2158
- "bucket": "1#mybucket[]",
2159
- "data": [
2160
- {
2161
- "checksum": 1859363232,
2162
- "data": "{"id":"t1","description":"Test 1b"}",
2163
- "object_id": "t1",
2164
- "object_type": "test",
2165
- "op": "PUT",
2166
- "op_id": "3",
2167
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2168
- },
2169
- {
2170
- "checksum": 3028503153,
2171
- "data": "{"id":"t2","description":"Test 2b"}",
2172
- "object_id": "t2",
2173
- "object_type": "test",
2174
- "op": "PUT",
2175
- "op_id": "4",
2176
- "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
2177
- },
2178
- ],
2179
- "has_more": false,
2180
- "next_after": "4",
2181
- },
2182
- },
2183
- {
2184
- "checkpoint_complete": {
2185
- "last_op_id": "4",
2186
- },
2187
- },
2188
- ]
2189
- `;
2190
-
2191
- exports[`sync - postgres > storage v3 > encodes sync rules id in buckets for streams 1`] = `
2192
- [
2193
- {
2194
- "checkpoint": {
2195
- "buckets": [
2196
- {
2197
- "bucket": "1#test|0[]",
2198
- "checksum": 920318466,
2199
- "count": 1,
2200
- "priority": 3,
2201
- "subscriptions": [
2202
- {
2203
- "default": 0,
2204
- },
2205
- ],
2206
- },
2207
- ],
2208
- "last_op_id": "1",
2209
- "streams": [
2210
- {
2211
- "errors": [],
2212
- "is_default": true,
2213
- "name": "test",
2214
- },
2215
- ],
2216
- "write_checkpoint": undefined,
2217
- },
2218
- },
2219
- {
2220
- "data": {
2221
- "after": "0",
2222
- "bucket": "1#test|0[]",
2223
- "data": [
2224
- {
2225
- "checksum": 920318466,
2226
- "data": "{"id":"t1","description":"Test 1"}",
2227
- "object_id": "t1",
2228
- "object_type": "test",
2229
- "op": "PUT",
2230
- "op_id": "1",
2231
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2232
- },
2233
- ],
2234
- "has_more": false,
2235
- "next_after": "1",
2236
- },
2237
- },
2238
- {
2239
- "checkpoint_complete": {
2240
- "last_op_id": "1",
2241
- },
2242
- },
2243
- ]
2244
- `;
2245
-
2246
- exports[`sync - postgres > storage v3 > encodes sync rules id in buckets for streams 2`] = `
2247
- [
2248
- {
2249
- "checkpoint": {
2250
- "buckets": [
2251
- {
2252
- "bucket": "2#test2|0[]",
2253
- "checksum": 920318466,
2254
- "count": 1,
2255
- "priority": 3,
2256
- "subscriptions": [
2257
- {
2258
- "default": 0,
2259
- },
2260
- ],
2261
- },
2262
- ],
2263
- "last_op_id": "2",
2264
- "streams": [
2265
- {
2266
- "errors": [],
2267
- "is_default": true,
2268
- "name": "test2",
2269
- },
2270
- ],
2271
- "write_checkpoint": undefined,
2272
- },
2273
- },
2274
- {
2275
- "data": {
2276
- "after": "0",
2277
- "bucket": "2#test2|0[]",
2278
- "data": [
2279
- {
2280
- "checksum": 920318466,
2281
- "data": "{"id":"t1","description":"Test 1"}",
2282
- "object_id": "t1",
2283
- "object_type": "test",
2284
- "op": "PUT",
2285
- "op_id": "2",
2286
- "subkey": "8a5f3fdd-3f59-5153-92ae-ac115c458441",
2287
- },
2288
- ],
2289
- "has_more": false,
2290
- "next_after": "2",
2291
- },
2292
- },
2293
- {
2294
- "checkpoint_complete": {
2295
- "last_op_id": "2",
2296
- },
2297
- },
2298
- ]
2299
- `;
2300
-
2301
- exports[`sync - postgres > storage v3 > expired token 1`] = `
2302
- [
2303
- {
2304
- "token_expires_in": 0,
2305
- },
2306
- ]
2307
- `;
2308
-
2309
- exports[`sync - postgres > storage v3 > expiring token 1`] = `
2310
- [
2311
- {
2312
- "checkpoint": {
2313
- "buckets": [
2314
- {
2315
- "bucket": "1#mybucket[]",
2316
- "checksum": 0,
2317
- "count": 0,
2318
- "priority": 3,
2319
- "subscriptions": [
2320
- {
2321
- "default": 0,
2322
- },
2323
- ],
2324
- },
2325
- ],
2326
- "last_op_id": "0",
2327
- "streams": [
2328
- {
2329
- "errors": [],
2330
- "is_default": true,
2331
- "name": "mybucket",
2332
- },
2333
- ],
2334
- "write_checkpoint": undefined,
2335
- },
2336
- },
2337
- {
2338
- "checkpoint_complete": {
2339
- "last_op_id": "0",
2340
- },
2341
- },
2342
- ]
2343
- `;
2344
-
2345
- exports[`sync - postgres > storage v3 > expiring token 2`] = `
2346
- [
2347
- {
2348
- "token_expires_in": 0,
2349
- },
2350
- ]
2351
- `;
2352
-
2353
- exports[`sync - postgres > storage v3 > sends checkpoint complete line for empty checkpoint 1`] = `
2354
- [
2355
- {
2356
- "checkpoint": {
2357
- "buckets": [
2358
- {
2359
- "bucket": "1#mybucket[]",
2360
- "checksum": -1221282404,
2361
- "count": 1,
2362
- "priority": 3,
2363
- "subscriptions": [
2364
- {
2365
- "default": 0,
2366
- },
2367
- ],
2368
- },
2369
- ],
2370
- "last_op_id": "1",
2371
- "streams": [
2372
- {
2373
- "errors": [],
2374
- "is_default": true,
2375
- "name": "mybucket",
2376
- },
2377
- ],
2378
- "write_checkpoint": undefined,
2379
- },
2380
- },
2381
- {
2382
- "data": {
2383
- "after": "0",
2384
- "bucket": "1#mybucket[]",
2385
- "data": [
2386
- {
2387
- "checksum": 3073684892,
2388
- "data": "{"id":"t1","description":"sync"}",
2389
- "object_id": "t1",
2390
- "object_type": "test",
2391
- "op": "PUT",
2392
- "op_id": "1",
2393
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2394
- },
2395
- ],
2396
- "has_more": false,
2397
- "next_after": "1",
2398
- },
2399
- },
2400
- null,
2401
- {
2402
- "checkpoint_complete": {
2403
- "last_op_id": "1",
2404
- },
2405
- },
2406
- {
2407
- "checkpoint_diff": {
2408
- "last_op_id": "1",
2409
- "removed_buckets": [],
2410
- "updated_buckets": [],
2411
- "write_checkpoint": "1",
2412
- },
2413
- },
2414
- {
2415
- "checkpoint_complete": {
2416
- "last_op_id": "1",
2417
- },
2418
- },
2419
- ]
2420
- `;
2421
-
2422
- exports[`sync - postgres > storage v3 > sync buckets in order 1`] = `
2423
- [
2424
- {
2425
- "checkpoint": {
2426
- "buckets": [
2427
- {
2428
- "bucket": "1#b0[]",
2429
- "checksum": 920318466,
2430
- "count": 1,
2431
- "priority": 2,
2432
- "subscriptions": [
2433
- {
2434
- "default": 0,
2435
- },
2436
- ],
2437
- },
2438
- {
2439
- "bucket": "1#b1[]",
2440
- "checksum": -1382098757,
2441
- "count": 1,
2442
- "priority": 1,
2443
- "subscriptions": [
2444
- {
2445
- "default": 1,
2446
- },
2447
- ],
2448
- },
2449
- ],
2450
- "last_op_id": "2",
2451
- "streams": [
2452
- {
2453
- "errors": [],
2454
- "is_default": true,
2455
- "name": "b0",
2456
- },
2457
- {
2458
- "errors": [],
2459
- "is_default": true,
2460
- "name": "b1",
2461
- },
2462
- ],
2463
- "write_checkpoint": undefined,
2464
- },
2465
- },
2466
- {
2467
- "data": {
2468
- "after": "0",
2469
- "bucket": "1#b1[]",
2470
- "data": [
2471
- {
2472
- "checksum": 2912868539,
2473
- "data": "{"id":"earlier","description":"Test 2"}",
2474
- "object_id": "earlier",
2475
- "object_type": "test",
2476
- "op": "PUT",
2477
- "op_id": "2",
2478
- "subkey": "243b0e26-87b2-578a-993c-5ac5b6f7fd64",
2479
- },
2480
- ],
2481
- "has_more": false,
2482
- "next_after": "2",
2483
- },
2484
- },
2485
- {
2486
- "partial_checkpoint_complete": {
2487
- "last_op_id": "2",
2488
- "priority": 1,
2489
- },
2490
- },
2491
- {
2492
- "data": {
2493
- "after": "0",
2494
- "bucket": "1#b0[]",
2495
- "data": [
2496
- {
2497
- "checksum": 920318466,
2498
- "data": "{"id":"t1","description":"Test 1"}",
2499
- "object_id": "t1",
2500
- "object_type": "test",
2501
- "op": "PUT",
2502
- "op_id": "1",
2503
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2504
- },
2505
- ],
2506
- "has_more": false,
2507
- "next_after": "1",
2508
- },
2509
- },
2510
- {
2511
- "checkpoint_complete": {
2512
- "last_op_id": "2",
2513
- },
2514
- },
2515
- ]
2516
- `;
2517
-
2518
- exports[`sync - postgres > storage v3 > sync global data 1`] = `
2519
- [
2520
- {
2521
- "checkpoint": {
2522
- "buckets": [
2523
- {
2524
- "bucket": "1#mybucket[]",
2525
- "checksum": -93886621,
2526
- "count": 2,
2527
- "priority": 3,
2528
- "subscriptions": [
2529
- {
2530
- "default": 0,
2531
- },
2532
- ],
2533
- },
2534
- ],
2535
- "last_op_id": "2",
2536
- "streams": [
2537
- {
2538
- "errors": [],
2539
- "is_default": true,
2540
- "name": "mybucket",
2541
- },
2542
- ],
2543
- "write_checkpoint": undefined,
2544
- },
2545
- },
2546
- {
2547
- "data": {
2548
- "after": "0",
2549
- "bucket": "1#mybucket[]",
2550
- "data": [
2551
- {
2552
- "checksum": 920318466,
2553
- "data": "{"id":"t1","description":"Test 1"}",
2554
- "object_id": "t1",
2555
- "object_type": "test",
2556
- "op": "PUT",
2557
- "op_id": "1",
2558
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2559
- },
2560
- {
2561
- "checksum": 3280762209,
2562
- "data": "{"id":"t2","description":"Test 2"}",
2563
- "object_id": "t2",
2564
- "object_type": "test",
2565
- "op": "PUT",
2566
- "op_id": "2",
2567
- "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
2568
- },
2569
- ],
2570
- "has_more": false,
2571
- "next_after": "2",
2572
- },
2573
- },
2574
- {
2575
- "checkpoint_complete": {
2576
- "last_op_id": "2",
2577
- },
2578
- },
2579
- ]
2580
- `;
2581
-
2582
- exports[`sync - postgres > storage v3 > sync legacy non-raw data 1`] = `
2583
- [
2584
- {
2585
- "checkpoint": {
2586
- "buckets": [
2587
- {
2588
- "bucket": "1#mybucket[]",
2589
- "checksum": -852817836,
2590
- "count": 1,
2591
- "priority": 3,
2592
- "subscriptions": [
2593
- {
2594
- "default": 0,
2595
- },
2596
- ],
2597
- },
2598
- ],
2599
- "last_op_id": "1",
2600
- "streams": [
2601
- {
2602
- "errors": [],
2603
- "is_default": true,
2604
- "name": "mybucket",
2605
- },
2606
- ],
2607
- "write_checkpoint": undefined,
2608
- },
2609
- },
2610
- {
2611
- "data": {
2612
- "after": "0",
2613
- "bucket": "1#mybucket[]",
2614
- "data": [
2615
- {
2616
- "checksum": 3442149460n,
2617
- "data": {
2618
- "description": "Test
2619
- "string"",
2620
- "id": "t1",
2621
- "large_num": 12345678901234567890n,
2622
- },
2623
- "object_id": "t1",
2624
- "object_type": "test",
2625
- "op": "PUT",
2626
- "op_id": "1",
2627
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2628
- },
2629
- ],
2630
- "has_more": false,
2631
- "next_after": "1",
2632
- },
2633
- },
2634
- {
2635
- "checkpoint_complete": {
2636
- "last_op_id": "1",
2637
- },
2638
- },
2639
- ]
2640
- `;
2641
-
2642
- exports[`sync - postgres > storage v3 > sync updates to data query only 1`] = `
2643
- [
2644
- {
2645
- "checkpoint": {
2646
- "buckets": [
2647
- {
2648
- "bucket": "1#by_user["user1"]",
2649
- "checksum": 0,
2650
- "count": 0,
2651
- "priority": 3,
2652
- "subscriptions": [
2653
- {
2654
- "default": 0,
2655
- },
2656
- ],
2657
- },
2658
- ],
2659
- "last_op_id": "1",
2660
- "streams": [
2661
- {
2662
- "errors": [],
2663
- "is_default": true,
2664
- "name": "by_user",
2665
- },
2666
- ],
2667
- "write_checkpoint": undefined,
2668
- },
2669
- },
2670
- {
2671
- "checkpoint_complete": {
2672
- "last_op_id": "1",
2673
- },
2674
- },
2675
- ]
2676
- `;
2677
-
2678
- exports[`sync - postgres > storage v3 > sync updates to data query only 2`] = `
2679
- [
2680
- {
2681
- "checkpoint_diff": {
2682
- "last_op_id": "2",
2683
- "removed_buckets": [],
2684
- "updated_buckets": [
2685
- {
2686
- "bucket": "1#by_user["user1"]",
2687
- "checksum": 1418351250,
2688
- "count": 1,
2689
- "priority": 3,
2690
- "subscriptions": [
2691
- {
2692
- "default": 0,
2693
- },
2694
- ],
2695
- },
2696
- ],
2697
- "write_checkpoint": undefined,
2698
- },
2699
- },
2700
- {
2701
- "data": {
2702
- "after": "0",
2703
- "bucket": "1#by_user["user1"]",
2704
- "data": [
2705
- {
2706
- "checksum": 1418351250,
2707
- "data": "{"id":"list1","user_id":"user1","name":"User 1"}",
2708
- "object_id": "list1",
2709
- "object_type": "lists",
2710
- "op": "PUT",
2711
- "op_id": "2",
2712
- "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
2713
- },
2714
- ],
2715
- "has_more": false,
2716
- "next_after": "2",
2717
- },
2718
- },
2719
- {
2720
- "checkpoint_complete": {
2721
- "last_op_id": "2",
2722
- },
2723
- },
2724
- ]
2725
- `;
2726
-
2727
- exports[`sync - postgres > storage v3 > sync updates to global data 1`] = `
2728
- [
2729
- {
2730
- "checkpoint": {
2731
- "buckets": [
2732
- {
2733
- "bucket": "1#mybucket[]",
2734
- "checksum": 0,
2735
- "count": 0,
2736
- "priority": 3,
2737
- "subscriptions": [
2738
- {
2739
- "default": 0,
2740
- },
2741
- ],
2742
- },
2743
- ],
2744
- "last_op_id": "0",
2745
- "streams": [
2746
- {
2747
- "errors": [],
2748
- "is_default": true,
2749
- "name": "mybucket",
2750
- },
2751
- ],
2752
- "write_checkpoint": undefined,
2753
- },
2754
- },
2755
- {
2756
- "checkpoint_complete": {
2757
- "last_op_id": "0",
2758
- },
2759
- },
2760
- ]
2761
- `;
2762
-
2763
- exports[`sync - postgres > storage v3 > sync updates to global data 2`] = `
2764
- [
2765
- {
2766
- "checkpoint_diff": {
2767
- "last_op_id": "1",
2768
- "removed_buckets": [],
2769
- "updated_buckets": [
2770
- {
2771
- "bucket": "1#mybucket[]",
2772
- "checksum": 920318466,
2773
- "count": 1,
2774
- "priority": 3,
2775
- "subscriptions": [
2776
- {
2777
- "default": 0,
2778
- },
2779
- ],
2780
- },
2781
- ],
2782
- "write_checkpoint": undefined,
2783
- },
2784
- },
2785
- {
2786
- "data": {
2787
- "after": "0",
2788
- "bucket": "1#mybucket[]",
2789
- "data": [
2790
- {
2791
- "checksum": 920318466,
2792
- "data": "{"id":"t1","description":"Test 1"}",
2793
- "object_id": "t1",
2794
- "object_type": "test",
2795
- "op": "PUT",
2796
- "op_id": "1",
2797
- "subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
2798
- },
2799
- ],
2800
- "has_more": false,
2801
- "next_after": "1",
2802
- },
2803
- },
2804
- {
2805
- "checkpoint_complete": {
2806
- "last_op_id": "1",
2807
- },
2808
- },
2809
- ]
2810
- `;
2811
-
2812
- exports[`sync - postgres > storage v3 > sync updates to global data 3`] = `
2813
- [
2814
- {
2815
- "checkpoint_diff": {
2816
- "last_op_id": "2",
2817
- "removed_buckets": [],
2818
- "updated_buckets": [
2819
- {
2820
- "bucket": "1#mybucket[]",
2821
- "checksum": -93886621,
2822
- "count": 2,
2823
- "priority": 3,
2824
- "subscriptions": [
2825
- {
2826
- "default": 0,
2827
- },
2828
- ],
2829
- },
2830
- ],
2831
- "write_checkpoint": undefined,
2832
- },
2833
- },
2834
- {
2835
- "data": {
2836
- "after": "1",
2837
- "bucket": "1#mybucket[]",
2838
- "data": [
2839
- {
2840
- "checksum": 3280762209,
2841
- "data": "{"id":"t2","description":"Test 2"}",
2842
- "object_id": "t2",
2843
- "object_type": "test",
2844
- "op": "PUT",
2845
- "op_id": "2",
2846
- "subkey": "a17e6883-d5d2-599d-a805-d60528127dbd",
2847
- },
2848
- ],
2849
- "has_more": false,
2850
- "next_after": "2",
2851
- },
2852
- },
2853
- {
2854
- "checkpoint_complete": {
2855
- "last_op_id": "2",
2856
- },
2857
- },
2858
- ]
2859
- `;
2860
-
2861
- exports[`sync - postgres > storage v3 > sync updates to parameter query + data 1`] = `
2862
- [
2863
- {
2864
- "checkpoint": {
2865
- "buckets": [],
2866
- "last_op_id": "0",
2867
- "streams": [
2868
- {
2869
- "errors": [],
2870
- "is_default": true,
2871
- "name": "by_user",
2872
- },
2873
- ],
2874
- "write_checkpoint": undefined,
2875
- },
2876
- },
2877
- {
2878
- "checkpoint_complete": {
2879
- "last_op_id": "0",
2880
- },
2881
- },
2882
- ]
2883
- `;
2884
-
2885
- exports[`sync - postgres > storage v3 > sync updates to parameter query + data 2`] = `
2886
- [
2887
- {
2888
- "checkpoint_diff": {
2889
- "last_op_id": "2",
2890
- "removed_buckets": [],
2891
- "updated_buckets": [
2892
- {
2893
- "bucket": "1#by_user["user1"]",
2894
- "checksum": 1418351250,
2895
- "count": 1,
2896
- "priority": 3,
2897
- "subscriptions": [
2898
- {
2899
- "default": 0,
2900
- },
2901
- ],
2902
- },
2903
- ],
2904
- "write_checkpoint": undefined,
2905
- },
2906
- },
2907
- {
2908
- "data": {
2909
- "after": "0",
2910
- "bucket": "1#by_user["user1"]",
2911
- "data": [
2912
- {
2913
- "checksum": 1418351250,
2914
- "data": "{"id":"list1","user_id":"user1","name":"User 1"}",
2915
- "object_id": "list1",
2916
- "object_type": "lists",
2917
- "op": "PUT",
2918
- "op_id": "1",
2919
- "subkey": "b9f16d58-e6f5-55b5-9622-7bc360dba34f",
2920
- },
2921
- ],
2922
- "has_more": false,
2923
- "next_after": "1",
2924
- },
2925
- },
2926
- {
2927
- "checkpoint_complete": {
2928
- "last_op_id": "2",
2929
- },
2930
- },
2931
- ]
2932
- `;
2933
-
2934
- exports[`sync - postgres > storage v3 > sync updates to parameter query only 1`] = `
2935
- [
2936
- {
2937
- "checkpoint": {
2938
- "buckets": [],
2939
- "last_op_id": "0",
2940
- "streams": [
2941
- {
2942
- "errors": [],
2943
- "is_default": true,
2944
- "name": "by_user",
2945
- },
2946
- ],
2947
- "write_checkpoint": undefined,
2948
- },
2949
- },
2950
- {
2951
- "checkpoint_complete": {
2952
- "last_op_id": "0",
2953
- },
2954
- },
2955
- ]
2956
- `;
2957
-
2958
- exports[`sync - postgres > storage v3 > sync updates to parameter query only 2`] = `
2959
- [
2960
- {
2961
- "checkpoint_diff": {
2962
- "last_op_id": "1",
2963
- "removed_buckets": [],
2964
- "updated_buckets": [
2965
- {
2966
- "bucket": "1#by_user["user1"]",
2967
- "checksum": 0,
2968
- "count": 0,
2969
- "priority": 3,
2970
- "subscriptions": [
2971
- {
2972
- "default": 0,
2973
- },
2974
- ],
2975
- },
2976
- ],
2977
- "write_checkpoint": undefined,
2978
- },
2979
- },
2980
- {
2981
- "checkpoint_complete": {
2982
- "last_op_id": "1",
2983
- },
2984
- },
2985
- ]
2986
- `;