@twilio/conversations 2.1.0-rc.1 → 2.1.0-rc.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/NOTICE.txt +679 -0
  3. package/builds/browser.js +674 -587
  4. package/builds/browser.js.map +1 -1
  5. package/builds/lib.d.ts +319 -122
  6. package/builds/lib.js +674 -587
  7. package/builds/lib.js.map +1 -1
  8. package/builds/twilio-conversations.js +852 -909
  9. package/builds/twilio-conversations.min.js +2 -14
  10. package/dist/aggregated-delivery-receipt.js +6 -1
  11. package/dist/aggregated-delivery-receipt.js.map +1 -1
  12. package/dist/client.js +165 -142
  13. package/dist/client.js.map +1 -1
  14. package/dist/command-executor.js +16 -14
  15. package/dist/command-executor.js.map +1 -1
  16. package/dist/configuration.js +14 -10
  17. package/dist/configuration.js.map +1 -1
  18. package/dist/conversation.js +212 -153
  19. package/dist/conversation.js.map +1 -1
  20. package/dist/data/conversations.js +81 -77
  21. package/dist/data/conversations.js.map +1 -1
  22. package/dist/data/messages.js +42 -38
  23. package/dist/data/messages.js.map +1 -1
  24. package/dist/data/participants.js +93 -75
  25. package/dist/data/participants.js.map +1 -1
  26. package/dist/data/users.js +24 -22
  27. package/dist/data/users.js.map +1 -1
  28. package/dist/detailed-delivery-receipt.js +1 -1
  29. package/dist/detailed-delivery-receipt.js.map +1 -1
  30. package/dist/interfaces/attributes.js +4 -4
  31. package/dist/interfaces/attributes.js.map +1 -1
  32. package/dist/interfaces/notification-types.js +5 -5
  33. package/dist/interfaces/notification-types.js.map +1 -1
  34. package/dist/logger.js +36 -15
  35. package/dist/logger.js.map +1 -1
  36. package/dist/media.js +21 -9
  37. package/dist/media.js.map +1 -1
  38. package/dist/message-builder.js +10 -9
  39. package/dist/message-builder.js.map +1 -1
  40. package/dist/message.js +131 -83
  41. package/dist/message.js.map +1 -1
  42. package/dist/packages/conversations/package.json.js +1 -1
  43. package/dist/participant.js +85 -51
  44. package/dist/participant.js.map +1 -1
  45. package/dist/push-notification.js.map +1 -1
  46. package/dist/rest-paginator.js +16 -6
  47. package/dist/rest-paginator.js.map +1 -1
  48. package/dist/services/network.js +18 -14
  49. package/dist/services/network.js.map +1 -1
  50. package/dist/services/typing-indicator.js +20 -17
  51. package/dist/services/typing-indicator.js.map +1 -1
  52. package/dist/unsent-message.js.map +1 -1
  53. package/dist/user.js +85 -59
  54. package/dist/user.js.map +1 -1
  55. package/dist/util/deferred.js +3 -1
  56. package/dist/util/deferred.js.map +1 -1
  57. package/dist/util/index.js +6 -6
  58. package/dist/util/index.js.map +1 -1
  59. package/docs/assets/js/search.js +1 -1
  60. package/docs/classes/AggregatedDeliveryReceipt.html +0 -117
  61. package/docs/classes/Client.html +24 -147
  62. package/docs/classes/Conversation.html +30 -147
  63. package/docs/classes/DetailedDeliveryReceipt.html +1 -118
  64. package/docs/classes/Media.html +0 -117
  65. package/docs/classes/Message.html +7 -124
  66. package/docs/classes/MessageBuilder.html +2 -119
  67. package/docs/classes/Participant.html +7 -124
  68. package/docs/classes/PushNotification.html +0 -117
  69. package/docs/classes/RestPaginator.html +0 -117
  70. package/docs/classes/UnsentMessage.html +0 -117
  71. package/docs/classes/User.html +7 -124
  72. package/docs/index.html +60 -0
  73. package/docs/interfaces/ClientOptions.html +0 -117
  74. package/docs/interfaces/ConversationBindings.html +0 -117
  75. package/docs/interfaces/ConversationEmailBinding.html +0 -117
  76. package/docs/interfaces/ConversationLimits.html +3098 -0
  77. package/docs/interfaces/ConversationState.html +0 -117
  78. package/docs/interfaces/CreateConversationOptions.html +1 -118
  79. package/docs/interfaces/LastMessage.html +0 -117
  80. package/docs/interfaces/Paginator.html +0 -117
  81. package/docs/interfaces/ParticipantBindings.html +0 -117
  82. package/docs/interfaces/ParticipantEmailBinding.html +0 -117
  83. package/docs/interfaces/PushNotificationData.html +0 -117
  84. package/docs/interfaces/SendEmailOptions.html +0 -117
  85. package/docs/interfaces/SendMediaOptions.html +0 -117
  86. package/docs/modules.html +60 -0
  87. package/package.json +23 -17
package/builds/lib.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { SyncClient } from "twilio-sync";
2
- import { Transport, TwilsockClient, InitRegistration } from "twilsock";
1
+ import { SyncClient, SyncDocument, SyncList } from "twilio-sync";
2
+ import { LogLevelDesc } from "loglevel";
3
+ import { Transport, TwilsockClient, InitRegistration, TransportResult } from "twilsock";
3
4
  import { ConnectionState as TwilsockConnectionState } from "twilsock";
4
5
  import { ReplayEventEmitter } from "@twilio/replay-event-emitter";
5
6
  import { ChannelType, Notifications } from "@twilio/notifications";
@@ -41,8 +42,8 @@ declare class Logger {
41
42
  private prefix;
42
43
  private constructor();
43
44
  static scope(prefix: string): Logger;
44
- setLevel(level: any): void;
45
- static setLevel(level: any): void;
45
+ setLevel(level: LogLevelDesc): void;
46
+ static setLevel(level: LogLevelDesc): void;
46
47
  trace(...args: any[]): void;
47
48
  debug(...args: any[]): void;
48
49
  info(...args: any[]): void;
@@ -54,11 +55,29 @@ declare class Logger {
54
55
  static warn(...args: any[]): void;
55
56
  static error(...args: any[]): void;
56
57
  }
57
- interface Limits {
58
+ /**
59
+ * Represents conversation limits.
60
+ */
61
+ interface ConversationLimits {
62
+ /**
63
+ * Maximum amount of attachments.
64
+ */
58
65
  mediaAttachmentsCountLimit: number;
66
+ /**
67
+ * Maximum attachment size in MB.
68
+ */
59
69
  mediaAttachmentSizeLimitInMb: number;
70
+ /**
71
+ * Maximum total attachment size in MB.
72
+ */
60
73
  mediaAttachmentsTotalSizeLimitInMb: number;
74
+ /**
75
+ * Allowed mime types for E-Mail histories.
76
+ */
61
77
  emailHistoriesAllowedMimeTypes: string[];
78
+ /**
79
+ * Allowed mime types for E-Mail bodies.
80
+ */
62
81
  emailBodiesAllowedMimeTypes: string[];
63
82
  }
64
83
  interface BackoffConfiguration {
@@ -77,7 +96,7 @@ declare class Configuration {
77
96
  mediaSetService: string;
78
97
  messagesReceipts: string;
79
98
  };
80
- readonly limits: Limits;
99
+ readonly limits: ConversationLimits;
81
100
  readonly productId?: string;
82
101
  readonly typingIndicatorTimeoutOverride?: number;
83
102
  readonly typingIndicatorTimeoutDefault: number;
@@ -90,7 +109,7 @@ declare class Configuration {
90
109
  readonly userIdentity: string;
91
110
  readonly userInfo: string;
92
111
  readonly myConversations: string;
93
- constructor(options: Record<string, any>, configurationResponse: ConfigurationResponse, logger: Logger);
112
+ constructor(options: ClientOptions, configurationResponse: ConfigurationResponse, logger: Logger);
94
113
  }
95
114
  interface CommandExecutorServices {
96
115
  transport: Transport;
@@ -105,6 +124,20 @@ declare class CommandExecutor {
105
124
  fetchResource<REQ = void, RESP = void>(url: string, requestBody?: REQ): Promise<RESP>;
106
125
  mutateResource<REQ = void, RESP = void>(method: "post" | "delete", url: string, requestBody?: REQ): Promise<RESP>;
107
126
  }
127
+ /**
128
+ * Represents a JSON value.
129
+ */
130
+ type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
131
+ /**
132
+ * Represents a JSON object.
133
+ */
134
+ type JSONObject = {
135
+ [x: string]: JSONValue;
136
+ };
137
+ /**
138
+ * Represents a JSON array.
139
+ */
140
+ type JSONArray = JSONValue[];
108
141
  type UserEvents = {
109
142
  updated: (data: {
110
143
  user: User;
@@ -180,25 +213,29 @@ declare class User extends ReplayEventEmitter<UserEvents> {
180
213
  /**
181
214
  * Custom attributes of the user.
182
215
  */
183
- get attributes(): any;
216
+ get attributes(): JSONValue;
184
217
  /**
185
218
  * Friendly name of the user, null if not set.
186
219
  */
187
- get friendlyName(): string;
220
+ get friendlyName(): string | null;
188
221
  /**
189
222
  * Status of the real-time conversation connection of the user.
190
223
  */
191
- get isOnline(): boolean;
224
+ get isOnline(): boolean | null;
192
225
  /**
193
226
  * User push notification registration status.
194
227
  */
195
- get isNotifiable(): boolean;
228
+ get isNotifiable(): boolean | null;
196
229
  /**
197
230
  * True if this user is receiving real-time status updates.
198
231
  */
199
232
  get isSubscribed(): boolean;
200
233
  // Handles service updates
201
- _update(key: string, value: any): Promise<void>;
234
+ _update(key: string, value: {
235
+ value: string;
236
+ notifiable: boolean | null;
237
+ online: boolean | null;
238
+ }): Promise<void>;
202
239
  // Fetch reachability info
203
240
  private _updateReachabilityInfo;
204
241
  // Fetch user
@@ -208,7 +245,7 @@ declare class User extends ReplayEventEmitter<UserEvents> {
208
245
  * Edit user attributes.
209
246
  * @param attributes New attributes.
210
247
  */
211
- updateAttributes(attributes: any): Promise<User>;
248
+ updateAttributes(attributes: JSONValue): Promise<User>;
212
249
  /**
213
250
  * Update the friendly name of the user.
214
251
  * @param friendlyName New friendly name.
@@ -232,7 +269,7 @@ declare class Network {
232
269
  private cleanupCache;
233
270
  pokeTimer(): void;
234
271
  private executeWithRetry;
235
- get(url: string): Promise<any>;
272
+ get<T>(url: string): Promise<TransportResult<T>>;
236
273
  }
237
274
  type UsersEvents = {
238
275
  userUpdated: (data: {
@@ -264,7 +301,7 @@ declare class Users extends ReplayEventEmitter<UsersEvents> {
264
301
  * if not - then subscribes and adds user to the FIFO stack
265
302
  * @returns {Promise<User>} Fully initialized user
266
303
  */
267
- getUser(identity: string, entityName?: string): Promise<User>;
304
+ getUser(identity?: string, entityName?: string): Promise<User>;
268
305
  /**
269
306
  * @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}
270
307
  */
@@ -283,16 +320,16 @@ type ParticipantEvents = {
283
320
  }) => void;
284
321
  };
285
322
  interface ParticipantDescriptor {
286
- attributes?: Object;
287
- dateCreated: any;
288
- dateUpdated: any;
323
+ attributes?: JSONValue;
324
+ dateCreated: Date | null;
325
+ dateUpdated: Date | null;
289
326
  identity: string;
290
327
  roleSid?: string;
291
- lastConsumedMessageIndex: number;
328
+ lastConsumedMessageIndex: number | null;
292
329
  lastConsumptionTimestamp: number;
293
330
  type: ParticipantType;
294
331
  userInfo: string;
295
- bindings?: Object;
332
+ bindings?: ParticipantBindings;
296
333
  }
297
334
  interface ParticipantServices {
298
335
  users: Users;
@@ -351,19 +388,19 @@ declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
351
388
  /**
352
389
  * Custom attributes of the participant.
353
390
  */
354
- get attributes(): Object;
391
+ get attributes(): JSONValue;
355
392
  /**
356
393
  * Date this participant was created on.
357
394
  */
358
- get dateCreated(): Date;
395
+ get dateCreated(): Date | null;
359
396
  /**
360
397
  * Date this participant was last updated on.
361
398
  */
362
- get dateUpdated(): Date;
399
+ get dateUpdated(): Date | null;
363
400
  /**
364
401
  * Identity of the participant.
365
402
  */
366
- get identity(): string;
403
+ get identity(): string | null;
367
404
  /**
368
405
  * Indicates whether the participant is currently typing.
369
406
  */
@@ -378,7 +415,7 @@ declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
378
415
  /**
379
416
  * Date of the most recent read horizon update.
380
417
  */
381
- get lastReadTimestamp(): Date;
418
+ get lastReadTimestamp(): Date | null;
382
419
  get roleSid(): string;
383
420
  /**
384
421
  * Type of the participant.
@@ -451,7 +488,27 @@ declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
451
488
  * Update the attributes of the participant.
452
489
  * @param attributes New attributes.
453
490
  */
454
- updateAttributes(attributes: any): Promise<Participant>;
491
+ updateAttributes(attributes: JSONValue): Promise<Participant>;
492
+ }
493
+ interface ParticipantResponse {
494
+ account_sid: string;
495
+ chat_service_sid: string;
496
+ conversation_sid: string;
497
+ role_sid: string;
498
+ sid: string;
499
+ attributes: string;
500
+ date_created: string;
501
+ date_updated: string;
502
+ identity: string | null;
503
+ messaging_binding: {
504
+ type: string;
505
+ address: string;
506
+ proxy_address: string;
507
+ } | null;
508
+ url: string;
509
+ links: {
510
+ conversation: string;
511
+ };
455
512
  }
456
513
  interface ParticipantBindingOptions {
457
514
  email?: ParticipantEmailBinding;
@@ -466,7 +523,7 @@ type MediaCategory$0 = McsMediaCategory;
466
523
  interface MediaState {
467
524
  sid: string;
468
525
  category: MediaCategory$0;
469
- filename?: string;
526
+ filename: string | null;
470
527
  contentType: string;
471
528
  size: number;
472
529
  }
@@ -491,7 +548,7 @@ declare class Media {
491
548
  /**
492
549
  * File name. Null if absent.
493
550
  */
494
- get filename(): string;
551
+ get filename(): string | null;
495
552
  /**
496
553
  * Content type of the media.
497
554
  */
@@ -511,7 +568,7 @@ declare class Media {
511
568
  * If the URL becomes expired, you need to request a new one.
512
569
  * Each call to this function produces a new temporary URL.
513
570
  */
514
- getContentTemporaryUrl(): Promise<string>;
571
+ getContentTemporaryUrl(): Promise<string | null>;
515
572
  /**
516
573
  * Returns cached direct content URL for the media.
517
574
  *
@@ -521,7 +578,7 @@ declare class Media {
521
578
  *
522
579
  * @returns {Promise<String>}
523
580
  */
524
- getCachedTemporaryUrl(): Promise<string>;
581
+ getCachedTemporaryUrl(): Promise<string | null>;
525
582
  private _fetchMcsMedia;
526
583
  }
527
584
  /**
@@ -616,7 +673,7 @@ interface DetailedDeliveryReceiptDescriptor {
616
673
  channel_message_sid: string;
617
674
  participant_sid: string;
618
675
  status: DeliveryStatus;
619
- error_code: number | null;
676
+ error_code: string | null;
620
677
  date_created: string;
621
678
  date_updated: string;
622
679
  }
@@ -652,7 +709,7 @@ declare class DetailedDeliveryReceipt {
652
709
  * Numeric error code mapped from Status callback code. Information about the error codes can be found
653
710
  * [here](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors).
654
711
  */
655
- errorCode: number | null;
712
+ errorCode: string | 0;
656
713
  /**
657
714
  * Date this delivery receipt was created on.
658
715
  */
@@ -694,6 +751,21 @@ interface MessageUpdatedEventArgs {
694
751
  message: Message;
695
752
  updateReasons: MessageUpdateReason[];
696
753
  }
754
+ interface MessageData {
755
+ sid: string;
756
+ text?: string;
757
+ type?: MessageType;
758
+ author: string | null;
759
+ subject: string | null;
760
+ lastUpdatedBy?: string | null;
761
+ attributes?: JSONValue;
762
+ dateUpdated: string;
763
+ timestamp?: string;
764
+ medias?: Media[];
765
+ media?: Media;
766
+ memberSid?: string;
767
+ delivery?: AggregatedDeliveryDescriptor;
768
+ }
697
769
  /**
698
770
  * A message in a conversation.
699
771
  */
@@ -709,7 +781,7 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
709
781
  /**
710
782
  * @internal
711
783
  */
712
- constructor(index: number, data: any, conversation: Conversation, links: MessageLinks, configuration: Configuration, services: MessageServices);
784
+ constructor(index: number, data: MessageData, conversation: Conversation, links: MessageLinks, configuration: Configuration, services: MessageServices);
713
785
  /**
714
786
  * Fired when the properties or the body of the message has been updated.
715
787
  *
@@ -726,7 +798,7 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
726
798
  /**
727
799
  * Name of the user that sent the message.
728
800
  */
729
- get author(): string;
801
+ get author(): string | null;
730
802
  /**
731
803
  * Message subject. Used only in email conversations.
732
804
  */
@@ -734,11 +806,11 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
734
806
  /**
735
807
  * Body of the message.
736
808
  */
737
- get body(): string;
809
+ get body(): string | null;
738
810
  /**
739
811
  * Date this message was last updated on.
740
812
  */
741
- get dateUpdated(): Date;
813
+ get dateUpdated(): Date | null;
742
814
  /**
743
815
  * Index of the message in the conversation's messages list.
744
816
  * By design of the Conversations system, the message indices may have arbitrary gaps between them,
@@ -754,15 +826,15 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
754
826
  /**
755
827
  * Identity of the last user that updated the message.
756
828
  */
757
- get lastUpdatedBy(): string;
829
+ get lastUpdatedBy(): string | null;
758
830
  /**
759
831
  * Date this message was created on.
760
832
  */
761
- get dateCreated(): Date;
833
+ get dateCreated(): Date | null;
762
834
  /**
763
835
  * Custom attributes of the message.
764
836
  */
765
- get attributes(): Object;
837
+ get attributes(): JSONValue;
766
838
  /**
767
839
  * Type of the message.
768
840
  */
@@ -779,7 +851,7 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
779
851
  /**
780
852
  * The server-assigned unique identifier of the authoring participant.
781
853
  */
782
- get participantSid(): string;
854
+ get participantSid(): string | null;
783
855
  /**
784
856
  * Aggregated information about the message delivery statuses across all participants of a conversation..
785
857
  */
@@ -825,12 +897,12 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
825
897
  * Edit the message attributes.
826
898
  * @param attributes New attributes.
827
899
  */
828
- updateAttributes(attributes: any): Promise<Message>;
900
+ updateAttributes(attributes: JSONValue): Promise<Message>;
829
901
  /**
830
902
  * Get content URLs for all media attachments in the given set using single operation.
831
903
  * @param contentSet Set of media attachments to query for content URL.
832
904
  */
833
- attachTemporaryUrlsFor(contentSet: Media[]): Promise<Media[]>;
905
+ attachTemporaryUrlsFor(contentSet: Media[] | null): Promise<Media[]>;
834
906
  private _getDetailedDeliveryReceiptsPaginator;
835
907
  }
836
908
  /**
@@ -912,9 +984,9 @@ declare class TypingIndicator {
912
984
  declare class UnsentMessage {
913
985
  private messagesEntity;
914
986
  text?: string;
915
- attributes: any;
987
+ attributes: JSONValue;
916
988
  mediaContent: [MediaCategory, FormData | SendMediaOptions][];
917
- emailOptions?: SendEmailOptions;
989
+ emailOptions: SendEmailOptions;
918
990
  /**
919
991
  * @internal
920
992
  */
@@ -923,7 +995,154 @@ declare class UnsentMessage {
923
995
  * Send the prepared message to the conversation.
924
996
  * @returns Index of the new message in the conversation.
925
997
  */
926
- send(): Promise<number>;
998
+ send(): Promise<number | null>;
999
+ }
1000
+ /**
1001
+ * Pagination helper class.
1002
+ */
1003
+ declare class RestPaginator<T> implements Paginator<T> {
1004
+ private state;
1005
+ /**
1006
+ * Indicates the existence of the next page.
1007
+ */
1008
+ get hasNextPage(): boolean;
1009
+ /**
1010
+ * Indicates the existence of the previous page
1011
+ */
1012
+ get hasPrevPage(): boolean;
1013
+ /**
1014
+ * Array of elements on the current page.
1015
+ */
1016
+ get items(): T[];
1017
+ /**
1018
+ * @internal
1019
+ */
1020
+ constructor(items: any, source: any, prevToken: any, nextToken: any);
1021
+ /**
1022
+ * Request the next page. Does not modify the existing object.
1023
+ */
1024
+ nextPage(): Promise<RestPaginator<T>>;
1025
+ /**
1026
+ * Request the previous page. Does not modify the existing object.
1027
+ */
1028
+ prevPage(): Promise<RestPaginator<T>>;
1029
+ }
1030
+ /**
1031
+ * @classdesc Pagination helper class for Sync
1032
+ *
1033
+ * @property {Array} items Array of elements on current page
1034
+ * @property {boolean} hasNextPage
1035
+ * @property {boolean} hasPrevPage
1036
+ */
1037
+ declare class SyncPaginator<T> implements Paginator<T> {
1038
+ private state;
1039
+ hasNextPage: boolean;
1040
+ hasPrevPage: boolean;
1041
+ get items(): T[];
1042
+ /**
1043
+ * @param {Array} items Array of element for current page
1044
+ * @param {Object} params
1045
+ */
1046
+ constructor(items: any, pageSize: any, anchor: any, direction: any, source: any);
1047
+ nextPage(): Promise<RestPaginator<T>>;
1048
+ prevPage(): Promise<SyncPaginator<T> | RestPaginator<T>>;
1049
+ }
1050
+ interface MessageResponse {
1051
+ account_sid: string;
1052
+ chat_service_sid: string;
1053
+ conversation_sid: string;
1054
+ sid: string;
1055
+ index: number;
1056
+ attributes: string;
1057
+ author: string;
1058
+ participant_sid: string;
1059
+ body: string;
1060
+ subject: string;
1061
+ date_created: string;
1062
+ date_updated: string;
1063
+ url: string;
1064
+ media: {
1065
+ sid: string;
1066
+ size: string;
1067
+ content_type: string;
1068
+ filename: string;
1069
+ }[] | null;
1070
+ links: {
1071
+ conversation: string;
1072
+ messages_receipts: string;
1073
+ };
1074
+ }
1075
+ type MessagesEvents = {
1076
+ messageAdded: (message: Message) => void;
1077
+ messageRemoved: (message: Message) => void;
1078
+ messageUpdated: (data: {
1079
+ message: Message;
1080
+ updateReasons: MessageUpdateReason[];
1081
+ }) => void;
1082
+ };
1083
+ interface MessagesServices {
1084
+ mcsClient: McsClient;
1085
+ network: Network;
1086
+ syncClient: SyncClient;
1087
+ commandExecutor: CommandExecutor;
1088
+ }
1089
+ /**
1090
+ * Represents the collection of messages in a conversation
1091
+ */
1092
+ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
1093
+ readonly conversation: Conversation;
1094
+ private readonly configuration;
1095
+ private readonly services;
1096
+ private readonly messagesByIndex;
1097
+ private messagesListPromise;
1098
+ constructor(conversation: Conversation, configuration: Configuration, services: MessagesServices);
1099
+ /**
1100
+ * Subscribe to the Messages Event Stream
1101
+ * @param name - The name of Sync object for the Messages resource.
1102
+ */
1103
+ subscribe(name: string): Promise<SyncList>;
1104
+ unsubscribe(): Promise<void>;
1105
+ /**
1106
+ * Send Message to the conversation, message could include both text and multiple media attachments.
1107
+ * @param message Message to post
1108
+ * @returns Returns a promise which can fail
1109
+ */
1110
+ sendV2(message: UnsentMessage): Promise<MessageResponse>;
1111
+ /**
1112
+ * Send Message to the conversation
1113
+ * @param message Message to post
1114
+ * @param attributes Message attributes
1115
+ * @param emailOptions Options that modify E-mail integration behaviors.
1116
+ * @returns Returns promise which can fail
1117
+ */
1118
+ send(message: null | string | FormData | SendMediaOptions, attributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<MessageResponse>;
1119
+ /**
1120
+ * Send Media Message to the conversation
1121
+ * @param mediaContent Media content to post
1122
+ * @param attributes Message attributes
1123
+ * @param emailOptions Email options
1124
+ * @returns Returns promise which can fail
1125
+ */
1126
+ sendMedia(mediaContent: FormData | SendMediaOptions, attributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<MessageResponse>;
1127
+ /**
1128
+ * Returns messages from conversation using paginator interface
1129
+ * @param pageSize Number of messages to return in single chunk. By default it's 30.
1130
+ * @param anchor Most early message id which is already known, or 'end' by default
1131
+ * @param direction Pagination order 'backwards' or 'forward', 'forward' by default
1132
+ * @returns Last page of messages by default
1133
+ */
1134
+ getMessages(pageSize: number | undefined, anchor: number | "end" | undefined, direction?: "forward" | "backwards"): Promise<SyncPaginator<Message>>;
1135
+ private _wrapPaginator;
1136
+ private _upsertMessage;
1137
+ /**
1138
+ * Returns last messages from conversation
1139
+ * @param {Number} [pageSize] Number of messages to return in single chunk. By default it's 30.
1140
+ * @param {String} [anchor] Most early message id which is already known, or 'end' by default
1141
+ * @param {String} [direction] Pagination order 'backwards' or 'forward', or 'forward' by default
1142
+ * @returns {Promise<SyncPaginator<Message>>} last page of messages by default
1143
+ * @private
1144
+ */
1145
+ private _getMessages;
927
1146
  }
928
1147
  /**
929
1148
  * Message builder. Allows the message to be built and sent via method chaining.
@@ -948,7 +1167,7 @@ declare class MessageBuilder {
948
1167
  /**
949
1168
  * @internal
950
1169
  */
951
- constructor(limits: Limits, messagesEntity: any);
1170
+ constructor(limits: ConversationLimits, messagesEntity: Messages);
952
1171
  /**
953
1172
  * Sets the message body.
954
1173
  * @param text Contents of the body.
@@ -963,7 +1182,7 @@ declare class MessageBuilder {
963
1182
  * Sets the message attributes.
964
1183
  * @param attributes Message attributes.
965
1184
  */
966
- setAttributes(attributes: any): MessageBuilder;
1185
+ setAttributes(attributes: JSONValue): MessageBuilder;
967
1186
  /**
968
1187
  * Set email body with given MIME-type.
969
1188
  * @param mimeType Format of the body to set (text/plain or text/html).
@@ -1020,12 +1239,12 @@ interface ConversationDescriptor {
1020
1239
  channel: string;
1021
1240
  entityName: string;
1022
1241
  uniqueName: string;
1023
- attributes: any;
1242
+ attributes: JSONValue;
1024
1243
  createdBy?: string;
1025
1244
  friendlyName?: string;
1026
1245
  lastConsumedMessageIndex: number;
1027
- dateCreated: any;
1028
- dateUpdated: any;
1246
+ dateCreated: Date | null;
1247
+ dateUpdated: Date | null;
1029
1248
  notificationLevel?: NotificationLevel;
1030
1249
  bindings?: ConversationBindings;
1031
1250
  }
@@ -1073,6 +1292,7 @@ interface ConversationUpdatedEventArgs {
1073
1292
  */
1074
1293
  interface ConversationBindings {
1075
1294
  email?: ConversationEmailBinding;
1295
+ sms?: ConversationSmsBinding;
1076
1296
  }
1077
1297
  /**
1078
1298
  * Binding for email conversation.
@@ -1081,6 +1301,9 @@ interface ConversationEmailBinding {
1081
1301
  name?: string;
1082
1302
  projected_address: string;
1083
1303
  }
1304
+ interface ConversationSmsBinding {
1305
+ address?: string;
1306
+ }
1084
1307
  /**
1085
1308
  * Configuration for attaching a media file to a message.
1086
1309
  * These options can be passed to {@link Conversation.sendMessage} and
@@ -1090,7 +1313,7 @@ interface SendMediaOptions {
1090
1313
  /**
1091
1314
  * Content type of media.
1092
1315
  */
1093
- contentType: string;
1316
+ contentType: null | string;
1094
1317
  /**
1095
1318
  * Optional filename.
1096
1319
  */
@@ -1098,7 +1321,7 @@ interface SendMediaOptions {
1098
1321
  /**
1099
1322
  * Content to post.
1100
1323
  */
1101
- media: string | Buffer | Blob;
1324
+ media: null | string | Buffer | Blob;
1102
1325
  }
1103
1326
  /**
1104
1327
  * These options can be passed to {@link Conversation.sendMessage}.
@@ -1234,7 +1457,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1234
1457
  /**
1235
1458
  * Unique name of the conversation.
1236
1459
  */
1237
- get uniqueName(): string;
1460
+ get uniqueName(): string | null;
1238
1461
  /**
1239
1462
  * Status of the conversation.
1240
1463
  */
@@ -1242,15 +1465,15 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1242
1465
  /**
1243
1466
  * Name of the conversation.
1244
1467
  */
1245
- get friendlyName(): string;
1468
+ get friendlyName(): string | null;
1246
1469
  /**
1247
1470
  * Date this conversation was last updated on.
1248
1471
  */
1249
- get dateUpdated(): any;
1472
+ get dateUpdated(): Date | null;
1250
1473
  /**
1251
1474
  * Date this conversation was created on.
1252
1475
  */
1253
- get dateCreated(): any;
1476
+ get dateCreated(): Date | null;
1254
1477
  /**
1255
1478
  * Identity of the user that created this conversation.
1256
1479
  */
@@ -1258,7 +1481,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1258
1481
  /**
1259
1482
  * Custom attributes of the conversation.
1260
1483
  */
1261
- get attributes(): any;
1484
+ get attributes(): JSONValue;
1262
1485
  /**
1263
1486
  * Index of the last message the user has read in this conversation.
1264
1487
  */
@@ -1266,13 +1489,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1266
1489
  /**
1267
1490
  * Last message sent to this conversation.
1268
1491
  */
1269
- get lastMessage(): LastMessage;
1492
+ get lastMessage(): LastMessage | undefined;
1270
1493
  /**
1271
1494
  * User notification level for this conversation.
1272
1495
  */
1273
1496
  get notificationLevel(): NotificationLevel;
1274
1497
  get bindings(): ConversationBindings;
1275
- get limits(): Limits;
1498
+ get limits(): ConversationLimits;
1276
1499
  /**
1277
1500
  * State of the conversation.
1278
1501
  */
@@ -1282,7 +1505,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1282
1505
  * This or _subscribeStreams will need to be called before any events on conversation will fire.
1283
1506
  * @internal
1284
1507
  */
1285
- _subscribe(): Promise<any>;
1508
+ _subscribe(): Promise<void | SyncDocument>;
1286
1509
  /**
1287
1510
  * Load the attributes of this conversation and instantiate its participants and messages.
1288
1511
  * This or _subscribe will need to be called before any events on the conversation will fire.
@@ -1296,7 +1519,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1296
1519
  */
1297
1520
  _unsubscribe(): Promise<[
1298
1521
  void,
1299
- any
1522
+ void
1300
1523
  ]>;
1301
1524
  /**
1302
1525
  * Set conversation status.
@@ -1324,7 +1547,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1324
1547
  * @param identity Identity of the Client to add.
1325
1548
  * @param attributes Attributes to be attached to the participant.
1326
1549
  */
1327
- add(identity: string, attributes?: any): Promise<void>;
1550
+ add(identity: string, attributes?: JSONValue): Promise<ParticipantResponse>;
1328
1551
  /**
1329
1552
  * Add a non-chat participant to the conversation.
1330
1553
  * @param proxyAddress Proxy (Twilio) address of the participant.
@@ -1332,7 +1555,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1332
1555
  * @param attributes Attributes to be attached to the participant.
1333
1556
  * @param bindingOptions Options for adding email participants - name and CC/To level.
1334
1557
  */
1335
- addNonChatParticipant(proxyAddress: string, address: string, attributes?: Record<string, any>, bindingOptions?: ParticipantBindingOptions): Promise<void>;
1558
+ addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<ParticipantResponse>;
1336
1559
  /**
1337
1560
  * Advance the conversation's last read message index to the current read horizon.
1338
1561
  * Rejects if the user is not a participant of the conversation.
@@ -1348,7 +1571,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1348
1571
  /**
1349
1572
  * Get the custom attributes of this Conversation.
1350
1573
  */
1351
- getAttributes(): Promise<any>;
1574
+ getAttributes(): Promise<JSONValue>;
1352
1575
  /**
1353
1576
  * Returns messages from the conversation using the paginator interface.
1354
1577
  * @param pageSize Number of messages to return in a single chunk. Default is 30.
@@ -1377,12 +1600,12 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1377
1600
  * Get a participant by its SID.
1378
1601
  * @param participantSid Participant SID.
1379
1602
  */
1380
- getParticipantBySid(participantSid: string): Promise<Participant>;
1603
+ getParticipantBySid(participantSid: string): Promise<Participant | null>;
1381
1604
  /**
1382
1605
  * Get a participant by its identity.
1383
1606
  * @param identity Participant identity.
1384
1607
  */
1385
- getParticipantByIdentity(identity: string): Promise<Participant>;
1608
+ getParticipantByIdentity(identity?: string | null): Promise<Participant | null>;
1386
1609
  /**
1387
1610
  * Get the total message count in the conversation.
1388
1611
  *
@@ -1423,6 +1646,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1423
1646
  * argument, it will assume that the string is an identity or SID.
1424
1647
  * @param participant Identity, SID or the participant object to remove.
1425
1648
  */
1649
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
1650
+ // @ts-ignore TODO: fix validateTypesAsync typing
1426
1651
  removeParticipant(participant: string | Participant): Promise<void>;
1427
1652
  /**
1428
1653
  * Send a message to the conversation.
@@ -1432,7 +1657,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1432
1657
  * @param emailOptions Email options for the message.
1433
1658
  * @return Index of the new message.
1434
1659
  */
1435
- sendMessage(message: string | FormData | SendMediaOptions | null, messageAttributes?: any, emailOptions?: SendEmailOptions): Promise<number>;
1660
+ sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<number>;
1436
1661
  /**
1437
1662
  * New interface to prepare for sending a message.
1438
1663
  * Use instead of `sendMessage`.
@@ -1463,7 +1688,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1463
1688
  * Update the attributes of the conversation.
1464
1689
  * @param attributes New attributes.
1465
1690
  */
1466
- updateAttributes(attributes: any): Promise<Conversation>;
1691
+ updateAttributes(attributes: JSONValue): Promise<Conversation>;
1467
1692
  /**
1468
1693
  * Update the friendly name of the conversation.
1469
1694
  * @param friendlyName New friendly name.
@@ -1488,13 +1713,13 @@ type ConversationsDataSource = "sync" | "chat" | "rest";
1488
1713
  */
1489
1714
  type PushNotificationType = "twilio.conversations.new_message" | "twilio.conversations.added_to_conversation" | "twilio.conversations.removed_from_conversation";
1490
1715
  interface PushNotificationDescriptor {
1491
- title: string;
1492
- body: string;
1493
- sound: string;
1494
- badge: number;
1495
- action: string;
1716
+ title: string | null;
1717
+ body: string | null;
1718
+ sound: string | null;
1719
+ badge: number | null;
1720
+ action: string | null;
1496
1721
  type: PushNotificationType;
1497
- data: Object;
1722
+ data: Record<string, unknown>;
1498
1723
  }
1499
1724
  /**
1500
1725
  * Additional data for a given push notification.
@@ -1520,23 +1745,23 @@ declare class PushNotification {
1520
1745
  /**
1521
1746
  * Title of the notification.
1522
1747
  */
1523
- readonly title: string;
1748
+ readonly title: string | null;
1524
1749
  /**
1525
1750
  * Text of the notification.
1526
1751
  */
1527
- readonly body: string;
1752
+ readonly body: string | null;
1528
1753
  /**
1529
1754
  * Sound of the notification.
1530
1755
  */
1531
- readonly sound: string;
1756
+ readonly sound: string | null;
1532
1757
  /**
1533
1758
  * Number of the badge.
1534
1759
  */
1535
- readonly badge: number;
1760
+ readonly badge: number | null;
1536
1761
  /**
1537
1762
  * Notification action (`click_action` in FCM terms and `category` in APN terms).
1538
1763
  */
1539
- readonly action: string;
1764
+ readonly action: string | null;
1540
1765
  /**
1541
1766
  * Type of the notification.
1542
1767
  */
@@ -1612,7 +1837,7 @@ type State = "failed" | "initialized";
1612
1837
  * * `'apn'`
1613
1838
  */
1614
1839
  type NotificationsChannelType = ChannelType;
1615
- type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent" | null;
1840
+ type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent";
1616
1841
  /**
1617
1842
  * Conversations client options.
1618
1843
  */
@@ -1632,15 +1857,17 @@ interface ClientOptions {
1632
1857
  httpCacheIntervalOverride?: string;
1633
1858
  userInfosToSubscribeOverride?: number;
1634
1859
  retryWhenThrottledOverride?: boolean;
1635
- backoffConfigOverride?: any;
1636
- Chat?: any;
1637
- IPMessaging?: any;
1638
- Sync?: any;
1639
- Notification?: any;
1640
- Twilsock?: any;
1641
- clientMetadata?: any;
1860
+ backoffConfigOverride?: Record<string, unknown>;
1861
+ Chat?: ClientOptions;
1862
+ IPMessaging?: ClientOptions;
1863
+ Sync?: Record<string, unknown>;
1864
+ Notification?: Record<string, unknown>;
1865
+ Twilsock?: Record<string, unknown>;
1866
+ clientMetadata?: Record<string, unknown>;
1642
1867
  initRegistrations?: InitRegistration[];
1643
1868
  disableDeepClone?: boolean;
1869
+ typingUri?: string;
1870
+ apiUri?: string;
1644
1871
  }
1645
1872
  /**
1646
1873
  * Options for {@link Client.createConversation}.
@@ -1649,7 +1876,7 @@ interface CreateConversationOptions {
1649
1876
  /**
1650
1877
  * Any custom attributes to attach to the conversation.
1651
1878
  */
1652
- attributes?: any;
1879
+ attributes?: JSONValue;
1653
1880
  /**
1654
1881
  * A non-unique display name of the conversation.
1655
1882
  */
@@ -1696,7 +1923,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
1696
1923
  * @param options Options to customize the Client
1697
1924
  * @returns A not yet fully-initialized client.
1698
1925
  */
1699
- constructor(fpaToken: string, options?: ClientOptions);
1926
+ constructor(fpaToken: string, options?: ClientOptions | null);
1700
1927
  static populateInitRegistrations(reg: InitRegistration): void;
1701
1928
  /**
1702
1929
  * Fired when a conversation becomes visible to the client. The event is also triggered when the client creates a new conversation.
@@ -1904,7 +2131,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
1904
2131
  * @param options Options to customize the client.
1905
2132
  * @returns Returns a fully initialized client.
1906
2133
  */
1907
- static create(token: string, options?: ClientOptions): Promise<Client>;
2134
+ static create(token: string, options?: ClientOptions | null): Promise<Client>;
1908
2135
  /**
1909
2136
  * Information of the logged-in user. Before client initialization, returns an
1910
2137
  * uninitialized user. Will trigger a {@link Client.userUpdated} event after
@@ -1942,7 +2169,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
1942
2169
  /**
1943
2170
  * Get the current list of all the subscribed conversations.
1944
2171
  */
1945
- getSubscribedConversations(args?: any): Promise<Paginator<Conversation>>;
2172
+ getSubscribedConversations(): Promise<Paginator<Conversation>>;
1946
2173
  /**
1947
2174
  * Create a conversation on the server and subscribe to its events.
1948
2175
  * The default is a conversation with an empty friendly name.
@@ -1996,36 +2223,6 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
1996
2223
  */
1997
2224
  getSubscribedUsers(): Promise<Array<User>>;
1998
2225
  }
1999
- /**
2000
- * Pagination helper class.
2001
- */
2002
- declare class RestPaginator<T> implements Paginator<T> {
2003
- private state;
2004
- /**
2005
- * Indicates the existence of the next page.
2006
- */
2007
- get hasNextPage(): boolean;
2008
- /**
2009
- * Indicates the existence of the previous page
2010
- */
2011
- get hasPrevPage(): boolean;
2012
- /**
2013
- * Array of elements on the current page.
2014
- */
2015
- get items(): Array<T>;
2016
- /**
2017
- * @internal
2018
- */
2019
- constructor(items: any, source: any, prevToken: any, nextToken: any);
2020
- /**
2021
- * Request the next page. Does not modify the existing object.
2022
- */
2023
- nextPage(): Promise<RestPaginator<T>>;
2024
- /**
2025
- * Request the previous page. Does not modify the existing object.
2026
- */
2027
- prevPage(): Promise<RestPaginator<T>>;
2028
- }
2029
2226
  declare class NotificationTypes {
2030
2227
  static readonly TYPING_INDICATOR = "twilio.ipmsg.typing_indicator";
2031
2228
  static readonly NEW_MESSAGE = "twilio.conversations.new_message";
@@ -2034,4 +2231,4 @@ declare class NotificationTypes {
2034
2231
  static readonly REMOVED_FROM_CONVERSATION = "twilio.conversations.removed_from_conversation";
2035
2232
  static readonly CONSUMPTION_UPDATE = "twilio.channel.consumption_update";
2036
2233
  }
2037
- 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 };
2234
+ export { Conversation, ConversationBindings, ConversationEmailBinding, ConversationUpdateReason, ConversationStatus, NotificationLevel, ConversationState, ConversationUpdatedEventArgs, SendMediaOptions, SendEmailOptions, LastMessage, Participant, ParticipantUpdateReason, ParticipantType, ParticipantUpdatedEventArgs, ParticipantBindings, ParticipantEmailBinding, ParticipantEmailLevel, Message, MessageUpdateReason, MessageType, MessageUpdatedEventArgs, Media, MediaCategory$0 as MediaCategory, AggregatedDeliveryReceipt, DeliveryAmount, DetailedDeliveryReceipt, DeliveryStatus, RestPaginator, MessageBuilder, UnsentMessage, Paginator, ParticipantBindingOptions, User, UserUpdateReason, UserUpdatedEventArgs, PushNotification, PushNotificationType, PushNotificationDescriptor, PushNotificationData, NotificationTypes, Client, State, ConnectionState, NotificationsChannelType, ClientOptions, CreateConversationOptions, ConversationLimits, JSONValue, JSONObject, JSONArray };