@farukada/aws-langgraph-dynamodb-ts 1.0.0-rc.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1820 -290
- package/dist/cjs/backfill/backfill.d.ts +171 -0
- package/dist/cjs/backfill/backfill.js +177 -0
- package/dist/cjs/checkpointer/actions/delete-thread.d.ts +50 -0
- package/dist/cjs/checkpointer/actions/delete-thread.js +26 -0
- package/dist/cjs/checkpointer/actions/get-tuple.d.ts +36 -0
- package/dist/cjs/checkpointer/actions/get-tuple.js +22 -0
- package/dist/cjs/checkpointer/actions/list.d.ts +55 -0
- package/dist/cjs/checkpointer/actions/list.js +70 -0
- package/dist/cjs/checkpointer/actions/put-writes.d.ts +49 -0
- package/dist/cjs/checkpointer/actions/put-writes.js +21 -0
- package/dist/cjs/checkpointer/actions/put.d.ts +95 -0
- package/dist/cjs/checkpointer/actions/put.js +79 -0
- package/dist/cjs/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/cjs/checkpointer/internal/delta-history.js +131 -0
- package/dist/cjs/checkpointer/internal/listing.d.ts +149 -0
- package/dist/cjs/checkpointer/internal/listing.js +104 -0
- package/dist/cjs/checkpointer/internal/parse.d.ts +298 -0
- package/dist/cjs/checkpointer/internal/parse.js +184 -0
- package/dist/cjs/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/cjs/checkpointer/internal/pending-writes.js +241 -0
- package/dist/cjs/checkpointer/internal/read.d.ts +135 -0
- package/dist/cjs/checkpointer/internal/read.js +132 -0
- package/dist/cjs/checkpointer/internal/rows.d.ts +644 -0
- package/dist/cjs/checkpointer/internal/rows.js +356 -0
- package/dist/cjs/checkpointer/internal/setup.d.ts +47 -0
- package/dist/cjs/checkpointer/internal/setup.js +25 -0
- package/dist/cjs/checkpointer/saver.d.ts +306 -0
- package/dist/cjs/checkpointer/saver.js +56 -0
- package/dist/cjs/checkpointer/types.d.ts +51 -0
- package/dist/cjs/factory/factory.d.ts +154 -0
- package/dist/cjs/factory/factory.js +137 -0
- package/dist/{factory → cjs/factory}/types.d.ts +33 -14
- package/dist/cjs/history/actions/add-messages.d.ts +51 -0
- package/dist/cjs/history/actions/add-messages.js +17 -0
- package/dist/cjs/history/actions/clear.d.ts +52 -0
- package/dist/cjs/history/actions/clear.js +29 -0
- package/dist/cjs/history/actions/get-messages.d.ts +60 -0
- package/dist/cjs/history/actions/get-messages.js +58 -0
- package/dist/cjs/history/actions/list-sessions.d.ts +55 -0
- package/dist/cjs/history/actions/list-sessions.js +67 -0
- package/dist/cjs/history/actions/reconcile-count.d.ts +49 -0
- package/dist/cjs/history/actions/reconcile-count.js +8 -0
- package/dist/cjs/history/chat-message-history.d.ts +267 -0
- package/dist/cjs/history/chat-message-history.js +61 -0
- package/dist/cjs/history/internal/append.d.ts +244 -0
- package/dist/cjs/history/internal/append.js +267 -0
- package/dist/cjs/history/internal/message-read.d.ts +84 -0
- package/dist/cjs/history/internal/message-read.js +93 -0
- package/dist/cjs/history/internal/parse.d.ts +153 -0
- package/dist/cjs/history/internal/parse.js +113 -0
- package/dist/cjs/history/internal/rows.d.ts +196 -0
- package/dist/cjs/history/internal/rows.js +96 -0
- package/dist/cjs/history/internal/session.d.ts +350 -0
- package/dist/cjs/history/internal/session.js +296 -0
- package/dist/cjs/history/internal/setup.d.ts +64 -0
- package/dist/cjs/history/internal/setup.js +60 -0
- package/dist/cjs/history/session-adapter.d.ts +112 -0
- package/dist/cjs/history/session-adapter.js +38 -0
- package/dist/cjs/history/types.d.ts +102 -0
- package/dist/cjs/index.d.ts +53 -0
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/shared/adapter.d.ts +146 -0
- package/dist/cjs/shared/adapter.js +70 -0
- package/dist/cjs/shared/clock.d.ts +52 -0
- package/dist/cjs/shared/clock.js +14 -0
- package/dist/cjs/shared/codec/codec.d.ts +336 -0
- package/dist/cjs/shared/codec/codec.js +162 -0
- package/dist/cjs/shared/codec/compression.d.ts +66 -0
- package/dist/cjs/shared/codec/compression.js +45 -0
- package/dist/cjs/shared/codec/json-serde.d.ts +80 -0
- package/dist/cjs/shared/codec/json-serde.js +58 -0
- package/dist/{shared → cjs/shared}/codec/s3/client-types.d.ts +22 -2
- package/dist/{shared → cjs/shared}/codec/s3/client-types.js +0 -1
- package/dist/cjs/shared/codec/s3/client.d.ts +63 -0
- package/dist/cjs/shared/codec/s3/client.js +78 -0
- package/dist/cjs/shared/codec/s3/config.d.ts +260 -0
- package/dist/cjs/shared/codec/s3/config.js +92 -0
- package/dist/cjs/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/cjs/shared/codec/s3/lifecycle.js +223 -0
- package/dist/cjs/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/cjs/shared/codec/s3/offloader.js +289 -0
- package/dist/cjs/shared/concurrency.d.ts +43 -0
- package/dist/{shared → cjs/shared}/concurrency.js +10 -9
- package/dist/cjs/shared/dynamodb/abort.d.ts +47 -0
- package/dist/cjs/shared/dynamodb/abort.js +16 -0
- package/dist/cjs/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/cjs/shared/dynamodb/batch-write.js +79 -0
- package/dist/cjs/shared/dynamodb/cancellation.d.ts +124 -0
- package/dist/cjs/shared/dynamodb/cancellation.js +37 -0
- package/dist/cjs/shared/dynamodb/client.d.ts +177 -0
- package/dist/{shared → cjs/shared}/dynamodb/client.js +12 -14
- package/dist/cjs/shared/dynamodb/idempotent-write.d.ts +596 -0
- package/dist/cjs/shared/dynamodb/idempotent-write.js +173 -0
- package/dist/cjs/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/cjs/shared/dynamodb/paginate.js +90 -0
- package/dist/cjs/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/cjs/shared/dynamodb/partition-delete.js +177 -0
- package/dist/cjs/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/cjs/shared/dynamodb/recency-index.js +146 -0
- package/dist/cjs/shared/dynamodb/retry.d.ts +317 -0
- package/dist/cjs/shared/dynamodb/retry.js +193 -0
- package/dist/cjs/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/cjs/shared/dynamodb/row-size.js +30 -0
- package/dist/cjs/shared/dynamodb/table-schema.d.ts +199 -0
- package/dist/cjs/shared/dynamodb/table-schema.js +52 -0
- package/dist/cjs/shared/errors/base-error.d.ts +231 -0
- package/dist/cjs/shared/errors/base-error.js +73 -0
- package/dist/cjs/shared/errors/boundary.d.ts +86 -0
- package/dist/cjs/shared/errors/boundary.js +61 -0
- package/dist/cjs/shared/errors/classify.d.ts +206 -0
- package/dist/cjs/shared/errors/classify.js +232 -0
- package/dist/cjs/shared/errors/error-code.d.ts +95 -0
- package/dist/{shared → cjs/shared}/errors/error-code.js +12 -2
- package/dist/cjs/shared/errors/errors.d.ts +233 -0
- package/dist/cjs/shared/errors/errors.js +123 -0
- package/dist/cjs/shared/logging/logger.d.ts +80 -0
- package/dist/cjs/shared/logging/logger.js +30 -0
- package/dist/cjs/shared/logging/redaction.d.ts +123 -0
- package/dist/cjs/shared/logging/redaction.js +145 -0
- package/dist/cjs/shared/logging/secret-patterns.d.ts +227 -0
- package/dist/cjs/shared/logging/secret-patterns.js +93 -0
- package/dist/cjs/shared/logging/truncate.d.ts +197 -0
- package/dist/cjs/shared/logging/truncate.js +31 -0
- package/dist/cjs/shared/options.d.ts +100 -0
- package/dist/cjs/shared/ulid.d.ts +80 -0
- package/dist/{shared → cjs/shared}/ulid.js +7 -21
- package/dist/cjs/shared/validation/collaborators.d.ts +160 -0
- package/dist/cjs/shared/validation/collaborators.js +79 -0
- package/dist/cjs/shared/validation/option-shape.d.ts +91 -0
- package/dist/cjs/shared/validation/option-shape.js +31 -0
- package/dist/cjs/shared/validation/options.d.ts +145 -0
- package/dist/cjs/shared/validation/options.js +166 -0
- package/dist/cjs/shared/validation/primitives.d.ts +292 -0
- package/dist/cjs/shared/validation/primitives.js +114 -0
- package/dist/cjs/shared/validation/ttl.d.ts +94 -0
- package/dist/cjs/shared/validation/ttl.js +52 -0
- package/dist/cjs/store/actions/list-namespaces.d.ts +79 -0
- package/dist/cjs/store/actions/list-namespaces.js +92 -0
- package/dist/cjs/store/actions/put.d.ts +43 -0
- package/dist/cjs/store/actions/put.js +49 -0
- package/dist/cjs/store/actions/reconcile-vector-index.d.ts +38 -0
- package/dist/cjs/store/actions/reconcile-vector-index.js +13 -0
- package/dist/cjs/store/actions/search.d.ts +38 -0
- package/dist/cjs/store/actions/search.js +26 -0
- package/dist/cjs/store/internal/batch-plan.d.ts +56 -0
- package/dist/cjs/store/internal/batch-plan.js +32 -0
- package/dist/cjs/store/internal/filter.d.ts +43 -0
- package/dist/cjs/store/internal/filter.js +64 -0
- package/dist/cjs/store/internal/get-item.d.ts +77 -0
- package/dist/cjs/store/internal/get-item.js +58 -0
- package/dist/cjs/store/internal/item-write.d.ts +270 -0
- package/dist/cjs/store/internal/item-write.js +181 -0
- package/dist/cjs/store/internal/parse.d.ts +230 -0
- package/dist/cjs/store/internal/parse.js +180 -0
- package/dist/cjs/store/internal/rows.d.ts +359 -0
- package/dist/cjs/store/internal/rows.js +166 -0
- package/dist/cjs/store/internal/semantic-search.d.ts +168 -0
- package/dist/{store/internal/text-path.js → cjs/store/internal/semantic-search.js} +92 -28
- package/dist/cjs/store/internal/setup.d.ts +96 -0
- package/dist/cjs/store/internal/setup.js +103 -0
- package/dist/cjs/store/internal/table-search.d.ts +100 -0
- package/dist/cjs/store/internal/table-search.js +123 -0
- package/dist/cjs/store/internal/vector-index.d.ts +258 -0
- package/dist/cjs/store/internal/vector-index.js +269 -0
- package/dist/cjs/store/store.d.ts +329 -0
- package/dist/cjs/store/store.js +97 -0
- package/dist/cjs/store/types.d.ts +111 -0
- package/dist/cjs/store/vector-backend.d.ts +104 -0
- package/dist/cjs/store/vector-backend.js +4 -0
- package/dist/esm/backfill/backfill.d.ts +171 -0
- package/dist/esm/backfill/backfill.js +170 -0
- package/dist/esm/checkpointer/actions/delete-thread.d.ts +50 -0
- package/dist/esm/checkpointer/actions/delete-thread.js +23 -0
- package/dist/esm/checkpointer/actions/get-tuple.d.ts +36 -0
- package/dist/esm/checkpointer/actions/get-tuple.js +19 -0
- package/dist/esm/checkpointer/actions/list.d.ts +55 -0
- package/dist/esm/checkpointer/actions/list.js +67 -0
- package/dist/esm/checkpointer/actions/put-writes.d.ts +49 -0
- package/dist/esm/checkpointer/actions/put-writes.js +18 -0
- package/dist/esm/checkpointer/actions/put.d.ts +95 -0
- package/dist/esm/checkpointer/actions/put.js +75 -0
- package/dist/esm/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/esm/checkpointer/internal/delta-history.js +126 -0
- package/dist/esm/checkpointer/internal/listing.d.ts +149 -0
- package/dist/esm/checkpointer/internal/listing.js +95 -0
- package/dist/esm/checkpointer/internal/parse.d.ts +298 -0
- package/dist/esm/checkpointer/internal/parse.js +169 -0
- package/dist/esm/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/esm/checkpointer/internal/pending-writes.js +229 -0
- package/dist/esm/checkpointer/internal/read.d.ts +135 -0
- package/dist/esm/checkpointer/internal/read.js +125 -0
- package/dist/esm/checkpointer/internal/rows.d.ts +644 -0
- package/dist/esm/checkpointer/internal/rows.js +323 -0
- package/dist/esm/checkpointer/internal/setup.d.ts +47 -0
- package/dist/esm/checkpointer/internal/setup.js +21 -0
- package/dist/esm/checkpointer/saver.d.ts +306 -0
- package/dist/esm/checkpointer/saver.js +52 -0
- package/dist/esm/checkpointer/types.d.ts +51 -0
- package/dist/esm/checkpointer/types.js +1 -0
- package/dist/esm/factory/factory.d.ts +154 -0
- package/dist/esm/factory/factory.js +133 -0
- package/dist/esm/factory/types.d.ts +76 -0
- package/dist/esm/factory/types.js +1 -0
- package/dist/esm/history/actions/add-messages.d.ts +51 -0
- package/dist/esm/history/actions/add-messages.js +14 -0
- package/dist/esm/history/actions/clear.d.ts +52 -0
- package/dist/esm/history/actions/clear.js +26 -0
- package/dist/esm/history/actions/get-messages.d.ts +60 -0
- package/dist/esm/history/actions/get-messages.js +55 -0
- package/dist/esm/history/actions/list-sessions.d.ts +55 -0
- package/dist/esm/history/actions/list-sessions.js +64 -0
- package/dist/esm/history/actions/reconcile-count.d.ts +49 -0
- package/dist/esm/history/actions/reconcile-count.js +5 -0
- package/dist/esm/history/chat-message-history.d.ts +267 -0
- package/dist/esm/history/chat-message-history.js +57 -0
- package/dist/esm/history/internal/append.d.ts +244 -0
- package/dist/esm/history/internal/append.js +259 -0
- package/dist/esm/history/internal/message-read.d.ts +84 -0
- package/dist/esm/history/internal/message-read.js +89 -0
- package/dist/esm/history/internal/parse.d.ts +153 -0
- package/dist/esm/history/internal/parse.js +105 -0
- package/dist/esm/history/internal/rows.d.ts +196 -0
- package/dist/esm/history/internal/rows.js +83 -0
- package/dist/esm/history/internal/session.d.ts +350 -0
- package/dist/esm/history/internal/session.js +285 -0
- package/dist/esm/history/internal/setup.d.ts +64 -0
- package/dist/esm/history/internal/setup.js +56 -0
- package/dist/esm/history/session-adapter.d.ts +112 -0
- package/dist/esm/history/session-adapter.js +34 -0
- package/dist/esm/history/types.d.ts +102 -0
- package/dist/esm/history/types.js +1 -0
- package/dist/esm/index.d.ts +53 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/shared/adapter.d.ts +146 -0
- package/dist/esm/shared/adapter.js +65 -0
- package/dist/esm/shared/clock.d.ts +52 -0
- package/dist/esm/shared/clock.js +9 -0
- package/dist/esm/shared/codec/codec.d.ts +336 -0
- package/dist/esm/shared/codec/codec.js +150 -0
- package/dist/esm/shared/codec/compression.d.ts +66 -0
- package/dist/esm/shared/codec/compression.js +40 -0
- package/dist/esm/shared/codec/json-serde.d.ts +80 -0
- package/dist/esm/shared/codec/json-serde.js +54 -0
- package/dist/esm/shared/codec/s3/client-types.d.ts +54 -0
- package/dist/esm/shared/codec/s3/client-types.js +3 -0
- package/dist/esm/shared/codec/s3/client.d.ts +63 -0
- package/dist/esm/shared/codec/s3/client.js +40 -0
- package/dist/esm/shared/codec/s3/config.d.ts +260 -0
- package/dist/esm/shared/codec/s3/config.js +79 -0
- package/dist/esm/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/esm/shared/codec/s3/lifecycle.js +214 -0
- package/dist/esm/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/esm/shared/codec/s3/offloader.js +278 -0
- package/dist/esm/shared/concurrency.d.ts +43 -0
- package/dist/esm/shared/concurrency.js +27 -0
- package/dist/esm/shared/dynamodb/abort.d.ts +47 -0
- package/dist/esm/shared/dynamodb/abort.js +12 -0
- package/dist/esm/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/esm/shared/dynamodb/batch-write.js +74 -0
- package/dist/esm/shared/dynamodb/cancellation.d.ts +124 -0
- package/dist/esm/shared/dynamodb/cancellation.js +30 -0
- package/dist/esm/shared/dynamodb/client.d.ts +177 -0
- package/dist/esm/shared/dynamodb/client.js +35 -0
- package/dist/esm/shared/dynamodb/idempotent-write.d.ts +596 -0
- package/dist/esm/shared/dynamodb/idempotent-write.js +153 -0
- package/dist/esm/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/esm/shared/dynamodb/paginate.js +84 -0
- package/dist/esm/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/esm/shared/dynamodb/partition-delete.js +171 -0
- package/dist/esm/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/esm/shared/dynamodb/recency-index.js +136 -0
- package/dist/esm/shared/dynamodb/retry.d.ts +317 -0
- package/dist/esm/shared/dynamodb/retry.js +180 -0
- package/dist/esm/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/esm/shared/dynamodb/row-size.js +26 -0
- package/dist/esm/shared/dynamodb/table-schema.d.ts +199 -0
- package/dist/esm/shared/dynamodb/table-schema.js +43 -0
- package/dist/esm/shared/errors/base-error.d.ts +231 -0
- package/dist/esm/shared/errors/base-error.js +64 -0
- package/dist/esm/shared/errors/boundary.d.ts +86 -0
- package/dist/esm/shared/errors/boundary.js +54 -0
- package/dist/esm/shared/errors/classify.d.ts +206 -0
- package/dist/esm/shared/errors/classify.js +220 -0
- package/dist/esm/shared/errors/error-code.d.ts +95 -0
- package/dist/esm/shared/errors/error-code.js +24 -0
- package/dist/esm/shared/errors/errors.d.ts +233 -0
- package/dist/esm/shared/errors/errors.js +110 -0
- package/dist/esm/shared/logging/logger.d.ts +80 -0
- package/dist/esm/shared/logging/logger.js +25 -0
- package/dist/esm/shared/logging/redaction.d.ts +123 -0
- package/dist/esm/shared/logging/redaction.js +140 -0
- package/dist/esm/shared/logging/secret-patterns.d.ts +227 -0
- package/dist/esm/shared/logging/secret-patterns.js +83 -0
- package/dist/esm/shared/logging/truncate.d.ts +197 -0
- package/dist/esm/shared/logging/truncate.js +25 -0
- package/dist/esm/shared/options.d.ts +100 -0
- package/dist/esm/shared/options.js +1 -0
- package/dist/esm/shared/ulid.d.ts +80 -0
- package/dist/esm/shared/ulid.js +77 -0
- package/dist/esm/shared/validation/collaborators.d.ts +160 -0
- package/dist/esm/shared/validation/collaborators.js +70 -0
- package/dist/esm/shared/validation/option-shape.d.ts +91 -0
- package/dist/esm/shared/validation/option-shape.js +24 -0
- package/dist/esm/shared/validation/options.d.ts +145 -0
- package/dist/esm/shared/validation/options.js +156 -0
- package/dist/esm/shared/validation/primitives.d.ts +292 -0
- package/dist/esm/shared/validation/primitives.js +100 -0
- package/dist/esm/shared/validation/ttl.d.ts +94 -0
- package/dist/esm/shared/validation/ttl.js +46 -0
- package/dist/esm/store/actions/list-namespaces.d.ts +79 -0
- package/dist/esm/store/actions/list-namespaces.js +86 -0
- package/dist/esm/store/actions/put.d.ts +43 -0
- package/dist/esm/store/actions/put.js +46 -0
- package/dist/esm/store/actions/reconcile-vector-index.d.ts +38 -0
- package/dist/esm/store/actions/reconcile-vector-index.js +10 -0
- package/dist/esm/store/actions/search.d.ts +38 -0
- package/dist/esm/store/actions/search.js +23 -0
- package/dist/esm/store/internal/batch-plan.d.ts +56 -0
- package/dist/esm/store/internal/batch-plan.js +28 -0
- package/dist/esm/store/internal/filter.d.ts +43 -0
- package/dist/esm/store/internal/filter.js +60 -0
- package/dist/esm/store/internal/get-item.d.ts +77 -0
- package/dist/esm/store/internal/get-item.js +54 -0
- package/dist/esm/store/internal/item-write.d.ts +270 -0
- package/dist/esm/store/internal/item-write.js +173 -0
- package/dist/esm/store/internal/parse.d.ts +230 -0
- package/dist/esm/store/internal/parse.js +169 -0
- package/dist/esm/store/internal/rows.d.ts +359 -0
- package/dist/esm/store/internal/rows.js +147 -0
- package/dist/esm/store/internal/semantic-search.d.ts +168 -0
- package/dist/esm/store/internal/semantic-search.js +200 -0
- package/dist/esm/store/internal/setup.d.ts +96 -0
- package/dist/esm/store/internal/setup.js +98 -0
- package/dist/esm/store/internal/table-search.d.ts +100 -0
- package/dist/esm/store/internal/table-search.js +119 -0
- package/dist/esm/store/internal/vector-index.d.ts +258 -0
- package/dist/esm/store/internal/vector-index.js +256 -0
- package/dist/esm/store/store.d.ts +329 -0
- package/dist/esm/store/store.js +93 -0
- package/dist/esm/store/types.d.ts +111 -0
- package/dist/esm/store/types.js +1 -0
- package/dist/esm/store/vector-backend.d.ts +104 -0
- package/dist/esm/store/vector-backend.js +1 -0
- package/package.json +68 -46
- package/dist/checkpointer/actions/delete-thread.d.ts +0 -10
- package/dist/checkpointer/actions/delete-thread.js +0 -38
- package/dist/checkpointer/actions/get-tuple.d.ts +0 -11
- package/dist/checkpointer/actions/get-tuple.js +0 -25
- package/dist/checkpointer/actions/list.d.ts +0 -20
- package/dist/checkpointer/actions/list.js +0 -113
- package/dist/checkpointer/actions/put-writes.d.ts +0 -15
- package/dist/checkpointer/actions/put-writes.js +0 -62
- package/dist/checkpointer/actions/put.d.ts +0 -17
- package/dist/checkpointer/actions/put.js +0 -73
- package/dist/checkpointer/internal/assemble.d.ts +0 -17
- package/dist/checkpointer/internal/assemble.js +0 -38
- package/dist/checkpointer/internal/checkpoint-write-verify.d.ts +0 -24
- package/dist/checkpointer/internal/checkpoint-write-verify.js +0 -67
- package/dist/checkpointer/internal/configurable.d.ts +0 -12
- package/dist/checkpointer/internal/configurable.js +0 -24
- package/dist/checkpointer/internal/fetch.d.ts +0 -19
- package/dist/checkpointer/internal/fetch.js +0 -88
- package/dist/checkpointer/internal/filter-match.d.ts +0 -13
- package/dist/checkpointer/internal/filter-match.js +0 -15
- package/dist/checkpointer/internal/item-reader.d.ts +0 -66
- package/dist/checkpointer/internal/item-reader.js +0 -113
- package/dist/checkpointer/internal/item-writer.d.ts +0 -35
- package/dist/checkpointer/internal/item-writer.js +0 -107
- package/dist/checkpointer/internal/keys.d.ts +0 -41
- package/dist/checkpointer/internal/keys.js +0 -117
- package/dist/checkpointer/internal/list-scope.d.ts +0 -61
- package/dist/checkpointer/internal/list-scope.js +0 -108
- package/dist/checkpointer/internal/pending-sends.d.ts +0 -13
- package/dist/checkpointer/internal/pending-sends.js +0 -29
- package/dist/checkpointer/internal/query.d.ts +0 -21
- package/dist/checkpointer/internal/query.js +0 -42
- package/dist/checkpointer/internal/regular-write.d.ts +0 -28
- package/dist/checkpointer/internal/regular-write.js +0 -66
- package/dist/checkpointer/internal/setup.d.ts +0 -33
- package/dist/checkpointer/internal/setup.js +0 -38
- package/dist/checkpointer/internal/special-write-cas.d.ts +0 -29
- package/dist/checkpointer/internal/special-write-cas.js +0 -104
- package/dist/checkpointer/internal/special-write-cleanup.d.ts +0 -23
- package/dist/checkpointer/internal/special-write-cleanup.js +0 -50
- package/dist/checkpointer/internal/special-write-verify.d.ts +0 -53
- package/dist/checkpointer/internal/special-write-verify.js +0 -80
- package/dist/checkpointer/internal/stored-channels.d.ts +0 -31
- package/dist/checkpointer/internal/stored-channels.js +0 -70
- package/dist/checkpointer/internal/validation.d.ts +0 -18
- package/dist/checkpointer/internal/validation.js +0 -40
- package/dist/checkpointer/internal/write-guard.d.ts +0 -20
- package/dist/checkpointer/internal/write-guard.js +0 -48
- package/dist/checkpointer/internal/write-index.d.ts +0 -36
- package/dist/checkpointer/internal/write-index.js +0 -41
- package/dist/checkpointer/saver.d.ts +0 -70
- package/dist/checkpointer/saver.js +0 -105
- package/dist/checkpointer/types.d.ts +0 -58
- package/dist/factory/factory.d.ts +0 -40
- package/dist/factory/factory.js +0 -87
- package/dist/history/actions/add-messages.d.ts +0 -15
- package/dist/history/actions/add-messages.js +0 -77
- package/dist/history/actions/clear.d.ts +0 -10
- package/dist/history/actions/clear.js +0 -34
- package/dist/history/actions/get-messages.d.ts +0 -17
- package/dist/history/actions/get-messages.js +0 -79
- package/dist/history/actions/list-sessions.d.ts +0 -13
- package/dist/history/actions/list-sessions.js +0 -53
- package/dist/history/actions/reconcile-count.d.ts +0 -12
- package/dist/history/actions/reconcile-count.js +0 -64
- package/dist/history/chat-message-history.d.ts +0 -73
- package/dist/history/chat-message-history.js +0 -111
- package/dist/history/internal/append-saga.d.ts +0 -25
- package/dist/history/internal/append-saga.js +0 -79
- package/dist/history/internal/compensation.d.ts +0 -25
- package/dist/history/internal/compensation.js +0 -92
- package/dist/history/internal/item-mapper.d.ts +0 -9
- package/dist/history/internal/item-mapper.js +0 -27
- package/dist/history/internal/keys.d.ts +0 -16
- package/dist/history/internal/keys.js +0 -48
- package/dist/history/internal/message-chunker.d.ts +0 -13
- package/dist/history/internal/message-chunker.js +0 -67
- package/dist/history/internal/message-transaction.d.ts +0 -25
- package/dist/history/internal/message-transaction.js +0 -61
- package/dist/history/internal/message-window.d.ts +0 -17
- package/dist/history/internal/message-window.js +0 -49
- package/dist/history/internal/query.d.ts +0 -23
- package/dist/history/internal/query.js +0 -39
- package/dist/history/internal/session-count.d.ts +0 -47
- package/dist/history/internal/session-count.js +0 -115
- package/dist/history/internal/session-title.d.ts +0 -19
- package/dist/history/internal/session-title.js +0 -43
- package/dist/history/internal/session-update.d.ts +0 -27
- package/dist/history/internal/session-update.js +0 -69
- package/dist/history/internal/setup.d.ts +0 -31
- package/dist/history/internal/setup.js +0 -43
- package/dist/history/internal/title-generator.d.ts +0 -12
- package/dist/history/internal/title-generator.js +0 -41
- package/dist/history/internal/ttl-anchor.d.ts +0 -24
- package/dist/history/internal/ttl-anchor.js +0 -38
- package/dist/history/internal/validation.d.ts +0 -25
- package/dist/history/internal/validation.js +0 -53
- package/dist/history/session-adapter.d.ts +0 -29
- package/dist/history/session-adapter.js +0 -35
- package/dist/history/types.d.ts +0 -69
- package/dist/index.d.ts +0 -29
- package/dist/index.js +0 -32
- package/dist/shared/clock.d.ts +0 -8
- package/dist/shared/clock.js +0 -16
- package/dist/shared/codec/codec.d.ts +0 -53
- package/dist/shared/codec/codec.js +0 -66
- package/dist/shared/codec/compression.d.ts +0 -24
- package/dist/shared/codec/compression.js +0 -48
- package/dist/shared/codec/descriptor-keys.d.ts +0 -12
- package/dist/shared/codec/descriptor-keys.js +0 -14
- package/dist/shared/codec/encode.d.ts +0 -13
- package/dist/shared/codec/encode.js +0 -43
- package/dist/shared/codec/json-serde.d.ts +0 -7
- package/dist/shared/codec/json-serde.js +0 -17
- package/dist/shared/codec/payload-loss.d.ts +0 -12
- package/dist/shared/codec/payload-loss.js +0 -38
- package/dist/shared/codec/s3/adapter-config.d.ts +0 -13
- package/dist/shared/codec/s3/adapter-config.js +0 -22
- package/dist/shared/codec/s3/bounded-body.d.ts +0 -14
- package/dist/shared/codec/s3/bounded-body.js +0 -47
- package/dist/shared/codec/s3/client.d.ts +0 -18
- package/dist/shared/codec/s3/client.js +0 -46
- package/dist/shared/codec/s3/config.d.ts +0 -51
- package/dist/shared/codec/s3/config.js +0 -58
- package/dist/shared/codec/s3/delete.d.ts +0 -7
- package/dist/shared/codec/s3/delete.js +0 -28
- package/dist/shared/codec/s3/key-scope.d.ts +0 -23
- package/dist/shared/codec/s3/key-scope.js +0 -44
- package/dist/shared/codec/s3/lifecycle.d.ts +0 -14
- package/dist/shared/codec/s3/lifecycle.js +0 -63
- package/dist/shared/codec/s3/offloader.d.ts +0 -44
- package/dist/shared/codec/s3/offloader.js +0 -118
- package/dist/shared/codec/s3/orphans.d.ts +0 -23
- package/dist/shared/codec/s3/orphans.js +0 -71
- package/dist/shared/codec/s3/read-write.d.ts +0 -18
- package/dist/shared/codec/s3/read-write.js +0 -51
- package/dist/shared/codec/s3/retry.d.ts +0 -5
- package/dist/shared/codec/s3/retry.js +0 -22
- package/dist/shared/concurrency.d.ts +0 -6
- package/dist/shared/constants.d.ts +0 -112
- package/dist/shared/constants.js +0 -115
- package/dist/shared/dynamodb/abort.d.ts +0 -9
- package/dist/shared/dynamodb/abort.js +0 -27
- package/dist/shared/dynamodb/backoff.d.ts +0 -15
- package/dist/shared/dynamodb/backoff.js +0 -48
- package/dist/shared/dynamodb/batch-write.d.ts +0 -22
- package/dist/shared/dynamodb/batch-write.js +0 -53
- package/dist/shared/dynamodb/cancellation.d.ts +0 -6
- package/dist/shared/dynamodb/cancellation.js +0 -7
- package/dist/shared/dynamodb/client.d.ts +0 -28
- package/dist/shared/dynamodb/conditional-put.d.ts +0 -67
- package/dist/shared/dynamodb/conditional-put.js +0 -76
- package/dist/shared/dynamodb/drain-unprocessed.d.ts +0 -21
- package/dist/shared/dynamodb/drain-unprocessed.js +0 -43
- package/dist/shared/dynamodb/expiry.d.ts +0 -16
- package/dist/shared/dynamodb/expiry.js +0 -29
- package/dist/shared/dynamodb/paginate-core.d.ts +0 -24
- package/dist/shared/dynamodb/paginate-core.js +0 -82
- package/dist/shared/dynamodb/paginate.d.ts +0 -14
- package/dist/shared/dynamodb/paginate.js +0 -19
- package/dist/shared/dynamodb/partition-delete.d.ts +0 -39
- package/dist/shared/dynamodb/partition-delete.js +0 -71
- package/dist/shared/dynamodb/retry-classifier.d.ts +0 -17
- package/dist/shared/dynamodb/retry-classifier.js +0 -118
- package/dist/shared/dynamodb/retry-policy.d.ts +0 -26
- package/dist/shared/dynamodb/retry-policy.js +0 -22
- package/dist/shared/dynamodb/retry.d.ts +0 -31
- package/dist/shared/dynamodb/retry.js +0 -57
- package/dist/shared/dynamodb/scan.d.ts +0 -14
- package/dist/shared/dynamodb/scan.js +0 -19
- package/dist/shared/dynamodb/types.d.ts +0 -23
- package/dist/shared/errors/base-error.d.ts +0 -30
- package/dist/shared/errors/base-error.js +0 -27
- package/dist/shared/errors/boundary.d.ts +0 -18
- package/dist/shared/errors/boundary.js +0 -46
- package/dist/shared/errors/error-code.d.ts +0 -13
- package/dist/shared/errors/errors.d.ts +0 -68
- package/dist/shared/errors/errors.js +0 -114
- package/dist/shared/errors/upstream-error.d.ts +0 -16
- package/dist/shared/errors/upstream-error.js +0 -27
- package/dist/shared/errors/wrap-error.d.ts +0 -7
- package/dist/shared/errors/wrap-error.js +0 -15
- package/dist/shared/logging/logger.d.ts +0 -18
- package/dist/shared/logging/logger.js +0 -15
- package/dist/shared/logging/redaction-walk.d.ts +0 -23
- package/dist/shared/logging/redaction-walk.js +0 -112
- package/dist/shared/logging/redaction.d.ts +0 -39
- package/dist/shared/logging/redaction.js +0 -75
- package/dist/shared/logging/secret-patterns.d.ts +0 -92
- package/dist/shared/logging/secret-patterns.js +0 -133
- package/dist/shared/options.d.ts +0 -37
- package/dist/shared/ulid.d.ts +0 -23
- package/dist/shared/validation/options.d.ts +0 -8
- package/dist/shared/validation/options.js +0 -90
- package/dist/shared/validation/primitives.d.ts +0 -29
- package/dist/shared/validation/primitives.js +0 -82
- package/dist/shared/validation/ttl.d.ts +0 -28
- package/dist/shared/validation/ttl.js +0 -52
- package/dist/store/actions/get.d.ts +0 -13
- package/dist/store/actions/get.js +0 -73
- package/dist/store/actions/list-namespaces.d.ts +0 -8
- package/dist/store/actions/list-namespaces.js +0 -59
- package/dist/store/actions/put.d.ts +0 -10
- package/dist/store/actions/put.js +0 -96
- package/dist/store/actions/reconcile-vector-index.d.ts +0 -18
- package/dist/store/actions/reconcile-vector-index.js +0 -26
- package/dist/store/actions/search.d.ts +0 -9
- package/dist/store/actions/search.js +0 -34
- package/dist/store/internal/backend-search.d.ts +0 -4
- package/dist/store/internal/backend-search.js +0 -74
- package/dist/store/internal/batch-plan.d.ts +0 -11
- package/dist/store/internal/batch-plan.js +0 -52
- package/dist/store/internal/candidates.d.ts +0 -23
- package/dist/store/internal/candidates.js +0 -94
- package/dist/store/internal/filter.d.ts +0 -9
- package/dist/store/internal/filter.js +0 -85
- package/dist/store/internal/index-reconcile.d.ts +0 -21
- package/dist/store/internal/index-reconcile.js +0 -118
- package/dist/store/internal/index-sync.d.ts +0 -10
- package/dist/store/internal/index-sync.js +0 -25
- package/dist/store/internal/item-mapper.d.ts +0 -27
- package/dist/store/internal/item-mapper.js +0 -61
- package/dist/store/internal/keys.d.ts +0 -17
- package/dist/store/internal/keys.js +0 -41
- package/dist/store/internal/namespace-match.d.ts +0 -11
- package/dist/store/internal/namespace-match.js +0 -40
- package/dist/store/internal/option-validation.d.ts +0 -13
- package/dist/store/internal/option-validation.js +0 -77
- package/dist/store/internal/overwrite-swap.d.ts +0 -32
- package/dist/store/internal/overwrite-swap.js +0 -68
- package/dist/store/internal/persist.d.ts +0 -28
- package/dist/store/internal/persist.js +0 -64
- package/dist/store/internal/query.d.ts +0 -11
- package/dist/store/internal/query.js +0 -48
- package/dist/store/internal/ranker.d.ts +0 -18
- package/dist/store/internal/ranker.js +0 -39
- package/dist/store/internal/read-existing.d.ts +0 -23
- package/dist/store/internal/read-existing.js +0 -41
- package/dist/store/internal/score-direction.d.ts +0 -31
- package/dist/store/internal/score-direction.js +0 -38
- package/dist/store/internal/search-filter.d.ts +0 -3
- package/dist/store/internal/search-filter.js +0 -10
- package/dist/store/internal/semantic-search.d.ts +0 -34
- package/dist/store/internal/semantic-search.js +0 -87
- package/dist/store/internal/setup.d.ts +0 -36
- package/dist/store/internal/setup.js +0 -40
- package/dist/store/internal/text-path.d.ts +0 -17
- package/dist/store/internal/validation.d.ts +0 -18
- package/dist/store/internal/validation.js +0 -51
- package/dist/store/internal/write-verify.d.ts +0 -42
- package/dist/store/internal/write-verify.js +0 -71
- package/dist/store/store.d.ts +0 -61
- package/dist/store/store.js +0 -107
- package/dist/store/types.d.ts +0 -50
- package/dist/store/types.js +0 -2
- package/dist/store/vector-backend.d.ts +0 -43
- package/dist/store/vector-backend.js +0 -2
- /package/dist/{checkpointer → cjs/checkpointer}/types.js +0 -0
- /package/dist/{factory → cjs/factory}/types.js +0 -0
- /package/dist/{history → cjs/history}/types.js +0 -0
- /package/dist/{shared → cjs/shared}/options.js +0 -0
- /package/dist/{shared/dynamodb → cjs/store}/types.js +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides which options every adapter shares.
|
|
3
|
+
*
|
|
4
|
+
* The table, the client, the ttl, the logger, the retry policy, the recency
|
|
5
|
+
* index, the read concurrency, the codec options and per-call cancellation are
|
|
6
|
+
* declared once here, so the checkpointer, the store and the history accept
|
|
7
|
+
* the same keys with the same meaning, and an adapter-wide option is added in
|
|
8
|
+
* one place. This module holds their types only; checking them is elsewhere.
|
|
9
|
+
*/
|
|
10
|
+
import type { DynamoDBClientConfig } from '@aws-sdk/client-dynamodb';
|
|
11
|
+
import type { CompressionConfig } from './codec/compression.js';
|
|
12
|
+
import type { S3OffloadConfig } from './codec/s3/config.js';
|
|
13
|
+
import type { DynamoDBDocumentLike } from './dynamodb/client.js';
|
|
14
|
+
import type { RetryPolicy } from './dynamodb/retry.js';
|
|
15
|
+
import type { Logger } from './logging/logger.js';
|
|
16
|
+
import type { TtlOption } from './validation/ttl.js';
|
|
17
|
+
/**
|
|
18
|
+
* Options common to every adapter (the unified options shape). An adapter
|
|
19
|
+
* either reuses an injected `client` or builds one from `clientConfig`.
|
|
20
|
+
*/
|
|
21
|
+
export interface BaseAdapterOptions {
|
|
22
|
+
/** DynamoDB table name. */
|
|
23
|
+
tableName: string;
|
|
24
|
+
/** Pre-built DocumentClient to reuse; when set, the adapter does not own it. */
|
|
25
|
+
client?: DynamoDBDocumentLike;
|
|
26
|
+
/** The config a client is built from when `client` is not provided. */
|
|
27
|
+
clientConfig?: DynamoDBClientConfig;
|
|
28
|
+
/** Optional time-to-live applied to written items. */
|
|
29
|
+
ttl?: TtlOption;
|
|
30
|
+
/** Optional per-instance logger (defaults to a silent logger). */
|
|
31
|
+
logger?: Logger;
|
|
32
|
+
/** Retry budget and backoff for every DynamoDB call (see the README "Retries and backoff"). */
|
|
33
|
+
retry?: RetryPolicy;
|
|
34
|
+
/**
|
|
35
|
+
* Index partitions per adapter in the recency index (GSI1), default 8.
|
|
36
|
+
*
|
|
37
|
+
* Checkpoint and session rows carry the index attributes whether or not the
|
|
38
|
+
* table defines the index, so enabling it later needs only a backfill of the
|
|
39
|
+
* rows written before. The value is fixed for the table's life. Every row
|
|
40
|
+
* keeps the shard it was written with, and `backfillRecencyIndex` writes
|
|
41
|
+
* keys only to rows that have none, so it cannot move a row. Raising the
|
|
42
|
+
* count is safe: the old shards stay among the ones a listing queries.
|
|
43
|
+
* Lowering it hides every row on a dropped shard from the listings. The
|
|
44
|
+
* store takes no `indexShards`.
|
|
45
|
+
*
|
|
46
|
+
* A single index partition per adapter would concentrate every listing on
|
|
47
|
+
* one partition, which is worse than the table scan it replaces.
|
|
48
|
+
*/
|
|
49
|
+
indexShards?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Name of the recency index (a GSI on `gsi1pk`/`gsi1sk`) on this table.
|
|
52
|
+
*
|
|
53
|
+
* Opt-in on purpose: whether the table carries the index is deployment
|
|
54
|
+
* configuration the operator knows, and probing for it would spend a failed
|
|
55
|
+
* request per process to find out. Naming it switches two listings that
|
|
56
|
+
* would otherwise scan the whole table onto a read of the index, newest
|
|
57
|
+
* first: `history.listSessions`, which pages it by cursor, and a
|
|
58
|
+
* `saver.list` without a `thread_id`, which streams it and takes no cursor.
|
|
59
|
+
* Leaving it unset keeps both on the table scan, so the index can be created
|
|
60
|
+
* and backfilled before any adapter reads it.
|
|
61
|
+
*
|
|
62
|
+
* The store takes no `indexName`: its rootless search and its namespace
|
|
63
|
+
* listing stay table scans.
|
|
64
|
+
*/
|
|
65
|
+
indexName?: string;
|
|
66
|
+
/**
|
|
67
|
+
* How many payloads a single call decodes at once, default 8.
|
|
68
|
+
*
|
|
69
|
+
* It is the multiplier on this package's memory ceiling, which is
|
|
70
|
+
* `readConcurrency × (s3.maxDownloadBytes + compression.maxDecompressedBytes)`
|
|
71
|
+
* — a downloaded object and its decompressed form are both resident while a
|
|
72
|
+
* payload is decoded, and that much can be in flight for each concurrent
|
|
73
|
+
* decode. Lower it on a small container; raising it trades memory for
|
|
74
|
+
* latency on reads that fetch many offloaded payloads.
|
|
75
|
+
*
|
|
76
|
+
* It also bounds how many recency-index shards one listing queries at once.
|
|
77
|
+
*/
|
|
78
|
+
readConcurrency?: number;
|
|
79
|
+
}
|
|
80
|
+
/** Options enabling payload compression and/or S3 offloading. */
|
|
81
|
+
export interface CodecOptions {
|
|
82
|
+
/** Gzip compression configuration. */
|
|
83
|
+
compression?: CompressionConfig;
|
|
84
|
+
/** S3 offload configuration for payloads over DynamoDB's item limit. */
|
|
85
|
+
s3?: S3OffloadConfig;
|
|
86
|
+
}
|
|
87
|
+
/** Per-call cancellation for the long-running adapter methods. */
|
|
88
|
+
export interface CancelOptions {
|
|
89
|
+
/**
|
|
90
|
+
* Aborting it rejects the call with an `ABORTED` error — carrying the abort
|
|
91
|
+
* reason as `cause` — whether the signal was already aborted (nothing is
|
|
92
|
+
* sent), aborts while the call waits between requests, or aborts while a
|
|
93
|
+
* request is in flight: the signal reaches the AWS SDK on every DynamoDB
|
|
94
|
+
* request and S3 transfer the call makes for you, so the request itself
|
|
95
|
+
* ends. The verification reads and the cleanup that follow a failure run to
|
|
96
|
+
* completion regardless. A value that is not `AbortSignal`-shaped is refused
|
|
97
|
+
* with `VALIDATION` naming `signal` before anything is sent.
|
|
98
|
+
*/
|
|
99
|
+
signal?: AbortSignal;
|
|
100
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides how a sortable, unique id is made from the clock and random bytes.
|
|
3
|
+
*
|
|
4
|
+
* A caller gets ids whose byte order is their creation order, and a prefix
|
|
5
|
+
* that bounds every id from a given millisecond, without knowing the alphabet,
|
|
6
|
+
* the width of the time field or where the randomness comes from. One
|
|
7
|
+
* generator's ids strictly increase whatever the clock does, and
|
|
8
|
+
* `ulidTimePrefix` refuses a millisecond the encoding cannot hold rather than
|
|
9
|
+
* wrapping it, so a caller building a bound from a raw millisecond cannot be
|
|
10
|
+
* handed a silently wrong one.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* One past the last millisecond ten base-32 characters can hold: `32^10`,
|
|
14
|
+
* which is `2^50`, and lands in the year 37648. Derived rather than written
|
|
15
|
+
* down, so widening {@link TIME_CHARS} moves the rule with it.
|
|
16
|
+
*/
|
|
17
|
+
export declare const ULID_TIME_RANGE_MS: number;
|
|
18
|
+
/**
|
|
19
|
+
* A CSPRNG-backed `rng` seam.
|
|
20
|
+
*
|
|
21
|
+
* Accepts: nothing. Each returned generator owns its own pool.
|
|
22
|
+
*
|
|
23
|
+
* Returns: a function yielding uniform values in `[0, 1)`, one byte per call,
|
|
24
|
+
* refilling from `crypto.randomBytes` every {@link RNG_POOL_BYTES} — so a burst
|
|
25
|
+
* of ids costs one syscall per 256 digits rather than one per digit.
|
|
26
|
+
*
|
|
27
|
+
* Throws: whatever `crypto.randomBytes` throws when the platform has no entropy.
|
|
28
|
+
*
|
|
29
|
+
* Guarantees: a digit drawn as `floor(rng() * 32)` is uniform over 0..31 —
|
|
30
|
+
* 256 is a whole multiple of 32, so there is no modulo bias. `Math.random`
|
|
31
|
+
* would order and disambiguate just as well but is not a cryptographically
|
|
32
|
+
* secure source, which the ULID spec asks for in identifier generation.
|
|
33
|
+
*/
|
|
34
|
+
export declare function secureRng(): () => number;
|
|
35
|
+
/**
|
|
36
|
+
* The 10 time characters every ULID generated at `timeMs` starts with.
|
|
37
|
+
*
|
|
38
|
+
* Accepts: `timeMs` — epoch milliseconds inside `[0, {@link
|
|
39
|
+
* ULID_TIME_RANGE_MS})`, which is every instant the ten characters can encode.
|
|
40
|
+
*
|
|
41
|
+
* Returns: the prefix, usable as a sort-key bound — every id from that
|
|
42
|
+
* millisecond onward sorts at or after it, every earlier id before it.
|
|
43
|
+
*
|
|
44
|
+
* Throws: `VALIDATION` for a millisecond outside the range, naming no field:
|
|
45
|
+
* no caller-supplied option is at fault here, and the rule a caller meets is
|
|
46
|
+
* `parseMessageWindow`'s, which names `before`. This guard is the invariant
|
|
47
|
+
* underneath it, so no second caller can rebuild the bound that broke.
|
|
48
|
+
*
|
|
49
|
+
* Guarantees: exactly ten characters, all of them from the ULID alphabet.
|
|
50
|
+
* Neither held before. A negative millisecond took a negative remainder into
|
|
51
|
+
* the alphabet and yielded `undefined` per character, so the bound read
|
|
52
|
+
* `undefinedundefined…` — which sorts *above* every real id, since `u` and `d`
|
|
53
|
+
* are both above `Z` — and a window asking for messages before 1969 matched
|
|
54
|
+
* the whole conversation instead of none of it. A millisecond at or past the
|
|
55
|
+
* range wrapped to `0000000000` and matched nothing at all. Both are garbage
|
|
56
|
+
* indistinguishable from a real answer, so both are refused rather than
|
|
57
|
+
* clamped: clamping would hand back the same wrong page under a different
|
|
58
|
+
* name.
|
|
59
|
+
*/
|
|
60
|
+
export declare function ulidTimePrefix(timeMs: number): string;
|
|
61
|
+
/**
|
|
62
|
+
* A monotonic ULID generator.
|
|
63
|
+
*
|
|
64
|
+
* Accepts: `now` — epoch milliseconds, default `Date.now`. `rng` — values in
|
|
65
|
+
* `[0, 1)`, default {@link secureRng}. Both are seams for deterministic tests.
|
|
66
|
+
*
|
|
67
|
+
* Returns: a function yielding lexicographically sortable 26-character ids
|
|
68
|
+
* whose first 10 characters encode the millisecond.
|
|
69
|
+
*
|
|
70
|
+
* Throws: whatever `rng` throws.
|
|
71
|
+
*
|
|
72
|
+
* Guarantees: ids from **one** generator strictly increase, whatever the clock
|
|
73
|
+
* does. A clock that advances starts a fresh random component; a clock that
|
|
74
|
+
* stalls or regresses reuses the last timestamp and increments that component;
|
|
75
|
+
* an increment that exhausts all 16 digits carries into the timestamp and draws
|
|
76
|
+
* fresh digits. Two generators — two processes, or two adapter instances —
|
|
77
|
+
* order only by their wall clocks at millisecond precision, so a lagging clock
|
|
78
|
+
* can sort a later id before an earlier one.
|
|
79
|
+
*/
|
|
80
|
+
export declare function createUlidFactory(now?: () => number, rng?: () => number): () => string;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { randomBytes } from 'node:crypto';
|
|
2
|
+
import { validationError } from './errors/errors.js';
|
|
3
|
+
const ENCODING = '0123456789ABCDEFGHJKMNPQRSTVWXYZ';
|
|
4
|
+
const ENCODING_LEN = 32;
|
|
5
|
+
const TIME_CHARS = 10;
|
|
6
|
+
const RANDOM_CHARS = 16;
|
|
7
|
+
export const ULID_TIME_RANGE_MS = ENCODING_LEN ** TIME_CHARS;
|
|
8
|
+
const RNG_POOL_BYTES = 256;
|
|
9
|
+
export function secureRng() {
|
|
10
|
+
let pool = Buffer.alloc(0);
|
|
11
|
+
let offset = 0;
|
|
12
|
+
return () => {
|
|
13
|
+
if (offset >= pool.length) {
|
|
14
|
+
pool = randomBytes(RNG_POOL_BYTES);
|
|
15
|
+
offset = 0;
|
|
16
|
+
}
|
|
17
|
+
const byte = pool[offset];
|
|
18
|
+
offset += 1;
|
|
19
|
+
return byte / 256;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
function encodeTime(timeMs) {
|
|
23
|
+
let remaining = Math.floor(timeMs);
|
|
24
|
+
let out = '';
|
|
25
|
+
for (let i = 0; i < TIME_CHARS; i++) {
|
|
26
|
+
out = ENCODING[remaining % ENCODING_LEN] + out;
|
|
27
|
+
remaining = Math.floor(remaining / ENCODING_LEN);
|
|
28
|
+
}
|
|
29
|
+
return out;
|
|
30
|
+
}
|
|
31
|
+
export function ulidTimePrefix(timeMs) {
|
|
32
|
+
if (!(timeMs >= 0 && timeMs < ULID_TIME_RANGE_MS)) {
|
|
33
|
+
throw validationError(`a ULID time prefix covers epoch milliseconds 0 to ${ULID_TIME_RANGE_MS - 1} (the year ` +
|
|
34
|
+
`37648); ${timeMs} is outside it and has no ten-character encoding`);
|
|
35
|
+
}
|
|
36
|
+
return encodeTime(timeMs);
|
|
37
|
+
}
|
|
38
|
+
function randomDigits(rng) {
|
|
39
|
+
const digits = [];
|
|
40
|
+
for (let i = 0; i < RANDOM_CHARS; i++) {
|
|
41
|
+
digits.push(Math.floor(rng() * ENCODING_LEN));
|
|
42
|
+
}
|
|
43
|
+
return digits;
|
|
44
|
+
}
|
|
45
|
+
function incrementDigits(digits) {
|
|
46
|
+
const next = [...digits];
|
|
47
|
+
for (let i = RANDOM_CHARS - 1; i >= 0; i--) {
|
|
48
|
+
if (next[i] < ENCODING_LEN - 1) {
|
|
49
|
+
next[i] += 1;
|
|
50
|
+
return { digits: next, overflowed: false };
|
|
51
|
+
}
|
|
52
|
+
next[i] = 0;
|
|
53
|
+
}
|
|
54
|
+
return { digits: next, overflowed: true };
|
|
55
|
+
}
|
|
56
|
+
export function createUlidFactory(now = Date.now, rng = secureRng()) {
|
|
57
|
+
let lastTime = -1;
|
|
58
|
+
let lastRandom = [];
|
|
59
|
+
return () => {
|
|
60
|
+
const time = now();
|
|
61
|
+
if (time > lastTime) {
|
|
62
|
+
lastTime = time;
|
|
63
|
+
lastRandom = randomDigits(rng);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
const result = incrementDigits(lastRandom);
|
|
67
|
+
if (result.overflowed) {
|
|
68
|
+
lastTime += 1;
|
|
69
|
+
lastRandom = randomDigits(rng);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
lastRandom = result.digits;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return encodeTime(lastTime) + lastRandom.map((digit) => ENCODING[digit]).join('');
|
|
76
|
+
};
|
|
77
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides what a collaborator a caller hands in must offer.
|
|
3
|
+
*
|
|
4
|
+
* An injected client, logger, serde, embeddings model or vector backend is
|
|
5
|
+
* checked by the members this package calls on it, and a cancellation signal
|
|
6
|
+
* — at construction or on a single call's options — by the members an
|
|
7
|
+
* `AbortSignal` has, so a wrong object fails where it was passed and not at the
|
|
8
|
+
* first call deep inside an operation.
|
|
9
|
+
*/
|
|
10
|
+
import type { CancelOptions } from '../options.js';
|
|
11
|
+
/** The `DynamoDBDocument` methods this package calls on an injected `client`. */
|
|
12
|
+
export declare const CLIENT_MEMBERS: readonly string[];
|
|
13
|
+
/** The `Logger` methods every adapter calls. */
|
|
14
|
+
export declare const LOGGER_MEMBERS: readonly string[];
|
|
15
|
+
/** The `SerializerProtocol` methods this package calls on `serde`. */
|
|
16
|
+
export declare const SERDE_MEMBERS: readonly string[];
|
|
17
|
+
/** The `Embeddings` methods this package calls on `index.embeddings`. */
|
|
18
|
+
export declare const EMBEDDINGS_MEMBERS: readonly string[];
|
|
19
|
+
/**
|
|
20
|
+
* The `VectorBackend` methods this package calls. `listKeys` is deliberately
|
|
21
|
+
* excluded: it is optional on the interface (`store/vector-backend.ts`), and
|
|
22
|
+
* `reconcileVectorIndex` already branches on its absence and logs instead of
|
|
23
|
+
* requiring it — requiring it here would refuse a backend shape this package
|
|
24
|
+
* documents and supports.
|
|
25
|
+
*/
|
|
26
|
+
export declare const VECTOR_BACKEND_MEMBERS: readonly string[];
|
|
27
|
+
/**
|
|
28
|
+
* Every `AbortSignal` member this package uses on a caller's `signal`, with
|
|
29
|
+
* the `typeof` each must have: `aborted` is read before a request and between
|
|
30
|
+
* pages, and the wait between retries attaches an abort listener and removes
|
|
31
|
+
* it again from inside its timer. `reason` is only read, which is safe on any
|
|
32
|
+
* object, so it is not required.
|
|
33
|
+
*/
|
|
34
|
+
export declare const ABORT_SIGNAL_MEMBERS: Readonly<Record<string, 'boolean' | 'function'>>;
|
|
35
|
+
/**
|
|
36
|
+
* Refuse a collaborator missing a method this package calls.
|
|
37
|
+
*
|
|
38
|
+
* Checked by shape, never `instanceof`: the rule is banned repo-wide, and a
|
|
39
|
+
* duck-typed check also survives two copies of a dependency in one tree, which
|
|
40
|
+
* is exactly the situation an injected client comes from.
|
|
41
|
+
*
|
|
42
|
+
* Accepts: `value` — the collaborator as the caller gave it. `members` — every
|
|
43
|
+
* method this package calls on it. `field` — what the error names.
|
|
44
|
+
*
|
|
45
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
46
|
+
* checks it.
|
|
47
|
+
*
|
|
48
|
+
* Throws: `VALIDATION` naming `field` for a non-object, `null` or an array,
|
|
49
|
+
* and `field.member` for the first missing method — naming which member is
|
|
50
|
+
* missing is what turns a first-request crash into a startup error a caller
|
|
51
|
+
* can act on. An array is refused as a whole rather than reported as missing
|
|
52
|
+
* its first method, which would point the caller at a method instead of at
|
|
53
|
+
* the value.
|
|
54
|
+
*/
|
|
55
|
+
export declare function assertMembers(value: object, members: readonly string[], field: string): void;
|
|
56
|
+
/**
|
|
57
|
+
* Refuse an injected client whose document translation changes what this
|
|
58
|
+
* package writes or reads back.
|
|
59
|
+
*
|
|
60
|
+
* Accepts: `client` — the injected document client, or any object standing in
|
|
61
|
+
* for one; one without `config.translateConfig` translates the default way.
|
|
62
|
+
*
|
|
63
|
+
* Returns: nothing: the client is kept under its declared type, and this checks it.
|
|
64
|
+
*
|
|
65
|
+
* Throws: `VALIDATION` naming `client` when its `unmarshallOptions.wrapNumbers`
|
|
66
|
+
* is set — every number this package reads back (a row's format version, a
|
|
67
|
+
* `ttl`, a message count) would arrive wrapped, so a newer row would read as
|
|
68
|
+
* version 0 and a session as malformed — or when its
|
|
69
|
+
* `marshallOptions.convertEmptyValues` is on, which stores the root checkpoint
|
|
70
|
+
* namespace, the empty string, as NULL.
|
|
71
|
+
*/
|
|
72
|
+
export declare function assertClientTranslation(client: object): void;
|
|
73
|
+
/**
|
|
74
|
+
* Validate the collaborators every adapter shares: `client`, `logger` and
|
|
75
|
+
* `serde`. Pulled out of each `setUp*` as one call rather than three inline
|
|
76
|
+
* checks, so the three adapters check them the same way.
|
|
77
|
+
*
|
|
78
|
+
* Accepts: `options` — the adapter options, narrowed to the three shared
|
|
79
|
+
* collaborator fields. Every field here is typed as `object`, which a real
|
|
80
|
+
* `DynamoDBDocument`, `Logger` or `SerializerProtocol` all satisfy, so any
|
|
81
|
+
* adapter's options type is assignable without a cast.
|
|
82
|
+
*
|
|
83
|
+
* Returns: nothing: each collaborator given is kept under its declared type,
|
|
84
|
+
* and this checks it. A collaborator the caller did not supply is left
|
|
85
|
+
* untouched, so it still reaches its default.
|
|
86
|
+
*
|
|
87
|
+
* Throws: see {@link assertMembers} for a collaborator missing a method, and
|
|
88
|
+
* {@link assertClientTranslation} for a `client` whose translation would
|
|
89
|
+
* change how a row reads back.
|
|
90
|
+
*/
|
|
91
|
+
export declare function assertBaseCollaborators(options: {
|
|
92
|
+
client?: object;
|
|
93
|
+
logger?: object;
|
|
94
|
+
serde?: object;
|
|
95
|
+
}): void;
|
|
96
|
+
/**
|
|
97
|
+
* A value usable as an `AbortSignal`, checked by shape.
|
|
98
|
+
*
|
|
99
|
+
* `signal` is not a method bag like the collaborators above, so this returns
|
|
100
|
+
* a boolean rather than throwing: it never needs to be paired with the
|
|
101
|
+
* caller's own decision about what an absent signal means.
|
|
102
|
+
*
|
|
103
|
+
* Accepts: `value` — the caller's `signal`, or `undefined`.
|
|
104
|
+
*
|
|
105
|
+
* Returns: `true` when `value` is a non-null object whose every member in
|
|
106
|
+
* {@link ABORT_SIGNAL_MEMBERS} has the type listed there — `false` otherwise,
|
|
107
|
+
* including for `undefined`.
|
|
108
|
+
*
|
|
109
|
+
* Throws: nothing.
|
|
110
|
+
*/
|
|
111
|
+
export declare function isAbortSignalLike(value: AbortSignal | undefined): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* Throw `VALIDATION` naming `field` unless `value` is absent or
|
|
114
|
+
* {@link isAbortSignalLike}.
|
|
115
|
+
*
|
|
116
|
+
* Accepts: `value` — a caller's signal, or `undefined`. `field` — what the
|
|
117
|
+
* error names; `signal` by default, and the full path for a signal nested in
|
|
118
|
+
* another option (`retry.signal`), so a caller whose top-level `signal` is
|
|
119
|
+
* valid is not pointed at it.
|
|
120
|
+
*
|
|
121
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
122
|
+
* checks it.
|
|
123
|
+
*
|
|
124
|
+
* Throws: `VALIDATION` naming `field`. Left unchecked, a value that is not
|
|
125
|
+
* an `AbortSignal` reaches whatever this package hands it to — an
|
|
126
|
+
* `addEventListener` call, a retry loop reading `.aborted`, a
|
|
127
|
+
* `removeEventListener` call from inside a timer, where nothing can catch it —
|
|
128
|
+
* and fails there with a raw, unrelated error instead of naming the option
|
|
129
|
+
* that caused it.
|
|
130
|
+
*/
|
|
131
|
+
export declare function assertSignalLike(value: AbortSignal | undefined, field?: string): void;
|
|
132
|
+
/**
|
|
133
|
+
* The keys of a cancellation-only option bag, exhaustive in both directions.
|
|
134
|
+
*
|
|
135
|
+
* Every feature's own option-bag lists live in that feature's `internal/`
|
|
136
|
+
* directory, beside the types they are checked against;
|
|
137
|
+
* `shared/` knows no feature. This one stays here because `CancelOptions` is
|
|
138
|
+
* shared by all three. `allKeysOf<T>` keeps the list from drifting from the
|
|
139
|
+
* type it guards: an exhaustive list compiles, omitting or inventing a key
|
|
140
|
+
* does not.
|
|
141
|
+
*/
|
|
142
|
+
export declare const CANCEL_KEYS: readonly string[];
|
|
143
|
+
/**
|
|
144
|
+
* Reject a `{ signal }` bag carrying a key this package does not read.
|
|
145
|
+
*
|
|
146
|
+
* Pulled out as one call because several methods across three classes take
|
|
147
|
+
* only cancellation (`addMessages`, `addMessage`, `clear`,
|
|
148
|
+
* `reconcileMessageCount`, `deleteThread`, `reconcileVectorIndex`) — one
|
|
149
|
+
* shared check keeps their wording and their key list from drifting apart.
|
|
150
|
+
*
|
|
151
|
+
* Accepts: `options` — as the caller passed it; absent is left alone, since
|
|
152
|
+
* there is nothing to check.
|
|
153
|
+
*
|
|
154
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
155
|
+
* checks it.
|
|
156
|
+
*
|
|
157
|
+
* Throws: `VALIDATION` naming `options.<key>` for the first key this
|
|
158
|
+
* package does not read, or `signal` for a value that is not AbortSignal-like.
|
|
159
|
+
*/
|
|
160
|
+
export declare function assertCancelOptions(options: CancelOptions | undefined): void;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { validationError } from '../errors/errors.js';
|
|
2
|
+
import { allKeysOf, assertShape, isObjectShape } from './option-shape.js';
|
|
3
|
+
export const CLIENT_MEMBERS = [
|
|
4
|
+
'get',
|
|
5
|
+
'put',
|
|
6
|
+
'delete',
|
|
7
|
+
'update',
|
|
8
|
+
'query',
|
|
9
|
+
'scan',
|
|
10
|
+
'batchWrite',
|
|
11
|
+
'transactWrite',
|
|
12
|
+
];
|
|
13
|
+
export const LOGGER_MEMBERS = ['debug', 'info', 'warn', 'error'];
|
|
14
|
+
export const SERDE_MEMBERS = ['dumpsTyped', 'loadsTyped'];
|
|
15
|
+
export const EMBEDDINGS_MEMBERS = ['embedQuery', 'embedDocuments'];
|
|
16
|
+
export const VECTOR_BACKEND_MEMBERS = ['upsert', 'query', 'delete'];
|
|
17
|
+
export const ABORT_SIGNAL_MEMBERS = {
|
|
18
|
+
aborted: 'boolean',
|
|
19
|
+
addEventListener: 'function',
|
|
20
|
+
removeEventListener: 'function',
|
|
21
|
+
};
|
|
22
|
+
export function assertMembers(value, members, field) {
|
|
23
|
+
if (!isObjectShape(value)) {
|
|
24
|
+
throw validationError(`${field} must be an object`, field);
|
|
25
|
+
}
|
|
26
|
+
for (const member of members) {
|
|
27
|
+
if (typeof Reflect.get(value, member) !== 'function') {
|
|
28
|
+
throw validationError(`${field}.${member} must be a function`, `${field}.${member}`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
export function assertClientTranslation(client) {
|
|
33
|
+
const translate = client.config?.translateConfig;
|
|
34
|
+
if (translate?.unmarshallOptions?.wrapNumbers) {
|
|
35
|
+
throw validationError('client reads numbers back wrapped (unmarshallOptions.wrapNumbers), where this package ' +
|
|
36
|
+
'reads a row version, a ttl and a count as numbers; inject a DynamoDBDocument built ' +
|
|
37
|
+
'without it', 'client');
|
|
38
|
+
}
|
|
39
|
+
if (translate?.marshallOptions?.convertEmptyValues === true) {
|
|
40
|
+
throw validationError('client stores an empty string as NULL (marshallOptions.convertEmptyValues), which erases ' +
|
|
41
|
+
'the root checkpoint namespace; inject a DynamoDBDocument built without it', 'client');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export function assertBaseCollaborators(options) {
|
|
45
|
+
if (options.client !== undefined) {
|
|
46
|
+
assertMembers(options.client, CLIENT_MEMBERS, 'client');
|
|
47
|
+
assertClientTranslation(options.client);
|
|
48
|
+
}
|
|
49
|
+
if (options.logger !== undefined)
|
|
50
|
+
assertMembers(options.logger, LOGGER_MEMBERS, 'logger');
|
|
51
|
+
if (options.serde !== undefined)
|
|
52
|
+
assertMembers(options.serde, SERDE_MEMBERS, 'serde');
|
|
53
|
+
}
|
|
54
|
+
export function isAbortSignalLike(value) {
|
|
55
|
+
if (typeof value !== 'object' || value === null)
|
|
56
|
+
return false;
|
|
57
|
+
return Object.entries(ABORT_SIGNAL_MEMBERS).every(([member, type]) => typeof Reflect.get(value, member) === type);
|
|
58
|
+
}
|
|
59
|
+
export function assertSignalLike(value, field = 'signal') {
|
|
60
|
+
if (value !== undefined && !isAbortSignalLike(value)) {
|
|
61
|
+
throw validationError(`${field} must be an AbortSignal`, field);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export const CANCEL_KEYS = allKeysOf({ signal: 'signal' });
|
|
65
|
+
export function assertCancelOptions(options) {
|
|
66
|
+
if (options === undefined)
|
|
67
|
+
return;
|
|
68
|
+
assertShape(options, CANCEL_KEYS, 'options');
|
|
69
|
+
assertSignalLike(options.signal);
|
|
70
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides how an option object is told apart from a misspelt one.
|
|
3
|
+
*
|
|
4
|
+
* An option type this package defines lists its keys once, checked by the
|
|
5
|
+
* compiler against the type, and an object carrying any other key is refused
|
|
6
|
+
* naming that key. An option object LangGraph defines is only held to being an
|
|
7
|
+
* object, since a key a later LangGraph adds must not refuse a call LangGraph
|
|
8
|
+
* makes (decision record 28). No caller writes the plain-object test or the
|
|
9
|
+
* unknown-key walk itself, so the message and the field a refusal names are the
|
|
10
|
+
* same for every option object this package reads.
|
|
11
|
+
*/
|
|
12
|
+
/**
|
|
13
|
+
* Every key of `T`, listed once.
|
|
14
|
+
*
|
|
15
|
+
* Accepts: an object naming every key of `T` as its own value. The parameter's
|
|
16
|
+
* type makes the list exhaustive in both directions: omitting a key the type
|
|
17
|
+
* declares, or naming one it does not, fails to compile — so the list cannot
|
|
18
|
+
* drift from the option type it guards, which matters because the list is what
|
|
19
|
+
* decides that a key is *unknown*.
|
|
20
|
+
*
|
|
21
|
+
* Returns: the keys.
|
|
22
|
+
*
|
|
23
|
+
* Throws: nothing.
|
|
24
|
+
*/
|
|
25
|
+
export declare function allKeysOf<T extends object>(keys: {
|
|
26
|
+
[K in keyof Required<T>]: K;
|
|
27
|
+
}): readonly string[];
|
|
28
|
+
/**
|
|
29
|
+
* Whether a value is a plain object: an object at all, not `null`, and not an
|
|
30
|
+
* array.
|
|
31
|
+
*
|
|
32
|
+
* Accepts: `value` — as the caller gave it, `undefined` included.
|
|
33
|
+
*
|
|
34
|
+
* Returns: true exactly when {@link assertObjectShape} would accept `value`.
|
|
35
|
+
* For code that must decide what to do with a malformed value rather than
|
|
36
|
+
* refuse it on the spot.
|
|
37
|
+
*
|
|
38
|
+
* Throws: nothing.
|
|
39
|
+
*/
|
|
40
|
+
export declare function isObjectShape(value: object | undefined): value is object;
|
|
41
|
+
/**
|
|
42
|
+
* Reject a value that is not a plain object: not an object at all, `null`, or
|
|
43
|
+
* an array.
|
|
44
|
+
*
|
|
45
|
+
* Accepts: `value` — as the caller gave it. `field` — what the error names.
|
|
46
|
+
*
|
|
47
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
48
|
+
* checks it.
|
|
49
|
+
*
|
|
50
|
+
* Throws: `VALIDATION` naming `field`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function assertObjectShape(value: object, field: string): void;
|
|
53
|
+
/**
|
|
54
|
+
* Reject an option object that is not an object, or that carries a key this
|
|
55
|
+
* package does not read.
|
|
56
|
+
*
|
|
57
|
+
* Accepts: `value` — the option object as the caller gave it. `allowed` — the
|
|
58
|
+
* key list from {@link allKeysOf}. `field` — what the error names.
|
|
59
|
+
*
|
|
60
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
61
|
+
* checks it.
|
|
62
|
+
*
|
|
63
|
+
* Throws: `VALIDATION` naming `field` for a value that is not an object, and
|
|
64
|
+
* `field.key` for an unknown key. A misspelt key is otherwise accepted and
|
|
65
|
+
* ignored, and the caller runs on a default they believe they overrode.
|
|
66
|
+
*
|
|
67
|
+
* `field.key` is **deliberately not cut**, where the rule that bounds an
|
|
68
|
+
* unchecked string before a message quotes it would otherwise reach it. The
|
|
69
|
+
* same string is the message *and* `context.field`, and `context.field` is the
|
|
70
|
+
* compatibility surface a caller branches on, so cutting one and not the other
|
|
71
|
+
* would make an error disagree with itself about which option it refused.
|
|
72
|
+
* Cutting both would bound a field callers match on, which this package does
|
|
73
|
+
* not do. The value is also the caller's own key off the caller's own options
|
|
74
|
+
* object — neither row-sourced nor third-party — so the only person who can
|
|
75
|
+
* make it enormous is the person reading the error.
|
|
76
|
+
*/
|
|
77
|
+
export declare function assertShape(value: object, allowed: readonly string[], field: string): void;
|
|
78
|
+
/**
|
|
79
|
+
* {@link assertShape}, returning `value` instead of nothing.
|
|
80
|
+
*
|
|
81
|
+
* Accepts: the same arguments as {@link assertShape}.
|
|
82
|
+
*
|
|
83
|
+
* Returns: `value`, unchanged. This returning form exists because a subclass
|
|
84
|
+
* constructor cannot run a statement before `super(...)`, so validating an
|
|
85
|
+
* argument bound for `super(...)` has to happen inside that expression —
|
|
86
|
+
* `super(parseShape(options, ALLOWED, 'options').thing)` — where a `void`
|
|
87
|
+
* function would not compile.
|
|
88
|
+
*
|
|
89
|
+
* Throws: the same as {@link assertShape}.
|
|
90
|
+
*/
|
|
91
|
+
export declare function parseShape<T extends object>(value: T, allowed: readonly string[], field: string): T;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { validationError } from '../errors/errors.js';
|
|
2
|
+
export function allKeysOf(keys) {
|
|
3
|
+
return Object.keys(keys);
|
|
4
|
+
}
|
|
5
|
+
export function isObjectShape(value) {
|
|
6
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
7
|
+
}
|
|
8
|
+
export function assertObjectShape(value, field) {
|
|
9
|
+
if (!isObjectShape(value)) {
|
|
10
|
+
throw validationError(`${field} must be an object`, field);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export function assertShape(value, allowed, field) {
|
|
14
|
+
assertObjectShape(value, field);
|
|
15
|
+
for (const key of Object.keys(value)) {
|
|
16
|
+
if (!allowed.includes(key)) {
|
|
17
|
+
throw validationError(`${field}.${key} is not an option this package reads; expected one of ${allowed.join(', ')}`, `${field}.${key}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export function parseShape(value, allowed, field) {
|
|
22
|
+
assertShape(value, allowed, field);
|
|
23
|
+
return value;
|
|
24
|
+
}
|