@farukada/aws-langgraph-dynamodb-ts 1.0.0-rc.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +390 -193
- package/dist/{backfill → cjs/backfill}/backfill.d.ts +15 -12
- package/dist/cjs/backfill/backfill.js +177 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/delete-thread.d.ts +1 -1
- package/dist/cjs/checkpointer/actions/delete-thread.js +26 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/get-tuple.d.ts +4 -3
- package/dist/cjs/checkpointer/actions/get-tuple.js +22 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/list.d.ts +7 -4
- package/dist/cjs/checkpointer/actions/list.js +70 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/put-writes.d.ts +8 -6
- package/dist/cjs/checkpointer/actions/put-writes.js +21 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/put.d.ts +21 -15
- package/dist/cjs/checkpointer/actions/put.js +79 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/delta-history.d.ts +38 -26
- package/dist/cjs/checkpointer/internal/delta-history.js +131 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/listing.d.ts +4 -4
- package/dist/cjs/checkpointer/internal/listing.js +104 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/parse.d.ts +51 -15
- package/dist/cjs/checkpointer/internal/parse.js +184 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/pending-writes.d.ts +64 -25
- package/dist/cjs/checkpointer/internal/pending-writes.js +241 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/read.d.ts +15 -10
- package/dist/cjs/checkpointer/internal/read.js +132 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/rows.d.ts +94 -21
- package/dist/cjs/checkpointer/internal/rows.js +356 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/setup.d.ts +13 -20
- package/dist/cjs/checkpointer/internal/setup.js +25 -0
- package/dist/{checkpointer → cjs/checkpointer}/saver.d.ts +72 -36
- package/dist/cjs/checkpointer/saver.js +56 -0
- package/dist/{checkpointer → cjs/checkpointer}/types.d.ts +1 -1
- package/dist/cjs/checkpointer/types.js +2 -0
- package/dist/{factory → cjs/factory}/factory.d.ts +25 -20
- package/dist/cjs/factory/factory.js +137 -0
- package/dist/{factory → cjs/factory}/types.d.ts +12 -12
- package/dist/cjs/factory/types.js +2 -0
- package/dist/{history → cjs/history}/actions/add-messages.d.ts +18 -10
- package/dist/cjs/history/actions/add-messages.js +17 -0
- package/dist/{history → cjs/history}/actions/clear.d.ts +1 -1
- package/dist/cjs/history/actions/clear.js +29 -0
- package/dist/{history → cjs/history}/actions/get-messages.d.ts +11 -9
- package/dist/cjs/history/actions/get-messages.js +58 -0
- package/dist/{history → cjs/history}/actions/list-sessions.d.ts +3 -3
- package/dist/cjs/history/actions/list-sessions.js +67 -0
- package/dist/{history → cjs/history}/actions/reconcile-count.d.ts +13 -9
- package/dist/cjs/history/actions/reconcile-count.js +8 -0
- package/dist/{history → cjs/history}/chat-message-history.d.ts +62 -30
- package/dist/cjs/history/chat-message-history.js +61 -0
- package/dist/{history → cjs/history}/internal/append.d.ts +64 -32
- package/dist/cjs/history/internal/append.js +267 -0
- package/dist/{history → cjs/history}/internal/message-read.d.ts +3 -3
- package/dist/cjs/history/internal/message-read.js +93 -0
- package/dist/{history → cjs/history}/internal/parse.d.ts +2 -2
- package/dist/cjs/history/internal/parse.js +113 -0
- package/dist/{history → cjs/history}/internal/rows.d.ts +11 -10
- package/dist/cjs/history/internal/rows.js +96 -0
- package/dist/{history → cjs/history}/internal/session.d.ts +41 -22
- package/dist/cjs/history/internal/session.js +296 -0
- package/dist/{history → cjs/history}/internal/setup.d.ts +2 -2
- package/dist/cjs/history/internal/setup.js +60 -0
- package/dist/{history → cjs/history}/session-adapter.d.ts +0 -6
- package/dist/cjs/history/session-adapter.js +38 -0
- package/dist/{history → cjs/history}/types.d.ts +18 -15
- package/dist/cjs/history/types.js +2 -0
- package/dist/{index.d.ts → cjs/index.d.ts} +27 -27
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/package.json +1 -0
- package/dist/{shared → cjs/shared}/adapter.d.ts +27 -16
- package/dist/cjs/shared/adapter.js +70 -0
- package/dist/cjs/shared/clock.js +14 -0
- package/dist/{shared → cjs/shared}/codec/codec.d.ts +37 -20
- package/dist/cjs/shared/codec/codec.js +162 -0
- package/dist/{shared → cjs/shared}/codec/compression.d.ts +9 -4
- package/dist/cjs/shared/codec/compression.js +45 -0
- package/dist/cjs/shared/codec/json-serde.js +58 -0
- package/dist/{shared → cjs/shared}/codec/s3/client-types.d.ts +2 -1
- package/dist/cjs/shared/codec/s3/client-types.js +6 -0
- package/dist/{shared → cjs/shared}/codec/s3/client.d.ts +25 -7
- package/dist/cjs/shared/codec/s3/client.js +78 -0
- package/dist/{shared → cjs/shared}/codec/s3/config.d.ts +12 -7
- package/dist/cjs/shared/codec/s3/config.js +92 -0
- package/dist/{shared → cjs/shared}/codec/s3/lifecycle.d.ts +71 -17
- package/dist/cjs/shared/codec/s3/lifecycle.js +223 -0
- package/dist/{shared → cjs/shared}/codec/s3/offloader.d.ts +42 -29
- package/dist/cjs/shared/codec/s3/offloader.js +289 -0
- package/dist/cjs/shared/concurrency.js +31 -0
- package/dist/{shared → cjs/shared}/dynamodb/abort.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/abort.js +16 -0
- package/dist/{shared → cjs/shared}/dynamodb/batch-write.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/batch-write.js +79 -0
- package/dist/cjs/shared/dynamodb/cancellation.js +37 -0
- package/dist/{shared → cjs/shared}/dynamodb/client.d.ts +24 -22
- package/dist/cjs/shared/dynamodb/client.js +40 -0
- package/dist/{shared → cjs/shared}/dynamodb/idempotent-write.d.ts +64 -19
- package/dist/cjs/shared/dynamodb/idempotent-write.js +173 -0
- package/dist/{shared → cjs/shared}/dynamodb/paginate.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/paginate.js +90 -0
- package/dist/{shared → cjs/shared}/dynamodb/partition-delete.d.ts +6 -6
- package/dist/cjs/shared/dynamodb/partition-delete.js +177 -0
- package/dist/{shared → cjs/shared}/dynamodb/recency-index.d.ts +27 -15
- package/dist/cjs/shared/dynamodb/recency-index.js +146 -0
- package/dist/{shared → cjs/shared}/dynamodb/retry.d.ts +37 -6
- package/dist/cjs/shared/dynamodb/retry.js +193 -0
- package/dist/cjs/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/cjs/shared/dynamodb/row-size.js +30 -0
- package/dist/{shared → cjs/shared}/dynamodb/table-schema.d.ts +27 -18
- package/dist/cjs/shared/dynamodb/table-schema.js +52 -0
- package/dist/{shared → cjs/shared}/errors/base-error.d.ts +42 -7
- package/dist/cjs/shared/errors/base-error.js +73 -0
- package/dist/{shared → cjs/shared}/errors/boundary.d.ts +29 -14
- package/dist/cjs/shared/errors/boundary.js +61 -0
- package/dist/cjs/shared/errors/classify.d.ts +206 -0
- package/dist/cjs/shared/errors/classify.js +232 -0
- package/dist/{shared → cjs/shared}/errors/error-code.d.ts +17 -10
- package/dist/cjs/shared/errors/error-code.js +27 -0
- package/dist/{shared → cjs/shared}/errors/errors.d.ts +75 -9
- package/dist/cjs/shared/errors/errors.js +123 -0
- package/dist/cjs/shared/logging/logger.js +30 -0
- package/dist/{shared → cjs/shared}/logging/redaction.d.ts +8 -4
- package/dist/cjs/shared/logging/redaction.js +145 -0
- package/dist/{shared → cjs/shared}/logging/secret-patterns.d.ts +30 -7
- package/dist/cjs/shared/logging/secret-patterns.js +93 -0
- package/dist/cjs/shared/logging/truncate.js +31 -0
- package/dist/{shared → cjs/shared}/options.d.ts +27 -11
- package/dist/cjs/shared/options.js +2 -0
- package/dist/cjs/shared/ulid.js +83 -0
- package/dist/{shared → cjs/shared}/validation/collaborators.d.ts +21 -2
- package/dist/cjs/shared/validation/collaborators.js +79 -0
- package/dist/{shared → cjs/shared}/validation/option-shape.d.ts +7 -5
- package/dist/cjs/shared/validation/option-shape.js +31 -0
- package/dist/{shared → cjs/shared}/validation/options.d.ts +4 -4
- package/dist/cjs/shared/validation/options.js +166 -0
- package/dist/cjs/shared/validation/primitives.js +114 -0
- package/dist/{shared → cjs/shared}/validation/ttl.d.ts +26 -9
- package/dist/cjs/shared/validation/ttl.js +52 -0
- package/dist/{store → cjs/store}/actions/list-namespaces.d.ts +5 -5
- package/dist/cjs/store/actions/list-namespaces.js +92 -0
- package/dist/{store → cjs/store}/actions/put.d.ts +11 -4
- package/dist/cjs/store/actions/put.js +49 -0
- package/dist/{store → cjs/store}/actions/reconcile-vector-index.d.ts +5 -5
- package/dist/cjs/store/actions/reconcile-vector-index.js +13 -0
- package/dist/{store → cjs/store}/actions/search.d.ts +2 -2
- package/dist/cjs/store/actions/search.js +26 -0
- package/dist/cjs/store/internal/batch-plan.d.ts +56 -0
- package/dist/cjs/store/internal/batch-plan.js +32 -0
- package/dist/{store → cjs/store}/internal/filter.d.ts +3 -3
- package/dist/cjs/store/internal/filter.js +64 -0
- package/dist/cjs/store/internal/get-item.d.ts +77 -0
- package/dist/cjs/store/internal/get-item.js +58 -0
- package/dist/{store → cjs/store}/internal/item-write.d.ts +72 -32
- package/dist/cjs/store/internal/item-write.js +181 -0
- package/dist/{store → cjs/store}/internal/parse.d.ts +15 -10
- package/dist/cjs/store/internal/parse.js +180 -0
- package/dist/{store → cjs/store}/internal/rows.d.ts +38 -34
- package/dist/cjs/store/internal/rows.js +166 -0
- package/dist/{store → cjs/store}/internal/semantic-search.d.ts +2 -2
- package/dist/cjs/store/internal/semantic-search.js +211 -0
- package/dist/{store → cjs/store}/internal/setup.d.ts +10 -15
- package/dist/cjs/store/internal/setup.js +103 -0
- package/dist/{store → cjs/store}/internal/table-search.d.ts +5 -5
- package/dist/cjs/store/internal/table-search.js +123 -0
- package/dist/{store → cjs/store}/internal/vector-index.d.ts +26 -15
- package/dist/cjs/store/internal/vector-index.js +269 -0
- package/dist/{store → cjs/store}/store.d.ts +82 -39
- package/dist/cjs/store/store.js +97 -0
- package/dist/{store → cjs/store}/types.d.ts +25 -10
- package/dist/cjs/store/types.js +2 -0
- package/dist/cjs/store/vector-backend.js +4 -0
- package/dist/esm/backfill/backfill.d.ts +171 -0
- package/dist/esm/backfill/backfill.js +170 -0
- package/dist/{checkpointer/actions/delete-thread.js → esm/checkpointer/actions/delete-thread.d.ts} +4 -26
- package/dist/esm/checkpointer/actions/delete-thread.js +23 -0
- package/dist/{checkpointer/actions/get-tuple.js → esm/checkpointer/actions/get-tuple.d.ts} +7 -24
- package/dist/esm/checkpointer/actions/get-tuple.js +19 -0
- package/dist/esm/checkpointer/actions/list.d.ts +55 -0
- package/dist/esm/checkpointer/actions/list.js +67 -0
- package/dist/{checkpointer/actions/put-writes.js → esm/checkpointer/actions/put-writes.d.ts} +10 -37
- package/dist/esm/checkpointer/actions/put-writes.js +18 -0
- package/dist/esm/checkpointer/actions/put.d.ts +95 -0
- package/dist/esm/checkpointer/actions/put.js +75 -0
- package/dist/esm/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/esm/checkpointer/internal/delta-history.js +126 -0
- package/dist/{checkpointer/internal/listing.js → esm/checkpointer/internal/listing.d.ts} +22 -118
- package/dist/esm/checkpointer/internal/listing.js +95 -0
- package/dist/esm/checkpointer/internal/parse.d.ts +298 -0
- package/dist/esm/checkpointer/internal/parse.js +169 -0
- package/dist/esm/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/esm/checkpointer/internal/pending-writes.js +229 -0
- package/dist/esm/checkpointer/internal/read.d.ts +135 -0
- package/dist/esm/checkpointer/internal/read.js +125 -0
- package/dist/esm/checkpointer/internal/rows.d.ts +644 -0
- package/dist/esm/checkpointer/internal/rows.js +323 -0
- package/dist/esm/checkpointer/internal/setup.d.ts +47 -0
- package/dist/esm/checkpointer/internal/setup.js +21 -0
- package/dist/{checkpointer/saver.js → esm/checkpointer/saver.d.ts} +84 -87
- package/dist/esm/checkpointer/saver.js +52 -0
- package/dist/esm/checkpointer/types.d.ts +51 -0
- package/dist/esm/checkpointer/types.js +1 -0
- package/dist/esm/factory/factory.d.ts +154 -0
- package/dist/esm/factory/factory.js +133 -0
- package/dist/esm/factory/types.d.ts +76 -0
- package/dist/esm/factory/types.js +1 -0
- package/dist/{history/actions/add-messages.js → esm/history/actions/add-messages.d.ts} +20 -26
- package/dist/esm/history/actions/add-messages.js +14 -0
- package/dist/{history/actions/clear.js → esm/history/actions/clear.d.ts} +4 -35
- package/dist/esm/history/actions/clear.js +26 -0
- package/dist/esm/history/actions/get-messages.d.ts +60 -0
- package/dist/esm/history/actions/get-messages.js +55 -0
- package/dist/esm/history/actions/list-sessions.d.ts +55 -0
- package/dist/esm/history/actions/list-sessions.js +64 -0
- package/dist/{history/actions/reconcile-count.js → esm/history/actions/reconcile-count.d.ts} +14 -16
- package/dist/esm/history/actions/reconcile-count.js +5 -0
- package/dist/{history/chat-message-history.js → esm/history/chat-message-history.d.ts} +76 -87
- package/dist/esm/history/chat-message-history.js +57 -0
- package/dist/esm/history/internal/append.d.ts +244 -0
- package/dist/esm/history/internal/append.js +259 -0
- package/dist/esm/history/internal/message-read.d.ts +84 -0
- package/dist/esm/history/internal/message-read.js +89 -0
- package/dist/esm/history/internal/parse.d.ts +153 -0
- package/dist/esm/history/internal/parse.js +105 -0
- package/dist/{history/internal/rows.js → esm/history/internal/rows.d.ts} +58 -112
- package/dist/esm/history/internal/rows.js +83 -0
- package/dist/esm/history/internal/session.d.ts +350 -0
- package/dist/esm/history/internal/session.js +285 -0
- package/dist/esm/history/internal/setup.d.ts +64 -0
- package/dist/esm/history/internal/setup.js +56 -0
- package/dist/{history/session-adapter.js → esm/history/session-adapter.d.ts} +25 -39
- package/dist/esm/history/session-adapter.js +34 -0
- package/dist/esm/history/types.d.ts +102 -0
- package/dist/esm/history/types.js +1 -0
- package/dist/esm/index.d.ts +53 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/shared/adapter.d.ts +146 -0
- package/dist/esm/shared/adapter.js +65 -0
- package/dist/{shared/clock.js → esm/shared/clock.d.ts} +3 -14
- package/dist/esm/shared/clock.js +9 -0
- package/dist/esm/shared/codec/codec.d.ts +336 -0
- package/dist/esm/shared/codec/codec.js +150 -0
- package/dist/esm/shared/codec/compression.d.ts +66 -0
- package/dist/esm/shared/codec/compression.js +40 -0
- package/dist/esm/shared/codec/json-serde.d.ts +80 -0
- package/dist/esm/shared/codec/json-serde.js +54 -0
- package/dist/esm/shared/codec/s3/client-types.d.ts +54 -0
- package/dist/esm/shared/codec/s3/client-types.js +3 -0
- package/dist/esm/shared/codec/s3/client.d.ts +63 -0
- package/dist/esm/shared/codec/s3/client.js +40 -0
- package/dist/{shared/codec/s3/config.js → esm/shared/codec/s3/config.d.ts} +45 -93
- package/dist/esm/shared/codec/s3/config.js +79 -0
- package/dist/esm/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/esm/shared/codec/s3/lifecycle.js +214 -0
- package/dist/esm/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/esm/shared/codec/s3/offloader.js +278 -0
- package/dist/{shared/concurrency.js → esm/shared/concurrency.d.ts} +2 -37
- package/dist/esm/shared/concurrency.js +27 -0
- package/dist/{shared/dynamodb/abort.js → esm/shared/dynamodb/abort.d.ts} +4 -16
- package/dist/esm/shared/dynamodb/abort.js +12 -0
- package/dist/esm/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/esm/shared/dynamodb/batch-write.js +74 -0
- package/dist/{shared/dynamodb/cancellation.js → esm/shared/dynamodb/cancellation.d.ts} +25 -53
- package/dist/esm/shared/dynamodb/cancellation.js +30 -0
- package/dist/{shared/dynamodb/client.js → esm/shared/dynamodb/client.d.ts} +74 -64
- package/dist/esm/shared/dynamodb/client.js +35 -0
- package/dist/{shared/dynamodb/idempotent-write.js → esm/shared/dynamodb/idempotent-write.d.ts} +172 -169
- package/dist/esm/shared/dynamodb/idempotent-write.js +153 -0
- package/dist/esm/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/esm/shared/dynamodb/paginate.js +84 -0
- package/dist/esm/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/esm/shared/dynamodb/partition-delete.js +171 -0
- package/dist/esm/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/esm/shared/dynamodb/recency-index.js +136 -0
- package/dist/esm/shared/dynamodb/retry.d.ts +317 -0
- package/dist/esm/shared/dynamodb/retry.js +180 -0
- package/dist/esm/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/esm/shared/dynamodb/row-size.js +26 -0
- package/dist/{shared/dynamodb/table-schema.js → esm/shared/dynamodb/table-schema.d.ts} +57 -67
- package/dist/esm/shared/dynamodb/table-schema.js +43 -0
- package/dist/esm/shared/errors/base-error.d.ts +231 -0
- package/dist/esm/shared/errors/base-error.js +64 -0
- package/dist/esm/shared/errors/boundary.d.ts +86 -0
- package/dist/esm/shared/errors/boundary.js +54 -0
- package/dist/esm/shared/errors/classify.d.ts +206 -0
- package/dist/esm/shared/errors/classify.js +220 -0
- package/dist/{shared/errors/error-code.js → esm/shared/errors/error-code.d.ts} +39 -43
- package/dist/esm/shared/errors/error-code.js +24 -0
- package/dist/{shared/errors/errors.js → esm/shared/errors/errors.d.ts} +92 -98
- package/dist/esm/shared/errors/errors.js +110 -0
- package/dist/{shared/logging/logger.js → esm/shared/logging/logger.d.ts} +22 -52
- package/dist/esm/shared/logging/logger.js +25 -0
- package/dist/esm/shared/logging/redaction.d.ts +123 -0
- package/dist/esm/shared/logging/redaction.js +140 -0
- package/dist/{shared/logging/secret-patterns.js → esm/shared/logging/secret-patterns.d.ts} +46 -87
- package/dist/esm/shared/logging/secret-patterns.js +83 -0
- package/dist/{shared/logging/truncate.js → esm/shared/logging/truncate.d.ts} +6 -40
- package/dist/esm/shared/logging/truncate.js +25 -0
- package/dist/esm/shared/options.d.ts +100 -0
- package/dist/esm/shared/options.js +1 -0
- package/dist/{shared/ulid.js → esm/shared/ulid.d.ts} +4 -84
- package/dist/esm/shared/ulid.js +77 -0
- package/dist/{shared/validation/collaborators.js → esm/shared/validation/collaborators.d.ts} +37 -65
- package/dist/esm/shared/validation/collaborators.js +70 -0
- package/dist/{shared/validation/option-shape.js → esm/shared/validation/option-shape.d.ts} +14 -36
- package/dist/esm/shared/validation/option-shape.js +24 -0
- package/dist/esm/shared/validation/options.d.ts +145 -0
- package/dist/esm/shared/validation/options.js +156 -0
- package/dist/{shared/validation/primitives.js → esm/shared/validation/primitives.d.ts} +30 -125
- package/dist/esm/shared/validation/primitives.js +100 -0
- package/dist/esm/shared/validation/ttl.d.ts +94 -0
- package/dist/esm/shared/validation/ttl.js +46 -0
- package/dist/esm/store/actions/list-namespaces.d.ts +79 -0
- package/dist/esm/store/actions/list-namespaces.js +86 -0
- package/dist/esm/store/actions/put.d.ts +43 -0
- package/dist/esm/store/actions/put.js +46 -0
- package/dist/{store/actions/reconcile-vector-index.js → esm/store/actions/reconcile-vector-index.d.ts} +8 -16
- package/dist/esm/store/actions/reconcile-vector-index.js +10 -0
- package/dist/esm/store/actions/search.d.ts +38 -0
- package/dist/esm/store/actions/search.js +23 -0
- package/dist/esm/store/internal/batch-plan.d.ts +56 -0
- package/dist/esm/store/internal/batch-plan.js +28 -0
- package/dist/esm/store/internal/filter.d.ts +43 -0
- package/dist/esm/store/internal/filter.js +60 -0
- package/dist/esm/store/internal/get-item.d.ts +77 -0
- package/dist/esm/store/internal/get-item.js +54 -0
- package/dist/esm/store/internal/item-write.d.ts +270 -0
- package/dist/esm/store/internal/item-write.js +173 -0
- package/dist/esm/store/internal/parse.d.ts +230 -0
- package/dist/esm/store/internal/parse.js +169 -0
- package/dist/{store/internal/rows.js → esm/store/internal/rows.d.ts} +111 -199
- package/dist/esm/store/internal/rows.js +147 -0
- package/dist/esm/store/internal/semantic-search.d.ts +168 -0
- package/dist/esm/store/internal/semantic-search.js +200 -0
- package/dist/esm/store/internal/setup.d.ts +96 -0
- package/dist/esm/store/internal/setup.js +98 -0
- package/dist/esm/store/internal/table-search.d.ts +100 -0
- package/dist/esm/store/internal/table-search.js +119 -0
- package/dist/esm/store/internal/vector-index.d.ts +258 -0
- package/dist/esm/store/internal/vector-index.js +256 -0
- package/dist/{store/store.js → esm/store/store.d.ts} +99 -133
- package/dist/esm/store/store.js +93 -0
- package/dist/esm/store/types.d.ts +111 -0
- package/dist/esm/store/types.js +1 -0
- package/dist/esm/store/vector-backend.d.ts +104 -0
- package/dist/esm/store/vector-backend.js +1 -0
- package/package.json +50 -44
- package/dist/backfill/backfill.js +0 -393
- package/dist/checkpointer/actions/list.js +0 -142
- package/dist/checkpointer/actions/put.js +0 -195
- package/dist/checkpointer/internal/delta-history.js +0 -252
- package/dist/checkpointer/internal/parse.js +0 -372
- package/dist/checkpointer/internal/pending-writes.js +0 -588
- package/dist/checkpointer/internal/read.js +0 -264
- package/dist/checkpointer/internal/rows.js +0 -834
- package/dist/checkpointer/internal/setup.js +0 -72
- package/dist/checkpointer/types.js +0 -12
- package/dist/factory/factory.js +0 -266
- package/dist/factory/types.js +0 -10
- package/dist/history/actions/get-messages.js +0 -141
- package/dist/history/actions/list-sessions.js +0 -156
- package/dist/history/internal/append.js +0 -500
- package/dist/history/internal/message-read.js +0 -204
- package/dist/history/internal/parse.js +0 -252
- package/dist/history/internal/session.js +0 -628
- package/dist/history/internal/setup.js +0 -106
- package/dist/history/types.js +0 -12
- package/dist/index.js +0 -51
- package/dist/shared/adapter.js +0 -143
- package/dist/shared/codec/codec.js +0 -441
- package/dist/shared/codec/compression.js +0 -89
- package/dist/shared/codec/json-serde.js +0 -191
- package/dist/shared/codec/s3/client-types.js +0 -26
- package/dist/shared/codec/s3/client.js +0 -97
- package/dist/shared/codec/s3/lifecycle.js +0 -355
- package/dist/shared/codec/s3/offloader.js +0 -658
- package/dist/shared/dynamodb/batch-write.js +0 -173
- package/dist/shared/dynamodb/paginate.js +0 -188
- package/dist/shared/dynamodb/partition-delete.js +0 -340
- package/dist/shared/dynamodb/recency-index.js +0 -377
- package/dist/shared/dynamodb/retry.js +0 -463
- package/dist/shared/errors/base-error.js +0 -174
- package/dist/shared/errors/boundary.js +0 -143
- package/dist/shared/errors/classify.d.ts +0 -97
- package/dist/shared/errors/classify.js +0 -257
- package/dist/shared/logging/redaction.js +0 -316
- package/dist/shared/options.js +0 -11
- package/dist/shared/validation/options.js +0 -328
- package/dist/shared/validation/ttl.js +0 -132
- package/dist/store/actions/list-namespaces.js +0 -197
- package/dist/store/actions/put.js +0 -78
- package/dist/store/actions/search.js +0 -66
- package/dist/store/internal/batch-plan.d.ts +0 -26
- package/dist/store/internal/batch-plan.js +0 -109
- package/dist/store/internal/filter.js +0 -137
- package/dist/store/internal/get-item.d.ts +0 -45
- package/dist/store/internal/get-item.js +0 -115
- package/dist/store/internal/item-write.js +0 -463
- package/dist/store/internal/parse.js +0 -350
- package/dist/store/internal/semantic-search.js +0 -389
- package/dist/store/internal/setup.js +0 -223
- package/dist/store/internal/table-search.js +0 -213
- package/dist/store/internal/vector-index.js +0 -546
- package/dist/store/types.js +0 -15
- package/dist/store/vector-backend.js +0 -17
- /package/dist/{shared → cjs/shared}/clock.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/codec/json-serde.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/concurrency.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/dynamodb/cancellation.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/logging/logger.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/logging/truncate.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/ulid.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/validation/primitives.d.ts +0 -0
- /package/dist/{store → cjs/store}/vector-backend.d.ts +0 -0
|
@@ -1,49 +1,25 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Hides the store's key layout and how an item becomes a row and back.
|
|
4
3
|
*
|
|
5
4
|
* An item's namespace root is its partition and the rest of its namespace,
|
|
6
5
|
* with its key, is its sort key, so a prefix search is a key-range query. How
|
|
7
6
|
* those keys are composed, which attributes a row carries — its revision token,
|
|
8
|
-
* timestamps, embeddings
|
|
9
|
-
* and
|
|
10
|
-
* decided here.
|
|
7
|
+
* timestamps, embeddings — how a value is encoded into one and decoded out,
|
|
8
|
+
* and which rows a read admits as this adapter's items are decided here.
|
|
11
9
|
*/
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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");
|
|
10
|
+
import type { QueryCommandInput, ScanCommandInput } from '@aws-sdk/lib-dynamodb';
|
|
11
|
+
import type { Item } from '@langchain/langgraph-checkpoint';
|
|
12
|
+
import { type DescriptorRef, type PayloadDescriptor } from '../../shared/codec/codec.js';
|
|
13
|
+
import type { AttributeMap } from '../../shared/dynamodb/client.js';
|
|
14
|
+
import { type RowKey } from '../../shared/dynamodb/table-schema.js';
|
|
15
|
+
import type { JsonValue } from './filter.js';
|
|
16
|
+
import type { StoreContext } from './setup.js';
|
|
35
17
|
/**
|
|
36
18
|
* The attribute an item row carries its revision token in, rewritten on every
|
|
37
19
|
* put. A put's compare-and-swap and a delete's pin both hold the row to the
|
|
38
20
|
* token they observed.
|
|
39
21
|
*/
|
|
40
|
-
|
|
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}`;
|
|
22
|
+
export declare const REVISION_ATTRIBUTE = "rev";
|
|
47
23
|
/**
|
|
48
24
|
* The tag every store partition key starts with.
|
|
49
25
|
*
|
|
@@ -54,9 +30,7 @@ const ADAPTER_PARTITION_PREFIX = `${table_schema_1.ADAPTER_TAGS.store}${table_sc
|
|
|
54
30
|
*
|
|
55
31
|
* Throws: nothing.
|
|
56
32
|
*/
|
|
57
|
-
function storePartitionPrefix()
|
|
58
|
-
return ADAPTER_PARTITION_PREFIX;
|
|
59
|
-
}
|
|
33
|
+
export declare function storePartitionPrefix(): string;
|
|
60
34
|
/**
|
|
61
35
|
* Partition key for an item: the adapter tag plus the scope-root element.
|
|
62
36
|
*
|
|
@@ -71,9 +45,7 @@ function storePartitionPrefix() {
|
|
|
71
45
|
*
|
|
72
46
|
* Throws: nothing.
|
|
73
47
|
*/
|
|
74
|
-
function partitionKey(namespace)
|
|
75
|
-
return `${ADAPTER_PARTITION_PREFIX}${namespace[0]}`;
|
|
76
|
-
}
|
|
48
|
+
export declare function partitionKey(namespace: string[]): string;
|
|
77
49
|
/**
|
|
78
50
|
* Sort key: the rest of the namespace plus the key, separator-joined.
|
|
79
51
|
*
|
|
@@ -85,9 +57,7 @@ function partitionKey(namespace) {
|
|
|
85
57
|
*
|
|
86
58
|
* Throws: nothing.
|
|
87
59
|
*/
|
|
88
|
-
function sortKey(namespace, key)
|
|
89
|
-
return [...namespace.slice(1), key].join(table_schema_1.KEY_SEPARATOR);
|
|
90
|
-
}
|
|
60
|
+
export declare function sortKey(namespace: string[], key: string): string;
|
|
91
61
|
/**
|
|
92
62
|
* `begins_with` prefix selecting a scoped subtree within `prefix[0]`'s
|
|
93
63
|
* partition.
|
|
@@ -101,10 +71,7 @@ function sortKey(namespace, key) {
|
|
|
101
71
|
*
|
|
102
72
|
* Throws: nothing.
|
|
103
73
|
*/
|
|
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
|
-
}
|
|
74
|
+
export declare function sortKeyPrefix(prefix: string[]): string;
|
|
108
75
|
/**
|
|
109
76
|
* Whether `namespace` starts with `prefix`, element by element.
|
|
110
77
|
*
|
|
@@ -117,11 +84,7 @@ function sortKeyPrefix(prefix) {
|
|
|
117
84
|
*
|
|
118
85
|
* Throws: nothing.
|
|
119
86
|
*/
|
|
120
|
-
function namespaceMatchesPrefix(namespace, prefix)
|
|
121
|
-
if (prefix.length > namespace.length)
|
|
122
|
-
return false;
|
|
123
|
-
return prefix.every((element, index) => namespace[index] === element);
|
|
124
|
-
}
|
|
87
|
+
export declare function namespaceMatchesPrefix(namespace: string[], prefix: string[]): boolean;
|
|
125
88
|
/**
|
|
126
89
|
* The key of an item's row.
|
|
127
90
|
*
|
|
@@ -132,9 +95,10 @@ function namespaceMatchesPrefix(namespace, prefix) {
|
|
|
132
95
|
*
|
|
133
96
|
* Throws: nothing.
|
|
134
97
|
*/
|
|
135
|
-
function itemRowKey(address
|
|
136
|
-
|
|
137
|
-
|
|
98
|
+
export declare function itemRowKey(address: {
|
|
99
|
+
namespace: string[];
|
|
100
|
+
key: string;
|
|
101
|
+
}): RowKey;
|
|
138
102
|
/**
|
|
139
103
|
* Query input for a scoped prefix.
|
|
140
104
|
*
|
|
@@ -148,23 +112,7 @@ function itemRowKey(address) {
|
|
|
148
112
|
*
|
|
149
113
|
* Throws: nothing.
|
|
150
114
|
*/
|
|
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
|
-
}
|
|
115
|
+
export declare function scopedQuery(tableName: string, prefix: string[]): QueryCommandInput;
|
|
168
116
|
/**
|
|
169
117
|
* Scan input for the rootless case, filtered to store items only.
|
|
170
118
|
*
|
|
@@ -194,14 +142,7 @@ function scopedQuery(tableName, prefix) {
|
|
|
194
142
|
*
|
|
195
143
|
* Throws: nothing.
|
|
196
144
|
*/
|
|
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
|
-
}
|
|
145
|
+
export declare function storeScan(tableName: string): ScanCommandInput;
|
|
205
146
|
/**
|
|
206
147
|
* Restrict a Query/Scan to the attributes `parseStoreRow` needs, leaving the
|
|
207
148
|
* payload behind: a namespace listing never reads a value.
|
|
@@ -220,24 +161,39 @@ function storeScan(tableName) {
|
|
|
220
161
|
* Guarantees: RCU is billed on the stored size regardless, so the saving is
|
|
221
162
|
* transfer and unmarshalling, not cost.
|
|
222
163
|
*/
|
|
223
|
-
function projectKeys(params)
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
},
|
|
233
|
-
};
|
|
164
|
+
export declare function projectKeys<T extends QueryCommandInput | ScanCommandInput>(params: T): T;
|
|
165
|
+
/** The previous row's createdAt, expiry, payload descriptor and revision. */
|
|
166
|
+
export interface ExistingRowMeta {
|
|
167
|
+
exists: boolean;
|
|
168
|
+
createdAt?: string;
|
|
169
|
+
/** The row's expiry stamp in epoch seconds, when it carries one. */
|
|
170
|
+
ttl?: number;
|
|
171
|
+
value?: DescriptorRef;
|
|
172
|
+
revision?: string;
|
|
234
173
|
}
|
|
174
|
+
/**
|
|
175
|
+
* Whether a row a put is about to replace is an item to its readers.
|
|
176
|
+
*
|
|
177
|
+
* A row past its `ttl` is hidden from `get`, from every search and from every
|
|
178
|
+
* listing until DynamoDB's sweep removes it, which can lag for days; a put over
|
|
179
|
+
* one is a creation, not an update. The row's revision and descriptor still
|
|
180
|
+
* count — the swap must pin the row that is physically there and release the
|
|
181
|
+
* object it names — so this is asked only of what the put inherits.
|
|
182
|
+
*
|
|
183
|
+
* Accepts: `existing` — what {@link readExisting} or {@link existingFrom} read.
|
|
184
|
+
*
|
|
185
|
+
* Returns: true when there is a row and it has not expired.
|
|
186
|
+
*
|
|
187
|
+
* Throws: nothing.
|
|
188
|
+
*/
|
|
189
|
+
export declare function isLiveRow(existing: ExistingRowMeta): boolean;
|
|
235
190
|
/**
|
|
236
191
|
* Read the fields a put needs from the row it is about to replace, in one
|
|
237
|
-
* strongly-consistent projection: `createdAt` to preserve
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
192
|
+
* strongly-consistent projection: `createdAt` to preserve and the `ttl` that
|
|
193
|
+
* decides whether it is preserved, the descriptor's location and S3 key to
|
|
194
|
+
* clean up afterwards (never its inline bytes, which can be hundreds of
|
|
195
|
+
* kilobytes the write would only discard), and the revision the
|
|
196
|
+
* compare-and-swap pins.
|
|
241
197
|
*
|
|
242
198
|
* Lives apart from `actions/put.ts` so `item-write.ts` can re-read on a lost swap
|
|
243
199
|
* without importing its own caller.
|
|
@@ -254,22 +210,7 @@ function projectKeys(params) {
|
|
|
254
210
|
* Guarantees: strongly consistent — a put must supersede the row that is really
|
|
255
211
|
* there, not one a replica still shows.
|
|
256
212
|
*/
|
|
257
|
-
|
|
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
|
-
}
|
|
213
|
+
export declare function readExisting(context: StoreContext, key: RowKey): Promise<ExistingRowMeta>;
|
|
273
214
|
/**
|
|
274
215
|
* Project a raw row onto {@link ExistingRowMeta}.
|
|
275
216
|
*
|
|
@@ -281,13 +222,37 @@ async function readExisting(context, key) {
|
|
|
281
222
|
*
|
|
282
223
|
* Throws: nothing.
|
|
283
224
|
*/
|
|
284
|
-
function existingFrom(item)
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
225
|
+
export declare function existingFrom(item: AttributeMap | undefined): ExistingRowMeta;
|
|
226
|
+
/** The DynamoDB item backing a single stored value. */
|
|
227
|
+
export interface StoreItemRow {
|
|
228
|
+
PK: string;
|
|
229
|
+
SK: string;
|
|
230
|
+
/** Row format version; absent on rows written before it existed (see `table-schema.ts`). */
|
|
231
|
+
v?: number;
|
|
232
|
+
namespace: string[];
|
|
233
|
+
key: string;
|
|
234
|
+
value: PayloadDescriptor;
|
|
235
|
+
createdAt: string;
|
|
236
|
+
updatedAt: string;
|
|
237
|
+
/**
|
|
238
|
+
* One vector per extracted path, scored by best match on read. Absent when
|
|
239
|
+
* the value has no indexable text, or when a `vectorBackend` holds the
|
|
240
|
+
* vectors instead.
|
|
241
|
+
*/
|
|
242
|
+
embeddings?: number[][];
|
|
243
|
+
/**
|
|
244
|
+
* The single joined vector rows carried before the store embedded each path
|
|
245
|
+
* separately. Never written now; still read, and scored as a one-element
|
|
246
|
+
* list, so rows written by an earlier version rank exactly as they did.
|
|
247
|
+
*/
|
|
248
|
+
embedding?: number[];
|
|
249
|
+
ttl?: number;
|
|
250
|
+
/**
|
|
251
|
+
* Revision token, rewritten on every put. Pins the compare-and-swap that
|
|
252
|
+
* keeps two concurrent overwrites from both deleting the same superseded S3
|
|
253
|
+
* object. Optional: rows written before 0.9.0 carry none.
|
|
254
|
+
*/
|
|
255
|
+
rev?: string;
|
|
291
256
|
}
|
|
292
257
|
/**
|
|
293
258
|
* Narrow a raw scanned row to a {@link StoreItemRow}, or `undefined` for a
|
|
@@ -311,18 +276,7 @@ function existingFrom(item) {
|
|
|
311
276
|
* attribute names it may no longer use. Skipping it would hide an item that
|
|
312
277
|
* exists.
|
|
313
278
|
*/
|
|
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
|
-
}
|
|
279
|
+
export declare function parseStoreRow(raw: AttributeMap): StoreItemRow | undefined;
|
|
326
280
|
/**
|
|
327
281
|
* The same narrowing for a call site that needs the *whole* row, not just its
|
|
328
282
|
* identity: {@link readStoreItem} reads the timestamps as well as the payload,
|
|
@@ -345,12 +299,21 @@ function parseStoreRow(raw) {
|
|
|
345
299
|
*
|
|
346
300
|
* Throws: as {@link parseStoreRow}.
|
|
347
301
|
*/
|
|
348
|
-
function parseWholeStoreRow(raw)
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
302
|
+
export declare function parseWholeStoreRow(raw: AttributeMap): StoreItemRow | undefined;
|
|
303
|
+
/** Fields controlling a stored item's timestamps, embeddings, ttl and revision token. */
|
|
304
|
+
export interface BuildRowOptions {
|
|
305
|
+
createdAt: string;
|
|
306
|
+
updatedAt: string;
|
|
307
|
+
embeddings?: number[][];
|
|
308
|
+
ttlTimestamp?: number;
|
|
309
|
+
/**
|
|
310
|
+
* The row's revision token, unique per `put` call. It is the value a
|
|
311
|
+
* concurrent overwrite pins with a compare-and-swap, so each writer can tell
|
|
312
|
+
* whether the row it read is still the row it is replacing, and it is the
|
|
313
|
+
* object id an offloaded value is uploaded under. A fresh UUID is drawn when
|
|
314
|
+
* it is absent.
|
|
315
|
+
*/
|
|
316
|
+
rev?: string;
|
|
354
317
|
}
|
|
355
318
|
/**
|
|
356
319
|
* Encode a value into the DynamoDB record for a stored item.
|
|
@@ -362,44 +325,20 @@ function parseWholeStoreRow(raw) {
|
|
|
362
325
|
* reads back, and an offloaded value's key ends in; absent, a fresh UUID is
|
|
363
326
|
* drawn, before the value is encoded.
|
|
364
327
|
*
|
|
365
|
-
* Returns: the complete row
|
|
366
|
-
*
|
|
328
|
+
* Returns: the complete row. It carries no recency-index keys: no store read
|
|
329
|
+
* uses that index.
|
|
367
330
|
*
|
|
368
331
|
* Throws: `VALIDATION` naming `value` for a value with no JSON
|
|
369
|
-
* representation
|
|
370
|
-
*
|
|
371
|
-
*
|
|
332
|
+
* representation, or `payload` for one too large to store inline without
|
|
333
|
+
* `s3`, or, once offloaded, larger than `s3.maxDownloadBytes`;
|
|
334
|
+
* `S3_OFFLOAD_FAILED` when an offloaded payload cannot be uploaded. Encoding
|
|
335
|
+
* happens before any write, so a value that cannot be stored never
|
|
336
|
+
* half-writes a row.
|
|
372
337
|
*/
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
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
|
-
}
|
|
338
|
+
export declare function buildStoreRow(context: StoreContext, address: {
|
|
339
|
+
namespace: string[];
|
|
340
|
+
key: string;
|
|
341
|
+
}, value: Record<string, JsonValue>, options: BuildRowOptions): Promise<StoreItemRow>;
|
|
403
342
|
/**
|
|
404
343
|
* Decode a DynamoDB record back into a store {@link Item}.
|
|
405
344
|
*
|
|
@@ -417,31 +356,4 @@ async function buildStoreRow(context, address, value, options) {
|
|
|
417
356
|
* including the missing-object error `getItem` resolves against a concurrent
|
|
418
357
|
* overwrite.
|
|
419
358
|
*/
|
|
420
|
-
|
|
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
|
-
}
|
|
359
|
+
export declare function readStoreItem(context: StoreContext, record: StoreItemRow, signal?: AbortSignal): Promise<Item>;
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { nowSeconds } from '../../shared/clock.js';
|
|
3
|
+
import { codecDepsOf, decodePayload, encodePayload, } from '../../shared/codec/codec.js';
|
|
4
|
+
import { withDynamoDBRetry } from '../../shared/dynamodb/retry.js';
|
|
5
|
+
import { ADAPTER_TAGS, assertReadableRow, isExpiredRow, KEY_SEPARATOR, PARTITION_KEY_ATTRIBUTE, ROW_FORMAT_VERSION, SORT_KEY_ATTRIBUTE, } from '../../shared/dynamodb/table-schema.js';
|
|
6
|
+
export const REVISION_ATTRIBUTE = 'rev';
|
|
7
|
+
const ADAPTER_PARTITION_PREFIX = `${ADAPTER_TAGS.store}${KEY_SEPARATOR}`;
|
|
8
|
+
export function storePartitionPrefix() {
|
|
9
|
+
return ADAPTER_PARTITION_PREFIX;
|
|
10
|
+
}
|
|
11
|
+
export function partitionKey(namespace) {
|
|
12
|
+
return `${ADAPTER_PARTITION_PREFIX}${namespace[0]}`;
|
|
13
|
+
}
|
|
14
|
+
export function sortKey(namespace, key) {
|
|
15
|
+
return [...namespace.slice(1), key].join(KEY_SEPARATOR);
|
|
16
|
+
}
|
|
17
|
+
export function sortKeyPrefix(prefix) {
|
|
18
|
+
const rest = prefix.slice(1);
|
|
19
|
+
return rest.length === 0 ? '' : `${rest.join(KEY_SEPARATOR)}${KEY_SEPARATOR}`;
|
|
20
|
+
}
|
|
21
|
+
export function namespaceMatchesPrefix(namespace, prefix) {
|
|
22
|
+
if (prefix.length > namespace.length)
|
|
23
|
+
return false;
|
|
24
|
+
return prefix.every((element, index) => namespace[index] === element);
|
|
25
|
+
}
|
|
26
|
+
export function itemRowKey(address) {
|
|
27
|
+
return { PK: partitionKey(address.namespace), SK: sortKey(address.namespace, address.key) };
|
|
28
|
+
}
|
|
29
|
+
export function scopedQuery(tableName, prefix) {
|
|
30
|
+
const skPrefix = sortKeyPrefix(prefix);
|
|
31
|
+
if (skPrefix.length === 0) {
|
|
32
|
+
return {
|
|
33
|
+
TableName: tableName,
|
|
34
|
+
KeyConditionExpression: '#pk = :pk',
|
|
35
|
+
ExpressionAttributeNames: { '#pk': PARTITION_KEY_ATTRIBUTE },
|
|
36
|
+
ExpressionAttributeValues: { ':pk': partitionKey(prefix) },
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
TableName: tableName,
|
|
41
|
+
KeyConditionExpression: '#pk = :pk AND begins_with(#sk, :skp)',
|
|
42
|
+
ExpressionAttributeNames: { '#pk': PARTITION_KEY_ATTRIBUTE, '#sk': SORT_KEY_ATTRIBUTE },
|
|
43
|
+
ExpressionAttributeValues: { ':pk': partitionKey(prefix), ':skp': skPrefix },
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export function storeScan(tableName) {
|
|
47
|
+
return {
|
|
48
|
+
TableName: tableName,
|
|
49
|
+
FilterExpression: 'begins_with(#pk, :pkp) AND attribute_exists(#ns)',
|
|
50
|
+
ExpressionAttributeNames: { '#pk': PARTITION_KEY_ATTRIBUTE, '#ns': 'namespace' },
|
|
51
|
+
ExpressionAttributeValues: { ':pkp': storePartitionPrefix() },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export function projectKeys(params) {
|
|
55
|
+
return {
|
|
56
|
+
...params,
|
|
57
|
+
ProjectionExpression: `${PARTITION_KEY_ATTRIBUTE}, ${SORT_KEY_ATTRIBUTE}, #ns, #key, #v`,
|
|
58
|
+
ExpressionAttributeNames: {
|
|
59
|
+
...params.ExpressionAttributeNames,
|
|
60
|
+
'#ns': 'namespace',
|
|
61
|
+
'#key': 'key',
|
|
62
|
+
'#v': 'v',
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
export function isLiveRow(existing) {
|
|
67
|
+
return existing.exists && !isExpiredRow(existing, nowSeconds());
|
|
68
|
+
}
|
|
69
|
+
export async function readExisting(context, key) {
|
|
70
|
+
const existing = await withDynamoDBRetry((request) => context.client.get({
|
|
71
|
+
TableName: context.tableName,
|
|
72
|
+
Key: key,
|
|
73
|
+
ConsistentRead: true,
|
|
74
|
+
ProjectionExpression: '#c, #r, #ttl, #v.#loc, #v.#s3k',
|
|
75
|
+
ExpressionAttributeNames: {
|
|
76
|
+
'#c': 'createdAt',
|
|
77
|
+
'#r': REVISION_ATTRIBUTE,
|
|
78
|
+
'#ttl': 'ttl',
|
|
79
|
+
'#v': 'value',
|
|
80
|
+
'#loc': 'location',
|
|
81
|
+
'#s3k': 's3Key',
|
|
82
|
+
},
|
|
83
|
+
}, request), context.retry);
|
|
84
|
+
return existingFrom(existing.Item);
|
|
85
|
+
}
|
|
86
|
+
export function existingFrom(item) {
|
|
87
|
+
return {
|
|
88
|
+
exists: item !== undefined,
|
|
89
|
+
createdAt: item?.createdAt,
|
|
90
|
+
ttl: item?.ttl,
|
|
91
|
+
value: item?.value,
|
|
92
|
+
revision: item?.[REVISION_ATTRIBUTE],
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
export function parseStoreRow(raw) {
|
|
96
|
+
assertReadableRow(raw, 'store item');
|
|
97
|
+
if (!Array.isArray(raw.namespace) || typeof raw.key !== 'string')
|
|
98
|
+
return undefined;
|
|
99
|
+
const record = raw;
|
|
100
|
+
const consistent = record.PK === partitionKey(record.namespace) &&
|
|
101
|
+
record.SK === sortKey(record.namespace, record.key);
|
|
102
|
+
return consistent ? record : undefined;
|
|
103
|
+
}
|
|
104
|
+
export function parseWholeStoreRow(raw) {
|
|
105
|
+
const record = parseStoreRow(raw);
|
|
106
|
+
if (record === undefined)
|
|
107
|
+
return undefined;
|
|
108
|
+
const stamped = typeof record.createdAt === 'string' && typeof record.updatedAt === 'string';
|
|
109
|
+
return stamped ? record : undefined;
|
|
110
|
+
}
|
|
111
|
+
export async function buildStoreRow(context, address, value, options) {
|
|
112
|
+
const { namespace, key } = address;
|
|
113
|
+
const pk = partitionKey(namespace);
|
|
114
|
+
const sk = sortKey(namespace, key);
|
|
115
|
+
const rev = options.rev ?? randomUUID();
|
|
116
|
+
const descriptor = await encodePayload(value, codecDepsOf(context), {
|
|
117
|
+
keyParts: [...namespace, key],
|
|
118
|
+
objectId: rev,
|
|
119
|
+
row: { pk, sk },
|
|
120
|
+
});
|
|
121
|
+
const record = {
|
|
122
|
+
PK: pk,
|
|
123
|
+
SK: sk,
|
|
124
|
+
v: ROW_FORMAT_VERSION,
|
|
125
|
+
namespace,
|
|
126
|
+
key,
|
|
127
|
+
value: descriptor,
|
|
128
|
+
createdAt: options.createdAt,
|
|
129
|
+
updatedAt: options.updatedAt,
|
|
130
|
+
rev,
|
|
131
|
+
};
|
|
132
|
+
if (options.embeddings)
|
|
133
|
+
record.embeddings = options.embeddings;
|
|
134
|
+
if (options.ttlTimestamp !== undefined)
|
|
135
|
+
record.ttl = options.ttlTimestamp;
|
|
136
|
+
return record;
|
|
137
|
+
}
|
|
138
|
+
export async function readStoreItem(context, record, signal) {
|
|
139
|
+
const value = await decodePayload(record.value, codecDepsOf(context, signal), [...record.namespace, record.key]);
|
|
140
|
+
return {
|
|
141
|
+
namespace: record.namespace,
|
|
142
|
+
key: record.key,
|
|
143
|
+
value,
|
|
144
|
+
createdAt: new Date(record.createdAt),
|
|
145
|
+
updatedAt: new Date(record.updatedAt),
|
|
146
|
+
};
|
|
147
|
+
}
|