-
Notifications
You must be signed in to change notification settings - Fork 611
/
Copy pathTransactWriteCommand.ts
143 lines (133 loc) · 4.97 KB
/
TransactWriteCommand.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// smithy-typescript generated code
import { TransactWriteItemsCommand as __TransactWriteItemsCommand } from "@aws-sdk/client-dynamodb";
import { Command as $Command } from "@smithy/smithy-client";
import type { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@smithy/types";
import { DynamoDBDocumentClientCommand } from "../baseCommand/DynamoDBDocumentClientCommand";
import { ALL_VALUES } from "../commands/utils";
import type {
DynamoDBDocumentClientResolvedConfig,
ServiceInputTypes,
ServiceOutputTypes,
} from "../DynamoDBDocumentClient";
/**
* @public
*/
export { DynamoDBDocumentClientCommand, $Command };
/**
* @public
*/
export type TransactWriteCommandInput = Omit<__TransactWriteItemsCommandInput, "TransactItems"> & {
TransactItems:
| (Omit<TransactWriteItem, "ConditionCheck" | "Put" | "Delete" | "Update"> & {
ConditionCheck?: Omit<ConditionCheck, "Key" | "ExpressionAttributeValues"> & {
Key: Record<string, NativeAttributeValue> | undefined;
ExpressionAttributeValues?: Record<string, NativeAttributeValue>;
};
Put?: Omit<Put, "Item" | "ExpressionAttributeValues"> & {
Item: Record<string, NativeAttributeValue> | undefined;
ExpressionAttributeValues?: Record<string, NativeAttributeValue>;
};
Delete?: Omit<Delete, "Key" | "ExpressionAttributeValues"> & {
Key: Record<string, NativeAttributeValue> | undefined;
ExpressionAttributeValues?: Record<string, NativeAttributeValue>;
};
Update?: Omit<Update, "Key" | "ExpressionAttributeValues"> & {
Key: Record<string, NativeAttributeValue> | undefined;
ExpressionAttributeValues?: Record<string, NativeAttributeValue>;
};
})[]
| undefined;
};
/**
* @public
*/
export type TransactWriteCommandOutput = Omit<__TransactWriteItemsCommandOutput, "ItemCollectionMetrics"> & {
ItemCollectionMetrics?: Record<
string,
(Omit<ItemCollectionMetrics, "ItemCollectionKey"> & {
ItemCollectionKey?: Record<string, NativeAttributeValue>;
})[]
>;
};
/**
* Accepts native JavaScript types instead of `AttributeValue`s, and calls
* TransactWriteItemsCommand operation from {@link @aws-sdk/client-dynamodb#TransactWriteItemsCommand}.
*
* JavaScript objects passed in as parameters are marshalled into `AttributeValue` shapes
* required by Amazon DynamoDB. Responses from DynamoDB are unmarshalled into plain JavaScript objects.
*
* @public
*/
export class TransactWriteCommand extends DynamoDBDocumentClientCommand<
TransactWriteCommandInput,
TransactWriteCommandOutput,
__TransactWriteItemsCommandInput,
__TransactWriteItemsCommandOutput,
DynamoDBDocumentClientResolvedConfig
> {
protected readonly inputKeyNodes = {
TransactItems: {
"*": {
ConditionCheck: {
Key: ALL_VALUES, // map with AttributeValue
ExpressionAttributeValues: ALL_VALUES, // map with AttributeValue
},
Put: {
Item: ALL_VALUES, // map with AttributeValue
ExpressionAttributeValues: ALL_VALUES, // map with AttributeValue
},
Delete: {
Key: ALL_VALUES, // map with AttributeValue
ExpressionAttributeValues: ALL_VALUES, // map with AttributeValue
},
Update: {
Key: ALL_VALUES, // map with AttributeValue
ExpressionAttributeValues: ALL_VALUES, // map with AttributeValue
},
},
},
};
protected readonly outputKeyNodes = {
ItemCollectionMetrics: {
"*": {
"*": {
ItemCollectionKey: ALL_VALUES, // map with AttributeValue
},
},
},
};
protected readonly clientCommand: __TransactWriteItemsCommand;
public readonly middlewareStack: MiddlewareStack<
TransactWriteCommandInput | __TransactWriteItemsCommandInput,
TransactWriteCommandOutput | __TransactWriteItemsCommandOutput
>;
constructor(readonly input: TransactWriteCommandInput) {
super();
this.clientCommand = new __TransactWriteItemsCommand(this.input as any);
this.middlewareStack = this.clientCommand.middlewareStack;
}
/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: DynamoDBDocumentClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<TransactWriteCommandInput, TransactWriteCommandOutput> {
this.addMarshallingMiddleware(configuration);
const stack = clientStack.concat(this.middlewareStack as typeof clientStack);
const handler = this.clientCommand.resolveMiddleware(stack, configuration, options);
return async () => handler(this.clientCommand);
}
}
import type {
ConditionCheck,
Delete,
ItemCollectionMetrics,
Put,
TransactWriteItem,
TransactWriteItemsCommandInput as __TransactWriteItemsCommandInput,
TransactWriteItemsCommandOutput as __TransactWriteItemsCommandOutput,
Update,
} from "@aws-sdk/client-dynamodb";
import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb";