@aligent/aws-wrappers 0.0.1
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/CLAUDE.md +172 -0
- package/README.md +286 -0
- package/docs/classes/DynamoDBService.md +353 -0
- package/docs/classes/S3Service.md +389 -0
- package/docs/classes/SNSService.md +95 -0
- package/docs/classes/SQSService.md +162 -0
- package/docs/classes/SSMService.md +157 -0
- package/docs/classes/SecretsManagerService.md +114 -0
- package/docs/classes/StepFunctionsService.md +134 -0
- package/docs/modules.md +15 -0
- package/package.json +32 -0
- package/src/dynamodb/dynamodb.d.ts +127 -0
- package/src/dynamodb/dynamodb.js +308 -0
- package/src/index.d.ts +7 -0
- package/src/index.js +17 -0
- package/src/s3/s3.d.ts +131 -0
- package/src/s3/s3.js +244 -0
- package/src/secrets-manager/secrets-manager.d.ts +78 -0
- package/src/secrets-manager/secrets-manager.js +152 -0
- package/src/sfn/sfn.d.ts +38 -0
- package/src/sfn/sfn.js +74 -0
- package/src/sns/sns.d.ts +48 -0
- package/src/sns/sns.js +110 -0
- package/src/sqs/sqs.d.ts +60 -0
- package/src/sqs/sqs.js +134 -0
- package/src/ssm/ssm.d.ts +84 -0
- package/src/ssm/ssm.js +144 -0
- package/src/util/redact.d.ts +18 -0
- package/src/util/redact.js +29 -0
- package/src/util/truncate.d.ts +15 -0
- package/src/util/truncate.js +36 -0
- package/tsconfig.lib.tsbuildinfo +1 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
[**@aligent/aws-wrappers**](../modules.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@aligent/aws-wrappers](../modules.md) / DynamoDBService
|
|
6
|
+
|
|
7
|
+
# Class: DynamoDBService
|
|
8
|
+
|
|
9
|
+
Defined in: [dynamodb/dynamodb.ts:49](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L49)
|
|
10
|
+
|
|
11
|
+
Wrapper around the AWS DynamoDB Document client providing structured
|
|
12
|
+
Powertools logging and X-Ray tracing by default.
|
|
13
|
+
|
|
14
|
+
Items are automatically marshalled / unmarshalled via the document client —
|
|
15
|
+
callers work with plain TypeScript objects in both directions.
|
|
16
|
+
|
|
17
|
+
## Constructors
|
|
18
|
+
|
|
19
|
+
<a id="constructor"></a>
|
|
20
|
+
|
|
21
|
+
### Constructor
|
|
22
|
+
|
|
23
|
+
> **new DynamoDBService**(`opts?`): `DynamoDBService`
|
|
24
|
+
|
|
25
|
+
Defined in: [dynamodb/dynamodb.ts:62](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L62)
|
|
26
|
+
|
|
27
|
+
#### Parameters
|
|
28
|
+
|
|
29
|
+
##### opts?
|
|
30
|
+
|
|
31
|
+
###### client?
|
|
32
|
+
|
|
33
|
+
`DynamoDBDocumentClient`
|
|
34
|
+
|
|
35
|
+
Optional pre-configured `DynamoDBDocumentClient`.
|
|
36
|
+
When supplied, the wrapper does not apply X-Ray instrumentation. When
|
|
37
|
+
omitted, a default `DynamoDBClient` is wrapped with `captureAWSv3Client`
|
|
38
|
+
*before* being passed to `DynamoDBDocumentClient.from`, so X-Ray
|
|
39
|
+
tracing captures every DynamoDB call.
|
|
40
|
+
|
|
41
|
+
###### logger?
|
|
42
|
+
|
|
43
|
+
`Logger`
|
|
44
|
+
|
|
45
|
+
Optional Powertools logger. Defaults to a logger with
|
|
46
|
+
`serviceName: 'DynamoDBService'`.
|
|
47
|
+
|
|
48
|
+
#### Returns
|
|
49
|
+
|
|
50
|
+
`DynamoDBService`
|
|
51
|
+
|
|
52
|
+
## Methods
|
|
53
|
+
|
|
54
|
+
<a id="batchget"></a>
|
|
55
|
+
|
|
56
|
+
### batchGet()
|
|
57
|
+
|
|
58
|
+
> **batchGet**(`input`): `Promise`\<`BatchGetCommandOutput`\>
|
|
59
|
+
|
|
60
|
+
Defined in: [dynamodb/dynamodb.ts:159](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L159)
|
|
61
|
+
|
|
62
|
+
Batch-get items from one or more DynamoDB tables.
|
|
63
|
+
|
|
64
|
+
Note: this method is intentionally **not** generic. `BatchGet`'s
|
|
65
|
+
`Responses` field is a multi-table `Record<string, item[]>` whose item
|
|
66
|
+
shapes can differ per table — no single `T` can soundly describe it.
|
|
67
|
+
Callers should narrow the result type at the call site.
|
|
68
|
+
|
|
69
|
+
#### Parameters
|
|
70
|
+
|
|
71
|
+
##### input
|
|
72
|
+
|
|
73
|
+
`BatchGetCommandInput`
|
|
74
|
+
|
|
75
|
+
#### Returns
|
|
76
|
+
|
|
77
|
+
`Promise`\<`BatchGetCommandOutput`\>
|
|
78
|
+
|
|
79
|
+
***
|
|
80
|
+
|
|
81
|
+
<a id="batchwrite"></a>
|
|
82
|
+
|
|
83
|
+
### batchWrite()
|
|
84
|
+
|
|
85
|
+
> **batchWrite**(`input`): `Promise`\<`BatchWriteCommandOutput`\>
|
|
86
|
+
|
|
87
|
+
Defined in: [dynamodb/dynamodb.ts:169](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L169)
|
|
88
|
+
|
|
89
|
+
Batch-write items to DynamoDB, retrying `UnprocessedItems` with jittered
|
|
90
|
+
exponential backoff. Up to 5 attempts (200ms base delay). Throws when
|
|
91
|
+
items remain unprocessed after the final attempt.
|
|
92
|
+
|
|
93
|
+
#### Parameters
|
|
94
|
+
|
|
95
|
+
##### input
|
|
96
|
+
|
|
97
|
+
`BatchWriteCommandInput`
|
|
98
|
+
|
|
99
|
+
#### Returns
|
|
100
|
+
|
|
101
|
+
`Promise`\<`BatchWriteCommandOutput`\>
|
|
102
|
+
|
|
103
|
+
***
|
|
104
|
+
|
|
105
|
+
<a id="deleteitem"></a>
|
|
106
|
+
|
|
107
|
+
### deleteItem()
|
|
108
|
+
|
|
109
|
+
> **deleteItem**\<`T`\>(`input`): `Promise`\<`Omit`\<`DeleteCommandOutput`, `"Attributes"`\> & `object`\>
|
|
110
|
+
|
|
111
|
+
Defined in: [dynamodb/dynamodb.ts:116](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L116)
|
|
112
|
+
|
|
113
|
+
Delete an item from DynamoDB. The `Attributes` field on the response is
|
|
114
|
+
typed as `T` — relevant when `ReturnValues: 'ALL_OLD'` is set.
|
|
115
|
+
|
|
116
|
+
#### Type Parameters
|
|
117
|
+
|
|
118
|
+
##### T
|
|
119
|
+
|
|
120
|
+
`T` = `Record`\<`string`, `unknown`\>
|
|
121
|
+
|
|
122
|
+
Expected shape of the returned `Attributes`.
|
|
123
|
+
|
|
124
|
+
#### Parameters
|
|
125
|
+
|
|
126
|
+
##### input
|
|
127
|
+
|
|
128
|
+
`DeleteCommandInput`
|
|
129
|
+
|
|
130
|
+
#### Returns
|
|
131
|
+
|
|
132
|
+
`Promise`\<`Omit`\<`DeleteCommandOutput`, `"Attributes"`\> & `object`\>
|
|
133
|
+
|
|
134
|
+
***
|
|
135
|
+
|
|
136
|
+
<a id="getitem"></a>
|
|
137
|
+
|
|
138
|
+
### getItem()
|
|
139
|
+
|
|
140
|
+
> **getItem**\<`T`\>(`input`): `Promise`\<`T` \| `undefined`\>
|
|
141
|
+
|
|
142
|
+
Defined in: [dynamodb/dynamodb.ts:76](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L76)
|
|
143
|
+
|
|
144
|
+
Get an item from DynamoDB.
|
|
145
|
+
|
|
146
|
+
#### Type Parameters
|
|
147
|
+
|
|
148
|
+
##### T
|
|
149
|
+
|
|
150
|
+
`T` = `Record`\<`string`, `unknown`\>
|
|
151
|
+
|
|
152
|
+
Expected unmarshalled item shape.
|
|
153
|
+
|
|
154
|
+
#### Parameters
|
|
155
|
+
|
|
156
|
+
##### input
|
|
157
|
+
|
|
158
|
+
`GetCommandInput`
|
|
159
|
+
|
|
160
|
+
#### Returns
|
|
161
|
+
|
|
162
|
+
`Promise`\<`T` \| `undefined`\>
|
|
163
|
+
|
|
164
|
+
The item, or `undefined` if not found.
|
|
165
|
+
|
|
166
|
+
***
|
|
167
|
+
|
|
168
|
+
<a id="paginateitems"></a>
|
|
169
|
+
|
|
170
|
+
### paginateItems()
|
|
171
|
+
|
|
172
|
+
> **paginateItems**\<`T`\>(`input`): `AsyncGenerator`\<`T`\>
|
|
173
|
+
|
|
174
|
+
Defined in: [dynamodb/dynamodb.ts:190](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L190)
|
|
175
|
+
|
|
176
|
+
Paginate over Query results, yielding one unmarshalled item at a time.
|
|
177
|
+
|
|
178
|
+
#### Type Parameters
|
|
179
|
+
|
|
180
|
+
##### T
|
|
181
|
+
|
|
182
|
+
`T` = `Record`\<`string`, `unknown`\>
|
|
183
|
+
|
|
184
|
+
Expected shape of each yielded item.
|
|
185
|
+
|
|
186
|
+
#### Parameters
|
|
187
|
+
|
|
188
|
+
##### input
|
|
189
|
+
|
|
190
|
+
`QueryCommandInput`
|
|
191
|
+
|
|
192
|
+
#### Returns
|
|
193
|
+
|
|
194
|
+
`AsyncGenerator`\<`T`\>
|
|
195
|
+
|
|
196
|
+
***
|
|
197
|
+
|
|
198
|
+
<a id="paginatescan"></a>
|
|
199
|
+
|
|
200
|
+
### paginateScan()
|
|
201
|
+
|
|
202
|
+
> **paginateScan**\<`T`\>(`input`): `AsyncGenerator`\<`T`\>
|
|
203
|
+
|
|
204
|
+
Defined in: [dynamodb/dynamodb.ts:203](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L203)
|
|
205
|
+
|
|
206
|
+
Paginate over Scan results, yielding one unmarshalled item at a time.
|
|
207
|
+
|
|
208
|
+
#### Type Parameters
|
|
209
|
+
|
|
210
|
+
##### T
|
|
211
|
+
|
|
212
|
+
`T` = `Record`\<`string`, `unknown`\>
|
|
213
|
+
|
|
214
|
+
Expected shape of each yielded item.
|
|
215
|
+
|
|
216
|
+
#### Parameters
|
|
217
|
+
|
|
218
|
+
##### input
|
|
219
|
+
|
|
220
|
+
`ScanCommandInput`
|
|
221
|
+
|
|
222
|
+
#### Returns
|
|
223
|
+
|
|
224
|
+
`AsyncGenerator`\<`T`\>
|
|
225
|
+
|
|
226
|
+
***
|
|
227
|
+
|
|
228
|
+
<a id="putitem"></a>
|
|
229
|
+
|
|
230
|
+
### putItem()
|
|
231
|
+
|
|
232
|
+
> **putItem**\<`T`\>(`input`): `Promise`\<`PutCommandOutput`\>
|
|
233
|
+
|
|
234
|
+
Defined in: [dynamodb/dynamodb.ts:87](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L87)
|
|
235
|
+
|
|
236
|
+
Put an item into DynamoDB. The caller's `Item` is typed as `T`, which
|
|
237
|
+
the document client marshalls automatically.
|
|
238
|
+
|
|
239
|
+
#### Type Parameters
|
|
240
|
+
|
|
241
|
+
##### T
|
|
242
|
+
|
|
243
|
+
`T`
|
|
244
|
+
|
|
245
|
+
Type of the item being stored.
|
|
246
|
+
|
|
247
|
+
#### Parameters
|
|
248
|
+
|
|
249
|
+
##### input
|
|
250
|
+
|
|
251
|
+
`Omit`\<`PutCommandInput`, `"Item"`\> & `object`
|
|
252
|
+
|
|
253
|
+
#### Returns
|
|
254
|
+
|
|
255
|
+
`Promise`\<`PutCommandOutput`\>
|
|
256
|
+
|
|
257
|
+
***
|
|
258
|
+
|
|
259
|
+
<a id="query"></a>
|
|
260
|
+
|
|
261
|
+
### query()
|
|
262
|
+
|
|
263
|
+
> **query**\<`T`\>(`input`): `Promise`\<`Omit`\<`QueryCommandOutput`, `"Items"`\> & `object`\>
|
|
264
|
+
|
|
265
|
+
Defined in: [dynamodb/dynamodb.ts:130](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L130)
|
|
266
|
+
|
|
267
|
+
Execute a DynamoDB Query. The full `QueryCommandOutput` is returned with
|
|
268
|
+
`Items` typed as `T[]` so callers retain pagination metadata
|
|
269
|
+
(`LastEvaluatedKey`, `Count`, etc.).
|
|
270
|
+
|
|
271
|
+
#### Type Parameters
|
|
272
|
+
|
|
273
|
+
##### T
|
|
274
|
+
|
|
275
|
+
`T` = `Record`\<`string`, `unknown`\>
|
|
276
|
+
|
|
277
|
+
Expected shape of each unmarshalled item.
|
|
278
|
+
|
|
279
|
+
#### Parameters
|
|
280
|
+
|
|
281
|
+
##### input
|
|
282
|
+
|
|
283
|
+
`QueryCommandInput`
|
|
284
|
+
|
|
285
|
+
#### Returns
|
|
286
|
+
|
|
287
|
+
`Promise`\<`Omit`\<`QueryCommandOutput`, `"Items"`\> & `object`\>
|
|
288
|
+
|
|
289
|
+
***
|
|
290
|
+
|
|
291
|
+
<a id="scan"></a>
|
|
292
|
+
|
|
293
|
+
### scan()
|
|
294
|
+
|
|
295
|
+
> **scan**\<`T`\>(`input`): `Promise`\<`Omit`\<`ScanCommandOutput`, `"Items"`\> & `object`\>
|
|
296
|
+
|
|
297
|
+
Defined in: [dynamodb/dynamodb.ts:143](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L143)
|
|
298
|
+
|
|
299
|
+
Scan a DynamoDB table. The full `ScanCommandOutput` is returned with
|
|
300
|
+
`Items` typed as `T[]` so callers retain pagination metadata.
|
|
301
|
+
|
|
302
|
+
#### Type Parameters
|
|
303
|
+
|
|
304
|
+
##### T
|
|
305
|
+
|
|
306
|
+
`T` = `Record`\<`string`, `unknown`\>
|
|
307
|
+
|
|
308
|
+
Expected shape of each unmarshalled item.
|
|
309
|
+
|
|
310
|
+
#### Parameters
|
|
311
|
+
|
|
312
|
+
##### input
|
|
313
|
+
|
|
314
|
+
`ScanCommandInput`
|
|
315
|
+
|
|
316
|
+
#### Returns
|
|
317
|
+
|
|
318
|
+
`Promise`\<`Omit`\<`ScanCommandOutput`, `"Items"`\> & `object`\>
|
|
319
|
+
|
|
320
|
+
***
|
|
321
|
+
|
|
322
|
+
<a id="updateitem"></a>
|
|
323
|
+
|
|
324
|
+
### updateItem()
|
|
325
|
+
|
|
326
|
+
> **updateItem**\<`T`\>(`input`): `Promise`\<`Omit`\<`UpdateCommandOutput`, `"Attributes"`\> & `object`\>
|
|
327
|
+
|
|
328
|
+
Defined in: [dynamodb/dynamodb.ts:103](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L103)
|
|
329
|
+
|
|
330
|
+
Update an item in DynamoDB. The `Attributes` field on the response is
|
|
331
|
+
typed as `T` — the caller should choose `T` to match their
|
|
332
|
+
`ReturnValues` setting:
|
|
333
|
+
- `NONE` (default): no `Attributes` returned.
|
|
334
|
+
- `ALL_OLD` / `ALL_NEW`: full item.
|
|
335
|
+
- `UPDATED_OLD` / `UPDATED_NEW`: only updated attributes (partial).
|
|
336
|
+
|
|
337
|
+
#### Type Parameters
|
|
338
|
+
|
|
339
|
+
##### T
|
|
340
|
+
|
|
341
|
+
`T` = `Record`\<`string`, `unknown`\>
|
|
342
|
+
|
|
343
|
+
Expected shape of the returned `Attributes`.
|
|
344
|
+
|
|
345
|
+
#### Parameters
|
|
346
|
+
|
|
347
|
+
##### input
|
|
348
|
+
|
|
349
|
+
`UpdateCommandInput`
|
|
350
|
+
|
|
351
|
+
#### Returns
|
|
352
|
+
|
|
353
|
+
`Promise`\<`Omit`\<`UpdateCommandOutput`, `"Attributes"`\> & `object`\>
|