@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,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Hides what each of this library's errors carries, for the codes that have
|
|
4
3
|
* a factory here.
|
|
@@ -10,31 +9,16 @@
|
|
|
10
9
|
* than inside the factory are decided here once per code, on the one error
|
|
11
10
|
* class (record 19). `FORMAT_UNSUPPORTED`, `PAYLOAD_CORRUPT`,
|
|
12
11
|
* `COMPRESSION_LIMIT`, `S3_OFFLOAD_FAILED` and `ANCESTOR_EXPIRED` are raised
|
|
13
|
-
* with `new DynamoDBLangGraphError` at their own call sites instead
|
|
14
|
-
*
|
|
15
|
-
*
|
|
12
|
+
* with `new DynamoDBLangGraphError` at their own call sites instead; so is
|
|
13
|
+
* `CONTENTION` when `ensureLifecycleRule` gives up on a lifecycle write that
|
|
14
|
+
* never stays, which is this package's own verdict rather than an AWS
|
|
15
|
+
* rejection. Every other occurrence of an AWS-classified code, `CONTENTION`
|
|
16
|
+
* included, is wrapped once, by `wrapForeignError` in the error boundary, not
|
|
17
|
+
* per code here.
|
|
16
18
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
exports.retryExhaustedError = retryExhaustedError;
|
|
21
|
-
exports.resultTruncatedError = resultTruncatedError;
|
|
22
|
-
exports.abortError = abortError;
|
|
23
|
-
exports.batchWriteIncompleteError = batchWriteIncompleteError;
|
|
24
|
-
exports.batchWriteAllIncompleteError = batchWriteAllIncompleteError;
|
|
25
|
-
exports.compensationFailedError = compensationFailedError;
|
|
26
|
-
const secret_patterns_1 = require("../logging/secret-patterns");
|
|
27
|
-
const base_error_1 = require("./base-error");
|
|
28
|
-
const error_code_1 = require("./error-code");
|
|
29
|
-
/**
|
|
30
|
-
* Build one error, with the stack starting at the code that called `factory`
|
|
31
|
-
* rather than inside it: the top frame is the one a reader follows.
|
|
32
|
-
*/
|
|
33
|
-
function build(factory, spec) {
|
|
34
|
-
const error = new base_error_1.DynamoDBLangGraphError(spec.message, spec.code, spec.context, spec.cause, spec.details);
|
|
35
|
-
Error.captureStackTrace(error, factory);
|
|
36
|
-
return error;
|
|
37
|
-
}
|
|
19
|
+
import type { WriteRequest } from '../dynamodb/client.js';
|
|
20
|
+
import { DynamoDBLangGraphError } from './base-error.js';
|
|
21
|
+
import { ErrorCode } from './error-code.js';
|
|
38
22
|
/**
|
|
39
23
|
* The error for input that failed a check before any AWS call was made.
|
|
40
24
|
*
|
|
@@ -48,14 +32,7 @@ function build(factory, spec) {
|
|
|
48
32
|
*
|
|
49
33
|
* Throws: nothing; building an error may not fail.
|
|
50
34
|
*/
|
|
51
|
-
function validationError(message, field, cause)
|
|
52
|
-
return build(validationError, {
|
|
53
|
-
message,
|
|
54
|
-
code: error_code_1.ErrorCode.VALIDATION,
|
|
55
|
-
context: field === undefined ? {} : { field },
|
|
56
|
-
cause,
|
|
57
|
-
});
|
|
58
|
-
}
|
|
35
|
+
export declare function validationError(message: string, field?: string, cause?: Error): DynamoDBLangGraphError<ErrorCode.VALIDATION>;
|
|
59
36
|
/**
|
|
60
37
|
* The error for a conditional write whose precondition no longer holds.
|
|
61
38
|
*
|
|
@@ -67,31 +44,58 @@ function validationError(message, field, cause) {
|
|
|
67
44
|
*
|
|
68
45
|
* Throws: nothing; building an error may not fail.
|
|
69
46
|
*/
|
|
70
|
-
function conflictError(message, cause)
|
|
71
|
-
|
|
72
|
-
|
|
47
|
+
export declare function conflictError(message: string, cause?: Error): DynamoDBLangGraphError<ErrorCode.CONDITION_CONFLICT>;
|
|
48
|
+
/**
|
|
49
|
+
* Record on `error` that an attempt of the budget it ended may still land.
|
|
50
|
+
*
|
|
51
|
+
* Accepts: `error` — the failure a retry budget is about to throw as it is: a
|
|
52
|
+
* refusal that is not retried, so it is thrown bare rather than wrapped in
|
|
53
|
+
* `RETRY_EXHAUSTED`, after an earlier attempt of the same budget got no
|
|
54
|
+
* answer. Credentials expiring mid-budget are the ordinary way there.
|
|
55
|
+
*
|
|
56
|
+
* Returns: `error`, carrying the record for {@link retryBudgetMayStillLand}.
|
|
57
|
+
* An error that cannot take a property — frozen, or not an object — is
|
|
58
|
+
* returned as it is, and then reads as answered, which is how every error
|
|
59
|
+
* read before this record existed.
|
|
60
|
+
*
|
|
61
|
+
* Throws: nothing, for any value.
|
|
62
|
+
*/
|
|
63
|
+
export declare function markMayStillLand<E extends Error>(error: E): E;
|
|
73
64
|
/**
|
|
74
65
|
* The error for a retried operation that exhausted its attempt budget.
|
|
75
66
|
*
|
|
76
67
|
* Accepts: `attempts` — how many were made before the budget ran out.
|
|
77
68
|
* `cause` — the last failure, kept so a caller can classify what actually
|
|
78
|
-
* went wrong.
|
|
69
|
+
* went wrong. `mayStillLand` — whether any attempt of the budget, not only the
|
|
70
|
+
* last, left DynamoDB free to apply it later; read back by
|
|
71
|
+
* {@link retryBudgetMayStillLand}. Defaults to false, which is what a caller
|
|
72
|
+
* outside `withRetry` — one built by an older release, or a test double — gets
|
|
73
|
+
* for not recording one.
|
|
79
74
|
*
|
|
80
75
|
* Returns: a `RETRY_EXHAUSTED` error, with `context.attempts` when `attempts`
|
|
81
|
-
* was given
|
|
76
|
+
* was given, and the `awsErrorName`, `httpStatusCode` and `requestId` of the
|
|
77
|
+
* last failure when that failure was AWS's, so a count by status needs no walk
|
|
78
|
+
* of `cause`. It says the attempts are spent, **not** that the operation did
|
|
82
79
|
* not happen: a write whose response was lost is reported this way too, which
|
|
83
80
|
* is why every caller that would delete something reads the row back first.
|
|
84
81
|
*
|
|
85
82
|
* Throws: nothing; building an error may not fail.
|
|
86
83
|
*/
|
|
87
|
-
function retryExhaustedError(message, attempts, cause)
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
84
|
+
export declare function retryExhaustedError(message: string, attempts?: number, cause?: Error, mayStillLand?: boolean): DynamoDBLangGraphError<ErrorCode.RETRY_EXHAUSTED>;
|
|
85
|
+
/**
|
|
86
|
+
* Whether some attempt of the retry budget this error ended — recorded across
|
|
87
|
+
* every attempt `withRetry` made, not re-derived from the error, which is only
|
|
88
|
+
* the last one — left DynamoDB free to apply it later.
|
|
89
|
+
*
|
|
90
|
+
* Accepts: `error` — any error; one {@link retryExhaustedError} built, or one
|
|
91
|
+
* {@link markMayStillLand} marked, carries the record.
|
|
92
|
+
*
|
|
93
|
+
* Returns: the flag recorded on the error; false for any other error,
|
|
94
|
+
* including a `RETRY_EXHAUSTED` error built without passing one.
|
|
95
|
+
*
|
|
96
|
+
* Throws: nothing, for any value.
|
|
97
|
+
*/
|
|
98
|
+
export declare function retryBudgetMayStillLand(error: Error): boolean;
|
|
95
99
|
/**
|
|
96
100
|
* The error for a paginated read that hit its runaway guard (item or
|
|
97
101
|
* iteration cap) while more data remained, so the result would have been
|
|
@@ -107,13 +111,7 @@ function retryExhaustedError(message, attempts, cause) {
|
|
|
107
111
|
*
|
|
108
112
|
* Throws: nothing; building an error may not fail.
|
|
109
113
|
*/
|
|
110
|
-
function resultTruncatedError(cap, limit)
|
|
111
|
-
return build(resultTruncatedError, {
|
|
112
|
-
message: `paginated read truncated at the ${cap} cap (${limit}) with more data remaining`,
|
|
113
|
-
code: error_code_1.ErrorCode.RESULT_TRUNCATED,
|
|
114
|
-
context: { field: cap },
|
|
115
|
-
});
|
|
116
|
-
}
|
|
114
|
+
export declare function resultTruncatedError(cap: string, limit: number): DynamoDBLangGraphError<ErrorCode.RESULT_TRUNCATED>;
|
|
117
115
|
/**
|
|
118
116
|
* The error for an operation cancelled via its `AbortSignal`.
|
|
119
117
|
*
|
|
@@ -126,9 +124,7 @@ function resultTruncatedError(cap, limit) {
|
|
|
126
124
|
*
|
|
127
125
|
* Throws: nothing; building an error may not fail.
|
|
128
126
|
*/
|
|
129
|
-
function abortError(message
|
|
130
|
-
return build(abortError, { message, code: error_code_1.ErrorCode.ABORTED, context: {}, cause });
|
|
131
|
-
}
|
|
127
|
+
export declare function abortError(message?: string, cause?: Error): DynamoDBLangGraphError<ErrorCode.ABORTED>;
|
|
132
128
|
/**
|
|
133
129
|
* The error for a `BatchWriteItem` sequence that could not drain its
|
|
134
130
|
* `UnprocessedItems`.
|
|
@@ -148,16 +144,17 @@ function abortError(message = 'Operation aborted', cause) {
|
|
|
148
144
|
* Throws: nothing; building an error may not fail. Anything but an array of
|
|
149
145
|
* requests reads as an empty list rather than crashing the report.
|
|
150
146
|
*/
|
|
151
|
-
function batchWriteIncompleteError(succeededCount, unprocessed, retries, cause)
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
147
|
+
export declare function batchWriteIncompleteError(succeededCount: number, unprocessed: WriteRequest[], retries: number, cause?: Error): DynamoDBLangGraphError<ErrorCode.BATCH_WRITE_INCOMPLETE>;
|
|
148
|
+
/** What a batch that could not finish reports. */
|
|
149
|
+
export interface IncompleteBatch {
|
|
150
|
+
/** Chunks (or rows) that committed. */
|
|
151
|
+
readonly succeeded: number;
|
|
152
|
+
/** Chunks (or rows) the batch had. */
|
|
153
|
+
readonly total: number;
|
|
154
|
+
readonly failures: Error[];
|
|
155
|
+
/** Requests that committed, when a chunk is more than one request. */
|
|
156
|
+
readonly succeededCount?: number;
|
|
157
|
+
readonly unit?: 'row';
|
|
161
158
|
}
|
|
162
159
|
/**
|
|
163
160
|
* The error for a `batchWriteAll` pass — or a partition-wide delete — that did
|
|
@@ -186,26 +183,7 @@ function batchWriteIncompleteError(succeededCount, unprocessed, retries, cause)
|
|
|
186
183
|
* Throws: nothing; building an error may not fail. Anything but an array of
|
|
187
184
|
* errors reads as an empty list rather than crashing the report.
|
|
188
185
|
*/
|
|
189
|
-
function batchWriteAllIncompleteError(batch)
|
|
190
|
-
const { succeeded, total, succeededCount = 0, unit = 'chunk' } = batch;
|
|
191
|
-
const failed = Array.isArray(batch.failures) ? [...batch.failures] : [];
|
|
192
|
-
return build(batchWriteAllIncompleteError, {
|
|
193
|
-
message: `${unit === 'chunk' ? 'batchWriteAll' : 'the partition delete'} did not fully drain: ` +
|
|
194
|
-
`${succeeded}/${total} ${unit}(s) succeeded, ` +
|
|
195
|
-
`${failed.length} ${unit}(s) failed. ${succeededCount} write(s) persisted before the failure.`,
|
|
196
|
-
code: error_code_1.ErrorCode.BATCH_WRITE_INCOMPLETE,
|
|
197
|
-
context: {},
|
|
198
|
-
cause: failed[0],
|
|
199
|
-
details: {
|
|
200
|
-
kind: 'pass',
|
|
201
|
-
unit,
|
|
202
|
-
succeededChunks: succeeded,
|
|
203
|
-
totalChunks: total,
|
|
204
|
-
failedChunks: failed,
|
|
205
|
-
succeededCount,
|
|
206
|
-
},
|
|
207
|
-
});
|
|
208
|
-
}
|
|
186
|
+
export declare function batchWriteAllIncompleteError(batch: IncompleteBatch): DynamoDBLangGraphError<ErrorCode.BATCH_WRITE_INCOMPLETE>;
|
|
209
187
|
/**
|
|
210
188
|
* The error for a compensating rollback that failed after an append-saga
|
|
211
189
|
* chunk error, so the trigger could not be cleanly undone.
|
|
@@ -225,15 +203,31 @@ function batchWriteAllIncompleteError(batch) {
|
|
|
225
203
|
* the rollback — which is why `toError` normalises both `cause` and
|
|
226
204
|
* `rollbackError` before anything reads off them.
|
|
227
205
|
*/
|
|
228
|
-
function compensationFailedError(cause, rollbackError)
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
206
|
+
export declare function compensationFailedError(cause: Error, rollbackError: Error): DynamoDBLangGraphError<ErrorCode.COMPENSATION_FAILED>;
|
|
207
|
+
/**
|
|
208
|
+
* The error for an append-saga chunk whose own outcome could not be
|
|
209
|
+
* established, raised once every chunk this call *could* confirm has already
|
|
210
|
+
* been undone — the rollback itself did not fail; this chunk alone could not
|
|
211
|
+
* be read back, or its write may still be applied after the read.
|
|
212
|
+
*
|
|
213
|
+
* Accepts: `cause` — the failing chunk's own failure. `unsettledBecause` —
|
|
214
|
+
* why its outcome is unknown: the read-back's own failure, or the write's
|
|
215
|
+
* own failure, when some attempt of it may still be applied. Both are built
|
|
216
|
+
* from a `catch`, so either may be whatever a `throw` produced rather than
|
|
217
|
+
* an `Error`.
|
|
218
|
+
*
|
|
219
|
+
* Returns: a `COMPENSATION_FAILED` error carrying `cause` as `cause` and
|
|
220
|
+
* `unsettledBecause` as `details.rollbackError`, each normalised through
|
|
221
|
+
* `toError` so both are always error-shaped. Its message says the chunk's
|
|
222
|
+
* own fate could not be established — never that a rollback failed, since
|
|
223
|
+
* every chunk this call could confirm was already rolled back before this is
|
|
224
|
+
* raised. The session's `messageCount` may have drifted, which
|
|
225
|
+
* `reconcileMessageCount` repairs; the quoted text of both errors is
|
|
226
|
+
* redacted before it is embedded.
|
|
227
|
+
*
|
|
228
|
+
* Throws: nothing; building an error may not fail. Reading `.message` off a
|
|
229
|
+
* thrown `null` or `undefined` would throw here, which is why `toError`
|
|
230
|
+
* normalises both `cause` and `unsettledBecause` before anything reads off
|
|
231
|
+
* them.
|
|
232
|
+
*/
|
|
233
|
+
export declare function unsettledAppendError(cause: Error, unsettledBecause: Error): DynamoDBLangGraphError<ErrorCode.COMPENSATION_FAILED>;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { redactedMessage } from '../logging/secret-patterns.js';
|
|
2
|
+
import { DynamoDBLangGraphError, toError, } from './base-error.js';
|
|
3
|
+
import { awsDiagnostics } from './classify.js';
|
|
4
|
+
import { ErrorCode } from './error-code.js';
|
|
5
|
+
function build(factory, spec) {
|
|
6
|
+
const error = new DynamoDBLangGraphError(spec.message, spec.code, spec.context, spec.cause, spec.details);
|
|
7
|
+
Error.captureStackTrace(error, factory);
|
|
8
|
+
return error;
|
|
9
|
+
}
|
|
10
|
+
export function validationError(message, field, cause) {
|
|
11
|
+
return build(validationError, {
|
|
12
|
+
message,
|
|
13
|
+
code: ErrorCode.VALIDATION,
|
|
14
|
+
context: field === undefined ? {} : { field },
|
|
15
|
+
cause,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
export function conflictError(message, cause) {
|
|
19
|
+
return build(conflictError, { message, code: ErrorCode.CONDITION_CONFLICT, context: {}, cause });
|
|
20
|
+
}
|
|
21
|
+
const MAY_STILL_LAND = Symbol('retryBudget.mayStillLand');
|
|
22
|
+
export function markMayStillLand(error) {
|
|
23
|
+
if (typeof error === 'object' && error !== null && Object.isExtensible(error)) {
|
|
24
|
+
Object.defineProperty(error, MAY_STILL_LAND, { value: true, enumerable: false });
|
|
25
|
+
}
|
|
26
|
+
return error;
|
|
27
|
+
}
|
|
28
|
+
export function retryExhaustedError(message, attempts, cause, mayStillLand = false) {
|
|
29
|
+
const error = build(retryExhaustedError, {
|
|
30
|
+
message,
|
|
31
|
+
code: ErrorCode.RETRY_EXHAUSTED,
|
|
32
|
+
context: {
|
|
33
|
+
...(attempts === undefined ? {} : { attempts }),
|
|
34
|
+
...(cause === undefined ? {} : awsDiagnostics(cause)),
|
|
35
|
+
},
|
|
36
|
+
cause,
|
|
37
|
+
});
|
|
38
|
+
Object.defineProperty(error, MAY_STILL_LAND, { value: mayStillLand, enumerable: false });
|
|
39
|
+
return error;
|
|
40
|
+
}
|
|
41
|
+
export function retryBudgetMayStillLand(error) {
|
|
42
|
+
if (typeof error !== 'object' || error === null)
|
|
43
|
+
return false;
|
|
44
|
+
return error[MAY_STILL_LAND] === true;
|
|
45
|
+
}
|
|
46
|
+
export function resultTruncatedError(cap, limit) {
|
|
47
|
+
return build(resultTruncatedError, {
|
|
48
|
+
message: `paginated read truncated at the ${cap} cap (${limit}) with more data remaining`,
|
|
49
|
+
code: ErrorCode.RESULT_TRUNCATED,
|
|
50
|
+
context: { field: cap },
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
export function abortError(message = 'Operation aborted', cause) {
|
|
54
|
+
return build(abortError, { message, code: ErrorCode.ABORTED, context: {}, cause });
|
|
55
|
+
}
|
|
56
|
+
export function batchWriteIncompleteError(succeededCount, unprocessed, retries, cause) {
|
|
57
|
+
const items = Array.isArray(unprocessed) ? [...unprocessed] : [];
|
|
58
|
+
return build(batchWriteIncompleteError, {
|
|
59
|
+
message: `batchWrite did not drain after ${retries} UnprocessedItems retries: ` +
|
|
60
|
+
`${succeededCount} item(s) persisted, ${items.length} still un-acked.`,
|
|
61
|
+
code: ErrorCode.BATCH_WRITE_INCOMPLETE,
|
|
62
|
+
context: {},
|
|
63
|
+
cause,
|
|
64
|
+
details: { kind: 'drain', succeededCount, unprocessed: items, retries },
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
export function batchWriteAllIncompleteError(batch) {
|
|
68
|
+
const { succeeded, total, succeededCount = 0, unit = 'chunk' } = batch;
|
|
69
|
+
const failed = Array.isArray(batch.failures) ? [...batch.failures] : [];
|
|
70
|
+
return build(batchWriteAllIncompleteError, {
|
|
71
|
+
message: `${unit === 'chunk' ? 'batchWriteAll' : 'the partition delete'} did not fully drain: ` +
|
|
72
|
+
`${succeeded}/${total} ${unit}(s) succeeded, ` +
|
|
73
|
+
`${failed.length} ${unit}(s) failed. ${succeededCount} write(s) persisted before the failure.`,
|
|
74
|
+
code: ErrorCode.BATCH_WRITE_INCOMPLETE,
|
|
75
|
+
context: {},
|
|
76
|
+
cause: failed[0],
|
|
77
|
+
details: {
|
|
78
|
+
kind: 'pass',
|
|
79
|
+
unit,
|
|
80
|
+
succeededChunks: succeeded,
|
|
81
|
+
totalChunks: total,
|
|
82
|
+
failedChunks: failed,
|
|
83
|
+
succeededCount,
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
export function compensationFailedError(cause, rollbackError) {
|
|
88
|
+
const trigger = toError(cause);
|
|
89
|
+
const rollback = toError(rollbackError);
|
|
90
|
+
return build(compensationFailedError, {
|
|
91
|
+
message: `compensation failed after an append error: ${redactedMessage(trigger)} ` +
|
|
92
|
+
`(rollback: ${redactedMessage(rollback)})`,
|
|
93
|
+
code: ErrorCode.COMPENSATION_FAILED,
|
|
94
|
+
context: {},
|
|
95
|
+
cause: trigger,
|
|
96
|
+
details: { rollbackError: rollback },
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
export function unsettledAppendError(cause, unsettledBecause) {
|
|
100
|
+
const trigger = toError(cause);
|
|
101
|
+
const unsettled = toError(unsettledBecause);
|
|
102
|
+
return build(unsettledAppendError, {
|
|
103
|
+
message: `an append chunk could not be settled after ${redactedMessage(trigger)} ` +
|
|
104
|
+
`(unsettled because: ${redactedMessage(unsettled)})`,
|
|
105
|
+
code: ErrorCode.COMPENSATION_FAILED,
|
|
106
|
+
context: {},
|
|
107
|
+
cause: trigger,
|
|
108
|
+
details: { rollbackError: unsettled },
|
|
109
|
+
});
|
|
110
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Hides that a caller's logger is foreign code that may throw.
|
|
4
3
|
*
|
|
@@ -8,17 +7,27 @@
|
|
|
8
7
|
* of its own, and where a throw is absorbed, and what becomes of the line it
|
|
9
8
|
* was writing, can change here without touching any call site.
|
|
10
9
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
/** A value safe to pass as a structured log argument. */
|
|
11
|
+
export type LogArgument = string | number | boolean | null | object;
|
|
12
|
+
/**
|
|
13
|
+
* Pluggable logging interface — consumers supply their own implementation.
|
|
14
|
+
* `args` are structured fields, at most one plain object per call, so an
|
|
15
|
+
* adapter for a structured logger (pino, winston) can merge them into one
|
|
16
|
+
* record; the message is a fixed string and never carries a value.
|
|
17
|
+
*
|
|
18
|
+
* It is the one piece of foreign code every adapter of this package calls,
|
|
19
|
+
* almost always from a `catch` block, so an adapter wraps it: anything one of
|
|
20
|
+
* its methods throws is absorbed at the log call and never replaces the error
|
|
21
|
+
* being reported.
|
|
22
|
+
*/
|
|
23
|
+
export interface Logger {
|
|
24
|
+
info(message: string, ...args: LogArgument[]): void;
|
|
25
|
+
warn(message: string, ...args: LogArgument[]): void;
|
|
26
|
+
error(message: string, ...args: LogArgument[]): void;
|
|
27
|
+
debug(message: string, ...args: LogArgument[]): void;
|
|
28
|
+
}
|
|
15
29
|
/** Default logger: discards everything. Inject a real logger to enable output. */
|
|
16
|
-
|
|
17
|
-
info() { },
|
|
18
|
-
warn() { },
|
|
19
|
-
error() { },
|
|
20
|
-
debug() { },
|
|
21
|
-
};
|
|
30
|
+
export declare const SILENT_LOGGER: Logger;
|
|
22
31
|
/**
|
|
23
32
|
* Run one log call so that a failure of the caller's own logger cannot become
|
|
24
33
|
* the caller's problem.
|
|
@@ -45,44 +54,7 @@ exports.SILENT_LOGGER = {
|
|
|
45
54
|
* statement runs, so a path that says what it is about to do and then does it
|
|
46
55
|
* cannot be stopped between the two by the saying.
|
|
47
56
|
*/
|
|
48
|
-
function absorbLoggerFailure(emit)
|
|
49
|
-
try {
|
|
50
|
-
emit();
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
// Nowhere left to say it: the reporting channel is the broken part.
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* `inner` with each level wrapped so a throw out of it stops at the log call.
|
|
58
|
-
*
|
|
59
|
-
* A `Logger` is an interface a consumer implements, so every log call this
|
|
60
|
-
* package makes runs foreign code, and almost every one of them is made from
|
|
61
|
-
* inside a `catch`: one that stringifies a circular object, whose transport
|
|
62
|
-
* has closed, or that asserts on a field it did not expect replaces the error
|
|
63
|
-
* the caller actually needs to see with its own. At the retry hook the damage
|
|
64
|
-
* is larger than a swap — `withRetry` calls `onRetry` synchronously and does
|
|
65
|
-
* not catch it, so a logger that throws ends an operation that was still
|
|
66
|
-
* succeeding, after its first transient failure.
|
|
67
|
-
*
|
|
68
|
-
* Wrapped once per adapter, here, rather than remembered at each of the three
|
|
69
|
-
* dozen call sites: a site that forgets is a site whose failure path reports
|
|
70
|
-
* the wrong error, and those sites are exactly the ones a test suite exercises
|
|
71
|
-
* least. `absorbLoggerFailure` stays for the places that promise,
|
|
72
|
-
* with no precondition on the logger they were handed, never to throw:
|
|
73
|
-
* `redactLogger`, which a caller may wrap any logger with, the S3 orphan
|
|
74
|
-
* cleanup, and the chat history's append compensation, whose announcement must
|
|
75
|
-
* not be able to stop the rollback it announces.
|
|
76
|
-
*/
|
|
77
|
-
function containedLogger(inner) {
|
|
78
|
-
const deliver = (level) => (message, ...args) => absorbLoggerFailure(() => inner[level](message, ...args));
|
|
79
|
-
return {
|
|
80
|
-
info: deliver('info'),
|
|
81
|
-
warn: deliver('warn'),
|
|
82
|
-
error: deliver('error'),
|
|
83
|
-
debug: deliver('debug'),
|
|
84
|
-
};
|
|
85
|
-
}
|
|
57
|
+
export declare function absorbLoggerFailure(emit: () => void): void;
|
|
86
58
|
/**
|
|
87
59
|
* Resolve an optional logger to a concrete one.
|
|
88
60
|
*
|
|
@@ -105,6 +77,4 @@ function containedLogger(inner) {
|
|
|
105
77
|
* that cannot throw, so no `catch` block, and no retry hook, has to treat a log
|
|
106
78
|
* call as a failure path of its own.
|
|
107
79
|
*/
|
|
108
|
-
function resolveLogger(logger)
|
|
109
|
-
return logger === undefined ? exports.SILENT_LOGGER : containedLogger(logger);
|
|
110
|
-
}
|
|
80
|
+
export declare function resolveLogger(logger?: Logger): Logger;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const SILENT_LOGGER = {
|
|
2
|
+
info() { },
|
|
3
|
+
warn() { },
|
|
4
|
+
error() { },
|
|
5
|
+
debug() { },
|
|
6
|
+
};
|
|
7
|
+
export function absorbLoggerFailure(emit) {
|
|
8
|
+
try {
|
|
9
|
+
emit();
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function containedLogger(inner) {
|
|
15
|
+
const deliver = (level) => (message, ...args) => absorbLoggerFailure(() => inner[level](message, ...args));
|
|
16
|
+
return {
|
|
17
|
+
info: deliver('info'),
|
|
18
|
+
warn: deliver('warn'),
|
|
19
|
+
error: deliver('error'),
|
|
20
|
+
debug: deliver('debug'),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export function resolveLogger(logger) {
|
|
24
|
+
return logger === undefined ? SILENT_LOGGER : containedLogger(logger);
|
|
25
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides how a logger and a value are redacted.
|
|
3
|
+
*
|
|
4
|
+
* A redacting logger walks every argument of every line, bounded in depth and
|
|
5
|
+
* safe against cycles and hostile getters, and replaces the value of any key
|
|
6
|
+
* that looks like a secret and any text that looks like one; the same walk
|
|
7
|
+
* serves `redactSecrets` for a value a caller wants to log themselves.
|
|
8
|
+
*/
|
|
9
|
+
import { type LogArgument, type Logger } from './logger.js';
|
|
10
|
+
/**
|
|
11
|
+
* Recursively clone `value`, replacing any value at a secret-looking key with
|
|
12
|
+
* `[REDACTED]` and any recognised secret *shape* inside a string — including an
|
|
13
|
+
* error's `message`/`stack` text, which key-name matching cannot reach — with
|
|
14
|
+
* the same marker. Cycles become `[Circular]`.
|
|
15
|
+
*
|
|
16
|
+
* An Error with no own enumerable properties whose text holds no secret is
|
|
17
|
+
* passed through by reference, so its identity and stack trace survive; one
|
|
18
|
+
* carrying own data (this library's error types all attach `code`/`context`
|
|
19
|
+
* this way) or a secret in its text is rebuilt instead, with `name`/`message`/
|
|
20
|
+
* `stack` redacted and every other own property recursed like a plain object.
|
|
21
|
+
* `Date`/`RegExp` keep their identity rather than collapsing to `{}`,
|
|
22
|
+
* `Set`/`Map` render as their contents, and binary views become a short label.
|
|
23
|
+
*
|
|
24
|
+
* Accepts: `value` — any log argument, including `undefined`, a primitive, a
|
|
25
|
+
* typed `Error`, a class instance or a `Record`, so callers never cast. A
|
|
26
|
+
* cyclic or shared graph is fine; each node is walked once. `patterns` and
|
|
27
|
+
* `valuePatterns` — the key names and value shapes to redact, an array of
|
|
28
|
+
* strings and an array of `RegExp` respectively; both default to this
|
|
29
|
+
* package's own lists, and an empty one turns that rule off. A key name is
|
|
30
|
+
* matched by its normalised form — lower-case, punctuation removed — against
|
|
31
|
+
* the end of each key's, so `'apiKey'` covers `x-api-key` and `API_KEY`.
|
|
32
|
+
*
|
|
33
|
+
* Returns: a redacted clone. The input is never mutated — a logger that
|
|
34
|
+
* scrubbed the caller's own object would corrupt the very data the application
|
|
35
|
+
* is working with.
|
|
36
|
+
*
|
|
37
|
+
* Throws: `VALIDATION` naming `patterns` or `valuePatterns` for a list this
|
|
38
|
+
* function could not apply — a non-array, a wrong entry, or a key name with
|
|
39
|
+
* no letter or digit in it, which would match every key — which is a mistake
|
|
40
|
+
* in the call itself and is raised before anything is walked. Nothing after
|
|
41
|
+
* that: a value whose
|
|
42
|
+
* redaction fails — a throwing getter, a structure deep enough to exhaust the
|
|
43
|
+
* stack — is replaced whole by `[UNREDACTABLE]`, since a logger that throws
|
|
44
|
+
* takes down the operation it was only observing. {@link redactLogger}
|
|
45
|
+
* redacts one argument per call, so there a single hostile argument is what is
|
|
46
|
+
* lost rather than the record around it.
|
|
47
|
+
*/
|
|
48
|
+
export declare function redactSecrets(value: LogArgument | undefined, patterns?: readonly string[], valuePatterns?: readonly RegExp[]): Redactable;
|
|
49
|
+
/** Options controlling {@link redactLogger}. */
|
|
50
|
+
export interface RedactLoggerOptions {
|
|
51
|
+
/**
|
|
52
|
+
* Additional key names to redact. Matched like the defaults: a key is
|
|
53
|
+
* redacted when its normalised form (lower-case, punctuation removed) equals
|
|
54
|
+
* or ends with the normalised name, so `'ssn'` covers `SSN` and `user_ssn`.
|
|
55
|
+
*/
|
|
56
|
+
extraKeys?: readonly string[];
|
|
57
|
+
/**
|
|
58
|
+
* Additional secret shapes to redact wherever they appear inside a string.
|
|
59
|
+
* A pattern's first capture group, if it has one, is preserved verbatim and
|
|
60
|
+
* only the remainder of the match is replaced.
|
|
61
|
+
*/
|
|
62
|
+
extraValuePatterns?: readonly RegExp[];
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Wrap a logger so object args are redacted before delegation.
|
|
66
|
+
*
|
|
67
|
+
* Accepts: `inner` — the logger to delegate to; it must carry all four
|
|
68
|
+
* methods, because a missing one is a wiring mistake worth naming here rather
|
|
69
|
+
* than at the first log line. `options.extraKeys` — further key names to
|
|
70
|
+
* redact, matched like the defaults. `options.extraValuePatterns` — further
|
|
71
|
+
* secret shapes; each must be a `RegExp`, and it is applied globally whether or
|
|
72
|
+
* not it carries the `g` flag.
|
|
73
|
+
*
|
|
74
|
+
* Returns: a logger with the same four methods.
|
|
75
|
+
*
|
|
76
|
+
* Throws: `VALIDATION` naming `logger` or `logger.<method>` for a logger it
|
|
77
|
+
* could not delegate to, and `options`, `extraKeys` or `extraValuePatterns`
|
|
78
|
+
* for an option of the wrong type. Nothing at log time.
|
|
79
|
+
*
|
|
80
|
+
* Guarantees: the message string is passed through unchanged — never
|
|
81
|
+
* interpolate a secret into it — and every other argument is redacted before
|
|
82
|
+
* it reaches `inner`. Past the wrap call nothing escapes a log call: an
|
|
83
|
+
* argument whose redaction fails is replaced by a fixed marker, and a failure
|
|
84
|
+
* of `inner` itself is absorbed, because the
|
|
85
|
+
* operation that wrote the line was only observing itself and is commonly
|
|
86
|
+
* reporting some other failure already.
|
|
87
|
+
*/
|
|
88
|
+
export declare function redactLogger(inner: Logger, options?: RedactLoggerOptions): Logger;
|
|
89
|
+
/** A value that {@link redactSecrets} can recurse through. */
|
|
90
|
+
export type Redactable = string | number | boolean | null | undefined | Redactable[] | {
|
|
91
|
+
[key: string]: Redactable;
|
|
92
|
+
};
|
|
93
|
+
/** Any `Redactable` that is a non-null object — what the walk dispatches on. */
|
|
94
|
+
export type RedactableObject = Redactable[] | {
|
|
95
|
+
[key: string]: Redactable;
|
|
96
|
+
};
|
|
97
|
+
/** One step of the recursive walk, threaded into the entry helpers. */
|
|
98
|
+
type Walk = (value: Redactable) => Redactable;
|
|
99
|
+
/** Collaborators threaded through the recursive walk. */
|
|
100
|
+
export interface WalkDeps {
|
|
101
|
+
keyPatterns: readonly string[];
|
|
102
|
+
valuePatterns: readonly RegExp[];
|
|
103
|
+
walk: Walk;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Dispatch one non-null object by its shape.
|
|
107
|
+
*
|
|
108
|
+
* Accepts: `current` — any object. `deps.walk` — how to recurse, which carries
|
|
109
|
+
* the cycle and memo state this module deliberately does not own.
|
|
110
|
+
*
|
|
111
|
+
* Returns: the redacted form — arrays and plain objects recursed, binary views
|
|
112
|
+
* collapsed to a label, `Date`/`RegExp` passed through by reference so they do
|
|
113
|
+
* not become `{}`, `Set`/`Map` rendered as their contents, and an Error through
|
|
114
|
+
* the error path, which preserves the non-enumerable text a plain walk cannot
|
|
115
|
+
* see.
|
|
116
|
+
*
|
|
117
|
+
* Throws: whatever a property getter on the value throws. `redactSecrets`, the
|
|
118
|
+
* only caller, catches it and returns `[UNREDACTABLE]` in place of the whole
|
|
119
|
+
* value it was given, rather than raising a getter's error at a caller who
|
|
120
|
+
* asked only for a copy it could log.
|
|
121
|
+
*/
|
|
122
|
+
export declare function walkObject(current: RedactableObject, deps: WalkDeps): Redactable;
|
|
123
|
+
export {};
|