@farukada/aws-langgraph-dynamodb-ts 1.0.0-rc.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1820 -290
- package/dist/cjs/backfill/backfill.d.ts +171 -0
- package/dist/cjs/backfill/backfill.js +177 -0
- package/dist/cjs/checkpointer/actions/delete-thread.d.ts +50 -0
- package/dist/cjs/checkpointer/actions/delete-thread.js +26 -0
- package/dist/cjs/checkpointer/actions/get-tuple.d.ts +36 -0
- package/dist/cjs/checkpointer/actions/get-tuple.js +22 -0
- package/dist/cjs/checkpointer/actions/list.d.ts +55 -0
- package/dist/cjs/checkpointer/actions/list.js +70 -0
- package/dist/cjs/checkpointer/actions/put-writes.d.ts +49 -0
- package/dist/cjs/checkpointer/actions/put-writes.js +21 -0
- package/dist/cjs/checkpointer/actions/put.d.ts +95 -0
- package/dist/cjs/checkpointer/actions/put.js +79 -0
- package/dist/cjs/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/cjs/checkpointer/internal/delta-history.js +131 -0
- package/dist/cjs/checkpointer/internal/listing.d.ts +149 -0
- package/dist/cjs/checkpointer/internal/listing.js +104 -0
- package/dist/cjs/checkpointer/internal/parse.d.ts +298 -0
- package/dist/cjs/checkpointer/internal/parse.js +184 -0
- package/dist/cjs/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/cjs/checkpointer/internal/pending-writes.js +241 -0
- package/dist/cjs/checkpointer/internal/read.d.ts +135 -0
- package/dist/cjs/checkpointer/internal/read.js +132 -0
- package/dist/cjs/checkpointer/internal/rows.d.ts +644 -0
- package/dist/cjs/checkpointer/internal/rows.js +356 -0
- package/dist/cjs/checkpointer/internal/setup.d.ts +47 -0
- package/dist/cjs/checkpointer/internal/setup.js +25 -0
- package/dist/cjs/checkpointer/saver.d.ts +306 -0
- package/dist/cjs/checkpointer/saver.js +56 -0
- package/dist/cjs/checkpointer/types.d.ts +51 -0
- package/dist/cjs/factory/factory.d.ts +154 -0
- package/dist/cjs/factory/factory.js +137 -0
- package/dist/{factory → cjs/factory}/types.d.ts +33 -14
- package/dist/cjs/history/actions/add-messages.d.ts +51 -0
- package/dist/cjs/history/actions/add-messages.js +17 -0
- package/dist/cjs/history/actions/clear.d.ts +52 -0
- package/dist/cjs/history/actions/clear.js +29 -0
- package/dist/cjs/history/actions/get-messages.d.ts +60 -0
- package/dist/cjs/history/actions/get-messages.js +58 -0
- package/dist/cjs/history/actions/list-sessions.d.ts +55 -0
- package/dist/cjs/history/actions/list-sessions.js +67 -0
- package/dist/cjs/history/actions/reconcile-count.d.ts +49 -0
- package/dist/cjs/history/actions/reconcile-count.js +8 -0
- package/dist/cjs/history/chat-message-history.d.ts +267 -0
- package/dist/cjs/history/chat-message-history.js +61 -0
- package/dist/cjs/history/internal/append.d.ts +244 -0
- package/dist/cjs/history/internal/append.js +267 -0
- package/dist/cjs/history/internal/message-read.d.ts +84 -0
- package/dist/cjs/history/internal/message-read.js +93 -0
- package/dist/cjs/history/internal/parse.d.ts +153 -0
- package/dist/cjs/history/internal/parse.js +113 -0
- package/dist/cjs/history/internal/rows.d.ts +196 -0
- package/dist/cjs/history/internal/rows.js +96 -0
- package/dist/cjs/history/internal/session.d.ts +350 -0
- package/dist/cjs/history/internal/session.js +296 -0
- package/dist/cjs/history/internal/setup.d.ts +64 -0
- package/dist/cjs/history/internal/setup.js +60 -0
- package/dist/cjs/history/session-adapter.d.ts +112 -0
- package/dist/cjs/history/session-adapter.js +38 -0
- package/dist/cjs/history/types.d.ts +102 -0
- package/dist/cjs/index.d.ts +53 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/shared/adapter.d.ts +146 -0
- package/dist/cjs/shared/adapter.js +70 -0
- package/dist/cjs/shared/clock.d.ts +52 -0
- package/dist/cjs/shared/clock.js +14 -0
- package/dist/cjs/shared/codec/codec.d.ts +336 -0
- package/dist/cjs/shared/codec/codec.js +162 -0
- package/dist/cjs/shared/codec/compression.d.ts +66 -0
- package/dist/cjs/shared/codec/compression.js +45 -0
- package/dist/cjs/shared/codec/json-serde.d.ts +80 -0
- package/dist/cjs/shared/codec/json-serde.js +58 -0
- package/dist/{shared → cjs/shared}/codec/s3/client-types.d.ts +22 -2
- package/dist/{shared → cjs/shared}/codec/s3/client-types.js +0 -1
- package/dist/cjs/shared/codec/s3/client.d.ts +63 -0
- package/dist/cjs/shared/codec/s3/client.js +78 -0
- package/dist/cjs/shared/codec/s3/config.d.ts +260 -0
- package/dist/cjs/shared/codec/s3/config.js +92 -0
- package/dist/cjs/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/cjs/shared/codec/s3/lifecycle.js +223 -0
- package/dist/cjs/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/cjs/shared/codec/s3/offloader.js +289 -0
- package/dist/cjs/shared/concurrency.d.ts +43 -0
- package/dist/{shared → cjs/shared}/concurrency.js +10 -9
- package/dist/cjs/shared/dynamodb/abort.d.ts +47 -0
- package/dist/cjs/shared/dynamodb/abort.js +16 -0
- package/dist/cjs/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/cjs/shared/dynamodb/batch-write.js +79 -0
- package/dist/cjs/shared/dynamodb/cancellation.d.ts +124 -0
- package/dist/cjs/shared/dynamodb/cancellation.js +37 -0
- package/dist/cjs/shared/dynamodb/client.d.ts +177 -0
- package/dist/{shared → cjs/shared}/dynamodb/client.js +12 -14
- package/dist/cjs/shared/dynamodb/idempotent-write.d.ts +596 -0
- package/dist/cjs/shared/dynamodb/idempotent-write.js +173 -0
- package/dist/cjs/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/cjs/shared/dynamodb/paginate.js +90 -0
- package/dist/cjs/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/cjs/shared/dynamodb/partition-delete.js +177 -0
- package/dist/cjs/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/cjs/shared/dynamodb/recency-index.js +146 -0
- package/dist/cjs/shared/dynamodb/retry.d.ts +317 -0
- package/dist/cjs/shared/dynamodb/retry.js +193 -0
- package/dist/cjs/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/cjs/shared/dynamodb/row-size.js +30 -0
- package/dist/cjs/shared/dynamodb/table-schema.d.ts +199 -0
- package/dist/cjs/shared/dynamodb/table-schema.js +52 -0
- package/dist/cjs/shared/errors/base-error.d.ts +231 -0
- package/dist/cjs/shared/errors/base-error.js +73 -0
- package/dist/cjs/shared/errors/boundary.d.ts +86 -0
- package/dist/cjs/shared/errors/boundary.js +61 -0
- package/dist/cjs/shared/errors/classify.d.ts +206 -0
- package/dist/cjs/shared/errors/classify.js +232 -0
- package/dist/cjs/shared/errors/error-code.d.ts +95 -0
- package/dist/{shared → cjs/shared}/errors/error-code.js +12 -2
- package/dist/cjs/shared/errors/errors.d.ts +233 -0
- package/dist/cjs/shared/errors/errors.js +123 -0
- package/dist/cjs/shared/logging/logger.d.ts +80 -0
- package/dist/cjs/shared/logging/logger.js +30 -0
- package/dist/cjs/shared/logging/redaction.d.ts +123 -0
- package/dist/cjs/shared/logging/redaction.js +145 -0
- package/dist/cjs/shared/logging/secret-patterns.d.ts +227 -0
- package/dist/cjs/shared/logging/secret-patterns.js +93 -0
- package/dist/cjs/shared/logging/truncate.d.ts +197 -0
- package/dist/cjs/shared/logging/truncate.js +31 -0
- package/dist/cjs/shared/options.d.ts +100 -0
- package/dist/cjs/shared/ulid.d.ts +80 -0
- package/dist/{shared → cjs/shared}/ulid.js +7 -21
- package/dist/cjs/shared/validation/collaborators.d.ts +160 -0
- package/dist/cjs/shared/validation/collaborators.js +79 -0
- package/dist/cjs/shared/validation/option-shape.d.ts +91 -0
- package/dist/cjs/shared/validation/option-shape.js +31 -0
- package/dist/cjs/shared/validation/options.d.ts +145 -0
- package/dist/cjs/shared/validation/options.js +166 -0
- package/dist/cjs/shared/validation/primitives.d.ts +292 -0
- package/dist/cjs/shared/validation/primitives.js +114 -0
- package/dist/cjs/shared/validation/ttl.d.ts +94 -0
- package/dist/cjs/shared/validation/ttl.js +52 -0
- package/dist/cjs/store/actions/list-namespaces.d.ts +79 -0
- package/dist/cjs/store/actions/list-namespaces.js +92 -0
- package/dist/cjs/store/actions/put.d.ts +43 -0
- package/dist/cjs/store/actions/put.js +49 -0
- package/dist/cjs/store/actions/reconcile-vector-index.d.ts +38 -0
- package/dist/cjs/store/actions/reconcile-vector-index.js +13 -0
- package/dist/cjs/store/actions/search.d.ts +38 -0
- package/dist/cjs/store/actions/search.js +26 -0
- package/dist/cjs/store/internal/batch-plan.d.ts +56 -0
- package/dist/cjs/store/internal/batch-plan.js +32 -0
- package/dist/cjs/store/internal/filter.d.ts +43 -0
- package/dist/cjs/store/internal/filter.js +64 -0
- package/dist/cjs/store/internal/get-item.d.ts +77 -0
- package/dist/cjs/store/internal/get-item.js +58 -0
- package/dist/cjs/store/internal/item-write.d.ts +270 -0
- package/dist/cjs/store/internal/item-write.js +181 -0
- package/dist/cjs/store/internal/parse.d.ts +230 -0
- package/dist/cjs/store/internal/parse.js +180 -0
- package/dist/cjs/store/internal/rows.d.ts +359 -0
- package/dist/cjs/store/internal/rows.js +166 -0
- package/dist/cjs/store/internal/semantic-search.d.ts +168 -0
- package/dist/{store/internal/text-path.js → cjs/store/internal/semantic-search.js} +92 -28
- package/dist/cjs/store/internal/setup.d.ts +96 -0
- package/dist/cjs/store/internal/setup.js +103 -0
- package/dist/cjs/store/internal/table-search.d.ts +100 -0
- package/dist/cjs/store/internal/table-search.js +123 -0
- package/dist/cjs/store/internal/vector-index.d.ts +258 -0
- package/dist/cjs/store/internal/vector-index.js +269 -0
- package/dist/cjs/store/store.d.ts +329 -0
- package/dist/cjs/store/store.js +97 -0
- package/dist/cjs/store/types.d.ts +111 -0
- package/dist/cjs/store/vector-backend.d.ts +104 -0
- package/dist/cjs/store/vector-backend.js +4 -0
- package/dist/esm/backfill/backfill.d.ts +171 -0
- package/dist/esm/backfill/backfill.js +170 -0
- package/dist/esm/checkpointer/actions/delete-thread.d.ts +50 -0
- package/dist/esm/checkpointer/actions/delete-thread.js +23 -0
- package/dist/esm/checkpointer/actions/get-tuple.d.ts +36 -0
- package/dist/esm/checkpointer/actions/get-tuple.js +19 -0
- package/dist/esm/checkpointer/actions/list.d.ts +55 -0
- package/dist/esm/checkpointer/actions/list.js +67 -0
- package/dist/esm/checkpointer/actions/put-writes.d.ts +49 -0
- package/dist/esm/checkpointer/actions/put-writes.js +18 -0
- package/dist/esm/checkpointer/actions/put.d.ts +95 -0
- package/dist/esm/checkpointer/actions/put.js +75 -0
- package/dist/esm/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/esm/checkpointer/internal/delta-history.js +126 -0
- package/dist/esm/checkpointer/internal/listing.d.ts +149 -0
- package/dist/esm/checkpointer/internal/listing.js +95 -0
- package/dist/esm/checkpointer/internal/parse.d.ts +298 -0
- package/dist/esm/checkpointer/internal/parse.js +169 -0
- package/dist/esm/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/esm/checkpointer/internal/pending-writes.js +229 -0
- package/dist/esm/checkpointer/internal/read.d.ts +135 -0
- package/dist/esm/checkpointer/internal/read.js +125 -0
- package/dist/esm/checkpointer/internal/rows.d.ts +644 -0
- package/dist/esm/checkpointer/internal/rows.js +323 -0
- package/dist/esm/checkpointer/internal/setup.d.ts +47 -0
- package/dist/esm/checkpointer/internal/setup.js +21 -0
- package/dist/esm/checkpointer/saver.d.ts +306 -0
- package/dist/esm/checkpointer/saver.js +52 -0
- package/dist/esm/checkpointer/types.d.ts +51 -0
- package/dist/esm/checkpointer/types.js +1 -0
- package/dist/esm/factory/factory.d.ts +154 -0
- package/dist/esm/factory/factory.js +133 -0
- package/dist/esm/factory/types.d.ts +76 -0
- package/dist/esm/factory/types.js +1 -0
- package/dist/esm/history/actions/add-messages.d.ts +51 -0
- package/dist/esm/history/actions/add-messages.js +14 -0
- package/dist/esm/history/actions/clear.d.ts +52 -0
- package/dist/esm/history/actions/clear.js +26 -0
- package/dist/esm/history/actions/get-messages.d.ts +60 -0
- package/dist/esm/history/actions/get-messages.js +55 -0
- package/dist/esm/history/actions/list-sessions.d.ts +55 -0
- package/dist/esm/history/actions/list-sessions.js +64 -0
- package/dist/esm/history/actions/reconcile-count.d.ts +49 -0
- package/dist/esm/history/actions/reconcile-count.js +5 -0
- package/dist/esm/history/chat-message-history.d.ts +267 -0
- package/dist/esm/history/chat-message-history.js +57 -0
- package/dist/esm/history/internal/append.d.ts +244 -0
- package/dist/esm/history/internal/append.js +259 -0
- package/dist/esm/history/internal/message-read.d.ts +84 -0
- package/dist/esm/history/internal/message-read.js +89 -0
- package/dist/esm/history/internal/parse.d.ts +153 -0
- package/dist/esm/history/internal/parse.js +105 -0
- package/dist/esm/history/internal/rows.d.ts +196 -0
- package/dist/esm/history/internal/rows.js +83 -0
- package/dist/esm/history/internal/session.d.ts +350 -0
- package/dist/esm/history/internal/session.js +285 -0
- package/dist/esm/history/internal/setup.d.ts +64 -0
- package/dist/esm/history/internal/setup.js +56 -0
- package/dist/esm/history/session-adapter.d.ts +112 -0
- package/dist/esm/history/session-adapter.js +34 -0
- package/dist/esm/history/types.d.ts +102 -0
- package/dist/esm/history/types.js +1 -0
- package/dist/esm/index.d.ts +53 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/shared/adapter.d.ts +146 -0
- package/dist/esm/shared/adapter.js +65 -0
- package/dist/esm/shared/clock.d.ts +52 -0
- package/dist/esm/shared/clock.js +9 -0
- package/dist/esm/shared/codec/codec.d.ts +336 -0
- package/dist/esm/shared/codec/codec.js +150 -0
- package/dist/esm/shared/codec/compression.d.ts +66 -0
- package/dist/esm/shared/codec/compression.js +40 -0
- package/dist/esm/shared/codec/json-serde.d.ts +80 -0
- package/dist/esm/shared/codec/json-serde.js +54 -0
- package/dist/esm/shared/codec/s3/client-types.d.ts +54 -0
- package/dist/esm/shared/codec/s3/client-types.js +3 -0
- package/dist/esm/shared/codec/s3/client.d.ts +63 -0
- package/dist/esm/shared/codec/s3/client.js +40 -0
- package/dist/esm/shared/codec/s3/config.d.ts +260 -0
- package/dist/esm/shared/codec/s3/config.js +79 -0
- package/dist/esm/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/esm/shared/codec/s3/lifecycle.js +214 -0
- package/dist/esm/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/esm/shared/codec/s3/offloader.js +278 -0
- package/dist/esm/shared/concurrency.d.ts +43 -0
- package/dist/esm/shared/concurrency.js +27 -0
- package/dist/esm/shared/dynamodb/abort.d.ts +47 -0
- package/dist/esm/shared/dynamodb/abort.js +12 -0
- package/dist/esm/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/esm/shared/dynamodb/batch-write.js +74 -0
- package/dist/esm/shared/dynamodb/cancellation.d.ts +124 -0
- package/dist/esm/shared/dynamodb/cancellation.js +30 -0
- package/dist/esm/shared/dynamodb/client.d.ts +177 -0
- package/dist/esm/shared/dynamodb/client.js +35 -0
- package/dist/esm/shared/dynamodb/idempotent-write.d.ts +596 -0
- package/dist/esm/shared/dynamodb/idempotent-write.js +153 -0
- package/dist/esm/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/esm/shared/dynamodb/paginate.js +84 -0
- package/dist/esm/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/esm/shared/dynamodb/partition-delete.js +171 -0
- package/dist/esm/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/esm/shared/dynamodb/recency-index.js +136 -0
- package/dist/esm/shared/dynamodb/retry.d.ts +317 -0
- package/dist/esm/shared/dynamodb/retry.js +180 -0
- package/dist/esm/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/esm/shared/dynamodb/row-size.js +26 -0
- package/dist/esm/shared/dynamodb/table-schema.d.ts +199 -0
- package/dist/esm/shared/dynamodb/table-schema.js +43 -0
- package/dist/esm/shared/errors/base-error.d.ts +231 -0
- package/dist/esm/shared/errors/base-error.js +64 -0
- package/dist/esm/shared/errors/boundary.d.ts +86 -0
- package/dist/esm/shared/errors/boundary.js +54 -0
- package/dist/esm/shared/errors/classify.d.ts +206 -0
- package/dist/esm/shared/errors/classify.js +220 -0
- package/dist/esm/shared/errors/error-code.d.ts +95 -0
- package/dist/esm/shared/errors/error-code.js +24 -0
- package/dist/esm/shared/errors/errors.d.ts +233 -0
- package/dist/esm/shared/errors/errors.js +110 -0
- package/dist/esm/shared/logging/logger.d.ts +80 -0
- package/dist/esm/shared/logging/logger.js +25 -0
- package/dist/esm/shared/logging/redaction.d.ts +123 -0
- package/dist/esm/shared/logging/redaction.js +140 -0
- package/dist/esm/shared/logging/secret-patterns.d.ts +227 -0
- package/dist/esm/shared/logging/secret-patterns.js +83 -0
- package/dist/esm/shared/logging/truncate.d.ts +197 -0
- package/dist/esm/shared/logging/truncate.js +25 -0
- package/dist/esm/shared/options.d.ts +100 -0
- package/dist/esm/shared/options.js +1 -0
- package/dist/esm/shared/ulid.d.ts +80 -0
- package/dist/esm/shared/ulid.js +77 -0
- package/dist/esm/shared/validation/collaborators.d.ts +160 -0
- package/dist/esm/shared/validation/collaborators.js +70 -0
- package/dist/esm/shared/validation/option-shape.d.ts +91 -0
- package/dist/esm/shared/validation/option-shape.js +24 -0
- package/dist/esm/shared/validation/options.d.ts +145 -0
- package/dist/esm/shared/validation/options.js +156 -0
- package/dist/esm/shared/validation/primitives.d.ts +292 -0
- package/dist/esm/shared/validation/primitives.js +100 -0
- package/dist/esm/shared/validation/ttl.d.ts +94 -0
- package/dist/esm/shared/validation/ttl.js +46 -0
- package/dist/esm/store/actions/list-namespaces.d.ts +79 -0
- package/dist/esm/store/actions/list-namespaces.js +86 -0
- package/dist/esm/store/actions/put.d.ts +43 -0
- package/dist/esm/store/actions/put.js +46 -0
- package/dist/esm/store/actions/reconcile-vector-index.d.ts +38 -0
- package/dist/esm/store/actions/reconcile-vector-index.js +10 -0
- package/dist/esm/store/actions/search.d.ts +38 -0
- package/dist/esm/store/actions/search.js +23 -0
- package/dist/esm/store/internal/batch-plan.d.ts +56 -0
- package/dist/esm/store/internal/batch-plan.js +28 -0
- package/dist/esm/store/internal/filter.d.ts +43 -0
- package/dist/esm/store/internal/filter.js +60 -0
- package/dist/esm/store/internal/get-item.d.ts +77 -0
- package/dist/esm/store/internal/get-item.js +54 -0
- package/dist/esm/store/internal/item-write.d.ts +270 -0
- package/dist/esm/store/internal/item-write.js +173 -0
- package/dist/esm/store/internal/parse.d.ts +230 -0
- package/dist/esm/store/internal/parse.js +169 -0
- package/dist/esm/store/internal/rows.d.ts +359 -0
- package/dist/esm/store/internal/rows.js +147 -0
- package/dist/esm/store/internal/semantic-search.d.ts +168 -0
- package/dist/esm/store/internal/semantic-search.js +200 -0
- package/dist/esm/store/internal/setup.d.ts +96 -0
- package/dist/esm/store/internal/setup.js +98 -0
- package/dist/esm/store/internal/table-search.d.ts +100 -0
- package/dist/esm/store/internal/table-search.js +119 -0
- package/dist/esm/store/internal/vector-index.d.ts +258 -0
- package/dist/esm/store/internal/vector-index.js +256 -0
- package/dist/esm/store/store.d.ts +329 -0
- package/dist/esm/store/store.js +93 -0
- package/dist/esm/store/types.d.ts +111 -0
- package/dist/esm/store/types.js +1 -0
- package/dist/esm/store/vector-backend.d.ts +104 -0
- package/dist/esm/store/vector-backend.js +1 -0
- package/package.json +68 -46
- package/dist/checkpointer/actions/delete-thread.d.ts +0 -10
- package/dist/checkpointer/actions/delete-thread.js +0 -38
- package/dist/checkpointer/actions/get-tuple.d.ts +0 -11
- package/dist/checkpointer/actions/get-tuple.js +0 -25
- package/dist/checkpointer/actions/list.d.ts +0 -20
- package/dist/checkpointer/actions/list.js +0 -113
- package/dist/checkpointer/actions/put-writes.d.ts +0 -15
- package/dist/checkpointer/actions/put-writes.js +0 -62
- package/dist/checkpointer/actions/put.d.ts +0 -17
- package/dist/checkpointer/actions/put.js +0 -73
- package/dist/checkpointer/internal/assemble.d.ts +0 -17
- package/dist/checkpointer/internal/assemble.js +0 -38
- package/dist/checkpointer/internal/checkpoint-write-verify.d.ts +0 -24
- package/dist/checkpointer/internal/checkpoint-write-verify.js +0 -67
- package/dist/checkpointer/internal/configurable.d.ts +0 -12
- package/dist/checkpointer/internal/configurable.js +0 -24
- package/dist/checkpointer/internal/fetch.d.ts +0 -19
- package/dist/checkpointer/internal/fetch.js +0 -88
- package/dist/checkpointer/internal/filter-match.d.ts +0 -13
- package/dist/checkpointer/internal/filter-match.js +0 -15
- package/dist/checkpointer/internal/item-reader.d.ts +0 -66
- package/dist/checkpointer/internal/item-reader.js +0 -113
- package/dist/checkpointer/internal/item-writer.d.ts +0 -35
- package/dist/checkpointer/internal/item-writer.js +0 -107
- package/dist/checkpointer/internal/keys.d.ts +0 -41
- package/dist/checkpointer/internal/keys.js +0 -117
- package/dist/checkpointer/internal/list-scope.d.ts +0 -61
- package/dist/checkpointer/internal/list-scope.js +0 -108
- package/dist/checkpointer/internal/pending-sends.d.ts +0 -13
- package/dist/checkpointer/internal/pending-sends.js +0 -29
- package/dist/checkpointer/internal/query.d.ts +0 -21
- package/dist/checkpointer/internal/query.js +0 -42
- package/dist/checkpointer/internal/regular-write.d.ts +0 -28
- package/dist/checkpointer/internal/regular-write.js +0 -66
- package/dist/checkpointer/internal/setup.d.ts +0 -33
- package/dist/checkpointer/internal/setup.js +0 -38
- package/dist/checkpointer/internal/special-write-cas.d.ts +0 -29
- package/dist/checkpointer/internal/special-write-cas.js +0 -104
- package/dist/checkpointer/internal/special-write-cleanup.d.ts +0 -23
- package/dist/checkpointer/internal/special-write-cleanup.js +0 -50
- package/dist/checkpointer/internal/special-write-verify.d.ts +0 -53
- package/dist/checkpointer/internal/special-write-verify.js +0 -80
- package/dist/checkpointer/internal/stored-channels.d.ts +0 -31
- package/dist/checkpointer/internal/stored-channels.js +0 -70
- package/dist/checkpointer/internal/validation.d.ts +0 -18
- package/dist/checkpointer/internal/validation.js +0 -40
- package/dist/checkpointer/internal/write-guard.d.ts +0 -20
- package/dist/checkpointer/internal/write-guard.js +0 -48
- package/dist/checkpointer/internal/write-index.d.ts +0 -36
- package/dist/checkpointer/internal/write-index.js +0 -41
- package/dist/checkpointer/saver.d.ts +0 -70
- package/dist/checkpointer/saver.js +0 -105
- package/dist/checkpointer/types.d.ts +0 -58
- package/dist/factory/factory.d.ts +0 -40
- package/dist/factory/factory.js +0 -87
- package/dist/history/actions/add-messages.d.ts +0 -15
- package/dist/history/actions/add-messages.js +0 -77
- package/dist/history/actions/clear.d.ts +0 -10
- package/dist/history/actions/clear.js +0 -34
- package/dist/history/actions/get-messages.d.ts +0 -17
- package/dist/history/actions/get-messages.js +0 -79
- package/dist/history/actions/list-sessions.d.ts +0 -13
- package/dist/history/actions/list-sessions.js +0 -53
- package/dist/history/actions/reconcile-count.d.ts +0 -12
- package/dist/history/actions/reconcile-count.js +0 -64
- package/dist/history/chat-message-history.d.ts +0 -73
- package/dist/history/chat-message-history.js +0 -111
- package/dist/history/internal/append-saga.d.ts +0 -25
- package/dist/history/internal/append-saga.js +0 -79
- package/dist/history/internal/compensation.d.ts +0 -25
- package/dist/history/internal/compensation.js +0 -92
- package/dist/history/internal/item-mapper.d.ts +0 -9
- package/dist/history/internal/item-mapper.js +0 -27
- package/dist/history/internal/keys.d.ts +0 -16
- package/dist/history/internal/keys.js +0 -48
- package/dist/history/internal/message-chunker.d.ts +0 -13
- package/dist/history/internal/message-chunker.js +0 -67
- package/dist/history/internal/message-transaction.d.ts +0 -25
- package/dist/history/internal/message-transaction.js +0 -61
- package/dist/history/internal/message-window.d.ts +0 -17
- package/dist/history/internal/message-window.js +0 -49
- package/dist/history/internal/query.d.ts +0 -23
- package/dist/history/internal/query.js +0 -39
- package/dist/history/internal/session-count.d.ts +0 -47
- package/dist/history/internal/session-count.js +0 -115
- package/dist/history/internal/session-title.d.ts +0 -19
- package/dist/history/internal/session-title.js +0 -43
- package/dist/history/internal/session-update.d.ts +0 -27
- package/dist/history/internal/session-update.js +0 -69
- package/dist/history/internal/setup.d.ts +0 -31
- package/dist/history/internal/setup.js +0 -43
- package/dist/history/internal/title-generator.d.ts +0 -12
- package/dist/history/internal/title-generator.js +0 -41
- package/dist/history/internal/ttl-anchor.d.ts +0 -24
- package/dist/history/internal/ttl-anchor.js +0 -38
- package/dist/history/internal/validation.d.ts +0 -25
- package/dist/history/internal/validation.js +0 -53
- package/dist/history/session-adapter.d.ts +0 -29
- package/dist/history/session-adapter.js +0 -35
- package/dist/history/types.d.ts +0 -69
- package/dist/index.d.ts +0 -29
- package/dist/index.js +0 -32
- package/dist/shared/clock.d.ts +0 -8
- package/dist/shared/clock.js +0 -16
- package/dist/shared/codec/codec.d.ts +0 -53
- package/dist/shared/codec/codec.js +0 -66
- package/dist/shared/codec/compression.d.ts +0 -24
- package/dist/shared/codec/compression.js +0 -48
- package/dist/shared/codec/descriptor-keys.d.ts +0 -12
- package/dist/shared/codec/descriptor-keys.js +0 -14
- package/dist/shared/codec/encode.d.ts +0 -13
- package/dist/shared/codec/encode.js +0 -43
- package/dist/shared/codec/json-serde.d.ts +0 -7
- package/dist/shared/codec/json-serde.js +0 -17
- package/dist/shared/codec/payload-loss.d.ts +0 -12
- package/dist/shared/codec/payload-loss.js +0 -38
- package/dist/shared/codec/s3/adapter-config.d.ts +0 -13
- package/dist/shared/codec/s3/adapter-config.js +0 -22
- package/dist/shared/codec/s3/bounded-body.d.ts +0 -14
- package/dist/shared/codec/s3/bounded-body.js +0 -47
- package/dist/shared/codec/s3/client.d.ts +0 -18
- package/dist/shared/codec/s3/client.js +0 -46
- package/dist/shared/codec/s3/config.d.ts +0 -51
- package/dist/shared/codec/s3/config.js +0 -58
- package/dist/shared/codec/s3/delete.d.ts +0 -7
- package/dist/shared/codec/s3/delete.js +0 -28
- package/dist/shared/codec/s3/key-scope.d.ts +0 -23
- package/dist/shared/codec/s3/key-scope.js +0 -44
- package/dist/shared/codec/s3/lifecycle.d.ts +0 -14
- package/dist/shared/codec/s3/lifecycle.js +0 -63
- package/dist/shared/codec/s3/offloader.d.ts +0 -44
- package/dist/shared/codec/s3/offloader.js +0 -118
- package/dist/shared/codec/s3/orphans.d.ts +0 -23
- package/dist/shared/codec/s3/orphans.js +0 -71
- package/dist/shared/codec/s3/read-write.d.ts +0 -18
- package/dist/shared/codec/s3/read-write.js +0 -51
- package/dist/shared/codec/s3/retry.d.ts +0 -5
- package/dist/shared/codec/s3/retry.js +0 -22
- package/dist/shared/concurrency.d.ts +0 -6
- package/dist/shared/constants.d.ts +0 -112
- package/dist/shared/constants.js +0 -115
- package/dist/shared/dynamodb/abort.d.ts +0 -9
- package/dist/shared/dynamodb/abort.js +0 -27
- package/dist/shared/dynamodb/backoff.d.ts +0 -15
- package/dist/shared/dynamodb/backoff.js +0 -48
- package/dist/shared/dynamodb/batch-write.d.ts +0 -22
- package/dist/shared/dynamodb/batch-write.js +0 -53
- package/dist/shared/dynamodb/cancellation.d.ts +0 -6
- package/dist/shared/dynamodb/cancellation.js +0 -7
- package/dist/shared/dynamodb/client.d.ts +0 -28
- package/dist/shared/dynamodb/conditional-put.d.ts +0 -67
- package/dist/shared/dynamodb/conditional-put.js +0 -76
- package/dist/shared/dynamodb/drain-unprocessed.d.ts +0 -21
- package/dist/shared/dynamodb/drain-unprocessed.js +0 -43
- package/dist/shared/dynamodb/expiry.d.ts +0 -16
- package/dist/shared/dynamodb/expiry.js +0 -29
- package/dist/shared/dynamodb/paginate-core.d.ts +0 -24
- package/dist/shared/dynamodb/paginate-core.js +0 -82
- package/dist/shared/dynamodb/paginate.d.ts +0 -14
- package/dist/shared/dynamodb/paginate.js +0 -19
- package/dist/shared/dynamodb/partition-delete.d.ts +0 -39
- package/dist/shared/dynamodb/partition-delete.js +0 -71
- package/dist/shared/dynamodb/retry-classifier.d.ts +0 -17
- package/dist/shared/dynamodb/retry-classifier.js +0 -118
- package/dist/shared/dynamodb/retry-policy.d.ts +0 -26
- package/dist/shared/dynamodb/retry-policy.js +0 -22
- package/dist/shared/dynamodb/retry.d.ts +0 -31
- package/dist/shared/dynamodb/retry.js +0 -57
- package/dist/shared/dynamodb/scan.d.ts +0 -14
- package/dist/shared/dynamodb/scan.js +0 -19
- package/dist/shared/dynamodb/types.d.ts +0 -23
- package/dist/shared/errors/base-error.d.ts +0 -30
- package/dist/shared/errors/base-error.js +0 -27
- package/dist/shared/errors/boundary.d.ts +0 -18
- package/dist/shared/errors/boundary.js +0 -46
- package/dist/shared/errors/error-code.d.ts +0 -13
- package/dist/shared/errors/errors.d.ts +0 -68
- package/dist/shared/errors/errors.js +0 -114
- package/dist/shared/errors/upstream-error.d.ts +0 -16
- package/dist/shared/errors/upstream-error.js +0 -27
- package/dist/shared/errors/wrap-error.d.ts +0 -7
- package/dist/shared/errors/wrap-error.js +0 -15
- package/dist/shared/logging/logger.d.ts +0 -18
- package/dist/shared/logging/logger.js +0 -15
- package/dist/shared/logging/redaction-walk.d.ts +0 -23
- package/dist/shared/logging/redaction-walk.js +0 -112
- package/dist/shared/logging/redaction.d.ts +0 -39
- package/dist/shared/logging/redaction.js +0 -75
- package/dist/shared/logging/secret-patterns.d.ts +0 -92
- package/dist/shared/logging/secret-patterns.js +0 -133
- package/dist/shared/options.d.ts +0 -37
- package/dist/shared/ulid.d.ts +0 -23
- package/dist/shared/validation/options.d.ts +0 -8
- package/dist/shared/validation/options.js +0 -90
- package/dist/shared/validation/primitives.d.ts +0 -29
- package/dist/shared/validation/primitives.js +0 -82
- package/dist/shared/validation/ttl.d.ts +0 -28
- package/dist/shared/validation/ttl.js +0 -52
- package/dist/store/actions/get.d.ts +0 -13
- package/dist/store/actions/get.js +0 -73
- package/dist/store/actions/list-namespaces.d.ts +0 -8
- package/dist/store/actions/list-namespaces.js +0 -59
- package/dist/store/actions/put.d.ts +0 -10
- package/dist/store/actions/put.js +0 -96
- package/dist/store/actions/reconcile-vector-index.d.ts +0 -18
- package/dist/store/actions/reconcile-vector-index.js +0 -26
- package/dist/store/actions/search.d.ts +0 -9
- package/dist/store/actions/search.js +0 -34
- package/dist/store/internal/backend-search.d.ts +0 -4
- package/dist/store/internal/backend-search.js +0 -74
- package/dist/store/internal/batch-plan.d.ts +0 -11
- package/dist/store/internal/batch-plan.js +0 -52
- package/dist/store/internal/candidates.d.ts +0 -23
- package/dist/store/internal/candidates.js +0 -94
- package/dist/store/internal/filter.d.ts +0 -9
- package/dist/store/internal/filter.js +0 -85
- package/dist/store/internal/index-reconcile.d.ts +0 -21
- package/dist/store/internal/index-reconcile.js +0 -118
- package/dist/store/internal/index-sync.d.ts +0 -10
- package/dist/store/internal/index-sync.js +0 -25
- package/dist/store/internal/item-mapper.d.ts +0 -27
- package/dist/store/internal/item-mapper.js +0 -61
- package/dist/store/internal/keys.d.ts +0 -17
- package/dist/store/internal/keys.js +0 -41
- package/dist/store/internal/namespace-match.d.ts +0 -11
- package/dist/store/internal/namespace-match.js +0 -40
- package/dist/store/internal/option-validation.d.ts +0 -13
- package/dist/store/internal/option-validation.js +0 -77
- package/dist/store/internal/overwrite-swap.d.ts +0 -32
- package/dist/store/internal/overwrite-swap.js +0 -68
- package/dist/store/internal/persist.d.ts +0 -28
- package/dist/store/internal/persist.js +0 -64
- package/dist/store/internal/query.d.ts +0 -11
- package/dist/store/internal/query.js +0 -48
- package/dist/store/internal/ranker.d.ts +0 -18
- package/dist/store/internal/ranker.js +0 -39
- package/dist/store/internal/read-existing.d.ts +0 -23
- package/dist/store/internal/read-existing.js +0 -41
- package/dist/store/internal/score-direction.d.ts +0 -31
- package/dist/store/internal/score-direction.js +0 -38
- package/dist/store/internal/search-filter.d.ts +0 -3
- package/dist/store/internal/search-filter.js +0 -10
- package/dist/store/internal/semantic-search.d.ts +0 -34
- package/dist/store/internal/semantic-search.js +0 -87
- package/dist/store/internal/setup.d.ts +0 -36
- package/dist/store/internal/setup.js +0 -40
- package/dist/store/internal/text-path.d.ts +0 -17
- package/dist/store/internal/validation.d.ts +0 -18
- package/dist/store/internal/validation.js +0 -51
- package/dist/store/internal/write-verify.d.ts +0 -42
- package/dist/store/internal/write-verify.js +0 -71
- package/dist/store/store.d.ts +0 -61
- package/dist/store/store.js +0 -107
- package/dist/store/types.d.ts +0 -50
- package/dist/store/types.js +0 -2
- package/dist/store/vector-backend.d.ts +0 -43
- package/dist/store/vector-backend.js +0 -2
- /package/dist/{checkpointer → cjs/checkpointer}/types.js +0 -0
- /package/dist/{factory → cjs/factory}/types.js +0 -0
- /package/dist/{history → cjs/history}/types.js +0 -0
- /package/dist/{shared → cjs/shared}/options.js +0 -0
- /package/dist/{shared/dynamodb → cjs/store}/types.js +0 -0
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.putItem = putItem;
|
|
4
|
-
const node_crypto_1 = require("node:crypto");
|
|
5
|
-
const clock_1 = require("../../shared/clock");
|
|
6
|
-
const descriptor_keys_1 = require("../../shared/codec/descriptor-keys");
|
|
7
|
-
const orphans_1 = require("../../shared/codec/s3/orphans");
|
|
8
|
-
const retry_1 = require("../../shared/dynamodb/retry");
|
|
9
|
-
const ttl_1 = require("../../shared/validation/ttl");
|
|
10
|
-
const index_sync_1 = require("../internal/index-sync");
|
|
11
|
-
const item_mapper_1 = require("../internal/item-mapper");
|
|
12
|
-
const keys_1 = require("../internal/keys");
|
|
13
|
-
const persist_1 = require("../internal/persist");
|
|
14
|
-
const read_existing_1 = require("../internal/read-existing");
|
|
15
|
-
const semantic_search_1 = require("../internal/semantic-search");
|
|
16
|
-
const validation_1 = require("../internal/validation");
|
|
17
|
-
const write_verify_1 = require("../internal/write-verify");
|
|
18
|
-
/**
|
|
19
|
-
* Delete the item and, when a vector backend is configured, drop its vector.
|
|
20
|
-
*
|
|
21
|
-
* The delete asks DynamoDB for the row it removed (`ReturnValues: 'ALL_OLD'`),
|
|
22
|
-
* so S3 cleanup targets the descriptor that was actually removed rather than
|
|
23
|
-
* one read a moment earlier — a concurrent put between a pre-read and the
|
|
24
|
-
* delete used to leave its just-written object orphaned — and the delete costs
|
|
25
|
-
* one request instead of two.
|
|
26
|
-
*
|
|
27
|
-
* A retry-exhausted failure is *ambiguous*: the delete may have landed
|
|
28
|
-
* server-side with only its acknowledgement lost. Mirroring `persistRecord`,
|
|
29
|
-
* that case is resolved with a strongly-consistent read — if the row is gone
|
|
30
|
-
* the delete succeeded and the vector-backend delete must still run. The
|
|
31
|
-
* removed descriptor travelled with the lost response, so that one object, if
|
|
32
|
-
* any, is left to the lifecycle rule. Any other failure, or a row still
|
|
33
|
-
* present, propagates unchanged.
|
|
34
|
-
*/
|
|
35
|
-
async function deleteStoreItem(context, op, pk, sk) {
|
|
36
|
-
let removed;
|
|
37
|
-
try {
|
|
38
|
-
const result = await (0, retry_1.withDynamoDBRetry)(() => context.client.delete({
|
|
39
|
-
TableName: context.tableName,
|
|
40
|
-
Key: { PK: pk, SK: sk },
|
|
41
|
-
ReturnValues: 'ALL_OLD',
|
|
42
|
-
}), context.retry);
|
|
43
|
-
removed = result.Attributes?.value;
|
|
44
|
-
}
|
|
45
|
-
catch (error) {
|
|
46
|
-
const landed = (0, write_verify_1.isRetryExhausted)(error) && (await (0, write_verify_1.rowIsAbsent)(context, { PK: pk, SK: sk }));
|
|
47
|
-
if (!landed)
|
|
48
|
-
throw error;
|
|
49
|
-
}
|
|
50
|
-
if (context.offloader && removed) {
|
|
51
|
-
await (0, orphans_1.cleanUpS3Orphans)(context.offloader, (0, descriptor_keys_1.collectS3Keys)([removed]), 'store.delete', context.logger, {
|
|
52
|
-
scope: [...op.namespace, op.key],
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
if (context.vectorBackend) {
|
|
56
|
-
await (0, index_sync_1.syncVectorIndex)(context.vectorBackend, op.namespace, op.key, undefined, context.logger);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
/** Compute the embedding for a put, honoring `op.index` (false disables it). */
|
|
60
|
-
async function resolveEmbedding(context, op, value) {
|
|
61
|
-
if (op.index === false)
|
|
62
|
-
return undefined;
|
|
63
|
-
return (0, semantic_search_1.embedValue)(context, value, Array.isArray(op.index) ? op.index : undefined);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Store, update, or delete an item (null deletes). The value is encoded
|
|
67
|
-
* (optional compression/S3 offload, nonced per call so a failed write can never
|
|
68
|
-
* delete the previous payload) and `createdAt` is preserved across updates; a
|
|
69
|
-
* computed embedding is sent to a configured `vectorBackend` instead of being
|
|
70
|
-
* stored on the item — DynamoDB always holds the canonical item.
|
|
71
|
-
*/
|
|
72
|
-
async function putItem(context, op) {
|
|
73
|
-
(0, validation_1.validateStoreKey)(op.namespace, op.key);
|
|
74
|
-
const pk = (0, keys_1.partitionKey)(op.namespace);
|
|
75
|
-
const sk = (0, keys_1.sortKey)(op.namespace, op.key);
|
|
76
|
-
if (op.value === null) {
|
|
77
|
-
await deleteStoreItem(context, op, pk, sk);
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const value = op.value;
|
|
81
|
-
const timestamp = (0, clock_1.nowIso)();
|
|
82
|
-
const existing = await (0, read_existing_1.readExisting)(context, pk, sk);
|
|
83
|
-
const embedding = await resolveEmbedding(context, op, value);
|
|
84
|
-
const ttlTimestamp = context.ttl ? (0, ttl_1.calculateTtlTimestamp)(context.ttl) : undefined;
|
|
85
|
-
const record = await (0, item_mapper_1.buildStoreItem)(context, op.namespace, op.key, value, {
|
|
86
|
-
createdAt: existing.createdAt ?? timestamp,
|
|
87
|
-
updatedAt: timestamp,
|
|
88
|
-
embedding: context.vectorBackend ? undefined : embedding,
|
|
89
|
-
ttlTimestamp,
|
|
90
|
-
nonce: (0, node_crypto_1.randomUUID)(),
|
|
91
|
-
});
|
|
92
|
-
await (0, persist_1.persistRecord)(context, record, existing);
|
|
93
|
-
if (context.vectorBackend) {
|
|
94
|
-
await (0, index_sync_1.syncVectorIndex)(context.vectorBackend, op.namespace, op.key, embedding, context.logger);
|
|
95
|
-
}
|
|
96
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import type { StoreContext } from '../internal/setup';
|
|
2
|
-
/** Counts returned by {@link reconcileVectorIndex}. */
|
|
3
|
-
export interface VectorReconcileResult {
|
|
4
|
-
upserted: number;
|
|
5
|
-
pruned: number;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Repair the vector backend against the canonical DynamoDB items under
|
|
9
|
-
* `namespacePrefix`: re-push every live embedding, and — when the backend
|
|
10
|
-
* implements {@link VectorBackend.listKeys} — prune vectors with no canonical
|
|
11
|
-
* item. A maintenance tool for backend drift; run it when the namespace is
|
|
12
|
-
* idle. Re-embeds with the store's configured fields, so per-put `index` field
|
|
13
|
-
* overrides are not reproduced. Requires a configured `index` and
|
|
14
|
-
* `vectorBackend`; the prefix must be a non-empty namespace.
|
|
15
|
-
*/
|
|
16
|
-
export declare function reconcileVectorIndex(context: StoreContext, namespacePrefix: string[], options?: {
|
|
17
|
-
signal?: AbortSignal;
|
|
18
|
-
}): Promise<VectorReconcileResult>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reconcileVectorIndex = reconcileVectorIndex;
|
|
4
|
-
const errors_1 = require("../../shared/errors/errors");
|
|
5
|
-
const index_reconcile_1 = require("../internal/index-reconcile");
|
|
6
|
-
const validation_1 = require("../internal/validation");
|
|
7
|
-
/**
|
|
8
|
-
* Repair the vector backend against the canonical DynamoDB items under
|
|
9
|
-
* `namespacePrefix`: re-push every live embedding, and — when the backend
|
|
10
|
-
* implements {@link VectorBackend.listKeys} — prune vectors with no canonical
|
|
11
|
-
* item. A maintenance tool for backend drift; run it when the namespace is
|
|
12
|
-
* idle. Re-embeds with the store's configured fields, so per-put `index` field
|
|
13
|
-
* overrides are not reproduced. Requires a configured `index` and
|
|
14
|
-
* `vectorBackend`; the prefix must be a non-empty namespace.
|
|
15
|
-
*/
|
|
16
|
-
async function reconcileVectorIndex(context, namespacePrefix, options = {}) {
|
|
17
|
-
(0, validation_1.validateNamespace)(namespacePrefix);
|
|
18
|
-
if (!context.index || !context.vectorBackend) {
|
|
19
|
-
throw new errors_1.ValidationError('reconcileVectorIndex requires a configured index and vectorBackend');
|
|
20
|
-
}
|
|
21
|
-
const backend = context.vectorBackend;
|
|
22
|
-
const targets = await (0, index_reconcile_1.collectReconcileTargets)(context, namespacePrefix, options.signal);
|
|
23
|
-
const upserted = await (0, index_reconcile_1.pushEmbeddings)(backend, targets);
|
|
24
|
-
const pruned = await (0, index_reconcile_1.pruneOrphans)(context, backend, namespacePrefix, targets);
|
|
25
|
-
return { upserted, pruned };
|
|
26
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { SearchItem, SearchOperation } from '@langchain/langgraph-checkpoint';
|
|
2
|
-
import type { StoreContext } from '../internal/setup';
|
|
3
|
-
/**
|
|
4
|
-
* Search items under a namespace prefix: metadata filtering plus optional
|
|
5
|
-
* semantic ranking. A non-empty prefix uses a native Query; an empty prefix
|
|
6
|
-
* falls back to a (filtered) Scan. Semantic ranking uses the configured
|
|
7
|
-
* VectorBackend when present, else an in-memory cosine ranking (capped).
|
|
8
|
-
*/
|
|
9
|
-
export declare function searchItems(context: StoreContext, op: SearchOperation, signal?: AbortSignal): Promise<SearchItem[]>;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.searchItems = searchItems;
|
|
4
|
-
const backend_search_1 = require("../internal/backend-search");
|
|
5
|
-
const candidates_1 = require("../internal/candidates");
|
|
6
|
-
const ranker_1 = require("../internal/ranker");
|
|
7
|
-
const semantic_search_1 = require("../internal/semantic-search");
|
|
8
|
-
const validation_1 = require("../internal/validation");
|
|
9
|
-
const DEFAULT_LIMIT = 10;
|
|
10
|
-
/**
|
|
11
|
-
* Search items under a namespace prefix: metadata filtering plus optional
|
|
12
|
-
* semantic ranking. A non-empty prefix uses a native Query; an empty prefix
|
|
13
|
-
* falls back to a (filtered) Scan. Semantic ranking uses the configured
|
|
14
|
-
* VectorBackend when present, else an in-memory cosine ranking (capped).
|
|
15
|
-
*/
|
|
16
|
-
async function searchItems(context, op, signal) {
|
|
17
|
-
const offset = op.offset ?? 0;
|
|
18
|
-
const limit = op.limit ?? DEFAULT_LIMIT;
|
|
19
|
-
(0, validation_1.validatePaging)(offset, limit);
|
|
20
|
-
if (op.query && context.index && context.vectorBackend) {
|
|
21
|
-
const ranked = await (0, backend_search_1.searchViaBackend)(context, context.vectorBackend, context.index, op, offset, limit, signal);
|
|
22
|
-
return ranked.slice(offset, offset + limit);
|
|
23
|
-
}
|
|
24
|
-
if (!op.query || !context.index) {
|
|
25
|
-
const page = await (0, candidates_1.collectCandidates)(context, op, { kind: 'page', need: offset + limit }, signal);
|
|
26
|
-
return page.map(({ item }) => ({ ...item })).slice(offset, offset + limit);
|
|
27
|
-
}
|
|
28
|
-
const candidates = await (0, candidates_1.collectCandidates)(context, op, { kind: 'semantic', cap: context.maxSearchCandidates }, signal);
|
|
29
|
-
const queryVector = await context.index.embeddings.embedQuery(op.query);
|
|
30
|
-
(0, semantic_search_1.assertVectorDims)(context.index, queryVector, 'query');
|
|
31
|
-
const ranked = (0, ranker_1.rankInMemory)(candidates, queryVector, context.maxSearchCandidates, (count) => context.logger.warn('search: some candidates carry an embedding of a different dimension than the query and ' +
|
|
32
|
-
'were ranked unscored; re-embed them with reconcileVectorIndex or a re-put', { namespacePrefix: op.namespacePrefix, count }));
|
|
33
|
-
return ranked.slice(offset, offset + limit);
|
|
34
|
-
}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { IndexConfig, SearchItem, SearchOperation } from '@langchain/langgraph-checkpoint';
|
|
2
|
-
import type { VectorBackend } from '../vector-backend';
|
|
3
|
-
import type { StoreContext } from './setup';
|
|
4
|
-
export declare function searchViaBackend(context: StoreContext, backend: VectorBackend, index: IndexConfig, op: SearchOperation, offset: number, limit: number, signal?: AbortSignal): Promise<SearchItem[]>;
|
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.searchViaBackend = searchViaBackend;
|
|
4
|
-
const errors_1 = require("../../shared/errors/errors");
|
|
5
|
-
const get_1 = require("../actions/get");
|
|
6
|
-
const keys_1 = require("./keys");
|
|
7
|
-
const score_direction_1 = require("./score-direction");
|
|
8
|
-
const search_filter_1 = require("./search-filter");
|
|
9
|
-
const semantic_search_1 = require("./semantic-search");
|
|
10
|
-
/**
|
|
11
|
-
* Warn when a backend's own ordering disagrees with its scores. A backend
|
|
12
|
-
* returning a raw distance still hands back nearest-first, so the order looks
|
|
13
|
-
* right while every score means the opposite of what {@link VectorMatch.score}
|
|
14
|
-
* promises — ascending scores are that exact signature. Results are never
|
|
15
|
-
* reordered on this basis: a correctly-scored backend's order is authoritative.
|
|
16
|
-
*/
|
|
17
|
-
function warnOnNonDescendingScores(context, matches, namespacePrefix) {
|
|
18
|
-
const descending = matches.every((match, position) => position === 0 || matches[position - 1].score >= match.score);
|
|
19
|
-
if (descending)
|
|
20
|
-
return;
|
|
21
|
-
context.logger.warn('search: vectorBackend returned ascending scores; VectorMatch.score must be a relevance ' +
|
|
22
|
-
'(higher is better), not a distance — results are forwarded in the order the backend gave', { namespacePrefix });
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Read the canonical item a backend match points at, or `undefined` when the
|
|
26
|
-
* match is unusable. `getItem` validates, so a backend returning a namespace
|
|
27
|
-
* element containing the reserved separator would otherwise turn the whole
|
|
28
|
-
* search into a ValidationError instead of dropping the one bad match.
|
|
29
|
-
*/
|
|
30
|
-
async function fetchMatch(context, match, signal) {
|
|
31
|
-
try {
|
|
32
|
-
return await (0, get_1.getItem)(context, match.namespace, match.key, signal);
|
|
33
|
-
}
|
|
34
|
-
catch (error) {
|
|
35
|
-
context.logger.warn('search: skipped an unusable vectorBackend match', {
|
|
36
|
-
namespace: match.namespace,
|
|
37
|
-
key: match.key,
|
|
38
|
-
reason: error.name,
|
|
39
|
-
});
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
async function searchViaBackend(context, backend, index, op, offset, limit, signal) {
|
|
44
|
-
const queryVector = await index.embeddings.embedQuery(op.query);
|
|
45
|
-
(0, semantic_search_1.assertVectorDims)(index, queryVector, 'query');
|
|
46
|
-
const need = offset + limit;
|
|
47
|
-
if (need > context.maxSearchCandidates) {
|
|
48
|
-
throw new errors_1.ValidationError(`Requested page (offset ${offset} + limit ${limit} = ${need}) exceeds maxSearchCandidates ` +
|
|
49
|
-
`(${context.maxSearchCandidates}); narrow the page or raise maxSearchCandidates`, 'maxSearchCandidates');
|
|
50
|
-
}
|
|
51
|
-
let topK = Math.min(need, context.maxSearchCandidates);
|
|
52
|
-
let results;
|
|
53
|
-
for (;;) {
|
|
54
|
-
const matches = (0, score_direction_1.toRelevanceScores)(await backend.query(op.namespacePrefix, queryVector, topK), context.vectorScoreDirection);
|
|
55
|
-
warnOnNonDescendingScores(context, matches, op.namespacePrefix);
|
|
56
|
-
results = [];
|
|
57
|
-
for (const match of matches) {
|
|
58
|
-
if (!(0, keys_1.namespaceMatchesPrefix)(match.namespace, op.namespacePrefix))
|
|
59
|
-
continue;
|
|
60
|
-
const item = await fetchMatch(context, match, signal);
|
|
61
|
-
if (item && (0, search_filter_1.passesFilter)(item, op))
|
|
62
|
-
results.push({ ...item, score: match.score });
|
|
63
|
-
}
|
|
64
|
-
if (results.length >= need || matches.length < topK)
|
|
65
|
-
break;
|
|
66
|
-
if (topK >= context.maxSearchCandidates) {
|
|
67
|
-
/** The backend still holds matches, but the filter left the page short at the cap: the same answer the in-DB ranker gives, not a silently short page. */
|
|
68
|
-
throw new errors_1.ValidationError(`Semantic search collected ${results.length} of ${need} matches within maxSearchCandidates ` +
|
|
69
|
-
`(${context.maxSearchCandidates}); narrow the filter or raise maxSearchCandidates`, 'maxSearchCandidates');
|
|
70
|
-
}
|
|
71
|
-
topK = Math.min(topK * 2, context.maxSearchCandidates);
|
|
72
|
-
}
|
|
73
|
-
return results;
|
|
74
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { Operation } from '@langchain/langgraph-checkpoint';
|
|
2
|
-
/**
|
|
3
|
-
* Run a batch: every write group serially within itself and groups
|
|
4
|
-
* concurrently with each other, then every read concurrently, at most
|
|
5
|
-
* {@link DEFAULT_READ_CONCURRENCY} operations in flight at a time. Results
|
|
6
|
-
* come back in operation order. Writes complete before any read starts, so a
|
|
7
|
-
* get or search in the same batch observes the puts beside it. Any failure
|
|
8
|
-
* rejects the whole batch: no further operation is started, the ones already
|
|
9
|
-
* in flight settle, and the first error propagates.
|
|
10
|
-
*/
|
|
11
|
-
export declare function runBatch<R>(operations: readonly Operation[], dispatch: (operation: Operation) => Promise<R>): Promise<R[]>;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runBatch = runBatch;
|
|
4
|
-
const concurrency_1 = require("../../shared/concurrency");
|
|
5
|
-
const constants_1 = require("../../shared/constants");
|
|
6
|
-
function itemOf(op) {
|
|
7
|
-
return JSON.stringify([op.namespace, op.key]);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Group a batch so that dependent operations stay ordered while independent
|
|
11
|
-
* ones can run side by side. Two writes to the same item must land in the
|
|
12
|
-
* order given, since the later one wins; writes to different items and all
|
|
13
|
-
* reads are independent of each other.
|
|
14
|
-
*/
|
|
15
|
-
function planBatch(operations) {
|
|
16
|
-
const groups = new Map();
|
|
17
|
-
const reads = [];
|
|
18
|
-
operations.forEach((op, index) => {
|
|
19
|
-
if (!('value' in op)) {
|
|
20
|
-
reads.push(index);
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const item = itemOf(op);
|
|
24
|
-
const group = groups.get(item);
|
|
25
|
-
if (group)
|
|
26
|
-
group.push(index);
|
|
27
|
-
else
|
|
28
|
-
groups.set(item, [index]);
|
|
29
|
-
});
|
|
30
|
-
return { writeGroups: [...groups.values()], reads };
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* Run a batch: every write group serially within itself and groups
|
|
34
|
-
* concurrently with each other, then every read concurrently, at most
|
|
35
|
-
* {@link DEFAULT_READ_CONCURRENCY} operations in flight at a time. Results
|
|
36
|
-
* come back in operation order. Writes complete before any read starts, so a
|
|
37
|
-
* get or search in the same batch observes the puts beside it. Any failure
|
|
38
|
-
* rejects the whole batch: no further operation is started, the ones already
|
|
39
|
-
* in flight settle, and the first error propagates.
|
|
40
|
-
*/
|
|
41
|
-
async function runBatch(operations, dispatch) {
|
|
42
|
-
const plan = planBatch(operations);
|
|
43
|
-
const results = [];
|
|
44
|
-
await (0, concurrency_1.mapWithConcurrency)(plan.writeGroups, constants_1.DEFAULT_READ_CONCURRENCY, async (group) => {
|
|
45
|
-
for (const index of group)
|
|
46
|
-
results[index] = await dispatch(operations[index]);
|
|
47
|
-
});
|
|
48
|
-
await (0, concurrency_1.mapWithConcurrency)(plan.reads, constants_1.DEFAULT_READ_CONCURRENCY, async (index) => {
|
|
49
|
-
results[index] = await dispatch(operations[index]);
|
|
50
|
-
});
|
|
51
|
-
return results;
|
|
52
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import type { SearchOperation } from '@langchain/langgraph-checkpoint';
|
|
2
|
-
import type { RankCandidate } from './ranker';
|
|
3
|
-
import type { StoreContext } from './setup';
|
|
4
|
-
/**
|
|
5
|
-
* How far a collection must go. A plain page is complete once `need`
|
|
6
|
-
* (`offset + limit`) matching items are in hand, so rows past it are never
|
|
7
|
-
* read or decoded; a semantic ranking needs every candidate but is refused as
|
|
8
|
-
* soon as more than `cap` rows exist, before a single decode or embedding.
|
|
9
|
-
*/
|
|
10
|
-
export type CollectBound = {
|
|
11
|
-
kind: 'page';
|
|
12
|
-
need: number;
|
|
13
|
-
} | {
|
|
14
|
-
kind: 'semantic';
|
|
15
|
-
cap: number;
|
|
16
|
-
};
|
|
17
|
-
/**
|
|
18
|
-
* Collect the live rows under the prefix and decode them within `bound`. A
|
|
19
|
-
* page decodes rows in batches of {@link DEFAULT_READ_CONCURRENCY} and closes
|
|
20
|
-
* the paginator as soon as the page is full, so a namespace far larger than the
|
|
21
|
-
* page costs neither a full decode nor a truncation error.
|
|
22
|
-
*/
|
|
23
|
-
export declare function collectCandidates(context: StoreContext, op: SearchOperation, bound: CollectBound, signal?: AbortSignal): Promise<RankCandidate[]>;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.collectCandidates = collectCandidates;
|
|
4
|
-
const clock_1 = require("../../shared/clock");
|
|
5
|
-
const concurrency_1 = require("../../shared/concurrency");
|
|
6
|
-
const constants_1 = require("../../shared/constants");
|
|
7
|
-
const expiry_1 = require("../../shared/dynamodb/expiry");
|
|
8
|
-
const paginate_1 = require("../../shared/dynamodb/paginate");
|
|
9
|
-
const retry_policy_1 = require("../../shared/dynamodb/retry-policy");
|
|
10
|
-
const scan_1 = require("../../shared/dynamodb/scan");
|
|
11
|
-
const errors_1 = require("../../shared/errors/errors");
|
|
12
|
-
const item_mapper_1 = require("./item-mapper");
|
|
13
|
-
const keys_1 = require("./keys");
|
|
14
|
-
const query_1 = require("./query");
|
|
15
|
-
const search_filter_1 = require("./search-filter");
|
|
16
|
-
function candidateSource(context, op, signal, now) {
|
|
17
|
-
return op.namespacePrefix.length > 0
|
|
18
|
-
? (0, paginate_1.paginateQuery)({
|
|
19
|
-
retry: (0, retry_policy_1.retryFor)(context, signal),
|
|
20
|
-
signal,
|
|
21
|
-
client: context.client,
|
|
22
|
-
params: (0, expiry_1.withoutExpired)((0, query_1.scopedQuery)(context.tableName, op.namespacePrefix), now),
|
|
23
|
-
maxItems: context.maxScanItems,
|
|
24
|
-
})
|
|
25
|
-
: (0, scan_1.paginateScan)({
|
|
26
|
-
retry: (0, retry_policy_1.retryFor)(context, signal),
|
|
27
|
-
signal,
|
|
28
|
-
client: context.client,
|
|
29
|
-
params: (0, expiry_1.withoutExpired)((0, query_1.storeScan)(context.tableName), now),
|
|
30
|
-
maxItems: context.maxScanItems,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
/** The store record a raw row denotes, or undefined for a foreign, expired or out-of-prefix row. */
|
|
34
|
-
function liveRecord(raw, op, now) {
|
|
35
|
-
const record = (0, item_mapper_1.narrowStoreRecord)(raw);
|
|
36
|
-
if (!record || (0, expiry_1.isExpiredRow)(record, now))
|
|
37
|
-
return undefined;
|
|
38
|
-
return (0, keys_1.namespaceMatchesPrefix)(record.namespace, op.namespacePrefix) ? record : undefined;
|
|
39
|
-
}
|
|
40
|
-
/** Decode the pending rows concurrently (each offloaded row is one S3 GET) and keep the ones passing the filter. */
|
|
41
|
-
async function flush(context, op, state) {
|
|
42
|
-
if (state.pending.length === 0)
|
|
43
|
-
return;
|
|
44
|
-
const batch = state.pending;
|
|
45
|
-
state.pending = [];
|
|
46
|
-
const items = await (0, concurrency_1.mapWithConcurrency)(batch, constants_1.DEFAULT_READ_CONCURRENCY, (record) => (0, item_mapper_1.readStoreItem)(context, record));
|
|
47
|
-
batch.forEach((record, index) => {
|
|
48
|
-
if ((0, search_filter_1.passesFilter)(items[index], op)) {
|
|
49
|
-
state.collected.push({ item: items[index], embedding: record.embedding });
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
/**
|
|
54
|
-
* Rows to gather before the next decode. With a filter every batch is a full
|
|
55
|
-
* one, since any row may be dropped; without one every decoded row is a match,
|
|
56
|
-
* so the batch never exceeds what the page still needs.
|
|
57
|
-
*/
|
|
58
|
-
function batchSize(op, need, collected) {
|
|
59
|
-
return op.filter === undefined
|
|
60
|
-
? Math.min(constants_1.DEFAULT_READ_CONCURRENCY, need - collected)
|
|
61
|
-
: constants_1.DEFAULT_READ_CONCURRENCY;
|
|
62
|
-
}
|
|
63
|
-
function tooManyCandidates(count, cap) {
|
|
64
|
-
return new errors_1.ValidationError(`Semantic search candidate set (${count}) exceeds maxSearchCandidates (${cap}); ` +
|
|
65
|
-
'use a dedicated VectorBackend for large corpora', 'maxSearchCandidates');
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Collect the live rows under the prefix and decode them within `bound`. A
|
|
69
|
-
* page decodes rows in batches of {@link DEFAULT_READ_CONCURRENCY} and closes
|
|
70
|
-
* the paginator as soon as the page is full, so a namespace far larger than the
|
|
71
|
-
* page costs neither a full decode nor a truncation error.
|
|
72
|
-
*/
|
|
73
|
-
async function collectCandidates(context, op, bound, signal) {
|
|
74
|
-
const now = (0, clock_1.nowSeconds)();
|
|
75
|
-
const state = { pending: [], collected: [] };
|
|
76
|
-
for await (const raw of candidateSource(context, op, signal, now)) {
|
|
77
|
-
const record = liveRecord(raw, op, now);
|
|
78
|
-
if (!record)
|
|
79
|
-
continue;
|
|
80
|
-
state.pending.push(record);
|
|
81
|
-
if (bound.kind === 'semantic') {
|
|
82
|
-
if (state.pending.length > bound.cap)
|
|
83
|
-
throw tooManyCandidates(state.pending.length, bound.cap);
|
|
84
|
-
continue;
|
|
85
|
-
}
|
|
86
|
-
if (state.pending.length < batchSize(op, bound.need, state.collected.length))
|
|
87
|
-
continue;
|
|
88
|
-
await flush(context, op, state);
|
|
89
|
-
if (state.collected.length >= bound.need)
|
|
90
|
-
return state.collected;
|
|
91
|
-
}
|
|
92
|
-
await flush(context, op, state);
|
|
93
|
-
return state.collected;
|
|
94
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/** A JSON value stored in an item or supplied in a filter. */
|
|
2
|
-
export type JsonValue = string | number | boolean | null | JsonValue[] | {
|
|
3
|
-
[key: string]: JsonValue;
|
|
4
|
-
};
|
|
5
|
-
/**
|
|
6
|
-
* True when `value` satisfies every field condition in `filter`. A plain value
|
|
7
|
-
* is exact-match ($eq); an operator object ({ $gt: 4 }) applies comparisons.
|
|
8
|
-
*/
|
|
9
|
-
export declare function matchesStoreFilter(value: Record<string, JsonValue>, filter: Record<string, JsonValue>): boolean;
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.matchesStoreFilter = matchesStoreFilter;
|
|
4
|
-
const node_util_1 = require("node:util");
|
|
5
|
-
/**
|
|
6
|
-
* Three-way order for a like-typed pair, or `undefined` when the pair is
|
|
7
|
-
* *unordered*. `NaN` compares `false` against everything including itself, so a
|
|
8
|
-
* bare `===`/`>` ternary silently reports it as "less than" — which let a
|
|
9
|
-
* stored `NaN` satisfy `$lt`/`$lte` against any number, contradicting
|
|
10
|
-
* {@link compareOrdered}'s own contract.
|
|
11
|
-
*/
|
|
12
|
-
function orderOf(actual, expected) {
|
|
13
|
-
if (actual < expected)
|
|
14
|
-
return -1;
|
|
15
|
-
if (actual > expected)
|
|
16
|
-
return 1;
|
|
17
|
-
return actual === expected ? 0 : undefined;
|
|
18
|
-
}
|
|
19
|
-
/** Apply `test` to a resolved order; an unordered pair never matches. */
|
|
20
|
-
function testOrder(order, test) {
|
|
21
|
-
return order !== undefined && test(order);
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Ordered comparison over like-typed values only: numbers compare numerically,
|
|
25
|
-
* strings lexicographically, and a mismatched or unordered pair never matches.
|
|
26
|
-
*
|
|
27
|
-
* Deliberately stricter than both what this used to do and what upstream does.
|
|
28
|
-
* Native `>` coerces, so a stored `'10'` satisfied `{ $gt: 5 }` — inclusion
|
|
29
|
-
* decided by JS coercion rather than by the stored type. Upstream instead
|
|
30
|
-
* reduces both sides with `Number()`, which makes two ISO-8601 date strings
|
|
31
|
-
* `NaN` and every comparison between them false. Comparing like types
|
|
32
|
-
* directly is well-defined in both cases.
|
|
33
|
-
*/
|
|
34
|
-
function compareOrdered(actual, expected, test) {
|
|
35
|
-
if (typeof actual === 'number' && typeof expected === 'number') {
|
|
36
|
-
return testOrder(orderOf(actual, expected), test);
|
|
37
|
-
}
|
|
38
|
-
if (typeof actual === 'string' && typeof expected === 'string') {
|
|
39
|
-
return testOrder(orderOf(actual, expected), test);
|
|
40
|
-
}
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
const COMPARATORS = {
|
|
44
|
-
$eq: (actual, expected) => (0, node_util_1.isDeepStrictEqual)(actual, expected),
|
|
45
|
-
$ne: (actual, expected) => !(0, node_util_1.isDeepStrictEqual)(actual, expected),
|
|
46
|
-
$gt: (actual, expected) => compareOrdered(actual, expected, (order) => order > 0),
|
|
47
|
-
$gte: (actual, expected) => compareOrdered(actual, expected, (order) => order >= 0),
|
|
48
|
-
$lt: (actual, expected) => compareOrdered(actual, expected, (order) => order < 0),
|
|
49
|
-
$lte: (actual, expected) => compareOrdered(actual, expected, (order) => order <= 0),
|
|
50
|
-
$in: (actual, expected) => Array.isArray(expected)
|
|
51
|
-
? expected.some((candidate) => (0, node_util_1.isDeepStrictEqual)(actual, candidate))
|
|
52
|
-
: false,
|
|
53
|
-
$nin: (actual, expected) => Array.isArray(expected)
|
|
54
|
-
? !expected.some((candidate) => (0, node_util_1.isDeepStrictEqual)(actual, candidate))
|
|
55
|
-
: true,
|
|
56
|
-
};
|
|
57
|
-
/**
|
|
58
|
-
* True only when every key is one of the exact known operator names — matches
|
|
59
|
-
* the official `@langchain/langgraph-checkpoint` InMemoryStore's own detection
|
|
60
|
-
* exactly, so a stored value that merely has `$`-prefixed keys (e.g. a JSON
|
|
61
|
-
* Schema document) is compared as a literal value instead of misread as a
|
|
62
|
-
* filter operator.
|
|
63
|
-
*/
|
|
64
|
-
function isOperatorObject(condition) {
|
|
65
|
-
return (typeof condition === 'object' &&
|
|
66
|
-
condition !== null &&
|
|
67
|
-
!Array.isArray(condition) &&
|
|
68
|
-
Object.keys(condition).length > 0 &&
|
|
69
|
-
Object.keys(condition).every((key) => Object.prototype.hasOwnProperty.call(COMPARATORS, key)));
|
|
70
|
-
}
|
|
71
|
-
function matchesCondition(actual, condition) {
|
|
72
|
-
if (!isOperatorObject(condition))
|
|
73
|
-
return (0, node_util_1.isDeepStrictEqual)(actual, condition);
|
|
74
|
-
return Object.entries(condition).every(([operator, expected]) => COMPARATORS[operator](actual, expected));
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* True when `value` satisfies every field condition in `filter`. A plain value
|
|
78
|
-
* is exact-match ($eq); an operator object ({ $gt: 4 }) applies comparisons.
|
|
79
|
-
*/
|
|
80
|
-
function matchesStoreFilter(value, filter) {
|
|
81
|
-
return Object.entries(filter).every(([field, condition]) =>
|
|
82
|
-
/** Own properties only: `value['toString']` would otherwise resolve up the
|
|
83
|
-
* prototype chain and be compared as if it were stored data. */
|
|
84
|
-
matchesCondition(Object.hasOwn(value, field) ? value[field] : undefined, condition));
|
|
85
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import type { VectorBackend, VectorRef } from '../vector-backend';
|
|
2
|
-
import type { StoreContext } from './setup';
|
|
3
|
-
/** A canonical item's location plus the embedding recomputed for it. */
|
|
4
|
-
export interface ReconcileTarget {
|
|
5
|
-
namespace: string[];
|
|
6
|
-
key: string;
|
|
7
|
-
embedding: number[] | undefined;
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Enumerate the live (unexpired) items under `prefix`, then recompute their
|
|
11
|
-
* embeddings in batches. A failed embedding rejects the whole reconcile: a
|
|
12
|
-
* skipped item would leave the live set and {@link selectOrphans} would prune
|
|
13
|
-
* its still-valid vector.
|
|
14
|
-
*/
|
|
15
|
-
export declare function collectReconcileTargets(context: StoreContext, prefix: string[], signal?: AbortSignal): Promise<ReconcileTarget[]>;
|
|
16
|
-
/** Re-push every live embedding to the backend; returns the upsert count. */
|
|
17
|
-
export declare function pushEmbeddings(backend: VectorBackend, targets: ReconcileTarget[]): Promise<number>;
|
|
18
|
-
/** Refs present in the backend but absent from `live` — orphans to prune. */
|
|
19
|
-
export declare function selectOrphans(backendRefs: VectorRef[], live: ReconcileTarget[]): VectorRef[];
|
|
20
|
-
/** Delete backend vectors with no canonical item; returns the prune count. */
|
|
21
|
-
export declare function pruneOrphans(context: StoreContext, backend: VectorBackend, prefix: string[], live: ReconcileTarget[]): Promise<number>;
|