UNPKG

1.31 kBTypeScriptView Raw
1import { EventFired, HandleEvent } from "./HandleEvent";
2import { HandlerContext } from "./HandlerContext";
3import { HandlerResult } from "./HandlerResult";
4import { EventHandlerMetadata } from "./metadata/automationMetadata";
5import { Maker } from "./util/constructionUtils";
6/**
7 * Handle the given event.
8 * @param e event we're matching on
9 * @param {HandlerContext} ctx context from which GraphQL client can be obtained if it's
10 * necessary to run further queries.
11 * @param params secrets and mapped parameters are available through this
12 * @return {Promise<HandlerResult>} result containing status and any command-specific data
13 */
14export declare type OnEvent<T = any, P = any> = (e: EventFired<T>, ctx: HandlerContext, params: P) => Promise<HandlerResult>;
15/**
16 * Create a HandleEvent instance with the appropriate metadata wrapping
17 * the given function
18 * @param {OnEvent<T, P>} h
19 * @param {Maker<P>} factory
20 * @param {string} subscription
21 * @param {string} name
22 * @param {string} description
23 * @param {string | string[]} tags
24 * @returns {HandleEvent<T, P> & EventHandlerMetadata}
25 */
26export declare function eventHandlerFrom<T, P>(h: OnEvent<T, P>, factory: Maker<P>, subscription: string, name?: string, description?: string, tags?: string | string[]): HandleEvent<T, P> & EventHandlerMetadata;