UNPKG

1.71 kBTypeScriptView Raw
1import { Configuration } from "./configuration";
2import { Contextual } from "./internal/invoker/Payload";
3import { CommandIncoming, EventIncoming } from "./internal/transport/RequestProcessor";
4import { AutomationContext } from "./internal/util/cls";
5import { GraphClient } from "./spi/graph/GraphClient";
6import { MessageClient, SlackMessageClient } from "./spi/message/MessageClient";
7/**
8 * Context available to all handlers
9 */
10export interface HandlerContext extends Contextual {
11 /**
12 * Client to use for GraphQL queries
13 */
14 graphClient?: GraphClient;
15 /**
16 * Client to send messages
17 */
18 messageClient: MessageClient & SlackMessageClient;
19 /**
20 * Provides access to the lifecycle of a handler and context
21 */
22 lifecycle?: HandlerLifecycle;
23}
24/**
25 * Context of the currently running automation
26 */
27export interface AutomationContextAware {
28 context: AutomationContext;
29 trigger: CommandIncoming | EventIncoming;
30}
31/**
32 * Access to the currently running automation client configuration
33 */
34export interface ConfigurationAware {
35 configuration: Configuration;
36}
37/**
38 * Lifecycle of the handler and its context
39 */
40export interface HandlerLifecycle {
41 /**
42 * Register a callback that should be invoked when this context gets disposed
43 * @param {() => Promise<void>} callback
44 * @param {string} description
45 */
46 registerDisposable(callback: () => Promise<void>, description?: string): void;
47 /**
48 * Disposes the HandlerContext.
49 * Before disposing the context, this will invoke all registered disposables
50 * @returns {Promise<any>}
51 */
52 dispose(): Promise<void>;
53}
54//# sourceMappingURL=HandlerContext.d.ts.map
\No newline at end of file