@farukada/aws-langgraph-dynamodb-ts 1.0.0-rc.2 → 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 +390 -193
- package/dist/{backfill → cjs/backfill}/backfill.d.ts +15 -12
- package/dist/cjs/backfill/backfill.js +177 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/delete-thread.d.ts +1 -1
- package/dist/cjs/checkpointer/actions/delete-thread.js +26 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/get-tuple.d.ts +4 -3
- package/dist/cjs/checkpointer/actions/get-tuple.js +22 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/list.d.ts +7 -4
- package/dist/cjs/checkpointer/actions/list.js +70 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/put-writes.d.ts +8 -6
- package/dist/cjs/checkpointer/actions/put-writes.js +21 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/put.d.ts +21 -15
- package/dist/cjs/checkpointer/actions/put.js +79 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/delta-history.d.ts +38 -26
- package/dist/cjs/checkpointer/internal/delta-history.js +131 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/listing.d.ts +4 -4
- package/dist/cjs/checkpointer/internal/listing.js +104 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/parse.d.ts +51 -15
- package/dist/cjs/checkpointer/internal/parse.js +184 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/pending-writes.d.ts +64 -25
- package/dist/cjs/checkpointer/internal/pending-writes.js +241 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/read.d.ts +15 -10
- package/dist/cjs/checkpointer/internal/read.js +132 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/rows.d.ts +94 -21
- package/dist/cjs/checkpointer/internal/rows.js +356 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/setup.d.ts +13 -20
- package/dist/cjs/checkpointer/internal/setup.js +25 -0
- package/dist/{checkpointer → cjs/checkpointer}/saver.d.ts +72 -36
- package/dist/cjs/checkpointer/saver.js +56 -0
- package/dist/{checkpointer → cjs/checkpointer}/types.d.ts +1 -1
- package/dist/cjs/checkpointer/types.js +2 -0
- package/dist/{factory → cjs/factory}/factory.d.ts +25 -20
- package/dist/cjs/factory/factory.js +137 -0
- package/dist/{factory → cjs/factory}/types.d.ts +12 -12
- package/dist/cjs/factory/types.js +2 -0
- package/dist/{history → cjs/history}/actions/add-messages.d.ts +18 -10
- package/dist/cjs/history/actions/add-messages.js +17 -0
- package/dist/{history → cjs/history}/actions/clear.d.ts +1 -1
- package/dist/cjs/history/actions/clear.js +29 -0
- package/dist/{history → cjs/history}/actions/get-messages.d.ts +11 -9
- package/dist/cjs/history/actions/get-messages.js +58 -0
- package/dist/{history → cjs/history}/actions/list-sessions.d.ts +3 -3
- package/dist/cjs/history/actions/list-sessions.js +67 -0
- package/dist/{history → cjs/history}/actions/reconcile-count.d.ts +13 -9
- package/dist/cjs/history/actions/reconcile-count.js +8 -0
- package/dist/{history → cjs/history}/chat-message-history.d.ts +62 -30
- package/dist/cjs/history/chat-message-history.js +61 -0
- package/dist/{history → cjs/history}/internal/append.d.ts +64 -32
- package/dist/cjs/history/internal/append.js +267 -0
- package/dist/{history → cjs/history}/internal/message-read.d.ts +3 -3
- package/dist/cjs/history/internal/message-read.js +93 -0
- package/dist/{history → cjs/history}/internal/parse.d.ts +2 -2
- package/dist/cjs/history/internal/parse.js +113 -0
- package/dist/{history → cjs/history}/internal/rows.d.ts +11 -10
- package/dist/cjs/history/internal/rows.js +96 -0
- package/dist/{history → cjs/history}/internal/session.d.ts +41 -22
- package/dist/cjs/history/internal/session.js +296 -0
- package/dist/{history → cjs/history}/internal/setup.d.ts +2 -2
- package/dist/cjs/history/internal/setup.js +60 -0
- package/dist/{history → cjs/history}/session-adapter.d.ts +0 -6
- package/dist/cjs/history/session-adapter.js +38 -0
- package/dist/{history → cjs/history}/types.d.ts +18 -15
- package/dist/cjs/history/types.js +2 -0
- package/dist/{index.d.ts → cjs/index.d.ts} +27 -27
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/package.json +1 -0
- package/dist/{shared → cjs/shared}/adapter.d.ts +27 -16
- package/dist/cjs/shared/adapter.js +70 -0
- package/dist/cjs/shared/clock.js +14 -0
- package/dist/{shared → cjs/shared}/codec/codec.d.ts +37 -20
- package/dist/cjs/shared/codec/codec.js +162 -0
- package/dist/{shared → cjs/shared}/codec/compression.d.ts +9 -4
- package/dist/cjs/shared/codec/compression.js +45 -0
- package/dist/cjs/shared/codec/json-serde.js +58 -0
- package/dist/{shared → cjs/shared}/codec/s3/client-types.d.ts +2 -1
- package/dist/cjs/shared/codec/s3/client-types.js +6 -0
- package/dist/{shared → cjs/shared}/codec/s3/client.d.ts +25 -7
- package/dist/cjs/shared/codec/s3/client.js +78 -0
- package/dist/{shared → cjs/shared}/codec/s3/config.d.ts +12 -7
- package/dist/cjs/shared/codec/s3/config.js +92 -0
- package/dist/{shared → cjs/shared}/codec/s3/lifecycle.d.ts +71 -17
- package/dist/cjs/shared/codec/s3/lifecycle.js +223 -0
- package/dist/{shared → cjs/shared}/codec/s3/offloader.d.ts +42 -29
- package/dist/cjs/shared/codec/s3/offloader.js +289 -0
- package/dist/cjs/shared/concurrency.js +31 -0
- package/dist/{shared → cjs/shared}/dynamodb/abort.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/abort.js +16 -0
- package/dist/{shared → cjs/shared}/dynamodb/batch-write.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/batch-write.js +79 -0
- package/dist/cjs/shared/dynamodb/cancellation.js +37 -0
- package/dist/{shared → cjs/shared}/dynamodb/client.d.ts +24 -22
- package/dist/cjs/shared/dynamodb/client.js +40 -0
- package/dist/{shared → cjs/shared}/dynamodb/idempotent-write.d.ts +64 -19
- package/dist/cjs/shared/dynamodb/idempotent-write.js +173 -0
- package/dist/{shared → cjs/shared}/dynamodb/paginate.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/paginate.js +90 -0
- package/dist/{shared → cjs/shared}/dynamodb/partition-delete.d.ts +6 -6
- package/dist/cjs/shared/dynamodb/partition-delete.js +177 -0
- package/dist/{shared → cjs/shared}/dynamodb/recency-index.d.ts +27 -15
- package/dist/cjs/shared/dynamodb/recency-index.js +146 -0
- package/dist/{shared → cjs/shared}/dynamodb/retry.d.ts +37 -6
- 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/{shared → cjs/shared}/dynamodb/table-schema.d.ts +27 -18
- package/dist/cjs/shared/dynamodb/table-schema.js +52 -0
- package/dist/{shared → cjs/shared}/errors/base-error.d.ts +42 -7
- package/dist/cjs/shared/errors/base-error.js +73 -0
- package/dist/{shared → cjs/shared}/errors/boundary.d.ts +29 -14
- 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/{shared → cjs/shared}/errors/error-code.d.ts +17 -10
- package/dist/cjs/shared/errors/error-code.js +27 -0
- package/dist/{shared → cjs/shared}/errors/errors.d.ts +75 -9
- package/dist/cjs/shared/errors/errors.js +123 -0
- package/dist/cjs/shared/logging/logger.js +30 -0
- package/dist/{shared → cjs/shared}/logging/redaction.d.ts +8 -4
- package/dist/cjs/shared/logging/redaction.js +145 -0
- package/dist/{shared → cjs/shared}/logging/secret-patterns.d.ts +30 -7
- package/dist/cjs/shared/logging/secret-patterns.js +93 -0
- package/dist/cjs/shared/logging/truncate.js +31 -0
- package/dist/{shared → cjs/shared}/options.d.ts +27 -11
- package/dist/cjs/shared/options.js +2 -0
- package/dist/cjs/shared/ulid.js +83 -0
- package/dist/{shared → cjs/shared}/validation/collaborators.d.ts +21 -2
- package/dist/cjs/shared/validation/collaborators.js +79 -0
- package/dist/{shared → cjs/shared}/validation/option-shape.d.ts +7 -5
- package/dist/cjs/shared/validation/option-shape.js +31 -0
- package/dist/{shared → cjs/shared}/validation/options.d.ts +4 -4
- package/dist/cjs/shared/validation/options.js +166 -0
- package/dist/cjs/shared/validation/primitives.js +114 -0
- package/dist/{shared → cjs/shared}/validation/ttl.d.ts +26 -9
- package/dist/cjs/shared/validation/ttl.js +52 -0
- package/dist/{store → cjs/store}/actions/list-namespaces.d.ts +5 -5
- package/dist/cjs/store/actions/list-namespaces.js +92 -0
- package/dist/{store → cjs/store}/actions/put.d.ts +11 -4
- package/dist/cjs/store/actions/put.js +49 -0
- package/dist/{store → cjs/store}/actions/reconcile-vector-index.d.ts +5 -5
- package/dist/cjs/store/actions/reconcile-vector-index.js +13 -0
- package/dist/{store → cjs/store}/actions/search.d.ts +2 -2
- 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/{store → cjs/store}/internal/filter.d.ts +3 -3
- 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/{store → cjs/store}/internal/item-write.d.ts +72 -32
- package/dist/cjs/store/internal/item-write.js +181 -0
- package/dist/{store → cjs/store}/internal/parse.d.ts +15 -10
- package/dist/cjs/store/internal/parse.js +180 -0
- package/dist/{store → cjs/store}/internal/rows.d.ts +38 -34
- package/dist/cjs/store/internal/rows.js +166 -0
- package/dist/{store → cjs/store}/internal/semantic-search.d.ts +2 -2
- package/dist/cjs/store/internal/semantic-search.js +211 -0
- package/dist/{store → cjs/store}/internal/setup.d.ts +10 -15
- package/dist/cjs/store/internal/setup.js +103 -0
- package/dist/{store → cjs/store}/internal/table-search.d.ts +5 -5
- package/dist/cjs/store/internal/table-search.js +123 -0
- package/dist/{store → cjs/store}/internal/vector-index.d.ts +26 -15
- package/dist/cjs/store/internal/vector-index.js +269 -0
- package/dist/{store → cjs/store}/store.d.ts +82 -39
- package/dist/cjs/store/store.js +97 -0
- package/dist/{store → cjs/store}/types.d.ts +25 -10
- package/dist/cjs/store/types.js +2 -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/{checkpointer/actions/delete-thread.js → esm/checkpointer/actions/delete-thread.d.ts} +4 -26
- package/dist/esm/checkpointer/actions/delete-thread.js +23 -0
- package/dist/{checkpointer/actions/get-tuple.js → esm/checkpointer/actions/get-tuple.d.ts} +7 -24
- 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/{checkpointer/actions/put-writes.js → esm/checkpointer/actions/put-writes.d.ts} +10 -37
- 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/{checkpointer/internal/listing.js → esm/checkpointer/internal/listing.d.ts} +22 -118
- 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/{checkpointer/saver.js → esm/checkpointer/saver.d.ts} +84 -87
- 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/{history/actions/add-messages.js → esm/history/actions/add-messages.d.ts} +20 -26
- package/dist/esm/history/actions/add-messages.js +14 -0
- package/dist/{history/actions/clear.js → esm/history/actions/clear.d.ts} +4 -35
- 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/{history/actions/reconcile-count.js → esm/history/actions/reconcile-count.d.ts} +14 -16
- package/dist/esm/history/actions/reconcile-count.js +5 -0
- package/dist/{history/chat-message-history.js → esm/history/chat-message-history.d.ts} +76 -87
- 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/{history/internal/rows.js → esm/history/internal/rows.d.ts} +58 -112
- 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/{history/session-adapter.js → esm/history/session-adapter.d.ts} +25 -39
- 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/{shared/clock.js → esm/shared/clock.d.ts} +3 -14
- 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/{shared/codec/s3/config.js → esm/shared/codec/s3/config.d.ts} +45 -93
- 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/{shared/concurrency.js → esm/shared/concurrency.d.ts} +2 -37
- package/dist/esm/shared/concurrency.js +27 -0
- package/dist/{shared/dynamodb/abort.js → esm/shared/dynamodb/abort.d.ts} +4 -16
- 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/{shared/dynamodb/cancellation.js → esm/shared/dynamodb/cancellation.d.ts} +25 -53
- package/dist/esm/shared/dynamodb/cancellation.js +30 -0
- package/dist/{shared/dynamodb/client.js → esm/shared/dynamodb/client.d.ts} +74 -64
- package/dist/esm/shared/dynamodb/client.js +35 -0
- package/dist/{shared/dynamodb/idempotent-write.js → esm/shared/dynamodb/idempotent-write.d.ts} +172 -169
- 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/{shared/dynamodb/table-schema.js → esm/shared/dynamodb/table-schema.d.ts} +57 -67
- 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/{shared/errors/error-code.js → esm/shared/errors/error-code.d.ts} +39 -43
- package/dist/esm/shared/errors/error-code.js +24 -0
- package/dist/{shared/errors/errors.js → esm/shared/errors/errors.d.ts} +92 -98
- package/dist/esm/shared/errors/errors.js +110 -0
- package/dist/{shared/logging/logger.js → esm/shared/logging/logger.d.ts} +22 -52
- 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/{shared/logging/secret-patterns.js → esm/shared/logging/secret-patterns.d.ts} +46 -87
- package/dist/esm/shared/logging/secret-patterns.js +83 -0
- package/dist/{shared/logging/truncate.js → esm/shared/logging/truncate.d.ts} +6 -40
- 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/{shared/ulid.js → esm/shared/ulid.d.ts} +4 -84
- package/dist/esm/shared/ulid.js +77 -0
- package/dist/{shared/validation/collaborators.js → esm/shared/validation/collaborators.d.ts} +37 -65
- package/dist/esm/shared/validation/collaborators.js +70 -0
- package/dist/{shared/validation/option-shape.js → esm/shared/validation/option-shape.d.ts} +14 -36
- 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/{shared/validation/primitives.js → esm/shared/validation/primitives.d.ts} +30 -125
- 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/{store/actions/reconcile-vector-index.js → esm/store/actions/reconcile-vector-index.d.ts} +8 -16
- 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/{store/internal/rows.js → esm/store/internal/rows.d.ts} +111 -199
- 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/{store/store.js → esm/store/store.d.ts} +99 -133
- 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 +50 -44
- package/dist/backfill/backfill.js +0 -393
- package/dist/checkpointer/actions/list.js +0 -142
- package/dist/checkpointer/actions/put.js +0 -195
- package/dist/checkpointer/internal/delta-history.js +0 -252
- package/dist/checkpointer/internal/parse.js +0 -372
- package/dist/checkpointer/internal/pending-writes.js +0 -588
- package/dist/checkpointer/internal/read.js +0 -264
- package/dist/checkpointer/internal/rows.js +0 -834
- package/dist/checkpointer/internal/setup.js +0 -72
- package/dist/checkpointer/types.js +0 -12
- package/dist/factory/factory.js +0 -266
- package/dist/factory/types.js +0 -10
- package/dist/history/actions/get-messages.js +0 -141
- package/dist/history/actions/list-sessions.js +0 -156
- package/dist/history/internal/append.js +0 -500
- package/dist/history/internal/message-read.js +0 -204
- package/dist/history/internal/parse.js +0 -252
- package/dist/history/internal/session.js +0 -628
- package/dist/history/internal/setup.js +0 -106
- package/dist/history/types.js +0 -12
- package/dist/index.js +0 -51
- package/dist/shared/adapter.js +0 -143
- package/dist/shared/codec/codec.js +0 -441
- package/dist/shared/codec/compression.js +0 -89
- package/dist/shared/codec/json-serde.js +0 -191
- package/dist/shared/codec/s3/client-types.js +0 -26
- package/dist/shared/codec/s3/client.js +0 -97
- package/dist/shared/codec/s3/lifecycle.js +0 -355
- package/dist/shared/codec/s3/offloader.js +0 -658
- package/dist/shared/dynamodb/batch-write.js +0 -173
- package/dist/shared/dynamodb/paginate.js +0 -188
- package/dist/shared/dynamodb/partition-delete.js +0 -340
- package/dist/shared/dynamodb/recency-index.js +0 -377
- package/dist/shared/dynamodb/retry.js +0 -463
- package/dist/shared/errors/base-error.js +0 -174
- package/dist/shared/errors/boundary.js +0 -143
- package/dist/shared/errors/classify.d.ts +0 -97
- package/dist/shared/errors/classify.js +0 -257
- package/dist/shared/logging/redaction.js +0 -316
- package/dist/shared/options.js +0 -11
- package/dist/shared/validation/options.js +0 -328
- package/dist/shared/validation/ttl.js +0 -132
- package/dist/store/actions/list-namespaces.js +0 -197
- package/dist/store/actions/put.js +0 -78
- package/dist/store/actions/search.js +0 -66
- package/dist/store/internal/batch-plan.d.ts +0 -26
- package/dist/store/internal/batch-plan.js +0 -109
- package/dist/store/internal/filter.js +0 -137
- package/dist/store/internal/get-item.d.ts +0 -45
- package/dist/store/internal/get-item.js +0 -115
- package/dist/store/internal/item-write.js +0 -463
- package/dist/store/internal/parse.js +0 -350
- package/dist/store/internal/semantic-search.js +0 -389
- package/dist/store/internal/setup.js +0 -223
- package/dist/store/internal/table-search.js +0 -213
- package/dist/store/internal/vector-index.js +0 -546
- package/dist/store/types.js +0 -15
- package/dist/store/vector-backend.js +0 -17
- /package/dist/{shared → cjs/shared}/clock.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/codec/json-serde.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/concurrency.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/dynamodb/cancellation.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/logging/logger.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/logging/truncate.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/ulid.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/validation/primitives.d.ts +0 -0
- /package/dist/{store → cjs/store}/vector-backend.d.ts +0 -0
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Hides which options the saver and its methods accept, and how the saver is
|
|
4
|
-
* assembled from them.
|
|
5
|
-
*
|
|
6
|
-
* The exhaustive key list of every option bag — the constructor's, `list`'s,
|
|
7
|
-
* `getDeltaChannelHistory`'s — lives here, compiler-checked against its type,
|
|
8
|
-
* beside the code that resolves the constructor's options into the context
|
|
9
|
-
* every action receives.
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.DELTA_CHANNEL_HISTORY_KEYS = exports.SAVER_LIST_KEYS = exports.SAVER_KEYS = void 0;
|
|
13
|
-
exports.setUpCheckpointer = setUpCheckpointer;
|
|
14
|
-
const adapter_1 = require("../../shared/adapter");
|
|
15
|
-
const option_shape_1 = require("../../shared/validation/option-shape");
|
|
16
|
-
/**
|
|
17
|
-
* The keys of each checkpointer option bag, exhaustive in both directions:
|
|
18
|
-
* `allKeysOf<T>` makes omitting or inventing one a compile error, so a list
|
|
19
|
-
* cannot rot away from the type it guards. They live with the feature because
|
|
20
|
-
* the types they are checked against do; `shared/` knows no feature.
|
|
21
|
-
*/
|
|
22
|
-
exports.SAVER_KEYS = (0, option_shape_1.allKeysOf)({
|
|
23
|
-
tableName: 'tableName',
|
|
24
|
-
client: 'client',
|
|
25
|
-
clientConfig: 'clientConfig',
|
|
26
|
-
createClient: 'createClient',
|
|
27
|
-
ttl: 'ttl',
|
|
28
|
-
logger: 'logger',
|
|
29
|
-
retry: 'retry',
|
|
30
|
-
indexShards: 'indexShards',
|
|
31
|
-
indexName: 'indexName',
|
|
32
|
-
readConcurrency: 'readConcurrency',
|
|
33
|
-
compression: 'compression',
|
|
34
|
-
s3: 's3',
|
|
35
|
-
serde: 'serde',
|
|
36
|
-
});
|
|
37
|
-
/** See {@link SAVER_KEYS}. */
|
|
38
|
-
exports.SAVER_LIST_KEYS = (0, option_shape_1.allKeysOf)({
|
|
39
|
-
limit: 'limit',
|
|
40
|
-
before: 'before',
|
|
41
|
-
filter: 'filter',
|
|
42
|
-
});
|
|
43
|
-
/**
|
|
44
|
-
* See {@link SAVER_KEYS}. `DeltaChannelHistoryOptions` is pinned equal to
|
|
45
|
-
* `BaseCheckpointSaver.getDeltaChannelHistory`'s own parameter type, the
|
|
46
|
-
* contract that method implements, so this list is checked against it.
|
|
47
|
-
*/
|
|
48
|
-
exports.DELTA_CHANNEL_HISTORY_KEYS = (0, option_shape_1.allKeysOf)({
|
|
49
|
-
config: 'config',
|
|
50
|
-
channels: 'channels',
|
|
51
|
-
});
|
|
52
|
-
/**
|
|
53
|
-
* Check the options, then resolve the client, offloader and serializer.
|
|
54
|
-
*
|
|
55
|
-
* Accepts: `options` — already held to the saver's key list by its constructor,
|
|
56
|
-
* which must read `serde` before anything else runs; checked here before
|
|
57
|
-
* anything is built, so no half-built saver exists when one is wrong. `serde` —
|
|
58
|
-
* the serializer the base class resolved, which is the caller's own serializer
|
|
59
|
-
* when they gave one.
|
|
60
|
-
*
|
|
61
|
-
* Returns: the context every action receives, and the shell that releases what
|
|
62
|
-
* it holds — a client the caller passed in is never destroyed by `destroy()`.
|
|
63
|
-
*
|
|
64
|
-
* Throws: `VALIDATION` for an option or collaborator that fails a check,
|
|
65
|
-
* naming the offending option.
|
|
66
|
-
*
|
|
67
|
-
* Guarantees: constructing a saver performs no I/O.
|
|
68
|
-
*/
|
|
69
|
-
function setUpCheckpointer(options, serde) {
|
|
70
|
-
const shell = (0, adapter_1.openAdapter)(options, 'checkpointer');
|
|
71
|
-
return { shell, context: { ...shell.core, serde } };
|
|
72
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Hides the saver's own modules from the shapes a caller types against.
|
|
4
|
-
*
|
|
5
|
-
* The saver's options and the options its delta-channel walk accepts are
|
|
6
|
-
* declared here, apart from the saver and its actions, so a caller can type
|
|
7
|
-
* what it builds without importing either. The narrowed `configurable` is
|
|
8
|
-
* declared beside them for the parser that reads it, not for a caller. The
|
|
9
|
-
* delta-channel options are pinned equal to upstream's inline parameter
|
|
10
|
-
* type, so they change only when LangGraph's do.
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/factory/factory.js
DELETED
|
@@ -1,266 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Hides how several adapters share one client and one set of defaults.
|
|
4
|
-
*
|
|
5
|
-
* A caller states its defaults once; which adapter gets the base client
|
|
6
|
-
* choice and which its own, how the DynamoDB region reaches a shared `s3`
|
|
7
|
-
* config, and who destroys a client the factory built rather than was handed
|
|
8
|
-
* are decided here. Teardown is total — one adapter failing to release cannot
|
|
9
|
-
* strand the others — and a `createAll` that fails partway releases what it
|
|
10
|
-
* had built before its own error propagates.
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.DynamoDBFactory = void 0;
|
|
14
|
-
const saver_1 = require("../checkpointer/saver");
|
|
15
|
-
const chat_message_history_1 = require("../history/chat-message-history");
|
|
16
|
-
const client_types_1 = require("../shared/codec/s3/client-types");
|
|
17
|
-
const client_1 = require("../shared/dynamodb/client");
|
|
18
|
-
const base_error_1 = require("../shared/errors/base-error");
|
|
19
|
-
const logger_1 = require("../shared/logging/logger");
|
|
20
|
-
const truncate_1 = require("../shared/logging/truncate");
|
|
21
|
-
const collaborators_1 = require("../shared/validation/collaborators");
|
|
22
|
-
const option_shape_1 = require("../shared/validation/option-shape");
|
|
23
|
-
const options_1 = require("../shared/validation/options");
|
|
24
|
-
const store_1 = require("../store/store");
|
|
25
|
-
/** The factory's own options, checked against {@link FactoryBaseOptions} at compile time. */
|
|
26
|
-
const FACTORY_BASE_KEYS = (0, option_shape_1.allKeysOf)({
|
|
27
|
-
client: 'client',
|
|
28
|
-
clientConfig: 'clientConfig',
|
|
29
|
-
createClient: 'createClient',
|
|
30
|
-
logger: 'logger',
|
|
31
|
-
ttl: 'ttl',
|
|
32
|
-
compression: 'compression',
|
|
33
|
-
s3: 's3',
|
|
34
|
-
retry: 'retry',
|
|
35
|
-
});
|
|
36
|
-
/** The sections `createAll` builds, checked against {@link CreateAllOptions} at compile time. */
|
|
37
|
-
const CREATE_ALL_KEYS = (0, option_shape_1.allKeysOf)({
|
|
38
|
-
saver: 'saver',
|
|
39
|
-
store: 'store',
|
|
40
|
-
history: 'history',
|
|
41
|
-
});
|
|
42
|
-
/**
|
|
43
|
-
* Release one resource without letting its failure strand the others.
|
|
44
|
-
*
|
|
45
|
-
* Teardown runs in two places that must both finish: the caller's `destroy`,
|
|
46
|
-
* where a throw halfway through would leak every resource after it, and the
|
|
47
|
-
* rollback of a failed {@link DynamoDBFactory.createAll}, where it would also
|
|
48
|
-
* replace the constructor error the caller needs with its own.
|
|
49
|
-
*/
|
|
50
|
-
function release(logger, close) {
|
|
51
|
-
try {
|
|
52
|
-
close();
|
|
53
|
-
}
|
|
54
|
-
catch (error) {
|
|
55
|
-
// The name, never the message — and bounded, because a name is a string an
|
|
56
|
-
// adapter's own `close` threw and nothing this package ran checked its
|
|
57
|
-
// length. `message` is bounded at `redactedMessage`, and relaying the two
|
|
58
|
-
// halves of "what the failure was" under different rules is the split that
|
|
59
|
-
// rule exists to remove.
|
|
60
|
-
logger.warn('factory.destroy: an adapter did not release its resources', {
|
|
61
|
-
reason: (0, truncate_1.truncateForLog)((0, base_error_1.failureLabel)(error)),
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
function overridesClient(options) {
|
|
66
|
-
return (options.client !== undefined ||
|
|
67
|
-
options.clientConfig !== undefined ||
|
|
68
|
-
options.createClient !== undefined);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* Convenience constructors for the adapters.
|
|
72
|
-
*
|
|
73
|
-
* Individual `create*` methods each build their own client; {@link createAll}
|
|
74
|
-
* builds one shared client used by all three and returns a combined `destroy`
|
|
75
|
-
* that tears everything down once. Each adapter validates the options it ends
|
|
76
|
-
* up with, so the same mistake is caught the same way however the adapter was
|
|
77
|
-
* built. The factory checks only what it reads itself before an adapter can:
|
|
78
|
-
* its own base options, client choice and logger, the keys of `createAll`'s
|
|
79
|
-
* argument, and that each adapter's options are an object at all.
|
|
80
|
-
*
|
|
81
|
-
* Every `create*` argument and every `createAll` section is one adapter's
|
|
82
|
-
* options, and a mistake in one is named the way that adapter's constructor
|
|
83
|
-
* names it: `options` for a value that is not an object, and the adapter's own
|
|
84
|
-
* field names (`options.<key>`, `tableName`, …) for anything inside one.
|
|
85
|
-
*/
|
|
86
|
-
class DynamoDBFactory {
|
|
87
|
-
base;
|
|
88
|
-
/**
|
|
89
|
-
* Accepts: `base` — the defaults every adapter inherits. Checked here, where
|
|
90
|
-
* the caller wrote them: an unknown key would otherwise be ignored, and a
|
|
91
|
-
* `client` next to a `clientConfig` was refused by the first `create*` call
|
|
92
|
-
* and accepted by `createAll`, for the same base. So is the shape of
|
|
93
|
-
* `clientConfig`: `createAll` hands its adapters the client built from it,
|
|
94
|
-
* never the config, so no adapter would see a malformed one. And so is
|
|
95
|
-
* `logger`, which `createAll` logs its own teardown failures through: a
|
|
96
|
-
* malformed one threw from inside that teardown, replacing a failed build's
|
|
97
|
-
* own error with a bare `TypeError`.
|
|
98
|
-
*
|
|
99
|
-
* Returns: a factory holding those defaults. It opens nothing: every client
|
|
100
|
-
* is built by the `create*` call that needs one.
|
|
101
|
-
*
|
|
102
|
-
* Throws: `VALIDATION` naming `options.<key>`, `client`, `clientConfig`,
|
|
103
|
-
* `logger` or `logger.<method>`. Everything else each adapter validates for
|
|
104
|
-
* itself, since a per-adapter value may still replace it.
|
|
105
|
-
*/
|
|
106
|
-
constructor(base = {}) {
|
|
107
|
-
this.base = base;
|
|
108
|
-
(0, option_shape_1.assertShape)(base, FACTORY_BASE_KEYS, 'options');
|
|
109
|
-
(0, options_1.assertClientChoice)(base);
|
|
110
|
-
if (base.logger !== undefined)
|
|
111
|
-
(0, collaborators_1.assertMembers)(base.logger, collaborators_1.LOGGER_MEMBERS, 'logger');
|
|
112
|
-
}
|
|
113
|
-
/** The base options every adapter inherits regardless of which client it uses. */
|
|
114
|
-
sharedDefaults() {
|
|
115
|
-
const { logger, ttl, compression, s3, retry } = this.base;
|
|
116
|
-
return { logger, ttl, compression, s3, retry };
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* The base `s3` config with the region the DynamoDB side was configured with
|
|
120
|
-
* already filled in.
|
|
121
|
-
*
|
|
122
|
-
* An adapter normally reads that region off its own `clientConfig`
|
|
123
|
-
* (`offloaderConfigFor`), but the adapters {@link createAll} builds are given
|
|
124
|
-
* the one shared `client` instead — and a `clientConfig` beside a `client` is
|
|
125
|
-
* refused, because for the DynamoDB client it would be silently ignored. So
|
|
126
|
-
* the region has to be carried here, on the config that still needs it:
|
|
127
|
-
* without it, a bucket reachable only through that region fails with an
|
|
128
|
-
* opaque `PermanentRedirect` on the first offload, unlike the identical
|
|
129
|
-
* configuration through `createStore`, which resolves its own region
|
|
130
|
-
* directly.
|
|
131
|
-
*
|
|
132
|
-
* A base `s3`, or its `clientConfig`, that is not an object is handed on
|
|
133
|
-
* unchanged, for each adapter to refuse by its own name: reading `.region`
|
|
134
|
-
* off a `null` one would throw here instead, and writing a region into a
|
|
135
|
-
* malformed `clientConfig` would turn it into an object shape an adapter
|
|
136
|
-
* then accepts instead of refusing.
|
|
137
|
-
*/
|
|
138
|
-
sharedS3() {
|
|
139
|
-
const s3 = this.base.s3;
|
|
140
|
-
if (!(0, option_shape_1.isObjectShape)(s3))
|
|
141
|
-
return s3;
|
|
142
|
-
if (s3.clientConfig !== undefined && !(0, option_shape_1.isObjectShape)(s3.clientConfig))
|
|
143
|
-
return s3;
|
|
144
|
-
const region = (0, client_types_1.s3ClientOptions)(s3.clientConfig).region ?? this.base.clientConfig?.region;
|
|
145
|
-
if (region === undefined)
|
|
146
|
-
return s3;
|
|
147
|
-
return { ...s3, clientConfig: { ...s3.clientConfig, region } };
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Per-adapter options replace the factory's client choice as a unit: a
|
|
151
|
-
* `client` handed to `createSaver` also displaces the base `clientConfig`
|
|
152
|
-
* and `createClient`, because carrying those along is exactly the ambiguous
|
|
153
|
-
* combination the adapters' option validation rejects. The shared
|
|
154
|
-
* `ttl`/`compression`/`s3`/`retry` defaults stay either way.
|
|
155
|
-
*/
|
|
156
|
-
defaultsFor(options) {
|
|
157
|
-
return overridesClient(options) ? this.sharedDefaults() : this.base;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* A saver on its own client.
|
|
161
|
-
*
|
|
162
|
-
* Accepts: `options` — the saver's own, laid over the factory's defaults. A
|
|
163
|
-
* per-adapter value wins; see {@link defaultsFor} for how a client choice
|
|
164
|
-
* replaces the factory's as a unit.
|
|
165
|
-
*
|
|
166
|
-
* Returns: the saver, which owns the client it built and releases it on
|
|
167
|
-
* `destroy()`.
|
|
168
|
-
*
|
|
169
|
-
* Throws: `VALIDATION` for any invalid option, naming it as the saver's
|
|
170
|
-
* constructor does — `options` for a value that is not an object, checked
|
|
171
|
-
* before the defaults are laid under it: reading `.client` off a `null`
|
|
172
|
-
* value would throw here, and spreading a string would iterate its
|
|
173
|
-
* characters instead of refusing it.
|
|
174
|
-
*/
|
|
175
|
-
createSaver(options) {
|
|
176
|
-
(0, option_shape_1.assertObjectShape)(options, 'options');
|
|
177
|
-
return new saver_1.DynamoDBSaver({ ...this.defaultsFor(options), ...options });
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* A store on its own client.
|
|
181
|
-
*
|
|
182
|
-
* Accepts: as {@link createSaver}, for the store's options.
|
|
183
|
-
*
|
|
184
|
-
* Returns: the store.
|
|
185
|
-
*
|
|
186
|
-
* Throws: as {@link createSaver}.
|
|
187
|
-
*/
|
|
188
|
-
createStore(options) {
|
|
189
|
-
(0, option_shape_1.assertObjectShape)(options, 'options');
|
|
190
|
-
return new store_1.DynamoDBStore({ ...this.defaultsFor(options), ...options });
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* A chat history on its own client.
|
|
194
|
-
*
|
|
195
|
-
* Accepts: as {@link createSaver}, for the history's options.
|
|
196
|
-
*
|
|
197
|
-
* Returns: the chat history.
|
|
198
|
-
*
|
|
199
|
-
* Throws: as {@link createSaver}.
|
|
200
|
-
*/
|
|
201
|
-
createChatMessageHistory(options) {
|
|
202
|
-
(0, option_shape_1.assertObjectShape)(options, 'options');
|
|
203
|
-
return new chat_message_history_1.DynamoDBChatMessageHistory({ ...this.defaultsFor(options), ...options });
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* Build the adapters whose sections are given, all on one shared client.
|
|
207
|
-
*
|
|
208
|
-
* Accepts: `options` — a section per adapter, laid over the factory's shared
|
|
209
|
-
* defaults; omitting one, or giving it as `undefined`, skips that adapter,
|
|
210
|
-
* and `{}` builds none. A key that is not a section name is refused rather
|
|
211
|
-
* than ignored, so a misspelt one cannot silently build nothing. Each section
|
|
212
|
-
* is that adapter's options, so one that is not an object, `null` included,
|
|
213
|
-
* is refused before any client is built.
|
|
214
|
-
*
|
|
215
|
-
* Returns: the adapters, typed by the sections asked for, and one `destroy`
|
|
216
|
-
* that releases all of them and the shared client. A client the factory was
|
|
217
|
-
* given rather than built is never destroyed.
|
|
218
|
-
*
|
|
219
|
-
* Throws: `VALIDATION` naming `options` for an argument or a section that
|
|
220
|
-
* is not an object, or `options.<key>` for a key that is not a section name.
|
|
221
|
-
* Whatever an adapter's constructor throws — after the adapters already
|
|
222
|
-
* built and the freshly created client have been released, so a failed call
|
|
223
|
-
* leaks nothing and the constructor's own error is the one that propagates.
|
|
224
|
-
*
|
|
225
|
-
* Guarantees: one DynamoDB client for all three adapters, and one S3 client
|
|
226
|
-
* per adapter, each under its own key prefix in the shared bucket. Teardown
|
|
227
|
-
* is total: one adapter failing to release its resources cannot strand the
|
|
228
|
-
* others.
|
|
229
|
-
*/
|
|
230
|
-
createAll(options) {
|
|
231
|
-
(0, option_shape_1.assertShape)(options, CREATE_ALL_KEYS, 'options');
|
|
232
|
-
const { saver, store, history } = options;
|
|
233
|
-
for (const section of [saver, store, history]) {
|
|
234
|
-
if (section !== undefined)
|
|
235
|
-
(0, option_shape_1.assertObjectShape)(section, 'options');
|
|
236
|
-
}
|
|
237
|
-
const logger = (0, logger_1.resolveLogger)(this.base.logger);
|
|
238
|
-
const resolved = (0, client_1.resolveDynamoDBClient)(this.base);
|
|
239
|
-
const shared = { ...this.sharedDefaults(), s3: this.sharedS3(), client: resolved.client };
|
|
240
|
-
const built = [];
|
|
241
|
-
// Record an adapter the moment it exists, so a later failure can still tear it down.
|
|
242
|
-
const track = (adapter) => {
|
|
243
|
-
built.push(adapter);
|
|
244
|
-
return adapter;
|
|
245
|
-
};
|
|
246
|
-
const destroy = () => {
|
|
247
|
-
for (const adapter of built)
|
|
248
|
-
release(logger, () => adapter.destroy());
|
|
249
|
-
release(logger, () => resolved.ddbClient?.destroy());
|
|
250
|
-
};
|
|
251
|
-
try {
|
|
252
|
-
const adapters = {
|
|
253
|
-
saver: saver && track(new saver_1.DynamoDBSaver({ ...shared, ...saver })),
|
|
254
|
-
store: store && track(new store_1.DynamoDBStore({ ...shared, ...store })),
|
|
255
|
-
history: history && track(new chat_message_history_1.DynamoDBChatMessageHistory({ ...shared, ...history })),
|
|
256
|
-
destroy,
|
|
257
|
-
};
|
|
258
|
-
return adapters;
|
|
259
|
-
}
|
|
260
|
-
catch (error) {
|
|
261
|
-
destroy();
|
|
262
|
-
throw error;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
exports.DynamoDBFactory = DynamoDBFactory;
|
package/dist/factory/types.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Hides how the factory's options are typed by what a caller asks for.
|
|
4
|
-
*
|
|
5
|
-
* The defaults every adapter inherits, the per-adapter sections of `createAll`
|
|
6
|
-
* without the shared client's fields, and a result whose adapters are typed
|
|
7
|
-
* `undefined` for each section left out are declared here, so a caller's
|
|
8
|
-
* compiler knows which adapters it got without a runtime check.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,141 +0,0 @@
|
|
|
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
|
-
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getMessages = getMessages;
|
|
16
|
-
const messages_1 = require("@langchain/core/messages");
|
|
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;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
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.
|
|
57
|
-
*/
|
|
58
|
-
async function decodeMessage(context, item, sessionId, signal) {
|
|
59
|
-
const deps = (0, codec_1.codecDepsOf)(context, signal);
|
|
60
|
-
let bytes;
|
|
61
|
-
try {
|
|
62
|
-
bytes = await (0, codec_1.readPayloadBytes)(item.message, deps, [sessionId]);
|
|
63
|
-
}
|
|
64
|
-
catch (error) {
|
|
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) };
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
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.
|
|
121
|
-
*/
|
|
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;
|
|
141
|
-
}
|
|
@@ -1,156 +0,0 @@
|
|
|
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
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.listSessions = listSessions;
|
|
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);
|
|
26
|
-
/**
|
|
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.
|
|
33
|
-
*/
|
|
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 }) };
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
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.
|
|
76
|
-
*/
|
|
77
|
-
async function allByScan(context, request) {
|
|
78
|
-
const sessions = [];
|
|
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,
|
|
83
|
-
client: context.client,
|
|
84
|
-
params: {
|
|
85
|
-
TableName: context.tableName,
|
|
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
|
-
},
|
|
92
|
-
},
|
|
93
|
-
maxIterations: request.maxIterations,
|
|
94
|
-
maxItems: request.maxItems,
|
|
95
|
-
})) {
|
|
96
|
-
const session = (0, session_1.summariseSession)(raw, atSeconds);
|
|
97
|
-
if (session)
|
|
98
|
-
sessions.push(session);
|
|
99
|
-
}
|
|
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.
|
|
104
|
-
sessions.sort((a, b) => (a.updatedAt < b.updatedAt ? 1 : a.updatedAt > b.updatedAt ? -1 : 0));
|
|
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);
|
|
156
|
-
}
|