@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.
- package/README.md +1720 -154
- package/dist/backfill/backfill.d.ts +168 -0
- package/dist/backfill/backfill.js +393 -0
- package/dist/checkpointer/actions/delete-thread.d.ts +47 -6
- package/dist/checkpointer/actions/delete-thread.js +58 -21
- package/dist/checkpointer/actions/get-tuple.d.ts +29 -4
- package/dist/checkpointer/actions/get-tuple.js +44 -10
- package/dist/checkpointer/actions/list.d.ts +46 -4
- package/dist/checkpointer/actions/list.js +121 -66
- package/dist/checkpointer/actions/put-writes.d.ts +41 -9
- package/dist/checkpointer/actions/put-writes.js +62 -77
- package/dist/checkpointer/actions/put.d.ts +83 -4
- package/dist/checkpointer/actions/put.js +177 -25
- package/dist/checkpointer/internal/delta-history.d.ts +112 -0
- package/dist/checkpointer/internal/delta-history.js +252 -0
- package/dist/checkpointer/internal/listing.d.ts +149 -0
- package/dist/checkpointer/internal/listing.js +245 -0
- package/dist/checkpointer/internal/parse.d.ts +262 -0
- package/dist/checkpointer/internal/parse.js +372 -0
- package/dist/checkpointer/internal/pending-writes.d.ts +275 -0
- package/dist/checkpointer/internal/pending-writes.js +588 -0
- package/dist/checkpointer/internal/read.d.ts +130 -0
- package/dist/checkpointer/internal/read.js +264 -0
- package/dist/checkpointer/internal/rows.d.ts +571 -0
- package/dist/checkpointer/internal/rows.js +834 -0
- package/dist/checkpointer/internal/setup.d.ts +42 -19
- package/dist/checkpointer/internal/setup.js +65 -29
- package/dist/checkpointer/saver.d.ts +256 -16
- package/dist/checkpointer/saver.js +275 -29
- package/dist/checkpointer/types.d.ts +39 -39
- package/dist/checkpointer/types.js +10 -1
- package/dist/factory/factory.d.ts +134 -28
- package/dist/factory/factory.js +240 -21
- package/dist/factory/types.d.ts +76 -0
- package/dist/factory/types.js +10 -0
- package/dist/history/actions/add-messages.d.ts +31 -4
- package/dist/history/actions/add-messages.js +38 -58
- package/dist/history/actions/clear.d.ts +49 -6
- package/dist/history/actions/clear.js +66 -14
- package/dist/history/actions/get-messages.d.ts +54 -6
- package/dist/history/actions/get-messages.js +126 -43
- package/dist/history/actions/list-sessions.d.ts +52 -10
- package/dist/history/actions/list-sessions.js +139 -40
- package/dist/history/actions/reconcile-count.d.ts +42 -10
- package/dist/history/actions/reconcile-count.js +45 -45
- package/dist/history/chat-message-history.d.ts +220 -33
- package/dist/history/chat-message-history.js +240 -43
- package/dist/history/internal/append.d.ts +212 -0
- package/dist/history/internal/append.js +500 -0
- package/dist/history/internal/message-read.d.ts +84 -0
- package/dist/history/internal/message-read.js +204 -0
- package/dist/history/internal/parse.d.ts +153 -0
- package/dist/history/internal/parse.js +252 -0
- package/dist/history/internal/rows.d.ts +195 -0
- package/dist/history/internal/rows.js +250 -0
- package/dist/history/internal/session.d.ts +331 -0
- package/dist/history/internal/session.js +628 -0
- package/dist/history/internal/setup.d.ts +52 -17
- package/dist/history/internal/setup.js +92 -21
- package/dist/history/session-adapter.d.ts +102 -7
- package/dist/history/session-adapter.js +103 -9
- package/dist/history/types.d.ts +80 -29
- package/dist/history/types.js +10 -1
- package/dist/index.d.ts +42 -11
- package/dist/index.js +33 -12
- package/dist/shared/adapter.d.ts +135 -0
- package/dist/shared/adapter.js +143 -0
- package/dist/shared/clock.d.ts +51 -2
- package/dist/shared/clock.js +57 -2
- package/dist/shared/codec/codec.d.ts +288 -13
- package/dist/shared/codec/codec.js +416 -19
- package/dist/shared/codec/compression.d.ts +43 -7
- package/dist/shared/codec/compression.js +53 -13
- package/dist/shared/codec/json-serde.d.ts +76 -4
- package/dist/shared/codec/json-serde.js +181 -8
- package/dist/shared/codec/s3/client-types.d.ts +53 -0
- package/dist/shared/codec/s3/client-types.js +26 -0
- package/dist/shared/codec/s3/client.d.ts +43 -10
- package/dist/shared/codec/s3/client.js +82 -9
- package/dist/shared/codec/s3/config.d.ts +242 -11
- package/dist/shared/codec/s3/config.js +293 -11
- package/dist/shared/codec/s3/lifecycle.d.ts +164 -6
- package/dist/shared/codec/s3/lifecycle.js +335 -27
- package/dist/shared/codec/s3/offloader.d.ts +393 -18
- package/dist/shared/codec/s3/offloader.js +595 -37
- package/dist/shared/concurrency.d.ts +43 -0
- package/dist/shared/concurrency.js +78 -0
- package/dist/shared/dynamodb/abort.d.ts +47 -0
- package/dist/shared/dynamodb/abort.js +59 -0
- package/dist/shared/dynamodb/batch-write.d.ts +77 -14
- package/dist/shared/dynamodb/batch-write.js +146 -27
- package/dist/shared/dynamodb/cancellation.d.ts +121 -4
- package/dist/shared/dynamodb/cancellation.js +147 -3
- package/dist/shared/dynamodb/client.d.ts +162 -8
- package/dist/shared/dynamodb/client.js +153 -5
- package/dist/shared/dynamodb/idempotent-write.d.ts +551 -0
- package/dist/shared/dynamodb/idempotent-write.js +593 -0
- package/dist/shared/dynamodb/paginate.d.ts +105 -9
- package/dist/shared/dynamodb/paginate.js +175 -7
- package/dist/shared/dynamodb/partition-delete.d.ts +185 -14
- package/dist/shared/dynamodb/partition-delete.js +314 -44
- package/dist/shared/dynamodb/recency-index.d.ts +231 -0
- package/dist/shared/dynamodb/recency-index.js +377 -0
- package/dist/shared/dynamodb/retry.d.ts +276 -8
- package/dist/shared/dynamodb/retry.js +433 -23
- package/dist/shared/dynamodb/table-schema.d.ts +190 -0
- package/dist/shared/dynamodb/table-schema.js +209 -0
- package/dist/shared/errors/base-error.d.ts +184 -10
- package/dist/shared/errors/base-error.js +160 -14
- package/dist/shared/errors/boundary.d.ts +71 -0
- package/dist/shared/errors/boundary.js +143 -0
- package/dist/shared/errors/classify.d.ts +97 -0
- package/dist/shared/errors/classify.js +257 -0
- package/dist/shared/errors/error-code.d.ts +77 -2
- package/dist/shared/errors/error-code.js +83 -1
- package/dist/shared/errors/errors.d.ts +158 -59
- package/dist/shared/errors/errors.js +219 -92
- package/dist/shared/logging/logger.d.ts +69 -3
- package/dist/shared/logging/logger.js +97 -3
- package/dist/shared/logging/redaction.d.ts +92 -8
- package/dist/shared/logging/redaction.js +273 -17
- package/dist/shared/logging/secret-patterns.d.ts +149 -19
- package/dist/shared/logging/secret-patterns.js +188 -27
- package/dist/shared/logging/truncate.d.ts +197 -0
- package/dist/shared/logging/truncate.js +231 -0
- package/dist/shared/options.d.ts +59 -7
- package/dist/shared/options.js +9 -1
- package/dist/shared/ulid.d.ts +77 -7
- package/dist/shared/ulid.js +103 -8
- package/dist/shared/validation/collaborators.d.ts +141 -0
- package/dist/shared/validation/collaborators.js +188 -0
- package/dist/shared/validation/option-shape.d.ts +89 -0
- package/dist/shared/validation/option-shape.js +113 -0
- package/dist/shared/validation/options.d.ts +145 -0
- package/dist/shared/validation/options.js +328 -0
- package/dist/shared/validation/primitives.d.ts +288 -21
- package/dist/shared/validation/primitives.js +353 -50
- package/dist/shared/validation/ttl.d.ts +66 -10
- package/dist/shared/validation/ttl.js +113 -15
- package/dist/store/actions/list-namespaces.d.ts +76 -6
- package/dist/store/actions/list-namespaces.js +166 -24
- package/dist/store/actions/put.d.ts +33 -8
- package/dist/store/actions/put.js +53 -60
- package/dist/store/actions/reconcile-vector-index.d.ts +31 -10
- package/dist/store/actions/reconcile-vector-index.js +34 -15
- package/dist/store/actions/search.d.ts +34 -6
- package/dist/store/actions/search.js +56 -51
- package/dist/store/internal/batch-plan.d.ts +26 -0
- package/dist/store/internal/batch-plan.js +109 -0
- package/dist/store/internal/filter.d.ts +36 -3
- package/dist/store/internal/filter.js +66 -15
- package/dist/store/internal/get-item.d.ts +45 -0
- package/dist/store/internal/get-item.js +115 -0
- package/dist/store/internal/item-write.d.ts +230 -0
- package/dist/store/internal/item-write.js +463 -0
- package/dist/store/internal/parse.d.ts +225 -0
- package/dist/store/internal/parse.js +350 -0
- package/dist/store/internal/rows.d.ts +355 -0
- package/dist/store/internal/rows.js +447 -0
- package/dist/store/internal/semantic-search.d.ts +161 -6
- package/dist/store/internal/semantic-search.js +360 -18
- package/dist/store/internal/setup.d.ts +77 -20
- package/dist/store/internal/setup.js +178 -47
- package/dist/store/internal/table-search.d.ts +100 -0
- package/dist/store/internal/table-search.js +213 -0
- package/dist/store/internal/vector-index.d.ts +247 -0
- package/dist/store/internal/vector-index.js +546 -0
- package/dist/store/store.d.ts +270 -17
- package/dist/store/store.js +329 -38
- package/dist/store/types.d.ts +76 -26
- package/dist/store/types.js +13 -1
- package/dist/store/vector-backend.d.ts +64 -4
- package/dist/store/vector-backend.js +15 -1
- package/package.json +58 -36
- package/dist/checkpointer/actions/delete-thread.d.ts.map +0 -1
- package/dist/checkpointer/actions/delete-thread.js.map +0 -1
- package/dist/checkpointer/actions/get-tuple.d.ts.map +0 -1
- package/dist/checkpointer/actions/get-tuple.js.map +0 -1
- package/dist/checkpointer/actions/list.d.ts.map +0 -1
- package/dist/checkpointer/actions/list.js.map +0 -1
- package/dist/checkpointer/actions/put-writes.d.ts.map +0 -1
- package/dist/checkpointer/actions/put-writes.js.map +0 -1
- package/dist/checkpointer/actions/put.d.ts.map +0 -1
- package/dist/checkpointer/actions/put.js.map +0 -1
- package/dist/checkpointer/internal/assemble.d.ts +0 -10
- package/dist/checkpointer/internal/assemble.d.ts.map +0 -1
- package/dist/checkpointer/internal/assemble.js +0 -37
- package/dist/checkpointer/internal/assemble.js.map +0 -1
- package/dist/checkpointer/internal/configurable.d.ts +0 -13
- package/dist/checkpointer/internal/configurable.d.ts.map +0 -1
- package/dist/checkpointer/internal/configurable.js +0 -23
- package/dist/checkpointer/internal/configurable.js.map +0 -1
- package/dist/checkpointer/internal/fetch.d.ts +0 -10
- package/dist/checkpointer/internal/fetch.d.ts.map +0 -1
- package/dist/checkpointer/internal/fetch.js +0 -46
- package/dist/checkpointer/internal/fetch.js.map +0 -1
- package/dist/checkpointer/internal/filter-match.d.ts +0 -12
- package/dist/checkpointer/internal/filter-match.d.ts.map +0 -1
- package/dist/checkpointer/internal/filter-match.js +0 -14
- package/dist/checkpointer/internal/filter-match.js.map +0 -1
- package/dist/checkpointer/internal/item-reader.d.ts +0 -55
- package/dist/checkpointer/internal/item-reader.d.ts.map +0 -1
- package/dist/checkpointer/internal/item-reader.js +0 -88
- package/dist/checkpointer/internal/item-reader.js.map +0 -1
- package/dist/checkpointer/internal/item-writer.d.ts +0 -26
- package/dist/checkpointer/internal/item-writer.d.ts.map +0 -1
- package/dist/checkpointer/internal/item-writer.js +0 -92
- package/dist/checkpointer/internal/item-writer.js.map +0 -1
- package/dist/checkpointer/internal/keys.d.ts +0 -31
- package/dist/checkpointer/internal/keys.d.ts.map +0 -1
- package/dist/checkpointer/internal/keys.js +0 -87
- package/dist/checkpointer/internal/keys.js.map +0 -1
- package/dist/checkpointer/internal/query.d.ts +0 -20
- package/dist/checkpointer/internal/query.d.ts.map +0 -1
- package/dist/checkpointer/internal/query.js +0 -36
- package/dist/checkpointer/internal/query.js.map +0 -1
- package/dist/checkpointer/internal/setup.d.ts.map +0 -1
- package/dist/checkpointer/internal/setup.js.map +0 -1
- package/dist/checkpointer/internal/special-write-cas.d.ts +0 -30
- package/dist/checkpointer/internal/special-write-cas.d.ts.map +0 -1
- package/dist/checkpointer/internal/special-write-cas.js +0 -104
- package/dist/checkpointer/internal/special-write-cas.js.map +0 -1
- package/dist/checkpointer/internal/special-write-cleanup.d.ts +0 -24
- package/dist/checkpointer/internal/special-write-cleanup.d.ts.map +0 -1
- package/dist/checkpointer/internal/special-write-cleanup.js +0 -47
- package/dist/checkpointer/internal/special-write-cleanup.js.map +0 -1
- package/dist/checkpointer/internal/special-write-verify.d.ts +0 -54
- package/dist/checkpointer/internal/special-write-verify.d.ts.map +0 -1
- package/dist/checkpointer/internal/special-write-verify.js +0 -65
- package/dist/checkpointer/internal/special-write-verify.js.map +0 -1
- package/dist/checkpointer/internal/validation.d.ts +0 -13
- package/dist/checkpointer/internal/validation.d.ts.map +0 -1
- package/dist/checkpointer/internal/validation.js +0 -30
- package/dist/checkpointer/internal/validation.js.map +0 -1
- package/dist/checkpointer/internal/write-guard.d.ts +0 -13
- package/dist/checkpointer/internal/write-guard.d.ts.map +0 -1
- package/dist/checkpointer/internal/write-guard.js +0 -39
- package/dist/checkpointer/internal/write-guard.js.map +0 -1
- package/dist/checkpointer/internal/write-index.d.ts +0 -37
- package/dist/checkpointer/internal/write-index.d.ts.map +0 -1
- package/dist/checkpointer/internal/write-index.js +0 -42
- package/dist/checkpointer/internal/write-index.js.map +0 -1
- package/dist/checkpointer/saver.d.ts.map +0 -1
- package/dist/checkpointer/saver.js.map +0 -1
- package/dist/checkpointer/types.d.ts.map +0 -1
- package/dist/checkpointer/types.js.map +0 -1
- package/dist/factory/factory.d.ts.map +0 -1
- package/dist/factory/factory.js.map +0 -1
- package/dist/history/actions/add-messages.d.ts.map +0 -1
- package/dist/history/actions/add-messages.js.map +0 -1
- package/dist/history/actions/clear.d.ts.map +0 -1
- package/dist/history/actions/clear.js.map +0 -1
- package/dist/history/actions/get-messages.d.ts.map +0 -1
- package/dist/history/actions/get-messages.js.map +0 -1
- package/dist/history/actions/list-sessions.d.ts.map +0 -1
- package/dist/history/actions/list-sessions.js.map +0 -1
- package/dist/history/actions/reconcile-count.d.ts.map +0 -1
- package/dist/history/actions/reconcile-count.js.map +0 -1
- package/dist/history/chat-message-history.d.ts.map +0 -1
- package/dist/history/chat-message-history.js.map +0 -1
- package/dist/history/internal/append-saga.d.ts +0 -20
- package/dist/history/internal/append-saga.d.ts.map +0 -1
- package/dist/history/internal/append-saga.js +0 -35
- package/dist/history/internal/append-saga.js.map +0 -1
- package/dist/history/internal/compensation.d.ts +0 -21
- package/dist/history/internal/compensation.d.ts.map +0 -1
- package/dist/history/internal/compensation.js +0 -84
- package/dist/history/internal/compensation.js.map +0 -1
- package/dist/history/internal/item-mapper.d.ts +0 -12
- package/dist/history/internal/item-mapper.d.ts.map +0 -1
- package/dist/history/internal/item-mapper.js +0 -33
- package/dist/history/internal/item-mapper.js.map +0 -1
- package/dist/history/internal/keys.d.ts +0 -17
- package/dist/history/internal/keys.d.ts.map +0 -1
- package/dist/history/internal/keys.js +0 -49
- package/dist/history/internal/keys.js.map +0 -1
- package/dist/history/internal/message-chunker.d.ts +0 -14
- package/dist/history/internal/message-chunker.d.ts.map +0 -1
- package/dist/history/internal/message-chunker.js +0 -68
- package/dist/history/internal/message-chunker.js.map +0 -1
- package/dist/history/internal/message-transaction.d.ts +0 -26
- package/dist/history/internal/message-transaction.d.ts.map +0 -1
- package/dist/history/internal/message-transaction.js +0 -60
- package/dist/history/internal/message-transaction.js.map +0 -1
- package/dist/history/internal/query.d.ts +0 -10
- package/dist/history/internal/query.d.ts.map +0 -1
- package/dist/history/internal/query.js +0 -31
- package/dist/history/internal/query.js.map +0 -1
- package/dist/history/internal/session-count.d.ts +0 -41
- package/dist/history/internal/session-count.d.ts.map +0 -1
- package/dist/history/internal/session-count.js +0 -109
- package/dist/history/internal/session-count.js.map +0 -1
- package/dist/history/internal/session-title.d.ts +0 -20
- package/dist/history/internal/session-title.d.ts.map +0 -1
- package/dist/history/internal/session-title.js +0 -44
- package/dist/history/internal/session-title.js.map +0 -1
- package/dist/history/internal/session-update.d.ts +0 -28
- package/dist/history/internal/session-update.d.ts.map +0 -1
- package/dist/history/internal/session-update.js +0 -70
- package/dist/history/internal/session-update.js.map +0 -1
- package/dist/history/internal/setup.d.ts.map +0 -1
- package/dist/history/internal/setup.js.map +0 -1
- package/dist/history/internal/title-generator.d.ts +0 -13
- package/dist/history/internal/title-generator.d.ts.map +0 -1
- package/dist/history/internal/title-generator.js +0 -25
- package/dist/history/internal/title-generator.js.map +0 -1
- package/dist/history/internal/ttl-anchor.d.ts +0 -25
- package/dist/history/internal/ttl-anchor.d.ts.map +0 -1
- package/dist/history/internal/ttl-anchor.js +0 -38
- package/dist/history/internal/ttl-anchor.js.map +0 -1
- package/dist/history/internal/validation.d.ts +0 -9
- package/dist/history/internal/validation.d.ts.map +0 -1
- package/dist/history/internal/validation.js +0 -16
- package/dist/history/internal/validation.js.map +0 -1
- package/dist/history/session-adapter.d.ts.map +0 -1
- package/dist/history/session-adapter.js.map +0 -1
- package/dist/history/types.d.ts.map +0 -1
- package/dist/history/types.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/shared/clock.d.ts.map +0 -1
- package/dist/shared/clock.js.map +0 -1
- package/dist/shared/codec/codec.d.ts.map +0 -1
- package/dist/shared/codec/codec.js.map +0 -1
- package/dist/shared/codec/compression.d.ts.map +0 -1
- package/dist/shared/codec/compression.js.map +0 -1
- package/dist/shared/codec/descriptor-keys.d.ts +0 -4
- package/dist/shared/codec/descriptor-keys.d.ts.map +0 -1
- package/dist/shared/codec/descriptor-keys.js +0 -14
- package/dist/shared/codec/descriptor-keys.js.map +0 -1
- package/dist/shared/codec/json-serde.d.ts.map +0 -1
- package/dist/shared/codec/json-serde.js.map +0 -1
- package/dist/shared/codec/s3/client.d.ts.map +0 -1
- package/dist/shared/codec/s3/client.js.map +0 -1
- package/dist/shared/codec/s3/config.d.ts.map +0 -1
- package/dist/shared/codec/s3/config.js.map +0 -1
- package/dist/shared/codec/s3/delete.d.ts +0 -8
- package/dist/shared/codec/s3/delete.d.ts.map +0 -1
- package/dist/shared/codec/s3/delete.js +0 -29
- package/dist/shared/codec/s3/delete.js.map +0 -1
- package/dist/shared/codec/s3/lifecycle.d.ts.map +0 -1
- package/dist/shared/codec/s3/lifecycle.js.map +0 -1
- package/dist/shared/codec/s3/offloader.d.ts.map +0 -1
- package/dist/shared/codec/s3/offloader.js.map +0 -1
- package/dist/shared/codec/s3/orphans.d.ts +0 -18
- package/dist/shared/codec/s3/orphans.d.ts.map +0 -1
- package/dist/shared/codec/s3/orphans.js +0 -58
- package/dist/shared/codec/s3/orphans.js.map +0 -1
- package/dist/shared/codec/s3/read-write.d.ts +0 -14
- package/dist/shared/codec/s3/read-write.d.ts.map +0 -1
- package/dist/shared/codec/s3/read-write.js +0 -43
- package/dist/shared/codec/s3/read-write.js.map +0 -1
- package/dist/shared/codec/s3/retry.d.ts +0 -5
- package/dist/shared/codec/s3/retry.d.ts.map +0 -1
- package/dist/shared/codec/s3/retry.js +0 -25
- package/dist/shared/codec/s3/retry.js.map +0 -1
- package/dist/shared/constants.d.ts +0 -64
- package/dist/shared/constants.d.ts.map +0 -1
- package/dist/shared/constants.js +0 -67
- package/dist/shared/constants.js.map +0 -1
- package/dist/shared/dynamodb/backoff.d.ts +0 -15
- package/dist/shared/dynamodb/backoff.d.ts.map +0 -1
- package/dist/shared/dynamodb/backoff.js +0 -48
- package/dist/shared/dynamodb/backoff.js.map +0 -1
- package/dist/shared/dynamodb/batch-write.d.ts.map +0 -1
- package/dist/shared/dynamodb/batch-write.js.map +0 -1
- package/dist/shared/dynamodb/cancellation.d.ts.map +0 -1
- package/dist/shared/dynamodb/cancellation.js.map +0 -1
- package/dist/shared/dynamodb/client.d.ts.map +0 -1
- package/dist/shared/dynamodb/client.js.map +0 -1
- package/dist/shared/dynamodb/conditional-put.d.ts +0 -51
- package/dist/shared/dynamodb/conditional-put.d.ts.map +0 -1
- package/dist/shared/dynamodb/conditional-put.js +0 -59
- package/dist/shared/dynamodb/conditional-put.js.map +0 -1
- package/dist/shared/dynamodb/drain-unprocessed.d.ts +0 -19
- package/dist/shared/dynamodb/drain-unprocessed.d.ts.map +0 -1
- package/dist/shared/dynamodb/drain-unprocessed.js +0 -44
- package/dist/shared/dynamodb/drain-unprocessed.js.map +0 -1
- package/dist/shared/dynamodb/paginate-core.d.ts +0 -22
- package/dist/shared/dynamodb/paginate-core.d.ts.map +0 -1
- package/dist/shared/dynamodb/paginate-core.js +0 -52
- package/dist/shared/dynamodb/paginate-core.js.map +0 -1
- package/dist/shared/dynamodb/paginate.d.ts.map +0 -1
- package/dist/shared/dynamodb/paginate.js.map +0 -1
- package/dist/shared/dynamodb/partition-delete.d.ts.map +0 -1
- package/dist/shared/dynamodb/partition-delete.js.map +0 -1
- package/dist/shared/dynamodb/retry-classifier.d.ts +0 -9
- package/dist/shared/dynamodb/retry-classifier.d.ts.map +0 -1
- package/dist/shared/dynamodb/retry-classifier.js +0 -87
- package/dist/shared/dynamodb/retry-classifier.js.map +0 -1
- package/dist/shared/dynamodb/retry.d.ts.map +0 -1
- package/dist/shared/dynamodb/retry.js.map +0 -1
- package/dist/shared/dynamodb/scan.d.ts +0 -15
- package/dist/shared/dynamodb/scan.d.ts.map +0 -1
- package/dist/shared/dynamodb/scan.js +0 -20
- package/dist/shared/dynamodb/scan.js.map +0 -1
- package/dist/shared/dynamodb/types.d.ts +0 -24
- package/dist/shared/dynamodb/types.d.ts.map +0 -1
- package/dist/shared/dynamodb/types.js +0 -3
- package/dist/shared/dynamodb/types.js.map +0 -1
- package/dist/shared/errors/base-error.d.ts.map +0 -1
- package/dist/shared/errors/base-error.js.map +0 -1
- package/dist/shared/errors/error-code.d.ts.map +0 -1
- package/dist/shared/errors/error-code.js.map +0 -1
- package/dist/shared/errors/errors.d.ts.map +0 -1
- package/dist/shared/errors/errors.js.map +0 -1
- package/dist/shared/errors/wrap-error.d.ts +0 -16
- package/dist/shared/errors/wrap-error.d.ts.map +0 -1
- package/dist/shared/errors/wrap-error.js +0 -30
- package/dist/shared/errors/wrap-error.js.map +0 -1
- package/dist/shared/logging/logger.d.ts.map +0 -1
- package/dist/shared/logging/logger.js.map +0 -1
- package/dist/shared/logging/redaction-walk.d.ts +0 -23
- package/dist/shared/logging/redaction-walk.d.ts.map +0 -1
- package/dist/shared/logging/redaction-walk.js +0 -92
- package/dist/shared/logging/redaction-walk.js.map +0 -1
- package/dist/shared/logging/redaction.d.ts.map +0 -1
- package/dist/shared/logging/redaction.js.map +0 -1
- package/dist/shared/logging/secret-patterns.d.ts.map +0 -1
- package/dist/shared/logging/secret-patterns.js.map +0 -1
- package/dist/shared/options.d.ts.map +0 -1
- package/dist/shared/options.js.map +0 -1
- package/dist/shared/ulid.d.ts.map +0 -1
- package/dist/shared/ulid.js.map +0 -1
- package/dist/shared/validation/primitives.d.ts.map +0 -1
- package/dist/shared/validation/primitives.js.map +0 -1
- package/dist/shared/validation/ttl.d.ts.map +0 -1
- package/dist/shared/validation/ttl.js.map +0 -1
- package/dist/store/actions/get.d.ts +0 -5
- package/dist/store/actions/get.d.ts.map +0 -1
- package/dist/store/actions/get.js +0 -35
- package/dist/store/actions/get.js.map +0 -1
- package/dist/store/actions/list-namespaces.d.ts.map +0 -1
- package/dist/store/actions/list-namespaces.js.map +0 -1
- package/dist/store/actions/put.d.ts.map +0 -1
- package/dist/store/actions/put.js.map +0 -1
- package/dist/store/actions/reconcile-vector-index.d.ts.map +0 -1
- package/dist/store/actions/reconcile-vector-index.js.map +0 -1
- package/dist/store/actions/search.d.ts.map +0 -1
- package/dist/store/actions/search.js.map +0 -1
- package/dist/store/internal/backend-search.d.ts +0 -5
- package/dist/store/internal/backend-search.d.ts.map +0 -1
- package/dist/store/internal/backend-search.js +0 -68
- package/dist/store/internal/backend-search.js.map +0 -1
- package/dist/store/internal/filter.d.ts.map +0 -1
- package/dist/store/internal/filter.js.map +0 -1
- package/dist/store/internal/index-reconcile.d.ts +0 -22
- package/dist/store/internal/index-reconcile.d.ts.map +0 -1
- package/dist/store/internal/index-reconcile.js +0 -105
- package/dist/store/internal/index-reconcile.js.map +0 -1
- package/dist/store/internal/index-sync.d.ts +0 -11
- package/dist/store/internal/index-sync.d.ts.map +0 -1
- package/dist/store/internal/index-sync.js +0 -26
- package/dist/store/internal/index-sync.js.map +0 -1
- package/dist/store/internal/item-mapper.d.ts +0 -25
- package/dist/store/internal/item-mapper.d.ts.map +0 -1
- package/dist/store/internal/item-mapper.js +0 -53
- package/dist/store/internal/item-mapper.js.map +0 -1
- package/dist/store/internal/keys.d.ts +0 -18
- package/dist/store/internal/keys.d.ts.map +0 -1
- package/dist/store/internal/keys.js +0 -42
- package/dist/store/internal/keys.js.map +0 -1
- package/dist/store/internal/namespace-match.d.ts +0 -12
- package/dist/store/internal/namespace-match.d.ts.map +0 -1
- package/dist/store/internal/namespace-match.js +0 -41
- package/dist/store/internal/namespace-match.js.map +0 -1
- package/dist/store/internal/overwrite-swap.d.ts +0 -33
- package/dist/store/internal/overwrite-swap.d.ts.map +0 -1
- package/dist/store/internal/overwrite-swap.js +0 -62
- package/dist/store/internal/overwrite-swap.js.map +0 -1
- package/dist/store/internal/persist.d.ts +0 -27
- package/dist/store/internal/persist.d.ts.map +0 -1
- package/dist/store/internal/persist.js +0 -59
- package/dist/store/internal/persist.js.map +0 -1
- package/dist/store/internal/query.d.ts +0 -6
- package/dist/store/internal/query.d.ts.map +0 -1
- package/dist/store/internal/query.js +0 -32
- package/dist/store/internal/query.js.map +0 -1
- package/dist/store/internal/ranker.d.ts +0 -13
- package/dist/store/internal/ranker.d.ts.map +0 -1
- package/dist/store/internal/ranker.js +0 -31
- package/dist/store/internal/ranker.js.map +0 -1
- package/dist/store/internal/read-existing.d.ts +0 -19
- package/dist/store/internal/read-existing.d.ts.map +0 -1
- package/dist/store/internal/read-existing.js +0 -29
- package/dist/store/internal/read-existing.js.map +0 -1
- package/dist/store/internal/score-direction.d.ts +0 -32
- package/dist/store/internal/score-direction.d.ts.map +0 -1
- package/dist/store/internal/score-direction.js +0 -39
- package/dist/store/internal/score-direction.js.map +0 -1
- package/dist/store/internal/search-filter.d.ts +0 -4
- package/dist/store/internal/search-filter.d.ts.map +0 -1
- package/dist/store/internal/search-filter.js +0 -11
- package/dist/store/internal/search-filter.js.map +0 -1
- package/dist/store/internal/semantic-search.d.ts.map +0 -1
- package/dist/store/internal/semantic-search.js.map +0 -1
- package/dist/store/internal/setup.d.ts.map +0 -1
- package/dist/store/internal/setup.js.map +0 -1
- package/dist/store/internal/validation.d.ts +0 -13
- package/dist/store/internal/validation.d.ts.map +0 -1
- package/dist/store/internal/validation.js +0 -35
- package/dist/store/internal/validation.js.map +0 -1
- package/dist/store/internal/write-verify.d.ts +0 -37
- package/dist/store/internal/write-verify.d.ts.map +0 -1
- package/dist/store/internal/write-verify.js +0 -68
- package/dist/store/internal/write-verify.js.map +0 -1
- package/dist/store/store.d.ts.map +0 -1
- package/dist/store/store.js.map +0 -1
- package/dist/store/types.d.ts.map +0 -1
- package/dist/store/types.js.map +0 -1
- package/dist/store/vector-backend.d.ts.map +0 -1
- package/dist/store/vector-backend.js.map +0 -1
|
@@ -1,31 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hides which rows a clear may delete.
|
|
4
|
+
*
|
|
5
|
+
* A clear removes only what the partition read observed and this adapter
|
|
6
|
+
* wrote, each row pinned to the write id it was read with, and reaches a
|
|
7
|
+
* message's offloaded payload through the attribute that holds it. A caller
|
|
8
|
+
* asks for a session to go and never decides that a foreign row, or one a
|
|
9
|
+
* concurrent append rewrote, is left in place and reported rather than
|
|
10
|
+
* deleted; the paging, the per-row deletes and the S3 cleanup are the shared
|
|
11
|
+
* partition delete's.
|
|
12
|
+
*/
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
14
|
exports.clearSession = clearSession;
|
|
15
|
+
const idempotent_write_1 = require("../../shared/dynamodb/idempotent-write");
|
|
4
16
|
const partition_delete_1 = require("../../shared/dynamodb/partition-delete");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
/**
|
|
17
|
+
const retry_1 = require("../../shared/dynamodb/retry");
|
|
18
|
+
const parse_1 = require("../internal/parse");
|
|
19
|
+
const rows_1 = require("../internal/rows");
|
|
20
|
+
/**
|
|
21
|
+
* The offloaded payload a chat-history row references, named by the attribute
|
|
22
|
+
* holding it, because a message row is pinned through a document path over that
|
|
23
|
+
* name. The session row carries no payload and is pinned top-level instead, and
|
|
24
|
+
* a row holding `null` there carries none either — `namedDescriptor` decides.
|
|
25
|
+
*/
|
|
9
26
|
function descriptorsOf(row) {
|
|
10
|
-
|
|
27
|
+
const entry = (0, partition_delete_1.namedDescriptor)(row, 'message');
|
|
28
|
+
return entry === undefined ? [] : [entry];
|
|
11
29
|
}
|
|
12
30
|
/**
|
|
13
|
-
* Delete
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
31
|
+
* Delete exactly the message rows and the session row of one session that the
|
|
32
|
+
* partition read observed.
|
|
33
|
+
*
|
|
34
|
+
* Accepts: `sessionId` — validated. `options.signal` — aborts between pages.
|
|
35
|
+
*
|
|
36
|
+
* Returns: nothing. Clearing a session that does not exist is not an error;
|
|
37
|
+
* there is simply nothing in the partition.
|
|
38
|
+
*
|
|
39
|
+
* Throws: `VALIDATION` naming `sessionId`; `BATCH_WRITE_INCOMPLETE`
|
|
40
|
+
* when a row's delete fails, carrying what did succeed; `ABORTED` when the
|
|
41
|
+
* signal fires, whether between pages or during a row's delete — a cancel is
|
|
42
|
+
* reported as a cancel and never as an incomplete delete, and no further row
|
|
43
|
+
* is issued after it. A refused
|
|
44
|
+
* row raises nothing and is not one of those failures: the pin turned it away
|
|
45
|
+
* because an append landed after the read, and deleting the session row then
|
|
46
|
+
* would remove the `messageCount`, the `updatedAt` and the recency-index entry
|
|
47
|
+
* of a session that is still alive — leaving it is the safe answer. The error's
|
|
48
|
+
* two counts are **rows**, not batches — rows deleted and rows attempted,
|
|
49
|
+
* summed across every flush of the pass, with `details.succeededCount` repeating
|
|
50
|
+
* the first and `details.failedChunks` holding each failing row's own error — and its
|
|
51
|
+
* message says so, because a pass that sends one request per row is not a batch
|
|
52
|
+
* that did not drain. Refused rows are in neither count; each is reported at
|
|
53
|
+
* `warn` with its sort key and counted as skipped. The remedy is to re-run once
|
|
54
|
+
* the session is quiescent, and `reconcileMessageCount` repairs the count the
|
|
55
|
+
* surviving session row is left over-counting in the meantime.
|
|
56
|
+
*
|
|
57
|
+
* Guarantees: a row this adapter did not write is left in place and logged, so
|
|
58
|
+
* a shared-table partition is never collaterally wiped. Offloaded objects are
|
|
59
|
+
* deleted best-effort after their rows, and only objects under this session's
|
|
60
|
+
* own path. A row rewritten after the read is left in place and reported: an
|
|
61
|
+
* append landing during the call moves the session row's own write id, so that
|
|
62
|
+
* row survives while the messages the read saw are still deleted, and its
|
|
63
|
+
* `messageCount` then over-counts until `reconcileMessageCount` repairs it —
|
|
64
|
+
* which is the right outcome, the session being alive. One pass over a
|
|
65
|
+
* quiescent session: a message appended while this runs may survive it.
|
|
17
66
|
*/
|
|
18
|
-
async function clearSession(context, sessionId) {
|
|
19
|
-
(0,
|
|
67
|
+
async function clearSession(context, sessionId, options = {}) {
|
|
68
|
+
const session = (0, parse_1.parseSessionId)(sessionId);
|
|
20
69
|
await (0, partition_delete_1.deletePartitionRows)({
|
|
21
70
|
client: context.client,
|
|
22
71
|
tableName: context.tableName,
|
|
23
|
-
params: (0,
|
|
72
|
+
params: (0, rows_1.sessionRowsQuery)(context.tableName, session, { consistent: true }),
|
|
24
73
|
logger: context.logger,
|
|
74
|
+
retry: (0, retry_1.retryFor)(context, options.signal),
|
|
75
|
+
signal: options.signal,
|
|
25
76
|
offloader: context.offloader,
|
|
26
77
|
operation: 'history.clear',
|
|
27
|
-
ownsSortKey:
|
|
78
|
+
ownsSortKey: rows_1.isHistorySortKey,
|
|
28
79
|
descriptorsOf,
|
|
80
|
+
idAttribute: idempotent_write_1.WRITE_ID_ATTRIBUTE,
|
|
81
|
+
scope: [session],
|
|
29
82
|
});
|
|
30
83
|
}
|
|
31
|
-
//# sourceMappingURL=clear.js.map
|
|
@@ -1,10 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides which decode failures cost one message and which fail the read.
|
|
3
|
+
*
|
|
4
|
+
* A stored message is fetched, deserialized and rebuilt in three stages, and
|
|
5
|
+
* the stage a failure comes from decides its fate: only a loss no reader could
|
|
6
|
+
* ever recover is confined to that message and handed to `onCorruptMessage`
|
|
7
|
+
* (record 12); a transport fault, an out-of-scope key, a newer payload or a
|
|
8
|
+
* serializer's refusal fails the read under either policy. A caller gets a
|
|
9
|
+
* conversation that is whole or, under `'skip'`, missing a lost turn
|
|
10
|
+
* reported at `error` — never one silently truncated without a trace —
|
|
11
|
+
* however many downloads run at once.
|
|
12
|
+
*/
|
|
1
13
|
import { type BaseMessage } from '@langchain/core/messages';
|
|
14
|
+
import type { CancelOptions } from '../../shared/options';
|
|
2
15
|
import type { HistoryContext } from '../internal/setup';
|
|
16
|
+
import type { MessageWindow } from '../types';
|
|
3
17
|
/**
|
|
4
|
-
* Return a session's messages in chronological order
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
18
|
+
* Return a session's messages in chronological order — the whole session, or
|
|
19
|
+
* the window `options` selects: `limit` keeps only the newest `limit`
|
|
20
|
+
* messages, `before` only those appended before that instant (see
|
|
21
|
+
* {@link readWindow}). Items past their TTL are filtered out on read
|
|
22
|
+
* (DynamoDB's background TTL sweep can lag by up to 48h), so the returned
|
|
23
|
+
* history is never stale. A corrupt item — see
|
|
24
|
+
* {@link decodeMessage} for exactly what counts — is handled per
|
|
25
|
+
* `onCorruptMessage`: `'throw'` fails the read with the underlying error;
|
|
26
|
+
* `'skip'` (the default) reports it at `error` with its sort key and returns
|
|
27
|
+
* the rest. Every other failure propagates regardless of the policy.
|
|
28
|
+
*
|
|
29
|
+
* Accepts: `options.limit` — the newest N, at least 1; absent asks for the
|
|
30
|
+
* whole session, and `0` is refused rather than read as an empty conversation
|
|
31
|
+
* (see {@link parseMessageWindow}).
|
|
32
|
+
* `options.before` — only messages appended before that instant.
|
|
33
|
+
* `options.signal` — aborts the reads.
|
|
34
|
+
*
|
|
35
|
+
* Returns: the messages in chronological order, oldest first. A session that
|
|
36
|
+
* does not exist and one whose messages have all expired both return nothing:
|
|
37
|
+
* a conversation nobody can read is a conversation that is not there.
|
|
38
|
+
*
|
|
39
|
+
* Throws: `VALIDATION` naming `sessionId`, `limit`, `before`, `signal`, or
|
|
40
|
+
* `options.<key>` for a key this package does not read;
|
|
41
|
+
* `FORMAT_UNSUPPORTED` for a row, or a payload, a newer version wrote — the
|
|
42
|
+
* payload half whatever the policy, because a newer reader reads it and
|
|
43
|
+
* dropping it would lose a turn a rollback could still serve; the decode error
|
|
44
|
+
* of a corrupt row under `onCorruptMessage: 'throw'`; `VALIDATION` naming
|
|
45
|
+
* `message` for a row in this session's message key space that this adapter
|
|
46
|
+
* did not write, naming
|
|
47
|
+
* `s3Key` for a row addressing an object outside the session's own path, and
|
|
48
|
+
* naming `serde` for a row whose payload the serializer refuses to
|
|
49
|
+
* reconstruct, all three whatever the policy; any infrastructure failure — a
|
|
50
|
+
* throttle, a permission, a transport error — whatever the policy, because
|
|
51
|
+
* dropping a message for one of those would hand back a silently truncated
|
|
52
|
+
* conversation that the chain then re-persists as the truth.
|
|
53
|
+
*
|
|
54
|
+
* Guarantees: strongly consistent, so the turn just appended is visible.
|
|
55
|
+
* Offloaded messages download several at a time, and the corruption policy is
|
|
56
|
+
* applied in message order however they finish.
|
|
8
57
|
*/
|
|
9
|
-
export declare function getMessages(context: HistoryContext, sessionId: string): Promise<BaseMessage[]>;
|
|
10
|
-
//# sourceMappingURL=get-messages.d.ts.map
|
|
58
|
+
export declare function getMessages(context: HistoryContext, sessionId: string, options?: MessageWindow & CancelOptions): Promise<BaseMessage[]>;
|
|
@@ -1,58 +1,141 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hides which decode failures cost one message and which fail the read.
|
|
4
|
+
*
|
|
5
|
+
* A stored message is fetched, deserialized and rebuilt in three stages, and
|
|
6
|
+
* the stage a failure comes from decides its fate: only a loss no reader could
|
|
7
|
+
* ever recover is confined to that message and handed to `onCorruptMessage`
|
|
8
|
+
* (record 12); a transport fault, an out-of-scope key, a newer payload or a
|
|
9
|
+
* serializer's refusal fails the read under either policy. A caller gets a
|
|
10
|
+
* conversation that is whole or, under `'skip'`, missing a lost turn
|
|
11
|
+
* reported at `error` — never one silently truncated without a trace —
|
|
12
|
+
* however many downloads run at once.
|
|
13
|
+
*/
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
15
|
exports.getMessages = getMessages;
|
|
4
16
|
const messages_1 = require("@langchain/core/messages");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
17
|
+
const codec_1 = require("../../shared/codec/codec");
|
|
18
|
+
const concurrency_1 = require("../../shared/concurrency");
|
|
19
|
+
const base_error_1 = require("../../shared/errors/base-error");
|
|
20
|
+
const truncate_1 = require("../../shared/logging/truncate");
|
|
21
|
+
const message_read_1 = require("../internal/message-read");
|
|
22
|
+
const parse_1 = require("../internal/parse");
|
|
23
|
+
/**
|
|
24
|
+
* This message's own loss, or the whole read's failure. Only what no reader
|
|
25
|
+
* could ever recover is confined to one message; everything else would hand
|
|
26
|
+
* the caller a silently truncated conversation that
|
|
27
|
+
* `RunnableWithMessageHistory` then re-persists as the truth.
|
|
28
|
+
*/
|
|
29
|
+
function corruptOrRethrow(error) {
|
|
30
|
+
if ((0, codec_1.isPermanentPayloadLoss)(error))
|
|
31
|
+
return { kind: 'corrupt', error };
|
|
32
|
+
throw error;
|
|
11
33
|
}
|
|
12
34
|
/**
|
|
13
|
-
* Decode one item
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
35
|
+
* Decode one item in three stages so failures are classified by what caused
|
|
36
|
+
* them. Fetching the bytes (an S3 download, decompression) is infrastructure:
|
|
37
|
+
* a transport, throttling or permission failure there is rethrown. Only a
|
|
38
|
+
* *permanent* loss at that stage — the object is gone, or the decompression
|
|
39
|
+
* guard tripped — is corruption; a row whose `s3Key` lies outside the session's
|
|
40
|
+
* own path is a configuration or tenancy fault, and a payload whose
|
|
41
|
+
* `schemaVersion` is newer than this release reads is a turn a newer reader
|
|
42
|
+
* still serves, so both are rethrown like any other infrastructure failure (see
|
|
43
|
+
* `assertKeyInScope` and `assertReadableDescriptor`).
|
|
44
|
+
*
|
|
45
|
+
* Deserializing is classified the same way, through the same predicate: bytes
|
|
46
|
+
* that are no longer the form the row declares are this message's own loss, but
|
|
47
|
+
* a serde that refuses to reconstruct what intact bytes *name* — the branded
|
|
48
|
+
* refusal {@link loadPayloadValue} raises for a stored `lc` record naming a
|
|
49
|
+
* class outside its allow-list — is a misconfigured serde or a planted row, and
|
|
50
|
+
* is reported for the same reason the out-of-scope key is. Bytes reached this
|
|
51
|
+
* stage bare before it existed, so a refusal of that kind was skipped here
|
|
52
|
+
* while the store and the saver raised on the identical row.
|
|
53
|
+
*
|
|
54
|
+
* Rebuilding the message from what the serde returned is pure data handling, so
|
|
55
|
+
* any failure there — a type LangChain cannot rebuild, such as a
|
|
56
|
+
* `RemoveMessage` — is corruption confined to that one message.
|
|
18
57
|
*/
|
|
19
|
-
async function
|
|
58
|
+
async function decodeMessage(context, item, sessionId, signal) {
|
|
59
|
+
const deps = (0, codec_1.codecDepsOf)(context, signal);
|
|
60
|
+
let bytes;
|
|
20
61
|
try {
|
|
21
|
-
|
|
62
|
+
bytes = await (0, codec_1.readPayloadBytes)(item.message, deps, [sessionId]);
|
|
22
63
|
}
|
|
23
64
|
catch (error) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
65
|
+
return corruptOrRethrow(error);
|
|
66
|
+
}
|
|
67
|
+
let stored;
|
|
68
|
+
try {
|
|
69
|
+
stored = await (0, codec_1.loadPayloadValue)(item.message.serdeType, bytes, deps);
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
return corruptOrRethrow(error);
|
|
73
|
+
}
|
|
74
|
+
try {
|
|
75
|
+
return { kind: 'ok', message: (0, messages_1.mapStoredMessagesToChatMessages)([stored])[0] };
|
|
76
|
+
}
|
|
77
|
+
catch (error) {
|
|
78
|
+
return { kind: 'corrupt', error: (0, base_error_1.toError)(error) };
|
|
31
79
|
}
|
|
32
80
|
}
|
|
33
81
|
/**
|
|
34
|
-
* Return a session's messages in chronological order
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
82
|
+
* Return a session's messages in chronological order — the whole session, or
|
|
83
|
+
* the window `options` selects: `limit` keeps only the newest `limit`
|
|
84
|
+
* messages, `before` only those appended before that instant (see
|
|
85
|
+
* {@link readWindow}). Items past their TTL are filtered out on read
|
|
86
|
+
* (DynamoDB's background TTL sweep can lag by up to 48h), so the returned
|
|
87
|
+
* history is never stale. A corrupt item — see
|
|
88
|
+
* {@link decodeMessage} for exactly what counts — is handled per
|
|
89
|
+
* `onCorruptMessage`: `'throw'` fails the read with the underlying error;
|
|
90
|
+
* `'skip'` (the default) reports it at `error` with its sort key and returns
|
|
91
|
+
* the rest. Every other failure propagates regardless of the policy.
|
|
92
|
+
*
|
|
93
|
+
* Accepts: `options.limit` — the newest N, at least 1; absent asks for the
|
|
94
|
+
* whole session, and `0` is refused rather than read as an empty conversation
|
|
95
|
+
* (see {@link parseMessageWindow}).
|
|
96
|
+
* `options.before` — only messages appended before that instant.
|
|
97
|
+
* `options.signal` — aborts the reads.
|
|
98
|
+
*
|
|
99
|
+
* Returns: the messages in chronological order, oldest first. A session that
|
|
100
|
+
* does not exist and one whose messages have all expired both return nothing:
|
|
101
|
+
* a conversation nobody can read is a conversation that is not there.
|
|
102
|
+
*
|
|
103
|
+
* Throws: `VALIDATION` naming `sessionId`, `limit`, `before`, `signal`, or
|
|
104
|
+
* `options.<key>` for a key this package does not read;
|
|
105
|
+
* `FORMAT_UNSUPPORTED` for a row, or a payload, a newer version wrote — the
|
|
106
|
+
* payload half whatever the policy, because a newer reader reads it and
|
|
107
|
+
* dropping it would lose a turn a rollback could still serve; the decode error
|
|
108
|
+
* of a corrupt row under `onCorruptMessage: 'throw'`; `VALIDATION` naming
|
|
109
|
+
* `message` for a row in this session's message key space that this adapter
|
|
110
|
+
* did not write, naming
|
|
111
|
+
* `s3Key` for a row addressing an object outside the session's own path, and
|
|
112
|
+
* naming `serde` for a row whose payload the serializer refuses to
|
|
113
|
+
* reconstruct, all three whatever the policy; any infrastructure failure — a
|
|
114
|
+
* throttle, a permission, a transport error — whatever the policy, because
|
|
115
|
+
* dropping a message for one of those would hand back a silently truncated
|
|
116
|
+
* conversation that the chain then re-persists as the truth.
|
|
117
|
+
*
|
|
118
|
+
* Guarantees: strongly consistent, so the turn just appended is visible.
|
|
119
|
+
* Offloaded messages download several at a time, and the corruption policy is
|
|
120
|
+
* applied in message order however they finish.
|
|
38
121
|
*/
|
|
39
|
-
async function getMessages(context, sessionId) {
|
|
40
|
-
(0,
|
|
41
|
-
const
|
|
42
|
-
const
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
122
|
+
async function getMessages(context, sessionId, options = {}) {
|
|
123
|
+
const request = (0, parse_1.parseGetMessagesRequest)(sessionId, options);
|
|
124
|
+
const items = await (0, message_read_1.readWindow)(context, request.sessionId, request.window, request.signal);
|
|
125
|
+
const decoded = await (0, concurrency_1.mapWithConcurrency)(items, context.readConcurrency ?? concurrency_1.DEFAULT_READ_CONCURRENCY, (item) => decodeMessage(context, item, request.sessionId, request.signal));
|
|
126
|
+
const messages = [];
|
|
127
|
+
decoded.forEach((result, index) => {
|
|
128
|
+
if (result.kind === 'ok') {
|
|
129
|
+
messages.push(result.message);
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
if (context.onCorruptMessage === 'throw')
|
|
133
|
+
throw result.error;
|
|
134
|
+
context.logger.error('getMessages: skipped a corrupt message item', {
|
|
135
|
+
sessionId: request.sessionId,
|
|
136
|
+
sortKey: (0, truncate_1.truncateForLog)(items[index].SK),
|
|
137
|
+
reason: (0, truncate_1.truncateForLog)((0, base_error_1.failureLabel)(result.error)),
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
return messages;
|
|
57
141
|
}
|
|
58
|
-
//# sourceMappingURL=get-messages.js.map
|
|
@@ -1,13 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides whether a listing reads the recency index or scans the table.
|
|
3
|
+
*
|
|
4
|
+
* With a configured `indexName` a listing is a cursor-paged, newest-first
|
|
5
|
+
* merge of the index shards; without one it is a filtered scan sorted in
|
|
6
|
+
* memory, with no cursor (record 8). A caller passes the same options and gets
|
|
7
|
+
* the same `SessionPage` either way: `limit` is the newest N on both paths,
|
|
8
|
+
* `0` reads neither, and the same rule summarises each session and drops the
|
|
9
|
+
* expired, foreign and malformed ones.
|
|
10
|
+
*/
|
|
1
11
|
import type { HistoryContext } from '../internal/setup';
|
|
2
|
-
import type {
|
|
12
|
+
import type { ListSessionsOptions, SessionPage } from '../types';
|
|
3
13
|
/**
|
|
4
|
-
* List
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
14
|
+
* List sessions as metadata summaries, most recently updated first.
|
|
15
|
+
*
|
|
16
|
+
* Accepts: `options.limit` — the package-wide page rule, an integer from 0 to
|
|
17
|
+
* the page ceiling; absent means one index page (100) with the index, and
|
|
18
|
+
* every session without it, since a scan has no cursor to fetch the rest with.
|
|
19
|
+
* `0` returns an empty page on either path without reading the table, which
|
|
20
|
+
* matters most on the scan path: a scan has to finish before the newest can be
|
|
21
|
+
* known, so answering `limit: 0` by scanning and then slicing to nothing would
|
|
22
|
+
* have paid for the whole table to return an empty page.
|
|
23
|
+
* `options.cursor` — from a previous page, and
|
|
24
|
+
* only with a configured `indexName`. `options.maxItems` and
|
|
25
|
+
* `maxIterations` — caps on the scan path; with the index the page size is the
|
|
26
|
+
* bound and they do nothing. Each must be a positive integer or `Infinity`
|
|
27
|
+
* (the paginator's own way to ask for no cap); absent keeps its default.
|
|
28
|
+
*
|
|
29
|
+
* Returns: the page, newest-updated first, and a `nextCursor` while rows may
|
|
30
|
+
* remain. A page can come back shorter than `limit` while more remain: expired
|
|
31
|
+
* and foreign rows are dropped after the read, and so is a row of this
|
|
32
|
+
* package's own whose `messageCount`, `createdAt`, `updatedAt`, `title` or
|
|
33
|
+
* `ttl` is not the type written there — otherwise one unreadable `ttl` would fail the
|
|
34
|
+
* whole call, taking every healthy session with it. The cursor is a position in
|
|
35
|
+
* the index rather than a count of what survived filtering. A cursor does not
|
|
36
|
+
* promise more rows: the page after it can come back empty (see
|
|
37
|
+
* `queryRecencyIndex`).
|
|
38
|
+
*
|
|
39
|
+
* Throws: `VALIDATION` naming `limit`, `cursor`, `maxItems`,
|
|
40
|
+
* `maxIterations`, `signal`, or `options.<key>` for a key this package does
|
|
41
|
+
* not read; `RESULT_TRUNCATED` past the scan path's caps, or for an
|
|
42
|
+
* index shard whose pages do not end within `MAX_LOOP_ITERATIONS`;
|
|
43
|
+
* `FORMAT_UNSUPPORTED` for a SESSION row a newer release wrote, on either
|
|
44
|
+
* path; `ABORTED`.
|
|
45
|
+
*
|
|
46
|
+
* Guarantees: with a configured `indexName` each index shard is read
|
|
47
|
+
* newest-first one DynamoDB page at a time, and its next page whenever it has
|
|
48
|
+
* no row buffered and the page still needs one, which can cost a query per
|
|
49
|
+
* shard per page whose rows the page never takes; at most `readConcurrency`
|
|
50
|
+
* shards are queried at once. Memory is the page being built, up to `limit`
|
|
51
|
+
* rows and so bounded by the page ceiling, plus at most one DynamoDB page per shard,
|
|
52
|
+
* whatever the table holds. Without one it is a filtered table scan that holds
|
|
53
|
+
* every session at once and returns no cursor, as earlier releases did.
|
|
8
54
|
*/
|
|
9
|
-
export declare function listSessions(context: HistoryContext, options?:
|
|
10
|
-
maxIterations?: number;
|
|
11
|
-
maxItems?: number;
|
|
12
|
-
}): Promise<SessionMetadata[]>;
|
|
13
|
-
//# sourceMappingURL=list-sessions.d.ts.map
|
|
55
|
+
export declare function listSessions(context: HistoryContext, options?: ListSessionsOptions): Promise<SessionPage>;
|
|
@@ -1,57 +1,156 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hides whether a listing reads the recency index or scans the table.
|
|
4
|
+
*
|
|
5
|
+
* With a configured `indexName` a listing is a cursor-paged, newest-first
|
|
6
|
+
* merge of the index shards; without one it is a filtered scan sorted in
|
|
7
|
+
* memory, with no cursor (record 8). A caller passes the same options and gets
|
|
8
|
+
* the same `SessionPage` either way: `limit` is the newest N on both paths,
|
|
9
|
+
* `0` reads neither, and the same rule summarises each session and drops the
|
|
10
|
+
* expired, foreign and malformed ones.
|
|
11
|
+
*/
|
|
2
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
13
|
exports.listSessions = listSessions;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
14
|
+
const clock_1 = require("../../shared/clock");
|
|
15
|
+
const concurrency_1 = require("../../shared/concurrency");
|
|
16
|
+
const paginate_1 = require("../../shared/dynamodb/paginate");
|
|
17
|
+
const recency_index_1 = require("../../shared/dynamodb/recency-index");
|
|
18
|
+
const retry_1 = require("../../shared/dynamodb/retry");
|
|
19
|
+
const table_schema_1 = require("../../shared/dynamodb/table-schema");
|
|
20
|
+
const primitives_1 = require("../../shared/validation/primitives");
|
|
21
|
+
const parse_1 = require("../internal/parse");
|
|
22
|
+
const rows_1 = require("../internal/rows");
|
|
23
|
+
const session_1 = require("../internal/session");
|
|
24
|
+
/** Rows per page when the caller names none. */
|
|
25
|
+
const DEFAULT_PAGE_SIZE = (0, primitives_1.parseLimit)(100, 0);
|
|
6
26
|
/**
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
27
|
+
* One page from the recency index, newest-updated first.
|
|
28
|
+
*
|
|
29
|
+
* Expired, foreign and malformed rows are dropped after the read, so a page can
|
|
30
|
+
* come back shorter than `limit` while more rows remain. The cursor still advances,
|
|
31
|
+
* because it is the position in the index rather than a count of what survived
|
|
32
|
+
* filtering.
|
|
11
33
|
*/
|
|
12
|
-
function
|
|
13
|
-
|
|
34
|
+
async function pageFromIndex(context, indexName, request) {
|
|
35
|
+
const atSeconds = (0, clock_1.nowSeconds)();
|
|
36
|
+
const page = await (0, recency_index_1.queryRecencyIndex)({
|
|
37
|
+
client: context.client,
|
|
38
|
+
tableName: context.tableName,
|
|
39
|
+
indexName,
|
|
40
|
+
tag: 'SESS',
|
|
41
|
+
shards: context.indexShards ?? recency_index_1.DEFAULT_INDEX_SHARDS,
|
|
42
|
+
concurrency: context.readConcurrency ?? concurrency_1.DEFAULT_READ_CONCURRENCY,
|
|
43
|
+
limit: request.limit ?? DEFAULT_PAGE_SIZE,
|
|
44
|
+
cursor: request.cursor,
|
|
45
|
+
retry: (0, retry_1.retryFor)(context, request.signal),
|
|
46
|
+
signal: request.signal,
|
|
47
|
+
});
|
|
48
|
+
const sessions = page.items
|
|
49
|
+
.map((raw) => (0, session_1.summariseSession)(raw, atSeconds))
|
|
50
|
+
.filter((session) => session !== undefined);
|
|
51
|
+
return { sessions, ...(page.nextCursor === undefined ? {} : { nextCursor: page.nextCursor }) };
|
|
14
52
|
}
|
|
15
53
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
54
|
+
* Every session, read by scanning the table and sorted in memory.
|
|
55
|
+
*
|
|
56
|
+
* The fallback for a table without the recency index. It consumes read capacity
|
|
57
|
+
* for every row the scan *evaluates*, not every row it returns, and it holds
|
|
58
|
+
* every session at once — which is why the index exists and why this path
|
|
59
|
+
* offers no cursor.
|
|
60
|
+
*
|
|
61
|
+
* An explicit `limit` is honoured here as the newest N, the same thing it means
|
|
62
|
+
* on the index path. It cannot bound the read — a scan has to finish before the
|
|
63
|
+
* newest can be known — but answering a caller who asked for ten with five
|
|
64
|
+
* thousand sessions was a wrong answer, not a cheaper one.
|
|
65
|
+
*
|
|
66
|
+
* The filter names the partition tag before the sort key. The sort key alone
|
|
67
|
+
* does not identify this adapter: a store namespace element may not hold the
|
|
68
|
+
* separator, but the join inserts one, so the legal store key
|
|
69
|
+
* `sortKey(['t', 'HISTORY'], 'SESSION')` composes `SESSION_SORT_KEY` byte for
|
|
70
|
+
* byte. Such a row sits in a `STORE#` partition, and since a row stamped with a
|
|
71
|
+
* format version above this release is *reported* rather than skipped, one of
|
|
72
|
+
* them was enough to fail this listing on a table the three adapters share.
|
|
73
|
+
* `summariseSession` already requires `PK` to equal `sessionPartition(sessionId)`, so
|
|
74
|
+
* the tag excludes only rows it was dropping after the read. Filtering costs no
|
|
75
|
+
* read capacity either way: DynamoDB applies it once the scan has finished.
|
|
20
76
|
*/
|
|
21
|
-
async function
|
|
77
|
+
async function allByScan(context, request) {
|
|
22
78
|
const sessions = [];
|
|
23
|
-
const
|
|
24
|
-
for await (const raw of (0,
|
|
79
|
+
const atSeconds = (0, clock_1.nowSeconds)();
|
|
80
|
+
for await (const raw of (0, paginate_1.paginateScan)({
|
|
81
|
+
retry: (0, retry_1.retryFor)(context, request.signal),
|
|
82
|
+
signal: request.signal,
|
|
25
83
|
client: context.client,
|
|
26
84
|
params: {
|
|
27
85
|
TableName: context.tableName,
|
|
28
|
-
FilterExpression: '#sk = :session',
|
|
29
|
-
ExpressionAttributeNames: { '#
|
|
30
|
-
ExpressionAttributeValues: {
|
|
86
|
+
FilterExpression: 'begins_with(#pk, :pkp) AND #sk = :session',
|
|
87
|
+
ExpressionAttributeNames: { '#pk': table_schema_1.PARTITION_KEY_ATTRIBUTE, '#sk': table_schema_1.SORT_KEY_ATTRIBUTE },
|
|
88
|
+
ExpressionAttributeValues: {
|
|
89
|
+
':pkp': (0, rows_1.historyPartitionPrefix)(),
|
|
90
|
+
':session': rows_1.SESSION_SORT_KEY,
|
|
91
|
+
},
|
|
31
92
|
},
|
|
32
|
-
maxIterations:
|
|
33
|
-
maxItems:
|
|
93
|
+
maxIterations: request.maxIterations,
|
|
94
|
+
maxItems: request.maxItems,
|
|
34
95
|
})) {
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
37
|
-
|
|
38
|
-
if (isExpired(item, nowSeconds))
|
|
39
|
-
continue;
|
|
40
|
-
sessions.push({
|
|
41
|
-
sessionId: item.sessionId,
|
|
42
|
-
title: item.title,
|
|
43
|
-
messageCount: item.messageCount,
|
|
44
|
-
createdAt: item.createdAt,
|
|
45
|
-
updatedAt: item.updatedAt,
|
|
46
|
-
});
|
|
96
|
+
const session = (0, session_1.summariseSession)(raw, atSeconds);
|
|
97
|
+
if (session)
|
|
98
|
+
sessions.push(session);
|
|
47
99
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
* here and are not guaranteed to agree with it in every locale.
|
|
53
|
-
*/
|
|
100
|
+
// Ordinal, not `localeCompare`: these are ISO-8601 timestamps, whose byte
|
|
101
|
+
// order already is their chronological order. Locale-aware collation applies
|
|
102
|
+
// rules (case folding, punctuation weighting) that have no meaning here and
|
|
103
|
+
// are not guaranteed to agree with it in every locale.
|
|
54
104
|
sessions.sort((a, b) => (a.updatedAt < b.updatedAt ? 1 : a.updatedAt > b.updatedAt ? -1 : 0));
|
|
55
|
-
return sessions;
|
|
105
|
+
return { sessions: request.limit === undefined ? sessions : sessions.slice(0, request.limit) };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* List sessions as metadata summaries, most recently updated first.
|
|
109
|
+
*
|
|
110
|
+
* Accepts: `options.limit` — the package-wide page rule, an integer from 0 to
|
|
111
|
+
* the page ceiling; absent means one index page (100) with the index, and
|
|
112
|
+
* every session without it, since a scan has no cursor to fetch the rest with.
|
|
113
|
+
* `0` returns an empty page on either path without reading the table, which
|
|
114
|
+
* matters most on the scan path: a scan has to finish before the newest can be
|
|
115
|
+
* known, so answering `limit: 0` by scanning and then slicing to nothing would
|
|
116
|
+
* have paid for the whole table to return an empty page.
|
|
117
|
+
* `options.cursor` — from a previous page, and
|
|
118
|
+
* only with a configured `indexName`. `options.maxItems` and
|
|
119
|
+
* `maxIterations` — caps on the scan path; with the index the page size is the
|
|
120
|
+
* bound and they do nothing. Each must be a positive integer or `Infinity`
|
|
121
|
+
* (the paginator's own way to ask for no cap); absent keeps its default.
|
|
122
|
+
*
|
|
123
|
+
* Returns: the page, newest-updated first, and a `nextCursor` while rows may
|
|
124
|
+
* remain. A page can come back shorter than `limit` while more remain: expired
|
|
125
|
+
* and foreign rows are dropped after the read, and so is a row of this
|
|
126
|
+
* package's own whose `messageCount`, `createdAt`, `updatedAt`, `title` or
|
|
127
|
+
* `ttl` is not the type written there — otherwise one unreadable `ttl` would fail the
|
|
128
|
+
* whole call, taking every healthy session with it. The cursor is a position in
|
|
129
|
+
* the index rather than a count of what survived filtering. A cursor does not
|
|
130
|
+
* promise more rows: the page after it can come back empty (see
|
|
131
|
+
* `queryRecencyIndex`).
|
|
132
|
+
*
|
|
133
|
+
* Throws: `VALIDATION` naming `limit`, `cursor`, `maxItems`,
|
|
134
|
+
* `maxIterations`, `signal`, or `options.<key>` for a key this package does
|
|
135
|
+
* not read; `RESULT_TRUNCATED` past the scan path's caps, or for an
|
|
136
|
+
* index shard whose pages do not end within `MAX_LOOP_ITERATIONS`;
|
|
137
|
+
* `FORMAT_UNSUPPORTED` for a SESSION row a newer release wrote, on either
|
|
138
|
+
* path; `ABORTED`.
|
|
139
|
+
*
|
|
140
|
+
* Guarantees: with a configured `indexName` each index shard is read
|
|
141
|
+
* newest-first one DynamoDB page at a time, and its next page whenever it has
|
|
142
|
+
* no row buffered and the page still needs one, which can cost a query per
|
|
143
|
+
* shard per page whose rows the page never takes; at most `readConcurrency`
|
|
144
|
+
* shards are queried at once. Memory is the page being built, up to `limit`
|
|
145
|
+
* rows and so bounded by the page ceiling, plus at most one DynamoDB page per shard,
|
|
146
|
+
* whatever the table holds. Without one it is a filtered table scan that holds
|
|
147
|
+
* every session at once and returns no cursor, as earlier releases did.
|
|
148
|
+
*/
|
|
149
|
+
async function listSessions(context, options = {}) {
|
|
150
|
+
const request = (0, parse_1.parseListSessionsRequest)(options, context.indexName);
|
|
151
|
+
if (request.limit === 0)
|
|
152
|
+
return { sessions: [] };
|
|
153
|
+
return context.indexName === undefined
|
|
154
|
+
? allByScan(context, request)
|
|
155
|
+
: pageFromIndex(context, context.indexName, request);
|
|
56
156
|
}
|
|
57
|
-
//# sourceMappingURL=list-sessions.js.map
|