/
ExecuteStatementCommand.ts
60 lines (53 loc) · 2.45 KB
/
ExecuteStatementCommand.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
import {
ExecuteStatementCommand as __ExecuteStatementCommand,
ExecuteStatementCommandInput as __ExecuteStatementCommandInput,
ExecuteStatementCommandOutput as __ExecuteStatementCommandOutput,
} from "@aws-sdk/client-dynamodb";
import { Command as $Command } from "@aws-sdk/smithy-client";
import { Handler, HttpHandlerOptions as __HttpHandlerOptions, MiddlewareStack } from "@aws-sdk/types";
import { NativeAttributeValue } from "@aws-sdk/util-dynamodb";
import { marshallInput, unmarshallOutput } from "../commands/utils";
import { DynamoDBDocumentClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../DynamoDBDocumentClient";
export type ExecuteStatementCommandInput = Omit<__ExecuteStatementCommandInput, "Parameters"> & {
Parameters?: NativeAttributeValue[];
};
export type ExecuteStatementCommandOutput = Omit<__ExecuteStatementCommandOutput, "Items"> & {
Items?: { [key: string]: NativeAttributeValue }[];
};
/**
* Accepts native JavaScript types instead of `AttributeValue`s, and calls
* ExecuteStatementCommand operation from {@link https://www.npmjs.com/package/@aws-sdk/client-dynamodb @aws-sdk/client-dynamodb}.
*
* JavaScript objects passed in as parameters are marshalled into `AttributeValue` shapes
* required by Amazon DynamoDB. Responses from DynamoDB are unmarshalled into plain JavaScript objects.
*/
export class ExecuteStatementCommand extends $Command<
ExecuteStatementCommandInput,
ExecuteStatementCommandOutput,
DynamoDBDocumentClientResolvedConfig
> {
private readonly inputKeyNodes = [{ key: "Parameters" }];
private readonly outputKeyNodes = [{ key: "Items" }];
constructor(readonly input: ExecuteStatementCommandInput) {
super();
}
/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: DynamoDBDocumentClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<ExecuteStatementCommandInput, ExecuteStatementCommandOutput> {
const { marshallOptions, unmarshallOptions } = configuration.translateConfig || {};
const command = new __ExecuteStatementCommand(marshallInput(this.input, this.inputKeyNodes, marshallOptions));
const handler = command.resolveMiddleware(clientStack, configuration, options);
return async () => {
const data = await handler(command);
return {
...data,
output: unmarshallOutput(data.output, this.outputKeyNodes, unmarshallOptions),
};
};
}
}