1 | import { SlackMessage } from "@atomist/slack-messages";
|
2 | import { Action as SlackAction } from "@atomist/slack-messages/lib/SlackMessages";
|
3 | import { GraphQLClient } from "./graphql";
|
4 | import { CommandContext, EventContext, HandlerStatus } from "./handler";
|
5 | import { CommandIncoming, EventIncoming, Skill, Source } from "./payload";
|
6 | export interface Destinations {
|
7 | users: string | string[];
|
8 | channels: string | string[];
|
9 | }
|
10 | export interface MessageClient {
|
11 | send(msg: any, destinations: Destinations, options?: MessageOptions): Promise<any>;
|
12 | delete?(destinations: Destinations, options: RequiredMessageOptions): Promise<void>;
|
13 | }
|
14 | export interface CommandMessageClient extends MessageClient {
|
15 | respond(msg: any, options?: MessageOptions): Promise<any>;
|
16 | }
|
17 | export declare type RequiredMessageOptions = Pick<MessageOptions, "id" | "thread"> & {
|
18 | id: string;
|
19 | };
|
20 |
|
21 |
|
22 |
|
23 | export interface MessageOptions extends Record<string, any> {
|
24 | |
25 |
|
26 |
|
27 |
|
28 | id?: string;
|
29 | |
30 |
|
31 |
|
32 |
|
33 |
|
34 | ttl?: number;
|
35 | |
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 | ts?: number;
|
43 | |
44 |
|
45 |
|
46 |
|
47 | post?: "update_only" | "always";
|
48 | |
49 |
|
50 |
|
51 |
|
52 | thread?: string | boolean;
|
53 | }
|
54 |
|
55 | export declare const MessageMimeTypes: {
|
56 | SLACK_JSON: string;
|
57 | SLACK_FILE_JSON: string;
|
58 | PLAIN_TEXT: string;
|
59 | APPLICATION_JSON: string;
|
60 | };
|
61 | export declare abstract class MessageClientSupport implements MessageClient, CommandMessageClient {
|
62 | respond(msg: any, options?: MessageOptions): Promise<any>;
|
63 | send(msg: any, destinations: Destinations, options?: MessageOptions): Promise<any>;
|
64 | abstract delete(destinations: Destinations, options: RequiredMessageOptions): Promise<void>;
|
65 | protected abstract doSend(msg: any, destinations: Destinations, options?: MessageOptions): Promise<any>;
|
66 | }
|
67 | export declare abstract class AbstractMessageClient extends MessageClientSupport {
|
68 | protected readonly request: CommandIncoming | EventIncoming;
|
69 | protected readonly correlationId: string;
|
70 | protected readonly team: {
|
71 | id: string;
|
72 | name?: string;
|
73 | };
|
74 | protected readonly source: Source;
|
75 | protected readonly graphClient: GraphQLClient;
|
76 | constructor(request: CommandIncoming | EventIncoming, correlationId: string, team: {
|
77 | id: string;
|
78 | name?: string;
|
79 | }, source: Source, graphClient: GraphQLClient);
|
80 | delete(destinations: Destinations, options: RequiredMessageOptions): Promise<void>;
|
81 | protected doSend(msg: any, destinations: Destinations, options?: MessageOptions): Promise<any>;
|
82 | protected abstract sendResponse(response: any): Promise<void>;
|
83 | private ts;
|
84 | private getTeamId;
|
85 | }
|
86 | export interface CommandReferencingAction extends SlackAction {
|
87 | command: CommandReference;
|
88 | }
|
89 |
|
90 |
|
91 |
|
92 |
|
93 | export interface CommandReference {
|
94 | |
95 |
|
96 |
|
97 | id: string;
|
98 | |
99 |
|
100 |
|
101 |
|
102 | name: string;
|
103 | |
104 |
|
105 |
|
106 | parameters?: {
|
107 | [key: string]: any;
|
108 | };
|
109 | |
110 |
|
111 |
|
112 |
|
113 | parameterName?: string;
|
114 | }
|
115 | export declare function mapActions(msg: SlackMessage): Action[];
|
116 | export interface HandlerResponse {
|
117 | api_version: "1";
|
118 | correlation_id: any;
|
119 | team: {
|
120 | id: string;
|
121 | name?: string;
|
122 | };
|
123 | command?: string;
|
124 | event?: string;
|
125 | status?: {
|
126 | visibility?: "hidden";
|
127 | code?: number;
|
128 | reason: string;
|
129 | };
|
130 | source?: Source;
|
131 | destinations?: any[];
|
132 | content_type?: string;
|
133 | body?: string;
|
134 | id?: string;
|
135 | timestamp?: number;
|
136 | ttl?: number;
|
137 | post_mode?: "ttl" | "always" | "update_only";
|
138 | actions?: Action[];
|
139 | skill: Skill;
|
140 | }
|
141 | export interface Action {
|
142 | id: string;
|
143 | parameter_name?: string;
|
144 | command: string;
|
145 | parameters: Parameter[];
|
146 | }
|
147 | export interface Parameter {
|
148 | name: string;
|
149 | value: string;
|
150 | }
|
151 | export declare function isSlackMessage(object: any): object is SlackMessage;
|
152 |
|
153 |
|
154 |
|
155 | export interface SlackFileMessage {
|
156 | content: string;
|
157 | title?: string;
|
158 | fileName?: string;
|
159 | fileType?: string;
|
160 | comment?: string;
|
161 | }
|
162 | export declare function isFileMessage(object: any): object is SlackFileMessage;
|
163 | export interface StatusPublisher {
|
164 | publish(status: HandlerResponse["status"]): Promise<void>;
|
165 | }
|
166 | declare abstract class AbstractPubSubMessageClient extends AbstractMessageClient {
|
167 | protected readonly request: CommandIncoming | EventIncoming;
|
168 | protected readonly correlationId: string;
|
169 | protected readonly team: {
|
170 | id: string;
|
171 | name?: string;
|
172 | };
|
173 | protected readonly source: Source;
|
174 | protected readonly graphClient: GraphQLClient;
|
175 | private readonly pubsub;
|
176 | constructor(request: CommandIncoming | EventIncoming, correlationId: string, team: {
|
177 | id: string;
|
178 | name?: string;
|
179 | }, source: Source, graphClient: GraphQLClient);
|
180 | sendResponse(message: any): Promise<void>;
|
181 | }
|
182 | export declare class PubSubCommandMessageClient extends AbstractPubSubMessageClient implements StatusPublisher {
|
183 | protected readonly request: CommandIncoming;
|
184 | protected readonly graphClient: GraphQLClient;
|
185 | constructor(request: CommandIncoming, graphClient: GraphQLClient);
|
186 | protected doSend(msg: string | SlackMessage, destinations: Destinations, options?: MessageOptions): Promise<any>;
|
187 | publish(status: HandlerResponse["status"]): Promise<void>;
|
188 | }
|
189 | export declare class PubSubEventMessageClient extends AbstractPubSubMessageClient implements StatusPublisher {
|
190 | protected readonly request: EventIncoming;
|
191 | protected readonly graphClient: GraphQLClient;
|
192 | constructor(request: EventIncoming, graphClient: GraphQLClient);
|
193 | protected doSend(msg: string | SlackMessage, destinations: Destinations, options?: MessageOptions): Promise<any>;
|
194 | publish(status: HandlerResponse["status"]): Promise<void>;
|
195 | }
|
196 | export declare function prepareStatus(status: HandlerStatus | Error, context: EventContext | CommandContext): HandlerResponse["status"];
|
197 | export {};
|
198 |
|
\ | No newline at end of file |