@twilio/conversations 2.1.0 → 3.0.0-canary.5

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 (72) hide show
  1. package/README.md +7 -3
  2. package/builds/browser.js +2346 -1627
  3. package/builds/browser.js.map +1 -1
  4. package/builds/lib.d.ts +510 -305
  5. package/builds/lib.js +2346 -1627
  6. package/builds/lib.js.map +1 -1
  7. package/builds/twilio-conversations.js +3373 -3347
  8. package/builds/twilio-conversations.min.js +2 -2
  9. package/dist/client.js +402 -281
  10. package/dist/client.js.map +1 -1
  11. package/dist/command-executor.js.map +1 -1
  12. package/dist/configuration.js +2 -2
  13. package/dist/configuration.js.map +1 -1
  14. package/dist/conversation.js +406 -374
  15. package/dist/conversation.js.map +1 -1
  16. package/dist/data/conversations.js +9 -10
  17. package/dist/data/conversations.js.map +1 -1
  18. package/dist/data/messages.js +46 -26
  19. package/dist/data/messages.js.map +1 -1
  20. package/dist/data/participants.js +19 -10
  21. package/dist/data/participants.js.map +1 -1
  22. package/dist/data/users.js +2 -2
  23. package/dist/data/users.js.map +1 -1
  24. package/dist/media.js +36 -25
  25. package/dist/media.js.map +1 -1
  26. package/dist/message-builder.js +24 -18
  27. package/dist/message-builder.js.map +1 -1
  28. package/dist/message.js +46 -19
  29. package/dist/message.js.map +1 -1
  30. package/dist/packages/conversations/package.json.js +1 -1
  31. package/dist/participant.js.map +1 -1
  32. package/dist/push-notification.js.map +1 -1
  33. package/dist/services/typing-indicator.js +1 -1
  34. package/dist/services/typing-indicator.js.map +1 -1
  35. package/dist/unsent-message.js +13 -3
  36. package/dist/unsent-message.js.map +1 -1
  37. package/package.json +10 -8
  38. package/CHANGELOG.md +0 -420
  39. package/docs/assets/css/main.css +0 -2660
  40. package/docs/assets/images/icons.png +0 -0
  41. package/docs/assets/images/icons@2x.png +0 -0
  42. package/docs/assets/images/widgets.png +0 -0
  43. package/docs/assets/images/widgets@2x.png +0 -0
  44. package/docs/assets/js/main.js +0 -248
  45. package/docs/assets/js/search.js +0 -1
  46. package/docs/classes/AggregatedDeliveryReceipt.html +0 -3184
  47. package/docs/classes/Client.html +0 -4073
  48. package/docs/classes/Conversation.html +0 -4325
  49. package/docs/classes/DetailedDeliveryReceipt.html +0 -3163
  50. package/docs/classes/Media.html +0 -3193
  51. package/docs/classes/Message.html +0 -3677
  52. package/docs/classes/MessageBuilder.html +0 -3254
  53. package/docs/classes/Participant.html +0 -3444
  54. package/docs/classes/PushNotification.html +0 -3130
  55. package/docs/classes/RestPaginator.html +0 -3160
  56. package/docs/classes/UnsentMessage.html +0 -3042
  57. package/docs/classes/User.html +0 -3349
  58. package/docs/index.html +0 -3512
  59. package/docs/interfaces/ClientOptions.html +0 -3034
  60. package/docs/interfaces/ConversationBindings.html +0 -3001
  61. package/docs/interfaces/ConversationEmailBinding.html +0 -3001
  62. package/docs/interfaces/ConversationLimits.html +0 -3098
  63. package/docs/interfaces/ConversationState.html +0 -3050
  64. package/docs/interfaces/CreateConversationOptions.html +0 -3066
  65. package/docs/interfaces/LastMessage.html +0 -3050
  66. package/docs/interfaces/Paginator.html +0 -3141
  67. package/docs/interfaces/ParticipantBindings.html +0 -3001
  68. package/docs/interfaces/ParticipantEmailBinding.html +0 -3001
  69. package/docs/interfaces/PushNotificationData.html +0 -3066
  70. package/docs/interfaces/SendEmailOptions.html +0 -3034
  71. package/docs/interfaces/SendMediaOptions.html +0 -3068
  72. package/docs/modules.html +0 -3513
package/builds/lib.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import { SyncClient, SyncDocument, SyncList } from "twilio-sync";
2
2
  import { LogLevelDesc } from "loglevel";
3
- import { Transport, TwilsockClient, InitRegistration, TransportResult } from "twilsock";
3
+ import { Transport, TwilsockClient, InitRegistration, ConnectionError, TransportResult } from "twilsock";
4
4
  import { ConnectionState as TwilsockConnectionState } from "twilsock";
5
5
  import { ReplayEventEmitter } from "@twilio/replay-event-emitter";
6
6
  import { ChannelType, Notifications } from "@twilio/notifications";
7
7
  import { Notifications as NotificationClient } from "@twilio/notifications";
8
- import { McsClient, MediaCategory, McsMedia } from "@twilio/mcs-client";
8
+ import { CancellablePromise, McsClient, MediaCategory, McsMedia } from "@twilio/mcs-client";
9
9
  import { MediaCategory as McsMediaCategory } from "@twilio/mcs-client";
10
10
  interface ConfigurationResponse {
11
11
  options: {
@@ -72,13 +72,13 @@ interface ConversationLimits {
72
72
  */
73
73
  mediaAttachmentsTotalSizeLimitInMb: number;
74
74
  /**
75
- * Allowed mime types for E-Mail histories.
75
+ * Allowed content types for E-Mail histories.
76
76
  */
77
- emailHistoriesAllowedMimeTypes: string[];
77
+ emailHistoriesAllowedContentTypes: string[];
78
78
  /**
79
- * Allowed mime types for E-Mail bodies.
79
+ * Allowed content types for E-Mail bodies.
80
80
  */
81
- emailBodiesAllowedMimeTypes: string[];
81
+ emailBodiesAllowedContentTypes: string[];
82
82
  }
83
83
  interface BackoffConfiguration {
84
84
  min: number;
@@ -301,7 +301,7 @@ declare class Users extends ReplayEventEmitter<UsersEvents> {
301
301
  * if not - then subscribes and adds user to the FIFO stack
302
302
  * @returns {Promise<User>} Fully initialized user
303
303
  */
304
- getUser(identity?: string, entityName?: string): Promise<User>;
304
+ getUser(identity: string, entityName?: string): Promise<User>;
305
305
  /**
306
306
  * @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}
307
307
  */
@@ -326,9 +326,9 @@ interface ParticipantDescriptor {
326
326
  identity: string;
327
327
  roleSid?: string;
328
328
  lastConsumedMessageIndex: number | null;
329
- lastConsumptionTimestamp: number;
329
+ lastConsumptionTimestamp: number | null;
330
330
  type: ParticipantType;
331
- userInfo: string;
331
+ userInfo?: string;
332
332
  bindings?: ParticipantBindings;
333
333
  }
334
334
  interface ParticipantServices {
@@ -490,26 +490,6 @@ declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
490
490
  */
491
491
  updateAttributes(attributes: JSONValue): Promise<Participant>;
492
492
  }
493
- interface ParticipantResponse {
494
- account_sid: string;
495
- chat_service_sid: string;
496
- conversation_sid: string;
497
- role_sid: string;
498
- sid: string;
499
- attributes: string;
500
- date_created: string;
501
- date_updated: string;
502
- identity: string | null;
503
- messaging_binding: {
504
- type: string;
505
- address: string;
506
- proxy_address: string;
507
- } | null;
508
- url: string;
509
- links: {
510
- conversation: string;
511
- };
512
- }
513
493
  interface ParticipantBindingOptions {
514
494
  email?: ParticipantEmailBinding;
515
495
  }
@@ -568,17 +548,7 @@ declare class Media {
568
548
  * If the URL becomes expired, you need to request a new one.
569
549
  * Each call to this function produces a new temporary URL.
570
550
  */
571
- getContentTemporaryUrl(): Promise<string | null>;
572
- /**
573
- * Returns cached direct content URL for the media.
574
- *
575
- * This URL will expire in several minutes. This function does not refresh the URL and can be used to query it several times
576
- * without causing network traffic.
577
- * If the URL becomes expired, you need to request a new one using getContentTemporaryUrl().
578
- *
579
- * @returns {Promise<String>}
580
- */
581
- getCachedTemporaryUrl(): Promise<string | null>;
551
+ getContentTemporaryUrl(): CancellablePromise<string | null>;
582
552
  private _fetchMcsMedia;
583
553
  }
584
554
  /**
@@ -862,16 +832,16 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
862
832
  * @param categories Array of categories to match.
863
833
  * @returns Array of media descriptors matching given categories.
864
834
  */
865
- getMediaByCategory(categories: Array<MediaCategory>): Array<Media> | null;
835
+ getMediaByCategories(categories: MediaCategory[]): Media[] | null;
866
836
  /**
867
837
  * Get a media descriptor for an email body attachment of a provided type.
868
- * Allowed body types are returned in the Conversation.limits().emailBodiesAllowedMimeTypes array.
838
+ * Allowed body types are returned in the Conversation.limits().emailBodiesAllowedContentTypes array.
869
839
  * @param type Type of email body to request, defaults to `text/plain`.
870
840
  */
871
841
  getEmailBody(type?: string): Media | null;
872
842
  /**
873
843
  * Get a media descriptor for an email history attachment of a provided type.
874
- * Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedMimeTypes array.
844
+ * Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedContentTypes array.
875
845
  * @param type Type of email history to request, defaults to `text/plain`.
876
846
  */
877
847
  getEmailHistory(type?: string): Media | null;
@@ -899,10 +869,19 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
899
869
  */
900
870
  updateAttributes(attributes: JSONValue): Promise<Message>;
901
871
  /**
902
- * Get content URLs for all media attachments in the given set using single operation.
903
- * @param contentSet Set of media attachments to query for content URL.
872
+ * Get content URLs for all media attachments in the given set using a single operation.
873
+ * @param contentSet Set of media attachments to query content URLs.
874
+ */
875
+ getTemporaryContentUrlsForMedia(contentSet: Media[] | null): CancellablePromise<Map<string, string>>;
876
+ /**
877
+ * Get content URLs for all media attachments in the given set of media sids using a single operation.
878
+ * @param mediaSids Set of media sids to query for the content URL.
904
879
  */
905
- attachTemporaryUrlsFor(contentSet: Media[] | null): Promise<Media[]>;
880
+ getTemporaryContentUrlsForMediaSids(mediaSids: string[]): CancellablePromise<Map<string, string>>;
881
+ /**
882
+ * Get content URLs for all media attached to the message.
883
+ */
884
+ getTemporaryContentUrlsForAttachedMedia(): CancellablePromise<Map<string, string>>;
906
885
  private _getDetailedDeliveryReceiptsPaginator;
907
886
  }
908
887
  /**
@@ -959,7 +938,7 @@ declare class TypingIndicator {
959
938
  private sentUpdates;
960
939
  private getConversation;
961
940
  private serviceTypingTimeout;
962
- constructor(getConversation: any, config: Configuration, services: TypingIndicatorServices);
941
+ constructor(getConversation: (conversationSid: string) => Promise<Conversation>, config: Configuration, services: TypingIndicatorServices);
963
942
  get typingTimeout(): number;
964
943
  /**
965
944
  * Initialize TypingIndicator controller
@@ -978,25 +957,6 @@ declare class TypingIndicator {
978
957
  send(conversationSid: string): Promise<void>;
979
958
  private _send;
980
959
  }
981
- /**
982
- * An unsent message. Returned from {@link MessageBuilder.build}.
983
- */
984
- declare class UnsentMessage {
985
- private messagesEntity;
986
- text?: string;
987
- attributes: JSONValue;
988
- mediaContent: [MediaCategory, FormData | SendMediaOptions][];
989
- emailOptions: SendEmailOptions;
990
- /**
991
- * @internal
992
- */
993
- constructor(messagesEntity: any);
994
- /**
995
- * Send the prepared message to the conversation.
996
- * @returns Index of the new message in the conversation.
997
- */
998
- send(): Promise<number | null>;
999
- }
1000
960
  /**
1001
961
  * Pagination helper class.
1002
962
  */
@@ -1103,11 +1063,10 @@ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
1103
1063
  subscribe(name: string): Promise<SyncList>;
1104
1064
  unsubscribe(): Promise<void>;
1105
1065
  /**
1106
- * Send Message to the conversation, message could include both text and multiple media attachments.
1066
+ * Send a message to the conversation. The message could include text and multiple media attachments.
1107
1067
  * @param message Message to post
1108
- * @returns Returns a promise which can fail
1109
1068
  */
1110
- sendV2(message: UnsentMessage): Promise<MessageResponse>;
1069
+ sendV2(message: UnsentMessage): CancellablePromise<MessageResponse>;
1111
1070
  /**
1112
1071
  * Send Message to the conversation
1113
1072
  * @param message Message to post
@@ -1144,6 +1103,25 @@ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
1144
1103
  */
1145
1104
  private _getMessages;
1146
1105
  }
1106
+ /**
1107
+ * An unsent message. Returned from {@link MessageBuilder.build}.
1108
+ */
1109
+ declare class UnsentMessage {
1110
+ private messagesEntity;
1111
+ text?: string;
1112
+ attributes: JSONValue;
1113
+ mediaContent: [MediaCategory, FormData | SendMediaOptions][];
1114
+ emailOptions: SendEmailOptions;
1115
+ /**
1116
+ * @internal
1117
+ */
1118
+ constructor(messagesEntity: Messages);
1119
+ /**
1120
+ * Send the prepared message to the conversation.
1121
+ * @returns Index of the new message in the conversation.
1122
+ */
1123
+ send(): CancellablePromise<number | null>;
1124
+ }
1147
1125
  /**
1148
1126
  * Message builder. Allows the message to be built and sent via method chaining.
1149
1127
  *
@@ -1184,17 +1162,17 @@ declare class MessageBuilder {
1184
1162
  */
1185
1163
  setAttributes(attributes: JSONValue): MessageBuilder;
1186
1164
  /**
1187
- * Set email body with given MIME-type.
1188
- * @param mimeType Format of the body to set (text/plain or text/html).
1189
- * @param body Body payload in selected format.
1165
+ * Set the email body with a given content type.
1166
+ * @param contentType Format of the body to set (text/plain or text/html).
1167
+ * @param body Body payload in the selected format.
1190
1168
  */
1191
- setEmailBody(mimeType: string, body: FormData | SendMediaOptions): MessageBuilder;
1169
+ setEmailBody(contentType: string, body: FormData | SendMediaOptions): MessageBuilder;
1192
1170
  /**
1193
- * Set email history with given MIME-type.
1194
- * @param mimeType Format of the history to set (text/plain or text/html).
1195
- * @param history History payload in selected format.
1171
+ * Set the email history with a given content type.
1172
+ * @param contentType Format of the history to set (text/plain or text/html).
1173
+ * @param history History payload in the selected format.
1196
1174
  */
1197
- setEmailHistory(mimeType: string, history: FormData | SendMediaOptions): MessageBuilder;
1175
+ setEmailHistory(contentType: string, history: FormData | SendMediaOptions): MessageBuilder;
1198
1176
  /**
1199
1177
  * Adds media to the message.
1200
1178
  * @param payload Media to add.
@@ -1204,8 +1182,15 @@ declare class MessageBuilder {
1204
1182
  * Builds the message, making it ready to be sent.
1205
1183
  */
1206
1184
  build(): UnsentMessage;
1185
+ /**
1186
+ * Prepares a message and sends it to the conversation.
1187
+ */
1188
+ buildAndSend(): CancellablePromise<number | null>;
1207
1189
  private getPayloadContentType;
1208
1190
  }
1191
+ /**
1192
+ * Conversation events.
1193
+ */
1209
1194
  type ConversationEvents = {
1210
1195
  participantJoined: (participant: Participant) => void;
1211
1196
  participantLeft: (participant: Participant) => void;
@@ -1227,55 +1212,28 @@ type ConversationEvents = {
1227
1212
  }) => void;
1228
1213
  removed: (conversation: Conversation) => void;
1229
1214
  };
1230
- interface ConversationServices {
1231
- users: Users;
1232
- typingIndicator: TypingIndicator;
1233
- network: Network;
1234
- mcsClient: McsClient;
1235
- syncClient: SyncClient;
1236
- commandExecutor: CommandExecutor;
1237
- }
1238
- interface ConversationDescriptor {
1239
- channel: string;
1240
- entityName: string;
1241
- uniqueName: string;
1242
- attributes: JSONValue;
1243
- createdBy?: string;
1244
- friendlyName?: string;
1245
- lastConsumedMessageIndex: number;
1246
- dateCreated: Date | null;
1247
- dateUpdated: Date | null;
1248
- notificationLevel?: NotificationLevel;
1249
- bindings?: ConversationBindings;
1250
- }
1251
- interface ConversationLinks {
1252
- self: string;
1253
- messages: string;
1254
- participants: string;
1255
- }
1256
1215
  /**
1257
- * The reason for the `updated` event being emitted by a conversation.
1216
+ * Reason for the `updated` event emission by a conversation.
1258
1217
  */
1259
1218
  type ConversationUpdateReason = "attributes" | "createdBy" | "dateCreated" | "dateUpdated" | "friendlyName" | "lastReadMessageIndex" | "state" | "status" | "uniqueName" | "lastMessage" | "notificationLevel" | "bindings";
1260
1219
  /**
1261
- * The status of the conversation, relative to the client: whether
1262
- * the conversation has been `joined` or the client is
1263
- * `notParticipating` in the conversation.
1220
+ * Status of the conversation, relative to the client: whether the conversation
1221
+ * has been `joined` or the client is `notParticipating` in the conversation.
1264
1222
  */
1265
1223
  type ConversationStatus = "notParticipating" | "joined";
1266
1224
  /**
1267
- * The user's notification level for the conversation. Determines
1225
+ * User's notification level for the conversation. Determines
1268
1226
  * whether the currently logged-in user will receive pushes for events
1269
1227
  * in this conversation. Can be either `muted` or `default`, where
1270
1228
  * `default` defers to the global service push configuration.
1271
1229
  */
1272
1230
  type NotificationLevel = "default" | "muted";
1273
1231
  /**
1274
- * The state of the conversation.
1232
+ * State of the conversation.
1275
1233
  */
1276
1234
  interface ConversationState {
1277
1235
  /**
1278
- * The current state.
1236
+ * Current state.
1279
1237
  */
1280
1238
  current: "active" | "inactive" | "closed";
1281
1239
  /**
@@ -1283,6 +1241,9 @@ interface ConversationState {
1283
1241
  */
1284
1242
  dateUpdated: Date;
1285
1243
  }
1244
+ /**
1245
+ * Event arguments for the `updated` event.
1246
+ */
1286
1247
  interface ConversationUpdatedEventArgs {
1287
1248
  conversation: Conversation;
1288
1249
  updateReasons: ConversationUpdateReason[];
@@ -1301,6 +1262,9 @@ interface ConversationEmailBinding {
1301
1262
  name?: string;
1302
1263
  projected_address: string;
1303
1264
  }
1265
+ /**
1266
+ * Binding for SMS conversation.
1267
+ */
1304
1268
  interface ConversationSmsBinding {
1305
1269
  address?: string;
1306
1270
  }
@@ -1346,33 +1310,51 @@ interface LastMessage {
1346
1310
  dateCreated?: Date;
1347
1311
  }
1348
1312
  /**
1349
- * A conversation represents communication between multiple Conversations clients
1313
+ * Conversation services.
1314
+ */
1315
+ interface ConversationServices {
1316
+ users: Users;
1317
+ typingIndicator: TypingIndicator;
1318
+ network: Network;
1319
+ mcsClient: McsClient;
1320
+ syncClient: SyncClient;
1321
+ commandExecutor: CommandExecutor;
1322
+ }
1323
+ /**
1324
+ * Conversation descriptor.
1325
+ */
1326
+ interface ConversationDescriptor {
1327
+ channel: string;
1328
+ entityName: string;
1329
+ uniqueName: string;
1330
+ attributes: JSONValue;
1331
+ createdBy?: string;
1332
+ friendlyName?: string;
1333
+ lastConsumedMessageIndex: number;
1334
+ dateCreated: Date | null;
1335
+ dateUpdated: Date | null;
1336
+ notificationLevel?: NotificationLevel;
1337
+ bindings?: ConversationBindings;
1338
+ }
1339
+ /**
1340
+ * Conversation links.
1341
+ */
1342
+ interface ConversationLinks {
1343
+ self: string;
1344
+ messages: string;
1345
+ participants: string;
1346
+ }
1347
+ /**
1348
+ * A conversation represents communication between multiple Conversations
1349
+ * clients.
1350
1350
  */
1351
1351
  declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1352
- /**
1353
- * Unique system identifier of the conversation.
1354
- */
1355
- readonly sid: string;
1356
- readonly links: ConversationLinks;
1357
- private readonly configuration;
1358
- private readonly services;
1359
- private channelState;
1360
- private statusSource;
1361
- private entityPromise;
1362
- private entityName;
1363
- private entity;
1364
- private messagesEntity;
1365
- private participantsEntity;
1366
- private readonly participants;
1367
- /**
1368
- * @internal
1369
- */
1370
- constructor(descriptor: ConversationDescriptor, sid: string, links: ConversationLinks, configuration: Configuration, services: ConversationServices);
1371
1352
  /**
1372
1353
  * Fired when a participant has joined the conversation.
1373
1354
  *
1374
1355
  * Parameters:
1375
- * 1. {@link Participant} `participant` - participant that joined the conversation
1356
+ * 1. {@link Participant} `participant` - participant that joined the
1357
+ * conversation
1376
1358
  * @event
1377
1359
  */
1378
1360
  static readonly participantJoined = "participantJoined";
@@ -1380,7 +1362,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1380
1362
  * Fired when a participant has left the conversation.
1381
1363
  *
1382
1364
  * Parameters:
1383
- * 1. {@link Participant} `participant` - participant that left the conversation
1365
+ * 1. {@link Participant} `participant` - participant that left the
1366
+ * conversation
1384
1367
  * @event
1385
1368
  */
1386
1369
  static readonly participantLeft = "participantLeft";
@@ -1388,9 +1371,12 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1388
1371
  * Fired when data of a participant has been updated.
1389
1372
  *
1390
1373
  * Parameters:
1391
- * 1. object `data` - info object provided with the event. It has the following properties:
1392
- * * {@link Participant} `participant` - participant that has received the update
1393
- * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons for update
1374
+ * 1. object `data` - info object provided with the event. It has the
1375
+ * following properties:
1376
+ * * {@link Participant} `participant` - participant that has received the
1377
+ * update
1378
+ * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
1379
+ * for the update
1394
1380
  * @event
1395
1381
  */
1396
1382
  static readonly participantUpdated = "participantUpdated";
@@ -1414,9 +1400,11 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1414
1400
  * Fired when data of a message has been updated.
1415
1401
  *
1416
1402
  * Parameters:
1417
- * 1. object `data` - info object provided with the event. It has the following properties:
1403
+ * 1. object `data` - info object provided with the event. It has the
1404
+ * following properties:
1418
1405
  * * {@link Message} `message` - message that has received the update
1419
- * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for update
1406
+ * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
1407
+ * the update
1420
1408
  * @event
1421
1409
  */
1422
1410
  static readonly messageUpdated = "messageUpdated";
@@ -1424,7 +1412,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1424
1412
  * Fired when a participant has stopped typing.
1425
1413
  *
1426
1414
  * Parameters:
1427
- * 1. {@link Participant} `participant` - the participant that has stopped typing
1415
+ * 1. {@link Participant} `participant` - the participant that has stopped
1416
+ * typing
1428
1417
  * @event
1429
1418
  */
1430
1419
  static readonly typingEnded = "typingEnded";
@@ -1432,7 +1421,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1432
1421
  * Fired when a participant has started typing.
1433
1422
  *
1434
1423
  * Parameters:
1435
- * 1. {@link Participant} `participant` - the participant that has started typing
1424
+ * 1. {@link Participant} `participant` - the participant that has started
1425
+ * typing
1436
1426
  * @event
1437
1427
  */
1438
1428
  static readonly typingStarted = "typingStarted";
@@ -1440,20 +1430,87 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1440
1430
  * Fired when the data of the conversation has been updated.
1441
1431
  *
1442
1432
  * Parameters:
1443
- * 1. object `data` - info object provided with the event. It has the following properties:
1444
- * * {@link Conversation} `conversation` - conversation that has received the update
1445
- * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons for update
1433
+ * 1. object `data` - info object provided with the event. It has the
1434
+ * following properties:
1435
+ * * {@link Conversation} `conversation` - conversation that has received
1436
+ * the update
1437
+ * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
1438
+ * for the update
1446
1439
  * @event
1447
1440
  */
1448
1441
  static readonly updated = "updated";
1449
1442
  /**
1450
- * Fired when the conversation was destroyed or the currently-logged-in user has left private conversation.
1443
+ * Fired when the conversation was destroyed or the currently-logged-in user
1444
+ * has left private conversation.
1451
1445
  *
1452
1446
  * Parameters:
1453
1447
  * 1. {@link Conversation} `conversation` - conversation that has been removed
1454
1448
  * @event
1455
1449
  */
1456
1450
  static readonly removed = "removed";
1451
+ /**
1452
+ * Logger instance.
1453
+ */
1454
+ private static readonly _logger;
1455
+ /**
1456
+ * Unique system identifier of the conversation.
1457
+ */
1458
+ readonly sid: string;
1459
+ /**
1460
+ * Conversation links for REST requests.
1461
+ * @internal
1462
+ */
1463
+ readonly _links: ConversationLinks;
1464
+ /**
1465
+ * Map of participants.
1466
+ * @internal
1467
+ */
1468
+ readonly _participants: Map<string, Participant>;
1469
+ /**
1470
+ * Configuration of the client that the conversation belongs to.
1471
+ */
1472
+ private readonly _configuration;
1473
+ /**
1474
+ * Conversation service objects.
1475
+ */
1476
+ private readonly _services;
1477
+ /**
1478
+ * Internal state of the conversation.
1479
+ */
1480
+ private readonly _internalState;
1481
+ /**
1482
+ * Name of the conversation entity document.
1483
+ */
1484
+ private readonly _entityName;
1485
+ /**
1486
+ * Messages entity.
1487
+ */
1488
+ private readonly _messagesEntity;
1489
+ /**
1490
+ * Participants entity.
1491
+ */
1492
+ private readonly _participantsEntity;
1493
+ /**
1494
+ * Source of the most recent update.
1495
+ */
1496
+ private _dataSource;
1497
+ /**
1498
+ * Promise for the conversation entity document.
1499
+ */
1500
+ private _entityPromise;
1501
+ /**
1502
+ * Conversation entity document.
1503
+ */
1504
+ private _entity;
1505
+ /**
1506
+ * @param descriptor Conversation descriptor.
1507
+ * @param sid Conversation SID.
1508
+ * @param links Conversation links for REST requests.
1509
+ * @param configuration Client configuration.
1510
+ * @param services Conversation services.
1511
+ * @internal
1512
+ */
1513
+ constructor(descriptor: ConversationDescriptor, sid: string, links: ConversationLinks, configuration: Configuration, services: ConversationServices);
1457
1514
  /**
1458
1515
  * Unique name of the conversation.
1459
1516
  */
@@ -1494,6 +1551,10 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1494
1551
  * User notification level for this conversation.
1495
1552
  */
1496
1553
  get notificationLevel(): NotificationLevel;
1554
+ /**
1555
+ * Conversation bindings. Undocumented feature (for now).
1556
+ * @internal
1557
+ */
1497
1558
  get bindings(): ConversationBindings;
1498
1559
  /**
1499
1560
  * Current conversation limits.
@@ -1504,65 +1565,38 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1504
1565
  */
1505
1566
  get state(): ConversationState | undefined;
1506
1567
  /**
1507
- * Load and subscribe to this conversation and do not subscribe to its participants and messages.
1508
- * This or _subscribeStreams will need to be called before any events on conversation will fire.
1509
- * @internal
1510
- */
1511
- _subscribe(): Promise<void | SyncDocument>;
1512
- /**
1513
- * Load the attributes of this conversation and instantiate its participants and messages.
1514
- * This or _subscribe will need to be called before any events on the conversation will fire.
1515
- * This will need to be called before any events on participants or messages will fire
1516
- * @internal
1517
- */
1518
- _subscribeStreams(): Promise<void>;
1519
- /**
1520
- * Stop listening for and firing events on this conversation.
1521
- * @internal
1522
- */
1523
- _unsubscribe(): Promise<[
1524
- void,
1525
- void
1526
- ]>;
1527
- /**
1528
- * Set conversation status.
1568
+ * Source of the conversation update.
1529
1569
  * @internal
1530
1570
  */
1531
- _setStatus(status: ConversationStatus, source: ConversationsDataSource): void;
1571
+ get _statusSource(): ConversationsDataSource;
1532
1572
  /**
1533
- * Get the source of the conversation update.
1534
- * @internal
1573
+ * Preprocess the update object.
1574
+ * @param update The update object received from Sync.
1575
+ * @param conversationSid The SID of the conversation in question.
1535
1576
  */
1536
- _statusSource(): ConversationsDataSource;
1537
1577
  private static preprocessUpdate;
1538
- /**
1539
- * Update the local conversation object with new values.
1540
- * @internal
1541
- */
1542
- _update(update: any): void;
1543
- /**
1544
- * @internal
1545
- */
1546
- private _onMessageAdded;
1547
- private _setLastReadMessageIndex;
1548
1578
  /**
1549
1579
  * Add a participant to the conversation by its identity.
1550
1580
  * @param identity Identity of the Client to add.
1551
1581
  * @param attributes Attributes to be attached to the participant.
1582
+ * @returns The added participant.
1552
1583
  */
1553
- add(identity: string, attributes?: JSONValue): Promise<ParticipantResponse>;
1584
+ add(identity: string, attributes?: JSONValue): Promise<Participant>;
1554
1585
  /**
1555
1586
  * Add a non-chat participant to the conversation.
1556
1587
  * @param proxyAddress Proxy (Twilio) address of the participant.
1557
1588
  * @param address User address of the participant.
1558
1589
  * @param attributes Attributes to be attached to the participant.
1559
- * @param bindingOptions Options for adding email participants - name and CC/To level.
1590
+ * @param bindingOptions Options for adding email participants - name and
1591
+ * CC/To level.
1592
+ * @returns The added participant.
1560
1593
  */
1561
- addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<ParticipantResponse>;
1594
+ addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<Participant>;
1562
1595
  /**
1563
- * Advance the conversation's last read message index to the current read horizon.
1564
- * Rejects if the user is not a participant of the conversation.
1565
- * Last read message index is updated only if the new index value is higher than the previous.
1596
+ * Advance the conversation's last read message index to the current read
1597
+ * horizon. Rejects if the user is not a participant of the conversation. Last
1598
+ * read message index is updated only if the new index value is higher than
1599
+ * the previous.
1566
1600
  * @param index Message index to advance to.
1567
1601
  * @return Resulting unread messages count in the conversation.
1568
1602
  */
@@ -1577,10 +1611,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1577
1611
  getAttributes(): Promise<JSONValue>;
1578
1612
  /**
1579
1613
  * Returns messages from the conversation using the paginator interface.
1580
- * @param pageSize Number of messages to return in a single chunk. Default is 30.
1581
- * @param anchor Index of the newest message to fetch. Default is from the end.
1582
- * @param direction Query direction. By default it queries backwards
1583
- * from newer to older. The `"forward"` value will query in the opposite direction.
1614
+ * @param pageSize Number of messages to return in a single chunk. Default is
1615
+ * 30.
1616
+ * @param anchor Index of the newest message to fetch. Default is from the
1617
+ * end.
1618
+ * @param direction Query direction. By default, it queries backwards
1619
+ * from newer to older. The `"forward"` value will query in the opposite
1620
+ * direction.
1584
1621
  * @return A page of messages.
1585
1622
  */
1586
1623
  getMessages(pageSize?: number, anchor?: number, direction?: "backwards" | "forward"): Promise<Paginator<Message>>;
@@ -1591,12 +1628,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1591
1628
  /**
1592
1629
  * Get conversation participants count.
1593
1630
  *
1594
- * This method is semi-realtime. This means that this data will be eventually correct,
1595
- * but will also be possibly incorrect for a few seconds. The Conversations system does not
1596
- * provide real time events for counter values changes.
1631
+ * This method is semi-realtime. This means that this data will be eventually
1632
+ * correct, but will also be possibly incorrect for a few seconds. The
1633
+ * Conversations system does not provide real time events for counter values
1634
+ * changes.
1597
1635
  *
1598
- * This is useful for any UI badges, but it is not recommended to build any core application
1599
- * logic based on these counters being accurate in real time.
1636
+ * This is useful for any UI badges, but it is not recommended to build any
1637
+ * core application logic based on these counters being accurate in real time.
1600
1638
  */
1601
1639
  getParticipantsCount(): Promise<number>;
1602
1640
  /**
@@ -1612,28 +1650,30 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1612
1650
  /**
1613
1651
  * Get the total message count in the conversation.
1614
1652
  *
1615
- * This method is semi-realtime. This means that this data will be eventually correct,
1616
- * but will also be possibly incorrect for a few seconds. The Conversations system does not
1617
- * provide real time events for counter values changes.
1653
+ * This method is semi-realtime. This means that this data will be eventually
1654
+ * correct, but will also be possibly incorrect for a few seconds. The
1655
+ * Conversations system does not provide real time events for counter values
1656
+ * changes.
1618
1657
  *
1619
- * This is useful for any UI badges, but it is not recommended to build any core application
1620
- * logic based on these counters being accurate in real time.
1658
+ * This is useful for any UI badges, but it is not recommended to build any
1659
+ * core application logic based on these counters being accurate in real time.
1621
1660
  */
1622
1661
  getMessagesCount(): Promise<number>;
1623
1662
  /**
1624
- * Get unread messages count for the user if they are a participant of this conversation.
1625
- * Rejects if the user is not a participant of the conversation.
1663
+ * Get unread messages count for the user if they are a participant of this
1664
+ * conversation. Rejects if the user is not a participant of the conversation.
1626
1665
  *
1627
1666
  * Use this method to obtain the number of unread messages together with
1628
1667
  * {@link Conversation.updateLastReadMessageIndex} instead of relying on the
1629
1668
  * message indices which may have gaps. See {@link Message.index} for details.
1630
1669
  *
1631
- * This method is semi-realtime. This means that this data will be eventually correct,
1632
- * but will also be possibly incorrect for a few seconds. The Conversations system does not
1633
- * provide real time events for counter values changes.
1670
+ * This method is semi-realtime. This means that this data will be eventually
1671
+ * correct, but will also be possibly incorrect for a few seconds. The
1672
+ * Conversations system does not provide real time events for counter values
1673
+ * changes.
1634
1674
  *
1635
- * This is useful for any UI badges, but it is not recommended to build any core application
1636
- * logic based on these counters being accurate in real time.
1675
+ * This is useful for any UI badges, but it is not recommended to build any
1676
+ * core application logic based on these counters being accurate in real time.
1637
1677
  */
1638
1678
  getUnreadMessagesCount(): Promise<number | null>;
1639
1679
  /**
@@ -1655,7 +1695,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1655
1695
  /**
1656
1696
  * Send a message to the conversation.
1657
1697
  * @param message Message body for the text message,
1658
- * `FormData` or {@link SendMediaOptions} for media content. Sending FormData is supported only with the browser engine.
1698
+ * `FormData` or {@link SendMediaOptions} for media content. Sending FormData
1699
+ * is supported only with the browser engine.
1659
1700
  * @param messageAttributes Attributes for the message.
1660
1701
  * @param emailOptions Email options for the message.
1661
1702
  * @return Index of the new message.
@@ -1663,12 +1704,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1663
1704
  sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<number>;
1664
1705
  /**
1665
1706
  * New interface to prepare for sending a message.
1666
- * Use instead of `sendMessage`.
1707
+ * Use this instead of {@link Message.sendMessage}.
1667
1708
  * @return A MessageBuilder to help set all message sending options.
1668
1709
  */
1669
1710
  prepareMessage(): MessageBuilder;
1670
1711
  /**
1671
- * Set last read message index of the conversation to the index of the last known message.
1712
+ * Set last read message index of the conversation to the index of the last
1713
+ * known message.
1672
1714
  * @return Resulting unread messages count in the conversation.
1673
1715
  */
1674
1716
  setAllMessagesRead(): Promise<number>;
@@ -1683,8 +1725,10 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1683
1725
  */
1684
1726
  setUserNotificationLevel(notificationLevel: NotificationLevel): Promise<void>;
1685
1727
  /**
1686
- * Send a notification to the server indicating that this client is currently typing in this conversation.
1687
- * Typing ended notification is sent after a while automatically, but by calling this method again you ensure that typing ended is not received.
1728
+ * Send a notification to the server indicating that this client is currently
1729
+ * typing in this conversation. Typing ended notification is sent after a
1730
+ * while automatically, but by calling this method again you ensure that
1731
+ * typing ended is not received.
1688
1732
  */
1689
1733
  typing(): Promise<void>;
1690
1734
  /**
@@ -1699,21 +1743,61 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1699
1743
  updateFriendlyName(friendlyName: string): Promise<Conversation>;
1700
1744
  /**
1701
1745
  * Set the last read message index to the current read horizon.
1702
- * @param index Message index to set as last read.
1703
- * If null is provided, then the behavior is identical to {@link Conversation.setAllMessagesUnread}.
1746
+ * @param index Message index to set as last read. If null is provided, then
1747
+ * the behavior is identical to {@link Conversation.setAllMessagesUnread}.
1704
1748
  * @returns Resulting unread messages count in the conversation.
1705
1749
  */
1706
1750
  updateLastReadMessageIndex(index: number | null): Promise<number>;
1707
1751
  /**
1708
1752
  * Update the unique name of the conversation.
1709
- * @param uniqueName New unique name for the conversation. Setting unique name to null removes it.
1753
+ * @param uniqueName New unique name for the conversation. Setting unique name
1754
+ * to null removes it.
1710
1755
  */
1711
1756
  updateUniqueName(uniqueName: string | null): Promise<Conversation>;
1757
+ /**
1758
+ * Load and subscribe to this conversation and do not subscribe to its
1759
+ * participants and messages. This or _subscribeStreams will need to be called
1760
+ * before any events on conversation will fire.
1761
+ * @internal
1762
+ */
1763
+ _subscribe(): Promise<SyncDocument>;
1764
+ /**
1765
+ * Load the attributes of this conversation and instantiate its participants
1766
+ * and messages. This or _subscribe will need to be called before any events
1767
+ * on the conversation will fire. This will need to be called before any
1768
+ * events on participants or messages will fire
1769
+ * @internal
1770
+ */
1771
+ _subscribeStreams(): Promise<void>;
1772
+ /**
1773
+ * Stop listening for and firing events on this conversation.
1774
+ * @internal
1775
+ */
1776
+ _unsubscribe(): Promise<[
1777
+ void,
1778
+ void
1779
+ ]>;
1780
+ /**
1781
+ * Set conversation status.
1782
+ * @internal
1783
+ */
1784
+ _setStatus(status: ConversationStatus, source: ConversationsDataSource): void;
1785
+ /**
1786
+ * Update the local conversation object with new values.
1787
+ * @internal
1788
+ */
1789
+ _update(update: any): void;
1790
+ /**
1791
+ * Handle onMessageAdded event.
1792
+ */
1793
+ private _onMessageAdded;
1794
+ /**
1795
+ * Set last read message index.
1796
+ * @param index New index to set.
1797
+ */
1798
+ private _setLastReadMessageIndex;
1712
1799
  }
1713
- type ConversationsDataSource = "sync" | "chat" | "rest";
1714
- /**
1715
- * Push notification type.
1716
- */
1800
+ type ConversationsDataSource = "sync" | "rest";
1717
1801
  type PushNotificationType = "twilio.conversations.new_message" | "twilio.conversations.added_to_conversation" | "twilio.conversations.removed_from_conversation";
1718
1802
  interface PushNotificationDescriptor {
1719
1803
  title: string | null;
@@ -1732,6 +1816,10 @@ interface PushNotificationData {
1732
1816
  * SID of the conversation.
1733
1817
  */
1734
1818
  conversationSid?: string;
1819
+ /**
1820
+ * Title of the conversation.
1821
+ */
1822
+ conversationTitle?: string;
1735
1823
  /**
1736
1824
  * Index of the message in the conversation.
1737
1825
  */
@@ -1740,6 +1828,14 @@ interface PushNotificationData {
1740
1828
  * SID of the message in the conversation.
1741
1829
  */
1742
1830
  messageSid?: string;
1831
+ /**
1832
+ * Media of the notification
1833
+ */
1834
+ media?: Media;
1835
+ /**
1836
+ * Amount of the attached media of the message.
1837
+ */
1838
+ mediaCount?: number;
1743
1839
  }
1744
1840
  /**
1745
1841
  * Push notification for a Conversations client.
@@ -1778,6 +1874,9 @@ declare class PushNotification {
1778
1874
  */
1779
1875
  constructor(data: PushNotificationDescriptor);
1780
1876
  }
1877
+ /**
1878
+ * Client events.
1879
+ */
1781
1880
  type ClientEvents = {
1782
1881
  conversationAdded: (conversation: Conversation) => void;
1783
1882
  conversationJoined: (conversation: Conversation) => void;
@@ -1799,7 +1898,7 @@ type ClientEvents = {
1799
1898
  message: Message;
1800
1899
  updateReasons: MessageUpdateReason[];
1801
1900
  }) => void;
1802
- tokenAboutToExpire: (ttl: number) => void;
1901
+ tokenAboutToExpire: () => void;
1803
1902
  tokenExpired: () => void;
1804
1903
  typingEnded: (participant: Participant) => void;
1805
1904
  typingStarted: (participant: Participant) => void;
@@ -1810,22 +1909,22 @@ type ClientEvents = {
1810
1909
  user: User;
1811
1910
  updateReasons: UserUpdateReason[];
1812
1911
  }) => void;
1813
- stateChanged: (state: State) => void;
1814
- connectionStateChanged: (state: TwilsockConnectionState) => void;
1815
- connectionError: (data: {
1816
- terminal: boolean;
1817
- message: string;
1818
- httpStatusCode?: number;
1819
- errorCode?: number;
1912
+ stateChanged: ({ state, error }: {
1913
+ state: State;
1914
+ error?: ConnectionError;
1820
1915
  }) => void;
1916
+ connectionStateChanged: (state: TwilsockConnectionState) => void;
1917
+ connectionError: (data: ConnectionError) => void;
1821
1918
  };
1822
1919
  /**
1823
1920
  * Connection state of the client. Possible values are as follows:
1824
1921
  * * `'connecting'` - client is offline and connection attempt is in process
1825
1922
  * * `'connected'` - client is online and ready
1826
1923
  * * `'disconnecting'` - client is going offline as disconnection is in process
1827
- * * `'disconnected'` - client is offline and no connection attempt is in process
1828
- * * `'denied'` - client connection is denied because of invalid JWT access token. User must refresh token in order to proceed
1924
+ * * `'disconnected'` - client is offline and no connection attempt is in
1925
+ * process
1926
+ * * `'denied'` - client connection is denied because of invalid JWT access
1927
+ * token. User must refresh token in order to proceed
1829
1928
  */
1830
1929
  type ConnectionState = TwilsockConnectionState;
1831
1930
  /**
@@ -1840,6 +1939,9 @@ type State = "failed" | "initialized";
1840
1939
  * * `'apn'`
1841
1940
  */
1842
1941
  type NotificationsChannelType = ChannelType;
1942
+ /**
1943
+ * Level of logging.
1944
+ */
1843
1945
  type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent";
1844
1946
  /**
1845
1947
  * Conversations client options.
@@ -1894,43 +1996,9 @@ interface CreateConversationOptions {
1894
1996
  */
1895
1997
  declare class Client extends ReplayEventEmitter<ClientEvents> {
1896
1998
  /**
1897
- * Client connection state.
1898
- */
1899
- connectionState: ConnectionState;
1900
- private conversationsPromise;
1901
- private _ensureReady;
1902
- private _resolveEnsureReady;
1903
- private _rejectEnsureReady;
1904
- private fpaToken;
1905
- private configuration;
1906
- private conversations;
1907
- private readonly options;
1908
- private services;
1909
- private readonly _myself;
1910
- /**
1911
- * Current version of the Conversations client.
1912
- */
1913
- static readonly version: string;
1914
- /**
1915
- * Current version of the Conversations client.
1916
- */
1917
- readonly version: string;
1918
- private static readonly supportedPushChannels;
1919
- private static readonly supportedPushDataFields;
1920
- /**
1921
- * Returned Conversations instance is not yet fully initialized. Calling any operations will block until it is.
1922
- * Use connection events to monitor when client becomes fully available (connectionStateChanged with state
1923
- * 'connected') or not available (connectionStateChange with state 'denied', event tokenExpired, event connectionError).
1924
- *
1925
- * @param fpaToken Access token
1926
- * @param options Options to customize the Client
1927
- * @returns A not yet fully-initialized client.
1928
- */
1929
- constructor(fpaToken: string, options?: ClientOptions | null);
1930
- static populateInitRegistrations(reg: InitRegistration): void;
1931
- /**
1932
- * Fired when a conversation becomes visible to the client. The event is also triggered when the client creates a new conversation.
1933
- * Fired for all conversations client has joined.
1999
+ * Fired when a conversation becomes visible to the client. The event is also
2000
+ * triggered when the client creates a new conversation.
2001
+ * Fired for all conversations that the client has joined.
1934
2002
  *
1935
2003
  * Parameters:
1936
2004
  * 1. {@link Conversation} `conversation` - the conversation in question
@@ -1962,14 +2030,17 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
1962
2030
  */
1963
2031
  static readonly conversationRemoved = "conversationRemoved";
1964
2032
  /**
1965
- * Fired when the attributes or the metadata of a conversation have been updated.
1966
- * During conversation's creation and initialization, this event might be fired multiple times
1967
- * for same joined or created conversation as new data is arriving from different sources.
2033
+ * Fired when the attributes or the metadata of a conversation have been
2034
+ * updated. During conversation's creation and initialization, this event
2035
+ * might be fired multiple times for same joined or created conversation as
2036
+ * new data is arriving from different sources.
1968
2037
  *
1969
2038
  * Parameters:
1970
- * 1. object `data` - info object provided with the event. It has the following properties:
2039
+ * 1. object `data` - info object provided with the event. It has the
2040
+ * following properties:
1971
2041
  * * {@link Conversation} `conversation` - the conversation in question
1972
- * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons for the update
2042
+ * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
2043
+ * for the update
1973
2044
  * @event
1974
2045
  */
1975
2046
  static readonly conversationUpdated = "conversationUpdated";
@@ -1993,9 +2064,11 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
1993
2064
  * Fired when a participant's fields have been updated.
1994
2065
  *
1995
2066
  * Parameters:
1996
- * 1. object `data` - info object provided with the event. It has the following properties:
2067
+ * 1. object `data` - info object provided with the event. It has the
2068
+ * following properties:
1997
2069
  * * {@link Participant} `participant` - the participant in question
1998
- * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons for the update
2070
+ * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
2071
+ * for the update
1999
2072
  * @event
2000
2073
  */
2001
2074
  static readonly participantUpdated = "participantUpdated";
@@ -2019,16 +2092,16 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2019
2092
  * Fired when the fields of an existing message are updated with new values.
2020
2093
  *
2021
2094
  * Parameters:
2022
- * 1. object `data` - info object provided with the event. It has the following properties:
2095
+ * 1. object `data` - info object provided with the event. It has the
2096
+ * following properties:
2023
2097
  * * {@link Message} `message` - the message in question
2024
- * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for the update
2098
+ * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
2099
+ * the update
2025
2100
  * @event
2026
2101
  */
2027
2102
  static readonly messageUpdated = "messageUpdated";
2028
2103
  /**
2029
2104
  * Fired when the token is about to expire and needs to be updated.
2030
- * * Parameters:
2031
- * 1. number `message` - token's time to live
2032
2105
  * @event
2033
2106
  */
2034
2107
  static readonly tokenAboutToExpire = "tokenAboutToExpire";
@@ -2054,10 +2127,12 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2054
2127
  */
2055
2128
  static readonly typingStarted = "typingStarted";
2056
2129
  /**
2057
- * Fired when the client has received (and parsed) a push notification via one of the push channels (apn or fcm).
2130
+ * Fired when the client has received (and parsed) a push notification via one
2131
+ * of the push channels (apn or fcm).
2058
2132
  *
2059
2133
  * Parameters:
2060
- * 1. {@link PushNotification} `pushNotification` - the push notification in question
2134
+ * 1. {@link PushNotification} `pushNotification` - the push notification in
2135
+ * question
2061
2136
  * @event
2062
2137
  */
2063
2138
  static readonly pushNotification = "pushNotification";
@@ -2078,12 +2153,15 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2078
2153
  */
2079
2154
  static readonly userUnsubscribed = "userUnsubscribed";
2080
2155
  /**
2081
- * Fired when the properties or the reachability status of a user have been updated.
2156
+ * Fired when the properties or the reachability status of a user have been
2157
+ * updated.
2082
2158
  *
2083
2159
  * Parameters:
2084
- * 1. object `data` - info object provided with the event. It has the following properties:
2160
+ * 1. object `data` - info object provided with the event. It has the
2161
+ * following properties:
2085
2162
  * * {@link User} `user` - the user in question
2086
- * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update
2163
+ * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the
2164
+ * update
2087
2165
  * @event
2088
2166
  */
2089
2167
  static readonly userUpdated = "userUpdated";
@@ -2091,14 +2169,17 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2091
2169
  * Fired when the state of the client has been changed.
2092
2170
  *
2093
2171
  * Parameters:
2094
- * 1. {@link State} `state` - the new client state
2172
+ * 1. object `data` - info object provided with the event. It has the
2173
+ * following properties:
2174
+ * * {@link State} `state` - the new client state
2175
+ * * Error? `error` - the initialization error if present
2095
2176
  * @event
2096
2177
  */
2097
2178
  static readonly stateChanged = "stateChanged";
2098
2179
  /**
2099
2180
  * Fired when the connection state of the client has been changed.
2100
2181
  *
2101
- * Paremeters:
2182
+ * Parameters:
2102
2183
  * 1. {@link ConnectionState} `state` - the new connection state
2103
2184
  * @event
2104
2185
  */
@@ -2107,7 +2188,8 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2107
2188
  * Fired when the connection is interrupted for an unexpected reason.
2108
2189
  *
2109
2190
  * Parameters:
2110
- * 1. object `data` - info object provided with the event. It has the following properties:
2191
+ * 1. object `data` - info object provided with the event. It has the
2192
+ * following properties:
2111
2193
  * * boolean `terminal` - Twilsock will stop connection attempts if true
2112
2194
  * * string `message` - the error message of the root cause
2113
2195
  * * number? `httpStatusCode` - http status code if available
@@ -2115,6 +2197,93 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2115
2197
  * @event
2116
2198
  */
2117
2199
  static readonly connectionError = "connectionError";
2200
+ /**
2201
+ * Current version of the Conversations client.
2202
+ */
2203
+ static readonly version: string;
2204
+ /**
2205
+ * Logger instance.
2206
+ */
2207
+ private static readonly _logger;
2208
+ /**
2209
+ * Supported push notification channels.
2210
+ */
2211
+ private static readonly _supportedPushChannels;
2212
+ /**
2213
+ * Supported push data fields.
2214
+ */
2215
+ private static readonly _supportedPushDataFields;
2216
+ /**
2217
+ * Current version of the Conversations client.
2218
+ */
2219
+ readonly version: string;
2220
+ /**
2221
+ * Client connection state.
2222
+ */
2223
+ connectionState: ConnectionState;
2224
+ /**
2225
+ * Promise that resolves on successful initialization.
2226
+ */
2227
+ private readonly _ensureReady;
2228
+ /**
2229
+ * Options passed to the client.
2230
+ */
2231
+ private readonly _options;
2232
+ /**
2233
+ * Client service objects.
2234
+ */
2235
+ private readonly _services;
2236
+ /**
2237
+ * The user of the client.
2238
+ */
2239
+ private readonly _myself;
2240
+ /**
2241
+ * Resolves the {@link Client._ensureReady} promise.
2242
+ */
2243
+ private _resolveEnsureReady;
2244
+ /**
2245
+ * Rejects the {@link Client._ensureReady} promise.
2246
+ */
2247
+ private _rejectEnsureReady;
2248
+ /**
2249
+ * The current token of the client.
2250
+ */
2251
+ private _fpaToken;
2252
+ /**
2253
+ * The constructed configuration object.
2254
+ */
2255
+ private _configuration;
2256
+ /**
2257
+ * The Conversations entity.
2258
+ */
2259
+ private _conversationsEntity;
2260
+ /**
2261
+ * Promise that resolves when initial conversations are fetched.
2262
+ */
2263
+ private _conversationsPromise;
2264
+ /**
2265
+ * Returned Conversations instance is not yet fully initialized. Calling any
2266
+ * operations will block until it is. Use connection events to monitor when
2267
+ * client becomes fully available (connectionStateChanged with state
2268
+ * 'connected') or not available (connectionStateChange with state 'denied',
2269
+ * event tokenExpired, event connectionError).
2270
+ *
2271
+ * @param fpaToken Access token
2272
+ * @param options Options to customize the Client
2273
+ * @returns A not yet fully-initialized client.
2274
+ */
2275
+ constructor(fpaToken: string, options?: ClientOptions | null);
2276
+ /**
2277
+ * Information of the logged-in user. Before client initialization, returns an
2278
+ * uninitialized user. Will trigger a {@link Client.userUpdated} event after
2279
+ * initialization.
2280
+ */
2281
+ get user(): User;
2282
+ /**
2283
+ * Client reachability state. Throws an error if accessed before the client
2284
+ * initialization was completed.
2285
+ */
2286
+ get reachabilityEnabled(): boolean;
2118
2287
  /**
2119
2288
  * @deprecated Call constructor directly.
2120
2289
  *
@@ -2136,20 +2305,21 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2136
2305
  */
2137
2306
  static create(token: string, options?: ClientOptions | null): Promise<Client>;
2138
2307
  /**
2139
- * Information of the logged-in user. Before client initialization, returns an
2140
- * uninitialized user. Will trigger a {@link Client.userUpdated} event after
2141
- * initialization.
2308
+ * Static method for push notification payload parsing. Returns parsed push as
2309
+ * a {@link PushNotification} object.
2310
+ * @param notificationPayload Push notification payload.
2142
2311
  */
2143
- get user(): User;
2312
+ static parsePushNotification(notificationPayload: any): PushNotification;
2144
2313
  /**
2145
- * Client reachability state. Throws if accessed before the client
2146
- * initialization was completed.
2314
+ * Static method for parsing push notification chat data.
2315
+ * @param data Data to parse
2147
2316
  */
2148
- get reachabilityEnabled(): boolean;
2149
- get token(): string;
2150
- private _subscribeToPushNotifications;
2151
- private _unsubscribeFromPushNotifications;
2152
- private _initialize;
2317
+ private static _parsePushNotificationChatData;
2318
+ /**
2319
+ * Populate the client with init registrations.
2320
+ * @param reg The init registration to populate.
2321
+ */
2322
+ static populateInitRegistrations(reg: InitRegistration): void;
2153
2323
  /**
2154
2324
  * Gracefully shut down the client.
2155
2325
  */
@@ -2164,6 +2334,12 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2164
2334
  * @param conversationSid Conversation sid
2165
2335
  */
2166
2336
  getConversationBySid(conversationSid: string): Promise<Conversation>;
2337
+ /**
2338
+ * Peek a conversation by its SID.
2339
+ * @param conversationSid Conversation sid
2340
+ * @internal
2341
+ */
2342
+ peekConversationBySid(conversationSid: string): Promise<Conversation>;
2167
2343
  /**
2168
2344
  * Get a known conversation by its unique identifier name.
2169
2345
  * @param uniqueName The unique identifier name of the conversation.
@@ -2182,7 +2358,8 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2182
2358
  /**
2183
2359
  * Register for push notifications.
2184
2360
  * @param channelType Channel type.
2185
- * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.
2361
+ * @param registrationId Push notification ID provided by the FCM/APNS service
2362
+ * on the platform.
2186
2363
  */
2187
2364
  setPushRegistrationId(channelType: NotificationsChannelType, registrationId: string): Promise<void>;
2188
2365
  /**
@@ -2195,27 +2372,29 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2195
2372
  * Clear existing registrations directly using provided device token.
2196
2373
  * This is useful to ensure stopped subscriptions without resubscribing.
2197
2374
  *
2198
- * This function goes completely beside the state machine and removes all registrations.
2199
- * Use with caution: if it races with current state machine operations, madness will ensue.
2375
+ * This function goes completely beside the state machine and removes all
2376
+ * registrations.
2377
+ * Use with caution: if it races with current state machine operations,
2378
+ * madness will ensue.
2200
2379
  *
2201
2380
  * @param channelType Channel type.
2202
- * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.
2381
+ * @param registrationId Push notification ID provided by the FCM/APNS service
2382
+ * on the platform.
2203
2383
  */
2204
2384
  removePushRegistrations(channelType: ChannelType, registrationId: string): Promise<void>;
2205
- private static parsePushNotificationChatData;
2206
2385
  /**
2207
- * Static method for push notification payload parsing. Returns parsed push as a {@link PushNotification} object.
2208
- * @param notificationPayload Push notification payload.
2386
+ * Current version of the Conversations client.
2209
2387
  */
2210
- static parsePushNotification(notificationPayload: any): PushNotification;
2211
2388
  parsePushNotification: typeof Client.parsePushNotification;
2212
2389
  /**
2213
- * Handle push notification payload parsing and emit the {@link Client.pushNotification} event on this {@link Client} instance.
2390
+ * Handle push notification payload parsing and emit the
2391
+ * {@link Client.pushNotification} event on this {@link Client} instance.
2214
2392
  * @param notificationPayload Push notification payload
2215
2393
  */
2216
2394
  handlePushNotification(notificationPayload: any): Promise<void>;
2217
2395
  /**
2218
- * Gets a user with the given identity. If it's in the subscribed list, then return the user object from it;
2396
+ * Gets a user with the given identity. If it's in the subscribed list, then
2397
+ * return the user object from it;
2219
2398
  * if not, then subscribe and add user to the subscribed list.
2220
2399
  * @param identity Identity of the user.
2221
2400
  * @returns A fully initialized user.
@@ -2225,6 +2404,32 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2225
2404
  * Get a list of subscribed user objects.
2226
2405
  */
2227
2406
  getSubscribedUsers(): Promise<Array<User>>;
2407
+ /**
2408
+ * Get content URLs for all media attachments in the given set of media sids
2409
+ * using a single operation.
2410
+ * @param mediaSids Set of media sids to query for the content URL.
2411
+ */
2412
+ getTemporaryContentUrlsForMediaSids(mediaSids: string[]): CancellablePromise<Map<string, string>>;
2413
+ /**
2414
+ * Get content URLs for all media attachments in the given set using a single
2415
+ * operation.
2416
+ * @param contentSet Set of media attachments to query content URLs.
2417
+ */
2418
+ getTemporaryContentUrlsForMedia(contentSet: Media[]): CancellablePromise<Map<string, string>>;
2419
+ /**
2420
+ * Initialize the client.
2421
+ */
2422
+ private _initialize;
2423
+ /**
2424
+ * Subscribe to push notifications.
2425
+ * @param channelType The channel type to subscribe to.
2426
+ */
2427
+ private _subscribeToPushNotifications;
2428
+ /**
2429
+ * Unsubscribe from push notifications.
2430
+ * @param channelType The channel type to unsubscribe from.
2431
+ */
2432
+ private _unsubscribeFromPushNotifications;
2228
2433
  }
2229
2434
  declare class NotificationTypes {
2230
2435
  static readonly TYPING_INDICATOR = "twilio.ipmsg.typing_indicator";