-
Notifications
You must be signed in to change notification settings - Fork 14
/
dynamodb-types.w
332 lines (285 loc) · 9.22 KB
/
dynamodb-types.w
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
pub struct StreamRecordDynamodb {
ApproximateCreationDateTime: str;
Keys: Json;
NewImage: Json?;
OldImage: Json?;
SequenceNumber: str;
SizeBytes: num;
StreamViewType: str;
}
pub struct StreamRecord {
dynamodb: StreamRecordDynamodb;
eventName: str;
eventID: str;
}
pub struct DeleteOptions {
Key: Json;
ConditionExpression: str?;
ExpressionAttributeNames: Map<str>?;
ExpressionAttributeValues: Map<Json>?;
ReturnValues: str?;
}
pub struct DeleteOutput {
Attributes: Json?;
}
pub struct GetOptions {
Key: Json;
ConsistentRead: bool?;
ProjectionExpression: str?;
ExpressionAttributeNames: Map<str>?;
ExpressionAttributeValues: Map<Json>?;
}
pub struct GetOutput {
Item: Json?;
}
pub struct PutOptions {
Item: Json;
ConditionExpression: str?;
ExpressionAttributeNames: Map<str>?;
ExpressionAttributeValues: Map<Json>?;
ReturnValues: str?;
}
pub struct UpdateOptions {
Key: Json;
ReturnValues: str?;
ReturnConsumedCapacity: str?;
UpdateExpression: str;
ConditionExpression: str?;
ExpressionAttributeNames: Map<str>?;
ExpressionAttributeValues: Map<Json>?;
}
pub struct PutOutput {
Attributes: Json?;
}
pub struct UpdateOutput extends PutOptions {}
pub struct QueryOptions {
ConsistentRead: bool?;
ExclusiveStartKey: Json?;
ExpressionAttributeNames: Map<str>?;
ExpressionAttributeValues: Map<Json>?;
FilterExpression: str?;
IndexName: str?;
KeyConditionExpression: str;
Limit: num?;
ProjectionExpression: str?;
ReturnConsumedCapacity: str?;
ScanIndexForward: bool?;
Select: str?;
}
pub struct QueryOutput {
Items: Array<Json>;
Count: num;
ScannedCount: num;
LastEvaluatedKey: Json?;
ConsumedCapacity: Json?;
}
pub struct ScanOptions {
ConsistentRead: bool?;
ExclusiveStartKey: Json?;
ExpressionAttributeNames: Map<str>?;
ExpressionAttributeValues: Map<Json>?;
FilterExpression: str?;
IndexName: str?;
Limit: num?;
ProjectionExpression: str?;
ReturnConsumedCapacity: str?;
Select: str?;
Segment: num?;
TotalSegments: num?;
}
pub struct ScanOutput {
Items: Array<Json>;
Count: num;
ScannedCount: num;
LastEvaluatedKey: Json?;
ConsumedCapacity: Json?;
}
pub struct TransactWriteItemConditionCheck {
Key: Json;
ConditionExpression: str?;
ExpressionAttributeNames: Map<str>?;
ExpressionAttributeValues: Map<Json>?;
ReturnValuesOnConditionCheckFailure: bool?;
}
pub struct TransactWriteItemPut {
Item: Json;
ConditionExpression: str?;
ExpressionAttributeNames: Map<str>?;
ExpressionAttributeValues: Map<Json>?;
ReturnValuesOnConditionCheckFailure: bool?;
}
pub struct TransactWriteItemDelete {
Key: Json;
ConditionExpression: str?;
ExpressionAttributeNames: Map<str>?;
ExpressionAttributeValues: Map<Json>?;
ReturnValuesOnConditionCheckFailure: bool?;
}
pub struct TransactWriteItemUpdate {
Key: Json;
ConditionExpression: str?;
UpdateExpression: str?;
ExpressionAttributeNames: Map<str>?;
ExpressionAttributeValues: Map<Json>?;
ReturnValuesOnConditionCheckFailure: bool?;
}
pub struct TransactWriteItem {
ConditionCheck: TransactWriteItemConditionCheck?;
Put: TransactWriteItemPut?;
Delete: TransactWriteItemDelete?;
Update: TransactWriteItemUpdate?;
}
pub struct TransactWriteOptions {
TransactItems: Array<TransactWriteItem>;
}
pub struct TransactWriteOutput {}
/// `TableBatchGetOptions` is used as an input to the `batchGet` operation on a Table or Client
/// (through [`BatchGetOptions`](#@winglibs/dynamodb.BatchGetOptions)).
pub struct TableBatchGetOptions {
Keys: Array<Json>;
AttributesToGet: Array<str>?;
ConsistentRead: bool?;
ExpressionAttributeNames: Map<str>?;
ProjectionExpression: str?;
/// When passed in on a **Table** resource, `ReturnConsumedCapacity` will be hoisted to the top
/// level inside of the request. When passed in on a **Client** resource (via
/// [`BatchGetOptions`](#@winglibs/dynamodb.BatchGetOptions)), setting `ReturnConsumedCapacity`
/// here has no effect, set it inside of the top-level instead.
ReturnConsumedCapacity: str?;
}
/// Input to the `batchGet` operation on a Client.
pub struct BatchGetOptions {
RequestItems: Map<TableBatchGetOptions>;
ReturnConsumedCapacity: str?;
}
pub struct BatchGetOutput {
UnprocessedKeys: Map<TableBatchGetOptions>;
Responses: Map<Array<Json>>?;
ConsumedCapacity: Array<Json>?;
}
/// Represents a request to perform a `DeleteItem` operation on an item.
pub struct DeleteRequest {
/// `Key` is a map of attribute name to attribute values, representing the primary key of the item
/// to delete. All of the table's primary key attributes must be specified
Key: Json;
}
/// Represents a request to perform a `PutItem` operation on an item.
pub struct PutRequest {
/// A map of attribute name to attribute values, representing the primary key of an item to be
/// processed by PutItem. All of the table's primary key attributes must be specified, and their
/// data types must match those of the table's key schema. If any attributes are present in the item
/// that are part of an index key schema for the table, their types must match the index key
/// schema.
Item: Json;
}
// Represents an operation to perform - either `DeleteItem` or `PutItem`. Used internally to map
// from the `DeleteRequests` or `PutRequests` on `TableBatchWriteOptions` to the contract required
// from DynamoDB.
internal struct WriteRequest {
DeleteRequest: DeleteRequest?;
PutRequest: PutRequest?;
}
/// `TableBatchWriteOptions` is used as an input to the `batchWrite` operation on a Table or Client
/// (through [`BatchWriteOptions`](#@winglibs/dynamodb.BatchWriteOptions)).
pub struct TableBatchWriteOptions {
/// `DeleteRequests` contains a list of `DeleteItem` operations to perform on this table.
DeleteRequests: Array<DeleteRequest>?;
/// `PutRequests` contains a list of `PutItem` operations to perform on this table.
PutRequests: Array<PutRequest>?;
/// When passed in on a **Table** resource, `ReturnConsumedCapacity` will be hoisted to the top
/// level inside of the request. When passed in on a **Client** resource (via
/// [`BatchWriteOptions`](#@winglibs/dynamodb.BatchWriteOptions)), setting
/// `ReturnConsumedCapacity` here has no effect, set it inside of the top-level instead.
ReturnConsumedCapacity: str?;
/// When passed in on a **Table** resource, `ReturnItemCollectionMetrics` will be hoisted to the
/// top level inside of the request. When passed in on a **Client** resource (via
/// [`BatchWriteOptions`](#@winglibs/dynamodb.BatchWriteOptions)), setting
/// `ReturnConsumedCapacity` here has no effect, set it inside of the top-level instead.
ReturnItemCollectionMetrics: str?;
}
/// Input to the `batchWrite` operation on a Client.
pub struct BatchWriteOptions {
RequestItems: Map<TableBatchWriteOptions>;
ReturnConsumedCapacity: str?;
ReturnItemCollectionMetrics: str?;
}
pub struct BatchWriteOutput {
UnprocessedItems: Map<TableBatchWriteOptions>?;
ItemCollectionMetrics: Json?;
ConsumedCapacity: Array<Json>?;
}
pub struct AttributeDefinition {
name: str;
type: str;
}
pub struct GlobalSecondaryIndex {
hashKey: str;
name: str;
nonKeyAttributes: Array<str>?;
projectionType: str;
rangeKey: str?;
readCapacity: num?;
writeCapacity: num?;
}
// pub struct StreamFilterPattern {
// pattern: str;
// }
// pub struct StreamFilterCriteria {
// filter: Array<StreamFilterPattern>;
// }
pub struct StreamConsumerOptions {
// filterCriteria: StreamFilterCriteria?;
batchSize: num?;
startingPosition: str?;
}
pub enum BillingMode {
PAY_PER_REQUEST,
PROVISIONED
}
pub struct TableProps {
name: str?;
attributes: Array<AttributeDefinition>;
hashKey: str;
rangeKey: str?;
timeToLiveAttribute: str?;
globalSecondaryIndex: Array<GlobalSecondaryIndex>?;
pointInTimeRecovery: bool?;
/// Billing mode for the table. Defaults to `PAY_PER_REQUEST`.
billingMode: BillingMode?;
/// Enables deletion protection for table. Disabled by default.
///
/// For the Terraform AWS provider, this will also enable `lifecycle { prevent_destroy = true }`
deletionProtection: bool?;
}
pub struct Credentials {
accessKeyId: str;
secretAccessKey: str;
}
pub struct ClientConfig {
endpoint: str;
region: str;
credentials: Credentials;
}
pub struct Connection {
tableName: str;
clientConfig: ClientConfig?;
}
pub inflight interface IDynamoResource {
inflight delete(options: DeleteOptions): DeleteOutput;
inflight get(options: GetOptions): GetOutput;
inflight put(options: PutOptions): PutOutput;
inflight update(options: UpdateOptions): UpdateOutput;
inflight query(options: QueryOptions): QueryOutput;
inflight scan(options: ScanOptions?): ScanOutput;
inflight transactWrite(options: TransactWriteOptions): TransactWriteOutput;
}
pub inflight interface IClient extends IDynamoResource {
inflight batchGet(options: BatchGetOptions): BatchGetOutput;
inflight batchWrite(options: BatchWriteOptions): BatchWriteOutput;
}
pub interface ITable extends IDynamoResource, std.IResource {
setStreamConsumer(handler: inflight (StreamRecord): void, options: StreamConsumerOptions?): void;
inflight readWriteConnection(): Connection;
inflight batchGet(options: TableBatchGetOptions): BatchGetOutput;
inflight batchWrite(options: TableBatchWriteOptions): BatchWriteOutput;
}