@twilio/conversations 2.4.1-rc.1 → 2.5.0-rc.0

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.
package/builds/lib.d.ts CHANGED
@@ -110,6 +110,7 @@ declare class Configuration {
110
110
  readonly userInfo: string;
111
111
  readonly myConversations: string;
112
112
  readonly channelMetadataCacheCapacity: number;
113
+ readonly messageRecipientsCacheCapacity: number;
113
114
  constructor(options: ClientOptions, configurationResponse: ConfigurationResponse, logger: Logger);
114
115
  }
115
116
  interface CommandExecutorServices {
@@ -1205,6 +1206,115 @@ declare class ChannelMetadataClient {
1205
1206
  constructor(services: ChannelMetadataClientServices, configuration: Configuration);
1206
1207
  getChannelMetadata(conversationSid: string, messageSid: string): Promise<ChannelMetadata | null>;
1207
1208
  }
1209
+ type MessageRecipient = {
1210
+ message_sid: string;
1211
+ type: "email"; // discriminant for future expansion
1212
+ level: "to" | "from" | "cc";
1213
+ name: string;
1214
+ address: string;
1215
+ };
1216
+ /**
1217
+ * Pagination helper interface.
1218
+ * @typeParam T The item type.
1219
+ */
1220
+ interface Paginator<T> {
1221
+ /**
1222
+ * Indicates the existence of the next page.
1223
+ */
1224
+ hasNextPage: boolean;
1225
+ /**
1226
+ * Indicates the existence of the previous page.
1227
+ */
1228
+ hasPrevPage: boolean;
1229
+ /**
1230
+ * Array of elements of type T on the current page.
1231
+ */
1232
+ items: T[];
1233
+ /**
1234
+ * Request next page.
1235
+ * Does not modify the existing object.
1236
+ */
1237
+ nextPage(): Promise<Paginator<T>>;
1238
+ /**
1239
+ * Request previous page.
1240
+ * Does not modify the existing object.
1241
+ */
1242
+ prevPage(): Promise<Paginator<T>>;
1243
+ }
1244
+ type MessageRecipientsClientServices = {
1245
+ commandExecutor: CommandExecutor;
1246
+ };
1247
+ /**
1248
+ * Message recipient descriptor.
1249
+ */
1250
+ type RecipientDescriptor = EmailRecipientDescriptor | UnknownRecipientDescriptor;
1251
+ /**
1252
+ * Email recipient level.
1253
+ */
1254
+ type EmailRecipientLevel = "to" | "from" | "cc";
1255
+ /**
1256
+ * Email recipient descriptor.
1257
+ */
1258
+ declare class EmailRecipientDescriptor {
1259
+ /**
1260
+ * Type of recipient.
1261
+ */
1262
+ readonly type = "email";
1263
+ /**
1264
+ * Sid of the message that this recipient belongs to.
1265
+ */
1266
+ readonly messageSid: string;
1267
+ /**
1268
+ * Email recipient level.
1269
+ */
1270
+ readonly level: EmailRecipientLevel;
1271
+ /**
1272
+ * Name of the recipient.
1273
+ */
1274
+ readonly name: string;
1275
+ /**
1276
+ * Address of the recipient.
1277
+ */
1278
+ readonly address: string;
1279
+ /**
1280
+ * @internal
1281
+ */
1282
+ constructor(recipient: MessageRecipient);
1283
+ }
1284
+ /**
1285
+ * Unknown recipient descriptor. Used to be able to handle recipient types that
1286
+ * are not supported by the current version of the SDK.
1287
+ */
1288
+ declare class UnknownRecipientDescriptor {
1289
+ /**
1290
+ * Type of recipient.
1291
+ */
1292
+ readonly type: string;
1293
+ /**
1294
+ * Sid of the message that this recipient belongs to.
1295
+ */
1296
+ readonly messageSid: string;
1297
+ /**
1298
+ * Recipient data as a JSON string.
1299
+ */
1300
+ readonly rawData: string;
1301
+ /**
1302
+ * @internal
1303
+ */
1304
+ constructor(recipient: MessageRecipient);
1305
+ }
1306
+ declare class MessageRecipientsClient {
1307
+ private readonly _services;
1308
+ private readonly _configuration;
1309
+ private readonly _cache;
1310
+ constructor(services: MessageRecipientsClientServices, configuration: Configuration);
1311
+ getRecipientsFromMessage(conversationSid: string, messageSid: string): Promise<RecipientDescriptor[]>;
1312
+ getRecipientsFromConversation(conversationSid: string, paginatorOptions?: {
1313
+ pageToken?: string;
1314
+ pageSize?: string;
1315
+ }): Promise<Paginator<RecipientDescriptor>>;
1316
+ private _wrapResponse;
1317
+ }
1208
1318
  type MessageEvents = {
1209
1319
  updated: (data: {
1210
1320
  message: Message;
@@ -1216,6 +1326,7 @@ interface MessageServices {
1216
1326
  network: Network;
1217
1327
  commandExecutor: CommandExecutor;
1218
1328
  channelMetadataClient: ChannelMetadataClient;
1329
+ messageRecipientsClient: MessageRecipientsClient;
1219
1330
  }
1220
1331
  interface MessageLinks {
1221
1332
  self: string;
@@ -1428,34 +1539,10 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
1428
1539
  * the message doesn't have any channel metadata.
1429
1540
  */
1430
1541
  getChannelMetadata(): Promise<ChannelMetadata | null>;
1431
- }
1432
- /**
1433
- * Pagination helper interface.
1434
- * @typeParam T The item type.
1435
- */
1436
- interface Paginator<T> {
1437
1542
  /**
1438
- * Indicates the existence of the next page.
1543
+ * Get recipients of the message.
1439
1544
  */
1440
- hasNextPage: boolean;
1441
- /**
1442
- * Indicates the existence of the previous page.
1443
- */
1444
- hasPrevPage: boolean;
1445
- /**
1446
- * Array of elements of type T on the current page.
1447
- */
1448
- items: T[];
1449
- /**
1450
- * Request next page.
1451
- * Does not modify the existing object.
1452
- */
1453
- nextPage(): Promise<Paginator<T>>;
1454
- /**
1455
- * Request previous page.
1456
- * Does not modify the existing object.
1457
- */
1458
- prevPage(): Promise<Paginator<T>>;
1545
+ getMessageRecipients(): Promise<RecipientDescriptor[]>;
1459
1546
  }
1460
1547
  interface TypingIndicatorServices {
1461
1548
  twilsockClient: TwilsockClient;
@@ -1591,6 +1678,7 @@ interface MessagesServices {
1591
1678
  syncClient: SyncClient;
1592
1679
  commandExecutor: CommandExecutor;
1593
1680
  channelMetadataClient: ChannelMetadataClient;
1681
+ messageRecipientsClient: MessageRecipientsClient;
1594
1682
  }
1595
1683
  /**
1596
1684
  * Represents the collection of messages in a conversation
@@ -1886,6 +1974,7 @@ interface ConversationServices {
1886
1974
  syncClient: SyncClient;
1887
1975
  commandExecutor: CommandExecutor;
1888
1976
  channelMetadataClient: ChannelMetadataClient;
1977
+ messageRecipientsClient: MessageRecipientsClient;
1889
1978
  }
1890
1979
  /**
1891
1980
  * Conversation descriptor.
@@ -2334,6 +2423,10 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
2334
2423
  * to null removes it.
2335
2424
  */
2336
2425
  updateUniqueName(uniqueName: string | null): Promise<Conversation>;
2426
+ /**
2427
+ * Get recipients of all messages in the conversation.
2428
+ */
2429
+ getMessageRecipients(): Promise<Paginator<RecipientDescriptor>>;
2337
2430
  /**
2338
2431
  * Load and subscribe to this conversation and do not subscribe to its
2339
2432
  * participants and messages. This or _subscribeStreams will need to be called
@@ -2546,6 +2639,10 @@ interface ClientOptions {
2546
2639
  * The cache capacity for channel metadata.
2547
2640
  */
2548
2641
  channelMetadataCacheCapacity?: number;
2642
+ /**
2643
+ * The cache capacity for message recipients.
2644
+ */
2645
+ messageRecipientsCacheCapacity?: number;
2549
2646
  region?: string;
2550
2647
  productId?: string;
2551
2648
  twilsockClient?: TwilsockClient;
@@ -3062,4 +3159,4 @@ declare class NotificationTypes {
3062
3159
  static readonly REMOVED_FROM_CONVERSATION = "twilio.conversations.removed_from_conversation";
3063
3160
  static readonly CONSUMPTION_UPDATE = "twilio.channel.consumption_update";
3064
3161
  }
3065
- 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, ContentDataActionUrl, ContentDataActionPhone, ContentDataActionReply, ContentDataActionOther, ContentDataAction, ContentDataText, ContentDataMedia, ContentDataLocation, ContentDataReply, ContentDataQuickReply, ContentDataCallToAction, ContentDataListPicker, ContentDataListItem, ContentDataCard, ContentDataOther, ContentData, ContentTemplate, ContentTemplateVariable, ChannelMetadata };
3162
+ 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, ContentDataActionUrl, ContentDataActionPhone, ContentDataActionReply, ContentDataActionOther, ContentDataAction, ContentDataText, ContentDataMedia, ContentDataLocation, ContentDataReply, ContentDataQuickReply, ContentDataCallToAction, ContentDataListPicker, ContentDataListItem, ContentDataCard, ContentDataOther, ContentData, ContentTemplate, ContentTemplateVariable, ChannelMetadata, RecipientDescriptor, EmailRecipientDescriptor, UnknownRecipientDescriptor, EmailRecipientLevel };