@farukada/aws-langgraph-dynamodb-ts 0.9.0 → 1.0.0-rc.2
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 +1720 -154
- package/dist/backfill/backfill.d.ts +168 -0
- package/dist/backfill/backfill.js +393 -0
- package/dist/checkpointer/actions/delete-thread.d.ts +47 -6
- package/dist/checkpointer/actions/delete-thread.js +58 -21
- package/dist/checkpointer/actions/get-tuple.d.ts +29 -4
- package/dist/checkpointer/actions/get-tuple.js +44 -10
- package/dist/checkpointer/actions/list.d.ts +46 -4
- package/dist/checkpointer/actions/list.js +121 -66
- package/dist/checkpointer/actions/put-writes.d.ts +41 -9
- package/dist/checkpointer/actions/put-writes.js +62 -77
- package/dist/checkpointer/actions/put.d.ts +83 -4
- package/dist/checkpointer/actions/put.js +177 -25
- package/dist/checkpointer/internal/delta-history.d.ts +112 -0
- package/dist/checkpointer/internal/delta-history.js +252 -0
- package/dist/checkpointer/internal/listing.d.ts +149 -0
- package/dist/checkpointer/internal/listing.js +245 -0
- package/dist/checkpointer/internal/parse.d.ts +262 -0
- package/dist/checkpointer/internal/parse.js +372 -0
- package/dist/checkpointer/internal/pending-writes.d.ts +275 -0
- package/dist/checkpointer/internal/pending-writes.js +588 -0
- package/dist/checkpointer/internal/read.d.ts +130 -0
- package/dist/checkpointer/internal/read.js +264 -0
- package/dist/checkpointer/internal/rows.d.ts +571 -0
- package/dist/checkpointer/internal/rows.js +834 -0
- package/dist/checkpointer/internal/setup.d.ts +42 -19
- package/dist/checkpointer/internal/setup.js +65 -29
- package/dist/checkpointer/saver.d.ts +256 -16
- package/dist/checkpointer/saver.js +275 -29
- package/dist/checkpointer/types.d.ts +39 -39
- package/dist/checkpointer/types.js +10 -1
- package/dist/factory/factory.d.ts +134 -28
- package/dist/factory/factory.js +240 -21
- package/dist/factory/types.d.ts +76 -0
- package/dist/factory/types.js +10 -0
- package/dist/history/actions/add-messages.d.ts +31 -4
- package/dist/history/actions/add-messages.js +38 -58
- package/dist/history/actions/clear.d.ts +49 -6
- package/dist/history/actions/clear.js +66 -14
- package/dist/history/actions/get-messages.d.ts +54 -6
- package/dist/history/actions/get-messages.js +126 -43
- package/dist/history/actions/list-sessions.d.ts +52 -10
- package/dist/history/actions/list-sessions.js +139 -40
- package/dist/history/actions/reconcile-count.d.ts +42 -10
- package/dist/history/actions/reconcile-count.js +45 -45
- package/dist/history/chat-message-history.d.ts +220 -33
- package/dist/history/chat-message-history.js +240 -43
- package/dist/history/internal/append.d.ts +212 -0
- package/dist/history/internal/append.js +500 -0
- package/dist/history/internal/message-read.d.ts +84 -0
- package/dist/history/internal/message-read.js +204 -0
- package/dist/history/internal/parse.d.ts +153 -0
- package/dist/history/internal/parse.js +252 -0
- package/dist/history/internal/rows.d.ts +195 -0
- package/dist/history/internal/rows.js +250 -0
- package/dist/history/internal/session.d.ts +331 -0
- package/dist/history/internal/session.js +628 -0
- package/dist/history/internal/setup.d.ts +52 -17
- package/dist/history/internal/setup.js +92 -21
- package/dist/history/session-adapter.d.ts +102 -7
- package/dist/history/session-adapter.js +103 -9
- package/dist/history/types.d.ts +80 -29
- package/dist/history/types.js +10 -1
- package/dist/index.d.ts +42 -11
- package/dist/index.js +33 -12
- package/dist/shared/adapter.d.ts +135 -0
- package/dist/shared/adapter.js +143 -0
- package/dist/shared/clock.d.ts +51 -2
- package/dist/shared/clock.js +57 -2
- package/dist/shared/codec/codec.d.ts +288 -13
- package/dist/shared/codec/codec.js +416 -19
- package/dist/shared/codec/compression.d.ts +43 -7
- package/dist/shared/codec/compression.js +53 -13
- package/dist/shared/codec/json-serde.d.ts +76 -4
- package/dist/shared/codec/json-serde.js +181 -8
- package/dist/shared/codec/s3/client-types.d.ts +53 -0
- package/dist/shared/codec/s3/client-types.js +26 -0
- package/dist/shared/codec/s3/client.d.ts +43 -10
- package/dist/shared/codec/s3/client.js +82 -9
- package/dist/shared/codec/s3/config.d.ts +242 -11
- package/dist/shared/codec/s3/config.js +293 -11
- package/dist/shared/codec/s3/lifecycle.d.ts +164 -6
- package/dist/shared/codec/s3/lifecycle.js +335 -27
- package/dist/shared/codec/s3/offloader.d.ts +393 -18
- package/dist/shared/codec/s3/offloader.js +595 -37
- package/dist/shared/concurrency.d.ts +43 -0
- package/dist/shared/concurrency.js +78 -0
- package/dist/shared/dynamodb/abort.d.ts +47 -0
- package/dist/shared/dynamodb/abort.js +59 -0
- package/dist/shared/dynamodb/batch-write.d.ts +77 -14
- package/dist/shared/dynamodb/batch-write.js +146 -27
- package/dist/shared/dynamodb/cancellation.d.ts +121 -4
- package/dist/shared/dynamodb/cancellation.js +147 -3
- package/dist/shared/dynamodb/client.d.ts +162 -8
- package/dist/shared/dynamodb/client.js +153 -5
- package/dist/shared/dynamodb/idempotent-write.d.ts +551 -0
- package/dist/shared/dynamodb/idempotent-write.js +593 -0
- package/dist/shared/dynamodb/paginate.d.ts +105 -9
- package/dist/shared/dynamodb/paginate.js +175 -7
- package/dist/shared/dynamodb/partition-delete.d.ts +185 -14
- package/dist/shared/dynamodb/partition-delete.js +314 -44
- package/dist/shared/dynamodb/recency-index.d.ts +231 -0
- package/dist/shared/dynamodb/recency-index.js +377 -0
- package/dist/shared/dynamodb/retry.d.ts +276 -8
- package/dist/shared/dynamodb/retry.js +433 -23
- package/dist/shared/dynamodb/table-schema.d.ts +190 -0
- package/dist/shared/dynamodb/table-schema.js +209 -0
- package/dist/shared/errors/base-error.d.ts +184 -10
- package/dist/shared/errors/base-error.js +160 -14
- package/dist/shared/errors/boundary.d.ts +71 -0
- package/dist/shared/errors/boundary.js +143 -0
- package/dist/shared/errors/classify.d.ts +97 -0
- package/dist/shared/errors/classify.js +257 -0
- package/dist/shared/errors/error-code.d.ts +77 -2
- package/dist/shared/errors/error-code.js +83 -1
- package/dist/shared/errors/errors.d.ts +158 -59
- package/dist/shared/errors/errors.js +219 -92
- package/dist/shared/logging/logger.d.ts +69 -3
- package/dist/shared/logging/logger.js +97 -3
- package/dist/shared/logging/redaction.d.ts +92 -8
- package/dist/shared/logging/redaction.js +273 -17
- package/dist/shared/logging/secret-patterns.d.ts +149 -19
- package/dist/shared/logging/secret-patterns.js +188 -27
- package/dist/shared/logging/truncate.d.ts +197 -0
- package/dist/shared/logging/truncate.js +231 -0
- package/dist/shared/options.d.ts +59 -7
- package/dist/shared/options.js +9 -1
- package/dist/shared/ulid.d.ts +77 -7
- package/dist/shared/ulid.js +103 -8
- package/dist/shared/validation/collaborators.d.ts +141 -0
- package/dist/shared/validation/collaborators.js +188 -0
- package/dist/shared/validation/option-shape.d.ts +89 -0
- package/dist/shared/validation/option-shape.js +113 -0
- package/dist/shared/validation/options.d.ts +145 -0
- package/dist/shared/validation/options.js +328 -0
- package/dist/shared/validation/primitives.d.ts +288 -21
- package/dist/shared/validation/primitives.js +353 -50
- package/dist/shared/validation/ttl.d.ts +66 -10
- package/dist/shared/validation/ttl.js +113 -15
- package/dist/store/actions/list-namespaces.d.ts +76 -6
- package/dist/store/actions/list-namespaces.js +166 -24
- package/dist/store/actions/put.d.ts +33 -8
- package/dist/store/actions/put.js +53 -60
- package/dist/store/actions/reconcile-vector-index.d.ts +31 -10
- package/dist/store/actions/reconcile-vector-index.js +34 -15
- package/dist/store/actions/search.d.ts +34 -6
- package/dist/store/actions/search.js +56 -51
- package/dist/store/internal/batch-plan.d.ts +26 -0
- package/dist/store/internal/batch-plan.js +109 -0
- package/dist/store/internal/filter.d.ts +36 -3
- package/dist/store/internal/filter.js +66 -15
- package/dist/store/internal/get-item.d.ts +45 -0
- package/dist/store/internal/get-item.js +115 -0
- package/dist/store/internal/item-write.d.ts +230 -0
- package/dist/store/internal/item-write.js +463 -0
- package/dist/store/internal/parse.d.ts +225 -0
- package/dist/store/internal/parse.js +350 -0
- package/dist/store/internal/rows.d.ts +355 -0
- package/dist/store/internal/rows.js +447 -0
- package/dist/store/internal/semantic-search.d.ts +161 -6
- package/dist/store/internal/semantic-search.js +360 -18
- package/dist/store/internal/setup.d.ts +77 -20
- package/dist/store/internal/setup.js +178 -47
- package/dist/store/internal/table-search.d.ts +100 -0
- package/dist/store/internal/table-search.js +213 -0
- package/dist/store/internal/vector-index.d.ts +247 -0
- package/dist/store/internal/vector-index.js +546 -0
- package/dist/store/store.d.ts +270 -17
- package/dist/store/store.js +329 -38
- package/dist/store/types.d.ts +76 -26
- package/dist/store/types.js +13 -1
- package/dist/store/vector-backend.d.ts +64 -4
- package/dist/store/vector-backend.js +15 -1
- package/package.json +58 -36
- package/dist/checkpointer/actions/delete-thread.d.ts.map +0 -1
- package/dist/checkpointer/actions/delete-thread.js.map +0 -1
- package/dist/checkpointer/actions/get-tuple.d.ts.map +0 -1
- package/dist/checkpointer/actions/get-tuple.js.map +0 -1
- package/dist/checkpointer/actions/list.d.ts.map +0 -1
- package/dist/checkpointer/actions/list.js.map +0 -1
- package/dist/checkpointer/actions/put-writes.d.ts.map +0 -1
- package/dist/checkpointer/actions/put-writes.js.map +0 -1
- package/dist/checkpointer/actions/put.d.ts.map +0 -1
- package/dist/checkpointer/actions/put.js.map +0 -1
- package/dist/checkpointer/internal/assemble.d.ts +0 -10
- package/dist/checkpointer/internal/assemble.d.ts.map +0 -1
- package/dist/checkpointer/internal/assemble.js +0 -37
- package/dist/checkpointer/internal/assemble.js.map +0 -1
- package/dist/checkpointer/internal/configurable.d.ts +0 -13
- package/dist/checkpointer/internal/configurable.d.ts.map +0 -1
- package/dist/checkpointer/internal/configurable.js +0 -23
- package/dist/checkpointer/internal/configurable.js.map +0 -1
- package/dist/checkpointer/internal/fetch.d.ts +0 -10
- package/dist/checkpointer/internal/fetch.d.ts.map +0 -1
- package/dist/checkpointer/internal/fetch.js +0 -46
- package/dist/checkpointer/internal/fetch.js.map +0 -1
- package/dist/checkpointer/internal/filter-match.d.ts +0 -12
- package/dist/checkpointer/internal/filter-match.d.ts.map +0 -1
- package/dist/checkpointer/internal/filter-match.js +0 -14
- package/dist/checkpointer/internal/filter-match.js.map +0 -1
- package/dist/checkpointer/internal/item-reader.d.ts +0 -55
- package/dist/checkpointer/internal/item-reader.d.ts.map +0 -1
- package/dist/checkpointer/internal/item-reader.js +0 -88
- package/dist/checkpointer/internal/item-reader.js.map +0 -1
- package/dist/checkpointer/internal/item-writer.d.ts +0 -26
- package/dist/checkpointer/internal/item-writer.d.ts.map +0 -1
- package/dist/checkpointer/internal/item-writer.js +0 -92
- package/dist/checkpointer/internal/item-writer.js.map +0 -1
- package/dist/checkpointer/internal/keys.d.ts +0 -31
- package/dist/checkpointer/internal/keys.d.ts.map +0 -1
- package/dist/checkpointer/internal/keys.js +0 -87
- package/dist/checkpointer/internal/keys.js.map +0 -1
- package/dist/checkpointer/internal/query.d.ts +0 -20
- package/dist/checkpointer/internal/query.d.ts.map +0 -1
- package/dist/checkpointer/internal/query.js +0 -36
- package/dist/checkpointer/internal/query.js.map +0 -1
- package/dist/checkpointer/internal/setup.d.ts.map +0 -1
- package/dist/checkpointer/internal/setup.js.map +0 -1
- package/dist/checkpointer/internal/special-write-cas.d.ts +0 -30
- package/dist/checkpointer/internal/special-write-cas.d.ts.map +0 -1
- package/dist/checkpointer/internal/special-write-cas.js +0 -104
- package/dist/checkpointer/internal/special-write-cas.js.map +0 -1
- package/dist/checkpointer/internal/special-write-cleanup.d.ts +0 -24
- package/dist/checkpointer/internal/special-write-cleanup.d.ts.map +0 -1
- package/dist/checkpointer/internal/special-write-cleanup.js +0 -47
- package/dist/checkpointer/internal/special-write-cleanup.js.map +0 -1
- package/dist/checkpointer/internal/special-write-verify.d.ts +0 -54
- package/dist/checkpointer/internal/special-write-verify.d.ts.map +0 -1
- package/dist/checkpointer/internal/special-write-verify.js +0 -65
- package/dist/checkpointer/internal/special-write-verify.js.map +0 -1
- package/dist/checkpointer/internal/validation.d.ts +0 -13
- package/dist/checkpointer/internal/validation.d.ts.map +0 -1
- package/dist/checkpointer/internal/validation.js +0 -30
- package/dist/checkpointer/internal/validation.js.map +0 -1
- package/dist/checkpointer/internal/write-guard.d.ts +0 -13
- package/dist/checkpointer/internal/write-guard.d.ts.map +0 -1
- package/dist/checkpointer/internal/write-guard.js +0 -39
- package/dist/checkpointer/internal/write-guard.js.map +0 -1
- package/dist/checkpointer/internal/write-index.d.ts +0 -37
- package/dist/checkpointer/internal/write-index.d.ts.map +0 -1
- package/dist/checkpointer/internal/write-index.js +0 -42
- package/dist/checkpointer/internal/write-index.js.map +0 -1
- package/dist/checkpointer/saver.d.ts.map +0 -1
- package/dist/checkpointer/saver.js.map +0 -1
- package/dist/checkpointer/types.d.ts.map +0 -1
- package/dist/checkpointer/types.js.map +0 -1
- package/dist/factory/factory.d.ts.map +0 -1
- package/dist/factory/factory.js.map +0 -1
- package/dist/history/actions/add-messages.d.ts.map +0 -1
- package/dist/history/actions/add-messages.js.map +0 -1
- package/dist/history/actions/clear.d.ts.map +0 -1
- package/dist/history/actions/clear.js.map +0 -1
- package/dist/history/actions/get-messages.d.ts.map +0 -1
- package/dist/history/actions/get-messages.js.map +0 -1
- package/dist/history/actions/list-sessions.d.ts.map +0 -1
- package/dist/history/actions/list-sessions.js.map +0 -1
- package/dist/history/actions/reconcile-count.d.ts.map +0 -1
- package/dist/history/actions/reconcile-count.js.map +0 -1
- package/dist/history/chat-message-history.d.ts.map +0 -1
- package/dist/history/chat-message-history.js.map +0 -1
- package/dist/history/internal/append-saga.d.ts +0 -20
- package/dist/history/internal/append-saga.d.ts.map +0 -1
- package/dist/history/internal/append-saga.js +0 -35
- package/dist/history/internal/append-saga.js.map +0 -1
- package/dist/history/internal/compensation.d.ts +0 -21
- package/dist/history/internal/compensation.d.ts.map +0 -1
- package/dist/history/internal/compensation.js +0 -84
- package/dist/history/internal/compensation.js.map +0 -1
- package/dist/history/internal/item-mapper.d.ts +0 -12
- package/dist/history/internal/item-mapper.d.ts.map +0 -1
- package/dist/history/internal/item-mapper.js +0 -33
- package/dist/history/internal/item-mapper.js.map +0 -1
- package/dist/history/internal/keys.d.ts +0 -17
- package/dist/history/internal/keys.d.ts.map +0 -1
- package/dist/history/internal/keys.js +0 -49
- package/dist/history/internal/keys.js.map +0 -1
- package/dist/history/internal/message-chunker.d.ts +0 -14
- package/dist/history/internal/message-chunker.d.ts.map +0 -1
- package/dist/history/internal/message-chunker.js +0 -68
- package/dist/history/internal/message-chunker.js.map +0 -1
- package/dist/history/internal/message-transaction.d.ts +0 -26
- package/dist/history/internal/message-transaction.d.ts.map +0 -1
- package/dist/history/internal/message-transaction.js +0 -60
- package/dist/history/internal/message-transaction.js.map +0 -1
- package/dist/history/internal/query.d.ts +0 -10
- package/dist/history/internal/query.d.ts.map +0 -1
- package/dist/history/internal/query.js +0 -31
- package/dist/history/internal/query.js.map +0 -1
- package/dist/history/internal/session-count.d.ts +0 -41
- package/dist/history/internal/session-count.d.ts.map +0 -1
- package/dist/history/internal/session-count.js +0 -109
- package/dist/history/internal/session-count.js.map +0 -1
- package/dist/history/internal/session-title.d.ts +0 -20
- package/dist/history/internal/session-title.d.ts.map +0 -1
- package/dist/history/internal/session-title.js +0 -44
- package/dist/history/internal/session-title.js.map +0 -1
- package/dist/history/internal/session-update.d.ts +0 -28
- package/dist/history/internal/session-update.d.ts.map +0 -1
- package/dist/history/internal/session-update.js +0 -70
- package/dist/history/internal/session-update.js.map +0 -1
- package/dist/history/internal/setup.d.ts.map +0 -1
- package/dist/history/internal/setup.js.map +0 -1
- package/dist/history/internal/title-generator.d.ts +0 -13
- package/dist/history/internal/title-generator.d.ts.map +0 -1
- package/dist/history/internal/title-generator.js +0 -25
- package/dist/history/internal/title-generator.js.map +0 -1
- package/dist/history/internal/ttl-anchor.d.ts +0 -25
- package/dist/history/internal/ttl-anchor.d.ts.map +0 -1
- package/dist/history/internal/ttl-anchor.js +0 -38
- package/dist/history/internal/ttl-anchor.js.map +0 -1
- package/dist/history/internal/validation.d.ts +0 -9
- package/dist/history/internal/validation.d.ts.map +0 -1
- package/dist/history/internal/validation.js +0 -16
- package/dist/history/internal/validation.js.map +0 -1
- package/dist/history/session-adapter.d.ts.map +0 -1
- package/dist/history/session-adapter.js.map +0 -1
- package/dist/history/types.d.ts.map +0 -1
- package/dist/history/types.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/shared/clock.d.ts.map +0 -1
- package/dist/shared/clock.js.map +0 -1
- package/dist/shared/codec/codec.d.ts.map +0 -1
- package/dist/shared/codec/codec.js.map +0 -1
- package/dist/shared/codec/compression.d.ts.map +0 -1
- package/dist/shared/codec/compression.js.map +0 -1
- package/dist/shared/codec/descriptor-keys.d.ts +0 -4
- package/dist/shared/codec/descriptor-keys.d.ts.map +0 -1
- package/dist/shared/codec/descriptor-keys.js +0 -14
- package/dist/shared/codec/descriptor-keys.js.map +0 -1
- package/dist/shared/codec/json-serde.d.ts.map +0 -1
- package/dist/shared/codec/json-serde.js.map +0 -1
- package/dist/shared/codec/s3/client.d.ts.map +0 -1
- package/dist/shared/codec/s3/client.js.map +0 -1
- package/dist/shared/codec/s3/config.d.ts.map +0 -1
- package/dist/shared/codec/s3/config.js.map +0 -1
- package/dist/shared/codec/s3/delete.d.ts +0 -8
- package/dist/shared/codec/s3/delete.d.ts.map +0 -1
- package/dist/shared/codec/s3/delete.js +0 -29
- package/dist/shared/codec/s3/delete.js.map +0 -1
- package/dist/shared/codec/s3/lifecycle.d.ts.map +0 -1
- package/dist/shared/codec/s3/lifecycle.js.map +0 -1
- package/dist/shared/codec/s3/offloader.d.ts.map +0 -1
- package/dist/shared/codec/s3/offloader.js.map +0 -1
- package/dist/shared/codec/s3/orphans.d.ts +0 -18
- package/dist/shared/codec/s3/orphans.d.ts.map +0 -1
- package/dist/shared/codec/s3/orphans.js +0 -58
- package/dist/shared/codec/s3/orphans.js.map +0 -1
- package/dist/shared/codec/s3/read-write.d.ts +0 -14
- package/dist/shared/codec/s3/read-write.d.ts.map +0 -1
- package/dist/shared/codec/s3/read-write.js +0 -43
- package/dist/shared/codec/s3/read-write.js.map +0 -1
- package/dist/shared/codec/s3/retry.d.ts +0 -5
- package/dist/shared/codec/s3/retry.d.ts.map +0 -1
- package/dist/shared/codec/s3/retry.js +0 -25
- package/dist/shared/codec/s3/retry.js.map +0 -1
- package/dist/shared/constants.d.ts +0 -64
- package/dist/shared/constants.d.ts.map +0 -1
- package/dist/shared/constants.js +0 -67
- package/dist/shared/constants.js.map +0 -1
- package/dist/shared/dynamodb/backoff.d.ts +0 -15
- package/dist/shared/dynamodb/backoff.d.ts.map +0 -1
- package/dist/shared/dynamodb/backoff.js +0 -48
- package/dist/shared/dynamodb/backoff.js.map +0 -1
- package/dist/shared/dynamodb/batch-write.d.ts.map +0 -1
- package/dist/shared/dynamodb/batch-write.js.map +0 -1
- package/dist/shared/dynamodb/cancellation.d.ts.map +0 -1
- package/dist/shared/dynamodb/cancellation.js.map +0 -1
- package/dist/shared/dynamodb/client.d.ts.map +0 -1
- package/dist/shared/dynamodb/client.js.map +0 -1
- package/dist/shared/dynamodb/conditional-put.d.ts +0 -51
- package/dist/shared/dynamodb/conditional-put.d.ts.map +0 -1
- package/dist/shared/dynamodb/conditional-put.js +0 -59
- package/dist/shared/dynamodb/conditional-put.js.map +0 -1
- package/dist/shared/dynamodb/drain-unprocessed.d.ts +0 -19
- package/dist/shared/dynamodb/drain-unprocessed.d.ts.map +0 -1
- package/dist/shared/dynamodb/drain-unprocessed.js +0 -44
- package/dist/shared/dynamodb/drain-unprocessed.js.map +0 -1
- package/dist/shared/dynamodb/paginate-core.d.ts +0 -22
- package/dist/shared/dynamodb/paginate-core.d.ts.map +0 -1
- package/dist/shared/dynamodb/paginate-core.js +0 -52
- package/dist/shared/dynamodb/paginate-core.js.map +0 -1
- package/dist/shared/dynamodb/paginate.d.ts.map +0 -1
- package/dist/shared/dynamodb/paginate.js.map +0 -1
- package/dist/shared/dynamodb/partition-delete.d.ts.map +0 -1
- package/dist/shared/dynamodb/partition-delete.js.map +0 -1
- package/dist/shared/dynamodb/retry-classifier.d.ts +0 -9
- package/dist/shared/dynamodb/retry-classifier.d.ts.map +0 -1
- package/dist/shared/dynamodb/retry-classifier.js +0 -87
- package/dist/shared/dynamodb/retry-classifier.js.map +0 -1
- package/dist/shared/dynamodb/retry.d.ts.map +0 -1
- package/dist/shared/dynamodb/retry.js.map +0 -1
- package/dist/shared/dynamodb/scan.d.ts +0 -15
- package/dist/shared/dynamodb/scan.d.ts.map +0 -1
- package/dist/shared/dynamodb/scan.js +0 -20
- package/dist/shared/dynamodb/scan.js.map +0 -1
- package/dist/shared/dynamodb/types.d.ts +0 -24
- package/dist/shared/dynamodb/types.d.ts.map +0 -1
- package/dist/shared/dynamodb/types.js +0 -3
- package/dist/shared/dynamodb/types.js.map +0 -1
- package/dist/shared/errors/base-error.d.ts.map +0 -1
- package/dist/shared/errors/base-error.js.map +0 -1
- package/dist/shared/errors/error-code.d.ts.map +0 -1
- package/dist/shared/errors/error-code.js.map +0 -1
- package/dist/shared/errors/errors.d.ts.map +0 -1
- package/dist/shared/errors/errors.js.map +0 -1
- package/dist/shared/errors/wrap-error.d.ts +0 -16
- package/dist/shared/errors/wrap-error.d.ts.map +0 -1
- package/dist/shared/errors/wrap-error.js +0 -30
- package/dist/shared/errors/wrap-error.js.map +0 -1
- package/dist/shared/logging/logger.d.ts.map +0 -1
- package/dist/shared/logging/logger.js.map +0 -1
- package/dist/shared/logging/redaction-walk.d.ts +0 -23
- package/dist/shared/logging/redaction-walk.d.ts.map +0 -1
- package/dist/shared/logging/redaction-walk.js +0 -92
- package/dist/shared/logging/redaction-walk.js.map +0 -1
- package/dist/shared/logging/redaction.d.ts.map +0 -1
- package/dist/shared/logging/redaction.js.map +0 -1
- package/dist/shared/logging/secret-patterns.d.ts.map +0 -1
- package/dist/shared/logging/secret-patterns.js.map +0 -1
- package/dist/shared/options.d.ts.map +0 -1
- package/dist/shared/options.js.map +0 -1
- package/dist/shared/ulid.d.ts.map +0 -1
- package/dist/shared/ulid.js.map +0 -1
- package/dist/shared/validation/primitives.d.ts.map +0 -1
- package/dist/shared/validation/primitives.js.map +0 -1
- package/dist/shared/validation/ttl.d.ts.map +0 -1
- package/dist/shared/validation/ttl.js.map +0 -1
- package/dist/store/actions/get.d.ts +0 -5
- package/dist/store/actions/get.d.ts.map +0 -1
- package/dist/store/actions/get.js +0 -35
- package/dist/store/actions/get.js.map +0 -1
- package/dist/store/actions/list-namespaces.d.ts.map +0 -1
- package/dist/store/actions/list-namespaces.js.map +0 -1
- package/dist/store/actions/put.d.ts.map +0 -1
- package/dist/store/actions/put.js.map +0 -1
- package/dist/store/actions/reconcile-vector-index.d.ts.map +0 -1
- package/dist/store/actions/reconcile-vector-index.js.map +0 -1
- package/dist/store/actions/search.d.ts.map +0 -1
- package/dist/store/actions/search.js.map +0 -1
- package/dist/store/internal/backend-search.d.ts +0 -5
- package/dist/store/internal/backend-search.d.ts.map +0 -1
- package/dist/store/internal/backend-search.js +0 -68
- package/dist/store/internal/backend-search.js.map +0 -1
- package/dist/store/internal/filter.d.ts.map +0 -1
- package/dist/store/internal/filter.js.map +0 -1
- package/dist/store/internal/index-reconcile.d.ts +0 -22
- package/dist/store/internal/index-reconcile.d.ts.map +0 -1
- package/dist/store/internal/index-reconcile.js +0 -105
- package/dist/store/internal/index-reconcile.js.map +0 -1
- package/dist/store/internal/index-sync.d.ts +0 -11
- package/dist/store/internal/index-sync.d.ts.map +0 -1
- package/dist/store/internal/index-sync.js +0 -26
- package/dist/store/internal/index-sync.js.map +0 -1
- package/dist/store/internal/item-mapper.d.ts +0 -25
- package/dist/store/internal/item-mapper.d.ts.map +0 -1
- package/dist/store/internal/item-mapper.js +0 -53
- package/dist/store/internal/item-mapper.js.map +0 -1
- package/dist/store/internal/keys.d.ts +0 -18
- package/dist/store/internal/keys.d.ts.map +0 -1
- package/dist/store/internal/keys.js +0 -42
- package/dist/store/internal/keys.js.map +0 -1
- package/dist/store/internal/namespace-match.d.ts +0 -12
- package/dist/store/internal/namespace-match.d.ts.map +0 -1
- package/dist/store/internal/namespace-match.js +0 -41
- package/dist/store/internal/namespace-match.js.map +0 -1
- package/dist/store/internal/overwrite-swap.d.ts +0 -33
- package/dist/store/internal/overwrite-swap.d.ts.map +0 -1
- package/dist/store/internal/overwrite-swap.js +0 -62
- package/dist/store/internal/overwrite-swap.js.map +0 -1
- package/dist/store/internal/persist.d.ts +0 -27
- package/dist/store/internal/persist.d.ts.map +0 -1
- package/dist/store/internal/persist.js +0 -59
- package/dist/store/internal/persist.js.map +0 -1
- package/dist/store/internal/query.d.ts +0 -6
- package/dist/store/internal/query.d.ts.map +0 -1
- package/dist/store/internal/query.js +0 -32
- package/dist/store/internal/query.js.map +0 -1
- package/dist/store/internal/ranker.d.ts +0 -13
- package/dist/store/internal/ranker.d.ts.map +0 -1
- package/dist/store/internal/ranker.js +0 -31
- package/dist/store/internal/ranker.js.map +0 -1
- package/dist/store/internal/read-existing.d.ts +0 -19
- package/dist/store/internal/read-existing.d.ts.map +0 -1
- package/dist/store/internal/read-existing.js +0 -29
- package/dist/store/internal/read-existing.js.map +0 -1
- package/dist/store/internal/score-direction.d.ts +0 -32
- package/dist/store/internal/score-direction.d.ts.map +0 -1
- package/dist/store/internal/score-direction.js +0 -39
- package/dist/store/internal/score-direction.js.map +0 -1
- package/dist/store/internal/search-filter.d.ts +0 -4
- package/dist/store/internal/search-filter.d.ts.map +0 -1
- package/dist/store/internal/search-filter.js +0 -11
- package/dist/store/internal/search-filter.js.map +0 -1
- package/dist/store/internal/semantic-search.d.ts.map +0 -1
- package/dist/store/internal/semantic-search.js.map +0 -1
- package/dist/store/internal/setup.d.ts.map +0 -1
- package/dist/store/internal/setup.js.map +0 -1
- package/dist/store/internal/validation.d.ts +0 -13
- package/dist/store/internal/validation.d.ts.map +0 -1
- package/dist/store/internal/validation.js +0 -35
- package/dist/store/internal/validation.js.map +0 -1
- package/dist/store/internal/write-verify.d.ts +0 -37
- package/dist/store/internal/write-verify.d.ts.map +0 -1
- package/dist/store/internal/write-verify.js +0 -68
- package/dist/store/internal/write-verify.js.map +0 -1
- package/dist/store/store.d.ts.map +0 -1
- package/dist/store/store.js.map +0 -1
- package/dist/store/types.d.ts.map +0 -1
- package/dist/store/types.js.map +0 -1
- package/dist/store/vector-backend.d.ts.map +0 -1
- package/dist/store/vector-backend.js.map +0 -1
|
@@ -0,0 +1,447 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hides the store's key layout and how an item becomes a row and back.
|
|
4
|
+
*
|
|
5
|
+
* An item's namespace root is its partition and the rest of its namespace,
|
|
6
|
+
* with its key, is its sort key, so a prefix search is a key-range query. How
|
|
7
|
+
* those keys are composed, which attributes a row carries — its revision token,
|
|
8
|
+
* timestamps, embeddings, recency-index keys — how a value is encoded into one
|
|
9
|
+
* and decoded out, and which rows a read admits as this adapter's items are
|
|
10
|
+
* decided here.
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.REVISION_ATTRIBUTE = void 0;
|
|
14
|
+
exports.storePartitionPrefix = storePartitionPrefix;
|
|
15
|
+
exports.partitionKey = partitionKey;
|
|
16
|
+
exports.sortKey = sortKey;
|
|
17
|
+
exports.sortKeyPrefix = sortKeyPrefix;
|
|
18
|
+
exports.namespaceMatchesPrefix = namespaceMatchesPrefix;
|
|
19
|
+
exports.itemRowKey = itemRowKey;
|
|
20
|
+
exports.scopedQuery = scopedQuery;
|
|
21
|
+
exports.storeScan = storeScan;
|
|
22
|
+
exports.projectKeys = projectKeys;
|
|
23
|
+
exports.readExisting = readExisting;
|
|
24
|
+
exports.existingFrom = existingFrom;
|
|
25
|
+
exports.parseStoreRow = parseStoreRow;
|
|
26
|
+
exports.parseWholeStoreRow = parseWholeStoreRow;
|
|
27
|
+
exports.buildStoreRow = buildStoreRow;
|
|
28
|
+
exports.readStoreItem = readStoreItem;
|
|
29
|
+
exports.storeIndexTarget = storeIndexTarget;
|
|
30
|
+
const node_crypto_1 = require("node:crypto");
|
|
31
|
+
const codec_1 = require("../../shared/codec/codec");
|
|
32
|
+
const recency_index_1 = require("../../shared/dynamodb/recency-index");
|
|
33
|
+
const retry_1 = require("../../shared/dynamodb/retry");
|
|
34
|
+
const table_schema_1 = require("../../shared/dynamodb/table-schema");
|
|
35
|
+
/**
|
|
36
|
+
* The attribute an item row carries its revision token in, rewritten on every
|
|
37
|
+
* put. A put's compare-and-swap and a delete's pin both hold the row to the
|
|
38
|
+
* token they observed.
|
|
39
|
+
*/
|
|
40
|
+
exports.REVISION_ATTRIBUTE = 'rev';
|
|
41
|
+
/**
|
|
42
|
+
* Adapter tag prefixed to every store partition key — see the equivalent in
|
|
43
|
+
* checkpointer/internal/rows.ts for why the three adapters' partitions must
|
|
44
|
+
* not overlap on a shared table.
|
|
45
|
+
*/
|
|
46
|
+
const ADAPTER_PARTITION_PREFIX = `${table_schema_1.ADAPTER_TAGS.store}${table_schema_1.KEY_SEPARATOR}`;
|
|
47
|
+
/**
|
|
48
|
+
* The tag every store partition key starts with.
|
|
49
|
+
*
|
|
50
|
+
* Accepts: nothing — the tag is fixed, and the function exists so no caller
|
|
51
|
+
* composes it by hand.
|
|
52
|
+
*
|
|
53
|
+
* Returns: the tag, for a table-wide `begins_with` over this adapter's rows.
|
|
54
|
+
*
|
|
55
|
+
* Throws: nothing.
|
|
56
|
+
*/
|
|
57
|
+
function storePartitionPrefix() {
|
|
58
|
+
return ADAPTER_PARTITION_PREFIX;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Partition key for an item: the adapter tag plus the scope-root element.
|
|
62
|
+
*
|
|
63
|
+
* Accepts: `namespace` — normally a validated one, whose first element is the
|
|
64
|
+
* scope root every item under it shares.
|
|
65
|
+
*
|
|
66
|
+
* Returns: the partition key. The function is deliberately **total**: it maps
|
|
67
|
+
* any array to a string rather than refusing a malformed one, because
|
|
68
|
+
* `parseStoreRow` calls it on rows read from a shared table to test whether
|
|
69
|
+
* a row's own attributes agree with the key it was found at. A corrupt or
|
|
70
|
+
* foreign row must be skipped there, not turned into a failed search.
|
|
71
|
+
*
|
|
72
|
+
* Throws: nothing.
|
|
73
|
+
*/
|
|
74
|
+
function partitionKey(namespace) {
|
|
75
|
+
return `${ADAPTER_PARTITION_PREFIX}${namespace[0]}`;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Sort key: the rest of the namespace plus the key, separator-joined.
|
|
79
|
+
*
|
|
80
|
+
* Accepts: `namespace` and `key` — normally validated, so no element can itself
|
|
81
|
+
* contain the separator and the join is unambiguous. A one-element namespace
|
|
82
|
+
* lives entirely in the partition key, so the sort key is just `key`.
|
|
83
|
+
*
|
|
84
|
+
* Returns: the sort key. Total, for the same reason as {@link partitionKey}.
|
|
85
|
+
*
|
|
86
|
+
* Throws: nothing.
|
|
87
|
+
*/
|
|
88
|
+
function sortKey(namespace, key) {
|
|
89
|
+
return [...namespace.slice(1), key].join(table_schema_1.KEY_SEPARATOR);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* `begins_with` prefix selecting a scoped subtree within `prefix[0]`'s
|
|
93
|
+
* partition.
|
|
94
|
+
*
|
|
95
|
+
* Accepts: `prefix` — its first element selects the partition and is not part
|
|
96
|
+
* of the sort key, so a one-element prefix has no rest to match on.
|
|
97
|
+
*
|
|
98
|
+
* Returns: the prefix, separator-terminated so `['users','u1']` does not also
|
|
99
|
+
* match a sibling like `u10`; `''` when there is no rest, which matches the
|
|
100
|
+
* whole partition.
|
|
101
|
+
*
|
|
102
|
+
* Throws: nothing.
|
|
103
|
+
*/
|
|
104
|
+
function sortKeyPrefix(prefix) {
|
|
105
|
+
const rest = prefix.slice(1);
|
|
106
|
+
return rest.length === 0 ? '' : `${rest.join(table_schema_1.KEY_SEPARATOR)}${table_schema_1.KEY_SEPARATOR}`;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Whether `namespace` starts with `prefix`, element by element.
|
|
110
|
+
*
|
|
111
|
+
* Accepts: any two namespaces; an empty prefix matches everything, and a prefix
|
|
112
|
+
* longer than the namespace matches nothing.
|
|
113
|
+
*
|
|
114
|
+
* Returns: whether every prefix element equals the namespace element at the
|
|
115
|
+
* same position — not a string comparison, so `['userspace']` does not match the
|
|
116
|
+
* prefix `['users']`.
|
|
117
|
+
*
|
|
118
|
+
* Throws: nothing.
|
|
119
|
+
*/
|
|
120
|
+
function namespaceMatchesPrefix(namespace, prefix) {
|
|
121
|
+
if (prefix.length > namespace.length)
|
|
122
|
+
return false;
|
|
123
|
+
return prefix.every((element, index) => namespace[index] === element);
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* The key of an item's row.
|
|
127
|
+
*
|
|
128
|
+
* Accepts: `address` — the item's namespace and key, parsed, or read back from
|
|
129
|
+
* a row or a vector backend's answer.
|
|
130
|
+
*
|
|
131
|
+
* Returns: the row's partition and sort key.
|
|
132
|
+
*
|
|
133
|
+
* Throws: nothing.
|
|
134
|
+
*/
|
|
135
|
+
function itemRowKey(address) {
|
|
136
|
+
return { PK: partitionKey(address.namespace), SK: sortKey(address.namespace, address.key) };
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Query input for a scoped prefix.
|
|
140
|
+
*
|
|
141
|
+
* Accepts: `prefix` — at least one element; the first selects the partition and
|
|
142
|
+
* the rest, when there are any, become a `begins_with` on the sort key. Callers
|
|
143
|
+
* decide the rootless case before reaching here: an empty prefix spans every
|
|
144
|
+
* partition, which is a Scan ({@link storeScan}), not a Query.
|
|
145
|
+
*
|
|
146
|
+
* Returns: the Query input. The `begins_with` prefix is separator-terminated,
|
|
147
|
+
* so the scope `['users', 'u1']` does not also read `u10`.
|
|
148
|
+
*
|
|
149
|
+
* Throws: nothing.
|
|
150
|
+
*/
|
|
151
|
+
function scopedQuery(tableName, prefix) {
|
|
152
|
+
const skPrefix = sortKeyPrefix(prefix);
|
|
153
|
+
if (skPrefix.length === 0) {
|
|
154
|
+
return {
|
|
155
|
+
TableName: tableName,
|
|
156
|
+
KeyConditionExpression: '#pk = :pk',
|
|
157
|
+
ExpressionAttributeNames: { '#pk': table_schema_1.PARTITION_KEY_ATTRIBUTE },
|
|
158
|
+
ExpressionAttributeValues: { ':pk': partitionKey(prefix) },
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
TableName: tableName,
|
|
163
|
+
KeyConditionExpression: '#pk = :pk AND begins_with(#sk, :skp)',
|
|
164
|
+
ExpressionAttributeNames: { '#pk': table_schema_1.PARTITION_KEY_ATTRIBUTE, '#sk': table_schema_1.SORT_KEY_ATTRIBUTE },
|
|
165
|
+
ExpressionAttributeValues: { ':pk': partitionKey(prefix), ':skp': skPrefix },
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Scan input for the rootless case, filtered to store items only.
|
|
170
|
+
*
|
|
171
|
+
* Accepts: the table name. There is nothing to scope by — this is the read for
|
|
172
|
+
* a search or listing whose conditions name no concrete partition.
|
|
173
|
+
*
|
|
174
|
+
* Returns: the Scan input, selecting this adapter's **key space** first and its
|
|
175
|
+
* rows within it second. `begins_with(PK, 'STORE#')` is what restricts the
|
|
176
|
+
* read: every store row carries that tag and no other adapter's partition key
|
|
177
|
+
* can, so a row belonging to another adapter or to another application never
|
|
178
|
+
* reaches the narrow. The `namespace` test stays behind it as a second line of
|
|
179
|
+
* defence over the store's own partitions.
|
|
180
|
+
*
|
|
181
|
+
* Selecting on the attribute alone was not equivalent. It admitted any row on a
|
|
182
|
+
* shared table that happens to carry a `namespace` attribute, and since a row
|
|
183
|
+
* stamped with a format version above this release is *reported* rather than
|
|
184
|
+
* skipped, one foreign row was enough to fail `search([])` and
|
|
185
|
+
* `listNamespaces()` outright. Nothing legitimate is lost: `parseStoreRow`
|
|
186
|
+
* already requires `PK` to equal `partitionKey(namespace)`, which carries the
|
|
187
|
+
* same tag, so every row the tag excludes was dropped after the read anyway.
|
|
188
|
+
*
|
|
189
|
+
* The extra condition is free. A filter "is applied after a `Scan` finishes but
|
|
190
|
+
* before the results are returned. Therefore, a `Scan` consumes the same amount
|
|
191
|
+
* of read capacity, regardless of whether a filter expression is present"
|
|
192
|
+
* (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Scan.html).
|
|
193
|
+
* It saves transfer, not RCU — which is also why it cannot replace the narrow.
|
|
194
|
+
*
|
|
195
|
+
* Throws: nothing.
|
|
196
|
+
*/
|
|
197
|
+
function storeScan(tableName) {
|
|
198
|
+
return {
|
|
199
|
+
TableName: tableName,
|
|
200
|
+
FilterExpression: 'begins_with(#pk, :pkp) AND attribute_exists(#ns)',
|
|
201
|
+
ExpressionAttributeNames: { '#pk': table_schema_1.PARTITION_KEY_ATTRIBUTE, '#ns': 'namespace' },
|
|
202
|
+
ExpressionAttributeValues: { ':pkp': storePartitionPrefix() },
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Restrict a Query/Scan to the attributes `parseStoreRow` needs, leaving the
|
|
207
|
+
* payload behind: a namespace listing never reads a value.
|
|
208
|
+
*
|
|
209
|
+
* Accepts: any Query or Scan input; its own attribute names are preserved and
|
|
210
|
+
* the projection's are added.
|
|
211
|
+
*
|
|
212
|
+
* Returns: the same input, projected onto the row's identity and its format
|
|
213
|
+
* version `v`. The version is what lets `parseStoreRow` refuse a row a
|
|
214
|
+
* newer release wrote; without it every projected row reads as version 0. A
|
|
215
|
+
* row read this way can be narrowed but not decoded — {@link readStoreItem}
|
|
216
|
+
* needs the whole row.
|
|
217
|
+
*
|
|
218
|
+
* Throws: nothing.
|
|
219
|
+
*
|
|
220
|
+
* Guarantees: RCU is billed on the stored size regardless, so the saving is
|
|
221
|
+
* transfer and unmarshalling, not cost.
|
|
222
|
+
*/
|
|
223
|
+
function projectKeys(params) {
|
|
224
|
+
return {
|
|
225
|
+
...params,
|
|
226
|
+
ProjectionExpression: `${table_schema_1.PARTITION_KEY_ATTRIBUTE}, ${table_schema_1.SORT_KEY_ATTRIBUTE}, #ns, #key, #v`,
|
|
227
|
+
ExpressionAttributeNames: {
|
|
228
|
+
...params.ExpressionAttributeNames,
|
|
229
|
+
'#ns': 'namespace',
|
|
230
|
+
'#key': 'key',
|
|
231
|
+
'#v': 'v',
|
|
232
|
+
},
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Read the fields a put needs from the row it is about to replace, in one
|
|
237
|
+
* strongly-consistent projection: `createdAt` to preserve, the descriptor's
|
|
238
|
+
* location and S3 key to clean up afterwards (never its inline bytes, which
|
|
239
|
+
* can be hundreds of kilobytes the write would only discard), and the
|
|
240
|
+
* revision the compare-and-swap pins.
|
|
241
|
+
*
|
|
242
|
+
* Lives apart from `actions/put.ts` so `item-write.ts` can re-read on a lost swap
|
|
243
|
+
* without importing its own caller.
|
|
244
|
+
*
|
|
245
|
+
* Accepts: `key` — the row's key. The row need not exist.
|
|
246
|
+
*
|
|
247
|
+
* Returns: what the row holds, with `exists: false` and every field undefined
|
|
248
|
+
* when there is none. A row written before revisions existed reports no
|
|
249
|
+
* `revision`, which is why the swap tests `rev` for presence rather than
|
|
250
|
+
* comparing two undefineds.
|
|
251
|
+
*
|
|
252
|
+
* Throws: whatever the read throws after retries.
|
|
253
|
+
*
|
|
254
|
+
* Guarantees: strongly consistent — a put must supersede the row that is really
|
|
255
|
+
* there, not one a replica still shows.
|
|
256
|
+
*/
|
|
257
|
+
async function readExisting(context, key) {
|
|
258
|
+
const existing = await (0, retry_1.withDynamoDBRetry)((request) => context.client.get({
|
|
259
|
+
TableName: context.tableName,
|
|
260
|
+
Key: key,
|
|
261
|
+
ConsistentRead: true,
|
|
262
|
+
ProjectionExpression: '#c, #r, #v.#loc, #v.#s3k',
|
|
263
|
+
ExpressionAttributeNames: {
|
|
264
|
+
'#c': 'createdAt',
|
|
265
|
+
'#r': exports.REVISION_ATTRIBUTE,
|
|
266
|
+
'#v': 'value',
|
|
267
|
+
'#loc': 'location',
|
|
268
|
+
'#s3k': 's3Key',
|
|
269
|
+
},
|
|
270
|
+
}, request), context.retry);
|
|
271
|
+
return existingFrom(existing.Item);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Project a raw row onto {@link ExistingRowMeta}.
|
|
275
|
+
*
|
|
276
|
+
* Accepts: `item` — a read result, or the row a conditional-check rejection
|
|
277
|
+
* carried with it; `undefined` means there is no row.
|
|
278
|
+
*
|
|
279
|
+
* Returns: the fields a put needs from the row it supersedes. Fields the
|
|
280
|
+
* projection did not ask for, or that the row does not carry, are undefined.
|
|
281
|
+
*
|
|
282
|
+
* Throws: nothing.
|
|
283
|
+
*/
|
|
284
|
+
function existingFrom(item) {
|
|
285
|
+
return {
|
|
286
|
+
exists: item !== undefined,
|
|
287
|
+
createdAt: item?.createdAt,
|
|
288
|
+
value: item?.value,
|
|
289
|
+
revision: item?.[exports.REVISION_ATTRIBUTE],
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Narrow a raw scanned row to a {@link StoreItemRow}, or `undefined` for a
|
|
294
|
+
* foreign row on a shared table (no `namespace`) — and for a row whose
|
|
295
|
+
* `namespace`/`key` attributes disagree with the DynamoDB key it was found at.
|
|
296
|
+
* The attributes name the S3 path the row may reference, so they must be bound
|
|
297
|
+
* to the partition the row actually lives in: a writer confined to its own
|
|
298
|
+
* partition can then never make a row speak for another tenant's objects.
|
|
299
|
+
*
|
|
300
|
+
* Accepts: `raw` — any row, whole or projected. The identity test reads only
|
|
301
|
+
* `PK`, `SK`, `namespace` and `key`, and the version check reads only `v`,
|
|
302
|
+
* which is what lets a namespace listing narrow rows it deliberately read
|
|
303
|
+
* without their payload. A projection that leaves out `v` reads every row as
|
|
304
|
+
* version 0, so the check cannot refuse one.
|
|
305
|
+
*
|
|
306
|
+
* Returns: the record, or undefined for a row that is not this adapter's item.
|
|
307
|
+
*
|
|
308
|
+
* Throws: `FORMAT_UNSUPPORTED` for a row a newer format version wrote —
|
|
309
|
+
* checked **before** the shape, as every other read of this package's rows
|
|
310
|
+
* checks it, so such a row is reported as newer rather than judged against
|
|
311
|
+
* attribute names it may no longer use. Skipping it would hide an item that
|
|
312
|
+
* exists.
|
|
313
|
+
*/
|
|
314
|
+
function parseStoreRow(raw) {
|
|
315
|
+
// The version first. A later format may compose the row's key from
|
|
316
|
+
// attributes this one does not know, so testing the shape first reads such a
|
|
317
|
+
// row as foreign and hides an item that is there.
|
|
318
|
+
(0, table_schema_1.assertReadableRow)(raw, 'store item');
|
|
319
|
+
if (!Array.isArray(raw.namespace) || typeof raw.key !== 'string')
|
|
320
|
+
return undefined;
|
|
321
|
+
const record = raw;
|
|
322
|
+
const consistent = record.PK === partitionKey(record.namespace) &&
|
|
323
|
+
record.SK === sortKey(record.namespace, record.key);
|
|
324
|
+
return consistent ? record : undefined;
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* The same narrowing for a call site that needs the *whole* row, not just its
|
|
328
|
+
* identity: {@link readStoreItem} reads the timestamps as well as the payload,
|
|
329
|
+
* and a row that carries none made `new Date(undefined)` — an `Invalid Date`
|
|
330
|
+
* handed back under a declared `Date`, which surfaces as a `RangeError` in the
|
|
331
|
+
* caller's own code, far from the row that caused it.
|
|
332
|
+
*
|
|
333
|
+
* It is a separate narrow rather than a stricter {@link parseStoreRow}
|
|
334
|
+
* because a namespace listing deliberately reads rows without their timestamps
|
|
335
|
+
* (see `projectKeys`): requiring one there would hide every namespace in the
|
|
336
|
+
* table.
|
|
337
|
+
*
|
|
338
|
+
* Accepts: `raw` — any whole row, as read by `get`, a search or a reconcile.
|
|
339
|
+
*
|
|
340
|
+
* Returns: the record, or undefined for a row {@link parseStoreRow}
|
|
341
|
+
* refuses and for one whose `createdAt` or `updatedAt` is not the string this
|
|
342
|
+
* package writes there. A row this adapter cannot describe is skipped where a
|
|
343
|
+
* foreign one already is, so one of them never costs a listing the rest of its
|
|
344
|
+
* rows.
|
|
345
|
+
*
|
|
346
|
+
* Throws: as {@link parseStoreRow}.
|
|
347
|
+
*/
|
|
348
|
+
function parseWholeStoreRow(raw) {
|
|
349
|
+
const record = parseStoreRow(raw);
|
|
350
|
+
if (record === undefined)
|
|
351
|
+
return undefined;
|
|
352
|
+
const stamped = typeof record.createdAt === 'string' && typeof record.updatedAt === 'string';
|
|
353
|
+
return stamped ? record : undefined;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Encode a value into the DynamoDB record for a stored item.
|
|
357
|
+
*
|
|
358
|
+
* Accepts: `address` — already validated; its `namespace` and `key` become the
|
|
359
|
+
* row's key and, with it, the S3 path any offloaded payload may occupy.
|
|
360
|
+
* `value` — a value the serializer can represent. `options.rev` — this put's
|
|
361
|
+
* own revision token, which the compare-and-swap pins, the write verification
|
|
362
|
+
* reads back, and an offloaded value's key ends in; absent, a fresh UUID is
|
|
363
|
+
* drawn, before the value is encoded.
|
|
364
|
+
*
|
|
365
|
+
* Returns: the complete row, including the recency-index attributes: a store
|
|
366
|
+
* item is listed across partitions by a rootless search, so it is indexed.
|
|
367
|
+
*
|
|
368
|
+
* Throws: `VALIDATION` naming `value` for a value with no JSON
|
|
369
|
+
* representation; `S3_OFFLOAD_FAILED` when an offloaded payload cannot be
|
|
370
|
+
* uploaded. Encoding happens before any write, so a value that cannot be stored
|
|
371
|
+
* never half-writes a row.
|
|
372
|
+
*/
|
|
373
|
+
async function buildStoreRow(context, address, value, options) {
|
|
374
|
+
const { namespace, key } = address;
|
|
375
|
+
const pk = partitionKey(namespace);
|
|
376
|
+
const sk = sortKey(namespace, key);
|
|
377
|
+
const rev = options.rev ?? (0, node_crypto_1.randomUUID)();
|
|
378
|
+
const descriptor = await (0, codec_1.encodePayload)(value, (0, codec_1.codecDepsOf)(context), {
|
|
379
|
+
keyParts: [...namespace, key],
|
|
380
|
+
objectId: rev,
|
|
381
|
+
row: { pk, sk },
|
|
382
|
+
});
|
|
383
|
+
// Store items are listed across partitions by a rootless search, so they are indexed.
|
|
384
|
+
const index = (0, recency_index_1.indexKeys)('STORE', sk, options.updatedAt, context.indexShards ?? recency_index_1.DEFAULT_INDEX_SHARDS);
|
|
385
|
+
const record = {
|
|
386
|
+
PK: pk,
|
|
387
|
+
SK: sk,
|
|
388
|
+
v: table_schema_1.ROW_FORMAT_VERSION,
|
|
389
|
+
...index,
|
|
390
|
+
namespace,
|
|
391
|
+
key,
|
|
392
|
+
value: descriptor,
|
|
393
|
+
createdAt: options.createdAt,
|
|
394
|
+
updatedAt: options.updatedAt,
|
|
395
|
+
rev,
|
|
396
|
+
};
|
|
397
|
+
if (options.embeddings)
|
|
398
|
+
record.embeddings = options.embeddings;
|
|
399
|
+
if (options.ttlTimestamp !== undefined)
|
|
400
|
+
record.ttl = options.ttlTimestamp;
|
|
401
|
+
return record;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Decode a DynamoDB record back into a store {@link Item}.
|
|
405
|
+
*
|
|
406
|
+
* Accepts: `record` — a whole row, never a projection: the value and the
|
|
407
|
+
* timestamps are read from it, and `projectKeys` rows exist only to establish
|
|
408
|
+
* identity for a namespace listing. {@link parseWholeStoreRow} is what proves a
|
|
409
|
+
* raw row is one of those, timestamps included. `signal` — cancels the
|
|
410
|
+
* download an offloaded value costs.
|
|
411
|
+
*
|
|
412
|
+
* Returns: the item, with the timestamps this library stamped at write time.
|
|
413
|
+
*
|
|
414
|
+
* Throws: `PAYLOAD_CORRUPT` for a payload that cannot be decoded,
|
|
415
|
+
* `VALIDATION` naming `serde` for one the configured serde refuses to
|
|
416
|
+
* reconstruct, and whatever the download throws for an offloaded one —
|
|
417
|
+
* including the missing-object error `getItem` resolves against a concurrent
|
|
418
|
+
* overwrite.
|
|
419
|
+
*/
|
|
420
|
+
async function readStoreItem(context, record, signal) {
|
|
421
|
+
const value = await (0, codec_1.decodePayload)(record.value, (0, codec_1.codecDepsOf)(context, signal), [...record.namespace, record.key]);
|
|
422
|
+
return {
|
|
423
|
+
namespace: record.namespace,
|
|
424
|
+
key: record.key,
|
|
425
|
+
value,
|
|
426
|
+
createdAt: new Date(record.createdAt),
|
|
427
|
+
updatedAt: new Date(record.updatedAt),
|
|
428
|
+
};
|
|
429
|
+
}
|
|
430
|
+
/**
|
|
431
|
+
* Where a store row sits in the recency index, for a row written before the
|
|
432
|
+
* index existed.
|
|
433
|
+
*
|
|
434
|
+
* Accepts: `row` — any row of the table.
|
|
435
|
+
*
|
|
436
|
+
* Returns: an item row's identity — its sort key, at its own `updatedAt` — or
|
|
437
|
+
* `undefined` for a row of another adapter.
|
|
438
|
+
*
|
|
439
|
+
* Throws: nothing.
|
|
440
|
+
*/
|
|
441
|
+
function storeIndexTarget(row) {
|
|
442
|
+
const pk = typeof row.PK === 'string' ? row.PK : '';
|
|
443
|
+
const sk = typeof row.SK === 'string' ? row.SK : '';
|
|
444
|
+
if (!pk.startsWith(storePartitionPrefix()))
|
|
445
|
+
return undefined;
|
|
446
|
+
return { tag: 'STORE', id: sk, at: (0, recency_index_1.backfilledAt)(row.updatedAt) };
|
|
447
|
+
}
|
|
@@ -1,13 +1,168 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides which text of a value is embedded, and how.
|
|
3
|
+
*
|
|
4
|
+
* The text an index field names is extracted exactly as LangGraph's in-memory
|
|
5
|
+
* store extracts it — dotted paths, `[n]` and `[*]`, `{a,b}` groups, pretty
|
|
6
|
+
* JSON for containers — then embedded in bounded batches, and every vector the
|
|
7
|
+
* model returns is held to the configured dimension.
|
|
8
|
+
*/
|
|
9
|
+
import type { IndexConfig } from '@langchain/langgraph-checkpoint';
|
|
1
10
|
import type { JsonValue } from './filter';
|
|
2
11
|
import type { StoreContext } from './setup';
|
|
3
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* Cosine similarity of two vectors.
|
|
14
|
+
*
|
|
15
|
+
* Accepts: any two vectors. Lengths that disagree, and a vector of all zeros,
|
|
16
|
+
* have no defined angle between them.
|
|
17
|
+
*
|
|
18
|
+
* Returns: the cosine, in [-1, 1]; `0` for the undefined cases, which ranks
|
|
19
|
+
* such a pair as unrelated rather than as opposed. A caller that must
|
|
20
|
+
* distinguish "unrelated" from "incomparable" checks the lengths itself —
|
|
21
|
+
* `rankInMemory` does, so it can report a model mismatch instead of ranking
|
|
22
|
+
* everything at zero.
|
|
23
|
+
*
|
|
24
|
+
* Throws: nothing.
|
|
25
|
+
*/
|
|
4
26
|
export declare function cosineSimilarity(a: number[], b: number[]): number;
|
|
5
|
-
/**
|
|
27
|
+
/**
|
|
28
|
+
* The indexable texts of a value, one per extracted path, in field order.
|
|
29
|
+
*
|
|
30
|
+
* Extraction is byte-for-byte what LangGraph's `InMemoryStore` does (see
|
|
31
|
+
* {@link getTextAtPath}), and so is keeping them apart: the reference embeds each
|
|
32
|
+
* extracted element separately and scores an item by its best-matching one.
|
|
33
|
+
* Joining them and embedding once averages a long document into a single
|
|
34
|
+
* vector, which ranks a document holding one strongly-matching section
|
|
35
|
+
* materially lower — a retrieval-quality difference, not an edge case.
|
|
36
|
+
*
|
|
37
|
+
* Accepts: `value` — a stored item's value. `fields` — JSON paths; a path that
|
|
38
|
+
* addresses nothing contributes nothing.
|
|
39
|
+
*
|
|
40
|
+
* Returns: one text per extracted path, in field order, with empty ones
|
|
41
|
+
* dropped: an empty string embeds to a vector that means nothing and would rank
|
|
42
|
+
* against every query.
|
|
43
|
+
*
|
|
44
|
+
* Throws: nothing.
|
|
45
|
+
*/
|
|
46
|
+
export declare function extractTexts(value: Record<string, JsonValue>, fields: string[]): string[];
|
|
47
|
+
/**
|
|
48
|
+
* The same texts joined into one, which is what a single-vector consumer needs.
|
|
49
|
+
*
|
|
50
|
+
* Accepts: as {@link extractTexts}.
|
|
51
|
+
*
|
|
52
|
+
* Returns: the texts joined by a space, and `''` when there are none — which is
|
|
53
|
+
* how a caller tells "nothing to index" from a text to embed.
|
|
54
|
+
*
|
|
55
|
+
* Throws: nothing.
|
|
56
|
+
*
|
|
57
|
+
* Used only for a configured `vectorBackend`, whose contract is one vector per
|
|
58
|
+
* `(namespace, key)`; the in-DynamoDB path embeds each text separately.
|
|
59
|
+
*/
|
|
6
60
|
export declare function extractText(value: Record<string, JsonValue>, fields: string[]): string;
|
|
7
61
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
62
|
+
* Reject a vector whose length disagrees with the configured `index.dims`. A
|
|
63
|
+
* mismatch means the embeddings model does not match the configuration, so
|
|
64
|
+
* every stored vector would be incomparable with every query; failing here
|
|
65
|
+
* surfaces that at the first put or search instead of ranking silently.
|
|
66
|
+
*
|
|
67
|
+
* Accepts: `index.dims` — the check is skipped when it is not a positive
|
|
68
|
+
* integer, since nothing else in this package reads it and a store configured
|
|
69
|
+
* without it must keep working. `vector` — a document or query vector the model
|
|
70
|
+
* just returned. `what` — names which of the two, for the message.
|
|
71
|
+
*
|
|
72
|
+
* Returns: nothing: `vector` is kept under its declared type, and this
|
|
73
|
+
* checks it.
|
|
74
|
+
*
|
|
75
|
+
* Throws: `VALIDATION` naming `index.dims`.
|
|
76
|
+
*/
|
|
77
|
+
export declare function assertVectorDims(index: IndexConfig, vector: number[], what: string): void;
|
|
78
|
+
/**
|
|
79
|
+
* Embed several values for indexing with `embedDocuments` — the document-side
|
|
80
|
+
* method; providers such as Titan and Cohere embed documents and queries with
|
|
81
|
+
* different task types, so embedding a document with `embedQuery` degrades
|
|
82
|
+
* retrieval.
|
|
83
|
+
*
|
|
84
|
+
* Accepts: `values` — any number, including none. `fieldsOverride` — a put's
|
|
85
|
+
* own `index` fields; absent uses the store's, and a store with no configured
|
|
86
|
+
* fields indexes the whole document (`'$'`), as the reference does.
|
|
87
|
+
*
|
|
88
|
+
* Returns: one entry per value, in input order: its vector, or `undefined` when
|
|
89
|
+
* the value has no indexable text or the store has no index at all.
|
|
90
|
+
*
|
|
91
|
+
* Throws: `VALIDATION` naming `index.dims` when the model's width disagrees
|
|
92
|
+
* with the configuration; whatever the model throws.
|
|
93
|
+
*
|
|
94
|
+
* Guarantees: values with no text are never sent to the model, and the rest go
|
|
95
|
+
* in batches of {@link EMBED_BATCH_SIZE}, so one call cannot turn into one
|
|
96
|
+
* provider request per item or a single unbounded one.
|
|
97
|
+
*/
|
|
98
|
+
export declare function embedValues(context: StoreContext, values: Record<string, JsonValue>[], fieldsOverride?: string[]): Promise<(number[] | undefined)[]>;
|
|
99
|
+
/**
|
|
100
|
+
* Embed one value for indexing.
|
|
101
|
+
*
|
|
102
|
+
* Accepts: as {@link embedValues}, for one value; `fieldsOverride` (from a
|
|
103
|
+
* put's `index` option) takes precedence over the store's configured fields.
|
|
104
|
+
*
|
|
105
|
+
* Returns: the value's vector, or undefined when indexing is off or it has no
|
|
106
|
+
* indexable text.
|
|
107
|
+
*
|
|
108
|
+
* Throws: as {@link embedValues}.
|
|
11
109
|
*/
|
|
12
110
|
export declare function embedValue(context: StoreContext, value: Record<string, JsonValue>, fieldsOverride?: string[]): Promise<number[] | undefined>;
|
|
13
|
-
|
|
111
|
+
/**
|
|
112
|
+
* One vector per extracted path, for the item's own row — the shape the
|
|
113
|
+
* in-DynamoDB ranker scores by best match, matching the reference store.
|
|
114
|
+
*
|
|
115
|
+
* Accepts: as {@link embedValues}, for one value.
|
|
116
|
+
*
|
|
117
|
+
* Returns: one vector per extracted text, in path order; `undefined` when
|
|
118
|
+
* indexing is off or the value yields no indexable text — which is what clears
|
|
119
|
+
* a stale vector on a re-put, since the row is written without the attribute.
|
|
120
|
+
*
|
|
121
|
+
* Throws: as {@link embedValues}.
|
|
122
|
+
*
|
|
123
|
+
* Guarantees: every text of one value goes in as few `embedDocuments` calls as
|
|
124
|
+
* {@link EMBED_BATCH_SIZE} allows, never one call per path.
|
|
125
|
+
*/
|
|
126
|
+
export declare function embedPassages(context: StoreContext, value: Record<string, JsonValue>, fieldsOverride?: string[]): Promise<number[][] | undefined>;
|
|
127
|
+
/**
|
|
128
|
+
* Split a JSON path into tokens the way LangGraph's `InMemoryStore` does: dots
|
|
129
|
+
* separate plain segments, while a `[…]` index and a `{…}` field group each
|
|
130
|
+
* become a token of their own (`tags[0]` → `['tags', '[0]']`).
|
|
131
|
+
*
|
|
132
|
+
* Accepts: any path string. An empty path, and a path of nothing but
|
|
133
|
+
* separators, tokenize to nothing. An **unterminated** `[` or `{` runs to the
|
|
134
|
+
* end of the path and becomes a token that no longer closes — `'tags[0'` →
|
|
135
|
+
* `['tags', '[0']` — so it is resolved as a plain member name and matches
|
|
136
|
+
* nothing unless the value at `tags` holds a field literally called `[0`. That is the reference
|
|
137
|
+
* tokenizer's own answer (`@langchain/langgraph-checkpoint@1.1.5`
|
|
138
|
+
* `dist/store/utils.js:23-30`), and matching it matters more than refusing the
|
|
139
|
+
* path: `index.fields` is validated where it is configured, and text extraction
|
|
140
|
+
* must stay byte-for-byte comparable with the reference store.
|
|
141
|
+
*
|
|
142
|
+
* Returns: the tokens, in path order.
|
|
143
|
+
*
|
|
144
|
+
* Throws: nothing.
|
|
145
|
+
*/
|
|
146
|
+
export declare function tokenizePath(path: string): string[];
|
|
147
|
+
/**
|
|
148
|
+
* Extract the indexable text of `value` at `path`, byte-for-byte as LangGraph's
|
|
149
|
+
* `InMemoryStore` does (`store/utils`), so an embedding computed here matches
|
|
150
|
+
* one computed by the reference store for the same document. Supports plain
|
|
151
|
+
* paths, `[n]`/`[-n]`/`[*]` indexing, a bare `*` wildcard, `{a,b.c}` field
|
|
152
|
+
* groups and `$` for the whole document. The package root's `getTextAtPath` is
|
|
153
|
+
* a string-only variant that returns nothing for numbers, booleans, objects
|
|
154
|
+
* and arrays and throws on a `null` intermediate; it must not be used here.
|
|
155
|
+
*
|
|
156
|
+
* Accepts: `value` — any stored value, including a scalar and `null`. `path` —
|
|
157
|
+
* empty or `$` asks for the whole document; anything else is tokenized. A path
|
|
158
|
+
* that addresses nothing present, a `[n]` against a non-array, a `{…}` group
|
|
159
|
+
* against a non-object: each yields no text rather than an error, because one
|
|
160
|
+
* unindexable field of one item must not fail a put or a search.
|
|
161
|
+
*
|
|
162
|
+
* Returns: the extracted texts, in path order — one per match, kept apart so
|
|
163
|
+
* each is embedded on its own (see `extractTexts`). Empty when the path
|
|
164
|
+
* addresses nothing, and empty for a leaf JSON cannot represent.
|
|
165
|
+
*
|
|
166
|
+
* Throws: nothing.
|
|
167
|
+
*/
|
|
168
|
+
export declare function getTextAtPath(value: JsonValue, path: string): string[];
|