@farukada/aws-langgraph-dynamodb-ts 1.0.0-rc.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1820 -290
- package/dist/cjs/backfill/backfill.d.ts +171 -0
- package/dist/cjs/backfill/backfill.js +177 -0
- package/dist/cjs/checkpointer/actions/delete-thread.d.ts +50 -0
- package/dist/cjs/checkpointer/actions/delete-thread.js +26 -0
- package/dist/cjs/checkpointer/actions/get-tuple.d.ts +36 -0
- package/dist/cjs/checkpointer/actions/get-tuple.js +22 -0
- package/dist/cjs/checkpointer/actions/list.d.ts +55 -0
- package/dist/cjs/checkpointer/actions/list.js +70 -0
- package/dist/cjs/checkpointer/actions/put-writes.d.ts +49 -0
- package/dist/cjs/checkpointer/actions/put-writes.js +21 -0
- package/dist/cjs/checkpointer/actions/put.d.ts +95 -0
- package/dist/cjs/checkpointer/actions/put.js +79 -0
- package/dist/cjs/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/cjs/checkpointer/internal/delta-history.js +131 -0
- package/dist/cjs/checkpointer/internal/listing.d.ts +149 -0
- package/dist/cjs/checkpointer/internal/listing.js +104 -0
- package/dist/cjs/checkpointer/internal/parse.d.ts +298 -0
- package/dist/cjs/checkpointer/internal/parse.js +184 -0
- package/dist/cjs/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/cjs/checkpointer/internal/pending-writes.js +241 -0
- package/dist/cjs/checkpointer/internal/read.d.ts +135 -0
- package/dist/cjs/checkpointer/internal/read.js +132 -0
- package/dist/cjs/checkpointer/internal/rows.d.ts +644 -0
- package/dist/cjs/checkpointer/internal/rows.js +356 -0
- package/dist/cjs/checkpointer/internal/setup.d.ts +47 -0
- package/dist/cjs/checkpointer/internal/setup.js +25 -0
- package/dist/cjs/checkpointer/saver.d.ts +306 -0
- package/dist/cjs/checkpointer/saver.js +56 -0
- package/dist/cjs/checkpointer/types.d.ts +51 -0
- package/dist/cjs/factory/factory.d.ts +154 -0
- package/dist/cjs/factory/factory.js +137 -0
- package/dist/{factory → cjs/factory}/types.d.ts +33 -14
- package/dist/cjs/history/actions/add-messages.d.ts +51 -0
- package/dist/cjs/history/actions/add-messages.js +17 -0
- package/dist/cjs/history/actions/clear.d.ts +52 -0
- package/dist/cjs/history/actions/clear.js +29 -0
- package/dist/cjs/history/actions/get-messages.d.ts +60 -0
- package/dist/cjs/history/actions/get-messages.js +58 -0
- package/dist/cjs/history/actions/list-sessions.d.ts +55 -0
- package/dist/cjs/history/actions/list-sessions.js +67 -0
- package/dist/cjs/history/actions/reconcile-count.d.ts +49 -0
- package/dist/cjs/history/actions/reconcile-count.js +8 -0
- package/dist/cjs/history/chat-message-history.d.ts +267 -0
- package/dist/cjs/history/chat-message-history.js +61 -0
- package/dist/cjs/history/internal/append.d.ts +244 -0
- package/dist/cjs/history/internal/append.js +267 -0
- package/dist/cjs/history/internal/message-read.d.ts +84 -0
- package/dist/cjs/history/internal/message-read.js +93 -0
- package/dist/cjs/history/internal/parse.d.ts +153 -0
- package/dist/cjs/history/internal/parse.js +113 -0
- package/dist/cjs/history/internal/rows.d.ts +196 -0
- package/dist/cjs/history/internal/rows.js +96 -0
- package/dist/cjs/history/internal/session.d.ts +350 -0
- package/dist/cjs/history/internal/session.js +296 -0
- package/dist/cjs/history/internal/setup.d.ts +64 -0
- package/dist/cjs/history/internal/setup.js +60 -0
- package/dist/cjs/history/session-adapter.d.ts +112 -0
- package/dist/cjs/history/session-adapter.js +38 -0
- package/dist/cjs/history/types.d.ts +102 -0
- package/dist/cjs/index.d.ts +53 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/shared/adapter.d.ts +146 -0
- package/dist/cjs/shared/adapter.js +70 -0
- package/dist/cjs/shared/clock.d.ts +52 -0
- package/dist/cjs/shared/clock.js +14 -0
- package/dist/cjs/shared/codec/codec.d.ts +336 -0
- package/dist/cjs/shared/codec/codec.js +162 -0
- package/dist/cjs/shared/codec/compression.d.ts +66 -0
- package/dist/cjs/shared/codec/compression.js +45 -0
- package/dist/cjs/shared/codec/json-serde.d.ts +80 -0
- package/dist/cjs/shared/codec/json-serde.js +58 -0
- package/dist/{shared → cjs/shared}/codec/s3/client-types.d.ts +22 -2
- package/dist/{shared → cjs/shared}/codec/s3/client-types.js +0 -1
- package/dist/cjs/shared/codec/s3/client.d.ts +63 -0
- package/dist/cjs/shared/codec/s3/client.js +78 -0
- package/dist/cjs/shared/codec/s3/config.d.ts +260 -0
- package/dist/cjs/shared/codec/s3/config.js +92 -0
- package/dist/cjs/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/cjs/shared/codec/s3/lifecycle.js +223 -0
- package/dist/cjs/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/cjs/shared/codec/s3/offloader.js +289 -0
- package/dist/cjs/shared/concurrency.d.ts +43 -0
- package/dist/{shared → cjs/shared}/concurrency.js +10 -9
- package/dist/cjs/shared/dynamodb/abort.d.ts +47 -0
- package/dist/cjs/shared/dynamodb/abort.js +16 -0
- package/dist/cjs/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/cjs/shared/dynamodb/batch-write.js +79 -0
- package/dist/cjs/shared/dynamodb/cancellation.d.ts +124 -0
- package/dist/cjs/shared/dynamodb/cancellation.js +37 -0
- package/dist/cjs/shared/dynamodb/client.d.ts +177 -0
- package/dist/{shared → cjs/shared}/dynamodb/client.js +12 -14
- package/dist/cjs/shared/dynamodb/idempotent-write.d.ts +596 -0
- package/dist/cjs/shared/dynamodb/idempotent-write.js +173 -0
- package/dist/cjs/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/cjs/shared/dynamodb/paginate.js +90 -0
- package/dist/cjs/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/cjs/shared/dynamodb/partition-delete.js +177 -0
- package/dist/cjs/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/cjs/shared/dynamodb/recency-index.js +146 -0
- package/dist/cjs/shared/dynamodb/retry.d.ts +317 -0
- package/dist/cjs/shared/dynamodb/retry.js +193 -0
- package/dist/cjs/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/cjs/shared/dynamodb/row-size.js +30 -0
- package/dist/cjs/shared/dynamodb/table-schema.d.ts +199 -0
- package/dist/cjs/shared/dynamodb/table-schema.js +52 -0
- package/dist/cjs/shared/errors/base-error.d.ts +231 -0
- package/dist/cjs/shared/errors/base-error.js +73 -0
- package/dist/cjs/shared/errors/boundary.d.ts +86 -0
- package/dist/cjs/shared/errors/boundary.js +61 -0
- package/dist/cjs/shared/errors/classify.d.ts +206 -0
- package/dist/cjs/shared/errors/classify.js +232 -0
- package/dist/cjs/shared/errors/error-code.d.ts +95 -0
- package/dist/{shared → cjs/shared}/errors/error-code.js +12 -2
- package/dist/cjs/shared/errors/errors.d.ts +233 -0
- package/dist/cjs/shared/errors/errors.js +123 -0
- package/dist/cjs/shared/logging/logger.d.ts +80 -0
- package/dist/cjs/shared/logging/logger.js +30 -0
- package/dist/cjs/shared/logging/redaction.d.ts +123 -0
- package/dist/cjs/shared/logging/redaction.js +145 -0
- package/dist/cjs/shared/logging/secret-patterns.d.ts +227 -0
- package/dist/cjs/shared/logging/secret-patterns.js +93 -0
- package/dist/cjs/shared/logging/truncate.d.ts +197 -0
- package/dist/cjs/shared/logging/truncate.js +31 -0
- package/dist/cjs/shared/options.d.ts +100 -0
- package/dist/cjs/shared/ulid.d.ts +80 -0
- package/dist/{shared → cjs/shared}/ulid.js +7 -21
- package/dist/cjs/shared/validation/collaborators.d.ts +160 -0
- package/dist/cjs/shared/validation/collaborators.js +79 -0
- package/dist/cjs/shared/validation/option-shape.d.ts +91 -0
- package/dist/cjs/shared/validation/option-shape.js +31 -0
- package/dist/cjs/shared/validation/options.d.ts +145 -0
- package/dist/cjs/shared/validation/options.js +166 -0
- package/dist/cjs/shared/validation/primitives.d.ts +292 -0
- package/dist/cjs/shared/validation/primitives.js +114 -0
- package/dist/cjs/shared/validation/ttl.d.ts +94 -0
- package/dist/cjs/shared/validation/ttl.js +52 -0
- package/dist/cjs/store/actions/list-namespaces.d.ts +79 -0
- package/dist/cjs/store/actions/list-namespaces.js +92 -0
- package/dist/cjs/store/actions/put.d.ts +43 -0
- package/dist/cjs/store/actions/put.js +49 -0
- package/dist/cjs/store/actions/reconcile-vector-index.d.ts +38 -0
- package/dist/cjs/store/actions/reconcile-vector-index.js +13 -0
- package/dist/cjs/store/actions/search.d.ts +38 -0
- package/dist/cjs/store/actions/search.js +26 -0
- package/dist/cjs/store/internal/batch-plan.d.ts +56 -0
- package/dist/cjs/store/internal/batch-plan.js +32 -0
- package/dist/cjs/store/internal/filter.d.ts +43 -0
- package/dist/cjs/store/internal/filter.js +64 -0
- package/dist/cjs/store/internal/get-item.d.ts +77 -0
- package/dist/cjs/store/internal/get-item.js +58 -0
- package/dist/cjs/store/internal/item-write.d.ts +270 -0
- package/dist/cjs/store/internal/item-write.js +181 -0
- package/dist/cjs/store/internal/parse.d.ts +230 -0
- package/dist/cjs/store/internal/parse.js +180 -0
- package/dist/cjs/store/internal/rows.d.ts +359 -0
- package/dist/cjs/store/internal/rows.js +166 -0
- package/dist/cjs/store/internal/semantic-search.d.ts +168 -0
- package/dist/{store/internal/text-path.js → cjs/store/internal/semantic-search.js} +92 -28
- package/dist/cjs/store/internal/setup.d.ts +96 -0
- package/dist/cjs/store/internal/setup.js +103 -0
- package/dist/cjs/store/internal/table-search.d.ts +100 -0
- package/dist/cjs/store/internal/table-search.js +123 -0
- package/dist/cjs/store/internal/vector-index.d.ts +258 -0
- package/dist/cjs/store/internal/vector-index.js +269 -0
- package/dist/cjs/store/store.d.ts +329 -0
- package/dist/cjs/store/store.js +97 -0
- package/dist/cjs/store/types.d.ts +111 -0
- package/dist/cjs/store/vector-backend.d.ts +104 -0
- package/dist/cjs/store/vector-backend.js +4 -0
- package/dist/esm/backfill/backfill.d.ts +171 -0
- package/dist/esm/backfill/backfill.js +170 -0
- package/dist/esm/checkpointer/actions/delete-thread.d.ts +50 -0
- package/dist/esm/checkpointer/actions/delete-thread.js +23 -0
- package/dist/esm/checkpointer/actions/get-tuple.d.ts +36 -0
- package/dist/esm/checkpointer/actions/get-tuple.js +19 -0
- package/dist/esm/checkpointer/actions/list.d.ts +55 -0
- package/dist/esm/checkpointer/actions/list.js +67 -0
- package/dist/esm/checkpointer/actions/put-writes.d.ts +49 -0
- package/dist/esm/checkpointer/actions/put-writes.js +18 -0
- package/dist/esm/checkpointer/actions/put.d.ts +95 -0
- package/dist/esm/checkpointer/actions/put.js +75 -0
- package/dist/esm/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/esm/checkpointer/internal/delta-history.js +126 -0
- package/dist/esm/checkpointer/internal/listing.d.ts +149 -0
- package/dist/esm/checkpointer/internal/listing.js +95 -0
- package/dist/esm/checkpointer/internal/parse.d.ts +298 -0
- package/dist/esm/checkpointer/internal/parse.js +169 -0
- package/dist/esm/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/esm/checkpointer/internal/pending-writes.js +229 -0
- package/dist/esm/checkpointer/internal/read.d.ts +135 -0
- package/dist/esm/checkpointer/internal/read.js +125 -0
- package/dist/esm/checkpointer/internal/rows.d.ts +644 -0
- package/dist/esm/checkpointer/internal/rows.js +323 -0
- package/dist/esm/checkpointer/internal/setup.d.ts +47 -0
- package/dist/esm/checkpointer/internal/setup.js +21 -0
- package/dist/esm/checkpointer/saver.d.ts +306 -0
- package/dist/esm/checkpointer/saver.js +52 -0
- package/dist/esm/checkpointer/types.d.ts +51 -0
- package/dist/esm/checkpointer/types.js +1 -0
- package/dist/esm/factory/factory.d.ts +154 -0
- package/dist/esm/factory/factory.js +133 -0
- package/dist/esm/factory/types.d.ts +76 -0
- package/dist/esm/factory/types.js +1 -0
- package/dist/esm/history/actions/add-messages.d.ts +51 -0
- package/dist/esm/history/actions/add-messages.js +14 -0
- package/dist/esm/history/actions/clear.d.ts +52 -0
- package/dist/esm/history/actions/clear.js +26 -0
- package/dist/esm/history/actions/get-messages.d.ts +60 -0
- package/dist/esm/history/actions/get-messages.js +55 -0
- package/dist/esm/history/actions/list-sessions.d.ts +55 -0
- package/dist/esm/history/actions/list-sessions.js +64 -0
- package/dist/esm/history/actions/reconcile-count.d.ts +49 -0
- package/dist/esm/history/actions/reconcile-count.js +5 -0
- package/dist/esm/history/chat-message-history.d.ts +267 -0
- package/dist/esm/history/chat-message-history.js +57 -0
- package/dist/esm/history/internal/append.d.ts +244 -0
- package/dist/esm/history/internal/append.js +259 -0
- package/dist/esm/history/internal/message-read.d.ts +84 -0
- package/dist/esm/history/internal/message-read.js +89 -0
- package/dist/esm/history/internal/parse.d.ts +153 -0
- package/dist/esm/history/internal/parse.js +105 -0
- package/dist/esm/history/internal/rows.d.ts +196 -0
- package/dist/esm/history/internal/rows.js +83 -0
- package/dist/esm/history/internal/session.d.ts +350 -0
- package/dist/esm/history/internal/session.js +285 -0
- package/dist/esm/history/internal/setup.d.ts +64 -0
- package/dist/esm/history/internal/setup.js +56 -0
- package/dist/esm/history/session-adapter.d.ts +112 -0
- package/dist/esm/history/session-adapter.js +34 -0
- package/dist/esm/history/types.d.ts +102 -0
- package/dist/esm/history/types.js +1 -0
- package/dist/esm/index.d.ts +53 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/shared/adapter.d.ts +146 -0
- package/dist/esm/shared/adapter.js +65 -0
- package/dist/esm/shared/clock.d.ts +52 -0
- package/dist/esm/shared/clock.js +9 -0
- package/dist/esm/shared/codec/codec.d.ts +336 -0
- package/dist/esm/shared/codec/codec.js +150 -0
- package/dist/esm/shared/codec/compression.d.ts +66 -0
- package/dist/esm/shared/codec/compression.js +40 -0
- package/dist/esm/shared/codec/json-serde.d.ts +80 -0
- package/dist/esm/shared/codec/json-serde.js +54 -0
- package/dist/esm/shared/codec/s3/client-types.d.ts +54 -0
- package/dist/esm/shared/codec/s3/client-types.js +3 -0
- package/dist/esm/shared/codec/s3/client.d.ts +63 -0
- package/dist/esm/shared/codec/s3/client.js +40 -0
- package/dist/esm/shared/codec/s3/config.d.ts +260 -0
- package/dist/esm/shared/codec/s3/config.js +79 -0
- package/dist/esm/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/esm/shared/codec/s3/lifecycle.js +214 -0
- package/dist/esm/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/esm/shared/codec/s3/offloader.js +278 -0
- package/dist/esm/shared/concurrency.d.ts +43 -0
- package/dist/esm/shared/concurrency.js +27 -0
- package/dist/esm/shared/dynamodb/abort.d.ts +47 -0
- package/dist/esm/shared/dynamodb/abort.js +12 -0
- package/dist/esm/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/esm/shared/dynamodb/batch-write.js +74 -0
- package/dist/esm/shared/dynamodb/cancellation.d.ts +124 -0
- package/dist/esm/shared/dynamodb/cancellation.js +30 -0
- package/dist/esm/shared/dynamodb/client.d.ts +177 -0
- package/dist/esm/shared/dynamodb/client.js +35 -0
- package/dist/esm/shared/dynamodb/idempotent-write.d.ts +596 -0
- package/dist/esm/shared/dynamodb/idempotent-write.js +153 -0
- package/dist/esm/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/esm/shared/dynamodb/paginate.js +84 -0
- package/dist/esm/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/esm/shared/dynamodb/partition-delete.js +171 -0
- package/dist/esm/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/esm/shared/dynamodb/recency-index.js +136 -0
- package/dist/esm/shared/dynamodb/retry.d.ts +317 -0
- package/dist/esm/shared/dynamodb/retry.js +180 -0
- package/dist/esm/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/esm/shared/dynamodb/row-size.js +26 -0
- package/dist/esm/shared/dynamodb/table-schema.d.ts +199 -0
- package/dist/esm/shared/dynamodb/table-schema.js +43 -0
- package/dist/esm/shared/errors/base-error.d.ts +231 -0
- package/dist/esm/shared/errors/base-error.js +64 -0
- package/dist/esm/shared/errors/boundary.d.ts +86 -0
- package/dist/esm/shared/errors/boundary.js +54 -0
- package/dist/esm/shared/errors/classify.d.ts +206 -0
- package/dist/esm/shared/errors/classify.js +220 -0
- package/dist/esm/shared/errors/error-code.d.ts +95 -0
- package/dist/esm/shared/errors/error-code.js +24 -0
- package/dist/esm/shared/errors/errors.d.ts +233 -0
- package/dist/esm/shared/errors/errors.js +110 -0
- package/dist/esm/shared/logging/logger.d.ts +80 -0
- package/dist/esm/shared/logging/logger.js +25 -0
- package/dist/esm/shared/logging/redaction.d.ts +123 -0
- package/dist/esm/shared/logging/redaction.js +140 -0
- package/dist/esm/shared/logging/secret-patterns.d.ts +227 -0
- package/dist/esm/shared/logging/secret-patterns.js +83 -0
- package/dist/esm/shared/logging/truncate.d.ts +197 -0
- package/dist/esm/shared/logging/truncate.js +25 -0
- package/dist/esm/shared/options.d.ts +100 -0
- package/dist/esm/shared/options.js +1 -0
- package/dist/esm/shared/ulid.d.ts +80 -0
- package/dist/esm/shared/ulid.js +77 -0
- package/dist/esm/shared/validation/collaborators.d.ts +160 -0
- package/dist/esm/shared/validation/collaborators.js +70 -0
- package/dist/esm/shared/validation/option-shape.d.ts +91 -0
- package/dist/esm/shared/validation/option-shape.js +24 -0
- package/dist/esm/shared/validation/options.d.ts +145 -0
- package/dist/esm/shared/validation/options.js +156 -0
- package/dist/esm/shared/validation/primitives.d.ts +292 -0
- package/dist/esm/shared/validation/primitives.js +100 -0
- package/dist/esm/shared/validation/ttl.d.ts +94 -0
- package/dist/esm/shared/validation/ttl.js +46 -0
- package/dist/esm/store/actions/list-namespaces.d.ts +79 -0
- package/dist/esm/store/actions/list-namespaces.js +86 -0
- package/dist/esm/store/actions/put.d.ts +43 -0
- package/dist/esm/store/actions/put.js +46 -0
- package/dist/esm/store/actions/reconcile-vector-index.d.ts +38 -0
- package/dist/esm/store/actions/reconcile-vector-index.js +10 -0
- package/dist/esm/store/actions/search.d.ts +38 -0
- package/dist/esm/store/actions/search.js +23 -0
- package/dist/esm/store/internal/batch-plan.d.ts +56 -0
- package/dist/esm/store/internal/batch-plan.js +28 -0
- package/dist/esm/store/internal/filter.d.ts +43 -0
- package/dist/esm/store/internal/filter.js +60 -0
- package/dist/esm/store/internal/get-item.d.ts +77 -0
- package/dist/esm/store/internal/get-item.js +54 -0
- package/dist/esm/store/internal/item-write.d.ts +270 -0
- package/dist/esm/store/internal/item-write.js +173 -0
- package/dist/esm/store/internal/parse.d.ts +230 -0
- package/dist/esm/store/internal/parse.js +169 -0
- package/dist/esm/store/internal/rows.d.ts +359 -0
- package/dist/esm/store/internal/rows.js +147 -0
- package/dist/esm/store/internal/semantic-search.d.ts +168 -0
- package/dist/esm/store/internal/semantic-search.js +200 -0
- package/dist/esm/store/internal/setup.d.ts +96 -0
- package/dist/esm/store/internal/setup.js +98 -0
- package/dist/esm/store/internal/table-search.d.ts +100 -0
- package/dist/esm/store/internal/table-search.js +119 -0
- package/dist/esm/store/internal/vector-index.d.ts +258 -0
- package/dist/esm/store/internal/vector-index.js +256 -0
- package/dist/esm/store/store.d.ts +329 -0
- package/dist/esm/store/store.js +93 -0
- package/dist/esm/store/types.d.ts +111 -0
- package/dist/esm/store/types.js +1 -0
- package/dist/esm/store/vector-backend.d.ts +104 -0
- package/dist/esm/store/vector-backend.js +1 -0
- package/package.json +68 -46
- package/dist/checkpointer/actions/delete-thread.d.ts +0 -10
- package/dist/checkpointer/actions/delete-thread.js +0 -38
- package/dist/checkpointer/actions/get-tuple.d.ts +0 -11
- package/dist/checkpointer/actions/get-tuple.js +0 -25
- package/dist/checkpointer/actions/list.d.ts +0 -20
- package/dist/checkpointer/actions/list.js +0 -113
- package/dist/checkpointer/actions/put-writes.d.ts +0 -15
- package/dist/checkpointer/actions/put-writes.js +0 -62
- package/dist/checkpointer/actions/put.d.ts +0 -17
- package/dist/checkpointer/actions/put.js +0 -73
- package/dist/checkpointer/internal/assemble.d.ts +0 -17
- package/dist/checkpointer/internal/assemble.js +0 -38
- package/dist/checkpointer/internal/checkpoint-write-verify.d.ts +0 -24
- package/dist/checkpointer/internal/checkpoint-write-verify.js +0 -67
- package/dist/checkpointer/internal/configurable.d.ts +0 -12
- package/dist/checkpointer/internal/configurable.js +0 -24
- package/dist/checkpointer/internal/fetch.d.ts +0 -19
- package/dist/checkpointer/internal/fetch.js +0 -88
- package/dist/checkpointer/internal/filter-match.d.ts +0 -13
- package/dist/checkpointer/internal/filter-match.js +0 -15
- package/dist/checkpointer/internal/item-reader.d.ts +0 -66
- package/dist/checkpointer/internal/item-reader.js +0 -113
- package/dist/checkpointer/internal/item-writer.d.ts +0 -35
- package/dist/checkpointer/internal/item-writer.js +0 -107
- package/dist/checkpointer/internal/keys.d.ts +0 -41
- package/dist/checkpointer/internal/keys.js +0 -117
- package/dist/checkpointer/internal/list-scope.d.ts +0 -61
- package/dist/checkpointer/internal/list-scope.js +0 -108
- package/dist/checkpointer/internal/pending-sends.d.ts +0 -13
- package/dist/checkpointer/internal/pending-sends.js +0 -29
- package/dist/checkpointer/internal/query.d.ts +0 -21
- package/dist/checkpointer/internal/query.js +0 -42
- package/dist/checkpointer/internal/regular-write.d.ts +0 -28
- package/dist/checkpointer/internal/regular-write.js +0 -66
- package/dist/checkpointer/internal/setup.d.ts +0 -33
- package/dist/checkpointer/internal/setup.js +0 -38
- package/dist/checkpointer/internal/special-write-cas.d.ts +0 -29
- package/dist/checkpointer/internal/special-write-cas.js +0 -104
- package/dist/checkpointer/internal/special-write-cleanup.d.ts +0 -23
- package/dist/checkpointer/internal/special-write-cleanup.js +0 -50
- package/dist/checkpointer/internal/special-write-verify.d.ts +0 -53
- package/dist/checkpointer/internal/special-write-verify.js +0 -80
- package/dist/checkpointer/internal/stored-channels.d.ts +0 -31
- package/dist/checkpointer/internal/stored-channels.js +0 -70
- package/dist/checkpointer/internal/validation.d.ts +0 -18
- package/dist/checkpointer/internal/validation.js +0 -40
- package/dist/checkpointer/internal/write-guard.d.ts +0 -20
- package/dist/checkpointer/internal/write-guard.js +0 -48
- package/dist/checkpointer/internal/write-index.d.ts +0 -36
- package/dist/checkpointer/internal/write-index.js +0 -41
- package/dist/checkpointer/saver.d.ts +0 -70
- package/dist/checkpointer/saver.js +0 -105
- package/dist/checkpointer/types.d.ts +0 -58
- package/dist/factory/factory.d.ts +0 -40
- package/dist/factory/factory.js +0 -87
- package/dist/history/actions/add-messages.d.ts +0 -15
- package/dist/history/actions/add-messages.js +0 -77
- package/dist/history/actions/clear.d.ts +0 -10
- package/dist/history/actions/clear.js +0 -34
- package/dist/history/actions/get-messages.d.ts +0 -17
- package/dist/history/actions/get-messages.js +0 -79
- package/dist/history/actions/list-sessions.d.ts +0 -13
- package/dist/history/actions/list-sessions.js +0 -53
- package/dist/history/actions/reconcile-count.d.ts +0 -12
- package/dist/history/actions/reconcile-count.js +0 -64
- package/dist/history/chat-message-history.d.ts +0 -73
- package/dist/history/chat-message-history.js +0 -111
- package/dist/history/internal/append-saga.d.ts +0 -25
- package/dist/history/internal/append-saga.js +0 -79
- package/dist/history/internal/compensation.d.ts +0 -25
- package/dist/history/internal/compensation.js +0 -92
- package/dist/history/internal/item-mapper.d.ts +0 -9
- package/dist/history/internal/item-mapper.js +0 -27
- package/dist/history/internal/keys.d.ts +0 -16
- package/dist/history/internal/keys.js +0 -48
- package/dist/history/internal/message-chunker.d.ts +0 -13
- package/dist/history/internal/message-chunker.js +0 -67
- package/dist/history/internal/message-transaction.d.ts +0 -25
- package/dist/history/internal/message-transaction.js +0 -61
- package/dist/history/internal/message-window.d.ts +0 -17
- package/dist/history/internal/message-window.js +0 -49
- package/dist/history/internal/query.d.ts +0 -23
- package/dist/history/internal/query.js +0 -39
- package/dist/history/internal/session-count.d.ts +0 -47
- package/dist/history/internal/session-count.js +0 -115
- package/dist/history/internal/session-title.d.ts +0 -19
- package/dist/history/internal/session-title.js +0 -43
- package/dist/history/internal/session-update.d.ts +0 -27
- package/dist/history/internal/session-update.js +0 -69
- package/dist/history/internal/setup.d.ts +0 -31
- package/dist/history/internal/setup.js +0 -43
- package/dist/history/internal/title-generator.d.ts +0 -12
- package/dist/history/internal/title-generator.js +0 -41
- package/dist/history/internal/ttl-anchor.d.ts +0 -24
- package/dist/history/internal/ttl-anchor.js +0 -38
- package/dist/history/internal/validation.d.ts +0 -25
- package/dist/history/internal/validation.js +0 -53
- package/dist/history/session-adapter.d.ts +0 -29
- package/dist/history/session-adapter.js +0 -35
- package/dist/history/types.d.ts +0 -69
- package/dist/index.d.ts +0 -29
- package/dist/index.js +0 -32
- package/dist/shared/clock.d.ts +0 -8
- package/dist/shared/clock.js +0 -16
- package/dist/shared/codec/codec.d.ts +0 -53
- package/dist/shared/codec/codec.js +0 -66
- package/dist/shared/codec/compression.d.ts +0 -24
- package/dist/shared/codec/compression.js +0 -48
- package/dist/shared/codec/descriptor-keys.d.ts +0 -12
- package/dist/shared/codec/descriptor-keys.js +0 -14
- package/dist/shared/codec/encode.d.ts +0 -13
- package/dist/shared/codec/encode.js +0 -43
- package/dist/shared/codec/json-serde.d.ts +0 -7
- package/dist/shared/codec/json-serde.js +0 -17
- package/dist/shared/codec/payload-loss.d.ts +0 -12
- package/dist/shared/codec/payload-loss.js +0 -38
- package/dist/shared/codec/s3/adapter-config.d.ts +0 -13
- package/dist/shared/codec/s3/adapter-config.js +0 -22
- package/dist/shared/codec/s3/bounded-body.d.ts +0 -14
- package/dist/shared/codec/s3/bounded-body.js +0 -47
- package/dist/shared/codec/s3/client.d.ts +0 -18
- package/dist/shared/codec/s3/client.js +0 -46
- package/dist/shared/codec/s3/config.d.ts +0 -51
- package/dist/shared/codec/s3/config.js +0 -58
- package/dist/shared/codec/s3/delete.d.ts +0 -7
- package/dist/shared/codec/s3/delete.js +0 -28
- package/dist/shared/codec/s3/key-scope.d.ts +0 -23
- package/dist/shared/codec/s3/key-scope.js +0 -44
- package/dist/shared/codec/s3/lifecycle.d.ts +0 -14
- package/dist/shared/codec/s3/lifecycle.js +0 -63
- package/dist/shared/codec/s3/offloader.d.ts +0 -44
- package/dist/shared/codec/s3/offloader.js +0 -118
- package/dist/shared/codec/s3/orphans.d.ts +0 -23
- package/dist/shared/codec/s3/orphans.js +0 -71
- package/dist/shared/codec/s3/read-write.d.ts +0 -18
- package/dist/shared/codec/s3/read-write.js +0 -51
- package/dist/shared/codec/s3/retry.d.ts +0 -5
- package/dist/shared/codec/s3/retry.js +0 -22
- package/dist/shared/concurrency.d.ts +0 -6
- package/dist/shared/constants.d.ts +0 -112
- package/dist/shared/constants.js +0 -115
- package/dist/shared/dynamodb/abort.d.ts +0 -9
- package/dist/shared/dynamodb/abort.js +0 -27
- package/dist/shared/dynamodb/backoff.d.ts +0 -15
- package/dist/shared/dynamodb/backoff.js +0 -48
- package/dist/shared/dynamodb/batch-write.d.ts +0 -22
- package/dist/shared/dynamodb/batch-write.js +0 -53
- package/dist/shared/dynamodb/cancellation.d.ts +0 -6
- package/dist/shared/dynamodb/cancellation.js +0 -7
- package/dist/shared/dynamodb/client.d.ts +0 -28
- package/dist/shared/dynamodb/conditional-put.d.ts +0 -67
- package/dist/shared/dynamodb/conditional-put.js +0 -76
- package/dist/shared/dynamodb/drain-unprocessed.d.ts +0 -21
- package/dist/shared/dynamodb/drain-unprocessed.js +0 -43
- package/dist/shared/dynamodb/expiry.d.ts +0 -16
- package/dist/shared/dynamodb/expiry.js +0 -29
- package/dist/shared/dynamodb/paginate-core.d.ts +0 -24
- package/dist/shared/dynamodb/paginate-core.js +0 -82
- package/dist/shared/dynamodb/paginate.d.ts +0 -14
- package/dist/shared/dynamodb/paginate.js +0 -19
- package/dist/shared/dynamodb/partition-delete.d.ts +0 -39
- package/dist/shared/dynamodb/partition-delete.js +0 -71
- package/dist/shared/dynamodb/retry-classifier.d.ts +0 -17
- package/dist/shared/dynamodb/retry-classifier.js +0 -118
- package/dist/shared/dynamodb/retry-policy.d.ts +0 -26
- package/dist/shared/dynamodb/retry-policy.js +0 -22
- package/dist/shared/dynamodb/retry.d.ts +0 -31
- package/dist/shared/dynamodb/retry.js +0 -57
- package/dist/shared/dynamodb/scan.d.ts +0 -14
- package/dist/shared/dynamodb/scan.js +0 -19
- package/dist/shared/dynamodb/types.d.ts +0 -23
- package/dist/shared/errors/base-error.d.ts +0 -30
- package/dist/shared/errors/base-error.js +0 -27
- package/dist/shared/errors/boundary.d.ts +0 -18
- package/dist/shared/errors/boundary.js +0 -46
- package/dist/shared/errors/error-code.d.ts +0 -13
- package/dist/shared/errors/errors.d.ts +0 -68
- package/dist/shared/errors/errors.js +0 -114
- package/dist/shared/errors/upstream-error.d.ts +0 -16
- package/dist/shared/errors/upstream-error.js +0 -27
- package/dist/shared/errors/wrap-error.d.ts +0 -7
- package/dist/shared/errors/wrap-error.js +0 -15
- package/dist/shared/logging/logger.d.ts +0 -18
- package/dist/shared/logging/logger.js +0 -15
- package/dist/shared/logging/redaction-walk.d.ts +0 -23
- package/dist/shared/logging/redaction-walk.js +0 -112
- package/dist/shared/logging/redaction.d.ts +0 -39
- package/dist/shared/logging/redaction.js +0 -75
- package/dist/shared/logging/secret-patterns.d.ts +0 -92
- package/dist/shared/logging/secret-patterns.js +0 -133
- package/dist/shared/options.d.ts +0 -37
- package/dist/shared/ulid.d.ts +0 -23
- package/dist/shared/validation/options.d.ts +0 -8
- package/dist/shared/validation/options.js +0 -90
- package/dist/shared/validation/primitives.d.ts +0 -29
- package/dist/shared/validation/primitives.js +0 -82
- package/dist/shared/validation/ttl.d.ts +0 -28
- package/dist/shared/validation/ttl.js +0 -52
- package/dist/store/actions/get.d.ts +0 -13
- package/dist/store/actions/get.js +0 -73
- package/dist/store/actions/list-namespaces.d.ts +0 -8
- package/dist/store/actions/list-namespaces.js +0 -59
- package/dist/store/actions/put.d.ts +0 -10
- package/dist/store/actions/put.js +0 -96
- package/dist/store/actions/reconcile-vector-index.d.ts +0 -18
- package/dist/store/actions/reconcile-vector-index.js +0 -26
- package/dist/store/actions/search.d.ts +0 -9
- package/dist/store/actions/search.js +0 -34
- package/dist/store/internal/backend-search.d.ts +0 -4
- package/dist/store/internal/backend-search.js +0 -74
- package/dist/store/internal/batch-plan.d.ts +0 -11
- package/dist/store/internal/batch-plan.js +0 -52
- package/dist/store/internal/candidates.d.ts +0 -23
- package/dist/store/internal/candidates.js +0 -94
- package/dist/store/internal/filter.d.ts +0 -9
- package/dist/store/internal/filter.js +0 -85
- package/dist/store/internal/index-reconcile.d.ts +0 -21
- package/dist/store/internal/index-reconcile.js +0 -118
- package/dist/store/internal/index-sync.d.ts +0 -10
- package/dist/store/internal/index-sync.js +0 -25
- package/dist/store/internal/item-mapper.d.ts +0 -27
- package/dist/store/internal/item-mapper.js +0 -61
- package/dist/store/internal/keys.d.ts +0 -17
- package/dist/store/internal/keys.js +0 -41
- package/dist/store/internal/namespace-match.d.ts +0 -11
- package/dist/store/internal/namespace-match.js +0 -40
- package/dist/store/internal/option-validation.d.ts +0 -13
- package/dist/store/internal/option-validation.js +0 -77
- package/dist/store/internal/overwrite-swap.d.ts +0 -32
- package/dist/store/internal/overwrite-swap.js +0 -68
- package/dist/store/internal/persist.d.ts +0 -28
- package/dist/store/internal/persist.js +0 -64
- package/dist/store/internal/query.d.ts +0 -11
- package/dist/store/internal/query.js +0 -48
- package/dist/store/internal/ranker.d.ts +0 -18
- package/dist/store/internal/ranker.js +0 -39
- package/dist/store/internal/read-existing.d.ts +0 -23
- package/dist/store/internal/read-existing.js +0 -41
- package/dist/store/internal/score-direction.d.ts +0 -31
- package/dist/store/internal/score-direction.js +0 -38
- package/dist/store/internal/search-filter.d.ts +0 -3
- package/dist/store/internal/search-filter.js +0 -10
- package/dist/store/internal/semantic-search.d.ts +0 -34
- package/dist/store/internal/semantic-search.js +0 -87
- package/dist/store/internal/setup.d.ts +0 -36
- package/dist/store/internal/setup.js +0 -40
- package/dist/store/internal/text-path.d.ts +0 -17
- package/dist/store/internal/validation.d.ts +0 -18
- package/dist/store/internal/validation.js +0 -51
- package/dist/store/internal/write-verify.d.ts +0 -42
- package/dist/store/internal/write-verify.js +0 -71
- package/dist/store/store.d.ts +0 -61
- package/dist/store/store.js +0 -107
- package/dist/store/types.d.ts +0 -50
- package/dist/store/types.js +0 -2
- package/dist/store/vector-backend.d.ts +0 -43
- package/dist/store/vector-backend.js +0 -2
- /package/dist/{checkpointer → cjs/checkpointer}/types.js +0 -0
- /package/dist/{factory → cjs/factory}/types.js +0 -0
- /package/dist/{history → cjs/history}/types.js +0 -0
- /package/dist/{shared → cjs/shared}/options.js +0 -0
- /package/dist/{shared/dynamodb → cjs/store}/types.js +0 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides the conventions every row of the shared table follows, whichever
|
|
3
|
+
* adapter wrote it.
|
|
4
|
+
*
|
|
5
|
+
* The three adapters share one table (record 2), so a few things are decided
|
|
6
|
+
* once for all of them: the two key attributes every row has, the format
|
|
7
|
+
* version every row is stamped with and refused above (record 7), the `ttl`
|
|
8
|
+
* attribute that makes a row absent before DynamoDB's sweep removes it, and the
|
|
9
|
+
* order the server gives string keys. Which segments a feature's keys carry is
|
|
10
|
+
* that feature's `rows` module's decision; that they are written into these
|
|
11
|
+
* attributes and read back in this order is this module's.
|
|
12
|
+
*/
|
|
13
|
+
import type { QueryCommandInput, ScanCommandInput } from '@aws-sdk/lib-dynamodb';
|
|
14
|
+
import type { AttributeMap } from './client.js';
|
|
15
|
+
/** The attribute every row is partitioned by. */
|
|
16
|
+
export declare const PARTITION_KEY_ATTRIBUTE = "PK";
|
|
17
|
+
/** The attribute every row is sorted by within its partition. */
|
|
18
|
+
export declare const SORT_KEY_ATTRIBUTE = "SK";
|
|
19
|
+
/**
|
|
20
|
+
* Byte caps on caller-supplied identifiers, measured as UTF-8. DynamoDB caps a
|
|
21
|
+
* partition key at 2048 bytes and a sort key at 1024; S3 caps an object key at
|
|
22
|
+
* 1024. These leave room for the adapter prefixes and separators that compose
|
|
23
|
+
* the stored keys, so a value that passes validation fails as a typed error
|
|
24
|
+
* here rather than as a raw AWS ValidationException on the write.
|
|
25
|
+
*
|
|
26
|
+
* Partition-key identifiers: `thread_id` and `sessionId`.
|
|
27
|
+
*/
|
|
28
|
+
export declare const MAX_PARTITION_ID_BYTES = 1024;
|
|
29
|
+
/**
|
|
30
|
+
* Sort-key segments other than the checkpoint namespace and a pending-write
|
|
31
|
+
* channel: `checkpoint_id`, `taskId`, a store namespace element and a store
|
|
32
|
+
* `key`.
|
|
33
|
+
*/
|
|
34
|
+
export declare const MAX_KEY_SEGMENT_BYTES = 256;
|
|
35
|
+
/**
|
|
36
|
+
* A pending-write channel's own cap. Every other segment is one identifier,
|
|
37
|
+
* but LangGraph names the channel behind a static fan-in after every source
|
|
38
|
+
* node — `join:<a>+<b>+…:<end>` — so a channel is as long as a graph's node
|
|
39
|
+
* names together, and nine sources with ordinary names pass 256 bytes. The
|
|
40
|
+
* channel is the last segment of the WRITE sort key, so DynamoDB's cap on the
|
|
41
|
+
* whole key is the bound that matters, and the composed-key check enforces it
|
|
42
|
+
* against the namespace, checkpoint id and task id the channel sits behind.
|
|
43
|
+
*/
|
|
44
|
+
export declare const MAX_WRITE_CHANNEL_BYTES = 1024;
|
|
45
|
+
/**
|
|
46
|
+
* The checkpoint namespace's own cap. LangGraph names a subgraph's namespace
|
|
47
|
+
* after its parent's, a separator, the node's name and a 36-character task id
|
|
48
|
+
* (`${parent}|${node}:${taskId}`), so each level of nesting adds roughly forty
|
|
49
|
+
* bytes plus the node name; 256 bytes stopped a graph at its fifth or sixth
|
|
50
|
+
* level. Twice that keeps the rows a namespace composes inside DynamoDB's
|
|
51
|
+
* sort-key cap, which the composed-key checks enforce either way.
|
|
52
|
+
*/
|
|
53
|
+
export declare const MAX_CHECKPOINT_NS_BYTES = 512;
|
|
54
|
+
/**
|
|
55
|
+
* DynamoDB cap on a whole sort key; composed keys are checked against it too.
|
|
56
|
+
*
|
|
57
|
+
* @see https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/HowItWorks.NamingRulesDataTypes.html
|
|
58
|
+
*/
|
|
59
|
+
export declare const MAX_SORT_KEY_BYTES = 1024;
|
|
60
|
+
/**
|
|
61
|
+
* The separator between the segments of every key this package composes. No
|
|
62
|
+
* caller-supplied identifier may contain it (the parsers refuse it), which is
|
|
63
|
+
* what lets a key be read back into its parts and matched by prefix (record 2).
|
|
64
|
+
*/
|
|
65
|
+
export declare const KEY_SEPARATOR = "#";
|
|
66
|
+
/**
|
|
67
|
+
* The tag each adapter's partition keys open with. The three differ in their
|
|
68
|
+
* first character, so no two adapters' partitions can collide on a shared
|
|
69
|
+
* table, whatever identifiers their callers reuse (record 2).
|
|
70
|
+
*/
|
|
71
|
+
export declare const ADAPTER_TAGS: {
|
|
72
|
+
readonly checkpointer: 'CHKPT';
|
|
73
|
+
readonly store: 'STORE';
|
|
74
|
+
readonly history: 'HIST';
|
|
75
|
+
};
|
|
76
|
+
/** A row's primary key, as a `Key` document and as the key half of an item. */
|
|
77
|
+
export interface RowKey {
|
|
78
|
+
PK: string;
|
|
79
|
+
SK: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The key of a row already in hand.
|
|
83
|
+
*
|
|
84
|
+
* Accepts: `row` — an item read from, or about to be written to, the table.
|
|
85
|
+
*
|
|
86
|
+
* Returns: its `PK` and `SK`, and nothing else, so it can be sent as a `Key`
|
|
87
|
+
* without the rest of the item.
|
|
88
|
+
*
|
|
89
|
+
* Throws: nothing.
|
|
90
|
+
*/
|
|
91
|
+
export declare function rowKeyOf(row: AttributeMap): RowKey;
|
|
92
|
+
/** The only attribute this module reads: a row's own format version. */
|
|
93
|
+
export interface VersionedRow {
|
|
94
|
+
v?: number;
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The format version this package stamps on every row it writes.
|
|
98
|
+
*
|
|
99
|
+
* Before it existed, "written by an older version" was inferred from a missing
|
|
100
|
+
* attribute — `rev`, `occurrence`, `writeGroup`, `storedChannels`. That
|
|
101
|
+
* inference is unreadable to a maintainer and it is not even expressible: a
|
|
102
|
+
* lookup cannot tell an attribute that is *absent* from one that is *present
|
|
103
|
+
* and undefined*, which reversed first-write-wins for pending writes across an
|
|
104
|
+
* upgrade. A row states its own version instead.
|
|
105
|
+
*/
|
|
106
|
+
export declare const ROW_FORMAT_VERSION = 1;
|
|
107
|
+
/** The highest version this package knows how to read. */
|
|
108
|
+
export declare const SUPPORTED_ROW_FORMAT_VERSION = 1;
|
|
109
|
+
/**
|
|
110
|
+
* A row's format version.
|
|
111
|
+
*
|
|
112
|
+
* Accepts: `row` — any row. One carrying no numeric `v` predates the attribute.
|
|
113
|
+
*
|
|
114
|
+
* Returns: the stamped version, or `0` for a row without one — the version
|
|
115
|
+
* whose rules applied when it was written.
|
|
116
|
+
*
|
|
117
|
+
* Throws: nothing.
|
|
118
|
+
*/
|
|
119
|
+
export declare function rowVersionOf(row: VersionedRow): number;
|
|
120
|
+
/**
|
|
121
|
+
* Refuse a row written by a newer version of this package.
|
|
122
|
+
*
|
|
123
|
+
* Accepts: `row` — any row; one at or below
|
|
124
|
+
* {@link SUPPORTED_ROW_FORMAT_VERSION} is accepted, which includes every row
|
|
125
|
+
* written before the attribute existed. `what` — the row kind, named in the
|
|
126
|
+
* message.
|
|
127
|
+
*
|
|
128
|
+
* Returns: nothing: `row` is kept under its declared type, and this checks
|
|
129
|
+
* it.
|
|
130
|
+
*
|
|
131
|
+
* Throws: `FORMAT_UNSUPPORTED` naming the field `v`. Guessing at a shape this
|
|
132
|
+
* version does not know is how a reader returns a checkpoint with silently
|
|
133
|
+
* missing state, so the caller is told to upgrade instead.
|
|
134
|
+
*/
|
|
135
|
+
export declare function assertReadableRow(row: VersionedRow, what: string): void;
|
|
136
|
+
/**
|
|
137
|
+
* Whether a row has reached its TTL.
|
|
138
|
+
*
|
|
139
|
+
* Accepts: `row` — any row; one without a `ttl` attribute never expires.
|
|
140
|
+
* `nowSeconds` — the current epoch **second**, the unit the attribute uses.
|
|
141
|
+
*
|
|
142
|
+
* Returns: true when `ttl <= nowSeconds`, so the expiry instant itself counts
|
|
143
|
+
* as expired.
|
|
144
|
+
*
|
|
145
|
+
* Throws: nothing.
|
|
146
|
+
*
|
|
147
|
+
* Guarantees: a caller that applies this hides an expired row even while
|
|
148
|
+
* DynamoDB's own sweep lags, which AWS documents as typically within a few days of the
|
|
149
|
+
* `ttl`, with no fixed bound
|
|
150
|
+
* (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/TTL.html).
|
|
151
|
+
*/
|
|
152
|
+
export declare function isExpiredRow(row: {
|
|
153
|
+
ttl?: number;
|
|
154
|
+
}, nowSeconds: number): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* The same query with expired rows filtered out server-side.
|
|
157
|
+
*
|
|
158
|
+
* Accepts: `params` — a Query or Scan input, with or without a
|
|
159
|
+
* `FilterExpression`; an existing one is ANDed rather than replaced.
|
|
160
|
+
* `nowSeconds` — the epoch second to compare against.
|
|
161
|
+
*
|
|
162
|
+
* Returns: a copy carrying the added filter and the `#ttl` / `:now` aliases. No
|
|
163
|
+
* other call site in this package uses those two names, so the merge cannot
|
|
164
|
+
* shadow a caller's own alias.
|
|
165
|
+
*
|
|
166
|
+
* Throws: nothing.
|
|
167
|
+
*
|
|
168
|
+
* Guarantees: this trims transfer only. It never replaces the in-process
|
|
169
|
+
* {@link isExpiredRow} check, because the query is built and its rows are read
|
|
170
|
+
* at two different instants, and DynamoDB applies a filter *after* `Limit`.
|
|
171
|
+
*/
|
|
172
|
+
export declare function withoutExpired<T extends QueryCommandInput | ScanCommandInput>(params: T, nowSeconds: number): T;
|
|
173
|
+
/**
|
|
174
|
+
* Order two DynamoDB string sort keys the way the server orders them.
|
|
175
|
+
*
|
|
176
|
+
* DynamoDB compares a string key by the bytes of its UTF-8 encoding.
|
|
177
|
+
* JavaScript's `<` and `>` compare UTF-16 code units, and the two disagree
|
|
178
|
+
* wherever an astral character meets one in U+E000-U+FFFF: an astral character
|
|
179
|
+
* is a surrogate pair starting at U+D800, so `'A\u{1F600}' < 'A!'` in
|
|
180
|
+
* JavaScript and the reverse on the server. Any listing that merges or bounds
|
|
181
|
+
* rows in memory and then resumes with a key condition has to use this order,
|
|
182
|
+
* or the boundary it draws is not the boundary the next query reads from, and
|
|
183
|
+
* a row is skipped or handed out twice.
|
|
184
|
+
*
|
|
185
|
+
* The comparison is written on the bytes rather than on code points. The two
|
|
186
|
+
* agree — UTF-8 was designed so that byte order is code-point order — but the
|
|
187
|
+
* bytes are what DynamoDB documents itself as comparing, so the code states the
|
|
188
|
+
* server's rule instead of a property that happens to coincide with it.
|
|
189
|
+
*
|
|
190
|
+
* Accepts: `left`, `right` — any two strings; well-formedness is not required,
|
|
191
|
+
* since an unpaired surrogate encodes to the replacement character's bytes and
|
|
192
|
+
* so still compares deterministically.
|
|
193
|
+
*
|
|
194
|
+
* Returns: a negative number when `left` sorts before `right`, a positive one
|
|
195
|
+
* when it sorts after, and `0` when the two encode to the same bytes.
|
|
196
|
+
*
|
|
197
|
+
* Throws: nothing.
|
|
198
|
+
*/
|
|
199
|
+
export declare function compareSortKeys(left: string, right: string): number;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SUPPORTED_ROW_FORMAT_VERSION = exports.ROW_FORMAT_VERSION = exports.ADAPTER_TAGS = exports.KEY_SEPARATOR = exports.MAX_SORT_KEY_BYTES = exports.MAX_CHECKPOINT_NS_BYTES = exports.MAX_WRITE_CHANNEL_BYTES = exports.MAX_KEY_SEGMENT_BYTES = exports.MAX_PARTITION_ID_BYTES = exports.SORT_KEY_ATTRIBUTE = exports.PARTITION_KEY_ATTRIBUTE = void 0;
|
|
4
|
+
exports.rowKeyOf = rowKeyOf;
|
|
5
|
+
exports.rowVersionOf = rowVersionOf;
|
|
6
|
+
exports.assertReadableRow = assertReadableRow;
|
|
7
|
+
exports.isExpiredRow = isExpiredRow;
|
|
8
|
+
exports.withoutExpired = withoutExpired;
|
|
9
|
+
exports.compareSortKeys = compareSortKeys;
|
|
10
|
+
const base_error_js_1 = require("../errors/base-error.js");
|
|
11
|
+
const error_code_js_1 = require("../errors/error-code.js");
|
|
12
|
+
exports.PARTITION_KEY_ATTRIBUTE = 'PK';
|
|
13
|
+
exports.SORT_KEY_ATTRIBUTE = 'SK';
|
|
14
|
+
exports.MAX_PARTITION_ID_BYTES = 1024;
|
|
15
|
+
exports.MAX_KEY_SEGMENT_BYTES = 256;
|
|
16
|
+
exports.MAX_WRITE_CHANNEL_BYTES = 1024;
|
|
17
|
+
exports.MAX_CHECKPOINT_NS_BYTES = 512;
|
|
18
|
+
exports.MAX_SORT_KEY_BYTES = 1024;
|
|
19
|
+
exports.KEY_SEPARATOR = '#';
|
|
20
|
+
exports.ADAPTER_TAGS = { checkpointer: 'CHKPT', store: 'STORE', history: 'HIST' };
|
|
21
|
+
function rowKeyOf(row) {
|
|
22
|
+
return { PK: row.PK, SK: row.SK };
|
|
23
|
+
}
|
|
24
|
+
exports.ROW_FORMAT_VERSION = 1;
|
|
25
|
+
exports.SUPPORTED_ROW_FORMAT_VERSION = 1;
|
|
26
|
+
function rowVersionOf(row) {
|
|
27
|
+
return typeof row.v === 'number' ? row.v : 0;
|
|
28
|
+
}
|
|
29
|
+
function assertReadableRow(row, what) {
|
|
30
|
+
const version = rowVersionOf(row);
|
|
31
|
+
if (version <= exports.SUPPORTED_ROW_FORMAT_VERSION)
|
|
32
|
+
return;
|
|
33
|
+
throw new base_error_js_1.DynamoDBLangGraphError(`this ${what} row was written in format version ${version}; this version of the library ` +
|
|
34
|
+
`reads up to ${exports.SUPPORTED_ROW_FORMAT_VERSION} — upgrade to read it`, error_code_js_1.ErrorCode.FORMAT_UNSUPPORTED, { field: 'v' });
|
|
35
|
+
}
|
|
36
|
+
function isExpiredRow(row, nowSeconds) {
|
|
37
|
+
return row.ttl !== undefined && row.ttl <= nowSeconds;
|
|
38
|
+
}
|
|
39
|
+
const TTL_FILTER = 'attribute_not_exists(#ttl) OR #ttl > :now';
|
|
40
|
+
function withoutExpired(params, nowSeconds) {
|
|
41
|
+
return {
|
|
42
|
+
...params,
|
|
43
|
+
FilterExpression: params.FilterExpression
|
|
44
|
+
? `(${params.FilterExpression}) AND (${TTL_FILTER})`
|
|
45
|
+
: TTL_FILTER,
|
|
46
|
+
ExpressionAttributeNames: { ...params.ExpressionAttributeNames, '#ttl': 'ttl' },
|
|
47
|
+
ExpressionAttributeValues: { ...params.ExpressionAttributeValues, ':now': nowSeconds },
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
function compareSortKeys(left, right) {
|
|
51
|
+
return Buffer.compare(Buffer.from(left, 'utf8'), Buffer.from(right, 'utf8'));
|
|
52
|
+
}
|
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides the one error class and what counts as an error at all.
|
|
3
|
+
*
|
|
4
|
+
* Every failure this package raises is a `DynamoDBLangGraphError` told apart by
|
|
5
|
+
* its code (record 19), recognisable across copies of the package by a brand
|
|
6
|
+
* rather than by `instanceof`; and whatever a caller's code or a dependency
|
|
7
|
+
* throws — a string, `undefined`, an object — is turned into an `Error` before
|
|
8
|
+
* anything reads it.
|
|
9
|
+
*/
|
|
10
|
+
import type { WriteRequest } from '../dynamodb/client.js';
|
|
11
|
+
import { ErrorCode } from './error-code.js';
|
|
12
|
+
/**
|
|
13
|
+
* Structured, log-safe context attached to every library error. Identifiers
|
|
14
|
+
* and counts only — never a payload or a credential.
|
|
15
|
+
*/
|
|
16
|
+
export interface ErrorContext {
|
|
17
|
+
/** The DynamoDB table the operation targeted, when known. */
|
|
18
|
+
tableName?: string;
|
|
19
|
+
/** The public operation (`saver.put`, `store.batch`, …) or internal step that failed. */
|
|
20
|
+
operation?: string;
|
|
21
|
+
/** The option, argument or cap that failed validation or was exceeded. */
|
|
22
|
+
field?: string;
|
|
23
|
+
/** The S3 object key involved, for offload failures. */
|
|
24
|
+
key?: string;
|
|
25
|
+
/** Attempts made before a retry budget was exhausted. */
|
|
26
|
+
attempts?: number;
|
|
27
|
+
/** The thread a checkpointer failure belongs to. */
|
|
28
|
+
threadId?: string;
|
|
29
|
+
/** The checkpoint a checkpointer failure names. */
|
|
30
|
+
checkpointId?: string;
|
|
31
|
+
/**
|
|
32
|
+
* The AWS exception name of the failure underneath, when that failure was
|
|
33
|
+
* AWS-shaped (it carried the SDK's `$metadata`, or a name the classifier
|
|
34
|
+
* knows or that ends in `Exception`). Lifted off `cause.name` so a log line
|
|
35
|
+
* or an alert can branch on it without walking `cause`.
|
|
36
|
+
*/
|
|
37
|
+
awsErrorName?: string;
|
|
38
|
+
/** The AWS request id (`cause.$metadata.requestId`), which AWS Support asks for. */
|
|
39
|
+
requestId?: string;
|
|
40
|
+
/** The HTTP status of the failed AWS response (`cause.$metadata.httpStatusCode`). */
|
|
41
|
+
httpStatusCode?: number;
|
|
42
|
+
}
|
|
43
|
+
/** What one `BatchWriteItem` drain left behind when it ran out of rounds. */
|
|
44
|
+
export interface BatchDrainDetails {
|
|
45
|
+
readonly kind: 'drain';
|
|
46
|
+
/** Writes DynamoDB acknowledged; they persist, since there is no rollback. */
|
|
47
|
+
readonly succeededCount: number;
|
|
48
|
+
/** The requests DynamoDB did not acknowledge, verbatim, so they can be re-submitted. */
|
|
49
|
+
readonly unprocessed: readonly WriteRequest[];
|
|
50
|
+
/** `UnprocessedItems` rounds spent. */
|
|
51
|
+
readonly retries: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* The tally of a pass that attempted every chunk (`unit: 'chunk'`, 25-row
|
|
55
|
+
* `BatchWriteItem` chunks) or every row (`unit: 'row'`, one conditional delete
|
|
56
|
+
* per row) before reporting.
|
|
57
|
+
*/
|
|
58
|
+
export interface BatchPassDetails {
|
|
59
|
+
readonly kind: 'pass';
|
|
60
|
+
readonly unit: 'chunk' | 'row';
|
|
61
|
+
readonly succeededChunks: number;
|
|
62
|
+
readonly totalChunks: number;
|
|
63
|
+
/** Each failing chunk's or row's own error. */
|
|
64
|
+
readonly failedChunks: readonly Error[];
|
|
65
|
+
/** Individual writes confirmed persisted across the whole pass. */
|
|
66
|
+
readonly succeededCount: number;
|
|
67
|
+
}
|
|
68
|
+
/** What a `BATCH_WRITE_INCOMPLETE` error reports: one drain, or a whole pass. */
|
|
69
|
+
export type BatchWriteIncompleteDetails = BatchDrainDetails | BatchPassDetails;
|
|
70
|
+
/** What a `COMPENSATION_FAILED` error reports besides its trigger, which is `cause`. */
|
|
71
|
+
export interface CompensationFailedDetails {
|
|
72
|
+
/**
|
|
73
|
+
* Why the append could not be undone or settled: the rollback's own
|
|
74
|
+
* failure (itself often a `BATCH_WRITE_INCOMPLETE`), the read-back's
|
|
75
|
+
* failure, or the write's own failure when some attempt of it may still
|
|
76
|
+
* be applied.
|
|
77
|
+
*/
|
|
78
|
+
readonly rollbackError: Error;
|
|
79
|
+
}
|
|
80
|
+
/** The codes that carry details, and the shape each one carries. */
|
|
81
|
+
export interface ErrorDetailsByCode {
|
|
82
|
+
[ErrorCode.BATCH_WRITE_INCOMPLETE]: BatchWriteIncompleteDetails;
|
|
83
|
+
[ErrorCode.COMPENSATION_FAILED]: CompensationFailedDetails;
|
|
84
|
+
}
|
|
85
|
+
/** The details a code carries; `undefined` for every code not in {@link ErrorDetailsByCode}. */
|
|
86
|
+
export type ErrorDetailsFor<C extends ErrorCode> = C extends keyof ErrorDetailsByCode ? ErrorDetailsByCode[C] : undefined;
|
|
87
|
+
/**
|
|
88
|
+
* Base class for every error this library throws. Carries a branchable
|
|
89
|
+
* {@link ErrorCode}, structured {@link ErrorContext}, code-specific
|
|
90
|
+
* {@link details}, and a native `cause` chain. Detected via
|
|
91
|
+
* {@link isDynamoDBLangGraphError} (a symbol brand) rather than `instanceof`,
|
|
92
|
+
* which is banned repo-wide.
|
|
93
|
+
*/
|
|
94
|
+
export declare class DynamoDBLangGraphError<C extends ErrorCode = ErrorCode> extends Error {
|
|
95
|
+
readonly code: C;
|
|
96
|
+
readonly context: ErrorContext;
|
|
97
|
+
/** Declared, not emitted: a code without details leaves no `undefined`-valued own property. */
|
|
98
|
+
readonly details: ErrorDetailsFor<C>;
|
|
99
|
+
/**
|
|
100
|
+
* Accepts: `message` — already redacted by whoever composed it, since it reaches
|
|
101
|
+
* `err.message`, which an application may print without a redacting logger.
|
|
102
|
+
* `code` — the code this error branches on. `context` — identifiers and counts
|
|
103
|
+
* only, never a payload or a credential. It is **copied**, so a caller that
|
|
104
|
+
* reuses one builder object cannot rewrite the context of an error already in
|
|
105
|
+
* flight; `null` reads as an absent one. `cause` — the failure below this one,
|
|
106
|
+
* kept as the native `cause` chain. `details` — the code-specific record
|
|
107
|
+
* {@link ErrorDetailsByCode} names, copied like `context`. The parameter is
|
|
108
|
+
* optional for every code, including the two whose `details` property is
|
|
109
|
+
* typed as always present (`BATCH_WRITE_INCOMPLETE`, `COMPENSATION_FAILED`):
|
|
110
|
+
* nothing at compile time stops a direct `new` from leaving it out, and an
|
|
111
|
+
* error built that way has no `details` at runtime whatever its type says.
|
|
112
|
+
* Inside this package those two codes are only ever built by the factories
|
|
113
|
+
* that always pass them.
|
|
114
|
+
*
|
|
115
|
+
* Returns: the error, branded so {@link isDynamoDBLangGraphError} recognises it
|
|
116
|
+
* across realms and across two copies of this package. The brand is
|
|
117
|
+
* non-enumerable, so it never reaches a log or a JSON serialization.
|
|
118
|
+
*
|
|
119
|
+
* Throws: nothing; building an error may not fail.
|
|
120
|
+
*/
|
|
121
|
+
constructor(message: string, code: C, context?: ErrorContext, cause?: Error, details?: ErrorDetailsFor<C>);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Every library error, as a union discriminated by `code`: comparing `code`
|
|
125
|
+
* narrows `details` to the shape that code carries.
|
|
126
|
+
*/
|
|
127
|
+
export type AnyDynamoDBLangGraphError = {
|
|
128
|
+
[C in ErrorCode]: DynamoDBLangGraphError<C>;
|
|
129
|
+
}[ErrorCode];
|
|
130
|
+
/**
|
|
131
|
+
* Whether `value` is one of this library's errors.
|
|
132
|
+
*
|
|
133
|
+
* Accepts: whatever a `catch` clause binds, as it is — an error from any realm
|
|
134
|
+
* or any copy of this package, and any other value a `throw` can produce:
|
|
135
|
+
* `null`, `undefined`, a string, a number, a symbol. Declared `unknown`
|
|
136
|
+
* because that is what `strict` types a `catch` binding, and the documented
|
|
137
|
+
* place to call this is the first line inside one.
|
|
138
|
+
*
|
|
139
|
+
* Returns: whether it carries the brand, narrowed to the union discriminated by
|
|
140
|
+
* `code`. A symbol registered by name, not `instanceof`: two copies of this
|
|
141
|
+
* package in one dependency tree produce two classes but one symbol, and an
|
|
142
|
+
* error crossing a realm boundary keeps its properties while losing its
|
|
143
|
+
* prototype. Anything that cannot carry a property answers `false`. Earlier
|
|
144
|
+
* releases set the same brand, so an older copy of this package installed
|
|
145
|
+
* beside this one has its errors recognised too — in that release's shape: no
|
|
146
|
+
* `details`, the counts as flat properties, and possibly a code this union
|
|
147
|
+
* does not list (`UPSTREAM`).
|
|
148
|
+
*
|
|
149
|
+
* Throws: nothing. The `in` operator raises a `TypeError` on a non-object, and
|
|
150
|
+
* a guard that throws inside the `catch` it was called from would replace the
|
|
151
|
+
* failure the caller is reporting with one of its own.
|
|
152
|
+
*/
|
|
153
|
+
export declare function isDynamoDBLangGraphError(value: unknown): value is AnyDynamoDBLangGraphError;
|
|
154
|
+
/**
|
|
155
|
+
* Whether `value` is one of this library's errors carrying `code`.
|
|
156
|
+
*
|
|
157
|
+
* Accepts: anything a `catch` can bind. `code` — the code to test for.
|
|
158
|
+
*
|
|
159
|
+
* Returns: `true` only for a branded error whose `code` is `code`, narrowed so
|
|
160
|
+
* its `details` are typed. An unbranded object that merely carries a `code`
|
|
161
|
+
* property is not one: recognition is by brand and code together, never by a
|
|
162
|
+
* name or a shape.
|
|
163
|
+
*
|
|
164
|
+
* Throws: nothing, for any value.
|
|
165
|
+
*/
|
|
166
|
+
export declare function hasErrorCode<C extends ErrorCode>(value: Error, code: C): value is DynamoDBLangGraphError<C>;
|
|
167
|
+
/**
|
|
168
|
+
* A caller's own copy of a branded error that several concurrent callers would
|
|
169
|
+
* otherwise share — a cached rejected import, a cached rejected client build.
|
|
170
|
+
* Sharing the one instance is safe while nothing on the path back to a public
|
|
171
|
+
* method writes to it, but the public boundary does: it stamps
|
|
172
|
+
* `context.operation` and `context.tableName`, each independently when the
|
|
173
|
+
* error does not already carry it, in place, and a second caller reaching the
|
|
174
|
+
* same shared instance through a *different* public method would then find
|
|
175
|
+
* the first caller's operation and table already sitting in its own context,
|
|
176
|
+
* unable to write its own. Giving each
|
|
177
|
+
* caller its own instance up front — same `message`, `code`, `context` and
|
|
178
|
+
* `cause` — keeps the two from ever writing to one object. Not a general
|
|
179
|
+
* clone: an *unbranded* failure needs none, since `wrapForeignError`
|
|
180
|
+
* (`shared/errors/boundary.ts`) already builds a fresh wrapper for it at
|
|
181
|
+
* every boundary crossing, unlike a branded error, which crosses unwrapped.
|
|
182
|
+
*
|
|
183
|
+
* Accepts: `error` — anything a `catch` can bind.
|
|
184
|
+
*
|
|
185
|
+
* Returns: a new `DynamoDBLangGraphError` carrying the same `message`, `code`,
|
|
186
|
+
* `context`, `cause` and `details` as `error`, when `error` already was one;
|
|
187
|
+
* `error` itself, unchanged, for anything else. The copy does not carry
|
|
188
|
+
* `RETRY_EXHAUSTED`'s non-enumerable record of whether a write's retry budget
|
|
189
|
+
* may still land, so it is not for a budget error: a caller judging one asks
|
|
190
|
+
* the original.
|
|
191
|
+
*
|
|
192
|
+
* Throws: nothing, for any value.
|
|
193
|
+
*/
|
|
194
|
+
export declare function copyForCaller(error: Error): Error;
|
|
195
|
+
/**
|
|
196
|
+
* What a log line calls a failure.
|
|
197
|
+
*
|
|
198
|
+
* Accepts: any error a `catch` bound.
|
|
199
|
+
*
|
|
200
|
+
* Returns: the `code` of one of this library's errors, and the `name` of any
|
|
201
|
+
* other. Every library error shares one name, so the name alone would log
|
|
202
|
+
* `DynamoDBLangGraphError` for a refused input and a spent retry budget alike;
|
|
203
|
+
* the code is what tells them apart, and like a name it is an identifier, never
|
|
204
|
+
* a payload.
|
|
205
|
+
*
|
|
206
|
+
* Throws: nothing for an error. A value that cannot carry a property raises
|
|
207
|
+
* the `TypeError` reading its `name` raises, as reading it directly would.
|
|
208
|
+
*/
|
|
209
|
+
export declare function failureLabel(error: Error): string;
|
|
210
|
+
/**
|
|
211
|
+
* A caught value as an `Error`.
|
|
212
|
+
*
|
|
213
|
+
* Kept in this module rather than in `boundary.ts`, which otherwise reads as
|
|
214
|
+
* its natural home: `shared/logging/secret-patterns.ts` calls this to
|
|
215
|
+
* normalise whatever a `catch` bound before redacting it, and `boundary.ts`
|
|
216
|
+
* itself calls `redactedMessage` while building the error it wraps a foreign
|
|
217
|
+
* failure into. Both edges are real, so the two modules cannot import each
|
|
218
|
+
* other without a cycle; this module depends on neither.
|
|
219
|
+
*
|
|
220
|
+
* Accepts: `value` — declared `Error` because callers narrow a catch clause
|
|
221
|
+
* with `toError(error as Error)`, but anything can be thrown in JavaScript:
|
|
222
|
+
* a string, `undefined`, a plain object, a `BigInt`, a symbol.
|
|
223
|
+
*
|
|
224
|
+
* Returns: the value itself when it is error-shaped — an object carrying a
|
|
225
|
+
* string `message`, which keeps an SDK error's own fields and `cause` intact;
|
|
226
|
+
* otherwise a fresh `Error` describing what was thrown.
|
|
227
|
+
*
|
|
228
|
+
* Throws: **nothing**. This runs inside `catch` blocks, so a throw here would
|
|
229
|
+
* discard the failure being reported and replace it with its own.
|
|
230
|
+
*/
|
|
231
|
+
export declare function toError(value: Error): Error;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DynamoDBLangGraphError = void 0;
|
|
4
|
+
exports.isDynamoDBLangGraphError = isDynamoDBLangGraphError;
|
|
5
|
+
exports.hasErrorCode = hasErrorCode;
|
|
6
|
+
exports.copyForCaller = copyForCaller;
|
|
7
|
+
exports.failureLabel = failureLabel;
|
|
8
|
+
exports.toError = toError;
|
|
9
|
+
const error_code_js_1 = require("./error-code.js");
|
|
10
|
+
const ERROR_BRAND = Symbol.for('@farukada/aws-langgraph-dynamodb-ts/error');
|
|
11
|
+
function isList(field) {
|
|
12
|
+
return Array.isArray(field);
|
|
13
|
+
}
|
|
14
|
+
function copyDetails(details) {
|
|
15
|
+
if (details === null || typeof details !== 'object')
|
|
16
|
+
return details;
|
|
17
|
+
const fields = Object.entries(details);
|
|
18
|
+
return Object.fromEntries(fields.map(([key, value]) => [key, isList(value) ? [...value] : value]));
|
|
19
|
+
}
|
|
20
|
+
class DynamoDBLangGraphError extends Error {
|
|
21
|
+
code;
|
|
22
|
+
context;
|
|
23
|
+
constructor(message, code, context = {}, cause, details) {
|
|
24
|
+
super(message, cause === undefined ? undefined : { cause });
|
|
25
|
+
this.name = 'DynamoDBLangGraphError';
|
|
26
|
+
this.code = code;
|
|
27
|
+
this.context = { ...context };
|
|
28
|
+
if (details !== undefined)
|
|
29
|
+
this.details = copyDetails(details);
|
|
30
|
+
Object.defineProperty(this, ERROR_BRAND, { value: true, enumerable: false });
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.DynamoDBLangGraphError = DynamoDBLangGraphError;
|
|
34
|
+
function isDynamoDBLangGraphError(value) {
|
|
35
|
+
return typeof value === 'object' && value !== null && ERROR_BRAND in value;
|
|
36
|
+
}
|
|
37
|
+
function hasErrorCode(value, code) {
|
|
38
|
+
return isDynamoDBLangGraphError(value) && value.code === code;
|
|
39
|
+
}
|
|
40
|
+
function copyForCaller(error) {
|
|
41
|
+
if (!isDynamoDBLangGraphError(error))
|
|
42
|
+
return error;
|
|
43
|
+
return new DynamoDBLangGraphError(error.message, error.code, error.context, error.cause, error.details);
|
|
44
|
+
}
|
|
45
|
+
function failureLabel(error) {
|
|
46
|
+
return isDynamoDBLangGraphError(error) ? error.code : error.name;
|
|
47
|
+
}
|
|
48
|
+
function describeThrown(value) {
|
|
49
|
+
if (typeof value === 'string')
|
|
50
|
+
return value;
|
|
51
|
+
if (value === undefined || value === null)
|
|
52
|
+
return `${String(value)} was thrown`;
|
|
53
|
+
try {
|
|
54
|
+
return JSON.stringify(value) ?? `a ${typeof value} value was thrown`;
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
return `an unserializable ${typeof value} value was thrown`;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function toError(value) {
|
|
61
|
+
if (value !== null && typeof value === 'object' && messageOf(value) !== undefined)
|
|
62
|
+
return value;
|
|
63
|
+
return new Error(describeThrown(value));
|
|
64
|
+
}
|
|
65
|
+
function messageOf(value) {
|
|
66
|
+
try {
|
|
67
|
+
const { message } = value;
|
|
68
|
+
return typeof message === 'string' ? message : undefined;
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides what crosses the public boundary.
|
|
3
|
+
*
|
|
4
|
+
* Only this package's own error leaves a public method (record 13): an error of
|
|
5
|
+
* its own passes through, given the public operation and the table it surfaced
|
|
6
|
+
* through for whichever of the two it does not already name, and anything
|
|
7
|
+
* else — an SDK failure, a caller's thrown value — is classified and wrapped
|
|
8
|
+
* with its cause attached and its text redacted.
|
|
9
|
+
*/
|
|
10
|
+
import { type AnyDynamoDBLangGraphError, DynamoDBLangGraphError } from './base-error.js';
|
|
11
|
+
/**
|
|
12
|
+
* Normalise anything escaping a public method into the library's error model.
|
|
13
|
+
*
|
|
14
|
+
* Accepts: anything a `catch` produced — an `Error`, or a value that is not one
|
|
15
|
+
* (`toError` settles that first). `operation` — the public method's name.
|
|
16
|
+
* `tableName` — the adapter's table, when the method has one.
|
|
17
|
+
*
|
|
18
|
+
* Returns: a branded library error — the same one, when it already was one,
|
|
19
|
+
* with whichever of `context.operation` and `context.tableName` it does not
|
|
20
|
+
* already carry filled in — or anything else wrapped by {@link wrapForeignError}
|
|
21
|
+
* with the code the classifier assigns, stamped the same way.
|
|
22
|
+
*
|
|
23
|
+
* Throws: nothing. It runs inside a `catch`, where throwing would discard the
|
|
24
|
+
* failure being reported and replace it with its own.
|
|
25
|
+
*/
|
|
26
|
+
export declare function toPublicError(error: Error, operation: string, tableName?: string): AnyDynamoDBLangGraphError;
|
|
27
|
+
/**
|
|
28
|
+
* Run a public operation so that every rejection is a library error.
|
|
29
|
+
*
|
|
30
|
+
* Accepts: `operation` — the public method's name, which the error carries.
|
|
31
|
+
* `fn` — the work. `tableName` — the adapter's table, which the error carries.
|
|
32
|
+
*
|
|
33
|
+
* Returns: whatever `fn` resolves to, untouched.
|
|
34
|
+
*
|
|
35
|
+
* Throws: a library error, always. Applied once, at each adapter class method,
|
|
36
|
+
* so internal code can keep rethrowing SDK errors verbatim — the retry
|
|
37
|
+
* classifier depends on their shape, and wrapping them early would blind it.
|
|
38
|
+
*/
|
|
39
|
+
export declare function guardPublic<T>(operation: string, fn: () => Promise<T>, tableName?: string): Promise<T>;
|
|
40
|
+
/**
|
|
41
|
+
* The same guard for a streaming result.
|
|
42
|
+
*
|
|
43
|
+
* Accepts: `operation` — the public method's name. `source` — the generator to
|
|
44
|
+
* relay. `tableName` — the adapter's table.
|
|
45
|
+
*
|
|
46
|
+
* Returns: a generator yielding the source's items untouched. A consumer that
|
|
47
|
+
* stops early still closes the source, so an abandoned listing stops reading
|
|
48
|
+
* rather than paging on in the background.
|
|
49
|
+
*
|
|
50
|
+
* Throws: a library error, always — including for a failure raised
|
|
51
|
+
* mid-iteration, which is the case a `try` around the loop body would miss.
|
|
52
|
+
*/
|
|
53
|
+
export declare function guardPublicIterable<T>(operation: string, source: AsyncGenerator<T>, tableName?: string): AsyncGenerator<T>;
|
|
54
|
+
/**
|
|
55
|
+
* The same guard for a synchronous public method.
|
|
56
|
+
*
|
|
57
|
+
* Accepts: `operation` — the public method's name. `fn` — the work.
|
|
58
|
+
* `tableName` — the adapter's table.
|
|
59
|
+
*
|
|
60
|
+
* Returns: whatever `fn` returns.
|
|
61
|
+
*
|
|
62
|
+
* Throws: a library error, always — what a client's own `destroy` threw
|
|
63
|
+
* included, classified like any other foreign failure and kept as `cause`.
|
|
64
|
+
*/
|
|
65
|
+
export declare function guardPublicSync<T>(operation: string, fn: () => T, tableName?: string): T;
|
|
66
|
+
/**
|
|
67
|
+
* A failure from below this library, as one of its errors.
|
|
68
|
+
*
|
|
69
|
+
* Accepts: `cause` — whatever a `catch` bound: an AWS SDK error, a transport
|
|
70
|
+
* error, or what a `VectorBackend`, `Embeddings`, `serde` or `MultiSessionHistory`
|
|
71
|
+
* threw. `operation` — the public method it surfaced through.
|
|
72
|
+
*
|
|
73
|
+
* Returns: an error whose code is {@link classifyAwsError}'s answer for
|
|
74
|
+
* {@link classifiableCause} of the normalised `cause` — so an AWS or network
|
|
75
|
+
* failure found down the cause chain still earns its own code rather than
|
|
76
|
+
* `UNEXPECTED_ERROR`. Its context names `operation` and — for whichever node
|
|
77
|
+
* was classified — `awsErrorName`, `requestId` and `httpStatusCode`. Its
|
|
78
|
+
* `cause` is the original, normalised through {@link toError}, kept whole
|
|
79
|
+
* regardless of which node down the chain supplied the code. The message
|
|
80
|
+
* quotes the cause's own name cut at the log cap and its own text redacted
|
|
81
|
+
* and cut at the relay cap, because `err.message` reaches applications that
|
|
82
|
+
* print it without a redacting logger.
|
|
83
|
+
*
|
|
84
|
+
* Throws: nothing, for any value.
|
|
85
|
+
*/
|
|
86
|
+
export declare function wrapForeignError(cause: Error, operation: string): DynamoDBLangGraphError;
|