1 |
|
2 |
|
3 | export type Config = {
|
4 | mainframe_secret: string,
|
5 | mainframe_url: string,
|
6 | port: number,
|
7 | }
|
8 |
|
9 | export type ClientContext = {
|
10 | user: Object,
|
11 | conversation?: ?Object,
|
12 | organization?: ?Object,
|
13 | subscription_token?: string,
|
14 | }
|
15 |
|
16 | export type PostPayload = {
|
17 | user_id: string,
|
18 | data: Object,
|
19 | context: ClientContext,
|
20 | }
|
21 |
|
22 | export type BotContext = {
|
23 | config: Config,
|
24 | callMainframe: (endpoint: string, data?: Object) => Promise<Object>,
|
25 | sendEvent: (payload: {
|
26 | conversation_id: string,
|
27 | message?: string,
|
28 | data?: Object,
|
29 | }) => Promise<Object>,
|
30 | }
|
31 |
|
32 | export type BotResponse = {
|
33 | success: boolean,
|
34 | message?: string,
|
35 | data?: Object,
|
36 | }
|
37 |
|
38 | export type Handlers = {
|
39 | enable?: (payload: { user_id: string }) => void,
|
40 | disable?: (payload: { user_id: string }) => void,
|
41 | conversation_added?: (payload: {
|
42 | user_id: string,
|
43 | conversation_id: string,
|
44 | }) => void,
|
45 | conversation_removed?: (payload: {
|
46 | user_id: string,
|
47 | conversation_id: string,
|
48 | }) => void,
|
49 | edit_subscription?: (payload: {
|
50 | user_id: string,
|
51 | conversation_id: string,
|
52 | subscription_id: string,
|
53 | }) => void,
|
54 | delete_subscription?: (payload: { subscription_id: string }) => void,
|
55 | post?: (payload: PostRequest) => Promise<BotResponse>,
|
56 | }
|