Improved aws-lambda type definitions

This commit is contained in:
Vasiliy Solovey
2016-08-19 12:21:44 +03:00
parent 57ec5fbb76
commit a94c941c50
2 changed files with 31 additions and 2 deletions

View File

@@ -9,6 +9,8 @@ var kinesis: lambda.Kinesis;
var recordsList: lambda.Record[];
var anyObj: any;
var num: number;
var identity: lambda.Identity;
var error: Error;
/* Records */
var records: lambda.Records;
@@ -46,4 +48,19 @@ context.succeed(str);
context.succeed(anyObj);
context.succeed(str, anyObj);
str = context.awsRequestId;
num = context.getRemainingTimeInMillis();
num = context.getRemainingTimeInMillis();
identity = context.identity;
/* Identity */
var identity: lambda.Identity;
str = identity.cognitoIdentityId;
str = identity.cognitoIdentityPoolId;
/* Callback */
function callback(cb: lambda.Callback) {
cb();
cb(null);
cb(error);
cb(null, anyObj);
}

View File

@@ -36,8 +36,20 @@ declare module "aws-lambda" {
succeed(message: string, object: any): void;
awsRequestId: string;
getRemainingTimeInMillis(): number;
/** Information about the Amazon Cognito identity provider when invoked through the AWS Mobile SDK. It can be null. */
identity?: Identity;
}
interface Identity {
cognitoIdentityId: string;
cognitoIdentityPoolId: string;
}
export type Callback = (error?: Error, message?: string) => void;
/**
* Optional callback parameter.
*
* @param error an optional parameter that you can use to provide results of the failed Lambda function execution.
* @param result an optional parameter that you can use to provide the result of a successful function execution. The result provided must be JSON.stringify compatible.
*/
export type Callback = (error?: Error, result?: any) => void;
}