@aligent/aws-wrappers 0.5.7 → 0.5.9
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 +106 -4
- package/cjs/index.cjs +393 -66
- package/cjs/package.json +16 -14
- package/cjs/src/eventbridge/eventbridge.d.ts +58 -0
- package/cjs/src/eventbridge/eventbridge.d.ts.map +1 -0
- package/cjs/src/index.d.ts +4 -0
- package/cjs/src/index.d.ts.map +1 -1
- package/cjs/src/lambda/lambda.d.ts +54 -0
- package/cjs/src/lambda/lambda.d.ts.map +1 -0
- package/cjs/src/s3/s3.d.ts +26 -4
- package/cjs/src/s3/s3.d.ts.map +1 -1
- package/cjs/src/scheduler/scheduler.d.ts +3 -2
- package/cjs/src/scheduler/scheduler.d.ts.map +1 -1
- package/cjs/src/ssm/ssm.d.ts +18 -3
- package/cjs/src/ssm/ssm.d.ts.map +1 -1
- package/cjs/src/util/batch-operation-error.d.ts +33 -4
- package/cjs/src/util/batch-operation-error.d.ts.map +1 -1
- package/cjs/src/util/lambda-function-error.d.ts +36 -0
- package/cjs/src/util/lambda-function-error.d.ts.map +1 -0
- package/docs/index/classes/APIGatewayService.md +6 -6
- package/docs/index/classes/APIGatewayV2Service.md +5 -5
- package/docs/index/classes/BatchOperationError.md +10 -6
- package/docs/index/classes/DynamoDBService.md +34 -12
- package/docs/index/classes/EventBridgeService.md +99 -0
- package/docs/index/classes/LambdaFunctionError.md +283 -0
- package/docs/index/classes/LambdaService.md +95 -0
- package/docs/index/classes/S3Service.md +42 -19
- package/docs/index/classes/SNSService.md +4 -4
- package/docs/index/classes/SQSService.md +7 -7
- package/docs/index/classes/SSMService.md +35 -10
- package/docs/index/classes/SchedulerService.md +14 -13
- package/docs/index/classes/SecretsManagerService.md +10 -8
- package/docs/index/classes/StepFunctionsService.md +6 -6
- package/docs/index/interfaces/BatchFailedEntry.md +6 -5
- package/docs/index/interfaces/EmptyBucketPageResult.md +23 -0
- package/docs/index/modules.md +4 -0
- package/docs/testing/testing/functions/createMockService.md +5 -1
- package/esm/index.mjs +391 -67
- package/esm/package.json +16 -14
- package/esm/src/eventbridge/eventbridge.d.ts +58 -0
- package/esm/src/eventbridge/eventbridge.d.ts.map +1 -0
- package/esm/src/index.d.ts +4 -0
- package/esm/src/index.d.ts.map +1 -1
- package/esm/src/lambda/lambda.d.ts +54 -0
- package/esm/src/lambda/lambda.d.ts.map +1 -0
- package/esm/src/s3/s3.d.ts +26 -4
- package/esm/src/s3/s3.d.ts.map +1 -1
- package/esm/src/scheduler/scheduler.d.ts +3 -2
- package/esm/src/scheduler/scheduler.d.ts.map +1 -1
- package/esm/src/ssm/ssm.d.ts +18 -3
- package/esm/src/ssm/ssm.d.ts.map +1 -1
- package/esm/src/util/batch-operation-error.d.ts +33 -4
- package/esm/src/util/batch-operation-error.d.ts.map +1 -1
- package/esm/src/util/lambda-function-error.d.ts +36 -0
- package/esm/src/util/lambda-function-error.d.ts.map +1 -0
- package/package.json +16 -14
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: DynamoDBService
|
|
8
8
|
|
|
9
|
-
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:166](https://github.com/aligent/microservice-development-utilities/blob/
|
|
9
|
+
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:166](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L166)
|
|
10
10
|
|
|
11
11
|
Wrapper around the AWS DynamoDB Document client providing structured
|
|
12
12
|
Powertools logging and X-Ray tracing by default.
|
|
@@ -26,7 +26,7 @@ callers work with plain TypeScript objects in both directions.
|
|
|
26
26
|
|
|
27
27
|
> **new DynamoDBService**(`opts?`): `DynamoDBService`
|
|
28
28
|
|
|
29
|
-
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:179](https://github.com/aligent/microservice-development-utilities/blob/
|
|
29
|
+
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:179](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L179)
|
|
30
30
|
|
|
31
31
|
#### Parameters
|
|
32
32
|
|
|
@@ -61,7 +61,7 @@ which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
|
61
61
|
|
|
62
62
|
> **batchGet**(`input`): `Promise`\<`BatchGetCommandOutput`\>
|
|
63
63
|
|
|
64
|
-
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:317](https://github.com/aligent/microservice-development-utilities/blob/
|
|
64
|
+
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:317](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L317)
|
|
65
65
|
|
|
66
66
|
Batch-get items from one or more DynamoDB tables, retrying
|
|
67
67
|
`UnprocessedKeys` with jittered exponential backoff. Up to 5 attempts
|
|
@@ -91,7 +91,7 @@ Callers should narrow the result type at the call site.
|
|
|
91
91
|
|
|
92
92
|
> **batchWrite**(`input`): `Promise`\<`BatchWriteCommandOutput`\>
|
|
93
93
|
|
|
94
|
-
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:349](https://github.com/aligent/microservice-development-utilities/blob/
|
|
94
|
+
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:349](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L349)
|
|
95
95
|
|
|
96
96
|
Batch-write items to DynamoDB, retrying `UnprocessedItems` with jittered
|
|
97
97
|
exponential backoff. Up to 5 attempts (200ms base delay). Throws when
|
|
@@ -115,19 +115,23 @@ items remain unprocessed after the final attempt.
|
|
|
115
115
|
|
|
116
116
|
> **deleteItem**\<`K`, `R`\>(`input`): `Promise`\<`Omit`\<`DeleteCommandOutput`, `"Attributes"`\> & `object`\>
|
|
117
117
|
|
|
118
|
-
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:248](https://github.com/aligent/microservice-development-utilities/blob/
|
|
118
|
+
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:248](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L248)
|
|
119
119
|
|
|
120
120
|
Delete an item from DynamoDB. The `Attributes` field on the response is
|
|
121
121
|
typed as `R` — relevant when `ReturnValues: 'ALL_OLD'` is set.
|
|
122
122
|
|
|
123
123
|
#### Type Parameters
|
|
124
124
|
|
|
125
|
+
<a id="k"></a>
|
|
126
|
+
|
|
125
127
|
##### K
|
|
126
128
|
|
|
127
129
|
`K` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
128
130
|
|
|
129
131
|
Shape of the partition / sort key.
|
|
130
132
|
|
|
133
|
+
<a id="r"></a>
|
|
134
|
+
|
|
131
135
|
##### R
|
|
132
136
|
|
|
133
137
|
`R` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
@@ -152,18 +156,22 @@ Expected shape of the returned `Attributes`.
|
|
|
152
156
|
|
|
153
157
|
> **getItem**\<`K`, `R`\>(`input`): `Promise`\<`R` \| `undefined`\>
|
|
154
158
|
|
|
155
|
-
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:194](https://github.com/aligent/microservice-development-utilities/blob/
|
|
159
|
+
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:194](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L194)
|
|
156
160
|
|
|
157
161
|
Get an item from DynamoDB.
|
|
158
162
|
|
|
159
163
|
#### Type Parameters
|
|
160
164
|
|
|
165
|
+
<a id="k-1"></a>
|
|
166
|
+
|
|
161
167
|
##### K
|
|
162
168
|
|
|
163
169
|
`K` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
164
170
|
|
|
165
171
|
Shape of the partition / sort key.
|
|
166
172
|
|
|
173
|
+
<a id="r-1"></a>
|
|
174
|
+
|
|
167
175
|
##### R
|
|
168
176
|
|
|
169
177
|
`R` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
@@ -190,7 +198,7 @@ The item, or `undefined` if not found.
|
|
|
190
198
|
|
|
191
199
|
> **paginateItems**\<`T`\>(`input`): `AsyncGenerator`\<`T`\>
|
|
192
200
|
|
|
193
|
-
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:395](https://github.com/aligent/microservice-development-utilities/blob/
|
|
201
|
+
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:395](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L395)
|
|
194
202
|
|
|
195
203
|
Paginate over Query results, yielding one unmarshalled item at a time.
|
|
196
204
|
|
|
@@ -217,6 +225,8 @@ walk.
|
|
|
217
225
|
|
|
218
226
|
#### Type Parameters
|
|
219
227
|
|
|
228
|
+
<a id="t"></a>
|
|
229
|
+
|
|
220
230
|
##### T
|
|
221
231
|
|
|
222
232
|
`T` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
@@ -241,7 +251,7 @@ Expected shape of each yielded item.
|
|
|
241
251
|
|
|
242
252
|
> **paginateScan**\<`T`\>(`input`): `AsyncGenerator`\<`T`\>
|
|
243
253
|
|
|
244
|
-
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:417](https://github.com/aligent/microservice-development-utilities/blob/
|
|
254
|
+
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:417](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L417)
|
|
245
255
|
|
|
246
256
|
Paginate over Scan results, yielding one unmarshalled item at a time.
|
|
247
257
|
|
|
@@ -251,6 +261,8 @@ stays the right knob for per-request consumed capacity and page memory.
|
|
|
251
261
|
|
|
252
262
|
#### Type Parameters
|
|
253
263
|
|
|
264
|
+
<a id="t-1"></a>
|
|
265
|
+
|
|
254
266
|
##### T
|
|
255
267
|
|
|
256
268
|
`T` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
@@ -275,13 +287,15 @@ Expected shape of each yielded item.
|
|
|
275
287
|
|
|
276
288
|
> **putItem**\<`T`\>(`input`): `Promise`\<`PutCommandOutput`\>
|
|
277
289
|
|
|
278
|
-
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:210](https://github.com/aligent/microservice-development-utilities/blob/
|
|
290
|
+
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:210](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L210)
|
|
279
291
|
|
|
280
292
|
Put an item into DynamoDB. The caller's `Item` is typed as `T`, which
|
|
281
293
|
the document client marshalls automatically.
|
|
282
294
|
|
|
283
295
|
#### Type Parameters
|
|
284
296
|
|
|
297
|
+
<a id="t-2"></a>
|
|
298
|
+
|
|
285
299
|
##### T
|
|
286
300
|
|
|
287
301
|
`T`
|
|
@@ -306,7 +320,7 @@ Type of the item being stored.
|
|
|
306
320
|
|
|
307
321
|
> **query**\<`T`\>(`input`): `Promise`\<`Omit`\<`QueryCommandOutput`, `"Items"`\> & `object`\>
|
|
308
322
|
|
|
309
|
-
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:267](https://github.com/aligent/microservice-development-utilities/blob/
|
|
323
|
+
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:267](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L267)
|
|
310
324
|
|
|
311
325
|
Execute a DynamoDB Query. The full `QueryCommandOutput` is returned with
|
|
312
326
|
`Items` typed as `T[]` so callers retain pagination metadata
|
|
@@ -314,6 +328,8 @@ Execute a DynamoDB Query. The full `QueryCommandOutput` is returned with
|
|
|
314
328
|
|
|
315
329
|
#### Type Parameters
|
|
316
330
|
|
|
331
|
+
<a id="t-3"></a>
|
|
332
|
+
|
|
317
333
|
##### T
|
|
318
334
|
|
|
319
335
|
`T` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
@@ -338,7 +354,7 @@ Expected shape of each unmarshalled item.
|
|
|
338
354
|
|
|
339
355
|
> **scan**\<`T`\>(`input`): `Promise`\<`Omit`\<`ScanCommandOutput`, `"Items"`\> & `object`\>
|
|
340
356
|
|
|
341
|
-
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:296](https://github.com/aligent/microservice-development-utilities/blob/
|
|
357
|
+
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:296](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L296)
|
|
342
358
|
|
|
343
359
|
Scan a DynamoDB table. The full `ScanCommandOutput` is returned with
|
|
344
360
|
`Items` typed as `T[]` so callers retain pagination metadata.
|
|
@@ -358,6 +374,8 @@ embedding a scan in a Lambda.
|
|
|
358
374
|
|
|
359
375
|
#### Type Parameters
|
|
360
376
|
|
|
377
|
+
<a id="t-4"></a>
|
|
378
|
+
|
|
361
379
|
##### T
|
|
362
380
|
|
|
363
381
|
`T` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
@@ -382,7 +400,7 @@ Expected shape of each unmarshalled item.
|
|
|
382
400
|
|
|
383
401
|
> **updateItem**\<`K`, `R`\>(`input`): `Promise`\<`Omit`\<`UpdateCommandOutput`, `"Attributes"`\> & `object`\>
|
|
384
402
|
|
|
385
|
-
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:229](https://github.com/aligent/microservice-development-utilities/blob/
|
|
403
|
+
Defined in: [packages/aws-wrappers/src/dynamodb/dynamodb.ts:229](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L229)
|
|
386
404
|
|
|
387
405
|
Update an item in DynamoDB. The `Attributes` field on the response is
|
|
388
406
|
typed as `R` — the caller should choose `R` to match their
|
|
@@ -393,12 +411,16 @@ typed as `R` — the caller should choose `R` to match their
|
|
|
393
411
|
|
|
394
412
|
#### Type Parameters
|
|
395
413
|
|
|
414
|
+
<a id="k-2"></a>
|
|
415
|
+
|
|
396
416
|
##### K
|
|
397
417
|
|
|
398
418
|
`K` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
399
419
|
|
|
400
420
|
Shape of the partition / sort key.
|
|
401
421
|
|
|
422
|
+
<a id="r-2"></a>
|
|
423
|
+
|
|
402
424
|
##### R
|
|
403
425
|
|
|
404
426
|
`R` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
[**@aligent/aws-wrappers**](../../modules.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@aligent/aws-wrappers](../../modules.md) / [index](../modules.md) / EventBridgeService
|
|
6
|
+
|
|
7
|
+
# Class: EventBridgeService
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/aws-wrappers/src/eventbridge/eventbridge.ts:64](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/eventbridge/eventbridge.ts#L64)
|
|
10
|
+
|
|
11
|
+
Wrapper around the AWS EventBridge client providing structured Powertools
|
|
12
|
+
logging and X-Ray tracing by default.
|
|
13
|
+
|
|
14
|
+
Where a method's input carries payloads, secret material or PII, the INFO
|
|
15
|
+
log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
16
|
+
`TRACE`) log full SDK inputs.
|
|
17
|
+
|
|
18
|
+
Covers `putEvents` only. Named `EventBridgeService` for the event bus API;
|
|
19
|
+
schedules live in `SchedulerService`.
|
|
20
|
+
|
|
21
|
+
## Constructors
|
|
22
|
+
|
|
23
|
+
<a id="constructor"></a>
|
|
24
|
+
|
|
25
|
+
### Constructor
|
|
26
|
+
|
|
27
|
+
> **new EventBridgeService**(`opts?`): `EventBridgeService`
|
|
28
|
+
|
|
29
|
+
Defined in: [packages/aws-wrappers/src/eventbridge/eventbridge.ts:74](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/eventbridge/eventbridge.ts#L74)
|
|
30
|
+
|
|
31
|
+
#### Parameters
|
|
32
|
+
|
|
33
|
+
##### opts?
|
|
34
|
+
|
|
35
|
+
###### client?
|
|
36
|
+
|
|
37
|
+
`EventBridgeClient`
|
|
38
|
+
|
|
39
|
+
Optional pre-configured `EventBridgeClient`. When
|
|
40
|
+
supplied, the wrapper does not apply X-Ray instrumentation.
|
|
41
|
+
|
|
42
|
+
###### logger?
|
|
43
|
+
|
|
44
|
+
`LoggerInterface`
|
|
45
|
+
|
|
46
|
+
Optional Powertools logger. Defaults to `new Logger()`,
|
|
47
|
+
which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
48
|
+
|
|
49
|
+
#### Returns
|
|
50
|
+
|
|
51
|
+
`EventBridgeService`
|
|
52
|
+
|
|
53
|
+
## Methods
|
|
54
|
+
|
|
55
|
+
<a id="putevents"></a>
|
|
56
|
+
|
|
57
|
+
### putEvents()
|
|
58
|
+
|
|
59
|
+
> **putEvents**(`input`): `Promise`\<`PutEventsCommandOutput`[]\>
|
|
60
|
+
|
|
61
|
+
Defined in: [packages/aws-wrappers/src/eventbridge/eventbridge.ts:108](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/eventbridge/eventbridge.ts#L108)
|
|
62
|
+
|
|
63
|
+
Publish events to an event bus. The EventBridge API caps `PutEvents` at
|
|
64
|
+
10 entries per request, so this method auto-chunks the caller's `Entries`
|
|
65
|
+
and sends one request per chunk, returning the array of outputs. The
|
|
66
|
+
remaining request fields (such as `EndpointId`) are carried onto every
|
|
67
|
+
chunk.
|
|
68
|
+
|
|
69
|
+
Chunking is by count only. The 256 KB request size limit is not enforced
|
|
70
|
+
here: a chunk that exceeds it fails at the SDK as a request-level error.
|
|
71
|
+
|
|
72
|
+
Every chunk is sent before the outcome is judged. If EventBridge rejected
|
|
73
|
+
any entry (it reports an error code on the result entry), a
|
|
74
|
+
[BatchOperationError](BatchOperationError.md) is then thrown carrying the per-chunk results
|
|
75
|
+
and the failed entries. For this method each failed entry's `id` is
|
|
76
|
+
always set, to the entry's index in the caller's original `Entries` list
|
|
77
|
+
across all chunks, as a string. Only `id`, `code` and `message` are
|
|
78
|
+
copied out, so event detail never reaches the error.
|
|
79
|
+
|
|
80
|
+
No retries are performed. Request-level SDK exceptions (throttling,
|
|
81
|
+
access denied, oversize request) are not wrapped: they propagate
|
|
82
|
+
unchanged and immediately, so earlier chunks may already have been
|
|
83
|
+
published.
|
|
84
|
+
|
|
85
|
+
At INFO level the log line includes only the endpoint id and the entry
|
|
86
|
+
count, because `Detail`, `Resources` and the entries themselves are
|
|
87
|
+
payload carriers.
|
|
88
|
+
|
|
89
|
+
#### Parameters
|
|
90
|
+
|
|
91
|
+
##### input
|
|
92
|
+
|
|
93
|
+
`PutEventsCommandInput`
|
|
94
|
+
|
|
95
|
+
PutEventsCommandInput including Entries.
|
|
96
|
+
|
|
97
|
+
#### Returns
|
|
98
|
+
|
|
99
|
+
`Promise`\<`PutEventsCommandOutput`[]\>
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
[**@aligent/aws-wrappers**](../../modules.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@aligent/aws-wrappers](../../modules.md) / [index](../modules.md) / LambdaFunctionError
|
|
6
|
+
|
|
7
|
+
# Class: LambdaFunctionError
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/aws-wrappers/src/util/lambda-function-error.ts:21](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/util/lambda-function-error.ts#L21)
|
|
10
|
+
|
|
11
|
+
Thrown by `LambdaService.invoke` when a synchronous invocation reached the
|
|
12
|
+
function but the function itself failed. Lambda reports that as an HTTP 200
|
|
13
|
+
carrying a function error marker, so the SDK does not throw.
|
|
14
|
+
|
|
15
|
+
`functionError` is the SDK's marker (`Handled` or `Unhandled`).
|
|
16
|
+
`errorType` and `errorMessage` are parsed from the response payload when it
|
|
17
|
+
has the usual `{ errorType, errorMessage }` JSON shape, otherwise undefined.
|
|
18
|
+
|
|
19
|
+
Deliberately excludes the raw SDK output and the stack trace: either can
|
|
20
|
+
contain the caller's payload or PII.
|
|
21
|
+
|
|
22
|
+
Match on `name` rather than `instanceof` if both the CJS and ESM builds of
|
|
23
|
+
this package may be loaded in one process.
|
|
24
|
+
|
|
25
|
+
## Extends
|
|
26
|
+
|
|
27
|
+
- `Error`
|
|
28
|
+
|
|
29
|
+
## Constructors
|
|
30
|
+
|
|
31
|
+
<a id="constructor"></a>
|
|
32
|
+
|
|
33
|
+
### Constructor
|
|
34
|
+
|
|
35
|
+
> **new LambdaFunctionError**(`functionName`, `functionError`, `payload`): `LambdaFunctionError`
|
|
36
|
+
|
|
37
|
+
Defined in: [packages/aws-wrappers/src/util/lambda-function-error.ts:26](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/util/lambda-function-error.ts#L26)
|
|
38
|
+
|
|
39
|
+
#### Parameters
|
|
40
|
+
|
|
41
|
+
##### functionName
|
|
42
|
+
|
|
43
|
+
`string` \| `undefined`
|
|
44
|
+
|
|
45
|
+
##### functionError
|
|
46
|
+
|
|
47
|
+
`string`
|
|
48
|
+
|
|
49
|
+
##### payload
|
|
50
|
+
|
|
51
|
+
`Pick`\<`LambdaFunctionError`, `"errorType"` \| `"errorMessage"`\>
|
|
52
|
+
|
|
53
|
+
#### Returns
|
|
54
|
+
|
|
55
|
+
`LambdaFunctionError`
|
|
56
|
+
|
|
57
|
+
#### Overrides
|
|
58
|
+
|
|
59
|
+
`Error.constructor`
|
|
60
|
+
|
|
61
|
+
## Properties
|
|
62
|
+
|
|
63
|
+
<a id="cause"></a>
|
|
64
|
+
|
|
65
|
+
### cause?
|
|
66
|
+
|
|
67
|
+
> `optional` **cause?**: `unknown`
|
|
68
|
+
|
|
69
|
+
Defined in: node\_modules/typescript/lib/lib.es2022.error.d.ts:24
|
|
70
|
+
|
|
71
|
+
#### Inherited from
|
|
72
|
+
|
|
73
|
+
`Error.cause`
|
|
74
|
+
|
|
75
|
+
***
|
|
76
|
+
|
|
77
|
+
<a id="errormessage"></a>
|
|
78
|
+
|
|
79
|
+
### errorMessage
|
|
80
|
+
|
|
81
|
+
> `readonly` **errorMessage**: `string` \| `undefined`
|
|
82
|
+
|
|
83
|
+
Defined in: [packages/aws-wrappers/src/util/lambda-function-error.ts:24](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/util/lambda-function-error.ts#L24)
|
|
84
|
+
|
|
85
|
+
***
|
|
86
|
+
|
|
87
|
+
<a id="errortype"></a>
|
|
88
|
+
|
|
89
|
+
### errorType
|
|
90
|
+
|
|
91
|
+
> `readonly` **errorType**: `string` \| `undefined`
|
|
92
|
+
|
|
93
|
+
Defined in: [packages/aws-wrappers/src/util/lambda-function-error.ts:23](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/util/lambda-function-error.ts#L23)
|
|
94
|
+
|
|
95
|
+
***
|
|
96
|
+
|
|
97
|
+
<a id="functionerror"></a>
|
|
98
|
+
|
|
99
|
+
### functionError
|
|
100
|
+
|
|
101
|
+
> `readonly` **functionError**: `string`
|
|
102
|
+
|
|
103
|
+
Defined in: [packages/aws-wrappers/src/util/lambda-function-error.ts:28](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/util/lambda-function-error.ts#L28)
|
|
104
|
+
|
|
105
|
+
***
|
|
106
|
+
|
|
107
|
+
<a id="functionname"></a>
|
|
108
|
+
|
|
109
|
+
### functionName
|
|
110
|
+
|
|
111
|
+
> `readonly` **functionName**: `string` \| `undefined`
|
|
112
|
+
|
|
113
|
+
Defined in: [packages/aws-wrappers/src/util/lambda-function-error.ts:27](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/util/lambda-function-error.ts#L27)
|
|
114
|
+
|
|
115
|
+
***
|
|
116
|
+
|
|
117
|
+
<a id="message"></a>
|
|
118
|
+
|
|
119
|
+
### message
|
|
120
|
+
|
|
121
|
+
> **message**: `string`
|
|
122
|
+
|
|
123
|
+
Defined in: node\_modules/typescript/lib/lib.es5.d.ts:1075
|
|
124
|
+
|
|
125
|
+
#### Inherited from
|
|
126
|
+
|
|
127
|
+
`Error.message`
|
|
128
|
+
|
|
129
|
+
***
|
|
130
|
+
|
|
131
|
+
<a id="name"></a>
|
|
132
|
+
|
|
133
|
+
### name
|
|
134
|
+
|
|
135
|
+
> `readonly` **name**: `"LambdaFunctionError"` = `'LambdaFunctionError'`
|
|
136
|
+
|
|
137
|
+
Defined in: [packages/aws-wrappers/src/util/lambda-function-error.ts:22](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/util/lambda-function-error.ts#L22)
|
|
138
|
+
|
|
139
|
+
#### Overrides
|
|
140
|
+
|
|
141
|
+
`Error.name`
|
|
142
|
+
|
|
143
|
+
***
|
|
144
|
+
|
|
145
|
+
<a id="stack"></a>
|
|
146
|
+
|
|
147
|
+
### stack?
|
|
148
|
+
|
|
149
|
+
> `optional` **stack?**: `string`
|
|
150
|
+
|
|
151
|
+
Defined in: node\_modules/typescript/lib/lib.es5.d.ts:1076
|
|
152
|
+
|
|
153
|
+
#### Inherited from
|
|
154
|
+
|
|
155
|
+
`Error.stack`
|
|
156
|
+
|
|
157
|
+
***
|
|
158
|
+
|
|
159
|
+
<a id="stacktracelimit"></a>
|
|
160
|
+
|
|
161
|
+
### stackTraceLimit
|
|
162
|
+
|
|
163
|
+
> `static` **stackTraceLimit**: `number`
|
|
164
|
+
|
|
165
|
+
Defined in: node\_modules/@types/node/globals.d.ts:68
|
|
166
|
+
|
|
167
|
+
The `Error.stackTraceLimit` property specifies the number of stack frames
|
|
168
|
+
collected by a stack trace (whether generated by `new Error().stack` or
|
|
169
|
+
`Error.captureStackTrace(obj)`).
|
|
170
|
+
|
|
171
|
+
The default value is `10` but may be set to any valid JavaScript number. Changes
|
|
172
|
+
will affect any stack trace captured _after_ the value has been changed.
|
|
173
|
+
|
|
174
|
+
If set to a non-number value, or set to a negative number, stack traces will
|
|
175
|
+
not capture any frames.
|
|
176
|
+
|
|
177
|
+
#### Inherited from
|
|
178
|
+
|
|
179
|
+
`Error.stackTraceLimit`
|
|
180
|
+
|
|
181
|
+
## Methods
|
|
182
|
+
|
|
183
|
+
<a id="capturestacktrace"></a>
|
|
184
|
+
|
|
185
|
+
### captureStackTrace()
|
|
186
|
+
|
|
187
|
+
> `static` **captureStackTrace**(`targetObject`, `constructorOpt?`): `void`
|
|
188
|
+
|
|
189
|
+
Defined in: node\_modules/@types/node/globals.d.ts:52
|
|
190
|
+
|
|
191
|
+
Creates a `.stack` property on `targetObject`, which when accessed returns
|
|
192
|
+
a string representing the location in the code at which
|
|
193
|
+
`Error.captureStackTrace()` was called.
|
|
194
|
+
|
|
195
|
+
```js
|
|
196
|
+
const myObject = {};
|
|
197
|
+
Error.captureStackTrace(myObject);
|
|
198
|
+
myObject.stack; // Similar to `new Error().stack`
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
The first line of the trace will be prefixed with
|
|
202
|
+
`${myObject.name}: ${myObject.message}`.
|
|
203
|
+
|
|
204
|
+
The optional `constructorOpt` argument accepts a function. If given, all frames
|
|
205
|
+
above `constructorOpt`, including `constructorOpt`, will be omitted from the
|
|
206
|
+
generated stack trace.
|
|
207
|
+
|
|
208
|
+
The `constructorOpt` argument is useful for hiding implementation
|
|
209
|
+
details of error generation from the user. For instance:
|
|
210
|
+
|
|
211
|
+
```js
|
|
212
|
+
function a() {
|
|
213
|
+
b();
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
function b() {
|
|
217
|
+
c();
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
function c() {
|
|
221
|
+
// Create an error without stack trace to avoid calculating the stack trace twice.
|
|
222
|
+
const { stackTraceLimit } = Error;
|
|
223
|
+
Error.stackTraceLimit = 0;
|
|
224
|
+
const error = new Error();
|
|
225
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
226
|
+
|
|
227
|
+
// Capture the stack trace above function b
|
|
228
|
+
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
|
|
229
|
+
throw error;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
a();
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
#### Parameters
|
|
236
|
+
|
|
237
|
+
##### targetObject
|
|
238
|
+
|
|
239
|
+
`object`
|
|
240
|
+
|
|
241
|
+
##### constructorOpt?
|
|
242
|
+
|
|
243
|
+
`Function`
|
|
244
|
+
|
|
245
|
+
#### Returns
|
|
246
|
+
|
|
247
|
+
`void`
|
|
248
|
+
|
|
249
|
+
#### Inherited from
|
|
250
|
+
|
|
251
|
+
`Error.captureStackTrace`
|
|
252
|
+
|
|
253
|
+
***
|
|
254
|
+
|
|
255
|
+
<a id="preparestacktrace"></a>
|
|
256
|
+
|
|
257
|
+
### prepareStackTrace()
|
|
258
|
+
|
|
259
|
+
> `static` **prepareStackTrace**(`err`, `stackTraces`): `any`
|
|
260
|
+
|
|
261
|
+
Defined in: node\_modules/@types/node/globals.d.ts:56
|
|
262
|
+
|
|
263
|
+
#### Parameters
|
|
264
|
+
|
|
265
|
+
##### err
|
|
266
|
+
|
|
267
|
+
`Error`
|
|
268
|
+
|
|
269
|
+
##### stackTraces
|
|
270
|
+
|
|
271
|
+
`CallSite`[]
|
|
272
|
+
|
|
273
|
+
#### Returns
|
|
274
|
+
|
|
275
|
+
`any`
|
|
276
|
+
|
|
277
|
+
#### See
|
|
278
|
+
|
|
279
|
+
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
|
|
280
|
+
|
|
281
|
+
#### Inherited from
|
|
282
|
+
|
|
283
|
+
`Error.prepareStackTrace`
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
[**@aligent/aws-wrappers**](../../modules.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@aligent/aws-wrappers](../../modules.md) / [index](../modules.md) / LambdaService
|
|
6
|
+
|
|
7
|
+
# Class: LambdaService
|
|
8
|
+
|
|
9
|
+
Defined in: [packages/aws-wrappers/src/lambda/lambda.ts:36](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/lambda/lambda.ts#L36)
|
|
10
|
+
|
|
11
|
+
Wrapper around the AWS Lambda client providing structured Powertools logging
|
|
12
|
+
and X-Ray tracing by default.
|
|
13
|
+
|
|
14
|
+
Where a method's input carries payloads, secret material or PII, the INFO
|
|
15
|
+
log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
16
|
+
`TRACE`) log full SDK inputs.
|
|
17
|
+
|
|
18
|
+
Covers `invoke` only.
|
|
19
|
+
|
|
20
|
+
## Constructors
|
|
21
|
+
|
|
22
|
+
<a id="constructor"></a>
|
|
23
|
+
|
|
24
|
+
### Constructor
|
|
25
|
+
|
|
26
|
+
> **new LambdaService**(`opts?`): `LambdaService`
|
|
27
|
+
|
|
28
|
+
Defined in: [packages/aws-wrappers/src/lambda/lambda.ts:46](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/lambda/lambda.ts#L46)
|
|
29
|
+
|
|
30
|
+
#### Parameters
|
|
31
|
+
|
|
32
|
+
##### opts?
|
|
33
|
+
|
|
34
|
+
###### client?
|
|
35
|
+
|
|
36
|
+
`LambdaClient`
|
|
37
|
+
|
|
38
|
+
Optional pre-configured `LambdaClient`. When
|
|
39
|
+
supplied, the wrapper does not apply X-Ray instrumentation.
|
|
40
|
+
|
|
41
|
+
###### logger?
|
|
42
|
+
|
|
43
|
+
`LoggerInterface`
|
|
44
|
+
|
|
45
|
+
Optional Powertools logger. Defaults to `new Logger()`,
|
|
46
|
+
which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
47
|
+
|
|
48
|
+
#### Returns
|
|
49
|
+
|
|
50
|
+
`LambdaService`
|
|
51
|
+
|
|
52
|
+
## Methods
|
|
53
|
+
|
|
54
|
+
<a id="invoke"></a>
|
|
55
|
+
|
|
56
|
+
### invoke()
|
|
57
|
+
|
|
58
|
+
> **invoke**(`input`): `Promise`\<`InvokeCommandOutput`\>
|
|
59
|
+
|
|
60
|
+
Defined in: [packages/aws-wrappers/src/lambda/lambda.ts:77](https://github.com/aligent/microservice-development-utilities/blob/3822f761bcc8572b495cfd407e000d4fed44d0ba/packages/aws-wrappers/src/lambda/lambda.ts#L77)
|
|
61
|
+
|
|
62
|
+
Invoke a Lambda function. The input is the SDK input unchanged and the
|
|
63
|
+
output is the SDK output unchanged: `Payload` stays a `Uint8Array` you
|
|
64
|
+
decode yourself. Choose synchronous, asynchronous or dry-run invocation
|
|
65
|
+
with `InvocationType`; omitting it means synchronous (`RequestResponse`).
|
|
66
|
+
|
|
67
|
+
Lambda answers HTTP 200 even when the invoked function threw, flagging it
|
|
68
|
+
with `FunctionError` on the response. If that marker is present this
|
|
69
|
+
method warns and throws a [LambdaFunctionError](LambdaFunctionError.md) carrying the
|
|
70
|
+
function name, the marker, and the error type and message parsed from the
|
|
71
|
+
payload when it has the usual JSON shape. The raw output and the stack
|
|
72
|
+
trace are deliberately left off the error.
|
|
73
|
+
|
|
74
|
+
The marker only appears on synchronous responses, so the check is
|
|
75
|
+
unconditional: asynchronous (`Event`) and `DryRun` responses return
|
|
76
|
+
without throwing. Failures of asynchronous invocations are therefore not
|
|
77
|
+
observable here; they belong to dead-letter queues and destinations on
|
|
78
|
+
the invoked function. No status code check is added; service-level
|
|
79
|
+
errors such as throttling are thrown by the SDK and propagate unwrapped.
|
|
80
|
+
|
|
81
|
+
At INFO level the log line includes only the function name, invocation
|
|
82
|
+
type, qualifier, log type and tenant id. `Payload` and `ClientContext` are
|
|
83
|
+
omitted, and responses are never logged.
|
|
84
|
+
|
|
85
|
+
#### Parameters
|
|
86
|
+
|
|
87
|
+
##### input
|
|
88
|
+
|
|
89
|
+
`InvokeCommandInput`
|
|
90
|
+
|
|
91
|
+
InvokeCommandInput including FunctionName.
|
|
92
|
+
|
|
93
|
+
#### Returns
|
|
94
|
+
|
|
95
|
+
`Promise`\<`InvokeCommandOutput`\>
|