@farukada/aws-langgraph-dynamodb-ts 0.9.0 → 1.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1720 -154
- package/dist/backfill/backfill.d.ts +168 -0
- package/dist/backfill/backfill.js +393 -0
- package/dist/checkpointer/actions/delete-thread.d.ts +47 -6
- package/dist/checkpointer/actions/delete-thread.js +58 -21
- package/dist/checkpointer/actions/get-tuple.d.ts +29 -4
- package/dist/checkpointer/actions/get-tuple.js +44 -10
- package/dist/checkpointer/actions/list.d.ts +46 -4
- package/dist/checkpointer/actions/list.js +121 -66
- package/dist/checkpointer/actions/put-writes.d.ts +41 -9
- package/dist/checkpointer/actions/put-writes.js +62 -77
- package/dist/checkpointer/actions/put.d.ts +83 -4
- package/dist/checkpointer/actions/put.js +177 -25
- package/dist/checkpointer/internal/delta-history.d.ts +112 -0
- package/dist/checkpointer/internal/delta-history.js +252 -0
- package/dist/checkpointer/internal/listing.d.ts +149 -0
- package/dist/checkpointer/internal/listing.js +245 -0
- package/dist/checkpointer/internal/parse.d.ts +262 -0
- package/dist/checkpointer/internal/parse.js +372 -0
- package/dist/checkpointer/internal/pending-writes.d.ts +275 -0
- package/dist/checkpointer/internal/pending-writes.js +588 -0
- package/dist/checkpointer/internal/read.d.ts +130 -0
- package/dist/checkpointer/internal/read.js +264 -0
- package/dist/checkpointer/internal/rows.d.ts +571 -0
- package/dist/checkpointer/internal/rows.js +834 -0
- package/dist/checkpointer/internal/setup.d.ts +42 -19
- package/dist/checkpointer/internal/setup.js +65 -29
- package/dist/checkpointer/saver.d.ts +256 -16
- package/dist/checkpointer/saver.js +275 -29
- package/dist/checkpointer/types.d.ts +39 -39
- package/dist/checkpointer/types.js +10 -1
- package/dist/factory/factory.d.ts +134 -28
- package/dist/factory/factory.js +240 -21
- package/dist/factory/types.d.ts +76 -0
- package/dist/factory/types.js +10 -0
- package/dist/history/actions/add-messages.d.ts +31 -4
- package/dist/history/actions/add-messages.js +38 -58
- package/dist/history/actions/clear.d.ts +49 -6
- package/dist/history/actions/clear.js +66 -14
- package/dist/history/actions/get-messages.d.ts +54 -6
- package/dist/history/actions/get-messages.js +126 -43
- package/dist/history/actions/list-sessions.d.ts +52 -10
- package/dist/history/actions/list-sessions.js +139 -40
- package/dist/history/actions/reconcile-count.d.ts +42 -10
- package/dist/history/actions/reconcile-count.js +45 -45
- package/dist/history/chat-message-history.d.ts +220 -33
- package/dist/history/chat-message-history.js +240 -43
- package/dist/history/internal/append.d.ts +212 -0
- package/dist/history/internal/append.js +500 -0
- package/dist/history/internal/message-read.d.ts +84 -0
- package/dist/history/internal/message-read.js +204 -0
- package/dist/history/internal/parse.d.ts +153 -0
- package/dist/history/internal/parse.js +252 -0
- package/dist/history/internal/rows.d.ts +195 -0
- package/dist/history/internal/rows.js +250 -0
- package/dist/history/internal/session.d.ts +331 -0
- package/dist/history/internal/session.js +628 -0
- package/dist/history/internal/setup.d.ts +52 -17
- package/dist/history/internal/setup.js +92 -21
- package/dist/history/session-adapter.d.ts +102 -7
- package/dist/history/session-adapter.js +103 -9
- package/dist/history/types.d.ts +80 -29
- package/dist/history/types.js +10 -1
- package/dist/index.d.ts +42 -11
- package/dist/index.js +33 -12
- package/dist/shared/adapter.d.ts +135 -0
- package/dist/shared/adapter.js +143 -0
- package/dist/shared/clock.d.ts +51 -2
- package/dist/shared/clock.js +57 -2
- package/dist/shared/codec/codec.d.ts +288 -13
- package/dist/shared/codec/codec.js +416 -19
- package/dist/shared/codec/compression.d.ts +43 -7
- package/dist/shared/codec/compression.js +53 -13
- package/dist/shared/codec/json-serde.d.ts +76 -4
- package/dist/shared/codec/json-serde.js +181 -8
- package/dist/shared/codec/s3/client-types.d.ts +53 -0
- package/dist/shared/codec/s3/client-types.js +26 -0
- package/dist/shared/codec/s3/client.d.ts +43 -10
- package/dist/shared/codec/s3/client.js +82 -9
- package/dist/shared/codec/s3/config.d.ts +242 -11
- package/dist/shared/codec/s3/config.js +293 -11
- package/dist/shared/codec/s3/lifecycle.d.ts +164 -6
- package/dist/shared/codec/s3/lifecycle.js +335 -27
- package/dist/shared/codec/s3/offloader.d.ts +393 -18
- package/dist/shared/codec/s3/offloader.js +595 -37
- package/dist/shared/concurrency.d.ts +43 -0
- package/dist/shared/concurrency.js +78 -0
- package/dist/shared/dynamodb/abort.d.ts +47 -0
- package/dist/shared/dynamodb/abort.js +59 -0
- package/dist/shared/dynamodb/batch-write.d.ts +77 -14
- package/dist/shared/dynamodb/batch-write.js +146 -27
- package/dist/shared/dynamodb/cancellation.d.ts +121 -4
- package/dist/shared/dynamodb/cancellation.js +147 -3
- package/dist/shared/dynamodb/client.d.ts +162 -8
- package/dist/shared/dynamodb/client.js +153 -5
- package/dist/shared/dynamodb/idempotent-write.d.ts +551 -0
- package/dist/shared/dynamodb/idempotent-write.js +593 -0
- package/dist/shared/dynamodb/paginate.d.ts +105 -9
- package/dist/shared/dynamodb/paginate.js +175 -7
- package/dist/shared/dynamodb/partition-delete.d.ts +185 -14
- package/dist/shared/dynamodb/partition-delete.js +314 -44
- package/dist/shared/dynamodb/recency-index.d.ts +231 -0
- package/dist/shared/dynamodb/recency-index.js +377 -0
- package/dist/shared/dynamodb/retry.d.ts +276 -8
- package/dist/shared/dynamodb/retry.js +433 -23
- package/dist/shared/dynamodb/table-schema.d.ts +190 -0
- package/dist/shared/dynamodb/table-schema.js +209 -0
- package/dist/shared/errors/base-error.d.ts +184 -10
- package/dist/shared/errors/base-error.js +160 -14
- package/dist/shared/errors/boundary.d.ts +71 -0
- package/dist/shared/errors/boundary.js +143 -0
- package/dist/shared/errors/classify.d.ts +97 -0
- package/dist/shared/errors/classify.js +257 -0
- package/dist/shared/errors/error-code.d.ts +77 -2
- package/dist/shared/errors/error-code.js +83 -1
- package/dist/shared/errors/errors.d.ts +158 -59
- package/dist/shared/errors/errors.js +219 -92
- package/dist/shared/logging/logger.d.ts +69 -3
- package/dist/shared/logging/logger.js +97 -3
- package/dist/shared/logging/redaction.d.ts +92 -8
- package/dist/shared/logging/redaction.js +273 -17
- package/dist/shared/logging/secret-patterns.d.ts +149 -19
- package/dist/shared/logging/secret-patterns.js +188 -27
- package/dist/shared/logging/truncate.d.ts +197 -0
- package/dist/shared/logging/truncate.js +231 -0
- package/dist/shared/options.d.ts +59 -7
- package/dist/shared/options.js +9 -1
- package/dist/shared/ulid.d.ts +77 -7
- package/dist/shared/ulid.js +103 -8
- package/dist/shared/validation/collaborators.d.ts +141 -0
- package/dist/shared/validation/collaborators.js +188 -0
- package/dist/shared/validation/option-shape.d.ts +89 -0
- package/dist/shared/validation/option-shape.js +113 -0
- package/dist/shared/validation/options.d.ts +145 -0
- package/dist/shared/validation/options.js +328 -0
- package/dist/shared/validation/primitives.d.ts +288 -21
- package/dist/shared/validation/primitives.js +353 -50
- package/dist/shared/validation/ttl.d.ts +66 -10
- package/dist/shared/validation/ttl.js +113 -15
- package/dist/store/actions/list-namespaces.d.ts +76 -6
- package/dist/store/actions/list-namespaces.js +166 -24
- package/dist/store/actions/put.d.ts +33 -8
- package/dist/store/actions/put.js +53 -60
- package/dist/store/actions/reconcile-vector-index.d.ts +31 -10
- package/dist/store/actions/reconcile-vector-index.js +34 -15
- package/dist/store/actions/search.d.ts +34 -6
- package/dist/store/actions/search.js +56 -51
- package/dist/store/internal/batch-plan.d.ts +26 -0
- package/dist/store/internal/batch-plan.js +109 -0
- package/dist/store/internal/filter.d.ts +36 -3
- package/dist/store/internal/filter.js +66 -15
- package/dist/store/internal/get-item.d.ts +45 -0
- package/dist/store/internal/get-item.js +115 -0
- package/dist/store/internal/item-write.d.ts +230 -0
- package/dist/store/internal/item-write.js +463 -0
- package/dist/store/internal/parse.d.ts +225 -0
- package/dist/store/internal/parse.js +350 -0
- package/dist/store/internal/rows.d.ts +355 -0
- package/dist/store/internal/rows.js +447 -0
- package/dist/store/internal/semantic-search.d.ts +161 -6
- package/dist/store/internal/semantic-search.js +360 -18
- package/dist/store/internal/setup.d.ts +77 -20
- package/dist/store/internal/setup.js +178 -47
- package/dist/store/internal/table-search.d.ts +100 -0
- package/dist/store/internal/table-search.js +213 -0
- package/dist/store/internal/vector-index.d.ts +247 -0
- package/dist/store/internal/vector-index.js +546 -0
- package/dist/store/store.d.ts +270 -17
- package/dist/store/store.js +329 -38
- package/dist/store/types.d.ts +76 -26
- package/dist/store/types.js +13 -1
- package/dist/store/vector-backend.d.ts +64 -4
- package/dist/store/vector-backend.js +15 -1
- package/package.json +58 -36
- package/dist/checkpointer/actions/delete-thread.d.ts.map +0 -1
- package/dist/checkpointer/actions/delete-thread.js.map +0 -1
- package/dist/checkpointer/actions/get-tuple.d.ts.map +0 -1
- package/dist/checkpointer/actions/get-tuple.js.map +0 -1
- package/dist/checkpointer/actions/list.d.ts.map +0 -1
- package/dist/checkpointer/actions/list.js.map +0 -1
- package/dist/checkpointer/actions/put-writes.d.ts.map +0 -1
- package/dist/checkpointer/actions/put-writes.js.map +0 -1
- package/dist/checkpointer/actions/put.d.ts.map +0 -1
- package/dist/checkpointer/actions/put.js.map +0 -1
- package/dist/checkpointer/internal/assemble.d.ts +0 -10
- package/dist/checkpointer/internal/assemble.d.ts.map +0 -1
- package/dist/checkpointer/internal/assemble.js +0 -37
- package/dist/checkpointer/internal/assemble.js.map +0 -1
- package/dist/checkpointer/internal/configurable.d.ts +0 -13
- package/dist/checkpointer/internal/configurable.d.ts.map +0 -1
- package/dist/checkpointer/internal/configurable.js +0 -23
- package/dist/checkpointer/internal/configurable.js.map +0 -1
- package/dist/checkpointer/internal/fetch.d.ts +0 -10
- package/dist/checkpointer/internal/fetch.d.ts.map +0 -1
- package/dist/checkpointer/internal/fetch.js +0 -46
- package/dist/checkpointer/internal/fetch.js.map +0 -1
- package/dist/checkpointer/internal/filter-match.d.ts +0 -12
- package/dist/checkpointer/internal/filter-match.d.ts.map +0 -1
- package/dist/checkpointer/internal/filter-match.js +0 -14
- package/dist/checkpointer/internal/filter-match.js.map +0 -1
- package/dist/checkpointer/internal/item-reader.d.ts +0 -55
- package/dist/checkpointer/internal/item-reader.d.ts.map +0 -1
- package/dist/checkpointer/internal/item-reader.js +0 -88
- package/dist/checkpointer/internal/item-reader.js.map +0 -1
- package/dist/checkpointer/internal/item-writer.d.ts +0 -26
- package/dist/checkpointer/internal/item-writer.d.ts.map +0 -1
- package/dist/checkpointer/internal/item-writer.js +0 -92
- package/dist/checkpointer/internal/item-writer.js.map +0 -1
- package/dist/checkpointer/internal/keys.d.ts +0 -31
- package/dist/checkpointer/internal/keys.d.ts.map +0 -1
- package/dist/checkpointer/internal/keys.js +0 -87
- package/dist/checkpointer/internal/keys.js.map +0 -1
- package/dist/checkpointer/internal/query.d.ts +0 -20
- package/dist/checkpointer/internal/query.d.ts.map +0 -1
- package/dist/checkpointer/internal/query.js +0 -36
- package/dist/checkpointer/internal/query.js.map +0 -1
- package/dist/checkpointer/internal/setup.d.ts.map +0 -1
- package/dist/checkpointer/internal/setup.js.map +0 -1
- package/dist/checkpointer/internal/special-write-cas.d.ts +0 -30
- package/dist/checkpointer/internal/special-write-cas.d.ts.map +0 -1
- package/dist/checkpointer/internal/special-write-cas.js +0 -104
- package/dist/checkpointer/internal/special-write-cas.js.map +0 -1
- package/dist/checkpointer/internal/special-write-cleanup.d.ts +0 -24
- package/dist/checkpointer/internal/special-write-cleanup.d.ts.map +0 -1
- package/dist/checkpointer/internal/special-write-cleanup.js +0 -47
- package/dist/checkpointer/internal/special-write-cleanup.js.map +0 -1
- package/dist/checkpointer/internal/special-write-verify.d.ts +0 -54
- package/dist/checkpointer/internal/special-write-verify.d.ts.map +0 -1
- package/dist/checkpointer/internal/special-write-verify.js +0 -65
- package/dist/checkpointer/internal/special-write-verify.js.map +0 -1
- package/dist/checkpointer/internal/validation.d.ts +0 -13
- package/dist/checkpointer/internal/validation.d.ts.map +0 -1
- package/dist/checkpointer/internal/validation.js +0 -30
- package/dist/checkpointer/internal/validation.js.map +0 -1
- package/dist/checkpointer/internal/write-guard.d.ts +0 -13
- package/dist/checkpointer/internal/write-guard.d.ts.map +0 -1
- package/dist/checkpointer/internal/write-guard.js +0 -39
- package/dist/checkpointer/internal/write-guard.js.map +0 -1
- package/dist/checkpointer/internal/write-index.d.ts +0 -37
- package/dist/checkpointer/internal/write-index.d.ts.map +0 -1
- package/dist/checkpointer/internal/write-index.js +0 -42
- package/dist/checkpointer/internal/write-index.js.map +0 -1
- package/dist/checkpointer/saver.d.ts.map +0 -1
- package/dist/checkpointer/saver.js.map +0 -1
- package/dist/checkpointer/types.d.ts.map +0 -1
- package/dist/checkpointer/types.js.map +0 -1
- package/dist/factory/factory.d.ts.map +0 -1
- package/dist/factory/factory.js.map +0 -1
- package/dist/history/actions/add-messages.d.ts.map +0 -1
- package/dist/history/actions/add-messages.js.map +0 -1
- package/dist/history/actions/clear.d.ts.map +0 -1
- package/dist/history/actions/clear.js.map +0 -1
- package/dist/history/actions/get-messages.d.ts.map +0 -1
- package/dist/history/actions/get-messages.js.map +0 -1
- package/dist/history/actions/list-sessions.d.ts.map +0 -1
- package/dist/history/actions/list-sessions.js.map +0 -1
- package/dist/history/actions/reconcile-count.d.ts.map +0 -1
- package/dist/history/actions/reconcile-count.js.map +0 -1
- package/dist/history/chat-message-history.d.ts.map +0 -1
- package/dist/history/chat-message-history.js.map +0 -1
- package/dist/history/internal/append-saga.d.ts +0 -20
- package/dist/history/internal/append-saga.d.ts.map +0 -1
- package/dist/history/internal/append-saga.js +0 -35
- package/dist/history/internal/append-saga.js.map +0 -1
- package/dist/history/internal/compensation.d.ts +0 -21
- package/dist/history/internal/compensation.d.ts.map +0 -1
- package/dist/history/internal/compensation.js +0 -84
- package/dist/history/internal/compensation.js.map +0 -1
- package/dist/history/internal/item-mapper.d.ts +0 -12
- package/dist/history/internal/item-mapper.d.ts.map +0 -1
- package/dist/history/internal/item-mapper.js +0 -33
- package/dist/history/internal/item-mapper.js.map +0 -1
- package/dist/history/internal/keys.d.ts +0 -17
- package/dist/history/internal/keys.d.ts.map +0 -1
- package/dist/history/internal/keys.js +0 -49
- package/dist/history/internal/keys.js.map +0 -1
- package/dist/history/internal/message-chunker.d.ts +0 -14
- package/dist/history/internal/message-chunker.d.ts.map +0 -1
- package/dist/history/internal/message-chunker.js +0 -68
- package/dist/history/internal/message-chunker.js.map +0 -1
- package/dist/history/internal/message-transaction.d.ts +0 -26
- package/dist/history/internal/message-transaction.d.ts.map +0 -1
- package/dist/history/internal/message-transaction.js +0 -60
- package/dist/history/internal/message-transaction.js.map +0 -1
- package/dist/history/internal/query.d.ts +0 -10
- package/dist/history/internal/query.d.ts.map +0 -1
- package/dist/history/internal/query.js +0 -31
- package/dist/history/internal/query.js.map +0 -1
- package/dist/history/internal/session-count.d.ts +0 -41
- package/dist/history/internal/session-count.d.ts.map +0 -1
- package/dist/history/internal/session-count.js +0 -109
- package/dist/history/internal/session-count.js.map +0 -1
- package/dist/history/internal/session-title.d.ts +0 -20
- package/dist/history/internal/session-title.d.ts.map +0 -1
- package/dist/history/internal/session-title.js +0 -44
- package/dist/history/internal/session-title.js.map +0 -1
- package/dist/history/internal/session-update.d.ts +0 -28
- package/dist/history/internal/session-update.d.ts.map +0 -1
- package/dist/history/internal/session-update.js +0 -70
- package/dist/history/internal/session-update.js.map +0 -1
- package/dist/history/internal/setup.d.ts.map +0 -1
- package/dist/history/internal/setup.js.map +0 -1
- package/dist/history/internal/title-generator.d.ts +0 -13
- package/dist/history/internal/title-generator.d.ts.map +0 -1
- package/dist/history/internal/title-generator.js +0 -25
- package/dist/history/internal/title-generator.js.map +0 -1
- package/dist/history/internal/ttl-anchor.d.ts +0 -25
- package/dist/history/internal/ttl-anchor.d.ts.map +0 -1
- package/dist/history/internal/ttl-anchor.js +0 -38
- package/dist/history/internal/ttl-anchor.js.map +0 -1
- package/dist/history/internal/validation.d.ts +0 -9
- package/dist/history/internal/validation.d.ts.map +0 -1
- package/dist/history/internal/validation.js +0 -16
- package/dist/history/internal/validation.js.map +0 -1
- package/dist/history/session-adapter.d.ts.map +0 -1
- package/dist/history/session-adapter.js.map +0 -1
- package/dist/history/types.d.ts.map +0 -1
- package/dist/history/types.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/shared/clock.d.ts.map +0 -1
- package/dist/shared/clock.js.map +0 -1
- package/dist/shared/codec/codec.d.ts.map +0 -1
- package/dist/shared/codec/codec.js.map +0 -1
- package/dist/shared/codec/compression.d.ts.map +0 -1
- package/dist/shared/codec/compression.js.map +0 -1
- package/dist/shared/codec/descriptor-keys.d.ts +0 -4
- package/dist/shared/codec/descriptor-keys.d.ts.map +0 -1
- package/dist/shared/codec/descriptor-keys.js +0 -14
- package/dist/shared/codec/descriptor-keys.js.map +0 -1
- package/dist/shared/codec/json-serde.d.ts.map +0 -1
- package/dist/shared/codec/json-serde.js.map +0 -1
- package/dist/shared/codec/s3/client.d.ts.map +0 -1
- package/dist/shared/codec/s3/client.js.map +0 -1
- package/dist/shared/codec/s3/config.d.ts.map +0 -1
- package/dist/shared/codec/s3/config.js.map +0 -1
- package/dist/shared/codec/s3/delete.d.ts +0 -8
- package/dist/shared/codec/s3/delete.d.ts.map +0 -1
- package/dist/shared/codec/s3/delete.js +0 -29
- package/dist/shared/codec/s3/delete.js.map +0 -1
- package/dist/shared/codec/s3/lifecycle.d.ts.map +0 -1
- package/dist/shared/codec/s3/lifecycle.js.map +0 -1
- package/dist/shared/codec/s3/offloader.d.ts.map +0 -1
- package/dist/shared/codec/s3/offloader.js.map +0 -1
- package/dist/shared/codec/s3/orphans.d.ts +0 -18
- package/dist/shared/codec/s3/orphans.d.ts.map +0 -1
- package/dist/shared/codec/s3/orphans.js +0 -58
- package/dist/shared/codec/s3/orphans.js.map +0 -1
- package/dist/shared/codec/s3/read-write.d.ts +0 -14
- package/dist/shared/codec/s3/read-write.d.ts.map +0 -1
- package/dist/shared/codec/s3/read-write.js +0 -43
- package/dist/shared/codec/s3/read-write.js.map +0 -1
- package/dist/shared/codec/s3/retry.d.ts +0 -5
- package/dist/shared/codec/s3/retry.d.ts.map +0 -1
- package/dist/shared/codec/s3/retry.js +0 -25
- package/dist/shared/codec/s3/retry.js.map +0 -1
- package/dist/shared/constants.d.ts +0 -64
- package/dist/shared/constants.d.ts.map +0 -1
- package/dist/shared/constants.js +0 -67
- package/dist/shared/constants.js.map +0 -1
- package/dist/shared/dynamodb/backoff.d.ts +0 -15
- package/dist/shared/dynamodb/backoff.d.ts.map +0 -1
- package/dist/shared/dynamodb/backoff.js +0 -48
- package/dist/shared/dynamodb/backoff.js.map +0 -1
- package/dist/shared/dynamodb/batch-write.d.ts.map +0 -1
- package/dist/shared/dynamodb/batch-write.js.map +0 -1
- package/dist/shared/dynamodb/cancellation.d.ts.map +0 -1
- package/dist/shared/dynamodb/cancellation.js.map +0 -1
- package/dist/shared/dynamodb/client.d.ts.map +0 -1
- package/dist/shared/dynamodb/client.js.map +0 -1
- package/dist/shared/dynamodb/conditional-put.d.ts +0 -51
- package/dist/shared/dynamodb/conditional-put.d.ts.map +0 -1
- package/dist/shared/dynamodb/conditional-put.js +0 -59
- package/dist/shared/dynamodb/conditional-put.js.map +0 -1
- package/dist/shared/dynamodb/drain-unprocessed.d.ts +0 -19
- package/dist/shared/dynamodb/drain-unprocessed.d.ts.map +0 -1
- package/dist/shared/dynamodb/drain-unprocessed.js +0 -44
- package/dist/shared/dynamodb/drain-unprocessed.js.map +0 -1
- package/dist/shared/dynamodb/paginate-core.d.ts +0 -22
- package/dist/shared/dynamodb/paginate-core.d.ts.map +0 -1
- package/dist/shared/dynamodb/paginate-core.js +0 -52
- package/dist/shared/dynamodb/paginate-core.js.map +0 -1
- package/dist/shared/dynamodb/paginate.d.ts.map +0 -1
- package/dist/shared/dynamodb/paginate.js.map +0 -1
- package/dist/shared/dynamodb/partition-delete.d.ts.map +0 -1
- package/dist/shared/dynamodb/partition-delete.js.map +0 -1
- package/dist/shared/dynamodb/retry-classifier.d.ts +0 -9
- package/dist/shared/dynamodb/retry-classifier.d.ts.map +0 -1
- package/dist/shared/dynamodb/retry-classifier.js +0 -87
- package/dist/shared/dynamodb/retry-classifier.js.map +0 -1
- package/dist/shared/dynamodb/retry.d.ts.map +0 -1
- package/dist/shared/dynamodb/retry.js.map +0 -1
- package/dist/shared/dynamodb/scan.d.ts +0 -15
- package/dist/shared/dynamodb/scan.d.ts.map +0 -1
- package/dist/shared/dynamodb/scan.js +0 -20
- package/dist/shared/dynamodb/scan.js.map +0 -1
- package/dist/shared/dynamodb/types.d.ts +0 -24
- package/dist/shared/dynamodb/types.d.ts.map +0 -1
- package/dist/shared/dynamodb/types.js +0 -3
- package/dist/shared/dynamodb/types.js.map +0 -1
- package/dist/shared/errors/base-error.d.ts.map +0 -1
- package/dist/shared/errors/base-error.js.map +0 -1
- package/dist/shared/errors/error-code.d.ts.map +0 -1
- package/dist/shared/errors/error-code.js.map +0 -1
- package/dist/shared/errors/errors.d.ts.map +0 -1
- package/dist/shared/errors/errors.js.map +0 -1
- package/dist/shared/errors/wrap-error.d.ts +0 -16
- package/dist/shared/errors/wrap-error.d.ts.map +0 -1
- package/dist/shared/errors/wrap-error.js +0 -30
- package/dist/shared/errors/wrap-error.js.map +0 -1
- package/dist/shared/logging/logger.d.ts.map +0 -1
- package/dist/shared/logging/logger.js.map +0 -1
- package/dist/shared/logging/redaction-walk.d.ts +0 -23
- package/dist/shared/logging/redaction-walk.d.ts.map +0 -1
- package/dist/shared/logging/redaction-walk.js +0 -92
- package/dist/shared/logging/redaction-walk.js.map +0 -1
- package/dist/shared/logging/redaction.d.ts.map +0 -1
- package/dist/shared/logging/redaction.js.map +0 -1
- package/dist/shared/logging/secret-patterns.d.ts.map +0 -1
- package/dist/shared/logging/secret-patterns.js.map +0 -1
- package/dist/shared/options.d.ts.map +0 -1
- package/dist/shared/options.js.map +0 -1
- package/dist/shared/ulid.d.ts.map +0 -1
- package/dist/shared/ulid.js.map +0 -1
- package/dist/shared/validation/primitives.d.ts.map +0 -1
- package/dist/shared/validation/primitives.js.map +0 -1
- package/dist/shared/validation/ttl.d.ts.map +0 -1
- package/dist/shared/validation/ttl.js.map +0 -1
- package/dist/store/actions/get.d.ts +0 -5
- package/dist/store/actions/get.d.ts.map +0 -1
- package/dist/store/actions/get.js +0 -35
- package/dist/store/actions/get.js.map +0 -1
- package/dist/store/actions/list-namespaces.d.ts.map +0 -1
- package/dist/store/actions/list-namespaces.js.map +0 -1
- package/dist/store/actions/put.d.ts.map +0 -1
- package/dist/store/actions/put.js.map +0 -1
- package/dist/store/actions/reconcile-vector-index.d.ts.map +0 -1
- package/dist/store/actions/reconcile-vector-index.js.map +0 -1
- package/dist/store/actions/search.d.ts.map +0 -1
- package/dist/store/actions/search.js.map +0 -1
- package/dist/store/internal/backend-search.d.ts +0 -5
- package/dist/store/internal/backend-search.d.ts.map +0 -1
- package/dist/store/internal/backend-search.js +0 -68
- package/dist/store/internal/backend-search.js.map +0 -1
- package/dist/store/internal/filter.d.ts.map +0 -1
- package/dist/store/internal/filter.js.map +0 -1
- package/dist/store/internal/index-reconcile.d.ts +0 -22
- package/dist/store/internal/index-reconcile.d.ts.map +0 -1
- package/dist/store/internal/index-reconcile.js +0 -105
- package/dist/store/internal/index-reconcile.js.map +0 -1
- package/dist/store/internal/index-sync.d.ts +0 -11
- package/dist/store/internal/index-sync.d.ts.map +0 -1
- package/dist/store/internal/index-sync.js +0 -26
- package/dist/store/internal/index-sync.js.map +0 -1
- package/dist/store/internal/item-mapper.d.ts +0 -25
- package/dist/store/internal/item-mapper.d.ts.map +0 -1
- package/dist/store/internal/item-mapper.js +0 -53
- package/dist/store/internal/item-mapper.js.map +0 -1
- package/dist/store/internal/keys.d.ts +0 -18
- package/dist/store/internal/keys.d.ts.map +0 -1
- package/dist/store/internal/keys.js +0 -42
- package/dist/store/internal/keys.js.map +0 -1
- package/dist/store/internal/namespace-match.d.ts +0 -12
- package/dist/store/internal/namespace-match.d.ts.map +0 -1
- package/dist/store/internal/namespace-match.js +0 -41
- package/dist/store/internal/namespace-match.js.map +0 -1
- package/dist/store/internal/overwrite-swap.d.ts +0 -33
- package/dist/store/internal/overwrite-swap.d.ts.map +0 -1
- package/dist/store/internal/overwrite-swap.js +0 -62
- package/dist/store/internal/overwrite-swap.js.map +0 -1
- package/dist/store/internal/persist.d.ts +0 -27
- package/dist/store/internal/persist.d.ts.map +0 -1
- package/dist/store/internal/persist.js +0 -59
- package/dist/store/internal/persist.js.map +0 -1
- package/dist/store/internal/query.d.ts +0 -6
- package/dist/store/internal/query.d.ts.map +0 -1
- package/dist/store/internal/query.js +0 -32
- package/dist/store/internal/query.js.map +0 -1
- package/dist/store/internal/ranker.d.ts +0 -13
- package/dist/store/internal/ranker.d.ts.map +0 -1
- package/dist/store/internal/ranker.js +0 -31
- package/dist/store/internal/ranker.js.map +0 -1
- package/dist/store/internal/read-existing.d.ts +0 -19
- package/dist/store/internal/read-existing.d.ts.map +0 -1
- package/dist/store/internal/read-existing.js +0 -29
- package/dist/store/internal/read-existing.js.map +0 -1
- package/dist/store/internal/score-direction.d.ts +0 -32
- package/dist/store/internal/score-direction.d.ts.map +0 -1
- package/dist/store/internal/score-direction.js +0 -39
- package/dist/store/internal/score-direction.js.map +0 -1
- package/dist/store/internal/search-filter.d.ts +0 -4
- package/dist/store/internal/search-filter.d.ts.map +0 -1
- package/dist/store/internal/search-filter.js +0 -11
- package/dist/store/internal/search-filter.js.map +0 -1
- package/dist/store/internal/semantic-search.d.ts.map +0 -1
- package/dist/store/internal/semantic-search.js.map +0 -1
- package/dist/store/internal/setup.d.ts.map +0 -1
- package/dist/store/internal/setup.js.map +0 -1
- package/dist/store/internal/validation.d.ts +0 -13
- package/dist/store/internal/validation.d.ts.map +0 -1
- package/dist/store/internal/validation.js +0 -35
- package/dist/store/internal/validation.js.map +0 -1
- package/dist/store/internal/write-verify.d.ts +0 -37
- package/dist/store/internal/write-verify.d.ts.map +0 -1
- package/dist/store/internal/write-verify.js +0 -68
- package/dist/store/internal/write-verify.js.map +0 -1
- package/dist/store/store.d.ts.map +0 -1
- package/dist/store/store.js.map +0 -1
- package/dist/store/types.d.ts.map +0 -1
- package/dist/store/types.js.map +0 -1
- package/dist/store/vector-backend.d.ts.map +0 -1
- package/dist/store/vector-backend.js.map +0 -1
|
@@ -1,84 +1,387 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hides the rules every caller-supplied primitive must pass.
|
|
4
|
+
*
|
|
5
|
+
* What makes a string an identifier safe inside a key, an integer a page size
|
|
6
|
+
* this package serves, and an array a copy holding only strings is decided
|
|
7
|
+
* once here. Only `parseLimit` returns a branded type of its own —
|
|
8
|
+
* `PageLimit`, which only it can build (record 21); every other rule's
|
|
9
|
+
* `parse*` form returns the plain checked value, and a feature parser brands
|
|
10
|
+
* it into its own type. Feature parsers compose these rules rather than
|
|
11
|
+
* restate them, so tightening one changes every method at once.
|
|
12
|
+
*/
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
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;
|
|
6
22
|
exports.assertNoControlChars = assertNoControlChars;
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
9
|
-
exports.
|
|
23
|
+
exports.assertWellFormed = assertWellFormed;
|
|
24
|
+
exports.parseKeySegment = parseKeySegment;
|
|
25
|
+
exports.parseIdentifier = parseIdentifier;
|
|
10
26
|
const errors_1 = require("../errors/errors");
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Largest `limit` any read accepts, on every method that takes one.
|
|
29
|
+
*
|
|
30
|
+
* Chosen from what a page costs, which is linear in `limit` and amortised
|
|
31
|
+
* nowhere: every row of a page is held decoded and resident until the whole
|
|
32
|
+
* page is handed back, and an offloaded row is an S3 GET and a decompression
|
|
33
|
+
* of its own, `readConcurrency` at a time. A page of N rows is therefore N
|
|
34
|
+
* objects held at once and, in the worst case, N round trips before the caller
|
|
35
|
+
* sees the first of them.
|
|
36
|
+
*
|
|
37
|
+
* Ten thousand is where this package already says a read has stopped being one
|
|
38
|
+
* and become an export: `MAX_TOTAL_ROWS_IN_MEMORY`
|
|
39
|
+
* (`src/shared/dynamodb/paginate.ts`) refuses to collect more than that across
|
|
40
|
+
* a whole paginated query, and `LIST_SCAN_WARN_THRESHOLD`
|
|
41
|
+
* (`src/shared/dynamodb/paginate.ts`) tells an operator about a listing that
|
|
42
|
+
* walks that far. A single page allowed past either would hold more than every
|
|
43
|
+
* other path in the package may. Its own literal at the same value rather than
|
|
44
|
+
* an alias of them, for the reason `LIST_SCAN_WARN_THRESHOLD`
|
|
45
|
+
* (`src/shared/dynamodb/paginate.ts`) records.
|
|
46
|
+
*
|
|
47
|
+
* What it does *not* do is promise a memory figure: rows are the caller's own
|
|
48
|
+
* data, so ten thousand session summaries are a few megabytes while a hundred
|
|
49
|
+
* items at `MAX_INLINE_PAYLOAD_BYTES` (`src/shared/codec/codec.ts`) are forty.
|
|
50
|
+
* It bounds a typo — a `1e12` that would otherwise resolve — not a working set.
|
|
51
|
+
*
|
|
52
|
+
* What a caller loses at the ceiling is one large page, never the rows: every
|
|
53
|
+
* bounded read has a way to continue — `listSessions` a cursor, `search` an
|
|
54
|
+
* `offset`, `getMessages` a `before`, and `saver.list` streams and never
|
|
55
|
+
* accumulates — so an answer larger than this is paid for as pages.
|
|
56
|
+
*/
|
|
57
|
+
exports.MAX_PAGE_LIMIT = 10_000;
|
|
58
|
+
/**
|
|
59
|
+
* The value as a string, or a refusal.
|
|
60
|
+
*
|
|
61
|
+
* Accepts: `value` — anything. A JavaScript caller, or a TypeScript caller
|
|
62
|
+
* whose input came from JSON, can pass any type where a string is declared, and
|
|
63
|
+
* every rule after this one reaches a string method.
|
|
64
|
+
*
|
|
65
|
+
* Returns: `value`, typed as the string it was checked to be.
|
|
66
|
+
*
|
|
67
|
+
* Throws: `VALIDATION` naming `field`, for anything that is not a string.
|
|
68
|
+
*/
|
|
69
|
+
function parseString(value, field) {
|
|
70
|
+
if (typeof value !== 'string') {
|
|
71
|
+
throw (0, errors_1.validationError)(`${field} must be a string`, field);
|
|
15
72
|
}
|
|
73
|
+
return value;
|
|
16
74
|
}
|
|
17
|
-
/**
|
|
18
|
-
|
|
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
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Throw `VALIDATION` unless `value` is a string holding at least one
|
|
94
|
+
* non-whitespace character.
|
|
95
|
+
*
|
|
96
|
+
* Accepts: `value` — any type; `''` and whitespace-only are rejected alongside
|
|
97
|
+
* non-strings. `field` — the option or identifier name carried on the error.
|
|
98
|
+
* The rule is {@link parseNonBlankString}'s; this form is for a value the
|
|
99
|
+
* caller keeps under its declared type.
|
|
100
|
+
*
|
|
101
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
102
|
+
* checks it.
|
|
103
|
+
*
|
|
104
|
+
* Throws: `VALIDATION` naming `field`.
|
|
105
|
+
*/
|
|
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
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The value as an integer inside `bounds`.
|
|
119
|
+
*
|
|
120
|
+
* Accepts: `value` — anything; a non-number, a fraction, `NaN` and `Infinity`
|
|
121
|
+
* are all refused by the integer rule. `bounds` — omitted or `{}` bounds
|
|
122
|
+
* nothing; `min` and `max` are inclusive.
|
|
123
|
+
*
|
|
124
|
+
* Returns: `value`, typed as a number.
|
|
125
|
+
*
|
|
126
|
+
* Throws: `VALIDATION` naming `field`; the integer rule is reported before
|
|
127
|
+
* either bound.
|
|
128
|
+
*/
|
|
129
|
+
function parseInteger(value, field, bounds = {}) {
|
|
19
130
|
if (typeof value !== 'number' || !Number.isInteger(value)) {
|
|
20
|
-
throw
|
|
131
|
+
throw (0, errors_1.validationError)(`${field} must be an integer`, field);
|
|
21
132
|
}
|
|
22
133
|
if (bounds.min !== undefined && value < bounds.min) {
|
|
23
|
-
throw
|
|
134
|
+
throw (0, errors_1.validationError)(`${field} must be >= ${bounds.min}`, field);
|
|
24
135
|
}
|
|
25
136
|
if (bounds.max !== undefined && value > bounds.max) {
|
|
26
|
-
throw
|
|
137
|
+
throw (0, errors_1.validationError)(`${field} must be <= ${bounds.max}`, field);
|
|
27
138
|
}
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Throw `VALIDATION` unless `value` is an integer inside `bounds`.
|
|
143
|
+
*
|
|
144
|
+
* Accepts: `value` — any type; a non-number, a fraction, `NaN` and `Infinity`
|
|
145
|
+
* are all rejected by the integer rule. `bounds` — omitted or `{}` bounds
|
|
146
|
+
* nothing, `min` and `max` are inclusive and may be given together or alone.
|
|
147
|
+
* The rule is {@link parseInteger}'s; this form is for a value the caller
|
|
148
|
+
* keeps under its declared type.
|
|
149
|
+
*
|
|
150
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
151
|
+
* checks it.
|
|
152
|
+
*
|
|
153
|
+
* Throws: `VALIDATION` naming `field`; the integer rule is reported before
|
|
154
|
+
* either bound.
|
|
155
|
+
*/
|
|
156
|
+
function assertInteger(value, field, bounds = {}) {
|
|
157
|
+
parseInteger(value, field, bounds);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* The value as a page size this package will serve: an integer from `min` to
|
|
161
|
+
* {@link MAX_PAGE_LIMIT}.
|
|
162
|
+
*
|
|
163
|
+
* One rule for every `limit` a public method takes. Without it they would
|
|
164
|
+
* disagree three ways — no minimum on `saver.list`, so `limit: -1` would
|
|
165
|
+
* resolve; `0` refused by the history reads and accepted by the store — and
|
|
166
|
+
* none would have a ceiling, so `limit: 1e12` would resolve on five methods.
|
|
167
|
+
* The same mistake would be answered differently depending on which method a
|
|
168
|
+
* caller happened to reach for.
|
|
169
|
+
*
|
|
170
|
+
* What survives that unification is one message shape, one ceiling and two
|
|
171
|
+
* floors, because zero does not ask for the same thing on every method. A zero
|
|
172
|
+
* *page* is answered: the caller asked a listing for nothing, holds the empty
|
|
173
|
+
* array it returned, and can see that is what it got. A zero *conversation
|
|
174
|
+
* window* is refused: it feeds a model rather than a caller, an empty
|
|
175
|
+
* conversation is indistinguishable from one that never happened, and the
|
|
176
|
+
* answer the model gives is persisted as the transcript. So every call site
|
|
177
|
+
* passes its floor and says why; `1` is passed from exactly one place,
|
|
178
|
+
* `parseMessageWindow` in `src/history/internal/parse.ts`, which is the
|
|
179
|
+
* check behind `history.getMessages` and `history.forSession` alike.
|
|
180
|
+
*
|
|
181
|
+
* Accepts: `value` — any type; a non-number, a fraction, `NaN` and `Infinity`
|
|
182
|
+
* are all rejected by the integer rule. `min` — `0` where an empty result is a
|
|
183
|
+
* request the call site answers without issuing a read, `1` where an empty
|
|
184
|
+
* result would be mistaken for an empty conversation. A negative value is
|
|
185
|
+
* refused at either floor rather than read as zero: it is a page size that was
|
|
186
|
+
* computed, and the computation went wrong.
|
|
187
|
+
*
|
|
188
|
+
* Returns: `value` as a {@link PageLimit}.
|
|
189
|
+
*
|
|
190
|
+
* Throws: `VALIDATION` naming `limit`, quoting the bound broken — the floor
|
|
191
|
+
* or {@link MAX_PAGE_LIMIT} — so the caller is told what the rule is rather
|
|
192
|
+
* than only that it has one.
|
|
193
|
+
*/
|
|
194
|
+
function parseLimit(value, min) {
|
|
195
|
+
return parseInteger(value, 'limit', { min, max: exports.MAX_PAGE_LIMIT });
|
|
28
196
|
}
|
|
29
|
-
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
197
|
+
/**
|
|
198
|
+
* The value as an array of strings, copied.
|
|
199
|
+
*
|
|
200
|
+
* Accepts: `value` — anything; a non-array is refused, as is an array holding
|
|
201
|
+
* anything but a string. An empty array is valid.
|
|
202
|
+
*
|
|
203
|
+
* Returns: a copy of `value`, so a caller changing its own array afterwards
|
|
204
|
+
* changes nothing this package acts on.
|
|
205
|
+
*
|
|
206
|
+
* Throws: `VALIDATION` naming `field`, its message identifying the offending
|
|
207
|
+
* index. Walked by position rather than `Array.prototype.some`, which skips a
|
|
208
|
+
* hole in a sparse array instead of visiting it, and copied by position rather
|
|
209
|
+
* than `Array.prototype.slice`, which carries a hole forward instead of
|
|
210
|
+
* filling it: unchecked, a hole passed as a string and reached a caller who
|
|
211
|
+
* declared `string[]`.
|
|
212
|
+
*/
|
|
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);
|
|
33
224
|
}
|
|
225
|
+
return result;
|
|
34
226
|
}
|
|
35
|
-
/**
|
|
227
|
+
/**
|
|
228
|
+
* Throw `VALIDATION` unless `value` is an array of strings.
|
|
229
|
+
*
|
|
230
|
+
* Accepts: `value` — declared `readonly string[]` for a caller whose types
|
|
231
|
+
* hold; a non-array is rejected, as is an array holding anything but a
|
|
232
|
+
* string. An empty array is valid. The rule is {@link parseStringArray}'s;
|
|
233
|
+
* this form is for a value the caller keeps under its declared type.
|
|
234
|
+
*
|
|
235
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
236
|
+
* checks it.
|
|
237
|
+
*
|
|
238
|
+
* Throws: `VALIDATION` naming `field`.
|
|
239
|
+
*/
|
|
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. */
|
|
36
244
|
function hasControlChar(value) {
|
|
37
245
|
for (let i = 0; i < value.length; i++) {
|
|
38
246
|
const code = value.charCodeAt(i);
|
|
39
|
-
if (code <= 0x1f || code
|
|
247
|
+
if (code <= 0x1f || (code >= 0x7f && code <= 0x9f))
|
|
40
248
|
return true;
|
|
41
|
-
}
|
|
42
249
|
}
|
|
43
250
|
return false;
|
|
44
251
|
}
|
|
45
|
-
/**
|
|
252
|
+
/**
|
|
253
|
+
* Throw `VALIDATION` unless `value` is free of control characters.
|
|
254
|
+
*
|
|
255
|
+
* Accepts: `value` — any type, non-strings rejected first by
|
|
256
|
+
* {@link parseString}. Rejected code points are C0 (`U+0000`–`U+001F`), DEL
|
|
257
|
+
* (`U+007F`) and C1 (`U+0080`–`U+009F`). The rule is this function's own:
|
|
258
|
+
* {@link parseKeySegment} applies it to every key segment and identifier by
|
|
259
|
+
* calling this one, and this form serves a value the caller keeps under its
|
|
260
|
+
* declared type.
|
|
261
|
+
*
|
|
262
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
263
|
+
* checks it.
|
|
264
|
+
*
|
|
265
|
+
* Throws: `VALIDATION` naming `field`.
|
|
266
|
+
*
|
|
267
|
+
* Guarantees: an accepted value cannot terminate a log line or open a terminal
|
|
268
|
+
* escape sequence — neither `ESC` (`U+001B`) nor the single-byte `CSI`
|
|
269
|
+
* (`U+009B`) survives this rule. Identifiers are written into log lines by this
|
|
270
|
+
* package, and unneutralised output is CWE-117
|
|
271
|
+
* (https://cwe.mitre.org/data/definitions/117.html).
|
|
272
|
+
*/
|
|
46
273
|
function assertNoControlChars(value, field) {
|
|
274
|
+
parseString(value, field);
|
|
47
275
|
if (hasControlChar(value)) {
|
|
48
|
-
throw
|
|
276
|
+
throw (0, errors_1.validationError)(`${field} must not contain control characters`, field);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Throw `VALIDATION` unless every surrogate in `value` is part of a
|
|
281
|
+
* pair.
|
|
282
|
+
*
|
|
283
|
+
* Accepts: `value` — any type, non-strings rejected first by
|
|
284
|
+
* {@link parseString}. The rule is this function's own:
|
|
285
|
+
* {@link parseKeySegment} applies it to every key segment and identifier by
|
|
286
|
+
* calling this one, and this form serves a value the caller keeps under its
|
|
287
|
+
* declared type.
|
|
288
|
+
*
|
|
289
|
+
* Returns: nothing: the value is kept under its declared type, and this
|
|
290
|
+
* checks it.
|
|
291
|
+
*
|
|
292
|
+
* Throws: `VALIDATION` naming `field`.
|
|
293
|
+
*
|
|
294
|
+
* Guarantees: the mapping from an accepted value to its UTF-8 encoding is
|
|
295
|
+
* injective. `Buffer.from(value, 'utf8')` replaces a lone surrogate with
|
|
296
|
+
* U+FFFD, so two values differing only there would encode identically and,
|
|
297
|
+
* where that encoding is a storage key, address one object.
|
|
298
|
+
*/
|
|
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);
|
|
49
304
|
}
|
|
50
305
|
}
|
|
51
|
-
/** Throw
|
|
306
|
+
/** Throw `VALIDATION` if `value` contains `separator`. */
|
|
52
307
|
function assertNoSeparator(value, separator, field) {
|
|
308
|
+
parseString(value, field);
|
|
53
309
|
if (value.includes(separator)) {
|
|
54
|
-
throw
|
|
310
|
+
throw (0, errors_1.validationError)(`${field} must not contain the reserved "${separator}" separator`, field);
|
|
55
311
|
}
|
|
56
312
|
}
|
|
57
313
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
314
|
+
* One segment of a key, which may be empty: every rule of
|
|
315
|
+
* {@link parseIdentifier} except non-blank. The checkpoint namespace is the one
|
|
316
|
+
* such value — `''` *is* the root namespace — and it is still a segment of both
|
|
317
|
+
* the sort key and the offloaded object's key, so a lone surrogate or a control
|
|
318
|
+
* character in it is as damaging as in any other.
|
|
319
|
+
*
|
|
320
|
+
* Accepts: `value` — anything. `separator`, `field`, `maxBytes` — as
|
|
321
|
+
* {@link parseIdentifier}.
|
|
322
|
+
*
|
|
323
|
+
* Returns: `value`, typed as a string.
|
|
324
|
+
*
|
|
325
|
+
* Throws: `VALIDATION` naming `field`, in this order: string, at most
|
|
326
|
+
* `maxBytes` of UTF-8, free of `separator`, free of control characters,
|
|
327
|
+
* well-formed UTF-16.
|
|
63
328
|
*/
|
|
64
|
-
function
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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;
|
|
68
336
|
}
|
|
69
|
-
/**
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
337
|
+
/**
|
|
338
|
+
* The value as a caller-supplied identifier that reaches a DynamoDB key or an
|
|
339
|
+
* S3 object key, checked.
|
|
340
|
+
*
|
|
341
|
+
* Accepts: `value` — any type. `separator`, `field`, `maxBytes` — as the rules
|
|
342
|
+
* below.
|
|
343
|
+
*
|
|
344
|
+
* Returns: `value`, typed as a string. The caller's parser brands it.
|
|
345
|
+
*
|
|
346
|
+
* Throws: `VALIDATION` naming `field`. The rules apply in this order, and
|
|
347
|
+
* the order is part of the contract because a caller branches on which one
|
|
348
|
+
* failed: string, non-blank, at most `maxBytes` of UTF-8, free of `separator`,
|
|
349
|
+
* free of control characters, well-formed UTF-16.
|
|
350
|
+
*
|
|
351
|
+
* Guarantees: every guarantee of {@link assertNoControlChars} and
|
|
352
|
+
* {@link assertWellFormed} holds for an accepted value, and it composes into a
|
|
353
|
+
* key segment without escaping.
|
|
354
|
+
*
|
|
355
|
+
* Not guaranteed, and deliberately so: an accepted identifier is **not**
|
|
356
|
+
* normalised, and Unicode format characters (`Cf` — `U+200B` ZERO WIDTH SPACE,
|
|
357
|
+
* `U+200C`/`U+200D` the zero-width non-joiner and joiner, `U+FEFF`, `U+202E`
|
|
358
|
+
* RIGHT-TO-LEFT OVERRIDE) and the separators `U+2028`/`U+2029` are all
|
|
359
|
+
* accepted. Two facts make that safe, and one makes it necessary.
|
|
360
|
+
*
|
|
361
|
+
* It is safe because none of them can produce a collision. DynamoDB orders and
|
|
362
|
+
* compares strings by their UTF-8 bytes, and {@link assertWellFormed} has
|
|
363
|
+
* already made the mapping from an accepted identifier to those bytes
|
|
364
|
+
* injective — so two identifiers differing anywhere address two different
|
|
365
|
+
* rows. An identifier that reaches an S3 key is base64url-encoded on the way
|
|
366
|
+
* (`encodeKeyPart`), so none of these characters appears in a key at all. What
|
|
367
|
+
* one actually costs is a log line, a terminal or a console that renders two
|
|
368
|
+
* distinct identifiers alike: confusion for a reader, not a row either of them
|
|
369
|
+
* can reach. Terminal escapes and line breaks, which *are* an injection rather
|
|
370
|
+
* than a rendering, are refused by {@link assertNoControlChars}.
|
|
371
|
+
*
|
|
372
|
+
* It is necessary because refusing `Cf` would refuse ordinary text rather than
|
|
373
|
+
* hostile text. `U+200C` and `U+200D` carry meaning in Persian, Hindi and the
|
|
374
|
+
* Indic scripts — the Persian for "goes" is spelled with a `U+200C` — and
|
|
375
|
+
* `U+200D` is what joins the code points of every multi-person emoji. A rule
|
|
376
|
+
* against `Cf` would reject a `thread_id` or a store `key` taken from ordinary
|
|
377
|
+
* user text, in a package whose identifiers are the caller's own.
|
|
378
|
+
*
|
|
379
|
+
* Normalising would be worse than breaking: `NFC` folds `e` + `U+0301` onto
|
|
380
|
+
* `U+00E9`, so a row written under one form would afterwards be addressed
|
|
381
|
+
* under the other and the caller's data would stop being found. That is silent
|
|
382
|
+
* loss on upgrade, bought with a rendering nicety. A caller who wants either
|
|
383
|
+
* rule can apply it to its own identifiers before passing them.
|
|
384
|
+
*/
|
|
385
|
+
function parseIdentifier(value, separator, field, maxBytes) {
|
|
386
|
+
return parseKeySegment(parseNonBlankString(value, field), separator, field, maxBytes);
|
|
83
387
|
}
|
|
84
|
-
//# sourceMappingURL=primitives.js.map
|
|
@@ -1,21 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hides how a `ttl` option becomes an expiry.
|
|
3
|
+
*
|
|
4
|
+
* A caller gives days or seconds. The one-unit rule, the five-year cap, the
|
|
5
|
+
* epoch second DynamoDB's TTL attribute takes, and the S3 lifecycle days that
|
|
6
|
+
* keep an offloaded object alive past its row's sweep lag are all derived
|
|
7
|
+
* here, so the two spellings of the `ttl` option are accepted or rejected
|
|
8
|
+
* alike and no reader re-derives one unit from the other itself. A stored
|
|
9
|
+
* row's own epoch-second `ttl` is converted to milliseconds for `Date` where
|
|
10
|
+
* that row is read, not here.
|
|
11
|
+
*/
|
|
12
|
+
/** Maximum TTL expressed in days (5 years). */
|
|
13
|
+
export declare const MAX_TTL_DAYS: number;
|
|
14
|
+
/** Maximum TTL expressed in seconds: the same five years as {@link MAX_TTL_DAYS}. */
|
|
15
|
+
export declare const MAX_TTL_SECONDS: number;
|
|
16
|
+
/**
|
|
17
|
+
* Extra days an S3 lifecycle rule adds over the TTL it backs. DynamoDB's TTL
|
|
18
|
+
* sweep can lag up to ~48 h past the `ttl` timestamp; the offloaded object
|
|
19
|
+
* must outlive its row, never the other way round.
|
|
20
|
+
*/
|
|
21
|
+
export declare const S3_LIFECYCLE_SWEEP_MARGIN_DAYS = 2;
|
|
1
22
|
/** Time-to-live expressed in whole days or whole seconds. */
|
|
2
23
|
export type TtlOption = {
|
|
3
24
|
days: number;
|
|
4
25
|
} | {
|
|
5
26
|
seconds: number;
|
|
6
27
|
};
|
|
7
|
-
/**
|
|
28
|
+
/**
|
|
29
|
+
* A {@link TtlOption} resolved to a positive number of seconds.
|
|
30
|
+
*
|
|
31
|
+
* Accepts: `ttl` — declared as the two-shape union; a JavaScript caller, or a
|
|
32
|
+
* config built from JSON, can also reach `undefined`, a non-object, `{}`, an
|
|
33
|
+
* object carrying both keys and one carrying any other key, and each is
|
|
34
|
+
* rejected. Within a shape the value must be an integer of at least 1.
|
|
35
|
+
*
|
|
36
|
+
* Returns: whole seconds, `days × 86400` for the days form.
|
|
37
|
+
*
|
|
38
|
+
* Throws: `VALIDATION`, in this order, naming `ttl` for a value that is not
|
|
39
|
+
* an object, `ttl.<key>` for a key other than `days` or `seconds`, `ttl` for
|
|
40
|
+
* an object naming neither unit or both, and `ttl.days` or `ttl.seconds` for a
|
|
41
|
+
* value outside 1..five years. Both forms share that cap, so the two spellings
|
|
42
|
+
* of one duration are accepted or rejected alike.
|
|
43
|
+
*/
|
|
8
44
|
export declare function resolveTtlSeconds(ttl: TtlOption): number;
|
|
9
45
|
/**
|
|
10
|
-
*
|
|
11
|
-
* epoch
|
|
46
|
+
* The value DynamoDB's TTL attribute takes for an item written now: the Unix
|
|
47
|
+
* epoch second at which it expires.
|
|
48
|
+
*
|
|
49
|
+
* Accepts: `ttl` — as {@link resolveTtlSeconds}. `now` — a clock returning
|
|
50
|
+
* epoch **milliseconds**, defaulting to `Date.now`; supplied by tests and by
|
|
51
|
+
* the adapters' clock seam.
|
|
52
|
+
*
|
|
53
|
+
* Returns: `floor(now() / 1000) + resolveTtlSeconds(ttl)`. Whole seconds,
|
|
54
|
+
* because DynamoDB reads the attribute as an epoch-second Number
|
|
55
|
+
* (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/time-to-live-ttl-before-you-start.html).
|
|
12
56
|
*
|
|
13
|
-
*
|
|
57
|
+
* Throws: whatever {@link resolveTtlSeconds} throws.
|
|
14
58
|
*/
|
|
15
59
|
export declare function calculateTtlTimestamp(ttl: TtlOption, now?: () => number): number;
|
|
16
|
-
/**
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
|
|
21
|
-
|
|
60
|
+
/**
|
|
61
|
+
* The `Days` of the S3 lifecycle expiration rule that backs a TTL.
|
|
62
|
+
*
|
|
63
|
+
* Accepts: `ttl` — as {@link resolveTtlSeconds}.
|
|
64
|
+
*
|
|
65
|
+
* Returns: the TTL rounded **up** to whole days plus
|
|
66
|
+
* {@link S3_LIFECYCLE_SWEEP_MARGIN_DAYS}, so always at least
|
|
67
|
+
* `1 + margin`.
|
|
68
|
+
*
|
|
69
|
+
* Throws: whatever {@link resolveTtlSeconds} throws.
|
|
70
|
+
*
|
|
71
|
+
* Guarantees: the object outlives the row that points at it. S3 expires an
|
|
72
|
+
* object at the first midnight UTC at least `Days` after creation, while
|
|
73
|
+
* DynamoDB may keep an expired item for up to 48 hours past its `ttl`
|
|
74
|
+
* (https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/howitworks-ttl.html);
|
|
75
|
+
* the margin covers that lag, which a bare `{ days: N }` did not.
|
|
76
|
+
*/
|
|
77
|
+
export declare function lifecycleExpirationDays(ttl: TtlOption): number;
|