@twilio/conversations 2.1.0-rc.8 → 3.0.0-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.
- package/CHANGELOG.md +24 -0
- package/builds/browser.js +1197 -690
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +251 -130
- package/builds/lib.js +1197 -690
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +1979 -1272
- package/builds/twilio-conversations.min.js +2 -2
- package/dist/client.js +403 -279
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js +2 -2
- package/dist/configuration.js.map +1 -1
- package/dist/conversation.js +3 -0
- package/dist/conversation.js.map +1 -1
- package/dist/data/messages.js +39 -19
- package/dist/data/messages.js.map +1 -1
- package/dist/media.js +36 -25
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js +24 -18
- package/dist/message-builder.js.map +1 -1
- package/dist/message.js +46 -19
- package/dist/message.js.map +1 -1
- package/dist/packages/conversations/package.json.js +1 -1
- package/dist/unsent-message.js +13 -3
- package/dist/unsent-message.js.map +1 -1
- package/docs/assets/js/search.js +1 -1
- package/docs/classes/Client.html +205 -33
- package/docs/classes/Conversation.html +23 -0
- package/docs/classes/Media.html +2 -28
- package/docs/classes/Message.html +94 -39
- package/docs/classes/MessageBuilder.html +31 -8
- package/docs/classes/UnsentMessage.html +2 -2
- package/docs/index.html +4 -2
- package/docs/interfaces/ConversationLimits.html +12 -12
- package/docs/modules.html +4 -2
- package/package.json +9 -8
package/builds/lib.d.ts
CHANGED
@@ -5,7 +5,7 @@ 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 { McsClient, MediaCategory, McsMedia } from "@twilio/mcs-client";
|
8
|
+
import { CancellablePromise, McsClient, MediaCategory, McsMedia } from "@twilio/mcs-client";
|
9
9
|
import { MediaCategory as McsMediaCategory } from "@twilio/mcs-client";
|
10
10
|
interface ConfigurationResponse {
|
11
11
|
options: {
|
@@ -72,13 +72,13 @@ interface ConversationLimits {
|
|
72
72
|
*/
|
73
73
|
mediaAttachmentsTotalSizeLimitInMb: number;
|
74
74
|
/**
|
75
|
-
* Allowed
|
75
|
+
* Allowed content types for E-Mail histories.
|
76
76
|
*/
|
77
|
-
|
77
|
+
emailHistoriesAllowedContentTypes: string[];
|
78
78
|
/**
|
79
|
-
* Allowed
|
79
|
+
* Allowed content types for E-Mail bodies.
|
80
80
|
*/
|
81
|
-
|
81
|
+
emailBodiesAllowedContentTypes: string[];
|
82
82
|
}
|
83
83
|
interface BackoffConfiguration {
|
84
84
|
min: number;
|
@@ -568,17 +568,7 @@ declare class Media {
|
|
568
568
|
* If the URL becomes expired, you need to request a new one.
|
569
569
|
* Each call to this function produces a new temporary URL.
|
570
570
|
*/
|
571
|
-
getContentTemporaryUrl():
|
572
|
-
/**
|
573
|
-
* Returns cached direct content URL for the media.
|
574
|
-
*
|
575
|
-
* This URL will expire in several minutes. This function does not refresh the URL and can be used to query it several times
|
576
|
-
* without causing network traffic.
|
577
|
-
* If the URL becomes expired, you need to request a new one using getContentTemporaryUrl().
|
578
|
-
*
|
579
|
-
* @returns {Promise<String>}
|
580
|
-
*/
|
581
|
-
getCachedTemporaryUrl(): Promise<string | null>;
|
571
|
+
getContentTemporaryUrl(): CancellablePromise<string | null>;
|
582
572
|
private _fetchMcsMedia;
|
583
573
|
}
|
584
574
|
/**
|
@@ -862,16 +852,16 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
|
|
862
852
|
* @param categories Array of categories to match.
|
863
853
|
* @returns Array of media descriptors matching given categories.
|
864
854
|
*/
|
865
|
-
|
855
|
+
getMediaByCategories(categories: MediaCategory[]): Media[] | null;
|
866
856
|
/**
|
867
857
|
* Get a media descriptor for an email body attachment of a provided type.
|
868
|
-
* Allowed body types are returned in the Conversation.limits().
|
858
|
+
* Allowed body types are returned in the Conversation.limits().emailBodiesAllowedContentTypes array.
|
869
859
|
* @param type Type of email body to request, defaults to `text/plain`.
|
870
860
|
*/
|
871
861
|
getEmailBody(type?: string): Media | null;
|
872
862
|
/**
|
873
863
|
* Get a media descriptor for an email history attachment of a provided type.
|
874
|
-
* Allowed body types are returned in the Conversation.limits().
|
864
|
+
* Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedContentTypes array.
|
875
865
|
* @param type Type of email history to request, defaults to `text/plain`.
|
876
866
|
*/
|
877
867
|
getEmailHistory(type?: string): Media | null;
|
@@ -899,10 +889,19 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
|
|
899
889
|
*/
|
900
890
|
updateAttributes(attributes: JSONValue): Promise<Message>;
|
901
891
|
/**
|
902
|
-
* Get content URLs for all media attachments in the given set using single operation.
|
903
|
-
* @param contentSet Set of media attachments to query
|
892
|
+
* Get content URLs for all media attachments in the given set using a single operation.
|
893
|
+
* @param contentSet Set of media attachments to query content URLs.
|
894
|
+
*/
|
895
|
+
getTemporaryContentUrlsForMedia(contentSet: Media[] | null): CancellablePromise<Map<string, string>>;
|
896
|
+
/**
|
897
|
+
* Get content URLs for all media attachments in the given set of media sids using a single operation.
|
898
|
+
* @param mediaSids Set of media sids to query for the content URL.
|
904
899
|
*/
|
905
|
-
|
900
|
+
getTemporaryContentUrlsForMediaSids(mediaSids: string[]): CancellablePromise<Map<string, string>>;
|
901
|
+
/**
|
902
|
+
* Get content URLs for all media attached to the message.
|
903
|
+
*/
|
904
|
+
getTemporaryContentUrlsForAttachedMedia(): CancellablePromise<Map<string, string>>;
|
906
905
|
private _getDetailedDeliveryReceiptsPaginator;
|
907
906
|
}
|
908
907
|
/**
|
@@ -978,25 +977,6 @@ declare class TypingIndicator {
|
|
978
977
|
send(conversationSid: string): Promise<void>;
|
979
978
|
private _send;
|
980
979
|
}
|
981
|
-
/**
|
982
|
-
* An unsent message. Returned from {@link MessageBuilder.build}.
|
983
|
-
*/
|
984
|
-
declare class UnsentMessage {
|
985
|
-
private messagesEntity;
|
986
|
-
text?: string;
|
987
|
-
attributes: JSONValue;
|
988
|
-
mediaContent: [MediaCategory, FormData | SendMediaOptions][];
|
989
|
-
emailOptions: SendEmailOptions;
|
990
|
-
/**
|
991
|
-
* @internal
|
992
|
-
*/
|
993
|
-
constructor(messagesEntity: any);
|
994
|
-
/**
|
995
|
-
* Send the prepared message to the conversation.
|
996
|
-
* @returns Index of the new message in the conversation.
|
997
|
-
*/
|
998
|
-
send(): Promise<number | null>;
|
999
|
-
}
|
1000
980
|
/**
|
1001
981
|
* Pagination helper class.
|
1002
982
|
*/
|
@@ -1103,11 +1083,10 @@ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
|
|
1103
1083
|
subscribe(name: string): Promise<SyncList>;
|
1104
1084
|
unsubscribe(): Promise<void>;
|
1105
1085
|
/**
|
1106
|
-
* Send
|
1086
|
+
* Send a message to the conversation. The message could include text and multiple media attachments.
|
1107
1087
|
* @param message Message to post
|
1108
|
-
* @returns Returns a promise which can fail
|
1109
1088
|
*/
|
1110
|
-
sendV2(message: UnsentMessage):
|
1089
|
+
sendV2(message: UnsentMessage): CancellablePromise<MessageResponse>;
|
1111
1090
|
/**
|
1112
1091
|
* Send Message to the conversation
|
1113
1092
|
* @param message Message to post
|
@@ -1144,6 +1123,25 @@ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
|
|
1144
1123
|
*/
|
1145
1124
|
private _getMessages;
|
1146
1125
|
}
|
1126
|
+
/**
|
1127
|
+
* An unsent message. Returned from {@link MessageBuilder.build}.
|
1128
|
+
*/
|
1129
|
+
declare class UnsentMessage {
|
1130
|
+
private messagesEntity;
|
1131
|
+
text?: string;
|
1132
|
+
attributes: JSONValue;
|
1133
|
+
mediaContent: [MediaCategory, FormData | SendMediaOptions][];
|
1134
|
+
emailOptions: SendEmailOptions;
|
1135
|
+
/**
|
1136
|
+
* @internal
|
1137
|
+
*/
|
1138
|
+
constructor(messagesEntity: Messages);
|
1139
|
+
/**
|
1140
|
+
* Send the prepared message to the conversation.
|
1141
|
+
* @returns Index of the new message in the conversation.
|
1142
|
+
*/
|
1143
|
+
send(): CancellablePromise<number | null>;
|
1144
|
+
}
|
1147
1145
|
/**
|
1148
1146
|
* Message builder. Allows the message to be built and sent via method chaining.
|
1149
1147
|
*
|
@@ -1184,17 +1182,17 @@ declare class MessageBuilder {
|
|
1184
1182
|
*/
|
1185
1183
|
setAttributes(attributes: JSONValue): MessageBuilder;
|
1186
1184
|
/**
|
1187
|
-
* Set email body with given
|
1188
|
-
* @param
|
1189
|
-
* @param body Body payload in selected format.
|
1185
|
+
* Set the email body with a given content type.
|
1186
|
+
* @param contentType Format of the body to set (text/plain or text/html).
|
1187
|
+
* @param body Body payload in the selected format.
|
1190
1188
|
*/
|
1191
|
-
setEmailBody(
|
1189
|
+
setEmailBody(contentType: string, body: FormData | SendMediaOptions): MessageBuilder;
|
1192
1190
|
/**
|
1193
|
-
* Set email history with given
|
1194
|
-
* @param
|
1195
|
-
* @param history History payload in selected format.
|
1191
|
+
* Set the email history with a given content type.
|
1192
|
+
* @param contentType Format of the history to set (text/plain or text/html).
|
1193
|
+
* @param history History payload in the selected format.
|
1196
1194
|
*/
|
1197
|
-
setEmailHistory(
|
1195
|
+
setEmailHistory(contentType: string, history: FormData | SendMediaOptions): MessageBuilder;
|
1198
1196
|
/**
|
1199
1197
|
* Adds media to the message.
|
1200
1198
|
* @param payload Media to add.
|
@@ -1204,6 +1202,10 @@ declare class MessageBuilder {
|
|
1204
1202
|
* Builds the message, making it ready to be sent.
|
1205
1203
|
*/
|
1206
1204
|
build(): UnsentMessage;
|
1205
|
+
/**
|
1206
|
+
* Prepares a message and sends it to the conversation.
|
1207
|
+
*/
|
1208
|
+
buildAndSend(): CancellablePromise<number | null>;
|
1207
1209
|
private getPayloadContentType;
|
1208
1210
|
}
|
1209
1211
|
type ConversationEvents = {
|
@@ -1495,6 +1497,9 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1495
1497
|
*/
|
1496
1498
|
get notificationLevel(): NotificationLevel;
|
1497
1499
|
get bindings(): ConversationBindings;
|
1500
|
+
/**
|
1501
|
+
* Current conversation limits.
|
1502
|
+
*/
|
1498
1503
|
get limits(): ConversationLimits;
|
1499
1504
|
/**
|
1500
1505
|
* State of the conversation.
|
@@ -1775,6 +1780,9 @@ declare class PushNotification {
|
|
1775
1780
|
*/
|
1776
1781
|
constructor(data: PushNotificationDescriptor);
|
1777
1782
|
}
|
1783
|
+
/**
|
1784
|
+
* Client events.
|
1785
|
+
*/
|
1778
1786
|
type ClientEvents = {
|
1779
1787
|
conversationAdded: (conversation: Conversation) => void;
|
1780
1788
|
conversationJoined: (conversation: Conversation) => void;
|
@@ -1807,7 +1815,10 @@ type ClientEvents = {
|
|
1807
1815
|
user: User;
|
1808
1816
|
updateReasons: UserUpdateReason[];
|
1809
1817
|
}) => void;
|
1810
|
-
stateChanged: (state
|
1818
|
+
stateChanged: ({ state, error }: {
|
1819
|
+
state: State;
|
1820
|
+
error?: Error;
|
1821
|
+
}) => void;
|
1811
1822
|
connectionStateChanged: (state: TwilsockConnectionState) => void;
|
1812
1823
|
connectionError: (data: {
|
1813
1824
|
terminal: boolean;
|
@@ -1821,8 +1832,10 @@ type ClientEvents = {
|
|
1821
1832
|
* * `'connecting'` - client is offline and connection attempt is in process
|
1822
1833
|
* * `'connected'` - client is online and ready
|
1823
1834
|
* * `'disconnecting'` - client is going offline as disconnection is in process
|
1824
|
-
* * `'disconnected'` - client is offline and no connection attempt is in
|
1825
|
-
*
|
1835
|
+
* * `'disconnected'` - client is offline and no connection attempt is in
|
1836
|
+
* process
|
1837
|
+
* * `'denied'` - client connection is denied because of invalid JWT access
|
1838
|
+
* token. User must refresh token in order to proceed
|
1826
1839
|
*/
|
1827
1840
|
type ConnectionState = TwilsockConnectionState;
|
1828
1841
|
/**
|
@@ -1837,6 +1850,9 @@ type State = "failed" | "initialized";
|
|
1837
1850
|
* * `'apn'`
|
1838
1851
|
*/
|
1839
1852
|
type NotificationsChannelType = ChannelType;
|
1853
|
+
/**
|
1854
|
+
* Level of logging.
|
1855
|
+
*/
|
1840
1856
|
type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent";
|
1841
1857
|
/**
|
1842
1858
|
* Conversations client options.
|
@@ -1891,43 +1907,9 @@ interface CreateConversationOptions {
|
|
1891
1907
|
*/
|
1892
1908
|
declare class Client extends ReplayEventEmitter<ClientEvents> {
|
1893
1909
|
/**
|
1894
|
-
*
|
1895
|
-
|
1896
|
-
|
1897
|
-
private conversationsPromise;
|
1898
|
-
private _ensureReady;
|
1899
|
-
private _resolveEnsureReady;
|
1900
|
-
private _rejectEnsureReady;
|
1901
|
-
private fpaToken;
|
1902
|
-
private configuration;
|
1903
|
-
private conversations;
|
1904
|
-
private readonly options;
|
1905
|
-
private services;
|
1906
|
-
private readonly _myself;
|
1907
|
-
/**
|
1908
|
-
* Current version of the Conversations client.
|
1909
|
-
*/
|
1910
|
-
static readonly version: string;
|
1911
|
-
/**
|
1912
|
-
* Current version of the Conversations client.
|
1913
|
-
*/
|
1914
|
-
readonly version: string;
|
1915
|
-
private static readonly supportedPushChannels;
|
1916
|
-
private static readonly supportedPushDataFields;
|
1917
|
-
/**
|
1918
|
-
* Returned Conversations instance is not yet fully initialized. Calling any operations will block until it is.
|
1919
|
-
* Use connection events to monitor when client becomes fully available (connectionStateChanged with state
|
1920
|
-
* 'connected') or not available (connectionStateChange with state 'denied', event tokenExpired, event connectionError).
|
1921
|
-
*
|
1922
|
-
* @param fpaToken Access token
|
1923
|
-
* @param options Options to customize the Client
|
1924
|
-
* @returns A not yet fully-initialized client.
|
1925
|
-
*/
|
1926
|
-
constructor(fpaToken: string, options?: ClientOptions | null);
|
1927
|
-
static populateInitRegistrations(reg: InitRegistration): void;
|
1928
|
-
/**
|
1929
|
-
* Fired when a conversation becomes visible to the client. The event is also triggered when the client creates a new conversation.
|
1930
|
-
* Fired for all conversations client has joined.
|
1910
|
+
* Fired when a conversation becomes visible to the client. The event is also
|
1911
|
+
* triggered when the client creates a new conversation.
|
1912
|
+
* Fired for all conversations that the client has joined.
|
1931
1913
|
*
|
1932
1914
|
* Parameters:
|
1933
1915
|
* 1. {@link Conversation} `conversation` - the conversation in question
|
@@ -1959,14 +1941,17 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
1959
1941
|
*/
|
1960
1942
|
static readonly conversationRemoved = "conversationRemoved";
|
1961
1943
|
/**
|
1962
|
-
* Fired when the attributes or the metadata of a conversation have been
|
1963
|
-
* During conversation's creation and initialization, this event
|
1964
|
-
* for same joined or created conversation as
|
1944
|
+
* Fired when the attributes or the metadata of a conversation have been
|
1945
|
+
* updated. During conversation's creation and initialization, this event
|
1946
|
+
* might be fired multiple times for same joined or created conversation as
|
1947
|
+
* new data is arriving from different sources.
|
1965
1948
|
*
|
1966
1949
|
* Parameters:
|
1967
|
-
* 1. object `data` - info object provided with the event. It has the
|
1950
|
+
* 1. object `data` - info object provided with the event. It has the
|
1951
|
+
* following properties:
|
1968
1952
|
* * {@link Conversation} `conversation` - the conversation in question
|
1969
|
-
* * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
|
1953
|
+
* * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
|
1954
|
+
* for the update
|
1970
1955
|
* @event
|
1971
1956
|
*/
|
1972
1957
|
static readonly conversationUpdated = "conversationUpdated";
|
@@ -1990,9 +1975,11 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
1990
1975
|
* Fired when a participant's fields have been updated.
|
1991
1976
|
*
|
1992
1977
|
* Parameters:
|
1993
|
-
* 1. object `data` - info object provided with the event. It has the
|
1978
|
+
* 1. object `data` - info object provided with the event. It has the
|
1979
|
+
* following properties:
|
1994
1980
|
* * {@link Participant} `participant` - the participant in question
|
1995
|
-
* * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
|
1981
|
+
* * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
|
1982
|
+
* for the update
|
1996
1983
|
* @event
|
1997
1984
|
*/
|
1998
1985
|
static readonly participantUpdated = "participantUpdated";
|
@@ -2016,9 +2003,11 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2016
2003
|
* Fired when the fields of an existing message are updated with new values.
|
2017
2004
|
*
|
2018
2005
|
* Parameters:
|
2019
|
-
* 1. object `data` - info object provided with the event. It has the
|
2006
|
+
* 1. object `data` - info object provided with the event. It has the
|
2007
|
+
* following properties:
|
2020
2008
|
* * {@link Message} `message` - the message in question
|
2021
|
-
* * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
|
2009
|
+
* * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
|
2010
|
+
* the update
|
2022
2011
|
* @event
|
2023
2012
|
*/
|
2024
2013
|
static readonly messageUpdated = "messageUpdated";
|
@@ -2051,10 +2040,12 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2051
2040
|
*/
|
2052
2041
|
static readonly typingStarted = "typingStarted";
|
2053
2042
|
/**
|
2054
|
-
* Fired when the client has received (and parsed) a push notification via one
|
2043
|
+
* Fired when the client has received (and parsed) a push notification via one
|
2044
|
+
* of the push channels (apn or fcm).
|
2055
2045
|
*
|
2056
2046
|
* Parameters:
|
2057
|
-
* 1. {@link PushNotification} `pushNotification` - the push notification in
|
2047
|
+
* 1. {@link PushNotification} `pushNotification` - the push notification in
|
2048
|
+
* question
|
2058
2049
|
* @event
|
2059
2050
|
*/
|
2060
2051
|
static readonly pushNotification = "pushNotification";
|
@@ -2075,12 +2066,15 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2075
2066
|
*/
|
2076
2067
|
static readonly userUnsubscribed = "userUnsubscribed";
|
2077
2068
|
/**
|
2078
|
-
* Fired when the properties or the reachability status of a user have been
|
2069
|
+
* Fired when the properties or the reachability status of a user have been
|
2070
|
+
* updated.
|
2079
2071
|
*
|
2080
2072
|
* Parameters:
|
2081
|
-
* 1. object `data` - info object provided with the event. It has the
|
2073
|
+
* 1. object `data` - info object provided with the event. It has the
|
2074
|
+
* following properties:
|
2082
2075
|
* * {@link User} `user` - the user in question
|
2083
|
-
* * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the
|
2076
|
+
* * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the
|
2077
|
+
* update
|
2084
2078
|
* @event
|
2085
2079
|
*/
|
2086
2080
|
static readonly userUpdated = "userUpdated";
|
@@ -2088,14 +2082,17 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2088
2082
|
* Fired when the state of the client has been changed.
|
2089
2083
|
*
|
2090
2084
|
* Parameters:
|
2091
|
-
* 1.
|
2085
|
+
* 1. object `data` - info object provided with the event. It has the
|
2086
|
+
* following properties:
|
2087
|
+
* * {@link State} `state` - the new client state
|
2088
|
+
* * Error? `error` - the initialization error if present
|
2092
2089
|
* @event
|
2093
2090
|
*/
|
2094
2091
|
static readonly stateChanged = "stateChanged";
|
2095
2092
|
/**
|
2096
2093
|
* Fired when the connection state of the client has been changed.
|
2097
2094
|
*
|
2098
|
-
*
|
2095
|
+
* Parameters:
|
2099
2096
|
* 1. {@link ConnectionState} `state` - the new connection state
|
2100
2097
|
* @event
|
2101
2098
|
*/
|
@@ -2104,7 +2101,8 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2104
2101
|
* Fired when the connection is interrupted for an unexpected reason.
|
2105
2102
|
*
|
2106
2103
|
* Parameters:
|
2107
|
-
* 1. object `data` - info object provided with the event. It has the
|
2104
|
+
* 1. object `data` - info object provided with the event. It has the
|
2105
|
+
* following properties:
|
2108
2106
|
* * boolean `terminal` - Twilsock will stop connection attempts if true
|
2109
2107
|
* * string `message` - the error message of the root cause
|
2110
2108
|
* * number? `httpStatusCode` - http status code if available
|
@@ -2112,6 +2110,93 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2112
2110
|
* @event
|
2113
2111
|
*/
|
2114
2112
|
static readonly connectionError = "connectionError";
|
2113
|
+
/**
|
2114
|
+
* Current version of the Conversations client.
|
2115
|
+
*/
|
2116
|
+
static readonly version: string;
|
2117
|
+
/**
|
2118
|
+
* Logger instance.
|
2119
|
+
*/
|
2120
|
+
private static readonly _logger;
|
2121
|
+
/**
|
2122
|
+
* Supported push notification channels.
|
2123
|
+
*/
|
2124
|
+
private static readonly _supportedPushChannels;
|
2125
|
+
/**
|
2126
|
+
* Supported push data fields.
|
2127
|
+
*/
|
2128
|
+
private static readonly _supportedPushDataFields;
|
2129
|
+
/**
|
2130
|
+
* Current version of the Conversations client.
|
2131
|
+
*/
|
2132
|
+
readonly version: string;
|
2133
|
+
/**
|
2134
|
+
* Client connection state.
|
2135
|
+
*/
|
2136
|
+
connectionState: ConnectionState;
|
2137
|
+
/**
|
2138
|
+
* Promise that resolves on successful initialization.
|
2139
|
+
*/
|
2140
|
+
private readonly _ensureReady;
|
2141
|
+
/**
|
2142
|
+
* Options passed to the client.
|
2143
|
+
*/
|
2144
|
+
private readonly _options;
|
2145
|
+
/**
|
2146
|
+
* Client service objects.
|
2147
|
+
*/
|
2148
|
+
private readonly _services;
|
2149
|
+
/**
|
2150
|
+
* The user of the client.
|
2151
|
+
*/
|
2152
|
+
private readonly _myself;
|
2153
|
+
/**
|
2154
|
+
* Resolves the {@link Client._ensureReady} promise.
|
2155
|
+
*/
|
2156
|
+
private _resolveEnsureReady;
|
2157
|
+
/**
|
2158
|
+
* Rejects the {@link Client._ensureReady} promise.
|
2159
|
+
*/
|
2160
|
+
private _rejectEnsureReady;
|
2161
|
+
/**
|
2162
|
+
* The current token of the client.
|
2163
|
+
*/
|
2164
|
+
private _fpaToken;
|
2165
|
+
/**
|
2166
|
+
* The constructed configuration object.
|
2167
|
+
*/
|
2168
|
+
private _configuration;
|
2169
|
+
/**
|
2170
|
+
* The Conversations entity.
|
2171
|
+
*/
|
2172
|
+
private _conversations;
|
2173
|
+
/**
|
2174
|
+
* Promise that resolves when initial conversations are fetched.
|
2175
|
+
*/
|
2176
|
+
private _conversationsPromise;
|
2177
|
+
/**
|
2178
|
+
* Returned Conversations instance is not yet fully initialized. Calling any
|
2179
|
+
* operations will block until it is. Use connection events to monitor when
|
2180
|
+
* client becomes fully available (connectionStateChanged with state
|
2181
|
+
* 'connected') or not available (connectionStateChange with state 'denied',
|
2182
|
+
* event tokenExpired, event connectionError).
|
2183
|
+
*
|
2184
|
+
* @param fpaToken Access token
|
2185
|
+
* @param options Options to customize the Client
|
2186
|
+
* @returns A not yet fully-initialized client.
|
2187
|
+
*/
|
2188
|
+
constructor(fpaToken: string, options?: ClientOptions | null);
|
2189
|
+
/**
|
2190
|
+
* Information of the logged-in user. Before client initialization, returns an
|
2191
|
+
* uninitialized user. Will trigger a {@link Client.userUpdated} event after
|
2192
|
+
* initialization.
|
2193
|
+
*/
|
2194
|
+
get user(): User;
|
2195
|
+
/**
|
2196
|
+
* Client reachability state. Throws an error if accessed before the client
|
2197
|
+
* initialization was completed.
|
2198
|
+
*/
|
2199
|
+
get reachabilityEnabled(): boolean;
|
2115
2200
|
/**
|
2116
2201
|
* @deprecated Call constructor directly.
|
2117
2202
|
*
|
@@ -2133,20 +2218,21 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2133
2218
|
*/
|
2134
2219
|
static create(token: string, options?: ClientOptions | null): Promise<Client>;
|
2135
2220
|
/**
|
2136
|
-
*
|
2137
|
-
*
|
2138
|
-
*
|
2221
|
+
* Static method for push notification payload parsing. Returns parsed push as
|
2222
|
+
* a {@link PushNotification} object.
|
2223
|
+
* @param notificationPayload Push notification payload.
|
2139
2224
|
*/
|
2140
|
-
|
2225
|
+
static parsePushNotification(notificationPayload: any): PushNotification;
|
2141
2226
|
/**
|
2142
|
-
*
|
2143
|
-
*
|
2227
|
+
* Static method for parsing push notification chat data.
|
2228
|
+
* @param data Data to parse
|
2144
2229
|
*/
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2230
|
+
private static _parsePushNotificationChatData;
|
2231
|
+
/**
|
2232
|
+
* Populate the client with init registrations.
|
2233
|
+
* @param reg The init registration to populate.
|
2234
|
+
*/
|
2235
|
+
static populateInitRegistrations(reg: InitRegistration): void;
|
2150
2236
|
/**
|
2151
2237
|
* Gracefully shut down the client.
|
2152
2238
|
*/
|
@@ -2161,6 +2247,12 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2161
2247
|
* @param conversationSid Conversation sid
|
2162
2248
|
*/
|
2163
2249
|
getConversationBySid(conversationSid: string): Promise<Conversation>;
|
2250
|
+
/**
|
2251
|
+
* Peek a conversation by its SID.
|
2252
|
+
* @param conversationSid Conversation sid
|
2253
|
+
* @internal
|
2254
|
+
*/
|
2255
|
+
peekConversationBySid(conversationSid: string): Promise<Conversation>;
|
2164
2256
|
/**
|
2165
2257
|
* Get a known conversation by its unique identifier name.
|
2166
2258
|
* @param uniqueName The unique identifier name of the conversation.
|
@@ -2179,7 +2271,8 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2179
2271
|
/**
|
2180
2272
|
* Register for push notifications.
|
2181
2273
|
* @param channelType Channel type.
|
2182
|
-
* @param registrationId Push notification ID provided by the FCM/APNS service
|
2274
|
+
* @param registrationId Push notification ID provided by the FCM/APNS service
|
2275
|
+
* on the platform.
|
2183
2276
|
*/
|
2184
2277
|
setPushRegistrationId(channelType: NotificationsChannelType, registrationId: string): Promise<void>;
|
2185
2278
|
/**
|
@@ -2192,27 +2285,29 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2192
2285
|
* Clear existing registrations directly using provided device token.
|
2193
2286
|
* This is useful to ensure stopped subscriptions without resubscribing.
|
2194
2287
|
*
|
2195
|
-
* This function goes completely beside the state machine and removes all
|
2196
|
-
*
|
2288
|
+
* This function goes completely beside the state machine and removes all
|
2289
|
+
* registrations.
|
2290
|
+
* Use with caution: if it races with current state machine operations,
|
2291
|
+
* madness will ensue.
|
2197
2292
|
*
|
2198
2293
|
* @param channelType Channel type.
|
2199
|
-
* @param registrationId Push notification ID provided by the FCM/APNS service
|
2294
|
+
* @param registrationId Push notification ID provided by the FCM/APNS service
|
2295
|
+
* on the platform.
|
2200
2296
|
*/
|
2201
2297
|
removePushRegistrations(channelType: ChannelType, registrationId: string): Promise<void>;
|
2202
|
-
private static parsePushNotificationChatData;
|
2203
2298
|
/**
|
2204
|
-
*
|
2205
|
-
* @param notificationPayload Push notification payload.
|
2299
|
+
* Current version of the Conversations client.
|
2206
2300
|
*/
|
2207
|
-
static parsePushNotification(notificationPayload: any): PushNotification;
|
2208
2301
|
parsePushNotification: typeof Client.parsePushNotification;
|
2209
2302
|
/**
|
2210
|
-
* Handle push notification payload parsing and emit the
|
2303
|
+
* Handle push notification payload parsing and emit the
|
2304
|
+
* {@link Client.pushNotification} event on this {@link Client} instance.
|
2211
2305
|
* @param notificationPayload Push notification payload
|
2212
2306
|
*/
|
2213
2307
|
handlePushNotification(notificationPayload: any): Promise<void>;
|
2214
2308
|
/**
|
2215
|
-
* Gets a user with the given identity. If it's in the subscribed list, then
|
2309
|
+
* Gets a user with the given identity. If it's in the subscribed list, then
|
2310
|
+
* return the user object from it;
|
2216
2311
|
* if not, then subscribe and add user to the subscribed list.
|
2217
2312
|
* @param identity Identity of the user.
|
2218
2313
|
* @returns A fully initialized user.
|
@@ -2222,6 +2317,32 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2222
2317
|
* Get a list of subscribed user objects.
|
2223
2318
|
*/
|
2224
2319
|
getSubscribedUsers(): Promise<Array<User>>;
|
2320
|
+
/**
|
2321
|
+
* Get content URLs for all media attachments in the given set of media sids
|
2322
|
+
* using a single operation.
|
2323
|
+
* @param mediaSids Set of media sids to query for the content URL.
|
2324
|
+
*/
|
2325
|
+
getTemporaryContentUrlsForMediaSids(mediaSids: string[]): CancellablePromise<Map<string, string>>;
|
2326
|
+
/**
|
2327
|
+
* Get content URLs for all media attachments in the given set using a single
|
2328
|
+
* operation.
|
2329
|
+
* @param contentSet Set of media attachments to query content URLs.
|
2330
|
+
*/
|
2331
|
+
getTemporaryContentUrlsForMedia(contentSet: Media[]): CancellablePromise<Map<string, string>>;
|
2332
|
+
/**
|
2333
|
+
* Initialize the client.
|
2334
|
+
*/
|
2335
|
+
private _initialize;
|
2336
|
+
/**
|
2337
|
+
* Subscribe to push notifications.
|
2338
|
+
* @param channelType The channel type to subscribe to.
|
2339
|
+
*/
|
2340
|
+
private _subscribeToPushNotifications;
|
2341
|
+
/**
|
2342
|
+
* Unsubscribe from push notifications.
|
2343
|
+
* @param channelType The channel type to unsubscribe from.
|
2344
|
+
*/
|
2345
|
+
private _unsubscribeFromPushNotifications;
|
2225
2346
|
}
|
2226
2347
|
declare class NotificationTypes {
|
2227
2348
|
static readonly TYPING_INDICATOR = "twilio.ipmsg.typing_indicator";
|