@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
package/builds/lib.d.ts CHANGED
@@ -1,12 +1,11 @@
1
1
  import { SyncClient, SyncDocument, SyncList } from "twilio-sync";
2
2
  import { LogLevelDesc } from "loglevel";
3
- import { Transport, TwilsockClient, InitRegistration, ConnectionError, TransportResult } from "twilsock";
3
+ import { Transport, TwilsockClient, InitRegistration, TransportResult } from "twilsock";
4
4
  import { ConnectionState as TwilsockConnectionState } from "twilsock";
5
5
  import { ReplayEventEmitter } from "@twilio/replay-event-emitter";
6
6
  import { ChannelType, Notifications } from "@twilio/notifications";
7
7
  import { Notifications as NotificationClient } from "@twilio/notifications";
8
- import { CancellablePromise, McsClient, MediaCategory, McsMedia } from "@twilio/mcs-client";
9
- import { MediaCategory as McsMediaCategory } from "@twilio/mcs-client";
8
+ import { CancellablePromise, McsClient, MediaCategory, McsMedia, McsMediaCategory, McsMediaState } from "@twilio/mcs-client";
10
9
  interface ConfigurationResponse {
11
10
  options: {
12
11
  consumption_report_interval: string;
@@ -109,6 +108,8 @@ declare class Configuration {
109
108
  readonly userIdentity: string;
110
109
  readonly userInfo: string;
111
110
  readonly myConversations: string;
111
+ readonly channelMetadataCacheCapacity: number;
112
+ readonly messageRecipientsCacheCapacity: number;
112
113
  constructor(options: ClientOptions, configurationResponse: ConfigurationResponse, logger: Logger);
113
114
  }
114
115
  interface CommandExecutorServices {
@@ -121,8 +122,8 @@ declare class CommandExecutor {
121
122
  constructor(_serviceUrl: string, _services: CommandExecutorServices, _productId?: string);
122
123
  private _preProcessUrl;
123
124
  private _makeRequest;
124
- fetchResource<REQ = void, RESP = void>(url: string, requestBody?: REQ): Promise<RESP>;
125
- mutateResource<REQ = void, RESP = void>(method: "post" | "delete", url: string, requestBody?: REQ): Promise<RESP>;
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>;
126
127
  }
127
128
  /**
128
129
  * Represents a JSON value.
@@ -343,9 +344,10 @@ interface ParticipantLinks {
343
344
  */
344
345
  type ParticipantUpdateReason = "attributes" | "dateCreated" | "dateUpdated" | "roleSid" | "lastReadMessageIndex" | "lastReadTimestamp" | "bindings";
345
346
  /**
346
- * Type of a participant.
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.
347
349
  */
348
- type ParticipantType = "chat" | "sms" | "whatsapp" | "email";
350
+ type ParticipantType = "chat" | "sms" | "whatsapp" | "email" | string;
349
351
  interface ParticipantUpdatedEventArgs {
350
352
  participant: Participant;
351
353
  updateReasons: ParticipantUpdateReason[];
@@ -490,6 +492,26 @@ declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
490
492
  */
491
493
  updateAttributes(attributes: JSONValue): Promise<Participant>;
492
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
+ }
493
515
  interface ParticipantBindingOptions {
494
516
  email?: ParticipantEmailBinding;
495
517
  }
@@ -500,13 +522,6 @@ interface ParticipantBindingOptions {
500
522
  * * `'history'`
501
523
  */
502
524
  type MediaCategory$0 = McsMediaCategory;
503
- interface MediaState {
504
- sid: string;
505
- category: MediaCategory$0;
506
- filename: string | null;
507
- contentType: string;
508
- size: number;
509
- }
510
525
  interface MediaServices {
511
526
  mcsClient: McsClient;
512
527
  }
@@ -520,7 +535,7 @@ declare class Media {
520
535
  /**
521
536
  * @internal
522
537
  */
523
- constructor(data: MediaState | McsMedia, services: MediaServices);
538
+ constructor(data: McsMediaState | McsMedia, services: MediaServices);
524
539
  /**
525
540
  * Server-assigned unique identifier for the media.
526
541
  */
@@ -550,6 +565,10 @@ declare class Media {
550
565
  */
551
566
  getContentTemporaryUrl(): CancellablePromise<string | null>;
552
567
  private _fetchMcsMedia;
568
+ /**
569
+ * @internal
570
+ */
571
+ _state(): McsMediaState;
553
572
  }
554
573
  /**
555
574
  * Signifies the amount of participants which have the status for the message.
@@ -567,7 +586,7 @@ interface AggregatedDeliveryDescriptor {
567
586
  * Contains aggregated information about delivery statuses of a message across all participants
568
587
  * of a conversation.
569
588
  *
570
- * At any moment during the message delivery to a participant, the message can have zero or more of following
589
+ * At any moment during the message delivery to a participant, the message can have zero or more of the following
571
590
  * delivery statuses:
572
591
  * * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
573
592
  * * Message is considered as **delivered** to a participant if Twilio has received confirmation of message
@@ -693,6 +712,611 @@ declare class DetailedDeliveryReceipt {
693
712
  */
694
713
  constructor(descriptor: DetailedDeliveryReceiptDescriptor);
695
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
+ }
696
1320
  type MessageEvents = {
697
1321
  updated: (data: {
698
1322
  message: Message;
@@ -703,6 +1327,8 @@ interface MessageServices {
703
1327
  mcsClient: McsClient;
704
1328
  network: Network;
705
1329
  commandExecutor: CommandExecutor;
1330
+ channelMetadataClient: ChannelMetadataClient;
1331
+ messageRecipientsClient: MessageRecipientsClient;
706
1332
  }
707
1333
  interface MessageLinks {
708
1334
  self: string;
@@ -712,9 +1338,9 @@ interface MessageLinks {
712
1338
  /**
713
1339
  * The reason for the `updated` event being emitted by a message.
714
1340
  */
715
- type MessageUpdateReason = "body" | "lastUpdatedBy" | "dateCreated" | "dateUpdated" | "attributes" | "author" | "deliveryReceipt" | "subject";
1341
+ type MessageUpdateReason = "body" | "lastUpdatedBy" | "dateCreated" | "dateUpdated" | "attributes" | "author" | "deliveryReceipt" | "subject" | "media";
716
1342
  /**
717
- * Type of a message.
1343
+ * Type of message.
718
1344
  */
719
1345
  type MessageType = "text" | "media";
720
1346
  interface MessageUpdatedEventArgs {
@@ -727,6 +1353,7 @@ interface MessageData {
727
1353
  type?: MessageType;
728
1354
  author: string | null;
729
1355
  subject: string | null;
1356
+ contentSid: string | null;
730
1357
  lastUpdatedBy?: string | null;
731
1358
  attributes?: JSONValue;
732
1359
  dateUpdated: string;
@@ -735,11 +1362,13 @@ interface MessageData {
735
1362
  media?: Media;
736
1363
  memberSid?: string;
737
1364
  delivery?: AggregatedDeliveryDescriptor;
1365
+ channelMetadata?: boolean;
738
1366
  }
739
1367
  /**
740
1368
  * A message in a conversation.
741
1369
  */
742
1370
  declare class Message extends ReplayEventEmitter<MessageEvents> {
1371
+ #private;
743
1372
  /**
744
1373
  * Conversation that the message is in.
745
1374
  */
@@ -773,6 +1402,10 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
773
1402
  * Message subject. Used only in email conversations.
774
1403
  */
775
1404
  get subject(): string | null;
1405
+ /**
1406
+ * Unique identifier of {@link ContentTemplate} for this message.
1407
+ */
1408
+ get contentSid(): string | null;
776
1409
  /**
777
1410
  * Body of the message.
778
1411
  */
@@ -782,14 +1415,15 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
782
1415
  */
783
1416
  get dateUpdated(): Date | null;
784
1417
  /**
785
- * Index of the message in the conversation's messages list.
786
- * By design of the Conversations system, the message indices may have arbitrary gaps between them,
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,
787
1421
  * that does not necessarily mean they were deleted or otherwise modified - just that
788
1422
  * messages may have some non-contiguous indices even if they are being sent immediately one after another.
789
1423
  *
790
1424
  * Trying to use indices for some calculations is going to be unreliable.
791
1425
  *
792
- * To calculate the number of unread messages it is better to use the read horizon API.
1426
+ * To calculate the number of unread messages, it is better to use the Read Horizon API.
793
1427
  * See {@link Conversation.getUnreadMessagesCount} for details.
794
1428
  */
795
1429
  get index(): number;
@@ -826,6 +1460,14 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
826
1460
  * Aggregated information about the message delivery statuses across all participants of a conversation..
827
1461
  */
828
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;
829
1471
  /**
830
1472
  * Return a (possibly empty) array of media matching a specific set of categories.
831
1473
  * Allowed category is so far only 'media'.
@@ -868,6 +1510,12 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
868
1510
  * @param attributes New attributes.
869
1511
  */
870
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[]>;
871
1519
  /**
872
1520
  * Get content URLs for all media attachments in the given set using a single operation.
873
1521
  * @param contentSet Set of media attachments to query content URLs.
@@ -883,34 +1531,20 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
883
1531
  */
884
1532
  getTemporaryContentUrlsForAttachedMedia(): CancellablePromise<Map<string, string>>;
885
1533
  private _getDetailedDeliveryReceiptsPaginator;
886
- }
887
- /**
888
- * Pagination helper interface.
889
- * @typeParam T The item type.
890
- */
891
- interface Paginator<T> {
892
- /**
893
- * Indicates the existence of the next page.
894
- */
895
- hasNextPage: boolean;
896
- /**
897
- * Indicates the existence of the previous page.
898
- */
899
- hasPrevPage: boolean;
900
1534
  /**
901
- * Array of elements of type T on the current page.
1535
+ * Get the {@link ContentData} for this message. Resolves to `null` when
1536
+ * {@link Message.contentSid} is null.
902
1537
  */
903
- items: T[];
1538
+ getContentData(): CancellablePromise<ContentData | null>;
904
1539
  /**
905
- * Request next page.
906
- * Does not modify the existing object.
1540
+ * Get the {@link ChannelMetadata} for this message. Resolves to `null` if
1541
+ * the message doesn't have any channel metadata.
907
1542
  */
908
- nextPage(): Promise<Paginator<T>>;
1543
+ getChannelMetadata(): Promise<ChannelMetadata | null>;
909
1544
  /**
910
- * Request previous page.
911
- * Does not modify the existing object.
1545
+ * Get recipients of the message.
912
1546
  */
913
- prevPage(): Promise<Paginator<T>>;
1547
+ getMessageRecipients(): Promise<RecipientDescriptor[]>;
914
1548
  }
915
1549
  interface TypingIndicatorServices {
916
1550
  twilsockClient: TwilsockClient;
@@ -1045,6 +1679,8 @@ interface MessagesServices {
1045
1679
  network: Network;
1046
1680
  syncClient: SyncClient;
1047
1681
  commandExecutor: CommandExecutor;
1682
+ channelMetadataClient: ChannelMetadataClient;
1683
+ messageRecipientsClient: MessageRecipientsClient;
1048
1684
  }
1049
1685
  /**
1050
1686
  * Represents the collection of messages in a conversation
@@ -1058,9 +1694,10 @@ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
1058
1694
  constructor(conversation: Conversation, configuration: Configuration, services: MessagesServices);
1059
1695
  /**
1060
1696
  * Subscribe to the Messages Event Stream
1061
- * @param name - The name of Sync object for the Messages resource.
1697
+ * @param arg - Name of the Sync object, or the SyncList itself, that
1698
+ * represents the Messages resource.
1062
1699
  */
1063
- subscribe(name: string): Promise<SyncList>;
1700
+ subscribe(arg: string | SyncList): Promise<SyncList>;
1064
1701
  unsubscribe(): Promise<void>;
1065
1702
  /**
1066
1703
  * Send a message to the conversation. The message could include text and multiple media attachments.
@@ -1115,6 +1752,8 @@ declare class UnsentMessage {
1115
1752
  FormData | SendMediaOptions
1116
1753
  ][];
1117
1754
  emailOptions: SendEmailOptions;
1755
+ contentSid?: string;
1756
+ contentVariables?: ContentTemplateVariable[];
1118
1757
  /**
1119
1758
  * @internal
1120
1759
  */
@@ -1176,6 +1815,21 @@ declare class MessageBuilder {
1176
1815
  * @param history History payload in the selected format.
1177
1816
  */
1178
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;
1179
1833
  /**
1180
1834
  * Adds media to the message.
1181
1835
  * @param payload Media to add.
@@ -1189,7 +1843,6 @@ declare class MessageBuilder {
1189
1843
  * Prepares a message and sends it to the conversation.
1190
1844
  */
1191
1845
  buildAndSend(): CancellablePromise<number | null>;
1192
- private getPayloadContentType;
1193
1846
  }
1194
1847
  /**
1195
1848
  * Conversation events.
@@ -1322,6 +1975,8 @@ interface ConversationServices {
1322
1975
  mcsClient: McsClient;
1323
1976
  syncClient: SyncClient;
1324
1977
  commandExecutor: CommandExecutor;
1978
+ channelMetadataClient: ChannelMetadataClient;
1979
+ messageRecipientsClient: MessageRecipientsClient;
1325
1980
  }
1326
1981
  /**
1327
1982
  * Conversation descriptor.
@@ -1464,11 +2119,6 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1464
2119
  * @internal
1465
2120
  */
1466
2121
  readonly _links: ConversationLinks;
1467
- /**
1468
- * Map of participants.
1469
- * @internal
1470
- */
1471
- readonly _participants: Map<string, Participant>;
1472
2122
  /**
1473
2123
  * Configuration of the client that the conversation belongs to.
1474
2124
  */
@@ -1489,10 +2139,23 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1489
2139
  * Messages entity.
1490
2140
  */
1491
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>;
1492
2151
  /**
1493
2152
  * Participants entity.
1494
2153
  */
1495
2154
  private readonly _participantsEntity;
2155
+ /**
2156
+ * Sync map containing participants.
2157
+ */
2158
+ private _participantsMap?;
1496
2159
  /**
1497
2160
  * Source of the most recent update.
1498
2161
  */
@@ -1501,6 +2164,10 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1501
2164
  * Promise for the conversation entity document.
1502
2165
  */
1503
2166
  private _entityPromise;
2167
+ /**
2168
+ * Promise for the messages list.
2169
+ */
2170
+ private _streamsPromise;
1504
2171
  /**
1505
2172
  * Conversation entity document.
1506
2173
  */
@@ -1555,7 +2222,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1555
2222
  */
1556
2223
  get notificationLevel(): NotificationLevel;
1557
2224
  /**
1558
- * Conversation bindings. Undocumented feature (for now).
2225
+ * Conversation bindings. An undocumented feature (for now).
1559
2226
  * @internal
1560
2227
  */
1561
2228
  get bindings(): ConversationBindings;
@@ -1584,7 +2251,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1584
2251
  * @param attributes Attributes to be attached to the participant.
1585
2252
  * @returns The added participant.
1586
2253
  */
1587
- add(identity: string, attributes?: JSONValue): Promise<Participant>;
2254
+ add(identity: string, attributes?: JSONValue): Promise<ParticipantResponse>;
1588
2255
  /**
1589
2256
  * Add a non-chat participant to the conversation.
1590
2257
  * @param proxyAddress Proxy (Twilio) address of the participant.
@@ -1594,7 +2261,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1594
2261
  * CC/To level.
1595
2262
  * @returns The added participant.
1596
2263
  */
1597
- addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<Participant>;
2264
+ addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<ParticipantResponse>;
1598
2265
  /**
1599
2266
  * Advance the conversation's last read message index to the current read
1600
2267
  * horizon. Rejects if the user is not a participant of the conversation. Last
@@ -1663,7 +2330,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1663
2330
  */
1664
2331
  getMessagesCount(): Promise<number>;
1665
2332
  /**
1666
- * Get unread messages count for the user if they are a participant of this
2333
+ * Get count of unread messages for the user if they are a participant of this
1667
2334
  * conversation. Rejects if the user is not a participant of the conversation.
1668
2335
  *
1669
2336
  * Use this method to obtain the number of unread messages together with
@@ -1671,12 +2338,19 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1671
2338
  * message indices which may have gaps. See {@link Message.index} for details.
1672
2339
  *
1673
2340
  * This method is semi-realtime. This means that this data will be eventually
1674
- * correct, but will also be possibly incorrect for a few seconds. The
2341
+ * correct, but it will also be possibly incorrect for a few seconds. The
1675
2342
  * Conversations system does not provide real time events for counter values
1676
2343
  * changes.
1677
2344
  *
1678
2345
  * This is useful for any UI badges, but it is not recommended to build any
1679
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.
1680
2354
  */
1681
2355
  getUnreadMessagesCount(): Promise<number | null>;
1682
2356
  /**
@@ -1705,7 +2379,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1705
2379
  sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<number>;
1706
2380
  /**
1707
2381
  * New interface to prepare for sending a message.
1708
- * Use this instead of {@link Message.sendMessage}.
2382
+ * Use this instead of {@link Conversation.sendMessage}.
1709
2383
  * @return A MessageBuilder to help set all message sending options.
1710
2384
  */
1711
2385
  prepareMessage(): MessageBuilder;
@@ -1717,7 +2391,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1717
2391
  setAllMessagesRead(): Promise<number>;
1718
2392
  /**
1719
2393
  * Set all messages in the conversation unread.
1720
- * @return Resulting unread messages count in the conversation.
2394
+ * @returns New count of unread messages after this update.
1721
2395
  */
1722
2396
  setAllMessagesUnread(): Promise<number>;
1723
2397
  /**
@@ -1746,7 +2420,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1746
2420
  * Set the last read message index to the current read horizon.
1747
2421
  * @param index Message index to set as last read. If null is provided, then
1748
2422
  * the behavior is identical to {@link Conversation.setAllMessagesUnread}.
1749
- * @returns Resulting unread messages count in the conversation.
2423
+ * @returns New count of unread messages after this update.
1750
2424
  */
1751
2425
  updateLastReadMessageIndex(index: number | null): Promise<number>;
1752
2426
  /**
@@ -1755,13 +2429,28 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1755
2429
  * to null removes it.
1756
2430
  */
1757
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>>;
1758
2437
  /**
1759
2438
  * Load and subscribe to this conversation and do not subscribe to its
1760
2439
  * participants and messages. This or _subscribeStreams will need to be called
1761
- * before any events on conversation will fire.
2440
+ * before any events in the conversation will fire.
1762
2441
  * @internal
1763
2442
  */
1764
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>;
1765
2454
  /**
1766
2455
  * Load the attributes of this conversation and instantiate its participants
1767
2456
  * and messages. This or _subscribe will need to be called before any events
@@ -1910,8 +2599,9 @@ type ClientEvents = {
1910
2599
  user: User;
1911
2600
  updateReasons: UserUpdateReason[];
1912
2601
  }) => void;
1913
- stateChanged: ({ state, error }: {
1914
- state: State;
2602
+ stateChanged: (state: State) => void;
2603
+ initialized: () => void;
2604
+ initFailed: ({ error }: {
1915
2605
  error?: ConnectionError;
1916
2606
  }) => void;
1917
2607
  connectionStateChanged: (state: TwilsockConnectionState) => void;
@@ -1952,6 +2642,14 @@ interface ClientOptions {
1952
2642
  * The level of logging to enable.
1953
2643
  */
1954
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;
1955
2653
  region?: string;
1956
2654
  productId?: string;
1957
2655
  twilsockClient?: TwilsockClient;
@@ -1974,7 +2672,12 @@ interface ClientOptions {
1974
2672
  disableDeepClone?: boolean;
1975
2673
  typingUri?: string;
1976
2674
  apiUri?: string;
2675
+ throwErrorsAlways?: boolean;
1977
2676
  }
2677
+ type ConnectionError = {
2678
+ terminal: boolean;
2679
+ message: string;
2680
+ };
1978
2681
  /**
1979
2682
  * Options for {@link Client.createConversation}.
1980
2683
  */
@@ -1991,6 +2694,11 @@ interface CreateConversationOptions {
1991
2694
  * A unique identifier of the conversation.
1992
2695
  */
1993
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;
1994
2702
  }
1995
2703
  /**
1996
2704
  * A client is the starting point to the Twilio Conversations functionality.
@@ -2167,16 +2875,29 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2167
2875
  */
2168
2876
  static readonly userUpdated = "userUpdated";
2169
2877
  /**
2878
+ * @deprecated Use initialized or initFailed events instead
2170
2879
  * Fired when the state of the client has been changed.
2171
2880
  *
2172
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:
2173
2895
  * 1. object `data` - info object provided with the event. It has the
2174
- * following properties:
2175
- * * {@link State} `state` - the new client state
2896
+ * following property:
2176
2897
  * * Error? `error` - the initialization error if present
2177
2898
  * @event
2178
2899
  */
2179
- static readonly stateChanged = "stateChanged";
2900
+ static readonly initFailed = "initFailed";
2180
2901
  /**
2181
2902
  * Fired when the connection state of the client has been changed.
2182
2903
  *
@@ -2225,7 +2946,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2225
2946
  /**
2226
2947
  * Promise that resolves on successful initialization.
2227
2948
  */
2228
- private readonly _ensureReady;
2949
+ private _ensureReady;
2229
2950
  /**
2230
2951
  * Options passed to the client.
2231
2952
  */
@@ -2263,7 +2984,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2263
2984
  */
2264
2985
  private _conversationsPromise;
2265
2986
  /**
2266
- * Returned Conversations instance is not yet fully initialized. Calling any
2987
+ * Returned Conversations Client instance is not yet fully initialized. Calling any
2267
2988
  * operations will block until it is. Use connection events to monitor when
2268
2989
  * client becomes fully available (connectionStateChanged with state
2269
2990
  * 'connected') or not available (connectionStateChange with state 'denied',
@@ -2285,6 +3006,12 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2285
3006
  * initialization was completed.
2286
3007
  */
2287
3008
  get reachabilityEnabled(): boolean;
3009
+ /**
3010
+ * @deprecated
3011
+ * Current token.
3012
+ * @internal
3013
+ */
3014
+ get token(): string;
2288
3015
  /**
2289
3016
  * @deprecated Call constructor directly.
2290
3017
  *
@@ -2338,7 +3065,6 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2338
3065
  /**
2339
3066
  * Peek a conversation by its SID.
2340
3067
  * @param conversationSid Conversation sid
2341
- * @internal
2342
3068
  */
2343
3069
  peekConversationBySid(conversationSid: string): Promise<Conversation>;
2344
3070
  /**
@@ -2384,7 +3110,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2384
3110
  */
2385
3111
  removePushRegistrations(channelType: ChannelType, registrationId: string): Promise<void>;
2386
3112
  /**
2387
- * Current version of the Conversations client.
3113
+ * Parse a push notification payload.
2388
3114
  */
2389
3115
  parsePushNotification: typeof Client.parsePushNotification;
2390
3116
  /**
@@ -2417,6 +3143,11 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2417
3143
  * @param contentSet Set of media attachments to query content URLs.
2418
3144
  */
2419
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[]>>;
2420
3151
  /**
2421
3152
  * Initialize the client.
2422
3153
  */
@@ -2431,6 +3162,10 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2431
3162
  * @param channelType The channel type to unsubscribe from.
2432
3163
  */
2433
3164
  private _unsubscribeFromPushNotifications;
3165
+ /**
3166
+ * Initialize the ensureReady promise.
3167
+ */
3168
+ private _initializeEnsureReady;
2434
3169
  }
2435
3170
  declare class NotificationTypes {
2436
3171
  static readonly TYPING_INDICATOR = "twilio.ipmsg.typing_indicator";
@@ -2440,4 +3175,4 @@ declare class NotificationTypes {
2440
3175
  static readonly REMOVED_FROM_CONVERSATION = "twilio.conversations.removed_from_conversation";
2441
3176
  static readonly CONSUMPTION_UPDATE = "twilio.channel.consumption_update";
2442
3177
  }
2443
- 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 };
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 };