@farukada/aws-langgraph-dynamodb-ts 0.9.0 → 1.0.0-rc.2

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 (512) hide show
  1. package/README.md +1720 -154
  2. package/dist/backfill/backfill.d.ts +168 -0
  3. package/dist/backfill/backfill.js +393 -0
  4. package/dist/checkpointer/actions/delete-thread.d.ts +47 -6
  5. package/dist/checkpointer/actions/delete-thread.js +58 -21
  6. package/dist/checkpointer/actions/get-tuple.d.ts +29 -4
  7. package/dist/checkpointer/actions/get-tuple.js +44 -10
  8. package/dist/checkpointer/actions/list.d.ts +46 -4
  9. package/dist/checkpointer/actions/list.js +121 -66
  10. package/dist/checkpointer/actions/put-writes.d.ts +41 -9
  11. package/dist/checkpointer/actions/put-writes.js +62 -77
  12. package/dist/checkpointer/actions/put.d.ts +83 -4
  13. package/dist/checkpointer/actions/put.js +177 -25
  14. package/dist/checkpointer/internal/delta-history.d.ts +112 -0
  15. package/dist/checkpointer/internal/delta-history.js +252 -0
  16. package/dist/checkpointer/internal/listing.d.ts +149 -0
  17. package/dist/checkpointer/internal/listing.js +245 -0
  18. package/dist/checkpointer/internal/parse.d.ts +262 -0
  19. package/dist/checkpointer/internal/parse.js +372 -0
  20. package/dist/checkpointer/internal/pending-writes.d.ts +275 -0
  21. package/dist/checkpointer/internal/pending-writes.js +588 -0
  22. package/dist/checkpointer/internal/read.d.ts +130 -0
  23. package/dist/checkpointer/internal/read.js +264 -0
  24. package/dist/checkpointer/internal/rows.d.ts +571 -0
  25. package/dist/checkpointer/internal/rows.js +834 -0
  26. package/dist/checkpointer/internal/setup.d.ts +42 -19
  27. package/dist/checkpointer/internal/setup.js +65 -29
  28. package/dist/checkpointer/saver.d.ts +256 -16
  29. package/dist/checkpointer/saver.js +275 -29
  30. package/dist/checkpointer/types.d.ts +39 -39
  31. package/dist/checkpointer/types.js +10 -1
  32. package/dist/factory/factory.d.ts +134 -28
  33. package/dist/factory/factory.js +240 -21
  34. package/dist/factory/types.d.ts +76 -0
  35. package/dist/factory/types.js +10 -0
  36. package/dist/history/actions/add-messages.d.ts +31 -4
  37. package/dist/history/actions/add-messages.js +38 -58
  38. package/dist/history/actions/clear.d.ts +49 -6
  39. package/dist/history/actions/clear.js +66 -14
  40. package/dist/history/actions/get-messages.d.ts +54 -6
  41. package/dist/history/actions/get-messages.js +126 -43
  42. package/dist/history/actions/list-sessions.d.ts +52 -10
  43. package/dist/history/actions/list-sessions.js +139 -40
  44. package/dist/history/actions/reconcile-count.d.ts +42 -10
  45. package/dist/history/actions/reconcile-count.js +45 -45
  46. package/dist/history/chat-message-history.d.ts +220 -33
  47. package/dist/history/chat-message-history.js +240 -43
  48. package/dist/history/internal/append.d.ts +212 -0
  49. package/dist/history/internal/append.js +500 -0
  50. package/dist/history/internal/message-read.d.ts +84 -0
  51. package/dist/history/internal/message-read.js +204 -0
  52. package/dist/history/internal/parse.d.ts +153 -0
  53. package/dist/history/internal/parse.js +252 -0
  54. package/dist/history/internal/rows.d.ts +195 -0
  55. package/dist/history/internal/rows.js +250 -0
  56. package/dist/history/internal/session.d.ts +331 -0
  57. package/dist/history/internal/session.js +628 -0
  58. package/dist/history/internal/setup.d.ts +52 -17
  59. package/dist/history/internal/setup.js +92 -21
  60. package/dist/history/session-adapter.d.ts +102 -7
  61. package/dist/history/session-adapter.js +103 -9
  62. package/dist/history/types.d.ts +80 -29
  63. package/dist/history/types.js +10 -1
  64. package/dist/index.d.ts +42 -11
  65. package/dist/index.js +33 -12
  66. package/dist/shared/adapter.d.ts +135 -0
  67. package/dist/shared/adapter.js +143 -0
  68. package/dist/shared/clock.d.ts +51 -2
  69. package/dist/shared/clock.js +57 -2
  70. package/dist/shared/codec/codec.d.ts +288 -13
  71. package/dist/shared/codec/codec.js +416 -19
  72. package/dist/shared/codec/compression.d.ts +43 -7
  73. package/dist/shared/codec/compression.js +53 -13
  74. package/dist/shared/codec/json-serde.d.ts +76 -4
  75. package/dist/shared/codec/json-serde.js +181 -8
  76. package/dist/shared/codec/s3/client-types.d.ts +53 -0
  77. package/dist/shared/codec/s3/client-types.js +26 -0
  78. package/dist/shared/codec/s3/client.d.ts +43 -10
  79. package/dist/shared/codec/s3/client.js +82 -9
  80. package/dist/shared/codec/s3/config.d.ts +242 -11
  81. package/dist/shared/codec/s3/config.js +293 -11
  82. package/dist/shared/codec/s3/lifecycle.d.ts +164 -6
  83. package/dist/shared/codec/s3/lifecycle.js +335 -27
  84. package/dist/shared/codec/s3/offloader.d.ts +393 -18
  85. package/dist/shared/codec/s3/offloader.js +595 -37
  86. package/dist/shared/concurrency.d.ts +43 -0
  87. package/dist/shared/concurrency.js +78 -0
  88. package/dist/shared/dynamodb/abort.d.ts +47 -0
  89. package/dist/shared/dynamodb/abort.js +59 -0
  90. package/dist/shared/dynamodb/batch-write.d.ts +77 -14
  91. package/dist/shared/dynamodb/batch-write.js +146 -27
  92. package/dist/shared/dynamodb/cancellation.d.ts +121 -4
  93. package/dist/shared/dynamodb/cancellation.js +147 -3
  94. package/dist/shared/dynamodb/client.d.ts +162 -8
  95. package/dist/shared/dynamodb/client.js +153 -5
  96. package/dist/shared/dynamodb/idempotent-write.d.ts +551 -0
  97. package/dist/shared/dynamodb/idempotent-write.js +593 -0
  98. package/dist/shared/dynamodb/paginate.d.ts +105 -9
  99. package/dist/shared/dynamodb/paginate.js +175 -7
  100. package/dist/shared/dynamodb/partition-delete.d.ts +185 -14
  101. package/dist/shared/dynamodb/partition-delete.js +314 -44
  102. package/dist/shared/dynamodb/recency-index.d.ts +231 -0
  103. package/dist/shared/dynamodb/recency-index.js +377 -0
  104. package/dist/shared/dynamodb/retry.d.ts +276 -8
  105. package/dist/shared/dynamodb/retry.js +433 -23
  106. package/dist/shared/dynamodb/table-schema.d.ts +190 -0
  107. package/dist/shared/dynamodb/table-schema.js +209 -0
  108. package/dist/shared/errors/base-error.d.ts +184 -10
  109. package/dist/shared/errors/base-error.js +160 -14
  110. package/dist/shared/errors/boundary.d.ts +71 -0
  111. package/dist/shared/errors/boundary.js +143 -0
  112. package/dist/shared/errors/classify.d.ts +97 -0
  113. package/dist/shared/errors/classify.js +257 -0
  114. package/dist/shared/errors/error-code.d.ts +77 -2
  115. package/dist/shared/errors/error-code.js +83 -1
  116. package/dist/shared/errors/errors.d.ts +158 -59
  117. package/dist/shared/errors/errors.js +219 -92
  118. package/dist/shared/logging/logger.d.ts +69 -3
  119. package/dist/shared/logging/logger.js +97 -3
  120. package/dist/shared/logging/redaction.d.ts +92 -8
  121. package/dist/shared/logging/redaction.js +273 -17
  122. package/dist/shared/logging/secret-patterns.d.ts +149 -19
  123. package/dist/shared/logging/secret-patterns.js +188 -27
  124. package/dist/shared/logging/truncate.d.ts +197 -0
  125. package/dist/shared/logging/truncate.js +231 -0
  126. package/dist/shared/options.d.ts +59 -7
  127. package/dist/shared/options.js +9 -1
  128. package/dist/shared/ulid.d.ts +77 -7
  129. package/dist/shared/ulid.js +103 -8
  130. package/dist/shared/validation/collaborators.d.ts +141 -0
  131. package/dist/shared/validation/collaborators.js +188 -0
  132. package/dist/shared/validation/option-shape.d.ts +89 -0
  133. package/dist/shared/validation/option-shape.js +113 -0
  134. package/dist/shared/validation/options.d.ts +145 -0
  135. package/dist/shared/validation/options.js +328 -0
  136. package/dist/shared/validation/primitives.d.ts +288 -21
  137. package/dist/shared/validation/primitives.js +353 -50
  138. package/dist/shared/validation/ttl.d.ts +66 -10
  139. package/dist/shared/validation/ttl.js +113 -15
  140. package/dist/store/actions/list-namespaces.d.ts +76 -6
  141. package/dist/store/actions/list-namespaces.js +166 -24
  142. package/dist/store/actions/put.d.ts +33 -8
  143. package/dist/store/actions/put.js +53 -60
  144. package/dist/store/actions/reconcile-vector-index.d.ts +31 -10
  145. package/dist/store/actions/reconcile-vector-index.js +34 -15
  146. package/dist/store/actions/search.d.ts +34 -6
  147. package/dist/store/actions/search.js +56 -51
  148. package/dist/store/internal/batch-plan.d.ts +26 -0
  149. package/dist/store/internal/batch-plan.js +109 -0
  150. package/dist/store/internal/filter.d.ts +36 -3
  151. package/dist/store/internal/filter.js +66 -15
  152. package/dist/store/internal/get-item.d.ts +45 -0
  153. package/dist/store/internal/get-item.js +115 -0
  154. package/dist/store/internal/item-write.d.ts +230 -0
  155. package/dist/store/internal/item-write.js +463 -0
  156. package/dist/store/internal/parse.d.ts +225 -0
  157. package/dist/store/internal/parse.js +350 -0
  158. package/dist/store/internal/rows.d.ts +355 -0
  159. package/dist/store/internal/rows.js +447 -0
  160. package/dist/store/internal/semantic-search.d.ts +161 -6
  161. package/dist/store/internal/semantic-search.js +360 -18
  162. package/dist/store/internal/setup.d.ts +77 -20
  163. package/dist/store/internal/setup.js +178 -47
  164. package/dist/store/internal/table-search.d.ts +100 -0
  165. package/dist/store/internal/table-search.js +213 -0
  166. package/dist/store/internal/vector-index.d.ts +247 -0
  167. package/dist/store/internal/vector-index.js +546 -0
  168. package/dist/store/store.d.ts +270 -17
  169. package/dist/store/store.js +329 -38
  170. package/dist/store/types.d.ts +76 -26
  171. package/dist/store/types.js +13 -1
  172. package/dist/store/vector-backend.d.ts +64 -4
  173. package/dist/store/vector-backend.js +15 -1
  174. package/package.json +58 -36
  175. package/dist/checkpointer/actions/delete-thread.d.ts.map +0 -1
  176. package/dist/checkpointer/actions/delete-thread.js.map +0 -1
  177. package/dist/checkpointer/actions/get-tuple.d.ts.map +0 -1
  178. package/dist/checkpointer/actions/get-tuple.js.map +0 -1
  179. package/dist/checkpointer/actions/list.d.ts.map +0 -1
  180. package/dist/checkpointer/actions/list.js.map +0 -1
  181. package/dist/checkpointer/actions/put-writes.d.ts.map +0 -1
  182. package/dist/checkpointer/actions/put-writes.js.map +0 -1
  183. package/dist/checkpointer/actions/put.d.ts.map +0 -1
  184. package/dist/checkpointer/actions/put.js.map +0 -1
  185. package/dist/checkpointer/internal/assemble.d.ts +0 -10
  186. package/dist/checkpointer/internal/assemble.d.ts.map +0 -1
  187. package/dist/checkpointer/internal/assemble.js +0 -37
  188. package/dist/checkpointer/internal/assemble.js.map +0 -1
  189. package/dist/checkpointer/internal/configurable.d.ts +0 -13
  190. package/dist/checkpointer/internal/configurable.d.ts.map +0 -1
  191. package/dist/checkpointer/internal/configurable.js +0 -23
  192. package/dist/checkpointer/internal/configurable.js.map +0 -1
  193. package/dist/checkpointer/internal/fetch.d.ts +0 -10
  194. package/dist/checkpointer/internal/fetch.d.ts.map +0 -1
  195. package/dist/checkpointer/internal/fetch.js +0 -46
  196. package/dist/checkpointer/internal/fetch.js.map +0 -1
  197. package/dist/checkpointer/internal/filter-match.d.ts +0 -12
  198. package/dist/checkpointer/internal/filter-match.d.ts.map +0 -1
  199. package/dist/checkpointer/internal/filter-match.js +0 -14
  200. package/dist/checkpointer/internal/filter-match.js.map +0 -1
  201. package/dist/checkpointer/internal/item-reader.d.ts +0 -55
  202. package/dist/checkpointer/internal/item-reader.d.ts.map +0 -1
  203. package/dist/checkpointer/internal/item-reader.js +0 -88
  204. package/dist/checkpointer/internal/item-reader.js.map +0 -1
  205. package/dist/checkpointer/internal/item-writer.d.ts +0 -26
  206. package/dist/checkpointer/internal/item-writer.d.ts.map +0 -1
  207. package/dist/checkpointer/internal/item-writer.js +0 -92
  208. package/dist/checkpointer/internal/item-writer.js.map +0 -1
  209. package/dist/checkpointer/internal/keys.d.ts +0 -31
  210. package/dist/checkpointer/internal/keys.d.ts.map +0 -1
  211. package/dist/checkpointer/internal/keys.js +0 -87
  212. package/dist/checkpointer/internal/keys.js.map +0 -1
  213. package/dist/checkpointer/internal/query.d.ts +0 -20
  214. package/dist/checkpointer/internal/query.d.ts.map +0 -1
  215. package/dist/checkpointer/internal/query.js +0 -36
  216. package/dist/checkpointer/internal/query.js.map +0 -1
  217. package/dist/checkpointer/internal/setup.d.ts.map +0 -1
  218. package/dist/checkpointer/internal/setup.js.map +0 -1
  219. package/dist/checkpointer/internal/special-write-cas.d.ts +0 -30
  220. package/dist/checkpointer/internal/special-write-cas.d.ts.map +0 -1
  221. package/dist/checkpointer/internal/special-write-cas.js +0 -104
  222. package/dist/checkpointer/internal/special-write-cas.js.map +0 -1
  223. package/dist/checkpointer/internal/special-write-cleanup.d.ts +0 -24
  224. package/dist/checkpointer/internal/special-write-cleanup.d.ts.map +0 -1
  225. package/dist/checkpointer/internal/special-write-cleanup.js +0 -47
  226. package/dist/checkpointer/internal/special-write-cleanup.js.map +0 -1
  227. package/dist/checkpointer/internal/special-write-verify.d.ts +0 -54
  228. package/dist/checkpointer/internal/special-write-verify.d.ts.map +0 -1
  229. package/dist/checkpointer/internal/special-write-verify.js +0 -65
  230. package/dist/checkpointer/internal/special-write-verify.js.map +0 -1
  231. package/dist/checkpointer/internal/validation.d.ts +0 -13
  232. package/dist/checkpointer/internal/validation.d.ts.map +0 -1
  233. package/dist/checkpointer/internal/validation.js +0 -30
  234. package/dist/checkpointer/internal/validation.js.map +0 -1
  235. package/dist/checkpointer/internal/write-guard.d.ts +0 -13
  236. package/dist/checkpointer/internal/write-guard.d.ts.map +0 -1
  237. package/dist/checkpointer/internal/write-guard.js +0 -39
  238. package/dist/checkpointer/internal/write-guard.js.map +0 -1
  239. package/dist/checkpointer/internal/write-index.d.ts +0 -37
  240. package/dist/checkpointer/internal/write-index.d.ts.map +0 -1
  241. package/dist/checkpointer/internal/write-index.js +0 -42
  242. package/dist/checkpointer/internal/write-index.js.map +0 -1
  243. package/dist/checkpointer/saver.d.ts.map +0 -1
  244. package/dist/checkpointer/saver.js.map +0 -1
  245. package/dist/checkpointer/types.d.ts.map +0 -1
  246. package/dist/checkpointer/types.js.map +0 -1
  247. package/dist/factory/factory.d.ts.map +0 -1
  248. package/dist/factory/factory.js.map +0 -1
  249. package/dist/history/actions/add-messages.d.ts.map +0 -1
  250. package/dist/history/actions/add-messages.js.map +0 -1
  251. package/dist/history/actions/clear.d.ts.map +0 -1
  252. package/dist/history/actions/clear.js.map +0 -1
  253. package/dist/history/actions/get-messages.d.ts.map +0 -1
  254. package/dist/history/actions/get-messages.js.map +0 -1
  255. package/dist/history/actions/list-sessions.d.ts.map +0 -1
  256. package/dist/history/actions/list-sessions.js.map +0 -1
  257. package/dist/history/actions/reconcile-count.d.ts.map +0 -1
  258. package/dist/history/actions/reconcile-count.js.map +0 -1
  259. package/dist/history/chat-message-history.d.ts.map +0 -1
  260. package/dist/history/chat-message-history.js.map +0 -1
  261. package/dist/history/internal/append-saga.d.ts +0 -20
  262. package/dist/history/internal/append-saga.d.ts.map +0 -1
  263. package/dist/history/internal/append-saga.js +0 -35
  264. package/dist/history/internal/append-saga.js.map +0 -1
  265. package/dist/history/internal/compensation.d.ts +0 -21
  266. package/dist/history/internal/compensation.d.ts.map +0 -1
  267. package/dist/history/internal/compensation.js +0 -84
  268. package/dist/history/internal/compensation.js.map +0 -1
  269. package/dist/history/internal/item-mapper.d.ts +0 -12
  270. package/dist/history/internal/item-mapper.d.ts.map +0 -1
  271. package/dist/history/internal/item-mapper.js +0 -33
  272. package/dist/history/internal/item-mapper.js.map +0 -1
  273. package/dist/history/internal/keys.d.ts +0 -17
  274. package/dist/history/internal/keys.d.ts.map +0 -1
  275. package/dist/history/internal/keys.js +0 -49
  276. package/dist/history/internal/keys.js.map +0 -1
  277. package/dist/history/internal/message-chunker.d.ts +0 -14
  278. package/dist/history/internal/message-chunker.d.ts.map +0 -1
  279. package/dist/history/internal/message-chunker.js +0 -68
  280. package/dist/history/internal/message-chunker.js.map +0 -1
  281. package/dist/history/internal/message-transaction.d.ts +0 -26
  282. package/dist/history/internal/message-transaction.d.ts.map +0 -1
  283. package/dist/history/internal/message-transaction.js +0 -60
  284. package/dist/history/internal/message-transaction.js.map +0 -1
  285. package/dist/history/internal/query.d.ts +0 -10
  286. package/dist/history/internal/query.d.ts.map +0 -1
  287. package/dist/history/internal/query.js +0 -31
  288. package/dist/history/internal/query.js.map +0 -1
  289. package/dist/history/internal/session-count.d.ts +0 -41
  290. package/dist/history/internal/session-count.d.ts.map +0 -1
  291. package/dist/history/internal/session-count.js +0 -109
  292. package/dist/history/internal/session-count.js.map +0 -1
  293. package/dist/history/internal/session-title.d.ts +0 -20
  294. package/dist/history/internal/session-title.d.ts.map +0 -1
  295. package/dist/history/internal/session-title.js +0 -44
  296. package/dist/history/internal/session-title.js.map +0 -1
  297. package/dist/history/internal/session-update.d.ts +0 -28
  298. package/dist/history/internal/session-update.d.ts.map +0 -1
  299. package/dist/history/internal/session-update.js +0 -70
  300. package/dist/history/internal/session-update.js.map +0 -1
  301. package/dist/history/internal/setup.d.ts.map +0 -1
  302. package/dist/history/internal/setup.js.map +0 -1
  303. package/dist/history/internal/title-generator.d.ts +0 -13
  304. package/dist/history/internal/title-generator.d.ts.map +0 -1
  305. package/dist/history/internal/title-generator.js +0 -25
  306. package/dist/history/internal/title-generator.js.map +0 -1
  307. package/dist/history/internal/ttl-anchor.d.ts +0 -25
  308. package/dist/history/internal/ttl-anchor.d.ts.map +0 -1
  309. package/dist/history/internal/ttl-anchor.js +0 -38
  310. package/dist/history/internal/ttl-anchor.js.map +0 -1
  311. package/dist/history/internal/validation.d.ts +0 -9
  312. package/dist/history/internal/validation.d.ts.map +0 -1
  313. package/dist/history/internal/validation.js +0 -16
  314. package/dist/history/internal/validation.js.map +0 -1
  315. package/dist/history/session-adapter.d.ts.map +0 -1
  316. package/dist/history/session-adapter.js.map +0 -1
  317. package/dist/history/types.d.ts.map +0 -1
  318. package/dist/history/types.js.map +0 -1
  319. package/dist/index.d.ts.map +0 -1
  320. package/dist/index.js.map +0 -1
  321. package/dist/shared/clock.d.ts.map +0 -1
  322. package/dist/shared/clock.js.map +0 -1
  323. package/dist/shared/codec/codec.d.ts.map +0 -1
  324. package/dist/shared/codec/codec.js.map +0 -1
  325. package/dist/shared/codec/compression.d.ts.map +0 -1
  326. package/dist/shared/codec/compression.js.map +0 -1
  327. package/dist/shared/codec/descriptor-keys.d.ts +0 -4
  328. package/dist/shared/codec/descriptor-keys.d.ts.map +0 -1
  329. package/dist/shared/codec/descriptor-keys.js +0 -14
  330. package/dist/shared/codec/descriptor-keys.js.map +0 -1
  331. package/dist/shared/codec/json-serde.d.ts.map +0 -1
  332. package/dist/shared/codec/json-serde.js.map +0 -1
  333. package/dist/shared/codec/s3/client.d.ts.map +0 -1
  334. package/dist/shared/codec/s3/client.js.map +0 -1
  335. package/dist/shared/codec/s3/config.d.ts.map +0 -1
  336. package/dist/shared/codec/s3/config.js.map +0 -1
  337. package/dist/shared/codec/s3/delete.d.ts +0 -8
  338. package/dist/shared/codec/s3/delete.d.ts.map +0 -1
  339. package/dist/shared/codec/s3/delete.js +0 -29
  340. package/dist/shared/codec/s3/delete.js.map +0 -1
  341. package/dist/shared/codec/s3/lifecycle.d.ts.map +0 -1
  342. package/dist/shared/codec/s3/lifecycle.js.map +0 -1
  343. package/dist/shared/codec/s3/offloader.d.ts.map +0 -1
  344. package/dist/shared/codec/s3/offloader.js.map +0 -1
  345. package/dist/shared/codec/s3/orphans.d.ts +0 -18
  346. package/dist/shared/codec/s3/orphans.d.ts.map +0 -1
  347. package/dist/shared/codec/s3/orphans.js +0 -58
  348. package/dist/shared/codec/s3/orphans.js.map +0 -1
  349. package/dist/shared/codec/s3/read-write.d.ts +0 -14
  350. package/dist/shared/codec/s3/read-write.d.ts.map +0 -1
  351. package/dist/shared/codec/s3/read-write.js +0 -43
  352. package/dist/shared/codec/s3/read-write.js.map +0 -1
  353. package/dist/shared/codec/s3/retry.d.ts +0 -5
  354. package/dist/shared/codec/s3/retry.d.ts.map +0 -1
  355. package/dist/shared/codec/s3/retry.js +0 -25
  356. package/dist/shared/codec/s3/retry.js.map +0 -1
  357. package/dist/shared/constants.d.ts +0 -64
  358. package/dist/shared/constants.d.ts.map +0 -1
  359. package/dist/shared/constants.js +0 -67
  360. package/dist/shared/constants.js.map +0 -1
  361. package/dist/shared/dynamodb/backoff.d.ts +0 -15
  362. package/dist/shared/dynamodb/backoff.d.ts.map +0 -1
  363. package/dist/shared/dynamodb/backoff.js +0 -48
  364. package/dist/shared/dynamodb/backoff.js.map +0 -1
  365. package/dist/shared/dynamodb/batch-write.d.ts.map +0 -1
  366. package/dist/shared/dynamodb/batch-write.js.map +0 -1
  367. package/dist/shared/dynamodb/cancellation.d.ts.map +0 -1
  368. package/dist/shared/dynamodb/cancellation.js.map +0 -1
  369. package/dist/shared/dynamodb/client.d.ts.map +0 -1
  370. package/dist/shared/dynamodb/client.js.map +0 -1
  371. package/dist/shared/dynamodb/conditional-put.d.ts +0 -51
  372. package/dist/shared/dynamodb/conditional-put.d.ts.map +0 -1
  373. package/dist/shared/dynamodb/conditional-put.js +0 -59
  374. package/dist/shared/dynamodb/conditional-put.js.map +0 -1
  375. package/dist/shared/dynamodb/drain-unprocessed.d.ts +0 -19
  376. package/dist/shared/dynamodb/drain-unprocessed.d.ts.map +0 -1
  377. package/dist/shared/dynamodb/drain-unprocessed.js +0 -44
  378. package/dist/shared/dynamodb/drain-unprocessed.js.map +0 -1
  379. package/dist/shared/dynamodb/paginate-core.d.ts +0 -22
  380. package/dist/shared/dynamodb/paginate-core.d.ts.map +0 -1
  381. package/dist/shared/dynamodb/paginate-core.js +0 -52
  382. package/dist/shared/dynamodb/paginate-core.js.map +0 -1
  383. package/dist/shared/dynamodb/paginate.d.ts.map +0 -1
  384. package/dist/shared/dynamodb/paginate.js.map +0 -1
  385. package/dist/shared/dynamodb/partition-delete.d.ts.map +0 -1
  386. package/dist/shared/dynamodb/partition-delete.js.map +0 -1
  387. package/dist/shared/dynamodb/retry-classifier.d.ts +0 -9
  388. package/dist/shared/dynamodb/retry-classifier.d.ts.map +0 -1
  389. package/dist/shared/dynamodb/retry-classifier.js +0 -87
  390. package/dist/shared/dynamodb/retry-classifier.js.map +0 -1
  391. package/dist/shared/dynamodb/retry.d.ts.map +0 -1
  392. package/dist/shared/dynamodb/retry.js.map +0 -1
  393. package/dist/shared/dynamodb/scan.d.ts +0 -15
  394. package/dist/shared/dynamodb/scan.d.ts.map +0 -1
  395. package/dist/shared/dynamodb/scan.js +0 -20
  396. package/dist/shared/dynamodb/scan.js.map +0 -1
  397. package/dist/shared/dynamodb/types.d.ts +0 -24
  398. package/dist/shared/dynamodb/types.d.ts.map +0 -1
  399. package/dist/shared/dynamodb/types.js +0 -3
  400. package/dist/shared/dynamodb/types.js.map +0 -1
  401. package/dist/shared/errors/base-error.d.ts.map +0 -1
  402. package/dist/shared/errors/base-error.js.map +0 -1
  403. package/dist/shared/errors/error-code.d.ts.map +0 -1
  404. package/dist/shared/errors/error-code.js.map +0 -1
  405. package/dist/shared/errors/errors.d.ts.map +0 -1
  406. package/dist/shared/errors/errors.js.map +0 -1
  407. package/dist/shared/errors/wrap-error.d.ts +0 -16
  408. package/dist/shared/errors/wrap-error.d.ts.map +0 -1
  409. package/dist/shared/errors/wrap-error.js +0 -30
  410. package/dist/shared/errors/wrap-error.js.map +0 -1
  411. package/dist/shared/logging/logger.d.ts.map +0 -1
  412. package/dist/shared/logging/logger.js.map +0 -1
  413. package/dist/shared/logging/redaction-walk.d.ts +0 -23
  414. package/dist/shared/logging/redaction-walk.d.ts.map +0 -1
  415. package/dist/shared/logging/redaction-walk.js +0 -92
  416. package/dist/shared/logging/redaction-walk.js.map +0 -1
  417. package/dist/shared/logging/redaction.d.ts.map +0 -1
  418. package/dist/shared/logging/redaction.js.map +0 -1
  419. package/dist/shared/logging/secret-patterns.d.ts.map +0 -1
  420. package/dist/shared/logging/secret-patterns.js.map +0 -1
  421. package/dist/shared/options.d.ts.map +0 -1
  422. package/dist/shared/options.js.map +0 -1
  423. package/dist/shared/ulid.d.ts.map +0 -1
  424. package/dist/shared/ulid.js.map +0 -1
  425. package/dist/shared/validation/primitives.d.ts.map +0 -1
  426. package/dist/shared/validation/primitives.js.map +0 -1
  427. package/dist/shared/validation/ttl.d.ts.map +0 -1
  428. package/dist/shared/validation/ttl.js.map +0 -1
  429. package/dist/store/actions/get.d.ts +0 -5
  430. package/dist/store/actions/get.d.ts.map +0 -1
  431. package/dist/store/actions/get.js +0 -35
  432. package/dist/store/actions/get.js.map +0 -1
  433. package/dist/store/actions/list-namespaces.d.ts.map +0 -1
  434. package/dist/store/actions/list-namespaces.js.map +0 -1
  435. package/dist/store/actions/put.d.ts.map +0 -1
  436. package/dist/store/actions/put.js.map +0 -1
  437. package/dist/store/actions/reconcile-vector-index.d.ts.map +0 -1
  438. package/dist/store/actions/reconcile-vector-index.js.map +0 -1
  439. package/dist/store/actions/search.d.ts.map +0 -1
  440. package/dist/store/actions/search.js.map +0 -1
  441. package/dist/store/internal/backend-search.d.ts +0 -5
  442. package/dist/store/internal/backend-search.d.ts.map +0 -1
  443. package/dist/store/internal/backend-search.js +0 -68
  444. package/dist/store/internal/backend-search.js.map +0 -1
  445. package/dist/store/internal/filter.d.ts.map +0 -1
  446. package/dist/store/internal/filter.js.map +0 -1
  447. package/dist/store/internal/index-reconcile.d.ts +0 -22
  448. package/dist/store/internal/index-reconcile.d.ts.map +0 -1
  449. package/dist/store/internal/index-reconcile.js +0 -105
  450. package/dist/store/internal/index-reconcile.js.map +0 -1
  451. package/dist/store/internal/index-sync.d.ts +0 -11
  452. package/dist/store/internal/index-sync.d.ts.map +0 -1
  453. package/dist/store/internal/index-sync.js +0 -26
  454. package/dist/store/internal/index-sync.js.map +0 -1
  455. package/dist/store/internal/item-mapper.d.ts +0 -25
  456. package/dist/store/internal/item-mapper.d.ts.map +0 -1
  457. package/dist/store/internal/item-mapper.js +0 -53
  458. package/dist/store/internal/item-mapper.js.map +0 -1
  459. package/dist/store/internal/keys.d.ts +0 -18
  460. package/dist/store/internal/keys.d.ts.map +0 -1
  461. package/dist/store/internal/keys.js +0 -42
  462. package/dist/store/internal/keys.js.map +0 -1
  463. package/dist/store/internal/namespace-match.d.ts +0 -12
  464. package/dist/store/internal/namespace-match.d.ts.map +0 -1
  465. package/dist/store/internal/namespace-match.js +0 -41
  466. package/dist/store/internal/namespace-match.js.map +0 -1
  467. package/dist/store/internal/overwrite-swap.d.ts +0 -33
  468. package/dist/store/internal/overwrite-swap.d.ts.map +0 -1
  469. package/dist/store/internal/overwrite-swap.js +0 -62
  470. package/dist/store/internal/overwrite-swap.js.map +0 -1
  471. package/dist/store/internal/persist.d.ts +0 -27
  472. package/dist/store/internal/persist.d.ts.map +0 -1
  473. package/dist/store/internal/persist.js +0 -59
  474. package/dist/store/internal/persist.js.map +0 -1
  475. package/dist/store/internal/query.d.ts +0 -6
  476. package/dist/store/internal/query.d.ts.map +0 -1
  477. package/dist/store/internal/query.js +0 -32
  478. package/dist/store/internal/query.js.map +0 -1
  479. package/dist/store/internal/ranker.d.ts +0 -13
  480. package/dist/store/internal/ranker.d.ts.map +0 -1
  481. package/dist/store/internal/ranker.js +0 -31
  482. package/dist/store/internal/ranker.js.map +0 -1
  483. package/dist/store/internal/read-existing.d.ts +0 -19
  484. package/dist/store/internal/read-existing.d.ts.map +0 -1
  485. package/dist/store/internal/read-existing.js +0 -29
  486. package/dist/store/internal/read-existing.js.map +0 -1
  487. package/dist/store/internal/score-direction.d.ts +0 -32
  488. package/dist/store/internal/score-direction.d.ts.map +0 -1
  489. package/dist/store/internal/score-direction.js +0 -39
  490. package/dist/store/internal/score-direction.js.map +0 -1
  491. package/dist/store/internal/search-filter.d.ts +0 -4
  492. package/dist/store/internal/search-filter.d.ts.map +0 -1
  493. package/dist/store/internal/search-filter.js +0 -11
  494. package/dist/store/internal/search-filter.js.map +0 -1
  495. package/dist/store/internal/semantic-search.d.ts.map +0 -1
  496. package/dist/store/internal/semantic-search.js.map +0 -1
  497. package/dist/store/internal/setup.d.ts.map +0 -1
  498. package/dist/store/internal/setup.js.map +0 -1
  499. package/dist/store/internal/validation.d.ts +0 -13
  500. package/dist/store/internal/validation.d.ts.map +0 -1
  501. package/dist/store/internal/validation.js +0 -35
  502. package/dist/store/internal/validation.js.map +0 -1
  503. package/dist/store/internal/write-verify.d.ts +0 -37
  504. package/dist/store/internal/write-verify.d.ts.map +0 -1
  505. package/dist/store/internal/write-verify.js +0 -68
  506. package/dist/store/internal/write-verify.js.map +0 -1
  507. package/dist/store/store.d.ts.map +0 -1
  508. package/dist/store/store.js.map +0 -1
  509. package/dist/store/types.d.ts.map +0 -1
  510. package/dist/store/types.js.map +0 -1
  511. package/dist/store/vector-backend.d.ts.map +0 -1
  512. package/dist/store/vector-backend.js.map +0 -1
@@ -0,0 +1,209 @@
1
+ "use strict";
2
+ /**
3
+ * Hides the conventions every row of the shared table follows, whichever
4
+ * adapter wrote it.
5
+ *
6
+ * The three adapters share one table (record 2), so a few things are decided
7
+ * once for all of them: the two key attributes every row has, the format
8
+ * version every row is stamped with and refused above (record 7), the `ttl`
9
+ * attribute that makes a row absent before DynamoDB's sweep removes it, and the
10
+ * order the server gives string keys. Which segments a feature's keys carry is
11
+ * that feature's `rows` module's decision; that they are written into these
12
+ * attributes and read back in this order is this module's.
13
+ */
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.SUPPORTED_ROW_FORMAT_VERSION = exports.ROW_FORMAT_VERSION = exports.ADAPTER_TAGS = exports.KEY_SEPARATOR = exports.MAX_SORT_KEY_BYTES = exports.MAX_KEY_SEGMENT_BYTES = exports.MAX_PARTITION_ID_BYTES = exports.SORT_KEY_ATTRIBUTE = exports.PARTITION_KEY_ATTRIBUTE = void 0;
16
+ exports.rowKeyOf = rowKeyOf;
17
+ exports.rowVersionOf = rowVersionOf;
18
+ exports.assertReadableRow = assertReadableRow;
19
+ exports.withRowVersion = withRowVersion;
20
+ exports.isExpiredRow = isExpiredRow;
21
+ exports.withoutExpired = withoutExpired;
22
+ exports.compareSortKeys = compareSortKeys;
23
+ const base_error_1 = require("../errors/base-error");
24
+ const error_code_1 = require("../errors/error-code");
25
+ /** The attribute every row is partitioned by. */
26
+ exports.PARTITION_KEY_ATTRIBUTE = 'PK';
27
+ /** The attribute every row is sorted by within its partition. */
28
+ exports.SORT_KEY_ATTRIBUTE = 'SK';
29
+ /**
30
+ * Byte caps on caller-supplied identifiers, measured as UTF-8. DynamoDB caps a
31
+ * partition key at 2048 bytes and a sort key at 1024; S3 caps an object key at
32
+ * 1024. These leave room for the adapter prefixes and separators that compose
33
+ * the stored keys, so a value that passes validation fails as a typed error
34
+ * here rather than as a raw AWS ValidationException on the write.
35
+ *
36
+ * Partition-key identifiers: `thread_id` and `sessionId`.
37
+ */
38
+ exports.MAX_PARTITION_ID_BYTES = 1024;
39
+ /**
40
+ * Sort-key segments: `checkpoint_ns`, `checkpoint_id`, `taskId`, a pending-write
41
+ * channel, a store namespace element and a store `key`.
42
+ */
43
+ exports.MAX_KEY_SEGMENT_BYTES = 256;
44
+ /**
45
+ * DynamoDB cap on a whole sort key; composed keys are checked against it too.
46
+ *
47
+ * @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html
48
+ */
49
+ exports.MAX_SORT_KEY_BYTES = 1024;
50
+ /**
51
+ * The separator between the segments of every key this package composes. No
52
+ * caller-supplied identifier may contain it (the parsers refuse it), which is
53
+ * what lets a key be read back into its parts and matched by prefix (record 2).
54
+ */
55
+ exports.KEY_SEPARATOR = '#';
56
+ /**
57
+ * The tag each adapter's partition keys open with. The three differ in their
58
+ * first character, so no two adapters' partitions can collide on a shared
59
+ * table, whatever identifiers their callers reuse (record 2).
60
+ */
61
+ exports.ADAPTER_TAGS = { checkpointer: 'CHKPT', store: 'STORE', history: 'HIST' };
62
+ /**
63
+ * The key of a row already in hand.
64
+ *
65
+ * Accepts: `row` — an item read from, or about to be written to, the table.
66
+ *
67
+ * Returns: its `PK` and `SK`, and nothing else, so it can be sent as a `Key`
68
+ * without the rest of the item.
69
+ *
70
+ * Throws: nothing.
71
+ */
72
+ function rowKeyOf(row) {
73
+ return { PK: row.PK, SK: row.SK };
74
+ }
75
+ /**
76
+ * The format version this package stamps on every row it writes.
77
+ *
78
+ * Before it existed, "written by an older version" was inferred from a missing
79
+ * attribute — `rev`, `occurrence`, `writeGroup`, `storedChannels`. That
80
+ * inference is unreadable to a maintainer and it is not even expressible: a
81
+ * lookup cannot tell an attribute that is *absent* from one that is *present
82
+ * and undefined*, which reversed first-write-wins for pending writes across an
83
+ * upgrade. A row states its own version instead.
84
+ */
85
+ exports.ROW_FORMAT_VERSION = 1;
86
+ /** The highest version this package knows how to read. */
87
+ exports.SUPPORTED_ROW_FORMAT_VERSION = 1;
88
+ /**
89
+ * A row's format version.
90
+ *
91
+ * Accepts: `row` — any row. One carrying no numeric `v` predates the attribute.
92
+ *
93
+ * Returns: the stamped version, or `0` for a row without one — the version
94
+ * whose rules applied when it was written.
95
+ *
96
+ * Throws: nothing.
97
+ */
98
+ function rowVersionOf(row) {
99
+ return typeof row.v === 'number' ? row.v : 0;
100
+ }
101
+ /**
102
+ * Refuse a row written by a newer version of this package.
103
+ *
104
+ * Accepts: `row` — any row; one at or below
105
+ * {@link SUPPORTED_ROW_FORMAT_VERSION} is accepted, which includes every row
106
+ * written before the attribute existed. `what` — the row kind, named in the
107
+ * message.
108
+ *
109
+ * Returns: nothing: `row` is kept under its declared type, and this checks
110
+ * it.
111
+ *
112
+ * Throws: `FORMAT_UNSUPPORTED` naming the field `v`. Guessing at a shape this
113
+ * version does not know is how a reader returns a checkpoint with silently
114
+ * missing state, so the caller is told to upgrade instead.
115
+ */
116
+ function assertReadableRow(row, what) {
117
+ const version = rowVersionOf(row);
118
+ if (version <= exports.SUPPORTED_ROW_FORMAT_VERSION)
119
+ return;
120
+ throw new base_error_1.DynamoDBLangGraphError(`this ${what} row was written in format version ${version}; this version of the library ` +
121
+ `reads up to ${exports.SUPPORTED_ROW_FORMAT_VERSION} — upgrade to read it`, error_code_1.ErrorCode.FORMAT_UNSUPPORTED, { field: 'v' });
122
+ }
123
+ /**
124
+ * The item with this release's format version stamped on it.
125
+ *
126
+ * Accepts: `item` — any item about to be written; an existing `v` is replaced.
127
+ *
128
+ * Returns: a copy carrying `v`, leaving the input untouched.
129
+ *
130
+ * Throws: nothing.
131
+ */
132
+ function withRowVersion(item) {
133
+ return { ...item, v: exports.ROW_FORMAT_VERSION };
134
+ }
135
+ /**
136
+ * Whether a row has reached its TTL.
137
+ *
138
+ * Accepts: `row` — any row; one without a `ttl` attribute never expires.
139
+ * `nowSeconds` — the current epoch **second**, the unit the attribute uses.
140
+ *
141
+ * Returns: true when `ttl <= nowSeconds`, so the expiry instant itself counts
142
+ * as expired.
143
+ *
144
+ * Throws: nothing.
145
+ *
146
+ * Guarantees: an expired row is absent to every reader even while DynamoDB's
147
+ * own sweep lags, which it may by up to 48 hours
148
+ * (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/howitworks-ttl.html).
149
+ */
150
+ function isExpiredRow(row, nowSeconds) {
151
+ return row.ttl !== undefined && row.ttl <= nowSeconds;
152
+ }
153
+ const TTL_FILTER = 'attribute_not_exists(#ttl) OR #ttl > :now';
154
+ /**
155
+ * The same query with expired rows filtered out server-side.
156
+ *
157
+ * Accepts: `params` — a Query or Scan input, with or without a
158
+ * `FilterExpression`; an existing one is ANDed rather than replaced.
159
+ * `nowSeconds` — the epoch second to compare against.
160
+ *
161
+ * Returns: a copy carrying the added filter and the `#ttl` / `:now` aliases. No
162
+ * other call site in this package uses those two names, so the merge cannot
163
+ * shadow a caller's own alias.
164
+ *
165
+ * Throws: nothing.
166
+ *
167
+ * Guarantees: this trims transfer only. It never replaces the in-process
168
+ * {@link isExpiredRow} check, because the query is built and its rows are read
169
+ * at two different instants, and DynamoDB applies a filter *after* `Limit`.
170
+ */
171
+ function withoutExpired(params, nowSeconds) {
172
+ return {
173
+ ...params,
174
+ FilterExpression: params.FilterExpression
175
+ ? `(${params.FilterExpression}) AND (${TTL_FILTER})`
176
+ : TTL_FILTER,
177
+ ExpressionAttributeNames: { ...params.ExpressionAttributeNames, '#ttl': 'ttl' },
178
+ ExpressionAttributeValues: { ...params.ExpressionAttributeValues, ':now': nowSeconds },
179
+ };
180
+ }
181
+ /**
182
+ * Order two DynamoDB string sort keys the way the server orders them.
183
+ *
184
+ * DynamoDB compares a string key by the bytes of its UTF-8 encoding.
185
+ * JavaScript's `<` and `>` compare UTF-16 code units, and the two disagree
186
+ * wherever an astral character meets one in U+E000-U+FFFF: an astral character
187
+ * is a surrogate pair starting at U+D800, so `'A\u{1F600}' < 'A!'` in
188
+ * JavaScript and the reverse on the server. Any listing that merges or bounds
189
+ * rows in memory and then resumes with a key condition has to use this order,
190
+ * or the boundary it draws is not the boundary the next query reads from, and
191
+ * a row is skipped or handed out twice.
192
+ *
193
+ * The comparison is written on the bytes rather than on code points. The two
194
+ * agree — UTF-8 was designed so that byte order is code-point order — but the
195
+ * bytes are what DynamoDB documents itself as comparing, so the code states the
196
+ * server's rule instead of a property that happens to coincide with it.
197
+ *
198
+ * Accepts: `left`, `right` — any two strings; well-formedness is not required,
199
+ * since an unpaired surrogate encodes to the replacement character's bytes and
200
+ * so still compares deterministically.
201
+ *
202
+ * Returns: a negative number when `left` sorts before `right`, a positive one
203
+ * when it sorts after, and `0` when the two encode to the same bytes.
204
+ *
205
+ * Throws: nothing.
206
+ */
207
+ function compareSortKeys(left, right) {
208
+ return Buffer.compare(Buffer.from(left, 'utf8'), Buffer.from(right, 'utf8'));
209
+ }
@@ -1,22 +1,196 @@
1
+ /**
2
+ * Hides the one error class and what counts as an error at all.
3
+ *
4
+ * Every failure this package raises is a `DynamoDBLangGraphError` told apart by
5
+ * its code (record 19), recognisable across copies of the package by a brand
6
+ * rather than by `instanceof`; and whatever a caller's code or a dependency
7
+ * throws — a string, `undefined`, an object — is turned into an `Error` before
8
+ * anything reads it.
9
+ */
10
+ import type { WriteRequest } from '../dynamodb/client';
1
11
  import { ErrorCode } from './error-code';
2
- /** Structured, log-safe context attached to every library error. */
12
+ /**
13
+ * Structured, log-safe context attached to every library error. Identifiers
14
+ * and counts only — never a payload or a credential.
15
+ */
3
16
  export interface ErrorContext {
17
+ /** The DynamoDB table the operation targeted, when known. */
4
18
  tableName?: string;
19
+ /** The public operation (`saver.put`, `store.batch`, …) or internal step that failed. */
5
20
  operation?: string;
21
+ /** The option, argument or cap that failed validation or was exceeded. */
22
+ field?: string;
23
+ /** The S3 object key involved, for offload failures. */
6
24
  key?: string;
25
+ /** Attempts made before a retry budget was exhausted. */
7
26
  attempts?: number;
27
+ /** The thread a checkpointer failure belongs to. */
28
+ threadId?: string;
29
+ /** The checkpoint a checkpointer failure names. */
30
+ checkpointId?: string;
31
+ /**
32
+ * The AWS exception name of the failure underneath, when that failure was
33
+ * AWS-shaped (it carried the SDK's `$metadata`, or a name the classifier
34
+ * knows or that ends in `Exception`). Lifted off `cause.name` so a log line
35
+ * or an alert can branch on it without walking `cause`.
36
+ */
37
+ awsErrorName?: string;
38
+ /** The AWS request id (`cause.$metadata.requestId`), which AWS Support asks for. */
39
+ requestId?: string;
40
+ /** The HTTP status of the failed AWS response (`cause.$metadata.httpStatusCode`). */
41
+ httpStatusCode?: number;
42
+ }
43
+ /** What one `BatchWriteItem` drain left behind when it ran out of rounds. */
44
+ export interface BatchDrainDetails {
45
+ readonly kind: 'drain';
46
+ /** Writes DynamoDB acknowledged; they persist, since there is no rollback. */
47
+ readonly succeededCount: number;
48
+ /** The requests DynamoDB did not acknowledge, verbatim, so they can be re-submitted. */
49
+ readonly unprocessed: readonly WriteRequest[];
50
+ /** `UnprocessedItems` rounds spent. */
51
+ readonly retries: number;
52
+ }
53
+ /**
54
+ * The tally of a pass that attempted every chunk (`unit: 'chunk'`, 25-row
55
+ * `BatchWriteItem` chunks) or every row (`unit: 'row'`, one conditional delete
56
+ * per row) before reporting.
57
+ */
58
+ export interface BatchPassDetails {
59
+ readonly kind: 'pass';
60
+ readonly unit: 'chunk' | 'row';
61
+ readonly succeededChunks: number;
62
+ readonly totalChunks: number;
63
+ /** Each failing chunk's or row's own error. */
64
+ readonly failedChunks: readonly Error[];
65
+ /** Individual writes confirmed persisted across the whole pass. */
66
+ readonly succeededCount: number;
67
+ }
68
+ /** What a `BATCH_WRITE_INCOMPLETE` error reports: one drain, or a whole pass. */
69
+ export type BatchWriteIncompleteDetails = BatchDrainDetails | BatchPassDetails;
70
+ /** What a `COMPENSATION_FAILED` error reports besides its trigger, which is `cause`. */
71
+ export interface CompensationFailedDetails {
72
+ /** Why the rollback itself could not finish; itself often a `BATCH_WRITE_INCOMPLETE`. */
73
+ readonly rollbackError: Error;
74
+ }
75
+ /** The codes that carry details, and the shape each one carries. */
76
+ export interface ErrorDetailsByCode {
77
+ [ErrorCode.BATCH_WRITE_INCOMPLETE]: BatchWriteIncompleteDetails;
78
+ [ErrorCode.COMPENSATION_FAILED]: CompensationFailedDetails;
8
79
  }
80
+ /** The details a code carries; `undefined` for every code not in {@link ErrorDetailsByCode}. */
81
+ export type ErrorDetailsFor<C extends ErrorCode> = C extends keyof ErrorDetailsByCode ? ErrorDetailsByCode[C] : undefined;
9
82
  /**
10
83
  * Base class for every error this library throws. Carries a branchable
11
- * {@link ErrorCode}, structured {@link ErrorContext}, and a native `cause`
12
- * chain. Detected via {@link isDynamoDbLangGraphError} (a symbol brand) rather
13
- * than `instanceof`, which is banned repo-wide.
84
+ * {@link ErrorCode}, structured {@link ErrorContext}, code-specific
85
+ * {@link details}, and a native `cause` chain. Detected via
86
+ * {@link isDynamoDBLangGraphError} (a symbol brand) rather than `instanceof`,
87
+ * which is banned repo-wide.
14
88
  */
15
- export declare class DynamoDbLangGraphError extends Error {
16
- readonly code: ErrorCode;
89
+ export declare class DynamoDBLangGraphError<C extends ErrorCode = ErrorCode> extends Error {
90
+ readonly code: C;
17
91
  readonly context: ErrorContext;
18
- constructor(message: string, code: ErrorCode, context?: ErrorContext, cause?: Error);
92
+ /** Declared, not emitted: a code without details leaves no `undefined`-valued own property. */
93
+ readonly details: ErrorDetailsFor<C>;
94
+ /**
95
+ * Accepts: `message` — already redacted by whoever composed it, since it reaches
96
+ * `err.message`, which an application may print without a redacting logger.
97
+ * `code` — the code this error branches on. `context` — identifiers and counts
98
+ * only, never a payload or a credential. It is **copied**, so a caller that
99
+ * reuses one builder object cannot rewrite the context of an error already in
100
+ * flight; `null` reads as an absent one. `cause` — the failure below this one,
101
+ * kept as the native `cause` chain. `details` — the code-specific record
102
+ * {@link ErrorDetailsByCode} names, copied like `context`. The parameter is
103
+ * optional for every code, including the two whose `details` property is
104
+ * typed as always present (`BATCH_WRITE_INCOMPLETE`, `COMPENSATION_FAILED`):
105
+ * nothing at compile time stops a direct `new` from leaving it out, and an
106
+ * error built that way has no `details` at runtime whatever its type says.
107
+ * Inside this package those two codes are only ever built by the factories
108
+ * that always pass them.
109
+ *
110
+ * Returns: the error, branded so {@link isDynamoDBLangGraphError} recognises it
111
+ * across realms and across two copies of this package. The brand is
112
+ * non-enumerable, so it never reaches a log or a JSON serialization.
113
+ *
114
+ * Throws: nothing; building an error may not fail.
115
+ */
116
+ constructor(message: string, code: C, context?: ErrorContext, cause?: Error, details?: ErrorDetailsFor<C>);
19
117
  }
20
- /** True when `value` is a {@link DynamoDbLangGraphError}, detected by brand. */
21
- export declare function isDynamoDbLangGraphError(value: Error): value is DynamoDbLangGraphError;
22
- //# sourceMappingURL=base-error.d.ts.map
118
+ /**
119
+ * Every library error, as a union discriminated by `code`: comparing `code`
120
+ * narrows `details` to the shape that code carries.
121
+ */
122
+ export type AnyDynamoDBLangGraphError = {
123
+ [C in ErrorCode]: DynamoDBLangGraphError<C>;
124
+ }[ErrorCode];
125
+ /**
126
+ * Whether `value` is one of this library's errors.
127
+ *
128
+ * Accepts: any error, from any realm or any copy of this package — and, since
129
+ * the documented place to call this is inside a `catch`, any other value a
130
+ * `throw` can produce: `null`, `undefined`, a string, a number, a symbol.
131
+ *
132
+ * Returns: whether it carries the brand, narrowed to the union discriminated by
133
+ * `code`. A symbol registered by name, not `instanceof`: two copies of this
134
+ * package in one dependency tree produce two classes but one symbol, and an
135
+ * error crossing a realm boundary keeps its properties while losing its
136
+ * prototype. Anything that cannot carry a property answers `false`. Earlier
137
+ * releases set the same brand, so an older copy of this package installed
138
+ * beside this one has its errors recognised too — in that release's shape: no
139
+ * `details`, the counts as flat properties, and possibly a code this union
140
+ * does not list (`UPSTREAM`).
141
+ *
142
+ * Throws: nothing. The `in` operator raises a `TypeError` on a non-object, and
143
+ * a guard that throws inside the `catch` it was called from would replace the
144
+ * failure the caller is reporting with one of its own.
145
+ */
146
+ export declare function isDynamoDBLangGraphError(value: Error): value is AnyDynamoDBLangGraphError;
147
+ /**
148
+ * Whether `value` is one of this library's errors carrying `code`.
149
+ *
150
+ * Accepts: anything a `catch` can bind. `code` — the code to test for.
151
+ *
152
+ * Returns: `true` only for a branded error whose `code` is `code`, narrowed so
153
+ * its `details` are typed. An unbranded object that merely carries a `code`
154
+ * property is not one: recognition is by brand and code together, never by a
155
+ * name or a shape.
156
+ *
157
+ * Throws: nothing, for any value.
158
+ */
159
+ export declare function hasErrorCode<C extends ErrorCode>(value: Error, code: C): value is DynamoDBLangGraphError<C>;
160
+ /**
161
+ * What a log line calls a failure.
162
+ *
163
+ * Accepts: any error a `catch` bound.
164
+ *
165
+ * Returns: the `code` of one of this library's errors, and the `name` of any
166
+ * other. Every library error shares one name, so the name alone would log
167
+ * `DynamoDBLangGraphError` for a refused input and a spent retry budget alike;
168
+ * the code is what tells them apart, and like a name it is an identifier, never
169
+ * a payload.
170
+ *
171
+ * Throws: nothing for an error. A value that cannot carry a property raises
172
+ * the `TypeError` reading its `name` raises, as reading it directly would.
173
+ */
174
+ export declare function failureLabel(error: Error): string;
175
+ /**
176
+ * A caught value as an `Error`.
177
+ *
178
+ * Kept in this module rather than in `boundary.ts`, which otherwise reads as
179
+ * its natural home: `shared/logging/secret-patterns.ts` calls this to
180
+ * normalise whatever a `catch` bound before redacting it, and `boundary.ts`
181
+ * itself calls `redactedMessage` while building the error it wraps a foreign
182
+ * failure into. Both edges are real, so the two modules cannot import each
183
+ * other without a cycle; this module depends on neither.
184
+ *
185
+ * Accepts: `value` — declared `Error` because callers narrow a catch clause
186
+ * with `toError(error as Error)`, but anything can be thrown in JavaScript:
187
+ * a string, `undefined`, a plain object, a `BigInt`, a symbol.
188
+ *
189
+ * Returns: the value itself when it is error-shaped — an object carrying a
190
+ * string `message`, which keeps an SDK error's own fields and `cause` intact;
191
+ * otherwise a fresh `Error` describing what was thrown.
192
+ *
193
+ * Throws: **nothing**. This runs inside `catch` blocks, so a throw here would
194
+ * discard the failure being reported and replace it with its own.
195
+ */
196
+ export declare function toError(value: Error): Error;
@@ -1,28 +1,174 @@
1
1
  "use strict";
2
+ /**
3
+ * Hides the one error class and what counts as an error at all.
4
+ *
5
+ * Every failure this package raises is a `DynamoDBLangGraphError` told apart by
6
+ * its code (record 19), recognisable across copies of the package by a brand
7
+ * rather than by `instanceof`; and whatever a caller's code or a dependency
8
+ * throws — a string, `undefined`, an object — is turned into an `Error` before
9
+ * anything reads it.
10
+ */
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DynamoDbLangGraphError = void 0;
4
- exports.isDynamoDbLangGraphError = isDynamoDbLangGraphError;
12
+ exports.DynamoDBLangGraphError = void 0;
13
+ exports.isDynamoDBLangGraphError = isDynamoDBLangGraphError;
14
+ exports.hasErrorCode = hasErrorCode;
15
+ exports.failureLabel = failureLabel;
16
+ exports.toError = toError;
17
+ const error_code_1 = require("./error-code");
5
18
  const ERROR_BRAND = Symbol.for('@farukada/aws-langgraph-dynamodb-ts/error');
19
+ /**
20
+ * A shallow copy of `details` with every array copied too, so a caller reusing
21
+ * its request buffer or failure list cannot rewrite what the error reported.
22
+ * Anything that is not an object is returned as it is: building an error may
23
+ * not fail.
24
+ */
25
+ function copyDetails(details) {
26
+ if (details === null || typeof details !== 'object')
27
+ return details;
28
+ return Object.fromEntries(Object.entries(details).map(([key, value]) => [key, Array.isArray(value) ? [...value] : value]));
29
+ }
6
30
  /**
7
31
  * Base class for every error this library throws. Carries a branchable
8
- * {@link ErrorCode}, structured {@link ErrorContext}, and a native `cause`
9
- * chain. Detected via {@link isDynamoDbLangGraphError} (a symbol brand) rather
10
- * than `instanceof`, which is banned repo-wide.
32
+ * {@link ErrorCode}, structured {@link ErrorContext}, code-specific
33
+ * {@link details}, and a native `cause` chain. Detected via
34
+ * {@link isDynamoDBLangGraphError} (a symbol brand) rather than `instanceof`,
35
+ * which is banned repo-wide.
11
36
  */
12
- class DynamoDbLangGraphError extends Error {
37
+ class DynamoDBLangGraphError extends Error {
13
38
  code;
14
39
  context;
15
- constructor(message, code, context = {}, cause) {
40
+ /**
41
+ * Accepts: `message` — already redacted by whoever composed it, since it reaches
42
+ * `err.message`, which an application may print without a redacting logger.
43
+ * `code` — the code this error branches on. `context` — identifiers and counts
44
+ * only, never a payload or a credential. It is **copied**, so a caller that
45
+ * reuses one builder object cannot rewrite the context of an error already in
46
+ * flight; `null` reads as an absent one. `cause` — the failure below this one,
47
+ * kept as the native `cause` chain. `details` — the code-specific record
48
+ * {@link ErrorDetailsByCode} names, copied like `context`. The parameter is
49
+ * optional for every code, including the two whose `details` property is
50
+ * typed as always present (`BATCH_WRITE_INCOMPLETE`, `COMPENSATION_FAILED`):
51
+ * nothing at compile time stops a direct `new` from leaving it out, and an
52
+ * error built that way has no `details` at runtime whatever its type says.
53
+ * Inside this package those two codes are only ever built by the factories
54
+ * that always pass them.
55
+ *
56
+ * Returns: the error, branded so {@link isDynamoDBLangGraphError} recognises it
57
+ * across realms and across two copies of this package. The brand is
58
+ * non-enumerable, so it never reaches a log or a JSON serialization.
59
+ *
60
+ * Throws: nothing; building an error may not fail.
61
+ */
62
+ constructor(message, code, context = {}, cause, details) {
16
63
  super(message, cause === undefined ? undefined : { cause });
17
- this.name = 'DynamoDbLangGraphError';
64
+ this.name = 'DynamoDBLangGraphError';
18
65
  this.code = code;
19
- this.context = context;
66
+ this.context = { ...context };
67
+ if (details !== undefined)
68
+ this.details = copyDetails(details);
20
69
  Object.defineProperty(this, ERROR_BRAND, { value: true, enumerable: false });
21
70
  }
22
71
  }
23
- exports.DynamoDbLangGraphError = DynamoDbLangGraphError;
24
- /** True when `value` is a {@link DynamoDbLangGraphError}, detected by brand. */
25
- function isDynamoDbLangGraphError(value) {
26
- return ERROR_BRAND in value;
72
+ exports.DynamoDBLangGraphError = DynamoDBLangGraphError;
73
+ /**
74
+ * Whether `value` is one of this library's errors.
75
+ *
76
+ * Accepts: any error, from any realm or any copy of this package — and, since
77
+ * the documented place to call this is inside a `catch`, any other value a
78
+ * `throw` can produce: `null`, `undefined`, a string, a number, a symbol.
79
+ *
80
+ * Returns: whether it carries the brand, narrowed to the union discriminated by
81
+ * `code`. A symbol registered by name, not `instanceof`: two copies of this
82
+ * package in one dependency tree produce two classes but one symbol, and an
83
+ * error crossing a realm boundary keeps its properties while losing its
84
+ * prototype. Anything that cannot carry a property answers `false`. Earlier
85
+ * releases set the same brand, so an older copy of this package installed
86
+ * beside this one has its errors recognised too — in that release's shape: no
87
+ * `details`, the counts as flat properties, and possibly a code this union
88
+ * does not list (`UPSTREAM`).
89
+ *
90
+ * Throws: nothing. The `in` operator raises a `TypeError` on a non-object, and
91
+ * a guard that throws inside the `catch` it was called from would replace the
92
+ * failure the caller is reporting with one of its own.
93
+ */
94
+ function isDynamoDBLangGraphError(value) {
95
+ return typeof value === 'object' && value !== null && ERROR_BRAND in value;
96
+ }
97
+ /**
98
+ * Whether `value` is one of this library's errors carrying `code`.
99
+ *
100
+ * Accepts: anything a `catch` can bind. `code` — the code to test for.
101
+ *
102
+ * Returns: `true` only for a branded error whose `code` is `code`, narrowed so
103
+ * its `details` are typed. An unbranded object that merely carries a `code`
104
+ * property is not one: recognition is by brand and code together, never by a
105
+ * name or a shape.
106
+ *
107
+ * Throws: nothing, for any value.
108
+ */
109
+ function hasErrorCode(value, code) {
110
+ return isDynamoDBLangGraphError(value) && value.code === code;
111
+ }
112
+ /**
113
+ * What a log line calls a failure.
114
+ *
115
+ * Accepts: any error a `catch` bound.
116
+ *
117
+ * Returns: the `code` of one of this library's errors, and the `name` of any
118
+ * other. Every library error shares one name, so the name alone would log
119
+ * `DynamoDBLangGraphError` for a refused input and a spent retry budget alike;
120
+ * the code is what tells them apart, and like a name it is an identifier, never
121
+ * a payload.
122
+ *
123
+ * Throws: nothing for an error. A value that cannot carry a property raises
124
+ * the `TypeError` reading its `name` raises, as reading it directly would.
125
+ */
126
+ function failureLabel(error) {
127
+ return isDynamoDBLangGraphError(error) ? error.code : error.name;
128
+ }
129
+ /**
130
+ * A description of a thrown value that is not an `Error`, for its message.
131
+ *
132
+ * `JSON.stringify` is the best available rendering and it throws on a circular
133
+ * structure and on a `BigInt`, so it is guarded: this runs inside a `catch`,
134
+ * where throwing would replace the failure the caller is trying to report.
135
+ */
136
+ function describeThrown(value) {
137
+ if (typeof value === 'string')
138
+ return value;
139
+ if (value === undefined || value === null)
140
+ return `${String(value)} was thrown`;
141
+ try {
142
+ return JSON.stringify(value) ?? `a ${typeof value} value was thrown`;
143
+ }
144
+ catch {
145
+ return `an unserializable ${typeof value} value was thrown`;
146
+ }
147
+ }
148
+ /**
149
+ * A caught value as an `Error`.
150
+ *
151
+ * Kept in this module rather than in `boundary.ts`, which otherwise reads as
152
+ * its natural home: `shared/logging/secret-patterns.ts` calls this to
153
+ * normalise whatever a `catch` bound before redacting it, and `boundary.ts`
154
+ * itself calls `redactedMessage` while building the error it wraps a foreign
155
+ * failure into. Both edges are real, so the two modules cannot import each
156
+ * other without a cycle; this module depends on neither.
157
+ *
158
+ * Accepts: `value` — declared `Error` because callers narrow a catch clause
159
+ * with `toError(error as Error)`, but anything can be thrown in JavaScript:
160
+ * a string, `undefined`, a plain object, a `BigInt`, a symbol.
161
+ *
162
+ * Returns: the value itself when it is error-shaped — an object carrying a
163
+ * string `message`, which keeps an SDK error's own fields and `cause` intact;
164
+ * otherwise a fresh `Error` describing what was thrown.
165
+ *
166
+ * Throws: **nothing**. This runs inside `catch` blocks, so a throw here would
167
+ * discard the failure being reported and replace it with its own.
168
+ */
169
+ function toError(value) {
170
+ if (value !== null && typeof value === 'object' && typeof value.message === 'string') {
171
+ return value;
172
+ }
173
+ return new Error(describeThrown(value));
27
174
  }
28
- //# sourceMappingURL=base-error.js.map
@@ -0,0 +1,71 @@
1
+ /**
2
+ * Hides what crosses the public boundary.
3
+ *
4
+ * Only this package's own error leaves a public method (record 13): an error of
5
+ * its own passes through with the operation named, and anything else — an SDK
6
+ * failure, a caller's thrown value — is classified and wrapped with its cause
7
+ * attached and its text redacted.
8
+ */
9
+ import { type AnyDynamoDBLangGraphError, DynamoDBLangGraphError } from './base-error';
10
+ /**
11
+ * Normalise anything escaping a public method into the library's error model.
12
+ *
13
+ * Accepts: anything a `catch` produced — an `Error`, or a value that is not one
14
+ * (`toError` settles that first).
15
+ *
16
+ * Returns: a branded library error unchanged, since its code was assigned
17
+ * closer to the failure and wins; anything else wrapped by
18
+ * {@link wrapForeignError}, with the code the classifier assigns.
19
+ *
20
+ * Throws: nothing. It runs inside a `catch`, where throwing would discard the
21
+ * failure being reported and replace it with its own.
22
+ */
23
+ export declare function toPublicError(error: Error, operation: string): AnyDynamoDBLangGraphError;
24
+ /**
25
+ * Run a public operation so that every rejection is a library error.
26
+ *
27
+ * Accepts: `operation` — the public method's name, which the wrapped error
28
+ * carries. `fn` — the work.
29
+ *
30
+ * Returns: whatever `fn` resolves to, untouched.
31
+ *
32
+ * Throws: a library error, always. Applied once, at each adapter class method,
33
+ * so internal code can keep rethrowing SDK errors verbatim — the retry
34
+ * classifier depends on their shape, and wrapping them early would blind it.
35
+ */
36
+ export declare function guardPublic<T>(operation: string, fn: () => Promise<T>): Promise<T>;
37
+ /**
38
+ * The same guard for a streaming result.
39
+ *
40
+ * Accepts: `operation` — the public method's name. `source` — the generator to
41
+ * relay.
42
+ *
43
+ * Returns: a generator yielding the source's items untouched. A consumer that
44
+ * stops early still closes the source, so an abandoned listing stops reading
45
+ * rather than paging on in the background.
46
+ *
47
+ * Throws: a library error, always — including for a failure raised
48
+ * mid-iteration, which is the case a `try` around the loop body would miss.
49
+ */
50
+ export declare function guardPublicIterable<T>(operation: string, source: AsyncGenerator<T>): AsyncGenerator<T>;
51
+ /**
52
+ * A failure from below this library, as one of its errors.
53
+ *
54
+ * Accepts: `cause` — whatever a `catch` bound: an AWS SDK error, a transport
55
+ * error, or what a `VectorBackend`, `Embeddings`, `serde` or `MultiSessionHistory`
56
+ * threw. `operation` — the public method it surfaced through.
57
+ *
58
+ * Returns: an error whose code is {@link classifyAwsError}'s answer for
59
+ * {@link classifiableCause} of the normalised `cause` — so an AWS or network
60
+ * failure found down the cause chain still earns its own code rather than
61
+ * `UNEXPECTED_ERROR`. Its context names `operation` and — for whichever node
62
+ * was classified — `awsErrorName`, `requestId` and `httpStatusCode`. Its
63
+ * `cause` is the original, normalised through {@link toError}, kept whole
64
+ * regardless of which node down the chain supplied the code. The message
65
+ * quotes the cause's own name cut at the log cap and its own text redacted
66
+ * and cut at the relay cap, because `err.message` reaches applications that
67
+ * print it without a redacting logger.
68
+ *
69
+ * Throws: nothing, for any value.
70
+ */
71
+ export declare function wrapForeignError(cause: Error, operation: string): DynamoDBLangGraphError;