// @flow export type Config = {| +mainframe_secret: string, +mainframe_url: string, +port: number, |} export type ClientContext = {| +user: { +id: string, +username: string, +name: string, }, +conversation?: { +id: string, +subject: ?string, +type: 'bot' | 'direct' | 'default' | 'space', }, +organization?: { +id: string, +username: string, +name: string, }, +subscription_token?: string, |} export type PostPayload = {| +user_id: string, +data: Object, +context: ClientContext, |} export type BotContext = {| +config: Config, +callMainframe: (endpoint: string, data?: Object) => Promise, +sendMessage: (payload: { conversation_id: string, message?: string, data?: Object, }) => Promise, |} export type BotResponse = {| success: boolean, message?: string, data?: Object, |} export type Handlers = {| enable?: (payload: { user_id: string }) => void, disable?: (payload: { user_id: string }) => void, conversation_added?: (payload: { user_id: string, conversation_id: string, }) => void, conversation_removed?: (payload: { user_id: string, conversation_id: string, }) => void, edit_subscription?: (payload: { user_id: string, conversation_id: string, subscription_id: string, }) => void, delete_subscription?: (payload: { subscription_id: string }) => void, post?: (payload: PostRequest) => BotResponse | Promise, |}