@powersync/service-core 0.0.0-dev-20240718134716 → 0.0.0-dev-20240918082156

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 (352) hide show
  1. package/CHANGELOG.md +89 -6
  2. package/dist/api/RouteAPI.d.ts +68 -0
  3. package/dist/api/RouteAPI.js +2 -0
  4. package/dist/api/RouteAPI.js.map +1 -0
  5. package/dist/api/api-index.d.ts +1 -0
  6. package/dist/api/api-index.js +1 -0
  7. package/dist/api/api-index.js.map +1 -1
  8. package/dist/api/diagnostics.d.ts +4 -4
  9. package/dist/api/diagnostics.js +11 -65
  10. package/dist/api/diagnostics.js.map +1 -1
  11. package/dist/api/schema.d.ts +3 -5
  12. package/dist/api/schema.js +9 -79
  13. package/dist/api/schema.js.map +1 -1
  14. package/dist/auth/KeyStore.d.ts +7 -4
  15. package/dist/auth/KeyStore.js +1 -1
  16. package/dist/auth/KeyStore.js.map +1 -1
  17. package/dist/auth/auth-index.d.ts +0 -1
  18. package/dist/auth/auth-index.js +0 -1
  19. package/dist/auth/auth-index.js.map +1 -1
  20. package/dist/entry/cli-entry.js +4 -2
  21. package/dist/entry/cli-entry.js.map +1 -1
  22. package/dist/entry/commands/compact-action.d.ts +2 -0
  23. package/dist/entry/commands/compact-action.js +52 -0
  24. package/dist/entry/commands/compact-action.js.map +1 -0
  25. package/dist/entry/commands/migrate-action.js +4 -5
  26. package/dist/entry/commands/migrate-action.js.map +1 -1
  27. package/dist/entry/commands/teardown-action.js +2 -2
  28. package/dist/entry/commands/teardown-action.js.map +1 -1
  29. package/dist/entry/entry-index.d.ts +1 -0
  30. package/dist/entry/entry-index.js +1 -0
  31. package/dist/entry/entry-index.js.map +1 -1
  32. package/dist/index.d.ts +4 -2
  33. package/dist/index.js +4 -2
  34. package/dist/index.js.map +1 -1
  35. package/dist/metrics/Metrics.d.ts +6 -5
  36. package/dist/metrics/Metrics.js +53 -10
  37. package/dist/metrics/Metrics.js.map +1 -1
  38. package/dist/migrations/db/migrations/1684951997326-init.d.ts +2 -2
  39. package/dist/migrations/db/migrations/1684951997326-init.js +4 -2
  40. package/dist/migrations/db/migrations/1684951997326-init.js.map +1 -1
  41. package/dist/migrations/db/migrations/1702295701188-sync-rule-state.d.ts +2 -2
  42. package/dist/migrations/db/migrations/1702295701188-sync-rule-state.js +4 -2
  43. package/dist/migrations/db/migrations/1702295701188-sync-rule-state.js.map +1 -1
  44. package/dist/migrations/db/migrations/1711543888062-write-checkpoint-index.d.ts +2 -2
  45. package/dist/migrations/db/migrations/1711543888062-write-checkpoint-index.js +4 -2
  46. package/dist/migrations/db/migrations/1711543888062-write-checkpoint-index.js.map +1 -1
  47. package/dist/migrations/migrations.d.ts +8 -0
  48. package/dist/migrations/migrations.js +19 -7
  49. package/dist/migrations/migrations.js.map +1 -1
  50. package/dist/modules/AbstractModule.d.ts +26 -0
  51. package/dist/modules/AbstractModule.js +11 -0
  52. package/dist/modules/AbstractModule.js.map +1 -0
  53. package/dist/modules/ModuleManager.d.ts +11 -0
  54. package/dist/modules/ModuleManager.js +32 -0
  55. package/dist/modules/ModuleManager.js.map +1 -0
  56. package/dist/modules/modules-index.d.ts +2 -0
  57. package/dist/modules/modules-index.js +3 -0
  58. package/dist/modules/modules-index.js.map +1 -0
  59. package/dist/replication/AbstractReplicationJob.d.ts +38 -0
  60. package/dist/replication/AbstractReplicationJob.js +51 -0
  61. package/dist/replication/AbstractReplicationJob.js.map +1 -0
  62. package/dist/replication/AbstractReplicator.d.ts +53 -0
  63. package/dist/replication/AbstractReplicator.js +187 -0
  64. package/dist/replication/AbstractReplicator.js.map +1 -0
  65. package/dist/replication/ErrorRateLimiter.d.ts +0 -9
  66. package/dist/replication/ErrorRateLimiter.js +1 -42
  67. package/dist/replication/ErrorRateLimiter.js.map +1 -1
  68. package/dist/replication/ReplicationEngine.d.ts +18 -0
  69. package/dist/replication/ReplicationEngine.js +41 -0
  70. package/dist/replication/ReplicationEngine.js.map +1 -0
  71. package/dist/replication/ReplicationModule.d.ts +39 -0
  72. package/dist/replication/ReplicationModule.js +65 -0
  73. package/dist/replication/ReplicationModule.js.map +1 -0
  74. package/dist/replication/replication-index.d.ts +4 -6
  75. package/dist/replication/replication-index.js +4 -6
  76. package/dist/replication/replication-index.js.map +1 -1
  77. package/dist/routes/RouterEngine.d.ts +42 -0
  78. package/dist/routes/RouterEngine.js +80 -0
  79. package/dist/routes/RouterEngine.js.map +1 -0
  80. package/dist/routes/auth.d.ts +2 -2
  81. package/dist/routes/auth.js +11 -11
  82. package/dist/routes/auth.js.map +1 -1
  83. package/dist/routes/configure-fastify.d.ts +737 -0
  84. package/dist/routes/configure-fastify.js +57 -0
  85. package/dist/routes/configure-fastify.js.map +1 -0
  86. package/dist/routes/configure-rsocket.d.ts +13 -0
  87. package/dist/routes/configure-rsocket.js +47 -0
  88. package/dist/routes/configure-rsocket.js.map +1 -0
  89. package/dist/routes/endpoints/admin.d.ts +0 -34
  90. package/dist/routes/endpoints/admin.js +48 -89
  91. package/dist/routes/endpoints/admin.js.map +1 -1
  92. package/dist/routes/endpoints/checkpointing.d.ts +56 -16
  93. package/dist/routes/endpoints/checkpointing.js +33 -12
  94. package/dist/routes/endpoints/checkpointing.js.map +1 -1
  95. package/dist/routes/endpoints/route-endpoints-index.d.ts +0 -1
  96. package/dist/routes/endpoints/route-endpoints-index.js +0 -1
  97. package/dist/routes/endpoints/route-endpoints-index.js.map +1 -1
  98. package/dist/routes/endpoints/socket-route.js +46 -39
  99. package/dist/routes/endpoints/socket-route.js.map +1 -1
  100. package/dist/routes/endpoints/sync-rules.d.ts +1 -1
  101. package/dist/routes/endpoints/sync-rules.js +32 -23
  102. package/dist/routes/endpoints/sync-rules.js.map +1 -1
  103. package/dist/routes/endpoints/sync-stream.d.ts +10 -0
  104. package/dist/routes/endpoints/sync-stream.js +17 -13
  105. package/dist/routes/endpoints/sync-stream.js.map +1 -1
  106. package/dist/routes/route-register.d.ts +1 -1
  107. package/dist/routes/route-register.js +1 -1
  108. package/dist/routes/route-register.js.map +1 -1
  109. package/dist/routes/router-socket.d.ts +5 -4
  110. package/dist/routes/router-socket.js +2 -1
  111. package/dist/routes/router-socket.js.map +1 -1
  112. package/dist/routes/router.d.ts +7 -2
  113. package/dist/routes/router.js.map +1 -1
  114. package/dist/routes/routes-index.d.ts +3 -0
  115. package/dist/routes/routes-index.js +3 -0
  116. package/dist/routes/routes-index.js.map +1 -1
  117. package/dist/runner/teardown.js +47 -76
  118. package/dist/runner/teardown.js.map +1 -1
  119. package/dist/storage/BucketStorage.d.ts +61 -20
  120. package/dist/storage/BucketStorage.js +0 -10
  121. package/dist/storage/BucketStorage.js.map +1 -1
  122. package/dist/storage/MongoBucketStorage.d.ts +4 -4
  123. package/dist/storage/MongoBucketStorage.js +19 -24
  124. package/dist/storage/MongoBucketStorage.js.map +1 -1
  125. package/dist/storage/SourceEntity.d.ts +20 -0
  126. package/dist/storage/SourceEntity.js +2 -0
  127. package/dist/storage/SourceEntity.js.map +1 -0
  128. package/dist/storage/SourceTable.d.ts +4 -5
  129. package/dist/storage/SourceTable.js +3 -4
  130. package/dist/storage/SourceTable.js.map +1 -1
  131. package/dist/storage/StorageEngine.d.ts +24 -0
  132. package/dist/storage/StorageEngine.js +43 -0
  133. package/dist/storage/StorageEngine.js.map +1 -0
  134. package/dist/storage/StorageProvider.d.ts +21 -0
  135. package/dist/storage/StorageProvider.js +2 -0
  136. package/dist/storage/StorageProvider.js.map +1 -0
  137. package/dist/storage/mongo/MongoBucketBatch.d.ts +1 -1
  138. package/dist/storage/mongo/MongoBucketBatch.js +6 -7
  139. package/dist/storage/mongo/MongoBucketBatch.js.map +1 -1
  140. package/dist/storage/mongo/MongoCompactor.d.ts +40 -0
  141. package/dist/storage/mongo/MongoCompactor.js +293 -0
  142. package/dist/storage/mongo/MongoCompactor.js.map +1 -0
  143. package/dist/storage/mongo/MongoPersistedSyncRulesContent.d.ts +2 -2
  144. package/dist/storage/mongo/MongoPersistedSyncRulesContent.js +2 -2
  145. package/dist/storage/mongo/MongoPersistedSyncRulesContent.js.map +1 -1
  146. package/dist/storage/mongo/MongoStorageProvider.d.ts +5 -0
  147. package/dist/storage/mongo/MongoStorageProvider.js +26 -0
  148. package/dist/storage/mongo/MongoStorageProvider.js.map +1 -0
  149. package/dist/storage/mongo/MongoSyncBucketStorage.d.ts +9 -7
  150. package/dist/storage/mongo/MongoSyncBucketStorage.js +43 -28
  151. package/dist/storage/mongo/MongoSyncBucketStorage.js.map +1 -1
  152. package/dist/storage/mongo/MongoSyncRulesLock.js +1 -1
  153. package/dist/storage/mongo/MongoSyncRulesLock.js.map +1 -1
  154. package/dist/storage/mongo/OperationBatch.d.ts +7 -3
  155. package/dist/storage/mongo/OperationBatch.js +16 -7
  156. package/dist/storage/mongo/OperationBatch.js.map +1 -1
  157. package/dist/storage/mongo/PersistedBatch.d.ts +3 -3
  158. package/dist/storage/mongo/PersistedBatch.js +2 -2
  159. package/dist/storage/mongo/PersistedBatch.js.map +1 -1
  160. package/dist/storage/mongo/models.d.ts +17 -7
  161. package/dist/storage/mongo/models.js.map +1 -1
  162. package/dist/storage/mongo/util.d.ts +14 -0
  163. package/dist/storage/mongo/util.js +70 -0
  164. package/dist/storage/mongo/util.js.map +1 -1
  165. package/dist/storage/storage-index.d.ts +5 -2
  166. package/dist/storage/storage-index.js +5 -2
  167. package/dist/storage/storage-index.js.map +1 -1
  168. package/dist/sync/RequestTracker.js +2 -3
  169. package/dist/sync/RequestTracker.js.map +1 -1
  170. package/dist/sync/sync-index.d.ts +1 -0
  171. package/dist/sync/sync-index.js +1 -0
  172. package/dist/sync/sync-index.js.map +1 -1
  173. package/dist/sync/sync.d.ts +2 -1
  174. package/dist/sync/sync.js +56 -17
  175. package/dist/sync/sync.js.map +1 -1
  176. package/dist/system/ServiceContext.d.ts +37 -0
  177. package/dist/system/ServiceContext.js +48 -0
  178. package/dist/system/ServiceContext.js.map +1 -0
  179. package/dist/system/system-index.d.ts +1 -1
  180. package/dist/system/system-index.js +1 -1
  181. package/dist/system/system-index.js.map +1 -1
  182. package/dist/util/config/collectors/config-collector.d.ts +12 -0
  183. package/dist/util/config/collectors/config-collector.js +43 -0
  184. package/dist/util/config/collectors/config-collector.js.map +1 -1
  185. package/dist/util/config/compound-config-collector.d.ts +10 -29
  186. package/dist/util/config/compound-config-collector.js +28 -84
  187. package/dist/util/config/compound-config-collector.js.map +1 -1
  188. package/dist/util/config/sync-rules/sync-rules-provider.d.ts +9 -0
  189. package/dist/util/config/sync-rules/sync-rules-provider.js +15 -0
  190. package/dist/util/config/sync-rules/sync-rules-provider.js.map +1 -0
  191. package/dist/util/config/types.d.ts +6 -4
  192. package/dist/util/config/types.js.map +1 -1
  193. package/dist/util/config.d.ts +3 -4
  194. package/dist/util/config.js +5 -20
  195. package/dist/util/config.js.map +1 -1
  196. package/dist/util/protocol-types.d.ts +4 -0
  197. package/dist/util/protocol-types.js +5 -1
  198. package/dist/util/protocol-types.js.map +1 -1
  199. package/dist/util/util-index.d.ts +3 -6
  200. package/dist/util/util-index.js +3 -6
  201. package/dist/util/util-index.js.map +1 -1
  202. package/dist/util/utils.d.ts +10 -6
  203. package/dist/util/utils.js +45 -25
  204. package/dist/util/utils.js.map +1 -1
  205. package/package.json +7 -7
  206. package/src/api/RouteAPI.ts +78 -0
  207. package/src/api/api-index.ts +1 -0
  208. package/src/api/diagnostics.ts +16 -71
  209. package/src/api/schema.ts +13 -89
  210. package/src/auth/KeyStore.ts +9 -6
  211. package/src/auth/auth-index.ts +0 -1
  212. package/src/entry/cli-entry.ts +4 -2
  213. package/src/entry/commands/compact-action.ts +57 -0
  214. package/src/entry/commands/migrate-action.ts +5 -8
  215. package/src/entry/commands/teardown-action.ts +2 -2
  216. package/src/entry/entry-index.ts +1 -0
  217. package/src/index.ts +5 -2
  218. package/src/metrics/Metrics.ts +70 -15
  219. package/src/migrations/db/migrations/1684951997326-init.ts +9 -4
  220. package/src/migrations/db/migrations/1702295701188-sync-rule-state.ts +7 -4
  221. package/src/migrations/db/migrations/1711543888062-write-checkpoint-index.ts +6 -4
  222. package/src/migrations/migrations.ts +24 -8
  223. package/src/modules/AbstractModule.ts +37 -0
  224. package/src/modules/ModuleManager.ts +34 -0
  225. package/src/modules/modules-index.ts +2 -0
  226. package/src/replication/AbstractReplicationJob.ts +79 -0
  227. package/src/replication/AbstractReplicator.ts +227 -0
  228. package/src/replication/ErrorRateLimiter.ts +0 -44
  229. package/src/replication/ReplicationEngine.ts +43 -0
  230. package/src/replication/ReplicationModule.ts +101 -0
  231. package/src/replication/replication-index.ts +4 -6
  232. package/src/routes/RouterEngine.ts +120 -0
  233. package/src/routes/auth.ts +21 -12
  234. package/src/routes/configure-fastify.ts +101 -0
  235. package/src/routes/configure-rsocket.ts +60 -0
  236. package/src/routes/endpoints/admin.ts +74 -100
  237. package/src/routes/endpoints/checkpointing.ts +46 -12
  238. package/src/routes/endpoints/route-endpoints-index.ts +0 -1
  239. package/src/routes/endpoints/socket-route.ts +50 -42
  240. package/src/routes/endpoints/sync-rules.ts +41 -25
  241. package/src/routes/endpoints/sync-stream.ts +17 -13
  242. package/src/routes/route-register.ts +2 -2
  243. package/src/routes/router-socket.ts +6 -5
  244. package/src/routes/router.ts +7 -2
  245. package/src/routes/routes-index.ts +3 -0
  246. package/src/runner/teardown.ts +50 -88
  247. package/src/storage/BucketStorage.ts +74 -26
  248. package/src/storage/MongoBucketStorage.ts +23 -26
  249. package/src/storage/SourceEntity.ts +22 -0
  250. package/src/storage/SourceTable.ts +4 -6
  251. package/src/storage/StorageEngine.ts +55 -0
  252. package/src/storage/StorageProvider.ts +27 -0
  253. package/src/storage/mongo/MongoBucketBatch.ts +8 -8
  254. package/src/storage/mongo/MongoCompactor.ts +372 -0
  255. package/src/storage/mongo/MongoPersistedSyncRulesContent.ts +3 -3
  256. package/src/storage/mongo/MongoStorageProvider.ts +31 -0
  257. package/src/storage/mongo/MongoSyncBucketStorage.ts +64 -34
  258. package/src/storage/mongo/MongoSyncRulesLock.ts +1 -1
  259. package/src/storage/mongo/OperationBatch.ts +18 -11
  260. package/src/storage/mongo/PersistedBatch.ts +6 -5
  261. package/src/storage/mongo/models.ts +17 -7
  262. package/src/storage/mongo/util.ts +71 -1
  263. package/src/storage/storage-index.ts +5 -2
  264. package/src/sync/RequestTracker.ts +3 -3
  265. package/src/sync/sync-index.ts +1 -0
  266. package/src/sync/sync.ts +66 -17
  267. package/src/system/ServiceContext.ts +68 -0
  268. package/src/system/system-index.ts +1 -1
  269. package/src/util/config/collectors/config-collector.ts +48 -0
  270. package/src/util/config/compound-config-collector.ts +45 -110
  271. package/src/util/config/sync-rules/sync-rules-provider.ts +18 -0
  272. package/src/util/config/types.ts +6 -5
  273. package/src/util/config.ts +6 -23
  274. package/src/util/protocol-types.ts +6 -1
  275. package/src/util/util-index.ts +3 -6
  276. package/src/util/utils.ts +55 -39
  277. package/test/src/__snapshots__/sync.test.ts.snap +90 -5
  278. package/test/src/auth.test.ts +7 -7
  279. package/test/src/broadcast_iterable.test.ts +1 -1
  280. package/test/src/bucket_validation.test.ts +142 -0
  281. package/test/src/bucket_validation.ts +116 -0
  282. package/test/src/checksum_cache.test.ts +3 -3
  283. package/test/src/compacting.test.ts +216 -0
  284. package/test/src/data_storage.test.ts +275 -204
  285. package/test/src/env.ts +1 -3
  286. package/test/src/merge_iterable.test.ts +1 -6
  287. package/test/src/setup.ts +1 -1
  288. package/test/src/stream_utils.ts +42 -0
  289. package/test/src/sync.test.ts +209 -48
  290. package/test/src/util.ts +110 -55
  291. package/test/tsconfig.json +1 -1
  292. package/tsconfig.tsbuildinfo +1 -1
  293. package/dist/auth/SupabaseKeyCollector.d.ts +0 -22
  294. package/dist/auth/SupabaseKeyCollector.js +0 -61
  295. package/dist/auth/SupabaseKeyCollector.js.map +0 -1
  296. package/dist/replication/PgRelation.d.ts +0 -16
  297. package/dist/replication/PgRelation.js +0 -26
  298. package/dist/replication/PgRelation.js.map +0 -1
  299. package/dist/replication/WalConnection.d.ts +0 -34
  300. package/dist/replication/WalConnection.js +0 -190
  301. package/dist/replication/WalConnection.js.map +0 -1
  302. package/dist/replication/WalStream.d.ts +0 -57
  303. package/dist/replication/WalStream.js +0 -517
  304. package/dist/replication/WalStream.js.map +0 -1
  305. package/dist/replication/WalStreamManager.d.ts +0 -30
  306. package/dist/replication/WalStreamManager.js +0 -198
  307. package/dist/replication/WalStreamManager.js.map +0 -1
  308. package/dist/replication/WalStreamRunner.d.ts +0 -38
  309. package/dist/replication/WalStreamRunner.js +0 -155
  310. package/dist/replication/WalStreamRunner.js.map +0 -1
  311. package/dist/replication/util.d.ts +0 -9
  312. package/dist/replication/util.js +0 -62
  313. package/dist/replication/util.js.map +0 -1
  314. package/dist/routes/endpoints/dev.d.ts +0 -312
  315. package/dist/routes/endpoints/dev.js +0 -172
  316. package/dist/routes/endpoints/dev.js.map +0 -1
  317. package/dist/system/CorePowerSyncSystem.d.ts +0 -23
  318. package/dist/system/CorePowerSyncSystem.js +0 -52
  319. package/dist/system/CorePowerSyncSystem.js.map +0 -1
  320. package/dist/util/PgManager.d.ts +0 -24
  321. package/dist/util/PgManager.js +0 -55
  322. package/dist/util/PgManager.js.map +0 -1
  323. package/dist/util/migration_lib.d.ts +0 -11
  324. package/dist/util/migration_lib.js +0 -64
  325. package/dist/util/migration_lib.js.map +0 -1
  326. package/dist/util/pgwire_utils.d.ts +0 -24
  327. package/dist/util/pgwire_utils.js +0 -117
  328. package/dist/util/pgwire_utils.js.map +0 -1
  329. package/dist/util/populate_test_data.d.ts +0 -8
  330. package/dist/util/populate_test_data.js +0 -65
  331. package/dist/util/populate_test_data.js.map +0 -1
  332. package/src/auth/SupabaseKeyCollector.ts +0 -67
  333. package/src/replication/PgRelation.ts +0 -42
  334. package/src/replication/WalConnection.ts +0 -227
  335. package/src/replication/WalStream.ts +0 -628
  336. package/src/replication/WalStreamManager.ts +0 -213
  337. package/src/replication/WalStreamRunner.ts +0 -180
  338. package/src/replication/util.ts +0 -76
  339. package/src/routes/endpoints/dev.ts +0 -199
  340. package/src/system/CorePowerSyncSystem.ts +0 -64
  341. package/src/util/PgManager.ts +0 -64
  342. package/src/util/migration_lib.ts +0 -79
  343. package/src/util/pgwire_utils.ts +0 -139
  344. package/src/util/populate_test_data.ts +0 -78
  345. package/test/src/__snapshots__/pg_test.test.ts.snap +0 -256
  346. package/test/src/large_batch.test.ts +0 -194
  347. package/test/src/pg_test.test.ts +0 -450
  348. package/test/src/schema_changes.test.ts +0 -545
  349. package/test/src/slow_tests.test.ts +0 -296
  350. package/test/src/validation.test.ts +0 -63
  351. package/test/src/wal_stream.test.ts +0 -314
  352. package/test/src/wal_stream_utils.ts +0 -147
@@ -1,18 +1,15 @@
1
- import * as t from 'ts-codec';
2
- import { configFile, normalizeConnection } from '@powersync/service-types';
3
- import { ConfigCollector } from './collectors/config-collector.js';
4
- import { ResolvedConnection, ResolvedPowerSyncConfig, RunnerConfig, SyncRulesConfig } from './types.js';
1
+ import { logger } from '@powersync/lib-services-framework';
2
+ import { configFile } from '@powersync/service-types';
5
3
  import * as auth from '../../auth/auth-index.js';
6
- import { SyncRulesCollector } from './sync-rules/sync-collector.js';
4
+ import { ConfigCollector } from './collectors/config-collector.js';
7
5
  import { Base64ConfigCollector } from './collectors/impl/base64-config-collector.js';
6
+ import { FallbackConfigCollector } from './collectors/impl/fallback-config-collector.js';
8
7
  import { FileSystemConfigCollector } from './collectors/impl/filesystem-config-collector.js';
9
8
  import { Base64SyncRulesCollector } from './sync-rules/impl/base64-sync-rules-collector.js';
10
- import { InlineSyncRulesCollector } from './sync-rules/impl/inline-sync-rules-collector.js';
11
9
  import { FileSystemSyncRulesCollector } from './sync-rules/impl/filesystem-sync-rules-collector.js';
12
- import { FallbackConfigCollector } from './collectors/impl/fallback-config-collector.js';
13
- import { logger, schema } from '@powersync/lib-services-framework';
14
-
15
- const POWERSYNC_DEV_KID = 'powersync-dev';
10
+ import { InlineSyncRulesCollector } from './sync-rules/impl/inline-sync-rules-collector.js';
11
+ import { SyncRulesCollector } from './sync-rules/sync-collector.js';
12
+ import { ResolvedPowerSyncConfig, RunnerConfig, SyncRulesConfig } from './types.js';
16
13
 
17
14
  export type CompoundConfigCollectorOptions = {
18
15
  /**
@@ -29,12 +26,17 @@ export type CompoundConfigCollectorOptions = {
29
26
  syncRulesCollectors: SyncRulesCollector[];
30
27
  };
31
28
 
32
- export type ConfigCollectorGenerics = {
33
- SERIALIZED: configFile.SerializedPowerSyncConfig;
34
- DESERIALIZED: configFile.PowerSyncConfig;
35
- RESOLVED: ResolvedPowerSyncConfig;
29
+ export type ConfigCollectedEvent = {
30
+ base_config: configFile.PowerSyncConfig;
31
+ resolved_config: ResolvedPowerSyncConfig;
32
+ };
33
+
34
+ export type ConfigCollectorListener = {
35
+ configCollected?: (event: ConfigCollectedEvent) => Promise<void>;
36
36
  };
37
37
 
38
+ const POWERSYNC_DEV_KID = 'powersync-dev';
39
+
38
40
  const DEFAULT_COLLECTOR_OPTIONS: CompoundConfigCollectorOptions = {
39
41
  configCollectors: [new Base64ConfigCollector(), new FileSystemConfigCollector(), new FallbackConfigCollector()],
40
42
  syncRulesCollectors: [
@@ -44,71 +46,20 @@ const DEFAULT_COLLECTOR_OPTIONS: CompoundConfigCollectorOptions = {
44
46
  ]
45
47
  };
46
48
 
47
- export class CompoundConfigCollector<Generics extends ConfigCollectorGenerics = ConfigCollectorGenerics> {
49
+ export class CompoundConfigCollector {
48
50
  constructor(protected options: CompoundConfigCollectorOptions = DEFAULT_COLLECTOR_OPTIONS) {}
49
51
 
50
- /**
51
- * The default ts-codec for validations and decoding
52
- */
53
- get codec(): t.AnyCodec {
54
- return configFile.powerSyncConfig;
55
- }
56
-
57
52
  /**
58
53
  * Collects and resolves base config
59
54
  */
60
- async collectConfig(runnerConfig: RunnerConfig = {}): Promise<Generics['RESOLVED']> {
55
+ async collectConfig(runnerConfig: RunnerConfig = {}): Promise<ResolvedPowerSyncConfig> {
61
56
  const baseConfig = await this.collectBaseConfig(runnerConfig);
62
- const baseResolvedConfig = await this.resolveBaseConfig(baseConfig, runnerConfig);
63
- return this.resolveConfig(baseConfig, baseResolvedConfig, runnerConfig);
64
- }
65
-
66
- /**
67
- * Collects the base PowerSyncConfig from various registered collectors.
68
- * @throws if no collector could return a configuration.
69
- */
70
- protected async collectBaseConfig(runner_config: RunnerConfig): Promise<Generics['DESERIALIZED']> {
71
- for (const collector of this.options.configCollectors) {
72
- try {
73
- const baseConfig = await collector.collectSerialized(runner_config);
74
- if (baseConfig) {
75
- const decoded = this.decode(baseConfig);
76
- this.validate(decoded);
77
- return decoded;
78
- }
79
- logger.debug(
80
- `Could not collect PowerSync config with ${collector.name} method. Moving on to next method if available.`
81
- );
82
- } catch (ex) {
83
- // An error in a collector is a hard stop
84
- throw new Error(`Could not collect config using ${collector.name} method. Caught exception: ${ex}`);
85
- }
86
- }
87
- throw new Error('PowerSyncConfig could not be collected using any of the registered config collectors.');
88
- }
89
57
 
90
- /**
91
- * Performs the resolving of the common (shared) base configuration
92
- */
93
- protected async resolveBaseConfig(
94
- baseConfig: Generics['DESERIALIZED'],
95
- runnerConfig: RunnerConfig = {}
96
- ): Promise<ResolvedPowerSyncConfig> {
97
- const connections = baseConfig.replication?.connections ?? [];
98
- if (connections.length > 1) {
99
- throw new Error('Only a single replication connection is supported currently');
58
+ const dataSources = baseConfig.replication?.connections ?? [];
59
+ if (dataSources.length > 1) {
60
+ throw new Error('Only a single replication data source is supported currently');
100
61
  }
101
62
 
102
- const mapped = connections.map((c) => {
103
- const conf: ResolvedConnection = {
104
- type: 'postgresql' as const,
105
- ...normalizeConnection(c),
106
- debug_api: c.debug_api ?? false
107
- };
108
-
109
- return conf;
110
- });
111
-
112
63
  const collectors = new auth.CompoundKeyCollector();
113
64
  const keyStore = new auth.KeyStore(collectors);
114
65
 
@@ -117,10 +68,6 @@ export class CompoundConfigCollector<Generics extends ConfigCollectorGenerics =
117
68
 
118
69
  collectors.add(staticCollector);
119
70
 
120
- if (baseConfig.client_auth?.supabase && mapped.length > 0) {
121
- collectors.add(new auth.CachedKeyCollector(new auth.SupabaseKeyCollector(mapped[0])));
122
- }
123
-
124
71
  let jwks_uris = baseConfig.client_auth?.jwks_uri ?? [];
125
72
  if (typeof jwks_uris == 'string') {
126
73
  jwks_uris = [jwks_uris];
@@ -146,7 +93,8 @@ export class CompoundConfigCollector<Generics extends ConfigCollectorGenerics =
146
93
  let jwt_audiences: string[] = baseConfig.client_auth?.audience ?? [];
147
94
 
148
95
  let config: ResolvedPowerSyncConfig = {
149
- connection: mapped[0],
96
+ base_config: baseConfig,
97
+ connections: baseConfig.replication?.connections || [],
150
98
  storage: baseConfig.storage,
151
99
  client_keystore: keyStore,
152
100
  // Dev tokens only use the static keys, no external key sources
@@ -172,23 +120,34 @@ export class CompoundConfigCollector<Generics extends ConfigCollectorGenerics =
172
120
  internal_service_endpoint:
173
121
  baseConfig.telemetry?.internal_service_endpoint ?? 'https://pulse.journeyapps.com/v1/metrics'
174
122
  },
175
- slot_name_prefix: connections[0]?.slot_name_prefix ?? 'powersync_'
123
+ // TODO maybe move this out of the connection or something
124
+ // slot_name_prefix: connections[0]?.slot_name_prefix ?? 'powersync_'
125
+ slot_name_prefix: 'powersync_'
176
126
  };
127
+
177
128
  return config;
178
129
  }
179
130
 
180
131
  /**
181
- * Perform any additional resolving from {@link ResolvedPowerSyncConfig}
182
- * to the extended {@link Generics['RESOLVED']}
183
- *
132
+ * Collects the base PowerSyncConfig from various registered collectors.
133
+ * @throws if no collector could return a configuration.
184
134
  */
185
- protected async resolveConfig(
186
- baseConfig: Generics['DESERIALIZED'],
187
- resolvedBaseConfig: ResolvedPowerSyncConfig,
188
- runnerConfig: RunnerConfig = {}
189
- ): Promise<Generics['RESOLVED']> {
190
- // The base version has ResolvedPowerSyncConfig == Generics['RESOLVED']
191
- return resolvedBaseConfig;
135
+ protected async collectBaseConfig(runner_config: RunnerConfig): Promise<configFile.PowerSyncConfig> {
136
+ for (const collector of this.options.configCollectors) {
137
+ try {
138
+ const baseConfig = await collector.collect(runner_config);
139
+ if (baseConfig) {
140
+ return baseConfig;
141
+ }
142
+ logger.debug(
143
+ `Could not collect PowerSync config with ${collector.name} method. Moving on to next method if available.`
144
+ );
145
+ } catch (ex) {
146
+ // An error in a collector is a hard stop
147
+ throw new Error(`Could not collect config using ${collector.name} method. Caught exception: ${ex}`);
148
+ }
149
+ }
150
+ throw new Error('PowerSyncConfig could not be collected using any of the registered config collectors.');
192
151
  }
193
152
 
194
153
  protected async collectSyncRules(
@@ -213,28 +172,4 @@ export class CompoundConfigCollector<Generics extends ConfigCollectorGenerics =
213
172
  present: false
214
173
  };
215
174
  }
216
-
217
- /**
218
- * Validates input config
219
- * ts-codec itself doesn't give great validation errors, so we use json schema for that
220
- */
221
- protected validate(config: Generics['DESERIALIZED']) {
222
- // ts-codec itself doesn't give great validation errors, so we use json schema for that
223
- const validator = schema
224
- .parseJSONSchema(t.generateJSONSchema(this.codec, { allowAdditional: true, parsers: [configFile.portParser] }))
225
- .validator();
226
-
227
- const valid = validator.validate(config);
228
- if (!valid.valid) {
229
- throw new Error(`Failed to validate PowerSync config: ${valid.errors.join(', ')}`);
230
- }
231
- }
232
-
233
- protected decode(encoded: Generics['SERIALIZED']): Generics['DESERIALIZED'] {
234
- try {
235
- return this.codec.decode(encoded);
236
- } catch (ex) {
237
- throw new Error(`Failed to decode PowerSync config: ${ex}`);
238
- }
239
- }
240
175
  }
@@ -0,0 +1,18 @@
1
+ import { SyncRulesConfig } from '../types.js';
2
+ import fs from 'fs/promises';
3
+
4
+ export interface SyncRulesProvider {
5
+ get(): Promise<string | undefined>;
6
+ }
7
+
8
+ export class ConfigurationFileSyncRulesProvider implements SyncRulesProvider {
9
+ constructor(private config: SyncRulesConfig) {}
10
+
11
+ async get(): Promise<string | undefined> {
12
+ if (this.config.content) {
13
+ return this.config.content;
14
+ } else if (this.config.path) {
15
+ return await fs.readFile(this.config.path, 'utf-8');
16
+ }
17
+ }
18
+ }
@@ -1,4 +1,6 @@
1
- import { NormalizedPostgresConnection, configFile } from '@powersync/service-types';
1
+ import { configFile } from '@powersync/service-types';
2
+ import { PowerSyncConfig } from '@powersync/service-types/src/config/PowerSyncConfig.js';
3
+ import { CompoundKeyCollector } from '../../auth/CompoundKeyCollector.js';
2
4
  import { KeySpec } from '../../auth/KeySpec.js';
3
5
  import { KeyStore } from '../../auth/KeyStore.js';
4
6
 
@@ -20,8 +22,6 @@ export type MigrationContext = {
20
22
 
21
23
  export type Runner = (config: RunnerConfig) => Promise<void>;
22
24
 
23
- export type ResolvedConnection = configFile.PostgresConnection & NormalizedPostgresConnection;
24
-
25
25
  export type SyncRulesConfig = {
26
26
  present: boolean;
27
27
  content?: string;
@@ -29,7 +29,8 @@ export type SyncRulesConfig = {
29
29
  };
30
30
 
31
31
  export type ResolvedPowerSyncConfig = {
32
- connection?: ResolvedConnection;
32
+ base_config: PowerSyncConfig;
33
+ connections?: configFile.DataSourceConfig[];
33
34
  storage: configFile.StorageConfig;
34
35
  dev: {
35
36
  demo_auth: boolean;
@@ -41,7 +42,7 @@ export type ResolvedPowerSyncConfig = {
41
42
  */
42
43
  dev_key?: KeySpec;
43
44
  };
44
- client_keystore: KeyStore;
45
+ client_keystore: KeyStore<CompoundKeyCollector>;
45
46
  /**
46
47
  * Keystore for development tokens.
47
48
  */
@@ -1,31 +1,14 @@
1
1
  import * as fs from 'fs/promises';
2
- import { baseUri } from '@powersync/service-types';
3
2
 
4
- import { ResolvedConnection, ResolvedPowerSyncConfig, RunnerConfig } from './config/types.js';
5
- import { CompoundConfigCollector } from './config/compound-config-collector.js';
3
+ import { container } from '@powersync/lib-services-framework';
4
+ import { ResolvedPowerSyncConfig, RunnerConfig } from './config/types.js';
5
+ import { CompoundConfigCollector } from './util-index.js';
6
6
 
7
7
  /**
8
- * Build a single URI from full postgres credentials.
8
+ * Loads the resolved config using the registered config collector
9
9
  */
10
- export function buildDemoPgUri(options: ResolvedConnection): string {
11
- if (!options.debug_api) {
12
- throw new Error('Not supported');
13
- }
14
-
15
- const uri = new URL(baseUri(options));
16
- uri.username = options.username;
17
- uri.password = options.password;
18
- if (options.sslmode != 'disable') {
19
- // verify-full is tricky to actually use on a client, since they won't have the cert
20
- // Just use "require" by default
21
- // uri.searchParams.set('sslmode', options.sslmode);
22
- uri.searchParams.set('sslmode', 'require');
23
- }
24
- return uri.toString();
25
- }
26
-
27
- export function loadConfig(runnerConfig: RunnerConfig = {}) {
28
- const collector = new CompoundConfigCollector();
10
+ export async function loadConfig(runnerConfig: RunnerConfig) {
11
+ const collector = container.getImplementation(CompoundConfigCollector);
29
12
  return collector.collectConfig(runnerConfig);
30
13
  }
31
14
 
@@ -94,7 +94,12 @@ export const StreamingSyncRequest = t.object({
94
94
  /**
95
95
  * Client parameters to be passed to the sync rules.
96
96
  */
97
- parameters: t.record(t.any).optional()
97
+ parameters: t.record(t.any).optional(),
98
+
99
+ /**
100
+ * Unique client id.
101
+ */
102
+ client_id: t.string.optional()
98
103
  });
99
104
 
100
105
  export type StreamingSyncRequest = t.Decoded<typeof StreamingSyncRequest>;
@@ -1,25 +1,22 @@
1
1
  export * from './alerting.js';
2
2
  export * from './env.js';
3
3
  export * from './memory-tracking.js';
4
- export * from './migration_lib.js';
5
4
  export * from './Mutex.js';
6
- export * from './PgManager.js';
7
- export * from './pgwire_utils.js';
8
- export * from './populate_test_data.js';
9
5
  export * from './protocol-types.js';
10
6
  export * from './secs.js';
11
7
  export * from './utils.js';
12
8
 
13
9
  export * from './config.js';
14
- export * from './config/types.js';
15
10
  export * from './config/compound-config-collector.js';
11
+ export * from './config/types.js';
16
12
 
17
13
  export * from './config/collectors/config-collector.js';
18
14
  export * from './config/collectors/impl/base64-config-collector.js';
19
15
  export * from './config/collectors/impl/fallback-config-collector.js';
20
16
  export * from './config/collectors/impl/filesystem-config-collector.js';
21
17
 
22
- export * from './config/sync-rules/sync-collector.js';
23
18
  export * from './config/sync-rules/impl/base64-sync-rules-collector.js';
24
19
  export * from './config/sync-rules/impl/filesystem-sync-rules-collector.js';
25
20
  export * from './config/sync-rules/impl/inline-sync-rules-collector.js';
21
+ export * from './config/sync-rules/sync-collector.js';
22
+ export * from './config/sync-rules/sync-rules-provider.js';
package/src/util/utils.ts CHANGED
@@ -1,14 +1,19 @@
1
+ import * as sync_rules from '@powersync/service-sync-rules';
2
+ import * as bson from 'bson';
1
3
  import crypto from 'crypto';
2
- import * as pgwire from '@powersync/service-jpgwire';
3
- import { pgwireRows } from '@powersync/service-jpgwire';
4
+ import * as uuid from 'uuid';
5
+ import { BucketChecksum, OpId } from './protocol-types.js';
4
6
 
5
7
  import * as storage from '../storage/storage-index.js';
6
- import { BucketChecksum, OpId } from './protocol-types.js';
7
- import { retriedQuery } from './pgwire_utils.js';
8
- import { logger } from '@powersync/lib-services-framework';
9
8
 
10
9
  export type ChecksumMap = Map<string, BucketChecksum>;
11
10
 
11
+ export const ID_NAMESPACE = 'a396dd91-09fc-4017-a28d-3df722f651e9';
12
+
13
+ export function escapeIdentifier(identifier: string) {
14
+ return `"${identifier.replace(/"/g, '""').replace(/\./g, '"."')}"`;
15
+ }
16
+
12
17
  export function hashData(type: string, id: string, data: string): number {
13
18
  const hash = crypto.createHash('sha256');
14
19
  hash.update(`put.${type}.${id}.${data}`);
@@ -76,47 +81,58 @@ export function addBucketChecksums(a: BucketChecksum, b: BucketChecksum | null):
76
81
  }
77
82
  }
78
83
 
79
- export async function getClientCheckpoint(
80
- db: pgwire.PgClient,
81
- bucketStorage: storage.BucketStorageFactory,
82
- options?: { timeout?: number }
83
- ): Promise<OpId> {
84
- const start = Date.now();
84
+ function getRawReplicaIdentity(
85
+ tuple: sync_rules.ToastableSqliteRow,
86
+ columns: storage.ColumnDescriptor[]
87
+ ): Record<string, any> {
88
+ let result: Record<string, any> = {};
89
+ for (let column of columns) {
90
+ const name = column.name;
91
+ result[name] = tuple[name];
92
+ }
93
+ return result;
94
+ }
85
95
 
86
- const [{ lsn }] = pgwireRows(await db.query(`SELECT pg_logical_emit_message(false, 'powersync', 'ping') as lsn`));
96
+ export function getUuidReplicaIdentityBson(
97
+ tuple: sync_rules.ToastableSqliteRow,
98
+ columns: storage.ColumnDescriptor[]
99
+ ): bson.UUID {
100
+ if (columns.length == 0) {
101
+ // REPLICA IDENTITY NOTHING - generate random id
102
+ return new bson.UUID(uuid.v4());
103
+ }
104
+ const rawIdentity = getRawReplicaIdentity(tuple, columns);
87
105
 
88
- // This old API needs a persisted checkpoint id.
89
- // Since we don't use LSNs anymore, the only way to get that is to wait.
106
+ return uuidForRowBson(rawIdentity);
107
+ }
90
108
 
91
- const timeout = options?.timeout ?? 50_000;
109
+ export function uuidForRowBson(row: sync_rules.SqliteRow): bson.UUID {
110
+ // Important: This must not change, since it will affect how ids are generated.
111
+ // Use BSON so that it's a well-defined format without encoding ambiguities.
112
+ const repr = bson.serialize(row);
113
+ const buffer = Buffer.alloc(16);
114
+ return new bson.UUID(uuid.v5(repr, ID_NAMESPACE, buffer));
115
+ }
92
116
 
93
- logger.info(`Waiting for LSN checkpoint: ${lsn}`);
94
- while (Date.now() - start < timeout) {
95
- const cp = await bucketStorage.getActiveCheckpoint();
96
- if (!cp.hasSyncRules()) {
97
- throw new Error('No sync rules available');
117
+ export function hasToastedValues(row: sync_rules.ToastableSqliteRow) {
118
+ for (let key in row) {
119
+ if (typeof row[key] == 'undefined') {
120
+ return true;
98
121
  }
99
- if (cp.lsn >= lsn) {
100
- logger.info(`Got write checkpoint: ${lsn} : ${cp.checkpoint}`);
101
- return cp.checkpoint;
102
- }
103
-
104
- await new Promise((resolve) => setTimeout(resolve, 30));
105
122
  }
123
+ return false;
124
+ }
106
125
 
107
- throw new Error('Timeout while waiting for checkpoint');
126
+ export function isCompleteRow(row: sync_rules.ToastableSqliteRow): row is sync_rules.SqliteRow {
127
+ return !hasToastedValues(row);
108
128
  }
109
129
 
110
- export async function createWriteCheckpoint(
111
- db: pgwire.PgClient,
112
- bucketStorage: storage.BucketStorageFactory,
113
- user_id: string
114
- ): Promise<bigint> {
115
- const [{ lsn }] = pgwireRows(
116
- await retriedQuery(db, `SELECT pg_logical_emit_message(false, 'powersync', 'ping') as lsn`)
117
- );
118
-
119
- const id = await bucketStorage.createWriteCheckpoint(user_id, { '1': lsn });
120
- logger.info(`Write checkpoint 2: ${JSON.stringify({ lsn, id: String(id) })}`);
121
- return id;
130
+ export function checkpointUserId(user_id: string | undefined, client_id: string | undefined) {
131
+ if (user_id == null) {
132
+ throw new Error('user_id is required');
133
+ }
134
+ if (client_id == null) {
135
+ return user_id;
136
+ }
137
+ return `${user_id}/${client_id}`;
122
138
  }
@@ -1,5 +1,90 @@
1
1
  // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
2
2
 
3
+ exports[`sync - mongodb > compacting data - invalidate checkpoint 1`] = `
4
+ [
5
+ {
6
+ "checkpoint": {
7
+ "buckets": [
8
+ {
9
+ "bucket": "mybucket[]",
10
+ "checksum": -93886621,
11
+ "count": 2,
12
+ },
13
+ ],
14
+ "last_op_id": "2",
15
+ "write_checkpoint": undefined,
16
+ },
17
+ },
18
+ ]
19
+ `;
20
+
21
+ exports[`sync - mongodb > compacting data - invalidate checkpoint 2`] = `
22
+ [
23
+ {
24
+ "data": {
25
+ "after": "0",
26
+ "bucket": "mybucket[]",
27
+ "data": [
28
+ {
29
+ "checksum": -93886621n,
30
+ "op": "CLEAR",
31
+ "op_id": "2",
32
+ },
33
+ ],
34
+ "has_more": false,
35
+ "next_after": "2",
36
+ },
37
+ },
38
+ {
39
+ "checkpoint_diff": {
40
+ "last_op_id": "4",
41
+ "removed_buckets": [],
42
+ "updated_buckets": [
43
+ {
44
+ "bucket": "mybucket[]",
45
+ "checksum": 499012468,
46
+ "count": 4,
47
+ },
48
+ ],
49
+ "write_checkpoint": undefined,
50
+ },
51
+ },
52
+ {
53
+ "data": {
54
+ "after": "2",
55
+ "bucket": "mybucket[]",
56
+ "data": [
57
+ {
58
+ "checksum": 1859363232n,
59
+ "data": "{\\"id\\":\\"t1\\",\\"description\\":\\"Test 1b\\"}",
60
+ "object_id": "t1",
61
+ "object_type": "test",
62
+ "op": "PUT",
63
+ "op_id": "3",
64
+ "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
65
+ },
66
+ {
67
+ "checksum": 3028503153n,
68
+ "data": "{\\"id\\":\\"t2\\",\\"description\\":\\"Test 2b\\"}",
69
+ "object_id": "t2",
70
+ "object_type": "test",
71
+ "op": "PUT",
72
+ "op_id": "4",
73
+ "subkey": "13423353-9f27-59b4-baf0-64a5e09f1769",
74
+ },
75
+ ],
76
+ "has_more": false,
77
+ "next_after": "4",
78
+ },
79
+ },
80
+ {
81
+ "checkpoint_complete": {
82
+ "last_op_id": "4",
83
+ },
84
+ },
85
+ ]
86
+ `;
87
+
3
88
  exports[`sync - mongodb > expired token 1`] = `
4
89
  [
5
90
  {
@@ -66,7 +151,7 @@ exports[`sync - mongodb > sync global data 1`] = `
66
151
  "object_type": "test",
67
152
  "op": "PUT",
68
153
  "op_id": "1",
69
- "subkey": "6544e3899293153fa7b38331/117ab485-4b42-58a2-ab32-0053a22c3423",
154
+ "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
70
155
  },
71
156
  {
72
157
  "checksum": 3280762209n,
@@ -75,7 +160,7 @@ exports[`sync - mongodb > sync global data 1`] = `
75
160
  "object_type": "test",
76
161
  "op": "PUT",
77
162
  "op_id": "2",
78
- "subkey": "6544e3899293153fa7b38331/ec27c691-b47a-5d92-927a-9944feb89eee",
163
+ "subkey": "13423353-9f27-59b4-baf0-64a5e09f1769",
79
164
  },
80
165
  ],
81
166
  "has_more": false,
@@ -122,7 +207,7 @@ exports[`sync - mongodb > sync legacy non-raw data 1`] = `
122
207
  "object_type": "test",
123
208
  "op": "PUT",
124
209
  "op_id": "1",
125
- "subkey": "6544e3899293153fa7b38331/117ab485-4b42-58a2-ab32-0053a22c3423",
210
+ "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
126
211
  },
127
212
  ],
128
213
  "has_more": false,
@@ -188,7 +273,7 @@ exports[`sync - mongodb > sync updates to global data 2`] = `
188
273
  "object_type": "test",
189
274
  "op": "PUT",
190
275
  "op_id": "1",
191
- "subkey": "6544e3899293153fa7b38331/117ab485-4b42-58a2-ab32-0053a22c3423",
276
+ "subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
192
277
  },
193
278
  ],
194
279
  "has_more": false,
@@ -231,7 +316,7 @@ exports[`sync - mongodb > sync updates to global data 3`] = `
231
316
  "object_type": "test",
232
317
  "op": "PUT",
233
318
  "op_id": "2",
234
- "subkey": "6544e3899293153fa7b38331/ec27c691-b47a-5d92-927a-9944feb89eee",
319
+ "subkey": "13423353-9f27-59b4-baf0-64a5e09f1769",
235
320
  },
236
321
  ],
237
322
  "has_more": false,
@@ -1,11 +1,11 @@
1
- import { describe, expect, test } from 'vitest';
2
- import { StaticKeyCollector } from '../../src/auth/StaticKeyCollector.js';
1
+ import { CachedKeyCollector } from '@/auth/CachedKeyCollector.js';
2
+ import { KeyResult } from '@/auth/KeyCollector.js';
3
+ import { KeySpec } from '@/auth/KeySpec.js';
4
+ import { KeyStore } from '@/auth/KeyStore.js';
5
+ import { RemoteJWKSCollector } from '@/auth/RemoteJWKSCollector.js';
6
+ import { StaticKeyCollector } from '@/auth/StaticKeyCollector.js';
3
7
  import * as jose from 'jose';
4
- import { KeyStore } from '../../src/auth/KeyStore.js';
5
- import { KeySpec } from '../../src/auth/KeySpec.js';
6
- import { RemoteJWKSCollector } from '../../src/auth/RemoteJWKSCollector.js';
7
- import { KeyResult } from '../../src/auth/KeyCollector.js';
8
- import { CachedKeyCollector } from '../../src/auth/CachedKeyCollector.js';
8
+ import { describe, expect, test } from 'vitest';
9
9
 
10
10
  const publicKey: jose.JWK = {
11
11
  use: 'sig',
@@ -1,3 +1,4 @@
1
+ import { BroadcastIterable, IterableSource } from '@/sync/BroadcastIterable.js';
1
2
  import { AsyncIterableX, interval } from 'ix/asynciterable/index.js';
2
3
  import { delayEach } from 'ix/asynciterable/operators/delayeach.js';
3
4
  import { take } from 'ix/asynciterable/operators/take.js';
@@ -5,7 +6,6 @@ import { wrapWithAbort } from 'ix/asynciterable/operators/withabort.js';
5
6
  import { toArray } from 'ix/asynciterable/toarray.js';
6
7
  import * as timers from 'timers/promises';
7
8
  import { describe, expect, test } from 'vitest';
8
- import { BroadcastIterable, IterableSource } from '../../src/sync/BroadcastIterable.js';
9
9
 
10
10
  describe('BroadcastIterable', () => {
11
11
  test('should iterate', async () => {