@twilio/conversations 1.3.0-rc8 → 2.0.0-rc.4
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 +210 -0
- package/README.md +22 -17
- package/dist/browser.js +7873 -0
- package/dist/browser.js.map +1 -0
- package/dist/docs/assets/css/main.css +2660 -0
- package/dist/docs/assets/images/icons.png +0 -0
- package/dist/docs/assets/images/icons@2x.png +0 -0
- package/dist/docs/assets/images/widgets.png +0 -0
- package/dist/docs/assets/images/widgets@2x.png +0 -0
- package/dist/docs/assets/js/main.js +248 -0
- package/dist/docs/assets/js/search.js +1 -0
- package/dist/docs/classes/AggregatedDeliveryReceipt.html +3286 -0
- package/dist/docs/classes/Client.html +4181 -0
- package/dist/docs/classes/Conversation.html +4397 -0
- package/dist/docs/classes/DetailedDeliveryReceipt.html +3265 -0
- package/dist/docs/classes/Media.html +3295 -0
- package/dist/docs/classes/Message.html +3713 -0
- package/dist/docs/classes/MessageBuilder.html +3280 -0
- package/dist/docs/classes/Participant.html +3517 -0
- package/dist/docs/classes/PushNotification.html +3232 -0
- package/dist/docs/classes/RestPaginator.html +3262 -0
- package/dist/docs/classes/UnsentMessage.html +3144 -0
- package/dist/docs/classes/User.html +3451 -0
- package/dist/docs/index.html +3394 -212
- package/dist/docs/interfaces/ClientOptions.html +3136 -0
- package/dist/docs/interfaces/ConversationState.html +3152 -0
- package/dist/docs/interfaces/CreateConversationOptions.html +3168 -0
- package/dist/docs/interfaces/LastMessage.html +3152 -0
- package/dist/docs/interfaces/Paginator.html +3243 -0
- package/dist/docs/interfaces/PushNotificationData.html +3168 -0
- package/dist/docs/interfaces/SendEmailOptions.html +3136 -0
- package/dist/docs/interfaces/SendMediaOptions.html +3170 -0
- package/dist/docs/modules.html +3425 -0
- package/dist/lib.d.ts +1952 -0
- package/dist/lib.js +7873 -0
- package/dist/lib.js.map +1 -0
- package/dist/post-install.js +29 -0
- package/dist/react-native.js +4038 -0
- package/dist/react-native.js.map +1 -0
- package/dist/twilio-conversations.js +40912 -0
- package/dist/twilio-conversations.min.js +156 -0
- package/package.json +59 -48
- package/.circleci/config.yml +0 -650
- package/.deepsource.toml +0 -6
- package/.env.example +0 -13
- package/browser/aggregateddeliveryreceipt.js +0 -152
- package/browser/client.js +0 -991
- package/browser/configuration.js +0 -80
- package/browser/conversation.js +0 -1826
- package/browser/data/conversations.js +0 -632
- package/browser/data/messages.js +0 -522
- package/browser/data/participants.js +0 -411
- package/browser/data/users.js +0 -281
- package/browser/detaileddeliveryreceipt.js +0 -44
- package/browser/index.js +0 -4
- package/browser/interfaces/limits.js +0 -3
- package/browser/interfaces/notificationtypes.js +0 -21
- package/browser/interfaces/paginator.js +0 -53
- package/browser/interfaces/responsecodes.js +0 -20
- package/browser/interfaces/transport.js +0 -3
- package/browser/logger.js +0 -141
- package/browser/media.js +0 -198
- package/browser/message.js +0 -685
- package/browser/participant.js +0 -415
- package/browser/pushnotification.js +0 -49
- package/browser/restpaginator.js +0 -74
- package/browser/services/network.js +0 -223
- package/browser/services/readhorizon.js +0 -181
- package/browser/services/typingindicator.js +0 -142
- package/browser/session.js +0 -505
- package/browser/sessionerror.js +0 -93
- package/browser/sri.json +0 -1
- package/browser/synclist.js +0 -90
- package/browser/synclistdescriptor.js +0 -29
- package/browser/syncpaginator.js +0 -63
- package/browser/user.js +0 -431
- package/browser/util/deferred.js +0 -56
- package/browser/util/index.js +0 -108
- package/dist/@twilio/conversations.js +0 -35533
- package/dist/@twilio/conversations.min.js +0 -204
- package/dist/docs/AggregatedDeliveryReceipt.html +0 -948
- package/dist/docs/Client.html +0 -5075
- package/dist/docs/Conversation.html +0 -6018
- package/dist/docs/DetailedDeliveryReceipt.html +0 -641
- package/dist/docs/Media.html +0 -694
- package/dist/docs/Message.html +0 -1934
- package/dist/docs/Paginator.html +0 -605
- package/dist/docs/Participant.html +0 -1510
- package/dist/docs/PushNotification.html +0 -836
- package/dist/docs/SessionError.html +0 -379
- package/dist/docs/User.html +0 -1315
- package/dist/docs/classes.list.html +0 -4431
- package/dist/docs/fonts/glyphicons-halflings-regular.eot +0 -0
- package/dist/docs/fonts/glyphicons-halflings-regular.svg +0 -288
- package/dist/docs/fonts/glyphicons-halflings-regular.ttf +0 -0
- package/dist/docs/fonts/glyphicons-halflings-regular.woff +0 -0
- package/dist/docs/fonts/glyphicons-halflings-regular.woff2 +0 -0
- package/dist/docs/img/glyphicons-halflings-white.png +0 -0
- package/dist/docs/img/glyphicons-halflings.png +0 -0
- package/dist/docs/quicksearch.html +0 -31
- package/dist/docs/scripts/docstrap.lib.js +0 -11
- package/dist/docs/scripts/fulltext-search-ui.js +0 -89
- package/dist/docs/scripts/fulltext-search.js +0 -36
- package/dist/docs/scripts/lunr.min.js +0 -6
- package/dist/docs/scripts/prettify/Apache-License-2.0.txt +0 -202
- package/dist/docs/scripts/prettify/jquery.min.js +0 -6
- package/dist/docs/scripts/prettify/lang-css.js +0 -21
- package/dist/docs/scripts/prettify/prettify.js +0 -496
- package/dist/docs/scripts/sunlight.js +0 -1157
- package/dist/docs/scripts/toc.js +0 -203
- package/dist/docs/styles/darkstrap.css +0 -960
- package/dist/docs/styles/prettify-tomorrow.css +0 -132
- package/dist/docs/styles/site.cerulean.css +0 -7008
- package/dist/docs/styles/site.cosmo.css +0 -7061
- package/dist/docs/styles/site.cyborg.css +0 -7048
- package/dist/docs/styles/site.darkly.css +0 -7171
- package/dist/docs/styles/site.darkstrap.css +0 -5638
- package/dist/docs/styles/site.dibs-bootstrap.css +0 -5899
- package/dist/docs/styles/site.flatly.css +0 -7147
- package/dist/docs/styles/site.journal.css +0 -6973
- package/dist/docs/styles/site.lumen.css +0 -7298
- package/dist/docs/styles/site.paper.css +0 -7623
- package/dist/docs/styles/site.readable.css +0 -6997
- package/dist/docs/styles/site.sandstone.css +0 -7035
- package/dist/docs/styles/site.simplex.css +0 -7023
- package/dist/docs/styles/site.slate.css +0 -7343
- package/dist/docs/styles/site.spacelab.css +0 -7055
- package/dist/docs/styles/site.superhero.css +0 -7131
- package/dist/docs/styles/site.united.css +0 -6895
- package/dist/docs/styles/site.yeti.css +0 -7195
- package/dist/docs/styles/sunlight.dark.css +0 -345
- package/dist/docs/styles/sunlight.default.css +0 -344
- package/dist/sri.json +0 -1
- package/lib/aggregateddeliveryreceipt.d.ts +0 -98
- package/lib/aggregateddeliveryreceipt.js +0 -112
- package/lib/client.d.ts +0 -317
- package/lib/client.js +0 -633
- package/lib/configuration.d.ts +0 -21
- package/lib/configuration.js +0 -41
- package/lib/conversation.d.ts +0 -460
- package/lib/conversation.js +0 -940
- package/lib/data/conversations.d.ts +0 -57
- package/lib/data/conversations.js +0 -296
- package/lib/data/messages.d.ts +0 -75
- package/lib/data/messages.js +0 -208
- package/lib/data/participants.d.ts +0 -94
- package/lib/data/participants.js +0 -204
- package/lib/data/users.d.ts +0 -42
- package/lib/data/users.js +0 -113
- package/lib/detaileddeliveryreceipt.d.ts +0 -45
- package/lib/detaileddeliveryreceipt.js +0 -34
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -3
- package/lib/interfaces/limits.d.ts +0 -8
- package/lib/interfaces/limits.js +0 -2
- package/lib/interfaces/notificationtypes.d.ts +0 -8
- package/lib/interfaces/notificationtypes.js +0 -11
- package/lib/interfaces/paginator.d.ts +0 -52
- package/lib/interfaces/paginator.js +0 -28
- package/lib/interfaces/responsecodes.d.ts +0 -8
- package/lib/interfaces/responsecodes.js +0 -10
- package/lib/interfaces/transport.d.ts +0 -13
- package/lib/interfaces/transport.js +0 -2
- package/lib/logger.d.ts +0 -18
- package/lib/logger.js +0 -35
- package/lib/media.d.ts +0 -52
- package/lib/media.js +0 -69
- package/lib/message.d.ts +0 -136
- package/lib/message.js +0 -305
- package/lib/participant.d.ts +0 -142
- package/lib/participant.js +0 -219
- package/lib/pushnotification.d.ts +0 -48
- package/lib/pushnotification.js +0 -39
- package/lib/restpaginator.d.ts +0 -19
- package/lib/restpaginator.js +0 -36
- package/lib/services/network.d.ts +0 -22
- package/lib/services/network.js +0 -87
- package/lib/services/readhorizon.d.ts +0 -28
- package/lib/services/readhorizon.js +0 -112
- package/lib/services/typingindicator.d.ts +0 -50
- package/lib/services/typingindicator.js +0 -102
- package/lib/session.d.ts +0 -63
- package/lib/session.js +0 -213
- package/lib/sessionerror.d.ts +0 -12
- package/lib/sessionerror.js +0 -24
- package/lib/sri.json +0 -1
- package/lib/synclist.d.ts +0 -24
- package/lib/synclist.js +0 -28
- package/lib/synclistdescriptor.d.ts +0 -27
- package/lib/synclistdescriptor.js +0 -19
- package/lib/syncpaginator.d.ts +0 -22
- package/lib/syncpaginator.js +0 -37
- package/lib/user.d.ts +0 -98
- package/lib/user.js +0 -219
- package/lib/util/deferred.d.ts +0 -12
- package/lib/util/deferred.js +0 -22
- package/lib/util/index.d.ts +0 -28
- package/lib/util/index.js +0 -82
- package/tools/rtd-sdk-cdn-pin/.gitrepo +0 -12
- package/tools/rtd-sdk-cdn-pin/README.md +0 -54
- package/tools/rtd-sdk-cdn-pin/bintray-settings.xml.template +0 -16
- package/tools/rtd-sdk-cdn-pin/cdn-common/cdn-prepare.sh +0 -67
- package/tools/rtd-sdk-cdn-pin/cdn-pin-latest.sh +0 -19
- package/tools/rtd-sdk-cdn-pin/cdn-pin.sh +0 -19
- package/tools/rtd-sdk-cdn-pin/cdn-upload.sh +0 -13
- package/tools/rtd-sdk-cdn-pin/fetch/common/fetch-bintray-android.sh +0 -34
- package/tools/rtd-sdk-cdn-pin/fetch/common/fetch-npm.sh +0 -18
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-chat-android.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-chat-js.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-conversations-android.sh +0 -6
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-conversations-js.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-sync-android.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch/twilio-sync-js.sh +0 -5
- package/tools/rtd-sdk-cdn-pin/fetch-artifact.sh +0 -26
- package/tools/sdk-release-tool/.gitrepo +0 -12
- package/tools/sdk-release-tool/Makefile +0 -49
- package/tools/sdk-release-tool/README.md +0 -275
- package/tools/sdk-release-tool/delete +0 -3
- package/tools/sdk-release-tool/download +0 -3
- package/tools/sdk-release-tool/get-cors +0 -3
- package/tools/sdk-release-tool/list +0 -3
- package/tools/sdk-release-tool/pin +0 -3
- package/tools/sdk-release-tool/pin-latest +0 -3
- package/tools/sdk-release-tool/requirements.txt +0 -4
- package/tools/sdk-release-tool/sdk-release-tool +0 -3
- package/tools/sdk-release-tool/sdk_release_tools/__init__.py +0 -0
- package/tools/sdk-release-tool/sdk_release_tools/__main__.py +0 -110
- package/tools/sdk-release-tool/sdk_release_tools/aws.py +0 -70
- package/tools/sdk-release-tool/sdk_release_tools/cli.py +0 -181
- package/tools/sdk-release-tool/sdk_release_tools/log.py +0 -24
- package/tools/sdk-release-tool/sdk_release_tools/ops.py +0 -295
- package/tools/sdk-release-tool/sdk_release_tools/rpm.py +0 -28
- package/tools/sdk-release-tool/sdk_release_tools/util.py +0 -186
- package/tools/sdk-release-tool/sdk_release_tools/versions.py +0 -362
- package/tools/sdk-release-tool/signal-sdk-js.json +0 -28
- package/tools/sdk-release-tool/tests/test_versions.py +0 -94
- package/tools/sdk-release-tool/twilio-accessmanager-android.json +0 -19
- package/tools/sdk-release-tool/twilio-accessmanager-ios.json +0 -26
- package/tools/sdk-release-tool/twilio-auth-ios.json +0 -29
- package/tools/sdk-release-tool/twilio-authenticator-ios.json +0 -29
- package/tools/sdk-release-tool/twilio-chat-android-2.json +0 -19
- package/tools/sdk-release-tool/twilio-chat-android.json +0 -22
- package/tools/sdk-release-tool/twilio-chat-ios.json +0 -26
- package/tools/sdk-release-tool/twilio-chat-js.json +0 -27
- package/tools/sdk-release-tool/twilio-client-android-aar.json +0 -22
- package/tools/sdk-release-tool/twilio-client-android.json +0 -22
- package/tools/sdk-release-tool/twilio-client-ios.json +0 -20
- package/tools/sdk-release-tool/twilio-client-js.json +0 -17
- package/tools/sdk-release-tool/twilio-client-sounds-js.json +0 -14
- package/tools/sdk-release-tool/twilio-common-android-maven.json +0 -16
- package/tools/sdk-release-tool/twilio-common-android.json +0 -22
- package/tools/sdk-release-tool/twilio-common-ios-rtc.json +0 -25
- package/tools/sdk-release-tool/twilio-common-ios.json +0 -25
- package/tools/sdk-release-tool/twilio-common-js.json +0 -19
- package/tools/sdk-release-tool/twilio-conversations-android.json +0 -22
- package/tools/sdk-release-tool/twilio-conversations-ios.json +0 -26
- package/tools/sdk-release-tool/twilio-conversations-js.json +0 -27
- package/tools/sdk-release-tool/twilio-flex-js.json +0 -20
- package/tools/sdk-release-tool/twilio-flex-webchat-js.json +0 -16
- package/tools/sdk-release-tool/twilio-frame-chat-android.json +0 -22
- package/tools/sdk-release-tool/twilio-frame-chat-ios.json +0 -23
- package/tools/sdk-release-tool/twilio-frame-chat-js.json +0 -23
- package/tools/sdk-release-tool/twilio-ip-messaging-android-maven.json +0 -16
- package/tools/sdk-release-tool/twilio-ip-messaging-android.json +0 -22
- package/tools/sdk-release-tool/twilio-ip-messaging-ios.json +0 -25
- package/tools/sdk-release-tool/twilio-ip-messaging-js.json +0 -21
- package/tools/sdk-release-tool/twilio-sync-android.json +0 -22
- package/tools/sdk-release-tool/twilio-sync-ios.json +0 -26
- package/tools/sdk-release-tool/twilio-sync-js.json +0 -39
- package/tools/sdk-release-tool/twilio-taskrouter-js.json +0 -17
- package/tools/sdk-release-tool/twilio-video-android.json +0 -22
- package/tools/sdk-release-tool/twilio-video-cpp-linux-cross-rootfs.json +0 -13
- package/tools/sdk-release-tool/twilio-video-cpp.json +0 -33
- package/tools/sdk-release-tool/twilio-video-ios.json +0 -25
- package/tools/sdk-release-tool/twilio-video-js.json +0 -19
- package/tools/sdk-release-tool/twilio-video-jsdocs.json +0 -14
- package/tools/sdk-release-tool/twilio-voice-android.json +0 -22
- package/tools/sdk-release-tool/twilio-voice-ios.json +0 -29
- package/tools/sdk-release-tool/unpin +0 -3
- package/tools/sdk-release-tool/unpin-latest +0 -3
- package/tools/sdk-release-tool/upload +0 -3
- package/twilio-chat.js.iml +0 -9
package/dist/lib.d.ts
ADDED
@@ -0,0 +1,1952 @@
|
|
1
|
+
import { SyncClient } from "twilio-sync";
|
2
|
+
import { Transport, TwilsockClient, InitRegistration } from "twilsock";
|
3
|
+
import { ConnectionState as TwilsockConnectionState } from "twilsock";
|
4
|
+
import { ReplayEventEmitter } from "@twilio/replay-event-emitter";
|
5
|
+
import { ChannelType, Notifications } from "@twilio/notifications";
|
6
|
+
import { Notifications as NotificationClient } from "@twilio/notifications";
|
7
|
+
import { McsClient, MediaCategory, McsMedia } from "@twilio/mcs-client";
|
8
|
+
import { MediaCategory as McsMediaCategory } from "@twilio/mcs-client";
|
9
|
+
interface ConfigurationResponse {
|
10
|
+
options: {
|
11
|
+
consumption_report_interval: string;
|
12
|
+
user_infos_to_subscribe: number;
|
13
|
+
reachability_enabled: boolean;
|
14
|
+
http_cache_interval: string;
|
15
|
+
my_conversations_page_size: number;
|
16
|
+
media_attachments_count_limit: number;
|
17
|
+
media_attachment_size_limit_in_mb: number;
|
18
|
+
media_attachments_total_size_limit_in_mb: number;
|
19
|
+
email_histories_allowed_mime_types: string[];
|
20
|
+
email_bodies_allowed_mime_types: string[];
|
21
|
+
};
|
22
|
+
sync_objects: {
|
23
|
+
my_conversations: string;
|
24
|
+
my_user_info: string;
|
25
|
+
};
|
26
|
+
links: {
|
27
|
+
my_conversations: string;
|
28
|
+
conversations: string;
|
29
|
+
users: string;
|
30
|
+
current_user: string;
|
31
|
+
typing: string;
|
32
|
+
media_service: string;
|
33
|
+
media_set_service: string;
|
34
|
+
messages_receipts: string;
|
35
|
+
};
|
36
|
+
identity: string;
|
37
|
+
url: string;
|
38
|
+
}
|
39
|
+
// twilio-conversations is used by Flex SDK. Please DO NOT change
|
40
|
+
declare class Logger {
|
41
|
+
private prefix;
|
42
|
+
private constructor();
|
43
|
+
static scope(prefix: string): Logger;
|
44
|
+
setLevel(level: any): void;
|
45
|
+
static setLevel(level: any): void;
|
46
|
+
trace(...args: any[]): void;
|
47
|
+
debug(...args: any[]): void;
|
48
|
+
info(...args: any[]): void;
|
49
|
+
warn(...args: any[]): void;
|
50
|
+
error(...args: any[]): void;
|
51
|
+
static trace(...args: any[]): void;
|
52
|
+
static debug(...args: any[]): void;
|
53
|
+
static info(...args: any[]): void;
|
54
|
+
static warn(...args: any[]): void;
|
55
|
+
static error(...args: any[]): void;
|
56
|
+
}
|
57
|
+
interface Limits {
|
58
|
+
mediaAttachmentsCountLimit: number;
|
59
|
+
mediaAttachmentSizeLimitInMb: number;
|
60
|
+
mediaAttachmentsTotalSizeLimitInMb: number;
|
61
|
+
emailHistoriesAllowedMimeTypes: string[];
|
62
|
+
emailBodiesAllowedMimeTypes: string[];
|
63
|
+
}
|
64
|
+
interface BackoffConfiguration {
|
65
|
+
min: number;
|
66
|
+
max: number;
|
67
|
+
maxAttemptsCount: number;
|
68
|
+
}
|
69
|
+
declare class Configuration {
|
70
|
+
readonly links: {
|
71
|
+
myConversations: string;
|
72
|
+
conversations: string;
|
73
|
+
users: string;
|
74
|
+
currentUser: string;
|
75
|
+
typing: string;
|
76
|
+
mediaService: string;
|
77
|
+
mediaSetService: string;
|
78
|
+
messagesReceipts: string;
|
79
|
+
};
|
80
|
+
readonly limits: Limits;
|
81
|
+
readonly productId?: string;
|
82
|
+
readonly typingIndicatorTimeoutOverride?: number;
|
83
|
+
readonly typingIndicatorTimeoutDefault: number;
|
84
|
+
readonly backoffConfiguration: BackoffConfiguration;
|
85
|
+
readonly retryWhenThrottled: boolean;
|
86
|
+
readonly consumptionReportInterval: number;
|
87
|
+
readonly userInfosToSubscribe: number;
|
88
|
+
readonly httpCacheInterval: number;
|
89
|
+
readonly reachabilityEnabled: boolean;
|
90
|
+
readonly userIdentity: string;
|
91
|
+
readonly userInfo: string;
|
92
|
+
readonly myConversations: string;
|
93
|
+
constructor(options: Record<string, any>, configurationResponse: ConfigurationResponse, logger: Logger);
|
94
|
+
}
|
95
|
+
interface CommandExecutorServices {
|
96
|
+
transport: Transport;
|
97
|
+
}
|
98
|
+
declare class CommandExecutor {
|
99
|
+
private _serviceUrl;
|
100
|
+
private _services;
|
101
|
+
private _productId?;
|
102
|
+
constructor(_serviceUrl: string, _services: CommandExecutorServices, _productId?: string);
|
103
|
+
private _preProcessUrl;
|
104
|
+
private _makeRequest;
|
105
|
+
fetchResource<REQ = void, RESP = void>(url: string, requestBody?: REQ): Promise<RESP>;
|
106
|
+
mutateResource<REQ = void, RESP = void>(method: "post" | "delete", url: string, requestBody?: REQ): Promise<RESP>;
|
107
|
+
}
|
108
|
+
type UserEvents = {
|
109
|
+
updated: (data: {
|
110
|
+
user: User;
|
111
|
+
updateReasons: UserUpdateReason[];
|
112
|
+
}) => void;
|
113
|
+
userSubscribed: (user: User) => void;
|
114
|
+
userUnsubscribed: (user: User) => void;
|
115
|
+
};
|
116
|
+
interface UserServices {
|
117
|
+
syncClient: SyncClient;
|
118
|
+
commandExecutor: CommandExecutor;
|
119
|
+
}
|
120
|
+
/**
|
121
|
+
* The reason for the `updated` event being emitted by a user.
|
122
|
+
*/
|
123
|
+
type UserUpdateReason = "friendlyName" | "attributes" | "reachabilityOnline" | "reachabilityNotifiable";
|
124
|
+
interface UserUpdatedEventArgs {
|
125
|
+
user: User;
|
126
|
+
updateReasons: UserUpdateReason[];
|
127
|
+
}
|
128
|
+
/**
|
129
|
+
* Extended user information.
|
130
|
+
* Note that `isOnline` and `isNotifiable` properties are eligible
|
131
|
+
* for use only if the reachability function is enabled.
|
132
|
+
* You may check if it is enabled by reading the value of {@link Client.reachabilityEnabled}.
|
133
|
+
*/
|
134
|
+
declare class User extends ReplayEventEmitter<UserEvents> {
|
135
|
+
private links;
|
136
|
+
private configuration;
|
137
|
+
private readonly services;
|
138
|
+
private entity;
|
139
|
+
private state;
|
140
|
+
private promiseToFetch;
|
141
|
+
private subscribed;
|
142
|
+
private _initializationPromise;
|
143
|
+
private _resolveInitializationPromise;
|
144
|
+
/**
|
145
|
+
* @internal
|
146
|
+
*/
|
147
|
+
constructor(identity: string, entityName: string, configuration: Configuration | null, services: UserServices);
|
148
|
+
/**
|
149
|
+
* Fired when the properties or the reachability status of the message has been updated.
|
150
|
+
*
|
151
|
+
* Parameters:
|
152
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
153
|
+
* * {@link User} `user` - the user in question
|
154
|
+
* * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update
|
155
|
+
* @event
|
156
|
+
*/
|
157
|
+
readonly updated = "updated";
|
158
|
+
/**
|
159
|
+
* Fired when the client has subscribed to the user.
|
160
|
+
*
|
161
|
+
* Parameters:
|
162
|
+
* 1. {@link User} `user` - the user in question
|
163
|
+
* @event
|
164
|
+
*/
|
165
|
+
readonly userSubscribed = "userSubscribed";
|
166
|
+
/**
|
167
|
+
* Fired when the client has unsubscribed from the user.
|
168
|
+
*
|
169
|
+
* Parameters:
|
170
|
+
* 1. {@link User} `user` - the user in question
|
171
|
+
* @event
|
172
|
+
*/
|
173
|
+
readonly userUnsubscribed = "userUnsubscribed";
|
174
|
+
/**
|
175
|
+
* User identity.
|
176
|
+
*/
|
177
|
+
get identity(): string;
|
178
|
+
set identity(identity: string);
|
179
|
+
set entityName(name: string);
|
180
|
+
/**
|
181
|
+
* Custom attributes of the user.
|
182
|
+
*/
|
183
|
+
get attributes(): any;
|
184
|
+
/**
|
185
|
+
* Friendly name of the user, null if not set.
|
186
|
+
*/
|
187
|
+
get friendlyName(): string;
|
188
|
+
/**
|
189
|
+
* Status of the real-time conversation connection of the user.
|
190
|
+
*/
|
191
|
+
get isOnline(): boolean;
|
192
|
+
/**
|
193
|
+
* User push notification registration status.
|
194
|
+
*/
|
195
|
+
get isNotifiable(): boolean;
|
196
|
+
/**
|
197
|
+
* True if this user is receiving real-time status updates.
|
198
|
+
*/
|
199
|
+
get isSubscribed(): boolean;
|
200
|
+
// Handles service updates
|
201
|
+
_update(key: string, value: any): Promise<void>;
|
202
|
+
// Fetch reachability info
|
203
|
+
private _updateReachabilityInfo;
|
204
|
+
// Fetch user
|
205
|
+
_fetch(): Promise<User>;
|
206
|
+
_ensureFetched(): Promise<User>;
|
207
|
+
/**
|
208
|
+
* Edit user attributes.
|
209
|
+
* @param attributes New attributes.
|
210
|
+
*/
|
211
|
+
updateAttributes(attributes: any): Promise<User>;
|
212
|
+
/**
|
213
|
+
* Update the friendly name of the user.
|
214
|
+
* @param friendlyName New friendly name.
|
215
|
+
*/
|
216
|
+
updateFriendlyName(friendlyName: string): Promise<User>;
|
217
|
+
/**
|
218
|
+
* Remove the user from the subscription list.
|
219
|
+
* @return A promise of completion.
|
220
|
+
*/
|
221
|
+
unsubscribe(): Promise<void>;
|
222
|
+
_resolveInitialization(configuration: Configuration, identity: string, entityName: string, emitUpdated: boolean): void;
|
223
|
+
}
|
224
|
+
declare class Network {
|
225
|
+
private readonly configuration;
|
226
|
+
private readonly services;
|
227
|
+
private cacheLifetime;
|
228
|
+
private readonly cache;
|
229
|
+
private timer;
|
230
|
+
constructor(configuration: any, services: any);
|
231
|
+
private isExpired;
|
232
|
+
private cleanupCache;
|
233
|
+
pokeTimer(): void;
|
234
|
+
private executeWithRetry;
|
235
|
+
get(url: string): Promise<any>;
|
236
|
+
}
|
237
|
+
type UsersEvents = {
|
238
|
+
userUpdated: (data: {
|
239
|
+
user: User;
|
240
|
+
updateReasons: UserUpdateReason[];
|
241
|
+
}) => void;
|
242
|
+
userSubscribed: (user: User) => void;
|
243
|
+
userUnsubscribed: (user: User) => void;
|
244
|
+
};
|
245
|
+
interface UsersServices {
|
246
|
+
network: Network;
|
247
|
+
syncClient: SyncClient;
|
248
|
+
commandExecutor: CommandExecutor;
|
249
|
+
}
|
250
|
+
/**
|
251
|
+
* Container for known users
|
252
|
+
*/
|
253
|
+
declare class Users extends ReplayEventEmitter<UsersEvents> {
|
254
|
+
private readonly configuration;
|
255
|
+
private readonly services;
|
256
|
+
private subscribedUsers;
|
257
|
+
private fifoStack;
|
258
|
+
readonly myself: User;
|
259
|
+
constructor(myself: User, configuration: Configuration, services: UsersServices);
|
260
|
+
private handleUnsubscribeUser;
|
261
|
+
private handleSubscribeUser;
|
262
|
+
/**
|
263
|
+
* Gets user, if it's in subscribed list - then return the user object from it,
|
264
|
+
* if not - then subscribes and adds user to the FIFO stack
|
265
|
+
* @returns {Promise<User>} Fully initialized user
|
266
|
+
*/
|
267
|
+
getUser(identity: string, entityName?: string): Promise<User>;
|
268
|
+
/**
|
269
|
+
* @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}
|
270
|
+
*/
|
271
|
+
getSubscribedUsers(): Promise<Array<User>>;
|
272
|
+
/**
|
273
|
+
* @returns {Promise<string>} User's sync unique name
|
274
|
+
*/
|
275
|
+
private getSyncUniqueName;
|
276
|
+
}
|
277
|
+
type ParticipantEvents = {
|
278
|
+
typingEnded: (participant: Participant) => void;
|
279
|
+
typingStarted: (participant: Participant) => void;
|
280
|
+
updated: (data: {
|
281
|
+
participant: Participant;
|
282
|
+
updateReasons: ParticipantUpdateReason[];
|
283
|
+
}) => void;
|
284
|
+
};
|
285
|
+
interface ParticipantDescriptor {
|
286
|
+
attributes?: Object;
|
287
|
+
dateCreated: any;
|
288
|
+
dateUpdated: any;
|
289
|
+
identity: string;
|
290
|
+
roleSid?: string;
|
291
|
+
lastConsumedMessageIndex: number;
|
292
|
+
lastConsumptionTimestamp: number;
|
293
|
+
type: ParticipantType;
|
294
|
+
userInfo: string;
|
295
|
+
}
|
296
|
+
interface ParticipantServices {
|
297
|
+
users: Users;
|
298
|
+
commandExecutor: CommandExecutor;
|
299
|
+
}
|
300
|
+
interface ParticipantLinks {
|
301
|
+
self: string;
|
302
|
+
}
|
303
|
+
/**
|
304
|
+
* The reason for the `updated` event being emitted by a participant.
|
305
|
+
*/
|
306
|
+
type ParticipantUpdateReason = "attributes" | "dateCreated" | "dateUpdated" | "roleSid" | "lastReadMessageIndex" | "lastReadTimestamp";
|
307
|
+
/**
|
308
|
+
* Type of a participant.
|
309
|
+
*/
|
310
|
+
type ParticipantType = "chat" | "sms" | "whatsapp";
|
311
|
+
interface ParticipantUpdatedEventArgs {
|
312
|
+
participant: Participant;
|
313
|
+
updateReasons: ParticipantUpdateReason[];
|
314
|
+
}
|
315
|
+
/**
|
316
|
+
* A participant represents a remote client in a conversation.
|
317
|
+
*/
|
318
|
+
declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
|
319
|
+
private state;
|
320
|
+
private readonly links;
|
321
|
+
private readonly services;
|
322
|
+
/**
|
323
|
+
* Conversation that the remote client is a participant of.
|
324
|
+
*/
|
325
|
+
readonly conversation: Conversation;
|
326
|
+
/**
|
327
|
+
* The server-assigned unique identifier for the participant.
|
328
|
+
*/
|
329
|
+
get sid(): string;
|
330
|
+
/**
|
331
|
+
* Custom attributes of the participant.
|
332
|
+
*/
|
333
|
+
get attributes(): Object;
|
334
|
+
/**
|
335
|
+
* Date this participant was created on.
|
336
|
+
*/
|
337
|
+
get dateCreated(): Date;
|
338
|
+
/**
|
339
|
+
* Date this participant was last updated on.
|
340
|
+
*/
|
341
|
+
get dateUpdated(): Date;
|
342
|
+
/**
|
343
|
+
* Identity of the participant.
|
344
|
+
*/
|
345
|
+
get identity(): string;
|
346
|
+
/**
|
347
|
+
* Indicates whether the participant is currently typing.
|
348
|
+
*/
|
349
|
+
get isTyping(): boolean;
|
350
|
+
/**
|
351
|
+
* The index of the last read message by the participant.
|
352
|
+
* Note that retrieving messages on a client endpoint does not mean that messages are read,
|
353
|
+
* please consider reading about the [Read Horizon feature](https://www.twilio.com/docs/api/chat/guides/consumption-horizon)
|
354
|
+
* to find out about the proper way to mark messages as read.
|
355
|
+
*/
|
356
|
+
get lastReadMessageIndex(): number | null;
|
357
|
+
/**
|
358
|
+
* Date of the most recent read horizon update.
|
359
|
+
*/
|
360
|
+
get lastReadTimestamp(): Date;
|
361
|
+
get roleSid(): string;
|
362
|
+
/**
|
363
|
+
* Message type of the participant.
|
364
|
+
*/
|
365
|
+
get type(): ParticipantType;
|
366
|
+
/**
|
367
|
+
* @internal
|
368
|
+
*/
|
369
|
+
constructor(data: ParticipantDescriptor, sid: string, conversation: Conversation, links: ParticipantLinks, services: ParticipantServices);
|
370
|
+
/**
|
371
|
+
* Fired when the participant has started typing.
|
372
|
+
*
|
373
|
+
* Parameters:
|
374
|
+
* 1. {@link Participant} `participant` - the participant in question
|
375
|
+
* @event
|
376
|
+
*/
|
377
|
+
static readonly typingStarted = "typingStarted";
|
378
|
+
/**
|
379
|
+
* Fired when the participant has stopped typing.
|
380
|
+
*
|
381
|
+
* Parameters:
|
382
|
+
* 1. {@link Participant} `participant` - the participant in question
|
383
|
+
* @event
|
384
|
+
*/
|
385
|
+
static readonly typingEnded = "typingEnded";
|
386
|
+
/**
|
387
|
+
* Fired when the fields of the participant have been updated.
|
388
|
+
*
|
389
|
+
* Parameters:
|
390
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
391
|
+
* * {@link Participant} participant - the participant in question
|
392
|
+
* * {@link ParticipantUpdateReason}[] updateReasons - array of reasons for the update
|
393
|
+
* @event
|
394
|
+
*/
|
395
|
+
static readonly updated = "updated";
|
396
|
+
/**
|
397
|
+
* Internal method used to start or reset the typing indicator timeout (with event emitting).
|
398
|
+
* @internal
|
399
|
+
*/
|
400
|
+
_startTyping(timeout: any): this;
|
401
|
+
/**
|
402
|
+
* Internal method function used to stop the typing indicator timeout (with event emitting).
|
403
|
+
* @internal
|
404
|
+
*/
|
405
|
+
_endTyping(): void;
|
406
|
+
/**
|
407
|
+
* Internal method function used update local object's property roleSid with a new value.
|
408
|
+
* @internal
|
409
|
+
*/
|
410
|
+
_update(data: any): this;
|
411
|
+
/**
|
412
|
+
* Get the user for this participant and subscribes to it. Supported only for participants of type `chat`.
|
413
|
+
*/
|
414
|
+
getUser(): Promise<User>;
|
415
|
+
/**
|
416
|
+
* Remove the participant from the conversation.
|
417
|
+
*/
|
418
|
+
remove(): Promise<void>;
|
419
|
+
/**
|
420
|
+
* Update the attributes of the participant.
|
421
|
+
* @param attributes New attributes.
|
422
|
+
*/
|
423
|
+
updateAttributes(attributes: any): Promise<Participant>;
|
424
|
+
}
|
425
|
+
/**
|
426
|
+
* Category of media. Possible values are as follows:
|
427
|
+
* * `'media'`
|
428
|
+
* * `'body'`
|
429
|
+
* * `'history'`
|
430
|
+
*/
|
431
|
+
type MediaCategory$0 = McsMediaCategory;
|
432
|
+
interface MediaState {
|
433
|
+
sid: string;
|
434
|
+
category: MediaCategory$0;
|
435
|
+
filename?: string;
|
436
|
+
contentType: string;
|
437
|
+
size: number;
|
438
|
+
}
|
439
|
+
interface MediaServices {
|
440
|
+
mcsClient: McsClient;
|
441
|
+
}
|
442
|
+
/**
|
443
|
+
* Represents a media information for a message in a conversation.
|
444
|
+
*/
|
445
|
+
declare class Media {
|
446
|
+
private state;
|
447
|
+
private services;
|
448
|
+
private mcsMedia;
|
449
|
+
/**
|
450
|
+
* @internal
|
451
|
+
*/
|
452
|
+
constructor(data: MediaState | McsMedia, services: MediaServices);
|
453
|
+
/**
|
454
|
+
* Server-assigned unique identifier for the media.
|
455
|
+
*/
|
456
|
+
get sid(): string;
|
457
|
+
/**
|
458
|
+
* File name. Null if absent.
|
459
|
+
*/
|
460
|
+
get filename(): string;
|
461
|
+
/**
|
462
|
+
* Content type of the media.
|
463
|
+
*/
|
464
|
+
get contentType(): string;
|
465
|
+
/**
|
466
|
+
* Size of the media in bytes.
|
467
|
+
*/
|
468
|
+
get size(): number;
|
469
|
+
/**
|
470
|
+
* Media category, can be one of the {@link MediaCategory} values.
|
471
|
+
*/
|
472
|
+
get category(): MediaCategory$0;
|
473
|
+
/**
|
474
|
+
* Returns the direct content URL for the media.
|
475
|
+
*
|
476
|
+
* This URL is impermanent, it will expire in several minutes and cannot be cached.
|
477
|
+
* If the URL becomes expired, you need to request a new one.
|
478
|
+
* Each call to this function produces a new temporary URL.
|
479
|
+
*/
|
480
|
+
getContentTemporaryUrl(): Promise<string>;
|
481
|
+
/**
|
482
|
+
* Returns cached direct content URL for the media.
|
483
|
+
*
|
484
|
+
* This URL will expire in several minutes. This function does not refresh the URL and can be used to query it several times
|
485
|
+
* without causing network traffic.
|
486
|
+
* If the URL becomes expired, you need to request a new one using getContentTemporaryUrl().
|
487
|
+
*
|
488
|
+
* @returns {Promise<String>}
|
489
|
+
*/
|
490
|
+
getCachedTemporaryUrl(): Promise<string>;
|
491
|
+
private _fetchMcsMedia;
|
492
|
+
}
|
493
|
+
/**
|
494
|
+
* Signifies the amount of participants which have the status for the message.
|
495
|
+
*/
|
496
|
+
type DeliveryAmount = "none" | "some" | "all";
|
497
|
+
interface AggregatedDeliveryDescriptor {
|
498
|
+
total: number;
|
499
|
+
delivered: DeliveryAmount;
|
500
|
+
failed: DeliveryAmount;
|
501
|
+
read: DeliveryAmount;
|
502
|
+
sent: DeliveryAmount;
|
503
|
+
undelivered: DeliveryAmount;
|
504
|
+
}
|
505
|
+
/**
|
506
|
+
* Contains aggregated information about delivery statuses of a message across all participants
|
507
|
+
* of a conversation.
|
508
|
+
*
|
509
|
+
* At any moment during the message delivery to a participant, the message can have zero or more of following
|
510
|
+
* delivery statuses:
|
511
|
+
* * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
|
512
|
+
* * Message is considered as **delivered** to a participant if Twilio has received confirmation of message
|
513
|
+
* delivery from the upstream carrier, and, where available, the destination handset.
|
514
|
+
* * Message considered as **undelivered** to a participant if Twilio has received a delivery receipt
|
515
|
+
* indicating that the message was not delivered. This can happen for many reasons including carrier content
|
516
|
+
* filtering and the availability of the destination handset.
|
517
|
+
* * Message considered as **read** by a participant if the message has been delivered and opened by the
|
518
|
+
* recipient in a conversation. The recipient must have enabled the read receipts.
|
519
|
+
* * Message considered as **failed** to be delivered to a participant if the message could not be sent.
|
520
|
+
* This can happen for various reasons including queue overflows, account suspensions and media
|
521
|
+
* errors (in the case of MMS for instance).
|
522
|
+
*
|
523
|
+
* {@link AggregatedDeliveryReceipt} class contains an aggregated value {@link DeliveryAmount} for each delivery status.
|
524
|
+
*/
|
525
|
+
declare class AggregatedDeliveryReceipt {
|
526
|
+
private state;
|
527
|
+
/**
|
528
|
+
* @internal
|
529
|
+
*/
|
530
|
+
constructor(data: AggregatedDeliveryDescriptor);
|
531
|
+
/**
|
532
|
+
* Maximum number of delivery events expected for the message.
|
533
|
+
*/
|
534
|
+
get total(): number;
|
535
|
+
/**
|
536
|
+
* Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
|
537
|
+
*
|
538
|
+
* @return Amount of participants that have the **sent** delivery status for the message.
|
539
|
+
*/
|
540
|
+
get sent(): DeliveryAmount;
|
541
|
+
/**
|
542
|
+
* Message is considered as **delivered** to a participant if Twilio has received confirmation of message
|
543
|
+
* delivery from the upstream carrier, and, where available, the destination handset.
|
544
|
+
*
|
545
|
+
* @return Amount of participants that have the **delivered** delivery status for the message.
|
546
|
+
*/
|
547
|
+
get delivered(): DeliveryAmount;
|
548
|
+
/**
|
549
|
+
* Message is considered as **read** by a participant, if the message has been delivered and opened by the
|
550
|
+
* recipient in a conversation. The recipient must have enabled the read receipts.
|
551
|
+
*
|
552
|
+
* @return Amount of participants that have the **read** delivery status for the message.
|
553
|
+
*/
|
554
|
+
get read(): DeliveryAmount;
|
555
|
+
/**
|
556
|
+
* Message is considered as **undelivered** to a participant if Twilio has received a delivery receipt
|
557
|
+
* indicating that the message was not delivered. This can happen for many reasons including carrier content
|
558
|
+
* filtering and the availability of the destination handset.
|
559
|
+
*
|
560
|
+
* @return Ammount of participants that have the **undelivered** delivery status for the message.
|
561
|
+
*/
|
562
|
+
get undelivered(): DeliveryAmount;
|
563
|
+
/**
|
564
|
+
* Message is considered as **failed** to be delivered to a participant if the message could not be sent.
|
565
|
+
* This can happen for various reasons including queue overflows, account suspensions and media
|
566
|
+
* errors (in the case of MMS for instance). Twilio does not charge you for failed messages.
|
567
|
+
*
|
568
|
+
* @return Amount of participants that have the **failed** delivery status for the message.
|
569
|
+
*/
|
570
|
+
get failed(): DeliveryAmount;
|
571
|
+
_update(data: AggregatedDeliveryDescriptor): void;
|
572
|
+
_isEquals(data: AggregatedDeliveryDescriptor): boolean;
|
573
|
+
}
|
574
|
+
/**
|
575
|
+
* Message delivery status.
|
576
|
+
*/
|
577
|
+
type DeliveryStatus = "sent" | "delivered" | "failed" | "read" | "undelivered" | "queued";
|
578
|
+
interface DetailedDeliveryReceiptDescriptor {
|
579
|
+
sid: string;
|
580
|
+
message_sid: string;
|
581
|
+
conversation_sid: string;
|
582
|
+
channel_message_sid: string;
|
583
|
+
participant_sid: string;
|
584
|
+
status: DeliveryStatus;
|
585
|
+
error_code: number | null;
|
586
|
+
date_created: string;
|
587
|
+
date_updated: string;
|
588
|
+
}
|
589
|
+
/**
|
590
|
+
* Represents a delivery receipt of a message.
|
591
|
+
*/
|
592
|
+
declare class DetailedDeliveryReceipt {
|
593
|
+
/**
|
594
|
+
* Unique identifier for the delivery receipt.
|
595
|
+
*/
|
596
|
+
sid: string;
|
597
|
+
/**
|
598
|
+
* Unique identifier for the message in the conversation.
|
599
|
+
*/
|
600
|
+
messageSid: string;
|
601
|
+
/**
|
602
|
+
* Unique identifier for the conversation.
|
603
|
+
*/
|
604
|
+
conversationSid: string;
|
605
|
+
/**
|
606
|
+
* Unique identifier for the `‘channel’` message (e.g., `WAxx` for WhatsApp, `SMxx` for SMS).
|
607
|
+
*/
|
608
|
+
channelMessageSid: string;
|
609
|
+
/**
|
610
|
+
* Unique identifier for the participant.
|
611
|
+
*/
|
612
|
+
participantSid: string;
|
613
|
+
/**
|
614
|
+
* Status of the message delivery.
|
615
|
+
*/
|
616
|
+
status: DeliveryStatus;
|
617
|
+
/**
|
618
|
+
* Numeric error code mapped from Status callback code. Information about the error codes can be found
|
619
|
+
* [here](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors).
|
620
|
+
*/
|
621
|
+
errorCode: number | null;
|
622
|
+
/**
|
623
|
+
* Date this delivery receipt was created on.
|
624
|
+
*/
|
625
|
+
dateCreated: string;
|
626
|
+
/**
|
627
|
+
* Date this delivery receipt was last updated on.
|
628
|
+
*/
|
629
|
+
dateUpdated: string;
|
630
|
+
/**
|
631
|
+
* @internal
|
632
|
+
*/
|
633
|
+
constructor(descriptor: DetailedDeliveryReceiptDescriptor);
|
634
|
+
}
|
635
|
+
type MessageEvents = {
|
636
|
+
updated: (data: {
|
637
|
+
message: Message;
|
638
|
+
updateReasons: MessageUpdateReason[];
|
639
|
+
}) => void;
|
640
|
+
};
|
641
|
+
interface MessageServices {
|
642
|
+
mcsClient: McsClient;
|
643
|
+
network: Network;
|
644
|
+
commandExecutor: CommandExecutor;
|
645
|
+
}
|
646
|
+
interface MessageLinks {
|
647
|
+
self: string;
|
648
|
+
conversation: string;
|
649
|
+
messages_receipts: string;
|
650
|
+
}
|
651
|
+
/**
|
652
|
+
* The reason for the `updated` event being emitted by a message.
|
653
|
+
*/
|
654
|
+
type MessageUpdateReason = "body" | "lastUpdatedBy" | "dateCreated" | "dateUpdated" | "attributes" | "author" | "deliveryReceipt" | "subject";
|
655
|
+
/**
|
656
|
+
* Type of a message.
|
657
|
+
*/
|
658
|
+
type MessageType = "text" | "media";
|
659
|
+
interface MessageUpdatedEventArgs {
|
660
|
+
message: Message;
|
661
|
+
updateReasons: MessageUpdateReason[];
|
662
|
+
}
|
663
|
+
/**
|
664
|
+
* A message in a conversation.
|
665
|
+
*/
|
666
|
+
declare class Message extends ReplayEventEmitter<MessageEvents> {
|
667
|
+
/**
|
668
|
+
* Conversation that the message is in.
|
669
|
+
*/
|
670
|
+
readonly conversation: Conversation;
|
671
|
+
private readonly links;
|
672
|
+
private readonly configuration;
|
673
|
+
private readonly services;
|
674
|
+
private state;
|
675
|
+
/**
|
676
|
+
* @internal
|
677
|
+
*/
|
678
|
+
constructor(index: number, data: any, conversation: Conversation, links: MessageLinks, configuration: Configuration, services: MessageServices);
|
679
|
+
/**
|
680
|
+
* Fired when the properties or the body of the message has been updated.
|
681
|
+
*
|
682
|
+
* Parameters:
|
683
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
684
|
+
* * {@link Message} message - the message in question
|
685
|
+
* * {@link MessageUpdateReason}[] updateReasons - array of reasons for the update
|
686
|
+
*/
|
687
|
+
static readonly updated = "updated";
|
688
|
+
/**
|
689
|
+
* The server-assigned unique identifier for the message.
|
690
|
+
*/
|
691
|
+
get sid(): string;
|
692
|
+
/**
|
693
|
+
* Name of the user that sent the message.
|
694
|
+
*/
|
695
|
+
get author(): string;
|
696
|
+
/**
|
697
|
+
* Message subject. Used only in email conversations.
|
698
|
+
*/
|
699
|
+
get subject(): string | null;
|
700
|
+
/**
|
701
|
+
* Body of the message.
|
702
|
+
*/
|
703
|
+
get body(): string;
|
704
|
+
/**
|
705
|
+
* Date this message was last updated on.
|
706
|
+
*/
|
707
|
+
get dateUpdated(): Date;
|
708
|
+
/**
|
709
|
+
* Index of the message in the conversation's messages list.
|
710
|
+
* By design of the Conversations system, the message indices may have arbitrary gaps between them,
|
711
|
+
* that does not necessarily mean they were deleted or otherwise modified - just that
|
712
|
+
* messages may have some non-contiguous indices even if they are being sent immediately one after another.
|
713
|
+
*
|
714
|
+
* Trying to use indices for some calculations is going to be unreliable.
|
715
|
+
*
|
716
|
+
* To calculate the number of unread messages it is better to use the read horizon API.
|
717
|
+
* See {@link Conversation.getUnreadMessagesCount} for details.
|
718
|
+
*/
|
719
|
+
get index(): number;
|
720
|
+
/**
|
721
|
+
* Identity of the last user that updated the message.
|
722
|
+
*/
|
723
|
+
get lastUpdatedBy(): string;
|
724
|
+
/**
|
725
|
+
* Date this message was created on.
|
726
|
+
*/
|
727
|
+
get dateCreated(): Date;
|
728
|
+
/**
|
729
|
+
* Custom attributes of the message.
|
730
|
+
*/
|
731
|
+
get attributes(): Object;
|
732
|
+
/**
|
733
|
+
* Push notification type of the message.
|
734
|
+
*/
|
735
|
+
get type(): MessageType;
|
736
|
+
/**
|
737
|
+
* One of the attached media.
|
738
|
+
* @deprecated Use attachedMedia instead. Note that the latter is now an array.
|
739
|
+
*/
|
740
|
+
get media(): Media;
|
741
|
+
/**
|
742
|
+
* Return all media attachments, except email body/history attachments, without temporary urls.
|
743
|
+
*/
|
744
|
+
get attachedMedia(): Array<Media> | null;
|
745
|
+
/**
|
746
|
+
* The server-assigned unique identifier of the authoring participant.
|
747
|
+
*/
|
748
|
+
get participantSid(): string;
|
749
|
+
/**
|
750
|
+
* Aggregated information about the message delivery statuses across all participants of a conversation..
|
751
|
+
*/
|
752
|
+
get aggregatedDeliveryReceipt(): AggregatedDeliveryReceipt | null;
|
753
|
+
/**
|
754
|
+
* Return a (possibly empty) array of media matching a specific set of categories.
|
755
|
+
* Allowed category is so far only 'media'.
|
756
|
+
* @param categories Array of categories to match.
|
757
|
+
* @returns Array of media descriptors matching given categories.
|
758
|
+
*/
|
759
|
+
getMediaByCategory(categories: Array<MediaCategory>): Array<Media> | null;
|
760
|
+
_update(data: any): void;
|
761
|
+
/**
|
762
|
+
* Get the participant who is the author of the message.
|
763
|
+
*/
|
764
|
+
getParticipant(): Promise<Participant>;
|
765
|
+
/**
|
766
|
+
* Get the delivery receipts of the message.
|
767
|
+
*/
|
768
|
+
getDetailedDeliveryReceipts(): Promise<DetailedDeliveryReceipt[]>;
|
769
|
+
/**
|
770
|
+
* Remove the message.
|
771
|
+
*/
|
772
|
+
remove(): Promise<Message>;
|
773
|
+
/**
|
774
|
+
* Edit the message body.
|
775
|
+
* @param body New body of the message.
|
776
|
+
*/
|
777
|
+
updateBody(body: string): Promise<Message>;
|
778
|
+
/**
|
779
|
+
* Edit the message attributes.
|
780
|
+
* @param attributes New attributes.
|
781
|
+
*/
|
782
|
+
updateAttributes(attributes: any): Promise<Message>;
|
783
|
+
/**
|
784
|
+
* Get content URLs for all media attachments in the given set using single operation.
|
785
|
+
* @param contentSet Set of media attachments to query for content URL.
|
786
|
+
*/
|
787
|
+
attachTemporaryUrlsFor(contentSet: Media[]): Promise<Media[]>;
|
788
|
+
private _getDetailedDeliveryReceiptsPaginator;
|
789
|
+
}
|
790
|
+
/**
|
791
|
+
* Pagination helper interface.
|
792
|
+
* @typeParam T The item type.
|
793
|
+
*/
|
794
|
+
interface Paginator<T> {
|
795
|
+
/**
|
796
|
+
* Indicates the existence of the next page.
|
797
|
+
*/
|
798
|
+
hasNextPage: boolean;
|
799
|
+
/**
|
800
|
+
* Indicates the existence of the previous page.
|
801
|
+
*/
|
802
|
+
hasPrevPage: boolean;
|
803
|
+
/**
|
804
|
+
* Array of elements of type T on the current page.
|
805
|
+
*/
|
806
|
+
items: T[];
|
807
|
+
/**
|
808
|
+
* Request next page.
|
809
|
+
* Does not modify the existing object.
|
810
|
+
*/
|
811
|
+
nextPage(): Promise<Paginator<T>>;
|
812
|
+
/**
|
813
|
+
* Request previous page.
|
814
|
+
* Does not modify the existing object.
|
815
|
+
*/
|
816
|
+
prevPage(): Promise<Paginator<T>>;
|
817
|
+
}
|
818
|
+
interface TypingIndicatorServices {
|
819
|
+
twilsockClient: TwilsockClient;
|
820
|
+
notificationClient: Notifications;
|
821
|
+
}
|
822
|
+
/**
|
823
|
+
* An important note in regards to typing timeout timers. There are two places that the SDK can get the "typing_timeout" attribute from. The first
|
824
|
+
* place that the attribute appears in is the response received from POST -> /v1/typing REST call. In the body of that response, the value of the
|
825
|
+
* "typing_timeout" attribute will be exactly the same as defined in the console. The second place that the attribute appears in is from a
|
826
|
+
* notification of type "twilio.ipmsg.typing_indicator". In this case, the "typing_timeout" value will be +1 of that in the console. This
|
827
|
+
* intentional. The timeout returned from the POST -> /v1/typing call should be used to disable further calls for that period of time. On contrary,
|
828
|
+
* the timeout returned from the notification should be used as the timeout for the "typingEnded" event, +1 is to account for latency.
|
829
|
+
*
|
830
|
+
* @private
|
831
|
+
*/
|
832
|
+
/**
|
833
|
+
* @class TypingIndicator
|
834
|
+
*
|
835
|
+
* @constructor
|
836
|
+
* @private
|
837
|
+
*/
|
838
|
+
declare class TypingIndicator {
|
839
|
+
private readonly services;
|
840
|
+
private readonly configuration;
|
841
|
+
private sentUpdates;
|
842
|
+
private getConversation;
|
843
|
+
private serviceTypingTimeout;
|
844
|
+
constructor(getConversation: any, config: Configuration, services: TypingIndicatorServices);
|
845
|
+
get typingTimeout(): number;
|
846
|
+
/**
|
847
|
+
* Initialize TypingIndicator controller
|
848
|
+
* Registers for needed message types and sets listeners
|
849
|
+
* @private
|
850
|
+
*/
|
851
|
+
initialize(): void;
|
852
|
+
/**
|
853
|
+
* Remote participants typing events handler
|
854
|
+
*/
|
855
|
+
private _handleRemoteTyping;
|
856
|
+
/**
|
857
|
+
* Send typing event for the given conversation sid
|
858
|
+
* @param {String} conversationSid
|
859
|
+
*/
|
860
|
+
send(conversationSid: string): Promise<void>;
|
861
|
+
private _send;
|
862
|
+
}
|
863
|
+
/**
|
864
|
+
* An unsent message. Returned from {@link MessageBuilder.build}.
|
865
|
+
*/
|
866
|
+
declare class UnsentMessage {
|
867
|
+
private messagesEntity;
|
868
|
+
text?: string;
|
869
|
+
attributes: any;
|
870
|
+
mediaContent: [MediaCategory, FormData | SendMediaOptions][];
|
871
|
+
emailOptions?: SendEmailOptions;
|
872
|
+
/**
|
873
|
+
* @internal
|
874
|
+
*/
|
875
|
+
constructor(messagesEntity: any);
|
876
|
+
/**
|
877
|
+
* Send the prepared message to the conversation.
|
878
|
+
* @returns Index of the new message in the conversation.
|
879
|
+
*/
|
880
|
+
send(): Promise<number>;
|
881
|
+
}
|
882
|
+
/**
|
883
|
+
* Message builder. Allows the message to be built and sent via method chaining.
|
884
|
+
*
|
885
|
+
* Example:
|
886
|
+
*
|
887
|
+
* ```ts
|
888
|
+
* await testConversation.prepareMessage()
|
889
|
+
* .setBody('Hello!')
|
890
|
+
* .setAttributes({foo: 'bar'})
|
891
|
+
* .addMedia(media1)
|
892
|
+
* .addMedia(media2)
|
893
|
+
* .build()
|
894
|
+
* .send();
|
895
|
+
* ```
|
896
|
+
*/
|
897
|
+
declare class MessageBuilder {
|
898
|
+
private readonly limits;
|
899
|
+
private readonly message;
|
900
|
+
/**
|
901
|
+
* @internal
|
902
|
+
*/
|
903
|
+
constructor(limits: Limits, messagesEntity: any);
|
904
|
+
/**
|
905
|
+
* Sets the message body.
|
906
|
+
* @param text Contents of the body.
|
907
|
+
*/
|
908
|
+
setBody(text: string): MessageBuilder;
|
909
|
+
/**
|
910
|
+
* Sets the message subject.
|
911
|
+
* @param subject Contents of the subject.
|
912
|
+
*/
|
913
|
+
setSubject(subject: string): MessageBuilder;
|
914
|
+
/**
|
915
|
+
* Sets the message attributes.
|
916
|
+
* @param attributes Message attributes.
|
917
|
+
*/
|
918
|
+
setAttributes(attributes: any): MessageBuilder;
|
919
|
+
/**
|
920
|
+
* Adds media to the message.
|
921
|
+
* @param payload Media to add.
|
922
|
+
*/
|
923
|
+
addMedia(payload: FormData | SendMediaOptions): MessageBuilder;
|
924
|
+
/**
|
925
|
+
* Builds the message, making it ready to be sent.
|
926
|
+
*/
|
927
|
+
build(): UnsentMessage;
|
928
|
+
private getPayloadContentType;
|
929
|
+
}
|
930
|
+
type ConversationEvents = {
|
931
|
+
participantJoined: (participant: Participant) => void;
|
932
|
+
participantLeft: (participant: Participant) => void;
|
933
|
+
participantUpdated: (data: {
|
934
|
+
participant: Participant;
|
935
|
+
updateReasons: ParticipantUpdateReason[];
|
936
|
+
}) => void;
|
937
|
+
messageAdded: (message: Message) => void;
|
938
|
+
messageRemoved: (message: Message) => void;
|
939
|
+
messageUpdated: (data: {
|
940
|
+
message: Message;
|
941
|
+
updateReasons: MessageUpdateReason[];
|
942
|
+
}) => void;
|
943
|
+
typingEnded: (participant: Participant) => void;
|
944
|
+
typingStarted: (participant: Participant) => void;
|
945
|
+
updated: (data: {
|
946
|
+
conversation: Conversation;
|
947
|
+
updateReasons: ConversationUpdateReason[];
|
948
|
+
}) => void;
|
949
|
+
removed: (conversation: Conversation) => void;
|
950
|
+
};
|
951
|
+
interface ConversationServices {
|
952
|
+
users: Users;
|
953
|
+
typingIndicator: TypingIndicator;
|
954
|
+
network: Network;
|
955
|
+
mcsClient: McsClient;
|
956
|
+
syncClient: SyncClient;
|
957
|
+
commandExecutor: CommandExecutor;
|
958
|
+
}
|
959
|
+
interface ConversationDescriptor {
|
960
|
+
channel: string;
|
961
|
+
entityName: string;
|
962
|
+
uniqueName: string;
|
963
|
+
attributes: any;
|
964
|
+
createdBy?: string;
|
965
|
+
friendlyName?: string;
|
966
|
+
lastConsumedMessageIndex: number;
|
967
|
+
dateCreated: any;
|
968
|
+
dateUpdated: any;
|
969
|
+
notificationLevel?: NotificationLevel;
|
970
|
+
}
|
971
|
+
interface ConversationLinks {
|
972
|
+
self: string;
|
973
|
+
messages: string;
|
974
|
+
participants: string;
|
975
|
+
}
|
976
|
+
/**
|
977
|
+
* The reason for the `updated` event being emitted by a conversation.
|
978
|
+
*/
|
979
|
+
type ConversationUpdateReason = "attributes" | "createdBy" | "dateCreated" | "dateUpdated" | "friendlyName" | "lastReadMessageIndex" | "state" | "status" | "uniqueName" | "lastMessage" | "notificationLevel";
|
980
|
+
/**
|
981
|
+
* The status of the conversation, relative to the client: whether
|
982
|
+
* the conversation has been `joined` or the client is
|
983
|
+
* `notParticipating` in the conversation.
|
984
|
+
*/
|
985
|
+
type ConversationStatus = "notParticipating" | "joined";
|
986
|
+
/**
|
987
|
+
* The user's notification level for the conversation. Determines
|
988
|
+
* whether the currently logged-in user will receive pushes for events
|
989
|
+
* in this conversation. Can be either `muted` or `default`, where
|
990
|
+
* `default` defers to the global service push configuration.
|
991
|
+
*/
|
992
|
+
type NotificationLevel = "default" | "muted";
|
993
|
+
/**
|
994
|
+
* The state of the conversation.
|
995
|
+
*/
|
996
|
+
interface ConversationState {
|
997
|
+
/**
|
998
|
+
* The current state.
|
999
|
+
*/
|
1000
|
+
current: "active" | "inactive" | "closed";
|
1001
|
+
/**
|
1002
|
+
* Date at which the latest conversation state update happened.
|
1003
|
+
*/
|
1004
|
+
dateUpdated: Date;
|
1005
|
+
}
|
1006
|
+
interface ConversationUpdatedEventArgs {
|
1007
|
+
conversation: Conversation;
|
1008
|
+
updateReasons: ConversationUpdateReason[];
|
1009
|
+
}
|
1010
|
+
/**
|
1011
|
+
* Configuration for attaching a media file to a message.
|
1012
|
+
* These options can be passed to {@link Conversation.sendMessage} and
|
1013
|
+
* {@link MessageBuilder.addMedia}.
|
1014
|
+
*/
|
1015
|
+
interface SendMediaOptions {
|
1016
|
+
/**
|
1017
|
+
* Content type of media.
|
1018
|
+
*/
|
1019
|
+
contentType: string;
|
1020
|
+
/**
|
1021
|
+
* Optional filename.
|
1022
|
+
*/
|
1023
|
+
filename?: string;
|
1024
|
+
/**
|
1025
|
+
* Content to post.
|
1026
|
+
*/
|
1027
|
+
media: string | Buffer | Blob;
|
1028
|
+
}
|
1029
|
+
/**
|
1030
|
+
* These options can be passed to {@link Conversation.sendMessage}.
|
1031
|
+
*/
|
1032
|
+
interface SendEmailOptions {
|
1033
|
+
/**
|
1034
|
+
* Message subject. Ignored for media messages.
|
1035
|
+
*/
|
1036
|
+
subject?: string;
|
1037
|
+
}
|
1038
|
+
/**
|
1039
|
+
* Information about the last message of a conversation.
|
1040
|
+
*/
|
1041
|
+
interface LastMessage {
|
1042
|
+
/**
|
1043
|
+
* Message's index.
|
1044
|
+
*/
|
1045
|
+
index?: number;
|
1046
|
+
/**
|
1047
|
+
* Message's creation date.
|
1048
|
+
*/
|
1049
|
+
dateCreated?: Date;
|
1050
|
+
}
|
1051
|
+
/**
|
1052
|
+
* A conversation represents communication between multiple Conversations clients
|
1053
|
+
*/
|
1054
|
+
declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
1055
|
+
/**
|
1056
|
+
* Unique system identifier of the conversation.
|
1057
|
+
*/
|
1058
|
+
readonly sid: string;
|
1059
|
+
readonly links: ConversationLinks;
|
1060
|
+
private readonly configuration;
|
1061
|
+
private readonly services;
|
1062
|
+
private channelState;
|
1063
|
+
private statusSource;
|
1064
|
+
private entityPromise;
|
1065
|
+
private entityName;
|
1066
|
+
private entity;
|
1067
|
+
private messagesEntity;
|
1068
|
+
private participantsEntity;
|
1069
|
+
private readonly participants;
|
1070
|
+
/**
|
1071
|
+
* @internal
|
1072
|
+
*/
|
1073
|
+
constructor(descriptor: ConversationDescriptor, sid: string, links: ConversationLinks, configuration: Configuration, services: ConversationServices);
|
1074
|
+
/**
|
1075
|
+
* Fired when a participant has joined the conversation.
|
1076
|
+
*
|
1077
|
+
* Parameters:
|
1078
|
+
* 1. {@link Participant} `participant` - participant that joined the conversation
|
1079
|
+
* @event
|
1080
|
+
*/
|
1081
|
+
static readonly participantJoined = "participantJoined";
|
1082
|
+
/**
|
1083
|
+
* Fired when a participant has left the conversation.
|
1084
|
+
*
|
1085
|
+
* Parameters:
|
1086
|
+
* 1. {@link Participant} `participant` - participant that left the conversation
|
1087
|
+
* @event
|
1088
|
+
*/
|
1089
|
+
static readonly participantLeft = "participantLeft";
|
1090
|
+
/**
|
1091
|
+
* Fired when data of a participant has been updated.
|
1092
|
+
*
|
1093
|
+
* Parameters:
|
1094
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
1095
|
+
* * {@link Participant} `participant` - participant that has received the update
|
1096
|
+
* * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons for update
|
1097
|
+
* @event
|
1098
|
+
*/
|
1099
|
+
static readonly participantUpdated = "participantUpdated";
|
1100
|
+
/**
|
1101
|
+
* Fired when a new message has been added to the conversation.
|
1102
|
+
*
|
1103
|
+
* Parameters:
|
1104
|
+
* 1. {@link Message} `message` - message that has been added
|
1105
|
+
* @event
|
1106
|
+
*/
|
1107
|
+
static readonly messageAdded = "messageAdded";
|
1108
|
+
/**
|
1109
|
+
* Fired when message is removed from the conversation's message list.
|
1110
|
+
*
|
1111
|
+
* Parameters:
|
1112
|
+
* 1. {@link Message} `message` - message that has been removed
|
1113
|
+
* @event
|
1114
|
+
*/
|
1115
|
+
static readonly messageRemoved = "messageRemoved";
|
1116
|
+
/**
|
1117
|
+
* Fired when data of a message has been updated.
|
1118
|
+
*
|
1119
|
+
* Parameters:
|
1120
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
1121
|
+
* * {@link Message} `message` - message that has received the update
|
1122
|
+
* * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for update
|
1123
|
+
* @event
|
1124
|
+
*/
|
1125
|
+
static readonly messageUpdated = "messageUpdated";
|
1126
|
+
/**
|
1127
|
+
* Fired when a participant has stopped typing.
|
1128
|
+
*
|
1129
|
+
* Parameters:
|
1130
|
+
* 1. {@link Participant} `participant` - the participant that has stopped typing
|
1131
|
+
* @event
|
1132
|
+
*/
|
1133
|
+
static readonly typingEnded = "typingEnded";
|
1134
|
+
/**
|
1135
|
+
* Fired when a participant has started typing.
|
1136
|
+
*
|
1137
|
+
* Parameters:
|
1138
|
+
* 1. {@link Participant} `participant` - the participant that has started typing
|
1139
|
+
* @event
|
1140
|
+
*/
|
1141
|
+
static readonly typingStarted = "typingStarted";
|
1142
|
+
/**
|
1143
|
+
* Fired when the data of the conversation has been updated.
|
1144
|
+
*
|
1145
|
+
* Parameters:
|
1146
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
1147
|
+
* * {@link Conversation} `conversation` - conversation that has received the update
|
1148
|
+
* * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons for update
|
1149
|
+
* @event
|
1150
|
+
*/
|
1151
|
+
static readonly updated = "updated";
|
1152
|
+
/**
|
1153
|
+
* Fired when the conversation was destroyed or the currently-logged-in user has left private conversation.
|
1154
|
+
*
|
1155
|
+
* Parameters:
|
1156
|
+
* 1. {@link Conversation} `conversation` - conversation that has been removed
|
1157
|
+
* @event
|
1158
|
+
*/
|
1159
|
+
static readonly removed = "removed";
|
1160
|
+
/**
|
1161
|
+
* Unique name of the conversation.
|
1162
|
+
*/
|
1163
|
+
get uniqueName(): string;
|
1164
|
+
/**
|
1165
|
+
* Status of the conversation.
|
1166
|
+
*/
|
1167
|
+
get status(): ConversationStatus;
|
1168
|
+
/**
|
1169
|
+
* Name of the conversation.
|
1170
|
+
*/
|
1171
|
+
get friendlyName(): string;
|
1172
|
+
/**
|
1173
|
+
* Date this conversation was last updated on.
|
1174
|
+
*/
|
1175
|
+
get dateUpdated(): any;
|
1176
|
+
/**
|
1177
|
+
* Date this conversation was created on.
|
1178
|
+
*/
|
1179
|
+
get dateCreated(): any;
|
1180
|
+
/**
|
1181
|
+
* Identity of the user that created this conversation.
|
1182
|
+
*/
|
1183
|
+
get createdBy(): string;
|
1184
|
+
/**
|
1185
|
+
* Custom attributes of the conversation.
|
1186
|
+
*/
|
1187
|
+
get attributes(): any;
|
1188
|
+
/**
|
1189
|
+
* Index of the last message the user has read in this conversation.
|
1190
|
+
*/
|
1191
|
+
get lastReadMessageIndex(): number | null;
|
1192
|
+
/**
|
1193
|
+
* Last message sent to this conversation.
|
1194
|
+
*/
|
1195
|
+
get lastMessage(): LastMessage;
|
1196
|
+
/**
|
1197
|
+
* User notification level for this conversation.
|
1198
|
+
*/
|
1199
|
+
get notificationLevel(): NotificationLevel;
|
1200
|
+
get limits(): Limits;
|
1201
|
+
/**
|
1202
|
+
* State of the conversation.
|
1203
|
+
*/
|
1204
|
+
get state(): ConversationState | undefined;
|
1205
|
+
/**
|
1206
|
+
* Load and subscribe to this conversation and do not subscribe to its participants and messages.
|
1207
|
+
* This or _subscribeStreams will need to be called before any events on conversation will fire.
|
1208
|
+
* @internal
|
1209
|
+
*/
|
1210
|
+
_subscribe(): Promise<any>;
|
1211
|
+
/**
|
1212
|
+
* Load the attributes of this conversation and instantiate its participants and messages.
|
1213
|
+
* This or _subscribe will need to be called before any events on the conversation will fire.
|
1214
|
+
* This will need to be called before any events on participants or messages will fire
|
1215
|
+
* @internal
|
1216
|
+
*/
|
1217
|
+
_subscribeStreams(): Promise<void>;
|
1218
|
+
/**
|
1219
|
+
* Stop listening for and firing events on this conversation.
|
1220
|
+
* @internal
|
1221
|
+
*/
|
1222
|
+
_unsubscribe(): Promise<[
|
1223
|
+
void,
|
1224
|
+
any
|
1225
|
+
]>;
|
1226
|
+
/**
|
1227
|
+
* Set conversation status.
|
1228
|
+
* @internal
|
1229
|
+
*/
|
1230
|
+
_setStatus(status: ConversationStatus, source: ConversationsDataSource): void;
|
1231
|
+
/**
|
1232
|
+
* Get the source of the conversation update.
|
1233
|
+
* @internal
|
1234
|
+
*/
|
1235
|
+
_statusSource(): ConversationsDataSource;
|
1236
|
+
private static preprocessUpdate;
|
1237
|
+
/**
|
1238
|
+
* Update the local conversation object with new values.
|
1239
|
+
* @internal
|
1240
|
+
*/
|
1241
|
+
_update(update: any): void;
|
1242
|
+
/**
|
1243
|
+
* @internal
|
1244
|
+
*/
|
1245
|
+
private _onMessageAdded;
|
1246
|
+
private _setLastReadMessageIndex;
|
1247
|
+
/**
|
1248
|
+
* Add a participant to the conversation by its identity.
|
1249
|
+
* @param identity Identity of the Client to add.
|
1250
|
+
* @param attributes Attributes to be attached to the participant.
|
1251
|
+
*/
|
1252
|
+
add(identity: string, attributes?: any): Promise<void>;
|
1253
|
+
/**
|
1254
|
+
* Add a non-chat participant to the conversation.
|
1255
|
+
* @param proxyAddress Proxy (Twilio) address of the participant.
|
1256
|
+
* @param address User address of the participant.
|
1257
|
+
* @param attributes Attributes to be attached to the participant.
|
1258
|
+
*/
|
1259
|
+
addNonChatParticipant(proxyAddress: string, address: string, attributes?: any): Promise<void>;
|
1260
|
+
/**
|
1261
|
+
* Advance the conversation's last read message index to the current read horizon.
|
1262
|
+
* Rejects if the user is not a participant of the conversation.
|
1263
|
+
* Last read message index is updated only if the new index value is higher than the previous.
|
1264
|
+
* @param index Message index to advance to.
|
1265
|
+
* @return Resulting unread messages count in the conversation.
|
1266
|
+
*/
|
1267
|
+
advanceLastReadMessageIndex(index: number): Promise<number>;
|
1268
|
+
/**
|
1269
|
+
* Delete the conversation and unsubscribe from its events.
|
1270
|
+
*/
|
1271
|
+
delete(): Promise<Conversation>;
|
1272
|
+
/**
|
1273
|
+
* Get the custom attributes of this Conversation.
|
1274
|
+
*/
|
1275
|
+
getAttributes(): Promise<any>;
|
1276
|
+
/**
|
1277
|
+
* Returns messages from the conversation using the paginator interface.
|
1278
|
+
* @param pageSize Number of messages to return in a single chunk. Default is 30.
|
1279
|
+
* @param anchor Index of the newest message to fetch. Default is from the end.
|
1280
|
+
* @param direction Query direction. By default it queries backwards
|
1281
|
+
* from newer to older. The `"forward"` value will query in the opposite direction.
|
1282
|
+
* @return A page of messages.
|
1283
|
+
*/
|
1284
|
+
getMessages(pageSize?: number, anchor?: number, direction?: "backwards" | "forward"): Promise<Paginator<Message>>;
|
1285
|
+
/**
|
1286
|
+
* Get a list of all the participants who are joined to this conversation.
|
1287
|
+
*/
|
1288
|
+
getParticipants(): Promise<Participant[]>;
|
1289
|
+
/**
|
1290
|
+
* Get conversation participants count.
|
1291
|
+
*
|
1292
|
+
* This method is semi-realtime. This means that this data will be eventually correct,
|
1293
|
+
* but will also be possibly incorrect for a few seconds. The Conversations system does not
|
1294
|
+
* provide real time events for counter values changes.
|
1295
|
+
*
|
1296
|
+
* This is useful for any UI badges, but it is not recommended to build any core application
|
1297
|
+
* logic based on these counters being accurate in real time.
|
1298
|
+
*/
|
1299
|
+
getParticipantsCount(): Promise<number>;
|
1300
|
+
/**
|
1301
|
+
* Get a participant by its SID.
|
1302
|
+
* @param participantSid Participant SID.
|
1303
|
+
*/
|
1304
|
+
getParticipantBySid(participantSid: string): Promise<Participant>;
|
1305
|
+
/**
|
1306
|
+
* Get a participant by its identity.
|
1307
|
+
* @param identity Participant identity.
|
1308
|
+
*/
|
1309
|
+
getParticipantByIdentity(identity: string): Promise<Participant>;
|
1310
|
+
/**
|
1311
|
+
* Get the total message count in the conversation.
|
1312
|
+
*
|
1313
|
+
* This method is semi-realtime. This means that this data will be eventually correct,
|
1314
|
+
* but will also be possibly incorrect for a few seconds. The Conversations system does not
|
1315
|
+
* provide real time events for counter values changes.
|
1316
|
+
*
|
1317
|
+
* This is useful for any UI badges, but it is not recommended to build any core application
|
1318
|
+
* logic based on these counters being accurate in real time.
|
1319
|
+
*/
|
1320
|
+
getMessagesCount(): Promise<number>;
|
1321
|
+
/**
|
1322
|
+
* Get unread messages count for the user if they are a participant of this conversation.
|
1323
|
+
* Rejects if the user is not a participant of the conversation.
|
1324
|
+
*
|
1325
|
+
* Use this method to obtain the number of unread messages together with
|
1326
|
+
* {@link Conversation.updateLastReadMessageIndex} instead of relying on the
|
1327
|
+
* message indices which may have gaps. See {@link Message.index} for details.
|
1328
|
+
*
|
1329
|
+
* This method is semi-realtime. This means that this data will be eventually correct,
|
1330
|
+
* but will also be possibly incorrect for a few seconds. The Conversations system does not
|
1331
|
+
* provide real time events for counter values changes.
|
1332
|
+
*
|
1333
|
+
* This is useful for any UI badges, but it is not recommended to build any core application
|
1334
|
+
* logic based on these counters being accurate in real time.
|
1335
|
+
*/
|
1336
|
+
getUnreadMessagesCount(): Promise<number | null>;
|
1337
|
+
/**
|
1338
|
+
* Join the conversation and subscribe to its events.
|
1339
|
+
*/
|
1340
|
+
join(): Promise<Conversation>;
|
1341
|
+
/**
|
1342
|
+
* Leave the conversation.
|
1343
|
+
*/
|
1344
|
+
leave(): Promise<Conversation>;
|
1345
|
+
/**
|
1346
|
+
* Remove a participant from the conversation. When a string is passed as the
|
1347
|
+
* argument, it will assume that the string is an identity or SID.
|
1348
|
+
* @param participant Identity, SID or the participant object to remove.
|
1349
|
+
*/
|
1350
|
+
removeParticipant(participant: string | Participant): Promise<void>;
|
1351
|
+
/**
|
1352
|
+
* Send a message to the conversation.
|
1353
|
+
* @param message Message body for the text message,
|
1354
|
+
* `FormData` or {@link SendMediaOptions} for media content. Sending FormData is supported only with the browser engine.
|
1355
|
+
* @param messageAttributes Attributes for the message.
|
1356
|
+
* @param emailOptions Email options for the message.
|
1357
|
+
* @return Index of the new message.
|
1358
|
+
*/
|
1359
|
+
sendMessage(message: string | FormData | SendMediaOptions | null, messageAttributes?: any, emailOptions?: SendEmailOptions): Promise<number>;
|
1360
|
+
/**
|
1361
|
+
* New interface to prepare for sending a message.
|
1362
|
+
* Use instead of `sendMessage`.
|
1363
|
+
*/
|
1364
|
+
prepareMessage(): MessageBuilder;
|
1365
|
+
/**
|
1366
|
+
* Set last read message index of the conversation to the index of the last known message.
|
1367
|
+
* @return Resulting unread messages count in the conversation.
|
1368
|
+
*/
|
1369
|
+
setAllMessagesRead(): Promise<number>;
|
1370
|
+
/**
|
1371
|
+
* Set all messages in the conversation unread.
|
1372
|
+
* @return Resulting unread messages count in the conversation.
|
1373
|
+
*/
|
1374
|
+
setAllMessagesUnread(): Promise<number>;
|
1375
|
+
/**
|
1376
|
+
* Set user notification level for this conversation.
|
1377
|
+
* @param notificationLevel New user notification level.
|
1378
|
+
*/
|
1379
|
+
setUserNotificationLevel(notificationLevel: NotificationLevel): Promise<void>;
|
1380
|
+
/**
|
1381
|
+
* Send a notification to the server indicating that this client is currently typing in this conversation.
|
1382
|
+
* Typing ended notification is sent after a while automatically, but by calling this method again you ensure that typing ended is not received.
|
1383
|
+
*/
|
1384
|
+
typing(): Promise<void>;
|
1385
|
+
/**
|
1386
|
+
* Update the attributes of the conversation.
|
1387
|
+
* @param attributes New attributes.
|
1388
|
+
*/
|
1389
|
+
updateAttributes(attributes: any): Promise<Conversation>;
|
1390
|
+
/**
|
1391
|
+
* Update the friendly name of the conversation.
|
1392
|
+
* @param friendlyName New friendly name.
|
1393
|
+
*/
|
1394
|
+
updateFriendlyName(friendlyName: string): Promise<Conversation>;
|
1395
|
+
/**
|
1396
|
+
* Set the last read message index to the current read horizon.
|
1397
|
+
* @param index Message index to set as last read.
|
1398
|
+
* If null is provided, then the behavior is identical to {@link Conversation.setAllMessagesUnread}.
|
1399
|
+
* @returns Resulting unread messages count in the conversation.
|
1400
|
+
*/
|
1401
|
+
updateLastReadMessageIndex(index: number | null): Promise<number>;
|
1402
|
+
/**
|
1403
|
+
* Update the unique name of the conversation.
|
1404
|
+
* @param uniqueName New unique name for the conversation. Setting unique name to null removes it.
|
1405
|
+
*/
|
1406
|
+
updateUniqueName(uniqueName: string | null): Promise<Conversation>;
|
1407
|
+
}
|
1408
|
+
type ConversationsDataSource = "sync" | "chat" | "rest";
|
1409
|
+
/**
|
1410
|
+
* Push notification type.
|
1411
|
+
*/
|
1412
|
+
type PushNotificationType = "twilio.conversations.new_message" | "twilio.conversations.added_to_conversation" | "twilio.conversations.removed_from_conversation";
|
1413
|
+
interface PushNotificationDescriptor {
|
1414
|
+
title: string;
|
1415
|
+
body: string;
|
1416
|
+
sound: string;
|
1417
|
+
badge: number;
|
1418
|
+
action: string;
|
1419
|
+
type: PushNotificationType;
|
1420
|
+
data: Object;
|
1421
|
+
}
|
1422
|
+
/**
|
1423
|
+
* Additional data for a given push notification.
|
1424
|
+
*/
|
1425
|
+
interface PushNotificationData {
|
1426
|
+
/**
|
1427
|
+
* SID of the conversation.
|
1428
|
+
*/
|
1429
|
+
conversationSid?: string;
|
1430
|
+
/**
|
1431
|
+
* Index of the message in the conversation.
|
1432
|
+
*/
|
1433
|
+
messageIndex?: number;
|
1434
|
+
/**
|
1435
|
+
* SID of the message in the conversation.
|
1436
|
+
*/
|
1437
|
+
messageSid?: string;
|
1438
|
+
}
|
1439
|
+
/**
|
1440
|
+
* Push notification for a Conversations client.
|
1441
|
+
*/
|
1442
|
+
declare class PushNotification {
|
1443
|
+
/**
|
1444
|
+
* Title of the notification.
|
1445
|
+
*/
|
1446
|
+
readonly title: string;
|
1447
|
+
/**
|
1448
|
+
* Text of the notification.
|
1449
|
+
*/
|
1450
|
+
readonly body: string;
|
1451
|
+
/**
|
1452
|
+
* Sound of the notification.
|
1453
|
+
*/
|
1454
|
+
readonly sound: string;
|
1455
|
+
/**
|
1456
|
+
* Number of the badge.
|
1457
|
+
*/
|
1458
|
+
readonly badge: number;
|
1459
|
+
/**
|
1460
|
+
* Notification action (`click_action` in FCM terms and `category` in APN terms).
|
1461
|
+
*/
|
1462
|
+
readonly action: string;
|
1463
|
+
/**
|
1464
|
+
* Type of the notification.
|
1465
|
+
*/
|
1466
|
+
readonly type: PushNotificationType;
|
1467
|
+
/**
|
1468
|
+
* Additional data of the conversation.
|
1469
|
+
*/
|
1470
|
+
readonly data: PushNotificationData;
|
1471
|
+
/**
|
1472
|
+
* @internal
|
1473
|
+
*/
|
1474
|
+
constructor(data: PushNotificationDescriptor);
|
1475
|
+
}
|
1476
|
+
type ClientEvents = {
|
1477
|
+
conversationAdded: (conversation: Conversation) => void;
|
1478
|
+
conversationJoined: (conversation: Conversation) => void;
|
1479
|
+
conversationLeft: (conversation: Conversation) => void;
|
1480
|
+
conversationRemoved: (conversation: Conversation) => void;
|
1481
|
+
conversationUpdated: (data: {
|
1482
|
+
conversation: Conversation;
|
1483
|
+
updateReasons: ConversationUpdateReason[];
|
1484
|
+
}) => void;
|
1485
|
+
participantJoined: (participant: Participant) => void;
|
1486
|
+
participantLeft: (participant: Participant) => void;
|
1487
|
+
participantUpdated: (data: {
|
1488
|
+
participant: Participant;
|
1489
|
+
updateReasons: ParticipantUpdateReason[];
|
1490
|
+
}) => void;
|
1491
|
+
messageAdded: (message: Message) => void;
|
1492
|
+
messageRemoved: (message: Message) => void;
|
1493
|
+
messageUpdated: (data: {
|
1494
|
+
message: Message;
|
1495
|
+
updateReasons: MessageUpdateReason[];
|
1496
|
+
}) => void;
|
1497
|
+
tokenAboutToExpire: (ttl: number) => void;
|
1498
|
+
tokenExpired: () => void;
|
1499
|
+
typingEnded: (participant: Participant) => void;
|
1500
|
+
typingStarted: (participant: Participant) => void;
|
1501
|
+
pushNotification: (pushNotification: PushNotification) => void;
|
1502
|
+
userSubscribed: (user: User) => void;
|
1503
|
+
userUnsubscribed: (user: User) => void;
|
1504
|
+
userUpdated: (data: {
|
1505
|
+
user: User;
|
1506
|
+
updateReasons: UserUpdateReason[];
|
1507
|
+
}) => void;
|
1508
|
+
stateChanged: (state: State) => void;
|
1509
|
+
connectionStateChanged: (state: TwilsockConnectionState) => void;
|
1510
|
+
connectionError: (data: {
|
1511
|
+
terminal: boolean;
|
1512
|
+
message: string;
|
1513
|
+
httpStatusCode?: number;
|
1514
|
+
errorCode?: number;
|
1515
|
+
}) => void;
|
1516
|
+
};
|
1517
|
+
/**
|
1518
|
+
* Connection state of the client. Possible values are as follows:
|
1519
|
+
* * `'connecting'` - client is offline and connection attempt is in process
|
1520
|
+
* * `'connected'` - client is online and ready
|
1521
|
+
* * `'disconnecting'` - client is going offline as disconnection is in process
|
1522
|
+
* * `'disconnected'` - client is offline and no connection attempt is in process
|
1523
|
+
* * `'denied'` - client connection is denied because of invalid JWT access token. User must refresh token in order to proceed
|
1524
|
+
*/
|
1525
|
+
type ConnectionState = TwilsockConnectionState;
|
1526
|
+
/**
|
1527
|
+
* State of the client. Possible values are as follows:
|
1528
|
+
* * `'failed'` - the client failed to initialize
|
1529
|
+
* * `'initialized'` - the client successfully initialized
|
1530
|
+
*/
|
1531
|
+
type State = "failed" | "initialized";
|
1532
|
+
/**
|
1533
|
+
* Notifications channel type. Possible values are as follows:
|
1534
|
+
* * `'fcm'`
|
1535
|
+
* * `'apn'`
|
1536
|
+
*/
|
1537
|
+
type NotificationsChannelType = ChannelType;
|
1538
|
+
type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent" | null;
|
1539
|
+
/**
|
1540
|
+
* Conversations client options.
|
1541
|
+
*/
|
1542
|
+
interface ClientOptions {
|
1543
|
+
/**
|
1544
|
+
* The level of logging to enable.
|
1545
|
+
*/
|
1546
|
+
logLevel?: LogLevel;
|
1547
|
+
region?: string;
|
1548
|
+
productId?: string;
|
1549
|
+
twilsockClient?: TwilsockClient;
|
1550
|
+
transport?: Transport;
|
1551
|
+
notificationsClient?: NotificationClient;
|
1552
|
+
syncClient?: SyncClient;
|
1553
|
+
typingIndicatorTimeoutOverride?: number;
|
1554
|
+
consumptionReportIntervalOverride?: string;
|
1555
|
+
httpCacheIntervalOverride?: string;
|
1556
|
+
userInfosToSubscribeOverride?: number;
|
1557
|
+
retryWhenThrottledOverride?: boolean;
|
1558
|
+
backoffConfigOverride?: any;
|
1559
|
+
Chat?: any;
|
1560
|
+
IPMessaging?: any;
|
1561
|
+
Sync?: any;
|
1562
|
+
Notification?: any;
|
1563
|
+
Twilsock?: any;
|
1564
|
+
clientMetadata?: any;
|
1565
|
+
initRegistrations?: InitRegistration[];
|
1566
|
+
disableDeepClone?: boolean;
|
1567
|
+
}
|
1568
|
+
/**
|
1569
|
+
* Options for {@link Client.createConversation}.
|
1570
|
+
*/
|
1571
|
+
interface CreateConversationOptions {
|
1572
|
+
/**
|
1573
|
+
* Any custom attributes to attach to the conversation.
|
1574
|
+
*/
|
1575
|
+
attributes?: any;
|
1576
|
+
/**
|
1577
|
+
* A non-unique display name of the conversation.
|
1578
|
+
*/
|
1579
|
+
friendlyName?: string;
|
1580
|
+
/**
|
1581
|
+
* A unique identifier of the conversation.
|
1582
|
+
*/
|
1583
|
+
uniqueName?: string;
|
1584
|
+
}
|
1585
|
+
/**
|
1586
|
+
* A client is the starting point to the Twilio Conversations functionality.
|
1587
|
+
*/
|
1588
|
+
declare class Client extends ReplayEventEmitter<ClientEvents> {
|
1589
|
+
/**
|
1590
|
+
* Client connection state.
|
1591
|
+
*/
|
1592
|
+
connectionState: ConnectionState;
|
1593
|
+
private conversationsPromise;
|
1594
|
+
private _ensureReady;
|
1595
|
+
private _resolveEnsureReady;
|
1596
|
+
private _rejectEnsureReady;
|
1597
|
+
private fpaToken;
|
1598
|
+
private configuration;
|
1599
|
+
private conversations;
|
1600
|
+
private readonly options;
|
1601
|
+
private services;
|
1602
|
+
private readonly _myself;
|
1603
|
+
/**
|
1604
|
+
* Current version of the Conversations client.
|
1605
|
+
*/
|
1606
|
+
static readonly version: string;
|
1607
|
+
/**
|
1608
|
+
* Current version of the Conversations client.
|
1609
|
+
*/
|
1610
|
+
readonly version: string;
|
1611
|
+
private static readonly supportedPushChannels;
|
1612
|
+
private static readonly supportedPushDataFields;
|
1613
|
+
/**
|
1614
|
+
* Returned Conversations instance is not yet fully initialized. Calling any operations will block until it is.
|
1615
|
+
* Use connection events to monitor when client becomes fully available (connectionStateChanged with state
|
1616
|
+
* 'connected') or not available (connectionStateChange with state 'denied', event tokenExpired, event connectionError).
|
1617
|
+
*
|
1618
|
+
* @param fpaToken Access token
|
1619
|
+
* @param options Options to customize the Client
|
1620
|
+
* @returns A not yet fully-initialized client.
|
1621
|
+
*/
|
1622
|
+
constructor(fpaToken: string, options?: ClientOptions);
|
1623
|
+
static populateInitRegistrations(reg: InitRegistration): void;
|
1624
|
+
/**
|
1625
|
+
* Fired when a conversation becomes visible to the client. The event is also triggered when the client creates a new conversation.
|
1626
|
+
* Fired for all conversations client has joined.
|
1627
|
+
*
|
1628
|
+
* Parameters:
|
1629
|
+
* 1. {@link Conversation} `conversation` - the conversation in question
|
1630
|
+
* @event
|
1631
|
+
*/
|
1632
|
+
static readonly conversationAdded = "conversationAdded";
|
1633
|
+
/**
|
1634
|
+
* Fired when the client joins a conversation.
|
1635
|
+
*
|
1636
|
+
* Parameters:
|
1637
|
+
* 1. {@link Conversation} `conversation` - the conversation in question
|
1638
|
+
* @event
|
1639
|
+
*/
|
1640
|
+
static readonly conversationJoined = "conversationJoined";
|
1641
|
+
/**
|
1642
|
+
* Fired when the client leaves a conversation.
|
1643
|
+
*
|
1644
|
+
* Parameters:
|
1645
|
+
* 1. {@link Conversation} `conversation` - the conversation in question
|
1646
|
+
* @event
|
1647
|
+
*/
|
1648
|
+
static readonly conversationLeft = "conversationLeft";
|
1649
|
+
/**
|
1650
|
+
* Fired when a conversation is no longer visible to the client.
|
1651
|
+
*
|
1652
|
+
* Parameters:
|
1653
|
+
* 1. {@link Conversation} `conversation` - the conversation in question
|
1654
|
+
* @event
|
1655
|
+
*/
|
1656
|
+
static readonly conversationRemoved = "conversationRemoved";
|
1657
|
+
/**
|
1658
|
+
* Fired when the attributes or the metadata of a conversation have been updated.
|
1659
|
+
* During conversation's creation and initialization, this event might be fired multiple times
|
1660
|
+
* for same joined or created conversation as new data is arriving from different sources.
|
1661
|
+
*
|
1662
|
+
* Parameters:
|
1663
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
1664
|
+
* * {@link Conversation} `conversation` - the conversation in question
|
1665
|
+
* * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons for the update
|
1666
|
+
* @event
|
1667
|
+
*/
|
1668
|
+
static readonly conversationUpdated = "conversationUpdated";
|
1669
|
+
/**
|
1670
|
+
* Fired when a participant has joined a conversation.
|
1671
|
+
*
|
1672
|
+
* Parameters:
|
1673
|
+
* 1. {@link Participant} `participant` - the participant in question
|
1674
|
+
* @event
|
1675
|
+
*/
|
1676
|
+
static readonly participantJoined = "participantJoined";
|
1677
|
+
/**
|
1678
|
+
* Fired when a participant has left a conversation.
|
1679
|
+
*
|
1680
|
+
* Parameters:
|
1681
|
+
* 1. {@link Participant} `participant` - the participant in question
|
1682
|
+
* @event
|
1683
|
+
*/
|
1684
|
+
static readonly participantLeft = "participantLeft";
|
1685
|
+
/**
|
1686
|
+
* Fired when a participant's fields have been updated.
|
1687
|
+
*
|
1688
|
+
* Parameters:
|
1689
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
1690
|
+
* * {@link Participant} `participant` - the participant in question
|
1691
|
+
* * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons for the update
|
1692
|
+
* @event
|
1693
|
+
*/
|
1694
|
+
static readonly participantUpdated = "participantUpdated";
|
1695
|
+
/**
|
1696
|
+
* Fired when a new message has been added to the conversation on the server.
|
1697
|
+
*
|
1698
|
+
* Parameters:
|
1699
|
+
* 1. {@link Message} `message` - the message in question
|
1700
|
+
* @event
|
1701
|
+
*/
|
1702
|
+
static readonly messageAdded = "messageAdded";
|
1703
|
+
/**
|
1704
|
+
* Fired when a message is removed from the message list of a conversation.
|
1705
|
+
*
|
1706
|
+
* Parameters:
|
1707
|
+
* 1. {@link Message} `message` - the message in question
|
1708
|
+
* @event
|
1709
|
+
*/
|
1710
|
+
static readonly messageRemoved = "messageRemoved";
|
1711
|
+
/**
|
1712
|
+
* Fired when the fields of an existing message are updated with new values.
|
1713
|
+
*
|
1714
|
+
* Parameters:
|
1715
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
1716
|
+
* * {@link Message} `message` - the message in question
|
1717
|
+
* * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for the update
|
1718
|
+
* @event
|
1719
|
+
*/
|
1720
|
+
static readonly messageUpdated = "messageUpdated";
|
1721
|
+
/**
|
1722
|
+
* Fired when the token is about to expire and needs to be updated.
|
1723
|
+
* * Parameters:
|
1724
|
+
* 1. number `message` - token's time to live
|
1725
|
+
* @event
|
1726
|
+
*/
|
1727
|
+
static readonly tokenAboutToExpire = "tokenAboutToExpire";
|
1728
|
+
/**
|
1729
|
+
* Fired when the token has expired.
|
1730
|
+
* @event
|
1731
|
+
*/
|
1732
|
+
static readonly tokenExpired = "tokenExpired";
|
1733
|
+
/**
|
1734
|
+
* Fired when a participant has stopped typing.
|
1735
|
+
*
|
1736
|
+
* Parameters:
|
1737
|
+
* 1. {@link Participant} `participant` - the participant in question
|
1738
|
+
* @event
|
1739
|
+
*/
|
1740
|
+
static readonly typingEnded = "typingEnded";
|
1741
|
+
/**
|
1742
|
+
* Fired when a participant has started typing.
|
1743
|
+
*
|
1744
|
+
* Parameters:
|
1745
|
+
* 1. {@link Participant} `participant` - the participant in question
|
1746
|
+
* @event
|
1747
|
+
*/
|
1748
|
+
static readonly typingStarted = "typingStarted";
|
1749
|
+
/**
|
1750
|
+
* Fired when the client has received (and parsed) a push notification via one of the push channels (apn or fcm).
|
1751
|
+
*
|
1752
|
+
* Parameters:
|
1753
|
+
* 1. {@link PushNotification} `pushNotification` - the push notification in question
|
1754
|
+
* @event
|
1755
|
+
*/
|
1756
|
+
static readonly pushNotification = "pushNotification";
|
1757
|
+
/**
|
1758
|
+
* Fired when the client has subscribed to a user.
|
1759
|
+
*
|
1760
|
+
* Parameters:
|
1761
|
+
* 1. {@link User} `user` - the user in question
|
1762
|
+
* @event
|
1763
|
+
*/
|
1764
|
+
static readonly userSubscribed = "userSubscribed";
|
1765
|
+
/**
|
1766
|
+
* Fired when the client has unsubscribed from a user.
|
1767
|
+
*
|
1768
|
+
* Parameters:
|
1769
|
+
* 1. {@link User} `user` - the user in question
|
1770
|
+
* @event
|
1771
|
+
*/
|
1772
|
+
static readonly userUnsubscribed = "userUnsubscribed";
|
1773
|
+
/**
|
1774
|
+
* Fired when the properties or the reachability status of a user have been updated.
|
1775
|
+
*
|
1776
|
+
* Parameters:
|
1777
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
1778
|
+
* * {@link User} `user` - the user in question
|
1779
|
+
* * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update
|
1780
|
+
* @event
|
1781
|
+
*/
|
1782
|
+
static readonly userUpdated = "userUpdated";
|
1783
|
+
/**
|
1784
|
+
* Fired when the state of the client has been changed.
|
1785
|
+
*
|
1786
|
+
* Parameters:
|
1787
|
+
* 1. {@link State} `state` - the new client state
|
1788
|
+
* @event
|
1789
|
+
*/
|
1790
|
+
static readonly stateChanged = "stateChanged";
|
1791
|
+
/**
|
1792
|
+
* Fired when the connection state of the client has been changed.
|
1793
|
+
*
|
1794
|
+
* Paremeters:
|
1795
|
+
* 1. {@link ConnectionState} `state` - the new connection state
|
1796
|
+
* @event
|
1797
|
+
*/
|
1798
|
+
static readonly connectionStateChanged = "connectionStateChanged";
|
1799
|
+
/**
|
1800
|
+
* Fired when the connection is interrupted for an unexpected reason.
|
1801
|
+
*
|
1802
|
+
* Parameters:
|
1803
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
1804
|
+
* * boolean `terminal` - Twilsock will stop connection attempts if true
|
1805
|
+
* * string `message` - the error message of the root cause
|
1806
|
+
* * number? `httpStatusCode` - http status code if available
|
1807
|
+
* * number? `errorCode` - Twilio public error code if available
|
1808
|
+
* @event
|
1809
|
+
*/
|
1810
|
+
static readonly connectionError = "connectionError";
|
1811
|
+
/**
|
1812
|
+
* @deprecated Call constructor directly.
|
1813
|
+
*
|
1814
|
+
* Factory method to create a Conversations client instance.
|
1815
|
+
*
|
1816
|
+
* The factory method will automatically trigger connection.
|
1817
|
+
* Do not use it if you need finer-grained control.
|
1818
|
+
*
|
1819
|
+
* Since this method returns an already-initialized client, some of the events
|
1820
|
+
* will be lost because they happen *before* the initialization. It is
|
1821
|
+
* recommended that `client.onWithReplay` is used as opposed to `client.on`
|
1822
|
+
* for subscribing to client events. The `client.onWithReplay` will re-emit
|
1823
|
+
* the most recent value for a given event if it emitted before the
|
1824
|
+
* subscription.
|
1825
|
+
*
|
1826
|
+
* @param token Access token.
|
1827
|
+
* @param options Options to customize the client.
|
1828
|
+
* @returns Returns a fully initialized client.
|
1829
|
+
*/
|
1830
|
+
static create(token: string, options?: ClientOptions): Promise<Client>;
|
1831
|
+
/**
|
1832
|
+
* Information of the logged-in user. Before client initialization, returns an
|
1833
|
+
* uninitialized user. Will trigger a {@link Client.userUpdated} event after
|
1834
|
+
* initialization.
|
1835
|
+
*/
|
1836
|
+
get user(): User;
|
1837
|
+
/**
|
1838
|
+
* Client reachability state. Throws if accessed before the client
|
1839
|
+
* initialization was completed.
|
1840
|
+
*/
|
1841
|
+
get reachabilityEnabled(): boolean;
|
1842
|
+
get token(): string;
|
1843
|
+
private _subscribeToPushNotifications;
|
1844
|
+
private _unsubscribeFromPushNotifications;
|
1845
|
+
private _initialize;
|
1846
|
+
/**
|
1847
|
+
* Gracefully shut down the client.
|
1848
|
+
*/
|
1849
|
+
shutdown(): Promise<void>;
|
1850
|
+
/**
|
1851
|
+
* Update the token used by the client and re-register with the Conversations services.
|
1852
|
+
* @param token New access token.
|
1853
|
+
*/
|
1854
|
+
updateToken(token: string): Promise<Client>;
|
1855
|
+
/**
|
1856
|
+
* Get a known conversation by its SID.
|
1857
|
+
* @param conversationSid Conversation sid
|
1858
|
+
*/
|
1859
|
+
getConversationBySid(conversationSid: string): Promise<Conversation>;
|
1860
|
+
/**
|
1861
|
+
* Get a known conversation by its unique identifier name.
|
1862
|
+
* @param uniqueName The unique identifier name of the conversation.
|
1863
|
+
*/
|
1864
|
+
getConversationByUniqueName(uniqueName: string): Promise<Conversation>;
|
1865
|
+
/**
|
1866
|
+
* Get the current list of all the subscribed conversations.
|
1867
|
+
*/
|
1868
|
+
getSubscribedConversations(args?: any): Promise<Paginator<Conversation>>;
|
1869
|
+
/**
|
1870
|
+
* Create a conversation on the server and subscribe to its events.
|
1871
|
+
* The default is a conversation with an empty friendly name.
|
1872
|
+
* @param options Options for the conversation.
|
1873
|
+
*/
|
1874
|
+
createConversation(options?: CreateConversationOptions): Promise<Conversation>;
|
1875
|
+
/**
|
1876
|
+
* Register for push notifications.
|
1877
|
+
* @param channelType Channel type.
|
1878
|
+
* @param registrationId Push notification ID provided by the FCM/APNS service on the platform.
|
1879
|
+
*/
|
1880
|
+
setPushRegistrationId(channelType: NotificationsChannelType, registrationId: string): Promise<void>;
|
1881
|
+
/**
|
1882
|
+
* Unregister from push notifications.
|
1883
|
+
* @param channelType Channel type.
|
1884
|
+
* @deprecated Use removePushRegistrations() instead.
|
1885
|
+
*/
|
1886
|
+
unsetPushRegistrationId(channelType: NotificationsChannelType): Promise<void>;
|
1887
|
+
/**
|
1888
|
+
* Clear existing registrations directly using provided device token.
|
1889
|
+
* This is useful to ensure stopped subscriptions without resubscribing.
|
1890
|
+
*
|
1891
|
+
* This function goes completely beside the state machine and removes all registrations.
|
1892
|
+
* Use with caution: if it races with current state machine operations, madness will ensue.
|
1893
|
+
*
|
1894
|
+
* @param channelType Channel type.
|
1895
|
+
* @param registrationId Push notification ID provided by the FCM/APNS service on the platform.
|
1896
|
+
*/
|
1897
|
+
removePushRegistrations(channelType: ChannelType, registrationId: string): Promise<void>;
|
1898
|
+
private static parsePushNotificationChatData;
|
1899
|
+
/**
|
1900
|
+
* Static method for push notification payload parsing. Returns parsed push as a {@link PushNotification} object.
|
1901
|
+
* @param notificationPayload Push notification payload.
|
1902
|
+
*/
|
1903
|
+
static parsePushNotification(notificationPayload: any): PushNotification;
|
1904
|
+
parsePushNotification: typeof Client.parsePushNotification;
|
1905
|
+
/**
|
1906
|
+
* Handle push notification payload parsing and emit the {@link Client.pushNotification} event on this {@link Client} instance.
|
1907
|
+
* @param notificationPayload Push notification payload
|
1908
|
+
*/
|
1909
|
+
handlePushNotification(notificationPayload: any): Promise<void>;
|
1910
|
+
/**
|
1911
|
+
* Gets a user with the given identity. If it's in the subscribed list, then return the user object from it;
|
1912
|
+
* if not, then subscribe and add user to the subscribed list.
|
1913
|
+
* @param identity Identity of the user.
|
1914
|
+
* @returns A fully initialized user.
|
1915
|
+
*/
|
1916
|
+
getUser(identity: string): Promise<User>;
|
1917
|
+
/**
|
1918
|
+
* Get a list of subscribed user objects.
|
1919
|
+
*/
|
1920
|
+
getSubscribedUsers(): Promise<Array<User>>;
|
1921
|
+
}
|
1922
|
+
/**
|
1923
|
+
* Pagination helper class.
|
1924
|
+
*/
|
1925
|
+
declare class RestPaginator<T> implements Paginator<T> {
|
1926
|
+
private state;
|
1927
|
+
/**
|
1928
|
+
* Indicates the existence of the next page.
|
1929
|
+
*/
|
1930
|
+
get hasNextPage(): boolean;
|
1931
|
+
/**
|
1932
|
+
* Indicates the existence of the previous page
|
1933
|
+
*/
|
1934
|
+
get hasPrevPage(): boolean;
|
1935
|
+
/**
|
1936
|
+
* Array of elements on the current page.
|
1937
|
+
*/
|
1938
|
+
get items(): Array<T>;
|
1939
|
+
/**
|
1940
|
+
* @internal
|
1941
|
+
*/
|
1942
|
+
constructor(items: any, source: any, prevToken: any, nextToken: any);
|
1943
|
+
/**
|
1944
|
+
* Request the next page. Does not modify the existing object.
|
1945
|
+
*/
|
1946
|
+
nextPage(): Promise<RestPaginator<T>>;
|
1947
|
+
/**
|
1948
|
+
* Request the previous page. Does not modify the existing object.
|
1949
|
+
*/
|
1950
|
+
prevPage(): Promise<RestPaginator<T>>;
|
1951
|
+
}
|
1952
|
+
export { Conversation, ConversationUpdateReason, ConversationStatus, NotificationLevel, ConversationState, ConversationUpdatedEventArgs, SendMediaOptions, SendEmailOptions, LastMessage, Participant, ParticipantUpdateReason, ParticipantType, ParticipantUpdatedEventArgs, Message, MessageUpdateReason, MessageType, MessageUpdatedEventArgs, Media, MediaCategory$0 as MediaCategory, AggregatedDeliveryReceipt, DeliveryAmount, DetailedDeliveryReceipt, DeliveryStatus, RestPaginator, MessageBuilder, UnsentMessage, Paginator, User, UserUpdateReason, UserUpdatedEventArgs, PushNotification, PushNotificationType, PushNotificationDescriptor, PushNotificationData, Client, State, ConnectionState, NotificationsChannelType, ClientOptions, CreateConversationOptions };
|