From 90c2247f74fd16e2d03d8ebe4dd3dabc16298b1d Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Tue, 6 Sep 2016 14:11:58 +0000 Subject: [PATCH] Updated aws-lambda (#10966) * Updated aws-lambda Fixed issue #10956 * Bring back old functions for Node.js Runtime v0.10.42 Bring back old functions for Node.js Runtime v0.10.42 --- aws-lambda/aws-lambda-tests.ts | 52 ++++++--------------- aws-lambda/aws-lambda.d.ts | 83 ++++++++++++++++++++-------------- 2 files changed, 61 insertions(+), 74 deletions(-) diff --git a/aws-lambda/aws-lambda-tests.ts b/aws-lambda/aws-lambda-tests.ts index 8b9f53a8ab..f562b59d3d 100644 --- a/aws-lambda/aws-lambda-tests.ts +++ b/aws-lambda/aws-lambda-tests.ts @@ -4,55 +4,29 @@ import lambda = require('aws-lambda'); var str: string; var date: Date; -var sns: lambda.SNS; -var kinesis: lambda.Kinesis; -var recordsList: lambda.Record[]; var anyObj: any; var num: number; -var identity: lambda.Identity; +var identity: lambda.CognitoIdentity; var error: Error; - -/* Records */ -var records: lambda.Records; - -recordsList = records.Records; - -/* Record */ -var record: lambda.Record; - -str = record.EventVersion; -str = record.EventSubscriptionArn; -str = record.EnventSource; -sns = record.Sns; -kinesis = record.kinesis; - -/* SNS */ -str = sns.Type; -str = sns.MessageId; -str = sns.TopicArn; -str = sns.Subject; -str = sns.Message; -date = sns.Timestamp; - -/* Kinesis */ -var kinesis: lambda.Kinesis; - -str = kinesis.data; +var b: boolean; +var clientCtx: lambda.ClientContext; /* Context */ var context: lambda.Context; -context.log(str, anyObj); -context.fail(str); -context.succeed(str); -context.succeed(anyObj); -context.succeed(str, anyObj); +b = context.callbackWaitsForEmptyEventLoop; +str = context.functionName; +str = context.functionVersion; +str = context.invokedFunctionArn; +num = context.memoryLimitInMB; str = context.awsRequestId; -num = context.getRemainingTimeInMillis(); +str = context.logGroupName; +str = context.logStreamName; identity = context.identity; +clientCtx = context.clientContext; -/* Identity */ -var identity: lambda.Identity; +/* CognitoIdentity */ +var identity: lambda.CognitoIdentity; str = identity.cognitoIdentityId; str = identity.cognitoIdentityPoolId; diff --git a/aws-lambda/aws-lambda.d.ts b/aws-lambda/aws-lambda.d.ts index 081c6e0e3e..c9a66a3783 100644 --- a/aws-lambda/aws-lambda.d.ts +++ b/aws-lambda/aws-lambda.d.ts @@ -1,55 +1,68 @@ // Type definitions for AWS Lambda // Project: http://docs.aws.amazon.com/lambda -// Definitions by: Michael Skarum +// Definitions by: James Darbyshire , Michael Skarum , Stef Heyenrath // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped declare module "aws-lambda" { + // Context + // http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-context.html + interface Context { + // Properties + callbackWaitsForEmptyEventLoop: boolean; + functionName: string; + functionVersion: string; + invokedFunctionArn: string; + memoryLimitInMB: number; + awsRequestId: string; + logGroupName: string; + logStreamName: string; + identity?: CognitoIdentity; + clientContext?: ClientContext; + + // Functions + getRemainingTimeInMillis(): number; - export interface Records { - Records: Record[]; - } - interface Record { - EventVersion: string; - EventSubscriptionArn: string; - EnventSource: string; - Sns: SNS; - kinesis: Kinesis; - } - interface SNS { - Type: string; - MessageId: string; - TopicArn: string; - Subject: string; - Message: string; - Timestamp: Date; - } - - interface Kinesis { - data: string; - } - - export interface Context { + // Functions for compatibility with earlier Node.js Runtime v0.10.42 log(message: string, object: any): void; fail(message: string): void; succeed(message: string): void; succeed(object: any): void; - 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; + succeed(message: string, object: any): void; } - - interface Identity { + + interface CognitoIdentity { cognitoIdentityId: string; cognitoIdentityPoolId: string; } - + + interface ClientContext { + client: ClientContextClient; + Custom?: any; + env: ClientContextEnv; + } + + interface ClientContextClient { + installationId: string; + appTitle: string; + appVersionName: string; + appVersionCode: string; + appPackageName: string; + } + + interface ClientContextEnv { + platformVersion: string; + platform: string; + make: string; + model: string; + locale: string; + } + /** * Optional callback parameter. + * http://docs.aws.amazon.com/lambda/latest/dg/nodejs-prog-model-handler.html * - * @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. + * @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; } \ No newline at end of file