@twilio/conversations 3.0.0-rc.9 → 3.0.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.
Files changed (99) hide show
  1. package/README.md +39 -29
  2. package/builds/browser.esm.js +10838 -0
  3. package/builds/browser.esm.js.map +1 -0
  4. package/builds/browser.js +2494 -476
  5. package/builds/browser.js.map +1 -1
  6. package/builds/lib.d.ts +805 -70
  7. package/builds/lib.esm.d.ts +3178 -0
  8. package/builds/lib.esm.js +10837 -0
  9. package/builds/lib.js +2494 -476
  10. package/builds/lib.js.map +1 -1
  11. package/builds/twilio-conversations.js +29167 -26611
  12. package/builds/twilio-conversations.js.map +1 -0
  13. package/builds/twilio-conversations.min.js +2 -1
  14. package/builds/twilio-conversations.min.js.map +1 -0
  15. package/dist/aggregated-delivery-receipt.js +10 -5
  16. package/dist/aggregated-delivery-receipt.js.map +1 -1
  17. package/dist/channel-metadata-client.js +187 -0
  18. package/dist/channel-metadata-client.js.map +1 -0
  19. package/dist/client.js +266 -192
  20. package/dist/client.js.map +1 -1
  21. package/dist/command-executor.js +51 -14
  22. package/dist/command-executor.js.map +1 -1
  23. package/dist/configuration.js +23 -12
  24. package/dist/configuration.js.map +1 -1
  25. package/dist/content-client.js +180 -0
  26. package/dist/content-client.js.map +1 -0
  27. package/dist/content-template.js +304 -0
  28. package/dist/content-template.js.map +1 -0
  29. package/dist/conversation.js +213 -134
  30. package/dist/conversation.js.map +1 -1
  31. package/dist/data/conversations.js +70 -50
  32. package/dist/data/conversations.js.map +1 -1
  33. package/dist/data/messages.js +40 -27
  34. package/dist/data/messages.js.map +1 -1
  35. package/dist/data/participants.js +38 -32
  36. package/dist/data/participants.js.map +1 -1
  37. package/dist/data/users.js +19 -14
  38. package/dist/data/users.js.map +1 -1
  39. package/dist/detailed-delivery-receipt.js +9 -4
  40. package/dist/detailed-delivery-receipt.js.map +1 -1
  41. package/dist/index.js +26 -41
  42. package/dist/index.js.map +1 -1
  43. package/dist/interfaces/notification-types.js +9 -4
  44. package/dist/interfaces/notification-types.js.map +1 -1
  45. package/dist/interfaces/{attributes.js → rules.js} +26 -13
  46. package/dist/interfaces/rules.js.map +1 -0
  47. package/dist/logger.js +17 -28
  48. package/dist/logger.js.map +1 -1
  49. package/dist/media.js +40 -24
  50. package/dist/media.js.map +1 -1
  51. package/dist/message-builder.js +79 -12
  52. package/dist/message-builder.js.map +1 -1
  53. package/dist/message-recipients-client.js +231 -0
  54. package/dist/message-recipients-client.js.map +1 -0
  55. package/dist/message.js +258 -92
  56. package/dist/message.js.map +1 -1
  57. package/dist/node_modules/quick-lru/index.js +261 -0
  58. package/dist/node_modules/quick-lru/index.js.map +1 -0
  59. package/dist/node_modules/tslib/tslib.es6.js +15 -5
  60. package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
  61. package/dist/packages/conversations/package.json.js +12 -7
  62. package/dist/packages/conversations/package.json.js.map +1 -1
  63. package/dist/participant.js +42 -38
  64. package/dist/participant.js.map +1 -1
  65. package/dist/push-notification.js +9 -4
  66. package/dist/push-notification.js.map +1 -1
  67. package/dist/rest-paginator.js +9 -4
  68. package/dist/rest-paginator.js.map +1 -1
  69. package/dist/services/network.js +11 -6
  70. package/dist/services/network.js.map +1 -1
  71. package/dist/services/typing-indicator.js +17 -11
  72. package/dist/services/typing-indicator.js.map +1 -1
  73. package/dist/unsent-message.js +14 -9
  74. package/dist/unsent-message.js.map +1 -1
  75. package/dist/user.js +40 -32
  76. package/dist/user.js.map +1 -1
  77. package/dist/util/deferred.js +9 -4
  78. package/dist/util/deferred.js.map +1 -1
  79. package/dist/util/index.js +44 -8
  80. package/dist/util/index.js.map +1 -1
  81. package/docs/assets/js/search.js +1 -1
  82. package/docs/classes/AggregatedDeliveryReceipt.html +1 -1
  83. package/docs/classes/ChannelMetadata.html +3050 -0
  84. package/docs/classes/Client.html +98 -27
  85. package/docs/classes/ContentTemplate.html +3116 -0
  86. package/docs/classes/ContentTemplateVariable.html +3116 -0
  87. package/docs/classes/Conversation.html +46 -9
  88. package/docs/classes/EmailRecipientDescriptor.html +3098 -0
  89. package/docs/classes/Message.html +99 -5
  90. package/docs/classes/MessageBuilder.html +41 -0
  91. package/docs/classes/Participant.html +2 -2
  92. package/docs/classes/UnknownRecipientDescriptor.html +3067 -0
  93. package/docs/index.html +892 -28
  94. package/docs/interfaces/ClientOptions.html +32 -0
  95. package/docs/interfaces/CreateConversationOptions.html +17 -0
  96. package/docs/modules.html +891 -27
  97. package/package.json +21 -19
  98. package/CHANGELOG.md +0 -509
  99. package/dist/interfaces/attributes.js.map +0 -1
@@ -0,0 +1,3178 @@
1
+ import { SyncClient, SyncDocument, SyncList } from "twilio-sync";
2
+ import { LogLevelDesc } from "loglevel";
3
+ import { Transport, TwilsockClient, InitRegistration, TransportResult } from "twilsock";
4
+ import { ConnectionState as TwilsockConnectionState } from "twilsock";
5
+ import { ReplayEventEmitter } from "@twilio/replay-event-emitter";
6
+ import { ChannelType, Notifications } from "@twilio/notifications";
7
+ import { Notifications as NotificationClient } from "@twilio/notifications";
8
+ import { CancellablePromise, McsClient, MediaCategory, McsMedia, McsMediaCategory, McsMediaState } from "@twilio/mcs-client";
9
+ interface ConfigurationResponse {
10
+ options: {
11
+ consumption_report_interval: string;
12
+ user_infos_to_subscribe: number;
13
+ reachability_enabled: boolean;
14
+ http_cache_interval: string;
15
+ my_conversations_page_size: number;
16
+ media_attachments_count_limit: number;
17
+ media_attachment_size_limit_in_mb: number;
18
+ media_attachments_total_size_limit_in_mb: number;
19
+ email_histories_allowed_mime_types: string[];
20
+ email_bodies_allowed_mime_types: string[];
21
+ };
22
+ sync_objects: {
23
+ my_conversations: string;
24
+ my_user_info: string;
25
+ };
26
+ links: {
27
+ my_conversations: string;
28
+ conversations: string;
29
+ users: string;
30
+ current_user: string;
31
+ typing: string;
32
+ media_service: string;
33
+ media_set_service: string;
34
+ messages_receipts: string;
35
+ };
36
+ identity: string;
37
+ url: string;
38
+ }
39
+ // twilio-conversations is used by Flex SDK. Please DO NOT change
40
+ declare class Logger {
41
+ private prefix;
42
+ private constructor();
43
+ static scope(prefix: string): Logger;
44
+ setLevel(level: LogLevelDesc): void;
45
+ static setLevel(level: LogLevelDesc): void;
46
+ trace(...args: any[]): void;
47
+ debug(...args: any[]): void;
48
+ info(...args: any[]): void;
49
+ warn(...args: any[]): void;
50
+ error(...args: any[]): void;
51
+ static trace(...args: any[]): void;
52
+ static debug(...args: any[]): void;
53
+ static info(...args: any[]): void;
54
+ static warn(...args: any[]): void;
55
+ static error(...args: any[]): void;
56
+ }
57
+ /**
58
+ * Represents conversation limits.
59
+ */
60
+ interface ConversationLimits {
61
+ /**
62
+ * Maximum amount of attachments.
63
+ */
64
+ mediaAttachmentsCountLimit: number;
65
+ /**
66
+ * Maximum attachment size in MB.
67
+ */
68
+ mediaAttachmentSizeLimitInMb: number;
69
+ /**
70
+ * Maximum total attachment size in MB.
71
+ */
72
+ mediaAttachmentsTotalSizeLimitInMb: number;
73
+ /**
74
+ * Allowed content types for E-Mail histories.
75
+ */
76
+ emailHistoriesAllowedContentTypes: string[];
77
+ /**
78
+ * Allowed content types for E-Mail bodies.
79
+ */
80
+ emailBodiesAllowedContentTypes: string[];
81
+ }
82
+ interface BackoffConfiguration {
83
+ min: number;
84
+ max: number;
85
+ maxAttemptsCount: number;
86
+ }
87
+ declare class Configuration {
88
+ readonly links: {
89
+ myConversations: string;
90
+ conversations: string;
91
+ users: string;
92
+ currentUser: string;
93
+ typing: string;
94
+ mediaService: string;
95
+ mediaSetService: string;
96
+ messagesReceipts: string;
97
+ };
98
+ readonly limits: ConversationLimits;
99
+ readonly productId?: string;
100
+ readonly typingIndicatorTimeoutOverride?: number;
101
+ readonly typingIndicatorTimeoutDefault: number;
102
+ readonly backoffConfiguration: BackoffConfiguration;
103
+ readonly retryWhenThrottled: boolean;
104
+ readonly consumptionReportInterval: number;
105
+ readonly userInfosToSubscribe: number;
106
+ readonly httpCacheInterval: number;
107
+ readonly reachabilityEnabled: boolean;
108
+ readonly userIdentity: string;
109
+ readonly userInfo: string;
110
+ readonly myConversations: string;
111
+ readonly channelMetadataCacheCapacity: number;
112
+ readonly messageRecipientsCacheCapacity: number;
113
+ constructor(options: ClientOptions, configurationResponse: ConfigurationResponse, logger: Logger);
114
+ }
115
+ interface CommandExecutorServices {
116
+ transport: Transport;
117
+ }
118
+ declare class CommandExecutor {
119
+ private _serviceUrl;
120
+ private _services;
121
+ private _productId?;
122
+ constructor(_serviceUrl: string, _services: CommandExecutorServices, _productId?: string);
123
+ private _preProcessUrl;
124
+ private _makeRequest;
125
+ fetchResource<Request = void, Response = void>(url: string, requestBody?: Request): Promise<Response>;
126
+ mutateResource<Request = void, Response = void>(method: "post" | "delete", url: string, requestBody?: Request): Promise<Response>;
127
+ }
128
+ /**
129
+ * Represents a JSON value.
130
+ */
131
+ type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
132
+ /**
133
+ * Represents a JSON object.
134
+ */
135
+ type JSONObject = {
136
+ [x: string]: JSONValue;
137
+ };
138
+ /**
139
+ * Represents a JSON array.
140
+ */
141
+ type JSONArray = JSONValue[];
142
+ type UserEvents = {
143
+ updated: (data: {
144
+ user: User;
145
+ updateReasons: UserUpdateReason[];
146
+ }) => void;
147
+ userSubscribed: (user: User) => void;
148
+ userUnsubscribed: (user: User) => void;
149
+ };
150
+ interface UserServices {
151
+ syncClient: SyncClient;
152
+ commandExecutor: CommandExecutor;
153
+ }
154
+ /**
155
+ * The reason for the `updated` event being emitted by a user.
156
+ */
157
+ type UserUpdateReason = "friendlyName" | "attributes" | "reachabilityOnline" | "reachabilityNotifiable";
158
+ interface UserUpdatedEventArgs {
159
+ user: User;
160
+ updateReasons: UserUpdateReason[];
161
+ }
162
+ /**
163
+ * Extended user information.
164
+ * Note that `isOnline` and `isNotifiable` properties are eligible
165
+ * for use only if the reachability function is enabled.
166
+ * You may check if it is enabled by reading the value of {@link Client.reachabilityEnabled}.
167
+ */
168
+ declare class User extends ReplayEventEmitter<UserEvents> {
169
+ private links;
170
+ private configuration;
171
+ private readonly services;
172
+ private entity;
173
+ private state;
174
+ private promiseToFetch;
175
+ private subscribed;
176
+ private _initializationPromise;
177
+ private _resolveInitializationPromise;
178
+ /**
179
+ * @internal
180
+ */
181
+ constructor(identity: string, entityName: string, configuration: Configuration | null, services: UserServices);
182
+ /**
183
+ * Fired when the properties or the reachability status of the message has been updated.
184
+ *
185
+ * Parameters:
186
+ * 1. object `data` - info object provided with the event. It has the following properties:
187
+ * * {@link User} `user` - the user in question
188
+ * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update
189
+ * @event
190
+ */
191
+ readonly updated = "updated";
192
+ /**
193
+ * Fired when the client has subscribed to the user.
194
+ *
195
+ * Parameters:
196
+ * 1. {@link User} `user` - the user in question
197
+ * @event
198
+ */
199
+ readonly userSubscribed = "userSubscribed";
200
+ /**
201
+ * Fired when the client has unsubscribed from the user.
202
+ *
203
+ * Parameters:
204
+ * 1. {@link User} `user` - the user in question
205
+ * @event
206
+ */
207
+ readonly userUnsubscribed = "userUnsubscribed";
208
+ /**
209
+ * User identity.
210
+ */
211
+ get identity(): string;
212
+ set identity(identity: string);
213
+ set entityName(name: string);
214
+ /**
215
+ * Custom attributes of the user.
216
+ */
217
+ get attributes(): JSONValue;
218
+ /**
219
+ * Friendly name of the user, null if not set.
220
+ */
221
+ get friendlyName(): string | null;
222
+ /**
223
+ * Status of the real-time conversation connection of the user.
224
+ */
225
+ get isOnline(): boolean | null;
226
+ /**
227
+ * User push notification registration status.
228
+ */
229
+ get isNotifiable(): boolean | null;
230
+ /**
231
+ * True if this user is receiving real-time status updates.
232
+ */
233
+ get isSubscribed(): boolean;
234
+ // Handles service updates
235
+ _update(key: string, value: {
236
+ value: string;
237
+ notifiable: boolean | null;
238
+ online: boolean | null;
239
+ }): Promise<void>;
240
+ // Fetch reachability info
241
+ private _updateReachabilityInfo;
242
+ // Fetch user
243
+ _fetch(): Promise<User>;
244
+ _ensureFetched(): Promise<User>;
245
+ /**
246
+ * Edit user attributes.
247
+ * @param attributes New attributes.
248
+ */
249
+ updateAttributes(attributes: JSONValue): Promise<User>;
250
+ /**
251
+ * Update the friendly name of the user.
252
+ * @param friendlyName New friendly name.
253
+ */
254
+ updateFriendlyName(friendlyName: string): Promise<User>;
255
+ /**
256
+ * Remove the user from the subscription list.
257
+ * @return A promise of completion.
258
+ */
259
+ unsubscribe(): Promise<void>;
260
+ _resolveInitialization(configuration: Configuration, identity: string, entityName: string, emitUpdated: boolean): void;
261
+ }
262
+ declare class Network {
263
+ private readonly configuration;
264
+ private readonly services;
265
+ private cacheLifetime;
266
+ private readonly cache;
267
+ private timer;
268
+ constructor(configuration: any, services: any);
269
+ private isExpired;
270
+ private cleanupCache;
271
+ pokeTimer(): void;
272
+ private executeWithRetry;
273
+ get<T>(url: string): Promise<TransportResult<T>>;
274
+ }
275
+ type UsersEvents = {
276
+ userUpdated: (data: {
277
+ user: User;
278
+ updateReasons: UserUpdateReason[];
279
+ }) => void;
280
+ userSubscribed: (user: User) => void;
281
+ userUnsubscribed: (user: User) => void;
282
+ };
283
+ interface UsersServices {
284
+ network: Network;
285
+ syncClient: SyncClient;
286
+ commandExecutor: CommandExecutor;
287
+ }
288
+ /**
289
+ * Container for known users
290
+ */
291
+ declare class Users extends ReplayEventEmitter<UsersEvents> {
292
+ private readonly configuration;
293
+ private readonly services;
294
+ private subscribedUsers;
295
+ private fifoStack;
296
+ readonly myself: User;
297
+ constructor(myself: User, configuration: Configuration, services: UsersServices);
298
+ private handleUnsubscribeUser;
299
+ private handleSubscribeUser;
300
+ /**
301
+ * Gets user, if it's in subscribed list - then return the user object from it,
302
+ * if not - then subscribes and adds user to the FIFO stack
303
+ * @returns {Promise<User>} Fully initialized user
304
+ */
305
+ getUser(identity: string, entityName?: string): Promise<User>;
306
+ /**
307
+ * @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}
308
+ */
309
+ getSubscribedUsers(): Promise<Array<User>>;
310
+ /**
311
+ * @returns {Promise<string>} User's sync unique name
312
+ */
313
+ private getSyncUniqueName;
314
+ }
315
+ type ParticipantEvents = {
316
+ typingEnded: (participant: Participant) => void;
317
+ typingStarted: (participant: Participant) => void;
318
+ updated: (data: {
319
+ participant: Participant;
320
+ updateReasons: ParticipantUpdateReason[];
321
+ }) => void;
322
+ };
323
+ interface ParticipantDescriptor {
324
+ attributes?: JSONValue;
325
+ dateCreated: Date | null;
326
+ dateUpdated: Date | null;
327
+ identity: string;
328
+ roleSid?: string;
329
+ lastConsumedMessageIndex: number | null;
330
+ lastConsumptionTimestamp: number | null;
331
+ type: ParticipantType;
332
+ userInfo?: string;
333
+ bindings?: ParticipantBindings;
334
+ }
335
+ interface ParticipantServices {
336
+ users: Users;
337
+ commandExecutor: CommandExecutor;
338
+ }
339
+ interface ParticipantLinks {
340
+ self: string;
341
+ }
342
+ /**
343
+ * The reason for the `updated` event being emitted by a participant.
344
+ */
345
+ type ParticipantUpdateReason = "attributes" | "dateCreated" | "dateUpdated" | "roleSid" | "lastReadMessageIndex" | "lastReadTimestamp" | "bindings";
346
+ /**
347
+ * Participant type. The string variant can be used to denote new types of
348
+ * participant that aren't supported by this version of the SDK.
349
+ */
350
+ type ParticipantType = "chat" | "sms" | "whatsapp" | "email" | string;
351
+ interface ParticipantUpdatedEventArgs {
352
+ participant: Participant;
353
+ updateReasons: ParticipantUpdateReason[];
354
+ }
355
+ /**
356
+ * Bindings for conversation participant.
357
+ */
358
+ interface ParticipantBindings {
359
+ email?: ParticipantEmailBinding;
360
+ }
361
+ /**
362
+ * Email participation level.
363
+ * to = to/from
364
+ * cc = cc
365
+ */
366
+ type ParticipantEmailLevel = "to" | "cc";
367
+ /**
368
+ * Bindings for email participant.
369
+ */
370
+ interface ParticipantEmailBinding {
371
+ name: string;
372
+ address: string;
373
+ level: ParticipantEmailLevel;
374
+ }
375
+ /**
376
+ * A participant represents a remote client in a conversation.
377
+ */
378
+ declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
379
+ private state;
380
+ private readonly links;
381
+ private readonly services;
382
+ /**
383
+ * Conversation that the remote client is a participant of.
384
+ */
385
+ readonly conversation: Conversation;
386
+ /**
387
+ * The server-assigned unique identifier for the participant.
388
+ */
389
+ get sid(): string;
390
+ /**
391
+ * Custom attributes of the participant.
392
+ */
393
+ get attributes(): JSONValue;
394
+ /**
395
+ * Date this participant was created on.
396
+ */
397
+ get dateCreated(): Date | null;
398
+ /**
399
+ * Date this participant was last updated on.
400
+ */
401
+ get dateUpdated(): Date | null;
402
+ /**
403
+ * Identity of the participant.
404
+ */
405
+ get identity(): string | null;
406
+ /**
407
+ * Indicates whether the participant is currently typing.
408
+ */
409
+ get isTyping(): boolean;
410
+ /**
411
+ * The index of the last read message by the participant.
412
+ * Note that retrieving messages on a client endpoint does not mean that messages are read,
413
+ * please consider reading about the [Read Horizon feature](https://www.twilio.com/docs/api/chat/guides/consumption-horizon)
414
+ * to find out about the proper way to mark messages as read.
415
+ */
416
+ get lastReadMessageIndex(): number | null;
417
+ /**
418
+ * Date of the most recent read horizon update.
419
+ */
420
+ get lastReadTimestamp(): Date | null;
421
+ get roleSid(): string;
422
+ /**
423
+ * Type of the participant.
424
+ */
425
+ get type(): ParticipantType;
426
+ /**
427
+ * Get the bindings mapping for the current participant.
428
+ * Available binding depends on the participant type.
429
+ * You could access it as `participant.bindings.sms?.address` or
430
+ * using the type dynamically `participant.bindings[participant.type]`
431
+ * just be aware that the binding information has different structure for
432
+ * each participant type.
433
+ * See also {ParticipantEmailBinding}, the only available currently binding descriptor.
434
+ */
435
+ get bindings(): ParticipantBindings;
436
+ /**
437
+ * @internal
438
+ */
439
+ constructor(data: ParticipantDescriptor, sid: string, conversation: Conversation, links: ParticipantLinks, services: ParticipantServices);
440
+ /**
441
+ * Fired when the participant has started typing.
442
+ *
443
+ * Parameters:
444
+ * 1. {@link Participant} `participant` - the participant in question
445
+ * @event
446
+ */
447
+ static readonly typingStarted = "typingStarted";
448
+ /**
449
+ * Fired when the participant has stopped typing.
450
+ *
451
+ * Parameters:
452
+ * 1. {@link Participant} `participant` - the participant in question
453
+ * @event
454
+ */
455
+ static readonly typingEnded = "typingEnded";
456
+ /**
457
+ * Fired when the fields of the participant have been updated.
458
+ *
459
+ * Parameters:
460
+ * 1. object `data` - info object provided with the event. It has the following properties:
461
+ * * {@link Participant} participant - the participant in question
462
+ * * {@link ParticipantUpdateReason}[] updateReasons - array of reasons for the update
463
+ * @event
464
+ */
465
+ static readonly updated = "updated";
466
+ /**
467
+ * Internal method used to start or reset the typing indicator timeout (with event emitting).
468
+ * @internal
469
+ */
470
+ _startTyping(timeout: any): this;
471
+ /**
472
+ * Internal method function used to stop the typing indicator timeout (with event emitting).
473
+ * @internal
474
+ */
475
+ _endTyping(): void;
476
+ /**
477
+ * Internal method function used update local object's property roleSid with a new value.
478
+ * @internal
479
+ */
480
+ _update(data: any): this;
481
+ /**
482
+ * Get the user for this participant and subscribes to it. Supported only for participants of type `chat`.
483
+ */
484
+ getUser(): Promise<User>;
485
+ /**
486
+ * Remove the participant from the conversation.
487
+ */
488
+ remove(): Promise<void>;
489
+ /**
490
+ * Update the attributes of the participant.
491
+ * @param attributes New attributes.
492
+ */
493
+ updateAttributes(attributes: JSONValue): Promise<Participant>;
494
+ }
495
+ interface ParticipantResponse {
496
+ account_sid: string;
497
+ chat_service_sid: string;
498
+ conversation_sid: string;
499
+ role_sid: string;
500
+ sid: string;
501
+ attributes: string;
502
+ date_created: string;
503
+ date_updated: string;
504
+ identity: string;
505
+ messaging_binding: {
506
+ type: "chat" | "sms" | "whatsapp" | "email";
507
+ address: string;
508
+ proxy_address: string;
509
+ } | null;
510
+ url: string;
511
+ links: {
512
+ conversation: string;
513
+ };
514
+ }
515
+ interface ParticipantBindingOptions {
516
+ email?: ParticipantEmailBinding;
517
+ }
518
+ /**
519
+ * Category of media. Possible values are as follows:
520
+ * * `'media'`
521
+ * * `'body'`
522
+ * * `'history'`
523
+ */
524
+ type MediaCategory$0 = McsMediaCategory;
525
+ interface MediaServices {
526
+ mcsClient: McsClient;
527
+ }
528
+ /**
529
+ * Represents a media information for a message in a conversation.
530
+ */
531
+ declare class Media {
532
+ private state;
533
+ private services;
534
+ private mcsMedia;
535
+ /**
536
+ * @internal
537
+ */
538
+ constructor(data: McsMediaState | McsMedia, services: MediaServices);
539
+ /**
540
+ * Server-assigned unique identifier for the media.
541
+ */
542
+ get sid(): string;
543
+ /**
544
+ * File name. Null if absent.
545
+ */
546
+ get filename(): string | null;
547
+ /**
548
+ * Content type of the media.
549
+ */
550
+ get contentType(): string;
551
+ /**
552
+ * Size of the media in bytes.
553
+ */
554
+ get size(): number;
555
+ /**
556
+ * Media category, can be one of the {@link MediaCategory} values.
557
+ */
558
+ get category(): MediaCategory$0;
559
+ /**
560
+ * Returns the direct content URL for the media.
561
+ *
562
+ * This URL is impermanent, it will expire in several minutes and cannot be cached.
563
+ * If the URL becomes expired, you need to request a new one.
564
+ * Each call to this function produces a new temporary URL.
565
+ */
566
+ getContentTemporaryUrl(): CancellablePromise<string | null>;
567
+ private _fetchMcsMedia;
568
+ /**
569
+ * @internal
570
+ */
571
+ _state(): McsMediaState;
572
+ }
573
+ /**
574
+ * Signifies the amount of participants which have the status for the message.
575
+ */
576
+ type DeliveryAmount = "none" | "some" | "all";
577
+ interface AggregatedDeliveryDescriptor {
578
+ total: number;
579
+ delivered: DeliveryAmount;
580
+ failed: DeliveryAmount;
581
+ read: DeliveryAmount;
582
+ sent: DeliveryAmount;
583
+ undelivered: DeliveryAmount;
584
+ }
585
+ /**
586
+ * Contains aggregated information about delivery statuses of a message across all participants
587
+ * of a conversation.
588
+ *
589
+ * At any moment during the message delivery to a participant, the message can have zero or more of the following
590
+ * delivery statuses:
591
+ * * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
592
+ * * Message is considered as **delivered** to a participant if Twilio has received confirmation of message
593
+ * delivery from the upstream carrier, and, where available, the destination handset.
594
+ * * Message considered as **undelivered** to a participant if Twilio has received a delivery receipt
595
+ * indicating that the message was not delivered. This can happen for many reasons including carrier content
596
+ * filtering and the availability of the destination handset.
597
+ * * Message considered as **read** by a participant if the message has been delivered and opened by the
598
+ * recipient in a conversation. The recipient must have enabled the read receipts.
599
+ * * Message considered as **failed** to be delivered to a participant if the message could not be sent.
600
+ * This can happen for various reasons including queue overflows, account suspensions and media
601
+ * errors (in the case of MMS for instance).
602
+ *
603
+ * {@link AggregatedDeliveryReceipt} class contains an aggregated value {@link DeliveryAmount} for each delivery status.
604
+ */
605
+ declare class AggregatedDeliveryReceipt {
606
+ private state;
607
+ /**
608
+ * @internal
609
+ */
610
+ constructor(data: AggregatedDeliveryDescriptor);
611
+ /**
612
+ * Maximum number of delivery events expected for the message.
613
+ */
614
+ get total(): number;
615
+ /**
616
+ * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
617
+ *
618
+ * @return Amount of participants that have the **sent** delivery status for the message.
619
+ */
620
+ get sent(): DeliveryAmount;
621
+ /**
622
+ * Message is considered as **delivered** to a participant if Twilio has received confirmation of message
623
+ * delivery from the upstream carrier, and, where available, the destination handset.
624
+ *
625
+ * @return Amount of participants that have the **delivered** delivery status for the message.
626
+ */
627
+ get delivered(): DeliveryAmount;
628
+ /**
629
+ * Message is considered as **read** by a participant, if the message has been delivered and opened by the
630
+ * recipient in a conversation. The recipient must have enabled the read receipts.
631
+ *
632
+ * @return Amount of participants that have the **read** delivery status for the message.
633
+ */
634
+ get read(): DeliveryAmount;
635
+ /**
636
+ * Message is considered as **undelivered** to a participant if Twilio has received a delivery receipt
637
+ * indicating that the message was not delivered. This can happen for many reasons including carrier content
638
+ * filtering and the availability of the destination handset.
639
+ *
640
+ * @return Ammount of participants that have the **undelivered** delivery status for the message.
641
+ */
642
+ get undelivered(): DeliveryAmount;
643
+ /**
644
+ * Message is considered as **failed** to be delivered to a participant if the message could not be sent.
645
+ * This can happen for various reasons including queue overflows, account suspensions and media
646
+ * errors (in the case of MMS for instance). Twilio does not charge you for failed messages.
647
+ *
648
+ * @return Amount of participants that have the **failed** delivery status for the message.
649
+ */
650
+ get failed(): DeliveryAmount;
651
+ _update(data: AggregatedDeliveryDescriptor): void;
652
+ _isEquals(data: AggregatedDeliveryDescriptor): boolean;
653
+ }
654
+ /**
655
+ * Message delivery status.
656
+ */
657
+ type DeliveryStatus = "sent" | "delivered" | "failed" | "read" | "undelivered" | "queued";
658
+ interface DetailedDeliveryReceiptDescriptor {
659
+ sid: string;
660
+ message_sid: string;
661
+ conversation_sid: string;
662
+ channel_message_sid: string;
663
+ participant_sid: string;
664
+ status: DeliveryStatus;
665
+ error_code: string | null;
666
+ date_created: string;
667
+ date_updated: string;
668
+ }
669
+ /**
670
+ * Represents a delivery receipt of a message.
671
+ */
672
+ declare class DetailedDeliveryReceipt {
673
+ /**
674
+ * Unique identifier for the delivery receipt.
675
+ */
676
+ sid: string;
677
+ /**
678
+ * Unique identifier for the message in the conversation.
679
+ */
680
+ messageSid: string;
681
+ /**
682
+ * Unique identifier for the conversation.
683
+ */
684
+ conversationSid: string;
685
+ /**
686
+ * Unique identifier for the `‘channel’` message (e.g., `WAxx` for WhatsApp, `SMxx` for SMS).
687
+ */
688
+ channelMessageSid: string;
689
+ /**
690
+ * Unique identifier for the participant.
691
+ */
692
+ participantSid: string;
693
+ /**
694
+ * Status of the message delivery.
695
+ */
696
+ status: DeliveryStatus;
697
+ /**
698
+ * Numeric error code mapped from Status callback code. Information about the error codes can be found
699
+ * [here](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors).
700
+ */
701
+ errorCode: string | 0;
702
+ /**
703
+ * Date this delivery receipt was created on.
704
+ */
705
+ dateCreated: string;
706
+ /**
707
+ * Date this delivery receipt was last updated on.
708
+ */
709
+ dateUpdated: string;
710
+ /**
711
+ * @internal
712
+ */
713
+ constructor(descriptor: DetailedDeliveryReceiptDescriptor);
714
+ }
715
+ type ContentDataActionResponse = Readonly<{
716
+ type: string;
717
+ title: string;
718
+ id?: string;
719
+ url?: string;
720
+ phone?: string;
721
+ index?: number;
722
+ }>;
723
+ type ContentDataTextResponse = Readonly<{
724
+ body: string;
725
+ }>;
726
+ type ContentDataMediaResponse = Readonly<{
727
+ body?: string;
728
+ media: string[];
729
+ }>;
730
+ type ContentDataLocationResponse = Readonly<{
731
+ longitude: number;
732
+ latitude: number;
733
+ label?: string;
734
+ }>;
735
+ type ContentDataQuickReplyResponse = Readonly<{
736
+ body: string;
737
+ actions: Readonly<{
738
+ title: string;
739
+ id?: string;
740
+ }>[];
741
+ }>;
742
+ type ContentDataCallToActionResponse = Readonly<{
743
+ body: string;
744
+ actions: ContentDataActionResponse[];
745
+ }>;
746
+ type ContentDataListPickerResponse = Readonly<{
747
+ body: string;
748
+ button: string;
749
+ items: Readonly<{
750
+ id: string;
751
+ item: string;
752
+ description?: string;
753
+ }>[];
754
+ }>;
755
+ type ContentDataCardResponse = Readonly<{
756
+ title: string;
757
+ subtitle?: string;
758
+ media?: string[];
759
+ actions?: ContentDataActionResponse[];
760
+ }>;
761
+ type ContentDataResponse = Readonly<{
762
+ "twilio/text"?: ContentDataTextResponse;
763
+ "twilio/media"?: ContentDataMediaResponse;
764
+ "twilio/location"?: ContentDataLocationResponse;
765
+ "twilio/quick-reply"?: ContentDataQuickReplyResponse;
766
+ "twilio/call-to-action"?: ContentDataCallToActionResponse;
767
+ "twilio/list-picker"?: ContentDataListPickerResponse;
768
+ "twilio/card"?: ContentDataCardResponse;
769
+ }>;
770
+ type ContentTemplateResponse = Readonly<{
771
+ sid: string;
772
+ account_sid: string;
773
+ friendly_name: string;
774
+ variables: string;
775
+ variants: ContentDataResponse;
776
+ date_created: string;
777
+ date_updated: string;
778
+ }>;
779
+ /**
780
+ * Shows a button that sends back a predefined text. Used in
781
+ * {@link ContentDataQuickReply}.
782
+ */
783
+ type ContentDataReply = {
784
+ /**
785
+ * Display value of the action. This is the message that will be sent back
786
+ * when the user taps on the button.
787
+ */
788
+ readonly title: string;
789
+ /**
790
+ * Postback payload. This field is not visible to the end user.
791
+ */
792
+ readonly id?: string;
793
+ };
794
+ /**
795
+ * Shows a button that redirects recipient to a predefined URL.
796
+ */
797
+ type ContentDataActionUrl = {
798
+ /**
799
+ * The type discriminant.
800
+ */
801
+ readonly type: "url";
802
+ /**
803
+ * Display value for the action.
804
+ */
805
+ readonly title: string;
806
+ /**
807
+ * URL to direct to when the recipient taps the button.
808
+ */
809
+ readonly url: string;
810
+ /**
811
+ * Full data as a stringified JSON. This could be used for future content
812
+ * types and fields which are not yet supported by the newest version of
813
+ * the Conversations SDK, or for using newer types in the older versions of
814
+ * the SDK.
815
+ */
816
+ readonly rawData: string;
817
+ };
818
+ /**
819
+ * Shows a button that calls a phone number.
820
+ */
821
+ type ContentDataActionPhone = {
822
+ /**
823
+ * The type discriminant.
824
+ */
825
+ readonly type: "phone";
826
+ /**
827
+ * Display value for the action.
828
+ */
829
+ readonly title: string;
830
+ /**
831
+ * Phone number to call when the recipient taps the button.
832
+ */
833
+ readonly phone: string;
834
+ /**
835
+ * Full data as a stringified JSON. This could be used for future content
836
+ * types and fields which are not yet supported by the newest version of
837
+ * the Conversations SDK, or for using newer types in the older versions of
838
+ * the SDK.
839
+ */
840
+ readonly rawData: string;
841
+ };
842
+ /**
843
+ * Shows a button that sends back a predefined text.
844
+ */
845
+ type ContentDataActionReply = {
846
+ /**
847
+ * The type discriminant.
848
+ */
849
+ readonly type: "reply";
850
+ /**
851
+ * Display value for the action. This is the message that will be sent back
852
+ * when the user taps on the button.
853
+ */
854
+ readonly title: string;
855
+ /**
856
+ * Postback payload. This field is not visible to the end user.
857
+ */
858
+ readonly id?: string;
859
+ /**
860
+ * Index for the action.
861
+ */
862
+ readonly index: number;
863
+ /**
864
+ * Full data as a stringified JSON. This could be used for future content
865
+ * types and fields which are not yet supported by the newest version of
866
+ * the Conversations SDK, or for using newer types in the older versions of
867
+ * the SDK.
868
+ */
869
+ readonly rawData: string;
870
+ };
871
+ /**
872
+ * Used for unknown action types which aren't present in the current version of
873
+ * the Conversations SDK.
874
+ */
875
+ type ContentDataActionOther = {
876
+ /**
877
+ * The type discriminant.
878
+ */
879
+ readonly type: "other";
880
+ /**
881
+ * Full data as a stringified JSON. This could be used for future content
882
+ * types and fields which are not yet supported by the newest version of
883
+ * the Conversations SDK, or for using newer types in the older versions of
884
+ * the SDK.
885
+ */
886
+ readonly rawData: string;
887
+ };
888
+ /**
889
+ * A union of possible actions used in {@link ContentDataCallToAction} and
890
+ * {@link ContentDataCard}.
891
+ */
892
+ type ContentDataAction = ContentDataActionUrl | ContentDataActionPhone | ContentDataActionReply | ContentDataActionOther;
893
+ /**
894
+ * Represents an item in the {@link ContentDataListPicker}.
895
+ */
896
+ type ContentDataListItem = {
897
+ /**
898
+ * Unique item identifier. Not visible to the recipient.
899
+ */
900
+ readonly id: string;
901
+ /**
902
+ * Display value of the item.
903
+ */
904
+ readonly item: string;
905
+ /**
906
+ * Description of the item.
907
+ */
908
+ readonly description?: string;
909
+ };
910
+ /**
911
+ * Contains only the plain text-based content. Represents the twilio/text
912
+ * content type.
913
+ */
914
+ type ContentDataText = {
915
+ /**
916
+ * The type discriminant.
917
+ */
918
+ readonly type: "text";
919
+ /**
920
+ * The text of the message you want to send.
921
+ */
922
+ readonly body: string;
923
+ /**
924
+ * Full data as a stringified JSON. This could be used for future content
925
+ * types and fields which are not yet supported by the newest version of
926
+ * the Conversations SDK, or for using newer types in the older versions of
927
+ * the SDK.
928
+ */
929
+ readonly rawData: string;
930
+ };
931
+ /**
932
+ * Used to send file attachments, or to send long texts via MMS in the US and
933
+ * Canada. Represents the twilio/media content type.
934
+ */
935
+ type ContentDataMedia = {
936
+ /**
937
+ * The type discriminant.
938
+ */
939
+ readonly type: "media";
940
+ /**
941
+ * The text of the message you want to send.
942
+ */
943
+ readonly body?: string;
944
+ /**
945
+ * URLs of the media you want to send.
946
+ */
947
+ readonly media: string[];
948
+ /**
949
+ * Full data as a stringified JSON. This could be used for future content
950
+ * types and fields which are not yet supported by the newest version of
951
+ * the Conversations SDK, or for using newer types in the older versions of
952
+ * the SDK.
953
+ */
954
+ readonly rawData: string;
955
+ };
956
+ /**
957
+ * Contains a location pin and an optional label, which can be used to enhance
958
+ * delivery notifications or connect recipients to physical experiences you
959
+ * offer. Represents the twilio/location content type.
960
+ */
961
+ type ContentDataLocation = {
962
+ /**
963
+ * The type discriminant.
964
+ */
965
+ readonly type: "location";
966
+ /**
967
+ * The longitude value of the location pin you want to send.
968
+ */
969
+ readonly longitude: number;
970
+ /**
971
+ * The latitude value of the location pin you want to send.
972
+ */
973
+ readonly latitude: number;
974
+ /**
975
+ * The label to be displayed to the end user alongside the location pin.
976
+ */
977
+ readonly label?: string;
978
+ /**
979
+ * Full data as a stringified JSON. This could be used for future content
980
+ * types and fields which are not yet supported by the newest version of
981
+ * the Conversations SDK, or for using newer types in the older versions of
982
+ * the SDK.
983
+ */
984
+ readonly rawData: string;
985
+ };
986
+ /**
987
+ * Let recipients tap, rather than type, to respond to the message. Represents
988
+ * the twilio/quick-reply content type.
989
+ */
990
+ type ContentDataQuickReply = {
991
+ /**
992
+ * The type discriminant.
993
+ */
994
+ readonly type: "quickReply";
995
+ /**
996
+ * The text of the message you want to send. This is included as a regular
997
+ * text message.
998
+ */
999
+ readonly body: string;
1000
+ /**
1001
+ * Up to 3 buttons can be created for quick reply. See
1002
+ * {@link ContentDataReply}.
1003
+ */
1004
+ readonly replies: ContentDataReply[];
1005
+ /**
1006
+ * Full data as a stringified JSON. This could be used for future content
1007
+ * types and fields which are not yet supported by the newest version of
1008
+ * the Conversations SDK, or for using newer types in the older versions of
1009
+ * the SDK.
1010
+ */
1011
+ readonly rawData: string;
1012
+ };
1013
+ /**
1014
+ * Buttons that let recipients tap to trigger actions such as launching a
1015
+ * website or making a phone call. Represents the twilio/call-to-action content
1016
+ * type.
1017
+ */
1018
+ type ContentDataCallToAction = {
1019
+ /**
1020
+ * The type discriminant.
1021
+ */
1022
+ readonly type: "callToAction";
1023
+ /**
1024
+ * The text of the message you want to send. This is included as a regular
1025
+ * text message.
1026
+ */
1027
+ readonly body: string;
1028
+ /**
1029
+ * Buttons that recipients can tap on to act on the message.
1030
+ */
1031
+ readonly actions: ContentDataAction[];
1032
+ /**
1033
+ * Full data as a stringified JSON. This could be used for future content
1034
+ * types and fields which are not yet supported by the newest version of
1035
+ * the Conversations SDK, or for using newer types in the older versions of
1036
+ * the SDK.
1037
+ */
1038
+ readonly rawData: string;
1039
+ };
1040
+ /**
1041
+ * Shows a menu of up to 10 options, which offers a simple way for users to make
1042
+ * a selection. Represents the twilio/list-picker content type.
1043
+ */
1044
+ type ContentDataListPicker = {
1045
+ /**
1046
+ * The type discriminant.
1047
+ */
1048
+ readonly type: "listPicker";
1049
+ /**
1050
+ * The text of the message you want to send. This is rendered as the body of
1051
+ * the message.
1052
+ */
1053
+ readonly body: string;
1054
+ /**
1055
+ * Display value of the primary button.
1056
+ */
1057
+ readonly button: string;
1058
+ /**
1059
+ * List item objects displayed in the list. See {@link ContentDataListItem}.
1060
+ */
1061
+ readonly items: ContentDataListItem[];
1062
+ /**
1063
+ * Full data as a stringified JSON. This could be used for future content
1064
+ * types and fields which are not yet supported by the newest version of
1065
+ * the Conversations SDK, or for using newer types in the older versions of
1066
+ * the SDK.
1067
+ */
1068
+ readonly rawData: string;
1069
+ };
1070
+ /**
1071
+ * Shows a menu of up to 10 options, which offers a simple way for users to make
1072
+ * a selection. Represents the twilio/card content type.
1073
+ */
1074
+ type ContentDataCard = {
1075
+ /**
1076
+ * The type discriminant.
1077
+ */
1078
+ readonly type: "card";
1079
+ /**
1080
+ * Title of the card.
1081
+ */
1082
+ readonly title: string;
1083
+ /**
1084
+ * Subtitle of the card.
1085
+ */
1086
+ readonly subtitle?: string;
1087
+ /**
1088
+ * URLs of the media to send with the message.
1089
+ */
1090
+ readonly media: string[];
1091
+ /**
1092
+ * Buttons that the recipients can tap on to act on the message.
1093
+ */
1094
+ readonly actions: ContentDataAction[];
1095
+ /**
1096
+ * Full data as a stringified JSON. This could be used for future content
1097
+ * types and fields which are not yet supported by the newest version of
1098
+ * the Conversations SDK, or for using newer types in the older versions of
1099
+ * the SDK.
1100
+ */
1101
+ readonly rawData: string;
1102
+ };
1103
+ /**
1104
+ * Used for unknown content types which aren't present in the current version of
1105
+ * the Conversations SDK.
1106
+ */
1107
+ type ContentDataOther = {
1108
+ /**
1109
+ * The type discriminant.
1110
+ */
1111
+ readonly type: "other";
1112
+ /**
1113
+ * Full data as a stringified JSON. This could be used for future content
1114
+ * types and fields which are not yet supported by the newest version of
1115
+ * the Conversations SDK, or for using newer types in the older versions of
1116
+ * the SDK.
1117
+ */
1118
+ readonly rawData: string;
1119
+ };
1120
+ /**
1121
+ * A union of possible data types in rich content templates.
1122
+ */
1123
+ type ContentData = ContentDataText | ContentDataMedia | ContentDataLocation | ContentDataQuickReply | ContentDataCallToAction | ContentDataListPicker | ContentDataCard | ContentDataOther;
1124
+ /**
1125
+ * Represents a variable for a content template. See
1126
+ * {@link ContentTemplate.variables}.
1127
+ */
1128
+ declare class ContentTemplateVariable {
1129
+ readonly name: string;
1130
+ readonly value: string;
1131
+ constructor(/**
1132
+ * Name of the variable.
1133
+ */
1134
+ name: string, /**
1135
+ * Key of the variable
1136
+ */
1137
+ value: string);
1138
+ /**
1139
+ * Copies the variable with a new value.
1140
+ *
1141
+ * @param value The new value for the variable.
1142
+ */
1143
+ copyWithValue(value: string): ContentTemplateVariable;
1144
+ }
1145
+ /**
1146
+ * A rich content template.
1147
+ *
1148
+ * Use {@Link Client.getContentTemplates} to request all the templates available
1149
+ * for the current account.
1150
+ */
1151
+ declare class ContentTemplate {
1152
+ /**
1153
+ * The server-assigned unique identifier for the template.
1154
+ */
1155
+ readonly sid: string;
1156
+ /**
1157
+ * Friendly name used to describe the content. Not visible to the recipient.
1158
+ */
1159
+ readonly friendlyName: string;
1160
+ /**
1161
+ * Variables used by this template.
1162
+ */
1163
+ readonly variables: ContentTemplateVariable[];
1164
+ /**
1165
+ * Variants of the content. See {@link ContentData}.
1166
+ */
1167
+ readonly variants: Map<string, ContentData>;
1168
+ /**
1169
+ * Date of creation.
1170
+ */
1171
+ readonly dateCreated: Date;
1172
+ /**
1173
+ * Date of the last update.
1174
+ */
1175
+ readonly dateUpdated: Date;
1176
+ /**
1177
+ * @internal
1178
+ */
1179
+ constructor(contentTemplateResponse: ContentTemplateResponse);
1180
+ }
1181
+ type ChannelMetadataClientServices = {
1182
+ commandExecutor: CommandExecutor;
1183
+ };
1184
+ /**
1185
+ * Represents channel metadata.
1186
+ */
1187
+ declare class ChannelMetadata {
1188
+ /**
1189
+ * Communication channel type.
1190
+ */
1191
+ readonly type: string;
1192
+ /**
1193
+ * The actual metadata.
1194
+ */
1195
+ readonly data: unknown;
1196
+ /**
1197
+ * @internal
1198
+ */
1199
+ constructor(type: string, data: unknown);
1200
+ }
1201
+ declare class ChannelMetadataClient {
1202
+ private readonly _services;
1203
+ private readonly _configuration;
1204
+ private readonly _cache;
1205
+ constructor(services: ChannelMetadataClientServices, configuration: Configuration);
1206
+ getChannelMetadata(conversationSid: string, messageSid: string): Promise<ChannelMetadata | null>;
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
+ }
1320
+ type MessageEvents = {
1321
+ updated: (data: {
1322
+ message: Message;
1323
+ updateReasons: MessageUpdateReason[];
1324
+ }) => void;
1325
+ };
1326
+ interface MessageServices {
1327
+ mcsClient: McsClient;
1328
+ network: Network;
1329
+ commandExecutor: CommandExecutor;
1330
+ channelMetadataClient: ChannelMetadataClient;
1331
+ messageRecipientsClient: MessageRecipientsClient;
1332
+ }
1333
+ interface MessageLinks {
1334
+ self: string;
1335
+ conversation: string;
1336
+ messages_receipts: string;
1337
+ }
1338
+ /**
1339
+ * The reason for the `updated` event being emitted by a message.
1340
+ */
1341
+ type MessageUpdateReason = "body" | "lastUpdatedBy" | "dateCreated" | "dateUpdated" | "attributes" | "author" | "deliveryReceipt" | "subject" | "media";
1342
+ /**
1343
+ * Type of message.
1344
+ */
1345
+ type MessageType = "text" | "media";
1346
+ interface MessageUpdatedEventArgs {
1347
+ message: Message;
1348
+ updateReasons: MessageUpdateReason[];
1349
+ }
1350
+ interface MessageData {
1351
+ sid: string;
1352
+ text?: string;
1353
+ type?: MessageType;
1354
+ author: string | null;
1355
+ subject: string | null;
1356
+ contentSid: string | null;
1357
+ lastUpdatedBy?: string | null;
1358
+ attributes?: JSONValue;
1359
+ dateUpdated: string;
1360
+ timestamp?: string;
1361
+ medias?: Media[];
1362
+ media?: Media;
1363
+ memberSid?: string;
1364
+ delivery?: AggregatedDeliveryDescriptor;
1365
+ channelMetadata?: boolean;
1366
+ }
1367
+ /**
1368
+ * A message in a conversation.
1369
+ */
1370
+ declare class Message extends ReplayEventEmitter<MessageEvents> {
1371
+ #private;
1372
+ /**
1373
+ * Conversation that the message is in.
1374
+ */
1375
+ readonly conversation: Conversation;
1376
+ private readonly links;
1377
+ private readonly configuration;
1378
+ private readonly services;
1379
+ private state;
1380
+ /**
1381
+ * @internal
1382
+ */
1383
+ constructor(index: number, data: MessageData, conversation: Conversation, links: MessageLinks, configuration: Configuration, services: MessageServices);
1384
+ /**
1385
+ * Fired when the properties or the body of the message has been updated.
1386
+ *
1387
+ * Parameters:
1388
+ * 1. object `data` - info object provided with the event. It has the following properties:
1389
+ * * {@link Message} message - the message in question
1390
+ * * {@link MessageUpdateReason}[] updateReasons - array of reasons for the update
1391
+ */
1392
+ static readonly updated = "updated";
1393
+ /**
1394
+ * The server-assigned unique identifier for the message.
1395
+ */
1396
+ get sid(): string;
1397
+ /**
1398
+ * Name of the user that sent the message.
1399
+ */
1400
+ get author(): string | null;
1401
+ /**
1402
+ * Message subject. Used only in email conversations.
1403
+ */
1404
+ get subject(): string | null;
1405
+ /**
1406
+ * Unique identifier of {@link ContentTemplate} for this message.
1407
+ */
1408
+ get contentSid(): string | null;
1409
+ /**
1410
+ * Body of the message.
1411
+ */
1412
+ get body(): string | null;
1413
+ /**
1414
+ * Date this message was last updated on.
1415
+ */
1416
+ get dateUpdated(): Date | null;
1417
+ /**
1418
+ * Index of this message in the conversation's list of messages.
1419
+ *
1420
+ * By design, the message indices may have arbitrary gaps between them,
1421
+ * that does not necessarily mean they were deleted or otherwise modified - just that
1422
+ * messages may have some non-contiguous indices even if they are being sent immediately one after another.
1423
+ *
1424
+ * Trying to use indices for some calculations is going to be unreliable.
1425
+ *
1426
+ * To calculate the number of unread messages, it is better to use the Read Horizon API.
1427
+ * See {@link Conversation.getUnreadMessagesCount} for details.
1428
+ */
1429
+ get index(): number;
1430
+ /**
1431
+ * Identity of the last user that updated the message.
1432
+ */
1433
+ get lastUpdatedBy(): string | null;
1434
+ /**
1435
+ * Date this message was created on.
1436
+ */
1437
+ get dateCreated(): Date | null;
1438
+ /**
1439
+ * Custom attributes of the message.
1440
+ */
1441
+ get attributes(): JSONValue;
1442
+ /**
1443
+ * Type of the message.
1444
+ */
1445
+ get type(): MessageType;
1446
+ /**
1447
+ * One of the attached media (if present).
1448
+ * @deprecated Use attachedMedia instead. Note that the latter is now an array.
1449
+ */
1450
+ get media(): Media | null;
1451
+ /**
1452
+ * Return all media attachments, except email body/history attachments, without temporary urls.
1453
+ */
1454
+ get attachedMedia(): Array<Media> | null;
1455
+ /**
1456
+ * The server-assigned unique identifier of the authoring participant.
1457
+ */
1458
+ get participantSid(): string | null;
1459
+ /**
1460
+ * Aggregated information about the message delivery statuses across all participants of a conversation..
1461
+ */
1462
+ get aggregatedDeliveryReceipt(): AggregatedDeliveryReceipt | null;
1463
+ /**
1464
+ * @deprecated
1465
+ * Return a (possibly empty) array of media matching a specific set of categories.
1466
+ * Allowed category is so far only 'media'.
1467
+ * @param categories Array of categories to match.
1468
+ * @returns Array of media descriptors matching given categories.
1469
+ */
1470
+ getMediaByCategory(categories: Array<MediaCategory>): Array<Media> | null;
1471
+ /**
1472
+ * Return a (possibly empty) array of media matching a specific set of categories.
1473
+ * Allowed category is so far only 'media'.
1474
+ * @param categories Array of categories to match.
1475
+ * @returns Array of media descriptors matching given categories.
1476
+ */
1477
+ getMediaByCategories(categories: MediaCategory[]): Media[] | null;
1478
+ /**
1479
+ * Get a media descriptor for an email body attachment of a provided type.
1480
+ * Allowed body types are returned in the Conversation.limits().emailBodiesAllowedContentTypes array.
1481
+ * @param type Type of email body to request, defaults to `text/plain`.
1482
+ */
1483
+ getEmailBody(type?: string): Media | null;
1484
+ /**
1485
+ * Get a media descriptor for an email history attachment of a provided type.
1486
+ * Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedContentTypes array.
1487
+ * @param type Type of email history to request, defaults to `text/plain`.
1488
+ */
1489
+ getEmailHistory(type?: string): Media | null;
1490
+ _update(data: any): void;
1491
+ /**
1492
+ * Get the participant who is the author of the message.
1493
+ */
1494
+ getParticipant(): Promise<Participant>;
1495
+ /**
1496
+ * Get the delivery receipts of the message.
1497
+ */
1498
+ getDetailedDeliveryReceipts(): Promise<DetailedDeliveryReceipt[]>;
1499
+ /**
1500
+ * Remove the message.
1501
+ */
1502
+ remove(): Promise<Message>;
1503
+ /**
1504
+ * Edit the message body.
1505
+ * @param body New body of the message.
1506
+ */
1507
+ updateBody(body: string): Promise<Message>;
1508
+ /**
1509
+ * Edit the message attributes.
1510
+ * @param attributes New attributes.
1511
+ */
1512
+ updateAttributes(attributes: JSONValue): Promise<Message>;
1513
+ /**
1514
+ * @deprecated
1515
+ * Get content URLs for all media attachments in the given set using a single operation.
1516
+ * @param contentSet Set of media attachments to query content URLs.
1517
+ */
1518
+ attachTemporaryUrlsFor(contentSet: Media[] | null): Promise<Media[]>;
1519
+ /**
1520
+ * Get content URLs for all media attachments in the given set using a single operation.
1521
+ * @param contentSet Set of media attachments to query content URLs.
1522
+ */
1523
+ getTemporaryContentUrlsForMedia(contentSet: Media[]): CancellablePromise<Map<string, string>>;
1524
+ /**
1525
+ * Get content URLs for all media attachments in the given set of media sids using a single operation.
1526
+ * @param mediaSids Set of media sids to query for the content URL.
1527
+ */
1528
+ getTemporaryContentUrlsForMediaSids(mediaSids: string[]): CancellablePromise<Map<string, string>>;
1529
+ /**
1530
+ * Get content URLs for all media attached to the message.
1531
+ */
1532
+ getTemporaryContentUrlsForAttachedMedia(): CancellablePromise<Map<string, string>>;
1533
+ private _getDetailedDeliveryReceiptsPaginator;
1534
+ /**
1535
+ * Get the {@link ContentData} for this message. Resolves to `null` when
1536
+ * {@link Message.contentSid} is null.
1537
+ */
1538
+ getContentData(): CancellablePromise<ContentData | null>;
1539
+ /**
1540
+ * Get the {@link ChannelMetadata} for this message. Resolves to `null` if
1541
+ * the message doesn't have any channel metadata.
1542
+ */
1543
+ getChannelMetadata(): Promise<ChannelMetadata | null>;
1544
+ /**
1545
+ * Get recipients of the message.
1546
+ */
1547
+ getMessageRecipients(): Promise<RecipientDescriptor[]>;
1548
+ }
1549
+ interface TypingIndicatorServices {
1550
+ twilsockClient: TwilsockClient;
1551
+ notificationClient: Notifications;
1552
+ }
1553
+ /**
1554
+ * An important note in regards to typing timeout timers. There are two places that the SDK can get the "typing_timeout" attribute from. The first
1555
+ * place that the attribute appears in is the response received from POST -> /v1/typing REST call. In the body of that response, the value of the
1556
+ * "typing_timeout" attribute will be exactly the same as defined in the console. The second place that the attribute appears in is from a
1557
+ * notification of type "twilio.ipmsg.typing_indicator". In this case, the "typing_timeout" value will be +1 of that in the console. This
1558
+ * intentional. The timeout returned from the POST -> /v1/typing call should be used to disable further calls for that period of time. On contrary,
1559
+ * the timeout returned from the notification should be used as the timeout for the "typingEnded" event, +1 is to account for latency.
1560
+ *
1561
+ * @private
1562
+ */
1563
+ /**
1564
+ * @class TypingIndicator
1565
+ *
1566
+ * @constructor
1567
+ * @private
1568
+ */
1569
+ declare class TypingIndicator {
1570
+ private readonly services;
1571
+ private readonly configuration;
1572
+ private sentUpdates;
1573
+ private getConversation;
1574
+ private serviceTypingTimeout;
1575
+ constructor(getConversation: (conversationSid: string) => Promise<Conversation>, config: Configuration, services: TypingIndicatorServices);
1576
+ get typingTimeout(): number;
1577
+ /**
1578
+ * Initialize TypingIndicator controller
1579
+ * Registers for needed message types and sets listeners
1580
+ * @private
1581
+ */
1582
+ initialize(): void;
1583
+ /**
1584
+ * Remote participants typing events handler
1585
+ */
1586
+ private _handleRemoteTyping;
1587
+ /**
1588
+ * Send typing event for the given conversation sid
1589
+ * @param {String} conversationSid
1590
+ */
1591
+ send(conversationSid: string): Promise<void>;
1592
+ private _send;
1593
+ }
1594
+ /**
1595
+ * Pagination helper class.
1596
+ */
1597
+ declare class RestPaginator<T> implements Paginator<T> {
1598
+ private state;
1599
+ /**
1600
+ * Indicates the existence of the next page.
1601
+ */
1602
+ get hasNextPage(): boolean;
1603
+ /**
1604
+ * Indicates the existence of the previous page
1605
+ */
1606
+ get hasPrevPage(): boolean;
1607
+ /**
1608
+ * Array of elements on the current page.
1609
+ */
1610
+ get items(): T[];
1611
+ /**
1612
+ * @internal
1613
+ */
1614
+ constructor(items: any, source: any, prevToken: any, nextToken: any);
1615
+ /**
1616
+ * Request the next page. Does not modify the existing object.
1617
+ */
1618
+ nextPage(): Promise<RestPaginator<T>>;
1619
+ /**
1620
+ * Request the previous page. Does not modify the existing object.
1621
+ */
1622
+ prevPage(): Promise<RestPaginator<T>>;
1623
+ }
1624
+ /**
1625
+ * @classdesc Pagination helper class for Sync
1626
+ *
1627
+ * @property {Array} items Array of elements on current page
1628
+ * @property {boolean} hasNextPage
1629
+ * @property {boolean} hasPrevPage
1630
+ */
1631
+ declare class SyncPaginator<T> implements Paginator<T> {
1632
+ private state;
1633
+ hasNextPage: boolean;
1634
+ hasPrevPage: boolean;
1635
+ get items(): T[];
1636
+ /**
1637
+ * @param {Array} items Array of element for current page
1638
+ * @param {Object} params
1639
+ */
1640
+ constructor(items: any, pageSize: any, anchor: any, direction: any, source: any);
1641
+ nextPage(): Promise<RestPaginator<T>>;
1642
+ prevPage(): Promise<SyncPaginator<T> | RestPaginator<T>>;
1643
+ }
1644
+ interface MessageResponse {
1645
+ account_sid: string;
1646
+ chat_service_sid: string;
1647
+ conversation_sid: string;
1648
+ sid: string;
1649
+ index: number;
1650
+ attributes: string;
1651
+ author: string;
1652
+ participant_sid: string;
1653
+ body: string;
1654
+ subject: string;
1655
+ date_created: string;
1656
+ date_updated: string;
1657
+ url: string;
1658
+ media: {
1659
+ sid: string;
1660
+ size: string;
1661
+ content_type: string;
1662
+ filename: string;
1663
+ }[] | null;
1664
+ links: {
1665
+ conversation: string;
1666
+ messages_receipts: string;
1667
+ };
1668
+ }
1669
+ type MessagesEvents = {
1670
+ messageAdded: (message: Message) => void;
1671
+ messageRemoved: (message: Message) => void;
1672
+ messageUpdated: (data: {
1673
+ message: Message;
1674
+ updateReasons: MessageUpdateReason[];
1675
+ }) => void;
1676
+ };
1677
+ interface MessagesServices {
1678
+ mcsClient: McsClient;
1679
+ network: Network;
1680
+ syncClient: SyncClient;
1681
+ commandExecutor: CommandExecutor;
1682
+ channelMetadataClient: ChannelMetadataClient;
1683
+ messageRecipientsClient: MessageRecipientsClient;
1684
+ }
1685
+ /**
1686
+ * Represents the collection of messages in a conversation
1687
+ */
1688
+ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
1689
+ readonly conversation: Conversation;
1690
+ private readonly configuration;
1691
+ private readonly services;
1692
+ private readonly messagesByIndex;
1693
+ private messagesListPromise;
1694
+ constructor(conversation: Conversation, configuration: Configuration, services: MessagesServices);
1695
+ /**
1696
+ * Subscribe to the Messages Event Stream
1697
+ * @param arg - Name of the Sync object, or the SyncList itself, that
1698
+ * represents the Messages resource.
1699
+ */
1700
+ subscribe(arg: string | SyncList): Promise<SyncList>;
1701
+ unsubscribe(): Promise<void>;
1702
+ /**
1703
+ * Send a message to the conversation. The message could include text and multiple media attachments.
1704
+ * @param message Message to post
1705
+ */
1706
+ sendV2(message: UnsentMessage): CancellablePromise<MessageResponse>;
1707
+ /**
1708
+ * Send Message to the conversation
1709
+ * @param message Message to post
1710
+ * @param attributes Message attributes
1711
+ * @param emailOptions Options that modify E-mail integration behaviors.
1712
+ * @returns Returns promise which can fail
1713
+ */
1714
+ send(message: null | string | FormData | SendMediaOptions, attributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<MessageResponse>;
1715
+ /**
1716
+ * Send Media Message to the conversation
1717
+ * @param mediaContent Media content to post
1718
+ * @param attributes Message attributes
1719
+ * @param emailOptions Email options
1720
+ * @returns Returns promise which can fail
1721
+ */
1722
+ sendMedia(mediaContent: FormData | SendMediaOptions, attributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<MessageResponse>;
1723
+ /**
1724
+ * Returns messages from conversation using paginator interface
1725
+ * @param pageSize Number of messages to return in single chunk. By default it's 30.
1726
+ * @param anchor Most early message id which is already known, or 'end' by default
1727
+ * @param direction Pagination order 'backwards' or 'forward', 'forward' by default
1728
+ * @returns Last page of messages by default
1729
+ */
1730
+ getMessages(pageSize: number | undefined, anchor: number | "end" | undefined, direction?: "forward" | "backwards"): Promise<SyncPaginator<Message>>;
1731
+ private _wrapPaginator;
1732
+ private _upsertMessage;
1733
+ /**
1734
+ * Returns last messages from conversation
1735
+ * @param {Number} [pageSize] Number of messages to return in single chunk. By default it's 30.
1736
+ * @param {String} [anchor] Most early message id which is already known, or 'end' by default
1737
+ * @param {String} [direction] Pagination order 'backwards' or 'forward', or 'forward' by default
1738
+ * @returns {Promise<SyncPaginator<Message>>} last page of messages by default
1739
+ * @private
1740
+ */
1741
+ private _getMessages;
1742
+ }
1743
+ /**
1744
+ * An unsent message. Returned from {@link MessageBuilder.build}.
1745
+ */
1746
+ declare class UnsentMessage {
1747
+ private messagesEntity;
1748
+ text?: string;
1749
+ attributes: JSONValue;
1750
+ mediaContent: [
1751
+ MediaCategory,
1752
+ FormData | SendMediaOptions
1753
+ ][];
1754
+ emailOptions: SendEmailOptions;
1755
+ contentSid?: string;
1756
+ contentVariables?: ContentTemplateVariable[];
1757
+ /**
1758
+ * @internal
1759
+ */
1760
+ constructor(messagesEntity: Messages);
1761
+ /**
1762
+ * Send the prepared message to the conversation.
1763
+ * @returns Index of the new message in the conversation.
1764
+ */
1765
+ send(): CancellablePromise<number | null>;
1766
+ }
1767
+ /**
1768
+ * Message builder. Allows the message to be built and sent via method chaining.
1769
+ *
1770
+ * Example:
1771
+ *
1772
+ * ```ts
1773
+ * await testConversation.prepareMessage()
1774
+ * .setBody('Hello!')
1775
+ * .setAttributes({foo: 'bar'})
1776
+ * .addMedia(media1)
1777
+ * .addMedia(media2)
1778
+ * .build()
1779
+ * .send();
1780
+ * ```
1781
+ */
1782
+ declare class MessageBuilder {
1783
+ private readonly limits;
1784
+ private readonly message;
1785
+ private emailBodies;
1786
+ private emailHistories;
1787
+ /**
1788
+ * @internal
1789
+ */
1790
+ constructor(limits: ConversationLimits, messagesEntity: Messages);
1791
+ /**
1792
+ * Sets the message body.
1793
+ * @param text Contents of the body.
1794
+ */
1795
+ setBody(text: string): MessageBuilder;
1796
+ /**
1797
+ * Sets the message subject.
1798
+ * @param subject Contents of the subject.
1799
+ */
1800
+ setSubject(subject: string): MessageBuilder;
1801
+ /**
1802
+ * Sets the message attributes.
1803
+ * @param attributes Message attributes.
1804
+ */
1805
+ setAttributes(attributes: JSONValue): MessageBuilder;
1806
+ /**
1807
+ * Set the email body with a given content type.
1808
+ * @param contentType Format of the body to set (text/plain or text/html).
1809
+ * @param body Body payload in the selected format.
1810
+ */
1811
+ setEmailBody(contentType: string, body: FormData | SendMediaOptions): MessageBuilder;
1812
+ /**
1813
+ * Set the email history with a given content type.
1814
+ * @param contentType Format of the history to set (text/plain or text/html).
1815
+ * @param history History payload in the selected format.
1816
+ */
1817
+ setEmailHistory(contentType: string, history: FormData | SendMediaOptions): MessageBuilder;
1818
+ /**
1819
+ * Adds {@link ContentTemplate} SID for the message alongside optional
1820
+ * variables. When no variables provided, the default values will be used.
1821
+ *
1822
+ * Adding the content SID converts the message to a rich message. In this
1823
+ * case, other fields are ignored and the message is sent using the content
1824
+ * from the the {@link ContentTemplate}.
1825
+ *
1826
+ * Use {@link Client.getContentTemplates} to request all available
1827
+ * {@link ContentTemplate}s.
1828
+ *
1829
+ * @param contentSid SID of the {@link ContentTemplate}
1830
+ * @param variables Custom variables to resolve the template.
1831
+ */
1832
+ setContentTemplate(contentSid: string, contentVariables?: ContentTemplateVariable[]): MessageBuilder;
1833
+ /**
1834
+ * Adds media to the message.
1835
+ * @param payload Media to add.
1836
+ */
1837
+ addMedia(payload: FormData | SendMediaOptions): MessageBuilder;
1838
+ /**
1839
+ * Builds the message, making it ready to be sent.
1840
+ */
1841
+ build(): UnsentMessage;
1842
+ /**
1843
+ * Prepares a message and sends it to the conversation.
1844
+ */
1845
+ buildAndSend(): CancellablePromise<number | null>;
1846
+ }
1847
+ /**
1848
+ * Conversation events.
1849
+ */
1850
+ type ConversationEvents = {
1851
+ participantJoined: (participant: Participant) => void;
1852
+ participantLeft: (participant: Participant) => void;
1853
+ participantUpdated: (data: {
1854
+ participant: Participant;
1855
+ updateReasons: ParticipantUpdateReason[];
1856
+ }) => void;
1857
+ messageAdded: (message: Message) => void;
1858
+ messageRemoved: (message: Message) => void;
1859
+ messageUpdated: (data: {
1860
+ message: Message;
1861
+ updateReasons: MessageUpdateReason[];
1862
+ }) => void;
1863
+ typingEnded: (participant: Participant) => void;
1864
+ typingStarted: (participant: Participant) => void;
1865
+ updated: (data: {
1866
+ conversation: Conversation;
1867
+ updateReasons: ConversationUpdateReason[];
1868
+ }) => void;
1869
+ removed: (conversation: Conversation) => void;
1870
+ };
1871
+ /**
1872
+ * Reason for the `updated` event emission by a conversation.
1873
+ */
1874
+ type ConversationUpdateReason = "attributes" | "createdBy" | "dateCreated" | "dateUpdated" | "friendlyName" | "lastReadMessageIndex" | "state" | "status" | "uniqueName" | "lastMessage" | "notificationLevel" | "bindings";
1875
+ /**
1876
+ * Status of the conversation, relative to the client: whether the conversation
1877
+ * has been `joined` or the client is `notParticipating` in the conversation.
1878
+ */
1879
+ type ConversationStatus = "notParticipating" | "joined";
1880
+ /**
1881
+ * User's notification level for the conversation. Determines
1882
+ * whether the currently logged-in user will receive pushes for events
1883
+ * in this conversation. Can be either `muted` or `default`, where
1884
+ * `default` defers to the global service push configuration.
1885
+ */
1886
+ type NotificationLevel = "default" | "muted";
1887
+ /**
1888
+ * State of the conversation.
1889
+ */
1890
+ interface ConversationState {
1891
+ /**
1892
+ * Current state.
1893
+ */
1894
+ current: "active" | "inactive" | "closed";
1895
+ /**
1896
+ * Date at which the latest conversation state update happened.
1897
+ */
1898
+ dateUpdated: Date;
1899
+ }
1900
+ /**
1901
+ * Event arguments for the `updated` event.
1902
+ */
1903
+ interface ConversationUpdatedEventArgs {
1904
+ conversation: Conversation;
1905
+ updateReasons: ConversationUpdateReason[];
1906
+ }
1907
+ /**
1908
+ * Binding for email conversation.
1909
+ */
1910
+ interface ConversationBindings {
1911
+ email?: ConversationEmailBinding;
1912
+ sms?: ConversationSmsBinding;
1913
+ }
1914
+ /**
1915
+ * Binding for email conversation.
1916
+ */
1917
+ interface ConversationEmailBinding {
1918
+ name?: string;
1919
+ projected_address: string;
1920
+ }
1921
+ /**
1922
+ * Binding for SMS conversation.
1923
+ */
1924
+ interface ConversationSmsBinding {
1925
+ address?: string;
1926
+ }
1927
+ /**
1928
+ * Configuration for attaching a media file to a message.
1929
+ * These options can be passed to {@link Conversation.sendMessage} and
1930
+ * {@link MessageBuilder.addMedia}.
1931
+ */
1932
+ interface SendMediaOptions {
1933
+ /**
1934
+ * Content type of media.
1935
+ */
1936
+ contentType: null | string;
1937
+ /**
1938
+ * Optional filename.
1939
+ */
1940
+ filename?: string;
1941
+ /**
1942
+ * Content to post.
1943
+ */
1944
+ media: null | string | Buffer | Blob;
1945
+ }
1946
+ /**
1947
+ * These options can be passed to {@link Conversation.sendMessage}.
1948
+ */
1949
+ interface SendEmailOptions {
1950
+ /**
1951
+ * Message subject. Ignored for media messages.
1952
+ */
1953
+ subject?: string;
1954
+ }
1955
+ /**
1956
+ * Information about the last message of a conversation.
1957
+ */
1958
+ interface LastMessage {
1959
+ /**
1960
+ * Message's index.
1961
+ */
1962
+ index?: number;
1963
+ /**
1964
+ * Message's creation date.
1965
+ */
1966
+ dateCreated?: Date;
1967
+ }
1968
+ /**
1969
+ * Conversation services.
1970
+ */
1971
+ interface ConversationServices {
1972
+ users: Users;
1973
+ typingIndicator: TypingIndicator;
1974
+ network: Network;
1975
+ mcsClient: McsClient;
1976
+ syncClient: SyncClient;
1977
+ commandExecutor: CommandExecutor;
1978
+ channelMetadataClient: ChannelMetadataClient;
1979
+ messageRecipientsClient: MessageRecipientsClient;
1980
+ }
1981
+ /**
1982
+ * Conversation descriptor.
1983
+ */
1984
+ interface ConversationDescriptor {
1985
+ channel: string;
1986
+ entityName: string;
1987
+ uniqueName: string;
1988
+ attributes: JSONValue;
1989
+ createdBy?: string;
1990
+ friendlyName?: string;
1991
+ lastConsumedMessageIndex: number;
1992
+ dateCreated: Date | null;
1993
+ dateUpdated: Date | null;
1994
+ notificationLevel?: NotificationLevel;
1995
+ bindings?: ConversationBindings;
1996
+ }
1997
+ /**
1998
+ * Conversation links.
1999
+ */
2000
+ interface ConversationLinks {
2001
+ self: string;
2002
+ messages: string;
2003
+ participants: string;
2004
+ }
2005
+ /**
2006
+ * A conversation represents communication between multiple Conversations
2007
+ * clients.
2008
+ */
2009
+ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
2010
+ /**
2011
+ * Fired when a participant has joined the conversation.
2012
+ *
2013
+ * Parameters:
2014
+ * 1. {@link Participant} `participant` - participant that joined the
2015
+ * conversation
2016
+ * @event
2017
+ */
2018
+ static readonly participantJoined = "participantJoined";
2019
+ /**
2020
+ * Fired when a participant has left the conversation.
2021
+ *
2022
+ * Parameters:
2023
+ * 1. {@link Participant} `participant` - participant that left the
2024
+ * conversation
2025
+ * @event
2026
+ */
2027
+ static readonly participantLeft = "participantLeft";
2028
+ /**
2029
+ * Fired when data of a participant has been updated.
2030
+ *
2031
+ * Parameters:
2032
+ * 1. object `data` - info object provided with the event. It has the
2033
+ * following properties:
2034
+ * * {@link Participant} `participant` - participant that has received the
2035
+ * update
2036
+ * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
2037
+ * for the update
2038
+ * @event
2039
+ */
2040
+ static readonly participantUpdated = "participantUpdated";
2041
+ /**
2042
+ * Fired when a new message has been added to the conversation.
2043
+ *
2044
+ * Parameters:
2045
+ * 1. {@link Message} `message` - message that has been added
2046
+ * @event
2047
+ */
2048
+ static readonly messageAdded = "messageAdded";
2049
+ /**
2050
+ * Fired when message is removed from the conversation's message list.
2051
+ *
2052
+ * Parameters:
2053
+ * 1. {@link Message} `message` - message that has been removed
2054
+ * @event
2055
+ */
2056
+ static readonly messageRemoved = "messageRemoved";
2057
+ /**
2058
+ * Fired when data of a message has been updated.
2059
+ *
2060
+ * Parameters:
2061
+ * 1. object `data` - info object provided with the event. It has the
2062
+ * following properties:
2063
+ * * {@link Message} `message` - message that has received the update
2064
+ * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
2065
+ * the update
2066
+ * @event
2067
+ */
2068
+ static readonly messageUpdated = "messageUpdated";
2069
+ /**
2070
+ * Fired when a participant has stopped typing.
2071
+ *
2072
+ * Parameters:
2073
+ * 1. {@link Participant} `participant` - the participant that has stopped
2074
+ * typing
2075
+ * @event
2076
+ */
2077
+ static readonly typingEnded = "typingEnded";
2078
+ /**
2079
+ * Fired when a participant has started typing.
2080
+ *
2081
+ * Parameters:
2082
+ * 1. {@link Participant} `participant` - the participant that has started
2083
+ * typing
2084
+ * @event
2085
+ */
2086
+ static readonly typingStarted = "typingStarted";
2087
+ /**
2088
+ * Fired when the data of the conversation has been updated.
2089
+ *
2090
+ * Parameters:
2091
+ * 1. object `data` - info object provided with the event. It has the
2092
+ * following properties:
2093
+ * * {@link Conversation} `conversation` - conversation that has received
2094
+ * the update
2095
+ * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
2096
+ * for the update
2097
+ * @event
2098
+ */
2099
+ static readonly updated = "updated";
2100
+ /**
2101
+ * Fired when the conversation was destroyed or the currently-logged-in user
2102
+ * has left private conversation.
2103
+ *
2104
+ * Parameters:
2105
+ * 1. {@link Conversation} `conversation` - conversation that has been removed
2106
+ * @event
2107
+ */
2108
+ static readonly removed = "removed";
2109
+ /**
2110
+ * Logger instance.
2111
+ */
2112
+ private static readonly _logger;
2113
+ /**
2114
+ * Unique system identifier of the conversation.
2115
+ */
2116
+ readonly sid: string;
2117
+ /**
2118
+ * Conversation links for REST requests.
2119
+ * @internal
2120
+ */
2121
+ readonly _links: ConversationLinks;
2122
+ /**
2123
+ * Configuration of the client that the conversation belongs to.
2124
+ */
2125
+ private readonly _configuration;
2126
+ /**
2127
+ * Conversation service objects.
2128
+ */
2129
+ private readonly _services;
2130
+ /**
2131
+ * Internal state of the conversation.
2132
+ */
2133
+ private readonly _internalState;
2134
+ /**
2135
+ * Name of the conversation entity document.
2136
+ */
2137
+ private readonly _entityName;
2138
+ /**
2139
+ * Messages entity.
2140
+ */
2141
+ private readonly _messagesEntity;
2142
+ /**
2143
+ * Sync list containing messages.
2144
+ */
2145
+ private _messagesList?;
2146
+ /**
2147
+ * Map of participants.
2148
+ * @internal
2149
+ */
2150
+ readonly _participants: Map<string, Participant>;
2151
+ /**
2152
+ * Participants entity.
2153
+ */
2154
+ private readonly _participantsEntity;
2155
+ /**
2156
+ * Sync map containing participants.
2157
+ */
2158
+ private _participantsMap?;
2159
+ /**
2160
+ * Source of the most recent update.
2161
+ */
2162
+ private _dataSource;
2163
+ /**
2164
+ * Promise for the conversation entity document.
2165
+ */
2166
+ private _entityPromise;
2167
+ /**
2168
+ * Promise for the messages list.
2169
+ */
2170
+ private _streamsPromise;
2171
+ /**
2172
+ * Conversation entity document.
2173
+ */
2174
+ private _entity;
2175
+ /**
2176
+ * @param descriptor Conversation descriptor.
2177
+ * @param sid Conversation SID.
2178
+ * @param links Conversation links for REST requests.
2179
+ * @param configuration Client configuration.
2180
+ * @param services Conversation services.
2181
+ * @internal
2182
+ */
2183
+ constructor(descriptor: ConversationDescriptor, sid: string, links: ConversationLinks, configuration: Configuration, services: ConversationServices);
2184
+ /**
2185
+ * Unique name of the conversation.
2186
+ */
2187
+ get uniqueName(): string | null;
2188
+ /**
2189
+ * Status of the conversation.
2190
+ */
2191
+ get status(): ConversationStatus;
2192
+ /**
2193
+ * Name of the conversation.
2194
+ */
2195
+ get friendlyName(): string | null;
2196
+ /**
2197
+ * Date this conversation was last updated on.
2198
+ */
2199
+ get dateUpdated(): Date | null;
2200
+ /**
2201
+ * Date this conversation was created on.
2202
+ */
2203
+ get dateCreated(): Date | null;
2204
+ /**
2205
+ * Identity of the user that created this conversation.
2206
+ */
2207
+ get createdBy(): string;
2208
+ /**
2209
+ * Custom attributes of the conversation.
2210
+ */
2211
+ get attributes(): JSONValue;
2212
+ /**
2213
+ * Index of the last message the user has read in this conversation.
2214
+ */
2215
+ get lastReadMessageIndex(): number | null;
2216
+ /**
2217
+ * Last message sent to this conversation.
2218
+ */
2219
+ get lastMessage(): LastMessage | undefined;
2220
+ /**
2221
+ * User notification level for this conversation.
2222
+ */
2223
+ get notificationLevel(): NotificationLevel;
2224
+ /**
2225
+ * Conversation bindings. An undocumented feature (for now).
2226
+ * @internal
2227
+ */
2228
+ get bindings(): ConversationBindings;
2229
+ /**
2230
+ * Current conversation limits.
2231
+ */
2232
+ get limits(): ConversationLimits;
2233
+ /**
2234
+ * State of the conversation.
2235
+ */
2236
+ get state(): ConversationState | undefined;
2237
+ /**
2238
+ * Source of the conversation update.
2239
+ * @internal
2240
+ */
2241
+ get _statusSource(): ConversationsDataSource;
2242
+ /**
2243
+ * Preprocess the update object.
2244
+ * @param update The update object received from Sync.
2245
+ * @param conversationSid The SID of the conversation in question.
2246
+ */
2247
+ private static preprocessUpdate;
2248
+ /**
2249
+ * Add a participant to the conversation by its identity.
2250
+ * @param identity Identity of the Client to add.
2251
+ * @param attributes Attributes to be attached to the participant.
2252
+ * @returns The added participant.
2253
+ */
2254
+ add(identity: string, attributes?: JSONValue): Promise<ParticipantResponse>;
2255
+ /**
2256
+ * Add a non-chat participant to the conversation.
2257
+ * @param proxyAddress Proxy (Twilio) address of the participant.
2258
+ * @param address User address of the participant.
2259
+ * @param attributes Attributes to be attached to the participant.
2260
+ * @param bindingOptions Options for adding email participants - name and
2261
+ * CC/To level.
2262
+ * @returns The added participant.
2263
+ */
2264
+ addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<ParticipantResponse>;
2265
+ /**
2266
+ * Advance the conversation's last read message index to the current read
2267
+ * horizon. Rejects if the user is not a participant of the conversation. Last
2268
+ * read message index is updated only if the new index value is higher than
2269
+ * the previous.
2270
+ * @param index Message index to advance to.
2271
+ * @return Resulting unread messages count in the conversation.
2272
+ */
2273
+ advanceLastReadMessageIndex(index: number): Promise<number>;
2274
+ /**
2275
+ * Delete the conversation and unsubscribe from its events.
2276
+ */
2277
+ delete(): Promise<Conversation>;
2278
+ /**
2279
+ * Get the custom attributes of this Conversation.
2280
+ */
2281
+ getAttributes(): Promise<JSONValue>;
2282
+ /**
2283
+ * Returns messages from the conversation using the paginator interface.
2284
+ * @param pageSize Number of messages to return in a single chunk. Default is
2285
+ * 30.
2286
+ * @param anchor Index of the newest message to fetch. Default is from the
2287
+ * end.
2288
+ * @param direction Query direction. By default, it queries backwards
2289
+ * from newer to older. The `"forward"` value will query in the opposite
2290
+ * direction.
2291
+ * @return A page of messages.
2292
+ */
2293
+ getMessages(pageSize?: number, anchor?: number, direction?: "backwards" | "forward"): Promise<Paginator<Message>>;
2294
+ /**
2295
+ * Get a list of all the participants who are joined to this conversation.
2296
+ */
2297
+ getParticipants(): Promise<Participant[]>;
2298
+ /**
2299
+ * Get conversation participants count.
2300
+ *
2301
+ * This method is semi-realtime. This means that this data will be eventually
2302
+ * correct, but will also be possibly incorrect for a few seconds. The
2303
+ * Conversations system does not provide real time events for counter values
2304
+ * changes.
2305
+ *
2306
+ * This is useful for any UI badges, but it is not recommended to build any
2307
+ * core application logic based on these counters being accurate in real time.
2308
+ */
2309
+ getParticipantsCount(): Promise<number>;
2310
+ /**
2311
+ * Get a participant by its SID.
2312
+ * @param participantSid Participant SID.
2313
+ */
2314
+ getParticipantBySid(participantSid: string): Promise<Participant | null>;
2315
+ /**
2316
+ * Get a participant by its identity.
2317
+ * @param identity Participant identity.
2318
+ */
2319
+ getParticipantByIdentity(identity?: string | null): Promise<Participant | null>;
2320
+ /**
2321
+ * Get the total message count in the conversation.
2322
+ *
2323
+ * This method is semi-realtime. This means that this data will be eventually
2324
+ * correct, but will also be possibly incorrect for a few seconds. The
2325
+ * Conversations system does not provide real time events for counter values
2326
+ * changes.
2327
+ *
2328
+ * This is useful for any UI badges, but it is not recommended to build any
2329
+ * core application logic based on these counters being accurate in real time.
2330
+ */
2331
+ getMessagesCount(): Promise<number>;
2332
+ /**
2333
+ * Get count of unread messages for the user if they are a participant of this
2334
+ * conversation. Rejects if the user is not a participant of the conversation.
2335
+ *
2336
+ * Use this method to obtain the number of unread messages together with
2337
+ * {@link Conversation.updateLastReadMessageIndex} instead of relying on the
2338
+ * message indices which may have gaps. See {@link Message.index} for details.
2339
+ *
2340
+ * This method is semi-realtime. This means that this data will be eventually
2341
+ * correct, but it will also be possibly incorrect for a few seconds. The
2342
+ * Conversations system does not provide real time events for counter values
2343
+ * changes.
2344
+ *
2345
+ * This is useful for any UI badges, but it is not recommended to build any
2346
+ * core application logic based on these counters being accurate in real time.
2347
+ *
2348
+ * If the read horizon is not set, this function will return null. This could mean
2349
+ * that all messages in the conversation are unread, or that the read horizon system
2350
+ * is not being used. How to interpret this `null` value is up to the customer application.
2351
+ *
2352
+ * @return Number of unread messages based on the current read horizon set for
2353
+ * the user or `null` if the read horizon is not set.
2354
+ */
2355
+ getUnreadMessagesCount(): Promise<number | null>;
2356
+ /**
2357
+ * Join the conversation and subscribe to its events.
2358
+ */
2359
+ join(): Promise<Conversation>;
2360
+ /**
2361
+ * Leave the conversation.
2362
+ */
2363
+ leave(): Promise<Conversation>;
2364
+ /**
2365
+ * Remove a participant from the conversation. When a string is passed as the
2366
+ * argument, it will assume that the string is an identity or SID.
2367
+ * @param participant Identity, SID or the participant object to remove.
2368
+ */
2369
+ removeParticipant(participant: string | Participant): Promise<void>;
2370
+ /**
2371
+ * Send a message to the conversation.
2372
+ * @param message Message body for the text message,
2373
+ * `FormData` or {@link SendMediaOptions} for media content. Sending FormData
2374
+ * is supported only with the browser engine.
2375
+ * @param messageAttributes Attributes for the message.
2376
+ * @param emailOptions Email options for the message.
2377
+ * @return Index of the new message.
2378
+ */
2379
+ sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<number>;
2380
+ /**
2381
+ * New interface to prepare for sending a message.
2382
+ * Use this instead of {@link Conversation.sendMessage}.
2383
+ * @return A MessageBuilder to help set all message sending options.
2384
+ */
2385
+ prepareMessage(): MessageBuilder;
2386
+ /**
2387
+ * Set last read message index of the conversation to the index of the last
2388
+ * known message.
2389
+ * @return Resulting unread messages count in the conversation.
2390
+ */
2391
+ setAllMessagesRead(): Promise<number>;
2392
+ /**
2393
+ * Set all messages in the conversation unread.
2394
+ * @returns New count of unread messages after this update.
2395
+ */
2396
+ setAllMessagesUnread(): Promise<number>;
2397
+ /**
2398
+ * Set user notification level for this conversation.
2399
+ * @param notificationLevel New user notification level.
2400
+ */
2401
+ setUserNotificationLevel(notificationLevel: NotificationLevel): Promise<void>;
2402
+ /**
2403
+ * Send a notification to the server indicating that this client is currently
2404
+ * typing in this conversation. Typing ended notification is sent after a
2405
+ * while automatically, but by calling this method again you ensure that
2406
+ * typing ended is not received.
2407
+ */
2408
+ typing(): Promise<void>;
2409
+ /**
2410
+ * Update the attributes of the conversation.
2411
+ * @param attributes New attributes.
2412
+ */
2413
+ updateAttributes(attributes: JSONValue): Promise<Conversation>;
2414
+ /**
2415
+ * Update the friendly name of the conversation.
2416
+ * @param friendlyName New friendly name.
2417
+ */
2418
+ updateFriendlyName(friendlyName: string): Promise<Conversation>;
2419
+ /**
2420
+ * Set the last read message index to the current read horizon.
2421
+ * @param index Message index to set as last read. If null is provided, then
2422
+ * the behavior is identical to {@link Conversation.setAllMessagesUnread}.
2423
+ * @returns New count of unread messages after this update.
2424
+ */
2425
+ updateLastReadMessageIndex(index: number | null): Promise<number>;
2426
+ /**
2427
+ * Update the unique name of the conversation.
2428
+ * @param uniqueName New unique name for the conversation. Setting unique name
2429
+ * to null removes it.
2430
+ */
2431
+ updateUniqueName(uniqueName: string | null): Promise<Conversation>;
2432
+ /**
2433
+ * Get recipients of all messages in the conversation.
2434
+ * @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.
2435
+ */
2436
+ getMessageRecipients(options?: PaginatorOptions): Promise<Paginator<RecipientDescriptor>>;
2437
+ /**
2438
+ * Load and subscribe to this conversation and do not subscribe to its
2439
+ * participants and messages. This or _subscribeStreams will need to be called
2440
+ * before any events in the conversation will fire.
2441
+ * @internal
2442
+ */
2443
+ _subscribe(): Promise<SyncDocument>;
2444
+ /**
2445
+ * Fetch participants and messages of the conversation. This method needs to
2446
+ * be called during conversation initialization to catch broken conversations
2447
+ * (broken conversations are conversations that have essential Sync entities
2448
+ * missing, i.e. the conversation document, the messages list or the
2449
+ * participant map). In case of this conversation being broken, the method
2450
+ * will throw an exception that will be caught and handled gracefully.
2451
+ * @internal
2452
+ */
2453
+ _fetchStreams(): Promise<boolean>;
2454
+ /**
2455
+ * Load the attributes of this conversation and instantiate its participants
2456
+ * and messages. This or _subscribe will need to be called before any events
2457
+ * on the conversation will fire. This will need to be called before any
2458
+ * events on participants or messages will fire
2459
+ * @internal
2460
+ */
2461
+ _subscribeStreams(): Promise<void>;
2462
+ /**
2463
+ * Stop listening for and firing events on this conversation.
2464
+ * @internal
2465
+ */
2466
+ _unsubscribe(): Promise<[
2467
+ void,
2468
+ void
2469
+ ]>;
2470
+ /**
2471
+ * Set conversation status.
2472
+ * @internal
2473
+ */
2474
+ _setStatus(status: ConversationStatus, source: ConversationsDataSource): void;
2475
+ /**
2476
+ * Update the local conversation object with new values.
2477
+ * @internal
2478
+ */
2479
+ _update(update: any): void;
2480
+ /**
2481
+ * Handle onMessageAdded event.
2482
+ */
2483
+ private _onMessageAdded;
2484
+ /**
2485
+ * Set last read message index.
2486
+ * @param index New index to set.
2487
+ */
2488
+ private _setLastReadMessageIndex;
2489
+ }
2490
+ type ConversationsDataSource = "sync" | "rest";
2491
+ type PushNotificationType = "twilio.conversations.new_message" | "twilio.conversations.added_to_conversation" | "twilio.conversations.removed_from_conversation";
2492
+ interface PushNotificationDescriptor {
2493
+ title: string | null;
2494
+ body: string | null;
2495
+ sound: string | null;
2496
+ badge: number | null;
2497
+ action: string | null;
2498
+ type: PushNotificationType;
2499
+ data: Record<string, unknown>;
2500
+ }
2501
+ /**
2502
+ * Additional data for a given push notification.
2503
+ */
2504
+ interface PushNotificationData {
2505
+ /**
2506
+ * SID of the conversation.
2507
+ */
2508
+ conversationSid?: string;
2509
+ /**
2510
+ * Title of the conversation.
2511
+ */
2512
+ conversationTitle?: string;
2513
+ /**
2514
+ * Index of the message in the conversation.
2515
+ */
2516
+ messageIndex?: number;
2517
+ /**
2518
+ * SID of the message in the conversation.
2519
+ */
2520
+ messageSid?: string;
2521
+ /**
2522
+ * Media of the notification
2523
+ */
2524
+ media?: Media;
2525
+ /**
2526
+ * Count of the attached media of the message.
2527
+ */
2528
+ mediaCount?: number;
2529
+ }
2530
+ /**
2531
+ * Push notification for a Conversations client.
2532
+ */
2533
+ declare class PushNotification {
2534
+ /**
2535
+ * Title of the notification.
2536
+ */
2537
+ readonly title: string | null;
2538
+ /**
2539
+ * Text of the notification.
2540
+ */
2541
+ readonly body: string | null;
2542
+ /**
2543
+ * Sound of the notification.
2544
+ */
2545
+ readonly sound: string | null;
2546
+ /**
2547
+ * Number of the badge.
2548
+ */
2549
+ readonly badge: number | null;
2550
+ /**
2551
+ * Notification action (`click_action` in FCM terms and `category` in APN terms).
2552
+ */
2553
+ readonly action: string | null;
2554
+ /**
2555
+ * Type of the notification.
2556
+ */
2557
+ readonly type: PushNotificationType;
2558
+ /**
2559
+ * Additional data of the conversation.
2560
+ */
2561
+ readonly data: PushNotificationData;
2562
+ /**
2563
+ * @internal
2564
+ */
2565
+ constructor(data: PushNotificationDescriptor);
2566
+ }
2567
+ /**
2568
+ * Client events.
2569
+ */
2570
+ type ClientEvents = {
2571
+ conversationAdded: (conversation: Conversation) => void;
2572
+ conversationJoined: (conversation: Conversation) => void;
2573
+ conversationLeft: (conversation: Conversation) => void;
2574
+ conversationRemoved: (conversation: Conversation) => void;
2575
+ conversationUpdated: (data: {
2576
+ conversation: Conversation;
2577
+ updateReasons: ConversationUpdateReason[];
2578
+ }) => void;
2579
+ participantJoined: (participant: Participant) => void;
2580
+ participantLeft: (participant: Participant) => void;
2581
+ participantUpdated: (data: {
2582
+ participant: Participant;
2583
+ updateReasons: ParticipantUpdateReason[];
2584
+ }) => void;
2585
+ messageAdded: (message: Message) => void;
2586
+ messageRemoved: (message: Message) => void;
2587
+ messageUpdated: (data: {
2588
+ message: Message;
2589
+ updateReasons: MessageUpdateReason[];
2590
+ }) => void;
2591
+ tokenAboutToExpire: () => void;
2592
+ tokenExpired: () => void;
2593
+ typingEnded: (participant: Participant) => void;
2594
+ typingStarted: (participant: Participant) => void;
2595
+ pushNotification: (pushNotification: PushNotification) => void;
2596
+ userSubscribed: (user: User) => void;
2597
+ userUnsubscribed: (user: User) => void;
2598
+ userUpdated: (data: {
2599
+ user: User;
2600
+ updateReasons: UserUpdateReason[];
2601
+ }) => void;
2602
+ stateChanged: (state: State) => void;
2603
+ initialized: () => void;
2604
+ initFailed: ({ error }: {
2605
+ error?: ConnectionError;
2606
+ }) => void;
2607
+ connectionStateChanged: (state: TwilsockConnectionState) => void;
2608
+ connectionError: (data: ConnectionError) => void;
2609
+ };
2610
+ /**
2611
+ * Connection state of the client. Possible values are as follows:
2612
+ * * `'connecting'` - client is offline and connection attempt is in process
2613
+ * * `'connected'` - client is online and ready
2614
+ * * `'disconnecting'` - client is going offline as disconnection is in process
2615
+ * * `'disconnected'` - client is offline and no connection attempt is in
2616
+ * process
2617
+ * * `'denied'` - client connection is denied because of invalid JWT access
2618
+ * token. User must refresh token in order to proceed
2619
+ */
2620
+ type ConnectionState = TwilsockConnectionState;
2621
+ /**
2622
+ * State of the client. Possible values are as follows:
2623
+ * * `'failed'` - the client failed to initialize
2624
+ * * `'initialized'` - the client successfully initialized
2625
+ */
2626
+ type State = "failed" | "initialized";
2627
+ /**
2628
+ * Notifications channel type. Possible values are as follows:
2629
+ * * `'fcm'`
2630
+ * * `'apn'`
2631
+ */
2632
+ type NotificationsChannelType = ChannelType;
2633
+ /**
2634
+ * Level of logging.
2635
+ */
2636
+ type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent";
2637
+ /**
2638
+ * Conversations client options.
2639
+ */
2640
+ interface ClientOptions {
2641
+ /**
2642
+ * The level of logging to enable.
2643
+ */
2644
+ logLevel?: LogLevel;
2645
+ /**
2646
+ * The cache capacity for channel metadata.
2647
+ */
2648
+ channelMetadataCacheCapacity?: number;
2649
+ /**
2650
+ * The cache capacity for message recipients.
2651
+ */
2652
+ messageRecipientsCacheCapacity?: number;
2653
+ region?: string;
2654
+ productId?: string;
2655
+ twilsockClient?: TwilsockClient;
2656
+ transport?: Transport;
2657
+ notificationsClient?: NotificationClient;
2658
+ syncClient?: SyncClient;
2659
+ typingIndicatorTimeoutOverride?: number;
2660
+ consumptionReportIntervalOverride?: string;
2661
+ httpCacheIntervalOverride?: string;
2662
+ userInfosToSubscribeOverride?: number;
2663
+ retryWhenThrottledOverride?: boolean;
2664
+ backoffConfigOverride?: Record<string, unknown>;
2665
+ Chat?: ClientOptions;
2666
+ IPMessaging?: ClientOptions;
2667
+ Sync?: Record<string, unknown>;
2668
+ Notification?: Record<string, unknown>;
2669
+ Twilsock?: Record<string, unknown>;
2670
+ clientMetadata?: Record<string, unknown>;
2671
+ initRegistrations?: InitRegistration[];
2672
+ disableDeepClone?: boolean;
2673
+ typingUri?: string;
2674
+ apiUri?: string;
2675
+ throwErrorsAlways?: boolean;
2676
+ }
2677
+ type ConnectionError = {
2678
+ terminal: boolean;
2679
+ message: string;
2680
+ };
2681
+ /**
2682
+ * Options for {@link Client.createConversation}.
2683
+ */
2684
+ interface CreateConversationOptions {
2685
+ /**
2686
+ * Any custom attributes to attach to the conversation.
2687
+ */
2688
+ attributes?: JSONValue;
2689
+ /**
2690
+ * A non-unique display name of the conversation.
2691
+ */
2692
+ friendlyName?: string;
2693
+ /**
2694
+ * A unique identifier of the conversation.
2695
+ */
2696
+ uniqueName?: string;
2697
+ /**
2698
+ * The access control for the conversation.
2699
+ * null for existing conversations, 'restricted' for conversations that need to support users with restricted access
2700
+ */
2701
+ access?: string;
2702
+ }
2703
+ /**
2704
+ * A client is the starting point to the Twilio Conversations functionality.
2705
+ */
2706
+ declare class Client extends ReplayEventEmitter<ClientEvents> {
2707
+ /**
2708
+ * Fired when a conversation becomes visible to the client. The event is also
2709
+ * triggered when the client creates a new conversation.
2710
+ * Fired for all conversations that the client has joined.
2711
+ *
2712
+ * Parameters:
2713
+ * 1. {@link Conversation} `conversation` - the conversation in question
2714
+ * @event
2715
+ */
2716
+ static readonly conversationAdded = "conversationAdded";
2717
+ /**
2718
+ * Fired when the client joins a conversation.
2719
+ *
2720
+ * Parameters:
2721
+ * 1. {@link Conversation} `conversation` - the conversation in question
2722
+ * @event
2723
+ */
2724
+ static readonly conversationJoined = "conversationJoined";
2725
+ /**
2726
+ * Fired when the client leaves a conversation.
2727
+ *
2728
+ * Parameters:
2729
+ * 1. {@link Conversation} `conversation` - the conversation in question
2730
+ * @event
2731
+ */
2732
+ static readonly conversationLeft = "conversationLeft";
2733
+ /**
2734
+ * Fired when a conversation is no longer visible to the client.
2735
+ *
2736
+ * Parameters:
2737
+ * 1. {@link Conversation} `conversation` - the conversation in question
2738
+ * @event
2739
+ */
2740
+ static readonly conversationRemoved = "conversationRemoved";
2741
+ /**
2742
+ * Fired when the attributes or the metadata of a conversation have been
2743
+ * updated. During conversation's creation and initialization, this event
2744
+ * might be fired multiple times for same joined or created conversation as
2745
+ * new data is arriving from different sources.
2746
+ *
2747
+ * Parameters:
2748
+ * 1. object `data` - info object provided with the event. It has the
2749
+ * following properties:
2750
+ * * {@link Conversation} `conversation` - the conversation in question
2751
+ * * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
2752
+ * for the update
2753
+ * @event
2754
+ */
2755
+ static readonly conversationUpdated = "conversationUpdated";
2756
+ /**
2757
+ * Fired when a participant has joined a conversation.
2758
+ *
2759
+ * Parameters:
2760
+ * 1. {@link Participant} `participant` - the participant in question
2761
+ * @event
2762
+ */
2763
+ static readonly participantJoined = "participantJoined";
2764
+ /**
2765
+ * Fired when a participant has left a conversation.
2766
+ *
2767
+ * Parameters:
2768
+ * 1. {@link Participant} `participant` - the participant in question
2769
+ * @event
2770
+ */
2771
+ static readonly participantLeft = "participantLeft";
2772
+ /**
2773
+ * Fired when a participant's fields have been updated.
2774
+ *
2775
+ * Parameters:
2776
+ * 1. object `data` - info object provided with the event. It has the
2777
+ * following properties:
2778
+ * * {@link Participant} `participant` - the participant in question
2779
+ * * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
2780
+ * for the update
2781
+ * @event
2782
+ */
2783
+ static readonly participantUpdated = "participantUpdated";
2784
+ /**
2785
+ * Fired when a new message has been added to the conversation on the server.
2786
+ *
2787
+ * Parameters:
2788
+ * 1. {@link Message} `message` - the message in question
2789
+ * @event
2790
+ */
2791
+ static readonly messageAdded = "messageAdded";
2792
+ /**
2793
+ * Fired when a message is removed from the message list of a conversation.
2794
+ *
2795
+ * Parameters:
2796
+ * 1. {@link Message} `message` - the message in question
2797
+ * @event
2798
+ */
2799
+ static readonly messageRemoved = "messageRemoved";
2800
+ /**
2801
+ * Fired when the fields of an existing message are updated with new values.
2802
+ *
2803
+ * Parameters:
2804
+ * 1. object `data` - info object provided with the event. It has the
2805
+ * following properties:
2806
+ * * {@link Message} `message` - the message in question
2807
+ * * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
2808
+ * the update
2809
+ * @event
2810
+ */
2811
+ static readonly messageUpdated = "messageUpdated";
2812
+ /**
2813
+ * Fired when the token is about to expire and needs to be updated.
2814
+ * @event
2815
+ */
2816
+ static readonly tokenAboutToExpire = "tokenAboutToExpire";
2817
+ /**
2818
+ * Fired when the token has expired.
2819
+ * @event
2820
+ */
2821
+ static readonly tokenExpired = "tokenExpired";
2822
+ /**
2823
+ * Fired when a participant has stopped typing.
2824
+ *
2825
+ * Parameters:
2826
+ * 1. {@link Participant} `participant` - the participant in question
2827
+ * @event
2828
+ */
2829
+ static readonly typingEnded = "typingEnded";
2830
+ /**
2831
+ * Fired when a participant has started typing.
2832
+ *
2833
+ * Parameters:
2834
+ * 1. {@link Participant} `participant` - the participant in question
2835
+ * @event
2836
+ */
2837
+ static readonly typingStarted = "typingStarted";
2838
+ /**
2839
+ * Fired when the client has received (and parsed) a push notification via one
2840
+ * of the push channels (apn or fcm).
2841
+ *
2842
+ * Parameters:
2843
+ * 1. {@link PushNotification} `pushNotification` - the push notification in
2844
+ * question
2845
+ * @event
2846
+ */
2847
+ static readonly pushNotification = "pushNotification";
2848
+ /**
2849
+ * Fired when the client has subscribed to a user.
2850
+ *
2851
+ * Parameters:
2852
+ * 1. {@link User} `user` - the user in question
2853
+ * @event
2854
+ */
2855
+ static readonly userSubscribed = "userSubscribed";
2856
+ /**
2857
+ * Fired when the client has unsubscribed from a user.
2858
+ *
2859
+ * Parameters:
2860
+ * 1. {@link User} `user` - the user in question
2861
+ * @event
2862
+ */
2863
+ static readonly userUnsubscribed = "userUnsubscribed";
2864
+ /**
2865
+ * Fired when the properties or the reachability status of a user have been
2866
+ * updated.
2867
+ *
2868
+ * Parameters:
2869
+ * 1. object `data` - info object provided with the event. It has the
2870
+ * following properties:
2871
+ * * {@link User} `user` - the user in question
2872
+ * * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the
2873
+ * update
2874
+ * @event
2875
+ */
2876
+ static readonly userUpdated = "userUpdated";
2877
+ /**
2878
+ * @deprecated Use initialized or initFailed events instead
2879
+ * Fired when the state of the client has been changed.
2880
+ *
2881
+ * Parameters:
2882
+ * 1. {@link State} `state` - the new client state
2883
+ * @event
2884
+ */
2885
+ static readonly stateChanged = "stateChanged";
2886
+ /**
2887
+ * Fired when the client has completed initialization successfully.
2888
+ * @event
2889
+ */
2890
+ static readonly initialized = "initialized";
2891
+ /**
2892
+ * Fired when the client initialization failed.
2893
+ *
2894
+ * Parameters:
2895
+ * 1. object `data` - info object provided with the event. It has the
2896
+ * following property:
2897
+ * * Error? `error` - the initialization error if present
2898
+ * @event
2899
+ */
2900
+ static readonly initFailed = "initFailed";
2901
+ /**
2902
+ * Fired when the connection state of the client has been changed.
2903
+ *
2904
+ * Parameters:
2905
+ * 1. {@link ConnectionState} `state` - the new connection state
2906
+ * @event
2907
+ */
2908
+ static readonly connectionStateChanged = "connectionStateChanged";
2909
+ /**
2910
+ * Fired when the connection is interrupted for an unexpected reason.
2911
+ *
2912
+ * Parameters:
2913
+ * 1. object `data` - info object provided with the event. It has the
2914
+ * following properties:
2915
+ * * boolean `terminal` - Twilsock will stop connection attempts if true
2916
+ * * string `message` - the error message of the root cause
2917
+ * * number? `httpStatusCode` - http status code if available
2918
+ * * number? `errorCode` - Twilio public error code if available
2919
+ * @event
2920
+ */
2921
+ static readonly connectionError = "connectionError";
2922
+ /**
2923
+ * Current version of the Conversations client.
2924
+ */
2925
+ static readonly version: string;
2926
+ /**
2927
+ * Logger instance.
2928
+ */
2929
+ private static readonly _logger;
2930
+ /**
2931
+ * Supported push notification channels.
2932
+ */
2933
+ private static readonly _supportedPushChannels;
2934
+ /**
2935
+ * Supported push data fields.
2936
+ */
2937
+ private static readonly _supportedPushDataFields;
2938
+ /**
2939
+ * Current version of the Conversations client.
2940
+ */
2941
+ readonly version: string;
2942
+ /**
2943
+ * Client connection state.
2944
+ */
2945
+ connectionState: ConnectionState;
2946
+ /**
2947
+ * Promise that resolves on successful initialization.
2948
+ */
2949
+ private _ensureReady;
2950
+ /**
2951
+ * Options passed to the client.
2952
+ */
2953
+ private readonly _options;
2954
+ /**
2955
+ * Client service objects.
2956
+ */
2957
+ private readonly _services;
2958
+ /**
2959
+ * The user of the client.
2960
+ */
2961
+ private readonly _myself;
2962
+ /**
2963
+ * Resolves the {@link Client._ensureReady} promise.
2964
+ */
2965
+ private _resolveEnsureReady;
2966
+ /**
2967
+ * Rejects the {@link Client._ensureReady} promise.
2968
+ */
2969
+ private _rejectEnsureReady;
2970
+ /**
2971
+ * The current token of the client.
2972
+ */
2973
+ private _fpaToken;
2974
+ /**
2975
+ * The constructed configuration object.
2976
+ */
2977
+ private _configuration;
2978
+ /**
2979
+ * The Conversations entity.
2980
+ */
2981
+ private _conversationsEntity;
2982
+ /**
2983
+ * Promise that resolves when initial conversations are fetched.
2984
+ */
2985
+ private _conversationsPromise;
2986
+ /**
2987
+ * Returned Conversations Client instance is not yet fully initialized. Calling any
2988
+ * operations will block until it is. Use connection events to monitor when
2989
+ * client becomes fully available (connectionStateChanged with state
2990
+ * 'connected') or not available (connectionStateChange with state 'denied',
2991
+ * event tokenExpired, event connectionError).
2992
+ *
2993
+ * @param fpaToken Access token
2994
+ * @param options Options to customize the Client
2995
+ * @returns A not yet fully-initialized client.
2996
+ */
2997
+ constructor(fpaToken: string, options?: ClientOptions | null);
2998
+ /**
2999
+ * Information of the logged-in user. Before client initialization, returns an
3000
+ * uninitialized user. Will trigger a {@link Client.userUpdated} event after
3001
+ * initialization.
3002
+ */
3003
+ get user(): User;
3004
+ /**
3005
+ * Client reachability state. Throws an error if accessed before the client
3006
+ * initialization was completed.
3007
+ */
3008
+ get reachabilityEnabled(): boolean;
3009
+ /**
3010
+ * @deprecated
3011
+ * Current token.
3012
+ * @internal
3013
+ */
3014
+ get token(): string;
3015
+ /**
3016
+ * @deprecated Call constructor directly.
3017
+ *
3018
+ * Factory method to create a Conversations client instance.
3019
+ *
3020
+ * The factory method will automatically trigger connection.
3021
+ * Do not use it if you need finer-grained control.
3022
+ *
3023
+ * Since this method returns an already-initialized client, some of the events
3024
+ * will be lost because they happen *before* the initialization. It is
3025
+ * recommended that `client.onWithReplay` is used as opposed to `client.on`
3026
+ * for subscribing to client events. The `client.onWithReplay` will re-emit
3027
+ * the most recent value for a given event if it emitted before the
3028
+ * subscription.
3029
+ *
3030
+ * @param token Access token.
3031
+ * @param options Options to customize the client.
3032
+ * @returns Returns a fully initialized client.
3033
+ */
3034
+ static create(token: string, options?: ClientOptions | null): Promise<Client>;
3035
+ /**
3036
+ * Static method for push notification payload parsing. Returns parsed push as
3037
+ * a {@link PushNotification} object.
3038
+ * @param notificationPayload Push notification payload.
3039
+ */
3040
+ static parsePushNotification(notificationPayload: any): PushNotification;
3041
+ /**
3042
+ * Static method for parsing push notification chat data.
3043
+ * @param data Data to parse
3044
+ */
3045
+ private static _parsePushNotificationChatData;
3046
+ /**
3047
+ * Populate the client with init registrations.
3048
+ * @param reg The init registration to populate.
3049
+ */
3050
+ static populateInitRegistrations(reg: InitRegistration): void;
3051
+ /**
3052
+ * Gracefully shut down the client.
3053
+ */
3054
+ shutdown(): Promise<void>;
3055
+ /**
3056
+ * Update the token used by the client and re-register with the Conversations services.
3057
+ * @param token New access token.
3058
+ */
3059
+ updateToken(token: string): Promise<Client>;
3060
+ /**
3061
+ * Get a known conversation by its SID.
3062
+ * @param conversationSid Conversation sid
3063
+ */
3064
+ getConversationBySid(conversationSid: string): Promise<Conversation>;
3065
+ /**
3066
+ * Peek a conversation by its SID.
3067
+ * @param conversationSid Conversation sid
3068
+ */
3069
+ peekConversationBySid(conversationSid: string): Promise<Conversation>;
3070
+ /**
3071
+ * Get a known conversation by its unique identifier name.
3072
+ * @param uniqueName The unique identifier name of the conversation.
3073
+ */
3074
+ getConversationByUniqueName(uniqueName: string): Promise<Conversation>;
3075
+ /**
3076
+ * Get the current list of all the subscribed conversations.
3077
+ */
3078
+ getSubscribedConversations(): Promise<Paginator<Conversation>>;
3079
+ /**
3080
+ * Create a conversation on the server and subscribe to its events.
3081
+ * The default is a conversation with an empty friendly name.
3082
+ * @param options Options for the conversation.
3083
+ */
3084
+ createConversation(options?: CreateConversationOptions): Promise<Conversation>;
3085
+ /**
3086
+ * Register for push notifications.
3087
+ * @param channelType Channel type.
3088
+ * @param registrationId Push notification ID provided by the FCM/APNS service
3089
+ * on the platform.
3090
+ */
3091
+ setPushRegistrationId(channelType: NotificationsChannelType, registrationId: string): Promise<void>;
3092
+ /**
3093
+ * Unregister from push notifications.
3094
+ * @param channelType Channel type.
3095
+ * @deprecated Use removePushRegistrations() instead.
3096
+ */
3097
+ unsetPushRegistrationId(channelType: NotificationsChannelType): Promise<void>;
3098
+ /**
3099
+ * Clear existing registrations directly using provided device token.
3100
+ * This is useful to ensure stopped subscriptions without resubscribing.
3101
+ *
3102
+ * This function goes completely beside the state machine and removes all
3103
+ * registrations.
3104
+ * Use with caution: if it races with current state machine operations,
3105
+ * madness will ensue.
3106
+ *
3107
+ * @param channelType Channel type.
3108
+ * @param registrationId Push notification ID provided by the FCM/APNS service
3109
+ * on the platform.
3110
+ */
3111
+ removePushRegistrations(channelType: ChannelType, registrationId: string): Promise<void>;
3112
+ /**
3113
+ * Parse a push notification payload.
3114
+ */
3115
+ parsePushNotification: typeof Client.parsePushNotification;
3116
+ /**
3117
+ * Handle push notification payload parsing and emit the
3118
+ * {@link Client.pushNotification} event on this {@link Client} instance.
3119
+ * @param notificationPayload Push notification payload
3120
+ */
3121
+ handlePushNotification(notificationPayload: any): Promise<void>;
3122
+ /**
3123
+ * Gets a user with the given identity. If it's in the subscribed list, then
3124
+ * return the user object from it;
3125
+ * if not, then subscribe and add user to the subscribed list.
3126
+ * @param identity Identity of the user.
3127
+ * @returns A fully initialized user.
3128
+ */
3129
+ getUser(identity: string): Promise<User>;
3130
+ /**
3131
+ * Get a list of subscribed user objects.
3132
+ */
3133
+ getSubscribedUsers(): Promise<Array<User>>;
3134
+ /**
3135
+ * Get content URLs for all media attachments in the given set of media sids
3136
+ * using a single operation.
3137
+ * @param mediaSids Set of media sids to query for the content URL.
3138
+ */
3139
+ getTemporaryContentUrlsForMediaSids(mediaSids: string[]): CancellablePromise<Map<string, string>>;
3140
+ /**
3141
+ * Get content URLs for all media attachments in the given set using a single
3142
+ * operation.
3143
+ * @param contentSet Set of media attachments to query content URLs.
3144
+ */
3145
+ getTemporaryContentUrlsForMedia(contentSet: Media[]): CancellablePromise<Map<string, string>>;
3146
+ /**
3147
+ * Returns rich content templates belonging to the account. Rich content
3148
+ * templates can be created via the Twilio console or the REST API.
3149
+ */
3150
+ getContentTemplates(): Promise<Readonly<ContentTemplate[]>>;
3151
+ /**
3152
+ * Initialize the client.
3153
+ */
3154
+ private _initialize;
3155
+ /**
3156
+ * Subscribe to push notifications.
3157
+ * @param channelType The channel type to subscribe to.
3158
+ */
3159
+ private _subscribeToPushNotifications;
3160
+ /**
3161
+ * Unsubscribe from push notifications.
3162
+ * @param channelType The channel type to unsubscribe from.
3163
+ */
3164
+ private _unsubscribeFromPushNotifications;
3165
+ /**
3166
+ * Initialize the ensureReady promise.
3167
+ */
3168
+ private _initializeEnsureReady;
3169
+ }
3170
+ declare class NotificationTypes {
3171
+ static readonly TYPING_INDICATOR = "twilio.ipmsg.typing_indicator";
3172
+ static readonly NEW_MESSAGE = "twilio.conversations.new_message";
3173
+ static readonly ADDED_TO_CONVERSATION = "twilio.conversations.added_to_conversation";
3174
+ // static readonly INVITED_TO_CHANNEL = 'twilio.channel.invited_to_channel';
3175
+ static readonly REMOVED_FROM_CONVERSATION = "twilio.conversations.removed_from_conversation";
3176
+ static readonly CONSUMPTION_UPDATE = "twilio.channel.consumption_update";
3177
+ }
3178
+ 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 };