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

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 (67) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/NOTICE.txt +679 -0
  3. package/builds/browser.js +676 -587
  4. package/builds/browser.js.map +1 -1
  5. package/builds/lib.d.ts +287 -117
  6. package/builds/lib.js +676 -587
  7. package/builds/lib.js.map +1 -1
  8. package/builds/twilio-conversations.js +854 -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 +130 -81
  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/classes/Client.html +24 -30
  60. package/docs/classes/Conversation.html +30 -30
  61. package/docs/classes/DetailedDeliveryReceipt.html +1 -1
  62. package/docs/classes/Message.html +7 -7
  63. package/docs/classes/MessageBuilder.html +2 -2
  64. package/docs/classes/Participant.html +7 -7
  65. package/docs/classes/User.html +7 -7
  66. package/docs/interfaces/CreateConversationOptions.html +1 -1
  67. 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;
@@ -90,7 +91,7 @@ declare class Configuration {
90
91
  readonly userIdentity: string;
91
92
  readonly userInfo: string;
92
93
  readonly myConversations: string;
93
- constructor(options: Record<string, any>, configurationResponse: ConfigurationResponse, logger: Logger);
94
+ constructor(options: ClientOptions, configurationResponse: ConfigurationResponse, logger: Logger);
94
95
  }
95
96
  interface CommandExecutorServices {
96
97
  transport: Transport;
@@ -105,6 +106,11 @@ declare class CommandExecutor {
105
106
  fetchResource<REQ = void, RESP = void>(url: string, requestBody?: REQ): Promise<RESP>;
106
107
  mutateResource<REQ = void, RESP = void>(method: "post" | "delete", url: string, requestBody?: REQ): Promise<RESP>;
107
108
  }
109
+ type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
110
+ type JSONObject = {
111
+ [x: string]: JSONValue;
112
+ };
113
+ type JSONArray = JSONValue[];
108
114
  type UserEvents = {
109
115
  updated: (data: {
110
116
  user: User;
@@ -180,25 +186,29 @@ declare class User extends ReplayEventEmitter<UserEvents> {
180
186
  /**
181
187
  * Custom attributes of the user.
182
188
  */
183
- get attributes(): any;
189
+ get attributes(): JSONValue;
184
190
  /**
185
191
  * Friendly name of the user, null if not set.
186
192
  */
187
- get friendlyName(): string;
193
+ get friendlyName(): string | null;
188
194
  /**
189
195
  * Status of the real-time conversation connection of the user.
190
196
  */
191
- get isOnline(): boolean;
197
+ get isOnline(): boolean | null;
192
198
  /**
193
199
  * User push notification registration status.
194
200
  */
195
- get isNotifiable(): boolean;
201
+ get isNotifiable(): boolean | null;
196
202
  /**
197
203
  * True if this user is receiving real-time status updates.
198
204
  */
199
205
  get isSubscribed(): boolean;
200
206
  // Handles service updates
201
- _update(key: string, value: any): Promise<void>;
207
+ _update(key: string, value: {
208
+ value: string;
209
+ notifiable: boolean | null;
210
+ online: boolean | null;
211
+ }): Promise<void>;
202
212
  // Fetch reachability info
203
213
  private _updateReachabilityInfo;
204
214
  // Fetch user
@@ -208,7 +218,7 @@ declare class User extends ReplayEventEmitter<UserEvents> {
208
218
  * Edit user attributes.
209
219
  * @param attributes New attributes.
210
220
  */
211
- updateAttributes(attributes: any): Promise<User>;
221
+ updateAttributes(attributes: JSONValue): Promise<User>;
212
222
  /**
213
223
  * Update the friendly name of the user.
214
224
  * @param friendlyName New friendly name.
@@ -232,7 +242,7 @@ declare class Network {
232
242
  private cleanupCache;
233
243
  pokeTimer(): void;
234
244
  private executeWithRetry;
235
- get(url: string): Promise<any>;
245
+ get<T>(url: string): Promise<TransportResult<T>>;
236
246
  }
237
247
  type UsersEvents = {
238
248
  userUpdated: (data: {
@@ -264,7 +274,7 @@ declare class Users extends ReplayEventEmitter<UsersEvents> {
264
274
  * if not - then subscribes and adds user to the FIFO stack
265
275
  * @returns {Promise<User>} Fully initialized user
266
276
  */
267
- getUser(identity: string, entityName?: string): Promise<User>;
277
+ getUser(identity?: string, entityName?: string): Promise<User>;
268
278
  /**
269
279
  * @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}
270
280
  */
@@ -283,16 +293,16 @@ type ParticipantEvents = {
283
293
  }) => void;
284
294
  };
285
295
  interface ParticipantDescriptor {
286
- attributes?: Object;
287
- dateCreated: any;
288
- dateUpdated: any;
296
+ attributes?: JSONValue;
297
+ dateCreated: Date | null;
298
+ dateUpdated: Date | null;
289
299
  identity: string;
290
300
  roleSid?: string;
291
- lastConsumedMessageIndex: number;
301
+ lastConsumedMessageIndex: number | null;
292
302
  lastConsumptionTimestamp: number;
293
303
  type: ParticipantType;
294
304
  userInfo: string;
295
- bindings?: Object;
305
+ bindings?: ParticipantBindings;
296
306
  }
297
307
  interface ParticipantServices {
298
308
  users: Users;
@@ -351,19 +361,19 @@ declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
351
361
  /**
352
362
  * Custom attributes of the participant.
353
363
  */
354
- get attributes(): Object;
364
+ get attributes(): JSONValue;
355
365
  /**
356
366
  * Date this participant was created on.
357
367
  */
358
- get dateCreated(): Date;
368
+ get dateCreated(): Date | null;
359
369
  /**
360
370
  * Date this participant was last updated on.
361
371
  */
362
- get dateUpdated(): Date;
372
+ get dateUpdated(): Date | null;
363
373
  /**
364
374
  * Identity of the participant.
365
375
  */
366
- get identity(): string;
376
+ get identity(): string | null;
367
377
  /**
368
378
  * Indicates whether the participant is currently typing.
369
379
  */
@@ -378,7 +388,7 @@ declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
378
388
  /**
379
389
  * Date of the most recent read horizon update.
380
390
  */
381
- get lastReadTimestamp(): Date;
391
+ get lastReadTimestamp(): Date | null;
382
392
  get roleSid(): string;
383
393
  /**
384
394
  * Type of the participant.
@@ -451,7 +461,27 @@ declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
451
461
  * Update the attributes of the participant.
452
462
  * @param attributes New attributes.
453
463
  */
454
- updateAttributes(attributes: any): Promise<Participant>;
464
+ updateAttributes(attributes: JSONValue): Promise<Participant>;
465
+ }
466
+ interface ParticipantResponse {
467
+ account_sid: string;
468
+ chat_service_sid: string;
469
+ conversation_sid: string;
470
+ role_sid: string;
471
+ sid: string;
472
+ attributes: string;
473
+ date_created: string;
474
+ date_updated: string;
475
+ identity: string | null;
476
+ messaging_binding: {
477
+ type: string;
478
+ address: string;
479
+ proxy_address: string;
480
+ } | null;
481
+ url: string;
482
+ links: {
483
+ conversation: string;
484
+ };
455
485
  }
456
486
  interface ParticipantBindingOptions {
457
487
  email?: ParticipantEmailBinding;
@@ -466,7 +496,7 @@ type MediaCategory$0 = McsMediaCategory;
466
496
  interface MediaState {
467
497
  sid: string;
468
498
  category: MediaCategory$0;
469
- filename?: string;
499
+ filename: string | null;
470
500
  contentType: string;
471
501
  size: number;
472
502
  }
@@ -491,7 +521,7 @@ declare class Media {
491
521
  /**
492
522
  * File name. Null if absent.
493
523
  */
494
- get filename(): string;
524
+ get filename(): string | null;
495
525
  /**
496
526
  * Content type of the media.
497
527
  */
@@ -511,7 +541,7 @@ declare class Media {
511
541
  * If the URL becomes expired, you need to request a new one.
512
542
  * Each call to this function produces a new temporary URL.
513
543
  */
514
- getContentTemporaryUrl(): Promise<string>;
544
+ getContentTemporaryUrl(): Promise<string | null>;
515
545
  /**
516
546
  * Returns cached direct content URL for the media.
517
547
  *
@@ -521,7 +551,7 @@ declare class Media {
521
551
  *
522
552
  * @returns {Promise<String>}
523
553
  */
524
- getCachedTemporaryUrl(): Promise<string>;
554
+ getCachedTemporaryUrl(): Promise<string | null>;
525
555
  private _fetchMcsMedia;
526
556
  }
527
557
  /**
@@ -616,7 +646,7 @@ interface DetailedDeliveryReceiptDescriptor {
616
646
  channel_message_sid: string;
617
647
  participant_sid: string;
618
648
  status: DeliveryStatus;
619
- error_code: number | null;
649
+ error_code: string | null;
620
650
  date_created: string;
621
651
  date_updated: string;
622
652
  }
@@ -652,7 +682,7 @@ declare class DetailedDeliveryReceipt {
652
682
  * Numeric error code mapped from Status callback code. Information about the error codes can be found
653
683
  * [here](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors).
654
684
  */
655
- errorCode: number | null;
685
+ errorCode: string | 0;
656
686
  /**
657
687
  * Date this delivery receipt was created on.
658
688
  */
@@ -694,6 +724,21 @@ interface MessageUpdatedEventArgs {
694
724
  message: Message;
695
725
  updateReasons: MessageUpdateReason[];
696
726
  }
727
+ interface MessageData {
728
+ sid: string;
729
+ text?: string;
730
+ type?: MessageType;
731
+ author: string | null;
732
+ subject: string | null;
733
+ lastUpdatedBy?: string | null;
734
+ attributes?: JSONValue;
735
+ dateUpdated: string;
736
+ timestamp?: string;
737
+ medias?: Media[];
738
+ media?: Media;
739
+ memberSid?: string;
740
+ delivery?: AggregatedDeliveryDescriptor;
741
+ }
697
742
  /**
698
743
  * A message in a conversation.
699
744
  */
@@ -709,7 +754,7 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
709
754
  /**
710
755
  * @internal
711
756
  */
712
- constructor(index: number, data: any, conversation: Conversation, links: MessageLinks, configuration: Configuration, services: MessageServices);
757
+ constructor(index: number, data: MessageData, conversation: Conversation, links: MessageLinks, configuration: Configuration, services: MessageServices);
713
758
  /**
714
759
  * Fired when the properties or the body of the message has been updated.
715
760
  *
@@ -726,7 +771,7 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
726
771
  /**
727
772
  * Name of the user that sent the message.
728
773
  */
729
- get author(): string;
774
+ get author(): string | null;
730
775
  /**
731
776
  * Message subject. Used only in email conversations.
732
777
  */
@@ -734,11 +779,11 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
734
779
  /**
735
780
  * Body of the message.
736
781
  */
737
- get body(): string;
782
+ get body(): string | null;
738
783
  /**
739
784
  * Date this message was last updated on.
740
785
  */
741
- get dateUpdated(): Date;
786
+ get dateUpdated(): Date | null;
742
787
  /**
743
788
  * Index of the message in the conversation's messages list.
744
789
  * By design of the Conversations system, the message indices may have arbitrary gaps between them,
@@ -754,15 +799,15 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
754
799
  /**
755
800
  * Identity of the last user that updated the message.
756
801
  */
757
- get lastUpdatedBy(): string;
802
+ get lastUpdatedBy(): string | null;
758
803
  /**
759
804
  * Date this message was created on.
760
805
  */
761
- get dateCreated(): Date;
806
+ get dateCreated(): Date | null;
762
807
  /**
763
808
  * Custom attributes of the message.
764
809
  */
765
- get attributes(): Object;
810
+ get attributes(): JSONValue;
766
811
  /**
767
812
  * Type of the message.
768
813
  */
@@ -825,12 +870,12 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
825
870
  * Edit the message attributes.
826
871
  * @param attributes New attributes.
827
872
  */
828
- updateAttributes(attributes: any): Promise<Message>;
873
+ updateAttributes(attributes: JSONValue): Promise<Message>;
829
874
  /**
830
875
  * Get content URLs for all media attachments in the given set using single operation.
831
876
  * @param contentSet Set of media attachments to query for content URL.
832
877
  */
833
- attachTemporaryUrlsFor(contentSet: Media[]): Promise<Media[]>;
878
+ attachTemporaryUrlsFor(contentSet: Media[] | null): Promise<Media[]>;
834
879
  private _getDetailedDeliveryReceiptsPaginator;
835
880
  }
836
881
  /**
@@ -912,9 +957,9 @@ declare class TypingIndicator {
912
957
  declare class UnsentMessage {
913
958
  private messagesEntity;
914
959
  text?: string;
915
- attributes: any;
960
+ attributes: JSONValue;
916
961
  mediaContent: [MediaCategory, FormData | SendMediaOptions][];
917
- emailOptions?: SendEmailOptions;
962
+ emailOptions: SendEmailOptions;
918
963
  /**
919
964
  * @internal
920
965
  */
@@ -923,7 +968,154 @@ declare class UnsentMessage {
923
968
  * Send the prepared message to the conversation.
924
969
  * @returns Index of the new message in the conversation.
925
970
  */
926
- send(): Promise<number>;
971
+ send(): Promise<number | null>;
972
+ }
973
+ /**
974
+ * Pagination helper class.
975
+ */
976
+ declare class RestPaginator<T> implements Paginator<T> {
977
+ private state;
978
+ /**
979
+ * Indicates the existence of the next page.
980
+ */
981
+ get hasNextPage(): boolean;
982
+ /**
983
+ * Indicates the existence of the previous page
984
+ */
985
+ get hasPrevPage(): boolean;
986
+ /**
987
+ * Array of elements on the current page.
988
+ */
989
+ get items(): T[];
990
+ /**
991
+ * @internal
992
+ */
993
+ constructor(items: any, source: any, prevToken: any, nextToken: any);
994
+ /**
995
+ * Request the next page. Does not modify the existing object.
996
+ */
997
+ nextPage(): Promise<RestPaginator<T>>;
998
+ /**
999
+ * Request the previous page. Does not modify the existing object.
1000
+ */
1001
+ prevPage(): Promise<RestPaginator<T>>;
1002
+ }
1003
+ /**
1004
+ * @classdesc Pagination helper class for Sync
1005
+ *
1006
+ * @property {Array} items Array of elements on current page
1007
+ * @property {boolean} hasNextPage
1008
+ * @property {boolean} hasPrevPage
1009
+ */
1010
+ declare class SyncPaginator<T> implements Paginator<T> {
1011
+ private state;
1012
+ hasNextPage: boolean;
1013
+ hasPrevPage: boolean;
1014
+ get items(): T[];
1015
+ /**
1016
+ * @param {Array} items Array of element for current page
1017
+ * @param {Object} params
1018
+ */
1019
+ constructor(items: any, pageSize: any, anchor: any, direction: any, source: any);
1020
+ nextPage(): Promise<RestPaginator<T>>;
1021
+ prevPage(): Promise<SyncPaginator<T> | RestPaginator<T>>;
1022
+ }
1023
+ interface MessageResponse {
1024
+ account_sid: string;
1025
+ chat_service_sid: string;
1026
+ conversation_sid: string;
1027
+ sid: string;
1028
+ index: number;
1029
+ attributes: string;
1030
+ author: string;
1031
+ participant_sid: string;
1032
+ body: string;
1033
+ subject: string;
1034
+ date_created: string;
1035
+ date_updated: string;
1036
+ url: string;
1037
+ media: {
1038
+ sid: string;
1039
+ size: string;
1040
+ content_type: string;
1041
+ filename: string;
1042
+ }[] | null;
1043
+ links: {
1044
+ conversation: string;
1045
+ messages_receipts: string;
1046
+ };
1047
+ }
1048
+ type MessagesEvents = {
1049
+ messageAdded: (message: Message) => void;
1050
+ messageRemoved: (message: Message) => void;
1051
+ messageUpdated: (data: {
1052
+ message: Message;
1053
+ updateReasons: MessageUpdateReason[];
1054
+ }) => void;
1055
+ };
1056
+ interface MessagesServices {
1057
+ mcsClient: McsClient;
1058
+ network: Network;
1059
+ syncClient: SyncClient;
1060
+ commandExecutor: CommandExecutor;
1061
+ }
1062
+ /**
1063
+ * Represents the collection of messages in a conversation
1064
+ */
1065
+ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
1066
+ readonly conversation: Conversation;
1067
+ private readonly configuration;
1068
+ private readonly services;
1069
+ private readonly messagesByIndex;
1070
+ private messagesListPromise;
1071
+ constructor(conversation: Conversation, configuration: Configuration, services: MessagesServices);
1072
+ /**
1073
+ * Subscribe to the Messages Event Stream
1074
+ * @param name - The name of Sync object for the Messages resource.
1075
+ */
1076
+ subscribe(name: string): Promise<SyncList>;
1077
+ unsubscribe(): Promise<void>;
1078
+ /**
1079
+ * Send Message to the conversation, message could include both text and multiple media attachments.
1080
+ * @param message Message to post
1081
+ * @returns Returns a promise which can fail
1082
+ */
1083
+ sendV2(message: UnsentMessage): Promise<MessageResponse>;
1084
+ /**
1085
+ * Send Message to the conversation
1086
+ * @param message Message to post
1087
+ * @param attributes Message attributes
1088
+ * @param emailOptions Options that modify E-mail integration behaviors.
1089
+ * @returns Returns promise which can fail
1090
+ */
1091
+ send(message: null | string | FormData | SendMediaOptions, attributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<MessageResponse>;
1092
+ /**
1093
+ * Send Media Message to the conversation
1094
+ * @param mediaContent Media content to post
1095
+ * @param attributes Message attributes
1096
+ * @param emailOptions Email options
1097
+ * @returns Returns promise which can fail
1098
+ */
1099
+ sendMedia(mediaContent: FormData | SendMediaOptions, attributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<MessageResponse>;
1100
+ /**
1101
+ * Returns messages from conversation using paginator interface
1102
+ * @param pageSize Number of messages to return in single chunk. By default it's 30.
1103
+ * @param anchor Most early message id which is already known, or 'end' by default
1104
+ * @param direction Pagination order 'backwards' or 'forward', 'forward' by default
1105
+ * @returns Last page of messages by default
1106
+ */
1107
+ getMessages(pageSize: number | undefined, anchor: number | "end" | undefined, direction?: "forward" | "backwards"): Promise<SyncPaginator<Message>>;
1108
+ private _wrapPaginator;
1109
+ private _upsertMessage;
1110
+ /**
1111
+ * Returns last messages from conversation
1112
+ * @param {Number} [pageSize] Number of messages to return in single chunk. By default it's 30.
1113
+ * @param {String} [anchor] Most early message id which is already known, or 'end' by default
1114
+ * @param {String} [direction] Pagination order 'backwards' or 'forward', or 'forward' by default
1115
+ * @returns {Promise<SyncPaginator<Message>>} last page of messages by default
1116
+ * @private
1117
+ */
1118
+ private _getMessages;
927
1119
  }
928
1120
  /**
929
1121
  * Message builder. Allows the message to be built and sent via method chaining.
@@ -948,7 +1140,7 @@ declare class MessageBuilder {
948
1140
  /**
949
1141
  * @internal
950
1142
  */
951
- constructor(limits: Limits, messagesEntity: any);
1143
+ constructor(limits: Limits, messagesEntity: Messages);
952
1144
  /**
953
1145
  * Sets the message body.
954
1146
  * @param text Contents of the body.
@@ -963,7 +1155,7 @@ declare class MessageBuilder {
963
1155
  * Sets the message attributes.
964
1156
  * @param attributes Message attributes.
965
1157
  */
966
- setAttributes(attributes: any): MessageBuilder;
1158
+ setAttributes(attributes: JSONValue): MessageBuilder;
967
1159
  /**
968
1160
  * Set email body with given MIME-type.
969
1161
  * @param mimeType Format of the body to set (text/plain or text/html).
@@ -1020,12 +1212,12 @@ interface ConversationDescriptor {
1020
1212
  channel: string;
1021
1213
  entityName: string;
1022
1214
  uniqueName: string;
1023
- attributes: any;
1215
+ attributes: JSONValue;
1024
1216
  createdBy?: string;
1025
1217
  friendlyName?: string;
1026
1218
  lastConsumedMessageIndex: number;
1027
- dateCreated: any;
1028
- dateUpdated: any;
1219
+ dateCreated: Date | null;
1220
+ dateUpdated: Date | null;
1029
1221
  notificationLevel?: NotificationLevel;
1030
1222
  bindings?: ConversationBindings;
1031
1223
  }
@@ -1073,6 +1265,7 @@ interface ConversationUpdatedEventArgs {
1073
1265
  */
1074
1266
  interface ConversationBindings {
1075
1267
  email?: ConversationEmailBinding;
1268
+ sms?: ConversationSmsBinding;
1076
1269
  }
1077
1270
  /**
1078
1271
  * Binding for email conversation.
@@ -1081,6 +1274,9 @@ interface ConversationEmailBinding {
1081
1274
  name?: string;
1082
1275
  projected_address: string;
1083
1276
  }
1277
+ interface ConversationSmsBinding {
1278
+ address?: string;
1279
+ }
1084
1280
  /**
1085
1281
  * Configuration for attaching a media file to a message.
1086
1282
  * These options can be passed to {@link Conversation.sendMessage} and
@@ -1090,7 +1286,7 @@ interface SendMediaOptions {
1090
1286
  /**
1091
1287
  * Content type of media.
1092
1288
  */
1093
- contentType: string;
1289
+ contentType: null | string;
1094
1290
  /**
1095
1291
  * Optional filename.
1096
1292
  */
@@ -1098,7 +1294,7 @@ interface SendMediaOptions {
1098
1294
  /**
1099
1295
  * Content to post.
1100
1296
  */
1101
- media: string | Buffer | Blob;
1297
+ media: null | string | Buffer | Blob;
1102
1298
  }
1103
1299
  /**
1104
1300
  * These options can be passed to {@link Conversation.sendMessage}.
@@ -1234,7 +1430,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1234
1430
  /**
1235
1431
  * Unique name of the conversation.
1236
1432
  */
1237
- get uniqueName(): string;
1433
+ get uniqueName(): string | null;
1238
1434
  /**
1239
1435
  * Status of the conversation.
1240
1436
  */
@@ -1242,15 +1438,15 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1242
1438
  /**
1243
1439
  * Name of the conversation.
1244
1440
  */
1245
- get friendlyName(): string;
1441
+ get friendlyName(): string | null;
1246
1442
  /**
1247
1443
  * Date this conversation was last updated on.
1248
1444
  */
1249
- get dateUpdated(): any;
1445
+ get dateUpdated(): Date | null;
1250
1446
  /**
1251
1447
  * Date this conversation was created on.
1252
1448
  */
1253
- get dateCreated(): any;
1449
+ get dateCreated(): Date | null;
1254
1450
  /**
1255
1451
  * Identity of the user that created this conversation.
1256
1452
  */
@@ -1258,7 +1454,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1258
1454
  /**
1259
1455
  * Custom attributes of the conversation.
1260
1456
  */
1261
- get attributes(): any;
1457
+ get attributes(): JSONValue;
1262
1458
  /**
1263
1459
  * Index of the last message the user has read in this conversation.
1264
1460
  */
@@ -1266,7 +1462,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1266
1462
  /**
1267
1463
  * Last message sent to this conversation.
1268
1464
  */
1269
- get lastMessage(): LastMessage;
1465
+ get lastMessage(): LastMessage | undefined;
1270
1466
  /**
1271
1467
  * User notification level for this conversation.
1272
1468
  */
@@ -1282,7 +1478,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1282
1478
  * This or _subscribeStreams will need to be called before any events on conversation will fire.
1283
1479
  * @internal
1284
1480
  */
1285
- _subscribe(): Promise<any>;
1481
+ _subscribe(): Promise<void | SyncDocument>;
1286
1482
  /**
1287
1483
  * Load the attributes of this conversation and instantiate its participants and messages.
1288
1484
  * This or _subscribe will need to be called before any events on the conversation will fire.
@@ -1296,7 +1492,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1296
1492
  */
1297
1493
  _unsubscribe(): Promise<[
1298
1494
  void,
1299
- any
1495
+ void
1300
1496
  ]>;
1301
1497
  /**
1302
1498
  * Set conversation status.
@@ -1324,7 +1520,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1324
1520
  * @param identity Identity of the Client to add.
1325
1521
  * @param attributes Attributes to be attached to the participant.
1326
1522
  */
1327
- add(identity: string, attributes?: any): Promise<void>;
1523
+ add(identity: string, attributes?: JSONValue): Promise<ParticipantResponse>;
1328
1524
  /**
1329
1525
  * Add a non-chat participant to the conversation.
1330
1526
  * @param proxyAddress Proxy (Twilio) address of the participant.
@@ -1332,7 +1528,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1332
1528
  * @param attributes Attributes to be attached to the participant.
1333
1529
  * @param bindingOptions Options for adding email participants - name and CC/To level.
1334
1530
  */
1335
- addNonChatParticipant(proxyAddress: string, address: string, attributes?: Record<string, any>, bindingOptions?: ParticipantBindingOptions): Promise<void>;
1531
+ addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<ParticipantResponse>;
1336
1532
  /**
1337
1533
  * Advance the conversation's last read message index to the current read horizon.
1338
1534
  * Rejects if the user is not a participant of the conversation.
@@ -1348,7 +1544,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1348
1544
  /**
1349
1545
  * Get the custom attributes of this Conversation.
1350
1546
  */
1351
- getAttributes(): Promise<any>;
1547
+ getAttributes(): Promise<JSONValue>;
1352
1548
  /**
1353
1549
  * Returns messages from the conversation using the paginator interface.
1354
1550
  * @param pageSize Number of messages to return in a single chunk. Default is 30.
@@ -1377,12 +1573,12 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1377
1573
  * Get a participant by its SID.
1378
1574
  * @param participantSid Participant SID.
1379
1575
  */
1380
- getParticipantBySid(participantSid: string): Promise<Participant>;
1576
+ getParticipantBySid(participantSid: string): Promise<Participant | null>;
1381
1577
  /**
1382
1578
  * Get a participant by its identity.
1383
1579
  * @param identity Participant identity.
1384
1580
  */
1385
- getParticipantByIdentity(identity: string): Promise<Participant>;
1581
+ getParticipantByIdentity(identity?: string | null): Promise<Participant | null>;
1386
1582
  /**
1387
1583
  * Get the total message count in the conversation.
1388
1584
  *
@@ -1423,6 +1619,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1423
1619
  * argument, it will assume that the string is an identity or SID.
1424
1620
  * @param participant Identity, SID or the participant object to remove.
1425
1621
  */
1622
+ /* eslint-disable @typescript-eslint/ban-ts-comment */
1623
+ // @ts-ignore TODO: fix validateTypesAsync typing
1426
1624
  removeParticipant(participant: string | Participant): Promise<void>;
1427
1625
  /**
1428
1626
  * Send a message to the conversation.
@@ -1432,7 +1630,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1432
1630
  * @param emailOptions Email options for the message.
1433
1631
  * @return Index of the new message.
1434
1632
  */
1435
- sendMessage(message: string | FormData | SendMediaOptions | null, messageAttributes?: any, emailOptions?: SendEmailOptions): Promise<number>;
1633
+ sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<number>;
1436
1634
  /**
1437
1635
  * New interface to prepare for sending a message.
1438
1636
  * Use instead of `sendMessage`.
@@ -1463,7 +1661,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1463
1661
  * Update the attributes of the conversation.
1464
1662
  * @param attributes New attributes.
1465
1663
  */
1466
- updateAttributes(attributes: any): Promise<Conversation>;
1664
+ updateAttributes(attributes: JSONValue): Promise<Conversation>;
1467
1665
  /**
1468
1666
  * Update the friendly name of the conversation.
1469
1667
  * @param friendlyName New friendly name.
@@ -1488,13 +1686,13 @@ type ConversationsDataSource = "sync" | "chat" | "rest";
1488
1686
  */
1489
1687
  type PushNotificationType = "twilio.conversations.new_message" | "twilio.conversations.added_to_conversation" | "twilio.conversations.removed_from_conversation";
1490
1688
  interface PushNotificationDescriptor {
1491
- title: string;
1492
- body: string;
1493
- sound: string;
1494
- badge: number;
1495
- action: string;
1689
+ title: string | null;
1690
+ body: string | null;
1691
+ sound: string | null;
1692
+ badge: number | null;
1693
+ action: string | null;
1496
1694
  type: PushNotificationType;
1497
- data: Object;
1695
+ data: Record<string, unknown>;
1498
1696
  }
1499
1697
  /**
1500
1698
  * Additional data for a given push notification.
@@ -1520,23 +1718,23 @@ declare class PushNotification {
1520
1718
  /**
1521
1719
  * Title of the notification.
1522
1720
  */
1523
- readonly title: string;
1721
+ readonly title: string | null;
1524
1722
  /**
1525
1723
  * Text of the notification.
1526
1724
  */
1527
- readonly body: string;
1725
+ readonly body: string | null;
1528
1726
  /**
1529
1727
  * Sound of the notification.
1530
1728
  */
1531
- readonly sound: string;
1729
+ readonly sound: string | null;
1532
1730
  /**
1533
1731
  * Number of the badge.
1534
1732
  */
1535
- readonly badge: number;
1733
+ readonly badge: number | null;
1536
1734
  /**
1537
1735
  * Notification action (`click_action` in FCM terms and `category` in APN terms).
1538
1736
  */
1539
- readonly action: string;
1737
+ readonly action: string | null;
1540
1738
  /**
1541
1739
  * Type of the notification.
1542
1740
  */
@@ -1612,7 +1810,7 @@ type State = "failed" | "initialized";
1612
1810
  * * `'apn'`
1613
1811
  */
1614
1812
  type NotificationsChannelType = ChannelType;
1615
- type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent" | null;
1813
+ type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent";
1616
1814
  /**
1617
1815
  * Conversations client options.
1618
1816
  */
@@ -1632,15 +1830,17 @@ interface ClientOptions {
1632
1830
  httpCacheIntervalOverride?: string;
1633
1831
  userInfosToSubscribeOverride?: number;
1634
1832
  retryWhenThrottledOverride?: boolean;
1635
- backoffConfigOverride?: any;
1636
- Chat?: any;
1637
- IPMessaging?: any;
1638
- Sync?: any;
1639
- Notification?: any;
1640
- Twilsock?: any;
1641
- clientMetadata?: any;
1833
+ backoffConfigOverride?: Record<string, unknown>;
1834
+ Chat?: ClientOptions;
1835
+ IPMessaging?: ClientOptions;
1836
+ Sync?: Record<string, unknown>;
1837
+ Notification?: Record<string, unknown>;
1838
+ Twilsock?: Record<string, unknown>;
1839
+ clientMetadata?: Record<string, unknown>;
1642
1840
  initRegistrations?: InitRegistration[];
1643
1841
  disableDeepClone?: boolean;
1842
+ typingUri?: string;
1843
+ apiUri?: string;
1644
1844
  }
1645
1845
  /**
1646
1846
  * Options for {@link Client.createConversation}.
@@ -1649,7 +1849,7 @@ interface CreateConversationOptions {
1649
1849
  /**
1650
1850
  * Any custom attributes to attach to the conversation.
1651
1851
  */
1652
- attributes?: any;
1852
+ attributes?: JSONValue;
1653
1853
  /**
1654
1854
  * A non-unique display name of the conversation.
1655
1855
  */
@@ -1696,7 +1896,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
1696
1896
  * @param options Options to customize the Client
1697
1897
  * @returns A not yet fully-initialized client.
1698
1898
  */
1699
- constructor(fpaToken: string, options?: ClientOptions);
1899
+ constructor(fpaToken: string, options?: ClientOptions | null);
1700
1900
  static populateInitRegistrations(reg: InitRegistration): void;
1701
1901
  /**
1702
1902
  * Fired when a conversation becomes visible to the client. The event is also triggered when the client creates a new conversation.
@@ -1904,7 +2104,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
1904
2104
  * @param options Options to customize the client.
1905
2105
  * @returns Returns a fully initialized client.
1906
2106
  */
1907
- static create(token: string, options?: ClientOptions): Promise<Client>;
2107
+ static create(token: string, options?: ClientOptions | null): Promise<Client>;
1908
2108
  /**
1909
2109
  * Information of the logged-in user. Before client initialization, returns an
1910
2110
  * uninitialized user. Will trigger a {@link Client.userUpdated} event after
@@ -1942,7 +2142,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
1942
2142
  /**
1943
2143
  * Get the current list of all the subscribed conversations.
1944
2144
  */
1945
- getSubscribedConversations(args?: any): Promise<Paginator<Conversation>>;
2145
+ getSubscribedConversations(): Promise<Paginator<Conversation>>;
1946
2146
  /**
1947
2147
  * Create a conversation on the server and subscribe to its events.
1948
2148
  * The default is a conversation with an empty friendly name.
@@ -1996,36 +2196,6 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
1996
2196
  */
1997
2197
  getSubscribedUsers(): Promise<Array<User>>;
1998
2198
  }
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
2199
  declare class NotificationTypes {
2030
2200
  static readonly TYPING_INDICATOR = "twilio.ipmsg.typing_indicator";
2031
2201
  static readonly NEW_MESSAGE = "twilio.conversations.new_message";