@opendatalabs/personal-server-ts-core 0.0.1-canary.052d47e → 0.0.1-canary.0620a9a

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 (837) hide show
  1. package/dist/additions/budget.d.ts +34 -0
  2. package/dist/additions/budget.d.ts.map +1 -0
  3. package/dist/additions/budget.js +144 -0
  4. package/dist/additions/budget.js.map +1 -0
  5. package/dist/additions/durable.d.ts +94 -0
  6. package/dist/additions/durable.d.ts.map +1 -0
  7. package/dist/additions/durable.js +823 -0
  8. package/dist/additions/durable.js.map +1 -0
  9. package/dist/additions/first-added.d.ts +204 -0
  10. package/dist/additions/first-added.d.ts.map +1 -0
  11. package/dist/additions/first-added.js +598 -0
  12. package/dist/additions/first-added.js.map +1 -0
  13. package/dist/additions/index.d.ts +9 -0
  14. package/dist/additions/index.d.ts.map +1 -0
  15. package/dist/additions/index.js +9 -0
  16. package/dist/additions/index.js.map +1 -0
  17. package/dist/additions/ledger-store.d.ts +69 -0
  18. package/dist/additions/ledger-store.d.ts.map +1 -0
  19. package/dist/additions/ledger-store.js +407 -0
  20. package/dist/additions/ledger-store.js.map +1 -0
  21. package/dist/additions/record-rules.d.ts +54 -0
  22. package/dist/additions/record-rules.d.ts.map +1 -0
  23. package/dist/additions/record-rules.js +198 -0
  24. package/dist/additions/record-rules.js.map +1 -0
  25. package/dist/additions/scope-lock.d.ts +14 -0
  26. package/dist/additions/scope-lock.d.ts.map +1 -0
  27. package/dist/additions/scope-lock.js +32 -0
  28. package/dist/additions/scope-lock.js.map +1 -0
  29. package/dist/additions/summary.d.ts +143 -0
  30. package/dist/additions/summary.d.ts.map +1 -0
  31. package/dist/additions/summary.js +279 -0
  32. package/dist/additions/summary.js.map +1 -0
  33. package/dist/additions/version-inventory.d.ts +86 -0
  34. package/dist/additions/version-inventory.d.ts.map +1 -0
  35. package/dist/additions/version-inventory.js +244 -0
  36. package/dist/additions/version-inventory.js.map +1 -0
  37. package/dist/api/index.d.ts +192 -8
  38. package/dist/api/index.d.ts.map +1 -1
  39. package/dist/api/index.js +1227 -153
  40. package/dist/api/index.js.map +1 -1
  41. package/dist/api/oura-collection-requirements.d.ts +16 -0
  42. package/dist/api/oura-collection-requirements.d.ts.map +1 -0
  43. package/dist/api/oura-collection-requirements.js +70 -0
  44. package/dist/api/oura-collection-requirements.js.map +1 -0
  45. package/dist/api/raw-envelope.d.ts +3 -0
  46. package/dist/api/raw-envelope.d.ts.map +1 -0
  47. package/dist/api/raw-envelope.js +215 -0
  48. package/dist/api/raw-envelope.js.map +1 -0
  49. package/dist/api/scope-upload-batches.d.ts +18 -0
  50. package/dist/api/scope-upload-batches.d.ts.map +1 -0
  51. package/dist/api/scope-upload-batches.js +71 -0
  52. package/dist/api/scope-upload-batches.js.map +1 -0
  53. package/dist/api/scope-uploads.d.ts +112 -0
  54. package/dist/api/scope-uploads.d.ts.map +1 -0
  55. package/dist/api/scope-uploads.js +369 -0
  56. package/dist/api/scope-uploads.js.map +1 -0
  57. package/dist/auth/index.d.ts +3 -1
  58. package/dist/auth/index.d.ts.map +1 -1
  59. package/dist/auth/index.js +3 -1
  60. package/dist/auth/index.js.map +1 -1
  61. package/dist/auth/proof-id.d.ts +8 -0
  62. package/dist/auth/proof-id.d.ts.map +1 -0
  63. package/dist/auth/proof-id.js +29 -0
  64. package/dist/auth/proof-id.js.map +1 -0
  65. package/dist/auth/request.d.ts +24 -0
  66. package/dist/auth/request.d.ts.map +1 -1
  67. package/dist/auth/request.js +99 -4
  68. package/dist/auth/request.js.map +1 -1
  69. package/dist/client.d.ts +70 -0
  70. package/dist/client.d.ts.map +1 -1
  71. package/dist/client.js +1 -0
  72. package/dist/client.js.map +1 -1
  73. package/dist/contracts/auth-device.d.ts +10 -0
  74. package/dist/contracts/auth-device.d.ts.map +1 -1
  75. package/dist/contracts/auth-device.js +2 -0
  76. package/dist/contracts/auth-device.js.map +1 -1
  77. package/dist/contracts/data.d.ts +102 -8
  78. package/dist/contracts/data.d.ts.map +1 -1
  79. package/dist/contracts/data.js +320 -47
  80. package/dist/contracts/data.js.map +1 -1
  81. package/dist/contracts/grants.d.ts.map +1 -1
  82. package/dist/contracts/grants.js +7 -0
  83. package/dist/contracts/grants.js.map +1 -1
  84. package/dist/contracts/index.d.ts +4 -2
  85. package/dist/contracts/index.d.ts.map +1 -1
  86. package/dist/contracts/index.js +3 -1
  87. package/dist/contracts/index.js.map +1 -1
  88. package/dist/contracts/oura-collection-requirements.d.ts +17 -0
  89. package/dist/contracts/oura-collection-requirements.d.ts.map +1 -0
  90. package/dist/contracts/oura-collection-requirements.js +49 -0
  91. package/dist/contracts/oura-collection-requirements.js.map +1 -0
  92. package/dist/contracts/sync.d.ts.map +1 -1
  93. package/dist/contracts/sync.js +1 -0
  94. package/dist/contracts/sync.js.map +1 -1
  95. package/dist/derivatives/answer-shape.d.ts +83 -0
  96. package/dist/derivatives/answer-shape.d.ts.map +1 -0
  97. package/dist/derivatives/answer-shape.js +320 -0
  98. package/dist/derivatives/answer-shape.js.map +1 -0
  99. package/dist/derivatives/api.d.ts +1 -1
  100. package/dist/derivatives/api.d.ts.map +1 -1
  101. package/dist/derivatives/api.js +8 -0
  102. package/dist/derivatives/api.js.map +1 -1
  103. package/dist/derivatives/compute.d.ts +9 -3
  104. package/dist/derivatives/compute.d.ts.map +1 -1
  105. package/dist/derivatives/compute.js +68 -6
  106. package/dist/derivatives/compute.js.map +1 -1
  107. package/dist/derivatives/index.d.ts +2 -1
  108. package/dist/derivatives/index.d.ts.map +1 -1
  109. package/dist/derivatives/index.js +2 -1
  110. package/dist/derivatives/index.js.map +1 -1
  111. package/dist/derivatives/prompt.d.ts +35 -0
  112. package/dist/derivatives/prompt.d.ts.map +1 -1
  113. package/dist/derivatives/prompt.js +96 -8
  114. package/dist/derivatives/prompt.js.map +1 -1
  115. package/dist/derivatives/registration.d.ts +6 -9
  116. package/dist/derivatives/registration.d.ts.map +1 -1
  117. package/dist/derivatives/registration.js +14 -6
  118. package/dist/derivatives/registration.js.map +1 -1
  119. package/dist/derivatives/scheduler.d.ts +39 -9
  120. package/dist/derivatives/scheduler.d.ts.map +1 -1
  121. package/dist/derivatives/scheduler.js +99 -8
  122. package/dist/derivatives/scheduler.js.map +1 -1
  123. package/dist/derivatives/store.d.ts.map +1 -1
  124. package/dist/derivatives/store.js +2 -0
  125. package/dist/derivatives/store.js.map +1 -1
  126. package/dist/derivatives/types.d.ts +13 -3
  127. package/dist/derivatives/types.d.ts.map +1 -1
  128. package/dist/derivatives/types.js +2 -0
  129. package/dist/derivatives/types.js.map +1 -1
  130. package/dist/errors/pdpp-catalog.d.ts +36 -0
  131. package/dist/errors/pdpp-catalog.d.ts.map +1 -0
  132. package/dist/errors/pdpp-catalog.js +86 -0
  133. package/dist/errors/pdpp-catalog.js.map +1 -0
  134. package/dist/grants/index.d.ts +2 -0
  135. package/dist/grants/index.d.ts.map +1 -1
  136. package/dist/grants/index.js +4 -0
  137. package/dist/grants/index.js.map +1 -1
  138. package/dist/grants/pdpp-binding-store.d.ts +89 -0
  139. package/dist/grants/pdpp-binding-store.d.ts.map +1 -0
  140. package/dist/grants/pdpp-binding-store.js +112 -0
  141. package/dist/grants/pdpp-binding-store.js.map +1 -0
  142. package/dist/grants/pdpp-binding.d.ts +169 -0
  143. package/dist/grants/pdpp-binding.d.ts.map +1 -0
  144. package/dist/grants/pdpp-binding.js +236 -0
  145. package/dist/grants/pdpp-binding.js.map +1 -0
  146. package/dist/legacy-projection/bindings.d.ts +31 -0
  147. package/dist/legacy-projection/bindings.d.ts.map +1 -0
  148. package/dist/legacy-projection/bindings.js +4512 -0
  149. package/dist/legacy-projection/bindings.js.map +1 -0
  150. package/dist/legacy-projection/claude-source-record.d.ts +22 -0
  151. package/dist/legacy-projection/claude-source-record.d.ts.map +1 -0
  152. package/dist/legacy-projection/claude-source-record.js +360 -0
  153. package/dist/legacy-projection/claude-source-record.js.map +1 -0
  154. package/dist/legacy-projection/declared-text.d.ts +41 -0
  155. package/dist/legacy-projection/declared-text.d.ts.map +1 -0
  156. package/dist/legacy-projection/declared-text.js +199 -0
  157. package/dist/legacy-projection/declared-text.js.map +1 -0
  158. package/dist/legacy-projection/github-browser-bindings.d.ts +3 -0
  159. package/dist/legacy-projection/github-browser-bindings.d.ts.map +1 -0
  160. package/dist/legacy-projection/github-browser-bindings.js +212 -0
  161. package/dist/legacy-projection/github-browser-bindings.js.map +1 -0
  162. package/dist/legacy-projection/github-legacy-fields.d.ts +6 -0
  163. package/dist/legacy-projection/github-legacy-fields.d.ts.map +1 -0
  164. package/dist/legacy-projection/github-legacy-fields.js +202 -0
  165. package/dist/legacy-projection/github-legacy-fields.js.map +1 -0
  166. package/dist/legacy-projection/index.d.ts +38 -0
  167. package/dist/legacy-projection/index.d.ts.map +1 -0
  168. package/dist/legacy-projection/index.js +231 -0
  169. package/dist/legacy-projection/index.js.map +1 -0
  170. package/dist/legacy-projection/meta-040-bindings.d.ts +3 -0
  171. package/dist/legacy-projection/meta-040-bindings.d.ts.map +1 -0
  172. package/dist/legacy-projection/meta-040-bindings.js +112 -0
  173. package/dist/legacy-projection/meta-040-bindings.js.map +1 -0
  174. package/dist/legacy-projection/oura-browser-bindings.d.ts +5 -0
  175. package/dist/legacy-projection/oura-browser-bindings.d.ts.map +1 -0
  176. package/dist/legacy-projection/oura-browser-bindings.js +141 -0
  177. package/dist/legacy-projection/oura-browser-bindings.js.map +1 -0
  178. package/dist/legacy-projection/provenance.d.ts +57 -0
  179. package/dist/legacy-projection/provenance.d.ts.map +1 -0
  180. package/dist/legacy-projection/provenance.js +2 -0
  181. package/dist/legacy-projection/provenance.js.map +1 -0
  182. package/dist/legacy-projection/strava-browser-bindings.d.ts +3 -0
  183. package/dist/legacy-projection/strava-browser-bindings.d.ts.map +1 -0
  184. package/dist/legacy-projection/strava-browser-bindings.js +32 -0
  185. package/dist/legacy-projection/strava-browser-bindings.js.map +1 -0
  186. package/dist/legacy-projection/test-debris.d.ts +2 -0
  187. package/dist/legacy-projection/test-debris.d.ts.map +1 -0
  188. package/dist/legacy-projection/test-debris.js +49 -0
  189. package/dist/legacy-projection/test-debris.js.map +1 -0
  190. package/dist/legacy-projection/types.d.ts +235 -0
  191. package/dist/legacy-projection/types.d.ts.map +1 -0
  192. package/dist/legacy-projection/types.js +2 -0
  193. package/dist/legacy-projection/types.js.map +1 -0
  194. package/dist/mcp/approval-url.d.ts +68 -0
  195. package/dist/mcp/approval-url.d.ts.map +1 -0
  196. package/dist/mcp/approval-url.js +95 -0
  197. package/dist/mcp/approval-url.js.map +1 -0
  198. package/dist/mcp/connection-api.d.ts +187 -3
  199. package/dist/mcp/connection-api.d.ts.map +1 -1
  200. package/dist/mcp/connection-api.js +600 -26
  201. package/dist/mcp/connection-api.js.map +1 -1
  202. package/dist/mcp/grantee.d.ts +1 -1
  203. package/dist/mcp/grantee.d.ts.map +1 -1
  204. package/dist/mcp/index.d.ts +4 -0
  205. package/dist/mcp/index.d.ts.map +1 -1
  206. package/dist/mcp/index.js +4 -0
  207. package/dist/mcp/index.js.map +1 -1
  208. package/dist/mcp/oauth-redirect.d.ts +14 -0
  209. package/dist/mcp/oauth-redirect.d.ts.map +1 -0
  210. package/dist/mcp/oauth-redirect.js +51 -0
  211. package/dist/mcp/oauth-redirect.js.map +1 -0
  212. package/dist/mcp/read-client.d.ts +5 -1
  213. package/dist/mcp/read-client.d.ts.map +1 -1
  214. package/dist/mcp/read-client.js +18 -4
  215. package/dist/mcp/read-client.js.map +1 -1
  216. package/dist/mcp/resources.d.ts.map +1 -1
  217. package/dist/mcp/resources.js +3 -0
  218. package/dist/mcp/resources.js.map +1 -1
  219. package/dist/mcp/server.d.ts +30 -0
  220. package/dist/mcp/server.d.ts.map +1 -1
  221. package/dist/mcp/server.js +172 -17
  222. package/dist/mcp/server.js.map +1 -1
  223. package/dist/mcp/session.d.ts +1 -1
  224. package/dist/mcp/session.d.ts.map +1 -1
  225. package/dist/mcp/session.js +17 -3
  226. package/dist/mcp/session.js.map +1 -1
  227. package/dist/mcp/store.d.ts +10 -1
  228. package/dist/mcp/store.d.ts.map +1 -1
  229. package/dist/mcp/store.js +72 -0
  230. package/dist/mcp/store.js.map +1 -1
  231. package/dist/mcp/token-expiry.d.ts +48 -0
  232. package/dist/mcp/token-expiry.d.ts.map +1 -0
  233. package/dist/mcp/token-expiry.js +69 -0
  234. package/dist/mcp/token-expiry.js.map +1 -0
  235. package/dist/mcp/tools.d.ts +92 -3
  236. package/dist/mcp/tools.d.ts.map +1 -1
  237. package/dist/mcp/tools.js +513 -28
  238. package/dist/mcp/tools.js.map +1 -1
  239. package/dist/mcp/types.d.ts +103 -4
  240. package/dist/mcp/types.d.ts.map +1 -1
  241. package/dist/mcp/types.js +13 -1
  242. package/dist/mcp/types.js.map +1 -1
  243. package/dist/mcp/write-client.d.ts +81 -0
  244. package/dist/mcp/write-client.d.ts.map +1 -0
  245. package/dist/mcp/write-client.js +140 -0
  246. package/dist/mcp/write-client.js.map +1 -0
  247. package/dist/oura/history-policy.d.ts +12 -0
  248. package/dist/oura/history-policy.d.ts.map +1 -0
  249. package/dist/oura/history-policy.js +54 -0
  250. package/dist/oura/history-policy.js.map +1 -0
  251. package/dist/oura/index.d.ts +51 -0
  252. package/dist/oura/index.d.ts.map +1 -0
  253. package/dist/oura/index.js +315 -0
  254. package/dist/oura/index.js.map +1 -0
  255. package/dist/payment/own-app.d.ts +8 -0
  256. package/dist/payment/own-app.d.ts.map +1 -0
  257. package/dist/payment/own-app.js +47 -0
  258. package/dist/payment/own-app.js.map +1 -0
  259. package/dist/pdpp/approval.d.ts +271 -0
  260. package/dist/pdpp/approval.d.ts.map +1 -0
  261. package/dist/pdpp/approval.js +486 -0
  262. package/dist/pdpp/approval.js.map +1 -0
  263. package/dist/pdpp/client-identity.d.ts +88 -0
  264. package/dist/pdpp/client-identity.d.ts.map +1 -0
  265. package/dist/pdpp/client-identity.js +196 -0
  266. package/dist/pdpp/client-identity.js.map +1 -0
  267. package/dist/pdpp/client-metadata.d.ts +95 -0
  268. package/dist/pdpp/client-metadata.d.ts.map +1 -0
  269. package/dist/pdpp/client-metadata.js +96 -0
  270. package/dist/pdpp/client-metadata.js.map +1 -0
  271. package/dist/pdpp/commitments.d.ts +75 -0
  272. package/dist/pdpp/commitments.d.ts.map +1 -0
  273. package/dist/pdpp/commitments.js +113 -0
  274. package/dist/pdpp/commitments.js.map +1 -0
  275. package/dist/pdpp/declaration-limits.d.ts +7 -0
  276. package/dist/pdpp/declaration-limits.d.ts.map +1 -0
  277. package/dist/pdpp/declaration-limits.js +7 -0
  278. package/dist/pdpp/declaration-limits.js.map +1 -0
  279. package/dist/pdpp/declaration.d.ts +119 -0
  280. package/dist/pdpp/declaration.d.ts.map +1 -0
  281. package/dist/pdpp/declaration.js +837 -0
  282. package/dist/pdpp/declaration.js.map +1 -0
  283. package/dist/pdpp/index.d.ts +38 -0
  284. package/dist/pdpp/index.d.ts.map +1 -0
  285. package/dist/pdpp/index.js +24 -0
  286. package/dist/pdpp/index.js.map +1 -0
  287. package/dist/pdpp/issuance.d.ts +126 -0
  288. package/dist/pdpp/issuance.d.ts.map +1 -0
  289. package/dist/pdpp/issuance.js +184 -0
  290. package/dist/pdpp/issuance.js.map +1 -0
  291. package/dist/pdpp/pkce.d.ts +53 -0
  292. package/dist/pdpp/pkce.d.ts.map +1 -0
  293. package/dist/pdpp/pkce.js +109 -0
  294. package/dist/pdpp/pkce.js.map +1 -0
  295. package/dist/pdpp/redirect.d.ts +60 -0
  296. package/dist/pdpp/redirect.d.ts.map +1 -0
  297. package/dist/pdpp/redirect.js +125 -0
  298. package/dist/pdpp/redirect.js.map +1 -0
  299. package/dist/pdpp/resolve.d.ts +120 -0
  300. package/dist/pdpp/resolve.d.ts.map +1 -0
  301. package/dist/pdpp/resolve.js +491 -0
  302. package/dist/pdpp/resolve.js.map +1 -0
  303. package/dist/pdpp/review.d.ts +280 -0
  304. package/dist/pdpp/review.d.ts.map +1 -0
  305. package/dist/pdpp/review.js +205 -0
  306. package/dist/pdpp/review.js.map +1 -0
  307. package/dist/pdpp/selection.d.ts +79 -0
  308. package/dist/pdpp/selection.d.ts.map +1 -0
  309. package/dist/pdpp/selection.js +493 -0
  310. package/dist/pdpp/selection.js.map +1 -0
  311. package/dist/pdpp/store.d.ts +228 -0
  312. package/dist/pdpp/store.d.ts.map +1 -0
  313. package/dist/pdpp/store.js +542 -0
  314. package/dist/pdpp/store.js.map +1 -0
  315. package/dist/pdpp/time.d.ts +39 -0
  316. package/dist/pdpp/time.d.ts.map +1 -0
  317. package/dist/pdpp/time.js +173 -0
  318. package/dist/pdpp/time.js.map +1 -0
  319. package/dist/pdpp/tokens.d.ts +181 -0
  320. package/dist/pdpp/tokens.d.ts.map +1 -0
  321. package/dist/pdpp/tokens.js +421 -0
  322. package/dist/pdpp/tokens.js.map +1 -0
  323. package/dist/pdpp/types.d.ts +457 -0
  324. package/dist/pdpp/types.d.ts.map +1 -0
  325. package/dist/pdpp/types.js +68 -0
  326. package/dist/pdpp/types.js.map +1 -0
  327. package/dist/pdpp-version.d.ts +28 -0
  328. package/dist/pdpp-version.d.ts.map +1 -0
  329. package/dist/pdpp-version.js +28 -0
  330. package/dist/pdpp-version.js.map +1 -0
  331. package/dist/policy/data-read.d.ts +52 -1
  332. package/dist/policy/data-read.d.ts.map +1 -1
  333. package/dist/policy/data-read.js +157 -3
  334. package/dist/policy/data-read.js.map +1 -1
  335. package/dist/policy/data-write.d.ts.map +1 -1
  336. package/dist/policy/data-write.js +18 -1
  337. package/dist/policy/data-write.js.map +1 -1
  338. package/dist/policy/index.d.ts +2 -1
  339. package/dist/policy/index.d.ts.map +1 -1
  340. package/dist/policy/index.js +2 -1
  341. package/dist/policy/index.js.map +1 -1
  342. package/dist/policy/reserved-scopes.d.ts +10 -0
  343. package/dist/policy/reserved-scopes.d.ts.map +1 -0
  344. package/dist/policy/reserved-scopes.js +16 -0
  345. package/dist/policy/reserved-scopes.js.map +1 -0
  346. package/dist/ports/index.d.ts +266 -5
  347. package/dist/ports/index.d.ts.map +1 -1
  348. package/dist/ports/index.js.map +1 -1
  349. package/dist/ports/pdpp-auth.d.ts +119 -0
  350. package/dist/ports/pdpp-auth.d.ts.map +1 -0
  351. package/dist/ports/pdpp-auth.js +46 -0
  352. package/dist/ports/pdpp-auth.js.map +1 -0
  353. package/dist/ports/pdpp-auth.test-utils.d.ts +9 -0
  354. package/dist/ports/pdpp-auth.test-utils.d.ts.map +1 -0
  355. package/dist/ports/pdpp-auth.test-utils.js +18 -0
  356. package/dist/ports/pdpp-auth.test-utils.js.map +1 -0
  357. package/dist/publication/publish.d.ts +109 -0
  358. package/dist/publication/publish.d.ts.map +1 -0
  359. package/dist/publication/publish.js +263 -0
  360. package/dist/publication/publish.js.map +1 -0
  361. package/dist/replication/completion.d.ts +20 -0
  362. package/dist/replication/completion.d.ts.map +1 -0
  363. package/dist/replication/completion.js +73 -0
  364. package/dist/replication/completion.js.map +1 -0
  365. package/dist/replication/coordinator-state.d.ts +29 -0
  366. package/dist/replication/coordinator-state.d.ts.map +1 -0
  367. package/dist/replication/coordinator-state.js +88 -0
  368. package/dist/replication/coordinator-state.js.map +1 -0
  369. package/dist/replication/coordinator-state.test-utils.d.ts +32 -0
  370. package/dist/replication/coordinator-state.test-utils.d.ts.map +1 -0
  371. package/dist/replication/coordinator-state.test-utils.js +113 -0
  372. package/dist/replication/coordinator-state.test-utils.js.map +1 -0
  373. package/dist/replication/coordinator.d.ts +264 -0
  374. package/dist/replication/coordinator.d.ts.map +1 -0
  375. package/dist/replication/coordinator.js +499 -0
  376. package/dist/replication/coordinator.js.map +1 -0
  377. package/dist/replication/copies.d.ts +126 -0
  378. package/dist/replication/copies.d.ts.map +1 -0
  379. package/dist/replication/copies.js +437 -0
  380. package/dist/replication/copies.js.map +1 -0
  381. package/dist/replication/copy-promotion.d.ts +132 -0
  382. package/dist/replication/copy-promotion.d.ts.map +1 -0
  383. package/dist/replication/copy-promotion.js +126 -0
  384. package/dist/replication/copy-promotion.js.map +1 -0
  385. package/dist/replication/door.d.ts +33 -0
  386. package/dist/replication/door.d.ts.map +1 -0
  387. package/dist/replication/door.js +10 -0
  388. package/dist/replication/door.js.map +1 -0
  389. package/dist/replication/dpv2.d.ts +141 -0
  390. package/dist/replication/dpv2.d.ts.map +1 -0
  391. package/dist/replication/dpv2.js +320 -0
  392. package/dist/replication/dpv2.js.map +1 -0
  393. package/dist/replication/effects.d.ts +68 -0
  394. package/dist/replication/effects.d.ts.map +1 -0
  395. package/dist/replication/effects.js +89 -0
  396. package/dist/replication/effects.js.map +1 -0
  397. package/dist/replication/engine.d.ts +378 -0
  398. package/dist/replication/engine.d.ts.map +1 -0
  399. package/dist/replication/engine.js +3197 -0
  400. package/dist/replication/engine.js.map +1 -0
  401. package/dist/replication/envelope.d.ts +481 -0
  402. package/dist/replication/envelope.d.ts.map +1 -0
  403. package/dist/replication/envelope.js +192 -0
  404. package/dist/replication/envelope.js.map +1 -0
  405. package/dist/replication/evidence.d.ts +118 -0
  406. package/dist/replication/evidence.d.ts.map +1 -0
  407. package/dist/replication/evidence.js +198 -0
  408. package/dist/replication/evidence.js.map +1 -0
  409. package/dist/replication/finality.d.ts +16 -0
  410. package/dist/replication/finality.d.ts.map +1 -0
  411. package/dist/replication/finality.js +11 -0
  412. package/dist/replication/finality.js.map +1 -0
  413. package/dist/replication/fixtures.d.ts +16 -0
  414. package/dist/replication/fixtures.d.ts.map +1 -0
  415. package/dist/replication/fixtures.js +47 -0
  416. package/dist/replication/fixtures.js.map +1 -0
  417. package/dist/replication/host-config.d.ts +52 -0
  418. package/dist/replication/host-config.d.ts.map +1 -0
  419. package/dist/replication/host-config.js +111 -0
  420. package/dist/replication/host-config.js.map +1 -0
  421. package/dist/replication/host-driver.d.ts +95 -0
  422. package/dist/replication/host-driver.d.ts.map +1 -0
  423. package/dist/replication/host-driver.js +202 -0
  424. package/dist/replication/host-driver.js.map +1 -0
  425. package/dist/replication/host-ports.d.ts +48 -0
  426. package/dist/replication/host-ports.d.ts.map +1 -0
  427. package/dist/replication/host-ports.js +69 -0
  428. package/dist/replication/host-ports.js.map +1 -0
  429. package/dist/replication/identity.d.ts +13 -0
  430. package/dist/replication/identity.d.ts.map +1 -0
  431. package/dist/replication/identity.js +22 -0
  432. package/dist/replication/identity.js.map +1 -0
  433. package/dist/replication/limits.d.ts +124 -0
  434. package/dist/replication/limits.d.ts.map +1 -0
  435. package/dist/replication/limits.js +182 -0
  436. package/dist/replication/limits.js.map +1 -0
  437. package/dist/replication/merge-plan.d.ts +92 -0
  438. package/dist/replication/merge-plan.d.ts.map +1 -0
  439. package/dist/replication/merge-plan.js +229 -0
  440. package/dist/replication/merge-plan.js.map +1 -0
  441. package/dist/replication/namespace.d.ts +4 -0
  442. package/dist/replication/namespace.d.ts.map +1 -0
  443. package/dist/replication/namespace.js +7 -0
  444. package/dist/replication/namespace.js.map +1 -0
  445. package/dist/replication/outcome.d.ts +178 -0
  446. package/dist/replication/outcome.d.ts.map +1 -0
  447. package/dist/replication/outcome.js +83 -0
  448. package/dist/replication/outcome.js.map +1 -0
  449. package/dist/replication/payload.d.ts +39 -0
  450. package/dist/replication/payload.d.ts.map +1 -0
  451. package/dist/replication/payload.js +137 -0
  452. package/dist/replication/payload.js.map +1 -0
  453. package/dist/replication/preparation.d.ts +42 -0
  454. package/dist/replication/preparation.d.ts.map +1 -0
  455. package/dist/replication/preparation.js +118 -0
  456. package/dist/replication/preparation.js.map +1 -0
  457. package/dist/replication/rebaseline.d.ts +33 -0
  458. package/dist/replication/rebaseline.d.ts.map +1 -0
  459. package/dist/replication/rebaseline.js +40 -0
  460. package/dist/replication/rebaseline.js.map +1 -0
  461. package/dist/replication/rebinding.d.ts +43 -0
  462. package/dist/replication/rebinding.d.ts.map +1 -0
  463. package/dist/replication/rebinding.js +52 -0
  464. package/dist/replication/rebinding.js.map +1 -0
  465. package/dist/replication/receive.d.ts +57 -0
  466. package/dist/replication/receive.d.ts.map +1 -0
  467. package/dist/replication/receive.js +114 -0
  468. package/dist/replication/receive.js.map +1 -0
  469. package/dist/replication/record-reducer.d.ts +16 -0
  470. package/dist/replication/record-reducer.d.ts.map +1 -0
  471. package/dist/replication/record-reducer.js +52 -0
  472. package/dist/replication/record-reducer.js.map +1 -0
  473. package/dist/replication/revision.d.ts +24 -0
  474. package/dist/replication/revision.d.ts.map +1 -0
  475. package/dist/replication/revision.js +35 -0
  476. package/dist/replication/revision.js.map +1 -0
  477. package/dist/replication/roster.d.ts +53 -0
  478. package/dist/replication/roster.d.ts.map +1 -0
  479. package/dist/replication/roster.js +115 -0
  480. package/dist/replication/roster.js.map +1 -0
  481. package/dist/replication/schedule.d.ts +73 -0
  482. package/dist/replication/schedule.d.ts.map +1 -0
  483. package/dist/replication/schedule.js +182 -0
  484. package/dist/replication/schedule.js.map +1 -0
  485. package/dist/replication/stream.d.ts +73 -0
  486. package/dist/replication/stream.d.ts.map +1 -0
  487. package/dist/replication/stream.js +542 -0
  488. package/dist/replication/stream.js.map +1 -0
  489. package/dist/replication/transport.d.ts +236 -0
  490. package/dist/replication/transport.d.ts.map +1 -0
  491. package/dist/replication/transport.js +440 -0
  492. package/dist/replication/transport.js.map +1 -0
  493. package/dist/replication/visibility-engine.d.ts +337 -0
  494. package/dist/replication/visibility-engine.d.ts.map +1 -0
  495. package/dist/replication/visibility-engine.js +602 -0
  496. package/dist/replication/visibility-engine.js.map +1 -0
  497. package/dist/replication/visibility-policy.d.ts +26 -0
  498. package/dist/replication/visibility-policy.d.ts.map +1 -0
  499. package/dist/replication/visibility-policy.js +33 -0
  500. package/dist/replication/visibility-policy.js.map +1 -0
  501. package/dist/replication/writer-identity-store.d.ts +100 -0
  502. package/dist/replication/writer-identity-store.d.ts.map +1 -0
  503. package/dist/replication/writer-identity-store.js +218 -0
  504. package/dist/replication/writer-identity-store.js.map +1 -0
  505. package/dist/replication/writer-identity.d.ts +252 -0
  506. package/dist/replication/writer-identity.d.ts.map +1 -0
  507. package/dist/replication/writer-identity.js +281 -0
  508. package/dist/replication/writer-identity.js.map +1 -0
  509. package/dist/replication/writer-identity.test-utils.d.ts +24 -0
  510. package/dist/replication/writer-identity.test-utils.d.ts.map +1 -0
  511. package/dist/replication/writer-identity.test-utils.js +86 -0
  512. package/dist/replication/writer-identity.test-utils.js.map +1 -0
  513. package/dist/schemas/server-config.d.ts +71 -0
  514. package/dist/schemas/server-config.d.ts.map +1 -1
  515. package/dist/schemas/server-config.js +151 -0
  516. package/dist/schemas/server-config.js.map +1 -1
  517. package/dist/signing/request-signer.d.ts +2 -0
  518. package/dist/signing/request-signer.d.ts.map +1 -1
  519. package/dist/signing/request-signer.js +1 -0
  520. package/dist/signing/request-signer.js.map +1 -1
  521. package/dist/storage/adapters/index.d.ts +3 -1
  522. package/dist/storage/adapters/index.d.ts.map +1 -1
  523. package/dist/storage/adapters/index.js +2 -0
  524. package/dist/storage/adapters/index.js.map +1 -1
  525. package/dist/storage/adapters/interface.d.ts +21 -1
  526. package/dist/storage/adapters/interface.d.ts.map +1 -1
  527. package/dist/storage/adapters/interface.js +13 -1
  528. package/dist/storage/adapters/interface.js.map +1 -1
  529. package/dist/storage/adapters/sdk.d.ts +2 -1
  530. package/dist/storage/adapters/sdk.d.ts.map +1 -1
  531. package/dist/storage/adapters/sdk.js +21 -3
  532. package/dist/storage/adapters/sdk.js.map +1 -1
  533. package/dist/storage/adapters/vana-audience.d.ts +24 -0
  534. package/dist/storage/adapters/vana-audience.d.ts.map +1 -0
  535. package/dist/storage/adapters/vana-audience.js +87 -0
  536. package/dist/storage/adapters/vana-audience.js.map +1 -0
  537. package/dist/storage/adapters/vana.d.ts +5 -3
  538. package/dist/storage/adapters/vana.d.ts.map +1 -1
  539. package/dist/storage/adapters/vana.js +69 -23
  540. package/dist/storage/adapters/vana.js.map +1 -1
  541. package/dist/storage/blocks/cursor.d.ts +5 -1
  542. package/dist/storage/blocks/cursor.d.ts.map +1 -1
  543. package/dist/storage/blocks/cursor.js +13 -1
  544. package/dist/storage/blocks/cursor.js.map +1 -1
  545. package/dist/storage/blocks/page.d.ts +18 -0
  546. package/dist/storage/blocks/page.d.ts.map +1 -0
  547. package/dist/storage/blocks/page.js +113 -0
  548. package/dist/storage/blocks/page.js.map +1 -0
  549. package/dist/storage/canonical-legacy-projection.d.ts +262 -0
  550. package/dist/storage/canonical-legacy-projection.d.ts.map +1 -0
  551. package/dist/storage/canonical-legacy-projection.js +759 -0
  552. package/dist/storage/canonical-legacy-projection.js.map +1 -0
  553. package/dist/storage/hierarchy/paths.d.ts.map +1 -1
  554. package/dist/storage/hierarchy/paths.js +9 -2
  555. package/dist/storage/hierarchy/paths.js.map +1 -1
  556. package/dist/storage/index/manager.d.ts +30 -3
  557. package/dist/storage/index/manager.d.ts.map +1 -1
  558. package/dist/storage/index/schema.d.ts +1 -1
  559. package/dist/storage/index/schema.js +1 -1
  560. package/dist/storage/index/types.d.ts +7 -1
  561. package/dist/storage/index/types.d.ts.map +1 -1
  562. package/dist/storage/legacy-projection.d.ts +88 -0
  563. package/dist/storage/legacy-projection.d.ts.map +1 -0
  564. package/dist/storage/legacy-projection.js +755 -0
  565. package/dist/storage/legacy-projection.js.map +1 -0
  566. package/dist/storage/legacy-scope-coverage-exceptions.d.ts +13 -0
  567. package/dist/storage/legacy-scope-coverage-exceptions.d.ts.map +1 -0
  568. package/dist/storage/legacy-scope-coverage-exceptions.js +14 -0
  569. package/dist/storage/legacy-scope-coverage-exceptions.js.map +1 -0
  570. package/dist/storage/legacy-scope-coverage.d.ts +53 -0
  571. package/dist/storage/legacy-scope-coverage.d.ts.map +1 -0
  572. package/dist/storage/legacy-scope-coverage.js +416 -0
  573. package/dist/storage/legacy-scope-coverage.js.map +1 -0
  574. package/dist/storage/legacy-scope-entity-keys.d.ts +17 -0
  575. package/dist/storage/legacy-scope-entity-keys.d.ts.map +1 -0
  576. package/dist/storage/legacy-scope-entity-keys.js +109 -0
  577. package/dist/storage/legacy-scope-entity-keys.js.map +1 -0
  578. package/dist/storage/legacy-scope-view.d.ts +206 -0
  579. package/dist/storage/legacy-scope-view.d.ts.map +1 -0
  580. package/dist/storage/legacy-scope-view.js +1061 -0
  581. package/dist/storage/legacy-scope-view.js.map +1 -0
  582. package/dist/storage/pdpp-records/completion.d.ts +91 -0
  583. package/dist/storage/pdpp-records/completion.d.ts.map +1 -0
  584. package/dist/storage/pdpp-records/completion.js +170 -0
  585. package/dist/storage/pdpp-records/completion.js.map +1 -0
  586. package/dist/storage/pdpp-records/cursor.d.ts +86 -0
  587. package/dist/storage/pdpp-records/cursor.d.ts.map +1 -0
  588. package/dist/storage/pdpp-records/cursor.js +56 -0
  589. package/dist/storage/pdpp-records/cursor.js.map +1 -0
  590. package/dist/storage/pdpp-records/declaration-witness.d.ts +58 -0
  591. package/dist/storage/pdpp-records/declaration-witness.d.ts.map +1 -0
  592. package/dist/storage/pdpp-records/declaration-witness.js +230 -0
  593. package/dist/storage/pdpp-records/declaration-witness.js.map +1 -0
  594. package/dist/storage/pdpp-records/enforcement.d.ts +39 -0
  595. package/dist/storage/pdpp-records/enforcement.d.ts.map +1 -0
  596. package/dist/storage/pdpp-records/enforcement.js +143 -0
  597. package/dist/storage/pdpp-records/enforcement.js.map +1 -0
  598. package/dist/storage/pdpp-records/index.d.ts +7 -0
  599. package/dist/storage/pdpp-records/index.d.ts.map +1 -0
  600. package/dist/storage/pdpp-records/index.js +6 -0
  601. package/dist/storage/pdpp-records/index.js.map +1 -0
  602. package/dist/storage/pdpp-records/ingest-plan.d.ts +39 -0
  603. package/dist/storage/pdpp-records/ingest-plan.d.ts.map +1 -0
  604. package/dist/storage/pdpp-records/ingest-plan.js +103 -0
  605. package/dist/storage/pdpp-records/ingest-plan.js.map +1 -0
  606. package/dist/storage/pdpp-records/interface.d.ts +111 -0
  607. package/dist/storage/pdpp-records/interface.d.ts.map +1 -0
  608. package/dist/storage/pdpp-records/interface.js +2 -0
  609. package/dist/storage/pdpp-records/interface.js.map +1 -0
  610. package/dist/storage/pdpp-records/list-page.d.ts +35 -0
  611. package/dist/storage/pdpp-records/list-page.d.ts.map +1 -0
  612. package/dist/storage/pdpp-records/list-page.js +106 -0
  613. package/dist/storage/pdpp-records/list-page.js.map +1 -0
  614. package/dist/storage/pdpp-records/memory-store.d.ts +9 -0
  615. package/dist/storage/pdpp-records/memory-store.d.ts.map +1 -0
  616. package/dist/storage/pdpp-records/memory-store.js +462 -0
  617. package/dist/storage/pdpp-records/memory-store.js.map +1 -0
  618. package/dist/storage/pdpp-records/portable.d.ts +12 -0
  619. package/dist/storage/pdpp-records/portable.d.ts.map +1 -0
  620. package/dist/storage/pdpp-records/portable.js +11 -0
  621. package/dist/storage/pdpp-records/portable.js.map +1 -0
  622. package/dist/storage/pdpp-records/read-port.d.ts +44 -0
  623. package/dist/storage/pdpp-records/read-port.d.ts.map +1 -0
  624. package/dist/storage/pdpp-records/read-port.js +22 -0
  625. package/dist/storage/pdpp-records/read-port.js.map +1 -0
  626. package/dist/storage/pdpp-records/record-key.d.ts +52 -0
  627. package/dist/storage/pdpp-records/record-key.d.ts.map +1 -0
  628. package/dist/storage/pdpp-records/record-key.js +97 -0
  629. package/dist/storage/pdpp-records/record-key.js.map +1 -0
  630. package/dist/storage/pdpp-records/replication-journal.d.ts +20 -0
  631. package/dist/storage/pdpp-records/replication-journal.d.ts.map +1 -0
  632. package/dist/storage/pdpp-records/replication-journal.js +2 -0
  633. package/dist/storage/pdpp-records/replication-journal.js.map +1 -0
  634. package/dist/storage/pdpp-records/schema.d.ts +41 -0
  635. package/dist/storage/pdpp-records/schema.d.ts.map +1 -0
  636. package/dist/storage/pdpp-records/schema.js +153 -0
  637. package/dist/storage/pdpp-records/schema.js.map +1 -0
  638. package/dist/storage/pdpp-records/stream-declaration.d.ts +86 -0
  639. package/dist/storage/pdpp-records/stream-declaration.d.ts.map +1 -0
  640. package/dist/storage/pdpp-records/stream-declaration.js +48 -0
  641. package/dist/storage/pdpp-records/stream-declaration.js.map +1 -0
  642. package/dist/storage/pdpp-records/sync-selection.d.ts +4 -0
  643. package/dist/storage/pdpp-records/sync-selection.d.ts.map +1 -0
  644. package/dist/storage/pdpp-records/sync-selection.js +37 -0
  645. package/dist/storage/pdpp-records/sync-selection.js.map +1 -0
  646. package/dist/storage/pdpp-records/types.d.ts +202 -0
  647. package/dist/storage/pdpp-records/types.d.ts.map +1 -0
  648. package/dist/storage/pdpp-records/types.js +38 -0
  649. package/dist/storage/pdpp-records/types.js.map +1 -0
  650. package/dist/stream-sync/artifacts.d.ts +31 -0
  651. package/dist/stream-sync/artifacts.d.ts.map +1 -0
  652. package/dist/stream-sync/artifacts.js +106 -0
  653. package/dist/stream-sync/artifacts.js.map +1 -0
  654. package/dist/stream-sync/blobs.d.ts +11 -0
  655. package/dist/stream-sync/blobs.d.ts.map +1 -0
  656. package/dist/stream-sync/blobs.js +34 -0
  657. package/dist/stream-sync/blobs.js.map +1 -0
  658. package/dist/stream-sync/crypto.d.ts +21 -0
  659. package/dist/stream-sync/crypto.d.ts.map +1 -0
  660. package/dist/stream-sync/crypto.js +45 -0
  661. package/dist/stream-sync/crypto.js.map +1 -0
  662. package/dist/stream-sync/home.d.ts +46 -0
  663. package/dist/stream-sync/home.d.ts.map +1 -0
  664. package/dist/stream-sync/home.js +37 -0
  665. package/dist/stream-sync/home.js.map +1 -0
  666. package/dist/stream-sync/index.d.ts +14 -0
  667. package/dist/stream-sync/index.d.ts.map +1 -0
  668. package/dist/stream-sync/index.js +14 -0
  669. package/dist/stream-sync/index.js.map +1 -0
  670. package/dist/stream-sync/intake.d.ts +165 -0
  671. package/dist/stream-sync/intake.d.ts.map +1 -0
  672. package/dist/stream-sync/intake.js +467 -0
  673. package/dist/stream-sync/intake.js.map +1 -0
  674. package/dist/stream-sync/io-barrier.d.ts +39 -0
  675. package/dist/stream-sync/io-barrier.d.ts.map +1 -0
  676. package/dist/stream-sync/io-barrier.js +130 -0
  677. package/dist/stream-sync/io-barrier.js.map +1 -0
  678. package/dist/stream-sync/memory-files.d.ts +6 -0
  679. package/dist/stream-sync/memory-files.d.ts.map +1 -0
  680. package/dist/stream-sync/memory-files.js +50 -0
  681. package/dist/stream-sync/memory-files.js.map +1 -0
  682. package/dist/stream-sync/ports.d.ts +134 -0
  683. package/dist/stream-sync/ports.d.ts.map +1 -0
  684. package/dist/stream-sync/ports.js +26 -0
  685. package/dist/stream-sync/ports.js.map +1 -0
  686. package/dist/stream-sync/publish-plan.d.ts +157 -0
  687. package/dist/stream-sync/publish-plan.d.ts.map +1 -0
  688. package/dist/stream-sync/publish-plan.js +212 -0
  689. package/dist/stream-sync/publish-plan.js.map +1 -0
  690. package/dist/stream-sync/registry.d.ts +19 -0
  691. package/dist/stream-sync/registry.d.ts.map +1 -0
  692. package/dist/stream-sync/registry.js +125 -0
  693. package/dist/stream-sync/registry.js.map +1 -0
  694. package/dist/stream-sync/scope-routing.d.ts +17 -0
  695. package/dist/stream-sync/scope-routing.d.ts.map +1 -0
  696. package/dist/stream-sync/scope-routing.js +24 -0
  697. package/dist/stream-sync/scope-routing.js.map +1 -0
  698. package/dist/stream-sync/spool.d.ts +69 -0
  699. package/dist/stream-sync/spool.d.ts.map +1 -0
  700. package/dist/stream-sync/spool.js +197 -0
  701. package/dist/stream-sync/spool.js.map +1 -0
  702. package/dist/stream-sync/writer-overlay.d.ts +19 -0
  703. package/dist/stream-sync/writer-overlay.d.ts.map +1 -0
  704. package/dist/stream-sync/writer-overlay.js +55 -0
  705. package/dist/stream-sync/writer-overlay.js.map +1 -0
  706. package/dist/stream-sync/writer.d.ts +404 -0
  707. package/dist/stream-sync/writer.d.ts.map +1 -0
  708. package/dist/stream-sync/writer.js +1994 -0
  709. package/dist/stream-sync/writer.js.map +1 -0
  710. package/dist/stream-sync-read/fold.d.ts +69 -0
  711. package/dist/stream-sync-read/fold.d.ts.map +1 -0
  712. package/dist/stream-sync-read/fold.js +83 -0
  713. package/dist/stream-sync-read/fold.js.map +1 -0
  714. package/dist/stream-sync-read/importer.d.ts +81 -0
  715. package/dist/stream-sync-read/importer.d.ts.map +1 -0
  716. package/dist/stream-sync-read/importer.js +226 -0
  717. package/dist/stream-sync-read/importer.js.map +1 -0
  718. package/dist/stream-sync-read/index.d.ts +8 -0
  719. package/dist/stream-sync-read/index.d.ts.map +1 -0
  720. package/dist/stream-sync-read/index.js +5 -0
  721. package/dist/stream-sync-read/index.js.map +1 -0
  722. package/dist/stream-sync-read/keys.d.ts +16 -0
  723. package/dist/stream-sync-read/keys.d.ts.map +1 -0
  724. package/dist/stream-sync-read/keys.js +48 -0
  725. package/dist/stream-sync-read/keys.js.map +1 -0
  726. package/dist/stream-sync-read/lines.d.ts +37 -0
  727. package/dist/stream-sync-read/lines.d.ts.map +1 -0
  728. package/dist/stream-sync-read/lines.js +98 -0
  729. package/dist/stream-sync-read/lines.js.map +1 -0
  730. package/dist/stream-sync-read/memory-files.d.ts +6 -0
  731. package/dist/stream-sync-read/memory-files.d.ts.map +1 -0
  732. package/dist/stream-sync-read/memory-files.js +34 -0
  733. package/dist/stream-sync-read/memory-files.js.map +1 -0
  734. package/dist/stream-sync-read/mirror.d.ts +80 -0
  735. package/dist/stream-sync-read/mirror.d.ts.map +1 -0
  736. package/dist/stream-sync-read/mirror.js +189 -0
  737. package/dist/stream-sync-read/mirror.js.map +1 -0
  738. package/dist/stream-sync-read/ports.d.ts +155 -0
  739. package/dist/stream-sync-read/ports.d.ts.map +1 -0
  740. package/dist/stream-sync-read/ports.js +9 -0
  741. package/dist/stream-sync-read/ports.js.map +1 -0
  742. package/dist/stream-sync-read/projection.d.ts +47 -0
  743. package/dist/stream-sync-read/projection.d.ts.map +1 -0
  744. package/dist/stream-sync-read/projection.js +338 -0
  745. package/dist/stream-sync-read/projection.js.map +1 -0
  746. package/dist/stream-sync-read/routing.d.ts +27 -0
  747. package/dist/stream-sync-read/routing.d.ts.map +1 -0
  748. package/dist/stream-sync-read/routing.js +49 -0
  749. package/dist/stream-sync-read/routing.js.map +1 -0
  750. package/dist/stream-sync-read/service-fixture.d.ts +94 -0
  751. package/dist/stream-sync-read/service-fixture.d.ts.map +1 -0
  752. package/dist/stream-sync-read/service-fixture.js +227 -0
  753. package/dist/stream-sync-read/service-fixture.js.map +1 -0
  754. package/dist/stream-sync-read/service.d.ts +260 -0
  755. package/dist/stream-sync-read/service.d.ts.map +1 -0
  756. package/dist/stream-sync-read/service.js +975 -0
  757. package/dist/stream-sync-read/service.js.map +1 -0
  758. package/dist/stream-sync-read/testing.d.ts +54 -0
  759. package/dist/stream-sync-read/testing.d.ts.map +1 -0
  760. package/dist/stream-sync-read/testing.js +80 -0
  761. package/dist/stream-sync-read/testing.js.map +1 -0
  762. package/dist/stream-sync-read/view-store.d.ts +98 -0
  763. package/dist/stream-sync-read/view-store.d.ts.map +1 -0
  764. package/dist/stream-sync-read/view-store.js +278 -0
  765. package/dist/stream-sync-read/view-store.js.map +1 -0
  766. package/dist/stream-sync-read/writer-rig.d.ts +122 -0
  767. package/dist/stream-sync-read/writer-rig.d.ts.map +1 -0
  768. package/dist/stream-sync-read/writer-rig.js +301 -0
  769. package/dist/stream-sync-read/writer-rig.js.map +1 -0
  770. package/dist/sync/data-point-feed.d.ts +3 -0
  771. package/dist/sync/data-point-feed.d.ts.map +1 -1
  772. package/dist/sync/data-point-feed.js +20 -1
  773. package/dist/sync/data-point-feed.js.map +1 -1
  774. package/dist/sync/delete-data-port.d.ts +19 -0
  775. package/dist/sync/delete-data-port.d.ts.map +1 -1
  776. package/dist/sync/delete-data-port.js +42 -9
  777. package/dist/sync/delete-data-port.js.map +1 -1
  778. package/dist/sync/engine/sync-manager.d.ts +21 -1
  779. package/dist/sync/engine/sync-manager.d.ts.map +1 -1
  780. package/dist/sync/engine/sync-manager.js +140 -11
  781. package/dist/sync/engine/sync-manager.js.map +1 -1
  782. package/dist/sync/index.d.ts +6 -2
  783. package/dist/sync/index.d.ts.map +1 -1
  784. package/dist/sync/index.js +7 -1
  785. package/dist/sync/index.js.map +1 -1
  786. package/dist/sync/pdpp-import.d.ts +192 -0
  787. package/dist/sync/pdpp-import.d.ts.map +1 -0
  788. package/dist/sync/pdpp-import.js +441 -0
  789. package/dist/sync/pdpp-import.js.map +1 -0
  790. package/dist/sync/pending-blob-deletions.d.ts +18 -2
  791. package/dist/sync/pending-blob-deletions.d.ts.map +1 -1
  792. package/dist/sync/pending-blob-deletions.js +97 -23
  793. package/dist/sync/pending-blob-deletions.js.map +1 -1
  794. package/dist/sync/scope-deletions.d.ts +12 -0
  795. package/dist/sync/scope-deletions.d.ts.map +1 -1
  796. package/dist/sync/scope-deletions.js +99 -25
  797. package/dist/sync/scope-deletions.js.map +1 -1
  798. package/dist/sync/tombstone-finality.d.ts +36 -0
  799. package/dist/sync/tombstone-finality.d.ts.map +1 -0
  800. package/dist/sync/tombstone-finality.js +142 -0
  801. package/dist/sync/tombstone-finality.js.map +1 -0
  802. package/dist/sync/tombstone-resubmits.d.ts +61 -0
  803. package/dist/sync/tombstone-resubmits.d.ts.map +1 -0
  804. package/dist/sync/tombstone-resubmits.js +85 -0
  805. package/dist/sync/tombstone-resubmits.js.map +1 -0
  806. package/dist/sync/types.d.ts +10 -0
  807. package/dist/sync/types.d.ts.map +1 -1
  808. package/dist/sync/workers/delete.d.ts +54 -5
  809. package/dist/sync/workers/delete.d.ts.map +1 -1
  810. package/dist/sync/workers/delete.js +594 -170
  811. package/dist/sync/workers/delete.js.map +1 -1
  812. package/dist/sync/workers/download.d.ts +42 -1
  813. package/dist/sync/workers/download.d.ts.map +1 -1
  814. package/dist/sync/workers/download.js +344 -24
  815. package/dist/sync/workers/download.js.map +1 -1
  816. package/dist/sync/workers/lost-data-points.d.ts +38 -0
  817. package/dist/sync/workers/lost-data-points.d.ts.map +1 -0
  818. package/dist/sync/workers/lost-data-points.js +72 -0
  819. package/dist/sync/workers/lost-data-points.js.map +1 -0
  820. package/dist/sync/workers/upload.d.ts +27 -6
  821. package/dist/sync/workers/upload.d.ts.map +1 -1
  822. package/dist/sync/workers/upload.js +169 -274
  823. package/dist/sync/workers/upload.js.map +1 -1
  824. package/dist/test-utils/memory-storage.d.ts +1 -1
  825. package/dist/test-utils/memory-storage.d.ts.map +1 -1
  826. package/dist/test-utils/memory-storage.js +83 -17
  827. package/dist/test-utils/memory-storage.js.map +1 -1
  828. package/dist/write/attribution.d.ts.map +1 -1
  829. package/dist/write/attribution.js +8 -4
  830. package/dist/write/attribution.js.map +1 -1
  831. package/dist/write/route.d.ts.map +1 -1
  832. package/dist/write/route.js +9 -10
  833. package/dist/write/route.js.map +1 -1
  834. package/dist/write/session.d.ts.map +1 -1
  835. package/dist/write/session.js +13 -0
  836. package/dist/write/session.js.map +1 -1
  837. package/package.json +103 -3
@@ -0,0 +1,975 @@
1
+ /**
2
+ * Stream-sync read side of one Personal Server (§2.9, §2.10).
3
+ *
4
+ * - The download worker hands it every physical registry row it lists
5
+ * (`observe`), before its cursor moves, then lets it import (`importPending`).
6
+ * - A data GET asks `resolve` what to serve for a requested name: a stream
7
+ * view, the existing legacy path, or a refusal. The decision is the
8
+ * package's one `eligible` rule; nothing here re-derives it.
9
+ *
10
+ * Requested names are logical: `pdpp.<c>.<s>` or a legacy binding name. A
11
+ * caller may pick a connection with `connection=<ns>`; grants never name
12
+ * one. Physical `~` names are never accepted as a requested name.
13
+ */
14
+ import { canonicalBytes32, classifyStreamRow, controlHashes, eligible, isHeadLive, selectConnection, streamScope, } from "@opendatalabs/personal-server-ts-stream-sync";
15
+ import { alternateLegacyBindingsForScope, LEGACY_SCOPE_BINDINGS, } from "../legacy-projection/index.js";
16
+ import { foldPlan, planHeadOf, } from "./fold.js";
17
+ import { StreamSyncImporter } from "./importer.js";
18
+ import { NO_OVERLAY, overlayWinners, viewLines, } from "./lines.js";
19
+ import { RegistryMirror, toControlRead, } from "./mirror.js";
20
+ import { planProjection, ProjectionFailedError } from "./projection.js";
21
+ import { isPhysicalScope, logicalStreamScopeParts } from "./routing.js";
22
+ import { ViewStore, } from "./view-store.js";
23
+ /**
24
+ * One row per stream the read side knows, for owner diagnostics. `records` is
25
+ * the imported head's record count only while that head is live (§2.4). A
26
+ * pending (unimported), tombstoned, superseded-generation or
27
+ * deleted-connection head counts `null`. Logical connection selection, a
28
+ * legacy-file fallback and rows from the local outbox overlay are outside
29
+ * this count.
30
+ */
31
+ export function liveStreamCounts(status) {
32
+ return status.connections.flatMap((connection) => Object.entries(connection.streams).map(([stream, head]) => ({
33
+ connector: connection.connector,
34
+ ns: connection.ns,
35
+ stream,
36
+ records: head.live ? head.records : null,
37
+ })));
38
+ }
39
+ const NS = /^(?:[0-9a-f]{16})?$/;
40
+ const DEFAULT_ARRAY_BUDGET = 64 * 1024 * 1024;
41
+ const encoder = new TextEncoder();
42
+ function legacyConnectorKey(pdppSource) {
43
+ return pdppSource.slice(pdppSource.lastIndexOf("/") + 1);
44
+ }
45
+ /** The connectors and streams a logical name reads. */
46
+ export function readTargets(scope) {
47
+ if (isPhysicalScope(scope))
48
+ return [];
49
+ const targets = new Map();
50
+ const plain = logicalStreamScopeParts(scope);
51
+ if (plain) {
52
+ targets.set(plain.connector, {
53
+ connector: plain.connector,
54
+ streams: [plain.stream],
55
+ });
56
+ }
57
+ const original = LEGACY_SCOPE_BINDINGS.get(scope);
58
+ if (original) {
59
+ const connector = legacyConnectorKey(original.pdppSource);
60
+ targets.set(connector, {
61
+ connector,
62
+ streams: original.pdppStreams,
63
+ binding: original,
64
+ });
65
+ }
66
+ for (const [profileKey, binding] of alternateLegacyBindingsForScope(scope)) {
67
+ targets.set(profileKey, {
68
+ connector: profileKey,
69
+ streams: binding.pdppStreams,
70
+ binding,
71
+ });
72
+ }
73
+ return [...targets.values()];
74
+ }
75
+ /** Whether the imported view holds everything the published stream holds. */
76
+ function covers(base, receipt) {
77
+ if (base.head.generation !== receipt.generation)
78
+ return false;
79
+ if (base.version > receipt.registryVersion)
80
+ return true;
81
+ return (base.version === receipt.registryVersion &&
82
+ sameBytes32(base.dataHash, receipt.dataHash));
83
+ }
84
+ /** Digests compare in the one spelling the writer uses; a malformed one never matches. */
85
+ function sameBytes32(a, b) {
86
+ try {
87
+ return canonicalBytes32(a) === canonicalBytes32(b);
88
+ }
89
+ catch {
90
+ return false;
91
+ }
92
+ }
93
+ function encodeCursor(cursor) {
94
+ const json = JSON.stringify(cursor);
95
+ let binary = "";
96
+ for (const byte of encoder.encode(json))
97
+ binary += String.fromCharCode(byte);
98
+ return btoa(binary)
99
+ .replace(/\+/g, "-")
100
+ .replace(/\//g, "_")
101
+ .replace(/=+$/, "");
102
+ }
103
+ function decodeCursor(text) {
104
+ try {
105
+ const binary = atob(text.replace(/-/g, "+").replace(/_/g, "/"));
106
+ const bytes = Uint8Array.from(binary, (c) => c.charCodeAt(0));
107
+ const parsed = JSON.parse(new TextDecoder().decode(bytes));
108
+ if (typeof parsed?.c !== "string" || typeof parsed.ns !== "string") {
109
+ return null;
110
+ }
111
+ const streams = {};
112
+ if (typeof parsed.s === "object" && parsed.s !== null) {
113
+ for (const [name, pin] of Object.entries(parsed.s)) {
114
+ const { b, m, p, d, h } = (pin ?? {});
115
+ if (b !== null && !Number.isSafeInteger(b))
116
+ return null;
117
+ const pairs = (x) => Array.isArray(x) &&
118
+ x.every((y) => Array.isArray(y) &&
119
+ y.length === 2 &&
120
+ typeof y[0] === "string" &&
121
+ typeof y[1] === "string");
122
+ if (m !== undefined && !pairs(m))
123
+ return null;
124
+ if (p !== undefined && !pairs(p))
125
+ return null;
126
+ if (d !== undefined && typeof d !== "boolean")
127
+ return null;
128
+ if (h !== undefined && typeof h !== "string")
129
+ return null;
130
+ streams[name] = {
131
+ b: b,
132
+ ...(m ? { m: m } : {}),
133
+ ...(p ? { p: p } : {}),
134
+ ...(d !== undefined ? { d } : {}),
135
+ ...(h !== undefined ? { h } : {}),
136
+ };
137
+ }
138
+ }
139
+ else if (typeof parsed.v === "object" && parsed.v !== null) {
140
+ // A cursor from before overlay pins: registry versions only.
141
+ for (const [name, version] of Object.entries(parsed.v)) {
142
+ if (!Number.isSafeInteger(version))
143
+ return null;
144
+ streams[name] = { b: version };
145
+ }
146
+ }
147
+ else {
148
+ return null;
149
+ }
150
+ return { c: parsed.c, ns: parsed.ns, s: streams };
151
+ }
152
+ catch {
153
+ return null;
154
+ }
155
+ }
156
+ function toStream(chunks, done) {
157
+ const iterator = chunks[Symbol.asyncIterator]();
158
+ let finished = false;
159
+ const finish = () => {
160
+ if (finished)
161
+ return;
162
+ finished = true;
163
+ done();
164
+ };
165
+ return new ReadableStream({
166
+ async pull(controller) {
167
+ try {
168
+ let buffer = "";
169
+ while (buffer.length < 64 * 1024) {
170
+ const next = await iterator.next();
171
+ if (next.done) {
172
+ if (buffer)
173
+ controller.enqueue(encoder.encode(buffer));
174
+ controller.close();
175
+ finish();
176
+ return;
177
+ }
178
+ buffer += next.value;
179
+ }
180
+ controller.enqueue(encoder.encode(buffer));
181
+ }
182
+ catch (error) {
183
+ finish();
184
+ controller.error(error);
185
+ }
186
+ },
187
+ async cancel() {
188
+ finish();
189
+ await iterator.return?.(undefined);
190
+ },
191
+ });
192
+ }
193
+ /** What a read sees when no overlay source is configured. */
194
+ const NO_SNAPSHOT = {
195
+ runs: [],
196
+ plan: () => [],
197
+ lines: () => {
198
+ throw new Error("no overlay source");
199
+ },
200
+ release() { },
201
+ };
202
+ /** Reads start over this many times when an import lands under them. */
203
+ const MAX_COHERENCE_ATTEMPTS = 8;
204
+ const BUSY_RETRY_AFTER_SECONDS = 1;
205
+ export class StreamSyncReadService {
206
+ options;
207
+ mirror;
208
+ views;
209
+ importer;
210
+ changed;
211
+ spoolCounter = 0;
212
+ constructor(options, mirror, views, importer, changed) {
213
+ this.options = options;
214
+ this.mirror = mirror;
215
+ this.views = views;
216
+ this.importer = importer;
217
+ this.changed = changed;
218
+ }
219
+ static async open(options) {
220
+ const hashes = await controlHashes(options.keys.hashes.keccak256, options.keys.keyCheck);
221
+ const mirror = await RegistryMirror.open(options.files, (row) => classifyStreamRow(toControlRead(row), hashes) === "tombstoned");
222
+ const views = await ViewStore.open(options.files);
223
+ await options.files.remove("spool");
224
+ const importer = new StreamSyncImporter({
225
+ mirror,
226
+ views,
227
+ blobs: options.blobs,
228
+ keys: options.keys,
229
+ controlHashes: hashes,
230
+ logger: options.logger,
231
+ // Only durable files may let the source retire what they cover.
232
+ ...(options.durable && options.overlay
233
+ ? {
234
+ acknowledge: (coverage) => options.overlay.acknowledge(coverage),
235
+ }
236
+ : {}),
237
+ });
238
+ // Every durable current view is covered already: say so, so a restart
239
+ // retires what an interrupted acknowledgment left behind.
240
+ if (options.durable && options.overlay) {
241
+ for (const { key, version } of views.views()) {
242
+ await importer.acknowledge(key, {
243
+ version: version.version,
244
+ dataHash: version.dataHash,
245
+ generation: version.head.generation,
246
+ });
247
+ }
248
+ }
249
+ // Import whatever the mirror holds that a crash left unimported.
250
+ return new StreamSyncReadService(options, mirror, views, importer, new Set(mirror.connectors()));
251
+ }
252
+ /** True when the next listing must start from the registry's first page. */
253
+ wantsListingFromStart() {
254
+ return this.mirror.wantsListingFromStart();
255
+ }
256
+ /** Record one listed page. Call before the listing cursor moves. */
257
+ async observe(rows, page) {
258
+ for (const connector of await this.mirror.observe(rows, page)) {
259
+ this.changed.add(connector);
260
+ }
261
+ }
262
+ /** Import changed connectors and retry those with a retried problem. */
263
+ async importPending() {
264
+ const connectors = new Set([
265
+ ...this.changed,
266
+ ...this.importer.retryConnectors(),
267
+ ]);
268
+ this.changed = new Set();
269
+ await this.importer.run([...connectors].sort());
270
+ }
271
+ status() {
272
+ const connections = [];
273
+ for (const connector of this.mirror.connectors()) {
274
+ for (const view of this.connectionViews(connector)) {
275
+ const streams = {};
276
+ for (const [stream, head] of Object.entries(view.streams)) {
277
+ const imported = this.importer.servableView({
278
+ connector,
279
+ ns: view.ns,
280
+ stream,
281
+ });
282
+ streams[stream] = {
283
+ ...head,
284
+ version: imported?.version ?? null,
285
+ records: imported?.head.recordCount ?? null,
286
+ };
287
+ }
288
+ connections.push({
289
+ connector,
290
+ ns: view.ns,
291
+ control: view.control.kind,
292
+ streams,
293
+ });
294
+ }
295
+ }
296
+ return {
297
+ listed: !this.mirror.needsFullListing(),
298
+ connections,
299
+ issues: this.importer.listIssues(),
300
+ };
301
+ }
302
+ /**
303
+ * The local runs whose rows `stream` of `(connector, ns)` shows on top of
304
+ * `base`, read from the writer's publish plan (`foldPlan`). A run counts
305
+ * only under a verified active control state of this key and its own
306
+ * generation (never the one active at read time), and never over a
307
+ * tombstoned stream row. A published stream that `base` already covers adds
308
+ * nothing: its rows are in the view.
309
+ *
310
+ * `pending` reads this device's own rows that no verified activation of
311
+ * their generation covers. `steps`, from a cursor, replays the plan of
312
+ * exactly those runs; the withheld and unpublished runs are still every
313
+ * such run now.
314
+ */
315
+ contributions(snapshot, connector, ns, stream, control, tombstoned, base, options = {}) {
316
+ const { pending = false, steps } = options;
317
+ const head = base && planHeadOf(base.head);
318
+ const none = foldPlan(head, [], []);
319
+ if (!snapshot || tombstoned)
320
+ return none;
321
+ // Pending: this device's own rows that no verified activation of their
322
+ // generation covers. A verified control of another generation, a deleted
323
+ // connection and a foreign key hide them.
324
+ if (pending
325
+ ? !(control.kind === "absent" || control.kind === "active")
326
+ : control.kind !== "active") {
327
+ return none;
328
+ }
329
+ // A receipt at or below the stream's deletion floor was published before
330
+ // the owner deleted the stream: the same rule servableView applies to
331
+ // imported views, on every overlay path (owner, pending and overlay-only).
332
+ const floor = this.mirror.deletionFloor(streamScope(connector, ns, stream));
333
+ const candidates = [];
334
+ for (const run of snapshot.runs) {
335
+ if (run.connector !== connector ||
336
+ run.ns !== ns ||
337
+ (pending
338
+ ? control.kind === "active" &&
339
+ run.generation !== null &&
340
+ run.generation !== control.generation
341
+ : run.generation !== control.generation)) {
342
+ continue;
343
+ }
344
+ const local = run.streams.find((s) => s.name === stream);
345
+ if (!local)
346
+ continue;
347
+ if (local.receipt && local.receipt.registryVersion <= floor)
348
+ continue;
349
+ if (local.receipt && base && covers(base, local.receipt))
350
+ continue;
351
+ candidates.push({ run, stream: local });
352
+ }
353
+ const fold = (runs) => foldPlan(head, runs, snapshot.plan(ns, stream, head, runs.map((c) => c.run.runId)));
354
+ const all = fold(candidates);
355
+ if (!steps)
356
+ return all;
357
+ const replay = fold(candidates.filter((c) => steps.some(([runId, revision]) => runId === c.run.runId && revision === c.stream.contentRevision)));
358
+ return {
359
+ ...replay,
360
+ withheld: all.withheld,
361
+ unpublished: all.unpublished,
362
+ awaiting: all.awaiting,
363
+ };
364
+ }
365
+ /** §2.10 inputs for connector c: every connection this server knows. */
366
+ connectionViews(connector, snapshot) {
367
+ const rows = this.mirror.rowsFor(connector);
368
+ const namespaces = new Set([
369
+ ...rows.controls.keys(),
370
+ ...rows.streams.keys(),
371
+ ]);
372
+ const out = [];
373
+ for (const ns of [...namespaces].sort()) {
374
+ const control = this.importer.controlState(rows.controls.get(ns));
375
+ const streams = {};
376
+ let latest = null;
377
+ const mirrored = rows.streams.get(ns) ?? new Map();
378
+ const names = new Set(mirrored.keys());
379
+ for (const run of snapshot?.runs ?? []) {
380
+ if (run.ns !== ns)
381
+ continue;
382
+ for (const s of run.streams)
383
+ names.add(s.name);
384
+ }
385
+ for (const stream of [...names].sort()) {
386
+ const row = mirrored.get(stream);
387
+ const imported = this.importer.servableView({ connector, ns, stream });
388
+ const kind = row ? this.importer.streamRowKind(row) : null;
389
+ const live = imported !== null &&
390
+ kind !== null &&
391
+ isHeadLive(control, kind, imported.head.generation);
392
+ const local = this.contributions(snapshot, connector, ns, stream, control, kind === "tombstoned", live ? imported : null);
393
+ streams[stream] = {
394
+ live: live || local.merged.length > 0,
395
+ complete: local.complete,
396
+ };
397
+ // Q6: the registry time of the connection's newest live stream head.
398
+ if (live && row && row.addedAtMs !== null) {
399
+ latest =
400
+ latest === null ? row.addedAtMs : Math.max(latest, row.addedAtMs);
401
+ }
402
+ }
403
+ out.push({ ns, control, latestHeadRegistration: latest, streams });
404
+ }
405
+ return out;
406
+ }
407
+ async resolve(input) {
408
+ if (input.connection !== null && !NS.test(input.connection)) {
409
+ return { kind: "invalid_connection" };
410
+ }
411
+ let cursor = null;
412
+ if (input.cursor !== null) {
413
+ cursor = decodeCursor(input.cursor);
414
+ if (!cursor)
415
+ return { kind: "invalid_cursor" };
416
+ }
417
+ const known = new Set(this.mirror.connectors());
418
+ const all = readTargets(input.scope);
419
+ const targets = all.filter((t) => known.has(t.connector));
420
+ // A connector the registry mirror has never seen can still hold the
421
+ // owner's local runs (a first run made offline).
422
+ const candidates = this.options.overlay && input.isOwnerView
423
+ ? all.filter((t) => !known.has(t.connector))
424
+ : [];
425
+ if (targets.length === 0 && candidates.length === 0) {
426
+ return input.connection !== null
427
+ ? { kind: "unavailable", reason: "connection_not_found" }
428
+ : { kind: "pass" };
429
+ }
430
+ // One pinned snapshot per connector, taken BEFORE any imported view is
431
+ // leased: whatever an import retires after this point stays readable
432
+ // from the pin. The chosen view keeps its snapshot until the body ends.
433
+ //
434
+ // The snapshot's plan knows the writer's commits up to the snapshot. An
435
+ // import that lands after it carries commits the plan does not know, so
436
+ // pairing that base with this plan could show a run the writer refuses.
437
+ // The read starts over when an import lands before the decision is made.
438
+ // Only the streams this read touches can invalidate it: the import
439
+ // revisions of the target streams are its basis. The snapshot pins the
440
+ // writer state of those streams (a publication in flight is part of it),
441
+ // so a later writer change alone cannot pair a base with another plan.
442
+ const touched = [...targets, ...candidates];
443
+ const basis = () => touched
444
+ .flatMap((t) => t.streams.map((s) => this.views.revision(t.connector, s)))
445
+ .join(",");
446
+ for (let attempt = 1;; attempt += 1) {
447
+ const before = basis();
448
+ const snapshots = new Map();
449
+ let decision;
450
+ try {
451
+ for (const target of [...targets, ...candidates]) {
452
+ snapshots.set(target.connector,
453
+ // Only the owner view reads local runs. A grant is answered from
454
+ // the imported heads, as if no local run existed.
455
+ input.isOwnerView
456
+ ? await this.snapshot(target.connector)
457
+ : NO_SNAPSHOT);
458
+ }
459
+ decision = await this.decide(input, cursor, targets, candidates, snapshots);
460
+ }
461
+ finally {
462
+ for (const snapshot of snapshots.values())
463
+ snapshot.release();
464
+ }
465
+ if (basis() === before)
466
+ return decision;
467
+ if ("body" in decision)
468
+ await decision.body.cancel();
469
+ if (attempt >= MAX_COHERENCE_ATTEMPTS) {
470
+ return { kind: "busy", retryAfterSeconds: BUSY_RETRY_AFTER_SECONDS };
471
+ }
472
+ }
473
+ }
474
+ snapshot(connector) {
475
+ return this.options.overlay
476
+ ? this.options.overlay.snapshot(connector)
477
+ : Promise.resolve(NO_SNAPSHOT);
478
+ }
479
+ async decide(input, cursor, targets, candidates, snapshots) {
480
+ const evaluated = targets.map((target) => {
481
+ const connections = this.connectionViews(target.connector, snapshots.get(target.connector));
482
+ const eligibility = this.eligibility(input, target, connections);
483
+ return { target, connections, eligibility };
484
+ });
485
+ // The owner never reads fewer records than a grant. When the stored body
486
+ // answers a grant (no published view of the imported heads), it answers
487
+ // the owner too, whatever the owner's own overlay would show: a complete
488
+ // overlay does not contain a different stored body.
489
+ const grantReadsFile = input.isOwnerView &&
490
+ input.legacyFile &&
491
+ input.connection === null &&
492
+ !targets.some((target) => this.eligibility(input, target, this.connectionViews(target.connector)).kind === "view");
493
+ const views = evaluated
494
+ .filter((e) => !grantReadsFile && e.eligibility.kind === "view")
495
+ .map((e) => {
496
+ const ns = e.eligibility.ns;
497
+ const selected = e.connections.find((c) => c.ns === ns);
498
+ return {
499
+ ...e,
500
+ ns,
501
+ registered: selected.latestHeadRegistration ?? -Infinity,
502
+ };
503
+ })
504
+ .sort((a, b) => b.registered - a.registered ||
505
+ (a.target.connector < b.target.connector ? -1 : 1));
506
+ if (views.length > 0) {
507
+ const best = views[0];
508
+ // The view owns its snapshot from here: it releases it with the body.
509
+ const snapshot = snapshots.get(best.target.connector);
510
+ snapshots.delete(best.target.connector);
511
+ return this.serveView(input.scope, best.target, best.ns, cursor, snapshot, input.isOwnerView);
512
+ }
513
+ const deleted = evaluated.some((e) => e.eligibility.kind === "unavailable" &&
514
+ e.eligibility.reason === "deleted");
515
+ // The owner's partial view, unless a deletion hides the connector. The
516
+ // owner never reads fewer rows than a grant: when a grant would read the
517
+ // legacy body, the owner reads it too, with the notes.
518
+ let notes = {};
519
+ if (input.isOwnerView && !deleted) {
520
+ const scan = this.pendingScan(input, [...targets, ...candidates], snapshots);
521
+ if (scan.best && !grantReadsFile) {
522
+ const snapshot = snapshots.get(scan.best.target.connector);
523
+ snapshots.delete(scan.best.target.connector);
524
+ try {
525
+ return await this.serveView(input.scope, scan.best.target, scan.best.ns, cursor, snapshot, true, "pending");
526
+ }
527
+ catch (error) {
528
+ // The projector refuses the partial input (a legacy name whose
529
+ // rows are not all there yet). No partial view serves; the answer
530
+ // below does, with the notes. serveView released the snapshot.
531
+ if (!(error instanceof ProjectionFailedError))
532
+ throw error;
533
+ this.options.logger.info({ connector: scan.best.target.connector }, "stream-sync read: the partial view cannot be projected");
534
+ // The writer will publish these runs, but the requested name cannot
535
+ // show them: the owner is told, whatever answer follows.
536
+ scan.withheld = uniqueWithheld([
537
+ ...scan.withheld,
538
+ ...scan.best.shown,
539
+ ]);
540
+ }
541
+ }
542
+ // No view is served: the runs the writer will not publish still reach
543
+ // the owner, with the answer that is.
544
+ if (scan.withheld.length > 0) {
545
+ this.logWithheld(scan.connectors, scan.withheld.length);
546
+ notes = { withheld: scan.withheld };
547
+ }
548
+ // The legacy body answers, as before own-writes; unpublished runs are
549
+ // counted, never compared by time.
550
+ if (input.legacyFile && scan.unpublished > 0) {
551
+ this.options.logger.info({ connector: scan.connectors.join(","), pending: scan.unpublished }, "stream-sync read: legacy body served over pending local runs");
552
+ notes = { ...notes, pending: { runs: scan.unpublished } };
553
+ }
554
+ // Published is not reflected: until import covers a published run, the
555
+ // legacy body does not show it either.
556
+ if (input.legacyFile && scan.awaiting > 0) {
557
+ notes = { ...notes, awaitingImport: { runs: scan.awaiting } };
558
+ }
559
+ // A live imported head the stored body does not reflect, whatever the
560
+ // runs say: import and retirement do not end this note, reflection does.
561
+ if (input.legacyFile && scan.notReflected > 0) {
562
+ notes = { ...notes, notReflected: { streams: scan.notReflected } };
563
+ }
564
+ }
565
+ if (cursor)
566
+ return { kind: "cursor_stale" };
567
+ if (deleted) {
568
+ return { kind: "unavailable", reason: "deleted" };
569
+ }
570
+ // A named connection is served only from its own view: a legacy file
571
+ // records no connection.
572
+ if (input.connection !== null) {
573
+ const foreign = evaluated.some((e) => e.connections.some((c) => c.ns === input.connection && c.control.kind === "foreign"));
574
+ return foreign
575
+ ? { kind: "key_mismatch" }
576
+ : { kind: "unavailable", reason: "connection_not_found", ...notes };
577
+ }
578
+ if (evaluated.some((e) => e.eligibility.kind === "legacy")) {
579
+ return { kind: "legacy", ...notes };
580
+ }
581
+ if (evaluated.some((e) => selectConnection(e.connections) === null &&
582
+ e.connections.some((c) => c.control.kind === "foreign"))) {
583
+ return { kind: "key_mismatch" };
584
+ }
585
+ return { kind: "pass", ...notes };
586
+ }
587
+ /** §2.10 for one target over `connections`. */
588
+ eligibility(input, target, connections) {
589
+ return eligible({
590
+ connections: [...connections],
591
+ target: input.connection !== null
592
+ ? {
593
+ kind: "physical",
594
+ ns: input.connection,
595
+ streams: target.streams,
596
+ }
597
+ : { kind: "logical", streams: target.streams },
598
+ legacyFile: input.legacyFile,
599
+ });
600
+ }
601
+ /** The imported view of a stream while its head is live, else null. */
602
+ liveImported(connector, ns, stream, control, row) {
603
+ const imported = this.importer.servableView({ connector, ns, stream });
604
+ const kind = row ? this.importer.streamRowKind(row) : null;
605
+ return imported !== null &&
606
+ kind !== null &&
607
+ isHeadLive(control, kind, imported.head.generation)
608
+ ? imported
609
+ : null;
610
+ }
611
+ /**
612
+ * The target and connection the owner's partial view serves: every needed
613
+ * stream has a live imported head (complete or not) or local runs the
614
+ * writer will publish; `at` is the newest stamp among them. Also every run
615
+ * withheld, and the distinct runs not published yet, among all the
616
+ * connections looked at, whether or not any of them can be served.
617
+ */
618
+ pendingScan(input, targets, snapshots) {
619
+ let best = null;
620
+ const withheld = [];
621
+ const unpublished = new Set();
622
+ const awaiting = new Set();
623
+ const notReflected = new Set();
624
+ const connectors = new Set();
625
+ for (const target of targets) {
626
+ const snapshot = snapshots.get(target.connector);
627
+ if (!snapshot)
628
+ continue;
629
+ const rows = this.mirror.rowsFor(target.connector);
630
+ const namespaces = new Set([
631
+ ...rows.controls.keys(),
632
+ ...rows.streams.keys(),
633
+ ]);
634
+ for (const run of snapshot.runs)
635
+ if (run.ns !== null)
636
+ namespaces.add(run.ns);
637
+ for (const ns of [...namespaces].sort()) {
638
+ if (input.connection !== null && input.connection !== ns)
639
+ continue;
640
+ const control = this.importer.controlState(rows.controls.get(ns));
641
+ if (control.kind === "deleted" || control.kind === "foreign")
642
+ continue;
643
+ let at = 0;
644
+ const shown = [];
645
+ // Every stream is scanned, whether or not an earlier one can be
646
+ // served: a withheld or unpublished run is reported either way.
647
+ const covered = target.streams.map((stream) => {
648
+ const row = rows.streams.get(ns)?.get(stream);
649
+ const live = this.liveImported(target.connector, ns, stream, control, row);
650
+ if (live !== null) {
651
+ notReflected.add(JSON.stringify([target.connector, ns, stream]));
652
+ }
653
+ const local = this.contributions(snapshot, target.connector, ns, stream, control, row !== undefined &&
654
+ this.importer.streamRowKind(row) === "tombstoned", live, { pending: true });
655
+ if (local.withheld.length > 0 || local.unpublished.length > 0) {
656
+ connectors.add(target.connector);
657
+ }
658
+ withheld.push(...withheldRuns([{ stream, fold: local }]));
659
+ for (const c of local.merged) {
660
+ shown.push({
661
+ runId: c.run.runId,
662
+ stream,
663
+ reason: "projection_unavailable",
664
+ });
665
+ }
666
+ for (const runId of local.unpublished) {
667
+ unpublished.add(JSON.stringify([target.connector, ns, runId]));
668
+ }
669
+ for (const runId of local.awaiting) {
670
+ awaiting.add(JSON.stringify([target.connector, ns, runId]));
671
+ }
672
+ at = Math.max(at, live?.head.observedAt ?? 0, ...local.merged.map((c) => c.run.observedAt));
673
+ return live !== null || local.merged.length > 0;
674
+ });
675
+ if (!covered.every(Boolean))
676
+ continue;
677
+ if (!best ||
678
+ at > best.at ||
679
+ (at === best.at && target.connector < best.target.connector)) {
680
+ best = { target, ns, at, shown };
681
+ }
682
+ }
683
+ }
684
+ return {
685
+ best,
686
+ withheld: uniqueWithheld(withheld),
687
+ unpublished: unpublished.size,
688
+ awaiting: awaiting.size,
689
+ notReflected: notReflected.size,
690
+ connectors: [...connectors],
691
+ };
692
+ }
693
+ /** One log line per read: a count, never a row. */
694
+ logWithheld(connectors, count) {
695
+ this.options.logger.warn({ connector: connectors.join(","), withheld: count }, "stream-sync read: local runs withheld from the view");
696
+ }
697
+ async serveView(scope, target, ns, cursor, snapshot, isOwnerView, mode = "view") {
698
+ const pending = mode === "pending";
699
+ const leases = [];
700
+ // Snapshot and leases are released together, once, with the body.
701
+ let released = false;
702
+ const releaseAll = () => {
703
+ if (released)
704
+ return;
705
+ released = true;
706
+ for (const lease of leases)
707
+ lease.release();
708
+ snapshot.release();
709
+ };
710
+ try {
711
+ if (cursor && (cursor.c !== target.connector || cursor.ns !== ns)) {
712
+ releaseAll();
713
+ return { kind: "cursor_stale" };
714
+ }
715
+ const rows = this.mirror.rowsFor(target.connector);
716
+ const control = this.importer.controlState(rows.controls.get(ns));
717
+ const inputs = [];
718
+ for (const stream of target.streams) {
719
+ const key = { connector: target.connector, ns, stream };
720
+ const pin = cursor ? cursor.s[stream] : undefined;
721
+ if (cursor && !pin) {
722
+ releaseAll();
723
+ return { kind: "cursor_stale" };
724
+ }
725
+ const row = rows.streams.get(ns)?.get(stream);
726
+ const kind = row ? this.importer.streamRowKind(row) : null;
727
+ const current = this.importer.servableView(key);
728
+ const currentLive = current !== null &&
729
+ kind !== null &&
730
+ isHeadLive(control, kind, current.head.generation);
731
+ // A partial view leases the live head too, complete or not: the
732
+ // owner's rows stay readable after the run that wrote them retires.
733
+ let lease = null;
734
+ if (cursor) {
735
+ if (pin.b === null) {
736
+ // The cursor saw no imported head; one has appeared since.
737
+ if (currentLive) {
738
+ releaseAll();
739
+ return { kind: "cursor_stale" };
740
+ }
741
+ }
742
+ else {
743
+ lease = this.views.lease(key, pin.b);
744
+ if (!lease) {
745
+ releaseAll();
746
+ return { kind: "cursor_stale" };
747
+ }
748
+ }
749
+ }
750
+ else if (currentLive) {
751
+ lease = this.views.lease(key);
752
+ }
753
+ if (lease)
754
+ leases.push(lease);
755
+ // Replay the plan a cursor recorded: a retired or changed run makes
756
+ // the cursor stale, and a new run does not join. A cursor from before
757
+ // fold pins recorded the shown members alone.
758
+ const steps = cursor ? (pin.p ?? pin.m ?? []) : undefined;
759
+ const fold = this.contributions(snapshot, target.connector, ns, stream, control, kind === "tombstoned", lease?.version ?? null, { pending, ...(steps ? { steps } : {}) });
760
+ if (cursor && !replaysPin(fold, pin)) {
761
+ releaseAll();
762
+ return { kind: "cursor_stale" };
763
+ }
764
+ if (!lease && fold.merged.length === 0) {
765
+ // Not a view after all: nothing imported and nothing local.
766
+ releaseAll();
767
+ return { kind: "cursor_stale" };
768
+ }
769
+ inputs.push({ stream, lease, fold });
770
+ }
771
+ // A stream without an imported head has no registry entry: only the
772
+ // owner reads it. Everyone else gets the existing path, with its own
773
+ // billing, grants and access record.
774
+ if (pending && !isOwnerView) {
775
+ releaseAll();
776
+ return { kind: "pass" };
777
+ }
778
+ if (!isOwnerView && inputs.some((i) => !i.lease)) {
779
+ releaseAll();
780
+ return { kind: "pass" };
781
+ }
782
+ const byStream = new Map(inputs.map((i) => [i.stream, i]));
783
+ const overlays = new Map();
784
+ let observedAt = 0;
785
+ for (const input of inputs) {
786
+ const { fold } = input;
787
+ const overlay = fold.merged.length
788
+ ? await overlayWinners(snapshot, this.options.keys, {
789
+ runs: fold.merged.map((c) => c.run),
790
+ stream: input.stream,
791
+ primaryKey: fold.shape.primaryKey,
792
+ })
793
+ : NO_OVERLAY;
794
+ overlays.set(input.stream, overlay);
795
+ observedAt = Math.max(observedAt, input.lease?.version.head.observedAt ?? 0, overlay.newestObservedAt ?? 0, ...fold.merged.map((c) => c.run.observedAt));
796
+ }
797
+ const lines = (stream) => {
798
+ const input = byStream.get(stream);
799
+ return viewLines(this.views, this.options.keys, input.lease, overlays.get(stream), input.fold.shape.primaryKey);
800
+ };
801
+ const nextCursor = encodeCursor({
802
+ c: target.connector,
803
+ ns,
804
+ s: Object.fromEntries(inputs.map((i) => [
805
+ i.stream,
806
+ {
807
+ b: i.lease ? i.lease.version.version : null,
808
+ m: i.fold.merged
809
+ .map((c) => [c.run.runId, c.stream.contentRevision])
810
+ .sort(),
811
+ p: i.fold.chain.map((c) => [c.run.runId, c.stream.contentRevision]),
812
+ h: shapePin(i.fold),
813
+ },
814
+ ])),
815
+ });
816
+ // Runs the writer will not publish are never shown and never dropped
817
+ // silently: the log gets a count, the owner gets the runs.
818
+ const withheldAll = uniqueWithheld(withheldRuns(inputs));
819
+ if (withheldAll.length > 0) {
820
+ this.logWithheld([target.connector], withheldAll.length);
821
+ }
822
+ const withheld = isOwnerView ? withheldAll : [];
823
+ const complete = inputs.every((i) => i.fold.complete);
824
+ const open = `{"version":"1.0","scope":${JSON.stringify(scope)},"collectedAt":${JSON.stringify(new Date(observedAt).toISOString())},${pending ? `"origin":"local-pending","complete":${complete},` : ""}${withheld.length > 0 ? `"withheld":${JSON.stringify(withheld)},` : ""}"data":`;
825
+ let payload;
826
+ if (!target.binding) {
827
+ payload = recordsPayload(lines(target.streams[0]));
828
+ }
829
+ else {
830
+ const first = inputs[0];
831
+ const plan = await planProjection({
832
+ scope,
833
+ binding: target.binding,
834
+ // The head the writer leaves, not the base the runs built on.
835
+ profileKey: first.fold.shape?.profile.key ?? undefined,
836
+ lines,
837
+ streamBytes: (stream) => (byStream.get(stream).lease?.version.head.parts ?? []).reduce((sum, p) => sum + p.bytes, 0),
838
+ sha256: this.options.keys.hashes.sha256,
839
+ spool: this.options.files,
840
+ spoolId: `${Date.now().toString(36)}-${(this.spoolCounter++).toString(36)}`,
841
+ budgetBytes: this.options.arrayProjectionBudgetBytes ?? DEFAULT_ARRAY_BUDGET,
842
+ now: (this.options.now?.() ?? new Date()).toISOString(),
843
+ });
844
+ if (plan.kind === "too_large") {
845
+ releaseAll();
846
+ return plan;
847
+ }
848
+ payload = plan.payload;
849
+ }
850
+ const servedStream = target.binding?.window?.parentStream ?? target.streams[0];
851
+ const servedBase = byStream.get(servedStream).lease;
852
+ const body = toStream(envelope(open, payload), releaseAll);
853
+ if (pending) {
854
+ return {
855
+ kind: "local_pending",
856
+ connector: target.connector,
857
+ ns,
858
+ cursor: nextCursor,
859
+ complete,
860
+ ...(withheld.length > 0 ? { withheld } : {}),
861
+ body,
862
+ };
863
+ }
864
+ return {
865
+ kind: "view",
866
+ connector: target.connector,
867
+ ns,
868
+ cursor: nextCursor,
869
+ // A view with an input that has no registered head has no registry
870
+ // entry to bind a paid read to.
871
+ served: servedBase && inputs.every((i) => i.lease)
872
+ ? {
873
+ scope: streamScope(target.connector, ns, servedStream),
874
+ version: servedBase.version.version,
875
+ }
876
+ : null,
877
+ ...(withheld.length > 0 ? { withheld } : {}),
878
+ body,
879
+ };
880
+ }
881
+ catch (error) {
882
+ releaseAll();
883
+ throw error;
884
+ }
885
+ }
886
+ }
887
+ /** The runs the view does not show, one per run and stream. */
888
+ function withheldRuns(inputs) {
889
+ return inputs.flatMap((i) => i.fold.withheld.map((c) => ({
890
+ runId: c.run.runId,
891
+ stream: i.stream,
892
+ reason: c.reason,
893
+ })));
894
+ }
895
+ /** The projection input a cursor pins: the shown head's key, profile and completeness. */
896
+ function shapePin(fold) {
897
+ return JSON.stringify([
898
+ fold.shape?.primaryKey ?? null,
899
+ fold.shape?.profile.key ?? null,
900
+ fold.shape?.profile.version ?? null,
901
+ fold.complete,
902
+ ]);
903
+ }
904
+ function uniqueWithheld(runs) {
905
+ const seen = new Set();
906
+ return runs
907
+ .filter((w) => {
908
+ const key = `${w.runId}\0${w.stream}`;
909
+ if (seen.has(key))
910
+ return false;
911
+ seen.add(key);
912
+ return true;
913
+ })
914
+ .sort((a, b) => a.runId === b.runId
915
+ ? a.stream < b.stream
916
+ ? -1
917
+ : a.stream > b.stream
918
+ ? 1
919
+ : 0
920
+ : a.runId < b.runId
921
+ ? -1
922
+ : 1);
923
+ }
924
+ const stepKey = (c) => `${c.run.runId}\0${c.stream.contentRevision}`;
925
+ const pairKey = ([runId, revision]) => `${runId}\0${revision}`;
926
+ /**
927
+ * The replayed fold is the one the cursor recorded: the same published runs
928
+ * in the same order, the same shown members, the same head shape. Otherwise
929
+ * a replay would mix rows the first response had replaced, or project them
930
+ * under another profile.
931
+ */
932
+ function replaysPin(fold, pin) {
933
+ if (pin.d === true)
934
+ return false;
935
+ if (pin.h !== undefined && pin.h !== shapePin(fold))
936
+ return false;
937
+ const members = (pin.m ?? []).map(pairKey).sort();
938
+ const shown = fold.merged.map(stepKey).sort();
939
+ if (members.length !== shown.length ||
940
+ members.some((key, i) => key !== shown[i])) {
941
+ return false;
942
+ }
943
+ if (pin.p) {
944
+ const chain = fold.chain.map(stepKey);
945
+ if (pin.p.length !== chain.length ||
946
+ pin.p.some((pair, i) => pairKey(pair) !== chain[i])) {
947
+ return false;
948
+ }
949
+ }
950
+ return true;
951
+ }
952
+ /**
953
+ * `{records}` of a stream with no legacy binding (`pdpp.<c>.<s>`).
954
+ *
955
+ * Record order is unspecified. The file read this replaces serves records in
956
+ * the order its writer chose, and no writer uses a record field: one pages
957
+ * the records route by import time and key, another keeps arrival order.
958
+ * A stream keeps no write order, so a view serves its parts in pkHash order
959
+ * and makes no promise about it. Readers that need an order sort by a field.
960
+ */
961
+ async function* recordsPayload(lines) {
962
+ yield '{"records":[';
963
+ let first = true;
964
+ for await (const line of lines) {
965
+ yield (first ? "" : ",") + JSON.stringify(line.v);
966
+ first = false;
967
+ }
968
+ yield "]}";
969
+ }
970
+ async function* envelope(open, payload) {
971
+ yield open;
972
+ yield* payload;
973
+ yield "}";
974
+ }
975
+ //# sourceMappingURL=service.js.map