effect-dynamodb 1.39.0 → 1.40.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/dist/Aggregate.d.ts +119 -15
- package/dist/Aggregate.d.ts.map +1 -1
- package/dist/Aggregate.js +2021 -379
- package/dist/Aggregate.js.map +1 -1
- package/dist/Batch.d.ts +9 -5
- package/dist/Batch.d.ts.map +1 -1
- package/dist/Batch.js +28 -44
- package/dist/Batch.js.map +1 -1
- package/dist/Collection.d.ts.map +1 -1
- package/dist/Collection.js +12 -5
- package/dist/Collection.js.map +1 -1
- package/dist/ConsumedCapacity.js +1 -1
- package/dist/ConsumedCapacity.js.map +1 -1
- package/dist/DynamoClient.d.ts +22 -8
- package/dist/DynamoClient.d.ts.map +1 -1
- package/dist/DynamoClient.js +243 -87
- package/dist/DynamoClient.js.map +1 -1
- package/dist/Entity.d.ts +87 -22
- package/dist/Entity.d.ts.map +1 -1
- package/dist/Entity.js +2750 -514
- package/dist/Entity.js.map +1 -1
- package/dist/EventStore.d.ts +37 -15
- package/dist/EventStore.d.ts.map +1 -1
- package/dist/EventStore.js +215 -79
- package/dist/EventStore.js.map +1 -1
- package/dist/Marshaller.d.ts +39 -9
- package/dist/Marshaller.d.ts.map +1 -1
- package/dist/Marshaller.js +421 -70
- package/dist/Marshaller.js.map +1 -1
- package/dist/Query.d.ts +23 -0
- package/dist/Query.d.ts.map +1 -1
- package/dist/Query.js +49 -3
- package/dist/Query.js.map +1 -1
- package/dist/StorageEncoding.d.ts +7 -1
- package/dist/StorageEncoding.d.ts.map +1 -1
- package/dist/StorageEncoding.js +8 -2
- package/dist/StorageEncoding.js.map +1 -1
- package/dist/Table.d.ts +69 -8
- package/dist/Table.d.ts.map +1 -1
- package/dist/Transaction.d.ts.map +1 -1
- package/dist/Transaction.js +10 -4
- package/dist/Transaction.js.map +1 -1
- package/dist/change-feed/ChangeFeed.d.ts +8 -3
- package/dist/change-feed/ChangeFeed.d.ts.map +1 -1
- package/dist/change-feed/ChangeFeed.js +76 -9
- package/dist/change-feed/ChangeFeed.js.map +1 -1
- package/dist/change-feed/CheckpointStore.js +1 -1
- package/dist/change-feed/CheckpointStore.js.map +1 -1
- package/dist/change-feed/DynamoStreamsClient.d.ts +12 -5
- package/dist/change-feed/DynamoStreamsClient.d.ts.map +1 -1
- package/dist/change-feed/DynamoStreamsClient.js +15 -9
- package/dist/change-feed/DynamoStreamsClient.js.map +1 -1
- package/dist/internal/BoundCrud.d.ts +40 -32
- package/dist/internal/BoundCrud.d.ts.map +1 -1
- package/dist/internal/BoundCrud.js.map +1 -1
- package/dist/internal/BoundQuery.d.ts +1 -1
- package/dist/internal/BoundQuery.d.ts.map +1 -1
- package/dist/internal/BoundQuery.js +22 -12
- package/dist/internal/BoundQuery.js.map +1 -1
- package/dist/internal/BoundVectorQuery.d.ts.map +1 -1
- package/dist/internal/BoundVectorQuery.js +2 -1
- package/dist/internal/BoundVectorQuery.js.map +1 -1
- package/dist/internal/Capacity.d.ts +44 -4
- package/dist/internal/Capacity.d.ts.map +1 -1
- package/dist/internal/Capacity.js +89 -15
- package/dist/internal/Capacity.js.map +1 -1
- package/dist/internal/ClientOptions.d.ts +72 -0
- package/dist/internal/ClientOptions.d.ts.map +1 -0
- package/dist/internal/ClientOptions.js +79 -0
- package/dist/internal/ClientOptions.js.map +1 -0
- package/dist/internal/Cursor.d.ts +19 -10
- package/dist/internal/Cursor.d.ts.map +1 -1
- package/dist/internal/Cursor.js +25 -10
- package/dist/internal/Cursor.js.map +1 -1
- package/dist/internal/EntityCombinators.d.ts +22 -7
- package/dist/internal/EntityCombinators.d.ts.map +1 -1
- package/dist/internal/EntityCombinators.js +6 -2
- package/dist/internal/EntityCombinators.js.map +1 -1
- package/dist/internal/EntityOps.d.ts +11 -1
- package/dist/internal/EntityOps.d.ts.map +1 -1
- package/dist/internal/EntityOps.js.map +1 -1
- package/dist/internal/EventProjection.d.ts +15 -3
- package/dist/internal/EventProjection.d.ts.map +1 -1
- package/dist/internal/EventProjection.js +27 -8
- package/dist/internal/EventProjection.js.map +1 -1
- package/dist/internal/Expr.d.ts.map +1 -1
- package/dist/internal/Expr.js +53 -2
- package/dist/internal/Expr.js.map +1 -1
- package/dist/internal/ExpressionLimits.d.ts +57 -1
- package/dist/internal/ExpressionLimits.d.ts.map +1 -1
- package/dist/internal/ExpressionLimits.js +90 -1
- package/dist/internal/ExpressionLimits.js.map +1 -1
- package/dist/internal/ItemSize.d.ts +108 -4
- package/dist/internal/ItemSize.d.ts.map +1 -1
- package/dist/internal/ItemSize.js +190 -3
- package/dist/internal/ItemSize.js.map +1 -1
- package/dist/internal/MultiProjection.d.ts +7 -2
- package/dist/internal/MultiProjection.d.ts.map +1 -1
- package/dist/internal/MultiProjection.js +9 -3
- package/dist/internal/MultiProjection.js.map +1 -1
- package/dist/internal/PathBuilder.d.ts +15 -4
- package/dist/internal/PathBuilder.d.ts.map +1 -1
- package/dist/internal/PathBuilder.js +20 -10
- package/dist/internal/PathBuilder.js.map +1 -1
- package/dist/internal/ProjectionEngine.d.ts +76 -2
- package/dist/internal/ProjectionEngine.d.ts.map +1 -1
- package/dist/internal/ProjectionEngine.js +358 -28
- package/dist/internal/ProjectionEngine.js.map +1 -1
- package/dist/internal/Rekey.d.ts +21 -1
- package/dist/internal/Rekey.d.ts.map +1 -1
- package/dist/internal/Rekey.js +67 -0
- package/dist/internal/Rekey.js.map +1 -1
- package/dist/internal/RoundTrip.d.ts +36 -0
- package/dist/internal/RoundTrip.d.ts.map +1 -0
- package/dist/internal/RoundTrip.js +79 -0
- package/dist/internal/RoundTrip.js.map +1 -0
- package/dist/internal/SentRequest.d.ts +14 -0
- package/dist/internal/SentRequest.d.ts.map +1 -0
- package/dist/internal/SentRequest.js +31 -0
- package/dist/internal/SentRequest.js.map +1 -0
- package/dist/internal/TransactWriteOps.d.ts +69 -15
- package/dist/internal/TransactWriteOps.d.ts.map +1 -1
- package/dist/internal/TransactWriteOps.js +144 -107
- package/dist/internal/TransactWriteOps.js.map +1 -1
- package/dist/internal/TransactableOps.d.ts +115 -23
- package/dist/internal/TransactableOps.d.ts.map +1 -1
- package/dist/internal/TransactableOps.js +244 -80
- package/dist/internal/TransactableOps.js.map +1 -1
- package/dist/internal/WriteDiagnosis.d.ts +31 -3
- package/dist/internal/WriteDiagnosis.d.ts.map +1 -1
- package/dist/internal/WriteDiagnosis.js +128 -11
- package/dist/internal/WriteDiagnosis.js.map +1 -1
- package/package.json +2 -2
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* - by strategies that pick a request that fits — `Entity`'s wide-update split
|
|
8
8
|
* and its strongest-guard fallback ({@link expressionFits}), the guard on a
|
|
9
|
-
* 1.36 row's move ({@link asReadGuard})
|
|
9
|
+
* 1.36 row's move ({@link asReadGuard}), the whole-row guard that proves a
|
|
10
|
+
* row unchanged or isn't sent ({@link wholeRowGuard}) — refusing nothing;
|
|
10
11
|
* - by `WriteDiagnosis.ts`, to confirm DynamoDB's rejection of an expression
|
|
11
12
|
* against the request that was sent and name it.
|
|
12
13
|
*
|
|
@@ -22,6 +23,11 @@ export declare const EXPRESSION_MAX_LENGTH = 4096;
|
|
|
22
23
|
export declare const EXPRESSION_MAX_OPERATORS = 300;
|
|
23
24
|
/** DynamoDB's limit on the operands of one `IN`. */
|
|
24
25
|
export declare const IN_MAX_OPERANDS = 100;
|
|
26
|
+
/**
|
|
27
|
+
* DynamoDB's limit on all of one expression's substitution variables: its `ExpressionAttributeNames`
|
|
28
|
+
* and `ExpressionAttributeValues` together.
|
|
29
|
+
*/
|
|
30
|
+
export declare const EXPRESSION_MAX_SUBSTITUTION_BYTES: number;
|
|
25
31
|
/**
|
|
26
32
|
* The operators DynamoDB counts against an expression's 300 (#133), measured
|
|
27
33
|
* against DynamoDB: in a condition, each comparison (`=`, `<>`, `<`, `<=`,
|
|
@@ -43,6 +49,14 @@ export declare const expressionCost: (expression: string | undefined, kind?: "co
|
|
|
43
49
|
* strategy choosing a request that fits, never to refuse one.
|
|
44
50
|
*/
|
|
45
51
|
export declare const expressionFits: (expression: string, kind?: "condition" | "update") => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* The size of an expression's substitution variables as {@link EXPRESSION_MAX_SUBSTITUTION_BYTES}
|
|
54
|
+
* measures it, counted generously: each placeholder's own text with the name's UTF-8 bytes, or with
|
|
55
|
+
* the value's size by the exact item size model.
|
|
56
|
+
*/
|
|
57
|
+
export declare const substitutionBytes: (names: Readonly<Record<string, string>>, values: Readonly<Record<string, AttributeValue>>) => number;
|
|
58
|
+
/** Whether substitution variables are within DynamoDB's limit for one expression. */
|
|
59
|
+
export declare const substitutionsFit: (names: Readonly<Record<string, string>>, values: Readonly<Record<string, AttributeValue>>) => boolean;
|
|
46
60
|
/**
|
|
47
61
|
* The condition that a stored row is still as it was read (#171): it exists,
|
|
48
62
|
* and every attribute but its table key (`pkField`, `sk`) holds the value
|
|
@@ -58,4 +72,46 @@ export declare const asReadGuard: (stored: Record<string, AttributeValue>, pkFie
|
|
|
58
72
|
readonly ExpressionAttributeNames: Record<string, string>;
|
|
59
73
|
readonly ExpressionAttributeValues?: Record<string, AttributeValue>;
|
|
60
74
|
};
|
|
75
|
+
/**
|
|
76
|
+
* The condition that a stored row is still exactly the row read, or undefined when it doesn't fit
|
|
77
|
+
* DynamoDB's limits on one expression whole: never weakened to fit, so a caller that can't prove the
|
|
78
|
+
* row unchanged leaves it alone. It is {@link asReadGuard}'s condition, byte for byte, with none of
|
|
79
|
+
* its terms left out (`prefer` first, `absent` the read didn't have still absent, then every other
|
|
80
|
+
* attribute but the table key holding the value read), followed by each of `extra` the read didn't
|
|
81
|
+
* have still absent: the attributes a write to the row could add. With none to add it is the
|
|
82
|
+
* request 1.39.0 sent.
|
|
83
|
+
*/
|
|
84
|
+
export declare const wholeRowGuard: (stored: Record<string, AttributeValue>, pkField: string, prefer: ReadonlyArray<string>, absent: ReadonlyArray<string>, extra: ReadonlyArray<string>) => {
|
|
85
|
+
readonly ConditionExpression: string;
|
|
86
|
+
readonly ExpressionAttributeNames: Record<string, string>;
|
|
87
|
+
readonly ExpressionAttributeValues?: Record<string, AttributeValue>;
|
|
88
|
+
} | undefined;
|
|
89
|
+
/**
|
|
90
|
+
* The guard on a row too wide to guard whole ({@link wholeRowGuard}) of a member that stamps
|
|
91
|
+
* `prefer` (an `updatedAt`): {@link asReadGuard}'s condition with `prefer` first, held or, when
|
|
92
|
+
* the read didn't have it, still absent (for a row holding it, the request 1.39.0 sent, byte for
|
|
93
|
+
* byte: then as many other attributes as fit), followed by as many of `absent` the read didn't
|
|
94
|
+
* have still absent as fit DynamoDB's limits on one expression. A write that changes `prefer`
|
|
95
|
+
* cancels the move; one that changes only what's left out, and not `prefer`, isn't seen.
|
|
96
|
+
*/
|
|
97
|
+
export declare const preferredGuard: (stored: Record<string, AttributeValue>, pkField: string, prefer: ReadonlyArray<string>, absent: ReadonlyArray<string>) => {
|
|
98
|
+
readonly ConditionExpression: string;
|
|
99
|
+
readonly ExpressionAttributeNames: Record<string, string>;
|
|
100
|
+
readonly ExpressionAttributeValues?: Record<string, AttributeValue>;
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* What `rekey`'s move does with a row it can't prove unchanged: one whose whole guard ({@link
|
|
104
|
+
* wholeRowGuard}) doesn't fit DynamoDB's limits on one expression, with no version or `updatedAt`
|
|
105
|
+
* the library stamps to stand in (its member is neither `versioned` nor `timestamps`, it's an
|
|
106
|
+
* aggregate row whose node declares its own `updatedAt` other than a date, or it's a stream's row or
|
|
107
|
+
* a projection's row tombstone or outbox item). Every move that meets such a row switches on it, so
|
|
108
|
+
* a new answer is a type error at each:
|
|
109
|
+
*
|
|
110
|
+
* - `"report"` — the default: the row isn't moved, and is reported `unguarded`. An aggregate or a
|
|
111
|
+
* stream already part-moved is finished as under `"strongest"`.
|
|
112
|
+
* - `"strongest"` — with `writesStopped`, as 1.39.0: the strongest guard that fits is sent, so a
|
|
113
|
+
* concurrent write changing only what it leaves out would land unseen. A soft, retain or unique
|
|
114
|
+
* delete always sends it.
|
|
115
|
+
*/
|
|
116
|
+
export type UnprovableRow = "report" | "strongest";
|
|
61
117
|
//# sourceMappingURL=ExpressionLimits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionLimits.d.ts","sourceRoot":"","sources":["../../src/internal/ExpressionLimits.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ExpressionLimits.d.ts","sourceRoot":"","sources":["../../src/internal/ExpressionLimits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAG9D,kEAAkE;AAClE,eAAO,MAAM,qBAAqB,OAAO,CAAA;AACzC,oEAAoE;AACpE,eAAO,MAAM,wBAAwB,MAAM,CAAA;AAC3C,oDAAoD;AACpD,eAAO,MAAM,eAAe,MAAM,CAAA;AAClC;;;GAGG;AACH,eAAO,MAAM,iCAAiC,QAAkB,CAAA;AAQhE;;;;;;;GAOG;AACH,eAAO,MAAM,cAAc,GAAI,YAAY,MAAM,EAAE,MAAM,WAAW,GAAG,QAAQ,KAAG,MAoBjF,CAAA;AAED,qFAAqF;AACrF,eAAO,MAAM,iBAAiB,GAAI,YAAY,MAAM,KAAG,MAQtD,CAAA;AAED,2DAA2D;AAC3D,eAAO,MAAM,cAAc,GACzB,YAAY,MAAM,GAAG,SAAS,EAC9B,OAAM,WAAW,GAAG,QAAsB,KACzC;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;CAGwB,CAAA;AAEhF;;;GAGG;AACH,eAAO,MAAM,cAAc,GACzB,YAAY,MAAM,EAClB,OAAM,WAAW,GAAG,QAAsB,KACzC,OAOF,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,GAC5B,OAAO,QAAQ,CAAC,MAAM,CAAC,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MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,EACtC,SAAS,MAAM,EACf,QAAQ,aAAa,CAAC,MAAM,CAAC,EAC7B,QAAQ,aAAa,CAAC,MAAM,CAAC,KAC5B;IACD,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAA;IACpC,QAAQ,CAAC,wBAAwB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACzD,QAAQ,CAAC,yBAAyB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;CAsBpE,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,WAAW,CAAA"}
|
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
*
|
|
7
7
|
* - by strategies that pick a request that fits — `Entity`'s wide-update split
|
|
8
8
|
* and its strongest-guard fallback ({@link expressionFits}), the guard on a
|
|
9
|
-
* 1.36 row's move ({@link asReadGuard})
|
|
9
|
+
* 1.36 row's move ({@link asReadGuard}), the whole-row guard that proves a
|
|
10
|
+
* row unchanged or isn't sent ({@link wholeRowGuard}) — refusing nothing;
|
|
10
11
|
* - by `WriteDiagnosis.ts`, to confirm DynamoDB's rejection of an expression
|
|
11
12
|
* against the request that was sent and name it.
|
|
12
13
|
*
|
|
@@ -15,12 +16,18 @@
|
|
|
15
16
|
* rejected; an `IN` of 100 operands accepted and 101 rejected. The length is
|
|
16
17
|
* the expression string's own, placeholders unexpanded.
|
|
17
18
|
*/
|
|
19
|
+
import { attributeBytes, utf8Bytes } from "./ItemSize.js";
|
|
18
20
|
/** DynamoDB's limit on one expression's length, in characters. */
|
|
19
21
|
export const EXPRESSION_MAX_LENGTH = 4096;
|
|
20
22
|
/** DynamoDB's limit on one expression's operators and functions. */
|
|
21
23
|
export const EXPRESSION_MAX_OPERATORS = 300;
|
|
22
24
|
/** DynamoDB's limit on the operands of one `IN`. */
|
|
23
25
|
export const IN_MAX_OPERANDS = 100;
|
|
26
|
+
/**
|
|
27
|
+
* DynamoDB's limit on all of one expression's substitution variables: its `ExpressionAttributeNames`
|
|
28
|
+
* and `ExpressionAttributeValues` together.
|
|
29
|
+
*/
|
|
30
|
+
export const EXPRESSION_MAX_SUBSTITUTION_BYTES = 2 * 1024 * 1024;
|
|
24
31
|
/**
|
|
25
32
|
* The tokens of a compiled expression. Names and values are placeholders
|
|
26
33
|
* (`#…`, `:…`), so no operator can hide inside one.
|
|
@@ -86,6 +93,23 @@ export const expressionFits = (expression, kind = "condition") => {
|
|
|
86
93
|
cost.operators <= EXPRESSION_MAX_OPERATORS &&
|
|
87
94
|
largestInOperands(expression) <= IN_MAX_OPERANDS);
|
|
88
95
|
};
|
|
96
|
+
/**
|
|
97
|
+
* The size of an expression's substitution variables as {@link EXPRESSION_MAX_SUBSTITUTION_BYTES}
|
|
98
|
+
* measures it, counted generously: each placeholder's own text with the name's UTF-8 bytes, or with
|
|
99
|
+
* the value's size by the exact item size model.
|
|
100
|
+
*/
|
|
101
|
+
export const substitutionBytes = (names, values) => {
|
|
102
|
+
let bytes = 0;
|
|
103
|
+
for (const [placeholder, name] of Object.entries(names)) {
|
|
104
|
+
bytes += utf8Bytes(placeholder) + utf8Bytes(name);
|
|
105
|
+
}
|
|
106
|
+
for (const [placeholder, value] of Object.entries(values)) {
|
|
107
|
+
bytes += utf8Bytes(placeholder) + attributeBytes(value);
|
|
108
|
+
}
|
|
109
|
+
return bytes;
|
|
110
|
+
};
|
|
111
|
+
/** Whether substitution variables are within DynamoDB's limit for one expression. */
|
|
112
|
+
export const substitutionsFit = (names, values) => substitutionBytes(names, values) <= EXPRESSION_MAX_SUBSTITUTION_BYTES;
|
|
89
113
|
/**
|
|
90
114
|
* The condition that a stored row is still as it was read (#171): it exists,
|
|
91
115
|
* and every attribute but its table key (`pkField`, `sk`) holds the value
|
|
@@ -105,6 +129,8 @@ export const asReadGuard = (stored, pkField, prefer, absent = []) => {
|
|
|
105
129
|
expression = `${expression} AND attribute_not_exists(#ga${i})`;
|
|
106
130
|
}
|
|
107
131
|
const attrs = [...new Set([...prefer, ...Object.keys(stored).sort()])].filter((attr) => attr !== pkField && attr !== "sk" && stored[attr] !== undefined);
|
|
132
|
+
// Its substitutions stay far below EXPRESSION_MAX_SUBSTITUTION_BYTES: a row's names and values
|
|
133
|
+
// are at most 400 KB, and an expression that fits names at most a few hundred placeholders.
|
|
108
134
|
for (const [i, attr] of attrs.entries()) {
|
|
109
135
|
const clause = `#g${i} = :g${i}`;
|
|
110
136
|
if (!expressionFits(`${expression} AND ${clause}`))
|
|
@@ -119,4 +145,67 @@ export const asReadGuard = (stored, pkField, prefer, absent = []) => {
|
|
|
119
145
|
...(Object.keys(values).length > 0 && { ExpressionAttributeValues: values }),
|
|
120
146
|
};
|
|
121
147
|
};
|
|
148
|
+
/**
|
|
149
|
+
* The condition that a stored row is still exactly the row read, or undefined when it doesn't fit
|
|
150
|
+
* DynamoDB's limits on one expression whole: never weakened to fit, so a caller that can't prove the
|
|
151
|
+
* row unchanged leaves it alone. It is {@link asReadGuard}'s condition, byte for byte, with none of
|
|
152
|
+
* its terms left out (`prefer` first, `absent` the read didn't have still absent, then every other
|
|
153
|
+
* attribute but the table key holding the value read), followed by each of `extra` the read didn't
|
|
154
|
+
* have still absent: the attributes a write to the row could add. With none to add it is the
|
|
155
|
+
* request 1.39.0 sent.
|
|
156
|
+
*/
|
|
157
|
+
export const wholeRowGuard = (stored, pkField, prefer, absent, extra) => {
|
|
158
|
+
const keyed = (attr) => attr !== pkField && attr !== "sk";
|
|
159
|
+
const held = new Set([...prefer, ...Object.keys(stored)].filter((attr) => keyed(attr)));
|
|
160
|
+
const guard = asReadGuard(stored, pkField, prefer, absent);
|
|
161
|
+
const names = { ...guard.ExpressionAttributeNames };
|
|
162
|
+
const values = { ...guard.ExpressionAttributeValues };
|
|
163
|
+
// `asReadGuard` leaves out what doesn't fit: whole, it named every attribute the read had.
|
|
164
|
+
const named = Object.keys(names).filter((placeholder) => /^#g\d+$/.test(placeholder)).length;
|
|
165
|
+
if (named !== [...held].filter((attr) => stored[attr] !== undefined).length)
|
|
166
|
+
return undefined;
|
|
167
|
+
const inGuard = new Set(Object.values(names));
|
|
168
|
+
let expression = guard.ConditionExpression;
|
|
169
|
+
const missing = [...new Set(extra)].filter((attr) => keyed(attr) && stored[attr] === undefined && !inGuard.has(attr));
|
|
170
|
+
for (const [i, attr] of missing.entries()) {
|
|
171
|
+
names[`#gx${i}`] = attr;
|
|
172
|
+
expression = `${expression} AND attribute_not_exists(#gx${i})`;
|
|
173
|
+
}
|
|
174
|
+
if (!expressionFits(expression) || !substitutionsFit(names, values))
|
|
175
|
+
return undefined;
|
|
176
|
+
return {
|
|
177
|
+
ConditionExpression: expression,
|
|
178
|
+
ExpressionAttributeNames: names,
|
|
179
|
+
...(Object.keys(values).length > 0 && { ExpressionAttributeValues: values }),
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* The guard on a row too wide to guard whole ({@link wholeRowGuard}) of a member that stamps
|
|
184
|
+
* `prefer` (an `updatedAt`): {@link asReadGuard}'s condition with `prefer` first, held or, when
|
|
185
|
+
* the read didn't have it, still absent (for a row holding it, the request 1.39.0 sent, byte for
|
|
186
|
+
* byte: then as many other attributes as fit), followed by as many of `absent` the read didn't
|
|
187
|
+
* have still absent as fit DynamoDB's limits on one expression. A write that changes `prefer`
|
|
188
|
+
* cancels the move; one that changes only what's left out, and not `prefer`, isn't seen.
|
|
189
|
+
*/
|
|
190
|
+
export const preferredGuard = (stored, pkField, prefer, absent) => {
|
|
191
|
+
const guard = asReadGuard(stored, pkField, prefer, prefer);
|
|
192
|
+
const names = { ...guard.ExpressionAttributeNames };
|
|
193
|
+
const values = { ...guard.ExpressionAttributeValues };
|
|
194
|
+
let expression = guard.ConditionExpression;
|
|
195
|
+
const missing = [...new Set(absent)].filter((attr) => attr !== pkField && attr !== "sk" && stored[attr] === undefined && !prefer.includes(attr));
|
|
196
|
+
for (const [i, attr] of missing.entries()) {
|
|
197
|
+
const clause = `attribute_not_exists(#gx${i})`;
|
|
198
|
+
if (!expressionFits(`${expression} AND ${clause}`))
|
|
199
|
+
continue;
|
|
200
|
+
if (!substitutionsFit({ ...names, [`#gx${i}`]: attr }, values))
|
|
201
|
+
continue;
|
|
202
|
+
names[`#gx${i}`] = attr;
|
|
203
|
+
expression = `${expression} AND ${clause}`;
|
|
204
|
+
}
|
|
205
|
+
return {
|
|
206
|
+
ConditionExpression: expression,
|
|
207
|
+
ExpressionAttributeNames: names,
|
|
208
|
+
...(Object.keys(values).length > 0 && { ExpressionAttributeValues: values }),
|
|
209
|
+
};
|
|
210
|
+
};
|
|
122
211
|
//# sourceMappingURL=ExpressionLimits.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressionLimits.js","sourceRoot":"","sources":["../../src/internal/ExpressionLimits.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ExpressionLimits.js","sourceRoot":"","sources":["../../src/internal/ExpressionLimits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzD,kEAAkE;AAClE,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,CAAA;AACzC,oEAAoE;AACpE,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAA;AAC3C,oDAAoD;AACpD,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;AAClC;;;GAGG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAA;AAEhE;;;GAGG;AACH,MAAM,gBAAgB,GAAG,sDAAsD,CAAA;AAE/E;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,UAAkB,EAAE,IAA4B,EAAU,EAAE;IACzF,MAAM,MAAM,GAAG,UAAU,CAAC,KAAK,CAAC,gBA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,CAAC,gBAAgB,CAAC,EAAE,GAAG,KAAK,EAAE,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,MAAM,CAAC;YAAE,SAAQ;QACxE,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,GAAG,IAAI,CAAA;QACvB,UAAU,GAAG,GAAG,UAAU,QAAQ,MAAM,EAAE,CAAA;IAC5C,CAAC;IACD,OAAO;QACL,mBAAmB,EAAE,UAAU;QAC/B,wBAAwB,EAAE,KAAK;QAC/B,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,yBAAyB,EAAE,MAAM,EAAE,CAAC;KAC7E,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @internal Exact sizes by DynamoDB's own accounting (#144), the one measure
|
|
3
|
-
* the library uses: `Batch.write`
|
|
4
|
-
*
|
|
3
|
+
* the library uses: `Batch.write` splits its requests by it and an
|
|
4
|
+
* aggregate's `rekey` its transactions ({@link packRequests}), and the
|
|
5
|
+
* failure-time diagnosis of DynamoDB's write limits
|
|
5
6
|
* (`internal/WriteDiagnosis.ts`) names the item at fault by it. Nothing here
|
|
6
7
|
* refuses a write: DynamoDB's own limits are never pre-checked.
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
+
* Two measures, for two kinds of limit:
|
|
10
|
+
*
|
|
11
|
+
* - **Item size** ({@link itemBytes}, {@link transactItemBytes}): what the
|
|
12
|
+
* 400 KB item and 4 MB transaction limits count. Rules below.
|
|
13
|
+
* - **Request body** ({@link jsonBytes}): what the 16 MB limit on one
|
|
14
|
+
* request counts — the JSON text the AWS SDK sends, where a control
|
|
15
|
+
* character in a string is 6 bytes (`\u0000`), a quote or backslash 2, and
|
|
16
|
+
* binary is base64. Item size counts 1 byte for each, so 25 items within
|
|
17
|
+
* 400 KB can still be over 16 MB on the wire. See {@link REQUEST_MAX_BYTES}.
|
|
18
|
+
*
|
|
19
|
+
* The item-size rules were measured on DynamoDB Local from the `Payload Size` its 4 MB
|
|
9
20
|
* rejection reports, and confirmed at the exact boundaries: an item of
|
|
10
21
|
* 409,600 bytes is accepted and 409,601 rejected; a transaction of 4,194,304
|
|
11
22
|
* bytes is accepted and 4,194,305 rejected.
|
|
@@ -19,7 +30,7 @@
|
|
|
19
30
|
* - A transaction action: its item (a Put) or its key (any other action), plus
|
|
20
31
|
* each of its expressions — see {@link transactItemBytes}.
|
|
21
32
|
*/
|
|
22
|
-
import type { AttributeValue, TransactWriteItem } from "@aws-sdk/client-dynamodb";
|
|
33
|
+
import type { AttributeValue, TransactWriteItem, WriteRequest } from "@aws-sdk/client-dynamodb";
|
|
23
34
|
/**
|
|
24
35
|
* DynamoDB's limit on the size of one `TransactWriteItems` request: 4 MB, in
|
|
25
36
|
* the binary megabytes DynamoDB uses for every size limit — 4,194,304 bytes,
|
|
@@ -71,4 +82,97 @@ export declare const expressionBytes: (expression: string | undefined, names: Re
|
|
|
71
82
|
export declare const transactItemBytes: (item: TransactWriteItem) => number;
|
|
72
83
|
/** A `TransactWriteItems` request's size: the sum of its actions' contributions. */
|
|
73
84
|
export declare const transactionBytes: (items: ReadonlyArray<TransactWriteItem>) => number;
|
|
85
|
+
/**
|
|
86
|
+
* The 16 MB limit on one request's body: 16,777,216 bytes of the JSON the AWS
|
|
87
|
+
* SDK sends, measured by {@link jsonBytes}.
|
|
88
|
+
*
|
|
89
|
+
* AWS documents 16 MB for `BatchWriteItem` ("up to 16 MB of data over the
|
|
90
|
+
* network"). DynamoDB Local rejects any request whose body is over 16 MiB:
|
|
91
|
+
* measured, 16,777,216 bytes accepted and 16,777,217 rejected, by every
|
|
92
|
+
* operation (`BatchWriteItem`, `TransactWriteItems`, `PutItem`, reads alike),
|
|
93
|
+
* with HTTP 413, before the request is read. The bytes are the raw body's —
|
|
94
|
+
* UTF-8 bytes, not characters. How AWS measures it, and whether it applies the
|
|
95
|
+
* limit to other operations, is unverified.
|
|
96
|
+
*/
|
|
97
|
+
export declare const REQUEST_MAX_BYTES: number;
|
|
98
|
+
/** DynamoDB's limit on the write requests of one `BatchWriteItem` request. */
|
|
99
|
+
export declare const BATCH_WRITE_REQUESTS_LIMIT = 25;
|
|
100
|
+
/**
|
|
101
|
+
* The UTF-8 bytes of `JSON.stringify(text)`, quotes included, without building
|
|
102
|
+
* either: `"` and `\` escape to 2 bytes; a control character to 2 (`\b`, `\t`,
|
|
103
|
+
* `\n`, `\f`, `\r`) or 6 (`\u0000`); a lone surrogate to 6 (`\ud800`); any
|
|
104
|
+
* other character is its UTF-8 bytes (U+2028 and U+2029 are not escaped).
|
|
105
|
+
*/
|
|
106
|
+
export declare const jsonStringBytes: (text: string) => number;
|
|
107
|
+
/**
|
|
108
|
+
* The UTF-8 bytes of the JSON the AWS SDK sends for `value`: `JSON.stringify`'s
|
|
109
|
+
* output — a property whose value is `undefined` left out — with binary
|
|
110
|
+
* (`Uint8Array`) as a base64 string. A request's body is `jsonBytes` of its
|
|
111
|
+
* input, plus, for `TransactWriteItems`, the `ClientRequestToken` the SDK fills
|
|
112
|
+
* in ({@link transactWriteBodyBytes}). Checked against the body the SDK builds
|
|
113
|
+
* (`test/RequestSize.test.ts`).
|
|
114
|
+
*/
|
|
115
|
+
export declare const jsonBytes: (value: unknown) => number;
|
|
116
|
+
/** Request-level fields sent beside a request's items: `ReturnConsumedCapacity`. */
|
|
117
|
+
export type RequestFields = {
|
|
118
|
+
readonly ReturnConsumedCapacity?: "TOTAL" | "INDEXES" | undefined;
|
|
119
|
+
};
|
|
120
|
+
/** A `BatchWriteItem` request's body as sent: its input, measured by {@link jsonBytes}. */
|
|
121
|
+
export declare const batchWriteBodyBytes: (input: {
|
|
122
|
+
readonly RequestItems?: Record<string, ReadonlyArray<WriteRequest>> | undefined;
|
|
123
|
+
}) => number;
|
|
124
|
+
/**
|
|
125
|
+
* A `TransactWriteItems` request's body as sent: its input, and the
|
|
126
|
+
* `ClientRequestToken` the AWS SDK fills when the input has none (60 bytes).
|
|
127
|
+
*/
|
|
128
|
+
export declare const transactWriteBodyBytes: (input: {
|
|
129
|
+
readonly TransactItems?: ReadonlyArray<TransactWriteItem> | undefined;
|
|
130
|
+
readonly ClientRequestToken?: string | undefined;
|
|
131
|
+
}) => number;
|
|
132
|
+
/**
|
|
133
|
+
* What one unit adds to a request: a `BatchWriteItem` write request, or the
|
|
134
|
+
* actions that must share one transaction (a `rekey` move's Put and Delete).
|
|
135
|
+
*/
|
|
136
|
+
export type RequestUnit = {
|
|
137
|
+
/** Its write requests or actions, against the request's count limit. */
|
|
138
|
+
readonly count: number;
|
|
139
|
+
/** Its item size ({@link transactionBytes}), against a transaction's 4 MB; 0 for a batch. */
|
|
140
|
+
readonly bytes: number;
|
|
141
|
+
/** Its body bytes ({@link jsonBytes}), each entry's separating comma included. */
|
|
142
|
+
readonly wire: number;
|
|
143
|
+
/**
|
|
144
|
+
* Body shared by every unit with the same `key`, sent once per request: a
|
|
145
|
+
* `BatchWriteItem` table's `"<name>":[]` and its comma.
|
|
146
|
+
*/
|
|
147
|
+
readonly shared?: {
|
|
148
|
+
readonly key: string;
|
|
149
|
+
readonly wire: number;
|
|
150
|
+
} | undefined;
|
|
151
|
+
};
|
|
152
|
+
/** One kind of request: its limits, and its body before any unit. */
|
|
153
|
+
export type RequestShape = {
|
|
154
|
+
readonly count: number;
|
|
155
|
+
/** A transaction's 4 MB of item size; none for a batch. */
|
|
156
|
+
readonly bytes?: number | undefined;
|
|
157
|
+
/** The body with no unit in it, less one comma (the first entry has none). */
|
|
158
|
+
readonly envelope: number;
|
|
159
|
+
};
|
|
160
|
+
/** A `BatchWriteItem` request, sent with `fields` beside its items. */
|
|
161
|
+
export declare const batchWriteShape: (fields: RequestFields) => RequestShape;
|
|
162
|
+
/** A `TransactWriteItems` request, sent with `fields` beside its items. */
|
|
163
|
+
export declare const transactWriteShape: (fields: RequestFields) => RequestShape;
|
|
164
|
+
/** A write request to `tableName`, as a unit of a `BatchWriteItem` request. */
|
|
165
|
+
export declare const batchWriteUnit: (tableName: string, request: WriteRequest) => RequestUnit;
|
|
166
|
+
/** Actions that must share one transaction, as a unit of a `TransactWriteItems` request. */
|
|
167
|
+
export declare const transactWriteUnit: (items: ReadonlyArray<TransactWriteItem>) => RequestUnit;
|
|
168
|
+
/**
|
|
169
|
+
* Split `units`, in order, into requests within every limit DynamoDB applies to
|
|
170
|
+
* one: `shape.count` entries, `shape.bytes` of item size, and
|
|
171
|
+
* {@link REQUEST_MAX_BYTES} of body. Greedy: a request takes the next unit
|
|
172
|
+
* while it fits, and always at least one — a unit over a limit on its own goes
|
|
173
|
+
* alone, for DynamoDB to reject and the diagnosis to name. It picks request
|
|
174
|
+
* boundaries and refuses nothing. Units within every limit are split exactly
|
|
175
|
+
* as by their count alone.
|
|
176
|
+
*/
|
|
177
|
+
export declare const packRequests: <U>(units: ReadonlyArray<U>, unitOf: (unit: U) => RequestUnit, shape: RequestShape) => Array<Array<U>>;
|
|
74
178
|
//# sourceMappingURL=ItemSize.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemSize.d.ts","sourceRoot":"","sources":["../../src/internal/ItemSize.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ItemSize.d.ts","sourceRoot":"","sources":["../../src/internal/ItemSize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAG/F;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,QAAkB,CAAA;AAEvD,gFAAgF;AAChF,eAAO,MAAM,cAAc,QAAa,CAAA;AAIxC,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,MAAqC,CAAA;AAE9E;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW,GAAI,GAAG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,EAC5B,OAAO,aAAa,CAAC,CAAC,CAAC,EACvB,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,WAAW,EAChC,OAAO,YAAY,KAClB,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CA+BhB,CAAA"}
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @internal Exact sizes by DynamoDB's own accounting (#144), the one measure
|
|
3
|
-
* the library uses: `Batch.write`
|
|
4
|
-
*
|
|
3
|
+
* the library uses: `Batch.write` splits its requests by it and an
|
|
4
|
+
* aggregate's `rekey` its transactions ({@link packRequests}), and the
|
|
5
|
+
* failure-time diagnosis of DynamoDB's write limits
|
|
5
6
|
* (`internal/WriteDiagnosis.ts`) names the item at fault by it. Nothing here
|
|
6
7
|
* refuses a write: DynamoDB's own limits are never pre-checked.
|
|
7
8
|
*
|
|
8
|
-
*
|
|
9
|
+
* Two measures, for two kinds of limit:
|
|
10
|
+
*
|
|
11
|
+
* - **Item size** ({@link itemBytes}, {@link transactItemBytes}): what the
|
|
12
|
+
* 400 KB item and 4 MB transaction limits count. Rules below.
|
|
13
|
+
* - **Request body** ({@link jsonBytes}): what the 16 MB limit on one
|
|
14
|
+
* request counts — the JSON text the AWS SDK sends, where a control
|
|
15
|
+
* character in a string is 6 bytes (`\u0000`), a quote or backslash 2, and
|
|
16
|
+
* binary is base64. Item size counts 1 byte for each, so 25 items within
|
|
17
|
+
* 400 KB can still be over 16 MB on the wire. See {@link REQUEST_MAX_BYTES}.
|
|
18
|
+
*
|
|
19
|
+
* The item-size rules were measured on DynamoDB Local from the `Payload Size` its 4 MB
|
|
9
20
|
* rejection reports, and confirmed at the exact boundaries: an item of
|
|
10
21
|
* 409,600 bytes is accepted and 409,601 rejected; a transaction of 4,194,304
|
|
11
22
|
* bytes is accepted and 4,194,305 rejected.
|
|
@@ -19,6 +30,7 @@
|
|
|
19
30
|
* - A transaction action: its item (a Put) or its key (any other action), plus
|
|
20
31
|
* each of its expressions — see {@link transactItemBytes}.
|
|
21
32
|
*/
|
|
33
|
+
import { TRANSACT_WRITE_ITEMS_LIMIT } from "@effect-dynamodb/schema/Errors.js";
|
|
22
34
|
/**
|
|
23
35
|
* DynamoDB's limit on the size of one `TransactWriteItems` request: 4 MB, in
|
|
24
36
|
* the binary megabytes DynamoDB uses for every size limit — 4,194,304 bytes,
|
|
@@ -142,4 +154,179 @@ export const transactItemBytes = (item) => {
|
|
|
142
154
|
};
|
|
143
155
|
/** A `TransactWriteItems` request's size: the sum of its actions' contributions. */
|
|
144
156
|
export const transactionBytes = (items) => items.reduce((sum, item) => sum + transactItemBytes(item), 0);
|
|
157
|
+
// ---------------------------------------------------------------------------
|
|
158
|
+
// Request body: the 16 MB limit
|
|
159
|
+
// ---------------------------------------------------------------------------
|
|
160
|
+
/**
|
|
161
|
+
* The 16 MB limit on one request's body: 16,777,216 bytes of the JSON the AWS
|
|
162
|
+
* SDK sends, measured by {@link jsonBytes}.
|
|
163
|
+
*
|
|
164
|
+
* AWS documents 16 MB for `BatchWriteItem` ("up to 16 MB of data over the
|
|
165
|
+
* network"). DynamoDB Local rejects any request whose body is over 16 MiB:
|
|
166
|
+
* measured, 16,777,216 bytes accepted and 16,777,217 rejected, by every
|
|
167
|
+
* operation (`BatchWriteItem`, `TransactWriteItems`, `PutItem`, reads alike),
|
|
168
|
+
* with HTTP 413, before the request is read. The bytes are the raw body's —
|
|
169
|
+
* UTF-8 bytes, not characters. How AWS measures it, and whether it applies the
|
|
170
|
+
* limit to other operations, is unverified.
|
|
171
|
+
*/
|
|
172
|
+
export const REQUEST_MAX_BYTES = 16 * 1024 * 1024;
|
|
173
|
+
/** DynamoDB's limit on the write requests of one `BatchWriteItem` request. */
|
|
174
|
+
export const BATCH_WRITE_REQUESTS_LIMIT = 25;
|
|
175
|
+
/**
|
|
176
|
+
* The UTF-8 bytes of `JSON.stringify(text)`, quotes included, without building
|
|
177
|
+
* either: `"` and `\` escape to 2 bytes; a control character to 2 (`\b`, `\t`,
|
|
178
|
+
* `\n`, `\f`, `\r`) or 6 (`\u0000`); a lone surrogate to 6 (`\ud800`); any
|
|
179
|
+
* other character is its UTF-8 bytes (U+2028 and U+2029 are not escaped).
|
|
180
|
+
*/
|
|
181
|
+
export const jsonStringBytes = (text) => {
|
|
182
|
+
let bytes = 2;
|
|
183
|
+
for (let i = 0; i < text.length; i++) {
|
|
184
|
+
const c = text.charCodeAt(i);
|
|
185
|
+
if (c < 0x20) {
|
|
186
|
+
bytes += c === 0x08 || c === 0x09 || c === 0x0a || c === 0x0c || c === 0x0d ? 2 : 6;
|
|
187
|
+
}
|
|
188
|
+
else if (c === 0x22 || c === 0x5c) {
|
|
189
|
+
bytes += 2;
|
|
190
|
+
}
|
|
191
|
+
else if (c < 0x80) {
|
|
192
|
+
bytes += 1;
|
|
193
|
+
}
|
|
194
|
+
else if (c < 0x800) {
|
|
195
|
+
bytes += 2;
|
|
196
|
+
}
|
|
197
|
+
else if (c >= 0xd800 && c <= 0xdbff) {
|
|
198
|
+
const next = text.charCodeAt(i + 1);
|
|
199
|
+
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
200
|
+
bytes += 4;
|
|
201
|
+
i++;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
bytes += 6;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
else if (c >= 0xdc00 && c <= 0xdfff) {
|
|
208
|
+
bytes += 6;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
bytes += 3;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
return bytes;
|
|
215
|
+
};
|
|
216
|
+
/**
|
|
217
|
+
* The UTF-8 bytes of the JSON the AWS SDK sends for `value`: `JSON.stringify`'s
|
|
218
|
+
* output — a property whose value is `undefined` left out — with binary
|
|
219
|
+
* (`Uint8Array`) as a base64 string. A request's body is `jsonBytes` of its
|
|
220
|
+
* input, plus, for `TransactWriteItems`, the `ClientRequestToken` the SDK fills
|
|
221
|
+
* in ({@link transactWriteBodyBytes}). Checked against the body the SDK builds
|
|
222
|
+
* (`test/RequestSize.test.ts`).
|
|
223
|
+
*/
|
|
224
|
+
export const jsonBytes = (value) => {
|
|
225
|
+
if (typeof value === "string")
|
|
226
|
+
return jsonStringBytes(value);
|
|
227
|
+
if (typeof value === "number")
|
|
228
|
+
return Number.isFinite(value) ? String(value).length : 4;
|
|
229
|
+
if (typeof value === "boolean")
|
|
230
|
+
return value ? 4 : 5;
|
|
231
|
+
if (value === null || typeof value !== "object")
|
|
232
|
+
return 4;
|
|
233
|
+
if (value instanceof Uint8Array)
|
|
234
|
+
return 2 + 4 * Math.ceil(value.byteLength / 3);
|
|
235
|
+
if (Array.isArray(value)) {
|
|
236
|
+
let bytes = value.length === 0 ? 2 : 1 + value.length;
|
|
237
|
+
for (const element of value)
|
|
238
|
+
bytes += jsonBytes(element);
|
|
239
|
+
return bytes;
|
|
240
|
+
}
|
|
241
|
+
let bytes = 1;
|
|
242
|
+
let entries = 0;
|
|
243
|
+
for (const key of Object.keys(value)) {
|
|
244
|
+
const element = value[key];
|
|
245
|
+
if (element === undefined || typeof element === "function" || typeof element === "symbol") {
|
|
246
|
+
continue;
|
|
247
|
+
}
|
|
248
|
+
bytes += jsonStringBytes(key) + 1 + jsonBytes(element);
|
|
249
|
+
entries++;
|
|
250
|
+
}
|
|
251
|
+
return bytes + Math.max(entries, 1);
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
* Stands in for the `ClientRequestToken` the AWS SDK fills on a
|
|
255
|
+
* `TransactWriteItems` whose input has none: a UUID, 36 characters.
|
|
256
|
+
*/
|
|
257
|
+
const SDK_TRANSACTION_TOKEN = "00000000-0000-0000-0000-000000000000";
|
|
258
|
+
/** A `BatchWriteItem` request's body as sent: its input, measured by {@link jsonBytes}. */
|
|
259
|
+
export const batchWriteBodyBytes = (input) => jsonBytes(input);
|
|
260
|
+
/**
|
|
261
|
+
* A `TransactWriteItems` request's body as sent: its input, and the
|
|
262
|
+
* `ClientRequestToken` the AWS SDK fills when the input has none (60 bytes).
|
|
263
|
+
*/
|
|
264
|
+
export const transactWriteBodyBytes = (input) => jsonBytes(input.ClientRequestToken === undefined
|
|
265
|
+
? { ...input, ClientRequestToken: SDK_TRANSACTION_TOKEN }
|
|
266
|
+
: input);
|
|
267
|
+
/** A `BatchWriteItem` request, sent with `fields` beside its items. */
|
|
268
|
+
export const batchWriteShape = (fields) => ({
|
|
269
|
+
count: BATCH_WRITE_REQUESTS_LIMIT,
|
|
270
|
+
envelope: batchWriteBodyBytes({ RequestItems: {}, ...fields }) - 1,
|
|
271
|
+
});
|
|
272
|
+
/** A `TransactWriteItems` request, sent with `fields` beside its items. */
|
|
273
|
+
export const transactWriteShape = (fields) => ({
|
|
274
|
+
count: TRANSACT_WRITE_ITEMS_LIMIT,
|
|
275
|
+
bytes: TRANSACT_WRITE_MAX_BYTES,
|
|
276
|
+
envelope: transactWriteBodyBytes({ TransactItems: [], ...fields }) - 1,
|
|
277
|
+
});
|
|
278
|
+
/** A write request to `tableName`, as a unit of a `BatchWriteItem` request. */
|
|
279
|
+
export const batchWriteUnit = (tableName, request) => ({
|
|
280
|
+
count: 1,
|
|
281
|
+
bytes: 0,
|
|
282
|
+
wire: jsonBytes(request) + 1,
|
|
283
|
+
shared: { key: tableName, wire: jsonStringBytes(tableName) + 3 },
|
|
284
|
+
});
|
|
285
|
+
/** Actions that must share one transaction, as a unit of a `TransactWriteItems` request. */
|
|
286
|
+
export const transactWriteUnit = (items) => ({
|
|
287
|
+
count: items.length,
|
|
288
|
+
bytes: transactionBytes(items),
|
|
289
|
+
wire: items.reduce((sum, item) => sum + jsonBytes(item) + 1, 0),
|
|
290
|
+
});
|
|
291
|
+
/**
|
|
292
|
+
* Split `units`, in order, into requests within every limit DynamoDB applies to
|
|
293
|
+
* one: `shape.count` entries, `shape.bytes` of item size, and
|
|
294
|
+
* {@link REQUEST_MAX_BYTES} of body. Greedy: a request takes the next unit
|
|
295
|
+
* while it fits, and always at least one — a unit over a limit on its own goes
|
|
296
|
+
* alone, for DynamoDB to reject and the diagnosis to name. It picks request
|
|
297
|
+
* boundaries and refuses nothing. Units within every limit are split exactly
|
|
298
|
+
* as by their count alone.
|
|
299
|
+
*/
|
|
300
|
+
export const packRequests = (units, unitOf, shape) => {
|
|
301
|
+
const requests = [];
|
|
302
|
+
let request = [];
|
|
303
|
+
let count = 0;
|
|
304
|
+
let bytes = 0;
|
|
305
|
+
let wire = shape.envelope;
|
|
306
|
+
let shared = new Set();
|
|
307
|
+
for (const unit of units) {
|
|
308
|
+
const sized = unitOf(unit);
|
|
309
|
+
const sharedWire = (open) => sized.shared === undefined || open.has(sized.shared.key) ? 0 : sized.shared.wire;
|
|
310
|
+
const fits = count + sized.count <= shape.count &&
|
|
311
|
+
(shape.bytes === undefined || bytes + sized.bytes <= shape.bytes) &&
|
|
312
|
+
wire + sharedWire(shared) + sized.wire <= REQUEST_MAX_BYTES;
|
|
313
|
+
if (request.length > 0 && !fits) {
|
|
314
|
+
requests.push(request);
|
|
315
|
+
request = [];
|
|
316
|
+
count = 0;
|
|
317
|
+
bytes = 0;
|
|
318
|
+
wire = shape.envelope;
|
|
319
|
+
shared = new Set();
|
|
320
|
+
}
|
|
321
|
+
wire += sharedWire(shared) + sized.wire;
|
|
322
|
+
if (sized.shared !== undefined)
|
|
323
|
+
shared.add(sized.shared.key);
|
|
324
|
+
count += sized.count;
|
|
325
|
+
bytes += sized.bytes;
|
|
326
|
+
request.push(unit);
|
|
327
|
+
}
|
|
328
|
+
if (request.length > 0)
|
|
329
|
+
requests.push(request);
|
|
330
|
+
return requests;
|
|
331
|
+
};
|
|
145
332
|
//# sourceMappingURL=ItemSize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemSize.js","sourceRoot":"","sources":["../../src/internal/ItemSize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAIH;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,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