@farukada/aws-langgraph-dynamodb-ts 1.0.0-rc.1 → 1.0.0
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 +1820 -290
- package/dist/cjs/backfill/backfill.d.ts +171 -0
- package/dist/cjs/backfill/backfill.js +177 -0
- package/dist/cjs/checkpointer/actions/delete-thread.d.ts +50 -0
- package/dist/cjs/checkpointer/actions/delete-thread.js +26 -0
- package/dist/cjs/checkpointer/actions/get-tuple.d.ts +36 -0
- package/dist/cjs/checkpointer/actions/get-tuple.js +22 -0
- package/dist/cjs/checkpointer/actions/list.d.ts +55 -0
- package/dist/cjs/checkpointer/actions/list.js +70 -0
- package/dist/cjs/checkpointer/actions/put-writes.d.ts +49 -0
- package/dist/cjs/checkpointer/actions/put-writes.js +21 -0
- package/dist/cjs/checkpointer/actions/put.d.ts +95 -0
- package/dist/cjs/checkpointer/actions/put.js +79 -0
- package/dist/cjs/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/cjs/checkpointer/internal/delta-history.js +131 -0
- package/dist/cjs/checkpointer/internal/listing.d.ts +149 -0
- package/dist/cjs/checkpointer/internal/listing.js +104 -0
- package/dist/cjs/checkpointer/internal/parse.d.ts +298 -0
- package/dist/cjs/checkpointer/internal/parse.js +184 -0
- package/dist/cjs/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/cjs/checkpointer/internal/pending-writes.js +241 -0
- package/dist/cjs/checkpointer/internal/read.d.ts +135 -0
- package/dist/cjs/checkpointer/internal/read.js +132 -0
- package/dist/cjs/checkpointer/internal/rows.d.ts +644 -0
- package/dist/cjs/checkpointer/internal/rows.js +356 -0
- package/dist/cjs/checkpointer/internal/setup.d.ts +47 -0
- package/dist/cjs/checkpointer/internal/setup.js +25 -0
- package/dist/cjs/checkpointer/saver.d.ts +306 -0
- package/dist/cjs/checkpointer/saver.js +56 -0
- package/dist/cjs/checkpointer/types.d.ts +51 -0
- package/dist/cjs/factory/factory.d.ts +154 -0
- package/dist/cjs/factory/factory.js +137 -0
- package/dist/{factory → cjs/factory}/types.d.ts +33 -14
- package/dist/cjs/history/actions/add-messages.d.ts +51 -0
- package/dist/cjs/history/actions/add-messages.js +17 -0
- package/dist/cjs/history/actions/clear.d.ts +52 -0
- package/dist/cjs/history/actions/clear.js +29 -0
- package/dist/cjs/history/actions/get-messages.d.ts +60 -0
- package/dist/cjs/history/actions/get-messages.js +58 -0
- package/dist/cjs/history/actions/list-sessions.d.ts +55 -0
- package/dist/cjs/history/actions/list-sessions.js +67 -0
- package/dist/cjs/history/actions/reconcile-count.d.ts +49 -0
- package/dist/cjs/history/actions/reconcile-count.js +8 -0
- package/dist/cjs/history/chat-message-history.d.ts +267 -0
- package/dist/cjs/history/chat-message-history.js +61 -0
- package/dist/cjs/history/internal/append.d.ts +244 -0
- package/dist/cjs/history/internal/append.js +267 -0
- package/dist/cjs/history/internal/message-read.d.ts +84 -0
- package/dist/cjs/history/internal/message-read.js +93 -0
- package/dist/cjs/history/internal/parse.d.ts +153 -0
- package/dist/cjs/history/internal/parse.js +113 -0
- package/dist/cjs/history/internal/rows.d.ts +196 -0
- package/dist/cjs/history/internal/rows.js +96 -0
- package/dist/cjs/history/internal/session.d.ts +350 -0
- package/dist/cjs/history/internal/session.js +296 -0
- package/dist/cjs/history/internal/setup.d.ts +64 -0
- package/dist/cjs/history/internal/setup.js +60 -0
- package/dist/cjs/history/session-adapter.d.ts +112 -0
- package/dist/cjs/history/session-adapter.js +38 -0
- package/dist/cjs/history/types.d.ts +102 -0
- package/dist/cjs/index.d.ts +53 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/shared/adapter.d.ts +146 -0
- package/dist/cjs/shared/adapter.js +70 -0
- package/dist/cjs/shared/clock.d.ts +52 -0
- package/dist/cjs/shared/clock.js +14 -0
- package/dist/cjs/shared/codec/codec.d.ts +336 -0
- package/dist/cjs/shared/codec/codec.js +162 -0
- package/dist/cjs/shared/codec/compression.d.ts +66 -0
- package/dist/cjs/shared/codec/compression.js +45 -0
- package/dist/cjs/shared/codec/json-serde.d.ts +80 -0
- package/dist/cjs/shared/codec/json-serde.js +58 -0
- package/dist/{shared → cjs/shared}/codec/s3/client-types.d.ts +22 -2
- package/dist/{shared → cjs/shared}/codec/s3/client-types.js +0 -1
- package/dist/cjs/shared/codec/s3/client.d.ts +63 -0
- package/dist/cjs/shared/codec/s3/client.js +78 -0
- package/dist/cjs/shared/codec/s3/config.d.ts +260 -0
- package/dist/cjs/shared/codec/s3/config.js +92 -0
- package/dist/cjs/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/cjs/shared/codec/s3/lifecycle.js +223 -0
- package/dist/cjs/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/cjs/shared/codec/s3/offloader.js +289 -0
- package/dist/cjs/shared/concurrency.d.ts +43 -0
- package/dist/{shared → cjs/shared}/concurrency.js +10 -9
- package/dist/cjs/shared/dynamodb/abort.d.ts +47 -0
- package/dist/cjs/shared/dynamodb/abort.js +16 -0
- package/dist/cjs/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/cjs/shared/dynamodb/batch-write.js +79 -0
- package/dist/cjs/shared/dynamodb/cancellation.d.ts +124 -0
- package/dist/cjs/shared/dynamodb/cancellation.js +37 -0
- package/dist/cjs/shared/dynamodb/client.d.ts +177 -0
- package/dist/{shared → cjs/shared}/dynamodb/client.js +12 -14
- package/dist/cjs/shared/dynamodb/idempotent-write.d.ts +596 -0
- package/dist/cjs/shared/dynamodb/idempotent-write.js +173 -0
- package/dist/cjs/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/cjs/shared/dynamodb/paginate.js +90 -0
- package/dist/cjs/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/cjs/shared/dynamodb/partition-delete.js +177 -0
- package/dist/cjs/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/cjs/shared/dynamodb/recency-index.js +146 -0
- package/dist/cjs/shared/dynamodb/retry.d.ts +317 -0
- package/dist/cjs/shared/dynamodb/retry.js +193 -0
- package/dist/cjs/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/cjs/shared/dynamodb/row-size.js +30 -0
- package/dist/cjs/shared/dynamodb/table-schema.d.ts +199 -0
- package/dist/cjs/shared/dynamodb/table-schema.js +52 -0
- package/dist/cjs/shared/errors/base-error.d.ts +231 -0
- package/dist/cjs/shared/errors/base-error.js +73 -0
- package/dist/cjs/shared/errors/boundary.d.ts +86 -0
- package/dist/cjs/shared/errors/boundary.js +61 -0
- package/dist/cjs/shared/errors/classify.d.ts +206 -0
- package/dist/cjs/shared/errors/classify.js +232 -0
- package/dist/cjs/shared/errors/error-code.d.ts +95 -0
- package/dist/{shared → cjs/shared}/errors/error-code.js +12 -2
- package/dist/cjs/shared/errors/errors.d.ts +233 -0
- package/dist/cjs/shared/errors/errors.js +123 -0
- package/dist/cjs/shared/logging/logger.d.ts +80 -0
- package/dist/cjs/shared/logging/logger.js +30 -0
- package/dist/cjs/shared/logging/redaction.d.ts +123 -0
- package/dist/cjs/shared/logging/redaction.js +145 -0
- package/dist/cjs/shared/logging/secret-patterns.d.ts +227 -0
- package/dist/cjs/shared/logging/secret-patterns.js +93 -0
- package/dist/cjs/shared/logging/truncate.d.ts +197 -0
- package/dist/cjs/shared/logging/truncate.js +31 -0
- package/dist/cjs/shared/options.d.ts +100 -0
- package/dist/cjs/shared/ulid.d.ts +80 -0
- package/dist/{shared → cjs/shared}/ulid.js +7 -21
- package/dist/cjs/shared/validation/collaborators.d.ts +160 -0
- package/dist/cjs/shared/validation/collaborators.js +79 -0
- package/dist/cjs/shared/validation/option-shape.d.ts +91 -0
- package/dist/cjs/shared/validation/option-shape.js +31 -0
- package/dist/cjs/shared/validation/options.d.ts +145 -0
- package/dist/cjs/shared/validation/options.js +166 -0
- package/dist/cjs/shared/validation/primitives.d.ts +292 -0
- package/dist/cjs/shared/validation/primitives.js +114 -0
- package/dist/cjs/shared/validation/ttl.d.ts +94 -0
- package/dist/cjs/shared/validation/ttl.js +52 -0
- package/dist/cjs/store/actions/list-namespaces.d.ts +79 -0
- package/dist/cjs/store/actions/list-namespaces.js +92 -0
- package/dist/cjs/store/actions/put.d.ts +43 -0
- package/dist/cjs/store/actions/put.js +49 -0
- package/dist/cjs/store/actions/reconcile-vector-index.d.ts +38 -0
- package/dist/cjs/store/actions/reconcile-vector-index.js +13 -0
- package/dist/cjs/store/actions/search.d.ts +38 -0
- package/dist/cjs/store/actions/search.js +26 -0
- package/dist/cjs/store/internal/batch-plan.d.ts +56 -0
- package/dist/cjs/store/internal/batch-plan.js +32 -0
- package/dist/cjs/store/internal/filter.d.ts +43 -0
- package/dist/cjs/store/internal/filter.js +64 -0
- package/dist/cjs/store/internal/get-item.d.ts +77 -0
- package/dist/cjs/store/internal/get-item.js +58 -0
- package/dist/cjs/store/internal/item-write.d.ts +270 -0
- package/dist/cjs/store/internal/item-write.js +181 -0
- package/dist/cjs/store/internal/parse.d.ts +230 -0
- package/dist/cjs/store/internal/parse.js +180 -0
- package/dist/cjs/store/internal/rows.d.ts +359 -0
- package/dist/cjs/store/internal/rows.js +166 -0
- package/dist/cjs/store/internal/semantic-search.d.ts +168 -0
- package/dist/{store/internal/text-path.js → cjs/store/internal/semantic-search.js} +92 -28
- package/dist/cjs/store/internal/setup.d.ts +96 -0
- package/dist/cjs/store/internal/setup.js +103 -0
- package/dist/cjs/store/internal/table-search.d.ts +100 -0
- package/dist/cjs/store/internal/table-search.js +123 -0
- package/dist/cjs/store/internal/vector-index.d.ts +258 -0
- package/dist/cjs/store/internal/vector-index.js +269 -0
- package/dist/cjs/store/store.d.ts +329 -0
- package/dist/cjs/store/store.js +97 -0
- package/dist/cjs/store/types.d.ts +111 -0
- package/dist/cjs/store/vector-backend.d.ts +104 -0
- package/dist/cjs/store/vector-backend.js +4 -0
- package/dist/esm/backfill/backfill.d.ts +171 -0
- package/dist/esm/backfill/backfill.js +170 -0
- package/dist/esm/checkpointer/actions/delete-thread.d.ts +50 -0
- package/dist/esm/checkpointer/actions/delete-thread.js +23 -0
- package/dist/esm/checkpointer/actions/get-tuple.d.ts +36 -0
- package/dist/esm/checkpointer/actions/get-tuple.js +19 -0
- package/dist/esm/checkpointer/actions/list.d.ts +55 -0
- package/dist/esm/checkpointer/actions/list.js +67 -0
- package/dist/esm/checkpointer/actions/put-writes.d.ts +49 -0
- package/dist/esm/checkpointer/actions/put-writes.js +18 -0
- package/dist/esm/checkpointer/actions/put.d.ts +95 -0
- package/dist/esm/checkpointer/actions/put.js +75 -0
- package/dist/esm/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/esm/checkpointer/internal/delta-history.js +126 -0
- package/dist/esm/checkpointer/internal/listing.d.ts +149 -0
- package/dist/esm/checkpointer/internal/listing.js +95 -0
- package/dist/esm/checkpointer/internal/parse.d.ts +298 -0
- package/dist/esm/checkpointer/internal/parse.js +169 -0
- package/dist/esm/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/esm/checkpointer/internal/pending-writes.js +229 -0
- package/dist/esm/checkpointer/internal/read.d.ts +135 -0
- package/dist/esm/checkpointer/internal/read.js +125 -0
- package/dist/esm/checkpointer/internal/rows.d.ts +644 -0
- package/dist/esm/checkpointer/internal/rows.js +323 -0
- package/dist/esm/checkpointer/internal/setup.d.ts +47 -0
- package/dist/esm/checkpointer/internal/setup.js +21 -0
- package/dist/esm/checkpointer/saver.d.ts +306 -0
- package/dist/esm/checkpointer/saver.js +52 -0
- package/dist/esm/checkpointer/types.d.ts +51 -0
- package/dist/esm/checkpointer/types.js +1 -0
- package/dist/esm/factory/factory.d.ts +154 -0
- package/dist/esm/factory/factory.js +133 -0
- package/dist/esm/factory/types.d.ts +76 -0
- package/dist/esm/factory/types.js +1 -0
- package/dist/esm/history/actions/add-messages.d.ts +51 -0
- package/dist/esm/history/actions/add-messages.js +14 -0
- package/dist/esm/history/actions/clear.d.ts +52 -0
- package/dist/esm/history/actions/clear.js +26 -0
- package/dist/esm/history/actions/get-messages.d.ts +60 -0
- package/dist/esm/history/actions/get-messages.js +55 -0
- package/dist/esm/history/actions/list-sessions.d.ts +55 -0
- package/dist/esm/history/actions/list-sessions.js +64 -0
- package/dist/esm/history/actions/reconcile-count.d.ts +49 -0
- package/dist/esm/history/actions/reconcile-count.js +5 -0
- package/dist/esm/history/chat-message-history.d.ts +267 -0
- package/dist/esm/history/chat-message-history.js +57 -0
- package/dist/esm/history/internal/append.d.ts +244 -0
- package/dist/esm/history/internal/append.js +259 -0
- package/dist/esm/history/internal/message-read.d.ts +84 -0
- package/dist/esm/history/internal/message-read.js +89 -0
- package/dist/esm/history/internal/parse.d.ts +153 -0
- package/dist/esm/history/internal/parse.js +105 -0
- package/dist/esm/history/internal/rows.d.ts +196 -0
- package/dist/esm/history/internal/rows.js +83 -0
- package/dist/esm/history/internal/session.d.ts +350 -0
- package/dist/esm/history/internal/session.js +285 -0
- package/dist/esm/history/internal/setup.d.ts +64 -0
- package/dist/esm/history/internal/setup.js +56 -0
- package/dist/esm/history/session-adapter.d.ts +112 -0
- package/dist/esm/history/session-adapter.js +34 -0
- package/dist/esm/history/types.d.ts +102 -0
- package/dist/esm/history/types.js +1 -0
- package/dist/esm/index.d.ts +53 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/shared/adapter.d.ts +146 -0
- package/dist/esm/shared/adapter.js +65 -0
- package/dist/esm/shared/clock.d.ts +52 -0
- package/dist/esm/shared/clock.js +9 -0
- package/dist/esm/shared/codec/codec.d.ts +336 -0
- package/dist/esm/shared/codec/codec.js +150 -0
- package/dist/esm/shared/codec/compression.d.ts +66 -0
- package/dist/esm/shared/codec/compression.js +40 -0
- package/dist/esm/shared/codec/json-serde.d.ts +80 -0
- package/dist/esm/shared/codec/json-serde.js +54 -0
- package/dist/esm/shared/codec/s3/client-types.d.ts +54 -0
- package/dist/esm/shared/codec/s3/client-types.js +3 -0
- package/dist/esm/shared/codec/s3/client.d.ts +63 -0
- package/dist/esm/shared/codec/s3/client.js +40 -0
- package/dist/esm/shared/codec/s3/config.d.ts +260 -0
- package/dist/esm/shared/codec/s3/config.js +79 -0
- package/dist/esm/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/esm/shared/codec/s3/lifecycle.js +214 -0
- package/dist/esm/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/esm/shared/codec/s3/offloader.js +278 -0
- package/dist/esm/shared/concurrency.d.ts +43 -0
- package/dist/esm/shared/concurrency.js +27 -0
- package/dist/esm/shared/dynamodb/abort.d.ts +47 -0
- package/dist/esm/shared/dynamodb/abort.js +12 -0
- package/dist/esm/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/esm/shared/dynamodb/batch-write.js +74 -0
- package/dist/esm/shared/dynamodb/cancellation.d.ts +124 -0
- package/dist/esm/shared/dynamodb/cancellation.js +30 -0
- package/dist/esm/shared/dynamodb/client.d.ts +177 -0
- package/dist/esm/shared/dynamodb/client.js +35 -0
- package/dist/esm/shared/dynamodb/idempotent-write.d.ts +596 -0
- package/dist/esm/shared/dynamodb/idempotent-write.js +153 -0
- package/dist/esm/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/esm/shared/dynamodb/paginate.js +84 -0
- package/dist/esm/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/esm/shared/dynamodb/partition-delete.js +171 -0
- package/dist/esm/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/esm/shared/dynamodb/recency-index.js +136 -0
- package/dist/esm/shared/dynamodb/retry.d.ts +317 -0
- package/dist/esm/shared/dynamodb/retry.js +180 -0
- package/dist/esm/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/esm/shared/dynamodb/row-size.js +26 -0
- package/dist/esm/shared/dynamodb/table-schema.d.ts +199 -0
- package/dist/esm/shared/dynamodb/table-schema.js +43 -0
- package/dist/esm/shared/errors/base-error.d.ts +231 -0
- package/dist/esm/shared/errors/base-error.js +64 -0
- package/dist/esm/shared/errors/boundary.d.ts +86 -0
- package/dist/esm/shared/errors/boundary.js +54 -0
- package/dist/esm/shared/errors/classify.d.ts +206 -0
- package/dist/esm/shared/errors/classify.js +220 -0
- package/dist/esm/shared/errors/error-code.d.ts +95 -0
- package/dist/esm/shared/errors/error-code.js +24 -0
- package/dist/esm/shared/errors/errors.d.ts +233 -0
- package/dist/esm/shared/errors/errors.js +110 -0
- package/dist/esm/shared/logging/logger.d.ts +80 -0
- package/dist/esm/shared/logging/logger.js +25 -0
- package/dist/esm/shared/logging/redaction.d.ts +123 -0
- package/dist/esm/shared/logging/redaction.js +140 -0
- package/dist/esm/shared/logging/secret-patterns.d.ts +227 -0
- package/dist/esm/shared/logging/secret-patterns.js +83 -0
- package/dist/esm/shared/logging/truncate.d.ts +197 -0
- package/dist/esm/shared/logging/truncate.js +25 -0
- package/dist/esm/shared/options.d.ts +100 -0
- package/dist/esm/shared/options.js +1 -0
- package/dist/esm/shared/ulid.d.ts +80 -0
- package/dist/esm/shared/ulid.js +77 -0
- package/dist/esm/shared/validation/collaborators.d.ts +160 -0
- package/dist/esm/shared/validation/collaborators.js +70 -0
- package/dist/esm/shared/validation/option-shape.d.ts +91 -0
- package/dist/esm/shared/validation/option-shape.js +24 -0
- package/dist/esm/shared/validation/options.d.ts +145 -0
- package/dist/esm/shared/validation/options.js +156 -0
- package/dist/esm/shared/validation/primitives.d.ts +292 -0
- package/dist/esm/shared/validation/primitives.js +100 -0
- package/dist/esm/shared/validation/ttl.d.ts +94 -0
- package/dist/esm/shared/validation/ttl.js +46 -0
- package/dist/esm/store/actions/list-namespaces.d.ts +79 -0
- package/dist/esm/store/actions/list-namespaces.js +86 -0
- package/dist/esm/store/actions/put.d.ts +43 -0
- package/dist/esm/store/actions/put.js +46 -0
- package/dist/esm/store/actions/reconcile-vector-index.d.ts +38 -0
- package/dist/esm/store/actions/reconcile-vector-index.js +10 -0
- package/dist/esm/store/actions/search.d.ts +38 -0
- package/dist/esm/store/actions/search.js +23 -0
- package/dist/esm/store/internal/batch-plan.d.ts +56 -0
- package/dist/esm/store/internal/batch-plan.js +28 -0
- package/dist/esm/store/internal/filter.d.ts +43 -0
- package/dist/esm/store/internal/filter.js +60 -0
- package/dist/esm/store/internal/get-item.d.ts +77 -0
- package/dist/esm/store/internal/get-item.js +54 -0
- package/dist/esm/store/internal/item-write.d.ts +270 -0
- package/dist/esm/store/internal/item-write.js +173 -0
- package/dist/esm/store/internal/parse.d.ts +230 -0
- package/dist/esm/store/internal/parse.js +169 -0
- package/dist/esm/store/internal/rows.d.ts +359 -0
- package/dist/esm/store/internal/rows.js +147 -0
- package/dist/esm/store/internal/semantic-search.d.ts +168 -0
- package/dist/esm/store/internal/semantic-search.js +200 -0
- package/dist/esm/store/internal/setup.d.ts +96 -0
- package/dist/esm/store/internal/setup.js +98 -0
- package/dist/esm/store/internal/table-search.d.ts +100 -0
- package/dist/esm/store/internal/table-search.js +119 -0
- package/dist/esm/store/internal/vector-index.d.ts +258 -0
- package/dist/esm/store/internal/vector-index.js +256 -0
- package/dist/esm/store/store.d.ts +329 -0
- package/dist/esm/store/store.js +93 -0
- package/dist/esm/store/types.d.ts +111 -0
- package/dist/esm/store/types.js +1 -0
- package/dist/esm/store/vector-backend.d.ts +104 -0
- package/dist/esm/store/vector-backend.js +1 -0
- package/package.json +68 -46
- package/dist/checkpointer/actions/delete-thread.d.ts +0 -10
- package/dist/checkpointer/actions/delete-thread.js +0 -38
- package/dist/checkpointer/actions/get-tuple.d.ts +0 -11
- package/dist/checkpointer/actions/get-tuple.js +0 -25
- package/dist/checkpointer/actions/list.d.ts +0 -20
- package/dist/checkpointer/actions/list.js +0 -113
- package/dist/checkpointer/actions/put-writes.d.ts +0 -15
- package/dist/checkpointer/actions/put-writes.js +0 -62
- package/dist/checkpointer/actions/put.d.ts +0 -17
- package/dist/checkpointer/actions/put.js +0 -73
- package/dist/checkpointer/internal/assemble.d.ts +0 -17
- package/dist/checkpointer/internal/assemble.js +0 -38
- package/dist/checkpointer/internal/checkpoint-write-verify.d.ts +0 -24
- package/dist/checkpointer/internal/checkpoint-write-verify.js +0 -67
- package/dist/checkpointer/internal/configurable.d.ts +0 -12
- package/dist/checkpointer/internal/configurable.js +0 -24
- package/dist/checkpointer/internal/fetch.d.ts +0 -19
- package/dist/checkpointer/internal/fetch.js +0 -88
- package/dist/checkpointer/internal/filter-match.d.ts +0 -13
- package/dist/checkpointer/internal/filter-match.js +0 -15
- package/dist/checkpointer/internal/item-reader.d.ts +0 -66
- package/dist/checkpointer/internal/item-reader.js +0 -113
- package/dist/checkpointer/internal/item-writer.d.ts +0 -35
- package/dist/checkpointer/internal/item-writer.js +0 -107
- package/dist/checkpointer/internal/keys.d.ts +0 -41
- package/dist/checkpointer/internal/keys.js +0 -117
- package/dist/checkpointer/internal/list-scope.d.ts +0 -61
- package/dist/checkpointer/internal/list-scope.js +0 -108
- package/dist/checkpointer/internal/pending-sends.d.ts +0 -13
- package/dist/checkpointer/internal/pending-sends.js +0 -29
- package/dist/checkpointer/internal/query.d.ts +0 -21
- package/dist/checkpointer/internal/query.js +0 -42
- package/dist/checkpointer/internal/regular-write.d.ts +0 -28
- package/dist/checkpointer/internal/regular-write.js +0 -66
- package/dist/checkpointer/internal/setup.d.ts +0 -33
- package/dist/checkpointer/internal/setup.js +0 -38
- package/dist/checkpointer/internal/special-write-cas.d.ts +0 -29
- package/dist/checkpointer/internal/special-write-cas.js +0 -104
- package/dist/checkpointer/internal/special-write-cleanup.d.ts +0 -23
- package/dist/checkpointer/internal/special-write-cleanup.js +0 -50
- package/dist/checkpointer/internal/special-write-verify.d.ts +0 -53
- package/dist/checkpointer/internal/special-write-verify.js +0 -80
- package/dist/checkpointer/internal/stored-channels.d.ts +0 -31
- package/dist/checkpointer/internal/stored-channels.js +0 -70
- package/dist/checkpointer/internal/validation.d.ts +0 -18
- package/dist/checkpointer/internal/validation.js +0 -40
- package/dist/checkpointer/internal/write-guard.d.ts +0 -20
- package/dist/checkpointer/internal/write-guard.js +0 -48
- package/dist/checkpointer/internal/write-index.d.ts +0 -36
- package/dist/checkpointer/internal/write-index.js +0 -41
- package/dist/checkpointer/saver.d.ts +0 -70
- package/dist/checkpointer/saver.js +0 -105
- package/dist/checkpointer/types.d.ts +0 -58
- package/dist/factory/factory.d.ts +0 -40
- package/dist/factory/factory.js +0 -87
- package/dist/history/actions/add-messages.d.ts +0 -15
- package/dist/history/actions/add-messages.js +0 -77
- package/dist/history/actions/clear.d.ts +0 -10
- package/dist/history/actions/clear.js +0 -34
- package/dist/history/actions/get-messages.d.ts +0 -17
- package/dist/history/actions/get-messages.js +0 -79
- package/dist/history/actions/list-sessions.d.ts +0 -13
- package/dist/history/actions/list-sessions.js +0 -53
- package/dist/history/actions/reconcile-count.d.ts +0 -12
- package/dist/history/actions/reconcile-count.js +0 -64
- package/dist/history/chat-message-history.d.ts +0 -73
- package/dist/history/chat-message-history.js +0 -111
- package/dist/history/internal/append-saga.d.ts +0 -25
- package/dist/history/internal/append-saga.js +0 -79
- package/dist/history/internal/compensation.d.ts +0 -25
- package/dist/history/internal/compensation.js +0 -92
- package/dist/history/internal/item-mapper.d.ts +0 -9
- package/dist/history/internal/item-mapper.js +0 -27
- package/dist/history/internal/keys.d.ts +0 -16
- package/dist/history/internal/keys.js +0 -48
- package/dist/history/internal/message-chunker.d.ts +0 -13
- package/dist/history/internal/message-chunker.js +0 -67
- package/dist/history/internal/message-transaction.d.ts +0 -25
- package/dist/history/internal/message-transaction.js +0 -61
- package/dist/history/internal/message-window.d.ts +0 -17
- package/dist/history/internal/message-window.js +0 -49
- package/dist/history/internal/query.d.ts +0 -23
- package/dist/history/internal/query.js +0 -39
- package/dist/history/internal/session-count.d.ts +0 -47
- package/dist/history/internal/session-count.js +0 -115
- package/dist/history/internal/session-title.d.ts +0 -19
- package/dist/history/internal/session-title.js +0 -43
- package/dist/history/internal/session-update.d.ts +0 -27
- package/dist/history/internal/session-update.js +0 -69
- package/dist/history/internal/setup.d.ts +0 -31
- package/dist/history/internal/setup.js +0 -43
- package/dist/history/internal/title-generator.d.ts +0 -12
- package/dist/history/internal/title-generator.js +0 -41
- package/dist/history/internal/ttl-anchor.d.ts +0 -24
- package/dist/history/internal/ttl-anchor.js +0 -38
- package/dist/history/internal/validation.d.ts +0 -25
- package/dist/history/internal/validation.js +0 -53
- package/dist/history/session-adapter.d.ts +0 -29
- package/dist/history/session-adapter.js +0 -35
- package/dist/history/types.d.ts +0 -69
- package/dist/index.d.ts +0 -29
- package/dist/index.js +0 -32
- package/dist/shared/clock.d.ts +0 -8
- package/dist/shared/clock.js +0 -16
- package/dist/shared/codec/codec.d.ts +0 -53
- package/dist/shared/codec/codec.js +0 -66
- package/dist/shared/codec/compression.d.ts +0 -24
- package/dist/shared/codec/compression.js +0 -48
- package/dist/shared/codec/descriptor-keys.d.ts +0 -12
- package/dist/shared/codec/descriptor-keys.js +0 -14
- package/dist/shared/codec/encode.d.ts +0 -13
- package/dist/shared/codec/encode.js +0 -43
- package/dist/shared/codec/json-serde.d.ts +0 -7
- package/dist/shared/codec/json-serde.js +0 -17
- package/dist/shared/codec/payload-loss.d.ts +0 -12
- package/dist/shared/codec/payload-loss.js +0 -38
- package/dist/shared/codec/s3/adapter-config.d.ts +0 -13
- package/dist/shared/codec/s3/adapter-config.js +0 -22
- package/dist/shared/codec/s3/bounded-body.d.ts +0 -14
- package/dist/shared/codec/s3/bounded-body.js +0 -47
- package/dist/shared/codec/s3/client.d.ts +0 -18
- package/dist/shared/codec/s3/client.js +0 -46
- package/dist/shared/codec/s3/config.d.ts +0 -51
- package/dist/shared/codec/s3/config.js +0 -58
- package/dist/shared/codec/s3/delete.d.ts +0 -7
- package/dist/shared/codec/s3/delete.js +0 -28
- package/dist/shared/codec/s3/key-scope.d.ts +0 -23
- package/dist/shared/codec/s3/key-scope.js +0 -44
- package/dist/shared/codec/s3/lifecycle.d.ts +0 -14
- package/dist/shared/codec/s3/lifecycle.js +0 -63
- package/dist/shared/codec/s3/offloader.d.ts +0 -44
- package/dist/shared/codec/s3/offloader.js +0 -118
- package/dist/shared/codec/s3/orphans.d.ts +0 -23
- package/dist/shared/codec/s3/orphans.js +0 -71
- package/dist/shared/codec/s3/read-write.d.ts +0 -18
- package/dist/shared/codec/s3/read-write.js +0 -51
- package/dist/shared/codec/s3/retry.d.ts +0 -5
- package/dist/shared/codec/s3/retry.js +0 -22
- package/dist/shared/concurrency.d.ts +0 -6
- package/dist/shared/constants.d.ts +0 -112
- package/dist/shared/constants.js +0 -115
- package/dist/shared/dynamodb/abort.d.ts +0 -9
- package/dist/shared/dynamodb/abort.js +0 -27
- package/dist/shared/dynamodb/backoff.d.ts +0 -15
- package/dist/shared/dynamodb/backoff.js +0 -48
- package/dist/shared/dynamodb/batch-write.d.ts +0 -22
- package/dist/shared/dynamodb/batch-write.js +0 -53
- package/dist/shared/dynamodb/cancellation.d.ts +0 -6
- package/dist/shared/dynamodb/cancellation.js +0 -7
- package/dist/shared/dynamodb/client.d.ts +0 -28
- package/dist/shared/dynamodb/conditional-put.d.ts +0 -67
- package/dist/shared/dynamodb/conditional-put.js +0 -76
- package/dist/shared/dynamodb/drain-unprocessed.d.ts +0 -21
- package/dist/shared/dynamodb/drain-unprocessed.js +0 -43
- package/dist/shared/dynamodb/expiry.d.ts +0 -16
- package/dist/shared/dynamodb/expiry.js +0 -29
- package/dist/shared/dynamodb/paginate-core.d.ts +0 -24
- package/dist/shared/dynamodb/paginate-core.js +0 -82
- package/dist/shared/dynamodb/paginate.d.ts +0 -14
- package/dist/shared/dynamodb/paginate.js +0 -19
- package/dist/shared/dynamodb/partition-delete.d.ts +0 -39
- package/dist/shared/dynamodb/partition-delete.js +0 -71
- package/dist/shared/dynamodb/retry-classifier.d.ts +0 -17
- package/dist/shared/dynamodb/retry-classifier.js +0 -118
- package/dist/shared/dynamodb/retry-policy.d.ts +0 -26
- package/dist/shared/dynamodb/retry-policy.js +0 -22
- package/dist/shared/dynamodb/retry.d.ts +0 -31
- package/dist/shared/dynamodb/retry.js +0 -57
- package/dist/shared/dynamodb/scan.d.ts +0 -14
- package/dist/shared/dynamodb/scan.js +0 -19
- package/dist/shared/dynamodb/types.d.ts +0 -23
- package/dist/shared/errors/base-error.d.ts +0 -30
- package/dist/shared/errors/base-error.js +0 -27
- package/dist/shared/errors/boundary.d.ts +0 -18
- package/dist/shared/errors/boundary.js +0 -46
- package/dist/shared/errors/error-code.d.ts +0 -13
- package/dist/shared/errors/errors.d.ts +0 -68
- package/dist/shared/errors/errors.js +0 -114
- package/dist/shared/errors/upstream-error.d.ts +0 -16
- package/dist/shared/errors/upstream-error.js +0 -27
- package/dist/shared/errors/wrap-error.d.ts +0 -7
- package/dist/shared/errors/wrap-error.js +0 -15
- package/dist/shared/logging/logger.d.ts +0 -18
- package/dist/shared/logging/logger.js +0 -15
- package/dist/shared/logging/redaction-walk.d.ts +0 -23
- package/dist/shared/logging/redaction-walk.js +0 -112
- package/dist/shared/logging/redaction.d.ts +0 -39
- package/dist/shared/logging/redaction.js +0 -75
- package/dist/shared/logging/secret-patterns.d.ts +0 -92
- package/dist/shared/logging/secret-patterns.js +0 -133
- package/dist/shared/options.d.ts +0 -37
- package/dist/shared/ulid.d.ts +0 -23
- package/dist/shared/validation/options.d.ts +0 -8
- package/dist/shared/validation/options.js +0 -90
- package/dist/shared/validation/primitives.d.ts +0 -29
- package/dist/shared/validation/primitives.js +0 -82
- package/dist/shared/validation/ttl.d.ts +0 -28
- package/dist/shared/validation/ttl.js +0 -52
- package/dist/store/actions/get.d.ts +0 -13
- package/dist/store/actions/get.js +0 -73
- package/dist/store/actions/list-namespaces.d.ts +0 -8
- package/dist/store/actions/list-namespaces.js +0 -59
- package/dist/store/actions/put.d.ts +0 -10
- package/dist/store/actions/put.js +0 -96
- package/dist/store/actions/reconcile-vector-index.d.ts +0 -18
- package/dist/store/actions/reconcile-vector-index.js +0 -26
- package/dist/store/actions/search.d.ts +0 -9
- package/dist/store/actions/search.js +0 -34
- package/dist/store/internal/backend-search.d.ts +0 -4
- package/dist/store/internal/backend-search.js +0 -74
- package/dist/store/internal/batch-plan.d.ts +0 -11
- package/dist/store/internal/batch-plan.js +0 -52
- package/dist/store/internal/candidates.d.ts +0 -23
- package/dist/store/internal/candidates.js +0 -94
- package/dist/store/internal/filter.d.ts +0 -9
- package/dist/store/internal/filter.js +0 -85
- package/dist/store/internal/index-reconcile.d.ts +0 -21
- package/dist/store/internal/index-reconcile.js +0 -118
- package/dist/store/internal/index-sync.d.ts +0 -10
- package/dist/store/internal/index-sync.js +0 -25
- package/dist/store/internal/item-mapper.d.ts +0 -27
- package/dist/store/internal/item-mapper.js +0 -61
- package/dist/store/internal/keys.d.ts +0 -17
- package/dist/store/internal/keys.js +0 -41
- package/dist/store/internal/namespace-match.d.ts +0 -11
- package/dist/store/internal/namespace-match.js +0 -40
- package/dist/store/internal/option-validation.d.ts +0 -13
- package/dist/store/internal/option-validation.js +0 -77
- package/dist/store/internal/overwrite-swap.d.ts +0 -32
- package/dist/store/internal/overwrite-swap.js +0 -68
- package/dist/store/internal/persist.d.ts +0 -28
- package/dist/store/internal/persist.js +0 -64
- package/dist/store/internal/query.d.ts +0 -11
- package/dist/store/internal/query.js +0 -48
- package/dist/store/internal/ranker.d.ts +0 -18
- package/dist/store/internal/ranker.js +0 -39
- package/dist/store/internal/read-existing.d.ts +0 -23
- package/dist/store/internal/read-existing.js +0 -41
- package/dist/store/internal/score-direction.d.ts +0 -31
- package/dist/store/internal/score-direction.js +0 -38
- package/dist/store/internal/search-filter.d.ts +0 -3
- package/dist/store/internal/search-filter.js +0 -10
- package/dist/store/internal/semantic-search.d.ts +0 -34
- package/dist/store/internal/semantic-search.js +0 -87
- package/dist/store/internal/setup.d.ts +0 -36
- package/dist/store/internal/setup.js +0 -40
- package/dist/store/internal/text-path.d.ts +0 -17
- package/dist/store/internal/validation.d.ts +0 -18
- package/dist/store/internal/validation.js +0 -51
- package/dist/store/internal/write-verify.d.ts +0 -42
- package/dist/store/internal/write-verify.js +0 -71
- package/dist/store/store.d.ts +0 -61
- package/dist/store/store.js +0 -107
- package/dist/store/types.d.ts +0 -50
- package/dist/store/types.js +0 -2
- package/dist/store/vector-backend.d.ts +0 -43
- package/dist/store/vector-backend.js +0 -2
- /package/dist/{checkpointer → cjs/checkpointer}/types.js +0 -0
- /package/dist/{factory → cjs/factory}/types.js +0 -0
- /package/dist/{history → cjs/history}/types.js +0 -0
- /package/dist/{shared → cjs/shared}/options.js +0 -0
- /package/dist/{shared/dynamodb → cjs/store}/types.js +0 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides which options the history and its methods accept, and how the history
|
|
3
|
+
* is assembled from them.
|
|
4
|
+
*
|
|
5
|
+
* The exhaustive key list of every option bag — the constructor's,
|
|
6
|
+
* `getMessages`', `listSessions`' — lives here, compiler-checked against its
|
|
7
|
+
* type, beside the code that resolves the constructor's options into the
|
|
8
|
+
* context every action receives.
|
|
9
|
+
*/
|
|
10
|
+
import type { SerializerProtocol } from '@langchain/langgraph-checkpoint';
|
|
11
|
+
import { type AdapterCore, type AdapterShell } from '../../shared/adapter.js';
|
|
12
|
+
import type { CorruptMessagePolicy, DynamoDBChatMessageHistoryOptions } from '../types.js';
|
|
13
|
+
/**
|
|
14
|
+
* Max attempts for the message-append transaction. It shares one session's
|
|
15
|
+
* metadata row across every concurrent `addMessages` caller on that session,
|
|
16
|
+
* so a burst of concurrent appends can collide repeatedly; combined with the
|
|
17
|
+
* existing 100ms base / 5000ms cap backoff, this keeps worst-case retrying
|
|
18
|
+
* within AWS's documented guidance to bound conflict retries to "around one
|
|
19
|
+
* minute" (see DynamoDB's "Error retries and exponential backoff" guide).
|
|
20
|
+
* This bound is exact for clients this library constructs, which disable the
|
|
21
|
+
* AWS SDK's own internal retries (`maxAttempts: 1`, see
|
|
22
|
+
* `resolveDynamoDBClient`). An injected client that keeps SDK retries stacks
|
|
23
|
+
* them inside each attempt; construction warns about that.
|
|
24
|
+
*/
|
|
25
|
+
export declare const MESSAGE_APPEND_RETRY_MAX_ATTEMPTS = 18;
|
|
26
|
+
/**
|
|
27
|
+
* The keys of each chat-history option bag, exhaustive in both directions:
|
|
28
|
+
* `allKeysOf<T>` makes omitting or inventing one a compile error, so a list
|
|
29
|
+
* cannot rot away from the type it guards. They live with the feature because
|
|
30
|
+
* the types they are checked against do; `shared/` knows no feature.
|
|
31
|
+
*/
|
|
32
|
+
export declare const HISTORY_KEYS: readonly string[];
|
|
33
|
+
/** See {@link HISTORY_KEYS}. */
|
|
34
|
+
export declare const GET_MESSAGES_KEYS: readonly string[];
|
|
35
|
+
/** See {@link HISTORY_KEYS}. */
|
|
36
|
+
export declare const LIST_SESSIONS_KEYS: readonly string[];
|
|
37
|
+
/** Resolved collaborators shared by every chat-history action. */
|
|
38
|
+
export interface HistoryContext extends AdapterCore {
|
|
39
|
+
serde: SerializerProtocol;
|
|
40
|
+
ulid: () => string;
|
|
41
|
+
onCorruptMessage: CorruptMessagePolicy;
|
|
42
|
+
}
|
|
43
|
+
/** Result of wiring up a chat-history adapter from its options. */
|
|
44
|
+
export interface HistorySetup {
|
|
45
|
+
context: HistoryContext;
|
|
46
|
+
shell: AdapterShell;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Validate the options, then resolve the client, offloader and serializer.
|
|
50
|
+
*
|
|
51
|
+
* Accepts: `options` — validated first, so no half-built adapter exists when
|
|
52
|
+
* one is wrong. `onCorruptMessage` is checked against its union here because a
|
|
53
|
+
* JavaScript caller can pass a string the type never admits, and an
|
|
54
|
+
* unrecognised policy would silently behave as `'skip'` — dropping messages a
|
|
55
|
+
* caller asked to be told about.
|
|
56
|
+
*
|
|
57
|
+
* Returns: the context every action shares, and the shell that releases what
|
|
58
|
+
* it holds — a client the caller passed in is never destroyed by `destroy()`.
|
|
59
|
+
*
|
|
60
|
+
* Throws: `VALIDATION` naming the offending option.
|
|
61
|
+
*
|
|
62
|
+
* Guarantees: constructing an adapter performs no I/O.
|
|
63
|
+
*/
|
|
64
|
+
export declare function setUpHistory(options: DynamoDBChatMessageHistoryOptions): HistorySetup;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { openAdapter } from '../../shared/adapter.js';
|
|
2
|
+
import { JSON_SERDE } from '../../shared/codec/json-serde.js';
|
|
3
|
+
import { validationError } from '../../shared/errors/errors.js';
|
|
4
|
+
import { createUlidFactory } from '../../shared/ulid.js';
|
|
5
|
+
import { allKeysOf, assertShape } from '../../shared/validation/option-shape.js';
|
|
6
|
+
export const MESSAGE_APPEND_RETRY_MAX_ATTEMPTS = 18;
|
|
7
|
+
export const HISTORY_KEYS = allKeysOf({
|
|
8
|
+
tableName: 'tableName',
|
|
9
|
+
client: 'client',
|
|
10
|
+
clientConfig: 'clientConfig',
|
|
11
|
+
createClient: 'createClient',
|
|
12
|
+
ttl: 'ttl',
|
|
13
|
+
logger: 'logger',
|
|
14
|
+
retry: 'retry',
|
|
15
|
+
indexShards: 'indexShards',
|
|
16
|
+
indexName: 'indexName',
|
|
17
|
+
readConcurrency: 'readConcurrency',
|
|
18
|
+
compression: 'compression',
|
|
19
|
+
s3: 's3',
|
|
20
|
+
serde: 'serde',
|
|
21
|
+
onCorruptMessage: 'onCorruptMessage',
|
|
22
|
+
});
|
|
23
|
+
export const GET_MESSAGES_KEYS = allKeysOf({
|
|
24
|
+
limit: 'limit',
|
|
25
|
+
before: 'before',
|
|
26
|
+
signal: 'signal',
|
|
27
|
+
});
|
|
28
|
+
export const LIST_SESSIONS_KEYS = allKeysOf({
|
|
29
|
+
limit: 'limit',
|
|
30
|
+
cursor: 'cursor',
|
|
31
|
+
maxIterations: 'maxIterations',
|
|
32
|
+
maxItems: 'maxItems',
|
|
33
|
+
signal: 'signal',
|
|
34
|
+
});
|
|
35
|
+
const CORRUPT_MESSAGE_POLICIES = ['skip', 'throw'];
|
|
36
|
+
function assertCorruptMessagePolicy(policy) {
|
|
37
|
+
if (policy !== undefined && !CORRUPT_MESSAGE_POLICIES.includes(policy)) {
|
|
38
|
+
throw validationError(`onCorruptMessage must be one of ${CORRUPT_MESSAGE_POLICIES.join(' | ')}`, 'onCorruptMessage');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
export function setUpHistory(options) {
|
|
42
|
+
assertShape(options, HISTORY_KEYS, 'options');
|
|
43
|
+
const shell = openAdapter(options, 'history', {
|
|
44
|
+
options: () => assertCorruptMessagePolicy(options.onCorruptMessage),
|
|
45
|
+
attemptFloor: MESSAGE_APPEND_RETRY_MAX_ATTEMPTS,
|
|
46
|
+
});
|
|
47
|
+
return {
|
|
48
|
+
shell,
|
|
49
|
+
context: {
|
|
50
|
+
...shell.core,
|
|
51
|
+
serde: options.serde ?? JSON_SERDE,
|
|
52
|
+
ulid: createUlidFactory(),
|
|
53
|
+
onCorruptMessage: options.onCorruptMessage ?? 'skip',
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides a multi-session history behind LangChain's single-session interface.
|
|
3
|
+
*
|
|
4
|
+
* `RunnableWithMessageHistory` wants a history bound to one conversation and
|
|
5
|
+
* calls it with no session id. This view fixes the session and the read window
|
|
6
|
+
* at construction, validates both there, and forwards each call to the
|
|
7
|
+
* multi-session history it wraps, through the same error boundary. The window
|
|
8
|
+
* bounds what a chain reads, never what is written or cleared.
|
|
9
|
+
*/
|
|
10
|
+
import { BaseListChatMessageHistory } from '@langchain/core/chat_history';
|
|
11
|
+
import type { BaseMessage } from '@langchain/core/messages';
|
|
12
|
+
/** The read window an adapter applies to every `getMessages`. */
|
|
13
|
+
export type AdapterWindow = {
|
|
14
|
+
limit?: number;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A history holding many sessions, addressed by session id: what a
|
|
18
|
+
* single-session adapter wraps. `DynamoDBChatMessageHistory` is one.
|
|
19
|
+
*/
|
|
20
|
+
export interface MultiSessionHistory {
|
|
21
|
+
getMessages(sessionId: string, window?: AdapterWindow): Promise<BaseMessage[]>;
|
|
22
|
+
addMessages(sessionId: string, messages: BaseMessage[]): Promise<void>;
|
|
23
|
+
clear(sessionId: string): Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Single-session view over a {@link MultiSessionHistory}, implementing LangChain's
|
|
27
|
+
* `BaseListChatMessageHistory` so it can drive `RunnableWithMessageHistory`.
|
|
28
|
+
* A `window` bounds what every read hands the chain — `{ limit: 50 }` feeds it
|
|
29
|
+
* the newest fifty messages instead of the whole session.
|
|
30
|
+
*/
|
|
31
|
+
export declare class DynamoDBSessionChatMessageHistory extends BaseListChatMessageHistory {
|
|
32
|
+
private readonly backend;
|
|
33
|
+
lc_namespace: string[];
|
|
34
|
+
private readonly sessionId;
|
|
35
|
+
private readonly window;
|
|
36
|
+
/**
|
|
37
|
+
* Accepts: `backend` — the multi-session adapter this view delegates to,
|
|
38
|
+
* checked structurally for {@link MultiSessionHistory}'s own members. `sessionId`
|
|
39
|
+
* — the one session it is bound to, validated the same way every other
|
|
40
|
+
* adapter method validates a session id. `window` — bounds every read it
|
|
41
|
+
* performs; when given, only the `limit` key `AdapterWindow` declares, an
|
|
42
|
+
* integer from 1 to the package's page ceiling. `0` is refused: this window
|
|
43
|
+
* is what `RunnableWithMessageHistory` reads on every invocation, and an
|
|
44
|
+
* empty one is indistinguishable from a conversation that never happened.
|
|
45
|
+
*
|
|
46
|
+
* Returns: the view. Normally built through
|
|
47
|
+
* `DynamoDBChatMessageHistory.forSession`, which is the supported route.
|
|
48
|
+
* The adapter keeps the window it parsed, not the caller's object, so
|
|
49
|
+
* changing that object afterwards changes nothing.
|
|
50
|
+
*
|
|
51
|
+
* Throws: `VALIDATION` naming `backend`, `backend.<member>` for the first
|
|
52
|
+
* missing method, `sessionId`, `window` for a window that is not an object,
|
|
53
|
+
* `window.<key>` for a key `AdapterWindow` does not declare, or `limit`. Checking here reports a caller's mistake at
|
|
54
|
+
* construction instead of rebranding it as an upstream failure on first use.
|
|
55
|
+
*/
|
|
56
|
+
constructor(backend: MultiSessionHistory, sessionId: string, window?: AdapterWindow);
|
|
57
|
+
/**
|
|
58
|
+
* This session's messages in chronological order.
|
|
59
|
+
*
|
|
60
|
+
* Accepts: nothing — the session and the window are fixed at construction,
|
|
61
|
+
* which is what `BaseListChatMessageHistory` requires.
|
|
62
|
+
*
|
|
63
|
+
* Returns: the messages, bounded by the adapter's window. LangChain calls
|
|
64
|
+
* this on every chain invocation, so the window is what keeps a long session
|
|
65
|
+
* from growing the prompt without limit.
|
|
66
|
+
*
|
|
67
|
+
* Throws: whatever the backend's `getMessages` throws, wrapped with
|
|
68
|
+
* the code the classifier assigns unless it is already one of this library's
|
|
69
|
+
* own errors.
|
|
70
|
+
*/
|
|
71
|
+
getMessages(): Promise<BaseMessage[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Append one message to this session.
|
|
74
|
+
*
|
|
75
|
+
* Accepts: `message` — a LangChain message.
|
|
76
|
+
*
|
|
77
|
+
* Returns: nothing.
|
|
78
|
+
*
|
|
79
|
+
* Throws: as {@link addMessages}.
|
|
80
|
+
*/
|
|
81
|
+
addMessage(message: BaseMessage): Promise<void>;
|
|
82
|
+
/**
|
|
83
|
+
* Append messages to this session.
|
|
84
|
+
*
|
|
85
|
+
* Accepts: `messages` — LangChain messages; an empty list writes nothing.
|
|
86
|
+
*
|
|
87
|
+
* Returns: nothing, and only once every message has landed.
|
|
88
|
+
*
|
|
89
|
+
* Throws: whatever the backend's `addMessages` throws, wrapped with
|
|
90
|
+
* the code the classifier assigns unless it is already one of this library's
|
|
91
|
+
* own errors.
|
|
92
|
+
*
|
|
93
|
+
* Guarantees: the window bounds what is *read*, never what is written — the
|
|
94
|
+
* session keeps every message appended to it.
|
|
95
|
+
*/
|
|
96
|
+
addMessages(messages: BaseMessage[]): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Delete this session's messages, metadata and offloaded objects.
|
|
99
|
+
*
|
|
100
|
+
* Accepts: nothing.
|
|
101
|
+
*
|
|
102
|
+
* Returns: nothing. Clearing a session that does not exist is not an error.
|
|
103
|
+
*
|
|
104
|
+
* Throws: whatever the backend's `clear` throws, wrapped with the code the
|
|
105
|
+
* classifier assigns unless it is already one of this library's own errors.
|
|
106
|
+
*
|
|
107
|
+
* Guarantees: the whole session goes, not the window.
|
|
108
|
+
* `BaseListChatMessageHistory` declares `clear()`, and a chain that calls it
|
|
109
|
+
* is asking for exactly that.
|
|
110
|
+
*/
|
|
111
|
+
clear(): Promise<void>;
|
|
112
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { BaseListChatMessageHistory } from '@langchain/core/chat_history';
|
|
2
|
+
import { guardPublic } from '../shared/errors/boundary.js';
|
|
3
|
+
import { assertMembers } from '../shared/validation/collaborators.js';
|
|
4
|
+
import { allKeysOf, assertShape } from '../shared/validation/option-shape.js';
|
|
5
|
+
import { parseMessageWindow, parseSessionId, } from './internal/parse.js';
|
|
6
|
+
const ADAPTER_WINDOW_KEYS = allKeysOf({ limit: 'limit' });
|
|
7
|
+
const MULTI_SESSION_HISTORY_MEMBERS = ['getMessages', 'addMessages', 'clear'];
|
|
8
|
+
export class DynamoDBSessionChatMessageHistory extends BaseListChatMessageHistory {
|
|
9
|
+
backend;
|
|
10
|
+
lc_namespace = ['langchain', 'stores', 'message', 'dynamodb'];
|
|
11
|
+
sessionId;
|
|
12
|
+
window;
|
|
13
|
+
constructor(backend, sessionId, window) {
|
|
14
|
+
super();
|
|
15
|
+
this.backend = backend;
|
|
16
|
+
assertMembers(backend, MULTI_SESSION_HISTORY_MEMBERS, 'backend');
|
|
17
|
+
this.sessionId = parseSessionId(sessionId);
|
|
18
|
+
if (window !== undefined)
|
|
19
|
+
assertShape(window, ADAPTER_WINDOW_KEYS, 'window');
|
|
20
|
+
this.window = window === undefined ? undefined : parseMessageWindow(window);
|
|
21
|
+
}
|
|
22
|
+
getMessages() {
|
|
23
|
+
return guardPublic('session.getMessages', () => this.backend.getMessages(this.sessionId, this.window));
|
|
24
|
+
}
|
|
25
|
+
addMessage(message) {
|
|
26
|
+
return guardPublic('session.addMessage', () => this.backend.addMessages(this.sessionId, [message]));
|
|
27
|
+
}
|
|
28
|
+
addMessages(messages) {
|
|
29
|
+
return guardPublic('session.addMessages', () => this.backend.addMessages(this.sessionId, messages));
|
|
30
|
+
}
|
|
31
|
+
clear() {
|
|
32
|
+
return guardPublic('session.clear', () => this.backend.clear(this.sessionId));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides the history's implementation from the types a caller names.
|
|
3
|
+
*
|
|
4
|
+
* Every option and result of the multi-session history's reads, writes and
|
|
5
|
+
* listings is declared here, with no run-time code, so a caller can type
|
|
6
|
+
* what it builds without importing an action, a parser or a row module. The
|
|
7
|
+
* parsed forms the actions work from belong to the parser and the row
|
|
8
|
+
* shapes to the modules that own them, so either can change without moving
|
|
9
|
+
* a published type.
|
|
10
|
+
*/
|
|
11
|
+
import type { SerializerProtocol } from '@langchain/langgraph-checkpoint';
|
|
12
|
+
import type { BaseAdapterOptions, CancelOptions, CodecOptions } from '../shared/options.js';
|
|
13
|
+
/** Options for {@link DynamoDBChatMessageHistory}. */
|
|
14
|
+
export type DynamoDBChatMessageHistoryOptions = BaseAdapterOptions & CodecOptions & {
|
|
15
|
+
/**
|
|
16
|
+
* Optional serializer override. The default is the exported `JSON_SERDE`,
|
|
17
|
+
* plain JSON: what it stores is the JSON projection of a value, and the
|
|
18
|
+
* README's *Table schema* section tabulates where that differs from the
|
|
19
|
+
* value itself.
|
|
20
|
+
*/
|
|
21
|
+
serde?: SerializerProtocol;
|
|
22
|
+
/**
|
|
23
|
+
* What `getMessages` does when a stored message cannot be decoded. It
|
|
24
|
+
* covers a payload nobody can read — bytes that are no longer the form
|
|
25
|
+
* the row declares, a gone S3 object, a descriptor that is not one — and
|
|
26
|
+
* a stored message LangChain cannot rebuild. It does not govern a
|
|
27
|
+
* payload larger than this reader's `compression.maxDecompressedBytes`
|
|
28
|
+
* or `s3.maxDownloadBytes` (a limit of this reader's, not a lost
|
|
29
|
+
* payload), nor a serializer declining intact bytes: a `serdeType` the
|
|
30
|
+
* configured serializer has no grammar for after a config change, like
|
|
31
|
+
* an `lc` record naming a class outside its allow-list, is reported
|
|
32
|
+
* under **both** policies, because a payload this reader merely may not
|
|
33
|
+
* rebuild is not a payload that is gone. `'skip'` (the default) drops
|
|
34
|
+
* the item, logs it at `error` with its sort key so an operator can
|
|
35
|
+
* locate it, and returns the rest; `'throw'` fails the whole read, which
|
|
36
|
+
* is all-or-nothing but leaves the session unreadable until the bad row
|
|
37
|
+
* is removed out of band.
|
|
38
|
+
*/
|
|
39
|
+
onCorruptMessage?: CorruptMessagePolicy;
|
|
40
|
+
};
|
|
41
|
+
/** How `getMessages` handles an item it cannot decode. */
|
|
42
|
+
export type CorruptMessagePolicy = 'skip' | 'throw';
|
|
43
|
+
/**
|
|
44
|
+
* Which slice of a session `getMessages` returns. Both bounds are optional
|
|
45
|
+
* and combine: `{ limit: 50, before }` is the fifty messages just before
|
|
46
|
+
* `before`.
|
|
47
|
+
*/
|
|
48
|
+
export interface MessageWindow {
|
|
49
|
+
/**
|
|
50
|
+
* Return only the newest `limit` messages — still in chronological order. An
|
|
51
|
+
* integer from 1 to 10,000: the page rule every `limit` in
|
|
52
|
+
* this package follows, with the one floor of 1 it has. `0` is refused rather
|
|
53
|
+
* than answered with nothing, since for a window into a conversation it is
|
|
54
|
+
* far more likely a bug than a request — and the empty window it would
|
|
55
|
+
* produce is what a chain reads as the whole session.
|
|
56
|
+
*/
|
|
57
|
+
limit?: number;
|
|
58
|
+
/** Return only messages appended before this instant (millisecond precision). */
|
|
59
|
+
before?: Date;
|
|
60
|
+
}
|
|
61
|
+
/** Options for `getMessages`: the read window plus cancellation. */
|
|
62
|
+
export type GetMessagesOptions = MessageWindow & CancelOptions;
|
|
63
|
+
/** Options for `listSessions`: the page, the scan caps, and cancellation. */
|
|
64
|
+
export interface ListSessionsOptions extends CancelOptions {
|
|
65
|
+
/**
|
|
66
|
+
* How many sessions to return, newest-updated first; an integer from 0 to
|
|
67
|
+
* 10,000.
|
|
68
|
+
*
|
|
69
|
+
* With a configured `indexName` it is the page size and defaults to 100.
|
|
70
|
+
* Without one the read is a table scan that cannot be paged: an explicit
|
|
71
|
+
* limit still selects the newest N, but omitting it returns every session,
|
|
72
|
+
* because there would be no cursor to fetch the rest with. `0` returns an
|
|
73
|
+
* empty page on either path and reads neither.
|
|
74
|
+
*/
|
|
75
|
+
limit?: number;
|
|
76
|
+
/**
|
|
77
|
+
* Opaque cursor from a previous page. Requires a configured `indexName` —
|
|
78
|
+
* without the index there is no position to resume from, and passing one is
|
|
79
|
+
* refused rather than answered with the first page again.
|
|
80
|
+
*/
|
|
81
|
+
cursor?: string;
|
|
82
|
+
/** Cap on scan pages before `RESULT_TRUNCATED` (default 1000). Scan path only. */
|
|
83
|
+
maxIterations?: number;
|
|
84
|
+
/** Cap on rows read into memory before `RESULT_TRUNCATED` (default 10 000). Scan path only. */
|
|
85
|
+
maxItems?: number;
|
|
86
|
+
}
|
|
87
|
+
/** One page of {@link SessionMetadata}, and where the next one resumes. */
|
|
88
|
+
export interface SessionPage {
|
|
89
|
+
sessions: SessionMetadata[];
|
|
90
|
+
/** Absent when this page is the last one, or when the read was a scan. */
|
|
91
|
+
nextCursor?: string;
|
|
92
|
+
}
|
|
93
|
+
/** Summary of a stored chat session. */
|
|
94
|
+
export interface SessionMetadata {
|
|
95
|
+
sessionId: string;
|
|
96
|
+
title?: string;
|
|
97
|
+
messageCount: number;
|
|
98
|
+
createdAt: string;
|
|
99
|
+
updatedAt: string;
|
|
100
|
+
/** When the session's TTL expires, as an ISO-8601 instant; absent when no TTL is stored. */
|
|
101
|
+
expiresAt?: string;
|
|
102
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AWS DynamoDB implementation of LangGraph's checkpoint saver, memory store
|
|
3
|
+
* and chat message history, in TypeScript.
|
|
4
|
+
*
|
|
5
|
+
* Hides where anything lives.
|
|
6
|
+
*
|
|
7
|
+
* This module re-exports and declares nothing of its own, so which module
|
|
8
|
+
* holds an adapter, the factory, the error class, the serializer or a
|
|
9
|
+
* collaborator type is free to change without moving anything a caller
|
|
10
|
+
* imports. What appears here is the whole supported surface; the package's
|
|
11
|
+
* exports map admits no deep import, so nothing else is reachable.
|
|
12
|
+
*
|
|
13
|
+
* @packageDocumentation
|
|
14
|
+
*/
|
|
15
|
+
export { DynamoDBSaver } from './checkpointer/saver.js';
|
|
16
|
+
export type { DeltaChannelHistoryOptions, DynamoDBSaverOptions } from './checkpointer/types.js';
|
|
17
|
+
export { DynamoDBStore } from './store/store.js';
|
|
18
|
+
export type { DynamoDBStoreOptions, ListNamespacesOptions, SearchOptions, VectorReconcileResult, } from './store/types.js';
|
|
19
|
+
export type { VectorBackend, VectorMatch, VectorRef, VectorScoreDirection, } from './store/vector-backend.js';
|
|
20
|
+
export { DynamoDBChatMessageHistory } from './history/chat-message-history.js';
|
|
21
|
+
export { DynamoDBSessionChatMessageHistory } from './history/session-adapter.js';
|
|
22
|
+
export type { AdapterWindow, MultiSessionHistory } from './history/session-adapter.js';
|
|
23
|
+
export type { CorruptMessagePolicy, DynamoDBChatMessageHistoryOptions, GetMessagesOptions, ListSessionsOptions, SessionPage, MessageWindow, SessionMetadata, } from './history/types.js';
|
|
24
|
+
/**
|
|
25
|
+
* Operator tool: give rows written before the recency index their index keys.
|
|
26
|
+
* Run it before setting `indexName` on any adapter — see its own documentation
|
|
27
|
+
* for why enabling the index first hides pre-existing rows from the listings.
|
|
28
|
+
*/
|
|
29
|
+
export { backfillRecencyIndex } from './backfill/backfill.js';
|
|
30
|
+
export type { BackfillOptions, BackfillResult } from './backfill/backfill.js';
|
|
31
|
+
export { DynamoDBFactory } from './factory/factory.js';
|
|
32
|
+
export type { AdapterSection, CreateAllOptions, CreatedAdapters, FactoryBaseOptions, } from './factory/types.js';
|
|
33
|
+
/**
|
|
34
|
+
* The plain JSON serializer the store and chat-history adapters use by
|
|
35
|
+
* default, exported so a checkpointer can be given it in place of LangGraph's
|
|
36
|
+
* `JsonPlusSerializer`, whose read path instantiates the class a stored
|
|
37
|
+
* `{"lc": …}` record names. See the README's *Trust boundary* note and
|
|
38
|
+
* `SECURITY.md`.
|
|
39
|
+
*/
|
|
40
|
+
export { JSON_SERDE } from './shared/codec/json-serde.js';
|
|
41
|
+
export { DynamoDBLangGraphError, isDynamoDBLangGraphError } from './shared/errors/base-error.js';
|
|
42
|
+
export type { AnyDynamoDBLangGraphError, BatchDrainDetails, BatchPassDetails, BatchWriteIncompleteDetails, CompensationFailedDetails, ErrorContext, ErrorDetailsByCode, ErrorDetailsFor, } from './shared/errors/base-error.js';
|
|
43
|
+
export { ErrorCode } from './shared/errors/error-code.js';
|
|
44
|
+
export type { Logger, LogArgument } from './shared/logging/logger.js';
|
|
45
|
+
export { redactLogger, redactSecrets } from './shared/logging/redaction.js';
|
|
46
|
+
export type { Redactable, RedactLoggerOptions } from './shared/logging/redaction.js';
|
|
47
|
+
export type { CancelOptions, BaseAdapterOptions, CodecOptions } from './shared/options.js';
|
|
48
|
+
export type { DynamoDBDocumentLike, WriteRequest } from './shared/dynamodb/client.js';
|
|
49
|
+
export type { RetryAttemptInfo, RetryOptions, RetryPolicy } from './shared/dynamodb/retry.js';
|
|
50
|
+
export type { TtlOption } from './shared/validation/ttl.js';
|
|
51
|
+
export type { CompressionConfig } from './shared/codec/compression.js';
|
|
52
|
+
export type { S3OffloadConfig } from './shared/codec/s3/config.js';
|
|
53
|
+
export type { S3ClientConfigLike, S3ClientOption, S3ClientOptions, S3RegionLike, } from './shared/codec/s3/client-types.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { DynamoDBSaver } from './checkpointer/saver.js';
|
|
2
|
+
export { DynamoDBStore } from './store/store.js';
|
|
3
|
+
export { DynamoDBChatMessageHistory } from './history/chat-message-history.js';
|
|
4
|
+
export { DynamoDBSessionChatMessageHistory } from './history/session-adapter.js';
|
|
5
|
+
export { backfillRecencyIndex } from './backfill/backfill.js';
|
|
6
|
+
export { DynamoDBFactory } from './factory/factory.js';
|
|
7
|
+
export { JSON_SERDE } from './shared/codec/json-serde.js';
|
|
8
|
+
export { DynamoDBLangGraphError, isDynamoDBLangGraphError } from './shared/errors/base-error.js';
|
|
9
|
+
export { ErrorCode } from './shared/errors/error-code.js';
|
|
10
|
+
export { redactLogger, redactSecrets } from './shared/logging/redaction.js';
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides what an adapter owns for its lifetime, and how it lets go of it.
|
|
3
|
+
*
|
|
4
|
+
* Every adapter resolves the same things from its options — a DynamoDB client
|
|
5
|
+
* it either built, and so must destroy, or was handed, and so must not; an S3
|
|
6
|
+
* offloader when it offloads; a logger; a retry policy; the recency index's
|
|
7
|
+
* settings — releases them the same way, and provisions the same lifecycle
|
|
8
|
+
* rule from its ttl. Whether an adapter owns its client is decided in
|
|
9
|
+
* `dynamodb/client.ts`; this module only reads that decision, to release a
|
|
10
|
+
* client it built and leave an injected one alone.
|
|
11
|
+
*/
|
|
12
|
+
import type { CompressionConfig } from './codec/compression.js';
|
|
13
|
+
import { type AdapterName } from './codec/s3/config.js';
|
|
14
|
+
import { S3Offloader } from './codec/s3/offloader.js';
|
|
15
|
+
import { type DynamoDBDocumentLike } from './dynamodb/client.js';
|
|
16
|
+
import { type RetryOptions } from './dynamodb/retry.js';
|
|
17
|
+
import { type Logger } from './logging/logger.js';
|
|
18
|
+
import type { BaseAdapterOptions, CodecOptions } from './options.js';
|
|
19
|
+
import { type TtlOption } from './validation/ttl.js';
|
|
20
|
+
/** Anything an adapter holds open and must hand back when it is torn down. */
|
|
21
|
+
export interface Releasable {
|
|
22
|
+
destroy(): void;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Release every resource, whatever any one of them does.
|
|
26
|
+
*
|
|
27
|
+
* The hazard is the one `DynamoDBFactory`'s own `release` names: a teardown
|
|
28
|
+
* written as a sequence of statements stops at the first throw, so everything
|
|
29
|
+
* after it is stranded with no reference left to reach it by. An adapter's
|
|
30
|
+
* teardown is such a sequence — the S3 offloader, then the DynamoDB client it
|
|
31
|
+
* built — and an S3 client whose sockets are already gone throws from its own
|
|
32
|
+
* `destroy`, which would leave the DynamoDB client open for the life of the
|
|
33
|
+
* process. Each resource is therefore released whatever the ones before it
|
|
34
|
+
* threw.
|
|
35
|
+
*
|
|
36
|
+
* Accepts: `resources` — in the order they should be released; an absent one
|
|
37
|
+
* (an adapter with no offloader, a client the caller injected and therefore
|
|
38
|
+
* owns) is skipped rather than guarded at each call site.
|
|
39
|
+
*
|
|
40
|
+
* Returns: nothing.
|
|
41
|
+
*
|
|
42
|
+
* Throws: the **first** failure, and only after every resource has been
|
|
43
|
+
* offered its release, so nothing is stranded behind it. Raised rather than
|
|
44
|
+
* logged because the default logger discards everything: a caller who never
|
|
45
|
+
* configured one would otherwise be told nowhere at all that a client of theirs
|
|
46
|
+
* is still holding sockets. A later failure is dropped, because a caller can
|
|
47
|
+
* act on one report and the first one names the resource that actually broke.
|
|
48
|
+
* A `throw` that produced something other than an `Error` is normalised, so a
|
|
49
|
+
* caller's `catch` is handed the same shape whatever a client raised.
|
|
50
|
+
*/
|
|
51
|
+
export declare function releaseOwned(resources: readonly (Releasable | undefined)[]): void;
|
|
52
|
+
/** What every adapter resolves from its options and every operation reads. */
|
|
53
|
+
export interface AdapterCore {
|
|
54
|
+
client: DynamoDBDocumentLike;
|
|
55
|
+
tableName: string;
|
|
56
|
+
compression?: CompressionConfig;
|
|
57
|
+
offloader?: S3Offloader;
|
|
58
|
+
ttl?: TtlOption;
|
|
59
|
+
logger: Logger;
|
|
60
|
+
/** Retry budget and backoff for every DynamoDB call, with the retry debug log attached. */
|
|
61
|
+
retry?: RetryOptions;
|
|
62
|
+
/**
|
|
63
|
+
* Index partitions per adapter for the recency index; see `indexKeys`.
|
|
64
|
+
* Absent means the default, which is where it is resolved.
|
|
65
|
+
*/
|
|
66
|
+
indexShards?: number;
|
|
67
|
+
/** Payloads decoded at once by one call; the memory ceiling’s multiplier. */
|
|
68
|
+
readConcurrency?: number;
|
|
69
|
+
/** Name of the recency index, when the table carries one; see `BaseAdapterOptions.indexName`. */
|
|
70
|
+
indexName?: string;
|
|
71
|
+
}
|
|
72
|
+
/** An adapter's hold on what it owns. */
|
|
73
|
+
export interface AdapterShell {
|
|
74
|
+
readonly core: AdapterCore;
|
|
75
|
+
/** Provision the S3 lifecycle rule for the configured ttl; see {@link ensureLifecycleFor}. */
|
|
76
|
+
ensureLifecycleRule(): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Release the offloader, and the DynamoDB client when the adapter built it;
|
|
79
|
+
* see {@link releaseOwned}. `release` runs once; a later call does nothing.
|
|
80
|
+
*/
|
|
81
|
+
release(): void;
|
|
82
|
+
}
|
|
83
|
+
/** The checks an adapter adds to the shared ones, and where they run. */
|
|
84
|
+
export interface AdapterChecks {
|
|
85
|
+
/** Runs after the shared option checks and before the collaborator checks. */
|
|
86
|
+
options?: () => void;
|
|
87
|
+
/** Runs after the shared collaborator checks, before anything is built. */
|
|
88
|
+
collaborators?: () => void;
|
|
89
|
+
/** The fewest attempts the adapter's own writes need; see `resolveRetryPolicy`. */
|
|
90
|
+
attemptFloor?: number;
|
|
91
|
+
}
|
|
92
|
+
/** The options every adapter takes, with the serializer each may add. */
|
|
93
|
+
export type AdapterOptions = BaseAdapterOptions & CodecOptions & {
|
|
94
|
+
serde?: object;
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Provision the S3 lifecycle rule that expires what an adapter offloads, on its
|
|
98
|
+
* ttl, so an offloaded payload does not outlive the DynamoDB item that points
|
|
99
|
+
* at it.
|
|
100
|
+
*
|
|
101
|
+
* The rule is expressed in whole days because that is the only granularity S3
|
|
102
|
+
* lifecycle expiration accepts, while the DynamoDB TTL is in seconds; see
|
|
103
|
+
* `lifecycleExpirationDays` for the rounding, which is always up.
|
|
104
|
+
*
|
|
105
|
+
* Accepts: `core` — the adapter's offloader, ttl and logger.
|
|
106
|
+
*
|
|
107
|
+
* Returns: nothing. Without an offloader there is nothing to rule over, and
|
|
108
|
+
* without a ttl no item expires, so any rule would delete a payload a live row
|
|
109
|
+
* still needs: either absence does nothing. Installing a rule that is already
|
|
110
|
+
* there is a no-op too, so calling this on every deploy is safe. When it
|
|
111
|
+
* writes the rules but cannot confirm within its polling window that a
|
|
112
|
+
* re-read shows them — S3 documents that a lifecycle configuration can take
|
|
113
|
+
* minutes to propagate — it logs a `warn` and returns rather than throwing:
|
|
114
|
+
* the rules were written, and a later call can confirm them.
|
|
115
|
+
*
|
|
116
|
+
* Throws: whatever reading or writing the bucket's lifecycle configuration
|
|
117
|
+
* throws, `VALIDATION` naming `s3.keyPrefix` when the rule id this prefix
|
|
118
|
+
* would take is already held by a different prefix, and `CONTENTION` when
|
|
119
|
+
* every one of the five rounds this call polls needs a write — a competing
|
|
120
|
+
* writer replacing the configuration on every single re-read.
|
|
121
|
+
*
|
|
122
|
+
* Guarantees: needs the bucket-level `s3:GetLifecycleConfiguration` /
|
|
123
|
+
* `s3:PutLifecycleConfiguration` permissions, which are broader than the
|
|
124
|
+
* object-level CRUD the rest of offload uses — so this is a provisioning call,
|
|
125
|
+
* not a per-request one.
|
|
126
|
+
*/
|
|
127
|
+
export declare function ensureLifecycleFor(core: Pick<AdapterCore, 'offloader' | 'ttl' | 'logger'>): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Check an adapter's options and resolve what it will own.
|
|
130
|
+
*
|
|
131
|
+
* Accepts: `options` — the adapter's, already held to its own key list, and
|
|
132
|
+
* checked first, so no half-built adapter exists when one is wrong.
|
|
133
|
+
* `adapter` — which adapter, which names its default S3 key prefix. `checks` —
|
|
134
|
+
* the adapter's own option and collaborator checks, and its retry floor.
|
|
135
|
+
*
|
|
136
|
+
* Returns: the shell: the core every operation reads, with every shared
|
|
137
|
+
* default filled in here and nowhere else, and the adapter's two lifetime
|
|
138
|
+
* operations. A client the caller passed in is never destroyed by `release`.
|
|
139
|
+
*
|
|
140
|
+
* Throws: `VALIDATION` for an option or a collaborator that fails a shared
|
|
141
|
+
* check or one of `checks`, in that order.
|
|
142
|
+
*
|
|
143
|
+
* Guarantees: no I/O. The stacked-retry check is deliberately not awaited: it
|
|
144
|
+
* is a warning about a caller-supplied client, not a precondition.
|
|
145
|
+
*/
|
|
146
|
+
export declare function openAdapter(options: AdapterOptions, adapter: AdapterName, checks?: AdapterChecks): AdapterShell;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { offloaderConfigFor } from './codec/s3/config.js';
|
|
2
|
+
import { S3Offloader } from './codec/s3/offloader.js';
|
|
3
|
+
import { DEFAULT_READ_CONCURRENCY } from './concurrency.js';
|
|
4
|
+
import { resolveDynamoDBClient, warnOnStackedRetries, } from './dynamodb/client.js';
|
|
5
|
+
import { DEFAULT_INDEX_SHARDS } from './dynamodb/recency-index.js';
|
|
6
|
+
import { resolveRetryPolicy } from './dynamodb/retry.js';
|
|
7
|
+
import { toError } from './errors/base-error.js';
|
|
8
|
+
import { resolveLogger } from './logging/logger.js';
|
|
9
|
+
import { assertBaseCollaborators } from './validation/collaborators.js';
|
|
10
|
+
import { assertBaseAdapterOptions } from './validation/options.js';
|
|
11
|
+
import { lifecycleExpirationDays } from './validation/ttl.js';
|
|
12
|
+
export function releaseOwned(resources) {
|
|
13
|
+
let first;
|
|
14
|
+
for (const resource of resources) {
|
|
15
|
+
try {
|
|
16
|
+
resource?.destroy();
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
first ??= toError(error);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (first !== undefined)
|
|
23
|
+
throw first;
|
|
24
|
+
}
|
|
25
|
+
export async function ensureLifecycleFor(core) {
|
|
26
|
+
if (!core.offloader || !core.ttl)
|
|
27
|
+
return;
|
|
28
|
+
await core.offloader.ensureLifecycleRule(lifecycleExpirationDays(core.ttl), core.logger);
|
|
29
|
+
}
|
|
30
|
+
export function openAdapter(options, adapter, checks = {}) {
|
|
31
|
+
assertBaseAdapterOptions(options);
|
|
32
|
+
checks.options?.();
|
|
33
|
+
assertBaseCollaborators(options);
|
|
34
|
+
checks.collaborators?.();
|
|
35
|
+
const logger = resolveLogger(options.logger);
|
|
36
|
+
const resolved = resolveDynamoDBClient(options);
|
|
37
|
+
if (!resolved.ownsClient)
|
|
38
|
+
void warnOnStackedRetries(resolved.client, logger);
|
|
39
|
+
const offloader = options.s3
|
|
40
|
+
? new S3Offloader(offloaderConfigFor(options.s3, adapter, options.clientConfig), logger)
|
|
41
|
+
: undefined;
|
|
42
|
+
const core = {
|
|
43
|
+
client: resolved.client,
|
|
44
|
+
tableName: options.tableName,
|
|
45
|
+
compression: options.compression,
|
|
46
|
+
offloader,
|
|
47
|
+
ttl: options.ttl,
|
|
48
|
+
logger,
|
|
49
|
+
retry: resolveRetryPolicy(options.retry, logger, checks.attemptFloor),
|
|
50
|
+
indexShards: options.indexShards ?? DEFAULT_INDEX_SHARDS,
|
|
51
|
+
readConcurrency: options.readConcurrency ?? DEFAULT_READ_CONCURRENCY,
|
|
52
|
+
indexName: options.indexName,
|
|
53
|
+
};
|
|
54
|
+
let released = false;
|
|
55
|
+
return {
|
|
56
|
+
core,
|
|
57
|
+
ensureLifecycleRule: () => ensureLifecycleFor(core),
|
|
58
|
+
release: () => {
|
|
59
|
+
if (released)
|
|
60
|
+
return;
|
|
61
|
+
released = true;
|
|
62
|
+
releaseOwned([offloader, resolved.ownsClient ? resolved.ddbClient : undefined]);
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|