@farukada/aws-langgraph-dynamodb-ts 1.0.0-rc.1 → 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 +1621 -288
- package/dist/backfill/backfill.d.ts +168 -0
- package/dist/backfill/backfill.js +393 -0
- package/dist/checkpointer/actions/delete-thread.d.ts +44 -4
- package/dist/checkpointer/actions/delete-thread.js +56 -22
- package/dist/checkpointer/actions/get-tuple.d.ts +29 -5
- package/dist/checkpointer/actions/get-tuple.js +41 -13
- package/dist/checkpointer/actions/list.d.ts +42 -10
- package/dist/checkpointer/actions/list.js +86 -57
- package/dist/checkpointer/actions/put-writes.d.ts +41 -9
- package/dist/checkpointer/actions/put-writes.js +62 -48
- package/dist/checkpointer/actions/put.d.ts +82 -10
- package/dist/checkpointer/actions/put.js +166 -44
- 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 -21
- package/dist/checkpointer/internal/setup.js +65 -31
- package/dist/checkpointer/saver.d.ts +242 -42
- package/dist/checkpointer/saver.js +257 -53
- package/dist/checkpointer/types.d.ts +37 -44
- package/dist/checkpointer/types.js +10 -0
- package/dist/factory/factory.d.ts +120 -11
- package/dist/factory/factory.js +195 -16
- package/dist/factory/types.d.ts +23 -4
- package/dist/factory/types.js +8 -0
- package/dist/history/actions/add-messages.d.ts +30 -2
- package/dist/history/actions/add-messages.js +37 -57
- package/dist/history/actions/clear.d.ts +46 -4
- package/dist/history/actions/clear.js +64 -15
- package/dist/history/actions/get-messages.d.ts +41 -0
- package/dist/history/actions/get-messages.js +94 -32
- package/dist/history/actions/list-sessions.d.ts +52 -10
- package/dist/history/actions/list-sessions.js +141 -38
- package/dist/history/actions/reconcile-count.d.ts +41 -8
- package/dist/history/actions/reconcile-count.js +44 -57
- package/dist/history/chat-message-history.d.ts +200 -38
- package/dist/history/chat-message-history.js +218 -51
- 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 -19
- package/dist/history/internal/setup.js +90 -27
- package/dist/history/session-adapter.d.ts +95 -6
- package/dist/history/session-adapter.js +99 -8
- package/dist/history/types.d.ts +61 -31
- package/dist/history/types.js +10 -0
- package/dist/index.d.ts +38 -14
- package/dist/index.js +31 -12
- package/dist/shared/adapter.d.ts +135 -0
- package/dist/shared/adapter.js +143 -0
- package/dist/shared/clock.d.ts +48 -4
- package/dist/shared/clock.js +51 -4
- package/dist/shared/codec/codec.d.ts +275 -9
- package/dist/shared/codec/codec.js +394 -19
- package/dist/shared/codec/compression.d.ts +43 -6
- package/dist/shared/codec/compression.js +52 -11
- package/dist/shared/codec/json-serde.d.ts +76 -3
- package/dist/shared/codec/json-serde.js +181 -7
- package/dist/shared/codec/s3/client-types.d.ts +20 -1
- package/dist/shared/codec/s3/client-types.js +20 -1
- package/dist/shared/codec/s3/client.d.ts +35 -8
- package/dist/shared/codec/s3/client.js +61 -10
- package/dist/shared/codec/s3/config.d.ts +226 -22
- package/dist/shared/codec/s3/config.js +274 -24
- package/dist/shared/codec/s3/lifecycle.d.ts +163 -11
- package/dist/shared/codec/s3/lifecycle.js +328 -36
- package/dist/shared/codec/s3/offloader.d.ts +390 -19
- package/dist/shared/codec/s3/offloader.js +590 -50
- package/dist/shared/concurrency.d.ts +40 -3
- package/dist/shared/concurrency.js +55 -7
- package/dist/shared/dynamodb/abort.d.ts +45 -7
- package/dist/shared/dynamodb/abort.js +46 -14
- package/dist/shared/dynamodb/batch-write.d.ts +77 -13
- package/dist/shared/dynamodb/batch-write.js +146 -26
- package/dist/shared/dynamodb/cancellation.d.ts +121 -3
- package/dist/shared/dynamodb/cancellation.js +147 -2
- package/dist/shared/dynamodb/client.d.ts +159 -12
- package/dist/shared/dynamodb/client.js +135 -10
- 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 -8
- package/dist/shared/dynamodb/paginate.js +175 -6
- package/dist/shared/dynamodb/partition-delete.d.ts +181 -16
- package/dist/shared/dynamodb/partition-delete.js +312 -43
- 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 +265 -10
- package/dist/shared/dynamodb/retry.js +426 -20
- 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 +174 -8
- package/dist/shared/errors/base-error.js +154 -7
- package/dist/shared/errors/boundary.d.ts +63 -10
- package/dist/shared/errors/boundary.js +110 -13
- 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 +76 -1
- package/dist/shared/errors/error-code.js +83 -1
- package/dist/shared/errors/errors.d.ts +157 -58
- package/dist/shared/errors/errors.js +218 -93
- package/dist/shared/logging/logger.d.ts +63 -1
- package/dist/shared/logging/logger.js +97 -2
- package/dist/shared/logging/redaction.d.ts +86 -6
- package/dist/shared/logging/redaction.js +265 -24
- package/dist/shared/logging/secret-patterns.d.ts +136 -24
- package/dist/shared/logging/secret-patterns.js +165 -30
- package/dist/shared/logging/truncate.d.ts +197 -0
- package/dist/shared/logging/truncate.js +231 -0
- package/dist/shared/options.d.ts +52 -5
- package/dist/shared/options.js +9 -0
- package/dist/shared/ulid.d.ts +71 -14
- package/dist/shared/ulid.js +77 -14
- 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 +142 -5
- package/dist/shared/validation/options.js +284 -46
- package/dist/shared/validation/primitives.d.ts +287 -24
- package/dist/shared/validation/primitives.js +347 -42
- package/dist/shared/validation/ttl.d.ts +61 -12
- package/dist/shared/validation/ttl.js +102 -22
- package/dist/store/actions/list-namespaces.d.ts +76 -5
- package/dist/store/actions/list-namespaces.js +160 -22
- package/dist/store/actions/put.d.ts +33 -7
- package/dist/store/actions/put.js +53 -71
- package/dist/store/actions/reconcile-vector-index.d.ts +28 -8
- package/dist/store/actions/reconcile-vector-index.js +33 -13
- package/dist/store/actions/search.d.ts +34 -5
- package/dist/store/actions/search.js +52 -20
- package/dist/store/internal/batch-plan.d.ts +24 -9
- package/dist/store/internal/batch-plan.js +91 -34
- package/dist/store/internal/filter.d.ts +36 -2
- package/dist/store/internal/filter.js +66 -14
- 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 +146 -12
- package/dist/store/internal/semantic-search.js +317 -15
- package/dist/store/internal/setup.d.ts +86 -21
- package/dist/store/internal/setup.js +209 -26
- 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 +258 -33
- package/dist/store/store.js +309 -53
- package/dist/store/types.d.ts +74 -28
- package/dist/store/types.js +13 -0
- package/dist/store/vector-backend.d.ts +64 -3
- package/dist/store/vector-backend.js +15 -0
- package/package.json +41 -25
- package/dist/checkpointer/internal/assemble.d.ts +0 -17
- package/dist/checkpointer/internal/assemble.js +0 -38
- package/dist/checkpointer/internal/checkpoint-write-verify.d.ts +0 -24
- package/dist/checkpointer/internal/checkpoint-write-verify.js +0 -67
- package/dist/checkpointer/internal/configurable.d.ts +0 -12
- package/dist/checkpointer/internal/configurable.js +0 -24
- package/dist/checkpointer/internal/fetch.d.ts +0 -19
- package/dist/checkpointer/internal/fetch.js +0 -88
- package/dist/checkpointer/internal/filter-match.d.ts +0 -13
- package/dist/checkpointer/internal/filter-match.js +0 -15
- package/dist/checkpointer/internal/item-reader.d.ts +0 -66
- package/dist/checkpointer/internal/item-reader.js +0 -113
- package/dist/checkpointer/internal/item-writer.d.ts +0 -35
- package/dist/checkpointer/internal/item-writer.js +0 -107
- package/dist/checkpointer/internal/keys.d.ts +0 -41
- package/dist/checkpointer/internal/keys.js +0 -117
- package/dist/checkpointer/internal/list-scope.d.ts +0 -61
- package/dist/checkpointer/internal/list-scope.js +0 -108
- package/dist/checkpointer/internal/pending-sends.d.ts +0 -13
- package/dist/checkpointer/internal/pending-sends.js +0 -29
- package/dist/checkpointer/internal/query.d.ts +0 -21
- package/dist/checkpointer/internal/query.js +0 -42
- package/dist/checkpointer/internal/regular-write.d.ts +0 -28
- package/dist/checkpointer/internal/regular-write.js +0 -66
- package/dist/checkpointer/internal/special-write-cas.d.ts +0 -29
- package/dist/checkpointer/internal/special-write-cas.js +0 -104
- package/dist/checkpointer/internal/special-write-cleanup.d.ts +0 -23
- package/dist/checkpointer/internal/special-write-cleanup.js +0 -50
- package/dist/checkpointer/internal/special-write-verify.d.ts +0 -53
- package/dist/checkpointer/internal/special-write-verify.js +0 -80
- package/dist/checkpointer/internal/stored-channels.d.ts +0 -31
- package/dist/checkpointer/internal/stored-channels.js +0 -70
- package/dist/checkpointer/internal/validation.d.ts +0 -18
- package/dist/checkpointer/internal/validation.js +0 -40
- package/dist/checkpointer/internal/write-guard.d.ts +0 -20
- package/dist/checkpointer/internal/write-guard.js +0 -48
- package/dist/checkpointer/internal/write-index.d.ts +0 -36
- package/dist/checkpointer/internal/write-index.js +0 -41
- package/dist/history/internal/append-saga.d.ts +0 -25
- package/dist/history/internal/append-saga.js +0 -79
- package/dist/history/internal/compensation.d.ts +0 -25
- package/dist/history/internal/compensation.js +0 -92
- package/dist/history/internal/item-mapper.d.ts +0 -9
- package/dist/history/internal/item-mapper.js +0 -27
- package/dist/history/internal/keys.d.ts +0 -16
- package/dist/history/internal/keys.js +0 -48
- package/dist/history/internal/message-chunker.d.ts +0 -13
- package/dist/history/internal/message-chunker.js +0 -67
- package/dist/history/internal/message-transaction.d.ts +0 -25
- package/dist/history/internal/message-transaction.js +0 -61
- package/dist/history/internal/message-window.d.ts +0 -17
- package/dist/history/internal/message-window.js +0 -49
- package/dist/history/internal/query.d.ts +0 -23
- package/dist/history/internal/query.js +0 -39
- package/dist/history/internal/session-count.d.ts +0 -47
- package/dist/history/internal/session-count.js +0 -115
- package/dist/history/internal/session-title.d.ts +0 -19
- package/dist/history/internal/session-title.js +0 -43
- package/dist/history/internal/session-update.d.ts +0 -27
- package/dist/history/internal/session-update.js +0 -69
- package/dist/history/internal/title-generator.d.ts +0 -12
- package/dist/history/internal/title-generator.js +0 -41
- package/dist/history/internal/ttl-anchor.d.ts +0 -24
- package/dist/history/internal/ttl-anchor.js +0 -38
- package/dist/history/internal/validation.d.ts +0 -25
- package/dist/history/internal/validation.js +0 -53
- package/dist/shared/codec/descriptor-keys.d.ts +0 -12
- package/dist/shared/codec/descriptor-keys.js +0 -14
- package/dist/shared/codec/encode.d.ts +0 -13
- package/dist/shared/codec/encode.js +0 -43
- package/dist/shared/codec/payload-loss.d.ts +0 -12
- package/dist/shared/codec/payload-loss.js +0 -38
- package/dist/shared/codec/s3/adapter-config.d.ts +0 -13
- package/dist/shared/codec/s3/adapter-config.js +0 -22
- package/dist/shared/codec/s3/bounded-body.d.ts +0 -14
- package/dist/shared/codec/s3/bounded-body.js +0 -47
- package/dist/shared/codec/s3/delete.d.ts +0 -7
- package/dist/shared/codec/s3/delete.js +0 -28
- package/dist/shared/codec/s3/key-scope.d.ts +0 -23
- package/dist/shared/codec/s3/key-scope.js +0 -44
- package/dist/shared/codec/s3/orphans.d.ts +0 -23
- package/dist/shared/codec/s3/orphans.js +0 -71
- package/dist/shared/codec/s3/read-write.d.ts +0 -18
- package/dist/shared/codec/s3/read-write.js +0 -51
- package/dist/shared/codec/s3/retry.d.ts +0 -5
- package/dist/shared/codec/s3/retry.js +0 -22
- package/dist/shared/constants.d.ts +0 -112
- package/dist/shared/constants.js +0 -115
- package/dist/shared/dynamodb/backoff.d.ts +0 -15
- package/dist/shared/dynamodb/backoff.js +0 -48
- package/dist/shared/dynamodb/conditional-put.d.ts +0 -67
- package/dist/shared/dynamodb/conditional-put.js +0 -76
- package/dist/shared/dynamodb/drain-unprocessed.d.ts +0 -21
- package/dist/shared/dynamodb/drain-unprocessed.js +0 -43
- package/dist/shared/dynamodb/expiry.d.ts +0 -16
- package/dist/shared/dynamodb/expiry.js +0 -29
- package/dist/shared/dynamodb/paginate-core.d.ts +0 -24
- package/dist/shared/dynamodb/paginate-core.js +0 -82
- package/dist/shared/dynamodb/retry-classifier.d.ts +0 -17
- package/dist/shared/dynamodb/retry-classifier.js +0 -118
- package/dist/shared/dynamodb/retry-policy.d.ts +0 -26
- package/dist/shared/dynamodb/retry-policy.js +0 -22
- package/dist/shared/dynamodb/scan.d.ts +0 -14
- package/dist/shared/dynamodb/scan.js +0 -19
- package/dist/shared/dynamodb/types.d.ts +0 -23
- package/dist/shared/dynamodb/types.js +0 -2
- package/dist/shared/errors/upstream-error.d.ts +0 -16
- package/dist/shared/errors/upstream-error.js +0 -27
- package/dist/shared/errors/wrap-error.d.ts +0 -7
- package/dist/shared/errors/wrap-error.js +0 -15
- package/dist/shared/logging/redaction-walk.d.ts +0 -23
- package/dist/shared/logging/redaction-walk.js +0 -112
- package/dist/store/actions/get.d.ts +0 -13
- package/dist/store/actions/get.js +0 -73
- package/dist/store/internal/backend-search.d.ts +0 -4
- package/dist/store/internal/backend-search.js +0 -74
- package/dist/store/internal/candidates.d.ts +0 -23
- package/dist/store/internal/candidates.js +0 -94
- package/dist/store/internal/index-reconcile.d.ts +0 -21
- package/dist/store/internal/index-reconcile.js +0 -118
- package/dist/store/internal/index-sync.d.ts +0 -10
- package/dist/store/internal/index-sync.js +0 -25
- package/dist/store/internal/item-mapper.d.ts +0 -27
- package/dist/store/internal/item-mapper.js +0 -61
- package/dist/store/internal/keys.d.ts +0 -17
- package/dist/store/internal/keys.js +0 -41
- package/dist/store/internal/namespace-match.d.ts +0 -11
- package/dist/store/internal/namespace-match.js +0 -40
- package/dist/store/internal/option-validation.d.ts +0 -13
- package/dist/store/internal/option-validation.js +0 -77
- package/dist/store/internal/overwrite-swap.d.ts +0 -32
- package/dist/store/internal/overwrite-swap.js +0 -68
- package/dist/store/internal/persist.d.ts +0 -28
- package/dist/store/internal/persist.js +0 -64
- package/dist/store/internal/query.d.ts +0 -11
- package/dist/store/internal/query.js +0 -48
- package/dist/store/internal/ranker.d.ts +0 -18
- package/dist/store/internal/ranker.js +0 -39
- package/dist/store/internal/read-existing.d.ts +0 -23
- package/dist/store/internal/read-existing.js +0 -41
- package/dist/store/internal/score-direction.d.ts +0 -31
- package/dist/store/internal/score-direction.js +0 -38
- package/dist/store/internal/search-filter.d.ts +0 -3
- package/dist/store/internal/search-filter.js +0 -10
- package/dist/store/internal/text-path.d.ts +0 -17
- package/dist/store/internal/text-path.js +0 -147
- package/dist/store/internal/validation.d.ts +0 -18
- package/dist/store/internal/validation.js +0 -51
- package/dist/store/internal/write-verify.d.ts +0 -42
- package/dist/store/internal/write-verify.js +0 -71
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validatePaging = validatePaging;
|
|
4
|
-
exports.validateNamespace = validateNamespace;
|
|
5
|
-
exports.validateKey = validateKey;
|
|
6
|
-
exports.validateStoreKey = validateStoreKey;
|
|
7
|
-
exports.validateMaxDepth = validateMaxDepth;
|
|
8
|
-
const constants_1 = require("../../shared/constants");
|
|
9
|
-
const errors_1 = require("../../shared/errors/errors");
|
|
10
|
-
const primitives_1 = require("../../shared/validation/primitives");
|
|
11
|
-
const keys_1 = require("./keys");
|
|
12
|
-
/** Validate search/listNamespaces paging is non-negative integers. */
|
|
13
|
-
function validatePaging(offset, limit) {
|
|
14
|
-
(0, primitives_1.validateInteger)(offset, 'offset', { min: 0 });
|
|
15
|
-
(0, primitives_1.validateInteger)(limit, 'limit', { min: 0 });
|
|
16
|
-
}
|
|
17
|
-
/** Validate the namespace is non-empty and each element is a valid, ≤256-byte identifier. */
|
|
18
|
-
function validateNamespace(namespace) {
|
|
19
|
-
(0, primitives_1.validateNonEmptyArray)(namespace, 'namespace');
|
|
20
|
-
for (const element of namespace) {
|
|
21
|
-
(0, primitives_1.validateIdentifier)(element, keys_1.NAMESPACE_SEPARATOR, 'namespace element', constants_1.MAX_KEY_SEGMENT_BYTES);
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
/** Validate an item key is a non-blank, separator- and control-char-free, ≤256-byte string. */
|
|
25
|
-
function validateKey(key) {
|
|
26
|
-
(0, primitives_1.validateIdentifier)(key, keys_1.NAMESPACE_SEPARATOR, 'key', constants_1.MAX_KEY_SEGMENT_BYTES);
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Validate a namespace/key pair as the item address it becomes: each segment
|
|
30
|
-
* on its own, then the sort key they compose, which DynamoDB caps at 1024
|
|
31
|
-
* bytes regardless of how short the individual segments are.
|
|
32
|
-
*/
|
|
33
|
-
function validateStoreKey(namespace, key) {
|
|
34
|
-
validateNamespace(namespace);
|
|
35
|
-
validateKey(key);
|
|
36
|
-
const bytes = Buffer.byteLength((0, keys_1.sortKey)(namespace, key), 'utf8');
|
|
37
|
-
if (bytes > constants_1.MAX_SORT_KEY_BYTES) {
|
|
38
|
-
throw new errors_1.ValidationError(`namespace and key compose a ${bytes}-byte sort key; DynamoDB caps sort keys at ` +
|
|
39
|
-
`${constants_1.MAX_SORT_KEY_BYTES} bytes`, 'sortKey');
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Validate an optional namespace depth cap. Left unchecked, a negative value
|
|
44
|
-
* silently inverted truncation via `Array.prototype.slice(0, -n)`, which drops
|
|
45
|
-
* the *last* n elements rather than erroring.
|
|
46
|
-
*/
|
|
47
|
-
function validateMaxDepth(maxDepth) {
|
|
48
|
-
if (maxDepth === undefined)
|
|
49
|
-
return;
|
|
50
|
-
(0, primitives_1.validateInteger)(maxDepth, 'maxDepth', { min: 1 });
|
|
51
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import type { StoreContext } from './setup';
|
|
2
|
-
/** True when `error` is a {@link RetryExhaustedError} — by name, not `instanceof` (banned repo-wide). */
|
|
3
|
-
export declare function isRetryExhausted(error: Error): boolean;
|
|
4
|
-
/**
|
|
5
|
-
* True when the row is confirmed absent — used to resolve an ambiguous
|
|
6
|
-
* retry-exhausted *delete*, where the delete may well have landed server-side
|
|
7
|
-
* and only its acknowledgement was lost. Only the partition key is projected:
|
|
8
|
-
* existence is the whole question. A failure reading this is not treated as
|
|
9
|
-
* confirmation, which is fail-safe here: the caller only rethrows, and nothing
|
|
10
|
-
* is deleted on the strength of a `false`.
|
|
11
|
-
*/
|
|
12
|
-
export declare function rowIsAbsent(context: StoreContext, key: {
|
|
13
|
-
PK: string;
|
|
14
|
-
SK: string;
|
|
15
|
-
}): Promise<boolean>;
|
|
16
|
-
/** What a post-failure verification read could establish about a write. */
|
|
17
|
-
export type WriteVerdict = 'landed' | 'not-landed' | 'unverified';
|
|
18
|
-
/**
|
|
19
|
-
* Read `record`'s row back to establish what an ambiguous write actually did,
|
|
20
|
-
* comparing the row's revision with the one this write carried. Every put
|
|
21
|
-
* stamps a fresh per-call `rev`, so the comparison works for inline and
|
|
22
|
-
* offloaded records alike.
|
|
23
|
-
*
|
|
24
|
-
* - `'landed'`: the row holds this write's `rev`, so it committed server-side
|
|
25
|
-
* and only its acknowledgement was lost.
|
|
26
|
-
* - `'not-landed'`: the row was read and holds something else, or nothing —
|
|
27
|
-
* or the record carries no `rev` to compare — so this call's own upload, if
|
|
28
|
-
* any, is dead and safe to delete.
|
|
29
|
-
* - `'unverified'`: the read itself failed, so nothing is established.
|
|
30
|
-
*
|
|
31
|
-
* The third answer used to be folded into the second as a plain `false`, which
|
|
32
|
-
* made a partition that blocked both the put and this read delete the object a
|
|
33
|
-
* possibly-live row points at — permanently breaking every later read of that
|
|
34
|
-
* item. Only a *confirmed* non-commit may delete the new upload: leaking one
|
|
35
|
-
* object (reclaimed by `ensureS3LifecycleRule`) is recoverable, stranding a
|
|
36
|
-
* live row is not.
|
|
37
|
-
*/
|
|
38
|
-
export declare function verifyWriteLanded(context: StoreContext, record: {
|
|
39
|
-
PK: string;
|
|
40
|
-
SK: string;
|
|
41
|
-
rev?: string;
|
|
42
|
-
}): Promise<WriteVerdict>;
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRetryExhausted = isRetryExhausted;
|
|
4
|
-
exports.rowIsAbsent = rowIsAbsent;
|
|
5
|
-
exports.verifyWriteLanded = verifyWriteLanded;
|
|
6
|
-
const conditional_put_1 = require("../../shared/dynamodb/conditional-put");
|
|
7
|
-
const retry_1 = require("../../shared/dynamodb/retry");
|
|
8
|
-
/** True when `error` is a {@link RetryExhaustedError} — by name, not `instanceof` (banned repo-wide). */
|
|
9
|
-
function isRetryExhausted(error) {
|
|
10
|
-
return error.name === 'RetryExhaustedError';
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* True when the row is confirmed absent — used to resolve an ambiguous
|
|
14
|
-
* retry-exhausted *delete*, where the delete may well have landed server-side
|
|
15
|
-
* and only its acknowledgement was lost. Only the partition key is projected:
|
|
16
|
-
* existence is the whole question. A failure reading this is not treated as
|
|
17
|
-
* confirmation, which is fail-safe here: the caller only rethrows, and nothing
|
|
18
|
-
* is deleted on the strength of a `false`.
|
|
19
|
-
*/
|
|
20
|
-
async function rowIsAbsent(context, key) {
|
|
21
|
-
try {
|
|
22
|
-
const result = await (0, retry_1.withDynamoDBRetry)(() => context.client.get({
|
|
23
|
-
TableName: context.tableName,
|
|
24
|
-
Key: key,
|
|
25
|
-
ConsistentRead: true,
|
|
26
|
-
ProjectionExpression: '#pk',
|
|
27
|
-
ExpressionAttributeNames: { '#pk': 'PK' },
|
|
28
|
-
}), context.retry);
|
|
29
|
-
return result.Item === undefined;
|
|
30
|
-
}
|
|
31
|
-
catch {
|
|
32
|
-
return false;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Read `record`'s row back to establish what an ambiguous write actually did,
|
|
37
|
-
* comparing the row's revision with the one this write carried. Every put
|
|
38
|
-
* stamps a fresh per-call `rev`, so the comparison works for inline and
|
|
39
|
-
* offloaded records alike.
|
|
40
|
-
*
|
|
41
|
-
* - `'landed'`: the row holds this write's `rev`, so it committed server-side
|
|
42
|
-
* and only its acknowledgement was lost.
|
|
43
|
-
* - `'not-landed'`: the row was read and holds something else, or nothing —
|
|
44
|
-
* or the record carries no `rev` to compare — so this call's own upload, if
|
|
45
|
-
* any, is dead and safe to delete.
|
|
46
|
-
* - `'unverified'`: the read itself failed, so nothing is established.
|
|
47
|
-
*
|
|
48
|
-
* The third answer used to be folded into the second as a plain `false`, which
|
|
49
|
-
* made a partition that blocked both the put and this read delete the object a
|
|
50
|
-
* possibly-live row points at — permanently breaking every later read of that
|
|
51
|
-
* item. Only a *confirmed* non-commit may delete the new upload: leaking one
|
|
52
|
-
* object (reclaimed by `ensureS3LifecycleRule`) is recoverable, stranding a
|
|
53
|
-
* live row is not.
|
|
54
|
-
*/
|
|
55
|
-
async function verifyWriteLanded(context, record) {
|
|
56
|
-
if (record.rev === undefined)
|
|
57
|
-
return 'not-landed';
|
|
58
|
-
try {
|
|
59
|
-
const result = await (0, retry_1.withDynamoDBRetry)(() => context.client.get({
|
|
60
|
-
TableName: context.tableName,
|
|
61
|
-
Key: { PK: record.PK, SK: record.SK },
|
|
62
|
-
ConsistentRead: true,
|
|
63
|
-
ProjectionExpression: '#r',
|
|
64
|
-
ExpressionAttributeNames: { '#r': conditional_put_1.REVISION_ATTRIBUTE },
|
|
65
|
-
}), context.retry);
|
|
66
|
-
return result.Item?.[conditional_put_1.REVISION_ATTRIBUTE] === record.rev ? 'landed' : 'not-landed';
|
|
67
|
-
}
|
|
68
|
-
catch {
|
|
69
|
-
return 'unverified';
|
|
70
|
-
}
|
|
71
|
-
}
|