@twilio/conversations 2.5.0 → 2.6.0-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/builds/browser.esm.js +10713 -0
- package/builds/browser.esm.js.map +1 -0
- package/builds/browser.js +158 -1
- package/builds/browser.js.map +1 -1
- package/builds/lib.esm.d.ts +3166 -0
- package/builds/lib.esm.js +10712 -0
- package/builds/lib.js +167 -1
- package/builds/lib.js.map +1 -1
- package/builds/twilio-conversations.js +309 -322
- package/builds/twilio-conversations.min.js +1 -1
- package/dist/aggregated-delivery-receipt.js +3 -5
- package/dist/aggregated-delivery-receipt.js.map +1 -1
- package/dist/channel-metadata-client.js +7 -9
- package/dist/channel-metadata-client.js.map +1 -1
- package/dist/client.js +189 -154
- package/dist/client.js.map +1 -1
- package/dist/command-executor.js +8 -8
- package/dist/command-executor.js.map +1 -1
- package/dist/configuration.js +12 -9
- package/dist/configuration.js.map +1 -1
- package/dist/content-client.js +11 -8
- package/dist/content-client.js.map +1 -1
- package/dist/content-template.js +3 -5
- package/dist/content-template.js.map +1 -1
- package/dist/conversation.js +113 -87
- package/dist/conversation.js.map +1 -1
- package/dist/data/conversations.js +34 -42
- package/dist/data/conversations.js.map +1 -1
- package/dist/data/messages.js +23 -21
- package/dist/data/messages.js.map +1 -1
- package/dist/data/participants.js +25 -23
- package/dist/data/participants.js.map +1 -1
- package/dist/data/users.js +15 -13
- package/dist/data/users.js.map +1 -1
- package/dist/detailed-delivery-receipt.js +3 -5
- package/dist/detailed-delivery-receipt.js.map +1 -1
- package/dist/index.js +17 -49
- package/dist/index.js.map +1 -1
- package/dist/interfaces/notification-types.js +1 -5
- package/dist/interfaces/notification-types.js.map +1 -1
- package/dist/interfaces/rules.js +13 -10
- package/dist/interfaces/rules.js.map +1 -1
- package/dist/logger.js +25 -26
- package/dist/logger.js.map +1 -1
- package/dist/media.js +11 -8
- package/dist/media.js.map +1 -1
- package/dist/message-builder.js +48 -40
- package/dist/message-builder.js.map +1 -1
- package/dist/message-recipients-client.js +10 -12
- package/dist/message-recipients-client.js.map +1 -1
- package/dist/message.js +88 -75
- package/dist/message.js.map +1 -1
- package/dist/node_modules/quick-lru/index.js +1 -5
- package/dist/node_modules/quick-lru/index.js.map +1 -1
- package/dist/node_modules/tslib/tslib.es6.js +1 -7
- package/dist/node_modules/tslib/tslib.es6.js.map +1 -1
- package/dist/packages/conversations/package.json.js +2 -6
- package/dist/packages/conversations/package.json.js.map +1 -1
- package/dist/participant.js +34 -29
- package/dist/participant.js.map +1 -1
- package/dist/push-notification.js +5 -4
- package/dist/push-notification.js.map +1 -1
- package/dist/rest-paginator.js +6 -4
- package/dist/rest-paginator.js.map +1 -1
- package/dist/services/network.js +3 -7
- package/dist/services/network.js.map +1 -1
- package/dist/services/typing-indicator.js +11 -8
- package/dist/services/typing-indicator.js.map +1 -1
- package/dist/unsent-message.js +9 -8
- package/dist/unsent-message.js.map +1 -1
- package/dist/user.js +27 -24
- package/dist/user.js.map +1 -1
- package/dist/util/deferred.js +6 -4
- package/dist/util/deferred.js.map +1 -1
- package/dist/util/index.js +1 -9
- package/dist/util/index.js.map +1 -1
- package/docs/index.html +3 -3
- package/docs/modules.html +2 -2
- package/package.json +7 -7
@@ -0,0 +1,3166 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { SyncClient, SyncDocument, SyncList } from "twilio-sync";
|
3
|
+
import { LogLevelDesc } from "loglevel";
|
4
|
+
import { Transport, TwilsockClient, InitRegistration, TransportResult } from "twilsock";
|
5
|
+
import { ConnectionState as TwilsockConnectionState } from "twilsock";
|
6
|
+
import { ReplayEventEmitter } from "@twilio/replay-event-emitter";
|
7
|
+
import { ChannelType, Notifications } from "@twilio/notifications";
|
8
|
+
import { Notifications as NotificationClient } from "@twilio/notifications";
|
9
|
+
import { CancellablePromise, McsClient, MediaCategory, McsMedia, McsMediaCategory, McsMediaState } from "@twilio/mcs-client";
|
10
|
+
interface ConfigurationResponse {
|
11
|
+
options: {
|
12
|
+
consumption_report_interval: string;
|
13
|
+
user_infos_to_subscribe: number;
|
14
|
+
reachability_enabled: boolean;
|
15
|
+
http_cache_interval: string;
|
16
|
+
my_conversations_page_size: number;
|
17
|
+
media_attachments_count_limit: number;
|
18
|
+
media_attachment_size_limit_in_mb: number;
|
19
|
+
media_attachments_total_size_limit_in_mb: number;
|
20
|
+
email_histories_allowed_mime_types: string[];
|
21
|
+
email_bodies_allowed_mime_types: string[];
|
22
|
+
};
|
23
|
+
sync_objects: {
|
24
|
+
my_conversations: string;
|
25
|
+
my_user_info: string;
|
26
|
+
};
|
27
|
+
links: {
|
28
|
+
my_conversations: string;
|
29
|
+
conversations: string;
|
30
|
+
users: string;
|
31
|
+
current_user: string;
|
32
|
+
typing: string;
|
33
|
+
media_service: string;
|
34
|
+
media_set_service: string;
|
35
|
+
messages_receipts: string;
|
36
|
+
};
|
37
|
+
identity: string;
|
38
|
+
url: string;
|
39
|
+
}
|
40
|
+
// twilio-conversations is used by Flex SDK. Please DO NOT change
|
41
|
+
declare class Logger {
|
42
|
+
private prefix;
|
43
|
+
private constructor();
|
44
|
+
static scope(prefix: string): Logger;
|
45
|
+
setLevel(level: LogLevelDesc): void;
|
46
|
+
static setLevel(level: LogLevelDesc): void;
|
47
|
+
trace(...args: any[]): void;
|
48
|
+
debug(...args: any[]): void;
|
49
|
+
info(...args: any[]): void;
|
50
|
+
warn(...args: any[]): void;
|
51
|
+
error(...args: any[]): void;
|
52
|
+
static trace(...args: any[]): void;
|
53
|
+
static debug(...args: any[]): void;
|
54
|
+
static info(...args: any[]): void;
|
55
|
+
static warn(...args: any[]): void;
|
56
|
+
static error(...args: any[]): void;
|
57
|
+
}
|
58
|
+
/**
|
59
|
+
* Represents conversation limits.
|
60
|
+
*/
|
61
|
+
interface ConversationLimits {
|
62
|
+
/**
|
63
|
+
* Maximum amount of attachments.
|
64
|
+
*/
|
65
|
+
mediaAttachmentsCountLimit: number;
|
66
|
+
/**
|
67
|
+
* Maximum attachment size in MB.
|
68
|
+
*/
|
69
|
+
mediaAttachmentSizeLimitInMb: number;
|
70
|
+
/**
|
71
|
+
* Maximum total attachment size in MB.
|
72
|
+
*/
|
73
|
+
mediaAttachmentsTotalSizeLimitInMb: number;
|
74
|
+
/**
|
75
|
+
* Allowed content types for E-Mail histories.
|
76
|
+
*/
|
77
|
+
emailHistoriesAllowedContentTypes: string[];
|
78
|
+
/**
|
79
|
+
* Allowed content types for E-Mail bodies.
|
80
|
+
*/
|
81
|
+
emailBodiesAllowedContentTypes: string[];
|
82
|
+
}
|
83
|
+
interface BackoffConfiguration {
|
84
|
+
min: number;
|
85
|
+
max: number;
|
86
|
+
maxAttemptsCount: number;
|
87
|
+
}
|
88
|
+
declare class Configuration {
|
89
|
+
readonly links: {
|
90
|
+
myConversations: string;
|
91
|
+
conversations: string;
|
92
|
+
users: string;
|
93
|
+
currentUser: string;
|
94
|
+
typing: string;
|
95
|
+
mediaService: string;
|
96
|
+
mediaSetService: string;
|
97
|
+
messagesReceipts: string;
|
98
|
+
};
|
99
|
+
readonly limits: ConversationLimits;
|
100
|
+
readonly productId?: string;
|
101
|
+
readonly typingIndicatorTimeoutOverride?: number;
|
102
|
+
readonly typingIndicatorTimeoutDefault: number;
|
103
|
+
readonly backoffConfiguration: BackoffConfiguration;
|
104
|
+
readonly retryWhenThrottled: boolean;
|
105
|
+
readonly consumptionReportInterval: number;
|
106
|
+
readonly userInfosToSubscribe: number;
|
107
|
+
readonly httpCacheInterval: number;
|
108
|
+
readonly reachabilityEnabled: boolean;
|
109
|
+
readonly userIdentity: string;
|
110
|
+
readonly userInfo: string;
|
111
|
+
readonly myConversations: string;
|
112
|
+
readonly channelMetadataCacheCapacity: number;
|
113
|
+
readonly messageRecipientsCacheCapacity: number;
|
114
|
+
constructor(options: ClientOptions, configurationResponse: ConfigurationResponse, logger: Logger);
|
115
|
+
}
|
116
|
+
interface CommandExecutorServices {
|
117
|
+
transport: Transport;
|
118
|
+
}
|
119
|
+
declare class CommandExecutor {
|
120
|
+
private _serviceUrl;
|
121
|
+
private _services;
|
122
|
+
private _productId?;
|
123
|
+
constructor(_serviceUrl: string, _services: CommandExecutorServices, _productId?: string);
|
124
|
+
private _preProcessUrl;
|
125
|
+
private _makeRequest;
|
126
|
+
fetchResource<Request = void, Response = void>(url: string, requestBody?: Request): Promise<Response>;
|
127
|
+
mutateResource<Request = void, Response = void>(method: "post" | "delete", url: string, requestBody?: Request): Promise<Response>;
|
128
|
+
}
|
129
|
+
/**
|
130
|
+
* Represents a JSON value.
|
131
|
+
*/
|
132
|
+
type JSONValue = null | string | number | boolean | JSONObject | JSONArray;
|
133
|
+
/**
|
134
|
+
* Represents a JSON object.
|
135
|
+
*/
|
136
|
+
type JSONObject = {
|
137
|
+
[x: string]: JSONValue;
|
138
|
+
};
|
139
|
+
/**
|
140
|
+
* Represents a JSON array.
|
141
|
+
*/
|
142
|
+
type JSONArray = JSONValue[];
|
143
|
+
type UserEvents = {
|
144
|
+
updated: (data: {
|
145
|
+
user: User;
|
146
|
+
updateReasons: UserUpdateReason[];
|
147
|
+
}) => void;
|
148
|
+
userSubscribed: (user: User) => void;
|
149
|
+
userUnsubscribed: (user: User) => void;
|
150
|
+
};
|
151
|
+
interface UserServices {
|
152
|
+
syncClient: SyncClient;
|
153
|
+
commandExecutor: CommandExecutor;
|
154
|
+
}
|
155
|
+
/**
|
156
|
+
* The reason for the `updated` event being emitted by a user.
|
157
|
+
*/
|
158
|
+
type UserUpdateReason = "friendlyName" | "attributes" | "reachabilityOnline" | "reachabilityNotifiable";
|
159
|
+
interface UserUpdatedEventArgs {
|
160
|
+
user: User;
|
161
|
+
updateReasons: UserUpdateReason[];
|
162
|
+
}
|
163
|
+
/**
|
164
|
+
* Extended user information.
|
165
|
+
* Note that `isOnline` and `isNotifiable` properties are eligible
|
166
|
+
* for use only if the reachability function is enabled.
|
167
|
+
* You may check if it is enabled by reading the value of {@link Client.reachabilityEnabled}.
|
168
|
+
*/
|
169
|
+
declare class User extends ReplayEventEmitter<UserEvents> {
|
170
|
+
private links;
|
171
|
+
private configuration;
|
172
|
+
private readonly services;
|
173
|
+
private entity;
|
174
|
+
private state;
|
175
|
+
private promiseToFetch;
|
176
|
+
private subscribed;
|
177
|
+
private _initializationPromise;
|
178
|
+
private _resolveInitializationPromise;
|
179
|
+
/**
|
180
|
+
* @internal
|
181
|
+
*/
|
182
|
+
constructor(identity: string, entityName: string, configuration: Configuration | null, services: UserServices);
|
183
|
+
/**
|
184
|
+
* Fired when the properties or the reachability status of the message has been updated.
|
185
|
+
*
|
186
|
+
* Parameters:
|
187
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
188
|
+
* * {@link User} `user` - the user in question
|
189
|
+
* * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the update
|
190
|
+
* @event
|
191
|
+
*/
|
192
|
+
readonly updated = "updated";
|
193
|
+
/**
|
194
|
+
* Fired when the client has subscribed to the user.
|
195
|
+
*
|
196
|
+
* Parameters:
|
197
|
+
* 1. {@link User} `user` - the user in question
|
198
|
+
* @event
|
199
|
+
*/
|
200
|
+
readonly userSubscribed = "userSubscribed";
|
201
|
+
/**
|
202
|
+
* Fired when the client has unsubscribed from the user.
|
203
|
+
*
|
204
|
+
* Parameters:
|
205
|
+
* 1. {@link User} `user` - the user in question
|
206
|
+
* @event
|
207
|
+
*/
|
208
|
+
readonly userUnsubscribed = "userUnsubscribed";
|
209
|
+
/**
|
210
|
+
* User identity.
|
211
|
+
*/
|
212
|
+
get identity(): string;
|
213
|
+
set identity(identity: string);
|
214
|
+
set entityName(name: string);
|
215
|
+
/**
|
216
|
+
* Custom attributes of the user.
|
217
|
+
*/
|
218
|
+
get attributes(): JSONValue;
|
219
|
+
/**
|
220
|
+
* Friendly name of the user, null if not set.
|
221
|
+
*/
|
222
|
+
get friendlyName(): string | null;
|
223
|
+
/**
|
224
|
+
* Status of the real-time conversation connection of the user.
|
225
|
+
*/
|
226
|
+
get isOnline(): boolean | null;
|
227
|
+
/**
|
228
|
+
* User push notification registration status.
|
229
|
+
*/
|
230
|
+
get isNotifiable(): boolean | null;
|
231
|
+
/**
|
232
|
+
* True if this user is receiving real-time status updates.
|
233
|
+
*/
|
234
|
+
get isSubscribed(): boolean;
|
235
|
+
// Handles service updates
|
236
|
+
_update(key: string, value: {
|
237
|
+
value: string;
|
238
|
+
notifiable: boolean | null;
|
239
|
+
online: boolean | null;
|
240
|
+
}): Promise<void>;
|
241
|
+
// Fetch reachability info
|
242
|
+
private _updateReachabilityInfo;
|
243
|
+
// Fetch user
|
244
|
+
_fetch(): Promise<User>;
|
245
|
+
_ensureFetched(): Promise<User>;
|
246
|
+
/**
|
247
|
+
* Edit user attributes.
|
248
|
+
* @param attributes New attributes.
|
249
|
+
*/
|
250
|
+
updateAttributes(attributes: JSONValue): Promise<User>;
|
251
|
+
/**
|
252
|
+
* Update the friendly name of the user.
|
253
|
+
* @param friendlyName New friendly name.
|
254
|
+
*/
|
255
|
+
updateFriendlyName(friendlyName: string): Promise<User>;
|
256
|
+
/**
|
257
|
+
* Remove the user from the subscription list.
|
258
|
+
* @return A promise of completion.
|
259
|
+
*/
|
260
|
+
unsubscribe(): Promise<void>;
|
261
|
+
_resolveInitialization(configuration: Configuration, identity: string, entityName: string, emitUpdated: boolean): void;
|
262
|
+
}
|
263
|
+
declare class Network {
|
264
|
+
private readonly configuration;
|
265
|
+
private readonly services;
|
266
|
+
private cacheLifetime;
|
267
|
+
private readonly cache;
|
268
|
+
private timer;
|
269
|
+
constructor(configuration: any, services: any);
|
270
|
+
private isExpired;
|
271
|
+
private cleanupCache;
|
272
|
+
pokeTimer(): void;
|
273
|
+
private executeWithRetry;
|
274
|
+
get<T>(url: string): Promise<TransportResult<T>>;
|
275
|
+
}
|
276
|
+
type UsersEvents = {
|
277
|
+
userUpdated: (data: {
|
278
|
+
user: User;
|
279
|
+
updateReasons: UserUpdateReason[];
|
280
|
+
}) => void;
|
281
|
+
userSubscribed: (user: User) => void;
|
282
|
+
userUnsubscribed: (user: User) => void;
|
283
|
+
};
|
284
|
+
interface UsersServices {
|
285
|
+
network: Network;
|
286
|
+
syncClient: SyncClient;
|
287
|
+
commandExecutor: CommandExecutor;
|
288
|
+
}
|
289
|
+
/**
|
290
|
+
* Container for known users
|
291
|
+
*/
|
292
|
+
declare class Users extends ReplayEventEmitter<UsersEvents> {
|
293
|
+
private readonly configuration;
|
294
|
+
private readonly services;
|
295
|
+
private subscribedUsers;
|
296
|
+
private fifoStack;
|
297
|
+
readonly myself: User;
|
298
|
+
constructor(myself: User, configuration: Configuration, services: UsersServices);
|
299
|
+
private handleUnsubscribeUser;
|
300
|
+
private handleSubscribeUser;
|
301
|
+
/**
|
302
|
+
* Gets user, if it's in subscribed list - then return the user object from it,
|
303
|
+
* if not - then subscribes and adds user to the FIFO stack
|
304
|
+
* @returns {Promise<User>} Fully initialized user
|
305
|
+
*/
|
306
|
+
getUser(identity: string, entityName?: string): Promise<User>;
|
307
|
+
/**
|
308
|
+
* @returns {Promise<Array<User>>} returns list of subscribed User objects {@see User}
|
309
|
+
*/
|
310
|
+
getSubscribedUsers(): Promise<Array<User>>;
|
311
|
+
/**
|
312
|
+
* @returns {Promise<string>} User's sync unique name
|
313
|
+
*/
|
314
|
+
private getSyncUniqueName;
|
315
|
+
}
|
316
|
+
type ParticipantEvents = {
|
317
|
+
typingEnded: (participant: Participant) => void;
|
318
|
+
typingStarted: (participant: Participant) => void;
|
319
|
+
updated: (data: {
|
320
|
+
participant: Participant;
|
321
|
+
updateReasons: ParticipantUpdateReason[];
|
322
|
+
}) => void;
|
323
|
+
};
|
324
|
+
interface ParticipantDescriptor {
|
325
|
+
attributes?: JSONValue;
|
326
|
+
dateCreated: Date | null;
|
327
|
+
dateUpdated: Date | null;
|
328
|
+
identity: string;
|
329
|
+
roleSid?: string;
|
330
|
+
lastConsumedMessageIndex: number | null;
|
331
|
+
lastConsumptionTimestamp: number | null;
|
332
|
+
type: ParticipantType;
|
333
|
+
userInfo?: string;
|
334
|
+
bindings?: ParticipantBindings;
|
335
|
+
}
|
336
|
+
interface ParticipantServices {
|
337
|
+
users: Users;
|
338
|
+
commandExecutor: CommandExecutor;
|
339
|
+
}
|
340
|
+
interface ParticipantLinks {
|
341
|
+
self: string;
|
342
|
+
}
|
343
|
+
/**
|
344
|
+
* The reason for the `updated` event being emitted by a participant.
|
345
|
+
*/
|
346
|
+
type ParticipantUpdateReason = "attributes" | "dateCreated" | "dateUpdated" | "roleSid" | "lastReadMessageIndex" | "lastReadTimestamp" | "bindings";
|
347
|
+
/**
|
348
|
+
* Participant type. The string variant can be used to denote new types of
|
349
|
+
* participant that aren't supported by this version of the SDK.
|
350
|
+
*/
|
351
|
+
type ParticipantType = "chat" | "sms" | "whatsapp" | "email" | string;
|
352
|
+
interface ParticipantUpdatedEventArgs {
|
353
|
+
participant: Participant;
|
354
|
+
updateReasons: ParticipantUpdateReason[];
|
355
|
+
}
|
356
|
+
/**
|
357
|
+
* Bindings for conversation participant.
|
358
|
+
*/
|
359
|
+
interface ParticipantBindings {
|
360
|
+
email?: ParticipantEmailBinding;
|
361
|
+
}
|
362
|
+
/**
|
363
|
+
* Email participation level.
|
364
|
+
* to = to/from
|
365
|
+
* cc = cc
|
366
|
+
*/
|
367
|
+
type ParticipantEmailLevel = "to" | "cc";
|
368
|
+
/**
|
369
|
+
* Bindings for email participant.
|
370
|
+
*/
|
371
|
+
interface ParticipantEmailBinding {
|
372
|
+
name: string;
|
373
|
+
address: string;
|
374
|
+
level: ParticipantEmailLevel;
|
375
|
+
}
|
376
|
+
/**
|
377
|
+
* A participant represents a remote client in a conversation.
|
378
|
+
*/
|
379
|
+
declare class Participant extends ReplayEventEmitter<ParticipantEvents> {
|
380
|
+
private state;
|
381
|
+
private readonly links;
|
382
|
+
private readonly services;
|
383
|
+
/**
|
384
|
+
* Conversation that the remote client is a participant of.
|
385
|
+
*/
|
386
|
+
readonly conversation: Conversation;
|
387
|
+
/**
|
388
|
+
* The server-assigned unique identifier for the participant.
|
389
|
+
*/
|
390
|
+
get sid(): string;
|
391
|
+
/**
|
392
|
+
* Custom attributes of the participant.
|
393
|
+
*/
|
394
|
+
get attributes(): JSONValue;
|
395
|
+
/**
|
396
|
+
* Date this participant was created on.
|
397
|
+
*/
|
398
|
+
get dateCreated(): Date | null;
|
399
|
+
/**
|
400
|
+
* Date this participant was last updated on.
|
401
|
+
*/
|
402
|
+
get dateUpdated(): Date | null;
|
403
|
+
/**
|
404
|
+
* Identity of the participant.
|
405
|
+
*/
|
406
|
+
get identity(): string | null;
|
407
|
+
/**
|
408
|
+
* Indicates whether the participant is currently typing.
|
409
|
+
*/
|
410
|
+
get isTyping(): boolean;
|
411
|
+
/**
|
412
|
+
* The index of the last read message by the participant.
|
413
|
+
* Note that retrieving messages on a client endpoint does not mean that messages are read,
|
414
|
+
* please consider reading about the [Read Horizon feature](https://www.twilio.com/docs/api/chat/guides/consumption-horizon)
|
415
|
+
* to find out about the proper way to mark messages as read.
|
416
|
+
*/
|
417
|
+
get lastReadMessageIndex(): number | null;
|
418
|
+
/**
|
419
|
+
* Date of the most recent read horizon update.
|
420
|
+
*/
|
421
|
+
get lastReadTimestamp(): Date | null;
|
422
|
+
get roleSid(): string;
|
423
|
+
/**
|
424
|
+
* Type of the participant.
|
425
|
+
*/
|
426
|
+
get type(): ParticipantType;
|
427
|
+
/**
|
428
|
+
* Get the bindings mapping for the current participant.
|
429
|
+
* Available binding depends on the participant type.
|
430
|
+
* You could access it as `participant.bindings.sms?.address` or
|
431
|
+
* using the type dynamically `participant.bindings[participant.type]`
|
432
|
+
* just be aware that the binding information has different structure for
|
433
|
+
* each participant type.
|
434
|
+
* See also {ParticipantEmailBinding}, the only available currently binding descriptor.
|
435
|
+
*/
|
436
|
+
get bindings(): ParticipantBindings;
|
437
|
+
/**
|
438
|
+
* @internal
|
439
|
+
*/
|
440
|
+
constructor(data: ParticipantDescriptor, sid: string, conversation: Conversation, links: ParticipantLinks, services: ParticipantServices);
|
441
|
+
/**
|
442
|
+
* Fired when the participant has started typing.
|
443
|
+
*
|
444
|
+
* Parameters:
|
445
|
+
* 1. {@link Participant} `participant` - the participant in question
|
446
|
+
* @event
|
447
|
+
*/
|
448
|
+
static readonly typingStarted = "typingStarted";
|
449
|
+
/**
|
450
|
+
* Fired when the participant has stopped typing.
|
451
|
+
*
|
452
|
+
* Parameters:
|
453
|
+
* 1. {@link Participant} `participant` - the participant in question
|
454
|
+
* @event
|
455
|
+
*/
|
456
|
+
static readonly typingEnded = "typingEnded";
|
457
|
+
/**
|
458
|
+
* Fired when the fields of the participant have been updated.
|
459
|
+
*
|
460
|
+
* Parameters:
|
461
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
462
|
+
* * {@link Participant} participant - the participant in question
|
463
|
+
* * {@link ParticipantUpdateReason}[] updateReasons - array of reasons for the update
|
464
|
+
* @event
|
465
|
+
*/
|
466
|
+
static readonly updated = "updated";
|
467
|
+
/**
|
468
|
+
* Internal method used to start or reset the typing indicator timeout (with event emitting).
|
469
|
+
* @internal
|
470
|
+
*/
|
471
|
+
_startTyping(timeout: any): this;
|
472
|
+
/**
|
473
|
+
* Internal method function used to stop the typing indicator timeout (with event emitting).
|
474
|
+
* @internal
|
475
|
+
*/
|
476
|
+
_endTyping(): void;
|
477
|
+
/**
|
478
|
+
* Internal method function used update local object's property roleSid with a new value.
|
479
|
+
* @internal
|
480
|
+
*/
|
481
|
+
_update(data: any): this;
|
482
|
+
/**
|
483
|
+
* Get the user for this participant and subscribes to it. Supported only for participants of type `chat`.
|
484
|
+
*/
|
485
|
+
getUser(): Promise<User>;
|
486
|
+
/**
|
487
|
+
* Remove the participant from the conversation.
|
488
|
+
*/
|
489
|
+
remove(): Promise<void>;
|
490
|
+
/**
|
491
|
+
* Update the attributes of the participant.
|
492
|
+
* @param attributes New attributes.
|
493
|
+
*/
|
494
|
+
updateAttributes(attributes: JSONValue): Promise<Participant>;
|
495
|
+
}
|
496
|
+
interface ParticipantResponse {
|
497
|
+
account_sid: string;
|
498
|
+
chat_service_sid: string;
|
499
|
+
conversation_sid: string;
|
500
|
+
role_sid: string;
|
501
|
+
sid: string;
|
502
|
+
attributes: string;
|
503
|
+
date_created: string;
|
504
|
+
date_updated: string;
|
505
|
+
identity: string;
|
506
|
+
messaging_binding: {
|
507
|
+
type: "chat" | "sms" | "whatsapp" | "email";
|
508
|
+
address: string;
|
509
|
+
proxy_address: string;
|
510
|
+
} | null;
|
511
|
+
url: string;
|
512
|
+
links: {
|
513
|
+
conversation: string;
|
514
|
+
};
|
515
|
+
}
|
516
|
+
interface ParticipantBindingOptions {
|
517
|
+
email?: ParticipantEmailBinding;
|
518
|
+
}
|
519
|
+
/**
|
520
|
+
* Category of media. Possible values are as follows:
|
521
|
+
* * `'media'`
|
522
|
+
* * `'body'`
|
523
|
+
* * `'history'`
|
524
|
+
*/
|
525
|
+
type MediaCategory$0 = McsMediaCategory;
|
526
|
+
interface MediaServices {
|
527
|
+
mcsClient: McsClient;
|
528
|
+
}
|
529
|
+
/**
|
530
|
+
* Represents a media information for a message in a conversation.
|
531
|
+
*/
|
532
|
+
declare class Media {
|
533
|
+
private state;
|
534
|
+
private services;
|
535
|
+
private mcsMedia;
|
536
|
+
/**
|
537
|
+
* @internal
|
538
|
+
*/
|
539
|
+
constructor(data: McsMediaState | McsMedia, services: MediaServices);
|
540
|
+
/**
|
541
|
+
* Server-assigned unique identifier for the media.
|
542
|
+
*/
|
543
|
+
get sid(): string;
|
544
|
+
/**
|
545
|
+
* File name. Null if absent.
|
546
|
+
*/
|
547
|
+
get filename(): string | null;
|
548
|
+
/**
|
549
|
+
* Content type of the media.
|
550
|
+
*/
|
551
|
+
get contentType(): string;
|
552
|
+
/**
|
553
|
+
* Size of the media in bytes.
|
554
|
+
*/
|
555
|
+
get size(): number;
|
556
|
+
/**
|
557
|
+
* Media category, can be one of the {@link MediaCategory} values.
|
558
|
+
*/
|
559
|
+
get category(): MediaCategory$0;
|
560
|
+
/**
|
561
|
+
* Returns the direct content URL for the media.
|
562
|
+
*
|
563
|
+
* This URL is impermanent, it will expire in several minutes and cannot be cached.
|
564
|
+
* If the URL becomes expired, you need to request a new one.
|
565
|
+
* Each call to this function produces a new temporary URL.
|
566
|
+
*/
|
567
|
+
getContentTemporaryUrl(): CancellablePromise<string | null>;
|
568
|
+
private _fetchMcsMedia;
|
569
|
+
/**
|
570
|
+
* @internal
|
571
|
+
*/
|
572
|
+
_state(): McsMediaState;
|
573
|
+
}
|
574
|
+
/**
|
575
|
+
* Signifies the amount of participants which have the status for the message.
|
576
|
+
*/
|
577
|
+
type DeliveryAmount = "none" | "some" | "all";
|
578
|
+
interface AggregatedDeliveryDescriptor {
|
579
|
+
total: number;
|
580
|
+
delivered: DeliveryAmount;
|
581
|
+
failed: DeliveryAmount;
|
582
|
+
read: DeliveryAmount;
|
583
|
+
sent: DeliveryAmount;
|
584
|
+
undelivered: DeliveryAmount;
|
585
|
+
}
|
586
|
+
/**
|
587
|
+
* Contains aggregated information about delivery statuses of a message across all participants
|
588
|
+
* of a conversation.
|
589
|
+
*
|
590
|
+
* At any moment during the message delivery to a participant, the message can have zero or more of the following
|
591
|
+
* delivery statuses:
|
592
|
+
* * Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
|
593
|
+
* * Message is considered as **delivered** to a participant if Twilio has received confirmation of message
|
594
|
+
* delivery from the upstream carrier, and, where available, the destination handset.
|
595
|
+
* * Message considered as **undelivered** to a participant if Twilio has received a delivery receipt
|
596
|
+
* indicating that the message was not delivered. This can happen for many reasons including carrier content
|
597
|
+
* filtering and the availability of the destination handset.
|
598
|
+
* * Message considered as **read** by a participant if the message has been delivered and opened by the
|
599
|
+
* recipient in a conversation. The recipient must have enabled the read receipts.
|
600
|
+
* * Message considered as **failed** to be delivered to a participant if the message could not be sent.
|
601
|
+
* This can happen for various reasons including queue overflows, account suspensions and media
|
602
|
+
* errors (in the case of MMS for instance).
|
603
|
+
*
|
604
|
+
* {@link AggregatedDeliveryReceipt} class contains an aggregated value {@link DeliveryAmount} for each delivery status.
|
605
|
+
*/
|
606
|
+
declare class AggregatedDeliveryReceipt {
|
607
|
+
private state;
|
608
|
+
/**
|
609
|
+
* @internal
|
610
|
+
*/
|
611
|
+
constructor(data: AggregatedDeliveryDescriptor);
|
612
|
+
/**
|
613
|
+
* Maximum number of delivery events expected for the message.
|
614
|
+
*/
|
615
|
+
get total(): number;
|
616
|
+
/**
|
617
|
+
* Message is considered as **sent** to a participant if the nearest upstream carrier accepted the message.
|
618
|
+
*
|
619
|
+
* @return Amount of participants that have the **sent** delivery status for the message.
|
620
|
+
*/
|
621
|
+
get sent(): DeliveryAmount;
|
622
|
+
/**
|
623
|
+
* Message is considered as **delivered** to a participant if Twilio has received confirmation of message
|
624
|
+
* delivery from the upstream carrier, and, where available, the destination handset.
|
625
|
+
*
|
626
|
+
* @return Amount of participants that have the **delivered** delivery status for the message.
|
627
|
+
*/
|
628
|
+
get delivered(): DeliveryAmount;
|
629
|
+
/**
|
630
|
+
* Message is considered as **read** by a participant, if the message has been delivered and opened by the
|
631
|
+
* recipient in a conversation. The recipient must have enabled the read receipts.
|
632
|
+
*
|
633
|
+
* @return Amount of participants that have the **read** delivery status for the message.
|
634
|
+
*/
|
635
|
+
get read(): DeliveryAmount;
|
636
|
+
/**
|
637
|
+
* Message is considered as **undelivered** to a participant if Twilio has received a delivery receipt
|
638
|
+
* indicating that the message was not delivered. This can happen for many reasons including carrier content
|
639
|
+
* filtering and the availability of the destination handset.
|
640
|
+
*
|
641
|
+
* @return Ammount of participants that have the **undelivered** delivery status for the message.
|
642
|
+
*/
|
643
|
+
get undelivered(): DeliveryAmount;
|
644
|
+
/**
|
645
|
+
* Message is considered as **failed** to be delivered to a participant if the message could not be sent.
|
646
|
+
* This can happen for various reasons including queue overflows, account suspensions and media
|
647
|
+
* errors (in the case of MMS for instance). Twilio does not charge you for failed messages.
|
648
|
+
*
|
649
|
+
* @return Amount of participants that have the **failed** delivery status for the message.
|
650
|
+
*/
|
651
|
+
get failed(): DeliveryAmount;
|
652
|
+
_update(data: AggregatedDeliveryDescriptor): void;
|
653
|
+
_isEquals(data: AggregatedDeliveryDescriptor): boolean;
|
654
|
+
}
|
655
|
+
/**
|
656
|
+
* Message delivery status.
|
657
|
+
*/
|
658
|
+
type DeliveryStatus = "sent" | "delivered" | "failed" | "read" | "undelivered" | "queued";
|
659
|
+
interface DetailedDeliveryReceiptDescriptor {
|
660
|
+
sid: string;
|
661
|
+
message_sid: string;
|
662
|
+
conversation_sid: string;
|
663
|
+
channel_message_sid: string;
|
664
|
+
participant_sid: string;
|
665
|
+
status: DeliveryStatus;
|
666
|
+
error_code: string | null;
|
667
|
+
date_created: string;
|
668
|
+
date_updated: string;
|
669
|
+
}
|
670
|
+
/**
|
671
|
+
* Represents a delivery receipt of a message.
|
672
|
+
*/
|
673
|
+
declare class DetailedDeliveryReceipt {
|
674
|
+
/**
|
675
|
+
* Unique identifier for the delivery receipt.
|
676
|
+
*/
|
677
|
+
sid: string;
|
678
|
+
/**
|
679
|
+
* Unique identifier for the message in the conversation.
|
680
|
+
*/
|
681
|
+
messageSid: string;
|
682
|
+
/**
|
683
|
+
* Unique identifier for the conversation.
|
684
|
+
*/
|
685
|
+
conversationSid: string;
|
686
|
+
/**
|
687
|
+
* Unique identifier for the `‘channel’` message (e.g., `WAxx` for WhatsApp, `SMxx` for SMS).
|
688
|
+
*/
|
689
|
+
channelMessageSid: string;
|
690
|
+
/**
|
691
|
+
* Unique identifier for the participant.
|
692
|
+
*/
|
693
|
+
participantSid: string;
|
694
|
+
/**
|
695
|
+
* Status of the message delivery.
|
696
|
+
*/
|
697
|
+
status: DeliveryStatus;
|
698
|
+
/**
|
699
|
+
* Numeric error code mapped from Status callback code. Information about the error codes can be found
|
700
|
+
* [here](https://www.twilio.com/docs/sms/api/message-resource#delivery-related-errors).
|
701
|
+
*/
|
702
|
+
errorCode: string | 0;
|
703
|
+
/**
|
704
|
+
* Date this delivery receipt was created on.
|
705
|
+
*/
|
706
|
+
dateCreated: string;
|
707
|
+
/**
|
708
|
+
* Date this delivery receipt was last updated on.
|
709
|
+
*/
|
710
|
+
dateUpdated: string;
|
711
|
+
/**
|
712
|
+
* @internal
|
713
|
+
*/
|
714
|
+
constructor(descriptor: DetailedDeliveryReceiptDescriptor);
|
715
|
+
}
|
716
|
+
type ContentDataActionResponse = Readonly<{
|
717
|
+
type: string;
|
718
|
+
title: string;
|
719
|
+
id?: string;
|
720
|
+
url?: string;
|
721
|
+
phone?: string;
|
722
|
+
index?: number;
|
723
|
+
}>;
|
724
|
+
type ContentDataTextResponse = Readonly<{
|
725
|
+
body: string;
|
726
|
+
}>;
|
727
|
+
type ContentDataMediaResponse = Readonly<{
|
728
|
+
body?: string;
|
729
|
+
media: string[];
|
730
|
+
}>;
|
731
|
+
type ContentDataLocationResponse = Readonly<{
|
732
|
+
longitude: number;
|
733
|
+
latitude: number;
|
734
|
+
label?: string;
|
735
|
+
}>;
|
736
|
+
type ContentDataQuickReplyResponse = Readonly<{
|
737
|
+
body: string;
|
738
|
+
actions: Readonly<{
|
739
|
+
title: string;
|
740
|
+
id?: string;
|
741
|
+
}>[];
|
742
|
+
}>;
|
743
|
+
type ContentDataCallToActionResponse = Readonly<{
|
744
|
+
body: string;
|
745
|
+
actions: ContentDataActionResponse[];
|
746
|
+
}>;
|
747
|
+
type ContentDataListPickerResponse = Readonly<{
|
748
|
+
body: string;
|
749
|
+
button: string;
|
750
|
+
items: Readonly<{
|
751
|
+
id: string;
|
752
|
+
item: string;
|
753
|
+
description?: string;
|
754
|
+
}>[];
|
755
|
+
}>;
|
756
|
+
type ContentDataCardResponse = Readonly<{
|
757
|
+
title: string;
|
758
|
+
subtitle?: string;
|
759
|
+
media?: string[];
|
760
|
+
actions?: ContentDataActionResponse[];
|
761
|
+
}>;
|
762
|
+
type ContentDataResponse = Readonly<{
|
763
|
+
"twilio/text"?: ContentDataTextResponse;
|
764
|
+
"twilio/media"?: ContentDataMediaResponse;
|
765
|
+
"twilio/location"?: ContentDataLocationResponse;
|
766
|
+
"twilio/quick-reply"?: ContentDataQuickReplyResponse;
|
767
|
+
"twilio/call-to-action"?: ContentDataCallToActionResponse;
|
768
|
+
"twilio/list-picker"?: ContentDataListPickerResponse;
|
769
|
+
"twilio/card"?: ContentDataCardResponse;
|
770
|
+
}>;
|
771
|
+
type ContentTemplateResponse = Readonly<{
|
772
|
+
sid: string;
|
773
|
+
account_sid: string;
|
774
|
+
friendly_name: string;
|
775
|
+
variables: string;
|
776
|
+
variants: ContentDataResponse;
|
777
|
+
date_created: string;
|
778
|
+
date_updated: string;
|
779
|
+
}>;
|
780
|
+
/**
|
781
|
+
* Shows a button that sends back a predefined text. Used in
|
782
|
+
* {@link ContentDataQuickReply}.
|
783
|
+
*/
|
784
|
+
type ContentDataReply = {
|
785
|
+
/**
|
786
|
+
* Display value of the action. This is the message that will be sent back
|
787
|
+
* when the user taps on the button.
|
788
|
+
*/
|
789
|
+
readonly title: string;
|
790
|
+
/**
|
791
|
+
* Postback payload. This field is not visible to the end user.
|
792
|
+
*/
|
793
|
+
readonly id?: string;
|
794
|
+
};
|
795
|
+
/**
|
796
|
+
* Shows a button that redirects recipient to a predefined URL.
|
797
|
+
*/
|
798
|
+
type ContentDataActionUrl = {
|
799
|
+
/**
|
800
|
+
* The type discriminant.
|
801
|
+
*/
|
802
|
+
readonly type: "url";
|
803
|
+
/**
|
804
|
+
* Display value for the action.
|
805
|
+
*/
|
806
|
+
readonly title: string;
|
807
|
+
/**
|
808
|
+
* URL to direct to when the recipient taps the button.
|
809
|
+
*/
|
810
|
+
readonly url: string;
|
811
|
+
/**
|
812
|
+
* Full data as a stringified JSON. This could be used for future content
|
813
|
+
* types and fields which are not yet supported by the newest version of
|
814
|
+
* the Conversations SDK, or for using newer types in the older versions of
|
815
|
+
* the SDK.
|
816
|
+
*/
|
817
|
+
readonly rawData: string;
|
818
|
+
};
|
819
|
+
/**
|
820
|
+
* Shows a button that calls a phone number.
|
821
|
+
*/
|
822
|
+
type ContentDataActionPhone = {
|
823
|
+
/**
|
824
|
+
* The type discriminant.
|
825
|
+
*/
|
826
|
+
readonly type: "phone";
|
827
|
+
/**
|
828
|
+
* Display value for the action.
|
829
|
+
*/
|
830
|
+
readonly title: string;
|
831
|
+
/**
|
832
|
+
* Phone number to call when the recipient taps the button.
|
833
|
+
*/
|
834
|
+
readonly phone: string;
|
835
|
+
/**
|
836
|
+
* Full data as a stringified JSON. This could be used for future content
|
837
|
+
* types and fields which are not yet supported by the newest version of
|
838
|
+
* the Conversations SDK, or for using newer types in the older versions of
|
839
|
+
* the SDK.
|
840
|
+
*/
|
841
|
+
readonly rawData: string;
|
842
|
+
};
|
843
|
+
/**
|
844
|
+
* Shows a button that sends back a predefined text.
|
845
|
+
*/
|
846
|
+
type ContentDataActionReply = {
|
847
|
+
/**
|
848
|
+
* The type discriminant.
|
849
|
+
*/
|
850
|
+
readonly type: "reply";
|
851
|
+
/**
|
852
|
+
* Display value for the action. This is the message that will be sent back
|
853
|
+
* when the user taps on the button.
|
854
|
+
*/
|
855
|
+
readonly title: string;
|
856
|
+
/**
|
857
|
+
* Postback payload. This field is not visible to the end user.
|
858
|
+
*/
|
859
|
+
readonly id?: string;
|
860
|
+
/**
|
861
|
+
* Index for the action.
|
862
|
+
*/
|
863
|
+
readonly index: number;
|
864
|
+
/**
|
865
|
+
* Full data as a stringified JSON. This could be used for future content
|
866
|
+
* types and fields which are not yet supported by the newest version of
|
867
|
+
* the Conversations SDK, or for using newer types in the older versions of
|
868
|
+
* the SDK.
|
869
|
+
*/
|
870
|
+
readonly rawData: string;
|
871
|
+
};
|
872
|
+
/**
|
873
|
+
* Used for unknown action types which aren't present in the current version of
|
874
|
+
* the Conversations SDK.
|
875
|
+
*/
|
876
|
+
type ContentDataActionOther = {
|
877
|
+
/**
|
878
|
+
* The type discriminant.
|
879
|
+
*/
|
880
|
+
readonly type: "other";
|
881
|
+
/**
|
882
|
+
* Full data as a stringified JSON. This could be used for future content
|
883
|
+
* types and fields which are not yet supported by the newest version of
|
884
|
+
* the Conversations SDK, or for using newer types in the older versions of
|
885
|
+
* the SDK.
|
886
|
+
*/
|
887
|
+
readonly rawData: string;
|
888
|
+
};
|
889
|
+
/**
|
890
|
+
* A union of possible actions used in {@link ContentDataCallToAction} and
|
891
|
+
* {@link ContentDataCard}.
|
892
|
+
*/
|
893
|
+
type ContentDataAction = ContentDataActionUrl | ContentDataActionPhone | ContentDataActionReply | ContentDataActionOther;
|
894
|
+
/**
|
895
|
+
* Represents an item in the {@link ContentDataListPicker}.
|
896
|
+
*/
|
897
|
+
type ContentDataListItem = {
|
898
|
+
/**
|
899
|
+
* Unique item identifier. Not visible to the recipient.
|
900
|
+
*/
|
901
|
+
readonly id: string;
|
902
|
+
/**
|
903
|
+
* Display value of the item.
|
904
|
+
*/
|
905
|
+
readonly item: string;
|
906
|
+
/**
|
907
|
+
* Description of the item.
|
908
|
+
*/
|
909
|
+
readonly description?: string;
|
910
|
+
};
|
911
|
+
/**
|
912
|
+
* Contains only the plain text-based content. Represents the twilio/text
|
913
|
+
* content type.
|
914
|
+
*/
|
915
|
+
type ContentDataText = {
|
916
|
+
/**
|
917
|
+
* The type discriminant.
|
918
|
+
*/
|
919
|
+
readonly type: "text";
|
920
|
+
/**
|
921
|
+
* The text of the message you want to send.
|
922
|
+
*/
|
923
|
+
readonly body: string;
|
924
|
+
/**
|
925
|
+
* Full data as a stringified JSON. This could be used for future content
|
926
|
+
* types and fields which are not yet supported by the newest version of
|
927
|
+
* the Conversations SDK, or for using newer types in the older versions of
|
928
|
+
* the SDK.
|
929
|
+
*/
|
930
|
+
readonly rawData: string;
|
931
|
+
};
|
932
|
+
/**
|
933
|
+
* Used to send file attachments, or to send long texts via MMS in the US and
|
934
|
+
* Canada. Represents the twilio/media content type.
|
935
|
+
*/
|
936
|
+
type ContentDataMedia = {
|
937
|
+
/**
|
938
|
+
* The type discriminant.
|
939
|
+
*/
|
940
|
+
readonly type: "media";
|
941
|
+
/**
|
942
|
+
* The text of the message you want to send.
|
943
|
+
*/
|
944
|
+
readonly body?: string;
|
945
|
+
/**
|
946
|
+
* URLs of the media you want to send.
|
947
|
+
*/
|
948
|
+
readonly media: string[];
|
949
|
+
/**
|
950
|
+
* Full data as a stringified JSON. This could be used for future content
|
951
|
+
* types and fields which are not yet supported by the newest version of
|
952
|
+
* the Conversations SDK, or for using newer types in the older versions of
|
953
|
+
* the SDK.
|
954
|
+
*/
|
955
|
+
readonly rawData: string;
|
956
|
+
};
|
957
|
+
/**
|
958
|
+
* Contains a location pin and an optional label, which can be used to enhance
|
959
|
+
* delivery notifications or connect recipients to physical experiences you
|
960
|
+
* offer. Represents the twilio/location content type.
|
961
|
+
*/
|
962
|
+
type ContentDataLocation = {
|
963
|
+
/**
|
964
|
+
* The type discriminant.
|
965
|
+
*/
|
966
|
+
readonly type: "location";
|
967
|
+
/**
|
968
|
+
* The longitude value of the location pin you want to send.
|
969
|
+
*/
|
970
|
+
readonly longitude: number;
|
971
|
+
/**
|
972
|
+
* The latitude value of the location pin you want to send.
|
973
|
+
*/
|
974
|
+
readonly latitude: number;
|
975
|
+
/**
|
976
|
+
* The label to be displayed to the end user alongside the location pin.
|
977
|
+
*/
|
978
|
+
readonly label?: string;
|
979
|
+
/**
|
980
|
+
* Full data as a stringified JSON. This could be used for future content
|
981
|
+
* types and fields which are not yet supported by the newest version of
|
982
|
+
* the Conversations SDK, or for using newer types in the older versions of
|
983
|
+
* the SDK.
|
984
|
+
*/
|
985
|
+
readonly rawData: string;
|
986
|
+
};
|
987
|
+
/**
|
988
|
+
* Let recipients tap, rather than type, to respond to the message. Represents
|
989
|
+
* the twilio/quick-reply content type.
|
990
|
+
*/
|
991
|
+
type ContentDataQuickReply = {
|
992
|
+
/**
|
993
|
+
* The type discriminant.
|
994
|
+
*/
|
995
|
+
readonly type: "quickReply";
|
996
|
+
/**
|
997
|
+
* The text of the message you want to send. This is included as a regular
|
998
|
+
* text message.
|
999
|
+
*/
|
1000
|
+
readonly body: string;
|
1001
|
+
/**
|
1002
|
+
* Up to 3 buttons can be created for quick reply. See
|
1003
|
+
* {@link ContentDataReply}.
|
1004
|
+
*/
|
1005
|
+
readonly replies: ContentDataReply[];
|
1006
|
+
/**
|
1007
|
+
* Full data as a stringified JSON. This could be used for future content
|
1008
|
+
* types and fields which are not yet supported by the newest version of
|
1009
|
+
* the Conversations SDK, or for using newer types in the older versions of
|
1010
|
+
* the SDK.
|
1011
|
+
*/
|
1012
|
+
readonly rawData: string;
|
1013
|
+
};
|
1014
|
+
/**
|
1015
|
+
* Buttons that let recipients tap to trigger actions such as launching a
|
1016
|
+
* website or making a phone call. Represents the twilio/call-to-action content
|
1017
|
+
* type.
|
1018
|
+
*/
|
1019
|
+
type ContentDataCallToAction = {
|
1020
|
+
/**
|
1021
|
+
* The type discriminant.
|
1022
|
+
*/
|
1023
|
+
readonly type: "callToAction";
|
1024
|
+
/**
|
1025
|
+
* The text of the message you want to send. This is included as a regular
|
1026
|
+
* text message.
|
1027
|
+
*/
|
1028
|
+
readonly body: string;
|
1029
|
+
/**
|
1030
|
+
* Buttons that recipients can tap on to act on the message.
|
1031
|
+
*/
|
1032
|
+
readonly actions: ContentDataAction[];
|
1033
|
+
/**
|
1034
|
+
* Full data as a stringified JSON. This could be used for future content
|
1035
|
+
* types and fields which are not yet supported by the newest version of
|
1036
|
+
* the Conversations SDK, or for using newer types in the older versions of
|
1037
|
+
* the SDK.
|
1038
|
+
*/
|
1039
|
+
readonly rawData: string;
|
1040
|
+
};
|
1041
|
+
/**
|
1042
|
+
* Shows a menu of up to 10 options, which offers a simple way for users to make
|
1043
|
+
* a selection. Represents the twilio/list-picker content type.
|
1044
|
+
*/
|
1045
|
+
type ContentDataListPicker = {
|
1046
|
+
/**
|
1047
|
+
* The type discriminant.
|
1048
|
+
*/
|
1049
|
+
readonly type: "listPicker";
|
1050
|
+
/**
|
1051
|
+
* The text of the message you want to send. This is rendered as the body of
|
1052
|
+
* the message.
|
1053
|
+
*/
|
1054
|
+
readonly body: string;
|
1055
|
+
/**
|
1056
|
+
* Display value of the primary button.
|
1057
|
+
*/
|
1058
|
+
readonly button: string;
|
1059
|
+
/**
|
1060
|
+
* List item objects displayed in the list. See {@link ContentDataListItem}.
|
1061
|
+
*/
|
1062
|
+
readonly items: ContentDataListItem[];
|
1063
|
+
/**
|
1064
|
+
* Full data as a stringified JSON. This could be used for future content
|
1065
|
+
* types and fields which are not yet supported by the newest version of
|
1066
|
+
* the Conversations SDK, or for using newer types in the older versions of
|
1067
|
+
* the SDK.
|
1068
|
+
*/
|
1069
|
+
readonly rawData: string;
|
1070
|
+
};
|
1071
|
+
/**
|
1072
|
+
* Shows a menu of up to 10 options, which offers a simple way for users to make
|
1073
|
+
* a selection. Represents the twilio/card content type.
|
1074
|
+
*/
|
1075
|
+
type ContentDataCard = {
|
1076
|
+
/**
|
1077
|
+
* The type discriminant.
|
1078
|
+
*/
|
1079
|
+
readonly type: "card";
|
1080
|
+
/**
|
1081
|
+
* Title of the card.
|
1082
|
+
*/
|
1083
|
+
readonly title: string;
|
1084
|
+
/**
|
1085
|
+
* Subtitle of the card.
|
1086
|
+
*/
|
1087
|
+
readonly subtitle?: string;
|
1088
|
+
/**
|
1089
|
+
* URLs of the media to send with the message.
|
1090
|
+
*/
|
1091
|
+
readonly media: string[];
|
1092
|
+
/**
|
1093
|
+
* Buttons that the recipients can tap on to act on the message.
|
1094
|
+
*/
|
1095
|
+
readonly actions: ContentDataAction[];
|
1096
|
+
/**
|
1097
|
+
* Full data as a stringified JSON. This could be used for future content
|
1098
|
+
* types and fields which are not yet supported by the newest version of
|
1099
|
+
* the Conversations SDK, or for using newer types in the older versions of
|
1100
|
+
* the SDK.
|
1101
|
+
*/
|
1102
|
+
readonly rawData: string;
|
1103
|
+
};
|
1104
|
+
/**
|
1105
|
+
* Used for unknown content types which aren't present in the current version of
|
1106
|
+
* the Conversations SDK.
|
1107
|
+
*/
|
1108
|
+
type ContentDataOther = {
|
1109
|
+
/**
|
1110
|
+
* The type discriminant.
|
1111
|
+
*/
|
1112
|
+
readonly type: "other";
|
1113
|
+
/**
|
1114
|
+
* Full data as a stringified JSON. This could be used for future content
|
1115
|
+
* types and fields which are not yet supported by the newest version of
|
1116
|
+
* the Conversations SDK, or for using newer types in the older versions of
|
1117
|
+
* the SDK.
|
1118
|
+
*/
|
1119
|
+
readonly rawData: string;
|
1120
|
+
};
|
1121
|
+
/**
|
1122
|
+
* A union of possible data types in rich content templates.
|
1123
|
+
*/
|
1124
|
+
type ContentData = ContentDataText | ContentDataMedia | ContentDataLocation | ContentDataQuickReply | ContentDataCallToAction | ContentDataListPicker | ContentDataCard | ContentDataOther;
|
1125
|
+
/**
|
1126
|
+
* Represents a variable for a content template. See
|
1127
|
+
* {@link ContentTemplate.variables}.
|
1128
|
+
*/
|
1129
|
+
declare class ContentTemplateVariable {
|
1130
|
+
readonly name: string;
|
1131
|
+
readonly value: string;
|
1132
|
+
constructor(/**
|
1133
|
+
* Name of the variable.
|
1134
|
+
*/
|
1135
|
+
name: string, /**
|
1136
|
+
* Key of the variable
|
1137
|
+
*/
|
1138
|
+
value: string);
|
1139
|
+
/**
|
1140
|
+
* Copies the variable with a new value.
|
1141
|
+
*
|
1142
|
+
* @param value The new value for the variable.
|
1143
|
+
*/
|
1144
|
+
copyWithValue(value: string): ContentTemplateVariable;
|
1145
|
+
}
|
1146
|
+
/**
|
1147
|
+
* A rich content template.
|
1148
|
+
*
|
1149
|
+
* Use {@Link Client.getContentTemplates} to request all the templates available
|
1150
|
+
* for the current account.
|
1151
|
+
*/
|
1152
|
+
declare class ContentTemplate {
|
1153
|
+
/**
|
1154
|
+
* The server-assigned unique identifier for the template.
|
1155
|
+
*/
|
1156
|
+
readonly sid: string;
|
1157
|
+
/**
|
1158
|
+
* Friendly name used to describe the content. Not visible to the recipient.
|
1159
|
+
*/
|
1160
|
+
readonly friendlyName: string;
|
1161
|
+
/**
|
1162
|
+
* Variables used by this template.
|
1163
|
+
*/
|
1164
|
+
readonly variables: ContentTemplateVariable[];
|
1165
|
+
/**
|
1166
|
+
* Variants of the content. See {@link ContentData}.
|
1167
|
+
*/
|
1168
|
+
readonly variants: Map<string, ContentData>;
|
1169
|
+
/**
|
1170
|
+
* Date of creation.
|
1171
|
+
*/
|
1172
|
+
readonly dateCreated: Date;
|
1173
|
+
/**
|
1174
|
+
* Date of the last update.
|
1175
|
+
*/
|
1176
|
+
readonly dateUpdated: Date;
|
1177
|
+
/**
|
1178
|
+
* @internal
|
1179
|
+
*/
|
1180
|
+
constructor(contentTemplateResponse: ContentTemplateResponse);
|
1181
|
+
}
|
1182
|
+
type ChannelMetadataClientServices = {
|
1183
|
+
commandExecutor: CommandExecutor;
|
1184
|
+
};
|
1185
|
+
/**
|
1186
|
+
* Represents channel metadata.
|
1187
|
+
*/
|
1188
|
+
declare class ChannelMetadata {
|
1189
|
+
/**
|
1190
|
+
* Communication channel type.
|
1191
|
+
*/
|
1192
|
+
readonly type: string;
|
1193
|
+
/**
|
1194
|
+
* The actual metadata.
|
1195
|
+
*/
|
1196
|
+
readonly data: unknown;
|
1197
|
+
/**
|
1198
|
+
* @internal
|
1199
|
+
*/
|
1200
|
+
constructor(type: string, data: unknown);
|
1201
|
+
}
|
1202
|
+
declare class ChannelMetadataClient {
|
1203
|
+
private readonly _services;
|
1204
|
+
private readonly _configuration;
|
1205
|
+
private readonly _cache;
|
1206
|
+
constructor(services: ChannelMetadataClientServices, configuration: Configuration);
|
1207
|
+
getChannelMetadata(conversationSid: string, messageSid: string): Promise<ChannelMetadata | null>;
|
1208
|
+
}
|
1209
|
+
type MessageRecipient = {
|
1210
|
+
message_sid: string;
|
1211
|
+
type: "email"; // discriminant for future expansion
|
1212
|
+
level: "to" | "from" | "cc";
|
1213
|
+
name: string;
|
1214
|
+
address: string;
|
1215
|
+
};
|
1216
|
+
/**
|
1217
|
+
* Pagination helper interface.
|
1218
|
+
* @typeParam T The item type.
|
1219
|
+
*/
|
1220
|
+
interface Paginator<T> {
|
1221
|
+
/**
|
1222
|
+
* Indicates the existence of the next page.
|
1223
|
+
*/
|
1224
|
+
hasNextPage: boolean;
|
1225
|
+
/**
|
1226
|
+
* Indicates the existence of the previous page.
|
1227
|
+
*/
|
1228
|
+
hasPrevPage: boolean;
|
1229
|
+
/**
|
1230
|
+
* Array of elements of type T on the current page.
|
1231
|
+
*/
|
1232
|
+
items: T[];
|
1233
|
+
/**
|
1234
|
+
* Request next page.
|
1235
|
+
* Does not modify the existing object.
|
1236
|
+
*/
|
1237
|
+
nextPage(): Promise<Paginator<T>>;
|
1238
|
+
/**
|
1239
|
+
* Request previous page.
|
1240
|
+
* Does not modify the existing object.
|
1241
|
+
*/
|
1242
|
+
prevPage(): Promise<Paginator<T>>;
|
1243
|
+
}
|
1244
|
+
interface PaginatorOptions {
|
1245
|
+
pageSize?: number;
|
1246
|
+
}
|
1247
|
+
type MessageRecipientsClientServices = {
|
1248
|
+
commandExecutor: CommandExecutor;
|
1249
|
+
};
|
1250
|
+
/**
|
1251
|
+
* Message recipient descriptor.
|
1252
|
+
*/
|
1253
|
+
type RecipientDescriptor = EmailRecipientDescriptor | UnknownRecipientDescriptor;
|
1254
|
+
/**
|
1255
|
+
* Email recipient level.
|
1256
|
+
*/
|
1257
|
+
type EmailRecipientLevel = "to" | "from" | "cc";
|
1258
|
+
/**
|
1259
|
+
* Email recipient descriptor.
|
1260
|
+
*/
|
1261
|
+
declare class EmailRecipientDescriptor {
|
1262
|
+
/**
|
1263
|
+
* Type of recipient.
|
1264
|
+
*/
|
1265
|
+
readonly type = "email";
|
1266
|
+
/**
|
1267
|
+
* Sid of the message that this recipient belongs to.
|
1268
|
+
*/
|
1269
|
+
readonly messageSid: string;
|
1270
|
+
/**
|
1271
|
+
* Email recipient level.
|
1272
|
+
*/
|
1273
|
+
readonly level: EmailRecipientLevel;
|
1274
|
+
/**
|
1275
|
+
* Name of the recipient.
|
1276
|
+
*/
|
1277
|
+
readonly name: string;
|
1278
|
+
/**
|
1279
|
+
* Address of the recipient.
|
1280
|
+
*/
|
1281
|
+
readonly address: string;
|
1282
|
+
/**
|
1283
|
+
* @internal
|
1284
|
+
*/
|
1285
|
+
constructor(recipient: MessageRecipient);
|
1286
|
+
}
|
1287
|
+
/**
|
1288
|
+
* Unknown recipient descriptor. Used to be able to handle recipient types that
|
1289
|
+
* are not supported by the current version of the SDK.
|
1290
|
+
*/
|
1291
|
+
declare class UnknownRecipientDescriptor {
|
1292
|
+
/**
|
1293
|
+
* Type of recipient.
|
1294
|
+
*/
|
1295
|
+
readonly type: string;
|
1296
|
+
/**
|
1297
|
+
* Sid of the message that this recipient belongs to.
|
1298
|
+
*/
|
1299
|
+
readonly messageSid: string;
|
1300
|
+
/**
|
1301
|
+
* Recipient data as a JSON string.
|
1302
|
+
*/
|
1303
|
+
readonly rawData: string;
|
1304
|
+
/**
|
1305
|
+
* @internal
|
1306
|
+
*/
|
1307
|
+
constructor(recipient: MessageRecipient);
|
1308
|
+
}
|
1309
|
+
declare class MessageRecipientsClient {
|
1310
|
+
private readonly _services;
|
1311
|
+
private readonly _configuration;
|
1312
|
+
private readonly _cache;
|
1313
|
+
constructor(services: MessageRecipientsClientServices, configuration: Configuration);
|
1314
|
+
getRecipientsFromMessage(conversationSid: string, messageSid: string): Promise<RecipientDescriptor[]>;
|
1315
|
+
getRecipientsFromConversation(conversationSid: string, paginatorOptions?: {
|
1316
|
+
pageToken?: string;
|
1317
|
+
pageSize?: number;
|
1318
|
+
}): Promise<Paginator<RecipientDescriptor>>;
|
1319
|
+
private _wrapResponse;
|
1320
|
+
}
|
1321
|
+
type MessageEvents = {
|
1322
|
+
updated: (data: {
|
1323
|
+
message: Message;
|
1324
|
+
updateReasons: MessageUpdateReason[];
|
1325
|
+
}) => void;
|
1326
|
+
};
|
1327
|
+
interface MessageServices {
|
1328
|
+
mcsClient: McsClient;
|
1329
|
+
network: Network;
|
1330
|
+
commandExecutor: CommandExecutor;
|
1331
|
+
channelMetadataClient: ChannelMetadataClient;
|
1332
|
+
messageRecipientsClient: MessageRecipientsClient;
|
1333
|
+
}
|
1334
|
+
interface MessageLinks {
|
1335
|
+
self: string;
|
1336
|
+
conversation: string;
|
1337
|
+
messages_receipts: string;
|
1338
|
+
}
|
1339
|
+
/**
|
1340
|
+
* The reason for the `updated` event being emitted by a message.
|
1341
|
+
*/
|
1342
|
+
type MessageUpdateReason = "body" | "lastUpdatedBy" | "dateCreated" | "dateUpdated" | "attributes" | "author" | "deliveryReceipt" | "subject" | "media";
|
1343
|
+
/**
|
1344
|
+
* Type of message.
|
1345
|
+
*/
|
1346
|
+
type MessageType = "text" | "media";
|
1347
|
+
interface MessageUpdatedEventArgs {
|
1348
|
+
message: Message;
|
1349
|
+
updateReasons: MessageUpdateReason[];
|
1350
|
+
}
|
1351
|
+
interface MessageData {
|
1352
|
+
sid: string;
|
1353
|
+
text?: string;
|
1354
|
+
type?: MessageType;
|
1355
|
+
author: string | null;
|
1356
|
+
subject: string | null;
|
1357
|
+
contentSid: string | null;
|
1358
|
+
lastUpdatedBy?: string | null;
|
1359
|
+
attributes?: JSONValue;
|
1360
|
+
dateUpdated: string;
|
1361
|
+
timestamp?: string;
|
1362
|
+
medias?: Media[];
|
1363
|
+
media?: Media;
|
1364
|
+
memberSid?: string;
|
1365
|
+
delivery?: AggregatedDeliveryDescriptor;
|
1366
|
+
channelMetadata?: boolean;
|
1367
|
+
}
|
1368
|
+
/**
|
1369
|
+
* A message in a conversation.
|
1370
|
+
*/
|
1371
|
+
declare class Message extends ReplayEventEmitter<MessageEvents> {
|
1372
|
+
#private;
|
1373
|
+
/**
|
1374
|
+
* Conversation that the message is in.
|
1375
|
+
*/
|
1376
|
+
readonly conversation: Conversation;
|
1377
|
+
private readonly links;
|
1378
|
+
private readonly configuration;
|
1379
|
+
private readonly services;
|
1380
|
+
private state;
|
1381
|
+
/**
|
1382
|
+
* @internal
|
1383
|
+
*/
|
1384
|
+
constructor(index: number, data: MessageData, conversation: Conversation, links: MessageLinks, configuration: Configuration, services: MessageServices);
|
1385
|
+
/**
|
1386
|
+
* Fired when the properties or the body of the message has been updated.
|
1387
|
+
*
|
1388
|
+
* Parameters:
|
1389
|
+
* 1. object `data` - info object provided with the event. It has the following properties:
|
1390
|
+
* * {@link Message} message - the message in question
|
1391
|
+
* * {@link MessageUpdateReason}[] updateReasons - array of reasons for the update
|
1392
|
+
*/
|
1393
|
+
static readonly updated = "updated";
|
1394
|
+
/**
|
1395
|
+
* The server-assigned unique identifier for the message.
|
1396
|
+
*/
|
1397
|
+
get sid(): string;
|
1398
|
+
/**
|
1399
|
+
* Name of the user that sent the message.
|
1400
|
+
*/
|
1401
|
+
get author(): string | null;
|
1402
|
+
/**
|
1403
|
+
* Message subject. Used only in email conversations.
|
1404
|
+
*/
|
1405
|
+
get subject(): string | null;
|
1406
|
+
/**
|
1407
|
+
* Unique identifier of {@link ContentTemplate} for this message.
|
1408
|
+
*/
|
1409
|
+
get contentSid(): string | null;
|
1410
|
+
/**
|
1411
|
+
* Body of the message.
|
1412
|
+
*/
|
1413
|
+
get body(): string | null;
|
1414
|
+
/**
|
1415
|
+
* Date this message was last updated on.
|
1416
|
+
*/
|
1417
|
+
get dateUpdated(): Date | null;
|
1418
|
+
/**
|
1419
|
+
* Index of this message in the conversation's list of messages.
|
1420
|
+
*
|
1421
|
+
* By design, the message indices may have arbitrary gaps between them,
|
1422
|
+
* that does not necessarily mean they were deleted or otherwise modified - just that
|
1423
|
+
* messages may have some non-contiguous indices even if they are being sent immediately one after another.
|
1424
|
+
*
|
1425
|
+
* Trying to use indices for some calculations is going to be unreliable.
|
1426
|
+
*
|
1427
|
+
* To calculate the number of unread messages, it is better to use the Read Horizon API.
|
1428
|
+
* See {@link Conversation.getUnreadMessagesCount} for details.
|
1429
|
+
*/
|
1430
|
+
get index(): number;
|
1431
|
+
/**
|
1432
|
+
* Identity of the last user that updated the message.
|
1433
|
+
*/
|
1434
|
+
get lastUpdatedBy(): string | null;
|
1435
|
+
/**
|
1436
|
+
* Date this message was created on.
|
1437
|
+
*/
|
1438
|
+
get dateCreated(): Date | null;
|
1439
|
+
/**
|
1440
|
+
* Custom attributes of the message.
|
1441
|
+
*/
|
1442
|
+
get attributes(): JSONValue;
|
1443
|
+
/**
|
1444
|
+
* Type of the message.
|
1445
|
+
*/
|
1446
|
+
get type(): MessageType;
|
1447
|
+
/**
|
1448
|
+
* One of the attached media (if present).
|
1449
|
+
* @deprecated Use attachedMedia instead. Note that the latter is now an array.
|
1450
|
+
*/
|
1451
|
+
get media(): Media | null;
|
1452
|
+
/**
|
1453
|
+
* Return all media attachments, except email body/history attachments, without temporary urls.
|
1454
|
+
*/
|
1455
|
+
get attachedMedia(): Array<Media> | null;
|
1456
|
+
/**
|
1457
|
+
* The server-assigned unique identifier of the authoring participant.
|
1458
|
+
*/
|
1459
|
+
get participantSid(): string | null;
|
1460
|
+
/**
|
1461
|
+
* Aggregated information about the message delivery statuses across all participants of a conversation..
|
1462
|
+
*/
|
1463
|
+
get aggregatedDeliveryReceipt(): AggregatedDeliveryReceipt | null;
|
1464
|
+
/**
|
1465
|
+
* @deprecated
|
1466
|
+
* Return a (possibly empty) array of media matching a specific set of categories.
|
1467
|
+
* Allowed category is so far only 'media'.
|
1468
|
+
* @param categories Array of categories to match.
|
1469
|
+
* @returns Array of media descriptors matching given categories.
|
1470
|
+
*/
|
1471
|
+
getMediaByCategory(categories: Array<MediaCategory>): Array<Media> | null;
|
1472
|
+
/**
|
1473
|
+
* Return a (possibly empty) array of media matching a specific set of categories.
|
1474
|
+
* Allowed category is so far only 'media'.
|
1475
|
+
* @param categories Array of categories to match.
|
1476
|
+
* @returns Array of media descriptors matching given categories.
|
1477
|
+
*/
|
1478
|
+
getMediaByCategories(categories: MediaCategory[]): Media[] | null;
|
1479
|
+
/**
|
1480
|
+
* Get a media descriptor for an email body attachment of a provided type.
|
1481
|
+
* Allowed body types are returned in the Conversation.limits().emailBodiesAllowedContentTypes array.
|
1482
|
+
* @param type Type of email body to request, defaults to `text/plain`.
|
1483
|
+
*/
|
1484
|
+
getEmailBody(type?: string): Media | null;
|
1485
|
+
/**
|
1486
|
+
* Get a media descriptor for an email history attachment of a provided type.
|
1487
|
+
* Allowed body types are returned in the Conversation.limits().emailHistoriesAllowedContentTypes array.
|
1488
|
+
* @param type Type of email history to request, defaults to `text/plain`.
|
1489
|
+
*/
|
1490
|
+
getEmailHistory(type?: string): Media | null;
|
1491
|
+
_update(data: any): void;
|
1492
|
+
/**
|
1493
|
+
* Get the participant who is the author of the message.
|
1494
|
+
*/
|
1495
|
+
getParticipant(): Promise<Participant>;
|
1496
|
+
/**
|
1497
|
+
* Get the delivery receipts of the message.
|
1498
|
+
*/
|
1499
|
+
getDetailedDeliveryReceipts(): Promise<DetailedDeliveryReceipt[]>;
|
1500
|
+
/**
|
1501
|
+
* Remove the message.
|
1502
|
+
*/
|
1503
|
+
remove(): Promise<Message>;
|
1504
|
+
/**
|
1505
|
+
* Edit the message body.
|
1506
|
+
* @param body New body of the message.
|
1507
|
+
*/
|
1508
|
+
updateBody(body: string): Promise<Message>;
|
1509
|
+
/**
|
1510
|
+
* Edit the message attributes.
|
1511
|
+
* @param attributes New attributes.
|
1512
|
+
*/
|
1513
|
+
updateAttributes(attributes: JSONValue): Promise<Message>;
|
1514
|
+
/**
|
1515
|
+
* @deprecated
|
1516
|
+
* Get content URLs for all media attachments in the given set using a single operation.
|
1517
|
+
* @param contentSet Set of media attachments to query content URLs.
|
1518
|
+
*/
|
1519
|
+
attachTemporaryUrlsFor(contentSet: Media[] | null): Promise<Media[]>;
|
1520
|
+
/**
|
1521
|
+
* Get content URLs for all media attachments in the given set using a single operation.
|
1522
|
+
* @param contentSet Set of media attachments to query content URLs.
|
1523
|
+
*/
|
1524
|
+
getTemporaryContentUrlsForMedia(contentSet: Media[]): CancellablePromise<Map<string, string>>;
|
1525
|
+
/**
|
1526
|
+
* Get content URLs for all media attachments in the given set of media sids using a single operation.
|
1527
|
+
* @param mediaSids Set of media sids to query for the content URL.
|
1528
|
+
*/
|
1529
|
+
getTemporaryContentUrlsForMediaSids(mediaSids: string[]): CancellablePromise<Map<string, string>>;
|
1530
|
+
/**
|
1531
|
+
* Get content URLs for all media attached to the message.
|
1532
|
+
*/
|
1533
|
+
getTemporaryContentUrlsForAttachedMedia(): CancellablePromise<Map<string, string>>;
|
1534
|
+
private _getDetailedDeliveryReceiptsPaginator;
|
1535
|
+
/**
|
1536
|
+
* Get the {@link ContentData} for this message. Resolves to `null` when
|
1537
|
+
* {@link Message.contentSid} is null.
|
1538
|
+
*/
|
1539
|
+
getContentData(): CancellablePromise<ContentData | null>;
|
1540
|
+
/**
|
1541
|
+
* Get the {@link ChannelMetadata} for this message. Resolves to `null` if
|
1542
|
+
* the message doesn't have any channel metadata.
|
1543
|
+
*/
|
1544
|
+
getChannelMetadata(): Promise<ChannelMetadata | null>;
|
1545
|
+
/**
|
1546
|
+
* Get recipients of the message.
|
1547
|
+
*/
|
1548
|
+
getMessageRecipients(): Promise<RecipientDescriptor[]>;
|
1549
|
+
}
|
1550
|
+
interface TypingIndicatorServices {
|
1551
|
+
twilsockClient: TwilsockClient;
|
1552
|
+
notificationClient: Notifications;
|
1553
|
+
}
|
1554
|
+
/**
|
1555
|
+
* 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
|
1556
|
+
* 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
|
1557
|
+
* "typing_timeout" attribute will be exactly the same as defined in the console. The second place that the attribute appears in is from a
|
1558
|
+
* notification of type "twilio.ipmsg.typing_indicator". In this case, the "typing_timeout" value will be +1 of that in the console. This
|
1559
|
+
* intentional. The timeout returned from the POST -> /v1/typing call should be used to disable further calls for that period of time. On contrary,
|
1560
|
+
* the timeout returned from the notification should be used as the timeout for the "typingEnded" event, +1 is to account for latency.
|
1561
|
+
*
|
1562
|
+
* @private
|
1563
|
+
*/
|
1564
|
+
/**
|
1565
|
+
* @class TypingIndicator
|
1566
|
+
*
|
1567
|
+
* @constructor
|
1568
|
+
* @private
|
1569
|
+
*/
|
1570
|
+
declare class TypingIndicator {
|
1571
|
+
private readonly services;
|
1572
|
+
private readonly configuration;
|
1573
|
+
private sentUpdates;
|
1574
|
+
private getConversation;
|
1575
|
+
private serviceTypingTimeout;
|
1576
|
+
constructor(getConversation: (conversationSid: string) => Promise<Conversation>, config: Configuration, services: TypingIndicatorServices);
|
1577
|
+
get typingTimeout(): number;
|
1578
|
+
/**
|
1579
|
+
* Initialize TypingIndicator controller
|
1580
|
+
* Registers for needed message types and sets listeners
|
1581
|
+
* @private
|
1582
|
+
*/
|
1583
|
+
initialize(): void;
|
1584
|
+
/**
|
1585
|
+
* Remote participants typing events handler
|
1586
|
+
*/
|
1587
|
+
private _handleRemoteTyping;
|
1588
|
+
/**
|
1589
|
+
* Send typing event for the given conversation sid
|
1590
|
+
* @param {String} conversationSid
|
1591
|
+
*/
|
1592
|
+
send(conversationSid: string): Promise<void>;
|
1593
|
+
private _send;
|
1594
|
+
}
|
1595
|
+
/**
|
1596
|
+
* Pagination helper class.
|
1597
|
+
*/
|
1598
|
+
declare class RestPaginator<T> implements Paginator<T> {
|
1599
|
+
private state;
|
1600
|
+
/**
|
1601
|
+
* Indicates the existence of the next page.
|
1602
|
+
*/
|
1603
|
+
get hasNextPage(): boolean;
|
1604
|
+
/**
|
1605
|
+
* Indicates the existence of the previous page
|
1606
|
+
*/
|
1607
|
+
get hasPrevPage(): boolean;
|
1608
|
+
/**
|
1609
|
+
* Array of elements on the current page.
|
1610
|
+
*/
|
1611
|
+
get items(): T[];
|
1612
|
+
/**
|
1613
|
+
* @internal
|
1614
|
+
*/
|
1615
|
+
constructor(items: any, source: any, prevToken: any, nextToken: any);
|
1616
|
+
/**
|
1617
|
+
* Request the next page. Does not modify the existing object.
|
1618
|
+
*/
|
1619
|
+
nextPage(): Promise<RestPaginator<T>>;
|
1620
|
+
/**
|
1621
|
+
* Request the previous page. Does not modify the existing object.
|
1622
|
+
*/
|
1623
|
+
prevPage(): Promise<RestPaginator<T>>;
|
1624
|
+
}
|
1625
|
+
/**
|
1626
|
+
* @classdesc Pagination helper class for Sync
|
1627
|
+
*
|
1628
|
+
* @property {Array} items Array of elements on current page
|
1629
|
+
* @property {boolean} hasNextPage
|
1630
|
+
* @property {boolean} hasPrevPage
|
1631
|
+
*/
|
1632
|
+
declare class SyncPaginator<T> implements Paginator<T> {
|
1633
|
+
private state;
|
1634
|
+
hasNextPage: boolean;
|
1635
|
+
hasPrevPage: boolean;
|
1636
|
+
get items(): T[];
|
1637
|
+
/**
|
1638
|
+
* @param {Array} items Array of element for current page
|
1639
|
+
* @param {Object} params
|
1640
|
+
*/
|
1641
|
+
constructor(items: any, pageSize: any, anchor: any, direction: any, source: any);
|
1642
|
+
nextPage(): Promise<RestPaginator<T>>;
|
1643
|
+
prevPage(): Promise<SyncPaginator<T> | RestPaginator<T>>;
|
1644
|
+
}
|
1645
|
+
interface MessageResponse {
|
1646
|
+
account_sid: string;
|
1647
|
+
chat_service_sid: string;
|
1648
|
+
conversation_sid: string;
|
1649
|
+
sid: string;
|
1650
|
+
index: number;
|
1651
|
+
attributes: string;
|
1652
|
+
author: string;
|
1653
|
+
participant_sid: string;
|
1654
|
+
body: string;
|
1655
|
+
subject: string;
|
1656
|
+
date_created: string;
|
1657
|
+
date_updated: string;
|
1658
|
+
url: string;
|
1659
|
+
media: {
|
1660
|
+
sid: string;
|
1661
|
+
size: string;
|
1662
|
+
content_type: string;
|
1663
|
+
filename: string;
|
1664
|
+
}[] | null;
|
1665
|
+
links: {
|
1666
|
+
conversation: string;
|
1667
|
+
messages_receipts: string;
|
1668
|
+
};
|
1669
|
+
}
|
1670
|
+
type MessagesEvents = {
|
1671
|
+
messageAdded: (message: Message) => void;
|
1672
|
+
messageRemoved: (message: Message) => void;
|
1673
|
+
messageUpdated: (data: {
|
1674
|
+
message: Message;
|
1675
|
+
updateReasons: MessageUpdateReason[];
|
1676
|
+
}) => void;
|
1677
|
+
};
|
1678
|
+
interface MessagesServices {
|
1679
|
+
mcsClient: McsClient;
|
1680
|
+
network: Network;
|
1681
|
+
syncClient: SyncClient;
|
1682
|
+
commandExecutor: CommandExecutor;
|
1683
|
+
channelMetadataClient: ChannelMetadataClient;
|
1684
|
+
messageRecipientsClient: MessageRecipientsClient;
|
1685
|
+
}
|
1686
|
+
/**
|
1687
|
+
* Represents the collection of messages in a conversation
|
1688
|
+
*/
|
1689
|
+
declare class Messages extends ReplayEventEmitter<MessagesEvents> {
|
1690
|
+
readonly conversation: Conversation;
|
1691
|
+
private readonly configuration;
|
1692
|
+
private readonly services;
|
1693
|
+
private readonly messagesByIndex;
|
1694
|
+
private messagesListPromise;
|
1695
|
+
constructor(conversation: Conversation, configuration: Configuration, services: MessagesServices);
|
1696
|
+
/**
|
1697
|
+
* Subscribe to the Messages Event Stream
|
1698
|
+
* @param arg - Name of the Sync object, or the SyncList itself, that
|
1699
|
+
* represents the Messages resource.
|
1700
|
+
*/
|
1701
|
+
subscribe(arg: string | SyncList): Promise<SyncList>;
|
1702
|
+
unsubscribe(): Promise<void>;
|
1703
|
+
/**
|
1704
|
+
* Send a message to the conversation. The message could include text and multiple media attachments.
|
1705
|
+
* @param message Message to post
|
1706
|
+
*/
|
1707
|
+
sendV2(message: UnsentMessage): CancellablePromise<MessageResponse>;
|
1708
|
+
/**
|
1709
|
+
* Send Message to the conversation
|
1710
|
+
* @param message Message to post
|
1711
|
+
* @param attributes Message attributes
|
1712
|
+
* @param emailOptions Options that modify E-mail integration behaviors.
|
1713
|
+
* @returns Returns promise which can fail
|
1714
|
+
*/
|
1715
|
+
send(message: null | string | FormData | SendMediaOptions, attributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<MessageResponse>;
|
1716
|
+
/**
|
1717
|
+
* Send Media Message to the conversation
|
1718
|
+
* @param mediaContent Media content to post
|
1719
|
+
* @param attributes Message attributes
|
1720
|
+
* @param emailOptions Email options
|
1721
|
+
* @returns Returns promise which can fail
|
1722
|
+
*/
|
1723
|
+
sendMedia(mediaContent: FormData | SendMediaOptions, attributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<MessageResponse>;
|
1724
|
+
/**
|
1725
|
+
* Returns messages from conversation using paginator interface
|
1726
|
+
* @param pageSize Number of messages to return in single chunk. By default it's 30.
|
1727
|
+
* @param anchor Most early message id which is already known, or 'end' by default
|
1728
|
+
* @param direction Pagination order 'backwards' or 'forward', 'forward' by default
|
1729
|
+
* @returns Last page of messages by default
|
1730
|
+
*/
|
1731
|
+
getMessages(pageSize: number | undefined, anchor: number | "end" | undefined, direction?: "forward" | "backwards"): Promise<SyncPaginator<Message>>;
|
1732
|
+
private _wrapPaginator;
|
1733
|
+
private _upsertMessage;
|
1734
|
+
/**
|
1735
|
+
* Returns last messages from conversation
|
1736
|
+
* @param {Number} [pageSize] Number of messages to return in single chunk. By default it's 30.
|
1737
|
+
* @param {String} [anchor] Most early message id which is already known, or 'end' by default
|
1738
|
+
* @param {String} [direction] Pagination order 'backwards' or 'forward', or 'forward' by default
|
1739
|
+
* @returns {Promise<SyncPaginator<Message>>} last page of messages by default
|
1740
|
+
* @private
|
1741
|
+
*/
|
1742
|
+
private _getMessages;
|
1743
|
+
}
|
1744
|
+
/**
|
1745
|
+
* An unsent message. Returned from {@link MessageBuilder.build}.
|
1746
|
+
*/
|
1747
|
+
declare class UnsentMessage {
|
1748
|
+
private messagesEntity;
|
1749
|
+
text?: string;
|
1750
|
+
attributes: JSONValue;
|
1751
|
+
mediaContent: [
|
1752
|
+
MediaCategory,
|
1753
|
+
FormData | SendMediaOptions
|
1754
|
+
][];
|
1755
|
+
emailOptions: SendEmailOptions;
|
1756
|
+
contentSid?: string;
|
1757
|
+
contentVariables?: ContentTemplateVariable[];
|
1758
|
+
/**
|
1759
|
+
* @internal
|
1760
|
+
*/
|
1761
|
+
constructor(messagesEntity: Messages);
|
1762
|
+
/**
|
1763
|
+
* Send the prepared message to the conversation.
|
1764
|
+
* @returns Index of the new message in the conversation.
|
1765
|
+
*/
|
1766
|
+
send(): CancellablePromise<number | null>;
|
1767
|
+
}
|
1768
|
+
/**
|
1769
|
+
* Message builder. Allows the message to be built and sent via method chaining.
|
1770
|
+
*
|
1771
|
+
* Example:
|
1772
|
+
*
|
1773
|
+
* ```ts
|
1774
|
+
* await testConversation.prepareMessage()
|
1775
|
+
* .setBody('Hello!')
|
1776
|
+
* .setAttributes({foo: 'bar'})
|
1777
|
+
* .addMedia(media1)
|
1778
|
+
* .addMedia(media2)
|
1779
|
+
* .build()
|
1780
|
+
* .send();
|
1781
|
+
* ```
|
1782
|
+
*/
|
1783
|
+
declare class MessageBuilder {
|
1784
|
+
private readonly limits;
|
1785
|
+
private readonly message;
|
1786
|
+
private emailBodies;
|
1787
|
+
private emailHistories;
|
1788
|
+
/**
|
1789
|
+
* @internal
|
1790
|
+
*/
|
1791
|
+
constructor(limits: ConversationLimits, messagesEntity: Messages);
|
1792
|
+
/**
|
1793
|
+
* Sets the message body.
|
1794
|
+
* @param text Contents of the body.
|
1795
|
+
*/
|
1796
|
+
setBody(text: string): MessageBuilder;
|
1797
|
+
/**
|
1798
|
+
* Sets the message subject.
|
1799
|
+
* @param subject Contents of the subject.
|
1800
|
+
*/
|
1801
|
+
setSubject(subject: string): MessageBuilder;
|
1802
|
+
/**
|
1803
|
+
* Sets the message attributes.
|
1804
|
+
* @param attributes Message attributes.
|
1805
|
+
*/
|
1806
|
+
setAttributes(attributes: JSONValue): MessageBuilder;
|
1807
|
+
/**
|
1808
|
+
* Set the email body with a given content type.
|
1809
|
+
* @param contentType Format of the body to set (text/plain or text/html).
|
1810
|
+
* @param body Body payload in the selected format.
|
1811
|
+
*/
|
1812
|
+
setEmailBody(contentType: string, body: FormData | SendMediaOptions): MessageBuilder;
|
1813
|
+
/**
|
1814
|
+
* Set the email history with a given content type.
|
1815
|
+
* @param contentType Format of the history to set (text/plain or text/html).
|
1816
|
+
* @param history History payload in the selected format.
|
1817
|
+
*/
|
1818
|
+
setEmailHistory(contentType: string, history: FormData | SendMediaOptions): MessageBuilder;
|
1819
|
+
/**
|
1820
|
+
* Adds {@link ContentTemplate} SID for the message alongside optional
|
1821
|
+
* variables. When no variables provided, the default values will be used.
|
1822
|
+
*
|
1823
|
+
* Adding the content SID converts the message to a rich message. In this
|
1824
|
+
* case, other fields are ignored and the message is sent using the content
|
1825
|
+
* from the the {@link ContentTemplate}.
|
1826
|
+
*
|
1827
|
+
* Use {@link Client.getContentTemplates} to request all available
|
1828
|
+
* {@link ContentTemplate}s.
|
1829
|
+
*
|
1830
|
+
* @param contentSid SID of the {@link ContentTemplate}
|
1831
|
+
* @param variables Custom variables to resolve the template.
|
1832
|
+
*/
|
1833
|
+
setContentTemplate(contentSid: string, contentVariables?: ContentTemplateVariable[]): MessageBuilder;
|
1834
|
+
/**
|
1835
|
+
* Adds media to the message.
|
1836
|
+
* @param payload Media to add.
|
1837
|
+
*/
|
1838
|
+
addMedia(payload: FormData | SendMediaOptions): MessageBuilder;
|
1839
|
+
/**
|
1840
|
+
* Builds the message, making it ready to be sent.
|
1841
|
+
*/
|
1842
|
+
build(): UnsentMessage;
|
1843
|
+
/**
|
1844
|
+
* Prepares a message and sends it to the conversation.
|
1845
|
+
*/
|
1846
|
+
buildAndSend(): CancellablePromise<number | null>;
|
1847
|
+
}
|
1848
|
+
/**
|
1849
|
+
* Conversation events.
|
1850
|
+
*/
|
1851
|
+
type ConversationEvents = {
|
1852
|
+
participantJoined: (participant: Participant) => void;
|
1853
|
+
participantLeft: (participant: Participant) => void;
|
1854
|
+
participantUpdated: (data: {
|
1855
|
+
participant: Participant;
|
1856
|
+
updateReasons: ParticipantUpdateReason[];
|
1857
|
+
}) => void;
|
1858
|
+
messageAdded: (message: Message) => void;
|
1859
|
+
messageRemoved: (message: Message) => void;
|
1860
|
+
messageUpdated: (data: {
|
1861
|
+
message: Message;
|
1862
|
+
updateReasons: MessageUpdateReason[];
|
1863
|
+
}) => void;
|
1864
|
+
typingEnded: (participant: Participant) => void;
|
1865
|
+
typingStarted: (participant: Participant) => void;
|
1866
|
+
updated: (data: {
|
1867
|
+
conversation: Conversation;
|
1868
|
+
updateReasons: ConversationUpdateReason[];
|
1869
|
+
}) => void;
|
1870
|
+
removed: (conversation: Conversation) => void;
|
1871
|
+
};
|
1872
|
+
/**
|
1873
|
+
* Reason for the `updated` event emission by a conversation.
|
1874
|
+
*/
|
1875
|
+
type ConversationUpdateReason = "attributes" | "createdBy" | "dateCreated" | "dateUpdated" | "friendlyName" | "lastReadMessageIndex" | "state" | "status" | "uniqueName" | "lastMessage" | "notificationLevel" | "bindings";
|
1876
|
+
/**
|
1877
|
+
* Status of the conversation, relative to the client: whether the conversation
|
1878
|
+
* has been `joined` or the client is `notParticipating` in the conversation.
|
1879
|
+
*/
|
1880
|
+
type ConversationStatus = "notParticipating" | "joined";
|
1881
|
+
/**
|
1882
|
+
* User's notification level for the conversation. Determines
|
1883
|
+
* whether the currently logged-in user will receive pushes for events
|
1884
|
+
* in this conversation. Can be either `muted` or `default`, where
|
1885
|
+
* `default` defers to the global service push configuration.
|
1886
|
+
*/
|
1887
|
+
type NotificationLevel = "default" | "muted";
|
1888
|
+
/**
|
1889
|
+
* State of the conversation.
|
1890
|
+
*/
|
1891
|
+
interface ConversationState {
|
1892
|
+
/**
|
1893
|
+
* Current state.
|
1894
|
+
*/
|
1895
|
+
current: "active" | "inactive" | "closed";
|
1896
|
+
/**
|
1897
|
+
* Date at which the latest conversation state update happened.
|
1898
|
+
*/
|
1899
|
+
dateUpdated: Date;
|
1900
|
+
}
|
1901
|
+
/**
|
1902
|
+
* Event arguments for the `updated` event.
|
1903
|
+
*/
|
1904
|
+
interface ConversationUpdatedEventArgs {
|
1905
|
+
conversation: Conversation;
|
1906
|
+
updateReasons: ConversationUpdateReason[];
|
1907
|
+
}
|
1908
|
+
/**
|
1909
|
+
* Binding for email conversation.
|
1910
|
+
*/
|
1911
|
+
interface ConversationBindings {
|
1912
|
+
email?: ConversationEmailBinding;
|
1913
|
+
sms?: ConversationSmsBinding;
|
1914
|
+
}
|
1915
|
+
/**
|
1916
|
+
* Binding for email conversation.
|
1917
|
+
*/
|
1918
|
+
interface ConversationEmailBinding {
|
1919
|
+
name?: string;
|
1920
|
+
projected_address: string;
|
1921
|
+
}
|
1922
|
+
/**
|
1923
|
+
* Binding for SMS conversation.
|
1924
|
+
*/
|
1925
|
+
interface ConversationSmsBinding {
|
1926
|
+
address?: string;
|
1927
|
+
}
|
1928
|
+
/**
|
1929
|
+
* Configuration for attaching a media file to a message.
|
1930
|
+
* These options can be passed to {@link Conversation.sendMessage} and
|
1931
|
+
* {@link MessageBuilder.addMedia}.
|
1932
|
+
*/
|
1933
|
+
interface SendMediaOptions {
|
1934
|
+
/**
|
1935
|
+
* Content type of media.
|
1936
|
+
*/
|
1937
|
+
contentType: null | string;
|
1938
|
+
/**
|
1939
|
+
* Optional filename.
|
1940
|
+
*/
|
1941
|
+
filename?: string;
|
1942
|
+
/**
|
1943
|
+
* Content to post.
|
1944
|
+
*/
|
1945
|
+
media: null | string | Buffer | Blob;
|
1946
|
+
}
|
1947
|
+
/**
|
1948
|
+
* These options can be passed to {@link Conversation.sendMessage}.
|
1949
|
+
*/
|
1950
|
+
interface SendEmailOptions {
|
1951
|
+
/**
|
1952
|
+
* Message subject. Ignored for media messages.
|
1953
|
+
*/
|
1954
|
+
subject?: string;
|
1955
|
+
}
|
1956
|
+
/**
|
1957
|
+
* Information about the last message of a conversation.
|
1958
|
+
*/
|
1959
|
+
interface LastMessage {
|
1960
|
+
/**
|
1961
|
+
* Message's index.
|
1962
|
+
*/
|
1963
|
+
index?: number;
|
1964
|
+
/**
|
1965
|
+
* Message's creation date.
|
1966
|
+
*/
|
1967
|
+
dateCreated?: Date;
|
1968
|
+
}
|
1969
|
+
/**
|
1970
|
+
* Conversation services.
|
1971
|
+
*/
|
1972
|
+
interface ConversationServices {
|
1973
|
+
users: Users;
|
1974
|
+
typingIndicator: TypingIndicator;
|
1975
|
+
network: Network;
|
1976
|
+
mcsClient: McsClient;
|
1977
|
+
syncClient: SyncClient;
|
1978
|
+
commandExecutor: CommandExecutor;
|
1979
|
+
channelMetadataClient: ChannelMetadataClient;
|
1980
|
+
messageRecipientsClient: MessageRecipientsClient;
|
1981
|
+
}
|
1982
|
+
/**
|
1983
|
+
* Conversation descriptor.
|
1984
|
+
*/
|
1985
|
+
interface ConversationDescriptor {
|
1986
|
+
channel: string;
|
1987
|
+
entityName: string;
|
1988
|
+
uniqueName: string;
|
1989
|
+
attributes: JSONValue;
|
1990
|
+
createdBy?: string;
|
1991
|
+
friendlyName?: string;
|
1992
|
+
lastConsumedMessageIndex: number;
|
1993
|
+
dateCreated: Date | null;
|
1994
|
+
dateUpdated: Date | null;
|
1995
|
+
notificationLevel?: NotificationLevel;
|
1996
|
+
bindings?: ConversationBindings;
|
1997
|
+
}
|
1998
|
+
/**
|
1999
|
+
* Conversation links.
|
2000
|
+
*/
|
2001
|
+
interface ConversationLinks {
|
2002
|
+
self: string;
|
2003
|
+
messages: string;
|
2004
|
+
participants: string;
|
2005
|
+
}
|
2006
|
+
/**
|
2007
|
+
* A conversation represents communication between multiple Conversations
|
2008
|
+
* clients.
|
2009
|
+
*/
|
2010
|
+
declare class Conversation extends ReplayEventEmitter<ConversationEvents> {
|
2011
|
+
/**
|
2012
|
+
* Fired when a participant has joined the conversation.
|
2013
|
+
*
|
2014
|
+
* Parameters:
|
2015
|
+
* 1. {@link Participant} `participant` - participant that joined the
|
2016
|
+
* conversation
|
2017
|
+
* @event
|
2018
|
+
*/
|
2019
|
+
static readonly participantJoined = "participantJoined";
|
2020
|
+
/**
|
2021
|
+
* Fired when a participant has left the conversation.
|
2022
|
+
*
|
2023
|
+
* Parameters:
|
2024
|
+
* 1. {@link Participant} `participant` - participant that left the
|
2025
|
+
* conversation
|
2026
|
+
* @event
|
2027
|
+
*/
|
2028
|
+
static readonly participantLeft = "participantLeft";
|
2029
|
+
/**
|
2030
|
+
* Fired when data of a participant has been updated.
|
2031
|
+
*
|
2032
|
+
* Parameters:
|
2033
|
+
* 1. object `data` - info object provided with the event. It has the
|
2034
|
+
* following properties:
|
2035
|
+
* * {@link Participant} `participant` - participant that has received the
|
2036
|
+
* update
|
2037
|
+
* * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
|
2038
|
+
* for the update
|
2039
|
+
* @event
|
2040
|
+
*/
|
2041
|
+
static readonly participantUpdated = "participantUpdated";
|
2042
|
+
/**
|
2043
|
+
* Fired when a new message has been added to the conversation.
|
2044
|
+
*
|
2045
|
+
* Parameters:
|
2046
|
+
* 1. {@link Message} `message` - message that has been added
|
2047
|
+
* @event
|
2048
|
+
*/
|
2049
|
+
static readonly messageAdded = "messageAdded";
|
2050
|
+
/**
|
2051
|
+
* Fired when message is removed from the conversation's message list.
|
2052
|
+
*
|
2053
|
+
* Parameters:
|
2054
|
+
* 1. {@link Message} `message` - message that has been removed
|
2055
|
+
* @event
|
2056
|
+
*/
|
2057
|
+
static readonly messageRemoved = "messageRemoved";
|
2058
|
+
/**
|
2059
|
+
* Fired when data of a message has been updated.
|
2060
|
+
*
|
2061
|
+
* Parameters:
|
2062
|
+
* 1. object `data` - info object provided with the event. It has the
|
2063
|
+
* following properties:
|
2064
|
+
* * {@link Message} `message` - message that has received the update
|
2065
|
+
* * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
|
2066
|
+
* the update
|
2067
|
+
* @event
|
2068
|
+
*/
|
2069
|
+
static readonly messageUpdated = "messageUpdated";
|
2070
|
+
/**
|
2071
|
+
* Fired when a participant has stopped typing.
|
2072
|
+
*
|
2073
|
+
* Parameters:
|
2074
|
+
* 1. {@link Participant} `participant` - the participant that has stopped
|
2075
|
+
* typing
|
2076
|
+
* @event
|
2077
|
+
*/
|
2078
|
+
static readonly typingEnded = "typingEnded";
|
2079
|
+
/**
|
2080
|
+
* Fired when a participant has started typing.
|
2081
|
+
*
|
2082
|
+
* Parameters:
|
2083
|
+
* 1. {@link Participant} `participant` - the participant that has started
|
2084
|
+
* typing
|
2085
|
+
* @event
|
2086
|
+
*/
|
2087
|
+
static readonly typingStarted = "typingStarted";
|
2088
|
+
/**
|
2089
|
+
* Fired when the data of the conversation has been updated.
|
2090
|
+
*
|
2091
|
+
* Parameters:
|
2092
|
+
* 1. object `data` - info object provided with the event. It has the
|
2093
|
+
* following properties:
|
2094
|
+
* * {@link Conversation} `conversation` - conversation that has received
|
2095
|
+
* the update
|
2096
|
+
* * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
|
2097
|
+
* for the update
|
2098
|
+
* @event
|
2099
|
+
*/
|
2100
|
+
static readonly updated = "updated";
|
2101
|
+
/**
|
2102
|
+
* Fired when the conversation was destroyed or the currently-logged-in user
|
2103
|
+
* has left private conversation.
|
2104
|
+
*
|
2105
|
+
* Parameters:
|
2106
|
+
* 1. {@link Conversation} `conversation` - conversation that has been removed
|
2107
|
+
* @event
|
2108
|
+
*/
|
2109
|
+
static readonly removed = "removed";
|
2110
|
+
/**
|
2111
|
+
* Logger instance.
|
2112
|
+
*/
|
2113
|
+
private static readonly _logger;
|
2114
|
+
/**
|
2115
|
+
* Unique system identifier of the conversation.
|
2116
|
+
*/
|
2117
|
+
readonly sid: string;
|
2118
|
+
/**
|
2119
|
+
* Conversation links for REST requests.
|
2120
|
+
* @internal
|
2121
|
+
*/
|
2122
|
+
readonly _links: ConversationLinks;
|
2123
|
+
/**
|
2124
|
+
* Configuration of the client that the conversation belongs to.
|
2125
|
+
*/
|
2126
|
+
private readonly _configuration;
|
2127
|
+
/**
|
2128
|
+
* Conversation service objects.
|
2129
|
+
*/
|
2130
|
+
private readonly _services;
|
2131
|
+
/**
|
2132
|
+
* Internal state of the conversation.
|
2133
|
+
*/
|
2134
|
+
private readonly _internalState;
|
2135
|
+
/**
|
2136
|
+
* Name of the conversation entity document.
|
2137
|
+
*/
|
2138
|
+
private readonly _entityName;
|
2139
|
+
/**
|
2140
|
+
* Messages entity.
|
2141
|
+
*/
|
2142
|
+
private readonly _messagesEntity;
|
2143
|
+
/**
|
2144
|
+
* Sync list containing messages.
|
2145
|
+
*/
|
2146
|
+
private _messagesList?;
|
2147
|
+
/**
|
2148
|
+
* Map of participants.
|
2149
|
+
* @internal
|
2150
|
+
*/
|
2151
|
+
readonly _participants: Map<string, Participant>;
|
2152
|
+
/**
|
2153
|
+
* Participants entity.
|
2154
|
+
*/
|
2155
|
+
private readonly _participantsEntity;
|
2156
|
+
/**
|
2157
|
+
* Sync map containing participants.
|
2158
|
+
*/
|
2159
|
+
private _participantsMap?;
|
2160
|
+
/**
|
2161
|
+
* Source of the most recent update.
|
2162
|
+
*/
|
2163
|
+
private _dataSource;
|
2164
|
+
/**
|
2165
|
+
* Promise for the conversation entity document.
|
2166
|
+
*/
|
2167
|
+
private _entityPromise;
|
2168
|
+
/**
|
2169
|
+
* Conversation entity document.
|
2170
|
+
*/
|
2171
|
+
private _entity;
|
2172
|
+
/**
|
2173
|
+
* @param descriptor Conversation descriptor.
|
2174
|
+
* @param sid Conversation SID.
|
2175
|
+
* @param links Conversation links for REST requests.
|
2176
|
+
* @param configuration Client configuration.
|
2177
|
+
* @param services Conversation services.
|
2178
|
+
* @internal
|
2179
|
+
*/
|
2180
|
+
constructor(descriptor: ConversationDescriptor, sid: string, links: ConversationLinks, configuration: Configuration, services: ConversationServices);
|
2181
|
+
/**
|
2182
|
+
* Unique name of the conversation.
|
2183
|
+
*/
|
2184
|
+
get uniqueName(): string | null;
|
2185
|
+
/**
|
2186
|
+
* Status of the conversation.
|
2187
|
+
*/
|
2188
|
+
get status(): ConversationStatus;
|
2189
|
+
/**
|
2190
|
+
* Name of the conversation.
|
2191
|
+
*/
|
2192
|
+
get friendlyName(): string | null;
|
2193
|
+
/**
|
2194
|
+
* Date this conversation was last updated on.
|
2195
|
+
*/
|
2196
|
+
get dateUpdated(): Date | null;
|
2197
|
+
/**
|
2198
|
+
* Date this conversation was created on.
|
2199
|
+
*/
|
2200
|
+
get dateCreated(): Date | null;
|
2201
|
+
/**
|
2202
|
+
* Identity of the user that created this conversation.
|
2203
|
+
*/
|
2204
|
+
get createdBy(): string;
|
2205
|
+
/**
|
2206
|
+
* Custom attributes of the conversation.
|
2207
|
+
*/
|
2208
|
+
get attributes(): JSONValue;
|
2209
|
+
/**
|
2210
|
+
* Index of the last message the user has read in this conversation.
|
2211
|
+
*/
|
2212
|
+
get lastReadMessageIndex(): number | null;
|
2213
|
+
/**
|
2214
|
+
* Last message sent to this conversation.
|
2215
|
+
*/
|
2216
|
+
get lastMessage(): LastMessage | undefined;
|
2217
|
+
/**
|
2218
|
+
* User notification level for this conversation.
|
2219
|
+
*/
|
2220
|
+
get notificationLevel(): NotificationLevel;
|
2221
|
+
/**
|
2222
|
+
* Conversation bindings. An undocumented feature (for now).
|
2223
|
+
* @internal
|
2224
|
+
*/
|
2225
|
+
get bindings(): ConversationBindings;
|
2226
|
+
/**
|
2227
|
+
* Current conversation limits.
|
2228
|
+
*/
|
2229
|
+
get limits(): ConversationLimits;
|
2230
|
+
/**
|
2231
|
+
* State of the conversation.
|
2232
|
+
*/
|
2233
|
+
get state(): ConversationState | undefined;
|
2234
|
+
/**
|
2235
|
+
* Source of the conversation update.
|
2236
|
+
* @internal
|
2237
|
+
*/
|
2238
|
+
get _statusSource(): ConversationsDataSource;
|
2239
|
+
/**
|
2240
|
+
* Preprocess the update object.
|
2241
|
+
* @param update The update object received from Sync.
|
2242
|
+
* @param conversationSid The SID of the conversation in question.
|
2243
|
+
*/
|
2244
|
+
private static preprocessUpdate;
|
2245
|
+
/**
|
2246
|
+
* Add a participant to the conversation by its identity.
|
2247
|
+
* @param identity Identity of the Client to add.
|
2248
|
+
* @param attributes Attributes to be attached to the participant.
|
2249
|
+
* @returns The added participant.
|
2250
|
+
*/
|
2251
|
+
add(identity: string, attributes?: JSONValue): Promise<ParticipantResponse>;
|
2252
|
+
/**
|
2253
|
+
* Add a non-chat participant to the conversation.
|
2254
|
+
* @param proxyAddress Proxy (Twilio) address of the participant.
|
2255
|
+
* @param address User address of the participant.
|
2256
|
+
* @param attributes Attributes to be attached to the participant.
|
2257
|
+
* @param bindingOptions Options for adding email participants - name and
|
2258
|
+
* CC/To level.
|
2259
|
+
* @returns The added participant.
|
2260
|
+
*/
|
2261
|
+
addNonChatParticipant(proxyAddress: string, address: string, attributes?: JSONValue, bindingOptions?: ParticipantBindingOptions): Promise<ParticipantResponse>;
|
2262
|
+
/**
|
2263
|
+
* Advance the conversation's last read message index to the current read
|
2264
|
+
* horizon. Rejects if the user is not a participant of the conversation. Last
|
2265
|
+
* read message index is updated only if the new index value is higher than
|
2266
|
+
* the previous.
|
2267
|
+
* @param index Message index to advance to.
|
2268
|
+
* @return Resulting unread messages count in the conversation.
|
2269
|
+
*/
|
2270
|
+
advanceLastReadMessageIndex(index: number): Promise<number>;
|
2271
|
+
/**
|
2272
|
+
* Delete the conversation and unsubscribe from its events.
|
2273
|
+
*/
|
2274
|
+
delete(): Promise<Conversation>;
|
2275
|
+
/**
|
2276
|
+
* Get the custom attributes of this Conversation.
|
2277
|
+
*/
|
2278
|
+
getAttributes(): Promise<JSONValue>;
|
2279
|
+
/**
|
2280
|
+
* Returns messages from the conversation using the paginator interface.
|
2281
|
+
* @param pageSize Number of messages to return in a single chunk. Default is
|
2282
|
+
* 30.
|
2283
|
+
* @param anchor Index of the newest message to fetch. Default is from the
|
2284
|
+
* end.
|
2285
|
+
* @param direction Query direction. By default, it queries backwards
|
2286
|
+
* from newer to older. The `"forward"` value will query in the opposite
|
2287
|
+
* direction.
|
2288
|
+
* @return A page of messages.
|
2289
|
+
*/
|
2290
|
+
getMessages(pageSize?: number, anchor?: number, direction?: "backwards" | "forward"): Promise<Paginator<Message>>;
|
2291
|
+
/**
|
2292
|
+
* Get a list of all the participants who are joined to this conversation.
|
2293
|
+
*/
|
2294
|
+
getParticipants(): Promise<Participant[]>;
|
2295
|
+
/**
|
2296
|
+
* Get conversation participants count.
|
2297
|
+
*
|
2298
|
+
* This method is semi-realtime. This means that this data will be eventually
|
2299
|
+
* correct, but will also be possibly incorrect for a few seconds. The
|
2300
|
+
* Conversations system does not provide real time events for counter values
|
2301
|
+
* changes.
|
2302
|
+
*
|
2303
|
+
* This is useful for any UI badges, but it is not recommended to build any
|
2304
|
+
* core application logic based on these counters being accurate in real time.
|
2305
|
+
*/
|
2306
|
+
getParticipantsCount(): Promise<number>;
|
2307
|
+
/**
|
2308
|
+
* Get a participant by its SID.
|
2309
|
+
* @param participantSid Participant SID.
|
2310
|
+
*/
|
2311
|
+
getParticipantBySid(participantSid: string): Promise<Participant | null>;
|
2312
|
+
/**
|
2313
|
+
* Get a participant by its identity.
|
2314
|
+
* @param identity Participant identity.
|
2315
|
+
*/
|
2316
|
+
getParticipantByIdentity(identity?: string | null): Promise<Participant | null>;
|
2317
|
+
/**
|
2318
|
+
* Get the total message count in the conversation.
|
2319
|
+
*
|
2320
|
+
* This method is semi-realtime. This means that this data will be eventually
|
2321
|
+
* correct, but will also be possibly incorrect for a few seconds. The
|
2322
|
+
* Conversations system does not provide real time events for counter values
|
2323
|
+
* changes.
|
2324
|
+
*
|
2325
|
+
* This is useful for any UI badges, but it is not recommended to build any
|
2326
|
+
* core application logic based on these counters being accurate in real time.
|
2327
|
+
*/
|
2328
|
+
getMessagesCount(): Promise<number>;
|
2329
|
+
/**
|
2330
|
+
* Get count of unread messages for the user if they are a participant of this
|
2331
|
+
* conversation. Rejects if the user is not a participant of the conversation.
|
2332
|
+
*
|
2333
|
+
* Use this method to obtain the number of unread messages together with
|
2334
|
+
* {@link Conversation.updateLastReadMessageIndex} instead of relying on the
|
2335
|
+
* message indices which may have gaps. See {@link Message.index} for details.
|
2336
|
+
*
|
2337
|
+
* This method is semi-realtime. This means that this data will be eventually
|
2338
|
+
* correct, but it will also be possibly incorrect for a few seconds. The
|
2339
|
+
* Conversations system does not provide real time events for counter values
|
2340
|
+
* changes.
|
2341
|
+
*
|
2342
|
+
* This is useful for any UI badges, but it is not recommended to build any
|
2343
|
+
* core application logic based on these counters being accurate in real time.
|
2344
|
+
*
|
2345
|
+
* If the read horizon is not set, this function will return null. This could mean
|
2346
|
+
* that all messages in the conversation are unread, or that the read horizon system
|
2347
|
+
* is not being used. How to interpret this `null` value is up to the customer application.
|
2348
|
+
*
|
2349
|
+
* @return Number of unread messages based on the current read horizon set for
|
2350
|
+
* the user or `null` if the read horizon is not set.
|
2351
|
+
*/
|
2352
|
+
getUnreadMessagesCount(): Promise<number | null>;
|
2353
|
+
/**
|
2354
|
+
* Join the conversation and subscribe to its events.
|
2355
|
+
*/
|
2356
|
+
join(): Promise<Conversation>;
|
2357
|
+
/**
|
2358
|
+
* Leave the conversation.
|
2359
|
+
*/
|
2360
|
+
leave(): Promise<Conversation>;
|
2361
|
+
/**
|
2362
|
+
* Remove a participant from the conversation. When a string is passed as the
|
2363
|
+
* argument, it will assume that the string is an identity or SID.
|
2364
|
+
* @param participant Identity, SID or the participant object to remove.
|
2365
|
+
*/
|
2366
|
+
removeParticipant(participant: string | Participant): Promise<void>;
|
2367
|
+
/**
|
2368
|
+
* Send a message to the conversation.
|
2369
|
+
* @param message Message body for the text message,
|
2370
|
+
* `FormData` or {@link SendMediaOptions} for media content. Sending FormData
|
2371
|
+
* is supported only with the browser engine.
|
2372
|
+
* @param messageAttributes Attributes for the message.
|
2373
|
+
* @param emailOptions Email options for the message.
|
2374
|
+
* @return Index of the new message.
|
2375
|
+
*/
|
2376
|
+
sendMessage(message: null | string | FormData | SendMediaOptions, messageAttributes?: JSONValue, emailOptions?: SendEmailOptions): Promise<number>;
|
2377
|
+
/**
|
2378
|
+
* New interface to prepare for sending a message.
|
2379
|
+
* Use this instead of {@link Conversation.sendMessage}.
|
2380
|
+
* @return A MessageBuilder to help set all message sending options.
|
2381
|
+
*/
|
2382
|
+
prepareMessage(): MessageBuilder;
|
2383
|
+
/**
|
2384
|
+
* Set last read message index of the conversation to the index of the last
|
2385
|
+
* known message.
|
2386
|
+
* @return Resulting unread messages count in the conversation.
|
2387
|
+
*/
|
2388
|
+
setAllMessagesRead(): Promise<number>;
|
2389
|
+
/**
|
2390
|
+
* Set all messages in the conversation unread.
|
2391
|
+
* @returns New count of unread messages after this update.
|
2392
|
+
*/
|
2393
|
+
setAllMessagesUnread(): Promise<number>;
|
2394
|
+
/**
|
2395
|
+
* Set user notification level for this conversation.
|
2396
|
+
* @param notificationLevel New user notification level.
|
2397
|
+
*/
|
2398
|
+
setUserNotificationLevel(notificationLevel: NotificationLevel): Promise<void>;
|
2399
|
+
/**
|
2400
|
+
* Send a notification to the server indicating that this client is currently
|
2401
|
+
* typing in this conversation. Typing ended notification is sent after a
|
2402
|
+
* while automatically, but by calling this method again you ensure that
|
2403
|
+
* typing ended is not received.
|
2404
|
+
*/
|
2405
|
+
typing(): Promise<void>;
|
2406
|
+
/**
|
2407
|
+
* Update the attributes of the conversation.
|
2408
|
+
* @param attributes New attributes.
|
2409
|
+
*/
|
2410
|
+
updateAttributes(attributes: JSONValue): Promise<Conversation>;
|
2411
|
+
/**
|
2412
|
+
* Update the friendly name of the conversation.
|
2413
|
+
* @param friendlyName New friendly name.
|
2414
|
+
*/
|
2415
|
+
updateFriendlyName(friendlyName: string): Promise<Conversation>;
|
2416
|
+
/**
|
2417
|
+
* Set the last read message index to the current read horizon.
|
2418
|
+
* @param index Message index to set as last read. If null is provided, then
|
2419
|
+
* the behavior is identical to {@link Conversation.setAllMessagesUnread}.
|
2420
|
+
* @returns New count of unread messages after this update.
|
2421
|
+
*/
|
2422
|
+
updateLastReadMessageIndex(index: number | null): Promise<number>;
|
2423
|
+
/**
|
2424
|
+
* Update the unique name of the conversation.
|
2425
|
+
* @param uniqueName New unique name for the conversation. Setting unique name
|
2426
|
+
* to null removes it.
|
2427
|
+
*/
|
2428
|
+
updateUniqueName(uniqueName: string | null): Promise<Conversation>;
|
2429
|
+
/**
|
2430
|
+
* Get recipients of all messages in the conversation.
|
2431
|
+
* @param options Optional configuration, set pageSize to request a specific pagination page size. Page size specifies a number of messages to include in a single batch. Each message may include multiple recipients.
|
2432
|
+
*/
|
2433
|
+
getMessageRecipients(options?: PaginatorOptions): Promise<Paginator<RecipientDescriptor>>;
|
2434
|
+
/**
|
2435
|
+
* Load and subscribe to this conversation and do not subscribe to its
|
2436
|
+
* participants and messages. This or _subscribeStreams will need to be called
|
2437
|
+
* before any events in the conversation will fire.
|
2438
|
+
* @internal
|
2439
|
+
*/
|
2440
|
+
_subscribe(): Promise<SyncDocument>;
|
2441
|
+
/**
|
2442
|
+
* Fetch participants and messages of the conversation. This method needs to
|
2443
|
+
* be called during conversation initialization to catch broken conversations
|
2444
|
+
* (broken conversations are conversations that have essential Sync entities
|
2445
|
+
* missing, i.e. the conversation document, the messages list or the
|
2446
|
+
* participant map). In case of this conversation being broken, the method
|
2447
|
+
* will throw an exception that will be caught and handled gracefully.
|
2448
|
+
* @internal
|
2449
|
+
*/
|
2450
|
+
_fetchStreams(): Promise<void>;
|
2451
|
+
/**
|
2452
|
+
* Load the attributes of this conversation and instantiate its participants
|
2453
|
+
* and messages. This or _subscribe will need to be called before any events
|
2454
|
+
* on the conversation will fire. This will need to be called before any
|
2455
|
+
* events on participants or messages will fire
|
2456
|
+
* @internal
|
2457
|
+
*/
|
2458
|
+
_subscribeStreams(): Promise<void>;
|
2459
|
+
/**
|
2460
|
+
* Stop listening for and firing events on this conversation.
|
2461
|
+
* @internal
|
2462
|
+
*/
|
2463
|
+
_unsubscribe(): Promise<[
|
2464
|
+
void,
|
2465
|
+
void
|
2466
|
+
]>;
|
2467
|
+
/**
|
2468
|
+
* Set conversation status.
|
2469
|
+
* @internal
|
2470
|
+
*/
|
2471
|
+
_setStatus(status: ConversationStatus, source: ConversationsDataSource): void;
|
2472
|
+
/**
|
2473
|
+
* Update the local conversation object with new values.
|
2474
|
+
* @internal
|
2475
|
+
*/
|
2476
|
+
_update(update: any): void;
|
2477
|
+
/**
|
2478
|
+
* Handle onMessageAdded event.
|
2479
|
+
*/
|
2480
|
+
private _onMessageAdded;
|
2481
|
+
/**
|
2482
|
+
* Set last read message index.
|
2483
|
+
* @param index New index to set.
|
2484
|
+
*/
|
2485
|
+
private _setLastReadMessageIndex;
|
2486
|
+
}
|
2487
|
+
type ConversationsDataSource = "sync" | "rest";
|
2488
|
+
type PushNotificationType = "twilio.conversations.new_message" | "twilio.conversations.added_to_conversation" | "twilio.conversations.removed_from_conversation";
|
2489
|
+
interface PushNotificationDescriptor {
|
2490
|
+
title: string | null;
|
2491
|
+
body: string | null;
|
2492
|
+
sound: string | null;
|
2493
|
+
badge: number | null;
|
2494
|
+
action: string | null;
|
2495
|
+
type: PushNotificationType;
|
2496
|
+
data: Record<string, unknown>;
|
2497
|
+
}
|
2498
|
+
/**
|
2499
|
+
* Additional data for a given push notification.
|
2500
|
+
*/
|
2501
|
+
interface PushNotificationData {
|
2502
|
+
/**
|
2503
|
+
* SID of the conversation.
|
2504
|
+
*/
|
2505
|
+
conversationSid?: string;
|
2506
|
+
/**
|
2507
|
+
* Title of the conversation.
|
2508
|
+
*/
|
2509
|
+
conversationTitle?: string;
|
2510
|
+
/**
|
2511
|
+
* Index of the message in the conversation.
|
2512
|
+
*/
|
2513
|
+
messageIndex?: number;
|
2514
|
+
/**
|
2515
|
+
* SID of the message in the conversation.
|
2516
|
+
*/
|
2517
|
+
messageSid?: string;
|
2518
|
+
/**
|
2519
|
+
* Media of the notification
|
2520
|
+
*/
|
2521
|
+
media?: Media;
|
2522
|
+
/**
|
2523
|
+
* Count of the attached media of the message.
|
2524
|
+
*/
|
2525
|
+
mediaCount?: number;
|
2526
|
+
}
|
2527
|
+
/**
|
2528
|
+
* Push notification for a Conversations client.
|
2529
|
+
*/
|
2530
|
+
declare class PushNotification {
|
2531
|
+
/**
|
2532
|
+
* Title of the notification.
|
2533
|
+
*/
|
2534
|
+
readonly title: string | null;
|
2535
|
+
/**
|
2536
|
+
* Text of the notification.
|
2537
|
+
*/
|
2538
|
+
readonly body: string | null;
|
2539
|
+
/**
|
2540
|
+
* Sound of the notification.
|
2541
|
+
*/
|
2542
|
+
readonly sound: string | null;
|
2543
|
+
/**
|
2544
|
+
* Number of the badge.
|
2545
|
+
*/
|
2546
|
+
readonly badge: number | null;
|
2547
|
+
/**
|
2548
|
+
* Notification action (`click_action` in FCM terms and `category` in APN terms).
|
2549
|
+
*/
|
2550
|
+
readonly action: string | null;
|
2551
|
+
/**
|
2552
|
+
* Type of the notification.
|
2553
|
+
*/
|
2554
|
+
readonly type: PushNotificationType;
|
2555
|
+
/**
|
2556
|
+
* Additional data of the conversation.
|
2557
|
+
*/
|
2558
|
+
readonly data: PushNotificationData;
|
2559
|
+
/**
|
2560
|
+
* @internal
|
2561
|
+
*/
|
2562
|
+
constructor(data: PushNotificationDescriptor);
|
2563
|
+
}
|
2564
|
+
/**
|
2565
|
+
* Client events.
|
2566
|
+
*/
|
2567
|
+
type ClientEvents = {
|
2568
|
+
conversationAdded: (conversation: Conversation) => void;
|
2569
|
+
conversationJoined: (conversation: Conversation) => void;
|
2570
|
+
conversationLeft: (conversation: Conversation) => void;
|
2571
|
+
conversationRemoved: (conversation: Conversation) => void;
|
2572
|
+
conversationUpdated: (data: {
|
2573
|
+
conversation: Conversation;
|
2574
|
+
updateReasons: ConversationUpdateReason[];
|
2575
|
+
}) => void;
|
2576
|
+
participantJoined: (participant: Participant) => void;
|
2577
|
+
participantLeft: (participant: Participant) => void;
|
2578
|
+
participantUpdated: (data: {
|
2579
|
+
participant: Participant;
|
2580
|
+
updateReasons: ParticipantUpdateReason[];
|
2581
|
+
}) => void;
|
2582
|
+
messageAdded: (message: Message) => void;
|
2583
|
+
messageRemoved: (message: Message) => void;
|
2584
|
+
messageUpdated: (data: {
|
2585
|
+
message: Message;
|
2586
|
+
updateReasons: MessageUpdateReason[];
|
2587
|
+
}) => void;
|
2588
|
+
tokenAboutToExpire: () => void;
|
2589
|
+
tokenExpired: () => void;
|
2590
|
+
typingEnded: (participant: Participant) => void;
|
2591
|
+
typingStarted: (participant: Participant) => void;
|
2592
|
+
pushNotification: (pushNotification: PushNotification) => void;
|
2593
|
+
userSubscribed: (user: User) => void;
|
2594
|
+
userUnsubscribed: (user: User) => void;
|
2595
|
+
userUpdated: (data: {
|
2596
|
+
user: User;
|
2597
|
+
updateReasons: UserUpdateReason[];
|
2598
|
+
}) => void;
|
2599
|
+
stateChanged: (state: State) => void;
|
2600
|
+
initialized: () => void;
|
2601
|
+
initFailed: ({ error }: {
|
2602
|
+
error?: ConnectionError;
|
2603
|
+
}) => void;
|
2604
|
+
connectionStateChanged: (state: TwilsockConnectionState) => void;
|
2605
|
+
connectionError: (data: ConnectionError) => void;
|
2606
|
+
};
|
2607
|
+
/**
|
2608
|
+
* Connection state of the client. Possible values are as follows:
|
2609
|
+
* * `'connecting'` - client is offline and connection attempt is in process
|
2610
|
+
* * `'connected'` - client is online and ready
|
2611
|
+
* * `'disconnecting'` - client is going offline as disconnection is in process
|
2612
|
+
* * `'disconnected'` - client is offline and no connection attempt is in
|
2613
|
+
* process
|
2614
|
+
* * `'denied'` - client connection is denied because of invalid JWT access
|
2615
|
+
* token. User must refresh token in order to proceed
|
2616
|
+
*/
|
2617
|
+
type ConnectionState = TwilsockConnectionState;
|
2618
|
+
/**
|
2619
|
+
* State of the client. Possible values are as follows:
|
2620
|
+
* * `'failed'` - the client failed to initialize
|
2621
|
+
* * `'initialized'` - the client successfully initialized
|
2622
|
+
*/
|
2623
|
+
type State = "failed" | "initialized";
|
2624
|
+
/**
|
2625
|
+
* Notifications channel type. Possible values are as follows:
|
2626
|
+
* * `'fcm'`
|
2627
|
+
* * `'apn'`
|
2628
|
+
*/
|
2629
|
+
type NotificationsChannelType = ChannelType;
|
2630
|
+
/**
|
2631
|
+
* Level of logging.
|
2632
|
+
*/
|
2633
|
+
type LogLevel = "trace" | "debug" | "info" | "warn" | "error" | "silent";
|
2634
|
+
/**
|
2635
|
+
* Conversations client options.
|
2636
|
+
*/
|
2637
|
+
interface ClientOptions {
|
2638
|
+
/**
|
2639
|
+
* The level of logging to enable.
|
2640
|
+
*/
|
2641
|
+
logLevel?: LogLevel;
|
2642
|
+
/**
|
2643
|
+
* The cache capacity for channel metadata.
|
2644
|
+
*/
|
2645
|
+
channelMetadataCacheCapacity?: number;
|
2646
|
+
/**
|
2647
|
+
* The cache capacity for message recipients.
|
2648
|
+
*/
|
2649
|
+
messageRecipientsCacheCapacity?: number;
|
2650
|
+
region?: string;
|
2651
|
+
productId?: string;
|
2652
|
+
twilsockClient?: TwilsockClient;
|
2653
|
+
transport?: Transport;
|
2654
|
+
notificationsClient?: NotificationClient;
|
2655
|
+
syncClient?: SyncClient;
|
2656
|
+
typingIndicatorTimeoutOverride?: number;
|
2657
|
+
consumptionReportIntervalOverride?: string;
|
2658
|
+
httpCacheIntervalOverride?: string;
|
2659
|
+
userInfosToSubscribeOverride?: number;
|
2660
|
+
retryWhenThrottledOverride?: boolean;
|
2661
|
+
backoffConfigOverride?: Record<string, unknown>;
|
2662
|
+
Chat?: ClientOptions;
|
2663
|
+
IPMessaging?: ClientOptions;
|
2664
|
+
Sync?: Record<string, unknown>;
|
2665
|
+
Notification?: Record<string, unknown>;
|
2666
|
+
Twilsock?: Record<string, unknown>;
|
2667
|
+
clientMetadata?: Record<string, unknown>;
|
2668
|
+
initRegistrations?: InitRegistration[];
|
2669
|
+
disableDeepClone?: boolean;
|
2670
|
+
typingUri?: string;
|
2671
|
+
apiUri?: string;
|
2672
|
+
}
|
2673
|
+
type ConnectionError = {
|
2674
|
+
terminal: boolean;
|
2675
|
+
message: string;
|
2676
|
+
};
|
2677
|
+
/**
|
2678
|
+
* Options for {@link Client.createConversation}.
|
2679
|
+
*/
|
2680
|
+
interface CreateConversationOptions {
|
2681
|
+
/**
|
2682
|
+
* Any custom attributes to attach to the conversation.
|
2683
|
+
*/
|
2684
|
+
attributes?: JSONValue;
|
2685
|
+
/**
|
2686
|
+
* A non-unique display name of the conversation.
|
2687
|
+
*/
|
2688
|
+
friendlyName?: string;
|
2689
|
+
/**
|
2690
|
+
* A unique identifier of the conversation.
|
2691
|
+
*/
|
2692
|
+
uniqueName?: string;
|
2693
|
+
}
|
2694
|
+
/**
|
2695
|
+
* A client is the starting point to the Twilio Conversations functionality.
|
2696
|
+
*/
|
2697
|
+
declare class Client extends ReplayEventEmitter<ClientEvents> {
|
2698
|
+
/**
|
2699
|
+
* Fired when a conversation becomes visible to the client. The event is also
|
2700
|
+
* triggered when the client creates a new conversation.
|
2701
|
+
* Fired for all conversations that the client has joined.
|
2702
|
+
*
|
2703
|
+
* Parameters:
|
2704
|
+
* 1. {@link Conversation} `conversation` - the conversation in question
|
2705
|
+
* @event
|
2706
|
+
*/
|
2707
|
+
static readonly conversationAdded = "conversationAdded";
|
2708
|
+
/**
|
2709
|
+
* Fired when the client joins a conversation.
|
2710
|
+
*
|
2711
|
+
* Parameters:
|
2712
|
+
* 1. {@link Conversation} `conversation` - the conversation in question
|
2713
|
+
* @event
|
2714
|
+
*/
|
2715
|
+
static readonly conversationJoined = "conversationJoined";
|
2716
|
+
/**
|
2717
|
+
* Fired when the client leaves a conversation.
|
2718
|
+
*
|
2719
|
+
* Parameters:
|
2720
|
+
* 1. {@link Conversation} `conversation` - the conversation in question
|
2721
|
+
* @event
|
2722
|
+
*/
|
2723
|
+
static readonly conversationLeft = "conversationLeft";
|
2724
|
+
/**
|
2725
|
+
* Fired when a conversation is no longer visible to the client.
|
2726
|
+
*
|
2727
|
+
* Parameters:
|
2728
|
+
* 1. {@link Conversation} `conversation` - the conversation in question
|
2729
|
+
* @event
|
2730
|
+
*/
|
2731
|
+
static readonly conversationRemoved = "conversationRemoved";
|
2732
|
+
/**
|
2733
|
+
* Fired when the attributes or the metadata of a conversation have been
|
2734
|
+
* updated. During conversation's creation and initialization, this event
|
2735
|
+
* might be fired multiple times for same joined or created conversation as
|
2736
|
+
* new data is arriving from different sources.
|
2737
|
+
*
|
2738
|
+
* Parameters:
|
2739
|
+
* 1. object `data` - info object provided with the event. It has the
|
2740
|
+
* following properties:
|
2741
|
+
* * {@link Conversation} `conversation` - the conversation in question
|
2742
|
+
* * {@link ConversationUpdateReason}[] `updateReasons` - array of reasons
|
2743
|
+
* for the update
|
2744
|
+
* @event
|
2745
|
+
*/
|
2746
|
+
static readonly conversationUpdated = "conversationUpdated";
|
2747
|
+
/**
|
2748
|
+
* Fired when a participant has joined a conversation.
|
2749
|
+
*
|
2750
|
+
* Parameters:
|
2751
|
+
* 1. {@link Participant} `participant` - the participant in question
|
2752
|
+
* @event
|
2753
|
+
*/
|
2754
|
+
static readonly participantJoined = "participantJoined";
|
2755
|
+
/**
|
2756
|
+
* Fired when a participant has left a conversation.
|
2757
|
+
*
|
2758
|
+
* Parameters:
|
2759
|
+
* 1. {@link Participant} `participant` - the participant in question
|
2760
|
+
* @event
|
2761
|
+
*/
|
2762
|
+
static readonly participantLeft = "participantLeft";
|
2763
|
+
/**
|
2764
|
+
* Fired when a participant's fields have been updated.
|
2765
|
+
*
|
2766
|
+
* Parameters:
|
2767
|
+
* 1. object `data` - info object provided with the event. It has the
|
2768
|
+
* following properties:
|
2769
|
+
* * {@link Participant} `participant` - the participant in question
|
2770
|
+
* * {@link ParticipantUpdateReason}[] `updateReasons` - array of reasons
|
2771
|
+
* for the update
|
2772
|
+
* @event
|
2773
|
+
*/
|
2774
|
+
static readonly participantUpdated = "participantUpdated";
|
2775
|
+
/**
|
2776
|
+
* Fired when a new message has been added to the conversation on the server.
|
2777
|
+
*
|
2778
|
+
* Parameters:
|
2779
|
+
* 1. {@link Message} `message` - the message in question
|
2780
|
+
* @event
|
2781
|
+
*/
|
2782
|
+
static readonly messageAdded = "messageAdded";
|
2783
|
+
/**
|
2784
|
+
* Fired when a message is removed from the message list of a conversation.
|
2785
|
+
*
|
2786
|
+
* Parameters:
|
2787
|
+
* 1. {@link Message} `message` - the message in question
|
2788
|
+
* @event
|
2789
|
+
*/
|
2790
|
+
static readonly messageRemoved = "messageRemoved";
|
2791
|
+
/**
|
2792
|
+
* Fired when the fields of an existing message are updated with new values.
|
2793
|
+
*
|
2794
|
+
* Parameters:
|
2795
|
+
* 1. object `data` - info object provided with the event. It has the
|
2796
|
+
* following properties:
|
2797
|
+
* * {@link Message} `message` - the message in question
|
2798
|
+
* * {@link MessageUpdateReason}[] `updateReasons` - array of reasons for
|
2799
|
+
* the update
|
2800
|
+
* @event
|
2801
|
+
*/
|
2802
|
+
static readonly messageUpdated = "messageUpdated";
|
2803
|
+
/**
|
2804
|
+
* Fired when the token is about to expire and needs to be updated.
|
2805
|
+
* @event
|
2806
|
+
*/
|
2807
|
+
static readonly tokenAboutToExpire = "tokenAboutToExpire";
|
2808
|
+
/**
|
2809
|
+
* Fired when the token has expired.
|
2810
|
+
* @event
|
2811
|
+
*/
|
2812
|
+
static readonly tokenExpired = "tokenExpired";
|
2813
|
+
/**
|
2814
|
+
* Fired when a participant has stopped typing.
|
2815
|
+
*
|
2816
|
+
* Parameters:
|
2817
|
+
* 1. {@link Participant} `participant` - the participant in question
|
2818
|
+
* @event
|
2819
|
+
*/
|
2820
|
+
static readonly typingEnded = "typingEnded";
|
2821
|
+
/**
|
2822
|
+
* Fired when a participant has started typing.
|
2823
|
+
*
|
2824
|
+
* Parameters:
|
2825
|
+
* 1. {@link Participant} `participant` - the participant in question
|
2826
|
+
* @event
|
2827
|
+
*/
|
2828
|
+
static readonly typingStarted = "typingStarted";
|
2829
|
+
/**
|
2830
|
+
* Fired when the client has received (and parsed) a push notification via one
|
2831
|
+
* of the push channels (apn or fcm).
|
2832
|
+
*
|
2833
|
+
* Parameters:
|
2834
|
+
* 1. {@link PushNotification} `pushNotification` - the push notification in
|
2835
|
+
* question
|
2836
|
+
* @event
|
2837
|
+
*/
|
2838
|
+
static readonly pushNotification = "pushNotification";
|
2839
|
+
/**
|
2840
|
+
* Fired when the client has subscribed to a user.
|
2841
|
+
*
|
2842
|
+
* Parameters:
|
2843
|
+
* 1. {@link User} `user` - the user in question
|
2844
|
+
* @event
|
2845
|
+
*/
|
2846
|
+
static readonly userSubscribed = "userSubscribed";
|
2847
|
+
/**
|
2848
|
+
* Fired when the client has unsubscribed from a user.
|
2849
|
+
*
|
2850
|
+
* Parameters:
|
2851
|
+
* 1. {@link User} `user` - the user in question
|
2852
|
+
* @event
|
2853
|
+
*/
|
2854
|
+
static readonly userUnsubscribed = "userUnsubscribed";
|
2855
|
+
/**
|
2856
|
+
* Fired when the properties or the reachability status of a user have been
|
2857
|
+
* updated.
|
2858
|
+
*
|
2859
|
+
* Parameters:
|
2860
|
+
* 1. object `data` - info object provided with the event. It has the
|
2861
|
+
* following properties:
|
2862
|
+
* * {@link User} `user` - the user in question
|
2863
|
+
* * {@link UserUpdateReason}[] `updateReasons` - array of reasons for the
|
2864
|
+
* update
|
2865
|
+
* @event
|
2866
|
+
*/
|
2867
|
+
static readonly userUpdated = "userUpdated";
|
2868
|
+
/**
|
2869
|
+
* @deprecated Use initialized or initFailed events instead
|
2870
|
+
* Fired when the state of the client has been changed.
|
2871
|
+
*
|
2872
|
+
* Parameters:
|
2873
|
+
* 1. {@link State} `state` - the new client state
|
2874
|
+
* @event
|
2875
|
+
*/
|
2876
|
+
static readonly stateChanged = "stateChanged";
|
2877
|
+
/**
|
2878
|
+
* Fired when the client has completed initialization successfully.
|
2879
|
+
* @event
|
2880
|
+
*/
|
2881
|
+
static readonly initialized = "initialized";
|
2882
|
+
/**
|
2883
|
+
* Fired when the client initialization failed.
|
2884
|
+
*
|
2885
|
+
* Parameters:
|
2886
|
+
* 1. object `data` - info object provided with the event. It has the
|
2887
|
+
* following property:
|
2888
|
+
* * Error? `error` - the initialization error if present
|
2889
|
+
* @event
|
2890
|
+
*/
|
2891
|
+
static readonly initFailed = "initFailed";
|
2892
|
+
/**
|
2893
|
+
* Fired when the connection state of the client has been changed.
|
2894
|
+
*
|
2895
|
+
* Parameters:
|
2896
|
+
* 1. {@link ConnectionState} `state` - the new connection state
|
2897
|
+
* @event
|
2898
|
+
*/
|
2899
|
+
static readonly connectionStateChanged = "connectionStateChanged";
|
2900
|
+
/**
|
2901
|
+
* Fired when the connection is interrupted for an unexpected reason.
|
2902
|
+
*
|
2903
|
+
* Parameters:
|
2904
|
+
* 1. object `data` - info object provided with the event. It has the
|
2905
|
+
* following properties:
|
2906
|
+
* * boolean `terminal` - Twilsock will stop connection attempts if true
|
2907
|
+
* * string `message` - the error message of the root cause
|
2908
|
+
* * number? `httpStatusCode` - http status code if available
|
2909
|
+
* * number? `errorCode` - Twilio public error code if available
|
2910
|
+
* @event
|
2911
|
+
*/
|
2912
|
+
static readonly connectionError = "connectionError";
|
2913
|
+
/**
|
2914
|
+
* Current version of the Conversations client.
|
2915
|
+
*/
|
2916
|
+
static readonly version: string;
|
2917
|
+
/**
|
2918
|
+
* Logger instance.
|
2919
|
+
*/
|
2920
|
+
private static readonly _logger;
|
2921
|
+
/**
|
2922
|
+
* Supported push notification channels.
|
2923
|
+
*/
|
2924
|
+
private static readonly _supportedPushChannels;
|
2925
|
+
/**
|
2926
|
+
* Supported push data fields.
|
2927
|
+
*/
|
2928
|
+
private static readonly _supportedPushDataFields;
|
2929
|
+
/**
|
2930
|
+
* Current version of the Conversations client.
|
2931
|
+
*/
|
2932
|
+
readonly version: string;
|
2933
|
+
/**
|
2934
|
+
* Client connection state.
|
2935
|
+
*/
|
2936
|
+
connectionState: ConnectionState;
|
2937
|
+
/**
|
2938
|
+
* Promise that resolves on successful initialization.
|
2939
|
+
*/
|
2940
|
+
private readonly _ensureReady;
|
2941
|
+
/**
|
2942
|
+
* Options passed to the client.
|
2943
|
+
*/
|
2944
|
+
private readonly _options;
|
2945
|
+
/**
|
2946
|
+
* Client service objects.
|
2947
|
+
*/
|
2948
|
+
private readonly _services;
|
2949
|
+
/**
|
2950
|
+
* The user of the client.
|
2951
|
+
*/
|
2952
|
+
private readonly _myself;
|
2953
|
+
/**
|
2954
|
+
* Resolves the {@link Client._ensureReady} promise.
|
2955
|
+
*/
|
2956
|
+
private _resolveEnsureReady;
|
2957
|
+
/**
|
2958
|
+
* Rejects the {@link Client._ensureReady} promise.
|
2959
|
+
*/
|
2960
|
+
private _rejectEnsureReady;
|
2961
|
+
/**
|
2962
|
+
* The current token of the client.
|
2963
|
+
*/
|
2964
|
+
private _fpaToken;
|
2965
|
+
/**
|
2966
|
+
* The constructed configuration object.
|
2967
|
+
*/
|
2968
|
+
private _configuration;
|
2969
|
+
/**
|
2970
|
+
* The Conversations entity.
|
2971
|
+
*/
|
2972
|
+
private _conversationsEntity;
|
2973
|
+
/**
|
2974
|
+
* Promise that resolves when initial conversations are fetched.
|
2975
|
+
*/
|
2976
|
+
private _conversationsPromise;
|
2977
|
+
/**
|
2978
|
+
* Returned Conversations Client instance is not yet fully initialized. Calling any
|
2979
|
+
* operations will block until it is. Use connection events to monitor when
|
2980
|
+
* client becomes fully available (connectionStateChanged with state
|
2981
|
+
* 'connected') or not available (connectionStateChange with state 'denied',
|
2982
|
+
* event tokenExpired, event connectionError).
|
2983
|
+
*
|
2984
|
+
* @param fpaToken Access token
|
2985
|
+
* @param options Options to customize the Client
|
2986
|
+
* @returns A not yet fully-initialized client.
|
2987
|
+
*/
|
2988
|
+
constructor(fpaToken: string, options?: ClientOptions | null);
|
2989
|
+
/**
|
2990
|
+
* Information of the logged-in user. Before client initialization, returns an
|
2991
|
+
* uninitialized user. Will trigger a {@link Client.userUpdated} event after
|
2992
|
+
* initialization.
|
2993
|
+
*/
|
2994
|
+
get user(): User;
|
2995
|
+
/**
|
2996
|
+
* Client reachability state. Throws an error if accessed before the client
|
2997
|
+
* initialization was completed.
|
2998
|
+
*/
|
2999
|
+
get reachabilityEnabled(): boolean;
|
3000
|
+
/**
|
3001
|
+
* @deprecated
|
3002
|
+
* Current token.
|
3003
|
+
* @internal
|
3004
|
+
*/
|
3005
|
+
get token(): string;
|
3006
|
+
/**
|
3007
|
+
* @deprecated Call constructor directly.
|
3008
|
+
*
|
3009
|
+
* Factory method to create a Conversations client instance.
|
3010
|
+
*
|
3011
|
+
* The factory method will automatically trigger connection.
|
3012
|
+
* Do not use it if you need finer-grained control.
|
3013
|
+
*
|
3014
|
+
* Since this method returns an already-initialized client, some of the events
|
3015
|
+
* will be lost because they happen *before* the initialization. It is
|
3016
|
+
* recommended that `client.onWithReplay` is used as opposed to `client.on`
|
3017
|
+
* for subscribing to client events. The `client.onWithReplay` will re-emit
|
3018
|
+
* the most recent value for a given event if it emitted before the
|
3019
|
+
* subscription.
|
3020
|
+
*
|
3021
|
+
* @param token Access token.
|
3022
|
+
* @param options Options to customize the client.
|
3023
|
+
* @returns Returns a fully initialized client.
|
3024
|
+
*/
|
3025
|
+
static create(token: string, options?: ClientOptions | null): Promise<Client>;
|
3026
|
+
/**
|
3027
|
+
* Static method for push notification payload parsing. Returns parsed push as
|
3028
|
+
* a {@link PushNotification} object.
|
3029
|
+
* @param notificationPayload Push notification payload.
|
3030
|
+
*/
|
3031
|
+
static parsePushNotification(notificationPayload: any): PushNotification;
|
3032
|
+
/**
|
3033
|
+
* Static method for parsing push notification chat data.
|
3034
|
+
* @param data Data to parse
|
3035
|
+
*/
|
3036
|
+
private static _parsePushNotificationChatData;
|
3037
|
+
/**
|
3038
|
+
* Populate the client with init registrations.
|
3039
|
+
* @param reg The init registration to populate.
|
3040
|
+
*/
|
3041
|
+
static populateInitRegistrations(reg: InitRegistration): void;
|
3042
|
+
/**
|
3043
|
+
* Gracefully shut down the client.
|
3044
|
+
*/
|
3045
|
+
shutdown(): Promise<void>;
|
3046
|
+
/**
|
3047
|
+
* Update the token used by the client and re-register with the Conversations services.
|
3048
|
+
* @param token New access token.
|
3049
|
+
*/
|
3050
|
+
updateToken(token: string): Promise<Client>;
|
3051
|
+
/**
|
3052
|
+
* Get a known conversation by its SID.
|
3053
|
+
* @param conversationSid Conversation sid
|
3054
|
+
*/
|
3055
|
+
getConversationBySid(conversationSid: string): Promise<Conversation>;
|
3056
|
+
/**
|
3057
|
+
* Peek a conversation by its SID.
|
3058
|
+
* @param conversationSid Conversation sid
|
3059
|
+
* @internal
|
3060
|
+
*/
|
3061
|
+
peekConversationBySid(conversationSid: string): Promise<Conversation>;
|
3062
|
+
/**
|
3063
|
+
* Get a known conversation by its unique identifier name.
|
3064
|
+
* @param uniqueName The unique identifier name of the conversation.
|
3065
|
+
*/
|
3066
|
+
getConversationByUniqueName(uniqueName: string): Promise<Conversation>;
|
3067
|
+
/**
|
3068
|
+
* Get the current list of all the subscribed conversations.
|
3069
|
+
*/
|
3070
|
+
getSubscribedConversations(): Promise<Paginator<Conversation>>;
|
3071
|
+
/**
|
3072
|
+
* Create a conversation on the server and subscribe to its events.
|
3073
|
+
* The default is a conversation with an empty friendly name.
|
3074
|
+
* @param options Options for the conversation.
|
3075
|
+
*/
|
3076
|
+
createConversation(options?: CreateConversationOptions): Promise<Conversation>;
|
3077
|
+
/**
|
3078
|
+
* Register for push notifications.
|
3079
|
+
* @param channelType Channel type.
|
3080
|
+
* @param registrationId Push notification ID provided by the FCM/APNS service
|
3081
|
+
* on the platform.
|
3082
|
+
*/
|
3083
|
+
setPushRegistrationId(channelType: NotificationsChannelType, registrationId: string): Promise<void>;
|
3084
|
+
/**
|
3085
|
+
* Unregister from push notifications.
|
3086
|
+
* @param channelType Channel type.
|
3087
|
+
* @deprecated Use removePushRegistrations() instead.
|
3088
|
+
*/
|
3089
|
+
unsetPushRegistrationId(channelType: NotificationsChannelType): Promise<void>;
|
3090
|
+
/**
|
3091
|
+
* Clear existing registrations directly using provided device token.
|
3092
|
+
* This is useful to ensure stopped subscriptions without resubscribing.
|
3093
|
+
*
|
3094
|
+
* This function goes completely beside the state machine and removes all
|
3095
|
+
* registrations.
|
3096
|
+
* Use with caution: if it races with current state machine operations,
|
3097
|
+
* madness will ensue.
|
3098
|
+
*
|
3099
|
+
* @param channelType Channel type.
|
3100
|
+
* @param registrationId Push notification ID provided by the FCM/APNS service
|
3101
|
+
* on the platform.
|
3102
|
+
*/
|
3103
|
+
removePushRegistrations(channelType: ChannelType, registrationId: string): Promise<void>;
|
3104
|
+
/**
|
3105
|
+
* Parse a push notification payload.
|
3106
|
+
*/
|
3107
|
+
parsePushNotification: typeof Client.parsePushNotification;
|
3108
|
+
/**
|
3109
|
+
* Handle push notification payload parsing and emit the
|
3110
|
+
* {@link Client.pushNotification} event on this {@link Client} instance.
|
3111
|
+
* @param notificationPayload Push notification payload
|
3112
|
+
*/
|
3113
|
+
handlePushNotification(notificationPayload: any): Promise<void>;
|
3114
|
+
/**
|
3115
|
+
* Gets a user with the given identity. If it's in the subscribed list, then
|
3116
|
+
* return the user object from it;
|
3117
|
+
* if not, then subscribe and add user to the subscribed list.
|
3118
|
+
* @param identity Identity of the user.
|
3119
|
+
* @returns A fully initialized user.
|
3120
|
+
*/
|
3121
|
+
getUser(identity: string): Promise<User>;
|
3122
|
+
/**
|
3123
|
+
* Get a list of subscribed user objects.
|
3124
|
+
*/
|
3125
|
+
getSubscribedUsers(): Promise<Array<User>>;
|
3126
|
+
/**
|
3127
|
+
* Get content URLs for all media attachments in the given set of media sids
|
3128
|
+
* using a single operation.
|
3129
|
+
* @param mediaSids Set of media sids to query for the content URL.
|
3130
|
+
*/
|
3131
|
+
getTemporaryContentUrlsForMediaSids(mediaSids: string[]): CancellablePromise<Map<string, string>>;
|
3132
|
+
/**
|
3133
|
+
* Get content URLs for all media attachments in the given set using a single
|
3134
|
+
* operation.
|
3135
|
+
* @param contentSet Set of media attachments to query content URLs.
|
3136
|
+
*/
|
3137
|
+
getTemporaryContentUrlsForMedia(contentSet: Media[]): CancellablePromise<Map<string, string>>;
|
3138
|
+
/**
|
3139
|
+
* Returns rich content templates belonging to the account. Rich content
|
3140
|
+
* templates can be created via the Twilio console or the REST API.
|
3141
|
+
*/
|
3142
|
+
getContentTemplates(): Promise<Readonly<ContentTemplate[]>>;
|
3143
|
+
/**
|
3144
|
+
* Initialize the client.
|
3145
|
+
*/
|
3146
|
+
private _initialize;
|
3147
|
+
/**
|
3148
|
+
* Subscribe to push notifications.
|
3149
|
+
* @param channelType The channel type to subscribe to.
|
3150
|
+
*/
|
3151
|
+
private _subscribeToPushNotifications;
|
3152
|
+
/**
|
3153
|
+
* Unsubscribe from push notifications.
|
3154
|
+
* @param channelType The channel type to unsubscribe from.
|
3155
|
+
*/
|
3156
|
+
private _unsubscribeFromPushNotifications;
|
3157
|
+
}
|
3158
|
+
declare class NotificationTypes {
|
3159
|
+
static readonly TYPING_INDICATOR = "twilio.ipmsg.typing_indicator";
|
3160
|
+
static readonly NEW_MESSAGE = "twilio.conversations.new_message";
|
3161
|
+
static readonly ADDED_TO_CONVERSATION = "twilio.conversations.added_to_conversation";
|
3162
|
+
// static readonly INVITED_TO_CHANNEL = 'twilio.channel.invited_to_channel';
|
3163
|
+
static readonly REMOVED_FROM_CONVERSATION = "twilio.conversations.removed_from_conversation";
|
3164
|
+
static readonly CONSUMPTION_UPDATE = "twilio.channel.consumption_update";
|
3165
|
+
}
|
3166
|
+
export { Conversation, ConversationBindings, ConversationEmailBinding, ConversationUpdateReason, ConversationStatus, NotificationLevel, ConversationState, ConversationUpdatedEventArgs, SendMediaOptions, SendEmailOptions, LastMessage, Participant, ParticipantUpdateReason, ParticipantType, ParticipantUpdatedEventArgs, ParticipantBindings, ParticipantEmailBinding, ParticipantEmailLevel, Message, MessageUpdateReason, MessageType, MessageUpdatedEventArgs, Media, MediaCategory$0 as MediaCategory, AggregatedDeliveryReceipt, DeliveryAmount, DetailedDeliveryReceipt, DeliveryStatus, RestPaginator, MessageBuilder, UnsentMessage, Paginator, ParticipantBindingOptions, User, UserUpdateReason, UserUpdatedEventArgs, PushNotification, PushNotificationType, PushNotificationDescriptor, PushNotificationData, NotificationTypes, Client, State, ConnectionState, NotificationsChannelType, ClientOptions, CreateConversationOptions, ConversationLimits, JSONValue, JSONObject, JSONArray, CancellablePromise, ContentDataActionUrl, ContentDataActionPhone, ContentDataActionReply, ContentDataActionOther, ContentDataAction, ContentDataText, ContentDataMedia, ContentDataLocation, ContentDataReply, ContentDataQuickReply, ContentDataCallToAction, ContentDataListPicker, ContentDataListItem, ContentDataCard, ContentDataOther, ContentData, ContentTemplate, ContentTemplateVariable, ChannelMetadata, RecipientDescriptor, EmailRecipientDescriptor, UnknownRecipientDescriptor, EmailRecipientLevel };
|