-
Notifications
You must be signed in to change notification settings - Fork 612
/
Copy pathQueryCommand.ts
120 lines (110 loc) · 3.7 KB
/
QueryCommand.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
// smithy-typescript generated code
import { QueryCommand as __QueryCommand } 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_MEMBERS, ALL_VALUES } from "../commands/utils";
import type {
DynamoDBDocumentClientResolvedConfig,
ServiceInputTypes,
ServiceOutputTypes,
} from "../DynamoDBDocumentClient";
/**
* @public
*/
export { DynamoDBDocumentClientCommand, $Command };
/**
* @public
*/
export type QueryCommandInput = Omit<
__QueryCommandInput,
"KeyConditions" | "QueryFilter" | "ExclusiveStartKey" | "ExpressionAttributeValues"
> & {
KeyConditions?: Record<
string,
Omit<Condition, "AttributeValueList"> & {
AttributeValueList?: NativeAttributeValue[];
}
>;
QueryFilter?: Record<
string,
Omit<Condition, "AttributeValueList"> & {
AttributeValueList?: NativeAttributeValue[];
}
>;
ExclusiveStartKey?: Record<string, NativeAttributeValue>;
ExpressionAttributeValues?: Record<string, NativeAttributeValue>;
};
/**
* @public
*/
export type QueryCommandOutput = Omit<__QueryCommandOutput, "Items" | "LastEvaluatedKey"> & {
Items?: Record<string, NativeAttributeValue>[];
LastEvaluatedKey?: Record<string, NativeAttributeValue>;
};
/**
* Accepts native JavaScript types instead of `AttributeValue`s, and calls
* QueryCommand operation from {@link @aws-sdk/client-dynamodb#QueryCommand}.
*
* 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 QueryCommand extends DynamoDBDocumentClientCommand<
QueryCommandInput,
QueryCommandOutput,
__QueryCommandInput,
__QueryCommandOutput,
DynamoDBDocumentClientResolvedConfig
> {
protected readonly inputKeyNodes = {
KeyConditions: {
"*": {
AttributeValueList: ALL_MEMBERS, // set/list of AttributeValue
},
},
QueryFilter: {
"*": {
AttributeValueList: ALL_MEMBERS, // set/list of AttributeValue
},
},
ExclusiveStartKey: ALL_VALUES, // map with AttributeValue
ExpressionAttributeValues: ALL_VALUES, // map with AttributeValue
};
protected readonly outputKeyNodes = {
Items: {
"*": ALL_VALUES, // map with AttributeValue
},
LastEvaluatedKey: ALL_VALUES, // map with AttributeValue
};
protected readonly clientCommand: __QueryCommand;
public readonly middlewareStack: MiddlewareStack<
QueryCommandInput | __QueryCommandInput,
QueryCommandOutput | __QueryCommandOutput
>;
constructor(readonly input: QueryCommandInput) {
super();
this.clientCommand = new __QueryCommand(this.input as any);
this.middlewareStack = this.clientCommand.middlewareStack;
}
/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: DynamoDBDocumentClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<QueryCommandInput, QueryCommandOutput> {
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 {
Condition,
QueryCommandInput as __QueryCommandInput,
QueryCommandOutput as __QueryCommandOutput,
} from "@aws-sdk/client-dynamodb";
import type { NativeAttributeValue } from "@aws-sdk/util-dynamodb";