mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 Merge PR #47284 [aws-lambda] add ses event by @johanneswuerbach
This commit is contained in:
parent
4d4da2106d
commit
89a11295bc
2
types/aws-lambda/index.d.ts
vendored
2
types/aws-lambda/index.d.ts
vendored
@ -75,7 +75,7 @@ export * from "./trigger/lex";
|
||||
// RDS events are delivered using SNS events...
|
||||
export * from "./trigger/s3";
|
||||
export * from "./trigger/s3-batch";
|
||||
// SES events are delivered using SNS events...
|
||||
export * from "./trigger/ses";
|
||||
export * from "./trigger/sns";
|
||||
export * from "./trigger/sqs";
|
||||
|
||||
|
||||
181
types/aws-lambda/test/ses-tests.ts
Normal file
181
types/aws-lambda/test/ses-tests.ts
Normal file
@ -0,0 +1,181 @@
|
||||
import { SESHandler, SESEvent, SESEventRecord } from 'aws-lambda';
|
||||
|
||||
// From https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-action-lambda-event.html#receiving-email-action-lambda-event-lambdaaction
|
||||
|
||||
const sesEvent: SESEvent = {
|
||||
Records: [
|
||||
{
|
||||
eventSource: 'aws:ses',
|
||||
eventVersion: '1.0',
|
||||
ses: {
|
||||
mail: {
|
||||
timestamp: '2019-08-05T21:30:02.028Z',
|
||||
source: 'prvs=144d0cba7=sender@example.com',
|
||||
messageId: 'EXAMPLE7c191be45-e9aedb9a-02f9-4d12-a87d-dd0099a07f8a-000000',
|
||||
destination: ['recipient@example.com'],
|
||||
headersTruncated: false,
|
||||
headers: [
|
||||
{
|
||||
name: 'Return-Path',
|
||||
value: '<prvs=144d0cba7=sender@example.com>',
|
||||
},
|
||||
{
|
||||
name: 'Received',
|
||||
value: 'REPLACED',
|
||||
},
|
||||
{
|
||||
name: 'X-SES-Spam-Verdict',
|
||||
value: 'PASS',
|
||||
},
|
||||
{
|
||||
name: 'X-SES-Virus-Verdict',
|
||||
value: 'PASS',
|
||||
},
|
||||
{
|
||||
name: 'Received-SPF',
|
||||
value: 'REPLACED',
|
||||
},
|
||||
{
|
||||
name: 'Authentication-Results',
|
||||
value: 'REPLACED',
|
||||
},
|
||||
{
|
||||
name: 'X-SES-RECEIPT',
|
||||
value: 'AEFBQUFBQUFBQUFHbFo0VU81VzVuYmRDNm51nhTVWpabDh6J4V2l5cG5PSHFtNzlBeUk90example',
|
||||
},
|
||||
{
|
||||
name: 'X-SES-DKIM-SIGNATURE',
|
||||
value: 'REPLACED',
|
||||
},
|
||||
{
|
||||
name: 'DKIM-Signature',
|
||||
value: 'REPLACED',
|
||||
},
|
||||
{
|
||||
name: 'Received',
|
||||
value: 'REPLACED',
|
||||
},
|
||||
{
|
||||
name: 'From',
|
||||
value: '"Doe, John" <sender@example.com>',
|
||||
},
|
||||
{
|
||||
name: 'To',
|
||||
value: '"recipient@example.com" <recipient@example.com>',
|
||||
},
|
||||
{
|
||||
name: 'Subject',
|
||||
value: 'This is a test',
|
||||
},
|
||||
{
|
||||
name: 'Thread-Topic',
|
||||
value: 'This is a test',
|
||||
},
|
||||
{
|
||||
name: 'Thread-Index',
|
||||
value: 'AQHVZDAaQ58yKI8q7kaAjkhC5stGexample',
|
||||
},
|
||||
{
|
||||
name: 'Date',
|
||||
value: 'Mon, 5 Aug 2019 21:29:57 +0000',
|
||||
},
|
||||
{
|
||||
name: 'Message-ID',
|
||||
value: '<F8098FDD-49A3-442D-9935-F6112example@example.com>',
|
||||
},
|
||||
{
|
||||
name: 'References',
|
||||
value: '<1FCED16B-F6B0-4506-A6F0-594DFexample@example.com>',
|
||||
},
|
||||
{
|
||||
name: 'In-Reply-To',
|
||||
value: '<1FCED16B-F6B0-4506-A6F0-594DFexample@example.com>',
|
||||
},
|
||||
{
|
||||
name: 'Accept-Language',
|
||||
value: 'en-US',
|
||||
},
|
||||
{
|
||||
name: 'Content-Language',
|
||||
value: 'en-US',
|
||||
},
|
||||
{
|
||||
name: 'X-MS-Has-Attach',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
name: 'X-MS-TNEF-Correlator',
|
||||
value: '',
|
||||
},
|
||||
{
|
||||
name: 'x-ms-exchange-messagesentrepresentingtype',
|
||||
value: '1',
|
||||
},
|
||||
{
|
||||
name: 'x-ms-exchange-transport-fromentityheader',
|
||||
value: 'Hosted',
|
||||
},
|
||||
{
|
||||
name: 'x-originating-ip',
|
||||
value: '[203.0.113.0]',
|
||||
},
|
||||
{
|
||||
name: 'Content-Type',
|
||||
value: 'multipart/alternative; boundary="_000_F8098FDD49A344F6112B195BDAexamplecom_"',
|
||||
},
|
||||
{
|
||||
name: 'MIME-Version',
|
||||
value: '1.0',
|
||||
},
|
||||
{
|
||||
name: 'Precedence',
|
||||
value: 'Bulk',
|
||||
},
|
||||
],
|
||||
commonHeaders: {
|
||||
returnPath: 'prvs=144d0cba7=sender@example.com',
|
||||
from: ['"Doe, John" <sender@example.com>'],
|
||||
date: 'Mon, 5 Aug 2019 21:29:57 +0000',
|
||||
to: ['"recipient@example.com" <recipient@example.com>'],
|
||||
messageId: '<F8098FDD-49A3-442D-9935-F6112B195BDA@example.com>',
|
||||
subject: 'This is a test',
|
||||
},
|
||||
},
|
||||
receipt: {
|
||||
timestamp: '2019-08-05T21:30:02.028Z',
|
||||
processingTimeMillis: 1205,
|
||||
recipients: ['recipient@example.com'],
|
||||
spamVerdict: {
|
||||
status: 'PASS',
|
||||
},
|
||||
virusVerdict: {
|
||||
status: 'PASS',
|
||||
},
|
||||
spfVerdict: {
|
||||
status: 'PASS',
|
||||
},
|
||||
dkimVerdict: {
|
||||
status: 'PASS',
|
||||
},
|
||||
dmarcVerdict: {
|
||||
status: 'GRAY',
|
||||
},
|
||||
action: {
|
||||
type: 'Lambda',
|
||||
functionArn: 'arn:aws:lambda:us-east-1:123456789012:function:IncomingEmail',
|
||||
invocationType: 'Event',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
// From https://docs.aws.amazon.com/ses/latest/DeveloperGuide/receiving-email-action-lambda-example-functions.html
|
||||
|
||||
const handler: SESHandler = (event, context, callback) => {
|
||||
const record: SESEventRecord = event.Records[num];
|
||||
|
||||
callback();
|
||||
callback(new Error());
|
||||
};
|
||||
65
types/aws-lambda/trigger/ses.d.ts
vendored
Normal file
65
types/aws-lambda/trigger/ses.d.ts
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
import { Handler } from '../handler';
|
||||
|
||||
export type SESHandler = Handler<SESEvent, void>;
|
||||
|
||||
// SES event
|
||||
export interface SESMailHeader {
|
||||
name: string;
|
||||
value: string;
|
||||
}
|
||||
|
||||
export interface SESMailCommonHeaders {
|
||||
returnPath: string;
|
||||
from: string[];
|
||||
date: string;
|
||||
to: string[];
|
||||
messageId: string;
|
||||
subject: string;
|
||||
}
|
||||
|
||||
export interface SESMail {
|
||||
timestamp: string;
|
||||
source: string;
|
||||
messageId: string;
|
||||
destination: string[];
|
||||
headersTruncated: boolean;
|
||||
headers: SESMailHeader[];
|
||||
commonHeaders: SESMailCommonHeaders;
|
||||
}
|
||||
|
||||
export interface SESReceiptStatus {
|
||||
status: string;
|
||||
}
|
||||
|
||||
export interface SESReceiptAction {
|
||||
type: string;
|
||||
functionArn: string;
|
||||
invocationType: string;
|
||||
}
|
||||
|
||||
export interface SESReceipt {
|
||||
timestamp: string;
|
||||
processingTimeMillis: number;
|
||||
recipients: string[];
|
||||
spamVerdict: SESReceiptStatus;
|
||||
virusVerdict: SESReceiptStatus;
|
||||
spfVerdict: SESReceiptStatus;
|
||||
dkimVerdict: SESReceiptStatus;
|
||||
dmarcVerdict: SESReceiptStatus;
|
||||
action: SESReceiptAction;
|
||||
}
|
||||
|
||||
export interface SESMessage {
|
||||
mail: SESMail;
|
||||
receipt: SESReceipt;
|
||||
}
|
||||
|
||||
export interface SESEventRecord {
|
||||
eventSource: string;
|
||||
eventVersion: string;
|
||||
ses: SESMessage;
|
||||
}
|
||||
|
||||
export interface SESEvent {
|
||||
Records: SESEventRecord[];
|
||||
}
|
||||
@ -33,6 +33,7 @@
|
||||
"test/kinesis-tests.ts",
|
||||
"test/lex-tests.ts",
|
||||
"test/s3-tests.ts",
|
||||
"test/ses-tests.ts",
|
||||
"test/sns-tests.ts",
|
||||
"test/sqs-tests.ts"
|
||||
]
|
||||
|
||||
Loading…
Reference in New Issue
Block a user