@twilio/conversations 2.1.0-rc.9 → 3.0.0-canary.9

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 (89) hide show
  1. package/README.md +7 -3
  2. package/builds/browser.js +2707 -1986
  3. package/builds/browser.js.map +1 -1
  4. package/builds/lib.d.ts +513 -305
  5. package/builds/lib.js +2707 -1986
  6. package/builds/lib.js.map +1 -1
  7. package/builds/twilio-conversations.js +5232 -5070
  8. package/builds/twilio-conversations.min.js +1 -16
  9. package/dist/aggregated-delivery-receipt.js.map +1 -1
  10. package/dist/client.js +417 -283
  11. package/dist/client.js.map +1 -1
  12. package/dist/command-executor.js.map +1 -1
  13. package/dist/configuration.js +2 -2
  14. package/dist/configuration.js.map +1 -1
  15. package/dist/conversation.js +407 -374
  16. package/dist/conversation.js.map +1 -1
  17. package/dist/data/conversations.js +10 -11
  18. package/dist/data/conversations.js.map +1 -1
  19. package/dist/data/messages.js +46 -26
  20. package/dist/data/messages.js.map +1 -1
  21. package/dist/data/participants.js +19 -10
  22. package/dist/data/participants.js.map +1 -1
  23. package/dist/data/users.js +2 -2
  24. package/dist/data/users.js.map +1 -1
  25. package/dist/detailed-delivery-receipt.js.map +1 -1
  26. package/dist/index.js +1 -4
  27. package/dist/index.js.map +1 -1
  28. package/dist/interfaces/attributes.js.map +1 -1
  29. package/dist/interfaces/notification-types.js.map +1 -1
  30. package/dist/logger.js +2 -4
  31. package/dist/logger.js.map +1 -1
  32. package/dist/media.js +36 -25
  33. package/dist/media.js.map +1 -1
  34. package/dist/message-builder.js +24 -18
  35. package/dist/message-builder.js.map +1 -1
  36. package/dist/message.js +53 -26
  37. package/dist/message.js.map +1 -1
  38. package/dist/node_modules/tslib/tslib.es6.js +1 -1
  39. package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
  40. package/dist/packages/conversations/package.json.js +1 -1
  41. package/dist/participant.js +2 -2
  42. package/dist/participant.js.map +1 -1
  43. package/dist/push-notification.js.map +1 -1
  44. package/dist/rest-paginator.js.map +1 -1
  45. package/dist/services/network.js.map +1 -1
  46. package/dist/services/typing-indicator.js +1 -1
  47. package/dist/services/typing-indicator.js.map +1 -1
  48. package/dist/unsent-message.js +13 -3
  49. package/dist/unsent-message.js.map +1 -1
  50. package/dist/user.js +1 -1
  51. package/dist/user.js.map +1 -1
  52. package/dist/util/deferred.js.map +1 -1
  53. package/dist/util/index.js.map +1 -1
  54. package/package.json +22 -18
  55. package/CHANGELOG.md +0 -412
  56. package/docs/assets/css/main.css +0 -2660
  57. package/docs/assets/images/icons.png +0 -0
  58. package/docs/assets/images/icons@2x.png +0 -0
  59. package/docs/assets/images/widgets.png +0 -0
  60. package/docs/assets/images/widgets@2x.png +0 -0
  61. package/docs/assets/js/main.js +0 -248
  62. package/docs/assets/js/search.js +0 -1
  63. package/docs/classes/AggregatedDeliveryReceipt.html +0 -3184
  64. package/docs/classes/Client.html +0 -4073
  65. package/docs/classes/Conversation.html +0 -4325
  66. package/docs/classes/DetailedDeliveryReceipt.html +0 -3163
  67. package/docs/classes/Media.html +0 -3193
  68. package/docs/classes/Message.html +0 -3677
  69. package/docs/classes/MessageBuilder.html +0 -3254
  70. package/docs/classes/Participant.html +0 -3444
  71. package/docs/classes/PushNotification.html +0 -3130
  72. package/docs/classes/RestPaginator.html +0 -3160
  73. package/docs/classes/UnsentMessage.html +0 -3042
  74. package/docs/classes/User.html +0 -3349
  75. package/docs/index.html +0 -3512
  76. package/docs/interfaces/ClientOptions.html +0 -3034
  77. package/docs/interfaces/ConversationBindings.html +0 -3001
  78. package/docs/interfaces/ConversationEmailBinding.html +0 -3001
  79. package/docs/interfaces/ConversationLimits.html +0 -3098
  80. package/docs/interfaces/ConversationState.html +0 -3050
  81. package/docs/interfaces/CreateConversationOptions.html +0 -3066
  82. package/docs/interfaces/LastMessage.html +0 -3050
  83. package/docs/interfaces/Paginator.html +0 -3141
  84. package/docs/interfaces/ParticipantBindings.html +0 -3001
  85. package/docs/interfaces/ParticipantEmailBinding.html +0 -3001
  86. package/docs/interfaces/PushNotificationData.html +0 -3066
  87. package/docs/interfaces/SendEmailOptions.html +0 -3034
  88. package/docs/interfaces/SendMediaOptions.html +0 -3068
  89. 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[]): 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,28 @@ 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: [
1114
+ MediaCategory,
1115
+ FormData | SendMediaOptions
1116
+ ][];
1117
+ emailOptions: SendEmailOptions;
1118
+ /**
1119
+ * @internal
1120
+ */
1121
+ constructor(messagesEntity: Messages);
1122
+ /**
1123
+ * Send the prepared message to the conversation.
1124
+ * @returns Index of the new message in the conversation.
1125
+ */
1126
+ send(): CancellablePromise<number | null>;
1127
+ }
1147
1128
  /**
1148
1129
  * Message builder. Allows the message to be built and sent via method chaining.
1149
1130
  *
@@ -1184,17 +1165,17 @@ declare class MessageBuilder {
1184
1165
  */
1185
1166
  setAttributes(attributes: JSONValue): MessageBuilder;
1186
1167
  /**
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.
1168
+ * Set the email body with a given content type.
1169
+ * @param contentType Format of the body to set (text/plain or text/html).
1170
+ * @param body Body payload in the selected format.
1190
1171
  */
1191
- setEmailBody(mimeType: string, body: FormData | SendMediaOptions): MessageBuilder;
1172
+ setEmailBody(contentType: string, body: FormData | SendMediaOptions): MessageBuilder;
1192
1173
  /**
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.
1174
+ * Set the email history with a given content type.
1175
+ * @param contentType Format of the history to set (text/plain or text/html).
1176
+ * @param history History payload in the selected format.
1196
1177
  */
1197
- setEmailHistory(mimeType: string, history: FormData | SendMediaOptions): MessageBuilder;
1178
+ setEmailHistory(contentType: string, history: FormData | SendMediaOptions): MessageBuilder;
1198
1179
  /**
1199
1180
  * Adds media to the message.
1200
1181
  * @param payload Media to add.
@@ -1204,8 +1185,15 @@ declare class MessageBuilder {
1204
1185
  * Builds the message, making it ready to be sent.
1205
1186
  */
1206
1187
  build(): UnsentMessage;
1188
+ /**
1189
+ * Prepares a message and sends it to the conversation.
1190
+ */
1191
+ buildAndSend(): CancellablePromise<number | null>;
1207
1192
  private getPayloadContentType;
1208
1193
  }
1194
+ /**
1195
+ * Conversation events.
1196
+ */
1209
1197
  type ConversationEvents = {
1210
1198
  participantJoined: (participant: Participant) => void;
1211
1199
  participantLeft: (participant: Participant) => void;
@@ -1227,55 +1215,28 @@ type ConversationEvents = {
1227
1215
  }) => void;
1228
1216
  removed: (conversation: Conversation) => void;
1229
1217
  };
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
1218
  /**
1257
- * The reason for the `updated` event being emitted by a conversation.
1219
+ * Reason for the `updated` event emission by a conversation.
1258
1220
  */
1259
1221
  type ConversationUpdateReason = "attributes" | "createdBy" | "dateCreated" | "dateUpdated" | "friendlyName" | "lastReadMessageIndex" | "state" | "status" | "uniqueName" | "lastMessage" | "notificationLevel" | "bindings";
1260
1222
  /**
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.
1223
+ * Status of the conversation, relative to the client: whether the conversation
1224
+ * has been `joined` or the client is `notParticipating` in the conversation.
1264
1225
  */
1265
1226
  type ConversationStatus = "notParticipating" | "joined";
1266
1227
  /**
1267
- * The user's notification level for the conversation. Determines
1228
+ * User's notification level for the conversation. Determines
1268
1229
  * whether the currently logged-in user will receive pushes for events
1269
1230
  * in this conversation. Can be either `muted` or `default`, where
1270
1231
  * `default` defers to the global service push configuration.
1271
1232
  */
1272
1233
  type NotificationLevel = "default" | "muted";
1273
1234
  /**
1274
- * The state of the conversation.
1235
+ * State of the conversation.
1275
1236
  */
1276
1237
  interface ConversationState {
1277
1238
  /**
1278
- * The current state.
1239
+ * Current state.
1279
1240
  */
1280
1241
  current: "active" | "inactive" | "closed";
1281
1242
  /**
@@ -1283,6 +1244,9 @@ interface ConversationState {
1283
1244
  */
1284
1245
  dateUpdated: Date;
1285
1246
  }
1247
+ /**
1248
+ * Event arguments for the `updated` event.
1249
+ */
1286
1250
  interface ConversationUpdatedEventArgs {
1287
1251
  conversation: Conversation;
1288
1252
  updateReasons: ConversationUpdateReason[];
@@ -1301,6 +1265,9 @@ interface ConversationEmailBinding {
1301
1265
  name?: string;
1302
1266
  projected_address: string;
1303
1267
  }
1268
+ /**
1269
+ * Binding for SMS conversation.
1270
+ */
1304
1271
  interface ConversationSmsBinding {
1305
1272
  address?: string;
1306
1273
  }
@@ -1346,33 +1313,51 @@ interface LastMessage {
1346
1313
  dateCreated?: Date;
1347
1314
  }
1348
1315
  /**
1349
- * A conversation represents communication between multiple Conversations clients
1316
+ * Conversation services.
1317
+ */
1318
+ interface ConversationServices {
1319
+ users: Users;
1320
+ typingIndicator: TypingIndicator;
1321
+ network: Network;
1322
+ mcsClient: McsClient;
1323
+ syncClient: SyncClient;
1324
+ commandExecutor: CommandExecutor;
1325
+ }
1326
+ /**
1327
+ * Conversation descriptor.
1328
+ */
1329
+ interface ConversationDescriptor {
1330
+ channel: string;
1331
+ entityName: string;
1332
+ uniqueName: string;
1333
+ attributes: JSONValue;
1334
+ createdBy?: string;
1335
+ friendlyName?: string;
1336
+ lastConsumedMessageIndex: number;
1337
+ dateCreated: Date | null;
1338
+ dateUpdated: Date | null;
1339
+ notificationLevel?: NotificationLevel;
1340
+ bindings?: ConversationBindings;
1341
+ }
1342
+ /**
1343
+ * Conversation links.
1344
+ */
1345
+ interface ConversationLinks {
1346
+ self: string;
1347
+ messages: string;
1348
+ participants: string;
1349
+ }
1350
+ /**
1351
+ * A conversation represents communication between multiple Conversations
1352
+ * clients.
1350
1353
  */
1351
1354
  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
1355
  /**
1372
1356
  * Fired when a participant has joined the conversation.
1373
1357
  *
1374
1358
  * Parameters:
1375
- * 1. {@link Participant} `participant` - participant that joined the conversation
1359
+ * 1. {@link Participant} `participant` - participant that joined the
1360
+ * conversation
1376
1361
  * @event
1377
1362
  */
1378
1363
  static readonly participantJoined = "participantJoined";
@@ -1380,7 +1365,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1380
1365
  * Fired when a participant has left the conversation.
1381
1366
  *
1382
1367
  * Parameters:
1383
- * 1. {@link Participant} `participant` - participant that left the conversation
1368
+ * 1. {@link Participant} `participant` - participant that left the
1369
+ * conversation
1384
1370
  * @event
1385
1371
  */
1386
1372
  static readonly participantLeft = "participantLeft";
@@ -1388,9 +1374,12 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1388
1374
  * Fired when data of a participant has been updated.
1389
1375
  *
1390
1376
  * 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
1377
+ * 1. object `data` - info object provided with the event. It has the
1378
+ * following properties:
1379
+ * * {@link Participant} `participant` - participant that has received the
1380
+ * update
1381
+ * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
1382
+ * for the update
1394
1383
  * @event
1395
1384
  */
1396
1385
  static readonly participantUpdated = "participantUpdated";
@@ -1414,9 +1403,11 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1414
1403
  * Fired when data of a message has been updated.
1415
1404
  *
1416
1405
  * Parameters:
1417
- * 1. object `data` - info object provided with the event. It has the following properties:
1406
+ * 1. object `data` - info object provided with the event. It has the
1407
+ * following properties:
1418
1408
  * * {@link Message} `message` - message that has received the update
1419
- * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for update
1409
+ * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
1410
+ * the update
1420
1411
  * @event
1421
1412
  */
1422
1413
  static readonly messageUpdated = "messageUpdated";
@@ -1424,7 +1415,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1424
1415
  * Fired when a participant has stopped typing.
1425
1416
  *
1426
1417
  * Parameters:
1427
- * 1. {@link Participant} `participant` - the participant that has stopped typing
1418
+ * 1. {@link Participant} `participant` - the participant that has stopped
1419
+ * typing
1428
1420
  * @event
1429
1421
  */
1430
1422
  static readonly typingEnded = "typingEnded";
@@ -1432,7 +1424,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1432
1424
  * Fired when a participant has started typing.
1433
1425
  *
1434
1426
  * Parameters:
1435
- * 1. {@link Participant} `participant` - the participant that has started typing
1427
+ * 1. {@link Participant} `participant` - the participant that has started
1428
+ * typing
1436
1429
  * @event
1437
1430
  */
1438
1431
  static readonly typingStarted = "typingStarted";
@@ -1440,20 +1433,87 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1440
1433
  * Fired when the data of the conversation has been updated.
1441
1434
  *
1442
1435
  * 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
1436
+ * 1. object `data` - info object provided with the event. It has the
1437
+ * following properties:
1438
+ * * {@link Conversation} `conversation` - conversation that has received
1439
+ * the update
1440
+ * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
1441
+ * for the update
1446
1442
  * @event
1447
1443
  */
1448
1444
  static readonly updated = "updated";
1449
1445
  /**
1450
- * Fired when the conversation was destroyed or the currently-logged-in user has left private conversation.
1446
+ * Fired when the conversation was destroyed or the currently-logged-in user
1447
+ * has left private conversation.
1451
1448
  *
1452
1449
  * Parameters:
1453
1450
  * 1. {@link Conversation} `conversation` - conversation that has been removed
1454
1451
  * @event
1455
1452
  */
1456
1453
  static readonly removed = "removed";
1454
+ /**
1455
+ * Logger instance.
1456
+ */
1457
+ private static readonly _logger;
1458
+ /**
1459
+ * Unique system identifier of the conversation.
1460
+ */
1461
+ readonly sid: string;
1462
+ /**
1463
+ * Conversation links for REST requests.
1464
+ * @internal
1465
+ */
1466
+ readonly _links: ConversationLinks;
1467
+ /**
1468
+ * Map of participants.
1469
+ * @internal
1470
+ */
1471
+ readonly _participants: Map<string, Participant>;
1472
+ /**
1473
+ * Configuration of the client that the conversation belongs to.
1474
+ */
1475
+ private readonly _configuration;
1476
+ /**
1477
+ * Conversation service objects.
1478
+ */
1479
+ private readonly _services;
1480
+ /**
1481
+ * Internal state of the conversation.
1482
+ */
1483
+ private readonly _internalState;
1484
+ /**
1485
+ * Name of the conversation entity document.
1486
+ */
1487
+ private readonly _entityName;
1488
+ /**
1489
+ * Messages entity.
1490
+ */
1491
+ private readonly _messagesEntity;
1492
+ /**
1493
+ * Participants entity.
1494
+ */
1495
+ private readonly _participantsEntity;
1496
+ /**
1497
+ * Source of the most recent update.
1498
+ */
1499
+ private _dataSource;
1500
+ /**
1501
+ * Promise for the conversation entity document.
1502
+ */
1503
+ private _entityPromise;
1504
+ /**
1505
+ * Conversation entity document.
1506
+ */
1507
+ private _entity;
1508
+ /**
1509
+ * @param descriptor Conversation descriptor.
1510
+ * @param sid Conversation SID.
1511
+ * @param links Conversation links for REST requests.
1512
+ * @param configuration Client configuration.
1513
+ * @param services Conversation services.
1514
+ * @internal
1515
+ */
1516
+ constructor(descriptor: ConversationDescriptor, sid: string, links: ConversationLinks, configuration: Configuration, services: ConversationServices);
1457
1517
  /**
1458
1518
  * Unique name of the conversation.
1459
1519
  */
@@ -1494,6 +1554,10 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1494
1554
  * User notification level for this conversation.
1495
1555
  */
1496
1556
  get notificationLevel(): NotificationLevel;
1557
+ /**
1558
+ * Conversation bindings. Undocumented feature (for now).
1559
+ * @internal
1560
+ */
1497
1561
  get bindings(): ConversationBindings;
1498
1562
  /**
1499
1563
  * Current conversation limits.
@@ -1504,65 +1568,38 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1504
1568
  */
1505
1569
  get state(): ConversationState | undefined;
1506
1570
  /**
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.
1571
+ * Source of the conversation update.
1529
1572
  * @internal
1530
1573
  */
1531
- _setStatus(status: ConversationStatus, source: ConversationsDataSource): void;
1574
+ get _statusSource(): ConversationsDataSource;
1532
1575
  /**
1533
- * Get the source of the conversation update.
1534
- * @internal
1576
+ * Preprocess the update object.
1577
+ * @param update The update object received from Sync.
1578
+ * @param conversationSid The SID of the conversation in question.
1535
1579
  */
1536
- _statusSource(): ConversationsDataSource;
1537
1580
  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
1581
  /**
1549
1582
  * Add a participant to the conversation by its identity.
1550
1583
  * @param identity Identity of the Client to add.
1551
1584
  * @param attributes Attributes to be attached to the participant.
1585
+ * @returns The added participant.
1552
1586
  */
1553
- add(identity: string, attributes?: JSONValue): Promise<ParticipantResponse>;
1587
+ add(identity: string, attributes?: JSONValue): Promise<Participant>;
1554
1588
  /**
1555
1589
  * Add a non-chat participant to the conversation.
1556
1590
  * @param proxyAddress Proxy (Twilio) address of the participant.
1557
1591
  * @param address User address of the participant.
1558
1592
  * @param attributes Attributes to be attached to the participant.
1559
- * @param bindingOptions Options for adding email participants - name and CC/To level.
1593
+ * @param bindingOptions Options for adding email participants - name and
1594
+ * CC/To level.
1595
+ * @returns The added participant.
1560
1596
  */
1561
- addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<ParticipantResponse>;
1597
+ addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<Participant>;
1562
1598
  /**
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.
1599
+ * Advance the conversation's last read message index to the current read
1600
+ * horizon. Rejects if the user is not a participant of the conversation. Last
1601
+ * read message index is updated only if the new index value is higher than
1602
+ * the previous.
1566
1603
  * @param index Message index to advance to.
1567
1604
  * @return Resulting unread messages count in the conversation.
1568
1605
  */
@@ -1577,10 +1614,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1577
1614
  getAttributes(): Promise<JSONValue>;
1578
1615
  /**
1579
1616
  * 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.
1617
+ * @param pageSize Number of messages to return in a single chunk. Default is
1618
+ * 30.
1619
+ * @param anchor Index of the newest message to fetch. Default is from the
1620
+ * end.
1621
+ * @param direction Query direction. By default, it queries backwards
1622
+ * from newer to older. The `"forward"` value will query in the opposite
1623
+ * direction.
1584
1624
  * @return A page of messages.
1585
1625
  */
1586
1626
  getMessages(pageSize?: number, anchor?: number, direction?: "backwards" | "forward"): Promise<Paginator<Message>>;
@@ -1591,12 +1631,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1591
1631
  /**
1592
1632
  * Get conversation participants count.
1593
1633
  *
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.
1634
+ * This method is semi-realtime. This means that this data will be eventually
1635
+ * correct, but will also be possibly incorrect for a few seconds. The
1636
+ * Conversations system does not provide real time events for counter values
1637
+ * changes.
1597
1638
  *
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.
1639
+ * This is useful for any UI badges, but it is not recommended to build any
1640
+ * core application logic based on these counters being accurate in real time.
1600
1641
  */
1601
1642
  getParticipantsCount(): Promise<number>;
1602
1643
  /**
@@ -1612,28 +1653,30 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1612
1653
  /**
1613
1654
  * Get the total message count in the conversation.
1614
1655
  *
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.
1656
+ * This method is semi-realtime. This means that this data will be eventually
1657
+ * correct, but will also be possibly incorrect for a few seconds. The
1658
+ * Conversations system does not provide real time events for counter values
1659
+ * changes.
1618
1660
  *
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.
1661
+ * This is useful for any UI badges, but it is not recommended to build any
1662
+ * core application logic based on these counters being accurate in real time.
1621
1663
  */
1622
1664
  getMessagesCount(): Promise<number>;
1623
1665
  /**
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.
1666
+ * Get unread messages count for the user if they are a participant of this
1667
+ * conversation. Rejects if the user is not a participant of the conversation.
1626
1668
  *
1627
1669
  * Use this method to obtain the number of unread messages together with
1628
1670
  * {@link Conversation.updateLastReadMessageIndex} instead of relying on the
1629
1671
  * message indices which may have gaps. See {@link Message.index} for details.
1630
1672
  *
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.
1673
+ * This method is semi-realtime. This means that this data will be eventually
1674
+ * correct, but will also be possibly incorrect for a few seconds. The
1675
+ * Conversations system does not provide real time events for counter values
1676
+ * changes.
1634
1677
  *
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.
1678
+ * This is useful for any UI badges, but it is not recommended to build any
1679
+ * core application logic based on these counters being accurate in real time.
1637
1680
  */
1638
1681
  getUnreadMessagesCount(): Promise<number | null>;
1639
1682
  /**
@@ -1655,7 +1698,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1655
1698
  /**
1656
1699
  * Send a message to the conversation.
1657
1700
  * @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.
1701
+ * `FormData` or {@link SendMediaOptions} for media content. Sending FormData
1702
+ * is supported only with the browser engine.
1659
1703
  * @param messageAttributes Attributes for the message.
1660
1704
  * @param emailOptions Email options for the message.
1661
1705
  * @return Index of the new message.
@@ -1663,12 +1707,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1663
1707
  sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<number>;
1664
1708
  /**
1665
1709
  * New interface to prepare for sending a message.
1666
- * Use instead of `sendMessage`.
1710
+ * Use this instead of {@link Message.sendMessage}.
1667
1711
  * @return A MessageBuilder to help set all message sending options.
1668
1712
  */
1669
1713
  prepareMessage(): MessageBuilder;
1670
1714
  /**
1671
- * Set last read message index of the conversation to the index of the last known message.
1715
+ * Set last read message index of the conversation to the index of the last
1716
+ * known message.
1672
1717
  * @return Resulting unread messages count in the conversation.
1673
1718
  */
1674
1719
  setAllMessagesRead(): Promise<number>;
@@ -1683,8 +1728,10 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1683
1728
  */
1684
1729
  setUserNotificationLevel(notificationLevel: NotificationLevel): Promise<void>;
1685
1730
  /**
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.
1731
+ * Send a notification to the server indicating that this client is currently
1732
+ * typing in this conversation. Typing ended notification is sent after a
1733
+ * while automatically, but by calling this method again you ensure that
1734
+ * typing ended is not received.
1688
1735
  */
1689
1736
  typing(): Promise<void>;
1690
1737
  /**
@@ -1699,21 +1746,61 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1699
1746
  updateFriendlyName(friendlyName: string): Promise<Conversation>;
1700
1747
  /**
1701
1748
  * 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}.
1749
+ * @param index Message index to set as last read. If null is provided, then
1750
+ * the behavior is identical to {@link Conversation.setAllMessagesUnread}.
1704
1751
  * @returns Resulting unread messages count in the conversation.
1705
1752
  */
1706
1753
  updateLastReadMessageIndex(index: number | null): Promise<number>;
1707
1754
  /**
1708
1755
  * Update the unique name of the conversation.
1709
- * @param uniqueName New unique name for the conversation. Setting unique name to null removes it.
1756
+ * @param uniqueName New unique name for the conversation. Setting unique name
1757
+ * to null removes it.
1710
1758
  */
1711
1759
  updateUniqueName(uniqueName: string | null): Promise<Conversation>;
1760
+ /**
1761
+ * Load and subscribe to this conversation and do not subscribe to its
1762
+ * participants and messages. This or _subscribeStreams will need to be called
1763
+ * before any events on conversation will fire.
1764
+ * @internal
1765
+ */
1766
+ _subscribe(): Promise<SyncDocument>;
1767
+ /**
1768
+ * Load the attributes of this conversation and instantiate its participants
1769
+ * and messages. This or _subscribe will need to be called before any events
1770
+ * on the conversation will fire. This will need to be called before any
1771
+ * events on participants or messages will fire
1772
+ * @internal
1773
+ */
1774
+ _subscribeStreams(): Promise<void>;
1775
+ /**
1776
+ * Stop listening for and firing events on this conversation.
1777
+ * @internal
1778
+ */
1779
+ _unsubscribe(): Promise<[
1780
+ void,
1781
+ void
1782
+ ]>;
1783
+ /**
1784
+ * Set conversation status.
1785
+ * @internal
1786
+ */
1787
+ _setStatus(status: ConversationStatus, source: ConversationsDataSource): void;
1788
+ /**
1789
+ * Update the local conversation object with new values.
1790
+ * @internal
1791
+ */
1792
+ _update(update: any): void;
1793
+ /**
1794
+ * Handle onMessageAdded event.
1795
+ */
1796
+ private _onMessageAdded;
1797
+ /**
1798
+ * Set last read message index.
1799
+ * @param index New index to set.
1800
+ */
1801
+ private _setLastReadMessageIndex;
1712
1802
  }
1713
- type ConversationsDataSource = "sync" | "chat" | "rest";
1714
- /**
1715
- * Push notification type.
1716
- */
1803
+ type ConversationsDataSource = "sync" | "rest";
1717
1804
  type PushNotificationType = "twilio.conversations.new_message" | "twilio.conversations.added_to_conversation" | "twilio.conversations.removed_from_conversation";
1718
1805
  interface PushNotificationDescriptor {
1719
1806
  title: string | null;
@@ -1732,6 +1819,10 @@ interface PushNotificationData {
1732
1819
  * SID of the conversation.
1733
1820
  */
1734
1821
  conversationSid?: string;
1822
+ /**
1823
+ * Title of the conversation.
1824
+ */
1825
+ conversationTitle?: string;
1735
1826
  /**
1736
1827
  * Index of the message in the conversation.
1737
1828
  */
@@ -1740,6 +1831,14 @@ interface PushNotificationData {
1740
1831
  * SID of the message in the conversation.
1741
1832
  */
1742
1833
  messageSid?: string;
1834
+ /**
1835
+ * Media of the notification
1836
+ */
1837
+ media?: Media;
1838
+ /**
1839
+ * Amount of the attached media of the message.
1840
+ */
1841
+ mediaCount?: number;
1743
1842
  }
1744
1843
  /**
1745
1844
  * Push notification for a Conversations client.
@@ -1778,6 +1877,9 @@ declare class PushNotification {
1778
1877
  */
1779
1878
  constructor(data: PushNotificationDescriptor);
1780
1879
  }
1880
+ /**
1881
+ * Client events.
1882
+ */
1781
1883
  type ClientEvents = {
1782
1884
  conversationAdded: (conversation: Conversation) => void;
1783
1885
  conversationJoined: (conversation: Conversation) => void;
@@ -1799,7 +1901,7 @@ type ClientEvents = {
1799
1901
  message: Message;
1800
1902
  updateReasons: MessageUpdateReason[];
1801
1903
  }) => void;
1802
- tokenAboutToExpire: (ttl: number) => void;
1904
+ tokenAboutToExpire: () => void;
1803
1905
  tokenExpired: () => void;
1804
1906
  typingEnded: (participant: Participant) => void;
1805
1907
  typingStarted: (participant: Participant) => void;
@@ -1810,22 +1912,22 @@ type ClientEvents = {
1810
1912
  user: User;
1811
1913
  updateReasons: UserUpdateReason[];
1812
1914
  }) => 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;
1915
+ stateChanged: ({ state, error }: {
1916
+ state: State;
1917
+ error?: ConnectionError;
1820
1918
  }) => void;
1919
+ connectionStateChanged: (state: TwilsockConnectionState) => void;
1920
+ connectionError: (data: ConnectionError) => void;
1821
1921
  };
1822
1922
  /**
1823
1923
  * Connection state of the client. Possible values are as follows:
1824
1924
  * * `'connecting'` - client is offline and connection attempt is in process
1825
1925
  * * `'connected'` - client is online and ready
1826
1926
  * * `'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
1927
+ * * `'disconnected'` - client is offline and no connection attempt is in
1928
+ * process
1929
+ * * `'denied'` - client connection is denied because of invalid JWT access
1930
+ * token. User must refresh token in order to proceed
1829
1931
  */
1830
1932
  type ConnectionState = TwilsockConnectionState;
1831
1933
  /**
@@ -1840,6 +1942,9 @@ type State = "failed" | "initialized";
1840
1942
  * * `'apn'`
1841
1943
  */
1842
1944
  type NotificationsChannelType = ChannelType;
1945
+ /**
1946
+ * Level of logging.
1947
+ */
1843
1948
  type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent";
1844
1949
  /**
1845
1950
  * Conversations client options.
@@ -1894,43 +1999,9 @@ interface CreateConversationOptions {
1894
1999
  */
1895
2000
  declare class Client extends ReplayEventEmitter<ClientEvents> {
1896
2001
  /**
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.
2002
+ * Fired when a conversation becomes visible to the client. The event is also
2003
+ * triggered when the client creates a new conversation.
2004
+ * Fired for all conversations that the client has joined.
1934
2005
  *
1935
2006
  * Parameters:
1936
2007
  * 1. {@link Conversation} `conversation` - the conversation in question
@@ -1962,14 +2033,17 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
1962
2033
  */
1963
2034
  static readonly conversationRemoved = "conversationRemoved";
1964
2035
  /**
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.
2036
+ * Fired when the attributes or the metadata of a conversation have been
2037
+ * updated. During conversation's creation and initialization, this event
2038
+ * might be fired multiple times for same joined or created conversation as
2039
+ * new data is arriving from different sources.
1968
2040
  *
1969
2041
  * Parameters:
1970
- * 1. object `data` - info object provided with the event. It has the following properties:
2042
+ * 1. object `data` - info object provided with the event. It has the
2043
+ * following properties:
1971
2044
  * * {@link Conversation} `conversation` - the conversation in question
1972
- * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons for the update
2045
+ * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
2046
+ * for the update
1973
2047
  * @event
1974
2048
  */
1975
2049
  static readonly conversationUpdated = "conversationUpdated";
@@ -1993,9 +2067,11 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
1993
2067
  * Fired when a participant's fields have been updated.
1994
2068
  *
1995
2069
  * Parameters:
1996
- * 1. object `data` - info object provided with the event. It has the following properties:
2070
+ * 1. object `data` - info object provided with the event. It has the
2071
+ * following properties:
1997
2072
  * * {@link Participant} `participant` - the participant in question
1998
- * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons for the update
2073
+ * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
2074
+ * for the update
1999
2075
  * @event
2000
2076
  */
2001
2077
  static readonly participantUpdated = "participantUpdated";
@@ -2019,16 +2095,16 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2019
2095
  * Fired when the fields of an existing message are updated with new values.
2020
2096
  *
2021
2097
  * Parameters:
2022
- * 1. object `data` - info object provided with the event. It has the following properties:
2098
+ * 1. object `data` - info object provided with the event. It has the
2099
+ * following properties:
2023
2100
  * * {@link Message} `message` - the message in question
2024
- * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for the update
2101
+ * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
2102
+ * the update
2025
2103
  * @event
2026
2104
  */
2027
2105
  static readonly messageUpdated = "messageUpdated";
2028
2106
  /**
2029
2107
  * 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
2108
  * @event
2033
2109
  */
2034
2110
  static readonly tokenAboutToExpire = "tokenAboutToExpire";
@@ -2054,10 +2130,12 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2054
2130
  */
2055
2131
  static readonly typingStarted = "typingStarted";
2056
2132
  /**
2057
- * Fired when the client has received (and parsed) a push notification via one of the push channels (apn or fcm).
2133
+ * Fired when the client has received (and parsed) a push notification via one
2134
+ * of the push channels (apn or fcm).
2058
2135
  *
2059
2136
  * Parameters:
2060
- * 1. {@link PushNotification} `pushNotification` - the push notification in question
2137
+ * 1. {@link PushNotification} `pushNotification` - the push notification in
2138
+ * question
2061
2139
  * @event
2062
2140
  */
2063
2141
  static readonly pushNotification = "pushNotification";
@@ -2078,12 +2156,15 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2078
2156
  */
2079
2157
  static readonly userUnsubscribed = "userUnsubscribed";
2080
2158
  /**
2081
- * Fired when the properties or the reachability status of a user have been updated.
2159
+ * Fired when the properties or the reachability status of a user have been
2160
+ * updated.
2082
2161
  *
2083
2162
  * Parameters:
2084
- * 1. object `data` - info object provided with the event. It has the following properties:
2163
+ * 1. object `data` - info object provided with the event. It has the
2164
+ * following properties:
2085
2165
  * * {@link User} `user` - the user in question
2086
- * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update
2166
+ * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the
2167
+ * update
2087
2168
  * @event
2088
2169
  */
2089
2170
  static readonly userUpdated = "userUpdated";
@@ -2091,14 +2172,17 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2091
2172
  * Fired when the state of the client has been changed.
2092
2173
  *
2093
2174
  * Parameters:
2094
- * 1. {@link State} `state` - the new client state
2175
+ * 1. object `data` - info object provided with the event. It has the
2176
+ * following properties:
2177
+ * * {@link State} `state` - the new client state
2178
+ * * Error? `error` - the initialization error if present
2095
2179
  * @event
2096
2180
  */
2097
2181
  static readonly stateChanged = "stateChanged";
2098
2182
  /**
2099
2183
  * Fired when the connection state of the client has been changed.
2100
2184
  *
2101
- * Paremeters:
2185
+ * Parameters:
2102
2186
  * 1. {@link ConnectionState} `state` - the new connection state
2103
2187
  * @event
2104
2188
  */
@@ -2107,7 +2191,8 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2107
2191
  * Fired when the connection is interrupted for an unexpected reason.
2108
2192
  *
2109
2193
  * Parameters:
2110
- * 1. object `data` - info object provided with the event. It has the following properties:
2194
+ * 1. object `data` - info object provided with the event. It has the
2195
+ * following properties:
2111
2196
  * * boolean `terminal` - Twilsock will stop connection attempts if true
2112
2197
  * * string `message` - the error message of the root cause
2113
2198
  * * number? `httpStatusCode` - http status code if available
@@ -2115,6 +2200,93 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2115
2200
  * @event
2116
2201
  */
2117
2202
  static readonly connectionError = "connectionError";
2203
+ /**
2204
+ * Current version of the Conversations client.
2205
+ */
2206
+ static readonly version: string;
2207
+ /**
2208
+ * Logger instance.
2209
+ */
2210
+ private static readonly _logger;
2211
+ /**
2212
+ * Supported push notification channels.
2213
+ */
2214
+ private static readonly _supportedPushChannels;
2215
+ /**
2216
+ * Supported push data fields.
2217
+ */
2218
+ private static readonly _supportedPushDataFields;
2219
+ /**
2220
+ * Current version of the Conversations client.
2221
+ */
2222
+ readonly version: string;
2223
+ /**
2224
+ * Client connection state.
2225
+ */
2226
+ connectionState: ConnectionState;
2227
+ /**
2228
+ * Promise that resolves on successful initialization.
2229
+ */
2230
+ private readonly _ensureReady;
2231
+ /**
2232
+ * Options passed to the client.
2233
+ */
2234
+ private readonly _options;
2235
+ /**
2236
+ * Client service objects.
2237
+ */
2238
+ private readonly _services;
2239
+ /**
2240
+ * The user of the client.
2241
+ */
2242
+ private readonly _myself;
2243
+ /**
2244
+ * Resolves the {@link Client._ensureReady} promise.
2245
+ */
2246
+ private _resolveEnsureReady;
2247
+ /**
2248
+ * Rejects the {@link Client._ensureReady} promise.
2249
+ */
2250
+ private _rejectEnsureReady;
2251
+ /**
2252
+ * The current token of the client.
2253
+ */
2254
+ private _fpaToken;
2255
+ /**
2256
+ * The constructed configuration object.
2257
+ */
2258
+ private _configuration;
2259
+ /**
2260
+ * The Conversations entity.
2261
+ */
2262
+ private _conversationsEntity;
2263
+ /**
2264
+ * Promise that resolves when initial conversations are fetched.
2265
+ */
2266
+ private _conversationsPromise;
2267
+ /**
2268
+ * Returned Conversations instance is not yet fully initialized. Calling any
2269
+ * operations will block until it is. Use connection events to monitor when
2270
+ * client becomes fully available (connectionStateChanged with state
2271
+ * 'connected') or not available (connectionStateChange with state 'denied',
2272
+ * event tokenExpired, event connectionError).
2273
+ *
2274
+ * @param fpaToken Access token
2275
+ * @param options Options to customize the Client
2276
+ * @returns A not yet fully-initialized client.
2277
+ */
2278
+ constructor(fpaToken: string, options?: ClientOptions | null);
2279
+ /**
2280
+ * Information of the logged-in user. Before client initialization, returns an
2281
+ * uninitialized user. Will trigger a {@link Client.userUpdated} event after
2282
+ * initialization.
2283
+ */
2284
+ get user(): User;
2285
+ /**
2286
+ * Client reachability state. Throws an error if accessed before the client
2287
+ * initialization was completed.
2288
+ */
2289
+ get reachabilityEnabled(): boolean;
2118
2290
  /**
2119
2291
  * @deprecated Call constructor directly.
2120
2292
  *
@@ -2136,20 +2308,21 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2136
2308
  */
2137
2309
  static create(token: string, options?: ClientOptions | null): Promise<Client>;
2138
2310
  /**
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.
2311
+ * Static method for push notification payload parsing. Returns parsed push as
2312
+ * a {@link PushNotification} object.
2313
+ * @param notificationPayload Push notification payload.
2142
2314
  */
2143
- get user(): User;
2315
+ static parsePushNotification(notificationPayload: any): PushNotification;
2144
2316
  /**
2145
- * Client reachability state. Throws if accessed before the client
2146
- * initialization was completed.
2317
+ * Static method for parsing push notification chat data.
2318
+ * @param data Data to parse
2147
2319
  */
2148
- get reachabilityEnabled(): boolean;
2149
- get token(): string;
2150
- private _subscribeToPushNotifications;
2151
- private _unsubscribeFromPushNotifications;
2152
- private _initialize;
2320
+ private static _parsePushNotificationChatData;
2321
+ /**
2322
+ * Populate the client with init registrations.
2323
+ * @param reg The init registration to populate.
2324
+ */
2325
+ static populateInitRegistrations(reg: InitRegistration): void;
2153
2326
  /**
2154
2327
  * Gracefully shut down the client.
2155
2328
  */
@@ -2164,6 +2337,12 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2164
2337
  * @param conversationSid Conversation sid
2165
2338
  */
2166
2339
  getConversationBySid(conversationSid: string): Promise<Conversation>;
2340
+ /**
2341
+ * Peek a conversation by its SID.
2342
+ * @param conversationSid Conversation sid
2343
+ * @internal
2344
+ */
2345
+ peekConversationBySid(conversationSid: string): Promise<Conversation>;
2167
2346
  /**
2168
2347
  * Get a known conversation by its unique identifier name.
2169
2348
  * @param uniqueName The unique identifier name of the conversation.
@@ -2182,7 +2361,8 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2182
2361
  /**
2183
2362
  * Register for push notifications.
2184
2363
  * @param channelType Channel type.
2185
- * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.
2364
+ * @param registrationId Push notification ID provided by the FCM/APNS service
2365
+ * on the platform.
2186
2366
  */
2187
2367
  setPushRegistrationId(channelType: NotificationsChannelType, registrationId: string): Promise<void>;
2188
2368
  /**
@@ -2195,27 +2375,29 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2195
2375
  * Clear existing registrations directly using provided device token.
2196
2376
  * This is useful to ensure stopped subscriptions without resubscribing.
2197
2377
  *
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.
2378
+ * This function goes completely beside the state machine and removes all
2379
+ * registrations.
2380
+ * Use with caution: if it races with current state machine operations,
2381
+ * madness will ensue.
2200
2382
  *
2201
2383
  * @param channelType Channel type.
2202
- * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.
2384
+ * @param registrationId Push notification ID provided by the FCM/APNS service
2385
+ * on the platform.
2203
2386
  */
2204
2387
  removePushRegistrations(channelType: ChannelType, registrationId: string): Promise<void>;
2205
- private static parsePushNotificationChatData;
2206
2388
  /**
2207
- * Static method for push notification payload parsing. Returns parsed push as a {@link PushNotification} object.
2208
- * @param notificationPayload Push notification payload.
2389
+ * Current version of the Conversations client.
2209
2390
  */
2210
- static parsePushNotification(notificationPayload: any): PushNotification;
2211
2391
  parsePushNotification: typeof Client.parsePushNotification;
2212
2392
  /**
2213
- * Handle push notification payload parsing and emit the {@link Client.pushNotification} event on this {@link Client} instance.
2393
+ * Handle push notification payload parsing and emit the
2394
+ * {@link Client.pushNotification} event on this {@link Client} instance.
2214
2395
  * @param notificationPayload Push notification payload
2215
2396
  */
2216
2397
  handlePushNotification(notificationPayload: any): Promise<void>;
2217
2398
  /**
2218
- * Gets a user with the given identity. If it's in the subscribed list, then return the user object from it;
2399
+ * Gets a user with the given identity. If it's in the subscribed list, then
2400
+ * return the user object from it;
2219
2401
  * if not, then subscribe and add user to the subscribed list.
2220
2402
  * @param identity Identity of the user.
2221
2403
  * @returns A fully initialized user.
@@ -2225,6 +2407,32 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2225
2407
  * Get a list of subscribed user objects.
2226
2408
  */
2227
2409
  getSubscribedUsers(): Promise<Array<User>>;
2410
+ /**
2411
+ * Get content URLs for all media attachments in the given set of media sids
2412
+ * using a single operation.
2413
+ * @param mediaSids Set of media sids to query for the content URL.
2414
+ */
2415
+ getTemporaryContentUrlsForMediaSids(mediaSids: string[]): CancellablePromise<Map<string, string>>;
2416
+ /**
2417
+ * Get content URLs for all media attachments in the given set using a single
2418
+ * operation.
2419
+ * @param contentSet Set of media attachments to query content URLs.
2420
+ */
2421
+ getTemporaryContentUrlsForMedia(contentSet: Media[]): CancellablePromise<Map<string, string>>;
2422
+ /**
2423
+ * Initialize the client.
2424
+ */
2425
+ private _initialize;
2426
+ /**
2427
+ * Subscribe to push notifications.
2428
+ * @param channelType The channel type to subscribe to.
2429
+ */
2430
+ private _subscribeToPushNotifications;
2431
+ /**
2432
+ * Unsubscribe from push notifications.
2433
+ * @param channelType The channel type to unsubscribe from.
2434
+ */
2435
+ private _unsubscribeFromPushNotifications;
2228
2436
  }
2229
2437
  declare class NotificationTypes {
2230
2438
  static readonly TYPING_INDICATOR = "twilio.ipmsg.typing_indicator";