@twilio/conversations 3.0.0-rc.9 → 3.0.1-rc.1

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 (158) hide show
  1. package/README.md +38 -28
  2. package/builds/browser.js +4327 -7903
  3. package/builds/browser.js.map +1 -1
  4. package/builds/lib.d.ts +629 -102
  5. package/builds/lib.js +4319 -7904
  6. package/builds/lib.js.map +1 -1
  7. package/builds/twilio-conversations.js +27540 -41958
  8. package/builds/twilio-conversations.min.js +200 -1
  9. package/dist/aggregated-delivery-receipt.js +10 -1
  10. package/dist/aggregated-delivery-receipt.js.map +1 -1
  11. package/dist/channel-metadata-client.js +192 -0
  12. package/dist/channel-metadata-client.js.map +1 -0
  13. package/dist/client.js +75 -123
  14. package/dist/client.js.map +1 -1
  15. package/dist/command-executor.js +81 -20
  16. package/dist/command-executor.js.map +1 -1
  17. package/dist/configuration.js +14 -3
  18. package/dist/configuration.js.map +1 -1
  19. package/dist/content-client.js +184 -0
  20. package/dist/content-client.js.map +1 -0
  21. package/dist/content-template.js +310 -0
  22. package/dist/content-template.js.map +1 -0
  23. package/dist/conversation.js +105 -22
  24. package/dist/conversation.js.map +1 -1
  25. package/dist/data/conversations.js +43 -5
  26. package/dist/data/conversations.js.map +1 -1
  27. package/dist/data/messages.js +26 -19
  28. package/dist/data/messages.js.map +1 -1
  29. package/dist/data/participants.js +15 -4
  30. package/dist/data/participants.js.map +1 -1
  31. package/dist/data/users.js +11 -2
  32. package/dist/data/users.js.map +1 -1
  33. package/dist/detailed-delivery-receipt.js +9 -0
  34. package/dist/detailed-delivery-receipt.js.map +1 -1
  35. package/dist/index.js +20 -2
  36. package/dist/index.js.map +1 -1
  37. package/dist/interfaces/notification-types.js +9 -0
  38. package/dist/interfaces/notification-types.js.map +1 -1
  39. package/dist/interfaces/{attributes.js → rules.js} +26 -7
  40. package/dist/interfaces/rules.js.map +1 -0
  41. package/dist/logger.js +9 -0
  42. package/dist/logger.js.map +1 -1
  43. package/dist/media.js +9 -0
  44. package/dist/media.js.map +1 -1
  45. package/dist/message-builder.js +77 -6
  46. package/dist/message-builder.js.map +1 -1
  47. package/dist/message.js +115 -22
  48. package/dist/message.js.map +1 -1
  49. package/dist/node_modules/quick-lru/index.js +265 -0
  50. package/dist/node_modules/quick-lru/index.js.map +1 -0
  51. package/dist/node_modules/tslib/tslib.es6.js +9 -0
  52. package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
  53. package/dist/packages/conversations/package.json.js +10 -1
  54. package/dist/packages/conversations/package.json.js.map +1 -1
  55. package/dist/participant.js +45 -36
  56. package/dist/participant.js.map +1 -1
  57. package/dist/push-notification.js +9 -0
  58. package/dist/push-notification.js.map +1 -1
  59. package/dist/rest-paginator.js +20 -11
  60. package/dist/rest-paginator.js.map +1 -1
  61. package/dist/services/network.js +110 -11
  62. package/dist/services/network.js.map +1 -1
  63. package/dist/services/typing-indicator.js +22 -5
  64. package/dist/services/typing-indicator.js.map +1 -1
  65. package/dist/unsent-message.js +9 -0
  66. package/dist/unsent-message.js.map +1 -1
  67. package/dist/user.js +20 -3
  68. package/dist/user.js.map +1 -1
  69. package/dist/util/deferred.js +9 -0
  70. package/dist/util/deferred.js.map +1 -1
  71. package/dist/util/index.js +9 -0
  72. package/dist/util/index.js.map +1 -1
  73. package/docs/.nojekyll +1 -0
  74. package/docs/assets/highlight.css +113 -0
  75. package/docs/assets/main.js +58 -0
  76. package/docs/assets/search.js +1 -0
  77. package/docs/assets/style.css +1279 -0
  78. package/docs/classes/AggregatedDeliveryReceipt.html +144 -3182
  79. package/docs/classes/CancellablePromise.html +224 -3209
  80. package/docs/classes/CancellationError.html +112 -0
  81. package/docs/classes/ChannelMetadata.html +67 -0
  82. package/docs/classes/Client.html +701 -4237
  83. package/docs/classes/ContentTemplate.html +97 -0
  84. package/docs/classes/ContentTemplateVariable.html +90 -0
  85. package/docs/classes/Conversation.html +768 -4352
  86. package/docs/classes/DetailedDeliveryReceipt.html +116 -3162
  87. package/docs/classes/Media.html +119 -3165
  88. package/docs/classes/Message.html +417 -3730
  89. package/docs/classes/MessageBuilder.html +208 -3274
  90. package/docs/classes/Participant.html +258 -3442
  91. package/docs/classes/PushNotification.html +101 -3129
  92. package/docs/classes/RestPaginator.html +120 -3158
  93. package/docs/classes/UnsentMessage.html +63 -3040
  94. package/docs/classes/User.html +209 -3347
  95. package/docs/index.html +146 -3502
  96. package/docs/interfaces/ClientOptions.html +66 -3033
  97. package/docs/interfaces/ConversationBindings.html +109 -3000
  98. package/docs/interfaces/ConversationEmailBinding.html +109 -3000
  99. package/docs/interfaces/ConversationLimits.html +87 -3097
  100. package/docs/interfaces/ConversationState.html +66 -3049
  101. package/docs/interfaces/ConversationUpdatedEventArgs.html +109 -3000
  102. package/docs/interfaces/CreateConversationOptions.html +73 -3065
  103. package/docs/interfaces/LastMessage.html +66 -3049
  104. package/docs/interfaces/Paginator.html +110 -3139
  105. package/docs/interfaces/ParticipantBindingOptions.html +110 -0
  106. package/docs/interfaces/ParticipantBindings.html +109 -3000
  107. package/docs/interfaces/ParticipantEmailBinding.html +109 -3000
  108. package/docs/interfaces/PushNotificationData.html +94 -3113
  109. package/docs/interfaces/SendEmailOptions.html +59 -3033
  110. package/docs/interfaces/SendMediaOptions.html +75 -3067
  111. package/docs/modules.html +180 -3509
  112. package/docs/types/ChannelType.html +106 -0
  113. package/docs/types/ConnectionState.html +115 -0
  114. package/docs/types/ContentData.html +106 -0
  115. package/docs/types/ContentDataAction.html +107 -0
  116. package/docs/types/ContentDataActionOther.html +121 -0
  117. package/docs/types/ContentDataActionPhone.html +128 -0
  118. package/docs/types/ContentDataActionReply.html +133 -0
  119. package/docs/types/ContentDataActionUrl.html +128 -0
  120. package/docs/types/ContentDataCallToAction.html +131 -0
  121. package/docs/types/ContentDataCard.html +137 -0
  122. package/docs/types/ContentDataListItem.html +121 -0
  123. package/docs/types/ContentDataListPicker.html +134 -0
  124. package/docs/types/ContentDataLocation.html +134 -0
  125. package/docs/types/ContentDataMedia.html +129 -0
  126. package/docs/types/ContentDataOther.html +121 -0
  127. package/docs/types/ContentDataQuickReply.html +131 -0
  128. package/docs/types/ContentDataReply.html +119 -0
  129. package/docs/types/ContentDataText.html +125 -0
  130. package/docs/types/ConversationStatus.html +107 -0
  131. package/docs/types/ConversationUpdateReason.html +106 -0
  132. package/docs/types/DeliveryAmount.html +106 -0
  133. package/docs/types/DeliveryStatus.html +106 -0
  134. package/docs/types/JSONArray.html +106 -0
  135. package/docs/types/JSONObject.html +111 -0
  136. package/docs/types/JSONValue.html +106 -0
  137. package/docs/types/LogLevel.html +106 -0
  138. package/docs/types/MediaCategory.html +106 -0
  139. package/docs/types/MessageType.html +106 -0
  140. package/docs/types/MessageUpdateReason.html +106 -0
  141. package/docs/types/NotificationLevel.html +109 -0
  142. package/docs/types/NotificationsChannelType.html +110 -0
  143. package/docs/types/ParticipantEmailLevel.html +108 -0
  144. package/docs/types/ParticipantType.html +107 -0
  145. package/docs/types/ParticipantUpdateReason.html +106 -0
  146. package/docs/types/PushNotificationType.html +106 -0
  147. package/docs/types/State.html +110 -0
  148. package/docs/types/UserUpdateReason.html +106 -0
  149. package/package.json +22 -17
  150. package/CHANGELOG.md +0 -509
  151. package/dist/interfaces/attributes.js.map +0 -1
  152. package/docs/assets/css/main.css +0 -2660
  153. package/docs/assets/images/icons.png +0 -0
  154. package/docs/assets/images/icons@2x.png +0 -0
  155. package/docs/assets/images/widgets.png +0 -0
  156. package/docs/assets/images/widgets@2x.png +0 -0
  157. package/docs/assets/js/main.js +0 -248
  158. package/docs/assets/js/search.js +0 -1
package/builds/lib.d.ts CHANGED
@@ -1,12 +1,13 @@
1
+ /// <reference types="node" />
1
2
  import { SyncClient, SyncDocument, SyncList } from "twilio-sync";
2
3
  import { LogLevelDesc } from "loglevel";
3
- import { Transport, TwilsockClient, InitRegistration, ConnectionError, TransportResult } from "twilsock";
4
- import { ConnectionState as TwilsockConnectionState } from "twilsock";
4
+ import { TwilsockClient } from "twilsock";
5
5
  import { ReplayEventEmitter } from "@twilio/replay-event-emitter";
6
+ import { JSONValue, CancellationError } from "@twilio/shared";
7
+ import { CancellablePromise as CancellablePromise$0 } from "@twilio/shared";
6
8
  import { ChannelType, Notifications } from "@twilio/notifications";
7
9
  import { Notifications as NotificationClient } from "@twilio/notifications";
8
10
  import { CancellablePromise, McsClient, MediaCategory, McsMedia } from "@twilio/mcs-client";
9
- import { MediaCategory as McsMediaCategory } from "@twilio/mcs-client";
10
11
  interface ConfigurationResponse {
11
12
  options: {
12
13
  consumption_report_interval: string;
@@ -109,10 +110,11 @@ declare class Configuration {
109
110
  readonly userIdentity: string;
110
111
  readonly userInfo: string;
111
112
  readonly myConversations: string;
113
+ readonly channelMetadataCacheCapacity: number;
112
114
  constructor(options: ClientOptions, configurationResponse: ConfigurationResponse, logger: Logger);
113
115
  }
114
116
  interface CommandExecutorServices {
115
- transport: Transport;
117
+ transport: TwilsockClient;
116
118
  }
117
119
  declare class CommandExecutor {
118
120
  private _serviceUrl;
@@ -121,23 +123,9 @@ declare class CommandExecutor {
121
123
  constructor(_serviceUrl: string, _services: CommandExecutorServices, _productId?: string);
122
124
  private _preProcessUrl;
123
125
  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>;
126
+ fetchResource<Request = void, Response = void>(url: string, requestBody?: Request): Promise<Response>;
127
+ mutateResource<Request = void, Response = void>(method: "post" | "delete", url: string, requestBody?: Request): Promise<Response>;
126
128
  }
127
- /**
128
- * Represents a JSON value.
129
- */
130
- type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
131
- /**
132
- * Represents a JSON object.
133
- */
134
- type JSONObject = {
135
- [x: string]: JSONValue;
136
- };
137
- /**
138
- * Represents a JSON array.
139
- */
140
- type JSONArray = JSONValue[];
141
129
  type UserEvents = {
142
130
  updated: (data: {
143
131
  user: User;
@@ -264,12 +252,16 @@ declare class Network {
264
252
  private cacheLifetime;
265
253
  private readonly cache;
266
254
  private timer;
255
+ private pendingRequests;
256
+ private isShutdownInitiated;
267
257
  constructor(configuration: any, services: any);
268
258
  private isExpired;
269
259
  private cleanupCache;
270
260
  pokeTimer(): void;
261
+ private static responsePostProcess;
271
262
  private executeWithRetry;
272
- get<T>(url: string): Promise<TransportResult<T>>;
263
+ get(url: string): Promise<any>;
264
+ disconnect(): Promise<void>;
273
265
  }
274
266
  type UsersEvents = {
275
267
  userUpdated: (data: {
@@ -343,9 +335,10 @@ interface ParticipantLinks {
343
335
  */
344
336
  type ParticipantUpdateReason = "attributes" | "dateCreated" | "dateUpdated" | "roleSid" | "lastReadMessageIndex" | "lastReadTimestamp" | "bindings";
345
337
  /**
346
- * Type of a participant.
338
+ * Participant type. The string variant can be used to denote new types of
339
+ * participant that aren't supported by this version of the SDK.
347
340
  */
348
- type ParticipantType = "chat" | "sms" | "whatsapp" | "email";
341
+ type ParticipantType = "chat" | "sms" | "whatsapp" | "email" | string;
349
342
  interface ParticipantUpdatedEventArgs {
350
343
  participant: Participant;
351
344
  updateReasons: ParticipantUpdateReason[];
@@ -428,7 +421,7 @@ declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
428
421
  * using the type dynamically `participant.bindings[participant.type]`
429
422
  * just be aware that the binding information has different structure for
430
423
  * each participant type.
431
- * See also {ParticipantEmailBinding}, the only available currently binding descriptor.
424
+ * See also {@link ParticipantEmailBinding}, the only available currently binding descriptor.
432
425
  */
433
426
  get bindings(): ParticipantBindings;
434
427
  /**
@@ -490,19 +483,15 @@ declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
490
483
  */
491
484
  updateAttributes(attributes: JSONValue): Promise<Participant>;
492
485
  }
486
+ /**
487
+ * Participant binding options
488
+ */
493
489
  interface ParticipantBindingOptions {
494
490
  email?: ParticipantEmailBinding;
495
491
  }
496
- /**
497
- * Category of media. Possible values are as follows:
498
- * * `'media'`
499
- * * `'body'`
500
- * * `'history'`
501
- */
502
- type MediaCategory$0 = McsMediaCategory;
503
492
  interface MediaState {
504
493
  sid: string;
505
- category: MediaCategory$0;
494
+ category: MediaCategory;
506
495
  filename: string | null;
507
496
  contentType: string;
508
497
  size: number;
@@ -540,7 +529,7 @@ declare class Media {
540
529
  /**
541
530
  * Media category, can be one of the {@link MediaCategory} values.
542
531
  */
543
- get category(): MediaCategory$0;
532
+ get category(): MediaCategory;
544
533
  /**
545
534
  * Returns the direct content URL for the media.
546
535
  *
@@ -567,7 +556,7 @@ interface AggregatedDeliveryDescriptor {
567
556
  * Contains aggregated information about delivery statuses of a message across all participants
568
557
  * of a conversation.
569
558
  *
570
- * At any moment during the message delivery to a participant, the message can have zero or more of following
559
+ * At any moment during the message delivery to a participant, the message can have zero or more of the following
571
560
  * delivery statuses:
572
561
  * * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
573
562
  * * Message is considered as **delivered** to a participant if Twilio has received confirmation of message
@@ -693,6 +682,499 @@ declare class DetailedDeliveryReceipt {
693
682
  */
694
683
  constructor(descriptor: DetailedDeliveryReceiptDescriptor);
695
684
  }
685
+ type ContentDataActionResponse = Readonly<{
686
+ type: string;
687
+ title: string;
688
+ id?: string;
689
+ url?: string;
690
+ phone?: string;
691
+ index?: number;
692
+ }>;
693
+ type ContentDataTextResponse = Readonly<{
694
+ body: string;
695
+ }>;
696
+ type ContentDataMediaResponse = Readonly<{
697
+ body?: string;
698
+ media: string[];
699
+ }>;
700
+ type ContentDataLocationResponse = Readonly<{
701
+ longitude: number;
702
+ latitude: number;
703
+ label?: string;
704
+ }>;
705
+ type ContentDataQuickReplyResponse = Readonly<{
706
+ body: string;
707
+ actions: Readonly<{
708
+ title: string;
709
+ id?: string;
710
+ }>[];
711
+ }>;
712
+ type ContentDataCallToActionResponse = Readonly<{
713
+ body: string;
714
+ actions: ContentDataActionResponse[];
715
+ }>;
716
+ type ContentDataListPickerResponse = Readonly<{
717
+ body: string;
718
+ button: string;
719
+ items: Readonly<{
720
+ id: string;
721
+ item: string;
722
+ description?: string;
723
+ }>[];
724
+ }>;
725
+ type ContentDataCardResponse = Readonly<{
726
+ title: string;
727
+ subtitle?: string;
728
+ media?: string[];
729
+ actions?: ContentDataActionResponse[];
730
+ }>;
731
+ type ContentDataResponse = Readonly<{
732
+ "twilio/text"?: ContentDataTextResponse;
733
+ "twilio/media"?: ContentDataMediaResponse;
734
+ "twilio/location"?: ContentDataLocationResponse;
735
+ "twilio/quick-reply"?: ContentDataQuickReplyResponse;
736
+ "twilio/call-to-action"?: ContentDataCallToActionResponse;
737
+ "twilio/list-picker"?: ContentDataListPickerResponse;
738
+ "twilio/card"?: ContentDataCardResponse;
739
+ }>;
740
+ type ContentTemplateResponse = Readonly<{
741
+ sid: string;
742
+ account_sid: string;
743
+ friendly_name: string;
744
+ variables: string;
745
+ variants: ContentDataResponse;
746
+ date_created: string;
747
+ date_updated: string;
748
+ }>;
749
+ /**
750
+ * Shows a button that sends back a predefined text. Used in
751
+ * {@link ContentDataQuickReply}.
752
+ */
753
+ type ContentDataReply = {
754
+ /**
755
+ * Display value of the action. This is the message that will be sent back
756
+ * when the user taps on the button.
757
+ */
758
+ readonly title: string;
759
+ /**
760
+ * Postback payload. This field is not visible to the end user.
761
+ */
762
+ readonly id?: string;
763
+ };
764
+ /**
765
+ * Shows a button that redirects recipient to a predefined URL.
766
+ */
767
+ type ContentDataActionUrl = {
768
+ /**
769
+ * The type discriminant.
770
+ */
771
+ readonly type: "url";
772
+ /**
773
+ * Display value for the action.
774
+ */
775
+ readonly title: string;
776
+ /**
777
+ * URL to direct to when the recipient taps the button.
778
+ */
779
+ readonly url: string;
780
+ /**
781
+ * Full data as a stringified JSON. This could be used for future content
782
+ * types and fields which are not yet supported by the newest version of
783
+ * the Conversations SDK, or for using newer types in the older versions of
784
+ * the SDK.
785
+ */
786
+ readonly rawData: string;
787
+ };
788
+ /**
789
+ * Shows a button that calls a phone number.
790
+ */
791
+ type ContentDataActionPhone = {
792
+ /**
793
+ * The type discriminant.
794
+ */
795
+ readonly type: "phone";
796
+ /**
797
+ * Display value for the action.
798
+ */
799
+ readonly title: string;
800
+ /**
801
+ * Phone number to call when the recipient taps the button.
802
+ */
803
+ readonly phone: string;
804
+ /**
805
+ * Full data as a stringified JSON. This could be used for future content
806
+ * types and fields which are not yet supported by the newest version of
807
+ * the Conversations SDK, or for using newer types in the older versions of
808
+ * the SDK.
809
+ */
810
+ readonly rawData: string;
811
+ };
812
+ /**
813
+ * Shows a button that sends back a predefined text.
814
+ */
815
+ type ContentDataActionReply = {
816
+ /**
817
+ * The type discriminant.
818
+ */
819
+ readonly type: "reply";
820
+ /**
821
+ * Display value for the action. This is the message that will be sent back
822
+ * when the user taps on the button.
823
+ */
824
+ readonly title: string;
825
+ /**
826
+ * Postback payload. This field is not visible to the end user.
827
+ */
828
+ readonly id?: string;
829
+ /**
830
+ * Index for the action.
831
+ */
832
+ readonly index: number;
833
+ /**
834
+ * Full data as a stringified JSON. This could be used for future content
835
+ * types and fields which are not yet supported by the newest version of
836
+ * the Conversations SDK, or for using newer types in the older versions of
837
+ * the SDK.
838
+ */
839
+ readonly rawData: string;
840
+ };
841
+ /**
842
+ * Used for unknown action types which aren't present in the current version of
843
+ * the Conversations SDK.
844
+ */
845
+ type ContentDataActionOther = {
846
+ /**
847
+ * The type discriminant.
848
+ */
849
+ readonly type: "other";
850
+ /**
851
+ * Full data as a stringified JSON. This could be used for future content
852
+ * types and fields which are not yet supported by the newest version of
853
+ * the Conversations SDK, or for using newer types in the older versions of
854
+ * the SDK.
855
+ */
856
+ readonly rawData: string;
857
+ };
858
+ /**
859
+ * A union of possible actions used in {@link ContentDataCallToAction} and
860
+ * {@link ContentDataCard}.
861
+ */
862
+ type ContentDataAction = ContentDataActionUrl | ContentDataActionPhone | ContentDataActionReply | ContentDataActionOther;
863
+ /**
864
+ * Represents an item in the {@link ContentDataListPicker}.
865
+ */
866
+ type ContentDataListItem = {
867
+ /**
868
+ * Unique item identifier. Not visible to the recipient.
869
+ */
870
+ readonly id: string;
871
+ /**
872
+ * Display value of the item.
873
+ */
874
+ readonly item: string;
875
+ /**
876
+ * Description of the item.
877
+ */
878
+ readonly description?: string;
879
+ };
880
+ /**
881
+ * Contains only the plain text-based content. Represents the twilio/text
882
+ * content type.
883
+ */
884
+ type ContentDataText = {
885
+ /**
886
+ * The type discriminant.
887
+ */
888
+ readonly type: "text";
889
+ /**
890
+ * The text of the message you want to send.
891
+ */
892
+ readonly body: string;
893
+ /**
894
+ * Full data as a stringified JSON. This could be used for future content
895
+ * types and fields which are not yet supported by the newest version of
896
+ * the Conversations SDK, or for using newer types in the older versions of
897
+ * the SDK.
898
+ */
899
+ readonly rawData: string;
900
+ };
901
+ /**
902
+ * Used to send file attachments, or to send long texts via MMS in the US and
903
+ * Canada. Represents the twilio/media content type.
904
+ */
905
+ type ContentDataMedia = {
906
+ /**
907
+ * The type discriminant.
908
+ */
909
+ readonly type: "media";
910
+ /**
911
+ * The text of the message you want to send.
912
+ */
913
+ readonly body?: string;
914
+ /**
915
+ * URLs of the media you want to send.
916
+ */
917
+ readonly media: string[];
918
+ /**
919
+ * Full data as a stringified JSON. This could be used for future content
920
+ * types and fields which are not yet supported by the newest version of
921
+ * the Conversations SDK, or for using newer types in the older versions of
922
+ * the SDK.
923
+ */
924
+ readonly rawData: string;
925
+ };
926
+ /**
927
+ * Contains a location pin and an optional label, which can be used to enhance
928
+ * delivery notifications or connect recipients to physical experiences you
929
+ * offer. Represents the twilio/location content type.
930
+ */
931
+ type ContentDataLocation = {
932
+ /**
933
+ * The type discriminant.
934
+ */
935
+ readonly type: "location";
936
+ /**
937
+ * The longitude value of the location pin you want to send.
938
+ */
939
+ readonly longitude: number;
940
+ /**
941
+ * The latitude value of the location pin you want to send.
942
+ */
943
+ readonly latitude: number;
944
+ /**
945
+ * The label to be displayed to the end user alongside the location pin.
946
+ */
947
+ readonly label?: 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
+ * Let recipients tap, rather than type, to respond to the message. Represents
958
+ * the twilio/quick-reply content type.
959
+ */
960
+ type ContentDataQuickReply = {
961
+ /**
962
+ * The type discriminant.
963
+ */
964
+ readonly type: "quickReply";
965
+ /**
966
+ * The text of the message you want to send. This is included as a regular
967
+ * text message.
968
+ */
969
+ readonly body: string;
970
+ /**
971
+ * Up to 3 buttons can be created for quick reply. See
972
+ * {@link ContentDataReply}.
973
+ */
974
+ readonly replies: ContentDataReply[];
975
+ /**
976
+ * Full data as a stringified JSON. This could be used for future content
977
+ * types and fields which are not yet supported by the newest version of
978
+ * the Conversations SDK, or for using newer types in the older versions of
979
+ * the SDK.
980
+ */
981
+ readonly rawData: string;
982
+ };
983
+ /**
984
+ * Buttons that let recipients tap to trigger actions such as launching a
985
+ * website or making a phone call. Represents the twilio/call-to-action content
986
+ * type.
987
+ */
988
+ type ContentDataCallToAction = {
989
+ /**
990
+ * The type discriminant.
991
+ */
992
+ readonly type: "callToAction";
993
+ /**
994
+ * The text of the message you want to send. This is included as a regular
995
+ * text message.
996
+ */
997
+ readonly body: string;
998
+ /**
999
+ * Buttons that recipients can tap on to act on the message.
1000
+ */
1001
+ readonly actions: ContentDataAction[];
1002
+ /**
1003
+ * Full data as a stringified JSON. This could be used for future content
1004
+ * types and fields which are not yet supported by the newest version of
1005
+ * the Conversations SDK, or for using newer types in the older versions of
1006
+ * the SDK.
1007
+ */
1008
+ readonly rawData: string;
1009
+ };
1010
+ /**
1011
+ * Shows a menu of up to 10 options, which offers a simple way for users to make
1012
+ * a selection. Represents the twilio/list-picker content type.
1013
+ */
1014
+ type ContentDataListPicker = {
1015
+ /**
1016
+ * The type discriminant.
1017
+ */
1018
+ readonly type: "listPicker";
1019
+ /**
1020
+ * The text of the message you want to send. This is rendered as the body of
1021
+ * the message.
1022
+ */
1023
+ readonly body: string;
1024
+ /**
1025
+ * Display value of the primary button.
1026
+ */
1027
+ readonly button: string;
1028
+ /**
1029
+ * List item objects displayed in the list. See {@link ContentDataListItem}.
1030
+ */
1031
+ readonly items: ContentDataListItem[];
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/card content type.
1043
+ */
1044
+ type ContentDataCard = {
1045
+ /**
1046
+ * The type discriminant.
1047
+ */
1048
+ readonly type: "card";
1049
+ /**
1050
+ * Title of the card.
1051
+ */
1052
+ readonly title: string;
1053
+ /**
1054
+ * Subtitle of the card.
1055
+ */
1056
+ readonly subtitle?: string;
1057
+ /**
1058
+ * URLs of the media to send with the message.
1059
+ */
1060
+ readonly media: string[];
1061
+ /**
1062
+ * Buttons that the recipients can tap on to act on the message.
1063
+ */
1064
+ readonly actions: ContentDataAction[];
1065
+ /**
1066
+ * Full data as a stringified JSON. This could be used for future content
1067
+ * types and fields which are not yet supported by the newest version of
1068
+ * the Conversations SDK, or for using newer types in the older versions of
1069
+ * the SDK.
1070
+ */
1071
+ readonly rawData: string;
1072
+ };
1073
+ /**
1074
+ * Used for unknown content types which aren't present in the current version of
1075
+ * the Conversations SDK.
1076
+ */
1077
+ type ContentDataOther = {
1078
+ /**
1079
+ * The type discriminant.
1080
+ */
1081
+ readonly type: "other";
1082
+ /**
1083
+ * Full data as a stringified JSON. This could be used for future content
1084
+ * types and fields which are not yet supported by the newest version of
1085
+ * the Conversations SDK, or for using newer types in the older versions of
1086
+ * the SDK.
1087
+ */
1088
+ readonly rawData: string;
1089
+ };
1090
+ /**
1091
+ * A union of possible data types in rich content templates.
1092
+ */
1093
+ type ContentData = ContentDataText | ContentDataMedia | ContentDataLocation | ContentDataQuickReply | ContentDataCallToAction | ContentDataListPicker | ContentDataCard | ContentDataOther;
1094
+ /**
1095
+ * Represents a variable for a content template. See
1096
+ * {@link ContentTemplate.variables}.
1097
+ */
1098
+ declare class ContentTemplateVariable {
1099
+ readonly name: string;
1100
+ readonly value: string;
1101
+ constructor(/**
1102
+ * Name of the variable.
1103
+ */
1104
+ name: string, /**
1105
+ * Key of the variable
1106
+ */
1107
+ value: string);
1108
+ /**
1109
+ * Copies the variable with a new value.
1110
+ *
1111
+ * @param value The new value for the variable.
1112
+ */
1113
+ copyWithValue(value: string): ContentTemplateVariable;
1114
+ }
1115
+ /**
1116
+ * A rich content template.
1117
+ *
1118
+ * Use {@link Client.getContentTemplates} to request all the templates available
1119
+ * for the current account.
1120
+ */
1121
+ declare class ContentTemplate {
1122
+ /**
1123
+ * The server-assigned unique identifier for the template.
1124
+ */
1125
+ readonly sid: string;
1126
+ /**
1127
+ * Friendly name used to describe the content. Not visible to the recipient.
1128
+ */
1129
+ readonly friendlyName: string;
1130
+ /**
1131
+ * Variables used by this template.
1132
+ */
1133
+ readonly variables: ContentTemplateVariable[];
1134
+ /**
1135
+ * Variants of the content. See {@link ContentData}.
1136
+ */
1137
+ readonly variants: Map<string, ContentData>;
1138
+ /**
1139
+ * Date of creation.
1140
+ */
1141
+ readonly dateCreated: Date;
1142
+ /**
1143
+ * Date of the last update.
1144
+ */
1145
+ readonly dateUpdated: Date;
1146
+ /**
1147
+ * @internal
1148
+ */
1149
+ constructor(contentTemplateResponse: ContentTemplateResponse);
1150
+ }
1151
+ type ChannelMetadataClientServices = {
1152
+ commandExecutor: CommandExecutor;
1153
+ };
1154
+ /**
1155
+ * Represents channel metadata.
1156
+ */
1157
+ declare class ChannelMetadata {
1158
+ /**
1159
+ * Communication channel type.
1160
+ */
1161
+ readonly type: string;
1162
+ /**
1163
+ * The actual metadata.
1164
+ */
1165
+ readonly data: unknown;
1166
+ /**
1167
+ * @internal
1168
+ */
1169
+ constructor(type: string, data: unknown);
1170
+ }
1171
+ declare class ChannelMetadataClient {
1172
+ private readonly _services;
1173
+ private readonly _configuration;
1174
+ private readonly _cache;
1175
+ constructor(services: ChannelMetadataClientServices, configuration: Configuration);
1176
+ getChannelMetadata(conversationSid: string, messageSid: string): Promise<ChannelMetadata | null>;
1177
+ }
696
1178
  type MessageEvents = {
697
1179
  updated: (data: {
698
1180
  message: Message;
@@ -703,6 +1185,7 @@ interface MessageServices {
703
1185
  mcsClient: McsClient;
704
1186
  network: Network;
705
1187
  commandExecutor: CommandExecutor;
1188
+ channelMetadataClient: ChannelMetadataClient;
706
1189
  }
707
1190
  interface MessageLinks {
708
1191
  self: string;
@@ -727,14 +1210,16 @@ interface MessageData {
727
1210
  type?: MessageType;
728
1211
  author: string | null;
729
1212
  subject: string | null;
1213
+ contentSid: string | null;
730
1214
  lastUpdatedBy?: string | null;
731
1215
  attributes?: JSONValue;
732
1216
  dateUpdated: string;
733
1217
  timestamp?: string;
734
- medias?: Media[];
735
- media?: Media;
1218
+ medias: MediaState[] | null;
1219
+ media: MediaState | null;
736
1220
  memberSid?: string;
737
1221
  delivery?: AggregatedDeliveryDescriptor;
1222
+ channelMetadata?: boolean;
738
1223
  }
739
1224
  /**
740
1225
  * A message in a conversation.
@@ -773,6 +1258,10 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
773
1258
  * Message subject. Used only in email conversations.
774
1259
  */
775
1260
  get subject(): string | null;
1261
+ /**
1262
+ * Unique identifier of {@link ContentTemplate} for this message.
1263
+ */
1264
+ get contentSid(): string | null;
776
1265
  /**
777
1266
  * Body of the message.
778
1267
  */
@@ -782,14 +1271,15 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
782
1271
  */
783
1272
  get dateUpdated(): Date | null;
784
1273
  /**
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,
1274
+ * Index of this message in the conversation's list of messages.
1275
+ *
1276
+ * By design, the message indices may have arbitrary gaps between them,
787
1277
  * that does not necessarily mean they were deleted or otherwise modified - just that
788
1278
  * messages may have some non-contiguous indices even if they are being sent immediately one after another.
789
1279
  *
790
1280
  * Trying to use indices for some calculations is going to be unreliable.
791
1281
  *
792
- * To calculate the number of unread messages it is better to use the read horizon API.
1282
+ * To calculate the number of unread messages, it is better to use the Read Horizon API.
793
1283
  * See {@link Conversation.getUnreadMessagesCount} for details.
794
1284
  */
795
1285
  get index(): number;
@@ -809,11 +1299,6 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
809
1299
  * Type of the message.
810
1300
  */
811
1301
  get type(): MessageType;
812
- /**
813
- * One of the attached media (if present).
814
- * @deprecated Use attachedMedia instead. Note that the latter is now an array.
815
- */
816
- get media(): Media | null;
817
1302
  /**
818
1303
  * Return all media attachments, except email body/history attachments, without temporary urls.
819
1304
  */
@@ -883,6 +1368,16 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
883
1368
  */
884
1369
  getTemporaryContentUrlsForAttachedMedia(): CancellablePromise<Map<string, string>>;
885
1370
  private _getDetailedDeliveryReceiptsPaginator;
1371
+ /**
1372
+ * Get the {@link ContentData} for this message. Resolves to `null` when
1373
+ * {@link Message.contentSid} is null.
1374
+ */
1375
+ getContentData(): CancellablePromise<ContentData | null>;
1376
+ /**
1377
+ * Get the {@link ChannelMetadata} for this message. Resolves to `null` if
1378
+ * the message doesn't have any channel metadata.
1379
+ */
1380
+ getChannelMetadata(): Promise<ChannelMetadata | null>;
886
1381
  }
887
1382
  /**
888
1383
  * Pagination helper interface.
@@ -1018,12 +1513,14 @@ interface MessageResponse {
1018
1513
  participant_sid: string;
1019
1514
  body: string;
1020
1515
  subject: string;
1516
+ content_sid: string;
1021
1517
  date_created: string;
1022
1518
  date_updated: string;
1023
1519
  url: string;
1024
1520
  media: {
1025
1521
  sid: string;
1026
1522
  size: string;
1523
+ category: string;
1027
1524
  content_type: string;
1028
1525
  filename: string;
1029
1526
  }[] | null;
@@ -1045,6 +1542,7 @@ interface MessagesServices {
1045
1542
  network: Network;
1046
1543
  syncClient: SyncClient;
1047
1544
  commandExecutor: CommandExecutor;
1545
+ channelMetadataClient: ChannelMetadataClient;
1048
1546
  }
1049
1547
  /**
1050
1548
  * Represents the collection of messages in a conversation
@@ -1058,9 +1556,10 @@ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
1058
1556
  constructor(conversation: Conversation, configuration: Configuration, services: MessagesServices);
1059
1557
  /**
1060
1558
  * Subscribe to the Messages Event Stream
1061
- * @param name - The name of Sync object for the Messages resource.
1559
+ * @param arg - Name of the Sync object, or the SyncList itself, that
1560
+ * represents the Messages resource.
1062
1561
  */
1063
- subscribe(name: string): Promise<SyncList>;
1562
+ subscribe(arg: string | SyncList): Promise<SyncList>;
1064
1563
  unsubscribe(): Promise<void>;
1065
1564
  /**
1066
1565
  * Send a message to the conversation. The message could include text and multiple media attachments.
@@ -1092,7 +1591,7 @@ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
1092
1591
  */
1093
1592
  getMessages(pageSize: number | undefined, anchor: number | "end" | undefined, direction?: "forward" | "backwards"): Promise<SyncPaginator<Message>>;
1094
1593
  private _wrapPaginator;
1095
- private _upsertMessage;
1594
+ _upsertMessage(index: number, value: MessageData): Message;
1096
1595
  /**
1097
1596
  * Returns last messages from conversation
1098
1597
  * @param {Number} [pageSize] Number of messages to return in single chunk. By default it's 30.
@@ -1115,6 +1614,8 @@ declare class UnsentMessage {
1115
1614
  FormData | SendMediaOptions
1116
1615
  ][];
1117
1616
  emailOptions: SendEmailOptions;
1617
+ contentSid?: string;
1618
+ contentVariables?: ContentTemplateVariable[];
1118
1619
  /**
1119
1620
  * @internal
1120
1621
  */
@@ -1176,6 +1677,21 @@ declare class MessageBuilder {
1176
1677
  * @param history History payload in the selected format.
1177
1678
  */
1178
1679
  setEmailHistory(contentType: string, history: FormData | SendMediaOptions): MessageBuilder;
1680
+ /**
1681
+ * Adds {@link ContentTemplate} SID for the message alongside optional
1682
+ * variables. When no variables provided, the default values will be used.
1683
+ *
1684
+ * Adding the content SID converts the message to a rich message. In this
1685
+ * case, other fields are ignored and the message is sent using the content
1686
+ * from the the {@link ContentTemplate}.
1687
+ *
1688
+ * Use {@link Client.getContentTemplates} to request all available
1689
+ * {@link ContentTemplate}s.
1690
+ *
1691
+ * @param contentSid SID of the {@link ContentTemplate}
1692
+ * @param variables Custom variables to resolve the template.
1693
+ */
1694
+ setContentTemplate(contentSid: string, contentVariables?: ContentTemplateVariable[]): MessageBuilder;
1179
1695
  /**
1180
1696
  * Adds media to the message.
1181
1697
  * @param payload Media to add.
@@ -1189,7 +1705,6 @@ declare class MessageBuilder {
1189
1705
  * Prepares a message and sends it to the conversation.
1190
1706
  */
1191
1707
  buildAndSend(): CancellablePromise<number | null>;
1192
- private getPayloadContentType;
1193
1708
  }
1194
1709
  /**
1195
1710
  * Conversation events.
@@ -1322,6 +1837,7 @@ interface ConversationServices {
1322
1837
  mcsClient: McsClient;
1323
1838
  syncClient: SyncClient;
1324
1839
  commandExecutor: CommandExecutor;
1840
+ channelMetadataClient: ChannelMetadataClient;
1325
1841
  }
1326
1842
  /**
1327
1843
  * Conversation descriptor.
@@ -1489,10 +2005,18 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1489
2005
  * Messages entity.
1490
2006
  */
1491
2007
  private readonly _messagesEntity;
2008
+ /**
2009
+ * Sync list containing messages.
2010
+ */
2011
+ private _messagesList?;
1492
2012
  /**
1493
2013
  * Participants entity.
1494
2014
  */
1495
2015
  private readonly _participantsEntity;
2016
+ /**
2017
+ * Sync map containing participants.
2018
+ */
2019
+ private _participantsMap?;
1496
2020
  /**
1497
2021
  * Source of the most recent update.
1498
2022
  */
@@ -1663,7 +2187,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1663
2187
  */
1664
2188
  getMessagesCount(): Promise<number>;
1665
2189
  /**
1666
- * Get unread messages count for the user if they are a participant of this
2190
+ * Get count of unread messages for the user if they are a participant of this
1667
2191
  * conversation. Rejects if the user is not a participant of the conversation.
1668
2192
  *
1669
2193
  * Use this method to obtain the number of unread messages together with
@@ -1671,12 +2195,19 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1671
2195
  * message indices which may have gaps. See {@link Message.index} for details.
1672
2196
  *
1673
2197
  * 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
2198
+ * correct, but it will also be possibly incorrect for a few seconds. The
1675
2199
  * Conversations system does not provide real time events for counter values
1676
2200
  * changes.
1677
2201
  *
1678
2202
  * This is useful for any UI badges, but it is not recommended to build any
1679
2203
  * core application logic based on these counters being accurate in real time.
2204
+ *
2205
+ * If the read horizon is not set, this function will return null. This could mean
2206
+ * that all messages in the conversation are unread, or that the read horizon system
2207
+ * is not being used. How to interpret this `null` value is up to the customer application.
2208
+ *
2209
+ * @return Number of unread messages based on the current read horizon set for
2210
+ * the user or `null` if the read horizon is not set.
1680
2211
  */
1681
2212
  getUnreadMessagesCount(): Promise<number | null>;
1682
2213
  /**
@@ -1702,10 +2233,10 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1702
2233
  * @param emailOptions Email options for the message.
1703
2234
  * @return Index of the new message.
1704
2235
  */
1705
- sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<number>;
2236
+ sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<Message>;
1706
2237
  /**
1707
2238
  * New interface to prepare for sending a message.
1708
- * Use this instead of {@link Message.sendMessage}.
2239
+ * Use this instead of {@link Conversation.sendMessage}.
1709
2240
  * @return A MessageBuilder to help set all message sending options.
1710
2241
  */
1711
2242
  prepareMessage(): MessageBuilder;
@@ -1717,7 +2248,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1717
2248
  setAllMessagesRead(): Promise<number>;
1718
2249
  /**
1719
2250
  * Set all messages in the conversation unread.
1720
- * @return Resulting unread messages count in the conversation.
2251
+ * @returns New count of unread messages after this update.
1721
2252
  */
1722
2253
  setAllMessagesUnread(): Promise<number>;
1723
2254
  /**
@@ -1746,7 +2277,7 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1746
2277
  * Set the last read message index to the current read horizon.
1747
2278
  * @param index Message index to set as last read. If null is provided, then
1748
2279
  * the behavior is identical to {@link Conversation.setAllMessagesUnread}.
1749
- * @returns Resulting unread messages count in the conversation.
2280
+ * @returns New count of unread messages after this update.
1750
2281
  */
1751
2282
  updateLastReadMessageIndex(index: number | null): Promise<number>;
1752
2283
  /**
@@ -1762,6 +2293,16 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1762
2293
  * @internal
1763
2294
  */
1764
2295
  _subscribe(): Promise<SyncDocument>;
2296
+ /**
2297
+ * Fetch participants and messages of the conversation. This method needs to
2298
+ * be called during conversation initialization to catch broken conversations
2299
+ * (broken conversations are conversations that have essential Sync entities
2300
+ * missing, i.e. the conversation document, the messages list or the
2301
+ * participant map). In case of this conversation being broken, the method
2302
+ * will throw an exception that will be caught and handled gracefully.
2303
+ * @internal
2304
+ */
2305
+ _fetchStreams(): Promise<void>;
1765
2306
  /**
1766
2307
  * Load the attributes of this conversation and instantiate its participants
1767
2308
  * and messages. This or _subscribe will need to be called before any events
@@ -1799,6 +2340,9 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
1799
2340
  private _setLastReadMessageIndex;
1800
2341
  }
1801
2342
  type ConversationsDataSource = "sync" | "rest";
2343
+ /**
2344
+ * Type of a push notification.
2345
+ */
1802
2346
  type PushNotificationType = "twilio.conversations.new_message" | "twilio.conversations.added_to_conversation" | "twilio.conversations.removed_from_conversation";
1803
2347
  interface PushNotificationDescriptor {
1804
2348
  title: string | null;
@@ -1910,11 +2454,11 @@ type ClientEvents = {
1910
2454
  user: User;
1911
2455
  updateReasons: UserUpdateReason[];
1912
2456
  }) => void;
1913
- stateChanged: ({ state, error }: {
1914
- state: State;
2457
+ initialized: () => void;
2458
+ initFailed: ({ error }: {
1915
2459
  error?: ConnectionError;
1916
2460
  }) => void;
1917
- connectionStateChanged: (state: TwilsockConnectionState) => void;
2461
+ connectionStateChanged: (state: ConnectionState) => void;
1918
2462
  connectionError: (data: ConnectionError) => void;
1919
2463
  };
1920
2464
  /**
@@ -1927,7 +2471,7 @@ type ClientEvents = {
1927
2471
  * * `'denied'` - client connection is denied because of invalid JWT access
1928
2472
  * token. User must refresh token in order to proceed
1929
2473
  */
1930
- type ConnectionState = TwilsockConnectionState;
2474
+ type ConnectionState = "disconnected" | "connecting" | "connected";
1931
2475
  /**
1932
2476
  * State of the client. Possible values are as follows:
1933
2477
  * * `'failed'` - the client failed to initialize
@@ -1952,10 +2496,14 @@ interface ClientOptions {
1952
2496
  * The level of logging to enable.
1953
2497
  */
1954
2498
  logLevel?: LogLevel;
2499
+ /**
2500
+ * The cache capacity for channel metadata.
2501
+ */
2502
+ channelMetadataCacheCapacity?: number;
1955
2503
  region?: string;
1956
2504
  productId?: string;
1957
2505
  twilsockClient?: TwilsockClient;
1958
- transport?: Transport;
2506
+ transport?: TwilsockClient;
1959
2507
  notificationsClient?: NotificationClient;
1960
2508
  syncClient?: SyncClient;
1961
2509
  typingIndicatorTimeoutOverride?: number;
@@ -1970,11 +2518,14 @@ interface ClientOptions {
1970
2518
  Notification?: Record<string, unknown>;
1971
2519
  Twilsock?: Record<string, unknown>;
1972
2520
  clientMetadata?: Record<string, unknown>;
1973
- initRegistrations?: InitRegistration[];
1974
2521
  disableDeepClone?: boolean;
1975
2522
  typingUri?: string;
1976
2523
  apiUri?: string;
1977
2524
  }
2525
+ type ConnectionError = {
2526
+ terminal: boolean;
2527
+ message: string;
2528
+ };
1978
2529
  /**
1979
2530
  * Options for {@link Client.createConversation}.
1980
2531
  */
@@ -2167,16 +2718,20 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2167
2718
  */
2168
2719
  static readonly userUpdated = "userUpdated";
2169
2720
  /**
2170
- * Fired when the state of the client has been changed.
2721
+ * Fired when the client has completed initialization successfully.
2722
+ * @event
2723
+ */
2724
+ static readonly initialized = "initialized";
2725
+ /**
2726
+ * Fired when the client initialization failed.
2171
2727
  *
2172
2728
  * Parameters:
2173
2729
  * 1. object `data` - info object provided with the event. It has the
2174
- * following properties:
2175
- * * {@link State} `state` - the new client state
2730
+ * following property:
2176
2731
  * * Error? `error` - the initialization error if present
2177
2732
  * @event
2178
2733
  */
2179
- static readonly stateChanged = "stateChanged";
2734
+ static readonly initFailed = "initFailed";
2180
2735
  /**
2181
2736
  * Fired when the connection state of the client has been changed.
2182
2737
  *
@@ -2221,7 +2776,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2221
2776
  /**
2222
2777
  * Client connection state.
2223
2778
  */
2224
- connectionState: ConnectionState;
2779
+ connectionState: ConnectionState | "unknown";
2225
2780
  /**
2226
2781
  * Promise that resolves on successful initialization.
2227
2782
  */
@@ -2285,26 +2840,6 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2285
2840
  * initialization was completed.
2286
2841
  */
2287
2842
  get reachabilityEnabled(): boolean;
2288
- /**
2289
- * @deprecated Call constructor directly.
2290
- *
2291
- * Factory method to create a Conversations client instance.
2292
- *
2293
- * The factory method will automatically trigger connection.
2294
- * Do not use it if you need finer-grained control.
2295
- *
2296
- * Since this method returns an already-initialized client, some of the events
2297
- * will be lost because they happen *before* the initialization. It is
2298
- * recommended that `client.onWithReplay` is used as opposed to `client.on`
2299
- * for subscribing to client events. The `client.onWithReplay` will re-emit
2300
- * the most recent value for a given event if it emitted before the
2301
- * subscription.
2302
- *
2303
- * @param token Access token.
2304
- * @param options Options to customize the client.
2305
- * @returns Returns a fully initialized client.
2306
- */
2307
- static create(token: string, options?: ClientOptions | null): Promise<Client>;
2308
2843
  /**
2309
2844
  * Static method for push notification payload parsing. Returns parsed push as
2310
2845
  * a {@link PushNotification} object.
@@ -2316,11 +2851,6 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2316
2851
  * @param data Data to parse
2317
2852
  */
2318
2853
  private static _parsePushNotificationChatData;
2319
- /**
2320
- * Populate the client with init registrations.
2321
- * @param reg The init registration to populate.
2322
- */
2323
- static populateInitRegistrations(reg: InitRegistration): void;
2324
2854
  /**
2325
2855
  * Gracefully shut down the client.
2326
2856
  */
@@ -2363,12 +2893,6 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2363
2893
  * on the platform.
2364
2894
  */
2365
2895
  setPushRegistrationId(channelType: NotificationsChannelType, registrationId: string): Promise<void>;
2366
- /**
2367
- * Unregister from push notifications.
2368
- * @param channelType Channel type.
2369
- * @deprecated Use removePushRegistrations() instead.
2370
- */
2371
- unsetPushRegistrationId(channelType: NotificationsChannelType): Promise<void>;
2372
2896
  /**
2373
2897
  * Clear existing registrations directly using provided device token.
2374
2898
  * This is useful to ensure stopped subscriptions without resubscribing.
@@ -2417,6 +2941,11 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2417
2941
  * @param contentSet Set of media attachments to query content URLs.
2418
2942
  */
2419
2943
  getTemporaryContentUrlsForMedia(contentSet: Media[]): CancellablePromise<Map<string, string>>;
2944
+ /**
2945
+ * Returns rich content templates belonging to the account. Rich content
2946
+ * templates can be created via the Twilio console or the REST API.
2947
+ */
2948
+ getContentTemplates(): Promise<Readonly<ContentTemplate[]>>;
2420
2949
  /**
2421
2950
  * Initialize the client.
2422
2951
  */
@@ -2426,11 +2955,6 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
2426
2955
  * @param channelType The channel type to subscribe to.
2427
2956
  */
2428
2957
  private _subscribeToPushNotifications;
2429
- /**
2430
- * Unsubscribe from push notifications.
2431
- * @param channelType The channel type to unsubscribe from.
2432
- */
2433
- private _unsubscribeFromPushNotifications;
2434
2958
  }
2435
2959
  declare class NotificationTypes {
2436
2960
  static readonly TYPING_INDICATOR = "twilio.ipmsg.typing_indicator";
@@ -2440,4 +2964,7 @@ declare class NotificationTypes {
2440
2964
  static readonly REMOVED_FROM_CONVERSATION = "twilio.conversations.removed_from_conversation";
2441
2965
  static readonly CONSUMPTION_UPDATE = "twilio.channel.consumption_update";
2442
2966
  }
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 };
2967
+ export { Conversation, ConversationBindings, ConversationEmailBinding, ConversationUpdateReason, ConversationStatus, NotificationLevel, ConversationState, ConversationUpdatedEventArgs, SendMediaOptions, SendEmailOptions, LastMessage, Participant, ParticipantUpdateReason, ParticipantType, ParticipantUpdatedEventArgs, ParticipantBindings, ParticipantEmailBinding, ParticipantEmailLevel, Message, MessageUpdateReason, MessageType, MessageUpdatedEventArgs, Media, AggregatedDeliveryReceipt, DeliveryAmount, DetailedDeliveryReceipt, DeliveryStatus, RestPaginator, MessageBuilder, UnsentMessage, Paginator, ParticipantBindingOptions, User, UserUpdateReason, UserUpdatedEventArgs, PushNotification, PushNotificationType, PushNotificationDescriptor, PushNotificationData, NotificationTypes, Client, State, ConnectionState, NotificationsChannelType, ClientOptions, CreateConversationOptions, ConversationLimits, CancellablePromise$0 as CancellablePromise, CancellationError, ContentDataActionUrl, ContentDataActionPhone, ContentDataActionReply, ContentDataActionOther, ContentDataAction, ContentDataText, ContentDataMedia, ContentDataLocation, ContentDataReply, ContentDataQuickReply, ContentDataCallToAction, ContentDataListPicker, ContentDataListItem, ContentDataCard, ContentDataOther, ContentData, ContentTemplate, ContentTemplateVariable, ChannelMetadata, LogLevel };
2968
+ export { JSONValue, JSONObject, JSONArray } from "@twilio/shared";
2969
+ export { MediaCategory } from "@twilio/mcs-client";
2970
+ export { ChannelType } from "@twilio/notifications";