mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
Added SNS Message event and allow boolean/number vaues in Proxy Lambda header response (#14858)
This commit is contained in:
parent
62fdb1966e
commit
565751df4d
@ -11,6 +11,12 @@ var clientContextClient: AWSLambda.ClientContextClient;
|
||||
var context: AWSLambda.Context;
|
||||
var identity: AWSLambda.CognitoIdentity;
|
||||
var proxyResult: AWSLambda.ProxyResult;
|
||||
var snsEvt: AWSLambda.SNSEvent;
|
||||
var snsEvtRecs: Array<AWSLambda.SNSEventRecord>;
|
||||
var snsEvtRec: AWSLambda.SNSEventRecord;
|
||||
var snsMsg: AWSLambda.SNSMessage;
|
||||
var snsMsgAttr: AWSLambda.SNSMessageAttribute;
|
||||
var snsMsgAttrs: AWSLambda.SNSMessageAttributes;
|
||||
|
||||
/* API Gateway Event */
|
||||
str = apiGwEvt.body;
|
||||
@ -42,9 +48,36 @@ str = apiGwEvt.requestContext.resourceId;
|
||||
str = apiGwEvt.requestContext.resourcePath;
|
||||
str = apiGwEvt.resource;
|
||||
|
||||
/* SNS Event */
|
||||
snsEvtRecs = snsEvt.Records;
|
||||
|
||||
str = snsEvtRec.EventSource;
|
||||
str = snsEvtRec.EventSubscriptionArn;
|
||||
str = snsEvtRec.EventVersion;
|
||||
snsMsg = snsEvtRec.Sns;
|
||||
|
||||
str = snsMsg.SignatureVersion;
|
||||
str = snsMsg.Timestamp;
|
||||
str = snsMsg.Signature;
|
||||
str = snsMsg.SigningCertUrl;
|
||||
str = snsMsg.MessageId;
|
||||
str = snsMsg.Message;
|
||||
snsMsgAttrs = snsMsg.MessageAttributes;
|
||||
str = snsMsg.Type;
|
||||
str = snsMsg.UnsubscribeUrl;
|
||||
str = snsMsg.TopicArn;
|
||||
str = snsMsg.Subject;
|
||||
|
||||
snsMsgAttrs["example"] = snsMsgAttr;
|
||||
|
||||
str = snsMsgAttr.Type;
|
||||
str = snsMsgAttr.Value;
|
||||
|
||||
/* Lambda Proxy Result */
|
||||
num = proxyResult.statusCode;
|
||||
str = proxyResult.headers["example"];
|
||||
proxyResult.headers["example"] = str;
|
||||
proxyResult.headers["example"] = b;
|
||||
proxyResult.headers["example"] = num;
|
||||
str = proxyResult.body
|
||||
|
||||
/* Context */
|
||||
|
||||
41
aws-lambda/index.d.ts
vendored
41
aws-lambda/index.d.ts
vendored
@ -39,6 +39,41 @@ interface APIGatewayEvent {
|
||||
resource: string;
|
||||
}
|
||||
|
||||
// SNS "event"
|
||||
interface SNSMessageAttribute {
|
||||
Type: string;
|
||||
Value: string;
|
||||
}
|
||||
|
||||
interface SNSMessageAttributes {
|
||||
[name: string]: SNSMessageAttribute;
|
||||
}
|
||||
|
||||
interface SNSMessage {
|
||||
SignatureVersion: string;
|
||||
Timestamp: string;
|
||||
Signature: string;
|
||||
SigningCertUrl: string;
|
||||
MessageId: string;
|
||||
Message: string;
|
||||
MessageAttributes: SNSMessageAttributes;
|
||||
Type: string;
|
||||
UnsubscribeUrl: string;
|
||||
TopicArn: string;
|
||||
Subject: string;
|
||||
}
|
||||
|
||||
interface SNSEventRecord {
|
||||
EventVersion: string;
|
||||
EventSubscriptionArn: string;
|
||||
EventSource: string;
|
||||
Sns: SNSMessage;
|
||||
}
|
||||
|
||||
interface SNSEvent {
|
||||
Records: Array<SNSEventRecord>;
|
||||
}
|
||||
|
||||
// Context
|
||||
// http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html
|
||||
interface Context {
|
||||
@ -97,7 +132,7 @@ interface ClientContextEnv {
|
||||
interface ProxyResult {
|
||||
statusCode: number;
|
||||
headers?: {
|
||||
[header: string]: string;
|
||||
[header: string]: boolean | number | string;
|
||||
},
|
||||
body: string;
|
||||
}
|
||||
@ -110,8 +145,8 @@ interface ProxyResult {
|
||||
* @param context – runtime information of the Lambda function that is executing.
|
||||
* @param callback – optional callback to return information to the caller, otherwise return value is null.
|
||||
*/
|
||||
export type Handler = (event: any, context: Context, callback?: Callback) => void;
|
||||
export type ProxyHandler = (event: APIGatewayEvent, context: Context, callback?: ProxyCallback) => void;
|
||||
export type Handler = (event: any, context: Context, callback?: Callback) => void;
|
||||
export type ProxyHandler = (event: APIGatewayEvent, context: Context, callback?: ProxyCallback) => void;
|
||||
|
||||
/**
|
||||
* Optional callback parameter.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user