@aligent/aws-wrappers 0.1.1 → 0.2.0
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/README.md +56 -0
- package/cjs/index.cjs +267 -0
- package/cjs/package.json +12 -11
- package/cjs/src/index.d.ts +1 -0
- package/cjs/src/scheduler/scheduler.d.ts +83 -0
- package/docs/classes/DynamoDBService.md +65 -34
- package/docs/classes/S3Service.md +73 -33
- package/docs/classes/SNSService.md +28 -8
- package/docs/classes/SQSService.md +30 -11
- package/docs/classes/SSMService.md +66 -9
- package/docs/classes/SchedulerService.md +269 -0
- package/docs/classes/SecretsManagerService.md +119 -7
- package/docs/classes/StepFunctionsService.md +9 -9
- package/docs/modules.md +1 -0
- package/esm/index.mjs +267 -1
- package/esm/package.json +12 -11
- package/esm/src/index.d.ts +1 -0
- package/esm/src/scheduler/scheduler.d.ts +83 -0
- package/package.json +12 -11
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: DynamoDBService
|
|
8
8
|
|
|
9
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
9
|
+
Defined in: [dynamodb/dynamodb.ts:155](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L155)
|
|
10
10
|
|
|
11
11
|
Wrapper around the AWS DynamoDB Document client providing structured
|
|
12
12
|
Powertools logging and X-Ray tracing by default.
|
|
@@ -22,7 +22,7 @@ callers work with plain TypeScript objects in both directions.
|
|
|
22
22
|
|
|
23
23
|
> **new DynamoDBService**(`opts?`): `DynamoDBService`
|
|
24
24
|
|
|
25
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
25
|
+
Defined in: [dynamodb/dynamodb.ts:168](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L168)
|
|
26
26
|
|
|
27
27
|
#### Parameters
|
|
28
28
|
|
|
@@ -40,10 +40,10 @@ tracing captures every DynamoDB call.
|
|
|
40
40
|
|
|
41
41
|
###### logger?
|
|
42
42
|
|
|
43
|
-
`
|
|
43
|
+
`LoggerInterface`
|
|
44
44
|
|
|
45
|
-
Optional Powertools logger. Defaults to
|
|
46
|
-
`
|
|
45
|
+
Optional Powertools logger. Defaults to `new Logger()`,
|
|
46
|
+
which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
47
47
|
|
|
48
48
|
#### Returns
|
|
49
49
|
|
|
@@ -57,7 +57,7 @@ Optional Powertools logger. Defaults to a logger with
|
|
|
57
57
|
|
|
58
58
|
> **batchGet**(`input`): `Promise`\<`BatchGetCommandOutput`\>
|
|
59
59
|
|
|
60
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
60
|
+
Defined in: [dynamodb/dynamodb.ts:319](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L319)
|
|
61
61
|
|
|
62
62
|
Batch-get items from one or more DynamoDB tables.
|
|
63
63
|
|
|
@@ -84,7 +84,7 @@ Callers should narrow the result type at the call site.
|
|
|
84
84
|
|
|
85
85
|
> **batchWrite**(`input`): `Promise`\<`BatchWriteCommandOutput`\>
|
|
86
86
|
|
|
87
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
87
|
+
Defined in: [dynamodb/dynamodb.ts:336](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L336)
|
|
88
88
|
|
|
89
89
|
Batch-write items to DynamoDB, retrying `UnprocessedItems` with jittered
|
|
90
90
|
exponential backoff. Up to 5 attempts (200ms base delay). Throws when
|
|
@@ -106,18 +106,24 @@ items remain unprocessed after the final attempt.
|
|
|
106
106
|
|
|
107
107
|
### deleteItem()
|
|
108
108
|
|
|
109
|
-
> **deleteItem**\<`
|
|
109
|
+
> **deleteItem**\<`K`, `R`\>(`input`): `Promise`\<`Omit`\<`DeleteCommandOutput`, `"Attributes"`\> & `object`\>
|
|
110
110
|
|
|
111
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
111
|
+
Defined in: [dynamodb/dynamodb.ts:249](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L249)
|
|
112
112
|
|
|
113
113
|
Delete an item from DynamoDB. The `Attributes` field on the response is
|
|
114
|
-
typed as `
|
|
114
|
+
typed as `R` — relevant when `ReturnValues: 'ALL_OLD'` is set.
|
|
115
115
|
|
|
116
116
|
#### Type Parameters
|
|
117
117
|
|
|
118
|
-
#####
|
|
118
|
+
##### K
|
|
119
|
+
|
|
120
|
+
`K` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
121
|
+
|
|
122
|
+
Shape of the partition / sort key.
|
|
123
|
+
|
|
124
|
+
##### R
|
|
119
125
|
|
|
120
|
-
`
|
|
126
|
+
`R` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
121
127
|
|
|
122
128
|
Expected shape of the returned `Attributes`.
|
|
123
129
|
|
|
@@ -125,7 +131,7 @@ Expected shape of the returned `Attributes`.
|
|
|
125
131
|
|
|
126
132
|
##### input
|
|
127
133
|
|
|
128
|
-
`DeleteCommandInput`
|
|
134
|
+
`WithTypedKey`\<`DeleteCommandInput`, `K`\>
|
|
129
135
|
|
|
130
136
|
#### Returns
|
|
131
137
|
|
|
@@ -137,17 +143,23 @@ Expected shape of the returned `Attributes`.
|
|
|
137
143
|
|
|
138
144
|
### getItem()
|
|
139
145
|
|
|
140
|
-
> **getItem**\<`
|
|
146
|
+
> **getItem**\<`K`, `R`\>(`input`): `Promise`\<`R` \| `undefined`\>
|
|
141
147
|
|
|
142
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
148
|
+
Defined in: [dynamodb/dynamodb.ts:183](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L183)
|
|
143
149
|
|
|
144
150
|
Get an item from DynamoDB.
|
|
145
151
|
|
|
146
152
|
#### Type Parameters
|
|
147
153
|
|
|
148
|
-
#####
|
|
154
|
+
##### K
|
|
155
|
+
|
|
156
|
+
`K` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
157
|
+
|
|
158
|
+
Shape of the partition / sort key.
|
|
159
|
+
|
|
160
|
+
##### R
|
|
149
161
|
|
|
150
|
-
`
|
|
162
|
+
`R` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
151
163
|
|
|
152
164
|
Expected unmarshalled item shape.
|
|
153
165
|
|
|
@@ -155,11 +167,11 @@ Expected unmarshalled item shape.
|
|
|
155
167
|
|
|
156
168
|
##### input
|
|
157
169
|
|
|
158
|
-
`GetCommandInput`
|
|
170
|
+
`WithTypedKey`\<`GetCommandInput`, `K`\>
|
|
159
171
|
|
|
160
172
|
#### Returns
|
|
161
173
|
|
|
162
|
-
`Promise`\<`
|
|
174
|
+
`Promise`\<`R` \| `undefined`\>
|
|
163
175
|
|
|
164
176
|
The item, or `undefined` if not found.
|
|
165
177
|
|
|
@@ -171,7 +183,7 @@ The item, or `undefined` if not found.
|
|
|
171
183
|
|
|
172
184
|
> **paginateItems**\<`T`\>(`input`): `AsyncGenerator`\<`T`\>
|
|
173
185
|
|
|
174
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
186
|
+
Defined in: [dynamodb/dynamodb.ts:364](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L364)
|
|
175
187
|
|
|
176
188
|
Paginate over Query results, yielding one unmarshalled item at a time.
|
|
177
189
|
|
|
@@ -179,7 +191,7 @@ Paginate over Query results, yielding one unmarshalled item at a time.
|
|
|
179
191
|
|
|
180
192
|
##### T
|
|
181
193
|
|
|
182
|
-
`T` = `Record`\<`string`, `unknown`\>
|
|
194
|
+
`T` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
183
195
|
|
|
184
196
|
Expected shape of each yielded item.
|
|
185
197
|
|
|
@@ -201,7 +213,7 @@ Expected shape of each yielded item.
|
|
|
201
213
|
|
|
202
214
|
> **paginateScan**\<`T`\>(`input`): `AsyncGenerator`\<`T`\>
|
|
203
215
|
|
|
204
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
216
|
+
Defined in: [dynamodb/dynamodb.ts:381](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L381)
|
|
205
217
|
|
|
206
218
|
Paginate over Scan results, yielding one unmarshalled item at a time.
|
|
207
219
|
|
|
@@ -209,7 +221,7 @@ Paginate over Scan results, yielding one unmarshalled item at a time.
|
|
|
209
221
|
|
|
210
222
|
##### T
|
|
211
223
|
|
|
212
|
-
`T` = `Record`\<`string`, `unknown`\>
|
|
224
|
+
`T` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
213
225
|
|
|
214
226
|
Expected shape of each yielded item.
|
|
215
227
|
|
|
@@ -231,7 +243,7 @@ Expected shape of each yielded item.
|
|
|
231
243
|
|
|
232
244
|
> **putItem**\<`T`\>(`input`): `Promise`\<`PutCommandOutput`\>
|
|
233
245
|
|
|
234
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
246
|
+
Defined in: [dynamodb/dynamodb.ts:203](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L203)
|
|
235
247
|
|
|
236
248
|
Put an item into DynamoDB. The caller's `Item` is typed as `T`, which
|
|
237
249
|
the document client marshalls automatically.
|
|
@@ -262,7 +274,7 @@ Type of the item being stored.
|
|
|
262
274
|
|
|
263
275
|
> **query**\<`T`\>(`input`): `Promise`\<`Omit`\<`QueryCommandOutput`, `"Items"`\> & `object`\>
|
|
264
276
|
|
|
265
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
277
|
+
Defined in: [dynamodb/dynamodb.ts:272](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L272)
|
|
266
278
|
|
|
267
279
|
Execute a DynamoDB Query. The full `QueryCommandOutput` is returned with
|
|
268
280
|
`Items` typed as `T[]` so callers retain pagination metadata
|
|
@@ -272,7 +284,7 @@ Execute a DynamoDB Query. The full `QueryCommandOutput` is returned with
|
|
|
272
284
|
|
|
273
285
|
##### T
|
|
274
286
|
|
|
275
|
-
`T` = `Record`\<`string`, `unknown`\>
|
|
287
|
+
`T` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
276
288
|
|
|
277
289
|
Expected shape of each unmarshalled item.
|
|
278
290
|
|
|
@@ -294,16 +306,29 @@ Expected shape of each unmarshalled item.
|
|
|
294
306
|
|
|
295
307
|
> **scan**\<`T`\>(`input`): `Promise`\<`Omit`\<`ScanCommandOutput`, `"Items"`\> & `object`\>
|
|
296
308
|
|
|
297
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
309
|
+
Defined in: [dynamodb/dynamodb.ts:301](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L301)
|
|
298
310
|
|
|
299
311
|
Scan a DynamoDB table. The full `ScanCommandOutput` is returned with
|
|
300
312
|
`Items` typed as `T[]` so callers retain pagination metadata.
|
|
301
313
|
|
|
314
|
+
Scan reads every item in the table, so cost and latency grow linearly
|
|
315
|
+
with table size; it is rarely the right tool in a runtime service.
|
|
316
|
+
Prefer, in order:
|
|
317
|
+
|
|
318
|
+
1. `query` with the table's partition key.
|
|
319
|
+
2. `query` against a GSI or LSI whose key matches your access pattern.
|
|
320
|
+
3. A sparse GSI populated only for the items you need to enumerate.
|
|
321
|
+
4. A denormalised lookup item or table maintained on write.
|
|
322
|
+
|
|
323
|
+
Legitimate scan use cases are mostly one-off admin work (export,
|
|
324
|
+
migration, audit). For those, prefer the AWS CLI or Console rather than
|
|
325
|
+
embedding a scan in a Lambda.
|
|
326
|
+
|
|
302
327
|
#### Type Parameters
|
|
303
328
|
|
|
304
329
|
##### T
|
|
305
330
|
|
|
306
|
-
`T` = `Record`\<`string`, `unknown`\>
|
|
331
|
+
`T` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
307
332
|
|
|
308
333
|
Expected shape of each unmarshalled item.
|
|
309
334
|
|
|
@@ -323,12 +348,12 @@ Expected shape of each unmarshalled item.
|
|
|
323
348
|
|
|
324
349
|
### updateItem()
|
|
325
350
|
|
|
326
|
-
> **updateItem**\<`
|
|
351
|
+
> **updateItem**\<`K`, `R`\>(`input`): `Promise`\<`Omit`\<`UpdateCommandOutput`, `"Attributes"`\> & `object`\>
|
|
327
352
|
|
|
328
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
353
|
+
Defined in: [dynamodb/dynamodb.ts:226](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L226)
|
|
329
354
|
|
|
330
355
|
Update an item in DynamoDB. The `Attributes` field on the response is
|
|
331
|
-
typed as `
|
|
356
|
+
typed as `R` — the caller should choose `R` to match their
|
|
332
357
|
`ReturnValues` setting:
|
|
333
358
|
- `NONE` (default): no `Attributes` returned.
|
|
334
359
|
- `ALL_OLD` / `ALL_NEW`: full item.
|
|
@@ -336,9 +361,15 @@ typed as `T` — the caller should choose `T` to match their
|
|
|
336
361
|
|
|
337
362
|
#### Type Parameters
|
|
338
363
|
|
|
339
|
-
#####
|
|
364
|
+
##### K
|
|
365
|
+
|
|
366
|
+
`K` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
367
|
+
|
|
368
|
+
Shape of the partition / sort key.
|
|
369
|
+
|
|
370
|
+
##### R
|
|
340
371
|
|
|
341
|
-
`
|
|
372
|
+
`R` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
342
373
|
|
|
343
374
|
Expected shape of the returned `Attributes`.
|
|
344
375
|
|
|
@@ -346,7 +377,7 @@ Expected shape of the returned `Attributes`.
|
|
|
346
377
|
|
|
347
378
|
##### input
|
|
348
379
|
|
|
349
|
-
`UpdateCommandInput`
|
|
380
|
+
`WithTypedKey`\<`UpdateCommandInput`, `K`\>
|
|
350
381
|
|
|
351
382
|
#### Returns
|
|
352
383
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: S3Service
|
|
8
8
|
|
|
9
|
-
Defined in: [s3/s3.ts:
|
|
9
|
+
Defined in: [s3/s3.ts:68](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L68)
|
|
10
10
|
|
|
11
11
|
Wrapper around the AWS S3 client providing structured Powertools logging
|
|
12
12
|
and X-Ray tracing by default.
|
|
@@ -23,7 +23,7 @@ tagging, version IDs) should use `S3Client` directly.
|
|
|
23
23
|
|
|
24
24
|
> **new S3Service**(`opts?`): `S3Service`
|
|
25
25
|
|
|
26
|
-
Defined in: [s3/s3.ts:
|
|
26
|
+
Defined in: [s3/s3.ts:78](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L78)
|
|
27
27
|
|
|
28
28
|
#### Parameters
|
|
29
29
|
|
|
@@ -38,10 +38,10 @@ the wrapper does not apply X-Ray instrumentation.
|
|
|
38
38
|
|
|
39
39
|
###### logger?
|
|
40
40
|
|
|
41
|
-
`
|
|
41
|
+
`LoggerInterface`
|
|
42
42
|
|
|
43
|
-
Optional Powertools logger. Defaults to
|
|
44
|
-
`
|
|
43
|
+
Optional Powertools logger. Defaults to `new Logger()`,
|
|
44
|
+
which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
45
45
|
|
|
46
46
|
#### Returns
|
|
47
47
|
|
|
@@ -55,7 +55,7 @@ Optional Powertools logger. Defaults to a logger with
|
|
|
55
55
|
|
|
56
56
|
> **copyObject**(`input`): `Promise`\<`CopyObjectCommandOutput`\>
|
|
57
57
|
|
|
58
|
-
Defined in: [s3/s3.ts:
|
|
58
|
+
Defined in: [s3/s3.ts:173](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L173)
|
|
59
59
|
|
|
60
60
|
Copy an object within S3.
|
|
61
61
|
|
|
@@ -77,7 +77,7 @@ Copy an object within S3.
|
|
|
77
77
|
|
|
78
78
|
> **deleteObject**(`input`): `Promise`\<`DeleteObjectCommandOutput`\>
|
|
79
79
|
|
|
80
|
-
Defined in: [s3/s3.ts:
|
|
80
|
+
Defined in: [s3/s3.ts:266](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L266)
|
|
81
81
|
|
|
82
82
|
Delete a single object from S3.
|
|
83
83
|
|
|
@@ -99,7 +99,7 @@ Delete a single object from S3.
|
|
|
99
99
|
|
|
100
100
|
> **deleteObjects**(`bucket`, `keys`): `Promise`\<`DeleteObjectsCommandOutput`[]\>
|
|
101
101
|
|
|
102
|
-
Defined in: [s3/s3.ts:
|
|
102
|
+
Defined in: [s3/s3.ts:278](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L278)
|
|
103
103
|
|
|
104
104
|
Delete multiple objects from S3, auto-chunking the request into batches
|
|
105
105
|
of 1000 keys (the S3-enforced DeleteObjects limit). Returns one output
|
|
@@ -127,7 +127,7 @@ per chunk.
|
|
|
127
127
|
|
|
128
128
|
> **emptyBucket**(`bucket`): `Promise`\<`string`[]\>
|
|
129
129
|
|
|
130
|
-
Defined in: [s3/s3.ts:
|
|
130
|
+
Defined in: [s3/s3.ts:307](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L307)
|
|
131
131
|
|
|
132
132
|
Delete every object in a bucket. Streams the listing page-by-page and
|
|
133
133
|
delegates each page's deletion to `deleteObjects`, so peak memory stays
|
|
@@ -153,7 +153,7 @@ The keys of every deleted object.
|
|
|
153
153
|
|
|
154
154
|
> **getAllObjects**\<`T`\>(`bucket`, `prefix?`): `Promise`\<`T`[]\>
|
|
155
155
|
|
|
156
|
-
Defined in: [s3/s3.ts:
|
|
156
|
+
Defined in: [s3/s3.ts:204](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L204)
|
|
157
157
|
|
|
158
158
|
List and JSON-parse every object under a bucket and optional prefix.
|
|
159
159
|
Auto-paginated. Objects without a body are skipped.
|
|
@@ -188,7 +188,7 @@ Expected type of each parsed object.
|
|
|
188
188
|
|
|
189
189
|
> **getJsonObject**\<`T`\>(`input`): `Promise`\<`T` \| `undefined`\>
|
|
190
190
|
|
|
191
|
-
Defined in: [s3/s3.ts:
|
|
191
|
+
Defined in: [s3/s3.ts:151](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L151)
|
|
192
192
|
|
|
193
193
|
Get an object from S3 and parse it as JSON.
|
|
194
194
|
|
|
@@ -224,7 +224,7 @@ If the body is non-empty and not valid JSON.
|
|
|
224
224
|
|
|
225
225
|
> **getObject**(`input`): `Promise`\<`GetObjectCommandOutput`\>
|
|
226
226
|
|
|
227
|
-
Defined in: [s3/s3.ts:
|
|
227
|
+
Defined in: [s3/s3.ts:125](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L125)
|
|
228
228
|
|
|
229
229
|
Get an object from S3.
|
|
230
230
|
|
|
@@ -246,7 +246,7 @@ Get an object from S3.
|
|
|
246
246
|
|
|
247
247
|
> **getObjectBody**(`input`): `Promise`\<`string` \| `undefined`\>
|
|
248
248
|
|
|
249
|
-
Defined in: [s3/s3.ts:
|
|
249
|
+
Defined in: [s3/s3.ts:137](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L137)
|
|
250
250
|
|
|
251
251
|
Get an object from S3 and return its body as a string.
|
|
252
252
|
|
|
@@ -265,13 +265,67 @@ has no body.
|
|
|
265
265
|
|
|
266
266
|
***
|
|
267
267
|
|
|
268
|
+
<a id="getpresignedurl"></a>
|
|
269
|
+
|
|
270
|
+
### getPresignedUrl()
|
|
271
|
+
|
|
272
|
+
> **getPresignedUrl**(`input`): `Promise`\<`string`\>
|
|
273
|
+
|
|
274
|
+
Defined in: [s3/s3.ts:242](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L242)
|
|
275
|
+
|
|
276
|
+
Generate a presigned URL that callers can use to GET or PUT an S3 object
|
|
277
|
+
directly, without going through the wrapper. The signing happens against
|
|
278
|
+
the wrapper's `S3Client`, so callers do not need their own client.
|
|
279
|
+
|
|
280
|
+
GET URLs are signed with `ResponseContentDisposition: 'attachment'` so
|
|
281
|
+
browsers download the object rather than rendering it in-place.
|
|
282
|
+
|
|
283
|
+
The input shape is an inline object (rather than the `Required<Pick<...>>`
|
|
284
|
+
pattern used by other S3 methods) because this method wraps two SDK
|
|
285
|
+
commands rather than one, and `action` / `expiresIn` are wrapper-level
|
|
286
|
+
concerns with no SDK-input equivalent.
|
|
287
|
+
|
|
288
|
+
#### Parameters
|
|
289
|
+
|
|
290
|
+
##### input
|
|
291
|
+
|
|
292
|
+
###### action
|
|
293
|
+
|
|
294
|
+
`"get"` \| `"put"`
|
|
295
|
+
|
|
296
|
+
`'get'` to download, `'put'` to upload.
|
|
297
|
+
|
|
298
|
+
###### Bucket
|
|
299
|
+
|
|
300
|
+
`string`
|
|
301
|
+
|
|
302
|
+
The S3 bucket name.
|
|
303
|
+
|
|
304
|
+
###### expiresIn?
|
|
305
|
+
|
|
306
|
+
`number`
|
|
307
|
+
|
|
308
|
+
URL lifetime in seconds. Defaults to 3600 (1 hour).
|
|
309
|
+
|
|
310
|
+
###### Key
|
|
311
|
+
|
|
312
|
+
`string`
|
|
313
|
+
|
|
314
|
+
The S3 object key.
|
|
315
|
+
|
|
316
|
+
#### Returns
|
|
317
|
+
|
|
318
|
+
`Promise`\<`string`\>
|
|
319
|
+
|
|
320
|
+
***
|
|
321
|
+
|
|
268
322
|
<a id="headobject"></a>
|
|
269
323
|
|
|
270
324
|
### headObject()
|
|
271
325
|
|
|
272
326
|
> **headObject**(`input`): `Promise`\<`HeadObjectCommandOutput`\>
|
|
273
327
|
|
|
274
|
-
Defined in: [s3/s3.ts:
|
|
328
|
+
Defined in: [s3/s3.ts:163](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L163)
|
|
275
329
|
|
|
276
330
|
Fetch the metadata for an S3 object without downloading its body.
|
|
277
331
|
|
|
@@ -293,7 +347,7 @@ Fetch the metadata for an S3 object without downloading its body.
|
|
|
293
347
|
|
|
294
348
|
> **listObjects**(`bucket`, `prefix?`): `Promise`\<`string`[]\>
|
|
295
349
|
|
|
296
|
-
Defined in: [s3/s3.ts:
|
|
350
|
+
Defined in: [s3/s3.ts:184](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L184)
|
|
297
351
|
|
|
298
352
|
List object keys under a bucket and optional prefix, auto-paginating
|
|
299
353
|
across all pages.
|
|
@@ -320,7 +374,7 @@ across all pages.
|
|
|
320
374
|
|
|
321
375
|
> **putJsonObject**\<`T`\>(`input`): `Promise`\<`PutObjectCommandOutput`\>
|
|
322
376
|
|
|
323
|
-
Defined in: [s3/s3.ts:
|
|
377
|
+
Defined in: [s3/s3.ts:108](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L108)
|
|
324
378
|
|
|
325
379
|
Serialise a value to JSON and store it as an S3 object.
|
|
326
380
|
|
|
@@ -340,21 +394,7 @@ Type of the value being stored.
|
|
|
340
394
|
|
|
341
395
|
##### input
|
|
342
396
|
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
`T`
|
|
346
|
-
|
|
347
|
-
###### Bucket
|
|
348
|
-
|
|
349
|
-
`string`
|
|
350
|
-
|
|
351
|
-
###### Key
|
|
352
|
-
|
|
353
|
-
`string`
|
|
354
|
-
|
|
355
|
-
###### Metadata?
|
|
356
|
-
|
|
357
|
-
`Record`\<`string`, `string`\>
|
|
397
|
+
`PutJsonObjectInput`\<`T`\>
|
|
358
398
|
|
|
359
399
|
#### Returns
|
|
360
400
|
|
|
@@ -368,7 +408,7 @@ Type of the value being stored.
|
|
|
368
408
|
|
|
369
409
|
> **putObject**(`input`): `Promise`\<`PutObjectCommandOutput`\>
|
|
370
410
|
|
|
371
|
-
Defined in: [s3/s3.ts:
|
|
411
|
+
Defined in: [s3/s3.ts:92](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/s3/s3.ts#L92)
|
|
372
412
|
|
|
373
413
|
Put an object into S3.
|
|
374
414
|
|
|
@@ -380,7 +420,7 @@ content into CloudWatch.
|
|
|
380
420
|
|
|
381
421
|
##### input
|
|
382
422
|
|
|
383
|
-
`
|
|
423
|
+
`PutObjectInput`
|
|
384
424
|
|
|
385
425
|
Bucket, Key, and Body of the object to store.
|
|
386
426
|
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: SNSService
|
|
8
8
|
|
|
9
|
-
Defined in: [sns/sns.ts:
|
|
9
|
+
Defined in: [sns/sns.ts:39](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/sns/sns.ts#L39)
|
|
10
10
|
|
|
11
11
|
Wrapper around the AWS SNS client providing structured Powertools logging
|
|
12
12
|
and X-Ray tracing by default.
|
|
@@ -19,7 +19,7 @@ and X-Ray tracing by default.
|
|
|
19
19
|
|
|
20
20
|
> **new SNSService**(`opts?`): `SNSService`
|
|
21
21
|
|
|
22
|
-
Defined in: [sns/sns.ts:
|
|
22
|
+
Defined in: [sns/sns.ts:55](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/sns/sns.ts#L55)
|
|
23
23
|
|
|
24
24
|
#### Parameters
|
|
25
25
|
|
|
@@ -34,10 +34,20 @@ the wrapper does not apply X-Ray instrumentation.
|
|
|
34
34
|
|
|
35
35
|
###### logger?
|
|
36
36
|
|
|
37
|
-
`
|
|
37
|
+
`LoggerInterface`
|
|
38
38
|
|
|
39
|
-
Optional Powertools logger. Defaults to
|
|
40
|
-
`
|
|
39
|
+
Optional Powertools logger. Defaults to `new Logger()`,
|
|
40
|
+
which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
41
|
+
|
|
42
|
+
###### truncate?
|
|
43
|
+
|
|
44
|
+
`boolean`
|
|
45
|
+
|
|
46
|
+
When `true`, oversized `Message` / `Subject` are
|
|
47
|
+
truncated (byte-safe / codepoint-safe) before sending instead of failing
|
|
48
|
+
at the SDK. Defaults to `false` — the SDK throws on oversize, which is
|
|
49
|
+
usually the right failure mode. Each `publish` call can override via
|
|
50
|
+
its own `truncate` option.
|
|
41
51
|
|
|
42
52
|
#### Returns
|
|
43
53
|
|
|
@@ -49,12 +59,16 @@ Optional Powertools logger. Defaults to a logger with
|
|
|
49
59
|
|
|
50
60
|
### publish()
|
|
51
61
|
|
|
52
|
-
> **publish**(`input`): `Promise`\<`PublishCommandOutput`\>
|
|
62
|
+
> **publish**(`input`, `opts?`): `Promise`\<`PublishCommandOutput`\>
|
|
53
63
|
|
|
54
|
-
Defined in: [sns/sns.ts:
|
|
64
|
+
Defined in: [sns/sns.ts:70](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/sns/sns.ts#L70)
|
|
55
65
|
|
|
56
66
|
Publish a single message to an SNS topic.
|
|
57
67
|
|
|
68
|
+
At INFO level the log line includes only routing / dedup metadata; see
|
|
69
|
+
`PUBLISH_SAFE_FIELDS` for the list. Setting `POWERTOOLS_LOG_LEVEL=DEBUG`
|
|
70
|
+
unlocks the full input.
|
|
71
|
+
|
|
58
72
|
#### Parameters
|
|
59
73
|
|
|
60
74
|
##### input
|
|
@@ -63,6 +77,12 @@ Publish a single message to an SNS topic.
|
|
|
63
77
|
|
|
64
78
|
PublishCommandInput including TopicArn and Message.
|
|
65
79
|
|
|
80
|
+
##### opts?
|
|
81
|
+
|
|
82
|
+
###### truncate?
|
|
83
|
+
|
|
84
|
+
`boolean`
|
|
85
|
+
|
|
66
86
|
#### Returns
|
|
67
87
|
|
|
68
88
|
`Promise`\<`PublishCommandOutput`\>
|
|
@@ -75,7 +95,7 @@ PublishCommandInput including TopicArn and Message.
|
|
|
75
95
|
|
|
76
96
|
> **publishBatch**(`input`): `Promise`\<`PublishBatchCommandOutput`[]\>
|
|
77
97
|
|
|
78
|
-
Defined in: [sns/sns.ts:
|
|
98
|
+
Defined in: [sns/sns.ts:107](https://github.com/aligent/microservice-development-utilities/blob/1c8403742cbf82a4bd82725126d0860e0996e39d/packages/aws-wrappers/src/sns/sns.ts#L107)
|
|
79
99
|
|
|
80
100
|
Publish a batch of messages to an SNS topic. The SNS API caps
|
|
81
101
|
PublishBatch at 10 entries per request, so this method auto-chunks
|