@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,316 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Hides how a logger and a value are redacted.
|
|
4
|
-
*
|
|
5
|
-
* A redacting logger walks every argument of every line, bounded in depth and
|
|
6
|
-
* safe against cycles and hostile getters, and replaces the value of any key
|
|
7
|
-
* that looks like a secret and any text that looks like one; the same walk
|
|
8
|
-
* serves `redactSecrets` for a value a caller wants to log themselves.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.redactSecrets = redactSecrets;
|
|
12
|
-
exports.redactLogger = redactLogger;
|
|
13
|
-
exports.walkObject = walkObject;
|
|
14
|
-
const errors_1 = require("../errors/errors");
|
|
15
|
-
const collaborators_1 = require("../validation/collaborators");
|
|
16
|
-
const option_shape_1 = require("../validation/option-shape");
|
|
17
|
-
const primitives_1 = require("../validation/primitives");
|
|
18
|
-
const logger_1 = require("./logger");
|
|
19
|
-
const secret_patterns_1 = require("./secret-patterns");
|
|
20
|
-
/** Substituted for a log argument whose redaction itself failed (a throwing getter, say). */
|
|
21
|
-
const UNREDACTABLE = '[UNREDACTABLE]';
|
|
22
|
-
/**
|
|
23
|
-
* Reject a list of value shapes this package could not apply.
|
|
24
|
-
*
|
|
25
|
-
* Accepts: `value` — the list as the caller gave it. `field` — what the error
|
|
26
|
-
* names.
|
|
27
|
-
*
|
|
28
|
-
* Returns: nothing: the value is kept under its declared type, and this
|
|
29
|
-
* checks it. An empty list is valid, and is how a caller turns value matching
|
|
30
|
-
* off.
|
|
31
|
-
*
|
|
32
|
-
* Throws: `VALIDATION` naming `field` for a non-array or an entry that is
|
|
33
|
-
* not a `RegExp`. {@link redactText} skips such an entry, which protects
|
|
34
|
-
* nothing while the caller believes it does, so it is refused where it is
|
|
35
|
-
* supplied instead.
|
|
36
|
-
*/
|
|
37
|
-
function assertRegExpArray(value, field) {
|
|
38
|
-
if (!Array.isArray(value) || value.some((entry) => !(0, secret_patterns_1.isRegExp)(entry))) {
|
|
39
|
-
throw (0, errors_1.validationError)(`${field} must be an array of RegExp`, field);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Recursively clone `value`, replacing any value at a secret-looking key with
|
|
44
|
-
* `[REDACTED]` and any recognised secret *shape* inside a string — including an
|
|
45
|
-
* error's `message`/`stack` text, which key-name matching cannot reach — with
|
|
46
|
-
* the same marker. Cycles become `[Circular]`.
|
|
47
|
-
*
|
|
48
|
-
* An Error with no own enumerable properties whose text holds no secret is
|
|
49
|
-
* passed through by reference, so its identity and stack trace survive; one
|
|
50
|
-
* carrying own data (this library's error types all attach `code`/`context`
|
|
51
|
-
* this way) or a secret in its text is rebuilt instead, with `name`/`message`/
|
|
52
|
-
* `stack` redacted and every other own property recursed like a plain object.
|
|
53
|
-
* `Date`/`RegExp` keep their identity rather than collapsing to `{}`,
|
|
54
|
-
* `Set`/`Map` render as their contents, and binary views become a short label.
|
|
55
|
-
*
|
|
56
|
-
* Accepts: `value` — any log argument, including `undefined`, a primitive, a
|
|
57
|
-
* typed `Error`, a class instance or a `Record`, so callers never cast. A
|
|
58
|
-
* cyclic or shared graph is fine; each node is walked once. `patterns` and
|
|
59
|
-
* `valuePatterns` — the key names and value shapes to redact, an array of
|
|
60
|
-
* strings and an array of `RegExp` respectively; both default to this
|
|
61
|
-
* package's own lists, and an empty one turns that rule off.
|
|
62
|
-
*
|
|
63
|
-
* Returns: a redacted clone. The input is never mutated — a logger that
|
|
64
|
-
* scrubbed the caller's own object would corrupt the very data the application
|
|
65
|
-
* is working with.
|
|
66
|
-
*
|
|
67
|
-
* Throws: `VALIDATION` naming `patterns` or `valuePatterns` for a list this
|
|
68
|
-
* function could not apply, which is a mistake in the call itself and is
|
|
69
|
-
* raised before anything is walked. Nothing after that: a value whose
|
|
70
|
-
* redaction fails — a throwing getter, a structure deep enough to exhaust the
|
|
71
|
-
* stack — is replaced whole by `[UNREDACTABLE]`, since a logger that throws
|
|
72
|
-
* takes down the operation it was only observing. {@link redactLogger}
|
|
73
|
-
* redacts one argument per call, so there a single hostile argument is what is
|
|
74
|
-
* lost rather than the record around it.
|
|
75
|
-
*/
|
|
76
|
-
function redactSecrets(value, patterns = secret_patterns_1.DEFAULT_SECRET_KEY_PATTERNS, valuePatterns = secret_patterns_1.DEFAULT_SECRET_VALUE_PATTERNS) {
|
|
77
|
-
(0, primitives_1.assertStringArray)(patterns, 'patterns');
|
|
78
|
-
assertRegExpArray(valuePatterns, 'valuePatterns');
|
|
79
|
-
// `walking` detects a cycle; `done` memoises a finished node. Both are
|
|
80
|
-
// needed and they answer different questions. A guard that only removed a
|
|
81
|
-
// node when its subtree finished is correct for cycles but re-walks every
|
|
82
|
-
// node reachable by more than one path, so a graph that merely *shares*
|
|
83
|
-
// structure — not even a cycle — costs exponential time: without `done`, a
|
|
84
|
-
// few dozen shared objects in a sub-kilobyte argument would block the event
|
|
85
|
-
// loop for minutes, and this is a public export reachable from caller code.
|
|
86
|
-
const walking = new WeakSet();
|
|
87
|
-
const done = new WeakMap();
|
|
88
|
-
const walk = (current) => {
|
|
89
|
-
if (typeof current === 'string')
|
|
90
|
-
return (0, secret_patterns_1.redactText)(current, valuePatterns);
|
|
91
|
-
if (current === null || typeof current !== 'object')
|
|
92
|
-
return current;
|
|
93
|
-
if (done.has(current))
|
|
94
|
-
return done.get(current);
|
|
95
|
-
if (walking.has(current))
|
|
96
|
-
return '[Circular]';
|
|
97
|
-
walking.add(current);
|
|
98
|
-
try {
|
|
99
|
-
const redacted = walkObject(current, { keyPatterns: patterns, valuePatterns, walk });
|
|
100
|
-
done.set(current, redacted);
|
|
101
|
-
return redacted;
|
|
102
|
-
}
|
|
103
|
-
finally {
|
|
104
|
-
walking.delete(current);
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
try {
|
|
108
|
-
return walk(value);
|
|
109
|
-
}
|
|
110
|
-
catch {
|
|
111
|
-
// Every failure of the walk yields the marker: a `RangeError` from nesting
|
|
112
|
-
// deeper than the stack holds, and equally a getter of the caller's own
|
|
113
|
-
// that throws. Telling the two apart served no caller. The value is being
|
|
114
|
-
// prepared for a log line, and the log line is typically written from a
|
|
115
|
-
// `catch`, so a throw here does not report the hostile value — it replaces
|
|
116
|
-
// the failure that was being reported with a `TypeError` about a getter.
|
|
117
|
-
return UNREDACTABLE;
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Reject redaction options that would silently fail to redact.
|
|
122
|
-
*
|
|
123
|
-
* A non-string in `extraKeys` reached `key.toLowerCase()` and raised a bare
|
|
124
|
-
* `TypeError` at the first log call; a non-`RegExp` in `extraValuePatterns` is
|
|
125
|
-
* skipped by {@link redactText} and would have protected nothing while the
|
|
126
|
-
* caller believed it did. An `options` that is not an object at all carried no
|
|
127
|
-
* rule to begin with, and was read as "none given", leaving the caller running
|
|
128
|
-
* on a default it believed it had overridden. All three are refused here,
|
|
129
|
-
* once, where they are configured.
|
|
130
|
-
*
|
|
131
|
-
* Accepts: `options` — as the caller gave it.
|
|
132
|
-
*
|
|
133
|
-
* Returns: nothing: the value is kept under its declared type, and this
|
|
134
|
-
* checks it.
|
|
135
|
-
*
|
|
136
|
-
* Throws: `VALIDATION` naming `options`, `extraKeys` or `extraValuePatterns`.
|
|
137
|
-
*/
|
|
138
|
-
function assertRedactionOptions(options) {
|
|
139
|
-
(0, option_shape_1.assertObjectShape)(options, 'options');
|
|
140
|
-
if (options.extraKeys !== undefined)
|
|
141
|
-
(0, primitives_1.assertStringArray)(options.extraKeys, 'extraKeys');
|
|
142
|
-
if (options.extraValuePatterns !== undefined) {
|
|
143
|
-
assertRegExpArray(options.extraValuePatterns, 'extraValuePatterns');
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Wrap a logger so object args are redacted before delegation.
|
|
148
|
-
*
|
|
149
|
-
* Accepts: `inner` — the logger to delegate to; it must carry all four
|
|
150
|
-
* methods, because a missing one is a wiring mistake worth naming here rather
|
|
151
|
-
* than at the first log line. `options.extraKeys` — further key names to
|
|
152
|
-
* redact, matched like the defaults. `options.extraValuePatterns` — further
|
|
153
|
-
* secret shapes; each must be a `RegExp`, and it is applied globally whether or
|
|
154
|
-
* not it carries the `g` flag.
|
|
155
|
-
*
|
|
156
|
-
* Returns: a logger with the same four methods.
|
|
157
|
-
*
|
|
158
|
-
* Throws: `VALIDATION` naming `logger` or `logger.<method>` for a logger it
|
|
159
|
-
* could not delegate to, and `options`, `extraKeys` or `extraValuePatterns`
|
|
160
|
-
* for an option of the wrong type. Nothing at log time.
|
|
161
|
-
*
|
|
162
|
-
* Guarantees: the message string is passed through unchanged — never
|
|
163
|
-
* interpolate a secret into it — and every other argument is redacted before
|
|
164
|
-
* it reaches `inner`. Past the wrap call nothing escapes a log call: an
|
|
165
|
-
* argument whose redaction fails is replaced by a fixed marker, and a failure
|
|
166
|
-
* of `inner` itself is absorbed, because the
|
|
167
|
-
* operation that wrote the line was only observing itself and is commonly
|
|
168
|
-
* reporting some other failure already.
|
|
169
|
-
*/
|
|
170
|
-
function redactLogger(inner, options = {}) {
|
|
171
|
-
(0, collaborators_1.assertMembers)(inner, collaborators_1.LOGGER_MEMBERS, 'logger');
|
|
172
|
-
assertRedactionOptions(options);
|
|
173
|
-
const patterns = options.extraKeys
|
|
174
|
-
? [...secret_patterns_1.DEFAULT_SECRET_KEY_PATTERNS, ...options.extraKeys.map(secret_patterns_1.normaliseKey)]
|
|
175
|
-
: secret_patterns_1.DEFAULT_SECRET_KEY_PATTERNS;
|
|
176
|
-
const valuePatterns = options.extraValuePatterns
|
|
177
|
-
? [...secret_patterns_1.DEFAULT_SECRET_VALUE_PATTERNS, ...options.extraValuePatterns]
|
|
178
|
-
: secret_patterns_1.DEFAULT_SECRET_VALUE_PATTERNS;
|
|
179
|
-
const deliver = (method) => (message, ...args) => (0, logger_1.absorbLoggerFailure)(() => inner[method](message, ...args.map((arg) => redactSecrets(arg, patterns, valuePatterns))));
|
|
180
|
-
return {
|
|
181
|
-
info: deliver('info'),
|
|
182
|
-
warn: deliver('warn'),
|
|
183
|
-
error: deliver('error'),
|
|
184
|
-
debug: deliver('debug'),
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
/** True when `value` is a Set, tested by tag so a cross-realm Set still matches. */
|
|
188
|
-
function isSetValue(value) {
|
|
189
|
-
return Object.prototype.toString.call(value) === '[object Set]';
|
|
190
|
-
}
|
|
191
|
-
/** True when `value` is a Map, tested by tag so a cross-realm Map still matches. */
|
|
192
|
-
function isMapValue(value) {
|
|
193
|
-
return Object.prototype.toString.call(value) === '[object Map]';
|
|
194
|
-
}
|
|
195
|
-
/**
|
|
196
|
-
* True when `value` is an Error (or subclass) or a `DOMException` — which has
|
|
197
|
-
* its own tag yet carries the same `name`/`message`/`stack` — tested by tag,
|
|
198
|
-
* not `instanceof`, so a cross-realm error still matches.
|
|
199
|
-
*/
|
|
200
|
-
function isErrorValue(value) {
|
|
201
|
-
const tag = Object.prototype.toString.call(value);
|
|
202
|
-
return tag === '[object Error]' || tag === '[object DOMException]';
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* True for a value whose identity matters more than its own properties.
|
|
206
|
-
* `Date` and `RegExp` have none, so recursing either would yield a bare `{}`.
|
|
207
|
-
*/
|
|
208
|
-
function isOpaqueValue(value) {
|
|
209
|
-
const tag = Object.prototype.toString.call(value);
|
|
210
|
-
return tag === '[object Date]' || tag === '[object RegExp]';
|
|
211
|
-
}
|
|
212
|
-
/**
|
|
213
|
-
* Rebuild entries into a plain object, redacting values at secret-looking
|
|
214
|
-
* keys. Properties are defined, not assigned: `out['__proto__'] = …` would
|
|
215
|
-
* replace the result's prototype (and drop the entry) instead of recording the
|
|
216
|
-
* key as data.
|
|
217
|
-
*/
|
|
218
|
-
function redactEntries(entries, keyPatterns, walk) {
|
|
219
|
-
const out = {};
|
|
220
|
-
for (const [key, value] of entries) {
|
|
221
|
-
Object.defineProperty(out, key, {
|
|
222
|
-
value: (0, secret_patterns_1.isSecretKey)(key, keyPatterns) ? secret_patterns_1.REDACTED : walk(value),
|
|
223
|
-
enumerable: true,
|
|
224
|
-
writable: true,
|
|
225
|
-
configurable: true,
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
return out;
|
|
229
|
-
}
|
|
230
|
-
/**
|
|
231
|
-
* A Map's entries as an object. Keys are stringified so a non-string key is
|
|
232
|
-
* still reported rather than dropped — including as `[object Object]` for a
|
|
233
|
-
* plain-object key, which beats silently losing the entry — and each is
|
|
234
|
-
* checked against the secret-key patterns exactly as a plain object's own
|
|
235
|
-
* keys are.
|
|
236
|
-
*
|
|
237
|
-
* The annotation on `keyText` is `Redactable`'s own shape restated with an
|
|
238
|
-
* explicit `toString`, which every one of its members already has; it changes
|
|
239
|
-
* nothing about which key is what, only what `no-base-to-string` can see, so
|
|
240
|
-
* it stops mistaking the deliberate `[object Object]` case above for a bug.
|
|
241
|
-
*/
|
|
242
|
-
function redactMap(value, deps) {
|
|
243
|
-
const entries = [...value].map(([key, entry]) => {
|
|
244
|
-
const keyText = key;
|
|
245
|
-
return [String(keyText), entry];
|
|
246
|
-
});
|
|
247
|
-
return redactEntries(entries, deps.keyPatterns, deps.walk);
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Rebuild an Error as a plain object carrying its redacted text alongside its
|
|
251
|
-
* redacted own properties. The one exception is an Error with no own
|
|
252
|
-
* enumerable data, no `cause`, no aggregated `errors`, and no secret in its
|
|
253
|
-
* text: it is returned by reference so its identity and stack trace survive,
|
|
254
|
-
* which is what keeps a caught error useful in a log.
|
|
255
|
-
*
|
|
256
|
-
* `cause` and `AggregateError.errors` are copied explicitly because both are
|
|
257
|
-
* defined *non-enumerable* per spec, so `Object.entries` never sees them.
|
|
258
|
-
* Without this the whole chain vanished on every rebuild — and the rebuild
|
|
259
|
-
* always fires for this library's own error types, since each attaches an
|
|
260
|
-
* enumerable `code`/`context`. A redacted `RETRY_EXHAUSTED` would then no
|
|
261
|
-
* longer say whether the underlying failure was a throttle, a validation error
|
|
262
|
-
* or a network fault, which is the entire reason it carries a cause. A bare
|
|
263
|
-
* Error *with* a cause is rebuilt for the same reason: passing it by reference
|
|
264
|
-
* would hand the caller whatever secret the cause carries. Recursing through
|
|
265
|
-
* `walk` redacts the chain too, and the cycle guard handles a cause that
|
|
266
|
-
* points back at its own wrapper.
|
|
267
|
-
*/
|
|
268
|
-
function redactError(current, entries, deps) {
|
|
269
|
-
const text = (0, secret_patterns_1.redactErrorText)(current, deps.valuePatterns);
|
|
270
|
-
const aggregated = current.errors;
|
|
271
|
-
const bare = entries.length === 0 && current.cause === undefined && aggregated === undefined;
|
|
272
|
-
if (bare && !text.changed)
|
|
273
|
-
return current;
|
|
274
|
-
const out = redactEntries(entries, deps.keyPatterns, deps.walk);
|
|
275
|
-
out.name = text.name;
|
|
276
|
-
out.message = text.message;
|
|
277
|
-
out.stack = text.stack;
|
|
278
|
-
if (current.cause !== undefined)
|
|
279
|
-
out.cause = deps.walk(current.cause);
|
|
280
|
-
if (Array.isArray(aggregated))
|
|
281
|
-
out.errors = deps.walk(aggregated);
|
|
282
|
-
return out;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Dispatch one non-null object by its shape.
|
|
286
|
-
*
|
|
287
|
-
* Accepts: `current` — any object. `deps.walk` — how to recurse, which carries
|
|
288
|
-
* the cycle and memo state this module deliberately does not own.
|
|
289
|
-
*
|
|
290
|
-
* Returns: the redacted form — arrays and plain objects recursed, binary views
|
|
291
|
-
* collapsed to a label, `Date`/`RegExp` passed through by reference so they do
|
|
292
|
-
* not become `{}`, `Set`/`Map` rendered as their contents, and an Error through
|
|
293
|
-
* the error path, which preserves the non-enumerable text a plain walk cannot
|
|
294
|
-
* see.
|
|
295
|
-
*
|
|
296
|
-
* Throws: whatever a property getter on the value throws. `redactSecrets`, the
|
|
297
|
-
* only caller, catches it and returns `[UNREDACTABLE]` in place of the whole
|
|
298
|
-
* value it was given, rather than raising a getter's error at a caller who
|
|
299
|
-
* asked only for a copy it could log.
|
|
300
|
-
*/
|
|
301
|
-
function walkObject(current, deps) {
|
|
302
|
-
if (Array.isArray(current))
|
|
303
|
-
return current.map(deps.walk);
|
|
304
|
-
if (ArrayBuffer.isView(current))
|
|
305
|
-
return (0, secret_patterns_1.binaryLabel)(current);
|
|
306
|
-
if (isOpaqueValue(current))
|
|
307
|
-
return current;
|
|
308
|
-
if (isSetValue(current))
|
|
309
|
-
return [...current].map(deps.walk);
|
|
310
|
-
if (isMapValue(current))
|
|
311
|
-
return redactMap(current, deps);
|
|
312
|
-
const entries = Object.entries(current);
|
|
313
|
-
if (isErrorValue(current))
|
|
314
|
-
return redactError(current, entries, deps);
|
|
315
|
-
return redactEntries(entries, deps.keyPatterns, deps.walk);
|
|
316
|
-
}
|
package/dist/shared/options.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Hides which options every adapter shares.
|
|
4
|
-
*
|
|
5
|
-
* The table, the client, the ttl, the logger, the retry policy, the recency
|
|
6
|
-
* index, the read concurrency, the codec options and per-call cancellation are
|
|
7
|
-
* declared once here, so the checkpointer, the store and the history accept
|
|
8
|
-
* the same keys with the same meaning, and an adapter-wide option is added in
|
|
9
|
-
* one place. This module holds their types only; checking them is elsewhere.
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Hides which adapter-wide construction options are accepted.
|
|
4
|
-
*
|
|
5
|
-
* The table name, the client choice, the ttl, the retry policy, the recency
|
|
6
|
-
* index, the read concurrency, compression and S3 offload are checked here with
|
|
7
|
-
* their bounds, before an adapter builds anything, so a misconfiguration
|
|
8
|
-
* surfaces at construction rather than on the first call.
|
|
9
|
-
*/
|
|
10
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
-
exports.MAX_READ_CONCURRENCY = exports.MAX_RETRY_DELAY_MS = exports.MAX_RETRY_ATTEMPTS = exports.MAX_PAYLOAD_BUFFER_BYTES = void 0;
|
|
12
|
-
exports.assertTableName = assertTableName;
|
|
13
|
-
exports.assertClientChoice = assertClientChoice;
|
|
14
|
-
exports.assertRetryBounds = assertRetryBounds;
|
|
15
|
-
exports.assertRetryPolicy = assertRetryPolicy;
|
|
16
|
-
exports.assertBaseAdapterOptions = assertBaseAdapterOptions;
|
|
17
|
-
exports.assertCompression = assertCompression;
|
|
18
|
-
exports.assertS3 = assertS3;
|
|
19
|
-
const codec_1 = require("../codec/codec");
|
|
20
|
-
const config_1 = require("../codec/s3/config");
|
|
21
|
-
const recency_index_1 = require("../dynamodb/recency-index");
|
|
22
|
-
const errors_1 = require("../errors/errors");
|
|
23
|
-
const option_shape_1 = require("./option-shape");
|
|
24
|
-
const primitives_1 = require("./primitives");
|
|
25
|
-
const ttl_1 = require("./ttl");
|
|
26
|
-
/** DynamoDB's table-name rule: 3–255 characters from `[A-Za-z0-9_.-]`. */
|
|
27
|
-
const TABLE_NAME_PATTERN = /^[A-Za-z0-9_.-]{3,255}$/;
|
|
28
|
-
/**
|
|
29
|
-
* Largest `s3.maxDownloadBytes`/`compression.maxDecompressedBytes` an adapter
|
|
30
|
-
* accepts (512 MiB): both hold one buffer fully resident while it is read or
|
|
31
|
-
* inflated, and `BaseAdapterOptions.readConcurrency`'s doc multiplies the two
|
|
32
|
-
* together into the package's memory ceiling, so an unbounded value here is an
|
|
33
|
-
* unbounded process, not just an unbounded object.
|
|
34
|
-
*/
|
|
35
|
-
exports.MAX_PAYLOAD_BUFFER_BYTES = 512 * 1024 * 1024;
|
|
36
|
-
/** Largest `retry.maxAttempts` an adapter accepts; beyond it a retry loop is a hang, not a policy. */
|
|
37
|
-
exports.MAX_RETRY_ATTEMPTS = 100;
|
|
38
|
-
/**
|
|
39
|
-
* Largest `retry.baseDelayMs`/`retry.maxDelayMs` an adapter accepts (one
|
|
40
|
-
* minute): combined with {@link MAX_RETRY_ATTEMPTS}, an unbounded per-attempt
|
|
41
|
-
* delay turns a bounded attempt count back into an effectively unbounded wait.
|
|
42
|
-
*/
|
|
43
|
-
exports.MAX_RETRY_DELAY_MS = 60_000;
|
|
44
|
-
/**
|
|
45
|
-
* Largest `readConcurrency` an adapter accepts: it is a multiplier on the
|
|
46
|
-
* memory-ceiling formula (see the option's own doc) and on requests fired at
|
|
47
|
-
* once, so an unbounded value turns a typo into an out-of-memory crash or a
|
|
48
|
-
* request storm against the table/bucket.
|
|
49
|
-
*/
|
|
50
|
-
exports.MAX_READ_CONCURRENCY = 128;
|
|
51
|
-
const RETRY_KEYS = (0, option_shape_1.allKeysOf)({
|
|
52
|
-
maxAttempts: 'maxAttempts',
|
|
53
|
-
baseDelayMs: 'baseDelayMs',
|
|
54
|
-
maxDelayMs: 'maxDelayMs',
|
|
55
|
-
});
|
|
56
|
-
/**
|
|
57
|
-
* Validate a table name against DynamoDB's own naming rule.
|
|
58
|
-
*
|
|
59
|
-
* Accepts: `tableName` — as the caller gave it.
|
|
60
|
-
*
|
|
61
|
-
* Returns: nothing: the value is kept under its declared type, and this
|
|
62
|
-
* checks it.
|
|
63
|
-
*
|
|
64
|
-
* Throws: `VALIDATION` naming `tableName`.
|
|
65
|
-
*/
|
|
66
|
-
function assertTableName(tableName) {
|
|
67
|
-
if (typeof tableName !== 'string' || !TABLE_NAME_PATTERN.test(tableName)) {
|
|
68
|
-
throw (0, errors_1.validationError)('tableName must be 3-255 characters from [A-Za-z0-9_.-], as DynamoDB requires', 'tableName');
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Reject a client choice that names two ways of getting one, or a
|
|
73
|
-
* `clientConfig` that is not an object.
|
|
74
|
-
*
|
|
75
|
-
* Accepts: the three client options, from an adapter or from the factory that
|
|
76
|
-
* defaults them. An injected `client` is used as-is, so a `clientConfig` or
|
|
77
|
-
* `createClient` given alongside it would be silently ignored — including a
|
|
78
|
-
* `region` the caller believes is in effect. `clientConfig`, when given, must
|
|
79
|
-
* be an object that is neither `null` nor an array; what it holds is the AWS
|
|
80
|
-
* SDK's to judge.
|
|
81
|
-
*
|
|
82
|
-
* Returns: nothing: the value is kept under its declared type, and this
|
|
83
|
-
* checks it.
|
|
84
|
-
*
|
|
85
|
-
* Throws: `VALIDATION` naming `client` for both ways at once, then
|
|
86
|
-
* `clientConfig` for one that is not an object.
|
|
87
|
-
*/
|
|
88
|
-
function assertClientChoice(options) {
|
|
89
|
-
if (options.client &&
|
|
90
|
-
(options.clientConfig !== undefined || options.createClient !== undefined)) {
|
|
91
|
-
throw (0, errors_1.validationError)('provide either `client` or `clientConfig`/`createClient`, not both: an injected client ' +
|
|
92
|
-
'is used as-is and the configuration would be silently ignored', 'client');
|
|
93
|
-
}
|
|
94
|
-
// The shape only, never the keys, and on purpose: they are the AWS SDK's
|
|
95
|
-
// `DynamoDBClientConfig`, which gains keys between SDK releases, and an
|
|
96
|
-
// application may install a newer SDK than the one this package was
|
|
97
|
-
// compiled against, so a key list compiled in here would refuse valid
|
|
98
|
-
// configuration. The SDK reads each key itself.
|
|
99
|
-
if (options.clientConfig !== undefined)
|
|
100
|
-
(0, option_shape_1.assertObjectShape)(options.clientConfig, 'clientConfig');
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* The three numeric bounds every retry policy shares, regardless of which
|
|
104
|
-
* other keys the caller's own type allows beyond them. Split out so a caller
|
|
105
|
-
* with a wider surface than {@link RetryPolicy} (`backfillRecencyIndex`'s
|
|
106
|
-
* `RetryOptions`, which also exposes `onRetry`, `isRetryable` and friends)
|
|
107
|
-
* can reuse the identical bounds without going through {@link
|
|
108
|
-
* assertRetryPolicy}'s narrower `assertShape`, which would refuse those
|
|
109
|
-
* extra keys outright.
|
|
110
|
-
*
|
|
111
|
-
* Accepts: `policy` — its `maxAttempts`, `baseDelayMs` and `maxDelayMs`, each
|
|
112
|
-
* optional.
|
|
113
|
-
*
|
|
114
|
-
* Returns: nothing: the value is kept under its declared type, and this
|
|
115
|
-
* checks it.
|
|
116
|
-
*
|
|
117
|
-
* Throws: `VALIDATION` naming `retry.maxAttempts`, `retry.baseDelayMs` or
|
|
118
|
-
* `retry.maxDelayMs`.
|
|
119
|
-
*/
|
|
120
|
-
function assertRetryBounds(policy) {
|
|
121
|
-
if (policy.maxAttempts !== undefined) {
|
|
122
|
-
(0, primitives_1.assertInteger)(policy.maxAttempts, 'retry.maxAttempts', { min: 1, max: exports.MAX_RETRY_ATTEMPTS });
|
|
123
|
-
}
|
|
124
|
-
if (policy.baseDelayMs !== undefined) {
|
|
125
|
-
(0, primitives_1.assertInteger)(policy.baseDelayMs, 'retry.baseDelayMs', { min: 1, max: exports.MAX_RETRY_DELAY_MS });
|
|
126
|
-
}
|
|
127
|
-
if (policy.maxDelayMs !== undefined) {
|
|
128
|
-
(0, primitives_1.assertInteger)(policy.maxDelayMs, 'retry.maxDelayMs', {
|
|
129
|
-
min: policy.baseDelayMs ?? 1,
|
|
130
|
-
max: exports.MAX_RETRY_DELAY_MS,
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Validate a retry policy: shape, then each bound.
|
|
136
|
-
*
|
|
137
|
-
* Accepts: `policy` — must be an object naming only `maxAttempts`,
|
|
138
|
-
* `baseDelayMs` and `maxDelayMs`; each, if given, is a bounded integer.
|
|
139
|
-
*
|
|
140
|
-
* Returns: nothing: the value is kept under its declared type, and this
|
|
141
|
-
* checks it.
|
|
142
|
-
*
|
|
143
|
-
* Throws: `VALIDATION` naming `retry` or `retry.<key>`.
|
|
144
|
-
*/
|
|
145
|
-
function assertRetryPolicy(policy) {
|
|
146
|
-
(0, option_shape_1.assertShape)(policy, RETRY_KEYS, 'retry');
|
|
147
|
-
assertRetryBounds(policy);
|
|
148
|
-
}
|
|
149
|
-
/** The recency index: a named GSI, and the partition count rows are sharded across. */
|
|
150
|
-
function assertRecencyIndex(options) {
|
|
151
|
-
if (options.indexShards !== undefined) {
|
|
152
|
-
(0, primitives_1.assertInteger)(options.indexShards, 'indexShards', { min: 1, max: recency_index_1.MAX_INDEX_SHARDS });
|
|
153
|
-
}
|
|
154
|
-
if (options.indexName !== undefined)
|
|
155
|
-
(0, primitives_1.assertNonEmptyString)(options.indexName, 'indexName');
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Validate the options every adapter shares, at construction.
|
|
159
|
-
*
|
|
160
|
-
* Accepts: `options` — must be an object. `tableName` is required; every other
|
|
161
|
-
* option is optional, and `undefined` means "not configured" for each. A
|
|
162
|
-
* nested `ttl`, `retry`, `compression` or `s3` must be an object whose keys
|
|
163
|
-
* this package reads: a misspelt key is rejected rather than ignored, because
|
|
164
|
-
* the caller would otherwise run on a default they believe they overrode.
|
|
165
|
-
* `clientConfig` and `s3.clientConfig` must be objects, but their keys belong
|
|
166
|
-
* to the AWS SDK and are not checked. Keys of `options` itself are not checked
|
|
167
|
-
* here — the adapter types differ and this validator sees only the shared ones.
|
|
168
|
-
*
|
|
169
|
-
* Returns: nothing: the value is kept under its declared type, and this
|
|
170
|
-
* checks it.
|
|
171
|
-
*
|
|
172
|
-
* Throws: `VALIDATION` whose `context.field` names the offending option,
|
|
173
|
-
* dotted for a nested one (`s3.bucketName`). The order is `tableName`, client
|
|
174
|
-
* choice, `ttl`, `retry`, `compression`, `s3`, `readConcurrency`, then the
|
|
175
|
-
* index options.
|
|
176
|
-
*
|
|
177
|
-
* Guarantees: a misconfiguration surfaces at construction, naming the option,
|
|
178
|
-
* rather than as a raw AWS error on the first request.
|
|
179
|
-
*/
|
|
180
|
-
function assertBaseAdapterOptions(options) {
|
|
181
|
-
if (typeof options !== 'object' || options === null) {
|
|
182
|
-
throw (0, errors_1.validationError)('options must be an object naming at least a tableName', 'options');
|
|
183
|
-
}
|
|
184
|
-
assertTableName(options.tableName);
|
|
185
|
-
assertClientChoice(options);
|
|
186
|
-
if (options.ttl !== undefined)
|
|
187
|
-
(0, ttl_1.resolveTtlSeconds)(options.ttl);
|
|
188
|
-
if (options.retry !== undefined)
|
|
189
|
-
assertRetryPolicy(options.retry);
|
|
190
|
-
if (options.compression !== undefined)
|
|
191
|
-
assertCompression(options.compression);
|
|
192
|
-
if (options.s3 !== undefined)
|
|
193
|
-
assertS3(options.s3);
|
|
194
|
-
if (options.readConcurrency !== undefined) {
|
|
195
|
-
(0, primitives_1.assertInteger)(options.readConcurrency, 'readConcurrency', {
|
|
196
|
-
min: 1,
|
|
197
|
-
max: exports.MAX_READ_CONCURRENCY,
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
assertRecencyIndex(options);
|
|
201
|
-
}
|
|
202
|
-
/** Server-side encryption algorithms S3 accepts for `PutObject`. */
|
|
203
|
-
const SSE_ALGORITHMS = ['AES256', 'aws:kms', 'aws:kms:dsse'];
|
|
204
|
-
const COMPRESSION_KEYS = (0, option_shape_1.allKeysOf)({
|
|
205
|
-
enabled: 'enabled',
|
|
206
|
-
level: 'level',
|
|
207
|
-
minSizeBytes: 'minSizeBytes',
|
|
208
|
-
maxDecompressedBytes: 'maxDecompressedBytes',
|
|
209
|
-
});
|
|
210
|
-
const S3_KEYS = (0, option_shape_1.allKeysOf)({
|
|
211
|
-
bucketName: 'bucketName',
|
|
212
|
-
keyPrefix: 'keyPrefix',
|
|
213
|
-
thresholdBytes: 'thresholdBytes',
|
|
214
|
-
serverSideEncryption: 'serverSideEncryption',
|
|
215
|
-
sseKmsKeyId: 'sseKmsKeyId',
|
|
216
|
-
maxDownloadBytes: 'maxDownloadBytes',
|
|
217
|
-
clientConfig: 'clientConfig',
|
|
218
|
-
createS3Client: 'createS3Client',
|
|
219
|
-
});
|
|
220
|
-
/**
|
|
221
|
-
* Validate a `compression` config, honoring its allowed key set.
|
|
222
|
-
*
|
|
223
|
-
* Accepts: `config` — an object naming only {@link CompressionConfig}'s keys.
|
|
224
|
-
*
|
|
225
|
-
* Returns: nothing: the value is kept under its declared type, and this
|
|
226
|
-
* checks it.
|
|
227
|
-
*
|
|
228
|
-
* Throws: `VALIDATION` naming the offending field, dotted under
|
|
229
|
-
* `compression`.
|
|
230
|
-
*/
|
|
231
|
-
function assertCompression(config) {
|
|
232
|
-
(0, option_shape_1.assertShape)(config, COMPRESSION_KEYS, 'compression');
|
|
233
|
-
if (typeof config.enabled !== 'boolean') {
|
|
234
|
-
throw (0, errors_1.validationError)('compression.enabled must be a boolean', 'compression.enabled');
|
|
235
|
-
}
|
|
236
|
-
if (config.level !== undefined) {
|
|
237
|
-
(0, primitives_1.assertInteger)(config.level, 'compression.level', { min: 0, max: 9 });
|
|
238
|
-
}
|
|
239
|
-
if (config.minSizeBytes !== undefined) {
|
|
240
|
-
// Bounded by MAX_PAYLOAD_BUFFER_BYTES, not by MAX_INLINE_PAYLOAD_BYTES as
|
|
241
|
-
// `s3.thresholdBytes` is, because the two differ in kind. `encodePayload`
|
|
242
|
-
// compresses first and only then decides inline versus offload, on the
|
|
243
|
-
// compressed size — so `minSizeBytes` above the inline limit, paired with
|
|
244
|
-
// `s3`, is a meaningful configuration: compress only what will be offloaded
|
|
245
|
-
// anyway. A `thresholdBytes` above the inline limit is not: a payload
|
|
246
|
-
// between the two is too large to store inline and too small to offload,
|
|
247
|
-
// so its write fails. `minSizeBytes` only decides whether gzip runs; the
|
|
248
|
-
// only value it can never act on is one larger than any payload this
|
|
249
|
-
// package can read back.
|
|
250
|
-
(0, primitives_1.assertInteger)(config.minSizeBytes, 'compression.minSizeBytes', {
|
|
251
|
-
min: 0,
|
|
252
|
-
max: exports.MAX_PAYLOAD_BUFFER_BYTES,
|
|
253
|
-
});
|
|
254
|
-
}
|
|
255
|
-
if (config.maxDecompressedBytes !== undefined) {
|
|
256
|
-
(0, primitives_1.assertInteger)(config.maxDecompressedBytes, 'compression.maxDecompressedBytes', {
|
|
257
|
-
min: 1,
|
|
258
|
-
max: exports.MAX_PAYLOAD_BUFFER_BYTES,
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Validate the two `s3` options `PutObject` receives as they were given.
|
|
264
|
-
*
|
|
265
|
-
* Accepts: `config.serverSideEncryption` — absent, or an algorithm S3 accepts.
|
|
266
|
-
* `config.sseKmsKeyId` — absent, or a non-empty string. Only its type is
|
|
267
|
-
* checked; whether it names a real key, by id or by ARN, is for S3 to answer.
|
|
268
|
-
*
|
|
269
|
-
* Returns: nothing: the value is kept under its declared type, and this
|
|
270
|
-
* checks it.
|
|
271
|
-
*
|
|
272
|
-
* Throws: `VALIDATION` naming `s3.serverSideEncryption` or
|
|
273
|
-
* `s3.sseKmsKeyId`. Unchecked, a truthy key id that is not a string was
|
|
274
|
-
* handed to `PutObject` at the first offload, and a falsy one (`''`, `null`,
|
|
275
|
-
* `0`) was dropped, uploading without the key the caller named.
|
|
276
|
-
*/
|
|
277
|
-
function assertS3Encryption(config) {
|
|
278
|
-
if (config.serverSideEncryption !== undefined &&
|
|
279
|
-
!SSE_ALGORITHMS.includes(config.serverSideEncryption)) {
|
|
280
|
-
throw (0, errors_1.validationError)(`s3.serverSideEncryption must be one of ${SSE_ALGORITHMS.join(', ')}`, 's3.serverSideEncryption');
|
|
281
|
-
}
|
|
282
|
-
if (config.sseKmsKeyId !== undefined) {
|
|
283
|
-
(0, primitives_1.assertNonEmptyString)(config.sseKmsKeyId, 's3.sseKmsKeyId');
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
/**
|
|
287
|
-
* Validate an `s3` offload config, honoring its allowed key set.
|
|
288
|
-
*
|
|
289
|
-
* Accepts: `config` — an object naming only {@link S3OffloadConfig}'s keys.
|
|
290
|
-
* `config.clientConfig`, when given, must be an object that is neither `null`
|
|
291
|
-
* nor an array; its own keys are not checked. `config.createS3Client`, when
|
|
292
|
-
* given, must be a function.
|
|
293
|
-
*
|
|
294
|
-
* Returns: nothing: the value is kept under its declared type, and this
|
|
295
|
-
* checks it.
|
|
296
|
-
*
|
|
297
|
-
* Throws: `VALIDATION` naming the offending field, dotted under `s3`.
|
|
298
|
-
*/
|
|
299
|
-
function assertS3(config) {
|
|
300
|
-
(0, option_shape_1.assertShape)(config, S3_KEYS, 's3');
|
|
301
|
-
(0, primitives_1.assertNonEmptyString)(config.bucketName, 's3.bucketName');
|
|
302
|
-
// The shape only, never the keys: they are the AWS SDK's `S3ClientConfig`,
|
|
303
|
-
// which gains keys between SDK releases, and an application may install a
|
|
304
|
-
// newer SDK than the one this package was compiled against, so a key list
|
|
305
|
-
// compiled in here would refuse valid configuration.
|
|
306
|
-
if (config.clientConfig !== undefined)
|
|
307
|
-
(0, option_shape_1.assertObjectShape)(config.clientConfig, 's3.clientConfig');
|
|
308
|
-
if (config.thresholdBytes !== undefined) {
|
|
309
|
-
(0, primitives_1.assertInteger)(config.thresholdBytes, 's3.thresholdBytes', {
|
|
310
|
-
min: 1,
|
|
311
|
-
max: codec_1.MAX_INLINE_PAYLOAD_BYTES,
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
if (config.keyPrefix !== undefined)
|
|
315
|
-
(0, config_1.assertScopedKeyPrefix)(config.keyPrefix);
|
|
316
|
-
if (config.maxDownloadBytes !== undefined) {
|
|
317
|
-
(0, primitives_1.assertInteger)(config.maxDownloadBytes, 's3.maxDownloadBytes', {
|
|
318
|
-
min: 1,
|
|
319
|
-
max: exports.MAX_PAYLOAD_BUFFER_BYTES,
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
assertS3Encryption(config);
|
|
323
|
-
// Called to build the S3 client at the first offload, where a value that is
|
|
324
|
-
// not a function threw a bare `TypeError`.
|
|
325
|
-
if (config.createS3Client !== undefined && typeof config.createS3Client !== 'function') {
|
|
326
|
-
throw (0, errors_1.validationError)('s3.createS3Client must be a function', 's3.createS3Client');
|
|
327
|
-
}
|
|
328
|
-
}
|