@farukada/aws-langgraph-dynamodb-ts 1.0.0-rc.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +390 -193
- package/dist/{backfill → cjs/backfill}/backfill.d.ts +15 -12
- package/dist/cjs/backfill/backfill.js +177 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/delete-thread.d.ts +1 -1
- package/dist/cjs/checkpointer/actions/delete-thread.js +26 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/get-tuple.d.ts +4 -3
- package/dist/cjs/checkpointer/actions/get-tuple.js +22 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/list.d.ts +7 -4
- package/dist/cjs/checkpointer/actions/list.js +70 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/put-writes.d.ts +8 -6
- package/dist/cjs/checkpointer/actions/put-writes.js +21 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/put.d.ts +21 -15
- package/dist/cjs/checkpointer/actions/put.js +79 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/delta-history.d.ts +38 -26
- package/dist/cjs/checkpointer/internal/delta-history.js +131 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/listing.d.ts +4 -4
- package/dist/cjs/checkpointer/internal/listing.js +104 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/parse.d.ts +51 -15
- package/dist/cjs/checkpointer/internal/parse.js +184 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/pending-writes.d.ts +64 -25
- package/dist/cjs/checkpointer/internal/pending-writes.js +241 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/read.d.ts +15 -10
- package/dist/cjs/checkpointer/internal/read.js +132 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/rows.d.ts +94 -21
- package/dist/cjs/checkpointer/internal/rows.js +356 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/setup.d.ts +13 -20
- package/dist/cjs/checkpointer/internal/setup.js +25 -0
- package/dist/{checkpointer → cjs/checkpointer}/saver.d.ts +72 -36
- package/dist/cjs/checkpointer/saver.js +56 -0
- package/dist/{checkpointer → cjs/checkpointer}/types.d.ts +1 -1
- package/dist/cjs/checkpointer/types.js +2 -0
- package/dist/{factory → cjs/factory}/factory.d.ts +25 -20
- package/dist/cjs/factory/factory.js +137 -0
- package/dist/{factory → cjs/factory}/types.d.ts +12 -12
- package/dist/cjs/factory/types.js +2 -0
- package/dist/{history → cjs/history}/actions/add-messages.d.ts +18 -10
- package/dist/cjs/history/actions/add-messages.js +17 -0
- package/dist/{history → cjs/history}/actions/clear.d.ts +1 -1
- package/dist/cjs/history/actions/clear.js +29 -0
- package/dist/{history → cjs/history}/actions/get-messages.d.ts +11 -9
- package/dist/cjs/history/actions/get-messages.js +58 -0
- package/dist/{history → cjs/history}/actions/list-sessions.d.ts +3 -3
- package/dist/cjs/history/actions/list-sessions.js +67 -0
- package/dist/{history → cjs/history}/actions/reconcile-count.d.ts +13 -9
- package/dist/cjs/history/actions/reconcile-count.js +8 -0
- package/dist/{history → cjs/history}/chat-message-history.d.ts +62 -30
- package/dist/cjs/history/chat-message-history.js +61 -0
- package/dist/{history → cjs/history}/internal/append.d.ts +64 -32
- package/dist/cjs/history/internal/append.js +267 -0
- package/dist/{history → cjs/history}/internal/message-read.d.ts +3 -3
- package/dist/cjs/history/internal/message-read.js +93 -0
- package/dist/{history → cjs/history}/internal/parse.d.ts +2 -2
- package/dist/cjs/history/internal/parse.js +113 -0
- package/dist/{history → cjs/history}/internal/rows.d.ts +11 -10
- package/dist/cjs/history/internal/rows.js +96 -0
- package/dist/{history → cjs/history}/internal/session.d.ts +41 -22
- package/dist/cjs/history/internal/session.js +296 -0
- package/dist/{history → cjs/history}/internal/setup.d.ts +2 -2
- package/dist/cjs/history/internal/setup.js +60 -0
- package/dist/{history → cjs/history}/session-adapter.d.ts +0 -6
- package/dist/cjs/history/session-adapter.js +38 -0
- package/dist/{history → cjs/history}/types.d.ts +18 -15
- package/dist/cjs/history/types.js +2 -0
- package/dist/{index.d.ts → cjs/index.d.ts} +27 -27
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/package.json +1 -0
- package/dist/{shared → cjs/shared}/adapter.d.ts +27 -16
- package/dist/cjs/shared/adapter.js +70 -0
- package/dist/cjs/shared/clock.js +14 -0
- package/dist/{shared → cjs/shared}/codec/codec.d.ts +37 -20
- package/dist/cjs/shared/codec/codec.js +162 -0
- package/dist/{shared → cjs/shared}/codec/compression.d.ts +9 -4
- package/dist/cjs/shared/codec/compression.js +45 -0
- package/dist/cjs/shared/codec/json-serde.js +58 -0
- package/dist/{shared → cjs/shared}/codec/s3/client-types.d.ts +2 -1
- package/dist/cjs/shared/codec/s3/client-types.js +6 -0
- package/dist/{shared → cjs/shared}/codec/s3/client.d.ts +25 -7
- package/dist/cjs/shared/codec/s3/client.js +78 -0
- package/dist/{shared → cjs/shared}/codec/s3/config.d.ts +12 -7
- package/dist/cjs/shared/codec/s3/config.js +92 -0
- package/dist/{shared → cjs/shared}/codec/s3/lifecycle.d.ts +71 -17
- package/dist/cjs/shared/codec/s3/lifecycle.js +223 -0
- package/dist/{shared → cjs/shared}/codec/s3/offloader.d.ts +42 -29
- package/dist/cjs/shared/codec/s3/offloader.js +289 -0
- package/dist/cjs/shared/concurrency.js +31 -0
- package/dist/{shared → cjs/shared}/dynamodb/abort.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/abort.js +16 -0
- package/dist/{shared → cjs/shared}/dynamodb/batch-write.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/batch-write.js +79 -0
- package/dist/cjs/shared/dynamodb/cancellation.js +37 -0
- package/dist/{shared → cjs/shared}/dynamodb/client.d.ts +24 -22
- package/dist/cjs/shared/dynamodb/client.js +40 -0
- package/dist/{shared → cjs/shared}/dynamodb/idempotent-write.d.ts +64 -19
- package/dist/cjs/shared/dynamodb/idempotent-write.js +173 -0
- package/dist/{shared → cjs/shared}/dynamodb/paginate.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/paginate.js +90 -0
- package/dist/{shared → cjs/shared}/dynamodb/partition-delete.d.ts +6 -6
- package/dist/cjs/shared/dynamodb/partition-delete.js +177 -0
- package/dist/{shared → cjs/shared}/dynamodb/recency-index.d.ts +27 -15
- package/dist/cjs/shared/dynamodb/recency-index.js +146 -0
- package/dist/{shared → cjs/shared}/dynamodb/retry.d.ts +37 -6
- package/dist/cjs/shared/dynamodb/retry.js +193 -0
- package/dist/cjs/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/cjs/shared/dynamodb/row-size.js +30 -0
- package/dist/{shared → cjs/shared}/dynamodb/table-schema.d.ts +27 -18
- package/dist/cjs/shared/dynamodb/table-schema.js +52 -0
- package/dist/{shared → cjs/shared}/errors/base-error.d.ts +42 -7
- package/dist/cjs/shared/errors/base-error.js +73 -0
- package/dist/{shared → cjs/shared}/errors/boundary.d.ts +29 -14
- package/dist/cjs/shared/errors/boundary.js +61 -0
- package/dist/cjs/shared/errors/classify.d.ts +206 -0
- package/dist/cjs/shared/errors/classify.js +232 -0
- package/dist/{shared → cjs/shared}/errors/error-code.d.ts +17 -10
- package/dist/cjs/shared/errors/error-code.js +27 -0
- package/dist/{shared → cjs/shared}/errors/errors.d.ts +75 -9
- package/dist/cjs/shared/errors/errors.js +123 -0
- package/dist/cjs/shared/logging/logger.js +30 -0
- package/dist/{shared → cjs/shared}/logging/redaction.d.ts +8 -4
- package/dist/cjs/shared/logging/redaction.js +145 -0
- package/dist/{shared → cjs/shared}/logging/secret-patterns.d.ts +30 -7
- package/dist/cjs/shared/logging/secret-patterns.js +93 -0
- package/dist/cjs/shared/logging/truncate.js +31 -0
- package/dist/{shared → cjs/shared}/options.d.ts +27 -11
- package/dist/cjs/shared/options.js +2 -0
- package/dist/cjs/shared/ulid.js +83 -0
- package/dist/{shared → cjs/shared}/validation/collaborators.d.ts +21 -2
- package/dist/cjs/shared/validation/collaborators.js +79 -0
- package/dist/{shared → cjs/shared}/validation/option-shape.d.ts +7 -5
- package/dist/cjs/shared/validation/option-shape.js +31 -0
- package/dist/{shared → cjs/shared}/validation/options.d.ts +4 -4
- package/dist/cjs/shared/validation/options.js +166 -0
- package/dist/cjs/shared/validation/primitives.js +114 -0
- package/dist/{shared → cjs/shared}/validation/ttl.d.ts +26 -9
- package/dist/cjs/shared/validation/ttl.js +52 -0
- package/dist/{store → cjs/store}/actions/list-namespaces.d.ts +5 -5
- package/dist/cjs/store/actions/list-namespaces.js +92 -0
- package/dist/{store → cjs/store}/actions/put.d.ts +11 -4
- package/dist/cjs/store/actions/put.js +49 -0
- package/dist/{store → cjs/store}/actions/reconcile-vector-index.d.ts +5 -5
- package/dist/cjs/store/actions/reconcile-vector-index.js +13 -0
- package/dist/{store → cjs/store}/actions/search.d.ts +2 -2
- package/dist/cjs/store/actions/search.js +26 -0
- package/dist/cjs/store/internal/batch-plan.d.ts +56 -0
- package/dist/cjs/store/internal/batch-plan.js +32 -0
- package/dist/{store → cjs/store}/internal/filter.d.ts +3 -3
- package/dist/cjs/store/internal/filter.js +64 -0
- package/dist/cjs/store/internal/get-item.d.ts +77 -0
- package/dist/cjs/store/internal/get-item.js +58 -0
- package/dist/{store → cjs/store}/internal/item-write.d.ts +72 -32
- package/dist/cjs/store/internal/item-write.js +181 -0
- package/dist/{store → cjs/store}/internal/parse.d.ts +15 -10
- package/dist/cjs/store/internal/parse.js +180 -0
- package/dist/{store → cjs/store}/internal/rows.d.ts +38 -34
- package/dist/cjs/store/internal/rows.js +166 -0
- package/dist/{store → cjs/store}/internal/semantic-search.d.ts +2 -2
- package/dist/cjs/store/internal/semantic-search.js +211 -0
- package/dist/{store → cjs/store}/internal/setup.d.ts +10 -15
- package/dist/cjs/store/internal/setup.js +103 -0
- package/dist/{store → cjs/store}/internal/table-search.d.ts +5 -5
- package/dist/cjs/store/internal/table-search.js +123 -0
- package/dist/{store → cjs/store}/internal/vector-index.d.ts +26 -15
- package/dist/cjs/store/internal/vector-index.js +269 -0
- package/dist/{store → cjs/store}/store.d.ts +82 -39
- package/dist/cjs/store/store.js +97 -0
- package/dist/{store → cjs/store}/types.d.ts +25 -10
- package/dist/cjs/store/types.js +2 -0
- package/dist/cjs/store/vector-backend.js +4 -0
- package/dist/esm/backfill/backfill.d.ts +171 -0
- package/dist/esm/backfill/backfill.js +170 -0
- package/dist/{checkpointer/actions/delete-thread.js → esm/checkpointer/actions/delete-thread.d.ts} +4 -26
- package/dist/esm/checkpointer/actions/delete-thread.js +23 -0
- package/dist/{checkpointer/actions/get-tuple.js → esm/checkpointer/actions/get-tuple.d.ts} +7 -24
- package/dist/esm/checkpointer/actions/get-tuple.js +19 -0
- package/dist/esm/checkpointer/actions/list.d.ts +55 -0
- package/dist/esm/checkpointer/actions/list.js +67 -0
- package/dist/{checkpointer/actions/put-writes.js → esm/checkpointer/actions/put-writes.d.ts} +10 -37
- package/dist/esm/checkpointer/actions/put-writes.js +18 -0
- package/dist/esm/checkpointer/actions/put.d.ts +95 -0
- package/dist/esm/checkpointer/actions/put.js +75 -0
- package/dist/esm/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/esm/checkpointer/internal/delta-history.js +126 -0
- package/dist/{checkpointer/internal/listing.js → esm/checkpointer/internal/listing.d.ts} +22 -118
- package/dist/esm/checkpointer/internal/listing.js +95 -0
- package/dist/esm/checkpointer/internal/parse.d.ts +298 -0
- package/dist/esm/checkpointer/internal/parse.js +169 -0
- package/dist/esm/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/esm/checkpointer/internal/pending-writes.js +229 -0
- package/dist/esm/checkpointer/internal/read.d.ts +135 -0
- package/dist/esm/checkpointer/internal/read.js +125 -0
- package/dist/esm/checkpointer/internal/rows.d.ts +644 -0
- package/dist/esm/checkpointer/internal/rows.js +323 -0
- package/dist/esm/checkpointer/internal/setup.d.ts +47 -0
- package/dist/esm/checkpointer/internal/setup.js +21 -0
- package/dist/{checkpointer/saver.js → esm/checkpointer/saver.d.ts} +84 -87
- package/dist/esm/checkpointer/saver.js +52 -0
- package/dist/esm/checkpointer/types.d.ts +51 -0
- package/dist/esm/checkpointer/types.js +1 -0
- package/dist/esm/factory/factory.d.ts +154 -0
- package/dist/esm/factory/factory.js +133 -0
- package/dist/esm/factory/types.d.ts +76 -0
- package/dist/esm/factory/types.js +1 -0
- package/dist/{history/actions/add-messages.js → esm/history/actions/add-messages.d.ts} +20 -26
- package/dist/esm/history/actions/add-messages.js +14 -0
- package/dist/{history/actions/clear.js → esm/history/actions/clear.d.ts} +4 -35
- package/dist/esm/history/actions/clear.js +26 -0
- package/dist/esm/history/actions/get-messages.d.ts +60 -0
- package/dist/esm/history/actions/get-messages.js +55 -0
- package/dist/esm/history/actions/list-sessions.d.ts +55 -0
- package/dist/esm/history/actions/list-sessions.js +64 -0
- package/dist/{history/actions/reconcile-count.js → esm/history/actions/reconcile-count.d.ts} +14 -16
- package/dist/esm/history/actions/reconcile-count.js +5 -0
- package/dist/{history/chat-message-history.js → esm/history/chat-message-history.d.ts} +76 -87
- package/dist/esm/history/chat-message-history.js +57 -0
- package/dist/esm/history/internal/append.d.ts +244 -0
- package/dist/esm/history/internal/append.js +259 -0
- package/dist/esm/history/internal/message-read.d.ts +84 -0
- package/dist/esm/history/internal/message-read.js +89 -0
- package/dist/esm/history/internal/parse.d.ts +153 -0
- package/dist/esm/history/internal/parse.js +105 -0
- package/dist/{history/internal/rows.js → esm/history/internal/rows.d.ts} +58 -112
- package/dist/esm/history/internal/rows.js +83 -0
- package/dist/esm/history/internal/session.d.ts +350 -0
- package/dist/esm/history/internal/session.js +285 -0
- package/dist/esm/history/internal/setup.d.ts +64 -0
- package/dist/esm/history/internal/setup.js +56 -0
- package/dist/{history/session-adapter.js → esm/history/session-adapter.d.ts} +25 -39
- package/dist/esm/history/session-adapter.js +34 -0
- package/dist/esm/history/types.d.ts +102 -0
- package/dist/esm/history/types.js +1 -0
- package/dist/esm/index.d.ts +53 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/shared/adapter.d.ts +146 -0
- package/dist/esm/shared/adapter.js +65 -0
- package/dist/{shared/clock.js → esm/shared/clock.d.ts} +3 -14
- package/dist/esm/shared/clock.js +9 -0
- package/dist/esm/shared/codec/codec.d.ts +336 -0
- package/dist/esm/shared/codec/codec.js +150 -0
- package/dist/esm/shared/codec/compression.d.ts +66 -0
- package/dist/esm/shared/codec/compression.js +40 -0
- package/dist/esm/shared/codec/json-serde.d.ts +80 -0
- package/dist/esm/shared/codec/json-serde.js +54 -0
- package/dist/esm/shared/codec/s3/client-types.d.ts +54 -0
- package/dist/esm/shared/codec/s3/client-types.js +3 -0
- package/dist/esm/shared/codec/s3/client.d.ts +63 -0
- package/dist/esm/shared/codec/s3/client.js +40 -0
- package/dist/{shared/codec/s3/config.js → esm/shared/codec/s3/config.d.ts} +45 -93
- package/dist/esm/shared/codec/s3/config.js +79 -0
- package/dist/esm/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/esm/shared/codec/s3/lifecycle.js +214 -0
- package/dist/esm/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/esm/shared/codec/s3/offloader.js +278 -0
- package/dist/{shared/concurrency.js → esm/shared/concurrency.d.ts} +2 -37
- package/dist/esm/shared/concurrency.js +27 -0
- package/dist/{shared/dynamodb/abort.js → esm/shared/dynamodb/abort.d.ts} +4 -16
- package/dist/esm/shared/dynamodb/abort.js +12 -0
- package/dist/esm/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/esm/shared/dynamodb/batch-write.js +74 -0
- package/dist/{shared/dynamodb/cancellation.js → esm/shared/dynamodb/cancellation.d.ts} +25 -53
- package/dist/esm/shared/dynamodb/cancellation.js +30 -0
- package/dist/{shared/dynamodb/client.js → esm/shared/dynamodb/client.d.ts} +74 -64
- package/dist/esm/shared/dynamodb/client.js +35 -0
- package/dist/{shared/dynamodb/idempotent-write.js → esm/shared/dynamodb/idempotent-write.d.ts} +172 -169
- package/dist/esm/shared/dynamodb/idempotent-write.js +153 -0
- package/dist/esm/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/esm/shared/dynamodb/paginate.js +84 -0
- package/dist/esm/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/esm/shared/dynamodb/partition-delete.js +171 -0
- package/dist/esm/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/esm/shared/dynamodb/recency-index.js +136 -0
- package/dist/esm/shared/dynamodb/retry.d.ts +317 -0
- package/dist/esm/shared/dynamodb/retry.js +180 -0
- package/dist/esm/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/esm/shared/dynamodb/row-size.js +26 -0
- package/dist/{shared/dynamodb/table-schema.js → esm/shared/dynamodb/table-schema.d.ts} +57 -67
- package/dist/esm/shared/dynamodb/table-schema.js +43 -0
- package/dist/esm/shared/errors/base-error.d.ts +231 -0
- package/dist/esm/shared/errors/base-error.js +64 -0
- package/dist/esm/shared/errors/boundary.d.ts +86 -0
- package/dist/esm/shared/errors/boundary.js +54 -0
- package/dist/esm/shared/errors/classify.d.ts +206 -0
- package/dist/esm/shared/errors/classify.js +220 -0
- package/dist/{shared/errors/error-code.js → esm/shared/errors/error-code.d.ts} +39 -43
- package/dist/esm/shared/errors/error-code.js +24 -0
- package/dist/{shared/errors/errors.js → esm/shared/errors/errors.d.ts} +92 -98
- package/dist/esm/shared/errors/errors.js +110 -0
- package/dist/{shared/logging/logger.js → esm/shared/logging/logger.d.ts} +22 -52
- package/dist/esm/shared/logging/logger.js +25 -0
- package/dist/esm/shared/logging/redaction.d.ts +123 -0
- package/dist/esm/shared/logging/redaction.js +140 -0
- package/dist/{shared/logging/secret-patterns.js → esm/shared/logging/secret-patterns.d.ts} +46 -87
- package/dist/esm/shared/logging/secret-patterns.js +83 -0
- package/dist/{shared/logging/truncate.js → esm/shared/logging/truncate.d.ts} +6 -40
- package/dist/esm/shared/logging/truncate.js +25 -0
- package/dist/esm/shared/options.d.ts +100 -0
- package/dist/esm/shared/options.js +1 -0
- package/dist/{shared/ulid.js → esm/shared/ulid.d.ts} +4 -84
- package/dist/esm/shared/ulid.js +77 -0
- package/dist/{shared/validation/collaborators.js → esm/shared/validation/collaborators.d.ts} +37 -65
- package/dist/esm/shared/validation/collaborators.js +70 -0
- package/dist/{shared/validation/option-shape.js → esm/shared/validation/option-shape.d.ts} +14 -36
- package/dist/esm/shared/validation/option-shape.js +24 -0
- package/dist/esm/shared/validation/options.d.ts +145 -0
- package/dist/esm/shared/validation/options.js +156 -0
- package/dist/{shared/validation/primitives.js → esm/shared/validation/primitives.d.ts} +30 -125
- package/dist/esm/shared/validation/primitives.js +100 -0
- package/dist/esm/shared/validation/ttl.d.ts +94 -0
- package/dist/esm/shared/validation/ttl.js +46 -0
- package/dist/esm/store/actions/list-namespaces.d.ts +79 -0
- package/dist/esm/store/actions/list-namespaces.js +86 -0
- package/dist/esm/store/actions/put.d.ts +43 -0
- package/dist/esm/store/actions/put.js +46 -0
- package/dist/{store/actions/reconcile-vector-index.js → esm/store/actions/reconcile-vector-index.d.ts} +8 -16
- package/dist/esm/store/actions/reconcile-vector-index.js +10 -0
- package/dist/esm/store/actions/search.d.ts +38 -0
- package/dist/esm/store/actions/search.js +23 -0
- package/dist/esm/store/internal/batch-plan.d.ts +56 -0
- package/dist/esm/store/internal/batch-plan.js +28 -0
- package/dist/esm/store/internal/filter.d.ts +43 -0
- package/dist/esm/store/internal/filter.js +60 -0
- package/dist/esm/store/internal/get-item.d.ts +77 -0
- package/dist/esm/store/internal/get-item.js +54 -0
- package/dist/esm/store/internal/item-write.d.ts +270 -0
- package/dist/esm/store/internal/item-write.js +173 -0
- package/dist/esm/store/internal/parse.d.ts +230 -0
- package/dist/esm/store/internal/parse.js +169 -0
- package/dist/{store/internal/rows.js → esm/store/internal/rows.d.ts} +111 -199
- package/dist/esm/store/internal/rows.js +147 -0
- package/dist/esm/store/internal/semantic-search.d.ts +168 -0
- package/dist/esm/store/internal/semantic-search.js +200 -0
- package/dist/esm/store/internal/setup.d.ts +96 -0
- package/dist/esm/store/internal/setup.js +98 -0
- package/dist/esm/store/internal/table-search.d.ts +100 -0
- package/dist/esm/store/internal/table-search.js +119 -0
- package/dist/esm/store/internal/vector-index.d.ts +258 -0
- package/dist/esm/store/internal/vector-index.js +256 -0
- package/dist/{store/store.js → esm/store/store.d.ts} +99 -133
- package/dist/esm/store/store.js +93 -0
- package/dist/esm/store/types.d.ts +111 -0
- package/dist/esm/store/types.js +1 -0
- package/dist/esm/store/vector-backend.d.ts +104 -0
- package/dist/esm/store/vector-backend.js +1 -0
- package/package.json +50 -44
- package/dist/backfill/backfill.js +0 -393
- package/dist/checkpointer/actions/list.js +0 -142
- package/dist/checkpointer/actions/put.js +0 -195
- package/dist/checkpointer/internal/delta-history.js +0 -252
- package/dist/checkpointer/internal/parse.js +0 -372
- package/dist/checkpointer/internal/pending-writes.js +0 -588
- package/dist/checkpointer/internal/read.js +0 -264
- package/dist/checkpointer/internal/rows.js +0 -834
- package/dist/checkpointer/internal/setup.js +0 -72
- package/dist/checkpointer/types.js +0 -12
- package/dist/factory/factory.js +0 -266
- package/dist/factory/types.js +0 -10
- package/dist/history/actions/get-messages.js +0 -141
- package/dist/history/actions/list-sessions.js +0 -156
- package/dist/history/internal/append.js +0 -500
- package/dist/history/internal/message-read.js +0 -204
- package/dist/history/internal/parse.js +0 -252
- package/dist/history/internal/session.js +0 -628
- package/dist/history/internal/setup.js +0 -106
- package/dist/history/types.js +0 -12
- package/dist/index.js +0 -51
- package/dist/shared/adapter.js +0 -143
- package/dist/shared/codec/codec.js +0 -441
- package/dist/shared/codec/compression.js +0 -89
- package/dist/shared/codec/json-serde.js +0 -191
- package/dist/shared/codec/s3/client-types.js +0 -26
- package/dist/shared/codec/s3/client.js +0 -97
- package/dist/shared/codec/s3/lifecycle.js +0 -355
- package/dist/shared/codec/s3/offloader.js +0 -658
- package/dist/shared/dynamodb/batch-write.js +0 -173
- package/dist/shared/dynamodb/paginate.js +0 -188
- package/dist/shared/dynamodb/partition-delete.js +0 -340
- package/dist/shared/dynamodb/recency-index.js +0 -377
- package/dist/shared/dynamodb/retry.js +0 -463
- package/dist/shared/errors/base-error.js +0 -174
- package/dist/shared/errors/boundary.js +0 -143
- package/dist/shared/errors/classify.d.ts +0 -97
- package/dist/shared/errors/classify.js +0 -257
- package/dist/shared/logging/redaction.js +0 -316
- package/dist/shared/options.js +0 -11
- package/dist/shared/validation/options.js +0 -328
- package/dist/shared/validation/ttl.js +0 -132
- package/dist/store/actions/list-namespaces.js +0 -197
- package/dist/store/actions/put.js +0 -78
- package/dist/store/actions/search.js +0 -66
- package/dist/store/internal/batch-plan.d.ts +0 -26
- package/dist/store/internal/batch-plan.js +0 -109
- package/dist/store/internal/filter.js +0 -137
- package/dist/store/internal/get-item.d.ts +0 -45
- package/dist/store/internal/get-item.js +0 -115
- package/dist/store/internal/item-write.js +0 -463
- package/dist/store/internal/parse.js +0 -350
- package/dist/store/internal/semantic-search.js +0 -389
- package/dist/store/internal/setup.js +0 -223
- package/dist/store/internal/table-search.js +0 -213
- package/dist/store/internal/vector-index.js +0 -546
- package/dist/store/types.js +0 -15
- package/dist/store/vector-backend.js +0 -17
- /package/dist/{shared → cjs/shared}/clock.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/codec/json-serde.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/concurrency.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/dynamodb/cancellation.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/logging/logger.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/logging/truncate.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/ulid.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/validation/primitives.d.ts +0 -0
- /package/dist/{store → cjs/store}/vector-backend.d.ts +0 -0
|
@@ -1,173 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Hides BatchWriteItem.
|
|
4
|
-
*
|
|
5
|
-
* A call carries at most twenty-five requests, and the service may hand some
|
|
6
|
-
* back unprocessed; they are re-sent with backoff until a bound, and a batch
|
|
7
|
-
* that still cannot finish is reported with how much of it did.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.MAX_UNPROCESSED_RETRIES = exports.BATCH_WRITE_MAX = void 0;
|
|
11
|
-
exports.batchWriteAll = batchWriteAll;
|
|
12
|
-
exports.drainUnprocessedWrites = drainUnprocessedWrites;
|
|
13
|
-
const base_error_1 = require("../errors/base-error");
|
|
14
|
-
const error_code_1 = require("../errors/error-code");
|
|
15
|
-
const errors_1 = require("../errors/errors");
|
|
16
|
-
const abort_1 = require("./abort");
|
|
17
|
-
const retry_1 = require("./retry");
|
|
18
|
-
/**
|
|
19
|
-
* DynamoDB BatchWriteItem maximum requests per call.
|
|
20
|
-
*
|
|
21
|
-
* @see https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_BatchWriteItem.html
|
|
22
|
-
*/
|
|
23
|
-
exports.BATCH_WRITE_MAX = 25;
|
|
24
|
-
/** Maximum retries draining UnprocessedItems / UnprocessedKeys. */
|
|
25
|
-
exports.MAX_UNPROCESSED_RETRIES = 10;
|
|
26
|
-
/**
|
|
27
|
-
* Write an arbitrary number of requests, chunked into batches of 25 (the
|
|
28
|
-
* BatchWriteItem limit). Every chunk is attempted regardless of an earlier
|
|
29
|
-
* chunk's failure — order-independent writes (deletes/puts) should never
|
|
30
|
-
* lose "later" chunks just because an earlier one failed. If any chunk fails,
|
|
31
|
-
* throws `BATCH_WRITE_INCOMPLETE` reporting exactly how many
|
|
32
|
-
* chunks succeeded vs. failed, and exactly how many individual writes
|
|
33
|
-
* persisted, once every chunk has been attempted.
|
|
34
|
-
*
|
|
35
|
-
* Accepts: `requests` — any number, in any order, of writes that do not depend
|
|
36
|
-
* on each other; none is a no-op. `options` — the drain's retry budget and
|
|
37
|
-
* signal.
|
|
38
|
-
*
|
|
39
|
-
* Returns: nothing, and only when every request persisted.
|
|
40
|
-
*
|
|
41
|
-
* Throws: `ABORTED` the moment a chunk reports one, unwrapped and with no
|
|
42
|
-
* further chunk attempted — a caller who cancelled did not encounter a fault,
|
|
43
|
-
* and spending the remaining requests on a cancelled call is the opposite of
|
|
44
|
-
* what the cancel asked for. Otherwise `BATCH_WRITE_INCOMPLETE`,
|
|
45
|
-
* once every chunk has been attempted, reporting how many chunks succeeded and
|
|
46
|
-
* how many individual writes persisted. Its one caller — the rollback in
|
|
47
|
-
* history/internal/append.ts — type-asserts a caught error straight to
|
|
48
|
-
* its code's details (not `instanceof`, banned repo-wide) instead of
|
|
49
|
-
* narrowing it, on the narrower guarantee that it passes no signal, so the
|
|
50
|
-
* abort path cannot arise there; a call site that does pass one must narrow
|
|
51
|
-
* instead.
|
|
52
|
-
*
|
|
53
|
-
* Guarantees: every chunk is attempted regardless of an earlier chunk's
|
|
54
|
-
* failure — these writes are order-independent, so losing the later ones to an
|
|
55
|
-
* earlier failure would delete less than the caller asked and report no more
|
|
56
|
-
* for it. A cancel is the one exception, because it is not a failure. The
|
|
57
|
-
* count the error carries is exact, which is what lets a compensating caller
|
|
58
|
-
* revert precisely what landed, and it never counts a chunk whose error
|
|
59
|
-
* carried no count of its own.
|
|
60
|
-
*/
|
|
61
|
-
async function batchWriteAll(client, tableName, requests, options = {}) {
|
|
62
|
-
const totalChunks = Math.ceil(requests.length / exports.BATCH_WRITE_MAX);
|
|
63
|
-
let succeededChunks = 0;
|
|
64
|
-
let succeededCount = 0;
|
|
65
|
-
const failedChunks = [];
|
|
66
|
-
for (let offset = 0; offset < requests.length; offset += exports.BATCH_WRITE_MAX) {
|
|
67
|
-
const chunk = requests.slice(offset, offset + exports.BATCH_WRITE_MAX);
|
|
68
|
-
try {
|
|
69
|
-
await drainUnprocessedWrites(client, tableName, chunk, options);
|
|
70
|
-
succeededChunks += 1;
|
|
71
|
-
succeededCount += chunk.length;
|
|
72
|
-
}
|
|
73
|
-
catch (error) {
|
|
74
|
-
const failure = error;
|
|
75
|
-
// Anything but an incomplete batch is the drain's other documented
|
|
76
|
-
// throw, a cancel, and it leaves the loop at once. Reading the brand and
|
|
77
|
-
// code rather than the class is the same realm-safe test the rest of
|
|
78
|
-
// this package makes, and it is what keeps a count this function cannot
|
|
79
|
-
// know out of the total: adding an absent `succeededCount` made it
|
|
80
|
-
// `NaN`.
|
|
81
|
-
if (!(0, base_error_1.hasErrorCode)(failure, error_code_1.ErrorCode.BATCH_WRITE_INCOMPLETE))
|
|
82
|
-
throw failure;
|
|
83
|
-
failedChunks.push(failure);
|
|
84
|
-
succeededCount += failure.details.succeededCount;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
if (failedChunks.length > 0) {
|
|
88
|
-
throw (0, errors_1.batchWriteAllIncompleteError)({
|
|
89
|
-
succeeded: succeededChunks,
|
|
90
|
-
total: totalChunks,
|
|
91
|
-
failures: failedChunks,
|
|
92
|
-
succeededCount,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
/**
|
|
97
|
-
* The backoff window between rounds: the adapter's configured policy, never
|
|
98
|
-
* module constants — reading the constants here instead would leave a caller
|
|
99
|
-
* who raises `baseDelayMs` still waiting the module's default 100 ms on this
|
|
100
|
-
* one path, breaking the documented "one policy governs every wait".
|
|
101
|
-
*/
|
|
102
|
-
function drainBackoff(retry) {
|
|
103
|
-
return {
|
|
104
|
-
base: retry?.baseDelayMs ?? retry_1.INITIAL_BACKOFF_DELAY_MS,
|
|
105
|
-
max: retry?.maxDelayMs ?? retry_1.MAX_BACKOFF_DELAY_MS,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* The error a failed round raises.
|
|
110
|
-
*
|
|
111
|
-
* An `ABORTED` error passes through unchanged: a caller who cancelled did not get
|
|
112
|
-
* an incomplete batch write, and wrapping it reported
|
|
113
|
-
* `BATCH_WRITE_INCOMPLETE` for an aborted `deleteThread`, contradicting the
|
|
114
|
-
* `ABORTED` every cancellable method documents. Anything else becomes a
|
|
115
|
-
* `BATCH_WRITE_INCOMPLETE` error carrying what did persist.
|
|
116
|
-
*/
|
|
117
|
-
function drainFailure(error, succeededCount, pending, retries) {
|
|
118
|
-
if ((0, abort_1.isAbortError)(error))
|
|
119
|
-
return error;
|
|
120
|
-
return (0, errors_1.batchWriteIncompleteError)(succeededCount, pending, retries, error);
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Write `requests` with `BatchWriteItem`, re-submitting what DynamoDB returns
|
|
124
|
-
* as `UnprocessedItems` until the batch drains.
|
|
125
|
-
*
|
|
126
|
-
* Accepts: `requests` — any length, including empty, which issues no request.
|
|
127
|
-
* `options.maxRetries` — re-submission rounds, default
|
|
128
|
-
* {@link MAX_UNPROCESSED_RETRIES}. `options.retry` — the adapter's policy, whose
|
|
129
|
-
* `baseDelayMs` and `maxDelayMs` set the backoff between rounds, so one policy
|
|
130
|
-
* governs every wait this package performs. `options.signal` — aborts a wait.
|
|
131
|
-
*
|
|
132
|
-
* Returns: nothing; success means every request persisted.
|
|
133
|
-
*
|
|
134
|
-
* Throws: `BATCH_WRITE_INCOMPLETE` when the batch does not drain
|
|
135
|
-
* within the rounds allowed, or when a round's write call fails outright — its
|
|
136
|
-
* `succeededCount` is every earlier round's confirmed persists and the
|
|
137
|
-
* triggering error is the `cause`. An `ABORTED` error passes through unchanged: a
|
|
138
|
-
* caller who cancelled did not get an incomplete batch write, and every
|
|
139
|
-
* cancellable method documents `ABORTED`.
|
|
140
|
-
*
|
|
141
|
-
* Guarantees: **every** error this function throws is one of those two — a
|
|
142
|
-
* `BATCH_WRITE_INCOMPLETE` error carrying an accurate `succeededCount`, or an
|
|
143
|
-
* `ABORTED` error. {@link batchWriteAll} adds up those counts across chunks and
|
|
144
|
-
* depends on it.
|
|
145
|
-
*/
|
|
146
|
-
async function drainUnprocessedWrites(client, tableName, requests, options = {}) {
|
|
147
|
-
if (requests.length === 0)
|
|
148
|
-
return;
|
|
149
|
-
const maxRetries = options.maxRetries ?? exports.MAX_UNPROCESSED_RETRIES;
|
|
150
|
-
const initialCount = requests.length;
|
|
151
|
-
const { base: baseDelay, max: maxDelay } = drainBackoff(options.retry);
|
|
152
|
-
let pending = requests;
|
|
153
|
-
let delay = baseDelay;
|
|
154
|
-
let retries = 0;
|
|
155
|
-
while (pending.length > 0) {
|
|
156
|
-
try {
|
|
157
|
-
const result = await (0, retry_1.withDynamoDBRetry)((request) => client.batchWrite({ RequestItems: { [tableName]: pending } }, request), { ...options.retry, signal: options.signal });
|
|
158
|
-
const leftover = result.UnprocessedItems?.[tableName] ?? [];
|
|
159
|
-
if (leftover.length === 0)
|
|
160
|
-
return;
|
|
161
|
-
pending = leftover;
|
|
162
|
-
retries += 1;
|
|
163
|
-
if (retries > maxRetries)
|
|
164
|
-
break;
|
|
165
|
-
await (0, retry_1.sleep)((0, retry_1.fullJitter)(delay, options.rng), options.signal);
|
|
166
|
-
delay = (0, retry_1.nextBackoffDelay)(delay, maxDelay);
|
|
167
|
-
}
|
|
168
|
-
catch (error) {
|
|
169
|
-
throw drainFailure(error, initialCount - pending.length, pending, retries);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
throw (0, errors_1.batchWriteIncompleteError)(initialCount - pending.length, pending, maxRetries);
|
|
173
|
-
}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Hides that a Query or a Scan is many pages.
|
|
4
|
-
*
|
|
5
|
-
* A read receives rows one at a time and never sees a page boundary. How many
|
|
6
|
-
* rows and pages it may collect before it refuses with `RESULT_TRUNCATED`
|
|
7
|
-
* rather than truncating silently, how a read that stopped exactly at its row
|
|
8
|
-
* cap probes whether anything remained, and where cancellation is checked
|
|
9
|
-
* between pages are decided here, the same way for a Query and a Scan.
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.LIST_SCAN_WARN_THRESHOLD = exports.MAX_TOTAL_ROWS_IN_MEMORY = exports.MAX_LOOP_ITERATIONS = void 0;
|
|
13
|
-
exports.paginateQuery = paginateQuery;
|
|
14
|
-
exports.paginatePages = paginatePages;
|
|
15
|
-
exports.paginateScan = paginateScan;
|
|
16
|
-
const errors_1 = require("../errors/errors");
|
|
17
|
-
const abort_1 = require("./abort");
|
|
18
|
-
const retry_1 = require("./retry");
|
|
19
|
-
/** Hard cap on query-pagination loop iterations (runaway-loop guard). */
|
|
20
|
-
exports.MAX_LOOP_ITERATIONS = 1000;
|
|
21
|
-
/** Hard cap on rows collected into memory across a paginated query. */
|
|
22
|
-
exports.MAX_TOTAL_ROWS_IN_MEMORY = 10000;
|
|
23
|
-
/**
|
|
24
|
-
* Raw rows a single `listCheckpoints` call may pull before it warns. The read
|
|
25
|
-
* itself is deliberately unbounded: capping it would count raw rows rather
|
|
26
|
-
* than filter-matched ones, so a caller asking for a handful of rare matches
|
|
27
|
-
* over a large thread would get a hard error instead of the true answer. The
|
|
28
|
-
* warning gives the operational signal without that wrong error.
|
|
29
|
-
*
|
|
30
|
-
* Its own literal, deliberately: this is the point at which a scan is worth
|
|
31
|
-
* telling an operator about, which is independent of
|
|
32
|
-
* {@link MAX_TOTAL_ROWS_IN_MEMORY}'s hard collection cap. Aliasing the two —
|
|
33
|
-
* so one reused the other's literal — would let retuning the memory cap
|
|
34
|
-
* silently move the warning threshold too, for constants that answer
|
|
35
|
-
* unrelated questions, and would make knip report the pair as a duplicate
|
|
36
|
-
* export.
|
|
37
|
-
*/
|
|
38
|
-
exports.LIST_SCAN_WARN_THRESHOLD = 10000;
|
|
39
|
-
/**
|
|
40
|
-
* Every row a Query returns, across all its pages.
|
|
41
|
-
*
|
|
42
|
-
* Accepts: `params` — the Query input; `ExclusiveStartKey` is set per page and
|
|
43
|
-
* anything the caller put there is replaced. `retry` and `signal` are applied
|
|
44
|
-
* to each page read, `maxItems` / `maxIterations` to the walk (see
|
|
45
|
-
* {@link paginatePages}).
|
|
46
|
-
*
|
|
47
|
-
* Returns: an async generator over the rows, following `LastEvaluatedKey`
|
|
48
|
-
* until it is absent. A page carrying no `Items` is an empty page, not the end.
|
|
49
|
-
*
|
|
50
|
-
* Throws: whatever the page read throws, plus the caps and abort behaviour of
|
|
51
|
-
* {@link paginatePages}.
|
|
52
|
-
*/
|
|
53
|
-
function paginateQuery(options) {
|
|
54
|
-
return paginatePages(async (startKey) => {
|
|
55
|
-
const page = await (0, retry_1.withDynamoDBRetry)((request) => options.client.query({ ...options.params, ExclusiveStartKey: startKey }, request), { ...options.retry, signal: options.signal });
|
|
56
|
-
return {
|
|
57
|
-
items: page.Items ?? [],
|
|
58
|
-
lastKey: page.LastEvaluatedKey,
|
|
59
|
-
};
|
|
60
|
-
}, options);
|
|
61
|
-
}
|
|
62
|
-
/** Read the next page, honouring the abort signal and the iteration cap first. */
|
|
63
|
-
async function readPage(reader, startKey) {
|
|
64
|
-
if (reader.iterations >= reader.maxIterations) {
|
|
65
|
-
throw (0, errors_1.resultTruncatedError)('maxIterations', reader.maxIterations);
|
|
66
|
-
}
|
|
67
|
-
if (reader.signal?.aborted)
|
|
68
|
-
throw (0, abort_1.abortErrorFrom)(reader.signal);
|
|
69
|
-
reader.iterations += 1;
|
|
70
|
-
return reader.fetchPage(startKey);
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Yield one page's rows, counting toward the shared `state.yielded` budget.
|
|
74
|
-
* Reaching the cap with unyielded rows still on the page is a truncation;
|
|
75
|
-
* reaching it on the last row is reported as `capped` for the caller to settle.
|
|
76
|
-
*
|
|
77
|
-
* Synchronous and private: nothing here awaits, and `paginatePages` delegates
|
|
78
|
-
* to it with `yield*` from inside its own `async function*`, so the rows it
|
|
79
|
-
* yields still reach callers through the same async-generator protocol.
|
|
80
|
-
*/
|
|
81
|
-
function* yieldPageRows(page, state, maxItems) {
|
|
82
|
-
for (let index = 0; index < page.items.length; index++) {
|
|
83
|
-
yield page.items[index];
|
|
84
|
-
state.yielded += 1;
|
|
85
|
-
if (state.yielded >= maxItems) {
|
|
86
|
-
if (index < page.items.length - 1)
|
|
87
|
-
throw (0, errors_1.resultTruncatedError)('maxItems', maxItems);
|
|
88
|
-
return 'capped';
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return 'exhausted';
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Whether anything remains past `startKey`. DynamoDB returns a
|
|
95
|
-
* `LastEvaluatedKey` whenever it stopped *evaluating* at the 1 MB boundary,
|
|
96
|
-
* whether or not a later item passes the filter, so a trailing key alone proves
|
|
97
|
-
* nothing: the keys are followed until a page carries an item (truncated) or
|
|
98
|
-
* they run out (the result was complete). The probe is charged against the same
|
|
99
|
-
* iteration budget and honours the same signal as the read itself.
|
|
100
|
-
*/
|
|
101
|
-
async function dataRemains(reader, startKey) {
|
|
102
|
-
let key = startKey;
|
|
103
|
-
while (key !== undefined) {
|
|
104
|
-
const page = await readPage(reader, key);
|
|
105
|
-
if (page.items.length > 0)
|
|
106
|
-
return true;
|
|
107
|
-
key = page.lastKey;
|
|
108
|
-
}
|
|
109
|
-
return false;
|
|
110
|
-
}
|
|
111
|
-
/** Reject a cap that admits nothing; `Infinity` is the way to ask for no cap. */
|
|
112
|
-
function assertPositiveCap(value, field) {
|
|
113
|
-
if (!(value >= 1)) {
|
|
114
|
-
throw (0, errors_1.validationError)(`${field} must be at least 1 (pass Infinity to read to completion)`, field);
|
|
115
|
-
}
|
|
116
|
-
return value;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Drive a paged DynamoDB read to completion, yielding each item.
|
|
120
|
-
*
|
|
121
|
-
* Accepts: `fetchPage` — performs one page read from a start key.
|
|
122
|
-
* `options.maxItems` — how many items may be yielded, default
|
|
123
|
-
* {@link MAX_TOTAL_ROWS_IN_MEMORY}. `options.maxIterations` — how many page
|
|
124
|
-
* reads may be issued, default {@link MAX_LOOP_ITERATIONS}; the probe below is
|
|
125
|
-
* charged against it too. Both accept `Infinity` to read to true completion
|
|
126
|
-
* (deletes do), and both must otherwise be at least 1 — an accepted cap of 0
|
|
127
|
-
* would yield one item before noticing. `options.signal` — checked before every
|
|
128
|
-
* fetch. `options.retry` is the page reader's own concern.
|
|
129
|
-
*
|
|
130
|
-
* Returns: an async generator over the items, continuing past empty pages.
|
|
131
|
-
*
|
|
132
|
-
* Throws: `VALIDATION` naming `maxItems` or `maxIterations` for a cap below
|
|
133
|
-
* 1; `ABORTED` when the signal is already aborted at a page boundary; and
|
|
134
|
-
* `RESULT_TRUNCATED` when a cap is reached while data actually
|
|
135
|
-
* remains — a partial result is never returned silently.
|
|
136
|
-
*
|
|
137
|
-
* Guarantees: reaching `maxItems` on the last item of a page is not by itself a
|
|
138
|
-
* truncation. DynamoDB returns a `LastEvaluatedKey` whenever it stopped
|
|
139
|
-
* *evaluating* at the 1 MB boundary, whether or not a later item passes the
|
|
140
|
-
* filter, so the remaining keys are followed until one carries an item
|
|
141
|
-
* (truncated) or they run out (the result was complete).
|
|
142
|
-
*/
|
|
143
|
-
async function* paginatePages(fetchPage, options = {}) {
|
|
144
|
-
const maxItems = assertPositiveCap(options.maxItems ?? exports.MAX_TOTAL_ROWS_IN_MEMORY, 'maxItems');
|
|
145
|
-
const reader = {
|
|
146
|
-
fetchPage,
|
|
147
|
-
maxIterations: assertPositiveCap(options.maxIterations ?? exports.MAX_LOOP_ITERATIONS, 'maxIterations'),
|
|
148
|
-
iterations: 0,
|
|
149
|
-
signal: options.signal,
|
|
150
|
-
};
|
|
151
|
-
const state = { yielded: 0 };
|
|
152
|
-
let startKey;
|
|
153
|
-
for (;;) {
|
|
154
|
-
const page = await readPage(reader, startKey);
|
|
155
|
-
const outcome = yield* yieldPageRows(page, state, maxItems);
|
|
156
|
-
if (outcome === 'capped') {
|
|
157
|
-
if (await dataRemains(reader, page.lastKey))
|
|
158
|
-
throw (0, errors_1.resultTruncatedError)('maxItems', maxItems);
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
startKey = page.lastKey;
|
|
162
|
-
if (startKey === undefined)
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Every item a Scan returns, across all its pages.
|
|
168
|
-
*
|
|
169
|
-
* Accepts: as {@link paginateQuery}; only the request differs.
|
|
170
|
-
*
|
|
171
|
-
* Returns: as {@link paginateQuery} — an async generator over the items, which
|
|
172
|
-
* a consumer may abandon early to stop reading.
|
|
173
|
-
*
|
|
174
|
-
* Throws: as {@link paginateQuery}.
|
|
175
|
-
*
|
|
176
|
-
* A `Scan` reads every row of the table before filtering, so the four reads
|
|
177
|
-
* allowed to call this are fixed and guarded; `test/static/guards/scan-sites.ts`
|
|
178
|
-
* lists them and states the rule they follow.
|
|
179
|
-
*/
|
|
180
|
-
function paginateScan(options) {
|
|
181
|
-
return paginatePages(async (startKey) => {
|
|
182
|
-
const page = await (0, retry_1.withDynamoDBRetry)((request) => options.client.scan({ ...options.params, ExclusiveStartKey: startKey }, request), { ...options.retry, signal: options.signal });
|
|
183
|
-
return {
|
|
184
|
-
items: page.Items ?? [],
|
|
185
|
-
lastKey: page.LastEvaluatedKey,
|
|
186
|
-
};
|
|
187
|
-
}, options);
|
|
188
|
-
}
|