lambda-live-debugger
Version:
Debug Lambda functions locally like it is running in the cloud
62 lines (61 loc) • 1.46 kB
TypeScript
import type { AwsCredentialIdentityProvider } from '@smithy/types';
type IoTMessageBase = {
workerId: string;
requestId: string;
functionId: string;
};
export type FuctionRequest = {
deadline: number;
event: any;
context: any;
env: {
[key: string]: string | undefined;
};
} & IoTMessageBase;
export type FunctionResponse = {
body: any;
} & IoTMessageBase;
export type FunctionErrorResponse = {
errorType: string;
errorMessage: string;
trace?: string;
} & IoTMessageBase;
export type FunctionPing = IoTMessageBase;
/**
* IoT Message that is exchanged between the Lambda and local worker
*/
export type IoTMessage = {
type: 'INVOKE';
data: FuctionRequest;
} | {
type: 'SUCCESS';
data: FunctionResponse;
} | {
type: 'ERROR';
data: FunctionErrorResponse;
} | {
type: 'PING';
data: FunctionPing;
};
export type IoTMessageTypes = IoTMessage['type'];
/**
* IoT Service Connection with an method to publish messages
*/
export type IoTServiceConnection = {
publish: (payload: IoTMessage, topic: string) => Promise<void>;
};
/**
* Connect to IoT
* @param props
* @returns
*/
declare function connect(props?: {
onMessage?: (message: IoTMessage) => void;
topic?: string;
region?: string;
credentialsProvider?: AwsCredentialIdentityProvider;
}): Promise<IoTServiceConnection>;
export declare const IoTService: {
connect: typeof connect;
};
export {};