@farukada/aws-langgraph-dynamodb-ts 0.8.0 → 1.0.0-rc.1

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 (482) hide show
  1. package/README.md +282 -49
  2. package/dist/checkpointer/actions/delete-thread.d.ts +3 -2
  3. package/dist/checkpointer/actions/delete-thread.js +5 -2
  4. package/dist/checkpointer/actions/get-tuple.d.ts +3 -2
  5. package/dist/checkpointer/actions/get-tuple.js +10 -4
  6. package/dist/checkpointer/actions/list.d.ts +14 -4
  7. package/dist/checkpointer/actions/list.js +94 -61
  8. package/dist/checkpointer/actions/put-writes.d.ts +5 -5
  9. package/dist/checkpointer/actions/put-writes.js +12 -40
  10. package/dist/checkpointer/actions/put.d.ts +10 -3
  11. package/dist/checkpointer/actions/put.js +42 -12
  12. package/dist/checkpointer/internal/assemble.d.ts +10 -3
  13. package/dist/checkpointer/internal/assemble.js +7 -6
  14. package/dist/checkpointer/internal/checkpoint-write-verify.d.ts +24 -0
  15. package/dist/checkpointer/internal/checkpoint-write-verify.js +67 -0
  16. package/dist/checkpointer/internal/configurable.d.ts +0 -1
  17. package/dist/checkpointer/internal/configurable.js +10 -9
  18. package/dist/checkpointer/internal/fetch.d.ts +14 -5
  19. package/dist/checkpointer/internal/fetch.js +56 -14
  20. package/dist/checkpointer/internal/filter-match.d.ts +3 -2
  21. package/dist/checkpointer/internal/filter-match.js +4 -3
  22. package/dist/checkpointer/internal/item-reader.d.ts +31 -6
  23. package/dist/checkpointer/internal/item-reader.js +54 -15
  24. package/dist/checkpointer/internal/item-writer.d.ts +12 -3
  25. package/dist/checkpointer/internal/item-writer.js +26 -10
  26. package/dist/checkpointer/internal/keys.d.ts +11 -1
  27. package/dist/checkpointer/internal/keys.js +33 -3
  28. package/dist/checkpointer/internal/list-scope.d.ts +61 -0
  29. package/dist/checkpointer/internal/list-scope.js +108 -0
  30. package/dist/checkpointer/internal/pending-sends.d.ts +13 -0
  31. package/dist/checkpointer/internal/pending-sends.js +29 -0
  32. package/dist/checkpointer/internal/query.d.ts +2 -1
  33. package/dist/checkpointer/internal/query.js +9 -3
  34. package/dist/checkpointer/internal/regular-write.d.ts +28 -0
  35. package/dist/checkpointer/internal/regular-write.js +66 -0
  36. package/dist/checkpointer/internal/setup.d.ts +3 -1
  37. package/dist/checkpointer/internal/setup.js +10 -8
  38. package/dist/checkpointer/internal/special-write-cas.d.ts +29 -0
  39. package/dist/checkpointer/internal/special-write-cas.js +104 -0
  40. package/dist/checkpointer/internal/special-write-cleanup.d.ts +19 -14
  41. package/dist/checkpointer/internal/special-write-cleanup.js +35 -87
  42. package/dist/checkpointer/internal/special-write-verify.d.ts +53 -0
  43. package/dist/checkpointer/internal/special-write-verify.js +80 -0
  44. package/dist/checkpointer/internal/stored-channels.d.ts +31 -0
  45. package/dist/checkpointer/internal/stored-channels.js +70 -0
  46. package/dist/checkpointer/internal/validation.d.ts +11 -6
  47. package/dist/checkpointer/internal/validation.js +19 -9
  48. package/dist/checkpointer/internal/write-guard.d.ts +8 -9
  49. package/dist/checkpointer/internal/write-guard.js +16 -16
  50. package/dist/checkpointer/internal/write-index.d.ts +8 -1
  51. package/dist/checkpointer/internal/write-index.js +6 -3
  52. package/dist/checkpointer/saver.d.ts +50 -10
  53. package/dist/checkpointer/saver.js +59 -17
  54. package/dist/checkpointer/types.d.ts +14 -1
  55. package/dist/checkpointer/types.js +0 -1
  56. package/dist/factory/factory.d.ts +22 -25
  57. package/dist/factory/factory.js +58 -18
  58. package/dist/factory/types.d.ts +57 -0
  59. package/dist/factory/types.js +2 -0
  60. package/dist/history/actions/add-messages.d.ts +1 -2
  61. package/dist/history/actions/add-messages.js +4 -4
  62. package/dist/history/actions/clear.d.ts +3 -2
  63. package/dist/history/actions/clear.js +5 -2
  64. package/dist/history/actions/get-messages.d.ts +13 -6
  65. package/dist/history/actions/get-messages.js +63 -42
  66. package/dist/history/actions/list-sessions.d.ts +1 -1
  67. package/dist/history/actions/list-sessions.js +8 -12
  68. package/dist/history/actions/reconcile-count.d.ts +1 -2
  69. package/dist/history/actions/reconcile-count.js +20 -7
  70. package/dist/history/chat-message-history.d.ts +51 -26
  71. package/dist/history/chat-message-history.js +60 -30
  72. package/dist/history/internal/append-saga.d.ts +7 -2
  73. package/dist/history/internal/append-saga.js +58 -14
  74. package/dist/history/internal/compensation.d.ts +6 -2
  75. package/dist/history/internal/compensation.js +14 -6
  76. package/dist/history/internal/item-mapper.d.ts +0 -3
  77. package/dist/history/internal/item-mapper.js +2 -8
  78. package/dist/history/internal/keys.d.ts +0 -1
  79. package/dist/history/internal/keys.js +0 -1
  80. package/dist/history/internal/message-chunker.d.ts +0 -1
  81. package/dist/history/internal/message-chunker.js +0 -1
  82. package/dist/history/internal/message-transaction.d.ts +0 -1
  83. package/dist/history/internal/message-transaction.js +3 -2
  84. package/dist/history/internal/message-window.d.ts +17 -0
  85. package/dist/history/internal/message-window.js +49 -0
  86. package/dist/history/internal/query.d.ts +16 -3
  87. package/dist/history/internal/query.js +13 -5
  88. package/dist/history/internal/session-count.d.ts +8 -2
  89. package/dist/history/internal/session-count.js +14 -8
  90. package/dist/history/internal/session-title.d.ts +0 -1
  91. package/dist/history/internal/session-title.js +1 -2
  92. package/dist/history/internal/session-update.d.ts +0 -1
  93. package/dist/history/internal/session-update.js +0 -1
  94. package/dist/history/internal/setup.d.ts +3 -1
  95. package/dist/history/internal/setup.js +16 -8
  96. package/dist/history/internal/title-generator.d.ts +0 -1
  97. package/dist/history/internal/title-generator.js +19 -3
  98. package/dist/history/internal/ttl-anchor.d.ts +1 -2
  99. package/dist/history/internal/ttl-anchor.js +5 -5
  100. package/dist/history/internal/validation.d.ts +19 -3
  101. package/dist/history/internal/validation.js +41 -4
  102. package/dist/history/session-adapter.d.ts +9 -3
  103. package/dist/history/session-adapter.js +6 -3
  104. package/dist/history/types.d.ts +23 -2
  105. package/dist/history/types.js +0 -1
  106. package/dist/index.d.ts +12 -5
  107. package/dist/index.js +5 -3
  108. package/dist/shared/clock.d.ts +6 -1
  109. package/dist/shared/clock.js +9 -1
  110. package/dist/shared/codec/codec.d.ts +26 -17
  111. package/dist/shared/codec/codec.js +46 -24
  112. package/dist/shared/codec/compression.d.ts +1 -2
  113. package/dist/shared/codec/compression.js +2 -3
  114. package/dist/shared/codec/descriptor-keys.d.ts +11 -3
  115. package/dist/shared/codec/descriptor-keys.js +2 -2
  116. package/dist/shared/codec/encode.d.ts +13 -0
  117. package/dist/shared/codec/encode.js +43 -0
  118. package/dist/shared/codec/json-serde.d.ts +0 -1
  119. package/dist/shared/codec/json-serde.js +0 -1
  120. package/dist/shared/codec/payload-loss.d.ts +12 -0
  121. package/dist/shared/codec/payload-loss.js +38 -0
  122. package/dist/shared/codec/s3/adapter-config.d.ts +13 -0
  123. package/dist/shared/codec/s3/adapter-config.js +22 -0
  124. package/dist/shared/codec/s3/bounded-body.d.ts +14 -0
  125. package/dist/shared/codec/s3/bounded-body.js +47 -0
  126. package/dist/shared/codec/s3/client-types.d.ts +34 -0
  127. package/dist/shared/codec/s3/client-types.js +7 -0
  128. package/dist/shared/codec/s3/client.d.ts +11 -5
  129. package/dist/shared/codec/s3/client.js +25 -3
  130. package/dist/shared/codec/s3/config.d.ts +32 -5
  131. package/dist/shared/codec/s3/config.js +37 -5
  132. package/dist/shared/codec/s3/delete.d.ts +0 -1
  133. package/dist/shared/codec/s3/delete.js +0 -1
  134. package/dist/shared/codec/s3/key-scope.d.ts +23 -0
  135. package/dist/shared/codec/s3/key-scope.js +44 -0
  136. package/dist/shared/codec/s3/lifecycle.d.ts +11 -5
  137. package/dist/shared/codec/s3/lifecycle.js +32 -16
  138. package/dist/shared/codec/s3/offloader.d.ts +6 -2
  139. package/dist/shared/codec/s3/offloader.js +21 -3
  140. package/dist/shared/codec/s3/orphans.d.ts +6 -1
  141. package/dist/shared/codec/s3/orphans.js +15 -2
  142. package/dist/shared/codec/s3/read-write.d.ts +7 -3
  143. package/dist/shared/codec/s3/read-write.js +16 -8
  144. package/dist/shared/codec/s3/retry.d.ts +4 -4
  145. package/dist/shared/codec/s3/retry.js +13 -16
  146. package/dist/shared/concurrency.d.ts +6 -0
  147. package/dist/shared/concurrency.js +30 -0
  148. package/dist/shared/constants.d.ts +68 -5
  149. package/dist/shared/constants.js +70 -7
  150. package/dist/shared/dynamodb/abort.d.ts +9 -0
  151. package/dist/shared/dynamodb/abort.js +27 -0
  152. package/dist/shared/dynamodb/backoff.d.ts +4 -4
  153. package/dist/shared/dynamodb/backoff.js +7 -7
  154. package/dist/shared/dynamodb/batch-write.d.ts +0 -1
  155. package/dist/shared/dynamodb/batch-write.js +0 -1
  156. package/dist/shared/dynamodb/cancellation.d.ts +0 -1
  157. package/dist/shared/dynamodb/cancellation.js +0 -1
  158. package/dist/shared/dynamodb/client.d.ts +9 -2
  159. package/dist/shared/dynamodb/client.js +24 -1
  160. package/dist/shared/dynamodb/conditional-put.d.ts +67 -0
  161. package/dist/shared/dynamodb/conditional-put.js +76 -0
  162. package/dist/shared/dynamodb/drain-unprocessed.d.ts +3 -1
  163. package/dist/shared/dynamodb/drain-unprocessed.js +1 -2
  164. package/dist/shared/dynamodb/expiry.d.ts +16 -0
  165. package/dist/shared/dynamodb/expiry.js +29 -0
  166. package/dist/shared/dynamodb/paginate-core.d.ts +5 -3
  167. package/dist/shared/dynamodb/paginate-core.js +47 -17
  168. package/dist/shared/dynamodb/paginate.d.ts +0 -1
  169. package/dist/shared/dynamodb/paginate.js +1 -2
  170. package/dist/shared/dynamodb/partition-delete.d.ts +7 -1
  171. package/dist/shared/dynamodb/partition-delete.js +4 -3
  172. package/dist/shared/dynamodb/retry-classifier.d.ts +10 -2
  173. package/dist/shared/dynamodb/retry-classifier.js +42 -11
  174. package/dist/shared/dynamodb/retry-policy.d.ts +26 -0
  175. package/dist/shared/dynamodb/retry-policy.js +22 -0
  176. package/dist/shared/dynamodb/retry.d.ts +14 -1
  177. package/dist/shared/dynamodb/retry.js +11 -7
  178. package/dist/shared/dynamodb/scan.d.ts +0 -1
  179. package/dist/shared/dynamodb/scan.js +1 -2
  180. package/dist/shared/dynamodb/types.d.ts +1 -2
  181. package/dist/shared/dynamodb/types.js +0 -1
  182. package/dist/shared/errors/base-error.d.ts +14 -6
  183. package/dist/shared/errors/base-error.js +8 -9
  184. package/dist/shared/errors/boundary.d.ts +18 -0
  185. package/dist/shared/errors/boundary.js +46 -0
  186. package/dist/shared/errors/error-code.d.ts +2 -2
  187. package/dist/shared/errors/error-code.js +1 -1
  188. package/dist/shared/errors/errors.d.ts +13 -13
  189. package/dist/shared/errors/errors.js +18 -16
  190. package/dist/shared/errors/upstream-error.d.ts +16 -0
  191. package/dist/shared/errors/upstream-error.js +27 -0
  192. package/dist/shared/errors/wrap-error.d.ts +0 -9
  193. package/dist/shared/errors/wrap-error.js +0 -15
  194. package/dist/shared/logging/logger.d.ts +6 -2
  195. package/dist/shared/logging/logger.js +0 -1
  196. package/dist/shared/logging/redaction-walk.d.ts +2 -2
  197. package/dist/shared/logging/redaction-walk.js +38 -18
  198. package/dist/shared/logging/redaction.d.ts +14 -6
  199. package/dist/shared/logging/redaction.js +19 -4
  200. package/dist/shared/logging/secret-patterns.d.ts +54 -3
  201. package/dist/shared/logging/secret-patterns.js +67 -8
  202. package/dist/shared/options.d.ts +9 -4
  203. package/dist/shared/options.js +0 -1
  204. package/dist/shared/ulid.d.ts +15 -2
  205. package/dist/shared/ulid.js +35 -3
  206. package/dist/shared/validation/options.d.ts +8 -0
  207. package/dist/shared/validation/options.js +90 -0
  208. package/dist/shared/validation/primitives.d.ts +14 -10
  209. package/dist/shared/validation/primitives.js +23 -25
  210. package/dist/shared/validation/ttl.d.ts +14 -7
  211. package/dist/shared/validation/ttl.js +29 -11
  212. package/dist/store/actions/get.d.ts +11 -3
  213. package/dist/store/actions/get.js +52 -14
  214. package/dist/store/actions/list-namespaces.d.ts +0 -1
  215. package/dist/store/actions/list-namespaces.js +10 -6
  216. package/dist/store/actions/put.d.ts +0 -1
  217. package/dist/store/actions/put.js +27 -28
  218. package/dist/store/actions/reconcile-vector-index.d.ts +3 -2
  219. package/dist/store/actions/reconcile-vector-index.js +2 -3
  220. package/dist/store/actions/search.d.ts +1 -2
  221. package/dist/store/actions/search.js +11 -38
  222. package/dist/store/internal/backend-search.d.ts +1 -2
  223. package/dist/store/internal/backend-search.js +14 -7
  224. package/dist/store/internal/batch-plan.d.ts +11 -0
  225. package/dist/store/internal/batch-plan.js +52 -0
  226. package/dist/store/internal/candidates.d.ts +23 -0
  227. package/dist/store/internal/candidates.js +94 -0
  228. package/dist/store/internal/filter.d.ts +0 -1
  229. package/dist/store/internal/filter.js +25 -6
  230. package/dist/store/internal/index-reconcile.d.ts +5 -6
  231. package/dist/store/internal/index-reconcile.js +32 -13
  232. package/dist/store/internal/index-sync.d.ts +0 -1
  233. package/dist/store/internal/index-sync.js +0 -1
  234. package/dist/store/internal/item-mapper.d.ts +6 -3
  235. package/dist/store/internal/item-mapper.js +16 -6
  236. package/dist/store/internal/keys.d.ts +0 -1
  237. package/dist/store/internal/keys.js +0 -1
  238. package/dist/store/internal/namespace-match.d.ts +0 -1
  239. package/dist/store/internal/namespace-match.js +0 -1
  240. package/dist/store/internal/option-validation.d.ts +13 -0
  241. package/dist/store/internal/option-validation.js +77 -0
  242. package/dist/store/internal/overwrite-swap.d.ts +32 -0
  243. package/dist/store/internal/overwrite-swap.js +68 -0
  244. package/dist/store/internal/persist.d.ts +24 -7
  245. package/dist/store/internal/persist.js +49 -19
  246. package/dist/store/internal/query.d.ts +6 -1
  247. package/dist/store/internal/query.js +17 -1
  248. package/dist/store/internal/ranker.d.ts +7 -2
  249. package/dist/store/internal/ranker.js +10 -2
  250. package/dist/store/internal/read-existing.d.ts +23 -0
  251. package/dist/store/internal/read-existing.js +41 -0
  252. package/dist/store/internal/score-direction.d.ts +31 -0
  253. package/dist/store/internal/score-direction.js +38 -0
  254. package/dist/store/internal/search-filter.d.ts +0 -1
  255. package/dist/store/internal/search-filter.js +0 -1
  256. package/dist/store/internal/semantic-search.d.ts +26 -5
  257. package/dist/store/internal/semantic-search.js +59 -19
  258. package/dist/store/internal/setup.d.ts +6 -12
  259. package/dist/store/internal/setup.js +12 -24
  260. package/dist/store/internal/text-path.d.ts +17 -0
  261. package/dist/store/internal/text-path.js +147 -0
  262. package/dist/store/internal/validation.d.ts +8 -3
  263. package/dist/store/internal/validation.js +21 -5
  264. package/dist/store/internal/write-verify.d.ts +27 -9
  265. package/dist/store/internal/write-verify.js +35 -19
  266. package/dist/store/store.d.ts +37 -9
  267. package/dist/store/store.js +52 -17
  268. package/dist/store/types.d.ts +22 -2
  269. package/dist/store/types.js +0 -1
  270. package/dist/store/vector-backend.d.ts +6 -7
  271. package/dist/store/vector-backend.js +0 -1
  272. package/package.json +21 -15
  273. package/dist/checkpointer/actions/delete-thread.d.ts.map +0 -1
  274. package/dist/checkpointer/actions/delete-thread.js.map +0 -1
  275. package/dist/checkpointer/actions/get-tuple.d.ts.map +0 -1
  276. package/dist/checkpointer/actions/get-tuple.js.map +0 -1
  277. package/dist/checkpointer/actions/list.d.ts.map +0 -1
  278. package/dist/checkpointer/actions/list.js.map +0 -1
  279. package/dist/checkpointer/actions/put-writes.d.ts.map +0 -1
  280. package/dist/checkpointer/actions/put-writes.js.map +0 -1
  281. package/dist/checkpointer/actions/put.d.ts.map +0 -1
  282. package/dist/checkpointer/actions/put.js.map +0 -1
  283. package/dist/checkpointer/internal/assemble.d.ts.map +0 -1
  284. package/dist/checkpointer/internal/assemble.js.map +0 -1
  285. package/dist/checkpointer/internal/configurable.d.ts.map +0 -1
  286. package/dist/checkpointer/internal/configurable.js.map +0 -1
  287. package/dist/checkpointer/internal/fetch.d.ts.map +0 -1
  288. package/dist/checkpointer/internal/fetch.js.map +0 -1
  289. package/dist/checkpointer/internal/filter-match.d.ts.map +0 -1
  290. package/dist/checkpointer/internal/filter-match.js.map +0 -1
  291. package/dist/checkpointer/internal/item-reader.d.ts.map +0 -1
  292. package/dist/checkpointer/internal/item-reader.js.map +0 -1
  293. package/dist/checkpointer/internal/item-writer.d.ts.map +0 -1
  294. package/dist/checkpointer/internal/item-writer.js.map +0 -1
  295. package/dist/checkpointer/internal/keys.d.ts.map +0 -1
  296. package/dist/checkpointer/internal/keys.js.map +0 -1
  297. package/dist/checkpointer/internal/query.d.ts.map +0 -1
  298. package/dist/checkpointer/internal/query.js.map +0 -1
  299. package/dist/checkpointer/internal/setup.d.ts.map +0 -1
  300. package/dist/checkpointer/internal/setup.js.map +0 -1
  301. package/dist/checkpointer/internal/special-write-cleanup.d.ts.map +0 -1
  302. package/dist/checkpointer/internal/special-write-cleanup.js.map +0 -1
  303. package/dist/checkpointer/internal/validation.d.ts.map +0 -1
  304. package/dist/checkpointer/internal/validation.js.map +0 -1
  305. package/dist/checkpointer/internal/write-guard.d.ts.map +0 -1
  306. package/dist/checkpointer/internal/write-guard.js.map +0 -1
  307. package/dist/checkpointer/internal/write-index.d.ts.map +0 -1
  308. package/dist/checkpointer/internal/write-index.js.map +0 -1
  309. package/dist/checkpointer/saver.d.ts.map +0 -1
  310. package/dist/checkpointer/saver.js.map +0 -1
  311. package/dist/checkpointer/types.d.ts.map +0 -1
  312. package/dist/checkpointer/types.js.map +0 -1
  313. package/dist/factory/factory.d.ts.map +0 -1
  314. package/dist/factory/factory.js.map +0 -1
  315. package/dist/history/actions/add-messages.d.ts.map +0 -1
  316. package/dist/history/actions/add-messages.js.map +0 -1
  317. package/dist/history/actions/clear.d.ts.map +0 -1
  318. package/dist/history/actions/clear.js.map +0 -1
  319. package/dist/history/actions/get-messages.d.ts.map +0 -1
  320. package/dist/history/actions/get-messages.js.map +0 -1
  321. package/dist/history/actions/list-sessions.d.ts.map +0 -1
  322. package/dist/history/actions/list-sessions.js.map +0 -1
  323. package/dist/history/actions/reconcile-count.d.ts.map +0 -1
  324. package/dist/history/actions/reconcile-count.js.map +0 -1
  325. package/dist/history/chat-message-history.d.ts.map +0 -1
  326. package/dist/history/chat-message-history.js.map +0 -1
  327. package/dist/history/internal/append-saga.d.ts.map +0 -1
  328. package/dist/history/internal/append-saga.js.map +0 -1
  329. package/dist/history/internal/compensation.d.ts.map +0 -1
  330. package/dist/history/internal/compensation.js.map +0 -1
  331. package/dist/history/internal/item-mapper.d.ts.map +0 -1
  332. package/dist/history/internal/item-mapper.js.map +0 -1
  333. package/dist/history/internal/keys.d.ts.map +0 -1
  334. package/dist/history/internal/keys.js.map +0 -1
  335. package/dist/history/internal/message-chunker.d.ts.map +0 -1
  336. package/dist/history/internal/message-chunker.js.map +0 -1
  337. package/dist/history/internal/message-transaction.d.ts.map +0 -1
  338. package/dist/history/internal/message-transaction.js.map +0 -1
  339. package/dist/history/internal/query.d.ts.map +0 -1
  340. package/dist/history/internal/query.js.map +0 -1
  341. package/dist/history/internal/session-count.d.ts.map +0 -1
  342. package/dist/history/internal/session-count.js.map +0 -1
  343. package/dist/history/internal/session-title.d.ts.map +0 -1
  344. package/dist/history/internal/session-title.js.map +0 -1
  345. package/dist/history/internal/session-update.d.ts.map +0 -1
  346. package/dist/history/internal/session-update.js.map +0 -1
  347. package/dist/history/internal/setup.d.ts.map +0 -1
  348. package/dist/history/internal/setup.js.map +0 -1
  349. package/dist/history/internal/title-generator.d.ts.map +0 -1
  350. package/dist/history/internal/title-generator.js.map +0 -1
  351. package/dist/history/internal/ttl-anchor.d.ts.map +0 -1
  352. package/dist/history/internal/ttl-anchor.js.map +0 -1
  353. package/dist/history/internal/validation.d.ts.map +0 -1
  354. package/dist/history/internal/validation.js.map +0 -1
  355. package/dist/history/session-adapter.d.ts.map +0 -1
  356. package/dist/history/session-adapter.js.map +0 -1
  357. package/dist/history/types.d.ts.map +0 -1
  358. package/dist/history/types.js.map +0 -1
  359. package/dist/index.d.ts.map +0 -1
  360. package/dist/index.js.map +0 -1
  361. package/dist/shared/clock.d.ts.map +0 -1
  362. package/dist/shared/clock.js.map +0 -1
  363. package/dist/shared/codec/codec.d.ts.map +0 -1
  364. package/dist/shared/codec/codec.js.map +0 -1
  365. package/dist/shared/codec/compression.d.ts.map +0 -1
  366. package/dist/shared/codec/compression.js.map +0 -1
  367. package/dist/shared/codec/descriptor-keys.d.ts.map +0 -1
  368. package/dist/shared/codec/descriptor-keys.js.map +0 -1
  369. package/dist/shared/codec/json-serde.d.ts.map +0 -1
  370. package/dist/shared/codec/json-serde.js.map +0 -1
  371. package/dist/shared/codec/s3/client.d.ts.map +0 -1
  372. package/dist/shared/codec/s3/client.js.map +0 -1
  373. package/dist/shared/codec/s3/config.d.ts.map +0 -1
  374. package/dist/shared/codec/s3/config.js.map +0 -1
  375. package/dist/shared/codec/s3/delete.d.ts.map +0 -1
  376. package/dist/shared/codec/s3/delete.js.map +0 -1
  377. package/dist/shared/codec/s3/lifecycle.d.ts.map +0 -1
  378. package/dist/shared/codec/s3/lifecycle.js.map +0 -1
  379. package/dist/shared/codec/s3/offloader.d.ts.map +0 -1
  380. package/dist/shared/codec/s3/offloader.js.map +0 -1
  381. package/dist/shared/codec/s3/orphans.d.ts.map +0 -1
  382. package/dist/shared/codec/s3/orphans.js.map +0 -1
  383. package/dist/shared/codec/s3/read-write.d.ts.map +0 -1
  384. package/dist/shared/codec/s3/read-write.js.map +0 -1
  385. package/dist/shared/codec/s3/retry.d.ts.map +0 -1
  386. package/dist/shared/codec/s3/retry.js.map +0 -1
  387. package/dist/shared/constants.d.ts.map +0 -1
  388. package/dist/shared/constants.js.map +0 -1
  389. package/dist/shared/dynamodb/backoff.d.ts.map +0 -1
  390. package/dist/shared/dynamodb/backoff.js.map +0 -1
  391. package/dist/shared/dynamodb/batch-write.d.ts.map +0 -1
  392. package/dist/shared/dynamodb/batch-write.js.map +0 -1
  393. package/dist/shared/dynamodb/cancellation.d.ts.map +0 -1
  394. package/dist/shared/dynamodb/cancellation.js.map +0 -1
  395. package/dist/shared/dynamodb/client.d.ts.map +0 -1
  396. package/dist/shared/dynamodb/client.js.map +0 -1
  397. package/dist/shared/dynamodb/drain-unprocessed.d.ts.map +0 -1
  398. package/dist/shared/dynamodb/drain-unprocessed.js.map +0 -1
  399. package/dist/shared/dynamodb/paginate-core.d.ts.map +0 -1
  400. package/dist/shared/dynamodb/paginate-core.js.map +0 -1
  401. package/dist/shared/dynamodb/paginate.d.ts.map +0 -1
  402. package/dist/shared/dynamodb/paginate.js.map +0 -1
  403. package/dist/shared/dynamodb/partition-delete.d.ts.map +0 -1
  404. package/dist/shared/dynamodb/partition-delete.js.map +0 -1
  405. package/dist/shared/dynamodb/retry-classifier.d.ts.map +0 -1
  406. package/dist/shared/dynamodb/retry-classifier.js.map +0 -1
  407. package/dist/shared/dynamodb/retry.d.ts.map +0 -1
  408. package/dist/shared/dynamodb/retry.js.map +0 -1
  409. package/dist/shared/dynamodb/scan.d.ts.map +0 -1
  410. package/dist/shared/dynamodb/scan.js.map +0 -1
  411. package/dist/shared/dynamodb/types.d.ts.map +0 -1
  412. package/dist/shared/dynamodb/types.js.map +0 -1
  413. package/dist/shared/errors/base-error.d.ts.map +0 -1
  414. package/dist/shared/errors/base-error.js.map +0 -1
  415. package/dist/shared/errors/error-code.d.ts.map +0 -1
  416. package/dist/shared/errors/error-code.js.map +0 -1
  417. package/dist/shared/errors/errors.d.ts.map +0 -1
  418. package/dist/shared/errors/errors.js.map +0 -1
  419. package/dist/shared/errors/wrap-error.d.ts.map +0 -1
  420. package/dist/shared/errors/wrap-error.js.map +0 -1
  421. package/dist/shared/logging/logger.d.ts.map +0 -1
  422. package/dist/shared/logging/logger.js.map +0 -1
  423. package/dist/shared/logging/redaction-walk.d.ts.map +0 -1
  424. package/dist/shared/logging/redaction-walk.js.map +0 -1
  425. package/dist/shared/logging/redaction.d.ts.map +0 -1
  426. package/dist/shared/logging/redaction.js.map +0 -1
  427. package/dist/shared/logging/secret-patterns.d.ts.map +0 -1
  428. package/dist/shared/logging/secret-patterns.js.map +0 -1
  429. package/dist/shared/options.d.ts.map +0 -1
  430. package/dist/shared/options.js.map +0 -1
  431. package/dist/shared/ulid.d.ts.map +0 -1
  432. package/dist/shared/ulid.js.map +0 -1
  433. package/dist/shared/validation/primitives.d.ts.map +0 -1
  434. package/dist/shared/validation/primitives.js.map +0 -1
  435. package/dist/shared/validation/ttl.d.ts.map +0 -1
  436. package/dist/shared/validation/ttl.js.map +0 -1
  437. package/dist/store/actions/get.d.ts.map +0 -1
  438. package/dist/store/actions/get.js.map +0 -1
  439. package/dist/store/actions/list-namespaces.d.ts.map +0 -1
  440. package/dist/store/actions/list-namespaces.js.map +0 -1
  441. package/dist/store/actions/put.d.ts.map +0 -1
  442. package/dist/store/actions/put.js.map +0 -1
  443. package/dist/store/actions/reconcile-vector-index.d.ts.map +0 -1
  444. package/dist/store/actions/reconcile-vector-index.js.map +0 -1
  445. package/dist/store/actions/search.d.ts.map +0 -1
  446. package/dist/store/actions/search.js.map +0 -1
  447. package/dist/store/internal/backend-search.d.ts.map +0 -1
  448. package/dist/store/internal/backend-search.js.map +0 -1
  449. package/dist/store/internal/filter.d.ts.map +0 -1
  450. package/dist/store/internal/filter.js.map +0 -1
  451. package/dist/store/internal/index-reconcile.d.ts.map +0 -1
  452. package/dist/store/internal/index-reconcile.js.map +0 -1
  453. package/dist/store/internal/index-sync.d.ts.map +0 -1
  454. package/dist/store/internal/index-sync.js.map +0 -1
  455. package/dist/store/internal/item-mapper.d.ts.map +0 -1
  456. package/dist/store/internal/item-mapper.js.map +0 -1
  457. package/dist/store/internal/keys.d.ts.map +0 -1
  458. package/dist/store/internal/keys.js.map +0 -1
  459. package/dist/store/internal/namespace-match.d.ts.map +0 -1
  460. package/dist/store/internal/namespace-match.js.map +0 -1
  461. package/dist/store/internal/persist.d.ts.map +0 -1
  462. package/dist/store/internal/persist.js.map +0 -1
  463. package/dist/store/internal/query.d.ts.map +0 -1
  464. package/dist/store/internal/query.js.map +0 -1
  465. package/dist/store/internal/ranker.d.ts.map +0 -1
  466. package/dist/store/internal/ranker.js.map +0 -1
  467. package/dist/store/internal/search-filter.d.ts.map +0 -1
  468. package/dist/store/internal/search-filter.js.map +0 -1
  469. package/dist/store/internal/semantic-search.d.ts.map +0 -1
  470. package/dist/store/internal/semantic-search.js.map +0 -1
  471. package/dist/store/internal/setup.d.ts.map +0 -1
  472. package/dist/store/internal/setup.js.map +0 -1
  473. package/dist/store/internal/validation.d.ts.map +0 -1
  474. package/dist/store/internal/validation.js.map +0 -1
  475. package/dist/store/internal/write-verify.d.ts.map +0 -1
  476. package/dist/store/internal/write-verify.js.map +0 -1
  477. package/dist/store/store.d.ts.map +0 -1
  478. package/dist/store/store.js.map +0 -1
  479. package/dist/store/types.d.ts.map +0 -1
  480. package/dist/store/types.js.map +0 -1
  481. package/dist/store/vector-backend.d.ts.map +0 -1
  482. package/dist/store/vector-backend.js.map +0 -1
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readListScope = readListScope;
4
+ exports.listQuery = listQuery;
5
+ exports.listScan = listScan;
6
+ exports.passesKeyFilters = passesKeyFilters;
7
+ exports.passesMetadataFilter = passesMetadataFilter;
8
+ const configurable_1 = require("./configurable");
9
+ const filter_match_1 = require("./filter-match");
10
+ const item_reader_1 = require("./item-reader");
11
+ const keys_1 = require("./keys");
12
+ const query_1 = require("./query");
13
+ const validation_1 = require("./validation");
14
+ /** The identifiers of a config that names no thread, validated the same way. */
15
+ function readThreadless(config) {
16
+ const checkpointNs = config.configurable?.checkpoint_ns ?? '';
17
+ (0, validation_1.validateCheckpointNs)(checkpointNs);
18
+ const rawId = config.configurable?.checkpoint_id;
19
+ const checkpointId = rawId ? rawId : undefined;
20
+ if (checkpointId !== undefined)
21
+ (0, validation_1.validateCheckpointId)(checkpointId);
22
+ return { threadId: '', checkpointNs, checkpointId };
23
+ }
24
+ /** The identifiers a list config names; a config without a thread is still validated for the ids it gives. */
25
+ function resolveListIds(config) {
26
+ if (config.configurable?.thread_id === undefined) {
27
+ return { ...readThreadless(config), threadId: undefined };
28
+ }
29
+ return (0, configurable_1.readConfigurable)(config);
30
+ }
31
+ /**
32
+ * Read the scope. Unlike `getTuple`, which addresses the root namespace when
33
+ * none is given, `list()` without a `checkpoint_ns` covers every namespace,
34
+ * and without a `thread_id` every thread, as the reference savers do; the
35
+ * identifiers that are given are validated either way.
36
+ */
37
+ function readListScope(config, options) {
38
+ const { threadId, checkpointNs, checkpointId } = resolveListIds(config);
39
+ return {
40
+ threadId,
41
+ checkpointNs: config.configurable?.checkpoint_ns === undefined ? undefined : checkpointNs,
42
+ checkpointId,
43
+ before: options?.before?.configurable?.checkpoint_id,
44
+ filter: options?.filter,
45
+ limit: options?.limit,
46
+ signal: config.signal,
47
+ };
48
+ }
49
+ /**
50
+ * The META query for a scope. A metadata filter means rows may be dropped
51
+ * client-side, so only an unfiltered list passes the caller's limit through as
52
+ * the page size. With an explicit namespace `before` bounds the key range so
53
+ * rows newer than it are never read; across namespaces ids do not share one
54
+ * order and `before` is applied in-process.
55
+ */
56
+ function listQuery(context, scope) {
57
+ const partition = (0, keys_1.partitionKey)(scope.threadId);
58
+ const limit = scope.filter === undefined ? scope.limit : undefined;
59
+ if (scope.checkpointNs === undefined) {
60
+ return (0, query_1.beginsWithQuery)(context.tableName, partition, (0, keys_1.metaAnyNamespacePrefix)(), { limit });
61
+ }
62
+ return (0, query_1.beginsWithQuery)(context.tableName, partition, (0, keys_1.metaSortKeyPrefix)(scope.checkpointNs), {
63
+ limit,
64
+ beforeSortKey: scope.before === undefined ? undefined : (0, keys_1.metaSortKey)(scope.checkpointNs, scope.before),
65
+ });
66
+ }
67
+ /**
68
+ * The table `Scan` a thread-less `list()` runs: every checkpointer META row,
69
+ * narrowed to one namespace when the caller gave one. It is what the
70
+ * reference savers do for a config without a thread, and on DynamoDB it costs
71
+ * a read of the whole table.
72
+ */
73
+ function listScan(context, scope) {
74
+ return {
75
+ TableName: context.tableName,
76
+ FilterExpression: 'begins_with(#pk, :pk) AND begins_with(#sk, :sk)',
77
+ ExpressionAttributeNames: { '#pk': 'PK', '#sk': 'SK' },
78
+ ExpressionAttributeValues: {
79
+ ':pk': (0, keys_1.checkpointerPartitionPrefix)(),
80
+ ':sk': scope.checkpointNs === undefined
81
+ ? (0, keys_1.metaAnyNamespacePrefix)()
82
+ : (0, keys_1.metaSortKeyPrefix)(scope.checkpointNs),
83
+ },
84
+ };
85
+ }
86
+ /**
87
+ * True when `meta` passes the key-level filters: strictly older than `before`,
88
+ * and — on a table scan, where the key condition cannot narrow them — in the
89
+ * requested namespace and, when one is given, the requested checkpoint.
90
+ */
91
+ function passesKeyFilters(meta, scope) {
92
+ return ((scope.before === undefined || meta.checkpointId < scope.before) &&
93
+ (scope.checkpointNs === undefined || meta.checkpointNs === scope.checkpointNs) &&
94
+ (scope.checkpointId === undefined || meta.checkpointId === scope.checkpointId));
95
+ }
96
+ /**
97
+ * Apply the optional metadata-equality filter. The metadata decoded here is
98
+ * handed to the tuple assembly, so a filtered list decodes (and, when offloaded,
99
+ * downloads) each metadata blob once instead of twice.
100
+ */
101
+ async function passesMetadataFilter(context, meta, scope) {
102
+ if (!scope.filter)
103
+ return { pass: true };
104
+ const metadata = await (0, item_reader_1.readMetadata)(context, meta, meta.threadId);
105
+ return (0, filter_match_1.matchesFilter)(metadata, scope.filter)
106
+ ? { pass: true, metadata }
107
+ : { pass: false };
108
+ }
@@ -0,0 +1,13 @@
1
+ import { type Checkpoint } from '@langchain/langgraph-checkpoint';
2
+ import { type ReadOptions } from './fetch';
3
+ import type { CheckpointerContext } from './setup';
4
+ /**
5
+ * Pre-v4 checkpoints kept a task's `Send`s as `__pregel_tasks` pending writes
6
+ * on the parent rather than in the checkpoint itself. Reading such a
7
+ * checkpoint rebuilds `channel_values[TASKS]` from those writes and stamps
8
+ * the channel with the highest version the checkpoint already carries (or
9
+ * the first version when it carries none), exactly as the reference savers
10
+ * do, so a thread written before LangGraph 0.2 still resumes. A v4 checkpoint,
11
+ * or one without a parent, is returned untouched.
12
+ */
13
+ export declare function migratePendingSends(context: CheckpointerContext, checkpoint: Checkpoint, threadId: string, checkpointNs: string, parentCheckpointId: string | undefined, read: ReadOptions): Promise<Checkpoint>;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.migratePendingSends = migratePendingSends;
4
+ const langgraph_checkpoint_1 = require("@langchain/langgraph-checkpoint");
5
+ const fetch_1 = require("./fetch");
6
+ /**
7
+ * Pre-v4 checkpoints kept a task's `Send`s as `__pregel_tasks` pending writes
8
+ * on the parent rather than in the checkpoint itself. Reading such a
9
+ * checkpoint rebuilds `channel_values[TASKS]` from those writes and stamps
10
+ * the channel with the highest version the checkpoint already carries (or
11
+ * the first version when it carries none), exactly as the reference savers
12
+ * do, so a thread written before LangGraph 0.2 still resumes. A v4 checkpoint,
13
+ * or one without a parent, is returned untouched.
14
+ */
15
+ async function migratePendingSends(context, checkpoint, threadId, checkpointNs, parentCheckpointId, read) {
16
+ if (checkpoint.v >= 4 || parentCheckpointId === undefined)
17
+ return checkpoint;
18
+ const writes = await (0, fetch_1.fetchPendingWrites)(context, threadId, checkpointNs, parentCheckpointId, read);
19
+ const sends = writes.filter(([, channel]) => channel === langgraph_checkpoint_1.TASKS).map(([, , value]) => value);
20
+ const versions = Object.values(checkpoint.channel_versions);
21
+ return {
22
+ ...checkpoint,
23
+ channel_values: { ...checkpoint.channel_values, [langgraph_checkpoint_1.TASKS]: sends },
24
+ channel_versions: {
25
+ ...checkpoint.channel_versions,
26
+ [langgraph_checkpoint_1.TASKS]: versions.length > 0 ? (0, langgraph_checkpoint_1.maxChannelVersion)(...versions) : 1,
27
+ },
28
+ };
29
+ }
@@ -6,6 +6,8 @@ export interface PartitionQueryOptions {
6
6
  /** Options for {@link beginsWithQuery}. */
7
7
  export interface BeginsWithQueryOptions {
8
8
  limit?: number;
9
+ /** Inclusive upper bound on the sort key; turns the prefix match into a `BETWEEN`. */
10
+ beforeSortKey?: string;
9
11
  ascending?: boolean;
10
12
  consistent?: boolean;
11
13
  }
@@ -17,4 +19,3 @@ export declare function partitionQuery(tableName: string, partition: string, opt
17
19
  * never appear bare. Defaults to newest-first ordering.
18
20
  */
19
21
  export declare function beginsWithQuery(tableName: string, partition: string, skPrefix: string, options?: BeginsWithQueryOptions): QueryCommandInput;
20
- //# sourceMappingURL=query.d.ts.map
@@ -20,11 +20,18 @@ function partitionQuery(tableName, partition, options = {}) {
20
20
  * never appear bare. Defaults to newest-first ordering.
21
21
  */
22
22
  function beginsWithQuery(tableName, partition, skPrefix, options = {}) {
23
+ const bounded = options.beforeSortKey !== undefined;
23
24
  const params = {
24
25
  TableName: tableName,
25
- KeyConditionExpression: '#pk = :pk AND begins_with(#sk, :skPrefix)',
26
+ KeyConditionExpression: bounded
27
+ ? '#pk = :pk AND #sk BETWEEN :skPrefix AND :before'
28
+ : '#pk = :pk AND begins_with(#sk, :skPrefix)',
26
29
  ExpressionAttributeNames: { '#pk': 'PK', '#sk': 'SK' },
27
- ExpressionAttributeValues: { ':pk': partition, ':skPrefix': skPrefix },
30
+ ExpressionAttributeValues: {
31
+ ':pk': partition,
32
+ ':skPrefix': skPrefix,
33
+ ...(bounded ? { ':before': options.beforeSortKey } : {}),
34
+ },
28
35
  ScanIndexForward: options.ascending ?? false,
29
36
  };
30
37
  if (options.limit !== undefined)
@@ -33,4 +40,3 @@ function beginsWithQuery(tableName, partition, skPrefix, options = {}) {
33
40
  params.ConsistentRead = true;
34
41
  return params;
35
42
  }
36
- //# sourceMappingURL=query.js.map
@@ -0,0 +1,28 @@
1
+ import type { CheckpointWriteItem } from '../types';
2
+ import type { CheckpointerContext } from './setup';
3
+ /**
4
+ * Outcome of {@link writeRegularItems}: never rejects. `deadUploads` holds
5
+ * exactly the items whose own S3 upload is confirmed unreferenced — a
6
+ * verified non-commit, or a guard rejection whose returned row provably
7
+ * belongs to another call — and is therefore safe to delete. Everything else
8
+ * either committed, was turned away by a row this call may have written
9
+ * itself, or could not be verified; none of those may be cleaned up.
10
+ */
11
+ export interface RegularWriteOutcome {
12
+ deadUploads: CheckpointWriteItem[];
13
+ error?: Error;
14
+ }
15
+ /**
16
+ * Write regular items with a first-write-wins guard. Every `PutCommand` fully
17
+ * settles (`Promise.allSettled`) before this resolves and never rejects; a
18
+ * genuine failure is reported via `error`, not thrown.
19
+ *
20
+ * A failure is not proof of a non-commit: `withDynamoDBRetry` re-issues a put
21
+ * whose response was lost, and the re-issues can time out at the transport, so
22
+ * the budget is spent on a `RetryExhaustedError` while the row is live.
23
+ * Treating that as "never reached DynamoDB" deleted the object the live row
24
+ * pointed at, making the checkpoint's pending writes unreadable forever. Each
25
+ * such failure is therefore verified against the row before it is classified,
26
+ * and a committed one is not an error at all.
27
+ */
28
+ export declare function writeRegularItems(context: CheckpointerContext, items: CheckpointWriteItem[], signal?: AbortSignal): Promise<RegularWriteOutcome>;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeRegularItems = writeRegularItems;
4
+ const conditional_put_1 = require("../../shared/dynamodb/conditional-put");
5
+ const retry_1 = require("../../shared/dynamodb/retry");
6
+ const retry_policy_1 = require("../../shared/dynamodb/retry-policy");
7
+ const special_write_verify_1 = require("./special-write-verify");
8
+ const write_guard_1 = require("./write-guard");
9
+ /**
10
+ * Resolve a non-guard failure by reading the row back. Without an offloader
11
+ * there is no object to protect, so the write is simply reported as not
12
+ * committed and the caller's cleanup is a no-op. The row holding this call's
13
+ * own `writeGroup` means the put landed and only its response was lost.
14
+ */
15
+ async function verifyFailure(context, item) {
16
+ if (!context.offloader)
17
+ return 'not-committed';
18
+ try {
19
+ const observed = await (0, special_write_verify_1.readSpecialRow)(context, item);
20
+ return observed.revision === item.writeGroup ? 'committed' : 'not-committed';
21
+ }
22
+ catch {
23
+ return 'unverified';
24
+ }
25
+ }
26
+ /**
27
+ * Write regular items with a first-write-wins guard. Every `PutCommand` fully
28
+ * settles (`Promise.allSettled`) before this resolves and never rejects; a
29
+ * genuine failure is reported via `error`, not thrown.
30
+ *
31
+ * A failure is not proof of a non-commit: `withDynamoDBRetry` re-issues a put
32
+ * whose response was lost, and the re-issues can time out at the transport, so
33
+ * the budget is spent on a `RetryExhaustedError` while the row is live.
34
+ * Treating that as "never reached DynamoDB" deleted the object the live row
35
+ * pointed at, making the checkpoint's pending writes unreadable forever. Each
36
+ * such failure is therefore verified against the row before it is classified,
37
+ * and a committed one is not an error at all.
38
+ */
39
+ async function writeRegularItems(context, items, signal) {
40
+ const results = await Promise.allSettled(items.map((item) => (0, retry_1.withDynamoDBRetry)(() => context.client.put({
41
+ TableName: context.tableName,
42
+ Item: item,
43
+ ConditionExpression: 'attribute_not_exists(PK)',
44
+ ReturnValuesOnConditionCheckFailure: 'ALL_OLD',
45
+ }), (0, retry_policy_1.retryFor)(context, signal))));
46
+ const outcome = { deadUploads: [] };
47
+ for (const [index, result] of results.entries()) {
48
+ if (result.status === 'fulfilled')
49
+ continue;
50
+ const item = items[index];
51
+ const reason = result.reason;
52
+ if ((0, conditional_put_1.isConditionalCheckFailed)(reason)) {
53
+ (0, write_guard_1.reportGuardRejection)(context, item, reason);
54
+ if ((0, write_guard_1.rejectionProvesForeignRow)(item, reason))
55
+ outcome.deadUploads.push(item);
56
+ continue;
57
+ }
58
+ const verdict = await verifyFailure(context, item);
59
+ if (verdict === 'committed')
60
+ continue;
61
+ if (verdict === 'not-committed')
62
+ outcome.deadUploads.push(item);
63
+ outcome.error = outcome.error ?? reason;
64
+ }
65
+ return outcome;
66
+ }
@@ -3,6 +3,7 @@ import type { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
3
3
  import type { SerializerProtocol } from '@langchain/langgraph-checkpoint';
4
4
  import type { CompressionConfig } from '../../shared/codec/compression';
5
5
  import { S3Offloader } from '../../shared/codec/s3/offloader';
6
+ import type { RetryOptions } from '../../shared/dynamodb/retry';
6
7
  import { type Logger } from '../../shared/logging/logger';
7
8
  import type { TtlOption } from '../../shared/validation/ttl';
8
9
  import type { DynamoDBSaverOptions } from '../types';
@@ -15,6 +16,8 @@ export interface CheckpointerContext {
15
16
  offloader?: S3Offloader;
16
17
  ttl?: TtlOption;
17
18
  logger: Logger;
19
+ /** Retry budget and backoff for every DynamoDB call, with the retry debug log attached. */
20
+ retry?: RetryOptions;
18
21
  }
19
22
  /** Result of wiring up a checkpointer from its options. */
20
23
  export interface CheckpointerSetup {
@@ -28,4 +31,3 @@ export interface CheckpointerSetup {
28
31
  * tear resources down.
29
32
  */
30
33
  export declare function setUpCheckpointer(options: DynamoDBSaverOptions, serde: SerializerProtocol): CheckpointerSetup;
31
- //# sourceMappingURL=setup.d.ts.map
@@ -1,23 +1,25 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.setUpCheckpointer = setUpCheckpointer;
4
- const config_1 = require("../../shared/codec/s3/config");
4
+ const adapter_config_1 = require("../../shared/codec/s3/adapter-config");
5
5
  const offloader_1 = require("../../shared/codec/s3/offloader");
6
- const constants_1 = require("../../shared/constants");
7
6
  const client_1 = require("../../shared/dynamodb/client");
7
+ const retry_policy_1 = require("../../shared/dynamodb/retry-policy");
8
8
  const logger_1 = require("../../shared/logging/logger");
9
+ const options_1 = require("../../shared/validation/options");
9
10
  /**
10
11
  * Resolve the DynamoDB client, optional S3 offloader, and logging into the
11
12
  * context every action receives, plus the ownership info the class needs to
12
13
  * tear resources down.
13
14
  */
14
15
  function setUpCheckpointer(options, serde) {
16
+ (0, options_1.validateBaseAdapterOptions)(options);
17
+ const logger = (0, logger_1.resolveLogger)(options.logger);
15
18
  const resolved = (0, client_1.resolveDynamoDBClient)(options);
19
+ if (!resolved.ownsClient)
20
+ void (0, client_1.warnOnStackedRetries)(resolved.client, logger);
16
21
  const offloader = options.s3
17
- ? new offloader_1.S3Offloader({
18
- ...options.s3,
19
- keyPrefix: options.s3.keyPrefix ?? (0, config_1.defaultAdapterKeyPrefix)(constants_1.DEFAULT_S3_KEY_PREFIX, 'checkpointer'),
20
- })
22
+ ? new offloader_1.S3Offloader((0, adapter_config_1.offloaderConfigFor)(options.s3, 'checkpointer', options.clientConfig))
21
23
  : undefined;
22
24
  return {
23
25
  context: {
@@ -27,10 +29,10 @@ function setUpCheckpointer(options, serde) {
27
29
  compression: options.compression,
28
30
  offloader,
29
31
  ttl: options.ttl,
30
- logger: (0, logger_1.resolveLogger)(options.logger),
32
+ logger,
33
+ retry: (0, retry_policy_1.resolveRetryPolicy)(options.retry, logger),
31
34
  },
32
35
  ddbClient: resolved.ddbClient,
33
36
  ownsClient: resolved.ownsClient,
34
37
  };
35
38
  }
36
- //# sourceMappingURL=setup.js.map
@@ -0,0 +1,29 @@
1
+ import type { CheckpointWriteItem } from '../types';
2
+ import type { CheckpointerContext } from './setup';
3
+ import { type SpecialWriteOutcome } from './special-write-verify';
4
+ /**
5
+ * Overwrite one special row, pinned to the `writeGroup` this call observed, and
6
+ * report the descriptor it superseded.
7
+ *
8
+ * Overwriting is correct for special channels — every reference implementation
9
+ * does it — but two concurrent calls to the same channel both read the same
10
+ * previous descriptor and both delete it, orphaning the loser's upload. Pinning
11
+ * the observed `writeGroup` and re-reading on rejection makes each call
12
+ * supersede exactly one payload.
13
+ *
14
+ * `BatchWriteItem` cannot carry conditions, which is why this path issues
15
+ * individual puts; a call holds at most one row per special channel, so that is
16
+ * four writes at worst.
17
+ *
18
+ * The compare-and-swap runs only when an offloader is configured — matching
19
+ * `store/internal/persist.ts` — because without one there is no S3 object to
20
+ * orphan, so a plain unconditional put stays correct and costs no extra
21
+ * ConsistentRead or write capacity. That shortcut is also why the surviving
22
+ * `catch` may report `committed: false` without verifying: with no offloader
23
+ * there is no object for the caller to delete on the strength of it.
24
+ *
25
+ * Never rejects: the caller runs this concurrently with the regular writes
26
+ * under `Promise.all`, whose own cleanup depends on every branch resolving
27
+ * rather than short-circuiting.
28
+ */
29
+ export declare function writeSpecialItem(context: CheckpointerContext, item: CheckpointWriteItem, signal?: AbortSignal): Promise<SpecialWriteOutcome>;
@@ -0,0 +1,104 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.writeSpecialItem = writeSpecialItem;
4
+ const conditional_put_1 = require("../../shared/dynamodb/conditional-put");
5
+ const retry_1 = require("../../shared/dynamodb/retry");
6
+ const retry_policy_1 = require("../../shared/dynamodb/retry-policy");
7
+ const special_write_verify_1 = require("./special-write-verify");
8
+ /**
9
+ * Retry a conditional put up to {@link OVERWRITE_CAS_MAX_ATTEMPTS} times,
10
+ * re-reading the row each time a racer's write invalidates the pinned
11
+ * `writeGroup`. Extracted from {@link writeSpecialItem} to keep both
12
+ * functions under the repo's block-nesting limit.
13
+ *
14
+ * A rejection is not proof a competitor won: `withDynamoDBRetry` retries
15
+ * transient errors, so an attempt can commit server-side, its response can be
16
+ * lost, and the retried put can hit the row it just wrote and fail the same
17
+ * guard — indistinguishable from a competitor's win by the rejection alone.
18
+ * Each attempt's pinned observation is captured in `attempted` before the
19
+ * put, so that when {@link verifyAfterFailure} finds the row already holding
20
+ * *this item's own* `writeGroup`, the outcome reports having superseded
21
+ * whatever `attempted` held — never the item's own just-committed payload,
22
+ * which would strand the live row pointing at a deleted object.
23
+ *
24
+ * Only a rejection whose re-read proves some *other* writer holds the row is
25
+ * retried; every other failure is already settled by the verification.
26
+ */
27
+ async function attemptCasWrites(context, item, initial, signal) {
28
+ let observed = initial;
29
+ for (let attempt = 1; attempt <= conditional_put_1.OVERWRITE_CAS_MAX_ATTEMPTS; attempt++) {
30
+ const attempted = observed;
31
+ try {
32
+ await (0, retry_1.withDynamoDBRetry)(() => context.client.put({
33
+ TableName: context.tableName,
34
+ Item: item,
35
+ ...(0, conditional_put_1.revisionGuard)(special_write_verify_1.SPECIAL_REVISION_ATTRIBUTE, attempted),
36
+ }), (0, retry_policy_1.retryFor)(context, signal));
37
+ return { done: true, outcome: { committed: true, superseded: attempted.value } };
38
+ }
39
+ catch (error) {
40
+ const verified = await (0, special_write_verify_1.verifyAfterFailure)(context, item, attempted, error);
41
+ if (!verified.observed || !(0, conditional_put_1.isConditionalCheckFailed)(error)) {
42
+ return { done: true, outcome: verified.outcome };
43
+ }
44
+ observed = verified.observed;
45
+ }
46
+ }
47
+ return { done: false, observed };
48
+ }
49
+ /**
50
+ * Overwrite the row unconditionally once the compare-and-swap budget is spent,
51
+ * verifying rather than assuming if that put fails too.
52
+ */
53
+ async function overwriteUnconditionally(context, item, observed, signal) {
54
+ try {
55
+ await (0, retry_1.withDynamoDBRetry)(() => context.client.put({ TableName: context.tableName, Item: item }), (0, retry_policy_1.retryFor)(context, signal));
56
+ return { committed: true, superseded: observed.value };
57
+ }
58
+ catch (error) {
59
+ return (await (0, special_write_verify_1.verifyAfterFailure)(context, item, observed, error)).outcome;
60
+ }
61
+ }
62
+ /**
63
+ * Overwrite one special row, pinned to the `writeGroup` this call observed, and
64
+ * report the descriptor it superseded.
65
+ *
66
+ * Overwriting is correct for special channels — every reference implementation
67
+ * does it — but two concurrent calls to the same channel both read the same
68
+ * previous descriptor and both delete it, orphaning the loser's upload. Pinning
69
+ * the observed `writeGroup` and re-reading on rejection makes each call
70
+ * supersede exactly one payload.
71
+ *
72
+ * `BatchWriteItem` cannot carry conditions, which is why this path issues
73
+ * individual puts; a call holds at most one row per special channel, so that is
74
+ * four writes at worst.
75
+ *
76
+ * The compare-and-swap runs only when an offloader is configured — matching
77
+ * `store/internal/persist.ts` — because without one there is no S3 object to
78
+ * orphan, so a plain unconditional put stays correct and costs no extra
79
+ * ConsistentRead or write capacity. That shortcut is also why the surviving
80
+ * `catch` may report `committed: false` without verifying: with no offloader
81
+ * there is no object for the caller to delete on the strength of it.
82
+ *
83
+ * Never rejects: the caller runs this concurrently with the regular writes
84
+ * under `Promise.all`, whose own cleanup depends on every branch resolving
85
+ * rather than short-circuiting.
86
+ */
87
+ async function writeSpecialItem(context, item, signal) {
88
+ try {
89
+ if (!context.offloader) {
90
+ await (0, retry_1.withDynamoDBRetry)(() => context.client.put({ TableName: context.tableName, Item: item }), (0, retry_policy_1.retryFor)(context, signal));
91
+ return { committed: true };
92
+ }
93
+ const initial = await (0, special_write_verify_1.readSpecialRow)(context, item);
94
+ const attempt = await attemptCasWrites(context, item, initial, signal);
95
+ if (attempt.done)
96
+ return attempt.outcome;
97
+ context.logger.warn('putWrites: special-write compare-and-swap exhausted; overwriting unconditionally, which ' +
98
+ 'can orphan one S3 object under a concurrent call (reclaimed by ensureS3LifecycleRule)', { sortKey: item.SK, channel: item.channel, attempts: conditional_put_1.OVERWRITE_CAS_MAX_ATTEMPTS });
99
+ return await overwriteUnconditionally(context, item, attempt.observed, signal);
100
+ }
101
+ catch (error) {
102
+ return { committed: false, error: error };
103
+ }
104
+ }
@@ -1,18 +1,23 @@
1
1
  import type { CheckpointWriteItem } from '../types';
2
2
  import type { CheckpointerContext } from './setup';
3
3
  /**
4
- * Write special (negative-index) items unconditionally — overwrite is
5
- * correct there, matching every reference checkpointer implementation. When
6
- * an offloader is configured, reads each item's previous descriptor first,
7
- * so a settled outcome can clean up the correct side: the previous
8
- * descriptor on success, each new upload on a confirmed non-commit (batch
9
- * write failed, or the previous-descriptor read itself failed before the
10
- * batch write was even attempted), neither when the outcome is genuinely
11
- * ambiguous (see {@link splitSpecialOutcome}). Never rejects — a failed read
12
- * is reported the same way a failed write is, via the return value —
13
- * because the caller runs this concurrently with writeRegularItems via
14
- * `Promise.all`, whose own regular-write cleanup depends on every branch of
15
- * that `Promise.all` resolving rather than short-circuiting on a reject.
4
+ * Write special (negative-index) items, then clean up the correct side of each.
5
+ *
6
+ * Overwrite is correct here, matching every reference checkpointer. Each item
7
+ * is written with a compare-and-swap on its row's `writeGroup` (see
8
+ * {@link writeSpecialItem}) so a concurrent call to the same special channel
9
+ * cannot make both callers delete the same superseded object and orphan one
10
+ * upload. A committed item cleans up the payload it actually superseded; an
11
+ * item confirmed never to have committed cleans up its own new upload.
12
+ *
13
+ * "Confirmed" is load-bearing, and {@link writeSpecialItem} is what earns it:
14
+ * an ambiguous failure is verified against the row and reported as committed
15
+ * unless the read proves otherwise. Deleting on *unknown* would strand a live
16
+ * row pointing at a deleted object; leaking one object instead is recoverable.
17
+ *
18
+ * Never rejects — a failure is reported via the return value, because the
19
+ * caller runs this concurrently with `writeRegularItems` under `Promise.all`,
20
+ * whose own cleanup depends on every branch resolving rather than
21
+ * short-circuiting.
16
22
  */
17
- export declare function writeSpecialItemsWithCleanup(context: CheckpointerContext, items: CheckpointWriteItem[]): Promise<Error | undefined>;
18
- //# sourceMappingURL=special-write-cleanup.d.ts.map
23
+ export declare function writeSpecialItemsWithCleanup(context: CheckpointerContext, threadId: string, items: CheckpointWriteItem[], signal?: AbortSignal): Promise<Error | undefined>;