@agentshouse/mdruntime 0.1.0-cfcbb238a5fa0 → 0.1.0-cfcfcecad6596

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 (427) hide show
  1. package/README.md +24 -19
  2. package/dist/acceptance.d.ts +3 -0
  3. package/dist/acceptance.d.ts.map +1 -0
  4. package/dist/acceptance.js +328 -0
  5. package/dist/act-lanes.d.ts +30 -0
  6. package/dist/act-lanes.d.ts.map +1 -0
  7. package/dist/act-lanes.js +225 -0
  8. package/dist/actions.d.ts +26 -0
  9. package/dist/actions.d.ts.map +1 -0
  10. package/dist/actions.js +341 -0
  11. package/dist/adapter.d.ts +287 -127
  12. package/dist/adapter.d.ts.map +1 -1
  13. package/dist/attached-model.d.ts +6 -10
  14. package/dist/attached-model.d.ts.map +1 -1
  15. package/dist/attached-model.js +35 -41
  16. package/dist/{binary.d.ts → attachment.d.ts} +8 -9
  17. package/dist/attachment.d.ts.map +1 -0
  18. package/dist/attachment.js +15 -0
  19. package/dist/authored.d.ts +88 -0
  20. package/dist/authored.d.ts.map +1 -0
  21. package/dist/authored.js +347 -0
  22. package/dist/bootstrap.d.ts +30 -11
  23. package/dist/bootstrap.d.ts.map +1 -1
  24. package/dist/bootstrap.js +309 -113
  25. package/dist/cell.d.ts +6 -0
  26. package/dist/cell.d.ts.map +1 -0
  27. package/dist/cell.js +9 -0
  28. package/dist/chain.d.ts +12 -0
  29. package/dist/chain.d.ts.map +1 -0
  30. package/dist/chain.js +67 -0
  31. package/dist/change-set.d.ts +13 -16
  32. package/dist/change-set.d.ts.map +1 -1
  33. package/dist/change-set.js +17 -89
  34. package/dist/change.d.ts +36 -1
  35. package/dist/change.d.ts.map +1 -1
  36. package/dist/change.js +17 -3
  37. package/dist/chat-types.d.ts +3 -0
  38. package/dist/chat-types.d.ts.map +1 -0
  39. package/dist/chat-types.js +11 -0
  40. package/dist/client.d.ts +51 -27
  41. package/dist/client.d.ts.map +1 -1
  42. package/dist/client.js +95 -28
  43. package/dist/collection.d.ts +34 -21
  44. package/dist/collection.d.ts.map +1 -1
  45. package/dist/collection.js +58 -286
  46. package/dist/column.d.ts +5 -0
  47. package/dist/column.d.ts.map +1 -0
  48. package/dist/column.js +9 -0
  49. package/dist/compile.d.ts +19 -0
  50. package/dist/compile.d.ts.map +1 -0
  51. package/dist/compile.js +755 -0
  52. package/dist/connection.d.ts +7 -132
  53. package/dist/connection.d.ts.map +1 -1
  54. package/dist/connection.js +113 -3468
  55. package/dist/context.d.ts +2 -0
  56. package/dist/context.d.ts.map +1 -0
  57. package/dist/{chat/context.js → context.js} +2 -5
  58. package/dist/conversation-live.d.ts +149 -0
  59. package/dist/conversation-live.d.ts.map +1 -0
  60. package/dist/conversation-live.js +259 -0
  61. package/dist/conversation-row.d.ts +40 -0
  62. package/dist/conversation-row.d.ts.map +1 -0
  63. package/dist/conversation-row.js +66 -0
  64. package/dist/conversation.d.ts +90 -51
  65. package/dist/conversation.d.ts.map +1 -1
  66. package/dist/conversation.js +1082 -759
  67. package/dist/declaration.d.ts +10 -0
  68. package/dist/declaration.d.ts.map +1 -0
  69. package/dist/declaration.js +24 -0
  70. package/dist/digest.d.ts +7 -0
  71. package/dist/digest.d.ts.map +1 -0
  72. package/dist/digest.js +113 -0
  73. package/dist/discovery.d.ts +12 -0
  74. package/dist/discovery.d.ts.map +1 -0
  75. package/dist/discovery.js +175 -0
  76. package/dist/download.d.ts +6 -0
  77. package/dist/download.d.ts.map +1 -0
  78. package/dist/download.js +42 -0
  79. package/dist/durability.d.ts +21 -4
  80. package/dist/durability.d.ts.map +1 -1
  81. package/dist/durability.js +12 -0
  82. package/dist/entry.d.ts +29 -2
  83. package/dist/entry.d.ts.map +1 -1
  84. package/dist/entry.js +121 -39
  85. package/dist/expectation.d.ts +26 -13
  86. package/dist/expectation.d.ts.map +1 -1
  87. package/dist/expectation.js +72 -19
  88. package/dist/failure.d.ts +3 -0
  89. package/dist/failure.d.ts.map +1 -1
  90. package/dist/failure.js +8 -0
  91. package/dist/figures.d.ts +49 -0
  92. package/dist/figures.d.ts.map +1 -0
  93. package/dist/figures.js +199 -0
  94. package/dist/file.d.ts +2 -19
  95. package/dist/file.d.ts.map +1 -1
  96. package/dist/file.js +8 -122
  97. package/dist/holdings.d.ts +29 -0
  98. package/dist/holdings.d.ts.map +1 -0
  99. package/dist/holdings.js +95 -0
  100. package/dist/host.d.ts +25 -11
  101. package/dist/host.d.ts.map +1 -1
  102. package/dist/host.js +165 -56
  103. package/dist/house-query.d.ts +24 -0
  104. package/dist/house-query.d.ts.map +1 -0
  105. package/dist/house-query.js +102 -0
  106. package/dist/identity.d.ts +1 -3
  107. package/dist/identity.d.ts.map +1 -1
  108. package/dist/identity.js +1 -7
  109. package/dist/index.d.ts +49 -17
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +25 -5
  112. package/dist/install.d.ts +60 -0
  113. package/dist/install.d.ts.map +1 -0
  114. package/dist/install.js +537 -0
  115. package/dist/lifecycle.d.ts +7 -0
  116. package/dist/lifecycle.d.ts.map +1 -0
  117. package/dist/lifecycle.js +290 -0
  118. package/dist/listing.d.ts +60 -0
  119. package/dist/listing.d.ts.map +1 -0
  120. package/dist/listing.js +168 -0
  121. package/dist/live.d.ts +39 -0
  122. package/dist/live.d.ts.map +1 -0
  123. package/dist/live.js +223 -0
  124. package/dist/loaded.d.ts +7 -0
  125. package/dist/loaded.d.ts.map +1 -0
  126. package/dist/loaded.js +46 -0
  127. package/dist/locks.d.ts +7 -0
  128. package/dist/locks.d.ts.map +1 -0
  129. package/dist/locks.js +34 -0
  130. package/dist/lost.d.ts +5 -0
  131. package/dist/lost.d.ts.map +1 -0
  132. package/dist/lost.js +49 -0
  133. package/dist/media.d.ts +24 -0
  134. package/dist/media.d.ts.map +1 -0
  135. package/dist/media.js +365 -0
  136. package/dist/memory.d.ts +22 -8
  137. package/dist/memory.d.ts.map +1 -1
  138. package/dist/memory.js +321 -122
  139. package/dist/messages.d.ts +63 -0
  140. package/dist/messages.d.ts.map +1 -0
  141. package/dist/messages.js +169 -0
  142. package/dist/modal.d.ts +2 -0
  143. package/dist/modal.d.ts.map +1 -0
  144. package/dist/modal.js +11 -0
  145. package/dist/model.d.ts +15 -15
  146. package/dist/model.d.ts.map +1 -1
  147. package/dist/model.js +11 -22
  148. package/dist/models.d.ts +10 -0
  149. package/dist/models.d.ts.map +1 -0
  150. package/dist/models.js +153 -0
  151. package/dist/name.d.ts +3 -0
  152. package/dist/name.d.ts.map +1 -0
  153. package/dist/name.js +118 -0
  154. package/dist/observation.d.ts +42 -10
  155. package/dist/observation.d.ts.map +1 -1
  156. package/dist/observation.js +266 -39
  157. package/dist/online.d.ts +7 -0
  158. package/dist/online.d.ts.map +1 -0
  159. package/dist/online.js +29 -0
  160. package/dist/opened.d.ts +22 -0
  161. package/dist/opened.d.ts.map +1 -0
  162. package/dist/opened.js +107 -0
  163. package/dist/opening.d.ts +4 -0
  164. package/dist/opening.d.ts.map +1 -0
  165. package/dist/opening.js +69 -0
  166. package/dist/outcome.d.ts +71 -10
  167. package/dist/outcome.d.ts.map +1 -1
  168. package/dist/outcome.js +75 -3
  169. package/dist/overlay.d.ts +24 -11
  170. package/dist/overlay.d.ts.map +1 -1
  171. package/dist/overlay.js +190 -180
  172. package/dist/page-metadata.d.ts +8 -0
  173. package/dist/page-metadata.d.ts.map +1 -0
  174. package/dist/page-metadata.js +19 -0
  175. package/dist/parts.d.ts +6 -0
  176. package/dist/parts.d.ts.map +1 -0
  177. package/dist/parts.js +36 -0
  178. package/dist/paths.d.ts +2 -0
  179. package/dist/paths.d.ts.map +1 -1
  180. package/dist/paths.js +26 -0
  181. package/dist/preparation.d.ts +46 -0
  182. package/dist/preparation.d.ts.map +1 -0
  183. package/dist/preparation.js +344 -0
  184. package/dist/presence.d.ts +58 -0
  185. package/dist/presence.d.ts.map +1 -0
  186. package/dist/presence.js +231 -0
  187. package/dist/queries.d.ts +16 -0
  188. package/dist/queries.d.ts.map +1 -0
  189. package/dist/queries.js +330 -0
  190. package/dist/query.d.ts +27 -193
  191. package/dist/query.d.ts.map +1 -1
  192. package/dist/query.js +3 -470
  193. package/dist/{chat/questions.d.ts → questions.d.ts} +6 -7
  194. package/dist/questions.d.ts.map +1 -0
  195. package/dist/{chat/questions.js → questions.js} +14 -8
  196. package/dist/queue.d.ts +40 -0
  197. package/dist/queue.d.ts.map +1 -0
  198. package/dist/queue.js +480 -0
  199. package/dist/reach.d.ts +31 -11
  200. package/dist/reach.d.ts.map +1 -1
  201. package/dist/reach.js +444 -112
  202. package/dist/react.d.ts +22 -5
  203. package/dist/react.d.ts.map +1 -1
  204. package/dist/react.js +35 -15
  205. package/dist/{chat/read.d.ts → read.d.ts} +2 -0
  206. package/dist/read.d.ts.map +1 -0
  207. package/dist/{chat/read.js → read.js} +4 -0
  208. package/dist/readiness.d.ts +36 -21
  209. package/dist/readiness.d.ts.map +1 -1
  210. package/dist/readiness.js +20 -18
  211. package/dist/reads.d.ts +38 -10
  212. package/dist/reads.d.ts.map +1 -1
  213. package/dist/reads.js +174 -83
  214. package/dist/recovery.d.ts +6 -2
  215. package/dist/recovery.d.ts.map +1 -1
  216. package/dist/recovery.js +67 -9
  217. package/dist/reference-forms.d.ts +4 -0
  218. package/dist/reference-forms.d.ts.map +1 -0
  219. package/dist/reference-forms.js +74 -0
  220. package/dist/refresh.d.ts +18 -15
  221. package/dist/refresh.d.ts.map +1 -1
  222. package/dist/refresh.js +145 -60
  223. package/dist/refusal.d.ts +5 -0
  224. package/dist/refusal.d.ts.map +1 -0
  225. package/dist/refusal.js +55 -0
  226. package/dist/replica.d.ts +45 -33
  227. package/dist/replica.d.ts.map +1 -1
  228. package/dist/replica.js +340 -200
  229. package/dist/retried.d.ts +30 -0
  230. package/dist/retried.d.ts.map +1 -0
  231. package/dist/retried.js +72 -0
  232. package/dist/room-draft.d.ts +56 -14
  233. package/dist/room-draft.d.ts.map +1 -1
  234. package/dist/room-draft.js +424 -127
  235. package/dist/room-drafts.d.ts +24 -0
  236. package/dist/room-drafts.d.ts.map +1 -0
  237. package/dist/room-drafts.js +222 -0
  238. package/dist/room-list.d.ts +10 -0
  239. package/dist/room-list.d.ts.map +1 -0
  240. package/dist/room-list.js +45 -0
  241. package/dist/rows.d.ts +40 -30
  242. package/dist/rows.d.ts.map +1 -1
  243. package/dist/rows.js +73 -119
  244. package/dist/running.d.ts +5 -0
  245. package/dist/running.d.ts.map +1 -0
  246. package/dist/running.js +10 -0
  247. package/dist/runtime.d.ts +37 -0
  248. package/dist/runtime.d.ts.map +1 -0
  249. package/dist/runtime.js +1 -0
  250. package/dist/save.d.ts +44 -48
  251. package/dist/save.d.ts.map +1 -1
  252. package/dist/save.js +751 -303
  253. package/dist/saves.d.ts +34 -0
  254. package/dist/saves.d.ts.map +1 -0
  255. package/dist/saves.js +463 -0
  256. package/dist/search.d.ts +12 -82
  257. package/dist/search.d.ts.map +1 -1
  258. package/dist/search.js +10 -207
  259. package/dist/seed.d.ts +11 -2
  260. package/dist/seed.d.ts.map +1 -1
  261. package/dist/seed.js +89 -5
  262. package/dist/selector.d.ts +3 -0
  263. package/dist/selector.d.ts.map +1 -0
  264. package/dist/selector.js +22 -0
  265. package/dist/shared.d.ts +6 -7
  266. package/dist/shared.d.ts.map +1 -1
  267. package/dist/shared.js +75 -104
  268. package/dist/shown.d.ts +35 -0
  269. package/dist/shown.d.ts.map +1 -0
  270. package/dist/shown.js +326 -0
  271. package/dist/socket/admission.d.ts +7 -0
  272. package/dist/socket/admission.d.ts.map +1 -0
  273. package/dist/socket/admission.js +39 -0
  274. package/dist/socket/answers.d.ts +6 -0
  275. package/dist/socket/answers.d.ts.map +1 -0
  276. package/dist/socket/answers.js +20 -0
  277. package/dist/socket/lanes.d.ts +28 -0
  278. package/dist/socket/lanes.d.ts.map +1 -0
  279. package/dist/socket/lanes.js +103 -0
  280. package/dist/socket/reads.d.ts +10 -0
  281. package/dist/socket/reads.d.ts.map +1 -0
  282. package/dist/socket/reads.js +31 -0
  283. package/dist/socket/session.d.ts +41 -0
  284. package/dist/socket/session.d.ts.map +1 -0
  285. package/dist/socket/session.js +26 -0
  286. package/dist/socket.d.ts +68 -0
  287. package/dist/socket.d.ts.map +1 -0
  288. package/dist/socket.js +165 -0
  289. package/dist/source.d.ts +61 -0
  290. package/dist/source.d.ts.map +1 -0
  291. package/dist/source.js +95 -0
  292. package/dist/status.d.ts +4 -5
  293. package/dist/status.d.ts.map +1 -1
  294. package/dist/status.js +3 -7
  295. package/dist/store/installs.d.ts +30 -0
  296. package/dist/store/installs.d.ts.map +1 -0
  297. package/dist/store/installs.js +40 -0
  298. package/dist/store/readiness.d.ts +11 -0
  299. package/dist/store/readiness.d.ts.map +1 -0
  300. package/dist/store/readiness.js +68 -0
  301. package/dist/store/records.d.ts +234 -0
  302. package/dist/store/records.d.ts.map +1 -0
  303. package/dist/store/records.js +474 -0
  304. package/dist/store/room-held.d.ts +8 -0
  305. package/dist/store/room-held.d.ts.map +1 -0
  306. package/dist/store/room-held.js +17 -0
  307. package/dist/store/rooms-shown.d.ts +8 -0
  308. package/dist/store/rooms-shown.d.ts.map +1 -0
  309. package/dist/store/rooms-shown.js +13 -0
  310. package/dist/store/space.d.ts +11 -0
  311. package/dist/store/space.d.ts.map +1 -0
  312. package/dist/store/space.js +41 -0
  313. package/dist/store/watchers.d.ts +17 -0
  314. package/dist/store/watchers.d.ts.map +1 -0
  315. package/dist/store/watchers.js +56 -0
  316. package/dist/store/writes.d.ts +24 -0
  317. package/dist/store/writes.d.ts.map +1 -0
  318. package/dist/store/writes.js +125 -0
  319. package/dist/store.d.ts +115 -149
  320. package/dist/store.d.ts.map +1 -1
  321. package/dist/store.js +166 -716
  322. package/dist/stored.d.ts +181 -0
  323. package/dist/stored.d.ts.map +1 -0
  324. package/dist/stored.js +807 -0
  325. package/dist/surface.d.ts +94 -0
  326. package/dist/surface.d.ts.map +1 -0
  327. package/dist/surface.js +255 -0
  328. package/dist/sync.d.ts +21 -0
  329. package/dist/sync.d.ts.map +1 -0
  330. package/dist/sync.js +557 -0
  331. package/dist/tables.d.ts +388 -0
  332. package/dist/tables.d.ts.map +1 -0
  333. package/dist/tables.js +506 -0
  334. package/dist/tallies.d.ts +18 -0
  335. package/dist/tallies.d.ts.map +1 -0
  336. package/dist/tallies.js +128 -0
  337. package/dist/transfer.d.ts +0 -5
  338. package/dist/transfer.d.ts.map +1 -1
  339. package/dist/turn.d.ts +5 -3
  340. package/dist/turn.d.ts.map +1 -1
  341. package/dist/turn.js +51 -21
  342. package/dist/validation.d.ts +31 -0
  343. package/dist/validation.d.ts.map +1 -0
  344. package/dist/validation.js +144 -0
  345. package/dist/windows.d.ts +11 -0
  346. package/dist/windows.d.ts.map +1 -0
  347. package/dist/windows.js +16 -0
  348. package/dist/wire.d.ts +113 -10
  349. package/dist/wire.d.ts.map +1 -1
  350. package/dist/wire.js +42 -12
  351. package/package.json +20 -20
  352. package/AGENTS.md +0 -299
  353. package/dist/acquisition.d.ts +0 -14
  354. package/dist/acquisition.d.ts.map +0 -1
  355. package/dist/acquisition.js +0 -24
  356. package/dist/attempt.d.ts +0 -16
  357. package/dist/attempt.d.ts.map +0 -1
  358. package/dist/attempt.js +0 -70
  359. package/dist/binary.d.ts.map +0 -1
  360. package/dist/binary.js +0 -8
  361. package/dist/chat/acts.d.ts +0 -33
  362. package/dist/chat/acts.d.ts.map +0 -1
  363. package/dist/chat/acts.js +0 -36
  364. package/dist/chat/context.d.ts +0 -3
  365. package/dist/chat/context.d.ts.map +0 -1
  366. package/dist/chat/input.d.ts +0 -9
  367. package/dist/chat/input.d.ts.map +0 -1
  368. package/dist/chat/input.js +0 -99
  369. package/dist/chat/kit.d.ts +0 -61
  370. package/dist/chat/kit.d.ts.map +0 -1
  371. package/dist/chat/kit.js +0 -123
  372. package/dist/chat/lasting.d.ts +0 -6
  373. package/dist/chat/lasting.d.ts.map +0 -1
  374. package/dist/chat/lasting.js +0 -19
  375. package/dist/chat/list.d.ts +0 -27
  376. package/dist/chat/list.d.ts.map +0 -1
  377. package/dist/chat/list.js +0 -63
  378. package/dist/chat/markdown.d.ts +0 -20
  379. package/dist/chat/markdown.d.ts.map +0 -1
  380. package/dist/chat/markdown.js +0 -188
  381. package/dist/chat/message.d.ts +0 -6
  382. package/dist/chat/message.d.ts.map +0 -1
  383. package/dist/chat/message.js +0 -192
  384. package/dist/chat/messages.d.ts +0 -22
  385. package/dist/chat/messages.d.ts.map +0 -1
  386. package/dist/chat/messages.js +0 -155
  387. package/dist/chat/name.d.ts +0 -6
  388. package/dist/chat/name.d.ts.map +0 -1
  389. package/dist/chat/name.js +0 -37
  390. package/dist/chat/opened.d.ts +0 -11
  391. package/dist/chat/opened.d.ts.map +0 -1
  392. package/dist/chat/opened.js +0 -17
  393. package/dist/chat/overlay.d.ts +0 -31
  394. package/dist/chat/overlay.d.ts.map +0 -1
  395. package/dist/chat/overlay.js +0 -97
  396. package/dist/chat/parts.d.ts +0 -57
  397. package/dist/chat/parts.d.ts.map +0 -1
  398. package/dist/chat/parts.js +0 -119
  399. package/dist/chat/process.d.ts +0 -20
  400. package/dist/chat/process.d.ts.map +0 -1
  401. package/dist/chat/process.js +0 -32
  402. package/dist/chat/provider.d.ts +0 -63
  403. package/dist/chat/provider.d.ts.map +0 -1
  404. package/dist/chat/provider.js +0 -629
  405. package/dist/chat/question.d.ts +0 -9
  406. package/dist/chat/question.d.ts.map +0 -1
  407. package/dist/chat/question.js +0 -80
  408. package/dist/chat/questions.d.ts.map +0 -1
  409. package/dist/chat/read.d.ts.map +0 -1
  410. package/dist/chat/ready.d.ts +0 -34
  411. package/dist/chat/ready.d.ts.map +0 -1
  412. package/dist/chat/ready.js +0 -91
  413. package/dist/chat/style.d.ts +0 -4
  414. package/dist/chat/style.d.ts.map +0 -1
  415. package/dist/chat/style.js +0 -302
  416. package/dist/chat.d.ts +0 -14
  417. package/dist/chat.d.ts.map +0 -1
  418. package/dist/chat.js +0 -8
  419. package/dist/fence.d.ts +0 -6
  420. package/dist/fence.d.ts.map +0 -1
  421. package/dist/fence.js +0 -10
  422. package/dist/log.d.ts +0 -5
  423. package/dist/log.d.ts.map +0 -1
  424. package/dist/log.js +0 -14
  425. package/dist/read-side.d.ts +0 -25
  426. package/dist/read-side.d.ts.map +0 -1
  427. package/dist/read-side.js +0 -642
@@ -1,25 +0,0 @@
1
- import type { ChangeSet } from './change-set.js';
2
- import { type KeyedResult, type QueryMessage } from './observation.js';
3
- import type { PendingResult, Plan, QueryCoverage, QueryRows } from './query.js';
4
- import type { SearchedDocument } from './search.js';
5
- export type Cover = {
6
- coverage: QueryCoverage;
7
- } | PendingResult;
8
- export type ReadSide = {
9
- apply(set: ChangeSet): void;
10
- recover(): void;
11
- query<T>(plan: Plan, at: () => T): Promise<{
12
- rows: QueryRows;
13
- at: T;
14
- }>;
15
- watch(plan: Plan, identity: string, cover: () => Cover, deliver: (message: QueryMessage) => void): () => void;
16
- room(room: string): readonly string[];
17
- document(room: string, path: string): SearchedDocument | null;
18
- close(): void;
19
- };
20
- export declare function reconciled(previous: KeyedResult, next: KeyedResult): {
21
- keyed: KeyedResult;
22
- message: QueryMessage;
23
- } | null;
24
- export declare function createReadSide(): ReadSide;
25
- //# sourceMappingURL=read-side.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"read-side.d.ts","sourceRoot":"","sources":["../src/read-side.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,YAAY,EAAe,MAAM,kBAAkB,CAAC;AACpF,OAAO,KAAK,EAOV,aAAa,EACb,IAAI,EAEJ,aAAa,EAGb,SAAS,EAIV,MAAM,YAAY,CAAC;AAGpB,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AA4CpD,MAAM,MAAM,KAAK,GAAG;IAAE,QAAQ,EAAE,aAAa,CAAA;CAAE,GAAG,aAAa,CAAC;AAuBhE,MAAM,MAAM,QAAQ,GAAG;IACrB,KAAK,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC5B,OAAO,IAAI,IAAI,CAAC;IAChB,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,EAAE,EAAE,CAAC,CAAA;KAAE,CAAC,CAAC;IACvE,KAAK,CACH,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,KAAK,EAClB,OAAO,EAAE,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,GACvC,MAAM,IAAI,CAAC;IACd,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAAC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAAC;IAC9D,KAAK,IAAI,IAAI,CAAC;CACf,CAAC;AAwWF,wBAAgB,UAAU,CACxB,QAAQ,EAAE,WAAW,EACrB,IAAI,EAAE,WAAW,GAChB;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,OAAO,EAAE,YAAY,CAAA;CAAE,GAAG,IAAI,CAuCtD;AAgBD,wBAAgB,cAAc,IAAI,QAAQ,CA+QzC"}
package/dist/read-side.js DELETED
@@ -1,642 +0,0 @@
1
- import { and, BasicIndex, configureIndexDevMode, count, createCollection, createLiveQueryCollection, deepEquals, eq, inArray, or, toArray, } from '@tanstack/db';
2
- import { ARRAY_INDEX, parse, pointerSegments } from '@agentshouse/mdmodel';
3
- import { documentKey } from './rows.js';
4
- import { after, inUnits, ROW_WEIGHT } from './turn.js';
5
- function every(expressions) {
6
- const [first, second, ...rest] = expressions;
7
- return second === undefined ? first : and(first, second, ...rest);
8
- }
9
- function same(held, value) {
10
- return Array.isArray(held) ? held.includes(value) : held === value;
11
- }
12
- function ordered(held, [operator, bound]) {
13
- if (typeof held !== typeof bound || held === null || typeof held === 'object')
14
- return false;
15
- const left = held;
16
- const right = bound;
17
- if (operator === 'gt')
18
- return left > right;
19
- if (operator === 'gte')
20
- return left >= right;
21
- if (operator === 'lt')
22
- return left < right;
23
- return left <= right;
24
- }
25
- function satisfied(test, held) {
26
- if (test.op === 'eq')
27
- return same(held, test.value);
28
- if (test.op === 'ne')
29
- return !same(held, test.value);
30
- if (test.op === 'in')
31
- return test.values.some((value) => same(held, value));
32
- if (test.op === 'nin')
33
- return !test.values.some((value) => same(held, value));
34
- if (test.op === 'range')
35
- return test.bounds.every((bound) => ordered(held, bound));
36
- if (test.op === 'all')
37
- return Array.isArray(held) && test.values.every((value) => same(held, value));
38
- return Array.isArray(held) && held.length === test.size;
39
- }
40
- function tested(test, reached) {
41
- if (test.op === 'exists')
42
- return test.exists === (reached !== undefined);
43
- if (reached === undefined)
44
- return test.op === 'ne' || test.op === 'nin';
45
- return reached.some((held) => satisfied(test, held));
46
- }
47
- function conditioned(condition, row) {
48
- if ('every' in condition)
49
- return condition.every.every((item) => conditioned(item, row));
50
- if ('some' in condition)
51
- return condition.some.some((item) => conditioned(item, row));
52
- return tested(condition.test, row.reached[condition.field]);
53
- }
54
- function narrowed(query, where, alias) {
55
- return where === null ? query : query.fn.where((row) => conditioned(where, row[alias]));
56
- }
57
- function reached(reach, room, document) {
58
- return reach === null
59
- ? []
60
- : [or(inArray(room, [...reach.rooms]), inArray(document, [...reach.documents]))];
61
- }
62
- function scoped(scope, row, rooms, reach) {
63
- return every([
64
- eq(row.kind, 'document'),
65
- ...(rooms === null ? [] : [inArray(row.room, [...rooms])]),
66
- ...reached(reach, row.room, row.key),
67
- ...(scope.types === null ? [] : [inArray(row.type, [...scope.types])]),
68
- ...(scope.pathPrefix === null ? [] : [inArray(scope.pathPrefix, row.directories)]),
69
- ]);
70
- }
71
- function keyed(key, row) {
72
- return key.of === 'field' ? row.values[key.field] : row[key.of];
73
- }
74
- function live(query) {
75
- return createLiveQueryCollection({
76
- query: query,
77
- startSync: true,
78
- });
79
- }
80
- function related(q, rows, scope, field, kept, reach) {
81
- const matched = kept === 'source' ? 'target' : 'source';
82
- const from = q.from({ r: rows });
83
- const joined = from
84
- .where(({ r }) => every([eq(r.kind, 'reference'), ...(field === null ? [] : [inArray(field, r.forms)])]))
85
- .innerJoin({ m: rows }, ({ r, m }) => eq(r[matched], m.key))
86
- .where(({ m }) => scoped(scope, m, null, reach));
87
- return narrowed(joined, scope.where, 'm')
88
- .groupBy(({ r }) => r[kept])
89
- .select(({ r }) => ({ key: r[kept] }));
90
- }
91
- function filtered(q, rows, plan) {
92
- const from = q.from({ d: rows });
93
- let query = narrowed(from.where(({ d }) => scoped(plan.root, d, plan.rooms, plan.reach)), plan.root.where, 'd');
94
- if (plan.hop !== null) {
95
- const hop = related(q, rows, plan.hop, plan.hop.field, 'source', plan.reach);
96
- query = query.innerJoin({ h: hop }, ({ d, h }) => eq(d.key, h.key));
97
- }
98
- if (plan.backlinks !== null) {
99
- const backlinks = related(q, rows, plan.backlinks, plan.backlinks.field, 'target', plan.reach);
100
- query = query.innerJoin({ k: backlinks }, ({ d, k }) => eq(d.key, k.key));
101
- }
102
- return query;
103
- }
104
- function bodied(shape) {
105
- return shape.sections !== null || shape.preamble || shape.markdown;
106
- }
107
- function documents(q, rows, plan, shape) {
108
- let query = filtered(q, rows, plan);
109
- for (const { key, options } of shape.orderBy) {
110
- query = query.orderBy(({ d }) => keyed(key, d), options);
111
- }
112
- if (shape.orderBy.length === 0 && plan.limit !== null) {
113
- query = query.orderBy(({ d }) => d.key, { stringSort: 'lexical' });
114
- }
115
- if (plan.limit !== null)
116
- query = query.limit(plan.limit);
117
- return query.select(({ d }) => ({
118
- room: d.room,
119
- path: d.path,
120
- type: d.type,
121
- binary: d.binary,
122
- ...(shape.fields === null ? {} : { fields: d.fields }),
123
- ...(bodied(shape) ? { text: d.text } : {}),
124
- ...(shape.backlinks ? { backlinks: toArray(backlinked(q, rows, d, plan.reach)) } : {}),
125
- ...(shape.change ? { change: d.change } : {}),
126
- ...(shape.fileId ? { fileId: d.fileId } : {}),
127
- }));
128
- }
129
- function backlinked(q, rows, document, reach) {
130
- const from = q.from({ r: rows });
131
- return from
132
- .where(({ r }) => every([eq(r.target, document.key), ...reached(reach, r.room, r.source)]))
133
- .orderBy(({ r }) => r.path, { stringSort: 'lexical' })
134
- .orderBy(({ r }) => r.field, { stringSort: 'lexical' })
135
- .select(({ r }) => ({ path: r.path, type: r.type, field: r.field }));
136
- }
137
- function groups(q, stage, shape, limit) {
138
- const keys = shape.groupBy.map((_, index) => `key${index}`);
139
- const from = q.from({ m: stage });
140
- let query = from.groupBy(({ m }) => keys.map((key) => m[key]));
141
- for (const { by, direction } of shape.orderBy) {
142
- query = query.orderBy(({ m }) => (by === 'count' ? count(m.key) : m[keys[by]]), direction);
143
- }
144
- if (limit !== null && shape.orderBy.length > 0)
145
- query = query.limit(limit);
146
- return query.select(({ m }) => ({
147
- ...Object.fromEntries(keys.map((key) => [key, m[key]])),
148
- count: count(m.key),
149
- }));
150
- }
151
- function built(rows, plan) {
152
- const shape = plan.shape;
153
- if (shape.kind === 'documents') {
154
- const collection = live((q) => documents(q, rows, plan, shape));
155
- return { live: collection, dispose: () => void collection.cleanup() };
156
- }
157
- const stage = live((q) => filtered(q, rows, plan).select(({ d }) => ({
158
- key: d.key,
159
- ...Object.fromEntries(shape.groupBy.map((key, index) => [`key${index}`, keyed(key, d)])),
160
- })));
161
- const collection = live((q) => groups(q, stage, shape, plan.limit));
162
- return {
163
- live: collection,
164
- dispose: () => {
165
- void collection.cleanup();
166
- void stage.cleanup();
167
- },
168
- };
169
- }
170
- function sectionsOf(sections, names) {
171
- if (names === 'all')
172
- return sections;
173
- return Object.fromEntries(names.flatMap((name) => (Object.hasOwn(sections, name) ? [[name, sections[name]]] : [])));
174
- }
175
- function bodyOf(row, key, bodies) {
176
- const text = row.text;
177
- if (text === null)
178
- return null;
179
- const held = bodies?.get(key);
180
- if (held !== undefined && held.text === text)
181
- return held.document;
182
- const read = parse(text, row.path);
183
- const document = read.ok ? read.document : null;
184
- bodies?.set(key, { text, document });
185
- return document;
186
- }
187
- function masked(pointers) {
188
- const root = { whole: false, members: new Map() };
189
- for (const pointer of pointers) {
190
- let mask = root;
191
- for (const token of pointerSegments(pointer)) {
192
- const next = mask.members.get(token) ?? { whole: false, members: new Map() };
193
- mask.members.set(token, next);
194
- mask = next;
195
- }
196
- mask.whole = true;
197
- }
198
- return root;
199
- }
200
- function merged(left, right) {
201
- if (left === undefined)
202
- return right;
203
- const members = new Map(left.members);
204
- for (const [token, mask] of right.members)
205
- members.set(token, merged(members.get(token), mask));
206
- return { whole: left.whole || right.whole, members };
207
- }
208
- function cut(value, mask) {
209
- if (mask.whole)
210
- return value;
211
- if (Array.isArray(value)) {
212
- const each = {
213
- whole: false,
214
- members: new Map([...mask.members].filter(([token]) => !ARRAY_INDEX.test(token))),
215
- };
216
- const kept = [];
217
- value.forEach((item, index) => {
218
- const part = cut(item, merged(mask.members.get(String(index)), each));
219
- if (part !== undefined)
220
- kept[index] = part;
221
- });
222
- return kept.length === 0 ? undefined : kept;
223
- }
224
- if (typeof value !== 'object' || value === null)
225
- return undefined;
226
- const kept = Object.entries(value).flatMap(([key, held]) => {
227
- const member = mask.members.get(key);
228
- const part = member === undefined ? undefined : cut(held, member);
229
- return part === undefined ? [] : [[key, part]];
230
- });
231
- return kept.length === 0 ? undefined : Object.fromEntries(kept);
232
- }
233
- function selected(fields, pointers) {
234
- return (cut(fields, masked(pointers)) ?? {});
235
- }
236
- function documentOf(key, row, shape, bodies) {
237
- if (row.type === null) {
238
- const binary = row.binary;
239
- return {
240
- room: row.room,
241
- path: row.path,
242
- ...(binary === null ? {} : { binaryFile: binary }),
243
- ...(shape.fileId ? { fileId: row.fileId } : {}),
244
- };
245
- }
246
- const body = bodied(shape) ? bodyOf(row, key, bodies) : null;
247
- return {
248
- room: row.room,
249
- path: row.path,
250
- type: row.type,
251
- ...(shape.fields === null
252
- ? {}
253
- : {
254
- fields: shape.fields === 'all'
255
- ? row.fields
256
- : selected(row.fields, shape.fields),
257
- }),
258
- ...(shape.sections === null || body === null
259
- ? {}
260
- : { sections: sectionsOf(body.sections, shape.sections) }),
261
- ...(shape.preamble && body !== null ? { preamble: body.preamble } : {}),
262
- ...(shape.markdown && body !== null ? { markdown: body.content } : {}),
263
- ...(shape.backlinks
264
- ? {
265
- backlinks: row.backlinks.map(({ path, type, field }) => ({ path, type, field })),
266
- }
267
- : {}),
268
- ...(shape.change ? { change: row.change } : {}),
269
- ...(shape.fileId ? { fileId: row.fileId } : {}),
270
- };
271
- }
272
- function weight(row) {
273
- return ROW_WEIGHT + (typeof row?.text === 'string' ? row.text.length : 0);
274
- }
275
- function rowsOfPlan(plan, entries, bodies, each = (row) => row) {
276
- const shape = plan.shape;
277
- if (shape.kind === 'documents') {
278
- const documents = [];
279
- return after(inUnits(entries, ([key, row]) => {
280
- documents.push(each(documentOf(key, row, shape, bodies)));
281
- return weight(row);
282
- }), () => ({ rows: { documents }, keys: entries.map(([key]) => key) }));
283
- }
284
- const bounded = shape.orderBy.length === 0 && plan.limit !== null ? entries.slice(0, plan.limit) : entries;
285
- const groups = [];
286
- return after(inUnits(bounded, ([, row]) => {
287
- groups.push(each({
288
- key: shape.groupBy.map((_, index) => row[`key${index}`]),
289
- count: row.count,
290
- }));
291
- return ROW_WEIGHT;
292
- }), () => ({ rows: { groups }, keys: bounded.map(([key]) => key) }));
293
- }
294
- export function reconciled(previous, next) {
295
- const before = previous.result;
296
- const after = next.result;
297
- if ('pending' in before || 'pending' in after) {
298
- if (deepEquals(before, after))
299
- return null;
300
- return { keyed: next, message: next };
301
- }
302
- const earlier = 'groups' in before ? before.groups : before.documents;
303
- const held = new Map(previous.keys.map((key, index) => [key, earlier[index]]));
304
- const changed = [];
305
- const rows = ('groups' in after ? after.groups : after.documents).map((row, index) => {
306
- const key = next.keys[index];
307
- const kept = held.get(key);
308
- if (kept !== undefined && deepEquals(kept, row))
309
- return kept;
310
- changed.push([key, row]);
311
- return row;
312
- });
313
- const present = new Set(next.keys);
314
- const removed = previous.keys.filter((key) => !present.has(key));
315
- const moved = reordered(previous.keys, next.keys, present);
316
- const covered = !deepEquals(before.coverage, after.coverage);
317
- if (changed.length === 0 && removed.length === 0 && !moved && !covered)
318
- return null;
319
- return {
320
- keyed: {
321
- result: 'groups' in after
322
- ? { groups: rows, coverage: after.coverage }
323
- : { documents: rows, coverage: after.coverage },
324
- keys: next.keys,
325
- },
326
- message: {
327
- changed,
328
- removed,
329
- order: moved ? next.keys : null,
330
- ...(covered ? { coverage: after.coverage } : {}),
331
- },
332
- };
333
- }
334
- function reordered(previous, next, present) {
335
- let at = 0;
336
- for (const key of previous) {
337
- if (!present.has(key))
338
- continue;
339
- if (next[at] !== key)
340
- return true;
341
- at += 1;
342
- }
343
- return at !== next.length;
344
- }
345
- export function createReadSide() {
346
- configureIndexDevMode({ enabled: false });
347
- let sync;
348
- const rows = createCollection({
349
- getKey: (row) => row.key,
350
- gcTime: 0,
351
- startSync: true,
352
- autoIndex: 'eager',
353
- defaultIndexType: BasicIndex,
354
- sync: {
355
- rowUpdateMode: 'full',
356
- sync: (params) => {
357
- sync = params;
358
- params.markReady();
359
- },
360
- },
361
- });
362
- const shared = new Map();
363
- function searched(row) {
364
- const read = row.text === null ? null : parse(row.text, row.path);
365
- if (read === null || !read.ok)
366
- return null;
367
- return {
368
- room: row.room,
369
- path: row.path,
370
- type: row.type,
371
- fields: row.fields,
372
- preamble: read.document.preamble,
373
- sections: read.document.sections,
374
- };
375
- }
376
- function kept(entry, key, row) {
377
- const held = entry.rows.get(key);
378
- if (held !== undefined && deepEquals(held, row))
379
- return;
380
- entry.rows.set(key, row);
381
- }
382
- function rebuilt(entry) {
383
- return after(rowsOfPlan(entry.plan, [...entry.built.live.entries()], entry.bodies), ({ rows: found, keys }) => {
384
- const present = new Set(keys);
385
- for (const key of [...entry.rows.keys()])
386
- if (!present.has(key))
387
- entry.rows.delete(key);
388
- for (const key of [...entry.bodies.keys()]) {
389
- if (!present.has(key))
390
- entry.bodies.delete(key);
391
- }
392
- keys.forEach((key, index) => kept(entry, key, rowAt(found, index)));
393
- return keys;
394
- });
395
- }
396
- function refreshed(entry, dirty) {
397
- const shape = entry.plan.shape;
398
- const keys = [...entry.built.live.keys()];
399
- const named = new Set([...dirty, ...keys.filter((key) => !entry.rows.has(key))]);
400
- const values = [...named].map((key) => [key, entry.built.live.get(key)]);
401
- const done = inUnits(values, ([key, value]) => {
402
- if (value !== undefined)
403
- kept(entry, key, documentOf(key, value, shape, entry.bodies));
404
- else {
405
- entry.rows.delete(key);
406
- entry.bodies.delete(key);
407
- }
408
- return weight(value);
409
- });
410
- return after(done, () => keys);
411
- }
412
- function current(entry, keys, coverage) {
413
- const found = keys.map((key) => entry.rows.get(key));
414
- return {
415
- result: entry.plan.shape.kind === 'groups'
416
- ? { groups: found, coverage }
417
- : { documents: found, coverage },
418
- keys,
419
- };
420
- }
421
- function delivered(entry, next) {
422
- const previous = entry.result;
423
- entry.result = next;
424
- const message = previous === undefined ? null : changedFrom(previous, next);
425
- if (message !== null)
426
- for (const listener of entry.ready)
427
- listener(message);
428
- for (const listener of entry.fresh) {
429
- entry.ready.add(listener);
430
- listener(next);
431
- }
432
- entry.fresh.clear();
433
- }
434
- function run(entry) {
435
- while (entry.listeners.size > 0 &&
436
- (entry.whole || entry.dirty.size > 0 || entry.stale || entry.fresh.size > 0)) {
437
- entry.stale = false;
438
- const cover = entry.cover();
439
- if ('pending' in cover) {
440
- entry.whole = true;
441
- entry.dirty.clear();
442
- entry.rows.clear();
443
- entry.bodies.clear();
444
- delivered(entry, { result: cover, keys: [] });
445
- break;
446
- }
447
- const whole = entry.whole ||
448
- entry.plan.shape.kind === 'groups' ||
449
- entry.result === undefined ||
450
- 'pending' in entry.result.result;
451
- const dirty = entry.dirty;
452
- entry.dirty = new Set();
453
- entry.whole = false;
454
- const keys = whole ? rebuilt(entry) : refreshed(entry, dirty);
455
- if (keys instanceof Promise) {
456
- void keys
457
- .then((found) => {
458
- if (entry.listeners.size > 0)
459
- delivered(entry, current(entry, found, cover.coverage));
460
- run(entry);
461
- })
462
- .catch(() => {
463
- entry.running = false;
464
- });
465
- return;
466
- }
467
- delivered(entry, current(entry, keys, cover.coverage));
468
- }
469
- entry.running = false;
470
- }
471
- function wake(entry) {
472
- if (entry.subscription === null || entry.running)
473
- return;
474
- entry.running = true;
475
- try {
476
- run(entry);
477
- }
478
- catch (error) {
479
- entry.running = false;
480
- throw error;
481
- }
482
- }
483
- function recover() {
484
- for (const entry of shared.values()) {
485
- if (entry.result === undefined || entry.subscription === null)
486
- continue;
487
- const cover = entry.cover();
488
- const before = entry.result.result;
489
- const held = 'pending' in cover
490
- ? deepEquals(before, cover)
491
- : 'coverage' in before && deepEquals(before.coverage, cover.coverage);
492
- if (held)
493
- continue;
494
- entry.stale = true;
495
- wake(entry);
496
- }
497
- }
498
- return {
499
- apply(set) {
500
- const next = new Map();
501
- for (const change of set.documents) {
502
- for (const row of change.before)
503
- next.set(row.key, null);
504
- for (const row of change.after)
505
- next.set(row.key, row);
506
- }
507
- if (next.size > 0) {
508
- sync.begin();
509
- for (const [key, row] of next) {
510
- if (row === null) {
511
- if (rows.has(key))
512
- sync.write({ type: 'delete', key });
513
- continue;
514
- }
515
- sync.write({ type: rows.has(key) ? 'update' : 'insert', value: row });
516
- }
517
- sync.commit();
518
- }
519
- recover();
520
- },
521
- recover,
522
- async query(plan, at) {
523
- const { live: collection, dispose } = built(rows, plan);
524
- try {
525
- await collection.toArrayWhenReady();
526
- const entries = [...collection.entries()];
527
- const held = at();
528
- const found = await rowsOfPlan(plan, entries, null, structuredClone);
529
- return { rows: found.rows, at: held };
530
- }
531
- finally {
532
- dispose();
533
- }
534
- },
535
- watch(plan, identity, cover, deliverTo) {
536
- let entry = shared.get(identity);
537
- if (entry === undefined) {
538
- const created = {
539
- plan,
540
- built: built(rows, plan),
541
- cover,
542
- result: undefined,
543
- rows: new Map(),
544
- bodies: new Map(),
545
- listeners: new Set(),
546
- fresh: new Set(),
547
- ready: new Set(),
548
- subscription: null,
549
- whole: true,
550
- dirty: new Set(),
551
- stale: false,
552
- running: false,
553
- };
554
- created.built.live.on('status:change', ({ status }) => {
555
- if (status === 'cleaned-up' && created.listeners.size === 0)
556
- shared.delete(identity);
557
- });
558
- shared.set(identity, created);
559
- entry = created;
560
- }
561
- const observed = entry;
562
- observed.listeners.add(deliverTo);
563
- observed.built.live.onFirstReady(() => {
564
- if (!observed.listeners.has(deliverTo))
565
- return;
566
- observed.fresh.add(deliverTo);
567
- if (observed.subscription === null) {
568
- observed.whole = true;
569
- observed.subscription = observed.built.live.subscribeChanges((changes) => {
570
- if (observed.plan.shape.kind === 'groups')
571
- observed.whole = true;
572
- else
573
- for (const { key } of changes)
574
- observed.dirty.add(key);
575
- wake(observed);
576
- }, { includeInitialState: false });
577
- }
578
- wake(observed);
579
- });
580
- return () => {
581
- observed.fresh.delete(deliverTo);
582
- observed.ready.delete(deliverTo);
583
- if (!observed.listeners.delete(deliverTo) || observed.listeners.size > 0)
584
- return;
585
- observed.subscription?.unsubscribe();
586
- observed.subscription = null;
587
- observed.result = undefined;
588
- observed.rows.clear();
589
- observed.bodies.clear();
590
- observed.dirty.clear();
591
- observed.whole = true;
592
- };
593
- },
594
- room(room) {
595
- return rows.toArray.flatMap((row) => row.kind !== 'document' || row.type === null || row.room !== room ? [] : [row.path]);
596
- },
597
- document(room, path) {
598
- const row = rows.get(documentKey(room, path));
599
- return row === undefined || row.type === null ? null : searched(row);
600
- },
601
- close() {
602
- for (const entry of shared.values()) {
603
- entry.listeners.clear();
604
- entry.fresh.clear();
605
- entry.ready.clear();
606
- entry.subscription?.unsubscribe();
607
- entry.built.dispose();
608
- }
609
- shared.clear();
610
- void rows.cleanup();
611
- },
612
- };
613
- }
614
- function changedFrom(previous, next) {
615
- const before = previous.result;
616
- const after = next.result;
617
- if ('pending' in before || 'pending' in after)
618
- return deepEquals(before, after) ? null : next;
619
- const earlier = 'groups' in before ? before.groups : before.documents;
620
- const held = new Map(previous.keys.map((key, index) => [key, earlier[index]]));
621
- const later = 'groups' in after ? after.groups : after.documents;
622
- const changed = [];
623
- next.keys.forEach((key, index) => {
624
- if (held.get(key) !== later[index])
625
- changed.push([key, later[index]]);
626
- });
627
- const present = new Set(next.keys);
628
- const removed = previous.keys.filter((key) => !present.has(key));
629
- const moved = reordered(previous.keys, next.keys, present);
630
- const covered = !deepEquals(before.coverage, after.coverage);
631
- if (changed.length === 0 && removed.length === 0 && !moved && !covered)
632
- return null;
633
- return {
634
- changed,
635
- removed,
636
- order: moved ? next.keys : null,
637
- ...(covered ? { coverage: after.coverage } : {}),
638
- };
639
- }
640
- function rowAt(rows, index) {
641
- return 'groups' in rows ? rows.groups[index] : rows.documents[index];
642
- }