diff --git a/types/aws-lambda-mock-context/aws-lambda-mock-context-tests.ts b/types/aws-lambda-mock-context/aws-lambda-mock-context-tests.ts new file mode 100644 index 0000000000..f6bcfad5bc --- /dev/null +++ b/types/aws-lambda-mock-context/aws-lambda-mock-context-tests.ts @@ -0,0 +1,22 @@ +import { context } from "aws-lambda-mock-context"; +import * as Alexa from "alexa-sdk"; + +const launchRequestJson: any = { + request: { + locale: "en-US", + requestId: "amzn1.echo-api.request.[unique-value-here]", + timestamp: "2016-10-27T18:21:44Z", + type: "LaunchRequest", + }, + session: { + application: {applicationId: "amzn1.ask.skill.[unique-value-here]"}, + attributes: {}, + new: false, + sessionId: "amzn1.echo-api.session.[unique-value-here]", + user: {userId: "amzn1.ask.account.[unique-value-here]"}, + }, + version: "1.0", +}; + +const ctx = context(); +const alexa = Alexa.handler(launchRequestJson, ctx); diff --git a/types/aws-lambda-mock-context/index.d.ts b/types/aws-lambda-mock-context/index.d.ts new file mode 100644 index 0000000000..250dc9b681 --- /dev/null +++ b/types/aws-lambda-mock-context/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for AWS Lambda Mock Context SDK 1.0 +// Project: https://github.com/moskalyk/typed-aws-lambda-mock-context +// Definitions by: Morgan Moskalyk , Anand Nimkar +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function context(options?: Options): Context; + +interface Context { + Promise: Promise; + callbackWaitsForEmptyEventLoop: boolean; + functionName: string; + functionVersion: string; + invokedFunctionArn: string; + memoryLimitInMB: string; + awsRequestId: string; + invokeid: string; + logGroupName: string; + logStreamName: string; + getRemainingTimeInMillis: number; + succeed(result: any): Promise; + fail(err: any): Promise; + done(err: any, result: any): Promise; +} + +interface Options { + region: string; + account: string; + functionName: string; + functionVersion: string; + memoryLimitInMB: string; + alias?: string; +} + +export { context }; \ No newline at end of file diff --git a/types/aws-lambda-mock-context/tsconfig.json b/types/aws-lambda-mock-context/tsconfig.json new file mode 100644 index 0000000000..bdfad87be5 --- /dev/null +++ b/types/aws-lambda-mock-context/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "aws-lambda-mock-context-tests.ts" + ] +} \ No newline at end of file diff --git a/types/aws-lambda-mock-context/tslint.json b/types/aws-lambda-mock-context/tslint.json new file mode 100644 index 0000000000..192203ab54 --- /dev/null +++ b/types/aws-lambda-mock-context/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "../tslint.json" +} \ No newline at end of file