forked from aws-powertools/powertools-lambda-typescript
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.ts
79 lines (71 loc) · 2.24 KB
/
types.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
import type {
Context,
DynamoDBRecord,
KinesisStreamRecord,
SQSRecord,
} from 'aws-lambda';
import { SqsFifoPartialProcessor } from './SqsFifoPartialProcessor.js';
import { BasePartialBatchProcessor } from './BasePartialBatchProcessor.js';
/**
* Options for batch processing
*
* @template T The type of the batch processor, defaults to BasePartialBatchProcessor
* @property context The context object provided by the AWS Lambda runtime
* @property skipGroupOnError The option to group on error during processing
*/
type BatchProcessingOptions<T = BasePartialBatchProcessor> = {
/**
* The context object provided by the AWS Lambda runtime. When provided,
* it's made available to the handler function you specify
*/
context: Context;
/**
* This option is only available for SqsFifoPartialProcessor.
* If true skip the group on error during processing.
*/
skipGroupOnError?: T extends SqsFifoPartialProcessor ? boolean : never;
};
/**
* The types of data that can be provided by an event source
*/
type EventSourceDataClassTypes =
| SQSRecord
| KinesisStreamRecord
| DynamoDBRecord;
/**
* Type representing a record from an event source
*/
type BaseRecord = { [key: string]: unknown } | EventSourceDataClassTypes;
/**
* Type representing a successful response
*
* The first element is the string literal 'success',
* the second element is the result of the handler function,
* and the third element is the type of data provided by the event source
*/
type SuccessResponse = ['success', unknown, EventSourceDataClassTypes];
/**
* Type representing a failure response
*
* The first element is the string literal 'fail',
* the second element is the error message,
* and the third element is the type of data provided by the event source
*/
type FailureResponse = ['fail', string, EventSourceDataClassTypes];
/**
* Type representing a partial failure response
*/
type PartialItemFailures = { itemIdentifier: string };
/**
* Type representing a partial failure response
*/
type PartialItemFailureResponse = { batchItemFailures: PartialItemFailures[] };
export type {
BatchProcessingOptions,
BaseRecord,
EventSourceDataClassTypes,
SuccessResponse,
FailureResponse,
PartialItemFailures,
PartialItemFailureResponse,
};