package slack

  1. Overview
  2. Docs

Source file slack_t.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
(* Auto-generated from "slack.atd" *)
[@@@ocaml.warning "-27-32-33-35-39"]

type usergroup = {
  id: string;
  team_id: string option;
  is_usergroup: bool;
  name: string option;
  description: string option;
  handle: string option;
  is_external: bool;
  date_create: int option;
  date_update: int option;
  date_delete: int option;
  created_by: string option;
  updated_by: string option;
  deleted_by: string option;
  users: string list option;
  user_count: int option
}

type two_fa_type =  App | Sms | Not_enabled 

type profile = {
  display_name: string;
  display_name_normalized: string;
  email: string option;
  first_name: string;
  last_name: string;
  phone: string option;
  pronouns: string option;
  real_name: string;
  real_name_normalized: string;
  status_emoji: string option;
  status_expiration: int option;
  status_text: string option;
  team: string;
  title: string option;
  image_24: string option;
  image_32: string option;
  image_48: string option;
  image_72: string option;
  image_192: string option;
  image_512: string option
}

type user = {
  id: string;
  deleted: bool;
  has_2fa: bool;
  is_admin: bool;
  is_app_user: bool;
  is_bot: bool;
  is_invited_user: bool;
  is_owner: bool;
  is_restricted: bool;
  is_stranger: bool;
  is_ultra_restricted: bool;
  locale: string option;
  profile: profile;
  two_factor_type: two_fa_type;
  tz: string option;
  tz_label: string option;
  tz_offset: int;
  updated: int
}

type user_info_res = { ok: bool; user: user }

type user_info_req = { user: string; include_locale: bool option }
  [@@deriving make]

type url_verification_notification = { token: string; challenge: string }

type update_usergroups_users_res = { ok: bool; usergroup: usergroup }

type update_usergroups_users_req = {
  usergroup: string;
  users: string list;
  include_count: bool option;
  team_id: string option
}
  [@@deriving make]

type update_message_res = { channel: string; ts: string }

type text_object_type =  Plain_text | Mrkdwn 

type text_object = { text_type: text_object_type; text: string }
  [@@deriving make]

type message_text_block = { text: text_object } [@@deriving make]

type message_field = { title: string option; value: string; short: bool }
  [@@deriving make]

type message_block =  Section of message_text_block | Divider 

type message_attachment = {
  fallback: string option;
  mrkdwn_in: string list option;
  color: string option;
  pretext: string option;
  author_name: string option;
  author_link: string option;
  author_icon: string option;
  title: string option;
  title_link: string option;
  text: string option;
  fields: message_field list option;
  image_url: string option;
  thumb_url: string option;
  ts: int option;
  footer: string option
}
  [@@deriving make]

type update_message_req = {
  channel: string;
  ts: string;
  text: string option;
  attachments: message_attachment list option;
  blocks: message_block list option;
  link_names: bool option;
  metadata: string option;
  parse: string option;
  reply_broadcast: bool option
}
  [@@deriving make]

type unfurl_block = { blocks: message_block list }

type unfurl = 
    Message_attachment of message_attachment
  | Blocks of unfurl_block


type timestamp_int = Devkit.Time.t

type slack_api_error = [
    `Access_denied
  | `Accesslimited
  | `Account_inactive
  | `As_user_not_supported
  | `Block_mismatch
  | `Blocked_file_type
  | `Cannot_auth_user
  | `Cannot_find_channel
  | `Cannot_find_message
  | `Cannot_find_service
  | `Cannot_parse_attachment
  | `Cannot_prompt
  | `Cannot_unfurl_message
  | `Cannot_unfurl_url
  | `Cant_broadcast_message
  | `Cant_update_message
  | `Channel_not_found
  | `Deprecated_endpoint
  | `Duplicate_channel_not_found
  | `Duplicate_message_not_found
  | `Edit_window_closed
  | `Ekm_access_denied
  | `Enterprise_is_restricted
  | `External_channel_migrating
  | `Fatal_error
  | `Internal_error
  | `Invalid_arg_name
  | `Invalid_arguments
  | `Invalid_array_arg
  | `Invalid_attachments
  | `Invalid_auth
  | `Invalid_blocks
  | `Invalid_blocks_format
  | `Invalid_channel
  | `Invalid_charset
  | `Invalid_cursor
  | `Invalid_form_data
  | `Invalid_metadata_filter_keys
  | `Invalid_metadata_format
  | `Invalid_metadata_schema
  | `Invalid_post_type
  | `Invalid_source
  | `Invalid_ts_latest
  | `Invalid_ts_oldest
  | `Invalid_unfurl_id
  | `Invalid_unfurls_format
  | `Invalid_users
  | `Is_archived
  | `Is_bot
  | `Is_inactive
  | `Malware_detected
  | `Message_limit_exceeded
  | `Message_not_found
  | `Messages_tab_disabled
  | `Metadata_must_be_sent_from_app
  | `Metadata_too_large
  | `Method_deprecated
  | `Method_not_supported_for_channel_type
  | `Missing_argument
  | `Missing_channel
  | `Missing_post_type
  | `Missing_scope
  | `Missing_source
  | `Missing_ts
  | `Missing_unfurl_id
  | `Missing_unfurls
  | `Msg_too_long
  | `No_dual_broadcast_content_update
  | `No_permission
  | `No_text
  | `No_users_provided
  | `Not_allowed_token_type
  | `Not_authed
  | `Not_in_channel
  | `Org_login_required
  | `Permission_denied
  | `Plan_upgrade_required
  | `Post_contents_too_large
  | `Posting_to_general_channel_denied
  | `Rate_limited
  | `Ratelimited
  | `Request_timeout
  | `Restricted_action
  | `Restricted_action_non_threadable_channel
  | `Restricted_action_read_only_channel
  | `Restricted_action_thread_locked
  | `Restricted_action_thread_only_channel
  | `Service_unavailable
  | `Slack_connect_blocked_file_type
  | `Slack_connect_canvas_sharing_blocked
  | `Slack_connect_clip_sharing_blocked
  | `Slack_connect_file_link_sharing_blocked
  | `Slack_connect_file_upload_sharing_blocked
  | `Slack_connect_team_blocked
  | `Subteam_max_users_exceeded
  | `Team_access_not_granted
  | `Team_added_to_org
  | `Team_not_found
  | `Thread_not_found
  | `Token_expired
  | `Token_revoked
  | `Too_many_attachments
  | `Too_many_contact_cards
  | `Too_many_members
  | `Too_many_users
  | `Two_factor_setup_required
  | `Update_failed
  | `User_is_restricted
  | `User_not_found
  | `User_not_visible
  | `Other of string
]

type ('ok, 'err) http_response = ('ok, 'err) Stdlib.result = 
    Ok of 'ok
  | Error of 'err


type 'ok slack_response = ('ok, slack_api_error) http_response

type secrets = {
  slack_access_token: string option;
  slack_signing_secret: string option
}

type post_message_res = { channel: string; ts: string }

type post_message_req = {
  channel: string;
  text: string option;
  attachments: message_attachment list option;
  blocks: message_block list option;
  username: string option;
  icon_url: string option;
  icon_emoji: string option;
  metadata: string option;
  mrkdwn: bool option;
  parse: string option;
  reply_broadcast: bool option;
  thread_ts: string option;
  unfurl_links: bool option;
  unfurl_media: bool option
}
  [@@deriving make]

type ok_res = { ok: bool }

type message_event = {
  subtype: string option;
  channel: string;
  user: string option;
  text: string option;
  ts: string;
  bot_id: string option;
  thread_ts: string option
}

type list_users_res = {
  ok: bool;
  members: user list;
  response_metadata: (string * string) list
}

type list_users_req = {
  cursor: string option;
  include_locale: bool option;
  limit: int option;
  team_id: string option
}
  [@@deriving make]

type list_usergroups_res = { ok: bool; usergroups: usergroup list }

type list_usergroups_req = {
  include_count: bool option;
  team_id: string option;
  include_users: bool option;
  include_disabled: bool option
}
  [@@deriving make]

type list_usergroup_users_res = { ok: bool; users: string list }

type list_usergroup_users_req = {
  usergroup: string;
  team_id: string option;
  include_disabled: bool option
}
  [@@deriving make]

type link_shared_source = [ `Conversations_history | `Composer ]

type link_shared_link = { domain: string; url: string }

type link_shared_event = {
  channel: string;
  is_bot_user_member: bool;
  user: string;
  message_ts: string;
  thread_ts: string option;
  links: link_shared_link list;
  source: link_shared_source
}

type json = Yojson.Basic.t

type file = {
  id: string;
  name: string option;
  title: string option;
  mimetype: string option;
  filetype: string option;
  pretty_type: string option;
  user: string option;
  size: int option;
  channels: string list;
  ims: string list;
  groups: string list;
  permalink: string option;
  permalink_public: string option
}

type files_upload_res = { ok: bool; file: file }

type files_upload_req = {
  channels: string option;
  content: string option;
  filename: string option;
  filetype: string option;
  initial_comment: string option;
  thread_ts: string option;
  title: string option
}
  [@@deriving make]

type event =  Message of message_event | Link_shared of link_shared_event 

type event_callback_notification = {
  token: string;
  team_id: string;
  api_app_id: string;
  event: event;
  event_id: string;
  event_time: timestamp_int
}

type event_notification = 
    Event_callback of event_callback_notification
  | Url_verification of url_verification_notification


type created_value = { value: string; creator: string; last_set: int }

type conversation_reply = {
  type_: string;
  ts: string;
  thread_ts: string option;
  user: string option;
  text: string option;
  reply_count: int option;
  subscribed: bool option;
  last_read: string option;
  unread_count: int option;
  parent_user_id: string option
}

type conversations_replies_res = {
  messages: conversation_reply list option;
  ok: bool;
  has_more: bool option;
  response_metadata: (string * json) list
}

type conversations_replies_req = {
  channel: string;
  ts: string;
  cursor: string option;
  include_all_metadata: bool option;
  inclusive: bool option;
  latest: string option;
  limit: int option;
  oldest: string option
}
  [@@deriving make]

type conversation = {
  id: string;
  name: string option;
  is_channel: bool;
  is_group: bool;
  is_im: bool;
  is_member: bool option;
  user: string option;
  locale: string option;
  num_members: int option;
  topic: created_value option;
  purpose: created_value option
}

type conversations_join_res = {
  channel: conversation;
  warning: string option;
  response_metadata: (string * json) list
}

type conversations_join_req = { channel: string } [@@deriving make]

type conversations_info_res = { ok: bool; channel: conversation }

type conversations_info_req = {
  channel: string;
  include_locale: bool option;
  include_num_members: bool option
}
  [@@deriving make]

type chat_unfurl_req = {
  channel: string;
  ts: string;
  unfurls: (string * unfurl) list
}
  [@@deriving make]

type auth_test_res = {
  url: string;
  team: string;
  user: string;
  team_id: string;
  user_id: string
}
OCaml

Innovation. Community. Security.