UNPKG

serverless-aws-lambda

Version:

AWS Application Load Balancer and API Gateway - Lambda dev tool for Serverless. Allows Express synthax in handlers. Supports packaging, local invoking and offline ALB, APG, S3, SNS, SQS, DynamoDB Stream server mocking.

123 lines (122 loc) 3.91 kB
import type { ServerResponse } from "http"; import type { ISnsEvent } from "../parseEvents/sns"; import type { IS3Event } from "../parseEvents/s3"; import type { ISqs } from "../parseEvents/sqs"; import type { IDdbEvent } from "../parseEvents/ddbStream"; import type { IDestination } from "../parseEvents/index"; import type { LambdaEndpoint } from "../parseEvents/endpoints"; import type { IKinesisEvent } from "../parseEvents/kinesis"; import type { IDocumentDbEvent } from "../parseEvents/documentDb"; import type { Runner } from "./runners/index"; type InvokeSub = (event: any, info?: any) => void | { [key: string]: any; }; type InvokeSuccessSub = (input: any, output: any, info?: any) => void; type InvokeErrorSub = InvokeSuccessSub; export interface ILambdaMock { /** * Function name declared in serverless.yml. */ name: string; /** * Function name which will be published as in AWS. */ outName: string; /** * Deploy Lambda or not to AWS. */ online: boolean | string | string[]; runtime: string; /** * API Gateway and Application Load balancer events. */ endpoints: LambdaEndpoint[]; s3: IS3Event[]; sns: ISnsEvent[]; ddb: IDdbEvent[]; sqs: ISqs[]; kinesis: IKinesisEvent[]; documentDb: IDocumentDbEvent[]; url?: LambdaEndpoint; timeout: number; memorySize: number; environment: { [key: string]: any; }; /** * function handler as declared in serverless.yml. */ handlerPath: string; /** * exported function name */ handlerName: string; /** * esbuild entry point absolute path. */ esEntryPoint: string; /** * bundle absolute path. */ esOutputPath: string; /** * resolved entry point. */ entryPoint: string; invokeSub: InvokeSub[]; invokeSuccessSub: InvokeSuccessSub[]; invokeErrorSub: InvokeErrorSub[]; /** * Invoke this lambda. * * must always be called with "await" or ".then()" * @returns {Promise} * @throws Error */ invoke: (event: any, info?: any, clientContext?: any) => Promise<any>; onError?: IDestination; onSuccess?: IDestination; onFailure?: IDestination; runner: Runner; } export declare class LambdaMock implements ILambdaMock { #private; name: string; outName: string; online: boolean | string | string[]; endpoints: LambdaEndpoint[]; runtime: string; s3: IS3Event[]; sns: ISnsEvent[]; sqs: ISqs[]; ddb: IDdbEvent[]; kinesis: IKinesisEvent[]; documentDb: IDocumentDbEvent[]; url?: LambdaEndpoint; timeout: number; memorySize: number; environment: { [key: string]: any; }; handlerPath: string; handlerName: string; esEntryPoint: string; esOutputPath: string; entryPoint: string; onError?: IDestination; onSuccess?: IDestination; onFailure?: IDestination; invokeSub: InvokeSub[]; invokeSuccessSub: InvokeSuccessSub[]; invokeErrorSub: InvokeErrorSub[]; runner: Runner; static ENABLE_TIMEOUT: boolean; constructor({ name, outName, online, endpoints, runtime, timeout, memorySize, environment, handlerPath, handlerName, esEntryPoint, esOutputPath, entryPoint, s3, sns, sqs, ddb, kinesis, url, documentDb, invokeSub, invokeSuccessSub, invokeErrorSub, onError, onSuccess, onFailure, runner, }: ILambdaMock & { runner: Runner; }); handleErrorDestination(event: any, info: any, error: any, awsRequestId: string): void; handleSuccessDestination(event: any, info: any, response: any, awsRequestId: string): void; invoke(event: any, info?: any, clientContext?: any, response?: ServerResponse): Promise<unknown>; clear: () => void; } export type { ISnsEvent, IS3Event, ISqs, IDdbEvent, IDestination, LambdaEndpoint, IDocumentDbEvent, IKinesisEvent };