@farukada/aws-langgraph-dynamodb-ts 1.0.0-rc.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1820 -290
- package/dist/cjs/backfill/backfill.d.ts +171 -0
- package/dist/cjs/backfill/backfill.js +177 -0
- package/dist/cjs/checkpointer/actions/delete-thread.d.ts +50 -0
- package/dist/cjs/checkpointer/actions/delete-thread.js +26 -0
- package/dist/cjs/checkpointer/actions/get-tuple.d.ts +36 -0
- package/dist/cjs/checkpointer/actions/get-tuple.js +22 -0
- package/dist/cjs/checkpointer/actions/list.d.ts +55 -0
- package/dist/cjs/checkpointer/actions/list.js +70 -0
- package/dist/cjs/checkpointer/actions/put-writes.d.ts +49 -0
- package/dist/cjs/checkpointer/actions/put-writes.js +21 -0
- package/dist/cjs/checkpointer/actions/put.d.ts +95 -0
- package/dist/cjs/checkpointer/actions/put.js +79 -0
- package/dist/cjs/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/cjs/checkpointer/internal/delta-history.js +131 -0
- package/dist/cjs/checkpointer/internal/listing.d.ts +149 -0
- package/dist/cjs/checkpointer/internal/listing.js +104 -0
- package/dist/cjs/checkpointer/internal/parse.d.ts +298 -0
- package/dist/cjs/checkpointer/internal/parse.js +184 -0
- package/dist/cjs/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/cjs/checkpointer/internal/pending-writes.js +241 -0
- package/dist/cjs/checkpointer/internal/read.d.ts +135 -0
- package/dist/cjs/checkpointer/internal/read.js +132 -0
- package/dist/cjs/checkpointer/internal/rows.d.ts +644 -0
- package/dist/cjs/checkpointer/internal/rows.js +356 -0
- package/dist/cjs/checkpointer/internal/setup.d.ts +47 -0
- package/dist/cjs/checkpointer/internal/setup.js +25 -0
- package/dist/cjs/checkpointer/saver.d.ts +306 -0
- package/dist/cjs/checkpointer/saver.js +56 -0
- package/dist/cjs/checkpointer/types.d.ts +51 -0
- package/dist/cjs/factory/factory.d.ts +154 -0
- package/dist/cjs/factory/factory.js +137 -0
- package/dist/{factory → cjs/factory}/types.d.ts +33 -14
- package/dist/cjs/history/actions/add-messages.d.ts +51 -0
- package/dist/cjs/history/actions/add-messages.js +17 -0
- package/dist/cjs/history/actions/clear.d.ts +52 -0
- package/dist/cjs/history/actions/clear.js +29 -0
- package/dist/cjs/history/actions/get-messages.d.ts +60 -0
- package/dist/cjs/history/actions/get-messages.js +58 -0
- package/dist/cjs/history/actions/list-sessions.d.ts +55 -0
- package/dist/cjs/history/actions/list-sessions.js +67 -0
- package/dist/cjs/history/actions/reconcile-count.d.ts +49 -0
- package/dist/cjs/history/actions/reconcile-count.js +8 -0
- package/dist/cjs/history/chat-message-history.d.ts +267 -0
- package/dist/cjs/history/chat-message-history.js +61 -0
- package/dist/cjs/history/internal/append.d.ts +244 -0
- package/dist/cjs/history/internal/append.js +267 -0
- package/dist/cjs/history/internal/message-read.d.ts +84 -0
- package/dist/cjs/history/internal/message-read.js +93 -0
- package/dist/cjs/history/internal/parse.d.ts +153 -0
- package/dist/cjs/history/internal/parse.js +113 -0
- package/dist/cjs/history/internal/rows.d.ts +196 -0
- package/dist/cjs/history/internal/rows.js +96 -0
- package/dist/cjs/history/internal/session.d.ts +350 -0
- package/dist/cjs/history/internal/session.js +296 -0
- package/dist/cjs/history/internal/setup.d.ts +64 -0
- package/dist/cjs/history/internal/setup.js +60 -0
- package/dist/cjs/history/session-adapter.d.ts +112 -0
- package/dist/cjs/history/session-adapter.js +38 -0
- package/dist/cjs/history/types.d.ts +102 -0
- package/dist/cjs/index.d.ts +53 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/shared/adapter.d.ts +146 -0
- package/dist/cjs/shared/adapter.js +70 -0
- package/dist/cjs/shared/clock.d.ts +52 -0
- package/dist/cjs/shared/clock.js +14 -0
- package/dist/cjs/shared/codec/codec.d.ts +336 -0
- package/dist/cjs/shared/codec/codec.js +162 -0
- package/dist/cjs/shared/codec/compression.d.ts +66 -0
- package/dist/cjs/shared/codec/compression.js +45 -0
- package/dist/cjs/shared/codec/json-serde.d.ts +80 -0
- package/dist/cjs/shared/codec/json-serde.js +58 -0
- package/dist/{shared → cjs/shared}/codec/s3/client-types.d.ts +22 -2
- package/dist/{shared → cjs/shared}/codec/s3/client-types.js +0 -1
- package/dist/cjs/shared/codec/s3/client.d.ts +63 -0
- package/dist/cjs/shared/codec/s3/client.js +78 -0
- package/dist/cjs/shared/codec/s3/config.d.ts +260 -0
- package/dist/cjs/shared/codec/s3/config.js +92 -0
- package/dist/cjs/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/cjs/shared/codec/s3/lifecycle.js +223 -0
- package/dist/cjs/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/cjs/shared/codec/s3/offloader.js +289 -0
- package/dist/cjs/shared/concurrency.d.ts +43 -0
- package/dist/{shared → cjs/shared}/concurrency.js +10 -9
- package/dist/cjs/shared/dynamodb/abort.d.ts +47 -0
- package/dist/cjs/shared/dynamodb/abort.js +16 -0
- package/dist/cjs/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/cjs/shared/dynamodb/batch-write.js +79 -0
- package/dist/cjs/shared/dynamodb/cancellation.d.ts +124 -0
- package/dist/cjs/shared/dynamodb/cancellation.js +37 -0
- package/dist/cjs/shared/dynamodb/client.d.ts +177 -0
- package/dist/{shared → cjs/shared}/dynamodb/client.js +12 -14
- package/dist/cjs/shared/dynamodb/idempotent-write.d.ts +596 -0
- package/dist/cjs/shared/dynamodb/idempotent-write.js +173 -0
- package/dist/cjs/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/cjs/shared/dynamodb/paginate.js +90 -0
- package/dist/cjs/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/cjs/shared/dynamodb/partition-delete.js +177 -0
- package/dist/cjs/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/cjs/shared/dynamodb/recency-index.js +146 -0
- package/dist/cjs/shared/dynamodb/retry.d.ts +317 -0
- package/dist/cjs/shared/dynamodb/retry.js +193 -0
- package/dist/cjs/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/cjs/shared/dynamodb/row-size.js +30 -0
- package/dist/cjs/shared/dynamodb/table-schema.d.ts +199 -0
- package/dist/cjs/shared/dynamodb/table-schema.js +52 -0
- package/dist/cjs/shared/errors/base-error.d.ts +231 -0
- package/dist/cjs/shared/errors/base-error.js +73 -0
- package/dist/cjs/shared/errors/boundary.d.ts +86 -0
- package/dist/cjs/shared/errors/boundary.js +61 -0
- package/dist/cjs/shared/errors/classify.d.ts +206 -0
- package/dist/cjs/shared/errors/classify.js +232 -0
- package/dist/cjs/shared/errors/error-code.d.ts +95 -0
- package/dist/{shared → cjs/shared}/errors/error-code.js +12 -2
- package/dist/cjs/shared/errors/errors.d.ts +233 -0
- package/dist/cjs/shared/errors/errors.js +123 -0
- package/dist/cjs/shared/logging/logger.d.ts +80 -0
- package/dist/cjs/shared/logging/logger.js +30 -0
- package/dist/cjs/shared/logging/redaction.d.ts +123 -0
- package/dist/cjs/shared/logging/redaction.js +145 -0
- package/dist/cjs/shared/logging/secret-patterns.d.ts +227 -0
- package/dist/cjs/shared/logging/secret-patterns.js +93 -0
- package/dist/cjs/shared/logging/truncate.d.ts +197 -0
- package/dist/cjs/shared/logging/truncate.js +31 -0
- package/dist/cjs/shared/options.d.ts +100 -0
- package/dist/cjs/shared/ulid.d.ts +80 -0
- package/dist/{shared → cjs/shared}/ulid.js +7 -21
- package/dist/cjs/shared/validation/collaborators.d.ts +160 -0
- package/dist/cjs/shared/validation/collaborators.js +79 -0
- package/dist/cjs/shared/validation/option-shape.d.ts +91 -0
- package/dist/cjs/shared/validation/option-shape.js +31 -0
- package/dist/cjs/shared/validation/options.d.ts +145 -0
- package/dist/cjs/shared/validation/options.js +166 -0
- package/dist/cjs/shared/validation/primitives.d.ts +292 -0
- package/dist/cjs/shared/validation/primitives.js +114 -0
- package/dist/cjs/shared/validation/ttl.d.ts +94 -0
- package/dist/cjs/shared/validation/ttl.js +52 -0
- package/dist/cjs/store/actions/list-namespaces.d.ts +79 -0
- package/dist/cjs/store/actions/list-namespaces.js +92 -0
- package/dist/cjs/store/actions/put.d.ts +43 -0
- package/dist/cjs/store/actions/put.js +49 -0
- package/dist/cjs/store/actions/reconcile-vector-index.d.ts +38 -0
- package/dist/cjs/store/actions/reconcile-vector-index.js +13 -0
- package/dist/cjs/store/actions/search.d.ts +38 -0
- package/dist/cjs/store/actions/search.js +26 -0
- package/dist/cjs/store/internal/batch-plan.d.ts +56 -0
- package/dist/cjs/store/internal/batch-plan.js +32 -0
- package/dist/cjs/store/internal/filter.d.ts +43 -0
- package/dist/cjs/store/internal/filter.js +64 -0
- package/dist/cjs/store/internal/get-item.d.ts +77 -0
- package/dist/cjs/store/internal/get-item.js +58 -0
- package/dist/cjs/store/internal/item-write.d.ts +270 -0
- package/dist/cjs/store/internal/item-write.js +181 -0
- package/dist/cjs/store/internal/parse.d.ts +230 -0
- package/dist/cjs/store/internal/parse.js +180 -0
- package/dist/cjs/store/internal/rows.d.ts +359 -0
- package/dist/cjs/store/internal/rows.js +166 -0
- package/dist/cjs/store/internal/semantic-search.d.ts +168 -0
- package/dist/{store/internal/text-path.js → cjs/store/internal/semantic-search.js} +92 -28
- package/dist/cjs/store/internal/setup.d.ts +96 -0
- package/dist/cjs/store/internal/setup.js +103 -0
- package/dist/cjs/store/internal/table-search.d.ts +100 -0
- package/dist/cjs/store/internal/table-search.js +123 -0
- package/dist/cjs/store/internal/vector-index.d.ts +258 -0
- package/dist/cjs/store/internal/vector-index.js +269 -0
- package/dist/cjs/store/store.d.ts +329 -0
- package/dist/cjs/store/store.js +97 -0
- package/dist/cjs/store/types.d.ts +111 -0
- package/dist/cjs/store/vector-backend.d.ts +104 -0
- package/dist/cjs/store/vector-backend.js +4 -0
- package/dist/esm/backfill/backfill.d.ts +171 -0
- package/dist/esm/backfill/backfill.js +170 -0
- package/dist/esm/checkpointer/actions/delete-thread.d.ts +50 -0
- package/dist/esm/checkpointer/actions/delete-thread.js +23 -0
- package/dist/esm/checkpointer/actions/get-tuple.d.ts +36 -0
- package/dist/esm/checkpointer/actions/get-tuple.js +19 -0
- package/dist/esm/checkpointer/actions/list.d.ts +55 -0
- package/dist/esm/checkpointer/actions/list.js +67 -0
- package/dist/esm/checkpointer/actions/put-writes.d.ts +49 -0
- package/dist/esm/checkpointer/actions/put-writes.js +18 -0
- package/dist/esm/checkpointer/actions/put.d.ts +95 -0
- package/dist/esm/checkpointer/actions/put.js +75 -0
- package/dist/esm/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/esm/checkpointer/internal/delta-history.js +126 -0
- package/dist/esm/checkpointer/internal/listing.d.ts +149 -0
- package/dist/esm/checkpointer/internal/listing.js +95 -0
- package/dist/esm/checkpointer/internal/parse.d.ts +298 -0
- package/dist/esm/checkpointer/internal/parse.js +169 -0
- package/dist/esm/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/esm/checkpointer/internal/pending-writes.js +229 -0
- package/dist/esm/checkpointer/internal/read.d.ts +135 -0
- package/dist/esm/checkpointer/internal/read.js +125 -0
- package/dist/esm/checkpointer/internal/rows.d.ts +644 -0
- package/dist/esm/checkpointer/internal/rows.js +323 -0
- package/dist/esm/checkpointer/internal/setup.d.ts +47 -0
- package/dist/esm/checkpointer/internal/setup.js +21 -0
- package/dist/esm/checkpointer/saver.d.ts +306 -0
- package/dist/esm/checkpointer/saver.js +52 -0
- package/dist/esm/checkpointer/types.d.ts +51 -0
- package/dist/esm/checkpointer/types.js +1 -0
- package/dist/esm/factory/factory.d.ts +154 -0
- package/dist/esm/factory/factory.js +133 -0
- package/dist/esm/factory/types.d.ts +76 -0
- package/dist/esm/factory/types.js +1 -0
- package/dist/esm/history/actions/add-messages.d.ts +51 -0
- package/dist/esm/history/actions/add-messages.js +14 -0
- package/dist/esm/history/actions/clear.d.ts +52 -0
- package/dist/esm/history/actions/clear.js +26 -0
- package/dist/esm/history/actions/get-messages.d.ts +60 -0
- package/dist/esm/history/actions/get-messages.js +55 -0
- package/dist/esm/history/actions/list-sessions.d.ts +55 -0
- package/dist/esm/history/actions/list-sessions.js +64 -0
- package/dist/esm/history/actions/reconcile-count.d.ts +49 -0
- package/dist/esm/history/actions/reconcile-count.js +5 -0
- package/dist/esm/history/chat-message-history.d.ts +267 -0
- package/dist/esm/history/chat-message-history.js +57 -0
- package/dist/esm/history/internal/append.d.ts +244 -0
- package/dist/esm/history/internal/append.js +259 -0
- package/dist/esm/history/internal/message-read.d.ts +84 -0
- package/dist/esm/history/internal/message-read.js +89 -0
- package/dist/esm/history/internal/parse.d.ts +153 -0
- package/dist/esm/history/internal/parse.js +105 -0
- package/dist/esm/history/internal/rows.d.ts +196 -0
- package/dist/esm/history/internal/rows.js +83 -0
- package/dist/esm/history/internal/session.d.ts +350 -0
- package/dist/esm/history/internal/session.js +285 -0
- package/dist/esm/history/internal/setup.d.ts +64 -0
- package/dist/esm/history/internal/setup.js +56 -0
- package/dist/esm/history/session-adapter.d.ts +112 -0
- package/dist/esm/history/session-adapter.js +34 -0
- package/dist/esm/history/types.d.ts +102 -0
- package/dist/esm/history/types.js +1 -0
- package/dist/esm/index.d.ts +53 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/shared/adapter.d.ts +146 -0
- package/dist/esm/shared/adapter.js +65 -0
- package/dist/esm/shared/clock.d.ts +52 -0
- package/dist/esm/shared/clock.js +9 -0
- package/dist/esm/shared/codec/codec.d.ts +336 -0
- package/dist/esm/shared/codec/codec.js +150 -0
- package/dist/esm/shared/codec/compression.d.ts +66 -0
- package/dist/esm/shared/codec/compression.js +40 -0
- package/dist/esm/shared/codec/json-serde.d.ts +80 -0
- package/dist/esm/shared/codec/json-serde.js +54 -0
- package/dist/esm/shared/codec/s3/client-types.d.ts +54 -0
- package/dist/esm/shared/codec/s3/client-types.js +3 -0
- package/dist/esm/shared/codec/s3/client.d.ts +63 -0
- package/dist/esm/shared/codec/s3/client.js +40 -0
- package/dist/esm/shared/codec/s3/config.d.ts +260 -0
- package/dist/esm/shared/codec/s3/config.js +79 -0
- package/dist/esm/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/esm/shared/codec/s3/lifecycle.js +214 -0
- package/dist/esm/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/esm/shared/codec/s3/offloader.js +278 -0
- package/dist/esm/shared/concurrency.d.ts +43 -0
- package/dist/esm/shared/concurrency.js +27 -0
- package/dist/esm/shared/dynamodb/abort.d.ts +47 -0
- package/dist/esm/shared/dynamodb/abort.js +12 -0
- package/dist/esm/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/esm/shared/dynamodb/batch-write.js +74 -0
- package/dist/esm/shared/dynamodb/cancellation.d.ts +124 -0
- package/dist/esm/shared/dynamodb/cancellation.js +30 -0
- package/dist/esm/shared/dynamodb/client.d.ts +177 -0
- package/dist/esm/shared/dynamodb/client.js +35 -0
- package/dist/esm/shared/dynamodb/idempotent-write.d.ts +596 -0
- package/dist/esm/shared/dynamodb/idempotent-write.js +153 -0
- package/dist/esm/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/esm/shared/dynamodb/paginate.js +84 -0
- package/dist/esm/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/esm/shared/dynamodb/partition-delete.js +171 -0
- package/dist/esm/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/esm/shared/dynamodb/recency-index.js +136 -0
- package/dist/esm/shared/dynamodb/retry.d.ts +317 -0
- package/dist/esm/shared/dynamodb/retry.js +180 -0
- package/dist/esm/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/esm/shared/dynamodb/row-size.js +26 -0
- package/dist/esm/shared/dynamodb/table-schema.d.ts +199 -0
- package/dist/esm/shared/dynamodb/table-schema.js +43 -0
- package/dist/esm/shared/errors/base-error.d.ts +231 -0
- package/dist/esm/shared/errors/base-error.js +64 -0
- package/dist/esm/shared/errors/boundary.d.ts +86 -0
- package/dist/esm/shared/errors/boundary.js +54 -0
- package/dist/esm/shared/errors/classify.d.ts +206 -0
- package/dist/esm/shared/errors/classify.js +220 -0
- package/dist/esm/shared/errors/error-code.d.ts +95 -0
- package/dist/esm/shared/errors/error-code.js +24 -0
- package/dist/esm/shared/errors/errors.d.ts +233 -0
- package/dist/esm/shared/errors/errors.js +110 -0
- package/dist/esm/shared/logging/logger.d.ts +80 -0
- package/dist/esm/shared/logging/logger.js +25 -0
- package/dist/esm/shared/logging/redaction.d.ts +123 -0
- package/dist/esm/shared/logging/redaction.js +140 -0
- package/dist/esm/shared/logging/secret-patterns.d.ts +227 -0
- package/dist/esm/shared/logging/secret-patterns.js +83 -0
- package/dist/esm/shared/logging/truncate.d.ts +197 -0
- package/dist/esm/shared/logging/truncate.js +25 -0
- package/dist/esm/shared/options.d.ts +100 -0
- package/dist/esm/shared/options.js +1 -0
- package/dist/esm/shared/ulid.d.ts +80 -0
- package/dist/esm/shared/ulid.js +77 -0
- package/dist/esm/shared/validation/collaborators.d.ts +160 -0
- package/dist/esm/shared/validation/collaborators.js +70 -0
- package/dist/esm/shared/validation/option-shape.d.ts +91 -0
- package/dist/esm/shared/validation/option-shape.js +24 -0
- package/dist/esm/shared/validation/options.d.ts +145 -0
- package/dist/esm/shared/validation/options.js +156 -0
- package/dist/esm/shared/validation/primitives.d.ts +292 -0
- package/dist/esm/shared/validation/primitives.js +100 -0
- package/dist/esm/shared/validation/ttl.d.ts +94 -0
- package/dist/esm/shared/validation/ttl.js +46 -0
- package/dist/esm/store/actions/list-namespaces.d.ts +79 -0
- package/dist/esm/store/actions/list-namespaces.js +86 -0
- package/dist/esm/store/actions/put.d.ts +43 -0
- package/dist/esm/store/actions/put.js +46 -0
- package/dist/esm/store/actions/reconcile-vector-index.d.ts +38 -0
- package/dist/esm/store/actions/reconcile-vector-index.js +10 -0
- package/dist/esm/store/actions/search.d.ts +38 -0
- package/dist/esm/store/actions/search.js +23 -0
- package/dist/esm/store/internal/batch-plan.d.ts +56 -0
- package/dist/esm/store/internal/batch-plan.js +28 -0
- package/dist/esm/store/internal/filter.d.ts +43 -0
- package/dist/esm/store/internal/filter.js +60 -0
- package/dist/esm/store/internal/get-item.d.ts +77 -0
- package/dist/esm/store/internal/get-item.js +54 -0
- package/dist/esm/store/internal/item-write.d.ts +270 -0
- package/dist/esm/store/internal/item-write.js +173 -0
- package/dist/esm/store/internal/parse.d.ts +230 -0
- package/dist/esm/store/internal/parse.js +169 -0
- package/dist/esm/store/internal/rows.d.ts +359 -0
- package/dist/esm/store/internal/rows.js +147 -0
- package/dist/esm/store/internal/semantic-search.d.ts +168 -0
- package/dist/esm/store/internal/semantic-search.js +200 -0
- package/dist/esm/store/internal/setup.d.ts +96 -0
- package/dist/esm/store/internal/setup.js +98 -0
- package/dist/esm/store/internal/table-search.d.ts +100 -0
- package/dist/esm/store/internal/table-search.js +119 -0
- package/dist/esm/store/internal/vector-index.d.ts +258 -0
- package/dist/esm/store/internal/vector-index.js +256 -0
- package/dist/esm/store/store.d.ts +329 -0
- package/dist/esm/store/store.js +93 -0
- package/dist/esm/store/types.d.ts +111 -0
- package/dist/esm/store/types.js +1 -0
- package/dist/esm/store/vector-backend.d.ts +104 -0
- package/dist/esm/store/vector-backend.js +1 -0
- package/package.json +68 -46
- package/dist/checkpointer/actions/delete-thread.d.ts +0 -10
- package/dist/checkpointer/actions/delete-thread.js +0 -38
- package/dist/checkpointer/actions/get-tuple.d.ts +0 -11
- package/dist/checkpointer/actions/get-tuple.js +0 -25
- package/dist/checkpointer/actions/list.d.ts +0 -20
- package/dist/checkpointer/actions/list.js +0 -113
- package/dist/checkpointer/actions/put-writes.d.ts +0 -15
- package/dist/checkpointer/actions/put-writes.js +0 -62
- package/dist/checkpointer/actions/put.d.ts +0 -17
- package/dist/checkpointer/actions/put.js +0 -73
- package/dist/checkpointer/internal/assemble.d.ts +0 -17
- package/dist/checkpointer/internal/assemble.js +0 -38
- package/dist/checkpointer/internal/checkpoint-write-verify.d.ts +0 -24
- package/dist/checkpointer/internal/checkpoint-write-verify.js +0 -67
- package/dist/checkpointer/internal/configurable.d.ts +0 -12
- package/dist/checkpointer/internal/configurable.js +0 -24
- package/dist/checkpointer/internal/fetch.d.ts +0 -19
- package/dist/checkpointer/internal/fetch.js +0 -88
- package/dist/checkpointer/internal/filter-match.d.ts +0 -13
- package/dist/checkpointer/internal/filter-match.js +0 -15
- package/dist/checkpointer/internal/item-reader.d.ts +0 -66
- package/dist/checkpointer/internal/item-reader.js +0 -113
- package/dist/checkpointer/internal/item-writer.d.ts +0 -35
- package/dist/checkpointer/internal/item-writer.js +0 -107
- package/dist/checkpointer/internal/keys.d.ts +0 -41
- package/dist/checkpointer/internal/keys.js +0 -117
- package/dist/checkpointer/internal/list-scope.d.ts +0 -61
- package/dist/checkpointer/internal/list-scope.js +0 -108
- package/dist/checkpointer/internal/pending-sends.d.ts +0 -13
- package/dist/checkpointer/internal/pending-sends.js +0 -29
- package/dist/checkpointer/internal/query.d.ts +0 -21
- package/dist/checkpointer/internal/query.js +0 -42
- package/dist/checkpointer/internal/regular-write.d.ts +0 -28
- package/dist/checkpointer/internal/regular-write.js +0 -66
- package/dist/checkpointer/internal/setup.d.ts +0 -33
- package/dist/checkpointer/internal/setup.js +0 -38
- package/dist/checkpointer/internal/special-write-cas.d.ts +0 -29
- package/dist/checkpointer/internal/special-write-cas.js +0 -104
- package/dist/checkpointer/internal/special-write-cleanup.d.ts +0 -23
- package/dist/checkpointer/internal/special-write-cleanup.js +0 -50
- package/dist/checkpointer/internal/special-write-verify.d.ts +0 -53
- package/dist/checkpointer/internal/special-write-verify.js +0 -80
- package/dist/checkpointer/internal/stored-channels.d.ts +0 -31
- package/dist/checkpointer/internal/stored-channels.js +0 -70
- package/dist/checkpointer/internal/validation.d.ts +0 -18
- package/dist/checkpointer/internal/validation.js +0 -40
- package/dist/checkpointer/internal/write-guard.d.ts +0 -20
- package/dist/checkpointer/internal/write-guard.js +0 -48
- package/dist/checkpointer/internal/write-index.d.ts +0 -36
- package/dist/checkpointer/internal/write-index.js +0 -41
- package/dist/checkpointer/saver.d.ts +0 -70
- package/dist/checkpointer/saver.js +0 -105
- package/dist/checkpointer/types.d.ts +0 -58
- package/dist/factory/factory.d.ts +0 -40
- package/dist/factory/factory.js +0 -87
- package/dist/history/actions/add-messages.d.ts +0 -15
- package/dist/history/actions/add-messages.js +0 -77
- package/dist/history/actions/clear.d.ts +0 -10
- package/dist/history/actions/clear.js +0 -34
- package/dist/history/actions/get-messages.d.ts +0 -17
- package/dist/history/actions/get-messages.js +0 -79
- package/dist/history/actions/list-sessions.d.ts +0 -13
- package/dist/history/actions/list-sessions.js +0 -53
- package/dist/history/actions/reconcile-count.d.ts +0 -12
- package/dist/history/actions/reconcile-count.js +0 -64
- package/dist/history/chat-message-history.d.ts +0 -73
- package/dist/history/chat-message-history.js +0 -111
- package/dist/history/internal/append-saga.d.ts +0 -25
- package/dist/history/internal/append-saga.js +0 -79
- package/dist/history/internal/compensation.d.ts +0 -25
- package/dist/history/internal/compensation.js +0 -92
- package/dist/history/internal/item-mapper.d.ts +0 -9
- package/dist/history/internal/item-mapper.js +0 -27
- package/dist/history/internal/keys.d.ts +0 -16
- package/dist/history/internal/keys.js +0 -48
- package/dist/history/internal/message-chunker.d.ts +0 -13
- package/dist/history/internal/message-chunker.js +0 -67
- package/dist/history/internal/message-transaction.d.ts +0 -25
- package/dist/history/internal/message-transaction.js +0 -61
- package/dist/history/internal/message-window.d.ts +0 -17
- package/dist/history/internal/message-window.js +0 -49
- package/dist/history/internal/query.d.ts +0 -23
- package/dist/history/internal/query.js +0 -39
- package/dist/history/internal/session-count.d.ts +0 -47
- package/dist/history/internal/session-count.js +0 -115
- package/dist/history/internal/session-title.d.ts +0 -19
- package/dist/history/internal/session-title.js +0 -43
- package/dist/history/internal/session-update.d.ts +0 -27
- package/dist/history/internal/session-update.js +0 -69
- package/dist/history/internal/setup.d.ts +0 -31
- package/dist/history/internal/setup.js +0 -43
- package/dist/history/internal/title-generator.d.ts +0 -12
- package/dist/history/internal/title-generator.js +0 -41
- package/dist/history/internal/ttl-anchor.d.ts +0 -24
- package/dist/history/internal/ttl-anchor.js +0 -38
- package/dist/history/internal/validation.d.ts +0 -25
- package/dist/history/internal/validation.js +0 -53
- package/dist/history/session-adapter.d.ts +0 -29
- package/dist/history/session-adapter.js +0 -35
- package/dist/history/types.d.ts +0 -69
- package/dist/index.d.ts +0 -29
- package/dist/index.js +0 -32
- package/dist/shared/clock.d.ts +0 -8
- package/dist/shared/clock.js +0 -16
- package/dist/shared/codec/codec.d.ts +0 -53
- package/dist/shared/codec/codec.js +0 -66
- package/dist/shared/codec/compression.d.ts +0 -24
- package/dist/shared/codec/compression.js +0 -48
- package/dist/shared/codec/descriptor-keys.d.ts +0 -12
- package/dist/shared/codec/descriptor-keys.js +0 -14
- package/dist/shared/codec/encode.d.ts +0 -13
- package/dist/shared/codec/encode.js +0 -43
- package/dist/shared/codec/json-serde.d.ts +0 -7
- package/dist/shared/codec/json-serde.js +0 -17
- package/dist/shared/codec/payload-loss.d.ts +0 -12
- package/dist/shared/codec/payload-loss.js +0 -38
- package/dist/shared/codec/s3/adapter-config.d.ts +0 -13
- package/dist/shared/codec/s3/adapter-config.js +0 -22
- package/dist/shared/codec/s3/bounded-body.d.ts +0 -14
- package/dist/shared/codec/s3/bounded-body.js +0 -47
- package/dist/shared/codec/s3/client.d.ts +0 -18
- package/dist/shared/codec/s3/client.js +0 -46
- package/dist/shared/codec/s3/config.d.ts +0 -51
- package/dist/shared/codec/s3/config.js +0 -58
- package/dist/shared/codec/s3/delete.d.ts +0 -7
- package/dist/shared/codec/s3/delete.js +0 -28
- package/dist/shared/codec/s3/key-scope.d.ts +0 -23
- package/dist/shared/codec/s3/key-scope.js +0 -44
- package/dist/shared/codec/s3/lifecycle.d.ts +0 -14
- package/dist/shared/codec/s3/lifecycle.js +0 -63
- package/dist/shared/codec/s3/offloader.d.ts +0 -44
- package/dist/shared/codec/s3/offloader.js +0 -118
- package/dist/shared/codec/s3/orphans.d.ts +0 -23
- package/dist/shared/codec/s3/orphans.js +0 -71
- package/dist/shared/codec/s3/read-write.d.ts +0 -18
- package/dist/shared/codec/s3/read-write.js +0 -51
- package/dist/shared/codec/s3/retry.d.ts +0 -5
- package/dist/shared/codec/s3/retry.js +0 -22
- package/dist/shared/concurrency.d.ts +0 -6
- package/dist/shared/constants.d.ts +0 -112
- package/dist/shared/constants.js +0 -115
- package/dist/shared/dynamodb/abort.d.ts +0 -9
- package/dist/shared/dynamodb/abort.js +0 -27
- package/dist/shared/dynamodb/backoff.d.ts +0 -15
- package/dist/shared/dynamodb/backoff.js +0 -48
- package/dist/shared/dynamodb/batch-write.d.ts +0 -22
- package/dist/shared/dynamodb/batch-write.js +0 -53
- package/dist/shared/dynamodb/cancellation.d.ts +0 -6
- package/dist/shared/dynamodb/cancellation.js +0 -7
- package/dist/shared/dynamodb/client.d.ts +0 -28
- package/dist/shared/dynamodb/conditional-put.d.ts +0 -67
- package/dist/shared/dynamodb/conditional-put.js +0 -76
- package/dist/shared/dynamodb/drain-unprocessed.d.ts +0 -21
- package/dist/shared/dynamodb/drain-unprocessed.js +0 -43
- package/dist/shared/dynamodb/expiry.d.ts +0 -16
- package/dist/shared/dynamodb/expiry.js +0 -29
- package/dist/shared/dynamodb/paginate-core.d.ts +0 -24
- package/dist/shared/dynamodb/paginate-core.js +0 -82
- package/dist/shared/dynamodb/paginate.d.ts +0 -14
- package/dist/shared/dynamodb/paginate.js +0 -19
- package/dist/shared/dynamodb/partition-delete.d.ts +0 -39
- package/dist/shared/dynamodb/partition-delete.js +0 -71
- package/dist/shared/dynamodb/retry-classifier.d.ts +0 -17
- package/dist/shared/dynamodb/retry-classifier.js +0 -118
- package/dist/shared/dynamodb/retry-policy.d.ts +0 -26
- package/dist/shared/dynamodb/retry-policy.js +0 -22
- package/dist/shared/dynamodb/retry.d.ts +0 -31
- package/dist/shared/dynamodb/retry.js +0 -57
- package/dist/shared/dynamodb/scan.d.ts +0 -14
- package/dist/shared/dynamodb/scan.js +0 -19
- package/dist/shared/dynamodb/types.d.ts +0 -23
- package/dist/shared/errors/base-error.d.ts +0 -30
- package/dist/shared/errors/base-error.js +0 -27
- package/dist/shared/errors/boundary.d.ts +0 -18
- package/dist/shared/errors/boundary.js +0 -46
- package/dist/shared/errors/error-code.d.ts +0 -13
- package/dist/shared/errors/errors.d.ts +0 -68
- package/dist/shared/errors/errors.js +0 -114
- package/dist/shared/errors/upstream-error.d.ts +0 -16
- package/dist/shared/errors/upstream-error.js +0 -27
- package/dist/shared/errors/wrap-error.d.ts +0 -7
- package/dist/shared/errors/wrap-error.js +0 -15
- package/dist/shared/logging/logger.d.ts +0 -18
- package/dist/shared/logging/logger.js +0 -15
- package/dist/shared/logging/redaction-walk.d.ts +0 -23
- package/dist/shared/logging/redaction-walk.js +0 -112
- package/dist/shared/logging/redaction.d.ts +0 -39
- package/dist/shared/logging/redaction.js +0 -75
- package/dist/shared/logging/secret-patterns.d.ts +0 -92
- package/dist/shared/logging/secret-patterns.js +0 -133
- package/dist/shared/options.d.ts +0 -37
- package/dist/shared/ulid.d.ts +0 -23
- package/dist/shared/validation/options.d.ts +0 -8
- package/dist/shared/validation/options.js +0 -90
- package/dist/shared/validation/primitives.d.ts +0 -29
- package/dist/shared/validation/primitives.js +0 -82
- package/dist/shared/validation/ttl.d.ts +0 -28
- package/dist/shared/validation/ttl.js +0 -52
- package/dist/store/actions/get.d.ts +0 -13
- package/dist/store/actions/get.js +0 -73
- package/dist/store/actions/list-namespaces.d.ts +0 -8
- package/dist/store/actions/list-namespaces.js +0 -59
- package/dist/store/actions/put.d.ts +0 -10
- package/dist/store/actions/put.js +0 -96
- package/dist/store/actions/reconcile-vector-index.d.ts +0 -18
- package/dist/store/actions/reconcile-vector-index.js +0 -26
- package/dist/store/actions/search.d.ts +0 -9
- package/dist/store/actions/search.js +0 -34
- package/dist/store/internal/backend-search.d.ts +0 -4
- package/dist/store/internal/backend-search.js +0 -74
- package/dist/store/internal/batch-plan.d.ts +0 -11
- package/dist/store/internal/batch-plan.js +0 -52
- package/dist/store/internal/candidates.d.ts +0 -23
- package/dist/store/internal/candidates.js +0 -94
- package/dist/store/internal/filter.d.ts +0 -9
- package/dist/store/internal/filter.js +0 -85
- package/dist/store/internal/index-reconcile.d.ts +0 -21
- package/dist/store/internal/index-reconcile.js +0 -118
- package/dist/store/internal/index-sync.d.ts +0 -10
- package/dist/store/internal/index-sync.js +0 -25
- package/dist/store/internal/item-mapper.d.ts +0 -27
- package/dist/store/internal/item-mapper.js +0 -61
- package/dist/store/internal/keys.d.ts +0 -17
- package/dist/store/internal/keys.js +0 -41
- package/dist/store/internal/namespace-match.d.ts +0 -11
- package/dist/store/internal/namespace-match.js +0 -40
- package/dist/store/internal/option-validation.d.ts +0 -13
- package/dist/store/internal/option-validation.js +0 -77
- package/dist/store/internal/overwrite-swap.d.ts +0 -32
- package/dist/store/internal/overwrite-swap.js +0 -68
- package/dist/store/internal/persist.d.ts +0 -28
- package/dist/store/internal/persist.js +0 -64
- package/dist/store/internal/query.d.ts +0 -11
- package/dist/store/internal/query.js +0 -48
- package/dist/store/internal/ranker.d.ts +0 -18
- package/dist/store/internal/ranker.js +0 -39
- package/dist/store/internal/read-existing.d.ts +0 -23
- package/dist/store/internal/read-existing.js +0 -41
- package/dist/store/internal/score-direction.d.ts +0 -31
- package/dist/store/internal/score-direction.js +0 -38
- package/dist/store/internal/search-filter.d.ts +0 -3
- package/dist/store/internal/search-filter.js +0 -10
- package/dist/store/internal/semantic-search.d.ts +0 -34
- package/dist/store/internal/semantic-search.js +0 -87
- package/dist/store/internal/setup.d.ts +0 -36
- package/dist/store/internal/setup.js +0 -40
- package/dist/store/internal/text-path.d.ts +0 -17
- package/dist/store/internal/validation.d.ts +0 -18
- package/dist/store/internal/validation.js +0 -51
- package/dist/store/internal/write-verify.d.ts +0 -42
- package/dist/store/internal/write-verify.js +0 -71
- package/dist/store/store.d.ts +0 -61
- package/dist/store/store.js +0 -107
- package/dist/store/types.d.ts +0 -50
- package/dist/store/types.js +0 -2
- package/dist/store/vector-backend.d.ts +0 -43
- package/dist/store/vector-backend.js +0 -2
- /package/dist/{checkpointer → cjs/checkpointer}/types.js +0 -0
- /package/dist/{factory → cjs/factory}/types.js +0 -0
- /package/dist/{history → cjs/history}/types.js +0 -0
- /package/dist/{shared → cjs/shared}/options.js +0 -0
- /package/dist/{shared/dynamodb → cjs/store}/types.js +0 -0
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DELETE_CONCURRENCY = void 0;
|
|
4
|
+
exports.namedDescriptor = namedDescriptor;
|
|
5
|
+
exports.deletePartitionRows = deletePartitionRows;
|
|
6
|
+
exports.flushPendingDeletes = flushPendingDeletes;
|
|
7
|
+
const codec_js_1 = require("../codec/codec.js");
|
|
8
|
+
const offloader_js_1 = require("../codec/s3/offloader.js");
|
|
9
|
+
const concurrency_js_1 = require("../concurrency.js");
|
|
10
|
+
const errors_js_1 = require("../errors/errors.js");
|
|
11
|
+
const truncate_js_1 = require("../logging/truncate.js");
|
|
12
|
+
const abort_js_1 = require("./abort.js");
|
|
13
|
+
const batch_write_js_1 = require("./batch-write.js");
|
|
14
|
+
const idempotent_write_js_1 = require("./idempotent-write.js");
|
|
15
|
+
const paginate_js_1 = require("./paginate.js");
|
|
16
|
+
const retry_js_1 = require("./retry.js");
|
|
17
|
+
const table_schema_js_1 = require("./table-schema.js");
|
|
18
|
+
exports.DELETE_CONCURRENCY = 8;
|
|
19
|
+
function namedDescriptor(row, attribute) {
|
|
20
|
+
const descriptor = row[attribute];
|
|
21
|
+
if (descriptor === null || descriptor === undefined)
|
|
22
|
+
return undefined;
|
|
23
|
+
return { attribute, descriptor };
|
|
24
|
+
}
|
|
25
|
+
function pinFor(idAttribute, row, named) {
|
|
26
|
+
if (idAttribute !== undefined) {
|
|
27
|
+
const observed = row[idAttribute];
|
|
28
|
+
if (typeof observed === 'string')
|
|
29
|
+
return (0, idempotent_write_js_1.writeIdGuard)(idAttribute, observed);
|
|
30
|
+
}
|
|
31
|
+
for (const entry of named) {
|
|
32
|
+
const { writeId } = entry.descriptor;
|
|
33
|
+
if (writeId !== undefined)
|
|
34
|
+
return (0, idempotent_write_js_1.writeIdGuard)(entry.attribute, writeId, idempotent_write_js_1.WRITE_ID_ATTRIBUTE);
|
|
35
|
+
}
|
|
36
|
+
return undefined;
|
|
37
|
+
}
|
|
38
|
+
function pendingDelete(options, row) {
|
|
39
|
+
const named = options.descriptorsOf(row);
|
|
40
|
+
return {
|
|
41
|
+
key: (0, table_schema_js_1.rowKeyOf)(row),
|
|
42
|
+
guard: pinFor(options.idAttribute, row, named),
|
|
43
|
+
descriptors: named.map((entry) => entry.descriptor),
|
|
44
|
+
unit: options.unitOf?.(row),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
function unitRefused(options, row, state) {
|
|
48
|
+
const unit = options.unitOf?.(row);
|
|
49
|
+
return unit !== undefined && state.units.has(unit);
|
|
50
|
+
}
|
|
51
|
+
function cancelAmong(failures) {
|
|
52
|
+
return failures.find(abort_js_1.isAbortError);
|
|
53
|
+
}
|
|
54
|
+
async function flushBuffer(options, state) {
|
|
55
|
+
if (state.buffer.length === 0)
|
|
56
|
+
return;
|
|
57
|
+
const tally = await flushPendingDeletes(options, state.buffer.splice(0));
|
|
58
|
+
state.deleted += tally.deleted;
|
|
59
|
+
state.skipped += tally.refused;
|
|
60
|
+
state.attempted += tally.deleted + tally.failures.length;
|
|
61
|
+
for (const unit of tally.refusedUnits)
|
|
62
|
+
state.units.add(unit);
|
|
63
|
+
if (tally.failures.length === 0)
|
|
64
|
+
return;
|
|
65
|
+
const cancelled = cancelAmong(tally.failures);
|
|
66
|
+
if (cancelled !== undefined)
|
|
67
|
+
throw cancelled;
|
|
68
|
+
const { deleted, attempted } = state;
|
|
69
|
+
throw (0, errors_js_1.batchWriteAllIncompleteError)({
|
|
70
|
+
succeeded: deleted,
|
|
71
|
+
total: attempted,
|
|
72
|
+
failures: tally.failures,
|
|
73
|
+
succeededCount: deleted,
|
|
74
|
+
unit: 'row',
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
async function deletePartitionRows(options) {
|
|
78
|
+
const state = { buffer: [], deleted: 0, attempted: 0, skipped: 0, units: new Set() };
|
|
79
|
+
let kind;
|
|
80
|
+
const pages = (0, paginate_js_1.paginateQuery)({
|
|
81
|
+
client: options.client,
|
|
82
|
+
params: options.params,
|
|
83
|
+
retry: options.retry,
|
|
84
|
+
signal: options.signal,
|
|
85
|
+
maxItems: Number.POSITIVE_INFINITY,
|
|
86
|
+
maxIterations: Number.POSITIVE_INFINITY,
|
|
87
|
+
});
|
|
88
|
+
for await (const row of pages) {
|
|
89
|
+
const sortKey = row.SK;
|
|
90
|
+
if (!options.ownsSortKey(sortKey)) {
|
|
91
|
+
state.skipped += 1;
|
|
92
|
+
options.logger.warn(`${options.operation}: left a foreign row in place`, {
|
|
93
|
+
sortKey: (0, truncate_js_1.truncateForLog)(sortKey),
|
|
94
|
+
});
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
const rowKind = options.kindOf?.(row);
|
|
98
|
+
if (rowKind !== kind) {
|
|
99
|
+
await flushBuffer(options, state);
|
|
100
|
+
kind = rowKind;
|
|
101
|
+
}
|
|
102
|
+
if (unitRefused(options, row, state)) {
|
|
103
|
+
state.skipped += 1;
|
|
104
|
+
options.logger.warn(`${options.operation}: skipped a row whose unit was refused`, {
|
|
105
|
+
sortKey: (0, truncate_js_1.truncateForLog)(sortKey),
|
|
106
|
+
});
|
|
107
|
+
continue;
|
|
108
|
+
}
|
|
109
|
+
state.buffer.push(pendingDelete(options, row));
|
|
110
|
+
if (state.buffer.length >= batch_write_js_1.BATCH_WRITE_MAX)
|
|
111
|
+
await flushBuffer(options, state);
|
|
112
|
+
}
|
|
113
|
+
await flushBuffer(options, state);
|
|
114
|
+
const { deleted, skipped } = state;
|
|
115
|
+
options.logger.info(`${options.operation}: deleted rows`, { deleted, skipped });
|
|
116
|
+
return deleted;
|
|
117
|
+
}
|
|
118
|
+
function recordRefusal(deps, row, tally) {
|
|
119
|
+
deps.logger.warn(`${deps.operation}: left a row rewritten since the read`, {
|
|
120
|
+
sortKey: (0, truncate_js_1.truncateForLog)(row.key.SK),
|
|
121
|
+
});
|
|
122
|
+
tally.refused += 1;
|
|
123
|
+
if (row.unit !== undefined)
|
|
124
|
+
tally.refusedUnits.push(row.unit);
|
|
125
|
+
}
|
|
126
|
+
async function settleRow(deps, row, tally) {
|
|
127
|
+
try {
|
|
128
|
+
await (0, retry_js_1.withDynamoDBRetry)((request) => deps.client.delete({
|
|
129
|
+
TableName: deps.tableName,
|
|
130
|
+
Key: row.key,
|
|
131
|
+
...row.guard,
|
|
132
|
+
}, request), deps.retry);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
const rejection = error;
|
|
136
|
+
if (!(0, idempotent_write_js_1.isConditionalCheckFailed)(rejection))
|
|
137
|
+
throw rejection;
|
|
138
|
+
if ((0, idempotent_write_js_1.rejectedRow)(rejection) !== undefined) {
|
|
139
|
+
recordRefusal(deps, row, tally);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
tally.deleted += 1;
|
|
144
|
+
tally.released.push(...row.descriptors);
|
|
145
|
+
}
|
|
146
|
+
async function deleteRow(deps, row, tally) {
|
|
147
|
+
try {
|
|
148
|
+
await settleRow(deps, row, tally);
|
|
149
|
+
}
|
|
150
|
+
catch (error) {
|
|
151
|
+
tally.failures.push(error);
|
|
152
|
+
throw error;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
async function flushPendingDeletes(deps, rows) {
|
|
156
|
+
const tally = {
|
|
157
|
+
deleted: 0,
|
|
158
|
+
refused: 0,
|
|
159
|
+
refusedUnits: [],
|
|
160
|
+
failures: [],
|
|
161
|
+
released: [],
|
|
162
|
+
};
|
|
163
|
+
try {
|
|
164
|
+
await (0, concurrency_js_1.mapWithConcurrency)(rows, exports.DELETE_CONCURRENCY, (row) => deleteRow(deps, row, tally));
|
|
165
|
+
}
|
|
166
|
+
catch {
|
|
167
|
+
}
|
|
168
|
+
if (deps.offloader) {
|
|
169
|
+
await (0, offloader_js_1.cleanUpS3Orphans)(deps.offloader, {
|
|
170
|
+
keys: (0, codec_js_1.collectS3Keys)(tally.released),
|
|
171
|
+
operation: deps.operation,
|
|
172
|
+
logger: deps.logger,
|
|
173
|
+
scope: deps.scope,
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
return tally;
|
|
177
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides the recency index (record 8).
|
|
3
|
+
*
|
|
4
|
+
* A row that a cross-partition listing reaches carries two index keys: a
|
|
5
|
+
* partition that hashes its identity onto one of a fixed number of shards, and
|
|
6
|
+
* a sort key that orders it by time. A listing reads every shard at once,
|
|
7
|
+
* merges them newest first, and hands out an opaque cursor that resumes the
|
|
8
|
+
* merge. The shard function, the key format and the merge are decided here.
|
|
9
|
+
*/
|
|
10
|
+
import { type PageLimit } from '../validation/primitives.js';
|
|
11
|
+
import type { AttributeMap, DynamoDBDocumentLike } from './client.js';
|
|
12
|
+
import { type RetryOptions } from './retry.js';
|
|
13
|
+
/** One page of a recency listing, and where the next one resumes. */
|
|
14
|
+
export interface IndexPage {
|
|
15
|
+
items: AttributeMap[];
|
|
16
|
+
/** Absent when the page is the last one. */
|
|
17
|
+
nextCursor?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Read one page of a recency listing from the index, newest first.
|
|
21
|
+
*
|
|
22
|
+
* Each shard is read one DynamoDB page at a time and the pages are merged row
|
|
23
|
+
* by row: the newest buffered row goes onto the page, and a shard whose buffer
|
|
24
|
+
* runs dry reads its next page before another row is chosen. That is correct
|
|
25
|
+
* because each shard is already sorted and no row is chosen while a shard that
|
|
26
|
+
* may hold a newer one is unread. It is also what bounds memory: a listing
|
|
27
|
+
* holds the page it is building, up to `limit` rows, plus at most one DynamoDB
|
|
28
|
+
* page per shard, and a shard none of whose buffered rows the page takes is
|
|
29
|
+
* never followed. The price is that a dry shard is read again whenever the page
|
|
30
|
+
* still needs a row, even when every row still to come is another shard's,
|
|
31
|
+
* which can cost a query per shard per page whose rows the page never takes.
|
|
32
|
+
* The alternative — one query over an unsharded index — would make every
|
|
33
|
+
* listing hit one partition, which is what the sharding exists to avoid.
|
|
34
|
+
*
|
|
35
|
+
* This replaces a full-table `Scan` with a `FilterExpression`, which consumed
|
|
36
|
+
* read capacity for every row *evaluated*, collected the whole table in memory
|
|
37
|
+
* and sorted it there.
|
|
38
|
+
*
|
|
39
|
+
* Accepts: `limit` — a `PageLimit`, already checked against the package-wide
|
|
40
|
+
* page rule by the caller's parser. `0` returns an empty page with no cursor
|
|
41
|
+
* and issues no query — and is answered here rather than left to the merge,
|
|
42
|
+
* where an empty page with shards still unread would have read
|
|
43
|
+
* `items[items.length - 1]` off an empty array to build the cursor. `cursor`
|
|
44
|
+
* — from a previous page, or none to start at the newest. `shards` — must
|
|
45
|
+
* match what the writers used. `concurrency` — how many shards are queried at
|
|
46
|
+
* once.
|
|
47
|
+
*
|
|
48
|
+
* Returns: the page, newest first, and a `nextCursor` exactly while rows may
|
|
49
|
+
* remain: a shard still buffers a row the page did not take, or has not
|
|
50
|
+
* reported its end. A cursor is never withheld while rows remain, and none is
|
|
51
|
+
* issued once every shard has reported its end, even for a page filled
|
|
52
|
+
* exactly. DynamoDB can still report a `LastEvaluatedKey` on a page that ends
|
|
53
|
+
* at a shard's last row, so the page after such a cursor may come back empty.
|
|
54
|
+
*
|
|
55
|
+
* Throws: `VALIDATION` naming `cursor`; `RESULT_TRUNCATED`
|
|
56
|
+
* for a shard whose pages do not end within `MAX_LOOP_ITERATIONS`; whatever
|
|
57
|
+
* the queries throw, including an `ABORTED` error.
|
|
58
|
+
*
|
|
59
|
+
* Guarantees: at most `concurrency` shards are queried at once; each shard is
|
|
60
|
+
* followed across DynamoDB's 1 MB page boundary, but its next page is read only
|
|
61
|
+
* when its buffer is empty and the page still needs a row, so besides the page
|
|
62
|
+
* being built, up to `limit` rows, no more than one DynamoDB page per shard is
|
|
63
|
+
* held at a time.
|
|
64
|
+
*/
|
|
65
|
+
export declare function queryRecencyIndex(options: IndexQueryOptions): Promise<IndexPage>;
|
|
66
|
+
/**
|
|
67
|
+
* Every row of one adapter's recency index, newest first, page by page.
|
|
68
|
+
*
|
|
69
|
+
* The streaming counterpart of {@link queryRecencyIndex}, for a caller that
|
|
70
|
+
* consumes rows until it has what it needs and then stops. It replaces a
|
|
71
|
+
* full-table `Scan` whose cost scaled with the table rather than with the
|
|
72
|
+
* answer.
|
|
73
|
+
*
|
|
74
|
+
* Accepts: as {@link queryRecencyIndex}, without `limit` and `cursor` — this
|
|
75
|
+
* walks the whole index, paging internally.
|
|
76
|
+
*
|
|
77
|
+
* Returns: an async generator over every row, newest first. An early `break`
|
|
78
|
+
* fetches no further page, so a caller that needs ten rows of a large index
|
|
79
|
+
* pays for one page.
|
|
80
|
+
*
|
|
81
|
+
* Throws: as {@link queryRecencyIndex}.
|
|
82
|
+
*/
|
|
83
|
+
export declare function iterateRecencyIndex(options: Omit<IndexQueryOptions, 'limit' | 'cursor'>): AsyncGenerator<AttributeMap>;
|
|
84
|
+
/**
|
|
85
|
+
* The adapter tags that scope GSI1: the checkpointer's own partition tag, and
|
|
86
|
+
* `SESS` for the history's session rows — not its `HIST` partition tag, which
|
|
87
|
+
* names a whole conversation where this index lists one row of it.
|
|
88
|
+
*/
|
|
89
|
+
export type IndexTag = 'CHKPT' | 'SESS';
|
|
90
|
+
/** How a row appears in the recency index: its adapter's tag, its identity, and its time. */
|
|
91
|
+
export interface IndexTarget {
|
|
92
|
+
tag: IndexTag;
|
|
93
|
+
id: string;
|
|
94
|
+
at: string;
|
|
95
|
+
}
|
|
96
|
+
/** The time a row that recorded none is indexed at, older than anything indexed since. */
|
|
97
|
+
export declare const BACKFILLED_AT = "1970-01-01T00:00:00.000Z";
|
|
98
|
+
/**
|
|
99
|
+
* The time a backfilled row is indexed at.
|
|
100
|
+
*
|
|
101
|
+
* Accepts: `recorded` — the row's own time attribute, whatever it holds.
|
|
102
|
+
*
|
|
103
|
+
* Returns: that time when it is a string, else {@link BACKFILLED_AT}.
|
|
104
|
+
*
|
|
105
|
+
* Throws: nothing.
|
|
106
|
+
*/
|
|
107
|
+
export declare function backfilledAt(recorded: AttributeMap[string]): string;
|
|
108
|
+
/** The index's partition-key attribute: `<tag>#<shard>`, the one name every writer, the backfill and the listing spell. */
|
|
109
|
+
export declare const INDEX_PARTITION_ATTRIBUTE = "gsi1pk";
|
|
110
|
+
/** The index's sort-key attribute: `<updatedAt>#<id>`, or the digest form past the sort-key cap. */
|
|
111
|
+
export declare const INDEX_SORT_ATTRIBUTE = "gsi1sk";
|
|
112
|
+
/** The two attributes a row carries to appear in GSI1. */
|
|
113
|
+
export interface IndexKeys {
|
|
114
|
+
[INDEX_PARTITION_ATTRIBUTE]: string;
|
|
115
|
+
[INDEX_SORT_ATTRIBUTE]: string;
|
|
116
|
+
}
|
|
117
|
+
/** Default number of index partitions per adapter. */
|
|
118
|
+
export declare const DEFAULT_INDEX_SHARDS = 8;
|
|
119
|
+
/**
|
|
120
|
+
* The most shards a recency index may have. The indexed read builds every
|
|
121
|
+
* shard's partition key and issues at least one query per shard, so an
|
|
122
|
+
* unbounded value turns a config typo into an unbounded stream of requests and
|
|
123
|
+
* an out-of-memory crash. How many of those queries run at once is
|
|
124
|
+
* `readConcurrency`.
|
|
125
|
+
*/
|
|
126
|
+
export declare const MAX_INDEX_SHARDS = 1024;
|
|
127
|
+
/**
|
|
128
|
+
* The GSI1 keys for a row that takes part in cross-partition listing.
|
|
129
|
+
*
|
|
130
|
+
* The partition key is the adapter tag plus a shard, because an index keyed by
|
|
131
|
+
* the tag alone is one partition per adapter — a single hot partition, which is
|
|
132
|
+
* worse than the table scan it replaces. AWS names the sharding requirement
|
|
133
|
+
* directly: mapping one identifier onto one partition key "will quickly create
|
|
134
|
+
* partition hot spots", and the answer is a secondary sharding model
|
|
135
|
+
* (https://docs.aws.amazon.com/whitepapers/latest/multi-tenant-saas-storage-strategies/multitenancy-on-dynamodb.html).
|
|
136
|
+
*
|
|
137
|
+
* The sort key leads with an ISO-8601 timestamp, used unparsed: its byte order
|
|
138
|
+
* already is its chronological order, so a recency listing is a key condition
|
|
139
|
+
* rather than an in-memory sort. The row's own id, or its SHA-256 digest once
|
|
140
|
+
* the composed key would pass DynamoDB's 1024-byte sort-key cap
|
|
141
|
+
* ({@link indexSortKey}), follows it, which makes the key total — two rows
|
|
142
|
+
* written in the same millisecond still order, so a cursor can never loop.
|
|
143
|
+
*
|
|
144
|
+
* Accepts: `tag` — the adapter's. `id` — the row's own identifier, which
|
|
145
|
+
* decides its shard and breaks ties in the sort key. `at` — an ISO-8601
|
|
146
|
+
* instant. `shards` — index partitions per adapter, at least 1; fixed for the
|
|
147
|
+
* table's life once rows carry keys, since `backfillRecencyIndex` writes keys
|
|
148
|
+
* only to rows that have none and so can never move a row already on a
|
|
149
|
+
* shard — raising the count is safe, since a listing still queries the old
|
|
150
|
+
* shards too, and lowering it hides the rows already on a dropped shard.
|
|
151
|
+
*
|
|
152
|
+
* Returns: the two index attributes; an id whose composed sort key would pass
|
|
153
|
+
* 1024 bytes is carried as its SHA-256 digest.
|
|
154
|
+
*
|
|
155
|
+
* Throws: `VALIDATION` naming `indexShards` for a count below 1 — the read
|
|
156
|
+
* side built an empty partition list from such a value and reported an empty
|
|
157
|
+
* table full of rows.
|
|
158
|
+
*
|
|
159
|
+
* Guarantees: the same row always lands on the same shard, so a listing that
|
|
160
|
+
* queries every shard sees every row exactly once.
|
|
161
|
+
*/
|
|
162
|
+
export declare function indexKeys(tag: IndexTag, id: string, at: string, shards: number): IndexKeys;
|
|
163
|
+
/**
|
|
164
|
+
* Every index partition of one adapter.
|
|
165
|
+
*
|
|
166
|
+
* Accepts: `shards` — the same count the rows were written with; validated
|
|
167
|
+
* here as it is in {@link indexKeys}, because a listing that silently queried
|
|
168
|
+
* an empty partition list would return nothing for a table full of rows.
|
|
169
|
+
*
|
|
170
|
+
* Returns: one partition key per shard, which a recency listing queries in
|
|
171
|
+
* parallel and merges.
|
|
172
|
+
*
|
|
173
|
+
* Throws: `VALIDATION` naming `indexShards`.
|
|
174
|
+
*/
|
|
175
|
+
export declare function indexPartitions(tag: IndexTag, shards: number): string[];
|
|
176
|
+
/** What a recency listing needs to read one page. */
|
|
177
|
+
export interface IndexQueryOptions {
|
|
178
|
+
client: DynamoDBDocumentLike;
|
|
179
|
+
tableName: string;
|
|
180
|
+
indexName: string;
|
|
181
|
+
tag: IndexTag;
|
|
182
|
+
shards: number;
|
|
183
|
+
/** Shards queried at once: the adapter's `readConcurrency`. */
|
|
184
|
+
concurrency: number;
|
|
185
|
+
/** Rows per page, checked by the caller's parser, so the query does not check it again. */
|
|
186
|
+
limit: PageLimit;
|
|
187
|
+
/** Opaque, from a previous page. */
|
|
188
|
+
cursor?: string;
|
|
189
|
+
retry?: RetryOptions;
|
|
190
|
+
signal?: AbortSignal;
|
|
191
|
+
}
|
|
192
|
+
/** Where one shard stands while a listing builds a page. */
|
|
193
|
+
export interface ShardReader {
|
|
194
|
+
partition: string;
|
|
195
|
+
/**
|
|
196
|
+
* The rows of the shard's last DynamoDB page that are not on the listing's
|
|
197
|
+
* page yet, oldest first, so the newest is the last element and leaves with
|
|
198
|
+
* `pop()`. Never more than one page.
|
|
199
|
+
*/
|
|
200
|
+
buffer: AttributeMap[];
|
|
201
|
+
/** Where the shard's next page starts; absent before its first page. */
|
|
202
|
+
startKey: AttributeMap | undefined;
|
|
203
|
+
/** True once DynamoDB reported no data past the last page read. */
|
|
204
|
+
exhausted: boolean;
|
|
205
|
+
/** DynamoDB pages read from this shard so far. */
|
|
206
|
+
pages: number;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* A reader placed before a shard's first page.
|
|
210
|
+
*
|
|
211
|
+
* Accepts: `partition` — the shard's index partition key.
|
|
212
|
+
*
|
|
213
|
+
* Returns: a reader with an empty buffer that is not exhausted, so a listing
|
|
214
|
+
* reads its first page before choosing any row.
|
|
215
|
+
*
|
|
216
|
+
* Throws: nothing.
|
|
217
|
+
*/
|
|
218
|
+
export declare function shardReader(partition: string): ShardReader;
|
|
219
|
+
/**
|
|
220
|
+
* Read a shard's next DynamoDB page into its buffer.
|
|
221
|
+
*
|
|
222
|
+
* `Limit` bounds the items a `Query` *evaluates*, and a page also stops at
|
|
223
|
+
* 1 MB, so a shard of large rows answers with fewer than `limit` items and a
|
|
224
|
+
* `LastEvaluatedKey`. Taking that short page as the whole shard would drop
|
|
225
|
+
* rows and report the listing complete. The key is kept here
|
|
226
|
+
* instead, and the listing reads the next page once the shard's buffer is empty
|
|
227
|
+
* and its page still needs a row. One page at a time is what bounds a listing's
|
|
228
|
+
* memory to at most one DynamoDB page per shard, besides the page it is
|
|
229
|
+
* building.
|
|
230
|
+
*
|
|
231
|
+
* Accepts: `reader` — its buffer empty and the shard not exhausted. `before` —
|
|
232
|
+
* the sort key to read below, or none for the newest. `limit` — the rows the
|
|
233
|
+
* listing's page still needs, at least 1; the shard cannot contribute more.
|
|
234
|
+
*
|
|
235
|
+
* Returns: nothing. The reader's buffer holds the page's rows, and its key,
|
|
236
|
+
* `exhausted` and page count describe what is left.
|
|
237
|
+
*
|
|
238
|
+
* Throws: `RESULT_TRUNCATED` naming `maxIterations`, without issuing
|
|
239
|
+
* a query, when the shard has already read {@link MAX_LOOP_ITERATIONS} pages —
|
|
240
|
+
* a listing fails rather than hand back a partial shard; whatever the query
|
|
241
|
+
* throws, including an `ABORTED` error.
|
|
242
|
+
*/
|
|
243
|
+
export declare function readShardPage(options: IndexQueryOptions, reader: ShardReader, before: string | undefined, limit: number): Promise<void>;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_INDEX_SHARDS = exports.DEFAULT_INDEX_SHARDS = exports.INDEX_SORT_ATTRIBUTE = exports.INDEX_PARTITION_ATTRIBUTE = exports.BACKFILLED_AT = void 0;
|
|
4
|
+
exports.queryRecencyIndex = queryRecencyIndex;
|
|
5
|
+
exports.iterateRecencyIndex = iterateRecencyIndex;
|
|
6
|
+
exports.backfilledAt = backfilledAt;
|
|
7
|
+
exports.indexKeys = indexKeys;
|
|
8
|
+
exports.indexPartitions = indexPartitions;
|
|
9
|
+
exports.shardReader = shardReader;
|
|
10
|
+
exports.readShardPage = readShardPage;
|
|
11
|
+
const node_crypto_1 = require("node:crypto");
|
|
12
|
+
const concurrency_js_1 = require("../concurrency.js");
|
|
13
|
+
const errors_js_1 = require("../errors/errors.js");
|
|
14
|
+
const primitives_js_1 = require("../validation/primitives.js");
|
|
15
|
+
const paginate_js_1 = require("./paginate.js");
|
|
16
|
+
const retry_js_1 = require("./retry.js");
|
|
17
|
+
const table_schema_js_1 = require("./table-schema.js");
|
|
18
|
+
function encodeCursor(sortKey) {
|
|
19
|
+
return Buffer.from(sortKey, 'utf8').toString('base64url');
|
|
20
|
+
}
|
|
21
|
+
function decodeCursor(cursor) {
|
|
22
|
+
const decoded = Buffer.from(cursor, 'base64url').toString('utf8');
|
|
23
|
+
if (!decoded.includes('#')) {
|
|
24
|
+
throw (0, errors_js_1.validationError)('cursor is not one this adapter issued', 'cursor');
|
|
25
|
+
}
|
|
26
|
+
return decoded;
|
|
27
|
+
}
|
|
28
|
+
function isDry(reader) {
|
|
29
|
+
return reader.buffer.length === 0 && !reader.exhausted;
|
|
30
|
+
}
|
|
31
|
+
async function refillDryShards(options, readers, before, needed) {
|
|
32
|
+
for (let dry = readers.filter(isDry); dry.length > 0; dry = readers.filter(isDry)) {
|
|
33
|
+
await (0, concurrency_js_1.mapWithConcurrency)(dry, options.concurrency, (reader) => readShardPage(options, reader, before, needed));
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function takeNewest(readers) {
|
|
37
|
+
let newest;
|
|
38
|
+
let newestKey = '';
|
|
39
|
+
for (const reader of readers) {
|
|
40
|
+
const head = reader.buffer[reader.buffer.length - 1];
|
|
41
|
+
if (head !== undefined && (0, table_schema_js_1.compareSortKeys)(head.gsi1sk, newestKey) > 0) {
|
|
42
|
+
newest = reader;
|
|
43
|
+
newestKey = head.gsi1sk;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return newest?.buffer.pop();
|
|
47
|
+
}
|
|
48
|
+
async function queryRecencyIndex(options) {
|
|
49
|
+
if (options.limit === 0)
|
|
50
|
+
return { items: [] };
|
|
51
|
+
const before = options.cursor === undefined ? undefined : decodeCursor(options.cursor);
|
|
52
|
+
const readers = indexPartitions(options.tag, options.shards).map((partition) => shardReader(partition));
|
|
53
|
+
const items = [];
|
|
54
|
+
while (items.length < options.limit) {
|
|
55
|
+
await refillDryShards(options, readers, before, options.limit - items.length);
|
|
56
|
+
const row = takeNewest(readers);
|
|
57
|
+
if (row === undefined)
|
|
58
|
+
break;
|
|
59
|
+
items.push(row);
|
|
60
|
+
}
|
|
61
|
+
const remain = readers.some((reader) => reader.buffer.length > 0 || !reader.exhausted);
|
|
62
|
+
return {
|
|
63
|
+
items,
|
|
64
|
+
...(remain ? { nextCursor: encodeCursor(items[items.length - 1].gsi1sk) } : {}),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const STREAM_PAGE_SIZE = (0, primitives_js_1.parseLimit)(100, 0);
|
|
68
|
+
async function* iterateRecencyIndex(options) {
|
|
69
|
+
let cursor;
|
|
70
|
+
do {
|
|
71
|
+
const page = await queryRecencyIndex({ ...options, limit: STREAM_PAGE_SIZE, cursor });
|
|
72
|
+
for (const item of page.items)
|
|
73
|
+
yield item;
|
|
74
|
+
cursor = page.nextCursor;
|
|
75
|
+
} while (cursor !== undefined);
|
|
76
|
+
}
|
|
77
|
+
exports.BACKFILLED_AT = '1970-01-01T00:00:00.000Z';
|
|
78
|
+
function backfilledAt(recorded) {
|
|
79
|
+
return typeof recorded === 'string' ? recorded : exports.BACKFILLED_AT;
|
|
80
|
+
}
|
|
81
|
+
exports.INDEX_PARTITION_ATTRIBUTE = 'gsi1pk';
|
|
82
|
+
exports.INDEX_SORT_ATTRIBUTE = 'gsi1sk';
|
|
83
|
+
exports.DEFAULT_INDEX_SHARDS = 8;
|
|
84
|
+
exports.MAX_INDEX_SHARDS = 1024;
|
|
85
|
+
function fnv1a(value) {
|
|
86
|
+
let hash = 0x811c9dc5;
|
|
87
|
+
for (let i = 0; i < value.length; i++) {
|
|
88
|
+
hash ^= value.charCodeAt(i);
|
|
89
|
+
hash = Math.imul(hash, 0x01000193) >>> 0;
|
|
90
|
+
}
|
|
91
|
+
return hash >>> 0;
|
|
92
|
+
}
|
|
93
|
+
function assertShardCount(shards) {
|
|
94
|
+
if (!Number.isInteger(shards) || shards < 1) {
|
|
95
|
+
throw (0, errors_js_1.validationError)(`indexShards must be a positive integer (received ${shards}); a non-positive value would ` +
|
|
96
|
+
'make every row share one index partition or produce an unusable key', 'indexShards');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
function indexSortKey(at, id) {
|
|
100
|
+
const verbatim = `${at}#${id}`;
|
|
101
|
+
if (Buffer.byteLength(verbatim, 'utf8') <= table_schema_js_1.MAX_SORT_KEY_BYTES)
|
|
102
|
+
return verbatim;
|
|
103
|
+
return `${at}#sha256:${(0, node_crypto_1.createHash)('sha256').update(id, 'utf8').digest('hex')}`;
|
|
104
|
+
}
|
|
105
|
+
function indexKeys(tag, id, at, shards) {
|
|
106
|
+
assertShardCount(shards);
|
|
107
|
+
return {
|
|
108
|
+
gsi1pk: `${tag}#${fnv1a(id) % shards}`,
|
|
109
|
+
gsi1sk: indexSortKey(at, id),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
function indexPartitions(tag, shards) {
|
|
113
|
+
assertShardCount(shards);
|
|
114
|
+
return Array.from({ length: shards }, (_unused, shard) => `${tag}#${shard}`);
|
|
115
|
+
}
|
|
116
|
+
function shardReader(partition) {
|
|
117
|
+
return { partition, buffer: [], startKey: undefined, exhausted: false, pages: 0 };
|
|
118
|
+
}
|
|
119
|
+
function shardQuery(options, reader, before, limit) {
|
|
120
|
+
return {
|
|
121
|
+
TableName: options.tableName,
|
|
122
|
+
IndexName: options.indexName,
|
|
123
|
+
KeyConditionExpression: before === undefined ? '#pk = :pk' : '#pk = :pk AND #sk < :before',
|
|
124
|
+
ExpressionAttributeNames: {
|
|
125
|
+
'#pk': exports.INDEX_PARTITION_ATTRIBUTE,
|
|
126
|
+
...(before === undefined ? {} : { '#sk': exports.INDEX_SORT_ATTRIBUTE }),
|
|
127
|
+
},
|
|
128
|
+
ExpressionAttributeValues: {
|
|
129
|
+
':pk': reader.partition,
|
|
130
|
+
...(before === undefined ? {} : { ':before': before }),
|
|
131
|
+
},
|
|
132
|
+
ScanIndexForward: false,
|
|
133
|
+
Limit: limit,
|
|
134
|
+
...(reader.startKey === undefined ? {} : { ExclusiveStartKey: reader.startKey }),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
async function readShardPage(options, reader, before, limit) {
|
|
138
|
+
if (reader.pages >= paginate_js_1.MAX_LOOP_ITERATIONS) {
|
|
139
|
+
throw (0, errors_js_1.resultTruncatedError)('maxIterations', paginate_js_1.MAX_LOOP_ITERATIONS);
|
|
140
|
+
}
|
|
141
|
+
const result = await (0, retry_js_1.withDynamoDBRetry)((request) => options.client.query(shardQuery(options, reader, before, limit), request), { ...options.retry, signal: options.signal });
|
|
142
|
+
reader.pages += 1;
|
|
143
|
+
reader.buffer = (result.Items ?? []).slice().reverse();
|
|
144
|
+
reader.startKey = result.LastEvaluatedKey;
|
|
145
|
+
reader.exhausted = reader.startKey === undefined;
|
|
146
|
+
}
|