@twilio/conversations 1.3.0-rc7 → 2.0.0-rc.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (282) hide show
  1. package/CHANGELOG.md +201 -0
  2. package/README.md +5 -5
  3. package/dist/browser.js +7866 -0
  4. package/dist/browser.js.map +1 -0
  5. package/dist/docs/assets/css/main.css +2660 -0
  6. package/dist/docs/assets/images/icons.png +0 -0
  7. package/dist/docs/assets/images/icons@2x.png +0 -0
  8. package/dist/docs/assets/images/widgets.png +0 -0
  9. package/dist/docs/assets/images/widgets@2x.png +0 -0
  10. package/dist/docs/assets/js/main.js +248 -0
  11. package/dist/docs/assets/js/search.js +1 -0
  12. package/dist/docs/classes/AggregatedDeliveryReceipt.html +3286 -0
  13. package/dist/docs/classes/Client.html +4181 -0
  14. package/dist/docs/classes/Conversation.html +4397 -0
  15. package/dist/docs/classes/DetailedDeliveryReceipt.html +3265 -0
  16. package/dist/docs/classes/Media.html +3295 -0
  17. package/dist/docs/classes/Message.html +3713 -0
  18. package/dist/docs/classes/MessageBuilder.html +3280 -0
  19. package/dist/docs/classes/Participant.html +3517 -0
  20. package/dist/docs/classes/PushNotification.html +3232 -0
  21. package/dist/docs/classes/RestPaginator.html +3262 -0
  22. package/dist/docs/classes/UnsentMessage.html +3144 -0
  23. package/dist/docs/classes/User.html +3451 -0
  24. package/dist/docs/index.html +3387 -212
  25. package/dist/docs/interfaces/ClientOptions.html +3136 -0
  26. package/dist/docs/interfaces/ConversationState.html +3152 -0
  27. package/dist/docs/interfaces/CreateConversationOptions.html +3168 -0
  28. package/dist/docs/interfaces/LastMessage.html +3152 -0
  29. package/dist/docs/interfaces/Paginator.html +3243 -0
  30. package/dist/docs/interfaces/PushNotificationData.html +3168 -0
  31. package/dist/docs/interfaces/SendEmailOptions.html +3136 -0
  32. package/dist/docs/interfaces/SendMediaOptions.html +3169 -0
  33. package/dist/docs/modules.html +3418 -0
  34. package/dist/lib.d.ts +1944 -0
  35. package/dist/lib.js +7866 -0
  36. package/dist/lib.js.map +1 -0
  37. package/dist/post-install.js +29 -0
  38. package/dist/react-native.js +4031 -0
  39. package/dist/react-native.js.map +1 -0
  40. package/dist/twilio-conversations.js +40905 -0
  41. package/dist/twilio-conversations.min.js +156 -0
  42. package/package.json +59 -48
  43. package/.circleci/config.yml +0 -650
  44. package/.deepsource.toml +0 -6
  45. package/.env.example +0 -13
  46. package/browser/aggregateddeliveryreceipt.js +0 -152
  47. package/browser/client.js +0 -991
  48. package/browser/configuration.js +0 -80
  49. package/browser/conversation.js +0 -1826
  50. package/browser/data/conversations.js +0 -665
  51. package/browser/data/messages.js +0 -522
  52. package/browser/data/participants.js +0 -411
  53. package/browser/data/users.js +0 -281
  54. package/browser/detaileddeliveryreceipt.js +0 -44
  55. package/browser/index.js +0 -4
  56. package/browser/interfaces/limits.js +0 -3
  57. package/browser/interfaces/notificationtypes.js +0 -21
  58. package/browser/interfaces/paginator.js +0 -53
  59. package/browser/interfaces/responsecodes.js +0 -20
  60. package/browser/interfaces/transport.js +0 -3
  61. package/browser/logger.js +0 -141
  62. package/browser/media.js +0 -198
  63. package/browser/message.js +0 -685
  64. package/browser/participant.js +0 -415
  65. package/browser/pushnotification.js +0 -49
  66. package/browser/restpaginator.js +0 -74
  67. package/browser/services/network.js +0 -223
  68. package/browser/services/readhorizon.js +0 -181
  69. package/browser/services/typingindicator.js +0 -142
  70. package/browser/session.js +0 -505
  71. package/browser/sessionerror.js +0 -93
  72. package/browser/sri.json +0 -1
  73. package/browser/synclist.js +0 -90
  74. package/browser/synclistdescriptor.js +0 -29
  75. package/browser/syncpaginator.js +0 -63
  76. package/browser/user.js +0 -431
  77. package/browser/util/deferred.js +0 -56
  78. package/browser/util/index.js +0 -108
  79. package/dist/@twilio/conversations.js +0 -35565
  80. package/dist/@twilio/conversations.min.js +0 -204
  81. package/dist/docs/AggregatedDeliveryReceipt.html +0 -948
  82. package/dist/docs/Client.html +0 -5075
  83. package/dist/docs/Conversation.html +0 -6018
  84. package/dist/docs/DetailedDeliveryReceipt.html +0 -641
  85. package/dist/docs/Media.html +0 -694
  86. package/dist/docs/Message.html +0 -1934
  87. package/dist/docs/Paginator.html +0 -605
  88. package/dist/docs/Participant.html +0 -1510
  89. package/dist/docs/PushNotification.html +0 -836
  90. package/dist/docs/SessionError.html +0 -379
  91. package/dist/docs/User.html +0 -1315
  92. package/dist/docs/classes.list.html +0 -4431
  93. package/dist/docs/fonts/glyphicons-halflings-regular.eot +0 -0
  94. package/dist/docs/fonts/glyphicons-halflings-regular.svg +0 -288
  95. package/dist/docs/fonts/glyphicons-halflings-regular.ttf +0 -0
  96. package/dist/docs/fonts/glyphicons-halflings-regular.woff +0 -0
  97. package/dist/docs/fonts/glyphicons-halflings-regular.woff2 +0 -0
  98. package/dist/docs/img/glyphicons-halflings-white.png +0 -0
  99. package/dist/docs/img/glyphicons-halflings.png +0 -0
  100. package/dist/docs/quicksearch.html +0 -31
  101. package/dist/docs/scripts/docstrap.lib.js +0 -11
  102. package/dist/docs/scripts/fulltext-search-ui.js +0 -89
  103. package/dist/docs/scripts/fulltext-search.js +0 -36
  104. package/dist/docs/scripts/lunr.min.js +0 -6
  105. package/dist/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
  106. package/dist/docs/scripts/prettify/jquery.min.js +0 -6
  107. package/dist/docs/scripts/prettify/lang-css.js +0 -21
  108. package/dist/docs/scripts/prettify/prettify.js +0 -496
  109. package/dist/docs/scripts/sunlight.js +0 -1157
  110. package/dist/docs/scripts/toc.js +0 -203
  111. package/dist/docs/styles/darkstrap.css +0 -960
  112. package/dist/docs/styles/prettify-tomorrow.css +0 -132
  113. package/dist/docs/styles/site.cerulean.css +0 -7008
  114. package/dist/docs/styles/site.cosmo.css +0 -7061
  115. package/dist/docs/styles/site.cyborg.css +0 -7048
  116. package/dist/docs/styles/site.darkly.css +0 -7171
  117. package/dist/docs/styles/site.darkstrap.css +0 -5638
  118. package/dist/docs/styles/site.dibs-bootstrap.css +0 -5899
  119. package/dist/docs/styles/site.flatly.css +0 -7147
  120. package/dist/docs/styles/site.journal.css +0 -6973
  121. package/dist/docs/styles/site.lumen.css +0 -7298
  122. package/dist/docs/styles/site.paper.css +0 -7623
  123. package/dist/docs/styles/site.readable.css +0 -6997
  124. package/dist/docs/styles/site.sandstone.css +0 -7035
  125. package/dist/docs/styles/site.simplex.css +0 -7023
  126. package/dist/docs/styles/site.slate.css +0 -7343
  127. package/dist/docs/styles/site.spacelab.css +0 -7055
  128. package/dist/docs/styles/site.superhero.css +0 -7131
  129. package/dist/docs/styles/site.united.css +0 -6895
  130. package/dist/docs/styles/site.yeti.css +0 -7195
  131. package/dist/docs/styles/sunlight.dark.css +0 -345
  132. package/dist/docs/styles/sunlight.default.css +0 -344
  133. package/dist/sri.json +0 -1
  134. package/lib/aggregateddeliveryreceipt.d.ts +0 -98
  135. package/lib/aggregateddeliveryreceipt.js +0 -112
  136. package/lib/client.d.ts +0 -317
  137. package/lib/client.js +0 -633
  138. package/lib/configuration.d.ts +0 -21
  139. package/lib/configuration.js +0 -41
  140. package/lib/conversation.d.ts +0 -460
  141. package/lib/conversation.js +0 -940
  142. package/lib/data/conversations.d.ts +0 -57
  143. package/lib/data/conversations.js +0 -318
  144. package/lib/data/messages.d.ts +0 -75
  145. package/lib/data/messages.js +0 -208
  146. package/lib/data/participants.d.ts +0 -94
  147. package/lib/data/participants.js +0 -204
  148. package/lib/data/users.d.ts +0 -42
  149. package/lib/data/users.js +0 -113
  150. package/lib/detaileddeliveryreceipt.d.ts +0 -45
  151. package/lib/detaileddeliveryreceipt.js +0 -34
  152. package/lib/index.d.ts +0 -1
  153. package/lib/index.js +0 -3
  154. package/lib/interfaces/limits.d.ts +0 -8
  155. package/lib/interfaces/limits.js +0 -2
  156. package/lib/interfaces/notificationtypes.d.ts +0 -8
  157. package/lib/interfaces/notificationtypes.js +0 -11
  158. package/lib/interfaces/paginator.d.ts +0 -52
  159. package/lib/interfaces/paginator.js +0 -28
  160. package/lib/interfaces/responsecodes.d.ts +0 -8
  161. package/lib/interfaces/responsecodes.js +0 -10
  162. package/lib/interfaces/transport.d.ts +0 -13
  163. package/lib/interfaces/transport.js +0 -2
  164. package/lib/logger.d.ts +0 -18
  165. package/lib/logger.js +0 -35
  166. package/lib/media.d.ts +0 -52
  167. package/lib/media.js +0 -69
  168. package/lib/message.d.ts +0 -136
  169. package/lib/message.js +0 -305
  170. package/lib/participant.d.ts +0 -142
  171. package/lib/participant.js +0 -219
  172. package/lib/pushnotification.d.ts +0 -48
  173. package/lib/pushnotification.js +0 -39
  174. package/lib/restpaginator.d.ts +0 -19
  175. package/lib/restpaginator.js +0 -36
  176. package/lib/services/network.d.ts +0 -22
  177. package/lib/services/network.js +0 -87
  178. package/lib/services/readhorizon.d.ts +0 -28
  179. package/lib/services/readhorizon.js +0 -112
  180. package/lib/services/typingindicator.d.ts +0 -50
  181. package/lib/services/typingindicator.js +0 -102
  182. package/lib/session.d.ts +0 -63
  183. package/lib/session.js +0 -213
  184. package/lib/sessionerror.d.ts +0 -12
  185. package/lib/sessionerror.js +0 -24
  186. package/lib/sri.json +0 -1
  187. package/lib/synclist.d.ts +0 -24
  188. package/lib/synclist.js +0 -28
  189. package/lib/synclistdescriptor.d.ts +0 -27
  190. package/lib/synclistdescriptor.js +0 -19
  191. package/lib/syncpaginator.d.ts +0 -22
  192. package/lib/syncpaginator.js +0 -37
  193. package/lib/user.d.ts +0 -98
  194. package/lib/user.js +0 -219
  195. package/lib/util/deferred.d.ts +0 -12
  196. package/lib/util/deferred.js +0 -22
  197. package/lib/util/index.d.ts +0 -28
  198. package/lib/util/index.js +0 -82
  199. package/tools/rtd-sdk-cdn-pin/.gitrepo +0 -12
  200. package/tools/rtd-sdk-cdn-pin/README.md +0 -54
  201. package/tools/rtd-sdk-cdn-pin/bintray-settings.xml.template +0 -16
  202. package/tools/rtd-sdk-cdn-pin/cdn-common/cdn-prepare.sh +0 -67
  203. package/tools/rtd-sdk-cdn-pin/cdn-pin-latest.sh +0 -19
  204. package/tools/rtd-sdk-cdn-pin/cdn-pin.sh +0 -19
  205. package/tools/rtd-sdk-cdn-pin/cdn-upload.sh +0 -13
  206. package/tools/rtd-sdk-cdn-pin/fetch/common/fetch-bintray-android.sh +0 -34
  207. package/tools/rtd-sdk-cdn-pin/fetch/common/fetch-npm.sh +0 -18
  208. package/tools/rtd-sdk-cdn-pin/fetch/twilio-chat-android.sh +0 -5
  209. package/tools/rtd-sdk-cdn-pin/fetch/twilio-chat-js.sh +0 -5
  210. package/tools/rtd-sdk-cdn-pin/fetch/twilio-conversations-android.sh +0 -6
  211. package/tools/rtd-sdk-cdn-pin/fetch/twilio-conversations-js.sh +0 -5
  212. package/tools/rtd-sdk-cdn-pin/fetch/twilio-sync-android.sh +0 -5
  213. package/tools/rtd-sdk-cdn-pin/fetch/twilio-sync-js.sh +0 -5
  214. package/tools/rtd-sdk-cdn-pin/fetch-artifact.sh +0 -26
  215. package/tools/sdk-release-tool/.gitrepo +0 -12
  216. package/tools/sdk-release-tool/Makefile +0 -49
  217. package/tools/sdk-release-tool/README.md +0 -275
  218. package/tools/sdk-release-tool/delete +0 -3
  219. package/tools/sdk-release-tool/download +0 -3
  220. package/tools/sdk-release-tool/get-cors +0 -3
  221. package/tools/sdk-release-tool/list +0 -3
  222. package/tools/sdk-release-tool/pin +0 -3
  223. package/tools/sdk-release-tool/pin-latest +0 -3
  224. package/tools/sdk-release-tool/requirements.txt +0 -4
  225. package/tools/sdk-release-tool/sdk-release-tool +0 -3
  226. package/tools/sdk-release-tool/sdk_release_tools/__init__.py +0 -0
  227. package/tools/sdk-release-tool/sdk_release_tools/__main__.py +0 -110
  228. package/tools/sdk-release-tool/sdk_release_tools/aws.py +0 -70
  229. package/tools/sdk-release-tool/sdk_release_tools/cli.py +0 -181
  230. package/tools/sdk-release-tool/sdk_release_tools/log.py +0 -24
  231. package/tools/sdk-release-tool/sdk_release_tools/ops.py +0 -295
  232. package/tools/sdk-release-tool/sdk_release_tools/rpm.py +0 -28
  233. package/tools/sdk-release-tool/sdk_release_tools/util.py +0 -186
  234. package/tools/sdk-release-tool/sdk_release_tools/versions.py +0 -362
  235. package/tools/sdk-release-tool/signal-sdk-js.json +0 -28
  236. package/tools/sdk-release-tool/tests/test_versions.py +0 -94
  237. package/tools/sdk-release-tool/twilio-accessmanager-android.json +0 -19
  238. package/tools/sdk-release-tool/twilio-accessmanager-ios.json +0 -26
  239. package/tools/sdk-release-tool/twilio-auth-ios.json +0 -29
  240. package/tools/sdk-release-tool/twilio-authenticator-ios.json +0 -29
  241. package/tools/sdk-release-tool/twilio-chat-android-2.json +0 -19
  242. package/tools/sdk-release-tool/twilio-chat-android.json +0 -22
  243. package/tools/sdk-release-tool/twilio-chat-ios.json +0 -26
  244. package/tools/sdk-release-tool/twilio-chat-js.json +0 -27
  245. package/tools/sdk-release-tool/twilio-client-android-aar.json +0 -22
  246. package/tools/sdk-release-tool/twilio-client-android.json +0 -22
  247. package/tools/sdk-release-tool/twilio-client-ios.json +0 -20
  248. package/tools/sdk-release-tool/twilio-client-js.json +0 -17
  249. package/tools/sdk-release-tool/twilio-client-sounds-js.json +0 -14
  250. package/tools/sdk-release-tool/twilio-common-android-maven.json +0 -16
  251. package/tools/sdk-release-tool/twilio-common-android.json +0 -22
  252. package/tools/sdk-release-tool/twilio-common-ios-rtc.json +0 -25
  253. package/tools/sdk-release-tool/twilio-common-ios.json +0 -25
  254. package/tools/sdk-release-tool/twilio-common-js.json +0 -19
  255. package/tools/sdk-release-tool/twilio-conversations-android.json +0 -22
  256. package/tools/sdk-release-tool/twilio-conversations-ios.json +0 -26
  257. package/tools/sdk-release-tool/twilio-conversations-js.json +0 -27
  258. package/tools/sdk-release-tool/twilio-flex-js.json +0 -20
  259. package/tools/sdk-release-tool/twilio-flex-webchat-js.json +0 -16
  260. package/tools/sdk-release-tool/twilio-frame-chat-android.json +0 -22
  261. package/tools/sdk-release-tool/twilio-frame-chat-ios.json +0 -23
  262. package/tools/sdk-release-tool/twilio-frame-chat-js.json +0 -23
  263. package/tools/sdk-release-tool/twilio-ip-messaging-android-maven.json +0 -16
  264. package/tools/sdk-release-tool/twilio-ip-messaging-android.json +0 -22
  265. package/tools/sdk-release-tool/twilio-ip-messaging-ios.json +0 -25
  266. package/tools/sdk-release-tool/twilio-ip-messaging-js.json +0 -21
  267. package/tools/sdk-release-tool/twilio-sync-android.json +0 -22
  268. package/tools/sdk-release-tool/twilio-sync-ios.json +0 -26
  269. package/tools/sdk-release-tool/twilio-sync-js.json +0 -39
  270. package/tools/sdk-release-tool/twilio-taskrouter-js.json +0 -17
  271. package/tools/sdk-release-tool/twilio-video-android.json +0 -22
  272. package/tools/sdk-release-tool/twilio-video-cpp-linux-cross-rootfs.json +0 -13
  273. package/tools/sdk-release-tool/twilio-video-cpp.json +0 -33
  274. package/tools/sdk-release-tool/twilio-video-ios.json +0 -25
  275. package/tools/sdk-release-tool/twilio-video-js.json +0 -19
  276. package/tools/sdk-release-tool/twilio-video-jsdocs.json +0 -14
  277. package/tools/sdk-release-tool/twilio-voice-android.json +0 -22
  278. package/tools/sdk-release-tool/twilio-voice-ios.json +0 -29
  279. package/tools/sdk-release-tool/unpin +0 -3
  280. package/tools/sdk-release-tool/unpin-latest +0 -3
  281. package/tools/sdk-release-tool/upload +0 -3
  282. package/twilio-chat.js.iml +0 -9
package/dist/lib.d.ts ADDED
@@ -0,0 +1,1944 @@
1
+ import { SyncClient } from "twilio-sync";
2
+ import { Transport, TwilsockClient, InitRegistration } from "twilsock";
3
+ import { ConnectionState as TwilsockConnectionState } from "twilsock";
4
+ import { ReplayEventEmitter } from "@twilio/replay-event-emitter";
5
+ import { ChannelType, Notifications } from "@twilio/notifications";
6
+ import { Notifications as NotificationClient } from "@twilio/notifications";
7
+ import { McsClient, MediaCategory, McsMedia } from "@twilio/mcs-client";
8
+ import { MediaCategory as McsMediaCategory } from "@twilio/mcs-client";
9
+ interface ConfigurationResponse {
10
+ options: {
11
+ consumption_report_interval: string;
12
+ user_infos_to_subscribe: number;
13
+ reachability_enabled: boolean;
14
+ http_cache_interval: string;
15
+ my_conversations_page_size: number;
16
+ media_attachments_count_limit: number;
17
+ media_attachment_size_limit_in_mb: number;
18
+ media_attachments_total_size_limit_in_mb: number;
19
+ email_histories_allowed_mime_types: string[];
20
+ email_bodies_allowed_mime_types: string[];
21
+ };
22
+ sync_objects: {
23
+ my_conversations: string;
24
+ my_user_info: string;
25
+ };
26
+ links: {
27
+ my_conversations: string;
28
+ conversations: string;
29
+ users: string;
30
+ current_user: string;
31
+ typing: string;
32
+ media_service: string;
33
+ media_set_service: string;
34
+ messages_receipts: string;
35
+ };
36
+ identity: string;
37
+ url: string;
38
+ }
39
+ // twilio-conversations is used by Flex SDK. Please DO NOT change
40
+ declare class Logger {
41
+ private prefix;
42
+ private constructor();
43
+ static scope(prefix: string): Logger;
44
+ setLevel(level: any): void;
45
+ static setLevel(level: any): void;
46
+ trace(...args: any[]): void;
47
+ debug(...args: any[]): void;
48
+ info(...args: any[]): void;
49
+ warn(...args: any[]): void;
50
+ error(...args: any[]): void;
51
+ static trace(...args: any[]): void;
52
+ static debug(...args: any[]): void;
53
+ static info(...args: any[]): void;
54
+ static warn(...args: any[]): void;
55
+ static error(...args: any[]): void;
56
+ }
57
+ interface Limits {
58
+ mediaAttachmentsCountLimit: number;
59
+ mediaAttachmentSizeLimitInMb: number;
60
+ mediaAttachmentsTotalSizeLimitInMb: number;
61
+ emailHistoriesAllowedMimeTypes: string[];
62
+ emailBodiesAllowedMimeTypes: string[];
63
+ }
64
+ interface BackoffConfiguration {
65
+ min: number;
66
+ max: number;
67
+ maxAttemptsCount: number;
68
+ }
69
+ declare class Configuration {
70
+ readonly links: {
71
+ myConversations: string;
72
+ conversations: string;
73
+ users: string;
74
+ currentUser: string;
75
+ typing: string;
76
+ mediaService: string;
77
+ mediaSetService: string;
78
+ messagesReceipts: string;
79
+ };
80
+ readonly limits: Limits;
81
+ readonly productId?: string;
82
+ readonly typingIndicatorTimeoutOverride?: number;
83
+ readonly typingIndicatorTimeoutDefault: number;
84
+ readonly backoffConfiguration: BackoffConfiguration;
85
+ readonly retryWhenThrottled: boolean;
86
+ readonly consumptionReportInterval: number;
87
+ readonly userInfosToSubscribe: number;
88
+ readonly httpCacheInterval: number;
89
+ readonly reachabilityEnabled: boolean;
90
+ readonly userIdentity: string;
91
+ readonly userInfo: string;
92
+ readonly myConversations: string;
93
+ constructor(options: Record<string, any>, configurationResponse: ConfigurationResponse, logger: Logger);
94
+ }
95
+ interface CommandExecutorServices {
96
+ transport: Transport;
97
+ }
98
+ declare class CommandExecutor {
99
+ private _serviceUrl;
100
+ private _services;
101
+ private _productId?;
102
+ constructor(_serviceUrl: string, _services: CommandExecutorServices, _productId?: string);
103
+ private _preProcessUrl;
104
+ private _makeRequest;
105
+ fetchResource<REQ = void, RESP = void>(url: string, requestBody?: REQ): Promise<RESP>;
106
+ mutateResource<REQ = void, RESP = void>(method: "post" | "delete", url: string, requestBody?: REQ): Promise<RESP>;
107
+ }
108
+ type UserEvents = {
109
+ updated: (data: {
110
+ user: User;
111
+ updateReasons: UserUpdateReason[];
112
+ }) => void;
113
+ userSubscribed: (user: User) => void;
114
+ userUnsubscribed: (user: User) => void;
115
+ };
116
+ interface UserServices {
117
+ syncClient: SyncClient;
118
+ commandExecutor: CommandExecutor;
119
+ }
120
+ /**
121
+ * The reason for the `updated` event being emitted by a user.
122
+ */
123
+ type UserUpdateReason = "friendlyName" | "attributes" | "reachabilityOnline" | "reachabilityNotifiable";
124
+ interface UserUpdatedEventArgs {
125
+ user: User;
126
+ updateReasons: UserUpdateReason[];
127
+ }
128
+ /**
129
+ * Extended user information.
130
+ * Note that `isOnline` and `isNotifiable` properties are eligible
131
+ * for use only if the reachability function is enabled.
132
+ * You may check if it is enabled by reading the value of {@link Client.reachabilityEnabled}.
133
+ */
134
+ declare class User extends ReplayEventEmitter<UserEvents> {
135
+ private links;
136
+ private configuration;
137
+ private readonly services;
138
+ private entity;
139
+ private state;
140
+ private promiseToFetch;
141
+ private subscribed;
142
+ private _initializationPromise;
143
+ private _resolveInitializationPromise;
144
+ /**
145
+ * @internal
146
+ */
147
+ constructor(identity: string, entityName: string, configuration: Configuration | null, services: UserServices);
148
+ /**
149
+ * Fired when the properties or the reachability status of the message has been updated.
150
+ *
151
+ * Parameters:
152
+ * 1. object `data` - info object provided with the event. It has the following properties:
153
+ * * {@link User} `user` - the user in question
154
+ * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update
155
+ * @event
156
+ */
157
+ readonly updated = "updated";
158
+ /**
159
+ * Fired when the client has subscribed to the user.
160
+ *
161
+ * Parameters:
162
+ * 1. {@link User} `user` - the user in question
163
+ * @event
164
+ */
165
+ readonly userSubscribed = "userSubscribed";
166
+ /**
167
+ * Fired when the client has unsubscribed from the user.
168
+ *
169
+ * Parameters:
170
+ * 1. {@link User} `user` - the user in question
171
+ * @event
172
+ */
173
+ readonly userUnsubscribed = "userUnsubscribed";
174
+ /**
175
+ * User identity.
176
+ */
177
+ get identity(): string;
178
+ set identity(identity: string);
179
+ set entityName(name: string);
180
+ /**
181
+ * Custom attributes of the user.
182
+ */
183
+ get attributes(): any;
184
+ /**
185
+ * Friendly name of the user, null if not set.
186
+ */
187
+ get friendlyName(): string;
188
+ /**
189
+ * Status of the real-time conversation connection of the user.
190
+ */
191
+ get isOnline(): boolean;
192
+ /**
193
+ * User push notification registration status.
194
+ */
195
+ get isNotifiable(): boolean;
196
+ /**
197
+ * True if this user is receiving real-time status updates.
198
+ */
199
+ get isSubscribed(): boolean;
200
+ // Handles service updates
201
+ _update(key: string, value: any): Promise<void>;
202
+ // Fetch reachability info
203
+ private _updateReachabilityInfo;
204
+ // Fetch user
205
+ _fetch(): Promise<User>;
206
+ _ensureFetched(): Promise<User>;
207
+ /**
208
+ * Edit user attributes.
209
+ * @param attributes New attributes.
210
+ */
211
+ updateAttributes(attributes: any): Promise<User>;
212
+ /**
213
+ * Update the friendly name of the user.
214
+ * @param friendlyName New friendly name.
215
+ */
216
+ updateFriendlyName(friendlyName: string): Promise<User>;
217
+ /**
218
+ * Remove the user from the subscription list.
219
+ * @return A promise of completion.
220
+ */
221
+ unsubscribe(): Promise<void>;
222
+ _resolveInitialization(configuration: Configuration, identity: string, entityName: string, emitUpdated: boolean): void;
223
+ }
224
+ declare class Network {
225
+ private readonly configuration;
226
+ private readonly services;
227
+ private cacheLifetime;
228
+ private readonly cache;
229
+ private timer;
230
+ constructor(configuration: any, services: any);
231
+ private isExpired;
232
+ private cleanupCache;
233
+ pokeTimer(): void;
234
+ private executeWithRetry;
235
+ get(url: string): Promise<any>;
236
+ }
237
+ type UsersEvents = {
238
+ userUpdated: (data: {
239
+ user: User;
240
+ updateReasons: UserUpdateReason[];
241
+ }) => void;
242
+ userSubscribed: (user: User) => void;
243
+ userUnsubscribed: (user: User) => void;
244
+ };
245
+ interface UsersServices {
246
+ network: Network;
247
+ syncClient: SyncClient;
248
+ commandExecutor: CommandExecutor;
249
+ }
250
+ /**
251
+ * Container for known users
252
+ */
253
+ declare class Users extends ReplayEventEmitter<UsersEvents> {
254
+ private readonly configuration;
255
+ private readonly services;
256
+ private subscribedUsers;
257
+ private fifoStack;
258
+ readonly myself: User;
259
+ constructor(myself: User, configuration: Configuration, services: UsersServices);
260
+ private handleUnsubscribeUser;
261
+ private handleSubscribeUser;
262
+ /**
263
+ * Gets user, if it's in subscribed list - then return the user object from it,
264
+ * if not - then subscribes and adds user to the FIFO stack
265
+ * @returns {Promise<User>} Fully initialized user
266
+ */
267
+ getUser(identity: string, entityName?: string): Promise<User>;
268
+ /**
269
+ * @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}
270
+ */
271
+ getSubscribedUsers(): Promise<Array<User>>;
272
+ /**
273
+ * @returns {Promise<string>} User's sync unique name
274
+ */
275
+ private getSyncUniqueName;
276
+ }
277
+ type ParticipantEvents = {
278
+ typingEnded: (participant: Participant) => void;
279
+ typingStarted: (participant: Participant) => void;
280
+ updated: (data: {
281
+ participant: Participant;
282
+ updateReasons: ParticipantUpdateReason[];
283
+ }) => void;
284
+ };
285
+ interface ParticipantDescriptor {
286
+ attributes?: Object;
287
+ dateCreated: any;
288
+ dateUpdated: any;
289
+ identity: string;
290
+ roleSid?: string;
291
+ lastConsumedMessageIndex: number;
292
+ lastConsumptionTimestamp: number;
293
+ type: ParticipantType;
294
+ userInfo: string;
295
+ }
296
+ interface ParticipantServices {
297
+ users: Users;
298
+ commandExecutor: CommandExecutor;
299
+ }
300
+ interface ParticipantLinks {
301
+ self: string;
302
+ }
303
+ /**
304
+ * The reason for the `updated` event being emitted by a participant.
305
+ */
306
+ type ParticipantUpdateReason = "attributes" | "dateCreated" | "dateUpdated" | "roleSid" | "lastReadMessageIndex" | "lastReadTimestamp";
307
+ /**
308
+ * Type of a participant.
309
+ */
310
+ type ParticipantType = "chat" | "sms" | "whatsapp";
311
+ interface ParticipantUpdatedEventArgs {
312
+ participant: Participant;
313
+ updateReasons: ParticipantUpdateReason[];
314
+ }
315
+ /**
316
+ * A participant represents a remote client in a conversation.
317
+ */
318
+ declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
319
+ private state;
320
+ private readonly links;
321
+ private readonly services;
322
+ /**
323
+ * Conversation that the remote client is a participant of.
324
+ */
325
+ readonly conversation: Conversation;
326
+ /**
327
+ * The server-assigned unique identifier for the participant.
328
+ */
329
+ get sid(): string;
330
+ /**
331
+ * Custom attributes of the participant.
332
+ */
333
+ get attributes(): Object;
334
+ /**
335
+ * Date this participant was created on.
336
+ */
337
+ get dateCreated(): Date;
338
+ /**
339
+ * Date this participant was last updated on.
340
+ */
341
+ get dateUpdated(): Date;
342
+ /**
343
+ * Identity of the participant.
344
+ */
345
+ get identity(): string;
346
+ /**
347
+ * Indicates whether the participant is currently typing.
348
+ */
349
+ get isTyping(): boolean;
350
+ /**
351
+ * The index of the last read message by the participant.
352
+ * Note that retrieving messages on a client endpoint does not mean that messages are read,
353
+ * please consider reading about the [Read Horizon feature](https://www.twilio.com/docs/api/chat/guides/consumption-horizon)
354
+ * to find out about the proper way to mark messages as read.
355
+ */
356
+ get lastReadMessageIndex(): number | null;
357
+ /**
358
+ * Date of the most recent read horizon update.
359
+ */
360
+ get lastReadTimestamp(): Date;
361
+ get roleSid(): string;
362
+ /**
363
+ * Message type of the participant.
364
+ */
365
+ get type(): ParticipantType;
366
+ /**
367
+ * @internal
368
+ */
369
+ constructor(data: ParticipantDescriptor, sid: string, conversation: Conversation, links: ParticipantLinks, services: ParticipantServices);
370
+ /**
371
+ * Fired when the participant has started typing.
372
+ *
373
+ * Parameters:
374
+ * 1. {@link Participant} `participant` - the participant in question
375
+ * @event
376
+ */
377
+ static readonly typingStarted = "typingStarted";
378
+ /**
379
+ * Fired when the participant has stopped typing.
380
+ *
381
+ * Parameters:
382
+ * 1. {@link Participant} `participant` - the participant in question
383
+ * @event
384
+ */
385
+ static readonly typingEnded = "typingEnded";
386
+ /**
387
+ * Fired when the fields of the participant have been updated.
388
+ *
389
+ * Parameters:
390
+ * 1. object `data` - info object provided with the event. It has the following properties:
391
+ * * {@link Participant} participant - the participant in question
392
+ * * {@link ParticipantUpdateReason}[] updateReasons - array of reasons for the update
393
+ * @event
394
+ */
395
+ static readonly updated = "updated";
396
+ /**
397
+ * Internal method used to start or reset the typing indicator timeout (with event emitting).
398
+ * @internal
399
+ */
400
+ _startTyping(timeout: any): this;
401
+ /**
402
+ * Internal method function used to stop the typing indicator timeout (with event emitting).
403
+ * @internal
404
+ */
405
+ _endTyping(): void;
406
+ /**
407
+ * Internal method function used update local object's property roleSid with a new value.
408
+ * @internal
409
+ */
410
+ _update(data: any): this;
411
+ /**
412
+ * Get the user for this participant and subscribes to it. Supported only for participants of type `chat`.
413
+ */
414
+ getUser(): Promise<User>;
415
+ /**
416
+ * Remove the participant from the conversation.
417
+ */
418
+ remove(): Promise<void>;
419
+ /**
420
+ * Update the attributes of the participant.
421
+ * @param attributes New attributes.
422
+ */
423
+ updateAttributes(attributes: any): Promise<Participant>;
424
+ }
425
+ /**
426
+ * Category of media. Possible values are as follows:
427
+ * * `'media'`
428
+ * * `'body'`
429
+ * * `'history'`
430
+ */
431
+ type MediaCategory$0 = McsMediaCategory;
432
+ interface MediaState {
433
+ sid: string;
434
+ category: MediaCategory$0;
435
+ filename?: string;
436
+ contentType: string;
437
+ size: number;
438
+ }
439
+ interface MediaServices {
440
+ mcsClient: McsClient;
441
+ }
442
+ /**
443
+ * Represents a media information for a message in a conversation.
444
+ */
445
+ declare class Media {
446
+ private state;
447
+ private services;
448
+ private mcsMedia;
449
+ /**
450
+ * @internal
451
+ */
452
+ constructor(data: MediaState | McsMedia, services: MediaServices);
453
+ /**
454
+ * Server-assigned unique identifier for the media.
455
+ */
456
+ get sid(): string;
457
+ /**
458
+ * File name. Null if absent.
459
+ */
460
+ get filename(): string;
461
+ /**
462
+ * Content type of the media.
463
+ */
464
+ get contentType(): string;
465
+ /**
466
+ * Size of the media in bytes.
467
+ */
468
+ get size(): number;
469
+ /**
470
+ * Media category, can be one of the {@link MediaCategory} values.
471
+ */
472
+ get category(): MediaCategory$0;
473
+ /**
474
+ * Returns the direct content URL for the media.
475
+ *
476
+ * This URL is impermanent, it will expire in several minutes and cannot be cached.
477
+ * If the URL becomes expired, you need to request a new one.
478
+ * Each call to this function produces a new temporary URL.
479
+ */
480
+ getContentTemporaryUrl(): Promise<string>;
481
+ /**
482
+ * Returns cached direct content URL for the media.
483
+ *
484
+ * This URL will expire in several minutes. This function does not refresh the URL and can be used to query it several times
485
+ * without causing network traffic.
486
+ * If the URL becomes expired, you need to request a new one using getContentTemporaryUrl().
487
+ *
488
+ * @returns {Promise<String>}
489
+ */
490
+ getCachedTemporaryUrl(): Promise<string>;
491
+ private _fetchMcsMedia;
492
+ }
493
+ /**
494
+ * Signifies the amount of participants which have the status for the message.
495
+ */
496
+ type DeliveryAmount = "none" | "some" | "all";
497
+ interface AggregatedDeliveryDescriptor {
498
+ total: number;
499
+ delivered: DeliveryAmount;
500
+ failed: DeliveryAmount;
501
+ read: DeliveryAmount;
502
+ sent: DeliveryAmount;
503
+ undelivered: DeliveryAmount;
504
+ }
505
+ /**
506
+ * Contains aggregated information about delivery statuses of a message across all participants
507
+ * of a conversation.
508
+ *
509
+ * At any moment during the message delivery to a participant, the message can have zero or more of following
510
+ * delivery statuses:
511
+ * * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
512
+ * * Message is considered as **delivered** to a participant if Twilio has received confirmation of message
513
+ * delivery from the upstream carrier, and, where available, the destination handset.
514
+ * * Message considered as **undelivered** to a participant if Twilio has received a delivery receipt
515
+ * indicating that the message was not delivered. This can happen for many reasons including carrier content
516
+ * filtering and the availability of the destination handset.
517
+ * * Message considered as **read** by a participant if the message has been delivered and opened by the
518
+ * recipient in a conversation. The recipient must have enabled the read receipts.
519
+ * * Message considered as **failed** to be delivered to a participant if the message could not be sent.
520
+ * This can happen for various reasons including queue overflows, account suspensions and media
521
+ * errors (in the case of MMS for instance).
522
+ *
523
+ * {@link AggregatedDeliveryReceipt} class contains an aggregated value {@link DeliveryAmount} for each delivery status.
524
+ */
525
+ declare class AggregatedDeliveryReceipt {
526
+ private state;
527
+ /**
528
+ * @internal
529
+ */
530
+ constructor(data: AggregatedDeliveryDescriptor);
531
+ /**
532
+ * Maximum number of delivery events expected for the message.
533
+ */
534
+ get total(): number;
535
+ /**
536
+ * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
537
+ *
538
+ * @return Amount of participants that have the **sent** delivery status for the message.
539
+ */
540
+ get sent(): DeliveryAmount;
541
+ /**
542
+ * Message is considered as **delivered** to a participant if Twilio has received confirmation of message
543
+ * delivery from the upstream carrier, and, where available, the destination handset.
544
+ *
545
+ * @return Amount of participants that have the **delivered** delivery status for the message.
546
+ */
547
+ get delivered(): DeliveryAmount;
548
+ /**
549
+ * Message is considered as **read** by a participant, if the message has been delivered and opened by the
550
+ * recipient in a conversation. The recipient must have enabled the read receipts.
551
+ *
552
+ * @return Amount of participants that have the **read** delivery status for the message.
553
+ */
554
+ get read(): DeliveryAmount;
555
+ /**
556
+ * Message is considered as **undelivered** to a participant if Twilio has received a delivery receipt
557
+ * indicating that the message was not delivered. This can happen for many reasons including carrier content
558
+ * filtering and the availability of the destination handset.
559
+ *
560
+ * @return Ammount of participants that have the **undelivered** delivery status for the message.
561
+ */
562
+ get undelivered(): DeliveryAmount;
563
+ /**
564
+ * Message is considered as **failed** to be delivered to a participant if the message could not be sent.
565
+ * This can happen for various reasons including queue overflows, account suspensions and media
566
+ * errors (in the case of MMS for instance). Twilio does not charge you for failed messages.
567
+ *
568
+ * @return Amount of participants that have the **failed** delivery status for the message.
569
+ */
570
+ get failed(): DeliveryAmount;
571
+ _update(data: AggregatedDeliveryDescriptor): void;
572
+ _isEquals(data: AggregatedDeliveryDescriptor): boolean;
573
+ }
574
+ /**
575
+ * Message delivery status.
576
+ */
577
+ type DeliveryStatus = "sent" | "delivered" | "failed" | "read" | "undelivered" | "queued";
578
+ interface DetailedDeliveryReceiptDescriptor {
579
+ sid: string;
580
+ message_sid: string;
581
+ conversation_sid: string;
582
+ channel_message_sid: string;
583
+ participant_sid: string;
584
+ status: DeliveryStatus;
585
+ error_code: number | null;
586
+ date_created: string;
587
+ date_updated: string;
588
+ }
589
+ /**
590
+ * Represents a delivery receipt of a message.
591
+ */
592
+ declare class DetailedDeliveryReceipt {
593
+ /**
594
+ * Unique identifier for the delivery receipt.
595
+ */
596
+ sid: string;
597
+ /**
598
+ * Unique identifier for the message in the conversation.
599
+ */
600
+ messageSid: string;
601
+ /**
602
+ * Unique identifier for the conversation.
603
+ */
604
+ conversationSid: string;
605
+ /**
606
+ * Unique identifier for the `‘channel’` message (e.g., `WAxx` for WhatsApp, `SMxx` for SMS).
607
+ */
608
+ channelMessageSid: string;
609
+ /**
610
+ * Unique identifier for the participant.
611
+ */
612
+ participantSid: string;
613
+ /**
614
+ * Status of the message delivery.
615
+ */
616
+ status: DeliveryStatus;
617
+ /**
618
+ * Numeric error code mapped from Status callback code. Information about the error codes can be found
619
+ * [here](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors).
620
+ */
621
+ errorCode: number | null;
622
+ /**
623
+ * Date this delivery receipt was created on.
624
+ */
625
+ dateCreated: string;
626
+ /**
627
+ * Date this delivery receipt was last updated on.
628
+ */
629
+ dateUpdated: string;
630
+ /**
631
+ * @internal
632
+ */
633
+ constructor(descriptor: DetailedDeliveryReceiptDescriptor);
634
+ }
635
+ type MessageEvents = {
636
+ updated: (data: {
637
+ message: Message;
638
+ updateReasons: MessageUpdateReason[];
639
+ }) => void;
640
+ };
641
+ interface MessageServices {
642
+ mcsClient: McsClient;
643
+ network: Network;
644
+ commandExecutor: CommandExecutor;
645
+ }
646
+ interface MessageLinks {
647
+ self: string;
648
+ conversation: string;
649
+ messages_receipts: string;
650
+ }
651
+ /**
652
+ * The reason for the `updated` event being emitted by a message.
653
+ */
654
+ type MessageUpdateReason = "body" | "lastUpdatedBy" | "dateCreated" | "dateUpdated" | "attributes" | "author" | "deliveryReceipt" | "subject";
655
+ /**
656
+ * Type of a message.
657
+ */
658
+ type MessageType = "text" | "media";
659
+ interface MessageUpdatedEventArgs {
660
+ message: Message;
661
+ updateReasons: MessageUpdateReason[];
662
+ }
663
+ /**
664
+ * A message in a conversation.
665
+ */
666
+ declare class Message extends ReplayEventEmitter<MessageEvents> {
667
+ /**
668
+ * Conversation that the message is in.
669
+ */
670
+ readonly conversation: Conversation;
671
+ private readonly links;
672
+ private readonly configuration;
673
+ private readonly services;
674
+ private state;
675
+ /**
676
+ * @internal
677
+ */
678
+ constructor(index: number, data: any, conversation: Conversation, links: MessageLinks, configuration: Configuration, services: MessageServices);
679
+ /**
680
+ * Fired when the properties or the body of the message has been updated.
681
+ *
682
+ * Parameters:
683
+ * 1. object `data` - info object provided with the event. It has the following properties:
684
+ * * {@link Message} message - the message in question
685
+ * * {@link MessageUpdateReason}[] updateReasons - array of reasons for the update
686
+ */
687
+ static readonly updated = "updated";
688
+ /**
689
+ * The server-assigned unique identifier for the message.
690
+ */
691
+ get sid(): string;
692
+ /**
693
+ * Name of the user that sent the message.
694
+ */
695
+ get author(): string;
696
+ /**
697
+ * Message subject. Used only in email conversations.
698
+ */
699
+ get subject(): string | null;
700
+ /**
701
+ * Body of the message.
702
+ */
703
+ get body(): string;
704
+ /**
705
+ * Date this message was last updated on.
706
+ */
707
+ get dateUpdated(): Date;
708
+ /**
709
+ * Index of the message in the conversation's messages list.
710
+ * By design of the Conversations system, the message indices may have arbitrary gaps between them,
711
+ * that does not necessarily mean they were deleted or otherwise modified - just that
712
+ * messages may have some non-contiguous indices even if they are being sent immediately one after another.
713
+ *
714
+ * Trying to use indices for some calculations is going to be unreliable.
715
+ *
716
+ * To calculate the number of unread messages it is better to use the read horizon API.
717
+ * See {@link Conversation.getUnreadMessagesCount} for details.
718
+ */
719
+ get index(): number;
720
+ /**
721
+ * Identity of the last user that updated the message.
722
+ */
723
+ get lastUpdatedBy(): string;
724
+ /**
725
+ * Date this message was created on.
726
+ */
727
+ get dateCreated(): Date;
728
+ /**
729
+ * Custom attributes of the message.
730
+ */
731
+ get attributes(): Object;
732
+ /**
733
+ * Push notification type of the message.
734
+ */
735
+ get type(): MessageType;
736
+ /**
737
+ * One of the attached media.
738
+ * @deprecated Use attachedMedia instead. Note that the latter is now an array.
739
+ */
740
+ get media(): Media;
741
+ /**
742
+ * Return all media attachments, except email body/history attachments, without temporary urls.
743
+ */
744
+ get attachedMedia(): Array<Media> | null;
745
+ /**
746
+ * The server-assigned unique identifier of the authoring participant.
747
+ */
748
+ get participantSid(): string;
749
+ /**
750
+ * Aggregated information about the message delivery statuses across all participants of a conversation..
751
+ */
752
+ get aggregatedDeliveryReceipt(): AggregatedDeliveryReceipt | null;
753
+ /**
754
+ * Return a (possibly empty) array of media matching a specific set of categories.
755
+ * Allowed category is so far only 'media'.
756
+ * @param categories Array of categories to match.
757
+ * @returns Array of media descriptors matching given categories.
758
+ */
759
+ getMediaByCategory(categories: Array<MediaCategory>): Array<Media> | null;
760
+ _update(data: any): void;
761
+ /**
762
+ * Get the participant who is the author of the message.
763
+ */
764
+ getParticipant(): Promise<Participant>;
765
+ /**
766
+ * Get the delivery receipts of the message.
767
+ */
768
+ getDetailedDeliveryReceipts(): Promise<DetailedDeliveryReceipt[]>;
769
+ /**
770
+ * Remove the message.
771
+ */
772
+ remove(): Promise<Message>;
773
+ /**
774
+ * Edit the message body.
775
+ * @param body New body of the message.
776
+ */
777
+ updateBody(body: string): Promise<Message>;
778
+ /**
779
+ * Edit the message attributes.
780
+ * @param attributes New attributes.
781
+ */
782
+ updateAttributes(attributes: any): Promise<Message>;
783
+ /**
784
+ * Get content URLs for all media attachments in the given set using single operation.
785
+ * @param contentSet Set of media attachments to query for content URL.
786
+ */
787
+ attachTemporaryUrlsFor(contentSet: Media[]): Promise<Media[]>;
788
+ private _getDetailedDeliveryReceiptsPaginator;
789
+ }
790
+ /**
791
+ * Pagination helper interface.
792
+ * @typeParam T The item type.
793
+ */
794
+ interface Paginator<T> {
795
+ /**
796
+ * Indicates the existence of the next page.
797
+ */
798
+ hasNextPage: boolean;
799
+ /**
800
+ * Indicates the existence of the previous page.
801
+ */
802
+ hasPrevPage: boolean;
803
+ /**
804
+ * Array of elements of type T on the current page.
805
+ */
806
+ items: T[];
807
+ /**
808
+ * Request next page.
809
+ * Does not modify the existing object.
810
+ */
811
+ nextPage(): Promise<Paginator<T>>;
812
+ /**
813
+ * Request previous page.
814
+ * Does not modify the existing object.
815
+ */
816
+ prevPage(): Promise<Paginator<T>>;
817
+ }
818
+ interface TypingIndicatorServices {
819
+ twilsockClient: TwilsockClient;
820
+ notificationClient: Notifications;
821
+ }
822
+ /**
823
+ * An important note in regards to typing timeout timers. There are two places that the SDK can get the "typing_timeout" attribute from. The first
824
+ * place that the attribute appears in is the response received from POST -> /v1/typing REST call. In the body of that response, the value of the
825
+ * "typing_timeout" attribute will be exactly the same as defined in the console. The second place that the attribute appears in is from a
826
+ * notification of type "twilio.ipmsg.typing_indicator". In this case, the "typing_timeout" value will be +1 of that in the console. This
827
+ * intentional. The timeout returned from the POST -> /v1/typing call should be used to disable further calls for that period of time. On contrary,
828
+ * the timeout returned from the notification should be used as the timeout for the "typingEnded" event, +1 is to account for latency.
829
+ *
830
+ * @private
831
+ */
832
+ /**
833
+ * @class TypingIndicator
834
+ *
835
+ * @constructor
836
+ * @private
837
+ */
838
+ declare class TypingIndicator {
839
+ private readonly services;
840
+ private readonly configuration;
841
+ private sentUpdates;
842
+ private getConversation;
843
+ private serviceTypingTimeout;
844
+ constructor(getConversation: any, config: Configuration, services: TypingIndicatorServices);
845
+ get typingTimeout(): number;
846
+ /**
847
+ * Initialize TypingIndicator controller
848
+ * Registers for needed message types and sets listeners
849
+ * @private
850
+ */
851
+ initialize(): void;
852
+ /**
853
+ * Remote participants typing events handler
854
+ */
855
+ private _handleRemoteTyping;
856
+ /**
857
+ * Send typing event for the given conversation sid
858
+ * @param {String} conversationSid
859
+ */
860
+ send(conversationSid: string): Promise<void>;
861
+ private _send;
862
+ }
863
+ /**
864
+ * An unsent message. Returned from {@link MessageBuilder.build}.
865
+ */
866
+ declare class UnsentMessage {
867
+ private messagesEntity;
868
+ text?: string;
869
+ attributes: any;
870
+ mediaContent: [MediaCategory, FormData | SendMediaOptions][];
871
+ emailOptions?: SendEmailOptions;
872
+ /**
873
+ * @internal
874
+ */
875
+ constructor(messagesEntity: any);
876
+ /**
877
+ * Send the prepared message to the conversation.
878
+ * @returns Index of the new message in the conversation.
879
+ */
880
+ send(): Promise<number>;
881
+ }
882
+ /**
883
+ * Message builder. Allows the message to be built and sent via method chaining.
884
+ *
885
+ * Example:
886
+ *
887
+ * ```ts
888
+ * await testConversation.prepareMessage()
889
+ * .setBody('Hello!')
890
+ * .setAttributes({foo: 'bar'})
891
+ * .addMedia(media1)
892
+ * .addMedia(media2)
893
+ * .build()
894
+ * .send();
895
+ * ```
896
+ */
897
+ declare class MessageBuilder {
898
+ private readonly limits;
899
+ private readonly message;
900
+ /**
901
+ * @internal
902
+ */
903
+ constructor(limits: Limits, messagesEntity: any);
904
+ /**
905
+ * Sets the message body.
906
+ * @param text Contents of the body.
907
+ */
908
+ setBody(text: string): MessageBuilder;
909
+ /**
910
+ * Sets the message subject.
911
+ * @param subject Contents of the subject.
912
+ */
913
+ setSubject(subject: string): MessageBuilder;
914
+ /**
915
+ * Sets the message attributes.
916
+ * @param attributes Message attributes.
917
+ */
918
+ setAttributes(attributes: any): MessageBuilder;
919
+ /**
920
+ * Adds media to the message.
921
+ * @param payload Media to add.
922
+ */
923
+ addMedia(payload: FormData | SendMediaOptions): MessageBuilder;
924
+ /**
925
+ * Builds the message, making it ready to be sent.
926
+ */
927
+ build(): UnsentMessage;
928
+ private getPayloadContentType;
929
+ }
930
+ type ConversationEvents = {
931
+ participantJoined: (participant: Participant) => void;
932
+ participantLeft: (participant: Participant) => void;
933
+ participantUpdated: (data: {
934
+ participant: Participant;
935
+ updateReasons: ParticipantUpdateReason[];
936
+ }) => void;
937
+ messageAdded: (message: Message) => void;
938
+ messageRemoved: (message: Message) => void;
939
+ messageUpdated: (data: {
940
+ message: Message;
941
+ updateReasons: MessageUpdateReason[];
942
+ }) => void;
943
+ typingEnded: (participant: Participant) => void;
944
+ typingStarted: (participant: Participant) => void;
945
+ updated: (data: {
946
+ conversation: Conversation;
947
+ updateReasons: ConversationUpdateReason[];
948
+ }) => void;
949
+ removed: (conversation: Conversation) => void;
950
+ };
951
+ interface ConversationServices {
952
+ users: Users;
953
+ typingIndicator: TypingIndicator;
954
+ network: Network;
955
+ mcsClient: McsClient;
956
+ syncClient: SyncClient;
957
+ commandExecutor: CommandExecutor;
958
+ }
959
+ interface ConversationDescriptor {
960
+ channel: string;
961
+ entityName: string;
962
+ uniqueName: string;
963
+ attributes: any;
964
+ createdBy?: string;
965
+ friendlyName?: string;
966
+ lastConsumedMessageIndex: number;
967
+ dateCreated: any;
968
+ dateUpdated: any;
969
+ notificationLevel?: NotificationLevel;
970
+ }
971
+ interface ConversationLinks {
972
+ self: string;
973
+ messages: string;
974
+ participants: string;
975
+ }
976
+ /**
977
+ * The reason for the `updated` event being emitted by a conversation.
978
+ */
979
+ type ConversationUpdateReason = "attributes" | "createdBy" | "dateCreated" | "dateUpdated" | "friendlyName" | "lastReadMessageIndex" | "state" | "status" | "uniqueName" | "lastMessage" | "notificationLevel";
980
+ /**
981
+ * The status of the conversation, relative to the client: whether
982
+ * the conversation has been `joined` or the client is
983
+ * `notParticipating` in the conversation.
984
+ */
985
+ type ConversationStatus = "notParticipating" | "joined";
986
+ /**
987
+ * The user's notification level for the conversation. Determines
988
+ * whether the currently logged-in user will receive pushes for events
989
+ * in this conversation. Can be either `muted` or `default`, where
990
+ * `default` defers to the global service push configuration.
991
+ */
992
+ type NotificationLevel = "default" | "muted";
993
+ /**
994
+ * The state of the conversation.
995
+ */
996
+ interface ConversationState {
997
+ /**
998
+ * The current state.
999
+ */
1000
+ current: "active" | "inactive" | "closed";
1001
+ /**
1002
+ * Date at which the latest conversation state update happened.
1003
+ */
1004
+ dateUpdated: Date;
1005
+ }
1006
+ interface ConversationUpdatedEventArgs {
1007
+ conversation: Conversation;
1008
+ updateReasons: ConversationUpdateReason[];
1009
+ }
1010
+ /**
1011
+ * Configuration for attaching a media file to a message.
1012
+ * These options can be passed to {@link Conversation.sendMessage}.
1013
+ */
1014
+ interface SendMediaOptions {
1015
+ /**
1016
+ * Content type of media.
1017
+ */
1018
+ contentType: string;
1019
+ /**
1020
+ * Optional filename.
1021
+ */
1022
+ filename?: string;
1023
+ /**
1024
+ * Content to post.
1025
+ */
1026
+ media: string | Buffer | Blob;
1027
+ }
1028
+ /**
1029
+ * These options can be passed to {@link Conversation.sendMessage}.
1030
+ */
1031
+ interface SendEmailOptions {
1032
+ /**
1033
+ * Message subject. Ignored for media messages.
1034
+ */
1035
+ subject?: string;
1036
+ }
1037
+ /**
1038
+ * Information about the last message of a conversation.
1039
+ */
1040
+ interface LastMessage {
1041
+ /**
1042
+ * Message's index.
1043
+ */
1044
+ index?: number;
1045
+ /**
1046
+ * Message's creation date.
1047
+ */
1048
+ dateCreated?: Date;
1049
+ }
1050
+ /**
1051
+ * A conversation represents communication between multiple Conversations clients
1052
+ */
1053
+ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1054
+ /**
1055
+ * Unique system identifier of the conversation.
1056
+ */
1057
+ readonly sid: string;
1058
+ readonly links: ConversationLinks;
1059
+ private readonly configuration;
1060
+ private readonly services;
1061
+ private channelState;
1062
+ private statusSource;
1063
+ private entityPromise;
1064
+ private entityName;
1065
+ private entity;
1066
+ private messagesEntity;
1067
+ private participantsEntity;
1068
+ private readonly participants;
1069
+ /**
1070
+ * @internal
1071
+ */
1072
+ constructor(descriptor: ConversationDescriptor, sid: string, links: ConversationLinks, configuration: Configuration, services: ConversationServices);
1073
+ /**
1074
+ * Fired when a participant has joined the conversation.
1075
+ *
1076
+ * Parameters:
1077
+ * 1. {@link Participant} `participant` - participant that joined the conversation
1078
+ * @event
1079
+ */
1080
+ static readonly participantJoined = "participantJoined";
1081
+ /**
1082
+ * Fired when a participant has left the conversation.
1083
+ *
1084
+ * Parameters:
1085
+ * 1. {@link Participant} `participant` - participant that left the conversation
1086
+ * @event
1087
+ */
1088
+ static readonly participantLeft = "participantLeft";
1089
+ /**
1090
+ * Fired when data of a participant has been updated.
1091
+ *
1092
+ * Parameters:
1093
+ * 1. object `data` - info object provided with the event. It has the following properties:
1094
+ * * {@link Participant} `participant` - participant that has received the update
1095
+ * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons for update
1096
+ * @event
1097
+ */
1098
+ static readonly participantUpdated = "participantUpdated";
1099
+ /**
1100
+ * Fired when a new message has been added to the conversation.
1101
+ *
1102
+ * Parameters:
1103
+ * 1. {@link Message} `message` - message that has been added
1104
+ * @event
1105
+ */
1106
+ static readonly messageAdded = "messageAdded";
1107
+ /**
1108
+ * Fired when message is removed from the conversation's message list.
1109
+ *
1110
+ * Parameters:
1111
+ * 1. {@link Message} `message` - message that has been removed
1112
+ * @event
1113
+ */
1114
+ static readonly messageRemoved = "messageRemoved";
1115
+ /**
1116
+ * Fired when data of a message has been updated.
1117
+ *
1118
+ * Parameters:
1119
+ * 1. object `data` - info object provided with the event. It has the following properties:
1120
+ * * {@link Message} `message` - message that has received the update
1121
+ * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for update
1122
+ * @event
1123
+ */
1124
+ static readonly messageUpdated = "messageUpdated";
1125
+ /**
1126
+ * Fired when a participant has stopped typing.
1127
+ *
1128
+ * Parameters:
1129
+ * 1. {@link Participant} `participant` - the participant that has stopped typing
1130
+ * @event
1131
+ */
1132
+ static readonly typingEnded = "typingEnded";
1133
+ /**
1134
+ * Fired when a participant has started typing.
1135
+ *
1136
+ * Parameters:
1137
+ * 1. {@link Participant} `participant` - the participant that has started typing
1138
+ * @event
1139
+ */
1140
+ static readonly typingStarted = "typingStarted";
1141
+ /**
1142
+ * Fired when the data of the conversation has been updated.
1143
+ *
1144
+ * Parameters:
1145
+ * 1. object `data` - info object provided with the event. It has the following properties:
1146
+ * * {@link Conversation} `conversation` - conversation that has received the update
1147
+ * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons for update
1148
+ * @event
1149
+ */
1150
+ static readonly updated = "updated";
1151
+ /**
1152
+ * Fired when the conversation was destroyed or the currently-logged-in user has left private conversation.
1153
+ *
1154
+ * Parameters:
1155
+ * 1. {@link Conversation} `conversation` - conversation that has been removed
1156
+ * @event
1157
+ */
1158
+ static readonly removed = "removed";
1159
+ /**
1160
+ * Unique name of the conversation.
1161
+ */
1162
+ get uniqueName(): string;
1163
+ /**
1164
+ * Status of the conversation.
1165
+ */
1166
+ get status(): ConversationStatus;
1167
+ /**
1168
+ * Name of the conversation.
1169
+ */
1170
+ get friendlyName(): string;
1171
+ /**
1172
+ * Date this conversation was last updated on.
1173
+ */
1174
+ get dateUpdated(): any;
1175
+ /**
1176
+ * Date this conversation was created on.
1177
+ */
1178
+ get dateCreated(): any;
1179
+ /**
1180
+ * Identity of the user that created this conversation.
1181
+ */
1182
+ get createdBy(): string;
1183
+ /**
1184
+ * Custom attributes of the conversation.
1185
+ */
1186
+ get attributes(): any;
1187
+ /**
1188
+ * Index of the last message the user has read in this conversation.
1189
+ */
1190
+ get lastReadMessageIndex(): number | null;
1191
+ /**
1192
+ * Last message sent to this conversation.
1193
+ */
1194
+ get lastMessage(): LastMessage;
1195
+ /**
1196
+ * User notification level for this conversation.
1197
+ */
1198
+ get notificationLevel(): NotificationLevel;
1199
+ get limits(): Limits;
1200
+ /**
1201
+ * State of the conversation.
1202
+ */
1203
+ get state(): ConversationState | undefined;
1204
+ /**
1205
+ * Load and subscribe to this conversation and do not subscribe to its participants and messages.
1206
+ * This or _subscribeStreams will need to be called before any events on conversation will fire.
1207
+ * @internal
1208
+ */
1209
+ _subscribe(): Promise<any>;
1210
+ /**
1211
+ * Load the attributes of this conversation and instantiate its participants and messages.
1212
+ * This or _subscribe will need to be called before any events on the conversation will fire.
1213
+ * This will need to be called before any events on participants or messages will fire
1214
+ * @internal
1215
+ */
1216
+ _subscribeStreams(): Promise<void>;
1217
+ /**
1218
+ * Stop listening for and firing events on this conversation.
1219
+ * @internal
1220
+ */
1221
+ _unsubscribe(): Promise<[
1222
+ void,
1223
+ any
1224
+ ]>;
1225
+ /**
1226
+ * Set conversation status.
1227
+ * @internal
1228
+ */
1229
+ _setStatus(status: ConversationStatus, source: ConversationsDataSource): void;
1230
+ /**
1231
+ * Get the source of the conversation update.
1232
+ * @internal
1233
+ */
1234
+ _statusSource(): ConversationsDataSource;
1235
+ private static preprocessUpdate;
1236
+ /**
1237
+ * Update the local conversation object with new values.
1238
+ * @internal
1239
+ */
1240
+ _update(update: any): void;
1241
+ /**
1242
+ * @internal
1243
+ */
1244
+ private _onMessageAdded;
1245
+ private _setLastReadMessageIndex;
1246
+ /**
1247
+ * Add a participant to the conversation by its identity.
1248
+ * @param identity Identity of the Client to add.
1249
+ * @param attributes Attributes to be attached to the participant.
1250
+ */
1251
+ add(identity: string, attributes?: any): Promise<void>;
1252
+ /**
1253
+ * Add a non-chat participant to the conversation.
1254
+ * @param proxyAddress Proxy (Twilio) address of the participant.
1255
+ * @param address User address of the participant.
1256
+ * @param attributes Attributes to be attached to the participant.
1257
+ */
1258
+ addNonChatParticipant(proxyAddress: string, address: string, attributes?: any): Promise<void>;
1259
+ /**
1260
+ * Advance the conversation's last read message index to the current read horizon.
1261
+ * Rejects if the user is not a participant of the conversation.
1262
+ * Last read message index is updated only if the new index value is higher than the previous.
1263
+ * @param index Message index to advance to.
1264
+ * @return Resulting unread messages count in the conversation.
1265
+ */
1266
+ advanceLastReadMessageIndex(index: number): Promise<number>;
1267
+ /**
1268
+ * Delete the conversation and unsubscribe from its events.
1269
+ */
1270
+ delete(): Promise<Conversation>;
1271
+ /**
1272
+ * Get the custom attributes of this Conversation.
1273
+ */
1274
+ getAttributes(): Promise<any>;
1275
+ /**
1276
+ * Returns messages from the conversation using the paginator interface.
1277
+ * @param pageSize Number of messages to return in a single chunk. Default is 30.
1278
+ * @param anchor Index of the newest message to fetch. Default is from the end.
1279
+ * @param direction Query direction. By default it queries backwards
1280
+ * from newer to older. The `"forward"` value will query in the opposite direction.
1281
+ * @return A page of messages.
1282
+ */
1283
+ getMessages(pageSize?: number, anchor?: number, direction?: "backwards" | "forward"): Promise<Paginator<Message>>;
1284
+ /**
1285
+ * Get a list of all the participants who are joined to this conversation.
1286
+ */
1287
+ getParticipants(): Promise<Participant[]>;
1288
+ /**
1289
+ * Get conversation participants count.
1290
+ *
1291
+ * This method is semi-realtime. This means that this data will be eventually correct,
1292
+ * but will also be possibly incorrect for a few seconds. The Conversations system does not
1293
+ * provide real time events for counter values changes.
1294
+ *
1295
+ * This is useful for any UI badges, but it is not recommended to build any core application
1296
+ * logic based on these counters being accurate in real time.
1297
+ */
1298
+ getParticipantsCount(): Promise<number>;
1299
+ /**
1300
+ * Get a participant by its SID.
1301
+ * @param participantSid Participant SID.
1302
+ */
1303
+ getParticipantBySid(participantSid: string): Promise<Participant>;
1304
+ /**
1305
+ * Get a participant by its identity.
1306
+ * @param identity Participant identity.
1307
+ */
1308
+ getParticipantByIdentity(identity: string): Promise<Participant>;
1309
+ /**
1310
+ * Get the total message count in the conversation.
1311
+ *
1312
+ * This method is semi-realtime. This means that this data will be eventually correct,
1313
+ * but will also be possibly incorrect for a few seconds. The Conversations system does not
1314
+ * provide real time events for counter values changes.
1315
+ *
1316
+ * This is useful for any UI badges, but it is not recommended to build any core application
1317
+ * logic based on these counters being accurate in real time.
1318
+ */
1319
+ getMessagesCount(): Promise<number>;
1320
+ /**
1321
+ * Get unread messages count for the user if they are a participant of this conversation.
1322
+ * Rejects if the user is not a participant of the conversation.
1323
+ *
1324
+ * Use this method to obtain the number of unread messages together with
1325
+ * {@link Conversation.updateLastReadMessageIndex} instead of relying on the
1326
+ * message indices which may have gaps. See {@link Message.index} for details.
1327
+ *
1328
+ * This method is semi-realtime. This means that this data will be eventually correct,
1329
+ * but will also be possibly incorrect for a few seconds. The Conversations system does not
1330
+ * provide real time events for counter values changes.
1331
+ *
1332
+ * This is useful for any UI badges, but it is not recommended to build any core application
1333
+ * logic based on these counters being accurate in real time.
1334
+ */
1335
+ getUnreadMessagesCount(): Promise<number | null>;
1336
+ /**
1337
+ * Join the conversation and subscribe to its events.
1338
+ */
1339
+ join(): Promise<Conversation>;
1340
+ /**
1341
+ * Leave the conversation.
1342
+ */
1343
+ leave(): Promise<Conversation>;
1344
+ /**
1345
+ * Remove a participant from the conversation. When a string is passed as the
1346
+ * argument, it will assume that the string is an identity or SID.
1347
+ * @param participant Identity, SID or the participant object to remove.
1348
+ */
1349
+ removeParticipant(participant: string | Participant): Promise<void>;
1350
+ /**
1351
+ * Send a message to the conversation.
1352
+ * @param message Message body for the text message,
1353
+ * `FormData` or {@link SendMediaOptions} for media content. Sending FormData is supported only with the browser engine.
1354
+ * @param messageAttributes Attributes for the message.
1355
+ * @param emailOptions Email options for the message.
1356
+ * @return Index of the new message.
1357
+ */
1358
+ sendMessage(message: string | FormData | SendMediaOptions | null, messageAttributes?: any, emailOptions?: SendEmailOptions): Promise<number>;
1359
+ /**
1360
+ * New interface to prepare for sending a message.
1361
+ * Use instead of `sendMessage`.
1362
+ */
1363
+ prepareMessage(): MessageBuilder;
1364
+ /**
1365
+ * Set last read message index of the conversation to the index of the last known message.
1366
+ * @return Resulting unread messages count in the conversation.
1367
+ */
1368
+ setAllMessagesRead(): Promise<number>;
1369
+ /**
1370
+ * Set all messages in the conversation unread.
1371
+ * @return Resulting unread messages count in the conversation.
1372
+ */
1373
+ setAllMessagesUnread(): Promise<number>;
1374
+ /**
1375
+ * Set user notification level for this conversation.
1376
+ * @param notificationLevel New user notification level.
1377
+ */
1378
+ setUserNotificationLevel(notificationLevel: NotificationLevel): Promise<void>;
1379
+ /**
1380
+ * Send a notification to the server indicating that this client is currently typing in this conversation.
1381
+ * Typing ended notification is sent after a while automatically, but by calling this method again you ensure that typing ended is not received.
1382
+ */
1383
+ typing(): Promise<void>;
1384
+ /**
1385
+ * Update the attributes of the conversation.
1386
+ * @param attributes New attributes.
1387
+ */
1388
+ updateAttributes(attributes: any): Promise<Conversation>;
1389
+ /**
1390
+ * Update the friendly name of the conversation.
1391
+ * @param friendlyName New friendly name.
1392
+ */
1393
+ updateFriendlyName(friendlyName: string): Promise<Conversation>;
1394
+ /**
1395
+ * Set the last read message index to the current read horizon.
1396
+ * @param index Message index to set as last read.
1397
+ * If null is provided, then the behavior is identical to {@link Conversation.setAllMessagesUnread}.
1398
+ * @returns Resulting unread messages count in the conversation.
1399
+ */
1400
+ updateLastReadMessageIndex(index: number | null): Promise<number>;
1401
+ /**
1402
+ * Update the unique name of the conversation.
1403
+ * @param uniqueName New unique name for the conversation. Setting unique name to null removes it.
1404
+ */
1405
+ updateUniqueName(uniqueName: string | null): Promise<Conversation>;
1406
+ }
1407
+ type ConversationsDataSource = "sync" | "chat" | "rest";
1408
+ /**
1409
+ * Push notification type.
1410
+ */
1411
+ type PushNotificationType = "twilio.conversations.new_message" | "twilio.conversations.added_to_conversation" | "twilio.conversations.removed_from_conversation";
1412
+ interface PushNotificationDescriptor {
1413
+ title: string;
1414
+ body: string;
1415
+ sound: string;
1416
+ badge: number;
1417
+ action: string;
1418
+ type: PushNotificationType;
1419
+ data: Object;
1420
+ }
1421
+ /**
1422
+ * Additional data for a given push notification.
1423
+ */
1424
+ interface PushNotificationData {
1425
+ /**
1426
+ * SID of the conversation.
1427
+ */
1428
+ conversationSid?: string;
1429
+ /**
1430
+ * Index of the message in the conversation.
1431
+ */
1432
+ messageIndex?: number;
1433
+ /**
1434
+ * SID of the message in the conversation.s
1435
+ */
1436
+ messageSid?: string;
1437
+ }
1438
+ /**
1439
+ * Push notification for a Conversations client.
1440
+ */
1441
+ declare class PushNotification {
1442
+ /**
1443
+ * Title of the notification.
1444
+ */
1445
+ readonly title: string;
1446
+ /**
1447
+ * Text of the notification.
1448
+ */
1449
+ readonly body: string;
1450
+ /**
1451
+ * Sound of the notification.
1452
+ */
1453
+ readonly sound: string;
1454
+ /**
1455
+ * Number of the badge.
1456
+ */
1457
+ readonly badge: number;
1458
+ /**
1459
+ * Notification action (`click_action` in FCM terms and `category` in APN terms).
1460
+ */
1461
+ readonly action: string;
1462
+ /**
1463
+ * Type of the notification.
1464
+ */
1465
+ readonly type: PushNotificationType;
1466
+ /**
1467
+ * Additional data of the conversation.
1468
+ */
1469
+ readonly data: PushNotificationData;
1470
+ /**
1471
+ * @internal
1472
+ */
1473
+ constructor(data: PushNotificationDescriptor);
1474
+ }
1475
+ type ClientEvents = {
1476
+ conversationAdded: (conversation: Conversation) => void;
1477
+ conversationJoined: (conversation: Conversation) => void;
1478
+ conversationLeft: (conversation: Conversation) => void;
1479
+ conversationRemoved: (conversation: Conversation) => void;
1480
+ conversationUpdated: (data: {
1481
+ conversation: Conversation;
1482
+ updateReasons: ConversationUpdateReason[];
1483
+ }) => void;
1484
+ participantJoined: (participant: Participant) => void;
1485
+ participantLeft: (participant: Participant) => void;
1486
+ participantUpdated: (data: {
1487
+ participant: Participant;
1488
+ updateReasons: ParticipantUpdateReason[];
1489
+ }) => void;
1490
+ messageAdded: (message: Message) => void;
1491
+ messageRemoved: (message: Message) => void;
1492
+ messageUpdated: (data: {
1493
+ message: Message;
1494
+ updateReasons: MessageUpdateReason[];
1495
+ }) => void;
1496
+ tokenAboutToExpire: (ttl: number) => void;
1497
+ tokenExpired: () => void;
1498
+ typingEnded: (participant: Participant) => void;
1499
+ typingStarted: (participant: Participant) => void;
1500
+ pushNotification: (pushNotification: PushNotification) => void;
1501
+ userSubscribed: (user: User) => void;
1502
+ userUnsubscribed: (user: User) => void;
1503
+ userUpdated: (data: {
1504
+ user: User;
1505
+ updateReasons: UserUpdateReason[];
1506
+ }) => void;
1507
+ stateChanged: (state: State) => void;
1508
+ connectionStateChanged: (state: TwilsockConnectionState) => void;
1509
+ connectionError: (data: {
1510
+ terminal: boolean;
1511
+ message: string;
1512
+ httpStatusCode?: number;
1513
+ errorCode?: number;
1514
+ }) => void;
1515
+ };
1516
+ /**
1517
+ * Connection state of the client. Possible values are as follows:
1518
+ * * `'connecting'` - client is offline and connection attempt is in process
1519
+ * * `'connected'` - client is online and ready
1520
+ * * `'disconnecting'` - client is going offline as disconnection is in process
1521
+ * * `'disconnected'` - client is offline and no connection attempt is in process
1522
+ * * `'denied'` - client connection is denied because of invalid JWT access token. User must refresh token in order to proceed
1523
+ */
1524
+ type ConnectionState = TwilsockConnectionState;
1525
+ /**
1526
+ * State of the client. Possible values are as follows:
1527
+ * * `'failed'` - the client failed to initialize
1528
+ * * `'initialized'` - the client successfully initialized
1529
+ */
1530
+ type State = "failed" | "initialized";
1531
+ /**
1532
+ * Notifications channel type. Possible values are as follows:
1533
+ * * `'fcm'`
1534
+ * * `'apn'`
1535
+ */
1536
+ type NotificationsChannelType = ChannelType;
1537
+ type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent" | null;
1538
+ /**
1539
+ * Conversations client options.
1540
+ */
1541
+ interface ClientOptions {
1542
+ /**
1543
+ * The level of logging to enable.
1544
+ */
1545
+ logLevel?: LogLevel;
1546
+ region?: string;
1547
+ productId?: string;
1548
+ twilsockClient?: TwilsockClient;
1549
+ transport?: Transport;
1550
+ notificationsClient?: NotificationClient;
1551
+ syncClient?: SyncClient;
1552
+ typingIndicatorTimeoutOverride?: number;
1553
+ consumptionReportIntervalOverride?: string;
1554
+ httpCacheIntervalOverride?: string;
1555
+ userInfosToSubscribeOverride?: number;
1556
+ retryWhenThrottledOverride?: boolean;
1557
+ backoffConfigOverride?: any;
1558
+ Chat?: any;
1559
+ IPMessaging?: any;
1560
+ Sync?: any;
1561
+ Notification?: any;
1562
+ Twilsock?: any;
1563
+ clientMetadata?: any;
1564
+ initRegistrations?: InitRegistration[];
1565
+ disableDeepClone?: boolean;
1566
+ }
1567
+ /**
1568
+ * Options for {@link Client.createConversation}.
1569
+ */
1570
+ interface CreateConversationOptions {
1571
+ /**
1572
+ * Any custom attributes to attach to the conversation.
1573
+ */
1574
+ attributes?: any;
1575
+ /**
1576
+ * A non-unique display name of the conversation.
1577
+ */
1578
+ friendlyName?: string;
1579
+ /**
1580
+ * A unique identifier of the conversation.
1581
+ */
1582
+ uniqueName?: string;
1583
+ }
1584
+ /**
1585
+ * A client is the starting point to the Twilio Conversations functionality.
1586
+ */
1587
+ declare class Client extends ReplayEventEmitter<ClientEvents> {
1588
+ /**
1589
+ * Client connection state.
1590
+ */
1591
+ connectionState: ConnectionState;
1592
+ private conversationsPromise;
1593
+ private _ensureReady;
1594
+ private _resolveEnsureReady;
1595
+ private _rejectEnsureReady;
1596
+ private fpaToken;
1597
+ private configuration;
1598
+ private conversations;
1599
+ private readonly options;
1600
+ private services;
1601
+ private readonly _myself;
1602
+ /**
1603
+ * Current version of the Conversations client.
1604
+ */
1605
+ static readonly version: string;
1606
+ /**
1607
+ * Current version of the Conversations client.
1608
+ */
1609
+ readonly version: string;
1610
+ private static readonly supportedPushChannels;
1611
+ private static readonly supportedPushDataFields;
1612
+ /**
1613
+ * Returned Conversations instance is not yet fully initialized. Calling any operations will block until it is.
1614
+ * Use connection events to monitor when client becomes fully available (connectionStateChanged with state
1615
+ * 'connected') or not available (connectionStateChange with state 'denied', event tokenExpired, event connectionError).
1616
+ *
1617
+ * @param fpaToken Access token
1618
+ * @param options Options to customize the Client
1619
+ * @returns A not yet fully-initialized client.
1620
+ */
1621
+ constructor(fpaToken: string, options?: ClientOptions);
1622
+ static populateInitRegistrations(reg: InitRegistration): void;
1623
+ /**
1624
+ * Fired when a conversation becomes visible to the client. The event is also triggered when the client creates a new conversation.
1625
+ * Fired for all conversations client has joined.
1626
+ *
1627
+ * Parameters:
1628
+ * 1. {@link Conversation} `conversation` - the conversation in question
1629
+ * @event
1630
+ */
1631
+ static readonly conversationAdded = "conversationAdded";
1632
+ /**
1633
+ * Fired when the client joins a conversation.
1634
+ *
1635
+ * Parameters:
1636
+ * 1. {@link Conversation} `conversation` - the conversation in question
1637
+ * @event
1638
+ */
1639
+ static readonly conversationJoined = "conversationJoined";
1640
+ /**
1641
+ * Fired when the client leaves a conversation.
1642
+ *
1643
+ * Parameters:
1644
+ * 1. {@link Conversation} `conversation` - the conversation in question
1645
+ * @event
1646
+ */
1647
+ static readonly conversationLeft = "conversationLeft";
1648
+ /**
1649
+ * Fired when a conversation is no longer visible to the client.
1650
+ *
1651
+ * Parameters:
1652
+ * 1. {@link Conversation} `conversation` - the conversation in question
1653
+ * @event
1654
+ */
1655
+ static readonly conversationRemoved = "conversationRemoved";
1656
+ /**
1657
+ * Fired when the attributes or the metadata of a conversation have been updated.
1658
+ * During conversation's creation and initialization, this event might be fired multiple times
1659
+ * for same joined or created conversation as new data is arriving from different sources.
1660
+ *
1661
+ * Parameters:
1662
+ * 1. object `data` - info object provided with the event. It has the following properties:
1663
+ * * {@link Conversation} `conversation` - the conversation in question
1664
+ * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons for the update
1665
+ * @event
1666
+ */
1667
+ static readonly conversationUpdated = "conversationUpdated";
1668
+ /**
1669
+ * Fired when a participant has joined a conversation.
1670
+ *
1671
+ * Parameters:
1672
+ * 1. {@link Participant} `participant` - the participant in question
1673
+ * @event
1674
+ */
1675
+ static readonly participantJoined = "participantJoined";
1676
+ /**
1677
+ * Fired when a participant has left a conversation.
1678
+ *
1679
+ * Parameters:
1680
+ * 1. {@link Participant} `participant` - the participant in question
1681
+ * @event
1682
+ */
1683
+ static readonly participantLeft = "participantLeft";
1684
+ /**
1685
+ * Fired when a participant's fields have been updated.
1686
+ *
1687
+ * Parameters:
1688
+ * 1. object `data` - info object provided with the event. It has the following properties:
1689
+ * * {@link Participant} `participant` - the participant in question
1690
+ * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons for the update
1691
+ * @event
1692
+ */
1693
+ static readonly participantUpdated = "participantUpdated";
1694
+ /**
1695
+ * Fired when a new message has been added to the conversation on the server.
1696
+ *
1697
+ * Parameters:
1698
+ * 1. {@link Message} `message` - the message in question
1699
+ * @event
1700
+ */
1701
+ static readonly messageAdded = "messageAdded";
1702
+ /**
1703
+ * Fired when a message is removed from the message list of a conversation.
1704
+ *
1705
+ * Parameters:
1706
+ * 1. {@link Message} `message` - the message in question
1707
+ * @event
1708
+ */
1709
+ static readonly messageRemoved = "messageRemoved";
1710
+ /**
1711
+ * Fired when the fields of an existing message are updated with new values.
1712
+ *
1713
+ * Parameters:
1714
+ * 1. object `data` - info object provided with the event. It has the following properties:
1715
+ * * {@link Message} `message` - the message in question
1716
+ * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for the update
1717
+ * @event
1718
+ */
1719
+ static readonly messageUpdated = "messageUpdated";
1720
+ /**
1721
+ * Fired when the token is about to expire and needs to be updated.
1722
+ * * Parameters:
1723
+ * 1. number `message` - token's time to live
1724
+ * @event
1725
+ */
1726
+ static readonly tokenAboutToExpire = "tokenAboutToExpire";
1727
+ /**
1728
+ * Fired when the token has expired.
1729
+ * @event
1730
+ */
1731
+ static readonly tokenExpired = "tokenExpired";
1732
+ /**
1733
+ * Fired when a participant has stopped typing.
1734
+ *
1735
+ * Parameters:
1736
+ * 1. {@link Participant} `participant` - the participant in question
1737
+ * @event
1738
+ */
1739
+ static readonly typingEnded = "typingEnded";
1740
+ /**
1741
+ * Fired when a participant has started typing.
1742
+ *
1743
+ * Parameters:
1744
+ * 1. {@link Participant} `participant` - the participant in question
1745
+ * @event
1746
+ */
1747
+ static readonly typingStarted = "typingStarted";
1748
+ /**
1749
+ * Fired when the client has received (and parsed) a push notification via one of the push channels (apn or fcm).
1750
+ *
1751
+ * Parameters:
1752
+ * 1. {@link PushNotification} `pushNotification` - the push notification in question
1753
+ * @event
1754
+ */
1755
+ static readonly pushNotification = "pushNotification";
1756
+ /**
1757
+ * Fired when the client has subscribed to a user.
1758
+ *
1759
+ * Parameters:
1760
+ * 1. {@link User} `user` - the user in question
1761
+ * @event
1762
+ */
1763
+ static readonly userSubscribed = "userSubscribed";
1764
+ /**
1765
+ * Fired when the client has unsubscribed from a user.
1766
+ *
1767
+ * Parameters:
1768
+ * 1. {@link User} `user` - the user in question
1769
+ * @event
1770
+ */
1771
+ static readonly userUnsubscribed = "userUnsubscribed";
1772
+ /**
1773
+ * Fired when the properties or the reachability status of a user have been updated.
1774
+ *
1775
+ * Parameters:
1776
+ * 1. object `data` - info object provided with the event. It has the following properties:
1777
+ * * {@link User} `user` - the user in question
1778
+ * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update
1779
+ * @event
1780
+ */
1781
+ static readonly userUpdated = "userUpdated";
1782
+ /**
1783
+ * Fired when the state of the client has been changed.
1784
+ *
1785
+ * Parameters:
1786
+ * 1. {@link State} `state` - the new client state
1787
+ * @event
1788
+ */
1789
+ static readonly stateChanged = "stateChanged";
1790
+ /**
1791
+ * Fired when the connection state of the client has been changed.
1792
+ *
1793
+ * Paremeters:
1794
+ * 1. {@link ConnectionState} `state` - the new connection state
1795
+ * @event
1796
+ */
1797
+ static readonly connectionStateChanged = "connectionStateChanged";
1798
+ /**
1799
+ * Fired when the connection is interrupted for an unexpected reason.
1800
+ *
1801
+ * Parameters:
1802
+ * 1. object `data` - info object provided with the event. It has the following properties:
1803
+ * * boolean `terminal` - Twilsock will stop connection attempts if true
1804
+ * * string `message` - the error message of the root cause
1805
+ * * number? `httpStatusCode` - http status code if available
1806
+ * * number? `errorCode` - Twilio public error code if available
1807
+ * @event
1808
+ */
1809
+ static readonly connectionError = "connectionError";
1810
+ /**
1811
+ * @deprecated Call constructor directly.
1812
+ *
1813
+ * Factory method to create a Conversations client instance.
1814
+ *
1815
+ * The factory method will automatically trigger connection.
1816
+ * Do not use it if you need finer-grained control.
1817
+ *
1818
+ * @param token Access token.
1819
+ * @param options Options to customize the client.
1820
+ * @returns Returns a fully initialized client.
1821
+ */
1822
+ static create(token: string, options?: ClientOptions): Promise<Client>;
1823
+ /**
1824
+ * Information of the logged-in user. Before client initialization, returns an
1825
+ * uninitialized user. Will trigger a {@link Client.userUpdated} event after
1826
+ * initialization.
1827
+ */
1828
+ get user(): User;
1829
+ /**
1830
+ * Client reachability state. Throws if accessed before the client
1831
+ * initialization was completed.
1832
+ */
1833
+ get reachabilityEnabled(): boolean;
1834
+ get token(): string;
1835
+ private _subscribeToPushNotifications;
1836
+ private _unsubscribeFromPushNotifications;
1837
+ private _initialize;
1838
+ /**
1839
+ * Gracefully shut down the client.
1840
+ */
1841
+ shutdown(): Promise<void>;
1842
+ /**
1843
+ * Update the token used by the client and re-register with the Conversations services.
1844
+ * @param token New access token.
1845
+ */
1846
+ updateToken(token: string): Promise<Client>;
1847
+ /**
1848
+ * Get a known conversation by its SID.
1849
+ * @param conversationSid Conversation sid
1850
+ */
1851
+ getConversationBySid(conversationSid: string): Promise<Conversation>;
1852
+ /**
1853
+ * Get a known conversation by its unique identifier name.
1854
+ * @param uniqueName The unique identifier name of the conversation.
1855
+ */
1856
+ getConversationByUniqueName(uniqueName: string): Promise<Conversation>;
1857
+ /**
1858
+ * Get the current list of all the subscribed conversations.
1859
+ */
1860
+ getSubscribedConversations(args?: any): Promise<Paginator<Conversation>>;
1861
+ /**
1862
+ * Create a conversation on the server and subscribe to its events.
1863
+ * The default is a conversation with an empty friendly name.
1864
+ * @param options Options for the conversation.
1865
+ */
1866
+ createConversation(options?: CreateConversationOptions): Promise<Conversation>;
1867
+ /**
1868
+ * Register for push notifications.
1869
+ * @param channelType Channel type.
1870
+ * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.
1871
+ */
1872
+ setPushRegistrationId(channelType: NotificationsChannelType, registrationId: string): Promise<void>;
1873
+ /**
1874
+ * Unregister from push notifications.
1875
+ * @param channelType Channel type.
1876
+ * @deprecated Use removePushRegistrations() instead.
1877
+ */
1878
+ unsetPushRegistrationId(channelType: NotificationsChannelType): Promise<void>;
1879
+ /**
1880
+ * Clear existing registrations directly using provided device token.
1881
+ * This is useful to ensure stopped subscriptions without resubscribing.
1882
+ *
1883
+ * This function goes completely beside the state machine and removes all registrations.
1884
+ * Use with caution: if it races with current state machine operations, madness will ensue.
1885
+ *
1886
+ * @param channelType Channel type.
1887
+ * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.
1888
+ */
1889
+ removePushRegistrations(channelType: ChannelType, registrationId: string): Promise<void>;
1890
+ private static parsePushNotificationChatData;
1891
+ /**
1892
+ * Static method for push notification payload parsing. Returns parsed push as a {@link PushNotification} object.
1893
+ * @param notificationPayload Push notification payload.
1894
+ */
1895
+ static parsePushNotification(notificationPayload: any): PushNotification;
1896
+ parsePushNotification: typeof Client.parsePushNotification;
1897
+ /**
1898
+ * Handle push notification payload parsing and emit the {@link Client.pushNotification} event on this {@link Client} instance.
1899
+ * @param notificationPayload Push notification payload
1900
+ */
1901
+ handlePushNotification(notificationPayload: any): Promise<void>;
1902
+ /**
1903
+ * Gets a user with the given identity. If it's in the subscribed list, then return the user object from it;
1904
+ * if not, then subscribe and add user to the subscribed list.
1905
+ * @param identity Identity of the user.
1906
+ * @returns A fully initialized user.
1907
+ */
1908
+ getUser(identity: string): Promise<User>;
1909
+ /**
1910
+ * Get a list of subscribed user objects.
1911
+ */
1912
+ getSubscribedUsers(): Promise<Array<User>>;
1913
+ }
1914
+ /**
1915
+ * Pagination helper class.
1916
+ */
1917
+ declare class RestPaginator<T> implements Paginator<T> {
1918
+ private state;
1919
+ /**
1920
+ * Indicates the existence of the next page.
1921
+ */
1922
+ get hasNextPage(): boolean;
1923
+ /**
1924
+ * Indicates the existence of the previous page
1925
+ */
1926
+ get hasPrevPage(): boolean;
1927
+ /**
1928
+ * Array of elements on the current page.
1929
+ */
1930
+ get items(): Array<T>;
1931
+ /**
1932
+ * @internal
1933
+ */
1934
+ constructor(items: any, source: any, prevToken: any, nextToken: any);
1935
+ /**
1936
+ * Request the next page. Does not modify the existing object.
1937
+ */
1938
+ nextPage(): Promise<RestPaginator<T>>;
1939
+ /**
1940
+ * Request the previous page. Does not modify the existing object.
1941
+ */
1942
+ prevPage(): Promise<RestPaginator<T>>;
1943
+ }
1944
+ export { Conversation, ConversationUpdateReason, ConversationStatus, NotificationLevel, ConversationState, ConversationUpdatedEventArgs, SendMediaOptions, SendEmailOptions, LastMessage, Participant, ParticipantUpdateReason, ParticipantType, ParticipantUpdatedEventArgs, Message, MessageUpdateReason, MessageType, MessageUpdatedEventArgs, Media, MediaCategory$0 as MediaCategory, AggregatedDeliveryReceipt, DeliveryAmount, DetailedDeliveryReceipt, DeliveryStatus, RestPaginator, MessageBuilder, UnsentMessage, Paginator, User, UserUpdateReason, UserUpdatedEventArgs, PushNotification, PushNotificationType, PushNotificationDescriptor, PushNotificationData, Client, State, ConnectionState, NotificationsChannelType, ClientOptions, CreateConversationOptions };