@opendatalabs/personal-server-ts-core 0.0.1-canary.052d47e → 0.0.1-canary.05cdd81

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 (1124) 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/account-storage-mode.d.ts +77 -0
  38. package/dist/api/account-storage-mode.d.ts.map +1 -0
  39. package/dist/api/account-storage-mode.js +72 -0
  40. package/dist/api/account-storage-mode.js.map +1 -0
  41. package/dist/api/index.d.ts +320 -10
  42. package/dist/api/index.d.ts.map +1 -1
  43. package/dist/api/index.js +1758 -181
  44. package/dist/api/index.js.map +1 -1
  45. package/dist/api/legacy-write-gate.d.ts +51 -0
  46. package/dist/api/legacy-write-gate.d.ts.map +1 -0
  47. package/dist/api/legacy-write-gate.js +88 -0
  48. package/dist/api/legacy-write-gate.js.map +1 -0
  49. package/dist/api/oura-collection-requirements.d.ts +16 -0
  50. package/dist/api/oura-collection-requirements.d.ts.map +1 -0
  51. package/dist/api/oura-collection-requirements.js +70 -0
  52. package/dist/api/oura-collection-requirements.js.map +1 -0
  53. package/dist/api/owner-connector-delete.d.ts +79 -0
  54. package/dist/api/owner-connector-delete.d.ts.map +1 -0
  55. package/dist/api/owner-connector-delete.js +109 -0
  56. package/dist/api/owner-connector-delete.js.map +1 -0
  57. package/dist/api/raw-envelope.d.ts +3 -0
  58. package/dist/api/raw-envelope.d.ts.map +1 -0
  59. package/dist/api/raw-envelope.js +215 -0
  60. package/dist/api/raw-envelope.js.map +1 -0
  61. package/dist/api/scope-upload-batches.d.ts +18 -0
  62. package/dist/api/scope-upload-batches.d.ts.map +1 -0
  63. package/dist/api/scope-upload-batches.js +71 -0
  64. package/dist/api/scope-upload-batches.js.map +1 -0
  65. package/dist/api/scope-uploads.d.ts +112 -0
  66. package/dist/api/scope-uploads.d.ts.map +1 -0
  67. package/dist/api/scope-uploads.js +369 -0
  68. package/dist/api/scope-uploads.js.map +1 -0
  69. package/dist/api/switched-delete-refusal.d.ts +16 -0
  70. package/dist/api/switched-delete-refusal.d.ts.map +1 -0
  71. package/dist/api/switched-delete-refusal.js +30 -0
  72. package/dist/api/switched-delete-refusal.js.map +1 -0
  73. package/dist/auth/index.d.ts +3 -1
  74. package/dist/auth/index.d.ts.map +1 -1
  75. package/dist/auth/index.js +3 -1
  76. package/dist/auth/index.js.map +1 -1
  77. package/dist/auth/proof-id.d.ts +8 -0
  78. package/dist/auth/proof-id.d.ts.map +1 -0
  79. package/dist/auth/proof-id.js +29 -0
  80. package/dist/auth/proof-id.js.map +1 -0
  81. package/dist/auth/request.d.ts +24 -0
  82. package/dist/auth/request.d.ts.map +1 -1
  83. package/dist/auth/request.js +99 -4
  84. package/dist/auth/request.js.map +1 -1
  85. package/dist/client.d.ts +78 -0
  86. package/dist/client.d.ts.map +1 -1
  87. package/dist/client.js +1 -0
  88. package/dist/client.js.map +1 -1
  89. package/dist/contracts/auth-device.d.ts +10 -0
  90. package/dist/contracts/auth-device.d.ts.map +1 -1
  91. package/dist/contracts/auth-device.js +2 -0
  92. package/dist/contracts/auth-device.js.map +1 -1
  93. package/dist/contracts/data.d.ts +102 -8
  94. package/dist/contracts/data.d.ts.map +1 -1
  95. package/dist/contracts/data.js +326 -47
  96. package/dist/contracts/data.js.map +1 -1
  97. package/dist/contracts/grants.d.ts.map +1 -1
  98. package/dist/contracts/grants.js +7 -0
  99. package/dist/contracts/grants.js.map +1 -1
  100. package/dist/contracts/index.d.ts +4 -2
  101. package/dist/contracts/index.d.ts.map +1 -1
  102. package/dist/contracts/index.js +3 -1
  103. package/dist/contracts/index.js.map +1 -1
  104. package/dist/contracts/oura-collection-requirements.d.ts +17 -0
  105. package/dist/contracts/oura-collection-requirements.d.ts.map +1 -0
  106. package/dist/contracts/oura-collection-requirements.js +49 -0
  107. package/dist/contracts/oura-collection-requirements.js.map +1 -0
  108. package/dist/contracts/sync.d.ts +9 -1
  109. package/dist/contracts/sync.d.ts.map +1 -1
  110. package/dist/contracts/sync.js +7 -2
  111. package/dist/contracts/sync.js.map +1 -1
  112. package/dist/derivatives/answer-shape.d.ts +83 -0
  113. package/dist/derivatives/answer-shape.d.ts.map +1 -0
  114. package/dist/derivatives/answer-shape.js +320 -0
  115. package/dist/derivatives/answer-shape.js.map +1 -0
  116. package/dist/derivatives/api.d.ts +1 -1
  117. package/dist/derivatives/api.d.ts.map +1 -1
  118. package/dist/derivatives/api.js +8 -0
  119. package/dist/derivatives/api.js.map +1 -1
  120. package/dist/derivatives/compute.d.ts +9 -3
  121. package/dist/derivatives/compute.d.ts.map +1 -1
  122. package/dist/derivatives/compute.js +87 -6
  123. package/dist/derivatives/compute.js.map +1 -1
  124. package/dist/derivatives/index.d.ts +2 -1
  125. package/dist/derivatives/index.d.ts.map +1 -1
  126. package/dist/derivatives/index.js +2 -1
  127. package/dist/derivatives/index.js.map +1 -1
  128. package/dist/derivatives/prompt.d.ts +35 -0
  129. package/dist/derivatives/prompt.d.ts.map +1 -1
  130. package/dist/derivatives/prompt.js +96 -8
  131. package/dist/derivatives/prompt.js.map +1 -1
  132. package/dist/derivatives/registration.d.ts +6 -9
  133. package/dist/derivatives/registration.d.ts.map +1 -1
  134. package/dist/derivatives/registration.js +14 -6
  135. package/dist/derivatives/registration.js.map +1 -1
  136. package/dist/derivatives/scheduler.d.ts +39 -9
  137. package/dist/derivatives/scheduler.d.ts.map +1 -1
  138. package/dist/derivatives/scheduler.js +99 -8
  139. package/dist/derivatives/scheduler.js.map +1 -1
  140. package/dist/derivatives/store.d.ts.map +1 -1
  141. package/dist/derivatives/store.js +2 -0
  142. package/dist/derivatives/store.js.map +1 -1
  143. package/dist/derivatives/types.d.ts +13 -3
  144. package/dist/derivatives/types.d.ts.map +1 -1
  145. package/dist/derivatives/types.js +2 -0
  146. package/dist/derivatives/types.js.map +1 -1
  147. package/dist/errors/pdpp-catalog.d.ts +36 -0
  148. package/dist/errors/pdpp-catalog.d.ts.map +1 -0
  149. package/dist/errors/pdpp-catalog.js +92 -0
  150. package/dist/errors/pdpp-catalog.js.map +1 -0
  151. package/dist/grants/index.d.ts +2 -0
  152. package/dist/grants/index.d.ts.map +1 -1
  153. package/dist/grants/index.js +4 -0
  154. package/dist/grants/index.js.map +1 -1
  155. package/dist/grants/pdpp-binding-store.d.ts +89 -0
  156. package/dist/grants/pdpp-binding-store.d.ts.map +1 -0
  157. package/dist/grants/pdpp-binding-store.js +112 -0
  158. package/dist/grants/pdpp-binding-store.js.map +1 -0
  159. package/dist/grants/pdpp-binding.d.ts +169 -0
  160. package/dist/grants/pdpp-binding.d.ts.map +1 -0
  161. package/dist/grants/pdpp-binding.js +236 -0
  162. package/dist/grants/pdpp-binding.js.map +1 -0
  163. package/dist/keys/index.d.ts +1 -0
  164. package/dist/keys/index.d.ts.map +1 -1
  165. package/dist/keys/index.js +1 -0
  166. package/dist/keys/index.js.map +1 -1
  167. package/dist/keys/owner-master-key.d.ts +37 -0
  168. package/dist/keys/owner-master-key.d.ts.map +1 -0
  169. package/dist/keys/owner-master-key.js +45 -0
  170. package/dist/keys/owner-master-key.js.map +1 -0
  171. package/dist/legacy-projection/bindings.d.ts +31 -0
  172. package/dist/legacy-projection/bindings.d.ts.map +1 -0
  173. package/dist/legacy-projection/bindings.js +4512 -0
  174. package/dist/legacy-projection/bindings.js.map +1 -0
  175. package/dist/legacy-projection/claude-source-record.d.ts +22 -0
  176. package/dist/legacy-projection/claude-source-record.d.ts.map +1 -0
  177. package/dist/legacy-projection/claude-source-record.js +360 -0
  178. package/dist/legacy-projection/claude-source-record.js.map +1 -0
  179. package/dist/legacy-projection/declared-text.d.ts +41 -0
  180. package/dist/legacy-projection/declared-text.d.ts.map +1 -0
  181. package/dist/legacy-projection/declared-text.js +199 -0
  182. package/dist/legacy-projection/declared-text.js.map +1 -0
  183. package/dist/legacy-projection/erase-connector.d.ts +18 -0
  184. package/dist/legacy-projection/erase-connector.d.ts.map +1 -0
  185. package/dist/legacy-projection/erase-connector.js +29 -0
  186. package/dist/legacy-projection/erase-connector.js.map +1 -0
  187. package/dist/legacy-projection/github-browser-bindings.d.ts +3 -0
  188. package/dist/legacy-projection/github-browser-bindings.d.ts.map +1 -0
  189. package/dist/legacy-projection/github-browser-bindings.js +212 -0
  190. package/dist/legacy-projection/github-browser-bindings.js.map +1 -0
  191. package/dist/legacy-projection/github-legacy-fields.d.ts +6 -0
  192. package/dist/legacy-projection/github-legacy-fields.d.ts.map +1 -0
  193. package/dist/legacy-projection/github-legacy-fields.js +202 -0
  194. package/dist/legacy-projection/github-legacy-fields.js.map +1 -0
  195. package/dist/legacy-projection/index.d.ts +48 -0
  196. package/dist/legacy-projection/index.d.ts.map +1 -0
  197. package/dist/legacy-projection/index.js +255 -0
  198. package/dist/legacy-projection/index.js.map +1 -0
  199. package/dist/legacy-projection/meta-040-bindings.d.ts +3 -0
  200. package/dist/legacy-projection/meta-040-bindings.d.ts.map +1 -0
  201. package/dist/legacy-projection/meta-040-bindings.js +112 -0
  202. package/dist/legacy-projection/meta-040-bindings.js.map +1 -0
  203. package/dist/legacy-projection/oura-browser-bindings.d.ts +5 -0
  204. package/dist/legacy-projection/oura-browser-bindings.d.ts.map +1 -0
  205. package/dist/legacy-projection/oura-browser-bindings.js +141 -0
  206. package/dist/legacy-projection/oura-browser-bindings.js.map +1 -0
  207. package/dist/legacy-projection/provenance.d.ts +57 -0
  208. package/dist/legacy-projection/provenance.d.ts.map +1 -0
  209. package/dist/legacy-projection/provenance.js +2 -0
  210. package/dist/legacy-projection/provenance.js.map +1 -0
  211. package/dist/legacy-projection/strava-browser-bindings.d.ts +3 -0
  212. package/dist/legacy-projection/strava-browser-bindings.d.ts.map +1 -0
  213. package/dist/legacy-projection/strava-browser-bindings.js +32 -0
  214. package/dist/legacy-projection/strava-browser-bindings.js.map +1 -0
  215. package/dist/legacy-projection/test-debris.d.ts +2 -0
  216. package/dist/legacy-projection/test-debris.d.ts.map +1 -0
  217. package/dist/legacy-projection/test-debris.js +49 -0
  218. package/dist/legacy-projection/test-debris.js.map +1 -0
  219. package/dist/legacy-projection/types.d.ts +235 -0
  220. package/dist/legacy-projection/types.d.ts.map +1 -0
  221. package/dist/legacy-projection/types.js +2 -0
  222. package/dist/legacy-projection/types.js.map +1 -0
  223. package/dist/lineage/gateway.d.ts +3 -1
  224. package/dist/lineage/gateway.d.ts.map +1 -1
  225. package/dist/lineage/gateway.js +2 -1
  226. package/dist/lineage/gateway.js.map +1 -1
  227. package/dist/localdb/apply.d.ts +13 -0
  228. package/dist/localdb/apply.d.ts.map +1 -0
  229. package/dist/localdb/apply.js +565 -0
  230. package/dist/localdb/apply.js.map +1 -0
  231. package/dist/localdb/batch-commit.d.ts +67 -0
  232. package/dist/localdb/batch-commit.d.ts.map +1 -0
  233. package/dist/localdb/batch-commit.js +121 -0
  234. package/dist/localdb/batch-commit.js.map +1 -0
  235. package/dist/localdb/blobs.d.ts +71 -0
  236. package/dist/localdb/blobs.d.ts.map +1 -0
  237. package/dist/localdb/blobs.js +306 -0
  238. package/dist/localdb/blobs.js.map +1 -0
  239. package/dist/localdb/bootstrap.d.ts +20 -0
  240. package/dist/localdb/bootstrap.d.ts.map +1 -0
  241. package/dist/localdb/bootstrap.js +157 -0
  242. package/dist/localdb/bootstrap.js.map +1 -0
  243. package/dist/localdb/connection-link.d.ts +12 -0
  244. package/dist/localdb/connection-link.d.ts.map +1 -0
  245. package/dist/localdb/connection-link.js +72 -0
  246. package/dist/localdb/connection-link.js.map +1 -0
  247. package/dist/localdb/cycle.d.ts +32 -0
  248. package/dist/localdb/cycle.d.ts.map +1 -0
  249. package/dist/localdb/cycle.js +46 -0
  250. package/dist/localdb/cycle.js.map +1 -0
  251. package/dist/localdb/delete-batch.d.ts +51 -0
  252. package/dist/localdb/delete-batch.d.ts.map +1 -0
  253. package/dist/localdb/delete-batch.js +132 -0
  254. package/dist/localdb/delete-batch.js.map +1 -0
  255. package/dist/localdb/delete.d.ts +81 -0
  256. package/dist/localdb/delete.d.ts.map +1 -0
  257. package/dist/localdb/delete.js +736 -0
  258. package/dist/localdb/delete.js.map +1 -0
  259. package/dist/localdb/deps.d.ts +54 -0
  260. package/dist/localdb/deps.d.ts.map +1 -0
  261. package/dist/localdb/deps.js +10 -0
  262. package/dist/localdb/deps.js.map +1 -0
  263. package/dist/localdb/driver.d.ts +67 -0
  264. package/dist/localdb/driver.d.ts.map +1 -0
  265. package/dist/localdb/driver.js +3 -0
  266. package/dist/localdb/driver.js.map +1 -0
  267. package/dist/localdb/encode.d.ts +217 -0
  268. package/dist/localdb/encode.d.ts.map +1 -0
  269. package/dist/localdb/encode.js +502 -0
  270. package/dist/localdb/encode.js.map +1 -0
  271. package/dist/localdb/fence.d.ts +31 -0
  272. package/dist/localdb/fence.d.ts.map +1 -0
  273. package/dist/localdb/fence.js +69 -0
  274. package/dist/localdb/fence.js.map +1 -0
  275. package/dist/localdb/history.d.ts +74 -0
  276. package/dist/localdb/history.d.ts.map +1 -0
  277. package/dist/localdb/history.js +266 -0
  278. package/dist/localdb/history.js.map +1 -0
  279. package/dist/localdb/import-fingerprint.d.ts +8 -0
  280. package/dist/localdb/import-fingerprint.d.ts.map +1 -0
  281. package/dist/localdb/import-fingerprint.js +35 -0
  282. package/dist/localdb/import-fingerprint.js.map +1 -0
  283. package/dist/localdb/import-ledger.d.ts +27 -0
  284. package/dist/localdb/import-ledger.d.ts.map +1 -0
  285. package/dist/localdb/import-ledger.js +197 -0
  286. package/dist/localdb/import-ledger.js.map +1 -0
  287. package/dist/localdb/import-readback.d.ts +8 -0
  288. package/dist/localdb/import-readback.d.ts.map +1 -0
  289. package/dist/localdb/import-readback.js +69 -0
  290. package/dist/localdb/import-readback.js.map +1 -0
  291. package/dist/localdb/import-snapshot.d.ts +21 -0
  292. package/dist/localdb/import-snapshot.d.ts.map +1 -0
  293. package/dist/localdb/import-snapshot.js +94 -0
  294. package/dist/localdb/import-snapshot.js.map +1 -0
  295. package/dist/localdb/index.d.ts +39 -0
  296. package/dist/localdb/index.d.ts.map +1 -0
  297. package/dist/localdb/index.js +36 -0
  298. package/dist/localdb/index.js.map +1 -0
  299. package/dist/localdb/legacy-import-types.d.ts +110 -0
  300. package/dist/localdb/legacy-import-types.d.ts.map +1 -0
  301. package/dist/localdb/legacy-import-types.js +2 -0
  302. package/dist/localdb/legacy-import-types.js.map +1 -0
  303. package/dist/localdb/legacy-import.d.ts +36 -0
  304. package/dist/localdb/legacy-import.d.ts.map +1 -0
  305. package/dist/localdb/legacy-import.js +288 -0
  306. package/dist/localdb/legacy-import.js.map +1 -0
  307. package/dist/localdb/legacy-retire.d.ts +26 -0
  308. package/dist/localdb/legacy-retire.d.ts.map +1 -0
  309. package/dist/localdb/legacy-retire.js +93 -0
  310. package/dist/localdb/legacy-retire.js.map +1 -0
  311. package/dist/localdb/lifetime-boundary.d.ts +49 -0
  312. package/dist/localdb/lifetime-boundary.d.ts.map +1 -0
  313. package/dist/localdb/lifetime-boundary.js +74 -0
  314. package/dist/localdb/lifetime-boundary.js.map +1 -0
  315. package/dist/localdb/listing.d.ts +51 -0
  316. package/dist/localdb/listing.d.ts.map +1 -0
  317. package/dist/localdb/listing.js +231 -0
  318. package/dist/localdb/listing.js.map +1 -0
  319. package/dist/localdb/merge.d.ts +95 -0
  320. package/dist/localdb/merge.d.ts.map +1 -0
  321. package/dist/localdb/merge.js +282 -0
  322. package/dist/localdb/merge.js.map +1 -0
  323. package/dist/localdb/migrate.d.ts +10 -0
  324. package/dist/localdb/migrate.d.ts.map +1 -0
  325. package/dist/localdb/migrate.js +27 -0
  326. package/dist/localdb/migrate.js.map +1 -0
  327. package/dist/localdb/name.d.ts +3 -0
  328. package/dist/localdb/name.d.ts.map +1 -0
  329. package/dist/localdb/name.js +8 -0
  330. package/dist/localdb/name.js.map +1 -0
  331. package/dist/localdb/older-versions.d.ts +49 -0
  332. package/dist/localdb/older-versions.d.ts.map +1 -0
  333. package/dist/localdb/older-versions.js +172 -0
  334. package/dist/localdb/older-versions.js.map +1 -0
  335. package/dist/localdb/open.d.ts +19 -0
  336. package/dist/localdb/open.d.ts.map +1 -0
  337. package/dist/localdb/open.js +46 -0
  338. package/dist/localdb/open.js.map +1 -0
  339. package/dist/localdb/part-layout.d.ts +74 -0
  340. package/dist/localdb/part-layout.d.ts.map +1 -0
  341. package/dist/localdb/part-layout.js +203 -0
  342. package/dist/localdb/part-layout.js.map +1 -0
  343. package/dist/localdb/publish-meter.d.ts +45 -0
  344. package/dist/localdb/publish-meter.d.ts.map +1 -0
  345. package/dist/localdb/publish-meter.js +62 -0
  346. package/dist/localdb/publish-meter.js.map +1 -0
  347. package/dist/localdb/publish.d.ts +47 -0
  348. package/dist/localdb/publish.d.ts.map +1 -0
  349. package/dist/localdb/publish.js +2100 -0
  350. package/dist/localdb/publish.js.map +1 -0
  351. package/dist/localdb/purge.d.ts +23 -0
  352. package/dist/localdb/purge.d.ts.map +1 -0
  353. package/dist/localdb/purge.js +75 -0
  354. package/dist/localdb/purge.js.map +1 -0
  355. package/dist/localdb/query.d.ts +69 -0
  356. package/dist/localdb/query.d.ts.map +1 -0
  357. package/dist/localdb/query.js +306 -0
  358. package/dist/localdb/query.js.map +1 -0
  359. package/dist/localdb/queue.d.ts +10 -0
  360. package/dist/localdb/queue.d.ts.map +1 -0
  361. package/dist/localdb/queue.js +31 -0
  362. package/dist/localdb/queue.js.map +1 -0
  363. package/dist/localdb/read-selection.d.ts +103 -0
  364. package/dist/localdb/read-selection.d.ts.map +1 -0
  365. package/dist/localdb/read-selection.js +141 -0
  366. package/dist/localdb/read-selection.js.map +1 -0
  367. package/dist/localdb/registry-view.d.ts +65 -0
  368. package/dist/localdb/registry-view.d.ts.map +1 -0
  369. package/dist/localdb/registry-view.js +73 -0
  370. package/dist/localdb/registry-view.js.map +1 -0
  371. package/dist/localdb/replace.d.ts +33 -0
  372. package/dist/localdb/replace.d.ts.map +1 -0
  373. package/dist/localdb/replace.js +22 -0
  374. package/dist/localdb/replace.js.map +1 -0
  375. package/dist/localdb/requirements.d.ts +35 -0
  376. package/dist/localdb/requirements.d.ts.map +1 -0
  377. package/dist/localdb/requirements.js +66 -0
  378. package/dist/localdb/requirements.js.map +1 -0
  379. package/dist/localdb/resolve.d.ts +43 -0
  380. package/dist/localdb/resolve.d.ts.map +1 -0
  381. package/dist/localdb/resolve.js +265 -0
  382. package/dist/localdb/resolve.js.map +1 -0
  383. package/dist/localdb/run-end.d.ts +19 -0
  384. package/dist/localdb/run-end.d.ts.map +1 -0
  385. package/dist/localdb/run-end.js +283 -0
  386. package/dist/localdb/run-end.js.map +1 -0
  387. package/dist/localdb/run-intake.d.ts +16 -0
  388. package/dist/localdb/run-intake.d.ts.map +1 -0
  389. package/dist/localdb/run-intake.js +441 -0
  390. package/dist/localdb/run-intake.js.map +1 -0
  391. package/dist/localdb/run-receipts.d.ts +19 -0
  392. package/dist/localdb/run-receipts.d.ts.map +1 -0
  393. package/dist/localdb/run-receipts.js +151 -0
  394. package/dist/localdb/run-receipts.js.map +1 -0
  395. package/dist/localdb/schema.d.ts +7 -0
  396. package/dist/localdb/schema.d.ts.map +1 -0
  397. package/dist/localdb/schema.js +312 -0
  398. package/dist/localdb/schema.js.map +1 -0
  399. package/dist/localdb/seed.d.ts +39 -0
  400. package/dist/localdb/seed.d.ts.map +1 -0
  401. package/dist/localdb/seed.js +188 -0
  402. package/dist/localdb/seed.js.map +1 -0
  403. package/dist/localdb/slot.d.ts +9 -0
  404. package/dist/localdb/slot.d.ts.map +1 -0
  405. package/dist/localdb/slot.js +15 -0
  406. package/dist/localdb/slot.js.map +1 -0
  407. package/dist/localdb/sync.d.ts +53 -0
  408. package/dist/localdb/sync.d.ts.map +1 -0
  409. package/dist/localdb/sync.js +211 -0
  410. package/dist/localdb/sync.js.map +1 -0
  411. package/dist/localdb/transfer-memory.d.ts +17 -0
  412. package/dist/localdb/transfer-memory.d.ts.map +1 -0
  413. package/dist/localdb/transfer-memory.js +17 -0
  414. package/dist/localdb/transfer-memory.js.map +1 -0
  415. package/dist/localdb/unwrite.d.ts +22 -0
  416. package/dist/localdb/unwrite.d.ts.map +1 -0
  417. package/dist/localdb/unwrite.js +46 -0
  418. package/dist/localdb/unwrite.js.map +1 -0
  419. package/dist/localdb/upload-wave.d.ts +34 -0
  420. package/dist/localdb/upload-wave.d.ts.map +1 -0
  421. package/dist/localdb/upload-wave.js +30 -0
  422. package/dist/localdb/upload-wave.js.map +1 -0
  423. package/dist/localdb/verified-heads.d.ts +13 -0
  424. package/dist/localdb/verified-heads.d.ts.map +1 -0
  425. package/dist/localdb/verified-heads.js +56 -0
  426. package/dist/localdb/verified-heads.js.map +1 -0
  427. package/dist/localdb/view-changes.d.ts +58 -0
  428. package/dist/localdb/view-changes.d.ts.map +1 -0
  429. package/dist/localdb/view-changes.js +174 -0
  430. package/dist/localdb/view-changes.js.map +1 -0
  431. package/dist/mcp/approval-url.d.ts +100 -0
  432. package/dist/mcp/approval-url.d.ts.map +1 -0
  433. package/dist/mcp/approval-url.js +171 -0
  434. package/dist/mcp/approval-url.js.map +1 -0
  435. package/dist/mcp/connection-api.d.ts +239 -3
  436. package/dist/mcp/connection-api.d.ts.map +1 -1
  437. package/dist/mcp/connection-api.js +792 -27
  438. package/dist/mcp/connection-api.js.map +1 -1
  439. package/dist/mcp/grant-registration.d.ts +15 -0
  440. package/dist/mcp/grant-registration.d.ts.map +1 -0
  441. package/dist/mcp/grant-registration.js +44 -0
  442. package/dist/mcp/grant-registration.js.map +1 -0
  443. package/dist/mcp/grantee.d.ts +1 -1
  444. package/dist/mcp/grantee.d.ts.map +1 -1
  445. package/dist/mcp/index.d.ts +5 -0
  446. package/dist/mcp/index.d.ts.map +1 -1
  447. package/dist/mcp/index.js +5 -0
  448. package/dist/mcp/index.js.map +1 -1
  449. package/dist/mcp/oauth-redirect.d.ts +14 -0
  450. package/dist/mcp/oauth-redirect.d.ts.map +1 -0
  451. package/dist/mcp/oauth-redirect.js +51 -0
  452. package/dist/mcp/oauth-redirect.js.map +1 -0
  453. package/dist/mcp/read-client.d.ts +27 -3
  454. package/dist/mcp/read-client.d.ts.map +1 -1
  455. package/dist/mcp/read-client.js +325 -19
  456. package/dist/mcp/read-client.js.map +1 -1
  457. package/dist/mcp/resources.d.ts +3 -1
  458. package/dist/mcp/resources.d.ts.map +1 -1
  459. package/dist/mcp/resources.js +14 -2
  460. package/dist/mcp/resources.js.map +1 -1
  461. package/dist/mcp/server.d.ts +47 -0
  462. package/dist/mcp/server.d.ts.map +1 -1
  463. package/dist/mcp/server.js +219 -17
  464. package/dist/mcp/server.js.map +1 -1
  465. package/dist/mcp/session.d.ts +3 -1
  466. package/dist/mcp/session.d.ts.map +1 -1
  467. package/dist/mcp/session.js +58 -11
  468. package/dist/mcp/session.js.map +1 -1
  469. package/dist/mcp/store.d.ts +23 -1
  470. package/dist/mcp/store.d.ts.map +1 -1
  471. package/dist/mcp/store.js +102 -1
  472. package/dist/mcp/store.js.map +1 -1
  473. package/dist/mcp/token-expiry.d.ts +48 -0
  474. package/dist/mcp/token-expiry.d.ts.map +1 -0
  475. package/dist/mcp/token-expiry.js +69 -0
  476. package/dist/mcp/token-expiry.js.map +1 -0
  477. package/dist/mcp/tools.d.ts +154 -3
  478. package/dist/mcp/tools.d.ts.map +1 -1
  479. package/dist/mcp/tools.js +660 -39
  480. package/dist/mcp/tools.js.map +1 -1
  481. package/dist/mcp/types.d.ts +105 -4
  482. package/dist/mcp/types.d.ts.map +1 -1
  483. package/dist/mcp/types.js +13 -1
  484. package/dist/mcp/types.js.map +1 -1
  485. package/dist/mcp/write-client.d.ts +81 -0
  486. package/dist/mcp/write-client.d.ts.map +1 -0
  487. package/dist/mcp/write-client.js +140 -0
  488. package/dist/mcp/write-client.js.map +1 -0
  489. package/dist/oura/history-policy.d.ts +12 -0
  490. package/dist/oura/history-policy.d.ts.map +1 -0
  491. package/dist/oura/history-policy.js +54 -0
  492. package/dist/oura/history-policy.js.map +1 -0
  493. package/dist/oura/index.d.ts +51 -0
  494. package/dist/oura/index.d.ts.map +1 -0
  495. package/dist/oura/index.js +330 -0
  496. package/dist/oura/index.js.map +1 -0
  497. package/dist/payment/own-app.d.ts +8 -0
  498. package/dist/payment/own-app.d.ts.map +1 -0
  499. package/dist/payment/own-app.js +47 -0
  500. package/dist/payment/own-app.js.map +1 -0
  501. package/dist/pdpp/approval.d.ts +271 -0
  502. package/dist/pdpp/approval.d.ts.map +1 -0
  503. package/dist/pdpp/approval.js +486 -0
  504. package/dist/pdpp/approval.js.map +1 -0
  505. package/dist/pdpp/client-identity.d.ts +88 -0
  506. package/dist/pdpp/client-identity.d.ts.map +1 -0
  507. package/dist/pdpp/client-identity.js +196 -0
  508. package/dist/pdpp/client-identity.js.map +1 -0
  509. package/dist/pdpp/client-metadata.d.ts +95 -0
  510. package/dist/pdpp/client-metadata.d.ts.map +1 -0
  511. package/dist/pdpp/client-metadata.js +96 -0
  512. package/dist/pdpp/client-metadata.js.map +1 -0
  513. package/dist/pdpp/commitments.d.ts +75 -0
  514. package/dist/pdpp/commitments.d.ts.map +1 -0
  515. package/dist/pdpp/commitments.js +113 -0
  516. package/dist/pdpp/commitments.js.map +1 -0
  517. package/dist/pdpp/declaration-limits.d.ts +7 -0
  518. package/dist/pdpp/declaration-limits.d.ts.map +1 -0
  519. package/dist/pdpp/declaration-limits.js +7 -0
  520. package/dist/pdpp/declaration-limits.js.map +1 -0
  521. package/dist/pdpp/declaration.d.ts +119 -0
  522. package/dist/pdpp/declaration.d.ts.map +1 -0
  523. package/dist/pdpp/declaration.js +837 -0
  524. package/dist/pdpp/declaration.js.map +1 -0
  525. package/dist/pdpp/index.d.ts +38 -0
  526. package/dist/pdpp/index.d.ts.map +1 -0
  527. package/dist/pdpp/index.js +24 -0
  528. package/dist/pdpp/index.js.map +1 -0
  529. package/dist/pdpp/issuance.d.ts +126 -0
  530. package/dist/pdpp/issuance.d.ts.map +1 -0
  531. package/dist/pdpp/issuance.js +184 -0
  532. package/dist/pdpp/issuance.js.map +1 -0
  533. package/dist/pdpp/pkce.d.ts +53 -0
  534. package/dist/pdpp/pkce.d.ts.map +1 -0
  535. package/dist/pdpp/pkce.js +109 -0
  536. package/dist/pdpp/pkce.js.map +1 -0
  537. package/dist/pdpp/redirect.d.ts +60 -0
  538. package/dist/pdpp/redirect.d.ts.map +1 -0
  539. package/dist/pdpp/redirect.js +125 -0
  540. package/dist/pdpp/redirect.js.map +1 -0
  541. package/dist/pdpp/resolve.d.ts +120 -0
  542. package/dist/pdpp/resolve.d.ts.map +1 -0
  543. package/dist/pdpp/resolve.js +491 -0
  544. package/dist/pdpp/resolve.js.map +1 -0
  545. package/dist/pdpp/review.d.ts +280 -0
  546. package/dist/pdpp/review.d.ts.map +1 -0
  547. package/dist/pdpp/review.js +205 -0
  548. package/dist/pdpp/review.js.map +1 -0
  549. package/dist/pdpp/selection.d.ts +79 -0
  550. package/dist/pdpp/selection.d.ts.map +1 -0
  551. package/dist/pdpp/selection.js +493 -0
  552. package/dist/pdpp/selection.js.map +1 -0
  553. package/dist/pdpp/store.d.ts +228 -0
  554. package/dist/pdpp/store.d.ts.map +1 -0
  555. package/dist/pdpp/store.js +542 -0
  556. package/dist/pdpp/store.js.map +1 -0
  557. package/dist/pdpp/time.d.ts +39 -0
  558. package/dist/pdpp/time.d.ts.map +1 -0
  559. package/dist/pdpp/time.js +173 -0
  560. package/dist/pdpp/time.js.map +1 -0
  561. package/dist/pdpp/tokens.d.ts +181 -0
  562. package/dist/pdpp/tokens.d.ts.map +1 -0
  563. package/dist/pdpp/tokens.js +421 -0
  564. package/dist/pdpp/tokens.js.map +1 -0
  565. package/dist/pdpp/types.d.ts +457 -0
  566. package/dist/pdpp/types.d.ts.map +1 -0
  567. package/dist/pdpp/types.js +68 -0
  568. package/dist/pdpp/types.js.map +1 -0
  569. package/dist/pdpp-version.d.ts +28 -0
  570. package/dist/pdpp-version.d.ts.map +1 -0
  571. package/dist/pdpp-version.js +28 -0
  572. package/dist/pdpp-version.js.map +1 -0
  573. package/dist/policy/data-read.d.ts +52 -1
  574. package/dist/policy/data-read.d.ts.map +1 -1
  575. package/dist/policy/data-read.js +157 -3
  576. package/dist/policy/data-read.js.map +1 -1
  577. package/dist/policy/data-write.d.ts.map +1 -1
  578. package/dist/policy/data-write.js +18 -1
  579. package/dist/policy/data-write.js.map +1 -1
  580. package/dist/policy/index.d.ts +2 -1
  581. package/dist/policy/index.d.ts.map +1 -1
  582. package/dist/policy/index.js +2 -1
  583. package/dist/policy/index.js.map +1 -1
  584. package/dist/policy/reserved-scopes.d.ts +10 -0
  585. package/dist/policy/reserved-scopes.d.ts.map +1 -0
  586. package/dist/policy/reserved-scopes.js +19 -0
  587. package/dist/policy/reserved-scopes.js.map +1 -0
  588. package/dist/ports/index.d.ts +323 -10
  589. package/dist/ports/index.d.ts.map +1 -1
  590. package/dist/ports/index.js.map +1 -1
  591. package/dist/ports/pdpp-auth.d.ts +119 -0
  592. package/dist/ports/pdpp-auth.d.ts.map +1 -0
  593. package/dist/ports/pdpp-auth.js +46 -0
  594. package/dist/ports/pdpp-auth.js.map +1 -0
  595. package/dist/ports/pdpp-auth.test-utils.d.ts +9 -0
  596. package/dist/ports/pdpp-auth.test-utils.d.ts.map +1 -0
  597. package/dist/ports/pdpp-auth.test-utils.js +18 -0
  598. package/dist/ports/pdpp-auth.test-utils.js.map +1 -0
  599. package/dist/publication/publish.d.ts +137 -0
  600. package/dist/publication/publish.d.ts.map +1 -0
  601. package/dist/publication/publish.js +278 -0
  602. package/dist/publication/publish.js.map +1 -0
  603. package/dist/replication/completion.d.ts +20 -0
  604. package/dist/replication/completion.d.ts.map +1 -0
  605. package/dist/replication/completion.js +73 -0
  606. package/dist/replication/completion.js.map +1 -0
  607. package/dist/replication/coordinator-state.d.ts +29 -0
  608. package/dist/replication/coordinator-state.d.ts.map +1 -0
  609. package/dist/replication/coordinator-state.js +88 -0
  610. package/dist/replication/coordinator-state.js.map +1 -0
  611. package/dist/replication/coordinator-state.test-utils.d.ts +32 -0
  612. package/dist/replication/coordinator-state.test-utils.d.ts.map +1 -0
  613. package/dist/replication/coordinator-state.test-utils.js +113 -0
  614. package/dist/replication/coordinator-state.test-utils.js.map +1 -0
  615. package/dist/replication/coordinator.d.ts +264 -0
  616. package/dist/replication/coordinator.d.ts.map +1 -0
  617. package/dist/replication/coordinator.js +499 -0
  618. package/dist/replication/coordinator.js.map +1 -0
  619. package/dist/replication/copies.d.ts +126 -0
  620. package/dist/replication/copies.d.ts.map +1 -0
  621. package/dist/replication/copies.js +437 -0
  622. package/dist/replication/copies.js.map +1 -0
  623. package/dist/replication/copy-promotion.d.ts +132 -0
  624. package/dist/replication/copy-promotion.d.ts.map +1 -0
  625. package/dist/replication/copy-promotion.js +126 -0
  626. package/dist/replication/copy-promotion.js.map +1 -0
  627. package/dist/replication/door.d.ts +33 -0
  628. package/dist/replication/door.d.ts.map +1 -0
  629. package/dist/replication/door.js +10 -0
  630. package/dist/replication/door.js.map +1 -0
  631. package/dist/replication/dpv2.d.ts +141 -0
  632. package/dist/replication/dpv2.d.ts.map +1 -0
  633. package/dist/replication/dpv2.js +320 -0
  634. package/dist/replication/dpv2.js.map +1 -0
  635. package/dist/replication/effects.d.ts +68 -0
  636. package/dist/replication/effects.d.ts.map +1 -0
  637. package/dist/replication/effects.js +89 -0
  638. package/dist/replication/effects.js.map +1 -0
  639. package/dist/replication/engine.d.ts +378 -0
  640. package/dist/replication/engine.d.ts.map +1 -0
  641. package/dist/replication/engine.js +3197 -0
  642. package/dist/replication/engine.js.map +1 -0
  643. package/dist/replication/envelope.d.ts +481 -0
  644. package/dist/replication/envelope.d.ts.map +1 -0
  645. package/dist/replication/envelope.js +192 -0
  646. package/dist/replication/envelope.js.map +1 -0
  647. package/dist/replication/evidence.d.ts +118 -0
  648. package/dist/replication/evidence.d.ts.map +1 -0
  649. package/dist/replication/evidence.js +198 -0
  650. package/dist/replication/evidence.js.map +1 -0
  651. package/dist/replication/finality.d.ts +16 -0
  652. package/dist/replication/finality.d.ts.map +1 -0
  653. package/dist/replication/finality.js +11 -0
  654. package/dist/replication/finality.js.map +1 -0
  655. package/dist/replication/fixtures.d.ts +16 -0
  656. package/dist/replication/fixtures.d.ts.map +1 -0
  657. package/dist/replication/fixtures.js +47 -0
  658. package/dist/replication/fixtures.js.map +1 -0
  659. package/dist/replication/host-config.d.ts +52 -0
  660. package/dist/replication/host-config.d.ts.map +1 -0
  661. package/dist/replication/host-config.js +111 -0
  662. package/dist/replication/host-config.js.map +1 -0
  663. package/dist/replication/host-driver.d.ts +95 -0
  664. package/dist/replication/host-driver.d.ts.map +1 -0
  665. package/dist/replication/host-driver.js +202 -0
  666. package/dist/replication/host-driver.js.map +1 -0
  667. package/dist/replication/host-ports.d.ts +48 -0
  668. package/dist/replication/host-ports.d.ts.map +1 -0
  669. package/dist/replication/host-ports.js +69 -0
  670. package/dist/replication/host-ports.js.map +1 -0
  671. package/dist/replication/identity.d.ts +13 -0
  672. package/dist/replication/identity.d.ts.map +1 -0
  673. package/dist/replication/identity.js +22 -0
  674. package/dist/replication/identity.js.map +1 -0
  675. package/dist/replication/limits.d.ts +124 -0
  676. package/dist/replication/limits.d.ts.map +1 -0
  677. package/dist/replication/limits.js +182 -0
  678. package/dist/replication/limits.js.map +1 -0
  679. package/dist/replication/merge-plan.d.ts +92 -0
  680. package/dist/replication/merge-plan.d.ts.map +1 -0
  681. package/dist/replication/merge-plan.js +229 -0
  682. package/dist/replication/merge-plan.js.map +1 -0
  683. package/dist/replication/namespace.d.ts +4 -0
  684. package/dist/replication/namespace.d.ts.map +1 -0
  685. package/dist/replication/namespace.js +7 -0
  686. package/dist/replication/namespace.js.map +1 -0
  687. package/dist/replication/outcome.d.ts +178 -0
  688. package/dist/replication/outcome.d.ts.map +1 -0
  689. package/dist/replication/outcome.js +83 -0
  690. package/dist/replication/outcome.js.map +1 -0
  691. package/dist/replication/payload.d.ts +39 -0
  692. package/dist/replication/payload.d.ts.map +1 -0
  693. package/dist/replication/payload.js +137 -0
  694. package/dist/replication/payload.js.map +1 -0
  695. package/dist/replication/preparation.d.ts +42 -0
  696. package/dist/replication/preparation.d.ts.map +1 -0
  697. package/dist/replication/preparation.js +118 -0
  698. package/dist/replication/preparation.js.map +1 -0
  699. package/dist/replication/rebaseline.d.ts +33 -0
  700. package/dist/replication/rebaseline.d.ts.map +1 -0
  701. package/dist/replication/rebaseline.js +40 -0
  702. package/dist/replication/rebaseline.js.map +1 -0
  703. package/dist/replication/rebinding.d.ts +43 -0
  704. package/dist/replication/rebinding.d.ts.map +1 -0
  705. package/dist/replication/rebinding.js +52 -0
  706. package/dist/replication/rebinding.js.map +1 -0
  707. package/dist/replication/receive.d.ts +57 -0
  708. package/dist/replication/receive.d.ts.map +1 -0
  709. package/dist/replication/receive.js +114 -0
  710. package/dist/replication/receive.js.map +1 -0
  711. package/dist/replication/record-reducer.d.ts +16 -0
  712. package/dist/replication/record-reducer.d.ts.map +1 -0
  713. package/dist/replication/record-reducer.js +52 -0
  714. package/dist/replication/record-reducer.js.map +1 -0
  715. package/dist/replication/revision.d.ts +24 -0
  716. package/dist/replication/revision.d.ts.map +1 -0
  717. package/dist/replication/revision.js +35 -0
  718. package/dist/replication/revision.js.map +1 -0
  719. package/dist/replication/roster.d.ts +53 -0
  720. package/dist/replication/roster.d.ts.map +1 -0
  721. package/dist/replication/roster.js +115 -0
  722. package/dist/replication/roster.js.map +1 -0
  723. package/dist/replication/schedule.d.ts +73 -0
  724. package/dist/replication/schedule.d.ts.map +1 -0
  725. package/dist/replication/schedule.js +182 -0
  726. package/dist/replication/schedule.js.map +1 -0
  727. package/dist/replication/stream.d.ts +73 -0
  728. package/dist/replication/stream.d.ts.map +1 -0
  729. package/dist/replication/stream.js +542 -0
  730. package/dist/replication/stream.js.map +1 -0
  731. package/dist/replication/transport.d.ts +236 -0
  732. package/dist/replication/transport.d.ts.map +1 -0
  733. package/dist/replication/transport.js +440 -0
  734. package/dist/replication/transport.js.map +1 -0
  735. package/dist/replication/visibility-engine.d.ts +337 -0
  736. package/dist/replication/visibility-engine.d.ts.map +1 -0
  737. package/dist/replication/visibility-engine.js +602 -0
  738. package/dist/replication/visibility-engine.js.map +1 -0
  739. package/dist/replication/visibility-policy.d.ts +26 -0
  740. package/dist/replication/visibility-policy.d.ts.map +1 -0
  741. package/dist/replication/visibility-policy.js +33 -0
  742. package/dist/replication/visibility-policy.js.map +1 -0
  743. package/dist/replication/writer-identity-store.d.ts +100 -0
  744. package/dist/replication/writer-identity-store.d.ts.map +1 -0
  745. package/dist/replication/writer-identity-store.js +218 -0
  746. package/dist/replication/writer-identity-store.js.map +1 -0
  747. package/dist/replication/writer-identity.d.ts +252 -0
  748. package/dist/replication/writer-identity.d.ts.map +1 -0
  749. package/dist/replication/writer-identity.js +281 -0
  750. package/dist/replication/writer-identity.js.map +1 -0
  751. package/dist/replication/writer-identity.test-utils.d.ts +24 -0
  752. package/dist/replication/writer-identity.test-utils.d.ts.map +1 -0
  753. package/dist/replication/writer-identity.test-utils.js +86 -0
  754. package/dist/replication/writer-identity.test-utils.js.map +1 -0
  755. package/dist/schemas/server-config.d.ts +81 -0
  756. package/dist/schemas/server-config.d.ts.map +1 -1
  757. package/dist/schemas/server-config.js +179 -0
  758. package/dist/schemas/server-config.js.map +1 -1
  759. package/dist/signing/request-signer.d.ts +2 -0
  760. package/dist/signing/request-signer.d.ts.map +1 -1
  761. package/dist/signing/request-signer.js +1 -0
  762. package/dist/signing/request-signer.js.map +1 -1
  763. package/dist/storage/adapters/index.d.ts +3 -1
  764. package/dist/storage/adapters/index.d.ts.map +1 -1
  765. package/dist/storage/adapters/index.js +2 -0
  766. package/dist/storage/adapters/index.js.map +1 -1
  767. package/dist/storage/adapters/interface.d.ts +33 -3
  768. package/dist/storage/adapters/interface.d.ts.map +1 -1
  769. package/dist/storage/adapters/interface.js +13 -1
  770. package/dist/storage/adapters/interface.js.map +1 -1
  771. package/dist/storage/adapters/rate-limit-policy.d.ts +66 -0
  772. package/dist/storage/adapters/rate-limit-policy.d.ts.map +1 -0
  773. package/dist/storage/adapters/rate-limit-policy.js +103 -0
  774. package/dist/storage/adapters/rate-limit-policy.js.map +1 -0
  775. package/dist/storage/adapters/sdk.d.ts +9 -1
  776. package/dist/storage/adapters/sdk.d.ts.map +1 -1
  777. package/dist/storage/adapters/sdk.js +32 -8
  778. package/dist/storage/adapters/sdk.js.map +1 -1
  779. package/dist/storage/adapters/throttle.d.ts +30 -0
  780. package/dist/storage/adapters/throttle.d.ts.map +1 -0
  781. package/dist/storage/adapters/throttle.js +94 -0
  782. package/dist/storage/adapters/throttle.js.map +1 -0
  783. package/dist/storage/adapters/vana-audience.d.ts +27 -0
  784. package/dist/storage/adapters/vana-audience.d.ts.map +1 -0
  785. package/dist/storage/adapters/vana-audience.js +99 -0
  786. package/dist/storage/adapters/vana-audience.js.map +1 -0
  787. package/dist/storage/adapters/vana.d.ts +5 -3
  788. package/dist/storage/adapters/vana.d.ts.map +1 -1
  789. package/dist/storage/adapters/vana.js +128 -18
  790. package/dist/storage/adapters/vana.js.map +1 -1
  791. package/dist/storage/blocks/cursor.d.ts +5 -1
  792. package/dist/storage/blocks/cursor.d.ts.map +1 -1
  793. package/dist/storage/blocks/cursor.js +13 -1
  794. package/dist/storage/blocks/cursor.js.map +1 -1
  795. package/dist/storage/blocks/page.d.ts +18 -0
  796. package/dist/storage/blocks/page.d.ts.map +1 -0
  797. package/dist/storage/blocks/page.js +113 -0
  798. package/dist/storage/blocks/page.js.map +1 -0
  799. package/dist/storage/canonical-legacy-projection.d.ts +262 -0
  800. package/dist/storage/canonical-legacy-projection.d.ts.map +1 -0
  801. package/dist/storage/canonical-legacy-projection.js +759 -0
  802. package/dist/storage/canonical-legacy-projection.js.map +1 -0
  803. package/dist/storage/hierarchy/paths.d.ts.map +1 -1
  804. package/dist/storage/hierarchy/paths.js +9 -2
  805. package/dist/storage/hierarchy/paths.js.map +1 -1
  806. package/dist/storage/index/manager.d.ts +46 -5
  807. package/dist/storage/index/manager.d.ts.map +1 -1
  808. package/dist/storage/index/schema.d.ts +1 -1
  809. package/dist/storage/index/schema.js +1 -1
  810. package/dist/storage/index/types.d.ts +7 -1
  811. package/dist/storage/index/types.d.ts.map +1 -1
  812. package/dist/storage/legacy-projection.d.ts +88 -0
  813. package/dist/storage/legacy-projection.d.ts.map +1 -0
  814. package/dist/storage/legacy-projection.js +755 -0
  815. package/dist/storage/legacy-projection.js.map +1 -0
  816. package/dist/storage/legacy-scope-coverage-exceptions.d.ts +13 -0
  817. package/dist/storage/legacy-scope-coverage-exceptions.d.ts.map +1 -0
  818. package/dist/storage/legacy-scope-coverage-exceptions.js +14 -0
  819. package/dist/storage/legacy-scope-coverage-exceptions.js.map +1 -0
  820. package/dist/storage/legacy-scope-coverage.d.ts +53 -0
  821. package/dist/storage/legacy-scope-coverage.d.ts.map +1 -0
  822. package/dist/storage/legacy-scope-coverage.js +416 -0
  823. package/dist/storage/legacy-scope-coverage.js.map +1 -0
  824. package/dist/storage/legacy-scope-entity-keys.d.ts +17 -0
  825. package/dist/storage/legacy-scope-entity-keys.d.ts.map +1 -0
  826. package/dist/storage/legacy-scope-entity-keys.js +109 -0
  827. package/dist/storage/legacy-scope-entity-keys.js.map +1 -0
  828. package/dist/storage/legacy-scope-view.d.ts +201 -0
  829. package/dist/storage/legacy-scope-view.d.ts.map +1 -0
  830. package/dist/storage/legacy-scope-view.js +1044 -0
  831. package/dist/storage/legacy-scope-view.js.map +1 -0
  832. package/dist/storage/legacy-write-seal.d.ts +73 -0
  833. package/dist/storage/legacy-write-seal.d.ts.map +1 -0
  834. package/dist/storage/legacy-write-seal.js +71 -0
  835. package/dist/storage/legacy-write-seal.js.map +1 -0
  836. package/dist/storage/pdpp-records/completion.d.ts +91 -0
  837. package/dist/storage/pdpp-records/completion.d.ts.map +1 -0
  838. package/dist/storage/pdpp-records/completion.js +170 -0
  839. package/dist/storage/pdpp-records/completion.js.map +1 -0
  840. package/dist/storage/pdpp-records/cursor.d.ts +86 -0
  841. package/dist/storage/pdpp-records/cursor.d.ts.map +1 -0
  842. package/dist/storage/pdpp-records/cursor.js +56 -0
  843. package/dist/storage/pdpp-records/cursor.js.map +1 -0
  844. package/dist/storage/pdpp-records/declaration-witness.d.ts +58 -0
  845. package/dist/storage/pdpp-records/declaration-witness.d.ts.map +1 -0
  846. package/dist/storage/pdpp-records/declaration-witness.js +230 -0
  847. package/dist/storage/pdpp-records/declaration-witness.js.map +1 -0
  848. package/dist/storage/pdpp-records/enforcement.d.ts +39 -0
  849. package/dist/storage/pdpp-records/enforcement.d.ts.map +1 -0
  850. package/dist/storage/pdpp-records/enforcement.js +143 -0
  851. package/dist/storage/pdpp-records/enforcement.js.map +1 -0
  852. package/dist/storage/pdpp-records/index.d.ts +7 -0
  853. package/dist/storage/pdpp-records/index.d.ts.map +1 -0
  854. package/dist/storage/pdpp-records/index.js +6 -0
  855. package/dist/storage/pdpp-records/index.js.map +1 -0
  856. package/dist/storage/pdpp-records/ingest-plan.d.ts +39 -0
  857. package/dist/storage/pdpp-records/ingest-plan.d.ts.map +1 -0
  858. package/dist/storage/pdpp-records/ingest-plan.js +103 -0
  859. package/dist/storage/pdpp-records/ingest-plan.js.map +1 -0
  860. package/dist/storage/pdpp-records/interface.d.ts +111 -0
  861. package/dist/storage/pdpp-records/interface.d.ts.map +1 -0
  862. package/dist/storage/pdpp-records/interface.js +2 -0
  863. package/dist/storage/pdpp-records/interface.js.map +1 -0
  864. package/dist/storage/pdpp-records/list-page.d.ts +35 -0
  865. package/dist/storage/pdpp-records/list-page.d.ts.map +1 -0
  866. package/dist/storage/pdpp-records/list-page.js +106 -0
  867. package/dist/storage/pdpp-records/list-page.js.map +1 -0
  868. package/dist/storage/pdpp-records/memory-store.d.ts +9 -0
  869. package/dist/storage/pdpp-records/memory-store.d.ts.map +1 -0
  870. package/dist/storage/pdpp-records/memory-store.js +462 -0
  871. package/dist/storage/pdpp-records/memory-store.js.map +1 -0
  872. package/dist/storage/pdpp-records/portable.d.ts +12 -0
  873. package/dist/storage/pdpp-records/portable.d.ts.map +1 -0
  874. package/dist/storage/pdpp-records/portable.js +11 -0
  875. package/dist/storage/pdpp-records/portable.js.map +1 -0
  876. package/dist/storage/pdpp-records/read-port.d.ts +44 -0
  877. package/dist/storage/pdpp-records/read-port.d.ts.map +1 -0
  878. package/dist/storage/pdpp-records/read-port.js +22 -0
  879. package/dist/storage/pdpp-records/read-port.js.map +1 -0
  880. package/dist/storage/pdpp-records/record-key.d.ts +52 -0
  881. package/dist/storage/pdpp-records/record-key.d.ts.map +1 -0
  882. package/dist/storage/pdpp-records/record-key.js +97 -0
  883. package/dist/storage/pdpp-records/record-key.js.map +1 -0
  884. package/dist/storage/pdpp-records/replication-journal.d.ts +20 -0
  885. package/dist/storage/pdpp-records/replication-journal.d.ts.map +1 -0
  886. package/dist/storage/pdpp-records/replication-journal.js +2 -0
  887. package/dist/storage/pdpp-records/replication-journal.js.map +1 -0
  888. package/dist/storage/pdpp-records/schema.d.ts +41 -0
  889. package/dist/storage/pdpp-records/schema.d.ts.map +1 -0
  890. package/dist/storage/pdpp-records/schema.js +153 -0
  891. package/dist/storage/pdpp-records/schema.js.map +1 -0
  892. package/dist/storage/pdpp-records/stream-declaration.d.ts +86 -0
  893. package/dist/storage/pdpp-records/stream-declaration.d.ts.map +1 -0
  894. package/dist/storage/pdpp-records/stream-declaration.js +48 -0
  895. package/dist/storage/pdpp-records/stream-declaration.js.map +1 -0
  896. package/dist/storage/pdpp-records/sync-selection.d.ts +4 -0
  897. package/dist/storage/pdpp-records/sync-selection.d.ts.map +1 -0
  898. package/dist/storage/pdpp-records/sync-selection.js +37 -0
  899. package/dist/storage/pdpp-records/sync-selection.js.map +1 -0
  900. package/dist/storage/pdpp-records/types.d.ts +204 -0
  901. package/dist/storage/pdpp-records/types.d.ts.map +1 -0
  902. package/dist/storage/pdpp-records/types.js +38 -0
  903. package/dist/storage/pdpp-records/types.js.map +1 -0
  904. package/dist/stream-sync/artifacts.d.ts +38 -0
  905. package/dist/stream-sync/artifacts.d.ts.map +1 -0
  906. package/dist/stream-sync/artifacts.js +141 -0
  907. package/dist/stream-sync/artifacts.js.map +1 -0
  908. package/dist/stream-sync/blobs.d.ts +18 -0
  909. package/dist/stream-sync/blobs.d.ts.map +1 -0
  910. package/dist/stream-sync/blobs.js +83 -0
  911. package/dist/stream-sync/blobs.js.map +1 -0
  912. package/dist/stream-sync/crypto-port.d.ts +20 -0
  913. package/dist/stream-sync/crypto-port.d.ts.map +1 -0
  914. package/dist/stream-sync/crypto-port.js +19 -0
  915. package/dist/stream-sync/crypto-port.js.map +1 -0
  916. package/dist/stream-sync/crypto.d.ts +27 -0
  917. package/dist/stream-sync/crypto.d.ts.map +1 -0
  918. package/dist/stream-sync/crypto.js +67 -0
  919. package/dist/stream-sync/crypto.js.map +1 -0
  920. package/dist/stream-sync/delete-metadata.d.ts +23 -0
  921. package/dist/stream-sync/delete-metadata.d.ts.map +1 -0
  922. package/dist/stream-sync/delete-metadata.js +40 -0
  923. package/dist/stream-sync/delete-metadata.js.map +1 -0
  924. package/dist/stream-sync/index.d.ts +13 -0
  925. package/dist/stream-sync/index.d.ts.map +1 -0
  926. package/dist/stream-sync/index.js +13 -0
  927. package/dist/stream-sync/index.js.map +1 -0
  928. package/dist/stream-sync/intake.d.ts +185 -0
  929. package/dist/stream-sync/intake.d.ts.map +1 -0
  930. package/dist/stream-sync/intake.js +36 -0
  931. package/dist/stream-sync/intake.js.map +1 -0
  932. package/dist/stream-sync/memory-registry.d.ts +58 -0
  933. package/dist/stream-sync/memory-registry.d.ts.map +1 -0
  934. package/dist/stream-sync/memory-registry.js +119 -0
  935. package/dist/stream-sync/memory-registry.js.map +1 -0
  936. package/dist/stream-sync/ports.d.ts +363 -0
  937. package/dist/stream-sync/ports.d.ts.map +1 -0
  938. package/dist/stream-sync/ports.js +68 -0
  939. package/dist/stream-sync/ports.js.map +1 -0
  940. package/dist/stream-sync/publish-plan.d.ts +157 -0
  941. package/dist/stream-sync/publish-plan.d.ts.map +1 -0
  942. package/dist/stream-sync/publish-plan.js +217 -0
  943. package/dist/stream-sync/publish-plan.js.map +1 -0
  944. package/dist/stream-sync/registry.d.ts +24 -0
  945. package/dist/stream-sync/registry.d.ts.map +1 -0
  946. package/dist/stream-sync/registry.js +389 -0
  947. package/dist/stream-sync/registry.js.map +1 -0
  948. package/dist/stream-sync/scope-routing.d.ts +17 -0
  949. package/dist/stream-sync/scope-routing.d.ts.map +1 -0
  950. package/dist/stream-sync/scope-routing.js +24 -0
  951. package/dist/stream-sync/scope-routing.js.map +1 -0
  952. package/dist/stream-sync/seed-staging.d.ts +85 -0
  953. package/dist/stream-sync/seed-staging.d.ts.map +1 -0
  954. package/dist/stream-sync/seed-staging.js +325 -0
  955. package/dist/stream-sync/seed-staging.js.map +1 -0
  956. package/dist/stream-sync/send-gate.d.ts +149 -0
  957. package/dist/stream-sync/send-gate.d.ts.map +1 -0
  958. package/dist/stream-sync/send-gate.js +382 -0
  959. package/dist/stream-sync/send-gate.js.map +1 -0
  960. package/dist/stream-sync/storage-retry.d.ts +210 -0
  961. package/dist/stream-sync/storage-retry.d.ts.map +1 -0
  962. package/dist/stream-sync/storage-retry.js +314 -0
  963. package/dist/stream-sync/storage-retry.js.map +1 -0
  964. package/dist/stream-sync/stream-aead.d.ts +33 -0
  965. package/dist/stream-sync/stream-aead.d.ts.map +1 -0
  966. package/dist/stream-sync/stream-aead.js +183 -0
  967. package/dist/stream-sync/stream-aead.js.map +1 -0
  968. package/dist/stream-sync-read/index.d.ts +4 -0
  969. package/dist/stream-sync-read/index.d.ts.map +1 -0
  970. package/dist/stream-sync-read/index.js +3 -0
  971. package/dist/stream-sync-read/index.js.map +1 -0
  972. package/dist/stream-sync-read/routing.d.ts +27 -0
  973. package/dist/stream-sync-read/routing.d.ts.map +1 -0
  974. package/dist/stream-sync-read/routing.js +49 -0
  975. package/dist/stream-sync-read/routing.js.map +1 -0
  976. package/dist/stream-sync-read/service.d.ts +196 -0
  977. package/dist/stream-sync-read/service.d.ts.map +1 -0
  978. package/dist/stream-sync-read/service.js +17 -0
  979. package/dist/stream-sync-read/service.js.map +1 -0
  980. package/dist/sync/account-mode/authority.d.ts +56 -0
  981. package/dist/sync/account-mode/authority.d.ts.map +1 -0
  982. package/dist/sync/account-mode/authority.js +145 -0
  983. package/dist/sync/account-mode/authority.js.map +1 -0
  984. package/dist/sync/account-mode/evidence-wire.d.ts +23 -0
  985. package/dist/sync/account-mode/evidence-wire.d.ts.map +1 -0
  986. package/dist/sync/account-mode/evidence-wire.js +37 -0
  987. package/dist/sync/account-mode/evidence-wire.js.map +1 -0
  988. package/dist/sync/account-mode/import-waker.d.ts +36 -0
  989. package/dist/sync/account-mode/import-waker.d.ts.map +1 -0
  990. package/dist/sync/account-mode/import-waker.js +55 -0
  991. package/dist/sync/account-mode/import-waker.js.map +1 -0
  992. package/dist/sync/account-mode/index.d.ts +10 -0
  993. package/dist/sync/account-mode/index.d.ts.map +1 -0
  994. package/dist/sync/account-mode/index.js +10 -0
  995. package/dist/sync/account-mode/index.js.map +1 -0
  996. package/dist/sync/account-mode/port.d.ts +11 -0
  997. package/dist/sync/account-mode/port.d.ts.map +1 -0
  998. package/dist/sync/account-mode/port.js +21 -0
  999. package/dist/sync/account-mode/port.js.map +1 -0
  1000. package/dist/sync/account-mode/record.d.ts +52 -0
  1001. package/dist/sync/account-mode/record.d.ts.map +1 -0
  1002. package/dist/sync/account-mode/record.js +60 -0
  1003. package/dist/sync/account-mode/record.js.map +1 -0
  1004. package/dist/sync/account-mode/rw-lock.d.ts +14 -0
  1005. package/dist/sync/account-mode/rw-lock.d.ts.map +1 -0
  1006. package/dist/sync/account-mode/rw-lock.js +59 -0
  1007. package/dist/sync/account-mode/rw-lock.js.map +1 -0
  1008. package/dist/sync/cancellable-gateway.d.ts +25 -0
  1009. package/dist/sync/cancellable-gateway.d.ts.map +1 -0
  1010. package/dist/sync/cancellable-gateway.js +64 -0
  1011. package/dist/sync/cancellable-gateway.js.map +1 -0
  1012. package/dist/sync/data-point-feed.d.ts +3 -0
  1013. package/dist/sync/data-point-feed.d.ts.map +1 -1
  1014. package/dist/sync/data-point-feed.js +20 -1
  1015. package/dist/sync/data-point-feed.js.map +1 -1
  1016. package/dist/sync/delete-data-port.d.ts +19 -0
  1017. package/dist/sync/delete-data-port.d.ts.map +1 -1
  1018. package/dist/sync/delete-data-port.js +42 -9
  1019. package/dist/sync/delete-data-port.js.map +1 -1
  1020. package/dist/sync/engine/change-probe.d.ts +42 -0
  1021. package/dist/sync/engine/change-probe.d.ts.map +1 -0
  1022. package/dist/sync/engine/change-probe.js +79 -0
  1023. package/dist/sync/engine/change-probe.js.map +1 -0
  1024. package/dist/sync/engine/change-push.d.ts +53 -0
  1025. package/dist/sync/engine/change-push.d.ts.map +1 -0
  1026. package/dist/sync/engine/change-push.js +153 -0
  1027. package/dist/sync/engine/change-push.js.map +1 -0
  1028. package/dist/sync/engine/sync-manager.d.ts +181 -2
  1029. package/dist/sync/engine/sync-manager.d.ts.map +1 -1
  1030. package/dist/sync/engine/sync-manager.js +642 -19
  1031. package/dist/sync/engine/sync-manager.js.map +1 -1
  1032. package/dist/sync/index.d.ts +11 -3
  1033. package/dist/sync/index.d.ts.map +1 -1
  1034. package/dist/sync/index.js +11 -1
  1035. package/dist/sync/index.js.map +1 -1
  1036. package/dist/sync/pdpp-import.d.ts +202 -0
  1037. package/dist/sync/pdpp-import.d.ts.map +1 -0
  1038. package/dist/sync/pdpp-import.js +466 -0
  1039. package/dist/sync/pdpp-import.js.map +1 -0
  1040. package/dist/sync/pending-blob-deletions.d.ts +18 -2
  1041. package/dist/sync/pending-blob-deletions.d.ts.map +1 -1
  1042. package/dist/sync/pending-blob-deletions.js +97 -23
  1043. package/dist/sync/pending-blob-deletions.js.map +1 -1
  1044. package/dist/sync/scope-deletions.d.ts +12 -0
  1045. package/dist/sync/scope-deletions.d.ts.map +1 -1
  1046. package/dist/sync/scope-deletions.js +99 -25
  1047. package/dist/sync/scope-deletions.js.map +1 -1
  1048. package/dist/sync/tombstone-finality.d.ts +36 -0
  1049. package/dist/sync/tombstone-finality.d.ts.map +1 -0
  1050. package/dist/sync/tombstone-finality.js +142 -0
  1051. package/dist/sync/tombstone-finality.js.map +1 -0
  1052. package/dist/sync/tombstone-resubmits.d.ts +61 -0
  1053. package/dist/sync/tombstone-resubmits.d.ts.map +1 -0
  1054. package/dist/sync/tombstone-resubmits.js +85 -0
  1055. package/dist/sync/tombstone-resubmits.js.map +1 -0
  1056. package/dist/sync/types.d.ts +26 -0
  1057. package/dist/sync/types.d.ts.map +1 -1
  1058. package/dist/sync/upload-attempts.d.ts +218 -0
  1059. package/dist/sync/upload-attempts.d.ts.map +1 -0
  1060. package/dist/sync/upload-attempts.js +500 -0
  1061. package/dist/sync/upload-attempts.js.map +1 -0
  1062. package/dist/sync/upload-state.d.ts +163 -0
  1063. package/dist/sync/upload-state.d.ts.map +1 -0
  1064. package/dist/sync/upload-state.js +239 -0
  1065. package/dist/sync/upload-state.js.map +1 -0
  1066. package/dist/sync/workers/delete.d.ts +63 -6
  1067. package/dist/sync/workers/delete.d.ts.map +1 -1
  1068. package/dist/sync/workers/delete.js +621 -168
  1069. package/dist/sync/workers/delete.js.map +1 -1
  1070. package/dist/sync/workers/download.d.ts +27 -1
  1071. package/dist/sync/workers/download.d.ts.map +1 -1
  1072. package/dist/sync/workers/download.js +368 -27
  1073. package/dist/sync/workers/download.js.map +1 -1
  1074. package/dist/sync/workers/lost-data-points.d.ts +38 -0
  1075. package/dist/sync/workers/lost-data-points.d.ts.map +1 -0
  1076. package/dist/sync/workers/lost-data-points.js +72 -0
  1077. package/dist/sync/workers/lost-data-points.js.map +1 -0
  1078. package/dist/sync/workers/upload.d.ts +97 -8
  1079. package/dist/sync/workers/upload.d.ts.map +1 -1
  1080. package/dist/sync/workers/upload.js +498 -277
  1081. package/dist/sync/workers/upload.js.map +1 -1
  1082. package/dist/test-support/memory-oracle.calibration.d.ts +16 -0
  1083. package/dist/test-support/memory-oracle.calibration.d.ts.map +1 -0
  1084. package/dist/test-support/memory-oracle.calibration.js +43 -0
  1085. package/dist/test-support/memory-oracle.calibration.js.map +1 -0
  1086. package/dist/test-support/memory-oracle.d.ts +82 -0
  1087. package/dist/test-support/memory-oracle.d.ts.map +1 -0
  1088. package/dist/test-support/memory-oracle.js +104 -0
  1089. package/dist/test-support/memory-oracle.js.map +1 -0
  1090. package/dist/test-utils/account-mode.d.ts +36 -0
  1091. package/dist/test-utils/account-mode.d.ts.map +1 -0
  1092. package/dist/test-utils/account-mode.js +77 -0
  1093. package/dist/test-utils/account-mode.js.map +1 -0
  1094. package/dist/test-utils/index.d.ts +2 -0
  1095. package/dist/test-utils/index.d.ts.map +1 -1
  1096. package/dist/test-utils/index.js +2 -0
  1097. package/dist/test-utils/index.js.map +1 -1
  1098. package/dist/test-utils/legacy-write-seal.d.ts +16 -0
  1099. package/dist/test-utils/legacy-write-seal.d.ts.map +1 -0
  1100. package/dist/test-utils/legacy-write-seal.js +20 -0
  1101. package/dist/test-utils/legacy-write-seal.js.map +1 -0
  1102. package/dist/test-utils/live-grants.d.ts +24 -0
  1103. package/dist/test-utils/live-grants.d.ts.map +1 -0
  1104. package/dist/test-utils/live-grants.js +6 -0
  1105. package/dist/test-utils/live-grants.js.map +1 -0
  1106. package/dist/test-utils/memory-storage.d.ts +18 -2
  1107. package/dist/test-utils/memory-storage.d.ts.map +1 -1
  1108. package/dist/test-utils/memory-storage.js +156 -42
  1109. package/dist/test-utils/memory-storage.js.map +1 -1
  1110. package/dist/write/attribution.d.ts.map +1 -1
  1111. package/dist/write/attribution.js +8 -4
  1112. package/dist/write/attribution.js.map +1 -1
  1113. package/dist/write/route.d.ts.map +1 -1
  1114. package/dist/write/route.js +9 -10
  1115. package/dist/write/route.js.map +1 -1
  1116. package/dist/write/session.d.ts.map +1 -1
  1117. package/dist/write/session.js +13 -0
  1118. package/dist/write/session.js.map +1 -1
  1119. package/dist-test/localdb/conformance.d.ts +13 -0
  1120. package/dist-test/localdb/conformance.d.ts.map +1 -0
  1121. package/dist-test/localdb/conformance.js +292 -0
  1122. package/dist-test/localdb/conformance.js.map +1 -0
  1123. package/dist-test/tsconfig.tsbuildinfo +1 -0
  1124. package/package.json +131 -5
@@ -1,10 +1,27 @@
1
- import { keccak256, stringToHex } from "viem";
2
- import { deriveScopeKey, encryptWithPassword, } from "@opendatalabs/vana-sdk/browser";
1
+ import { isMemoryScope } from "../../policy/reserved-scopes.js";
2
+ import { isReplicaScope } from "../../replication/namespace.js";
3
+ import { publishVersion, } from "../../publication/publish.js";
4
+ export { parseGatewayNextVersion } from "../../publication/publish.js";
5
+ import { LegacyWriteRefusedError } from "../../api/legacy-write-gate.js";
3
6
  import { computeDataPointId } from "../data-point-id.js";
4
7
  import { deletionTimestamp, isEntryCoveredByTombstone, tombstoneVersion, } from "../scope-deletions.js";
5
- import { readStoredLineage } from "../../lineage/lineage.js";
8
+ import { MAX_UPLOAD_BODY_BYTES, createUploadStateTracker, exceedsUploadCap, isUsableUploadSize, } from "../upload-state.js";
9
+ import { DEFAULT_ABANDON_GRACE_MS, uploadAttemptKey, UploadAttemptStorageFailedError, } from "../upload-attempts.js";
6
10
  export { computeDataPointId } from "../data-point-id.js";
7
11
  export { isEntryCoveredByTombstone } from "../scope-deletions.js";
12
+ /** An upload attempt that ran past its deadline and was aborted. */
13
+ export class UploadDeadlineError extends Error {
14
+ deadlineMs;
15
+ constructor(deadlineMs) {
16
+ super(`Upload attempt passed its ${deadlineMs} ms deadline and was aborted`);
17
+ this.deadlineMs = deadlineMs;
18
+ this.name = "UploadDeadlineError";
19
+ }
20
+ }
21
+ /** One attempt's budget. Long enough for a slow link, short of forever. */
22
+ export const DEFAULT_UPLOAD_ATTEMPT_DEADLINE_MS = 10 * 60_000;
23
+ /** Default most unsynced rows read per cycle (index rows only, no bodies). */
24
+ export const UPLOAD_SCAN_BUDGET = 2000;
8
25
  /**
9
26
  * Thrown when an unsynced entry's local payload file is gone, so the entry was
10
27
  * dropped from the index rather than uploaded. `uploadAll` treats it as a
@@ -29,40 +46,48 @@ export class DeletedScopeEntryError extends Error {
29
46
  this.name = "DeletedScopeEntryError";
30
47
  }
31
48
  }
49
+ /**
50
+ * Thrown before anything is read when an unsynced entry's upload body would
51
+ * pass `MAX_UPLOAD_BODY_BYTES`. The entry stays local and readable; it can
52
+ * never sync, so retrying it is wasted work.
53
+ */
54
+ export class UploadTooLargeError extends Error {
55
+ path;
56
+ sizeBytes;
57
+ constructor(path, sizeBytes) {
58
+ super(`Too large to sync: ${path} is ${sizeBytes} bytes and an upload body is limited to ${MAX_UPLOAD_BODY_BYTES} bytes`);
59
+ this.path = path;
60
+ this.sizeBytes = sizeBytes;
61
+ this.name = "UploadTooLargeError";
62
+ }
63
+ }
64
+ /**
65
+ * Thrown before anything is read when an unsynced entry's stored size is
66
+ * missing or not a positive finite number. The cap cannot be checked, so the
67
+ * entry is held back (fail closed) and stays local.
68
+ */
69
+ export class UploadUnsizableError extends Error {
70
+ path;
71
+ sizeBytes;
72
+ constructor(path, sizeBytes) {
73
+ super(`No usable stored size for ${path}: ${String(sizeBytes)}`);
74
+ this.path = path;
75
+ this.sizeBytes = sizeBytes;
76
+ this.name = "UploadUnsizableError";
77
+ }
78
+ }
32
79
  /**
33
80
  * Drop an unsynced entry the gateway tombstone covers and signal it as a
34
81
  * self-heal. Returns without effect when the entry was ingested with
35
82
  * knowledge of the tombstone (`afterTombstoneVersion`): a legitimate re-add.
36
83
  *
37
- * When the entry's ciphertext already went up (`uploaded`: the tombstone
38
- * landed between the deletion guard and the registration), that exact blob
39
- * is deleted too, so abandoning the entry never leaves owner-decryptable
40
- * deleted data in storage. If the delete fails the scope is queued for the
41
- * exact-key cleanup the sync cycle retries.
84
+ * Remote cleanup belongs to the deletion pipeline. Registry refusal does
85
+ * not grant this publisher authority to delete a potentially committed blob.
42
86
  */
43
- async function dropIfCoveredByDeletion(deps, entry, tombstone, deletedAt, uploaded) {
87
+ async function dropIfCoveredByDeletion(deps, entry, tombstone, deletedAt) {
44
88
  const version = tombstoneVersion(tombstone);
45
89
  if (!isEntryCoveredByTombstone(entry, { version }))
46
90
  return;
47
- if (uploaded) {
48
- try {
49
- await deps.storageAdapter.delete(uploaded.url);
50
- }
51
- catch (err) {
52
- const message = err instanceof Error ? err.message : String(err);
53
- if (deps.pendingBlobDeletions) {
54
- await deps.pendingBlobDeletions.add([
55
- { scope: entry.scope, version: String(entry.version) },
56
- ]);
57
- }
58
- deps.logger.warn({
59
- scope: entry.scope,
60
- url: uploaded.url,
61
- error: message,
62
- queuedForCleanup: Boolean(deps.pendingBlobDeletions),
63
- }, "Could not delete the ciphertext uploaded for an entry the tombstone covers");
64
- }
65
- }
66
91
  await deps.storage.deleteVersion(entry.scope, entry.collectedAt);
67
92
  deps.logger.warn({
68
93
  path: entry.path,
@@ -95,8 +120,19 @@ function isMissingPayloadError(err) {
95
120
  * 6. Register DPv2 data point on-chain (AddData) if not already
96
121
  * 7. Persist the gateway-assigned dataPointId (marks the entry synced)
97
122
  */
98
- export async function uploadOne(deps, entry) {
123
+ export async function uploadOne(deps, entry, options) {
124
+ const signal = options?.signal;
125
+ if (isReplicaScope(entry.scope))
126
+ throw new Error("replica scopes require immutable transport");
99
127
  const { storage, storageAdapter, gateway, signer, masterKey, serverOwner, logger, } = deps;
128
+ // Decide from the stored size alone, before anything is read, parsed or
129
+ // encrypted: a body over the request limit can never be accepted.
130
+ if (!entry.dataPointId) {
131
+ if (!isUsableUploadSize(entry.sizeBytes))
132
+ throw new UploadUnsizableError(entry.path, entry.sizeBytes);
133
+ if (exceedsUploadCap(entry.sizeBytes))
134
+ throw new UploadTooLargeError(entry.path, entry.sizeBytes);
135
+ }
100
136
  // 1. Read local data file
101
137
  let envelope;
102
138
  try {
@@ -118,229 +154,74 @@ export async function uploadOne(deps, entry) {
118
154
  }
119
155
  throw err;
120
156
  }
121
- // 1b. Deletion guard. If the gateway holds a tombstone for this scope, an
122
- // unsynced entry from before the deletion must never be uploaded: the
123
- // owner deleted it (possibly on another replica) and registering it again
124
- // would resurrect the scope. An entry ingested after the deletion is a
125
- // real re-add and goes up at a version strictly after the tombstone.
126
- let registerVersion = BigInt(entry.version);
127
- if (!entry.dataPointId && deps.dataPointFeed) {
128
- const remote = await deps.dataPointFeed.getDataPoint({
157
+ signal?.throwIfAborted();
158
+ const readHead = async () => deps.dataPointFeed
159
+ ? deps.dataPointFeed.getDataPoint({
129
160
  ownerAddress: serverOwner,
130
161
  scope: entry.scope,
131
- });
132
- const deletedAt = deletionTimestamp(remote);
133
- if (remote && deletedAt !== null) {
162
+ signal,
163
+ })
164
+ : gateway.getDataPoint(computeDataPointId(serverOwner, entry.scope));
165
+ const checkHead = async (remote) => {
166
+ const deletedAt = remote?.deletedAt ??
167
+ (remote?.addedAt
168
+ ? deletionTimestamp({ ...remote, addedAt: remote.addedAt })
169
+ : null);
170
+ if (remote && deletedAt !== null)
134
171
  await dropIfCoveredByDeletion(deps, entry, remote, deletedAt);
135
- const afterTombstone = BigInt(remote.expectedVersion) + 1n;
136
- if (afterTombstone > registerVersion)
137
- registerVersion = afterTombstone;
172
+ };
173
+ const initialHead = !entry.dataPointId && deps.dataPointFeed ? await readHead() : undefined;
174
+ await checkHead(initialHead ?? null);
175
+ const proof = entry.dataPointId
176
+ ? {
177
+ dataPointId: entry.dataPointId,
178
+ url: storageAdapter.urlForKey(`${entry.scope}/${entry.version}`),
179
+ version: BigInt(entry.version),
180
+ sizeBytes: entry.sizeBytes,
138
181
  }
182
+ : await publishVersion({
183
+ ownerAddress: serverOwner,
184
+ envelope,
185
+ preferredVersion: BigInt(entry.version),
186
+ masterKey,
187
+ storageAdapter,
188
+ gateway,
189
+ signer,
190
+ lineageGateway: deps.lineageGateway,
191
+ fencedPublication: deps.fencedPublication,
192
+ // Each remote legacy write (blob upload, registration) is sealed.
193
+ legacyWriteSeal: storage.legacyWriteSeal,
194
+ signal,
195
+ head: initialHead,
196
+ readHead,
197
+ checkHead,
198
+ acknowledgedDeletionVersion: entry.afterTombstoneVersion == null
199
+ ? undefined
200
+ : BigInt(entry.afterTombstoneVersion),
201
+ // The marker is written at ingest, after the owner deleted the scope
202
+ // and imported it again: a deliberate re-add, not a recovery.
203
+ deletionAcknowledgedAtIngest: entry.afterTombstoneVersion != null,
204
+ });
205
+ const { dataPointId, url, sizeBytes } = proof;
206
+ // Past the deadline the registration may have landed, but the local rows are
207
+ // left alone: the retry finds the registered head and adopts it.
208
+ signal?.throwIfAborted();
209
+ if (!entry.dataPointId) {
210
+ // The path may have been replaced by a new row while this one uploaded;
211
+ // the acknowledgement names the row it uploaded (`entry.id`) and changes
212
+ // nothing on a different one, which stays unsynced for its own upload.
213
+ const acknowledged = proof.version === BigInt(entry.version) ||
214
+ (await storage.updateEntryVersion(entry.path, Number(proof.version), entry.id));
215
+ if (acknowledged &&
216
+ (await storage.updateDataPointId(entry.path, dataPointId, entry.id)))
217
+ deps.scopeDeletions?.markLive(entry.scope);
139
218
  }
140
- // 2. Derive scope key → hex-encode as OpenPGP password
141
- const scopeKey = deriveScopeKey(masterKey, entry.scope);
142
- const scopeKeyHex = uint8ToHex(scopeKey);
143
- // 3. Encrypt with OpenPGP password-based encryption
144
- const plaintext = new TextEncoder().encode(JSON.stringify(envelope));
145
- const encrypted = await encryptWithPassword(plaintext, scopeKeyHex);
146
- // 4. Compute the on-chain commitments.
147
- // dataHash = keccak256 of the plaintext envelope JSON. Commits to the
148
- // canonical content, not the ciphertext — OpenPGP
149
- // password-based encryption embeds random salts so
150
- // re-encrypting the same plaintext yields different bytes;
151
- // hashing the plaintext keeps the on-chain commitment
152
- // reproducible across replicas serving the same version.
153
- // metadataHash = keccak256 of canonical-JSON({scope, collectedAt,
154
- // sizeBytes}). Commits to the off-chain metadata that
155
- // describes this version without leaking the payload. DPv2
156
- // is scope-addressed with no schema concept — the gateway
157
- // neither records nor registers schemas — so no schemaId is
158
- // looked up or committed.
159
- const dataHash = keccak256(plaintext);
160
- const metadataHash = keccak256(stringToHex(JSON.stringify({
161
- scope: entry.scope,
162
- collectedAt: entry.collectedAt,
163
- sizeBytes: encrypted.byteLength,
164
- })));
165
- // 5. Upload ciphertext to storage backend FIRST, version-keyed so the
166
- // download worker can reconstruct the URL from a DataPointRecord's
167
- // (scope, expectedVersion) — DataPointRecords carry no URL. We upload
168
- // before registering so the on-chain data point (the synced marker) is
169
- // never stamped ahead of a blob that failed to land.
170
- const storageKey = `${entry.scope}/${registerVersion}`;
171
- let url = await storageAdapter.upload(storageKey, encrypted);
172
- // 6. DPv2 data-point registration (idempotent — skipped when a prior run
173
- // already persisted a dataPointId on this entry). registerDataPoint stamps
174
- // the synced marker that excludes this entry from findUnsynced next time.
175
- let dataPointId;
176
- if (entry.dataPointId) {
177
- dataPointId = entry.dataPointId;
178
- }
179
- else {
180
- const registerAt = async (version) => {
181
- const addDataSignature = await signer.signAddData({
182
- ownerAddress: serverOwner,
183
- scope: entry.scope,
184
- dataHash,
185
- metadataHash,
186
- expectedVersion: version,
187
- });
188
- const registration = {
189
- ownerAddress: serverOwner,
190
- scope: entry.scope,
191
- dataHash,
192
- metadataHash,
193
- expectedVersion: String(version),
194
- signature: addDataSignature,
195
- };
196
- // A derivative carries its validated `$lineage` inside the envelope;
197
- // the gateway stores the same sources next to this (dataPointId,
198
- // version) so lineage can be walked without the plaintext. The
199
- // AddData signature is unchanged (dataHash already commits to the
200
- // plaintext, `$lineage` included); the plaintext list the gateway
201
- // keeps is covered by a separate LineageAttestation signature bound
202
- // to this version and dataHash, so a replayed registration cannot
203
- // swap it (see lineage/attestation.ts).
204
- const lineage = readStoredLineage(envelope.data);
205
- // An empty `$lineage` is an explicit root statement and is registered
206
- // as such (attested empty list); only an ABSENT `$lineage` makes no
207
- // statement and goes through the plain client.
208
- let dataPointResult;
209
- if (lineage) {
210
- if (!deps.lineageGateway) {
211
- throw new Error(`Cannot register derivative ${entry.path} (scope=${entry.scope}): lineage registration needs a gateway URL (lineageGateway is not configured)`);
212
- }
213
- const lineageSignature = await signer.signLineageAttestation({
214
- ownerAddress: serverOwner,
215
- scope: entry.scope,
216
- expectedVersion: version,
217
- dataHash,
218
- sources: lineage.sources,
219
- });
220
- dataPointResult = await deps.lineageGateway.registerDataPoint({
221
- ...registration,
222
- lineage: lineage.sources,
223
- lineageSignature,
224
- });
225
- }
226
- else {
227
- dataPointResult = await gateway.registerDataPoint(registration);
228
- }
229
- const id = dataPointResult.dataPointId ?? null;
230
- if (!id) {
231
- throw new Error(`Gateway registerDataPoint did not return a dataPointId for ${entry.path} (scope=${entry.scope}, version=${version})`);
232
- }
233
- return id;
234
- };
235
- try {
236
- dataPointId = await registerAt(registerVersion);
237
- if (registerVersion !== BigInt(entry.version)) {
238
- // Re-add after a deletion: the row must follow the registered
239
- // version (the blob key embeds it).
240
- await storage.updateEntryVersion(entry.path, Number(registerVersion));
241
- }
242
- }
243
- catch (err) {
244
- if (!isStaleVersionConflict(err))
245
- throw err;
246
- // The registry's version for this (owner, scope) is ahead of the local
247
- // index: pre-DPv2 rows were backfilled to version 1, and other replicas
248
- // (PS Lite in the browser) advance the same per-scope sequence. The
249
- // gateway 409s precisely so the client can re-sign against the live
250
- // version — retrying the same version every cycle head-blocks the
251
- // scope's whole upload queue.
252
- // Prefer the deletion-aware feed: the SDK client throws on a 410 for
253
- // a tombstoned point, which would wedge this entry forever.
254
- const record = deps.dataPointFeed
255
- ? await deps.dataPointFeed.getDataPoint({
256
- ownerAddress: serverOwner,
257
- scope: entry.scope,
258
- })
259
- : await gateway.getDataPoint(computeDataPointId(serverOwner, entry.scope));
260
- // The 409 may be a tombstone that landed after the deletion guard in
261
- // step 1b ran (a delete on another replica racing this upload). Apply
262
- // the same rule again before rebasing: a covered entry is dropped, a
263
- // genuine re-add rebases past the tombstone below.
264
- const conflictDeletedAt = record ? deletionTimestamp(record) : null;
265
- if (record && conflictDeletedAt !== null) {
266
- await dropIfCoveredByDeletion(deps, entry, record, conflictDeletedAt, {
267
- url,
268
- });
269
- }
270
- if (record && record.dataHash.toLowerCase() === dataHash.toLowerCase()) {
271
- // Identical content is already registered (this entry, or a replica's
272
- // copy of it) — adopt the registered data point rather than minting a
273
- // new version of the same bytes.
274
- dataPointId = record.id;
275
- // Align the local row with the adopted registry version — downstream
276
- // consumers sign from the row's version (e.g. x402 RecordDataAccess),
277
- // so a stale local version would emit records the registry rejects.
278
- const adoptedVersion = Number(record.expectedVersion);
279
- if (adoptedVersion !== entry.version) {
280
- // Cross-replica adopt: "the registrant already uploaded the blob
281
- // under the registered version key" is an assumption, not a fact —
282
- // a replica that crashed between register and upload leaves a
283
- // registry row whose bytes 404 for every consumer (readers
284
- // reconstruct the URL from the record's (scope, expectedVersion);
285
- // records carry no URL). Verify, and heal from our identical
286
- // plaintext (dataHash matched, so our ciphertext decrypts to the
287
- // registered content).
288
- const adoptedKey = `${entry.scope}/${adoptedVersion}`;
289
- const adoptedBlobExists = await storageAdapter.exists(storageAdapter.urlForKey(adoptedKey));
290
- if (!adoptedBlobExists) {
291
- logger.warn({ scope: entry.scope, version: adoptedVersion, dataPointId }, "Adopted registry version has no blob in storage; re-uploading from local content");
292
- url = await storageAdapter.upload(adoptedKey, encrypted);
293
- }
294
- await storage.updateEntryVersion(entry.path, adoptedVersion);
295
- }
296
- }
297
- else {
298
- // Rebase onto the gateway's live next-valid version. Two independent
299
- // signals for what that is:
300
- // • the registry row — a replica racing AHEAD advances it past the
301
- // version this error was raised against;
302
- // • the 409 message itself — authoritative when the registry
303
- // regressed BEHIND the local index (a moksha/DataRegistry reset,
304
- // or duplicate re-snapshots pushing the local counter ahead), and
305
- // the only signal at all when the reset left no row for
306
- // getDataPoint to return (BUI-715).
307
- // Take the max so the scope converges from either direction; when
308
- // neither signal is available there is nothing to rebase onto, so
309
- // surface the conflict rather than guess.
310
- const recordNext = record ? Number(record.expectedVersion) + 1 : 0;
311
- const errorNext = parseGatewayNextVersion(err.message) ?? 0;
312
- const target = Math.max(recordNext, errorNext);
313
- if (target <= 0)
314
- throw err;
315
- const rebased = BigInt(target);
316
- // Known limitation (BUI-715 follow-up): when the registry regressed
317
- // BELOW the local index, `target` can land on a version this scope
318
- // already has an (older, now-defunct) synced row for. We realign only
319
- // this entry, so the scope's other stale rows stay bound to gateway
320
- // versions the reset dropped until their next sync cycle re-registers
321
- // them. That is transient and fail-safe — readers resolve blobs from
322
- // the gateway record (consistent with what we just re-registered), and
323
- // x402 signed from a stale local version is rejected by the gateway
324
- // rather than serving wrong bytes. A full scope reconcile (clear +
325
- // renumber every row for the scope from the gateway's version) is
326
- // tracked separately; head-block recovery is the fix that matters here.
327
- // The blob key embeds the version (replicas reconstruct URLs from the
328
- // registry record), so the rebased version needs its own blob; the one
329
- // written under the stale key above is orphaned, which storage
330
- // tolerates.
331
- url = await storageAdapter.upload(`${entry.scope}/${rebased}`, encrypted);
332
- // A concurrent replica can still win the race to `rebased`; the next
333
- // sync cycle re-reads the registry and rebases again, so this stays
334
- // convergent without looping here.
335
- dataPointId = await registerAt(rebased);
336
- await storage.updateEntryVersion(entry.path, Number(rebased));
337
- }
338
- }
339
- // 7. Stamp the dataPointId on the local index entry — marks it synced.
340
- await storage.updateDataPointId(entry.path, dataPointId);
341
- // The registry now holds a live row for the scope (fresh registration or
342
- // an adopted one): reads must stop treating it as deleted.
343
- deps.scopeDeletions?.markLive(entry.scope);
219
+ if (deps.additions) {
220
+ await deps.additions.recordUpload({
221
+ scope: entry.scope,
222
+ collectedAt: envelope.collectedAt,
223
+ data: envelope.data,
224
+ }, { envelope, encryptedSize: sizeBytes });
344
225
  }
345
226
  logger.info({
346
227
  path: entry.path,
@@ -351,62 +232,402 @@ export async function uploadOne(deps, entry) {
351
232
  }, "Uploaded and registered DPv2 data point");
352
233
  return { path: entry.path, url, dataPointId };
353
234
  }
235
+ /**
236
+ * Agent-memory scopes (see `isMemoryScope`): every save stores a full snapshot,
237
+ * so publishing each intermediate one would cost a registration per save.
238
+ */
239
+ export function isCoalescedScope(scope) {
240
+ return isMemoryScope(scope);
241
+ }
242
+ /**
243
+ * A coalesced scope is published once its newest snapshot has been quiet this
244
+ * long (saves have stopped) ...
245
+ */
246
+ export const COALESCE_QUIET_MS = 2 * 60_000;
247
+ /** ... or once its oldest unpublished snapshot has waited this long. */
248
+ export const COALESCE_MAX_WAIT_MS = 10 * 60_000;
249
+ const at = (entry) => Date.parse(entry.collectedAt);
250
+ const identityOf = (entry) => ({
251
+ id: entry.id,
252
+ sizeBytes: entry.sizeBytes,
253
+ });
254
+ const VERSION_PAGE = 200;
255
+ /**
256
+ * One plan per coalesced scope in the batch. The head is the scope's latest
257
+ * local version (`findEntry`), not the batch's latest. Only the head is ever
258
+ * published: readers serve the latest version, which is a full state, so an
259
+ * older unpublished snapshot is never what anyone sees and publishing it would
260
+ * roll the scope back.
261
+ */
262
+ function coalescePlan(deps, entries, nowMs) {
263
+ // One pass, one small aggregate per scope: the batch's newest row and the
264
+ // oldest time. Nothing is copied per row, so the cost is linear in the
265
+ // entries however many versions one scope holds.
266
+ const aggregates = new Map();
267
+ for (const entry of entries) {
268
+ if (!isCoalescedScope(entry.scope))
269
+ continue;
270
+ const known = aggregates.get(entry.scope);
271
+ if (!known) {
272
+ aggregates.set(entry.scope, { batchHead: entry, oldestMs: at(entry) });
273
+ continue;
274
+ }
275
+ if (at(entry) > at(known.batchHead))
276
+ known.batchHead = entry;
277
+ if (at(entry) < known.oldestMs)
278
+ known.oldestMs = at(entry);
279
+ }
280
+ const plans = new Map();
281
+ for (const [scope, { batchHead, oldestMs }] of aggregates) {
282
+ const latest = deps.storage.findEntry?.({ scope });
283
+ const head = latest && at(latest) >= at(batchHead) ? latest : batchHead;
284
+ const oldest = Math.min(oldestMs, at(head));
285
+ const deferred = head.dataPointId === null &&
286
+ nowMs - at(head) < COALESCE_QUIET_MS &&
287
+ nowMs - oldest < COALESCE_MAX_WAIT_MS;
288
+ plans.set(scope, { head, deferred });
289
+ }
290
+ return plans;
291
+ }
292
+ /** Every unpublished version of `head`'s scope older than `head`. */
293
+ function olderUnsynced(deps, head) {
294
+ const older = [];
295
+ for (let offset = 0;; offset += VERSION_PAGE) {
296
+ const page = deps.storage.listVersions(head.scope, {
297
+ limit: VERSION_PAGE,
298
+ offset,
299
+ });
300
+ for (const entry of page) {
301
+ if (entry.id !== head.id &&
302
+ entry.dataPointId === null &&
303
+ at(entry) < at(head)) {
304
+ older.push(entry);
305
+ }
306
+ }
307
+ if (page.length < VERSION_PAGE)
308
+ return older;
309
+ }
310
+ }
311
+ /**
312
+ * Erase the older unsynced snapshots of a coalesced scope once its newest
313
+ * snapshot is published. Fenced to the exact rows selected, so a row that
314
+ * changed since is left alone. A failed erase is logged; the row stays and is
315
+ * superseded again on the next pass.
316
+ */
317
+ async function eraseSuperseded(deps, entries) {
318
+ for (const entry of entries) {
319
+ try {
320
+ await deps.storage.deleteVersion(entry.scope, entry.collectedAt, {
321
+ id: entry.id,
322
+ path: entry.path,
323
+ });
324
+ }
325
+ catch (err) {
326
+ deps.logger.warn({
327
+ path: entry.path,
328
+ scope: entry.scope,
329
+ error: err instanceof Error ? err.message : String(err),
330
+ }, "Failed to erase a superseded memory snapshot");
331
+ }
332
+ }
333
+ }
334
+ /**
335
+ * Note an entry whose stored size means it can never be uploaded (too large,
336
+ * or no usable size), log it once, and say so. Reads nothing but the row.
337
+ */
338
+ function holdBackTerminal(deps, state, target) {
339
+ if (target.dataPointId !== null)
340
+ return false;
341
+ const at = {
342
+ scope: target.scope,
343
+ path: target.path,
344
+ identity: identityOf(target),
345
+ };
346
+ if (!isUsableUploadSize(target.sizeBytes)) {
347
+ if (state.markUnsizable(at)) {
348
+ deps.logger.warn({ ...at, sizeBytes: String(target.sizeBytes) }, "Entry has no usable size; it stays local and is not uploaded");
349
+ }
350
+ return true;
351
+ }
352
+ if (!exceedsUploadCap(target.sizeBytes))
353
+ return false;
354
+ if (state.markTooLarge(at, target.sizeBytes)) {
355
+ deps.logger.warn({
356
+ ...at,
357
+ sizeBytes: target.sizeBytes,
358
+ maxBodyBytes: MAX_UPLOAD_BODY_BYTES,
359
+ }, "Entry is too large to sync; it stays local and is not uploaded");
360
+ }
361
+ return true;
362
+ }
363
+ /**
364
+ * Start `attempt` with an AbortSignal that fires at the deadline. `result`
365
+ * rejects with `UploadDeadlineError` at the deadline even when `attempt` never
366
+ * settles, so the worker can move on. `stopped` resolves, with the attempt's
367
+ * error or `undefined`, only when `attempt` has truly stopped.
368
+ */
369
+ function startAttempt(deadlineMs, attempt) {
370
+ const controller = new AbortController();
371
+ const running = attempt(controller.signal);
372
+ const stopped = running.then(() => undefined, (error) => error ?? new Error("Upload attempt failed"));
373
+ let timer;
374
+ const expired = new Promise((_, reject) => {
375
+ timer = setTimeout(() => {
376
+ const error = new UploadDeadlineError(deadlineMs);
377
+ controller.abort(error);
378
+ reject(error);
379
+ }, deadlineMs);
380
+ });
381
+ const result = Promise.race([running, expired]).finally(() => clearTimeout(timer));
382
+ return { result, stopped };
383
+ }
354
384
  /**
355
385
  * Process all unsynced entries (dataPointId === null).
356
386
  * Processes sequentially to avoid overwhelming storage backend.
357
387
  * Returns array of results (skips failures, logs errors).
388
+ *
389
+ * Coalesced scopes (see `isCoalescedScope`) publish only their newest
390
+ * unsynced snapshot in the batch, after a quiet window; the older ones are
391
+ * erased after it lands.
358
392
  */
359
393
  export async function uploadAll(deps, options) {
360
394
  const batchSize = options?.batchSize ?? 50;
361
- const entries = deps.storage.findUnsynced({ limit: batchSize });
395
+ const clock = () => (options?.now ?? (() => new Date()))().getTime();
396
+ // Unsynced index rows only, no bodies. Entries that cannot be attempted now
397
+ // must not occupy the batch, or they hide every entry behind them, so the
398
+ // batch is chosen below from everything listed, not from a limited page.
399
+ // A host with keyset paging lists one window of at most `scanBudget` rows
400
+ // per cycle, resuming where the last cycle stopped, so a huge backlog costs
401
+ // a bounded amount per cycle and is still swept in full. Any other host is
402
+ // listed whole.
403
+ const state = deps.uploadState ?? createUploadStateTracker();
404
+ const attempts = deps.uploadAttempts;
405
+ // Leftover markers are attempts that never settled; count them before
406
+ // choosing what to upload.
407
+ if (attempts && !(await attempts.recover())) {
408
+ // Another manager owns the markers. Uploading from here would make a live
409
+ // attempt look like a crash, or overwrite its markers.
410
+ deps.logger.warn({}, "Upload attempt markers are owned by another sync manager; not uploading");
411
+ return [];
412
+ }
413
+ // Paging needs both methods: the page method alone has no fence, so a
414
+ // growing tail could keep the sweep from ever wrapping. Such a host is
415
+ // listed whole.
416
+ const paged = deps.storage.maxUnsyncedId
417
+ ? deps.storage.findUnsyncedPage
418
+ : undefined;
419
+ const scanBudget = options?.scanBudget ?? UPLOAD_SCAN_BUDGET;
420
+ const scanAfter = paged ? state.scanCursor() : 0;
421
+ // A sweep covers the rows present when it began: its upper id is fixed at
422
+ // the start. Rows that arrive above it wait for the next sweep, so a tail
423
+ // that keeps growing cannot stop the sweep from wrapping back to earlier
424
+ // rows (a failed upload that is due again would never be revisited).
425
+ if (paged && scanAfter === 0 && state.scanFence() === null) {
426
+ const max = deps.storage.maxUnsyncedId?.() ?? Number.POSITIVE_INFINITY;
427
+ state.setScanFence(max);
428
+ // No unsynced row is above the fresh maximum, so state recorded for ids
429
+ // beyond it belongs to rows that are gone (a remote deletion removes rows
430
+ // without the sync manager). Only a new sweep may say this: an older
431
+ // sweep's fence can sit below live state.
432
+ if (Number.isFinite(max)) {
433
+ state.reconcile([], {
434
+ afterId: max,
435
+ throughId: Number.POSITIVE_INFINITY,
436
+ });
437
+ }
438
+ }
439
+ const scanFence = paged ? (state.scanFence() ?? Number.POSITIVE_INFINITY) : 0;
440
+ const listed = paged
441
+ ? paged.call(deps.storage, { afterId: scanAfter, limit: scanBudget })
442
+ : deps.storage.findUnsynced();
443
+ const entries = paged ? listed.filter((e) => e.id <= scanFence) : listed;
444
+ // The window is full only if it filled the budget and stayed inside the
445
+ // fence; otherwise the sweep has listed everything up to its fence.
446
+ const windowFull = paged !== undefined &&
447
+ listed.length >= scanBudget &&
448
+ entries.length === listed.length;
449
+ // Tracked state is dropped for rows that are gone or were rewritten. After a
450
+ // partial window only the id range actually listed counts, so backoff of
451
+ // rows beyond it survives; a window that reached the end covers the rest.
452
+ const scanned = paged
453
+ ? {
454
+ afterId: scanAfter,
455
+ throughId: windowFull
456
+ ? Number(entries[entries.length - 1]?.id)
457
+ : scanFence,
458
+ }
459
+ : undefined;
460
+ state.reconcile(entries, scanned);
461
+ // Markers of rows that are gone or rewritten go the same way.
462
+ await attempts?.reconcile(entries, scanned);
463
+ const plans = coalescePlan(deps, entries, clock());
362
464
  const results = [];
465
+ /** Erase superseded snapshots and forget their upload state. */
466
+ const supersede = async (head) => {
467
+ const older = olderUnsynced(deps, head);
468
+ await eraseSuperseded(deps, older);
469
+ for (const entry of older)
470
+ state.clear(entry.path);
471
+ };
472
+ const batch = [];
473
+ const planned = new Set();
474
+ const selectedAt = clock();
475
+ // Last listed row the selection looked at; the next window resumes after it.
476
+ let lastLookedAt = scanAfter;
477
+ let selectionStopped = false;
363
478
  for (const entry of entries) {
479
+ if (batch.length >= batchSize) {
480
+ selectionStopped = true;
481
+ break;
482
+ }
483
+ lastLookedAt = Number(entry.id);
484
+ const plan = plans.get(entry.scope);
485
+ if (plan) {
486
+ if (planned.has(entry.scope))
487
+ continue;
488
+ planned.add(entry.scope);
489
+ if (plan.deferred)
490
+ continue;
491
+ if (plan.head.dataPointId === null) {
492
+ if (!state.shouldAttempt(plan.head.path, selectedAt))
493
+ continue;
494
+ }
495
+ }
496
+ else if (!state.shouldAttempt(entry.path, selectedAt))
497
+ continue;
498
+ // Entries that can never upload are classified here, from the index row
499
+ // alone, so they cost no batch slot even the first time they are seen.
500
+ if (holdBackTerminal(deps, state, plan ? plan.head : entry))
501
+ continue;
502
+ // An entry whose attempts killed the process is skipped, not retried: it
503
+ // would starve every entry behind it after each restart.
504
+ const candidate = plan ? plan.head : entry;
505
+ // An earlier attempt past its deadline may still be unwinding: never run a
506
+ // second attempt on the same entry version beside it.
507
+ if (attempts?.isLive(uploadAttemptKey(deps.serverOwner, candidate)))
508
+ continue;
509
+ const crashed = attempts
510
+ ?.quarantined()
511
+ .find((record) => record.key === uploadAttemptKey(deps.serverOwner, candidate));
512
+ if (crashed) {
513
+ state.markCrashed({
514
+ scope: crashed.scope,
515
+ path: crashed.path,
516
+ identity: identityOf(candidate),
517
+ }, crashed.interrupted, selectedAt);
518
+ continue;
519
+ }
520
+ batch.push({ entry, plan });
521
+ }
522
+ if (paged) {
523
+ // Stopped early: resume right after the last row looked at. Looked at all
524
+ // of a full window: continue past it. Reached the end of the sweep's
525
+ // fence: start over with a new fence.
526
+ const resumes = selectionStopped || windowFull;
527
+ state.setScanCursor(resumes ? lastLookedAt : 0);
528
+ if (!resumes)
529
+ state.setScanFence(null);
530
+ }
531
+ for (const { entry, plan } of batch) {
532
+ if (plan && plan.head.dataPointId !== null) {
533
+ // The latest version is already published: older unpublished
534
+ // snapshots are superseded, never published.
535
+ await supersede(plan.head);
536
+ continue;
537
+ }
538
+ const target = plan ? plan.head : entry;
539
+ // Earlier entries may have taken minutes: judge this one at its own time.
540
+ if (!state.shouldAttempt(target.path, clock()))
541
+ continue;
542
+ // A first attempt at an entry is new data: it releases the scope's
543
+ // stopped entries to try again.
544
+ if (!state.has(target.path))
545
+ state.releaseStopped(target.scope);
546
+ // Set once the attempt exists; resolves when it has truly stopped and its
547
+ // marker is cleared.
548
+ let markerCleared;
549
+ let abandoned = false;
364
550
  try {
365
- const result = await uploadOne(deps, entry);
551
+ // Durable before any body is built: if this attempt kills the process,
552
+ // the next boot finds the marker and counts it.
553
+ const token = attempts ? await attempts.begin(target) : undefined;
554
+ const deadlineMs = options?.attemptDeadlineMs ?? DEFAULT_UPLOAD_ATTEMPT_DEADLINE_MS;
555
+ const running = startAttempt(deadlineMs, (signal) => uploadOne(deps, target, { signal }));
556
+ // The marker is cleared when the attempt has actually stopped, not when
557
+ // the deadline gave up on it: abandoned work that dies with the process
558
+ // must still count. A caught failure keeps the interrupted count.
559
+ markerCleared = running.stopped
560
+ .then((error) => attempts?.settle(token, error === undefined ||
561
+ error instanceof OrphanedEntryError ||
562
+ error instanceof DeletedScopeEntryError ||
563
+ error instanceof LegacyWriteRefusedError
564
+ ? "success"
565
+ : "failure"))
566
+ .catch((err) => {
567
+ deps.logger.warn({
568
+ path: target.path,
569
+ error: err instanceof Error ? err.message : String(err),
570
+ }, "Could not clear an upload attempt marker");
571
+ });
572
+ const result = await running.result;
366
573
  results.push(result);
574
+ state.clear(target.path);
575
+ if (plan)
576
+ await supersede(plan.head);
367
577
  }
368
578
  catch (err) {
579
+ // A marker that cannot be repaired stops the pass, not just this entry.
580
+ if (err instanceof UploadAttemptStorageFailedError)
581
+ throw err;
582
+ abandoned = err instanceof UploadDeadlineError;
369
583
  // A dropped orphan is a self-heal, not a failure: the row is already
370
584
  // gone, there is nothing to retry, and surfacing it would keep the
371
585
  // scope showing a scary error (and fail settle-waits) for a file the
372
586
  // user deleted on purpose. Already logged in uploadOne; swallow here.
373
587
  if (err instanceof OrphanedEntryError ||
374
588
  err instanceof DeletedScopeEntryError) {
589
+ state.clear(target.path);
375
590
  continue;
376
591
  }
592
+ // The account no longer accepts legacy writes (switched) or has not said
593
+ // yet (unknown). Nothing is wrong with this entry: it is not a failure,
594
+ // spends no retry budget, and the rest of the pass would be refused too.
595
+ if (err instanceof LegacyWriteRefusedError) {
596
+ deps.logger.info({ path: target.path, scope: target.scope, verdict: err.verdict }, "Stopped uploading: legacy writes are not open for this account");
597
+ break;
598
+ }
377
599
  const error = err;
600
+ state.recordFailure({
601
+ scope: target.scope,
602
+ path: target.path,
603
+ identity: identityOf(target),
604
+ }, error.message, clock());
378
605
  options?.onError?.(entry, error);
379
606
  deps.logger.error({ path: entry.path, scope: entry.scope, error: error.message }, "Failed to upload entry");
607
+ if (!state.shouldAttempt(target.path, Number.MAX_SAFE_INTEGER)) {
608
+ deps.logger.warn({ path: target.path, scope: target.scope }, "Stopped retrying the upload of an entry after repeated failures");
609
+ }
610
+ }
611
+ finally {
612
+ if (!abandoned)
613
+ await markerCleared;
614
+ else {
615
+ // Give the aborted work a short moment to unwind. If it has not
616
+ // stopped, its marker stays and the entry is not retried until it does.
617
+ const grace = options?.abandonGraceMs ?? DEFAULT_ABANDON_GRACE_MS;
618
+ let timer;
619
+ await Promise.race([
620
+ markerCleared,
621
+ new Promise((resolve) => {
622
+ timer = setTimeout(resolve, grace);
623
+ }),
624
+ ]);
625
+ clearTimeout(timer);
626
+ if (attempts?.isLive(uploadAttemptKey(deps.serverOwner, target)))
627
+ deps.logger.warn({ path: target.path, scope: target.scope }, "Upload attempt is still running after its deadline; its marker is kept");
628
+ }
380
629
  }
381
630
  }
382
631
  return results;
383
632
  }
384
- function uint8ToHex(bytes) {
385
- return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
386
- }
387
- // The gateway rejects a registration whose expectedVersion is not strictly
388
- // greater than its stored value with a 409; the SDK client surfaces it as
389
- // `Gateway error: 409 <detail>`. Anything else is not a version conflict.
390
- function isStaleVersionConflict(err) {
391
- return err instanceof Error && /Gateway error: 409\b/.test(err.message);
392
- }
393
- // Extract the gateway's authoritative next-valid version from a 409 body so a
394
- // rebase can target it directly instead of only inferring from a registry row
395
- // (which is absent after a reset that dropped the scope's row entirely).
396
- // Handles the current "Gap in version sequence … next valid version is N"
397
- // phrasing (and its "effective max (M" form) as well as the older "Stale
398
- // expectedVersion … must be strictly greater than the stored value N" one.
399
- // Returns null when no version can be parsed.
400
- export function parseGatewayNextVersion(message) {
401
- const nextValid = message.match(/next valid version is (\d+)/i);
402
- if (nextValid)
403
- return Number(nextValid[1]);
404
- const effectiveMax = message.match(/effective max \((\d+)/i);
405
- if (effectiveMax)
406
- return Number(effectiveMax[1]) + 1;
407
- const storedValue = message.match(/strictly greater than the stored value (\d+)/i);
408
- if (storedValue)
409
- return Number(storedValue[1]) + 1;
410
- return null;
411
- }
412
633
  //# sourceMappingURL=upload.js.map