@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
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DESCRIPTOR_SCHEMA_VERSION = exports.PayloadLocation = exports.MAX_INLINE_PAYLOAD_BYTES = void 0;
|
|
4
|
+
exports.codecDepsOf = codecDepsOf;
|
|
5
|
+
exports.readPayloadBytes = readPayloadBytes;
|
|
6
|
+
exports.loadPayloadValue = loadPayloadValue;
|
|
7
|
+
exports.decodePayload = decodePayload;
|
|
8
|
+
exports.encodePayload = encodePayload;
|
|
9
|
+
exports.collectS3Keys = collectS3Keys;
|
|
10
|
+
exports.isMissingObjectError = isMissingObjectError;
|
|
11
|
+
exports.isRefusedObjectError = isRefusedObjectError;
|
|
12
|
+
exports.isPermanentPayloadLoss = isPermanentPayloadLoss;
|
|
13
|
+
const base_error_js_1 = require("../errors/base-error.js");
|
|
14
|
+
const classify_js_1 = require("../errors/classify.js");
|
|
15
|
+
const error_code_js_1 = require("../errors/error-code.js");
|
|
16
|
+
const errors_js_1 = require("../errors/errors.js");
|
|
17
|
+
const truncate_js_1 = require("../logging/truncate.js");
|
|
18
|
+
const compression_js_1 = require("./compression.js");
|
|
19
|
+
const json_serde_js_1 = require("./json-serde.js");
|
|
20
|
+
exports.MAX_INLINE_PAYLOAD_BYTES = 400 * 1024 - 8 * 1024;
|
|
21
|
+
var PayloadLocation;
|
|
22
|
+
(function (PayloadLocation) {
|
|
23
|
+
PayloadLocation["INLINE"] = "INLINE";
|
|
24
|
+
PayloadLocation["S3"] = "S3";
|
|
25
|
+
})(PayloadLocation || (exports.PayloadLocation = PayloadLocation = {}));
|
|
26
|
+
exports.DESCRIPTOR_SCHEMA_VERSION = 1;
|
|
27
|
+
function codecDepsOf(source, signal) {
|
|
28
|
+
return {
|
|
29
|
+
serde: source.serde,
|
|
30
|
+
compression: source.compression,
|
|
31
|
+
offloader: source.offloader,
|
|
32
|
+
signal,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function configuredOffloader(deps) {
|
|
36
|
+
if (!deps.offloader) {
|
|
37
|
+
throw (0, errors_js_1.validationError)("this row's payload is offloaded to S3 but the adapter has no `s3` configuration; " +
|
|
38
|
+
'configure the bucket the writer used', 's3');
|
|
39
|
+
}
|
|
40
|
+
return deps.offloader;
|
|
41
|
+
}
|
|
42
|
+
function assertReadableDescriptor(descriptor) {
|
|
43
|
+
if (descriptor === null || typeof descriptor !== 'object') {
|
|
44
|
+
throw (0, errors_js_1.validationError)(`payload descriptor is ${descriptor === null ? 'null' : typeof descriptor}, not a descriptor ` +
|
|
45
|
+
'this library wrote', 'descriptor');
|
|
46
|
+
}
|
|
47
|
+
const version = descriptor.schemaVersion ?? exports.DESCRIPTOR_SCHEMA_VERSION;
|
|
48
|
+
if (version > exports.DESCRIPTOR_SCHEMA_VERSION) {
|
|
49
|
+
const written = (0, truncate_js_1.truncateForLog)(String(version));
|
|
50
|
+
throw new base_error_js_1.DynamoDBLangGraphError(`this payload was written in descriptor schema version ${written}; this version of the ` +
|
|
51
|
+
`library reads up to ${exports.DESCRIPTOR_SCHEMA_VERSION} — upgrade to read it`, error_code_js_1.ErrorCode.FORMAT_UNSUPPORTED, { field: 'schemaVersion' });
|
|
52
|
+
}
|
|
53
|
+
const locations = Object.values(PayloadLocation);
|
|
54
|
+
if (!locations.includes(descriptor.location)) {
|
|
55
|
+
const location = (0, truncate_js_1.truncateForLog)(String(JSON.stringify(descriptor.location)));
|
|
56
|
+
throw (0, errors_js_1.validationError)(`payload descriptor has an unknown location ${location}`, 'descriptor');
|
|
57
|
+
}
|
|
58
|
+
if (descriptor.location === PayloadLocation.S3 && typeof descriptor.s3Key !== 'string') {
|
|
59
|
+
throw (0, errors_js_1.validationError)('payload descriptor is offloaded but names no object key', 'descriptor');
|
|
60
|
+
}
|
|
61
|
+
if (descriptor.location === PayloadLocation.INLINE && !ArrayBuffer.isView(descriptor.bytes)) {
|
|
62
|
+
throw (0, errors_js_1.validationError)('payload descriptor is inline but carries no bytes', 'descriptor');
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async function readPayloadBytes(descriptor, deps, scope) {
|
|
66
|
+
assertReadableDescriptor(descriptor);
|
|
67
|
+
let raw;
|
|
68
|
+
if (descriptor.location === PayloadLocation.S3) {
|
|
69
|
+
const offloader = configuredOffloader(deps);
|
|
70
|
+
offloader.assertOwnedKey(descriptor.s3Key, scope);
|
|
71
|
+
raw = await offloader.download(descriptor.s3Key, deps.signal);
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
raw = descriptor.bytes;
|
|
75
|
+
}
|
|
76
|
+
return (0, compression_js_1.decompress)(raw, descriptor.compressed, deps.compression?.maxDecompressedBytes);
|
|
77
|
+
}
|
|
78
|
+
async function loadPayloadValue(serdeType, bytes, deps) {
|
|
79
|
+
try {
|
|
80
|
+
return (await deps.serde.loadsTyped(serdeType, bytes));
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
const refusal = (0, base_error_js_1.toError)(error);
|
|
84
|
+
if ((0, base_error_js_1.isDynamoDBLangGraphError)(refusal))
|
|
85
|
+
throw refusal;
|
|
86
|
+
if (!(0, json_serde_js_1.bytesHoldDeclaredForm)(serdeType, bytes)) {
|
|
87
|
+
throw new base_error_js_1.DynamoDBLangGraphError('the stored payload is no longer the form this row declares, so no serde could decode ' +
|
|
88
|
+
'it; the refusal that proved it is attached as `cause`', error_code_js_1.ErrorCode.PAYLOAD_CORRUPT, {}, refusal);
|
|
89
|
+
}
|
|
90
|
+
throw (0, errors_js_1.validationError)('the configured serde refused the payload stored in this row: the bytes parse, but the ' +
|
|
91
|
+
'serializer would not reconstruct the value they name — a stored `lc` constructor record ' +
|
|
92
|
+
'naming a class outside its allow-list reads this way, as does a serde that did not ' +
|
|
93
|
+
'write these bytes. The refusal itself is attached as `cause`', 'serde', refusal);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
async function decodePayload(descriptor, deps, scope) {
|
|
97
|
+
const bytes = await readPayloadBytes(descriptor, deps, scope);
|
|
98
|
+
return loadPayloadValue(descriptor.serdeType, bytes, deps);
|
|
99
|
+
}
|
|
100
|
+
function assertInlinePayloadFits(bytes, deps) {
|
|
101
|
+
if (bytes.length <= exports.MAX_INLINE_PAYLOAD_BYTES)
|
|
102
|
+
return;
|
|
103
|
+
const hint = deps.compression?.enabled
|
|
104
|
+
? ''
|
|
105
|
+
: ', or enable compression if the data compresses well';
|
|
106
|
+
throw (0, errors_js_1.validationError)(`payload of ${bytes.length} bytes exceeds the ${exports.MAX_INLINE_PAYLOAD_BYTES}-byte inline limit ` +
|
|
107
|
+
`(DynamoDB items are capped at 400 KB); configure s3 offloading${hint}`, 'payload');
|
|
108
|
+
}
|
|
109
|
+
function assertSerialisedToBytes(raw) {
|
|
110
|
+
if (raw.length > 0)
|
|
111
|
+
return;
|
|
112
|
+
throw (0, errors_js_1.validationError)('value serialises to zero bytes, which no reader can parse back: a function, a symbol ' +
|
|
113
|
+
'or any value the configured serde drops encodes to nothing. Store a value the serde ' +
|
|
114
|
+
'can represent, or configure one that refuses it.', 'value');
|
|
115
|
+
}
|
|
116
|
+
async function encodePayload(value, deps, options) {
|
|
117
|
+
const [serdeType, raw] = await deps.serde.dumpsTyped(value);
|
|
118
|
+
assertSerialisedToBytes(raw);
|
|
119
|
+
const { bytes, compressed } = deps.compression
|
|
120
|
+
? await (0, compression_js_1.compress)(raw, deps.compression)
|
|
121
|
+
: { bytes: raw, compressed: false };
|
|
122
|
+
const base = {
|
|
123
|
+
schemaVersion: exports.DESCRIPTOR_SCHEMA_VERSION,
|
|
124
|
+
serdeType,
|
|
125
|
+
compressed,
|
|
126
|
+
writeId: options.objectId,
|
|
127
|
+
};
|
|
128
|
+
if (deps.offloader && deps.offloader.shouldOffload(bytes)) {
|
|
129
|
+
const s3Key = deps.offloader.buildKey(options.keyParts, options.objectId);
|
|
130
|
+
await deps.offloader.upload(s3Key, bytes, options.row, deps.signal);
|
|
131
|
+
return { ...base, location: PayloadLocation.S3, s3Key };
|
|
132
|
+
}
|
|
133
|
+
if (!deps.offloader)
|
|
134
|
+
assertInlinePayloadFits(bytes, deps);
|
|
135
|
+
return { ...base, location: PayloadLocation.INLINE, bytes };
|
|
136
|
+
}
|
|
137
|
+
function collectS3Keys(descriptors) {
|
|
138
|
+
const keys = [];
|
|
139
|
+
for (const descriptor of descriptors) {
|
|
140
|
+
if (descriptor?.location === PayloadLocation.S3 && descriptor.s3Key !== undefined) {
|
|
141
|
+
keys.push(descriptor.s3Key);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
return keys;
|
|
145
|
+
}
|
|
146
|
+
function isMissingObjectError(error) {
|
|
147
|
+
return ((0, base_error_js_1.hasErrorCode)(error, error_code_js_1.ErrorCode.S3_OFFLOAD_FAILED) &&
|
|
148
|
+
error.cause !== undefined &&
|
|
149
|
+
(0, classify_js_1.isMissingObject)(error.cause));
|
|
150
|
+
}
|
|
151
|
+
function isRefusedObjectError(error) {
|
|
152
|
+
return ((0, base_error_js_1.hasErrorCode)(error, error_code_js_1.ErrorCode.S3_OFFLOAD_FAILED) &&
|
|
153
|
+
(0, classify_js_1.classifyAwsError)(error.cause) === error_code_js_1.ErrorCode.ACCESS_DENIED);
|
|
154
|
+
}
|
|
155
|
+
function isUnreadableDescriptor(error) {
|
|
156
|
+
return (0, base_error_js_1.hasErrorCode)(error, error_code_js_1.ErrorCode.VALIDATION) && error.context.field === 'descriptor';
|
|
157
|
+
}
|
|
158
|
+
function isPermanentPayloadLoss(error) {
|
|
159
|
+
return ((0, base_error_js_1.hasErrorCode)(error, error_code_js_1.ErrorCode.PAYLOAD_CORRUPT) ||
|
|
160
|
+
isMissingObjectError(error) ||
|
|
161
|
+
isUnreadableDescriptor(error));
|
|
162
|
+
}
|
|
@@ -32,7 +32,8 @@ export interface CompressionResult {
|
|
|
32
32
|
* returns the input untouched. `config.minSizeBytes` — the size below which
|
|
33
33
|
* gzip is not attempted, default {@link DEFAULT_COMPRESSION_MIN_BYTES}.
|
|
34
34
|
* `config.level` — zlib level 0–9, default {@link DEFAULT_COMPRESSION_LEVEL}.
|
|
35
|
-
* `config.maxDecompressedBytes`
|
|
35
|
+
* `config.maxDecompressedBytes` — a payload larger than it is stored
|
|
36
|
+
* uncompressed, since no reader configured like this writer would inflate it.
|
|
36
37
|
*
|
|
37
38
|
* Returns: `compressed: true` only when gzip beat the input by more than 10%;
|
|
38
39
|
* otherwise the input bytes and `compressed: false`. The flag is recorded in
|
|
@@ -54,8 +55,12 @@ export declare function compress(data: Uint8Array, config: CompressionConfig): P
|
|
|
54
55
|
* Returns: the decoded bytes.
|
|
55
56
|
*
|
|
56
57
|
* Throws: `COMPRESSION_LIMIT` when the output would exceed `maxBytes`, and
|
|
57
|
-
* `PAYLOAD_CORRUPT` when `compressed` is true but the bytes are not gzip.
|
|
58
|
-
*
|
|
59
|
-
*
|
|
58
|
+
* `PAYLOAD_CORRUPT` when `compressed` is true but the bytes are not gzip.
|
|
59
|
+
* `PAYLOAD_CORRUPT` is permanent for that payload
|
|
60
|
+
* ({@link isPermanentPayloadLoss}). `COMPRESSION_LIMIT` is this reader's
|
|
61
|
+
* limit, not the payload's loss: a reader with a larger cap reads it. From
|
|
62
|
+
* this release on, `compress` never produces a payload past its writer's own
|
|
63
|
+
* cap; a payload an earlier release compressed — which did not check it —
|
|
64
|
+
* can still exceed a smaller `maxBytes` here.
|
|
60
65
|
*/
|
|
61
66
|
export declare function decompress(data: Uint8Array, compressed: boolean, maxBytes?: number): Promise<Uint8Array>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_MAX_DECOMPRESSED_BYTES = exports.DEFAULT_COMPRESSION_LEVEL = exports.DEFAULT_COMPRESSION_MIN_BYTES = void 0;
|
|
4
|
+
exports.compress = compress;
|
|
5
|
+
exports.decompress = decompress;
|
|
6
|
+
const node_util_1 = require("node:util");
|
|
7
|
+
const node_zlib_1 = require("node:zlib");
|
|
8
|
+
const base_error_js_1 = require("../errors/base-error.js");
|
|
9
|
+
const error_code_js_1 = require("../errors/error-code.js");
|
|
10
|
+
const gzipAsync = (0, node_util_1.promisify)(node_zlib_1.gzip);
|
|
11
|
+
const gunzipAsync = (0, node_util_1.promisify)(node_zlib_1.gunzip);
|
|
12
|
+
const COMPRESSION_GAIN_RATIO = 0.9;
|
|
13
|
+
exports.DEFAULT_COMPRESSION_MIN_BYTES = 1024;
|
|
14
|
+
exports.DEFAULT_COMPRESSION_LEVEL = 6;
|
|
15
|
+
exports.DEFAULT_MAX_DECOMPRESSED_BYTES = 50 * 1024 * 1024;
|
|
16
|
+
async function compress(data, config) {
|
|
17
|
+
const minSize = config.minSizeBytes ?? exports.DEFAULT_COMPRESSION_MIN_BYTES;
|
|
18
|
+
const readable = config.maxDecompressedBytes ?? exports.DEFAULT_MAX_DECOMPRESSED_BYTES;
|
|
19
|
+
if (!config.enabled || data.length < minSize || data.length > readable) {
|
|
20
|
+
return { bytes: data, compressed: false };
|
|
21
|
+
}
|
|
22
|
+
const level = config.level ?? exports.DEFAULT_COMPRESSION_LEVEL;
|
|
23
|
+
const gzipped = new Uint8Array(await gzipAsync(data, { level }));
|
|
24
|
+
if (gzipped.length >= data.length * COMPRESSION_GAIN_RATIO) {
|
|
25
|
+
return { bytes: data, compressed: false };
|
|
26
|
+
}
|
|
27
|
+
return { bytes: gzipped, compressed: true };
|
|
28
|
+
}
|
|
29
|
+
function corruptPayload(cause) {
|
|
30
|
+
return new base_error_js_1.DynamoDBLangGraphError('the stored payload is marked compressed but is not valid gzip, so it cannot be decoded', error_code_js_1.ErrorCode.PAYLOAD_CORRUPT, {}, cause);
|
|
31
|
+
}
|
|
32
|
+
async function decompress(data, compressed, maxBytes = exports.DEFAULT_MAX_DECOMPRESSED_BYTES) {
|
|
33
|
+
if (!compressed)
|
|
34
|
+
return data;
|
|
35
|
+
try {
|
|
36
|
+
return new Uint8Array(await gunzipAsync(data, { maxOutputLength: maxBytes }));
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
const err = error;
|
|
40
|
+
if (err.code === 'ERR_BUFFER_TOO_LARGE') {
|
|
41
|
+
throw new base_error_js_1.DynamoDBLangGraphError(`Refusing to decompress: output would exceed ${maxBytes} bytes`, error_code_js_1.ErrorCode.COMPRESSION_LIMIT, {}, error);
|
|
42
|
+
}
|
|
43
|
+
throw corruptPayload(error);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.JSON_SERDE = void 0;
|
|
4
|
+
exports.bytesHoldDeclaredForm = bytesHoldDeclaredForm;
|
|
5
|
+
const base_error_js_1 = require("../errors/base-error.js");
|
|
6
|
+
const error_code_js_1 = require("../errors/error-code.js");
|
|
7
|
+
const errors_js_1 = require("../errors/errors.js");
|
|
8
|
+
const truncate_js_1 = require("../logging/truncate.js");
|
|
9
|
+
exports.JSON_SERDE = {
|
|
10
|
+
async dumpsTyped(value) {
|
|
11
|
+
let text;
|
|
12
|
+
try {
|
|
13
|
+
text = JSON.stringify(value);
|
|
14
|
+
}
|
|
15
|
+
catch (error) {
|
|
16
|
+
throw (0, errors_js_1.validationError)('value cannot be serialized as JSON — a circular structure, or a value JSON has no ' +
|
|
17
|
+
'encoding for such as a BigInt; the refusal itself is attached as `cause`', 'value', (0, base_error_js_1.toError)(error));
|
|
18
|
+
}
|
|
19
|
+
if (text === undefined) {
|
|
20
|
+
throw (0, errors_js_1.validationError)('value has no JSON representation (undefined, a function or a symbol), so it cannot be ' +
|
|
21
|
+
'stored; store null instead to record an absent value', 'value');
|
|
22
|
+
}
|
|
23
|
+
return Promise.resolve([JSON_SERDE_TYPE, new TextEncoder().encode(text)]);
|
|
24
|
+
},
|
|
25
|
+
async loadsTyped(type, data) {
|
|
26
|
+
if (type !== JSON_SERDE_TYPE) {
|
|
27
|
+
throw (0, errors_js_1.validationError)(`this serializer reads only the \`${JSON_SERDE_TYPE}\` form it writes, and this payload ` +
|
|
28
|
+
`declares ${(0, truncate_js_1.truncateForLog)(String(JSON.stringify(type)))}; read the row with the ` +
|
|
29
|
+
'serializer that wrote it, or rewrite the row', 'serde');
|
|
30
|
+
}
|
|
31
|
+
let text;
|
|
32
|
+
try {
|
|
33
|
+
text = typeof data === 'string' ? data : new TextDecoder().decode(data);
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
throw (0, errors_js_1.validationError)('data must be the bytes or text this serializer wrote, as a Uint8Array or a string', 'data', error);
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
return Promise.resolve(JSON.parse(text));
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw new base_error_js_1.DynamoDBLangGraphError('the stored payload is not the JSON this serializer wrote, so it cannot be decoded', error_code_js_1.ErrorCode.PAYLOAD_CORRUPT, {}, error);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
Object.freeze(exports.JSON_SERDE);
|
|
47
|
+
const JSON_SERDE_TYPE = 'json';
|
|
48
|
+
function bytesHoldDeclaredForm(serdeType, bytes) {
|
|
49
|
+
if (serdeType !== JSON_SERDE_TYPE)
|
|
50
|
+
return true;
|
|
51
|
+
try {
|
|
52
|
+
JSON.parse(new TextDecoder().decode(bytes));
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
catch {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -40,7 +40,7 @@ export type S3ClientConfigLike = S3ClientOptions | object;
|
|
|
40
40
|
*/
|
|
41
41
|
export declare function s3ClientOptions(config: S3ClientConfigLike | undefined): S3ClientOptions;
|
|
42
42
|
/** What every SDK command object carries: its `input`. */
|
|
43
|
-
|
|
43
|
+
interface S3CommandLike {
|
|
44
44
|
input: object;
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
@@ -51,3 +51,4 @@ export interface S3ClientLike {
|
|
|
51
51
|
send(command: S3CommandLike, options?: object): Promise<object>;
|
|
52
52
|
destroy(): void;
|
|
53
53
|
}
|
|
54
|
+
export {};
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* bounds a stalled transfer without bounding a slow one.
|
|
10
10
|
*/
|
|
11
11
|
import type { S3Client } from '@aws-sdk/client-s3';
|
|
12
|
-
import type
|
|
12
|
+
import { type S3ClientConfigLike, type S3ClientOptions } from './client-types.js';
|
|
13
13
|
type S3Sdk = typeof import('@aws-sdk/client-s3');
|
|
14
14
|
/**
|
|
15
15
|
* The optional `@aws-sdk/client-s3` peer, imported on first use.
|
|
@@ -21,18 +21,24 @@ type S3Sdk = typeof import('@aws-sdk/client-s3');
|
|
|
21
21
|
* Throws: `VALIDATION` naming `s3` when the package is not installed,
|
|
22
22
|
* carrying the install command; any other import failure — a broken build, a
|
|
23
23
|
* syntax error inside the package — passes through unchanged. A failure is not
|
|
24
|
-
* cached, so an install or a fixed bundle succeeds on a later call.
|
|
24
|
+
* cached, so an install or a fixed bundle succeeds on a later call. Each
|
|
25
|
+
* concurrent caller of a failed import gets its own error instance
|
|
26
|
+
* (`copyForCaller`), so the public boundary stamping one's `context.operation`
|
|
27
|
+
* cannot leave it sitting in another caller's error too.
|
|
25
28
|
*/
|
|
26
29
|
export declare function loadS3Sdk(): Promise<S3Sdk>;
|
|
27
30
|
/**
|
|
28
|
-
*
|
|
31
|
+
* `config` with the two defaults every S3 client of this library is built
|
|
32
|
+
* with, whichever constructor builds it.
|
|
29
33
|
*
|
|
30
|
-
* Accepts: `config` —
|
|
31
|
-
* `requestHandler` wins over the defaults below.
|
|
34
|
+
* Accepts: `config` — the caller's `s3.clientConfig`, or an empty object.
|
|
32
35
|
*
|
|
33
|
-
* Returns:
|
|
36
|
+
* Returns: a copy whose `maxAttempts` and `requestHandler` are the caller's
|
|
37
|
+
* own where it gave one and the default where it did not. A key named with
|
|
38
|
+
* `undefined` — a config assembled from settings that were not all set — gave
|
|
39
|
+
* none, and keeps the default.
|
|
34
40
|
*
|
|
35
|
-
* Throws:
|
|
41
|
+
* Throws: nothing.
|
|
36
42
|
*
|
|
37
43
|
* Guarantees: `maxAttempts` defaults to 1, so the SDK performs no retries of
|
|
38
44
|
* its own and this library's retry, backoff and classification are the only
|
|
@@ -41,5 +47,17 @@ export declare function loadS3Sdk(): Promise<S3Sdk>;
|
|
|
41
47
|
* stalled, which `maxAttempts` alone does not; a `requestHandler` in `config`
|
|
42
48
|
* replaces it whole rather than merging with it.
|
|
43
49
|
*/
|
|
50
|
+
export declare function withS3ClientDefaults(config: S3ClientConfigLike): S3ClientOptions;
|
|
51
|
+
/**
|
|
52
|
+
* An `S3Client` built from `config` with the lazily-loaded SDK.
|
|
53
|
+
*
|
|
54
|
+
* Accepts: `config` — any `S3ClientConfig`; an explicit `maxAttempts` or
|
|
55
|
+
* `requestHandler` wins over the defaults {@link withS3ClientDefaults} fills
|
|
56
|
+
* in.
|
|
57
|
+
*
|
|
58
|
+
* Returns: the client. The caller owns it and destroys it.
|
|
59
|
+
*
|
|
60
|
+
* Throws: whatever {@link loadS3Sdk} throws.
|
|
61
|
+
*/
|
|
44
62
|
export declare function createDefaultS3Client(config: S3ClientConfigLike): Promise<S3Client>;
|
|
45
63
|
export {};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.loadS3Sdk = loadS3Sdk;
|
|
37
|
+
exports.withS3ClientDefaults = withS3ClientDefaults;
|
|
38
|
+
exports.createDefaultS3Client = createDefaultS3Client;
|
|
39
|
+
const client_js_1 = require("../../dynamodb/client.js");
|
|
40
|
+
const base_error_js_1 = require("../../errors/base-error.js");
|
|
41
|
+
const errors_js_1 = require("../../errors/errors.js");
|
|
42
|
+
const client_types_js_1 = require("./client-types.js");
|
|
43
|
+
const MISSING_MODULE_CODES = ['ERR_MODULE_NOT_FOUND', 'MODULE_NOT_FOUND'];
|
|
44
|
+
let sdkPromise;
|
|
45
|
+
function wrapMissingPeer(error) {
|
|
46
|
+
const code = error.code;
|
|
47
|
+
if (code !== undefined && MISSING_MODULE_CODES.includes(code)) {
|
|
48
|
+
throw (0, errors_js_1.validationError)('S3 offload requires the optional peer @aws-sdk/client-s3 (npm install @aws-sdk/client-s3); ' +
|
|
49
|
+
'bundlers must keep it installed or external', 's3', error);
|
|
50
|
+
}
|
|
51
|
+
throw error;
|
|
52
|
+
}
|
|
53
|
+
async function loadS3Sdk() {
|
|
54
|
+
if (!sdkPromise) {
|
|
55
|
+
sdkPromise = Promise.resolve().then(() => __importStar(require('@aws-sdk/client-s3'))).catch((error) => {
|
|
56
|
+
sdkPromise = undefined;
|
|
57
|
+
return wrapMissingPeer(error);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
try {
|
|
61
|
+
return await sdkPromise;
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
throw (0, base_error_js_1.copyForCaller)(error);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function withS3ClientDefaults(config) {
|
|
68
|
+
const options = (0, client_types_js_1.s3ClientOptions)(config);
|
|
69
|
+
return {
|
|
70
|
+
...options,
|
|
71
|
+
maxAttempts: options.maxAttempts ?? 1,
|
|
72
|
+
requestHandler: options.requestHandler ?? { socketTimeout: client_js_1.DEFAULT_SOCKET_TIMEOUT_MS },
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
async function createDefaultS3Client(config) {
|
|
76
|
+
const { S3Client: S3ClientCtor } = await loadS3Sdk();
|
|
77
|
+
return new S3ClientCtor(withS3ClientDefaults(config));
|
|
78
|
+
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* rule ids derived from a prefix are part of the same layout.
|
|
10
10
|
*/
|
|
11
11
|
import type { DynamoDBClientConfig } from '@aws-sdk/client-dynamodb';
|
|
12
|
-
import { type S3ClientConfigLike } from './client-types';
|
|
12
|
+
import { type S3ClientConfigLike } from './client-types.js';
|
|
13
13
|
/** Default S3 key prefix for offloaded payloads. */
|
|
14
14
|
export declare const DEFAULT_S3_KEY_PREFIX = "langgraph-checkpoints/";
|
|
15
15
|
/** S3 cap on an object key, applied to the produced offload key. */
|
|
@@ -21,16 +21,21 @@ export interface S3OffloadConfig {
|
|
|
21
21
|
/**
|
|
22
22
|
* Serialized payloads at or above this size are offloaded (default 350 KB).
|
|
23
23
|
* Only the payload counts: the store's inline vectors live on the same item
|
|
24
|
-
* and are not part of it. The store embeds one vector
|
|
25
|
-
*
|
|
26
|
-
* dimension, so three
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* and are not part of it. The store embeds one vector per text its
|
|
25
|
+
* `index.fields` extract — a wildcard path yields one per element — each up
|
|
26
|
+
* to about 10 bytes per dimension, so three texts at 1024 dims cost roughly
|
|
27
|
+
* 30 KB. A row that payload and those vectors would take past DynamoDB's
|
|
28
|
+
* 400 KB item limit is refused with `VALIDATION` naming `index`.
|
|
29
29
|
*/
|
|
30
30
|
thresholdBytes?: number;
|
|
31
31
|
serverSideEncryption?: string;
|
|
32
32
|
sseKmsKeyId?: string;
|
|
33
|
-
/**
|
|
33
|
+
/**
|
|
34
|
+
* Largest object this adapter will buffer from S3 (default 50 MiB). An
|
|
35
|
+
* offloaded payload larger than it is refused at the write, and a value
|
|
36
|
+
* below `thresholdBytes` is refused at construction, so an adapter never
|
|
37
|
+
* stores an object it could not read back.
|
|
38
|
+
*/
|
|
34
39
|
maxDownloadBytes?: number;
|
|
35
40
|
/**
|
|
36
41
|
* S3 client configuration (an `S3ClientConfig`). `region` defaults to the
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_S3_KEY_BYTES = exports.DEFAULT_S3_KEY_PREFIX = void 0;
|
|
4
|
+
exports.encodeKeyPart = encodeKeyPart;
|
|
5
|
+
exports.buildS3Key = buildS3Key;
|
|
6
|
+
exports.assertScopedKeyPrefix = assertScopedKeyPrefix;
|
|
7
|
+
exports.buildLifecycleRuleId = buildLifecycleRuleId;
|
|
8
|
+
exports.buildMarkerRuleId = buildMarkerRuleId;
|
|
9
|
+
exports.defaultAdapterKeyPrefix = defaultAdapterKeyPrefix;
|
|
10
|
+
exports.s3KeyScope = s3KeyScope;
|
|
11
|
+
exports.isKeyInScope = isKeyInScope;
|
|
12
|
+
exports.assertKeyInScope = assertKeyInScope;
|
|
13
|
+
exports.offloaderConfigFor = offloaderConfigFor;
|
|
14
|
+
const errors_js_1 = require("../../errors/errors.js");
|
|
15
|
+
const truncate_js_1 = require("../../logging/truncate.js");
|
|
16
|
+
const primitives_js_1 = require("../../validation/primitives.js");
|
|
17
|
+
const client_types_js_1 = require("./client-types.js");
|
|
18
|
+
exports.DEFAULT_S3_KEY_PREFIX = 'langgraph-checkpoints/';
|
|
19
|
+
exports.MAX_S3_KEY_BYTES = 1024;
|
|
20
|
+
function encodeKeyPart(part) {
|
|
21
|
+
return Buffer.from(part, 'utf8').toString('base64url');
|
|
22
|
+
}
|
|
23
|
+
function buildS3Key(prefix, parts, objectId) {
|
|
24
|
+
if (parts.length === 0) {
|
|
25
|
+
throw (0, errors_js_1.validationError)('an offloaded object needs the identity of the row that points at it; parts was empty', 's3Key');
|
|
26
|
+
}
|
|
27
|
+
const encoded = [...parts.map(encodeKeyPart), objectId];
|
|
28
|
+
const key = `${prefix}${encoded.join('/')}.bin`;
|
|
29
|
+
const bytes = Buffer.byteLength(key, 'utf8');
|
|
30
|
+
if (bytes > exports.MAX_S3_KEY_BYTES) {
|
|
31
|
+
throw (0, errors_js_1.validationError)(`the offloaded S3 object key would be ${bytes} bytes; S3 caps keys at ` +
|
|
32
|
+
`${exports.MAX_S3_KEY_BYTES} — shorten the identifiers or the keyPrefix`, 's3Key');
|
|
33
|
+
}
|
|
34
|
+
return key;
|
|
35
|
+
}
|
|
36
|
+
const UNSCOPED_SEGMENTS = new Set(['', '.', '..']);
|
|
37
|
+
function assertScopedKeyPrefix(keyPrefix) {
|
|
38
|
+
if (typeof keyPrefix !== 'string' ||
|
|
39
|
+
keyPrefix === '' ||
|
|
40
|
+
keyPrefix === '/' ||
|
|
41
|
+
!keyPrefix.endsWith('/')) {
|
|
42
|
+
throw (0, errors_js_1.validationError)('s3.keyPrefix must be a non-empty path that ends with "/" (for example "langgraph/"): ' +
|
|
43
|
+
'it scopes both the offloaded objects and the S3 lifecycle rule', 's3.keyPrefix');
|
|
44
|
+
}
|
|
45
|
+
(0, primitives_js_1.assertNoControlChars)(keyPrefix, 's3.keyPrefix');
|
|
46
|
+
(0, primitives_js_1.assertWellFormed)(keyPrefix, 's3.keyPrefix');
|
|
47
|
+
if (keyPrefix
|
|
48
|
+
.slice(0, -1)
|
|
49
|
+
.split('/')
|
|
50
|
+
.some((segment) => UNSCOPED_SEGMENTS.has(segment))) {
|
|
51
|
+
throw (0, errors_js_1.validationError)('s3.keyPrefix must name a real path: no empty, "." or ".." segment (for example ' +
|
|
52
|
+
'"langgraph/", not "../langgraph/" or "/langgraph/"). Such a prefix addresses object ' +
|
|
53
|
+
'keys outside the path the IAM policy grants and the lifecycle rule sweeps', 's3.keyPrefix');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
function buildLifecycleRuleId(prefix) {
|
|
57
|
+
let trimmed = prefix;
|
|
58
|
+
while (trimmed.endsWith('/'))
|
|
59
|
+
trimmed = trimmed.slice(0, -1);
|
|
60
|
+
const slug = trimmed.replace(/[^a-zA-Z0-9-]/g, '-') || 'default';
|
|
61
|
+
return `langgraph-ttl-${slug}`;
|
|
62
|
+
}
|
|
63
|
+
function buildMarkerRuleId(prefix) {
|
|
64
|
+
return `${buildLifecycleRuleId(prefix)}-markers`;
|
|
65
|
+
}
|
|
66
|
+
function defaultAdapterKeyPrefix(base, adapter) {
|
|
67
|
+
return `${base}${adapter}/`;
|
|
68
|
+
}
|
|
69
|
+
function s3KeyScope(prefix, parts) {
|
|
70
|
+
return `${prefix}${parts.map(encodeKeyPart).join('/')}`;
|
|
71
|
+
}
|
|
72
|
+
function isKeyInScope(key, prefix, parts) {
|
|
73
|
+
const scope = s3KeyScope(prefix, parts);
|
|
74
|
+
if (parts.length === 0)
|
|
75
|
+
return key.startsWith(scope);
|
|
76
|
+
return key === `${scope}.bin` || key.startsWith(`${scope}/`);
|
|
77
|
+
}
|
|
78
|
+
function assertKeyInScope(key, prefix, parts) {
|
|
79
|
+
if (isKeyInScope(key, prefix, parts))
|
|
80
|
+
return;
|
|
81
|
+
throw (0, errors_js_1.validationError)(`s3Key "${(0, truncate_js_1.truncateForLog)(key)}" lies outside the S3 path this row may reference ` +
|
|
82
|
+
`("${(0, truncate_js_1.truncateForLog)(s3KeyScope(prefix, parts))}"); refusing to touch an object the row ` +
|
|
83
|
+
'does not own', 's3Key');
|
|
84
|
+
}
|
|
85
|
+
function offloaderConfigFor(s3, adapter, clientConfig) {
|
|
86
|
+
const region = (0, client_types_js_1.s3ClientOptions)(s3.clientConfig).region ?? clientConfig?.region;
|
|
87
|
+
return {
|
|
88
|
+
...s3,
|
|
89
|
+
keyPrefix: s3.keyPrefix ?? defaultAdapterKeyPrefix(exports.DEFAULT_S3_KEY_PREFIX, adapter),
|
|
90
|
+
...(region === undefined ? {} : { clientConfig: { ...s3.clientConfig, region } }),
|
|
91
|
+
};
|
|
92
|
+
}
|