@twilio/conversations 3.0.0-rc.1 → 3.0.0-rc.7
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 +57 -0
- package/README.md +7 -3
- package/builds/browser.js +1643 -1410
- package/builds/browser.js.map +1 -1
- package/builds/lib.d.ts +270 -182
- package/builds/lib.js +1643 -1410
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +3719 -4034
- package/builds/twilio-conversations.min.js +1 -16
- package/dist/aggregated-delivery-receipt.js.map +1 -1
- package/dist/client.js +53 -35
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js.map +1 -1
- package/dist/conversation.js +405 -376
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +10 -11
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +9 -9
- 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/detailed-delivery-receipt.js.map +1 -1
- package/dist/index.js +6 -4
- package/dist/index.js.map +1 -1
- package/dist/interfaces/attributes.js.map +1 -1
- package/dist/interfaces/notification-types.js.map +1 -1
- package/dist/logger.js +2 -4
- package/dist/logger.js.map +1 -1
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js.map +1 -1
- package/dist/message.js +16 -12
- package/dist/message.js.map +1 -1
- package/dist/node_modules/tslib/tslib.es6.js +1 -1
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/packages/conversations/package.json.js +1 -1
- package/dist/participant.js +2 -2
- package/dist/participant.js.map +1 -1
- package/dist/push-notification.js.map +1 -1
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.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.map +1 -1
- package/dist/user.js +1 -1
- package/dist/user.js.map +1 -1
- package/dist/util/deferred.js.map +1 -1
- package/dist/util/index.js.map +1 -1
- package/docs/assets/js/search.js +1 -1
- package/docs/classes/CancellablePromise.html +3213 -0
- package/docs/classes/Client.html +4 -10
- package/docs/classes/Conversation.html +80 -51
- package/docs/classes/Media.html +2 -2
- package/docs/classes/Message.html +6 -6
- package/docs/classes/MessageBuilder.html +2 -2
- package/docs/classes/PushNotification.html +1 -1
- package/docs/classes/UnsentMessage.html +2 -2
- package/docs/index.html +20 -25
- package/docs/interfaces/ConversationState.html +2 -2
- package/docs/interfaces/ConversationUpdatedEventArgs.html +3001 -0
- package/docs/interfaces/PushNotificationData.html +48 -0
- package/docs/modules.html +19 -24
- package/package.json +21 -19
package/builds/lib.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
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";
|
@@ -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
|
}
|
@@ -892,7 +872,7 @@ declare class Message extends ReplayEventEmitter<MessageEvents> {
|
|
892
872
|
* Get content URLs for all media attachments in the given set using a single operation.
|
893
873
|
* @param contentSet Set of media attachments to query content URLs.
|
894
874
|
*/
|
895
|
-
getTemporaryContentUrlsForMedia(contentSet: Media[]
|
875
|
+
getTemporaryContentUrlsForMedia(contentSet: Media[]): CancellablePromise<Map<string, string>>;
|
896
876
|
/**
|
897
877
|
* Get content URLs for all media attachments in the given set of media sids using a single operation.
|
898
878
|
* @param mediaSids Set of media sids to query for the content URL.
|
@@ -958,7 +938,7 @@ declare class TypingIndicator {
|
|
958
938
|
private sentUpdates;
|
959
939
|
private getConversation;
|
960
940
|
private serviceTypingTimeout;
|
961
|
-
constructor(getConversation:
|
941
|
+
constructor(getConversation: (conversationSid: string) => Promise<Conversation>, config: Configuration, services: TypingIndicatorServices);
|
962
942
|
get typingTimeout(): number;
|
963
943
|
/**
|
964
944
|
* Initialize TypingIndicator controller
|
@@ -1130,7 +1110,10 @@ declare class UnsentMessage {
|
|
1130
1110
|
private messagesEntity;
|
1131
1111
|
text?: string;
|
1132
1112
|
attributes: JSONValue;
|
1133
|
-
mediaContent: [
|
1113
|
+
mediaContent: [
|
1114
|
+
MediaCategory,
|
1115
|
+
FormData | SendMediaOptions
|
1116
|
+
][];
|
1134
1117
|
emailOptions: SendEmailOptions;
|
1135
1118
|
/**
|
1136
1119
|
* @internal
|
@@ -1208,6 +1191,9 @@ declare class MessageBuilder {
|
|
1208
1191
|
buildAndSend(): CancellablePromise<number | null>;
|
1209
1192
|
private getPayloadContentType;
|
1210
1193
|
}
|
1194
|
+
/**
|
1195
|
+
* Conversation events.
|
1196
|
+
*/
|
1211
1197
|
type ConversationEvents = {
|
1212
1198
|
participantJoined: (participant: Participant) => void;
|
1213
1199
|
participantLeft: (participant: Participant) => void;
|
@@ -1229,55 +1215,28 @@ type ConversationEvents = {
|
|
1229
1215
|
}) => void;
|
1230
1216
|
removed: (conversation: Conversation) => void;
|
1231
1217
|
};
|
1232
|
-
interface ConversationServices {
|
1233
|
-
users: Users;
|
1234
|
-
typingIndicator: TypingIndicator;
|
1235
|
-
network: Network;
|
1236
|
-
mcsClient: McsClient;
|
1237
|
-
syncClient: SyncClient;
|
1238
|
-
commandExecutor: CommandExecutor;
|
1239
|
-
}
|
1240
|
-
interface ConversationDescriptor {
|
1241
|
-
channel: string;
|
1242
|
-
entityName: string;
|
1243
|
-
uniqueName: string;
|
1244
|
-
attributes: JSONValue;
|
1245
|
-
createdBy?: string;
|
1246
|
-
friendlyName?: string;
|
1247
|
-
lastConsumedMessageIndex: number;
|
1248
|
-
dateCreated: Date | null;
|
1249
|
-
dateUpdated: Date | null;
|
1250
|
-
notificationLevel?: NotificationLevel;
|
1251
|
-
bindings?: ConversationBindings;
|
1252
|
-
}
|
1253
|
-
interface ConversationLinks {
|
1254
|
-
self: string;
|
1255
|
-
messages: string;
|
1256
|
-
participants: string;
|
1257
|
-
}
|
1258
1218
|
/**
|
1259
|
-
*
|
1219
|
+
* Reason for the `updated` event emission by a conversation.
|
1260
1220
|
*/
|
1261
1221
|
type ConversationUpdateReason = "attributes" | "createdBy" | "dateCreated" | "dateUpdated" | "friendlyName" | "lastReadMessageIndex" | "state" | "status" | "uniqueName" | "lastMessage" | "notificationLevel" | "bindings";
|
1262
1222
|
/**
|
1263
|
-
*
|
1264
|
-
*
|
1265
|
-
* `notParticipating` in the conversation.
|
1223
|
+
* Status of the conversation, relative to the client: whether the conversation
|
1224
|
+
* has been `joined` or the client is `notParticipating` in the conversation.
|
1266
1225
|
*/
|
1267
1226
|
type ConversationStatus = "notParticipating" | "joined";
|
1268
1227
|
/**
|
1269
|
-
*
|
1228
|
+
* User's notification level for the conversation. Determines
|
1270
1229
|
* whether the currently logged-in user will receive pushes for events
|
1271
1230
|
* in this conversation. Can be either `muted` or `default`, where
|
1272
1231
|
* `default` defers to the global service push configuration.
|
1273
1232
|
*/
|
1274
1233
|
type NotificationLevel = "default" | "muted";
|
1275
1234
|
/**
|
1276
|
-
*
|
1235
|
+
* State of the conversation.
|
1277
1236
|
*/
|
1278
1237
|
interface ConversationState {
|
1279
1238
|
/**
|
1280
|
-
*
|
1239
|
+
* Current state.
|
1281
1240
|
*/
|
1282
1241
|
current: "active" | "inactive" | "closed";
|
1283
1242
|
/**
|
@@ -1285,6 +1244,9 @@ interface ConversationState {
|
|
1285
1244
|
*/
|
1286
1245
|
dateUpdated: Date;
|
1287
1246
|
}
|
1247
|
+
/**
|
1248
|
+
* Event arguments for the `updated` event.
|
1249
|
+
*/
|
1288
1250
|
interface ConversationUpdatedEventArgs {
|
1289
1251
|
conversation: Conversation;
|
1290
1252
|
updateReasons: ConversationUpdateReason[];
|
@@ -1303,6 +1265,9 @@ interface ConversationEmailBinding {
|
|
1303
1265
|
name?: string;
|
1304
1266
|
projected_address: string;
|
1305
1267
|
}
|
1268
|
+
/**
|
1269
|
+
* Binding for SMS conversation.
|
1270
|
+
*/
|
1306
1271
|
interface ConversationSmsBinding {
|
1307
1272
|
address?: string;
|
1308
1273
|
}
|
@@ -1348,33 +1313,51 @@ interface LastMessage {
|
|
1348
1313
|
dateCreated?: Date;
|
1349
1314
|
}
|
1350
1315
|
/**
|
1351
|
-
*
|
1316
|
+
* Conversation services.
|
1317
|
+
*/
|
1318
|
+
interface ConversationServices {
|
1319
|
+
users: Users;
|
1320
|
+
typingIndicator: TypingIndicator;
|
1321
|
+
network: Network;
|
1322
|
+
mcsClient: McsClient;
|
1323
|
+
syncClient: SyncClient;
|
1324
|
+
commandExecutor: CommandExecutor;
|
1325
|
+
}
|
1326
|
+
/**
|
1327
|
+
* Conversation descriptor.
|
1328
|
+
*/
|
1329
|
+
interface ConversationDescriptor {
|
1330
|
+
channel: string;
|
1331
|
+
entityName: string;
|
1332
|
+
uniqueName: string;
|
1333
|
+
attributes: JSONValue;
|
1334
|
+
createdBy?: string;
|
1335
|
+
friendlyName?: string;
|
1336
|
+
lastConsumedMessageIndex: number;
|
1337
|
+
dateCreated: Date | null;
|
1338
|
+
dateUpdated: Date | null;
|
1339
|
+
notificationLevel?: NotificationLevel;
|
1340
|
+
bindings?: ConversationBindings;
|
1341
|
+
}
|
1342
|
+
/**
|
1343
|
+
* Conversation links.
|
1344
|
+
*/
|
1345
|
+
interface ConversationLinks {
|
1346
|
+
self: string;
|
1347
|
+
messages: string;
|
1348
|
+
participants: string;
|
1349
|
+
}
|
1350
|
+
/**
|
1351
|
+
* A conversation represents communication between multiple Conversations
|
1352
|
+
* clients.
|
1352
1353
|
*/
|
1353
1354
|
declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
1354
|
-
/**
|
1355
|
-
* Unique system identifier of the conversation.
|
1356
|
-
*/
|
1357
|
-
readonly sid: string;
|
1358
|
-
readonly links: ConversationLinks;
|
1359
|
-
private readonly configuration;
|
1360
|
-
private readonly services;
|
1361
|
-
private channelState;
|
1362
|
-
private statusSource;
|
1363
|
-
private entityPromise;
|
1364
|
-
private entityName;
|
1365
|
-
private entity;
|
1366
|
-
private messagesEntity;
|
1367
|
-
private participantsEntity;
|
1368
|
-
private readonly participants;
|
1369
|
-
/**
|
1370
|
-
* @internal
|
1371
|
-
*/
|
1372
|
-
constructor(descriptor: ConversationDescriptor, sid: string, links: ConversationLinks, configuration: Configuration, services: ConversationServices);
|
1373
1355
|
/**
|
1374
1356
|
* Fired when a participant has joined the conversation.
|
1375
1357
|
*
|
1376
1358
|
* Parameters:
|
1377
|
-
* 1. {@link Participant} `participant` - participant that joined the
|
1359
|
+
* 1. {@link Participant} `participant` - participant that joined the
|
1360
|
+
* conversation
|
1378
1361
|
* @event
|
1379
1362
|
*/
|
1380
1363
|
static readonly participantJoined = "participantJoined";
|
@@ -1382,7 +1365,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1382
1365
|
* Fired when a participant has left the conversation.
|
1383
1366
|
*
|
1384
1367
|
* Parameters:
|
1385
|
-
* 1. {@link Participant} `participant` - participant that left the
|
1368
|
+
* 1. {@link Participant} `participant` - participant that left the
|
1369
|
+
* conversation
|
1386
1370
|
* @event
|
1387
1371
|
*/
|
1388
1372
|
static readonly participantLeft = "participantLeft";
|
@@ -1390,9 +1374,12 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1390
1374
|
* Fired when data of a participant has been updated.
|
1391
1375
|
*
|
1392
1376
|
* Parameters:
|
1393
|
-
* 1. object `data` - info object provided with the event. It has the
|
1394
|
-
*
|
1395
|
-
* * {@link
|
1377
|
+
* 1. object `data` - info object provided with the event. It has the
|
1378
|
+
* following properties:
|
1379
|
+
* * {@link Participant} `participant` - participant that has received the
|
1380
|
+
* update
|
1381
|
+
* * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
|
1382
|
+
* for the update
|
1396
1383
|
* @event
|
1397
1384
|
*/
|
1398
1385
|
static readonly participantUpdated = "participantUpdated";
|
@@ -1416,9 +1403,11 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1416
1403
|
* Fired when data of a message has been updated.
|
1417
1404
|
*
|
1418
1405
|
* Parameters:
|
1419
|
-
* 1. object `data` - info object provided with the event. It has the
|
1406
|
+
* 1. object `data` - info object provided with the event. It has the
|
1407
|
+
* following properties:
|
1420
1408
|
* * {@link Message} `message` - message that has received the update
|
1421
|
-
* * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
|
1409
|
+
* * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
|
1410
|
+
* the update
|
1422
1411
|
* @event
|
1423
1412
|
*/
|
1424
1413
|
static readonly messageUpdated = "messageUpdated";
|
@@ -1426,7 +1415,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1426
1415
|
* Fired when a participant has stopped typing.
|
1427
1416
|
*
|
1428
1417
|
* Parameters:
|
1429
|
-
* 1. {@link Participant} `participant` - the participant that has stopped
|
1418
|
+
* 1. {@link Participant} `participant` - the participant that has stopped
|
1419
|
+
* typing
|
1430
1420
|
* @event
|
1431
1421
|
*/
|
1432
1422
|
static readonly typingEnded = "typingEnded";
|
@@ -1434,7 +1424,8 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1434
1424
|
* Fired when a participant has started typing.
|
1435
1425
|
*
|
1436
1426
|
* Parameters:
|
1437
|
-
* 1. {@link Participant} `participant` - the participant that has started
|
1427
|
+
* 1. {@link Participant} `participant` - the participant that has started
|
1428
|
+
* typing
|
1438
1429
|
* @event
|
1439
1430
|
*/
|
1440
1431
|
static readonly typingStarted = "typingStarted";
|
@@ -1442,20 +1433,87 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1442
1433
|
* Fired when the data of the conversation has been updated.
|
1443
1434
|
*
|
1444
1435
|
* Parameters:
|
1445
|
-
* 1. object `data` - info object provided with the event. It has the
|
1446
|
-
*
|
1447
|
-
* * {@link
|
1436
|
+
* 1. object `data` - info object provided with the event. It has the
|
1437
|
+
* following properties:
|
1438
|
+
* * {@link Conversation} `conversation` - conversation that has received
|
1439
|
+
* the update
|
1440
|
+
* * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
|
1441
|
+
* for the update
|
1448
1442
|
* @event
|
1449
1443
|
*/
|
1450
1444
|
static readonly updated = "updated";
|
1451
1445
|
/**
|
1452
|
-
* Fired when the conversation was destroyed or the currently-logged-in user
|
1446
|
+
* Fired when the conversation was destroyed or the currently-logged-in user
|
1447
|
+
* has left private conversation.
|
1453
1448
|
*
|
1454
1449
|
* Parameters:
|
1455
1450
|
* 1. {@link Conversation} `conversation` - conversation that has been removed
|
1456
1451
|
* @event
|
1457
1452
|
*/
|
1458
1453
|
static readonly removed = "removed";
|
1454
|
+
/**
|
1455
|
+
* Logger instance.
|
1456
|
+
*/
|
1457
|
+
private static readonly _logger;
|
1458
|
+
/**
|
1459
|
+
* Unique system identifier of the conversation.
|
1460
|
+
*/
|
1461
|
+
readonly sid: string;
|
1462
|
+
/**
|
1463
|
+
* Conversation links for REST requests.
|
1464
|
+
* @internal
|
1465
|
+
*/
|
1466
|
+
readonly _links: ConversationLinks;
|
1467
|
+
/**
|
1468
|
+
* Map of participants.
|
1469
|
+
* @internal
|
1470
|
+
*/
|
1471
|
+
readonly _participants: Map<string, Participant>;
|
1472
|
+
/**
|
1473
|
+
* Configuration of the client that the conversation belongs to.
|
1474
|
+
*/
|
1475
|
+
private readonly _configuration;
|
1476
|
+
/**
|
1477
|
+
* Conversation service objects.
|
1478
|
+
*/
|
1479
|
+
private readonly _services;
|
1480
|
+
/**
|
1481
|
+
* Internal state of the conversation.
|
1482
|
+
*/
|
1483
|
+
private readonly _internalState;
|
1484
|
+
/**
|
1485
|
+
* Name of the conversation entity document.
|
1486
|
+
*/
|
1487
|
+
private readonly _entityName;
|
1488
|
+
/**
|
1489
|
+
* Messages entity.
|
1490
|
+
*/
|
1491
|
+
private readonly _messagesEntity;
|
1492
|
+
/**
|
1493
|
+
* Participants entity.
|
1494
|
+
*/
|
1495
|
+
private readonly _participantsEntity;
|
1496
|
+
/**
|
1497
|
+
* Source of the most recent update.
|
1498
|
+
*/
|
1499
|
+
private _dataSource;
|
1500
|
+
/**
|
1501
|
+
* Promise for the conversation entity document.
|
1502
|
+
*/
|
1503
|
+
private _entityPromise;
|
1504
|
+
/**
|
1505
|
+
* Conversation entity document.
|
1506
|
+
*/
|
1507
|
+
private _entity;
|
1508
|
+
/**
|
1509
|
+
* @param descriptor Conversation descriptor.
|
1510
|
+
* @param sid Conversation SID.
|
1511
|
+
* @param links Conversation links for REST requests.
|
1512
|
+
* @param configuration Client configuration.
|
1513
|
+
* @param services Conversation services.
|
1514
|
+
* @internal
|
1515
|
+
*/
|
1516
|
+
constructor(descriptor: ConversationDescriptor, sid: string, links: ConversationLinks, configuration: Configuration, services: ConversationServices);
|
1459
1517
|
/**
|
1460
1518
|
* Unique name of the conversation.
|
1461
1519
|
*/
|
@@ -1496,6 +1554,10 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1496
1554
|
* User notification level for this conversation.
|
1497
1555
|
*/
|
1498
1556
|
get notificationLevel(): NotificationLevel;
|
1557
|
+
/**
|
1558
|
+
* Conversation bindings. Undocumented feature (for now).
|
1559
|
+
* @internal
|
1560
|
+
*/
|
1499
1561
|
get bindings(): ConversationBindings;
|
1500
1562
|
/**
|
1501
1563
|
* Current conversation limits.
|
@@ -1506,65 +1568,38 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1506
1568
|
*/
|
1507
1569
|
get state(): ConversationState | undefined;
|
1508
1570
|
/**
|
1509
|
-
*
|
1510
|
-
* This or _subscribeStreams will need to be called before any events on conversation will fire.
|
1571
|
+
* Source of the conversation update.
|
1511
1572
|
* @internal
|
1512
1573
|
*/
|
1513
|
-
|
1574
|
+
get _statusSource(): ConversationsDataSource;
|
1514
1575
|
/**
|
1515
|
-
*
|
1516
|
-
*
|
1517
|
-
*
|
1518
|
-
* @internal
|
1576
|
+
* Preprocess the update object.
|
1577
|
+
* @param update The update object received from Sync.
|
1578
|
+
* @param conversationSid The SID of the conversation in question.
|
1519
1579
|
*/
|
1520
|
-
_subscribeStreams(): Promise<void>;
|
1521
|
-
/**
|
1522
|
-
* Stop listening for and firing events on this conversation.
|
1523
|
-
* @internal
|
1524
|
-
*/
|
1525
|
-
_unsubscribe(): Promise<[
|
1526
|
-
void,
|
1527
|
-
void
|
1528
|
-
]>;
|
1529
|
-
/**
|
1530
|
-
* Set conversation status.
|
1531
|
-
* @internal
|
1532
|
-
*/
|
1533
|
-
_setStatus(status: ConversationStatus, source: ConversationsDataSource): void;
|
1534
|
-
/**
|
1535
|
-
* Get the source of the conversation update.
|
1536
|
-
* @internal
|
1537
|
-
*/
|
1538
|
-
_statusSource(): ConversationsDataSource;
|
1539
1580
|
private static preprocessUpdate;
|
1540
|
-
/**
|
1541
|
-
* Update the local conversation object with new values.
|
1542
|
-
* @internal
|
1543
|
-
*/
|
1544
|
-
_update(update: any): void;
|
1545
|
-
/**
|
1546
|
-
* @internal
|
1547
|
-
*/
|
1548
|
-
private _onMessageAdded;
|
1549
|
-
private _setLastReadMessageIndex;
|
1550
1581
|
/**
|
1551
1582
|
* Add a participant to the conversation by its identity.
|
1552
1583
|
* @param identity Identity of the Client to add.
|
1553
1584
|
* @param attributes Attributes to be attached to the participant.
|
1585
|
+
* @returns The added participant.
|
1554
1586
|
*/
|
1555
|
-
add(identity: string, attributes?: JSONValue): Promise<
|
1587
|
+
add(identity: string, attributes?: JSONValue): Promise<Participant>;
|
1556
1588
|
/**
|
1557
1589
|
* Add a non-chat participant to the conversation.
|
1558
1590
|
* @param proxyAddress Proxy (Twilio) address of the participant.
|
1559
1591
|
* @param address User address of the participant.
|
1560
1592
|
* @param attributes Attributes to be attached to the participant.
|
1561
|
-
* @param bindingOptions Options for adding email participants - name and
|
1593
|
+
* @param bindingOptions Options for adding email participants - name and
|
1594
|
+
* CC/To level.
|
1595
|
+
* @returns The added participant.
|
1562
1596
|
*/
|
1563
|
-
addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<
|
1597
|
+
addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<Participant>;
|
1564
1598
|
/**
|
1565
|
-
* Advance the conversation's last read message index to the current read
|
1566
|
-
* Rejects if the user is not a participant of the conversation.
|
1567
|
-
*
|
1599
|
+
* Advance the conversation's last read message index to the current read
|
1600
|
+
* horizon. Rejects if the user is not a participant of the conversation. Last
|
1601
|
+
* read message index is updated only if the new index value is higher than
|
1602
|
+
* the previous.
|
1568
1603
|
* @param index Message index to advance to.
|
1569
1604
|
* @return Resulting unread messages count in the conversation.
|
1570
1605
|
*/
|
@@ -1579,10 +1614,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1579
1614
|
getAttributes(): Promise<JSONValue>;
|
1580
1615
|
/**
|
1581
1616
|
* Returns messages from the conversation using the paginator interface.
|
1582
|
-
* @param pageSize Number of messages to return in a single chunk. Default is
|
1583
|
-
*
|
1584
|
-
* @param
|
1585
|
-
*
|
1617
|
+
* @param pageSize Number of messages to return in a single chunk. Default is
|
1618
|
+
* 30.
|
1619
|
+
* @param anchor Index of the newest message to fetch. Default is from the
|
1620
|
+
* end.
|
1621
|
+
* @param direction Query direction. By default, it queries backwards
|
1622
|
+
* from newer to older. The `"forward"` value will query in the opposite
|
1623
|
+
* direction.
|
1586
1624
|
* @return A page of messages.
|
1587
1625
|
*/
|
1588
1626
|
getMessages(pageSize?: number, anchor?: number, direction?: "backwards" | "forward"): Promise<Paginator<Message>>;
|
@@ -1593,12 +1631,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1593
1631
|
/**
|
1594
1632
|
* Get conversation participants count.
|
1595
1633
|
*
|
1596
|
-
* This method is semi-realtime. This means that this data will be eventually
|
1597
|
-
* but will also be possibly incorrect for a few seconds. The
|
1598
|
-
* provide real time events for counter values
|
1634
|
+
* This method is semi-realtime. This means that this data will be eventually
|
1635
|
+
* correct, but will also be possibly incorrect for a few seconds. The
|
1636
|
+
* Conversations system does not provide real time events for counter values
|
1637
|
+
* changes.
|
1599
1638
|
*
|
1600
|
-
* This is useful for any UI badges, but it is not recommended to build any
|
1601
|
-
* logic based on these counters being accurate in real time.
|
1639
|
+
* This is useful for any UI badges, but it is not recommended to build any
|
1640
|
+
* core application logic based on these counters being accurate in real time.
|
1602
1641
|
*/
|
1603
1642
|
getParticipantsCount(): Promise<number>;
|
1604
1643
|
/**
|
@@ -1614,28 +1653,30 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1614
1653
|
/**
|
1615
1654
|
* Get the total message count in the conversation.
|
1616
1655
|
*
|
1617
|
-
* This method is semi-realtime. This means that this data will be eventually
|
1618
|
-
* but will also be possibly incorrect for a few seconds. The
|
1619
|
-
* provide real time events for counter values
|
1656
|
+
* This method is semi-realtime. This means that this data will be eventually
|
1657
|
+
* correct, but will also be possibly incorrect for a few seconds. The
|
1658
|
+
* Conversations system does not provide real time events for counter values
|
1659
|
+
* changes.
|
1620
1660
|
*
|
1621
|
-
* This is useful for any UI badges, but it is not recommended to build any
|
1622
|
-
* logic based on these counters being accurate in real time.
|
1661
|
+
* This is useful for any UI badges, but it is not recommended to build any
|
1662
|
+
* core application logic based on these counters being accurate in real time.
|
1623
1663
|
*/
|
1624
1664
|
getMessagesCount(): Promise<number>;
|
1625
1665
|
/**
|
1626
|
-
* Get unread messages count for the user if they are a participant of this
|
1627
|
-
* Rejects if the user is not a participant of the conversation.
|
1666
|
+
* Get unread messages count for the user if they are a participant of this
|
1667
|
+
* conversation. Rejects if the user is not a participant of the conversation.
|
1628
1668
|
*
|
1629
1669
|
* Use this method to obtain the number of unread messages together with
|
1630
1670
|
* {@link Conversation.updateLastReadMessageIndex} instead of relying on the
|
1631
1671
|
* message indices which may have gaps. See {@link Message.index} for details.
|
1632
1672
|
*
|
1633
|
-
* This method is semi-realtime. This means that this data will be eventually
|
1634
|
-
* but will also be possibly incorrect for a few seconds. The
|
1635
|
-
* provide real time events for counter values
|
1673
|
+
* This method is semi-realtime. This means that this data will be eventually
|
1674
|
+
* correct, but will also be possibly incorrect for a few seconds. The
|
1675
|
+
* Conversations system does not provide real time events for counter values
|
1676
|
+
* changes.
|
1636
1677
|
*
|
1637
|
-
* This is useful for any UI badges, but it is not recommended to build any
|
1638
|
-
* logic based on these counters being accurate in real time.
|
1678
|
+
* This is useful for any UI badges, but it is not recommended to build any
|
1679
|
+
* core application logic based on these counters being accurate in real time.
|
1639
1680
|
*/
|
1640
1681
|
getUnreadMessagesCount(): Promise<number | null>;
|
1641
1682
|
/**
|
@@ -1651,13 +1692,12 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1651
1692
|
* argument, it will assume that the string is an identity or SID.
|
1652
1693
|
* @param participant Identity, SID or the participant object to remove.
|
1653
1694
|
*/
|
1654
|
-
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
1655
|
-
// @ts-ignore TODO: fix validateTypesAsync typing
|
1656
1695
|
removeParticipant(participant: string | Participant): Promise<void>;
|
1657
1696
|
/**
|
1658
1697
|
* Send a message to the conversation.
|
1659
1698
|
* @param message Message body for the text message,
|
1660
|
-
* `FormData` or {@link SendMediaOptions} for media content. Sending FormData
|
1699
|
+
* `FormData` or {@link SendMediaOptions} for media content. Sending FormData
|
1700
|
+
* is supported only with the browser engine.
|
1661
1701
|
* @param messageAttributes Attributes for the message.
|
1662
1702
|
* @param emailOptions Email options for the message.
|
1663
1703
|
* @return Index of the new message.
|
@@ -1665,12 +1705,13 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1665
1705
|
sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<number>;
|
1666
1706
|
/**
|
1667
1707
|
* New interface to prepare for sending a message.
|
1668
|
-
* Use instead of
|
1708
|
+
* Use this instead of {@link Message.sendMessage}.
|
1669
1709
|
* @return A MessageBuilder to help set all message sending options.
|
1670
1710
|
*/
|
1671
1711
|
prepareMessage(): MessageBuilder;
|
1672
1712
|
/**
|
1673
|
-
* Set last read message index of the conversation to the index of the last
|
1713
|
+
* Set last read message index of the conversation to the index of the last
|
1714
|
+
* known message.
|
1674
1715
|
* @return Resulting unread messages count in the conversation.
|
1675
1716
|
*/
|
1676
1717
|
setAllMessagesRead(): Promise<number>;
|
@@ -1685,8 +1726,10 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1685
1726
|
*/
|
1686
1727
|
setUserNotificationLevel(notificationLevel: NotificationLevel): Promise<void>;
|
1687
1728
|
/**
|
1688
|
-
* Send a notification to the server indicating that this client is currently
|
1689
|
-
* Typing ended notification is sent after a
|
1729
|
+
* Send a notification to the server indicating that this client is currently
|
1730
|
+
* typing in this conversation. Typing ended notification is sent after a
|
1731
|
+
* while automatically, but by calling this method again you ensure that
|
1732
|
+
* typing ended is not received.
|
1690
1733
|
*/
|
1691
1734
|
typing(): Promise<void>;
|
1692
1735
|
/**
|
@@ -1701,21 +1744,61 @@ declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
|
1701
1744
|
updateFriendlyName(friendlyName: string): Promise<Conversation>;
|
1702
1745
|
/**
|
1703
1746
|
* Set the last read message index to the current read horizon.
|
1704
|
-
* @param index Message index to set as last read.
|
1705
|
-
*
|
1747
|
+
* @param index Message index to set as last read. If null is provided, then
|
1748
|
+
* the behavior is identical to {@link Conversation.setAllMessagesUnread}.
|
1706
1749
|
* @returns Resulting unread messages count in the conversation.
|
1707
1750
|
*/
|
1708
1751
|
updateLastReadMessageIndex(index: number | null): Promise<number>;
|
1709
1752
|
/**
|
1710
1753
|
* Update the unique name of the conversation.
|
1711
|
-
* @param uniqueName New unique name for the conversation. Setting unique name
|
1754
|
+
* @param uniqueName New unique name for the conversation. Setting unique name
|
1755
|
+
* to null removes it.
|
1712
1756
|
*/
|
1713
1757
|
updateUniqueName(uniqueName: string | null): Promise<Conversation>;
|
1758
|
+
/**
|
1759
|
+
* Load and subscribe to this conversation and do not subscribe to its
|
1760
|
+
* participants and messages. This or _subscribeStreams will need to be called
|
1761
|
+
* before any events on conversation will fire.
|
1762
|
+
* @internal
|
1763
|
+
*/
|
1764
|
+
_subscribe(): Promise<SyncDocument>;
|
1765
|
+
/**
|
1766
|
+
* Load the attributes of this conversation and instantiate its participants
|
1767
|
+
* and messages. This or _subscribe will need to be called before any events
|
1768
|
+
* on the conversation will fire. This will need to be called before any
|
1769
|
+
* events on participants or messages will fire
|
1770
|
+
* @internal
|
1771
|
+
*/
|
1772
|
+
_subscribeStreams(): Promise<void>;
|
1773
|
+
/**
|
1774
|
+
* Stop listening for and firing events on this conversation.
|
1775
|
+
* @internal
|
1776
|
+
*/
|
1777
|
+
_unsubscribe(): Promise<[
|
1778
|
+
void,
|
1779
|
+
void
|
1780
|
+
]>;
|
1781
|
+
/**
|
1782
|
+
* Set conversation status.
|
1783
|
+
* @internal
|
1784
|
+
*/
|
1785
|
+
_setStatus(status: ConversationStatus, source: ConversationsDataSource): void;
|
1786
|
+
/**
|
1787
|
+
* Update the local conversation object with new values.
|
1788
|
+
* @internal
|
1789
|
+
*/
|
1790
|
+
_update(update: any): void;
|
1791
|
+
/**
|
1792
|
+
* Handle onMessageAdded event.
|
1793
|
+
*/
|
1794
|
+
private _onMessageAdded;
|
1795
|
+
/**
|
1796
|
+
* Set last read message index.
|
1797
|
+
* @param index New index to set.
|
1798
|
+
*/
|
1799
|
+
private _setLastReadMessageIndex;
|
1714
1800
|
}
|
1715
|
-
type ConversationsDataSource = "sync" | "
|
1716
|
-
/**
|
1717
|
-
* Push notification type.
|
1718
|
-
*/
|
1801
|
+
type ConversationsDataSource = "sync" | "rest";
|
1719
1802
|
type PushNotificationType = "twilio.conversations.new_message" | "twilio.conversations.added_to_conversation" | "twilio.conversations.removed_from_conversation";
|
1720
1803
|
interface PushNotificationDescriptor {
|
1721
1804
|
title: string | null;
|
@@ -1734,6 +1817,10 @@ interface PushNotificationData {
|
|
1734
1817
|
* SID of the conversation.
|
1735
1818
|
*/
|
1736
1819
|
conversationSid?: string;
|
1820
|
+
/**
|
1821
|
+
* Title of the conversation.
|
1822
|
+
*/
|
1823
|
+
conversationTitle?: string;
|
1737
1824
|
/**
|
1738
1825
|
* Index of the message in the conversation.
|
1739
1826
|
*/
|
@@ -1742,6 +1829,14 @@ interface PushNotificationData {
|
|
1742
1829
|
* SID of the message in the conversation.
|
1743
1830
|
*/
|
1744
1831
|
messageSid?: string;
|
1832
|
+
/**
|
1833
|
+
* Media of the notification
|
1834
|
+
*/
|
1835
|
+
media?: Media;
|
1836
|
+
/**
|
1837
|
+
* Amount of the attached media of the message.
|
1838
|
+
*/
|
1839
|
+
mediaCount?: number;
|
1745
1840
|
}
|
1746
1841
|
/**
|
1747
1842
|
* Push notification for a Conversations client.
|
@@ -1804,7 +1899,7 @@ type ClientEvents = {
|
|
1804
1899
|
message: Message;
|
1805
1900
|
updateReasons: MessageUpdateReason[];
|
1806
1901
|
}) => void;
|
1807
|
-
tokenAboutToExpire: (
|
1902
|
+
tokenAboutToExpire: () => void;
|
1808
1903
|
tokenExpired: () => void;
|
1809
1904
|
typingEnded: (participant: Participant) => void;
|
1810
1905
|
typingStarted: (participant: Participant) => void;
|
@@ -1817,15 +1912,10 @@ type ClientEvents = {
|
|
1817
1912
|
}) => void;
|
1818
1913
|
stateChanged: ({ state, error }: {
|
1819
1914
|
state: State;
|
1820
|
-
error?:
|
1915
|
+
error?: ConnectionError;
|
1821
1916
|
}) => void;
|
1822
1917
|
connectionStateChanged: (state: TwilsockConnectionState) => void;
|
1823
|
-
connectionError: (data:
|
1824
|
-
terminal: boolean;
|
1825
|
-
message: string;
|
1826
|
-
httpStatusCode?: number;
|
1827
|
-
errorCode?: number;
|
1828
|
-
}) => void;
|
1918
|
+
connectionError: (data: ConnectionError) => void;
|
1829
1919
|
};
|
1830
1920
|
/**
|
1831
1921
|
* Connection state of the client. Possible values are as follows:
|
@@ -2013,8 +2103,6 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2013
2103
|
static readonly messageUpdated = "messageUpdated";
|
2014
2104
|
/**
|
2015
2105
|
* Fired when the token is about to expire and needs to be updated.
|
2016
|
-
* * Parameters:
|
2017
|
-
* 1. number `message` - token's time to live
|
2018
2106
|
* @event
|
2019
2107
|
*/
|
2020
2108
|
static readonly tokenAboutToExpire = "tokenAboutToExpire";
|
@@ -2169,7 +2257,7 @@ declare class Client extends ReplayEventEmitter<ClientEvents> {
|
|
2169
2257
|
/**
|
2170
2258
|
* The Conversations entity.
|
2171
2259
|
*/
|
2172
|
-
private
|
2260
|
+
private _conversationsEntity;
|
2173
2261
|
/**
|
2174
2262
|
* Promise that resolves when initial conversations are fetched.
|
2175
2263
|
*/
|
@@ -2352,4 +2440,4 @@ declare class NotificationTypes {
|
|
2352
2440
|
static readonly REMOVED_FROM_CONVERSATION = "twilio.conversations.removed_from_conversation";
|
2353
2441
|
static readonly CONSUMPTION_UPDATE = "twilio.channel.consumption_update";
|
2354
2442
|
}
|
2355
|
-
export { Conversation, ConversationBindings, ConversationEmailBinding, ConversationUpdateReason, ConversationStatus, NotificationLevel, ConversationState, ConversationUpdatedEventArgs, SendMediaOptions, SendEmailOptions, LastMessage, Participant, ParticipantUpdateReason, ParticipantType, ParticipantUpdatedEventArgs, ParticipantBindings, ParticipantEmailBinding, ParticipantEmailLevel, Message, MessageUpdateReason, MessageType, MessageUpdatedEventArgs, Media, MediaCategory$0 as MediaCategory, AggregatedDeliveryReceipt, DeliveryAmount, DetailedDeliveryReceipt, DeliveryStatus, RestPaginator, MessageBuilder, UnsentMessage, Paginator, ParticipantBindingOptions, User, UserUpdateReason, UserUpdatedEventArgs, PushNotification, PushNotificationType, PushNotificationDescriptor, PushNotificationData, NotificationTypes, Client, State, ConnectionState, NotificationsChannelType, ClientOptions, CreateConversationOptions, ConversationLimits, JSONValue, JSONObject, JSONArray };
|
2443
|
+
export { Conversation, ConversationBindings, ConversationEmailBinding, ConversationUpdateReason, ConversationStatus, NotificationLevel, ConversationState, ConversationUpdatedEventArgs, SendMediaOptions, SendEmailOptions, LastMessage, Participant, ParticipantUpdateReason, ParticipantType, ParticipantUpdatedEventArgs, ParticipantBindings, ParticipantEmailBinding, ParticipantEmailLevel, Message, MessageUpdateReason, MessageType, MessageUpdatedEventArgs, Media, MediaCategory$0 as MediaCategory, AggregatedDeliveryReceipt, DeliveryAmount, DetailedDeliveryReceipt, DeliveryStatus, RestPaginator, MessageBuilder, UnsentMessage, Paginator, ParticipantBindingOptions, User, UserUpdateReason, UserUpdatedEventArgs, PushNotification, PushNotificationType, PushNotificationDescriptor, PushNotificationData, NotificationTypes, Client, State, ConnectionState, NotificationsChannelType, ClientOptions, CreateConversationOptions, ConversationLimits, JSONValue, JSONObject, JSONArray, CancellablePromise };
|