@atomist/automation-client
Version:
Atomist API for software low-level client
70 lines • 1.91 kB
TypeScript
/**
* Result of a handler. Can be extended to include further,
* command-specific, data
*/
export interface HandlerResult {
/**
* 0 is success
*/
code: number;
/**
* The simple text message describing the result
*/
message?: string;
}
/**
* The result of a command invocation returns a redirect URL that can be
* presented to the invoker of the command in different ways: eg. HTTP redirect
* or a slack message with the link.
*/
export interface RedirectResult extends HandlerResult {
/**
* The redirect url
*/
redirect: string;
}
/**
* Handler result for failing handler.
*/
export interface HandlerError extends HandlerResult {
/**
* The stack trace of the error
*/
stack?: any;
}
/**
* Default success result.
*/
export declare const Success: HandlerResult;
/**
* Default success result wrapped in a promise.
*/
export declare const SuccessPromise: Promise<HandlerResult>;
/**
* Default failure result.
*/
export declare const Failure: HandlerResult;
/**
* Default failure result wrapped in a promise.
*/
export declare const FailurePromise: Promise<HandlerResult>;
/**
* Function that returns a handler failure result.
*/
export declare function failure(err: Error): HandlerError;
/**
* Function that returns a handler success result.
*/
export declare function success(): HandlerResult;
/**
* Combine an array of HandlerResults into a single HandlerResult.
* Each HandlerResult.code is summed into the final, single value and
* messages are concatenated, separated by a semicolon (;). Useful to
* combine the return value from calling Promise.all on the array of
* events sent to an event handler.
*
* @param results array of HandlerResults
* @return single, combined result
*/
export declare function reduceResults(results: HandlerResult[]): HandlerResult;
//# sourceMappingURL=HandlerResult.d.ts.map