1 | /**
|
2 | * Result of a handler. Can be extended to include further,
|
3 | * command-specific, data
|
4 | */
|
5 | export interface HandlerResult {
|
6 | /**
|
7 | * 0 is success
|
8 | */
|
9 | code: number;
|
10 | /**
|
11 | * The simple text message describing the result
|
12 | */
|
13 | message?: string;
|
14 | }
|
15 | /**
|
16 | * The result of a command invocation returns a redirect URL that can be
|
17 | * presented to the invoker of the command in different ways: eg. HTTP redirect
|
18 | * or a slack message with the link.
|
19 | */
|
20 | export interface RedirectResult extends HandlerResult {
|
21 | /**
|
22 | * The redirect url
|
23 | */
|
24 | redirect: string;
|
25 | }
|
26 | /**
|
27 | * Handler result for failing handler.
|
28 | */
|
29 | export interface HandlerError extends HandlerResult {
|
30 | /**
|
31 | * The stack trace of the error
|
32 | */
|
33 | stack?: any;
|
34 | }
|
35 | /**
|
36 | * Default success result.
|
37 | */
|
38 | export declare const Success: HandlerResult;
|
39 | /**
|
40 | * Default success result wrapped in a promise.
|
41 | */
|
42 | export declare const SuccessPromise: Promise<HandlerResult>;
|
43 | /**
|
44 | * Default failure result.
|
45 | */
|
46 | export declare const Failure: HandlerResult;
|
47 | /**
|
48 | * Default failure result wrapped in a promise.
|
49 | */
|
50 | export declare const FailurePromise: Promise<HandlerResult>;
|
51 | /**
|
52 | * Function that returns a handler failure result.
|
53 | */
|
54 | export declare function failure(err: Error): HandlerError;
|
55 | /**
|
56 | * Function that returns a handler success result.
|
57 | */
|
58 | export declare function success(): HandlerResult;
|
59 | /**
|
60 | * Combine an array of HandlerResults into a single HandlerResult.
|
61 | * Each HandlerResult.code is summed into the final, single value and
|
62 | * messages are concatenated, separated by a semicolon (;). Useful to
|
63 | * combine the return value from calling Promise.all on the array of
|
64 | * events sent to an event handler.
|
65 | *
|
66 | * @param results array of HandlerResults
|
67 | * @return single, combined result
|
68 | */
|
69 | export declare function reduceResults(results: HandlerResult[]): HandlerResult;
|
70 | //# sourceMappingURL=HandlerResult.d.ts.map |
\ | No newline at end of file |