@twilio/conversations 2.1.0-rc.8 → 3.0.0-canary.13

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 (69) hide show
  1. package/README.md +8 -4
  2. package/builds/browser.js +2730 -1984
  3. package/builds/browser.js.map +1 -1
  4. package/builds/lib.d.ts +516 -307
  5. package/builds/lib.js +2730 -1984
  6. package/builds/lib.js.map +1 -1
  7. package/builds/twilio-conversations.js +5347 -4949
  8. package/builds/twilio-conversations.min.js +1 -16
  9. package/dist/aggregated-delivery-receipt.js.map +1 -1
  10. package/dist/client.js +429 -284
  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 +405 -369
  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 +6 -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 +60 -29
  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/docs/assets/js/search.js +1 -1
  55. package/docs/classes/Client.html +205 -39
  56. package/docs/classes/Conversation.html +103 -51
  57. package/docs/classes/Media.html +2 -28
  58. package/docs/classes/Message.html +94 -39
  59. package/docs/classes/MessageBuilder.html +31 -8
  60. package/docs/classes/PushNotification.html +1 -1
  61. package/docs/classes/UnsentMessage.html +2 -2
  62. package/docs/index.html +20 -27
  63. package/docs/interfaces/ConversationLimits.html +12 -12
  64. package/docs/interfaces/ConversationState.html +2 -2
  65. package/docs/interfaces/ConversationUpdatedEventArgs.html +3001 -0
  66. package/docs/interfaces/PushNotificationData.html +48 -0
  67. package/docs/modules.html +19 -26
  68. package/package.json +24 -20
  69. package/CHANGELOG.md +0 -404
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,72 +1554,52 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1494
1554
  * User notification level for this conversation.
1495
1555
  */
1496
1556
  get notificationLevel(): NotificationLevel;
1497
- get bindings(): ConversationBindings;
1498
- get limits(): ConversationLimits;
1499
- /**
1500
- * State of the conversation.
1501
- */
1502
- get state(): ConversationState | undefined;
1503
1557
  /**
1504
- * Load and subscribe to this conversation and do not subscribe to its participants and messages.
1505
- * This or _subscribeStreams will need to be called before any events on conversation will fire.
1558
+ * Conversation bindings. Undocumented feature (for now).
1506
1559
  * @internal
1507
1560
  */
1508
- _subscribe(): Promise<void | SyncDocument>;
1561
+ get bindings(): ConversationBindings;
1509
1562
  /**
1510
- * Load the attributes of this conversation and instantiate its participants and messages.
1511
- * This or _subscribe will need to be called before any events on the conversation will fire.
1512
- * This will need to be called before any events on participants or messages will fire
1513
- * @internal
1563
+ * Current conversation limits.
1514
1564
  */
1515
- _subscribeStreams(): Promise<void>;
1565
+ get limits(): ConversationLimits;
1516
1566
  /**
1517
- * Stop listening for and firing events on this conversation.
1518
- * @internal
1567
+ * State of the conversation.
1519
1568
  */
1520
- _unsubscribe(): Promise<[
1521
- void,
1522
- void
1523
- ]>;
1569
+ get state(): ConversationState | undefined;
1524
1570
  /**
1525
- * Set conversation status.
1571
+ * Source of the conversation update.
1526
1572
  * @internal
1527
1573
  */
1528
- _setStatus(status: ConversationStatus, source: ConversationsDataSource): void;
1574
+ get _statusSource(): ConversationsDataSource;
1529
1575
  /**
1530
- * Get the source of the conversation update.
1531
- * @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.
1532
1579
  */
1533
- _statusSource(): ConversationsDataSource;
1534
1580
  private static preprocessUpdate;
1535
- /**
1536
- * Update the local conversation object with new values.
1537
- * @internal
1538
- */
1539
- _update(update: any): void;
1540
- /**
1541
- * @internal
1542
- */
1543
- private _onMessageAdded;
1544
- private _setLastReadMessageIndex;
1545
1581
  /**
1546
1582
  * Add a participant to the conversation by its identity.
1547
1583
  * @param identity Identity of the Client to add.
1548
1584
  * @param attributes Attributes to be attached to the participant.
1585
+ * @returns The added participant.
1549
1586
  */
1550
- add(identity: string, attributes?: JSONValue): Promise<ParticipantResponse>;
1587
+ add(identity: string, attributes?: JSONValue): Promise<Participant>;
1551
1588
  /**
1552
1589
  * Add a non-chat participant to the conversation.
1553
1590
  * @param proxyAddress Proxy (Twilio) address of the participant.
1554
1591
  * @param address User address of the participant.
1555
1592
  * @param attributes Attributes to be attached to the participant.
1556
- * @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.
1557
1596
  */
1558
- addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<ParticipantResponse>;
1597
+ addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<Participant>;
1559
1598
  /**
1560
- * Advance the conversation's last read message index to the current read horizon.
1561
- * Rejects if the user is not a participant of the conversation.
1562
- * 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.
1563
1603
  * @param index Message index to advance to.
1564
1604
  * @return Resulting unread messages count in the conversation.
1565
1605
  */
@@ -1574,10 +1614,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1574
1614
  getAttributes(): Promise<JSONValue>;
1575
1615
  /**
1576
1616
  * Returns messages from the conversation using the paginator interface.
1577
- * @param pageSize Number of messages to return in a single chunk. Default is 30.
1578
- * @param anchor Index of the newest message to fetch. Default is from the end.
1579
- * @param direction Query direction. By default it queries backwards
1580
- * 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.
1581
1624
  * @return A page of messages.
1582
1625
  */
1583
1626
  getMessages(pageSize?: number, anchor?: number, direction?: "backwards" | "forward"): Promise<Paginator<Message>>;
@@ -1588,12 +1631,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1588
1631
  /**
1589
1632
  * Get conversation participants count.
1590
1633
  *
1591
- * This method is semi-realtime. This means that this data will be eventually correct,
1592
- * but will also be possibly incorrect for a few seconds. The Conversations system does not
1593
- * 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.
1594
1638
  *
1595
- * This is useful for any UI badges, but it is not recommended to build any core application
1596
- * 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.
1597
1641
  */
1598
1642
  getParticipantsCount(): Promise<number>;
1599
1643
  /**
@@ -1609,28 +1653,30 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1609
1653
  /**
1610
1654
  * Get the total message count in the conversation.
1611
1655
  *
1612
- * This method is semi-realtime. This means that this data will be eventually correct,
1613
- * but will also be possibly incorrect for a few seconds. The Conversations system does not
1614
- * 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.
1615
1660
  *
1616
- * This is useful for any UI badges, but it is not recommended to build any core application
1617
- * 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.
1618
1663
  */
1619
1664
  getMessagesCount(): Promise<number>;
1620
1665
  /**
1621
- * Get unread messages count for the user if they are a participant of this conversation.
1622
- * 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.
1623
1668
  *
1624
1669
  * Use this method to obtain the number of unread messages together with
1625
1670
  * {@link Conversation.updateLastReadMessageIndex} instead of relying on the
1626
1671
  * message indices which may have gaps. See {@link Message.index} for details.
1627
1672
  *
1628
- * This method is semi-realtime. This means that this data will be eventually correct,
1629
- * but will also be possibly incorrect for a few seconds. The Conversations system does not
1630
- * 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.
1631
1677
  *
1632
- * This is useful for any UI badges, but it is not recommended to build any core application
1633
- * 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.
1634
1680
  */
1635
1681
  getUnreadMessagesCount(): Promise<number | null>;
1636
1682
  /**
@@ -1646,13 +1692,12 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1646
1692
  * argument, it will assume that the string is an identity or SID.
1647
1693
  * @param participant Identity, SID or the participant object to remove.
1648
1694
  */
1649
- /* eslint-disable @typescript-eslint/ban-ts-comment */
1650
- // @ts-ignore TODO: fix validateTypesAsync typing
1651
1695
  removeParticipant(participant: string | Participant): Promise<void>;
1652
1696
  /**
1653
1697
  * Send a message to the conversation.
1654
1698
  * @param message Message body for the text message,
1655
- * `FormData` or {@link SendMediaOptions} for media content. Sending FormData is supported only with the browser engine.
1699
+ * `FormData` or {@link SendMediaOptions} for media content. Sending FormData
1700
+ * is supported only with the browser engine.
1656
1701
  * @param messageAttributes Attributes for the message.
1657
1702
  * @param emailOptions Email options for the message.
1658
1703
  * @return Index of the new message.
@@ -1660,12 +1705,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1660
1705
  sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<number>;
1661
1706
  /**
1662
1707
  * New interface to prepare for sending a message.
1663
- * Use instead of `sendMessage`.
1708
+ * Use this instead of {@link Message.sendMessage}.
1664
1709
  * @return A MessageBuilder to help set all message sending options.
1665
1710
  */
1666
1711
  prepareMessage(): MessageBuilder;
1667
1712
  /**
1668
- * Set last read message index of the conversation to the index of the last known message.
1713
+ * Set last read message index of the conversation to the index of the last
1714
+ * known message.
1669
1715
  * @return Resulting unread messages count in the conversation.
1670
1716
  */
1671
1717
  setAllMessagesRead(): Promise<number>;
@@ -1680,8 +1726,10 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1680
1726
  */
1681
1727
  setUserNotificationLevel(notificationLevel: NotificationLevel): Promise<void>;
1682
1728
  /**
1683
- * Send a notification to the server indicating that this client is currently typing in this conversation.
1684
- * Typing ended notification is sent after a while automatically, but by calling this method again you ensure that typing ended is not received.
1729
+ * Send a notification to the server indicating that this client is currently
1730
+ * typing in this conversation. Typing ended notification is sent after a
1731
+ * while automatically, but by calling this method again you ensure that
1732
+ * typing ended is not received.
1685
1733
  */
1686
1734
  typing(): Promise<void>;
1687
1735
  /**
@@ -1696,21 +1744,61 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1696
1744
  updateFriendlyName(friendlyName: string): Promise<Conversation>;
1697
1745
  /**
1698
1746
  * Set the last read message index to the current read horizon.
1699
- * @param index Message index to set as last read.
1700
- * If null is provided, then the behavior is identical to {@link Conversation.setAllMessagesUnread}.
1747
+ * @param index Message index to set as last read. If null is provided, then
1748
+ * the behavior is identical to {@link Conversation.setAllMessagesUnread}.
1701
1749
  * @returns Resulting unread messages count in the conversation.
1702
1750
  */
1703
1751
  updateLastReadMessageIndex(index: number | null): Promise<number>;
1704
1752
  /**
1705
1753
  * Update the unique name of the conversation.
1706
- * @param uniqueName New unique name for the conversation. Setting unique name to null removes it.
1754
+ * @param uniqueName New unique name for the conversation. Setting unique name
1755
+ * to null removes it.
1707
1756
  */
1708
1757
  updateUniqueName(uniqueName: string | null): Promise<Conversation>;
1758
+ /**
1759
+ * Load and subscribe to this conversation and do not subscribe to its
1760
+ * participants and messages. This or _subscribeStreams will need to be called
1761
+ * before any events on conversation will fire.
1762
+ * @internal
1763
+ */
1764
+ _subscribe(): Promise<SyncDocument>;
1765
+ /**
1766
+ * Load the attributes of this conversation and instantiate its participants
1767
+ * and messages. This or _subscribe will need to be called before any events
1768
+ * on the conversation will fire. This will need to be called before any
1769
+ * events on participants or messages will fire
1770
+ * @internal
1771
+ */
1772
+ _subscribeStreams(): Promise<void>;
1773
+ /**
1774
+ * Stop listening for and firing events on this conversation.
1775
+ * @internal
1776
+ */
1777
+ _unsubscribe(): Promise<[
1778
+ void,
1779
+ void
1780
+ ]>;
1781
+ /**
1782
+ * Set conversation status.
1783
+ * @internal
1784
+ */
1785
+ _setStatus(status: ConversationStatus, source: ConversationsDataSource): void;
1786
+ /**
1787
+ * Update the local conversation object with new values.
1788
+ * @internal
1789
+ */
1790
+ _update(update: any): void;
1791
+ /**
1792
+ * Handle onMessageAdded event.
1793
+ */
1794
+ private _onMessageAdded;
1795
+ /**
1796
+ * Set last read message index.
1797
+ * @param index New index to set.
1798
+ */
1799
+ private _setLastReadMessageIndex;
1709
1800
  }
1710
- type ConversationsDataSource = "sync" | "chat" | "rest";
1711
- /**
1712
- * Push notification type.
1713
- */
1801
+ type ConversationsDataSource = "sync" | "rest";
1714
1802
  type PushNotificationType = "twilio.conversations.new_message" | "twilio.conversations.added_to_conversation" | "twilio.conversations.removed_from_conversation";
1715
1803
  interface PushNotificationDescriptor {
1716
1804
  title: string | null;
@@ -1729,6 +1817,10 @@ interface PushNotificationData {
1729
1817
  * SID of the conversation.
1730
1818
  */
1731
1819
  conversationSid?: string;
1820
+ /**
1821
+ * Title of the conversation.
1822
+ */
1823
+ conversationTitle?: string;
1732
1824
  /**
1733
1825
  * Index of the message in the conversation.
1734
1826
  */
@@ -1737,6 +1829,14 @@ interface PushNotificationData {
1737
1829
  * SID of the message in the conversation.
1738
1830
  */
1739
1831
  messageSid?: string;
1832
+ /**
1833
+ * Media of the notification
1834
+ */
1835
+ media?: Media;
1836
+ /**
1837
+ * Count of the attached media of the message.
1838
+ */
1839
+ mediaCount?: number;
1740
1840
  }
1741
1841
  /**
1742
1842
  * Push notification for a Conversations client.
@@ -1775,6 +1875,9 @@ declare class PushNotification {
1775
1875
  */
1776
1876
  constructor(data: PushNotificationDescriptor);
1777
1877
  }
1878
+ /**
1879
+ * Client events.
1880
+ */
1778
1881
  type ClientEvents = {
1779
1882
  conversationAdded: (conversation: Conversation) => void;
1780
1883
  conversationJoined: (conversation: Conversation) => void;
@@ -1796,7 +1899,7 @@ type ClientEvents = {
1796
1899
  message: Message;
1797
1900
  updateReasons: MessageUpdateReason[];
1798
1901
  }) => void;
1799
- tokenAboutToExpire: (ttl: number) => void;
1902
+ tokenAboutToExpire: () => void;
1800
1903
  tokenExpired: () => void;
1801
1904
  typingEnded: (participant: Participant) => void;
1802
1905
  typingStarted: (participant: Participant) => void;
@@ -1807,22 +1910,22 @@ type ClientEvents = {
1807
1910
  user: User;
1808
1911
  updateReasons: UserUpdateReason[];
1809
1912
  }) => void;
1810
- stateChanged: (state: State) => void;
1811
- connectionStateChanged: (state: TwilsockConnectionState) => void;
1812
- connectionError: (data: {
1813
- terminal: boolean;
1814
- message: string;
1815
- httpStatusCode?: number;
1816
- errorCode?: number;
1913
+ stateChanged: ({ state, error }: {
1914
+ state: State;
1915
+ error?: ConnectionError;
1817
1916
  }) => void;
1917
+ connectionStateChanged: (state: TwilsockConnectionState) => void;
1918
+ connectionError: (data: ConnectionError) => void;
1818
1919
  };
1819
1920
  /**
1820
1921
  * Connection state of the client. Possible values are as follows:
1821
1922
  * * `'connecting'` - client is offline and connection attempt is in process
1822
1923
  * * `'connected'` - client is online and ready
1823
1924
  * * `'disconnecting'` - client is going offline as disconnection is in process
1824
- * * `'disconnected'` - client is offline and no connection attempt is in process
1825
- * * `'denied'` - client connection is denied because of invalid JWT access token. User must refresh token in order to proceed
1925
+ * * `'disconnected'` - client is offline and no connection attempt is in
1926
+ * process
1927
+ * * `'denied'` - client connection is denied because of invalid JWT access
1928
+ * token. User must refresh token in order to proceed
1826
1929
  */
1827
1930
  type ConnectionState = TwilsockConnectionState;
1828
1931
  /**
@@ -1837,6 +1940,9 @@ type State = "failed" | "initialized";
1837
1940
  * * `'apn'`
1838
1941
  */
1839
1942
  type NotificationsChannelType = ChannelType;
1943
+ /**
1944
+ * Level of logging.
1945
+ */
1840
1946
  type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent";
1841
1947
  /**
1842
1948
  * Conversations client options.
@@ -1891,43 +1997,9 @@ interface CreateConversationOptions {
1891
1997
  */
1892
1998
  declare class Client extends ReplayEventEmitter<ClientEvents> {
1893
1999
  /**
1894
- * Client connection state.
1895
- */
1896
- connectionState: ConnectionState;
1897
- private conversationsPromise;
1898
- private _ensureReady;
1899
- private _resolveEnsureReady;
1900
- private _rejectEnsureReady;
1901
- private fpaToken;
1902
- private configuration;
1903
- private conversations;
1904
- private readonly options;
1905
- private services;
1906
- private readonly _myself;
1907
- /**
1908
- * Current version of the Conversations client.
1909
- */
1910
- static readonly version: string;
1911
- /**
1912
- * Current version of the Conversations client.
1913
- */
1914
- readonly version: string;
1915
- private static readonly supportedPushChannels;
1916
- private static readonly supportedPushDataFields;
1917
- /**
1918
- * Returned Conversations instance is not yet fully initialized. Calling any operations will block until it is.
1919
- * Use connection events to monitor when client becomes fully available (connectionStateChanged with state
1920
- * 'connected') or not available (connectionStateChange with state 'denied', event tokenExpired, event connectionError).
1921
- *
1922
- * @param fpaToken Access token
1923
- * @param options Options to customize the Client
1924
- * @returns A not yet fully-initialized client.
1925
- */
1926
- constructor(fpaToken: string, options?: ClientOptions | null);
1927
- static populateInitRegistrations(reg: InitRegistration): void;
1928
- /**
1929
- * Fired when a conversation becomes visible to the client. The event is also triggered when the client creates a new conversation.
1930
- * Fired for all conversations client has joined.
2000
+ * Fired when a conversation becomes visible to the client. The event is also
2001
+ * triggered when the client creates a new conversation.
2002
+ * Fired for all conversations that the client has joined.
1931
2003
  *
1932
2004
  * Parameters:
1933
2005
  * 1. {@link Conversation} `conversation` - the conversation in question
@@ -1959,14 +2031,17 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
1959
2031
  */
1960
2032
  static readonly conversationRemoved = "conversationRemoved";
1961
2033
  /**
1962
- * Fired when the attributes or the metadata of a conversation have been updated.
1963
- * During conversation's creation and initialization, this event might be fired multiple times
1964
- * for same joined or created conversation as new data is arriving from different sources.
2034
+ * Fired when the attributes or the metadata of a conversation have been
2035
+ * updated. During conversation's creation and initialization, this event
2036
+ * might be fired multiple times for same joined or created conversation as
2037
+ * new data is arriving from different sources.
1965
2038
  *
1966
2039
  * Parameters:
1967
- * 1. object `data` - info object provided with the event. It has the following properties:
2040
+ * 1. object `data` - info object provided with the event. It has the
2041
+ * following properties:
1968
2042
  * * {@link Conversation} `conversation` - the conversation in question
1969
- * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons for the update
2043
+ * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
2044
+ * for the update
1970
2045
  * @event
1971
2046
  */
1972
2047
  static readonly conversationUpdated = "conversationUpdated";
@@ -1990,9 +2065,11 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
1990
2065
  * Fired when a participant's fields have been updated.
1991
2066
  *
1992
2067
  * Parameters:
1993
- * 1. object `data` - info object provided with the event. It has the following properties:
2068
+ * 1. object `data` - info object provided with the event. It has the
2069
+ * following properties:
1994
2070
  * * {@link Participant} `participant` - the participant in question
1995
- * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons for the update
2071
+ * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
2072
+ * for the update
1996
2073
  * @event
1997
2074
  */
1998
2075
  static readonly participantUpdated = "participantUpdated";
@@ -2016,16 +2093,16 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2016
2093
  * Fired when the fields of an existing message are updated with new values.
2017
2094
  *
2018
2095
  * Parameters:
2019
- * 1. object `data` - info object provided with the event. It has the following properties:
2096
+ * 1. object `data` - info object provided with the event. It has the
2097
+ * following properties:
2020
2098
  * * {@link Message} `message` - the message in question
2021
- * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for the update
2099
+ * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
2100
+ * the update
2022
2101
  * @event
2023
2102
  */
2024
2103
  static readonly messageUpdated = "messageUpdated";
2025
2104
  /**
2026
2105
  * Fired when the token is about to expire and needs to be updated.
2027
- * * Parameters:
2028
- * 1. number `message` - token's time to live
2029
2106
  * @event
2030
2107
  */
2031
2108
  static readonly tokenAboutToExpire = "tokenAboutToExpire";
@@ -2051,10 +2128,12 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2051
2128
  */
2052
2129
  static readonly typingStarted = "typingStarted";
2053
2130
  /**
2054
- * Fired when the client has received (and parsed) a push notification via one of the push channels (apn or fcm).
2131
+ * Fired when the client has received (and parsed) a push notification via one
2132
+ * of the push channels (apn or fcm).
2055
2133
  *
2056
2134
  * Parameters:
2057
- * 1. {@link PushNotification} `pushNotification` - the push notification in question
2135
+ * 1. {@link PushNotification} `pushNotification` - the push notification in
2136
+ * question
2058
2137
  * @event
2059
2138
  */
2060
2139
  static readonly pushNotification = "pushNotification";
@@ -2075,12 +2154,15 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2075
2154
  */
2076
2155
  static readonly userUnsubscribed = "userUnsubscribed";
2077
2156
  /**
2078
- * Fired when the properties or the reachability status of a user have been updated.
2157
+ * Fired when the properties or the reachability status of a user have been
2158
+ * updated.
2079
2159
  *
2080
2160
  * Parameters:
2081
- * 1. object `data` - info object provided with the event. It has the following properties:
2161
+ * 1. object `data` - info object provided with the event. It has the
2162
+ * following properties:
2082
2163
  * * {@link User} `user` - the user in question
2083
- * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update
2164
+ * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the
2165
+ * update
2084
2166
  * @event
2085
2167
  */
2086
2168
  static readonly userUpdated = "userUpdated";
@@ -2088,14 +2170,17 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2088
2170
  * Fired when the state of the client has been changed.
2089
2171
  *
2090
2172
  * Parameters:
2091
- * 1. {@link State} `state` - the new client state
2173
+ * 1. object `data` - info object provided with the event. It has the
2174
+ * following properties:
2175
+ * * {@link State} `state` - the new client state
2176
+ * * Error? `error` - the initialization error if present
2092
2177
  * @event
2093
2178
  */
2094
2179
  static readonly stateChanged = "stateChanged";
2095
2180
  /**
2096
2181
  * Fired when the connection state of the client has been changed.
2097
2182
  *
2098
- * Paremeters:
2183
+ * Parameters:
2099
2184
  * 1. {@link ConnectionState} `state` - the new connection state
2100
2185
  * @event
2101
2186
  */
@@ -2104,7 +2189,8 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2104
2189
  * Fired when the connection is interrupted for an unexpected reason.
2105
2190
  *
2106
2191
  * Parameters:
2107
- * 1. object `data` - info object provided with the event. It has the following properties:
2192
+ * 1. object `data` - info object provided with the event. It has the
2193
+ * following properties:
2108
2194
  * * boolean `terminal` - Twilsock will stop connection attempts if true
2109
2195
  * * string `message` - the error message of the root cause
2110
2196
  * * number? `httpStatusCode` - http status code if available
@@ -2112,6 +2198,93 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2112
2198
  * @event
2113
2199
  */
2114
2200
  static readonly connectionError = "connectionError";
2201
+ /**
2202
+ * Current version of the Conversations client.
2203
+ */
2204
+ static readonly version: string;
2205
+ /**
2206
+ * Logger instance.
2207
+ */
2208
+ private static readonly _logger;
2209
+ /**
2210
+ * Supported push notification channels.
2211
+ */
2212
+ private static readonly _supportedPushChannels;
2213
+ /**
2214
+ * Supported push data fields.
2215
+ */
2216
+ private static readonly _supportedPushDataFields;
2217
+ /**
2218
+ * Current version of the Conversations client.
2219
+ */
2220
+ readonly version: string;
2221
+ /**
2222
+ * Client connection state.
2223
+ */
2224
+ connectionState: ConnectionState;
2225
+ /**
2226
+ * Promise that resolves on successful initialization.
2227
+ */
2228
+ private readonly _ensureReady;
2229
+ /**
2230
+ * Options passed to the client.
2231
+ */
2232
+ private readonly _options;
2233
+ /**
2234
+ * Client service objects.
2235
+ */
2236
+ private readonly _services;
2237
+ /**
2238
+ * The user of the client.
2239
+ */
2240
+ private readonly _myself;
2241
+ /**
2242
+ * Resolves the {@link Client._ensureReady} promise.
2243
+ */
2244
+ private _resolveEnsureReady;
2245
+ /**
2246
+ * Rejects the {@link Client._ensureReady} promise.
2247
+ */
2248
+ private _rejectEnsureReady;
2249
+ /**
2250
+ * The current token of the client.
2251
+ */
2252
+ private _fpaToken;
2253
+ /**
2254
+ * The constructed configuration object.
2255
+ */
2256
+ private _configuration;
2257
+ /**
2258
+ * The Conversations entity.
2259
+ */
2260
+ private _conversationsEntity;
2261
+ /**
2262
+ * Promise that resolves when initial conversations are fetched.
2263
+ */
2264
+ private _conversationsPromise;
2265
+ /**
2266
+ * Returned Conversations instance is not yet fully initialized. Calling any
2267
+ * operations will block until it is. Use connection events to monitor when
2268
+ * client becomes fully available (connectionStateChanged with state
2269
+ * 'connected') or not available (connectionStateChange with state 'denied',
2270
+ * event tokenExpired, event connectionError).
2271
+ *
2272
+ * @param fpaToken Access token
2273
+ * @param options Options to customize the Client
2274
+ * @returns A not yet fully-initialized client.
2275
+ */
2276
+ constructor(fpaToken: string, options?: ClientOptions | null);
2277
+ /**
2278
+ * Information of the logged-in user. Before client initialization, returns an
2279
+ * uninitialized user. Will trigger a {@link Client.userUpdated} event after
2280
+ * initialization.
2281
+ */
2282
+ get user(): User;
2283
+ /**
2284
+ * Client reachability state. Throws an error if accessed before the client
2285
+ * initialization was completed.
2286
+ */
2287
+ get reachabilityEnabled(): boolean;
2115
2288
  /**
2116
2289
  * @deprecated Call constructor directly.
2117
2290
  *
@@ -2133,20 +2306,21 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2133
2306
  */
2134
2307
  static create(token: string, options?: ClientOptions | null): Promise<Client>;
2135
2308
  /**
2136
- * Information of the logged-in user. Before client initialization, returns an
2137
- * uninitialized user. Will trigger a {@link Client.userUpdated} event after
2138
- * initialization.
2309
+ * Static method for push notification payload parsing. Returns parsed push as
2310
+ * a {@link PushNotification} object.
2311
+ * @param notificationPayload Push notification payload.
2139
2312
  */
2140
- get user(): User;
2313
+ static parsePushNotification(notificationPayload: any): PushNotification;
2141
2314
  /**
2142
- * Client reachability state. Throws if accessed before the client
2143
- * initialization was completed.
2315
+ * Static method for parsing push notification chat data.
2316
+ * @param data Data to parse
2144
2317
  */
2145
- get reachabilityEnabled(): boolean;
2146
- get token(): string;
2147
- private _subscribeToPushNotifications;
2148
- private _unsubscribeFromPushNotifications;
2149
- private _initialize;
2318
+ private static _parsePushNotificationChatData;
2319
+ /**
2320
+ * Populate the client with init registrations.
2321
+ * @param reg The init registration to populate.
2322
+ */
2323
+ static populateInitRegistrations(reg: InitRegistration): void;
2150
2324
  /**
2151
2325
  * Gracefully shut down the client.
2152
2326
  */
@@ -2161,6 +2335,12 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2161
2335
  * @param conversationSid Conversation sid
2162
2336
  */
2163
2337
  getConversationBySid(conversationSid: string): Promise<Conversation>;
2338
+ /**
2339
+ * Peek a conversation by its SID.
2340
+ * @param conversationSid Conversation sid
2341
+ * @internal
2342
+ */
2343
+ peekConversationBySid(conversationSid: string): Promise<Conversation>;
2164
2344
  /**
2165
2345
  * Get a known conversation by its unique identifier name.
2166
2346
  * @param uniqueName The unique identifier name of the conversation.
@@ -2179,7 +2359,8 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2179
2359
  /**
2180
2360
  * Register for push notifications.
2181
2361
  * @param channelType Channel type.
2182
- * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.
2362
+ * @param registrationId Push notification ID provided by the FCM/APNS service
2363
+ * on the platform.
2183
2364
  */
2184
2365
  setPushRegistrationId(channelType: NotificationsChannelType, registrationId: string): Promise<void>;
2185
2366
  /**
@@ -2192,27 +2373,29 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2192
2373
  * Clear existing registrations directly using provided device token.
2193
2374
  * This is useful to ensure stopped subscriptions without resubscribing.
2194
2375
  *
2195
- * This function goes completely beside the state machine and removes all registrations.
2196
- * Use with caution: if it races with current state machine operations, madness will ensue.
2376
+ * This function goes completely beside the state machine and removes all
2377
+ * registrations.
2378
+ * Use with caution: if it races with current state machine operations,
2379
+ * madness will ensue.
2197
2380
  *
2198
2381
  * @param channelType Channel type.
2199
- * @param registrationId Push notification ID provided by the FCM/APNS service on the platform.
2382
+ * @param registrationId Push notification ID provided by the FCM/APNS service
2383
+ * on the platform.
2200
2384
  */
2201
2385
  removePushRegistrations(channelType: ChannelType, registrationId: string): Promise<void>;
2202
- private static parsePushNotificationChatData;
2203
2386
  /**
2204
- * Static method for push notification payload parsing. Returns parsed push as a {@link PushNotification} object.
2205
- * @param notificationPayload Push notification payload.
2387
+ * Current version of the Conversations client.
2206
2388
  */
2207
- static parsePushNotification(notificationPayload: any): PushNotification;
2208
2389
  parsePushNotification: typeof Client.parsePushNotification;
2209
2390
  /**
2210
- * Handle push notification payload parsing and emit the {@link Client.pushNotification} event on this {@link Client} instance.
2391
+ * Handle push notification payload parsing and emit the
2392
+ * {@link Client.pushNotification} event on this {@link Client} instance.
2211
2393
  * @param notificationPayload Push notification payload
2212
2394
  */
2213
2395
  handlePushNotification(notificationPayload: any): Promise<void>;
2214
2396
  /**
2215
- * Gets a user with the given identity. If it's in the subscribed list, then return the user object from it;
2397
+ * Gets a user with the given identity. If it's in the subscribed list, then
2398
+ * return the user object from it;
2216
2399
  * if not, then subscribe and add user to the subscribed list.
2217
2400
  * @param identity Identity of the user.
2218
2401
  * @returns A fully initialized user.
@@ -2222,6 +2405,32 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2222
2405
  * Get a list of subscribed user objects.
2223
2406
  */
2224
2407
  getSubscribedUsers(): Promise<Array<User>>;
2408
+ /**
2409
+ * Get content URLs for all media attachments in the given set of media sids
2410
+ * using a single operation.
2411
+ * @param mediaSids Set of media sids to query for the content URL.
2412
+ */
2413
+ getTemporaryContentUrlsForMediaSids(mediaSids: string[]): CancellablePromise<Map<string, string>>;
2414
+ /**
2415
+ * Get content URLs for all media attachments in the given set using a single
2416
+ * operation.
2417
+ * @param contentSet Set of media attachments to query content URLs.
2418
+ */
2419
+ getTemporaryContentUrlsForMedia(contentSet: Media[]): CancellablePromise<Map<string, string>>;
2420
+ /**
2421
+ * Initialize the client.
2422
+ */
2423
+ private _initialize;
2424
+ /**
2425
+ * Subscribe to push notifications.
2426
+ * @param channelType The channel type to subscribe to.
2427
+ */
2428
+ private _subscribeToPushNotifications;
2429
+ /**
2430
+ * Unsubscribe from push notifications.
2431
+ * @param channelType The channel type to unsubscribe from.
2432
+ */
2433
+ private _unsubscribeFromPushNotifications;
2225
2434
  }
2226
2435
  declare class NotificationTypes {
2227
2436
  static readonly TYPING_INDICATOR = "twilio.ipmsg.typing_indicator";
@@ -2231,4 +2440,4 @@ declare class NotificationTypes {
2231
2440
  static readonly REMOVED_FROM_CONVERSATION = "twilio.conversations.removed_from_conversation";
2232
2441
  static readonly CONSUMPTION_UPDATE = "twilio.channel.consumption_update";
2233
2442
  }
2234
- export { Conversation, ConversationBindings, ConversationEmailBinding, ConversationUpdateReason, ConversationStatus, NotificationLevel, ConversationState, ConversationUpdatedEventArgs, SendMediaOptions, SendEmailOptions, LastMessage, Participant, ParticipantUpdateReason, ParticipantType, ParticipantUpdatedEventArgs, ParticipantBindings, ParticipantEmailBinding, ParticipantEmailLevel, Message, MessageUpdateReason, MessageType, MessageUpdatedEventArgs, Media, MediaCategory$0 as MediaCategory, AggregatedDeliveryReceipt, DeliveryAmount, DetailedDeliveryReceipt, DeliveryStatus, RestPaginator, MessageBuilder, UnsentMessage, Paginator, ParticipantBindingOptions, User, UserUpdateReason, UserUpdatedEventArgs, PushNotification, PushNotificationType, PushNotificationDescriptor, PushNotificationData, NotificationTypes, Client, State, ConnectionState, NotificationsChannelType, ClientOptions, CreateConversationOptions, ConversationLimits, JSONValue, JSONObject, JSONArray };
2443
+ export { Conversation, ConversationBindings, ConversationEmailBinding, ConversationUpdateReason, ConversationStatus, NotificationLevel, ConversationState, ConversationUpdatedEventArgs, SendMediaOptions, SendEmailOptions, LastMessage, Participant, ParticipantUpdateReason, ParticipantType, ParticipantUpdatedEventArgs, ParticipantBindings, ParticipantEmailBinding, ParticipantEmailLevel, Message, MessageUpdateReason, MessageType, MessageUpdatedEventArgs, Media, MediaCategory$0 as MediaCategory, AggregatedDeliveryReceipt, DeliveryAmount, DetailedDeliveryReceipt, DeliveryStatus, RestPaginator, MessageBuilder, UnsentMessage, Paginator, ParticipantBindingOptions, User, UserUpdateReason, UserUpdatedEventArgs, PushNotification, PushNotificationType, PushNotificationDescriptor, PushNotificationData, NotificationTypes, Client, State, ConnectionState, NotificationsChannelType, ClientOptions, CreateConversationOptions, ConversationLimits, JSONValue, JSONObject, JSONArray, CancellablePromise };