@twilio/conversations 2.4.1 → 2.5.0-rc.8

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
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { SyncClient, SyncDocument, SyncList } from "twilio-sync";
3
2
  import { LogLevelDesc } from "loglevel";
4
3
  import { Transport, TwilsockClient, InitRegistration, TransportResult } from "twilsock";
@@ -110,6 +109,7 @@ declare class Configuration {
110
109
  readonly userInfo: string;
111
110
  readonly myConversations: string;
112
111
  readonly channelMetadataCacheCapacity: number;
112
+ readonly messageRecipientsCacheCapacity: number;
113
113
  constructor(options: ClientOptions, configurationResponse: ConfigurationResponse, logger: Logger);
114
114
  }
115
115
  interface CommandExecutorServices {
@@ -1205,6 +1205,118 @@ declare class ChannelMetadataClient {
1205
1205
  constructor(services: ChannelMetadataClientServices, configuration: Configuration);
1206
1206
  getChannelMetadata(conversationSid: string, messageSid: string): Promise<ChannelMetadata | null>;
1207
1207
  }
1208
+ type MessageRecipient = {
1209
+ message_sid: string;
1210
+ type: "email"; // discriminant for future expansion
1211
+ level: "to" | "from" | "cc";
1212
+ name: string;
1213
+ address: string;
1214
+ };
1215
+ /**
1216
+ * Pagination helper interface.
1217
+ * @typeParam T The item type.
1218
+ */
1219
+ interface Paginator<T> {
1220
+ /**
1221
+ * Indicates the existence of the next page.
1222
+ */
1223
+ hasNextPage: boolean;
1224
+ /**
1225
+ * Indicates the existence of the previous page.
1226
+ */
1227
+ hasPrevPage: boolean;
1228
+ /**
1229
+ * Array of elements of type T on the current page.
1230
+ */
1231
+ items: T[];
1232
+ /**
1233
+ * Request next page.
1234
+ * Does not modify the existing object.
1235
+ */
1236
+ nextPage(): Promise<Paginator<T>>;
1237
+ /**
1238
+ * Request previous page.
1239
+ * Does not modify the existing object.
1240
+ */
1241
+ prevPage(): Promise<Paginator<T>>;
1242
+ }
1243
+ interface PaginatorOptions {
1244
+ pageSize?: number;
1245
+ }
1246
+ type MessageRecipientsClientServices = {
1247
+ commandExecutor: CommandExecutor;
1248
+ };
1249
+ /**
1250
+ * Message recipient descriptor.
1251
+ */
1252
+ type RecipientDescriptor = EmailRecipientDescriptor | UnknownRecipientDescriptor;
1253
+ /**
1254
+ * Email recipient level.
1255
+ */
1256
+ type EmailRecipientLevel = "to" | "from" | "cc";
1257
+ /**
1258
+ * Email recipient descriptor.
1259
+ */
1260
+ declare class EmailRecipientDescriptor {
1261
+ /**
1262
+ * Type of recipient.
1263
+ */
1264
+ readonly type = "email";
1265
+ /**
1266
+ * Sid of the message that this recipient belongs to.
1267
+ */
1268
+ readonly messageSid: string;
1269
+ /**
1270
+ * Email recipient level.
1271
+ */
1272
+ readonly level: EmailRecipientLevel;
1273
+ /**
1274
+ * Name of the recipient.
1275
+ */
1276
+ readonly name: string;
1277
+ /**
1278
+ * Address of the recipient.
1279
+ */
1280
+ readonly address: string;
1281
+ /**
1282
+ * @internal
1283
+ */
1284
+ constructor(recipient: MessageRecipient);
1285
+ }
1286
+ /**
1287
+ * Unknown recipient descriptor. Used to be able to handle recipient types that
1288
+ * are not supported by the current version of the SDK.
1289
+ */
1290
+ declare class UnknownRecipientDescriptor {
1291
+ /**
1292
+ * Type of recipient.
1293
+ */
1294
+ readonly type: string;
1295
+ /**
1296
+ * Sid of the message that this recipient belongs to.
1297
+ */
1298
+ readonly messageSid: string;
1299
+ /**
1300
+ * Recipient data as a JSON string.
1301
+ */
1302
+ readonly rawData: string;
1303
+ /**
1304
+ * @internal
1305
+ */
1306
+ constructor(recipient: MessageRecipient);
1307
+ }
1308
+ declare class MessageRecipientsClient {
1309
+ private readonly _services;
1310
+ private readonly _configuration;
1311
+ private readonly _cache;
1312
+ constructor(services: MessageRecipientsClientServices, configuration: Configuration);
1313
+ getRecipientsFromMessage(conversationSid: string, messageSid: string): Promise<RecipientDescriptor[]>;
1314
+ getRecipientsFromConversation(conversationSid: string, paginatorOptions?: {
1315
+ pageToken?: string;
1316
+ pageSize?: number;
1317
+ }): Promise<Paginator<RecipientDescriptor>>;
1318
+ private _wrapResponse;
1319
+ }
1208
1320
  type MessageEvents = {
1209
1321
  updated: (data: {
1210
1322
  message: Message;
@@ -1216,6 +1328,7 @@ interface MessageServices {
1216
1328
  network: Network;
1217
1329
  commandExecutor: CommandExecutor;
1218
1330
  channelMetadataClient: ChannelMetadataClient;
1331
+ messageRecipientsClient: MessageRecipientsClient;
1219
1332
  }
1220
1333
  interface MessageLinks {
1221
1334
  self: string;
@@ -1428,34 +1541,10 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
1428
1541
  * the message doesn't have any channel metadata.
1429
1542
  */
1430
1543
  getChannelMetadata(): Promise<ChannelMetadata | null>;
1431
- }
1432
- /**
1433
- * Pagination helper interface.
1434
- * @typeParam T The item type.
1435
- */
1436
- interface Paginator<T> {
1437
- /**
1438
- * Indicates the existence of the next page.
1439
- */
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
1544
  /**
1450
- * Request next page.
1451
- * Does not modify the existing object.
1545
+ * Get recipients of the message.
1452
1546
  */
1453
- nextPage(): Promise<Paginator<T>>;
1454
- /**
1455
- * Request previous page.
1456
- * Does not modify the existing object.
1457
- */
1458
- prevPage(): Promise<Paginator<T>>;
1547
+ getMessageRecipients(): Promise<RecipientDescriptor[]>;
1459
1548
  }
1460
1549
  interface TypingIndicatorServices {
1461
1550
  twilsockClient: TwilsockClient;
@@ -1522,7 +1611,7 @@ declare class RestPaginator<T> implements Paginator<T> {
1522
1611
  /**
1523
1612
  * @internal
1524
1613
  */
1525
- constructor(items: any, source: any, prevToken: any, nextToken: any);
1614
+ constructor(items: any, source: any, prevToken: any, nextToken: any, pageSize: any);
1526
1615
  /**
1527
1616
  * Request the next page. Does not modify the existing object.
1528
1617
  */
@@ -1591,6 +1680,7 @@ interface MessagesServices {
1591
1680
  syncClient: SyncClient;
1592
1681
  commandExecutor: CommandExecutor;
1593
1682
  channelMetadataClient: ChannelMetadataClient;
1683
+ messageRecipientsClient: MessageRecipientsClient;
1594
1684
  }
1595
1685
  /**
1596
1686
  * Represents the collection of messages in a conversation
@@ -1886,6 +1976,7 @@ interface ConversationServices {
1886
1976
  syncClient: SyncClient;
1887
1977
  commandExecutor: CommandExecutor;
1888
1978
  channelMetadataClient: ChannelMetadataClient;
1979
+ messageRecipientsClient: MessageRecipientsClient;
1889
1980
  }
1890
1981
  /**
1891
1982
  * Conversation descriptor.
@@ -2334,10 +2425,15 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
2334
2425
  * to null removes it.
2335
2426
  */
2336
2427
  updateUniqueName(uniqueName: string | null): Promise<Conversation>;
2428
+ /**
2429
+ * Get recipients of all messages in the conversation.
2430
+ * @param options Optional configuration, set pageSize to request a specific pagination page size. Page size specifies a number of messages to include in a single batch. Each message may include multiple recipients.
2431
+ */
2432
+ getMessageRecipients(options?: PaginatorOptions): Promise<Paginator<RecipientDescriptor>>;
2337
2433
  /**
2338
2434
  * Load and subscribe to this conversation and do not subscribe to its
2339
2435
  * participants and messages. This or _subscribeStreams will need to be called
2340
- * before any events on conversation will fire.
2436
+ * before any events in the conversation will fire.
2341
2437
  * @internal
2342
2438
  */
2343
2439
  _subscribe(): Promise<SyncDocument>;
@@ -2546,6 +2642,10 @@ interface ClientOptions {
2546
2642
  * The cache capacity for channel metadata.
2547
2643
  */
2548
2644
  channelMetadataCacheCapacity?: number;
2645
+ /**
2646
+ * The cache capacity for message recipients.
2647
+ */
2648
+ messageRecipientsCacheCapacity?: number;
2549
2649
  region?: string;
2550
2650
  productId?: string;
2551
2651
  twilsockClient?: TwilsockClient;
@@ -3062,4 +3162,4 @@ declare class NotificationTypes {
3062
3162
  static readonly REMOVED_FROM_CONVERSATION = "twilio.conversations.removed_from_conversation";
3063
3163
  static readonly CONSUMPTION_UPDATE = "twilio.channel.consumption_update";
3064
3164
  }
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 };
3165
+ 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 };