@powerhousedao/reactor 6.0.0-dev.7 → 6.0.0-dev.77

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 (371) hide show
  1. package/dist/src/cache/collection-membership-cache.d.ts +13 -0
  2. package/dist/src/cache/collection-membership-cache.d.ts.map +1 -0
  3. package/dist/src/cache/document-meta-cache.d.ts.map +1 -1
  4. package/dist/src/cache/kysely-operation-index.d.ts +6 -1
  5. package/dist/src/cache/kysely-operation-index.d.ts.map +1 -1
  6. package/dist/src/cache/kysely-write-cache.d.ts +9 -2
  7. package/dist/src/cache/kysely-write-cache.d.ts.map +1 -1
  8. package/dist/src/cache/operation-index-types.d.ts +16 -2
  9. package/dist/src/cache/operation-index-types.d.ts.map +1 -1
  10. package/dist/src/cache/write/interfaces.d.ts +7 -2
  11. package/dist/src/cache/write/interfaces.d.ts.map +1 -1
  12. package/dist/src/client/reactor-client.d.ts +13 -10
  13. package/dist/src/client/reactor-client.d.ts.map +1 -1
  14. package/dist/src/client/types.d.ts +25 -6
  15. package/dist/src/client/types.d.ts.map +1 -1
  16. package/dist/src/core/reactor-builder.d.ts +23 -7
  17. package/dist/src/core/reactor-builder.d.ts.map +1 -1
  18. package/dist/src/core/reactor-client-builder.d.ts +5 -4
  19. package/dist/src/core/reactor-client-builder.d.ts.map +1 -1
  20. package/dist/src/core/reactor.d.ts +20 -80
  21. package/dist/src/core/reactor.d.ts.map +1 -1
  22. package/dist/src/core/types.d.ts +64 -28
  23. package/dist/src/core/types.d.ts.map +1 -1
  24. package/dist/src/core/utils.d.ts +39 -3
  25. package/dist/src/core/utils.d.ts.map +1 -1
  26. package/dist/src/events/types.d.ts +35 -10
  27. package/dist/src/events/types.d.ts.map +1 -1
  28. package/dist/src/executor/document-action-handler.d.ts +37 -0
  29. package/dist/src/executor/document-action-handler.d.ts.map +1 -0
  30. package/dist/src/executor/signature-verifier.d.ts +9 -0
  31. package/dist/src/executor/signature-verifier.d.ts.map +1 -0
  32. package/dist/src/executor/simple-job-executor-manager.d.ts +6 -1
  33. package/dist/src/executor/simple-job-executor-manager.d.ts.map +1 -1
  34. package/dist/src/executor/simple-job-executor.d.ts +6 -46
  35. package/dist/src/executor/simple-job-executor.d.ts.map +1 -1
  36. package/dist/src/executor/types.d.ts +1 -3
  37. package/dist/src/executor/types.d.ts.map +1 -1
  38. package/dist/src/executor/util.d.ts +12 -2
  39. package/dist/src/executor/util.d.ts.map +1 -1
  40. package/dist/src/index.d.ts +11 -9
  41. package/dist/src/index.d.ts.map +1 -1
  42. package/dist/src/index.js +19998 -61
  43. package/dist/src/job-tracker/in-memory-job-tracker.d.ts +4 -3
  44. package/dist/src/job-tracker/in-memory-job-tracker.d.ts.map +1 -1
  45. package/dist/src/job-tracker/interfaces.d.ts +3 -1
  46. package/dist/src/job-tracker/interfaces.d.ts.map +1 -1
  47. package/dist/src/logging/console.d.ts +1 -22
  48. package/dist/src/logging/console.d.ts.map +1 -1
  49. package/dist/src/logging/types.d.ts +1 -11
  50. package/dist/src/logging/types.d.ts.map +1 -1
  51. package/dist/src/processors/index.d.ts +1 -1
  52. package/dist/src/processors/index.d.ts.map +1 -1
  53. package/dist/src/processors/processor-manager.d.ts +2 -2
  54. package/dist/src/processors/processor-manager.d.ts.map +1 -1
  55. package/dist/src/processors/relational/types.d.ts +2 -0
  56. package/dist/src/processors/relational/types.d.ts.map +1 -0
  57. package/dist/src/processors/relational/utils.d.ts +2 -0
  58. package/dist/src/processors/relational/utils.d.ts.map +1 -0
  59. package/dist/src/processors/utils.d.ts +2 -2
  60. package/dist/src/processors/utils.d.ts.map +1 -1
  61. package/dist/src/queue/job-execution-handle.d.ts +3 -0
  62. package/dist/src/queue/job-execution-handle.d.ts.map +1 -1
  63. package/dist/src/queue/queue.d.ts +30 -1
  64. package/dist/src/queue/queue.d.ts.map +1 -1
  65. package/dist/src/queue/types.d.ts +4 -3
  66. package/dist/src/queue/types.d.ts.map +1 -1
  67. package/dist/src/read-models/base-read-model.d.ts +1 -1
  68. package/dist/src/read-models/base-read-model.d.ts.map +1 -1
  69. package/dist/src/read-models/coordinator.d.ts +2 -2
  70. package/dist/src/read-models/coordinator.d.ts.map +1 -1
  71. package/dist/src/read-models/document-view.d.ts +6 -3
  72. package/dist/src/read-models/document-view.d.ts.map +1 -1
  73. package/dist/src/read-models/interfaces.d.ts +1 -1
  74. package/dist/src/read-models/interfaces.d.ts.map +1 -1
  75. package/dist/src/registry/document-model-resolver.d.ts +29 -0
  76. package/dist/src/registry/document-model-resolver.d.ts.map +1 -0
  77. package/dist/src/registry/implementation.d.ts +4 -0
  78. package/dist/src/registry/implementation.d.ts.map +1 -1
  79. package/dist/src/registry/index.d.ts +3 -1
  80. package/dist/src/registry/index.d.ts.map +1 -1
  81. package/dist/src/registry/interfaces.d.ts +8 -0
  82. package/dist/src/registry/interfaces.d.ts.map +1 -1
  83. package/dist/src/shared/awaiter.d.ts +2 -2
  84. package/dist/src/shared/awaiter.d.ts.map +1 -1
  85. package/dist/src/shared/collect-all-pages.d.ts +7 -0
  86. package/dist/src/shared/collect-all-pages.d.ts.map +1 -0
  87. package/dist/src/shared/drive-url.d.ts +15 -0
  88. package/dist/src/shared/drive-url.d.ts.map +1 -0
  89. package/dist/src/shared/errors.d.ts +9 -0
  90. package/dist/src/shared/errors.d.ts.map +1 -1
  91. package/dist/src/shared/factories.d.ts +6 -2
  92. package/dist/src/shared/factories.d.ts.map +1 -1
  93. package/dist/src/shared/types.d.ts +32 -6
  94. package/dist/src/shared/types.d.ts.map +1 -1
  95. package/dist/src/signer/passthrough-signer.d.ts +1 -1
  96. package/dist/src/signer/passthrough-signer.d.ts.map +1 -1
  97. package/dist/src/storage/interfaces.d.ts +238 -124
  98. package/dist/src/storage/interfaces.d.ts.map +1 -1
  99. package/dist/src/storage/kysely/document-indexer.d.ts +8 -7
  100. package/dist/src/storage/kysely/document-indexer.d.ts.map +1 -1
  101. package/dist/src/storage/kysely/store.d.ts +5 -4
  102. package/dist/src/storage/kysely/store.d.ts.map +1 -1
  103. package/dist/src/storage/kysely/sync-cursor-storage.d.ts +1 -1
  104. package/dist/src/storage/kysely/sync-cursor-storage.d.ts.map +1 -1
  105. package/dist/src/storage/kysely/sync-dead-letter-storage.d.ts +17 -0
  106. package/dist/src/storage/kysely/sync-dead-letter-storage.d.ts.map +1 -0
  107. package/dist/src/storage/kysely/types.d.ts +22 -0
  108. package/dist/src/storage/kysely/types.d.ts.map +1 -1
  109. package/dist/src/storage/migrations/011_add_cursor_type_column.d.ts +3 -0
  110. package/dist/src/storage/migrations/011_add_cursor_type_column.d.ts.map +1 -0
  111. package/dist/src/storage/migrations/012_add_source_remote_column.d.ts +3 -0
  112. package/dist/src/storage/migrations/012_add_source_remote_column.d.ts.map +1 -0
  113. package/dist/src/storage/migrations/013_create_sync_dead_letters_table.d.ts +3 -0
  114. package/dist/src/storage/migrations/013_create_sync_dead_letters_table.d.ts.map +1 -0
  115. package/dist/src/storage/migrations/migrator.d.ts.map +1 -1
  116. package/dist/src/subs/default-error-handler.d.ts.map +1 -1
  117. package/dist/src/subs/subscription-notification-read-model.d.ts +3 -2
  118. package/dist/src/subs/subscription-notification-read-model.d.ts.map +1 -1
  119. package/dist/src/sync/batch-aggregator.d.ts +25 -0
  120. package/dist/src/sync/batch-aggregator.d.ts.map +1 -0
  121. package/dist/src/sync/buffered-mailbox.d.ts +36 -0
  122. package/dist/src/sync/buffered-mailbox.d.ts.map +1 -0
  123. package/dist/src/sync/channels/{gql-channel.d.ts → gql-req-channel.d.ts} +49 -42
  124. package/dist/src/sync/channels/gql-req-channel.d.ts.map +1 -0
  125. package/dist/src/sync/channels/gql-request-channel-factory.d.ts +32 -0
  126. package/dist/src/sync/channels/gql-request-channel-factory.d.ts.map +1 -0
  127. package/dist/src/sync/channels/gql-res-channel.d.ts +25 -0
  128. package/dist/src/sync/channels/gql-res-channel.d.ts.map +1 -0
  129. package/dist/src/sync/channels/gql-response-channel-factory.d.ts +13 -0
  130. package/dist/src/sync/channels/gql-response-channel-factory.d.ts.map +1 -0
  131. package/dist/src/sync/channels/index.d.ts +6 -4
  132. package/dist/src/sync/channels/index.d.ts.map +1 -1
  133. package/dist/src/sync/channels/interval-poll-timer.d.ts +40 -0
  134. package/dist/src/sync/channels/interval-poll-timer.d.ts.map +1 -0
  135. package/dist/src/sync/channels/poll-timer.d.ts +14 -0
  136. package/dist/src/sync/channels/poll-timer.d.ts.map +1 -0
  137. package/dist/src/sync/channels/utils.d.ts +15 -1
  138. package/dist/src/sync/channels/utils.d.ts.map +1 -1
  139. package/dist/src/sync/index.d.ts +10 -6
  140. package/dist/src/sync/index.d.ts.map +1 -1
  141. package/dist/src/sync/interfaces.d.ts +34 -21
  142. package/dist/src/sync/interfaces.d.ts.map +1 -1
  143. package/dist/src/sync/mailbox.d.ts +51 -12
  144. package/dist/src/sync/mailbox.d.ts.map +1 -1
  145. package/dist/src/sync/sync-awaiter.d.ts +34 -0
  146. package/dist/src/sync/sync-awaiter.d.ts.map +1 -0
  147. package/dist/src/sync/sync-builder.d.ts +5 -1
  148. package/dist/src/sync/sync-builder.d.ts.map +1 -1
  149. package/dist/src/sync/sync-manager.d.ts +21 -8
  150. package/dist/src/sync/sync-manager.d.ts.map +1 -1
  151. package/dist/src/sync/sync-operation.d.ts +4 -2
  152. package/dist/src/sync/sync-operation.d.ts.map +1 -1
  153. package/dist/src/sync/sync-status-tracker.d.ts +31 -0
  154. package/dist/src/sync/sync-status-tracker.d.ts.map +1 -0
  155. package/dist/src/sync/types.d.ts +90 -2
  156. package/dist/src/sync/types.d.ts.map +1 -1
  157. package/dist/src/sync/utils.d.ts +37 -2
  158. package/dist/src/sync/utils.d.ts.map +1 -1
  159. package/dist/src/utils/reshuffle.d.ts +22 -5
  160. package/dist/src/utils/reshuffle.d.ts.map +1 -1
  161. package/package.json +24 -20
  162. package/dist/src/actions/index.js +0 -76
  163. package/dist/src/actions/index.js.map +0 -1
  164. package/dist/src/cache/buffer/ring-buffer.js +0 -69
  165. package/dist/src/cache/buffer/ring-buffer.js.map +0 -1
  166. package/dist/src/cache/document-meta-cache-types.js +0 -2
  167. package/dist/src/cache/document-meta-cache-types.js.map +0 -1
  168. package/dist/src/cache/document-meta-cache.js +0 -128
  169. package/dist/src/cache/document-meta-cache.js.map +0 -1
  170. package/dist/src/cache/index.js +0 -2
  171. package/dist/src/cache/index.js.map +0 -1
  172. package/dist/src/cache/kysely-operation-index.js +0 -250
  173. package/dist/src/cache/kysely-operation-index.js.map +0 -1
  174. package/dist/src/cache/kysely-write-cache.js +0 -388
  175. package/dist/src/cache/kysely-write-cache.js.map +0 -1
  176. package/dist/src/cache/lru/lru-tracker.js +0 -96
  177. package/dist/src/cache/lru/lru-tracker.js.map +0 -1
  178. package/dist/src/cache/operation-index-types.js +0 -4
  179. package/dist/src/cache/operation-index-types.js.map +0 -1
  180. package/dist/src/cache/write/interfaces.js +0 -2
  181. package/dist/src/cache/write/interfaces.js.map +0 -1
  182. package/dist/src/cache/write-cache-types.js +0 -2
  183. package/dist/src/cache/write-cache-types.js.map +0 -1
  184. package/dist/src/client/reactor-client.js +0 -406
  185. package/dist/src/client/reactor-client.js.map +0 -1
  186. package/dist/src/client/types.js +0 -14
  187. package/dist/src/client/types.js.map +0 -1
  188. package/dist/src/core/reactor-builder.js +0 -231
  189. package/dist/src/core/reactor-builder.js.map +0 -1
  190. package/dist/src/core/reactor-client-builder.js +0 -123
  191. package/dist/src/core/reactor-client-builder.js.map +0 -1
  192. package/dist/src/core/reactor.js +0 -981
  193. package/dist/src/core/reactor.js.map +0 -1
  194. package/dist/src/core/types.js +0 -2
  195. package/dist/src/core/types.js.map +0 -1
  196. package/dist/src/core/utils.js +0 -171
  197. package/dist/src/core/utils.js.map +0 -1
  198. package/dist/src/events/event-bus.js +0 -53
  199. package/dist/src/events/event-bus.js.map +0 -1
  200. package/dist/src/events/interfaces.js +0 -2
  201. package/dist/src/events/interfaces.js.map +0 -1
  202. package/dist/src/events/types.js +0 -28
  203. package/dist/src/events/types.js.map +0 -1
  204. package/dist/src/executor/interfaces.js +0 -2
  205. package/dist/src/executor/interfaces.js.map +0 -1
  206. package/dist/src/executor/simple-job-executor-manager.js +0 -233
  207. package/dist/src/executor/simple-job-executor-manager.js.map +0 -1
  208. package/dist/src/executor/simple-job-executor.js +0 -898
  209. package/dist/src/executor/simple-job-executor.js.map +0 -1
  210. package/dist/src/executor/types.js +0 -11
  211. package/dist/src/executor/types.js.map +0 -1
  212. package/dist/src/executor/util.js +0 -184
  213. package/dist/src/executor/util.js.map +0 -1
  214. package/dist/src/index.js.map +0 -1
  215. package/dist/src/job-tracker/in-memory-job-tracker.js +0 -112
  216. package/dist/src/job-tracker/in-memory-job-tracker.js.map +0 -1
  217. package/dist/src/job-tracker/index.js +0 -2
  218. package/dist/src/job-tracker/index.js.map +0 -1
  219. package/dist/src/job-tracker/interfaces.js +0 -2
  220. package/dist/src/job-tracker/interfaces.js.map +0 -1
  221. package/dist/src/logging/console.js +0 -108
  222. package/dist/src/logging/console.js.map +0 -1
  223. package/dist/src/logging/types.js +0 -2
  224. package/dist/src/logging/types.js.map +0 -1
  225. package/dist/src/processors/index.js +0 -2
  226. package/dist/src/processors/index.js.map +0 -1
  227. package/dist/src/processors/processor-manager.js +0 -165
  228. package/dist/src/processors/processor-manager.js.map +0 -1
  229. package/dist/src/processors/types.d.ts +0 -63
  230. package/dist/src/processors/types.d.ts.map +0 -1
  231. package/dist/src/processors/types.js +0 -2
  232. package/dist/src/processors/types.js.map +0 -1
  233. package/dist/src/processors/utils.js +0 -58
  234. package/dist/src/processors/utils.js.map +0 -1
  235. package/dist/src/queue/interfaces.js +0 -2
  236. package/dist/src/queue/interfaces.js.map +0 -1
  237. package/dist/src/queue/job-execution-handle.js +0 -62
  238. package/dist/src/queue/job-execution-handle.js.map +0 -1
  239. package/dist/src/queue/queue.js +0 -384
  240. package/dist/src/queue/queue.js.map +0 -1
  241. package/dist/src/queue/types.js +0 -19
  242. package/dist/src/queue/types.js.map +0 -1
  243. package/dist/src/read-models/base-read-model.js +0 -143
  244. package/dist/src/read-models/base-read-model.js.map +0 -1
  245. package/dist/src/read-models/coordinator.js +0 -72
  246. package/dist/src/read-models/coordinator.js.map +0 -1
  247. package/dist/src/read-models/document-view.js +0 -375
  248. package/dist/src/read-models/document-view.js.map +0 -1
  249. package/dist/src/read-models/interfaces.js +0 -2
  250. package/dist/src/read-models/interfaces.js.map +0 -1
  251. package/dist/src/read-models/types.js +0 -2
  252. package/dist/src/read-models/types.js.map +0 -1
  253. package/dist/src/registry/implementation.js +0 -216
  254. package/dist/src/registry/implementation.js.map +0 -1
  255. package/dist/src/registry/index.js +0 -2
  256. package/dist/src/registry/index.js.map +0 -1
  257. package/dist/src/registry/interfaces.js +0 -2
  258. package/dist/src/registry/interfaces.js.map +0 -1
  259. package/dist/src/shared/awaiter.js +0 -123
  260. package/dist/src/shared/awaiter.js.map +0 -1
  261. package/dist/src/shared/consistency-tracker.js +0 -123
  262. package/dist/src/shared/consistency-tracker.js.map +0 -1
  263. package/dist/src/shared/errors.js +0 -75
  264. package/dist/src/shared/errors.js.map +0 -1
  265. package/dist/src/shared/factories.js +0 -33
  266. package/dist/src/shared/factories.js.map +0 -1
  267. package/dist/src/shared/types.js +0 -38
  268. package/dist/src/shared/types.js.map +0 -1
  269. package/dist/src/shared/utils.js +0 -8
  270. package/dist/src/shared/utils.js.map +0 -1
  271. package/dist/src/signer/passthrough-signer.js +0 -19
  272. package/dist/src/signer/passthrough-signer.js.map +0 -1
  273. package/dist/src/signer/types.js +0 -2
  274. package/dist/src/signer/types.js.map +0 -1
  275. package/dist/src/storage/consistency-aware-legacy-storage.d.ts +0 -33
  276. package/dist/src/storage/consistency-aware-legacy-storage.d.ts.map +0 -1
  277. package/dist/src/storage/consistency-aware-legacy-storage.js +0 -65
  278. package/dist/src/storage/consistency-aware-legacy-storage.js.map +0 -1
  279. package/dist/src/storage/index.js +0 -3
  280. package/dist/src/storage/index.js.map +0 -1
  281. package/dist/src/storage/interfaces.js +0 -19
  282. package/dist/src/storage/interfaces.js.map +0 -1
  283. package/dist/src/storage/kysely/document-indexer.js +0 -350
  284. package/dist/src/storage/kysely/document-indexer.js.map +0 -1
  285. package/dist/src/storage/kysely/keyframe-store.js +0 -64
  286. package/dist/src/storage/kysely/keyframe-store.js.map +0 -1
  287. package/dist/src/storage/kysely/store.js +0 -233
  288. package/dist/src/storage/kysely/store.js.map +0 -1
  289. package/dist/src/storage/kysely/sync-cursor-storage.js +0 -93
  290. package/dist/src/storage/kysely/sync-cursor-storage.js.map +0 -1
  291. package/dist/src/storage/kysely/sync-remote-storage.js +0 -133
  292. package/dist/src/storage/kysely/sync-remote-storage.js.map +0 -1
  293. package/dist/src/storage/kysely/types.js +0 -2
  294. package/dist/src/storage/kysely/types.js.map +0 -1
  295. package/dist/src/storage/migrations/001_create_operation_table.js +0 -41
  296. package/dist/src/storage/migrations/001_create_operation_table.js.map +0 -1
  297. package/dist/src/storage/migrations/002_create_keyframe_table.js +0 -27
  298. package/dist/src/storage/migrations/002_create_keyframe_table.js.map +0 -1
  299. package/dist/src/storage/migrations/003_create_document_table.js +0 -10
  300. package/dist/src/storage/migrations/003_create_document_table.js.map +0 -1
  301. package/dist/src/storage/migrations/004_create_document_relationship_table.js +0 -35
  302. package/dist/src/storage/migrations/004_create_document_relationship_table.js.map +0 -1
  303. package/dist/src/storage/migrations/005_create_indexer_state_table.js +0 -10
  304. package/dist/src/storage/migrations/005_create_indexer_state_table.js.map +0 -1
  305. package/dist/src/storage/migrations/006_create_document_snapshot_table.js +0 -49
  306. package/dist/src/storage/migrations/006_create_document_snapshot_table.js.map +0 -1
  307. package/dist/src/storage/migrations/007_create_slug_mapping_table.js +0 -24
  308. package/dist/src/storage/migrations/007_create_slug_mapping_table.js.map +0 -1
  309. package/dist/src/storage/migrations/008_create_view_state_table.js +0 -10
  310. package/dist/src/storage/migrations/008_create_view_state_table.js.map +0 -1
  311. package/dist/src/storage/migrations/009_create_operation_index_tables.js +0 -50
  312. package/dist/src/storage/migrations/009_create_operation_index_tables.js.map +0 -1
  313. package/dist/src/storage/migrations/010_create_sync_tables.js +0 -43
  314. package/dist/src/storage/migrations/010_create_sync_tables.js.map +0 -1
  315. package/dist/src/storage/migrations/index.js +0 -3
  316. package/dist/src/storage/migrations/index.js.map +0 -1
  317. package/dist/src/storage/migrations/migrator.js +0 -78
  318. package/dist/src/storage/migrations/migrator.js.map +0 -1
  319. package/dist/src/storage/migrations/run-migrations.js +0 -58
  320. package/dist/src/storage/migrations/run-migrations.js.map +0 -1
  321. package/dist/src/storage/migrations/types.js +0 -2
  322. package/dist/src/storage/migrations/types.js.map +0 -1
  323. package/dist/src/storage/txn.js +0 -42
  324. package/dist/src/storage/txn.js.map +0 -1
  325. package/dist/src/subs/default-error-handler.js +0 -27
  326. package/dist/src/subs/default-error-handler.js.map +0 -1
  327. package/dist/src/subs/react-subscription-manager.js +0 -185
  328. package/dist/src/subs/react-subscription-manager.js.map +0 -1
  329. package/dist/src/subs/subscription-notification-read-model.js +0 -62
  330. package/dist/src/subs/subscription-notification-read-model.js.map +0 -1
  331. package/dist/src/subs/types.js +0 -2
  332. package/dist/src/subs/types.js.map +0 -1
  333. package/dist/src/sync/channels/composite-channel-factory.d.ts +0 -30
  334. package/dist/src/sync/channels/composite-channel-factory.d.ts.map +0 -1
  335. package/dist/src/sync/channels/composite-channel-factory.js +0 -87
  336. package/dist/src/sync/channels/composite-channel-factory.js.map +0 -1
  337. package/dist/src/sync/channels/gql-channel-factory.d.ts +0 -25
  338. package/dist/src/sync/channels/gql-channel-factory.d.ts.map +0 -1
  339. package/dist/src/sync/channels/gql-channel-factory.js +0 -76
  340. package/dist/src/sync/channels/gql-channel-factory.js.map +0 -1
  341. package/dist/src/sync/channels/gql-channel.d.ts.map +0 -1
  342. package/dist/src/sync/channels/gql-channel.js +0 -423
  343. package/dist/src/sync/channels/gql-channel.js.map +0 -1
  344. package/dist/src/sync/channels/index.js +0 -6
  345. package/dist/src/sync/channels/index.js.map +0 -1
  346. package/dist/src/sync/channels/polling-channel.d.ts +0 -39
  347. package/dist/src/sync/channels/polling-channel.d.ts.map +0 -1
  348. package/dist/src/sync/channels/polling-channel.js +0 -72
  349. package/dist/src/sync/channels/polling-channel.js.map +0 -1
  350. package/dist/src/sync/channels/utils.js +0 -96
  351. package/dist/src/sync/channels/utils.js.map +0 -1
  352. package/dist/src/sync/errors.js +0 -17
  353. package/dist/src/sync/errors.js.map +0 -1
  354. package/dist/src/sync/index.js +0 -9
  355. package/dist/src/sync/index.js.map +0 -1
  356. package/dist/src/sync/interfaces.js +0 -2
  357. package/dist/src/sync/interfaces.js.map +0 -1
  358. package/dist/src/sync/mailbox.js +0 -59
  359. package/dist/src/sync/mailbox.js.map +0 -1
  360. package/dist/src/sync/sync-builder.js +0 -39
  361. package/dist/src/sync/sync-builder.js.map +0 -1
  362. package/dist/src/sync/sync-manager.js +0 -266
  363. package/dist/src/sync/sync-manager.js.map +0 -1
  364. package/dist/src/sync/sync-operation.js +0 -63
  365. package/dist/src/sync/sync-operation.js.map +0 -1
  366. package/dist/src/sync/types.js +0 -16
  367. package/dist/src/sync/types.js.map +0 -1
  368. package/dist/src/sync/utils.js +0 -78
  369. package/dist/src/sync/utils.js.map +0 -1
  370. package/dist/src/utils/reshuffle.js +0 -47
  371. package/dist/src/utils/reshuffle.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/shared/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,KAAK;IAC7C,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;gBAEnC,UAAU,EAAE,MAAM,EAAE,eAAe,GAAE,MAAM,GAAG,IAAW;CAYtE;AAED;;GAEG;AACH,qBAAa,2BAA4B,SAAQ,KAAK;IACpD,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,KAAK,EAAE,MAAM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AM,EAAE,MAAM,CAAC;gBAEnB,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAQ/C;AAED;;GAEG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,WAAW,EAAE,MAAM,CAAC;IACpC,SAAgB,SAAS,EAAE,MAAM,CAAC;gBAEtB,YAAY,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;CAWzE;AAED;;GAEG;AACH,qBAAa,4BAA6B,SAAQ,KAAK;IACrD,SAAgB,YAAY,EAAE,MAAM,CAAC;gBAEzB,YAAY,EAAE,MAAM;CAOjC;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,SAAgB,UAAU,EAAE,MAAM,CAAC;gBAEvB,UAAU,EAAE,MAAM;IAQ9B,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,qBAAqB;CAG/D"}
@@ -10,7 +10,11 @@ export declare function createShutdownStatus(isShutdown: boolean): ShutdownStatu
10
10
  * Factory method to create a ShutdownStatus that can be updated
11
11
  *
12
12
  * @param initialState - Initial shutdown state (default: false)
13
- * @returns A tuple of [ShutdownStatus, setter function]
13
+ * @returns A tuple of [ShutdownStatus, setShutdown function, setCompleted function]
14
14
  */
15
- export declare function createMutableShutdownStatus(initialState?: boolean): [ShutdownStatus, (value: boolean) => void];
15
+ export declare function createMutableShutdownStatus(initialState?: boolean): [
16
+ ShutdownStatus,
17
+ (value: boolean) => void,
18
+ (completed: Promise<void>) => void
19
+ ];
16
20
  //# sourceMappingURL=factories.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../../../src/shared/factories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,OAAO,GAAG,cAAc,CAQxE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,UAAQ,GACnB,CAAC,cAAc,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC,CAc5C"}
1
+ {"version":3,"file":"factories.d.ts","sourceRoot":"","sources":["../../../src/shared/factories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,OAAO,GAAG,cAAc,CASxE;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,YAAY,UAAQ,GACnB;IACD,cAAc;IACd,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI;IACxB,CAAC,SAAS,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,IAAI;CACnC,CAsBA"}
@@ -24,6 +24,13 @@ export type ShutdownStatus = {
24
24
  * In the case of a server process, a graceful shutdown period should be allowed for the system to finish its work.
25
25
  */
26
26
  get isShutdown(): boolean;
27
+ /**
28
+ * A promise that resolves when the shutdown process is complete.
29
+ *
30
+ * For server environments, await this promise to ensure all active jobs finish
31
+ * before exiting the process.
32
+ */
33
+ completed: Promise<void>;
27
34
  };
28
35
  /**
29
36
  * Enum that determines deletion propagation.
@@ -39,6 +46,20 @@ export declare enum RelationshipChangeType {
39
46
  Added = "added",
40
47
  Removed = "removed"
41
48
  }
49
+ /**
50
+ * Batch-specific metadata always present on every job.
51
+ * Single jobs get a unique batchId and batchJobIds of [jobId].
52
+ */
53
+ export type BatchMeta = {
54
+ batchId: string;
55
+ batchJobIds: string[];
56
+ };
57
+ /**
58
+ * Metadata that flows through the job lifecycle.
59
+ * Always includes batch fields; callers may add additional properties.
60
+ */
61
+ export type JobMeta = BatchMeta & Record<string, unknown>;
62
+ import type { Job } from "../queue/types.js";
42
63
  /**
43
64
  * Describes the current state of a job.
44
65
  */
@@ -55,9 +76,13 @@ export type JobInfo = {
55
76
  */
56
77
  consistencyToken: ConsistencyToken;
57
78
  /**
58
- * Optional metadata that flows through the job lifecycle.
79
+ * Metadata that flows through the job lifecycle.
80
+ */
81
+ meta: JobMeta;
82
+ /**
83
+ * The full job object, populated on failure for debugging purposes.
59
84
  */
60
- meta?: Record<string, unknown>;
85
+ job?: Job;
61
86
  };
62
87
  /**
63
88
  * Job execution statuses
@@ -67,10 +92,10 @@ export declare enum JobStatus {
67
92
  PENDING = "PENDING",
68
93
  /** Job is currently being executed */
69
94
  RUNNING = "RUNNING",
70
- /** Operations have been written to the operation store (OPERATION_WRITTEN event) */
71
- WRITE_COMPLETED = "WRITE_COMPLETED",
72
- /** Read models have finished indexing operations (OPERATIONS_READY event) */
73
- READ_MODELS_READY = "READ_MODELS_READY",
95
+ /** Operations have been written to the operation store (JOB_WRITE_READY event) */
96
+ WRITE_READY = "WRITE_READY",
97
+ /** Read models have finished indexing operations (JOB_READ_READY event) */
98
+ READ_READY = "READ_READY",
74
99
  /** Job failed (may be retried) */
75
100
  FAILED = "FAILED"
76
101
  }
@@ -109,6 +134,7 @@ export type PagedResults<T> = {
109
134
  options: PagingOptions;
110
135
  next?: () => Promise<PagedResults<T>>;
111
136
  nextCursor?: string;
137
+ totalCount?: number;
112
138
  };
113
139
  /**
114
140
  * A string key in the format `documentId:scope:branch` used to identify a consistency checkpoint.
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/shared/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,kBAAkB,yCAAyC,CAAC;AAEzE;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B;;;;;;;;OAQG;IACH,IAAI,UAAU,IAAI,OAAO,CAAC;CAC3B,CAAC;AAEF;;GAE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C;IAClB,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,IAAI;IAC5B,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,OAAO,EAAE,aAAa,CAAC;IAEvB,IAAI,CAAC,EAAE,MAAM,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,GAAG,MAAM,IAAI,MAAM,IAAI,MAAM,EAAE,CAAC;AAE7D;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,OAAO,EAAE,CAAC,CAAC;IACX,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,qBAAqB,EAAE,CAAC;CACtC,CAAC"}
@@ -4,7 +4,7 @@ import type { ISigner, Signature } from "document-model";
4
4
  * Used when signing is not required.
5
5
  */
6
6
  export declare class PassthroughSigner implements ISigner {
7
- publicKey(): Promise<JsonWebKey>;
7
+ publicKey: CryptoKey;
8
8
  sign(): Promise<Uint8Array>;
9
9
  verify(): Promise<void>;
10
10
  signAction(): Promise<Signature>;
@@ -1 +1 @@
1
- {"version":3,"file":"passthrough-signer.d.ts","sourceRoot":"","sources":["../../../src/signer/passthrough-signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEzD;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,OAAO;IAC/C,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC;IAIhC,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IAI3B,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC;CAGjC"}
1
+ {"version":3,"file":"passthrough-signer.d.ts","sourceRoot":"","sources":["../../../src/signer/passthrough-signer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEzD;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,OAAO;IAC/C,SAAS,EAAoB,SAAS,CAAC;IAEvC,IAAI,IAAI,OAAO,CAAC,UAAU,CAAC;IAI3B,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAIvB,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC;CAGjC"}
@@ -1,39 +1,86 @@
1
- import type { Operation, PHDocument } from "document-model";
2
- import type { ConsistencyToken } from "../shared/types.js";
1
+ import type { Operation, OperationWithContext, PHDocument } from "document-model";
2
+ import type { ConsistencyToken, PagedResults, PagingOptions } from "../shared/types.js";
3
+ import type { ChannelErrorSource } from "../sync/types.js";
3
4
  import type { RemoteCursor, RemoteRecord } from "../sync/types.js";
4
- export type OperationContext = {
5
- documentId: string;
6
- documentType: string;
7
- scope: string;
8
- branch: string;
9
- resultingState?: string;
10
- ordinal: number;
11
- };
12
- export type OperationWithContext = {
13
- operation: Operation;
14
- context: OperationContext;
15
- };
5
+ export type { PagedResults, PagingOptions } from "../shared/types.js";
6
+ /**
7
+ * Thrown when an operation with the same identity already exists in the store.
8
+ */
16
9
  export declare class DuplicateOperationError extends Error {
17
10
  constructor(description: string);
18
11
  }
12
+ /**
13
+ * Thrown when a concurrent write conflict is detected during an atomic apply.
14
+ */
19
15
  export declare class OptimisticLockError extends Error {
20
16
  constructor(message: string);
21
17
  }
18
+ /**
19
+ * Thrown when the caller-provided revision does not match the current
20
+ * stored revision, indicating a stale read.
21
+ */
22
22
  export declare class RevisionMismatchError extends Error {
23
23
  constructor(expected: number, actual: number);
24
24
  }
25
+ /**
26
+ * A write transaction passed to {@link IOperationStore.apply}. Accumulates
27
+ * operations that are committed atomically when the callback returns.
28
+ */
25
29
  export interface AtomicTxn {
30
+ /** Stages one or more operations to be written as part of this transaction. */
26
31
  addOperations(...operations: Operation[]): void;
27
32
  }
33
+ /**
34
+ * Per-scope revision map for a document, used to reconstruct the header
35
+ * revision field and lastModified timestamp.
36
+ */
28
37
  export type DocumentRevisions = {
29
38
  /** Map of scope to operation index for that scope */
30
39
  revision: Record<string, number>;
31
40
  /** Latest timestamp across revisions */
32
41
  latestTimestamp: string;
33
42
  };
43
+ /**
44
+ * Append-only store for document operations. Operations are partitioned by
45
+ * (documentId, scope, branch) and ordered by a monotonic revision index.
46
+ */
34
47
  export interface IOperationStore {
48
+ /**
49
+ * Atomically appends operations for a single document/scope/branch.
50
+ * The provided revision must match the current head; otherwise a
51
+ * {@link RevisionMismatchError} is thrown.
52
+ *
53
+ * @param documentId - The document id
54
+ * @param documentType - The document type identifier
55
+ * @param scope - The operation scope (e.g. "global", "local")
56
+ * @param branch - The branch name
57
+ * @param revision - Expected current revision (optimistic lock)
58
+ * @param fn - Callback that stages operations via {@link AtomicTxn}
59
+ * @param signal - Optional abort signal to cancel the request
60
+ */
35
61
  apply(documentId: string, documentType: string, scope: string, branch: string, revision: number, fn: (txn: AtomicTxn) => void | Promise<void>, signal?: AbortSignal): Promise<void>;
36
- getSince(documentId: string, scope: string, branch: string, revision: number, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Operation>>;
62
+ /**
63
+ * Returns operations for a document/scope/branch whose index is greater
64
+ * than the given revision.
65
+ *
66
+ * @param documentId - The document id
67
+ * @param scope - The operation scope
68
+ * @param branch - The branch name
69
+ * @param revision - Return operations after this revision index
70
+ * @param filter - Optional filters (action types, timestamp range)
71
+ * @param paging - Optional paging options for cursor-based pagination
72
+ * @param signal - Optional abort signal to cancel the request
73
+ */
74
+ getSince(documentId: string, scope: string, branch: string, revision: number, filter?: OperationFilter, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<Operation>>;
75
+ /**
76
+ * Returns operations across all documents whose auto-increment store id
77
+ * is greater than the given id. Used by read models and sync to catch up
78
+ * on operations they may have missed.
79
+ *
80
+ * @param id - Return operations with store id greater than this value
81
+ * @param paging - Optional paging options for cursor-based pagination
82
+ * @param signal - Optional abort signal to cancel the request
83
+ */
37
84
  getSinceId(id: number, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<OperationWithContext>>;
38
85
  /**
39
86
  * Gets operations that may conflict with incoming operations during a load.
@@ -59,51 +106,92 @@ export interface IOperationStore {
59
106
  */
60
107
  getRevisions(documentId: string, branch: string, signal?: AbortSignal): Promise<DocumentRevisions>;
61
108
  }
109
+ /**
110
+ * Stores periodic document snapshots (keyframes) so that document state
111
+ * can be reconstructed without replaying the full operation history.
112
+ */
62
113
  export interface IKeyframeStore {
114
+ /**
115
+ * Stores a document snapshot at a specific revision.
116
+ *
117
+ * @param documentId - The document id
118
+ * @param scope - The operation scope
119
+ * @param branch - The branch name
120
+ * @param revision - The operation index this snapshot corresponds to
121
+ * @param document - The full document state to persist
122
+ * @param signal - Optional abort signal to cancel the request
123
+ */
63
124
  putKeyframe(documentId: string, scope: string, branch: string, revision: number, document: PHDocument, signal?: AbortSignal): Promise<void>;
125
+ /**
126
+ * Finds the keyframe closest to (but not exceeding) the target revision.
127
+ * Returns undefined if no keyframe exists for this document/scope/branch.
128
+ *
129
+ * @param documentId - The document id
130
+ * @param scope - The operation scope
131
+ * @param branch - The branch name
132
+ * @param targetRevision - The desired revision upper bound
133
+ * @param signal - Optional abort signal to cancel the request
134
+ */
64
135
  findNearestKeyframe(documentId: string, scope: string, branch: string, targetRevision: number, signal?: AbortSignal): Promise<{
65
136
  revision: number;
66
137
  document: PHDocument;
67
138
  } | undefined>;
139
+ /**
140
+ * Deletes keyframes for a document. Optionally scoped to a specific
141
+ * scope and/or branch.
142
+ *
143
+ * @param documentId - The document id
144
+ * @param scope - Optional scope filter; omit to delete across all scopes
145
+ * @param branch - Optional branch filter; omit to delete across all branches
146
+ * @param signal - Optional abort signal to cancel the request
147
+ * @returns The number of keyframes deleted
148
+ */
68
149
  deleteKeyframes(documentId: string, scope?: string, branch?: string, signal?: AbortSignal): Promise<number>;
69
150
  }
151
+ /**
152
+ * Filters applied when reading document state from {@link IDocumentView}.
153
+ */
70
154
  export interface ViewFilter {
155
+ /** Branch to read from. Defaults to the main branch when omitted. */
71
156
  branch?: string;
157
+ /** Scopes to include. When omitted, all scopes are included. */
72
158
  scopes?: string[];
159
+ /** Exclude operations originating from this remote name. */
160
+ excludeSourceRemote?: string;
73
161
  }
162
+ /**
163
+ * Criteria for searching documents in storage-backed read models.
164
+ * All provided fields are combined with AND logic.
165
+ */
74
166
  export interface SearchFilter {
167
+ /** Filter by document type identifier. */
75
168
  documentType?: string;
169
+ /** Filter by parent document id. */
76
170
  parentId?: string;
171
+ /** Filter by arbitrary key-value identifiers stored on the document. */
77
172
  identifiers?: Record<string, any>;
173
+ /** When true, include soft-deleted documents in results. */
78
174
  includeDeleted?: boolean;
79
175
  }
80
- export interface PagingOptions {
81
- cursor?: string;
82
- limit?: number;
83
- }
84
- export interface PagedResults<T> {
85
- items: T[];
86
- nextCursor?: string;
87
- hasMore: boolean;
88
- }
89
- export interface DocumentSnapshot {
90
- id: string;
91
- documentId: string;
92
- slug: string | null;
93
- name: string | null;
94
- scope: string;
95
- branch: string;
96
- content: string;
97
- documentType: string;
98
- lastOperationIndex: number;
99
- lastOperationHash: string;
100
- lastUpdatedAt: Date;
101
- snapshotVersion: number;
102
- identifiers: string | null;
103
- metadata: string | null;
104
- isDeleted: boolean;
105
- deletedAt: Date | null;
176
+ /**
177
+ * Filter options for querying operations. When multiple filters are provided,
178
+ * they are combined with AND logic.
179
+ */
180
+ export interface OperationFilter {
181
+ /** Filter by action types (OR logic within array) */
182
+ actionTypes?: string[];
183
+ /** Filter operations with timestamp >= this value (ISO string) */
184
+ timestampFrom?: string;
185
+ /** Filter operations with timestamp <= this value (ISO string) */
186
+ timestampTo?: string;
187
+ /** Filter operations with index >= this value */
188
+ sinceRevision?: number;
106
189
  }
190
+ /**
191
+ * Materialised read model that maintains document snapshots. Snapshots are
192
+ * updated by indexing operations (which must include `resultingState`) and
193
+ * queried with optional consistency tokens for read-after-write guarantees.
194
+ */
107
195
  export interface IDocumentView {
108
196
  /**
109
197
  * Initializes the view.
@@ -143,6 +231,15 @@ export interface IDocumentView {
143
231
  * @param signal - Optional abort signal to cancel the request
144
232
  */
145
233
  get<TDocument extends PHDocument>(documentId: string, view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<TDocument>;
234
+ /**
235
+ * Returns the documents with the given ids.
236
+ *
237
+ * @param documentIds - The list of document ids to get.
238
+ * @param view - Optional filter containing branch and scopes information
239
+ * @param consistencyToken - Optional token for read-after-write consistency
240
+ * @param signal - Optional abort signal to cancel the request
241
+ */
242
+ getMany<TDocument extends PHDocument>(documentIds: string[], view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<TDocument[]>;
146
243
  /**
147
244
  * Returns the document with the given identifier (either id or slug).
148
245
  * Throws an error if the identifier matches both an id and a slug that refer to different documents.
@@ -174,7 +271,33 @@ export interface IDocumentView {
174
271
  * @returns The document ID or undefined if the slug doesn't exist
175
272
  */
176
273
  resolveSlug(slug: string, view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string | undefined>;
274
+ /**
275
+ * Resolves a list of slugs to document IDs.
276
+ *
277
+ * @param slugs - The list of slugs to resolve.
278
+ * @param view - Optional filter containing branch and scopes information
279
+ * @param consistencyToken - Optional token for read-after-write consistency
280
+ * @param signal - Optional abort signal to cancel the request
281
+ * @returns The list of document IDs
282
+ */
283
+ resolveSlugs(slugs: string[], view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[]>;
284
+ /**
285
+ * Resolves an identifier (either id or slug) to a document ID.
286
+ * This is a lightweight alternative to getByIdOrSlug that returns just the ID
287
+ * without fetching the full document.
288
+ *
289
+ * @param identifier - The id or slug to resolve
290
+ * @param view - Optional filter containing branch and scopes information
291
+ * @param consistencyToken - Optional token for read-after-write consistency
292
+ * @param signal - Optional abort signal to cancel the request
293
+ * @returns The document ID
294
+ * @throws {Error} If document not found or identifier matches both an ID and slug referring to different documents
295
+ */
296
+ resolveIdOrSlug(identifier: string, view?: ViewFilter, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string>;
177
297
  }
298
+ /**
299
+ * A directed relationship between two documents in the document graph.
300
+ */
178
301
  export type DocumentRelationship = {
179
302
  sourceId: string;
180
303
  targetId: string;
@@ -183,15 +306,27 @@ export type DocumentRelationship = {
183
306
  createdAt: Date;
184
307
  updatedAt: Date;
185
308
  };
309
+ /**
310
+ * A lightweight directed edge in a {@link IDocumentGraph}.
311
+ */
186
312
  export type DocumentGraphEdge = {
187
313
  from: string;
188
314
  to: string;
189
315
  type: string;
190
316
  };
317
+ /**
318
+ * A subgraph of the document relationship graph, returned by traversal
319
+ * queries such as {@link IDocumentIndexer.findAncestors}.
320
+ */
191
321
  export interface IDocumentGraph {
192
322
  nodes: string[];
193
323
  edges: DocumentGraphEdge[];
194
324
  }
325
+ /**
326
+ * Read model that maintains a directed graph of document relationships.
327
+ * Relationships are created and removed by indexing operations containing
328
+ * ADD_RELATIONSHIP and REMOVE_RELATIONSHIP actions.
329
+ */
195
330
  export interface IDocumentIndexer {
196
331
  /**
197
332
  * Initializes the indexer and catches up on any missed operations.
@@ -221,7 +356,7 @@ export interface IDocumentIndexer {
221
356
  * @param consistencyToken - Optional token for read-after-write consistency
222
357
  * @param signal - Optional abort signal to cancel the request
223
358
  */
224
- getOutgoing(documentId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<DocumentRelationship[]>;
359
+ getOutgoing(documentId: string, types?: string[], paging?: PagingOptions, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<PagedResults<DocumentRelationship>>;
225
360
  /**
226
361
  * Returns incoming relationships to a document.
227
362
  *
@@ -230,7 +365,7 @@ export interface IDocumentIndexer {
230
365
  * @param consistencyToken - Optional token for read-after-write consistency
231
366
  * @param signal - Optional abort signal to cancel the request
232
367
  */
233
- getIncoming(documentId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<DocumentRelationship[]>;
368
+ getIncoming(documentId: string, types?: string[], paging?: PagingOptions, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<PagedResults<DocumentRelationship>>;
234
369
  /**
235
370
  * Checks if a relationship exists between two documents.
236
371
  *
@@ -250,7 +385,7 @@ export interface IDocumentIndexer {
250
385
  * @param consistencyToken - Optional token for read-after-write consistency
251
386
  * @param signal - Optional abort signal to cancel the request
252
387
  */
253
- getUndirectedRelationships(a: string, b: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<DocumentRelationship[]>;
388
+ getUndirectedRelationships(a: string, b: string, types?: string[], paging?: PagingOptions, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<PagedResults<DocumentRelationship>>;
254
389
  /**
255
390
  * Returns all directed relationships between two documents.
256
391
  *
@@ -260,7 +395,7 @@ export interface IDocumentIndexer {
260
395
  * @param consistencyToken - Optional token for read-after-write consistency
261
396
  * @param signal - Optional abort signal to cancel the request
262
397
  */
263
- getDirectedRelationships(sourceId: string, targetId: string, types?: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<DocumentRelationship[]>;
398
+ getDirectedRelationships(sourceId: string, targetId: string, types?: string[], paging?: PagingOptions, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<PagedResults<DocumentRelationship>>;
264
399
  /**
265
400
  * Finds a path from source to target following directed edges.
266
401
  *
@@ -290,85 +425,9 @@ export interface IDocumentIndexer {
290
425
  getRelationshipTypes(consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[]>;
291
426
  }
292
427
  /**
293
- * A consistency-aware storage interface used by the Reactor when legacy storage
294
- * mode is enabled. This interface provides read-after-write consistency by
295
- * accepting an optional consistency token on read operations.
296
- *
297
- * This is a standalone interface (not extending IDocumentStorage) because the
298
- * method signatures differ - consistency token is added as an optional parameter
299
- * to read operations.
428
+ * Persistent storage for sync remote configurations. Each remote represents
429
+ * a connection to an external system that operations can be synced with.
300
430
  */
301
- export interface IConsistencyAwareStorage {
302
- /**
303
- * Returns the document with the given id.
304
- *
305
- * @param id - The id of the document to get
306
- * @param consistencyToken - Optional token for read-after-write consistency
307
- * @param signal - Optional abort signal to cancel the request
308
- */
309
- get<TDocument extends PHDocument>(id: string, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<TDocument>;
310
- /**
311
- * Returns the document with the given slug.
312
- *
313
- * @param slug - The slug of the document to get
314
- * @param consistencyToken - Optional token for read-after-write consistency
315
- * @param signal - Optional abort signal to cancel the request
316
- */
317
- getBySlug<TDocument extends PHDocument>(slug: string, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<TDocument>;
318
- /**
319
- * Returns true if the document exists.
320
- *
321
- * @param id - The id of the document to check
322
- * @param consistencyToken - Optional token for read-after-write consistency
323
- * @param signal - Optional abort signal to cancel the request
324
- */
325
- exists(id: string, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<boolean>;
326
- /**
327
- * Finds documents by their document type.
328
- *
329
- * @param type - The document type to search for
330
- * @param limit - Optional limit on the number of results
331
- * @param cursor - Optional cursor for pagination
332
- * @param consistencyToken - Optional token for read-after-write consistency
333
- * @param signal - Optional abort signal to cancel the request
334
- */
335
- findByType(type: string, limit?: number, cursor?: string, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<{
336
- documents: string[];
337
- nextCursor: string | undefined;
338
- }>;
339
- /**
340
- * Returns the children of a document.
341
- *
342
- * @param id - The id of the parent document
343
- * @param consistencyToken - Optional token for read-after-write consistency
344
- * @param signal - Optional abort signal to cancel the request
345
- */
346
- getChildren(id: string, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[]>;
347
- /**
348
- * Resolves slugs to document IDs.
349
- *
350
- * @param slugs - The slugs to resolve
351
- * @param consistencyToken - Optional token for read-after-write consistency
352
- * @param signal - Optional abort signal to cancel the request
353
- */
354
- resolveIds(slugs: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[]>;
355
- /**
356
- * Resolves document IDs to slugs.
357
- *
358
- * @param ids - The document IDs to resolve
359
- * @param consistencyToken - Optional token for read-after-write consistency
360
- * @param signal - Optional abort signal to cancel the request
361
- */
362
- resolveSlugs(ids: string[], consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[]>;
363
- /**
364
- * Returns all parent documents of the child document with the given id.
365
- *
366
- * @param childId - The id of the child document
367
- * @param consistencyToken - Optional token for read-after-write consistency
368
- * @param signal - Optional abort signal to cancel the request
369
- */
370
- getParents(childId: string, consistencyToken?: ConsistencyToken, signal?: AbortSignal): Promise<string[]>;
371
- }
372
431
  export interface ISyncRemoteStorage {
373
432
  /**
374
433
  * Lists all remotes.
@@ -402,6 +461,10 @@ export interface ISyncRemoteStorage {
402
461
  */
403
462
  remove(name: string, signal?: AbortSignal): Promise<void>;
404
463
  }
464
+ /**
465
+ * Persistent storage for sync cursors that track inbox/outbox progress
466
+ * per remote. Cursors allow sync to resume from where it left off.
467
+ */
405
468
  export interface ISyncCursorStorage {
406
469
  /**
407
470
  * Lists all cursors for a remote.
@@ -415,10 +478,11 @@ export interface ISyncCursorStorage {
415
478
  * Gets a cursor for a remote.
416
479
  *
417
480
  * @param remoteName - The name of the remote
481
+ * @param cursorType - The type of cursor ("inbox" or "outbox")
418
482
  * @param signal - Optional abort signal to cancel the request
419
483
  * @returns The cursor
420
484
  */
421
- get(remoteName: string, signal?: AbortSignal): Promise<RemoteCursor>;
485
+ get(remoteName: string, cursorType: "inbox" | "outbox", signal?: AbortSignal): Promise<RemoteCursor>;
422
486
  /**
423
487
  * Upserts a cursor.
424
488
  *
@@ -436,4 +500,54 @@ export interface ISyncCursorStorage {
436
500
  */
437
501
  remove(remoteName: string, signal?: AbortSignal): Promise<void>;
438
502
  }
503
+ /**
504
+ * Serializable snapshot of a permanently failed SyncOperation.
505
+ */
506
+ export type DeadLetterRecord = {
507
+ id: string;
508
+ jobId: string;
509
+ jobDependencies: string[];
510
+ remoteName: string;
511
+ documentId: string;
512
+ scopes: string[];
513
+ branch: string;
514
+ operations: OperationWithContext[];
515
+ errorSource: ChannelErrorSource;
516
+ errorMessage: string;
517
+ };
518
+ /**
519
+ * Persists dead-lettered sync operations so they survive reactor restarts.
520
+ */
521
+ export interface ISyncDeadLetterStorage {
522
+ /**
523
+ * Lists dead letters for a remote, ordered by ordinal DESC (newest first).
524
+ *
525
+ * @param remoteName - The name of the remote
526
+ * @param paging - Optional paging options (cursor + limit)
527
+ * @param signal - Optional abort signal to cancel the request
528
+ * @returns Paged dead letter records
529
+ */
530
+ list(remoteName: string, paging?: PagingOptions, signal?: AbortSignal): Promise<PagedResults<DeadLetterRecord>>;
531
+ /**
532
+ * Adds a dead letter. Duplicate ids are silently ignored.
533
+ *
534
+ * @param deadLetter - The dead letter record to persist
535
+ * @param signal - Optional abort signal to cancel the request
536
+ */
537
+ add(deadLetter: DeadLetterRecord, signal?: AbortSignal): Promise<void>;
538
+ /**
539
+ * Removes a single dead letter by id.
540
+ *
541
+ * @param id - The dead letter id
542
+ * @param signal - Optional abort signal to cancel the request
543
+ */
544
+ remove(id: string, signal?: AbortSignal): Promise<void>;
545
+ /**
546
+ * Removes all dead letters for a remote.
547
+ *
548
+ * @param remoteName - The name of the remote
549
+ * @param signal - Optional abort signal to cancel the request
550
+ */
551
+ removeByRemote(remoteName: string, signal?: AbortSignal): Promise<void>;
552
+ }
439
553
  //# sourceMappingURL=interfaces.d.ts.map