@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
@@ -1,84 +1,387 @@
1
1
  "use strict";
2
+ /**
3
+ * Hides the rules every caller-supplied primitive must pass.
4
+ *
5
+ * What makes a string an identifier safe inside a key, an integer a page size
6
+ * this package serves, and an array a copy holding only strings is decided
7
+ * once here. Only `parseLimit` returns a branded type of its own —
8
+ * `PageLimit`, which only it can build (record 21); every other rule's
9
+ * `parse*` form returns the plain checked value, and a feature parser brands
10
+ * it into its own type. Feature parsers compose these rules rather than
11
+ * restate them, so tightening one changes every method at once.
12
+ */
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validateNonEmptyString = validateNonEmptyString;
4
- exports.validateInteger = validateInteger;
5
- exports.validateNonEmptyArray = validateNonEmptyArray;
14
+ exports.MAX_PAGE_LIMIT = void 0;
15
+ exports.parseString = parseString;
16
+ exports.assertNonEmptyString = assertNonEmptyString;
17
+ exports.parseInteger = parseInteger;
18
+ exports.assertInteger = assertInteger;
19
+ exports.parseLimit = parseLimit;
20
+ exports.parseStringArray = parseStringArray;
21
+ exports.assertStringArray = assertStringArray;
6
22
  exports.assertNoControlChars = assertNoControlChars;
7
- exports.assertNoSeparator = assertNoSeparator;
8
- exports.validateIdentifier = validateIdentifier;
9
- exports.validateArrayMaxDepth = validateArrayMaxDepth;
23
+ exports.assertWellFormed = assertWellFormed;
24
+ exports.parseKeySegment = parseKeySegment;
25
+ exports.parseIdentifier = parseIdentifier;
10
26
  const errors_1 = require("../errors/errors");
11
- /** Throw {@link ValidationError} unless `value` is a non-empty string. */
12
- function validateNonEmptyString(value, field) {
13
- if (typeof value !== 'string' || value.length === 0) {
14
- throw new errors_1.ValidationError(`${field} must be a non-empty string`, field);
27
+ /**
28
+ * Largest `limit` any read accepts, on every method that takes one.
29
+ *
30
+ * Chosen from what a page costs, which is linear in `limit` and amortised
31
+ * nowhere: every row of a page is held decoded and resident until the whole
32
+ * page is handed back, and an offloaded row is an S3 GET and a decompression
33
+ * of its own, `readConcurrency` at a time. A page of N rows is therefore N
34
+ * objects held at once and, in the worst case, N round trips before the caller
35
+ * sees the first of them.
36
+ *
37
+ * Ten thousand is where this package already says a read has stopped being one
38
+ * and become an export: `MAX_TOTAL_ROWS_IN_MEMORY`
39
+ * (`src/shared/dynamodb/paginate.ts`) refuses to collect more than that across
40
+ * a whole paginated query, and `LIST_SCAN_WARN_THRESHOLD`
41
+ * (`src/shared/dynamodb/paginate.ts`) tells an operator about a listing that
42
+ * walks that far. A single page allowed past either would hold more than every
43
+ * other path in the package may. Its own literal at the same value rather than
44
+ * an alias of them, for the reason `LIST_SCAN_WARN_THRESHOLD`
45
+ * (`src/shared/dynamodb/paginate.ts`) records.
46
+ *
47
+ * What it does *not* do is promise a memory figure: rows are the caller's own
48
+ * data, so ten thousand session summaries are a few megabytes while a hundred
49
+ * items at `MAX_INLINE_PAYLOAD_BYTES` (`src/shared/codec/codec.ts`) are forty.
50
+ * It bounds a typo — a `1e12` that would otherwise resolve — not a working set.
51
+ *
52
+ * What a caller loses at the ceiling is one large page, never the rows: every
53
+ * bounded read has a way to continue — `listSessions` a cursor, `search` an
54
+ * `offset`, `getMessages` a `before`, and `saver.list` streams and never
55
+ * accumulates — so an answer larger than this is paid for as pages.
56
+ */
57
+ exports.MAX_PAGE_LIMIT = 10_000;
58
+ /**
59
+ * The value as a string, or a refusal.
60
+ *
61
+ * Accepts: `value` — anything. A JavaScript caller, or a TypeScript caller
62
+ * whose input came from JSON, can pass any type where a string is declared, and
63
+ * every rule after this one reaches a string method.
64
+ *
65
+ * Returns: `value`, typed as the string it was checked to be.
66
+ *
67
+ * Throws: `VALIDATION` naming `field`, for anything that is not a string.
68
+ */
69
+ function parseString(value, field) {
70
+ if (typeof value !== 'string') {
71
+ throw (0, errors_1.validationError)(`${field} must be a string`, field);
15
72
  }
73
+ return value;
16
74
  }
17
- /** Throw {@link ValidationError} unless `value` is an integer within bounds. */
18
- function validateInteger(value, field, bounds = {}) {
75
+ /**
76
+ * The value as a string holding at least one non-whitespace character.
77
+ *
78
+ * Accepts: `value` — anything; `''` and whitespace-only are refused alongside
79
+ * non-strings.
80
+ *
81
+ * Returns: `value`, typed as a string.
82
+ *
83
+ * Throws: `VALIDATION` naming `field`.
84
+ */
85
+ function parseNonBlankString(value, field) {
86
+ const text = parseString(value, field);
87
+ if (text.trim().length === 0) {
88
+ throw (0, errors_1.validationError)(`${field} must be a non-empty string (whitespace-only counts as empty)`, field);
89
+ }
90
+ return text;
91
+ }
92
+ /**
93
+ * Throw `VALIDATION` unless `value` is a string holding at least one
94
+ * non-whitespace character.
95
+ *
96
+ * Accepts: `value` — any type; `''` and whitespace-only are rejected alongside
97
+ * non-strings. `field` — the option or identifier name carried on the error.
98
+ * The rule is {@link parseNonBlankString}'s; this form is for a value the
99
+ * caller keeps under its declared type.
100
+ *
101
+ * Returns: nothing: the value is kept under its declared type, and this
102
+ * checks it.
103
+ *
104
+ * Throws: `VALIDATION` naming `field`.
105
+ */
106
+ function assertNonEmptyString(value, field) {
107
+ parseNonBlankString(value, field);
108
+ }
109
+ /** Throw `VALIDATION` unless `value` encodes to at most `maxBytes` of UTF-8. */
110
+ function assertMaxBytes(value, field, maxBytes) {
111
+ parseString(value, field);
112
+ const bytes = Buffer.byteLength(value, 'utf8');
113
+ if (bytes > maxBytes) {
114
+ throw (0, errors_1.validationError)(`${field} must be at most ${maxBytes} bytes of UTF-8 (received ${bytes})`, field);
115
+ }
116
+ }
117
+ /**
118
+ * The value as an integer inside `bounds`.
119
+ *
120
+ * Accepts: `value` — anything; a non-number, a fraction, `NaN` and `Infinity`
121
+ * are all refused by the integer rule. `bounds` — omitted or `{}` bounds
122
+ * nothing; `min` and `max` are inclusive.
123
+ *
124
+ * Returns: `value`, typed as a number.
125
+ *
126
+ * Throws: `VALIDATION` naming `field`; the integer rule is reported before
127
+ * either bound.
128
+ */
129
+ function parseInteger(value, field, bounds = {}) {
19
130
  if (typeof value !== 'number' || !Number.isInteger(value)) {
20
- throw new errors_1.ValidationError(`${field} must be an integer`, field);
131
+ throw (0, errors_1.validationError)(`${field} must be an integer`, field);
21
132
  }
22
133
  if (bounds.min !== undefined && value < bounds.min) {
23
- throw new errors_1.ValidationError(`${field} must be >= ${bounds.min}`, field);
134
+ throw (0, errors_1.validationError)(`${field} must be >= ${bounds.min}`, field);
24
135
  }
25
136
  if (bounds.max !== undefined && value > bounds.max) {
26
- throw new errors_1.ValidationError(`${field} must be <= ${bounds.max}`, field);
137
+ throw (0, errors_1.validationError)(`${field} must be <= ${bounds.max}`, field);
27
138
  }
139
+ return value;
140
+ }
141
+ /**
142
+ * Throw `VALIDATION` unless `value` is an integer inside `bounds`.
143
+ *
144
+ * Accepts: `value` — any type; a non-number, a fraction, `NaN` and `Infinity`
145
+ * are all rejected by the integer rule. `bounds` — omitted or `{}` bounds
146
+ * nothing, `min` and `max` are inclusive and may be given together or alone.
147
+ * The rule is {@link parseInteger}'s; this form is for a value the caller
148
+ * keeps under its declared type.
149
+ *
150
+ * Returns: nothing: the value is kept under its declared type, and this
151
+ * checks it.
152
+ *
153
+ * Throws: `VALIDATION` naming `field`; the integer rule is reported before
154
+ * either bound.
155
+ */
156
+ function assertInteger(value, field, bounds = {}) {
157
+ parseInteger(value, field, bounds);
158
+ }
159
+ /**
160
+ * The value as a page size this package will serve: an integer from `min` to
161
+ * {@link MAX_PAGE_LIMIT}.
162
+ *
163
+ * One rule for every `limit` a public method takes. Without it they would
164
+ * disagree three ways — no minimum on `saver.list`, so `limit: -1` would
165
+ * resolve; `0` refused by the history reads and accepted by the store — and
166
+ * none would have a ceiling, so `limit: 1e12` would resolve on five methods.
167
+ * The same mistake would be answered differently depending on which method a
168
+ * caller happened to reach for.
169
+ *
170
+ * What survives that unification is one message shape, one ceiling and two
171
+ * floors, because zero does not ask for the same thing on every method. A zero
172
+ * *page* is answered: the caller asked a listing for nothing, holds the empty
173
+ * array it returned, and can see that is what it got. A zero *conversation
174
+ * window* is refused: it feeds a model rather than a caller, an empty
175
+ * conversation is indistinguishable from one that never happened, and the
176
+ * answer the model gives is persisted as the transcript. So every call site
177
+ * passes its floor and says why; `1` is passed from exactly one place,
178
+ * `parseMessageWindow` in `src/history/internal/parse.ts`, which is the
179
+ * check behind `history.getMessages` and `history.forSession` alike.
180
+ *
181
+ * Accepts: `value` — any type; a non-number, a fraction, `NaN` and `Infinity`
182
+ * are all rejected by the integer rule. `min` — `0` where an empty result is a
183
+ * request the call site answers without issuing a read, `1` where an empty
184
+ * result would be mistaken for an empty conversation. A negative value is
185
+ * refused at either floor rather than read as zero: it is a page size that was
186
+ * computed, and the computation went wrong.
187
+ *
188
+ * Returns: `value` as a {@link PageLimit}.
189
+ *
190
+ * Throws: `VALIDATION` naming `limit`, quoting the bound broken — the floor
191
+ * or {@link MAX_PAGE_LIMIT} — so the caller is told what the rule is rather
192
+ * than only that it has one.
193
+ */
194
+ function parseLimit(value, min) {
195
+ return parseInteger(value, 'limit', { min, max: exports.MAX_PAGE_LIMIT });
28
196
  }
29
- /** Throw {@link ValidationError} unless `value` is a non-empty array. */
30
- function validateNonEmptyArray(value, field) {
31
- if (!Array.isArray(value) || value.length === 0) {
32
- throw new errors_1.ValidationError(`${field} must be a non-empty array`, field);
197
+ /**
198
+ * The value as an array of strings, copied.
199
+ *
200
+ * Accepts: `value` — anything; a non-array is refused, as is an array holding
201
+ * anything but a string. An empty array is valid.
202
+ *
203
+ * Returns: a copy of `value`, so a caller changing its own array afterwards
204
+ * changes nothing this package acts on.
205
+ *
206
+ * Throws: `VALIDATION` naming `field`, its message identifying the offending
207
+ * index. Walked by position rather than `Array.prototype.some`, which skips a
208
+ * hole in a sparse array instead of visiting it, and copied by position rather
209
+ * than `Array.prototype.slice`, which carries a hole forward instead of
210
+ * filling it: unchecked, a hole passed as a string and reached a caller who
211
+ * declared `string[]`.
212
+ */
213
+ function parseStringArray(value, field) {
214
+ if (!Array.isArray(value)) {
215
+ throw (0, errors_1.validationError)(`${field} must be an array of strings`, field);
216
+ }
217
+ const result = [];
218
+ for (let index = 0; index < value.length; index += 1) {
219
+ const item = value[index];
220
+ if (typeof item !== 'string') {
221
+ throw (0, errors_1.validationError)(`${field}[${index}] must be a string`, field);
222
+ }
223
+ result.push(item);
33
224
  }
225
+ return result;
34
226
  }
35
- /** Return `true` if `value` contains any ASCII control character. */
227
+ /**
228
+ * Throw `VALIDATION` unless `value` is an array of strings.
229
+ *
230
+ * Accepts: `value` — declared `readonly string[]` for a caller whose types
231
+ * hold; a non-array is rejected, as is an array holding anything but a
232
+ * string. An empty array is valid. The rule is {@link parseStringArray}'s;
233
+ * this form is for a value the caller keeps under its declared type.
234
+ *
235
+ * Returns: nothing: the value is kept under its declared type, and this
236
+ * checks it.
237
+ *
238
+ * Throws: `VALIDATION` naming `field`.
239
+ */
240
+ function assertStringArray(value, field) {
241
+ parseStringArray(value, field);
242
+ }
243
+ /** True when `value` holds a C0 control character, DEL, or a C1 control character. */
36
244
  function hasControlChar(value) {
37
245
  for (let i = 0; i < value.length; i++) {
38
246
  const code = value.charCodeAt(i);
39
- if (code <= 0x1f || code === 0x7f) {
247
+ if (code <= 0x1f || (code >= 0x7f && code <= 0x9f))
40
248
  return true;
41
- }
42
249
  }
43
250
  return false;
44
251
  }
45
- /** Throw {@link ValidationError} if `value` contains an ASCII control character. */
252
+ /**
253
+ * Throw `VALIDATION` unless `value` is free of control characters.
254
+ *
255
+ * Accepts: `value` — any type, non-strings rejected first by
256
+ * {@link parseString}. Rejected code points are C0 (`U+0000`–`U+001F`), DEL
257
+ * (`U+007F`) and C1 (`U+0080`–`U+009F`). The rule is this function's own:
258
+ * {@link parseKeySegment} applies it to every key segment and identifier by
259
+ * calling this one, and this form serves a value the caller keeps under its
260
+ * declared type.
261
+ *
262
+ * Returns: nothing: the value is kept under its declared type, and this
263
+ * checks it.
264
+ *
265
+ * Throws: `VALIDATION` naming `field`.
266
+ *
267
+ * Guarantees: an accepted value cannot terminate a log line or open a terminal
268
+ * escape sequence — neither `ESC` (`U+001B`) nor the single-byte `CSI`
269
+ * (`U+009B`) survives this rule. Identifiers are written into log lines by this
270
+ * package, and unneutralised output is CWE-117
271
+ * (https://cwe.mitre.org/data/definitions/117.html).
272
+ */
46
273
  function assertNoControlChars(value, field) {
274
+ parseString(value, field);
47
275
  if (hasControlChar(value)) {
48
- throw new errors_1.ValidationError(`${field} must not contain control characters`, field);
276
+ throw (0, errors_1.validationError)(`${field} must not contain control characters`, field);
277
+ }
278
+ }
279
+ /**
280
+ * Throw `VALIDATION` unless every surrogate in `value` is part of a
281
+ * pair.
282
+ *
283
+ * Accepts: `value` — any type, non-strings rejected first by
284
+ * {@link parseString}. The rule is this function's own:
285
+ * {@link parseKeySegment} applies it to every key segment and identifier by
286
+ * calling this one, and this form serves a value the caller keeps under its
287
+ * declared type.
288
+ *
289
+ * Returns: nothing: the value is kept under its declared type, and this
290
+ * checks it.
291
+ *
292
+ * Throws: `VALIDATION` naming `field`.
293
+ *
294
+ * Guarantees: the mapping from an accepted value to its UTF-8 encoding is
295
+ * injective. `Buffer.from(value, 'utf8')` replaces a lone surrogate with
296
+ * U+FFFD, so two values differing only there would encode identically and,
297
+ * where that encoding is a storage key, address one object.
298
+ */
299
+ function assertWellFormed(value, field) {
300
+ parseString(value, field);
301
+ if (!value.isWellFormed()) {
302
+ throw (0, errors_1.validationError)(`${field} must be well-formed UTF-16 (it contains an unpaired surrogate, which does not ` +
303
+ 'survive encoding to UTF-8)', field);
49
304
  }
50
305
  }
51
- /** Throw {@link ValidationError} if `value` contains the reserved `separator`. */
306
+ /** Throw `VALIDATION` if `value` contains `separator`. */
52
307
  function assertNoSeparator(value, separator, field) {
308
+ parseString(value, field);
53
309
  if (value.includes(separator)) {
54
- throw new errors_1.ValidationError(`${field} must not contain the reserved "${separator}" separator`, field);
310
+ throw (0, errors_1.validationError)(`${field} must not contain the reserved "${separator}" separator`, field);
55
311
  }
56
312
  }
57
313
  /**
58
- * Validate a caller-supplied identifier that reaches a DynamoDB key: non-empty,
59
- * free of the reserved `separator`, and free of control characters. The last
60
- * rule matters even though DynamoDB itself accepts control characters — an
61
- * identifier is echoed into logs, so an unvalidated ANSI escape is a
62
- * log/terminal-injection surface for any app that writes these values out.
314
+ * One segment of a key, which may be empty: every rule of
315
+ * {@link parseIdentifier} except non-blank. The checkpoint namespace is the one
316
+ * such value — `''` *is* the root namespace — and it is still a segment of both
317
+ * the sort key and the offloaded object's key, so a lone surrogate or a control
318
+ * character in it is as damaging as in any other.
319
+ *
320
+ * Accepts: `value` — anything. `separator`, `field`, `maxBytes` — as
321
+ * {@link parseIdentifier}.
322
+ *
323
+ * Returns: `value`, typed as a string.
324
+ *
325
+ * Throws: `VALIDATION` naming `field`, in this order: string, at most
326
+ * `maxBytes` of UTF-8, free of `separator`, free of control characters,
327
+ * well-formed UTF-16.
63
328
  */
64
- function validateIdentifier(value, separator, field) {
65
- validateNonEmptyString(value, field);
66
- assertNoSeparator(value, separator, field);
67
- assertNoControlChars(value, field);
329
+ function parseKeySegment(value, separator, field, maxBytes) {
330
+ const text = parseString(value, field);
331
+ assertMaxBytes(text, field, maxBytes);
332
+ assertNoSeparator(text, separator, field);
333
+ assertNoControlChars(text, field);
334
+ assertWellFormed(text, field);
335
+ return text;
68
336
  }
69
- /** Throw {@link ValidationError} if nested-array depth exceeds `maxDepth`. */
70
- function validateArrayMaxDepth(value, field, maxDepth) {
71
- const depthOf = (node, depth) => {
72
- if (!Array.isArray(node)) {
73
- return depth;
74
- }
75
- if (depth > maxDepth) {
76
- return depth;
77
- }
78
- return node.reduce((max, child) => Math.max(max, depthOf(child, depth + 1)), depth);
79
- };
80
- if (depthOf(value, 0) > maxDepth) {
81
- throw new errors_1.ValidationError(`${field} exceeds maximum array depth of ${maxDepth}`, field);
82
- }
337
+ /**
338
+ * The value as a caller-supplied identifier that reaches a DynamoDB key or an
339
+ * S3 object key, checked.
340
+ *
341
+ * Accepts: `value` — any type. `separator`, `field`, `maxBytes` — as the rules
342
+ * below.
343
+ *
344
+ * Returns: `value`, typed as a string. The caller's parser brands it.
345
+ *
346
+ * Throws: `VALIDATION` naming `field`. The rules apply in this order, and
347
+ * the order is part of the contract because a caller branches on which one
348
+ * failed: string, non-blank, at most `maxBytes` of UTF-8, free of `separator`,
349
+ * free of control characters, well-formed UTF-16.
350
+ *
351
+ * Guarantees: every guarantee of {@link assertNoControlChars} and
352
+ * {@link assertWellFormed} holds for an accepted value, and it composes into a
353
+ * key segment without escaping.
354
+ *
355
+ * Not guaranteed, and deliberately so: an accepted identifier is **not**
356
+ * normalised, and Unicode format characters (`Cf` — `U+200B` ZERO WIDTH SPACE,
357
+ * `U+200C`/`U+200D` the zero-width non-joiner and joiner, `U+FEFF`, `U+202E`
358
+ * RIGHT-TO-LEFT OVERRIDE) and the separators `U+2028`/`U+2029` are all
359
+ * accepted. Two facts make that safe, and one makes it necessary.
360
+ *
361
+ * It is safe because none of them can produce a collision. DynamoDB orders and
362
+ * compares strings by their UTF-8 bytes, and {@link assertWellFormed} has
363
+ * already made the mapping from an accepted identifier to those bytes
364
+ * injective — so two identifiers differing anywhere address two different
365
+ * rows. An identifier that reaches an S3 key is base64url-encoded on the way
366
+ * (`encodeKeyPart`), so none of these characters appears in a key at all. What
367
+ * one actually costs is a log line, a terminal or a console that renders two
368
+ * distinct identifiers alike: confusion for a reader, not a row either of them
369
+ * can reach. Terminal escapes and line breaks, which *are* an injection rather
370
+ * than a rendering, are refused by {@link assertNoControlChars}.
371
+ *
372
+ * It is necessary because refusing `Cf` would refuse ordinary text rather than
373
+ * hostile text. `U+200C` and `U+200D` carry meaning in Persian, Hindi and the
374
+ * Indic scripts — the Persian for "goes" is spelled with a `U+200C` — and
375
+ * `U+200D` is what joins the code points of every multi-person emoji. A rule
376
+ * against `Cf` would reject a `thread_id` or a store `key` taken from ordinary
377
+ * user text, in a package whose identifiers are the caller's own.
378
+ *
379
+ * Normalising would be worse than breaking: `NFC` folds `e` + `U+0301` onto
380
+ * `U+00E9`, so a row written under one form would afterwards be addressed
381
+ * under the other and the caller's data would stop being found. That is silent
382
+ * loss on upgrade, bought with a rendering nicety. A caller who wants either
383
+ * rule can apply it to its own identifiers before passing them.
384
+ */
385
+ function parseIdentifier(value, separator, field, maxBytes) {
386
+ return parseKeySegment(parseNonBlankString(value, field), separator, field, maxBytes);
83
387
  }
84
- //# sourceMappingURL=primitives.js.map
@@ -1,21 +1,77 @@
1
+ /**
2
+ * Hides how a `ttl` option becomes an expiry.
3
+ *
4
+ * A caller gives days or seconds. The one-unit rule, the five-year cap, the
5
+ * epoch second DynamoDB's TTL attribute takes, and the S3 lifecycle days that
6
+ * keep an offloaded object alive past its row's sweep lag are all derived
7
+ * here, so the two spellings of the `ttl` option are accepted or rejected
8
+ * alike and no reader re-derives one unit from the other itself. A stored
9
+ * row's own epoch-second `ttl` is converted to milliseconds for `Date` where
10
+ * that row is read, not here.
11
+ */
12
+ /** Maximum TTL expressed in days (5 years). */
13
+ export declare const MAX_TTL_DAYS: number;
14
+ /** Maximum TTL expressed in seconds: the same five years as {@link MAX_TTL_DAYS}. */
15
+ export declare const MAX_TTL_SECONDS: number;
16
+ /**
17
+ * Extra days an S3 lifecycle rule adds over the TTL it backs. DynamoDB's TTL
18
+ * sweep can lag up to ~48 h past the `ttl` timestamp; the offloaded object
19
+ * must outlive its row, never the other way round.
20
+ */
21
+ export declare const S3_LIFECYCLE_SWEEP_MARGIN_DAYS = 2;
1
22
  /** Time-to-live expressed in whole days or whole seconds. */
2
23
  export type TtlOption = {
3
24
  days: number;
4
25
  } | {
5
26
  seconds: number;
6
27
  };
7
- /** Validate a {@link TtlOption} and resolve it to a positive number of seconds. */
28
+ /**
29
+ * A {@link TtlOption} resolved to a positive number of seconds.
30
+ *
31
+ * Accepts: `ttl` — declared as the two-shape union; a JavaScript caller, or a
32
+ * config built from JSON, can also reach `undefined`, a non-object, `{}`, an
33
+ * object carrying both keys and one carrying any other key, and each is
34
+ * rejected. Within a shape the value must be an integer of at least 1.
35
+ *
36
+ * Returns: whole seconds, `days × 86400` for the days form.
37
+ *
38
+ * Throws: `VALIDATION`, in this order, naming `ttl` for a value that is not
39
+ * an object, `ttl.<key>` for a key other than `days` or `seconds`, `ttl` for
40
+ * an object naming neither unit or both, and `ttl.days` or `ttl.seconds` for a
41
+ * value outside 1..five years. Both forms share that cap, so the two spellings
42
+ * of one duration are accepted or rejected alike.
43
+ */
8
44
  export declare function resolveTtlSeconds(ttl: TtlOption): number;
9
45
  /**
10
- * Resolve a {@link TtlOption} into a DynamoDB TTL attribute value: the Unix
11
- * epoch (seconds) at which the item expires.
46
+ * The value DynamoDB's TTL attribute takes for an item written now: the Unix
47
+ * epoch second at which it expires.
48
+ *
49
+ * Accepts: `ttl` — as {@link resolveTtlSeconds}. `now` — a clock returning
50
+ * epoch **milliseconds**, defaulting to `Date.now`; supplied by tests and by
51
+ * the adapters' clock seam.
52
+ *
53
+ * Returns: `floor(now() / 1000) + resolveTtlSeconds(ttl)`. Whole seconds,
54
+ * because DynamoDB reads the attribute as an epoch-second Number
55
+ * (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/time-to-live-ttl-before-you-start.html).
12
56
  *
13
- * @param now - Clock seam returning epoch milliseconds. Defaults to `Date.now`.
57
+ * Throws: whatever {@link resolveTtlSeconds} throws.
14
58
  */
15
59
  export declare function calculateTtlTimestamp(ttl: TtlOption, now?: () => number): number;
16
- /** Resolve a {@link TtlOption} to whole days, rounded up so the S3 lifecycle
17
- * expiration never fires before DynamoDB's own TTL sweep (which can lag up
18
- * to ~48h past the TTL timestamp) — expiring the S3 object first would leave
19
- * a live DynamoDB item pointing at a deleted payload. */
20
- export declare function resolveTtlDaysCeil(ttl: TtlOption): number;
21
- //# sourceMappingURL=ttl.d.ts.map
60
+ /**
61
+ * The `Days` of the S3 lifecycle expiration rule that backs a TTL.
62
+ *
63
+ * Accepts: `ttl` — as {@link resolveTtlSeconds}.
64
+ *
65
+ * Returns: the TTL rounded **up** to whole days plus
66
+ * {@link S3_LIFECYCLE_SWEEP_MARGIN_DAYS}, so always at least
67
+ * `1 + margin`.
68
+ *
69
+ * Throws: whatever {@link resolveTtlSeconds} throws.
70
+ *
71
+ * Guarantees: the object outlives the row that points at it. S3 expires an
72
+ * object at the first midnight UTC at least `Days` after creation, while
73
+ * DynamoDB may keep an expired item for up to 48 hours past its `ttl`
74
+ * (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/howitworks-ttl.html);
75
+ * the margin covers that lag, which a bare `{ days: N }` did not.
76
+ */
77
+ export declare function lifecycleExpirationDays(ttl: TtlOption): number;