@powerhousedao/reactor 6.0.0-dev.13 → 6.0.0-dev.130

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 (409) hide show
  1. package/dist/index.d.ts +4320 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +9442 -0
  4. package/dist/index.js.map +1 -0
  5. package/package.json +21 -20
  6. package/dist/src/actions/index.d.ts +0 -24
  7. package/dist/src/actions/index.d.ts.map +0 -1
  8. package/dist/src/actions/index.js +0 -76
  9. package/dist/src/actions/index.js.map +0 -1
  10. package/dist/src/cache/buffer/ring-buffer.d.ts +0 -37
  11. package/dist/src/cache/buffer/ring-buffer.d.ts.map +0 -1
  12. package/dist/src/cache/buffer/ring-buffer.js +0 -69
  13. package/dist/src/cache/buffer/ring-buffer.js.map +0 -1
  14. package/dist/src/cache/document-meta-cache-types.d.ts +0 -114
  15. package/dist/src/cache/document-meta-cache-types.d.ts.map +0 -1
  16. package/dist/src/cache/document-meta-cache-types.js +0 -2
  17. package/dist/src/cache/document-meta-cache-types.js.map +0 -1
  18. package/dist/src/cache/document-meta-cache.d.ts +0 -30
  19. package/dist/src/cache/document-meta-cache.d.ts.map +0 -1
  20. package/dist/src/cache/document-meta-cache.js +0 -128
  21. package/dist/src/cache/document-meta-cache.js.map +0 -1
  22. package/dist/src/cache/index.d.ts +0 -3
  23. package/dist/src/cache/index.d.ts.map +0 -1
  24. package/dist/src/cache/index.js +0 -2
  25. package/dist/src/cache/index.js.map +0 -1
  26. package/dist/src/cache/kysely-operation-index.d.ts +0 -15
  27. package/dist/src/cache/kysely-operation-index.d.ts.map +0 -1
  28. package/dist/src/cache/kysely-operation-index.js +0 -250
  29. package/dist/src/cache/kysely-operation-index.js.map +0 -1
  30. package/dist/src/cache/kysely-write-cache.d.ts +0 -134
  31. package/dist/src/cache/kysely-write-cache.d.ts.map +0 -1
  32. package/dist/src/cache/kysely-write-cache.js +0 -388
  33. package/dist/src/cache/kysely-write-cache.js.map +0 -1
  34. package/dist/src/cache/lru/lru-tracker.d.ts +0 -15
  35. package/dist/src/cache/lru/lru-tracker.d.ts.map +0 -1
  36. package/dist/src/cache/lru/lru-tracker.js +0 -96
  37. package/dist/src/cache/lru/lru-tracker.js.map +0 -1
  38. package/dist/src/cache/operation-index-types.d.ts +0 -50
  39. package/dist/src/cache/operation-index-types.d.ts.map +0 -1
  40. package/dist/src/cache/operation-index-types.js +0 -4
  41. package/dist/src/cache/operation-index-types.js.map +0 -1
  42. package/dist/src/cache/write/interfaces.d.ts +0 -83
  43. package/dist/src/cache/write/interfaces.d.ts.map +0 -1
  44. package/dist/src/cache/write/interfaces.js +0 -2
  45. package/dist/src/cache/write/interfaces.js.map +0 -1
  46. package/dist/src/cache/write-cache-types.d.ts +0 -42
  47. package/dist/src/cache/write-cache-types.d.ts.map +0 -1
  48. package/dist/src/cache/write-cache-types.js +0 -2
  49. package/dist/src/cache/write-cache-types.js.map +0 -1
  50. package/dist/src/client/reactor-client.d.ts +0 -117
  51. package/dist/src/client/reactor-client.d.ts.map +0 -1
  52. package/dist/src/client/reactor-client.js +0 -406
  53. package/dist/src/client/reactor-client.js.map +0 -1
  54. package/dist/src/client/types.d.ts +0 -241
  55. package/dist/src/client/types.d.ts.map +0 -1
  56. package/dist/src/client/types.js +0 -14
  57. package/dist/src/client/types.js.map +0 -1
  58. package/dist/src/core/reactor-builder.d.ts +0 -47
  59. package/dist/src/core/reactor-builder.d.ts.map +0 -1
  60. package/dist/src/core/reactor-builder.js +0 -231
  61. package/dist/src/core/reactor-builder.js.map +0 -1
  62. package/dist/src/core/reactor-client-builder.d.ts +0 -49
  63. package/dist/src/core/reactor-client-builder.d.ts.map +0 -1
  64. package/dist/src/core/reactor-client-builder.js +0 -123
  65. package/dist/src/core/reactor-client-builder.js.map +0 -1
  66. package/dist/src/core/reactor.d.ts +0 -116
  67. package/dist/src/core/reactor.d.ts.map +0 -1
  68. package/dist/src/core/reactor.js +0 -981
  69. package/dist/src/core/reactor.js.map +0 -1
  70. package/dist/src/core/types.d.ts +0 -276
  71. package/dist/src/core/types.d.ts.map +0 -1
  72. package/dist/src/core/types.js +0 -2
  73. package/dist/src/core/types.js.map +0 -1
  74. package/dist/src/core/utils.d.ts +0 -59
  75. package/dist/src/core/utils.d.ts.map +0 -1
  76. package/dist/src/core/utils.js +0 -171
  77. package/dist/src/core/utils.js.map +0 -1
  78. package/dist/src/events/event-bus.d.ts +0 -8
  79. package/dist/src/events/event-bus.d.ts.map +0 -1
  80. package/dist/src/events/event-bus.js +0 -53
  81. package/dist/src/events/event-bus.js.map +0 -1
  82. package/dist/src/events/interfaces.d.ts +0 -27
  83. package/dist/src/events/interfaces.d.ts.map +0 -1
  84. package/dist/src/events/interfaces.js +0 -2
  85. package/dist/src/events/interfaces.js.map +0 -1
  86. package/dist/src/events/types.d.ts +0 -67
  87. package/dist/src/events/types.d.ts.map +0 -1
  88. package/dist/src/events/types.js +0 -28
  89. package/dist/src/events/types.js.map +0 -1
  90. package/dist/src/executor/interfaces.d.ts +0 -49
  91. package/dist/src/executor/interfaces.d.ts.map +0 -1
  92. package/dist/src/executor/interfaces.js +0 -2
  93. package/dist/src/executor/interfaces.js.map +0 -1
  94. package/dist/src/executor/simple-job-executor-manager.d.ts +0 -34
  95. package/dist/src/executor/simple-job-executor-manager.d.ts.map +0 -1
  96. package/dist/src/executor/simple-job-executor-manager.js +0 -233
  97. package/dist/src/executor/simple-job-executor-manager.js.map +0 -1
  98. package/dist/src/executor/simple-job-executor.d.ts +0 -80
  99. package/dist/src/executor/simple-job-executor.d.ts.map +0 -1
  100. package/dist/src/executor/simple-job-executor.js +0 -898
  101. package/dist/src/executor/simple-job-executor.js.map +0 -1
  102. package/dist/src/executor/types.d.ts +0 -93
  103. package/dist/src/executor/types.d.ts.map +0 -1
  104. package/dist/src/executor/types.js +0 -11
  105. package/dist/src/executor/types.js.map +0 -1
  106. package/dist/src/executor/util.d.ts +0 -74
  107. package/dist/src/executor/util.d.ts.map +0 -1
  108. package/dist/src/executor/util.js +0 -184
  109. package/dist/src/executor/util.js.map +0 -1
  110. package/dist/src/index.d.ts +0 -53
  111. package/dist/src/index.d.ts.map +0 -1
  112. package/dist/src/index.js +0 -62
  113. package/dist/src/index.js.map +0 -1
  114. package/dist/src/job-tracker/in-memory-job-tracker.d.ts +0 -25
  115. package/dist/src/job-tracker/in-memory-job-tracker.d.ts.map +0 -1
  116. package/dist/src/job-tracker/in-memory-job-tracker.js +0 -112
  117. package/dist/src/job-tracker/in-memory-job-tracker.js.map +0 -1
  118. package/dist/src/job-tracker/index.d.ts +0 -3
  119. package/dist/src/job-tracker/index.d.ts.map +0 -1
  120. package/dist/src/job-tracker/index.js +0 -2
  121. package/dist/src/job-tracker/index.js.map +0 -1
  122. package/dist/src/job-tracker/interfaces.d.ts +0 -39
  123. package/dist/src/job-tracker/interfaces.d.ts.map +0 -1
  124. package/dist/src/job-tracker/interfaces.js +0 -2
  125. package/dist/src/job-tracker/interfaces.js.map +0 -1
  126. package/dist/src/logging/console.d.ts +0 -23
  127. package/dist/src/logging/console.d.ts.map +0 -1
  128. package/dist/src/logging/console.js +0 -108
  129. package/dist/src/logging/console.js.map +0 -1
  130. package/dist/src/logging/types.d.ts +0 -12
  131. package/dist/src/logging/types.d.ts.map +0 -1
  132. package/dist/src/logging/types.js +0 -2
  133. package/dist/src/logging/types.js.map +0 -1
  134. package/dist/src/processors/index.d.ts +0 -3
  135. package/dist/src/processors/index.d.ts.map +0 -1
  136. package/dist/src/processors/index.js +0 -2
  137. package/dist/src/processors/index.js.map +0 -1
  138. package/dist/src/processors/processor-manager.d.ts +0 -38
  139. package/dist/src/processors/processor-manager.d.ts.map +0 -1
  140. package/dist/src/processors/processor-manager.js +0 -165
  141. package/dist/src/processors/processor-manager.js.map +0 -1
  142. package/dist/src/processors/types.d.ts +0 -63
  143. package/dist/src/processors/types.d.ts.map +0 -1
  144. package/dist/src/processors/types.js +0 -2
  145. package/dist/src/processors/types.js.map +0 -1
  146. package/dist/src/processors/utils.d.ts +0 -10
  147. package/dist/src/processors/utils.d.ts.map +0 -1
  148. package/dist/src/processors/utils.js +0 -59
  149. package/dist/src/processors/utils.js.map +0 -1
  150. package/dist/src/queue/interfaces.d.ts +0 -103
  151. package/dist/src/queue/interfaces.d.ts.map +0 -1
  152. package/dist/src/queue/interfaces.js +0 -2
  153. package/dist/src/queue/interfaces.js.map +0 -1
  154. package/dist/src/queue/job-execution-handle.d.ts +0 -25
  155. package/dist/src/queue/job-execution-handle.d.ts.map +0 -1
  156. package/dist/src/queue/job-execution-handle.js +0 -62
  157. package/dist/src/queue/job-execution-handle.js.map +0 -1
  158. package/dist/src/queue/queue.d.ts +0 -81
  159. package/dist/src/queue/queue.d.ts.map +0 -1
  160. package/dist/src/queue/queue.js +0 -384
  161. package/dist/src/queue/queue.js.map +0 -1
  162. package/dist/src/queue/types.d.ts +0 -73
  163. package/dist/src/queue/types.d.ts.map +0 -1
  164. package/dist/src/queue/types.js +0 -19
  165. package/dist/src/queue/types.js.map +0 -1
  166. package/dist/src/read-models/base-read-model.d.ts +0 -60
  167. package/dist/src/read-models/base-read-model.d.ts.map +0 -1
  168. package/dist/src/read-models/base-read-model.js +0 -143
  169. package/dist/src/read-models/base-read-model.js.map +0 -1
  170. package/dist/src/read-models/coordinator.d.ts +0 -39
  171. package/dist/src/read-models/coordinator.d.ts.map +0 -1
  172. package/dist/src/read-models/coordinator.js +0 -72
  173. package/dist/src/read-models/coordinator.js.map +0 -1
  174. package/dist/src/read-models/document-view.d.ts +0 -24
  175. package/dist/src/read-models/document-view.d.ts.map +0 -1
  176. package/dist/src/read-models/document-view.js +0 -375
  177. package/dist/src/read-models/document-view.js.map +0 -1
  178. package/dist/src/read-models/interfaces.d.ts +0 -29
  179. package/dist/src/read-models/interfaces.d.ts.map +0 -1
  180. package/dist/src/read-models/interfaces.js +0 -2
  181. package/dist/src/read-models/interfaces.js.map +0 -1
  182. package/dist/src/read-models/types.d.ts +0 -47
  183. package/dist/src/read-models/types.d.ts.map +0 -1
  184. package/dist/src/read-models/types.js +0 -2
  185. package/dist/src/read-models/types.js.map +0 -1
  186. package/dist/src/registry/implementation.d.ts +0 -70
  187. package/dist/src/registry/implementation.d.ts.map +0 -1
  188. package/dist/src/registry/implementation.js +0 -216
  189. package/dist/src/registry/implementation.js.map +0 -1
  190. package/dist/src/registry/index.d.ts +0 -3
  191. package/dist/src/registry/index.d.ts.map +0 -1
  192. package/dist/src/registry/index.js +0 -2
  193. package/dist/src/registry/index.js.map +0 -1
  194. package/dist/src/registry/interfaces.d.ts +0 -100
  195. package/dist/src/registry/interfaces.d.ts.map +0 -1
  196. package/dist/src/registry/interfaces.js +0 -2
  197. package/dist/src/registry/interfaces.js.map +0 -1
  198. package/dist/src/shared/awaiter.d.ts +0 -35
  199. package/dist/src/shared/awaiter.d.ts.map +0 -1
  200. package/dist/src/shared/awaiter.js +0 -123
  201. package/dist/src/shared/awaiter.js.map +0 -1
  202. package/dist/src/shared/consistency-tracker.d.ts +0 -48
  203. package/dist/src/shared/consistency-tracker.d.ts.map +0 -1
  204. package/dist/src/shared/consistency-tracker.js +0 -123
  205. package/dist/src/shared/consistency-tracker.js.map +0 -1
  206. package/dist/src/shared/drive-url.d.ts +0 -15
  207. package/dist/src/shared/drive-url.d.ts.map +0 -1
  208. package/dist/src/shared/drive-url.js +0 -17
  209. package/dist/src/shared/drive-url.js.map +0 -1
  210. package/dist/src/shared/errors.d.ts +0 -41
  211. package/dist/src/shared/errors.d.ts.map +0 -1
  212. package/dist/src/shared/errors.js +0 -75
  213. package/dist/src/shared/errors.js.map +0 -1
  214. package/dist/src/shared/factories.d.ts +0 -16
  215. package/dist/src/shared/factories.d.ts.map +0 -1
  216. package/dist/src/shared/factories.js +0 -33
  217. package/dist/src/shared/factories.js.map +0 -1
  218. package/dist/src/shared/types.d.ts +0 -135
  219. package/dist/src/shared/types.d.ts.map +0 -1
  220. package/dist/src/shared/types.js +0 -38
  221. package/dist/src/shared/types.js.map +0 -1
  222. package/dist/src/shared/utils.d.ts +0 -3
  223. package/dist/src/shared/utils.d.ts.map +0 -1
  224. package/dist/src/shared/utils.js +0 -8
  225. package/dist/src/shared/utils.js.map +0 -1
  226. package/dist/src/signer/passthrough-signer.d.ts +0 -12
  227. package/dist/src/signer/passthrough-signer.d.ts.map +0 -1
  228. package/dist/src/signer/passthrough-signer.js +0 -19
  229. package/dist/src/signer/passthrough-signer.js.map +0 -1
  230. package/dist/src/signer/types.d.ts +0 -17
  231. package/dist/src/signer/types.d.ts.map +0 -1
  232. package/dist/src/signer/types.js +0 -2
  233. package/dist/src/signer/types.js.map +0 -1
  234. package/dist/src/storage/consistency-aware-legacy-storage.d.ts +0 -33
  235. package/dist/src/storage/consistency-aware-legacy-storage.d.ts.map +0 -1
  236. package/dist/src/storage/consistency-aware-legacy-storage.js +0 -65
  237. package/dist/src/storage/consistency-aware-legacy-storage.js.map +0 -1
  238. package/dist/src/storage/index.d.ts +0 -4
  239. package/dist/src/storage/index.d.ts.map +0 -1
  240. package/dist/src/storage/index.js +0 -3
  241. package/dist/src/storage/index.js.map +0 -1
  242. package/dist/src/storage/interfaces.d.ts +0 -439
  243. package/dist/src/storage/interfaces.d.ts.map +0 -1
  244. package/dist/src/storage/interfaces.js +0 -19
  245. package/dist/src/storage/interfaces.js.map +0 -1
  246. package/dist/src/storage/kysely/document-indexer.d.ts +0 -28
  247. package/dist/src/storage/kysely/document-indexer.d.ts.map +0 -1
  248. package/dist/src/storage/kysely/document-indexer.js +0 -350
  249. package/dist/src/storage/kysely/document-indexer.js.map +0 -1
  250. package/dist/src/storage/kysely/keyframe-store.d.ts +0 -15
  251. package/dist/src/storage/kysely/keyframe-store.d.ts.map +0 -1
  252. package/dist/src/storage/kysely/keyframe-store.js +0 -64
  253. package/dist/src/storage/kysely/keyframe-store.js.map +0 -1
  254. package/dist/src/storage/kysely/store.d.ts +0 -16
  255. package/dist/src/storage/kysely/store.d.ts.map +0 -1
  256. package/dist/src/storage/kysely/store.js +0 -233
  257. package/dist/src/storage/kysely/store.js.map +0 -1
  258. package/dist/src/storage/kysely/sync-cursor-storage.d.ts +0 -13
  259. package/dist/src/storage/kysely/sync-cursor-storage.d.ts.map +0 -1
  260. package/dist/src/storage/kysely/sync-cursor-storage.js +0 -93
  261. package/dist/src/storage/kysely/sync-cursor-storage.js.map +0 -1
  262. package/dist/src/storage/kysely/sync-remote-storage.d.ts +0 -13
  263. package/dist/src/storage/kysely/sync-remote-storage.d.ts.map +0 -1
  264. package/dist/src/storage/kysely/sync-remote-storage.js +0 -133
  265. package/dist/src/storage/kysely/sync-remote-storage.js.map +0 -1
  266. package/dist/src/storage/kysely/types.d.ts +0 -135
  267. package/dist/src/storage/kysely/types.d.ts.map +0 -1
  268. package/dist/src/storage/kysely/types.js +0 -2
  269. package/dist/src/storage/kysely/types.js.map +0 -1
  270. package/dist/src/storage/migrations/001_create_operation_table.d.ts +0 -3
  271. package/dist/src/storage/migrations/001_create_operation_table.d.ts.map +0 -1
  272. package/dist/src/storage/migrations/001_create_operation_table.js +0 -41
  273. package/dist/src/storage/migrations/001_create_operation_table.js.map +0 -1
  274. package/dist/src/storage/migrations/002_create_keyframe_table.d.ts +0 -3
  275. package/dist/src/storage/migrations/002_create_keyframe_table.d.ts.map +0 -1
  276. package/dist/src/storage/migrations/002_create_keyframe_table.js +0 -27
  277. package/dist/src/storage/migrations/002_create_keyframe_table.js.map +0 -1
  278. package/dist/src/storage/migrations/003_create_document_table.d.ts +0 -3
  279. package/dist/src/storage/migrations/003_create_document_table.d.ts.map +0 -1
  280. package/dist/src/storage/migrations/003_create_document_table.js +0 -10
  281. package/dist/src/storage/migrations/003_create_document_table.js.map +0 -1
  282. package/dist/src/storage/migrations/004_create_document_relationship_table.d.ts +0 -3
  283. package/dist/src/storage/migrations/004_create_document_relationship_table.d.ts.map +0 -1
  284. package/dist/src/storage/migrations/004_create_document_relationship_table.js +0 -35
  285. package/dist/src/storage/migrations/004_create_document_relationship_table.js.map +0 -1
  286. package/dist/src/storage/migrations/005_create_indexer_state_table.d.ts +0 -3
  287. package/dist/src/storage/migrations/005_create_indexer_state_table.d.ts.map +0 -1
  288. package/dist/src/storage/migrations/005_create_indexer_state_table.js +0 -10
  289. package/dist/src/storage/migrations/005_create_indexer_state_table.js.map +0 -1
  290. package/dist/src/storage/migrations/006_create_document_snapshot_table.d.ts +0 -3
  291. package/dist/src/storage/migrations/006_create_document_snapshot_table.d.ts.map +0 -1
  292. package/dist/src/storage/migrations/006_create_document_snapshot_table.js +0 -49
  293. package/dist/src/storage/migrations/006_create_document_snapshot_table.js.map +0 -1
  294. package/dist/src/storage/migrations/007_create_slug_mapping_table.d.ts +0 -3
  295. package/dist/src/storage/migrations/007_create_slug_mapping_table.d.ts.map +0 -1
  296. package/dist/src/storage/migrations/007_create_slug_mapping_table.js +0 -24
  297. package/dist/src/storage/migrations/007_create_slug_mapping_table.js.map +0 -1
  298. package/dist/src/storage/migrations/008_create_view_state_table.d.ts +0 -3
  299. package/dist/src/storage/migrations/008_create_view_state_table.d.ts.map +0 -1
  300. package/dist/src/storage/migrations/008_create_view_state_table.js +0 -10
  301. package/dist/src/storage/migrations/008_create_view_state_table.js.map +0 -1
  302. package/dist/src/storage/migrations/009_create_operation_index_tables.d.ts +0 -3
  303. package/dist/src/storage/migrations/009_create_operation_index_tables.d.ts.map +0 -1
  304. package/dist/src/storage/migrations/009_create_operation_index_tables.js +0 -50
  305. package/dist/src/storage/migrations/009_create_operation_index_tables.js.map +0 -1
  306. package/dist/src/storage/migrations/010_create_sync_tables.d.ts +0 -3
  307. package/dist/src/storage/migrations/010_create_sync_tables.d.ts.map +0 -1
  308. package/dist/src/storage/migrations/010_create_sync_tables.js +0 -43
  309. package/dist/src/storage/migrations/010_create_sync_tables.js.map +0 -1
  310. package/dist/src/storage/migrations/index.d.ts +0 -3
  311. package/dist/src/storage/migrations/index.d.ts.map +0 -1
  312. package/dist/src/storage/migrations/index.js +0 -3
  313. package/dist/src/storage/migrations/index.js.map +0 -1
  314. package/dist/src/storage/migrations/migrator.d.ts +0 -6
  315. package/dist/src/storage/migrations/migrator.d.ts.map +0 -1
  316. package/dist/src/storage/migrations/migrator.js +0 -78
  317. package/dist/src/storage/migrations/migrator.js.map +0 -1
  318. package/dist/src/storage/migrations/run-migrations.d.ts +0 -2
  319. package/dist/src/storage/migrations/run-migrations.d.ts.map +0 -1
  320. package/dist/src/storage/migrations/run-migrations.js +0 -58
  321. package/dist/src/storage/migrations/run-migrations.js.map +0 -1
  322. package/dist/src/storage/migrations/types.d.ts +0 -9
  323. package/dist/src/storage/migrations/types.d.ts.map +0 -1
  324. package/dist/src/storage/migrations/types.js +0 -2
  325. package/dist/src/storage/migrations/types.js.map +0 -1
  326. package/dist/src/storage/txn.d.ts +0 -15
  327. package/dist/src/storage/txn.d.ts.map +0 -1
  328. package/dist/src/storage/txn.js +0 -42
  329. package/dist/src/storage/txn.js.map +0 -1
  330. package/dist/src/subs/default-error-handler.d.ts +0 -13
  331. package/dist/src/subs/default-error-handler.d.ts.map +0 -1
  332. package/dist/src/subs/default-error-handler.js +0 -27
  333. package/dist/src/subs/default-error-handler.js.map +0 -1
  334. package/dist/src/subs/react-subscription-manager.d.ts +0 -45
  335. package/dist/src/subs/react-subscription-manager.d.ts.map +0 -1
  336. package/dist/src/subs/react-subscription-manager.js +0 -185
  337. package/dist/src/subs/react-subscription-manager.js.map +0 -1
  338. package/dist/src/subs/subscription-notification-read-model.d.ts +0 -17
  339. package/dist/src/subs/subscription-notification-read-model.d.ts.map +0 -1
  340. package/dist/src/subs/subscription-notification-read-model.js +0 -62
  341. package/dist/src/subs/subscription-notification-read-model.js.map +0 -1
  342. package/dist/src/subs/types.d.ts +0 -64
  343. package/dist/src/subs/types.d.ts.map +0 -1
  344. package/dist/src/subs/types.js +0 -2
  345. package/dist/src/subs/types.js.map +0 -1
  346. package/dist/src/sync/channels/composite-channel-factory.d.ts +0 -30
  347. package/dist/src/sync/channels/composite-channel-factory.d.ts.map +0 -1
  348. package/dist/src/sync/channels/composite-channel-factory.js +0 -87
  349. package/dist/src/sync/channels/composite-channel-factory.js.map +0 -1
  350. package/dist/src/sync/channels/gql-channel-factory.d.ts +0 -25
  351. package/dist/src/sync/channels/gql-channel-factory.d.ts.map +0 -1
  352. package/dist/src/sync/channels/gql-channel-factory.js +0 -76
  353. package/dist/src/sync/channels/gql-channel-factory.js.map +0 -1
  354. package/dist/src/sync/channels/gql-channel.d.ts +0 -118
  355. package/dist/src/sync/channels/gql-channel.d.ts.map +0 -1
  356. package/dist/src/sync/channels/gql-channel.js +0 -423
  357. package/dist/src/sync/channels/gql-channel.js.map +0 -1
  358. package/dist/src/sync/channels/index.d.ts +0 -6
  359. package/dist/src/sync/channels/index.d.ts.map +0 -1
  360. package/dist/src/sync/channels/index.js +0 -6
  361. package/dist/src/sync/channels/index.js.map +0 -1
  362. package/dist/src/sync/channels/polling-channel.d.ts +0 -39
  363. package/dist/src/sync/channels/polling-channel.d.ts.map +0 -1
  364. package/dist/src/sync/channels/polling-channel.js +0 -72
  365. package/dist/src/sync/channels/polling-channel.js.map +0 -1
  366. package/dist/src/sync/channels/utils.d.ts +0 -30
  367. package/dist/src/sync/channels/utils.d.ts.map +0 -1
  368. package/dist/src/sync/channels/utils.js +0 -96
  369. package/dist/src/sync/channels/utils.js.map +0 -1
  370. package/dist/src/sync/errors.d.ts +0 -10
  371. package/dist/src/sync/errors.d.ts.map +0 -1
  372. package/dist/src/sync/errors.js +0 -17
  373. package/dist/src/sync/errors.js.map +0 -1
  374. package/dist/src/sync/index.d.ts +0 -12
  375. package/dist/src/sync/index.d.ts.map +0 -1
  376. package/dist/src/sync/index.js +0 -9
  377. package/dist/src/sync/index.js.map +0 -1
  378. package/dist/src/sync/interfaces.d.ts +0 -180
  379. package/dist/src/sync/interfaces.d.ts.map +0 -1
  380. package/dist/src/sync/interfaces.js +0 -2
  381. package/dist/src/sync/interfaces.js.map +0 -1
  382. package/dist/src/sync/mailbox.d.ts +0 -21
  383. package/dist/src/sync/mailbox.d.ts.map +0 -1
  384. package/dist/src/sync/mailbox.js +0 -59
  385. package/dist/src/sync/mailbox.js.map +0 -1
  386. package/dist/src/sync/sync-builder.d.ts +0 -19
  387. package/dist/src/sync/sync-builder.d.ts.map +0 -1
  388. package/dist/src/sync/sync-builder.js +0 -39
  389. package/dist/src/sync/sync-builder.js.map +0 -1
  390. package/dist/src/sync/sync-manager.d.ts +0 -37
  391. package/dist/src/sync/sync-manager.d.ts.map +0 -1
  392. package/dist/src/sync/sync-manager.js +0 -266
  393. package/dist/src/sync/sync-manager.js.map +0 -1
  394. package/dist/src/sync/sync-operation.d.ts +0 -28
  395. package/dist/src/sync/sync-operation.d.ts.map +0 -1
  396. package/dist/src/sync/sync-operation.js +0 -63
  397. package/dist/src/sync/sync-operation.js.map +0 -1
  398. package/dist/src/sync/types.d.ts +0 -60
  399. package/dist/src/sync/types.d.ts.map +0 -1
  400. package/dist/src/sync/types.js +0 -16
  401. package/dist/src/sync/types.js.map +0 -1
  402. package/dist/src/sync/utils.d.ts +0 -36
  403. package/dist/src/sync/utils.d.ts.map +0 -1
  404. package/dist/src/sync/utils.js +0 -78
  405. package/dist/src/sync/utils.js.map +0 -1
  406. package/dist/src/utils/reshuffle.d.ts +0 -30
  407. package/dist/src/utils/reshuffle.d.ts.map +0 -1
  408. package/dist/src/utils/reshuffle.js +0 -47
  409. package/dist/src/utils/reshuffle.js.map +0 -1
@@ -1,266 +0,0 @@
1
- import { OperationEventTypes, } from "../events/types.js";
2
- import { JobAwaiter } from "../shared/awaiter.js";
3
- import { JobStatus, } from "../shared/types.js";
4
- import { ChannelError } from "./errors.js";
5
- import { SyncOperation } from "./sync-operation.js";
6
- import { ChannelErrorSource, SyncOperationStatus } from "./types.js";
7
- import { batchOperationsByDocument, createIdleHealth, filterOperations, } from "./utils.js";
8
- export class SyncManager {
9
- logger;
10
- remoteStorage;
11
- cursorStorage;
12
- channelFactory;
13
- _operationIndex;
14
- reactor;
15
- eventBus;
16
- remotes;
17
- awaiter;
18
- isShutdown;
19
- eventUnsubscribe;
20
- loadJobs = new Map();
21
- constructor(logger, remoteStorage, cursorStorage, channelFactory, operationIndex, reactor, eventBus) {
22
- this.logger = logger;
23
- this.remoteStorage = remoteStorage;
24
- this.cursorStorage = cursorStorage;
25
- this.channelFactory = channelFactory;
26
- this._operationIndex = operationIndex;
27
- this.reactor = reactor;
28
- this.eventBus = eventBus;
29
- this.remotes = new Map();
30
- this.awaiter = new JobAwaiter(eventBus, (jobId, signal) => reactor.getJobStatus(jobId, signal));
31
- this.isShutdown = false;
32
- }
33
- async startup() {
34
- if (this.isShutdown) {
35
- throw new Error("SyncManager is already shutdown and cannot be started");
36
- }
37
- const remoteRecords = await this.remoteStorage.list();
38
- for (const record of remoteRecords) {
39
- const channel = this.channelFactory.instance(record.id, record.name, record.channelConfig, this.cursorStorage, record.collectionId, record.filter);
40
- try {
41
- await channel.init();
42
- }
43
- catch (error) {
44
- console.error(`Error initializing channel for remote ${record.name}: ${error instanceof Error ? error.message : String(error)}`);
45
- continue;
46
- }
47
- const remote = {
48
- id: record.id,
49
- name: record.name,
50
- collectionId: record.collectionId,
51
- filter: record.filter,
52
- options: record.options,
53
- channel,
54
- };
55
- this.remotes.set(record.name, remote);
56
- this.wireChannelCallbacks(remote);
57
- }
58
- this.eventUnsubscribe = this.eventBus.subscribe(OperationEventTypes.OPERATION_WRITTEN, (_type, event) => this.handleOperationWritten(event));
59
- }
60
- shutdown() {
61
- this.isShutdown = true;
62
- if (this.eventUnsubscribe) {
63
- this.eventUnsubscribe();
64
- this.eventUnsubscribe = undefined;
65
- }
66
- this.awaiter.shutdown();
67
- for (const remote of this.remotes.values()) {
68
- try {
69
- remote.channel.shutdown();
70
- }
71
- catch (error) {
72
- console.error(`Error shutting down channel for remote ${remote.name}: ${error instanceof Error ? error.message : String(error)}`);
73
- }
74
- }
75
- this.remotes.clear();
76
- return {
77
- isShutdown: true,
78
- };
79
- }
80
- getByName(name) {
81
- const remote = this.remotes.get(name);
82
- if (!remote) {
83
- throw new Error(`Remote with name '${name}' does not exist`);
84
- }
85
- return remote;
86
- }
87
- getById(id) {
88
- for (const remote of this.remotes.values()) {
89
- if (remote.id === id) {
90
- return remote;
91
- }
92
- }
93
- throw new Error(`Remote with id '${id}' does not exist`);
94
- }
95
- async add(name, collectionId, channelConfig, filter = { documentId: [], scope: [], branch: "" }, options = {}, id) {
96
- if (this.isShutdown) {
97
- throw new Error("SyncManager is shutdown and cannot add remotes");
98
- }
99
- if (this.remotes.has(name)) {
100
- throw new Error(`Remote with name '${name}' already exists`);
101
- }
102
- this.logger.debug("Adding remote (@name, @collectionId, @channelConfig, @filter, @options, @id)", name, collectionId, channelConfig, filter, options, id);
103
- const remoteId = id ?? crypto.randomUUID();
104
- const status = {
105
- push: createIdleHealth(),
106
- pull: createIdleHealth(),
107
- };
108
- const remoteRecord = {
109
- id: remoteId,
110
- name,
111
- collectionId,
112
- channelConfig,
113
- filter,
114
- options,
115
- status,
116
- };
117
- await this.remoteStorage.upsert(remoteRecord);
118
- const channel = this.channelFactory.instance(remoteId, name, channelConfig, this.cursorStorage, collectionId, filter);
119
- await channel.init();
120
- const remote = {
121
- id: remoteId,
122
- name,
123
- collectionId,
124
- filter,
125
- options,
126
- channel,
127
- };
128
- this.remotes.set(name, remote);
129
- this.wireChannelCallbacks(remote);
130
- await this.backfillOutbox(remote, collectionId, filter);
131
- return remote;
132
- }
133
- async backfillOutbox(remote, collectionId, filter) {
134
- let historicalOps;
135
- try {
136
- historicalOps = await this._operationIndex.find(collectionId);
137
- }
138
- catch {
139
- return;
140
- }
141
- if (historicalOps.items.length === 0) {
142
- return;
143
- }
144
- const opsWithContext = historicalOps.items.map((entry) => ({
145
- operation: {
146
- id: entry.id,
147
- index: entry.index,
148
- skip: entry.skip,
149
- hash: entry.hash,
150
- timestampUtcMs: entry.timestampUtcMs,
151
- action: entry.action,
152
- },
153
- context: {
154
- documentId: entry.documentId,
155
- documentType: entry.documentType,
156
- scope: entry.scope,
157
- branch: entry.branch,
158
- ordinal: entry.ordinal ?? 0,
159
- },
160
- }));
161
- const filteredOps = filterOperations(opsWithContext, filter);
162
- if (filteredOps.length === 0) {
163
- return;
164
- }
165
- const batches = batchOperationsByDocument(filteredOps);
166
- for (const batch of batches) {
167
- const syncOp = new SyncOperation(crypto.randomUUID(), remote.name, batch.documentId, [batch.scope], batch.branch, batch.operations);
168
- remote.channel.outbox.add(syncOp);
169
- }
170
- }
171
- async remove(name) {
172
- const remote = this.remotes.get(name);
173
- if (!remote) {
174
- throw new Error(`Remote with name '${name}' does not exist`);
175
- }
176
- await this.remoteStorage.remove(name);
177
- remote.channel.shutdown();
178
- this.remotes.delete(name);
179
- }
180
- list() {
181
- return Array.from(this.remotes.values());
182
- }
183
- wireChannelCallbacks(remote) {
184
- remote.channel.inbox.onAdded((syncOp) => {
185
- this.handleInboxJob(remote, syncOp);
186
- });
187
- remote.channel.outbox.onAdded((syncOp) => {
188
- this.handleOutboxJob(remote, syncOp);
189
- });
190
- }
191
- handleOperationWritten(event) {
192
- if (this.isShutdown) {
193
- return;
194
- }
195
- const sourceRemote = event.jobMeta?.sourceRemote;
196
- for (const remote of this.remotes.values()) {
197
- if (sourceRemote && remote.name === sourceRemote) {
198
- continue;
199
- }
200
- const filteredOps = filterOperations(event.operations, remote.filter);
201
- if (filteredOps.length === 0) {
202
- continue;
203
- }
204
- const batches = batchOperationsByDocument(filteredOps);
205
- for (const batch of batches) {
206
- const syncOp = new SyncOperation(crypto.randomUUID(), remote.name, batch.documentId, [batch.scope], batch.branch, batch.operations);
207
- remote.channel.outbox.add(syncOp);
208
- }
209
- }
210
- }
211
- handleInboxJob(remote, syncOp) {
212
- if (this.isShutdown) {
213
- return;
214
- }
215
- void this.applyInboxJob(remote, syncOp);
216
- }
217
- handleOutboxJob(remote, syncOp) {
218
- syncOp.on((syncOp, _prev, next) => {
219
- if (next === SyncOperationStatus.Applied) {
220
- remote.channel.outbox.remove(syncOp);
221
- }
222
- else if (next === SyncOperationStatus.Error) {
223
- remote.channel.outbox.remove(syncOp);
224
- }
225
- });
226
- }
227
- async applyInboxJob(remote, syncOp) {
228
- const operations = syncOp.operations.map((op) => op.operation);
229
- let jobInfo;
230
- try {
231
- jobInfo = await this.reactor.load(syncOp.documentId, syncOp.branch, operations, undefined, { sourceRemote: remote.name });
232
- }
233
- catch (error) {
234
- const err = error instanceof Error ? error : new Error(String(error));
235
- const channelError = new ChannelError(ChannelErrorSource.Inbox, err);
236
- syncOp.failed(channelError);
237
- remote.channel.deadLetter.add(syncOp);
238
- remote.channel.inbox.remove(syncOp);
239
- return;
240
- }
241
- let completedJobInfo;
242
- try {
243
- completedJobInfo = await this.awaiter.waitForJob(jobInfo.id);
244
- }
245
- catch (error) {
246
- const err = error instanceof Error ? error : new Error(String(error));
247
- const channelError = new ChannelError(ChannelErrorSource.Inbox, err);
248
- syncOp.failed(channelError);
249
- remote.channel.deadLetter.add(syncOp);
250
- remote.channel.inbox.remove(syncOp);
251
- return;
252
- }
253
- const jobKey = `${syncOp.documentId}:${syncOp.branch}`;
254
- this.loadJobs.set(jobKey, completedJobInfo);
255
- if (completedJobInfo.status === JobStatus.FAILED) {
256
- const error = new ChannelError(ChannelErrorSource.Inbox, new Error(`Failed to apply operations: ${completedJobInfo.error?.message || "Unknown error"}`));
257
- syncOp.failed(error);
258
- remote.channel.deadLetter.add(syncOp);
259
- }
260
- else {
261
- syncOp.executed();
262
- }
263
- remote.channel.inbox.remove(syncOp);
264
- }
265
- }
266
- //# sourceMappingURL=sync-manager.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-manager.js","sourceRoot":"","sources":["../../../src/sync/sync-manager.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,mBAAmB,GAEpB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,SAAS,GAGV,MAAM,oBAAoB,CAAC;AAK5B,OAAO,EAAE,YAAY,EAAE,MAAM,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,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACxC,CAAC;aAAM,CAAC;YACN,MAAM,CAAC,QAAQ,EAAE,CAAC;QACpB,CAAC;QAED,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;CACF"}
@@ -1,28 +0,0 @@
1
- import type { OperationWithContext } from "../storage/interfaces.js";
2
- import type { ChannelError } from "./errors.js";
3
- import { SyncOperationStatus } from "./types.js";
4
- type SyncOperationStatusCallback = (syncOp: SyncOperation, prev: SyncOperationStatus, next: SyncOperationStatus) => void;
5
- export declare class SyncOperationAggregateError extends Error {
6
- errors: Error[];
7
- constructor(errors: Error[]);
8
- }
9
- export declare class SyncOperation {
10
- readonly id: string;
11
- readonly remoteName: string;
12
- readonly documentId: string;
13
- readonly scopes: string[];
14
- readonly branch: string;
15
- readonly operations: OperationWithContext[];
16
- status: SyncOperationStatus;
17
- error?: ChannelError;
18
- private callbacks;
19
- constructor(id: string, remoteName: string, documentId: string, scopes: string[], branch: string, operations: OperationWithContext[]);
20
- on(callback: SyncOperationStatusCallback): void;
21
- started(): void;
22
- transported(): void;
23
- executed(): void;
24
- failed(error: ChannelError): void;
25
- private transition;
26
- }
27
- export {};
28
- //# sourceMappingURL=sync-operation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-operation.d.ts","sourceRoot":"","sources":["../../../src/sync/sync-operation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,KAAK,2BAA2B,GAAG,CACjC,MAAM,EAAE,aAAa,EACrB,IAAI,EAAE,mBAAmB,EACzB,IAAI,EAAE,mBAAmB,KACtB,IAAI,CAAC;AAEV,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,MAAM,EAAE,KAAK,EAAE,CAAC;gBAEJ,MAAM,EAAE,KAAK,EAAE;CAQ5B;AAED,qBAAa,aAAa;IACxB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,oBAAoB,EAAE,CAAC;IAC5C,MAAM,EAAE,mBAAmB,CAAC;IAC5B,KAAK,CAAC,EAAE,YAAY,CAAC;IAErB,OAAO,CAAC,SAAS,CAAqC;gBAGpD,EAAE,EAAE,MAAM,EACV,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EAAE,EAChB,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,oBAAoB,EAAE;IAWpC,EAAE,CAAC,QAAQ,EAAE,2BAA2B,GAAG,IAAI;IAI/C,OAAO,IAAI,IAAI;IAIf,WAAW,IAAI,IAAI;IAInB,QAAQ,IAAI,IAAI;IAIhB,MAAM,CAAC,KAAK,EAAE,YAAY,GAAG,IAAI;IAKjC,OAAO,CAAC,UAAU;CAenB"}
@@ -1,63 +0,0 @@
1
- import { SyncOperationStatus } from "./types.js";
2
- export class SyncOperationAggregateError extends Error {
3
- errors;
4
- constructor(errors) {
5
- const messages = errors.map((e) => e.message).join("; ");
6
- super(`SyncOperation callback failed with ${errors.length} error(s): ${messages}`);
7
- this.name = "SyncOperationAggregateError";
8
- this.errors = errors;
9
- }
10
- }
11
- export class SyncOperation {
12
- id;
13
- remoteName;
14
- documentId;
15
- scopes;
16
- branch;
17
- operations;
18
- status;
19
- error;
20
- callbacks = [];
21
- constructor(id, remoteName, documentId, scopes, branch, operations) {
22
- this.id = id;
23
- this.remoteName = remoteName;
24
- this.documentId = documentId;
25
- this.scopes = scopes;
26
- this.branch = branch;
27
- this.operations = operations;
28
- this.status = SyncOperationStatus.Unknown;
29
- }
30
- on(callback) {
31
- this.callbacks.push(callback);
32
- }
33
- started() {
34
- this.transition(SyncOperationStatus.TransportPending);
35
- }
36
- transported() {
37
- this.transition(SyncOperationStatus.ExecutionPending);
38
- }
39
- executed() {
40
- this.transition(SyncOperationStatus.Applied);
41
- }
42
- failed(error) {
43
- this.error = error;
44
- this.transition(SyncOperationStatus.Error);
45
- }
46
- transition(next) {
47
- const prev = this.status;
48
- this.status = next;
49
- const errors = [];
50
- for (const callback of this.callbacks) {
51
- try {
52
- callback(this, prev, next);
53
- }
54
- catch (error) {
55
- errors.push(error instanceof Error ? error : new Error(String(error)));
56
- }
57
- }
58
- if (errors.length > 0) {
59
- throw new SyncOperationAggregateError(errors);
60
- }
61
- }
62
- }
63
- //# sourceMappingURL=sync-operation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sync-operation.js","sourceRoot":"","sources":["../../../src/sync/sync-operation.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAQjD,MAAM,OAAO,2BAA4B,SAAQ,KAAK;IACpD,MAAM,CAAU;IAEhB,YAAY,MAAe;QACzB,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzD,KAAK,CACH,sCAAsC,MAAM,CAAC,MAAM,cAAc,QAAQ,EAAE,CAC5E,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAC;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,MAAM,OAAO,aAAa;IACf,EAAE,CAAS;IACX,UAAU,CAAS;IACnB,UAAU,CAAS;IACnB,MAAM,CAAW;IAC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IAAI,CAAC;gBACH,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;YAC7B,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,IAAI,CAAC,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACzE,CAAC;QACH,CAAC;QACD,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,2BAA2B,CAAC,MAAM,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;CACF"}
@@ -1,60 +0,0 @@
1
- import type { OperationWithContext } from "../storage/interfaces.js";
2
- export type RemoteOptions = {};
3
- export type RemoteFilter = {
4
- documentId: string[];
5
- scope: string[];
6
- branch: string;
7
- };
8
- export type RemoteCursor = {
9
- remoteName: string;
10
- cursorOrdinal: number;
11
- lastSyncedAtUtcMs?: number;
12
- };
13
- export type ChannelMeta = {
14
- id: string;
15
- };
16
- export type SyncEnvelopeType = "operations" | "ack";
17
- export type SyncEnvelope = {
18
- type: SyncEnvelopeType;
19
- channelMeta: ChannelMeta;
20
- operations?: OperationWithContext[];
21
- cursor?: RemoteCursor;
22
- };
23
- export declare enum SyncOperationStatus {
24
- Unknown = -1,
25
- TransportPending = 0,
26
- ExecutionPending = 1,
27
- Applied = 2,
28
- Error = 3
29
- }
30
- export declare enum ChannelErrorSource {
31
- None = "none",
32
- Channel = "channel",
33
- Inbox = "inbox",
34
- Outbox = "outbox"
35
- }
36
- export type SyncOperationErrorType = "SIGNATURE_INVALID" | "HASH_MISMATCH" | "LIBRARY_ERROR" | "MISSING_OPERATIONS" | "EXCESSIVE_SHUFFLE" | "GRACEFUL_ABORT";
37
- export type ChannelHealth = {
38
- state: "idle" | "running" | "error";
39
- lastSuccessUtcMs?: number;
40
- lastFailureUtcMs?: number;
41
- failureCount: number;
42
- };
43
- export type RemoteStatus = {
44
- push: ChannelHealth;
45
- pull: ChannelHealth;
46
- };
47
- export type ChannelConfig = {
48
- type: string;
49
- parameters: Record<string, unknown>;
50
- };
51
- export type RemoteRecord = {
52
- id: string;
53
- name: string;
54
- collectionId: string;
55
- channelConfig: ChannelConfig;
56
- filter: RemoteFilter;
57
- options: RemoteOptions;
58
- status: RemoteStatus;
59
- };
60
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/sync/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AAGrE,MAAM,MAAM,aAAa,GAAG,EAE3B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,YAAY,GAAG,KAAK,CAAC;AAEpD,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,gBAAgB,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC;IACzB,UAAU,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACpC,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB,CAAC;AAEF,oBAAY,mBAAmB;IAC7B,OAAO,KAAK;IACZ,gBAAgB,IAAI;IACpB,gBAAgB,IAAI;IACpB,OAAO,IAAI;IACX,KAAK,IAAI;CACV;AAED,oBAAY,kBAAkB;IAC5B,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,sBAAsB,GAC9B,mBAAmB,GACnB,eAAe,GACf,eAAe,GACf,oBAAoB,GACpB,mBAAmB,GACnB,gBAAgB,CAAC;AAErB,MAAM,MAAM,aAAa,GAAG;IAC1B,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IACpC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,aAAa,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,aAAa,CAAC;IAC7B,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,aAAa,CAAC;IACvB,MAAM,EAAE,YAAY,CAAC;CACtB,CAAC"}
@@ -1,16 +0,0 @@
1
- export var SyncOperationStatus;
2
- (function (SyncOperationStatus) {
3
- SyncOperationStatus[SyncOperationStatus["Unknown"] = -1] = "Unknown";
4
- SyncOperationStatus[SyncOperationStatus["TransportPending"] = 0] = "TransportPending";
5
- SyncOperationStatus[SyncOperationStatus["ExecutionPending"] = 1] = "ExecutionPending";
6
- SyncOperationStatus[SyncOperationStatus["Applied"] = 2] = "Applied";
7
- SyncOperationStatus[SyncOperationStatus["Error"] = 3] = "Error";
8
- })(SyncOperationStatus || (SyncOperationStatus = {}));
9
- export var ChannelErrorSource;
10
- (function (ChannelErrorSource) {
11
- ChannelErrorSource["None"] = "none";
12
- ChannelErrorSource["Channel"] = "channel";
13
- ChannelErrorSource["Inbox"] = "inbox";
14
- ChannelErrorSource["Outbox"] = "outbox";
15
- })(ChannelErrorSource || (ChannelErrorSource = {}));
16
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/sync/types.ts"],"names":[],"mappings":"AAgCA,MAAM,CAAN,IAAY,mBAMX;AAND,WAAY,mBAAmB;IAC7B,oEAAY,CAAA;IACZ,qFAAoB,CAAA;IACpB,qFAAoB,CAAA;IACpB,mEAAW,CAAA;IACX,+DAAS,CAAA;AACX,CAAC,EANW,mBAAmB,KAAnB,mBAAmB,QAM9B;AAED,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,mCAAa,CAAA;IACb,yCAAmB,CAAA;IACnB,qCAAe,CAAA;IACf,uCAAiB,CAAA;AACnB,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B"}
@@ -1,36 +0,0 @@
1
- import type { OperationWithContext } from "../storage/interfaces.js";
2
- import type { ChannelHealth, RemoteFilter } from "./types.js";
3
- export type OperationBatch = {
4
- documentId: string;
5
- branch: string;
6
- scope: string;
7
- operations: OperationWithContext[];
8
- };
9
- /**
10
- * Filters operations based on a remote's filter criteria.
11
- *
12
- * @param operations - The operations to filter
13
- * @param filter - The filter criteria to apply
14
- * @returns The filtered operations that match the criteria
15
- */
16
- export declare function filterOperations(operations: OperationWithContext[], filter: RemoteFilter): OperationWithContext[];
17
- /**
18
- * Creates an idle channel health status.
19
- *
20
- * @returns A new idle channel health object
21
- */
22
- export declare function createIdleHealth(): ChannelHealth;
23
- /**
24
- * Batches consecutive operations by documentId and scope, preserving ordering.
25
- *
26
- * For operations [a1_doc, a1_global, a2_doc, b1_global], this returns:
27
- * - Batch 1: [a1_doc] for doc-a, document scope
28
- * - Batch 2: [a1_global] for doc-a, global scope
29
- * - Batch 3: [a2_doc] for doc-a, document scope
30
- * - Batch 4: [b1_global] for doc-b, global scope
31
- *
32
- * This ensures operations are grouped for efficient processing while maintaining
33
- * causality across documents and scopes.
34
- */
35
- export declare function batchOperationsByDocument(operations: OperationWithContext[]): OperationBatch[];
36
- //# sourceMappingURL=utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/sync/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE9D,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,oBAAoB,EAAE,CAAC;CACpC,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,oBAAoB,EAAE,EAClC,MAAM,EAAE,YAAY,GACnB,oBAAoB,EAAE,CAmBxB;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,aAAa,CAKhD;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CACvC,UAAU,EAAE,oBAAoB,EAAE,GACjC,cAAc,EAAE,CAsClB"}
@@ -1,78 +0,0 @@
1
- /**
2
- * Filters operations based on a remote's filter criteria.
3
- *
4
- * @param operations - The operations to filter
5
- * @param filter - The filter criteria to apply
6
- * @returns The filtered operations that match the criteria
7
- */
8
- export function filterOperations(operations, filter) {
9
- return operations.filter((op) => {
10
- if (filter.branch && op.context.branch !== filter.branch) {
11
- return false;
12
- }
13
- if (filter.documentId.length > 0 &&
14
- !filter.documentId.includes(op.context.documentId)) {
15
- return false;
16
- }
17
- if (filter.scope.length > 0 && !filter.scope.includes(op.context.scope)) {
18
- return false;
19
- }
20
- return true;
21
- });
22
- }
23
- /**
24
- * Creates an idle channel health status.
25
- *
26
- * @returns A new idle channel health object
27
- */
28
- export function createIdleHealth() {
29
- return {
30
- state: "idle",
31
- failureCount: 0,
32
- };
33
- }
34
- /**
35
- * Batches consecutive operations by documentId and scope, preserving ordering.
36
- *
37
- * For operations [a1_doc, a1_global, a2_doc, b1_global], this returns:
38
- * - Batch 1: [a1_doc] for doc-a, document scope
39
- * - Batch 2: [a1_global] for doc-a, global scope
40
- * - Batch 3: [a2_doc] for doc-a, document scope
41
- * - Batch 4: [b1_global] for doc-b, global scope
42
- *
43
- * This ensures operations are grouped for efficient processing while maintaining
44
- * causality across documents and scopes.
45
- */
46
- export function batchOperationsByDocument(operations) {
47
- const batches = [];
48
- let currentDocId = null;
49
- let currentScope = null;
50
- let currentBatch = [];
51
- const flushBatch = () => {
52
- if (currentBatch.length === 0 ||
53
- currentDocId === null ||
54
- currentScope === null) {
55
- return;
56
- }
57
- batches.push({
58
- documentId: currentDocId,
59
- branch: currentBatch[0].context.branch,
60
- scope: currentScope,
61
- operations: currentBatch,
62
- });
63
- currentBatch = [];
64
- };
65
- for (const op of operations) {
66
- const docId = op.context.documentId;
67
- const scope = op.context.scope;
68
- if (docId !== currentDocId || scope !== currentScope) {
69
- flushBatch();
70
- currentDocId = docId;
71
- currentScope = scope;
72
- }
73
- currentBatch.push(op);
74
- }
75
- flushBatch();
76
- return batches;
77
- }
78
- //# sourceMappingURL=utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/sync/utils.ts"],"names":[],"mappings":"AAUA;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAC9B,UAAkC,EAClC,MAAoB;IAEpB,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE;QAC9B,IAAI,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC;YACzD,OAAO,KAAK,CAA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AAG,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC;QACpC,MAAM,KAAK,GAAG,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;QAC/B,IAAI,KAAK,KAAK,YAAY,IAAI,KAAK,KAAK,YAAY,EAAE,CAAC;YACrD,UAAU,EAAE,CAAC;YACb,YAAY,GAAG,KAAK,CAAC;YACrB,YAAY,GAAG,KAAK,CAAC;QACvB,CAAC;QACD,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACxB,CAAC;IAED,UAAU,EAAE,CAAC;IACb,OAAO,OAAO,CAAC;AACjB,CAAC"}
@@ -1,30 +0,0 @@
1
- type OperationIndex = {
2
- index: number;
3
- skip: number;
4
- id?: string;
5
- timestampUtcMs?: string;
6
- };
7
- /**
8
- * Sorts operations by index and skip number.
9
- * [0:0 2:0 1:0 3:3 3:1] => [0:0 1:0 2:0 3:1 3:3]
10
- */
11
- export declare function sortOperations<TOpIndex extends OperationIndex>(operations: TOpIndex[]): TOpIndex[];
12
- /**
13
- * Reshuffles operations by timestamp only, ignoring their original index values.
14
- * Used for merging concurrent operations from different branches.
15
- *
16
- * Example:
17
- * [0:0, 1:0, 2:0, A3:0, A4:0, A5:0] + [0:0, 1:0, 2:0, B3:0, B4:2, B5:0]
18
- * GC => [0:0, 1:0, 2:0, A3:0, A4:0, A5:0] + [0:0, 1:0, B4:2, B5:0]
19
- * Split => [0:0, 1:0] + [2:0, A3:0, A4:0, A5:0] + [B4:2, B5:0]
20
- * Reshuffle(6:4) => [6:4, 7:0, 8:0, 9:0, 10:0, 11:0]
21
- * merge => [0:0, 1:0, 6:4, 7:0, 8:0, 9:0, 10:0, 11:0]
22
- */
23
- export declare function reshuffleByTimestamp<TOp extends OperationIndex>(startIndex: OperationIndex, opsA: TOp[], opsB: TOp[]): TOp[];
24
- /**
25
- * Reshuffles operations by timestamp first, then by original index value.
26
- * Used for merging concurrent operations while preserving index ordering for operations with same timestamp.
27
- */
28
- export declare function reshuffleByTimestampAndIndex<TOp extends OperationIndex>(startIndex: OperationIndex, opsA: TOp[], opsB: TOp[]): TOp[];
29
- export {};
30
- //# sourceMappingURL=reshuffle.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reshuffle.d.ts","sourceRoot":"","sources":["../../../src/utils/reshuffle.ts"],"names":[],"mappings":"AAAA,KAAK,cAAc,GAAG;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF;;;GAGG;AACH,wBAAgB,cAAc,CAAC,QAAQ,SAAS,cAAc,EAC5D,UAAU,EAAE,QAAQ,EAAE,GACrB,QAAQ,EAAE,CAKZ;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,SAAS,cAAc,EAC7D,UAAU,EAAE,cAAc,EAC1B,IAAI,EAAE,GAAG,EAAE,EACX,IAAI,EAAE,GAAG,EAAE,GACV,GAAG,EAAE,CAYP;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,SAAS,cAAc,EACrE,UAAU,EAAE,cAAc,EAC1B,IAAI,EAAE,GAAG,EAAE,EACX,IAAI,EAAE,GAAG,EAAE,GACV,GAAG,EAAE,CAaP"}