@twilio/conversations 2.1.0-rc.8 → 3.0.0-canary.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -3
- package/builds/browser.js +2350 -1627
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +512 -304
- package/builds/lib.js +2350 -1627
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +3448 -3403
- package/builds/twilio-conversations.min.js +2 -2
- package/dist/client.js +402 -281
- 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 +408 -373
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +9 -10
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +46 -26
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +19 -10
- package/dist/data/participants.js.map +1 -1
- package/dist/data/users.js +2 -2
- package/dist/data/users.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/participant.js.map +1 -1
- package/dist/push-notification.js.map +1 -1
- package/dist/services/typing-indicator.js +1 -1
- package/dist/services/typing-indicator.js.map +1 -1
- package/dist/unsent-message.js +13 -3
- package/dist/unsent-message.js.map +1 -1
- package/package.json +12 -10
- package/CHANGELOG.md +0 -404
- package/docs/assets/css/main.css +0 -2660
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -248
- package/docs/assets/js/search.js +0 -1
- package/docs/classes/AggregatedDeliveryReceipt.html +0 -3184
- package/docs/classes/Client.html +0 -4073
- package/docs/classes/Conversation.html +0 -4302
- package/docs/classes/DetailedDeliveryReceipt.html +0 -3163
- package/docs/classes/Media.html +0 -3193
- package/docs/classes/Message.html +0 -3677
- package/docs/classes/MessageBuilder.html +0 -3254
- package/docs/classes/Participant.html +0 -3444
- package/docs/classes/PushNotification.html +0 -3130
- package/docs/classes/RestPaginator.html +0 -3160
- package/docs/classes/UnsentMessage.html +0 -3042
- package/docs/classes/User.html +0 -3349
- package/docs/index.html +0 -3512
- package/docs/interfaces/ClientOptions.html +0 -3034
- package/docs/interfaces/ConversationBindings.html +0 -3001
- package/docs/interfaces/ConversationEmailBinding.html +0 -3001
- package/docs/interfaces/ConversationLimits.html +0 -3098
- package/docs/interfaces/ConversationState.html +0 -3050
- package/docs/interfaces/CreateConversationOptions.html +0 -3066
- package/docs/interfaces/LastMessage.html +0 -3050
- package/docs/interfaces/Paginator.html +0 -3141
- package/docs/interfaces/ParticipantBindings.html +0 -3001
- package/docs/interfaces/ParticipantEmailBinding.html +0 -3001
- package/docs/interfaces/PushNotificationData.html +0 -3066
- package/docs/interfaces/SendEmailOptions.html +0 -3034
- package/docs/interfaces/SendMediaOptions.html +0 -3068
- package/docs/modules.html +0 -3513
package/builds/lib.d.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import { SyncClient, SyncDocument, SyncList } from "twilio-sync";
|
2
2
|
import { LogLevelDesc } from "loglevel";
|
3
|
-
import { Transport, TwilsockClient, InitRegistration, TransportResult } from "twilsock";
|
3
|
+
import { Transport, TwilsockClient, InitRegistration, ConnectionError, 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 { 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;
|
@@ -301,7 +301,7 @@ declare class Users extends ReplayEventEmitter<UsersEvents> {
|
|
301
301
|
* if not - then subscribes and adds user to the FIFO stack
|
302
302
|
* @returns {Promise<User>} Fully initialized user
|
303
303
|
*/
|
304
|
-
getUser(identity
|
304
|
+
getUser(identity: string, entityName?: string): Promise<User>;
|
305
305
|
/**
|
306
306
|
* @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}
|
307
307
|
*/
|
@@ -326,9 +326,9 @@ interface ParticipantDescriptor {
|
|
326
326
|
identity: string;
|
327
327
|
roleSid?: string;
|
328
328
|
lastConsumedMessageIndex: number | null;
|
329
|
-
lastConsumptionTimestamp: number;
|
329
|
+
lastConsumptionTimestamp: number | null;
|
330
330
|
type: ParticipantType;
|
331
|
-
userInfo
|
331
|
+
userInfo?: string;
|
332
332
|
bindings?: ParticipantBindings;
|
333
333
|
}
|
334
334
|
interface ParticipantServices {
|
@@ -490,26 +490,6 @@ declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
|
|
490
490
|
*/
|
491
491
|
updateAttributes(attributes: JSONValue): Promise<Participant>;
|
492
492
|
}
|
493
|
-
interface ParticipantResponse {
|
494
|
-
account_sid: string;
|
495
|
-
chat_service_sid: string;
|
496
|
-
conversation_sid: string;
|
497
|
-
role_sid: string;
|
498
|
-
sid: string;
|
499
|
-
attributes: string;
|
500
|
-
date_created: string;
|
501
|
-
date_updated: string;
|
502
|
-
identity: string | null;
|
503
|
-
messaging_binding: {
|
504
|
-
type: string;
|
505
|
-
address: string;
|
506
|
-
proxy_address: string;
|
507
|
-
} | null;
|
508
|
-
url: string;
|
509
|
-
links: {
|
510
|
-
conversation: string;
|
511
|
-
};
|
512
|
-
}
|
513
493
|
interface ParticipantBindingOptions {
|
514
494
|
email?: ParticipantEmailBinding;
|
515
495
|
}
|
@@ -568,17 +548,7 @@ declare class Media {
|
|
568
548
|
* If the URL becomes expired, you need to request a new one.
|
569
549
|
* Each call to this function produces a new temporary URL.
|
570
550
|
*/
|
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>;
|
551
|
+
getContentTemporaryUrl(): CancellablePromise<string | null>;
|
582
552
|
private _fetchMcsMedia;
|
583
553
|
}
|
584
554
|
/**
|
@@ -862,16 +832,16 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
|
|
862
832
|
* @param categories Array of categories to match.
|
863
833
|
* @returns Array of media descriptors matching given categories.
|
864
834
|
*/
|
865
|
-
|
835
|
+
getMediaByCategories(categories: MediaCategory[]): Media[] | null;
|
866
836
|
/**
|
867
837
|
* Get a media descriptor for an email body attachment of a provided type.
|
868
|
-
* Allowed body types are returned in the Conversation.limits().
|
838
|
+
* Allowed body types are returned in the Conversation.limits().emailBodiesAllowedContentTypes array.
|
869
839
|
* @param type Type of email body to request, defaults to `text/plain`.
|
870
840
|
*/
|
871
841
|
getEmailBody(type?: string): Media | null;
|
872
842
|
/**
|
873
843
|
* Get a media descriptor for an email history attachment of a provided type.
|
874
|
-
* Allowed body types are returned in the Conversation.limits().
|
844
|
+
* Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedContentTypes array.
|
875
845
|
* @param type Type of email history to request, defaults to `text/plain`.
|
876
846
|
*/
|
877
847
|
getEmailHistory(type?: string): Media | null;
|
@@ -899,10 +869,19 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
|
|
899
869
|
*/
|
900
870
|
updateAttributes(attributes: JSONValue): Promise<Message>;
|
901
871
|
/**
|
902
|
-
* Get content URLs for all media attachments in the given set using single operation.
|
903
|
-
* @param contentSet Set of media attachments to query
|
872
|
+
* Get content URLs for all media attachments in the given set using a single operation.
|
873
|
+
* @param contentSet Set of media attachments to query content URLs.
|
874
|
+
*/
|
875
|
+
getTemporaryContentUrlsForMedia(contentSet: Media[] | null): CancellablePromise<Map<string, string>>;
|
876
|
+
/**
|
877
|
+
* Get content URLs for all media attachments in the given set of media sids using a single operation.
|
878
|
+
* @param mediaSids Set of media sids to query for the content URL.
|
904
879
|
*/
|
905
|
-
|
880
|
+
getTemporaryContentUrlsForMediaSids(mediaSids: string[]): CancellablePromise<Map<string, string>>;
|
881
|
+
/**
|
882
|
+
* Get content URLs for all media attached to the message.
|
883
|
+
*/
|
884
|
+
getTemporaryContentUrlsForAttachedMedia(): CancellablePromise<Map<string, string>>;
|
906
885
|
private _getDetailedDeliveryReceiptsPaginator;
|
907
886
|
}
|
908
887
|
/**
|
@@ -959,7 +938,7 @@ declare class TypingIndicator {
|
|
959
938
|
private sentUpdates;
|
960
939
|
private getConversation;
|
961
940
|
private serviceTypingTimeout;
|
962
|
-
constructor(getConversation:
|
941
|
+
constructor(getConversation: (conversationSid: string) => Promise<Conversation>, config: Configuration, services: TypingIndicatorServices);
|
963
942
|
get typingTimeout(): number;
|
964
943
|
/**
|
965
944
|
* Initialize TypingIndicator controller
|
@@ -978,25 +957,6 @@ declare class TypingIndicator {
|
|
978
957
|
send(conversationSid: string): Promise<void>;
|
979
958
|
private _send;
|
980
959
|
}
|
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
960
|
/**
|
1001
961
|
* Pagination helper class.
|
1002
962
|
*/
|
@@ -1103,11 +1063,10 @@ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
|
|
1103
1063
|
subscribe(name: string): Promise<SyncList>;
|
1104
1064
|
unsubscribe(): Promise<void>;
|
1105
1065
|
/**
|
1106
|
-
* Send
|
1066
|
+
* Send a message to the conversation. The message could include text and multiple media attachments.
|
1107
1067
|
* @param message Message to post
|
1108
|
-
* @returns Returns a promise which can fail
|
1109
1068
|
*/
|
1110
|
-
sendV2(message: UnsentMessage):
|
1069
|
+
sendV2(message: UnsentMessage): CancellablePromise<MessageResponse>;
|
1111
1070
|
/**
|
1112
1071
|
* Send Message to the conversation
|
1113
1072
|
* @param message Message to post
|
@@ -1144,6 +1103,25 @@ declare class Messages extends ReplayEventEmitter<MessagesEvents> {
|
|
1144
1103
|
*/
|
1145
1104
|
private _getMessages;
|
1146
1105
|
}
|
1106
|
+
/**
|
1107
|
+
* An unsent message. Returned from {@link MessageBuilder.build}.
|
1108
|
+
*/
|
1109
|
+
declare class UnsentMessage {
|
1110
|
+
private messagesEntity;
|
1111
|
+
text?: string;
|
1112
|
+
attributes: JSONValue;
|
1113
|
+
mediaContent: [MediaCategory, FormData | SendMediaOptions][];
|
1114
|
+
emailOptions: SendEmailOptions;
|
1115
|
+
/**
|
1116
|
+
* @internal
|
1117
|
+
*/
|
1118
|
+
constructor(messagesEntity: Messages);
|
1119
|
+
/**
|
1120
|
+
* Send the prepared message to the conversation.
|
1121
|
+
* @returns Index of the new message in the conversation.
|
1122
|
+
*/
|
1123
|
+
send(): CancellablePromise<number | null>;
|
1124
|
+
}
|
1147
1125
|
/**
|
1148
1126
|
* Message builder. Allows the message to be built and sent via method chaining.
|
1149
1127
|
*
|
@@ -1184,17 +1162,17 @@ declare class MessageBuilder {
|
|
1184
1162
|
*/
|
1185
1163
|
setAttributes(attributes: JSONValue): MessageBuilder;
|
1186
1164
|
/**
|
1187
|
-
* Set email body with given
|
1188
|
-
* @param
|
1189
|
-
* @param body Body payload in selected format.
|
1165
|
+
* Set the email body with a given content type.
|
1166
|
+
* @param contentType Format of the body to set (text/plain or text/html).
|
1167
|
+
* @param body Body payload in the selected format.
|
1190
1168
|
*/
|
1191
|
-
setEmailBody(
|
1169
|
+
setEmailBody(contentType: string, body: FormData | SendMediaOptions): MessageBuilder;
|
1192
1170
|
/**
|
1193
|
-
* Set email history with given
|
1194
|
-
* @param
|
1195
|
-
* @param history History payload in selected format.
|
1171
|
+
* Set the email history with a given content type.
|
1172
|
+
* @param contentType Format of the history to set (text/plain or text/html).
|
1173
|
+
* @param history History payload in the selected format.
|
1196
1174
|
*/
|
1197
|
-
setEmailHistory(
|
1175
|
+
setEmailHistory(contentType: string, history: FormData | SendMediaOptions): MessageBuilder;
|
1198
1176
|
/**
|
1199
1177
|
* Adds media to the message.
|
1200
1178
|
* @param payload Media to add.
|
@@ -1204,8 +1182,15 @@ declare class MessageBuilder {
|
|
1204
1182
|
* Builds the message, making it ready to be sent.
|
1205
1183
|
*/
|
1206
1184
|
build(): UnsentMessage;
|
1185
|
+
/**
|
1186
|
+
* Prepares a message and sends it to the conversation.
|
1187
|
+
*/
|
1188
|
+
buildAndSend(): CancellablePromise<number | null>;
|
1207
1189
|
private getPayloadContentType;
|
1208
1190
|
}
|
1191
|
+
/**
|
1192
|
+
* Conversation events.
|
1193
|
+
*/
|
1209
1194
|
type ConversationEvents = {
|
1210
1195
|
participantJoined: (participant: Participant) => void;
|
1211
1196
|
participantLeft: (participant: Participant) => void;
|
@@ -1227,55 +1212,28 @@ type ConversationEvents = {
|
|
1227
1212
|
}) => void;
|
1228
1213
|
removed: (conversation: Conversation) => void;
|
1229
1214
|
};
|
1230
|
-
interface ConversationServices {
|
1231
|
-
users: Users;
|
1232
|
-
typingIndicator: TypingIndicator;
|
1233
|
-
network: Network;
|
1234
|
-
mcsClient: McsClient;
|
1235
|
-
syncClient: SyncClient;
|
1236
|
-
commandExecutor: CommandExecutor;
|
1237
|
-
}
|
1238
|
-
interface ConversationDescriptor {
|
1239
|
-
channel: string;
|
1240
|
-
entityName: string;
|
1241
|
-
uniqueName: string;
|
1242
|
-
attributes: JSONValue;
|
1243
|
-
createdBy?: string;
|
1244
|
-
friendlyName?: string;
|
1245
|
-
lastConsumedMessageIndex: number;
|
1246
|
-
dateCreated: Date | null;
|
1247
|
-
dateUpdated: Date | null;
|
1248
|
-
notificationLevel?: NotificationLevel;
|
1249
|
-
bindings?: ConversationBindings;
|
1250
|
-
}
|
1251
|
-
interface ConversationLinks {
|
1252
|
-
self: string;
|
1253
|
-
messages: string;
|
1254
|
-
participants: string;
|
1255
|
-
}
|
1256
1215
|
/**
|
1257
|
-
*
|
1216
|
+
* Reason for the `updated` event emission by a conversation.
|
1258
1217
|
*/
|
1259
1218
|
type ConversationUpdateReason = "attributes" | "createdBy" | "dateCreated" | "dateUpdated" | "friendlyName" | "lastReadMessageIndex" | "state" | "status" | "uniqueName" | "lastMessage" | "notificationLevel" | "bindings";
|
1260
1219
|
/**
|
1261
|
-
*
|
1262
|
-
*
|
1263
|
-
* `notParticipating` in the conversation.
|
1220
|
+
* Status of the conversation, relative to the client: whether the conversation
|
1221
|
+
* has been `joined` or the client is `notParticipating` in the conversation.
|
1264
1222
|
*/
|
1265
1223
|
type ConversationStatus = "notParticipating" | "joined";
|
1266
1224
|
/**
|
1267
|
-
*
|
1225
|
+
* User's notification level for the conversation. Determines
|
1268
1226
|
* whether the currently logged-in user will receive pushes for events
|
1269
1227
|
* in this conversation. Can be either `muted` or `default`, where
|
1270
1228
|
* `default` defers to the global service push configuration.
|
1271
1229
|
*/
|
1272
1230
|
type NotificationLevel = "default" | "muted";
|
1273
1231
|
/**
|
1274
|
-
*
|
1232
|
+
* State of the conversation.
|
1275
1233
|
*/
|
1276
1234
|
interface ConversationState {
|
1277
1235
|
/**
|
1278
|
-
*
|
1236
|
+
* Current state.
|
1279
1237
|
*/
|
1280
1238
|
current: "active" | "inactive" | "closed";
|
1281
1239
|
/**
|
@@ -1283,6 +1241,9 @@ interface ConversationState {
|
|
1283
1241
|
*/
|
1284
1242
|
dateUpdated: Date;
|
1285
1243
|
}
|
1244
|
+
/**
|
1245
|
+
* Event arguments for the `updated` event.
|
1246
|
+
*/
|
1286
1247
|
interface ConversationUpdatedEventArgs {
|
1287
1248
|
conversation: Conversation;
|
1288
1249
|
updateReasons: ConversationUpdateReason[];
|
@@ -1301,6 +1262,9 @@ interface ConversationEmailBinding {
|
|
1301
1262
|
name?: string;
|
1302
1263
|
projected_address: string;
|
1303
1264
|
}
|
1265
|
+
/**
|
1266
|
+
* Binding for SMS conversation.
|
1267
|
+
*/
|
1304
1268
|
interface ConversationSmsBinding {
|
1305
1269
|
address?: string;
|
1306
1270
|
}
|
@@ -1346,33 +1310,51 @@ interface LastMessage {
|
|
1346
1310
|
dateCreated?: Date;
|
1347
1311
|
}
|
1348
1312
|
/**
|
1349
|
-
*
|
1313
|
+
* Conversation services.
|
1314
|
+
*/
|
1315
|
+
interface ConversationServices {
|
1316
|
+
users: Users;
|
1317
|
+
typingIndicator: TypingIndicator;
|
1318
|
+
network: Network;
|
1319
|
+
mcsClient: McsClient;
|
1320
|
+
syncClient: SyncClient;
|
1321
|
+
commandExecutor: CommandExecutor;
|
1322
|
+
}
|
1323
|
+
/**
|
1324
|
+
* Conversation descriptor.
|
1325
|
+
*/
|
1326
|
+
interface ConversationDescriptor {
|
1327
|
+
channel: string;
|
1328
|
+
entityName: string;
|
1329
|
+
uniqueName: string;
|
1330
|
+
attributes: JSONValue;
|
1331
|
+
createdBy?: string;
|
1332
|
+
friendlyName?: string;
|
1333
|
+
lastConsumedMessageIndex: number;
|
1334
|
+
dateCreated: Date | null;
|
1335
|
+
dateUpdated: Date | null;
|
1336
|
+
notificationLevel?: NotificationLevel;
|
1337
|
+
bindings?: ConversationBindings;
|
1338
|
+
}
|
1339
|
+
/**
|
1340
|
+
* Conversation links.
|
1341
|
+
*/
|
1342
|
+
interface ConversationLinks {
|
1343
|
+
self: string;
|
1344
|
+
messages: string;
|
1345
|
+
participants: string;
|
1346
|
+
}
|
1347
|
+
/**
|
1348
|
+
* A conversation represents communication between multiple Conversations
|
1349
|
+
* clients.
|
1350
1350
|
*/
|
1351
1351
|
declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
1352
|
-
/**
|
1353
|
-
* Unique system identifier of the conversation.
|
1354
|
-
*/
|
1355
|
-
readonly sid: string;
|
1356
|
-
readonly links: ConversationLinks;
|
1357
|
-
private readonly configuration;
|
1358
|
-
private readonly services;
|
1359
|
-
private channelState;
|
1360
|
-
private statusSource;
|
1361
|
-
private entityPromise;
|
1362
|
-
private entityName;
|
1363
|
-
private entity;
|
1364
|
-
private messagesEntity;
|
1365
|
-
private participantsEntity;
|
1366
|
-
private readonly participants;
|
1367
|
-
/**
|
1368
|
-
* @internal
|
1369
|
-
*/
|
1370
|
-
constructor(descriptor: ConversationDescriptor, sid: string, links: ConversationLinks, configuration: Configuration, services: ConversationServices);
|
1371
1352
|
/**
|
1372
1353
|
* Fired when a participant has joined the conversation.
|
1373
1354
|
*
|
1374
1355
|
* Parameters:
|
1375
|
-
* 1. {@link Participant} `participant` - participant that joined the
|
1356
|
+
* 1. {@link Participant} `participant` - participant that joined the
|
1357
|
+
* conversation
|
1376
1358
|
* @event
|
1377
1359
|
*/
|
1378
1360
|
static readonly participantJoined = "participantJoined";
|
@@ -1380,7 +1362,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1380
1362
|
* Fired when a participant has left the conversation.
|
1381
1363
|
*
|
1382
1364
|
* Parameters:
|
1383
|
-
* 1. {@link Participant} `participant` - participant that left the
|
1365
|
+
* 1. {@link Participant} `participant` - participant that left the
|
1366
|
+
* conversation
|
1384
1367
|
* @event
|
1385
1368
|
*/
|
1386
1369
|
static readonly participantLeft = "participantLeft";
|
@@ -1388,9 +1371,12 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1388
1371
|
* Fired when data of a participant has been updated.
|
1389
1372
|
*
|
1390
1373
|
* Parameters:
|
1391
|
-
* 1. object `data` - info object provided with the event. It has the
|
1392
|
-
*
|
1393
|
-
* * {@link
|
1374
|
+
* 1. object `data` - info object provided with the event. It has the
|
1375
|
+
* following properties:
|
1376
|
+
* * {@link Participant} `participant` - participant that has received the
|
1377
|
+
* update
|
1378
|
+
* * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
|
1379
|
+
* for the update
|
1394
1380
|
* @event
|
1395
1381
|
*/
|
1396
1382
|
static readonly participantUpdated = "participantUpdated";
|
@@ -1414,9 +1400,11 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1414
1400
|
* Fired when data of a message has been updated.
|
1415
1401
|
*
|
1416
1402
|
* Parameters:
|
1417
|
-
* 1. object `data` - info object provided with the event. It has the
|
1403
|
+
* 1. object `data` - info object provided with the event. It has the
|
1404
|
+
* following properties:
|
1418
1405
|
* * {@link Message} `message` - message that has received the update
|
1419
|
-
* * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
|
1406
|
+
* * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
|
1407
|
+
* the update
|
1420
1408
|
* @event
|
1421
1409
|
*/
|
1422
1410
|
static readonly messageUpdated = "messageUpdated";
|
@@ -1424,7 +1412,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1424
1412
|
* Fired when a participant has stopped typing.
|
1425
1413
|
*
|
1426
1414
|
* Parameters:
|
1427
|
-
* 1. {@link Participant} `participant` - the participant that has stopped
|
1415
|
+
* 1. {@link Participant} `participant` - the participant that has stopped
|
1416
|
+
* typing
|
1428
1417
|
* @event
|
1429
1418
|
*/
|
1430
1419
|
static readonly typingEnded = "typingEnded";
|
@@ -1432,7 +1421,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1432
1421
|
* Fired when a participant has started typing.
|
1433
1422
|
*
|
1434
1423
|
* Parameters:
|
1435
|
-
* 1. {@link Participant} `participant` - the participant that has started
|
1424
|
+
* 1. {@link Participant} `participant` - the participant that has started
|
1425
|
+
* typing
|
1436
1426
|
* @event
|
1437
1427
|
*/
|
1438
1428
|
static readonly typingStarted = "typingStarted";
|
@@ -1440,20 +1430,87 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1440
1430
|
* Fired when the data of the conversation has been updated.
|
1441
1431
|
*
|
1442
1432
|
* Parameters:
|
1443
|
-
* 1. object `data` - info object provided with the event. It has the
|
1444
|
-
*
|
1445
|
-
* * {@link
|
1433
|
+
* 1. object `data` - info object provided with the event. It has the
|
1434
|
+
* following properties:
|
1435
|
+
* * {@link Conversation} `conversation` - conversation that has received
|
1436
|
+
* the update
|
1437
|
+
* * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
|
1438
|
+
* for the update
|
1446
1439
|
* @event
|
1447
1440
|
*/
|
1448
1441
|
static readonly updated = "updated";
|
1449
1442
|
/**
|
1450
|
-
* Fired when the conversation was destroyed or the currently-logged-in user
|
1443
|
+
* Fired when the conversation was destroyed or the currently-logged-in user
|
1444
|
+
* has left private conversation.
|
1451
1445
|
*
|
1452
1446
|
* Parameters:
|
1453
1447
|
* 1. {@link Conversation} `conversation` - conversation that has been removed
|
1454
1448
|
* @event
|
1455
1449
|
*/
|
1456
1450
|
static readonly removed = "removed";
|
1451
|
+
/**
|
1452
|
+
* Logger instance.
|
1453
|
+
*/
|
1454
|
+
private static readonly _logger;
|
1455
|
+
/**
|
1456
|
+
* Unique system identifier of the conversation.
|
1457
|
+
*/
|
1458
|
+
readonly sid: string;
|
1459
|
+
/**
|
1460
|
+
* Conversation links for REST requests.
|
1461
|
+
* @internal
|
1462
|
+
*/
|
1463
|
+
readonly _links: ConversationLinks;
|
1464
|
+
/**
|
1465
|
+
* Map of participants.
|
1466
|
+
* @internal
|
1467
|
+
*/
|
1468
|
+
readonly _participants: Map<string, Participant>;
|
1469
|
+
/**
|
1470
|
+
* Configuration of the client that the conversation belongs to.
|
1471
|
+
*/
|
1472
|
+
private readonly _configuration;
|
1473
|
+
/**
|
1474
|
+
* Conversation service objects.
|
1475
|
+
*/
|
1476
|
+
private readonly _services;
|
1477
|
+
/**
|
1478
|
+
* Internal state of the conversation.
|
1479
|
+
*/
|
1480
|
+
private readonly _internalState;
|
1481
|
+
/**
|
1482
|
+
* Name of the conversation entity document.
|
1483
|
+
*/
|
1484
|
+
private readonly _entityName;
|
1485
|
+
/**
|
1486
|
+
* Messages entity.
|
1487
|
+
*/
|
1488
|
+
private readonly _messagesEntity;
|
1489
|
+
/**
|
1490
|
+
* Participants entity.
|
1491
|
+
*/
|
1492
|
+
private readonly _participantsEntity;
|
1493
|
+
/**
|
1494
|
+
* Source of the most recent update.
|
1495
|
+
*/
|
1496
|
+
private _dataSource;
|
1497
|
+
/**
|
1498
|
+
* Promise for the conversation entity document.
|
1499
|
+
*/
|
1500
|
+
private _entityPromise;
|
1501
|
+
/**
|
1502
|
+
* Conversation entity document.
|
1503
|
+
*/
|
1504
|
+
private _entity;
|
1505
|
+
/**
|
1506
|
+
* @param descriptor Conversation descriptor.
|
1507
|
+
* @param sid Conversation SID.
|
1508
|
+
* @param links Conversation links for REST requests.
|
1509
|
+
* @param configuration Client configuration.
|
1510
|
+
* @param services Conversation services.
|
1511
|
+
* @internal
|
1512
|
+
*/
|
1513
|
+
constructor(descriptor: ConversationDescriptor, sid: string, links: ConversationLinks, configuration: Configuration, services: ConversationServices);
|
1457
1514
|
/**
|
1458
1515
|
* Unique name of the conversation.
|
1459
1516
|
*/
|
@@ -1494,72 +1551,52 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1494
1551
|
* User notification level for this conversation.
|
1495
1552
|
*/
|
1496
1553
|
get notificationLevel(): NotificationLevel;
|
1497
|
-
get bindings(): ConversationBindings;
|
1498
|
-
get limits(): ConversationLimits;
|
1499
1554
|
/**
|
1500
|
-
*
|
1501
|
-
*/
|
1502
|
-
get state(): ConversationState | undefined;
|
1503
|
-
/**
|
1504
|
-
* Load and subscribe to this conversation and do not subscribe to its participants and messages.
|
1505
|
-
* This or _subscribeStreams will need to be called before any events on conversation will fire.
|
1555
|
+
* Conversation bindings. Undocumented feature (for now).
|
1506
1556
|
* @internal
|
1507
1557
|
*/
|
1508
|
-
|
1558
|
+
get bindings(): ConversationBindings;
|
1509
1559
|
/**
|
1510
|
-
*
|
1511
|
-
* This or _subscribe will need to be called before any events on the conversation will fire.
|
1512
|
-
* This will need to be called before any events on participants or messages will fire
|
1513
|
-
* @internal
|
1560
|
+
* Current conversation limits.
|
1514
1561
|
*/
|
1515
|
-
|
1562
|
+
get limits(): ConversationLimits;
|
1516
1563
|
/**
|
1517
|
-
*
|
1518
|
-
* @internal
|
1564
|
+
* State of the conversation.
|
1519
1565
|
*/
|
1520
|
-
|
1521
|
-
void,
|
1522
|
-
void
|
1523
|
-
]>;
|
1566
|
+
get state(): ConversationState | undefined;
|
1524
1567
|
/**
|
1525
|
-
*
|
1568
|
+
* Source of the conversation update.
|
1526
1569
|
* @internal
|
1527
1570
|
*/
|
1528
|
-
|
1571
|
+
get _statusSource(): ConversationsDataSource;
|
1529
1572
|
/**
|
1530
|
-
*
|
1531
|
-
* @
|
1573
|
+
* Preprocess the update object.
|
1574
|
+
* @param update The update object received from Sync.
|
1575
|
+
* @param conversationSid The SID of the conversation in question.
|
1532
1576
|
*/
|
1533
|
-
_statusSource(): ConversationsDataSource;
|
1534
1577
|
private static preprocessUpdate;
|
1535
|
-
/**
|
1536
|
-
* Update the local conversation object with new values.
|
1537
|
-
* @internal
|
1538
|
-
*/
|
1539
|
-
_update(update: any): void;
|
1540
|
-
/**
|
1541
|
-
* @internal
|
1542
|
-
*/
|
1543
|
-
private _onMessageAdded;
|
1544
|
-
private _setLastReadMessageIndex;
|
1545
1578
|
/**
|
1546
1579
|
* Add a participant to the conversation by its identity.
|
1547
1580
|
* @param identity Identity of the Client to add.
|
1548
1581
|
* @param attributes Attributes to be attached to the participant.
|
1582
|
+
* @returns The added participant.
|
1549
1583
|
*/
|
1550
|
-
add(identity: string, attributes?: JSONValue): Promise<
|
1584
|
+
add(identity: string, attributes?: JSONValue): Promise<Participant>;
|
1551
1585
|
/**
|
1552
1586
|
* Add a non-chat participant to the conversation.
|
1553
1587
|
* @param proxyAddress Proxy (Twilio) address of the participant.
|
1554
1588
|
* @param address User address of the participant.
|
1555
1589
|
* @param attributes Attributes to be attached to the participant.
|
1556
|
-
* @param bindingOptions Options for adding email participants - name and
|
1590
|
+
* @param bindingOptions Options for adding email participants - name and
|
1591
|
+
* CC/To level.
|
1592
|
+
* @returns The added participant.
|
1557
1593
|
*/
|
1558
|
-
addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<
|
1594
|
+
addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<Participant>;
|
1559
1595
|
/**
|
1560
|
-
* Advance the conversation's last read message index to the current read
|
1561
|
-
* Rejects if the user is not a participant of the conversation.
|
1562
|
-
*
|
1596
|
+
* Advance the conversation's last read message index to the current read
|
1597
|
+
* horizon. Rejects if the user is not a participant of the conversation. Last
|
1598
|
+
* read message index is updated only if the new index value is higher than
|
1599
|
+
* the previous.
|
1563
1600
|
* @param index Message index to advance to.
|
1564
1601
|
* @return Resulting unread messages count in the conversation.
|
1565
1602
|
*/
|
@@ -1574,10 +1611,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1574
1611
|
getAttributes(): Promise<JSONValue>;
|
1575
1612
|
/**
|
1576
1613
|
* Returns messages from the conversation using the paginator interface.
|
1577
|
-
* @param pageSize Number of messages to return in a single chunk. Default is
|
1578
|
-
*
|
1579
|
-
* @param
|
1580
|
-
*
|
1614
|
+
* @param pageSize Number of messages to return in a single chunk. Default is
|
1615
|
+
* 30.
|
1616
|
+
* @param anchor Index of the newest message to fetch. Default is from the
|
1617
|
+
* end.
|
1618
|
+
* @param direction Query direction. By default, it queries backwards
|
1619
|
+
* from newer to older. The `"forward"` value will query in the opposite
|
1620
|
+
* direction.
|
1581
1621
|
* @return A page of messages.
|
1582
1622
|
*/
|
1583
1623
|
getMessages(pageSize?: number, anchor?: number, direction?: "backwards" | "forward"): Promise<Paginator<Message>>;
|
@@ -1588,12 +1628,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1588
1628
|
/**
|
1589
1629
|
* Get conversation participants count.
|
1590
1630
|
*
|
1591
|
-
* This method is semi-realtime. This means that this data will be eventually
|
1592
|
-
* but will also be possibly incorrect for a few seconds. The
|
1593
|
-
* provide real time events for counter values
|
1631
|
+
* This method is semi-realtime. This means that this data will be eventually
|
1632
|
+
* correct, but will also be possibly incorrect for a few seconds. The
|
1633
|
+
* Conversations system does not provide real time events for counter values
|
1634
|
+
* changes.
|
1594
1635
|
*
|
1595
|
-
* This is useful for any UI badges, but it is not recommended to build any
|
1596
|
-
* logic based on these counters being accurate in real time.
|
1636
|
+
* This is useful for any UI badges, but it is not recommended to build any
|
1637
|
+
* core application logic based on these counters being accurate in real time.
|
1597
1638
|
*/
|
1598
1639
|
getParticipantsCount(): Promise<number>;
|
1599
1640
|
/**
|
@@ -1609,28 +1650,30 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1609
1650
|
/**
|
1610
1651
|
* Get the total message count in the conversation.
|
1611
1652
|
*
|
1612
|
-
* This method is semi-realtime. This means that this data will be eventually
|
1613
|
-
* but will also be possibly incorrect for a few seconds. The
|
1614
|
-
* provide real time events for counter values
|
1653
|
+
* This method is semi-realtime. This means that this data will be eventually
|
1654
|
+
* correct, but will also be possibly incorrect for a few seconds. The
|
1655
|
+
* Conversations system does not provide real time events for counter values
|
1656
|
+
* changes.
|
1615
1657
|
*
|
1616
|
-
* This is useful for any UI badges, but it is not recommended to build any
|
1617
|
-
* logic based on these counters being accurate in real time.
|
1658
|
+
* This is useful for any UI badges, but it is not recommended to build any
|
1659
|
+
* core application logic based on these counters being accurate in real time.
|
1618
1660
|
*/
|
1619
1661
|
getMessagesCount(): Promise<number>;
|
1620
1662
|
/**
|
1621
|
-
* Get unread messages count for the user if they are a participant of this
|
1622
|
-
* Rejects if the user is not a participant of the conversation.
|
1663
|
+
* Get unread messages count for the user if they are a participant of this
|
1664
|
+
* conversation. Rejects if the user is not a participant of the conversation.
|
1623
1665
|
*
|
1624
1666
|
* Use this method to obtain the number of unread messages together with
|
1625
1667
|
* {@link Conversation.updateLastReadMessageIndex} instead of relying on the
|
1626
1668
|
* message indices which may have gaps. See {@link Message.index} for details.
|
1627
1669
|
*
|
1628
|
-
* This method is semi-realtime. This means that this data will be eventually
|
1629
|
-
* but will also be possibly incorrect for a few seconds. The
|
1630
|
-
* provide real time events for counter values
|
1670
|
+
* This method is semi-realtime. This means that this data will be eventually
|
1671
|
+
* correct, but will also be possibly incorrect for a few seconds. The
|
1672
|
+
* Conversations system does not provide real time events for counter values
|
1673
|
+
* changes.
|
1631
1674
|
*
|
1632
|
-
* This is useful for any UI badges, but it is not recommended to build any
|
1633
|
-
* logic based on these counters being accurate in real time.
|
1675
|
+
* This is useful for any UI badges, but it is not recommended to build any
|
1676
|
+
* core application logic based on these counters being accurate in real time.
|
1634
1677
|
*/
|
1635
1678
|
getUnreadMessagesCount(): Promise<number | null>;
|
1636
1679
|
/**
|
@@ -1652,7 +1695,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1652
1695
|
/**
|
1653
1696
|
* Send a message to the conversation.
|
1654
1697
|
* @param message Message body for the text message,
|
1655
|
-
* `FormData` or {@link SendMediaOptions} for media content. Sending FormData
|
1698
|
+
* `FormData` or {@link SendMediaOptions} for media content. Sending FormData
|
1699
|
+
* is supported only with the browser engine.
|
1656
1700
|
* @param messageAttributes Attributes for the message.
|
1657
1701
|
* @param emailOptions Email options for the message.
|
1658
1702
|
* @return Index of the new message.
|
@@ -1660,12 +1704,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1660
1704
|
sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<number>;
|
1661
1705
|
/**
|
1662
1706
|
* New interface to prepare for sending a message.
|
1663
|
-
* Use instead of
|
1707
|
+
* Use this instead of {@link Message.sendMessage}.
|
1664
1708
|
* @return A MessageBuilder to help set all message sending options.
|
1665
1709
|
*/
|
1666
1710
|
prepareMessage(): MessageBuilder;
|
1667
1711
|
/**
|
1668
|
-
* Set last read message index of the conversation to the index of the last
|
1712
|
+
* Set last read message index of the conversation to the index of the last
|
1713
|
+
* known message.
|
1669
1714
|
* @return Resulting unread messages count in the conversation.
|
1670
1715
|
*/
|
1671
1716
|
setAllMessagesRead(): Promise<number>;
|
@@ -1680,8 +1725,10 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1680
1725
|
*/
|
1681
1726
|
setUserNotificationLevel(notificationLevel: NotificationLevel): Promise<void>;
|
1682
1727
|
/**
|
1683
|
-
* Send a notification to the server indicating that this client is currently
|
1684
|
-
* Typing ended notification is sent after a
|
1728
|
+
* Send a notification to the server indicating that this client is currently
|
1729
|
+
* typing in this conversation. Typing ended notification is sent after a
|
1730
|
+
* while automatically, but by calling this method again you ensure that
|
1731
|
+
* typing ended is not received.
|
1685
1732
|
*/
|
1686
1733
|
typing(): Promise<void>;
|
1687
1734
|
/**
|
@@ -1696,21 +1743,61 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1696
1743
|
updateFriendlyName(friendlyName: string): Promise<Conversation>;
|
1697
1744
|
/**
|
1698
1745
|
* Set the last read message index to the current read horizon.
|
1699
|
-
* @param index Message index to set as last read.
|
1700
|
-
*
|
1746
|
+
* @param index Message index to set as last read. If null is provided, then
|
1747
|
+
* the behavior is identical to {@link Conversation.setAllMessagesUnread}.
|
1701
1748
|
* @returns Resulting unread messages count in the conversation.
|
1702
1749
|
*/
|
1703
1750
|
updateLastReadMessageIndex(index: number | null): Promise<number>;
|
1704
1751
|
/**
|
1705
1752
|
* Update the unique name of the conversation.
|
1706
|
-
* @param uniqueName New unique name for the conversation. Setting unique name
|
1753
|
+
* @param uniqueName New unique name for the conversation. Setting unique name
|
1754
|
+
* to null removes it.
|
1707
1755
|
*/
|
1708
1756
|
updateUniqueName(uniqueName: string | null): Promise<Conversation>;
|
1757
|
+
/**
|
1758
|
+
* Load and subscribe to this conversation and do not subscribe to its
|
1759
|
+
* participants and messages. This or _subscribeStreams will need to be called
|
1760
|
+
* before any events on conversation will fire.
|
1761
|
+
* @internal
|
1762
|
+
*/
|
1763
|
+
_subscribe(): Promise<SyncDocument>;
|
1764
|
+
/**
|
1765
|
+
* Load the attributes of this conversation and instantiate its participants
|
1766
|
+
* and messages. This or _subscribe will need to be called before any events
|
1767
|
+
* on the conversation will fire. This will need to be called before any
|
1768
|
+
* events on participants or messages will fire
|
1769
|
+
* @internal
|
1770
|
+
*/
|
1771
|
+
_subscribeStreams(): Promise<void>;
|
1772
|
+
/**
|
1773
|
+
* Stop listening for and firing events on this conversation.
|
1774
|
+
* @internal
|
1775
|
+
*/
|
1776
|
+
_unsubscribe(): Promise<[
|
1777
|
+
void,
|
1778
|
+
void
|
1779
|
+
]>;
|
1780
|
+
/**
|
1781
|
+
* Set conversation status.
|
1782
|
+
* @internal
|
1783
|
+
*/
|
1784
|
+
_setStatus(status: ConversationStatus, source: ConversationsDataSource): void;
|
1785
|
+
/**
|
1786
|
+
* Update the local conversation object with new values.
|
1787
|
+
* @internal
|
1788
|
+
*/
|
1789
|
+
_update(update: any): void;
|
1790
|
+
/**
|
1791
|
+
* Handle onMessageAdded event.
|
1792
|
+
*/
|
1793
|
+
private _onMessageAdded;
|
1794
|
+
/**
|
1795
|
+
* Set last read message index.
|
1796
|
+
* @param index New index to set.
|
1797
|
+
*/
|
1798
|
+
private _setLastReadMessageIndex;
|
1709
1799
|
}
|
1710
|
-
type ConversationsDataSource = "sync" | "
|
1711
|
-
/**
|
1712
|
-
* Push notification type.
|
1713
|
-
*/
|
1800
|
+
type ConversationsDataSource = "sync" | "rest";
|
1714
1801
|
type PushNotificationType = "twilio.conversations.new_message" | "twilio.conversations.added_to_conversation" | "twilio.conversations.removed_from_conversation";
|
1715
1802
|
interface PushNotificationDescriptor {
|
1716
1803
|
title: string | null;
|
@@ -1729,6 +1816,10 @@ interface PushNotificationData {
|
|
1729
1816
|
* SID of the conversation.
|
1730
1817
|
*/
|
1731
1818
|
conversationSid?: string;
|
1819
|
+
/**
|
1820
|
+
* Title of the conversation.
|
1821
|
+
*/
|
1822
|
+
conversationTitle?: string;
|
1732
1823
|
/**
|
1733
1824
|
* Index of the message in the conversation.
|
1734
1825
|
*/
|
@@ -1737,6 +1828,14 @@ interface PushNotificationData {
|
|
1737
1828
|
* SID of the message in the conversation.
|
1738
1829
|
*/
|
1739
1830
|
messageSid?: string;
|
1831
|
+
/**
|
1832
|
+
* Media of the notification
|
1833
|
+
*/
|
1834
|
+
media?: Media;
|
1835
|
+
/**
|
1836
|
+
* Amount of the attached media of the message.
|
1837
|
+
*/
|
1838
|
+
mediaCount?: number;
|
1740
1839
|
}
|
1741
1840
|
/**
|
1742
1841
|
* Push notification for a Conversations client.
|
@@ -1775,6 +1874,9 @@ declare class PushNotification {
|
|
1775
1874
|
*/
|
1776
1875
|
constructor(data: PushNotificationDescriptor);
|
1777
1876
|
}
|
1877
|
+
/**
|
1878
|
+
* Client events.
|
1879
|
+
*/
|
1778
1880
|
type ClientEvents = {
|
1779
1881
|
conversationAdded: (conversation: Conversation) => void;
|
1780
1882
|
conversationJoined: (conversation: Conversation) => void;
|
@@ -1796,7 +1898,7 @@ type ClientEvents = {
|
|
1796
1898
|
message: Message;
|
1797
1899
|
updateReasons: MessageUpdateReason[];
|
1798
1900
|
}) => void;
|
1799
|
-
tokenAboutToExpire: (
|
1901
|
+
tokenAboutToExpire: () => void;
|
1800
1902
|
tokenExpired: () => void;
|
1801
1903
|
typingEnded: (participant: Participant) => void;
|
1802
1904
|
typingStarted: (participant: Participant) => void;
|
@@ -1807,22 +1909,22 @@ type ClientEvents = {
|
|
1807
1909
|
user: User;
|
1808
1910
|
updateReasons: UserUpdateReason[];
|
1809
1911
|
}) => void;
|
1810
|
-
stateChanged: (state
|
1811
|
-
|
1812
|
-
|
1813
|
-
terminal: boolean;
|
1814
|
-
message: string;
|
1815
|
-
httpStatusCode?: number;
|
1816
|
-
errorCode?: number;
|
1912
|
+
stateChanged: ({ state, error }: {
|
1913
|
+
state: State;
|
1914
|
+
error?: ConnectionError;
|
1817
1915
|
}) => void;
|
1916
|
+
connectionStateChanged: (state: TwilsockConnectionState) => void;
|
1917
|
+
connectionError: (data: ConnectionError) => void;
|
1818
1918
|
};
|
1819
1919
|
/**
|
1820
1920
|
* Connection state of the client. Possible values are as follows:
|
1821
1921
|
* * `'connecting'` - client is offline and connection attempt is in process
|
1822
1922
|
* * `'connected'` - client is online and ready
|
1823
1923
|
* * `'disconnecting'` - client is going offline as disconnection is in process
|
1824
|
-
* * `'disconnected'` - client is offline and no connection attempt is in
|
1825
|
-
*
|
1924
|
+
* * `'disconnected'` - client is offline and no connection attempt is in
|
1925
|
+
* process
|
1926
|
+
* * `'denied'` - client connection is denied because of invalid JWT access
|
1927
|
+
* token. User must refresh token in order to proceed
|
1826
1928
|
*/
|
1827
1929
|
type ConnectionState = TwilsockConnectionState;
|
1828
1930
|
/**
|
@@ -1837,6 +1939,9 @@ type State = "failed" | "initialized";
|
|
1837
1939
|
* * `'apn'`
|
1838
1940
|
*/
|
1839
1941
|
type NotificationsChannelType = ChannelType;
|
1942
|
+
/**
|
1943
|
+
* Level of logging.
|
1944
|
+
*/
|
1840
1945
|
type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent";
|
1841
1946
|
/**
|
1842
1947
|
* Conversations client options.
|
@@ -1891,43 +1996,9 @@ interface CreateConversationOptions {
|
|
1891
1996
|
*/
|
1892
1997
|
declare class Client extends ReplayEventEmitter<ClientEvents> {
|
1893
1998
|
/**
|
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.
|
1999
|
+
* Fired when a conversation becomes visible to the client. The event is also
|
2000
|
+
* triggered when the client creates a new conversation.
|
2001
|
+
* Fired for all conversations that the client has joined.
|
1931
2002
|
*
|
1932
2003
|
* Parameters:
|
1933
2004
|
* 1. {@link Conversation} `conversation` - the conversation in question
|
@@ -1959,14 +2030,17 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
1959
2030
|
*/
|
1960
2031
|
static readonly conversationRemoved = "conversationRemoved";
|
1961
2032
|
/**
|
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
|
2033
|
+
* Fired when the attributes or the metadata of a conversation have been
|
2034
|
+
* updated. During conversation's creation and initialization, this event
|
2035
|
+
* might be fired multiple times for same joined or created conversation as
|
2036
|
+
* new data is arriving from different sources.
|
1965
2037
|
*
|
1966
2038
|
* Parameters:
|
1967
|
-
* 1. object `data` - info object provided with the event. It has the
|
2039
|
+
* 1. object `data` - info object provided with the event. It has the
|
2040
|
+
* following properties:
|
1968
2041
|
* * {@link Conversation} `conversation` - the conversation in question
|
1969
|
-
* * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
|
2042
|
+
* * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
|
2043
|
+
* for the update
|
1970
2044
|
* @event
|
1971
2045
|
*/
|
1972
2046
|
static readonly conversationUpdated = "conversationUpdated";
|
@@ -1990,9 +2064,11 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
1990
2064
|
* Fired when a participant's fields have been updated.
|
1991
2065
|
*
|
1992
2066
|
* Parameters:
|
1993
|
-
* 1. object `data` - info object provided with the event. It has the
|
2067
|
+
* 1. object `data` - info object provided with the event. It has the
|
2068
|
+
* following properties:
|
1994
2069
|
* * {@link Participant} `participant` - the participant in question
|
1995
|
-
* * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
|
2070
|
+
* * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
|
2071
|
+
* for the update
|
1996
2072
|
* @event
|
1997
2073
|
*/
|
1998
2074
|
static readonly participantUpdated = "participantUpdated";
|
@@ -2016,16 +2092,16 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2016
2092
|
* Fired when the fields of an existing message are updated with new values.
|
2017
2093
|
*
|
2018
2094
|
* Parameters:
|
2019
|
-
* 1. object `data` - info object provided with the event. It has the
|
2095
|
+
* 1. object `data` - info object provided with the event. It has the
|
2096
|
+
* following properties:
|
2020
2097
|
* * {@link Message} `message` - the message in question
|
2021
|
-
* * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
|
2098
|
+
* * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
|
2099
|
+
* the update
|
2022
2100
|
* @event
|
2023
2101
|
*/
|
2024
2102
|
static readonly messageUpdated = "messageUpdated";
|
2025
2103
|
/**
|
2026
2104
|
* Fired when the token is about to expire and needs to be updated.
|
2027
|
-
* * Parameters:
|
2028
|
-
* 1. number `message` - token's time to live
|
2029
2105
|
* @event
|
2030
2106
|
*/
|
2031
2107
|
static readonly tokenAboutToExpire = "tokenAboutToExpire";
|
@@ -2051,10 +2127,12 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2051
2127
|
*/
|
2052
2128
|
static readonly typingStarted = "typingStarted";
|
2053
2129
|
/**
|
2054
|
-
* Fired when the client has received (and parsed) a push notification via one
|
2130
|
+
* Fired when the client has received (and parsed) a push notification via one
|
2131
|
+
* of the push channels (apn or fcm).
|
2055
2132
|
*
|
2056
2133
|
* Parameters:
|
2057
|
-
* 1. {@link PushNotification} `pushNotification` - the push notification in
|
2134
|
+
* 1. {@link PushNotification} `pushNotification` - the push notification in
|
2135
|
+
* question
|
2058
2136
|
* @event
|
2059
2137
|
*/
|
2060
2138
|
static readonly pushNotification = "pushNotification";
|
@@ -2075,12 +2153,15 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2075
2153
|
*/
|
2076
2154
|
static readonly userUnsubscribed = "userUnsubscribed";
|
2077
2155
|
/**
|
2078
|
-
* Fired when the properties or the reachability status of a user have been
|
2156
|
+
* Fired when the properties or the reachability status of a user have been
|
2157
|
+
* updated.
|
2079
2158
|
*
|
2080
2159
|
* Parameters:
|
2081
|
-
* 1. object `data` - info object provided with the event. It has the
|
2160
|
+
* 1. object `data` - info object provided with the event. It has the
|
2161
|
+
* following properties:
|
2082
2162
|
* * {@link User} `user` - the user in question
|
2083
|
-
* * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the
|
2163
|
+
* * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the
|
2164
|
+
* update
|
2084
2165
|
* @event
|
2085
2166
|
*/
|
2086
2167
|
static readonly userUpdated = "userUpdated";
|
@@ -2088,14 +2169,17 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2088
2169
|
* Fired when the state of the client has been changed.
|
2089
2170
|
*
|
2090
2171
|
* Parameters:
|
2091
|
-
* 1.
|
2172
|
+
* 1. object `data` - info object provided with the event. It has the
|
2173
|
+
* following properties:
|
2174
|
+
* * {@link State} `state` - the new client state
|
2175
|
+
* * Error? `error` - the initialization error if present
|
2092
2176
|
* @event
|
2093
2177
|
*/
|
2094
2178
|
static readonly stateChanged = "stateChanged";
|
2095
2179
|
/**
|
2096
2180
|
* Fired when the connection state of the client has been changed.
|
2097
2181
|
*
|
2098
|
-
*
|
2182
|
+
* Parameters:
|
2099
2183
|
* 1. {@link ConnectionState} `state` - the new connection state
|
2100
2184
|
* @event
|
2101
2185
|
*/
|
@@ -2104,7 +2188,8 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2104
2188
|
* Fired when the connection is interrupted for an unexpected reason.
|
2105
2189
|
*
|
2106
2190
|
* Parameters:
|
2107
|
-
* 1. object `data` - info object provided with the event. It has the
|
2191
|
+
* 1. object `data` - info object provided with the event. It has the
|
2192
|
+
* following properties:
|
2108
2193
|
* * boolean `terminal` - Twilsock will stop connection attempts if true
|
2109
2194
|
* * string `message` - the error message of the root cause
|
2110
2195
|
* * number? `httpStatusCode` - http status code if available
|
@@ -2112,6 +2197,93 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2112
2197
|
* @event
|
2113
2198
|
*/
|
2114
2199
|
static readonly connectionError = "connectionError";
|
2200
|
+
/**
|
2201
|
+
* Current version of the Conversations client.
|
2202
|
+
*/
|
2203
|
+
static readonly version: string;
|
2204
|
+
/**
|
2205
|
+
* Logger instance.
|
2206
|
+
*/
|
2207
|
+
private static readonly _logger;
|
2208
|
+
/**
|
2209
|
+
* Supported push notification channels.
|
2210
|
+
*/
|
2211
|
+
private static readonly _supportedPushChannels;
|
2212
|
+
/**
|
2213
|
+
* Supported push data fields.
|
2214
|
+
*/
|
2215
|
+
private static readonly _supportedPushDataFields;
|
2216
|
+
/**
|
2217
|
+
* Current version of the Conversations client.
|
2218
|
+
*/
|
2219
|
+
readonly version: string;
|
2220
|
+
/**
|
2221
|
+
* Client connection state.
|
2222
|
+
*/
|
2223
|
+
connectionState: ConnectionState;
|
2224
|
+
/**
|
2225
|
+
* Promise that resolves on successful initialization.
|
2226
|
+
*/
|
2227
|
+
private readonly _ensureReady;
|
2228
|
+
/**
|
2229
|
+
* Options passed to the client.
|
2230
|
+
*/
|
2231
|
+
private readonly _options;
|
2232
|
+
/**
|
2233
|
+
* Client service objects.
|
2234
|
+
*/
|
2235
|
+
private readonly _services;
|
2236
|
+
/**
|
2237
|
+
* The user of the client.
|
2238
|
+
*/
|
2239
|
+
private readonly _myself;
|
2240
|
+
/**
|
2241
|
+
* Resolves the {@link Client._ensureReady} promise.
|
2242
|
+
*/
|
2243
|
+
private _resolveEnsureReady;
|
2244
|
+
/**
|
2245
|
+
* Rejects the {@link Client._ensureReady} promise.
|
2246
|
+
*/
|
2247
|
+
private _rejectEnsureReady;
|
2248
|
+
/**
|
2249
|
+
* The current token of the client.
|
2250
|
+
*/
|
2251
|
+
private _fpaToken;
|
2252
|
+
/**
|
2253
|
+
* The constructed configuration object.
|
2254
|
+
*/
|
2255
|
+
private _configuration;
|
2256
|
+
/**
|
2257
|
+
* The Conversations entity.
|
2258
|
+
*/
|
2259
|
+
private _conversationsEntity;
|
2260
|
+
/**
|
2261
|
+
* Promise that resolves when initial conversations are fetched.
|
2262
|
+
*/
|
2263
|
+
private _conversationsPromise;
|
2264
|
+
/**
|
2265
|
+
* Returned Conversations instance is not yet fully initialized. Calling any
|
2266
|
+
* operations will block until it is. Use connection events to monitor when
|
2267
|
+
* client becomes fully available (connectionStateChanged with state
|
2268
|
+
* 'connected') or not available (connectionStateChange with state 'denied',
|
2269
|
+
* event tokenExpired, event connectionError).
|
2270
|
+
*
|
2271
|
+
* @param fpaToken Access token
|
2272
|
+
* @param options Options to customize the Client
|
2273
|
+
* @returns A not yet fully-initialized client.
|
2274
|
+
*/
|
2275
|
+
constructor(fpaToken: string, options?: ClientOptions | null);
|
2276
|
+
/**
|
2277
|
+
* Information of the logged-in user. Before client initialization, returns an
|
2278
|
+
* uninitialized user. Will trigger a {@link Client.userUpdated} event after
|
2279
|
+
* initialization.
|
2280
|
+
*/
|
2281
|
+
get user(): User;
|
2282
|
+
/**
|
2283
|
+
* Client reachability state. Throws an error if accessed before the client
|
2284
|
+
* initialization was completed.
|
2285
|
+
*/
|
2286
|
+
get reachabilityEnabled(): boolean;
|
2115
2287
|
/**
|
2116
2288
|
* @deprecated Call constructor directly.
|
2117
2289
|
*
|
@@ -2133,20 +2305,21 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2133
2305
|
*/
|
2134
2306
|
static create(token: string, options?: ClientOptions | null): Promise<Client>;
|
2135
2307
|
/**
|
2136
|
-
*
|
2137
|
-
*
|
2138
|
-
*
|
2308
|
+
* Static method for push notification payload parsing. Returns parsed push as
|
2309
|
+
* a {@link PushNotification} object.
|
2310
|
+
* @param notificationPayload Push notification payload.
|
2139
2311
|
*/
|
2140
|
-
|
2312
|
+
static parsePushNotification(notificationPayload: any): PushNotification;
|
2141
2313
|
/**
|
2142
|
-
*
|
2143
|
-
*
|
2314
|
+
* Static method for parsing push notification chat data.
|
2315
|
+
* @param data Data to parse
|
2144
2316
|
*/
|
2145
|
-
|
2146
|
-
|
2147
|
-
|
2148
|
-
|
2149
|
-
|
2317
|
+
private static _parsePushNotificationChatData;
|
2318
|
+
/**
|
2319
|
+
* Populate the client with init registrations.
|
2320
|
+
* @param reg The init registration to populate.
|
2321
|
+
*/
|
2322
|
+
static populateInitRegistrations(reg: InitRegistration): void;
|
2150
2323
|
/**
|
2151
2324
|
* Gracefully shut down the client.
|
2152
2325
|
*/
|
@@ -2161,6 +2334,12 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2161
2334
|
* @param conversationSid Conversation sid
|
2162
2335
|
*/
|
2163
2336
|
getConversationBySid(conversationSid: string): Promise<Conversation>;
|
2337
|
+
/**
|
2338
|
+
* Peek a conversation by its SID.
|
2339
|
+
* @param conversationSid Conversation sid
|
2340
|
+
* @internal
|
2341
|
+
*/
|
2342
|
+
peekConversationBySid(conversationSid: string): Promise<Conversation>;
|
2164
2343
|
/**
|
2165
2344
|
* Get a known conversation by its unique identifier name.
|
2166
2345
|
* @param uniqueName The unique identifier name of the conversation.
|
@@ -2179,7 +2358,8 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2179
2358
|
/**
|
2180
2359
|
* Register for push notifications.
|
2181
2360
|
* @param channelType Channel type.
|
2182
|
-
* @param registrationId Push notification ID provided by the FCM/APNS service
|
2361
|
+
* @param registrationId Push notification ID provided by the FCM/APNS service
|
2362
|
+
* on the platform.
|
2183
2363
|
*/
|
2184
2364
|
setPushRegistrationId(channelType: NotificationsChannelType, registrationId: string): Promise<void>;
|
2185
2365
|
/**
|
@@ -2192,27 +2372,29 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2192
2372
|
* Clear existing registrations directly using provided device token.
|
2193
2373
|
* This is useful to ensure stopped subscriptions without resubscribing.
|
2194
2374
|
*
|
2195
|
-
* This function goes completely beside the state machine and removes all
|
2196
|
-
*
|
2375
|
+
* This function goes completely beside the state machine and removes all
|
2376
|
+
* registrations.
|
2377
|
+
* Use with caution: if it races with current state machine operations,
|
2378
|
+
* madness will ensue.
|
2197
2379
|
*
|
2198
2380
|
* @param channelType Channel type.
|
2199
|
-
* @param registrationId Push notification ID provided by the FCM/APNS service
|
2381
|
+
* @param registrationId Push notification ID provided by the FCM/APNS service
|
2382
|
+
* on the platform.
|
2200
2383
|
*/
|
2201
2384
|
removePushRegistrations(channelType: ChannelType, registrationId: string): Promise<void>;
|
2202
|
-
private static parsePushNotificationChatData;
|
2203
2385
|
/**
|
2204
|
-
*
|
2205
|
-
* @param notificationPayload Push notification payload.
|
2386
|
+
* Current version of the Conversations client.
|
2206
2387
|
*/
|
2207
|
-
static parsePushNotification(notificationPayload: any): PushNotification;
|
2208
2388
|
parsePushNotification: typeof Client.parsePushNotification;
|
2209
2389
|
/**
|
2210
|
-
* Handle push notification payload parsing and emit the
|
2390
|
+
* Handle push notification payload parsing and emit the
|
2391
|
+
* {@link Client.pushNotification} event on this {@link Client} instance.
|
2211
2392
|
* @param notificationPayload Push notification payload
|
2212
2393
|
*/
|
2213
2394
|
handlePushNotification(notificationPayload: any): Promise<void>;
|
2214
2395
|
/**
|
2215
|
-
* Gets a user with the given identity. If it's in the subscribed list, then
|
2396
|
+
* Gets a user with the given identity. If it's in the subscribed list, then
|
2397
|
+
* return the user object from it;
|
2216
2398
|
* if not, then subscribe and add user to the subscribed list.
|
2217
2399
|
* @param identity Identity of the user.
|
2218
2400
|
* @returns A fully initialized user.
|
@@ -2222,6 +2404,32 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2222
2404
|
* Get a list of subscribed user objects.
|
2223
2405
|
*/
|
2224
2406
|
getSubscribedUsers(): Promise<Array<User>>;
|
2407
|
+
/**
|
2408
|
+
* Get content URLs for all media attachments in the given set of media sids
|
2409
|
+
* using a single operation.
|
2410
|
+
* @param mediaSids Set of media sids to query for the content URL.
|
2411
|
+
*/
|
2412
|
+
getTemporaryContentUrlsForMediaSids(mediaSids: string[]): CancellablePromise<Map<string, string>>;
|
2413
|
+
/**
|
2414
|
+
* Get content URLs for all media attachments in the given set using a single
|
2415
|
+
* operation.
|
2416
|
+
* @param contentSet Set of media attachments to query content URLs.
|
2417
|
+
*/
|
2418
|
+
getTemporaryContentUrlsForMedia(contentSet: Media[]): CancellablePromise<Map<string, string>>;
|
2419
|
+
/**
|
2420
|
+
* Initialize the client.
|
2421
|
+
*/
|
2422
|
+
private _initialize;
|
2423
|
+
/**
|
2424
|
+
* Subscribe to push notifications.
|
2425
|
+
* @param channelType The channel type to subscribe to.
|
2426
|
+
*/
|
2427
|
+
private _subscribeToPushNotifications;
|
2428
|
+
/**
|
2429
|
+
* Unsubscribe from push notifications.
|
2430
|
+
* @param channelType The channel type to unsubscribe from.
|
2431
|
+
*/
|
2432
|
+
private _unsubscribeFromPushNotifications;
|
2225
2433
|
}
|
2226
2434
|
declare class NotificationTypes {
|
2227
2435
|
static readonly TYPING_INDICATOR = "twilio.ipmsg.typing_indicator";
|