@farukada/aws-langgraph-dynamodb-ts 1.0.0-rc.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +390 -193
- package/dist/{backfill → cjs/backfill}/backfill.d.ts +15 -12
- package/dist/cjs/backfill/backfill.js +177 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/delete-thread.d.ts +1 -1
- package/dist/cjs/checkpointer/actions/delete-thread.js +26 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/get-tuple.d.ts +4 -3
- package/dist/cjs/checkpointer/actions/get-tuple.js +22 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/list.d.ts +7 -4
- package/dist/cjs/checkpointer/actions/list.js +70 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/put-writes.d.ts +8 -6
- package/dist/cjs/checkpointer/actions/put-writes.js +21 -0
- package/dist/{checkpointer → cjs/checkpointer}/actions/put.d.ts +21 -15
- package/dist/cjs/checkpointer/actions/put.js +79 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/delta-history.d.ts +38 -26
- package/dist/cjs/checkpointer/internal/delta-history.js +131 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/listing.d.ts +4 -4
- package/dist/cjs/checkpointer/internal/listing.js +104 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/parse.d.ts +51 -15
- package/dist/cjs/checkpointer/internal/parse.js +184 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/pending-writes.d.ts +64 -25
- package/dist/cjs/checkpointer/internal/pending-writes.js +241 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/read.d.ts +15 -10
- package/dist/cjs/checkpointer/internal/read.js +132 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/rows.d.ts +94 -21
- package/dist/cjs/checkpointer/internal/rows.js +356 -0
- package/dist/{checkpointer → cjs/checkpointer}/internal/setup.d.ts +13 -20
- package/dist/cjs/checkpointer/internal/setup.js +25 -0
- package/dist/{checkpointer → cjs/checkpointer}/saver.d.ts +72 -36
- package/dist/cjs/checkpointer/saver.js +56 -0
- package/dist/{checkpointer → cjs/checkpointer}/types.d.ts +1 -1
- package/dist/cjs/checkpointer/types.js +2 -0
- package/dist/{factory → cjs/factory}/factory.d.ts +25 -20
- package/dist/cjs/factory/factory.js +137 -0
- package/dist/{factory → cjs/factory}/types.d.ts +12 -12
- package/dist/cjs/factory/types.js +2 -0
- package/dist/{history → cjs/history}/actions/add-messages.d.ts +18 -10
- package/dist/cjs/history/actions/add-messages.js +17 -0
- package/dist/{history → cjs/history}/actions/clear.d.ts +1 -1
- package/dist/cjs/history/actions/clear.js +29 -0
- package/dist/{history → cjs/history}/actions/get-messages.d.ts +11 -9
- package/dist/cjs/history/actions/get-messages.js +58 -0
- package/dist/{history → cjs/history}/actions/list-sessions.d.ts +3 -3
- package/dist/cjs/history/actions/list-sessions.js +67 -0
- package/dist/{history → cjs/history}/actions/reconcile-count.d.ts +13 -9
- package/dist/cjs/history/actions/reconcile-count.js +8 -0
- package/dist/{history → cjs/history}/chat-message-history.d.ts +62 -30
- package/dist/cjs/history/chat-message-history.js +61 -0
- package/dist/{history → cjs/history}/internal/append.d.ts +64 -32
- package/dist/cjs/history/internal/append.js +267 -0
- package/dist/{history → cjs/history}/internal/message-read.d.ts +3 -3
- package/dist/cjs/history/internal/message-read.js +93 -0
- package/dist/{history → cjs/history}/internal/parse.d.ts +2 -2
- package/dist/cjs/history/internal/parse.js +113 -0
- package/dist/{history → cjs/history}/internal/rows.d.ts +11 -10
- package/dist/cjs/history/internal/rows.js +96 -0
- package/dist/{history → cjs/history}/internal/session.d.ts +41 -22
- package/dist/cjs/history/internal/session.js +296 -0
- package/dist/{history → cjs/history}/internal/setup.d.ts +2 -2
- package/dist/cjs/history/internal/setup.js +60 -0
- package/dist/{history → cjs/history}/session-adapter.d.ts +0 -6
- package/dist/cjs/history/session-adapter.js +38 -0
- package/dist/{history → cjs/history}/types.d.ts +18 -15
- package/dist/cjs/history/types.js +2 -0
- package/dist/{index.d.ts → cjs/index.d.ts} +27 -27
- package/dist/cjs/index.js +25 -0
- package/dist/cjs/package.json +1 -0
- package/dist/{shared → cjs/shared}/adapter.d.ts +27 -16
- package/dist/cjs/shared/adapter.js +70 -0
- package/dist/cjs/shared/clock.js +14 -0
- package/dist/{shared → cjs/shared}/codec/codec.d.ts +37 -20
- package/dist/cjs/shared/codec/codec.js +162 -0
- package/dist/{shared → cjs/shared}/codec/compression.d.ts +9 -4
- package/dist/cjs/shared/codec/compression.js +45 -0
- package/dist/cjs/shared/codec/json-serde.js +58 -0
- package/dist/{shared → cjs/shared}/codec/s3/client-types.d.ts +2 -1
- package/dist/cjs/shared/codec/s3/client-types.js +6 -0
- package/dist/{shared → cjs/shared}/codec/s3/client.d.ts +25 -7
- package/dist/cjs/shared/codec/s3/client.js +78 -0
- package/dist/{shared → cjs/shared}/codec/s3/config.d.ts +12 -7
- package/dist/cjs/shared/codec/s3/config.js +92 -0
- package/dist/{shared → cjs/shared}/codec/s3/lifecycle.d.ts +71 -17
- package/dist/cjs/shared/codec/s3/lifecycle.js +223 -0
- package/dist/{shared → cjs/shared}/codec/s3/offloader.d.ts +42 -29
- package/dist/cjs/shared/codec/s3/offloader.js +289 -0
- package/dist/cjs/shared/concurrency.js +31 -0
- package/dist/{shared → cjs/shared}/dynamodb/abort.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/abort.js +16 -0
- package/dist/{shared → cjs/shared}/dynamodb/batch-write.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/batch-write.js +79 -0
- package/dist/cjs/shared/dynamodb/cancellation.js +37 -0
- package/dist/{shared → cjs/shared}/dynamodb/client.d.ts +24 -22
- package/dist/cjs/shared/dynamodb/client.js +40 -0
- package/dist/{shared → cjs/shared}/dynamodb/idempotent-write.d.ts +64 -19
- package/dist/cjs/shared/dynamodb/idempotent-write.js +173 -0
- package/dist/{shared → cjs/shared}/dynamodb/paginate.d.ts +2 -2
- package/dist/cjs/shared/dynamodb/paginate.js +90 -0
- package/dist/{shared → cjs/shared}/dynamodb/partition-delete.d.ts +6 -6
- package/dist/cjs/shared/dynamodb/partition-delete.js +177 -0
- package/dist/{shared → cjs/shared}/dynamodb/recency-index.d.ts +27 -15
- package/dist/cjs/shared/dynamodb/recency-index.js +146 -0
- package/dist/{shared → cjs/shared}/dynamodb/retry.d.ts +37 -6
- package/dist/cjs/shared/dynamodb/retry.js +193 -0
- package/dist/cjs/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/cjs/shared/dynamodb/row-size.js +30 -0
- package/dist/{shared → cjs/shared}/dynamodb/table-schema.d.ts +27 -18
- package/dist/cjs/shared/dynamodb/table-schema.js +52 -0
- package/dist/{shared → cjs/shared}/errors/base-error.d.ts +42 -7
- package/dist/cjs/shared/errors/base-error.js +73 -0
- package/dist/{shared → cjs/shared}/errors/boundary.d.ts +29 -14
- package/dist/cjs/shared/errors/boundary.js +61 -0
- package/dist/cjs/shared/errors/classify.d.ts +206 -0
- package/dist/cjs/shared/errors/classify.js +232 -0
- package/dist/{shared → cjs/shared}/errors/error-code.d.ts +17 -10
- package/dist/cjs/shared/errors/error-code.js +27 -0
- package/dist/{shared → cjs/shared}/errors/errors.d.ts +75 -9
- package/dist/cjs/shared/errors/errors.js +123 -0
- package/dist/cjs/shared/logging/logger.js +30 -0
- package/dist/{shared → cjs/shared}/logging/redaction.d.ts +8 -4
- package/dist/cjs/shared/logging/redaction.js +145 -0
- package/dist/{shared → cjs/shared}/logging/secret-patterns.d.ts +30 -7
- package/dist/cjs/shared/logging/secret-patterns.js +93 -0
- package/dist/cjs/shared/logging/truncate.js +31 -0
- package/dist/{shared → cjs/shared}/options.d.ts +27 -11
- package/dist/cjs/shared/options.js +2 -0
- package/dist/cjs/shared/ulid.js +83 -0
- package/dist/{shared → cjs/shared}/validation/collaborators.d.ts +21 -2
- package/dist/cjs/shared/validation/collaborators.js +79 -0
- package/dist/{shared → cjs/shared}/validation/option-shape.d.ts +7 -5
- package/dist/cjs/shared/validation/option-shape.js +31 -0
- package/dist/{shared → cjs/shared}/validation/options.d.ts +4 -4
- package/dist/cjs/shared/validation/options.js +166 -0
- package/dist/cjs/shared/validation/primitives.js +114 -0
- package/dist/{shared → cjs/shared}/validation/ttl.d.ts +26 -9
- package/dist/cjs/shared/validation/ttl.js +52 -0
- package/dist/{store → cjs/store}/actions/list-namespaces.d.ts +5 -5
- package/dist/cjs/store/actions/list-namespaces.js +92 -0
- package/dist/{store → cjs/store}/actions/put.d.ts +11 -4
- package/dist/cjs/store/actions/put.js +49 -0
- package/dist/{store → cjs/store}/actions/reconcile-vector-index.d.ts +5 -5
- package/dist/cjs/store/actions/reconcile-vector-index.js +13 -0
- package/dist/{store → cjs/store}/actions/search.d.ts +2 -2
- package/dist/cjs/store/actions/search.js +26 -0
- package/dist/cjs/store/internal/batch-plan.d.ts +56 -0
- package/dist/cjs/store/internal/batch-plan.js +32 -0
- package/dist/{store → cjs/store}/internal/filter.d.ts +3 -3
- package/dist/cjs/store/internal/filter.js +64 -0
- package/dist/cjs/store/internal/get-item.d.ts +77 -0
- package/dist/cjs/store/internal/get-item.js +58 -0
- package/dist/{store → cjs/store}/internal/item-write.d.ts +72 -32
- package/dist/cjs/store/internal/item-write.js +181 -0
- package/dist/{store → cjs/store}/internal/parse.d.ts +15 -10
- package/dist/cjs/store/internal/parse.js +180 -0
- package/dist/{store → cjs/store}/internal/rows.d.ts +38 -34
- package/dist/cjs/store/internal/rows.js +166 -0
- package/dist/{store → cjs/store}/internal/semantic-search.d.ts +2 -2
- package/dist/cjs/store/internal/semantic-search.js +211 -0
- package/dist/{store → cjs/store}/internal/setup.d.ts +10 -15
- package/dist/cjs/store/internal/setup.js +103 -0
- package/dist/{store → cjs/store}/internal/table-search.d.ts +5 -5
- package/dist/cjs/store/internal/table-search.js +123 -0
- package/dist/{store → cjs/store}/internal/vector-index.d.ts +26 -15
- package/dist/cjs/store/internal/vector-index.js +269 -0
- package/dist/{store → cjs/store}/store.d.ts +82 -39
- package/dist/cjs/store/store.js +97 -0
- package/dist/{store → cjs/store}/types.d.ts +25 -10
- package/dist/cjs/store/types.js +2 -0
- package/dist/cjs/store/vector-backend.js +4 -0
- package/dist/esm/backfill/backfill.d.ts +171 -0
- package/dist/esm/backfill/backfill.js +170 -0
- package/dist/{checkpointer/actions/delete-thread.js → esm/checkpointer/actions/delete-thread.d.ts} +4 -26
- package/dist/esm/checkpointer/actions/delete-thread.js +23 -0
- package/dist/{checkpointer/actions/get-tuple.js → esm/checkpointer/actions/get-tuple.d.ts} +7 -24
- package/dist/esm/checkpointer/actions/get-tuple.js +19 -0
- package/dist/esm/checkpointer/actions/list.d.ts +55 -0
- package/dist/esm/checkpointer/actions/list.js +67 -0
- package/dist/{checkpointer/actions/put-writes.js → esm/checkpointer/actions/put-writes.d.ts} +10 -37
- package/dist/esm/checkpointer/actions/put-writes.js +18 -0
- package/dist/esm/checkpointer/actions/put.d.ts +95 -0
- package/dist/esm/checkpointer/actions/put.js +75 -0
- package/dist/esm/checkpointer/internal/delta-history.d.ts +124 -0
- package/dist/esm/checkpointer/internal/delta-history.js +126 -0
- package/dist/{checkpointer/internal/listing.js → esm/checkpointer/internal/listing.d.ts} +22 -118
- package/dist/esm/checkpointer/internal/listing.js +95 -0
- package/dist/esm/checkpointer/internal/parse.d.ts +298 -0
- package/dist/esm/checkpointer/internal/parse.js +169 -0
- package/dist/esm/checkpointer/internal/pending-writes.d.ts +314 -0
- package/dist/esm/checkpointer/internal/pending-writes.js +229 -0
- package/dist/esm/checkpointer/internal/read.d.ts +135 -0
- package/dist/esm/checkpointer/internal/read.js +125 -0
- package/dist/esm/checkpointer/internal/rows.d.ts +644 -0
- package/dist/esm/checkpointer/internal/rows.js +323 -0
- package/dist/esm/checkpointer/internal/setup.d.ts +47 -0
- package/dist/esm/checkpointer/internal/setup.js +21 -0
- package/dist/{checkpointer/saver.js → esm/checkpointer/saver.d.ts} +84 -87
- package/dist/esm/checkpointer/saver.js +52 -0
- package/dist/esm/checkpointer/types.d.ts +51 -0
- package/dist/esm/checkpointer/types.js +1 -0
- package/dist/esm/factory/factory.d.ts +154 -0
- package/dist/esm/factory/factory.js +133 -0
- package/dist/esm/factory/types.d.ts +76 -0
- package/dist/esm/factory/types.js +1 -0
- package/dist/{history/actions/add-messages.js → esm/history/actions/add-messages.d.ts} +20 -26
- package/dist/esm/history/actions/add-messages.js +14 -0
- package/dist/{history/actions/clear.js → esm/history/actions/clear.d.ts} +4 -35
- package/dist/esm/history/actions/clear.js +26 -0
- package/dist/esm/history/actions/get-messages.d.ts +60 -0
- package/dist/esm/history/actions/get-messages.js +55 -0
- package/dist/esm/history/actions/list-sessions.d.ts +55 -0
- package/dist/esm/history/actions/list-sessions.js +64 -0
- package/dist/{history/actions/reconcile-count.js → esm/history/actions/reconcile-count.d.ts} +14 -16
- package/dist/esm/history/actions/reconcile-count.js +5 -0
- package/dist/{history/chat-message-history.js → esm/history/chat-message-history.d.ts} +76 -87
- package/dist/esm/history/chat-message-history.js +57 -0
- package/dist/esm/history/internal/append.d.ts +244 -0
- package/dist/esm/history/internal/append.js +259 -0
- package/dist/esm/history/internal/message-read.d.ts +84 -0
- package/dist/esm/history/internal/message-read.js +89 -0
- package/dist/esm/history/internal/parse.d.ts +153 -0
- package/dist/esm/history/internal/parse.js +105 -0
- package/dist/{history/internal/rows.js → esm/history/internal/rows.d.ts} +58 -112
- package/dist/esm/history/internal/rows.js +83 -0
- package/dist/esm/history/internal/session.d.ts +350 -0
- package/dist/esm/history/internal/session.js +285 -0
- package/dist/esm/history/internal/setup.d.ts +64 -0
- package/dist/esm/history/internal/setup.js +56 -0
- package/dist/{history/session-adapter.js → esm/history/session-adapter.d.ts} +25 -39
- package/dist/esm/history/session-adapter.js +34 -0
- package/dist/esm/history/types.d.ts +102 -0
- package/dist/esm/history/types.js +1 -0
- package/dist/esm/index.d.ts +53 -0
- package/dist/esm/index.js +10 -0
- package/dist/esm/shared/adapter.d.ts +146 -0
- package/dist/esm/shared/adapter.js +65 -0
- package/dist/{shared/clock.js → esm/shared/clock.d.ts} +3 -14
- package/dist/esm/shared/clock.js +9 -0
- package/dist/esm/shared/codec/codec.d.ts +336 -0
- package/dist/esm/shared/codec/codec.js +150 -0
- package/dist/esm/shared/codec/compression.d.ts +66 -0
- package/dist/esm/shared/codec/compression.js +40 -0
- package/dist/esm/shared/codec/json-serde.d.ts +80 -0
- package/dist/esm/shared/codec/json-serde.js +54 -0
- package/dist/esm/shared/codec/s3/client-types.d.ts +54 -0
- package/dist/esm/shared/codec/s3/client-types.js +3 -0
- package/dist/esm/shared/codec/s3/client.d.ts +63 -0
- package/dist/esm/shared/codec/s3/client.js +40 -0
- package/dist/{shared/codec/s3/config.js → esm/shared/codec/s3/config.d.ts} +45 -93
- package/dist/esm/shared/codec/s3/config.js +79 -0
- package/dist/esm/shared/codec/s3/lifecycle.d.ts +220 -0
- package/dist/esm/shared/codec/s3/lifecycle.js +214 -0
- package/dist/esm/shared/codec/s3/offloader.d.ts +428 -0
- package/dist/esm/shared/codec/s3/offloader.js +278 -0
- package/dist/{shared/concurrency.js → esm/shared/concurrency.d.ts} +2 -37
- package/dist/esm/shared/concurrency.js +27 -0
- package/dist/{shared/dynamodb/abort.js → esm/shared/dynamodb/abort.d.ts} +4 -16
- package/dist/esm/shared/dynamodb/abort.js +12 -0
- package/dist/esm/shared/dynamodb/batch-write.d.ts +86 -0
- package/dist/esm/shared/dynamodb/batch-write.js +74 -0
- package/dist/{shared/dynamodb/cancellation.js → esm/shared/dynamodb/cancellation.d.ts} +25 -53
- package/dist/esm/shared/dynamodb/cancellation.js +30 -0
- package/dist/{shared/dynamodb/client.js → esm/shared/dynamodb/client.d.ts} +74 -64
- package/dist/esm/shared/dynamodb/client.js +35 -0
- package/dist/{shared/dynamodb/idempotent-write.js → esm/shared/dynamodb/idempotent-write.d.ts} +172 -169
- package/dist/esm/shared/dynamodb/idempotent-write.js +153 -0
- package/dist/esm/shared/dynamodb/paginate.d.ts +111 -0
- package/dist/esm/shared/dynamodb/paginate.js +84 -0
- package/dist/esm/shared/dynamodb/partition-delete.d.ts +204 -0
- package/dist/esm/shared/dynamodb/partition-delete.js +171 -0
- package/dist/esm/shared/dynamodb/recency-index.d.ts +243 -0
- package/dist/esm/shared/dynamodb/recency-index.js +136 -0
- package/dist/esm/shared/dynamodb/retry.d.ts +317 -0
- package/dist/esm/shared/dynamodb/retry.js +180 -0
- package/dist/esm/shared/dynamodb/row-size.d.ts +33 -0
- package/dist/esm/shared/dynamodb/row-size.js +26 -0
- package/dist/{shared/dynamodb/table-schema.js → esm/shared/dynamodb/table-schema.d.ts} +57 -67
- package/dist/esm/shared/dynamodb/table-schema.js +43 -0
- package/dist/esm/shared/errors/base-error.d.ts +231 -0
- package/dist/esm/shared/errors/base-error.js +64 -0
- package/dist/esm/shared/errors/boundary.d.ts +86 -0
- package/dist/esm/shared/errors/boundary.js +54 -0
- package/dist/esm/shared/errors/classify.d.ts +206 -0
- package/dist/esm/shared/errors/classify.js +220 -0
- package/dist/{shared/errors/error-code.js → esm/shared/errors/error-code.d.ts} +39 -43
- package/dist/esm/shared/errors/error-code.js +24 -0
- package/dist/{shared/errors/errors.js → esm/shared/errors/errors.d.ts} +92 -98
- package/dist/esm/shared/errors/errors.js +110 -0
- package/dist/{shared/logging/logger.js → esm/shared/logging/logger.d.ts} +22 -52
- package/dist/esm/shared/logging/logger.js +25 -0
- package/dist/esm/shared/logging/redaction.d.ts +123 -0
- package/dist/esm/shared/logging/redaction.js +140 -0
- package/dist/{shared/logging/secret-patterns.js → esm/shared/logging/secret-patterns.d.ts} +46 -87
- package/dist/esm/shared/logging/secret-patterns.js +83 -0
- package/dist/{shared/logging/truncate.js → esm/shared/logging/truncate.d.ts} +6 -40
- package/dist/esm/shared/logging/truncate.js +25 -0
- package/dist/esm/shared/options.d.ts +100 -0
- package/dist/esm/shared/options.js +1 -0
- package/dist/{shared/ulid.js → esm/shared/ulid.d.ts} +4 -84
- package/dist/esm/shared/ulid.js +77 -0
- package/dist/{shared/validation/collaborators.js → esm/shared/validation/collaborators.d.ts} +37 -65
- package/dist/esm/shared/validation/collaborators.js +70 -0
- package/dist/{shared/validation/option-shape.js → esm/shared/validation/option-shape.d.ts} +14 -36
- package/dist/esm/shared/validation/option-shape.js +24 -0
- package/dist/esm/shared/validation/options.d.ts +145 -0
- package/dist/esm/shared/validation/options.js +156 -0
- package/dist/{shared/validation/primitives.js → esm/shared/validation/primitives.d.ts} +30 -125
- package/dist/esm/shared/validation/primitives.js +100 -0
- package/dist/esm/shared/validation/ttl.d.ts +94 -0
- package/dist/esm/shared/validation/ttl.js +46 -0
- package/dist/esm/store/actions/list-namespaces.d.ts +79 -0
- package/dist/esm/store/actions/list-namespaces.js +86 -0
- package/dist/esm/store/actions/put.d.ts +43 -0
- package/dist/esm/store/actions/put.js +46 -0
- package/dist/{store/actions/reconcile-vector-index.js → esm/store/actions/reconcile-vector-index.d.ts} +8 -16
- package/dist/esm/store/actions/reconcile-vector-index.js +10 -0
- package/dist/esm/store/actions/search.d.ts +38 -0
- package/dist/esm/store/actions/search.js +23 -0
- package/dist/esm/store/internal/batch-plan.d.ts +56 -0
- package/dist/esm/store/internal/batch-plan.js +28 -0
- package/dist/esm/store/internal/filter.d.ts +43 -0
- package/dist/esm/store/internal/filter.js +60 -0
- package/dist/esm/store/internal/get-item.d.ts +77 -0
- package/dist/esm/store/internal/get-item.js +54 -0
- package/dist/esm/store/internal/item-write.d.ts +270 -0
- package/dist/esm/store/internal/item-write.js +173 -0
- package/dist/esm/store/internal/parse.d.ts +230 -0
- package/dist/esm/store/internal/parse.js +169 -0
- package/dist/{store/internal/rows.js → esm/store/internal/rows.d.ts} +111 -199
- package/dist/esm/store/internal/rows.js +147 -0
- package/dist/esm/store/internal/semantic-search.d.ts +168 -0
- package/dist/esm/store/internal/semantic-search.js +200 -0
- package/dist/esm/store/internal/setup.d.ts +96 -0
- package/dist/esm/store/internal/setup.js +98 -0
- package/dist/esm/store/internal/table-search.d.ts +100 -0
- package/dist/esm/store/internal/table-search.js +119 -0
- package/dist/esm/store/internal/vector-index.d.ts +258 -0
- package/dist/esm/store/internal/vector-index.js +256 -0
- package/dist/{store/store.js → esm/store/store.d.ts} +99 -133
- package/dist/esm/store/store.js +93 -0
- package/dist/esm/store/types.d.ts +111 -0
- package/dist/esm/store/types.js +1 -0
- package/dist/esm/store/vector-backend.d.ts +104 -0
- package/dist/esm/store/vector-backend.js +1 -0
- package/package.json +50 -44
- package/dist/backfill/backfill.js +0 -393
- package/dist/checkpointer/actions/list.js +0 -142
- package/dist/checkpointer/actions/put.js +0 -195
- package/dist/checkpointer/internal/delta-history.js +0 -252
- package/dist/checkpointer/internal/parse.js +0 -372
- package/dist/checkpointer/internal/pending-writes.js +0 -588
- package/dist/checkpointer/internal/read.js +0 -264
- package/dist/checkpointer/internal/rows.js +0 -834
- package/dist/checkpointer/internal/setup.js +0 -72
- package/dist/checkpointer/types.js +0 -12
- package/dist/factory/factory.js +0 -266
- package/dist/factory/types.js +0 -10
- package/dist/history/actions/get-messages.js +0 -141
- package/dist/history/actions/list-sessions.js +0 -156
- package/dist/history/internal/append.js +0 -500
- package/dist/history/internal/message-read.js +0 -204
- package/dist/history/internal/parse.js +0 -252
- package/dist/history/internal/session.js +0 -628
- package/dist/history/internal/setup.js +0 -106
- package/dist/history/types.js +0 -12
- package/dist/index.js +0 -51
- package/dist/shared/adapter.js +0 -143
- package/dist/shared/codec/codec.js +0 -441
- package/dist/shared/codec/compression.js +0 -89
- package/dist/shared/codec/json-serde.js +0 -191
- package/dist/shared/codec/s3/client-types.js +0 -26
- package/dist/shared/codec/s3/client.js +0 -97
- package/dist/shared/codec/s3/lifecycle.js +0 -355
- package/dist/shared/codec/s3/offloader.js +0 -658
- package/dist/shared/dynamodb/batch-write.js +0 -173
- package/dist/shared/dynamodb/paginate.js +0 -188
- package/dist/shared/dynamodb/partition-delete.js +0 -340
- package/dist/shared/dynamodb/recency-index.js +0 -377
- package/dist/shared/dynamodb/retry.js +0 -463
- package/dist/shared/errors/base-error.js +0 -174
- package/dist/shared/errors/boundary.js +0 -143
- package/dist/shared/errors/classify.d.ts +0 -97
- package/dist/shared/errors/classify.js +0 -257
- package/dist/shared/logging/redaction.js +0 -316
- package/dist/shared/options.js +0 -11
- package/dist/shared/validation/options.js +0 -328
- package/dist/shared/validation/ttl.js +0 -132
- package/dist/store/actions/list-namespaces.js +0 -197
- package/dist/store/actions/put.js +0 -78
- package/dist/store/actions/search.js +0 -66
- package/dist/store/internal/batch-plan.d.ts +0 -26
- package/dist/store/internal/batch-plan.js +0 -109
- package/dist/store/internal/filter.js +0 -137
- package/dist/store/internal/get-item.d.ts +0 -45
- package/dist/store/internal/get-item.js +0 -115
- package/dist/store/internal/item-write.js +0 -463
- package/dist/store/internal/parse.js +0 -350
- package/dist/store/internal/semantic-search.js +0 -389
- package/dist/store/internal/setup.js +0 -223
- package/dist/store/internal/table-search.js +0 -213
- package/dist/store/internal/vector-index.js +0 -546
- package/dist/store/types.js +0 -15
- package/dist/store/vector-backend.js +0 -17
- /package/dist/{shared → cjs/shared}/clock.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/codec/json-serde.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/concurrency.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/dynamodb/cancellation.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/logging/logger.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/logging/truncate.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/ulid.d.ts +0 -0
- /package/dist/{shared → cjs/shared}/validation/primitives.d.ts +0 -0
- /package/dist/{store → cjs/store}/vector-backend.d.ts +0 -0
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides which adapter-wide construction options are accepted.
|
|
3
|
+
*
|
|
4
|
+
* The table name, the client choice, the ttl, the retry policy, the recency
|
|
5
|
+
* index, the read concurrency, compression and S3 offload are checked here with
|
|
6
|
+
* their bounds, before an adapter builds anything, so a misconfiguration
|
|
7
|
+
* surfaces at construction rather than on the first call.
|
|
8
|
+
*/
|
|
9
|
+
import type { CompressionConfig } from '../codec/compression.js';
|
|
10
|
+
import { type S3OffloadConfig } from '../codec/s3/config.js';
|
|
11
|
+
import type { RetryPolicy } from '../dynamodb/retry.js';
|
|
12
|
+
import type { BaseAdapterOptions, CodecOptions } from '../options.js';
|
|
13
|
+
/**
|
|
14
|
+
* Largest `s3.maxDownloadBytes`/`compression.maxDecompressedBytes` an adapter
|
|
15
|
+
* accepts (512 MiB): both hold one buffer fully resident while it is read or
|
|
16
|
+
* inflated, and `BaseAdapterOptions.readConcurrency`'s doc multiplies the two
|
|
17
|
+
* together into the package's memory ceiling, so an unbounded value here is an
|
|
18
|
+
* unbounded process, not just an unbounded object.
|
|
19
|
+
*/
|
|
20
|
+
export declare const MAX_PAYLOAD_BUFFER_BYTES: number;
|
|
21
|
+
/** Largest `retry.maxAttempts` an adapter accepts; beyond it a retry loop is a hang, not a policy. */
|
|
22
|
+
export declare const MAX_RETRY_ATTEMPTS = 100;
|
|
23
|
+
/**
|
|
24
|
+
* Largest `retry.baseDelayMs`/`retry.maxDelayMs` an adapter accepts (one
|
|
25
|
+
* minute): combined with {@link MAX_RETRY_ATTEMPTS}, an unbounded per-attempt
|
|
26
|
+
* delay turns a bounded attempt count back into an effectively unbounded wait.
|
|
27
|
+
*/
|
|
28
|
+
export declare const MAX_RETRY_DELAY_MS = 60000;
|
|
29
|
+
/**
|
|
30
|
+
* Largest `readConcurrency` an adapter accepts: it is a multiplier on the
|
|
31
|
+
* memory-ceiling formula (see the option's own doc) and on requests fired at
|
|
32
|
+
* once, so an unbounded value turns a typo into an out-of-memory crash or a
|
|
33
|
+
* request storm against the table/bucket.
|
|
34
|
+
*/
|
|
35
|
+
export declare const MAX_READ_CONCURRENCY = 128;
|
|
36
|
+
/**
|
|
37
|
+
* Validate a table name against DynamoDB's own naming rule.
|
|
38
|
+
*
|
|
39
|
+
* Accepts: `tableName` — as the caller gave it.
|
|
40
|
+
*
|
|
41
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
42
|
+
* checks it.
|
|
43
|
+
*
|
|
44
|
+
* Throws: `VALIDATION` naming `tableName`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function assertTableName(tableName: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Reject a client choice that names two ways of getting one, or a
|
|
49
|
+
* `clientConfig` that is not an object.
|
|
50
|
+
*
|
|
51
|
+
* Accepts: the three client options, from an adapter or from the factory that
|
|
52
|
+
* defaults them. An injected `client` is used as-is, so a `clientConfig` or
|
|
53
|
+
* `createClient` given alongside it would be silently ignored — including a
|
|
54
|
+
* `region` the caller believes is in effect. `clientConfig`, when given, must
|
|
55
|
+
* be an object that is neither `null` nor an array; what it holds is the AWS
|
|
56
|
+
* SDK's to judge.
|
|
57
|
+
*
|
|
58
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
59
|
+
* checks it.
|
|
60
|
+
*
|
|
61
|
+
* Throws: `VALIDATION` naming `client` for both ways at once, then
|
|
62
|
+
* `clientConfig` for one that is not an object.
|
|
63
|
+
*/
|
|
64
|
+
export declare function assertClientChoice(options: Pick<BaseAdapterOptions, 'client' | 'clientConfig' | 'createClient'>): void;
|
|
65
|
+
/**
|
|
66
|
+
* The three numeric bounds every retry policy shares, regardless of which
|
|
67
|
+
* other keys the caller's own type allows beyond them. Split out so a caller
|
|
68
|
+
* with a wider surface than {@link RetryPolicy} (`backfillRecencyIndex`'s
|
|
69
|
+
* `RetryOptions`, which also exposes `onRetry`, `isRetryable` and friends)
|
|
70
|
+
* can reuse the identical bounds without going through {@link
|
|
71
|
+
* assertRetryPolicy}'s narrower `assertShape`, which would refuse those
|
|
72
|
+
* extra keys outright.
|
|
73
|
+
*
|
|
74
|
+
* Accepts: `policy` — its `maxAttempts`, `baseDelayMs` and `maxDelayMs`, each
|
|
75
|
+
* optional.
|
|
76
|
+
*
|
|
77
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
78
|
+
* checks it.
|
|
79
|
+
*
|
|
80
|
+
* Throws: `VALIDATION` naming `retry.maxAttempts`, `retry.baseDelayMs` or
|
|
81
|
+
* `retry.maxDelayMs`.
|
|
82
|
+
*/
|
|
83
|
+
export declare function assertRetryBounds(policy: Pick<RetryPolicy, 'maxAttempts' | 'baseDelayMs' | 'maxDelayMs'>): void;
|
|
84
|
+
/**
|
|
85
|
+
* Validate a retry policy: shape, then each bound.
|
|
86
|
+
*
|
|
87
|
+
* Accepts: `policy` — must be an object naming only `maxAttempts`,
|
|
88
|
+
* `baseDelayMs` and `maxDelayMs`; each, if given, is a bounded integer.
|
|
89
|
+
*
|
|
90
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
91
|
+
* checks it.
|
|
92
|
+
*
|
|
93
|
+
* Throws: `VALIDATION` naming `retry` or `retry.<key>`.
|
|
94
|
+
*/
|
|
95
|
+
export declare function assertRetryPolicy(policy: RetryPolicy): void;
|
|
96
|
+
/**
|
|
97
|
+
* Validate the options every adapter shares, at construction.
|
|
98
|
+
*
|
|
99
|
+
* Accepts: `options` — must be an object. `tableName` is required; every other
|
|
100
|
+
* option is optional, and `undefined` means "not configured" for each. A
|
|
101
|
+
* nested `ttl`, `retry`, `compression` or `s3` must be an object whose keys
|
|
102
|
+
* this package reads: a misspelt key is rejected rather than ignored, because
|
|
103
|
+
* the caller would otherwise run on a default they believe they overrode.
|
|
104
|
+
* `clientConfig` and `s3.clientConfig` must be objects, but their keys belong
|
|
105
|
+
* to the AWS SDK and are not checked. Keys of `options` itself are not checked
|
|
106
|
+
* here — the adapter types differ and this validator sees only the shared ones.
|
|
107
|
+
*
|
|
108
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
109
|
+
* checks it.
|
|
110
|
+
*
|
|
111
|
+
* Throws: `VALIDATION` whose `context.field` names the offending option,
|
|
112
|
+
* dotted for a nested one (`s3.bucketName`). The order is `tableName`, client
|
|
113
|
+
* choice, `ttl`, `retry`, `compression`, `s3`, `readConcurrency`, then the
|
|
114
|
+
* index options.
|
|
115
|
+
*
|
|
116
|
+
* Guarantees: a misconfiguration surfaces at construction, naming the option,
|
|
117
|
+
* rather than as a raw AWS error on the first request.
|
|
118
|
+
*/
|
|
119
|
+
export declare function assertBaseAdapterOptions(options: BaseAdapterOptions & CodecOptions): void;
|
|
120
|
+
/**
|
|
121
|
+
* Validate a `compression` config, honoring its allowed key set.
|
|
122
|
+
*
|
|
123
|
+
* Accepts: `config` — an object naming only {@link CompressionConfig}'s keys.
|
|
124
|
+
*
|
|
125
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
126
|
+
* checks it.
|
|
127
|
+
*
|
|
128
|
+
* Throws: `VALIDATION` naming the offending field, dotted under
|
|
129
|
+
* `compression`.
|
|
130
|
+
*/
|
|
131
|
+
export declare function assertCompression(config: CompressionConfig): void;
|
|
132
|
+
/**
|
|
133
|
+
* Validate an `s3` offload config, honoring its allowed key set.
|
|
134
|
+
*
|
|
135
|
+
* Accepts: `config` — an object naming only {@link S3OffloadConfig}'s keys.
|
|
136
|
+
* `config.clientConfig`, when given, must be an object that is neither `null`
|
|
137
|
+
* nor an array; its own keys are not checked. `config.createS3Client`, when
|
|
138
|
+
* given, must be a function.
|
|
139
|
+
*
|
|
140
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
141
|
+
* checks it.
|
|
142
|
+
*
|
|
143
|
+
* Throws: `VALIDATION` naming the offending field, dotted under `s3`.
|
|
144
|
+
*/
|
|
145
|
+
export declare function assertS3(config: S3OffloadConfig): void;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { MAX_INLINE_PAYLOAD_BYTES } from '../codec/codec.js';
|
|
2
|
+
import { assertScopedKeyPrefix } from '../codec/s3/config.js';
|
|
3
|
+
import { DEFAULT_MAX_S3_DOWNLOAD_BYTES, DEFAULT_S3_THRESHOLD_BYTES, } from '../codec/s3/offloader.js';
|
|
4
|
+
import { MAX_INDEX_SHARDS } from '../dynamodb/recency-index.js';
|
|
5
|
+
import { validationError } from '../errors/errors.js';
|
|
6
|
+
import { allKeysOf, assertObjectShape, assertShape } from './option-shape.js';
|
|
7
|
+
import { assertInteger, assertNonEmptyString } from './primitives.js';
|
|
8
|
+
import { resolveTtlSeconds } from './ttl.js';
|
|
9
|
+
const TABLE_NAME_PATTERN = /^[A-Za-z0-9_.-]{3,255}$/;
|
|
10
|
+
export const MAX_PAYLOAD_BUFFER_BYTES = 512 * 1024 * 1024;
|
|
11
|
+
export const MAX_RETRY_ATTEMPTS = 100;
|
|
12
|
+
export const MAX_RETRY_DELAY_MS = 60_000;
|
|
13
|
+
export const MAX_READ_CONCURRENCY = 128;
|
|
14
|
+
const RETRY_KEYS = allKeysOf({
|
|
15
|
+
maxAttempts: 'maxAttempts',
|
|
16
|
+
baseDelayMs: 'baseDelayMs',
|
|
17
|
+
maxDelayMs: 'maxDelayMs',
|
|
18
|
+
});
|
|
19
|
+
export function assertTableName(tableName) {
|
|
20
|
+
if (typeof tableName !== 'string' || !TABLE_NAME_PATTERN.test(tableName)) {
|
|
21
|
+
throw validationError('tableName must be 3-255 characters from [A-Za-z0-9_.-], as DynamoDB requires', 'tableName');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export function assertClientChoice(options) {
|
|
25
|
+
if (options.client &&
|
|
26
|
+
(options.clientConfig !== undefined || options.createClient !== undefined)) {
|
|
27
|
+
throw validationError('provide either `client` or `clientConfig`/`createClient`, not both: an injected client ' +
|
|
28
|
+
'is used as-is and the configuration would be silently ignored', 'client');
|
|
29
|
+
}
|
|
30
|
+
if (options.clientConfig !== undefined)
|
|
31
|
+
assertObjectShape(options.clientConfig, 'clientConfig');
|
|
32
|
+
}
|
|
33
|
+
export function assertRetryBounds(policy) {
|
|
34
|
+
if (policy.maxAttempts !== undefined) {
|
|
35
|
+
assertInteger(policy.maxAttempts, 'retry.maxAttempts', { min: 1, max: MAX_RETRY_ATTEMPTS });
|
|
36
|
+
}
|
|
37
|
+
if (policy.baseDelayMs !== undefined) {
|
|
38
|
+
assertInteger(policy.baseDelayMs, 'retry.baseDelayMs', { min: 1, max: MAX_RETRY_DELAY_MS });
|
|
39
|
+
}
|
|
40
|
+
if (policy.maxDelayMs !== undefined) {
|
|
41
|
+
assertInteger(policy.maxDelayMs, 'retry.maxDelayMs', {
|
|
42
|
+
min: policy.baseDelayMs ?? 1,
|
|
43
|
+
max: MAX_RETRY_DELAY_MS,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export function assertRetryPolicy(policy) {
|
|
48
|
+
assertShape(policy, RETRY_KEYS, 'retry');
|
|
49
|
+
assertRetryBounds(policy);
|
|
50
|
+
}
|
|
51
|
+
function assertRecencyIndex(options) {
|
|
52
|
+
if (options.indexShards !== undefined) {
|
|
53
|
+
assertInteger(options.indexShards, 'indexShards', { min: 1, max: MAX_INDEX_SHARDS });
|
|
54
|
+
}
|
|
55
|
+
if (options.indexName !== undefined)
|
|
56
|
+
assertNonEmptyString(options.indexName, 'indexName');
|
|
57
|
+
}
|
|
58
|
+
export function assertBaseAdapterOptions(options) {
|
|
59
|
+
if (typeof options !== 'object' || options === null) {
|
|
60
|
+
throw validationError('options must be an object naming at least a tableName', 'options');
|
|
61
|
+
}
|
|
62
|
+
assertTableName(options.tableName);
|
|
63
|
+
assertClientChoice(options);
|
|
64
|
+
if (options.ttl !== undefined)
|
|
65
|
+
resolveTtlSeconds(options.ttl);
|
|
66
|
+
if (options.retry !== undefined)
|
|
67
|
+
assertRetryPolicy(options.retry);
|
|
68
|
+
if (options.compression !== undefined)
|
|
69
|
+
assertCompression(options.compression);
|
|
70
|
+
if (options.s3 !== undefined)
|
|
71
|
+
assertS3(options.s3);
|
|
72
|
+
if (options.readConcurrency !== undefined) {
|
|
73
|
+
assertInteger(options.readConcurrency, 'readConcurrency', {
|
|
74
|
+
min: 1,
|
|
75
|
+
max: MAX_READ_CONCURRENCY,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
assertRecencyIndex(options);
|
|
79
|
+
}
|
|
80
|
+
const SSE_ALGORITHMS = ['AES256', 'aws:kms', 'aws:kms:dsse'];
|
|
81
|
+
const COMPRESSION_KEYS = allKeysOf({
|
|
82
|
+
enabled: 'enabled',
|
|
83
|
+
level: 'level',
|
|
84
|
+
minSizeBytes: 'minSizeBytes',
|
|
85
|
+
maxDecompressedBytes: 'maxDecompressedBytes',
|
|
86
|
+
});
|
|
87
|
+
const S3_KEYS = allKeysOf({
|
|
88
|
+
bucketName: 'bucketName',
|
|
89
|
+
keyPrefix: 'keyPrefix',
|
|
90
|
+
thresholdBytes: 'thresholdBytes',
|
|
91
|
+
serverSideEncryption: 'serverSideEncryption',
|
|
92
|
+
sseKmsKeyId: 'sseKmsKeyId',
|
|
93
|
+
maxDownloadBytes: 'maxDownloadBytes',
|
|
94
|
+
clientConfig: 'clientConfig',
|
|
95
|
+
createS3Client: 'createS3Client',
|
|
96
|
+
});
|
|
97
|
+
export function assertCompression(config) {
|
|
98
|
+
assertShape(config, COMPRESSION_KEYS, 'compression');
|
|
99
|
+
if (typeof config.enabled !== 'boolean') {
|
|
100
|
+
throw validationError('compression.enabled must be a boolean', 'compression.enabled');
|
|
101
|
+
}
|
|
102
|
+
if (config.level !== undefined) {
|
|
103
|
+
assertInteger(config.level, 'compression.level', { min: 0, max: 9 });
|
|
104
|
+
}
|
|
105
|
+
if (config.minSizeBytes !== undefined) {
|
|
106
|
+
assertInteger(config.minSizeBytes, 'compression.minSizeBytes', {
|
|
107
|
+
min: 0,
|
|
108
|
+
max: MAX_PAYLOAD_BUFFER_BYTES,
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
if (config.maxDecompressedBytes !== undefined) {
|
|
112
|
+
assertInteger(config.maxDecompressedBytes, 'compression.maxDecompressedBytes', {
|
|
113
|
+
min: 1,
|
|
114
|
+
max: MAX_PAYLOAD_BUFFER_BYTES,
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
function assertS3Encryption(config) {
|
|
119
|
+
if (config.serverSideEncryption !== undefined &&
|
|
120
|
+
!SSE_ALGORITHMS.includes(config.serverSideEncryption)) {
|
|
121
|
+
throw validationError(`s3.serverSideEncryption must be one of ${SSE_ALGORITHMS.join(', ')}`, 's3.serverSideEncryption');
|
|
122
|
+
}
|
|
123
|
+
if (config.sseKmsKeyId !== undefined) {
|
|
124
|
+
assertNonEmptyString(config.sseKmsKeyId, 's3.sseKmsKeyId');
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
export function assertS3(config) {
|
|
128
|
+
assertShape(config, S3_KEYS, 's3');
|
|
129
|
+
assertNonEmptyString(config.bucketName, 's3.bucketName');
|
|
130
|
+
if (config.clientConfig !== undefined)
|
|
131
|
+
assertObjectShape(config.clientConfig, 's3.clientConfig');
|
|
132
|
+
if (config.thresholdBytes !== undefined) {
|
|
133
|
+
assertInteger(config.thresholdBytes, 's3.thresholdBytes', {
|
|
134
|
+
min: 1,
|
|
135
|
+
max: MAX_INLINE_PAYLOAD_BYTES,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
if (config.keyPrefix !== undefined)
|
|
139
|
+
assertScopedKeyPrefix(config.keyPrefix);
|
|
140
|
+
if (config.maxDownloadBytes !== undefined) {
|
|
141
|
+
assertInteger(config.maxDownloadBytes, 's3.maxDownloadBytes', {
|
|
142
|
+
min: 1,
|
|
143
|
+
max: MAX_PAYLOAD_BUFFER_BYTES,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
const threshold = config.thresholdBytes ?? DEFAULT_S3_THRESHOLD_BYTES;
|
|
147
|
+
const downloadable = config.maxDownloadBytes ?? DEFAULT_MAX_S3_DOWNLOAD_BYTES;
|
|
148
|
+
if (downloadable < threshold) {
|
|
149
|
+
throw validationError(`s3.maxDownloadBytes (${downloadable}) must be at least s3.thresholdBytes (${threshold}): ` +
|
|
150
|
+
'every offloaded payload is at least the threshold, so none could be read back', 's3.maxDownloadBytes');
|
|
151
|
+
}
|
|
152
|
+
assertS3Encryption(config);
|
|
153
|
+
if (config.createS3Client !== undefined && typeof config.createS3Client !== 'function') {
|
|
154
|
+
throw validationError('s3.createS3Client must be a function', 's3.createS3Client');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Hides the rules every caller-supplied primitive must pass.
|
|
4
3
|
*
|
|
@@ -10,20 +9,6 @@
|
|
|
10
9
|
* it into its own type. Feature parsers compose these rules rather than
|
|
11
10
|
* restate them, so tightening one changes every method at once.
|
|
12
11
|
*/
|
|
13
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.MAX_PAGE_LIMIT = void 0;
|
|
15
|
-
exports.parseString = parseString;
|
|
16
|
-
exports.assertNonEmptyString = assertNonEmptyString;
|
|
17
|
-
exports.parseInteger = parseInteger;
|
|
18
|
-
exports.assertInteger = assertInteger;
|
|
19
|
-
exports.parseLimit = parseLimit;
|
|
20
|
-
exports.parseStringArray = parseStringArray;
|
|
21
|
-
exports.assertStringArray = assertStringArray;
|
|
22
|
-
exports.assertNoControlChars = assertNoControlChars;
|
|
23
|
-
exports.assertWellFormed = assertWellFormed;
|
|
24
|
-
exports.parseKeySegment = parseKeySegment;
|
|
25
|
-
exports.parseIdentifier = parseIdentifier;
|
|
26
|
-
const errors_1 = require("../errors/errors");
|
|
27
12
|
/**
|
|
28
13
|
* Largest `limit` any read accepts, on every method that takes one.
|
|
29
14
|
*
|
|
@@ -54,7 +39,18 @@ const errors_1 = require("../errors/errors");
|
|
|
54
39
|
* `offset`, `getMessages` a `before`, and `saver.list` streams and never
|
|
55
40
|
* accumulates — so an answer larger than this is paid for as pages.
|
|
56
41
|
*/
|
|
57
|
-
|
|
42
|
+
export declare const MAX_PAGE_LIMIT = 10000;
|
|
43
|
+
declare const pageLimitBrand: unique symbol;
|
|
44
|
+
/**
|
|
45
|
+
* A page size checked against the package-wide page rule: an integer from the
|
|
46
|
+
* call site's floor to {@link MAX_PAGE_LIMIT}. {@link parseLimit} is the only
|
|
47
|
+
* way to obtain one, so a reader that asks for a `PageLimit` cannot be handed a
|
|
48
|
+
* size nobody checked, and does not check it again. The brand is phantom: at
|
|
49
|
+
* run time it is the caller's own number.
|
|
50
|
+
*/
|
|
51
|
+
export type PageLimit = number & {
|
|
52
|
+
readonly [pageLimitBrand]: true;
|
|
53
|
+
};
|
|
58
54
|
/**
|
|
59
55
|
* The value as a string, or a refusal.
|
|
60
56
|
*
|
|
@@ -66,29 +62,7 @@ exports.MAX_PAGE_LIMIT = 10_000;
|
|
|
66
62
|
*
|
|
67
63
|
* Throws: `VALIDATION` naming `field`, for anything that is not a string.
|
|
68
64
|
*/
|
|
69
|
-
function parseString(value, field)
|
|
70
|
-
if (typeof value !== 'string') {
|
|
71
|
-
throw (0, errors_1.validationError)(`${field} must be a string`, field);
|
|
72
|
-
}
|
|
73
|
-
return value;
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* The value as a string holding at least one non-whitespace character.
|
|
77
|
-
*
|
|
78
|
-
* Accepts: `value` — anything; `''` and whitespace-only are refused alongside
|
|
79
|
-
* non-strings.
|
|
80
|
-
*
|
|
81
|
-
* Returns: `value`, typed as a string.
|
|
82
|
-
*
|
|
83
|
-
* Throws: `VALIDATION` naming `field`.
|
|
84
|
-
*/
|
|
85
|
-
function parseNonBlankString(value, field) {
|
|
86
|
-
const text = parseString(value, field);
|
|
87
|
-
if (text.trim().length === 0) {
|
|
88
|
-
throw (0, errors_1.validationError)(`${field} must be a non-empty string (whitespace-only counts as empty)`, field);
|
|
89
|
-
}
|
|
90
|
-
return text;
|
|
91
|
-
}
|
|
65
|
+
export declare function parseString(value: unknown, field: string): string;
|
|
92
66
|
/**
|
|
93
67
|
* Throw `VALIDATION` unless `value` is a string holding at least one
|
|
94
68
|
* non-whitespace character.
|
|
@@ -103,17 +77,7 @@ function parseNonBlankString(value, field) {
|
|
|
103
77
|
*
|
|
104
78
|
* Throws: `VALIDATION` naming `field`.
|
|
105
79
|
*/
|
|
106
|
-
function assertNonEmptyString(value, field)
|
|
107
|
-
parseNonBlankString(value, field);
|
|
108
|
-
}
|
|
109
|
-
/** Throw `VALIDATION` unless `value` encodes to at most `maxBytes` of UTF-8. */
|
|
110
|
-
function assertMaxBytes(value, field, maxBytes) {
|
|
111
|
-
parseString(value, field);
|
|
112
|
-
const bytes = Buffer.byteLength(value, 'utf8');
|
|
113
|
-
if (bytes > maxBytes) {
|
|
114
|
-
throw (0, errors_1.validationError)(`${field} must be at most ${maxBytes} bytes of UTF-8 (received ${bytes})`, field);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
80
|
+
export declare function assertNonEmptyString(value: string, field: string): void;
|
|
117
81
|
/**
|
|
118
82
|
* The value as an integer inside `bounds`.
|
|
119
83
|
*
|
|
@@ -126,18 +90,10 @@ function assertMaxBytes(value, field, maxBytes) {
|
|
|
126
90
|
* Throws: `VALIDATION` naming `field`; the integer rule is reported before
|
|
127
91
|
* either bound.
|
|
128
92
|
*/
|
|
129
|
-
function parseInteger(value, field, bounds
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (bounds.min !== undefined && value < bounds.min) {
|
|
134
|
-
throw (0, errors_1.validationError)(`${field} must be >= ${bounds.min}`, field);
|
|
135
|
-
}
|
|
136
|
-
if (bounds.max !== undefined && value > bounds.max) {
|
|
137
|
-
throw (0, errors_1.validationError)(`${field} must be <= ${bounds.max}`, field);
|
|
138
|
-
}
|
|
139
|
-
return value;
|
|
140
|
-
}
|
|
93
|
+
export declare function parseInteger(value: unknown, field: string, bounds?: {
|
|
94
|
+
min?: number;
|
|
95
|
+
max?: number;
|
|
96
|
+
}): number;
|
|
141
97
|
/**
|
|
142
98
|
* Throw `VALIDATION` unless `value` is an integer inside `bounds`.
|
|
143
99
|
*
|
|
@@ -153,9 +109,10 @@ function parseInteger(value, field, bounds = {}) {
|
|
|
153
109
|
* Throws: `VALIDATION` naming `field`; the integer rule is reported before
|
|
154
110
|
* either bound.
|
|
155
111
|
*/
|
|
156
|
-
function assertInteger(value, field, bounds
|
|
157
|
-
|
|
158
|
-
|
|
112
|
+
export declare function assertInteger(value: number, field: string, bounds?: {
|
|
113
|
+
min?: number;
|
|
114
|
+
max?: number;
|
|
115
|
+
}): void;
|
|
159
116
|
/**
|
|
160
117
|
* The value as a page size this package will serve: an integer from `min` to
|
|
161
118
|
* {@link MAX_PAGE_LIMIT}.
|
|
@@ -191,9 +148,7 @@ function assertInteger(value, field, bounds = {}) {
|
|
|
191
148
|
* or {@link MAX_PAGE_LIMIT} — so the caller is told what the rule is rather
|
|
192
149
|
* than only that it has one.
|
|
193
150
|
*/
|
|
194
|
-
function parseLimit(value, min)
|
|
195
|
-
return parseInteger(value, 'limit', { min, max: exports.MAX_PAGE_LIMIT });
|
|
196
|
-
}
|
|
151
|
+
export declare function parseLimit(value: unknown, min: 0 | 1): PageLimit;
|
|
197
152
|
/**
|
|
198
153
|
* The value as an array of strings, copied.
|
|
199
154
|
*
|
|
@@ -210,20 +165,7 @@ function parseLimit(value, min) {
|
|
|
210
165
|
* filling it: unchecked, a hole passed as a string and reached a caller who
|
|
211
166
|
* declared `string[]`.
|
|
212
167
|
*/
|
|
213
|
-
function parseStringArray(value, field)
|
|
214
|
-
if (!Array.isArray(value)) {
|
|
215
|
-
throw (0, errors_1.validationError)(`${field} must be an array of strings`, field);
|
|
216
|
-
}
|
|
217
|
-
const result = [];
|
|
218
|
-
for (let index = 0; index < value.length; index += 1) {
|
|
219
|
-
const item = value[index];
|
|
220
|
-
if (typeof item !== 'string') {
|
|
221
|
-
throw (0, errors_1.validationError)(`${field}[${index}] must be a string`, field);
|
|
222
|
-
}
|
|
223
|
-
result.push(item);
|
|
224
|
-
}
|
|
225
|
-
return result;
|
|
226
|
-
}
|
|
168
|
+
export declare function parseStringArray(value: unknown, field: string): string[];
|
|
227
169
|
/**
|
|
228
170
|
* Throw `VALIDATION` unless `value` is an array of strings.
|
|
229
171
|
*
|
|
@@ -237,18 +179,7 @@ function parseStringArray(value, field) {
|
|
|
237
179
|
*
|
|
238
180
|
* Throws: `VALIDATION` naming `field`.
|
|
239
181
|
*/
|
|
240
|
-
function assertStringArray(value, field)
|
|
241
|
-
parseStringArray(value, field);
|
|
242
|
-
}
|
|
243
|
-
/** True when `value` holds a C0 control character, DEL, or a C1 control character. */
|
|
244
|
-
function hasControlChar(value) {
|
|
245
|
-
for (let i = 0; i < value.length; i++) {
|
|
246
|
-
const code = value.charCodeAt(i);
|
|
247
|
-
if (code <= 0x1f || (code >= 0x7f && code <= 0x9f))
|
|
248
|
-
return true;
|
|
249
|
-
}
|
|
250
|
-
return false;
|
|
251
|
-
}
|
|
182
|
+
export declare function assertStringArray(value: readonly string[], field: string): void;
|
|
252
183
|
/**
|
|
253
184
|
* Throw `VALIDATION` unless `value` is free of control characters.
|
|
254
185
|
*
|
|
@@ -270,12 +201,7 @@ function hasControlChar(value) {
|
|
|
270
201
|
* package, and unneutralised output is CWE-117
|
|
271
202
|
* (https://cwe.mitre.org/data/definitions/117.html).
|
|
272
203
|
*/
|
|
273
|
-
function assertNoControlChars(value, field)
|
|
274
|
-
parseString(value, field);
|
|
275
|
-
if (hasControlChar(value)) {
|
|
276
|
-
throw (0, errors_1.validationError)(`${field} must not contain control characters`, field);
|
|
277
|
-
}
|
|
278
|
-
}
|
|
204
|
+
export declare function assertNoControlChars(value: string, field: string): void;
|
|
279
205
|
/**
|
|
280
206
|
* Throw `VALIDATION` unless every surrogate in `value` is part of a
|
|
281
207
|
* pair.
|
|
@@ -296,20 +222,7 @@ function assertNoControlChars(value, field) {
|
|
|
296
222
|
* U+FFFD, so two values differing only there would encode identically and,
|
|
297
223
|
* where that encoding is a storage key, address one object.
|
|
298
224
|
*/
|
|
299
|
-
function assertWellFormed(value, field)
|
|
300
|
-
parseString(value, field);
|
|
301
|
-
if (!value.isWellFormed()) {
|
|
302
|
-
throw (0, errors_1.validationError)(`${field} must be well-formed UTF-16 (it contains an unpaired surrogate, which does not ` +
|
|
303
|
-
'survive encoding to UTF-8)', field);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
/** Throw `VALIDATION` if `value` contains `separator`. */
|
|
307
|
-
function assertNoSeparator(value, separator, field) {
|
|
308
|
-
parseString(value, field);
|
|
309
|
-
if (value.includes(separator)) {
|
|
310
|
-
throw (0, errors_1.validationError)(`${field} must not contain the reserved "${separator}" separator`, field);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
225
|
+
export declare function assertWellFormed(value: string, field: string): void;
|
|
313
226
|
/**
|
|
314
227
|
* One segment of a key, which may be empty: every rule of
|
|
315
228
|
* {@link parseIdentifier} except non-blank. The checkpoint namespace is the one
|
|
@@ -326,14 +239,7 @@ function assertNoSeparator(value, separator, field) {
|
|
|
326
239
|
* `maxBytes` of UTF-8, free of `separator`, free of control characters,
|
|
327
240
|
* well-formed UTF-16.
|
|
328
241
|
*/
|
|
329
|
-
function parseKeySegment(value, separator, field, maxBytes)
|
|
330
|
-
const text = parseString(value, field);
|
|
331
|
-
assertMaxBytes(text, field, maxBytes);
|
|
332
|
-
assertNoSeparator(text, separator, field);
|
|
333
|
-
assertNoControlChars(text, field);
|
|
334
|
-
assertWellFormed(text, field);
|
|
335
|
-
return text;
|
|
336
|
-
}
|
|
242
|
+
export declare function parseKeySegment(value: unknown, separator: string, field: string, maxBytes: number): string;
|
|
337
243
|
/**
|
|
338
244
|
* The value as a caller-supplied identifier that reaches a DynamoDB key or an
|
|
339
245
|
* S3 object key, checked.
|
|
@@ -382,6 +288,5 @@ function parseKeySegment(value, separator, field, maxBytes) {
|
|
|
382
288
|
* loss on upgrade, bought with a rendering nicety. A caller who wants either
|
|
383
289
|
* rule can apply it to its own identifiers before passing them.
|
|
384
290
|
*/
|
|
385
|
-
function parseIdentifier(value, separator, field, maxBytes)
|
|
386
|
-
|
|
387
|
-
}
|
|
291
|
+
export declare function parseIdentifier(value: unknown, separator: string, field: string, maxBytes: number): string;
|
|
292
|
+
export {};
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { validationError } from '../errors/errors.js';
|
|
2
|
+
export const MAX_PAGE_LIMIT = 10_000;
|
|
3
|
+
export function parseString(value, field) {
|
|
4
|
+
if (typeof value !== 'string') {
|
|
5
|
+
throw validationError(`${field} must be a string`, field);
|
|
6
|
+
}
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
function parseNonBlankString(value, field) {
|
|
10
|
+
const text = parseString(value, field);
|
|
11
|
+
if (text.trim().length === 0) {
|
|
12
|
+
throw validationError(`${field} must be a non-empty string (whitespace-only counts as empty)`, field);
|
|
13
|
+
}
|
|
14
|
+
return text;
|
|
15
|
+
}
|
|
16
|
+
export function assertNonEmptyString(value, field) {
|
|
17
|
+
parseNonBlankString(value, field);
|
|
18
|
+
}
|
|
19
|
+
function assertMaxBytes(value, field, maxBytes) {
|
|
20
|
+
parseString(value, field);
|
|
21
|
+
const bytes = Buffer.byteLength(value, 'utf8');
|
|
22
|
+
if (bytes > maxBytes) {
|
|
23
|
+
throw validationError(`${field} must be at most ${maxBytes} bytes of UTF-8 (received ${bytes})`, field);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export function parseInteger(value, field, bounds = {}) {
|
|
27
|
+
if (typeof value !== 'number' || !Number.isInteger(value)) {
|
|
28
|
+
throw validationError(`${field} must be an integer`, field);
|
|
29
|
+
}
|
|
30
|
+
if (bounds.min !== undefined && value < bounds.min) {
|
|
31
|
+
throw validationError(`${field} must be >= ${bounds.min}`, field);
|
|
32
|
+
}
|
|
33
|
+
if (bounds.max !== undefined && value > bounds.max) {
|
|
34
|
+
throw validationError(`${field} must be <= ${bounds.max}`, field);
|
|
35
|
+
}
|
|
36
|
+
return value;
|
|
37
|
+
}
|
|
38
|
+
export function assertInteger(value, field, bounds = {}) {
|
|
39
|
+
parseInteger(value, field, bounds);
|
|
40
|
+
}
|
|
41
|
+
export function parseLimit(value, min) {
|
|
42
|
+
return parseInteger(value, 'limit', { min, max: MAX_PAGE_LIMIT });
|
|
43
|
+
}
|
|
44
|
+
function parseStringElement(item, field, index) {
|
|
45
|
+
if (typeof item !== 'string') {
|
|
46
|
+
throw validationError(`${field}[${index}] must be a string`, field);
|
|
47
|
+
}
|
|
48
|
+
return item;
|
|
49
|
+
}
|
|
50
|
+
export function parseStringArray(value, field) {
|
|
51
|
+
if (!Array.isArray(value)) {
|
|
52
|
+
throw validationError(`${field} must be an array of strings`, field);
|
|
53
|
+
}
|
|
54
|
+
const result = [];
|
|
55
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
56
|
+
result.push(parseStringElement(value[index], field, index));
|
|
57
|
+
}
|
|
58
|
+
return result;
|
|
59
|
+
}
|
|
60
|
+
export function assertStringArray(value, field) {
|
|
61
|
+
parseStringArray(value, field);
|
|
62
|
+
}
|
|
63
|
+
function hasControlChar(value) {
|
|
64
|
+
for (let i = 0; i < value.length; i++) {
|
|
65
|
+
const code = value.charCodeAt(i);
|
|
66
|
+
if (code <= 0x1f || (code >= 0x7f && code <= 0x9f))
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
export function assertNoControlChars(value, field) {
|
|
72
|
+
parseString(value, field);
|
|
73
|
+
if (hasControlChar(value)) {
|
|
74
|
+
throw validationError(`${field} must not contain control characters`, field);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
export function assertWellFormed(value, field) {
|
|
78
|
+
parseString(value, field);
|
|
79
|
+
if (!value.isWellFormed()) {
|
|
80
|
+
throw validationError(`${field} must be well-formed UTF-16 (it contains an unpaired surrogate, which does not ` +
|
|
81
|
+
'survive encoding to UTF-8)', field);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function assertNoSeparator(value, separator, field) {
|
|
85
|
+
parseString(value, field);
|
|
86
|
+
if (value.includes(separator)) {
|
|
87
|
+
throw validationError(`${field} must not contain the reserved "${separator}" separator`, field);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export function parseKeySegment(value, separator, field, maxBytes) {
|
|
91
|
+
const text = parseString(value, field);
|
|
92
|
+
assertMaxBytes(text, field, maxBytes);
|
|
93
|
+
assertNoSeparator(text, separator, field);
|
|
94
|
+
assertNoControlChars(text, field);
|
|
95
|
+
assertWellFormed(text, field);
|
|
96
|
+
return text;
|
|
97
|
+
}
|
|
98
|
+
export function parseIdentifier(value, separator, field, maxBytes) {
|
|
99
|
+
return parseKeySegment(parseNonBlankString(value, field), separator, field, maxBytes);
|
|
100
|
+
}
|