-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
41 changed files
with
2,878 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/** | ||
* Copyright 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* This module defines types, enums and interfaces common to the other modules. | ||
*/ | ||
/// <reference types="node" /> | ||
import { IncomingHttpHeaders } from "http"; | ||
export interface InvocationResponse { | ||
bodyJson: string; | ||
headers: IncomingHttpHeaders; | ||
} | ||
export interface NativeClient { | ||
initializeClient: (userAgent: string) => void; | ||
done: (id: string, bodyString: string) => void; | ||
error: (id: string, bodyString: string, xrayString: string) => void; | ||
next: () => Promise<InvocationResponse>; | ||
} | ||
export declare enum INVOKE_HEADER { | ||
ClientContext = "lambda-runtime-client-context", | ||
CognitoIdentity = "lambda-runtime-cognito-identity", | ||
ARN = "lambda-runtime-invoked-function-arn", | ||
AWSRequestId = "lambda-runtime-aws-request-id", | ||
DeadlineMs = "lambda-runtime-deadline-ms", | ||
XRayTrace = "lambda-runtime-trace-id" | ||
} | ||
export interface IEnvironmentData { | ||
functionVersion?: string; | ||
functionName?: string; | ||
memoryLimitInMB?: string; | ||
logGroupName?: string; | ||
logStreamName?: string; | ||
} | ||
export interface IHeaderData { | ||
clientContext?: string; | ||
identity?: string; | ||
invokedFunctionArn?: string; | ||
awsRequestId?: string; | ||
getRemainingTimeInMillis: () => number; | ||
} | ||
export declare type ErrorStringOrUndefined = Error | string | undefined; | ||
export declare type ErrorStringOrUndefinedOrNull = ErrorStringOrUndefined | null; | ||
/** | ||
* | ||
*/ | ||
export interface ICallbackContext { | ||
callbackWaitsForEmptyEventLoop: boolean; | ||
succeed: (result: unknown) => void; | ||
fail: (err: ErrorStringOrUndefinedOrNull) => void; | ||
done: (err: ErrorStringOrUndefinedOrNull, result?: unknown) => void; | ||
} | ||
export declare type CallbackFunction = (err: ErrorStringOrUndefinedOrNull, result?: unknown) => void; | ||
export interface IBeforeExitListener { | ||
invoke: () => void; | ||
reset: () => () => void; | ||
set: (listener: () => void) => () => void; | ||
} | ||
export interface IErrorCallbacks { | ||
uncaughtException: (err: Error) => void; | ||
unhandledRejection: (err: Error) => void; | ||
} | ||
export declare type HandlerFunction = (body: unknown, data: IEnvironmentData & IHeaderData, callback: CallbackFunction) => PromiseLike<unknown> | unknown; | ||
//# sourceMappingURL=index.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. */ | ||
/** | ||
* prepare an exception blob for sending to AWS X-Ray | ||
* transform an Error, or Error-like, into an exception parseable by X-Ray's service. | ||
* { | ||
* "name": "CustomException", | ||
* "message": "Something bad happend!", | ||
* "stack": [ | ||
* "exports.handler (/var/function/node_modules/event_invoke.js:3:502) | ||
* ] | ||
* } | ||
* => | ||
* { | ||
* "working_directory": "/var/function", | ||
* "exceptions": [ | ||
* { | ||
* "type": "CustomException", | ||
* "message": "Something bad happend!", | ||
* "stack": [ | ||
* { | ||
* "path": "/var/function/event_invoke.js", | ||
* "line": 502, | ||
* "label": "exports.throw_custom_exception" | ||
* } | ||
* ] | ||
* } | ||
* ], | ||
* "paths": [ | ||
* "/var/function/event_invoke.js" | ||
* ] | ||
* } | ||
*/ | ||
export declare const toFormatted: (err: unknown) => string; | ||
//# sourceMappingURL=XRayError.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* | ||
* Defines custom error types throwable by the runtime. | ||
*/ | ||
export declare function isError(obj: any): obj is Error; | ||
interface RuntimeErrorResponse { | ||
errorType: string; | ||
errorMessage: string; | ||
trace: string[]; | ||
} | ||
/** | ||
* Attempt to convert an object into a response object. | ||
* This method accounts for failures when serializing the error object. | ||
*/ | ||
export declare function toRuntimeResponse(error: unknown): RuntimeErrorResponse; | ||
/** | ||
* Format an error with the expected properties. | ||
* For compatability, the error string always starts with a tab. | ||
*/ | ||
export declare const toFormatted: (error: unknown) => string; | ||
export declare class ExtendedError extends Error { | ||
code?: number; | ||
custom?: string; | ||
reason?: string; | ||
promise?: Promise<any>; | ||
constructor(reason?: string); | ||
} | ||
export declare class ImportModuleError extends ExtendedError { | ||
} | ||
export declare class HandlerNotFound extends ExtendedError { | ||
} | ||
export declare class MalformedHandlerName extends ExtendedError { | ||
} | ||
export declare class UserCodeSyntaxError extends ExtendedError { | ||
} | ||
export declare class UnhandledPromiseRejection extends ExtendedError { | ||
constructor(reason?: string, promise?: Promise<any>); | ||
} | ||
export {}; | ||
//# sourceMappingURL=index.d.ts.map |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.